@ogcio/design-system-react 1.20.0 → 1.22.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.
Files changed (58) hide show
  1. package/dist/alert/alert.d.ts +3 -90
  2. package/dist/alert/alert.js +43 -74
  3. package/dist/alert/types.d.ts +11 -0
  4. package/dist/alert/types.js +1 -0
  5. package/dist/alert/variants.d.ts +76 -0
  6. package/dist/alert/variants.js +36 -0
  7. package/dist/autocomplete/autocomplete.js +105 -97
  8. package/dist/card/card-legacy.d.ts +1 -1
  9. package/dist/card/card-legacy.js +12 -12
  10. package/dist/card/card-next.d.ts +2 -3
  11. package/dist/card/card-next.js +226 -61
  12. package/dist/card/card.js +17 -16
  13. package/dist/card/types.d.ts +20 -30
  14. package/dist/checkbox/types.d.ts +0 -1
  15. package/dist/drawer/drawer.d.ts +2 -3
  16. package/dist/drawer/drawer.js +59 -36
  17. package/dist/forms/form-field/form-field.d.ts +2 -3
  18. package/dist/forms/form-field/form-field.js +69 -60
  19. package/dist/forms/form-field/types.d.ts +3 -0
  20. package/dist/index.d.ts +4 -3
  21. package/dist/index.js +235 -228
  22. package/dist/input-checkbox/input-checkbox.d.ts +1 -1
  23. package/dist/input-checkbox/input-checkbox.js +33 -35
  24. package/dist/input-checkbox/types.d.ts +0 -1
  25. package/dist/input-checkbox/types.js +2 -3
  26. package/dist/input-radio/input-radio.d.ts +1 -1
  27. package/dist/input-radio/input-radio.js +39 -40
  28. package/dist/input-radio/types.d.ts +0 -1
  29. package/dist/input-radio/types.js +0 -1
  30. package/dist/link/link.d.ts +2 -2
  31. package/dist/link/link.js +18 -19
  32. package/dist/modal/modal.js +158 -178
  33. package/dist/radio/types.d.ts +0 -1
  34. package/dist/select/select-next.js +151 -144
  35. package/dist/styles.css +1 -1
  36. package/dist/summary-list/index.d.ts +6 -0
  37. package/dist/summary-list/index.js +12 -0
  38. package/dist/summary-list/summary-list-action.d.ts +5 -0
  39. package/dist/summary-list/summary-list-action.js +18 -0
  40. package/dist/summary-list/summary-list-context.d.ts +2 -0
  41. package/dist/summary-list/summary-list-context.js +20 -0
  42. package/dist/summary-list/summary-list-header.d.ts +5 -0
  43. package/dist/summary-list/summary-list-header.js +68 -0
  44. package/dist/summary-list/summary-list-row.d.ts +6 -0
  45. package/dist/summary-list/summary-list-row.js +63 -0
  46. package/dist/summary-list/summary-list-value.d.ts +5 -0
  47. package/dist/summary-list/summary-list-value.js +17 -0
  48. package/dist/summary-list/summary-list.d.ts +2 -11
  49. package/dist/summary-list/summary-list.js +37 -43
  50. package/dist/summary-list/types.d.ts +15 -11
  51. package/dist/toast/ds-toast.d.ts +1 -1
  52. package/dist/toast/ds-toast.js +29 -40
  53. package/dist/toast/toast.d.ts +1 -1
  54. package/dist/toast/toast.js +65 -57
  55. package/dist/toast/types.d.ts +3 -2
  56. package/dist/utilities.d.ts +3 -0
  57. package/dist/utilities.js +17 -7
  58. package/package.json +2 -2
@@ -1,159 +1,166 @@
1
1
  "use client";
2
2
  import "@ogcio/design-system-react/browser-check";
