react-animated-select 0.2.7 → 0.2.9
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/index.cjs.js +9 -9
- package/dist/index.es.js +481 -473
- package/package.json +1 -1
- package/src/options.jsx +2 -2
- package/src/select.jsx +2 -0
- package/src/useSelectLogic.jsx +131 -181
package/dist/index.es.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import xe, { createContext as Ae, useRef as oe, useState as Q, useEffect as W, useCallback as k, useMemo as X, useId as Ee, memo as Ne, forwardRef as Ie, useImperativeHandle as Oe, isValidElement as Pe, cloneElement as Ce, useContext as De } from "react";
|
|
2
2
|
import { CSSTransition as ve } from "react-transition-group";
|
|
3
|
-
import './index.css';var
|
|
3
|
+
import './index.css';var le = { exports: {} }, te = {};
|
|
4
4
|
var be;
|
|
5
5
|
function Fe() {
|
|
6
6
|
if (be) return te;
|
|
7
7
|
be = 1;
|
|
8
|
-
var
|
|
9
|
-
function s(
|
|
10
|
-
var
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
for (var
|
|
14
|
-
|
|
15
|
-
} else
|
|
16
|
-
return f =
|
|
17
|
-
$$typeof:
|
|
18
|
-
type:
|
|
19
|
-
key:
|
|
8
|
+
var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), o = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
9
|
+
function s(l, f, a) {
|
|
10
|
+
var x = null;
|
|
11
|
+
if (a !== void 0 && (x = "" + a), f.key !== void 0 && (x = "" + f.key), "key" in f) {
|
|
12
|
+
a = {};
|
|
13
|
+
for (var S in f)
|
|
14
|
+
S !== "key" && (a[S] = f[S]);
|
|
15
|
+
} else a = f;
|
|
16
|
+
return f = a.ref, {
|
|
17
|
+
$$typeof: t,
|
|
18
|
+
type: l,
|
|
19
|
+
key: x,
|
|
20
20
|
ref: f !== void 0 ? f : null,
|
|
21
|
-
props:
|
|
21
|
+
props: a
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
return te.Fragment = o, te.jsx = s, te.jsxs = s, te;
|
|
@@ -27,44 +27,44 @@ var ne = {};
|
|
|
27
27
|
var he;
|
|
28
28
|
function Le() {
|
|
29
29
|
return he || (he = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
30
|
-
function
|
|
30
|
+
function t(e) {
|
|
31
31
|
if (e == null) return null;
|
|
32
32
|
if (typeof e == "function")
|
|
33
|
-
return e.$$typeof ===
|
|
33
|
+
return e.$$typeof === n ? null : e.displayName || e.name || null;
|
|
34
34
|
if (typeof e == "string") return e;
|
|
35
35
|
switch (e) {
|
|
36
|
-
case
|
|
36
|
+
case m:
|
|
37
37
|
return "Fragment";
|
|
38
|
-
case
|
|
38
|
+
case L:
|
|
39
39
|
return "Profiler";
|
|
40
|
-
case
|
|
40
|
+
case E:
|
|
41
41
|
return "StrictMode";
|
|
42
|
-
case
|
|
42
|
+
case _:
|
|
43
43
|
return "Suspense";
|
|
44
|
-
case V:
|
|
45
|
-
return "SuspenseList";
|
|
46
44
|
case z:
|
|
45
|
+
return "SuspenseList";
|
|
46
|
+
case q:
|
|
47
47
|
return "Activity";
|
|
48
48
|
}
|
|
49
49
|
if (typeof e == "object")
|
|
50
50
|
switch (typeof e.tag == "number" && console.error(
|
|
51
51
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
52
52
|
), e.$$typeof) {
|
|
53
|
-
case u:
|
|
54
|
-
return "Portal";
|
|
55
53
|
case d:
|
|
54
|
+
return "Portal";
|
|
55
|
+
case u:
|
|
56
56
|
return e.displayName || "Context";
|
|
57
|
-
case
|
|
57
|
+
case C:
|
|
58
58
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
59
59
|
case U:
|
|
60
|
-
var
|
|
61
|
-
return e = e.displayName, e || (e =
|
|
62
|
-
case
|
|
63
|
-
return
|
|
64
|
-
case
|
|
65
|
-
|
|
60
|
+
var c = e.render;
|
|
61
|
+
return e = e.displayName, e || (e = c.displayName || c.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
62
|
+
case ee:
|
|
63
|
+
return c = e.displayName || null, c !== null ? c : t(e.type) || "Memo";
|
|
64
|
+
case O:
|
|
65
|
+
c = e._payload, e = e._init;
|
|
66
66
|
try {
|
|
67
|
-
return
|
|
67
|
+
return t(e(c));
|
|
68
68
|
} catch {
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -76,71 +76,71 @@ function Le() {
|
|
|
76
76
|
function s(e) {
|
|
77
77
|
try {
|
|
78
78
|
o(e);
|
|
79
|
-
var
|
|
79
|
+
var c = !1;
|
|
80
80
|
} catch {
|
|
81
|
-
|
|
81
|
+
c = !0;
|
|
82
82
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
var
|
|
86
|
-
return
|
|
87
|
-
|
|
83
|
+
if (c) {
|
|
84
|
+
c = console;
|
|
85
|
+
var g = c.error, T = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
86
|
+
return g.call(
|
|
87
|
+
c,
|
|
88
88
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
89
|
-
|
|
89
|
+
T
|
|
90
90
|
), o(e);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
if (e ===
|
|
95
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
93
|
+
function l(e) {
|
|
94
|
+
if (e === m) return "<>";
|
|
95
|
+
if (typeof e == "object" && e !== null && e.$$typeof === O)
|
|
96
96
|
return "<...>";
|
|
97
97
|
try {
|
|
98
|
-
var
|
|
99
|
-
return
|
|
98
|
+
var c = t(e);
|
|
99
|
+
return c ? "<" + c + ">" : "<...>";
|
|
100
100
|
} catch {
|
|
101
101
|
return "<...>";
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
function f() {
|
|
105
|
-
var e =
|
|
105
|
+
var e = b.A;
|
|
106
106
|
return e === null ? null : e.getOwner();
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function a() {
|
|
109
109
|
return Error("react-stack-top-frame");
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
if (
|
|
113
|
-
var
|
|
114
|
-
if (
|
|
111
|
+
function x(e) {
|
|
112
|
+
if ($.call(e, "key")) {
|
|
113
|
+
var c = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
114
|
+
if (c && c.isReactWarning) return !1;
|
|
115
115
|
}
|
|
116
116
|
return e.key !== void 0;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
function
|
|
120
|
-
|
|
118
|
+
function S(e, c) {
|
|
119
|
+
function g() {
|
|
120
|
+
i || (i = !0, console.error(
|
|
121
121
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
122
|
-
|
|
122
|
+
c
|
|
123
123
|
));
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
get:
|
|
125
|
+
g.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
126
|
+
get: g,
|
|
127
127
|
configurable: !0
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
function v() {
|
|
131
|
-
var e =
|
|
132
|
-
return
|
|
131
|
+
var e = t(this.type);
|
|
132
|
+
return h[e] || (h[e] = !0, console.error(
|
|
133
133
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
134
134
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
135
135
|
}
|
|
136
|
-
function j(e,
|
|
137
|
-
var w =
|
|
136
|
+
function j(e, c, g, T, B, K) {
|
|
137
|
+
var w = g.ref;
|
|
138
138
|
return e = {
|
|
139
|
-
$$typeof:
|
|
139
|
+
$$typeof: I,
|
|
140
140
|
type: e,
|
|
141
|
-
key:
|
|
142
|
-
props:
|
|
143
|
-
_owner:
|
|
141
|
+
key: c,
|
|
142
|
+
props: g,
|
|
143
|
+
_owner: T
|
|
144
144
|
}, (w !== void 0 ? w : null) !== null ? Object.defineProperty(e, "ref", {
|
|
145
145
|
enumerable: !1,
|
|
146
146
|
get: v
|
|
@@ -158,7 +158,7 @@ function Le() {
|
|
|
158
158
|
configurable: !1,
|
|
159
159
|
enumerable: !1,
|
|
160
160
|
writable: !0,
|
|
161
|
-
value:
|
|
161
|
+
value: B
|
|
162
162
|
}), Object.defineProperty(e, "_debugTask", {
|
|
163
163
|
configurable: !1,
|
|
164
164
|
enumerable: !1,
|
|
@@ -166,104 +166,104 @@ function Le() {
|
|
|
166
166
|
value: K
|
|
167
167
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
168
168
|
}
|
|
169
|
-
function F(e,
|
|
170
|
-
var w =
|
|
169
|
+
function F(e, c, g, T, B, K) {
|
|
170
|
+
var w = c.children;
|
|
171
171
|
if (w !== void 0)
|
|
172
|
-
if (
|
|
173
|
-
if (
|
|
174
|
-
for (
|
|
175
|
-
P(w[
|
|
172
|
+
if (T)
|
|
173
|
+
if (V(w)) {
|
|
174
|
+
for (T = 0; T < w.length; T++)
|
|
175
|
+
P(w[T]);
|
|
176
176
|
Object.freeze && Object.freeze(w);
|
|
177
177
|
} else
|
|
178
178
|
console.error(
|
|
179
179
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
180
180
|
);
|
|
181
181
|
else P(w);
|
|
182
|
-
if (
|
|
183
|
-
w =
|
|
184
|
-
var
|
|
185
|
-
return
|
|
182
|
+
if ($.call(c, "key")) {
|
|
183
|
+
w = t(e);
|
|
184
|
+
var H = Object.keys(c).filter(function(se) {
|
|
185
|
+
return se !== "key";
|
|
186
186
|
});
|
|
187
|
-
|
|
187
|
+
T = 0 < H.length ? "{key: someKey, " + H.join(": ..., ") + ": ...}" : "{key: someKey}", Y[w + T] || (H = 0 < H.length ? "{" + H.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
188
188
|
`A props object containing a "key" prop is being spread into JSX:
|
|
189
189
|
let props = %s;
|
|
190
190
|
<%s {...props} />
|
|
191
191
|
React keys must be passed directly to JSX without using spread:
|
|
192
192
|
let props = %s;
|
|
193
193
|
<%s key={someKey} {...props} />`,
|
|
194
|
-
|
|
194
|
+
T,
|
|
195
195
|
w,
|
|
196
|
-
|
|
196
|
+
H,
|
|
197
197
|
w
|
|
198
|
-
),
|
|
198
|
+
), Y[w + T] = !0);
|
|
199
199
|
}
|
|
200
|
-
if (w = null,
|
|
201
|
-
|
|
202
|
-
for (var Z in
|
|
203
|
-
Z !== "key" && (
|
|
204
|
-
} else
|
|
205
|
-
return w &&
|
|
206
|
-
|
|
200
|
+
if (w = null, g !== void 0 && (s(g), w = "" + g), x(c) && (s(c.key), w = "" + c.key), "key" in c) {
|
|
201
|
+
g = {};
|
|
202
|
+
for (var Z in c)
|
|
203
|
+
Z !== "key" && (g[Z] = c[Z]);
|
|
204
|
+
} else g = c;
|
|
205
|
+
return w && S(
|
|
206
|
+
g,
|
|
207
207
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
208
208
|
), j(
|
|
209
209
|
e,
|
|
210
210
|
w,
|
|
211
|
-
|
|
211
|
+
g,
|
|
212
212
|
f(),
|
|
213
|
-
|
|
213
|
+
B,
|
|
214
214
|
K
|
|
215
215
|
);
|
|
216
216
|
}
|
|
217
217
|
function P(e) {
|
|
218
|
-
|
|
218
|
+
N(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === O && (e._payload.status === "fulfilled" ? N(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
219
219
|
}
|
|
220
|
-
function
|
|
221
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
220
|
+
function N(e) {
|
|
221
|
+
return typeof e == "object" && e !== null && e.$$typeof === I;
|
|
222
222
|
}
|
|
223
|
-
var
|
|
223
|
+
var A = xe, I = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.portal"), m = /* @__PURE__ */ Symbol.for("react.fragment"), E = /* @__PURE__ */ Symbol.for("react.strict_mode"), L = /* @__PURE__ */ Symbol.for("react.profiler"), C = /* @__PURE__ */ Symbol.for("react.consumer"), u = /* @__PURE__ */ Symbol.for("react.context"), U = /* @__PURE__ */ Symbol.for("react.forward_ref"), _ = /* @__PURE__ */ Symbol.for("react.suspense"), z = /* @__PURE__ */ Symbol.for("react.suspense_list"), ee = /* @__PURE__ */ Symbol.for("react.memo"), O = /* @__PURE__ */ Symbol.for("react.lazy"), q = /* @__PURE__ */ Symbol.for("react.activity"), n = /* @__PURE__ */ Symbol.for("react.client.reference"), b = A.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, $ = Object.prototype.hasOwnProperty, V = Array.isArray, r = console.createTask ? console.createTask : function() {
|
|
224
224
|
return null;
|
|
225
225
|
};
|
|
226
|
-
|
|
226
|
+
A = {
|
|
227
227
|
react_stack_bottom_frame: function(e) {
|
|
228
228
|
return e();
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
)(),
|
|
235
|
-
ne.Fragment =
|
|
236
|
-
var
|
|
231
|
+
var i, h = {}, R = A.react_stack_bottom_frame.bind(
|
|
232
|
+
A,
|
|
233
|
+
a
|
|
234
|
+
)(), M = r(l(a)), Y = {};
|
|
235
|
+
ne.Fragment = m, ne.jsx = function(e, c, g) {
|
|
236
|
+
var T = 1e4 > b.recentlyCreatedOwnerStacks++;
|
|
237
237
|
return F(
|
|
238
238
|
e,
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
c,
|
|
240
|
+
g,
|
|
241
241
|
!1,
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
T ? Error("react-stack-top-frame") : R,
|
|
243
|
+
T ? r(l(e)) : M
|
|
244
244
|
);
|
|
245
|
-
}, ne.jsxs = function(e,
|
|
246
|
-
var
|
|
245
|
+
}, ne.jsxs = function(e, c, g) {
|
|
246
|
+
var T = 1e4 > b.recentlyCreatedOwnerStacks++;
|
|
247
247
|
return F(
|
|
248
248
|
e,
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
c,
|
|
250
|
+
g,
|
|
251
251
|
!0,
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
T ? Error("react-stack-top-frame") : R,
|
|
253
|
+
T ? r(l(e)) : M
|
|
254
254
|
);
|
|
255
255
|
};
|
|
256
256
|
})()), ne;
|
|
257
257
|
}
|
|
258
258
|
var ge;
|
|
259
|
-
function
|
|
260
|
-
return ge || (ge = 1, process.env.NODE_ENV === "production" ?
|
|
259
|
+
function Me() {
|
|
260
|
+
return ge || (ge = 1, process.env.NODE_ENV === "production" ? le.exports = Fe() : le.exports = Le()), le.exports;
|
|
261
261
|
}
|
|
262
|
-
var
|
|
263
|
-
const
|
|
262
|
+
var y = Me();
|
|
263
|
+
const Ye = ({ className: t = "", ...o }) => /* @__PURE__ */ y.jsx(
|
|
264
264
|
"svg",
|
|
265
265
|
{
|
|
266
|
-
className:
|
|
266
|
+
className: t,
|
|
267
267
|
role: "button",
|
|
268
268
|
"aria-label": "Clear selection",
|
|
269
269
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -272,357 +272,365 @@ const Me = ({ className: r = "", ...o }) => /* @__PURE__ */ g.jsx(
|
|
|
272
272
|
height: "1em",
|
|
273
273
|
fill: "currentColor",
|
|
274
274
|
...o,
|
|
275
|
-
children: /* @__PURE__ */
|
|
275
|
+
children: /* @__PURE__ */ y.jsx("path", { d: "M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z" })
|
|
276
276
|
}
|
|
277
|
-
), Ve = ({ className:
|
|
277
|
+
), Ve = ({ className: t = "", ...o }) => /* @__PURE__ */ y.jsx(
|
|
278
278
|
"svg",
|
|
279
279
|
{
|
|
280
|
-
className:
|
|
280
|
+
className: t,
|
|
281
281
|
xmlns: "http://www.w3.org/2000/svg",
|
|
282
282
|
viewBox: "0 0 448 512",
|
|
283
283
|
width: "1em",
|
|
284
284
|
height: "1em",
|
|
285
285
|
fill: "currentColor",
|
|
286
286
|
...o,
|
|
287
|
-
children: /* @__PURE__ */
|
|
287
|
+
children: /* @__PURE__ */ y.jsx("path", { d: "M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z" })
|
|
288
288
|
}
|
|
289
|
-
),
|
|
290
|
-
function
|
|
291
|
-
disabled:
|
|
289
|
+
), me = Ae(null);
|
|
290
|
+
function We({
|
|
291
|
+
disabled: t,
|
|
292
292
|
isOpen: o,
|
|
293
293
|
setIsOpen: s,
|
|
294
|
-
options:
|
|
294
|
+
options: l,
|
|
295
295
|
selectOption: f,
|
|
296
|
-
selected:
|
|
296
|
+
selected: a
|
|
297
297
|
}) {
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
298
|
+
const x = oe(!1), S = oe(0), [v, j] = Q(-1);
|
|
299
|
+
W(() => {
|
|
300
|
+
const d = () => {
|
|
301
|
+
S.current = Date.now();
|
|
302
302
|
};
|
|
303
|
-
return window.addEventListener("focus",
|
|
304
|
-
}, []),
|
|
303
|
+
return window.addEventListener("focus", d), () => window.removeEventListener("focus", d);
|
|
304
|
+
}, []), W(() => {
|
|
305
305
|
if (o) {
|
|
306
|
-
let
|
|
307
|
-
if (
|
|
308
|
-
const
|
|
309
|
-
|
|
306
|
+
let d = -1;
|
|
307
|
+
if (a) {
|
|
308
|
+
const m = l.findIndex((E) => E.id === a.id && !E.disabled);
|
|
309
|
+
m >= 0 && (d = m);
|
|
310
310
|
}
|
|
311
|
-
|
|
311
|
+
d === -1 && (d = l.findIndex((m) => !m.disabled)), j(d);
|
|
312
312
|
} else
|
|
313
313
|
j(-1);
|
|
314
|
-
}, [o,
|
|
315
|
-
const F = k((
|
|
316
|
-
|
|
314
|
+
}, [o, a, l]);
|
|
315
|
+
const F = k((d) => {
|
|
316
|
+
d.currentTarget.contains(d.relatedTarget) || s(!1);
|
|
317
317
|
}, [s]), P = k(() => {
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
t || document.hidden || Date.now() - S.current < 100 || o || (s(!0), x.current = !0, setTimeout(() => {
|
|
319
|
+
x.current = !1;
|
|
320
320
|
}, 200));
|
|
321
|
-
}, [
|
|
322
|
-
|
|
323
|
-
}, [
|
|
324
|
-
if (
|
|
325
|
-
let
|
|
321
|
+
}, [t, o, s]), N = k((d) => {
|
|
322
|
+
t || d.target.closest(".rac-select-cancel") || x.current || s(!o);
|
|
323
|
+
}, [t, o, s]), A = (d, m) => {
|
|
324
|
+
if (l.every((C) => C.disabled)) return -1;
|
|
325
|
+
let E = d, L = 0;
|
|
326
326
|
do
|
|
327
|
-
|
|
328
|
-
while (
|
|
329
|
-
return
|
|
330
|
-
},
|
|
331
|
-
if (!
|
|
332
|
-
switch (
|
|
327
|
+
E += m, E < 0 && (E = l.length - 1), E >= l.length && (E = 0), L++;
|
|
328
|
+
while (l[E]?.disabled && L <= l.length);
|
|
329
|
+
return E;
|
|
330
|
+
}, I = k((d) => {
|
|
331
|
+
if (!t)
|
|
332
|
+
switch (d.key) {
|
|
333
333
|
case "Enter":
|
|
334
334
|
case " ":
|
|
335
|
-
|
|
335
|
+
d.preventDefault(), o ? v !== -1 && l[v] && f(l[v], d) : s(!0);
|
|
336
336
|
break;
|
|
337
337
|
case "Escape":
|
|
338
|
-
|
|
338
|
+
d.preventDefault(), s(!1);
|
|
339
339
|
break;
|
|
340
340
|
case "ArrowDown":
|
|
341
|
-
|
|
341
|
+
d.preventDefault(), o ? j((m) => A(m, 1)) : s(!0);
|
|
342
342
|
break;
|
|
343
343
|
case "ArrowUp":
|
|
344
|
-
|
|
344
|
+
d.preventDefault(), o ? j((m) => A(m, -1)) : s(!0);
|
|
345
345
|
break;
|
|
346
346
|
case "Tab":
|
|
347
347
|
o && s(!1);
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
|
-
}, [
|
|
351
|
-
return
|
|
350
|
+
}, [t, o, s, v, l, f]);
|
|
351
|
+
return X(() => ({
|
|
352
352
|
handleBlur: F,
|
|
353
353
|
handleFocus: P,
|
|
354
|
-
handleToggle:
|
|
355
|
-
handleKeyDown:
|
|
354
|
+
handleToggle: N,
|
|
355
|
+
handleKeyDown: I,
|
|
356
356
|
highlightedIndex: v,
|
|
357
357
|
setHighlightedIndex: j
|
|
358
|
-
}), [F, P,
|
|
358
|
+
}), [F, P, N, I, v, j]);
|
|
359
359
|
}
|
|
360
|
-
function
|
|
361
|
-
options:
|
|
360
|
+
function ze({
|
|
361
|
+
options: t = [],
|
|
362
362
|
jsxOptions: o = [],
|
|
363
363
|
value: s,
|
|
364
|
-
defaultValue:
|
|
364
|
+
defaultValue: l = void 0,
|
|
365
365
|
onChange: f,
|
|
366
|
-
disabled:
|
|
367
|
-
loading:
|
|
368
|
-
error:
|
|
366
|
+
disabled: a = !1,
|
|
367
|
+
loading: x = !1,
|
|
368
|
+
error: S = !1,
|
|
369
369
|
placeholder: v = "Choose option",
|
|
370
370
|
emptyText: j = "No options",
|
|
371
371
|
disabledText: F = "Disabled",
|
|
372
372
|
loadingText: P = "Loading",
|
|
373
|
-
errorText:
|
|
374
|
-
disabledOption:
|
|
375
|
-
emptyOption:
|
|
376
|
-
invalidOption:
|
|
377
|
-
setVisibility:
|
|
373
|
+
errorText: N = "Failed to load",
|
|
374
|
+
disabledOption: A = "Disabled option",
|
|
375
|
+
emptyOption: I = "Empty option",
|
|
376
|
+
invalidOption: d = "Invalid option",
|
|
377
|
+
setVisibility: m
|
|
378
378
|
}) {
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
379
|
+
const E = Ee(), L = s !== void 0, [C, u] = Q(null), U = (n) => !n || typeof n != "object" || Array.isArray(n) ? !1 : "id" in n || "value" in n || "name" in n || "label" in n || "disabled" in n, _ = X(() => {
|
|
380
|
+
const n = [], b = (r, i, h) => {
|
|
381
|
+
let R = h?.id ?? h?.value ?? i ?? r;
|
|
382
|
+
if (typeof i == "function") {
|
|
383
|
+
n.push({
|
|
384
|
+
key: `invalid-${n.length}`,
|
|
385
|
+
value: i,
|
|
386
|
+
userId: null,
|
|
387
|
+
disabled: !0,
|
|
388
|
+
isInvalid: !0,
|
|
389
|
+
label: d,
|
|
390
|
+
original: h
|
|
390
391
|
});
|
|
391
392
|
return;
|
|
392
393
|
}
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
key: `
|
|
396
|
-
value:
|
|
397
|
-
userId:
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
original:
|
|
394
|
+
if (i === "") {
|
|
395
|
+
n.push({
|
|
396
|
+
key: `empty-str-${n.length}`,
|
|
397
|
+
value: "",
|
|
398
|
+
userId: null,
|
|
399
|
+
disabled: !0,
|
|
400
|
+
label: I,
|
|
401
|
+
original: h
|
|
401
402
|
});
|
|
402
403
|
return;
|
|
403
404
|
}
|
|
404
|
-
if (i
|
|
405
|
-
|
|
406
|
-
key: `empty-${
|
|
405
|
+
if (i == null) {
|
|
406
|
+
n.push({
|
|
407
|
+
key: `empty-${n.length}`,
|
|
407
408
|
value: null,
|
|
408
|
-
userId:
|
|
409
|
+
userId: null,
|
|
409
410
|
disabled: !0,
|
|
410
|
-
label:
|
|
411
|
-
original:
|
|
411
|
+
label: I,
|
|
412
|
+
original: h
|
|
412
413
|
});
|
|
413
414
|
return;
|
|
414
415
|
}
|
|
415
|
-
if (typeof i == "
|
|
416
|
-
|
|
417
|
-
key:
|
|
418
|
-
value:
|
|
419
|
-
userId:
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
original: x
|
|
416
|
+
if (typeof i == "number" || typeof i == "boolean") {
|
|
417
|
+
n.push({
|
|
418
|
+
key: `${typeof i}-${i}-${n.length}`,
|
|
419
|
+
value: i,
|
|
420
|
+
userId: R,
|
|
421
|
+
label: String(i),
|
|
422
|
+
original: h
|
|
423
423
|
});
|
|
424
424
|
return;
|
|
425
425
|
}
|
|
426
|
-
i && typeof i == "object" && !Array.isArray(i) ?
|
|
427
|
-
key: i.id ?? i.value ?? i.name ?? n
|
|
426
|
+
i && typeof i == "object" && !Array.isArray(i) ? n.push({
|
|
427
|
+
key: i.id ?? i.value ?? i.name ?? r ?? `obj-${n.length}`,
|
|
428
428
|
value: i,
|
|
429
|
-
userId:
|
|
429
|
+
userId: R,
|
|
430
430
|
disabled: !!i.disabled,
|
|
431
|
-
label: i.name ?? i.label ??
|
|
432
|
-
original:
|
|
433
|
-
}) :
|
|
434
|
-
key: n
|
|
431
|
+
label: i.name ?? i.label ?? String(r),
|
|
432
|
+
original: h
|
|
433
|
+
}) : n.push({
|
|
434
|
+
key: r ?? `opt-${n.length}`,
|
|
435
435
|
value: i,
|
|
436
|
-
userId:
|
|
437
|
-
label: String(i ??
|
|
438
|
-
original:
|
|
436
|
+
userId: R,
|
|
437
|
+
label: String(i ?? r),
|
|
438
|
+
original: h
|
|
439
439
|
});
|
|
440
440
|
};
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
return t.map((n, i) => ({
|
|
474
|
-
id: `${y}-opt-${i}`,
|
|
475
|
-
userId: n.userId,
|
|
476
|
-
name: String(n.label),
|
|
477
|
-
raw: n.value,
|
|
478
|
-
original: n.original,
|
|
479
|
-
disabled: n.disabled,
|
|
480
|
-
type: typeof n.value == "boolean" ? "boolean" : "normal"
|
|
441
|
+
Array.isArray(t) ? t.forEach((r, i) => {
|
|
442
|
+
if (r && typeof r == "object" && Object.keys(r).length === 1 && r.disabled === !0)
|
|
443
|
+
n.push({ key: `dis-${i}`, value: null, userId: null, disabled: !0, label: A, original: r });
|
|
444
|
+
else if (U(r)) {
|
|
445
|
+
const h = r.id ?? (typeof r.value != "object" ? r.value : r.label ?? r.name ?? r.value);
|
|
446
|
+
n.push({
|
|
447
|
+
key: r.id ?? r.value ?? r.name ?? `opt-${i}`,
|
|
448
|
+
value: r.value !== void 0 ? r.value : r.id !== void 0 ? r.id : r,
|
|
449
|
+
userId: h,
|
|
450
|
+
disabled: !!r.disabled,
|
|
451
|
+
label: r.name ?? r.label ?? String(r.id ?? r.value),
|
|
452
|
+
original: r
|
|
453
|
+
});
|
|
454
|
+
} else r && typeof r == "object" && !Array.isArray(r) ? Object.entries(r).forEach(([h, R]) => b(h, R, R)) : b(r, r, r);
|
|
455
|
+
}) : typeof t == "object" && t !== null && Object.entries(t).forEach(([r, i]) => b(r, i, i));
|
|
456
|
+
const $ = n.map((r, i) => ({
|
|
457
|
+
id: `${E}-opt-${i}`,
|
|
458
|
+
userId: r.userId,
|
|
459
|
+
name: String(r.label),
|
|
460
|
+
raw: r.value,
|
|
461
|
+
original: r.original,
|
|
462
|
+
disabled: r.disabled,
|
|
463
|
+
isInvalid: r.isInvalid,
|
|
464
|
+
type: typeof r.value == "boolean" ? "boolean" : "normal"
|
|
465
|
+
})), V = o.map((r, i) => ({
|
|
466
|
+
...r,
|
|
467
|
+
id: `jsx-${E.replace(/:/g, "")}-${r.id}-${i}`,
|
|
468
|
+
userId: r.id,
|
|
469
|
+
raw: r.value,
|
|
470
|
+
original: r.value,
|
|
471
|
+
name: r.label,
|
|
472
|
+
type: typeof r.value == "boolean" ? "boolean" : "normal"
|
|
481
473
|
}));
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}, [O, S, $, T]), ee = k((t, b) => {
|
|
505
|
-
if (t.disabled) {
|
|
506
|
-
b.stopPropagation(), b.preventDefault();
|
|
474
|
+
return [...$, ...V];
|
|
475
|
+
}, [t, o, E, I, A]), z = k((n) => {
|
|
476
|
+
if (n == null) return null;
|
|
477
|
+
const b = _.find(($) => $.original === n || $.raw === n);
|
|
478
|
+
if (b) return b.id;
|
|
479
|
+
if (typeof n == "object")
|
|
480
|
+
try {
|
|
481
|
+
const $ = JSON.stringify(n), V = _.find(
|
|
482
|
+
(r) => r.original && typeof r.original == "object" && JSON.stringify(r.original) === $
|
|
483
|
+
);
|
|
484
|
+
if (V) return V.id;
|
|
485
|
+
} catch {
|
|
486
|
+
}
|
|
487
|
+
return _.find(($) => $.userId === n)?.id ?? null;
|
|
488
|
+
}, [_]);
|
|
489
|
+
W(() => {
|
|
490
|
+
const n = L ? s : l, b = _.find((V) => V.id === C);
|
|
491
|
+
b && (b.original === n || b.raw === n || b.userId === n) || u(z(n));
|
|
492
|
+
}, [s, l, L, _, z]);
|
|
493
|
+
const ee = X(() => _.find((n) => n.id === C) ?? null, [C, _]), O = k((n, b) => {
|
|
494
|
+
if (n.disabled) {
|
|
495
|
+
b?.stopPropagation(), b?.preventDefault();
|
|
507
496
|
return;
|
|
508
497
|
}
|
|
509
|
-
|
|
510
|
-
}, [f,
|
|
511
|
-
|
|
498
|
+
u(n.id), f?.(n.original, n.userId), m(!1);
|
|
499
|
+
}, [f, m]), q = k((n) => {
|
|
500
|
+
n.preventDefault(), n.stopPropagation(), u(null), f?.(null, null);
|
|
512
501
|
}, [f]);
|
|
513
|
-
return {
|
|
502
|
+
return {
|
|
503
|
+
normalizedOptions: _,
|
|
504
|
+
selected: ee,
|
|
505
|
+
selectOption: O,
|
|
506
|
+
clear: q,
|
|
507
|
+
hasOptions: _.length > 0,
|
|
508
|
+
active: !S && !x && !a && _.length > 0,
|
|
509
|
+
selectedValue: s ?? l,
|
|
510
|
+
placeholder: v,
|
|
511
|
+
emptyText: j,
|
|
512
|
+
disabledText: F,
|
|
513
|
+
loadingText: P,
|
|
514
|
+
errorText: N,
|
|
515
|
+
disabledOption: A,
|
|
516
|
+
emptyOption: I,
|
|
517
|
+
invalidOption: d,
|
|
518
|
+
disabled: a,
|
|
519
|
+
loading: x,
|
|
520
|
+
error: S
|
|
521
|
+
};
|
|
514
522
|
}
|
|
515
|
-
const ae = (
|
|
516
|
-
const
|
|
517
|
-
if (typeof
|
|
518
|
-
return
|
|
519
|
-
const f =
|
|
520
|
-
return f ? f || `${o}-${Math.random().toString(36).slice(2, 8)}` :
|
|
523
|
+
const ae = (t, o = "invalid-option", s = "") => {
|
|
524
|
+
const l = s ? s.replace(/:/g, "") : "";
|
|
525
|
+
if (typeof t != "string" || !t.trim())
|
|
526
|
+
return l ? `${o}-${l}` : `${o}-${Math.random().toString(36).slice(2, 8)}`;
|
|
527
|
+
const f = t.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, "-").replace(/[^\p{L}\p{N}-]+/gu, "").toLowerCase();
|
|
528
|
+
return f ? f || `${o}-${Math.random().toString(36).slice(2, 8)}` : l ? `${o}-${l}` : `${o}-${Math.random().toString(36).slice(2, 8)}`;
|
|
521
529
|
};
|
|
522
530
|
function He({
|
|
523
|
-
visibility:
|
|
531
|
+
visibility: t,
|
|
524
532
|
children: o,
|
|
525
533
|
selectRef: s,
|
|
526
|
-
onAnimationDone:
|
|
534
|
+
onAnimationDone: l,
|
|
527
535
|
unmount: f = !0,
|
|
528
|
-
duration:
|
|
529
|
-
easing:
|
|
530
|
-
offset:
|
|
536
|
+
duration: a,
|
|
537
|
+
easing: x,
|
|
538
|
+
offset: S,
|
|
531
539
|
animateOpacity: v
|
|
532
540
|
}) {
|
|
533
541
|
const j = oe(null), [F, P] = Q(0);
|
|
534
|
-
|
|
542
|
+
W(() => {
|
|
535
543
|
if (!s?.current) return;
|
|
536
544
|
P(s.current.offsetHeight);
|
|
537
|
-
const U = new ResizeObserver((
|
|
538
|
-
for (let
|
|
545
|
+
const U = new ResizeObserver((_) => {
|
|
546
|
+
for (let z of _) P(z.target.offsetHeight);
|
|
539
547
|
});
|
|
540
548
|
return U.observe(s.current), () => U.disconnect();
|
|
541
549
|
}, [s]);
|
|
542
|
-
const
|
|
550
|
+
const N = `height ${a}ms ${x}${v ? `, opacity ${a}ms ${x}` : ""}`, A = {
|
|
543
551
|
position: "absolute",
|
|
544
|
-
top: `calc(100% + ${
|
|
552
|
+
top: `calc(100% + ${S}px)`,
|
|
545
553
|
left: "0",
|
|
546
554
|
width: "100%",
|
|
547
555
|
overflow: "hidden",
|
|
548
556
|
marginTop: "2px",
|
|
549
557
|
zIndex: "1",
|
|
550
|
-
height:
|
|
551
|
-
opacity:
|
|
552
|
-
pointerEvents:
|
|
558
|
+
height: t ? "auto" : "0px",
|
|
559
|
+
opacity: v ? t ? 1 : 0 : 1,
|
|
560
|
+
pointerEvents: t ? "all" : "none",
|
|
553
561
|
visibility: F ? "visible" : "hidden"
|
|
554
|
-
},
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
}, [v]),
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
}, [
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
}, [
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
}, [
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
}, [v]),
|
|
570
|
-
const
|
|
571
|
-
|
|
562
|
+
}, I = k(() => {
|
|
563
|
+
const u = j.current;
|
|
564
|
+
u && (u.style.height = "0px", v && (u.style.opacity = "0"), u.style.transition = "");
|
|
565
|
+
}, [v]), d = k(() => {
|
|
566
|
+
const u = j.current;
|
|
567
|
+
u && (u.style.transition = N, u.style.height = `${u.scrollHeight}px`, v && (u.style.opacity = "1"));
|
|
568
|
+
}, [N, v]), m = k(() => {
|
|
569
|
+
const u = j.current;
|
|
570
|
+
u && (u.style.height = "auto", u.style.transition = "", l && l());
|
|
571
|
+
}, [l]), E = k(() => {
|
|
572
|
+
const u = j.current;
|
|
573
|
+
u && (u.style.height = `${u.scrollHeight}px`, v && (u.style.opacity = "1"), u.offsetHeight, u.style.transition = N);
|
|
574
|
+
}, [N, v]), L = k(() => {
|
|
575
|
+
const u = j.current;
|
|
576
|
+
u && (u.style.height = "0px", v && (u.style.opacity = "0"));
|
|
577
|
+
}, [v]), C = k(() => {
|
|
578
|
+
const u = j.current;
|
|
579
|
+
u && (u.style.transition = "");
|
|
572
580
|
}, []);
|
|
573
|
-
return /* @__PURE__ */
|
|
581
|
+
return /* @__PURE__ */ y.jsx(
|
|
574
582
|
ve,
|
|
575
583
|
{
|
|
576
|
-
in:
|
|
577
|
-
timeout:
|
|
584
|
+
in: t,
|
|
585
|
+
timeout: a,
|
|
578
586
|
classNames: "rac-options",
|
|
579
587
|
unmountOnExit: f,
|
|
580
588
|
nodeRef: j,
|
|
581
|
-
onEnter:
|
|
582
|
-
onEntering:
|
|
583
|
-
onEntered:
|
|
584
|
-
onExit:
|
|
585
|
-
onExiting:
|
|
586
|
-
onExited:
|
|
587
|
-
children: /* @__PURE__ */
|
|
589
|
+
onEnter: I,
|
|
590
|
+
onEntering: d,
|
|
591
|
+
onEntered: m,
|
|
592
|
+
onExit: E,
|
|
593
|
+
onExiting: L,
|
|
594
|
+
onExited: C,
|
|
595
|
+
children: /* @__PURE__ */ y.jsx(
|
|
588
596
|
"div",
|
|
589
597
|
{
|
|
590
598
|
ref: j,
|
|
591
599
|
className: "rac-options",
|
|
592
|
-
style:
|
|
600
|
+
style: A,
|
|
593
601
|
children: o
|
|
594
602
|
}
|
|
595
603
|
)
|
|
596
604
|
}
|
|
597
605
|
);
|
|
598
606
|
}
|
|
599
|
-
const Ue = Ne(He, (
|
|
600
|
-
function
|
|
601
|
-
visibility:
|
|
607
|
+
const Ue = Ne(He, (t, o) => t.visibility === o.visibility && t.duration === o.duration && t.easing === o.easing && t.offset === o.offset && t.animateOpacity === o.animateOpacity && t.selectRef === o.selectRef && t.children === o.children);
|
|
608
|
+
function ie({
|
|
609
|
+
visibility: t,
|
|
602
610
|
children: o,
|
|
603
611
|
duration: s = 300,
|
|
604
|
-
unmount:
|
|
612
|
+
unmount: l,
|
|
605
613
|
style: f
|
|
606
614
|
}) {
|
|
607
|
-
const
|
|
608
|
-
return /* @__PURE__ */
|
|
615
|
+
const a = oe(null);
|
|
616
|
+
return /* @__PURE__ */ y.jsx(
|
|
609
617
|
ve,
|
|
610
618
|
{
|
|
611
|
-
in:
|
|
619
|
+
in: t,
|
|
612
620
|
timeout: s,
|
|
613
621
|
classNames: "rac-slide-left",
|
|
614
622
|
unmountOnExit: !0,
|
|
615
|
-
nodeRef:
|
|
616
|
-
onEnter: () =>
|
|
617
|
-
onEntering: () =>
|
|
618
|
-
onEntered: () =>
|
|
619
|
-
onExit: () =>
|
|
620
|
-
onExiting: () =>
|
|
621
|
-
onExited: () =>
|
|
622
|
-
children: /* @__PURE__ */
|
|
623
|
+
nodeRef: a,
|
|
624
|
+
onEnter: () => a.current.style.width = "0px",
|
|
625
|
+
onEntering: () => a.current.style.width = a.current.scrollWidth + "px",
|
|
626
|
+
onEntered: () => a.current.style.width = "auto",
|
|
627
|
+
onExit: () => a.current.style.width = a.current.scrollWidth + "px",
|
|
628
|
+
onExiting: () => a.current.style.width = "0px",
|
|
629
|
+
onExited: () => l?.(),
|
|
630
|
+
children: /* @__PURE__ */ y.jsx(
|
|
623
631
|
"div",
|
|
624
632
|
{
|
|
625
|
-
ref:
|
|
633
|
+
ref: a,
|
|
626
634
|
style: {
|
|
627
635
|
...f,
|
|
628
636
|
overflow: "hidden",
|
|
@@ -634,97 +642,97 @@ function le({
|
|
|
634
642
|
}
|
|
635
643
|
);
|
|
636
644
|
}
|
|
637
|
-
const
|
|
638
|
-
if (!
|
|
639
|
-
if (typeof
|
|
640
|
-
return /* @__PURE__ */
|
|
641
|
-
if (Pe(
|
|
642
|
-
return Ce(
|
|
643
|
-
if (typeof
|
|
644
|
-
const s =
|
|
645
|
-
return /* @__PURE__ */
|
|
645
|
+
const ye = (t, o) => {
|
|
646
|
+
if (!t) return null;
|
|
647
|
+
if (typeof t == "string")
|
|
648
|
+
return /* @__PURE__ */ y.jsx("img", { src: t, ...o, alt: "" });
|
|
649
|
+
if (Pe(t))
|
|
650
|
+
return Ce(t, o);
|
|
651
|
+
if (typeof t == "function" || typeof t == "object" && t.$$typeof) {
|
|
652
|
+
const s = t;
|
|
653
|
+
return /* @__PURE__ */ y.jsx(s, { ...o });
|
|
646
654
|
}
|
|
647
655
|
return null;
|
|
648
|
-
},
|
|
649
|
-
unmount:
|
|
656
|
+
}, Be = Ie(({
|
|
657
|
+
unmount: t,
|
|
650
658
|
children: o,
|
|
651
659
|
renderedDropdown: s,
|
|
652
|
-
visibility:
|
|
660
|
+
visibility: l,
|
|
653
661
|
ownBehavior: f = !1,
|
|
654
|
-
alwaysOpen:
|
|
655
|
-
duration:
|
|
656
|
-
easing:
|
|
662
|
+
alwaysOpen: a = !1,
|
|
663
|
+
duration: x = 300,
|
|
664
|
+
easing: S = "ease-out",
|
|
657
665
|
offset: v = 2,
|
|
658
666
|
animateOpacity: j = !0,
|
|
659
667
|
style: F = {},
|
|
660
668
|
className: P = "",
|
|
661
|
-
ArrowIcon:
|
|
662
|
-
ClearIcon:
|
|
663
|
-
...
|
|
664
|
-
},
|
|
665
|
-
const
|
|
666
|
-
|
|
669
|
+
ArrowIcon: N = Ve,
|
|
670
|
+
ClearIcon: A = Ye,
|
|
671
|
+
...I
|
|
672
|
+
}, d) => {
|
|
673
|
+
const m = Ee(), E = X(() => m.replace(/:/g, ""), [m]), [L, C] = Q([]), u = k((p) => {
|
|
674
|
+
C((D) => [...D, p]);
|
|
667
675
|
}, []), U = k((p) => {
|
|
668
|
-
|
|
669
|
-
}, []),
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}, [
|
|
673
|
-
const [
|
|
674
|
-
|
|
675
|
-
}, [
|
|
676
|
-
disabled:
|
|
677
|
-
isOpen:
|
|
678
|
-
setIsOpen:
|
|
679
|
-
options:
|
|
680
|
-
selectOption:
|
|
681
|
-
selected:
|
|
676
|
+
C((D) => D.filter((G) => G.id !== p));
|
|
677
|
+
}, []), _ = oe(null);
|
|
678
|
+
W(() => {
|
|
679
|
+
d && (typeof d == "function" ? d(_.current) : d.current = _.current);
|
|
680
|
+
}, [d]), Oe(d, () => _.current);
|
|
681
|
+
const [z, ee] = Q(!1), O = X(() => a ? !0 : f ? !!l : z, [a, f, l, z]), q = k((p) => {
|
|
682
|
+
a || f || ee((D) => typeof p == "function" ? p(D) : p);
|
|
683
|
+
}, [a, f]), { normalizedOptions: n, selected: b, selectOption: $, clear: V, hasOptions: r, active: i, selectedValue: h, disabled: R, loading: M, error: Y, placeholder: e, invalidOption: c, options: g, value: T, defaultValue: B, isControlled: K, emptyText: w, disabledText: H, loadingText: Z, errorText: se } = ze({ ...I, setVisibility: q, jsxOptions: L }), { handleBlur: we, handleFocus: je, handleToggle: _e, handleKeyDown: Te, highlightedIndex: re, setHighlightedIndex: Se } = We({
|
|
684
|
+
disabled: R,
|
|
685
|
+
isOpen: O,
|
|
686
|
+
setIsOpen: q,
|
|
687
|
+
options: n,
|
|
688
|
+
selectOption: $,
|
|
689
|
+
selected: b
|
|
682
690
|
}), [ue, de] = Q(!1);
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
}, [
|
|
686
|
-
(
|
|
687
|
-
}, [
|
|
688
|
-
if (
|
|
689
|
-
const p =
|
|
691
|
+
W(() => {
|
|
692
|
+
O || de(!1);
|
|
693
|
+
}, [O]), W(() => {
|
|
694
|
+
(Y || R || M || !r) && q(!1);
|
|
695
|
+
}, [Y, R, M, r]), W(() => {
|
|
696
|
+
if (O && ue && re !== -1) {
|
|
697
|
+
const p = n[re];
|
|
690
698
|
if (p) {
|
|
691
|
-
const D = `opt-${
|
|
699
|
+
const D = `opt-${E}-${ae(p.id)}`, G = document.getElementById(D);
|
|
692
700
|
G && G.scrollIntoView({ block: "nearest" });
|
|
693
701
|
}
|
|
694
702
|
}
|
|
695
|
-
}, [re,
|
|
696
|
-
const fe =
|
|
697
|
-
if (
|
|
698
|
-
if (
|
|
699
|
-
if (
|
|
700
|
-
if (
|
|
703
|
+
}, [re, O, ue, n, E]);
|
|
704
|
+
const fe = h != null && !(Array.isArray(h) && h.length === 0) && !(typeof h == "object" && Object.keys(h).length === 0), pe = X(() => {
|
|
705
|
+
if (Y) return se;
|
|
706
|
+
if (M) return Z;
|
|
707
|
+
if (R) return H;
|
|
708
|
+
if (b) return b.jsx ?? b.name;
|
|
701
709
|
if (fe) {
|
|
702
|
-
const p =
|
|
703
|
-
return p ? p.name : typeof
|
|
710
|
+
const p = n.find((D) => D.raw === h);
|
|
711
|
+
return p ? p.name : typeof h == "object" && h !== null ? h.name ?? h.label ?? "Selected Object" : String(h);
|
|
704
712
|
}
|
|
705
|
-
return
|
|
706
|
-
}, [
|
|
707
|
-
const G = `opt-${
|
|
708
|
-
let
|
|
709
|
-
return p.className && (
|
|
713
|
+
return r ? e : w;
|
|
714
|
+
}, [R, M, Y, r, b, h, e, se, Z, H, w]), Re = `${E}-listbox`, $e = X(() => n?.map((p, D) => {
|
|
715
|
+
const G = `opt-${E}-${ae(p.id)}`;
|
|
716
|
+
let J = "rac-select-option";
|
|
717
|
+
return p.className && (J += ` ${p.className}`), b?.id === p.id && (J += " rac-selected"), D === re && (J += " rac-highlighted"), p.disabled && (J += " rac-disabled-option"), p.isInvalid && (J += " rac-invalid-option"), typeof p.raw == "boolean" && (J += p.raw ? " rac-true-option" : " rac-false-option"), p.name == c && (J += " rac-invalid-option"), /* @__PURE__ */ y.jsx(
|
|
710
718
|
"div",
|
|
711
719
|
{
|
|
712
|
-
className:
|
|
713
|
-
onClick: (ke) =>
|
|
714
|
-
onMouseEnter: () => !p.disabled &&
|
|
720
|
+
className: J,
|
|
721
|
+
onClick: (ke) => $(p, ke),
|
|
722
|
+
onMouseEnter: () => !p.disabled && Se(D),
|
|
715
723
|
id: G,
|
|
716
724
|
role: "option",
|
|
717
|
-
"aria-selected":
|
|
725
|
+
"aria-selected": b?.id === p.id,
|
|
718
726
|
"aria-disabled": p.disabled,
|
|
719
727
|
children: p.jsx ?? p.name
|
|
720
728
|
},
|
|
721
729
|
p.id
|
|
722
730
|
);
|
|
723
|
-
}), [
|
|
724
|
-
return
|
|
725
|
-
process.env.NODE_ENV !== "production" && (
|
|
731
|
+
}), [n, $, E, b, re]);
|
|
732
|
+
return W(() => {
|
|
733
|
+
process.env.NODE_ENV !== "production" && (g && typeof g != "object" && console.error(
|
|
726
734
|
`%c[Select Library]:%c Invalid prop %coptions%c.
|
|
727
|
-
Expected %cArray%c or %cObject%c, but received %c${typeof
|
|
735
|
+
Expected %cArray%c or %cObject%c, but received %c${typeof g}%c.
|
|
728
736
|
`,
|
|
729
737
|
"color: #ff4d4f; font-weight: bold;",
|
|
730
738
|
"color: default;",
|
|
@@ -736,52 +744,52 @@ Expected %cArray%c or %cObject%c, but received %c${typeof h}%c.
|
|
|
736
744
|
"color: default;",
|
|
737
745
|
"color: #ff4d4f; font-weight: bold;",
|
|
738
746
|
"color: default;"
|
|
739
|
-
), K &&
|
|
747
|
+
), K && B !== void 0 && console.warn(
|
|
740
748
|
`%c[Select Library]:%c .
|
|
741
749
|
`,
|
|
742
750
|
"color: #faad14; font-weight: bold;",
|
|
743
751
|
"color: default;"
|
|
744
752
|
));
|
|
745
|
-
}, [
|
|
746
|
-
|
|
753
|
+
}, [g, T, B, K]), /* @__PURE__ */ y.jsxs(
|
|
754
|
+
me.Provider,
|
|
747
755
|
{
|
|
748
|
-
value: { registerOption:
|
|
756
|
+
value: { registerOption: u, unregisterOption: U },
|
|
749
757
|
children: [
|
|
750
758
|
o,
|
|
751
759
|
s,
|
|
752
|
-
/* @__PURE__ */
|
|
760
|
+
/* @__PURE__ */ y.jsxs(
|
|
753
761
|
"div",
|
|
754
762
|
{
|
|
755
763
|
style: {
|
|
756
|
-
"--rac-duration": `${
|
|
764
|
+
"--rac-duration": `${x}ms`,
|
|
757
765
|
...F
|
|
758
766
|
},
|
|
759
767
|
className: `rac-select
|
|
760
768
|
${P}
|
|
761
|
-
${!
|
|
762
|
-
${
|
|
763
|
-
${
|
|
764
|
-
tabIndex:
|
|
765
|
-
ref:
|
|
769
|
+
${!r || R ? "rac-disabled-style" : ""}
|
|
770
|
+
${M ? "rac-loading-style" : ""}
|
|
771
|
+
${Y ? "rac-error-style" : ""}`,
|
|
772
|
+
tabIndex: i ? 0 : -1,
|
|
773
|
+
ref: _,
|
|
766
774
|
role: "combobox",
|
|
767
775
|
"aria-haspopup": "listbox",
|
|
768
|
-
"aria-expanded":
|
|
769
|
-
"aria-controls":
|
|
776
|
+
"aria-expanded": O,
|
|
777
|
+
"aria-controls": Re,
|
|
770
778
|
"aria-label": e,
|
|
771
|
-
"aria-disabled":
|
|
772
|
-
...
|
|
779
|
+
"aria-disabled": R || !r,
|
|
780
|
+
...i && {
|
|
773
781
|
onBlur: we,
|
|
774
782
|
onFocus: je,
|
|
775
783
|
onClick: _e,
|
|
776
784
|
onKeyDown: Te
|
|
777
785
|
},
|
|
778
786
|
children: [
|
|
779
|
-
/* @__PURE__ */
|
|
787
|
+
/* @__PURE__ */ y.jsxs(
|
|
780
788
|
"div",
|
|
781
789
|
{
|
|
782
|
-
className: `rac-select-title ${!
|
|
790
|
+
className: `rac-select-title ${!Y && !M && b?.type == "boolean" ? b.raw ? "rac-true-option" : "rac-false-option" : ""}`,
|
|
783
791
|
children: [
|
|
784
|
-
/* @__PURE__ */
|
|
792
|
+
/* @__PURE__ */ y.jsx(
|
|
785
793
|
"span",
|
|
786
794
|
{
|
|
787
795
|
className: "rac-title-text",
|
|
@@ -789,49 +797,49 @@ Expected %cArray%c or %cObject%c, but received %c${typeof h}%c.
|
|
|
789
797
|
},
|
|
790
798
|
pe
|
|
791
799
|
),
|
|
792
|
-
/* @__PURE__ */
|
|
793
|
-
|
|
800
|
+
/* @__PURE__ */ y.jsx(
|
|
801
|
+
ie,
|
|
794
802
|
{
|
|
795
|
-
visibility:
|
|
796
|
-
duration:
|
|
797
|
-
children: /* @__PURE__ */
|
|
798
|
-
/* @__PURE__ */
|
|
799
|
-
/* @__PURE__ */
|
|
800
|
-
/* @__PURE__ */
|
|
803
|
+
visibility: M && !Y,
|
|
804
|
+
duration: x,
|
|
805
|
+
children: /* @__PURE__ */ y.jsxs("span", { className: "rac-loading-dots", children: [
|
|
806
|
+
/* @__PURE__ */ y.jsx("i", {}),
|
|
807
|
+
/* @__PURE__ */ y.jsx("i", {}),
|
|
808
|
+
/* @__PURE__ */ y.jsx("i", {})
|
|
801
809
|
] })
|
|
802
810
|
}
|
|
803
811
|
)
|
|
804
812
|
]
|
|
805
813
|
}
|
|
806
814
|
),
|
|
807
|
-
/* @__PURE__ */
|
|
815
|
+
/* @__PURE__ */ y.jsxs(
|
|
808
816
|
"div",
|
|
809
817
|
{
|
|
810
818
|
className: "rac-select-buttons",
|
|
811
819
|
children: [
|
|
812
|
-
/* @__PURE__ */
|
|
813
|
-
|
|
820
|
+
/* @__PURE__ */ y.jsx(
|
|
821
|
+
ie,
|
|
814
822
|
{
|
|
815
|
-
visibility: fe &&
|
|
816
|
-
duration:
|
|
823
|
+
visibility: fe && r && !R && !M && !Y,
|
|
824
|
+
duration: x,
|
|
817
825
|
style: { display: "grid" },
|
|
818
|
-
children:
|
|
826
|
+
children: ye(A, {
|
|
819
827
|
className: "rac-select-cancel",
|
|
820
|
-
onClick: (p) =>
|
|
828
|
+
onClick: (p) => V(p)
|
|
821
829
|
})
|
|
822
830
|
}
|
|
823
831
|
),
|
|
824
|
-
/* @__PURE__ */
|
|
825
|
-
|
|
832
|
+
/* @__PURE__ */ y.jsx(
|
|
833
|
+
ie,
|
|
826
834
|
{
|
|
827
|
-
visibility:
|
|
828
|
-
duration:
|
|
835
|
+
visibility: i,
|
|
836
|
+
duration: x,
|
|
829
837
|
style: { display: "grid" },
|
|
830
|
-
children: /* @__PURE__ */
|
|
838
|
+
children: /* @__PURE__ */ y.jsx(
|
|
831
839
|
"span",
|
|
832
840
|
{
|
|
833
|
-
className: `rac-select-arrow-wrapper ${
|
|
834
|
-
children:
|
|
841
|
+
className: `rac-select-arrow-wrapper ${O ? "--open" : ""}`,
|
|
842
|
+
children: ye(N, {
|
|
835
843
|
className: "rac-select-arrow-wrapper"
|
|
836
844
|
})
|
|
837
845
|
}
|
|
@@ -841,18 +849,18 @@ Expected %cArray%c or %cObject%c, but received %c${typeof h}%c.
|
|
|
841
849
|
]
|
|
842
850
|
}
|
|
843
851
|
),
|
|
844
|
-
/* @__PURE__ */
|
|
852
|
+
/* @__PURE__ */ y.jsx(
|
|
845
853
|
Ue,
|
|
846
854
|
{
|
|
847
|
-
visibility:
|
|
848
|
-
selectRef:
|
|
855
|
+
visibility: O,
|
|
856
|
+
selectRef: _,
|
|
849
857
|
onAnimationDone: () => de(!0),
|
|
850
|
-
unmount:
|
|
851
|
-
duration:
|
|
852
|
-
easing:
|
|
858
|
+
unmount: t,
|
|
859
|
+
duration: x,
|
|
860
|
+
easing: S,
|
|
853
861
|
offset: v,
|
|
854
862
|
animateOpacity: j,
|
|
855
|
-
children: /* @__PURE__ */
|
|
863
|
+
children: /* @__PURE__ */ y.jsx(
|
|
856
864
|
"div",
|
|
857
865
|
{
|
|
858
866
|
className: "rac-select-list",
|
|
@@ -869,23 +877,23 @@ Expected %cArray%c or %cObject%c, but received %c${typeof h}%c.
|
|
|
869
877
|
]
|
|
870
878
|
}
|
|
871
879
|
);
|
|
872
|
-
}), ce = (
|
|
873
|
-
function
|
|
874
|
-
const
|
|
875
|
-
return
|
|
876
|
-
if (!
|
|
877
|
-
const
|
|
878
|
-
id: String(o ?? ae(String(
|
|
879
|
-
value:
|
|
880
|
-
label: typeof
|
|
881
|
-
jsx:
|
|
880
|
+
}), ce = (t) => t ? typeof t == "string" || typeof t == "number" ? String(t) : Array.isArray(t) ? t.map(ce).join(" ").replace(/\s+/g, " ").trim() : xe.isValidElement(t) ? ce(t.props.children) : "" : "";
|
|
881
|
+
function Ge({ value: t, id: o, className: s, children: l, disabled: f }) {
|
|
882
|
+
const a = De(me);
|
|
883
|
+
return W(() => {
|
|
884
|
+
if (!a) return;
|
|
885
|
+
const x = ce(l), S = {
|
|
886
|
+
id: String(o ?? ae(String(x))),
|
|
887
|
+
value: t !== void 0 ? t : x,
|
|
888
|
+
label: typeof l == "string" ? l : String(t ?? o),
|
|
889
|
+
jsx: l,
|
|
882
890
|
className: s,
|
|
883
891
|
disabled: !!f
|
|
884
892
|
};
|
|
885
|
-
return
|
|
886
|
-
}, [o,
|
|
893
|
+
return a.registerOption(S), () => a.unregisterOption(S.id);
|
|
894
|
+
}, [o, t, l, s, f]), null;
|
|
887
895
|
}
|
|
888
896
|
export {
|
|
889
|
-
|
|
890
|
-
|
|
897
|
+
Ge as Option,
|
|
898
|
+
Be as Select
|
|
891
899
|
};
|