@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,153 +1,161 @@
1
1
  "use client";
2
2
  import "@ogcio/design-system-react/browser-check";
3
- import { jsxs as J, jsx as O } from "react/jsx-runtime";
4
- import { forwardRef as Q, useRef as G, useImperativeHandle as W, useEffect as Y, createElement as Z, Children as ee, isValidElement as te } from "react";
5
- import { cn as P } from "../cn.js";
6
- import { translate as D } from "../i18n/utility.js";
3
+ import { jsxs as J, jsx as b } from "react/jsx-runtime";
4
+ import { forwardRef as Q, useRef as D, useImperativeHandle as W, useEffect as Y, createElement as Z, Children as ee, isValidElement as te } from "react";
5
+ import { cn as G } from "../cn.js";
6
+ import { translate as P } from "../i18n/utility.js";
7
7
  import { InputText as oe } from "../input-text/input-text.js";
8
8
  import { Popover as ne } from "../popover/popover.js";
9
- import { SelectMenu as le, SelectMenuOption as L, SelectMenuGroupItem as re } from "../select/select-menu.js";
10
- import { AUTOCOMPLETE_ACTIONS as ae } from "./types.js";
9
+ import { SelectMenu as ae, SelectMenuOption as L, SelectMenuGroupItem as re } from "../select/select-menu.js";
10
+ import { AUTOCOMPLETE_ACTIONS as le } from "./types.js";
11
11
  import { useAutocompleteController as pe } from "./use-autocomplete-controller.js";
