@navikt/ds-react 8.9.0 → 8.10.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/content/BaseAlertContent.js +4 -1
- package/cjs/alert/base-alert/content/BaseAlertContent.js.map +1 -1
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.d.ts +3 -0
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +41 -20
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/cjs/data/drag-and-drop/item/DragAndDropItem.d.ts +7 -2
- package/cjs/data/drag-and-drop/item/DragAndDropItem.js +6 -8
- package/cjs/data/drag-and-drop/item/DragAndDropItem.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDrop.context.d.ts +2 -1
- package/cjs/data/drag-and-drop/root/DragAndDrop.context.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.d.ts +7 -30
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js +124 -65
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/cjs/data/drag-and-drop/types.d.ts +4 -0
- package/cjs/data/table/base-cell/DataTableBaseCell.d.ts +46 -0
- package/cjs/data/table/base-cell/DataTableBaseCell.js +63 -0
- package/cjs/data/table/base-cell/DataTableBaseCell.js.map +1 -0
- package/cjs/data/table/column-header/DataTableColumnHeader.d.ts +32 -0
- package/cjs/data/table/column-header/DataTableColumnHeader.js +108 -0
- package/cjs/data/table/column-header/DataTableColumnHeader.js.map +1 -0
- package/cjs/data/table/column-header/useTableColumnResize.js.map +1 -0
- package/cjs/data/table/empty-state/DataTableEmptyState.d.ts +6 -2
- package/cjs/data/table/empty-state/DataTableEmptyState.js +2 -2
- package/cjs/data/table/empty-state/DataTableEmptyState.js.map +1 -1
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.d.ts +10 -10
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js +29 -28
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/getSingleSelectProps.d.ts +7 -5
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js +8 -9
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/selection.types.d.ts +44 -21
- package/cjs/data/table/hooks/useColumnOptions.d.ts +19 -0
- package/cjs/data/table/hooks/useColumnOptions.js +19 -0
- package/cjs/data/table/hooks/useColumnOptions.js.map +1 -0
- package/cjs/data/table/hooks/useTableExpansion.d.ts +26 -0
- package/cjs/data/table/hooks/useTableExpansion.js +68 -0
- package/cjs/data/table/hooks/useTableExpansion.js.map +1 -0
- package/cjs/data/table/hooks/useTableKeyboardNav.d.ts +2 -1
- package/cjs/data/table/hooks/useTableKeyboardNav.js +3 -1
- package/cjs/data/table/hooks/useTableKeyboardNav.js.map +1 -1
- package/cjs/data/table/hooks/useTableSelection.d.ts +14 -7
- package/cjs/data/table/hooks/useTableSelection.js +40 -27
- package/cjs/data/table/hooks/useTableSelection.js.map +1 -1
- package/cjs/data/table/hooks/useTableSort.d.ts +37 -0
- package/cjs/data/table/hooks/useTableSort.js +49 -0
- package/cjs/data/table/hooks/useTableSort.js.map +1 -0
- package/cjs/data/table/loading-state/DataTableLoadingState.d.ts +6 -2
- package/cjs/data/table/loading-state/DataTableLoadingState.js +2 -2
- package/cjs/data/table/loading-state/DataTableLoadingState.js.map +1 -1
- package/cjs/data/table/root/DataTable.types.d.ts +55 -4
- package/cjs/data/table/root/DataTableAuto.d.ts +97 -1
- package/cjs/data/table/root/DataTableAuto.js +92 -41
- package/cjs/data/table/root/DataTableAuto.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.context.d.ts +22 -1
- package/cjs/data/table/root/DataTableRoot.context.js +7 -1
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +0 -6
- package/cjs/data/table/root/DataTableRoot.js +5 -4
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/tbody/DataTableTbody.js +7 -1
- package/cjs/data/table/tbody/DataTableTbody.js.map +1 -1
- package/cjs/data/table/td/DataTableTd.d.ts +3 -19
- package/cjs/data/table/td/DataTableTd.js +3 -5
- package/cjs/data/table/td/DataTableTd.js.map +1 -1
- package/cjs/data/table/tfoot/DataTableTfoot.js +3 -1
- package/cjs/data/table/tfoot/DataTableTfoot.js.map +1 -1
- package/cjs/data/table/th/DataTableTh.d.ts +3 -44
- package/cjs/data/table/th/DataTableTh.js +3 -54
- package/cjs/data/table/th/DataTableTh.js.map +1 -1
- package/cjs/data/table/thead/DataTableThead.js +2 -2
- package/cjs/data/table/thead/DataTableThead.js.map +1 -1
- package/cjs/data/table/tr/DataTableTr.d.ts +8 -0
- package/cjs/data/table/tr/DataTableTr.js +131 -9
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/data/token-filter/FilterChip.d.ts +10 -0
- package/cjs/data/token-filter/FilterChip.js +65 -0
- package/cjs/data/token-filter/FilterChip.js.map +1 -0
- package/cjs/data/token-filter/TokenFilter.js +3 -10
- package/cjs/data/token-filter/TokenFilter.js.map +1 -1
- package/cjs/date/datepicker/hooks/useRangeDatepicker.js +1 -1
- package/cjs/date/datepicker/hooks/useRangeDatepicker.js.map +1 -1
- package/cjs/date/datepicker/parts/DatePicker.DayButton.js +3 -1
- package/cjs/date/datepicker/parts/DatePicker.DayButton.js.map +1 -1
- package/cjs/date/datepicker/parts/DatePicker.RDP.d.ts +1 -1
- package/cjs/date/datepicker/parts/DatePicker.RDP.js +26 -11
- package/cjs/date/datepicker/parts/DatePicker.RDP.js.map +1 -1
- package/cjs/date/monthpicker/parts/MonthPicker.Button.js +7 -5
- package/cjs/date/monthpicker/parts/MonthPicker.Button.js.map +1 -1
- package/cjs/date/monthpicker/parts/MonthPicker.Standalone.d.ts +1 -1
- package/cjs/dialog/popup/DialogPopupInternal.js +1 -1
- package/cjs/dialog/popup/DialogPopupInternal.js.map +1 -1
- package/cjs/form/checkbox/Checkbox.js +19 -33
- package/cjs/form/checkbox/Checkbox.js.map +1 -1
- package/cjs/form/checkbox/CheckboxGroup.context.d.ts +6 -0
- package/cjs/form/checkbox/CheckboxGroup.context.js +6 -0
- package/cjs/form/checkbox/CheckboxGroup.context.js.map +1 -0
- package/cjs/form/checkbox/CheckboxGroup.d.ts +0 -6
- package/cjs/form/checkbox/CheckboxGroup.js +8 -8
- package/cjs/form/checkbox/CheckboxGroup.js.map +1 -1
- package/cjs/form/checkbox/checkbox-input/CheckboxInput.d.ts +21 -0
- package/cjs/form/checkbox/checkbox-input/CheckboxInput.js +65 -0
- package/cjs/form/checkbox/checkbox-input/CheckboxInput.js.map +1 -0
- package/cjs/form/checkbox/types.d.ts +1 -1
- package/cjs/form/checkbox/useCheckbox.js +2 -2
- package/cjs/form/checkbox/useCheckbox.js.map +1 -1
- package/cjs/form/combobox/ComboboxWrapper.js +1 -3
- package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
- package/cjs/form/error-summary/ErrorSummary.js +1 -3
- package/cjs/form/error-summary/ErrorSummary.js.map +1 -1
- package/cjs/form/fieldset/Fieldset.d.ts +0 -4
- package/cjs/form/fieldset/Fieldset.js +5 -9
- package/cjs/form/fieldset/Fieldset.js.map +1 -1
- package/cjs/form/fieldset/useFieldset.d.ts +5 -3
- package/cjs/form/fieldset/useFieldset.js +9 -4
- package/cjs/form/fieldset/useFieldset.js.map +1 -1
- package/cjs/form/radio/Radio.js +9 -7
- package/cjs/form/radio/Radio.js.map +1 -1
- package/cjs/form/radio/RadioGroup.context.d.ts +8 -0
- package/cjs/form/radio/RadioGroup.context.js +6 -0
- package/cjs/form/radio/RadioGroup.context.js.map +1 -0
- package/cjs/form/radio/RadioGroup.d.ts +0 -8
- package/cjs/form/radio/RadioGroup.js +10 -10
- package/cjs/form/radio/RadioGroup.js.map +1 -1
- package/cjs/form/radio/radio-input/RadioInput.d.ts +19 -0
- package/cjs/{data/table/thead/DataTableThead.context.js → form/radio/radio-input/RadioInput.js} +19 -9
- package/cjs/form/radio/radio-input/RadioInput.js.map +1 -0
- package/cjs/form/radio/useRadio.js +2 -2
- package/cjs/form/radio/useRadio.js.map +1 -1
- package/cjs/form/search/Search.js +1 -3
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/inline-message/root/InlineMessage.js +2 -5
- package/cjs/inline-message/root/InlineMessage.js.map +1 -1
- package/cjs/modal/Modal.js +1 -3
- package/cjs/modal/Modal.js.map +1 -1
- package/cjs/modal/ModalUtils.js +1 -1
- package/cjs/modal/ModalUtils.js.map +1 -1
- package/cjs/primitives/box/Box.d.ts +1 -1
- package/cjs/process/Process.js +1 -5
- package/cjs/process/Process.js.map +1 -1
- package/cjs/tabs/useTabs.js +3 -7
- package/cjs/tabs/useTabs.js.map +1 -1
- package/cjs/timeline/Timeline.js +25 -62
- package/cjs/timeline/Timeline.js.map +1 -1
- package/cjs/timeline/TimelineRow.js +10 -14
- package/cjs/timeline/TimelineRow.js.map +1 -1
- package/cjs/timeline/hooks/TimelineKeyboardNavProvider.d.ts +16 -0
- package/cjs/timeline/hooks/TimelineKeyboardNavProvider.js +179 -0
- package/cjs/timeline/hooks/TimelineKeyboardNavProvider.js.map +1 -0
- package/cjs/timeline/hooks/usePeriodContext.d.ts +0 -1
- package/cjs/timeline/hooks/usePeriodContext.js +0 -1
- package/cjs/timeline/hooks/usePeriodContext.js.map +1 -1
- package/cjs/timeline/hooks/useRowContext.d.ts +0 -1
- package/cjs/timeline/hooks/useRowContext.js +0 -1
- package/cjs/timeline/hooks/useRowContext.js.map +1 -1
- package/cjs/timeline/hooks/useTimelineContext.d.ts +0 -4
- package/cjs/timeline/hooks/useTimelineContext.js +0 -4
- package/cjs/timeline/hooks/useTimelineContext.js.map +1 -1
- package/cjs/timeline/period/ClickablePeriod.js +6 -20
- package/cjs/timeline/period/ClickablePeriod.js.map +1 -1
- package/cjs/timeline/period/NonClickablePeriod.js +1 -1
- package/cjs/timeline/period/NonClickablePeriod.js.map +1 -1
- package/cjs/timeline/pin/PinInternal.js +9 -10
- package/cjs/timeline/pin/PinInternal.js.map +1 -1
- package/cjs/toggle-group/useToggleGroup.js +1 -1
- package/cjs/toggle-group/useToggleGroup.js.map +1 -1
- package/cjs/utils/components/HighlightText/HighlightText.js +1 -4
- package/cjs/utils/components/HighlightText/HighlightText.js.map +1 -1
- package/cjs/utils/components/dismissablelayer/DismissableLayer.js +1 -1
- package/cjs/utils/components/dismissablelayer/DismissableLayer.js.map +1 -1
- package/cjs/utils/helpers/create-strict-context.js +1 -1
- package/cjs/utils/helpers/create-strict-context.js.map +1 -1
- package/cjs/utils/hooks/useEventCallback.js +1 -1
- package/cjs/utils/hooks/useEventCallback.js.map +1 -1
- package/cjs/utils/hooks/useMedia.js +1 -1
- package/cjs/utils/hooks/useMedia.js.map +1 -1
- package/esm/alert/base-alert/content/BaseAlertContent.js +4 -1
- package/esm/alert/base-alert/content/BaseAlertContent.js.map +1 -1
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.d.ts +3 -0
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +41 -20
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/esm/data/drag-and-drop/item/DragAndDropItem.d.ts +7 -2
- package/esm/data/drag-and-drop/item/DragAndDropItem.js +6 -8
- package/esm/data/drag-and-drop/item/DragAndDropItem.js.map +1 -1
- package/esm/data/drag-and-drop/root/DragAndDrop.context.d.ts +2 -1
- package/esm/data/drag-and-drop/root/DragAndDrop.context.js.map +1 -1
- package/esm/data/drag-and-drop/root/DragAndDropRoot.d.ts +7 -30
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js +125 -66
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/esm/data/drag-and-drop/types.d.ts +4 -0
- package/esm/data/table/base-cell/DataTableBaseCell.d.ts +46 -0
- package/esm/data/table/base-cell/DataTableBaseCell.js +27 -0
- package/esm/data/table/base-cell/DataTableBaseCell.js.map +1 -0
- package/esm/data/table/column-header/DataTableColumnHeader.d.ts +32 -0
- package/esm/data/table/column-header/DataTableColumnHeader.js +72 -0
- package/esm/data/table/column-header/DataTableColumnHeader.js.map +1 -0
- package/esm/data/table/column-header/useTableColumnResize.js.map +1 -0
- package/esm/data/table/empty-state/DataTableEmptyState.d.ts +6 -2
- package/esm/data/table/empty-state/DataTableEmptyState.js +2 -2
- package/esm/data/table/empty-state/DataTableEmptyState.js.map +1 -1
- package/esm/data/table/helpers/selection/getMultipleSelectProps.d.ts +10 -10
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js +29 -28
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/getSingleSelectProps.d.ts +7 -5
- package/esm/data/table/helpers/selection/getSingleSelectProps.js +8 -9
- package/esm/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/selection.types.d.ts +44 -21
- package/esm/data/table/hooks/useColumnOptions.d.ts +19 -0
- package/esm/data/table/hooks/useColumnOptions.js +17 -0
- package/esm/data/table/hooks/useColumnOptions.js.map +1 -0
- package/esm/data/table/hooks/useTableExpansion.d.ts +26 -0
- package/esm/data/table/hooks/useTableExpansion.js +31 -0
- package/esm/data/table/hooks/useTableExpansion.js.map +1 -0
- package/esm/data/table/hooks/useTableKeyboardNav.d.ts +2 -1
- package/esm/data/table/hooks/useTableKeyboardNav.js +4 -2
- package/esm/data/table/hooks/useTableKeyboardNav.js.map +1 -1
- package/esm/data/table/hooks/useTableSelection.d.ts +14 -7
- package/esm/data/table/hooks/useTableSelection.js +40 -29
- package/esm/data/table/hooks/useTableSelection.js.map +1 -1
- package/esm/data/table/hooks/useTableSort.d.ts +37 -0
- package/esm/data/table/hooks/useTableSort.js +47 -0
- package/esm/data/table/hooks/useTableSort.js.map +1 -0
- package/esm/data/table/loading-state/DataTableLoadingState.d.ts +6 -2
- package/esm/data/table/loading-state/DataTableLoadingState.js +2 -2
- package/esm/data/table/loading-state/DataTableLoadingState.js.map +1 -1
- package/esm/data/table/root/DataTable.types.d.ts +55 -4
- package/esm/data/table/root/DataTableAuto.d.ts +97 -1
- package/esm/data/table/root/DataTableAuto.js +94 -43
- package/esm/data/table/root/DataTableAuto.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.context.d.ts +22 -1
- package/esm/data/table/root/DataTableRoot.context.js +5 -1
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.d.ts +0 -6
- package/esm/data/table/root/DataTableRoot.js +6 -5
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/tbody/DataTableTbody.js +8 -2
- package/esm/data/table/tbody/DataTableTbody.js.map +1 -1
- package/esm/data/table/td/DataTableTd.d.ts +3 -19
- package/esm/data/table/td/DataTableTd.js +3 -5
- package/esm/data/table/td/DataTableTd.js.map +1 -1
- package/esm/data/table/tfoot/DataTableTfoot.js +3 -1
- package/esm/data/table/tfoot/DataTableTfoot.js.map +1 -1
- package/esm/data/table/th/DataTableTh.d.ts +3 -44
- package/esm/data/table/th/DataTableTh.js +4 -55
- package/esm/data/table/th/DataTableTh.js.map +1 -1
- package/esm/data/table/thead/DataTableThead.js +2 -2
- package/esm/data/table/thead/DataTableThead.js.map +1 -1
- package/esm/data/table/tr/DataTableTr.d.ts +8 -0
- package/esm/data/table/tr/DataTableTr.js +134 -12
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/data/token-filter/FilterChip.d.ts +10 -0
- package/esm/data/token-filter/FilterChip.js +30 -0
- package/esm/data/token-filter/FilterChip.js.map +1 -0
- package/esm/data/token-filter/TokenFilter.js +3 -10
- package/esm/data/token-filter/TokenFilter.js.map +1 -1
- package/esm/date/datepicker/hooks/useRangeDatepicker.js +1 -1
- package/esm/date/datepicker/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/datepicker/parts/DatePicker.DayButton.js +3 -1
- package/esm/date/datepicker/parts/DatePicker.DayButton.js.map +1 -1
- package/esm/date/datepicker/parts/DatePicker.RDP.d.ts +1 -1
- package/esm/date/datepicker/parts/DatePicker.RDP.js +27 -12
- package/esm/date/datepicker/parts/DatePicker.RDP.js.map +1 -1
- package/esm/date/monthpicker/parts/MonthPicker.Button.js +7 -5
- package/esm/date/monthpicker/parts/MonthPicker.Button.js.map +1 -1
- package/esm/date/monthpicker/parts/MonthPicker.Standalone.d.ts +1 -1
- package/esm/dialog/popup/DialogPopupInternal.js +1 -1
- package/esm/dialog/popup/DialogPopupInternal.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +19 -33
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.context.d.ts +6 -0
- package/esm/form/checkbox/CheckboxGroup.context.js +3 -0
- package/esm/form/checkbox/CheckboxGroup.context.js.map +1 -0
- package/esm/form/checkbox/CheckboxGroup.d.ts +0 -6
- package/esm/form/checkbox/CheckboxGroup.js +8 -8
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/checkbox/checkbox-input/CheckboxInput.d.ts +21 -0
- package/esm/form/checkbox/checkbox-input/CheckboxInput.js +29 -0
- package/esm/form/checkbox/checkbox-input/CheckboxInput.js.map +1 -0
- package/esm/form/checkbox/types.d.ts +1 -1
- package/esm/form/checkbox/useCheckbox.js +1 -1
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/combobox/ComboboxWrapper.js +1 -3
- package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
- package/esm/form/error-summary/ErrorSummary.js +1 -3
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/fieldset/Fieldset.d.ts +0 -4
- package/esm/form/fieldset/Fieldset.js +5 -9
- package/esm/form/fieldset/Fieldset.js.map +1 -1
- package/esm/form/fieldset/useFieldset.d.ts +5 -3
- package/esm/form/fieldset/useFieldset.js +10 -5
- package/esm/form/fieldset/useFieldset.js.map +1 -1
- package/esm/form/radio/Radio.js +9 -7
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/RadioGroup.context.d.ts +8 -0
- package/esm/form/radio/RadioGroup.context.js +3 -0
- package/esm/form/radio/RadioGroup.context.js.map +1 -0
- package/esm/form/radio/RadioGroup.d.ts +0 -8
- package/esm/form/radio/RadioGroup.js +9 -9
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/radio/radio-input/RadioInput.d.ts +19 -0
- package/esm/form/radio/radio-input/RadioInput.js +19 -0
- package/esm/form/radio/radio-input/RadioInput.js.map +1 -0
- package/esm/form/radio/useRadio.js +1 -1
- package/esm/form/radio/useRadio.js.map +1 -1
- package/esm/form/search/Search.js +1 -3
- package/esm/form/search/Search.js.map +1 -1
- package/esm/inline-message/root/InlineMessage.js +2 -5
- package/esm/inline-message/root/InlineMessage.js.map +1 -1
- package/esm/modal/Modal.js +1 -3
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalUtils.js +1 -1
- package/esm/modal/ModalUtils.js.map +1 -1
- package/esm/primitives/box/Box.d.ts +1 -1
- package/esm/process/Process.js +1 -5
- package/esm/process/Process.js.map +1 -1
- package/esm/tabs/useTabs.js +3 -7
- package/esm/tabs/useTabs.js.map +1 -1
- package/esm/timeline/Timeline.js +26 -63
- package/esm/timeline/Timeline.js.map +1 -1
- package/esm/timeline/TimelineRow.js +10 -14
- package/esm/timeline/TimelineRow.js.map +1 -1
- package/esm/timeline/hooks/TimelineKeyboardNavProvider.d.ts +16 -0
- package/esm/timeline/hooks/TimelineKeyboardNavProvider.js +141 -0
- package/esm/timeline/hooks/TimelineKeyboardNavProvider.js.map +1 -0
- package/esm/timeline/hooks/usePeriodContext.d.ts +0 -1
- package/esm/timeline/hooks/usePeriodContext.js +0 -1
- package/esm/timeline/hooks/usePeriodContext.js.map +1 -1
- package/esm/timeline/hooks/useRowContext.d.ts +0 -1
- package/esm/timeline/hooks/useRowContext.js +0 -1
- package/esm/timeline/hooks/useRowContext.js.map +1 -1
- package/esm/timeline/hooks/useTimelineContext.d.ts +0 -4
- package/esm/timeline/hooks/useTimelineContext.js +0 -4
- package/esm/timeline/hooks/useTimelineContext.js.map +1 -1
- package/esm/timeline/period/ClickablePeriod.js +7 -21
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/timeline/period/NonClickablePeriod.js +1 -1
- package/esm/timeline/period/NonClickablePeriod.js.map +1 -1
- package/esm/timeline/pin/PinInternal.js +10 -11
- package/esm/timeline/pin/PinInternal.js.map +1 -1
- package/esm/toggle-group/useToggleGroup.js +1 -1
- package/esm/toggle-group/useToggleGroup.js.map +1 -1
- package/esm/utils/components/HighlightText/HighlightText.js +1 -4
- package/esm/utils/components/HighlightText/HighlightText.js.map +1 -1
- package/esm/utils/components/dismissablelayer/DismissableLayer.js +1 -1
- package/esm/utils/components/dismissablelayer/DismissableLayer.js.map +1 -1
- package/esm/utils/helpers/create-strict-context.js +1 -1
- package/esm/utils/helpers/create-strict-context.js.map +1 -1
- package/esm/utils/hooks/useEventCallback.js +1 -1
- package/esm/utils/hooks/useEventCallback.js.map +1 -1
- package/esm/utils/hooks/useMedia.js +1 -1
- package/esm/utils/hooks/useMedia.js.map +1 -1
- package/package.json +9 -7
- package/src/alert/base-alert/content/BaseAlertContent.tsx +7 -2
- package/src/data/drag-and-drop/drag-handler/DragAndDropDragHandler.tsx +73 -29
- package/src/data/drag-and-drop/item/DragAndDropItem.tsx +28 -18
- package/src/data/drag-and-drop/root/DragAndDrop.context.tsx +4 -2
- package/src/data/drag-and-drop/root/DragAndDropRoot.tsx +303 -209
- package/src/data/drag-and-drop/types.ts +5 -0
- package/src/data/table/base-cell/DataTableBaseCell.tsx +92 -0
- package/src/data/table/column-header/DataTableColumnHeader.tsx +180 -0
- package/src/data/table/empty-state/DataTableEmptyState.tsx +5 -3
- package/src/data/table/helpers/selection/getMultipleSelectProps.ts +49 -45
- package/src/data/table/helpers/selection/getSingleSelectProps.ts +15 -13
- package/src/data/table/helpers/selection/selection.types.ts +46 -21
- package/src/data/table/hooks/__tests__/useTableSelection.test.ts +93 -56
- package/src/data/table/hooks/useColumnOptions.ts +48 -0
- package/src/data/table/hooks/useTableExpansion.tsx +100 -0
- package/src/data/table/hooks/useTableKeyboardNav.ts +7 -5
- package/src/data/table/hooks/useTableSelection.ts +77 -46
- package/src/data/table/hooks/useTableSort.ts +103 -0
- package/src/data/table/loading-state/DataTableLoadingState.tsx +5 -3
- package/src/data/table/root/DataTable.types.ts +64 -5
- package/src/data/table/root/DataTableAuto.tsx +383 -95
- package/src/data/table/root/DataTableRoot.context.ts +30 -1
- package/src/data/table/root/DataTableRoot.tsx +14 -11
- package/src/data/table/tbody/DataTableTbody.tsx +17 -6
- package/src/data/table/td/DataTableTd.tsx +10 -33
- package/src/data/table/tfoot/DataTableTfoot.tsx +10 -7
- package/src/data/table/th/DataTableTh.tsx +11 -172
- package/src/data/table/thead/DataTableThead.tsx +3 -3
- package/src/data/table/tr/DataTableTr.tsx +300 -11
- package/src/data/token-filter/FilterChip.tsx +100 -0
- package/src/data/token-filter/TokenFilter.tsx +8 -24
- package/src/date/datepicker/hooks/useRangeDatepicker.tsx +1 -1
- package/src/date/datepicker/parts/DatePicker.DayButton.tsx +2 -1
- package/src/date/datepicker/parts/DatePicker.RDP.tsx +34 -15
- package/src/date/monthpicker/parts/MonthPicker.Button.tsx +11 -9
- package/src/date/monthpicker/parts/MonthPicker.Standalone.tsx +1 -1
- package/src/dialog/popup/DialogPopupInternal.tsx +1 -1
- package/src/form/checkbox/Checkbox.tsx +37 -64
- package/src/form/checkbox/CheckboxGroup.context.ts +10 -0
- package/src/form/checkbox/CheckboxGroup.tsx +18 -28
- package/src/form/checkbox/checkbox-input/CheckboxInput.tsx +69 -0
- package/src/form/checkbox/types.ts +1 -1
- package/src/form/checkbox/useCheckbox.ts +1 -1
- package/src/form/fieldset/Fieldset.tsx +8 -14
- package/src/form/fieldset/useFieldset.ts +13 -6
- package/src/form/radio/Radio.tsx +43 -38
- package/src/form/radio/RadioGroup.context.ts +13 -0
- package/src/form/radio/RadioGroup.tsx +22 -31
- package/src/form/radio/radio-input/RadioInput.tsx +32 -0
- package/src/form/radio/useRadio.ts +1 -1
- package/src/inline-message/root/InlineMessage.tsx +3 -13
- package/src/modal/ModalUtils.ts +1 -1
- package/src/primitives/box/Box.tsx +1 -1
- package/src/tabs/useTabs.ts +3 -7
- package/src/timeline/Timeline.tsx +62 -91
- package/src/timeline/TimelineRow.tsx +19 -17
- package/src/timeline/hooks/TimelineKeyboardNavProvider.tsx +237 -0
- package/src/timeline/hooks/usePeriodContext.tsx +0 -2
- package/src/timeline/hooks/useRowContext.tsx +0 -2
- package/src/timeline/hooks/useTimelineContext.tsx +0 -8
- package/src/timeline/period/ClickablePeriod.tsx +8 -19
- package/src/timeline/period/NonClickablePeriod.tsx +2 -0
- package/src/timeline/pin/PinInternal.tsx +10 -13
- package/src/toggle-group/useToggleGroup.ts +1 -1
- package/src/utils/components/dismissablelayer/DismissableLayer.tsx +1 -1
- package/src/utils/helpers/create-strict-context.tsx +1 -1
- package/src/utils/hooks/useEventCallback.ts +1 -1
- package/src/utils/hooks/useMedia.ts +1 -1
- package/cjs/data/table/th/DataTableThActions.d.ts +0 -5
- package/cjs/data/table/th/DataTableThActions.js +0 -23
- package/cjs/data/table/th/DataTableThActions.js.map +0 -1
- package/cjs/data/table/th/useTableColumnResize.js.map +0 -1
- package/cjs/data/table/thead/DataTableThead.context.d.ts +0 -4
- package/cjs/data/table/thead/DataTableThead.context.js.map +0 -1
- package/esm/data/table/th/DataTableThActions.d.ts +0 -5
- package/esm/data/table/th/DataTableThActions.js +0 -18
- package/esm/data/table/th/DataTableThActions.js.map +0 -1
- package/esm/data/table/th/useTableColumnResize.js.map +0 -1
- package/esm/data/table/thead/DataTableThead.context.d.ts +0 -4
- package/esm/data/table/thead/DataTableThead.context.js +0 -8
- package/esm/data/table/thead/DataTableThead.context.js.map +0 -1
- package/src/data/table/th/DataTableThActions.tsx +0 -32
- package/src/data/table/thead/DataTableThead.context.ts +0 -10
- /package/cjs/data/table/{th → column-header}/useTableColumnResize.d.ts +0 -0
- /package/cjs/data/table/{th → column-header}/useTableColumnResize.js +0 -0
- /package/esm/data/table/{th → column-header}/useTableColumnResize.d.ts +0 -0
- /package/esm/data/table/{th → column-header}/useTableColumnResize.js +0 -0
- /package/src/data/table/{th → column-header}/useTableColumnResize.ts +0 -0
|
@@ -1,44 +1,21 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { cl } from "../../../utils/helpers";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
DataTableBaseCell,
|
|
5
|
+
type DataTableBaseCellProps,
|
|
6
|
+
} from "../base-cell/DataTableBaseCell";
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Sets a max-width on the content wrapper div inside the cell.
|
|
8
|
-
* This is only needed when using `layout="auto"` together with
|
|
9
|
-
* `truncateContent` on `<DataTable>` and you want the cell to be truncated.
|
|
10
|
-
*/
|
|
11
|
-
contentMaxWidth?: number | `${number}${string}`;
|
|
12
|
-
/**
|
|
13
|
-
* TODO: Consider a prop like this instead of contentMaxWidth to use together with layout=auto.
|
|
14
|
-
* Maybe even with layout=auto as a way to override truncateContent on single cells?
|
|
15
|
-
* Need to work on the name though. Or maybe have two separate props?
|
|
16
|
-
*/
|
|
17
|
-
//textWrap?: boolean | number | `${number}${string}`;
|
|
18
|
-
/**
|
|
19
|
-
* Content alignment inside cell
|
|
20
|
-
* @default "left"
|
|
21
|
-
*/
|
|
22
|
-
textAlign?: "left" | "center" | "right";
|
|
23
|
-
}
|
|
8
|
+
type DataTableTdProps = DataTableBaseCellProps;
|
|
24
9
|
|
|
25
10
|
const DataTableTd = forwardRef<HTMLTableCellElement, DataTableTdProps>(
|
|
26
|
-
(
|
|
27
|
-
{ className, children, contentMaxWidth, textAlign = "left", ...rest },
|
|
28
|
-
forwardedRef,
|
|
29
|
-
) => {
|
|
30
|
-
const { withKeyboardNav } = useDataTableContext();
|
|
31
|
-
|
|
11
|
+
({ className, ...rest }, forwardedRef) => {
|
|
32
12
|
return (
|
|
33
|
-
<
|
|
34
|
-
{...rest}
|
|
13
|
+
<DataTableBaseCell
|
|
35
14
|
ref={forwardedRef}
|
|
15
|
+
{...rest}
|
|
16
|
+
as="td"
|
|
36
17
|
className={cl("aksel-data-table__td", className)}
|
|
37
|
-
|
|
38
|
-
data-align={textAlign}
|
|
39
|
-
>
|
|
40
|
-
<div style={{ maxWidth: contentMaxWidth }}>{children}</div>
|
|
41
|
-
</td>
|
|
18
|
+
/>
|
|
42
19
|
);
|
|
43
20
|
},
|
|
44
21
|
);
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { cl } from "../../../utils/helpers";
|
|
3
|
+
import { DataTableLocationProvider } from "../root/DataTableRoot.context";
|
|
3
4
|
|
|
4
5
|
type DataTableTfootProps = React.HTMLAttributes<HTMLTableSectionElement>;
|
|
5
6
|
|
|
6
7
|
const DataTableTfoot = forwardRef<HTMLTableSectionElement, DataTableTfootProps>(
|
|
7
8
|
({ className, children, ...rest }, forwardedRef) => {
|
|
8
9
|
return (
|
|
9
|
-
<tfoot
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
<DataTableLocationProvider location="tfoot">
|
|
11
|
+
<tfoot
|
|
12
|
+
{...rest}
|
|
13
|
+
ref={forwardedRef}
|
|
14
|
+
className={cl("aksel-data-table__tfoot", className)}
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</tfoot>
|
|
18
|
+
</DataTableLocationProvider>
|
|
16
19
|
);
|
|
17
20
|
},
|
|
18
21
|
);
|
|
@@ -1,185 +1,24 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
2
|
-
import {
|
|
3
|
-
ArrowsUpDownIcon,
|
|
4
|
-
CaretLeftCircleFillIcon,
|
|
5
|
-
CaretRightCircleFillIcon,
|
|
6
|
-
SortDownIcon,
|
|
7
|
-
SortUpIcon,
|
|
8
|
-
} from "@navikt/aksel-icons";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
9
2
|
import { cl } from "../../../utils/helpers";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type SortDirection = "asc" | "desc" | "none";
|
|
15
|
-
|
|
16
|
-
interface DataTableThProps
|
|
17
|
-
extends React.HTMLAttributes<HTMLTableCellElement>, ResizeProps {
|
|
18
|
-
resizeHandler?: (
|
|
19
|
-
event:
|
|
20
|
-
| React.MouseEvent<HTMLButtonElement>
|
|
21
|
-
| React.TouchEvent<HTMLButtonElement>,
|
|
22
|
-
) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Content alignment inside cell
|
|
25
|
-
* @default "left"
|
|
26
|
-
*/
|
|
27
|
-
textAlign?: "left" | "center" | "right";
|
|
28
|
-
/**
|
|
29
|
-
* Makes the column header sortable. The entire header cell content becomes
|
|
30
|
-
* a clickable button when true.
|
|
31
|
-
*/
|
|
32
|
-
sortable?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Current sort direction. Only relevant when `sortable` is true.
|
|
35
|
-
* Uses values matching the `aria-sort` attribute directly.
|
|
36
|
-
* @default "none"
|
|
37
|
-
*/
|
|
38
|
-
sortDirection?: SortDirection;
|
|
39
|
-
/**
|
|
40
|
-
* Called when the user clicks the sortable header.
|
|
41
|
-
* The consumer is responsible for determining and setting the next sort state.
|
|
42
|
-
*/
|
|
43
|
-
onSortClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
44
|
-
render?: {
|
|
45
|
-
filterMenu?: {
|
|
46
|
-
title: string;
|
|
47
|
-
content: React.ReactNode;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* TODO: Shouldnt be needed to declare these here... But getting type-errors if not
|
|
52
|
-
*/
|
|
53
|
-
colSpan?: number;
|
|
54
|
-
rowSpan?: number;
|
|
55
|
-
}
|
|
3
|
+
import {
|
|
4
|
+
DataTableBaseCell,
|
|
5
|
+
type DataTableBaseCellProps,
|
|
6
|
+
} from "../base-cell/DataTableBaseCell";
|
|
56
7
|
|
|
57
|
-
|
|
58
|
-
asc: SortUpIcon,
|
|
59
|
-
desc: SortDownIcon,
|
|
60
|
-
none: ArrowsUpDownIcon,
|
|
61
|
-
};
|
|
8
|
+
type DataTableThProps = DataTableBaseCellProps;
|
|
62
9
|
|
|
63
|
-
/**
|
|
64
|
-
* TODO:
|
|
65
|
-
* - Plan for pinning: Move it into "settings" dialog like here: https://cloudscape.design/examples/react/table.html
|
|
66
|
-
* - Keyboard-nav breaks in headers now because of the resize-handles.
|
|
67
|
-
* Toggling `data-block-keyboard-nav` does not work since the created "grid" does not update when toggling this attribute.
|
|
68
|
-
*/
|
|
69
10
|
const DataTableTh = forwardRef<HTMLTableCellElement, DataTableThProps>(
|
|
70
|
-
(
|
|
71
|
-
{
|
|
72
|
-
className,
|
|
73
|
-
children,
|
|
74
|
-
sortable = false,
|
|
75
|
-
sortDirection = "none",
|
|
76
|
-
onSortClick,
|
|
77
|
-
style,
|
|
78
|
-
textAlign = "left",
|
|
79
|
-
width,
|
|
80
|
-
minWidth,
|
|
81
|
-
maxWidth,
|
|
82
|
-
onWidthChange,
|
|
83
|
-
defaultWidth,
|
|
84
|
-
colSpan,
|
|
85
|
-
...rest
|
|
86
|
-
},
|
|
87
|
-
forwardedRef,
|
|
88
|
-
) => {
|
|
89
|
-
const { withKeyboardNav } = useDataTableContext();
|
|
90
|
-
const [isOverflowing, setIsOverflowing] = React.useState(false);
|
|
91
|
-
const contentRef = React.useRef<HTMLDivElement>(null);
|
|
92
|
-
const [thRefState, setThRefState] = useState<HTMLTableCellElement | null>(
|
|
93
|
-
null,
|
|
94
|
-
);
|
|
95
|
-
const mergedRef = useMergeRefs(forwardedRef, setThRefState);
|
|
96
|
-
|
|
97
|
-
const resizeResult = useTableColumnResize({
|
|
98
|
-
ref: thRefState,
|
|
99
|
-
width,
|
|
100
|
-
defaultWidth,
|
|
101
|
-
minWidth,
|
|
102
|
-
maxWidth,
|
|
103
|
-
onWidthChange,
|
|
104
|
-
style,
|
|
105
|
-
colSpan,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const SortIcon = sortable ? SORT_ICON[sortDirection] : null;
|
|
109
|
-
|
|
11
|
+
({ className, ...rest }, forwardedRef) => {
|
|
110
12
|
return (
|
|
111
|
-
<
|
|
13
|
+
<DataTableBaseCell
|
|
14
|
+
ref={forwardedRef}
|
|
112
15
|
{...rest}
|
|
113
|
-
|
|
16
|
+
as="th"
|
|
114
17
|
className={cl("aksel-data-table__th", className)}
|
|
115
|
-
|
|
116
|
-
style={resizeResult.style}
|
|
117
|
-
aria-sort={sortable ? getAriaSort(sortDirection) : undefined}
|
|
118
|
-
onPointerEnter={() => {
|
|
119
|
-
const el = contentRef.current;
|
|
120
|
-
setIsOverflowing(el ? el.scrollWidth > el.offsetWidth : false);
|
|
121
|
-
console.info("is overflowing", isOverflowing);
|
|
122
|
-
}}
|
|
123
|
-
onPointerLeave={() => setIsOverflowing(false)}
|
|
124
|
-
tabIndex={withKeyboardNav ? -1 : undefined}
|
|
125
|
-
data-align={textAlign}
|
|
126
|
-
colSpan={colSpan}
|
|
127
|
-
>
|
|
128
|
-
{sortable ? (
|
|
129
|
-
<button
|
|
130
|
-
className="aksel-data-table__th-sort-button"
|
|
131
|
-
onClick={sortable ? onSortClick : undefined}
|
|
132
|
-
>
|
|
133
|
-
<div ref={contentRef} className="aksel-data-table__th-content">
|
|
134
|
-
{children}
|
|
135
|
-
</div>
|
|
136
|
-
{SortIcon && (
|
|
137
|
-
<SortIcon
|
|
138
|
-
aria-hidden
|
|
139
|
-
data-sort-direction={sortDirection}
|
|
140
|
-
className="aksel-data-table__th-sort-icon"
|
|
141
|
-
fontSize="1.25rem"
|
|
142
|
-
/>
|
|
143
|
-
)}
|
|
144
|
-
</button>
|
|
145
|
-
) : (
|
|
146
|
-
<div ref={contentRef} className="aksel-data-table__th-content">
|
|
147
|
-
{children}
|
|
148
|
-
</div>
|
|
149
|
-
)}
|
|
150
|
-
|
|
151
|
-
{resizeResult.enabled && (
|
|
152
|
-
<button
|
|
153
|
-
{...resizeResult.resizeHandlerProps}
|
|
154
|
-
className="aksel-data-table__th-resize-handle"
|
|
155
|
-
data-active={resizeResult.isResizingWithKeyboard}
|
|
156
|
-
data-block-keyboard-nav
|
|
157
|
-
>
|
|
158
|
-
{resizeResult.isResizingWithKeyboard && (
|
|
159
|
-
<>
|
|
160
|
-
<span className="aksel-data-table__th-resize-handle-indicator aksel-data-table__th-resize-handle-indicator--start">
|
|
161
|
-
<CaretLeftCircleFillIcon aria-hidden fontSize="1.5rem" />
|
|
162
|
-
</span>
|
|
163
|
-
<span className="aksel-data-table__th-resize-handle-indicator aksel-data-table__th-resize-handle-indicator--end">
|
|
164
|
-
<CaretRightCircleFillIcon aria-hidden fontSize="1.5rem" />
|
|
165
|
-
</span>
|
|
166
|
-
</>
|
|
167
|
-
)}
|
|
168
|
-
</button>
|
|
169
|
-
)}
|
|
170
|
-
</th>
|
|
18
|
+
/>
|
|
171
19
|
);
|
|
172
20
|
},
|
|
173
21
|
);
|
|
174
22
|
|
|
175
|
-
function getAriaSort(
|
|
176
|
-
sortDirection: SortDirection | undefined,
|
|
177
|
-
): "ascending" | "descending" | "none" | undefined {
|
|
178
|
-
if (sortDirection === "asc") return "ascending";
|
|
179
|
-
if (sortDirection === "desc") return "descending";
|
|
180
|
-
if (sortDirection === "none") return "none";
|
|
181
|
-
return undefined;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
23
|
export { DataTableTh };
|
|
185
24
|
export type { DataTableThProps };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { cl } from "../../../utils/helpers";
|
|
3
|
-
import {
|
|
3
|
+
import { DataTableLocationProvider } from "../root/DataTableRoot.context";
|
|
4
4
|
|
|
5
5
|
type DataTableTheadProps = React.HTMLAttributes<HTMLTableSectionElement>;
|
|
6
6
|
|
|
7
7
|
const DataTableThead = forwardRef<HTMLTableSectionElement, DataTableTheadProps>(
|
|
8
8
|
({ className, ...rest }, forwardedRef) => {
|
|
9
9
|
return (
|
|
10
|
-
<
|
|
10
|
+
<DataTableLocationProvider location="thead">
|
|
11
11
|
<thead
|
|
12
12
|
{...rest}
|
|
13
13
|
ref={forwardedRef}
|
|
14
14
|
className={cl("aksel-data-table__thead", className)}
|
|
15
15
|
/>
|
|
16
|
-
</
|
|
16
|
+
</DataTableLocationProvider>
|
|
17
17
|
);
|
|
18
18
|
},
|
|
19
19
|
);
|
|
@@ -1,32 +1,116 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import React, { forwardRef, useCallback } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ChevronDownUpIcon,
|
|
4
|
+
ChevronUpDownIcon,
|
|
5
|
+
MinusIcon,
|
|
6
|
+
PlusIcon,
|
|
7
|
+
} from "@navikt/aksel-icons";
|
|
8
|
+
import { Button } from "../../../button";
|
|
9
|
+
import { CheckboxInput } from "../../../form/checkbox/checkbox-input/CheckboxInput";
|
|
10
|
+
import { RadioInput } from "../../../form/radio/radio-input/RadioInput";
|
|
11
|
+
import { Skeleton } from "../../../skeleton";
|
|
12
|
+
import { Label } from "../../../typography";
|
|
13
|
+
import { useId } from "../../../utils-external";
|
|
14
|
+
import { cl, composeEventHandlers } from "../../../utils/helpers";
|
|
15
|
+
import { DataTableBaseCell } from "../base-cell/DataTableBaseCell";
|
|
16
|
+
import { DataTableColumnHeader } from "../column-header/DataTableColumnHeader";
|
|
17
|
+
import { useDataTableExpansion } from "../hooks/useTableExpansion";
|
|
18
|
+
import {
|
|
19
|
+
useDataTableContext,
|
|
20
|
+
useDataTableLocation,
|
|
21
|
+
} from "../root/DataTableRoot.context";
|
|
22
|
+
import { DataTableTd } from "../td/DataTableTd";
|
|
23
|
+
|
|
24
|
+
const SELECTION_CELL_WIDTH = "50px";
|
|
4
25
|
|
|
5
26
|
type DataTableTrProps = React.HTMLAttributes<HTMLTableRowElement> & {
|
|
6
27
|
selected?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Unique identifier for the row, used for selection..
|
|
30
|
+
*/
|
|
31
|
+
rowId?: string | number;
|
|
7
32
|
};
|
|
8
33
|
|
|
9
34
|
const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
10
|
-
(
|
|
11
|
-
|
|
35
|
+
(
|
|
36
|
+
{
|
|
37
|
+
className,
|
|
38
|
+
children,
|
|
39
|
+
selected: selectedProp = false,
|
|
40
|
+
rowId,
|
|
41
|
+
onClick,
|
|
42
|
+
...rest
|
|
43
|
+
},
|
|
44
|
+
forwardedRef,
|
|
45
|
+
) => {
|
|
46
|
+
const {
|
|
47
|
+
layout,
|
|
48
|
+
stickyHeader,
|
|
49
|
+
selectionState,
|
|
50
|
+
onRowClick,
|
|
51
|
+
disableRowSelectionOnClick,
|
|
52
|
+
} = useDataTableContext();
|
|
53
|
+
const { location } = useDataTableLocation();
|
|
12
54
|
|
|
13
55
|
const renderFillerCell = layout === "fixed" && children;
|
|
14
56
|
|
|
57
|
+
const selected =
|
|
58
|
+
selectionState.selection.isRowSelected(rowId ?? "") ?? selectedProp;
|
|
59
|
+
|
|
60
|
+
const isSticky = location === "thead" && stickyHeader;
|
|
61
|
+
|
|
62
|
+
const handleClick = useCallback(
|
|
63
|
+
(event: React.MouseEvent<HTMLTableRowElement>) => {
|
|
64
|
+
if (
|
|
65
|
+
location !== "tbody" ||
|
|
66
|
+
rowId === undefined ||
|
|
67
|
+
isInteractiveTarget(event.target) ||
|
|
68
|
+
(event.target as HTMLElement | null)?.closest(
|
|
69
|
+
"[data-prevent-row-click]",
|
|
70
|
+
)
|
|
71
|
+
) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const selection = window.getSelection();
|
|
76
|
+
if (selection && selection.toString().length > 0) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (
|
|
81
|
+
!disableRowSelectionOnClick &&
|
|
82
|
+
selectionState.selection.selectionMode !== "none"
|
|
83
|
+
) {
|
|
84
|
+
selectionState.selection.toggleSelection(rowId);
|
|
85
|
+
}
|
|
86
|
+
onRowClick?.(rowId, event);
|
|
87
|
+
},
|
|
88
|
+
[
|
|
89
|
+
disableRowSelectionOnClick,
|
|
90
|
+
location,
|
|
91
|
+
onRowClick,
|
|
92
|
+
rowId,
|
|
93
|
+
selectionState.selection,
|
|
94
|
+
],
|
|
95
|
+
);
|
|
96
|
+
|
|
15
97
|
return (
|
|
16
98
|
<tr
|
|
17
99
|
{...rest}
|
|
100
|
+
onClick={composeEventHandlers(onClick, handleClick)}
|
|
18
101
|
ref={forwardedRef}
|
|
19
|
-
className={cl("aksel-data-table__tr", className
|
|
20
|
-
|
|
21
|
-
}
|
|
102
|
+
className={cl("aksel-data-table__tr", className)}
|
|
103
|
+
data-selected={selected}
|
|
104
|
+
data-sticky={isSticky || undefined}
|
|
22
105
|
>
|
|
106
|
+
<RowExpansionCell rowId={rowId} />
|
|
107
|
+
<RowSelectionCell rowId={rowId} />
|
|
23
108
|
{children}
|
|
24
109
|
{renderFillerCell && (
|
|
25
|
-
/*
|
|
26
|
-
/* using div causes illegal dom structure */
|
|
110
|
+
/* Using div causes illegal dom structure */
|
|
27
111
|
<td
|
|
28
112
|
aria-hidden
|
|
29
|
-
className="aksel-data-
|
|
113
|
+
className="aksel-data-table__cell aksel-data-table__filler-cell"
|
|
30
114
|
data-block-keyboard-nav
|
|
31
115
|
/>
|
|
32
116
|
)}
|
|
@@ -35,5 +119,210 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
35
119
|
},
|
|
36
120
|
);
|
|
37
121
|
|
|
122
|
+
function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
123
|
+
const { tableId, showLoadingSkeletons } = useDataTableContext();
|
|
124
|
+
const { location } = useDataTableLocation();
|
|
125
|
+
const expansionContext = useDataTableExpansion(false);
|
|
126
|
+
|
|
127
|
+
if (!expansionContext) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const {
|
|
132
|
+
isExpanded,
|
|
133
|
+
toggleExpansion,
|
|
134
|
+
enableExpansion,
|
|
135
|
+
isAllExpanded,
|
|
136
|
+
toggleAll,
|
|
137
|
+
showExpandAll,
|
|
138
|
+
} = expansionContext;
|
|
139
|
+
|
|
140
|
+
if (!enableExpansion) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (showLoadingSkeletons) {
|
|
145
|
+
if (location === "thead") {
|
|
146
|
+
return (
|
|
147
|
+
<DataTableColumnHeader
|
|
148
|
+
width={SELECTION_CELL_WIDTH}
|
|
149
|
+
UNSAFE_isSelection
|
|
150
|
+
data-block-keyboard-nav
|
|
151
|
+
/* isSticky={stickySelection && "start"} */
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
return (
|
|
156
|
+
<DataTableBaseCell as="td">
|
|
157
|
+
<Skeleton variant="text" />
|
|
158
|
+
</DataTableBaseCell>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (location === "thead" && !showExpandAll) {
|
|
163
|
+
return (
|
|
164
|
+
<DataTableColumnHeader
|
|
165
|
+
width={SELECTION_CELL_WIDTH}
|
|
166
|
+
UNSAFE_isSelection
|
|
167
|
+
data-block-keyboard-nav
|
|
168
|
+
/* isSticky={stickySelection && "start"} */
|
|
169
|
+
/>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (location === "thead") {
|
|
174
|
+
return (
|
|
175
|
+
<DataTableColumnHeader
|
|
176
|
+
textAlign="center"
|
|
177
|
+
width={SELECTION_CELL_WIDTH}
|
|
178
|
+
UNSAFE_isSelection
|
|
179
|
+
/* isSticky={stickySelection && "start"} */
|
|
180
|
+
>
|
|
181
|
+
<Button
|
|
182
|
+
variant="tertiary"
|
|
183
|
+
data-color="neutral"
|
|
184
|
+
size="xsmall"
|
|
185
|
+
onClick={toggleAll}
|
|
186
|
+
aria-expanded={isAllExpanded}
|
|
187
|
+
aria-label={isAllExpanded ? "Skjul alle rader" : "Vis alle rader"}
|
|
188
|
+
icon={
|
|
189
|
+
isAllExpanded ? (
|
|
190
|
+
<ChevronDownUpIcon aria-hidden />
|
|
191
|
+
) : (
|
|
192
|
+
<ChevronUpDownIcon aria-hidden />
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
/>
|
|
196
|
+
</DataTableColumnHeader>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (!rowId) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const isRowExpanded = isExpanded(rowId);
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<DataTableTd UNSAFE_isSelection preventRowClick>
|
|
208
|
+
<Button
|
|
209
|
+
variant="tertiary"
|
|
210
|
+
data-color="neutral"
|
|
211
|
+
size="xsmall"
|
|
212
|
+
onClick={(e) => {
|
|
213
|
+
e.stopPropagation();
|
|
214
|
+
toggleExpansion(rowId);
|
|
215
|
+
}}
|
|
216
|
+
aria-expanded={isRowExpanded}
|
|
217
|
+
aria-controls={`${tableId}-expansion-${rowId}`}
|
|
218
|
+
aria-label={isRowExpanded ? "Skjul detaljer" : "Vis detaljer"}
|
|
219
|
+
icon={
|
|
220
|
+
isRowExpanded ? <MinusIcon aria-hidden /> : <PlusIcon aria-hidden />
|
|
221
|
+
}
|
|
222
|
+
/>
|
|
223
|
+
</DataTableTd>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* TODO: How do these cells handle multiple thead rows, or col/rowspans?
|
|
229
|
+
* TODO: a11y for labels
|
|
230
|
+
*/
|
|
231
|
+
function RowSelectionCell({ rowId }: { rowId?: string | number }) {
|
|
232
|
+
const { selectionState, stickySelection, showLoadingSkeletons } =
|
|
233
|
+
useDataTableContext();
|
|
234
|
+
const { location } = useDataTableLocation();
|
|
235
|
+
const inputId = useId();
|
|
236
|
+
|
|
237
|
+
const { selection, renderSelection } = selectionState;
|
|
238
|
+
|
|
239
|
+
if (selection.selectionMode === "none" || !renderSelection) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (showLoadingSkeletons) {
|
|
244
|
+
if (location === "thead") {
|
|
245
|
+
return (
|
|
246
|
+
<DataTableColumnHeader
|
|
247
|
+
width={SELECTION_CELL_WIDTH}
|
|
248
|
+
UNSAFE_isSelection
|
|
249
|
+
data-block-keyboard-nav
|
|
250
|
+
isSticky={stickySelection && "start"}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<DataTableBaseCell as="td">
|
|
257
|
+
<Skeleton variant="text" />
|
|
258
|
+
</DataTableBaseCell>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* TODO: A11y support */
|
|
263
|
+
if (selection.selectionMode === "multiple" && location === "thead") {
|
|
264
|
+
const theadCheckboxProps = selection.getTheadCheckboxProps();
|
|
265
|
+
|
|
266
|
+
let labelText = "Velg alle synlige rader";
|
|
267
|
+
if (theadCheckboxProps.checked) {
|
|
268
|
+
labelText = "Fjern alle synlige valgte rader";
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return (
|
|
272
|
+
<DataTableColumnHeader
|
|
273
|
+
textAlign="center"
|
|
274
|
+
width={SELECTION_CELL_WIDTH}
|
|
275
|
+
UNSAFE_isSelection
|
|
276
|
+
isSticky={stickySelection && "start"}
|
|
277
|
+
>
|
|
278
|
+
<Label htmlFor={inputId} visuallyHidden>
|
|
279
|
+
{labelText}
|
|
280
|
+
</Label>
|
|
281
|
+
<CheckboxInput {...theadCheckboxProps} id={inputId} compact />
|
|
282
|
+
</DataTableColumnHeader>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (selection.selectionMode === "single" && location === "thead") {
|
|
287
|
+
return (
|
|
288
|
+
<DataTableColumnHeader
|
|
289
|
+
width={SELECTION_CELL_WIDTH}
|
|
290
|
+
UNSAFE_isSelection
|
|
291
|
+
data-block-keyboard-nav
|
|
292
|
+
isSticky={stickySelection && "start"}
|
|
293
|
+
/>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (rowId == null) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (selection.selectionMode === "multiple" && location === "tbody") {
|
|
302
|
+
return (
|
|
303
|
+
<DataTableTd UNSAFE_isSelection isSticky={stickySelection && "start"}>
|
|
304
|
+
<CheckboxInput {...selection.getRowCheckboxProps(rowId)} compact />
|
|
305
|
+
</DataTableTd>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (selection.selectionMode === "single" && location === "tbody") {
|
|
310
|
+
return (
|
|
311
|
+
<DataTableTd UNSAFE_isSelection isSticky={stickySelection && "start"}>
|
|
312
|
+
<RadioInput {...selection.getRowRadioProps(rowId)} />
|
|
313
|
+
</DataTableTd>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/* Utils */
|
|
321
|
+
function isInteractiveTarget(target: EventTarget | null): boolean {
|
|
322
|
+
return !!(target as HTMLElement | null)?.closest(
|
|
323
|
+
"a, button, input, select, textarea",
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
38
327
|
export { DataTableTr };
|
|
39
328
|
export type { DataTableTrProps };
|