@navikt/ds-react 8.7.0 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/alert/base-alert/root/BaseAlertRoot.js +1 -2
- package/cjs/alert/base-alert/root/BaseAlertRoot.js.map +1 -1
- package/cjs/alert/info-card/index.d.ts +2 -2
- package/cjs/alert/info-card/index.js +2 -1
- package/cjs/alert/info-card/index.js.map +1 -1
- package/cjs/alert/info-card/message/InfoCardMessage.d.ts +23 -0
- package/cjs/alert/info-card/message/InfoCardMessage.js +73 -0
- package/cjs/alert/info-card/message/InfoCardMessage.js.map +1 -0
- package/cjs/alert/info-card/root/InfoCardRoot.d.ts +15 -2
- package/cjs/alert/info-card/root/InfoCardRoot.js +4 -1
- package/cjs/alert/info-card/root/InfoCardRoot.js.map +1 -1
- package/cjs/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.d.ts +21 -0
- package/cjs/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.js +24 -0
- package/cjs/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.js.map +1 -0
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js +7 -57
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.d.ts +4 -1
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js +7 -3
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.d.ts +12 -2
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js +14 -64
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js.map +1 -1
- package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.d.ts +22 -0
- package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js +35 -0
- package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js.map +1 -0
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.d.ts +27 -0
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.js +86 -0
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +1 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.d.ts +5 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js +6 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +1 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.d.ts +24 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.js +108 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.js.map +1 -0
- package/cjs/data/table/empty-state/DataTableEmptyState.d.ts +5 -0
- package/cjs/data/table/empty-state/DataTableEmptyState.js +57 -0
- package/cjs/data/table/empty-state/DataTableEmptyState.js.map +1 -0
- package/cjs/data/table/helpers/table-focus.js +7 -1
- package/cjs/data/table/helpers/table-focus.js.map +1 -1
- package/cjs/data/table/helpers/table-keyboard.d.ts +0 -1
- package/cjs/data/table/helpers/table-keyboard.js +2 -4
- package/cjs/data/table/helpers/table-keyboard.js.map +1 -1
- package/cjs/data/table/loading-state/DataTableLoadingState.d.ts +5 -0
- package/cjs/data/table/loading-state/DataTableLoadingState.js +57 -0
- package/cjs/data/table/loading-state/DataTableLoadingState.js.map +1 -0
- package/cjs/data/table/root/DataTable.types.d.ts +13 -0
- package/cjs/data/table/root/DataTable.types.js +3 -0
- package/cjs/data/table/root/DataTable.types.js.map +1 -0
- package/cjs/data/table/root/DataTableAuto.d.ts +60 -0
- package/cjs/data/table/root/DataTableAuto.js +99 -0
- package/cjs/data/table/root/DataTableAuto.js.map +1 -0
- package/cjs/data/table/root/DataTableRoot.context.d.ts +3 -2
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +30 -3
- package/cjs/data/table/root/DataTableRoot.js +8 -2
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/root/useTableKeyboardNav.js +1 -0
- package/cjs/data/table/root/useTableKeyboardNav.js.map +1 -1
- package/cjs/data/table/root/useTableSelection.d.ts +55 -0
- package/cjs/data/table/root/useTableSelection.js +79 -0
- package/cjs/data/table/root/useTableSelection.js.map +1 -0
- package/cjs/data/table/td/DataTableTd.d.ts +10 -0
- package/cjs/data/table/td/DataTableTd.js +4 -2
- package/cjs/data/table/td/DataTableTd.js.map +1 -1
- package/cjs/data/table/th/DataTableTh.d.ts +10 -4
- package/cjs/data/table/th/DataTableTh.js +24 -22
- package/cjs/data/table/th/DataTableTh.js.map +1 -1
- package/cjs/data/table/th/useTableColumnResize.d.ts +64 -0
- package/cjs/data/table/th/useTableColumnResize.js +144 -0
- package/cjs/data/table/th/useTableColumnResize.js.map +1 -0
- package/cjs/data/table/thead/DataTableThead.context.d.ts +4 -0
- package/cjs/data/table/thead/DataTableThead.context.js +45 -0
- package/cjs/data/table/thead/DataTableThead.context.js.map +1 -0
- package/cjs/data/table/thead/DataTableThead.js +3 -1
- package/cjs/data/table/thead/DataTableThead.js.map +1 -1
- package/cjs/data/table/tr/DataTableTr.js +4 -3
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/data/token-filter/AutoSuggest.js +4 -6
- package/cjs/data/token-filter/AutoSuggest.js.map +1 -1
- package/cjs/date/Date.Input.js +1 -1
- package/cjs/date/Date.Input.js.map +1 -1
- package/cjs/date/datepicker/hooks/useDatepicker.d.ts +12 -1
- package/cjs/date/datepicker/hooks/useDatepicker.js.map +1 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.d.ts +11 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.js.map +1 -1
- package/cjs/form/checkbox/CheckboxGroup.js +1 -1
- package/cjs/form/checkbox/CheckboxGroup.js.map +1 -1
- package/cjs/form/fieldset/Fieldset.d.ts +25 -5
- package/cjs/form/fieldset/Fieldset.js +19 -2
- package/cjs/form/fieldset/Fieldset.js.map +1 -1
- package/cjs/form/radio/RadioGroup.js +1 -1
- package/cjs/form/radio/RadioGroup.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/read-more/ReadMore.d.ts +10 -0
- package/cjs/read-more/ReadMore.js +4 -6
- package/cjs/read-more/ReadMore.js.map +1 -1
- package/cjs/types/index.d.ts +1 -1
- package/cjs/types/index.js +0 -15
- package/cjs/types/index.js.map +1 -1
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.js +1 -1
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.js.map +1 -1
- package/cjs/utils/components/Listbox/option/ListboxOption.d.ts +24 -0
- package/cjs/utils/components/Listbox/{item/ListboxItem.js → option/ListboxOption.js} +8 -8
- package/cjs/utils/components/Listbox/option/ListboxOption.js.map +1 -0
- package/cjs/utils/components/Listbox/options/ListboxOptions.d.ts +8 -0
- package/cjs/utils/components/Listbox/{list/ListboxList.js → options/ListboxOptions.js} +8 -8
- package/cjs/utils/components/Listbox/options/ListboxOptions.js.map +1 -0
- package/cjs/utils/components/Listbox/root/ListboxRoot.d.ts +6 -6
- package/cjs/utils/components/Listbox/root/ListboxRoot.js +28 -28
- package/cjs/utils/components/Listbox/root/ListboxRoot.js.map +1 -1
- package/cjs/utils/components/Listbox/root/domHelpers.d.ts +3 -3
- package/cjs/utils/components/Listbox/root/domHelpers.js +8 -8
- package/cjs/utils/components/Listbox/root/domHelpers.js.map +1 -1
- package/cjs/utils/components/floating/Floating.d.ts +1 -1
- package/cjs/utils/components/floating/Floating.js +1 -1
- package/cjs/utils/components/floating/Floating.js.map +1 -1
- package/cjs/utils/components/focus-boundary/FocusBoundary.d.ts +0 -1
- package/cjs/utils/components/focus-boundary/FocusBoundary.js +1 -1
- package/cjs/utils/components/focus-boundary/FocusBoundary.js.map +1 -1
- package/cjs/utils/components/link-anchor/LinkAnchor.js +10 -0
- package/cjs/utils/components/link-anchor/LinkAnchor.js.map +1 -1
- package/cjs/utils/helpers/className.js +1 -1
- package/cjs/utils/helpers/className.js.map +1 -1
- package/cjs/utils/helpers/focus.d.ts +3 -1
- package/cjs/utils/helpers/focus.js +2 -2
- package/cjs/utils/helpers/focus.js.map +1 -1
- package/cjs/utils/helpers/index.d.ts +9 -9
- package/cjs/utils/helpers/index.js +22 -23
- package/cjs/utils/helpers/index.js.map +1 -1
- package/cjs/utils/hooks/index.d.ts +13 -13
- package/cjs/utils/hooks/index.js +31 -28
- package/cjs/utils/hooks/index.js.map +1 -1
- package/cjs/utils/hooks/useScrollLock.js +41 -11
- package/cjs/utils/hooks/useScrollLock.js.map +1 -1
- package/esm/alert/base-alert/root/BaseAlertRoot.js +1 -2
- package/esm/alert/base-alert/root/BaseAlertRoot.js.map +1 -1
- package/esm/alert/info-card/index.d.ts +2 -2
- package/esm/alert/info-card/index.js +1 -1
- package/esm/alert/info-card/index.js.map +1 -1
- package/esm/alert/info-card/message/InfoCardMessage.d.ts +23 -0
- package/esm/alert/info-card/message/InfoCardMessage.js +37 -0
- package/esm/alert/info-card/message/InfoCardMessage.js.map +1 -0
- package/esm/alert/info-card/root/InfoCardRoot.d.ts +15 -2
- package/esm/alert/info-card/root/InfoCardRoot.js +3 -1
- package/esm/alert/info-card/root/InfoCardRoot.js.map +1 -1
- package/esm/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.d.ts +21 -0
- package/esm/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.js +18 -0
- package/esm/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.js.map +1 -0
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js +4 -24
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js.map +1 -1
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.d.ts +4 -1
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js +5 -2
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js.map +1 -1
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.d.ts +12 -2
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js +15 -65
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js.map +1 -1
- package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.d.ts +22 -0
- package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js +29 -0
- package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js.map +1 -0
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.d.ts +27 -0
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.js +50 -0
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +1 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.d.ts +5 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js +3 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +1 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.d.ts +24 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.js +68 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.js.map +1 -0
- package/esm/data/table/empty-state/DataTableEmptyState.d.ts +5 -0
- package/esm/data/table/empty-state/DataTableEmptyState.js +21 -0
- package/esm/data/table/empty-state/DataTableEmptyState.js.map +1 -0
- package/esm/data/table/helpers/table-focus.js +7 -1
- package/esm/data/table/helpers/table-focus.js.map +1 -1
- package/esm/data/table/helpers/table-keyboard.d.ts +0 -1
- package/esm/data/table/helpers/table-keyboard.js +2 -4
- package/esm/data/table/helpers/table-keyboard.js.map +1 -1
- package/esm/data/table/loading-state/DataTableLoadingState.d.ts +5 -0
- package/esm/data/table/loading-state/DataTableLoadingState.js +21 -0
- package/esm/data/table/loading-state/DataTableLoadingState.js.map +1 -0
- package/esm/data/table/root/DataTable.types.d.ts +13 -0
- package/esm/data/table/root/DataTable.types.js +2 -0
- package/esm/data/table/root/DataTable.types.js.map +1 -0
- package/esm/data/table/root/DataTableAuto.d.ts +60 -0
- package/esm/data/table/root/DataTableAuto.js +63 -0
- package/esm/data/table/root/DataTableAuto.js.map +1 -0
- package/esm/data/table/root/DataTableRoot.context.d.ts +3 -2
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.d.ts +30 -3
- package/esm/data/table/root/DataTableRoot.js +6 -2
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/root/useTableKeyboardNav.js +1 -0
- package/esm/data/table/root/useTableKeyboardNav.js.map +1 -1
- package/esm/data/table/root/useTableSelection.d.ts +55 -0
- package/esm/data/table/root/useTableSelection.js +77 -0
- package/esm/data/table/root/useTableSelection.js.map +1 -0
- package/esm/data/table/td/DataTableTd.d.ts +10 -0
- package/esm/data/table/td/DataTableTd.js +4 -2
- package/esm/data/table/td/DataTableTd.js.map +1 -1
- package/esm/data/table/th/DataTableTh.d.ts +10 -4
- package/esm/data/table/th/DataTableTh.js +25 -23
- package/esm/data/table/th/DataTableTh.js.map +1 -1
- package/esm/data/table/th/useTableColumnResize.d.ts +64 -0
- package/esm/data/table/th/useTableColumnResize.js +142 -0
- package/esm/data/table/th/useTableColumnResize.js.map +1 -0
- package/esm/data/table/thead/DataTableThead.context.d.ts +4 -0
- package/esm/data/table/thead/DataTableThead.context.js +8 -0
- package/esm/data/table/thead/DataTableThead.context.js.map +1 -0
- package/esm/data/table/thead/DataTableThead.js +3 -1
- package/esm/data/table/thead/DataTableThead.js.map +1 -1
- package/esm/data/table/tr/DataTableTr.js +4 -3
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/data/token-filter/AutoSuggest.js +4 -6
- package/esm/data/token-filter/AutoSuggest.js.map +1 -1
- package/esm/date/Date.Input.js +1 -1
- package/esm/date/Date.Input.js.map +1 -1
- package/esm/date/datepicker/hooks/useDatepicker.d.ts +12 -1
- package/esm/date/datepicker/hooks/useDatepicker.js.map +1 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.d.ts +11 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.js +1 -1
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/fieldset/Fieldset.d.ts +25 -5
- package/esm/form/fieldset/Fieldset.js +19 -2
- package/esm/form/fieldset/Fieldset.js.map +1 -1
- package/esm/form/radio/RadioGroup.js +1 -1
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js.map +1 -1
- package/esm/read-more/ReadMore.d.ts +10 -0
- package/esm/read-more/ReadMore.js +4 -6
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/types/index.d.ts +1 -1
- package/esm/types/index.js +1 -1
- package/esm/types/index.js.map +1 -1
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.js +1 -1
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.js.map +1 -1
- package/esm/utils/components/Listbox/option/ListboxOption.d.ts +24 -0
- package/esm/utils/components/Listbox/{item/ListboxItem.js → option/ListboxOption.js} +7 -7
- package/esm/utils/components/Listbox/option/ListboxOption.js.map +1 -0
- package/esm/utils/components/Listbox/options/ListboxOptions.d.ts +8 -0
- package/esm/utils/components/Listbox/{list/ListboxList.js → options/ListboxOptions.js} +8 -8
- package/esm/utils/components/Listbox/options/ListboxOptions.js.map +1 -0
- package/esm/utils/components/Listbox/root/ListboxRoot.d.ts +6 -6
- package/esm/utils/components/Listbox/root/ListboxRoot.js +29 -29
- package/esm/utils/components/Listbox/root/ListboxRoot.js.map +1 -1
- package/esm/utils/components/Listbox/root/domHelpers.d.ts +3 -3
- package/esm/utils/components/Listbox/root/domHelpers.js +7 -7
- package/esm/utils/components/Listbox/root/domHelpers.js.map +1 -1
- package/esm/utils/components/floating/Floating.d.ts +1 -1
- package/esm/utils/components/floating/Floating.js +1 -1
- package/esm/utils/components/floating/Floating.js.map +1 -1
- package/esm/utils/components/focus-boundary/FocusBoundary.d.ts +0 -1
- package/esm/utils/components/focus-boundary/FocusBoundary.js +1 -1
- package/esm/utils/components/focus-boundary/FocusBoundary.js.map +1 -1
- package/esm/utils/components/link-anchor/LinkAnchor.js +10 -0
- package/esm/utils/components/link-anchor/LinkAnchor.js.map +1 -1
- package/esm/utils/helpers/className.js +1 -1
- package/esm/utils/helpers/className.js.map +1 -1
- package/esm/utils/helpers/focus.d.ts +3 -1
- package/esm/utils/helpers/focus.js +2 -2
- package/esm/utils/helpers/focus.js.map +1 -1
- package/esm/utils/helpers/index.d.ts +9 -9
- package/esm/utils/helpers/index.js +9 -9
- package/esm/utils/helpers/index.js.map +1 -1
- package/esm/utils/hooks/index.d.ts +13 -13
- package/esm/utils/hooks/index.js +13 -13
- package/esm/utils/hooks/index.js.map +1 -1
- package/esm/utils/hooks/useScrollLock.js +41 -11
- package/esm/utils/hooks/useScrollLock.js.map +1 -1
- package/package.json +5 -5
- package/src/alert/base-alert/root/BaseAlertRoot.tsx +1 -1
- package/src/alert/info-card/index.ts +2 -0
- package/src/alert/info-card/message/InfoCardMessage.tsx +48 -0
- package/src/alert/info-card/root/InfoCardRoot.tsx +20 -1
- package/src/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.tsx +63 -0
- package/src/data/drag-and-drop/item/DataDragAndDropItem.tsx +6 -53
- package/src/data/drag-and-drop/root/DataDragAndDrop.context.tsx +9 -4
- package/src/data/drag-and-drop/root/DataDragAndDropRoot.tsx +19 -63
- package/src/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.tsx +104 -0
- package/src/data/drag-and-drop-old/item/DataDragAndDropItem.tsx +74 -0
- package/src/data/drag-and-drop-old/root/DataDragAndDrop.context.tsx +11 -0
- package/src/data/drag-and-drop-old/root/DataDragAndDropRoot.tsx +96 -0
- package/src/data/table/empty-state/DataTableEmptyState.tsx +26 -0
- package/src/data/table/helpers/table-focus.ts +10 -1
- package/src/data/table/helpers/table-keyboard.ts +2 -6
- package/src/data/table/loading-state/DataTableLoadingState.tsx +26 -0
- package/src/data/table/root/DataTable.types.ts +16 -0
- package/src/data/table/root/DataTableAuto.tsx +182 -0
- package/src/data/table/root/DataTableRoot.context.ts +3 -2
- package/src/data/table/root/DataTableRoot.tsx +45 -2
- package/src/data/table/root/useTableKeyboardNav.ts +1 -0
- package/src/data/table/root/useTableSelection.ts +126 -0
- package/src/data/table/td/DataTableTd.tsx +14 -1
- package/src/data/table/th/DataTableTh.tsx +48 -36
- package/src/data/table/th/useTableColumnResize.ts +276 -0
- package/src/data/table/thead/DataTableThead.context.ts +10 -0
- package/src/data/table/thead/DataTableThead.tsx +8 -5
- package/src/data/table/tr/DataTableTr.tsx +8 -3
- package/src/data/token-filter/AutoSuggest.tsx +11 -12
- package/src/date/Date.Input.tsx +1 -1
- package/src/date/datepicker/hooks/useDatepicker.tsx +12 -1
- package/src/date/monthpicker/hooks/useMonthPicker.tsx +11 -1
- package/src/form/checkbox/CheckboxGroup.tsx +1 -1
- package/src/form/fieldset/Fieldset.tsx +31 -7
- package/src/form/radio/RadioGroup.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/read-more/ReadMore.tsx +15 -16
- package/src/types/index.ts +1 -1
- package/src/utils/components/Listbox/input-slot/ListboxInputSlot.tsx +1 -1
- package/src/utils/components/Listbox/{item/ListboxItem.tsx → option/ListboxOption.tsx} +14 -14
- package/src/utils/components/Listbox/{list/ListboxList.tsx → options/ListboxOptions.tsx} +10 -10
- package/src/utils/components/Listbox/root/ListboxRoot.tsx +31 -31
- package/src/utils/components/Listbox/root/domHelpers.ts +8 -7
- package/src/utils/components/floating/Floating.tsx +2 -2
- package/src/utils/components/focus-boundary/FocusBoundary.tsx +1 -2
- package/src/utils/components/link-anchor/LinkAnchor.tsx +11 -0
- package/src/utils/helpers/className.ts +1 -1
- package/src/utils/helpers/focus.ts +5 -2
- package/src/utils/helpers/index.ts +9 -9
- package/src/utils/hooks/index.ts +20 -13
- package/src/utils/hooks/useScrollLock.ts +57 -13
- package/cjs/utils/components/Listbox/item/ListboxItem.d.ts +0 -24
- package/cjs/utils/components/Listbox/item/ListboxItem.js.map +0 -1
- package/cjs/utils/components/Listbox/list/ListboxList.d.ts +0 -8
- package/cjs/utils/components/Listbox/list/ListboxList.js.map +0 -1
- package/esm/utils/components/Listbox/item/ListboxItem.d.ts +0 -24
- package/esm/utils/components/Listbox/item/ListboxItem.js.map +0 -1
- package/esm/utils/components/Listbox/list/ListboxList.d.ts +0 -8
- package/esm/utils/components/Listbox/list/ListboxList.js.map +0 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { cl } from "../../../helpers";
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface ListboxOptionProps extends Omit<
|
|
5
5
|
React.HTMLAttributes<HTMLDivElement>,
|
|
6
6
|
"role" | "tabIndex"
|
|
7
7
|
> {
|
|
8
8
|
/**
|
|
9
|
-
* Unique ID used for tracking which
|
|
9
|
+
* Unique ID used for tracking which option has virtual focus.
|
|
10
10
|
*/
|
|
11
11
|
id: string;
|
|
12
12
|
hasVirtualFocus: boolean;
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
/**
|
|
15
|
-
* Callback when
|
|
16
|
-
* To improve performance when you have many
|
|
15
|
+
* Callback when option is selected.
|
|
16
|
+
* To improve performance when you have many options,
|
|
17
17
|
* memoize the prop with e.g. useEventCallback.
|
|
18
18
|
*/
|
|
19
19
|
onClick: React.MouseEventHandler<HTMLDivElement>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function
|
|
22
|
+
function ListboxOptionComponent({
|
|
23
23
|
id,
|
|
24
24
|
hasVirtualFocus,
|
|
25
25
|
children,
|
|
26
26
|
className,
|
|
27
27
|
...rest
|
|
28
|
-
}:
|
|
29
|
-
//console.log("Rendering
|
|
28
|
+
}: ListboxOptionProps) {
|
|
29
|
+
//console.log("Rendering option", id);
|
|
30
30
|
|
|
31
31
|
// TODO: Slot?
|
|
32
32
|
|
|
@@ -34,12 +34,12 @@ function ListboxItemComponent({
|
|
|
34
34
|
<div
|
|
35
35
|
aria-selected={false}
|
|
36
36
|
{...rest}
|
|
37
|
-
className={cl("aksel-
|
|
37
|
+
className={cl("aksel-listbox__option", className)}
|
|
38
38
|
role="option"
|
|
39
39
|
tabIndex={-1}
|
|
40
40
|
data-virtual-focus={hasVirtualFocus}
|
|
41
41
|
data-id={id}
|
|
42
|
-
id={hasVirtualFocus ? "aksel-
|
|
42
|
+
id={hasVirtualFocus ? "aksel-listbox__option-active" : undefined}
|
|
43
43
|
>
|
|
44
44
|
{children}
|
|
45
45
|
</div>
|
|
@@ -47,11 +47,11 @@ function ListboxItemComponent({
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* This component is memoized. To improve performance when you have many
|
|
50
|
+
* This component is memoized. To improve performance when you have many options,
|
|
51
51
|
* make sure all object props have stable references (i.e. memoize the event handlers with e.g. useEventCallback).
|
|
52
52
|
*
|
|
53
|
-
* NB: Remember to set `aria-selected` on selected
|
|
53
|
+
* NB: Remember to set `aria-selected` on selected options!
|
|
54
54
|
*/
|
|
55
|
-
export const
|
|
56
|
-
|
|
57
|
-
) as typeof
|
|
55
|
+
export const ListboxOption = React.memo(
|
|
56
|
+
ListboxOptionComponent,
|
|
57
|
+
) as typeof ListboxOptionComponent;
|
|
@@ -3,30 +3,30 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { cl } from "../../../helpers";
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface ListboxOptionsProps extends Omit<
|
|
7
7
|
React.HTMLAttributes<HTMLDivElement>,
|
|
8
8
|
"role" | "tabIndex" | "onMouseOver"
|
|
9
9
|
> {
|
|
10
10
|
children: React.ReactNode;
|
|
11
|
-
|
|
11
|
+
setVirtuallyFocusedOptionId: (value: string) => void;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function
|
|
14
|
+
function ListboxOptions({
|
|
15
15
|
children,
|
|
16
|
-
|
|
16
|
+
setVirtuallyFocusedOptionId,
|
|
17
17
|
...rest
|
|
18
|
-
}:
|
|
18
|
+
}: ListboxOptionsProps) {
|
|
19
19
|
return (
|
|
20
20
|
<div
|
|
21
21
|
{...rest}
|
|
22
|
-
className={cl(rest.className, "aksel-
|
|
22
|
+
className={cl(rest.className, "aksel-listbox__options")}
|
|
23
23
|
role="listbox"
|
|
24
24
|
tabIndex={-1}
|
|
25
25
|
onMouseOver={(event) => {
|
|
26
26
|
const target = event.target as HTMLElement;
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
|
|
27
|
+
const optionEl: HTMLElement | null = target.closest('[role="option"]');
|
|
28
|
+
if (optionEl) {
|
|
29
|
+
setVirtuallyFocusedOptionId(optionEl?.dataset.id || "");
|
|
30
30
|
}
|
|
31
31
|
}}
|
|
32
32
|
>
|
|
@@ -35,4 +35,4 @@ function ListboxList({
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export {
|
|
38
|
+
export { ListboxOptions };
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { ListboxGroup } from "../group/ListboxGroup";
|
|
5
5
|
import { ListboxInputSlot } from "../input-slot/ListboxInputSlot";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { ListboxOption } from "../option/ListboxOption";
|
|
7
|
+
import { ListboxOptions } from "../options/ListboxOptions";
|
|
8
|
+
import { findNextOption, findPrevOption } from "./domHelpers";
|
|
9
9
|
|
|
10
10
|
export interface ListboxProps {
|
|
11
11
|
children: React.ReactNode;
|
|
12
|
-
|
|
12
|
+
setVirtuallyFocusedOptionId: (value: string) => void;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Low level component for displaying a list of selectable
|
|
16
|
+
* Low level component for displaying a list of selectable options with optional grouping.
|
|
17
17
|
* Keyboard navigation is implemented with virtual focus so that real focus can remain on an input field.
|
|
18
18
|
*/
|
|
19
|
-
function Listbox({ children,
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
function Listbox({ children, setVirtuallyFocusedOptionId }: ListboxProps) {
|
|
20
|
+
const virtuallyFocusOption = (element: HTMLElement | null) => {
|
|
21
|
+
setVirtuallyFocusedOptionId(element?.dataset.id || "");
|
|
22
22
|
element?.scrollIntoView({ block: "nearest" });
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -32,59 +32,59 @@ function Listbox({ children, setVirtuallyFocusedItemId }: ListboxProps) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// Helper functions
|
|
35
|
-
const
|
|
35
|
+
const getFirstOption = (suffix: string = "") =>
|
|
36
36
|
listbox.querySelector<HTMLElement>(`[role="option"]${suffix}`);
|
|
37
|
-
const
|
|
38
|
-
const
|
|
37
|
+
const getLastOption = () => {
|
|
38
|
+
const allOptions =
|
|
39
39
|
listbox.querySelectorAll<HTMLElement>('[role="option"]');
|
|
40
|
-
return
|
|
40
|
+
return allOptions[allOptions.length - 1];
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const focusedOptionElm = getFirstOption('[data-virtual-focus="true"]');
|
|
44
44
|
|
|
45
|
-
// Doesn't make sense to have real focus on one
|
|
45
|
+
// Doesn't make sense to have real focus on one option and virtual focus on another at the same time.
|
|
46
46
|
// Not sure if it matters, though 🤔
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
47
|
+
const optionElmWithRealFocus = getFirstOption(":focus");
|
|
48
|
+
if (optionElmWithRealFocus) {
|
|
49
49
|
listbox.focus();
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const virtuallyFocusWithFallback = (
|
|
53
|
-
getNextElement: (
|
|
53
|
+
getNextElement: (currentOption: HTMLElement) => HTMLElement | null,
|
|
54
54
|
getFallback: () => HTMLElement | null,
|
|
55
55
|
) => {
|
|
56
56
|
event.preventDefault();
|
|
57
|
-
if (!
|
|
58
|
-
|
|
57
|
+
if (!focusedOptionElm) {
|
|
58
|
+
virtuallyFocusOption(getFallback());
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
63
|
-
|
|
61
|
+
const nextOption = getNextElement(focusedOptionElm);
|
|
62
|
+
if (!nextOption) {
|
|
63
|
+
virtuallyFocusOption(getFallback());
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
virtuallyFocusOption(nextOption);
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
switch (event.key) {
|
|
70
70
|
case "ArrowDown":
|
|
71
|
-
virtuallyFocusWithFallback(
|
|
71
|
+
virtuallyFocusWithFallback(findNextOption, getFirstOption);
|
|
72
72
|
break;
|
|
73
73
|
case "ArrowUp":
|
|
74
|
-
virtuallyFocusWithFallback(
|
|
74
|
+
virtuallyFocusWithFallback(findPrevOption, getLastOption);
|
|
75
75
|
break;
|
|
76
76
|
case "Home":
|
|
77
77
|
event.preventDefault();
|
|
78
|
-
|
|
78
|
+
virtuallyFocusOption(getFirstOption());
|
|
79
79
|
break;
|
|
80
80
|
case "End":
|
|
81
81
|
event.preventDefault();
|
|
82
|
-
|
|
82
|
+
virtuallyFocusOption(getLastOption());
|
|
83
83
|
break;
|
|
84
84
|
case "Enter":
|
|
85
85
|
case "Accept":
|
|
86
|
-
if (
|
|
87
|
-
|
|
86
|
+
if (focusedOptionElm) {
|
|
87
|
+
focusedOptionElm.click();
|
|
88
88
|
}
|
|
89
89
|
break;
|
|
90
90
|
// TODO: Consider implementing PageUp/PageDown too
|
|
@@ -97,8 +97,8 @@ function Listbox({ children, setVirtuallyFocusedItemId }: ListboxProps) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
Listbox.InputSlot = ListboxInputSlot;
|
|
100
|
-
Listbox.
|
|
101
|
-
Listbox.
|
|
100
|
+
Listbox.Options = ListboxOptions;
|
|
101
|
+
Listbox.Option = ListboxOption;
|
|
102
102
|
Listbox.Group = ListboxGroup;
|
|
103
103
|
|
|
104
104
|
export default Listbox;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function
|
|
2
|
-
const nextElement =
|
|
1
|
+
function findNextOption(currentOption: HTMLElement) {
|
|
2
|
+
const nextElement = currentOption.nextElementSibling as HTMLElement | null;
|
|
3
3
|
if (nextElement) {
|
|
4
4
|
if (nextElement.role === "group") {
|
|
5
5
|
return nextElement.querySelector<HTMLElement>('[role="option"]');
|
|
@@ -11,7 +11,7 @@ function findNextItem(currentItem: HTMLElement) {
|
|
|
11
11
|
|
|
12
12
|
// No next element: Current element might be inside a group.
|
|
13
13
|
// Check if the parent has a next sibling
|
|
14
|
-
const parentNextElement =
|
|
14
|
+
const parentNextElement = currentOption.parentElement
|
|
15
15
|
?.nextElementSibling as HTMLElement | null;
|
|
16
16
|
if (parentNextElement) {
|
|
17
17
|
if (parentNextElement.role === "group") {
|
|
@@ -25,8 +25,9 @@ function findNextItem(currentItem: HTMLElement) {
|
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function
|
|
29
|
-
const prevElement =
|
|
28
|
+
function findPrevOption(currentOption: HTMLElement) {
|
|
29
|
+
const prevElement =
|
|
30
|
+
currentOption.previousElementSibling as HTMLElement | null;
|
|
30
31
|
if (prevElement) {
|
|
31
32
|
if (prevElement.role === "group") {
|
|
32
33
|
return prevElement.querySelector<HTMLElement>(
|
|
@@ -40,7 +41,7 @@ function findPrevItem(currentItem: HTMLElement) {
|
|
|
40
41
|
|
|
41
42
|
// No previous element: Current element might be inside a group.
|
|
42
43
|
// Check if the parent has a previous sibling.
|
|
43
|
-
const parentPrevElement =
|
|
44
|
+
const parentPrevElement = currentOption.parentElement
|
|
44
45
|
?.previousElementSibling as HTMLElement | null;
|
|
45
46
|
if (parentPrevElement) {
|
|
46
47
|
if (parentPrevElement.role === "group") {
|
|
@@ -56,4 +57,4 @@ function findPrevItem(currentItem: HTMLElement) {
|
|
|
56
57
|
return null;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
export {
|
|
60
|
+
export { findNextOption, findPrevOption };
|
|
@@ -73,7 +73,7 @@ const Floating: FloatingComponent = ({ children }: FloatingProps) => {
|
|
|
73
73
|
*/
|
|
74
74
|
type FloatingAnchorProps = HTMLAttributes<HTMLDivElement> &
|
|
75
75
|
AsChildProps & {
|
|
76
|
-
virtualRef?:
|
|
76
|
+
virtualRef?: Measurable;
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -90,7 +90,7 @@ const FloatingAnchor = forwardRef<HTMLDivElement, FloatingAnchorProps>(
|
|
|
90
90
|
useEffect(() => {
|
|
91
91
|
// Allows anchoring the floating to non-DOM nodes like a cursor position.
|
|
92
92
|
// We replace `anchorRef` with a virtual ref in such cases.
|
|
93
|
-
context.onAnchorChange(virtualRef
|
|
93
|
+
context.onAnchorChange(virtualRef || ref.current);
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
const Comp = asChild ? Slot : "div";
|
|
@@ -31,7 +31,6 @@ interface FocusBoundaryProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
31
31
|
* tabbing. If focus is moved outside the boundary programmatically or by
|
|
32
32
|
* pointer, it will not be moved back.
|
|
33
33
|
*
|
|
34
|
-
* - Links (`<a>` elements), are not considered tabbable for the purpose of looping.
|
|
35
34
|
* - Hidden inputs (i.e. `<input type="hidden">`) are not considered tabbable.
|
|
36
35
|
* - Elements that are `display: none` or `visibility: hidden` are not considered tabbable.
|
|
37
36
|
* - Elements with `tabIndex < 0` are not considered tabbable.
|
|
@@ -392,7 +391,7 @@ const FocusBoundary = forwardRef<HTMLDivElement, FocusBoundaryProps>(
|
|
|
392
391
|
* Returns the first and last tabbable elements inside a container as a tuple.
|
|
393
392
|
*/
|
|
394
393
|
function getTabbableEdges(container: HTMLElement) {
|
|
395
|
-
const candidates = getTabbableCandidates(container);
|
|
394
|
+
const candidates = getTabbableCandidates(container, { omitLinks: false });
|
|
396
395
|
return [
|
|
397
396
|
findFirstVisible(candidates, container),
|
|
398
397
|
findFirstVisible(candidates.reverse(), container),
|
|
@@ -29,6 +29,17 @@ const {
|
|
|
29
29
|
|
|
30
30
|
type LinkAnchorOverlayProps = HTMLAttributes<HTMLDivElement> & AsChildProps;
|
|
31
31
|
|
|
32
|
+
/*
|
|
33
|
+
* NB: Clicks on the overlay are captured with onClick. This does not work with middle-mouse-click.
|
|
34
|
+
* We could capture such click with onAuxClick, but last time we tried that,
|
|
35
|
+
* "forwarding" the click with dispatchEvent didn't work properly.
|
|
36
|
+
* - Chrome: Worked if we dispatched a regular click event.
|
|
37
|
+
* - Firefox: Did not work.
|
|
38
|
+
* - Safari: Opened the link in the same tab (tested in BrowserStack).
|
|
39
|
+
* We could use window.open() instead, but this would not run on(Aux)Click-callbacks on the link.
|
|
40
|
+
* We consider this unacceptable since many rely on this for tracking etc.
|
|
41
|
+
*/
|
|
42
|
+
|
|
32
43
|
const LinkAnchorOverlay = forwardRef<HTMLDivElement, LinkAnchorOverlayProps>(
|
|
33
44
|
(
|
|
34
45
|
{
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
* See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
6
6
|
* Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
|
|
7
7
|
*/
|
|
8
|
-
function getTabbableCandidates(
|
|
8
|
+
function getTabbableCandidates(
|
|
9
|
+
container: HTMLElement,
|
|
10
|
+
{ omitLinks = true } = {},
|
|
11
|
+
) {
|
|
9
12
|
const nodes: HTMLElement[] = [];
|
|
10
13
|
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
11
14
|
acceptNode: (node: any) => {
|
|
@@ -29,7 +32,7 @@ function getTabbableCandidates(container: HTMLElement) {
|
|
|
29
32
|
nodes.push(walker.currentNode as HTMLElement);
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
return removeLinks(nodes);
|
|
35
|
+
return omitLinks ? removeLinks(nodes) : nodes;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
function removeLinks(items: HTMLElement[]) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
1
|
+
export { cl } from "./className";
|
|
2
|
+
export { composeEventHandlers } from "./composeEventHandlers";
|
|
3
|
+
export { clipboardCopy } from "./clipboardCopy";
|
|
4
|
+
export { createStrictContext } from "./create-strict-context";
|
|
5
|
+
export { isIOS, isSafari, isWebKit } from "./detectBrowser";
|
|
6
|
+
export { hideNonTargetElements } from "./hideNonTargetElements";
|
|
7
|
+
export { ownerDocument, ownerWindow } from "./owner";
|
|
8
|
+
export { requireReactElement } from "./requireReactElement";
|
|
9
|
+
export { resolveRef } from "./resolveRef";
|
package/src/utils/hooks/index.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
1
|
+
export {
|
|
2
|
+
useControllableState,
|
|
3
|
+
type UseControllableStateProps,
|
|
4
|
+
} from "./useControllableState";
|
|
5
|
+
export { useMergeRefs, useMergeRefsN } from "./useMergeRefs";
|
|
6
|
+
export { noMatchMedia, useMedia } from "./useMedia";
|
|
7
|
+
export { usePrevious } from "./usePrevious";
|
|
8
|
+
export { useAnimationsFinished } from "./useAnimationsFinished";
|
|
9
|
+
export { useEventCallback } from "./useEventCallback";
|
|
10
|
+
export { useOpenChangeAnimationComplete } from "./useOpenChangeAnimationComplete";
|
|
11
|
+
export { useRefWithInit } from "./useRefWithInit";
|
|
12
|
+
export { useScrollLock } from "./useScrollLock";
|
|
13
|
+
export { Timeout, useTimeout } from "./useTimeout";
|
|
14
|
+
export {
|
|
15
|
+
type TransitionStatus,
|
|
16
|
+
createTransitionStatusAttribute,
|
|
17
|
+
useTransitionStatus,
|
|
18
|
+
} from "./useTransitionStatus";
|
|
19
|
+
export { useValueAsRef } from "./useValueAsRef";
|
|
20
|
+
export { createDescendantContext } from "./descendants/useDescendant";
|
|
14
21
|
export { DescendantsManager } from "./descendants/descendant";
|
|
@@ -6,6 +6,46 @@ let originalHtmlStyles: Partial<CSSStyleDeclaration> = {};
|
|
|
6
6
|
let originalBodyStyles: Partial<CSSStyleDeclaration> = {};
|
|
7
7
|
let originalHtmlScrollBehavior = "";
|
|
8
8
|
|
|
9
|
+
function supportsStableScrollbarGutter(referenceElement: Element | null) {
|
|
10
|
+
const supported =
|
|
11
|
+
typeof CSS !== "undefined" &&
|
|
12
|
+
CSS.supports &&
|
|
13
|
+
CSS.supports("scrollbar-gutter", "stable");
|
|
14
|
+
|
|
15
|
+
if (!supported || typeof document === "undefined") {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* We need to do aditional checks since the scenario:
|
|
21
|
+
* - Scrollbar is edited with `::-webkit-scrollbar`
|
|
22
|
+
* - MacOS setting: Show scroll bars -> Automatically based on mouse or tracked
|
|
23
|
+
* Causes the calculation of scrollbar width to be incorrect, and thus the scrollbar gutter to not work as intended.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const doc = ownerDocument(referenceElement);
|
|
27
|
+
const html = doc.documentElement;
|
|
28
|
+
const body = doc.body;
|
|
29
|
+
|
|
30
|
+
const scrollContainer = isOverflowElement(html) ? html : body;
|
|
31
|
+
|
|
32
|
+
const originalScrollContainerOverflowY = scrollContainer.style.overflowY;
|
|
33
|
+
const originalHtmlStyleGutter = html.style.scrollbarGutter;
|
|
34
|
+
|
|
35
|
+
html.style.scrollbarGutter = "stable";
|
|
36
|
+
|
|
37
|
+
scrollContainer.style.overflowY = "scroll";
|
|
38
|
+
const before = scrollContainer.offsetWidth;
|
|
39
|
+
|
|
40
|
+
scrollContainer.style.overflowY = "hidden";
|
|
41
|
+
const after = scrollContainer.offsetWidth;
|
|
42
|
+
|
|
43
|
+
scrollContainer.style.overflowY = originalScrollContainerOverflowY;
|
|
44
|
+
html.style.scrollbarGutter = originalHtmlStyleGutter;
|
|
45
|
+
|
|
46
|
+
return before === after;
|
|
47
|
+
}
|
|
48
|
+
|
|
9
49
|
function hasInsetScrollbars(referenceElement: Element | null) {
|
|
10
50
|
if (typeof document === "undefined") {
|
|
11
51
|
return false;
|
|
@@ -59,6 +99,9 @@ function preventScrollStandard(referenceElement: Element | null) {
|
|
|
59
99
|
|
|
60
100
|
const htmlStyles = win.getComputedStyle(html);
|
|
61
101
|
const bodyStyles = win.getComputedStyle(body);
|
|
102
|
+
const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || "";
|
|
103
|
+
const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges");
|
|
104
|
+
const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable";
|
|
62
105
|
|
|
63
106
|
scrollTop = html.scrollTop;
|
|
64
107
|
scrollLeft = html.scrollLeft;
|
|
@@ -103,26 +146,27 @@ function preventScrollStandard(referenceElement: Element | null) {
|
|
|
103
146
|
/**
|
|
104
147
|
* Check support for stable scrollbar gutter to avoid layout shift when scrollbars appear/disappear.
|
|
105
148
|
*/
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
149
|
+
const supportsScrollbarGutter =
|
|
150
|
+
supportsStableScrollbarGutter(referenceElement);
|
|
151
|
+
|
|
109
152
|
/*
|
|
110
153
|
* DOM writes:
|
|
111
154
|
* Do not read the DOM past this point!
|
|
112
155
|
*/
|
|
113
156
|
|
|
157
|
+
if (supportsScrollbarGutter) {
|
|
158
|
+
const elementToLock = isOverflowElement(html) ? html : body;
|
|
159
|
+
|
|
160
|
+
html.style.scrollbarGutter = scrollbarGutterValue;
|
|
161
|
+
elementToLock.style.overflowY = "hidden";
|
|
162
|
+
elementToLock.style.overflowX = "hidden";
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
114
166
|
Object.assign(html.style, {
|
|
115
167
|
scrollbarGutter: "stable",
|
|
116
|
-
overflowY:
|
|
117
|
-
|
|
118
|
-
(isScrollableY || hasConstantOverflowY)
|
|
119
|
-
? "scroll"
|
|
120
|
-
: "hidden",
|
|
121
|
-
overflowX:
|
|
122
|
-
!supportsStableScrollbarGutter &&
|
|
123
|
-
(isScrollableX || hasConstantOverflowX)
|
|
124
|
-
? "scroll"
|
|
125
|
-
: "hidden",
|
|
168
|
+
overflowY: isScrollableY || hasConstantOverflowY ? "scroll" : "hidden",
|
|
169
|
+
overflowX: isScrollableX || hasConstantOverflowX ? "scroll" : "hidden",
|
|
126
170
|
});
|
|
127
171
|
|
|
128
172
|
Object.assign(body.style, {
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface ListboxItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "role" | "tabIndex"> {
|
|
3
|
-
/**
|
|
4
|
-
* Unique ID used for tracking which item has virtual focus.
|
|
5
|
-
*/
|
|
6
|
-
id: string;
|
|
7
|
-
hasVirtualFocus: boolean;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
/**
|
|
10
|
-
* Callback when item is selected.
|
|
11
|
-
* To improve performance when you have many items,
|
|
12
|
-
* memoize the prop with e.g. useEventCallback.
|
|
13
|
-
*/
|
|
14
|
-
onClick: React.MouseEventHandler<HTMLDivElement>;
|
|
15
|
-
}
|
|
16
|
-
declare function ListboxItemComponent({ id, hasVirtualFocus, children, className, ...rest }: ListboxItemProps): React.JSX.Element;
|
|
17
|
-
/**
|
|
18
|
-
* This component is memoized. To improve performance when you have many items,
|
|
19
|
-
* make sure all object props have stable references (i.e. memoize the event handlers with e.g. useEventCallback).
|
|
20
|
-
*
|
|
21
|
-
* NB: Remember to set `aria-selected` on selected items!
|
|
22
|
-
*/
|
|
23
|
-
export declare const ListboxItem: typeof ListboxItemComponent;
|
|
24
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListboxItem.js","sourceRoot":"","sources":["../../../../../src/utils/components/Listbox/item/ListboxItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,8CAAsC;AAoBtC,SAAS,oBAAoB,CAAC,EAMX;IACjB,oCAAoC;QAPR,EAC5B,EAAE,EACF,eAAe,EACf,QAAQ,EACR,SAAS,OAEQ,EADd,IAAI,cALqB,kDAM7B,CADQ;IAIP,cAAc;IAEd,OAAO,CACL,sEACiB,KAAK,IAChB,IAAI,IACR,SAAS,EAAE,IAAA,YAAE,EAAC,qBAAqB,EAAE,SAAS,CAAC,EAC/C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,wBACQ,eAAe,aAC1B,EAAE,EACX,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,SAAS,KAE7D,QAAQ,CACL,CACP,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACU,QAAA,WAAW,GAAG,eAAK,CAAC,IAAI,CACnC,oBAAoB,CACU,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** biome-ignore-all lint/a11y/useKeyWithMouseEvents: We know what we are doing */
|
|
2
|
-
import React from "react";
|
|
3
|
-
export interface ListboxListProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "role" | "tabIndex" | "onMouseOver"> {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
setVirtuallyFocusedItemId: (value: string) => void;
|
|
6
|
-
}
|
|
7
|
-
declare function ListboxList({ children, setVirtuallyFocusedItemId, ...rest }: ListboxListProps): React.JSX.Element;
|
|
8
|
-
export { ListboxList };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListboxList.js","sourceRoot":"","sources":["../../../../../src/utils/components/Listbox/list/ListboxList.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAqCS,kCAAW;AArCpB,0DAA0D;AAC1D,kFAAkF;AAClF,kDAA0B;AAC1B,8CAAsC;AAUtC,SAAS,WAAW,CAAC,EAIF;QAJE,EACnB,QAAQ,EACR,yBAAyB,OAER,EADd,IAAI,cAHY,yCAIpB,CADQ;IAEP,OAAO,CACL,uDACM,IAAI,IACR,SAAS,EAAE,IAAA,YAAE,EAAC,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC,EACpD,IAAI,EAAC,SAAS,EACd,QAAQ,EAAE,CAAC,CAAC,EACZ,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAqB,CAAC;YAC3C,MAAM,MAAM,GAAuB,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YACrE,IAAI,MAAM,EAAE,CAAC;gBACX,yBAAyB,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,EAAE,KAAI,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,KAEA,QAAQ,CACL,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface ListboxItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "role" | "tabIndex"> {
|
|
3
|
-
/**
|
|
4
|
-
* Unique ID used for tracking which item has virtual focus.
|
|
5
|
-
*/
|
|
6
|
-
id: string;
|
|
7
|
-
hasVirtualFocus: boolean;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
/**
|
|
10
|
-
* Callback when item is selected.
|
|
11
|
-
* To improve performance when you have many items,
|
|
12
|
-
* memoize the prop with e.g. useEventCallback.
|
|
13
|
-
*/
|
|
14
|
-
onClick: React.MouseEventHandler<HTMLDivElement>;
|
|
15
|
-
}
|
|
16
|
-
declare function ListboxItemComponent({ id, hasVirtualFocus, children, className, ...rest }: ListboxItemProps): React.JSX.Element;
|
|
17
|
-
/**
|
|
18
|
-
* This component is memoized. To improve performance when you have many items,
|
|
19
|
-
* make sure all object props have stable references (i.e. memoize the event handlers with e.g. useEventCallback).
|
|
20
|
-
*
|
|
21
|
-
* NB: Remember to set `aria-selected` on selected items!
|
|
22
|
-
*/
|
|
23
|
-
export declare const ListboxItem: typeof ListboxItemComponent;
|
|
24
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListboxItem.js","sourceRoot":"","sources":["../../../../../src/utils/components/Listbox/item/ListboxItem.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAoBtC,SAAS,oBAAoB,CAAC,EAMX;IACjB,oCAAoC;QAPR,EAC5B,EAAE,EACF,eAAe,EACf,QAAQ,EACR,SAAS,OAEQ,EADd,IAAI,cALqB,kDAM7B,CADQ;IAIP,cAAc;IAEd,OAAO,CACL,4DACiB,KAAK,IAChB,IAAI,IACR,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAC/C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,wBACQ,eAAe,aAC1B,EAAE,EACX,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,SAAS,KAE7D,QAAQ,CACL,CACP,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CACnC,oBAAoB,CACU,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** biome-ignore-all lint/a11y/useKeyWithMouseEvents: We know what we are doing */
|
|
2
|
-
import React from "react";
|
|
3
|
-
export interface ListboxListProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "role" | "tabIndex" | "onMouseOver"> {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
setVirtuallyFocusedItemId: (value: string) => void;
|
|
6
|
-
}
|
|
7
|
-
declare function ListboxList({ children, setVirtuallyFocusedItemId, ...rest }: ListboxListProps): React.JSX.Element;
|
|
8
|
-
export { ListboxList };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListboxList.js","sourceRoot":"","sources":["../../../../../src/utils/components/Listbox/list/ListboxList.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,0DAA0D;AAC1D,kFAAkF;AAClF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAUtC,SAAS,WAAW,CAAC,EAIF;QAJE,EACnB,QAAQ,EACR,yBAAyB,OAER,EADd,IAAI,cAHY,yCAIpB,CADQ;IAEP,OAAO,CACL,6CACM,IAAI,IACR,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC,EACpD,IAAI,EAAC,SAAS,EACd,QAAQ,EAAE,CAAC,CAAC,EACZ,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAqB,CAAC;YAC3C,MAAM,MAAM,GAAuB,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YACrE,IAAI,MAAM,EAAE,CAAC;gBACX,yBAAyB,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,EAAE,KAAI,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,KAEA,QAAQ,CACL,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|