@navikt/ds-react 1.0.0-rc.6 → 1.0.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 (55) hide show
  1. package/README.md +2 -1
  2. package/cjs/form/Fieldset/Fieldset.js +1 -1
  3. package/cjs/form/Select.js +2 -2
  4. package/cjs/form/TextField.js +2 -2
  5. package/cjs/form/Textarea.js +6 -5
  6. package/cjs/form/checkbox/Checkbox.js +3 -3
  7. package/cjs/form/radio/Radio.js +3 -3
  8. package/cjs/form/search/Search.js +1 -1
  9. package/cjs/modal/Modal.js +2 -2
  10. package/cjs/table/HeaderCell.js +3 -3
  11. package/cjs/typography/ErrorMessage.js +42 -3
  12. package/cjs/typography/Label.js +1 -1
  13. package/esm/form/Fieldset/Fieldset.js +2 -2
  14. package/esm/form/Fieldset/Fieldset.js.map +1 -1
  15. package/esm/form/Select.js +3 -3
  16. package/esm/form/Select.js.map +1 -1
  17. package/esm/form/TextField.js +3 -3
  18. package/esm/form/TextField.js.map +1 -1
  19. package/esm/form/Textarea.js +7 -6
  20. package/esm/form/Textarea.js.map +1 -1
  21. package/esm/form/checkbox/Checkbox.js +3 -3
  22. package/esm/form/checkbox/Checkbox.js.map +1 -1
  23. package/esm/form/radio/Radio.js +3 -3
  24. package/esm/form/radio/Radio.js.map +1 -1
  25. package/esm/form/search/Search.js +1 -1
  26. package/esm/form/search/Search.js.map +1 -1
  27. package/esm/help-text/HelpText.d.ts +1 -1
  28. package/esm/modal/Modal.d.ts +4 -0
  29. package/esm/modal/Modal.js +2 -2
  30. package/esm/modal/Modal.js.map +1 -1
  31. package/esm/table/HeaderCell.js +3 -3
  32. package/esm/table/HeaderCell.js.map +1 -1
  33. package/esm/typography/ErrorMessage.d.ts +7 -2
  34. package/esm/typography/ErrorMessage.js +19 -3
  35. package/esm/typography/ErrorMessage.js.map +1 -1
  36. package/esm/typography/Label.d.ts +2 -2
  37. package/esm/typography/Label.js +1 -1
  38. package/esm/typography/Label.js.map +1 -1
  39. package/package.json +6 -6
  40. package/src/form/Fieldset/Fieldset.tsx +3 -3
  41. package/src/form/Select.tsx +3 -4
  42. package/src/form/TextField.tsx +3 -4
  43. package/src/form/Textarea.tsx +8 -7
  44. package/src/form/checkbox/Checkbox.tsx +4 -4
  45. package/src/form/checkbox/checkbox.stories.tsx +4 -1
  46. package/src/form/radio/Radio.tsx +4 -4
  47. package/src/form/radio/radio.stories.tsx +5 -1
  48. package/src/form/search/Search.tsx +0 -1
  49. package/src/help-text/HelpText.tsx +1 -1
  50. package/src/loader/loader.stories.tsx +2 -2
  51. package/src/modal/Modal.tsx +6 -0
  52. package/src/modal/modal.stories.tsx +11 -62
  53. package/src/table/HeaderCell.tsx +4 -6
  54. package/src/typography/ErrorMessage.tsx +21 -9
  55. package/src/typography/Label.tsx +4 -3
@@ -1,6 +1,22 @@
1
- import React from "react";
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { forwardRef } from "react";
2
13
  import cl from "clsx";
3
- import { Label } from "..";
4
- const ErrorMessage = (props) => (React.createElement(Label, Object.assign({}, props, { as: "div", className: cl("navds-error-message", props.className) })));
14
+ const ErrorMessage = forwardRef((_a, ref) => {
15
+ var { className, size, spacing, as: Component = "p" } = _a, rest = __rest(_a, ["className", "size", "spacing", "as"]);
16
+ return (React.createElement(Component, Object.assign({}, rest, { ref: ref, className: cl("navds-error-message", "navds-label", className, {
17
+ "navds-label--small": size === "small",
18
+ "navds-typo--spacing": !!spacing,
19
+ }) })));
20
+ });
5
21
  export default ErrorMessage;
