@ogcio/design-system-react 1.15.2 → 1.16.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 (42) hide show
  1. package/dist/assets/logos/gov-of-ireland/harp-black.d.ts +2 -0
  2. package/dist/assets/logos/gov-of-ireland/harp-black.js +322 -0
  3. package/dist/assets/logos/harp/harp-black.d.ts +2 -0
  4. package/dist/assets/logos/harp/harp-black.js +63 -0
  5. package/dist/autocomplete/autocomplete.js +56 -53
  6. package/dist/button/button.js +1 -1
  7. package/dist/drawer/drawer.content.js +29 -43
  8. package/dist/drawer/drawer.d.ts +2 -1
  9. package/dist/drawer/drawer.js +11 -7
  10. package/dist/file-upload/file-upload.d.ts +3 -1
  11. package/dist/forms/form-field/form-field.d.ts +1 -1
  12. package/dist/forms/form-field/form-field.js +29 -19
  13. package/dist/header/components/header-menu.js +53 -47
  14. package/dist/header/components/header-slot.d.ts +5 -3
  15. package/dist/header/components/header-slot.js +58 -47
  16. package/dist/header/header.d.ts +1 -1
  17. package/dist/header/header.js +128 -106
  18. package/dist/header/types.d.ts +2 -0
  19. package/dist/header/variants.d.ts +160 -0
  20. package/dist/header/variants.js +88 -0
  21. package/dist/input-file/input-file.d.ts +3 -2
  22. package/dist/input-file/input-file.js +13 -12
  23. package/dist/input-file/types.d.ts +3 -1
  24. package/dist/input-text/input-text.d.ts +2 -0
  25. package/dist/input-text/input-text.js +56 -55
  26. package/dist/input-text/type.d.ts +1 -0
  27. package/dist/modal/modal.d.ts +2 -2
  28. package/dist/modal/modal.js +185 -149
  29. package/dist/modal/types.d.ts +5 -0
  30. package/dist/phase-banner/phase-banner.d.ts +4 -2
  31. package/dist/phase-banner/phase-banner.js +30 -7
  32. package/dist/popover/popover.js +560 -524
  33. package/dist/select/select-menu.js +61 -63
  34. package/dist/select/select-next.js +61 -57
  35. package/dist/select/types.d.ts +0 -3
  36. package/dist/styles.css +1 -1
  37. package/dist/table/table-pagination.js +63 -46
  38. package/dist/table/table.js +18 -18
  39. package/dist/text-input/text-input.d.ts +1 -0
  40. package/dist/textarea/textarea.js +52 -49
  41. package/dist/toast/toast.js +6 -9
  42. package/package.json +4 -3
@@ -1,29 +1,27 @@
1
1
  "use client";
