@navikt/ds-react 5.12.2 → 5.12.4

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.
@@ -60,7 +60,7 @@ exports.Fieldset = (0, react_1.forwardRef)((props, ref) => {
60
60
  disabled: (_c = props.disabled) !== null && _c !== void 0 ? _c : false,
61
61
  readOnly,
62
62
  } },
63
- react_1.default.createElement("fieldset", Object.assign({}, (0, util_1.omit)(rest, ["errorId", "error", "size", "readOnly"]), inputProps, { ref: ref, className: (0, clsx_1.default)(className, "navds-fieldset", `navds-fieldset--${size}`, {
63
+ react_1.default.createElement("fieldset", Object.assign({}, (0, util_1.omit)(rest, ["errorId", "error", "size", "readOnly"]), (0, util_1.omit)(inputProps, ["aria-describedby", "aria-invalid"]), { ref: ref, className: (0, clsx_1.default)(className, "navds-fieldset", `navds-fieldset--${size}`, {
64
64
  "navds-fieldset--error": hasError,
65
65
  "navds-fieldset--readonly": readOnly,
66
66
  }) }),
@@ -35,6 +35,8 @@ const ReadOnlyIcon_1 = require("../ReadOnlyIcon");
35
35
  const useCheckbox_1 = __importDefault(require("./useCheckbox"));
36
36
  exports.Checkbox = (0, react_1.forwardRef)((props, ref) => {
37
37
  const { inputProps, hasError, size, readOnly, nested } = (0, useCheckbox_1.default)(props);
38
+ const labelId = (0, util_1.useId)();
39
+ const descriptionId = (0, util_1.useId)();
38
40
  return (react_1.default.createElement("div", { className: (0, clsx_1.default)(props.className, "navds-checkbox", `navds-checkbox--${size}`, {
39
41
  "navds-checkbox--error": hasError,
40
42
  "navds-checkbox--disabled": inputProps.disabled,
@@ -49,7 +51,7 @@ exports.Checkbox = (0, react_1.forwardRef)((props, ref) => {
49
51
  "indeterminate",
50
52
  "errorId",
51
53
  "readOnly",
52
- ]), inputProps, { type: "checkbox", className: "navds-checkbox__input", "aria-checked": props.indeterminate ? "mixed" : inputProps.checked, ref: (el) => {
54
+ ]), (0, util_1.omit)(inputProps, ["aria-invalid"]), { type: "checkbox", className: "navds-checkbox__input", "aria-checked": props.indeterminate ? "mixed" : inputProps.checked, ref: (el) => {
53
55
  var _a;
54
56
  if (el) {
55
57
  el.indeterminate = (_a = props.indeterminate) !== null && _a !== void 0 ? _a : false;
@@ -60,7 +62,9 @@ exports.Checkbox = (0, react_1.forwardRef)((props, ref) => {
60
62
  else if (ref != null) {
61
63
  ref.current = el;
62
64
  }
63
- } })),
65
+ }, "aria-labelledby": (0, clsx_1.default)(labelId, !!props["aria-labelledby"] && props["aria-labelledby"], {
66
+ [descriptionId]: props.description,
67
+ }) })),
64
68
  react_1.default.createElement("label", { htmlFor: inputProps.id, className: "navds-checkbox__label" },
65
69
  react_1.default.createElement("span", { className: "navds-checkbox__icon" },
66
70
  react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "0.8125rem", height: "0.625rem", viewBox: "0 0 13 10", fill: "none", focusable: false, role: "img", "aria-hidden": true },
@@ -68,9 +72,9 @@ exports.Checkbox = (0, react_1.forwardRef)((props, ref) => {
68
72
  react_1.default.createElement("span", { className: (0, clsx_1.default)("navds-checkbox__content", {
69
73
  "navds-sr-only": props.hideLabel,
70
74
  }) },
71
- react_1.default.createElement(typography_1.BodyShort, { as: "span", size: size, className: "navds-checkbox__label-text" },
75
+ react_1.default.createElement(typography_1.BodyShort, { as: "span", id: labelId, size: size, className: "navds-checkbox__label-text", "aria-hidden": true },
72
76
  !nested && (react_1.default.createElement(ReadOnlyIcon_1.ReadOnlyIcon, { readOnly: readOnly, nativeReadOnly: false })),
73
77
  props.children),
74
- props.description && (react_1.default.createElement(typography_1.BodyShort, { as: "span", size: size, className: "navds-form-field__subdescription navds-checkbox__description" }, props.description))))));
78
+ props.description && (react_1.default.createElement(typography_1.BodyShort, { as: "span", id: descriptionId, size: size, className: "navds-form-field__subdescription navds-checkbox__description", "aria-hidden": true }, props.description))))));
75
79
  });
76
80
  exports.default = exports.Checkbox;
@@ -34,15 +34,19 @@ const util_1 = require("../../util");
34
34
  const useRadio_1 = require("./useRadio");
35
35
  exports.Radio = (0, react_1.forwardRef)((props, ref) => {
36
36
  const { inputProps, size, hasError, readOnly } = (0, useRadio_1.useRadio)(props);
37
+ const labelId = (0, util_1.useId)();
38
+ const descriptionId = (0, util_1.useId)();
37
39
  return (react_1.default.createElement("div", { className: (0, clsx_1.default)(props.className, "navds-radio", `navds-radio--${size}`, {
38
40
  "navds-radio--error": hasError,
39
41
  "navds-radio--disabled": inputProps.disabled,
40
42
  "navds-radio--readonly": readOnly,
41
43
  }) },
42
- react_1.default.createElement("input", Object.assign({}, (0, util_1.omit)(props, ["children", "size", "description", "readOnly"]), inputProps, { className: "navds-radio__input", ref: ref })),
44
+ react_1.default.createElement("input", Object.assign({}, (0, util_1.omit)(props, ["children", "size", "description", "readOnly"]), (0, util_1.omit)(inputProps, ["aria-invalid"]), { "aria-labelledby": (0, clsx_1.default)(labelId, !!props["aria-labelledby"] && props["aria-labelledby"], {
45
+ [descriptionId]: props.description,
46
+ }), className: "navds-radio__input", ref: ref })),
43
47
  react_1.default.createElement("label", { htmlFor: inputProps.id, className: "navds-radio__label" },
44
48
  react_1.default.createElement("span", { className: "navds-radio__content" },
45
- react_1.default.createElement(typography_1.BodyShort, { as: "span", size: size }, props.children),
46
- props.description && (react_1.default.createElement(typography_1.BodyShort, { as: "span", size: size, className: "navds-form-field__subdescription navds-radio__description" }, props.description))))));
49
+ react_1.default.createElement(typography_1.BodyShort, { as: "span", id: labelId, size: size, "aria-hidden": true }, props.children),
50
+ props.description && (react_1.default.createElement(typography_1.BodyShort, { as: "span", id: descriptionId, size: size, className: "navds-form-field__subdescription navds-radio__description", "aria-hidden": true }, props.description))))));
47
51
  });
48
52
  exports.default = exports.Radio;
@@ -31,7 +31,7 @@ export const Fieldset = forwardRef((props, ref) => {
31
31
  disabled: (_c = props.disabled) !== null && _c !== void 0 ? _c : false,
32
32
  readOnly,
33
33
  } },
34
- React.createElement("fieldset", Object.assign({}, omit(rest, ["errorId", "error", "size", "readOnly"]), inputProps, { ref: ref, className: cl(className, "navds-fieldset", `navds-fieldset--${size}`, {
34
+ React.createElement("fieldset", Object.assign({}, omit(rest, ["errorId", "error", "size", "readOnly"]), omit(inputProps, ["aria-describedby", "aria-invalid"]), { ref: ref, className: cl(className, "navds-fieldset", `navds-fieldset--${size}`, {
35
35
  "navds-fieldset--error": hasError,
36
36
  "navds-fieldset--readonly": readOnly,
37
37
  }) }),
@@ -1 +1 @@
1
- {"version":3,"file":"Fieldset.js","sourceRoot":"","sources":["../../../src/form/Fieldset/Fieldset.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAA0B,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAyB5C,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAChC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;;IACb,MAAM,EACJ,UAAU,EACV,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,kBAAkB,GACnB,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAEvB,MAAM,QAAQ,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAE7C,MAAM,EACJ,QAAQ,EACR,SAAS,EACT,gBAAgB,GAAG,IAAI,EACvB,MAAM,EACN,WAAW,EACX,UAAU,EACV,cAAc,GAAG,IAAI,KAEnB,KAAK,EADJ,IAAI,UACL,KAAK,EATH,sGASL,CAAQ,CAAC;IAEV,OAAO,CACL,oBAAC,e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,IAAI,CAChB,oBAAC,SAAS,IACR,SAAS,EAAE,EAAE,CAAC,6BAA6B,EAAE;oBAC3C,eAAe,EAAE,CAAC,CAAC,UAAU;iBAC9B,CAAC,EACF,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,QAAQ,EACtB,EAAE,EAAC,KAAK,IAEP,KAAK,CAAC,WAAW,CACR,CACb;YACA,QAAQ;YACT,6BACE,EAAE,EAAE,OAAO,mBACG,oBAAoB,eACxB,QAAQ,EAClB,SAAS,EAAC,uBAAuB,IAEhC,YAAY,IAAI,CACf,oBAAC,YAAY,IAAC,IAAI,EAAE,IAAI,IAAG,KAAK,CAAC,KAAK,CAAgB,CACvD,CACG,CACG,CACc,CAC5B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,11 +1,13 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { BodyShort } from "../../typography";
4
- import { omit } from "../../util";
4
+ import { omit, useId } from "../../util";
5
5
  import { ReadOnlyIcon } from "../ReadOnlyIcon";
6
6
  import useCheckbox from "./useCheckbox";
7
7
  export const Checkbox = forwardRef((props, ref) => {
8
8
  const { inputProps, hasError, size, readOnly, nested } = useCheckbox(props);
9
+ const labelId = useId();
10
+ const descriptionId = useId();
9
11
  return (React.createElement("div", { className: cl(props.className, "navds-checkbox", `navds-checkbox--${size}`, {
10
12
  "navds-checkbox--error": hasError,
11
13
  "navds-checkbox--disabled": inputProps.disabled,
@@ -20,7 +22,7 @@ export const Checkbox = forwardRef((props, ref) => {
20
22
  "indeterminate",
21
23
  "errorId",
22
24
  "readOnly",
23
- ]), inputProps, { type: "checkbox", className: "navds-checkbox__input", "aria-checked": props.indeterminate ? "mixed" : inputProps.checked, ref: (el) => {
25
+ ]), omit(inputProps, ["aria-invalid"]), { type: "checkbox", className: "navds-checkbox__input", "aria-checked": props.indeterminate ? "mixed" : inputProps.checked, ref: (el) => {
24
26
  var _a;
25
27
  if (el) {
26
28
  el.indeterminate = (_a = props.indeterminate) !== null && _a !== void 0 ? _a : false;
@@ -31,7 +33,9 @@ export const Checkbox = forwardRef((props, ref) => {
31
33
  else if (ref != null) {
32
34
  ref.current = el;
33
35
  }
34
- } })),
36
+ }, "aria-labelledby": cl(labelId, !!props["aria-labelledby"] && props["aria-labelledby"], {
37
+ [descriptionId]: props.description,
38
+ }) })),
35
39
  React.createElement("label", { htmlFor: inputProps.id, className: "navds-checkbox__label" },
36
40
  React.createElement("span", { className: "navds-checkbox__icon" },
37
41
  React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "0.8125rem", height: "0.625rem", viewBox: "0 0 13 10", fill: "none", focusable: false, role: "img", "aria-hidden": true },
@@ -39,10 +43,10 @@ export const Checkbox = forwardRef((props, ref) => {
39
43
  React.createElement("span", { className: cl("navds-checkbox__content", {
40
44
  "navds-sr-only": props.hideLabel,
41
45
  }) },
42
- React.createElement(BodyShort, { as: "span", size: size, className: "navds-checkbox__label-text" },
46
+ React.createElement(BodyShort, { as: "span", id: labelId, size: size, className: "navds-checkbox__label-text", "aria-hidden": true },
43
47
  !nested && (React.createElement(ReadOnlyIcon, { readOnly: readOnly, nativeReadOnly: false })),
44
48
  props.children),
45
- props.description && (React.createElement(BodyShort, { as: "span", size: size, className: "navds-form-field__subdescription navds-checkbox__description" }, props.description))))));
49
+ props.description && (React.createElement(BodyShort, { as: "span", id: descriptionId, size: size, className: "navds-form-field__subdescription navds-checkbox__description", "aria-hidden": true }, props.description))))));
46
50
  });
47
51
  export default Checkbox;
48
52
  //# sourceMappingURL=Checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/form/checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAA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react";
3
3
  import { BodyShort } from "../../typography";
4
- import { omit } from "../../util";
4
+ import { omit, useId } from "../../util";
5
5
  import { useRadio } from "./useRadio";
6
6
  export const Radio = forwardRef((props, ref) => {
7
7
  const { inputProps, size, hasError, readOnly } = useRadio(props);
8
+ const labelId = useId();
9
+ const descriptionId = useId();
8
10
  return (React.createElement("div", { className: cl(props.className, "navds-radio", `navds-radio--${size}`, {
9
11
  "navds-radio--error": hasError,
10
12
  "navds-radio--disabled": inputProps.disabled,
11
13
  "navds-radio--readonly": readOnly,
12
14
  }) },
13
- React.createElement("input", Object.assign({}, omit(props, ["children", "size", "description", "readOnly"]), inputProps, { className: "navds-radio__input", ref: ref })),
15
+ React.createElement("input", Object.assign({}, omit(props, ["children", "size", "description", "readOnly"]), omit(inputProps, ["aria-invalid"]), { "aria-labelledby": cl(labelId, !!props["aria-labelledby"] && props["aria-labelledby"], {
16
+ [descriptionId]: props.description,
17
+ }), className: "navds-radio__input", ref: ref })),
14
18
  React.createElement("label", { htmlFor: inputProps.id, className: "navds-radio__label" },
15
19
  React.createElement("span", { className: "navds-radio__content" },
16
- React.createElement(BodyShort, { as: "span", size: size }, props.children),
17
- props.description && (React.createElement(BodyShort, { as: "span", size: size, className: "navds-form-field__subdescription navds-radio__description" }, props.description))))));
20
+ React.createElement(BodyShort, { as: "span", id: labelId, size: size, "aria-hidden": true }, props.children),
21
+ props.description && (React.createElement(BodyShort, { as: "span", id: descriptionId, size: size, className: "navds-form-field__subdescription navds-radio__description", "aria-hidden": true }, props.description))))));
18
22
  });
19
23
  export default Radio;
20
24
  //# sourceMappingURL=Radio.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../../src/form/radio/Radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CA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C,MAAM,EAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,yBACzC,KAAK,CAAC,QAAQ,CACL;gBACX,KAAK,CAAC,WAAW,IAAI,CACpB,oBAAC,SAAS,IACR,EAAE,EAAC,MAAM,EACT,EAAE,EAAE,aAAa,EACjB,IAAI,EAAE,IAAI,EACV,SAAS,EAAC,2DAA2D,yBAGpE,KAAK,CAAC,WAAW,CACR,CACb,CACI,CACD,CACJ,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC"}
@@ -4,4 +4,4 @@
4
4
  * @param idOverride
5
5
  * @returns {string}
6
6
  */
7
- export declare function useId(idOverride?: string): string | undefined;
7
+ export declare function useId(idOverride?: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/ds-react",
3
- "version": "5.12.2",
3
+ "version": "5.12.4",
4
4
  "description": "Aksel react-components for NAV designsystem",
5
5
  "author": "Aksel | NAV designsystem team",
6
6
  "license": "MIT",
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@floating-ui/react": "0.25.4",
41
- "@navikt/aksel-icons": "^5.12.2",
42
- "@navikt/ds-tokens": "^5.12.2",
41
+ "@navikt/aksel-icons": "^5.12.4",
42
+ "@navikt/ds-tokens": "^5.12.4",
43
43
  "@radix-ui/react-tabs": "1.0.0",
44
44
  "@radix-ui/react-toggle-group": "1.0.0",
45
45
  "clsx": "^1.2.1",
@@ -70,7 +70,7 @@ export const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(
70
70
  >
71
71
  <fieldset
72
72
  {...omit(rest, ["errorId", "error", "size", "readOnly"])}
73
- {...inputProps}
73
+ {...omit(inputProps, ["aria-describedby", "aria-invalid"])}
74
74
  ref={ref}
75
75
  className={cl(
76
76
  className,
@@ -1,6 +1,6 @@
1
- import React from "react";
2
1
  import { fireEvent, render, screen } from "@testing-library/react";
3
2
  import faker from "faker";
3
+ import React from "react";
4
4
  import { Checkbox, CheckboxGroup } from ".";
5
5
 
6
6
  const firstArgumentOfFirstCall = (fn: jest.Mock) => fn.mock.calls[0][0];
@@ -1,7 +1,7 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { BodyShort } from "../../typography";
4
- import { omit } from "../../util";
4
+ import { omit, useId } from "../../util";
5
5
  import { ReadOnlyIcon } from "../ReadOnlyIcon";
6
6
  import { CheckboxProps } from "./types";
7
7
  import useCheckbox from "./useCheckbox";
@@ -10,6 +10,9 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
10
10
  (props, ref) => {
11
11
  const { inputProps, hasError, size, readOnly, nested } = useCheckbox(props);
12
12
 
13
+ const labelId = useId();
14
+ const descriptionId = useId();
15
+
13
16
  return (
14
17
  <div
15
18
  className={cl(
@@ -34,7 +37,7 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
34
37
  "errorId",
35
38
  "readOnly",
36
39
  ])}
37
- {...inputProps}
40
+ {...omit(inputProps, ["aria-invalid"])}
38
41
  type="checkbox"
39
42
  className="navds-checkbox__input"
40
43
  aria-checked={props.indeterminate ? "mixed" : inputProps.checked}
@@ -49,6 +52,13 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
49
52
  ref.current = el;
50
53
  }
51
54
  }}
55
+ aria-labelledby={cl(
56
+ labelId,
57
+ !!props["aria-labelledby"] && props["aria-labelledby"],
58
+ {
59
+ [descriptionId]: props.description,
60
+ }
61
+ )}
52
62
  />
53
63
  <label htmlFor={inputProps.id} className="navds-checkbox__label">
54
64
  <span className="navds-checkbox__icon">
@@ -75,8 +85,10 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
75
85
  >
76
86
  <BodyShort
77
87
  as="span"
88
+ id={labelId}
78
89
  size={size}
79
90
  className="navds-checkbox__label-text"
91
+ aria-hidden
80
92
  >
81
93
  {!nested && (
82
94
  <ReadOnlyIcon readOnly={readOnly} nativeReadOnly={false} />
@@ -86,8 +98,10 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
86
98
  {props.description && (
87
99
  <BodyShort
88
100
  as="span"
101
+ id={descriptionId}
89
102
  size={size}
90
103
  className="navds-form-field__subdescription navds-checkbox__description"
104
+ aria-hidden
91
105
  >
92
106
  {props.description}
93
107
  </BodyShort>
@@ -134,27 +134,31 @@ export const SingleSmall = () => (
134
134
  </div>
135
135
  );
136
136
 
137
- export const SingleDescription = () => (
138
- <div className="colspan">
139
- <Checkbox value="tekst" description="checkboxdescription">
140
- Checkboxtekst
141
- </Checkbox>
142
- <Checkbox value="tekst" defaultChecked description="checkboxdescription">
143
- Checkboxtekst
144
- </Checkbox>
145
- </div>
146
- );
147
-
148
- export const SingleError = () => (
149
- <div className="colspan">
150
- <Checkbox value="tekst" error>
151
- Checkboxtekst
152
- </Checkbox>
153
- <Checkbox value="tekst" defaultChecked error>
154
- Checkboxtekst
155
- </Checkbox>
156
- </div>
157
- );
137
+ export const SingleDescription = () => {
138
+ const [isValueSelected, setValueSelected] = useState(false);
139
+ return (
140
+ <CheckboxGroup
141
+ legend="Hvor vil du sitte?"
142
+ className="colspan"
143
+ error={!isValueSelected ? "Du må velge en sitteplass" : undefined}
144
+ >
145
+ <Checkbox
146
+ onChange={() => setValueSelected(true)}
147
+ value="foran"
148
+ description="Tilgjengelig med rullestol"
149
+ >
150
+ Foran
151
+ </Checkbox>
152
+ <Checkbox
153
+ onChange={() => setValueSelected(true)}
154
+ value="tekst"
155
+ description="Adgang via trapp med to trinn"
156
+ >
157
+ Bak
158
+ </Checkbox>
159
+ </CheckboxGroup>
160
+ );
161
+ };
158
162
 
159
163
  export const Indeterminate = () => {
160
164
  const [checked, setChecked] = useState([true, false]);
@@ -1,13 +1,16 @@
1
1
  import cl from "clsx";
2
2
  import React, { forwardRef } from "react";
3
3
  import { BodyShort } from "../../typography";
4
- import { omit } from "../../util";
4
+ import { omit, useId } from "../../util";
5
5
  import { RadioProps } from "./types";
6
6
  import { useRadio } from "./useRadio";
7
7
 
8
8
  export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
9
9
  const { inputProps, size, hasError, readOnly } = useRadio(props);
10
10
 
11
+ const labelId = useId();
12
+ const descriptionId = useId();
13
+
11
14
  return (
12
15
  <div
13
16
  className={cl(props.className, "navds-radio", `navds-radio--${size}`, {
@@ -18,20 +21,29 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
18
21
  >
19
22
  <input
20
23
  {...omit(props, ["children", "size", "description", "readOnly"])}
21
- {...inputProps}
24
+ {...omit(inputProps, ["aria-invalid"])}
25
+ aria-labelledby={cl(
26
+ labelId,
27
+ !!props["aria-labelledby"] && props["aria-labelledby"],
28
+ {
29
+ [descriptionId]: props.description,
30
+ }
31
+ )}
22
32
  className="navds-radio__input"
23
33
  ref={ref}
24
34
  />
25
35
  <label htmlFor={inputProps.id} className="navds-radio__label">
26
36
  <span className="navds-radio__content">
27
- <BodyShort as="span" size={size}>
37
+ <BodyShort as="span" id={labelId} size={size} aria-hidden>
28
38
  {props.children}
29
39
  </BodyShort>
30
40
  {props.description && (
31
41
  <BodyShort
32
42
  as="span"
43
+ id={descriptionId}
33
44
  size={size}
34
45
  className="navds-form-field__subdescription navds-radio__description"
46
+ aria-hidden
35
47
  >
36
48
  {props.description}
37
49
  </BodyShort>
@@ -60,16 +60,33 @@ export const Group = () => (
60
60
  </RadioGroup>
61
61
  );
62
62
 
63
- export const GroupError = () => (
64
- <RadioGroup
65
- legend="Group legend"
66
- defaultValue="tekst2"
67
- error="Group errormelding"
68
- >
69
- <Radio value="tekst">Radiotekst</Radio>
70
- <Radio value="tekst2">Radiotekst</Radio>
71
- </RadioGroup>
72
- );
63
+ export const GroupError = () => {
64
+ const [isValueSelected, setValueSelected] = useState(false);
65
+ return (
66
+ <>
67
+ <button>Stop her</button>
68
+ <RadioGroup
69
+ legend="Velg din aldersgruppe"
70
+ description="Informasjonen blir brukt for å gi deg bedre søketreff."
71
+ error={!isValueSelected ? "Du må velge en aldersgruppe" : undefined}
72
+ >
73
+ <Radio onChange={() => setValueSelected(true)} value="0-20">
74
+ 0-20 år
75
+ </Radio>
76
+ <Radio
77
+ onChange={() => setValueSelected(true)}
78
+ value="21-45"
79
+ description="Gjelder fra året man blir 21"
80
+ >
81
+ 21-45 år
82
+ </Radio>
83
+ <Radio onChange={() => setValueSelected(true)} value="46-100">
84
+ 46-100 år
85
+ </Radio>
86
+ </RadioGroup>
87
+ </>
88
+ );
89
+ };
73
90
 
74
91
  export const GroupSmall = () => (
75
92
  <RadioGroup legend="Group legend" defaultValue="tekst2" size="small">
package/src/util/useId.ts CHANGED
@@ -27,7 +27,7 @@ const maybeReactUseId: undefined | (() => string) = (React as any)[
27
27
  * @param idOverride
28
28
  * @returns {string}
29
29
  */
30
- export function useId(idOverride?: string): string | undefined {
30
+ export function useId(idOverride?: string): string {
31
31
  if (maybeReactUseId !== undefined) {
32
32
  const reactId = maybeReactUseId();
33
33
  return idOverride ?? reactId.replace(/(:)/g, "");