@ogcio/design-system-react 1.12.4 → 1.13.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 (96) hide show
  1. package/dist/accordion/accordion-item.js +1 -1
  2. package/dist/alert/alert.js +1 -1
  3. package/dist/autocomplete/autocomplete.js +124 -198
  4. package/dist/autocomplete/types.d.ts +23 -5
  5. package/dist/autocomplete/use-autocomplete-controller.d.ts +10 -0
  6. package/dist/autocomplete/use-autocomplete-controller.js +125 -0
  7. package/dist/button/helpers.d.ts +1 -1
  8. package/dist/button/helpers.js +14 -12
  9. package/dist/button/types.d.ts +1 -1
  10. package/dist/button-group/button-group.d.ts +1 -0
  11. package/dist/button-group/button-group.js +67 -60
  12. package/dist/card/card-next.js +28 -28
  13. package/dist/checkbox/checkbox.d.ts +7 -1
  14. package/dist/combo-box/dropdown-item.js +30 -30
  15. package/dist/data-grid/editable-table-cell.d.ts +3 -0
  16. package/dist/data-grid/editable-table-cell.js +73 -0
  17. package/dist/data-grid/tanstack/tanstack-helpers.d.ts +11 -0
  18. package/dist/data-grid/tanstack/tanstack-helpers.js +1799 -0
  19. package/dist/data-grid/types.d.ts +20 -0
  20. package/dist/data-grid/types.js +1 -0
  21. package/dist/drawer/drawer.content.js +6 -6
  22. package/dist/drawer/drawer.js +8 -8
  23. package/dist/error-text/error-text.js +1 -1
  24. package/dist/forms/form-field/form-field.js +4 -4
  25. package/dist/forms/form-field-with-tag/form-field-with-tag.js +1 -1
  26. package/dist/header/components/header-slot.js +38 -27
  27. package/dist/header/header.js +5 -5
  28. package/dist/heading/heading.js +1 -1
  29. package/dist/hint-text/hint-text.js +1 -1
  30. package/dist/hooks/use-aria-hider.d.ts +1 -0
  31. package/dist/hooks/use-aria-hider.js +20 -0
  32. package/dist/hooks/use-focus-trap.d.ts +2 -0
  33. package/dist/hooks/use-focus-trap.js +678 -0
  34. package/dist/icon/icon.js +32 -32
  35. package/dist/icon/icons.d.ts +2 -2
  36. package/dist/icon/icons.js +5 -1
  37. package/dist/icon/svgs/placeholder.js +2 -2
  38. package/dist/icon-button/icon-button.js +17 -17
  39. package/dist/index-2sRBqKFV.js +78 -0
  40. package/dist/{index-DNkhmzZp.js → index-CB-zPpNk.js} +44 -44
  41. package/dist/index.d.ts +6 -4
  42. package/dist/index.js +135 -130
  43. package/dist/input-checkbox/input-checkbox.d.ts +9 -2
  44. package/dist/input-checkbox/input-checkbox.js +65 -42
  45. package/dist/input-checkbox/types.d.ts +5 -0
  46. package/dist/input-checkbox-group/input-checkbox-group.js +22 -16
  47. package/dist/input-checkbox-group/types.d.ts +1 -0
  48. package/dist/input-radio/input-radio.js +15 -15
  49. package/dist/input-radio-group/input-radio-group.js +24 -17
  50. package/dist/input-radio-group/types.d.ts +1 -0
  51. package/dist/input-text/input-text.d.ts +22 -0
  52. package/dist/input-text/input-text.js +121 -100
  53. package/dist/input-text/type.d.ts +5 -0
  54. package/dist/label/label.js +1 -1
  55. package/dist/link/link.js +1 -1
  56. package/dist/list/list.js +2 -2
  57. package/dist/lodash-D1c5hFAM.js +3677 -0
  58. package/dist/modal/modal.content.js +1 -1
  59. package/dist/modal/modal.js +141 -127
  60. package/dist/popover/popover.js +464 -466
  61. package/dist/primitives/anchor.js +1 -1
  62. package/dist/progress-bar/progress-bar.js +8 -8
  63. package/dist/progress-stepper/progress-stepper.js +12 -12
  64. package/dist/score-select/score-select.js +3 -3
  65. package/dist/select/select-menu.d.ts +1 -1
  66. package/dist/select/select-menu.js +96 -90
  67. package/dist/select/select-native.d.ts +5 -2
  68. package/dist/select/select-native.js +45 -15
  69. package/dist/select/select-next.d.ts +3 -2
  70. package/dist/select/select-next.js +125 -92
  71. package/dist/select/select-search.d.ts +3 -0
  72. package/dist/select/select-search.js +24 -0
  73. package/dist/select/select.d.ts +4 -2
  74. package/dist/select/select.js +3 -2
  75. package/dist/select/types.d.ts +22 -0
  76. package/dist/side-nav/side-nav.js +23 -23
  77. package/dist/spinner/spinner.js +1 -1
  78. package/dist/stack/stack.js +40 -49
  79. package/dist/styles.css +2 -3
  80. package/dist/table/index.d.ts +8 -0
  81. package/dist/table/index.js +19 -0
  82. package/dist/table/table-data.d.ts +16 -2
  83. package/dist/table/table-data.js +64 -17
  84. package/dist/table/table-header.d.ts +4 -1
  85. package/dist/table/table-header.js +58 -18
  86. package/dist/table/table-pagination.d.ts +8 -0
  87. package/dist/table/table-pagination.js +97 -0
  88. package/dist/table/table-row.js +7 -6
  89. package/dist/table/table.d.ts +4 -1
  90. package/dist/table/table.js +22 -15
  91. package/dist/text-input/text-input.d.ts +1 -0
  92. package/dist/textarea/textarea.js +18 -17
  93. package/dist/toast/ds-toast.js +1 -1
  94. package/dist/tooltip/tooltip.js +1 -1
  95. package/package.json +6 -6
  96. package/dist/index-ntYL1VRC.js +0 -64
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsxs as d, Fragment as u, jsx as i } from "react/jsx-runtime";
3
3
  import { useState as y, useRef as b } from "react";
