@lumx/react 2.2.18-alpha-hooks.1 → 2.2.20-alpha.xss.datatable
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/esm/_internal/{alertdialog.1.js → AlertDialog.js} +8 -8
- package/esm/_internal/AlertDialog.js.map +1 -0
- package/esm/_internal/{autocompletemultiple.2.js → AutocompleteMultiple.js} +9 -9
- package/esm/_internal/AutocompleteMultiple.js.map +1 -0
- package/esm/_internal/{avatar.3.js → Avatar2.js} +4 -4
- package/esm/_internal/Avatar2.js.map +1 -0
- package/esm/_internal/{badge.4.js → Badge2.js} +3 -3
- package/esm/_internal/Badge2.js.map +1 -0
- package/esm/_internal/{button.5.js → Button2.js} +5 -5
- package/esm/_internal/Button2.js.map +1 -0
- package/esm/_internal/{buttongroup.7.js → ButtonGroup.js} +3 -3
- package/esm/_internal/ButtonGroup.js.map +1 -0
- package/esm/_internal/{buttonroot.57.js → ButtonRoot.js} +4 -4
- package/esm/_internal/ButtonRoot.js.map +1 -0
- package/esm/_internal/{checkbox.8.js → Checkbox2.js} +10 -8
- package/esm/_internal/Checkbox2.js.map +1 -0
- package/esm/_internal/{chip.9.js → Chip2.js} +3 -3
- package/esm/_internal/Chip2.js.map +1 -0
- package/esm/_internal/{chipgroup.10.js → ChipGroup.js} +3 -3
- package/esm/_internal/ChipGroup.js.map +1 -0
- package/esm/_internal/{clickawayprovider.60.js → ClickAwayProvider.js} +4 -4
- package/esm/_internal/ClickAwayProvider.js.map +1 -0
- package/esm/_internal/{commentblock.11.js → CommentBlock.js} +5 -5
- package/esm/_internal/CommentBlock.js.map +1 -0
- package/esm/_internal/{datepickerfield.12.js → DatePickerField.js} +9 -9
- package/esm/_internal/DatePickerField.js.map +1 -0
- package/esm/_internal/{dialog.13.js → Dialog2.js} +12 -12
- package/esm/_internal/Dialog2.js.map +1 -0
- package/esm/_internal/{divider.14.js → Divider2.js} +3 -3
- package/esm/_internal/Divider2.js.map +1 -0
- package/esm/_internal/{draghandle.15.js → DragHandle.js} +4 -4
- package/esm/_internal/DragHandle.js.map +1 -0
- package/esm/_internal/{dropdown.16.js → Dropdown2.js} +6 -6
- package/esm/_internal/Dropdown2.js.map +1 -0
- package/esm/_internal/{expansionpanel.17.js → ExpansionPanel.js} +8 -8
- package/esm/_internal/ExpansionPanel.js.map +1 -0
- package/esm/_internal/{flag.18.js → Flag2.js} +4 -4
- package/esm/_internal/Flag2.js.map +1 -0
- package/esm/_internal/{flexbox.19.js → FlexBox.js} +3 -3
- package/esm/_internal/FlexBox.js.map +1 -0
- package/esm/_internal/{griditem.20.js → GridItem.js} +3 -3
- package/esm/_internal/GridItem.js.map +1 -0
- package/esm/_internal/{icon.21.js → Icon2.js} +3 -3
- package/esm/_internal/Icon2.js.map +1 -0
- package/esm/_internal/{iconbutton.6.js → IconButton.js} +6 -6
- package/esm/_internal/IconButton.js.map +1 -0
- package/esm/_internal/{imageblock.22.js → ImageBlock.js} +4 -4
- package/esm/_internal/ImageBlock.js.map +1 -0
- package/esm/_internal/{inputhelper.23.js → InputHelper.js} +3 -3
- package/esm/_internal/InputHelper.js.map +1 -0
- package/esm/_internal/{inputlabel.24.js → InputLabel.js} +3 -3
- package/esm/_internal/InputLabel.js.map +1 -0
- package/esm/_internal/{lightbox.25.js → Lightbox2.js} +11 -11
- package/esm/_internal/Lightbox2.js.map +1 -0
- package/esm/_internal/{link.26.js → Link2.js} +5 -5
- package/esm/_internal/Link2.js.map +1 -0
- package/esm/_internal/{linkpreview.27.js → LinkPreview.js} +5 -5
- package/esm/_internal/LinkPreview.js.map +1 -0
- package/esm/_internal/{list.28.js → List2.js} +6 -6
- package/esm/_internal/List2.js.map +1 -0
- package/esm/_internal/{listsubheader.29.js → ListSubheader.js} +3 -3
- package/esm/_internal/ListSubheader.js.map +1 -0
- package/esm/_internal/{message.30.js → Message2.js} +4 -4
- package/esm/_internal/Message2.js.map +1 -0
- package/esm/_internal/{mosaic.31.js → Mosaic2.js} +4 -4
- package/esm/_internal/Mosaic2.js.map +1 -0
- package/esm/_internal/{notification.32.js → Notification2.js} +7 -7
- package/esm/_internal/Notification2.js.map +1 -0
- package/esm/_internal/{popover.33.js → Popover2.js} +31 -8
- package/esm/_internal/Popover2.js.map +1 -0
- package/esm/_internal/{postblock.34.js → PostBlock.js} +5 -5
- package/esm/_internal/PostBlock.js.map +1 -0
- package/esm/_internal/{progress.35.js → Progress2.js} +3 -3
- package/esm/_internal/Progress2.js.map +1 -0
- package/esm/_internal/{progresstrackersteppanel.36.js → ProgressTrackerStepPanel.js} +8 -8
- package/esm/_internal/ProgressTrackerStepPanel.js.map +1 -0
- package/esm/_internal/{radiogroup.37.js → RadioGroup.js} +6 -6
- package/esm/_internal/RadioGroup.js.map +1 -0
- package/esm/_internal/{selectmultiple.38.js → SelectMultiple.js} +12 -12
- package/esm/_internal/SelectMultiple.js.map +1 -0
- package/esm/_internal/{sidenavigationitem.39.js → SideNavigationItem.js} +15 -11
- package/esm/_internal/SideNavigationItem.js.map +1 -0
- package/esm/_internal/{skeletontypography.40.js → SkeletonTypography.js} +3 -3
- package/esm/_internal/SkeletonTypography.js.map +1 -0
- package/esm/_internal/{slider.41.js → Slider2.js} +6 -6
- package/esm/_internal/Slider2.js.map +1 -0
- package/esm/_internal/{slides.42.js → Slides.js} +8 -8
- package/esm/_internal/Slides.js.map +1 -0
- package/esm/_internal/{switch.43.js → Switch2.js} +6 -6
- package/esm/_internal/Switch2.js.map +1 -0
- package/esm/_internal/{tabpanel.45.js → TabPanel.js} +6 -6
- package/esm/_internal/TabPanel.js.map +1 -0
- package/esm/_internal/{tablerow.44.js → TableRow.js} +4 -4
- package/esm/_internal/TableRow.js.map +1 -0
- package/esm/_internal/{textfield.46.js → TextField.js} +9 -9
- package/esm/_internal/TextField.js.map +1 -0
- package/esm/_internal/{thumbnail.47.js → Thumbnail2.js} +6 -6
- package/esm/_internal/Thumbnail2.js.map +1 -0
- package/esm/_internal/{toolbar.49.js → Toolbar2.js} +3 -3
- package/esm/_internal/Toolbar2.js.map +1 -0
- package/esm/_internal/{tooltip.50.js → Tooltip2.js} +17 -19
- package/esm/_internal/Tooltip2.js.map +1 -0
- package/esm/_internal/{uploader.51.js → Uploader2.js} +4 -4
- package/esm/_internal/Uploader2.js.map +1 -0
- package/esm/_internal/{userblock.52.js → UserBlock.js} +14 -7
- package/esm/_internal/UserBlock.js.map +1 -0
- package/esm/_internal/{_rolluppluginbabelhelpers.53.js → _rollupPluginBabelHelpers.js} +1 -1
- package/esm/_internal/_rollupPluginBabelHelpers.js.map +1 -0
- package/esm/_internal/alert-dialog.js +19 -19
- package/esm/_internal/autocomplete.js +20 -21
- package/esm/_internal/autocomplete.js.map +1 -1
- package/esm/_internal/avatar.js +6 -6
- package/esm/_internal/badge.js +3 -3
- package/esm/_internal/button.js +14 -15
- package/esm/_internal/button.js.map +1 -1
- package/esm/_internal/checkbox.js +7 -7
- package/esm/_internal/chip.js +4 -4
- package/esm/_internal/comment-block.js +12 -13
- package/esm/_internal/comment-block.js.map +1 -1
- package/esm/_internal/components.js +1 -1
- package/esm/_internal/{constants.59.js → constants.js} +1 -1
- package/esm/_internal/constants.js.map +1 -0
- package/esm/_internal/date-picker.js +18 -19
- package/esm/_internal/date-picker.js.map +1 -1
- package/esm/_internal/dialog.js +12 -12
- package/esm/_internal/divider.js +3 -3
- package/esm/_internal/drag-handle.js +4 -4
- package/esm/_internal/dropdown.js +10 -11
- package/esm/_internal/dropdown.js.map +1 -1
- package/esm/_internal/expansion-panel.js +16 -17
- package/esm/_internal/expansion-panel.js.map +1 -1
- package/esm/_internal/flag.js +4 -4
- package/esm/_internal/flex-box.js +3 -3
- package/esm/_internal/{getrootclassname.54.js → getRootClassName.js} +2 -2
- package/esm/_internal/getRootClassName.js.map +1 -0
- package/esm/_internal/grid.js +3 -3
- package/esm/_internal/icon.js +3 -3
- package/esm/_internal/image-block.js +6 -6
- package/esm/_internal/input-helper.js +3 -3
- package/esm/_internal/input-label.js +3 -3
- package/esm/_internal/lightbox.js +16 -17
- package/esm/_internal/lightbox.js.map +1 -1
- package/esm/_internal/link-preview.js +8 -8
- package/esm/_internal/link.js +5 -5
- package/esm/_internal/list.js +7 -7
- package/esm/_internal/{mergerefs.56.js → mergeRefs.js} +1 -1
- package/esm/_internal/mergeRefs.js.map +1 -0
- package/esm/_internal/message.js +4 -4
- package/esm/_internal/mosaic.js +6 -6
- package/esm/_internal/notification.js +9 -9
- package/esm/_internal/{partitionmulti.62.js → partitionMulti.js} +1 -1
- package/esm/_internal/partitionMulti.js.map +1 -0
- package/esm/_internal/popover.js +6 -7
- package/esm/_internal/popover.js.map +1 -1
- package/esm/_internal/post-block.js +7 -7
- package/esm/_internal/progress-tracker.js +9 -9
- package/esm/_internal/progress.js +3 -3
- package/esm/_internal/radio-button.js +6 -6
- package/esm/_internal/{renderlink.65.js → renderLink.js} +2 -2
- package/esm/_internal/renderLink.js.map +1 -0
- package/esm/_internal/select.js +19 -20
- package/esm/_internal/select.js.map +1 -1
- package/esm/_internal/side-navigation.js +14 -15
- package/esm/_internal/side-navigation.js.map +1 -1
- package/esm/_internal/skeleton.js +3 -3
- package/esm/_internal/slider.js +6 -6
- package/esm/_internal/slideshow.js +13 -14
- package/esm/_internal/slideshow.js.map +1 -1
- package/esm/_internal/switch.js +6 -6
- package/esm/_internal/table.js +4 -4
- package/esm/_internal/tabs.js +7 -7
- package/esm/_internal/text-field.js +15 -16
- package/esm/_internal/text-field.js.map +1 -1
- package/esm/_internal/thumbnail.js +6 -6
- package/esm/_internal/toolbar.js +3 -3
- package/esm/_internal/tooltip.js +8 -9
- package/esm/_internal/tooltip.js.map +1 -1
- package/esm/_internal/{type.64.js → type.js} +1 -1
- package/esm/_internal/type.js.map +1 -0
- package/esm/_internal/{types.48.js → types.js} +3 -2
- package/esm/_internal/types.js.map +1 -0
- package/esm/_internal/uploader.js +4 -4
- package/esm/_internal/{usedelayedvisibility.63.js → useDelayedVisibility.js} +2 -2
- package/esm/_internal/useDelayedVisibility.js.map +1 -0
- package/esm/_internal/{usedisablebodyscroll.61.js → useDisableBodyScroll.js} +1 -1
- package/esm/_internal/useDisableBodyScroll.js.map +1 -0
- package/esm/_internal/{usefocustrap.58.js → useFocusTrap.js} +24 -15
- package/esm/_internal/useFocusTrap.js.map +1 -0
- package/esm/_internal/{userovingtabindex.66.js → useRovingTabIndex.js} +3 -3
- package/esm/_internal/useRovingTabIndex.js.map +1 -0
- package/esm/_internal/user-block.js +10 -9
- package/esm/_internal/user-block.js.map +1 -1
- package/esm/index.js +90 -0
- package/{index.js.map → esm/index.js.map} +0 -0
- package/esm/{_internal/index.55.js → index2.js} +1 -1
- package/esm/index2.js.map +1 -0
- package/package.json +9 -12
- package/src/components/button/Button.stories.tsx +1 -0
- package/src/components/button/ButtonRoot.tsx +4 -4
- package/src/components/checkbox/Checkbox.tsx +2 -1
- package/src/components/checkbox/__snapshots__/Checkbox.test.tsx.snap +4 -0
- package/src/components/dialog/Dialog.stories.tsx +4 -1
- package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +85 -77
- package/src/components/side-navigation/SideNavigation.stories.tsx +26 -0
- package/src/components/side-navigation/SideNavigationItem.test.tsx +19 -2
- package/src/components/side-navigation/SideNavigationItem.tsx +10 -2
- package/src/components/side-navigation/__snapshots__/SideNavigationItem.test.tsx.snap +1 -1
- package/src/components/thumbnail/index.ts +1 -0
- package/src/components/tooltip/Tooltip.tsx +2 -5
- package/src/components/tooltip/useTooltipOpen.tsx +7 -4
- package/src/components/user-block/UserBlock.stories.tsx +4 -4
- package/src/components/user-block/UserBlock.tsx +9 -3
- package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +51 -8
- package/src/hooks/useBooleanState.tsx +4 -10
- package/src/hooks/useFocusTrap.ts +2 -28
- package/src/stories/generated/Dialog/Demos.stories.tsx +1 -0
- package/src/utils/focus/getFirstAndLastFocusable.test.ts +128 -0
- package/src/utils/focus/getFirstAndLastFocusable.ts +27 -0
- package/{index.d.ts → types.d.ts} +13 -9
- package/esm/_internal/_rolluppluginbabelhelpers.53.js.map +0 -1
- package/esm/_internal/alertdialog.1.js.map +0 -1
- package/esm/_internal/autocompletemultiple.2.js.map +0 -1
- package/esm/_internal/avatar.3.js.map +0 -1
- package/esm/_internal/badge.4.js.map +0 -1
- package/esm/_internal/button.5.js.map +0 -1
- package/esm/_internal/buttongroup.7.js.map +0 -1
- package/esm/_internal/buttonroot.57.js.map +0 -1
- package/esm/_internal/checkbox.8.js.map +0 -1
- package/esm/_internal/chip.9.js.map +0 -1
- package/esm/_internal/chipgroup.10.js.map +0 -1
- package/esm/_internal/clickawayprovider.60.js.map +0 -1
- package/esm/_internal/commentblock.11.js.map +0 -1
- package/esm/_internal/constants.59.js.map +0 -1
- package/esm/_internal/datepickerfield.12.js.map +0 -1
- package/esm/_internal/dialog.13.js.map +0 -1
- package/esm/_internal/divider.14.js.map +0 -1
- package/esm/_internal/draghandle.15.js.map +0 -1
- package/esm/_internal/dropdown.16.js.map +0 -1
- package/esm/_internal/expansionpanel.17.js.map +0 -1
- package/esm/_internal/flag.18.js.map +0 -1
- package/esm/_internal/flexbox.19.js.map +0 -1
- package/esm/_internal/getrootclassname.54.js.map +0 -1
- package/esm/_internal/griditem.20.js.map +0 -1
- package/esm/_internal/icon.21.js.map +0 -1
- package/esm/_internal/iconbutton.6.js.map +0 -1
- package/esm/_internal/imageblock.22.js.map +0 -1
- package/esm/_internal/index.55.js.map +0 -1
- package/esm/_internal/inputhelper.23.js.map +0 -1
- package/esm/_internal/inputlabel.24.js.map +0 -1
- package/esm/_internal/lightbox.25.js.map +0 -1
- package/esm/_internal/link.26.js.map +0 -1
- package/esm/_internal/linkpreview.27.js.map +0 -1
- package/esm/_internal/list.28.js.map +0 -1
- package/esm/_internal/listsubheader.29.js.map +0 -1
- package/esm/_internal/mergerefs.56.js.map +0 -1
- package/esm/_internal/message.30.js.map +0 -1
- package/esm/_internal/mosaic.31.js.map +0 -1
- package/esm/_internal/notification.32.js.map +0 -1
- package/esm/_internal/partitionmulti.62.js.map +0 -1
- package/esm/_internal/popover.33.js.map +0 -1
- package/esm/_internal/postblock.34.js.map +0 -1
- package/esm/_internal/progress.35.js.map +0 -1
- package/esm/_internal/progresstrackersteppanel.36.js.map +0 -1
- package/esm/_internal/radiogroup.37.js.map +0 -1
- package/esm/_internal/renderlink.65.js.map +0 -1
- package/esm/_internal/selectmultiple.38.js.map +0 -1
- package/esm/_internal/sidenavigationitem.39.js.map +0 -1
- package/esm/_internal/skeletontypography.40.js.map +0 -1
- package/esm/_internal/slider.41.js.map +0 -1
- package/esm/_internal/slides.42.js.map +0 -1
- package/esm/_internal/switch.43.js.map +0 -1
- package/esm/_internal/tablerow.44.js.map +0 -1
- package/esm/_internal/tabpanel.45.js.map +0 -1
- package/esm/_internal/textfield.46.js.map +0 -1
- package/esm/_internal/thumbnail.47.js.map +0 -1
- package/esm/_internal/toolbar.49.js.map +0 -1
- package/esm/_internal/tooltip.50.js.map +0 -1
- package/esm/_internal/type.64.js.map +0 -1
- package/esm/_internal/types.48.js.map +0 -1
- package/esm/_internal/uploader.51.js.map +0 -1
- package/esm/_internal/usedelayedvisibility.63.js.map +0 -1
- package/esm/_internal/usedisablebodyscroll.61.js.map +0 -1
- package/esm/_internal/usefocustrap.58.js.map +0 -1
- package/esm/_internal/userblock.52.js.map +0 -1
- package/esm/_internal/userovingtabindex.66.js.map +0 -1
- package/hooks/useFocusWithin.d.ts +0 -16
- package/hooks/useFocusWithin.js +0 -28
- package/hooks/useFocusWithin.js.map +0 -1
- package/index.js +0 -90
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRovingTabIndex.js","sources":["../../../src/components/tabs/state.ts","../../../src/hooks/useRovingTabIndex.tsx"],"sourcesContent":["import { Dispatch, createContext, useCallback, useContext, useEffect, useMemo } from 'react';\nimport { uid } from 'uid';\n\ntype TabType = 'tab' | 'tabPanel';\n\nexport interface State {\n isLazy: boolean;\n shouldActivateOnFocus: boolean;\n activeTabIndex: number;\n ids: Record<TabType, string[]>;\n}\n\nexport const INIT_STATE: State = {\n isLazy: true,\n shouldActivateOnFocus: false,\n activeTabIndex: 0,\n ids: { tab: [], tabPanel: [] },\n};\n\nexport type Action =\n | { type: 'update'; payload: Partial<State> }\n | { type: 'setActiveTabIndex'; payload: number }\n | { type: 'register'; payload: { type: TabType; id: string } }\n | { type: 'unregister'; payload: { type: TabType; id: string } };\n\nexport const reducer = (state: State, action: Action): State => {\n switch (action.type) {\n case 'update':\n return { ...state, ...action.payload };\n case 'setActiveTabIndex': {\n if (state.activeTabIndex === action.payload) {\n return state;\n }\n // Change active tab index.\n return { ...state, activeTabIndex: action.payload };\n }\n case 'register': {\n const { type, id } = action.payload;\n // Append tab/tabPanel id in state.\n return { ...state, ids: { ...state.ids, [type]: [...state.ids[type], id] } };\n }\n case 'unregister': {\n const { type, id } = action.payload;\n const index = state.ids[type].indexOf(id);\n if (index === -1) return state;\n // Remove tab & tab panel at index.\n const tabIds = [...state.ids.tab];\n tabIds.splice(index, 1);\n const tabPanelIds = [...state.ids.tabPanel];\n tabPanelIds.splice(index, 1);\n return {\n ...state,\n ids: { tab: tabIds, tabPanel: tabPanelIds },\n };\n }\n default:\n return state;\n }\n};\n\nexport const TabProviderContext = createContext<[State, Dispatch<Action>] | null>(null);\n\nexport type TabState = Pick<Required<State>, 'isLazy' | 'shouldActivateOnFocus'> & {\n isActive: boolean;\n tabId: string;\n tabPanelId: string;\n changeToTab(): void;\n};\n\n/* eslint-disable react-hooks/rules-of-hooks */\nexport const useTabProviderContext = (type: TabType, originalId?: string): undefined | TabState => {\n const context = useContext(TabProviderContext);\n if (!context) {\n return undefined;\n }\n const [state, dispatch] = context;\n\n // Current tab or tab panel id.\n const id = useMemo(\n () => originalId || `${type}-${uid()}`,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n useEffect(\n () => {\n // On mount: register tab or tab panel id.\n dispatch({ type: 'register', payload: { type, id } });\n return () => {\n // On unmount: unregister tab or tab panel id.\n dispatch({ type: 'unregister', payload: { type, id } });\n };\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n // Find tab/tabPanel index using it's id.\n const index = useMemo(() => state.ids[type].indexOf(id), [state.ids, type, id]);\n const tabId = useMemo(() => state.ids.tab[index] || '', [state, index]);\n const tabPanelId = useMemo(() => state.ids.tabPanel[index] || '', [state, index]);\n const isActive = useMemo(() => state.activeTabIndex === index, [state, index]);\n const changeToTab = useCallback(() => dispatch({ type: 'setActiveTabIndex', payload: index }), [dispatch, index]);\n return {\n isLazy: state.isLazy,\n shouldActivateOnFocus: state.shouldActivateOnFocus,\n tabId,\n tabPanelId,\n isActive,\n changeToTab,\n };\n};\n\nexport const useTabProviderContextState = (): State | undefined => {\n const context = useContext(TabProviderContext);\n return context?.[0];\n};\n","import { RefObject, useEffect } from 'react';\n\ninterface UseRovingTabIndexOptions {\n parentRef: RefObject<HTMLElement>;\n elementSelector: string;\n keepTabIndex?: boolean;\n /** List of values to be used as extra dependencies of the useEffect */\n extraDependencies?: any[];\n}\n\nexport const useRovingTabIndex = ({\n parentRef,\n elementSelector,\n keepTabIndex,\n extraDependencies = [],\n}: UseRovingTabIndexOptions): void => {\n useEffect(\n () => {\n const parent = parentRef?.current;\n if (!parent) {\n return undefined;\n }\n\n const elements = parent.querySelectorAll(elementSelector) as NodeListOf<HTMLElement>;\n const initialFocusableElement = parent?.querySelector(`${elementSelector}[tabindex=\"0\"]`);\n\n const handleKeyDown = (index: number) => (evt: KeyboardEvent) => {\n let newTabFocus = index;\n if (!(evt.key === 'ArrowRight' || evt.key === 'ArrowLeft')) {\n return;\n }\n\n if (evt.key === 'ArrowRight') {\n // Move right\n newTabFocus += 1;\n // If we're at the end, go to the start\n if (newTabFocus >= elements.length) {\n newTabFocus = 0;\n }\n } else if (evt.key === 'ArrowLeft') {\n // Move left\n newTabFocus -= 1;\n if (newTabFocus < 0) {\n // If we're at the start, move to the end\n newTabFocus = elements.length - 1;\n }\n }\n const newElement = elements[newTabFocus];\n newElement?.focus();\n if (keepTabIndex) {\n (evt.currentTarget as HTMLElement).setAttribute('tabindex', '-1');\n newElement?.setAttribute('tabindex', '0');\n }\n };\n\n if (elements?.length > 0) {\n elements.forEach((el, key) => {\n // if no element has tabindex set to 0, set the first element as focusable\n if (!initialFocusableElement && key === 0) {\n el.setAttribute('tabindex', '0');\n // set all other to -1\n } else if (initialFocusableElement !== el) {\n el.setAttribute('tabindex', '-1');\n }\n // add event listener\n el.addEventListener('keydown', handleKeyDown(key) as EventListener);\n });\n }\n\n // Cleanup listeners\n return () => {\n if (elements?.length > 0) {\n elements.forEach((el, key) => {\n el.removeEventListener('keydown', handleKeyDown(key) as EventListener);\n });\n }\n };\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [parentRef, ...extraDependencies],\n );\n};\n"],"names":["INIT_STATE","isLazy","shouldActivateOnFocus","activeTabIndex","ids","tab","tabPanel","reducer","state","action","type","payload","id","index","indexOf","tabIds","splice","tabPanelIds","TabProviderContext","createContext","useTabProviderContext","originalId","context","useContext","undefined","dispatch","useMemo","uid","useEffect","tabId","tabPanelId","isActive","changeToTab","useCallback","useTabProviderContextState","useRovingTabIndex","parentRef","elementSelector","keepTabIndex","extraDependencies","parent","current","elements","querySelectorAll","initialFocusableElement","querySelector","handleKeyDown","evt","newTabFocus","key","length","newElement","focus","currentTarget","setAttribute","forEach","el","addEventListener","removeEventListener"],"mappings":";;;;IAYaA,UAAiB,GAAG;AAC7BC,EAAAA,MAAM,EAAE,IADqB;AAE7BC,EAAAA,qBAAqB,EAAE,KAFM;AAG7BC,EAAAA,cAAc,EAAE,CAHa;AAI7BC,EAAAA,GAAG,EAAE;AAAEC,IAAAA,GAAG,EAAE,EAAP;AAAWC,IAAAA,QAAQ,EAAE;AAArB;AAJwB;IAapBC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAeC,MAAf,EAAyC;AAC5D,UAAQA,MAAM,CAACC,IAAf;AACI,SAAK,QAAL;AACI,gCAAYF,K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Z,CAAyB,UAAzB,EAAqC,GAArC;AACH;AACJ,OA3BqB;AAAA,KAAtB;;AA6BA,QAAI,CAAAZ,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEQ,MAAV,IAAmB,CAAvB,EAA0B;AACtBR,MAAAA,QAAQ,CAACa,OAAT,CAAiB,UAACC,EAAD,EAAKP,GAAL,EAAa;AAC1B;AACA,YAAI,CAACL,uBAAD,IAA4BK,GAAG,KAAK,CAAxC,EAA2C;AACvCO,UAAAA,EAAE,CAACF,YAAH,CAAgB,UAAhB,EAA4B,GAA5B,EADuC;AAG1C,SAHD,MAGO,IAAIV,uBAAuB,KAAKY,EAAhC,EAAoC;AACvCA,UAAAA,EAAE,CAACF,YAAH,CAAgB,UAAhB,EAA4B,IAA5B;AACH,SAPyB;;;AAS1BE,QAAAA,EAAE,CAACC,gBAAH,CAAoB,SAApB,EAA+BX,aAAa,CAACG,GAAD,CAA5C;AACH,OAVD;AAWH,KAlDC;;;AAqDF,WAAO,YAAM;AACT,UAAI,CAAAP,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAEQ,MAAV,IAAmB,CAAvB,EAA0B;AACtBR,QAAAA,QAAQ,CAACa,OAAT,CAAiB,UAACC,EAAD,EAAKP,GAAL,EAAa;AAC1BO,UAAAA,EAAE,CAACE,mBAAH,CAAuB,SAAvB,EAAkCZ,aAAa,CAACG,GAAD,CAA/C;AACH,SAFD;AAGH;AACJ,KAND;AAOH,GA7DI;AAAA,GA8DJb,SA9DI,4BA8DUG,iBA9DV,GAAT;AAgEH;;;;"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './_rollupPluginBabelHelpers.js';
|
|
2
2
|
import './components.js';
|
|
3
3
|
import 'react';
|
|
4
|
-
import './
|
|
5
|
-
import './
|
|
4
|
+
import './getRootClassName.js';
|
|
5
|
+
import './Icon2.js';
|
|
6
6
|
import 'lodash/isBoolean';
|
|
7
7
|
import 'lodash/isEmpty';
|
|
8
8
|
import 'lodash/kebabCase';
|
|
9
9
|
import 'lodash/noop';
|
|
10
|
-
import './
|
|
11
|
-
import './
|
|
12
|
-
import './
|
|
13
|
-
import './
|
|
14
|
-
import './
|
|
15
|
-
|
|
10
|
+
import './mergeRefs.js';
|
|
11
|
+
import './Avatar2.js';
|
|
12
|
+
import './renderLink.js';
|
|
13
|
+
import './Link2.js';
|
|
14
|
+
import './Thumbnail2.js';
|
|
15
|
+
import 'lodash/set';
|
|
16
|
+
export { U as UserBlock } from './UserBlock.js';
|
|
16
17
|
//# sourceMappingURL=user-block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import './_internal/_rollupPluginBabelHelpers.js';
|
|
2
|
+
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, Size, Theme, Typography, TypographyInterface, TypographyTitleCustom } from './_internal/components.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import './_internal/getRootClassName.js';
|
|
5
|
+
export { I as Icon } from './_internal/Icon2.js';
|
|
6
|
+
import './index2.js';
|
|
7
|
+
import 'lodash/isBoolean';
|
|
8
|
+
import 'lodash/isEmpty';
|
|
9
|
+
import 'lodash/kebabCase';
|
|
10
|
+
import 'lodash/noop';
|
|
11
|
+
import './_internal/constants.js';
|
|
12
|
+
import 'lodash/concat';
|
|
13
|
+
import 'lodash/dropRight';
|
|
14
|
+
import 'lodash/last';
|
|
15
|
+
import 'lodash/partition';
|
|
16
|
+
import 'lodash/reduce';
|
|
17
|
+
import './_internal/partitionMulti.js';
|
|
18
|
+
import 'lodash/get';
|
|
19
|
+
import './_internal/type.js';
|
|
20
|
+
export { A as AlertDialog } from './_internal/AlertDialog.js';
|
|
21
|
+
export { P as Placement, a as Popover } from './_internal/Popover2.js';
|
|
22
|
+
import './_internal/mergeRefs.js';
|
|
23
|
+
export { A as Autocomplete, a as AutocompleteMultiple } from './_internal/AutocompleteMultiple.js';
|
|
24
|
+
export { A as Avatar } from './_internal/Avatar2.js';
|
|
25
|
+
export { B as Badge } from './_internal/Badge2.js';
|
|
26
|
+
import './_internal/renderLink.js';
|
|
27
|
+
import './_internal/ButtonRoot.js';
|
|
28
|
+
export { a as Button, B as ButtonEmphasis } from './_internal/Button2.js';
|
|
29
|
+
export { I as IconButton } from './_internal/IconButton.js';
|
|
30
|
+
export { B as ButtonGroup } from './_internal/ButtonGroup.js';
|
|
31
|
+
export { C as Checkbox } from './_internal/Checkbox2.js';
|
|
32
|
+
import 'lodash/isFunction';
|
|
33
|
+
export { C as Chip } from './_internal/Chip2.js';
|
|
34
|
+
export { C as ChipGroup } from './_internal/ChipGroup.js';
|
|
35
|
+
export { a as CommentBlock, C as CommentBlockVariant } from './_internal/CommentBlock.js';
|
|
36
|
+
import 'moment';
|
|
37
|
+
export { D as DatePicker, a as DatePickerControlled, b as DatePickerField } from './_internal/DatePickerField.js';
|
|
38
|
+
import 'lodash/range';
|
|
39
|
+
import 'moment-range';
|
|
40
|
+
import './_internal/useFocusTrap.js';
|
|
41
|
+
import 'react-dom';
|
|
42
|
+
import './_internal/ClickAwayProvider.js';
|
|
43
|
+
export { D as Dialog } from './_internal/Dialog2.js';
|
|
44
|
+
import 'lodash/pull';
|
|
45
|
+
import './_internal/useDelayedVisibility.js';
|
|
46
|
+
import './_internal/useDisableBodyScroll.js';
|
|
47
|
+
export { D as DEFAULT_PROPS, a as Divider } from './_internal/Divider2.js';
|
|
48
|
+
export { D as DragHandle } from './_internal/DragHandle.js';
|
|
49
|
+
export { L as List, a as ListItem, i as isClickable } from './_internal/List2.js';
|
|
50
|
+
export { D as Dropdown } from './_internal/Dropdown2.js';
|
|
51
|
+
export { E as ExpansionPanel } from './_internal/ExpansionPanel.js';
|
|
52
|
+
export { F as Flag } from './_internal/Flag2.js';
|
|
53
|
+
import 'lodash/castArray';
|
|
54
|
+
export { F as FlexBox } from './_internal/FlexBox.js';
|
|
55
|
+
export { G as Grid, a as GridItem } from './_internal/GridItem.js';
|
|
56
|
+
import 'lodash/isObject';
|
|
57
|
+
export { a as ImageBlock, I as ImageBlockCaptionPosition } from './_internal/ImageBlock.js';
|
|
58
|
+
export { I as InputHelper } from './_internal/InputHelper.js';
|
|
59
|
+
export { I as InputLabel } from './_internal/InputLabel.js';
|
|
60
|
+
export { L as Lightbox } from './_internal/Lightbox2.js';
|
|
61
|
+
export { L as Link } from './_internal/Link2.js';
|
|
62
|
+
export { L as LinkPreview } from './_internal/LinkPreview.js';
|
|
63
|
+
export { L as ListDivider, a as ListSubheader } from './_internal/ListSubheader.js';
|
|
64
|
+
export { M as Message } from './_internal/Message2.js';
|
|
65
|
+
import 'lodash/take';
|
|
66
|
+
export { M as Mosaic } from './_internal/Mosaic2.js';
|
|
67
|
+
export { N as Notification } from './_internal/Notification2.js';
|
|
68
|
+
export { P as PostBlock } from './_internal/PostBlock.js';
|
|
69
|
+
export { a as Progress, P as ProgressVariant } from './_internal/Progress2.js';
|
|
70
|
+
import './_internal/useRovingTabIndex.js';
|
|
71
|
+
export { a as ProgressTracker, P as ProgressTrackerProvider, b as ProgressTrackerStep, c as ProgressTrackerStepPanel } from './_internal/ProgressTrackerStepPanel.js';
|
|
72
|
+
export { R as RadioButton, a as RadioGroup } from './_internal/RadioGroup.js';
|
|
73
|
+
export { a as Select, c as SelectMultiple, b as SelectMultipleField, S as SelectVariant } from './_internal/SelectMultiple.js';
|
|
74
|
+
export { S as SideNavigation, a as SideNavigationItem } from './_internal/SideNavigationItem.js';
|
|
75
|
+
export { S as SkeletonCircle, b as SkeletonRectangle, a as SkeletonRectangleVariant, c as SkeletonTypography } from './_internal/SkeletonTypography.js';
|
|
76
|
+
export { S as Slider, c as clamp } from './_internal/Slider2.js';
|
|
77
|
+
export { c as Slides, S as Slideshow, b as SlideshowControls, a as SlideshowItem } from './_internal/Slides.js';
|
|
78
|
+
import 'lodash/uniqueId';
|
|
79
|
+
export { S as Switch } from './_internal/Switch2.js';
|
|
80
|
+
export { T as Table, a as TableBody, d as TableCell, c as TableCellVariant, e as TableHeader, f as TableRow, b as ThOrder } from './_internal/TableRow.js';
|
|
81
|
+
export { c as Tab, b as TabList, a as TabListLayout, d as TabPanel, T as TabProvider } from './_internal/TabPanel.js';
|
|
82
|
+
export { T as TextField } from './_internal/TextField.js';
|
|
83
|
+
export { T as Thumbnail, u as useFocusPointStyle } from './_internal/Thumbnail2.js';
|
|
84
|
+
export { T as ThumbnailAspectRatio, a as ThumbnailVariant } from './_internal/types.js';
|
|
85
|
+
export { T as Toolbar } from './_internal/Toolbar2.js';
|
|
86
|
+
export { T as Tooltip } from './_internal/Tooltip2.js';
|
|
87
|
+
export { a as Uploader, U as UploaderVariant } from './_internal/Uploader2.js';
|
|
88
|
+
import 'lodash/set';
|
|
89
|
+
export { U as UserBlock } from './_internal/UserBlock.js';
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index2.js","sources":["../../../../node_modules/uid/dist/index.mjs"],"sourcesContent":["var IDX=256, HEX=[], SIZE=256, BUFFER;\nwhile (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);\n\nexport function uid(len) {\n\tvar i=0, tmp=(len || 11);\n\tif (!BUFFER || ((IDX + tmp) > SIZE*2)) {\n\t\tfor (BUFFER='',IDX=0; i < SIZE; i++) {\n\t\t\tBUFFER += HEX[Math.random() * 256 | 0];\n\t\t}\n\t}\n\n\treturn BUFFER.substring(IDX, IDX++ + tmp);\n}\n"],"names":[],"mappings":"AAAA,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;AACtC,OAAO,GAAG,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC/D;AACO,SAAS,GAAG,CAAC,GAAG,EAAE;AACzB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AAC1B,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE;AACxC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;AACvC,GAAG,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;AAC1C,GAAG;AACH,EAAE;AACF;AACA,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AAC3C;;;;"}
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^2.2.
|
|
11
|
-
"@lumx/icons": "^2.2.
|
|
10
|
+
"@lumx/core": "^2.2.20-alpha.xss.datatable",
|
|
11
|
+
"@lumx/icons": "^2.2.20-alpha.xss.datatable",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
@@ -67,13 +67,12 @@
|
|
|
67
67
|
"rollup-plugin-babel": "^4.4.0",
|
|
68
68
|
"rollup-plugin-cleaner": "^1.0.0",
|
|
69
69
|
"rollup-plugin-copy": "^3.3.0",
|
|
70
|
-
"rollup-plugin-dts": "^4.1.0",
|
|
71
70
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
72
71
|
"rollup-plugin-ts-paths-resolve": "^1.3.0",
|
|
73
72
|
"rollup-plugin-typescript-paths": "^1.2.2",
|
|
74
73
|
"test-data-bot": "^0.8.0",
|
|
75
74
|
"ts-jest": "^26.2.0",
|
|
76
|
-
"tsconfig-paths-webpack-plugin": "^3.
|
|
75
|
+
"tsconfig-paths-webpack-plugin": "^3.3.0",
|
|
77
76
|
"typescript": "^4.1.2",
|
|
78
77
|
"yargs": "^15.4.1",
|
|
79
78
|
"yarn": "^1.19.1"
|
|
@@ -99,12 +98,10 @@
|
|
|
99
98
|
"React"
|
|
100
99
|
],
|
|
101
100
|
"license": "MIT",
|
|
102
|
-
"
|
|
101
|
+
"module": "esm/index.js",
|
|
102
|
+
"main": "esm/index.js",
|
|
103
|
+
"types": "types.d.ts",
|
|
103
104
|
"name": "@lumx/react",
|
|
104
|
-
"exports": {
|
|
105
|
-
".": "./index.js",
|
|
106
|
-
"./hooks/*": "./hooks/*.js"
|
|
107
|
-
},
|
|
108
105
|
"publishConfig": {
|
|
109
106
|
"directory": "dist"
|
|
110
107
|
},
|
|
@@ -114,7 +111,7 @@
|
|
|
114
111
|
},
|
|
115
112
|
"scripts": {
|
|
116
113
|
"build": "rollup -c && yarn generate:types",
|
|
117
|
-
"generate:types": "dts-bundle-generator --no-check --external-types=react --external-imports=moment -o dist/
|
|
114
|
+
"generate:types": "dts-bundle-generator --no-check --external-types=react --external-imports=moment -o dist/types.d.ts src/index.ts",
|
|
118
115
|
"prepare": "install-peers || exit 0",
|
|
119
116
|
"prepublishOnly": "yarn build",
|
|
120
117
|
"test": "jest --config jest/index.js --coverage --notify --passWithNoTests --detectOpenHandles --runInBand",
|
|
@@ -123,6 +120,6 @@
|
|
|
123
120
|
"build:storybook": "cd storybook && ./build"
|
|
124
121
|
},
|
|
125
122
|
"sideEffects": false,
|
|
126
|
-
"version": "2.2.
|
|
127
|
-
"gitHead": "
|
|
123
|
+
"version": "2.2.20-alpha.xss.datatable",
|
|
124
|
+
"gitHead": "f3e5a90ee87b5f78417bff7015fa43852205a69d"
|
|
128
125
|
}
|
|
@@ -13,6 +13,7 @@ const DEFAULT_PROPS = Button.defaultProps as any;
|
|
|
13
13
|
export const SimpleButton = ({ theme }: any) => {
|
|
14
14
|
return (
|
|
15
15
|
<Button
|
|
16
|
+
aria-pressed={boolean('isSelected', Boolean(DEFAULT_PROPS.isSelected))}
|
|
16
17
|
emphasis={emphasis('Emphasis', DEFAULT_PROPS.emphasis)}
|
|
17
18
|
theme={theme}
|
|
18
19
|
rightIcon={select('Right icon', { none: undefined, mdiSend }, undefined)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ButtonHTMLAttributes, DetailedHTMLProps, forwardRef, RefObject } from 'react';
|
|
1
|
+
import React, { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps, forwardRef, RefObject } from 'react';
|
|
2
2
|
|
|
3
3
|
import isEmpty from 'lodash/isEmpty';
|
|
4
4
|
|
|
@@ -16,9 +16,9 @@ type HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>
|
|
|
16
16
|
*/
|
|
17
17
|
export type ButtonSize = Extract<Size, 's' | 'm'>;
|
|
18
18
|
|
|
19
|
-
export interface BaseButtonProps
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
export interface BaseButtonProps
|
|
20
|
+
extends GenericProps,
|
|
21
|
+
Pick<AriaAttributes, 'aria-expanded' | 'aria-haspopup' | 'aria-pressed' | 'aria-label'> {
|
|
22
22
|
/** Color variant. */
|
|
23
23
|
color?: Color;
|
|
24
24
|
/** Emphasis variant. */
|
|
@@ -112,6 +112,7 @@ export const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props,
|
|
|
112
112
|
value={value}
|
|
113
113
|
checked={isChecked}
|
|
114
114
|
onChange={handleChange}
|
|
115
|
+
aria-describedby={helper ? `${inputId}-helper` : undefined}
|
|
115
116
|
{...inputProps}
|
|
116
117
|
/>
|
|
117
118
|
|
|
@@ -131,7 +132,7 @@ export const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props,
|
|
|
131
132
|
</InputLabel>
|
|
132
133
|
)}
|
|
133
134
|
{helper && (
|
|
134
|
-
<InputHelper className={`${CLASSNAME}__helper`} theme={theme}>
|
|
135
|
+
<InputHelper id={`${inputId}-helper`} className={`${CLASSNAME}__helper`} theme={theme}>
|
|
135
136
|
{helper}
|
|
136
137
|
</InputHelper>
|
|
137
138
|
)}
|
|
@@ -8,6 +8,7 @@ exports[`<Checkbox> Props should use the given props 1`] = `
|
|
|
8
8
|
className="lumx-checkbox__input-wrapper"
|
|
9
9
|
>
|
|
10
10
|
<input
|
|
11
|
+
aria-describedby="fixedId-helper"
|
|
11
12
|
className="lumx-checkbox__input-native"
|
|
12
13
|
id="fixedId"
|
|
13
14
|
onChange={[Function]}
|
|
@@ -41,6 +42,7 @@ exports[`<Checkbox> Props should use the given props 1`] = `
|
|
|
41
42
|
</InputLabel>
|
|
42
43
|
<InputHelper
|
|
43
44
|
className="lumx-checkbox__helper"
|
|
45
|
+
id="fixedId-helper"
|
|
44
46
|
kind="info"
|
|
45
47
|
theme="light"
|
|
46
48
|
>
|
|
@@ -58,6 +60,7 @@ exports[`<Checkbox> Props should use the given props while passing custom props
|
|
|
58
60
|
className="lumx-checkbox__input-wrapper"
|
|
59
61
|
>
|
|
60
62
|
<input
|
|
63
|
+
aria-describedby="fixedId-helper"
|
|
61
64
|
aria-labelledby="labelledby-id"
|
|
62
65
|
className="lumx-checkbox__input-native"
|
|
63
66
|
id="fixedId"
|
|
@@ -92,6 +95,7 @@ exports[`<Checkbox> Props should use the given props while passing custom props
|
|
|
92
95
|
</InputLabel>
|
|
93
96
|
<InputHelper
|
|
94
97
|
className="lumx-checkbox__helper"
|
|
98
|
+
id="fixedId-helper"
|
|
95
99
|
kind="info"
|
|
96
100
|
theme="light"
|
|
97
101
|
>
|
|
@@ -283,7 +283,8 @@ export const ScrollableDialogWithHeaderAndFooter = ({ theme }: any) => {
|
|
|
283
283
|
);
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
/** Test dialog focus trap (focus is contained inside the dialog) with all kinds of focusable and non-focusable items */
|
|
287
|
+
export const DialogFocusTrap = ({ theme }: any) => {
|
|
287
288
|
const { button, buttonRef, closeDialog, isOpen } = useOpenButton(theme);
|
|
288
289
|
const [textValue, setTextValue] = useState('value');
|
|
289
290
|
const [checkboxValue, setCheckboxValue] = useState(false);
|
|
@@ -372,6 +373,8 @@ export const DialogWithFocusableElements = ({ theme }: any) => {
|
|
|
372
373
|
|
|
373
374
|
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}
|
|
374
375
|
<div tabIndex={0}>Focus div</div>
|
|
376
|
+
|
|
377
|
+
<Button isDisabled={false}>Button explicitly not disabled (should focus)</Button>
|
|
375
378
|
</div>
|
|
376
379
|
</Dialog>
|
|
377
380
|
</>
|
|
@@ -1,82 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`<Dialog> Snapshots and structure should render story
|
|
4
|
-
<Fragment>
|
|
5
|
-
<Button
|
|
6
|
-
emphasis="high"
|
|
7
|
-
onClick={[Function]}
|
|
8
|
-
size="m"
|
|
9
|
-
theme="light"
|
|
10
|
-
>
|
|
11
|
-
Open dialog
|
|
12
|
-
</Button>
|
|
13
|
-
<Dialog
|
|
14
|
-
isOpen={true}
|
|
15
|
-
onClose={[Function]}
|
|
16
|
-
parentElement={
|
|
17
|
-
Object {
|
|
18
|
-
"current": undefined,
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
size="big"
|
|
22
|
-
>
|
|
23
|
-
<div
|
|
24
|
-
className="lumx-spacing-padding"
|
|
25
|
-
>
|
|
26
|
-
|
|
27
|
-
Nihil hic munitissimus habendi senatus locus, nihil horum? At nos hinc posthac, sitientis piros
|
|
28
|
-
Afros. Magna pars studiorum, prodita quaerimus. Integer legentibus erat a ante historiarum
|
|
29
|
-
dapibus. Praeterea iter est quasdam res quas ex communi. Ullamco laboris nisi ut aliquid ex ea
|
|
30
|
-
commodi consequat. Inmensae subtilitatis, obscuris et malesuada fames. Me non paenitet nullum
|
|
31
|
-
festiviorem excogitasse ad hoc. Cum ceteris in veneratione tui montes, nascetur mus. Etiam
|
|
32
|
-
habebis sem dicantur magna mollis euismod. Quis aute iure reprehenderit in voluptate velit esse.
|
|
33
|
-
Phasellus laoreet lorem vel dolor tempus vehicula. Ambitioni dedisse scripsisse iudicaretur.
|
|
34
|
-
Paullum deliquit, ponderibus modulisque suis ratio utitur. Ab illo tempore, ab est sed
|
|
35
|
-
immemorabili. Nec dubitamus multa iter quae et nos invenerat. Tu quoque, Brute, fili mi, nihil
|
|
36
|
-
timor populi, nihil! Morbi fringilla convallis sapien, id pulvinar odio volutpat. Cras mattis
|
|
37
|
-
iudicium purus sit amet fermentum. Vivamus sagittis lacus vel augue laoreet rutrum faucibus.
|
|
38
|
-
Quisque ut dolor gravida, placerat libero vel, euismod. Unam incolunt Belgae, aliam Aquitani,
|
|
39
|
-
tertiam. Cras mattis iudicium purus sit amet fermentum
|
|
40
|
-
</div>
|
|
41
|
-
<footer>
|
|
42
|
-
<Toolbar
|
|
43
|
-
after={
|
|
44
|
-
<Button
|
|
45
|
-
emphasis="low"
|
|
46
|
-
onClick={[Function]}
|
|
47
|
-
size="m"
|
|
48
|
-
theme="light"
|
|
49
|
-
>
|
|
50
|
-
Close
|
|
51
|
-
</Button>
|
|
52
|
-
}
|
|
53
|
-
/>
|
|
54
|
-
</footer>
|
|
55
|
-
</Dialog>
|
|
56
|
-
<AlertDialog
|
|
57
|
-
confirmProps={
|
|
58
|
-
Object {
|
|
59
|
-
"label": "Confirm",
|
|
60
|
-
"onClick": [Function],
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
isOpen={false}
|
|
64
|
-
kind="info"
|
|
65
|
-
onClose={[Function]}
|
|
66
|
-
parentElement={
|
|
67
|
-
Object {
|
|
68
|
-
"current": undefined,
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
size="tiny"
|
|
72
|
-
title="Default (info)"
|
|
73
|
-
>
|
|
74
|
-
Consequat deserunt officia aute laborum tempor anim sint est.
|
|
75
|
-
</AlertDialog>
|
|
76
|
-
</Fragment>
|
|
77
|
-
`;
|
|
78
|
-
|
|
79
|
-
exports[`<Dialog> Snapshots and structure should render story DialogWithFocusableElements 1`] = `
|
|
3
|
+
exports[`<Dialog> Snapshots and structure should render story DialogFocusTrap 1`] = `
|
|
80
4
|
<Fragment>
|
|
81
5
|
<Button
|
|
82
6
|
emphasis="high"
|
|
@@ -226,11 +150,95 @@ exports[`<Dialog> Snapshots and structure should render story DialogWithFocusabl
|
|
|
226
150
|
>
|
|
227
151
|
Focus div
|
|
228
152
|
</div>
|
|
153
|
+
<Button
|
|
154
|
+
emphasis="high"
|
|
155
|
+
isDisabled={false}
|
|
156
|
+
size="m"
|
|
157
|
+
theme="light"
|
|
158
|
+
>
|
|
159
|
+
Button explicitly not disabled (should focus)
|
|
160
|
+
</Button>
|
|
229
161
|
</div>
|
|
230
162
|
</Dialog>
|
|
231
163
|
</Fragment>
|
|
232
164
|
`;
|
|
233
165
|
|
|
166
|
+
exports[`<Dialog> Snapshots and structure should render story DialogWithAlertDialog 1`] = `
|
|
167
|
+
<Fragment>
|
|
168
|
+
<Button
|
|
169
|
+
emphasis="high"
|
|
170
|
+
onClick={[Function]}
|
|
171
|
+
size="m"
|
|
172
|
+
theme="light"
|
|
173
|
+
>
|
|
174
|
+
Open dialog
|
|
175
|
+
</Button>
|
|
176
|
+
<Dialog
|
|
177
|
+
isOpen={true}
|
|
178
|
+
onClose={[Function]}
|
|
179
|
+
parentElement={
|
|
180
|
+
Object {
|
|
181
|
+
"current": undefined,
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
size="big"
|
|
185
|
+
>
|
|
186
|
+
<div
|
|
187
|
+
className="lumx-spacing-padding"
|
|
188
|
+
>
|
|
189
|
+
|
|
190
|
+
Nihil hic munitissimus habendi senatus locus, nihil horum? At nos hinc posthac, sitientis piros
|
|
191
|
+
Afros. Magna pars studiorum, prodita quaerimus. Integer legentibus erat a ante historiarum
|
|
192
|
+
dapibus. Praeterea iter est quasdam res quas ex communi. Ullamco laboris nisi ut aliquid ex ea
|
|
193
|
+
commodi consequat. Inmensae subtilitatis, obscuris et malesuada fames. Me non paenitet nullum
|
|
194
|
+
festiviorem excogitasse ad hoc. Cum ceteris in veneratione tui montes, nascetur mus. Etiam
|
|
195
|
+
habebis sem dicantur magna mollis euismod. Quis aute iure reprehenderit in voluptate velit esse.
|
|
196
|
+
Phasellus laoreet lorem vel dolor tempus vehicula. Ambitioni dedisse scripsisse iudicaretur.
|
|
197
|
+
Paullum deliquit, ponderibus modulisque suis ratio utitur. Ab illo tempore, ab est sed
|
|
198
|
+
immemorabili. Nec dubitamus multa iter quae et nos invenerat. Tu quoque, Brute, fili mi, nihil
|
|
199
|
+
timor populi, nihil! Morbi fringilla convallis sapien, id pulvinar odio volutpat. Cras mattis
|
|
200
|
+
iudicium purus sit amet fermentum. Vivamus sagittis lacus vel augue laoreet rutrum faucibus.
|
|
201
|
+
Quisque ut dolor gravida, placerat libero vel, euismod. Unam incolunt Belgae, aliam Aquitani,
|
|
202
|
+
tertiam. Cras mattis iudicium purus sit amet fermentum
|
|
203
|
+
</div>
|
|
204
|
+
<footer>
|
|
205
|
+
<Toolbar
|
|
206
|
+
after={
|
|
207
|
+
<Button
|
|
208
|
+
emphasis="low"
|
|
209
|
+
onClick={[Function]}
|
|
210
|
+
size="m"
|
|
211
|
+
theme="light"
|
|
212
|
+
>
|
|
213
|
+
Close
|
|
214
|
+
</Button>
|
|
215
|
+
}
|
|
216
|
+
/>
|
|
217
|
+
</footer>
|
|
218
|
+
</Dialog>
|
|
219
|
+
<AlertDialog
|
|
220
|
+
confirmProps={
|
|
221
|
+
Object {
|
|
222
|
+
"label": "Confirm",
|
|
223
|
+
"onClick": [Function],
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
isOpen={false}
|
|
227
|
+
kind="info"
|
|
228
|
+
onClose={[Function]}
|
|
229
|
+
parentElement={
|
|
230
|
+
Object {
|
|
231
|
+
"current": undefined,
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
size="tiny"
|
|
235
|
+
title="Default (info)"
|
|
236
|
+
>
|
|
237
|
+
Consequat deserunt officia aute laborum tempor anim sint est.
|
|
238
|
+
</AlertDialog>
|
|
239
|
+
</Fragment>
|
|
240
|
+
`;
|
|
241
|
+
|
|
234
242
|
exports[`<Dialog> Snapshots and structure should render story DialogWithHeaderFooterAndDivider 1`] = `
|
|
235
243
|
<Fragment>
|
|
236
244
|
<Button
|
|
@@ -163,3 +163,29 @@ export const With3LevelsAndMultiActions = () => {
|
|
|
163
163
|
</SideNavigation>
|
|
164
164
|
);
|
|
165
165
|
};
|
|
166
|
+
|
|
167
|
+
/** Using closeMode="hide" keeps children in DOM on close */
|
|
168
|
+
export const CloseModeHide = () => {
|
|
169
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
170
|
+
const toggleL1 = () => setIsOpen(!isOpen);
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<SideNavigation>
|
|
174
|
+
<SideNavigationItem
|
|
175
|
+
closeMode="hide"
|
|
176
|
+
label="Level 1"
|
|
177
|
+
emphasis={Emphasis.high}
|
|
178
|
+
isOpen={isOpen}
|
|
179
|
+
onClick={toggleL1}
|
|
180
|
+
toggleButtonProps={{ label: 'Toggle' }}
|
|
181
|
+
>
|
|
182
|
+
<SideNavigationItem
|
|
183
|
+
closeMode="hide"
|
|
184
|
+
label="Level 2"
|
|
185
|
+
emphasis={Emphasis.medium}
|
|
186
|
+
toggleButtonProps={{ label: 'Toggle' }}
|
|
187
|
+
/>
|
|
188
|
+
</SideNavigationItem>
|
|
189
|
+
</SideNavigation>
|
|
190
|
+
);
|
|
191
|
+
};
|
|
@@ -2,6 +2,7 @@ import React, { ReactElement } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { mount, shallow } from 'enzyme';
|
|
4
4
|
import 'jest-enzyme';
|
|
5
|
+
import without from 'lodash/without';
|
|
5
6
|
|
|
6
7
|
import { commonTestsSuite, Wrapper } from '@lumx/react/testing/utils';
|
|
7
8
|
import { getBasicClass } from '@lumx/react/utils';
|
|
@@ -51,13 +52,28 @@ describe(`<${SideNavigationItem.displayName}>`, () => {
|
|
|
51
52
|
expect(root).toHaveClassName(CLASSNAME);
|
|
52
53
|
});
|
|
53
54
|
|
|
54
|
-
it('should render correctly with
|
|
55
|
+
it('should render correctly with split actions', () => {
|
|
55
56
|
const { root, wrapper } = setup({ linkProps: { href: 'http://toto.com' }, onClick: () => null });
|
|
56
57
|
expect(wrapper).toMatchSnapshot();
|
|
57
58
|
|
|
58
59
|
expect(root).toExist();
|
|
59
60
|
expect(root).toHaveClassName(CLASSNAME);
|
|
60
61
|
});
|
|
62
|
+
|
|
63
|
+
it('should unmount children by default when closed', () => {
|
|
64
|
+
const { children } = setup({
|
|
65
|
+
children: <SideNavigationItem label="Child 1" toggleButtonProps={{ label: 'Toggle' }} />,
|
|
66
|
+
});
|
|
67
|
+
expect(children).not.toExist();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should keep children in DOM when closed and with closeMode="hide"', () => {
|
|
71
|
+
const { children } = setup({
|
|
72
|
+
closeMode: 'hide',
|
|
73
|
+
children: <SideNavigationItem key="1" label="Child 1" toggleButtonProps={{ label: 'Toggle' }} />,
|
|
74
|
+
});
|
|
75
|
+
expect(children).toExist();
|
|
76
|
+
});
|
|
61
77
|
});
|
|
62
78
|
|
|
63
79
|
// 2. Test defaultProps value and important props custom values.
|
|
@@ -67,7 +83,8 @@ describe(`<${SideNavigationItem.displayName}>`, () => {
|
|
|
67
83
|
it('should use default props', () => {
|
|
68
84
|
const { root } = setup();
|
|
69
85
|
|
|
70
|
-
|
|
86
|
+
const propNames = without(Object.keys(DEFAULT_PROPS), 'closeMode');
|
|
87
|
+
for (const prop of propNames) {
|
|
71
88
|
const className = getBasicClass({ prefix: CLASSNAME, type: prop, value: DEFAULT_PROPS[prop] });
|
|
72
89
|
if (className) {
|
|
73
90
|
expect(root).toHaveClassName(className);
|
|
@@ -41,6 +41,11 @@ export interface SideNavigationItemProps extends GenericProps {
|
|
|
41
41
|
/** Props to pass to the toggle button (minus those already set by the SideNavigationItem props). */
|
|
42
42
|
toggleButtonProps: Pick<IconButtonProps, 'label'> &
|
|
43
43
|
Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color' | 'size'>;
|
|
44
|
+
/**
|
|
45
|
+
* Choose how the children are hidden when closed
|
|
46
|
+
* ('hide' keeps the children in DOM but hide them, 'unmount' remove the children from the DOM).
|
|
47
|
+
*/
|
|
48
|
+
closeMode?: 'hide' | 'unmount';
|
|
44
49
|
/** On action button click callback. */
|
|
45
50
|
onActionClick?(evt: React.MouseEvent): void;
|
|
46
51
|
/** On click callback. */
|
|
@@ -62,6 +67,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
62
67
|
*/
|
|
63
68
|
const DEFAULT_PROPS: Partial<SideNavigationItemProps> = {
|
|
64
69
|
emphasis: Emphasis.high,
|
|
70
|
+
closeMode: 'unmount',
|
|
65
71
|
};
|
|
66
72
|
|
|
67
73
|
/**
|
|
@@ -85,12 +91,14 @@ export const SideNavigationItem: Comp<SideNavigationItemProps, HTMLLIElement> =
|
|
|
85
91
|
onActionClick,
|
|
86
92
|
onClick,
|
|
87
93
|
toggleButtonProps,
|
|
94
|
+
closeMode = 'unmount',
|
|
88
95
|
...forwardedProps
|
|
89
96
|
} = props;
|
|
90
97
|
|
|
91
98
|
const content = children && Children.toArray(children).filter(isComponent(SideNavigationItem));
|
|
92
99
|
const hasContent = !isEmpty(content);
|
|
93
100
|
const shouldSplitActions = Boolean(onActionClick);
|
|
101
|
+
const showChildren = hasContent && isOpen;
|
|
94
102
|
|
|
95
103
|
return (
|
|
96
104
|
<li
|
|
@@ -100,7 +108,7 @@ export const SideNavigationItem: Comp<SideNavigationItemProps, HTMLLIElement> =
|
|
|
100
108
|
className,
|
|
101
109
|
handleBasicClasses({
|
|
102
110
|
emphasis,
|
|
103
|
-
isOpen,
|
|
111
|
+
isOpen: showChildren,
|
|
104
112
|
isSelected,
|
|
105
113
|
prefix: CLASSNAME,
|
|
106
114
|
}),
|
|
@@ -151,7 +159,7 @@ export const SideNavigationItem: Comp<SideNavigationItemProps, HTMLLIElement> =
|
|
|
151
159
|
)
|
|
152
160
|
)}
|
|
153
161
|
|
|
154
|
-
{
|
|
162
|
+
{(closeMode === 'hide' || showChildren) && <ul className={`${CLASSNAME}__children`}>{content}</ul>}
|
|
155
163
|
</li>
|
|
156
164
|
);
|
|
157
165
|
});
|
|
@@ -13,7 +13,7 @@ exports[`<SideNavigationItem> Snapshots and structure should render correctly 1`
|
|
|
13
13
|
</li>
|
|
14
14
|
`;
|
|
15
15
|
|
|
16
|
-
exports[`<SideNavigationItem> Snapshots and structure should render correctly with
|
|
16
|
+
exports[`<SideNavigationItem> Snapshots and structure should render correctly with split actions 1`] = `
|
|
17
17
|
<li
|
|
18
18
|
className="lumx-side-navigation-item lumx-side-navigation-item--emphasis-high"
|
|
19
19
|
>
|