@navikt/ds-react 8.7.0 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/alert/base-alert/root/BaseAlertRoot.js +1 -2
- package/cjs/alert/base-alert/root/BaseAlertRoot.js.map +1 -1
- package/cjs/alert/info-card/index.d.ts +2 -2
- package/cjs/alert/info-card/index.js +2 -1
- package/cjs/alert/info-card/index.js.map +1 -1
- package/cjs/alert/info-card/message/InfoCardMessage.d.ts +23 -0
- package/cjs/alert/info-card/message/InfoCardMessage.js +73 -0
- package/cjs/alert/info-card/message/InfoCardMessage.js.map +1 -0
- package/cjs/alert/info-card/root/InfoCardRoot.d.ts +15 -2
- package/cjs/alert/info-card/root/InfoCardRoot.js +4 -1
- package/cjs/alert/info-card/root/InfoCardRoot.js.map +1 -1
- package/cjs/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.d.ts +21 -0
- package/cjs/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.js +24 -0
- package/cjs/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.js.map +1 -0
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js +7 -57
- package/cjs/data/drag-and-drop/item/DataDragAndDropItem.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.d.ts +4 -1
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js +7 -3
- package/cjs/data/drag-and-drop/root/DataDragAndDrop.context.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.d.ts +12 -2
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js +14 -64
- package/cjs/data/drag-and-drop/root/DataDragAndDropRoot.js.map +1 -1
- package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.d.ts +22 -0
- package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js +35 -0
- package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js.map +1 -0
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.d.ts +27 -0
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.js +86 -0
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +1 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.d.ts +5 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js +6 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +1 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.d.ts +24 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.js +108 -0
- package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.js.map +1 -0
- package/cjs/data/table/empty-state/DataTableEmptyState.d.ts +5 -0
- package/cjs/data/table/empty-state/DataTableEmptyState.js +57 -0
- package/cjs/data/table/empty-state/DataTableEmptyState.js.map +1 -0
- package/cjs/data/table/helpers/table-focus.js +7 -1
- package/cjs/data/table/helpers/table-focus.js.map +1 -1
- package/cjs/data/table/helpers/table-keyboard.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/loading-state/DataTableLoadingState.d.ts +5 -0
- package/cjs/data/table/loading-state/DataTableLoadingState.js +57 -0
- package/cjs/data/table/loading-state/DataTableLoadingState.js.map +1 -0
- package/cjs/data/table/root/DataTable.types.d.ts +13 -0
- package/cjs/data/table/root/DataTable.types.js +3 -0
- package/cjs/data/table/root/DataTable.types.js.map +1 -0
- package/cjs/data/table/root/DataTableAuto.d.ts +60 -0
- package/cjs/data/table/root/DataTableAuto.js +99 -0
- package/cjs/data/table/root/DataTableAuto.js.map +1 -0
- package/cjs/data/table/root/DataTableRoot.context.d.ts +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 +8 -2
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/root/useTableKeyboardNav.js +1 -0
- package/cjs/data/table/root/useTableKeyboardNav.js.map +1 -1
- package/cjs/data/table/root/useTableSelection.d.ts +55 -0
- package/cjs/data/table/root/useTableSelection.js +79 -0
- package/cjs/data/table/root/useTableSelection.js.map +1 -0
- package/cjs/data/table/td/DataTableTd.d.ts +10 -0
- package/cjs/data/table/td/DataTableTd.js +4 -2
- package/cjs/data/table/td/DataTableTd.js.map +1 -1
- package/cjs/data/table/th/DataTableTh.d.ts +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 +4 -6
- package/cjs/data/token-filter/AutoSuggest.js.map +1 -1
- package/cjs/date/Date.Input.js +1 -1
- package/cjs/date/Date.Input.js.map +1 -1
- package/cjs/date/datepicker/hooks/useDatepicker.d.ts +12 -1
- 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.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/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/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/DataDragAndDropDragHandler.d.ts +21 -0
- package/esm/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.js +18 -0
- package/esm/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.js.map +1 -0
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js +4 -24
- package/esm/data/drag-and-drop/item/DataDragAndDropItem.js.map +1 -1
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.d.ts +4 -1
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js +5 -2
- package/esm/data/drag-and-drop/root/DataDragAndDrop.context.js.map +1 -1
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.d.ts +12 -2
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js +15 -65
- package/esm/data/drag-and-drop/root/DataDragAndDropRoot.js.map +1 -1
- package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.d.ts +22 -0
- package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js +29 -0
- package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js.map +1 -0
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.d.ts +27 -0
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.js +50 -0
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +1 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.d.ts +5 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js +3 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +1 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.d.ts +24 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.js +68 -0
- package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.js.map +1 -0
- package/esm/data/table/empty-state/DataTableEmptyState.d.ts +5 -0
- package/esm/data/table/empty-state/DataTableEmptyState.js +21 -0
- package/esm/data/table/empty-state/DataTableEmptyState.js.map +1 -0
- package/esm/data/table/helpers/table-focus.js +7 -1
- package/esm/data/table/helpers/table-focus.js.map +1 -1
- package/esm/data/table/helpers/table-keyboard.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/loading-state/DataTableLoadingState.d.ts +5 -0
- package/esm/data/table/loading-state/DataTableLoadingState.js +21 -0
- package/esm/data/table/loading-state/DataTableLoadingState.js.map +1 -0
- package/esm/data/table/root/DataTable.types.d.ts +13 -0
- package/esm/data/table/root/DataTable.types.js +2 -0
- package/esm/data/table/root/DataTable.types.js.map +1 -0
- package/esm/data/table/root/DataTableAuto.d.ts +60 -0
- package/esm/data/table/root/DataTableAuto.js +63 -0
- package/esm/data/table/root/DataTableAuto.js.map +1 -0
- package/esm/data/table/root/DataTableRoot.context.d.ts +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 +6 -2
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/root/useTableKeyboardNav.js +1 -0
- package/esm/data/table/root/useTableKeyboardNav.js.map +1 -1
- package/esm/data/table/root/useTableSelection.d.ts +55 -0
- package/esm/data/table/root/useTableSelection.js +77 -0
- package/esm/data/table/root/useTableSelection.js.map +1 -0
- package/esm/data/table/td/DataTableTd.d.ts +10 -0
- package/esm/data/table/td/DataTableTd.js +4 -2
- package/esm/data/table/td/DataTableTd.js.map +1 -1
- package/esm/data/table/th/DataTableTh.d.ts +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 +4 -6
- package/esm/data/token-filter/AutoSuggest.js.map +1 -1
- package/esm/date/Date.Input.js +1 -1
- package/esm/date/Date.Input.js.map +1 -1
- package/esm/date/datepicker/hooks/useDatepicker.d.ts +12 -1
- 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.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/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/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 +5 -5
- package/src/alert/base-alert/root/BaseAlertRoot.tsx +1 -1
- package/src/alert/info-card/index.ts +2 -0
- package/src/alert/info-card/message/InfoCardMessage.tsx +48 -0
- package/src/alert/info-card/root/InfoCardRoot.tsx +20 -1
- package/src/data/drag-and-drop/drag-handler/DataDragAndDropDragHandler.tsx +63 -0
- package/src/data/drag-and-drop/item/DataDragAndDropItem.tsx +6 -53
- package/src/data/drag-and-drop/root/DataDragAndDrop.context.tsx +9 -4
- package/src/data/drag-and-drop/root/DataDragAndDropRoot.tsx +19 -63
- package/src/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.tsx +104 -0
- package/src/data/drag-and-drop-old/item/DataDragAndDropItem.tsx +74 -0
- package/src/data/drag-and-drop-old/root/DataDragAndDrop.context.tsx +11 -0
- package/src/data/drag-and-drop-old/root/DataDragAndDropRoot.tsx +96 -0
- package/src/data/table/empty-state/DataTableEmptyState.tsx +26 -0
- package/src/data/table/helpers/table-focus.ts +10 -1
- package/src/data/table/helpers/table-keyboard.ts +2 -6
- package/src/data/table/loading-state/DataTableLoadingState.tsx +26 -0
- package/src/data/table/root/DataTable.types.ts +16 -0
- package/src/data/table/root/DataTableAuto.tsx +182 -0
- package/src/data/table/root/DataTableRoot.context.ts +3 -2
- package/src/data/table/root/DataTableRoot.tsx +45 -2
- package/src/data/table/root/useTableKeyboardNav.ts +1 -0
- package/src/data/table/root/useTableSelection.ts +126 -0
- package/src/data/table/td/DataTableTd.tsx +14 -1
- package/src/data/table/th/DataTableTh.tsx +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 +11 -12
- package/src/date/Date.Input.tsx +1 -1
- package/src/date/datepicker/hooks/useDatepicker.tsx +12 -1
- package/src/date/monthpicker/hooks/useMonthPicker.tsx +11 -1
- 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/read-more/ReadMore.tsx +15 -16
- package/src/types/index.ts +1 -1
- 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/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/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
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { type DOMAttributes, useCallback, useState } from "react";
|
|
2
|
+
import { useControllableState } from "../../../utils/hooks";
|
|
3
|
+
import { useDataTableContext } from "../root/DataTableRoot.context";
|
|
4
|
+
|
|
5
|
+
type ColumnWidth = number | string;
|
|
6
|
+
|
|
7
|
+
type ResizeProps = {
|
|
8
|
+
ref: HTMLTableCellElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* Controlled width of the column.
|
|
11
|
+
*
|
|
12
|
+
* Should only be used to fully control column width state. Otherwise, use `defaultWidth` and let the component handle resizing.
|
|
13
|
+
*/
|
|
14
|
+
width?: ColumnWidth;
|
|
15
|
+
/**
|
|
16
|
+
* Initial width of the column. Only used when `width` is not set.
|
|
17
|
+
*/
|
|
18
|
+
defaultWidth?: ColumnWidth;
|
|
19
|
+
/**
|
|
20
|
+
* Minimum width of the column.
|
|
21
|
+
*
|
|
22
|
+
* Should be used in conjunction with `width` or `defaultWidth` to set limits when resizing.
|
|
23
|
+
*/
|
|
24
|
+
minWidth?: ColumnWidth;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum width of the column.
|
|
27
|
+
*
|
|
28
|
+
* Should be used in conjunction with `width` or `defaultWidth` to set limits when resizing.
|
|
29
|
+
*/
|
|
30
|
+
maxWidth?: ColumnWidth;
|
|
31
|
+
/**
|
|
32
|
+
* Called when the column width changes.
|
|
33
|
+
*/
|
|
34
|
+
onWidthChange?: (width: ColumnWidth) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Forwarded styles
|
|
37
|
+
*/
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
/**
|
|
40
|
+
* Forwarded colSpan
|
|
41
|
+
*/
|
|
42
|
+
colSpan?: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type TableColumnResizeArgs = ResizeProps & {};
|
|
46
|
+
|
|
47
|
+
type TableColumnResizeResult =
|
|
48
|
+
| {
|
|
49
|
+
style?: React.CSSProperties;
|
|
50
|
+
resizeHandlerProps: {
|
|
51
|
+
onMouseDown: DOMAttributes<HTMLButtonElement>["onMouseDown"];
|
|
52
|
+
onTouchStart: DOMAttributes<HTMLButtonElement>["onTouchStart"];
|
|
53
|
+
onKeyDown: DOMAttributes<HTMLButtonElement>["onKeyDown"];
|
|
54
|
+
onBlur: DOMAttributes<HTMLButtonElement>["onBlur"];
|
|
55
|
+
onDoubleClick: DOMAttributes<HTMLButtonElement>["onDoubleClick"];
|
|
56
|
+
};
|
|
57
|
+
isResizingWithKeyboard: boolean;
|
|
58
|
+
enabled: true;
|
|
59
|
+
}
|
|
60
|
+
| {
|
|
61
|
+
style?: React.CSSProperties;
|
|
62
|
+
enabled: false;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* TODO:
|
|
67
|
+
* - Do we allow % widths?
|
|
68
|
+
* - Auto-width mode is hard now since that might cause layout-shifts on mount. But would be preferable to
|
|
69
|
+
* be able to set "1fr" or similar and have it fill remaining space.
|
|
70
|
+
*/
|
|
71
|
+
function useTableColumnResize(
|
|
72
|
+
args: TableColumnResizeArgs,
|
|
73
|
+
): TableColumnResizeResult {
|
|
74
|
+
const {
|
|
75
|
+
ref,
|
|
76
|
+
width: userWidth,
|
|
77
|
+
defaultWidth,
|
|
78
|
+
onWidthChange,
|
|
79
|
+
maxWidth = Infinity,
|
|
80
|
+
minWidth = 40,
|
|
81
|
+
style,
|
|
82
|
+
colSpan,
|
|
83
|
+
} = args;
|
|
84
|
+
|
|
85
|
+
const tableContext = useDataTableContext();
|
|
86
|
+
|
|
87
|
+
const [width, _setWidth] = useControllableState({
|
|
88
|
+
value: userWidth,
|
|
89
|
+
defaultValue: defaultWidth ?? (colSpan ?? 1) * 140,
|
|
90
|
+
/**
|
|
91
|
+
* TODO:
|
|
92
|
+
* - Potential optimization: Only call when width as "stopped" changing, e.g. on mouse up or after a debounce when resizing with keyboard.
|
|
93
|
+
* Otherwise, this could cause excessive calls when resizing quickly.
|
|
94
|
+
*/
|
|
95
|
+
onChange: onWidthChange,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const [isResizingWithKeyboard, setIsResizingWithKeyboard] = useState(false);
|
|
99
|
+
const [, setIsResizingWithMouse] = useState(false);
|
|
100
|
+
|
|
101
|
+
const setWidth = useCallback(
|
|
102
|
+
(newWidth: number) => {
|
|
103
|
+
const currentWidth = ref?.offsetWidth;
|
|
104
|
+
if (!currentWidth) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const min = parseWidth(minWidth) ?? 0;
|
|
109
|
+
const max = parseWidth(maxWidth) ?? Infinity;
|
|
110
|
+
const clamped = Math.min(Math.max(newWidth, min), max);
|
|
111
|
+
|
|
112
|
+
if (newWidth <= currentWidth && newWidth > max) {
|
|
113
|
+
_setWidth(newWidth);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (newWidth >= currentWidth && newWidth > max) {
|
|
118
|
+
_setWidth(currentWidth);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_setWidth(clamped);
|
|
123
|
+
},
|
|
124
|
+
[minWidth, maxWidth, _setWidth, ref],
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const handleKeyDown: DOMAttributes<HTMLButtonElement>["onKeyDown"] =
|
|
128
|
+
useCallback(
|
|
129
|
+
(event) => {
|
|
130
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
131
|
+
setIsResizingWithKeyboard((prev) => !prev);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!isResizingWithKeyboard) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
|
|
142
|
+
const th = (event.target as HTMLElement).closest(
|
|
143
|
+
"th",
|
|
144
|
+
) as HTMLTableCellElement;
|
|
145
|
+
const startWidth = th.offsetWidth;
|
|
146
|
+
|
|
147
|
+
const delta = event.key === "ArrowRight" ? 20 : -20;
|
|
148
|
+
setWidth(startWidth + delta);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
[isResizingWithKeyboard, setWidth],
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const startResize = useCallback(
|
|
155
|
+
(th: HTMLTableCellElement, startX: number) => {
|
|
156
|
+
setIsResizingWithMouse(true);
|
|
157
|
+
const startWidth = th.offsetWidth;
|
|
158
|
+
|
|
159
|
+
function onPointerMove(clientX: number) {
|
|
160
|
+
setWidth(startWidth + (clientX - startX));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function onMouseMove(e: MouseEvent) {
|
|
164
|
+
onPointerMove(e.clientX);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function onTouchMove(e: TouchEvent) {
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
onPointerMove(e.touches[0].clientX);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function cleanup() {
|
|
173
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
174
|
+
document.removeEventListener("touchmove", onTouchMove);
|
|
175
|
+
document.removeEventListener("mouseup", cleanup);
|
|
176
|
+
document.removeEventListener("touchend", cleanup);
|
|
177
|
+
document.removeEventListener("touchcancel", cleanup);
|
|
178
|
+
setIsResizingWithMouse(false);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
182
|
+
document.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
183
|
+
document.addEventListener("mouseup", cleanup);
|
|
184
|
+
document.addEventListener("touchend", cleanup);
|
|
185
|
+
document.addEventListener("touchcancel", cleanup);
|
|
186
|
+
},
|
|
187
|
+
[setWidth],
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const handleMouseDown: DOMAttributes<HTMLButtonElement>["onMouseDown"] =
|
|
191
|
+
useCallback(
|
|
192
|
+
(event) => {
|
|
193
|
+
const th = (event.target as HTMLElement).closest(
|
|
194
|
+
"th",
|
|
195
|
+
) as HTMLTableCellElement;
|
|
196
|
+
startResize(th, event.clientX);
|
|
197
|
+
},
|
|
198
|
+
[startResize],
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const handleTouchStart: DOMAttributes<HTMLButtonElement>["onTouchStart"] =
|
|
202
|
+
useCallback(
|
|
203
|
+
(event) => {
|
|
204
|
+
const th = (event.target as HTMLElement).closest(
|
|
205
|
+
"th",
|
|
206
|
+
) as HTMLTableCellElement;
|
|
207
|
+
startResize(th, event.touches[0].clientX);
|
|
208
|
+
},
|
|
209
|
+
[startResize],
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* TODO: Do we even want this?
|
|
214
|
+
* - + 32px padding is hardcoded now, fix this
|
|
215
|
+
* - Need to find widest element in column, not the header itself.
|
|
216
|
+
* - Should doubleclick just reset to defaultWidth? Or add a autoWidth prop.
|
|
217
|
+
*/
|
|
218
|
+
const handleDoubleClick: DOMAttributes<HTMLButtonElement>["onDoubleClick"] =
|
|
219
|
+
useCallback(
|
|
220
|
+
(event) => {
|
|
221
|
+
const th = (event.target as HTMLElement).closest(
|
|
222
|
+
"th",
|
|
223
|
+
) as HTMLTableCellElement;
|
|
224
|
+
|
|
225
|
+
const contentEl = th.getElementsByClassName(
|
|
226
|
+
"aksel-data-table__th-content",
|
|
227
|
+
)[0];
|
|
228
|
+
const range = document.createRange();
|
|
229
|
+
range.selectNodeContents(contentEl);
|
|
230
|
+
const contentWidth = range.getBoundingClientRect().width;
|
|
231
|
+
|
|
232
|
+
setWidth(contentWidth + 32);
|
|
233
|
+
},
|
|
234
|
+
[setWidth],
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
if (tableContext.layout !== "fixed") {
|
|
238
|
+
return {
|
|
239
|
+
style,
|
|
240
|
+
enabled: false,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
style: {
|
|
246
|
+
...style,
|
|
247
|
+
width,
|
|
248
|
+
},
|
|
249
|
+
resizeHandlerProps: {
|
|
250
|
+
onMouseDown: handleMouseDown,
|
|
251
|
+
onTouchStart: handleTouchStart,
|
|
252
|
+
onKeyDown: handleKeyDown,
|
|
253
|
+
onBlur: () => setIsResizingWithKeyboard(false),
|
|
254
|
+
onDoubleClick: handleDoubleClick,
|
|
255
|
+
},
|
|
256
|
+
isResizingWithKeyboard,
|
|
257
|
+
enabled: true,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function parseWidth(width: ColumnWidth | undefined): number | undefined {
|
|
262
|
+
if (width == null) {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
if (typeof width === "number") {
|
|
266
|
+
return width;
|
|
267
|
+
}
|
|
268
|
+
if (typeof width === "string") {
|
|
269
|
+
const parsed = parseInt(width, 10);
|
|
270
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
271
|
+
}
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export { useTableColumnResize };
|
|
276
|
+
export type { ResizeProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { createContext } from "react";
|
|
2
|
+
|
|
3
|
+
const DataTableTheadContext = createContext<boolean>(false);
|
|
4
|
+
|
|
5
|
+
function useDataTableThead(): boolean {
|
|
6
|
+
const context = React.useContext(DataTableTheadContext);
|
|
7
|
+
return context;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { DataTableTheadContext, useDataTableThead };
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { cl } from "../../../utils/helpers";
|
|
3
|
+
import { DataTableTheadContext } from "./DataTableThead.context";
|
|
3
4
|
|
|
4
5
|
type DataTableTheadProps = React.HTMLAttributes<HTMLTableSectionElement>;
|
|
5
6
|
|
|
6
7
|
const DataTableThead = forwardRef<HTMLTableSectionElement, DataTableTheadProps>(
|
|
7
8
|
({ className, ...rest }, forwardedRef) => {
|
|
8
9
|
return (
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
<DataTableTheadContext.Provider value={true}>
|
|
11
|
+
<thead
|
|
12
|
+
{...rest}
|
|
13
|
+
ref={forwardedRef}
|
|
14
|
+
className={cl("aksel-data-table__thead", className)}
|
|
15
|
+
/>
|
|
16
|
+
</DataTableTheadContext.Provider>
|
|
14
17
|
);
|
|
15
18
|
},
|
|
16
19
|
);
|
|
@@ -8,9 +8,9 @@ type DataTableTrProps = React.HTMLAttributes<HTMLTableRowElement> & {
|
|
|
8
8
|
|
|
9
9
|
const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
10
10
|
({ className, children, selected = false, ...rest }, forwardedRef) => {
|
|
11
|
-
const
|
|
11
|
+
const { layout } = useDataTableContext();
|
|
12
12
|
|
|
13
|
-
const renderFillerCell =
|
|
13
|
+
const renderFillerCell = layout === "fixed" && children;
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<tr
|
|
@@ -23,7 +23,12 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
23
23
|
{children}
|
|
24
24
|
{renderFillerCell && (
|
|
25
25
|
/* TODO: Consider chaning between th and td based on context */
|
|
26
|
-
|
|
26
|
+
/* using div causes illegal dom structure */
|
|
27
|
+
<td
|
|
28
|
+
aria-hidden
|
|
29
|
+
className="aksel-data-table__th aksel-data-table__filler-cell"
|
|
30
|
+
data-block-keyboard-nav
|
|
31
|
+
/>
|
|
27
32
|
)}
|
|
28
33
|
</tr>
|
|
29
34
|
);
|
|
@@ -2,8 +2,6 @@ import React, { forwardRef, useState } from "react";
|
|
|
2
2
|
import { Search } from "../../form/search";
|
|
3
3
|
import { VStack } from "../../primitives/stack";
|
|
4
4
|
import { Detail, Label } from "../../typography";
|
|
5
|
-
import { ListboxGroup } from "../../utils/components/Listbox/group/ListboxGroup";
|
|
6
|
-
import { ListboxItem } from "../../utils/components/Listbox/item/ListboxItem";
|
|
7
5
|
import Listbox from "../../utils/components/Listbox/root/ListboxRoot";
|
|
8
6
|
import { DismissableLayer } from "../../utils/components/dismissablelayer/DismissableLayer";
|
|
9
7
|
import { Floating } from "../../utils/components/floating/Floating";
|
|
@@ -22,7 +20,8 @@ interface AutoSuggestProps {
|
|
|
22
20
|
|
|
23
21
|
const AutoSuggest = forwardRef<HTMLInputElement, AutoSuggestProps>(
|
|
24
22
|
({ options, onSelect, value, onChange, open, setOpen }, ref) => {
|
|
25
|
-
const [
|
|
23
|
+
const [virtuallyFocusedOptionId, setVirtuallyFocusedOptionId] =
|
|
24
|
+
useState("");
|
|
26
25
|
|
|
27
26
|
const [inputRef, setInputRef] = useState<HTMLInputElement | null>(null);
|
|
28
27
|
|
|
@@ -49,7 +48,7 @@ const AutoSuggest = forwardRef<HTMLInputElement, AutoSuggestProps>(
|
|
|
49
48
|
|
|
50
49
|
return (
|
|
51
50
|
<Floating>
|
|
52
|
-
<Listbox
|
|
51
|
+
<Listbox setVirtuallyFocusedOptionId={setVirtuallyFocusedOptionId}>
|
|
53
52
|
<Floating.Anchor>
|
|
54
53
|
<Listbox.InputSlot>
|
|
55
54
|
<Search
|
|
@@ -76,8 +75,8 @@ const AutoSuggest = forwardRef<HTMLInputElement, AutoSuggestProps>(
|
|
|
76
75
|
<AutoSuggestPopup
|
|
77
76
|
options={options}
|
|
78
77
|
onSelect={handleSelectOption}
|
|
79
|
-
focusedValue={
|
|
80
|
-
setFocusedValue={
|
|
78
|
+
focusedValue={virtuallyFocusedOptionId}
|
|
79
|
+
setFocusedValue={setVirtuallyFocusedOptionId}
|
|
81
80
|
onClose={handleClose}
|
|
82
81
|
safeZoneAnchor={inputRef}
|
|
83
82
|
/>
|
|
@@ -124,11 +123,11 @@ const AutoSuggestPopup = forwardRef<HTMLDivElement, AutoSuggestPopupProps>(
|
|
|
124
123
|
className="aksel-property-filter__popup"
|
|
125
124
|
>
|
|
126
125
|
<div className="aksel-property-filter__popup-inner">
|
|
127
|
-
<Listbox.
|
|
126
|
+
<Listbox.Options setVirtuallyFocusedOptionId={setFocusedValue}>
|
|
128
127
|
{options.map((group) => (
|
|
129
|
-
<
|
|
128
|
+
<Listbox.Group key={group.label} label={group.label}>
|
|
130
129
|
{group.options.map((item) => (
|
|
131
|
-
<
|
|
130
|
+
<Listbox.Option
|
|
132
131
|
key={item.value}
|
|
133
132
|
id={item.value}
|
|
134
133
|
onClick={() => onSelect(item)}
|
|
@@ -147,11 +146,11 @@ const AutoSuggestPopup = forwardRef<HTMLDivElement, AutoSuggestPopupProps>(
|
|
|
147
146
|
))}
|
|
148
147
|
</div>
|
|
149
148
|
)} */}
|
|
150
|
-
</
|
|
149
|
+
</Listbox.Option>
|
|
151
150
|
))}
|
|
152
|
-
</
|
|
151
|
+
</Listbox.Group>
|
|
153
152
|
))}
|
|
154
|
-
</Listbox.
|
|
153
|
+
</Listbox.Options>
|
|
155
154
|
</div>
|
|
156
155
|
</Floating.Content>
|
|
157
156
|
</DismissableLayer>
|
package/src/date/Date.Input.tsx
CHANGED
|
@@ -154,7 +154,7 @@ const DateInput = forwardRef<HTMLInputElement, DateInputProps>((props, ref) => {
|
|
|
154
154
|
/>
|
|
155
155
|
<button
|
|
156
156
|
disabled={inputProps.disabled || readOnly}
|
|
157
|
-
tabIndex={readOnly ? -1 :
|
|
157
|
+
tabIndex={readOnly ? -1 : undefined}
|
|
158
158
|
onClick={() => {
|
|
159
159
|
context?.onOpen();
|
|
160
160
|
setAnchorRef?.(buttonRef.current);
|
|
@@ -90,12 +90,23 @@ interface UseDatepickerValue {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export type DateValidationT = {
|
|
93
|
+
/**
|
|
94
|
+
* Whether there are any validation errors.
|
|
95
|
+
* - When `true`, all the other properties will be `false`.
|
|
96
|
+
* - When `false`, at least one of the other properties will be `true`.
|
|
97
|
+
*/
|
|
98
|
+
isValidDate: boolean;
|
|
99
|
+
/** Whether the date is a disabled date */
|
|
93
100
|
isDisabled: boolean;
|
|
101
|
+
/** Whether the date falls on a weekend and `disableWeekends` is true */
|
|
94
102
|
isWeekend: boolean;
|
|
103
|
+
/** Whether the input field is empty */
|
|
95
104
|
isEmpty: boolean;
|
|
105
|
+
/** Whether the entered value cannot be parsed as a date (i.e. wrong format or non-existing date) */
|
|
96
106
|
isInvalid: boolean;
|
|
97
|
-
|
|
107
|
+
/** Whether the date is before `fromDate` */
|
|
98
108
|
isBefore: boolean;
|
|
109
|
+
/** Whether the date is after `toDate` */
|
|
99
110
|
isAfter: boolean;
|
|
100
111
|
};
|
|
101
112
|
|
|
@@ -74,11 +74,21 @@ interface UseMonthPickerValue {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export type MonthValidationT = {
|
|
77
|
+
/**
|
|
78
|
+
* Whether there are any validation errors.
|
|
79
|
+
* - When `true`, all the other properties will be `false`.
|
|
80
|
+
* - When `false`, at least one of the other properties will be `true`.
|
|
81
|
+
*/
|
|
82
|
+
isValidMonth: boolean;
|
|
83
|
+
/** Whether the month is a disabled month */
|
|
77
84
|
isDisabled: boolean;
|
|
85
|
+
/** Whether the input field is empty */
|
|
78
86
|
isEmpty: boolean;
|
|
87
|
+
/** Whether the entered value cannot be parsed as a month (i.e. wrong format) */
|
|
79
88
|
isInvalid: boolean;
|
|
80
|
-
|
|
89
|
+
/** Whether the month is before `fromDate` */
|
|
81
90
|
isBefore: boolean;
|
|
91
|
+
/** Whether the month is after `toDate` */
|
|
82
92
|
isAfter: boolean;
|
|
83
93
|
};
|
|
84
94
|
|
|
@@ -81,7 +81,7 @@ export const CheckboxGroup = forwardRef<
|
|
|
81
81
|
"aksel-checkbox-group",
|
|
82
82
|
`aksel-checkbox-group--${rest.size ?? fieldset?.size ?? "medium"}`,
|
|
83
83
|
)}
|
|
84
|
-
|
|
84
|
+
_fieldsSupportNativeReadOnly={false}
|
|
85
85
|
>
|
|
86
86
|
<CheckboxGroupContext.Provider
|
|
87
87
|
value={{
|
|
@@ -10,25 +10,45 @@ import { useFieldset } from "./useFieldset";
|
|
|
10
10
|
export interface FieldsetProps
|
|
11
11
|
extends FormFieldProps, FieldsetHTMLAttributes<HTMLFieldSetElement> {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Form fields in Fieldset.
|
|
14
14
|
*/
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
/**
|
|
17
|
-
* Fieldset legend
|
|
17
|
+
* Fieldset legend.
|
|
18
18
|
*/
|
|
19
19
|
legend: React.ReactNode;
|
|
20
20
|
/**
|
|
21
|
-
* If enabled shows the legend and description for
|
|
21
|
+
* If enabled, shows the legend and description for screen readers only.
|
|
22
22
|
*/
|
|
23
23
|
hideLegend?: boolean;
|
|
24
24
|
/**
|
|
25
|
-
* Toggles error propagation to child-elements
|
|
25
|
+
* Toggles error propagation to child-elements.
|
|
26
26
|
* @default true
|
|
27
27
|
*/
|
|
28
28
|
errorPropagation?: boolean;
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
_fieldsSupportNativeReadOnly?: boolean;
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Component for grouping form fields.
|
|
37
|
+
*
|
|
38
|
+
* **NB: Only for special use cases.** Form fields should not be grouped by default,
|
|
39
|
+
* except for checkboxes and radio buttons, for which CheckboxGroup/RadioGroup should be used instead.
|
|
40
|
+
*
|
|
41
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/fieldset)
|
|
42
|
+
* @see 🏷️ {@link FieldsetProps}
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```jsx
|
|
46
|
+
* <Fieldset legend="Telefonnummer">
|
|
47
|
+
* <TextField label="Landkode" />
|
|
48
|
+
* <TextField label="Nummer" />
|
|
49
|
+
* </Fieldset>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
32
52
|
export const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(
|
|
33
53
|
(props, ref) => {
|
|
34
54
|
const legendId = useId();
|
|
@@ -51,7 +71,7 @@ export const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(
|
|
|
51
71
|
legend,
|
|
52
72
|
description,
|
|
53
73
|
hideLegend,
|
|
54
|
-
|
|
74
|
+
_fieldsSupportNativeReadOnly = true,
|
|
55
75
|
...rest
|
|
56
76
|
} = props;
|
|
57
77
|
|
|
@@ -93,7 +113,11 @@ export const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(
|
|
|
93
113
|
})}
|
|
94
114
|
>
|
|
95
115
|
{readOnly &&
|
|
96
|
-
(
|
|
116
|
+
(_fieldsSupportNativeReadOnly ? (
|
|
117
|
+
<ReadOnlyIcon />
|
|
118
|
+
) : (
|
|
119
|
+
<ReadOnlyIconWithTitle />
|
|
120
|
+
))}
|
|
97
121
|
{legend}
|
|
98
122
|
</Label>
|
|
99
123
|
{!!description && (
|
|
@@ -84,7 +84,7 @@ export const RadioGroup = forwardRef<HTMLFieldSetElement, RadioGroupProps>(
|
|
|
84
84
|
"aksel-radio-group",
|
|
85
85
|
`aksel-radio-group--${rest.size ?? fieldset?.size ?? "medium"}`,
|
|
86
86
|
)}
|
|
87
|
-
|
|
87
|
+
_fieldsSupportNativeReadOnly={false}
|
|
88
88
|
>
|
|
89
89
|
<RadioGroupContext.Provider
|
|
90
90
|
value={{
|
package/src/index.ts
CHANGED
|
@@ -43,6 +43,16 @@ export interface ReadMoreProps extends React.ButtonHTMLAttributes<HTMLButtonElem
|
|
|
43
43
|
* @private
|
|
44
44
|
*/
|
|
45
45
|
"data-color"?: Exclude<AkselColor, AkselStatusColorRole>;
|
|
46
|
+
/**
|
|
47
|
+
* Changes variant of ReadMore.
|
|
48
|
+
*
|
|
49
|
+
* `moderate` is a more visually prominent variant.
|
|
50
|
+
*
|
|
51
|
+
*
|
|
52
|
+
* `ghost` is more subtle, mainly for use in forms.
|
|
53
|
+
* @default "ghost"
|
|
54
|
+
*/
|
|
55
|
+
variant?: "moderate" | "ghost";
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
/**
|
|
@@ -66,6 +76,7 @@ export const ReadMore = forwardRef<HTMLButtonElement, ReadMoreProps>(
|
|
|
66
76
|
onClick,
|
|
67
77
|
size = "medium",
|
|
68
78
|
onOpenChange,
|
|
79
|
+
variant = "ghost",
|
|
69
80
|
...rest
|
|
70
81
|
}: ReadMoreProps,
|
|
71
82
|
ref,
|
|
@@ -80,13 +91,9 @@ export const ReadMore = forwardRef<HTMLButtonElement, ReadMoreProps>(
|
|
|
80
91
|
|
|
81
92
|
return (
|
|
82
93
|
<div
|
|
83
|
-
className={cl(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
className,
|
|
87
|
-
{ "aksel-read-more--open": _open },
|
|
88
|
-
)}
|
|
89
|
-
data-volume="low"
|
|
94
|
+
className={cl("aksel-read-more", `aksel-read-more--${size}`, className)}
|
|
95
|
+
data-variant={variant}
|
|
96
|
+
data-state={_open ? "open" : "closed"}
|
|
90
97
|
>
|
|
91
98
|
<button
|
|
92
99
|
{...rest}
|
|
@@ -97,7 +104,6 @@ export const ReadMore = forwardRef<HTMLButtonElement, ReadMoreProps>(
|
|
|
97
104
|
})}
|
|
98
105
|
onClick={composeEventHandlers(onClick, () => _setOpen((x) => !x))}
|
|
99
106
|
aria-expanded={_open}
|
|
100
|
-
data-state={_open ? "open" : "closed"}
|
|
101
107
|
>
|
|
102
108
|
<ChevronDownIcon
|
|
103
109
|
className="aksel-read-more__expand-icon"
|
|
@@ -106,14 +112,7 @@ export const ReadMore = forwardRef<HTMLButtonElement, ReadMoreProps>(
|
|
|
106
112
|
<span>{header}</span>
|
|
107
113
|
</button>
|
|
108
114
|
|
|
109
|
-
<BodyLong
|
|
110
|
-
as="div"
|
|
111
|
-
className={cl("aksel-read-more__content", {
|
|
112
|
-
"aksel-read-more__content--closed": !_open,
|
|
113
|
-
})}
|
|
114
|
-
size={typoSize}
|
|
115
|
-
data-state={_open ? "open" : "closed"}
|
|
116
|
-
>
|
|
115
|
+
<BodyLong as="div" className="aksel-read-more__content" size={typoSize}>
|
|
117
116
|
{children}
|
|
118
117
|
</BodyLong>
|
|
119
118
|
</div>
|
package/src/types/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { AkselColor, CustomAkselColor } from "./theme";
|
|
@@ -8,7 +8,7 @@ interface ListboxInputSlotProps {
|
|
|
8
8
|
const ListboxInputSlot = ({ children }: ListboxInputSlotProps) => {
|
|
9
9
|
return (
|
|
10
10
|
<Slot
|
|
11
|
-
aria-activedescendant="aksel-
|
|
11
|
+
aria-activedescendant="aksel-listbox__option-active"
|
|
12
12
|
// @ts-expect-error - You are meant to use an <input>, but Slot doesn't know that.
|
|
13
13
|
autoComplete="off"
|
|
14
14
|
role="combobox"
|