@navikt/ds-react 6.1.0 → 6.2.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/accordion/Accordion.d.ts +4 -4
- package/cjs/alert/Alert.d.ts +12 -10
- package/cjs/alert/Alert.js.map +1 -1
- package/cjs/button/Button.d.ts +9 -8
- package/cjs/button/Button.js.map +1 -1
- package/cjs/chat/Chat.d.ts +6 -6
- package/cjs/chips/Chips.d.ts +2 -2
- package/cjs/copybutton/CopyButton.d.ts +14 -12
- package/cjs/copybutton/CopyButton.js.map +1 -1
- package/cjs/date/datepicker/types.d.ts +7 -6
- package/cjs/date/hooks/useDatepicker.d.ts +4 -3
- package/cjs/date/hooks/useDatepicker.js.map +1 -1
- package/cjs/date/hooks/useMonthPicker.d.ts +4 -3
- package/cjs/date/hooks/useMonthPicker.js.map +1 -1
- package/cjs/date/monthpicker/types.d.ts +2 -1
- package/cjs/date/parts/DateInput.d.ts +1 -1
- package/cjs/expansion-card/ExpansionCardTitle.d.ts +1 -1
- package/cjs/form/checkbox/CheckboxGroup.d.ts +3 -3
- package/cjs/form/checkbox/types.d.ts +4 -4
- package/cjs/form/combobox/types.d.ts +15 -15
- package/cjs/form/error-summary/ErrorSummary.d.ts +5 -5
- package/cjs/form/radio/RadioGroup.d.ts +1 -1
- package/cjs/form/search/Search.d.ts +3 -2
- package/cjs/form/search/Search.js.map +1 -1
- package/cjs/form/select/Select.d.ts +9 -9
- package/cjs/form/switch/Switch.d.ts +5 -5
- package/cjs/form/textarea/Textarea.d.ts +5 -4
- package/cjs/form/textarea/Textarea.js.map +1 -1
- package/cjs/form/useFormField.d.ts +10 -8
- package/cjs/form/useFormField.js.map +1 -1
- package/cjs/layout/bleed/Bleed.d.ts +9 -1
- package/cjs/layout/bleed/Bleed.js.map +1 -1
- package/cjs/layout/box/Box.d.ts +5 -5
- package/cjs/layout/grid/HGrid.d.ts +1 -3
- package/cjs/layout/grid/HGrid.js.map +1 -1
- package/cjs/layout/page/Page.d.ts +2 -2
- package/cjs/layout/responsive/Responsive.d.ts +2 -4
- package/cjs/layout/responsive/Responsive.js.map +1 -1
- package/cjs/layout/stack/Stack.d.ts +18 -4
- package/cjs/layout/stack/Stack.js.map +1 -1
- package/cjs/list/types.d.ts +1 -1
- package/cjs/loader/Loader.d.ts +1 -0
- package/cjs/loader/Loader.js.map +1 -1
- package/cjs/modal/Modal.js +28 -10
- package/cjs/modal/Modal.js.map +1 -1
- package/cjs/modal/ModalHeader.js +1 -1
- package/cjs/modal/ModalHeader.js.map +1 -1
- package/cjs/modal/ModalUtils.d.ts +5 -0
- package/cjs/modal/ModalUtils.js +9 -1
- package/cjs/modal/ModalUtils.js.map +1 -1
- package/cjs/modal/types.d.ts +8 -8
- package/cjs/pagination/Pagination.d.ts +3 -2
- package/cjs/pagination/Pagination.js.map +1 -1
- package/cjs/pagination/PaginationItem.d.ts +1 -1
- package/cjs/popover/Popover.d.ts +2 -1
- package/cjs/popover/Popover.js.map +1 -1
- package/cjs/read-more/ReadMore.d.ts +7 -7
- package/cjs/stepper/Step.d.ts +4 -4
- package/cjs/stepper/Stepper.d.ts +7 -5
- package/cjs/stepper/Stepper.js.map +1 -1
- package/cjs/table/AnimateHeight.d.ts +1 -1
- package/cjs/tabs/TabList.d.ts +1 -1
- package/cjs/tabs/Tabs.d.ts +7 -7
- package/cjs/timeline/Timeline.d.ts +6 -3
- package/cjs/timeline/Timeline.js +2 -1
- package/cjs/timeline/Timeline.js.map +1 -1
- package/cjs/timeline/period/index.d.ts +3 -2
- package/cjs/timeline/period/index.js.map +1 -1
- package/cjs/tooltip/Tooltip.d.ts +19 -12
- package/cjs/tooltip/Tooltip.js.map +1 -1
- package/esm/accordion/Accordion.d.ts +4 -4
- package/esm/alert/Alert.d.ts +12 -10
- package/esm/alert/Alert.js.map +1 -1
- package/esm/button/Button.d.ts +9 -8
- package/esm/button/Button.js.map +1 -1
- package/esm/chat/Chat.d.ts +6 -6
- package/esm/chips/Chips.d.ts +2 -2
- package/esm/copybutton/CopyButton.d.ts +14 -12
- package/esm/copybutton/CopyButton.js.map +1 -1
- package/esm/date/datepicker/types.d.ts +7 -6
- package/esm/date/hooks/useDatepicker.d.ts +4 -3
- package/esm/date/hooks/useDatepicker.js.map +1 -1
- package/esm/date/hooks/useMonthPicker.d.ts +4 -3
- package/esm/date/hooks/useMonthPicker.js.map +1 -1
- package/esm/date/monthpicker/types.d.ts +2 -1
- package/esm/date/parts/DateInput.d.ts +1 -1
- package/esm/expansion-card/ExpansionCardTitle.d.ts +1 -1
- package/esm/form/checkbox/CheckboxGroup.d.ts +3 -3
- package/esm/form/checkbox/types.d.ts +4 -4
- package/esm/form/combobox/types.d.ts +15 -15
- package/esm/form/error-summary/ErrorSummary.d.ts +5 -5
- package/esm/form/radio/RadioGroup.d.ts +1 -1
- package/esm/form/search/Search.d.ts +3 -2
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/select/Select.d.ts +9 -9
- package/esm/form/switch/Switch.d.ts +5 -5
- package/esm/form/textarea/Textarea.d.ts +5 -4
- package/esm/form/textarea/Textarea.js.map +1 -1
- package/esm/form/useFormField.d.ts +10 -8
- package/esm/form/useFormField.js.map +1 -1
- package/esm/layout/bleed/Bleed.d.ts +9 -1
- package/esm/layout/bleed/Bleed.js.map +1 -1
- package/esm/layout/box/Box.d.ts +5 -5
- package/esm/layout/grid/HGrid.d.ts +1 -3
- package/esm/layout/grid/HGrid.js.map +1 -1
- package/esm/layout/page/Page.d.ts +2 -2
- package/esm/layout/responsive/Responsive.d.ts +2 -4
- package/esm/layout/responsive/Responsive.js.map +1 -1
- package/esm/layout/stack/Stack.d.ts +18 -4
- package/esm/layout/stack/Stack.js.map +1 -1
- package/esm/list/types.d.ts +1 -1
- package/esm/loader/Loader.d.ts +1 -0
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/Modal.js +29 -11
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalHeader.js +1 -1
- package/esm/modal/ModalHeader.js.map +1 -1
- package/esm/modal/ModalUtils.d.ts +5 -0
- package/esm/modal/ModalUtils.js +7 -0
- package/esm/modal/ModalUtils.js.map +1 -1
- package/esm/modal/types.d.ts +8 -8
- package/esm/pagination/Pagination.d.ts +3 -2
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.d.ts +1 -1
- package/esm/popover/Popover.d.ts +2 -1
- package/esm/popover/Popover.js.map +1 -1
- package/esm/read-more/ReadMore.d.ts +7 -7
- package/esm/stepper/Step.d.ts +4 -4
- package/esm/stepper/Stepper.d.ts +7 -5
- package/esm/stepper/Stepper.js.map +1 -1
- package/esm/table/AnimateHeight.d.ts +1 -1
- package/esm/tabs/TabList.d.ts +1 -1
- package/esm/tabs/Tabs.d.ts +7 -7
- package/esm/timeline/Timeline.d.ts +6 -3
- package/esm/timeline/Timeline.js +2 -1
- package/esm/timeline/Timeline.js.map +1 -1
- package/esm/timeline/period/index.d.ts +3 -2
- package/esm/timeline/period/index.js.map +1 -1
- package/esm/tooltip/Tooltip.d.ts +19 -12
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/package.json +3 -4
- package/src/accordion/Accordion.tsx +4 -4
- package/src/accordion/accordion.stories.tsx +0 -2
- package/src/alert/Alert.tsx +12 -10
- package/src/button/Button.tsx +9 -8
- package/src/chat/Chat.tsx +6 -6
- package/src/chips/Chips.tsx +2 -2
- package/src/copybutton/CopyButton.tsx +14 -12
- package/src/date/datepicker/datepicker.stories.tsx +0 -1
- package/src/date/datepicker/types.ts +7 -6
- package/src/date/hooks/useDatepicker.tsx +4 -3
- package/src/date/hooks/useMonthPicker.tsx +4 -3
- package/src/date/monthpicker/types.ts +2 -1
- package/src/date/parts/DateInput.tsx +1 -1
- package/src/expansion-card/ExpansionCardTitle.tsx +1 -1
- package/src/form/checkbox/CheckboxGroup.tsx +3 -3
- package/src/form/checkbox/types.ts +4 -4
- package/src/form/combobox/types.ts +15 -15
- package/src/form/error-summary/ErrorSummary.tsx +5 -5
- package/src/form/radio/RadioGroup.tsx +1 -1
- package/src/form/search/Search.tsx +3 -2
- package/src/form/select/Select.tsx +9 -9
- package/src/form/select/select.stories.tsx +32 -37
- package/src/form/switch/Switch.tsx +5 -5
- package/src/form/textarea/Textarea.tsx +5 -4
- package/src/form/useFormField.ts +10 -8
- package/src/layout/bleed/Bleed.tsx +9 -1
- package/src/layout/box/Box.tsx +5 -5
- package/src/layout/grid/HGrid.tsx +1 -3
- package/src/layout/page/Page.tsx +2 -2
- package/src/layout/responsive/Responsive.tsx +2 -4
- package/src/layout/stack/Stack.tsx +18 -4
- package/src/link/stories/link.stories.tsx +187 -96
- package/src/list/types.ts +1 -1
- package/src/loader/Loader.tsx +1 -0
- package/src/modal/Modal.tsx +49 -10
- package/src/modal/ModalHeader.tsx +1 -1
- package/src/modal/ModalUtils.ts +14 -0
- package/src/modal/types.ts +8 -8
- package/src/pagination/Pagination.tsx +3 -2
- package/src/pagination/PaginationItem.tsx +1 -1
- package/src/popover/Popover.tsx +2 -1
- package/src/read-more/ReadMore.tsx +7 -7
- package/src/stepper/Step.tsx +4 -4
- package/src/stepper/Stepper.tsx +7 -5
- package/src/table/AnimateHeight.tsx +1 -1
- package/src/tabs/TabList.tsx +1 -1
- package/src/tabs/Tabs.tsx +7 -7
- package/src/timeline/Timeline.tsx +6 -3
- package/src/timeline/period/index.tsx +3 -2
- package/src/tooltip/Tooltip.tsx +19 -12
|
@@ -14,7 +14,7 @@ import copy from "../util/copy";
|
|
|
14
14
|
export interface CopyButtonProps
|
|
15
15
|
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* `"xsmall"` should _only_ be used in tables.
|
|
18
18
|
* @default "medium"
|
|
19
19
|
*/
|
|
20
20
|
size?: "medium" | "small" | "xsmall";
|
|
@@ -23,11 +23,11 @@ export interface CopyButtonProps
|
|
|
23
23
|
*/
|
|
24
24
|
variant?: "action" | "neutral";
|
|
25
25
|
/**
|
|
26
|
-
* Text to copy to clipboard
|
|
26
|
+
* Text to copy to clipboard.
|
|
27
27
|
*/
|
|
28
28
|
copyText: string;
|
|
29
29
|
/**
|
|
30
|
-
* Optional text in button
|
|
30
|
+
* Optional text in button.
|
|
31
31
|
*/
|
|
32
32
|
text?: string;
|
|
33
33
|
/**
|
|
@@ -36,36 +36,38 @@ export interface CopyButtonProps
|
|
|
36
36
|
*/
|
|
37
37
|
activeText?: string;
|
|
38
38
|
/**
|
|
39
|
-
* Callback when
|
|
39
|
+
* Callback that is called when internal copy-state changes.
|
|
40
|
+
*
|
|
41
|
+
* @param state `true` when copy-state is activated, `false` when copy-state is deactivated.
|
|
40
42
|
*/
|
|
41
43
|
onActiveChange?: (state: boolean) => void;
|
|
42
44
|
/**
|
|
43
|
-
* Icon shown when button is not clicked
|
|
45
|
+
* Icon shown when button is not clicked.
|
|
44
46
|
* @default <FilesIcon />
|
|
45
47
|
*/
|
|
46
48
|
icon?: React.ReactNode;
|
|
47
49
|
/**
|
|
48
|
-
* Icon shown when active
|
|
50
|
+
* Icon shown when active.
|
|
49
51
|
* @default <CheckmarkIcon />
|
|
50
52
|
*/
|
|
51
53
|
activeIcon?: React.ReactNode;
|
|
52
54
|
/**
|
|
53
|
-
* Timeout duration in milliseconds
|
|
55
|
+
* Timeout duration in milliseconds.
|
|
54
56
|
* @default 2000
|
|
55
57
|
*/
|
|
56
58
|
activeDuration?: number;
|
|
57
59
|
/**
|
|
58
|
-
* Accessible label for icon (ignored if text is set)
|
|
59
|
-
* @default
|
|
60
|
+
* Accessible label for icon (ignored if text is set).
|
|
61
|
+
* @default "Kopier"
|
|
60
62
|
*/
|
|
61
63
|
title?: string;
|
|
62
64
|
/**
|
|
63
|
-
* Accessible label for icon in active-state (ignored if text is set)
|
|
64
|
-
* @default
|
|
65
|
+
* Accessible label for icon in active-state (ignored if text is set).
|
|
66
|
+
* @default "Kopiert"
|
|
65
67
|
*/
|
|
66
68
|
activeTitle?: string;
|
|
67
69
|
/**
|
|
68
|
-
* Icon position in button
|
|
70
|
+
* Icon position in button.
|
|
69
71
|
* @default "left"
|
|
70
72
|
*/
|
|
71
73
|
iconPosition?: "left" | "right";
|
|
@@ -16,7 +16,7 @@ export type MultipleMode = {
|
|
|
16
16
|
min?: number;
|
|
17
17
|
max?: number;
|
|
18
18
|
/**
|
|
19
|
-
* Allows selecting a week at a time. Only used with mode
|
|
19
|
+
* Allows selecting a week at a time. Only used with `mode` is set to "multiple".
|
|
20
20
|
*/
|
|
21
21
|
onWeekNumberClick?: DayPickerBase["onWeekNumberClick"];
|
|
22
22
|
};
|
|
@@ -83,21 +83,22 @@ export interface DatePickerDefaultProps
|
|
|
83
83
|
*/
|
|
84
84
|
showWeekNumber?: boolean;
|
|
85
85
|
/**
|
|
86
|
-
* Open state for user-controlled state. Component controlled by default
|
|
86
|
+
* Open state for user-controlled state. Component controlled by default.
|
|
87
87
|
*/
|
|
88
88
|
open?: boolean;
|
|
89
89
|
/**
|
|
90
|
-
* onClose callback for user-controlled state
|
|
90
|
+
* onClose callback for user-controlled state.
|
|
91
91
|
*/
|
|
92
92
|
onClose?: () => void;
|
|
93
93
|
/**
|
|
94
|
-
* onOpenToggle callback for user-controlled state. Only called if `<DatePicker.Input />` is used
|
|
94
|
+
* onOpenToggle callback for user-controlled state. Only called if `<DatePicker.Input />` is used.
|
|
95
95
|
*/
|
|
96
96
|
onOpenToggle?: () => void;
|
|
97
97
|
/**
|
|
98
|
-
* Avoid using if possible
|
|
98
|
+
* **Avoid using if possible!**
|
|
99
|
+
*
|
|
99
100
|
* Changes what CSS position property to use.
|
|
100
|
-
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
|
|
101
|
+
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape.
|
|
101
102
|
* @default See Popover
|
|
102
103
|
*/
|
|
103
104
|
strategy?: "absolute" | "fixed";
|
|
@@ -49,10 +49,11 @@ export interface UseDatepickerOptions
|
|
|
49
49
|
*/
|
|
50
50
|
onValidate?: (val: DateValidationT) => void;
|
|
51
51
|
/**
|
|
52
|
-
* Allows input of with
|
|
52
|
+
* Allows input of with `yy` year format.
|
|
53
|
+
*
|
|
54
|
+
* Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th.
|
|
55
|
+
* e.g. In 2024 this equals to 1944 - 2043.
|
|
53
56
|
* @default true
|
|
54
|
-
* @Note Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th.
|
|
55
|
-
* In 2024 this equals to 1944 - 2043
|
|
56
57
|
*/
|
|
57
58
|
allowTwoDigitYear?: boolean;
|
|
58
59
|
}
|
|
@@ -36,10 +36,11 @@ export interface UseMonthPickerOptions
|
|
|
36
36
|
*/
|
|
37
37
|
defaultYear?: Date;
|
|
38
38
|
/**
|
|
39
|
-
* Allows input of with
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* Allows input of with `yy` year format.
|
|
40
|
+
*
|
|
41
|
+
* Decision between 20th and 21st century is based on before(todays year - 80) ? 21st : 20th.
|
|
42
42
|
* In 2024 this equals to 1944 - 2043
|
|
43
|
+
* @default true
|
|
43
44
|
*/
|
|
44
45
|
allowTwoDigitYear?: boolean;
|
|
45
46
|
}
|
|
@@ -69,7 +69,8 @@ export interface MonthPickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
69
69
|
*/
|
|
70
70
|
onYearChange?: (y?: Date) => void;
|
|
71
71
|
/**
|
|
72
|
-
* Avoid using if possible
|
|
72
|
+
* **Avoid using if possible!**
|
|
73
|
+
*
|
|
73
74
|
* Changes what CSS position property to use
|
|
74
75
|
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
|
|
75
76
|
* @default "absolute"
|
|
@@ -19,7 +19,7 @@ export interface CheckboxGroupProps
|
|
|
19
19
|
"onChange" | "errorPropagation" | "defaultValue"
|
|
20
20
|
> {
|
|
21
21
|
/**
|
|
22
|
-
* Collection of
|
|
22
|
+
* Collection of `<Checkbox/>`.
|
|
23
23
|
*/
|
|
24
24
|
children: React.ReactNode;
|
|
25
25
|
/**
|
|
@@ -27,11 +27,11 @@ export interface CheckboxGroupProps
|
|
|
27
27
|
*/
|
|
28
28
|
value?: any[];
|
|
29
29
|
/**
|
|
30
|
-
* Default checked checkboxes on render
|
|
30
|
+
* Default checked checkboxes on render.
|
|
31
31
|
*/
|
|
32
32
|
defaultValue?: any[];
|
|
33
33
|
/**
|
|
34
|
-
* Returns current checked checkboxes in group
|
|
34
|
+
* Returns current checked checkboxes in group.
|
|
35
35
|
*/
|
|
36
36
|
onChange?: (value: any[]) => void;
|
|
37
37
|
}
|
|
@@ -5,12 +5,12 @@ export interface CheckboxProps
|
|
|
5
5
|
extends FormFieldProps,
|
|
6
6
|
Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "value"> {
|
|
7
7
|
/**
|
|
8
|
-
* Adds error indication on checkbox
|
|
8
|
+
* Adds error indication on checkbox.
|
|
9
9
|
* @default false
|
|
10
10
|
*/
|
|
11
11
|
error?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Id for error resulting in checkbox having error
|
|
13
|
+
* Id for error resulting in checkbox having error.
|
|
14
14
|
*/
|
|
15
15
|
errorId?: string;
|
|
16
16
|
/**
|
|
@@ -26,12 +26,12 @@ export interface CheckboxProps
|
|
|
26
26
|
*/
|
|
27
27
|
value?: any;
|
|
28
28
|
/**
|
|
29
|
-
* Specify whether the Checkbox is in an indeterminate state
|
|
29
|
+
* Specify whether the Checkbox is in an indeterminate state.
|
|
30
30
|
* @default false
|
|
31
31
|
*/
|
|
32
32
|
indeterminate?: boolean;
|
|
33
33
|
/**
|
|
34
|
-
* Adds a description to extend labling of Checkbox
|
|
34
|
+
* Adds a description to extend labling of Checkbox.
|
|
35
35
|
*/
|
|
36
36
|
description?: string;
|
|
37
37
|
}
|
|
@@ -16,11 +16,11 @@ export interface ComboboxProps
|
|
|
16
16
|
extends FormFieldProps,
|
|
17
17
|
Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "onChange" | "value"> {
|
|
18
18
|
/**
|
|
19
|
-
* Combobox label
|
|
19
|
+
* Combobox label.
|
|
20
20
|
*/
|
|
21
21
|
label: React.ReactNode;
|
|
22
22
|
/**
|
|
23
|
-
* List of options to use for autocompletion
|
|
23
|
+
* List of options to use for autocompletion.
|
|
24
24
|
*/
|
|
25
25
|
options: string[];
|
|
26
26
|
/**
|
|
@@ -28,11 +28,11 @@ export interface ComboboxProps
|
|
|
28
28
|
*/
|
|
29
29
|
allowNewValues?: boolean;
|
|
30
30
|
/**
|
|
31
|
-
* If
|
|
31
|
+
* If `true` adds a button to clear the value in the input field
|
|
32
32
|
*/
|
|
33
33
|
clearButton?: boolean;
|
|
34
34
|
/**
|
|
35
|
-
* Custom name for the clear button. Requires
|
|
35
|
+
* Custom name for the clear button. Requires `clearButton` to be `true`.
|
|
36
36
|
*
|
|
37
37
|
* @default "Tøm"
|
|
38
38
|
*/
|
|
@@ -59,13 +59,13 @@ export interface ComboboxProps
|
|
|
59
59
|
*/
|
|
60
60
|
isListOpen?: boolean;
|
|
61
61
|
/**
|
|
62
|
-
* Set to
|
|
62
|
+
* Set to `true` when doing an async search and waiting for new filteredOptions.
|
|
63
63
|
*
|
|
64
64
|
* Will show a spinner in the dropdown and announce to screen readers that it is loading.
|
|
65
65
|
*/
|
|
66
66
|
isLoading?: boolean;
|
|
67
67
|
/**
|
|
68
|
-
* Set to
|
|
68
|
+
* Set to `true` to allow multiple selections.
|
|
69
69
|
*
|
|
70
70
|
* This will display selected values as a list of Chips in front of the input field, instead of a selection replacing the value of the input.
|
|
71
71
|
*
|
|
@@ -82,18 +82,18 @@ export interface ComboboxProps
|
|
|
82
82
|
value?: string,
|
|
83
83
|
) => void;
|
|
84
84
|
/**
|
|
85
|
-
* Callback function triggered whenever the input field is cleared
|
|
85
|
+
* Callback function triggered whenever the input field is cleared.
|
|
86
86
|
*
|
|
87
87
|
* @param event
|
|
88
88
|
* @returns
|
|
89
89
|
*/
|
|
90
90
|
onClear?: (event: React.PointerEvent | React.KeyboardEvent) => void;
|
|
91
91
|
/**
|
|
92
|
-
* Callback function triggered whenever an option is selected or de-selected
|
|
92
|
+
* Callback function triggered whenever an option is selected or de-selected.
|
|
93
93
|
*
|
|
94
|
-
* @param option
|
|
95
|
-
* @param isSelected
|
|
96
|
-
* @param isCustomOption
|
|
94
|
+
* @param option The selected option.
|
|
95
|
+
* @param isSelected Whether the option has been selected or unselected.
|
|
96
|
+
* @param isCustomOption Whether the option comes from user input, instead of from the list.
|
|
97
97
|
* @returns
|
|
98
98
|
*/
|
|
99
99
|
onToggleSelected?: (
|
|
@@ -113,25 +113,25 @@ export interface ComboboxProps
|
|
|
113
113
|
*/
|
|
114
114
|
maxSelected?: MaxSelected;
|
|
115
115
|
/**
|
|
116
|
-
* Set to
|
|
116
|
+
* Set to `true` to enable inline autocomplete.
|
|
117
117
|
*
|
|
118
118
|
* @default false
|
|
119
119
|
*/
|
|
120
120
|
shouldAutocomplete?: boolean;
|
|
121
121
|
/**
|
|
122
|
-
* When set to
|
|
122
|
+
* When set to `true` displays selected options as Chips before the input field
|
|
123
123
|
*
|
|
124
124
|
* @default true
|
|
125
125
|
*/
|
|
126
126
|
shouldShowSelectedOptions?: boolean;
|
|
127
127
|
/**
|
|
128
|
-
* When set to
|
|
128
|
+
* When set to `true` displays the toggle button for opening/closing the dropdown list
|
|
129
129
|
*
|
|
130
130
|
* @default true
|
|
131
131
|
*/
|
|
132
132
|
toggleListButton?: boolean;
|
|
133
133
|
/**
|
|
134
|
-
* Custom name for the toggle list-button. Requires "toggleListButton" to be
|
|
134
|
+
* Custom name for the toggle list-button. Requires "toggleListButton" to be `true`.
|
|
135
135
|
*
|
|
136
136
|
* @default "Alternativer"
|
|
137
137
|
*/
|
|
@@ -6,20 +6,20 @@ import ErrorSummaryItem, { ErrorSummaryItemType } from "./ErrorSummaryItem";
|
|
|
6
6
|
|
|
7
7
|
export interface ErrorSummaryProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Collection of `ErrorSummary.Item`.
|
|
10
10
|
*/
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
/**
|
|
13
|
-
* Changes padding and font-sizes
|
|
13
|
+
* Changes padding and font-sizes.
|
|
14
14
|
* @default "medium"
|
|
15
15
|
*/
|
|
16
16
|
size?: "medium" | "small";
|
|
17
17
|
/**
|
|
18
|
-
* Heading above links
|
|
18
|
+
* Heading above links.
|
|
19
19
|
*/
|
|
20
20
|
heading?: React.ReactNode;
|
|
21
21
|
/**
|
|
22
|
-
* Allows setting a different HTML h-tag
|
|
22
|
+
* Allows setting a different HTML h-tag.
|
|
23
23
|
* @default "h2"
|
|
24
24
|
*/
|
|
25
25
|
headingTag?: React.ElementType<any>;
|
|
@@ -30,7 +30,7 @@ interface ErrorSummaryComponent
|
|
|
30
30
|
ErrorSummaryProps & React.RefAttributes<HTMLDivElement>
|
|
31
31
|
> {
|
|
32
32
|
/**
|
|
33
|
-
* Link to error
|
|
33
|
+
* Link to error.
|
|
34
34
|
*
|
|
35
35
|
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
|
|
36
36
|
*
|
|
@@ -26,8 +26,9 @@ export interface SearchProps
|
|
|
26
26
|
Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "onChange" | "type"> {
|
|
27
27
|
children?: React.ReactNode;
|
|
28
28
|
/**
|
|
29
|
-
* Search label
|
|
30
|
-
*
|
|
29
|
+
* Search label.
|
|
30
|
+
*
|
|
31
|
+
* Will be hidden by default, is required for accessibility reasons.
|
|
31
32
|
*/
|
|
32
33
|
label: React.ReactNode;
|
|
33
34
|
/**
|
|
@@ -8,27 +8,27 @@ import { FormFieldProps, useFormField } from "../useFormField";
|
|
|
8
8
|
|
|
9
9
|
export interface SelectProps
|
|
10
10
|
extends FormFieldProps,
|
|
11
|
-
Omit<SelectHTMLAttributes<HTMLSelectElement>, "size"> {
|
|
11
|
+
Omit<SelectHTMLAttributes<HTMLSelectElement>, "size" | "multiple"> {
|
|
12
12
|
/**
|
|
13
|
-
* Collection of <option />-elements
|
|
13
|
+
* Collection of <option />-elements.
|
|
14
14
|
*/
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
/**
|
|
17
|
-
* Exposes the HTML size attribute
|
|
17
|
+
* Exposes the HTML size attribute.
|
|
18
18
|
*/
|
|
19
19
|
htmlSize?: number;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Sets inline-style on select wrapper.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Label for select.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
label: React.ReactNode;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Shows label and description for screenreaders only.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
hideLabel?: boolean;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -1,36 +1,15 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from "@storybook/react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import Select from "./Select";
|
|
3
|
+
import Select, { SelectProps } from "./Select";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const meta: Meta<typeof Select> = {
|
|
6
6
|
title: "ds-react/Select",
|
|
7
7
|
component: Select,
|
|
8
|
-
argTypes: {
|
|
9
|
-
size: {
|
|
10
|
-
control: {
|
|
11
|
-
type: "radio",
|
|
12
|
-
options: ["medium", "small"],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
description: {
|
|
16
|
-
type: "string",
|
|
17
|
-
},
|
|
18
|
-
error: {
|
|
19
|
-
type: "string",
|
|
20
|
-
},
|
|
21
|
-
hideLabel: {
|
|
22
|
-
type: "boolean",
|
|
23
|
-
},
|
|
24
|
-
disabled: {
|
|
25
|
-
type: "boolean",
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
8
|
parameters: {
|
|
29
9
|
chromatic: { disable: true },
|
|
30
10
|
},
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type Story = StoryObj<typeof Select>;
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
34
13
|
|
|
35
14
|
const content = (
|
|
36
15
|
<>
|
|
@@ -40,16 +19,32 @@ const content = (
|
|
|
40
19
|
</>
|
|
41
20
|
);
|
|
42
21
|
|
|
43
|
-
export const Default =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
export const Default: StoryFn<Omit<SelectProps, "children">> = (props) => (
|
|
23
|
+
<Select {...props}>{content}</Select>
|
|
24
|
+
);
|
|
25
|
+
Default.args = {
|
|
26
|
+
label: "Ipsum enim quis culpa",
|
|
27
|
+
};
|
|
28
|
+
Default.argTypes = {
|
|
29
|
+
description: {
|
|
30
|
+
type: "string",
|
|
31
|
+
},
|
|
32
|
+
size: {
|
|
33
|
+
control: { type: "radio" },
|
|
34
|
+
options: ["medium", "small"],
|
|
35
|
+
},
|
|
36
|
+
error: {
|
|
37
|
+
type: "string",
|
|
38
|
+
},
|
|
39
|
+
hideLabel: {
|
|
40
|
+
type: "boolean",
|
|
41
|
+
},
|
|
42
|
+
disabled: {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
},
|
|
45
|
+
readOnly: {
|
|
46
|
+
type: "boolean",
|
|
50
47
|
},
|
|
51
|
-
|
|
52
|
-
args: {},
|
|
53
48
|
};
|
|
54
49
|
|
|
55
50
|
export const Small = () => {
|
|
@@ -138,12 +133,12 @@ export const Readonly = () => {
|
|
|
138
133
|
);
|
|
139
134
|
};
|
|
140
135
|
|
|
141
|
-
export const Chromatic:
|
|
136
|
+
export const Chromatic: StoryObj<typeof Select> = {
|
|
142
137
|
render: () => (
|
|
143
138
|
<div>
|
|
144
139
|
<div>
|
|
145
140
|
<h2>Default</h2>
|
|
146
|
-
|
|
141
|
+
<Default label="Ipsum enim quis culpa" />
|
|
147
142
|
</div>
|
|
148
143
|
<div>
|
|
149
144
|
<h2>Small</h2>
|
|
@@ -36,24 +36,24 @@ export interface SwitchProps
|
|
|
36
36
|
extends Omit<FormFieldProps, "error" | "errorId">,
|
|
37
37
|
Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
38
38
|
/**
|
|
39
|
-
* Switch-label
|
|
39
|
+
* Switch-label.
|
|
40
40
|
*/
|
|
41
41
|
children: React.ReactNode;
|
|
42
42
|
/**
|
|
43
|
-
* If enabled shows the label and description for screenreaders only
|
|
43
|
+
* If enabled shows the label and description for screenreaders only.
|
|
44
44
|
*/
|
|
45
45
|
hideLabel?: boolean;
|
|
46
46
|
/**
|
|
47
|
-
* Toggles loading state with loader-component on switch
|
|
47
|
+
* Toggles loading state with loader-component on switch.
|
|
48
48
|
*/
|
|
49
49
|
loading?: boolean;
|
|
50
50
|
/**
|
|
51
|
-
* Positions switch on left/right side of label
|
|
51
|
+
* Positions switch on left/right side of label.
|
|
52
52
|
* @default "left"
|
|
53
53
|
*/
|
|
54
54
|
position?: "left" | "right";
|
|
55
55
|
/**
|
|
56
|
-
* Adds a description to extend labling of Switch
|
|
56
|
+
* Adds a description to extend labling of Switch.
|
|
57
57
|
*/
|
|
58
58
|
description?: string;
|
|
59
59
|
}
|
|
@@ -17,7 +17,8 @@ export interface TextareaProps
|
|
|
17
17
|
React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
18
18
|
/**
|
|
19
19
|
* Allowed character-count for content
|
|
20
|
-
*
|
|
20
|
+
*
|
|
21
|
+
* This is just a visual indicator! You will still need to handle actual character-limits/validation if needed.
|
|
21
22
|
*/
|
|
22
23
|
maxLength?: number;
|
|
23
24
|
/**
|
|
@@ -37,15 +38,15 @@ export interface TextareaProps
|
|
|
37
38
|
*/
|
|
38
39
|
minRows?: number;
|
|
39
40
|
/**
|
|
40
|
-
* Textarea label
|
|
41
|
+
* Textarea label.
|
|
41
42
|
*/
|
|
42
43
|
label: React.ReactNode;
|
|
43
44
|
/**
|
|
44
|
-
* If enabled shows the label and description for screenreaders only
|
|
45
|
+
* If enabled shows the label and description for screenreaders only.
|
|
45
46
|
*/
|
|
46
47
|
hideLabel?: boolean;
|
|
47
48
|
/**
|
|
48
|
-
* Enables resizing of field
|
|
49
|
+
* Enables resizing of field.
|
|
49
50
|
*/
|
|
50
51
|
resize?: boolean | "vertical" | "horizontal";
|
|
51
52
|
/**
|
package/src/form/useFormField.ts
CHANGED
|
@@ -5,32 +5,34 @@ import { FieldsetContext } from "./fieldset/context";
|
|
|
5
5
|
|
|
6
6
|
export interface FormFieldProps {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Adds a description to extend labling of the field.
|
|
9
|
+
* Error message for element.
|
|
9
10
|
*/
|
|
10
11
|
error?: React.ReactNode;
|
|
11
12
|
/**
|
|
12
|
-
* Override internal errorId
|
|
13
|
+
* Override internal errorId.
|
|
13
14
|
*/
|
|
14
15
|
errorId?: string;
|
|
15
16
|
/**
|
|
16
|
-
* Changes font-size, padding and gaps
|
|
17
|
+
* Changes font-size, padding and gaps.
|
|
17
18
|
*/
|
|
18
19
|
size?: "medium" | "small";
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* **Avoid using if possible for accessibility purposes**.
|
|
22
|
+
*
|
|
23
|
+
* Disables element.
|
|
22
24
|
*/
|
|
23
25
|
disabled?: boolean;
|
|
24
26
|
/**
|
|
25
|
-
* Adds a description to extend labling of a field
|
|
27
|
+
* Adds a description to extend labling of a field.
|
|
26
28
|
*/
|
|
27
29
|
description?: React.ReactNode;
|
|
28
30
|
/**
|
|
29
|
-
* Override internal id
|
|
31
|
+
* Override internal id.
|
|
30
32
|
*/
|
|
31
33
|
id?: string;
|
|
32
34
|
/**
|
|
33
|
-
* Read
|
|
35
|
+
* Read-only state.
|
|
34
36
|
*/
|
|
35
37
|
readOnly?: boolean;
|
|
36
38
|
}
|
|
@@ -9,7 +9,11 @@ export type BleedSpacingBlock = "0" | "px" | SpacingScale;
|
|
|
9
9
|
|
|
10
10
|
export interface BleedProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
11
|
/** **Negative** horizontal margin around children.
|
|
12
|
-
*
|
|
12
|
+
* Accepts a spacing token or an object of spacing tokens for different breakpoints.
|
|
13
|
+
*
|
|
14
|
+
* The `px` value is useful to nudge by just 1px.
|
|
15
|
+
* The `full` value is used to extend the margin to the full width of the parent.
|
|
16
|
+
*
|
|
13
17
|
* @example
|
|
14
18
|
* marginInline='4'
|
|
15
19
|
* marginInline='4 5'
|
|
@@ -20,6 +24,10 @@ export interface BleedProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
20
24
|
>;
|
|
21
25
|
/** **Negative** vertical margin around children.
|
|
22
26
|
* Accepts a spacing token or an object of spacing tokens for different breakpoints.
|
|
27
|
+
*
|
|
28
|
+
* The `px` value is useful to nudge by just 1px.
|
|
29
|
+
* This prop does **not** accept the `full` value.
|
|
30
|
+
*
|
|
23
31
|
* @example
|
|
24
32
|
* marginBlock='4'
|
|
25
33
|
* marginBlock='4 5'
|