@lumx/react 2.2.18-alpha-hooks.1 → 2.2.20-alpha-type.1
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.js +194 -0
- 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} +27 -20
- package/esm/_internal/DatePickerField.js.map +1 -0
- package/esm/_internal/{dialog.13.js → Dialog2.js} +13 -13
- 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/GenericBlock.js +90 -0
- package/esm/_internal/GenericBlock.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} +12 -12
- 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} +26 -16
- 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} +51 -15
- 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} +28 -16
- 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 +20 -20
- package/esm/_internal/autocomplete.js +22 -22
- package/esm/_internal/avatar.js +6 -6
- package/esm/_internal/badge.js +3 -3
- package/esm/_internal/button.js +16 -16
- package/esm/_internal/checkbox.js +7 -7
- package/esm/_internal/chip.js +4 -4
- package/esm/_internal/comment-block.js +14 -14
- 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 +20 -20
- package/esm/_internal/dialog.js +13 -13
- package/esm/_internal/divider.js +3 -3
- package/esm/_internal/drag-handle.js +4 -4
- package/esm/_internal/dropdown.js +12 -12
- package/esm/_internal/expansion-panel.js +17 -18
- 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/generic-block.js +12 -0
- package/esm/_internal/generic-block.js.map +1 -0
- 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 +18 -18
- 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 +8 -8
- 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 +21 -21
- package/esm/_internal/side-navigation.js +16 -16
- package/esm/_internal/skeleton.js +3 -3
- package/esm/_internal/slider.js +6 -6
- package/esm/_internal/slideshow.js +15 -15
- 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 +17 -17
- package/esm/_internal/thumbnail.js +6 -6
- package/esm/_internal/toolbar.js +3 -3
- package/esm/_internal/tooltip.js +10 -10
- 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.js +86 -0
- 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 +91 -0
- package/{index.js.map → esm/index.js.map} +1 -1
- 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/autocomplete/Autocomplete.tsx +4 -4
- 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/date-picker/DatePickerField.tsx +15 -16
- package/src/components/date-picker/types.ts +2 -2
- package/src/components/dialog/Dialog.stories.tsx +61 -14
- package/src/components/dialog/Dialog.tsx +3 -3
- package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +167 -91
- package/src/components/dropdown/Dropdown.tsx +4 -3
- package/src/components/generic-block/GenericBlock.stories.tsx +149 -0
- package/src/components/generic-block/GenericBlock.test.tsx +28 -0
- package/src/components/generic-block/GenericBlock.tsx +120 -0
- package/src/components/generic-block/__snapshots__/GenericBlock.test.tsx.snap +92 -0
- package/src/components/generic-block/index.ts +1 -0
- package/src/components/lightbox/Lightbox.tsx +1 -1
- package/src/components/link-preview/LinkPreview.test.tsx +50 -55
- package/src/components/link-preview/LinkPreview.tsx +43 -16
- package/src/components/popover/Popover.tsx +20 -4
- package/src/components/select/Select.stories.tsx +2 -0
- package/src/components/select/Select.tsx +11 -1
- package/src/components/select/SelectMultiple.stories.tsx +2 -0
- package/src/components/select/SelectMultiple.tsx +11 -1
- package/src/components/select/constants.ts +2 -0
- 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/table/__snapshots__/Table.test.tsx.snap +5 -0
- package/src/components/text-field/TextField.tsx +4 -4
- package/src/components/thumbnail/Thumbnail.tsx +2 -2
- 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/useCallbackOnEscape.ts +21 -13
- package/src/hooks/useFocusTrap.ts +67 -76
- package/src/index.ts +1 -0
- package/src/stories/generated/Dialog/Demos.stories.tsx +1 -0
- package/src/stories/generated/GenericBlock/Demos.stories.tsx +6 -0
- package/src/utils/focus/getFirstAndLastFocusable.test.ts +134 -0
- package/src/utils/focus/getFirstAndLastFocusable.ts +27 -0
- package/src/utils/makeListenerTowerContext.ts +32 -0
- package/src/utils/type.ts +3 -0
- package/{index.d.ts → types.d.ts} +82 -22
- 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 +0 -116
- 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 +0 -93
- 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
- package/src/components/link-preview/__snapshots__/LinkPreview.test.tsx.snap +0 -51
|
@@ -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,KAAZ,MAAsBC,MAAM,CAACE,OAA7B;;AACJ,SAAK,mBAAL;AAA0B;AACtB,YAAIH,KAAK,CAACL,cAAN,KAAyBM,MAAM,CAACE,OAApC,EAA6C;AACzC,iBAAOH,KAAP;AACH,SAHqB;;;AAKtB,kCAAYA,KAAZ;AAAmBL,UAAAA,cAAc,EAAEM,MAAM,CAACE;AAA1C;AACH;;AACD,SAAK,UAAL;AAAiB;AAAA,8BACQF,MAAM,CAACE,OADf;AAAA,YACLD,IADK,mBACLA,IADK;AAAA,YACCE,EADD,mBACCA,EADD;;AAGb,kCAAYJ,KAAZ;AAAmBJ,UAAAA,GAAG,qBAAOI,KAAK,CAACJ,GAAb,sBAAmBM,IAAnB,+BAA8BF,KAAK,CAACJ,GAAN,CAAUM,IAAV,CAA9B,IAA+CE,EAA/C;AAAtB;A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E,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,91 @@
|
|
|
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/ClickAwayProvider.js';
|
|
41
|
+
import 'lodash/pull';
|
|
42
|
+
import './_internal/useFocusTrap.js';
|
|
43
|
+
import 'react-dom';
|
|
44
|
+
export { D as Dialog } from './_internal/Dialog2.js';
|
|
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 GenericBlock } from './_internal/GenericBlock.js';
|
|
56
|
+
export { G as Grid, a as GridItem } from './_internal/GridItem.js';
|
|
57
|
+
import 'lodash/isObject';
|
|
58
|
+
export { a as ImageBlock, I as ImageBlockCaptionPosition } from './_internal/ImageBlock.js';
|
|
59
|
+
export { I as InputHelper } from './_internal/InputHelper.js';
|
|
60
|
+
export { I as InputLabel } from './_internal/InputLabel.js';
|
|
61
|
+
export { L as Lightbox } from './_internal/Lightbox2.js';
|
|
62
|
+
export { L as Link } from './_internal/Link2.js';
|
|
63
|
+
export { L as LinkPreview } from './_internal/LinkPreview.js';
|
|
64
|
+
export { L as ListDivider, a as ListSubheader } from './_internal/ListSubheader.js';
|
|
65
|
+
export { M as Message } from './_internal/Message2.js';
|
|
66
|
+
import 'lodash/take';
|
|
67
|
+
export { M as Mosaic } from './_internal/Mosaic2.js';
|
|
68
|
+
export { N as Notification } from './_internal/Notification2.js';
|
|
69
|
+
export { P as PostBlock } from './_internal/PostBlock.js';
|
|
70
|
+
export { a as Progress, P as ProgressVariant } from './_internal/Progress2.js';
|
|
71
|
+
import './_internal/useRovingTabIndex.js';
|
|
72
|
+
export { a as ProgressTracker, P as ProgressTrackerProvider, b as ProgressTrackerStep, c as ProgressTrackerStepPanel } from './_internal/ProgressTrackerStepPanel.js';
|
|
73
|
+
export { R as RadioButton, a as RadioGroup } from './_internal/RadioGroup.js';
|
|
74
|
+
export { a as Select, c as SelectMultiple, b as SelectMultipleField, S as SelectVariant } from './_internal/SelectMultiple.js';
|
|
75
|
+
export { S as SideNavigation, a as SideNavigationItem } from './_internal/SideNavigationItem.js';
|
|
76
|
+
export { S as SkeletonCircle, b as SkeletonRectangle, a as SkeletonRectangleVariant, c as SkeletonTypography } from './_internal/SkeletonTypography.js';
|
|
77
|
+
export { S as Slider, c as clamp } from './_internal/Slider2.js';
|
|
78
|
+
export { c as Slides, S as Slideshow, b as SlideshowControls, a as SlideshowItem } from './_internal/Slides.js';
|
|
79
|
+
import 'lodash/uniqueId';
|
|
80
|
+
export { S as Switch } from './_internal/Switch2.js';
|
|
81
|
+
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';
|
|
82
|
+
export { c as Tab, b as TabList, a as TabListLayout, d as TabPanel, T as TabProvider } from './_internal/TabPanel.js';
|
|
83
|
+
export { T as TextField } from './_internal/TextField.js';
|
|
84
|
+
export { T as Thumbnail, u as useFocusPointStyle } from './_internal/Thumbnail2.js';
|
|
85
|
+
export { T as ThumbnailAspectRatio, a as ThumbnailVariant } from './_internal/types.js';
|
|
86
|
+
export { T as Toolbar } from './_internal/Toolbar2.js';
|
|
87
|
+
export { T as Tooltip } from './_internal/Tooltip2.js';
|
|
88
|
+
export { a as Uploader, U as UploaderVariant } from './_internal/Uploader2.js';
|
|
89
|
+
import 'lodash/set';
|
|
90
|
+
export { U as UserBlock } from './_internal/UserBlock.js';
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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-type.1",
|
|
11
|
+
"@lumx/icons": "^2.2.20-alpha-type.1",
|
|
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-
|
|
114
|
+
"generate:types": "dts-bundle-generator --no-check --external-imports=react -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-type.1",
|
|
124
|
+
"gitHead": "ad74227be3187c488044780000f5f66007af2132"
|
|
128
125
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { forwardRef, ReactNode,
|
|
1
|
+
import React, { forwardRef, ReactNode, SyntheticEvent, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { Dropdown, IconButtonProps, Offset, Placement, TextField, Theme } from '@lumx/react';
|
|
5
|
+
import { Dropdown, IconButtonProps, Offset, Placement, TextField, TextFieldProps, Theme } from '@lumx/react';
|
|
6
6
|
|
|
7
7
|
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
8
8
|
|
|
@@ -29,7 +29,7 @@ export interface AutocompleteProps extends GenericProps {
|
|
|
29
29
|
* Reference to the <input> or <textarea> element.
|
|
30
30
|
* @see {@link TextFieldProps#inputRef}
|
|
31
31
|
*/
|
|
32
|
-
inputRef?:
|
|
32
|
+
inputRef?: TextFieldProps['inputRef'];
|
|
33
33
|
/**
|
|
34
34
|
* The offset that will be applied to the Dropdown position.
|
|
35
35
|
* @see {@link DropdownProps#offset}
|
|
@@ -244,7 +244,7 @@ export const Autocomplete: Comp<AutocompleteProps, HTMLDivElement> = forwardRef(
|
|
|
244
244
|
hasError={hasError}
|
|
245
245
|
helper={helper}
|
|
246
246
|
icon={icon}
|
|
247
|
-
inputRef={mergeRefs(inputAnchorRef
|
|
247
|
+
inputRef={mergeRefs(inputAnchorRef as React.RefObject<HTMLInputElement>, inputRef)}
|
|
248
248
|
clearButtonProps={clearButtonProps}
|
|
249
249
|
isDisabled={isDisabled}
|
|
250
250
|
isRequired={isRequired}
|
|
@@ -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
|
>
|
|
@@ -62,7 +62,7 @@ export const DatePickerField: Comp<DatePickerFieldProps, HTMLDivElement> = forwa
|
|
|
62
62
|
value,
|
|
63
63
|
...forwardedProps
|
|
64
64
|
} = props;
|
|
65
|
-
const
|
|
65
|
+
const [wrapperElement, setWrapperElement] = useState<HTMLDivElement | null>(null);
|
|
66
66
|
const anchorRef = useRef(null);
|
|
67
67
|
|
|
68
68
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -83,8 +83,8 @@ export const DatePickerField: Comp<DatePickerFieldProps, HTMLDivElement> = forwa
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
// Handle focus trap.
|
|
86
|
-
const
|
|
87
|
-
useFocusTrap(
|
|
86
|
+
const [todayOrSelectedDate, setTodayOrSelectedDate] = useState<HTMLButtonElement | null>(null);
|
|
87
|
+
useFocusTrap(isOpen && wrapperElement, todayOrSelectedDate);
|
|
88
88
|
|
|
89
89
|
const onTextFieldChange = (textFieldValue: string, textFieldName?: string, event?: SyntheticEvent) => {
|
|
90
90
|
if (!textFieldValue) {
|
|
@@ -121,19 +121,18 @@ export const DatePickerField: Comp<DatePickerFieldProps, HTMLDivElement> = forwa
|
|
|
121
121
|
closeOnClickAway
|
|
122
122
|
closeOnEscape
|
|
123
123
|
>
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
</div>
|
|
124
|
+
<DatePicker
|
|
125
|
+
ref={setWrapperElement}
|
|
126
|
+
locale={locale}
|
|
127
|
+
maxDate={maxDate}
|
|
128
|
+
minDate={minDate}
|
|
129
|
+
value={value}
|
|
130
|
+
onChange={onDatePickerChange}
|
|
131
|
+
todayOrSelectedDateRef={setTodayOrSelectedDate}
|
|
132
|
+
defaultMonth={defaultMonth}
|
|
133
|
+
nextButtonProps={nextButtonProps}
|
|
134
|
+
previousButtonProps={previousButtonProps}
|
|
135
|
+
/>
|
|
137
136
|
</Popover>
|
|
138
137
|
) : null}
|
|
139
138
|
</>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IconButtonProps } from '@lumx/react';
|
|
2
2
|
import { GenericProps } from '@lumx/react/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { Ref } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Defines the props of the component.
|
|
@@ -20,7 +20,7 @@ export interface DatePickerProps extends GenericProps {
|
|
|
20
20
|
previousButtonProps: Pick<IconButtonProps, 'label'> &
|
|
21
21
|
Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;
|
|
22
22
|
/** Reference to the <button> element corresponding to the current date or the selected date. */
|
|
23
|
-
todayOrSelectedDateRef?:
|
|
23
|
+
todayOrSelectedDateRef?: Ref<HTMLButtonElement>;
|
|
24
24
|
/** Currently selected date. */
|
|
25
25
|
value: Date | undefined;
|
|
26
26
|
/** On change callback. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import noop from 'lodash/noop';
|
|
1
2
|
import { mdiClose } from '@lumx/icons';
|
|
2
3
|
import {
|
|
3
4
|
AlertDialog,
|
|
@@ -17,7 +18,8 @@ import {
|
|
|
17
18
|
} from '@lumx/react';
|
|
18
19
|
import { DIALOG_TRANSITION_DURATION } from '@lumx/core/js/constants';
|
|
19
20
|
import { select } from '@storybook/addon-knobs';
|
|
20
|
-
import React, { RefObject, useRef, useState } from 'react';
|
|
21
|
+
import React, { RefObject, useCallback, useRef, useState } from 'react';
|
|
22
|
+
import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
|
|
21
23
|
import { Dialog, DialogSizes } from './Dialog';
|
|
22
24
|
import { loremIpsum } from '../../stories/knobs/lorem';
|
|
23
25
|
import { chromaticForceScreenSize } from '../../stories/chromaticForceScreenSize';
|
|
@@ -43,8 +45,8 @@ const footer = <footer className="lumx-spacing-padding">Dialog footer</footer>;
|
|
|
43
45
|
function useOpenButton(theme: Theme, defaultState = true) {
|
|
44
46
|
const buttonRef = useRef() as RefObject<HTMLButtonElement>;
|
|
45
47
|
const [isOpen, setOpen] = useState(defaultState);
|
|
46
|
-
const openDialog = () => setOpen(true);
|
|
47
|
-
const closeDialog = () => setOpen(false);
|
|
48
|
+
const openDialog = useCallback(() => setOpen(true), []);
|
|
49
|
+
const closeDialog = useCallback(() => setOpen(false), []);
|
|
48
50
|
|
|
49
51
|
return {
|
|
50
52
|
button: (
|
|
@@ -283,7 +285,8 @@ export const ScrollableDialogWithHeaderAndFooter = ({ theme }: any) => {
|
|
|
283
285
|
);
|
|
284
286
|
};
|
|
285
287
|
|
|
286
|
-
|
|
288
|
+
/** Test dialog focus trap (focus is contained inside the dialog) with all kinds of focusable and non-focusable items */
|
|
289
|
+
export const DialogFocusTrap = ({ theme }: any) => {
|
|
287
290
|
const { button, buttonRef, closeDialog, isOpen } = useOpenButton(theme);
|
|
288
291
|
const [textValue, setTextValue] = useState('value');
|
|
289
292
|
const [checkboxValue, setCheckboxValue] = useState(false);
|
|
@@ -300,6 +303,9 @@ export const DialogWithFocusableElements = ({ theme }: any) => {
|
|
|
300
303
|
};
|
|
301
304
|
const [date, setDate] = useState<Date | undefined>(new Date('2020-05-18'));
|
|
302
305
|
|
|
306
|
+
const datePickerDialogButtonRef = useRef<HTMLButtonElement>(null);
|
|
307
|
+
const [isDatePickerDialogOpen, closeDatePickerDialog, openDatePickerDialog] = useBooleanState(false);
|
|
308
|
+
|
|
303
309
|
return (
|
|
304
310
|
<>
|
|
305
311
|
{button}
|
|
@@ -313,6 +319,10 @@ export const DialogWithFocusableElements = ({ theme }: any) => {
|
|
|
313
319
|
/>
|
|
314
320
|
</header>
|
|
315
321
|
<div className="lumx-spacing-padding-horizontal-huge lumx-spacing-padding-bottom-huge">
|
|
322
|
+
{/* Testing hidden input do not count in th focus trap*/}
|
|
323
|
+
<input hidden type="file" />
|
|
324
|
+
<input type="hidden" />
|
|
325
|
+
|
|
316
326
|
<div className="lumx-spacing-margin-bottom-huge">
|
|
317
327
|
The text field should capture the focus on open and a focus trap should be in place.
|
|
318
328
|
</div>
|
|
@@ -334,16 +344,51 @@ export const DialogWithFocusableElements = ({ theme }: any) => {
|
|
|
334
344
|
/>
|
|
335
345
|
|
|
336
346
|
<FlexBox orientation="horizontal" hAlign="bottom" gap="regular">
|
|
337
|
-
<
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
+
<Button ref={datePickerDialogButtonRef} onClick={openDatePickerDialog}>
|
|
348
|
+
Open date picker
|
|
349
|
+
</Button>
|
|
350
|
+
<Dialog
|
|
351
|
+
isOpen={isDatePickerDialogOpen}
|
|
352
|
+
parentElement={datePickerDialogButtonRef}
|
|
353
|
+
onClose={closeDatePickerDialog}
|
|
354
|
+
>
|
|
355
|
+
<header>
|
|
356
|
+
<Toolbar
|
|
357
|
+
label={<h1 className="lumx-typography-title">Date picker</h1>}
|
|
358
|
+
after={
|
|
359
|
+
<IconButton
|
|
360
|
+
label="Close"
|
|
361
|
+
icon={mdiClose}
|
|
362
|
+
onClick={closeDatePickerDialog}
|
|
363
|
+
emphasis={Emphasis.low}
|
|
364
|
+
/>
|
|
365
|
+
}
|
|
366
|
+
/>
|
|
367
|
+
</header>
|
|
368
|
+
<div className="lumx-spacing-padding">
|
|
369
|
+
<DatePickerField
|
|
370
|
+
locale="fr"
|
|
371
|
+
label="Start date"
|
|
372
|
+
placeholder="Pick a date"
|
|
373
|
+
theme={theme}
|
|
374
|
+
onChange={setDate}
|
|
375
|
+
value={date}
|
|
376
|
+
nextButtonProps={{ label: 'Next month' }}
|
|
377
|
+
previousButtonProps={{ label: 'Previous month' }}
|
|
378
|
+
/>
|
|
379
|
+
<DatePickerField
|
|
380
|
+
locale="fr"
|
|
381
|
+
label="Start date"
|
|
382
|
+
placeholder="Pick a date"
|
|
383
|
+
theme={theme}
|
|
384
|
+
onChange={noop}
|
|
385
|
+
value={undefined}
|
|
386
|
+
nextButtonProps={{ label: 'Next month' }}
|
|
387
|
+
previousButtonProps={{ label: 'Previous month' }}
|
|
388
|
+
defaultMonth={new Date('2020-05-18')}
|
|
389
|
+
/>
|
|
390
|
+
</div>
|
|
391
|
+
</Dialog>
|
|
347
392
|
|
|
348
393
|
<Select
|
|
349
394
|
className="lumx-spacing-margin-left-huge"
|
|
@@ -372,6 +417,8 @@ export const DialogWithFocusableElements = ({ theme }: any) => {
|
|
|
372
417
|
|
|
373
418
|
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}
|
|
374
419
|
<div tabIndex={0}>Focus div</div>
|
|
420
|
+
|
|
421
|
+
<Button isDisabled={false}>Button explicitly not disabled (should focus)</Button>
|
|
375
422
|
</div>
|
|
376
423
|
</Dialog>
|
|
377
424
|
</>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Children, forwardRef, ReactElement, ReactNode, RefObject, useMemo, useRef, useState } from 'react';
|
|
1
|
+
import React, { Children, forwardRef, ReactElement, ReactNode, Ref, RefObject, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -42,7 +42,7 @@ export interface DialogProps extends GenericProps {
|
|
|
42
42
|
/** Reference to the parent element that triggered modal opening (will get back focus on close). */
|
|
43
43
|
parentElement?: RefObject<HTMLElement>;
|
|
44
44
|
/** Reference to the dialog content element. */
|
|
45
|
-
contentRef?:
|
|
45
|
+
contentRef?: Ref<HTMLDivElement>;
|
|
46
46
|
/** Reference to the of the element that should get the focus when the dialogs opens. By default, the first child will take focus. */
|
|
47
47
|
focusElement?: RefObject<HTMLElement>;
|
|
48
48
|
/** Whether to keep the dialog open on clickaway or escape press. */
|
|
@@ -142,7 +142,7 @@ export const Dialog: Comp<DialogProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
142
142
|
const localContentRef = useRef<HTMLDivElement>(null);
|
|
143
143
|
// Handle focus trap.
|
|
144
144
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
145
|
-
useFocusTrap(wrapperRef.current, focusElement?.current);
|
|
145
|
+
useFocusTrap(isOpen && wrapperRef.current, focusElement?.current);
|
|
146
146
|
|
|
147
147
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
148
148
|
useDisableBodyScroll(isOpen && localContentRef.current);
|