@ogcio/design-system-react 1.24.0 → 1.25.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/README.md +5 -5
- package/dist/autocomplete/autocomplete.js +105 -101
- package/dist/autocomplete/use-autocomplete-controller.js +60 -58
- package/dist/browser-support/browser-support.d.ts +6 -0
- package/dist/browser-support/browser-support.js +2202 -0
- package/dist/browser-support/index.d.ts +1 -0
- package/dist/browser-support/index.js +4 -0
- package/dist/constants.d.ts +43 -0
- package/dist/constants.js +46 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +193 -190
- package/dist/pagination/pagination.js +305 -565
- package/dist/side-nav/index.d.ts +2 -0
- package/dist/side-nav/index.js +6 -0
- package/dist/side-nav/side-nav.d.ts +2 -1
- package/dist/side-nav/side-nav.js +119 -98
- package/dist/side-nav/types.d.ts +4 -0
- package/dist/styles.css +1 -1
- package/dist/useTranslation-BmIU4GBA.js +272 -0
- package/package.json +7 -10
- package/dist/browser-support/runtime.d.ts +0 -43
- package/dist/browser-support/runtime.js +0 -282
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**This library should only be imported for departments actively working with the core design system team during its development. Do not use this library if you are not part of this development process, and contact the design system team instead if you interested in its use.**
|
|
4
4
|
|
|
5
|
-
Welcome to the
|
|
5
|
+
Welcome to the Government of Ireland Design System React component library, a collection of reusable React components designed to help you build modern React web applications utilising the Government of Ireland Design System.
|
|
6
6
|
|
|
7
7
|
## Getting Started
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ npm install @ogcio/design-system-react @ogcio/theme-govie
|
|
|
14
14
|
|
|
15
15
|
### Pinning packages
|
|
16
16
|
|
|
17
|
-
We **strongly recommend** that you pin the
|
|
17
|
+
We **strongly recommend** that you pin the Government of Ireland Design System packages, so that any regressions are not automatically introduced during development. Regressions that will only be discoverable at runtime.
|
|
18
18
|
|
|
19
19
|
**Upgrades should be explicit version updates** in the `package.json` and then your application should be regression tested:
|
|
20
20
|
|
|
@@ -28,7 +28,7 @@ We **strongly recommend** that you pin the GOV IE design system packages, so tha
|
|
|
28
28
|
|
|
29
29
|
### Usage
|
|
30
30
|
|
|
31
|
-
Import the
|
|
31
|
+
Import the Government of Ireland `theme.css` from the `@ogcio/theme-govie` theme package at the entry point of your application, for example:
|
|
32
32
|
|
|
33
33
|
```diff
|
|
34
34
|
+import '@ogcio/theme-govie/theme.css'
|
|
@@ -58,7 +58,7 @@ export function MyComponent() {
|
|
|
58
58
|
|
|
59
59
|
### Typography
|
|
60
60
|
|
|
61
|
-
The `@ogcio/design-system-react` package contains `Heading` and `Paragraph` components that implement the
|
|
61
|
+
The `@ogcio/design-system-react` package contains `Heading` and `Paragraph` components that implement the Government of Ireland Design System responsive text guidelines:
|
|
62
62
|
|
|
63
63
|
```jsx
|
|
64
64
|
import { Heading, Paragraph } from '@ogcio/design-system-react';
|
|
@@ -73,7 +73,7 @@ function MyComponent() {
|
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
The
|
|
76
|
+
The Government of Ireland Design System uses the [Lato](https://fonts.google.com/specimen/Lato) Google font. The font should be added to your application, e.g. via [next/font](https://nextjs.org/docs/app/building-your-application/optimizing/fonts), [Fontsource](https://fontsource.org/docs/getting-started/install) or embed code.
|
|
77
77
|
|
|
78
78
|
### Internationalization (i18n) Guidelines
|
|
79
79
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { cn as
|
|
2
|
+
import { jsxs as z, jsx as h } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as J, useRef as N, useImperativeHandle as Q, useEffect as W, useCallback as D, createElement as Y, Children as Z, isValidElement as ee } from "react";
|
|
4
|
+
import { cn as P } from "../cn.js";
|
|
5
5
|
import { useDomId as te } from "../hooks/use-dom-id.js";
|
|
6
|
-
import { translate as
|
|
6
|
+
import { translate as G } from "../i18n/utility.js";
|
|
7
7
|
import { InputText as oe } from "../input-text/input-text.js";
|
|
8
8
|
import { Popover as ne } from "../popover/popover.js";
|
|
9
|
-
import { SelectMenu as ae, SelectMenuOption as
|
|
9
|
+
import { SelectMenu as ae, SelectMenuOption as L, SelectMenuGroupItem as re } from "../select/select-menu.js";
|
|
10
10
|
import { cycleEnabledIndex as le } from "../utilities.js";
|
|
11
11
|
import { AUTOCOMPLETE_ACTIONS as pe } from "./types.js";
|
|
12
12
|
import { useAutocompleteController as ie } from "./use-autocomplete-controller.js";
|
|
13
13
|
const {
|
|
14
14
|
ON_RESET: se,
|
|
15
15
|
ON_SELECT_ITEM: ce,
|
|
16
|
-
SET_INPUT_VALUE:
|
|
17
|
-
SET_IS_OPEN:
|
|
16
|
+
SET_INPUT_VALUE: R,
|
|
17
|
+
SET_IS_OPEN: i,
|
|
18
18
|
TOGGLE_CLEAR_BUTTON: C,
|
|
19
19
|
SET_HIGHLIGHTED_INDEX: ue,
|
|
20
20
|
SET_VALUE: de
|
|
21
|
-
} = pe, me = (a) => a ? "keyboard_arrow_up" : "keyboard_arrow_down",
|
|
21
|
+
} = pe, me = (a) => a ? "keyboard_arrow_up" : "keyboard_arrow_down", T = (a, r) => (p) => {
|
|
22
22
|
a && a({
|
|
23
23
|
target: { name: r, value: p },
|
|
24
24
|
currentTarget: { name: r, value: p },
|
|
@@ -34,155 +34,159 @@ const {
|
|
|
34
34
|
bubbles: !0,
|
|
35
35
|
isTrusted: !0
|
|
36
36
|
});
|
|
37
|
-
},
|
|
37
|
+
}, ke = J(
|
|
38
38
|
(a, r) => {
|
|
39
39
|
var x;
|
|
40
40
|
const p = N(null), {
|
|
41
41
|
disabled: l,
|
|
42
|
-
children:
|
|
43
|
-
placeholder:
|
|
44
|
-
onSelectItem:
|
|
42
|
+
children: c,
|
|
43
|
+
placeholder: y,
|
|
44
|
+
onSelectItem: m,
|
|
45
45
|
isLoading: g,
|
|
46
|
-
freeSolo:
|
|
46
|
+
freeSolo: s = !1,
|
|
47
47
|
onChange: b,
|
|
48
|
-
onBlur:
|
|
49
|
-
name:
|
|
48
|
+
onBlur: B,
|
|
49
|
+
name: u,
|
|
50
50
|
value: E,
|
|
51
|
-
id:
|
|
51
|
+
id: M
|
|
52
52
|
} = a, v = N(!1), {
|
|
53
53
|
state: t,
|
|
54
54
|
dispatch: o,
|
|
55
|
-
inputRef:
|
|
55
|
+
inputRef: f,
|
|
56
56
|
getOptionLabelByValue: S,
|
|
57
57
|
listRef: A,
|
|
58
|
-
debouncedFilter:
|
|
58
|
+
debouncedFilter: U,
|
|
59
|
+
validChildren: be
|
|
59
60
|
} = ie({
|
|
60
61
|
...a,
|
|
61
|
-
onChange:
|
|
62
|
+
onChange: T(b, u)
|
|
62
63
|
}), _ = te();
|
|
63
|
-
|
|
64
|
+
Q(r, () => f.current), W(() => {
|
|
64
65
|
E !== void 0 && (o({ type: de, payload: E }), o({
|
|
65
|
-
type:
|
|
66
|
-
payload: S(
|
|
66
|
+
type: R,
|
|
67
|
+
payload: S(c, E)
|
|
67
68
|
}), o({ type: C }));
|
|
68
69
|
}, [E]);
|
|
69
|
-
const w = a["aria-label"] ??
|
|
70
|
-
o({ type:
|
|
71
|
-
},
|
|
72
|
-
o({ type: se }), o({ type:
|
|
73
|
-
}, H = (e) => {
|
|
74
|
-
o({ type: L, payload: e }), i && O(b, d)(e), e && o({ type: s, payload: !0 }), M(e);
|
|
70
|
+
const w = a["aria-label"] ?? G("autocomplete.placeholder", { defaultValue: "Type to Search" }), V = (e) => {
|
|
71
|
+
o({ type: i, payload: e }), e || o({ type: C, payload: !1 });
|
|
72
|
+
}, H = () => {
|
|
73
|
+
o({ type: se }), o({ type: i, payload: !1 }), T(b, u)("");
|
|
75
74
|
}, j = (e) => {
|
|
75
|
+
o({ type: R, payload: e }), s && T(b, u)(e), e && o({ type: i, payload: !0 }), U(e);
|
|
76
|
+
}, $ = (e) => {
|
|
76
77
|
const {
|
|
77
78
|
target: { value: n }
|
|
78
79
|
} = e;
|
|
79
|
-
e.__origin === "clear_button"
|
|
80
|
-
var
|
|
81
|
-
return (
|
|
82
|
-
});
|
|
83
|
-
}, $ = () => {
|
|
84
|
-
var e;
|
|
85
|
-
o({ type: s, payload: !t.isOpen }), (e = m.current) == null || e.focus();
|
|
80
|
+
e.__origin === "clear_button" && H(), !/^\s/.test(n) && (j(n), o({ type: C }), setTimeout(() => {
|
|
81
|
+
var d;
|
|
82
|
+
return (d = f.current) == null ? void 0 : d.focus();
|
|
83
|
+
}));
|
|
86
84
|
}, K = () => {
|
|
85
|
+
var e;
|
|
86
|
+
o({ type: i, payload: !t.isOpen }), (e = f.current) == null || e.focus();
|
|
87
|
+
}, F = () => {
|
|
87
88
|
t.isOpen || o({
|
|
88
|
-
type:
|
|
89
|
+
type: i,
|
|
89
90
|
payload: !0
|
|
90
91
|
});
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
}, I = D(
|
|
93
|
+
(e) => {
|
|
94
|
+
o({
|
|
95
|
+
type: ce,
|
|
96
|
+
payload: {
|
|
97
|
+
inputValue: S(c, e),
|
|
98
|
+
value: e
|
|
99
|
+
}
|
|
100
|
+
}), T(b, u)(e), setTimeout(() => {
|
|
101
|
+
var n;
|
|
102
|
+
(n = f.current) == null || n.focus();
|
|
103
|
+
}, 0), m == null || m(e);
|
|
104
|
+
},
|
|
105
|
+
[c, o, u, b, m]
|
|
106
|
+
), X = (e) => {
|
|
107
|
+
var O, k;
|
|
104
108
|
const { relatedTarget: n } = e;
|
|
105
|
-
if (n && ((
|
|
109
|
+
if (n && ((O = A.current) != null && O.contains(n) || (k = p.current) != null && k.contains(n)) || v.current) {
|
|
106
110
|
setTimeout(() => v.current = !1, 0);
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
109
|
-
const
|
|
110
|
-
fe(
|
|
111
|
-
},
|
|
113
|
+
const d = t.value ?? t.inputValue ?? "";
|
|
114
|
+
fe(B, u)(d);
|
|
115
|
+
}, q = D(
|
|
112
116
|
(e) => {
|
|
113
117
|
switch (e.key) {
|
|
114
118
|
case "ArrowDown":
|
|
115
119
|
case "ArrowUp": {
|
|
116
120
|
e.preventDefault();
|
|
117
|
-
const n = () => t.highlightedIndex === -1 ?
|
|
121
|
+
const n = () => t.highlightedIndex === -1 ? d === -1 ? 0 : -1 : t.highlightedIndex, d = e.key === "ArrowDown" ? 1 : -1, O = le(
|
|
118
122
|
t.autocompleteOptions,
|
|
119
123
|
n(),
|
|
120
|
-
|
|
124
|
+
d
|
|
121
125
|
);
|
|
122
|
-
o({ type: ue, payload:
|
|
126
|
+
o({ type: ue, payload: O }), o({ type: i, payload: !0 });
|
|
123
127
|
break;
|
|
124
128
|
}
|
|
125
129
|
case "Enter":
|
|
126
130
|
case "NumpadEnter": {
|
|
127
|
-
if (e.preventDefault(), t.highlightedIndex >= 0) {
|
|
131
|
+
if (e.preventDefault(), o({ type: i, payload: !0 }), t.highlightedIndex >= 0) {
|
|
128
132
|
const n = t.autocompleteOptions[t.highlightedIndex];
|
|
129
|
-
n && n.props.value && !n.props.disabled &&
|
|
133
|
+
n && n.props.value && !n.props.disabled && I(n.props.value);
|
|
130
134
|
}
|
|
131
135
|
break;
|
|
132
136
|
}
|
|
133
137
|
case "Tab": {
|
|
134
|
-
o({ type:
|
|
138
|
+
o({ type: i, payload: !1 });
|
|
135
139
|
break;
|
|
136
140
|
}
|
|
137
141
|
case "Escape": {
|
|
138
|
-
o({ type:
|
|
142
|
+
o({ type: i, payload: !1 });
|
|
139
143
|
break;
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
146
|
},
|
|
143
|
-
[t.highlightedIndex]
|
|
147
|
+
[t.highlightedIndex, t.autocompleteOptions, I]
|
|
144
148
|
);
|
|
145
|
-
return /* @__PURE__ */
|
|
149
|
+
return /* @__PURE__ */ z(
|
|
146
150
|
"div",
|
|
147
151
|
{
|
|
148
152
|
"aria-disabled": l,
|
|
149
|
-
className:
|
|
153
|
+
className: P("gi-autocomplete gi-not-prose", a.className),
|
|
150
154
|
children: [
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
/* @__PURE__ */
|
|
155
|
+
/* @__PURE__ */ h("span", { id: _, className: "gi-sr-only", children: w }),
|
|
156
|
+
/* @__PURE__ */ h(
|
|
153
157
|
oe,
|
|
154
158
|
{
|
|
155
159
|
autoComplete: "off",
|
|
156
|
-
id:
|
|
157
|
-
name:
|
|
158
|
-
onKeyDown:
|
|
159
|
-
onIconEndClick:
|
|
160
|
-
onChange:
|
|
161
|
-
onClick:
|
|
162
|
-
onBlur:
|
|
160
|
+
id: M,
|
|
161
|
+
name: u,
|
|
162
|
+
onKeyDown: q,
|
|
163
|
+
onIconEndClick: K,
|
|
164
|
+
onChange: $,
|
|
165
|
+
onClick: F,
|
|
166
|
+
onBlur: X,
|
|
163
167
|
clearButtonEnabled: t.isClearButtonEnabled,
|
|
164
168
|
inputActionPosition: "beforeSuffix",
|
|
165
169
|
"aria-label": w,
|
|
166
170
|
"aria-labelledby": _,
|
|
167
171
|
"aria-disabled": l,
|
|
168
172
|
disabled: l,
|
|
169
|
-
placeholder:
|
|
170
|
-
iconEndClassName:
|
|
171
|
-
"gi-cursor-pointer": !l && !
|
|
172
|
-
"gi-cursor-not-allowed gi-pointer-events-none": l && !
|
|
173
|
+
placeholder: y ?? G("autocomplete.placeholder", { defaultValue: "Type to Search" }),
|
|
174
|
+
iconEndClassName: P({
|
|
175
|
+
"gi-cursor-pointer": !l && !s,
|
|
176
|
+
"gi-cursor-not-allowed gi-pointer-events-none": l && !s
|
|
173
177
|
}),
|
|
174
|
-
iconEnd:
|
|
175
|
-
ref:
|
|
178
|
+
iconEnd: s ? void 0 : me(t.isOpen),
|
|
179
|
+
ref: f,
|
|
176
180
|
iconEndRef: p,
|
|
177
181
|
value: t.inputValue,
|
|
178
182
|
"data-highlighted-index": t.highlightedIndex
|
|
179
183
|
}
|
|
180
184
|
),
|
|
181
|
-
/* @__PURE__ */
|
|
185
|
+
/* @__PURE__ */ h(
|
|
182
186
|
ne,
|
|
183
187
|
{
|
|
184
|
-
onOpenChange:
|
|
185
|
-
triggerRef:
|
|
188
|
+
onOpenChange: V,
|
|
189
|
+
triggerRef: f,
|
|
186
190
|
extraRefs: [p],
|
|
187
191
|
open: t.isOpen,
|
|
188
192
|
maxHeight: 304,
|
|
@@ -197,17 +201,17 @@ const {
|
|
|
197
201
|
}
|
|
198
202
|
]
|
|
199
203
|
},
|
|
200
|
-
children: /* @__PURE__ */
|
|
204
|
+
children: /* @__PURE__ */ h(
|
|
201
205
|
ae,
|
|
202
206
|
{
|
|
203
|
-
onChange:
|
|
207
|
+
onChange: I,
|
|
204
208
|
isLoading: g,
|
|
205
209
|
showNoData: !((x = t.autocompleteOptions) != null && x.length),
|
|
206
210
|
ref: A,
|
|
207
211
|
children: he(
|
|
208
212
|
t.autocompleteOptions,
|
|
209
213
|
t,
|
|
210
|
-
|
|
214
|
+
I
|
|
211
215
|
)
|
|
212
216
|
}
|
|
213
217
|
)
|
|
@@ -217,39 +221,39 @@ const {
|
|
|
217
221
|
}
|
|
218
222
|
);
|
|
219
223
|
}
|
|
220
|
-
), he = (a, r, p) => a.map((l,
|
|
224
|
+
), he = (a, r, p) => a.map((l, c) => {
|
|
221
225
|
if (r.optionType === "AutocompleteItem")
|
|
222
226
|
return /* @__PURE__ */ Y(
|
|
223
|
-
|
|
227
|
+
L,
|
|
224
228
|
{
|
|
225
229
|
...l.props,
|
|
226
230
|
key: `AutocompleteItem-${l.props.value}`,
|
|
227
231
|
selected: r.value === l.props.value,
|
|
228
|
-
isHighlighted:
|
|
229
|
-
index:
|
|
232
|
+
isHighlighted: c === r.highlightedIndex,
|
|
233
|
+
index: c
|
|
230
234
|
}
|
|
231
235
|
);
|
|
232
236
|
if (r.optionType === "AutocompleteGroupItem") {
|
|
233
|
-
const
|
|
234
|
-
const
|
|
235
|
-
return /* @__PURE__ */
|
|
236
|
-
|
|
237
|
+
const y = l, m = Z.toArray(y.props.children).filter((g) => ee(g)).map((g) => {
|
|
238
|
+
const s = g.props;
|
|
239
|
+
return /* @__PURE__ */ h(
|
|
240
|
+
L,
|
|
237
241
|
{
|
|
238
|
-
...
|
|
239
|
-
selected: r.value.toString() ===
|
|
242
|
+
...s,
|
|
243
|
+
selected: r.value.toString() === s.value.toString(),
|
|
240
244
|
onChange: p,
|
|
241
|
-
index:
|
|
245
|
+
index: c
|
|
242
246
|
},
|
|
243
|
-
`SelectGroupItemNext-SelectItemNext-${
|
|
247
|
+
`SelectGroupItemNext-SelectItemNext-${s.value.toString()}`
|
|
244
248
|
);
|
|
245
249
|
});
|
|
246
|
-
return /* @__PURE__ */
|
|
250
|
+
return /* @__PURE__ */ h(
|
|
247
251
|
re,
|
|
248
252
|
{
|
|
249
|
-
label:
|
|
250
|
-
children:
|
|
253
|
+
label: y.props.label,
|
|
254
|
+
children: m
|
|
251
255
|
},
|
|
252
|
-
`Group-${
|
|
256
|
+
`Group-${y.props.label}`
|
|
253
257
|
);
|
|
254
258
|
}
|
|
255
259
|
return null;
|
|
@@ -266,7 +270,7 @@ Object.defineProperty(ge, "componentType", {
|
|
|
266
270
|
enumerable: !1
|
|
267
271
|
});
|
|
268
272
|
export {
|
|
269
|
-
|
|
273
|
+
ke as Autocomplete,
|
|
270
274
|
ge as AutocompleteGroupItem,
|
|
271
275
|
ye as AutocompleteItem,
|
|
272
276
|
he as renderSelectMenuOptions
|
|
@@ -4,7 +4,7 @@ import { useScrollHighlightedItem as Y } from "../hooks/use-scroll-highlighted-i
|
|
|
4
4
|
import { safeCloneElement as j } from "../utils/utilities.js";
|
|
5
5
|
import { AUTOCOMPLETE_ACTIONS as k } from "./types.js";
|
|
6
6
|
const {
|
|
7
|
-
ON_RESET:
|
|
7
|
+
ON_RESET: R,
|
|
8
8
|
ON_SELECT_ITEM: q,
|
|
9
9
|
SET_INPUT_VALUE: P,
|
|
10
10
|
SET_IS_OPEN: v,
|
|
@@ -31,7 +31,7 @@ const {
|
|
|
31
31
|
...e,
|
|
32
32
|
isClearButtonEnabled: t.payload || !!e.inputValue
|
|
33
33
|
};
|
|
34
|
-
case
|
|
34
|
+
case R:
|
|
35
35
|
return {
|
|
36
36
|
...e,
|
|
37
37
|
value: "",
|
|
@@ -45,7 +45,8 @@ const {
|
|
|
45
45
|
inputValue: t.payload.inputValue,
|
|
46
46
|
value: t.payload.value,
|
|
47
47
|
isOpen: !1,
|
|
48
|
-
isClearButtonEnabled: !0
|
|
48
|
+
isClearButtonEnabled: !0,
|
|
49
|
+
highlightedIndex: -1
|
|
49
50
|
};
|
|
50
51
|
case S:
|
|
51
52
|
return { ...e, highlightedIndex: t.payload };
|
|
@@ -55,25 +56,25 @@ const {
|
|
|
55
56
|
return e;
|
|
56
57
|
}
|
|
57
58
|
}, J = (e) => {
|
|
58
|
-
var
|
|
59
|
-
const t = ((
|
|
60
|
-
return h(e) && (t === "AutocompleteItem" || t === "AutocompleteGroupItem");
|
|
59
|
+
var s, l, o;
|
|
60
|
+
const t = ((s = e == null ? void 0 : e.type) == null ? void 0 : s.componentType) || ((l = e == null ? void 0 : e.props) == null ? void 0 : l.__type);
|
|
61
|
+
return h(e) && !((o = e == null ? void 0 : e.props) != null && o.hidden) && (t === "AutocompleteItem" || t === "AutocompleteGroupItem");
|
|
61
62
|
}, B = (e, t) => {
|
|
62
|
-
var
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
}, V = (e) => C.toArray(e).filter((t) => J(t)) || [],
|
|
66
|
-
var
|
|
67
|
-
const
|
|
68
|
-
for (const y of
|
|
69
|
-
const T = ((
|
|
70
|
-
if (((
|
|
71
|
-
return ((
|
|
63
|
+
var a, i;
|
|
64
|
+
const s = ((a = e.props.children) == null ? void 0 : a.toString().toLowerCase()) || "", l = (i = e.props.value) == null ? void 0 : i.toLowerCase(), o = t.toLowerCase();
|
|
65
|
+
return s.includes(o) || l.includes(o);
|
|
66
|
+
}, V = (e) => C.toArray(e).filter((t) => J(t)) || [], x = (e, t) => {
|
|
67
|
+
var l, o, a, i, I, f;
|
|
68
|
+
const s = V(e);
|
|
69
|
+
for (const y of s) {
|
|
70
|
+
const T = ((l = y.type) == null ? void 0 : l.componentType) || ((o = y.props) == null ? void 0 : o.__type);
|
|
71
|
+
if (((a = y.props) == null ? void 0 : a.value) === t)
|
|
72
|
+
return ((i = y.props.children) == null ? void 0 : i.toString()) || "";
|
|
72
73
|
if (T === "AutocompleteGroupItem") {
|
|
73
|
-
const
|
|
74
|
+
const n = C.toArray(y.props.children).filter(
|
|
74
75
|
(c) => h(c)
|
|
75
76
|
);
|
|
76
|
-
for (const c of
|
|
77
|
+
for (const c of n)
|
|
77
78
|
if (((I = c.props) == null ? void 0 : I.value) === t)
|
|
78
79
|
return ((f = c.props.children) == null ? void 0 : f.toString()) || "";
|
|
79
80
|
}
|
|
@@ -82,88 +83,89 @@ const {
|
|
|
82
83
|
}, K = (e) => {
|
|
83
84
|
const t = V(e);
|
|
84
85
|
return t != null && t.length && t.every(
|
|
85
|
-
(
|
|
86
|
-
var
|
|
87
|
-
return
|
|
86
|
+
(l) => {
|
|
87
|
+
var o;
|
|
88
|
+
return l.props.__type === "AutocompleteGroupItem" || ((o = l.type) == null ? void 0 : o.componentType) === "AutocompleteGroupItem";
|
|
88
89
|
}
|
|
89
90
|
) ? "AutocompleteGroupItem" : "AutocompleteItem";
|
|
90
91
|
}, pe = ({
|
|
91
92
|
children: e,
|
|
92
93
|
defaultValue: t = "",
|
|
93
|
-
isOpen:
|
|
94
|
-
freeSolo:
|
|
95
|
-
onOpen:
|
|
96
|
-
onClose:
|
|
97
|
-
onChange:
|
|
94
|
+
isOpen: s = !1,
|
|
95
|
+
freeSolo: l = !1,
|
|
96
|
+
onOpen: o,
|
|
97
|
+
onClose: a,
|
|
98
|
+
onChange: i,
|
|
98
99
|
value: I
|
|
99
100
|
}) => {
|
|
100
|
-
const f = g(null), y = g(null), T = g(!1),
|
|
101
|
+
const f = g(null), y = g(null), T = g(!1), n = G(
|
|
101
102
|
() => V(e || []),
|
|
102
103
|
[e]
|
|
103
104
|
), c = () => {
|
|
104
|
-
var
|
|
105
|
-
return (
|
|
106
|
-
}, d = G(() => K(e), [e]), [
|
|
107
|
-
isOpen: !!
|
|
105
|
+
var u;
|
|
106
|
+
return (u = f.current) == null ? void 0 : u.focus();
|
|
107
|
+
}, d = G(() => K(e), [e]), [p, r] = X(z, null, () => ({
|
|
108
|
+
isOpen: !!s,
|
|
108
109
|
value: I,
|
|
109
110
|
inputValue: t,
|
|
110
|
-
autocompleteOptions:
|
|
111
|
+
autocompleteOptions: n,
|
|
111
112
|
isClearButtonEnabled: !1,
|
|
112
113
|
highlightedIndex: -1,
|
|
113
114
|
optionType: d
|
|
114
115
|
}));
|
|
115
|
-
Y(y,
|
|
116
|
-
|
|
117
|
-
}, [
|
|
118
|
-
|
|
116
|
+
Y(y, p.highlightedIndex), A(() => {
|
|
117
|
+
r({ type: E, payload: n });
|
|
118
|
+
}, [n]), A(() => {
|
|
119
|
+
r({ type: H, payload: d });
|
|
119
120
|
}, [d]), A(() => {
|
|
121
|
+
var u;
|
|
120
122
|
if (!T.current) {
|
|
121
123
|
T.current = !0;
|
|
122
124
|
return;
|
|
123
125
|
}
|
|
124
|
-
|
|
125
|
-
}, [
|
|
126
|
-
if (
|
|
127
|
-
|
|
126
|
+
p.inputValue === "" && p.value === "" && ((u = p.autocompleteOptions) != null && u.length) && c();
|
|
127
|
+
}, [p.isClearButtonEnabled]), A(() => {
|
|
128
|
+
if (p.isOpen)
|
|
129
|
+
o == null || o(), c(), r({ type: E, payload: n });
|
|
128
130
|
else {
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
131
|
+
a == null || a();
|
|
132
|
+
const u = x(e, p.value);
|
|
133
|
+
u && p.value ? (r({
|
|
132
134
|
type: P,
|
|
133
|
-
payload:
|
|
134
|
-
}),
|
|
135
|
+
payload: u
|
|
136
|
+
}), r({ type: v, payload: !1 })) : l || (r({ type: R }), i == null || i("")), r({ type: U });
|
|
135
137
|
}
|
|
136
|
-
}, [
|
|
138
|
+
}, [p.isOpen]);
|
|
137
139
|
const M = G(
|
|
138
|
-
() => F.debounce((
|
|
139
|
-
if (
|
|
140
|
-
const _ =
|
|
140
|
+
() => F.debounce((u) => {
|
|
141
|
+
if (u) {
|
|
142
|
+
const _ = n.map((m) => {
|
|
141
143
|
var L, b;
|
|
142
144
|
const D = ((L = m.type) == null ? void 0 : L.componentType) || ((b = m.props) == null ? void 0 : b.__type);
|
|
143
145
|
if (d === "AutocompleteGroupItem" && D === "AutocompleteGroupItem") {
|
|
144
146
|
const N = C.toArray(
|
|
145
147
|
m.props.children
|
|
146
148
|
).filter((O) => h(O)).filter(
|
|
147
|
-
(O) => B(O,
|
|
149
|
+
(O) => B(O, u)
|
|
148
150
|
);
|
|
149
151
|
return N.length > 0 ? j(m, { children: N }) : null;
|
|
150
152
|
} else if (d === "AutocompleteItem")
|
|
151
|
-
return B(m,
|
|
153
|
+
return B(m, u) ? m : null;
|
|
152
154
|
return null;
|
|
153
155
|
}).filter(Boolean);
|
|
154
|
-
|
|
156
|
+
r({ type: E, payload: _ }), r({ type: S, payload: -1 }), (!p.isOpen && !p.value || (_ == null ? void 0 : _.length) === 0) && r({ type: v, payload: !0 });
|
|
155
157
|
} else
|
|
156
|
-
|
|
158
|
+
r({ type: w, payload: "" }), r({ type: E, payload: n }), r({ type: S, payload: -1 });
|
|
157
159
|
}, 500),
|
|
158
|
-
[
|
|
160
|
+
[n, p.isOpen, p.value, l]
|
|
159
161
|
);
|
|
160
162
|
return {
|
|
161
|
-
state:
|
|
162
|
-
dispatch:
|
|
163
|
+
state: p,
|
|
164
|
+
dispatch: r,
|
|
163
165
|
inputRef: f,
|
|
164
166
|
listRef: y,
|
|
165
|
-
validChildren:
|
|
166
|
-
getOptionLabelByValue:
|
|
167
|
+
validChildren: n,
|
|
168
|
+
getOptionLabelByValue: x,
|
|
167
169
|
debouncedFilter: M
|
|
168
170
|
};
|
|
169
171
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export type BrowserSupportProps = {
|
|
3
|
+
onClose?: () => void;
|
|
4
|
+
className?: string;
|
|
5
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
6
|
+
export declare const BrowserSupport: ({ className, ...props }: BrowserSupportProps) => import("react/jsx-runtime").JSX.Element | null;
|