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