@obosbbl/grunnmuren-react 1.8.0 → 1.9.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.
- package/dist/Radio/RadioContext.d.ts +1 -0
- package/dist/Radio/RadioGroup.d.ts +2 -0
- package/dist/grunnmuren.es.js +27 -10
- package/package.json +10 -10
|
@@ -4,6 +4,8 @@ export interface RadioGroupProps extends Omit<React.ComponentPropsWithoutRef<'di
|
|
|
4
4
|
defaultValue?: string;
|
|
5
5
|
/** Help text for the radio group. */
|
|
6
6
|
description?: React.ReactNode;
|
|
7
|
+
/** Error message for the form control */
|
|
8
|
+
error?: string;
|
|
7
9
|
/** The `name` attribute for the radio buttons. */
|
|
8
10
|
name: string;
|
|
9
11
|
/** The label for the radio group. */
|
package/dist/grunnmuren.es.js
CHANGED
|
@@ -1314,7 +1314,8 @@ const RadioContext = createContext({
|
|
|
1314
1314
|
name: void 0,
|
|
1315
1315
|
onChange: noop,
|
|
1316
1316
|
required: false,
|
|
1317
|
-
value: void 0
|
|
1317
|
+
value: void 0,
|
|
1318
|
+
error: false
|
|
1318
1319
|
});
|
|
1319
1320
|
const Radio = forwardRef((props, ref) => {
|
|
1320
1321
|
const _a = props, {
|
|
@@ -1330,12 +1331,13 @@ const Radio = forwardRef((props, ref) => {
|
|
|
1330
1331
|
name,
|
|
1331
1332
|
onChange,
|
|
1332
1333
|
required,
|
|
1333
|
-
value
|
|
1334
|
+
value,
|
|
1335
|
+
error
|
|
1334
1336
|
} = useContext(RadioContext);
|
|
1335
1337
|
return /* @__PURE__ */ jsxs("label", {
|
|
1336
1338
|
className: cx(className, "flex cursor-pointer gap-2.5"),
|
|
1337
1339
|
children: [/* @__PURE__ */ jsx("input", __spreadValues({
|
|
1338
|
-
className: "radio",
|
|
1340
|
+
className: cx("radio", error && "border-red"),
|
|
1339
1341
|
defaultChecked: !isControlled ? rest.value === defaultValue : void 0,
|
|
1340
1342
|
checked: isControlled ? rest.value === value : void 0,
|
|
1341
1343
|
name,
|
|
@@ -1352,6 +1354,8 @@ const RadioGroup = forwardRef((props, ref) => {
|
|
|
1352
1354
|
className,
|
|
1353
1355
|
defaultValue,
|
|
1354
1356
|
description,
|
|
1357
|
+
error,
|
|
1358
|
+
id: idProp,
|
|
1355
1359
|
children,
|
|
1356
1360
|
label,
|
|
1357
1361
|
name,
|
|
@@ -1362,6 +1366,8 @@ const RadioGroup = forwardRef((props, ref) => {
|
|
|
1362
1366
|
"className",
|
|
1363
1367
|
"defaultValue",
|
|
1364
1368
|
"description",
|
|
1369
|
+
"error",
|
|
1370
|
+
"id",
|
|
1365
1371
|
"children",
|
|
1366
1372
|
"label",
|
|
1367
1373
|
"name",
|
|
@@ -1379,15 +1385,22 @@ const RadioGroup = forwardRef((props, ref) => {
|
|
|
1379
1385
|
name,
|
|
1380
1386
|
onChange,
|
|
1381
1387
|
required,
|
|
1382
|
-
value
|
|
1383
|
-
|
|
1384
|
-
|
|
1388
|
+
value,
|
|
1389
|
+
error: Boolean(error)
|
|
1390
|
+
}), [defaultValue, isControlled, name, onChange, required, value, error]);
|
|
1391
|
+
const groupId = useFallbackId(idProp);
|
|
1385
1392
|
const labelId = `${groupId}:label`;
|
|
1386
|
-
const
|
|
1393
|
+
const helpTextId = `${groupId}:help`;
|
|
1394
|
+
const errorMsgId = groupId + "err";
|
|
1395
|
+
const errorMsg = error;
|
|
1387
1396
|
return /* @__PURE__ */ jsx(RadioContext.Provider, {
|
|
1388
1397
|
value: group,
|
|
1389
1398
|
children: /* @__PURE__ */ jsxs("div", __spreadProps(__spreadValues({
|
|
1390
|
-
"aria-describedby":
|
|
1399
|
+
"aria-describedby": cx({
|
|
1400
|
+
[errorMsgId]: errorMsg,
|
|
1401
|
+
[helpTextId]: description
|
|
1402
|
+
}) || void 0,
|
|
1403
|
+
"aria-invalid": !!error,
|
|
1391
1404
|
"aria-labelledby": label ? labelId : void 0,
|
|
1392
1405
|
className: cx(className, "flex flex-col gap-4"),
|
|
1393
1406
|
role: "radiogroup",
|
|
@@ -1396,10 +1409,14 @@ const RadioGroup = forwardRef((props, ref) => {
|
|
|
1396
1409
|
children: [label && /* @__PURE__ */ jsx(FormLabel, {
|
|
1397
1410
|
id: labelId,
|
|
1398
1411
|
isRequired: required,
|
|
1412
|
+
isInvalid: !!error,
|
|
1399
1413
|
children: label
|
|
1400
|
-
}),
|
|
1401
|
-
id:
|
|
1414
|
+
}), description && /* @__PURE__ */ jsx(FormHelperText, {
|
|
1415
|
+
id: helpTextId,
|
|
1402
1416
|
children: description
|
|
1417
|
+
}), children, errorMsg && /* @__PURE__ */ jsx(FormErrorMessage, {
|
|
1418
|
+
id: errorMsgId,
|
|
1419
|
+
children: errorMsg
|
|
1403
1420
|
})]
|
|
1404
1421
|
}))
|
|
1405
1422
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obosbbl/grunnmuren-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "OBOS Grunnmuren design system React components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,23 +17,23 @@
|
|
|
17
17
|
],
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@babel/core": "7.20.
|
|
21
|
-
"@storybook/addon-controls": "6.5.
|
|
22
|
-
"@storybook/addon-docs": "6.5.
|
|
20
|
+
"@babel/core": "7.20.7",
|
|
21
|
+
"@storybook/addon-controls": "6.5.15",
|
|
22
|
+
"@storybook/addon-docs": "6.5.15",
|
|
23
23
|
"@storybook/addon-postcss": "2.0.0",
|
|
24
|
-
"@storybook/builder-webpack5": "6.5.
|
|
25
|
-
"@storybook/manager-webpack5": "6.5.
|
|
26
|
-
"@storybook/react": "6.5.
|
|
24
|
+
"@storybook/builder-webpack5": "6.5.15",
|
|
25
|
+
"@storybook/manager-webpack5": "6.5.15",
|
|
26
|
+
"@storybook/react": "6.5.15",
|
|
27
27
|
"@types/react": "18.0.26",
|
|
28
|
-
"@types/react-dom": "18.0.
|
|
28
|
+
"@types/react-dom": "18.0.10",
|
|
29
29
|
"@vitejs/plugin-react": "1.3.2",
|
|
30
|
-
"postcss": "8.4.
|
|
30
|
+
"postcss": "8.4.20",
|
|
31
31
|
"react": "18.2.0",
|
|
32
32
|
"react-dom": "18.2.0",
|
|
33
33
|
"require-from-string": "2.0.2",
|
|
34
34
|
"rimraf": "3.0.2",
|
|
35
35
|
"tailwindcss": "3.2.4",
|
|
36
|
-
"type-fest": "3.
|
|
36
|
+
"type-fest": "3.5.0",
|
|
37
37
|
"vite": "2.9.15",
|
|
38
38
|
"webpack": "5.75.0",
|
|
39
39
|
"@obosbbl/grunnmuren-tailwind": "0.8.4"
|