@navikt/ds-react 5.5.0 → 5.6.0-beta.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 +446 -888
- package/cjs/accordion/AccordionItem.js +3 -2
- package/cjs/date/datepicker/DatePickerStandalone.js +2 -2
- 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/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/layout/bleed/Bleed.js +49 -0
- package/cjs/layout/bleed/index.js +8 -0
- package/cjs/layout/bleed/package.json +6 -0
- package/cjs/layout/content-box/ContentBox.js +56 -0
- package/cjs/layout/content-box/index.js +8 -0
- package/cjs/layout/content-box/package.json +6 -0
- package/cjs/layout/page-demo/AvatarPanel.js +18 -0
- package/cjs/layout/page-demo/Filter.js +21 -0
- package/cjs/layout/page-demo/Header.js +48 -0
- package/cjs/layout/page-demo/Intro.js +36 -0
- package/cjs/layout/page-demo/Sidebar.js +49 -0
- 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/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/AccordionItem.js +3 -2
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/date/datepicker/DatePickerStandalone.js +2 -2
- package/esm/date/datepicker/DatePickerStandalone.js.map +1 -1
- 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/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/Fieldset/useFieldset.d.ts +1 -1
- package/esm/form/Select.js +1 -1
- package/esm/form/Select.js.map +1 -1
- package/esm/form/checkbox/useCheckbox.d.ts +2 -2
- 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/radio/useRadio.d.ts +1 -1
- package/esm/form/search/Search.js +3 -1
- package/esm/form/search/Search.js.map +1 -1
- package/esm/layout/bleed/Bleed.d.ts +8 -0
- package/esm/layout/bleed/Bleed.js +21 -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.map +1 -1
- package/esm/layout/content-box/ContentBox.d.ts +8 -0
- package/esm/layout/content-box/ContentBox.js +28 -0
- package/esm/layout/content-box/ContentBox.js.map +1 -0
- package/esm/layout/content-box/index.d.ts +1 -0
- package/esm/layout/content-box/index.js +2 -0
- package/esm/layout/content-box/index.js.map +1 -0
- package/esm/layout/page-demo/AvatarPanel.d.ts +4 -0
- package/esm/layout/page-demo/AvatarPanel.js +12 -0
- package/esm/layout/page-demo/AvatarPanel.js.map +1 -0
- package/esm/layout/page-demo/Filter.d.ts +2 -0
- package/esm/layout/page-demo/Filter.js +15 -0
- package/esm/layout/page-demo/Filter.js.map +1 -0
- package/esm/layout/page-demo/Header.d.ts +2 -0
- package/esm/layout/page-demo/Header.js +42 -0
- package/esm/layout/page-demo/Header.js.map +1 -0
- package/esm/layout/page-demo/Intro.d.ts +2 -0
- package/esm/layout/page-demo/Intro.js +30 -0
- package/esm/layout/page-demo/Intro.js.map +1 -0
- package/esm/layout/page-demo/Sidebar.d.ts +4 -0
- package/esm/layout/page-demo/Sidebar.js +41 -0
- package/esm/layout/page-demo/Sidebar.js.map +1 -0
- 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.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 +3 -4
- package/src/accordion/AccordionItem.tsx +3 -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/DatePickerStandalone.tsx +1 -3
- package/src/date/datepicker/datepicker.stories.tsx +1 -1
- package/src/date/datepicker/datepicker.test.tsx +5 -4
- 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__/is-match.test.ts +3 -3
- package/src/date/utils/__tests__/parse-dates.test.ts +4 -2
- 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/layout/box/Box.stories.tsx +251 -256
- package/src/layout/box/Box.tsx +1 -1
- 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 +0 -1
- 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/esm/util/useId.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useId.js","sourceRoot":"","sources":["../../src/util/useId.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,SAAS,WAAW,CAAC,UAAmB;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,UAAU,IAAI,SAAS,CAAC;IACnC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,6CAA6C;YAC7C,6DAA6D;YAC7D,+BAA+B;YAC/B,wHAAwH;YACxH,QAAQ,IAAI,CAAC,CAAC;YACd,YAAY,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;SACtC;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAChB,OAAO,EAAE,CAAC;AACZ,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"useId.js","sourceRoot":"","sources":["../../src/util/useId.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,SAAS,WAAW,CAAC,UAAmB;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,UAAU,IAAI,SAAS,CAAC;IACnC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,6CAA6C;YAC7C,6DAA6D;YAC7D,+BAA+B;YAC/B,wHAAwH;YACxH,QAAQ,IAAI,CAAC,CAAC;YACd,YAAY,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;SACtC;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAChB,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,eAAe,GAAgC,KAAa,CAChE,OAAO,GAAG,EAAE,CAAC,iEAAiE;CAC/E,CAAC;AACF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,UAAmB;;IACvC,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,OAAO,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KAClD;IACD,0FAA0F;IAC1F,OAAO,MAAA,WAAW,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0-beta.0",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"module": "./esm/index.js",
|
|
19
19
|
"typings": "./esm/index.d.ts",
|
|
20
20
|
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
"provenance": true
|
|
21
|
+
"access": "public"
|
|
23
22
|
},
|
|
24
23
|
"files": [
|
|
25
24
|
"/cjs",
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"test": "TZ=UTC jest"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@floating-ui/react": "0.
|
|
39
|
+
"@floating-ui/react": "0.25.4",
|
|
41
40
|
"@navikt/aksel-icons": "^5.5.0",
|
|
42
41
|
"@navikt/ds-tokens": "^5.5.0",
|
|
43
42
|
"@radix-ui/react-tabs": "1.0.0",
|
|
@@ -7,6 +7,7 @@ import React, {
|
|
|
7
7
|
useState,
|
|
8
8
|
} from "react";
|
|
9
9
|
import { AccordionContext } from "./AccordionContext";
|
|
10
|
+
import { omit } from "../util";
|
|
10
11
|
|
|
11
12
|
export interface AccordionItemProps
|
|
12
13
|
extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -36,10 +37,7 @@ export const AccordionItemContext =
|
|
|
36
37
|
createContext<AccordionItemContextProps | null>(null);
|
|
37
38
|
|
|
38
39
|
const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
|
|
39
|
-
(
|
|
40
|
-
{ children, className, open, defaultOpen = false, onClick, id, ...rest },
|
|
41
|
-
ref
|
|
42
|
-
) => {
|
|
40
|
+
({ children, className, open, defaultOpen = false, ...rest }, ref) => {
|
|
43
41
|
const [internalOpen, setInternalOpen] = useState<boolean>(defaultOpen);
|
|
44
42
|
const context = useContext(AccordionContext);
|
|
45
43
|
|
|
@@ -64,7 +62,7 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
|
|
|
64
62
|
"navds-accordion__item--no-animation": !shouldAnimate.current,
|
|
65
63
|
})}
|
|
66
64
|
ref={ref}
|
|
67
|
-
{...rest}
|
|
65
|
+
{...omit(rest, ["onClick"])}
|
|
68
66
|
>
|
|
69
67
|
<AccordionItemContext.Provider
|
|
70
68
|
value={{
|
|
@@ -274,39 +274,26 @@ const SingleHeaderAccordion = ({
|
|
|
274
274
|
);
|
|
275
275
|
};
|
|
276
276
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
277
|
+
const sizes: AccordionProps["size"][] = ["large", "medium", "small"];
|
|
278
|
+
const headingSizes: AccordionProps["headingSize"][] = [
|
|
279
|
+
"large",
|
|
280
|
+
"medium",
|
|
281
|
+
"small",
|
|
282
|
+
"xsmall",
|
|
283
|
+
];
|
|
281
284
|
|
|
282
|
-
export const Size =
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
<
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
</div>
|
|
290
|
-
);
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
args: {
|
|
294
|
-
variant: "neutral",
|
|
295
|
-
},
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
export const HeadingSize = {
|
|
299
|
-
render: ({ ...props }) => {
|
|
300
|
-
return (
|
|
301
|
-
<div style={{ width: 500 }} className="colgap">
|
|
302
|
-
{headingSizes.map((element) => (
|
|
303
|
-
<SingleHeaderAccordion headingSize={element} {...props} />
|
|
304
|
-
))}
|
|
305
|
-
</div>
|
|
306
|
-
);
|
|
307
|
-
},
|
|
285
|
+
export const Size = (props) => (
|
|
286
|
+
<div style={{ width: 500 }} className="colgap">
|
|
287
|
+
{sizes.map((size) => (
|
|
288
|
+
<SingleHeaderAccordion key={size} size={size} {...props} />
|
|
289
|
+
))}
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
308
292
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
293
|
+
export const HeadingSize = (props) => (
|
|
294
|
+
<div style={{ width: 500 }} className="colgap">
|
|
295
|
+
{headingSizes.map((size) => (
|
|
296
|
+
<SingleHeaderAccordion key={size} headingSize={size} {...props} />
|
|
297
|
+
))}
|
|
298
|
+
</div>
|
|
299
|
+
);
|
|
@@ -140,7 +140,7 @@ export const Heading = () => {
|
|
|
140
140
|
export const Links = () => {
|
|
141
141
|
return (
|
|
142
142
|
<div className="colgap">
|
|
143
|
-
{variants.map((variant
|
|
143
|
+
{variants.map((variant) => (
|
|
144
144
|
<Alert key={variant} variant={variant}>
|
|
145
145
|
<Link href="#">Id elit esse enim reprehenderit</Link>
|
|
146
146
|
</Alert>
|
|
@@ -156,7 +156,7 @@ const AlertWithCloseButton = ({
|
|
|
156
156
|
size?: "medium" | "small";
|
|
157
157
|
children?: React.ReactNode;
|
|
158
158
|
}) => {
|
|
159
|
-
|
|
159
|
+
const [show, setShow] = React.useState(true);
|
|
160
160
|
|
|
161
161
|
return show ? (
|
|
162
162
|
<Alert
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
1
|
import React, { useState } from "react";
|
|
3
2
|
import { Chips } from ".";
|
|
4
3
|
|
|
@@ -23,46 +22,44 @@ export default {
|
|
|
23
22
|
|
|
24
23
|
const options = ["Norsk", "Dansk", "Svensk", "Tysk", "Spansk"];
|
|
25
24
|
|
|
26
|
-
export const Default = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const [filter, setFilter] = useState(options);
|
|
30
|
-
|
|
31
|
-
if (props.type === "toggle") {
|
|
32
|
-
return (
|
|
33
|
-
<Chips size={props.size ?? "medium"}>
|
|
34
|
-
{options.map((c) => (
|
|
35
|
-
<Chips.Toggle
|
|
36
|
-
selected={selected.includes(c)}
|
|
37
|
-
key={c}
|
|
38
|
-
onClick={() =>
|
|
39
|
-
setSelected(
|
|
40
|
-
selected.includes(c)
|
|
41
|
-
? selected.filter((x) => x !== c)
|
|
42
|
-
: [...selected, c]
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
>
|
|
46
|
-
{c}
|
|
47
|
-
</Chips.Toggle>
|
|
48
|
-
))}
|
|
49
|
-
</Chips>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
25
|
+
export const Default = (props) => {
|
|
26
|
+
const [selected, setSelected] = useState(["Dansk", "Svensk"]);
|
|
27
|
+
const [filter, setFilter] = useState(options);
|
|
52
28
|
|
|
29
|
+
if (props.type === "toggle") {
|
|
53
30
|
return (
|
|
54
31
|
<Chips size={props.size ?? "medium"}>
|
|
55
|
-
{
|
|
56
|
-
<Chips.
|
|
32
|
+
{options.map((c) => (
|
|
33
|
+
<Chips.Toggle
|
|
34
|
+
selected={selected.includes(c)}
|
|
57
35
|
key={c}
|
|
58
|
-
onClick={() =>
|
|
36
|
+
onClick={() =>
|
|
37
|
+
setSelected(
|
|
38
|
+
selected.includes(c)
|
|
39
|
+
? selected.filter((x) => x !== c)
|
|
40
|
+
: [...selected, c]
|
|
41
|
+
)
|
|
42
|
+
}
|
|
59
43
|
>
|
|
60
44
|
{c}
|
|
61
|
-
</Chips.
|
|
45
|
+
</Chips.Toggle>
|
|
62
46
|
))}
|
|
63
47
|
</Chips>
|
|
64
48
|
);
|
|
65
|
-
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Chips size={props.size ?? "medium"}>
|
|
53
|
+
{filter.map((c) => (
|
|
54
|
+
<Chips.Removable
|
|
55
|
+
key={c}
|
|
56
|
+
onClick={() => setFilter((x) => x.filter((y) => y !== c))}
|
|
57
|
+
>
|
|
58
|
+
{c}
|
|
59
|
+
</Chips.Removable>
|
|
60
|
+
))}
|
|
61
|
+
</Chips>
|
|
62
|
+
);
|
|
66
63
|
};
|
|
67
64
|
|
|
68
65
|
export const Toggle = () => {
|
|
@@ -44,7 +44,6 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
|
|
|
44
44
|
>(
|
|
45
45
|
(
|
|
46
46
|
{
|
|
47
|
-
children,
|
|
48
47
|
className,
|
|
49
48
|
locale = "nb",
|
|
50
49
|
dropdownCaption,
|
|
@@ -52,7 +51,6 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
|
|
|
52
51
|
disableWeekends = false,
|
|
53
52
|
showWeekNumber = false,
|
|
54
53
|
selected,
|
|
55
|
-
id,
|
|
56
54
|
defaultSelected,
|
|
57
55
|
onSelect,
|
|
58
56
|
fixedWeeks = true,
|
|
@@ -121,7 +119,7 @@ export const DatePickerStandalone: DatePickerStandaloneType = forwardRef<
|
|
|
121
119
|
showWeekNumber={showWeekNumber}
|
|
122
120
|
fixedWeeks={fixedWeeks}
|
|
123
121
|
showOutsideDays
|
|
124
|
-
{...omit(rest, ["onSelect"])}
|
|
122
|
+
{...omit(rest, ["onSelect", "children", "id"])}
|
|
125
123
|
/>
|
|
126
124
|
</div>
|
|
127
125
|
);
|
|
@@ -311,7 +311,7 @@ export const UseRangedDatepickerValidation = () => {
|
|
|
311
311
|
);
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
-
export const
|
|
314
|
+
export const DefaultShownMonth = () => {
|
|
315
315
|
const { datepickerProps, inputProps } = useDatepicker({
|
|
316
316
|
fromDate: new Date("Aug 23 2019"),
|
|
317
317
|
onDateChange: console.log,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { act, render } from "@testing-library/react";
|
|
1
|
+
import { act, render, screen } from "@testing-library/react";
|
|
3
2
|
import userEvent from "@testing-library/user-event";
|
|
4
3
|
import React from "react";
|
|
5
4
|
import { DatePicker, useDatepicker } from "..";
|
|
@@ -18,11 +17,13 @@ const App = () => {
|
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
describe("Render datepicker", () => {
|
|
20
|
+
// eslint-disable-next-line jest/expect-expect
|
|
21
21
|
it("Should not crash when e.target is window", async () => {
|
|
22
|
-
|
|
22
|
+
render(<App />);
|
|
23
23
|
|
|
24
|
+
// eslint-disable-next-line testing-library/no-unnecessary-act -- https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning
|
|
24
25
|
await act(async () => {
|
|
25
|
-
await userEvent.click(
|
|
26
|
+
await userEvent.click(screen.getByText("Velg dato"));
|
|
26
27
|
});
|
|
27
28
|
});
|
|
28
29
|
});
|
|
@@ -207,7 +207,7 @@ export const useDatepicker = (
|
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
!open && openOnFocus && handleOpen(true);
|
|
210
|
-
|
|
210
|
+
const day = parseDate(
|
|
211
211
|
e.target.value,
|
|
212
212
|
today,
|
|
213
213
|
locale,
|
|
@@ -227,7 +227,7 @@ export const useDatepicker = (
|
|
|
227
227
|
};
|
|
228
228
|
|
|
229
229
|
const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {
|
|
230
|
-
|
|
230
|
+
const day = parseDate(
|
|
231
231
|
e.target.value,
|
|
232
232
|
today,
|
|
233
233
|
locale,
|
|
@@ -204,7 +204,7 @@ export const useMonthpicker = (
|
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
206
|
!open && openOnFocus && handleOpen(true);
|
|
207
|
-
|
|
207
|
+
const day = parseDate(
|
|
208
208
|
e.target.value,
|
|
209
209
|
today,
|
|
210
210
|
locale,
|
|
@@ -223,7 +223,7 @@ export const useMonthpicker = (
|
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {
|
|
226
|
-
|
|
226
|
+
const day = parseDate(
|
|
227
227
|
e.target.value,
|
|
228
228
|
today,
|
|
229
229
|
locale,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* eslint-disable
|
|
2
|
-
import { act, 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 { act, render, screen } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { DatePicker, useRangeDatepicker } from "..";
|
|
@@ -23,15 +23,15 @@ const RangeDemo = () => {
|
|
|
23
23
|
|
|
24
24
|
describe("Writing in input sets correct values", () => {
|
|
25
25
|
it("useRangeDatepicker same date", async () => {
|
|
26
|
-
|
|
26
|
+
render(<RangeDemo />);
|
|
27
27
|
|
|
28
|
-
const fraInput =
|
|
29
|
-
const tilInput =
|
|
28
|
+
const fraInput = screen.getByRole("textbox", { name: "Fra" });
|
|
29
|
+
const tilInput = screen.getByRole("textbox", { name: "Til" });
|
|
30
30
|
await act(async () => {
|
|
31
31
|
await userEvent.type(fraInput, "03.08.2022");
|
|
32
32
|
await userEvent.type(tilInput, "03.08.2022");
|
|
33
33
|
});
|
|
34
|
-
const res =
|
|
34
|
+
const res = screen.getByTitle("res");
|
|
35
35
|
expect(res.innerHTML).toEqual(
|
|
36
36
|
JSON.stringify({
|
|
37
37
|
from: "2022-08-03T00:00:00.000Z",
|
|
@@ -40,16 +40,16 @@ describe("Writing in input sets correct values", () => {
|
|
|
40
40
|
);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
it("useRangeDatepicker before after to
|
|
44
|
-
|
|
43
|
+
it("useRangeDatepicker before after to", async () => {
|
|
44
|
+
render(<RangeDemo />);
|
|
45
45
|
|
|
46
|
-
const fraInput =
|
|
47
|
-
const tilInput =
|
|
46
|
+
const fraInput = screen.getByRole("textbox", { name: "Fra" });
|
|
47
|
+
const tilInput = screen.getByRole("textbox", { name: "Til" });
|
|
48
48
|
await act(async () => {
|
|
49
49
|
await userEvent.type(fraInput, "03.08.2022");
|
|
50
50
|
await userEvent.type(tilInput, "02.08.2022");
|
|
51
51
|
});
|
|
52
|
-
const res =
|
|
52
|
+
const res = screen.getByTitle("res");
|
|
53
53
|
expect(res.innerHTML).toEqual(
|
|
54
54
|
JSON.stringify({
|
|
55
55
|
from: "2022-08-03T00:00:00.000Z",
|
|
@@ -325,7 +325,7 @@ export const useRangeDatepicker = (
|
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
!open && openOnFocus && setOpen(true);
|
|
328
|
-
|
|
328
|
+
const day = parseDate(
|
|
329
329
|
e.target.value,
|
|
330
330
|
today,
|
|
331
331
|
locale,
|
|
@@ -349,7 +349,7 @@ export const useRangeDatepicker = (
|
|
|
349
349
|
};
|
|
350
350
|
|
|
351
351
|
const handleBlur = (e, src: RangeT) => {
|
|
352
|
-
|
|
352
|
+
const day = parseDate(
|
|
353
353
|
e.target.value,
|
|
354
354
|
today,
|
|
355
355
|
locale,
|
|
@@ -379,7 +379,7 @@ export const useRangeDatepicker = (
|
|
|
379
379
|
if (range?.from && range?.to) {
|
|
380
380
|
setOpen(false);
|
|
381
381
|
}
|
|
382
|
-
|
|
382
|
+
const prevToRange =
|
|
383
383
|
!selectedRange?.from && selectedRange?.to ? selectedRange?.to : range?.to;
|
|
384
384
|
|
|
385
385
|
const resetTo = isBefore(prevToRange, range?.from);
|
|
@@ -13,9 +13,9 @@ interface MonthType {
|
|
|
13
13
|
month: Date;
|
|
14
14
|
months: Date[];
|
|
15
15
|
focus: Date | undefined;
|
|
16
|
-
setFocus:
|
|
16
|
+
setFocus: (date?: Date) => void;
|
|
17
17
|
tabRoot?: Date;
|
|
18
|
-
setTabRoot:
|
|
18
|
+
setTabRoot: (date?: Date) => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const disableMonth = (month: Date, fromDate?: Date, toDate?: Date) => {
|
|
@@ -70,7 +70,7 @@ export interface MonthPickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
70
70
|
/**
|
|
71
71
|
* Callback for user-controlled state
|
|
72
72
|
*/
|
|
73
|
-
onMonthSelect?:
|
|
73
|
+
onMonthSelect?: (month?: Date) => void;
|
|
74
74
|
/**
|
|
75
75
|
* Used to set visible year programmatically. Component controlled by default
|
|
76
76
|
*/
|
|
@@ -62,9 +62,9 @@ export const MonthSelector = () => {
|
|
|
62
62
|
return (
|
|
63
63
|
<BodyShort as="table" className="rdp-table">
|
|
64
64
|
<tbody className="rdp-tbody">
|
|
65
|
-
{tableMonths.map((
|
|
66
|
-
<tr className="rdp-row" key={
|
|
67
|
-
{
|
|
65
|
+
{tableMonths.map((months, i) => (
|
|
66
|
+
<tr className="rdp-row" key={i}>
|
|
67
|
+
{months.map((month: Date) => {
|
|
68
68
|
return (
|
|
69
69
|
<td key={month.toDateString()} className="rdp-cell">
|
|
70
70
|
<MonthButton
|
|
@@ -22,18 +22,6 @@ describe("Returns initial year for monthpicker", () => {
|
|
|
22
22
|
)
|
|
23
23
|
).toBeFalsy();
|
|
24
24
|
});
|
|
25
|
-
test("Default selected should not be valid (false)", () => {
|
|
26
|
-
expect(
|
|
27
|
-
isSameYear(
|
|
28
|
-
new Date("Oct 4 2021"),
|
|
29
|
-
getInitialYear({
|
|
30
|
-
defaultMonth: new Date("Aug 4 2020"),
|
|
31
|
-
/* toDate: new Date("Oct 4 2021"), */
|
|
32
|
-
/* fromDate: new Date("Oct 4 2021"), */
|
|
33
|
-
})
|
|
34
|
-
)
|
|
35
|
-
).toBeFalsy();
|
|
36
|
-
});
|
|
37
25
|
test("Default selected should be valid with fromDate", () => {
|
|
38
26
|
expect(
|
|
39
27
|
isSameYear(
|
|
@@ -13,13 +13,13 @@ describe("Returns if date is disabled", () => {
|
|
|
13
13
|
test("Date should be disabled type Date[] (true)", () => {
|
|
14
14
|
expect(isMatch(new Date("Dec 4 2011"), disabled)).toBeTruthy();
|
|
15
15
|
});
|
|
16
|
-
test("Date should be disabled type Range (
|
|
16
|
+
test("Date should be disabled type Range (false)", () => {
|
|
17
17
|
expect(isMatch(new Date("Sep 5 2023"), disabled)).toBeTruthy();
|
|
18
18
|
});
|
|
19
19
|
test("Date should be disabled type Range (true)", () => {
|
|
20
20
|
expect(isMatch(new Date("Sep 3 2023"), disabled)).toBeTruthy();
|
|
21
21
|
});
|
|
22
|
-
test("Date should be disabled type After (true)", () => {
|
|
22
|
+
test("Date should be disabled type After (same month)(true)", () => {
|
|
23
23
|
expect(
|
|
24
24
|
isMatch(new Date("Aug 5 2018"), [{ after: new Date("Aug 2 2018") }])
|
|
25
25
|
).toBeTruthy();
|
|
@@ -34,7 +34,7 @@ describe("Returns if date is disabled", () => {
|
|
|
34
34
|
isMatch(new Date("Aug 1 2018"), [{ before: new Date("Aug 2 2018") }])
|
|
35
35
|
).toBeTruthy();
|
|
36
36
|
});
|
|
37
|
-
test("Date should be disabled type Before (
|
|
37
|
+
test("Date should be disabled type Before (false)", () => {
|
|
38
38
|
expect(
|
|
39
39
|
isMatch(new Date("Jul 1 2018"), [{ before: new Date("Aug 2 2018") }])
|
|
40
40
|
).toBeTruthy();
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { isValidDate } from "..";
|
|
1
|
+
/* eslint-disable jest/expect-expect */
|
|
2
|
+
import { parseDate, isValidDate } from "..";
|
|
3
3
|
import nb from "date-fns/locale/nb";
|
|
4
4
|
import getMonth from "date-fns/getMonth";
|
|
5
5
|
|
|
6
6
|
const check = (inp: string) =>
|
|
7
|
+
// eslint-disable-next-line jest/valid-expect
|
|
7
8
|
expect(isValidDate(parseDate(inp, new Date(), nb, "date", false)));
|
|
8
9
|
|
|
9
10
|
const checkTwoDigit = (inp: string) =>
|
|
11
|
+
// eslint-disable-next-line jest/valid-expect
|
|
10
12
|
expect(isValidDate(parseDate(inp, new Date(), nb, "date", true)));
|
|
11
13
|
|
|
12
14
|
const parse = (inp: string) => parseDate(inp, new Date(), nb, "date", false);
|
|
@@ -6,7 +6,7 @@ export const nextEnabled = (
|
|
|
6
6
|
key: string,
|
|
7
7
|
disabled: Matcher[],
|
|
8
8
|
currentMonth: Date,
|
|
9
|
-
setYearState:
|
|
9
|
+
setYearState: (date: Date) => void,
|
|
10
10
|
yearState: Date,
|
|
11
11
|
dropdownCaption: boolean,
|
|
12
12
|
fromDate?: Date,
|
|
@@ -148,7 +148,7 @@ const loopBack = (
|
|
|
148
148
|
months: Date[],
|
|
149
149
|
disabled: Matcher[],
|
|
150
150
|
yearState: Date,
|
|
151
|
-
setYearState:
|
|
151
|
+
setYearState: (date: Date) => void,
|
|
152
152
|
rowCheck: boolean,
|
|
153
153
|
dropdownCaption: boolean,
|
|
154
154
|
fromDate?: Date,
|
|
@@ -191,7 +191,7 @@ const loopForward = (
|
|
|
191
191
|
currentIndex: number,
|
|
192
192
|
months: Date[],
|
|
193
193
|
yearState: Date,
|
|
194
|
-
setYearState:
|
|
194
|
+
setYearState: (date: Date) => void,
|
|
195
195
|
disabled: Matcher[],
|
|
196
196
|
rowCheck: boolean,
|
|
197
197
|
dropdownCaption: boolean,
|
package/src/dropdown/Toggle.tsx
CHANGED
|
@@ -60,32 +60,29 @@ export const DefaultOpen = {
|
|
|
60
60
|
args: { chromatic: { delay: 300 } },
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
export const ControlledOpen = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</Dropdown>
|
|
88
|
-
);
|
|
89
|
-
},
|
|
90
|
-
args: { chromatic: { delay: 300 } },
|
|
63
|
+
export const ControlledOpen = () => {
|
|
64
|
+
const [openState, setOpenState] = useState(true);
|
|
65
|
+
return (
|
|
66
|
+
<Dropdown onSelect={(event) => console.log(event)} open={openState}>
|
|
67
|
+
<Button as={Dropdown.Toggle} onClick={() => setOpenState(!openState)}>
|
|
68
|
+
Toggle
|
|
69
|
+
</Button>
|
|
70
|
+
<Dropdown.Menu
|
|
71
|
+
strategy="fixed"
|
|
72
|
+
onClose={() => console.log("ONCLOSE CONTROLLED")}
|
|
73
|
+
>
|
|
74
|
+
<Dropdown.Menu.GroupedList>
|
|
75
|
+
<Dropdown.Menu.GroupedList.Heading>
|
|
76
|
+
Systemer og oppslagsverk
|
|
77
|
+
</Dropdown.Menu.GroupedList.Heading>
|
|
78
|
+
<Dropdown.Menu.GroupedList.Item
|
|
79
|
+
onClick={() => console.log("GroupedList.Item-click")}
|
|
80
|
+
>
|
|
81
|
+
Gosys
|
|
82
|
+
</Dropdown.Menu.GroupedList.Item>
|
|
83
|
+
</Dropdown.Menu.GroupedList>
|
|
84
|
+
</Dropdown.Menu>
|
|
85
|
+
</Dropdown>
|
|
86
|
+
);
|
|
91
87
|
};
|
|
88
|
+
ControlledOpen.args = { chromatic: { delay: 300 } };
|
package/src/dropdown/index.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default as Dropdown } from "./Dropdown";
|
|
2
|
-
export * from "./Dropdown";
|
|
1
|
+
export { default as Dropdown, type DropdownProps } from "./Dropdown";
|