2
- import { jsxs as b, jsx as n } from "react/jsx-runtime";
3
- import { forwardRef as H, useState as N, useEffect as A, Children as K, isValidElement as P, cloneElement as v } from "react";
4
- import { cn as F } from "../cn.js";
5
- import { translate as B } from "../i18n/utility.js";
6
- import { Icon as J } from "../icon/icon.js";
7
- import { InputText as Q } from "../input-text/input-text.js";
8
- import { Label as U } from "../label/label.js";
9
- import { Spinner as W } from "../spinner/spinner.js";
10
- const se = H(
11
- ({ children: o, className: i, onChange: s, enableSearch: r, isLoading: c, showNoData: m }, g) => {
12
- const [l, y] = N(""), [O, f] = N(!1), [S, w] = N([]);
13
- A(() => {
14
- f(!1), m && setTimeout(() => f(!0), 0);
15
- }, [m]), A(() => {
16
- const R = K.toArray(o).filter(
17
- (a) => P(a)
2
+ import { jsxs as N, jsx as n } from "react/jsx-runtime";
3
+ import { forwardRef as F, useState as $, useEffect as R, Children as z, isValidElement as A, cloneElement as v } from "react";
4
+ import { cn as P } from "../cn.js";
5
+ import { translate as K } from "../i18n/utility.js";
6
+ import { Icon as q } from "../icon/icon.js";
7
+ import { InputText as H } from "../input-text/input-text.js";
8
+ import { Label as J } from "../label/label.js";
9
+ import { Spinner as Q } from "../spinner/spinner.js";
10
+ const re = F(
11
+ ({ children: o, className: i, onChange: s, enableSearch: r, isLoading: c, showNoData: d }, g) => {
12
+ const [l, O] = $(""), [S, w] = $([]);
13
+ R(() => {
14
+ const u = z.toArray(o).filter(
15
+ (a) => A(a)
18
16
  ).map((a) => {
19
- var L, M, T, I, k, E;
20
- const q = (L = a == null ? void 0 : a.type) == null ? void 0 : L.componentType, D = l.toLowerCase();
21
- switch (q) {
17
+ var x, L, M, I, T, k;
18
+ const B = (x = a == null ? void 0 : a.type) == null ? void 0 : x.componentType, b = l.toLowerCase();
19
+ switch (B) {
22
20
  case "SelectMenuOption": {
23
21
  const e = a;
24
22
  if (typeof e.props.value == "string") {
25
- const G = ((I = (T = (M = e == null ? void 0 : e.props) == null ? void 0 : M.children) == null ? void 0 : T.toString()) == null ? void 0 : I.toLowerCase()) || "", j = (E = (k = e == null ? void 0 : e.props) == null ? void 0 : k.value) == null ? void 0 : E.toLowerCase();
26
- if (G.includes(D) || j.includes(D))
23
+ const D = ((I = (M = (L = e == null ? void 0 : e.props) == null ? void 0 : L.children) == null ? void 0 : M.toString()) == null ? void 0 : I.toLowerCase()) || "", E = (k = (T = e == null ? void 0 : e.props) == null ? void 0 : T.value) == null ? void 0 : k.toLowerCase();
24
+ if (D.includes(b) || E.includes(b))
27
25
  return v(e, {
28
26
  onChange: s,
29
27
  enableSearch: r
@@ -32,116 +30,116 @@ const se = H(
32
30
  break;
33
31
  }
34
32
  case "SelectMenuGroupItem": {
35
- const e = a, C = K.toArray(
33
+ const e = a, G = z.toArray(
36
34
  e.props.children
37
- ).filter((t) => P(t)).map((t) => {
35
+ ).filter((t) => A(t)).map((t) => {
38
36
  var p;
39
37
  return ((p = t == null ? void 0 : t.type) == null ? void 0 : p.componentType) === "SelectMenuOption" ? v(t, { onChange: s }) : null;
40
38
  }).filter(
41
39
  (t) => t !== null
42
40
  ).filter((t) => {
43
- var V, $, z;
44
- const p = (($ = (V = t.props.children) == null ? void 0 : V.toString()) == null ? void 0 : $.toLowerCase()) || "", d = ((z = t.props.value) == null ? void 0 : z.toLowerCase()) || "";
45
- return (p == null ? void 0 : p.includes(l.toLowerCase())) || (d == null ? void 0 : d.includes(l.toLowerCase()));
41
+ var j, C, V;
42
+ const p = ((C = (j = t.props.children) == null ? void 0 : j.toString()) == null ? void 0 : C.toLowerCase()) || "", f = ((V = t.props.value) == null ? void 0 : V.toLowerCase()) || "";
43
+ return (p == null ? void 0 : p.includes(l.toLowerCase())) || (f == null ? void 0 : f.includes(l.toLowerCase()));
46
44
  });
47
- return C.length > 0 || l === "" ? v(e, {
48
- children: C
45
+ return G.length > 0 || l === "" ? v(e, {
46
+ children: G
49
47
  }) : null;
50
48
  }
51
49
  default:
52
50
  return null;
53
51
  }
54
52
  }).filter(Boolean);
55
- w(R);
53
+ w(u);
56
54
  }, [o, l, s]);
57
- const h = (x) => {
58
- y(x.target.value);
59
- }, u = () => c ? /* @__PURE__ */ n("div", { className: "gi-select-menu-loading", children: /* @__PURE__ */ n(W, { size: "md" }) }) : O ? /* @__PURE__ */ n("div", { className: "gi-select-menu-option-not-found", children: B("autocomplete.noData", {
55
+ const y = (m) => {
56
+ O(m.target.value);
57
+ }, h = () => c ? /* @__PURE__ */ n("div", { className: "gi-select-menu-loading", children: /* @__PURE__ */ n(Q, { size: "md" }) }) : d ? /* @__PURE__ */ n("div", { className: "gi-select-menu-option-not-found", children: K("autocomplete.noData", {
60
58
  defaultValue: "No data found."
61
59
  }) }) : /* @__PURE__ */ n("ul", { children: S });
62
- return /* @__PURE__ */ b("div", { ref: g, className: F("gi-select-menu-container", i), children: [
60
+ return /* @__PURE__ */ N("div", { ref: g, className: P("gi-select-menu-container", i), children: [
63
61
  r && /* @__PURE__ */ n("div", { className: "gi-select-menu-input-container", children: /* @__PURE__ */ n(
64
- Q,
62
+ H,
65
63
  {
66
64
  tabIndex: 0,
67
- placeholder: B("input.search"),
65
+ placeholder: K("input.search"),
68
66
  iconEnd: "search",
69
- onChange: h,
67
+ onChange: y,
70
68
  value: l
71
69
  }
72
70
  ) }),
73
- /* @__PURE__ */ n("div", { className: "gi-select-menu-option-container", children: u() })
71
+ /* @__PURE__ */ n("div", { className: "gi-select-menu-option-container", children: h() })
74
72
  ] });
75
73
  }
76
- ), X = ({
74
+ ), U = ({
77
75
  children: o,
78
76
  value: i,
79
77
  selected: s,
80
78
  onChange: r,
81
79
  disabled: c,
82
- dataTestid: m,
80
+ dataTestid: d,
83
81
  className: g,
84
82
  hidden: l,
85
- enableSearch: y,
86
- isHighlighted: O,
87
- index: f,
88
- ...S
83
+ enableSearch: O,
84
+ isHighlighted: S,
85
+ index: w,
86
+ ...y
89
87
  }) => {
90
- const w = (u) => {
88
+ const h = (u) => {
91
89
  (u.key === "Enter" || u.key === " ") && (u.preventDefault(), r == null || r(i));
92
- }, h = () => {
90
+ }, m = () => {
93
91
  c || r == null || r(i);
94
92
  };
95
- return l ? null : /* @__PURE__ */ b(
93
+ return l ? null : /* @__PURE__ */ N(
96
94
  "li",
97
95
  {
98
96
  role: "option",
99
97
  tabIndex: c ? -1 : 0,
100
- "data-index": f,
98
+ "data-index": w,
101
99
  "aria-selected": s,
102
100
  "aria-label": o == null ? void 0 : o.toString(),
103
101
  "aria-disabled": c,
104
- onKeyDown: w,
105
- onClick: h,
106
- className: F(
102
+ onKeyDown: h,
103
+ onClick: m,
104
+ className: P(
107
105
  "gi-select-option-item",
108
106
  {
109
107
  "gi-select-option-item-disabled": c,
110
- "gi-select-option-item-highlighted": O
108
+ "gi-select-option-item-highlighted": S
111
109
  },
112
110
  g
113
111
  ),
114
- "data-search-enabled": y,
115
- "data-testid": m || `option-${i}`,
116
- ...S,
112
+ "data-search-enabled": O,
113
+ "data-testid": d || `option-${i}`,
114
+ ...y,
117
115
  children: [
118
116
  /* @__PURE__ */ n("span", { className: "gi-text-sm", children: o }),
119
- s && /* @__PURE__ */ n(J, { icon: "check" })
117
+ s && /* @__PURE__ */ n(q, { icon: "check" })
120
118
  ]
121
119
  },
122
120
  `${o}-${i}`
123
121
  );
124
122
  };
125
- Object.defineProperty(X, "componentType", {
123
+ Object.defineProperty(U, "componentType", {
126
124
  value: "SelectMenuOption",
127
125
  writable: !1,
128
126
  enumerable: !1
129
127
  });
130
- const Y = ({
128
+ const W = ({
131
129
  children: o,
132
130
  label: i,
133
131
  ...s
134
- }) => /* @__PURE__ */ b("div", { ...s, role: "group", className: "gi-px-3", children: [
135
- /* @__PURE__ */ n(U, { text: i, size: "sm", className: "gi-font-bold gi-pb-1" }),
132
+ }) => /* @__PURE__ */ N("div", { ...s, role: "group", className: "gi-px-3", children: [
133
+ /* @__PURE__ */ n(J, { text: i, size: "sm", className: "gi-font-bold gi-pb-1" }),
136
134
  o
137
135
  ] });
138
- Object.defineProperty(Y, "componentType", {
136
+ Object.defineProperty(W, "componentType", {
139
137
  value: "SelectMenuGroupItem",
140
138
  writable: !1,
141
139
  enumerable: !1
142
140
  });
143
141
  export {
144
- se as SelectMenu,
145
- Y as SelectMenuGroupItem,
146
- X as SelectMenuOption
142
+ re as SelectMenu,
143
+ W as SelectMenuGroupItem,
144
+ U as SelectMenuOption
147
145
  };
@@ -1,27 +1,29 @@
1
1
  "use client";
2
- import { jsx as l, jsxs as U } from "react/jsx-runtime";
3
- import { forwardRef as W, useRef as x, useState as C, useImperativeHandle as X, Children as k, isValidElement as E, useEffect as M } from "react";
2
+ import { jsx as l, jsxs as V } from "react/jsx-runtime";
3
+ import { forwardRef as W, useRef as b, useState as w, useImperativeHandle as X, Children as k, isValidElement as E, useEffect as M } from "react";
4
4
  import { cn as H } from "../cn.js";
5
- import { InputText as Y } from "../input-text/input-text.js";
6
- import { Popover as Z } from "../popover/popover.js";
7
- import { SelectMenu as V, SelectMenuOption as K, SelectMenuGroupItem as _ } from "./select-menu.js";
8
- import { SelectSearch as B } from "./select-search.js";
9
- const ee = W(
5
+ import { translate as Y } from "../i18n/utility.js";
6
+ import { InputText as Z } from "../input-text/input-text.js";
7
+ import { Popover as _ } from "../popover/popover.js";
8
+ import { SelectMenu as B, SelectMenuOption as K, SelectMenuGroupItem as ee } from "./select-menu.js";
9
+ import { SelectSearch as te } from "./select-search.js";
10
+ const ne = W(
10
11
  ({
11
12
  children: S,
12
- value: a,
13
+ value: p,
13
14
  defaultValue: I = "",
14
15
  onChange: d,
15
16
  onMenuClose: g,
16
17
  enableSearch: v,
17
18
  disabled: n,
18
- name: p,
19
+ name: a,
19
20
  onBlur: i,
21
+ placeholder: R,
20
22
  ...h
21
23
  }, z) => {
22
- const u = x(null), N = x(null), R = x(null), G = x(!1), [r, P] = C(
23
- I || a
24
- ), [F, T] = C(!1), [$, j] = C("");
24
+ const u = b(null), N = b(null), G = b(null), P = b(!1), [r, $] = w(
25
+ I || p
26
+ ), [F, T] = w(!1), [J, j] = w("");
25
27
  X(z, () => u.current);
26
28
  const O = k.toArray(S).filter(
27
29
  (e) => E(e)
@@ -57,49 +59,49 @@ const ee = W(
57
59
  } else
58
60
  j(""), u.current && (u.current.value = "");
59
61
  }, [r, O]), M(() => {
60
- a !== void 0 && P(a);
61
- }, [a]);
62
- const w = () => {
62
+ p !== void 0 && $(p);
63
+ }, [p]);
64
+ const C = () => {
63
65
  var e;
64
66
  T(!0), (e = u.current) == null || e.focus();
65
- }, J = (e) => {
67
+ }, L = (e) => {
66
68
  T(e), g && !e && g();
67
69
  }, A = (e) => {
68
- if (T(!1), P(e), d && (d({
69
- target: { name: p, value: e },
70
- currentTarget: { name: p, value: e },
70
+ if (T(!1), $(e), d && (d({
71
+ target: { name: a, value: e },
72
+ currentTarget: { name: a, value: e },
71
73
  type: "change",
72
74
  bubbles: !0
73
75
  }), i)) {
74
76
  const s = {
75
- target: { name: p, value: e },
76
- currentTarget: { name: p, value: e },
77
+ target: { name: a, value: e },
78
+ currentTarget: { name: a, value: e },
77
79
  type: "blur",
78
80
  bubbles: !0
79
81
  };
80
82
  i == null || i(s);
81
83
  }
82
- }, L = (e) => {
83
- e.key === "Enter" && !n && w();
84
84
  }, Q = (e) => {
85
+ e.key === "Enter" && !n && C();
86
+ }, U = (e) => {
85
87
  var s, o;
86
88
  const c = e.relatedTarget;
87
- if (c && ((s = R.current) != null && s.contains(c) || (o = N.current) != null && o.contains(c)) || G.current) {
88
- setTimeout(() => G.current = !1, 0);
89
+ if (c && ((s = G.current) != null && s.contains(c) || (o = N.current) != null && o.contains(c)) || P.current) {
90
+ setTimeout(() => P.current = !1, 0);
89
91
  return;
90
92
  }
91
93
  if (i) {
92
- const t = a ?? r ?? "";
94
+ const t = p ?? r ?? "";
93
95
  i({
94
- target: { name: p, value: t },
95
- currentTarget: { name: p, value: t },
96
+ target: { name: a, value: t },
97
+ currentTarget: { name: a, value: t },
96
98
  type: "blur",
97
99
  bubbles: !0
98
100
  });
99
101
  }
100
102
  };
101
103
  return v ? /* @__PURE__ */ l(
102
- B,
104
+ te,
103
105
  {
104
106
  ...h,
105
107
  value: r,
@@ -107,23 +109,25 @@ const ee = W(
107
109
  disabled: n,
108
110
  ref: u,
109
111
  onBlur: i,
110
- name: p,
112
+ name: a,
113
+ placeholder: R,
111
114
  children: S
112
115
  }
113
- ) : /* @__PURE__ */ U(
116
+ ) : /* @__PURE__ */ V(
114
117
  "div",
115
118
  {
116
119
  "aria-disabled": n,
117
120
  className: H("gi-select-next", h.className),
118
121
  children: [
119
122
  /* @__PURE__ */ l(
120
- Y,
123
+ Z,
121
124
  {
122
125
  ...h,
126
+ autoComplete: "off",
123
127
  "aria-label": "Select an option",
124
128
  "aria-disabled": n,
125
129
  disabled: n,
126
- placeholder: $ || "Select",
130
+ placeholder: R ?? Y("select.next.placeholder", { defaultValue: "Search" }),
127
131
  readOnly: !0,
128
132
  inputClassName: "gi-cursor-pointer",
129
133
  iconEndClassName: H({
@@ -132,22 +136,22 @@ const ee = W(
132
136
  "gi-pointer-events-none": n
133
137
  }),
134
138
  iconEnd: "keyboard_arrow_down",
135
- onIconEndClick: w,
139
+ onIconEndClick: C,
136
140
  ref: u,
137
141
  iconEndRef: N,
138
- value: $,
139
- onClick: w,
140
- onKeyDown: L,
141
- onBlur: Q,
142
- name: p
142
+ value: J,
143
+ onClick: C,
144
+ onKeyDown: Q,
145
+ onBlur: U,
146
+ name: a
143
147
  }
144
148
  ),
145
149
  /* @__PURE__ */ l(
146
- Z,
150
+ _,
147
151
  {
148
152
  triggerRef: u,
149
153
  extraRefs: [N],
150
- onOpenChange: J,
154
+ onOpenChange: L,
151
155
  open: F,
152
156
  maxHeight: 304,
153
157
  options: {
@@ -159,9 +163,9 @@ const ee = W(
159
163
  ]
160
164
  },
161
165
  children: /* @__PURE__ */ l(
162
- V,
166
+ B,
163
167
  {
164
- ref: R,
168
+ ref: G,
165
169
  onChange: A,
166
170
  enableSearch: v,
167
171
  children: O.map((e, c) => {
@@ -180,20 +184,20 @@ const ee = W(
180
184
  );
181
185
  } else if (s === "SelectGroupItemNext") {
182
186
  const t = e, f = k.toArray(t.props.children).filter((m) => E(m)).map((m, y) => {
183
- const b = m.props;
187
+ const x = m.props;
184
188
  return /* @__PURE__ */ l(
185
189
  K,
186
190
  {
187
- ...b,
188
- selected: (r == null ? void 0 : r.toString()) === b.value.toString(),
191
+ ...x,
192
+ selected: (r == null ? void 0 : r.toString()) === x.value.toString(),
189
193
  onChange: A,
190
194
  index: y
191
195
  },
192
- `SelectGroupItemNext-SelectItemNext-${b.value.toString()}`
196
+ `SelectGroupItemNext-SelectItemNext-${x.value.toString()}`
193
197
  );
194
198
  });
195
199
  return /* @__PURE__ */ l(
196
- _,
200
+ ee,
197
201
  {
198
202
  label: t.props.label,
199
203
  children: f
@@ -217,29 +221,29 @@ Object.defineProperty(q, "componentType", {
217
221
  writable: !1,
218
222
  enumerable: !1
219
223
  });
220
- const te = () => null;
221
- Object.defineProperty(te, "componentType", {
224
+ const re = () => null;
225
+ Object.defineProperty(re, "componentType", {
222
226
  value: "SelectGroupItemNext",
223
227
  writable: !1,
224
228
  enumerable: !1
225
229
  });
226
- const ae = (S) => {
227
- const { options: a, defaultValue: I, onChange: d, error: g } = S;
230
+ const fe = (S) => {
231
+ const { options: p, defaultValue: I, onChange: d, error: g } = S;
228
232
  return /* @__PURE__ */ l(
229
- ee,
233
+ ne,
230
234
  {
231
235
  ...S,
232
236
  defaultValue: I,
233
237
  onChange: d,
234
238
  "data-table-cell": "true",
235
239
  "data-table-cell-error-state": g == null ? void 0 : g.toString(),
236
- children: a.map(({ value: v, label: n }) => /* @__PURE__ */ l(q, { value: v, children: n }, `${v}-${n}`))
240
+ children: p.map(({ value: v, label: n }) => /* @__PURE__ */ l(q, { value: v, children: n }, `${v}-${n}`))
237
241
  }
238
242
  );
239
243
  };
240
244
  export {
241
- te as SelectGroupItemNext,
245
+ re as SelectGroupItemNext,
242
246
  q as SelectItemNext,
243
- ee as SelectNext,
244
- ae as SelectNextTableCell
247
+ ne as SelectNext,
248
+ fe as SelectNextTableCell
245
249
  };
@@ -54,9 +54,6 @@ export type SelectNextProps = PropsWithChildren<{
54
54
  value?: string;
55
55
  enableSearch?: boolean;
56
56
  disabled?: boolean;
57
- /**
58
- * Works only when `enableSearch` is set to `true`
59
- */
60
57
  placeholder?: string;
61
58
  } & Omit<HTMLAttributes<HTMLDivElement>, `onChange`>>;
62
59
  export type SelectNextOptionProps = PropsWithChildren<{