6
22
  //# sourceMappingURL=ErrorMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorMessage.js","sourceRoot":"","sources":["../../src/typography/ErrorMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAe3B,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAC9B,oBAAC,KAAK,oBACA,KAAK,IACT,EAAE,EAAC,KAAK,EACR,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,KAAK,CAAC,SAAS,CAAC,IACrD,CACH,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ErrorMessage.js","sourceRoot":"","sources":["../../src/typography/ErrorMessage.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAoBtB,MAAM,YAAY,GAGd,UAAU,CACZ,CAAC,EAA0D,EAAE,GAAG,EAAE,EAAE;QAAnE,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG,OAAW,EAAN,IAAI,cAAxD,sCAA0D,CAAF;IAAY,OAAA,CACnE,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,aAAa,EAAE,SAAS,EAAE;YAC7D,oBAAoB,EAAE,IAAI,KAAK,OAAO;YACtC,qBAAqB,EAAE,CAAC,CAAC,OAAO;SACjC,CAAC,IACF,CACH,CAAA;CAAA,CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { OverridableComponent } from "..";
3
- export interface LabelProps extends React.HTMLAttributes<HTMLParagraphElement> {
3
+ export interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
4
4
  /**
5
5
  * medium: 18px, small: 16px
6
6
  * @default "medium"
@@ -15,5 +15,5 @@ export interface LabelProps extends React.HTMLAttributes<HTMLParagraphElement> {
15
15
  */
16
16
  spacing?: boolean;
17
17
  }
18
- export declare const Label: OverridableComponent<LabelProps, HTMLParagraphElement>;
18
+ export declare const Label: OverridableComponent<LabelProps, HTMLLabelElement>;
19
19
  export default Label;
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import React, { forwardRef } from "react";
13
13
  import cl from "clsx";
