@navikt/ds-react 6.3.1 → 6.3.3

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.
Files changed (61) hide show
  1. package/cjs/date/hooks/useDatepicker.js +1 -1
  2. package/cjs/date/hooks/useDatepicker.js.map +1 -1
  3. package/cjs/form/checkbox/types.d.ts +1 -1
  4. package/cjs/form/file-upload/i18n/i18n.context.d.ts +1 -1
  5. package/cjs/form/file-upload/i18n/i18n.context.js +2 -2
  6. package/cjs/form/file-upload/i18n/i18n.context.js.map +1 -1
  7. package/cjs/form/file-upload/i18n/i18n.types.d.ts +1 -1
  8. package/cjs/form/file-upload/i18n/locales/nb.d.ts +21 -0
  9. package/cjs/form/file-upload/i18n/locales/nb.js +23 -0
  10. package/cjs/form/file-upload/i18n/locales/nb.js.map +1 -0
  11. package/cjs/form/file-upload/parts/dropzone/Dropzone.js +1 -1
  12. package/cjs/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
  13. package/cjs/form/file-upload/parts/item/Item.d.ts +4 -2
  14. package/cjs/form/file-upload/parts/item/Item.js.map +1 -1
  15. package/cjs/form/radio/types.d.ts +3 -3
  16. package/cjs/form/search/Search.d.ts +14 -10
  17. package/cjs/form/search/Search.js +1 -1
  18. package/cjs/form/search/Search.js.map +1 -1
  19. package/cjs/form/switch/Switch.d.ts +1 -1
  20. package/cjs/form/useFormField.d.ts +2 -2
  21. package/esm/date/hooks/useDatepicker.js +1 -1
  22. package/esm/date/hooks/useDatepicker.js.map +1 -1
  23. package/esm/form/checkbox/types.d.ts +1 -1
  24. package/esm/form/file-upload/i18n/i18n.context.d.ts +1 -1
  25. package/esm/form/file-upload/i18n/i18n.context.js +1 -1
  26. package/esm/form/file-upload/i18n/i18n.context.js.map +1 -1
  27. package/esm/form/file-upload/i18n/i18n.types.d.ts +1 -1
  28. package/esm/form/file-upload/i18n/locales/nb.d.ts +21 -0
  29. package/esm/form/file-upload/i18n/locales/nb.js +21 -0
  30. package/esm/form/file-upload/i18n/locales/nb.js.map +1 -0
  31. package/esm/form/file-upload/parts/dropzone/Dropzone.js +1 -1
  32. package/esm/form/file-upload/parts/dropzone/Dropzone.js.map +1 -1
  33. package/esm/form/file-upload/parts/item/Item.d.ts +4 -2
  34. package/esm/form/file-upload/parts/item/Item.js.map +1 -1
  35. package/esm/form/radio/types.d.ts +3 -3
  36. package/esm/form/search/Search.d.ts +14 -10
  37. package/esm/form/search/Search.js +1 -1
  38. package/esm/form/search/Search.js.map +1 -1
  39. package/esm/form/switch/Switch.d.ts +1 -1
  40. package/esm/form/useFormField.d.ts +2 -2
  41. package/package.json +3 -3
  42. package/src/date/datepicker/datepicker.stories.tsx +1 -0
  43. package/src/date/hooks/useDatepicker.tsx +1 -1
  44. package/src/dropdown/dropdown.stories.tsx +56 -20
  45. package/src/form/checkbox/types.ts +1 -1
  46. package/src/form/error-summary/error-summary.stories.tsx +47 -11
  47. package/src/form/fieldset/fieldset.stories.tsx +111 -76
  48. package/src/form/file-upload/i18n/i18n.context.ts +1 -1
  49. package/src/form/file-upload/i18n/i18n.types.ts +1 -1
  50. package/src/form/file-upload/i18n/locales/nb.ts +20 -0
  51. package/src/form/file-upload/parts/dropzone/Dropzone.tsx +1 -1
  52. package/src/form/file-upload/parts/item/Item.tsx +4 -2
  53. package/src/form/radio/radio.stories.tsx +1 -0
  54. package/src/form/radio/types.ts +3 -3
  55. package/src/form/search/Search.tsx +15 -11
  56. package/src/form/switch/Switch.tsx +1 -1
  57. package/src/form/switch/switch.stories.tsx +96 -57
  58. package/src/form/useFormField.ts +2 -2
  59. package/cjs/form/file-upload/i18n/locales/nb.json +0 -20
  60. package/esm/form/file-upload/i18n/locales/nb.json +0 -20
  61. package/src/form/file-upload/i18n/locales/nb.json +0 -20
