react-animated-select 0.2.9 → 0.3.1

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