@navikt/ds-react 8.7.0 → 8.9.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/DragAndDropDragHandler.d.ts +12 -0
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +57 -0
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -0
- package/cjs/data/drag-and-drop/item/DragAndDropItem.d.ts +27 -0
- package/cjs/data/drag-and-drop/item/DragAndDropItem.js +52 -0
- package/cjs/data/drag-and-drop/item/DragAndDropItem.js.map +1 -0
- package/cjs/data/drag-and-drop/root/DragAndDrop.context.d.ts +16 -0
- package/cjs/data/drag-and-drop/root/DragAndDrop.context.js +10 -0
- package/cjs/data/drag-and-drop/root/DragAndDrop.context.js.map +1 -0
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.d.ts +36 -0
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js +187 -0
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -0
- package/cjs/data/drag-and-drop/types.d.ts +4 -0
- package/cjs/data/drag-and-drop/types.js +3 -0
- package/cjs/data/drag-and-drop/types.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 → drag-and-drop-old}/item/DataDragAndDropItem.js +2 -7
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +1 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +1 -0
- package/cjs/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDropRoot.d.ts +2 -2
- package/cjs/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDropRoot.js +5 -8
- 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/selection/getMultipleSelectProps.d.ts +14 -0
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js +48 -0
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -0
- package/cjs/data/table/helpers/selection/getSingleSelectProps.d.ts +10 -0
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js +23 -0
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js.map +1 -0
- package/cjs/data/table/helpers/selection/selection.types.d.ts +42 -0
- package/cjs/data/table/helpers/selection/selection.types.js +3 -0
- package/cjs/data/table/helpers/selection/selection.types.js.map +1 -0
- package/cjs/data/table/helpers/table-focus.js +7 -1
- package/cjs/data/table/helpers/table-focus.js.map +1 -1
- package/cjs/data/table/helpers/table-keyboard.d.ts +0 -1
- package/cjs/data/table/helpers/table-keyboard.js +2 -4
- package/cjs/data/table/helpers/table-keyboard.js.map +1 -1
- package/cjs/data/table/{root → hooks}/useTableKeyboardNav.js +2 -1
- package/cjs/data/table/hooks/useTableKeyboardNav.js.map +1 -0
- package/cjs/data/table/hooks/useTableSelection.d.ts +8 -0
- package/cjs/data/table/hooks/useTableSelection.js +49 -0
- package/cjs/data/table/hooks/useTableSelection.js.map +1 -0
- 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 +113 -0
- package/cjs/data/table/root/DataTableAuto.js.map +1 -0
- package/cjs/data/table/root/DataTableRoot.context.d.ts +3 -2
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +30 -3
- package/cjs/data/table/root/DataTableRoot.js +9 -3
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/td/DataTableTd.d.ts +10 -0
- package/cjs/data/table/td/DataTableTd.js +4 -2
- package/cjs/data/table/td/DataTableTd.js.map +1 -1
- package/cjs/data/table/th/DataTableTh.d.ts +10 -4
- package/cjs/data/table/th/DataTableTh.js +24 -22
- package/cjs/data/table/th/DataTableTh.js.map +1 -1
- package/cjs/data/table/th/useTableColumnResize.d.ts +64 -0
- package/cjs/data/table/th/useTableColumnResize.js +144 -0
- package/cjs/data/table/th/useTableColumnResize.js.map +1 -0
- package/cjs/data/table/thead/DataTableThead.context.d.ts +4 -0
- package/cjs/data/table/thead/DataTableThead.context.js +45 -0
- package/cjs/data/table/thead/DataTableThead.context.js.map +1 -0
- package/cjs/data/table/thead/DataTableThead.js +3 -1
- package/cjs/data/table/thead/DataTableThead.js.map +1 -1
- package/cjs/data/table/tr/DataTableTr.js +4 -3
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/data/token-filter/AutoSuggest.js +40 -9
- package/cjs/data/token-filter/AutoSuggest.js.map +1 -1
- package/cjs/data/token-filter/TokenFilter.d.ts +1 -0
- package/cjs/data/token-filter/TokenFilter.js +1 -0
- package/cjs/data/token-filter/TokenFilter.js.map +1 -1
- package/cjs/data/toolbar/root/DataToolbarRoot.d.ts +6 -23
- package/cjs/data/toolbar/root/DataToolbarRoot.js +42 -7
- package/cjs/data/toolbar/root/DataToolbarRoot.js.map +1 -1
- package/cjs/date/Date.Input.js +8 -9
- package/cjs/date/Date.Input.js.map +1 -1
- package/cjs/date/datepicker/hooks/useDatepicker.d.ts +12 -1
- package/cjs/date/datepicker/hooks/useDatepicker.js +4 -3
- package/cjs/date/datepicker/hooks/useDatepicker.js.map +1 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.d.ts +11 -1
- package/cjs/date/monthpicker/hooks/useMonthPicker.js +3 -2
- package/cjs/date/monthpicker/hooks/useMonthPicker.js.map +1 -1
- package/cjs/form/checkbox/CheckboxGroup.js +1 -1
- package/cjs/form/checkbox/CheckboxGroup.js.map +1 -1
- package/cjs/form/fieldset/Fieldset.d.ts +25 -5
- package/cjs/form/fieldset/Fieldset.js +19 -2
- package/cjs/form/fieldset/Fieldset.js.map +1 -1
- package/cjs/form/radio/RadioGroup.js +1 -1
- package/cjs/form/radio/RadioGroup.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/internal-header/InternalHeaderButton.d.ts +5 -0
- package/cjs/internal-header/InternalHeaderButton.js +2 -2
- package/cjs/internal-header/InternalHeaderButton.js.map +1 -1
- package/cjs/read-more/ReadMore.d.ts +10 -0
- package/cjs/read-more/ReadMore.js +4 -6
- package/cjs/read-more/ReadMore.js.map +1 -1
- package/cjs/types/index.d.ts +1 -1
- package/cjs/types/index.js +0 -15
- package/cjs/types/index.js.map +1 -1
- package/cjs/utils/components/Listbox/group/ListboxGroup.js +2 -1
- package/cjs/utils/components/Listbox/group/ListboxGroup.js.map +1 -1
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.js +1 -1
- package/cjs/utils/components/Listbox/input-slot/ListboxInputSlot.js.map +1 -1
- package/cjs/utils/components/Listbox/option/ListboxOption.d.ts +24 -0
- package/cjs/utils/components/Listbox/{item/ListboxItem.js → option/ListboxOption.js} +8 -8
- package/cjs/utils/components/Listbox/option/ListboxOption.js.map +1 -0
- package/cjs/utils/components/Listbox/options/ListboxOptions.d.ts +8 -0
- package/cjs/utils/components/Listbox/{list/ListboxList.js → options/ListboxOptions.js} +8 -8
- package/cjs/utils/components/Listbox/options/ListboxOptions.js.map +1 -0
- package/cjs/utils/components/Listbox/root/ListboxRoot.d.ts +6 -6
- package/cjs/utils/components/Listbox/root/ListboxRoot.js +28 -28
- package/cjs/utils/components/Listbox/root/ListboxRoot.js.map +1 -1
- package/cjs/utils/components/Listbox/root/domHelpers.d.ts +3 -3
- package/cjs/utils/components/Listbox/root/domHelpers.js +8 -8
- package/cjs/utils/components/Listbox/root/domHelpers.js.map +1 -1
- package/cjs/utils/components/floating/Floating.d.ts +1 -1
- package/cjs/utils/components/floating/Floating.js +1 -1
- package/cjs/utils/components/floating/Floating.js.map +1 -1
- package/cjs/utils/components/focus-boundary/FocusBoundary.d.ts +0 -1
- package/cjs/utils/components/focus-boundary/FocusBoundary.js +1 -1
- package/cjs/utils/components/focus-boundary/FocusBoundary.js.map +1 -1
- package/cjs/utils/components/link-anchor/LinkAnchor.js +10 -0
- package/cjs/utils/components/link-anchor/LinkAnchor.js.map +1 -1
- package/cjs/utils/helpers/className.js +1 -1
- package/cjs/utils/helpers/className.js.map +1 -1
- package/cjs/utils/helpers/focus.d.ts +3 -1
- package/cjs/utils/helpers/focus.js +2 -2
- package/cjs/utils/helpers/focus.js.map +1 -1
- package/cjs/utils/helpers/index.d.ts +9 -9
- package/cjs/utils/helpers/index.js +22 -23
- package/cjs/utils/helpers/index.js.map +1 -1
- package/cjs/utils/hooks/index.d.ts +13 -13
- package/cjs/utils/hooks/index.js +31 -28
- package/cjs/utils/hooks/index.js.map +1 -1
- package/cjs/utils/hooks/useScrollLock.js +41 -11
- package/cjs/utils/hooks/useScrollLock.js.map +1 -1
- package/esm/alert/base-alert/root/BaseAlertRoot.js +1 -2
- package/esm/alert/base-alert/root/BaseAlertRoot.js.map +1 -1
- package/esm/alert/info-card/index.d.ts +2 -2
- package/esm/alert/info-card/index.js +1 -1
- package/esm/alert/info-card/index.js.map +1 -1
- package/esm/alert/info-card/message/InfoCardMessage.d.ts +23 -0
- package/esm/alert/info-card/message/InfoCardMessage.js +37 -0
- package/esm/alert/info-card/message/InfoCardMessage.js.map +1 -0
- package/esm/alert/info-card/root/InfoCardRoot.d.ts +15 -2
- package/esm/alert/info-card/root/InfoCardRoot.js +3 -1
- package/esm/alert/info-card/root/InfoCardRoot.js.map +1 -1
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.d.ts +12 -0
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +51 -0
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -0
- package/esm/data/drag-and-drop/item/DragAndDropItem.d.ts +27 -0
- package/esm/data/drag-and-drop/item/DragAndDropItem.js +46 -0
- package/esm/data/drag-and-drop/item/DragAndDropItem.js.map +1 -0
- package/esm/data/drag-and-drop/root/DragAndDrop.context.d.ts +16 -0
- package/esm/data/drag-and-drop/root/DragAndDrop.context.js +6 -0
- package/esm/data/drag-and-drop/root/DragAndDrop.context.js.map +1 -0
- package/esm/data/drag-and-drop/root/DragAndDropRoot.d.ts +36 -0
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js +147 -0
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -0
- package/esm/data/drag-and-drop/types.d.ts +4 -0
- package/esm/data/drag-and-drop/types.js +2 -0
- package/esm/data/drag-and-drop/types.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 → drag-and-drop-old}/item/DataDragAndDropItem.js +2 -7
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +1 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +1 -0
- package/esm/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDropRoot.d.ts +2 -2
- package/esm/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDropRoot.js +5 -8
- 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/selection/getMultipleSelectProps.d.ts +14 -0
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js +46 -0
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -0
- package/esm/data/table/helpers/selection/getSingleSelectProps.d.ts +10 -0
- package/esm/data/table/helpers/selection/getSingleSelectProps.js +21 -0
- package/esm/data/table/helpers/selection/getSingleSelectProps.js.map +1 -0
- package/esm/data/table/helpers/selection/selection.types.d.ts +42 -0
- package/esm/data/table/helpers/selection/selection.types.js +2 -0
- package/esm/data/table/helpers/selection/selection.types.js.map +1 -0
- package/esm/data/table/helpers/table-focus.js +7 -1
- package/esm/data/table/helpers/table-focus.js.map +1 -1
- package/esm/data/table/helpers/table-keyboard.d.ts +0 -1
- package/esm/data/table/helpers/table-keyboard.js +2 -4
- package/esm/data/table/helpers/table-keyboard.js.map +1 -1
- package/esm/data/table/{root → hooks}/useTableKeyboardNav.js +2 -1
- package/esm/data/table/hooks/useTableKeyboardNav.js.map +1 -0
- package/esm/data/table/hooks/useTableSelection.d.ts +8 -0
- package/esm/data/table/hooks/useTableSelection.js +47 -0
- package/esm/data/table/hooks/useTableSelection.js.map +1 -0
- 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 +77 -0
- package/esm/data/table/root/DataTableAuto.js.map +1 -0
- package/esm/data/table/root/DataTableRoot.context.d.ts +3 -2
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.d.ts +30 -3
- package/esm/data/table/root/DataTableRoot.js +7 -3
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/td/DataTableTd.d.ts +10 -0
- package/esm/data/table/td/DataTableTd.js +4 -2
- package/esm/data/table/td/DataTableTd.js.map +1 -1
- package/esm/data/table/th/DataTableTh.d.ts +10 -4
- package/esm/data/table/th/DataTableTh.js +25 -23
- package/esm/data/table/th/DataTableTh.js.map +1 -1
- package/esm/data/table/th/useTableColumnResize.d.ts +64 -0
- package/esm/data/table/th/useTableColumnResize.js +142 -0
- package/esm/data/table/th/useTableColumnResize.js.map +1 -0
- package/esm/data/table/thead/DataTableThead.context.d.ts +4 -0
- package/esm/data/table/thead/DataTableThead.context.js +8 -0
- package/esm/data/table/thead/DataTableThead.context.js.map +1 -0
- package/esm/data/table/thead/DataTableThead.js +3 -1
- package/esm/data/table/thead/DataTableThead.js.map +1 -1
- package/esm/data/table/tr/DataTableTr.js +4 -3
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/data/token-filter/AutoSuggest.js +41 -10
- package/esm/data/token-filter/AutoSuggest.js.map +1 -1
- package/esm/data/token-filter/TokenFilter.d.ts +1 -0
- package/esm/data/token-filter/TokenFilter.js +1 -0
- package/esm/data/token-filter/TokenFilter.js.map +1 -1
- package/esm/data/toolbar/root/DataToolbarRoot.d.ts +6 -23
- package/esm/data/toolbar/root/DataToolbarRoot.js +9 -7
- package/esm/data/toolbar/root/DataToolbarRoot.js.map +1 -1
- package/esm/date/Date.Input.js +9 -10
- package/esm/date/Date.Input.js.map +1 -1
- package/esm/date/datepicker/hooks/useDatepicker.d.ts +12 -1
- package/esm/date/datepicker/hooks/useDatepicker.js +4 -3
- package/esm/date/datepicker/hooks/useDatepicker.js.map +1 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.d.ts +11 -1
- package/esm/date/monthpicker/hooks/useMonthPicker.js +3 -2
- package/esm/date/monthpicker/hooks/useMonthPicker.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.js +1 -1
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/fieldset/Fieldset.d.ts +25 -5
- package/esm/form/fieldset/Fieldset.js +19 -2
- package/esm/form/fieldset/Fieldset.js.map +1 -1
- package/esm/form/radio/RadioGroup.js +1 -1
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js.map +1 -1
- package/esm/internal-header/InternalHeaderButton.d.ts +5 -0
- package/esm/internal-header/InternalHeaderButton.js +2 -2
- package/esm/internal-header/InternalHeaderButton.js.map +1 -1
- package/esm/read-more/ReadMore.d.ts +10 -0
- package/esm/read-more/ReadMore.js +4 -6
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/types/index.d.ts +1 -1
- package/esm/types/index.js +1 -1
- package/esm/types/index.js.map +1 -1
- package/esm/utils/components/Listbox/group/ListboxGroup.js +2 -1
- package/esm/utils/components/Listbox/group/ListboxGroup.js.map +1 -1
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.js +1 -1
- package/esm/utils/components/Listbox/input-slot/ListboxInputSlot.js.map +1 -1
- package/esm/utils/components/Listbox/option/ListboxOption.d.ts +24 -0
- package/esm/utils/components/Listbox/{item/ListboxItem.js → option/ListboxOption.js} +7 -7
- package/esm/utils/components/Listbox/option/ListboxOption.js.map +1 -0
- package/esm/utils/components/Listbox/options/ListboxOptions.d.ts +8 -0
- package/esm/utils/components/Listbox/{list/ListboxList.js → options/ListboxOptions.js} +8 -8
- package/esm/utils/components/Listbox/options/ListboxOptions.js.map +1 -0
- package/esm/utils/components/Listbox/root/ListboxRoot.d.ts +6 -6
- package/esm/utils/components/Listbox/root/ListboxRoot.js +29 -29
- package/esm/utils/components/Listbox/root/ListboxRoot.js.map +1 -1
- package/esm/utils/components/Listbox/root/domHelpers.d.ts +3 -3
- package/esm/utils/components/Listbox/root/domHelpers.js +7 -7
- package/esm/utils/components/Listbox/root/domHelpers.js.map +1 -1
- package/esm/utils/components/floating/Floating.d.ts +1 -1
- package/esm/utils/components/floating/Floating.js +1 -1
- package/esm/utils/components/floating/Floating.js.map +1 -1
- package/esm/utils/components/focus-boundary/FocusBoundary.d.ts +0 -1
- package/esm/utils/components/focus-boundary/FocusBoundary.js +1 -1
- package/esm/utils/components/focus-boundary/FocusBoundary.js.map +1 -1
- package/esm/utils/components/link-anchor/LinkAnchor.js +10 -0
- package/esm/utils/components/link-anchor/LinkAnchor.js.map +1 -1
- package/esm/utils/helpers/className.js +1 -1
- package/esm/utils/helpers/className.js.map +1 -1
- package/esm/utils/helpers/focus.d.ts +3 -1
- package/esm/utils/helpers/focus.js +2 -2
- package/esm/utils/helpers/focus.js.map +1 -1
- package/esm/utils/helpers/index.d.ts +9 -9
- package/esm/utils/helpers/index.js +9 -9
- package/esm/utils/helpers/index.js.map +1 -1
- package/esm/utils/hooks/index.d.ts +13 -13
- package/esm/utils/hooks/index.js +13 -13
- package/esm/utils/hooks/index.js.map +1 -1
- package/esm/utils/hooks/useScrollLock.js +41 -11
- package/esm/utils/hooks/useScrollLock.js.map +1 -1
- package/package.json +6 -6
- 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/DragAndDropDragHandler.tsx +90 -0
- package/src/data/drag-and-drop/item/DragAndDropItem.tsx +71 -0
- package/src/data/drag-and-drop/root/DragAndDrop.context.tsx +25 -0
- package/src/data/drag-and-drop/root/DragAndDropRoot.tsx +245 -0
- package/src/data/drag-and-drop/types.ts +4 -0
- package/src/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.tsx +104 -0
- package/src/data/{drag-and-drop → drag-and-drop-old}/item/DataDragAndDropItem.tsx +6 -33
- package/src/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDrop.context.tsx +2 -0
- package/src/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDropRoot.tsx +6 -8
- package/src/data/table/empty-state/DataTableEmptyState.tsx +26 -0
- package/src/data/table/helpers/selection/getMultipleSelectProps.ts +70 -0
- package/src/data/table/helpers/selection/getSingleSelectProps.ts +33 -0
- package/src/data/table/helpers/selection/selection.types.ts +56 -0
- package/src/data/table/helpers/table-focus.ts +10 -1
- package/src/data/table/helpers/table-keyboard.ts +2 -6
- package/src/data/table/hooks/__tests__/useTableSelection.test.ts +327 -0
- package/src/data/table/{root → hooks}/useTableKeyboardNav.ts +2 -1
- package/src/data/table/hooks/useTableSelection.ts +78 -0
- 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 +205 -0
- package/src/data/table/root/DataTableRoot.context.ts +3 -2
- package/src/data/table/root/DataTableRoot.tsx +46 -3
- package/src/data/table/td/DataTableTd.tsx +14 -1
- package/src/data/table/th/DataTableTh.tsx +48 -36
- package/src/data/table/th/useTableColumnResize.ts +276 -0
- package/src/data/table/thead/DataTableThead.context.ts +10 -0
- package/src/data/table/thead/DataTableThead.tsx +8 -5
- package/src/data/table/tr/DataTableTr.tsx +8 -3
- package/src/data/token-filter/AutoSuggest.tsx +76 -15
- package/src/data/token-filter/TokenFilter.tsx +1 -0
- package/src/data/toolbar/root/DataToolbarRoot.tsx +29 -32
- package/src/date/Date.Input.tsx +18 -17
- package/src/date/datepicker/hooks/useDatepicker.tsx +16 -6
- package/src/date/monthpicker/hooks/useMonthPicker.tsx +14 -5
- package/src/form/checkbox/CheckboxGroup.tsx +1 -1
- package/src/form/fieldset/Fieldset.tsx +31 -7
- package/src/form/radio/RadioGroup.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/internal-header/InternalHeaderButton.tsx +18 -9
- package/src/read-more/ReadMore.tsx +15 -16
- package/src/types/index.ts +1 -1
- package/src/utils/components/Listbox/group/ListboxGroup.tsx +9 -2
- package/src/utils/components/Listbox/input-slot/ListboxInputSlot.tsx +1 -1
- package/src/utils/components/Listbox/{item/ListboxItem.tsx → option/ListboxOption.tsx} +14 -14
- package/src/utils/components/Listbox/{list/ListboxList.tsx → options/ListboxOptions.tsx} +10 -10
- package/src/utils/components/Listbox/root/ListboxRoot.tsx +31 -31
- package/src/utils/components/Listbox/root/domHelpers.ts +8 -7
- package/src/utils/components/floating/Floating.tsx +2 -2
- package/src/utils/components/focus-boundary/FocusBoundary.tsx +1 -2
- package/src/utils/components/link-anchor/LinkAnchor.tsx +11 -0
- package/src/utils/helpers/className.ts +1 -1
- package/src/utils/helpers/focus.ts +5 -2
- package/src/utils/helpers/index.ts +9 -9
- package/src/utils/hooks/index.ts +20 -13
- package/src/utils/hooks/useScrollLock.ts +57 -13
- package/cjs/data/action-bar/root/DataActionBarRoot.d.ts +0 -27
- package/cjs/data/action-bar/root/DataActionBarRoot.js +0 -49
- package/cjs/data/action-bar/root/DataActionBarRoot.js.map +0 -1
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js.map +0 -1
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js.map +0 -1
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js.map +0 -1
- package/cjs/data/table/root/useTableKeyboardNav.js.map +0 -1
- package/cjs/utils/components/Listbox/item/ListboxItem.d.ts +0 -24
- package/cjs/utils/components/Listbox/item/ListboxItem.js.map +0 -1
- package/cjs/utils/components/Listbox/list/ListboxList.d.ts +0 -8
- package/cjs/utils/components/Listbox/list/ListboxList.js.map +0 -1
- package/esm/data/action-bar/root/DataActionBarRoot.d.ts +0 -27
- package/esm/data/action-bar/root/DataActionBarRoot.js +0 -43
- package/esm/data/action-bar/root/DataActionBarRoot.js.map +0 -1
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js.map +0 -1
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js.map +0 -1
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js.map +0 -1
- package/esm/data/table/root/useTableKeyboardNav.js.map +0 -1
- package/esm/utils/components/Listbox/item/ListboxItem.d.ts +0 -24
- package/esm/utils/components/Listbox/item/ListboxItem.js.map +0 -1
- package/esm/utils/components/Listbox/list/ListboxList.d.ts +0 -8
- package/esm/utils/components/Listbox/list/ListboxList.js.map +0 -1
- package/src/data/action-bar/root/DataActionBarRoot.tsx +0 -59
- /package/cjs/data/{drag-and-drop → drag-and-drop-old}/item/DataDragAndDropItem.d.ts +0 -0
- /package/cjs/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDrop.context.d.ts +0 -0
- /package/cjs/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDrop.context.js +0 -0
- /package/cjs/data/table/{root → hooks}/useTableKeyboardNav.d.ts +0 -0
- /package/esm/data/{drag-and-drop → drag-and-drop-old}/item/DataDragAndDropItem.d.ts +0 -0
- /package/esm/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDrop.context.d.ts +0 -0
- /package/esm/data/{drag-and-drop → drag-and-drop-old}/root/DataDragAndDrop.context.js +0 -0
- /package/esm/data/table/{root → hooks}/useTableKeyboardNav.d.ts +0 -0
|
@@ -52,7 +52,6 @@ function getNavigationAction(event: KeyboardEvent): NavigationAction | null {
|
|
|
52
52
|
* - Select arrow down/up for opening popup
|
|
53
53
|
* - User is navigating inside multiline textarea
|
|
54
54
|
* - contenteditable attrb is in use
|
|
55
|
-
* - element has attribute data-block-keyboard-nav="true"
|
|
56
55
|
*/
|
|
57
56
|
function shouldBlockNavigation(event: KeyboardEvent): boolean {
|
|
58
57
|
const key = event.key;
|
|
@@ -71,7 +70,7 @@ function shouldBlockNavigation(event: KeyboardEvent): boolean {
|
|
|
71
70
|
|
|
72
71
|
/* If not any of these elements, assume "safe" to navigate */
|
|
73
72
|
const editable = el.closest(
|
|
74
|
-
'input, textarea, select, [contenteditable="true"]
|
|
73
|
+
'input, textarea, select, [contenteditable="true"]',
|
|
75
74
|
);
|
|
76
75
|
|
|
77
76
|
if (!editable) {
|
|
@@ -93,10 +92,7 @@ function shouldBlockNavigation(event: KeyboardEvent): boolean {
|
|
|
93
92
|
return false;
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
return (
|
|
97
|
-
editable.hasAttribute("contenteditable") ||
|
|
98
|
-
editable.hasAttribute("data-block-keyboard-nav")
|
|
99
|
-
);
|
|
95
|
+
return editable.hasAttribute("contenteditable");
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
function shouldBlockInputArrow(input: HTMLInputElement, key: string): boolean {
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { act, renderHook } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, test, vi } from "vitest";
|
|
3
|
+
import type {
|
|
4
|
+
MultipleSelection,
|
|
5
|
+
SingleSelection,
|
|
6
|
+
} from "../../helpers/selection/selection.types";
|
|
7
|
+
import { useTableSelection } from "../useTableSelection";
|
|
8
|
+
|
|
9
|
+
type Item = { id: string; name: string };
|
|
10
|
+
|
|
11
|
+
const items: Item[] = [
|
|
12
|
+
{ id: "a", name: "Alpha" },
|
|
13
|
+
{ id: "b", name: "Beta" },
|
|
14
|
+
{ id: "c", name: "Charlie" },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const getRowId = (item: Item) => item.id;
|
|
18
|
+
|
|
19
|
+
function asSingle(
|
|
20
|
+
result: ReturnType<typeof renderHook>["result"],
|
|
21
|
+
): SingleSelection {
|
|
22
|
+
return result.current as SingleSelection;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function asMultiple(
|
|
26
|
+
result: ReturnType<typeof renderHook>["result"],
|
|
27
|
+
): MultipleSelection {
|
|
28
|
+
return result.current as MultipleSelection;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe("useTableSelection", () => {
|
|
32
|
+
describe('selectionMode="none"', () => {
|
|
33
|
+
test("returns empty selectedKeys and no prop getters", () => {
|
|
34
|
+
const { result } = renderHook(() =>
|
|
35
|
+
useTableSelection({
|
|
36
|
+
selectionMode: "none",
|
|
37
|
+
data: items,
|
|
38
|
+
getRowId,
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(result.current.selectionMode).toBe("none");
|
|
43
|
+
expect(result.current.selectedKeys).toEqual([]);
|
|
44
|
+
expect(result.current.allKeys).toEqual(["a", "b", "c"]);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('selectionMode="single"', () => {
|
|
49
|
+
test("returns getRowRadioProps", () => {
|
|
50
|
+
const { result } = renderHook(() =>
|
|
51
|
+
useTableSelection({
|
|
52
|
+
selectionMode: "single",
|
|
53
|
+
data: items,
|
|
54
|
+
getRowId,
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(result.current.selectionMode).toBe("single");
|
|
59
|
+
expect(asSingle(result).getRowRadioProps).toBeDefined();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("selecting a row via radio onChange", () => {
|
|
63
|
+
const onChange = vi.fn();
|
|
64
|
+
const { result } = renderHook(() =>
|
|
65
|
+
useTableSelection({
|
|
66
|
+
selectionMode: "single",
|
|
67
|
+
data: items,
|
|
68
|
+
getRowId,
|
|
69
|
+
onSelectionChange: onChange,
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const radioProps = asSingle(result).getRowRadioProps("a");
|
|
74
|
+
expect(radioProps.checked).toBe(false);
|
|
75
|
+
|
|
76
|
+
act(() => {
|
|
77
|
+
radioProps.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(asSingle(result).selectedKeys).toEqual(["a"]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("toggling the same row deselects it", () => {
|
|
84
|
+
const { result } = renderHook(() =>
|
|
85
|
+
useTableSelection({
|
|
86
|
+
selectionMode: "single",
|
|
87
|
+
data: items,
|
|
88
|
+
getRowId,
|
|
89
|
+
defaultSelectedKeys: ["a"],
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
act(() => {
|
|
94
|
+
asSingle(result)
|
|
95
|
+
.getRowRadioProps("a")
|
|
96
|
+
.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(asSingle(result).selectedKeys).toEqual([]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("selecting a new row replaces the previous", () => {
|
|
103
|
+
const { result } = renderHook(() =>
|
|
104
|
+
useTableSelection({
|
|
105
|
+
selectionMode: "single",
|
|
106
|
+
data: items,
|
|
107
|
+
getRowId,
|
|
108
|
+
defaultSelectedKeys: ["a"],
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
act(() => {
|
|
113
|
+
asSingle(result)
|
|
114
|
+
.getRowRadioProps("b")
|
|
115
|
+
.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(asSingle(result).selectedKeys).toEqual(["b"]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("disabled rows have disabled prop", () => {
|
|
122
|
+
const { result } = renderHook(() =>
|
|
123
|
+
useTableSelection({
|
|
124
|
+
selectionMode: "single",
|
|
125
|
+
data: items,
|
|
126
|
+
getRowId,
|
|
127
|
+
disabledKeys: ["b"],
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
expect(asSingle(result).getRowRadioProps("a").disabled).toBe(false);
|
|
132
|
+
expect(asSingle(result).getRowRadioProps("b").disabled).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("controlled selectedKeys", () => {
|
|
136
|
+
const { result, rerender } = renderHook(
|
|
137
|
+
({ selectedKeys }) =>
|
|
138
|
+
useTableSelection({
|
|
139
|
+
selectionMode: "single",
|
|
140
|
+
data: items,
|
|
141
|
+
getRowId,
|
|
142
|
+
selectedKeys,
|
|
143
|
+
}),
|
|
144
|
+
{ initialProps: { selectedKeys: ["a"] as (string | number)[] } },
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
expect(asSingle(result).selectedKeys).toEqual(["a"]);
|
|
148
|
+
|
|
149
|
+
rerender({ selectedKeys: ["b"] });
|
|
150
|
+
expect(asSingle(result).selectedKeys).toEqual(["b"]);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('selectionMode="multiple"', () => {
|
|
155
|
+
test("returns getTheadCheckboxProps and getRowCheckboxProps", () => {
|
|
156
|
+
const { result } = renderHook(() =>
|
|
157
|
+
useTableSelection({
|
|
158
|
+
selectionMode: "multiple",
|
|
159
|
+
data: items,
|
|
160
|
+
getRowId,
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
expect(result.current.selectionMode).toBe("multiple");
|
|
165
|
+
expect(asMultiple(result).getTheadCheckboxProps).toBeDefined();
|
|
166
|
+
expect(asMultiple(result).getRowCheckboxProps).toBeDefined();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("selecting individual rows", () => {
|
|
170
|
+
const { result } = renderHook(() =>
|
|
171
|
+
useTableSelection({
|
|
172
|
+
selectionMode: "multiple",
|
|
173
|
+
data: items,
|
|
174
|
+
getRowId,
|
|
175
|
+
}),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
act(() => {
|
|
179
|
+
asMultiple(result)
|
|
180
|
+
.getRowCheckboxProps("a")
|
|
181
|
+
.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
expect(asMultiple(result).selectedKeys).toEqual(["a"]);
|
|
185
|
+
|
|
186
|
+
act(() => {
|
|
187
|
+
asMultiple(result)
|
|
188
|
+
.getRowCheckboxProps("c")
|
|
189
|
+
.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
expect(asMultiple(result).selectedKeys).toEqual(["a", "c"]);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("deselecting a row", () => {
|
|
196
|
+
const { result } = renderHook(() =>
|
|
197
|
+
useTableSelection({
|
|
198
|
+
selectionMode: "multiple",
|
|
199
|
+
data: items,
|
|
200
|
+
getRowId,
|
|
201
|
+
defaultSelectedKeys: ["a", "b"],
|
|
202
|
+
}),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
act(() => {
|
|
206
|
+
asMultiple(result)
|
|
207
|
+
.getRowCheckboxProps("a")
|
|
208
|
+
.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(asMultiple(result).selectedKeys).toEqual(["b"]);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("select all via thead checkbox", () => {
|
|
215
|
+
const { result } = renderHook(() =>
|
|
216
|
+
useTableSelection({
|
|
217
|
+
selectionMode: "multiple",
|
|
218
|
+
data: items,
|
|
219
|
+
getRowId,
|
|
220
|
+
}),
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
act(() => {
|
|
224
|
+
asMultiple(result)
|
|
225
|
+
.getTheadCheckboxProps()
|
|
226
|
+
.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
expect(asMultiple(result).selectedKeys).toEqual(["a", "b", "c"]);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("deselect all when all are selected", () => {
|
|
233
|
+
const { result } = renderHook(() =>
|
|
234
|
+
useTableSelection({
|
|
235
|
+
selectionMode: "multiple",
|
|
236
|
+
data: items,
|
|
237
|
+
getRowId,
|
|
238
|
+
defaultSelectedKeys: ["a", "b", "c"],
|
|
239
|
+
}),
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
act(() => {
|
|
243
|
+
asMultiple(result)
|
|
244
|
+
.getTheadCheckboxProps()
|
|
245
|
+
.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
expect(asMultiple(result).selectedKeys).toEqual([]);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
test("thead checkbox shows indeterminate when partially selected", () => {
|
|
252
|
+
const { result } = renderHook(() =>
|
|
253
|
+
useTableSelection({
|
|
254
|
+
selectionMode: "multiple",
|
|
255
|
+
data: items,
|
|
256
|
+
getRowId,
|
|
257
|
+
defaultSelectedKeys: ["a"],
|
|
258
|
+
}),
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
const theadProps = asMultiple(result).getTheadCheckboxProps();
|
|
262
|
+
expect(theadProps.indeterminate).toBe(true);
|
|
263
|
+
expect(theadProps.checked).toBe(false);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test("thead checkbox shows checked when all selected", () => {
|
|
267
|
+
const { result } = renderHook(() =>
|
|
268
|
+
useTableSelection({
|
|
269
|
+
selectionMode: "multiple",
|
|
270
|
+
data: items,
|
|
271
|
+
getRowId,
|
|
272
|
+
defaultSelectedKeys: ["a", "b", "c"],
|
|
273
|
+
}),
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
const theadProps = asMultiple(result).getTheadCheckboxProps();
|
|
277
|
+
expect(theadProps.indeterminate).toBe(false);
|
|
278
|
+
expect(theadProps.checked).toBe(true);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("deselecting one row when selectedKeys is 'all'", () => {
|
|
282
|
+
const { result } = renderHook(() =>
|
|
283
|
+
useTableSelection({
|
|
284
|
+
selectionMode: "multiple",
|
|
285
|
+
data: items,
|
|
286
|
+
getRowId,
|
|
287
|
+
defaultSelectedKeys: "all",
|
|
288
|
+
}),
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
act(() => {
|
|
292
|
+
asMultiple(result)
|
|
293
|
+
.getRowCheckboxProps("b")
|
|
294
|
+
.onChange?.({} as React.ChangeEvent<HTMLInputElement>);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
expect(asMultiple(result).selectedKeys).toEqual(["a", "c"]);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test("disabled rows have disabled prop", () => {
|
|
301
|
+
const { result } = renderHook(() =>
|
|
302
|
+
useTableSelection({
|
|
303
|
+
selectionMode: "multiple",
|
|
304
|
+
data: items,
|
|
305
|
+
getRowId,
|
|
306
|
+
disabledKeys: ["b"],
|
|
307
|
+
}),
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
expect(asMultiple(result).getRowCheckboxProps("a").disabled).toBe(false);
|
|
311
|
+
expect(asMultiple(result).getRowCheckboxProps("b").disabled).toBe(true);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
test("thead checkbox disabled when all rows disabled", () => {
|
|
315
|
+
const { result } = renderHook(() =>
|
|
316
|
+
useTableSelection({
|
|
317
|
+
selectionMode: "multiple",
|
|
318
|
+
data: items,
|
|
319
|
+
getRowId,
|
|
320
|
+
disabledKeys: ["a", "b", "c"],
|
|
321
|
+
}),
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
expect(asMultiple(result).getTheadCheckboxProps().disabled).toBe(true);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
});
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
getNavigationAction,
|
|
15
15
|
shouldBlockNavigation,
|
|
16
16
|
} from "../helpers/table-keyboard";
|
|
17
|
-
import { useGridCache } from "
|
|
17
|
+
import { useGridCache } from "./useGridCache";
|
|
18
18
|
|
|
19
19
|
type UseTableKeyboardNavOptions = {
|
|
20
20
|
enabled: boolean;
|
|
@@ -130,6 +130,7 @@ function useTableKeyboardNav(
|
|
|
130
130
|
/**
|
|
131
131
|
* When focus is moved to elements inside a cell like inputs, checkbox etc
|
|
132
132
|
* we want to update the active cell to the parent td/th, so that keyboard navigation continues to work as expected from there.
|
|
133
|
+
* Make sure td/th elements have tabIndex={-1} so they can receive focus on click
|
|
133
134
|
*/
|
|
134
135
|
const handleTableFocusIn = useEventCallback((event: FocusEvent): void => {
|
|
135
136
|
const target = event.target as Element | null;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useControllableState } from "../../../utils/hooks";
|
|
3
|
+
import { getMultipleSelectProps } from "../helpers/selection/getMultipleSelectProps";
|
|
4
|
+
import { getSingleSelectProps } from "../helpers/selection/getSingleSelectProps";
|
|
5
|
+
import type {
|
|
6
|
+
SelectionProps,
|
|
7
|
+
SelectionT,
|
|
8
|
+
TableSelection,
|
|
9
|
+
} from "../helpers/selection/selection.types";
|
|
10
|
+
|
|
11
|
+
type UseTableSelectionArgs<T> = SelectionProps & {
|
|
12
|
+
data: T[];
|
|
13
|
+
getRowId: (rowData: T, index: number) => string | number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function useTableSelection<T>({
|
|
17
|
+
selectionMode = "none",
|
|
18
|
+
defaultSelectedKeys,
|
|
19
|
+
selectedKeys: selectedKeysProp,
|
|
20
|
+
onSelectionChange,
|
|
21
|
+
disabledKeys = [],
|
|
22
|
+
data,
|
|
23
|
+
getRowId,
|
|
24
|
+
}: UseTableSelectionArgs<T>): TableSelection {
|
|
25
|
+
const allKeys = useMemo(
|
|
26
|
+
() => data.map((item, index) => getRowId(item, index)),
|
|
27
|
+
[data, getRowId],
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const [selectedKeys, setSelectedKeys] = useControllableState<SelectionT>({
|
|
31
|
+
value: selectionMode !== "none" ? selectedKeysProp : undefined,
|
|
32
|
+
defaultValue: defaultSelectedKeys ?? [],
|
|
33
|
+
onChange: onSelectionChange,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (selectionMode === "none") {
|
|
37
|
+
return { selectionMode, allKeys, selectedKeys: [], disabledKeys };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (selectionMode === "single") {
|
|
41
|
+
const arrayKeys = Array.isArray(selectedKeys) ? selectedKeys : [];
|
|
42
|
+
const { getRowRadioProps } = getSingleSelectProps({
|
|
43
|
+
selectedKeys: arrayKeys,
|
|
44
|
+
setSelectedKeys,
|
|
45
|
+
disabledKeys,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
selectionMode,
|
|
50
|
+
allKeys,
|
|
51
|
+
selectedKeys: arrayKeys,
|
|
52
|
+
disabledKeys,
|
|
53
|
+
getRowRadioProps,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const { getTheadCheckboxProps, getRowCheckboxProps } = getMultipleSelectProps(
|
|
58
|
+
{
|
|
59
|
+
selectedKeys,
|
|
60
|
+
setSelectedKeys,
|
|
61
|
+
disabledKeys,
|
|
62
|
+
allKeys,
|
|
63
|
+
totalCount: data.length,
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
selectionMode,
|
|
69
|
+
allKeys,
|
|
70
|
+
selectedKeys,
|
|
71
|
+
disabledKeys,
|
|
72
|
+
getTheadCheckboxProps,
|
|
73
|
+
getRowCheckboxProps,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { useTableSelection };
|
|
78
|
+
export type { SelectionProps, SelectionT };
|
|
@@ -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,205 @@
|
|
|
1
|
+
/** biome-ignore-all lint/correctness/useHookAtTopLevel: False positive because of the way forwardRef() is added */
|
|
2
|
+
import React, { forwardRef, useState } from "react";
|
|
3
|
+
import { Checkbox } from "../../../form/checkbox";
|
|
4
|
+
import { cl } from "../../../utils/helpers";
|
|
5
|
+
import { useMergeRefs } from "../../../utils/hooks";
|
|
6
|
+
import { useTableKeyboardNav } from "../hooks/useTableKeyboardNav";
|
|
7
|
+
import {
|
|
8
|
+
type SelectionProps,
|
|
9
|
+
useTableSelection,
|
|
10
|
+
} from "../hooks/useTableSelection";
|
|
11
|
+
import { DataTableTbody } from "../tbody/DataTableTbody";
|
|
12
|
+
import { DataTableTd } from "../td/DataTableTd";
|
|
13
|
+
import { DataTableTh } from "../th/DataTableTh";
|
|
14
|
+
import { DataTableThead } from "../thead/DataTableThead";
|
|
15
|
+
import { DataTableTr } from "../tr/DataTableTr";
|
|
16
|
+
import type { ColumnDefinitions } from "./DataTable.types";
|
|
17
|
+
import { DataTableContextProvider } from "./DataTableRoot.context";
|
|
18
|
+
|
|
19
|
+
interface DataTableProps<T>
|
|
20
|
+
extends React.HTMLAttributes<HTMLTableElement>, SelectionProps {
|
|
21
|
+
children?: never;
|
|
22
|
+
/**
|
|
23
|
+
* Controls vertical cell padding.
|
|
24
|
+
* @default "normal"
|
|
25
|
+
*/
|
|
26
|
+
rowDensity?: "condensed" | "normal" | "spacious";
|
|
27
|
+
/**
|
|
28
|
+
* Zebra striped table
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
zebraStripes?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Truncate content in cells and show ellipsis for overflowed text.
|
|
34
|
+
*
|
|
35
|
+
* **NB:** When using `layout="auto"`, you have to manually set a `maxWidth` on columns that should be truncated.
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
truncateContent?: boolean; // TODO: Consider making this default false when layout=auto, and maybe disallow it but add a wrap prop on the td-comp.
|
|
39
|
+
/**
|
|
40
|
+
* Enables keyboard navigation for table rows and cells.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
withKeyboardNav?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Custom callback to determine if navigation should be blocked.
|
|
46
|
+
* Called before default blocking logic.
|
|
47
|
+
* Requires `withKeyboardNav` to be `true`.
|
|
48
|
+
*/
|
|
49
|
+
shouldBlockNavigation?: (event: KeyboardEvent) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Controls table layout.
|
|
52
|
+
*
|
|
53
|
+
* ### fixed
|
|
54
|
+
* Gives you full control of column widths. This is required for resizable columns.
|
|
55
|
+
*
|
|
56
|
+
* ### auto
|
|
57
|
+
* Makes the columns resize automatically based on the content.
|
|
58
|
+
* The table will take up at least 100% of available width.
|
|
59
|
+
*
|
|
60
|
+
* **NB:** When using this with `truncateContent`, you have to manually
|
|
61
|
+
* set a `contentMaxWidth` on cells that should be truncated.
|
|
62
|
+
* @default "fixed"
|
|
63
|
+
*/
|
|
64
|
+
layout?: "fixed" | "auto";
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
columnDefinitions: ColumnDefinitions<T>;
|
|
69
|
+
data: T[];
|
|
70
|
+
getRowId?: (rowData: T, index: number) => string | number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function DataTableAutoInner<T>(
|
|
74
|
+
{
|
|
75
|
+
className,
|
|
76
|
+
rowDensity = "normal",
|
|
77
|
+
withKeyboardNav = false,
|
|
78
|
+
zebraStripes = false,
|
|
79
|
+
truncateContent = true,
|
|
80
|
+
shouldBlockNavigation,
|
|
81
|
+
layout = "fixed",
|
|
82
|
+
selectionMode: selectionModeProp = "none",
|
|
83
|
+
selectedKeys,
|
|
84
|
+
defaultSelectedKeys,
|
|
85
|
+
onSelectionChange,
|
|
86
|
+
disabledKeys = [],
|
|
87
|
+
data,
|
|
88
|
+
columnDefinitions,
|
|
89
|
+
getRowId,
|
|
90
|
+
...rest
|
|
91
|
+
}: DataTableProps<T>,
|
|
92
|
+
forwardedRef: React.ForwardedRef<HTMLTableElement>,
|
|
93
|
+
) {
|
|
94
|
+
const [tableRef, setTableRef] = useState<HTMLTableElement | null>(null);
|
|
95
|
+
const mergedRef = useMergeRefs(forwardedRef, setTableRef);
|
|
96
|
+
|
|
97
|
+
const { tabIndex } = useTableKeyboardNav(tableRef, {
|
|
98
|
+
enabled: withKeyboardNav,
|
|
99
|
+
shouldBlockNavigation,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const resolvedGetRowId =
|
|
103
|
+
getRowId ??
|
|
104
|
+
(((_row: T, index: number) => index) as (rowData: T) => string | number);
|
|
105
|
+
|
|
106
|
+
const selection = useTableSelection({
|
|
107
|
+
selectionMode: selectionModeProp,
|
|
108
|
+
selectedKeys,
|
|
109
|
+
defaultSelectedKeys,
|
|
110
|
+
onSelectionChange,
|
|
111
|
+
disabledKeys,
|
|
112
|
+
data,
|
|
113
|
+
getRowId: resolvedGetRowId,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<DataTableContextProvider layout={layout} withKeyboardNav={withKeyboardNav}>
|
|
118
|
+
<div className="aksel-data-table__border-wrapper">
|
|
119
|
+
<div className="aksel-data-table__scroll-wrapper">
|
|
120
|
+
<table
|
|
121
|
+
{...rest}
|
|
122
|
+
ref={mergedRef}
|
|
123
|
+
className={cl("aksel-data-table", className)}
|
|
124
|
+
data-zebra-stripes={zebraStripes}
|
|
125
|
+
data-truncate-content={truncateContent}
|
|
126
|
+
data-density={rowDensity}
|
|
127
|
+
data-layout={layout}
|
|
128
|
+
tabIndex={tabIndex}
|
|
129
|
+
>
|
|
130
|
+
<DataTableThead>
|
|
131
|
+
<DataTableTr>
|
|
132
|
+
{selection.selectionMode === "multiple" && (
|
|
133
|
+
/* TODO: Overflow/focus is clipped. Alignment is off */
|
|
134
|
+
/* TODO: Should not be resizable */
|
|
135
|
+
<DataTableTh textAlign="center" width="60px">
|
|
136
|
+
<Checkbox {...selection.getTheadCheckboxProps()} />
|
|
137
|
+
</DataTableTh>
|
|
138
|
+
)}
|
|
139
|
+
{selection.selectionMode === "single" && (
|
|
140
|
+
<DataTableTd align="center" width="60px" />
|
|
141
|
+
)}
|
|
142
|
+
{columnDefinitions.map((colDef, colDefIndex) => {
|
|
143
|
+
return (
|
|
144
|
+
<DataTableTh
|
|
145
|
+
/* TODO: Make these user-changable */
|
|
146
|
+
maxWidth="400px"
|
|
147
|
+
minWidth="100px"
|
|
148
|
+
defaultWidth="100%"
|
|
149
|
+
textAlign="left"
|
|
150
|
+
key={colDef.id || colDefIndex}
|
|
151
|
+
>
|
|
152
|
+
{colDef.header}
|
|
153
|
+
</DataTableTh>
|
|
154
|
+
);
|
|
155
|
+
})}
|
|
156
|
+
</DataTableTr>
|
|
157
|
+
</DataTableThead>
|
|
158
|
+
<DataTableTbody>
|
|
159
|
+
{data.map((rowData, rowIndex) => {
|
|
160
|
+
const rowId = selection.allKeys[rowIndex];
|
|
161
|
+
return (
|
|
162
|
+
<DataTableTr key={rowId}>
|
|
163
|
+
{selection.selectionMode === "multiple" && (
|
|
164
|
+
<DataTableTd align="center" width="60px">
|
|
165
|
+
<Checkbox {...selection.getRowCheckboxProps(rowId)} />
|
|
166
|
+
</DataTableTd>
|
|
167
|
+
)}
|
|
168
|
+
{selection.selectionMode === "single" && (
|
|
169
|
+
<DataTableTd align="center" width="60px">
|
|
170
|
+
{/**
|
|
171
|
+
* TODO: This should be a radio, but our current Radio implementation has some issues:
|
|
172
|
+
* - Checked cant be controlled outside of radiogroup
|
|
173
|
+
* - Cant hide label
|
|
174
|
+
* */}
|
|
175
|
+
<Checkbox {...selection.getRowRadioProps(rowId)} />
|
|
176
|
+
</DataTableTd>
|
|
177
|
+
)}
|
|
178
|
+
{columnDefinitions.map((colDef, colDefIndex) => {
|
|
179
|
+
return (
|
|
180
|
+
<DataTableTd
|
|
181
|
+
textAlign="left"
|
|
182
|
+
key={colDef.id || colDefIndex}
|
|
183
|
+
>
|
|
184
|
+
{colDef.cell(rowData)}
|
|
185
|
+
</DataTableTd>
|
|
186
|
+
);
|
|
187
|
+
})}
|
|
188
|
+
</DataTableTr>
|
|
189
|
+
);
|
|
190
|
+
})}
|
|
191
|
+
</DataTableTbody>
|
|
192
|
+
</table>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
</DataTableContextProvider>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const DataTableAuto = forwardRef(DataTableAutoInner) as <T>(
|
|
200
|
+
props: DataTableProps<T> & React.RefAttributes<HTMLTableElement>,
|
|
201
|
+
) => React.ReactElement | null;
|
|
202
|
+
|
|
203
|
+
export { DataTableAuto };
|
|
204
|
+
export type { DataTableProps };
|
|
205
|
+
export default DataTableAuto;
|