|
1 | 1 | import * as ReactDOM from 'react-dom';
|
2 | 2 | import { SIDE } from './constants';
|
3 |
| -import * as React from 'react'; |
4 |
| -import { ApplicationLauncherSeparator } from '../components/ApplicationLauncher/ApplicationLauncherSeparator'; |
5 |
| -import { Divider } from '../components/Divider/Divider'; |
6 | 3 |
|
7 | 4 | /**
|
8 | 5 | * @param {string} input - String to capitalize first letter
|
@@ -277,84 +274,6 @@ export const toCamel = (s: string) => s.replace(/([-_][a-z])/gi, camelize);
|
277 | 274 | */
|
278 | 275 | export const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
279 | 276 |
|
280 |
| -/** |
281 |
| - * This function is a helper for creating an array of renderable favorite items for the Application launcher or Select |
282 |
| - * |
283 |
| - * @param {object} items The items rendered in Select or Application aLauncher |
284 |
| - * @param {boolean} isGrouped Flag indicating if items are grouped |
285 |
| - * @param {any[]} favorites Array of ids of favorited items |
286 |
| - * @param {boolean} isEnterTriggersArrowDown Flag indicating if we should add isEnterTriggersArrowDown to favorited item |
287 |
| - */ |
288 |
| -export const createRenderableFavorites = ( |
289 |
| - items: object, |
290 |
| - isGrouped: boolean, |
291 |
| - favorites: any[], |
292 |
| - isEnterTriggersArrowDown?: boolean |
293 |
| -) => { |
294 |
| - if (isGrouped) { |
295 |
| - const favoriteItems: React.ReactNode[] = []; |
296 |
| - (items as React.ReactElement[]).forEach(group => { |
297 |
| - if (favorites.length > 0) { |
298 |
| - return ( |
299 |
| - group.props.children && |
300 |
| - (group.props.children as React.ReactElement[]) |
301 |
| - .filter(item => favorites.includes(item.props.id)) |
302 |
| - .map(item => { |
303 |
| - if (isEnterTriggersArrowDown) { |
304 |
| - return favoriteItems.push( |
305 |
| - React.cloneElement(item, { |
306 |
| - isFavorite: true, |
307 |
| - enterTriggersArrowDown: isEnterTriggersArrowDown, |
308 |
| - id: `favorite-${item.props.id}` |
309 |
| - }) |
310 |
| - ); |
311 |
| - } else { |
312 |
| - return favoriteItems.push( |
313 |
| - React.cloneElement(item, { isFavorite: true, id: `favorite-${item.props.id}` }) |
314 |
| - ); |
315 |
| - } |
316 |
| - }) |
317 |
| - ); |
318 |
| - } |
319 |
| - }); |
320 |
| - return favoriteItems; |
321 |
| - } |
322 |
| - return (items as React.ReactElement[]) |
323 |
| - .filter(item => favorites.includes(item.props.id)) |
324 |
| - .map(item => React.cloneElement(item, { isFavorite: true, enterTriggersArrowDown: isEnterTriggersArrowDown })); |
325 |
| -}; |
326 |
| - |
327 |
| -/** |
328 |
| - * This function is a helper for extending the array of renderable favorite with the select/application launcher items to render in the Application launcher or Select |
329 |
| - * |
330 |
| - * @param {object} items The items rendered in Select or Application aLauncher |
331 |
| - * @param {boolean} isGrouped Flag indicating if items are grouped |
332 |
| - * @param {any[]} favorites Array of ids of favorited items |
333 |
| - */ |
334 |
| -export const extendItemsWithFavorite = (items: object, isGrouped: boolean, favorites: any[]) => { |
335 |
| - if (isGrouped) { |
336 |
| - return (items as React.ReactElement[]).map(group => |
337 |
| - React.cloneElement(group, { |
338 |
| - children: React.Children.map(group.props.children as React.ReactElement[], item => { |
339 |
| - if (item.type === ApplicationLauncherSeparator || item.type === Divider) { |
340 |
| - return item; |
341 |
| - } |
342 |
| - return React.cloneElement(item, { |
343 |
| - isFavorite: favorites.some( |
344 |
| - favoriteId => favoriteId === item.props.id || `favorite-${favoriteId}` === item.props.id |
345 |
| - ) |
346 |
| - }); |
347 |
| - }) |
348 |
| - }) |
349 |
| - ); |
350 |
| - } |
351 |
| - return (items as React.ReactElement[]).map(item => |
352 |
| - React.cloneElement(item, { |
353 |
| - isFavorite: favorites.some(favoriteId => favoriteId === item.props.id) |
354 |
| - }) |
355 |
| - ); |
356 |
| -}; |
357 |
| - |
358 | 277 | /**
|
359 | 278 | * Calculate the width of the text
|
360 | 279 | * Example:
|
|
0 commit comments