@navikt/ds-react 5.5.0 → 5.6.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/_docs.json +507 -106
- package/cjs/accordion/Accordion.js +1 -0
- package/cjs/accordion/AccordionContext.js +1 -1
- package/cjs/accordion/AccordionHeader.js +2 -2
- package/cjs/accordion/AccordionItem.js +6 -2
- package/cjs/date/datepicker/DatePicker.js +30 -34
- package/cjs/date/datepicker/DatePickerStandalone.js +23 -26
- package/cjs/date/datepicker/parts/Caption.js +28 -0
- package/cjs/date/datepicker/{DayButton.js → parts/DayButton.js} +1 -2
- package/cjs/date/datepicker/{caption → parts}/DropdownCaption.js +13 -7
- package/cjs/date/datepicker/parts/HeadRow.js +36 -0
- package/cjs/date/datepicker/parts/Row.js +23 -0
- package/cjs/date/datepicker/{TableHead.js → parts/TableHead.js} +4 -3
- package/cjs/date/datepicker/parts/WeekNumber.js +35 -0
- package/cjs/date/datepicker/parts/WeekRow.js +34 -0
- package/cjs/date/hooks/useDatepicker.js +2 -2
- package/cjs/date/hooks/useMonthPicker.js +2 -2
- package/cjs/date/hooks/useRangeDatepicker.js +3 -3
- package/cjs/date/monthpicker/MonthSelector.js +1 -1
- package/cjs/date/utils/get-month-weeks.js +46 -0
- package/cjs/date/utils/labels.js +40 -1
- package/cjs/dropdown/Toggle.js +2 -2
- package/cjs/dropdown/index.js +0 -15
- package/cjs/form/Select.js +1 -1
- package/cjs/form/checkbox/useCheckbox.js +3 -4
- package/cjs/form/combobox/Combobox.js +1 -1
- package/cjs/form/combobox/Input/Input.js +1 -1
- package/cjs/form/search/Search.js +3 -1
- package/cjs/index.js +1 -0
- package/cjs/layout/bleed/Bleed.js +69 -0
- package/cjs/layout/bleed/index.js +5 -0
- package/cjs/layout/bleed/package.json +6 -0
- package/cjs/layout/box/Box.js +1 -1
- package/cjs/layout/responsive/Responsive.js +8 -6
- package/cjs/layout/sidemal-test/AvatarPanel.js +18 -0
- package/cjs/layout/sidemal-test/Content.js +66 -0
- package/cjs/layout/sidemal-test/Filter.js +48 -0
- package/cjs/layout/sidemal-test/Header.js +48 -0
- package/cjs/layout/sidemal-test/Intro.js +36 -0
- package/cjs/layout/sidemal-test/Sidebar.js +49 -0
- package/cjs/layout/sidemal-test/content-box/ContentBox.js +65 -0
- package/cjs/layout/sidemal-test/content-box/index.js +8 -0
- package/cjs/layout/sidemal-test/content-box/package.json +6 -0
- package/cjs/layout/stack/Stack.js +2 -2
- package/cjs/layout/stack/index.js +3 -1
- package/cjs/layout/utilities/css.js +37 -14
- package/cjs/loader/Loader.js +2 -2
- package/cjs/modal/dialog-polyfill.js +2 -0
- package/cjs/popover/Popover.js +3 -2
- package/cjs/tabs/TabList.js +6 -7
- package/cjs/timeline/Pin.js +20 -20
- package/cjs/timeline/Timeline.js +4 -4
- package/cjs/timeline/period/ClickablePeriod.js +19 -19
- package/cjs/timeline/period/index.js +1 -1
- package/cjs/timeline/utils/timeline.js +3 -3
- package/cjs/toggle-group/ToggleGroup.js +1 -1
- package/cjs/tooltip/Tooltip.js +1 -1
- package/cjs/typography/Heading.js +1 -1
- package/cjs/util/RandomIcon.js +1 -0
- package/cjs/util/Slot.js +88 -0
- package/cjs/util/useId.js +2 -4
- package/esm/accordion/Accordion.js +1 -0
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/accordion/AccordionContext.d.ts +1 -0
- package/esm/accordion/AccordionContext.js +1 -1
- package/esm/accordion/AccordionContext.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +2 -2
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.js +6 -2
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +14 -5
- package/esm/date/datepicker/DatePicker.js +29 -33
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.d.ts +3 -2
- package/esm/date/datepicker/DatePickerStandalone.js +22 -25
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- package/esm/date/datepicker/{caption → parts}/Caption.d.ts +3 -0
- package/esm/date/datepicker/parts/Caption.js +22 -0
- package/esm/date/datepicker/parts/Caption.js.map +1 -0
- package/esm/date/datepicker/parts/DayButton.d.ts +4 -0
- package/esm/date/datepicker/{DayButton.js → parts/DayButton.js} +2 -1
- package/esm/date/datepicker/parts/DayButton.js.map +1 -0
- package/esm/date/datepicker/{caption → parts}/DropdownCaption.d.ts +3 -0
- package/esm/date/datepicker/parts/DropdownCaption.js +44 -0
- package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -0
- package/esm/date/datepicker/parts/HeadRow.d.ts +11 -0
- package/esm/date/datepicker/parts/HeadRow.js +29 -0
- package/esm/date/datepicker/parts/HeadRow.js.map +1 -0
- package/esm/date/datepicker/parts/Row.d.ts +17 -0
- package/esm/date/datepicker/parts/Row.js +19 -0
- package/esm/date/datepicker/parts/Row.js.map +1 -0
- package/esm/date/datepicker/parts/TableHead.d.ts +6 -0
- package/esm/date/datepicker/{TableHead.js → parts/TableHead.js} +5 -2
- package/esm/date/datepicker/parts/TableHead.js.map +1 -0
- package/esm/date/datepicker/parts/WeekNumber.d.ts +13 -0
- package/esm/date/datepicker/parts/WeekNumber.js +31 -0
- package/esm/date/datepicker/parts/WeekNumber.js.map +1 -0
- package/esm/date/datepicker/parts/WeekRow.d.ts +5 -0
- package/esm/date/datepicker/parts/WeekRow.js +30 -0
- package/esm/date/datepicker/parts/WeekRow.js.map +1 -0
- package/esm/date/hooks/useDatepicker.js +2 -2
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.js +2 -2
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.js +3 -3
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/monthpicker/MonthButton.d.ts +2 -2
- package/esm/date/monthpicker/MonthPicker.d.ts +1 -1
- package/esm/date/monthpicker/MonthSelector.js +1 -1
- package/esm/date/monthpicker/MonthSelector.js.map +1 -1
- package/esm/date/utils/get-month-weeks.d.ts +16 -0
- package/esm/date/utils/get-month-weeks.js +42 -0
- package/esm/date/utils/get-month-weeks.js.map +1 -0
- package/esm/date/utils/labels.d.ts +9 -0
- package/esm/date/utils/labels.js +36 -0
- package/esm/date/utils/labels.js.map +1 -1
- package/esm/date/utils/navigation.d.ts +1 -1
- package/esm/date/utils/navigation.js.map +1 -1
- package/esm/dropdown/Toggle.js +1 -1
- package/esm/dropdown/Toggle.js.map +1 -1
- package/esm/dropdown/index.d.ts +1 -2
- package/esm/dropdown/index.js +0 -1
- package/esm/dropdown/index.js.map +1 -1
- package/esm/form/Select.js +1 -1
- package/esm/form/Select.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +1 -1
- package/esm/form/checkbox/useCheckbox.js +3 -4
- package/esm/form/checkbox/useCheckbox.js.map +1 -1
- package/esm/form/combobox/Combobox.d.ts +1 -1
- package/esm/form/combobox/Combobox.js +1 -1
- package/esm/form/combobox/Combobox.js.map +1 -1
- package/esm/form/combobox/Input/Input.d.ts +0 -2
- package/esm/form/combobox/Input/Input.js +1 -1
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/search/Search.js +3 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/layout/bleed/Bleed.d.ts +47 -0
- package/esm/layout/bleed/Bleed.js +41 -0
- package/esm/layout/bleed/Bleed.js.map +1 -0
- package/esm/layout/bleed/index.d.ts +1 -0
- package/esm/layout/bleed/index.js +2 -0
- package/esm/layout/bleed/index.js.map +1 -0
- package/esm/layout/box/Box.d.ts +1 -2
- package/esm/layout/box/Box.js +1 -1
- package/esm/layout/box/Box.js.map +1 -1
- package/esm/layout/responsive/Responsive.d.ts +8 -4
- package/esm/layout/responsive/Responsive.js +8 -6
- package/esm/layout/responsive/Responsive.js.map +1 -1
- package/esm/layout/sidemal-test/AvatarPanel.d.ts +4 -0
- package/esm/layout/sidemal-test/AvatarPanel.js +12 -0
- package/esm/layout/sidemal-test/AvatarPanel.js.map +1 -0
- package/esm/layout/sidemal-test/Content.d.ts +2 -0
- package/esm/layout/sidemal-test/Content.js +60 -0
- package/esm/layout/sidemal-test/Content.js.map +1 -0
- package/esm/layout/sidemal-test/Filter.d.ts +2 -0
- package/esm/layout/sidemal-test/Filter.js +22 -0
- package/esm/layout/sidemal-test/Filter.js.map +1 -0
- package/esm/layout/sidemal-test/Header.d.ts +2 -0
- package/esm/layout/sidemal-test/Header.js +42 -0
- package/esm/layout/sidemal-test/Header.js.map +1 -0
- package/esm/layout/sidemal-test/Intro.d.ts +2 -0
- package/esm/layout/sidemal-test/Intro.js +30 -0
- package/esm/layout/sidemal-test/Intro.js.map +1 -0
- package/esm/layout/sidemal-test/Sidebar.d.ts +4 -0
- package/esm/layout/sidemal-test/Sidebar.js +41 -0
- package/esm/layout/sidemal-test/Sidebar.js.map +1 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.d.ts +8 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.js +37 -0
- package/esm/layout/sidemal-test/content-box/ContentBox.js.map +1 -0
- package/esm/layout/sidemal-test/content-box/index.d.ts +1 -0
- package/esm/layout/sidemal-test/content-box/index.js +2 -0
- package/esm/layout/sidemal-test/content-box/index.js.map +1 -0
- package/esm/layout/stack/Stack.d.ts +7 -3
- package/esm/layout/stack/Stack.js +3 -3
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/layout/stack/index.d.ts +1 -0
- package/esm/layout/stack/index.js +1 -0
- package/esm/layout/stack/index.js.map +1 -1
- package/esm/layout/utilities/css.d.ts +1 -1
- package/esm/layout/utilities/css.js +37 -14
- package/esm/layout/utilities/css.js.map +1 -1
- package/esm/loader/Loader.js +3 -3
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/dialog-polyfill.js +2 -0
- package/esm/modal/dialog-polyfill.js.map +1 -1
- package/esm/popover/Popover.js +3 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/tabs/TabList.js +6 -7
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/timeline/Pin.js +21 -21
- package/esm/timeline/Pin.js.map +1 -1
- package/esm/timeline/Timeline.js +4 -4
- package/esm/timeline/Timeline.js.map +1 -1
- package/esm/timeline/TimelineRow.js.map +1 -1
- package/esm/timeline/hooks/usePeriodContext.d.ts +1 -1
- package/esm/timeline/period/ClickablePeriod.js +20 -20
- package/esm/timeline/period/ClickablePeriod.js.map +1 -1
- package/esm/timeline/period/index.d.ts +2 -2
- package/esm/timeline/period/index.js +1 -1
- package/esm/timeline/period/index.js.map +1 -1
- package/esm/timeline/utils/timeline.js +3 -3
- package/esm/timeline/utils/timeline.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +1 -1
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/tooltip/Tooltip.js +1 -1
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/Heading.js +1 -1
- package/esm/typography/Heading.js.map +1 -1
- package/esm/util/RandomIcon.js +1 -0
- package/esm/util/RandomIcon.js.map +1 -1
- package/esm/util/Slot.d.ts +6 -0
- package/esm/util/Slot.js +60 -0
- package/esm/util/Slot.js.map +1 -0
- package/esm/util/mergeRefs.d.ts +1 -1
- package/esm/util/useId.js +2 -4
- package/esm/util/useId.js.map +1 -1
- package/package.json +4 -4
- package/src/accordion/Accordion.tsx +1 -0
- package/src/accordion/AccordionContext.tsx +2 -1
- package/src/accordion/AccordionHeader.tsx +2 -2
- package/src/accordion/AccordionItem.tsx +7 -5
- package/src/accordion/accordion.stories.tsx +21 -34
- package/src/alert/alert.stories.tsx +2 -2
- package/src/chips/chips.stories.tsx +29 -32
- package/src/date/datepicker/DatePicker.tsx +63 -58
- package/src/date/datepicker/DatePickerStandalone.tsx +36 -39
- package/src/date/datepicker/datepicker.stories.tsx +67 -2
- package/src/date/datepicker/datepicker.test.tsx +5 -4
- package/src/date/datepicker/{caption → parts}/Caption.tsx +19 -17
- package/src/date/datepicker/{DayButton.tsx → parts/DayButton.tsx} +3 -1
- package/src/date/datepicker/parts/DropdownCaption.tsx +113 -0
- package/src/date/datepicker/parts/HeadRow.tsx +56 -0
- package/src/date/datepicker/parts/Row.tsx +47 -0
- package/src/date/datepicker/{TableHead.tsx → parts/TableHead.tsx} +6 -2
- package/src/date/datepicker/parts/WeekNumber.tsx +79 -0
- package/src/date/datepicker/parts/WeekRow.tsx +60 -0
- package/src/date/hooks/useDatepicker.tsx +2 -2
- package/src/date/hooks/useMonthPicker.tsx +2 -2
- package/src/date/hooks/useRangeDatepicker.test.tsx +11 -11
- package/src/date/hooks/useRangeDatepicker.tsx +3 -3
- package/src/date/monthpicker/MonthButton.tsx +2 -2
- package/src/date/monthpicker/MonthPicker.tsx +1 -1
- package/src/date/monthpicker/MonthSelector.tsx +3 -3
- package/src/date/monthpicker/monthpicker.stories.tsx +1 -1
- package/src/date/utils/__tests__/get-initial-year.test.ts +0 -12
- package/src/date/utils/__tests__/get-month-weeks.test.ts +113 -0
- package/src/date/utils/__tests__/is-match.test.ts +3 -3
- package/src/date/utils/__tests__/parse-dates.test.ts +4 -2
- package/src/date/utils/get-month-weeks.ts +93 -0
- package/src/date/utils/labels.ts +51 -0
- package/src/date/utils/navigation.ts +3 -3
- package/src/dropdown/Toggle.tsx +1 -1
- package/src/dropdown/dropdown.stories.tsx +25 -28
- package/src/dropdown/index.ts +1 -2
- package/src/expansion-card/expansion-card.stories.tsx +143 -161
- package/src/form/ConfirmationPanel.test.tsx +5 -5
- package/src/form/Select.tsx +1 -1
- package/src/form/checkbox/Checkbox.test.tsx +14 -26
- package/src/form/checkbox/checkbox.stories.tsx +66 -71
- package/src/form/checkbox/useCheckbox.ts +3 -4
- package/src/form/combobox/Combobox.tsx +2 -3
- package/src/form/combobox/Input/Input.tsx +1 -3
- package/src/form/combobox/combobox.stories.tsx +20 -23
- package/src/form/combobox/combobox.test.tsx +22 -20
- package/src/form/radio/radio.stories.tsx +39 -44
- package/src/form/search/Search.tsx +1 -0
- package/src/form/search/search.stories.tsx +22 -26
- package/src/form/stories/fieldset.stories.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/layout/bleed/Bleed.stories.tsx +381 -0
- package/src/layout/bleed/Bleed.tsx +130 -0
- package/src/layout/bleed/index.ts +1 -0
- package/src/layout/box/Box.stories.tsx +251 -256
- package/src/layout/box/Box.tsx +2 -1
- package/src/layout/responsive/Responsive.tsx +21 -6
- package/src/layout/responsive/hide.stories.tsx +35 -0
- package/src/layout/responsive/show.stories.tsx +35 -0
- package/src/layout/sidemal-test/AvatarPanel.tsx +27 -0
- package/src/layout/sidemal-test/Content.tsx +129 -0
- package/src/layout/sidemal-test/Filter.tsx +46 -0
- package/src/layout/sidemal-test/Header.tsx +96 -0
- package/src/layout/sidemal-test/Intro.tsx +91 -0
- package/src/layout/sidemal-test/Sidebar.tsx +77 -0
- package/src/layout/sidemal-test/content-box/ContentBox.tsx +46 -0
- package/src/layout/sidemal-test/content-box/index.ts +1 -0
- package/src/layout/sidemal-test/navno-sidemal.stories.mdx +29 -0
- package/src/layout/sidemal-test/navno-sidemal.stories.tsx +65 -0
- package/src/layout/sidemal-test/styling.css +43 -0
- package/src/layout/stack/Stack.tsx +14 -8
- package/src/layout/stack/index.ts +1 -0
- package/src/layout/stack/stack.stories.tsx +23 -1
- package/src/layout/utilities/css.ts +59 -20
- package/src/loader/Loader.tsx +2 -3
- package/src/modal/dialog-polyfill.ts +2 -0
- package/src/pagination/pagination.stories.tsx +35 -42
- package/src/popover/Popover.test.tsx +21 -35
- package/src/popover/Popover.tsx +2 -2
- package/src/popover/popover.stories.tsx +25 -41
- package/src/react-css.d.ts +0 -1
- package/src/read-more/readmore.stories.tsx +35 -36
- package/src/stepper/stepper.stories.tsx +45 -52
- package/src/table/stories/table-expandable.stories.tsx +59 -63
- package/src/tabs/TabList.tsx +4 -6
- package/src/tabs/Tabs.stories.tsx +3 -3
- package/src/tag/tag.stories.tsx +4 -4
- package/src/timeline/Pin.tsx +44 -39
- package/src/timeline/Timeline.tsx +6 -6
- package/src/timeline/TimelineRow.tsx +1 -0
- package/src/timeline/hooks/usePeriodContext.tsx +1 -1
- package/src/timeline/period/ClickablePeriod.tsx +42 -38
- package/src/timeline/period/index.tsx +5 -4
- package/src/timeline/timeline.stories.tsx +11 -10
- package/src/timeline/utils/timeline.ts +3 -3
- package/src/toggle-group/ToggleGroup.stories.tsx +25 -29
- package/src/toggle-group/ToggleGroup.tsx +0 -1
- package/src/tooltip/Tooltip.test.tsx +40 -54
- package/src/tooltip/Tooltip.tsx +1 -1
- package/src/typography/Heading.tsx +1 -1
- package/src/util/RandomIcon.tsx +1 -0
- package/src/util/Slot.tsx +69 -0
- package/src/util/__tests__/Slot.test.tsx +98 -0
- package/src/util/mergeRefs.tsx +1 -1
- package/src/util/useId.ts +1 -3
- package/cjs/date/datepicker/caption/Caption.js +0 -23
- package/cjs/date/datepicker/caption/index.js +0 -10
- package/cjs/date/datepicker/caption/package.json +0 -6
- package/esm/date/datepicker/DayButton.d.ts +0 -3
- package/esm/date/datepicker/DayButton.js.map +0 -1
- package/esm/date/datepicker/TableHead.d.ts +0 -3
- package/esm/date/datepicker/TableHead.js.map +0 -1
- package/esm/date/datepicker/caption/Caption.js +0 -17
- package/esm/date/datepicker/caption/Caption.js.map +0 -1
- package/esm/date/datepicker/caption/DropdownCaption.js +0 -38
- package/esm/date/datepicker/caption/DropdownCaption.js.map +0 -1
- package/esm/date/datepicker/caption/index.d.ts +0 -2
- package/esm/date/datepicker/caption/index.js +0 -3
- package/esm/date/datepicker/caption/index.js.map +0 -1
- package/src/date/datepicker/caption/DropdownCaption.tsx +0 -108
- package/src/date/datepicker/caption/index.ts +0 -2
|
@@ -14,11 +14,9 @@ import Input from "./Input/Input";
|
|
|
14
14
|
|
|
15
15
|
export const Combobox = forwardRef<
|
|
16
16
|
HTMLInputElement,
|
|
17
|
-
Omit<ComboboxProps, "onChange" | "options" | "size">
|
|
17
|
+
Omit<ComboboxProps, "onChange" | "options" | "size" | "onClear" | "value">
|
|
18
18
|
>((props, ref) => {
|
|
19
19
|
const {
|
|
20
|
-
value: externalValue,
|
|
21
|
-
onClear,
|
|
22
20
|
className,
|
|
23
21
|
hideLabel = false,
|
|
24
22
|
description,
|
|
@@ -87,6 +85,7 @@ export const Combobox = forwardRef<
|
|
|
87
85
|
</BodyShort>
|
|
88
86
|
)}
|
|
89
87
|
<div className="navds-combobox__wrapper">
|
|
88
|
+
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
|
|
90
89
|
<div
|
|
91
90
|
className={cl(
|
|
92
91
|
"navds-combobox__wrapper-inner navds-text-field__input",
|
|
@@ -14,13 +14,11 @@ interface InputProps
|
|
|
14
14
|
extends Omit<InputHTMLAttributes<HTMLInputElement>, "value"> {
|
|
15
15
|
ref: React.Ref<HTMLInputElement>;
|
|
16
16
|
inputClassName?: string;
|
|
17
|
-
errorId?: string;
|
|
18
17
|
value?: string;
|
|
19
|
-
error?: React.ReactNode;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
23
|
-
({ inputClassName,
|
|
21
|
+
({ inputClassName, ...rest }, ref) => {
|
|
24
22
|
const { clearInput, inputProps, onChange, size, value } = useInputContext();
|
|
25
23
|
const {
|
|
26
24
|
selectedOptions,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
1
|
import { Meta, StoryFn, StoryObj } from "@storybook/react";
|
|
3
2
|
import React, { useState, useId, useMemo } from "react";
|
|
4
3
|
import { userEvent, within } from "@storybook/testing-library";
|
|
@@ -286,28 +285,26 @@ export const ComboboxSizes = () => (
|
|
|
286
285
|
</>
|
|
287
286
|
);
|
|
288
287
|
|
|
289
|
-
export const WithError:
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
);
|
|
310
|
-
},
|
|
288
|
+
export const WithError: StoryFunction = (props) => {
|
|
289
|
+
const [hasSelectedValue, setHasSelectedValue] = useState(false);
|
|
290
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
291
|
+
return (
|
|
292
|
+
<UNSAFE_Combobox
|
|
293
|
+
filteredOptions={isLoading ? [] : undefined}
|
|
294
|
+
options={options}
|
|
295
|
+
label="Hva er dine favorittfrukter?"
|
|
296
|
+
error={!hasSelectedValue && props.error}
|
|
297
|
+
isLoading={isLoading}
|
|
298
|
+
onChange={() => {
|
|
299
|
+
setIsLoading(true);
|
|
300
|
+
setTimeout(() => setIsLoading(false), 2000);
|
|
301
|
+
}}
|
|
302
|
+
onToggleSelected={(_, isSelected) => setHasSelectedValue(isSelected)}
|
|
303
|
+
/>
|
|
304
|
+
);
|
|
305
|
+
};
|
|
306
|
+
WithError.args = {
|
|
307
|
+
error: "Du må velge en favorittfrukt.",
|
|
311
308
|
};
|
|
312
309
|
|
|
313
310
|
function sleep(ms: number) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* eslint-disable
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
1
|
+
/* eslint-disable testing-library/no-unnecessary-act -- https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning */
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import React, { useId } from "react";
|
|
5
5
|
import { UNSAFE_Combobox } from "..";
|
|
@@ -38,54 +38,58 @@ const App = (props) => {
|
|
|
38
38
|
describe("Render combobox", () => {
|
|
39
39
|
describe("with multi select", () => {
|
|
40
40
|
it("Should be able to search, select and remove selections", async () => {
|
|
41
|
-
|
|
41
|
+
render(<App isMultiSelect options={options} />);
|
|
42
42
|
|
|
43
43
|
await act(async () => {
|
|
44
44
|
await userEvent.click(
|
|
45
|
-
|
|
45
|
+
screen.getByRole("combobox", { name: "Hva er dine favorittfrukter?" })
|
|
46
46
|
);
|
|
47
47
|
});
|
|
48
48
|
await act(async () => {
|
|
49
49
|
await userEvent.type(
|
|
50
|
-
|
|
50
|
+
screen.getByRole("combobox", {
|
|
51
|
+
name: "Hva er dine favorittfrukter?",
|
|
52
|
+
}),
|
|
51
53
|
"apple"
|
|
52
54
|
);
|
|
53
55
|
});
|
|
54
56
|
await act(async () => {
|
|
55
57
|
await userEvent.click(
|
|
56
|
-
await
|
|
58
|
+
await screen.findByRole("option", { name: "apple" })
|
|
57
59
|
);
|
|
58
60
|
});
|
|
59
61
|
expect(
|
|
60
|
-
await
|
|
62
|
+
await screen.findByRole("option", { name: "apple", selected: true })
|
|
61
63
|
).toBeInTheDocument();
|
|
62
64
|
await act(async () => {
|
|
63
65
|
await userEvent.click(
|
|
64
|
-
await
|
|
66
|
+
await screen.findByRole("button", { name: "apple slett" })
|
|
65
67
|
);
|
|
66
68
|
});
|
|
67
69
|
});
|
|
68
70
|
});
|
|
69
71
|
|
|
70
72
|
it("Should show loading icon when loading (used for async search)", async () => {
|
|
71
|
-
|
|
73
|
+
render(<App options={[]} isListOpen isLoading />);
|
|
72
74
|
|
|
73
|
-
expect(
|
|
75
|
+
expect(
|
|
76
|
+
await screen.findByRole("option", { name: "venter..." })
|
|
77
|
+
).toBeInTheDocument();
|
|
74
78
|
});
|
|
75
79
|
});
|
|
76
80
|
|
|
77
81
|
describe("Combobox state-handling", () => {
|
|
78
82
|
it("Should not select previous focused element when closes", async () => {
|
|
79
|
-
|
|
83
|
+
render(<App options={options} />);
|
|
80
84
|
|
|
81
85
|
await act(async () => {
|
|
82
86
|
await userEvent.click(
|
|
83
|
-
|
|
87
|
+
screen.getByRole("combobox", { name: "Hva er dine favorittfrukter?" })
|
|
84
88
|
);
|
|
85
89
|
});
|
|
86
90
|
await act(async () => {
|
|
87
91
|
await userEvent.type(
|
|
88
|
-
|
|
92
|
+
screen.getByRole("combobox", { name: "Hva er dine favorittfrukter?" }),
|
|
89
93
|
"ban"
|
|
90
94
|
);
|
|
91
95
|
await userEvent.keyboard("{ArrowDown}");
|
|
@@ -93,22 +97,20 @@ describe("Combobox state-handling", () => {
|
|
|
93
97
|
await userEvent.keyboard("{Enter}");
|
|
94
98
|
});
|
|
95
99
|
|
|
96
|
-
expect(
|
|
97
|
-
await utils.queryByRole("button", { name: "banana slett" })
|
|
98
|
-
).toBeNull();
|
|
100
|
+
expect(screen.queryByRole("button", { name: "banana slett" })).toBeNull();
|
|
99
101
|
});
|
|
100
102
|
|
|
101
103
|
it("Should reset list when resetting input (ESC)", async () => {
|
|
102
|
-
|
|
104
|
+
render(<App options={options} />);
|
|
103
105
|
|
|
104
106
|
await act(async () => {
|
|
105
107
|
await userEvent.click(
|
|
106
|
-
|
|
108
|
+
screen.getByRole("combobox", { name: "Hva er dine favorittfrukter?" })
|
|
107
109
|
);
|
|
108
110
|
});
|
|
109
111
|
await act(async () => {
|
|
110
112
|
await userEvent.type(
|
|
111
|
-
|
|
113
|
+
screen.getByRole("combobox", { name: "Hva er dine favorittfrukter?" }),
|
|
112
114
|
"apple"
|
|
113
115
|
);
|
|
114
116
|
await userEvent.keyboard("{ArrowDown}");
|
|
@@ -117,7 +119,7 @@ describe("Combobox state-handling", () => {
|
|
|
117
119
|
});
|
|
118
120
|
|
|
119
121
|
expect(
|
|
120
|
-
await
|
|
122
|
+
await screen.findByRole("option", { name: "banana" })
|
|
121
123
|
).toBeInTheDocument();
|
|
122
124
|
});
|
|
123
125
|
});
|
|
@@ -1,58 +1,53 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
1
|
import { Meta } from "@storybook/react";
|
|
3
2
|
import React, { useState } from "react";
|
|
4
3
|
import { Radio, RadioGroup } from "../../index";
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
const meta: Meta<typeof Radio> = {
|
|
7
6
|
title: "ds-react/Radio",
|
|
8
7
|
component: Radio,
|
|
9
|
-
subcomponents: {
|
|
10
|
-
RadioGroup,
|
|
11
|
-
},
|
|
12
8
|
argTypes: {
|
|
13
|
-
size: {
|
|
9
|
+
size: {
|
|
10
|
+
options: ["medium", "small"],
|
|
11
|
+
control: { type: "radio" },
|
|
12
|
+
},
|
|
14
13
|
},
|
|
15
|
-
}
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
16
|
|
|
17
|
-
export const Default = {
|
|
18
|
-
|
|
19
|
-
const [state, setState] = useState("radio1");
|
|
17
|
+
export const Default = (props) => {
|
|
18
|
+
const [state, setState] = useState("radio1");
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
return (
|
|
21
|
+
<RadioGroup
|
|
22
|
+
legend={props.legend}
|
|
23
|
+
description={props.description}
|
|
24
|
+
value={props.controlled ? state : undefined}
|
|
25
|
+
onChange={props.controlled ? setState : undefined}
|
|
26
|
+
hideLegend={props.hideLegend}
|
|
27
|
+
error={props.error ? "Errormelding" : undefined}
|
|
28
|
+
size={props?.size}
|
|
29
|
+
>
|
|
30
|
+
<Radio value="radio1">{props.children || "Apple"}</Radio>
|
|
31
|
+
<Radio
|
|
32
|
+
value="radio2"
|
|
33
|
+
description={props.radioDescription ? "Orange description" : undefined}
|
|
30
34
|
>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
controlled: false,
|
|
48
|
-
error: false,
|
|
49
|
-
size: "medium",
|
|
50
|
-
legend: "Legend-tekst",
|
|
51
|
-
radioDescription: false,
|
|
52
|
-
hideLegend: false,
|
|
53
|
-
children: "",
|
|
54
|
-
description: "",
|
|
55
|
-
},
|
|
35
|
+
{props.children || "Orange"}
|
|
36
|
+
</Radio>
|
|
37
|
+
<Radio value="radio3">{props.children || "Banana"}</Radio>
|
|
38
|
+
<Radio value="radio4">{props.children || "Melon"}</Radio>
|
|
39
|
+
</RadioGroup>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
Default.args = {
|
|
43
|
+
controlled: false,
|
|
44
|
+
error: false,
|
|
45
|
+
size: "medium",
|
|
46
|
+
legend: "Legend-tekst",
|
|
47
|
+
radioDescription: false,
|
|
48
|
+
hideLegend: false,
|
|
49
|
+
children: "",
|
|
50
|
+
description: "",
|
|
56
51
|
};
|
|
57
52
|
|
|
58
53
|
export const Group = () => (
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
1
|
import { Meta } from "@storybook/react";
|
|
3
2
|
import React, { useState } from "react";
|
|
4
3
|
|
|
@@ -32,31 +31,28 @@ export default {
|
|
|
32
31
|
},
|
|
33
32
|
} as Meta;
|
|
34
33
|
|
|
35
|
-
export const Default = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
darkmode: false,
|
|
58
|
-
hideLabel: true,
|
|
59
|
-
},
|
|
34
|
+
export const Default = (props) => {
|
|
35
|
+
const [state, setState] = useState("");
|
|
36
|
+
return (
|
|
37
|
+
<div data-theme={props.darkmode ? "dark" : "light"}>
|
|
38
|
+
<Search
|
|
39
|
+
value={props.controlled ? state : undefined}
|
|
40
|
+
onChange={props.controlled ? setState : undefined}
|
|
41
|
+
label="Søk"
|
|
42
|
+
size={props.size}
|
|
43
|
+
clearButton={props.clearButton}
|
|
44
|
+
variant={props.variant}
|
|
45
|
+
hideLabel={props.hideLabel}
|
|
46
|
+
error={props.error}
|
|
47
|
+
onSearchClick={console.log}
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
Default.args = {
|
|
53
|
+
controlled: false,
|
|
54
|
+
darkmode: false,
|
|
55
|
+
hideLabel: true,
|
|
60
56
|
};
|
|
61
57
|
|
|
62
58
|
export const Small = () => (
|
package/src/index.ts
CHANGED