@ogcio/design-system-react 1.12.2 → 1.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.
@@ -1,85 +1,104 @@
1
1
  "use client";
2
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
3
- import { S as y } from "../../index-ntYL1VRC.js";
4
- import { createContext as N, Children as p, isValidElement as l, useContext as C } from "react";
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 v, useContext as L, isValidElement as C } from "react";
5
5
  import { cn as m } from "../../cn.js";
6
- import { ErrorText as v } from "../../error-text/error-text.js";
7
- import { HintText as L } from "../../hint-text/hint-text.js";
8
- import { Label as E } from "../../label/label.js";
9
- const f = N(null);
10
- function u(e) {
11
- C(f) || console.error(`[${e}] must be used within a <FormField>.`);
6
+ import { ErrorText as E } from "../../error-text/error-text.js";
7
+ import { HintText as N } from "../../hint-text/hint-text.js";
8
+ import { Label as T } from "../../label/label.js";
9
+ const c = x(null);
10
+ function s(e) {
11
+ L(c) || console.error(`[${e}] must be used within a <FormField>.`);
12
+ }
13
+ function a(e) {
14
+ var r, i;
15
+ return C(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 e === s || e === c || e === d;
18
+ return ["FormFieldLabel", "FormFieldHint", "FormFieldError"].includes(
19
+ a(e) ?? ""
20
+ );
15
21
  }
16
- const B = (e) => ["error", "hint", "label"].some((r) => r in e) ? (console.warn(
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__ */ i(f.Provider, { value: !0, children: /* @__PURE__ */ a(g, { children: [
19
- e.label && /* @__PURE__ */ i(s, { ...e.label }),
20
- e.hint && /* @__PURE__ */ i(c, { ...e.hint }),
21
- e.error && /* @__PURE__ */ i(d, { ...e.error }),
24
+ ), /* @__PURE__ */ o(c.Provider, { value: !0, children: /* @__PURE__ */ n(y, { ...e, 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__ */ i(f.Provider, { value: !0, children: /* @__PURE__ */ i(g, { children: e.children }) }), g = ({
29
+ ] }) })) : /* @__PURE__ */ o(c.Provider, { value: !0, children: /* @__PURE__ */ o(y, { ...e, children: e.children }) }), y = ({
24
30
  children: e,
25
- className: o,
26
- ...n
31
+ className: r,
32
+ ...i
27
33
  }) => {
28
- const r = p.toArray(e), F = r.find(
29
- (t) => l(t) && t.type === s
30
- ), h = r.find(
31
- (t) => l(t) && t.type === c
32
- ), b = r.find(
33
- (t) => l(t) && t.type === d
34
- ), x = r.filter(
35
- (t) => !l(t) || !H(t.type)
36
- );
37
- return /* @__PURE__ */ a(
34
+ const l = v.toArray(e), d = 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 }, o),
41
- ...n,
44
+ className: m({ "gi-error-state": !!b }, r),
45
+ ...i,
42
46
  children: [
43
- /* @__PURE__ */ a("div", { className: "gi-pb-3 gi-flex gi-flex-col gi-gap-1", children: [
44
- /* @__PURE__ */ a("div", { children: [
45
- F,
46
- h
47
+ /* @__PURE__ */ n("div", { className: "gi-pb-3 gi-flex gi-flex-col gi-gap-1", children: [
48
+ /* @__PURE__ */ n("div", { children: [
49
+ d,
50
+ p
47
51
  ] }),
48
52
  b
49
53
  ] }),
50
- /* @__PURE__ */ i(y, { children: x })
54
+ /* @__PURE__ */ o(g, { children: h })
51
55
  ]
52
56
  }
53
57
  );
54
- }, s = ({
58
+ }, F = ({
55
59
  children: e,
56
- text: o,
57
- size: n,
58
- htmlFor: r,
59
- className: F
60
- }) => (u("FormFieldLabel"), /* @__PURE__ */ i(
61
- E,
60
+ text: r,
61
+ size: i,
62
+ htmlFor: l,
63
+ className: d
64
+ }) => (s("FormFieldLabel"), /* @__PURE__ */ o(
65
+ T,
62
66
  {
63
- text: o,
64
- size: n,
65
- htmlFor: r,
66
- className: m("gi-font-bold", F),
67
+ text: r,
68
+ size: i,
69
+ htmlFor: l,
70
+ className: m("gi-font-bold", d),
67
71
  children: e
68
72
  }
69
73
  ));
70
- s.displayName = "FormFieldLabel";
71
- const c = ({ children: e, text: o, size: n, className: r }) => (u("FormFieldHint"), /* @__PURE__ */ i(L, { text: o, size: n, className: m("gi-mb-1", r), children: e }));
72
- c.displayName = "FormFieldHint";
73
- const d = ({
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 }) => (s("FormFieldHint"), /* @__PURE__ */ o(N, { 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: o,
76
- size: n,
77
- className: r
78
- }) => (u("FormFieldError"), /* @__PURE__ */ i(v, { text: o, size: n, className: m("gi-mb-1", r), children: e }));
79
- d.displayName = "FormFieldError";
89
+ text: r,
90
+ size: i,
91
+ className: l
92
+ }) => (s("FormFieldError"), /* @__PURE__ */ o(E, { 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
- B as FormField,
82
- d as FormFieldError,
83
- c as FormFieldHint,
84
- s as FormFieldLabel
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 { jsx as r, jsxs as d } from "react/jsx-runtime";
3
- import f from "react";
4
- import { ButtonGroup as k, ButtonGroupItem as y } from "../button-group/button-group.js";
5
- import { FormField as N } from "../forms/form-field/form-field.js";
6
- const G = ({
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: x,
10
+ label: F,
11
11
  hint: i,
12
12
  leftLabel: a,
13
- rightLabel: u,
13
+ rightLabel: r,
14
14
  onChange: c,
15
15
  type: I
16
16
  }) => {
17
- var o, n;
18
- const t = f.useId(), v = `${t}-label`, b = i ? `${t}-hint` : void 0;
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__ */ r(
61
- N,
62
- {
63
- className: "gi-w-full",
64
- label: { text: x, id: v },
65
- hint: i ? { text: i, id: b } : void 0,
66
- children: /* @__PURE__ */ d(
67
- "div",
68
- {
69
- className: "gi-score-select-button-group",
70
- role: "group",
71
- "aria-labelledby": v,
72
- "aria-describedby": b,
73
- children: [
74
- a && u && l.length > 2 && /* @__PURE__ */ d("div", { className: "gi-score-select-labels-responsive", "aria-hidden": "true", children: [
75
- /* @__PURE__ */ d("div", { children: [
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__ */ r(
87
- k,
88
- {
89
- name: p,
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
- G as ScoreSelect
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.2",
3
+ "version": "1.12.4",
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
- "@ogcio/theme-doete": "1.0.0",
55
56
  "@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-doete": "1.0.0"
58
58
  },
59
59
  "scripts": {
60
60
  "format": "prettier 'src/**/*.{ts,tsx}' --write",