4
- import { c as h } from "../index-DNkhmzZp.js";
4
+ import { c as h } from "../index-CB-zPpNk.js";
5
5
  import { cn as r } from "../cn.js";
6
6
  import { Icon as w } from "../icon/icon.js";
7
7
  const I = h({
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsxs as n, jsx as r } from "react/jsx-runtime";
3
3
  import { useState as D } from "react";
4
- import { c as h } from "../index-DNkhmzZp.js";
4
+ import { c as h } from "../index-CB-zPpNk.js";
5
5
  import { cn as v } from "../cn.js";
6
6
  import { translate as k } from "../i18n/utility.js";
7
7
  import { Icon as w } from "../icon/icon.js";
@@ -1,222 +1,142 @@
1
1
  "use client";
2
- import { jsxs as G, jsx as E } from "react/jsx-runtime";
3
- import { useRef as C, useReducer as H, useEffect as m, createElement as j, isValidElement as K, Children as X } from "react";
4
- import { cn as N } from "../cn.js";
5
- import { InputText as $ } from "../input-text/input-text.js";
6
- import { Popover as q } from "../popover/popover.js";
7
- import { SelectMenu as z, SelectMenuOption as F } from "../select/select-menu.js";
8
- import { AUTOCOMPLETE_ACTIONS as J } from "./types.js";
2
+ import { jsxs as R, jsx as h } from "react/jsx-runtime";
3
+ import { useRef as B, createElement as G } from "react";
4
+ import { cn as T } from "../cn.js";
5
+ import { translate as H } from "../i18n/utility.js";
6
+ import { InputText as M } from "../input-text/input-text.js";
7
+ import { Popover as V } from "../popover/popover.js";
8
+ import { SelectMenu as j, SelectMenuOption as K } from "../select/select-menu.js";
9
+ import { AUTOCOMPLETE_ACTIONS as X } from "./types.js";
10
+ import { useAutocompleteController as $ } from "./use-autocomplete-controller.js";
9
11
  const {
10
- ON_RESET: v,
11
- ON_SELECT_ITEM: L,
12
- SET_INPUT_VALUE: h,
13
- SET_IS_OPEN: u,
14
- SET_OPTIONS: T,
15
- TOGGLE_CLEAR_BUTTON: O,
16
- SET_VALUE: R,
17
- SET_HIGHLIGHTED_INDEX: b
18
- } = J, Q = (t, o) => {
19
- switch (o.type) {
20
- case u:
21
- return { ...t, isOpen: o.payload };
22
- case h:
23
- return { ...t, inputValue: o.payload };
24
- case T:
25
- return { ...t, autocompleteOptions: o.payload };
26
- case R:
27
- return { ...t, value: o.payload };
28
- case O:
29
- return {
30
- ...t,
31
- isClearButtonEnabled: o.payload || !!t.inputValue
32
- };
33
- case v:
34
- return {
35
- ...t,
36
- value: "",
37
- inputValue: "",
38
- isClearButtonEnabled: !1,
39
- highlightedIndex: -1
40
- };
41
- case L:
42
- return {
43
- ...t,
44
- inputValue: o.payload.inputValue,
45
- value: o.payload.value,
46
- isOpen: !1,
47
- isClearButtonEnabled: !0
48
- };
49
- case b:
50
- return { ...t, highlightedIndex: o.payload, isOpen: !0 };
51
- default:
52
- return t;
12
+ ON_RESET: q,
13
+ ON_SELECT_ITEM: z,
14
+ SET_INPUT_VALUE: F,
15
+ SET_IS_OPEN: s,
16
+ TOGGLE_CLEAR_BUTTON: _,
17
+ SET_HIGHLIGHTED_INDEX: x
18
+ } = X, J = (n) => n ? "arrow_drop_up" : "arrow_drop_down", g = (n) => (c, a) => {
19
+ if (n && a.current) {
20
+ const u = {
21
+ target: {
22
+ ...a.current,
23
+ value: c
24
+ },
25
+ currentTarget: a.current,
26
+ bubbles: !0,
27
+ isTrusted: !0
28
+ };
29
+ n == null || n(u);
53
30
  }
54
- }, W = (t, o) => {
55
- var l, y;
56
- const r = ((l = t.props.children) == null ? void 0 : l.toString().toLowerCase()) || "", s = (y = t.props.value) == null ? void 0 : y.toLowerCase(), c = o.toLowerCase();
57
- return r.includes(c) || s.includes(c);
58
- }, _ = (t) => {
59
- var r, s;
60
- const o = ((r = t == null ? void 0 : t.type) == null ? void 0 : r.componentType) || ((s = t == null ? void 0 : t.props) == null ? void 0 : s.__mdxType);
61
- return K(t) && o === "AutocompleteItem";
62
- }, S = (t) => X.toArray(t).filter((o) => _(o)) || [], I = (t, o) => {
63
- var r;
64
- return (((r = S(t).find((s) => s.props.value === o)) == null ? void 0 : r.props.children) || "").toString();
65
- }, re = ({
66
- disabled: t,
67
- children: o,
68
- defaultValue: r = "",
69
- onChange: s,
70
- ...c
71
- }) => {
72
- const l = C(null), y = C(null), x = C(!1), [n, a] = H(Q, {
73
- isOpen: !1,
74
- value: r,
75
- inputValue: r ? I(o, r) : "",
76
- autocompleteOptions: o,
77
- isClearButtonEnabled: !1,
78
- highlightedIndex: -1
79
- }), f = S(n.autocompleteOptions), V = (e) => {
80
- if (s && l.current) {
81
- const p = {
82
- target: {
83
- ...l.current,
84
- value: e
85
- },
86
- currentTarget: l.current,
87
- bubbles: !0,
88
- isTrusted: !0
89
- };
90
- s(p);
91
- }
31
+ }, re = (n) => {
32
+ var E, I;
33
+ const c = B(null), {
34
+ disabled: a,
35
+ children: u,
36
+ placeholder: C,
37
+ onSelectItem: y,
38
+ isLoading: S,
39
+ freeSolo: m = !1,
40
+ onChange: f
41
+ } = n, { state: t, dispatch: o, inputRef: i, getOptionLabelByValue: A } = $({
42
+ ...n,
43
+ onChange: g(f)
44
+ }), w = (e) => {
45
+ o({ type: s, payload: e }), e || o({ type: _, payload: !1 });
46
+ }, N = () => {
47
+ o({ type: q }), o({ type: s, payload: !1 }), g(f)("", i);
92
48
  }, k = (e) => {
93
- a({ type: u, payload: e }), e || a({ type: O, payload: !1 });
94
- }, B = (e) => {
49
+ o({ type: F, payload: e }), g(f)(e, i), e && o({ type: s, payload: !0 });
50
+ }, v = (e) => {
95
51
  const {
96
- target: { value: p }
52
+ target: { value: l }
97
53
  } = e;
98
- e.__origin === "clear_button" ? (a({ type: v }), a({ type: u, payload: !1 }), V("")) : (a({ type: h, payload: p }), p && a({ type: u, payload: !0 })), a({ type: O }), setTimeout(() => {
99
- var i;
100
- return (i = l.current) == null ? void 0 : i.focus();
54
+ e.__origin === "clear_button" ? N() : k(l), o({ type: _ }), setTimeout(() => {
55
+ var p;
56
+ return (p = i.current) == null ? void 0 : p.focus();
101
57
  });
102
- }, P = () => {
103
- var e;
104
- a({ type: u, payload: !n.isOpen }), (e = l.current) == null || e.focus();
105
58
  }, D = () => {
106
- n.isOpen || a({
107
- type: u,
59
+ var e;
60
+ o({ type: s, payload: !t.isOpen }), (e = i.current) == null || e.focus();
61
+ }, L = () => {
62
+ t.isOpen || o({
63
+ type: s,
108
64
  payload: !0
109
65
  });
110
- }, w = (e) => {
111
- a({
112
- type: L,
66
+ }, O = (e) => {
67
+ o({
68
+ type: z,
113
69
  payload: {
114
- inputValue: I(o, e),
70
+ inputValue: A(u, e),
115
71
  value: e
116
72
  }
117
- }), V(e);
118
- };
119
- m(() => {
120
- var p;
121
- const e = f.find(
122
- (i) => _(i) && i.props.value === n.value
123
- );
124
- e && a({
125
- type: h,
126
- payload: ((p = e.props.children) == null ? void 0 : p.toString()) || ""
127
- });
128
- }, [n.value]), m(() => {
129
- var p;
130
- if (!x.current) {
131
- x.current = !0;
132
- return;
133
- }
134
- n.inputValue === "" && n.value === "" && ((p = l.current) == null || p.focus());
135
- }, [n.isClearButtonEnabled]), m(() => {
136
- var e;
137
- if (n.isOpen)
138
- (e = l.current) == null || e.focus();
139
- else {
140
- const p = I(o, n.value);
141
- p && n.value ? (a({
142
- type: h,
143
- payload: p
144
- }), a({ type: u, payload: !1 })) : a({ type: v }), a({ type: O });
145
- }
146
- }, [n.isOpen]), m(() => {
147
- if (n.inputValue && o) {
148
- const e = S(o).filter(
149
- (p) => W(p, n.inputValue)
150
- );
151
- a({ type: T, payload: e }), !n.isOpen && !n.value && a({ type: u, payload: !0 });
152
- } else
153
- a({ type: R, payload: "" }), a({ type: T, payload: o });
154
- }, [n.inputValue]);
155
- const U = (e) => {
156
- const p = f.length, i = (d, M) => {
157
- let g = d;
158
- for (let A = 0; A < p; A++)
159
- if (g = (g + M + p) % p, !f[g].props.disabled)
160
- return g;
73
+ }), y && y(e);
74
+ }, P = (e) => {
75
+ const l = t.autocompleteOptions.length, p = (r, U) => {
76
+ let d = r;
77
+ for (let b = 0; b < l; b++)
78
+ if (d = (d + U + l) % l, !t.autocompleteOptions[d].props.disabled)
79
+ return d;
161
80
  return -1;
162
81
  };
163
82
  if (e.key === "ArrowDown")
164
- e.preventDefault(), a({
165
- type: b,
166
- payload: n.isOpen ? i(n.highlightedIndex, 1) : 0
83
+ e.preventDefault(), o({
84
+ type: x,
85
+ payload: t.isOpen ? p(t.highlightedIndex, 1) : 0
167
86
  });
168
87
  else if (e.key === "ArrowUp")
169
- e.preventDefault(), a({
170
- type: b,
171
- payload: i(n.highlightedIndex, -1)
88
+ e.preventDefault(), o({
89
+ type: x,
90
+ payload: p(t.highlightedIndex, -1)
172
91
  });
173
- else if (e.key === "Enter" && n.highlightedIndex >= 0) {
174
- const d = f[n.highlightedIndex];
175
- d && d.props.value && !d.props.disabled && w(d.props.value);
92
+ else if (e.key === "Enter" && t.highlightedIndex >= 0) {
93
+ const r = t.autocompleteOptions[t.highlightedIndex];
94
+ r && r.props.value && !r.props.disabled && O(r.props.value);
176
95
  }
177
96
  };
178
- return /* @__PURE__ */ G(
97
+ return /* @__PURE__ */ R(
179
98
  "div",
180
99
  {
181
- ...c,
182
- "aria-disabled": t,
183
- className: N("gi-autocomplete gi-not-prose", c.className),
100
+ ...n,
101
+ "aria-disabled": a,
102
+ className: T("gi-autocomplete gi-not-prose", n.className),
184
103
  children: [
185
- /* @__PURE__ */ E(
186
- $,
104
+ /* @__PURE__ */ h(
105
+ M,
187
106
  {
188
- onKeyDown: U,
189
- onIconEndClick: P,
190
- onChange: B,
191
- onClick: D,
192
- clearButtonEnabled: n.isClearButtonEnabled,
107
+ onKeyDown: P,
108
+ onIconEndClick: D,
109
+ onChange: v,
110
+ onClick: L,
111
+ clearButtonEnabled: t.isClearButtonEnabled,
193
112
  inputActionPosition: "beforeSuffix",
194
113
  "aria-label": "Type to Search",
195
- "aria-disabled": t,
196
- disabled: t,
197
- placeholder: n.inputValue || "Type to Search",
198
- iconEndClassName: N({
199
- "gi-cursor-pointer": !t,
200
- "gi-cursor-not-allowed gi-pointer-events-none": t
114
+ "aria-disabled": a,
115
+ disabled: a,
116
+ placeholder: C || H("autocomplete.placeholder"),
117
+ iconEndClassName: T({
118
+ "gi-cursor-pointer": !a && !m,
119
+ "gi-cursor-not-allowed gi-pointer-events-none": a && !m
201
120
  }),
202
- iconEnd: n.isOpen ? "arrow_drop_up" : "arrow_drop_down",
203
- ref: l,
204
- iconEndRef: y,
205
- value: n.inputValue,
206
- "data-highlighted-index": n.highlightedIndex
121
+ iconEnd: m ? void 0 : J(t.isOpen),
122
+ ref: i,
123
+ iconEndRef: c,
124
+ value: t.inputValue,
125
+ "data-highlighted-index": t.highlightedIndex
207
126
  }
208
127
  ),
209
- /* @__PURE__ */ E(
210
- q,
128
+ /* @__PURE__ */ h(
129
+ V,
211
130
  {
212
- onOpenChange: k,
213
- triggerRef: l,
214
- extraRefs: [y],
215
- open: n.isOpen,
131
+ onOpenChange: w,
132
+ triggerRef: i,
133
+ extraRefs: [c],
134
+ open: t.isOpen,
216
135
  options: {
217
136
  placement: "bottom-start",
218
137
  strategy: "absolute",
219
138
  modifiers: [
139
+ { name: "offset", options: { offset: [0, 4] } },
220
140
  { name: "preventOverflow", options: { padding: 8 } },
221
141
  {
222
142
  name: "flip",
@@ -224,29 +144,35 @@ const {
224
144
  }
225
145
  ]
226
146
  },
227
- children: /* @__PURE__ */ E(z, { onChange: w, children: f.map(
228
- (e, p) => _(e) ? /* @__PURE__ */ j(
229
- F,
230
- {
231
- ...e.props,
232
- key: `AutocompleteItem-${e.props.value}`,
233
- selected: n.value === e.props.value,
234
- isHighlighted: p === n.highlightedIndex
235
- }
236
- ) : null
237
- ) })
147
+ children: /* @__PURE__ */ h(
148
+ j,
149
+ {
150
+ onChange: O,
151
+ isLoading: S,
152
+ showNoData: !((E = t.autocompleteOptions) != null && E.length),
153
+ children: (I = t.autocompleteOptions) == null ? void 0 : I.map((e, l) => /* @__PURE__ */ G(
154
+ K,
155
+ {
156
+ ...e.props,
157
+ key: `AutocompleteItem-${e.props.value}`,
158
+ selected: t.value === e.props.value,
159
+ isHighlighted: l === t.highlightedIndex
160
+ }
161
+ ))
162
+ }
163
+ )
238
164
  }
239
165
  )
240
166
  ]
241
167
  }
242
168
  );
243
- }, Y = () => null;
244
- Object.defineProperty(Y, "componentType", {
169
+ }, Q = () => null;
170
+ Object.defineProperty(Q, "componentType", {
245
171
  value: "AutocompleteItem",
246
172
  writable: !1,
247
173
  enumerable: !1
248
174
  });
249
175
  export {
250
176
  re as Autocomplete,
251
- Y as AutocompleteItem
177
+ Q as AutocompleteItem
252
178
  };
@@ -1,4 +1,4 @@
1
- import { ReactElement } from 'react';
1
+ import { ChangeEvent, ReactElement } from 'react';
2
2
  import { SelectMenuOptionProps } from '../select/types.js';
3
3
  export declare const AUTOCOMPLETE_ACTIONS: {
4
4
  readonly SET_IS_OPEN: "SET_IS_OPEN";
@@ -15,7 +15,7 @@ export type AutocompleteState = {
15
15
  value: string;
16
16
  inputValue: string;
17
17
  isClearButtonEnabled: boolean;
18
- autocompleteOptions: React.ReactNode;
18
+ autocompleteOptions: any[];
19
19
  highlightedIndex: number;
20
20
  };
21
21
  export type AutocompleteAction = {
@@ -26,7 +26,7 @@ export type AutocompleteAction = {
26
26
  payload: string;
27
27
  } | {
28
28
  type: typeof AUTOCOMPLETE_ACTIONS.SET_OPTIONS;
29
- payload: React.ReactNode;
29
+ payload: any[];
30
30
  } | {
31
31
  type: typeof AUTOCOMPLETE_ACTIONS.SET_VALUE;
32
32
  payload: string;
@@ -49,9 +49,27 @@ export type AutocompleteOptionItemElement = ReactElement<SelectMenuOptionProps &
49
49
  selectedValue: string;
50
50
  }>;
51
51
  export type AutocompleteProps = {
52
- defaultValue?: string;
53
- onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
54
52
  children: ReactElement<AutocompleteItemProps> | ReactElement<AutocompleteItemProps>[];
53
+ /** Unique identifier for the autocomplete component. */
54
+ id?: string;
55
+ /** Initial selected value when the component is first rendered. */
56
+ defaultValue?: string;
57
+ /** When true, disables the autocomplete input and prevents user interaction. */
58
+ disabled?: boolean;
59
+ /** Callback function triggered when the input value changes */
60
+ onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
61
+ /** Enables typing freeform values not limited to the dropdown options and keep the value inside the Input. */
62
+ freeSolo?: boolean;
63
+ /** Displays loading spinner inside the dropdown list. */
64
+ isLoading?: boolean;
65
+ /** Callback triggered when an option is selected from the dropdown. */
66
+ onSelectItem?: (item: string) => void;
67
+ /** Callback triggered when the dropdown is opened. */
68
+ onOpen?: () => void;
69
+ /** Callback triggered when the dropdown is closed. */
70
+ onClose?: () => void;
71
+ /** Controls whether the dropdown is open (controlled mode). */
72
+ isOpen?: boolean;
55
73
  } & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'defaultChecked'>;
56
74
  export type AutocompleteItemProps = {
57
75
  children: string;
@@ -0,0 +1,10 @@
1
+ import { AutocompleteAction, AutocompleteState, AutocompleteOptionItemElement, AutocompleteProps } from './types.js';
2
+ export declare const useAutocompleteController: ({ children, defaultValue, isOpen, freeSolo, onOpen, onClose, onChange, }: {
3
+ onChange?: (input: string, inputRef: any) => void;
4
+ } & Pick<AutocompleteProps, "children" | "defaultValue" | "isOpen" | "freeSolo" | "onOpen" | "onClose">) => {
5
+ state: AutocompleteState;
6
+ dispatch: import('react').ActionDispatch<[action: AutocompleteAction]>;
7
+ inputRef: import('react').RefObject<HTMLInputElement | null>;
8
+ validChildren: AutocompleteOptionItemElement[];
9
+ getOptionLabelByValue: (children: AutocompleteProps["children"], value: string) => string;
10
+ };
@@ -0,0 +1,125 @@
1
+ import { l as B } from "../lodash-D1c5hFAM.js";
2
+ import { useRef as _, useMemo as v, Children as x, useReducer as R, useEffect as y, isValidElement as U } from "react";
3
+ import { AUTOCOMPLETE_ACTIONS as w } from "./types.js";
4
+ const {
5
+ ON_RESET: V,
6
+ ON_SELECT_ITEM: C,
7
+ SET_INPUT_VALUE: L,
8
+ SET_IS_OPEN: f,
9
+ SET_OPTIONS: c,
10
+ TOGGLE_CLEAR_BUTTON: b,
11
+ SET_VALUE: E,
12
+ SET_HIGHLIGHTED_INDEX: G
13
+ } = w, M = (e, t) => {
14
+ switch (t.type) {
15
+ case f:
16
+ return { ...e, isOpen: t.payload };
17
+ case L:
18
+ return { ...e, inputValue: t.payload };
19
+ case c:
20
+ return { ...e, autocompleteOptions: t.payload || [] };
21
+ case E:
22
+ return { ...e, value: t.payload };
23
+ case b:
24
+ return {
25
+ ...e,
26
+ isClearButtonEnabled: t.payload || !!e.inputValue
27
+ };
28
+ case V:
29
+ return {
30
+ ...e,
31
+ value: "",
32
+ inputValue: "",
33
+ isClearButtonEnabled: !1,
34
+ highlightedIndex: -1
35
+ };
36
+ case C:
37
+ return {
38
+ ...e,
39
+ inputValue: t.payload.inputValue,
40
+ value: t.payload.value,
41
+ isOpen: !1,
42
+ isClearButtonEnabled: !0
43
+ };
44
+ case G:
45
+ return { ...e, highlightedIndex: t.payload, isOpen: !0 };
46
+ default:
47
+ return e;
48
+ }
49
+ }, P = (e) => {
50
+ var p, r;
51
+ const t = ((p = e == null ? void 0 : e.type) == null ? void 0 : p.componentType) || ((r = e == null ? void 0 : e.props) == null ? void 0 : r.__mdxType);
52
+ return U(e) && t === "AutocompleteItem";
53
+ }, H = (e, t) => {
54
+ var i, a;
55
+ const p = ((i = e.props.children) == null ? void 0 : i.toString().toLowerCase()) || "", r = (a = e.props.value) == null ? void 0 : a.toLowerCase(), o = t.toLowerCase();
56
+ return p.includes(o) || r.includes(o);
57
+ }, S = (e) => x.toArray(e).filter((t) => P(t)) || [], I = (e, t) => {
58
+ var p;
59
+ return (((p = S(e).find((r) => r.props.value === t)) == null ? void 0 : p.props.children) || "").toString();
60
+ }, X = ({
61
+ children: e,
62
+ defaultValue: t = "",
63
+ isOpen: p = !1,
64
+ freeSolo: r = !1,
65
+ onOpen: o,
66
+ onClose: i,
67
+ onChange: a
68
+ }) => {
69
+ const d = _(null), T = _(!1), n = v(
70
+ () => S(e || []),
71
+ [e]
72
+ ), O = () => {
73
+ var s;
74
+ return (s = d.current) == null ? void 0 : s.focus();
75
+ }, [u, l] = R(M, null, () => ({
76
+ isOpen: !!p,
77
+ value: t,
78
+ inputValue: t,
79
+ autocompleteOptions: n,
80
+ isClearButtonEnabled: !1,
81
+ highlightedIndex: -1
82
+ }));
83
+ y(() => {
84
+ l({ type: c, payload: n });
85
+ }, [n]), y(() => {
86
+ if (!T.current) {
87
+ T.current = !0;
88
+ return;
89
+ }
90
+ u.inputValue === "" && u.value === "" && O();
91
+ }, [u.isClearButtonEnabled]), y(() => {
92
+ if (u.isOpen)
93
+ o == null || o(), O();
94
+ else {
95
+ i == null || i();
96
+ const s = I(e, u.value);
97
+ s && u.value ? (l({
98
+ type: L,
99
+ payload: s
100
+ }), l({ type: f, payload: !1 }), a == null || a(s, d)) : r || (l({ type: V }), a == null || a("", d)), l({ type: b });
101
+ }
102
+ }, [u.isOpen]);
103
+ const m = v(
104
+ () => B.debounce((s) => {
105
+ if (s) {
106
+ const A = n.filter(
107
+ (N) => H(N, s)
108
+ );
109
+ l({ type: c, payload: A }), !u.isOpen && !u.value && l({ type: f, payload: !0 }), r && l({ type: E, payload: "" });
110
+ } else
111
+ l({ type: E, payload: "" }), l({ type: c, payload: n });
112
+ }, 500),
113
+ [n, u.isOpen, u.value, r]
114
+ );
115
+ return y(() => (m(u.inputValue), () => m.cancel()), [u.inputValue]), {
116
+ state: u,
117
+ dispatch: l,
118
+ inputRef: d,
119
+ validChildren: n,
120
+ getOptionLabelByValue: I
121
+ };
122
+ };
123
+ export {
124
+ X as useAutocompleteController
125
+ };
@@ -5,7 +5,7 @@ export declare const getVariantAppearanceClass: ({ disabled, variant, appearance
5
5
  appearance?: ButtonAppearance;
6
6
  }) => string | undefined;
7
7
  export declare const getSizeClass: (size?: ButtonSize) => "gi-btn-small" | "gi-btn-large" | "gi-btn-regular";
8
- export declare const getButtonIconSizeClass: (size?: ButtonSize) => "gi-icon-btn-small" | "gi-icon-btn-large" | "gi-icon-btn-regular";
8
+ export declare const getButtonIconSizeClass: (size?: ButtonSize) => "gi-icon-btn-small" | "gi-icon-btn-large" | "gi-icon-btn-extra-large" | "gi-icon-btn-regular";
9
9
  export declare const isButtonDisabled: ({ disabled, variant, appearance, }: {
10
10
  disabled?: boolean;
11
11
  variant?: ButtonVariant;
@@ -1,12 +1,12 @@
1
1
  const s = ({
2
- disabled: t,
2
+ disabled: l,
3
3
  variant: e,
4
- appearance: l
4
+ appearance: t
5
5
  }) => {
6
6
  let i;
7
- return t || (e === "secondary" ? l === "dark" ? i = "gi-btn-secondary-dark" : l === "light" ? i = "gi-btn-secondary-light" : i = "gi-btn-secondary" : e === "flat" ? l === "dark" ? i = "gi-btn-flat-dark" : l === "light" ? i = "gi-btn-flat-light" : i = "gi-btn-flat" : l === "dark" ? i = "gi-btn-primary-dark" : l === "light" ? i = "gi-btn-primary-light" : i = "gi-btn-primary"), i;
8
- }, r = (t) => {
9
- switch (t) {
7
+ return l || (e === "secondary" ? t === "dark" ? i = "gi-btn-secondary-dark" : t === "light" ? i = "gi-btn-secondary-light" : i = "gi-btn-secondary" : e === "flat" ? t === "dark" ? i = "gi-btn-flat-dark" : t === "light" ? i = "gi-btn-flat-light" : i = "gi-btn-flat" : t === "dark" ? i = "gi-btn-primary-dark" : t === "light" ? i = "gi-btn-primary-light" : i = "gi-btn-primary"), i;
8
+ }, r = (l) => {
9
+ switch (l) {
10
10
  case "small":
11
11
  return "gi-btn-small";
12
12
  case "large":
@@ -14,26 +14,28 @@ const s = ({
14
14
  default:
15
15
  return "gi-btn-regular";
16
16
  }
17
- }, g = (t) => {
18
- switch (t) {
17
+ }, g = (l) => {
18
+ switch (l) {
19
19
  case "small":
20
20
  return "gi-icon-btn-small";
21
21
  case "large":
22
22
  return "gi-icon-btn-large";
23
+ case "extraLarge":
24
+ return "gi-icon-btn-extra-large";
23
25
  default:
24
26
  return "gi-icon-btn-regular";
25
27
  }
26
- }, d = ({
27
- disabled: t,
28
+ }, n = ({
29
+ disabled: l,
28
30
  variant: e,
29
- appearance: l
31
+ appearance: t
30
32
  }) => {
31
33
  let i;
32
- return t && (e === "secondary" ? l === "dark" ? i = "gi-btn-secondary-dark-disabled" : l === "light" ? i = "gi-btn-secondary-light-disabled" : i = "gi-btn-secondary-disabled" : e === "flat" ? l === "dark" ? i = "gi-btn-flat-dark-disabled" : l === "light" ? i = "gi-btn-flat-light-disabled" : i = "gi-btn-flat-disabled" : l === "dark" ? i = "gi-btn-primary-dark-disabled" : l === "light" ? i = "gi-btn-primary-light-disabled" : i = "gi-btn-primary-disabled"), i;
34
+ return l && (e === "secondary" ? t === "dark" ? i = "gi-btn-secondary-dark-disabled" : t === "light" ? i = "gi-btn-secondary-light-disabled" : i = "gi-btn-secondary-disabled" : e === "flat" ? t === "dark" ? i = "gi-btn-flat-dark-disabled" : t === "light" ? i = "gi-btn-flat-light-disabled" : i = "gi-btn-flat-disabled" : t === "dark" ? i = "gi-btn-primary-dark-disabled" : t === "light" ? i = "gi-btn-primary-light-disabled" : i = "gi-btn-primary-disabled"), i;
33
35
  };
34
36
  export {
35
37
  g as getButtonIconSizeClass,
36
38
  r as getSizeClass,
37
39
  s as getVariantAppearanceClass,
38
- d as isButtonDisabled
40
+ n as isButtonDisabled
39
41
  };
@@ -1,7 +1,7 @@
1
1
  export declare const ButtonVariants: readonly ["primary", "secondary", "flat"];
2
2
  export type ButtonVariant = (typeof ButtonVariants)[number];
3
3
  export type ButtonAppearance = 'default' | 'dark' | 'light';
4
- export type ButtonSize = 'medium' | 'small' | 'large';
4
+ export type ButtonSize = 'medium' | 'small' | 'large' | 'extraLarge';
5
5
  export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
6
6
  variant?: ButtonVariant;
7
7
  appearance?: ButtonAppearance;