@navikt/ds-react 8.6.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.d.ts +27 -0
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js +41 -0
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js.map +1 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.d.ts +8 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js +10 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js.map +1 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.d.ts +34 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js +61 -0
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js.map +1 -0
- 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.js +1 -1
- 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 +9 -0
- package/cjs/data/table/root/DataTableRoot.context.js +11 -0
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -0
- package/cjs/data/table/root/DataTableRoot.d.ts +30 -3
- package/cjs/data/table/root/DataTableRoot.js +12 -4
- 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 +27 -5
- package/cjs/data/table/th/DataTableTh.js +49 -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 +10 -2
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/data/token-filter/AutoSuggest.d.ts +6 -2
- package/cjs/data/token-filter/AutoSuggest.js +44 -11
- package/cjs/data/token-filter/AutoSuggest.js.map +1 -1
- package/cjs/data/token-filter/TokenFilter.d.ts +5 -5
- package/cjs/data/token-filter/TokenFilter.js +105 -42
- package/cjs/data/token-filter/TokenFilter.js.map +1 -1
- package/cjs/data/token-filter/TokenFilter.types.d.ts +51 -33
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.d.ts +2 -3
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js +11 -15
- package/cjs/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
- package/cjs/data/token-filter/helpers/operators.d.ts +6 -6
- package/cjs/data/token-filter/helpers/operators.js +3 -4
- package/cjs/data/token-filter/helpers/operators.js.map +1 -1
- package/cjs/data/token-filter/helpers/parse-query-text.d.ts +2 -20
- package/cjs/data/token-filter/helpers/parse-query-text.js +1 -1
- package/cjs/data/token-filter/helpers/parse-query-text.js.map +1 -1
- package/cjs/data/token-filter/helpers/query-builder.d.ts +2 -2
- package/cjs/data/token-filter/helpers/query-builder.js.map +1 -1
- package/cjs/date/Date.Dialog.d.ts +5 -1
- package/cjs/date/Date.Dialog.js +6 -2
- package/cjs/date/Date.Dialog.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/DatePicker.js +3 -2
- package/cjs/date/datepicker/DatePicker.js.map +1 -1
- package/cjs/date/datepicker/hooks/useDatepicker.d.ts +12 -1
- package/cjs/date/datepicker/hooks/useDatepicker.js +5 -2
- package/cjs/date/datepicker/hooks/useDatepicker.js.map +1 -1
- package/cjs/date/datepicker/hooks/useRangeDatepicker.js +3 -1
- package/cjs/date/datepicker/hooks/useRangeDatepicker.js.map +1 -1
- package/cjs/date/datepicker/parts/DatePicker.Months.d.ts +2 -1
- package/cjs/date/datepicker/parts/DatePicker.Months.js +3 -3
- package/cjs/date/datepicker/parts/DatePicker.Months.js.map +1 -1
- package/cjs/date/datepicker/parts/DatePicker.RDP.d.ts +5 -1
- package/cjs/date/datepicker/parts/DatePicker.RDP.js +2 -2
- package/cjs/date/datepicker/parts/DatePicker.RDP.js.map +1 -1
- package/cjs/date/monthpicker/MonthPicker.js +3 -2
- package/cjs/date/monthpicker/MonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.d.ts +11 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.js +3 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.d.ts +4 -1
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.js +3 -2
- package/cjs/date/monthpicker/parts/MonthPicker.Caption.js.map +1 -1
- package/cjs/dropdown/Toggle.js +5 -12
- package/cjs/dropdown/Toggle.js.map +1 -1
- package/cjs/form/checkbox/CheckboxGroup.js +1 -1
- package/cjs/form/checkbox/CheckboxGroup.js.map +1 -1
- package/cjs/form/combobox/Input/Input.js +1 -1
- package/cjs/form/combobox/Input/Input.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/inline-message/root/InlineMessage.js +2 -2
- package/cjs/inline-message/root/InlineMessage.js.map +1 -1
- package/cjs/provider/Provider.d.ts +2 -2
- 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/tooltip/Tooltip.js +1 -3
- package/cjs/tooltip/Tooltip.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/HighlightText/HighlightText.d.ts +8 -0
- package/cjs/utils/components/HighlightText/HighlightText.js +27 -0
- package/cjs/utils/components/HighlightText/HighlightText.js.map +1 -0
- package/cjs/utils/components/Listbox/group/ListboxGroup.d.ts +7 -0
- package/cjs/utils/components/Listbox/group/ListboxGroup.js +15 -0
- package/cjs/utils/components/Listbox/group/ListboxGroup.js.map +1 -0
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.d.ts +7 -0
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.js +15 -0
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.js.map +1 -0
- package/cjs/utils/components/Listbox/option/ListboxOption.d.ts +24 -0
- package/cjs/utils/components/Listbox/option/ListboxOption.js +33 -0
- 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/options/ListboxOptions.js +32 -0
- package/cjs/utils/components/Listbox/options/ListboxOptions.js.map +1 -0
- package/cjs/utils/components/Listbox/root/ListboxRoot.d.ts +20 -0
- package/cjs/utils/components/Listbox/root/ListboxRoot.js +84 -0
- package/cjs/utils/components/Listbox/root/ListboxRoot.js.map +1 -0
- package/cjs/utils/components/Listbox/root/domHelpers.d.ts +3 -0
- package/cjs/utils/components/Listbox/root/domHelpers.js +53 -0
- package/cjs/utils/components/Listbox/root/domHelpers.js.map +1 -0
- 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 +9 -64
- 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 +16 -0
- package/cjs/utils/helpers/focus.js +63 -0
- package/cjs/utils/helpers/focus.js.map +1 -0
- 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/useDeferredValue.d.ts +1 -0
- package/cjs/utils/hooks/useDeferredValue.js +14 -0
- package/cjs/utils/hooks/useDeferredValue.js.map +1 -0
- 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.d.ts +27 -0
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js +35 -0
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js.map +1 -0
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.d.ts +8 -0
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js +6 -0
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js.map +1 -0
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.d.ts +34 -0
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js +21 -0
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js.map +1 -0
- 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.js +1 -1
- 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 +9 -0
- package/esm/data/table/root/DataTableRoot.context.js +7 -0
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -0
- package/esm/data/table/root/DataTableRoot.d.ts +30 -3
- package/esm/data/table/root/DataTableRoot.js +10 -4
- 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 +27 -5
- package/esm/data/table/th/DataTableTh.js +51 -24
- 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 +10 -2
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/data/token-filter/AutoSuggest.d.ts +6 -2
- package/esm/data/token-filter/AutoSuggest.js +43 -13
- package/esm/data/token-filter/AutoSuggest.js.map +1 -1
- package/esm/data/token-filter/TokenFilter.d.ts +5 -5
- package/esm/data/token-filter/TokenFilter.js +105 -42
- package/esm/data/token-filter/TokenFilter.js.map +1 -1
- package/esm/data/token-filter/TokenFilter.types.d.ts +51 -33
- package/esm/data/token-filter/helpers/generate-autocomplete-options.d.ts +2 -3
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js +11 -15
- package/esm/data/token-filter/helpers/generate-autocomplete-options.js.map +1 -1
- package/esm/data/token-filter/helpers/operators.d.ts +6 -6
- package/esm/data/token-filter/helpers/operators.js +3 -4
- package/esm/data/token-filter/helpers/operators.js.map +1 -1
- package/esm/data/token-filter/helpers/parse-query-text.d.ts +2 -20
- package/esm/data/token-filter/helpers/parse-query-text.js +1 -1
- package/esm/data/token-filter/helpers/parse-query-text.js.map +1 -1
- package/esm/data/token-filter/helpers/query-builder.d.ts +2 -2
- package/esm/data/token-filter/helpers/query-builder.js.map +1 -1
- package/esm/date/Date.Dialog.d.ts +5 -1
- package/esm/date/Date.Dialog.js +6 -2
- package/esm/date/Date.Dialog.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/DatePicker.js +3 -2
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/hooks/useDatepicker.d.ts +12 -1
- package/esm/date/datepicker/hooks/useDatepicker.js +5 -2
- package/esm/date/datepicker/hooks/useDatepicker.js.map +1 -1
- package/esm/date/datepicker/hooks/useRangeDatepicker.js +3 -1
- package/esm/date/datepicker/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/datepicker/parts/DatePicker.Months.d.ts +2 -1
- package/esm/date/datepicker/parts/DatePicker.Months.js +3 -3
- package/esm/date/datepicker/parts/DatePicker.Months.js.map +1 -1
- package/esm/date/datepicker/parts/DatePicker.RDP.d.ts +5 -1
- package/esm/date/datepicker/parts/DatePicker.RDP.js +2 -2
- package/esm/date/datepicker/parts/DatePicker.RDP.js.map +1 -1
- package/esm/date/monthpicker/MonthPicker.js +3 -2
- package/esm/date/monthpicker/MonthPicker.js.map +1 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.d.ts +11 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.js +3 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/monthpicker/parts/MonthPicker.Caption.d.ts +4 -1
- package/esm/date/monthpicker/parts/MonthPicker.Caption.js +3 -2
- package/esm/date/monthpicker/parts/MonthPicker.Caption.js.map +1 -1
- package/esm/dropdown/Toggle.js +5 -12
- package/esm/dropdown/Toggle.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.js +1 -1
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.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/inline-message/root/InlineMessage.js +3 -3
- package/esm/inline-message/root/InlineMessage.js.map +1 -1
- package/esm/provider/Provider.d.ts +2 -2
- 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/tooltip/Tooltip.js +1 -3
- package/esm/tooltip/Tooltip.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/HighlightText/HighlightText.d.ts +8 -0
- package/esm/utils/components/HighlightText/HighlightText.js +21 -0
- package/esm/utils/components/HighlightText/HighlightText.js.map +1 -0
- package/esm/utils/components/Listbox/group/ListboxGroup.d.ts +7 -0
- package/esm/utils/components/Listbox/group/ListboxGroup.js +10 -0
- package/esm/utils/components/Listbox/group/ListboxGroup.js.map +1 -0
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.d.ts +7 -0
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.js +9 -0
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.js.map +1 -0
- package/esm/utils/components/Listbox/option/ListboxOption.d.ts +24 -0
- package/esm/utils/components/Listbox/option/ListboxOption.js +27 -0
- 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/options/ListboxOptions.js +27 -0
- package/esm/utils/components/Listbox/options/ListboxOptions.js.map +1 -0
- package/esm/utils/components/Listbox/root/ListboxRoot.d.ts +20 -0
- package/esm/utils/components/Listbox/root/ListboxRoot.js +79 -0
- package/esm/utils/components/Listbox/root/ListboxRoot.js.map +1 -0
- package/esm/utils/components/Listbox/root/domHelpers.d.ts +3 -0
- package/esm/utils/components/Listbox/root/domHelpers.js +50 -0
- package/esm/utils/components/Listbox/root/domHelpers.js.map +1 -0
- 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 +9 -64
- 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 +16 -0
- package/esm/utils/helpers/focus.js +60 -0
- package/esm/utils/helpers/focus.js.map +1 -0
- 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/useDeferredValue.d.ts +1 -0
- package/esm/utils/hooks/useDeferredValue.js +7 -0
- package/esm/utils/hooks/useDeferredValue.js.map +1 -0
- package/esm/utils/hooks/useScrollLock.js +41 -11
- package/esm/utils/hooks/useScrollLock.js.map +1 -1
- package/package.json +9 -9
- 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 +54 -0
- package/src/data/drag-and-drop/root/DataDragAndDrop.context.tsx +14 -0
- package/src/data/drag-and-drop/root/DataDragAndDropRoot.tsx +54 -0
- 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 +1 -1
- 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 +14 -0
- package/src/data/table/root/DataTableRoot.tsx +60 -14
- 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 +133 -65
- 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 +18 -2
- package/src/data/token-filter/AutoSuggest.tsx +141 -29
- package/src/data/token-filter/TokenFilter.tsx +174 -79
- package/src/data/token-filter/TokenFilter.types.ts +70 -42
- package/src/data/token-filter/helpers/generate-autocomplete-options.test.ts +97 -97
- package/src/data/token-filter/helpers/generate-autocomplete-options.ts +31 -38
- package/src/data/token-filter/helpers/operators.test.ts +29 -29
- package/src/data/token-filter/helpers/operators.ts +16 -16
- package/src/data/token-filter/helpers/parse-query-text.test.ts +37 -35
- package/src/data/token-filter/helpers/parse-query-text.ts +7 -26
- package/src/data/token-filter/helpers/query-builder.ts +2 -2
- package/src/date/Date.Dialog.tsx +15 -0
- package/src/date/Date.Input.tsx +1 -1
- package/src/date/datepicker/DatePicker.tsx +3 -0
- package/src/date/datepicker/hooks/useDatepicker.tsx +19 -3
- package/src/date/datepicker/hooks/useRangeDatepicker.tsx +5 -1
- package/src/date/datepicker/parts/DatePicker.Months.tsx +9 -1
- package/src/date/datepicker/parts/DatePicker.RDP.tsx +7 -1
- package/src/date/monthpicker/MonthPicker.tsx +3 -1
- package/src/date/monthpicker/hooks/useMonthPicker.tsx +16 -2
- package/src/date/monthpicker/parts/MonthPicker.Caption.tsx +20 -2
- package/src/dropdown/Toggle.tsx +6 -12
- package/src/form/checkbox/CheckboxGroup.tsx +1 -1
- package/src/form/combobox/Input/Input.tsx +2 -2
- package/src/form/fieldset/Fieldset.tsx +31 -7
- package/src/form/radio/RadioGroup.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/inline-message/root/InlineMessage.tsx +5 -5
- package/src/provider/Provider.tsx +2 -2
- package/src/read-more/ReadMore.tsx +15 -16
- package/src/tooltip/Tooltip.tsx +1 -3
- package/src/types/index.ts +1 -1
- package/src/utils/components/HighlightText/HighlightText.tsx +34 -0
- package/src/utils/components/Listbox/group/ListboxGroup.tsx +26 -0
- package/src/utils/components/Listbox/input-slot/ListboxInputSlot.tsx +22 -0
- package/src/utils/components/Listbox/option/ListboxOption.tsx +57 -0
- package/src/utils/components/Listbox/options/ListboxOptions.tsx +38 -0
- package/src/utils/components/Listbox/root/ListboxRoot.tsx +104 -0
- package/src/utils/components/Listbox/root/domHelpers.ts +60 -0
- package/src/utils/components/floating/Floating.tsx +2 -2
- package/src/utils/components/focus-boundary/FocusBoundary.tsx +9 -80
- package/src/utils/components/link-anchor/LinkAnchor.tsx +11 -0
- package/src/utils/helpers/className.ts +1 -1
- package/src/utils/helpers/focus.ts +78 -0
- package/src/utils/helpers/index.ts +9 -9
- package/src/utils/hooks/index.ts +20 -13
- package/src/utils/hooks/useDeferredValue.ts +12 -0
- package/src/utils/hooks/useScrollLock.ts +57 -13
- package/cjs/data/table/th/DataTableThSortHandle.d.ts +0 -6
- package/cjs/data/table/th/DataTableThSortHandle.js +0 -82
- package/cjs/data/table/th/DataTableThSortHandle.js.map +0 -1
- package/esm/data/table/th/DataTableThSortHandle.d.ts +0 -6
- package/esm/data/table/th/DataTableThSortHandle.js +0 -47
- package/esm/data/table/th/DataTableThSortHandle.js.map +0 -1
- package/src/data/table/th/DataTableThSortHandle.tsx +0 -67
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useId } from "../../../../utils-external";
|
|
3
|
+
|
|
4
|
+
interface ListboxGroupProps {
|
|
5
|
+
label: React.ReactNode;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function ListboxGroup({ label, children }: ListboxGroupProps) {
|
|
10
|
+
const labelId = useId();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
role="group"
|
|
15
|
+
className="aksel-listbox__group"
|
|
16
|
+
aria-labelledby={labelId}
|
|
17
|
+
>
|
|
18
|
+
<div id={labelId} aria-hidden>
|
|
19
|
+
{label}
|
|
20
|
+
</div>
|
|
21
|
+
{children}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { ListboxGroup };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Slot } from "../../slot/Slot";
|
|
3
|
+
|
|
4
|
+
interface ListboxInputSlotProps {
|
|
5
|
+
children: React.ReactElement;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const ListboxInputSlot = ({ children }: ListboxInputSlotProps) => {
|
|
9
|
+
return (
|
|
10
|
+
<Slot
|
|
11
|
+
aria-activedescendant="aksel-listbox__option-active"
|
|
12
|
+
// @ts-expect-error - You are meant to use an <input>, but Slot doesn't know that.
|
|
13
|
+
autoComplete="off"
|
|
14
|
+
role="combobox"
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</Slot>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { ListboxInputSlot };
|
|
22
|
+
export type { ListboxInputSlotProps };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cl } from "../../../helpers";
|
|
3
|
+
|
|
4
|
+
export interface ListboxOptionProps extends Omit<
|
|
5
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
6
|
+
"role" | "tabIndex"
|
|
7
|
+
> {
|
|
8
|
+
/**
|
|
9
|
+
* Unique ID used for tracking which option has virtual focus.
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
hasVirtualFocus: boolean;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Callback when option is selected.
|
|
16
|
+
* To improve performance when you have many options,
|
|
17
|
+
* memoize the prop with e.g. useEventCallback.
|
|
18
|
+
*/
|
|
19
|
+
onClick: React.MouseEventHandler<HTMLDivElement>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function ListboxOptionComponent({
|
|
23
|
+
id,
|
|
24
|
+
hasVirtualFocus,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
...rest
|
|
28
|
+
}: ListboxOptionProps) {
|
|
29
|
+
//console.log("Rendering option", id);
|
|
30
|
+
|
|
31
|
+
// TODO: Slot?
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
aria-selected={false}
|
|
36
|
+
{...rest}
|
|
37
|
+
className={cl("aksel-listbox__option", className)}
|
|
38
|
+
role="option"
|
|
39
|
+
tabIndex={-1}
|
|
40
|
+
data-virtual-focus={hasVirtualFocus}
|
|
41
|
+
data-id={id}
|
|
42
|
+
id={hasVirtualFocus ? "aksel-listbox__option-active" : undefined}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* This component is memoized. To improve performance when you have many options,
|
|
51
|
+
* make sure all object props have stable references (i.e. memoize the event handlers with e.g. useEventCallback).
|
|
52
|
+
*
|
|
53
|
+
* NB: Remember to set `aria-selected` on selected options!
|
|
54
|
+
*/
|
|
55
|
+
export const ListboxOption = React.memo(
|
|
56
|
+
ListboxOptionComponent,
|
|
57
|
+
) as typeof ListboxOptionComponent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
|
|
2
|
+
/** biome-ignore-all lint/a11y/useKeyWithMouseEvents: We know what we are doing */
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { cl } from "../../../helpers";
|
|
5
|
+
|
|
6
|
+
export interface ListboxOptionsProps extends Omit<
|
|
7
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
8
|
+
"role" | "tabIndex" | "onMouseOver"
|
|
9
|
+
> {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
setVirtuallyFocusedOptionId: (value: string) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function ListboxOptions({
|
|
15
|
+
children,
|
|
16
|
+
setVirtuallyFocusedOptionId,
|
|
17
|
+
...rest
|
|
18
|
+
}: ListboxOptionsProps) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
{...rest}
|
|
22
|
+
className={cl(rest.className, "aksel-listbox__options")}
|
|
23
|
+
role="listbox"
|
|
24
|
+
tabIndex={-1}
|
|
25
|
+
onMouseOver={(event) => {
|
|
26
|
+
const target = event.target as HTMLElement;
|
|
27
|
+
const optionEl: HTMLElement | null = target.closest('[role="option"]');
|
|
28
|
+
if (optionEl) {
|
|
29
|
+
setVirtuallyFocusedOptionId(optionEl?.dataset.id || "");
|
|
30
|
+
}
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { ListboxOptions };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
+
/** biome-ignore-all lint/a11y/noStaticElementInteractions: We know what we are doing */
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { ListboxGroup } from "../group/ListboxGroup";
|
|
5
|
+
import { ListboxInputSlot } from "../input-slot/ListboxInputSlot";
|
|
6
|
+
import { ListboxOption } from "../option/ListboxOption";
|
|
7
|
+
import { ListboxOptions } from "../options/ListboxOptions";
|
|
8
|
+
import { findNextOption, findPrevOption } from "./domHelpers";
|
|
9
|
+
|
|
10
|
+
export interface ListboxProps {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
setVirtuallyFocusedOptionId: (value: string) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Low level component for displaying a list of selectable options with optional grouping.
|
|
17
|
+
* Keyboard navigation is implemented with virtual focus so that real focus can remain on an input field.
|
|
18
|
+
*/
|
|
19
|
+
function Listbox({ children, setVirtuallyFocusedOptionId }: ListboxProps) {
|
|
20
|
+
const virtuallyFocusOption = (element: HTMLElement | null) => {
|
|
21
|
+
setVirtuallyFocusedOptionId(element?.dataset.id || "");
|
|
22
|
+
element?.scrollIntoView({ block: "nearest" });
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div
|
|
27
|
+
onKeyDown={(event) => {
|
|
28
|
+
const listbox =
|
|
29
|
+
event.currentTarget.querySelector<HTMLElement>('[role="listbox"]');
|
|
30
|
+
if (!listbox) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Helper functions
|
|
35
|
+
const getFirstOption = (suffix: string = "") =>
|
|
36
|
+
listbox.querySelector<HTMLElement>(`[role="option"]${suffix}`);
|
|
37
|
+
const getLastOption = () => {
|
|
38
|
+
const allOptions =
|
|
39
|
+
listbox.querySelectorAll<HTMLElement>('[role="option"]');
|
|
40
|
+
return allOptions[allOptions.length - 1];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const focusedOptionElm = getFirstOption('[data-virtual-focus="true"]');
|
|
44
|
+
|
|
45
|
+
// Doesn't make sense to have real focus on one option and virtual focus on another at the same time.
|
|
46
|
+
// Not sure if it matters, though 🤔
|
|
47
|
+
const optionElmWithRealFocus = getFirstOption(":focus");
|
|
48
|
+
if (optionElmWithRealFocus) {
|
|
49
|
+
listbox.focus();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const virtuallyFocusWithFallback = (
|
|
53
|
+
getNextElement: (currentOption: HTMLElement) => HTMLElement | null,
|
|
54
|
+
getFallback: () => HTMLElement | null,
|
|
55
|
+
) => {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
if (!focusedOptionElm) {
|
|
58
|
+
virtuallyFocusOption(getFallback());
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const nextOption = getNextElement(focusedOptionElm);
|
|
62
|
+
if (!nextOption) {
|
|
63
|
+
virtuallyFocusOption(getFallback());
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
virtuallyFocusOption(nextOption);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
switch (event.key) {
|
|
70
|
+
case "ArrowDown":
|
|
71
|
+
virtuallyFocusWithFallback(findNextOption, getFirstOption);
|
|
72
|
+
break;
|
|
73
|
+
case "ArrowUp":
|
|
74
|
+
virtuallyFocusWithFallback(findPrevOption, getLastOption);
|
|
75
|
+
break;
|
|
76
|
+
case "Home":
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
virtuallyFocusOption(getFirstOption());
|
|
79
|
+
break;
|
|
80
|
+
case "End":
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
virtuallyFocusOption(getLastOption());
|
|
83
|
+
break;
|
|
84
|
+
case "Enter":
|
|
85
|
+
case "Accept":
|
|
86
|
+
if (focusedOptionElm) {
|
|
87
|
+
focusedOptionElm.click();
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
// TODO: Consider implementing PageUp/PageDown too
|
|
91
|
+
}
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{children}
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Listbox.InputSlot = ListboxInputSlot;
|
|
100
|
+
Listbox.Options = ListboxOptions;
|
|
101
|
+
Listbox.Option = ListboxOption;
|
|
102
|
+
Listbox.Group = ListboxGroup;
|
|
103
|
+
|
|
104
|
+
export default Listbox;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function findNextOption(currentOption: HTMLElement) {
|
|
2
|
+
const nextElement = currentOption.nextElementSibling as HTMLElement | null;
|
|
3
|
+
if (nextElement) {
|
|
4
|
+
if (nextElement.role === "group") {
|
|
5
|
+
return nextElement.querySelector<HTMLElement>('[role="option"]');
|
|
6
|
+
}
|
|
7
|
+
if (nextElement.role === "option") {
|
|
8
|
+
return nextElement;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// No next element: Current element might be inside a group.
|
|
13
|
+
// Check if the parent has a next sibling
|
|
14
|
+
const parentNextElement = currentOption.parentElement
|
|
15
|
+
?.nextElementSibling as HTMLElement | null;
|
|
16
|
+
if (parentNextElement) {
|
|
17
|
+
if (parentNextElement.role === "group") {
|
|
18
|
+
return parentNextElement.querySelector<HTMLElement>('[role="option"]');
|
|
19
|
+
}
|
|
20
|
+
if (parentNextElement.role === "option") {
|
|
21
|
+
return parentNextElement;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function findPrevOption(currentOption: HTMLElement) {
|
|
29
|
+
const prevElement =
|
|
30
|
+
currentOption.previousElementSibling as HTMLElement | null;
|
|
31
|
+
if (prevElement) {
|
|
32
|
+
if (prevElement.role === "group") {
|
|
33
|
+
return prevElement.querySelector<HTMLElement>(
|
|
34
|
+
'[role="option"]:last-of-type',
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (prevElement.role === "option") {
|
|
38
|
+
return prevElement;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// No previous element: Current element might be inside a group.
|
|
43
|
+
// Check if the parent has a previous sibling.
|
|
44
|
+
const parentPrevElement = currentOption.parentElement
|
|
45
|
+
?.previousElementSibling as HTMLElement | null;
|
|
46
|
+
if (parentPrevElement) {
|
|
47
|
+
if (parentPrevElement.role === "group") {
|
|
48
|
+
return parentPrevElement.querySelector<HTMLElement>(
|
|
49
|
+
'[role="option"]:last-of-type',
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if (parentPrevElement.role === "option") {
|
|
53
|
+
return parentPrevElement;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
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";
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ownerDocument,
|
|
12
12
|
resolveRef,
|
|
13
13
|
} from "../../helpers";
|
|
14
|
+
import { focusElement, getTabbableCandidates } from "../../helpers/focus";
|
|
14
15
|
import { useMergeRefs } from "../../hooks";
|
|
15
16
|
import { useValueAsRef } from "../../hooks/useValueAsRef";
|
|
16
17
|
import { Slot } from "../slot/Slot";
|
|
@@ -30,7 +31,6 @@ interface FocusBoundaryProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
30
31
|
* tabbing. If focus is moved outside the boundary programmatically or by
|
|
31
32
|
* pointer, it will not be moved back.
|
|
32
33
|
*
|
|
33
|
-
* - Links (`<a>` elements), are not considered tabbable for the purpose of looping.
|
|
34
34
|
* - Hidden inputs (i.e. `<input type="hidden">`) are not considered tabbable.
|
|
35
35
|
* - Elements that are `display: none` or `visibility: hidden` are not considered tabbable.
|
|
36
36
|
* - Elements with `tabIndex < 0` are not considered tabbable.
|
|
@@ -118,7 +118,7 @@ const FocusBoundary = forwardRef<HTMLDivElement, FocusBoundaryProps>(
|
|
|
118
118
|
if (container.contains(target)) {
|
|
119
119
|
lastFocusedElementRef.current = target;
|
|
120
120
|
} else {
|
|
121
|
-
|
|
121
|
+
focusElement(lastFocusedElementRef.current, { select: true });
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -150,7 +150,7 @@ const FocusBoundary = forwardRef<HTMLDivElement, FocusBoundaryProps>(
|
|
|
150
150
|
* when they are not supposed to (like when clicking on elements outside the container
|
|
151
151
|
*/
|
|
152
152
|
if (!container.contains(relatedTarget)) {
|
|
153
|
-
|
|
153
|
+
focusElement(lastFocusedElementRef.current, { select: true });
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -165,7 +165,7 @@ const FocusBoundary = forwardRef<HTMLDivElement, FocusBoundaryProps>(
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
if (mutations.some((mutation) => mutation.removedNodes.length > 0)) {
|
|
168
|
-
|
|
168
|
+
focusElement(container);
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
171
|
|
|
@@ -230,7 +230,7 @@ const FocusBoundary = forwardRef<HTMLDivElement, FocusBoundaryProps>(
|
|
|
230
230
|
const previouslyFocusedElement = ownerDoc.activeElement;
|
|
231
231
|
|
|
232
232
|
queueMicrotask(() => {
|
|
233
|
-
const focusableElements =
|
|
233
|
+
const focusableElements = getTabbableCandidates(container);
|
|
234
234
|
const initialFocusValueOrFn = initialFocusRef.current;
|
|
235
235
|
const resolvedInitialFocus =
|
|
236
236
|
typeof initialFocusValueOrFn === "function"
|
|
@@ -262,7 +262,7 @@ const FocusBoundary = forwardRef<HTMLDivElement, FocusBoundaryProps>(
|
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
focusElement(elToFocus, {
|
|
266
266
|
preventScroll: elToFocus === container,
|
|
267
267
|
sync: false,
|
|
268
268
|
});
|
|
@@ -361,12 +361,12 @@ const FocusBoundary = forwardRef<HTMLDivElement, FocusBoundaryProps>(
|
|
|
361
361
|
if (!event.shiftKey && focusedElement === last) {
|
|
362
362
|
event.preventDefault();
|
|
363
363
|
if (loop) {
|
|
364
|
-
|
|
364
|
+
focusElement(first, { select: true });
|
|
365
365
|
}
|
|
366
366
|
} else if (event.shiftKey && focusedElement === first) {
|
|
367
367
|
event.preventDefault();
|
|
368
368
|
if (loop) {
|
|
369
|
-
|
|
369
|
+
focusElement(last, { select: true });
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
}
|
|
@@ -391,47 +391,13 @@ const FocusBoundary = forwardRef<HTMLDivElement, FocusBoundaryProps>(
|
|
|
391
391
|
* Returns the first and last tabbable elements inside a container as a tuple.
|
|
392
392
|
*/
|
|
393
393
|
function getTabbableEdges(container: HTMLElement) {
|
|
394
|
-
const candidates = getTabbableCandidates(container);
|
|
394
|
+
const candidates = getTabbableCandidates(container, { omitLinks: false });
|
|
395
395
|
return [
|
|
396
396
|
findFirstVisible(candidates, container),
|
|
397
397
|
findFirstVisible(candidates.reverse(), container),
|
|
398
398
|
] as const;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
/**
|
|
402
|
-
* Returns a list of potential tabbable candidates.
|
|
403
|
-
* We do not take into account tabindex values.
|
|
404
|
-
*
|
|
405
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
406
|
-
* Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
|
|
407
|
-
*/
|
|
408
|
-
function getTabbableCandidates(container: HTMLElement) {
|
|
409
|
-
const nodes: HTMLElement[] = [];
|
|
410
|
-
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
411
|
-
acceptNode: (node: any) => {
|
|
412
|
-
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
413
|
-
if (node.disabled || node.hidden || isHiddenInput) {
|
|
414
|
-
return NodeFilter.FILTER_SKIP;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* `.tabIndex` is not the same as the `tabindex` attribute. It works on the
|
|
419
|
-
* runtime's understanding of tabbability, so this automatically accounts
|
|
420
|
-
* for any kind of element that could be tabbed to.
|
|
421
|
-
*/
|
|
422
|
-
return node.tabIndex >= 0
|
|
423
|
-
? NodeFilter.FILTER_ACCEPT
|
|
424
|
-
: NodeFilter.FILTER_SKIP;
|
|
425
|
-
},
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
while (walker.nextNode()) {
|
|
429
|
-
nodes.push(walker.currentNode as HTMLElement);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return nodes;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
401
|
/**
|
|
436
402
|
* Returns the first visible element in a list.
|
|
437
403
|
* NOTE: Only checks visibility up to the `container`.
|
|
@@ -462,39 +428,6 @@ function isHidden(node: HTMLElement, { upTo }: { upTo?: HTMLElement }) {
|
|
|
462
428
|
return false;
|
|
463
429
|
}
|
|
464
430
|
|
|
465
|
-
let rafId = 0;
|
|
466
|
-
function focus(
|
|
467
|
-
element?: HTMLElement | null,
|
|
468
|
-
{ select = false, preventScroll = true, sync = true } = {},
|
|
469
|
-
) {
|
|
470
|
-
if (!element?.focus) {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
const previouslyFocusedElement = document.activeElement;
|
|
475
|
-
|
|
476
|
-
cancelAnimationFrame(rafId);
|
|
477
|
-
const exec = () => element.focus({ preventScroll });
|
|
478
|
-
|
|
479
|
-
if (sync) {
|
|
480
|
-
exec();
|
|
481
|
-
} else {
|
|
482
|
-
rafId = requestAnimationFrame(exec);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
if (!select) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/* By default, inputs that gets focus should select its contents */
|
|
490
|
-
if (
|
|
491
|
-
element !== previouslyFocusedElement &&
|
|
492
|
-
element instanceof HTMLInputElement &&
|
|
493
|
-
"select" in element
|
|
494
|
-
)
|
|
495
|
-
element.select();
|
|
496
|
-
}
|
|
497
|
-
|
|
498
431
|
/* ---------------------------- FocusBoundary stack ---------------------------- */
|
|
499
432
|
type FocusBoundaryAPI = { paused: boolean; pause(): void; resume(): void };
|
|
500
433
|
const focusBoundarysStack = createFocusBoundarysStack();
|
|
@@ -531,10 +464,6 @@ function arrayRemove<T>(array: T[], item: T) {
|
|
|
531
464
|
return updatedArray;
|
|
532
465
|
}
|
|
533
466
|
|
|
534
|
-
function removeLinks(items: HTMLElement[]) {
|
|
535
|
-
return items.filter((item) => item.tagName !== "A");
|
|
536
|
-
}
|
|
537
|
-
|
|
538
467
|
const LIST_LIMIT = 10;
|
|
539
468
|
let previouslyFocusedElements: Element[] = [];
|
|
540
469
|
const focusedElementsByContainer = new WeakMap<Element, Element[]>();
|
|
@@ -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
|
{
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a list of potential tabbable candidates.
|
|
3
|
+
* We do not take into account tabindex values.
|
|
4
|
+
*
|
|
5
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
6
|
+
* Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
|
|
7
|
+
*/
|
|
8
|
+
function getTabbableCandidates(
|
|
9
|
+
container: HTMLElement,
|
|
10
|
+
{ omitLinks = true } = {},
|
|
11
|
+
) {
|
|
12
|
+
const nodes: HTMLElement[] = [];
|
|
13
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
14
|
+
acceptNode: (node: any) => {
|
|
15
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
16
|
+
if (node.disabled || node.hidden || isHiddenInput) {
|
|
17
|
+
return NodeFilter.FILTER_SKIP;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `.tabIndex` is not the same as the `tabindex` attribute. It works on the
|
|
22
|
+
* runtime's understanding of tabbability, so this automatically accounts
|
|
23
|
+
* for any kind of element that could be tabbed to.
|
|
24
|
+
*/
|
|
25
|
+
return node.tabIndex >= 0
|
|
26
|
+
? NodeFilter.FILTER_ACCEPT
|
|
27
|
+
: NodeFilter.FILTER_SKIP;
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
while (walker.nextNode()) {
|
|
32
|
+
nodes.push(walker.currentNode as HTMLElement);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return omitLinks ? removeLinks(nodes) : nodes;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function removeLinks(items: HTMLElement[]) {
|
|
39
|
+
return items.filter((item) => item.tagName !== "A");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let rafId = 0;
|
|
43
|
+
|
|
44
|
+
function focusElement(
|
|
45
|
+
element?: HTMLElement | null,
|
|
46
|
+
{ select = false, preventScroll = true, sync = true } = {},
|
|
47
|
+
) {
|
|
48
|
+
if (!element?.focus) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const previouslyFocusedElement = document.activeElement;
|
|
53
|
+
|
|
54
|
+
cancelAnimationFrame(rafId);
|
|
55
|
+
const exec = () => {
|
|
56
|
+
element.focus({ preventScroll });
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (sync) {
|
|
60
|
+
exec();
|
|
61
|
+
} else {
|
|
62
|
+
rafId = requestAnimationFrame(exec);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!select) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* By default, inputs that gets focus should select its contents */
|
|
70
|
+
if (
|
|
71
|
+
element !== previouslyFocusedElement &&
|
|
72
|
+
element instanceof HTMLInputElement &&
|
|
73
|
+
"select" in element
|
|
74
|
+
)
|
|
75
|
+
element.select();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { getTabbableCandidates, focusElement };
|
|
@@ -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";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
const maybeReactUseDeferredValue: undefined | ((string: string) => string) = (
|
|
4
|
+
React as any
|
|
5
|
+
)[
|
|
6
|
+
"useDeferredValue" + "" // Workaround for https://github.com/webpack/webpack/issues/14814
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
export const useDeferredValue = (value: string): string =>
|
|
10
|
+
maybeReactUseDeferredValue !== undefined
|
|
11
|
+
? maybeReactUseDeferredValue(value)
|
|
12
|
+
: value;
|