@navikt/ds-react 5.12.3 → 5.12.5
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/date/monthpicker/MonthCaption.js +6 -6
- package/cjs/form/Fieldset/Fieldset.js +1 -1
- package/cjs/form/checkbox/Checkbox.js +8 -4
- package/cjs/form/combobox/Input/Input.js +4 -4
- package/cjs/form/radio/Radio.js +7 -3
- package/esm/date/monthpicker/MonthCaption.js +6 -6
- package/esm/date/monthpicker/MonthCaption.js.map +1 -1
- package/esm/form/Fieldset/Fieldset.js +1 -1
- package/esm/form/Fieldset/Fieldset.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +9 -5
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/combobox/Input/Input.js +4 -4
- package/esm/form/combobox/Input/Input.js.map +1 -1
- package/esm/form/radio/Radio.js +8 -4
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/util/useId.d.ts +1 -1
- package/package.json +3 -3
- package/src/date/monthpicker/MonthCaption.tsx +6 -6
- package/src/form/Fieldset/Fieldset.tsx +1 -1
- package/src/form/checkbox/Checkbox.test.tsx +1 -1
- package/src/form/checkbox/Checkbox.tsx +16 -2
- package/src/form/checkbox/checkbox.stories.tsx +25 -21
- package/src/form/combobox/Input/Input.tsx +7 -7
- package/src/form/radio/Radio.tsx +15 -3
- package/src/form/radio/radio.stories.tsx +27 -10
- package/src/util/useId.ts +1 -1
|
@@ -35,20 +35,20 @@ const MonthCaption = () => {
|
|
|
35
35
|
const newYear = Number(year.getFullYear() + val);
|
|
36
36
|
toYear((0, setYear_1.default)(year, newYear));
|
|
37
37
|
};
|
|
38
|
-
const
|
|
38
|
+
const disablePreviousYear = () => {
|
|
39
39
|
return fromDate
|
|
40
40
|
? (0, date_fns_1.isBefore)((year === null || year === void 0 ? void 0 : year.getFullYear()) - 1, fromDate === null || fromDate === void 0 ? void 0 : fromDate.getFullYear())
|
|
41
|
-
:
|
|
41
|
+
: false;
|
|
42
42
|
};
|
|
43
|
-
const
|
|
43
|
+
const disableNextYear = () => {
|
|
44
44
|
return toDate
|
|
45
45
|
? (0, date_fns_1.isAfter)((year === null || year === void 0 ? void 0 : year.getFullYear()) + 1, toDate === null || toDate === void 0 ? void 0 : toDate.getFullYear())
|
|
46
|
-
:
|
|
46
|
+
: false;
|
|
47
47
|
};
|
|
48
48
|
return (react_1.default.createElement("div", { className: "navds-date__caption" },
|
|
49
|
-
react_1.default.createElement(button_1.Button, { className: "navds-date__caption-button", disabled:
|
|
49
|
+
react_1.default.createElement(button_1.Button, { className: "navds-date__caption-button", disabled: disablePreviousYear(), onClick: () => handleButtonClick(-1), "aria-label": (0, utils_1.labelPrevYear)(locale === null || locale === void 0 ? void 0 : locale.code), icon: react_1.default.createElement(aksel_icons_1.ArrowLeftIcon, { "aria-hidden": true }), variant: "tertiary", type: "button" }),
|
|
50
50
|
hasDropdown ? (react_1.default.createElement(Select_1.Select, { label: "velg \u00E5r", hideLabel: true, value: year === null || year === void 0 ? void 0 : year.getFullYear(), onChange: handleYearChange, className: "navds-date__caption__year" }, years.map((yearOpt) => (react_1.default.createElement("option", { key: yearOpt.getFullYear(), value: yearOpt.getFullYear() }, formatYearCaption(yearOpt, { locale })))))) : (react_1.default.createElement("span", { className: "navds-date__year-label", "aria-live": "polite" }, year.getFullYear())),
|
|
51
|
-
react_1.default.createElement(button_1.Button, { className: "navds-date__caption-button", disabled:
|
|
51
|
+
react_1.default.createElement(button_1.Button, { className: "navds-date__caption-button", disabled: disableNextYear(), onClick: () => handleButtonClick(1), "aria-label": (0, utils_1.labelNextYear)(locale === null || locale === void 0 ? void 0 : locale.code), icon: react_1.default.createElement(aksel_icons_1.ArrowRightIcon, { "aria-hidden": true }), variant: "tertiary", type: "button" })));
|
|
52
52
|
};
|
|
53
53
|
exports.MonthCaption = MonthCaption;
|
|
54
54
|
exports.default = exports.MonthCaption;
|
|
@@ -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;
|
|
@@ -37,13 +37,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
const util_1 = require("../../../util");
|
|
41
|
-
const react_1 = __importStar(require("react"));
|
|
42
40
|
const clsx_1 = __importDefault(require("clsx"));
|
|
43
|
-
const
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const util_1 = require("../../../util");
|
|
43
|
+
const filtered_options_util_1 = __importDefault(require("../FilteredOptions/filtered-options-util"));
|
|
44
44
|
const filteredOptionsContext_1 = require("../FilteredOptions/filteredOptionsContext");
|
|
45
|
+
const selectedOptionsContext_1 = require("../SelectedOptions/selectedOptionsContext");
|
|
45
46
|
const inputContext_1 = require("./inputContext");
|
|
46
|
-
const filtered_options_util_1 = __importDefault(require("../FilteredOptions/filtered-options-util"));
|
|
47
47
|
const Input = (0, react_1.forwardRef)((_a, ref) => {
|
|
48
48
|
var { inputClassName } = _a, rest = __rest(_a, ["inputClassName"]);
|
|
49
49
|
const { clearInput, inputProps, onChange, size, value } = (0, inputContext_1.useInputContext)();
|
package/cjs/form/radio/Radio.js
CHANGED
|
@@ -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, {
|
|
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;
|
|
@@ -29,20 +29,20 @@ export const MonthCaption = () => {
|
|
|
29
29
|
const newYear = Number(year.getFullYear() + val);
|
|
30
30
|
toYear(setYear(year, newYear));
|
|
31
31
|
};
|
|
32
|
-
const
|
|
32
|
+
const disablePreviousYear = () => {
|
|
33
33
|
return fromDate
|
|
34
34
|
? isBefore((year === null || year === void 0 ? void 0 : year.getFullYear()) - 1, fromDate === null || fromDate === void 0 ? void 0 : fromDate.getFullYear())
|
|
35
|
-
:
|
|
35
|
+
: false;
|
|
36
36
|
};
|
|
37
|
-
const
|
|
37
|
+
const disableNextYear = () => {
|
|
38
38
|
return toDate
|
|
39
39
|
? isAfter((year === null || year === void 0 ? void 0 : year.getFullYear()) + 1, toDate === null || toDate === void 0 ? void 0 : toDate.getFullYear())
|
|
40
|
-
:
|
|
40
|
+
: false;
|
|
41
41
|
};
|
|
42
42
|
return (React.createElement("div", { className: "navds-date__caption" },
|
|
43
|
-
React.createElement(Button, { className: "navds-date__caption-button", disabled:
|
|
43
|
+
React.createElement(Button, { className: "navds-date__caption-button", disabled: disablePreviousYear(), onClick: () => handleButtonClick(-1), "aria-label": labelPrevYear(locale === null || locale === void 0 ? void 0 : locale.code), icon: React.createElement(ArrowLeftIcon, { "aria-hidden": true }), variant: "tertiary", type: "button" }),
|
|
44
44
|
hasDropdown ? (React.createElement(Select, { label: "velg \u00E5r", hideLabel: true, value: year === null || year === void 0 ? void 0 : year.getFullYear(), onChange: handleYearChange, className: "navds-date__caption__year" }, years.map((yearOpt) => (React.createElement("option", { key: yearOpt.getFullYear(), value: yearOpt.getFullYear() }, formatYearCaption(yearOpt, { locale })))))) : (React.createElement("span", { className: "navds-date__year-label", "aria-live": "polite" }, year.getFullYear())),
|
|
45
|
-
React.createElement(Button, { className: "navds-date__caption-button", disabled:
|
|
45
|
+
React.createElement(Button, { className: "navds-date__caption-button", disabled: disableNextYear(), onClick: () => handleButtonClick(1), "aria-label": labelNextYear(locale === null || locale === void 0 ? void 0 : locale.code), icon: React.createElement(ArrowRightIcon, { "aria-hidden": true }), variant: "tertiary", type: "button" })));
|
|
46
46
|
};
|
|
47
47
|
export default MonthCaption;
|
|
48
48
|
//# sourceMappingURL=MonthCaption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthCaption.js","sourceRoot":"","sources":["../../../src/date/monthpicker/MonthCaption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,OAA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N,MAAM,CAAE,IAAI,CAAC,EACvC,IAAI,EAAE,oBAAC,aAAa,0BAAe,EACnC,OAAO,EAAC,UAAU,EAClB,IAAI,EAAC,QAAQ,GACb;QAED,WAAW,CAAC,CAAC,CAAC,CACb,oBAAC,MAAM,IACL,KAAK,EAAC,cAAS,EACf,SAAS,QACT,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,EAAE,EAC1B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAC,2BAA2B,IAEpC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACtB,gCAAQ,GAAG,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE,IAC7D,iBAAiB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAChC,CACV,CAAC,CACK,CACV,CAAC,CAAC,CAAC,CACF,8BAAM,SAAS,EAAC,wBAAwB,eAAW,QAAQ,IACxD,IAAI,CAAC,WAAW,EAAE,CACd,CACR;QACD,oBAAC,MAAM,IACL,SAAS,EAAC,4BAA4B,EACtC,QAAQ,EAAE,eAAe,EAAE,EAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBACvB,aAAa,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,EACvC,IAAI,EAAE,oBAAC,cAAc,0BAAe,EACpC,OAAO,EAAC,UAAU,EAClB,IAAI,EAAC,QAAQ,GACb,CACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -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,EAT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E,QAAQ;aACrC,CACF;YAED,oBAAC,KAAK,IACJ,IAAI,EAAE,IAAI,EACV,EAAE,EAAC,QAAQ,EACX,SAAS,EAAE,EAAE,CAAC,wBAAwB,EAAE;oBACtC,eAAe,EAAE,CAAC,CAAC,UAAU;iBAC9B,CAAC;gBAEF,oBAAC,YAAY,IAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,GAAI;gBACnE,MAAM,CACD;YACP,CAAC,CAAC,WAAW,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,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
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,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAChC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACb,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,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ACD;QACF,+BAAO,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,SAAS,EAAC,uBAAuB;YAC9D,8BAAM,SAAS,EAAC,sBAAsB;gBACpC,6BACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,WAAW,EACjB,MAAM,EAAC,UAAU,EACjB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,KAAK,EAChB,IAAI,EAAC,KAAK;oBAGV,8BACE,CAAC,EAAC,6WAA6W,EAC/W,IAAI,EAAC,cAAc,GACnB,CACE,CACD;YACP,8BACE,SAAS,EAAE,EAAE,CAAC,yBAAyB,EAAE;oBACvC,eAAe,EAAE,KAAK,CAAC,SAAS;iBACjC,CAAC;gBAEF,oBAAC,SAAS,IACR,EAAE,EAAC,MAAM,EACT,EAAE,EAAE,OAAO,EACX,IAAI,EAAE,IAAI,EACV,SAAS,EAAC,4BAA4B;oBAGrC,CAAC,MAAM,IAAI,CACV,oBAAC,YAAY,IAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,GAAI,CAC5D;oBACA,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,8DAA8D,yBAGvE,KAAK,CAAC,WAAW,CACR,CACb,CACI,CACD,CACJ,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -9,13 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { omit } from "../../../util";
|
|
13
|
-
import React, { useCallback, forwardRef, } from "react";
|
|
14
12
|
import cl from "clsx";
|
|
15
|
-
import {
|
|
13
|
+
import React, { forwardRef, useCallback, } from "react";
|
|
14
|
+
import { omit } from "../../../util";
|
|
15
|
+
import filteredOptionsUtil from "../FilteredOptions/filtered-options-util";
|
|
16
16
|
import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext";
|
|
17
|
+
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
17
18
|
import { useInputContext } from "./inputContext";
|
|
18
|
-
import filteredOptionsUtil from "../FilteredOptions/filtered-options-util";
|
|
19
19
|
const Input = forwardRef((_a, ref) => {
|
|
20
20
|
var { inputClassName } = _a, rest = __rest(_a, ["inputClassName"]);
|
|
21
21
|
const { clearInput, inputProps, onChange, size, value } = useInputContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/form/combobox/Input/Input.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/form/combobox/Input/Input.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAGZ,UAAU,EACV,WAAW,GACZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,mBAAmB,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AASjD,MAAM,KAAK,GAAG,UAAU,CACtB,CAAC,EAA2B,EAAE,GAAG,EAAE,EAAE;QAApC,EAAE,cAAc,OAAW,EAAN,IAAI,cAAzB,kBAA2B,CAAF;IACxB,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,eAAe,EAAE,CAAC;IAC5E,MAAM,EACJ,eAAe,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K,CAAC,CAAC;IAClB,CAAC,EACD,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CACnE,CAAC;IAEF,OAAO,CACL,+CACM,IAAI,EACJ,IAAI,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,CAAC,IACtC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,mBACT,mBAAmB,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC,mBACvD,CAAC,CAAC,UAAU,EAC3B,YAAY,EAAC,KAAK,uBACC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,2BAChC,iBAAiB,sBACtB,eAAe,kBACnB,UAAU,CAAC,cAAc,CAAC,EACxC,SAAS,EAAE,EAAE,CACX,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,IAAI,EAAE,CAC5B,IACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/esm/form/radio/Radio.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
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 { 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, {
|
|
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,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
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,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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"}
|
package/esm/util/useId.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.5",
|
|
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.
|
|
42
|
-
"@navikt/ds-tokens": "^5.12.
|
|
41
|
+
"@navikt/aksel-icons": "^5.12.5",
|
|
42
|
+
"@navikt/ds-tokens": "^5.12.5",
|
|
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",
|
|
@@ -43,23 +43,23 @@ export const MonthCaption = () => {
|
|
|
43
43
|
toYear(setYear(year, newYear));
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const disablePreviousYear = () => {
|
|
47
47
|
return fromDate
|
|
48
48
|
? isBefore(year?.getFullYear() - 1, fromDate?.getFullYear())
|
|
49
|
-
:
|
|
49
|
+
: false;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const
|
|
52
|
+
const disableNextYear = () => {
|
|
53
53
|
return toDate
|
|
54
54
|
? isAfter(year?.getFullYear() + 1, toDate?.getFullYear())
|
|
55
|
-
:
|
|
55
|
+
: false;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
59
|
<div className="navds-date__caption">
|
|
60
60
|
<Button
|
|
61
61
|
className="navds-date__caption-button"
|
|
62
|
-
disabled={
|
|
62
|
+
disabled={disablePreviousYear()}
|
|
63
63
|
onClick={() => handleButtonClick(-1)}
|
|
64
64
|
aria-label={labelPrevYear(locale?.code)}
|
|
65
65
|
icon={<ArrowLeftIcon aria-hidden />}
|
|
@@ -88,7 +88,7 @@ export const MonthCaption = () => {
|
|
|
88
88
|
)}
|
|
89
89
|
<Button
|
|
90
90
|
className="navds-date__caption-button"
|
|
91
|
-
disabled={
|
|
91
|
+
disabled={disableNextYear()}
|
|
92
92
|
onClick={() => handleButtonClick(1)}
|
|
93
93
|
aria-label={labelNextYear(locale?.code)}
|
|
94
94
|
icon={<ArrowRightIcon aria-hidden />}
|
|
@@ -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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cl from "clsx";
|
|
2
2
|
import React, {
|
|
3
|
-
useCallback,
|
|
4
|
-
forwardRef,
|
|
5
|
-
InputHTMLAttributes,
|
|
6
3
|
ChangeEvent,
|
|
4
|
+
InputHTMLAttributes,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useCallback,
|
|
7
7
|
} from "react";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import { omit } from "../../../util";
|
|
9
|
+
import filteredOptionsUtil from "../FilteredOptions/filtered-options-util";
|
|
10
10
|
import { useFilteredOptionsContext } from "../FilteredOptions/filteredOptionsContext";
|
|
11
|
+
import { useSelectedOptionsContext } from "../SelectedOptions/selectedOptionsContext";
|
|
11
12
|
import { useInputContext } from "./inputContext";
|
|
12
|
-
import filteredOptionsUtil from "../FilteredOptions/filtered-options-util";
|
|
13
13
|
|
|
14
14
|
interface InputProps
|
|
15
15
|
extends Omit<InputHTMLAttributes<HTMLInputElement>, "value"> {
|
package/src/form/radio/Radio.tsx
CHANGED
|
@@ -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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
30
|
+
export function useId(idOverride?: string): string {
|
|
31
31
|
if (maybeReactUseId !== undefined) {
|
|
32
32
|
const reactId = maybeReactUseId();
|
|
33
33
|
return idOverride ?? reactId.replace(/(:)/g, "");
|