12
12
  const {
13
13
  ON_RESET: ie,
14
14
  ON_SELECT_ITEM: se,
15
15
  SET_INPUT_VALUE: R,
16
- SET_IS_OPEN: d,
17
- TOGGLE_CLEAR_BUTTON: v,
16
+ SET_IS_OPEN: c,
17
+ TOGGLE_CLEAR_BUTTON: S,
18
18
  SET_HIGHLIGHTED_INDEX: B,
19
19
  SET_VALUE: ce
20
- } = ae, ue = (n) => n ? "keyboard_arrow_up" : "keyboard_arrow_down", C = (n, l) => (p) => {
20
+ } = le, ue = (n) => n ? "keyboard_arrow_up" : "keyboard_arrow_down", C = (n, a) => (p) => {
21
21
  n && n({
22
- target: {
23
- name: l,
24
- value: p
25
- },
26
- currentTarget: {
27
- name: l,
28
- value: p
29
- },
22
+ target: { name: a, value: p },
23
+ currentTarget: { name: a, value: p },
30
24
  type: "change",
31
25
  bubbles: !0,
32
26
  isTrusted: !0
33
27
  });
34
- }, M = (n, l) => (p) => {
28
+ }, M = (n, a) => (p) => {
35
29
  n && n({
36
- target: { name: l, value: p },
37
- currentTarget: { name: l, value: p },
30
+ target: { name: a, value: p },
31
+ currentTarget: { name: a, value: p },
38
32
  type: "blur",
39
33
  bubbles: !0,
40
34
  isTrusted: !0
41
35
  });
42
36
  }, Ae = Q(
43
- (n, l) => {
37
+ (n, a) => {
44
38
  var N;
45
- const p = G(null), {
39
+ const p = D(null), {
46
40
  disabled: r,
47
- children: f,
41
+ children: m,
48
42
  placeholder: h,
49
43
  onSelectItem: y,
50
44
  isLoading: g,
51
45
  freeSolo: s = !1,
52
- onChange: b,
46
+ onChange: E,
53
47
  onBlur: A,
54
- name: c,
55
- value: E,
48
+ name: u,
49
+ value: O,
56
50
  id: U
57
- } = n, _ = G(!1), {
51
+ } = n, _ = D(!1), {
58
52
  state: t,
59
53
  dispatch: o,
60
- inputRef: m,
54
+ inputRef: f,
61
55
  getOptionLabelByValue: x,
62
56
  listRef: w,
63
57
  debouncedFilter: V
64
58
  } = pe({
65
59
  ...n,
66
- onChange: C(b, c)
60
+ onChange: C(E, u)
67
61
  });
68
- W(l, () => m.current), Y(() => {
69
- E !== void 0 && (o({ type: ce, payload: E }), o({
62
+ W(a, () => f.current), Y(() => {
63
+ O !== void 0 && (o({ type: ce, payload: O }), o({
70
64
  type: R,
71
- payload: x(f, E)
72
- }), o({ type: v }));
73
- }, [E]);
65
+ payload: x(m, O)
66
+ }), o({ type: S }));
67
+ }, [O]);
74
68
  const H = (e) => {
75
- o({ type: d, payload: e }), e || o({ type: v, payload: !1 });
69
+ o({ type: c, payload: e }), e || o({ type: S, payload: !1 });
76
70
  }, j = () => {
77
- o({ type: ie }), o({ type: d, payload: !1 }), C(b, c)("");
71
+ o({ type: ie }), o({ type: c, payload: !1 }), C(E, u)("");
78
72
  }, $ = (e) => {
79
- o({ type: R, payload: e }), s && C(b, c)(e), e && o({ type: d, payload: !0 }), V(e);
73
+ o({ type: R, payload: e }), s && C(E, u)(e), e && o({ type: c, payload: !0 }), V(e);
80
74
  }, K = (e) => {
81
75
  const {
82
- target: { value: a }
76
+ target: { value: l }
83
77
  } = e;
84
- e.__origin === "clear_button" ? j() : $(a), o({ type: v }), setTimeout(() => {
85
- var u;
86
- return (u = m.current) == null ? void 0 : u.focus();
78
+ e.__origin === "clear_button" ? j() : $(l), o({ type: S }), setTimeout(() => {
79
+ var d;
80
+ return (d = f.current) == null ? void 0 : d.focus();
87
81
  });
88
82
  }, F = () => {
89
83
  var e;
90
- o({ type: d, payload: !t.isOpen }), (e = m.current) == null || e.focus();
84
+ o({ type: c, payload: !t.isOpen }), (e = f.current) == null || e.focus();
91
85
  }, X = () => {
92
86
  t.isOpen || o({
93
- type: d,
87
+ type: c,
94
88
  payload: !0
95
89
  });
96
- }, S = (e) => {
90
+ }, v = (e) => {
97
91
  o({
98
92
  type: se,
99
93
  payload: {
100
- inputValue: x(f, e),
94
+ inputValue: x(m, e),
101
95
  value: e
102
96
  }
103
- }), C(b, c)(e), setTimeout(() => {
104
- var a;
105
- M(A, c)(e), (a = m.current) == null || a.blur();
97
+ }), C(E, u)(e), setTimeout(() => {
98
+ var l;
99
+ M(A, u)(e), (l = f.current) == null || l.blur();
106
100
  }, 0), y == null || y(e);
107
101
  }, q = (e) => {
108
102
  var i, I;
109
- const { relatedTarget: a } = e;
110
- if (a && ((i = w.current) != null && i.contains(a) || (I = p.current) != null && I.contains(a)) || _.current) {
103
+ const { relatedTarget: l } = e;
104
+ if (l && ((i = w.current) != null && i.contains(l) || (I = p.current) != null && I.contains(l)) || _.current) {
111
105
  setTimeout(() => _.current = !1, 0);
112
106
  return;
113
107
  }
114
- const u = t.value ?? t.inputValue ?? "";
115
- M(A, c)(u);
108
+ const d = t.value ?? t.inputValue ?? "";
109
+ M(A, u)(d);
116
110
  }, z = (e) => {
117
- const a = t.autocompleteOptions.length, u = (i, I) => {
111
+ const l = t.autocompleteOptions.length, d = (i, I) => {
118
112
  let T = i;
119
- for (let k = 0; k < a; k++)
120
- if (T = (T + I + a) % a, !t.autocompleteOptions[T].props.disabled)
113
+ for (let k = 0; k < l; k++)
114
+ if (T = (T + I + l) % l, !t.autocompleteOptions[T].props.disabled)
121
115
  return T;
122
116
  return -1;
123
117
  };
124
- if (e.key === "ArrowDown")
125
- e.preventDefault(), o({
126
- type: B,
127
- payload: t.isOpen ? u(t.highlightedIndex, 1) : 0
128
- }), o({ type: d, payload: !0 });
129
- else if (e.key === "ArrowUp")
130
- e.preventDefault(), o({
131
- type: B,
132
- payload: u(t.highlightedIndex, -1)
133
- }), o({ type: d, payload: !0 });
134
- else if (e.key === "Enter" && t.highlightedIndex >= 0) {
135
- const i = t.autocompleteOptions[t.highlightedIndex];
136
- i && i.props.value && !i.props.disabled && S(i.props.value);
118
+ switch (e.key) {
119
+ case "ArrowDown": {
120
+ e.preventDefault(), o({
121
+ type: B,
122
+ payload: t.isOpen ? d(t.highlightedIndex, 1) : 0
123
+ }), o({ type: c, payload: !0 });
124
+ break;
125
+ }
126
+ case "ArrowUp": {
127
+ e.preventDefault(), o({
128
+ type: B,
129
+ payload: d(t.highlightedIndex, -1)
130
+ }), o({ type: c, payload: !0 });
131
+ break;
132
+ }
133
+ case "Enter":
134
+ case "NumpadEnter": {
135
+ if (e.preventDefault(), t.highlightedIndex >= 0) {
136
+ const i = t.autocompleteOptions[t.highlightedIndex];
137
+ i && i.props.value && !i.props.disabled && v(i.props.value);
138
+ }
139
+ break;
140
+ }
141
+ case "Escape": {
142
+ o({ type: c, payload: !1 });
143
+ break;
144
+ }
137
145
  }
138
146
  };
139
147
  return /* @__PURE__ */ J(
140
148
  "div",
141
149
  {
142
150
  "aria-disabled": r,
143
- className: P("gi-autocomplete gi-not-prose", n.className),
151
+ className: G("gi-autocomplete gi-not-prose", n.className),
144
152
  children: [
145
- /* @__PURE__ */ O(
153
+ /* @__PURE__ */ b(
146
154
  oe,
147
155
  {
148
156
  autoComplete: "off",
149
157
  id: U,
150
- name: c,
158
+ name: u,
151
159
  onKeyDown: z,
152
160
  onIconEndClick: F,
153
161
  onChange: K,
@@ -155,28 +163,28 @@ const {
155
163
  onBlur: q,
156
164
  clearButtonEnabled: t.isClearButtonEnabled,
157
165
  inputActionPosition: "beforeSuffix",
158
- "aria-label": D("autocomplete.placeholder", {
166
+ "aria-label": P("autocomplete.placeholder", {
159
167
  defaultValue: "Type to Search"
160
168
  }),
161
169
  "aria-disabled": r,
162
170
  disabled: r,
163
- placeholder: h ?? D("autocomplete.placeholder", { defaultValue: "Type to Search" }),
164
- iconEndClassName: P({
171
+ placeholder: h ?? P("autocomplete.placeholder", { defaultValue: "Type to Search" }),
172
+ iconEndClassName: G({
165
173
  "gi-cursor-pointer": !r && !s,
166
174
  "gi-cursor-not-allowed gi-pointer-events-none": r && !s
167
175
  }),
168
176
  iconEnd: s ? void 0 : ue(t.isOpen),
169
- ref: m,
177
+ ref: f,
170
178
  iconEndRef: p,
171
179
  value: t.inputValue,
172
180
  "data-highlighted-index": t.highlightedIndex
173
181
  }
174
182
  ),
175
- /* @__PURE__ */ O(
183
+ /* @__PURE__ */ b(
176
184
  ne,
177
185
  {
178
186
  onOpenChange: H,
179
- triggerRef: m,
187
+ triggerRef: f,
180
188
  extraRefs: [p],
181
189
  open: t.isOpen,
182
190
  maxHeight: 304,
@@ -191,17 +199,17 @@ const {
191
199
  }
192
200
  ]
193
201
  },
194
- children: /* @__PURE__ */ O(
195
- le,
202
+ children: /* @__PURE__ */ b(
203
+ ae,
196
204
  {
197
- onChange: S,
205
+ onChange: v,
198
206
  isLoading: g,
199
207
  showNoData: !((N = t.autocompleteOptions) != null && N.length),
200
208
  ref: w,
201
209
  children: de(
202
210
  t.autocompleteOptions,
203
211
  t,
204
- S
212
+ v
205
213
  )
206
214
  }
207
215
  )
@@ -211,33 +219,33 @@ const {
211
219
  }
212
220
  );
213
221
  }
214
- ), de = (n, l, p) => n.map((r, f) => {
215
- if (l.optionType === "AutocompleteItem")
222
+ ), de = (n, a, p) => n.map((r, m) => {
223
+ if (a.optionType === "AutocompleteItem")
216
224
  return /* @__PURE__ */ Z(
217
225
  L,
218
226
  {
219
227
  ...r.props,
220
228
  key: `AutocompleteItem-${r.props.value}`,
221
- selected: l.value === r.props.value,
222
- isHighlighted: f === l.highlightedIndex,
223
- index: f
229
+ selected: a.value === r.props.value,
230
+ isHighlighted: m === a.highlightedIndex,
231
+ index: m
224
232
  }
225
233
  );
226
- if (l.optionType === "AutocompleteGroupItem") {
234
+ if (a.optionType === "AutocompleteGroupItem") {
227
235
  const h = r, y = ee.toArray(h.props.children).filter((g) => te(g)).map((g) => {
228
236
  const s = g.props;
229
- return /* @__PURE__ */ O(
237
+ return /* @__PURE__ */ b(
230
238
  L,
231
239
  {
232
240
  ...s,
233
- selected: l.value.toString() === s.value.toString(),
241
+ selected: a.value.toString() === s.value.toString(),
234
242
  onChange: p,
235
- index: f
243
+ index: m
236
244
  },
237
245
  `SelectGroupItemNext-SelectItemNext-${s.value.toString()}`
238
246
  );
239
247
  });
240
- return /* @__PURE__ */ O(
248
+ return /* @__PURE__ */ b(
241
249
  re,
242
250
  {
243
251
  label: h.props.label,
@@ -247,21 +255,21 @@ const {
247
255
  );
248
256
  }
249
257
  return null;
250
- }), fe = () => null;
251
- Object.defineProperty(fe, "componentType", {
258
+ }), me = () => null;
259
+ Object.defineProperty(me, "componentType", {
252
260
  value: "AutocompleteItem",
253
261
  writable: !1,
254
262
  enumerable: !1
255
263
  });
256
- const me = () => null;
257
- Object.defineProperty(me, "componentType", {
264
+ const fe = () => null;
265
+ Object.defineProperty(fe, "componentType", {
258
266
  value: "AutocompleteGroupItem",
259
267
  writable: !1,
260
268
  enumerable: !1
261
269
  });
262
270
  export {
263
271
  Ae as Autocomplete,
264
- me as AutocompleteGroupItem,
265
- fe as AutocompleteItem,
272
+ fe as AutocompleteGroupItem,
273
+ me as AutocompleteItem,
266
274
  de as renderSelectMenuOptions
267
275
  };
@@ -1,5 +1,5 @@
1
1
  import { CardProps } from './types.js';
2
2
  export declare const CardLegacy: {
3
- ({ type, title, inset, subTitle, media, content, action, href, tag, dataTestid, titleAsChild, children, }: CardProps): import("react/jsx-runtime").JSX.Element;
3
+ ({ type, title, inset, subTitle, media, content, action, href, tag, titleAsChild, children, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
4
4
  displayName: string;
5
5
  };
@@ -1,21 +1,21 @@
1
1
  import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
- import { Button as b } from "../button/button.js";
2
+ import { Button as k } from "../button/button.js";
3
3
  import { translate as c } from "../i18n/utility.js";
4
4
  import { Link as u } from "../link/link.js";
5
- import { CardNext as k, CardMedia as T, CardContainer as L, CardHeader as V, CardTitle as $, CardSubtitle as j, CardTag as A, CardDescription as B, CardAction as H } from "./card-next.js";
5
+ import { CardNext as b, CardMedia as L, CardContainer as T, CardHeader as V, CardTitle as $, CardSubtitle as j, CardTag as A, CardDescription as B, CardAction as H } from "./card-next.js";
6
6
  const N = ({
7
7
  type: C = "vertical",
8
8
  title: d,
9
- inset: t = "none",
10
- subTitle: p,
9
+ inset: p = "none",
10
+ subTitle: t,
11
11
  media: o,
12
12
  content: m,
13
13
  action: h,
14
14
  href: n,
15
15
  tag: l,
16
- dataTestid: s,
17
16
  titleAsChild: a,
18
- children: y
17
+ children: s,
18
+ ...y
19
19
  }) => {
20
20
  const f = () => !d || !n && !a ? d || "" : /* @__PURE__ */ e(
21
21
  u,
@@ -26,7 +26,7 @@ const N = ({
26
26
  title: d,
27
27
  defaultValue: `Card link: ${d}`
28
28
  }),
29
- children: a ? y : d
29
+ children: a ? s : d
30
30
  }
31
31
  ), x = (r) => r.type === "link" ? /* @__PURE__ */ e(
32
32
  u,
@@ -39,7 +39,7 @@ const N = ({
39
39
  children: r.children
40
40
  }
41
41
  ) : /* @__PURE__ */ e(
42
- b,
42
+ k,
43
43
  {
44
44
  ...r,
45
45
  "aria-label": c("card.actionButton", {
@@ -49,12 +49,12 @@ const N = ({
49
49
  children: r.children
50
50
  }
51
51
  );
52
- return /* @__PURE__ */ i(k, { inset: t, type: C, dataTestid: s, children: [
53
- o && /* @__PURE__ */ e(T, { media: o, href: n }),
54
- /* @__PURE__ */ i(L, { inset: t, children: [
52
+ return /* @__PURE__ */ i(b, { inset: p, type: C, ...y, children: [
53
+ o && /* @__PURE__ */ e(L, { media: o, href: n }),
54
+ /* @__PURE__ */ i(T, { children: [
55
55
  /* @__PURE__ */ i(V, { children: [
56
56
  /* @__PURE__ */ e($, { children: f() }),
57
- /* @__PURE__ */ e(j, { children: p }),
57
+ t && /* @__PURE__ */ e(j, { children: t }),
58
58
  l && /* @__PURE__ */ e(A, { text: l.text, type: l.type })
59
59
  ] }),
60
60
  /* @__PURE__ */ e(B, { children: m }),
@@ -1,13 +1,12 @@
1
1
  import { Context, FC } from 'react';
2
- import { TagProps } from '../tag/tag.js';
3
- import { CardDescriptionProps, CardContainerProps, CardActionProps, CardHeaderProps, CardMediaProps, CardNextProps, CardSubtitleProps, CardTitleProps } from './types.js';
2
+ import { CardDescriptionProps, CardContainerProps, CardActionProps, CardHeaderProps, CardMediaProps, CardNextProps, CardSubtitleProps, CardTitleProps, CardTagProps } from './types.js';
4
3
  export declare function useRequiredContext(context: Context<boolean>, componentName: string, parentName: string): true;
5
4
  export declare const CardNext: FC<CardNextProps>;
6
5
  export declare const CardMedia: FC<CardMediaProps>;
7
6
  export declare const CardContainer: FC<CardContainerProps>;
8
7
  export declare const CardTitle: FC<CardTitleProps>;
9
8
  export declare const CardSubtitle: FC<CardSubtitleProps>;
10
- export declare const CardTag: FC<TagProps>;
9
+ export declare const CardTag: FC<CardTagProps>;
11
10
  export declare const CardHeader: FC<CardHeaderProps>;
12
11
  export declare const CardDescription: FC<CardDescriptionProps>;
13
12
  export declare const CardAction: FC<CardActionProps>;