@@ -5,15 +5,15 @@ export interface RadioProps
5
5
  extends Omit<FormFieldProps, "error" | "errorId" | "readOnly">,
6
6
  Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "value"> {
7
7
  /**
8
- * Radio label
8
+ * Radio label.
9
9
  */
10
10
  children: React.ReactNode;
11
11
  /**
12
- * The value of the HTML element
12
+ * The value of the HTML element.
13
13
  */
14
14
  value: any;
15
15
  /**
16
- * Adds a description to extend labling of Radio
16
+ * Adds a description to extend labeling of Radio.
17
17
  */
18
18
  description?: string;
19
19
  }
@@ -28,47 +28,51 @@ export interface SearchProps
28
28
  /**
29
29
  * Search label.
30
30
  *
31
- * Will be hidden by default, is required for accessibility reasons.
31
+ * Will be hidden by default and is required for WCAG compliance.
32
32
  */
33
33
  label: React.ReactNode;
34
34
  /**
35
- * Shows label and description for screenreaders-only
35
+ * Shows label and description for screenreaders only.
36
36
  * @default true
37
37
  */
38
38
  hideLabel?: boolean;
39
39
  /**
40
- * Callback for value-change in input
40
+ * Callback for value-change in input.
41
41
  */
42
42
  onChange?: (value: string) => void;
43
43
  /**
44
- * Callback for click on clear-button or Escape keydown
44
+ * Callback for click on clear-button or Escape keydown.
45
45
  */
46
46
  onClear?: (e: SearchClearEvent) => void;
47
47
  /**
48
- * Callback for Search-button submit
48
+ * Callback for Search-button submit.
49
49
  */
50
50
  onSearchClick?: (value: string) => void;
51
51
  /**
52
- * aria-label on clear button
52
+ * Sets the `aria-label` for the clear button.
53
53
  * @default "Tøm"
54
54
  */
55
55
  clearButtonLabel?: string;
56
56
  /**
57
- * If false, removes clear-button option from input.
57
+ * Removes clear-button if `false`.
58
58
  * @default true
59
59
  */
60
60
  clearButton?: boolean;
61
61
  /**
62
- * Changes button-variant, "simple" removes button
62
+ * Changes button-variant.
63
+ *
64
+ * - "primary": When this is the main function of the page.
65
+ * - "secondary": This is probably the one you want if in doubt.
66
+ * - "simple": Removes the search button.
63
67
  * @default "primary"
64
68
  */
65
69
  variant?: "primary" | "secondary" | "simple";
66
70
  /**
67
- * Exposes the HTML size attribute
71
+ * Exposes the HTML size attribute. Specifies the width of the element, in characters.
68
72
  */
69
73
  htmlSize?: number | string;
70
74
  /*
71
- * Exposes role attribute
75
+ * Exposes role attribute.
72
76
  */
73
77
  role?: string;
74
78
  }
@@ -88,7 +92,7 @@ interface SearchComponent
88
92
  *
89
93
  * @example
90
94
  * ```jsx
91
- * <form>
95
+ * <form role="search">
92
96
  * <Search label="Søk alle NAV sine sider" variant="primary" />
93
97
  * </form>
94
98
  * ```
@@ -53,7 +53,7 @@ export interface SwitchProps
53
53
  */
54
54
  position?: "left" | "right";
55
55
  /**
56
- * Adds a description to extend labling of Switch.
56
+ * Adds a description to extend labeling of Switch.
57
57
  */
58
58
  description?: string;
59
59
  }
@@ -1,5 +1,6 @@
1
- import { Meta } from "@storybook/react";
1
+ import { Meta, StoryObj } from "@storybook/react";
2
2
  import React from "react";
3
+ import { VStack } from "../../layout/stack";
3
4
  import Switch from "./Switch";
4
5
 
5
6
  export default {
@@ -31,70 +32,59 @@ export default {
31
32
  type: "boolean",
32
33
  },
33
34
  },
