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