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