@ogcio/design-system-react 1.12.2 → 1.12.3
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.
|
@@ -1,85 +1,104 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { S as
|
|
4
|
-
import { createContext as
|
|
2
|
+
import { jsx as o, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
import { S as g } from "../../index-ntYL1VRC.js";
|
|
4
|
+
import { createContext as x, Children as N, useContext as v, isValidElement as L } from "react";
|
|
5
5
|
import { cn as m } from "../../cn.js";
|
|
6
|
-
import { ErrorText as
|
|
7
|
-
import { HintText as
|
|
8
|
-
import { Label as
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
|
|
6
|
+
import { ErrorText as C } from "../../error-text/error-text.js";
|
|
7
|
+
import { HintText as E } from "../../hint-text/hint-text.js";
|
|
8
|
+
import { Label as T } from "../../label/label.js";
|
|
9
|
+
const c = x(null);
|
|
10
|
+
function d(e) {
|
|
11
|
+
v(c) || console.error(`[${e}] must be used within a <FormField>.`);
|
|
12
|
+
}
|
|
13
|
+
function a(e) {
|
|
14
|
+
var r, i;
|
|
15
|
+
return L(e) && (((r = e.type) == null ? void 0 : r.componentType) || ((i = e.props) == null ? void 0 : i.__mdxType)) || null;
|
|
12
16
|
}
|
|
13
17
|
function H(e) {
|
|
14
|
-
return
|
|
18
|
+
return ["FormFieldLabel", "FormFieldHint", "FormFieldError"].includes(
|
|
19
|
+
a(e) ?? ""
|
|
20
|
+
);
|
|
15
21
|
}
|
|
16
|
-
const
|
|
22
|
+
const _ = (e) => ["error", "hint", "label"].some((l) => l in e) ? (console.warn(
|
|
17
23
|
"[FormField] Using legacy props. Please migrate to the new composable API."
|
|
18
|
-
), /* @__PURE__ */
|
|
19
|
-
e.label && /* @__PURE__ */
|
|
20
|
-
e.hint && /* @__PURE__ */
|
|
21
|
-
e.error && /* @__PURE__ */
|
|
24
|
+
), /* @__PURE__ */ o(c.Provider, { value: !0, children: /* @__PURE__ */ n(y, { className: e.className, children: [
|
|
25
|
+
e.label && /* @__PURE__ */ o(F, { ...e.label }),
|
|
26
|
+
e.hint && /* @__PURE__ */ o(u, { ...e.hint }),
|
|
27
|
+
e.error && /* @__PURE__ */ o(f, { ...e.error }),
|
|
22
28
|
e.children
|
|
23
|
-
] }) })) : /* @__PURE__ */
|
|
29
|
+
] }) })) : /* @__PURE__ */ o(c.Provider, { value: !0, children: /* @__PURE__ */ o(y, { className: e.className, children: e.children }) }), y = ({
|
|
24
30
|
children: e,
|
|
25
|
-
className:
|
|
26
|
-
...
|
|
31
|
+
className: r,
|
|
32
|
+
...i
|
|
27
33
|
}) => {
|
|
28
|
-
const
|
|
29
|
-
(t) =>
|
|
30
|
-
),
|
|
31
|
-
(t) =>
|
|
32
|
-
), b =
|
|
33
|
-
(t) =>
|
|
34
|
-
),
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
return /* @__PURE__ */ a(
|
|
34
|
+
const l = N.toArray(e), s = l.find(
|
|
35
|
+
(t) => a(t) === "FormFieldLabel"
|
|
36
|
+
), p = l.find(
|
|
37
|
+
(t) => a(t) === "FormFieldHint"
|
|
38
|
+
), b = l.find(
|
|
39
|
+
(t) => a(t) === "FormFieldError"
|
|
40
|
+
), h = l.filter((t) => !H(t));
|
|
41
|
+
return /* @__PURE__ */ n(
|
|
38
42
|
"fieldset",
|
|
39
43
|
{
|
|
40
|
-
className: m({ "gi-error-state": !!b },
|
|
41
|
-
...
|
|
44
|
+
className: m({ "gi-error-state": !!b }, r),
|
|
45
|
+
...i,
|
|
42
46
|
children: [
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
/* @__PURE__ */ n("div", { className: "gi-pb-3 gi-flex gi-flex-col gi-gap-1", children: [
|
|
48
|
+
/* @__PURE__ */ n("div", { children: [
|
|
49
|
+
s,
|
|
50
|
+
p
|
|
47
51
|
] }),
|
|
48
52
|
b
|
|
49
53
|
] }),
|
|
50
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ o(g, { children: h })
|
|
51
55
|
]
|
|
52
56
|
}
|
|
53
57
|
);
|
|
54
|
-
},
|
|
58
|
+
}, F = ({
|
|
55
59
|
children: e,
|
|
56
|
-
text:
|
|
57
|
-
size:
|
|
58
|
-
htmlFor:
|
|
59
|
-
className:
|
|
60
|
-
}) => (
|
|
61
|
-
|
|
60
|
+
text: r,
|
|
61
|
+
size: i,
|
|
62
|
+
htmlFor: l,
|
|
63
|
+
className: s
|
|
64
|
+
}) => (d("FormFieldLabel"), /* @__PURE__ */ o(
|
|
65
|
+
T,
|
|
62
66
|
{
|
|
63
|
-
text:
|
|
64
|
-
size:
|
|
65
|
-
htmlFor:
|
|
66
|
-
className: m("gi-font-bold",
|
|
67
|
+
text: r,
|
|
68
|
+
size: i,
|
|
69
|
+
htmlFor: l,
|
|
70
|
+
className: m("gi-font-bold", s),
|
|
67
71
|
children: e
|
|
68
72
|
}
|
|
69
73
|
));
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
Object.defineProperty(F, "componentType", {
|
|
75
|
+
value: "FormFieldLabel",
|
|
76
|
+
writable: !1,
|
|
77
|
+
enumerable: !1
|
|
78
|
+
});
|
|
79
|
+
F.displayName = "FormFieldLabel";
|
|
80
|
+
const u = ({ children: e, text: r, size: i, className: l }) => (d("FormFieldHint"), /* @__PURE__ */ o(E, { text: r, size: i, className: m("gi-mb-1", l), children: e }));
|
|
81
|
+
Object.defineProperty(u, "componentType", {
|
|
82
|
+
value: "FormFieldHint",
|
|
83
|
+
writable: !1,
|
|
84
|
+
enumerable: !1
|
|
85
|
+
});
|
|
86
|
+
u.displayName = "FormFieldHint";
|
|
87
|
+
const f = ({
|
|
74
88
|
children: e,
|
|
75
|
-
text:
|
|
76
|
-
size:
|
|
77
|
-
className:
|
|
78
|
-
}) => (
|
|
79
|
-
|
|
89
|
+
text: r,
|
|
90
|
+
size: i,
|
|
91
|
+
className: l
|
|
92
|
+
}) => (d("FormFieldError"), /* @__PURE__ */ o(C, { text: r, size: i, className: m("gi-mb-1", l), children: e }));
|
|
93
|
+
Object.defineProperty(f, "componentType", {
|
|
94
|
+
value: "FormFieldError",
|
|
95
|
+
writable: !1,
|
|
96
|
+
enumerable: !1
|
|
97
|
+
});
|
|
98
|
+
f.displayName = "FormFieldError";
|
|
80
99
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
_ as FormField,
|
|
101
|
+
f as FormFieldError,
|
|
102
|
+
u as FormFieldHint,
|
|
103
|
+
F as FormFieldLabel
|
|
85
104
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { ButtonGroup as
|
|
5
|
-
import { FormField as
|
|
6
|
-
const
|
|
2
|
+
import { jsxs as u, jsx as d } from "react/jsx-runtime";
|
|
3
|
+
import k from "react";
|
|
4
|
+
import { ButtonGroup as y, ButtonGroupItem as N } from "../button-group/button-group.js";
|
|
5
|
+
import { FormField as f, FormFieldLabel as x, FormFieldHint as j } from "../forms/form-field/form-field.js";
|
|
6
|
+
const _ = ({
|
|
7
7
|
name: p,
|
|
8
8
|
size: $ = "medium",
|
|
9
9
|
value: s,
|
|
10
|
-
label:
|
|
10
|
+
label: F,
|
|
11
11
|
hint: i,
|
|
12
12
|
leftLabel: a,
|
|
13
|
-
rightLabel:
|
|
13
|
+
rightLabel: r,
|
|
14
14
|
onChange: c,
|
|
15
15
|
type: I
|
|
16
16
|
}) => {
|
|
17
|
-
var
|
|
18
|
-
const
|
|
17
|
+
var m, t;
|
|
18
|
+
const o = k.useId(), v = `${o}-label`, b = i ? `${o}-hint` : void 0;
|
|
19
19
|
let l = [];
|
|
20
20
|
switch (I) {
|
|
21
21
|
case "1-5": {
|
|
@@ -57,68 +57,64 @@ const G = ({
|
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"aria-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
(o = l[0]) == null ? void 0 : o.label,
|
|
77
|
-
" – ",
|
|
78
|
-
a
|
|
79
|
-
] }),
|
|
80
|
-
/* @__PURE__ */ d("div", { children: [
|
|
81
|
-
(n = l.at(-1)) == null ? void 0 : n.label,
|
|
82
|
-
" – ",
|
|
83
|
-
u
|
|
84
|
-
] })
|
|
60
|
+
return /* @__PURE__ */ u(f, { className: "gi-w-full", children: [
|
|
61
|
+
/* @__PURE__ */ d(x, { id: v, children: F }),
|
|
62
|
+
i && /* @__PURE__ */ d(j, { id: b, children: i }),
|
|
63
|
+
/* @__PURE__ */ u(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
className: "gi-score-select-button-group",
|
|
67
|
+
role: "group",
|
|
68
|
+
"aria-labelledby": v,
|
|
69
|
+
"aria-describedby": b,
|
|
70
|
+
children: [
|
|
71
|
+
a && r && l.length > 2 && /* @__PURE__ */ u("div", { className: "gi-score-select-labels-responsive", "aria-hidden": "true", children: [
|
|
72
|
+
/* @__PURE__ */ u("div", { children: [
|
|
73
|
+
(m = l[0]) == null ? void 0 : m.label,
|
|
74
|
+
" – ",
|
|
75
|
+
a
|
|
85
76
|
] }),
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
size: $,
|
|
91
|
-
defaultValue: s,
|
|
92
|
-
onChange: (e) => c == null ? void 0 : c(e),
|
|
93
|
-
role: "radiogroup",
|
|
94
|
-
"aria-labelledby": v,
|
|
95
|
-
"aria-describedby": b,
|
|
96
|
-
children: l.map((e) => {
|
|
97
|
-
var m, h;
|
|
98
|
-
return /* @__PURE__ */ r(
|
|
99
|
-
y,
|
|
100
|
-
{
|
|
101
|
-
value: e.value,
|
|
102
|
-
role: "radio",
|
|
103
|
-
"aria-checked": s === e.value,
|
|
104
|
-
"aria-label": `${e.label}${a && e.value === ((m = l[0]) == null ? void 0 : m.value) ? ` - ${a}` : ""}${u && e.value === ((h = l.at(-1)) == null ? void 0 : h.value) ? ` - ${u}` : ""}`,
|
|
105
|
-
children: e.label
|
|
106
|
-
},
|
|
107
|
-
e.value
|
|
108
|
-
);
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
),
|
|
112
|
-
(a || u) && /* @__PURE__ */ d("div", { className: "gi-score-select-labels", "aria-hidden": "true", children: [
|
|
113
|
-
/* @__PURE__ */ r("div", { children: a }),
|
|
114
|
-
/* @__PURE__ */ r("div", { children: u })
|
|
77
|
+
/* @__PURE__ */ u("div", { children: [
|
|
78
|
+
(t = l.at(-1)) == null ? void 0 : t.label,
|
|
79
|
+
" – ",
|
|
80
|
+
r
|
|
115
81
|
] })
|
|
116
|
-
]
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ d(
|
|
84
|
+
y,
|
|
85
|
+
{
|
|
86
|
+
name: p,
|
|
87
|
+
size: $,
|
|
88
|
+
defaultValue: s,
|
|
89
|
+
onChange: (e) => c == null ? void 0 : c(e),
|
|
90
|
+
role: "radiogroup",
|
|
91
|
+
"aria-labelledby": v,
|
|
92
|
+
"aria-describedby": b,
|
|
93
|
+
children: l.map((e) => {
|
|
94
|
+
var n, h;
|
|
95
|
+
return /* @__PURE__ */ d(
|
|
96
|
+
N,
|
|
97
|
+
{
|
|
98
|
+
value: e.value,
|
|
99
|
+
role: "radio",
|
|
100
|
+
"aria-checked": s === e.value,
|
|
101
|
+
"aria-label": `${e.label}${a && e.value === ((n = l[0]) == null ? void 0 : n.value) ? ` - ${a}` : ""}${r && e.value === ((h = l.at(-1)) == null ? void 0 : h.value) ? ` - ${r}` : ""}`,
|
|
102
|
+
children: e.label
|
|
103
|
+
},
|
|
104
|
+
e.value
|
|
105
|
+
);
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
(a || r) && /* @__PURE__ */ u("div", { className: "gi-score-select-labels", "aria-hidden": "true", children: [
|
|
110
|
+
/* @__PURE__ */ d("div", { children: a }),
|
|
111
|
+
/* @__PURE__ */ d("div", { children: r })
|
|
112
|
+
] })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] });
|
|
121
117
|
};
|
|
122
118
|
export {
|
|
123
|
-
|
|
119
|
+
_ as ScoreSelect
|
|
124
120
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogcio/design-system-react",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.3",
|
|
4
4
|
"description": "The GOV IE design system React components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"postcss-import": "^16.1.0",
|
|
51
51
|
"react": "19.0.0",
|
|
52
52
|
"react-dom": "19.0.0",
|
|
53
|
+
"@ogcio/design-system-eslint-config": "1.2.5",
|
|
54
|
+
"@ogcio/design-system-prettier-config": "1.0.5",
|
|
53
55
|
"@ogcio/design-system-tailwind": "1.11.0",
|
|
54
56
|
"@ogcio/theme-doete": "1.0.0",
|
|
55
|
-
"@ogcio/theme-govie": "1.5.3"
|
|
56
|
-
"@ogcio/design-system-prettier-config": "1.0.5",
|
|
57
|
-
"@ogcio/design-system-eslint-config": "1.2.5"
|
|
57
|
+
"@ogcio/theme-govie": "1.5.3"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"format": "prettier 'src/**/*.{ts,tsx}' --write",
|