@rio-cloud/rio-uikit 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/actionBarItem/ActionBarItem.d.ts +2 -2
- package/components/actionBarItem/ActionBarItem.js.map +1 -1
- package/components/applicationHeader/ApplicationHeader.d.ts +6 -7
- package/components/applicationHeader/ApplicationHeader.js.map +1 -1
- package/components/applicationLayout/SubNavigation.d.ts +7 -0
- package/components/applicationLayout/SubNavigation.js.map +1 -1
- package/components/assetTree/AssetTree.d.ts +7 -0
- package/components/assetTree/AssetTree.js.map +1 -1
- package/components/assetTree/Tree.d.ts +15 -0
- package/components/assetTree/Tree.js.map +1 -1
- package/components/assetTree/TreeIcon.d.ts +30 -0
- package/components/assetTree/TreeIcon.js +16 -0
- package/components/assetTree/TreeIcon.js.map +1 -0
- package/components/assetTree/TreeLeaf.js +22 -22
- package/components/assetTree/TreeLeaf.js.map +1 -1
- package/components/assetTree/TreeNode.js +25 -25
- package/components/assetTree/TreeNode.js.map +1 -1
- package/components/assetTree/TreeSearch.d.ts +2 -0
- package/components/assetTree/TreeSearch.js.map +1 -1
- package/components/barList/BarList.d.ts +26 -0
- package/components/barList/BarList.js.map +1 -1
- package/components/bottomSheet/BottomSheet.d.ts +17 -3
- package/components/bottomSheet/BottomSheet.js.map +1 -1
- package/components/bottomSheet/TimedBottomSheet.d.ts +10 -0
- package/components/bottomSheet/TimedBottomSheet.js.map +1 -1
- package/components/calendarStripe/CalendarStripe.d.ts +1 -1
- package/components/calendarStripe/CalendarStripe.js +34 -36
- package/components/calendarStripe/CalendarStripe.js.map +1 -1
- package/components/charts/Area.d.ts +2 -2
- package/components/charts/Area.js.map +1 -1
- package/components/charts/Line.d.ts +2 -2
- package/components/charts/Line.js.map +1 -1
- package/components/checkbox/Checkbox.d.ts +0 -3
- package/components/checkbox/Checkbox.js.map +1 -1
- package/components/clearableInput/ClearableInput.d.ts +21 -20
- package/components/clearableInput/ClearableInput.js.map +1 -1
- package/components/collapse/Collapse.d.ts +3 -0
- package/components/collapse/Collapse.js +12 -12
- package/components/collapse/Collapse.js.map +1 -1
- package/components/contentLoader/ContentLoader.d.ts +10 -2
- package/components/contentLoader/ContentLoader.js.map +1 -1
- package/components/dataTabs/DataTabs.d.ts +6 -0
- package/components/dataTabs/DataTabs.js.map +1 -1
- package/components/datepicker/DatePicker.d.ts +2 -2
- package/components/datepicker/DatePicker.js +31 -31
- package/components/datepicker/DatePicker.js.map +1 -1
- package/components/dialog/ConfirmationDialog.d.ts +22 -0
- package/components/dialog/ConfirmationDialog.js.map +1 -1
- package/components/dialog/Dialog.d.ts +13 -1
- package/components/dialog/Dialog.js.map +1 -1
- package/components/dialog/ReleaseNotesDialog.d.ts +3 -3
- package/components/dialog/ReleaseNotesDialog.js.map +1 -1
- package/components/dropdown/ButtonDropdown.d.ts +4 -0
- package/components/dropdown/ButtonDropdown.js +51 -51
- package/components/dropdown/ButtonDropdown.js.map +1 -1
- package/components/dropdown/DropdownSubmenu.d.ts +4 -0
- package/components/dropdown/DropdownSubmenu.js.map +1 -1
- package/components/editableContent/EditableContent.d.ts +6 -0
- package/components/editableContent/EditableContent.js.map +1 -1
- package/components/expander/ExpanderList.d.ts +3 -0
- package/components/expander/ExpanderList.js.map +1 -1
- package/components/expander/ExpanderPanel.d.ts +14 -4
- package/components/expander/ExpanderPanel.js.map +1 -1
- package/components/fade/Fade.d.ts +1 -1
- package/components/fade/Fade.js.map +1 -1
- package/components/filepicker/FilePicker.d.ts +0 -2
- package/components/filepicker/FilePicker.js.map +1 -1
- package/components/groupedItemList/GroupedItemList.d.ts +10 -7
- package/components/groupedItemList/GroupedItemList.js.map +1 -1
- package/components/listMenu/ListMenu.js.map +1 -1
- package/components/listMenu/ListMenuGroup.d.ts +2 -1
- package/components/listMenu/ListMenuGroup.js.map +1 -1
- package/components/map/components/Map.js.map +1 -1
- package/components/map/components/constants.js.map +1 -1
- package/components/map/components/features/ContextMenuItem.d.ts +1 -1
- package/components/map/components/features/ContextMenuItem.js +2 -17
- package/components/map/components/features/ContextMenuItem.js.map +1 -1
- package/components/map/components/features/basics/Polyline.d.ts +4 -1
- package/components/map/components/features/basics/Polyline.js +1 -1
- package/components/map/components/features/basics/Polyline.js.map +1 -1
- package/components/map/components/features/layers/MarkerLayer.d.ts +3 -1
- package/components/map/components/features/layers/MarkerLayer.js.map +1 -1
- package/components/map/components/features/layers/clustering/ClusterLayer.js +1 -1
- package/components/map/components/features/layers/clustering/ClusterLayer.js.map +1 -1
- package/components/map/components/features/layers/clustering/SimpleClusterLayer.d.ts +3 -2
- package/components/map/components/features/layers/clustering/SimpleClusterLayer.js.map +1 -1
- package/components/map/components/features/layers/overlayLayers/RoadRestrictionLayer.js +7 -7
- package/components/map/components/features/layers/overlayLayers/RoadRestrictionLayer.js.map +1 -1
- package/components/map/components/features/layers/overlayLayers/TrafficLayer.js +4 -4
- package/components/map/components/features/layers/overlayLayers/TrafficLayer.js.map +1 -1
- package/components/map/utils/clustering.d.ts +6 -1
- package/components/map/utils/clustering.js +25 -19
- package/components/map/utils/clustering.js.map +1 -1
- package/components/map/utils/rendering.d.ts +1 -1
- package/components/map/utils/rendering.js +23 -23
- package/components/map/utils/rendering.js.map +1 -1
- package/components/menuItems/MenuItem.d.ts +23 -0
- package/components/menuItems/MenuItem.js.map +1 -1
- package/components/notification/Notification.js +4 -4
- package/components/notification/Notification.js.map +1 -1
- package/components/onboarding/OnboardingTip.d.ts +18 -12
- package/components/onboarding/OnboardingTip.js.map +1 -1
- package/components/overlay/OverlayTrigger.d.ts +43 -1
- package/components/overlay/OverlayTrigger.js.map +1 -1
- package/components/pager/Pager.d.ts +3 -0
- package/components/pager/Pager.js.map +1 -1
- package/components/popover/Popover.d.ts +1 -0
- package/components/popover/Popover.js.map +1 -1
- package/components/preloader/ImagePreloader.d.ts +1 -1
- package/components/preloader/ImagePreloader.js.map +1 -1
- package/components/radiobutton/RadioButton.d.ts +9 -5
- package/components/radiobutton/RadioButton.js.map +1 -1
- package/components/releaseNotes/ReleaseNotes.d.ts +0 -3
- package/components/releaseNotes/ReleaseNotes.js.map +1 -1
- package/components/resizer/Resizer.d.ts +17 -3
- package/components/resizer/Resizer.js.map +1 -1
- package/components/rioglyph/Rioglyph.d.ts +20 -8
- package/components/rioglyph/Rioglyph.js.map +1 -1
- package/components/rules/RulesWrapper.js +1 -1
- package/components/rules/RulesWrapper.js.map +1 -1
- package/components/saveableInput/SaveableDateInput.d.ts +20 -2
- package/components/saveableInput/SaveableDateInput.js.map +1 -1
- package/components/saveableInput/SaveableInput.d.ts +10 -2
- package/components/saveableInput/SaveableInput.js.map +1 -1
- package/components/selects/BaseSelectDropdown.js +90 -79
- package/components/selects/BaseSelectDropdown.js.map +1 -1
- package/components/selects/Select.d.ts +5 -0
- package/components/selects/Select.js +94 -94
- package/components/selects/Select.js.map +1 -1
- package/components/sidebars/Sidebar.d.ts +19 -3
- package/components/sidebars/Sidebar.js.map +1 -1
- package/components/slider/RangeSlider.d.ts +15 -0
- package/components/slider/RangeSlider.js.map +1 -1
- package/components/slider/Slider.d.ts +9 -0
- package/components/slider/Slider.js.map +1 -1
- package/components/smoothScrollbars/SmoothScrollbars.d.ts +44 -0
- package/components/smoothScrollbars/SmoothScrollbars.js.map +1 -1
- package/components/spinner/Spinner.d.ts +3 -3
- package/components/spinner/Spinner.js.map +1 -1
- package/components/states/BaseStateProps.d.ts +6 -2
- package/components/states/StateIcon.d.ts +14 -1
- package/components/states/StateIcon.js.map +1 -1
- package/components/statsWidget/StatsWidget.d.ts +2 -0
- package/components/statsWidget/StatsWidget.js.map +1 -1
- package/components/statsWidget/StatsWidgetBody.d.ts +1 -0
- package/components/statsWidget/StatsWidgetBody.js.map +1 -1
- package/components/statsWidget/StatsWidgetNumber.d.ts +2 -0
- package/components/statsWidget/StatsWidgetNumber.js.map +1 -1
- package/components/statusBar/StatusBar.d.ts +2 -31
- package/components/statusBar/StatusBar.js.map +1 -1
- package/components/statusBar/StatusBarIcon.d.ts +2 -2
- package/components/statusBar/StatusBarIcon.js.map +1 -1
- package/components/statusBar/StatusBarLabel.d.ts +2 -2
- package/components/statusBar/StatusBarLabel.js.map +1 -1
- package/components/statusBar/StatusBarProgressBar.d.ts +1 -1
- package/components/statusBar/StatusBarProgressBar.js.map +1 -1
- package/components/statusBar/{StatusBar.types.d.ts → StatusBarProps.d.ts} +44 -2
- package/components/steppedProgressBar/SteppedProgressBar.d.ts +1 -1
- package/components/steppedProgressBar/SteppedProgressBar.js.map +1 -1
- package/components/switch/Switch.d.ts +13 -1
- package/components/switch/Switch.js.map +1 -1
- package/components/table/SortArrowDown.d.ts +1 -1
- package/components/table/SortArrowDown.js.map +1 -1
- package/components/table/SortArrowUp.d.ts +1 -1
- package/components/table/SortArrowUp.js.map +1 -1
- package/components/table/TableSettingsDialog.d.ts +5 -0
- package/components/table/TableSettingsDialog.js +119 -109
- package/components/table/TableSettingsDialog.js.map +1 -1
- package/components/table/TableSettingsDialogFooter.js +9 -9
- package/components/table/TableSettingsDialogFooter.js.map +1 -1
- package/components/table/TableViewToggles.d.ts +21 -1
- package/components/table/TableViewToggles.js.map +1 -1
- package/components/tag/Tag.d.ts +7 -2
- package/components/tag/Tag.js.map +1 -1
- package/components/tagManager/TagManager.d.ts +15 -0
- package/components/tagManager/TagManager.js.map +1 -1
- package/components/tagManager/TagManagerTag.d.ts +9 -0
- package/components/teaser/Teaser.d.ts +57 -55
- package/components/teaser/Teaser.js.map +1 -1
- package/components/teaser/TeaserContainer.d.ts +1 -1
- package/components/teaser/TeaserContainer.js.map +1 -1
- package/components/tooltip/SimpleTooltip.d.ts +22 -4
- package/components/tooltip/SimpleTooltip.js.map +1 -1
- package/components/tooltip/Tooltip.d.ts +22 -2
- package/components/tooltip/Tooltip.js.map +1 -1
- package/components/video/ResponsiveVideo.d.ts +8 -3
- package/components/video/ResponsiveVideo.js.map +1 -1
- package/hooks/useKey.d.ts +1 -1
- package/hooks/useKey.js.map +1 -1
- package/hooks/useOnboarding.d.ts +86 -80
- package/hooks/useOnboarding.js.map +1 -1
- package/hooks/useTableExport.js.map +1 -1
- package/hooks/useUncontrollable.d.ts +1 -1
- package/hooks/useUncontrollable.js.map +1 -1
- package/package.json +12 -14
- package/utils/colorScheme.js +14 -13
- package/utils/colorScheme.js.map +1 -1
- package/utils/cssuseragent.js.map +1 -1
- package/utils/scrollItemIntoView.js +12 -11
- package/utils/scrollItemIntoView.js.map +1 -1
- package/utils/urlFeatureToggles.js +19 -20
- package/utils/urlFeatureToggles.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
|
@@ -13,7 +13,7 @@ export type ActionBarItemProps = {
|
|
|
13
13
|
*/
|
|
14
14
|
id?: string;
|
|
15
15
|
/**
|
|
16
|
-
* The title property for the
|
|
16
|
+
* The title property for the sub-component ActionBarItem.Popover.
|
|
17
17
|
*
|
|
18
18
|
* This can be a String or another component as well as a React-Intl component.
|
|
19
19
|
*/
|
|
@@ -21,7 +21,7 @@ export type ActionBarItemProps = {
|
|
|
21
21
|
/**
|
|
22
22
|
* Additional class names that are added to the respective component.
|
|
23
23
|
*
|
|
24
|
-
* It can be defined for the parent and all
|
|
24
|
+
* It can be defined for the parent and all sub-components.
|
|
25
25
|
*/
|
|
26
26
|
className?: string;
|
|
27
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBarItem.js","sources":["../../../src/components/actionBarItem/ActionBarItem.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useLayoutEffect,\n useState,\n useRef,\n type PropsWithChildren,\n type HTMLAttributes,\n type MemoExoticComponent,\n type FC,\n} from 'react';\nimport classNames from 'classnames';\nimport { negate } from 'es-toolkit/function';\nimport { delay, head } from 'es-toolkit/compat';\n\nimport ActionBarOverlay from './ActionBarOverlay';\nimport ActionBarItemPopoverContent from './ActionBarItemPopoverContent';\nimport ActionBarItemIcon from './ActionBarItemIcon';\nimport ActionBarItemList from './ActionBarItemList';\nimport ActionBarItemListItem from './ActionBarItemListItem';\nimport ActionBarItemListSeparator from './ActionBarItemListSeparator';\nimport OverlayTrigger from '../overlay/OverlayTrigger';\nimport Dialog from '../dialog/Dialog';\n\nconst EVENT = 'mousedown';\nconst CLASSNAME_SHOW = 'show';\nconst CLASSNAME_OFFSCREEN = 'position-offscreen';\n\nconst DEFAULT_POPOVER_WIDTH = 250;\nconst POPOVER_CLOSE_DELAY_IN_MS = 200;\nconst SMALL_RESOLUTION_THRESHOLD_IN_PX = 580;\n\nconst getRandomString = () => (Math.random() + 1).toString(36).toUpperCase().substring(2);\n\nconst hasClass = (element: HTMLElement, className: string) => element.classList.contains(className);\nconst hasNotClass = negate(hasClass);\n\nconst isNotChildNodeOf = (childNode: HTMLElement, parentNode: HTMLElement) => !parentNode.contains(childNode);\n\nconst checkIfSmallResolution = () => {\n const [isSmallResolution, setIsSmallResolution] = useState(false);\n\n // We only execute this once. Before it was re-rendered on every change.\n // Users probably don't switch between display sizes that often therefore it probably makes sense to\n // avoid the re-rendering or applying an event listener.\n useEffect(() => {\n const header = head(document.getElementsByClassName('ApplicationHeader')) as HTMLElement | undefined;\n const isSmall = header ? header.offsetWidth < SMALL_RESOLUTION_THRESHOLD_IN_PX : false;\n setIsSmallResolution(isSmall);\n }, []);\n\n return isSmallResolution;\n};\n\nconst isActionBarItemPopover = (child: React.ReactElement) =>\n child.type && (child.type as React.ComponentType<unknown>).displayName === ActionBarItemPopoverContent.displayName;\n\nconst isActionBarItemIcon = (child: React.ReactElement) =>\n child.type && (child.type as React.ComponentType<unknown>).displayName === ActionBarItemIcon.displayName;\n\nexport type ActionBarItemPopoverWidth = 100 | 150 | 200 | 250 | 300 | 350 | 400 | 450 | 500;\n\nexport type ActionBarItemProps = {\n /**\n * The id is used to identify the item in the DOM.\n *\n * If not provided, a random id is used instead.\n */\n id?: string;\n\n /**\n * The title property for the subcomponent ActionBarItem.Popover.\n *\n * This can be a String or another component as well as a React-Intl component.\n */\n title?: string | React.ReactNode;\n\n /**\n * Additional class names that are added to the respective component.\n *\n * It can be defined for the parent and all subcomponents.\n */\n className?: string;\n\n /**\n * Defines if the popover should close when any child element is being clicked.\n *\n * @default true\n */\n hidePopoverOnClick?: boolean;\n\n /**\n * Possible values are `100`, `150`, `200`, `250`, `300`, `350`, `400`, `450` or `500`.\n *\n * @default 250\n */\n popoverWidth?: ActionBarItemPopoverWidth;\n\n /**\n * Additional class names that are added to dialog fallback modal-body element.\n */\n mobileDialogBodyClassName?: string;\n};\n\nexport type ActionBarItemComponents = {\n Icon: typeof ActionBarItemIcon;\n Popover: typeof ActionBarItemPopoverContent;\n List: typeof ActionBarItemList;\n ListItem: typeof ActionBarItemListItem;\n ListSeparator: typeof ActionBarItemListSeparator;\n};\n\ntype ActionBarItemPropsWithChildren = PropsWithChildren<ActionBarItemProps>;\n\nconst ActionBarItemBase = (props: ActionBarItemPropsWithChildren) => {\n const {\n id = getRandomString(),\n className,\n mobileDialogBodyClassName = '',\n children,\n popoverWidth = DEFAULT_POPOVER_WIDTH,\n hidePopoverOnClick = true,\n ...remainingProps\n } = props;\n\n const [isShown, setIsShown] = useState(false);\n\n const clickOutsideRef = useRef(null);\n\n useLayoutEffect(() => {\n const listener = (event: MouseEvent) => {\n if (!clickOutsideRef || !clickOutsideRef.current || !isShown) {\n return;\n }\n\n // Since the popover component is based on React Portal and might be offscreen, we need to use\n // old-school approach and query the DOM for the item ID.\n const popoverEl = document.getElementById(id);\n\n if (!popoverEl) {\n return;\n }\n\n // Abort when the ActionBarItemIcon itself has been clicked as there is a toggle function\n // applied to the icon that takes care of opening and closing\n const hasIconClickedToClose = (event.target as HTMLElement).offsetParent === clickOutsideRef.current;\n if (hasIconClickedToClose) {\n return;\n }\n\n // Handle click outside the popover to close it\n const isClickOutsidePopover = isNotChildNodeOf(event.target as HTMLElement, popoverEl);\n const isPopoverVisible = hasClass(popoverEl, CLASSNAME_SHOW) && hasNotClass(popoverEl, CLASSNAME_OFFSCREEN);\n\n if (isPopoverVisible && isClickOutsidePopover) {\n setIsShown(false);\n return;\n }\n\n // Handle click inside the popover.\n // Delay the closing of the popover to execute possible actions from within the popover\n // like clicks on links or buttons\n if (hidePopoverOnClick) {\n delay(() => setIsShown(false), POPOVER_CLOSE_DELAY_IN_MS);\n }\n };\n\n document.addEventListener(EVENT, listener);\n return () => {\n document.removeEventListener(EVENT, listener);\n };\n }, [clickOutsideRef, id, isShown]);\n\n const classes = classNames('ActionBarItem', className);\n\n const isSmallScreen = checkIfSmallResolution();\n\n const onToggle = useCallback(() => setIsShown(!isShown), [setIsShown, isShown]);\n\n // The children depend on each other, that's why it's easier to convert them once to an array\n // and then pick the correct elements. In most cases there are only 2 or 3 elements in the children\n // array so the looping shouldn't be too worrisome.\n const childrenAsList = React.Children.toArray(children) as React.ReactElement[];\n const itemPopover = childrenAsList.find(isActionBarItemPopover);\n const itemIcon = childrenAsList.find(isActionBarItemIcon);\n\n if (!itemPopover) {\n return <div className={classes}>{children}</div>;\n }\n\n const { useOffscreen = false, title } = itemPopover.props;\n\n // Filter out the popover and icon component from the list of children as they are handled separately\n const childrenWithoutPopover = childrenAsList.filter(child => !isActionBarItemPopover(child));\n const childrenWithoutPopoverAndIcon = childrenWithoutPopover.filter(child => !isActionBarItemIcon(child));\n\n if (isSmallScreen) {\n return (\n <div {...(remainingProps as HTMLAttributes<HTMLDivElement>)} className={classes} ref={clickOutsideRef}>\n {React.cloneElement(itemIcon as React.ReactElement, { onClick: onToggle })}\n <div onClick={() => setIsShown(false)}>\n <Dialog\n show={isShown}\n onClose={() => setIsShown(false)}\n body={itemPopover}\n bodyClassName={mobileDialogBodyClassName}\n title={title}\n />\n </div>\n {childrenWithoutPopoverAndIcon}\n </div>\n );\n }\n\n const overlay = (\n <ActionBarOverlay\n id={id}\n key='child'\n title={title}\n width={popoverWidth}\n preRender={useOffscreen}\n show={isShown}\n >\n {itemPopover}\n </ActionBarOverlay>\n );\n\n return (\n <div {...(remainingProps as HTMLAttributes<HTMLDivElement>)} className={classes} ref={clickOutsideRef}>\n <OverlayTrigger\n onToggle={onToggle}\n show={isShown || useOffscreen}\n placement={OverlayTrigger.BOTTOM_END}\n overlay={overlay}\n rootClose={false}\n trigger='click'\n popperConfig={{\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 5],\n },\n },\n {\n name: 'arrow',\n options: {},\n },\n ],\n }}\n >\n {itemIcon}\n </OverlayTrigger>\n {childrenWithoutPopoverAndIcon}\n </div>\n );\n};\n\nconst ActionBarItem = memo(ActionBarItemBase) as ActionBarItemComponents &\n MemoExoticComponent<FC<ActionBarItemPropsWithChildren>>;\n\n// Define static variables on the component type\nActionBarItem.Icon = ActionBarItemIcon;\nActionBarItem.Popover = ActionBarItemPopoverContent;\nActionBarItem.List = ActionBarItemList;\nActionBarItem.ListItem = ActionBarItemListItem;\nActionBarItem.ListSeparator = ActionBarItemListSeparator;\n\nexport default ActionBarItem;\n"],"names":["EVENT","CLASSNAME_SHOW","CLASSNAME_OFFSCREEN","DEFAULT_POPOVER_WIDTH","POPOVER_CLOSE_DELAY_IN_MS","SMALL_RESOLUTION_THRESHOLD_IN_PX","getRandomString","hasClass","element","className","hasNotClass","negate","isNotChildNodeOf","childNode","parentNode","checkIfSmallResolution","isSmallResolution","setIsSmallResolution","useState","useEffect","header","head","isSmall","isActionBarItemPopover","child","ActionBarItemPopoverContent","isActionBarItemIcon","ActionBarItemIcon","ActionBarItemBase","props","id","mobileDialogBodyClassName","children","popoverWidth","hidePopoverOnClick","remainingProps","isShown","setIsShown","clickOutsideRef","useRef","useLayoutEffect","listener","event","popoverEl","isClickOutsidePopover","delay","classes","classNames","isSmallScreen","onToggle","useCallback","childrenAsList","React","itemPopover","itemIcon","jsx","useOffscreen","title","childrenWithoutPopoverAndIcon","Dialog","overlay","ActionBarOverlay","OverlayTrigger","ActionBarItem","memo","ActionBarItemList","ActionBarItemListItem","ActionBarItemListSeparator"],"mappings":";;;;;;;;;;;;;AAyBA,MAAMA,IAAQ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AAMC,EAAW,EAAK;AAAA,UAC/B,MAAMgB;AAAA,UACN,eAAetB;AAAA,UACf,OAAA0B;AAAA,QAAA;AAAA,MAAA,GAER;AAAA,MACCC;AAAA,IAAA,GACL;AAIR,QAAME,IACF,gBAAAL;AAAA,IAACM;AAAA,IAAA;AAAA,MACG,IAAA/B;AAAA,MAEA,OAAA2B;AAAA,MACA,OAAOxB;AAAA,MACP,WAAWuB;AAAA,MACX,MAAMpB;AAAA,MAEL,UAAAiB;AAAA,IAAA;AAAA,IANG;AAAA,EAAA;AAUZ,2BACK,OAAA,EAAK,GAAIlB,GAAmD,WAAWW,GAAS,KAAKR,GAClF,UAAA;AAAA,IAAA,gBAAAiB;AAAA,MAACO;AAAA,MAAA;AAAA,QACG,UAAAb;AAAA,QACA,MAAMb,KAAWoB;AAAA,QACjB,WAAWM,EAAe;AAAA,QAC1B,SAAAF;AAAA,QACA,WAAW;AAAA,QACX,SAAQ;AAAA,QACR,cAAc;AAAA,UACV,WAAW;AAAA,YACP;AAAA,cACI,MAAM;AAAA,cACN,SAAS;AAAA,gBACL,QAAQ,CAAC,GAAG,CAAC;AAAA,cAAA;AAAA,YACjB;AAAA,YAEJ;AAAA,cACI,MAAM;AAAA,cACN,SAAS,CAAA;AAAA,YAAC;AAAA,UACd;AAAA,QACJ;AAAA,QAGH,UAAAN;AAAA,MAAA;AAAA,IAAA;AAAA,IAEJI;AAAA,EAAA,GACL;AAER,GAEMK,IAAgBC,EAAKpC,EAAiB;AAI5CmC,EAAc,OAAOpC;AACrBoC,EAAc,UAAUtC;AACxBsC,EAAc,OAAOE;AACrBF,EAAc,WAAWG;AACzBH,EAAc,gBAAgBI;"}
|
|
1
|
+
{"version":3,"file":"ActionBarItem.js","sources":["../../../src/components/actionBarItem/ActionBarItem.tsx"],"sourcesContent":["import React, {\n memo,\n useCallback,\n useEffect,\n useLayoutEffect,\n useState,\n useRef,\n type PropsWithChildren,\n type HTMLAttributes,\n type MemoExoticComponent,\n type FC,\n} from 'react';\nimport classNames from 'classnames';\nimport { negate } from 'es-toolkit/function';\nimport { delay, head } from 'es-toolkit/compat';\n\nimport ActionBarOverlay from './ActionBarOverlay';\nimport ActionBarItemPopoverContent from './ActionBarItemPopoverContent';\nimport ActionBarItemIcon from './ActionBarItemIcon';\nimport ActionBarItemList from './ActionBarItemList';\nimport ActionBarItemListItem from './ActionBarItemListItem';\nimport ActionBarItemListSeparator from './ActionBarItemListSeparator';\nimport OverlayTrigger from '../overlay/OverlayTrigger';\nimport Dialog from '../dialog/Dialog';\n\nconst EVENT = 'mousedown';\nconst CLASSNAME_SHOW = 'show';\nconst CLASSNAME_OFFSCREEN = 'position-offscreen';\n\nconst DEFAULT_POPOVER_WIDTH = 250;\nconst POPOVER_CLOSE_DELAY_IN_MS = 200;\nconst SMALL_RESOLUTION_THRESHOLD_IN_PX = 580;\n\nconst getRandomString = () => (Math.random() + 1).toString(36).toUpperCase().substring(2);\n\nconst hasClass = (element: HTMLElement, className: string) => element.classList.contains(className);\nconst hasNotClass = negate(hasClass);\n\nconst isNotChildNodeOf = (childNode: HTMLElement, parentNode: HTMLElement) => !parentNode.contains(childNode);\n\nconst checkIfSmallResolution = () => {\n const [isSmallResolution, setIsSmallResolution] = useState(false);\n\n // We only execute this once. Before it was re-rendered on every change.\n // Users probably don't switch between display sizes that often therefore it probably makes sense to\n // avoid the re-rendering or applying an event listener.\n useEffect(() => {\n const header = head(document.getElementsByClassName('ApplicationHeader')) as HTMLElement | undefined;\n const isSmall = header ? header.offsetWidth < SMALL_RESOLUTION_THRESHOLD_IN_PX : false;\n setIsSmallResolution(isSmall);\n }, []);\n\n return isSmallResolution;\n};\n\nconst isActionBarItemPopover = (child: React.ReactElement) =>\n child.type && (child.type as React.ComponentType<unknown>).displayName === ActionBarItemPopoverContent.displayName;\n\nconst isActionBarItemIcon = (child: React.ReactElement) =>\n child.type && (child.type as React.ComponentType<unknown>).displayName === ActionBarItemIcon.displayName;\n\nexport type ActionBarItemPopoverWidth = 100 | 150 | 200 | 250 | 300 | 350 | 400 | 450 | 500;\n\nexport type ActionBarItemProps = {\n /**\n * The id is used to identify the item in the DOM.\n *\n * If not provided, a random id is used instead.\n */\n id?: string;\n\n /**\n * The title property for the sub-component ActionBarItem.Popover.\n *\n * This can be a String or another component as well as a React-Intl component.\n */\n title?: string | React.ReactNode;\n\n /**\n * Additional class names that are added to the respective component.\n *\n * It can be defined for the parent and all sub-components.\n */\n className?: string;\n\n /**\n * Defines if the popover should close when any child element is being clicked.\n *\n * @default true\n */\n hidePopoverOnClick?: boolean;\n\n /**\n * Possible values are `100`, `150`, `200`, `250`, `300`, `350`, `400`, `450` or `500`.\n *\n * @default 250\n */\n popoverWidth?: ActionBarItemPopoverWidth;\n\n /**\n * Additional class names that are added to dialog fallback modal-body element.\n */\n mobileDialogBodyClassName?: string;\n};\n\nexport type ActionBarItemComponents = {\n Icon: typeof ActionBarItemIcon;\n Popover: typeof ActionBarItemPopoverContent;\n List: typeof ActionBarItemList;\n ListItem: typeof ActionBarItemListItem;\n ListSeparator: typeof ActionBarItemListSeparator;\n};\n\ntype ActionBarItemPropsWithChildren = PropsWithChildren<ActionBarItemProps>;\n\nconst ActionBarItemBase = (props: ActionBarItemPropsWithChildren) => {\n const {\n id = getRandomString(),\n className,\n mobileDialogBodyClassName = '',\n children,\n popoverWidth = DEFAULT_POPOVER_WIDTH,\n hidePopoverOnClick = true,\n ...remainingProps\n } = props;\n\n const [isShown, setIsShown] = useState(false);\n\n const clickOutsideRef = useRef(null);\n\n useLayoutEffect(() => {\n const listener = (event: MouseEvent) => {\n if (!clickOutsideRef || !clickOutsideRef.current || !isShown) {\n return;\n }\n\n // Since the popover component is based on React Portal and might be offscreen, we need to use\n // old-school approach and query the DOM for the item ID.\n const popoverEl = document.getElementById(id);\n\n if (!popoverEl) {\n return;\n }\n\n // Abort when the ActionBarItemIcon itself has been clicked as there is a toggle function\n // applied to the icon that takes care of opening and closing\n const hasIconClickedToClose = (event.target as HTMLElement).offsetParent === clickOutsideRef.current;\n if (hasIconClickedToClose) {\n return;\n }\n\n // Handle click outside the popover to close it\n const isClickOutsidePopover = isNotChildNodeOf(event.target as HTMLElement, popoverEl);\n const isPopoverVisible = hasClass(popoverEl, CLASSNAME_SHOW) && hasNotClass(popoverEl, CLASSNAME_OFFSCREEN);\n\n if (isPopoverVisible && isClickOutsidePopover) {\n setIsShown(false);\n return;\n }\n\n // Handle click inside the popover.\n // Delay the closing of the popover to execute possible actions from within the popover\n // like clicks on links or buttons\n if (hidePopoverOnClick) {\n delay(() => setIsShown(false), POPOVER_CLOSE_DELAY_IN_MS);\n }\n };\n\n document.addEventListener(EVENT, listener);\n return () => {\n document.removeEventListener(EVENT, listener);\n };\n }, [clickOutsideRef, id, isShown]);\n\n const classes = classNames('ActionBarItem', className);\n\n const isSmallScreen = checkIfSmallResolution();\n\n const onToggle = useCallback(() => setIsShown(!isShown), [setIsShown, isShown]);\n\n // The children depend on each other, that's why it's easier to convert them once to an array\n // and then pick the correct elements. In most cases there are only 2 or 3 elements in the children\n // array so the looping shouldn't be too worrisome.\n const childrenAsList = React.Children.toArray(children) as React.ReactElement[];\n const itemPopover = childrenAsList.find(isActionBarItemPopover);\n const itemIcon = childrenAsList.find(isActionBarItemIcon);\n\n if (!itemPopover) {\n return <div className={classes}>{children}</div>;\n }\n\n const { useOffscreen = false, title } = itemPopover.props;\n\n // Filter out the popover and icon component from the list of children as they are handled separately\n const childrenWithoutPopover = childrenAsList.filter(child => !isActionBarItemPopover(child));\n const childrenWithoutPopoverAndIcon = childrenWithoutPopover.filter(child => !isActionBarItemIcon(child));\n\n if (isSmallScreen) {\n return (\n <div {...(remainingProps as HTMLAttributes<HTMLDivElement>)} className={classes} ref={clickOutsideRef}>\n {React.cloneElement(itemIcon as React.ReactElement, { onClick: onToggle })}\n <div onClick={() => setIsShown(false)}>\n <Dialog\n show={isShown}\n onClose={() => setIsShown(false)}\n body={itemPopover}\n bodyClassName={mobileDialogBodyClassName}\n title={title}\n />\n </div>\n {childrenWithoutPopoverAndIcon}\n </div>\n );\n }\n\n const overlay = (\n <ActionBarOverlay\n id={id}\n key='child'\n title={title}\n width={popoverWidth}\n preRender={useOffscreen}\n show={isShown}\n >\n {itemPopover}\n </ActionBarOverlay>\n );\n\n return (\n <div {...(remainingProps as HTMLAttributes<HTMLDivElement>)} className={classes} ref={clickOutsideRef}>\n <OverlayTrigger\n onToggle={onToggle}\n show={isShown || useOffscreen}\n placement={OverlayTrigger.BOTTOM_END}\n overlay={overlay}\n rootClose={false}\n trigger='click'\n popperConfig={{\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 5],\n },\n },\n {\n name: 'arrow',\n options: {},\n },\n ],\n }}\n >\n {itemIcon}\n </OverlayTrigger>\n {childrenWithoutPopoverAndIcon}\n </div>\n );\n};\n\nconst ActionBarItem = memo(ActionBarItemBase) as ActionBarItemComponents &\n MemoExoticComponent<FC<ActionBarItemPropsWithChildren>>;\n\n// Define static variables on the component type\nActionBarItem.Icon = ActionBarItemIcon;\nActionBarItem.Popover = ActionBarItemPopoverContent;\nActionBarItem.List = ActionBarItemList;\nActionBarItem.ListItem = ActionBarItemListItem;\nActionBarItem.ListSeparator = ActionBarItemListSeparator;\n\nexport default ActionBarItem;\n"],"names":["EVENT","CLASSNAME_SHOW","CLASSNAME_OFFSCREEN","DEFAULT_POPOVER_WIDTH","POPOVER_CLOSE_DELAY_IN_MS","SMALL_RESOLUTION_THRESHOLD_IN_PX","getRandomString","hasClass","element","className","hasNotClass","negate","isNotChildNodeOf","childNode","parentNode","checkIfSmallResolution","isSmallResolution","setIsSmallResolution","useState","useEffect","header","head","isSmall","isActionBarItemPopover","child","ActionBarItemPopoverContent","isActionBarItemIcon","ActionBarItemIcon","ActionBarItemBase","props","id","mobileDialogBodyClassName","children","popoverWidth","hidePopoverOnClick","remainingProps","isShown","setIsShown","clickOutsideRef","useRef","useLayoutEffect","listener","event","popoverEl","isClickOutsidePopover","delay","classes","classNames","isSmallScreen","onToggle","useCallback","childrenAsList","React","itemPopover","itemIcon","jsx","useOffscreen","title","childrenWithoutPopoverAndIcon","Dialog","overlay","ActionBarOverlay","OverlayTrigger","ActionBarItem","memo","ActionBarItemList","ActionBarItemListItem","ActionBarItemListSeparator"],"mappings":";;;;;;;;;;;;;AAyBA,MAAMA,IAAQ,aACRC,IAAiB,QACjBC,IAAsB,sBAEtBC,IAAwB,KACxBC,KAA4B,KAC5BC,KAAmC,KAEnCC,KAAkB,OAAO,KAAK,OAAA,IAAW,GAAG,SAAS,EAAE,EAAE,cAAc,UAAU,CAAC,GAElFC,IAAW,CAACC,GAAsBC,MAAsBD,EAAQ,UAAU,SAASC,CAAS,GAC5FC,KAAcC,EAAOJ,CAAQ,GAE7BK,KAAmB,CAACC,GAAwBC,MAA4B,CAACA,EAAW,SAASD,CAAS,GAEtGE,KAAyB,MAAM;AACjC,QAAM,CAACC,GAAmBC,CAAoB,IAAIC,EAAS,EAAK;AAKhE,SAAAC,EAAU,MAAM;AACZ,UAAMC,IAASC,EAAK,SAAS,uBAAuB,mBAAmB,CAAC,GAClEC,IAAUF,IAASA,EAAO,cAAcf,KAAmC;AACjF,IAAAY,EAAqBK,CAAO;AAAA,EAChC,GAAG,CAAA,CAAE,GAEEN;AACX,GAEMO,IAAyB,CAACC,MAC5BA,EAAM,QAASA,EAAM,KAAsC,gBAAgBC,EAA4B,aAErGC,IAAsB,CAACF,MACzBA,EAAM,QAASA,EAAM,KAAsC,gBAAgBG,EAAkB,aAwD3FC,KAAoB,CAACC,MAA0C;AACjE,QAAM;AAAA,IACF,IAAAC,IAAKxB,GAAA;AAAA,IACL,WAAAG;AAAA,IACA,2BAAAsB,IAA4B;AAAA,IAC5B,UAAAC;AAAA,IACA,cAAAC,IAAe9B;AAAA,IACf,oBAAA+B,IAAqB;AAAA,IACrB,GAAGC;AAAA,EAAA,IACHN,GAEE,CAACO,GAASC,CAAU,IAAInB,EAAS,EAAK,GAEtCoB,IAAkBC,EAAO,IAAI;AAEnC,EAAAC,EAAgB,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 +8,7 @@ export type ModulePropType = {
|
|
|
8
8
|
* The navigation link component used for rendering the name and for routing.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
*
|
|
12
|
-
* ```tsx
|
|
13
|
-
* <NavLink to='/app/ipsum'>{'Lorem ipsum'}</NavLink>
|
|
14
|
-
* ```
|
|
11
|
+
* <NavLink to='/app/ipsum'>Lorem ipsum</NavLink>
|
|
15
12
|
*/
|
|
16
13
|
route: React.ReactNode;
|
|
17
14
|
};
|
|
@@ -25,14 +22,13 @@ export type ApplicationHeaderProps = {
|
|
|
25
22
|
* as homeRoute into the header. For example:
|
|
26
23
|
*
|
|
27
24
|
* @example
|
|
28
|
-
*
|
|
29
|
-
* ```tsx
|
|
30
25
|
* <NavLink to='https://home.rio.cloud' />
|
|
31
|
-
* ```
|
|
32
26
|
*/
|
|
33
27
|
homeRoute?: React.ReactNode;
|
|
34
28
|
/**
|
|
35
29
|
* Defines to either show the home icon or the RIO logo as brand logo.
|
|
30
|
+
*
|
|
31
|
+
* @default true
|
|
36
32
|
*/
|
|
37
33
|
showHomeIcon?: boolean;
|
|
38
34
|
/**
|
|
@@ -63,11 +59,14 @@ export type ApplicationHeaderProps = {
|
|
|
63
59
|
*
|
|
64
60
|
* For example, the rio-accountmenu or application-owned components such as a ServiceInfo icon. These components
|
|
65
61
|
* are based on the `ActionBarItem`.
|
|
62
|
+
*
|
|
63
|
+
* @default []
|
|
66
64
|
*/
|
|
67
65
|
actionBarItems?: React.ReactNode[];
|
|
68
66
|
/**
|
|
69
67
|
* Callback function triggered when the application menu is open or closed.
|
|
70
68
|
*
|
|
69
|
+
* @default () => {}
|
|
71
70
|
* @param isOpen The new "open" state.
|
|
72
71
|
*/
|
|
73
72
|
onToggleAppMenu?: (isOpen: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationHeader.js","sources":["../../../src/components/applicationHeader/ApplicationHeader.tsx"],"sourcesContent":["import React, { useRef, forwardRef, useCallback, useImperativeHandle, type ForwardedRef } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\nimport classNames from 'classnames';\n\nimport AppMenu from './AppMenu';\nimport ApplicationActionBar from './ApplicationActionBar';\nimport MobileSubmoduleNavigation from './MobileSubmoduleNavigation';\nimport MobileAppMenu from './MobileAppMenu';\nimport useResizeObserver from '../../hooks/useResizeObserver';\nimport NavItems from './NavItems';\n\nconst SCREEN_SM = 768; // @screen-sm: 768px;\n\nexport type ModulePropType = {\n /**\n * Unique key for the sub-module navigation component of an app.\n */\n key: string;\n\n /**\n * The navigation link component used for rendering the name and for routing.\n *\n * @example\n
|
|
1
|
+
{"version":3,"file":"ApplicationHeader.js","sources":["../../../src/components/applicationHeader/ApplicationHeader.tsx"],"sourcesContent":["import React, { useRef, forwardRef, useCallback, useImperativeHandle, type ForwardedRef } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\nimport classNames from 'classnames';\n\nimport AppMenu from './AppMenu';\nimport ApplicationActionBar from './ApplicationActionBar';\nimport MobileSubmoduleNavigation from './MobileSubmoduleNavigation';\nimport MobileAppMenu from './MobileAppMenu';\nimport useResizeObserver from '../../hooks/useResizeObserver';\nimport NavItems from './NavItems';\n\nconst SCREEN_SM = 768; // @screen-sm: 768px;\n\nexport type ModulePropType = {\n /**\n * Unique key for the sub-module navigation component of an app.\n */\n key: string;\n\n /**\n * The navigation link component used for rendering the name and for routing.\n *\n * @example\n * <NavLink to='/app/ipsum'>Lorem ipsum</NavLink>\n */\n route: React.ReactNode;\n};\n\nexport type ApplicationHeaderProps = {\n /**\n * The service name shown as the navigator dropdown label.\n */\n label?: string | React.ReactNode;\n\n /**\n * The home URL that shall be used for the home button. Pass a `react-router-dom` `NavLink`\n * as homeRoute into the header. For example:\n *\n * @example\n * <NavLink to='https://home.rio.cloud' />\n */\n homeRoute?: React.ReactNode;\n\n /**\n * Defines to either show the home icon or the RIO logo as brand logo.\n *\n * @default true\n */\n showHomeIcon?: boolean;\n\n /**\n * The component for the navigation between apps which will be shown inside the main dropdown.\n *\n * Platform apps may use the default AppNavigator, but there are also cases like support apps where it's just a\n * simple list In this case, use the prop `appMenuItems`.\n *\n * If no appNavigator is defined, the dropdown menu will not be rendered.\n */\n appNavigator?: React.ReactNode;\n\n /**\n * Additional class names that are added to the appNavigator.\n */\n appNavigatorClassName?: string;\n\n /**\n * List of application navigation link components.\n */\n appMenuItems?: ModulePropType[];\n\n /**\n * List of submodule navigation component of an app.\n *\n * Items collapse into a dropdown if remaining space in the header is not sufficient.\n */\n navItems?: ModulePropType[];\n\n /**\n * List of external smart components.\n *\n * For example, the rio-accountmenu or application-owned components such as a ServiceInfo icon. These components\n * are based on the `ActionBarItem`.\n *\n * @default []\n */\n actionBarItems?: React.ReactNode[];\n\n /**\n * Callback function triggered when the application menu is open or closed.\n *\n * @default () => {}\n * @param isOpen The new \"open\" state.\n */\n onToggleAppMenu?: (isOpen: boolean) => void;\n\n /**\n * Additional class names that are added to the wrapper component.\n */\n className?: string;\n};\n\nexport const ApplicationHeader = forwardRef((props: ApplicationHeaderProps, ref: ForwardedRef<HTMLDivElement>) => {\n const {\n homeRoute = '',\n showHomeIcon = true,\n label,\n className,\n appNavigator,\n appNavigatorClassName,\n appMenuItems,\n navItems,\n actionBarItems = [],\n onToggleAppMenu = () => {},\n ...remainingProps\n } = props;\n\n const actionBarRef = useRef(null);\n\n const [navRef, entry] = useResizeObserver();\n\n const contentRect = entry?.contentRect;\n\n useImperativeHandle<HTMLDivElement, any>(ref, () => navRef, [navRef]);\n\n const getContentRect = useCallback(\n (key: keyof DOMRectReadOnly) => {\n if (contentRect) {\n const value = contentRect[key];\n return typeof value === 'number' && Math.round(value);\n }\n },\n [contentRect]\n );\n\n // If container width cannot be properly read initially, fall back to window width.\n // This fixes ugly jumping on mobile header and desktop header on mount.\n const containerWidth = getContentRect('width') || window.innerWidth;\n\n const isMobileWidth = containerWidth <= SCREEN_SM;\n\n const hasActionBarItems = !isEmpty(actionBarItems);\n\n const wrapperClassNames = classNames(\n 'ApplicationHeader',\n 'user-select-none',\n isMobileWidth && 'mobile',\n className && className\n );\n\n return (\n <nav {...remainingProps} className={wrapperClassNames} ref={navRef}>\n {isMobileWidth && (\n <React.Fragment>\n <MobileAppMenu\n showHomeIcon={showHomeIcon}\n homeRoute={homeRoute}\n appMenuItems={appMenuItems}\n appNavigator={appNavigator}\n onToggleAppMenu={onToggleAppMenu}\n />\n <div className='flex-1-1-0 display-flex gap-10'>\n <MobileSubmoduleNavigation className='flex-1-1' label={label} navItems={navItems} />\n {hasActionBarItems && <Divider />}\n <ApplicationActionBar className='mobile' nodeRef={actionBarRef} items={actionBarItems} />\n </div>\n </React.Fragment>\n )}\n {!isMobileWidth && (\n <React.Fragment>\n <div className='navbar-header'>\n <span className={`navbar-brand ${showHomeIcon ? 'home-icon' : ''}`}>{homeRoute}</span>\n </div>\n {label && (\n <AppMenu\n label={label}\n key='AppMenu'\n appMenuItems={appMenuItems}\n appNavigator={appNavigator}\n appNavigatorClassName={appNavigatorClassName}\n onToggleAppMenu={onToggleAppMenu}\n />\n )}\n {isEmpty(navItems) && <ul className='SubmoduleNavigation nav' />}\n {!isEmpty(navItems) && (\n <NavItems\n key='NavItems'\n navItems={navItems}\n containerWidth={containerWidth}\n actionBarItems={actionBarItems}\n />\n )}\n <ApplicationActionBar nodeRef={actionBarRef} items={actionBarItems} />\n </React.Fragment>\n )}\n </nav>\n );\n});\n\nconst Divider = () => (\n <div className='divider display-flex align-items-center'>\n <div className='width-3 height-20 bg-lighter' />\n </div>\n);\n\nexport default ApplicationHeader;\n"],"names":["SCREEN_SM","ApplicationHeader","forwardRef","props","ref","homeRoute","showHomeIcon","label","className","appNavigator","appNavigatorClassName","appMenuItems","navItems","actionBarItems","onToggleAppMenu","remainingProps","actionBarRef","useRef","navRef","entry","useResizeObserver","contentRect","useImperativeHandle","containerWidth","useCallback","key","value","isMobileWidth","hasActionBarItems","isEmpty","wrapperClassNames","classNames","jsxs","React","jsx","MobileAppMenu","MobileSubmo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1
1
|
import { ModulePropType } from '../applicationHeader/ApplicationHeader';
|
|
2
2
|
export type SubNavigationProps = {
|
|
3
|
+
/**
|
|
4
|
+
* List of navigation items with key and route prop.
|
|
5
|
+
* The route prop is a react-router NavLink component with an `active` style.
|
|
6
|
+
*/
|
|
3
7
|
navItems?: ModulePropType[];
|
|
8
|
+
/**
|
|
9
|
+
* Additional classes for the wrapper element.
|
|
10
|
+
*/
|
|
4
11
|
className?: string;
|
|
5
12
|
};
|
|
6
13
|
declare const SubNavigation: import('react').ForwardRefExoticComponent<SubNavigationProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubNavigation.js","sources":["../../../src/components/applicationLayout/SubNavigation.tsx"],"sourcesContent":["import { forwardRef, type ForwardedRef } from 'react';\nimport classNames from 'classnames';\n\nimport type { ModulePropType } from '../applicationHeader/ApplicationHeader';\n\nexport type SubNavigationProps = {\n navItems?: ModulePropType[];\n className?: string;\n};\n\ntype Ref = ForwardedRef<HTMLDivElement>;\n\nconst SubNavigation = forwardRef((props: SubNavigationProps, ref: Ref) => {\n const { className, navItems = [], ...remainingProps } = props;\n\n const navigationClasses = classNames('SubNavigation', 'width-100pct overflow-auto', className);\n\n return (\n <div ref={ref} {...remainingProps} className={navigationClasses}>\n <ul className='SubmoduleNavigation nav'>\n {navItems.map(navItem => (\n <li className='submodule' key={navItem.key} data-nav-item-key={navItem.key}>\n {navItem.route}\n </li>\n ))}\n </ul>\n </div>\n );\n});\n\nexport default SubNavigation;\n"],"names":["SubNavigation","forwardRef","props","ref","className","navItems","remainingProps","navigationClasses","classNames","jsx","navItem"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SubNavigation.js","sources":["../../../src/components/applicationLayout/SubNavigation.tsx"],"sourcesContent":["import { forwardRef, type ForwardedRef } from 'react';\nimport classNames from 'classnames';\n\nimport type { ModulePropType } from '../applicationHeader/ApplicationHeader';\n\nexport type SubNavigationProps = {\n /**\n * List of navigation items with key and route prop.\n * The route prop is a react-router NavLink component with an `active` style.\n */\n navItems?: ModulePropType[];\n\n /**\n * Additional classes for the wrapper element.\n */\n className?: string;\n};\n\ntype Ref = ForwardedRef<HTMLDivElement>;\n\nconst SubNavigation = forwardRef((props: SubNavigationProps, ref: Ref) => {\n const { className, navItems = [], ...remainingProps } = props;\n\n const navigationClasses = classNames('SubNavigation', 'width-100pct overflow-auto', className);\n\n return (\n <div ref={ref} {...remainingProps} className={navigationClasses}>\n <ul className='SubmoduleNavigation nav'>\n {navItems.map(navItem => (\n <li className='submodule' key={navItem.key} data-nav-item-key={navItem.key}>\n {navItem.route}\n </li>\n ))}\n </ul>\n </div>\n );\n});\n\nexport default SubNavigation;\n"],"names":["SubNavigation","forwardRef","props","ref","className","navItems","remainingProps","navigationClasses","classNames","jsx","navItem"],"mappings":";;;AAoBA,MAAMA,IAAgBC,EAAW,CAACC,GAA2BC,MAAa;AACtE,QAAM,EAAE,WAAAC,GAAW,UAAAC,IAAW,CAAA,GAAI,GAAGC,MAAmBJ,GAElDK,IAAoBC,EAAW,iBAAiB,8BAA8BJ,CAAS;AAE7F,SACI,gBAAAK,EAAC,OAAA,EAAI,KAAAN,GAAW,GAAGG,GAAgB,WAAWC,GAC1C,UAAA,gBAAAE,EAAC,MAAA,EAAG,WAAU,2BACT,UAAAJ,EAAS,IAAI,CAAAK,MACV,gBAAAD,EAAC,MAAA,EAAG,WAAU,aAA8B,qBAAmBC,EAAQ,KAClE,UAAAA,EAAQ,SADkBA,EAAQ,GAEvC,CACH,EAAA,CACL,GACJ;AAER,CAAC;"}
|
|
@@ -20,6 +20,7 @@ export type AssetTreeProps = {
|
|
|
20
20
|
bordered?: boolean;
|
|
21
21
|
/**
|
|
22
22
|
* Defines the width of the component. The value is set as inline style.
|
|
23
|
+
*
|
|
23
24
|
* Note: when component is resizable it will take the provided
|
|
24
25
|
* width in px only and convert it to number in case.
|
|
25
26
|
*
|
|
@@ -50,6 +51,8 @@ export type AssetTreeProps = {
|
|
|
50
51
|
isOpen?: boolean;
|
|
51
52
|
/**
|
|
52
53
|
* Callback for when the tree visibility is toggled.
|
|
54
|
+
*
|
|
55
|
+
* @default () => {}
|
|
53
56
|
* @param isOpen
|
|
54
57
|
* @returns
|
|
55
58
|
*/
|
|
@@ -60,12 +63,16 @@ export type AssetTreeProps = {
|
|
|
60
63
|
currentCategoryId?: string;
|
|
61
64
|
/**
|
|
62
65
|
* Callback for handling change of category.
|
|
66
|
+
*
|
|
67
|
+
* @default () => {}
|
|
63
68
|
* @param selectedCategoryId
|
|
64
69
|
* @returns
|
|
65
70
|
*/
|
|
66
71
|
onCategoryChange?: (selectedCategoryId: string) => void;
|
|
67
72
|
/**
|
|
68
73
|
* Callback for when the resize is done.
|
|
74
|
+
*
|
|
75
|
+
* @default () => {}
|
|
69
76
|
*/
|
|
70
77
|
onResizeEnd?: VoidFunction;
|
|
71
78
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetTree.js","sources":["../../../src/components/assetTree/AssetTree.tsx"],"sourcesContent":["import React, { memo, useState, useRef, forwardRef, type PropsWithChildren } from 'react';\nimport classNames from 'classnames';\nimport { head, isArray, noop } from 'es-toolkit/compat';\nimport invariant from 'tiny-invariant';\n\nimport TreeCategory, { type TreeCategoryProps } from './TreeCategory';\nimport Resizer from '../resizer/Resizer';\nimport TreeSidebar from './TreeSidebar';\nimport getWidthInBoundaries from '../../utils/getWidthInBoundaries';\nimport mergeRefs from '../../utils/mergeRefs';\nimport usePrevious from '../../usePrevious';\nimport SmoothScrollbars from '../smoothScrollbars/SmoothScrollbars';\n\nconst DEFAULT_WIDTH = 350;\nconst DEFAULT_MIN_WIDTH = 100;\nconst DEFAULT_MAX_WIDTH = 0;\n\nconst TreeMode = {\n MODE_FLY: 'fly',\n MODE_FLUID: 'fluid',\n} as const;\n\nconst getSidebarBodyRef = (sidebarRef: React.MutableRefObject<HTMLDivElement | null>) =>\n head(sidebarRef?.current?.getElementsByClassName('AssetTreeBody'));\n\nconst getCurrentCategoryElement = (children: React.ReactElement[], currentCategoryId: string) => {\n return isArray(children) ? children.find(child => child && child.props.id === currentCategoryId) : children;\n};\n\nconst renderTreesOffscreen = (children: React.ReactElement[], categoryId: string | undefined) => {\n return React.Children.map(children, child => {\n const offscreenClasses = classNames(\n 'TreeOffscreenWrapper',\n child && child.props.id !== categoryId && 'position-offscreen pointer-events-none'\n );\n return <div className={offscreenClasses}>{child}</div>;\n });\n};\n\nexport type AssetTreeProps = {\n /**\n * Defines if the component will overlap the body content.\n *\n * @default false\n */\n fly?: boolean;\n\n /**\n * Defines whether or not the sidebar is resizable.\n *\n * @default true\n */\n resizable?: boolean;\n\n /**\n * Defines whether the component has a border or not.\n *\n * @default false\n */\n bordered?: boolean;\n\n /**\n * Defines the width of the component. The value is set as inline style.\n * Note: when component is resizable it will take the provided\n * width in px only and convert it to number in case.\n *\n * @default 350\n */\n width?: number;\n\n /**\n * Defines the minimum width of the component in px that will take effect when resizing.\n *\n * @default 100\n */\n minWidth?: number;\n\n /**\n * Defines the maximum width of the component in px that will take effect when resizing.\n *\n * @default 0\n */\n maxWidth?: number;\n\n /**\n * Defines the height of the component in px.\n */\n height?: number;\n\n /**\n * Defines whether the component is open or not.\n *\n * @default true\n */\n isOpen?: boolean;\n\n /**\n * Callback for when the tree visibility is toggled.\n * @param isOpen\n * @returns\n */\n onToggleTree?: (isOpen: boolean) => void;\n\n /**\n * The id of the category which is currently active and shall be shown.\n */\n currentCategoryId?: string;\n\n /**\n * Callback for handling change of category.\n * @param selectedCategoryId\n * @returns\n */\n onCategoryChange?: (selectedCategoryId: string) => void;\n\n /**\n * Callback for when the resize is done.\n */\n onResizeEnd?: VoidFunction;\n\n /**\n * Defines whether the tree components are rendered offscreen and kept mounted in the DOM.\n *\n * @default false\n */\n useOffscreen?: boolean;\n\n /**\n * Additional classes added on the wrapper element.\n */\n className?: string;\n};\n\n// Check if the child is a React element and if it has the type TreeCategory\nconst isTreeCategory = (child: React.ReactNode): child is React.ReactElement<TreeCategoryProps> => {\n return React.isValidElement(child) && child.type === TreeCategory;\n};\n\nconst AssetTree = memo(\n forwardRef<HTMLDivElement, PropsWithChildren<AssetTreeProps>>((props, ref) => {\n const {\n className,\n resizable = true,\n width = DEFAULT_WIDTH,\n minWidth = DEFAULT_MIN_WIDTH,\n maxWidth = DEFAULT_MAX_WIDTH,\n height,\n bordered = false,\n currentCategoryId,\n isOpen = true,\n useOffscreen = false,\n fly = false,\n onCategoryChange = noop,\n onToggleTree = noop,\n onResizeEnd = noop,\n children = [],\n ...remainingProps\n } = props;\n\n const getSidebarMode = (isFly: boolean) => (isFly ? TreeMode.MODE_FLY : TreeMode.MODE_FLUID);\n\n const [treeWidth, setTreeWidth] = useState(width);\n const [isResize, setIsResize] = useState(false);\n const [sidebarMode, setSidebarMode] = useState(getSidebarMode(fly));\n\n const sidebarRef = useRef<HTMLDivElement>(null);\n\n const mergedRefs = mergeRefs([ref, sidebarRef]);\n\n // Update internal state when props change\n const previousWidth = usePrevious(width);\n if (previousWidth !== width) {\n setTreeWidth(width);\n }\n\n const [previousMode, setPreviousMode] = useState(fly);\n if (previousMode !== fly) {\n setSidebarMode(getSidebarMode(fly));\n setPreviousMode(fly);\n }\n\n const childrenArray = React.Children.toArray(children);\n\n // check for children type of TreeCategory and throw error in case\n invariant(childrenArray.every(isTreeCategory), 'AssetTree only excepts children of type \"TreeCategory\"');\n\n const classes = classNames(\n 'AssetTree',\n className,\n !isOpen && 'closed',\n bordered && 'border',\n sidebarMode === TreeMode.MODE_FLY ? 'fly' : 'fluid'\n );\n\n const resizeLimitClasses = classNames('AssetTreeResizeLimit', isResize && 'display-block');\n\n const resizeIndicatorPosition = maxWidth || window.innerWidth * 0.5;\n const resizeLimitStyle = { left: resizeIndicatorPosition };\n\n const firstChild = head(childrenArray);\n\n const category = currentCategoryId ? getCurrentCategoryElement(childrenArray, currentCategoryId) : firstChild;\n\n const style = {\n width: treeWidth,\n height,\n };\n\n const handleToggleTreeContent = () => onToggleTree(!isOpen);\n\n const handleSelectCategory = (selectedCategoryId: string) => {\n onCategoryChange(selectedCategoryId);\n\n if (!isOpen) {\n handleToggleTreeContent();\n } else if (isOpen && currentCategoryId === selectedCategoryId) {\n handleToggleTreeContent();\n }\n };\n\n const handleResize = (diff: number) => {\n const halfWindowWidth = window.innerWidth * 0.5;\n const usedMaxWidth = maxWidth || halfWindowWidth;\n\n // Check for sidebar width if it is half window size. If it was before but the sidebar was resized so it is\n // no longer half window size, set the sidebar width to half the window size to avoid jumping sidebar\n // to old width\n setTreeWidth(oldWidth => {\n const updatedWidth = oldWidth - diff;\n return getWidthInBoundaries(minWidth, usedMaxWidth, updatedWidth);\n });\n };\n\n const handleResizeStart = () => {\n const body = getSidebarBodyRef(sidebarRef);\n if (body) {\n body.classList.add('pointer-events-none');\n }\n setIsResize(true);\n };\n\n const handleResizeEnd = () => {\n const body = getSidebarBodyRef(sidebarRef);\n if (body) {\n body.classList.remove('pointer-events-none');\n }\n setIsResize(false);\n onResizeEnd();\n };\n\n return (\n <div {...remainingProps} className={classes} style={style} ref={mergedRefs}>\n <div className={resizeLimitClasses} style={resizeLimitStyle} />\n <div className='AssetTreeContent'>\n <TreeSidebar\n onSelectCategory={handleSelectCategory}\n currentCategoryId={currentCategoryId}\n onClick={handleToggleTreeContent}\n >\n {isArray(children) ? children : [children]}\n </TreeSidebar>\n <SmoothScrollbars slideIn className='AssetTreeBody'>\n {useOffscreen ? renderTreesOffscreen(childrenArray, currentCategoryId) : category}\n </SmoothScrollbars>\n </div>\n {resizable && isOpen && (\n <Resizer\n onResizeStart={handleResizeStart}\n onResize={handleResize}\n onResizeEnd={handleResizeEnd}\n direction={Resizer.HORIZONTAL}\n position={Resizer.RIGHT}\n />\n )}\n </div>\n );\n })\n);\n\nObject.assign(AssetTree, TreeMode);\n\nexport default AssetTree;\n"],"names":["DEFAULT_WIDTH","DEFAULT_MIN_WIDTH","DEFAULT_MAX_WIDTH","TreeMode","getSidebarBodyRef","sidebarRef","head","getCurrentCategoryElement","children","currentCategoryId","isArray","child","renderTreesOffscreen","categoryId","React","offscreenClasses","classNames","jsx","isTreeCategory","TreeCategory","AssetTree","memo","forwardRef","props","ref","className","resizable","width","minWidth","maxWidth","height","bordered","isOpen","useOffscreen","fly","onCategoryChange","noop","onToggleTree","onResizeEnd","remainingProps","getSidebarMode","isFly","treeWidth","setTreeWidth","useState","isResize","setIsResize","sidebarMode","setSidebarMode","useRef","mergedRefs","mergeRefs","usePrevious","previousMode","setPreviousMode","childrenArray","invariant","classes","resizeLimitClasses","resizeLimitStyle","firstChild","category","style","handleToggleTreeContent","handleSelectCategory","selectedCategoryId","handleResize","diff","halfWindowWidth","usedMaxWidth","oldWidth","updatedWidth","getWidthInBoundaries","handleResizeStart","body","handleResizeEnd","jsxs","TreeSidebar","SmoothScrollbars","Resizer"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,KAAgB,KAChBC,KAAoB,KACpBC,KAAoB,GAEpBC,IAAW;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAChB,GAEMC,IAAoB,CAACC,MACvBC,EAAKD,GAAY,SAAS,uBAAuB,eAAe,CAAC,GAE/DE,KAA4B,CAACC,GAAgCC,MACxDC,EAAQF,CAAQ,IAAIA,EAAS,KAAK,CAAAG,MAASA,KAASA,EAAM,MAAM,OAAOF,CAAiB,IAAID,GAGjGI,KAAuB,CAACJ,GAAgCK,MACnDC,EAAM,SAAS,IAAIN,GAAU,CAAAG,MAAS;AACzC,QAAMI,IAAmBC;AAAA,IACrB;AAAA,IACAL,KAASA,EAAM,MAAM,OAAOE,KAAc;AAAA,EAAA;AAE9C,SAAO,gBAAAI,EAAC,OAAA,EAAI,WAAWF,GAAmB,UAAAJ,GAAM;AACpD,CAAC,GAkGCO,KAAiB,CAACP,MACbG,EAAM,eAAeH,CAAK,KAAKA,EAAM,SAASQ,IAGnDC,KAAYC;AAAA,EACdC,GAA8D,CAACC,GAAOC,MAAQ;AAC1E,UAAM;AAAA,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IAAW,CAACA,CAAQ;AAAA,UAAA;AAAA,QAAA;AAAA,QAE7C,gBAAAS,EAAC6D,IAAA,EAAiB,SAAO,IAAC,WAAU,iBAC/B,UAAA7C,IAAerB,GAAqB2C,GAAe9C,CAAiB,IAAIoD,EAAA,CAC7E;AAAA,MAAA,GACJ;AAAA,MACCnC,KAAaM,KACV,gBAAAf;AAAA,QAAC8D;AAAA,QAAA;AAAA,UACG,eAAeN;AAAA,UACf,UAAUP;AAAA,UACV,aAAaS;AAAA,UACb,WAAWI,EAAQ;AAAA,UACnB,UAAUA,EAAQ;AAAA,QAAA;AAAA,MAAA;AAAA,IACtB,GAER;AAAA,EAER,CAAC;AACL;AAEA,OAAO,OAAO3D,IAAWjB,CAAQ;"}
|
|
1
|
+
{"version":3,"file":"AssetTree.js","sources":["../../../src/components/assetTree/AssetTree.tsx"],"sourcesContent":["import React, { memo, useState, useRef, forwardRef, type PropsWithChildren } from 'react';\nimport classNames from 'classnames';\nimport { head, isArray, noop } from 'es-toolkit/compat';\nimport invariant from 'tiny-invariant';\n\nimport TreeCategory, { type TreeCategoryProps } from './TreeCategory';\nimport Resizer from '../resizer/Resizer';\nimport TreeSidebar from './TreeSidebar';\nimport getWidthInBoundaries from '../../utils/getWidthInBoundaries';\nimport mergeRefs from '../../utils/mergeRefs';\nimport usePrevious from '../../usePrevious';\nimport SmoothScrollbars from '../smoothScrollbars/SmoothScrollbars';\n\nconst DEFAULT_WIDTH = 350;\nconst DEFAULT_MIN_WIDTH = 100;\nconst DEFAULT_MAX_WIDTH = 0;\n\nconst TreeMode = {\n MODE_FLY: 'fly',\n MODE_FLUID: 'fluid',\n} as const;\n\nconst getSidebarBodyRef = (sidebarRef: React.MutableRefObject<HTMLDivElement | null>) =>\n head(sidebarRef?.current?.getElementsByClassName('AssetTreeBody'));\n\nconst getCurrentCategoryElement = (children: React.ReactElement[], currentCategoryId: string) => {\n return isArray(children) ? children.find(child => child && child.props.id === currentCategoryId) : children;\n};\n\nconst renderTreesOffscreen = (children: React.ReactElement[], categoryId: string | undefined) => {\n return React.Children.map(children, child => {\n const offscreenClasses = classNames(\n 'TreeOffscreenWrapper',\n child && child.props.id !== categoryId && 'position-offscreen pointer-events-none'\n );\n return <div className={offscreenClasses}>{child}</div>;\n });\n};\n\nexport type AssetTreeProps = {\n /**\n * Defines if the component will overlap the body content.\n *\n * @default false\n */\n fly?: boolean;\n\n /**\n * Defines whether or not the sidebar is resizable.\n *\n * @default true\n */\n resizable?: boolean;\n\n /**\n * Defines whether the component has a border or not.\n *\n * @default false\n */\n bordered?: boolean;\n\n /**\n * Defines the width of the component. The value is set as inline style.\n *\n * Note: when component is resizable it will take the provided\n * width in px only and convert it to number in case.\n *\n * @default 350\n */\n width?: number;\n\n /**\n * Defines the minimum width of the component in px that will take effect when resizing.\n *\n * @default 100\n */\n minWidth?: number;\n\n /**\n * Defines the maximum width of the component in px that will take effect when resizing.\n *\n * @default 0\n */\n maxWidth?: number;\n\n /**\n * Defines the height of the component in px.\n */\n height?: number;\n\n /**\n * Defines whether the component is open or not.\n *\n * @default true\n */\n isOpen?: boolean;\n\n /**\n * Callback for when the tree visibility is toggled.\n *\n * @default () => {}\n * @param isOpen\n * @returns\n */\n onToggleTree?: (isOpen: boolean) => void;\n\n /**\n * The id of the category which is currently active and shall be shown.\n */\n currentCategoryId?: string;\n\n /**\n * Callback for handling change of category.\n *\n * @default () => {}\n * @param selectedCategoryId\n * @returns\n */\n onCategoryChange?: (selectedCategoryId: string) => void;\n\n /**\n * Callback for when the resize is done.\n *\n * @default () => {}\n */\n onResizeEnd?: VoidFunction;\n\n /**\n * Defines whether the tree components are rendered offscreen and kept mounted in the DOM.\n *\n * @default false\n */\n useOffscreen?: boolean;\n\n /**\n * Additional classes added on the wrapper element.\n */\n className?: string;\n};\n\n// Check if the child is a React element and if it has the type TreeCategory\nconst isTreeCategory = (child: React.ReactNode): child is React.ReactElement<TreeCategoryProps> => {\n return React.isValidElement(child) && child.type === TreeCategory;\n};\n\nconst AssetTree = memo(\n forwardRef<HTMLDivElement, PropsWithChildren<AssetTreeProps>>((props, ref) => {\n const {\n className,\n resizable = true,\n width = DEFAULT_WIDTH,\n minWidth = DEFAULT_MIN_WIDTH,\n maxWidth = DEFAULT_MAX_WIDTH,\n height,\n bordered = false,\n currentCategoryId,\n isOpen = true,\n useOffscreen = false,\n fly = false,\n onCategoryChange = noop,\n onToggleTree = noop,\n onResizeEnd = noop,\n children = [],\n ...remainingProps\n } = props;\n\n const getSidebarMode = (isFly: boolean) => (isFly ? TreeMode.MODE_FLY : TreeMode.MODE_FLUID);\n\n const [treeWidth, setTreeWidth] = useState(width);\n const [isResize, setIsResize] = useState(false);\n const [sidebarMode, setSidebarMode] = useState(getSidebarMode(fly));\n\n const sidebarRef = useRef<HTMLDivElement>(null);\n\n const mergedRefs = mergeRefs([ref, sidebarRef]);\n\n // Update internal state when props change\n const previousWidth = usePrevious(width);\n if (previousWidth !== width) {\n setTreeWidth(width);\n }\n\n const [previousMode, setPreviousMode] = useState(fly);\n if (previousMode !== fly) {\n setSidebarMode(getSidebarMode(fly));\n setPreviousMode(fly);\n }\n\n const childrenArray = React.Children.toArray(children);\n\n // check for children type of TreeCategory and throw error in case\n invariant(childrenArray.every(isTreeCategory), 'AssetTree only excepts children of type \"TreeCategory\"');\n\n const classes = classNames(\n 'AssetTree',\n className,\n !isOpen && 'closed',\n bordered && 'border',\n sidebarMode === TreeMode.MODE_FLY ? 'fly' : 'fluid'\n );\n\n const resizeLimitClasses = classNames('AssetTreeResizeLimit', isResize && 'display-block');\n\n const resizeIndicatorPosition = maxWidth || window.innerWidth * 0.5;\n const resizeLimitStyle = { left: resizeIndicatorPosition };\n\n const firstChild = head(childrenArray);\n\n const category = currentCategoryId ? getCurrentCategoryElement(childrenArray, currentCategoryId) : firstChild;\n\n const style = {\n width: treeWidth,\n height,\n };\n\n const handleToggleTreeContent = () => onToggleTree(!isOpen);\n\n const handleSelectCategory = (selectedCategoryId: string) => {\n onCategoryChange(selectedCategoryId);\n\n if (!isOpen) {\n handleToggleTreeContent();\n } else if (isOpen && currentCategoryId === selectedCategoryId) {\n handleToggleTreeContent();\n }\n };\n\n const handleResize = (diff: number) => {\n const halfWindowWidth = window.innerWidth * 0.5;\n const usedMaxWidth = maxWidth || halfWindowWidth;\n\n // Check for sidebar width if it is half window size. If it was before but the sidebar was resized so it is\n // no longer half window size, set the sidebar width to half the window size to avoid jumping sidebar\n // to old width\n setTreeWidth(oldWidth => {\n const updatedWidth = oldWidth - diff;\n return getWidthInBoundaries(minWidth, usedMaxWidth, updatedWidth);\n });\n };\n\n const handleResizeStart = () => {\n const body = getSidebarBodyRef(sidebarRef);\n if (body) {\n body.classList.add('pointer-events-none');\n }\n setIsResize(true);\n };\n\n const handleResizeEnd = () => {\n const body = getSidebarBodyRef(sidebarRef);\n if (body) {\n body.classList.remove('pointer-events-none');\n }\n setIsResize(false);\n onResizeEnd();\n };\n\n return (\n <div {...remainingProps} className={classes} style={style} ref={mergedRefs}>\n <div className={resizeLimitClasses} style={resizeLimitStyle} />\n <div className='AssetTreeContent'>\n <TreeSidebar\n onSelectCategory={handleSelectCategory}\n currentCategoryId={currentCategoryId}\n onClick={handleToggleTreeContent}\n >\n {isArray(children) ? children : [children]}\n </TreeSidebar>\n <SmoothScrollbars slideIn className='AssetTreeBody'>\n {useOffscreen ? renderTreesOffscreen(childrenArray, currentCategoryId) : category}\n </SmoothScrollbars>\n </div>\n {resizable && isOpen && (\n <Resizer\n onResizeStart={handleResizeStart}\n onResize={handleResize}\n onResizeEnd={handleResizeEnd}\n direction={Resizer.HORIZONTAL}\n position={Resizer.RIGHT}\n />\n )}\n </div>\n );\n })\n);\n\nObject.assign(AssetTree, TreeMode);\n\nexport default AssetTree;\n"],"names":["DEFAULT_WIDTH","DEFAULT_MIN_WIDTH","DEFAULT_MAX_WIDTH","TreeMode","getSidebarBodyRef","sidebarRef","head","getCurrentCategoryElement","children","currentCategoryId","isArray","child","renderTreesOffscreen","categoryId","React","offscreenClasses","classNames","jsx","isTreeCategory","TreeCategory","AssetTree","memo","forwardRef","props","ref","className","resizable","width","minWidth","maxWidth","height","bordered","isOpen","useOffscreen","fly","onCategoryChange","noop","onToggleTree","onResizeEnd","remainingProps","getSidebarMode","isFly","treeWidth","setTreeWidth","useState","isResize","setIsResize","sidebarMode","setSidebarMode","useRef","mergedRefs","mergeRefs","usePrevious","previousMode","setPreviousMode","childrenArray","invariant","classes","resizeLimitClasses","resizeLimitStyle","firstChild","category","style","handleToggleTreeContent","handleSelectCategory","selectedCategoryId","handleResize","diff","halfWindowWidth","usedMaxWidth","oldWidth","updatedWidth","getWidthInBoundaries","handleResizeStart","body","handleResizeEnd","jsxs","TreeSidebar","SmoothScrollbars","Resizer"],"mappings":";;;;;;;;;;;;AAaA,MAAMA,KAAgB,KAChBC,KAAoB,KACpBC,KAAoB,GAEpBC,IAAW;AAAA,EACb,UAAU;AAAA,EACV,YAAY;AAChB,GAEMC,IAAoB,CAACC,MACvBC,EAAKD,GAAY,SAAS,uBAAuB,eAAe,CAAC,GAE/DE,KAA4B,CAACC,GAAgCC,MACxDC,EAAQF,CAAQ,IAAIA,EAAS,KAAK,CAAAG,MAASA,KAASA,EAAM,MAAM,OAAOF,CAAiB,IAAID,GAGjGI,KAAuB,CAACJ,GAAgCK,MACnDC,EAAM,SAAS,IAAIN,GAAU,CAAAG,MAAS;AACzC,QAAMI,IAAmBC;AAAA,IACrB;AAAA,IACAL,KAASA,EAAM,MAAM,OAAOE,KAAc;AAAA,EAAA;AAE9C,SAAO,gBAAAI,EAAC,OAAA,EAAI,WAAWF,GAAmB,UAAAJ,GAAM;AACpD,CAAC,GAyGCO,KAAiB,CAACP,MACbG,EAAM,eAAeH,CAAK,KAAKA,EAAM,SAASQ,IAGnDC,KAAYC;AAAA,EACdC,GAA8D,CAACC,GAAOC,MAAQ;AAC1E,UAAM;AAAA,MACF,WAAAC;AAAA,MACA,WAAAC,IAAY;AAAA,MACZ,OAAAC,IAAQ3B;AAAA,MACR,UA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,EAAiB,SAAO,IAAC,WAAU,iBAC/B,UAAA7C,IAAerB,GAAqB2C,GAAe9C,CAAiB,IAAIoD,EAAA,CAC7E;AAAA,MAAA,GACJ;AAAA,MACCnC,KAAaM,KACV,gBAAAf;AAAA,QAAC8D;AAAA,QAAA;AAAA,UACG,eAAeN;AAAA,UACf,UAAUP;AAAA,UACV,aAAaS;AAAA,UACb,WAAWI,EAAQ;AAAA,UACnB,UAAUA,EAAQ;AAAA,QAAA;AAAA,MAAA;AAAA,IACtB,GAER;AAAA,EAER,CAAC;AACL;AAEA,OAAO,OAAO3D,IAAWjB,CAAQ;"}
|
|
@@ -25,12 +25,20 @@ export type TreeGroup = {
|
|
|
25
25
|
* The rioglyph icon name for a group.
|
|
26
26
|
*
|
|
27
27
|
* The prefix `rioglyph-` can be omitted.
|
|
28
|
+
*
|
|
29
|
+
* For custom icons and logos, provide an image URL with one of these extensions:
|
|
30
|
+
* `.png`, `.webp`, `.jpg`, `.jpeg`, `.svg`.
|
|
31
|
+
* In this case, an img tag is rendered instead of the rioglyph.
|
|
28
32
|
*/
|
|
29
33
|
icon?: string;
|
|
30
34
|
/**
|
|
31
35
|
* The rioglyph icon name for a expanded group.
|
|
32
36
|
*
|
|
33
37
|
* The prefix `rioglyph-` can be omitted.
|
|
38
|
+
*
|
|
39
|
+
* For custom icons and logos, provide an image URL with one of these extensions:
|
|
40
|
+
* `.png`, `.webp`, `.jpg`, `.jpeg`, `.svg`.
|
|
41
|
+
* In this case, an img tag is rendered instead of the rioglyph.
|
|
34
42
|
*/
|
|
35
43
|
expandedIcon?: string;
|
|
36
44
|
/**
|
|
@@ -67,6 +75,10 @@ export type TreeItem = {
|
|
|
67
75
|
* - If set to `null`, no icon will be rendered, even if `type` is defined.
|
|
68
76
|
*
|
|
69
77
|
* This allows full control over the icon behavior while maintaining backward compatibility with type-based icons.
|
|
78
|
+
*
|
|
79
|
+
* For custom icons and logos, provide an image URL with one of these extensions:
|
|
80
|
+
* `.png`, `.webp`, `.jpg`, `.jpeg`, `.svg`.
|
|
81
|
+
* In this case, an img tag is rendered instead of the rioglyph.
|
|
70
82
|
*/
|
|
71
83
|
icon?: string | null;
|
|
72
84
|
/**
|
|
@@ -197,6 +209,9 @@ export type TreeProps = {
|
|
|
197
209
|
* @default false
|
|
198
210
|
*/
|
|
199
211
|
hideTreeHead?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Additional custom content that is rendered at the top of the tree component. This can be used for nav pills.
|
|
214
|
+
*/
|
|
200
215
|
treeHeaderContent?: React.ReactElement;
|
|
201
216
|
/**
|
|
202
217
|
* Defines the max-height of the scrollable list.
|