14
14
  export const Label = forwardRef((_a, ref) => {
15
- var { className, size = "medium", spacing, as: Component = "p" } = _a, rest = __rest(_a, ["className", "size", "spacing", "as"]);
15
+ var { className, size = "medium", spacing, as: Component = "label" } = _a, rest = __rest(_a, ["className", "size", "spacing", "as"]);
16
16
  return (React.createElement(Component, Object.assign({}, rest, { ref: ref, className: cl(className, "navds-label", {
17
17
  "navds-label--small": size === "small",
18
18
  "navds-typo--spacing": !!spacing,
@@ -1 +1 @@
1
- {"version":3,"file":"Label.js","sourceRoot":"","sources":["../../src/typography/Label.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAmBtB,MAAM,CAAC,MAAM,KAAK,GAChB,UAAU,CACR,CACE,EAAqE,EACrE,GAAG,EACH,EAAE;QAFF,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,GAAG,GAAG,OAAW,EAAN,IAAI,cAAnE,sCAAqE,CAAF;IAEhE,OAAA,CACH,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE;YACtC,oBAAoB,EAAE,IAAI,KAAK,OAAO;YACtC,qBAAqB,EAAE,CAAC,CAAC,OAAO;SACjC,CAAC,IACF,CACH,CAAA;CAAA,CACF,CAAC;AAEJ,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Label.js","sourceRoot":"","sources":["../../src/typography/Label.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAoBtB,MAAM,CAAC,MAAM,KAAK,GAChB,UAAU,CACR,CACE,EAAyE,EACzE,GAAG,EACH,EAAE;QAFF,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,GAAG,OAAO,OAAW,EAAN,IAAI,cAAvE,sCAAyE,CAAF;IAEpE,OAAA,CACH,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE;YACtC,oBAAoB,EAAE,IAAI,KAAK,OAAO;YACtC,qBAAqB,EAAE,CAAC,CAAC,OAAO;SACjC,CAAC,IACF,CACH,CAAA;CAAA,CACF,CAAC;AAEJ,eAAe,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "1.0.0-rc.6",
3
+ "version": "1.0.0",
4
4
  "description": "NAV designsystem react components",
5
5
  "author": "NAV Designsystem team",
6
6
  "license": "MIT",
@@ -35,10 +35,10 @@
35
35
  "test": "jest"
36
36
  },
37
37
  "dependencies": {
38
- "@floating-ui/react-dom-interactions": "0.6.6",
39
- "@navikt/ds-icons": "^1.0.0-rc.6",
40
- "@radix-ui/react-tabs": "0.1.5",
41
- "@radix-ui/react-toggle-group": "0.1.5",
38
+ "@floating-ui/react-dom-interactions": "0.9.2",
39
+ "@navikt/ds-icons": "^1.0.0",
40
+ "@radix-ui/react-tabs": "1.0.0",
41
+ "@radix-ui/react-toggle-group": "1.0.0",
42
42
  "clsx": "^1.1.1",
43
43
  "react-modal": "3.15.1"
44
44
  },
@@ -74,5 +74,5 @@
74
74
  "optional": true
75
75
  }
76
76
  },
77
- "gitHead": "e943e716375c95e9e81de474577b77dcb2312752"
77
+ "gitHead": "155c556feab360fd9d3cdc4062408bd29ff17e71"
78
78
  }
@@ -1,6 +1,6 @@
1
1
  import cl from "clsx";
2
2
  import React, { FieldsetHTMLAttributes, forwardRef, useContext } from "react";
3
- import { BodyShort, Detail, Label, ErrorMessage, omit } from "../..";
3
+ import { BodyLong, Detail, Label, ErrorMessage, omit } from "../..";
4
4
  import { FormFieldProps } from "../useFormField";
5
5
  import { useFieldset } from "./useFieldset";
6
6
 
@@ -106,7 +106,7 @@ export const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(
106
106
  </Label>
107
107
  {!!description &&
108
108
  (size === "medium" ? (
109
- <BodyShort
109
+ <BodyLong
110
110
  className={cl("navds-fieldset__description", {
111
111
  "navds-sr-only": !!hideLegend,
112
112
  })}
@@ -115,7 +115,7 @@ export const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(
115
115
  as="div"
116
116
  >
117
117
  {props.description}
118
- </BodyShort>
118
+ </BodyLong>
119
119
  ) : (
120
120
  <Detail
121
121
  className={cl("navds-fieldset__description", {
@@ -1,7 +1,7 @@
1
1
  import React, { forwardRef, SelectHTMLAttributes } from "react";
2
2
  import cl from "clsx";
3
3
  import { Expand } from "@navikt/ds-icons";
4
- import { BodyShort, Label, ErrorMessage, omit, Detail } from "..";
4
+ import { BodyLong, Label, ErrorMessage, omit, Detail } from "..";
5
5
  import { FormFieldProps, useFormField } from "./useFormField";
6
6
 
7
7
  export interface SelectProps
@@ -66,7 +66,6 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
66
66
  <Label
67
67
  htmlFor={inputProps.id}
68
68
  size={size}
69
- as="label"
70
69
  className={cl("navds-form-field__label", {
71
70
  "navds-sr-only": hideLabel,
72
71
  })}
@@ -76,7 +75,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
76
75
  {!!description && (
77
76
  <>
78
77
  {size === "medium" ? (
79
- <BodyShort
78
+ <BodyLong
80
79
  className={cl("navds-form-field__description", {
81
80
  "navds-sr-only": hideLabel,
82
81
  })}
@@ -85,7 +84,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
85
84
  as="div"
86
85
  >
87
86
  {description}
88
- </BodyShort>
87
+ </BodyLong>
89
88
  ) : (
90
89
  <Detail
91
90
  className={cl("navds-form-field__description", {
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, InputHTMLAttributes } from "react";
2
2
  import cl from "clsx";
3
- import { BodyShort, Detail, Label, ErrorMessage, omit } from "..";
3
+ import { BodyLong, Detail, Label, ErrorMessage, omit } from "..";
4
4
  import { FormFieldProps, useFormField } from "./useFormField";
5
5
 
6
6
  export interface TextFieldProps
@@ -70,7 +70,6 @@ export const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
70
70
  <Label
71
71
  htmlFor={inputProps.id}
72
72
  size={size}
73
- as="label"
74
73
  className={cl("navds-form-field__label", {
75
74
  "navds-sr-only": hideLabel,
76
75
  })}
@@ -81,7 +80,7 @@ export const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
81
80
  {!!description && (
82
81
  <>
83
82
  {size === "medium" ? (
84
- <BodyShort
83
+ <BodyLong
85
84
  className={cl("navds-form-field__description", {
86
85
  "navds-sr-only": hideLabel,
87
86
  })}
@@ -90,7 +89,7 @@ export const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
90
89
  as="div"
91
90
  >
92
91
  {description}
93
- </BodyShort>
92
+ </BodyLong>
94
93
  ) : (
95
94
  <Detail
96
95
  className={cl("navds-form-field__description", {
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, useState } from "react";
2
2
  import cl from "clsx";
3
- import { BodyShort, Label, ErrorMessage, omit, Detail } from "..";
3
+ import { BodyShort, BodyLong, Label, ErrorMessage, omit, Detail } from "..";
4
4
  import { FormFieldProps, useFormField } from "./useFormField";
5
5
  import { useId } from "..";
6
6
  import TextareaAutosize from "../util/TextareaAutoSize";
@@ -83,6 +83,10 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
83
83
  return rows;
84
84
  };
85
85
 
86
+ const describedBy = cl(inputProps["aria-describedby"], {
87
+ [maxLengthId ?? ""]: hasMaxLength,
88
+ });
89
+
86
90
  return (
87
91
  <div
88
92
  className={cl(
@@ -99,7 +103,6 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
99
103
  <Label
100
104
  htmlFor={inputProps.id}
101
105
  size={size}
102
- as="label"
103
106
  className={cl("navds-form-field__label", {
104
107
  "navds-sr-only": hideLabel,
105
108
  })}
@@ -109,7 +112,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
109
112
  {!!description && (
110
113
  <>
111
114
  {size === "medium" ? (
112
- <BodyShort
115
+ <BodyLong
113
116
  className={cl("navds-form-field__description", {
114
117
  "navds-sr-only": hideLabel,
115
118
  })}
@@ -118,7 +121,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
118
121
  as="div"
119
122
  >
120
123
  {description}
121
- </BodyShort>
124
+ </BodyLong>
122
125
  ) : (
123
126
  <Detail
124
127
  className={cl("navds-form-field__description", {
@@ -152,9 +155,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
152
155
  "navds-textarea--counter": hasMaxLength,
153
156
  }
154
157
  )}
155
- aria-describedby={cl(inputProps["aria-describedby"], {
156
- [maxLengthId ?? ""]: hasMaxLength,
157
- })}
158
+ {...(describedBy ? { "aria-describedby": describedBy } : {})}
158
159
  />
159
160
  {hasMaxLength && (
160
161
  <>
@@ -84,24 +84,24 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
84
84
  }}
85
85
  />
86
86
  <label htmlFor={inputProps.id} className="navds-checkbox__label">
87
- <div
87
+ <span
88
88
  className={cl("navds-checkbox__content", {
89
89
  "navds-sr-only": props.hideLabel,
90
90
  })}
91
91
  >
92
- <BodyShort as="div" size={size}>
92
+ <BodyShort as="span" size={size}>
93
93
  {props.children}
94
94
  </BodyShort>
95
95
  {props.description && (
96
96
  <Description
97
- as="div"
97
+ as="span"
98
98
  size="small"
99
99
  className="navds-checkbox__description"
100
100
  >
101
101
  {props.description}
102
102
  </Description>
103
103
  )}
104
- </div>
104
+ </span>
105
105
  </label>
106
106
  </div>
107
107
  );
@@ -8,6 +8,9 @@ export default {
8
8
  subcomponents: {
9
9
  CheckboxGroup,
10
10
  },
11
+ argTypes: {
12
+ size: { control: { type: "select", options: ["medium", "small"] } },
13
+ },
11
14
  } as Meta;
12
15
 
13
16
  export const Default = (props) => {
@@ -22,7 +25,7 @@ export const Default = (props) => {
22
25
  onChange={props.controlled ? setState : undefined}
23
26
  hideLegend={props.hideLegend}
24
27
  error={props.errorGroup ? "Errormelding for checkboxgruppe" : undefined}
25
- {...props}
28
+ size={props?.size}
26
29
  >
27
30
  <Checkbox
28
31
  value="checkbox1"
@@ -40,20 +40,20 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
40
40
  ref={ref}
41
41
  />
42
42
  <label htmlFor={inputProps.id} className="navds-radio__label">
43
- <div className="navds-radio__content">
44
- <BodyShort as="div" size={size}>
43
+ <span className="navds-radio__content">
44
+ <BodyShort as="span" size={size}>
45
45
  {props.children}
46
46
  </BodyShort>
47
47
  {props.description && (
48
48
  <Description
49
- as="div"
49
+ as="span"
50
50
  size="small"
51
51
  className="navds-radio__description"
52
52
  >
53
53
  {props.description}
54
54
  </Description>
55
55
  )}
56
- </div>
56
+ </span>
57
57
  </label>
58
58
  </div>
59
59
  );
@@ -8,6 +8,9 @@ export default {
8
8
  subcomponents: {
9
9
  RadioGroup,
10
10
  },
11
+ argTypes: {
12
+ size: { control: { type: "select", options: ["medium", "small"] } },
13
+ },
11
14
  } as Meta;
12
15
 
13
16
  export const Default = (props) => {
@@ -21,7 +24,7 @@ export const Default = (props) => {
21
24
  onChange={props.controlled ? setState : undefined}
22
25
  hideLegend={props.hideLegend}
23
26
  error={props.errorGroup ? "Errormelding" : undefined}
24
- {...props}
27
+ size={props?.size}
25
28
  >
26
29
  <Radio value="radio1">{props.children || "Apple"}</Radio>
27
30
  <Radio
@@ -38,6 +41,7 @@ export const Default = (props) => {
38
41
 
39
42
  Default.args = {
40
43
  controlled: false,
44
+ size: "medium",
41
45
  legend: "Legend-tekst",
42
46
  radioDescription: false,
43
47
  hideLegend: false,
@@ -163,7 +163,6 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
163
163
  <Label
164
164
  htmlFor={inputProps.id}
165
165
  size={size}
166
- as="label"
167
166
  className={cl("navds-form-field__label", {
168
167
  "navds-sr-only": hideLabel,
169
168
  })}
@@ -9,7 +9,7 @@ export interface HelpTextProps
9
9
  /**
10
10
  * Helptext-dialog content
11
11
  */
12
- children: React.ReactNode;
12
+ children: string;
13
13
  /**
14
14
  * Adds a title-tooltip with the given text
15
15
  * @default "hjelp"
@@ -55,7 +55,7 @@ export const Variant = () => (
55
55
  <Loader size="3xlarge" variant="inverted" />
56
56
  <Loader size="3xlarge" variant="interaction" />
57
57
  </div>
58
- <div style={{ backgroundColor: "#292929" }}>
58
+ <div style={{ backgroundColor: "#262626" }}>
59
59
  <Loader size="3xlarge" variant="neutral" />
60
60
  <Loader size="3xlarge" variant="inverted" />
61
61
  <Loader size="3xlarge" variant="interaction" />
@@ -70,7 +70,7 @@ export const Transparent = () => (
70
70
  <Loader size="3xlarge" transparent variant="inverted" />
71
71
  <Loader size="3xlarge" transparent variant="interaction" />
72
72
  </div>
73
- <div style={{ backgroundColor: "#292929" }}>
73
+ <div style={{ backgroundColor: "#262626" }}>
74
74
  <Loader size="3xlarge" transparent variant="neutral" />
75
75
  <Loader size="3xlarge" transparent variant="inverted" />
76
76
  <Loader size="3xlarge" transparent variant="interaction" />
@@ -32,6 +32,10 @@ export interface ModalProps {
32
32
  * @default true
33
33
  */
34
34
  closeButton?: boolean;
35
+ /**
36
+ * Allows custom styling of ReactModal, in accordance with their typing
37
+ */
38
+ style?: ReactModal.Styles;
35
39
  /**
36
40
  * Callback for setting parent element modal will attach to
37
41
  */
@@ -71,6 +75,7 @@ export const Modal = forwardRef<ReactModal, ModalProps>(
71
75
  "aria-labelledby": ariaLabelledBy,
72
76
  "aria-modal": ariaModal,
73
77
  "aria-label": contentLabel,
78
+ style,
74
79
  ...rest
75
80
  },
76
81
  ref
@@ -90,6 +95,7 @@ export const Modal = forwardRef<ReactModal, ModalProps>(
90
95
  return (
91
96
  <ReactModal
92
97
  {...rest}
98
+ style={style}
93
99
  isOpen={open}
94
100
  ref={mergedRef}
95
101
  className={cl("navds-modal", className)}
@@ -1,5 +1,6 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { BodyLong, Button, Heading, Modal } from "../..";
2
+ import { BodyLong, Button, Heading } from "../..";
3
+ import Modal from "./Modal";
3
4
 
4
5
  export default {
5
6
  title: "ds-react/Modal",
@@ -13,16 +14,23 @@ export const Default = (props) => {
13
14
  const [open, setOpen] = useState(false);
14
15
 
15
16
  useEffect(() => {
16
- Modal.setAppElement("#root");
17
+ Modal.setAppElement?.("#root");
17
18
  }, []);
18
19
 
19
20
  return (
20
21
  <>
21
- <Button onClick={() => setOpen(true)}>Open</Button>
22
+ <Button onClick={() => setOpen(true)}>Open Modal</Button>
23
+ <p>
24
+ We can also custom style the modal by passing in a react-modal style
25
+ object. Here the backdrop is red.
26
+ </p>
22
27
  <Modal
23
28
  open={open}
24
29
  onClose={() => setOpen(false)}
25
30
  aria-labelledby="header123"
31
+ style={{
32
+ overlay: { backgroundColor: "#ff0000aa" },
33
+ }}
26
34
  {...props}
27
35
  >
28
36
  <Modal.Content>
@@ -43,62 +51,3 @@ Default.args = {
43
51
  shouldCloseOnOverlayClick: true,
44
52
  closeButton: true,
45
53
  };
46
-
47
- export const Open = () => {
48
- const [open, setOpen] = useState(null);
49
-
50
- useEffect(() => {
51
- Modal.setAppElement("#root");
52
- }, []);
53
-
54
- return (
55
- <>
56
- <Button onClick={() => setOpen(true)}>Open</Button>
57
- <Modal
58
- open={open ?? true}
59
- onClose={() => setOpen(false)}
60
- aria-labelledby="header123"
61
- >
62
- <Modal.Content>
63
- <Heading spacing id="header123" level="1" size="large">
64
- Header
65
- </Heading>
66
- <Heading spacing level="2" size="medium">
67
- Header
68
- </Heading>
69
- <BodyLong>Voluptate laboris mollit dolore qui. Magna elit.</BodyLong>
70
- </Modal.Content>
71
- </Modal>
72
- </>
73
- );
74
- };
75
-
76
- export const CloseButton = () => {
77
- const [open, setOpen] = useState(true);
78
-
79
- useEffect(() => {
80
- Modal.setAppElement("#root");
81
- }, []);
82
-
83
- return (
84
- <>
85
- <Button onClick={() => setOpen(true)}>Open</Button>
86
- <Modal
87
- open={open}
88
- onClose={() => setOpen(false)}
89
- aria-labelledby="header123"
90
- closeButton={false}
91
- >
92
- <Modal.Content>
93
- <Heading spacing id="header123" level="1" size="large">
94
- Header
95
- </Heading>
96
- <Heading spacing level="2" size="medium">
97
- Header
98
- </Heading>
99
- <BodyLong>Voluptate laboris mollit dolore qui. Magna elit.</BodyLong>
100
- </Modal.Content>
101
- </Modal>
102
- </>
103
- );
104
- };
@@ -1,6 +1,5 @@
1
1
  import React, { forwardRef, useContext } from "react";
2
2
  import cl from "clsx";
3
- import { Label } from "..";
4
3
  import { TableContext } from "./Table";
5
4
 
6
5
  export interface HeaderCellProps
@@ -23,17 +22,16 @@ export const HeaderCell: HeaderCellType = forwardRef(
23
22
  const context = useContext(TableContext);
24
23
 
25
24
  return (
26
- <Label
27
- as="th"
25
+ <th
28
26
  ref={ref}
29
- className={cl("navds-table__header-cell", className, {
27
+ className={cl("navds-table__header-cell", "navds-label", className, {
30
28
  [`navds-table__header-cell--align-${align}`]: align,
29
+ "navds-label--small": context?.size === "small",
31
30
  })}
32
- size={context?.size}
33
31
  {...rest}
34
32
  >
35
33
  {children}
36
- </Label>
34
+ </th>
37
35
  );
38
36
  }
39
37
  );
@@ -1,9 +1,9 @@
1
- import React from "react";
1
+ import React, { forwardRef } from "react";
2
2
  import cl from "clsx";
3
- import { Label } from "..";
3
+ import { OverridableComponent } from "..";
4
4
 
5
5
  export interface ErrorMessageProps
6
- extends React.HTMLAttributes<HTMLDivElement> {
6
+ extends React.HTMLAttributes<HTMLParagraphElement> {
7
7
  /**
8
8
  * medium: 18px, small: 16px
9
9
  * @default "medium"
@@ -13,14 +13,26 @@ export interface ErrorMessageProps
13
13
  * Error text
14
14
  */
15
15
  children: React.ReactNode;
16
+ /**
17
+ * Adds margin-bottom
18
+ */
19
+ spacing?: boolean;
16
20
  }
17
21
 
18
- const ErrorMessage = (props) => (
19
- <Label
20
- {...props}
21
- as="div"
22
- className={cl("navds-error-message", props.className)}
23
- />
22
+ const ErrorMessage: OverridableComponent<
23
+ ErrorMessageProps,
24
+ HTMLParagraphElement
25
+ > = forwardRef(
26
+ ({ className, size, spacing, as: Component = "p", ...rest }, ref) => (
27
+ <Component
28
+ {...rest}
29
+ ref={ref}
30
+ className={cl("navds-error-message", "navds-label", className, {
31
+ "navds-label--small": size === "small",
32
+ "navds-typo--spacing": !!spacing,
33
+ })}
34
+ />
35
+ )
24
36
  );
25
37
 
26
38
  export default ErrorMessage;
@@ -2,7 +2,8 @@ import React, { forwardRef } from "react";
2
2
  import cl from "clsx";
3
3
  import { OverridableComponent } from "..";
4
4
 
5
- export interface LabelProps extends React.HTMLAttributes<HTMLParagraphElement> {
5
+ export interface LabelProps
6
+ extends React.LabelHTMLAttributes<HTMLLabelElement> {
6
7
  /**
7
8
  * medium: 18px, small: 16px
8
9
  * @default "medium"
@@ -18,10 +19,10 @@ export interface LabelProps extends React.HTMLAttributes<HTMLParagraphElement> {
18
19
  spacing?: boolean;
19
20
  }
20
21
 
21
- export const Label: OverridableComponent<LabelProps, HTMLParagraphElement> =
22
+ export const Label: OverridableComponent<LabelProps, HTMLLabelElement> =
22
23
  forwardRef(
23
24
  (
24
- { className, size = "medium", spacing, as: Component = "p", ...rest },
25
+ { className, size = "medium", spacing, as: Component = "label", ...rest },
25
26
  ref
26
27
  ) => (
27
28
  <Component