34
- } as Meta;
35
-
36
- export const Default = {
37
- render: (props) => {
38
- return <Switch {...props}>Label text</Switch>;
35
+ parameters: {
36
+ chromatic: { disable: true },
39
37
  },
38
+ } satisfies Meta<typeof Switch>;
39
+
40
+ type Story = StoryObj<typeof Switch>;
40
41
 
42
+ export const Default: Story = {
41
43
  args: {
42
- position: "right",
44
+ children: "Label text",
43
45
  },
44
46
  };
45
47
 
46
- export const Small = () => {
47
- return (
48
- <div className="colgap">
49
- <Switch size="small">Label text</Switch>
50
- <Switch size="small" position="right">
51
- Label text
52
- </Switch>
53
- </div>
54
- );
48
+ export const Small: Story = {
49
+ args: {
50
+ children: "Label text",
51
+ size: "small",
52
+ },
55
53
  };
56
54
 
57
- export const Description = () => {
58
- return (
59
- <div className="colgap">
60
- <Switch size="small" description="Cillum sint exercitation ut cillum.">
61
- Label text
62
- </Switch>
63
- <Switch
64
- size="small"
65
- position="right"
66
- description="Cillum sint exercitation ut cillum."
67
- >
68
- Label text
69
- </Switch>
70
- </div>
71
- );
55
+ export const Description: Story = {
56
+ args: {
57
+ children: "Label text",
58
+ description: "Cillum sint exercitation ut cillum.",
59
+ },
72
60
  };
73
61
 
74
- export const Loading = () => {
75
- return (
76
- <div className="colgap">
62
+ export const Loading: Story = {
63
+ render: () => {
64
+ return (
77
65
  <div className="colgap">
78
- <Switch loading>Label text</Switch>
66
+ <div className="colgap">
67
+ <Switch loading>Label text</Switch>
79
68
 
80
- <Switch checked loading>
81
- Label text
82
- </Switch>
83
- </div>
84
- <div className="colgap">
85
- <Switch loading size="small">
86
- Label text
87
- </Switch>
88
- <Switch checked loading size="small">
89
- Label text
90
- </Switch>
69
+ <Switch checked loading>
70
+ Label text
71
+ </Switch>
72
+ </div>
73
+ <div className="colgap">
74
+ <Switch loading size="small">
75
+ Label text
76
+ </Switch>
77
+ <Switch checked loading size="small">
78
+ Label text
79
+ </Switch>
80
+ </div>
91
81
  </div>
92
- </div>
93
- );
82
+ );
83
+ },
94
84
  };
95
85
 
96
- export const Disabled = () => {
97
- return (
86
+ export const Disabled: Story = {
87
+ render: () => (
98
88
  <div className="colgap">
99
89
  <Switch disabled>Label text</Switch>
100
90
 
@@ -102,11 +92,11 @@ export const Disabled = () => {
102
92
  Label text
103
93
  </Switch>
104
94
  </div>
105
- );
95
+ ),
106
96
  };
107
97
 
108
- export const HideLabel = () => {
109
- return (
98
+ export const HideLabel: Story = {
99
+ render: () => (
110
100
  <div className="colgap">
111
101
  <Switch hideLabel>Label text</Switch>
112
102
 
@@ -114,11 +104,11 @@ export const HideLabel = () => {
114
104
  Label text
115
105
  </Switch>
116
106
  </div>
117
- );
107
+ ),
118
108
  };
119
109
 
120
- export const Readonly = () => {
121
- return (
110
+ export const Readonly: Story = {
111
+ render: () => (
122
112
  <div className="colgap">
123
113
  <Switch description="Slår av alle notifikasjoner" readOnly>
124
114
  Notifikasjoner
@@ -128,5 +118,54 @@ export const Readonly = () => {
128
118
  Notifikasjoner
129
119
  </Switch>
130
120
  </div>
131
- );
121
+ ),
122
+ };
123
+
124
+ export const Chromatic: Story = {
125
+ render: () => (
126
+ <VStack gap="4" align="start">
127
+ <div>
128
+ <h2>Default</h2>
129
+ {/* @ts-expect-error Args are Partial here */}
130
+ <Switch {...Default.args} />
131
+ </div>
132
+ <div>
133
+ <h2>Small</h2>
134
+ {/* @ts-expect-error Args are Partial here */}
135
+ <Switch {...Small.args} position="left" />
136
+ {/* @ts-expect-error Args are Partial here */}
137
+ <Switch {...Small.args} position="right" />
138
+ </div>
139
+ <div>
140
+ <h2>Description</h2>
141
+ {/* @ts-expect-error Args are Partial here */}
142
+ <Switch {...Description.args} position="left" />
143
+ {/* @ts-expect-error Args are Partial here */}
144
+ <Switch {...Description.args} position="right" />
145
+ </div>
146
+ <div>
147
+ <h2>Loading</h2>
148
+ {/* @ts-expect-error Args are Partial here */}
149
+ <Loading.render />
150
+ </div>
151
+ <div>
152
+ <h2>Disabled</h2>
153
+ {/* @ts-expect-error Args are Partial here */}
154
+ <Disabled.render />
155
+ </div>
156
+ <div>
157
+ <h2>HideLabel</h2>
158
+ {/* @ts-expect-error Args are Partial here */}
159
+ <HideLabel.render />
160
+ </div>
161
+ <div>
162
+ <h2>Readonly</h2>
163
+ {/* @ts-expect-error Args are Partial here */}
164
+ <Readonly.render />
165
+ </div>
166
+ </VStack>
167
+ ),
168
+ parameters: {
169
+ chromatic: { disable: false },
170
+ },
132
171
  };
@@ -5,7 +5,7 @@ import { FieldsetContext } from "./fieldset/context";
5
5
 
6
6
  export interface FormFieldProps {
7
7
  /**
8
- * Adds a description to extend labling of the field.
8
+ * Adds a description to extend labeling of the field.
9
9
  * Error message for element.
10
10
  */
11
11
  error?: React.ReactNode;
@@ -24,7 +24,7 @@ export interface FormFieldProps {
24
24
  */
25
25
  disabled?: boolean;
26
26
  /**
27
- * Adds a description to extend labling of a field.
27
+ * Adds a description to extend labeling of a field.
28
28
  */
29
29
  description?: React.ReactNode;
30
30
  /**
@@ -1,20 +0,0 @@
1
- {
2
- "FileUpload": {
3
- "dropzone": {
4
- "button": "Velg fil",
5
- "buttonMultiple": "Velg filer",
6
- "dragAndDrop": "Dra og slipp filen her",
7
- "dragAndDropMultiple": "Dra og slipp filer her",
8
- "drop": "Slipp",
9
- "or": "eller",
10
- "disabled": "Filopplasting er deaktivert",
11
- "disabledFilelimit": "Du kan ikke laste opp flere filer"
12
- },
13
- "item": {
14
- "retryButtonTitle": "Prøv å laste opp filen på nytt",
15
- "deleteButtonTitle": "Slett filen",
16
- "uploading": "Laster opp…",
17
- "downloading": "Laster ned…"
18
- }
19
- }
20
- }
@@ -1,20 +0,0 @@
1
- {
2
- "FileUpload": {
3
- "dropzone": {
4
- "button": "Velg fil",
5
- "buttonMultiple": "Velg filer",
6
- "dragAndDrop": "Dra og slipp filen her",
7
- "dragAndDropMultiple": "Dra og slipp filer her",
8
- "drop": "Slipp",
9
- "or": "eller",
10
- "disabled": "Filopplasting er deaktivert",
11
- "disabledFilelimit": "Du kan ikke laste opp flere filer"
12
- },
13
- "item": {
14
- "retryButtonTitle": "Prøv å laste opp filen på nytt",
15
- "deleteButtonTitle": "Slett filen",
16
- "uploading": "Laster opp…",
17
- "downloading": "Laster ned…"
18
- }
19
- }
20
- }
@@ -1,20 +0,0 @@
1
- {
2
- "FileUpload": {
3
- "dropzone": {
4
- "button": "Velg fil",
5
- "buttonMultiple": "Velg filer",
6
- "dragAndDrop": "Dra og slipp filen her",
7
- "dragAndDropMultiple": "Dra og slipp filer her",
8
- "drop": "Slipp",
9
- "or": "eller",
10
- "disabled": "Filopplasting er deaktivert",
11
- "disabledFilelimit": "Du kan ikke laste opp flere filer"
12
- },
13
- "item": {
14
- "retryButtonTitle": "Prøv å laste opp filen på nytt",
15
- "deleteButtonTitle": "Slett filen",
16
- "uploading": "Laster opp…",
17
- "downloading": "Laster ned…"
18
- }
19
- }
20
- }