@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
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect } from "react";
|
|
2
|
+
import { Floating } from "../../../utils/components/floating/Floating";
|
|
3
|
+
import DragAndDropItem, { DragAndDropItemProps } from "../item/DragAndDropItem";
|
|
4
|
+
import { DragAndDropElement } from "../types";
|
|
5
|
+
import { DragAndDropProvider } from "./DragAndDrop.context";
|
|
6
|
+
|
|
7
|
+
interface DragAndDropProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
children: any[];
|
|
9
|
+
setItems: React.Dispatch<React.SetStateAction<any[]>>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface DataDragAndDropRootComponent extends React.ForwardRefExoticComponent<
|
|
13
|
+
DragAndDropProps & React.RefAttributes<HTMLDivElement>
|
|
14
|
+
> {
|
|
15
|
+
/**
|
|
16
|
+
* @see 🏷️ {@link DragAndDropItemProps}
|
|
17
|
+
* * @example
|
|
18
|
+
* ```jsx
|
|
19
|
+
* <DragAndDrop>
|
|
20
|
+
* <DragAndDrop.Item id="1" index={0}>
|
|
21
|
+
* ...
|
|
22
|
+
* </DragAndDrop.Item>
|
|
23
|
+
* </DragAndDrop>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
Item: typeof DragAndDropItem;
|
|
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
|
+
*/
|
|
41
|
+
|
|
42
|
+
const DragAndDrop = forwardRef<HTMLDivElement, DragAndDropProps>(
|
|
43
|
+
({ setItems, children }, forwardedRef) => {
|
|
44
|
+
const [activeItem, setActiveItem] =
|
|
45
|
+
React.useState<DragAndDropElement | null>(null);
|
|
46
|
+
const [dropTarget, setDropTarget] =
|
|
47
|
+
React.useState<DragAndDropElement | null>(null);
|
|
48
|
+
const [dragHandlerActive, setDragHandlerActive] =
|
|
49
|
+
React.useState<DragAndDropElement | null>(null);
|
|
50
|
+
|
|
51
|
+
const activeItemRef = React.useRef<DragAndDropElement | null>(null);
|
|
52
|
+
const dropTargetRef = React.useRef<DragAndDropElement | null>(null);
|
|
53
|
+
|
|
54
|
+
const [virtualRef, setVirtualRef] = React.useState({
|
|
55
|
+
getBoundingClientRect: () =>
|
|
56
|
+
DOMRect.fromRect({ width: 0, height: 0, x: 0, y: 0 }),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const setCombinedActiveItem = React.useCallback(
|
|
60
|
+
(item: DragAndDropElement | null) => {
|
|
61
|
+
activeItemRef.current = item;
|
|
62
|
+
setActiveItem(item);
|
|
63
|
+
},
|
|
64
|
+
[],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const setCombinedDropTarget = React.useCallback(
|
|
68
|
+
(item: DragAndDropElement | null) => {
|
|
69
|
+
dropTargetRef.current = item;
|
|
70
|
+
setDropTarget(item);
|
|
71
|
+
},
|
|
72
|
+
[],
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (activeItem) {
|
|
77
|
+
document.documentElement.setAttribute("data-dragging", "true");
|
|
78
|
+
document.body.style.userSelect = "none";
|
|
79
|
+
} else {
|
|
80
|
+
document.documentElement.removeAttribute("data-dragging");
|
|
81
|
+
document.body.style.userSelect = "";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return () => {
|
|
85
|
+
document.documentElement.removeAttribute("data-dragging");
|
|
86
|
+
document.body.style.userSelect = "";
|
|
87
|
+
};
|
|
88
|
+
}, [activeItem]);
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (!activeItem) return;
|
|
92
|
+
|
|
93
|
+
const handlePointerMove = (event: PointerEvent) => {
|
|
94
|
+
setVirtualRef({
|
|
95
|
+
getBoundingClientRect: () =>
|
|
96
|
+
DOMRect.fromRect({
|
|
97
|
+
width: 0,
|
|
98
|
+
height: 0,
|
|
99
|
+
x: event.clientX,
|
|
100
|
+
y: event.clientY,
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const active = activeItemRef.current;
|
|
105
|
+
if (!active) return;
|
|
106
|
+
|
|
107
|
+
const elements = document.elementsFromPoint(
|
|
108
|
+
event.clientX,
|
|
109
|
+
event.clientY,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const matchingElements = elements.filter(
|
|
113
|
+
(el) =>
|
|
114
|
+
el instanceof HTMLElement && Boolean(el.closest("[data-dnd-id]")),
|
|
115
|
+
) as HTMLElement[];
|
|
116
|
+
|
|
117
|
+
const itemElements = matchingElements
|
|
118
|
+
.map((el) => el.closest("[data-dnd-id]") as HTMLElement)
|
|
119
|
+
.filter((el) => el instanceof HTMLElement);
|
|
120
|
+
|
|
121
|
+
const uniqueItemElements = Array.from(new Set(itemElements));
|
|
122
|
+
|
|
123
|
+
const targetElement =
|
|
124
|
+
uniqueItemElements.find((el) => el.dataset.dndId !== active.id) ??
|
|
125
|
+
uniqueItemElements.find((el) => el.dataset.dndId === active.id) ??
|
|
126
|
+
null;
|
|
127
|
+
|
|
128
|
+
if (!targetElement) {
|
|
129
|
+
setCombinedDropTarget(null);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const hoveredId = targetElement.dataset.dndId;
|
|
134
|
+
const hoveredIndex = Number(targetElement.dataset.dndIndex);
|
|
135
|
+
|
|
136
|
+
if (!hoveredId || Number.isNaN(hoveredIndex)) {
|
|
137
|
+
setCombinedDropTarget(null);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
setCombinedDropTarget({ id: hoveredId, index: hoveredIndex });
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const handlePointerUp = () => {
|
|
145
|
+
const active = activeItemRef.current;
|
|
146
|
+
const target = dropTargetRef.current;
|
|
147
|
+
|
|
148
|
+
if (active && target && active.id !== target.id) {
|
|
149
|
+
setItems((items) => {
|
|
150
|
+
const newItems = [...items];
|
|
151
|
+
const [movedItem] = newItems.splice(active.index, 1);
|
|
152
|
+
newItems.splice(target.index, 0, movedItem);
|
|
153
|
+
return newItems;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
setCombinedActiveItem(null);
|
|
157
|
+
setCombinedDropTarget(null);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// TODO - Look into adding a cancel listener event
|
|
161
|
+
window.addEventListener("pointermove", handlePointerMove);
|
|
162
|
+
window.addEventListener("pointerup", handlePointerUp);
|
|
163
|
+
|
|
164
|
+
return () => {
|
|
165
|
+
window.removeEventListener("pointermove", handlePointerMove);
|
|
166
|
+
window.removeEventListener("pointerup", handlePointerUp);
|
|
167
|
+
};
|
|
168
|
+
}, [activeItem, setCombinedDropTarget, setCombinedActiveItem, setItems]);
|
|
169
|
+
|
|
170
|
+
const onKeyboardDragEnd = (diff: number) => {
|
|
171
|
+
if (!dragHandlerActive) return;
|
|
172
|
+
|
|
173
|
+
const targetIndex = dragHandlerActive.index + diff;
|
|
174
|
+
if (targetIndex < 0 || targetIndex >= children.length) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
setItems((items) => {
|
|
179
|
+
const newItems = [...items];
|
|
180
|
+
const [movedItem] = newItems.splice(dragHandlerActive.index, 1);
|
|
181
|
+
newItems.splice(targetIndex, 0, movedItem);
|
|
182
|
+
return newItems;
|
|
183
|
+
});
|
|
184
|
+
setDragHandlerActive({ ...dragHandlerActive, index: targetIndex });
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const onDragStart = (
|
|
188
|
+
event: React.PointerEvent | React.MouseEvent,
|
|
189
|
+
item: DragAndDropElement,
|
|
190
|
+
) => {
|
|
191
|
+
setVirtualRef({
|
|
192
|
+
getBoundingClientRect: () =>
|
|
193
|
+
DOMRect.fromRect({
|
|
194
|
+
width: 0,
|
|
195
|
+
height: 0,
|
|
196
|
+
x: event.clientX,
|
|
197
|
+
y: event.clientY,
|
|
198
|
+
}),
|
|
199
|
+
});
|
|
200
|
+
setCombinedActiveItem(item);
|
|
201
|
+
setCombinedDropTarget(item);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// TODO - Make overlay same width as the OG item, currently jumps to content width
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<DragAndDropProvider
|
|
208
|
+
activeItem={activeItem}
|
|
209
|
+
setActiveItem={setCombinedActiveItem}
|
|
210
|
+
dropTarget={dropTarget}
|
|
211
|
+
setDropTarget={setCombinedDropTarget}
|
|
212
|
+
dragHandlerActive={dragHandlerActive}
|
|
213
|
+
setDragHandlerActive={setDragHandlerActive}
|
|
214
|
+
onKeyboardDragEnd={onKeyboardDragEnd}
|
|
215
|
+
onDragStart={onDragStart}
|
|
216
|
+
>
|
|
217
|
+
<div ref={forwardedRef}>{children}</div>
|
|
218
|
+
{activeItem && (
|
|
219
|
+
<Floating>
|
|
220
|
+
<Floating.Anchor virtualRef={virtualRef}>
|
|
221
|
+
<span />
|
|
222
|
+
</Floating.Anchor>
|
|
223
|
+
<Floating.Content
|
|
224
|
+
align="start"
|
|
225
|
+
updatePositionStrategy="always"
|
|
226
|
+
style={{ pointerEvents: "none" }}
|
|
227
|
+
>
|
|
228
|
+
{React.cloneElement(children[activeItem.index], {
|
|
229
|
+
"data-dnd-id": undefined,
|
|
230
|
+
"data-dnd-index": undefined,
|
|
231
|
+
"data-overlay": true,
|
|
232
|
+
})}
|
|
233
|
+
</Floating.Content>
|
|
234
|
+
</Floating>
|
|
235
|
+
)}
|
|
236
|
+
</DragAndDropProvider>
|
|
237
|
+
);
|
|
238
|
+
},
|
|
239
|
+
) as DataDragAndDropRootComponent;
|
|
240
|
+
|
|
241
|
+
DragAndDrop.Item = DragAndDropItem;
|
|
242
|
+
|
|
243
|
+
export { DragAndDrop, DragAndDropItem };
|
|
244
|
+
export default DragAndDrop;
|
|
245
|
+
export type { DragAndDropItemProps, DragAndDropProps };
|
|
@@ -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
|
+
});
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { useSortable } from "@dnd-kit/react/sortable";
|
|
2
2
|
import React, { useRef } from "react";
|
|
3
|
-
import {
|
|
4
|
-
CaretDownCircleFillIcon,
|
|
5
|
-
CaretUpCircleFillIcon,
|
|
6
|
-
DragVerticalIcon,
|
|
7
|
-
} from "@navikt/aksel-icons";
|
|
8
3
|
import { HStack } from "../../../primitives/stack";
|
|
9
4
|
import { cl } from "../../../utils/helpers";
|
|
10
5
|
import { useMergeRefs } from "../../../utils/hooks";
|
|
6
|
+
import { DataDragAndDropDragHandler } from "../drag-handler/DataDragAndDropDragHandler";
|
|
11
7
|
import { DataDragAndDropContext } from "../root/DataDragAndDrop.context";
|
|
12
8
|
|
|
13
9
|
interface DataDragAndDropItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -62,34 +58,11 @@ const DataDragAndDropItem = React.forwardRef<
|
|
|
62
58
|
data-drop-target={mouseDropTarget}
|
|
63
59
|
tabIndex={-1}
|
|
64
60
|
>
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
>
|
|
71
|
-
{keyboardDragging && (
|
|
72
|
-
<span
|
|
73
|
-
className="aksel-data-table__drag-and-drop-item-keyboard-drag-icon"
|
|
74
|
-
data-direction="up"
|
|
75
|
-
>
|
|
76
|
-
<CaretUpCircleFillIcon aria-hidden fontSize="1.2rem" />
|
|
77
|
-
</span>
|
|
78
|
-
)}
|
|
79
|
-
<DragVerticalIcon
|
|
80
|
-
aria-hidden
|
|
81
|
-
title="Dra for å flytte"
|
|
82
|
-
fontSize="1.5rem"
|
|
83
|
-
/>
|
|
84
|
-
{keyboardDragging && (
|
|
85
|
-
<span
|
|
86
|
-
className="aksel-data-table__drag-and-drop-item-keyboard-drag-icon"
|
|
87
|
-
data-direction="down"
|
|
88
|
-
>
|
|
89
|
-
<CaretDownCircleFillIcon aria-hidden fontSize="1.2rem" />
|
|
90
|
-
</span>
|
|
91
|
-
)}
|
|
92
|
-
</div>
|
|
61
|
+
<DataDragAndDropDragHandler
|
|
62
|
+
handleRef={handleRef}
|
|
63
|
+
keyboardDragging={keyboardDragging}
|
|
64
|
+
alt
|
|
65
|
+
/>
|
|
93
66
|
<div>{children}</div>
|
|
94
67
|
</div>
|
|
95
68
|
</HStack>
|
|
@@ -2,6 +2,8 @@ import { createContext } from "react";
|
|
|
2
2
|
|
|
3
3
|
interface DataDragAndDropContextType {
|
|
4
4
|
inputMethod: "mouse" | "keyboard" | null;
|
|
5
|
+
// setInputMethod: (method: "mouse" | "keyboard" | null) => void;
|
|
6
|
+
// setItems: React.Dispatch<React.SetStateAction<any[]>>;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
export const DataDragAndDropContext = createContext<
|
|
@@ -7,13 +7,13 @@ import DataDragAndDropItem, {
|
|
|
7
7
|
} from "../item/DataDragAndDropItem";
|
|
8
8
|
import { DataDragAndDropContext } from "./DataDragAndDrop.context";
|
|
9
9
|
|
|
10
|
-
interface DataDragAndDropProps extends React.HTMLAttributes<
|
|
10
|
+
interface DataDragAndDropProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
11
|
children: any[];
|
|
12
12
|
setItems: React.Dispatch<React.SetStateAction<any[]>>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
interface DataDragAndDropRootComponent extends React.ForwardRefExoticComponent<
|
|
16
|
-
DataDragAndDropProps & React.RefAttributes<
|
|
16
|
+
DataDragAndDropProps & React.RefAttributes<HTMLDivElement>
|
|
17
17
|
> {
|
|
18
18
|
/**
|
|
19
19
|
* @see 🏷️ {@link DataDragAndDropItemProps}
|
|
@@ -62,11 +62,9 @@ const DataDragAndDrop = forwardRef<HTMLDivElement, DataDragAndDropProps>(
|
|
|
62
62
|
}
|
|
63
63
|
}}
|
|
64
64
|
onDragEnd={(event) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
setItemOrder(source.initialIndex, target.index);
|
|
69
|
-
}
|
|
65
|
+
const { source, target } = event.operation;
|
|
66
|
+
if (!isSortable(source) || !isSortable(target)) return;
|
|
67
|
+
setItemOrder(source.initialIndex, target.index);
|
|
70
68
|
}}
|
|
71
69
|
>
|
|
72
70
|
<VStack asChild gap="space-12">
|
|
@@ -74,7 +72,7 @@ const DataDragAndDrop = forwardRef<HTMLDivElement, DataDragAndDropProps>(
|
|
|
74
72
|
{children}
|
|
75
73
|
</div>
|
|
76
74
|
</VStack>
|
|
77
|
-
<DragOverlay>
|
|
75
|
+
<DragOverlay dropAnimation={null}>
|
|
78
76
|
{(source) => {
|
|
79
77
|
// Overlay not needed and causes glitching when using keyboard
|
|
80
78
|
if (inputMethod === "keyboard") return null;
|
|
@@ -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 };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { CheckboxProps } from "../../../../form/checkbox/types";
|
|
2
|
+
import type { SelectionT } from "./selection.types";
|
|
3
|
+
|
|
4
|
+
type GetMultipleSelectPropsArgs = {
|
|
5
|
+
selectedKeys: SelectionT;
|
|
6
|
+
setSelectedKeys: (keys: SelectionT) => void;
|
|
7
|
+
disabledKeys: (string | number)[];
|
|
8
|
+
allKeys: (string | number)[];
|
|
9
|
+
totalCount: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function getMultipleSelectProps({
|
|
13
|
+
selectedKeys,
|
|
14
|
+
setSelectedKeys,
|
|
15
|
+
disabledKeys,
|
|
16
|
+
allKeys,
|
|
17
|
+
totalCount,
|
|
18
|
+
}: GetMultipleSelectPropsArgs) {
|
|
19
|
+
const handleToggleAll = () => {
|
|
20
|
+
const allSelected =
|
|
21
|
+
selectedKeys === "all" ||
|
|
22
|
+
(Array.isArray(selectedKeys) && selectedKeys.length === totalCount);
|
|
23
|
+
|
|
24
|
+
setSelectedKeys(allSelected ? [] : allKeys);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const handleToggleRow = (key: string | number) => {
|
|
28
|
+
if (selectedKeys === "all") {
|
|
29
|
+
setSelectedKeys(allKeys.filter((id) => id !== key));
|
|
30
|
+
} else if (selectedKeys.includes(key)) {
|
|
31
|
+
setSelectedKeys(selectedKeys.filter((k) => k !== key));
|
|
32
|
+
} else {
|
|
33
|
+
setSelectedKeys([...selectedKeys, key]);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const isChecked = (key: string | number) =>
|
|
38
|
+
selectedKeys === "all" ||
|
|
39
|
+
(Array.isArray(selectedKeys) && selectedKeys.includes(key));
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
getTheadCheckboxProps: (): CheckboxProps => {
|
|
43
|
+
const indeterminate =
|
|
44
|
+
Array.isArray(selectedKeys) &&
|
|
45
|
+
selectedKeys.length > 0 &&
|
|
46
|
+
selectedKeys.length < totalCount;
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
children: "Select all rows",
|
|
50
|
+
onChange: handleToggleAll,
|
|
51
|
+
checked:
|
|
52
|
+
(selectedKeys === "all" ||
|
|
53
|
+
(Array.isArray(selectedKeys) && selectedKeys.length > 0)) &&
|
|
54
|
+
!indeterminate,
|
|
55
|
+
indeterminate,
|
|
56
|
+
disabled: disabledKeys.length === totalCount,
|
|
57
|
+
hideLabel: true,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
getRowCheckboxProps: (key: string | number): CheckboxProps => ({
|
|
61
|
+
children: `Select row with id ${key}`,
|
|
62
|
+
onChange: () => handleToggleRow(key),
|
|
63
|
+
checked: isChecked(key),
|
|
64
|
+
disabled: disabledKeys.includes(key),
|
|
65
|
+
hideLabel: true,
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { getMultipleSelectProps };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RadioProps } from "../../../../form/radio/types";
|
|
2
|
+
|
|
3
|
+
type GetSingleSelectPropsArgs = {
|
|
4
|
+
selectedKeys: (string | number)[];
|
|
5
|
+
setSelectedKeys: (keys: (string | number)[]) => void;
|
|
6
|
+
disabledKeys: (string | number)[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function getSingleSelectProps({
|
|
10
|
+
selectedKeys,
|
|
11
|
+
setSelectedKeys,
|
|
12
|
+
disabledKeys,
|
|
13
|
+
}: GetSingleSelectPropsArgs) {
|
|
14
|
+
const handleSelectionChange = (key: string | number) => {
|
|
15
|
+
if (selectedKeys.includes(key)) {
|
|
16
|
+
setSelectedKeys([]);
|
|
17
|
+
} else {
|
|
18
|
+
setSelectedKeys([key]);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
getRowRadioProps: (key: string | number): RadioProps => ({
|
|
24
|
+
children: `Select row with id ${key}`,
|
|
25
|
+
checked: selectedKeys.includes(key),
|
|
26
|
+
onChange: () => handleSelectionChange(key),
|
|
27
|
+
disabled: disabledKeys.includes(key),
|
|
28
|
+
value: key,
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { getSingleSelectProps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CheckboxProps } from "../../../../form/checkbox/types";
|
|
2
|
+
import type { RadioProps } from "../../../../form/radio/types";
|
|
3
|
+
|
|
4
|
+
type SelectionT = (string | number)[] | "all";
|
|
5
|
+
|
|
6
|
+
type SelectionProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Enables selection of rows.
|
|
9
|
+
*
|
|
10
|
+
* When set to "single", only one row can be selected at a time (renders radio buttons).
|
|
11
|
+
*
|
|
12
|
+
* When set to "multiple", multiple rows can be selected (renders checkboxes).
|
|
13
|
+
*
|
|
14
|
+
* @default "none"
|
|
15
|
+
*/
|
|
16
|
+
selectionMode?: "none" | "single" | "multiple";
|
|
17
|
+
selectedKeys?: SelectionT;
|
|
18
|
+
defaultSelectedKeys?: SelectionT;
|
|
19
|
+
onSelectionChange?: (keys: SelectionT) => void;
|
|
20
|
+
disabledKeys?: (string | number)[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type NoneSelection = {
|
|
24
|
+
selectionMode: "none";
|
|
25
|
+
allKeys: (string | number)[];
|
|
26
|
+
selectedKeys: (string | number)[];
|
|
27
|
+
disabledKeys: (string | number)[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type SingleSelection = {
|
|
31
|
+
selectionMode: "single";
|
|
32
|
+
allKeys: (string | number)[];
|
|
33
|
+
selectedKeys: (string | number)[];
|
|
34
|
+
disabledKeys: (string | number)[];
|
|
35
|
+
getRowRadioProps: (key: string | number) => RadioProps;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type MultipleSelection = {
|
|
39
|
+
selectionMode: "multiple";
|
|
40
|
+
allKeys: (string | number)[];
|
|
41
|
+
selectedKeys: SelectionT;
|
|
42
|
+
disabledKeys: (string | number)[];
|
|
43
|
+
getTheadCheckboxProps: () => CheckboxProps;
|
|
44
|
+
getRowCheckboxProps: (key: string | number) => CheckboxProps;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type TableSelection = NoneSelection | SingleSelection | MultipleSelection;
|
|
48
|
+
|
|
49
|
+
export type {
|
|
50
|
+
MultipleSelection,
|
|
51
|
+
NoneSelection,
|
|
52
|
+
SelectionProps,
|
|
53
|
+
SelectionT,
|
|
54
|
+
SingleSelection,
|
|
55
|
+
TableSelection,
|
|
56
|
+
};
|
|
@@ -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
|
}
|