@navikt/ds-react 6.3.5 → 6.4.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.
Files changed (56) hide show
  1. package/cjs/copybutton/CopyButton.d.ts +1 -0
  2. package/cjs/copybutton/CopyButton.js.map +1 -1
  3. package/cjs/date/datepicker/parts/DayButton.js +1 -1
  4. package/cjs/date/datepicker/parts/DayButton.js.map +1 -1
  5. package/cjs/form/checkbox/CheckboxGroup.d.ts +6 -6
  6. package/cjs/form/checkbox/CheckboxGroup.js +4 -4
  7. package/cjs/form/checkbox/types.d.ts +3 -3
  8. package/cjs/form/file-upload/FileUpload.d.ts +2 -2
  9. package/cjs/form/file-upload/parts/item/Item.d.ts +10 -17
  10. package/cjs/form/file-upload/parts/item/Item.js +4 -2
  11. package/cjs/form/file-upload/parts/item/Item.js.map +1 -1
  12. package/cjs/form/file-upload/parts/item/ItemButton.d.ts +5 -8
  13. package/cjs/form/file-upload/parts/item/ItemButton.js +3 -11
  14. package/cjs/form/file-upload/parts/item/ItemButton.js.map +1 -1
  15. package/cjs/form/radio/RadioGroup.d.ts +1 -1
  16. package/cjs/form/radio/types.d.ts +2 -2
  17. package/cjs/form/useFormField.d.ts +2 -3
  18. package/cjs/form/useFormField.js.map +1 -1
  19. package/esm/copybutton/CopyButton.d.ts +1 -0
  20. package/esm/copybutton/CopyButton.js.map +1 -1
  21. package/esm/date/datepicker/parts/DayButton.js +1 -1
  22. package/esm/date/datepicker/parts/DayButton.js.map +1 -1
  23. package/esm/form/checkbox/CheckboxGroup.d.ts +6 -6
  24. package/esm/form/checkbox/CheckboxGroup.js +4 -4
  25. package/esm/form/checkbox/types.d.ts +3 -3
  26. package/esm/form/file-upload/FileUpload.d.ts +2 -2
  27. package/esm/form/file-upload/parts/item/Item.d.ts +10 -17
  28. package/esm/form/file-upload/parts/item/Item.js +4 -2
  29. package/esm/form/file-upload/parts/item/Item.js.map +1 -1
  30. package/esm/form/file-upload/parts/item/ItemButton.d.ts +5 -8
  31. package/esm/form/file-upload/parts/item/ItemButton.js +3 -11
  32. package/esm/form/file-upload/parts/item/ItemButton.js.map +1 -1
  33. package/esm/form/radio/RadioGroup.d.ts +1 -1
  34. package/esm/form/radio/types.d.ts +2 -2
  35. package/esm/form/useFormField.d.ts +2 -3
  36. package/esm/form/useFormField.js.map +1 -1
  37. package/package.json +3 -3
  38. package/src/copybutton/CopyButton.tsx +1 -0
  39. package/src/date/datepicker/parts/DayButton.tsx +1 -0
  40. package/src/form/checkbox/CheckboxGroup.tsx +6 -6
  41. package/src/form/checkbox/types.ts +3 -3
  42. package/src/form/file-upload/FileUpload.tsx +2 -2
  43. package/src/form/file-upload/file-upload-item.stories.tsx +28 -16
  44. package/src/form/file-upload/file-upload.stories.tsx +17 -5
  45. package/src/form/file-upload/parts/item/Item.tsx +20 -38
  46. package/src/form/file-upload/parts/item/ItemButton.tsx +16 -41
  47. package/src/form/radio/RadioGroup.tsx +1 -1
  48. package/src/form/radio/types.ts +2 -2
  49. package/src/form/useFormField.ts +2 -3
  50. package/src/guide-panel/guidepanel.stories.tsx +4 -6
  51. package/src/typography/stories/bodylong.stories.tsx +3 -4
  52. package/src/typography/stories/bodyshort.stories.tsx +3 -4
  53. package/src/typography/stories/detail.stories.tsx +3 -4
  54. package/src/typography/stories/error-message.stories.tsx +3 -4
  55. package/src/typography/stories/heading.stories.tsx +3 -4
  56. package/src/typography/stories/label.stories.tsx +3 -4
