@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.
- package/dist/accordion/accordion-item.js +1 -1
- package/dist/alert/alert.js +1 -1
- package/dist/autocomplete/autocomplete.js +124 -198
- package/dist/autocomplete/types.d.ts +23 -5
- package/dist/autocomplete/use-autocomplete-controller.d.ts +10 -0
- package/dist/autocomplete/use-autocomplete-controller.js +125 -0
- package/dist/button/helpers.d.ts +1 -1
- package/dist/button/helpers.js +14 -12
- package/dist/button/types.d.ts +1 -1
- package/dist/button-group/button-group.d.ts +1 -0
- package/dist/button-group/button-group.js +67 -60
- package/dist/card/card-next.js +28 -28
- package/dist/checkbox/checkbox.d.ts +7 -1
- package/dist/combo-box/dropdown-item.js +30 -30
- package/dist/data-grid/editable-table-cell.d.ts +3 -0
- package/dist/data-grid/editable-table-cell.js +73 -0
- package/dist/data-grid/tanstack/tanstack-helpers.d.ts +11 -0
- package/dist/data-grid/tanstack/tanstack-helpers.js +1799 -0
- package/dist/data-grid/types.d.ts +20 -0
- package/dist/data-grid/types.js +1 -0
- package/dist/drawer/drawer.content.js +6 -6
- package/dist/drawer/drawer.js +8 -8
- package/dist/error-text/error-text.js +1 -1
- package/dist/forms/form-field/form-field.js +4 -4
- package/dist/forms/form-field-with-tag/form-field-with-tag.js +1 -1
- package/dist/header/components/header-slot.js +38 -27
- package/dist/header/header.js +5 -5
- package/dist/heading/heading.js +1 -1
- package/dist/hint-text/hint-text.js +1 -1
- package/dist/hooks/use-aria-hider.d.ts +1 -0
- package/dist/hooks/use-aria-hider.js +20 -0
- package/dist/hooks/use-focus-trap.d.ts +2 -0
- package/dist/hooks/use-focus-trap.js +678 -0
- package/dist/icon/icon.js +32 -32
- package/dist/icon/icons.d.ts +2 -2
- package/dist/icon/icons.js +5 -1
- package/dist/icon/svgs/placeholder.js +2 -2
- package/dist/icon-button/icon-button.js +17 -17
- package/dist/index-2sRBqKFV.js +78 -0
- package/dist/{index-DNkhmzZp.js → index-CB-zPpNk.js} +44 -44
- package/dist/index.d.ts +6 -4
- package/dist/index.js +135 -130
- package/dist/input-checkbox/input-checkbox.d.ts +9 -2
- package/dist/input-checkbox/input-checkbox.js +65 -42
- package/dist/input-checkbox/types.d.ts +5 -0
- package/dist/input-checkbox-group/input-checkbox-group.js +22 -16
- package/dist/input-checkbox-group/types.d.ts +1 -0
- package/dist/input-radio/input-radio.js +15 -15
- package/dist/input-radio-group/input-radio-group.js +24 -17
- package/dist/input-radio-group/types.d.ts +1 -0
- package/dist/input-text/input-text.d.ts +22 -0
- package/dist/input-text/input-text.js +121 -100
- package/dist/input-text/type.d.ts +5 -0
- package/dist/label/label.js +1 -1
- package/dist/link/link.js +1 -1
- package/dist/list/list.js +2 -2
- package/dist/lodash-D1c5hFAM.js +3677 -0
- package/dist/modal/modal.content.js +1 -1
- package/dist/modal/modal.js +141 -127
- package/dist/popover/popover.js +464 -466
- package/dist/primitives/anchor.js +1 -1
- package/dist/progress-bar/progress-bar.js +8 -8
- package/dist/progress-stepper/progress-stepper.js +12 -12
- package/dist/score-select/score-select.js +3 -3
- package/dist/select/select-menu.d.ts +1 -1
- package/dist/select/select-menu.js +96 -90
- package/dist/select/select-native.d.ts +5 -2
- package/dist/select/select-native.js +45 -15
- package/dist/select/select-next.d.ts +3 -2
- package/dist/select/select-next.js +125 -92
- package/dist/select/select-search.d.ts +3 -0
- package/dist/select/select-search.js +24 -0
- package/dist/select/select.d.ts +4 -2
- package/dist/select/select.js +3 -2
- package/dist/select/types.d.ts +22 -0
- package/dist/side-nav/side-nav.js +23 -23
- package/dist/spinner/spinner.js +1 -1
- package/dist/stack/stack.js +40 -49
- package/dist/styles.css +2 -3
- package/dist/table/index.d.ts +8 -0
- package/dist/table/index.js +19 -0
- package/dist/table/table-data.d.ts +16 -2
- package/dist/table/table-data.js +64 -17
- package/dist/table/table-header.d.ts +4 -1
- package/dist/table/table-header.js +58 -18
- package/dist/table/table-pagination.d.ts +8 -0
- package/dist/table/table-pagination.js +97 -0
- package/dist/table/table-row.js +7 -6
- package/dist/table/table.d.ts +4 -1
- package/dist/table/table.js +22 -15
- package/dist/text-input/text-input.d.ts +1 -0
- package/dist/textarea/textarea.js +18 -17
- package/dist/toast/ds-toast.js +1 -1
- package/dist/tooltip/tooltip.js +1 -1
- package/package.json +6 -6
- 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-
|
|
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({
|
package/dist/alert/alert.js
CHANGED
|
@@ -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-
|
|
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
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { cn as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
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:
|
|
11
|
-
ON_SELECT_ITEM:
|
|
12
|
-
SET_INPUT_VALUE:
|
|
13
|
-
SET_IS_OPEN:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
},
|
|
55
|
-
var
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
94
|
-
},
|
|
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:
|
|
52
|
+
target: { value: l }
|
|
97
53
|
} = e;
|
|
98
|
-
e.__origin === "clear_button" ? (
|
|
99
|
-
var
|
|
100
|
-
return (
|
|
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
|
-
|
|
107
|
-
|
|
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
|
-
},
|
|
111
|
-
|
|
112
|
-
type:
|
|
66
|
+
}, O = (e) => {
|
|
67
|
+
o({
|
|
68
|
+
type: z,
|
|
113
69
|
payload: {
|
|
114
|
-
inputValue:
|
|
70
|
+
inputValue: A(u, e),
|
|
115
71
|
value: e
|
|
116
72
|
}
|
|
117
|
-
}),
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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(),
|
|
165
|
-
type:
|
|
166
|
-
payload:
|
|
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(),
|
|
170
|
-
type:
|
|
171
|
-
payload:
|
|
88
|
+
e.preventDefault(), o({
|
|
89
|
+
type: x,
|
|
90
|
+
payload: p(t.highlightedIndex, -1)
|
|
172
91
|
});
|
|
173
|
-
else if (e.key === "Enter" &&
|
|
174
|
-
const
|
|
175
|
-
|
|
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__ */
|
|
97
|
+
return /* @__PURE__ */ R(
|
|
179
98
|
"div",
|
|
180
99
|
{
|
|
181
|
-
...
|
|
182
|
-
"aria-disabled":
|
|
183
|
-
className:
|
|
100
|
+
...n,
|
|
101
|
+
"aria-disabled": a,
|
|
102
|
+
className: T("gi-autocomplete gi-not-prose", n.className),
|
|
184
103
|
children: [
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
|
|
104
|
+
/* @__PURE__ */ h(
|
|
105
|
+
M,
|
|
187
106
|
{
|
|
188
|
-
onKeyDown:
|
|
189
|
-
onIconEndClick:
|
|
190
|
-
onChange:
|
|
191
|
-
onClick:
|
|
192
|
-
clearButtonEnabled:
|
|
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":
|
|
196
|
-
disabled:
|
|
197
|
-
placeholder:
|
|
198
|
-
iconEndClassName:
|
|
199
|
-
"gi-cursor-pointer": !
|
|
200
|
-
"gi-cursor-not-allowed gi-pointer-events-none":
|
|
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:
|
|
203
|
-
ref:
|
|
204
|
-
iconEndRef:
|
|
205
|
-
value:
|
|
206
|
-
"data-highlighted-index":
|
|
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__ */
|
|
210
|
-
|
|
128
|
+
/* @__PURE__ */ h(
|
|
129
|
+
V,
|
|
211
130
|
{
|
|
212
|
-
onOpenChange:
|
|
213
|
-
triggerRef:
|
|
214
|
-
extraRefs: [
|
|
215
|
-
open:
|
|
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__ */
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
},
|
|
244
|
-
Object.defineProperty(
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
+
};
|
package/dist/button/helpers.d.ts
CHANGED
|
@@ -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;
|
package/dist/button/helpers.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const s = ({
|
|
2
|
-
disabled:
|
|
2
|
+
disabled: l,
|
|
3
3
|
variant: e,
|
|
4
|
-
appearance:
|
|
4
|
+
appearance: t
|
|
5
5
|
}) => {
|
|
6
6
|
let i;
|
|
7
|
-
return
|
|
8
|
-
}, r = (
|
|
9
|
-
switch (
|
|
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 = (
|
|
18
|
-
switch (
|
|
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
|
-
},
|
|
27
|
-
disabled:
|
|
28
|
+
}, n = ({
|
|
29
|
+
disabled: l,
|
|
28
30
|
variant: e,
|
|
29
|
-
appearance:
|
|
31
|
+
appearance: t
|
|
30
32
|
}) => {
|
|
31
33
|
let i;
|
|
32
|
-
return
|
|
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
|
-
|
|
40
|
+
n as isButtonDisabled
|
|
39
41
|
};
|
package/dist/button/types.d.ts
CHANGED
|
@@ -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;
|