@navikt/ds-react 2.1.6 → 2.1.7
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/README.md +4 -5
- package/_docs.json +293 -293
- package/cjs/accordion/AccordionContent.js +2 -2
- package/cjs/accordion/AccordionHeader.js +2 -2
- package/cjs/alert/Alert.js +2 -2
- package/cjs/chat/Chat.js +3 -3
- package/cjs/date/hooks/useRangeDatepicker.js +1 -1
- package/esm/accordion/AccordionContent.js +1 -1
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +1 -1
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/index.d.ts +1 -1
- package/esm/accordion/index.js.map +1 -1
- package/esm/alert/Alert.js +1 -1
- package/esm/alert/Alert.js.map +1 -1
- package/esm/alert/index.d.ts +1 -1
- package/esm/button/index.d.ts +1 -1
- package/esm/chat/Chat.js +1 -1
- package/esm/chat/Chat.js.map +1 -1
- package/esm/chat/index.d.ts +1 -1
- package/esm/chat/index.js.map +1 -1
- package/esm/chips/Removable.d.ts +1 -1
- package/esm/chips/Toggle.d.ts +1 -1
- package/esm/chips/index.d.ts +1 -1
- package/esm/chips/index.js.map +1 -1
- package/esm/date/hooks/useRangeDatepicker.js +1 -1
- package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
- package/esm/date/index.d.ts +6 -6
- package/esm/date/utils/index.d.ts +1 -1
- package/esm/date/utils/index.js.map +1 -1
- package/esm/form/Fieldset/index.d.ts +1 -1
- package/esm/form/checkbox/index.d.ts +2 -2
- package/esm/form/checkbox/index.js +1 -1
- package/esm/form/checkbox/index.js.map +1 -1
- package/esm/form/error-summary/index.d.ts +1 -1
- package/esm/form/index.d.ts +10 -10
- package/esm/form/index.js +1 -1
- package/esm/form/index.js.map +1 -1
- package/esm/form/radio/index.d.ts +2 -2
- package/esm/form/radio/index.js.map +1 -1
- package/esm/form/search/index.d.ts +1 -1
- package/esm/form/search/index.js +1 -1
- package/esm/form/search/index.js.map +1 -1
- package/esm/grid/index.d.ts +3 -3
- package/esm/grid/index.js.map +1 -1
- package/esm/guide-panel/index.d.ts +2 -2
- package/esm/guide-panel/index.js.map +1 -1
- package/esm/help-text/index.d.ts +1 -1
- package/esm/link/Link.d.ts +1 -1
- package/esm/link/index.d.ts +1 -1
- package/esm/link-panel/LinkPanelTitle.d.ts +1 -1
- package/esm/link-panel/index.d.ts +1 -1
- package/esm/loader/index.d.ts +1 -1
- package/esm/modal/index.d.ts +2 -2
- package/esm/modal/index.js.map +1 -1
- package/esm/pagination/index.d.ts +1 -1
- package/esm/pagination/index.js.map +1 -1
- package/esm/panel/Panel.d.ts +1 -1
- package/esm/panel/index.d.ts +1 -1
- package/esm/popover/index.d.ts +2 -2
- package/esm/popover/index.js.map +1 -1
- package/esm/read-more/index.d.ts +1 -1
- package/esm/stepper/index.d.ts +1 -1
- package/esm/stepper/index.js.map +1 -1
- package/esm/table/index.d.ts +8 -8
- package/esm/table/index.js.map +1 -1
- package/esm/tabs/index.d.ts +4 -4
- package/esm/tabs/index.js.map +1 -1
- package/esm/tag/index.d.ts +1 -1
- package/esm/tag/index.js.map +1 -1
- package/esm/toggle-group/index.d.ts +2 -2
- package/esm/toggle-group/index.js.map +1 -1
- package/esm/tooltip/index.d.ts +1 -1
- package/esm/tooltip/index.js.map +1 -1
- package/esm/typography/BodyLong.d.ts +1 -1
- package/esm/typography/BodyShort.d.ts +1 -1
- package/esm/typography/Detail.d.ts +1 -1
- package/esm/typography/ErrorMessage.d.ts +1 -1
- package/esm/typography/Heading.d.ts +1 -1
- package/esm/typography/Ingress.d.ts +1 -1
- package/esm/typography/Label.d.ts +1 -1
- package/esm/typography/index.d.ts +7 -7
- package/esm/typography/index.js +1 -1
- package/esm/typography/index.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/AccordionContent.tsx +1 -1
- package/src/accordion/AccordionHeader.tsx +1 -1
- package/src/accordion/accordion.stories.tsx +16 -14
- package/src/accordion/index.ts +1 -1
- package/src/alert/Alert.tsx +1 -1
- package/src/alert/alert.stories.tsx +35 -27
- package/src/alert/index.ts +1 -1
- package/src/button/button.stories.tsx +95 -83
- package/src/button/index.ts +1 -1
- package/src/chat/Chat.tsx +1 -1
- package/src/chat/chat.stories.tsx +27 -25
- package/src/chat/index.ts +1 -1
- package/src/chips/Removable.tsx +1 -1
- package/src/chips/Toggle.tsx +1 -1
- package/src/chips/chips.stories.tsx +32 -29
- package/src/chips/index.ts +1 -1
- package/src/date/datepicker/datepicker.stories.tsx +87 -81
- package/src/date/hooks/useRangeDatepicker.tsx +1 -1
- package/src/date/index.ts +8 -8
- package/src/date/monthpicker/monthpicker.stories.tsx +13 -11
- package/src/date/utils/index.ts +1 -1
- package/src/form/Fieldset/index.ts +1 -1
- package/src/form/checkbox/checkbox.stories.tsx +66 -61
- package/src/form/checkbox/index.ts +5 -2
- package/src/form/error-summary/error-summary.stories.tsx +16 -14
- package/src/form/error-summary/index.ts +1 -1
- package/src/form/index.ts +16 -11
- package/src/form/radio/index.ts +2 -2
- package/src/form/radio/radio.stories.tsx +39 -34
- package/src/form/search/index.ts +5 -1
- package/src/form/search/search.stories.tsx +26 -23
- package/src/form/stories/confirmation-panel.stories.tsx +19 -17
- package/src/form/stories/fieldset.stories.tsx +13 -11
- package/src/form/stories/select.stories.tsx +12 -10
- package/src/form/stories/switch.stories.tsx +9 -7
- package/src/form/stories/text-field.stories.tsx +8 -6
- package/src/form/stories/textarea.stories.tsx +16 -14
- package/src/grid/index.ts +3 -3
- package/src/guide-panel/guidepanel.stories.tsx +21 -19
- package/src/guide-panel/index.ts +2 -2
- package/src/help-text/help-text.stories.tsx +11 -9
- package/src/help-text/index.ts +1 -1
- package/src/link/Link.tsx +1 -1
- package/src/link/index.ts +1 -1
- package/src/link/link.stories.tsx +24 -22
- package/src/link-panel/LinkPanelTitle.tsx +1 -1
- package/src/link-panel/index.ts +1 -1
- package/src/link-panel/link-panel.stories.tsx +19 -17
- package/src/loader/index.ts +1 -1
- package/src/loader/loader.stories.tsx +8 -6
- package/src/modal/index.ts +2 -2
- package/src/modal/modal.stories.tsx +35 -30
- package/src/pagination/index.ts +1 -1
- package/src/pagination/pagination.stories.tsx +41 -36
- package/src/panel/Panel.tsx +1 -1
- package/src/panel/index.ts +1 -1
- package/src/panel/panel.stories.tsx +17 -15
- package/src/popover/index.ts +2 -2
- package/src/popover/popover.stories.tsx +25 -19
- package/src/read-more/index.ts +1 -1
- package/src/read-more/readmore.stories.tsx +20 -17
- package/src/stepper/index.ts +1 -1
- package/src/stepper/stepper.stories.tsx +44 -41
- package/src/table/index.ts +8 -8
- package/src/tabs/Tabs.stories.tsx +24 -22
- package/src/tabs/index.ts +4 -4
- package/src/tag/index.ts +1 -1
- package/src/tag/tag.stories.tsx +9 -7
- package/src/toggle-group/ToggleGroup.stories.tsx +21 -18
- package/src/toggle-group/index.ts +2 -2
- package/src/tooltip/index.ts +1 -1
- package/src/tooltip/tooltip.stories.tsx +22 -20
- package/src/typography/BodyLong.tsx +1 -1
- package/src/typography/BodyShort.tsx +1 -1
- package/src/typography/Detail.tsx +1 -1
- package/src/typography/ErrorMessage.tsx +1 -1
- package/src/typography/Heading.tsx +1 -1
- package/src/typography/Ingress.tsx +1 -1
- package/src/typography/Label.tsx +1 -1
- package/src/typography/heading.stories.tsx +5 -3
- package/src/typography/index.ts +10 -7
- package/src/typography/typography.stories.tsx +0 -44
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
1
2
|
import React, { useState } from "react";
|
|
2
3
|
import { Chips } from ".";
|
|
3
4
|
|
|
@@ -22,44 +23,46 @@ export default {
|
|
|
22
23
|
|
|
23
24
|
const options = ["Norsk", "Dansk", "Svensk", "Tysk", "Spansk"];
|
|
24
25
|
|
|
25
|
-
export const Default =
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
export const Default = {
|
|
27
|
+
render: (props) => {
|
|
28
|
+
const [selected, setSelected] = useState(["Dansk", "Svensk"]);
|
|
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
|
+
}
|
|
28
52
|
|
|
29
|
-
if (props.type === "toggle") {
|
|
30
53
|
return (
|
|
31
54
|
<Chips size={props.size ?? "medium"}>
|
|
32
|
-
{
|
|
33
|
-
<Chips.
|
|
34
|
-
selected={selected.includes(c)}
|
|
55
|
+
{filter.map((c) => (
|
|
56
|
+
<Chips.Removable
|
|
35
57
|
key={c}
|
|
36
|
-
onClick={() =>
|
|
37
|
-
setSelected(
|
|
38
|
-
selected.includes(c)
|
|
39
|
-
? selected.filter((x) => x !== c)
|
|
40
|
-
: [...selected, c]
|
|
41
|
-
)
|
|
42
|
-
}
|
|
58
|
+
onClick={() => setFilter((x) => x.filter((y) => y !== c))}
|
|
43
59
|
>
|
|
44
60
|
{c}
|
|
45
|
-
</Chips.
|
|
61
|
+
</Chips.Removable>
|
|
46
62
|
))}
|
|
47
63
|
</Chips>
|
|
48
64
|
);
|
|
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
|
-
);
|
|
65
|
+
},
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
export const Toggle = () => {
|
package/src/chips/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Chips, ChipsProps } from "./Chips";
|
|
1
|
+
export { default as Chips, type ChipsProps } from "./Chips";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
1
2
|
import React, { useId, useState } from "react";
|
|
2
3
|
import { UNSAFE_useDatepicker, UNSAFE_useRangeDatepicker } from "..";
|
|
3
4
|
import { Button } from "../..";
|
|
@@ -34,93 +35,95 @@ export default {
|
|
|
34
35
|
},
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
export const Default =
|
|
38
|
-
|
|
38
|
+
export const Default = {
|
|
39
|
+
render: (props) => {
|
|
40
|
+
const [open, setOpen] = useState(false);
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const rangeCtx = UNSAFE_useRangeDatepicker({
|
|
43
|
+
fromDate: new Date("Aug 23 2020"),
|
|
44
|
+
toDate: new Date("Aug 23 2023"),
|
|
45
|
+
});
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const singleCtx = UNSAFE_useDatepicker({
|
|
48
|
+
fromDate: new Date("Aug 23 2020"),
|
|
49
|
+
toDate: new Date("Aug 23 2023"),
|
|
50
|
+
});
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
const newProps = {
|
|
53
|
+
...(!props.inputfield || props.mode === "multiple"
|
|
54
|
+
? {
|
|
55
|
+
open,
|
|
56
|
+
onClose: () => setOpen(false),
|
|
57
|
+
fromDate: new Date("Aug 23 2020"),
|
|
58
|
+
toDate: new Date("Aug 23 2023"),
|
|
59
|
+
}
|
|
60
|
+
: {}),
|
|
61
|
+
};
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
const Comp = !props.standalone ? DatePicker : DatePicker.Standalone;
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
65
|
+
return (
|
|
66
|
+
<div>
|
|
67
|
+
<Comp
|
|
68
|
+
locale={props?.locale}
|
|
69
|
+
dropdownCaption={props?.dropdownCaption}
|
|
70
|
+
disableWeekends={props?.disableWeekends}
|
|
71
|
+
showWeekNumber={props.showWeekNumber}
|
|
72
|
+
mode={props.mode}
|
|
73
|
+
{...(props.mode === "single"
|
|
74
|
+
? singleCtx.datepickerProps
|
|
75
|
+
: props.mode === "range"
|
|
76
|
+
? rangeCtx.datepickerProps
|
|
77
|
+
: {})}
|
|
78
|
+
{...newProps}
|
|
79
|
+
>
|
|
80
|
+
{!props.standalone && (
|
|
81
|
+
<>
|
|
82
|
+
{props.inputfield && props.mode !== "multiple" ? (
|
|
83
|
+
<>
|
|
84
|
+
{props.mode === "range" ? (
|
|
85
|
+
<div style={{ display: "flex", gap: "1rem" }}>
|
|
86
|
+
<DatePicker.Input
|
|
87
|
+
label="Fra"
|
|
88
|
+
size={props?.size}
|
|
89
|
+
{...rangeCtx.fromInputProps}
|
|
90
|
+
/>
|
|
91
|
+
<DatePicker.Input
|
|
92
|
+
label="Til"
|
|
93
|
+
size={props?.size}
|
|
94
|
+
{...rangeCtx.toInputProps}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
) : (
|
|
98
|
+
<>
|
|
99
|
+
<DatePicker.Input
|
|
100
|
+
label="Velg dato"
|
|
101
|
+
size={props?.size}
|
|
102
|
+
{...singleCtx.inputProps}
|
|
103
|
+
/>
|
|
104
|
+
</>
|
|
105
|
+
)}
|
|
106
|
+
</>
|
|
107
|
+
) : (
|
|
108
|
+
<Button onClick={() => setOpen((x) => !x)}>
|
|
109
|
+
Åpne datovelger
|
|
110
|
+
</Button>
|
|
111
|
+
)}
|
|
112
|
+
</>
|
|
113
|
+
)}
|
|
114
|
+
</Comp>
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
},
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
args: {
|
|
120
|
+
dropdownCaption: false,
|
|
121
|
+
disableWeekends: false,
|
|
122
|
+
showWeekNumber: false,
|
|
123
|
+
inputfield: true,
|
|
124
|
+
standalone: false,
|
|
125
|
+
openOnFocus: true,
|
|
126
|
+
},
|
|
124
127
|
};
|
|
125
128
|
|
|
126
129
|
export const DropdownCaption = () => (
|
|
@@ -198,9 +201,11 @@ export const OpenOnFocus = () => {
|
|
|
198
201
|
export const NB = () => (
|
|
199
202
|
<DatePicker.Standalone locale="nb" today={new Date("2006-07-01")} />
|
|
200
203
|
);
|
|
204
|
+
|
|
201
205
|
export const NN = () => (
|
|
202
206
|
<DatePicker.Standalone locale="nn" today={new Date("2006-07-01")} />
|
|
203
207
|
);
|
|
208
|
+
|
|
204
209
|
export const EN = () => (
|
|
205
210
|
<DatePicker.Standalone locale="en" today={new Date("2006-07-01")} />
|
|
206
211
|
);
|
|
@@ -212,6 +217,7 @@ export const Standalone = () => (
|
|
|
212
217
|
export const StandaloneRange = () => (
|
|
213
218
|
<DatePicker.Standalone mode="range" today={new Date("2006-07-01")} />
|
|
214
219
|
);
|
|
220
|
+
|
|
215
221
|
export const StandaloneMultiple = () => (
|
|
216
222
|
<DatePicker.Standalone mode="multiple" today={new Date("2006-07-01")} />
|
|
217
223
|
);
|
|
@@ -388,11 +388,11 @@ export const useRangeDatepicker = (
|
|
|
388
388
|
formatDateForInput(prevToRange, locale, "date", inputFormat)
|
|
389
389
|
)
|
|
390
390
|
: setToInputValue("");
|
|
391
|
+
updateRange({ from: range?.from, to: resetTo ? undefined : prevToRange });
|
|
391
392
|
updateValidation(
|
|
392
393
|
{ isValidDate: !!range?.from, isEmpty: !range?.from },
|
|
393
394
|
{ isValidDate: !!range?.to, isEmpty: !prevToRange || resetTo }
|
|
394
395
|
);
|
|
395
|
-
updateRange({ from: range?.from, to: resetTo ? undefined : prevToRange });
|
|
396
396
|
};
|
|
397
397
|
|
|
398
398
|
const fromChange = (
|
package/src/date/index.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { DateInputProps } from "./DateInput";
|
|
1
|
+
export { type DateInputProps } from "./DateInput";
|
|
2
2
|
export {
|
|
3
|
-
DatePickerProps,
|
|
3
|
+
type DatePickerProps,
|
|
4
4
|
default as UNSAFE_DatePicker,
|
|
5
5
|
} from "./datepicker/DatePicker";
|
|
6
|
-
export { DatePickerStandaloneProps } from "./datepicker/DatePickerStandalone";
|
|
7
|
-
export { MonthPickerStandaloneProps } from "./monthpicker/MonthPickerStandalone";
|
|
6
|
+
export { type DatePickerStandaloneProps } from "./datepicker/DatePickerStandalone";
|
|
7
|
+
export { type MonthPickerStandaloneProps } from "./monthpicker/MonthPickerStandalone";
|
|
8
8
|
export {
|
|
9
9
|
UNSAFE_useDatepicker,
|
|
10
10
|
UNSAFE_useMonthpicker,
|
|
11
11
|
UNSAFE_useRangeDatepicker,
|
|
12
|
-
RangeValidationT,
|
|
13
|
-
DateValidationT,
|
|
14
|
-
MonthValidationT,
|
|
12
|
+
type RangeValidationT,
|
|
13
|
+
type DateValidationT,
|
|
14
|
+
type MonthValidationT,
|
|
15
15
|
} from "./hooks";
|
|
16
16
|
export {
|
|
17
17
|
default as UNSAFE_MonthPicker,
|
|
18
|
-
MonthPickerProps,
|
|
18
|
+
type MonthPickerProps,
|
|
19
19
|
} from "./monthpicker/MonthPicker";
|
|
@@ -54,17 +54,19 @@ export const NB = () => <MonthPicker.Standalone locale="nb" />;
|
|
|
54
54
|
export const NN = () => <MonthPicker.Standalone locale="nn" />;
|
|
55
55
|
export const EN = () => <MonthPicker.Standalone locale="en" />;
|
|
56
56
|
|
|
57
|
-
export const DisabledMonths =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
export const DisabledMonths = {
|
|
58
|
+
render: (props) => {
|
|
59
|
+
return (
|
|
60
|
+
<MonthPicker.Standalone
|
|
61
|
+
disabled={[
|
|
62
|
+
{ from: new Date("Jan 1 2022"), to: new Date("Jul 6 2022") },
|
|
63
|
+
{ from: new Date("Apr 2 2023"), to: new Date("Dec 4 2023") },
|
|
64
|
+
new Date("Sep 5 2022"),
|
|
65
|
+
new Date("Jan 5 2023"),
|
|
66
|
+
]}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
},
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
export const Standalone = () => {
|
package/src/date/utils/index.ts
CHANGED
|
@@ -17,5 +17,5 @@ export { disableDate } from "./dates-disabled";
|
|
|
17
17
|
|
|
18
18
|
export { dateIsInCurrentMonth, isValidDate, hasNextYear } from "./check-dates";
|
|
19
19
|
export { getInitialYear } from "./get-initial-year";
|
|
20
|
-
export { isMatch, isDateInRange, Matcher } from "./is-match";
|
|
20
|
+
export { isMatch, isDateInRange, type Matcher } from "./is-match";
|
|
21
21
|
export { nextEnabled } from "./navigation";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
1
2
|
import React, { useState } from "react";
|
|
2
3
|
import { Checkbox, CheckboxGroup } from "../../index";
|
|
3
|
-
import { Meta } from "@storybook/react
|
|
4
|
+
import { Meta } from "@storybook/react";
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
|
-
title: "ds-react/
|
|
7
|
+
title: "ds-react/Checkbox",
|
|
7
8
|
component: Checkbox,
|
|
8
9
|
subcomponents: {
|
|
9
10
|
CheckboxGroup,
|
|
@@ -13,69 +14,73 @@ export default {
|
|
|
13
14
|
},
|
|
14
15
|
} as Meta;
|
|
15
16
|
|
|
16
|
-
export const Default =
|
|
17
|
-
|
|
17
|
+
export const Default = {
|
|
18
|
+
render: (props) => {
|
|
19
|
+
const [state, setState] = useState(["checkbox1"]);
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
>
|
|
30
|
-
<Checkbox
|
|
31
|
-
value="checkbox1"
|
|
32
|
-
indeterminate={props.indeterminate}
|
|
33
|
-
hideLabel={props.hideLabel}
|
|
34
|
-
>
|
|
35
|
-
{props.children || "Apple"}
|
|
36
|
-
</Checkbox>
|
|
37
|
-
<Checkbox
|
|
38
|
-
value="checkbox2"
|
|
39
|
-
error={props.errorSingle}
|
|
40
|
-
description={
|
|
41
|
-
props.checkboxDescription
|
|
42
|
-
? "Quis laborum culpa enim amet cillum veniam."
|
|
43
|
-
: undefined
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<CheckboxGroup
|
|
24
|
+
legend={props.legend}
|
|
25
|
+
description={props.description}
|
|
26
|
+
value={props.controlled ? state : undefined}
|
|
27
|
+
onChange={props.controlled ? setState : undefined}
|
|
28
|
+
hideLegend={props.hideLegend}
|
|
29
|
+
error={
|
|
30
|
+
props.errorGroup ? "Errormelding for checkboxgruppe" : undefined
|
|
44
31
|
}
|
|
45
|
-
|
|
46
|
-
hideLabel={props.hideLabel}
|
|
47
|
-
>
|
|
48
|
-
{props.children || "Orange"}
|
|
49
|
-
</Checkbox>
|
|
50
|
-
<Checkbox
|
|
51
|
-
value="checkbox3"
|
|
52
|
-
indeterminate={props.indeterminate}
|
|
53
|
-
hideLabel={props.hideLabel}
|
|
32
|
+
size={props?.size}
|
|
54
33
|
>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
34
|
+
<Checkbox
|
|
35
|
+
value="checkbox1"
|
|
36
|
+
indeterminate={props.indeterminate}
|
|
37
|
+
hideLabel={props.hideLabel}
|
|
38
|
+
>
|
|
39
|
+
{props.children || "Apple"}
|
|
40
|
+
</Checkbox>
|
|
41
|
+
<Checkbox
|
|
42
|
+
value="checkbox2"
|
|
43
|
+
error={props.errorSingle}
|
|
44
|
+
description={
|
|
45
|
+
props.checkboxDescription
|
|
46
|
+
? "Quis laborum culpa enim amet cillum veniam."
|
|
47
|
+
: undefined
|
|
48
|
+
}
|
|
49
|
+
indeterminate={props.indeterminate}
|
|
50
|
+
hideLabel={props.hideLabel}
|
|
51
|
+
>
|
|
52
|
+
{props.children || "Orange"}
|
|
53
|
+
</Checkbox>
|
|
54
|
+
<Checkbox
|
|
55
|
+
value="checkbox3"
|
|
56
|
+
indeterminate={props.indeterminate}
|
|
57
|
+
hideLabel={props.hideLabel}
|
|
58
|
+
>
|
|
59
|
+
{props.children || "Banana"}
|
|
60
|
+
</Checkbox>
|
|
61
|
+
<Checkbox
|
|
62
|
+
value="checkbox4"
|
|
63
|
+
indeterminate={props.indeterminate}
|
|
64
|
+
hideLabel={props.hideLabel}
|
|
65
|
+
>
|
|
66
|
+
{props.children || "Melon"}
|
|
67
|
+
</Checkbox>
|
|
68
|
+
</CheckboxGroup>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
},
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
args: {
|
|
74
|
+
controlled: false,
|
|
75
|
+
legend: "Legend-tekst",
|
|
76
|
+
checkboxDescription: false,
|
|
77
|
+
hideLabel: false,
|
|
78
|
+
hideLegend: false,
|
|
79
|
+
errorSingle: false,
|
|
80
|
+
errorGroup: false,
|
|
81
|
+
children: "",
|
|
82
|
+
description: "",
|
|
83
|
+
},
|
|
79
84
|
};
|
|
80
85
|
|
|
81
86
|
export const Group = () => (
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export { default as Checkbox, CheckboxProps } from "./Checkbox";
|
|
2
|
-
export {
|
|
1
|
+
export { default as Checkbox, type CheckboxProps } from "./Checkbox";
|
|
2
|
+
export {
|
|
3
|
+
default as CheckboxGroup,
|
|
4
|
+
type CheckboxGroupProps,
|
|
5
|
+
} from "./CheckboxGroup";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Meta } from "@storybook/react
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
3
|
import { ErrorSummary } from "..";
|
|
4
4
|
export default {
|
|
5
|
-
title: "ds-react/
|
|
5
|
+
title: "ds-react/Errorsummary",
|
|
6
6
|
component: ErrorSummary,
|
|
7
7
|
argTypes: {
|
|
8
8
|
headingTag: {
|
|
@@ -19,18 +19,20 @@ export default {
|
|
|
19
19
|
},
|
|
20
20
|
} as Meta;
|
|
21
21
|
|
|
22
|
-
export const Default =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
export const Default = {
|
|
23
|
+
render: (props) => (
|
|
24
|
+
<ErrorSummary
|
|
25
|
+
heading="Feiloppsummering komponent"
|
|
26
|
+
headingTag={props.headingTag || "h2"}
|
|
27
|
+
size={props.size ?? undefined}
|
|
28
|
+
>
|
|
29
|
+
<ErrorSummary.Item href="#1">Checkbox må fylles ut</ErrorSummary.Item>
|
|
30
|
+
<ErrorSummary.Item href="#2">
|
|
31
|
+
Tekstfeltet må ha en godkjent e-mail
|
|
32
|
+
</ErrorSummary.Item>
|
|
33
|
+
</ErrorSummary>
|
|
34
|
+
),
|
|
35
|
+
};
|
|
34
36
|
|
|
35
37
|
export const Small = () => (
|
|
36
38
|
<ErrorSummary heading="Feiloppsummering komponent" size="small">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as ErrorSummary } from "./ErrorSummary";
|
|
2
|
-
export { ErrorSummaryProps } from "./ErrorSummary";
|
|
2
|
+
export { type ErrorSummaryProps } from "./ErrorSummary";
|
package/src/form/index.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
export {
|
|
2
2
|
Checkbox,
|
|
3
3
|
CheckboxGroup,
|
|
4
|
-
CheckboxGroupProps,
|
|
5
|
-
CheckboxProps,
|
|
4
|
+
type CheckboxGroupProps,
|
|
5
|
+
type CheckboxProps,
|
|
6
6
|
} from "./checkbox";
|
|
7
7
|
export {
|
|
8
|
-
ConfirmationPanelProps,
|
|
8
|
+
type ConfirmationPanelProps,
|
|
9
9
|
default as ConfirmationPanel,
|
|
10
10
|
} from "./ConfirmationPanel";
|
|
11
|
-
export { ErrorSummary, ErrorSummaryProps } from "./error-summary";
|
|
12
|
-
export { Fieldset, FieldsetContext, FieldsetProps } from "./Fieldset";
|
|
13
|
-
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export { ErrorSummary, type ErrorSummaryProps } from "./error-summary";
|
|
12
|
+
export { Fieldset, FieldsetContext, type FieldsetProps } from "./Fieldset";
|
|
13
|
+
export {
|
|
14
|
+
Radio,
|
|
15
|
+
RadioGroup,
|
|
16
|
+
type RadioGroupProps,
|
|
17
|
+
type RadioProps,
|
|
18
|
+
} from "./radio";
|
|
19
|
+
export { Search, type SearchClearEvent, type SearchProps } from "./search";
|
|
20
|
+
export { default as Select, type SelectProps } from "./Select";
|
|
21
|
+
export { default as Switch, type SwitchProps } from "./Switch";
|
|
22
|
+
export { Counter, default as Textarea, type TextareaProps } from "./Textarea";
|
|
23
|
+
export { default as TextField, type TextFieldProps } from "./TextField";
|
package/src/form/radio/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Radio, RadioProps } from "./Radio";
|
|
2
|
-
export { default as RadioGroup, RadioGroupProps } from "./RadioGroup";
|
|
1
|
+
export { default as Radio, type RadioProps } from "./Radio";
|
|
2
|
+
export { default as RadioGroup, type RadioGroupProps } from "./RadioGroup";
|