@@ -6,11 +6,11 @@ export interface RadioProps extends Omit<FormFieldProps, "error" | "errorId" | "
6
6
  */
7
7
  children: React.ReactNode;
8
8
  /**
9
- * The value of the HTML element.
9
+ * Radio value.
10
10
  */
11
11
  value: any;
12
12
  /**
13
- * Adds a description to extend labeling of Radio.
13
+ * Adds a description to extend the labeling.
14
14
  */
15
15
  description?: string;
16
16
  }
@@ -1,8 +1,7 @@
1
1
  import React from "react";
2
2
  export interface FormFieldProps {
3
3
  /**
4
- * Adds a description to extend labeling of the field.
5
- * Error message for element.
4
+ * Error message.
6
5
  */
7
6
  error?: React.ReactNode;
8
7
  /**
@@ -20,7 +19,7 @@ export interface FormFieldProps {
20
19
  */
21
20
  disabled?: boolean;
22
21
  /**
23
- * Adds a description to extend labeling of a field.
22
+ * Adds a description to extend the labeling.
24
23
  */
25
24
  description?: React.ReactNode;
26
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"useFormField.js","sourceRoot":"","sources":["../../src/form/useFormField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAmDrD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAqB,EACrB,MAAc,EACC,EAAE;;IACjB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAEpD,MAAM,QAAQ,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAE7C,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC;IAEtB,MAAM,EAAE,GAAG,MAAA,KAAK,CAAC,EAAE,mCAAI,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,GAAG,MAAM,UAAU,KAAK,EAAE,CAAC;IAC1D,MAAM,kBAAkB,GAAG,GAAG,MAAM,gBAAgB,KAAK,EAAE,CAAC;IAE5D,MAAM,QAAQ,GAAG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,KAAI,KAAK,CAAC,QAAQ,CAAC;IACtD,MAAM,QAAQ,GACZ,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,KAAI,KAAK,CAAC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AAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,mCAAI,EAAE,CAAC,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,CAAA;aACzD,CAAC,IAAI,SAAS,EAEjB,QAAQ,GACT;KACF,CAAC;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "6.3.5",
3
+ "version": "6.4.0",
4
4
  "description": "React components from the Norwegian Labour and Welfare Administration.",
5
5
  "author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
6
6
  "license": "MIT",
@@ -562,8 +562,8 @@
562
562
  },
563
563
  "dependencies": {
564
564
  "@floating-ui/react": "0.25.4",
565
- "@navikt/aksel-icons": "^6.3.5",
566
- "@navikt/ds-tokens": "^6.3.5",
565
+ "@navikt/aksel-icons": "^6.4.0",
566
+ "@navikt/ds-tokens": "^6.4.0",
567
567
  "@radix-ui/react-tabs": "1.0.0",
568
568
  "@radix-ui/react-toggle-group": "1.0.0",
569
569
  "clsx": "^2.1.0",
@@ -33,6 +33,7 @@ export interface CopyButtonProps
33
33
  /**
34
34
  * Text shown when button is clicked.
35
35
  * Only set if used with `text`-prop.
36
+ * @default "Kopiert!"
36
37
  */
37
38
  activeText?: string;
38
39
  /**
@@ -20,6 +20,7 @@ const DayButton = (props: DayProps) => {
20
20
  name="day"
21
21
  ref={buttonRef}
22
22
  {...dayRender.buttonProps}
23
+ role={undefined}
23
24
  aria-label={dateTime}
24
25
  aria-hidden={dayRender.activeModifiers.outside}
25
26
  />
@@ -16,7 +16,7 @@ export const CheckboxGroupContext = createContext<CheckboxGroupState | null>(
16
16
  export interface CheckboxGroupProps
17
17
  extends Omit<
18
18
  FieldsetProps,
19
- "onChange" | "errorPropagation" | "defaultValue"
19
+ "onChange" | "errorPropagation" | "defaultValue" | "nativeReadOnly"
20
20
  > {
21
21
  /**
22
22
  * Collection of `<Checkbox/>`.
@@ -27,7 +27,7 @@ export interface CheckboxGroupProps
27
27
  */
28
28
  value?: any[];
29
29
  /**
30
- * Default checked checkboxes on render.
30
+ * Default checked checkboxes.
31
31
  */
32
32
  defaultValue?: any[];
33
33
  /**
@@ -44,10 +44,10 @@ export interface CheckboxGroupProps
44
44
  *
45
45
  * @example
46
46
  * ```jsx
47
- * <CheckboxGroup legend="Hvor vil du sitte?">
48
- * <Checkbox value="Bakerst">Bakerst</Checkbox>
49
- * <Checkbox value="Midterst">Midterst</Checkbox>
50
- * <Checkbox value="Fremst">Fremst</Checkbox>
47
+ * <CheckboxGroup legend="Transportmiddel">
48
+ * <Checkbox value="car">Bil</Checkbox>
49
+ * <Checkbox value="taxi">Drosje</Checkbox>
50
+ * <Checkbox value="public">Kollektivt</Checkbox>
51
51
  * </CheckboxGroup>
52
52
  * ```
53
53
  */
@@ -14,7 +14,7 @@ export interface CheckboxProps
14
14
  */
15
15
  errorId?: string;
16
16
  /**
17
- * Checkbox label
17
+ * Checkbox label.
18
18
  */
19
19
  children: React.ReactNode;
20
20
  /**
@@ -22,7 +22,7 @@ export interface CheckboxProps
22
22
  */
23
23
  hideLabel?: boolean;
24
24
  /**
25
- * The value of the HTML element.
25
+ * Checkbox value.
26
26
  */
27
27
  value?: any;
28
28
  /**
@@ -31,7 +31,7 @@ export interface CheckboxProps
31
31
  */
32
32
  indeterminate?: boolean;
33
33
  /**
34
- * Adds a description to extend labeling of Checkbox.
34
+ * Adds a description to extend the labeling.
35
35
  */
36
36
  description?: string;
37
37
  }
@@ -89,8 +89,8 @@ interface FileUploadComponent
89
89
  * ```jsx
90
90
  * <FileUpload.Item file={file} status="uploading" />
91
91
  * <FileUpload.Item file={file} status="downloading" />
92
- * <FileUpload.Item file={file} itemAction="retry" onRetry={...} />
93
- * <FileUpload.Item file={file} itemAction="delete" onDelete={...} />
92
+ * <FileUpload.Item file={file} button={{ action:"retry", onClick:... }} />
93
+ * <FileUpload.Item file={file} button={{ action:"delete", onClick:... }} />
94
94
  * ```
95
95
  */
96
96
  Item: typeof Item;
@@ -57,51 +57,63 @@ export const States: StoryObj<typeof FileUpload.Item> = {
57
57
  file={fileTxt}
58
58
  error="Error og uploading"
59
59
  status="uploading"
60
- onRetry={() => onRetry(fileTxt)}
61
- onDelete={() => onDelete(fileTxt)}
60
+ button={{
61
+ onClick: () => onDelete(fileTxt),
62
+ action: "delete",
63
+ }}
62
64
  />
63
65
  <h2>Item Actions</h2>
64
66
  <h3>status + delete</h3>
65
67
  <FileUpload.Item
66
68
  file={fileDocx}
67
- onDelete={() => onDelete(fileDocx)}
68
- onRetry={() => onRetry(fileDocx)}
69
69
  status="uploading"
70
- itemAction="delete"
70
+ button={{
71
+ onClick: () => onDelete(fileDocx),
72
+ action: "delete",
73
+ }}
71
74
  />
72
75
  <h3>status + retry</h3>
73
76
  <FileUpload.Item
74
77
  file={fileDocx}
75
- onDelete={() => onDelete(fileDocx)}
76
- onRetry={() => onRetry(fileDocx)}
77
78
  status="downloading"
78
- itemAction="retry"
79
+ button={{
80
+ onClick: () => onRetry(fileDocx),
81
+ action: "retry",
82
+ }}
79
83
  />
80
84
  <h3>retry</h3>
81
85
  <FileUpload.Item
82
86
  file={fileCsv}
83
- onRetry={() => onRetry(fileCsv)}
84
- itemAction="retry"
87
+ button={{
88
+ onClick: () => onRetry(fileCsv),
89
+ action: "retry",
90
+ }}
85
91
  />
86
92
  <h3>delete</h3>
87
93
  <FileUpload.Item
88
94
  file={filePptx}
89
- onDelete={() => onDelete(filePptx)}
90
- itemAction="delete"
95
+ button={{
96
+ onClick: () => onDelete(filePptx),
97
+ action: "delete",
98
+ }}
91
99
  />
92
100
  <h3>retry + error</h3>
93
101
  <FileUpload.Item
94
102
  file={fileCsv}
95
103
  error="Error og onRetry"
96
- onRetry={() => onRetry(fileCsv)}
97
- itemAction="retry"
104
+ button={{
105
+ onClick: () => onRetry(fileCsv),
106
+ action: "retry",
107
+ }}
98
108
  />
99
109
  <h3>delete + error</h3>
100
110
  <FileUpload.Item
101
111
  file={filePptx}
102
112
  error="Error og onDelete"
103
- onDelete={() => onDelete(filePptx)}
104
- itemAction="delete"
113
+ button={{
114
+ onClick: () => onDelete(filePptx),
115
+ action: "delete",
116
+ }}
105
117
  />
106
118
  </div>
107
119
  ),
@@ -25,6 +25,7 @@ const MAX_SIZE = MAX_SIZE_MB * 1024 * 1024;
25
25
 
26
26
  const CustomItem = ({
27
27
  index,
28
+ onDelete,
28
29
  ...props
29
30
  }: FileUploadItemProps & {
30
31
  index: number;
@@ -45,7 +46,10 @@ const CustomItem = ({
45
46
  <FileUpload.Item
46
47
  {...props}
47
48
  status={loading ? "uploading" : "idle"}
48
- itemAction="delete"
49
+ button={{
50
+ action: "delete",
51
+ onClick: onDelete,
52
+ }}
49
53
  as="li"
50
54
  />
51
55
  );
@@ -165,7 +169,10 @@ export const Single: StoryFn = () => {
165
169
  key={file.file.name}
166
170
  file={file.file}
167
171
  error={file.error ? errors[file.reasons[0]] : undefined}
168
- onDelete={removeFile}
172
+ button={{
173
+ action: "delete",
174
+ onClick: removeFile,
175
+ }}
169
176
  />
170
177
  ))}
171
178
  </VStack>
@@ -194,12 +201,17 @@ export const Translation = () => (
194
201
  <FileUpload.Dropzone label="Last opp bilder" onSelect={console.log} />
195
202
  <FileUpload.Item
196
203
  file={{ name: "eksempel.png", size: 200000 }}
197
- onDelete={() => null}
204
+ button={{
205
+ action: "delete",
206
+ onClick: () => null,
207
+ }}
198
208
  />
199
209
  <FileUpload.Item
200
210
  file={{ name: "eksempel.png", size: 200000 }}
201
- itemAction="retry"
202
- onRetry={() => null}
211
+ button={{
212
+ action: "retry",
213
+ onClick: () => null,
214
+ }}
203
215
  />
204
216
  <FileUpload.Item
205
217
  file={{ name: "eksempel.png", size: 200000 }}
@@ -12,12 +12,13 @@ import ItemIcon from "./ItemIcon";
12
12
  import ItemName from "./ItemName";
13
13
  import { formatFileSize } from "./utils/format-file-size";
14
14
 
15
- export interface FileItemBaseProps {
15
+ export interface FileUploadItemProps
16
+ extends React.HTMLAttributes<HTMLDivElement> {
16
17
  /**
17
18
  * Overrides html-tag
18
19
  * @default "div"
19
20
  */
20
- as?: "div" | "li";
21
+ as?: ("div" | "li") & React.ElementType;
21
22
  /**
22
23
  * Either a native File or file metadata.
23
24
  */
@@ -43,37 +44,20 @@ export interface FileItemBaseProps {
43
44
  * @default "idle"
44
45
  */
45
46
  status?: "downloading" | "uploading" | "idle";
47
+ /**
48
+ * Props for the action button.
49
+ */
50
+ button?: {
51
+ action: "delete" | "retry";
52
+ onClick: (event: MouseEvent<HTMLButtonElement>) => void;
53
+ id?: string;
54
+ };
46
55
  /**
47
56
  * i18n-API for customizing texts and labels
48
57
  */
49
58
  translations?: ComponentTranslation<"FileUpload">["item"];
50
- onRetry?: (event: MouseEvent<HTMLButtonElement>) => void;
51
- onDelete?: (event: MouseEvent<HTMLButtonElement>) => void;
52
59
  }
53
60
 
54
- type FileItemActionDelete = {
55
- onDelete: (event: MouseEvent<HTMLButtonElement>) => void;
56
- itemAction: "delete";
57
- };
58
-
59
- type FileItemActionRetry = {
60
- onRetry: (event: MouseEvent<HTMLButtonElement>) => void;
61
- itemAction: "retry";
62
- };
63
-
64
- type FileItemActionNone = {
65
- itemAction?: "none";
66
- };
67
-
68
- type FileItemConditionalProps =
69
- | FileItemActionDelete
70
- | FileItemActionRetry
71
- | FileItemActionNone;
72
-
73
- export type FileUploadItemProps = FileItemBaseProps &
74
- FileItemConditionalProps &
75
- React.HTMLAttributes<HTMLDivElement>;
76
-
77
61
  export const Item: OverridableComponent<FileUploadItemProps, HTMLDivElement> =
78
62
  forwardRef(
79
63
  (
@@ -81,16 +65,14 @@ export const Item: OverridableComponent<FileUploadItemProps, HTMLDivElement> =
81
65
  as: Component = "div",
82
66
  file,
83
67
  status = "idle",
84
- onDelete,
85
- onRetry,
86
68
  error,
87
69
  className,
88
70
  href,
89
71
  onFileClick,
90
- itemAction = "delete",
72
+ button,
91
73
  translations,
92
74
  ...rest
93
- },
75
+ }: FileUploadItemProps,
94
76
  ref,
95
77
  ) => {
96
78
  const context = useFileUploadTranslation(false);
@@ -148,14 +130,14 @@ export const Item: OverridableComponent<FileUploadItemProps, HTMLDivElement> =
148
130
  </div>
149
131
  </div>
150
132
 
151
- {status === "idle" && (
133
+ {status === "idle" && button && (
152
134
  <ItemButton
153
- file={file}
154
- onRetry={onRetry}
155
- onDelete={onDelete}
156
- action={itemAction}
157
- retryTitle={translate("item.retryButtonTitle")}
158
- deleteTitle={translate("item.deleteButtonTitle")}
135
+ {...button}
136
+ title={translate(
137
+ button.action === "retry"
138
+ ? "item.retryButtonTitle"
139
+ : "item.deleteButtonTitle",
140
+ )}
159
141
  />
160
142
  )}
161
143
  </div>
@@ -1,52 +1,27 @@
1
1
  import React from "react";
2
2
  import { ArrowsCirclepathIcon, TrashIcon } from "@navikt/aksel-icons";
3
3
  import { Button } from "../../../../button";
4
- import { FileItem } from "./Item.types";
5
4
 
6
5
  interface Props {
7
- file: FileItem;
8
- onRetry?: (event: React.MouseEvent<HTMLButtonElement>) => void;
9
- onDelete?: (event: React.MouseEvent<HTMLButtonElement>) => void;
10
- action: "delete" | "retry" | "none";
11
- retryTitle: string;
12
- deleteTitle: string;
6
+ action: "delete" | "retry";
7
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
8
+ id?: string;
9
+ title: string;
13
10
  }
14
11
 
15
- const ItemButton = ({
16
- onRetry,
17
- onDelete,
18
- action,
19
- retryTitle,
20
- deleteTitle,
21
- }: Props) => {
22
- if (action === "none") {
23
- return null;
24
- }
12
+ const ItemButton = ({ action, onClick, id, title }: Props) => {
13
+ const Icon = action === "delete" ? TrashIcon : ArrowsCirclepathIcon;
25
14
 
26
- if (onRetry && action === "retry") {
27
- return (
28
- <Button
29
- className="navds-file-item__button"
30
- type="button"
31
- variant="tertiary-neutral"
32
- onClick={onRetry}
33
- icon={<ArrowsCirclepathIcon title={retryTitle} />}
34
- />
35
- );
36
- }
37
- if (onDelete && action === "delete") {
38
- return (
39
- <Button
40
- className="navds-file-item__button"
41
- type="button"
42
- variant="tertiary-neutral"
43
- onClick={onDelete}
44
- icon={<TrashIcon title={deleteTitle} />}
45
- />
46
- );
47
- }
48
-
49
- return null;
15
+ return (
16
+ <Button
17
+ id={id}
18
+ className="navds-file-item__button"
19
+ type="button"
20
+ variant="tertiary-neutral"
21
+ onClick={onClick}
22
+ icon={<Icon title={title} />}
23
+ />
24
+ );
50
25
  };
51
26
 
52
27
  export default ItemButton;
@@ -18,7 +18,7 @@ export const RadioGroupContext =
18
18
  export interface RadioGroupProps
19
19
  extends Omit<
20
20
  FieldsetProps,
21
- "onChange" | "errorPropagation" | "defaultValue"
21
+ "onChange" | "errorPropagation" | "defaultValue" | "nativeReadOnly"
22
22
  > {
23
23
  /**
24
24
  * Collection of `<Radio />`-elements
@@ -9,11 +9,11 @@ export interface RadioProps
9
9
  */
10
10
  children: React.ReactNode;
11
11
  /**
12
- * The value of the HTML element.
12
+ * Radio value.
13
13
  */
14
14
  value: any;
15
15
  /**
16
- * Adds a description to extend labeling of Radio.
16
+ * Adds a description to extend the labeling.
17
17
  */
18
18
  description?: string;
19
19
  }
@@ -5,8 +5,7 @@ import { FieldsetContext } from "./fieldset/context";
5
5
 
6
6
  export interface FormFieldProps {
7
7
  /**
8
- * Adds a description to extend labeling of the field.
9
- * Error message for element.
8
+ * Error message.
10
9
  */
11
10
  error?: React.ReactNode;
12
11
  /**
@@ -24,7 +23,7 @@ export interface FormFieldProps {
24
23
  */
25
24
  disabled?: boolean;
26
25
  /**
27
- * Adds a description to extend labeling of a field.
26
+ * Adds a description to extend the labeling.
28
27
  */
29
28
  description?: React.ReactNode;
30
29
  /**
@@ -41,16 +41,14 @@ export const PosterVariants = {
41
41
  render: () => (
42
42
  <VStack gap="6" align="start">
43
43
  <GuidePanel>
44
- If you exclude the <code>poster</code> prop, you will get the poster
45
- variant on mobile (&lt;480px) and the non-poster variant otherwise.
44
+ If you exclude the `poster` prop, you will get the poster variant on
45
+ mobile (&lt;480px) and the non-poster variant otherwise.
46
46
  </GuidePanel>
47
47
  <GuidePanel poster>
48
- Use the <code>poster</code> prop to get the poster variant on all
49
- viewports.
48
+ Use the `poster` prop to get the poster variant on all viewports.
50
49
  </GuidePanel>
51
50
  <GuidePanel poster={false}>
52
- Set <code>poster=false</code> to get the non-poster variant on all
53
- viewports.
51
+ Set `poster=false` to get the non-poster variant on all viewports.
54
52
  </GuidePanel>
55
53
  </VStack>
56
54
  ),
@@ -4,18 +4,17 @@ import React from "react";
4
4
  import { VStack } from "../../layout/stack";
5
5
  import BodyLong from "../BodyLong";
6
6
 
7
- const meta = {
7
+ const meta: Meta<typeof BodyLong> = {
8
8
  title: "ds-react/Typography/BodyLong",
9
9
  component: BodyLong,
10
10
  decorators: [(story) => <div style={{ maxWidth: "700px" }}>{story()}</div>],
11
11
  parameters: {
12
12
  chromatic: { disable: true },
13
13
  },
14
- } satisfies Meta<typeof BodyLong>;
15
-
14
+ };
16
15
  export default meta;
17
16
 
18
- type Story = StoryObj<typeof meta>;
17
+ type Story = StoryObj<typeof BodyLong>;
19
18
 
20
19
  const lorem =
21
20
  "Hvis du ikke bor sammen med begge foreldrene dine, kan du ha rett til barnebidrag fra en eller begge foreldre mens du fullfører videregående skole eller tilsvarende.";
@@ -4,18 +4,17 @@ import React from "react";
4
4
  import { VStack } from "../../layout/stack";
5
5
  import { BodyShort } from "../BodyShort";
6
6
 
7
- const meta = {
7
+ const meta: Meta<typeof BodyShort> = {
8
8
  title: "ds-react/Typography/BodyShort",
9
9
  component: BodyShort,
10
10
  decorators: [(story) => <div style={{ maxWidth: "250px" }}>{story()}</div>],
11
11
  parameters: {
12
12
  chromatic: { disable: true },
13
13
  },
14
- } satisfies Meta<typeof BodyShort>;
15
-
14
+ };
16
15
  export default meta;
17
16
 
18
- type Story = StoryObj<typeof meta>;
17
+ type Story = StoryObj<typeof BodyShort>;
19
18
 
20
19
  const lorem = "Du må gjøre en filtrering for å se brukere i listen.";
21
20
 
@@ -4,18 +4,17 @@ import React from "react";
4
4
  import { VStack } from "../../layout/stack";
5
5
  import Detail from "../Detail";
6
6
 
7
- const meta = {
7
+ const meta: Meta<typeof Detail> = {
8
8
  title: "ds-react/Typography/Detail",
9
9
  component: Detail,
10
10
  decorators: [(story) => <div style={{ maxWidth: "200px" }}>{story()}</div>],
11
11
  parameters: {
12
12
  chromatic: { disable: true },
13
13
  },
14
- } satisfies Meta<typeof Detail>;
15
-
14
+ };
16
15
  export default meta;
17
16
 
18
- type Story = StoryObj<typeof meta>;
17
+ type Story = StoryObj<typeof Detail>;
19
18
 
20
19
  const lorem = "Du må gjøre en filtrering for å se brukere i listen.";
21
20
 
@@ -4,17 +4,16 @@ import React from "react";
4
4
  import { VStack } from "../../layout/stack";
5
5
  import ErrorMessage from "../ErrorMessage";
6
6
 
7
- const meta = {
7
+ const meta: Meta<typeof ErrorMessage> = {
8
8
  title: "ds-react/Typography/ErrorMessage",
9
9
  component: ErrorMessage,
10
10
  parameters: {
11
11
  chromatic: { disable: true },
12
12
  },
13
- } satisfies Meta<typeof ErrorMessage>;
14
-
13
+ };
15
14
  export default meta;
16
15
 
17
- type Story = StoryObj<typeof meta>;
16
+ type Story = StoryObj<typeof ErrorMessage>;
18
17
 
19
18
  const lorem =
20
19
  "Du må fylle ut: Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon";
@@ -4,18 +4,17 @@ import { default as React } from "react";
4
4
  import { VStack } from "../../layout/stack";
5
5
  import Heading from "../Heading";
6
6
 
7
- const meta = {
7
+ const meta: Meta<typeof Heading> = {
8
8
  title: "ds-react/Typography/Heading",
9
9
  component: Heading,
10
10
  decorators: [(story) => <div style={{ maxWidth: "300px" }}>{story()}</div>],
11
11
  parameters: {
12
12
  chromatic: { disable: true },
13
13
  },
14
- } satisfies Meta<typeof Heading>;
15
-
14
+ };
16
15
  export default meta;
17
16
 
18
- type Story = StoryObj<typeof meta>;
17
+ type Story = StoryObj<typeof Heading>;
19
18
 
20
19
  const lorem = "Hva kan vi hjelpe deg med?";
21
20
 
@@ -4,18 +4,17 @@ import React from "react";
4
4
  import { VStack } from "../../layout/stack";
5
5
  import Label from "../Label";
6
6
 
7
- const meta = {
7
+ const meta: Meta<typeof Label> = {
8
8
  title: "ds-react/Typography/Label",
9
9
  component: Label,
10
10
  decorators: [(story) => <div style={{ maxWidth: "400px" }}>{story()}</div>],
11
11
  parameters: {
12
12
  chromatic: { disable: true },
13
13
  },
14
- } satisfies Meta<typeof Label>;
15
-
14
+ };
16
15
  export default meta;
17
16
 
18
- type Story = StoryObj<typeof meta>;
17
+ type Story = StoryObj<typeof Label>;
19
18
 
20
19
  const lorem =
21
20
  "Oppgi årsaken til at du har ventet mer enn 6 måneder med å søke om refusjon";