3
- import { jsx as l, jsxs as V } from "react/jsx-runtime";
4
- import { forwardRef as W, useRef as b, useState as w, useImperativeHandle as X, Children as k, isValidElement as E, useEffect as M } from "react";
5
- import { cn as H } from "../cn.js";
6
- import { translate as Y } from "../i18n/utility.js";
7
- import { InputText as Z } from "../input-text/input-text.js";
8
- import { Popover as _ } from "../popover/popover.js";
9
- import { SelectMenu as B, SelectMenuOption as K, SelectMenuGroupItem as ee } from "./select-menu.js";
10
- import { SelectSearch as te } from "./select-search.js";
11
- const ne = W(
3
+ import { jsxs as q, jsx as s } from "react/jsx-runtime";
4
+ import { forwardRef as Z, useRef as v, useState as E, useImperativeHandle as _, Children as R, isValidElement as G, useEffect as P } from "react";
5
+ import { cn as D } from "../cn.js";
6
+ import { useDomId as B } from "../hooks/use-dom-id.js";
7
+ import { translate as z } from "../i18n/utility.js";
8
+ import { InputText as ee } from "../input-text/input-text.js";
9
+ import { Popover as te } from "../popover/popover.js";
10
+ import { SelectMenu as re, SelectMenuOption as F, SelectMenuGroupItem as ne } from "./select-menu.js";
11
+ import { SelectSearch as oe } from "./select-search.js";
12
+ const se = Z(
12
13
  ({
13
14
  children: S,
14
15
  value: p,
15
- defaultValue: I = "",
16
- onChange: d,
16
+ defaultValue: T = "",
17
+ onChange: b,
17
18
  onMenuClose: g,
18
- enableSearch: v,
19
- disabled: n,
20
- name: a,
21
- onBlur: i,
22
- placeholder: R,
23
- ...h
24
- }, z) => {
25
- const u = b(null), N = b(null), G = b(null), P = b(!1), [r, $] = w(
26
- I || p
27
- ), [F, T] = w(!1), [J, j] = w("");
28
- X(z, () => u.current);
29
- const O = k.toArray(S).filter(
30
- (e) => E(e)
19
+ enableSearch: d,
20
+ disabled: r,
21
+ name: i,
22
+ onBlur: u,
23
+ placeholder: $,
24
+ ...x
25
+ }, Q) => {
26
+ const c = v(null), O = v(null), j = v(null), A = v(!1), [n, M] = E(
27
+ T || p
28
+ ), [H, h] = E(!1), [U, K] = E("");
29
+ _(Q, () => c.current);
30
+ const k = R.toArray(S).filter(
31
+ (e) => G(e)
31
32
  );
32
- M(() => {
33
- var c, s;
33
+ P(() => {
34
+ var l, a;
34
35
  let e;
35
- for (const o of O) {
36
- const t = (c = o.type) == null ? void 0 : c.componentType;
36
+ for (const o of k) {
37
+ const t = (l = o.type) == null ? void 0 : l.componentType;
37
38
  if (t === "SelectItemNext") {
38
39
  const f = o;
39
- if (f.props.value === r) {
40
+ if (f.props.value === n) {
40
41
  e = f;
41
42
  break;
42
43
  }
43
44
  }
44
45
  if (t === "SelectGroupItemNext") {
45
- const f = o, m = k.toArray(f.props.children).find(
46
+ const f = o, m = R.toArray(f.props.children).find(
46
47
  (y) => {
47
- var D;
48
- return ((D = y == null ? void 0 : y.type) == null ? void 0 : D.componentType) === "SelectItemNext" && y.props.value === r;
48
+ var V;
49
+ return ((V = y == null ? void 0 : y.type) == null ? void 0 : V.componentType) === "SelectItemNext" && y.props.value === n;
49
50
  }
50
51
  );
51
- if (m && E(m)) {
52
+ if (m && G(m)) {
52
53
  e = m;
53
54
  break;
54
55
  }
55
56
  }
56
57
  }
57
58
  if (e) {
58
- const o = ((s = e.props.children) == null ? void 0 : s.toString()) || "";
59
- j(o);
59
+ const o = ((a = e.props.children) == null ? void 0 : a.toString()) || "";
60
+ K(o);
60
61
  } else
61
- j(""), u.current && (u.current.value = "");
62
- }, [r, O]), M(() => {
63
- p !== void 0 && $(p);
62
+ K(""), c.current && (c.current.value = "");
63
+ }, [n, k]), P(() => {
64
+ p !== void 0 && M(p);
64
65
  }, [p]);
65
- const C = () => {
66
+ const w = () => {
66
67
  var e;
67
- T(!0), (e = u.current) == null || e.focus();
68
+ h(!0), (e = c.current) == null || e.focus();
69
+ }, W = (e) => {
70
+ h(e), g && !e && g();
68
71
  }, L = (e) => {
69
- T(e), g && !e && g();
70
- }, A = (e) => {
71
- if (T(!1), $(e), d && (d({
72
- target: { name: a, value: e },
73
- currentTarget: { name: a, value: e },
72
+ if (h(!1), M(e), b && (b({
73
+ target: { name: i, value: e },
74
+ currentTarget: { name: i, value: e },
74
75
  type: "change",
75
76
  bubbles: !0
76
- }), i)) {
77
- const s = {
78
- target: { name: a, value: e },
79
- currentTarget: { name: a, value: e },
77
+ }), u)) {
78
+ const a = {
79
+ target: { name: i, value: e },
80
+ currentTarget: { name: i, value: e },
80
81
  type: "blur",
81
82
  bubbles: !0
82
83
  };
83
- i == null || i(s);
84
+ u == null || u(a);
84
85
  }
85
- }, Q = (e) => {
86
- e.key === "Enter" && !n && C();
87
- }, U = (e) => {
88
- var s, o;
89
- const c = e.relatedTarget;
90
- if (c && ((s = G.current) != null && s.contains(c) || (o = N.current) != null && o.contains(c)) || P.current) {
91
- setTimeout(() => P.current = !1, 0);
86
+ }, X = (e) => {
87
+ !r && (e.key === "Enter" || e.key === "NumpadEnter") ? (e.preventDefault(), w()) : e.key === "Escape" && h(!1);
88
+ }, Y = (e) => {
89
+ var a, o;
90
+ const l = e.relatedTarget;
91
+ if (l && ((a = j.current) != null && a.contains(l) || (o = O.current) != null && o.contains(l)) || A.current) {
92
+ setTimeout(() => A.current = !1, 0);
92
93
  return;
93
94
  }
94
- if (i) {
95
- const t = p ?? r ?? "";
96
- i({
97
- target: { name: a, value: t },
98
- currentTarget: { name: a, value: t },
95
+ if (u) {
96
+ const t = p ?? n ?? "";
97
+ u({
98
+ target: { name: i, value: t },
99
+ currentTarget: { name: i, value: t },
99
100
  type: "blur",
100
101
  bubbles: !0
101
102
  });
102
103
  }
103
- };
104
- return v ? /* @__PURE__ */ l(
105
- te,
106
- {
107
- ...h,
108
- value: r,
109
- onChange: d,
110
- disabled: n,
111
- ref: u,
112
- onBlur: i,
113
- name: a,
114
- placeholder: R,
115
- children: S
116
- }
117
- ) : /* @__PURE__ */ V(
104
+ }, I = B(), C = x["aria-label"] ?? z("select.next.placeholder", { defaultValue: "Select" });
105
+ return P(() => {
106
+ c.current && c.current.setAttribute("aria-labelledby", I);
107
+ }, [I, d]), d ? /* @__PURE__ */ q("div", { className: D("gi-select-next", x.className), children: [
108
+ /* @__PURE__ */ s("span", { id: I, className: "gi-sr-only", children: C }),
109
+ /* @__PURE__ */ s(
110
+ oe,
111
+ {
112
+ ...x,
113
+ value: n,
114
+ onChange: b,
115
+ disabled: r,
116
+ ref: c,
117
+ onBlur: u,
118
+ name: i,
119
+ placeholder: $,
120
+ children: S
121
+ }
122
+ )
123
+ ] }) : /* @__PURE__ */ q(
118
124
  "div",
119
125
  {
120
- "aria-disabled": n,
121
- className: H("gi-select-next", h.className),
126
+ "aria-disabled": r,
127
+ className: D("gi-select-next", x.className),
122
128
  children: [
123
- /* @__PURE__ */ l(
124
- Z,
129
+ /* @__PURE__ */ s("span", { id: I, className: "gi-sr-only", children: C }),
130
+ /* @__PURE__ */ s(
131
+ ee,
125
132
  {
126
- ...h,
133
+ ...x,
127
134
  autoComplete: "off",
128
- "aria-label": "Select an option",
129
- "aria-disabled": n,
130
- disabled: n,
131
- placeholder: R ?? Y("select.next.placeholder", { defaultValue: "Search" }),
135
+ "aria-label": C,
136
+ "aria-disabled": r,
137
+ disabled: r,
138
+ placeholder: $ ?? z("select.next.placeholder", { defaultValue: "Search" }),
132
139
  readOnly: !0,
133
140
  inputClassName: "gi-cursor-pointer",
134
- iconEndClassName: H({
135
- "gi-cursor-pointer": !n,
136
- "gi-cursor-not-allowed": n,
137
- "gi-pointer-events-none": n
141
+ iconEndClassName: D({
142
+ "gi-cursor-pointer": !r,
143
+ "gi-cursor-not-allowed": r,
144
+ "gi-pointer-events-none": r
138
145
  }),
139
- iconEnd: "keyboard_arrow_down",
140
- onIconEndClick: C,
141
- ref: u,
142
- iconEndRef: N,
143
- value: J,
144
- onClick: C,
145
- onKeyDown: Q,
146
- onBlur: U,
147
- name: a
146
+ iconEnd: H ? "keyboard_arrow_up" : "keyboard_arrow_down",
147
+ onIconEndClick: w,
148
+ ref: c,
149
+ iconEndRef: O,
150
+ value: U,
151
+ onClick: w,
152
+ onKeyDown: X,
153
+ onBlur: Y,
154
+ name: i
148
155
  }
149
156
  ),
150
- /* @__PURE__ */ l(
151
- _,
157
+ /* @__PURE__ */ s(
158
+ te,
152
159
  {
153
- triggerRef: u,
154
- extraRefs: [N],
155
- onOpenChange: L,
156
- open: F,
160
+ triggerRef: c,
161
+ extraRefs: [O],
162
+ onOpenChange: W,
163
+ open: H,
157
164
  maxHeight: 304,
158
165
  options: {
159
166
  placement: "bottom-start",
@@ -163,47 +170,47 @@ const ne = W(
163
170
  { name: "flip", options: { fallbackPlacements: ["top"] } }
164
171
  ]
165
172
  },
166
- children: /* @__PURE__ */ l(
167
- B,
173
+ children: /* @__PURE__ */ s(
174
+ re,
168
175
  {
169
- ref: G,
170
- onChange: A,
171
- enableSearch: v,
172
- children: O.map((e, c) => {
176
+ ref: j,
177
+ onChange: L,
178
+ enableSearch: d,
179
+ children: k.map((e, l) => {
173
180
  var o;
174
- const s = (o = e == null ? void 0 : e.type) == null ? void 0 : o.componentType;
175
- if (s === "SelectItemNext") {
181
+ const a = (o = e == null ? void 0 : e.type) == null ? void 0 : o.componentType;
182
+ if (a === "SelectItemNext") {
176
183
  const t = e;
177
- return /* @__PURE__ */ l(
178
- K,
184
+ return /* @__PURE__ */ s(
185
+ F,
179
186
  {
180
187
  ...t.props,
181
- selected: (r == null ? void 0 : r.toString()) === t.props.value.toString(),
182
- index: c
188
+ selected: (n == null ? void 0 : n.toString()) === t.props.value.toString(),
189
+ index: l
183
190
  },
184
191
  `SelectItemNext-${t.props.value.toString()}`
185
192
  );
186
- } else if (s === "SelectGroupItemNext") {
187
- const t = e, f = k.toArray(t.props.children).filter((m) => E(m)).map((m, y) => {
188
- const x = m.props;
189
- return /* @__PURE__ */ l(
190
- K,
193
+ } else if (a === "SelectGroupItemNext") {
194
+ const t = e, f = R.toArray(t.props.children).filter((m) => G(m)).map((m, y) => {
195
+ const N = m.props;
196
+ return /* @__PURE__ */ s(
197
+ F,
191
198
  {
192
- ...x,
193
- selected: (r == null ? void 0 : r.toString()) === x.value.toString(),
194
- onChange: A,
199
+ ...N,
200
+ selected: (n == null ? void 0 : n.toString()) === N.value.toString(),
201
+ onChange: L,
195
202
  index: y
196
203
  },
197
- `SelectGroupItemNext-SelectItemNext-${x.value.toString()}`
204
+ `SelectGroupItemNext-SelectItemNext-${N.value.toString()}`
198
205
  );
199
206
  });
200
- return /* @__PURE__ */ l(
201
- ee,
207
+ return /* @__PURE__ */ s(
208
+ ne,
202
209
  {
203
210
  label: t.props.label,
204
211
  children: f
205
212
  },
206
- `option-group-${c}`
213
+ `option-group-${l}`
207
214
  );
208
215
  }
209
216
  return null;
@@ -216,35 +223,35 @@ const ne = W(
216
223
  }
217
224
  );
218
225
  }
219
- ), q = () => null;
220
- Object.defineProperty(q, "componentType", {
226
+ ), J = () => null;
227
+ Object.defineProperty(J, "componentType", {
221
228
  value: "SelectItemNext",
222
229
  writable: !1,
223
230
  enumerable: !1
224
231
  });
225
- const re = () => null;
226
- Object.defineProperty(re, "componentType", {
232
+ const le = () => null;
233
+ Object.defineProperty(le, "componentType", {
227
234
  value: "SelectGroupItemNext",
228
235
  writable: !1,
229
236
  enumerable: !1
230
237
  });
231
- const me = (S) => {
232
- const { options: p, defaultValue: I, onChange: d, error: g } = S;
233
- return /* @__PURE__ */ l(
234
- ne,
238
+ const Se = (S) => {
239
+ const { options: p, defaultValue: T, onChange: b, error: g } = S;
240
+ return /* @__PURE__ */ s(
241
+ se,
235
242
  {
236
243
  ...S,
237
- defaultValue: I,
238
- onChange: d,
244
+ defaultValue: T,
245
+ onChange: b,
239
246
  "data-table-cell": "true",
240
247
  "data-table-cell-error-state": g == null ? void 0 : g.toString(),
241
- children: p.map(({ value: v, label: n }) => /* @__PURE__ */ l(q, { value: v, children: n }, `${v}-${n}`))
248
+ children: p.map(({ value: d, label: r }) => /* @__PURE__ */ s(J, { value: d, children: r }, `${d}-${r}`))
242
249
  }
243
250
  );
244
251
  };
245
252
  export {
246
- re as SelectGroupItemNext,
247
- q as SelectItemNext,
248
- ne as SelectNext,
249
- me as SelectNextTableCell
253
+ le as SelectGroupItemNext,
254
+ J as SelectItemNext,
255
+ se as SelectNext,
256
+ Se as SelectNextTableCell
250
257
  };