@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,54 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import DataDragAndDropItem, {
|
|
3
|
+
DataDragAndDropItemProps,
|
|
4
|
+
} from "../item/DataDragAndDropItem";
|
|
5
|
+
import { DataDragAndDropProvider } from "./DataDragAndDrop.context";
|
|
6
|
+
|
|
7
|
+
interface DataDragAndDropProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
children: any[];
|
|
9
|
+
setItems: React.Dispatch<React.SetStateAction<any[]>>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface DataDragAndDropRootComponent extends React.ForwardRefExoticComponent<
|
|
13
|
+
DataDragAndDropProps & React.RefAttributes<HTMLDivElement>
|
|
14
|
+
> {
|
|
15
|
+
/**
|
|
16
|
+
* @see 🏷️ {@link DataDragAndDropItemProps}
|
|
17
|
+
* * @example
|
|
18
|
+
* ```jsx
|
|
19
|
+
* <DragAndDrop>
|
|
20
|
+
* <DragAndDrop.Item id="1" index={0}>
|
|
21
|
+
* ...
|
|
22
|
+
* </DragAndDrop.Item>
|
|
23
|
+
* </DragAndDrop>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
Item: typeof DataDragAndDropItem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* TODO
|
|
31
|
+
* setItems on root
|
|
32
|
+
* state : active element
|
|
33
|
+
* pointer over listener / state, onPointerEnter, onPointerLeave
|
|
34
|
+
* Overlay - Use floating component
|
|
35
|
+
* Keyboard navigation
|
|
36
|
+
* Handle - button, arrows also button
|
|
37
|
+
* UU - announce on drag start, item moved, drag end
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const DataDragAndDrop = forwardRef<HTMLDivElement, DataDragAndDropProps>(
|
|
41
|
+
({ children }, forwardedRef) => {
|
|
42
|
+
return (
|
|
43
|
+
<DataDragAndDropProvider inputMethod={null}>
|
|
44
|
+
<div ref={forwardedRef}>{children}</div>
|
|
45
|
+
</DataDragAndDropProvider>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
) as DataDragAndDropRootComponent;
|
|
49
|
+
|
|
50
|
+
DataDragAndDrop.Item = DataDragAndDropItem;
|
|
51
|
+
|
|
52
|
+
export { DataDragAndDrop, DataDragAndDropItem };
|
|
53
|
+
export default DataDragAndDrop;
|
|
54
|
+
export type { DataDragAndDropItemProps, DataDragAndDropProps };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
CaretDownCircleFillIcon,
|
|
4
|
+
CaretUpCircleFillIcon,
|
|
5
|
+
DragVerticalIcon,
|
|
6
|
+
} from "@navikt/aksel-icons";
|
|
7
|
+
import { Floating } from "../../../utils/components/floating/Floating";
|
|
8
|
+
|
|
9
|
+
export interface DataDragAndDropDragHandlerProps {
|
|
10
|
+
/**
|
|
11
|
+
* Whether the drag handler is disabled
|
|
12
|
+
*/
|
|
13
|
+
// disabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Wether dragging is done by keyboard. Used to conditionally render drag indicators.
|
|
16
|
+
*/
|
|
17
|
+
keyboardDragging?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Handle ref is forwarded to the button element serving as drag handle.
|
|
20
|
+
*/
|
|
21
|
+
handleRef: React.Ref<HTMLDivElement>;
|
|
22
|
+
// Just for testing purposes, to render an alternative drag handler
|
|
23
|
+
alt?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* DataDragAndDropDragHandler
|
|
28
|
+
*
|
|
29
|
+
* A button component that serves as a drag handle for drag and drop operations.
|
|
30
|
+
* Can be used to initiate dragging of elements in a data table or list.
|
|
31
|
+
*/
|
|
32
|
+
export const DataDragAndDropDragHandler = React.forwardRef<
|
|
33
|
+
HTMLButtonElement,
|
|
34
|
+
DataDragAndDropDragHandlerProps
|
|
35
|
+
>(({ keyboardDragging, handleRef, alt }) => {
|
|
36
|
+
if (alt) {
|
|
37
|
+
return (
|
|
38
|
+
<div className="aksel-data-drag-and-drop__drag-handler__alt">
|
|
39
|
+
{keyboardDragging && (
|
|
40
|
+
<span
|
|
41
|
+
className="aksel-data-drag-and-drop__drag-handler__arrow"
|
|
42
|
+
data-direction="up"
|
|
43
|
+
>
|
|
44
|
+
<CaretUpCircleFillIcon aria-hidden fontSize="1.2rem" />
|
|
45
|
+
</span>
|
|
46
|
+
)}
|
|
47
|
+
<div
|
|
48
|
+
ref={handleRef}
|
|
49
|
+
className="aksel-data-drag-and-drop__drag-handler__button"
|
|
50
|
+
>
|
|
51
|
+
<DragVerticalIcon
|
|
52
|
+
aria-hidden
|
|
53
|
+
title="Dra for å flytte"
|
|
54
|
+
fontSize="1.5rem"
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
{keyboardDragging && (
|
|
58
|
+
<span
|
|
59
|
+
className="aksel-data-drag-and-drop__drag-handler__arrow"
|
|
60
|
+
data-direction="down"
|
|
61
|
+
>
|
|
62
|
+
<CaretDownCircleFillIcon aria-hidden fontSize="1.2rem" />
|
|
63
|
+
</span>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Floating>
|
|
71
|
+
{keyboardDragging && (
|
|
72
|
+
<Floating.Content
|
|
73
|
+
side="top"
|
|
74
|
+
avoidCollisions={false}
|
|
75
|
+
updatePositionStrategy="always"
|
|
76
|
+
className="aksel-data-drag-and-drop__drag-handler__arrow"
|
|
77
|
+
>
|
|
78
|
+
<CaretUpCircleFillIcon aria-hidden fontSize="1.2rem" />
|
|
79
|
+
</Floating.Content>
|
|
80
|
+
)}
|
|
81
|
+
<Floating.Anchor asChild>
|
|
82
|
+
<div
|
|
83
|
+
ref={handleRef}
|
|
84
|
+
className="aksel-data-drag-and-drop__drag-handler__button"
|
|
85
|
+
>
|
|
86
|
+
<DragVerticalIcon
|
|
87
|
+
aria-hidden
|
|
88
|
+
title="Dra for å flytte"
|
|
89
|
+
fontSize="1.5rem"
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</Floating.Anchor>
|
|
93
|
+
{keyboardDragging && (
|
|
94
|
+
<Floating.Content
|
|
95
|
+
avoidCollisions={false}
|
|
96
|
+
updatePositionStrategy="always"
|
|
97
|
+
className="aksel-data-drag-and-drop__drag-handler__arrow"
|
|
98
|
+
>
|
|
99
|
+
<CaretDownCircleFillIcon aria-hidden fontSize="1.2rem" />
|
|
100
|
+
</Floating.Content>
|
|
101
|
+
)}
|
|
102
|
+
</Floating>
|
|
103
|
+
);
|
|
104
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useSortable } from "@dnd-kit/react/sortable";
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
|
+
import { HStack } from "../../../primitives/stack";
|
|
4
|
+
import { cl } from "../../../utils/helpers";
|
|
5
|
+
import { useMergeRefs } from "../../../utils/hooks";
|
|
6
|
+
import { DataDragAndDropDragHandler } from "../drag-handler/DataDragAndDropDragHandler";
|
|
7
|
+
import { DataDragAndDropContext } from "../root/DataDragAndDrop.context";
|
|
8
|
+
|
|
9
|
+
interface DataDragAndDropItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Unique id
|
|
13
|
+
*/
|
|
14
|
+
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* Index of the item being dragged
|
|
17
|
+
*/
|
|
18
|
+
index: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* TODO
|
|
23
|
+
*
|
|
24
|
+
* @see 🏷️ {@link DataDragAndDropItemProps}
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <DragAndDrop.Item numOfSelectedRows={selectedRows.length} onClear={handleClear}>
|
|
28
|
+
* TODO
|
|
29
|
+
* </DragAndDrop.Item>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
const DataDragAndDropItem = React.forwardRef<
|
|
33
|
+
HTMLDivElement,
|
|
34
|
+
DataDragAndDropItemProps
|
|
35
|
+
>(({ children, id, index, className, ...rest }, forwardedRef) => {
|
|
36
|
+
const handleRef = useRef<HTMLDivElement>(null);
|
|
37
|
+
const { ref, isDragging, isDropTarget } = useSortable({
|
|
38
|
+
id,
|
|
39
|
+
index,
|
|
40
|
+
handle: handleRef,
|
|
41
|
+
});
|
|
42
|
+
const mergedRef = useMergeRefs(ref, forwardedRef);
|
|
43
|
+
const context = React.useContext(DataDragAndDropContext);
|
|
44
|
+
const mouseDragging = isDragging && context?.inputMethod === "mouse";
|
|
45
|
+
const mouseDropTarget = isDropTarget && context?.inputMethod === "mouse";
|
|
46
|
+
const keyboardDragging = isDragging && context?.inputMethod === "keyboard";
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<HStack gap="space-8" align="center" wrap={false} asChild>
|
|
50
|
+
{/* TODO Should this be a <li>? */}
|
|
51
|
+
<div
|
|
52
|
+
ref={mergedRef}
|
|
53
|
+
{...rest}
|
|
54
|
+
className={cl("aksel-data-table__drag-and-drop-item", className)}
|
|
55
|
+
data-dragging={isDragging}
|
|
56
|
+
data-mouse-dragging={mouseDragging}
|
|
57
|
+
data-keyboard-dragging={keyboardDragging}
|
|
58
|
+
data-drop-target={mouseDropTarget}
|
|
59
|
+
tabIndex={-1}
|
|
60
|
+
>
|
|
61
|
+
<DataDragAndDropDragHandler
|
|
62
|
+
handleRef={handleRef}
|
|
63
|
+
keyboardDragging={keyboardDragging}
|
|
64
|
+
alt
|
|
65
|
+
/>
|
|
66
|
+
<div>{children}</div>
|
|
67
|
+
</div>
|
|
68
|
+
</HStack>
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export default DataDragAndDropItem;
|
|
73
|
+
export { DataDragAndDropItem };
|
|
74
|
+
export type { DataDragAndDropItemProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
|
|
3
|
+
interface DataDragAndDropContextType {
|
|
4
|
+
inputMethod: "mouse" | "keyboard" | null;
|
|
5
|
+
// setInputMethod: (method: "mouse" | "keyboard" | null) => void;
|
|
6
|
+
// setItems: React.Dispatch<React.SetStateAction<any[]>>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const DataDragAndDropContext = createContext<
|
|
10
|
+
DataDragAndDropContextType | undefined
|
|
11
|
+
>(undefined);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { DragDropProvider, DragOverlay } from "@dnd-kit/react";
|
|
2
|
+
import { isSortable } from "@dnd-kit/react/sortable";
|
|
3
|
+
import React, { forwardRef, isValidElement } from "react";
|
|
4
|
+
import { VStack } from "../../../primitives/stack";
|
|
5
|
+
import DataDragAndDropItem, {
|
|
6
|
+
DataDragAndDropItemProps,
|
|
7
|
+
} from "../item/DataDragAndDropItem";
|
|
8
|
+
import { DataDragAndDropContext } from "./DataDragAndDrop.context";
|
|
9
|
+
|
|
10
|
+
interface DataDragAndDropProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
|
+
children: any[];
|
|
12
|
+
setItems: React.Dispatch<React.SetStateAction<any[]>>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface DataDragAndDropRootComponent extends React.ForwardRefExoticComponent<
|
|
16
|
+
DataDragAndDropProps & React.RefAttributes<HTMLDivElement>
|
|
17
|
+
> {
|
|
18
|
+
/**
|
|
19
|
+
* @see 🏷️ {@link DataDragAndDropItemProps}
|
|
20
|
+
* * @example
|
|
21
|
+
* ```jsx
|
|
22
|
+
* <DragAndDrop>
|
|
23
|
+
* <DragAndDrop.Item id="1" index={0}>
|
|
24
|
+
* ...
|
|
25
|
+
* </DragAndDrop.Item>
|
|
26
|
+
* </DragAndDrop>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
Item: typeof DataDragAndDropItem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const DataDragAndDrop = forwardRef<HTMLDivElement, DataDragAndDropProps>(
|
|
33
|
+
({ setItems, children, ...rest }, forwardedRef) => {
|
|
34
|
+
const [inputMethod, setInputMethod] = React.useState<
|
|
35
|
+
"mouse" | "keyboard" | null
|
|
36
|
+
>(null);
|
|
37
|
+
|
|
38
|
+
const setItemOrder = (initalIndex: number, targetIndex: number) => {
|
|
39
|
+
setItems((items) => {
|
|
40
|
+
const newItems = [...items];
|
|
41
|
+
const [movedItem] = newItems.splice(initalIndex, 1);
|
|
42
|
+
newItems.splice(targetIndex, 0, movedItem);
|
|
43
|
+
return newItems;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<DataDragAndDropContext.Provider value={{ inputMethod }}>
|
|
49
|
+
<DragDropProvider
|
|
50
|
+
// TODO Look into overriding default keybinds, might eliminate context need
|
|
51
|
+
onBeforeDragStart={(event) =>
|
|
52
|
+
setInputMethod(
|
|
53
|
+
event.operation.activatorEvent?.type === "pointerdown"
|
|
54
|
+
? "mouse"
|
|
55
|
+
: "keyboard",
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
onDragOver={(event) => {
|
|
59
|
+
if (event.operation.activatorEvent?.type === "pointerdown") {
|
|
60
|
+
// Prevents items to rearrange while dragging with mouse, but allows keyboard dragging to work as intended
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
}
|
|
63
|
+
}}
|
|
64
|
+
onDragEnd={(event) => {
|
|
65
|
+
const { source, target } = event.operation;
|
|
66
|
+
if (!isSortable(source) || !isSortable(target)) return;
|
|
67
|
+
setItemOrder(source.initialIndex, target.index);
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<VStack asChild gap="space-12">
|
|
71
|
+
<div {...rest} ref={forwardedRef}>
|
|
72
|
+
{children}
|
|
73
|
+
</div>
|
|
74
|
+
</VStack>
|
|
75
|
+
<DragOverlay dropAnimation={null}>
|
|
76
|
+
{(source) => {
|
|
77
|
+
// Overlay not needed and causes glitching when using keyboard
|
|
78
|
+
if (inputMethod === "keyboard") return null;
|
|
79
|
+
if (!isSortable(source)) return null;
|
|
80
|
+
if (isValidElement(children[source.initialIndex])) {
|
|
81
|
+
return children[source.initialIndex];
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}}
|
|
85
|
+
</DragOverlay>
|
|
86
|
+
</DragDropProvider>
|
|
87
|
+
</DataDragAndDropContext.Provider>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
) as DataDragAndDropRootComponent;
|
|
91
|
+
|
|
92
|
+
DataDragAndDrop.Item = DataDragAndDropItem;
|
|
93
|
+
|
|
94
|
+
export { DataDragAndDrop, DataDragAndDropItem };
|
|
95
|
+
export default DataDragAndDrop;
|
|
96
|
+
export type { DataDragAndDropItemProps, DataDragAndDropProps };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { cl } from "../../../utils/helpers";
|
|
3
|
+
|
|
4
|
+
type DataTableEmptyStateProps = React.HTMLAttributes<HTMLDivElement>;
|
|
5
|
+
|
|
6
|
+
const DataTableEmptyState = forwardRef<
|
|
7
|
+
HTMLDivElement,
|
|
8
|
+
DataTableEmptyStateProps
|
|
9
|
+
>(({ className, children, ...rest }, forwardedRef) => {
|
|
10
|
+
return (
|
|
11
|
+
<tr>
|
|
12
|
+
<td colSpan={999}>
|
|
13
|
+
<div
|
|
14
|
+
{...rest}
|
|
15
|
+
ref={forwardedRef}
|
|
16
|
+
className={cl("aksel-data-table__empty-state", className)}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
</td>
|
|
21
|
+
</tr>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { DataTableEmptyState };
|
|
26
|
+
export type { DataTableEmptyStateProps };
|
|
@@ -34,7 +34,11 @@ function restoreTabIndex(cell: Element): void {
|
|
|
34
34
|
*/
|
|
35
35
|
function findFocusableElementInCell(cell: Element): HTMLElement | null {
|
|
36
36
|
const el = cell as HTMLElement | null;
|
|
37
|
-
if (
|
|
37
|
+
if (
|
|
38
|
+
!el ||
|
|
39
|
+
isHiddenElement(el) ||
|
|
40
|
+
el.hasAttribute("data-block-keyboard-nav")
|
|
41
|
+
) {
|
|
38
42
|
return null;
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -48,6 +52,11 @@ function findFocusableElementInCell(cell: Element): HTMLElement | null {
|
|
|
48
52
|
|
|
49
53
|
for (let i = 0; i < focusables.length; i += 1) {
|
|
50
54
|
const focusable = focusables[i] as HTMLElement;
|
|
55
|
+
/* Ignore element if it has [data-block-keyboard-nav="true"] */
|
|
56
|
+
if (focusable.hasAttribute("data-block-keyboard-nav")) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
if (!isHiddenElement(focusable) && !isDisabledElement(focusable)) {
|
|
52
61
|
return focusable;
|
|
53
62
|
}
|
|
@@ -68,7 +68,7 @@ function shouldBlockNavigation(event: KeyboardEvent): boolean {
|
|
|
68
68
|
return true;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/* If not any of these elements,
|
|
71
|
+
/* If not any of these elements, assume "safe" to navigate */
|
|
72
72
|
const editable = el.closest(
|
|
73
73
|
'input, textarea, select, [contenteditable="true"]',
|
|
74
74
|
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { cl } from "../../../utils/helpers";
|
|
3
|
+
|
|
4
|
+
type DataTableLoadingStateProps = React.HTMLAttributes<HTMLDivElement>;
|
|
5
|
+
|
|
6
|
+
const DataTableLoadingState = forwardRef<
|
|
7
|
+
HTMLDivElement,
|
|
8
|
+
DataTableLoadingStateProps
|
|
9
|
+
>(({ className, children, ...rest }, forwardedRef) => {
|
|
10
|
+
return (
|
|
11
|
+
<tr>
|
|
12
|
+
<td colSpan={999}>
|
|
13
|
+
<div
|
|
14
|
+
{...rest}
|
|
15
|
+
ref={forwardedRef}
|
|
16
|
+
className={cl("aksel-data-table__loading-state", className)}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
</td>
|
|
21
|
+
</tr>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { DataTableLoadingState };
|
|
26
|
+
export type { DataTableLoadingStateProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type ColumnDefinition<T> = {
|
|
2
|
+
id?: string;
|
|
3
|
+
header: React.ReactNode;
|
|
4
|
+
width?: number | string;
|
|
5
|
+
minWidth?: number | string;
|
|
6
|
+
maxWidth?: number | string;
|
|
7
|
+
/* isRowHeader?: boolean; */
|
|
8
|
+
/**
|
|
9
|
+
* TODO: Could add table/row/cell context into callback
|
|
10
|
+
*/
|
|
11
|
+
cell: (item: T) => React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type ColumnDefinitions<T> = ColumnDefinition<T>[];
|
|
15
|
+
|
|
16
|
+
export type { ColumnDefinition, ColumnDefinitions };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import React, { forwardRef, useState } from "react";
|
|
2
|
+
import { Checkbox } from "../../../form/checkbox";
|
|
3
|
+
import { cl } from "../../../utils/helpers";
|
|
4
|
+
import { useMergeRefs } from "../../../utils/hooks";
|
|
5
|
+
import { DataTableTbody } from "../tbody/DataTableTbody";
|
|
6
|
+
import { DataTableTd } from "../td/DataTableTd";
|
|
7
|
+
import { DataTableTh } from "../th/DataTableTh";
|
|
8
|
+
import { DataTableThead } from "../thead/DataTableThead";
|
|
9
|
+
import { DataTableTr } from "../tr/DataTableTr";
|
|
10
|
+
import type { ColumnDefinitions } from "./DataTable.types";
|
|
11
|
+
import { DataTableContextProvider } from "./DataTableRoot.context";
|
|
12
|
+
import { useTableKeyboardNav } from "./useTableKeyboardNav";
|
|
13
|
+
import { type SelectionProps, useTableSelection } from "./useTableSelection";
|
|
14
|
+
|
|
15
|
+
interface DataTableProps<T>
|
|
16
|
+
extends React.HTMLAttributes<HTMLTableElement>, SelectionProps {
|
|
17
|
+
children?: never;
|
|
18
|
+
/**
|
|
19
|
+
* Controls vertical cell padding.
|
|
20
|
+
* @default "normal"
|
|
21
|
+
*/
|
|
22
|
+
rowDensity?: "condensed" | "normal" | "spacious";
|
|
23
|
+
/**
|
|
24
|
+
* Zebra striped table
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
zebraStripes?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Truncate content in cells and show ellipsis for overflowed text.
|
|
30
|
+
*
|
|
31
|
+
* **NB:** When using `layout="auto"`, you have to manually set a `maxWidth` on columns that should be truncated.
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
truncateContent?: boolean; // TODO: Consider making this default false when layout=auto, and maybe disallow it but add a wrap prop on the td-comp.
|
|
35
|
+
/**
|
|
36
|
+
* Enables keyboard navigation for table rows and cells.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
withKeyboardNav?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Custom callback to determine if navigation should be blocked.
|
|
42
|
+
* Called before default blocking logic.
|
|
43
|
+
* Requires `withKeyboardNav` to be `true`.
|
|
44
|
+
*/
|
|
45
|
+
shouldBlockNavigation?: (event: KeyboardEvent) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Controls table layout.
|
|
48
|
+
*
|
|
49
|
+
* ### fixed
|
|
50
|
+
* Gives you full control of column widths. This is required for resizable columns.
|
|
51
|
+
*
|
|
52
|
+
* ### auto
|
|
53
|
+
* Makes the columns resize automatically based on the content.
|
|
54
|
+
* The table will take up at least 100% of available width.
|
|
55
|
+
*
|
|
56
|
+
* **NB:** When using this with `truncateContent`, you have to manually
|
|
57
|
+
* set a `contentMaxWidth` on cells that should be truncated.
|
|
58
|
+
* @default "fixed"
|
|
59
|
+
*/
|
|
60
|
+
layout?: "fixed" | "auto";
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
columnDefinitions: ColumnDefinitions<T>;
|
|
65
|
+
data: (T & { id: string | number })[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function DataTableAutoInner<T>(
|
|
69
|
+
{
|
|
70
|
+
className,
|
|
71
|
+
rowDensity = "normal",
|
|
72
|
+
withKeyboardNav = false,
|
|
73
|
+
zebraStripes = false,
|
|
74
|
+
truncateContent = true,
|
|
75
|
+
shouldBlockNavigation,
|
|
76
|
+
layout = "fixed",
|
|
77
|
+
selectionMode: selectionModeProp = "none",
|
|
78
|
+
selectedKeys,
|
|
79
|
+
defaultSelectedKeys,
|
|
80
|
+
onSelectionChange,
|
|
81
|
+
disabledKeys = [],
|
|
82
|
+
data,
|
|
83
|
+
columnDefinitions,
|
|
84
|
+
...rest
|
|
85
|
+
}: DataTableProps<T>,
|
|
86
|
+
forwardedRef: React.ForwardedRef<HTMLTableElement>,
|
|
87
|
+
) {
|
|
88
|
+
const [tableRef, setTableRef] = useState<HTMLTableElement | null>(null);
|
|
89
|
+
const mergedRef = useMergeRefs(forwardedRef, setTableRef);
|
|
90
|
+
|
|
91
|
+
const { tabIndex } = useTableKeyboardNav(tableRef, {
|
|
92
|
+
enabled: withKeyboardNav,
|
|
93
|
+
shouldBlockNavigation,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const { getTheadCheckboxProps, selectionMode, getRowCheckboxProps } =
|
|
97
|
+
useTableSelection({
|
|
98
|
+
selectionMode: selectionModeProp,
|
|
99
|
+
selectedKeys,
|
|
100
|
+
defaultSelectedKeys,
|
|
101
|
+
onSelectionChange,
|
|
102
|
+
disabledKeys,
|
|
103
|
+
data,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<DataTableContextProvider layout={layout} withKeyboardNav={withKeyboardNav}>
|
|
108
|
+
<div className="aksel-data-table__border-wrapper">
|
|
109
|
+
<div className="aksel-data-table__scroll-wrapper">
|
|
110
|
+
<table
|
|
111
|
+
{...rest}
|
|
112
|
+
ref={mergedRef}
|
|
113
|
+
className={cl("aksel-data-table", className)}
|
|
114
|
+
data-zebra-stripes={zebraStripes}
|
|
115
|
+
data-truncate-content={truncateContent}
|
|
116
|
+
data-density={rowDensity}
|
|
117
|
+
data-layout={layout}
|
|
118
|
+
tabIndex={tabIndex}
|
|
119
|
+
>
|
|
120
|
+
<DataTableThead>
|
|
121
|
+
<DataTableTr>
|
|
122
|
+
{getTheadCheckboxProps && (
|
|
123
|
+
<DataTableTd align="center" width="60px">
|
|
124
|
+
<Checkbox {...getTheadCheckboxProps()} />
|
|
125
|
+
</DataTableTd>
|
|
126
|
+
)}
|
|
127
|
+
{columnDefinitions.map((colDef, colDefIndex) => {
|
|
128
|
+
return (
|
|
129
|
+
<DataTableTh
|
|
130
|
+
maxWidth="400px"
|
|
131
|
+
minWidth="100px"
|
|
132
|
+
defaultWidth="100%"
|
|
133
|
+
textAlign="left"
|
|
134
|
+
key={colDef.id || colDefIndex}
|
|
135
|
+
>
|
|
136
|
+
{colDef.header}
|
|
137
|
+
</DataTableTh>
|
|
138
|
+
);
|
|
139
|
+
})}
|
|
140
|
+
</DataTableTr>
|
|
141
|
+
</DataTableThead>
|
|
142
|
+
<DataTableTbody>
|
|
143
|
+
{data.map((rowData, rowIndex) => {
|
|
144
|
+
return (
|
|
145
|
+
<DataTableTr
|
|
146
|
+
key={
|
|
147
|
+
rowIndex /* TODO: Should be more flexible to allow user to define the key? */
|
|
148
|
+
}
|
|
149
|
+
>
|
|
150
|
+
{selectionMode !== "none" && getRowCheckboxProps && (
|
|
151
|
+
<DataTableTd align="center" width="60px">
|
|
152
|
+
<Checkbox {...getRowCheckboxProps(rowData.id)} />
|
|
153
|
+
</DataTableTd>
|
|
154
|
+
)}
|
|
155
|
+
{columnDefinitions.map((colDef, colDefIndex) => {
|
|
156
|
+
return (
|
|
157
|
+
<DataTableTd
|
|
158
|
+
textAlign="left"
|
|
159
|
+
key={colDef.id || colDefIndex}
|
|
160
|
+
>
|
|
161
|
+
{colDef.cell(rowData)}
|
|
162
|
+
</DataTableTd>
|
|
163
|
+
);
|
|
164
|
+
})}
|
|
165
|
+
</DataTableTr>
|
|
166
|
+
);
|
|
167
|
+
})}
|
|
168
|
+
</DataTableTbody>
|
|
169
|
+
</table>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
</DataTableContextProvider>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const DataTableAuto = forwardRef(DataTableAutoInner) as <T>(
|
|
177
|
+
props: DataTableProps<T> & React.RefAttributes<HTMLTableElement>,
|
|
178
|
+
) => React.ReactElement | null;
|
|
179
|
+
|
|
180
|
+
export { DataTableAuto };
|
|
181
|
+
export type { DataTableProps };
|
|
182
|
+
export default DataTableAuto;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createStrictContext } from "../../../utils/helpers";
|
|
2
|
+
|
|
3
|
+
type DataTableContextProps = {
|
|
4
|
+
layout: "fixed" | "auto";
|
|
5
|
+
withKeyboardNav: boolean;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const { Provider: DataTableContextProvider, useContext: useDataTableContext } =
|
|
9
|
+
createStrictContext<DataTableContextProps>({
|
|
10
|
+
name: "DataTableContext",
|
|
11
|
+
errorMessage: "useDataTableContext must be used within DataTable",
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { DataTableContextProvider, useDataTableContext };
|