react-animated-select 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,150 +1,150 @@
1
- import Be, { createContext as Ze, memo as Fe, useRef as fe, useState as ue, useCallback as N, useEffect as re, useMemo as de, useId as ze, forwardRef as ur, useImperativeHandle as dr, isValidElement as fr, cloneElement as gr, useContext as Le } from "react";
2
- import { CSSTransition as Te, TransitionGroup as pr } from "react-transition-group";
3
- import { createPortal as hr } from "react-dom";
4
- import './index.css';var ke = { exports: {} }, Se = {};
5
- var Me;
6
- function xr() {
7
- if (Me) return Se;
8
- Me = 1;
9
- var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), i = /* @__PURE__ */ Symbol.for("react.fragment");
10
- function a(o, l, n) {
11
- var m = null;
12
- if (n !== void 0 && (m = "" + n), l.key !== void 0 && (m = "" + l.key), "key" in l) {
13
- n = {};
14
- for (var y in l)
15
- y !== "key" && (n[y] = l[y]);
16
- } else n = l;
17
- return l = n.ref, {
1
+ import dr, { createContext as fr, forwardRef as hr, useRef as ne, useImperativeHandle as gr, useEffect as ue, memo as qe, useCallback as _, useLayoutEffect as Ve, Fragment as pr, useState as le, useMemo as Ne, useId as xr, isValidElement as vr, cloneElement as jr, useContext as Be } from "react";
2
+ import { CSSTransition as Xe, TransitionGroup as Sr } from "react-transition-group";
3
+ import { createPortal as $r } from "react-dom";
4
+ import './index.css';var Je = { exports: {} }, Ye = {};
5
+ var nr;
6
+ function Nr() {
7
+ if (nr) return Ye;
8
+ nr = 1;
9
+ var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
10
+ function o(s, c, g) {
11
+ var y = null;
12
+ if (g !== void 0 && (y = "" + g), c.key !== void 0 && (y = "" + c.key), "key" in c) {
13
+ g = {};
14
+ for (var d in c)
15
+ d !== "key" && (g[d] = c[d]);
16
+ } else g = c;
17
+ return c = g.ref, {
18
18
  $$typeof: e,
19
- type: o,
20
- key: m,
21
- ref: l !== void 0 ? l : null,
22
- props: n
19
+ type: s,
20
+ key: y,
21
+ ref: c !== void 0 ? c : null,
22
+ props: g
23
23
  };
24
24
  }
25
- return Se.Fragment = i, Se.jsx = a, Se.jsxs = a, Se;
25
+ return Ye.Fragment = t, Ye.jsx = o, Ye.jsxs = o, Ye;
26
26
  }
27
- var _e = {};
28
- var Ve;
29
- function br() {
30
- return Ve || (Ve = 1, process.env.NODE_ENV !== "production" && (function() {
27
+ var ze = {};
28
+ var sr;
29
+ function kr() {
30
+ return sr || (sr = 1, process.env.NODE_ENV !== "production" && (function() {
31
31
  function e(r) {
32
32
  if (r == null) return null;
33
33
  if (typeof r == "function")
34
- return r.$$typeof === h ? null : r.displayName || r.name || null;
34
+ return r.$$typeof === re ? null : r.displayName || r.name || null;
35
35
  if (typeof r == "string") return r;
36
36
  switch (r) {
37
- case R:
37
+ case P:
38
38
  return "Fragment";
39
- case T:
39
+ case W:
40
40
  return "Profiler";
41
- case C:
41
+ case M:
42
42
  return "StrictMode";
43
43
  case X:
44
44
  return "Suspense";
45
- case te:
45
+ case Y:
46
46
  return "SuspenseList";
47
- case G:
47
+ case ee:
48
48
  return "Activity";
49
49
  }
50
50
  if (typeof r == "object")
51
51
  switch (typeof r.tag == "number" && console.error(
52
52
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
53
53
  ), r.$$typeof) {
54
- case P:
54
+ case L:
55
55
  return "Portal";
56
- case U:
57
- return r.displayName || "Context";
58
56
  case z:
57
+ return r.displayName || "Context";
58
+ case C:
59
59
  return (r._context.displayName || "Context") + ".Consumer";
60
- case Q:
61
- var g = r.render;
62
- return r = r.displayName, r || (r = g.displayName || g.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
63
- case ne:
64
- return g = r.displayName || null, g !== null ? g : e(r.type) || "Memo";
65
- case c:
66
- g = r._payload, r = r._init;
60
+ case ie:
61
+ var l = r.render;
62
+ return r = r.displayName, r || (r = l.displayName || l.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
63
+ case T:
64
+ return l = r.displayName || null, l !== null ? l : e(r.type) || "Memo";
65
+ case a:
66
+ l = r._payload, r = r._init;
67
67
  try {
68
- return e(r(g));
68
+ return e(r(l));
69
69
  } catch {
70
70
  }
71
71
  }
72
72
  return null;
73
73
  }
74
- function i(r) {
74
+ function t(r) {
75
75
  return "" + r;
76
76
  }
77
- function a(r) {
77
+ function o(r) {
78
78
  try {
79
- i(r);
80
- var g = !1;
79
+ t(r);
80
+ var l = !1;
81
81
  } catch {
82
- g = !0;
82
+ l = !0;
83
83
  }
84
- if (g) {
85
- g = console;
86
- var w = g.error, A = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
87
- return w.call(
88
- g,
84
+ if (l) {
85
+ l = console;
86
+ var m = l.error, w = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
87
+ return m.call(
88
+ l,
89
89
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
90
- A
91
- ), i(r);
90
+ w
91
+ ), t(r);
92
92
  }
93
93
  }
94
- function o(r) {
95
- if (r === R) return "<>";
96
- if (typeof r == "object" && r !== null && r.$$typeof === c)
94
+ function s(r) {
95
+ if (r === P) return "<>";
96
+ if (typeof r == "object" && r !== null && r.$$typeof === a)
97
97
  return "<...>";
98
98
  try {
99
- var g = e(r);
100
- return g ? "<" + g + ">" : "<...>";
99
+ var l = e(r);
100
+ return l ? "<" + l + ">" : "<...>";
101
101
  } catch {
102
102
  return "<...>";
103
103
  }
104
104
  }
105
- function l() {
106
- var r = E.A;
105
+ function c() {
106
+ var r = V.A;
107
107
  return r === null ? null : r.getOwner();
108
108
  }
109
- function n() {
109
+ function g() {
110
110
  return Error("react-stack-top-frame");
111
111
  }
112
- function m(r) {
113
- if (k.call(r, "key")) {
114
- var g = Object.getOwnPropertyDescriptor(r, "key").get;
115
- if (g && g.isReactWarning) return !1;
112
+ function y(r) {
113
+ if (K.call(r, "key")) {
114
+ var l = Object.getOwnPropertyDescriptor(r, "key").get;
115
+ if (l && l.isReactWarning) return !1;
116
116
  }
117
117
  return r.key !== void 0;
118
118
  }
119
- function y(r, g) {
120
- function w() {
121
- H || (H = !0, console.error(
119
+ function d(r, l) {
120
+ function m() {
121
+ A || (A = !0, console.error(
122
122
  "%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)",
123
- g
123
+ l
124
124
  ));
125
125
  }
126
- w.isReactWarning = !0, Object.defineProperty(r, "key", {
127
- get: w,
126
+ m.isReactWarning = !0, Object.defineProperty(r, "key", {
127
+ get: m,
128
128
  configurable: !0
129
129
  });
130
130
  }
131
- function b() {
131
+ function i() {
132
132
  var r = e(this.type);
133
- return ge[r] || (ge[r] = !0, console.error(
133
+ return B[r] || (B[r] = !0, console.error(
134
134
  "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."
135
135
  )), r = this.props.ref, r !== void 0 ? r : null;
136
136
  }
137
- function p(r, g, w, A, B, Z) {
138
- var t = w.ref;
137
+ function E(r, l, m, w, ge, ve) {
138
+ var n = m.ref;
139
139
  return r = {
140
- $$typeof: O,
140
+ $$typeof: F,
141
141
  type: r,
142
- key: g,
143
- props: w,
144
- _owner: A
145
- }, (t !== void 0 ? t : null) !== null ? Object.defineProperty(r, "ref", {
142
+ key: l,
143
+ props: m,
144
+ _owner: w
145
+ }, (n !== void 0 ? n : null) !== null ? Object.defineProperty(r, "ref", {
146
146
  enumerable: !1,
147
- get: b
147
+ get: i
148
148
  }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
149
149
  configurable: !1,
150
150
  enumerable: !1,
@@ -159,109 +159,109 @@ function br() {
159
159
  configurable: !1,
160
160
  enumerable: !1,
161
161
  writable: !0,
162
- value: B
162
+ value: ge
163
163
  }), Object.defineProperty(r, "_debugTask", {
164
164
  configurable: !1,
165
165
  enumerable: !1,
166
166
  writable: !0,
167
- value: Z
167
+ value: ve
168
168
  }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
169
169
  }
170
- function L(r, g, w, A, B, Z) {
171
- var t = g.children;
172
- if (t !== void 0)
173
- if (A)
174
- if (Y(t)) {
175
- for (A = 0; A < t.length; A++)
176
- j(t[A]);
177
- Object.freeze && Object.freeze(t);
170
+ function b(r, l, m, w, ge, ve) {
171
+ var n = l.children;
172
+ if (n !== void 0)
173
+ if (w)
174
+ if (de(n)) {
175
+ for (w = 0; w < n.length; w++)
176
+ k(n[w]);
177
+ Object.freeze && Object.freeze(n);
178
178
  } else
179
179
  console.error(
180
180
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
181
181
  );
182
- else j(t);
183
- if (k.call(g, "key")) {
184
- t = e(r);
185
- var f = Object.keys(g).filter(function(x) {
186
- return x !== "key";
182
+ else k(n);
183
+ if (K.call(l, "key")) {
184
+ n = e(r);
185
+ var p = Object.keys(l).filter(function(f) {
186
+ return f !== "key";
187
187
  });
188
- A = 0 < f.length ? "{key: someKey, " + f.join(": ..., ") + ": ...}" : "{key: someKey}", ie[t + A] || (f = 0 < f.length ? "{" + f.join(": ..., ") + ": ...}" : "{}", console.error(
188
+ w = 0 < p.length ? "{key: someKey, " + p.join(": ..., ") + ": ...}" : "{key: someKey}", x[n + w] || (p = 0 < p.length ? "{" + p.join(": ..., ") + ": ...}" : "{}", console.error(
189
189
  `A props object containing a "key" prop is being spread into JSX:
190
190
  let props = %s;
191
191
  <%s {...props} />
192
192
  React keys must be passed directly to JSX without using spread:
193
193
  let props = %s;
194
194
  <%s key={someKey} {...props} />`,
195
- A,
196
- t,
197
- f,
198
- t
199
- ), ie[t + A] = !0);
195
+ w,
196
+ n,
197
+ p,
198
+ n
199
+ ), x[n + w] = !0);
200
200
  }
201
- if (t = null, w !== void 0 && (a(w), t = "" + w), m(g) && (a(g.key), t = "" + g.key), "key" in g) {
202
- w = {};
203
- for (var s in g)
204
- s !== "key" && (w[s] = g[s]);
205
- } else w = g;
206
- return t && y(
207
- w,
201
+ if (n = null, m !== void 0 && (o(m), n = "" + m), y(l) && (o(l.key), n = "" + l.key), "key" in l) {
202
+ m = {};
203
+ for (var j in l)
204
+ j !== "key" && (m[j] = l[j]);
205
+ } else m = l;
206
+ return n && d(
207
+ m,
208
208
  typeof r == "function" ? r.displayName || r.name || "Unknown" : r
209
- ), p(
209
+ ), E(
210
210
  r,
211
- t,
212
- w,
213
- l(),
214
- B,
215
- Z
211
+ n,
212
+ m,
213
+ c(),
214
+ ge,
215
+ ve
216
216
  );
217
217
  }
218
- function j(r) {
219
- V(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === c && (r._payload.status === "fulfilled" ? V(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
218
+ function k(r) {
219
+ N(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === a && (r._payload.status === "fulfilled" ? N(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
220
220
  }
221
- function V(r) {
222
- return typeof r == "object" && r !== null && r.$$typeof === O;
221
+ function N(r) {
222
+ return typeof r == "object" && r !== null && r.$$typeof === F;
223
223
  }
224
- var J = Be, O = /* @__PURE__ */ Symbol.for("react.transitional.element"), P = /* @__PURE__ */ Symbol.for("react.portal"), R = /* @__PURE__ */ Symbol.for("react.fragment"), C = /* @__PURE__ */ Symbol.for("react.strict_mode"), T = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), U = /* @__PURE__ */ Symbol.for("react.context"), Q = /* @__PURE__ */ Symbol.for("react.forward_ref"), X = /* @__PURE__ */ Symbol.for("react.suspense"), te = /* @__PURE__ */ Symbol.for("react.suspense_list"), ne = /* @__PURE__ */ Symbol.for("react.memo"), c = /* @__PURE__ */ Symbol.for("react.lazy"), G = /* @__PURE__ */ Symbol.for("react.activity"), h = /* @__PURE__ */ Symbol.for("react.client.reference"), E = J.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, k = Object.prototype.hasOwnProperty, Y = Array.isArray, S = console.createTask ? console.createTask : function() {
224
+ var R = dr, F = /* @__PURE__ */ Symbol.for("react.transitional.element"), L = /* @__PURE__ */ Symbol.for("react.portal"), P = /* @__PURE__ */ Symbol.for("react.fragment"), M = /* @__PURE__ */ Symbol.for("react.strict_mode"), W = /* @__PURE__ */ Symbol.for("react.profiler"), C = /* @__PURE__ */ Symbol.for("react.consumer"), z = /* @__PURE__ */ Symbol.for("react.context"), ie = /* @__PURE__ */ Symbol.for("react.forward_ref"), X = /* @__PURE__ */ Symbol.for("react.suspense"), Y = /* @__PURE__ */ Symbol.for("react.suspense_list"), T = /* @__PURE__ */ Symbol.for("react.memo"), a = /* @__PURE__ */ Symbol.for("react.lazy"), ee = /* @__PURE__ */ Symbol.for("react.activity"), re = /* @__PURE__ */ Symbol.for("react.client.reference"), V = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, de = Array.isArray, ae = console.createTask ? console.createTask : function() {
225
225
  return null;
226
226
  };
227
- J = {
227
+ R = {
228
228
  react_stack_bottom_frame: function(r) {
229
229
  return r();
230
230
  }
231
231
  };
232
- var H, ge = {}, K = J.react_stack_bottom_frame.bind(
233
- J,
234
- n
235
- )(), le = S(o(n)), ie = {};
236
- _e.Fragment = R, _e.jsx = function(r, g, w) {
237
- var A = 1e4 > E.recentlyCreatedOwnerStacks++;
238
- return L(
232
+ var A, B = {}, se = R.react_stack_bottom_frame.bind(
233
+ R,
234
+ g
235
+ )(), v = ae(s(g)), x = {};
236
+ ze.Fragment = P, ze.jsx = function(r, l, m) {
237
+ var w = 1e4 > V.recentlyCreatedOwnerStacks++;
238
+ return b(
239
239
  r,
240
- g,
241
- w,
240
+ l,
241
+ m,
242
242
  !1,
243
- A ? Error("react-stack-top-frame") : K,
244
- A ? S(o(r)) : le
243
+ w ? Error("react-stack-top-frame") : se,
244
+ w ? ae(s(r)) : v
245
245
  );
246
- }, _e.jsxs = function(r, g, w) {
247
- var A = 1e4 > E.recentlyCreatedOwnerStacks++;
248
- return L(
246
+ }, ze.jsxs = function(r, l, m) {
247
+ var w = 1e4 > V.recentlyCreatedOwnerStacks++;
248
+ return b(
249
249
  r,
250
- g,
251
- w,
250
+ l,
251
+ m,
252
252
  !0,
253
- A ? Error("react-stack-top-frame") : K,
254
- A ? S(o(r)) : le
253
+ w ? Error("react-stack-top-frame") : se,
254
+ w ? ae(s(r)) : v
255
255
  );
256
256
  };
257
- })()), _e;
257
+ })()), ze;
258
258
  }
259
- var Ue;
260
- function yr() {
261
- return Ue || (Ue = 1, process.env.NODE_ENV === "production" ? ke.exports = xr() : ke.exports = br()), ke.exports;
259
+ var ir;
260
+ function Rr() {
261
+ return ir || (ir = 1, process.env.NODE_ENV === "production" ? Je.exports = Nr() : Je.exports = kr()), Je.exports;
262
262
  }
263
- var d = yr();
264
- const qe = ({ className: e = "", ...i }) => /* @__PURE__ */ d.jsx(
263
+ var u = Rr();
264
+ const or = ({ className: e = "", ...t }) => /* @__PURE__ */ u.jsx(
265
265
  "svg",
266
266
  {
267
267
  className: e,
@@ -272,10 +272,10 @@ const qe = ({ className: e = "", ...i }) => /* @__PURE__ */ d.jsx(
272
272
  width: "1em",
273
273
  height: "1em",
274
274
  fill: "currentColor",
275
- ...i,
276
- children: /* @__PURE__ */ d.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" })
275
+ ...t,
276
+ children: /* @__PURE__ */ u.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" })
277
277
  }
278
- ), mr = ({ className: e = "", ...i }) => /* @__PURE__ */ d.jsx(
278
+ ), _r = ({ className: e = "", ...t }) => /* @__PURE__ */ u.jsx(
279
279
  "svg",
280
280
  {
281
281
  className: e,
@@ -284,10 +284,10 @@ const qe = ({ className: e = "", ...i }) => /* @__PURE__ */ d.jsx(
284
284
  width: "1em",
285
285
  height: "1em",
286
286
  fill: "currentColor",
287
- ...i,
288
- children: /* @__PURE__ */ d.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" })
287
+ ...t,
288
+ children: /* @__PURE__ */ u.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" })
289
289
  }
290
- ), Xe = ({ className: e = "", ...i }) => /* @__PURE__ */ d.jsx(
290
+ ), ar = ({ className: e = "", ...t }) => /* @__PURE__ */ u.jsx(
291
291
  "svg",
292
292
  {
293
293
  className: e,
@@ -296,1163 +296,1328 @@ const qe = ({ className: e = "", ...i }) => /* @__PURE__ */ d.jsx(
296
296
  width: "1em",
297
297
  height: "1em",
298
298
  fill: "currentColor",
299
- ...i,
300
- children: /* @__PURE__ */ d.jsx("path", { d: "M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z" })
299
+ ...t,
300
+ children: /* @__PURE__ */ u.jsx("path", { d: "M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z" })
301
301
  }
302
- ), He = (e, i = "invalid-option", a = "") => {
303
- const o = a ? a.replace(/:/g, "") : "";
302
+ ), Ze = (e, t = "invalid-option", o = "") => {
303
+ const s = o ? o.replace(/:/g, "") : "";
304
304
  if (typeof e != "string" || !e.trim())
305
- return o ? `${i}-${o}` : `${i}-${Math.random().toString(36).slice(2, 8)}`;
306
- const l = e.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, "-").replace(/[^\p{L}\p{N}-]+/gu, "").toLowerCase();
307
- return l ? l || `${i}-${Math.random().toString(36).slice(2, 8)}` : o ? `${i}-${o}` : `${i}-${Math.random().toString(36).slice(2, 8)}`;
308
- }, Ge = Ze(null);
309
- function Er({
310
- visibility: e,
311
- children: i,
312
- selectRef: a,
313
- onAnimationDone: o,
314
- unmount: l = !0,
315
- duration: n,
316
- easing: m,
317
- offset: y,
318
- animateOpacity: b,
319
- style: p,
320
- className: L
321
- }) {
322
- const j = fe(null), [V, J] = ue(0), [O, P] = ue({ top: 0, left: 0, width: 0 }), R = N(() => {
323
- if (a?.current) {
324
- const c = a.current.getBoundingClientRect(), G = window.innerHeight, h = j.current?.scrollHeight || 250, E = G - c.bottom, k = E < h && c.top > E;
325
- P({
326
- top: c.top,
327
- bottom: c.bottom,
328
- left: c.left,
329
- width: c.width,
330
- isUpward: k
331
- });
332
- }
333
- }, [a]);
334
- re(() => {
335
- if (e)
336
- return R(), window.addEventListener("scroll", R, !0), window.addEventListener("resize", R), () => {
337
- window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R);
338
- };
339
- }, [e, R]);
340
- const C = `height var(--rac-duration) ${m}${b ? `, opacity var(--rac-duration) ${m}` : ""}`;
341
- re(() => {
342
- if (!a?.current) return;
343
- J(a.current.offsetHeight);
344
- const G = new ResizeObserver((h) => {
345
- for (let E of h) J(E.target.offsetHeight);
346
- });
347
- return G.observe(a.current), () => G.disconnect();
348
- }, [a]);
349
- const T = {
350
- position: "fixed",
351
- "--rac-duration": `${n}ms`,
352
- "--rac-easing": m,
353
- left: `${O.left}px`,
354
- width: `${O.width}px`,
355
- overflow: "hidden",
356
- zIndex: "1",
357
- height: e ? "auto" : "0px",
358
- opacity: b ? e ? 1 : 0 : 1,
359
- pointerEvents: e ? "all" : "none",
360
- visibility: V ? "visible" : "hidden",
361
- boxSizing: "border-box",
362
- transformOrigin: O.isUpward ? "bottom" : "top",
363
- ...O.isUpward ? {
364
- bottom: `${window.innerHeight - O.top + y}px`,
365
- top: "auto"
366
- } : {
367
- top: `${O.bottom + y}px`,
368
- bottom: "auto"
369
- },
370
- ...Object.fromEntries(
371
- Object.entries(p || {}).map(([c, G]) => [
372
- c.startsWith("--") ? c : `--rac-${c.replace(/([A-Z])/g, "-$1").toLowerCase()}`,
373
- G
374
- ])
375
- )
376
- }, z = N(() => {
377
- const c = j.current;
378
- c && (c.style.height = "0px", b && (c.style.opacity = "0"), c.style.transition = "");
379
- }, [b]), U = N(() => {
380
- const c = j.current;
381
- c && (c.style.transition = C, c.style.height = `${c.scrollHeight}px`, b && (c.style.opacity = "1"));
382
- }, [C, b]), Q = N(() => {
383
- const c = j.current;
384
- c && (c.style.height = "auto", c.style.transition = "", o && o());
385
- }, [o]), X = N(() => {
386
- const c = j.current;
387
- c && (c.style.height = `${c.scrollHeight}px`, b && (c.style.opacity = "1"), c.offsetHeight, c.style.transition = C);
388
- }, [C, b]), te = N(() => {
389
- const c = j.current;
390
- c && (c.style.height = "0px", b && (c.style.opacity = "0"));
391
- }, [b]), ne = N(() => {
392
- const c = j.current;
393
- c && (c.style.transition = "");
394
- }, []);
395
- return hr(
396
- /* @__PURE__ */ d.jsx(
397
- Te,
398
- {
399
- in: e,
400
- timeout: n,
401
- classNames: "rac-options",
402
- unmountOnExit: l,
403
- nodeRef: j,
404
- onEnter: z,
405
- onEntering: U,
406
- onEntered: Q,
407
- onExit: X,
408
- onExiting: te,
409
- onExited: ne,
410
- children: /* @__PURE__ */ d.jsx(
411
- "div",
412
- {
413
- ref: j,
414
- className: `rac-options ${L || ""}`,
415
- style: {
416
- ...T,
417
- "--rac-duration": `${n}ms`,
418
- "--rac-duration-fast": "calc(var(--rac-duration) * 0.5)",
419
- "--rac-duration-base": "var(--rac-duration)",
420
- "--rac-duration-slow": "calc(var(--rac-duration) * 1.3)"
421
- },
422
- onMouseDown: (c) => {
423
- c.preventDefault();
424
- },
425
- children: i
426
- }
427
- )
428
- }
429
- ),
430
- document.body
431
- );
432
- }
433
- const vr = Fe(Er, (e, i) => e.visibility === i.visibility && e.duration === i.duration && e.easing === i.easing && e.offset === i.offset && e.animateOpacity === i.animateOpacity && e.selectRef === i.selectRef && e.children === i.children && JSON.stringify(e.style) === JSON.stringify(i.style));
434
- function Re({
435
- visibility: e,
436
- children: i,
437
- duration: a = 300,
438
- unmount: o,
439
- style: l
440
- }) {
441
- const n = fe(null);
442
- return /* @__PURE__ */ d.jsx(
443
- Te,
305
+ return s ? `${t}-${s}` : `${t}-${Math.random().toString(36).slice(2, 8)}`;
306
+ const c = e.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, "-").replace(/[^\p{L}\p{N}-]+/gu, "").toLowerCase();
307
+ return c ? c || `${t}-${Math.random().toString(36).slice(2, 8)}` : s ? `${t}-${s}` : `${t}-${Math.random().toString(36).slice(2, 8)}`;
308
+ }, er = fr(null), Fe = hr(({ className: e = "", visibility: t, setLeaving: o, setSpacer: s, children: c, duration: g = 300, unmount: y, style: d, exit: i = !0 }, E) => {
309
+ const b = ne(null);
310
+ return gr(E, () => b.current), ue(() => {
311
+ !t && b.current && (b.current.style.width = "0px");
312
+ }, []), /* @__PURE__ */ u.jsx(
313
+ Xe,
444
314
  {
445
- in: e,
446
- timeout: a,
315
+ onEnter: () => {
316
+ b.current.style.transition = "none", b.current.style.width = "0px";
317
+ },
318
+ onEntering: () => {
319
+ requestAnimationFrame(() => {
320
+ requestAnimationFrame(() => {
321
+ b.current && (b.current.style.transition = `width ${g}ms, color ${g}ms, background-color ${g}ms`, b.current.style.width = b.current.scrollWidth + "px");
322
+ });
323
+ });
324
+ },
325
+ onEntered: () => {
326
+ b.current.style.width = "auto", s?.(!1);
327
+ },
328
+ onExit: () => {
329
+ b.current.style.width = b.current.scrollWidth + "px", b.current.offsetHeight, o?.(!0);
330
+ },
331
+ onExiting: () => b.current.style.width = "0px",
332
+ onExited: () => {
333
+ y?.(), o?.(!1), s?.(!1);
334
+ },
447
335
  classNames: "rac-slide-left",
448
- unmountOnExit: !0,
449
- nodeRef: n,
450
- onEnter: () => n.current.style.width = "0px",
451
- onEntering: () => n.current.style.width = n.current.scrollWidth + "px",
452
- onEntered: () => n.current.style.width = "auto",
453
- onExit: () => n.current.style.width = n.current.scrollWidth + "px",
454
- onExiting: () => n.current.style.width = "0px",
455
- onExited: () => o?.(),
456
- children: /* @__PURE__ */ d.jsx(
336
+ unmountOnExit: i,
337
+ timeout: g,
338
+ nodeRef: b,
339
+ in: t,
340
+ children: /* @__PURE__ */ u.jsx(
457
341
  "div",
458
342
  {
459
- ref: n,
343
+ className: e,
344
+ ref: b,
460
345
  style: {
461
- ...l,
346
+ transition: `width ${g}ms, color ${g}ms, background-color ${g}ms`,
347
+ willChange: "width",
462
348
  overflow: "hidden",
463
- transition: `width ${a}ms ease`
349
+ ...d
464
350
  },
465
- children: i
351
+ children: c
466
352
  }
467
353
  )
468
354
  }
469
355
  );
470
- }
471
- const Ke = ({ children: e, duration: i, widthMode: a = !1, ...o }) => {
472
- const l = fe(null);
473
- return /* @__PURE__ */ d.jsx(
474
- Te,
356
+ }), Tr = qe(({ element: e, index: t, leaving: o, setLeaving: s, setSpacer: c, selectRef: g, spacer: y, delSpacer: d, setVisibility: i, setActiveHoverId: E, activeHoverId: b, swipedId: k, setSwipedId: N, deleteInline: R, remove: F, renderIcon: L, DelIcon: P, normalizedOptions: M, swiped: W, onSwipe: C, deleting: z, setDeleting: ie, onRender: X, duration: Y }) => {
357
+ const T = ne(null), a = ne(!1), ee = ne(!1), re = ne(0), V = ne(null), K = _((x) => {
358
+ re.current = x.touches[0].clientX, a.current = !1, T.current && clearTimeout(T.current), T.current = setTimeout(() => {
359
+ ie(!0), a.current = !0, g.current?.focus(), i(!1), window.navigator.vibrate && window.navigator.vibrate(50);
360
+ }, 600), x.preventDefault();
361
+ }, []), de = _((x) => {
362
+ T.current && clearTimeout(T.current);
363
+ const r = x.touches[0].clientX, l = re.current - r;
364
+ Math.abs(l) > 10 && (ee.current = !0, l > 30 && !W ? C(e.id) : l < -30 && W && C(null));
365
+ }, [e.id, W, C]), ae = _((x) => {
366
+ T.current && clearTimeout(T.current), a.current && x.preventDefault();
367
+ }, []);
368
+ let A = null;
369
+ if (e?.jsx)
370
+ A = e.jsx;
371
+ else if (e?.name)
372
+ A = e.name;
373
+ else if (e?.raw !== void 0) {
374
+ const x = M.find(
375
+ (r) => r.raw === e.raw || r.original === e.raw || r.userId === e.raw
376
+ );
377
+ x && (A = x.jsx ?? x.name);
378
+ }
379
+ A == null && (A = typeof e == "object" ? e.label ?? e.name ?? e.value ?? "Selected item" : String(e));
380
+ const B = _((x) => {
381
+ x.stopPropagation(), x.preventDefault();
382
+ }, []), se = _((x) => {
383
+ B(x), F(e.id), C(null);
384
+ }, [e.id, F, C]), v = _((x) => {
385
+ if (B(x), a.current) {
386
+ a.current = !1;
387
+ return;
388
+ }
389
+ if (z) {
390
+ se(x);
391
+ return;
392
+ }
393
+ }, [z, se]);
394
+ return Ve(() => {
395
+ if (V.current && X) {
396
+ const x = V.current.offsetWidth;
397
+ X(x);
398
+ }
399
+ }, [X, A]), /* @__PURE__ */ u.jsxs(pr, { children: [
400
+ /* @__PURE__ */ u.jsxs(
401
+ "div",
402
+ {
403
+ className: `rac-multiple-selected-option ${z ? "--deleting-shake" : ""}`,
404
+ onMouseEnter: () => E(e.id),
405
+ onMouseLeave: () => E(null),
406
+ onTouchStart: K,
407
+ onTouchMove: de,
408
+ onTouchEnd: ae,
409
+ onClick: v,
410
+ ref: V,
411
+ children: [
412
+ A,
413
+ /* @__PURE__ */ u.jsx(
414
+ Fe,
415
+ {
416
+ style: {
417
+ backgroundColor: z || R ? "transparent" : "--rac-multiple-del-bg",
418
+ position: z || R ? "relative" : "absolute"
419
+ },
420
+ visibility: b === e.id || k === e.id || z,
421
+ className: "rac-multiple-del",
422
+ setLeaving: s,
423
+ setSpacer: c,
424
+ duration: Y,
425
+ children: L(P, { onClick: se, onMouseDown: B })
426
+ }
427
+ )
428
+ ]
429
+ }
430
+ ),
431
+ /* @__PURE__ */ u.jsx(
432
+ Fe,
433
+ {
434
+ visibility: !o && !y?.state && !b && !k && !z && R && d,
435
+ className: "rac-multiple-option",
436
+ style: { visibility: "hidden" },
437
+ children: /* @__PURE__ */ u.jsx(
438
+ "div",
439
+ {
440
+ style: { padding: 0, marginRight: 0, marginLeft: 0 },
441
+ className: "rac-multiple-selected-option",
442
+ children: L(P)
443
+ }
444
+ )
445
+ }
446
+ )
447
+ ] });
448
+ }), mr = ({ children: e, setLeaving: t, duration: o, setSpacer: s, id: c = null, widthMode: g = !1, ...y }) => {
449
+ const d = ne(null);
450
+ return /* @__PURE__ */ u.jsx(
451
+ Xe,
475
452
  {
476
- nodeRef: l,
477
- timeout: i,
478
453
  classNames: "rac-slide-left",
479
- ...o,
454
+ timeout: o,
455
+ nodeRef: d,
456
+ unmountOnExit: !0,
457
+ ...y,
480
458
  onEnter: () => {
481
- const n = l.current;
482
- a ? n.style.width = "0px" : (n.style.height = "0px", n.style.transform = "translateY(-10px)"), n.style.opacity = "0";
459
+ const i = d.current;
460
+ i && (g ? i.style.width = "0px" : (i.style.height = "0px", i.style.transform = "translateY(-10px)"), i.style.opacity = "0");
483
461
  },
484
462
  onEntering: () => {
485
- const n = l.current;
486
- n.offsetHeight, a ? n.style.width = n.scrollWidth + "px" : (n.style.height = n.scrollHeight + "px", n.style.transform = "translateY(0)"), n.style.opacity = "1";
463
+ const i = d.current;
464
+ i.offsetHeight, g ? i.style.width = i.scrollWidth + "px" : (i.style.height = i.scrollHeight + "px", i.style.transform = "translateY(0)"), i.style.opacity = "1";
487
465
  },
488
466
  onEntered: () => {
489
- const n = l.current;
490
- n.style.width = a ? "auto" : "", n.style.height = a ? "" : "auto", n.style.opacity = "1", n.style.transform = "";
467
+ const i = d.current;
468
+ i.style.width = g ? "auto" : "", i.style.height = g ? "" : "100%", i.style.opacity = "1", i.style.transform = "", s?.(!1);
491
469
  },
492
470
  onExit: () => {
493
- const n = l.current;
494
- a ? n.style.width = n.offsetWidth + "px" : (n.style.height = n.offsetHeight + "px", n.style.position = "absolute"), n.style.opacity = "1";
471
+ const i = d.current;
472
+ g ? i.style.width = i.offsetWidth + "px" : (i.style.height = i.offsetHeight + "px", i.style.position = "absolute"), i.style.opacity = "1", t?.(!0);
495
473
  },
496
474
  onExiting: () => {
497
- const n = l.current;
498
- a ? n.style.width = "0px" : (n.style.height = "0px", n.style.transform = "translateY(10px)"), n.style.opacity = "0";
475
+ const i = d.current;
476
+ g ? i.style.width = "0px" : (i.style.height = "0px", i.style.transform = "translateY(10px)"), i.style.opacity = "0";
499
477
  },
500
- children: /* @__PURE__ */ d.jsx(
478
+ onExited: () => {
479
+ s?.(!1), t?.(!1);
480
+ },
481
+ children: /* @__PURE__ */ u.jsx(
501
482
  "div",
502
483
  {
503
- ref: l,
484
+ ref: d,
485
+ id: c,
504
486
  style: {
505
- display: "flex",
487
+ transition: `all ${o}ms ease`,
506
488
  alignItems: "center",
507
- height: "100%",
508
- overflow: "hidden",
509
489
  whiteSpace: "nowrap",
510
- transition: `all ${i}ms ease`,
511
- top: 0,
512
- left: 0
490
+ overflow: "hidden",
491
+ display: "flex",
492
+ left: 0,
493
+ top: 0
513
494
  },
514
495
  children: e
515
496
  }
516
497
  )
517
498
  }
518
499
  );
519
- }, wr = Fe(({ element: e, index: i, remove: a, renderIcon: o, DelIcon: l, normalizedOptions: n }) => {
520
- let m = null;
521
- if (e?.jsx)
522
- m = e.jsx;
523
- else if (e?.name)
524
- m = e.name;
525
- else if (e?.raw !== void 0) {
526
- const p = n.find(
527
- (L) => L.raw === e.raw || L.original === e.raw || L.userId === e.raw
528
- );
529
- p && (m = p.jsx ?? p.name);
530
- }
531
- m == null && (m = typeof e == "object" ? e.label ?? e.name ?? e.value ?? "Selected item" : String(e));
532
- const y = N((p) => {
533
- p.stopPropagation(), p.preventDefault(), a(e.id);
534
- }, [e.id, a]), b = N((p) => {
535
- p.stopPropagation(), p.preventDefault();
536
- }, []);
537
- return /* @__PURE__ */ d.jsxs("div", { className: "rac-multiple-selected-option", children: [
538
- m,
539
- o(l, { onClick: y, onMouseDown: b })
540
- ] });
541
- }), jr = Fe(({
542
- selectRef: e,
543
- selectId: i,
544
- removeOption: a,
545
- renderOptions: o,
546
- selected: l,
547
- selectedIDs: n,
548
- setSelectedIds: m,
549
- normalizedOptions: y,
550
- title: b,
551
- visibility: p,
552
- active: L,
553
- hasOptions: j,
554
- hasActualValue: V,
555
- optionsClassName: J,
556
- selectedText: O,
557
- disabled: P,
558
- loading: R,
559
- error: C,
560
- registerOption: T,
561
- unregisterOption: z,
562
- handleBlur: U,
563
- handleFocus: Q,
564
- handleToggle: X,
565
- handleKeyDown: te,
566
- handleListScroll: ne,
567
- setAnimationFinished: c,
568
- clear: G,
569
- children: h,
570
- placeholder: E,
571
- className: k,
572
- style: Y,
573
- duration: S,
574
- easing: H,
575
- offset: ge,
576
- animateOpacity: K,
577
- unmount: le,
578
- ArrowIcon: ie,
579
- ClearIcon: r,
580
- DelIcon: g,
581
- renderIcon: w,
582
- hasMore: A,
583
- loadButton: B
584
- }) => {
585
- const Z = fe(null);
586
- re(() => {
587
- e && (typeof e == "function" ? e(Z.current) : e.current = Z.current);
588
- }, [e]);
589
- const t = N((s) => {
590
- a ? a(s) : m((x) => x.filter((_) => _.id !== s));
591
- }, [a, m]), f = n?.map((s, x) => /* @__PURE__ */ d.jsx(
592
- Ke,
500
+ }, Ar = qe(({ element: e, index: t, leaving: o, setLeaving: s, selectRef: c, setVisibility: g, setActiveHoverId: y, delSpacer: d, swiped: i, swipedId: E, setSwipedId: b, onSwipe: k, activeHoverId: N, deleteInline: R, spacer: F, duration: L, normalizedOptions: P, setDeleting: M, renderIcon: W, deleting: C, DelIcon: z, remove: ie, registerItemWidth: X, setSpacer: Y, ...T }) => /* @__PURE__ */ u.jsxs(pr, { children: [
501
+ /* @__PURE__ */ u.jsx(
502
+ mr,
593
503
  {
594
- duration: S,
504
+ className: "rac-multiple-option",
505
+ onEnter: T.onEnter,
506
+ setLeaving: s,
507
+ setSpacer: Y,
508
+ onExit: T.onExit,
509
+ duration: L,
510
+ in: T.in,
511
+ id: e.id,
595
512
  widthMode: !0,
596
- children: /* @__PURE__ */ d.jsx(
597
- wr,
513
+ children: /* @__PURE__ */ u.jsx(
514
+ Tr,
598
515
  {
599
- element: s,
600
- index: x,
601
- remove: t,
602
- renderIcon: w,
603
- DelIcon: g,
604
- normalizedOptions: y
516
+ onRender: (a) => X(e.id, a),
517
+ normalizedOptions: P,
518
+ setActiveHoverId: y,
519
+ activeHoverId: N,
520
+ setVisibility: g,
521
+ deleteInline: R,
522
+ setDeleting: M,
523
+ setSwipedId: b,
524
+ setLeaving: s,
525
+ renderIcon: W,
526
+ setSpacer: Y,
527
+ selectRef: c,
528
+ delSpacer: d,
529
+ duration: L,
530
+ deleting: C,
531
+ swipedId: E,
532
+ onSwipe: k,
533
+ element: e,
534
+ DelIcon: z,
535
+ leaving: o,
536
+ swiped: i,
537
+ remove: ie,
538
+ spacer: F,
539
+ index: t
605
540
  },
606
- s.id ?? x
541
+ e.id ?? t
607
542
  )
608
- },
609
- s.id ?? x
610
- ));
611
- return /* @__PURE__ */ d.jsxs(
612
- Ge.Provider,
543
+ }
544
+ ),
545
+ F.state && F.id === e.id && /* @__PURE__ */ u.jsx(
546
+ "div",
613
547
  {
614
- value: { registerOption: T, unregisterOption: z },
615
- children: [
616
- h,
617
- /* @__PURE__ */ d.jsxs(
548
+ style: { width: F.width - 2 },
549
+ className: "rac-spacer"
550
+ }
551
+ )
552
+ ] }));
553
+ function Or({ visibility: e, children: t, selectRef: o, onAnimationDone: s, unmount: c = !0, duration: g, easing: y, offset: d, animateOpacity: i, style: E, className: b, setBottomDirection: k = () => {
554
+ } }) {
555
+ const N = ne(null), [R, F] = le({ top: 0, left: 0, width: 0 }), L = ne(R);
556
+ ue(() => {
557
+ L.current = R;
558
+ }, [R]);
559
+ const P = _(() => {
560
+ if (o?.current) {
561
+ const a = o.current.getBoundingClientRect(), ee = window.innerHeight, re = N.current?.scrollHeight || 250, V = ee - a.bottom, K = V < re && a.top > V;
562
+ k(K), F({
563
+ top: a.top,
564
+ bottom: a.bottom,
565
+ left: a.left,
566
+ width: a.width,
567
+ isUpward: K
568
+ });
569
+ }
570
+ }, [o]);
571
+ ue(() => {
572
+ if (e)
573
+ return P(), window.addEventListener("scroll", P, !0), window.addEventListener("resize", P), () => {
574
+ window.removeEventListener("scroll", P, !0), window.removeEventListener("resize", P);
575
+ };
576
+ }, [e, P]);
577
+ const M = `height var(--rac-duration) ${y}${i ? `, opacity var(--rac-duration) ${y}` : ""}`;
578
+ Ve(() => {
579
+ if (!o?.current) return;
580
+ const a = new ResizeObserver((ee) => {
581
+ for (let re of ee)
582
+ if (e && N.current && o.current) {
583
+ const V = o.current.getBoundingClientRect(), { isUpward: K } = L.current;
584
+ N.current.style.width = `${V.width}px`, N.current.style.left = `${V.left}px`, K ? N.current.style.bottom = `${window.innerHeight - V.top + d}px` : N.current.style.top = `${V.bottom + d}px`;
585
+ }
586
+ });
587
+ return a.observe(o.current), () => a.disconnect();
588
+ }, [o, e, d]);
589
+ const W = {
590
+ position: "fixed",
591
+ "--rac-duration": `${g}ms`,
592
+ "--rac-easing": y,
593
+ left: `${R.left}px`,
594
+ width: `${R.width}px`,
595
+ overflow: "hidden",
596
+ zIndex: "2147483647",
597
+ height: e ? "auto" : "0px",
598
+ opacity: i ? e ? 1 : 0 : 1,
599
+ pointerEvents: e ? "all" : "none",
600
+ // visibility: visibility ? 'visible' : 'hidden',
601
+ boxSizing: "border-box",
602
+ transformOrigin: R.isUpward ? "bottom" : "top",
603
+ ...R.isUpward ? {
604
+ bottom: `${window.innerHeight - R.top + d}px`,
605
+ top: "auto"
606
+ } : {
607
+ top: `${R.bottom + d}px`,
608
+ bottom: "auto"
609
+ },
610
+ ...Object.fromEntries(
611
+ Object.entries(E || {}).map(([a, ee]) => [
612
+ a.startsWith("--") ? a : `--rac-${a.replace(/([A-Z])/g, "-$1").toLowerCase()}`,
613
+ ee
614
+ ])
615
+ )
616
+ }, C = _(() => {
617
+ const a = N.current;
618
+ a && (a.style.height = "0px", i && (a.style.opacity = "0"), a.style.transition = "");
619
+ }, [i]), z = _(() => {
620
+ const a = N.current;
621
+ a && (a.style.transition = M, a.style.height = `${a.scrollHeight}px`, i && (a.style.opacity = "1"));
622
+ }, [M, i]), ie = _(() => {
623
+ const a = N.current;
624
+ a && (a.style.height = "auto", a.style.transition = "", s && s());
625
+ }, [s]), X = _(() => {
626
+ const a = N.current;
627
+ a && (a.style.height = `${a.scrollHeight}px`, i && (a.style.opacity = "1"), a.offsetHeight, a.style.transition = M);
628
+ }, [M, i]), Y = _(() => {
629
+ const a = N.current;
630
+ a && (a.style.height = "0px", i && (a.style.opacity = "0"));
631
+ }, [i]), T = _(() => {
632
+ const a = N.current;
633
+ a && (a.style.transition = "");
634
+ }, []);
635
+ return $r(
636
+ /* @__PURE__ */ u.jsx(
637
+ Xe,
638
+ {
639
+ in: e,
640
+ timeout: g,
641
+ classNames: "rac-options",
642
+ unmountOnExit: c,
643
+ nodeRef: N,
644
+ onEnter: C,
645
+ onEntering: z,
646
+ onEntered: ie,
647
+ onExit: X,
648
+ onExiting: Y,
649
+ onExited: T,
650
+ children: /* @__PURE__ */ u.jsx(
618
651
  "div",
619
652
  {
620
- ref: Z,
653
+ ref: N,
654
+ className: `rac-options ${b || ""}`,
621
655
  style: {
622
- ...Y,
623
- "--rac-duration": `${S}ms`,
656
+ ...W,
657
+ "--rac-duration": `${g}ms`,
624
658
  "--rac-duration-fast": "calc(var(--rac-duration) * 0.5)",
625
659
  "--rac-duration-base": "var(--rac-duration)",
626
660
  "--rac-duration-slow": "calc(var(--rac-duration) * 1.3)"
627
661
  },
628
- className: `rac-select
629
- ${k}
630
- ${!j || P ? "rac-disabled-style" : ""}
631
- ${R ? "rac-loading-style" : ""}
632
- ${C ? "rac-error-style" : ""}`,
633
- tabIndex: L ? 0 : -1,
634
- role: "combobox",
635
- "aria-haspopup": "listbox",
636
- "aria-expanded": p,
637
- "aria-controls": `${i}-listbox`,
638
- "aria-label": E,
639
- "aria-disabled": P || !j,
640
- ...L && {
641
- onBlur: U,
642
- onFocus: Q,
643
- onClick: X,
644
- onKeyDown: te
645
- },
646
- children: [
647
- /* @__PURE__ */ d.jsx(
648
- "div",
649
- {
650
- className: `rac-select-title
651
- ${!C && !R && l?.type === "boolean" ? l.raw ? "rac-true-option" : "rac-false-option" : ""}
662
+ onMouseDown: (a) => a.preventDefault(),
663
+ children: t
664
+ }
665
+ )
666
+ }
667
+ ),
668
+ document.body
669
+ );
670
+ }
671
+ const Pr = qe(Or, (e, t) => e.visibility === t.visibility && e.duration === t.duration && e.easing === t.easing && e.offset === t.offset && e.animateOpacity === t.animateOpacity && e.selectRef === t.selectRef && e.children === t.children && JSON.stringify(e.style) === JSON.stringify(t.style)), cr = (e) => {
672
+ const t = window.getComputedStyle(e);
673
+ return parseFloat(t.marginLeft) + parseFloat(t.marginRight);
674
+ }, lr = (e) => e.reduce((t, o) => {
675
+ const s = o.offsetTop, c = o.getBoundingClientRect().width;
676
+ return t[s] = (t[s] || 0) + c, t;
677
+ }, {}), Cr = qe(({ deleteInline: e, selectRef: t, setVisibility: o, selectId: s, removeOption: c, renderOptions: g, selected: y, selectedIDs: d, setSelectedIds: i, normalizedOptions: E, title: b, visibility: k, active: N, hasOptions: R, hasActualValue: F, optionsClassName: L, selectedText: P, disabled: M, loading: W, error: C, registerOption: z, unregisterOption: ie, handleBlur: X, handleFocus: Y, toggleVisibility: T, handleKeyDown: a, handleListScroll: ee, setAnimationFinished: re, clear: V, children: K, placeholder: de, className: ae, style: A, duration: B, easing: se, offset: v, animateOpacity: x, unmount: r, ArrowIcon: l, ClearIcon: m, DelIcon: w, renderIcon: ge, hasMore: ve, loadButton: n, deleting: p, setDeleting: j }) => {
678
+ const [f, I] = le(!1), [D, fe] = le(null), [q, U] = le(!1), [ce, h] = le({}), [G, Q] = le(null), [pe, $] = le(null), [xe, me] = le(!1), we = ne(!0), Te = ne(null), oe = _((H) => {
679
+ c ? c(H) : i((J) => J.filter((te) => te.id !== H));
680
+ }, [c, i]), Pe = _((H) => {
681
+ if (p) {
682
+ H.stopPropagation(), H.preventDefault(), j(!1);
683
+ return;
684
+ }
685
+ T(H);
686
+ }, [p, T]), Ce = _((H, J) => {
687
+ h((te) => te[H] === J ? te : { ...te, [H]: J });
688
+ }, []);
689
+ Ve(() => {
690
+ const H = Te.current;
691
+ if (!H) return;
692
+ const J = new ResizeObserver((te) => {
693
+ window.requestAnimationFrame(() => {
694
+ if (!Array.isArray(te) || !te.length) return;
695
+ const Le = te[0].contentRect.height;
696
+ fe(Le);
697
+ });
698
+ });
699
+ return J.observe(H), () => J.disconnect();
700
+ }, []), ue(() => {
701
+ we.current = !1, t && (typeof t == "function" ? t(t.current) : t.current = t.current);
702
+ }, [t]), ue(() => {
703
+ p && k && T() && T?.()(p && d?.length === 0) && j(!1), $(null);
704
+ }, [d?.length, p]), Ve(() => {
705
+ const H = Te.current;
706
+ if (!H || !d?.length || p) {
707
+ d?.length || U({ state: !1, id: null, width: 0 });
708
+ return;
709
+ }
710
+ const J = Array.from(H.children).filter((ye) => ye.classList.contains("rac-multiple-option")), te = H.clientWidth;
711
+ if (J.length > d.length) {
712
+ const ye = new Set(d.map((O) => O.id)), je = J.findIndex((O) => !ye.has(O.id));
713
+ if (je === -1) return;
714
+ const Se = J[je], be = J[je - 1];
715
+ if (!(be && Se.offsetTop !== be.offsetTop)) {
716
+ U({ state: !1, id: null, width: 0 });
717
+ return;
718
+ }
719
+ const He = lr(J), Ee = Object.keys(He).map(Number).sort((O, Z) => O - Z), ke = Ee.indexOf(Se.offsetTop);
720
+ if (ke <= 0) {
721
+ U({ state: !1, id: null, width: 0 });
722
+ return;
723
+ }
724
+ const Re = Ee[ke - 1], Ae = He[Re], Me = te - Ae;
725
+ Le(be?.id || null, !0, Me);
726
+ } else if (J.length === d.length) {
727
+ const ye = J[J.length - 1], je = d[d.length - 1]?.id, Se = ce[je];
728
+ if (!Se) return;
729
+ const be = ye?.firstElementChild || ye, Ge = cr(be), He = cr(ye), Ee = J.slice(0, -1), ke = lr(Ee), Re = Object.keys(ke).map(Number).sort((Z, he) => Z - he);
730
+ let Ae = te;
731
+ if (Re.length > 0) {
732
+ const Z = Math.max(...Re);
733
+ Ae = te - (ke[Z] || 0);
734
+ }
735
+ const Me = Se + Ge + He > Ae, O = d[d.length - 2]?.id;
736
+ Le(O, Me, Ae);
737
+ }
738
+ function Le(ye, je, Se) {
739
+ U((be) => be.id === ye && be.state === je && be.width === Se ? be : { state: je, id: ye, width: Se });
740
+ }
741
+ }, [d, ce, p]);
742
+ const Ie = d?.map((H, J) => {
743
+ const te = J === d.length - 1;
744
+ return /* @__PURE__ */ u.jsx(
745
+ Ar,
746
+ {
747
+ normalizedOptions: E,
748
+ registerItemWidth: Ce,
749
+ setActiveHoverId: $,
750
+ swiped: G === H.id,
751
+ activeHoverId: pe,
752
+ setVisibility: o,
753
+ deleteInline: e,
754
+ setDeleting: j,
755
+ setSwipedId: Q,
756
+ setLeaving: me,
757
+ renderIcon: ge,
758
+ selectRef: t,
759
+ setSpacer: U,
760
+ onSwipe: Q,
761
+ delSpacer: te,
762
+ duration: B,
763
+ deleting: p,
764
+ swipedId: G,
765
+ leaving: xe,
766
+ element: H,
767
+ DelIcon: w,
768
+ spacer: q,
769
+ remove: oe,
770
+ index: J
771
+ },
772
+ H.id ?? J
773
+ );
774
+ });
775
+ return /* @__PURE__ */ u.jsxs(er.Provider, { value: { registerOption: z, unregisterOption: ie }, children: [
776
+ K,
777
+ /* @__PURE__ */ u.jsxs(
778
+ "div",
779
+ {
780
+ ref: t,
781
+ style: {
782
+ "--rac-duration-fast": "calc(var(--rac-duration) * 0.5)",
783
+ "--rac-duration-slow": "calc(var(--rac-duration) * 1.3)",
784
+ "--rac-duration-base": "var(--rac-duration)",
785
+ "--rac-duration": `${B}ms`,
786
+ ...A
787
+ },
788
+ className: `
789
+ ${!R || M ? "rac-disabled-style" : ""}
790
+ ${W ? "rac-loading-style" : ""}
791
+ ${C ? "rac-error-style" : ""}
792
+ ${ae}
793
+ rac-select
794
+ `,
795
+ ...N && {
796
+ onKeyDown: a,
797
+ onFocus: Y,
798
+ onClick: Pe,
799
+ onBlur: X
800
+ },
801
+ "aria-disabled": M || !R,
802
+ "aria-controls": `${s}-listbox`,
803
+ tabIndex: N ? 0 : -1,
804
+ "aria-expanded": k,
805
+ "aria-label": de,
806
+ "aria-haspopup": "listbox",
807
+ role: "combobox",
808
+ children: [
809
+ /* @__PURE__ */ u.jsx(
810
+ "div",
811
+ {
812
+ className: `rac-select-title-wrapper
813
+ ${!C && !W && y?.type === "boolean" ? y.raw ? "rac-true-option" : "rac-false-option" : ""}
652
814
  `,
653
- children: /* @__PURE__ */ d.jsx(pr, { component: null, children: n?.length && !O ? f : /* @__PURE__ */ d.jsxs(
654
- Ke,
655
- {
656
- duration: S,
657
- widthMode: !0,
658
- children: [
659
- /* @__PURE__ */ d.jsx("span", { className: "rac-title-text", children: b }),
660
- /* @__PURE__ */ d.jsx(Re, { visibility: R && !C, duration: S, children: /* @__PURE__ */ d.jsxs("span", { className: "rac-loading-dots", children: [
661
- /* @__PURE__ */ d.jsx("i", {}),
662
- /* @__PURE__ */ d.jsx("i", {}),
663
- /* @__PURE__ */ d.jsx("i", {})
664
- ] }) })
665
- ]
666
- },
667
- b
668
- ) })
669
- }
670
- ),
671
- /* @__PURE__ */ d.jsxs("div", { className: "rac-select-buttons", children: [
672
- /* @__PURE__ */ d.jsx(
673
- Re,
674
- {
675
- visibility: V && j && !P && !R && !C,
676
- duration: S,
677
- style: { display: "grid" },
678
- children: w(r, {
679
- className: "rac-select-cancel",
680
- onMouseDown: (s) => {
681
- s.preventDefault(), s.stopPropagation();
682
- },
683
- onClick: G
684
- })
685
- }
686
- ),
687
- /* @__PURE__ */ d.jsx(
688
- Re,
689
- {
690
- visibility: L,
691
- duration: S,
692
- style: { display: "grid" },
693
- children: /* @__PURE__ */ d.jsx(
694
- "span",
695
- {
696
- className: `rac-select-arrow-wrapper ${p ? "--open" : ""}`,
697
- children: w(ie, {
698
- className: "rac-select-arrow-wrapper"
699
- })
700
- }
701
- )
702
- }
703
- )
704
- ] }),
705
- /* @__PURE__ */ d.jsx(
706
- vr,
815
+ style: {
816
+ alignItems: d?.length && !P ? "flex-start" : "center",
817
+ height: D ? `${D}px` : "auto"
818
+ },
819
+ children: /* @__PURE__ */ u.jsx(
820
+ "div",
707
821
  {
708
- className: J,
709
- visibility: p,
710
- selectRef: e,
711
- onAnimationDone: () => c(!0),
712
- unmount: le,
713
- duration: S,
714
- easing: H,
715
- offset: ge,
716
- animateOpacity: K,
717
822
  style: {
718
- ...Y,
719
- "--rac-duration": `${S}ms`
823
+ alignItems: d?.length && !P ? "flex-start" : "center",
824
+ height: W ? "100%" : "auto"
720
825
  },
721
- children: /* @__PURE__ */ d.jsxs(
722
- "div",
826
+ className: "rac-select-title",
827
+ ref: Te,
828
+ children: /* @__PURE__ */ u.jsx(
829
+ Sr,
723
830
  {
724
- onScroll: ne,
725
- tabIndex: "-1",
726
- className: "rac-select-list",
727
- role: "listbox",
728
- "aria-label": "Options",
729
- children: [
730
- o,
731
- !B && A && /* @__PURE__ */ d.jsxs(
732
- "div",
733
- {
734
- className: "rac-select-option rac-disabled-option rac-loading-option",
735
- onClick: (s) => s.stopPropagation(),
736
- children: [
737
- /* @__PURE__ */ d.jsx("span", { className: "rac-loading-option-title", children: "Loading" }),
738
- /* @__PURE__ */ d.jsxs("span", { className: "rac-loading-dots", children: [
739
- /* @__PURE__ */ d.jsx("i", {}),
740
- /* @__PURE__ */ d.jsx("i", {}),
741
- /* @__PURE__ */ d.jsx("i", {})
742
- ] })
743
- ]
744
- }
745
- )
746
- ]
831
+ enter: !we.current,
832
+ component: null,
833
+ appear: !1,
834
+ children: d?.length && !P && !W ? Ie : /* @__PURE__ */ u.jsxs(
835
+ mr,
836
+ {
837
+ className: "rac-title-container",
838
+ duration: B,
839
+ widthMode: !0,
840
+ children: [
841
+ /* @__PURE__ */ u.jsx("span", { className: "rac-title-text", children: b }),
842
+ /* @__PURE__ */ u.jsx(
843
+ Fe,
844
+ {
845
+ className: "rac-loading-container",
846
+ visibility: W && !C,
847
+ duration: B,
848
+ children: /* @__PURE__ */ u.jsxs("span", { className: "rac-loading-dots", children: [
849
+ /* @__PURE__ */ u.jsx("i", {}),
850
+ /* @__PURE__ */ u.jsx("i", {}),
851
+ /* @__PURE__ */ u.jsx("i", {})
852
+ ] })
853
+ }
854
+ )
855
+ ]
856
+ },
857
+ b
858
+ )
747
859
  }
748
860
  )
749
861
  }
750
862
  )
751
- ]
752
- }
753
- )
754
- ]
755
- }
756
- );
757
- });
758
- function Sr({
759
- disabled: e,
760
- open: i,
761
- setOpen: a,
762
- options: o = [],
763
- selectOption: l,
764
- selected: n,
765
- multiple: m,
766
- hasMore: y,
767
- loadMore: b,
768
- loadButton: p,
769
- loadButtonText: L,
770
- setLoadingTitle: j,
771
- loadOffset: V,
772
- loadAhead: J,
773
- expandedGroups: O
774
- }) {
775
- const P = fe(!1), R = fe(0), C = fe(!1), [T, z] = ue(-1);
776
- re(() => {
777
- C.current = !1, p && j(L);
778
- }, [o.length, y, p, L, j]);
779
- const U = N(() => {
780
- !y || C.current || (C.current = !0, b());
781
- }, [y, b]), Q = N((h) => {
782
- if (p || !y || C.current) return;
783
- const { scrollTop: E, scrollHeight: k, clientHeight: Y } = h.currentTarget;
784
- k - E <= Y + V && U();
785
- }, [p, y, V, U]);
786
- re(() => {
787
- !p && i && y && T >= o.length - J && U();
788
- }, [T, i, y, o.length, J, p, U]), re(() => {
789
- const h = () => {
790
- R.current = Date.now();
791
- };
792
- return window.addEventListener("focus", h), () => window.removeEventListener("focus", h);
793
- }, []), re(() => {
794
- if (!i) {
795
- z(-1);
796
- return;
797
- }
798
- if (T >= 0 && T < o.length && !(!o[T] || o[T].hidden || o[T].groupHeader))
799
- return;
800
- let h = -1;
801
- if (n) {
802
- const E = m ? n[0] : n;
803
- E && (h = o.findIndex((k) => k.id === E.id && !k.disabled && !k.hidden && !k.groupHeader));
804
- }
805
- h === -1 && (h = o.findIndex((E) => !E.disabled && !E.hidden && !E.groupHeader)), z(h);
806
- }, [i, o, n]);
807
- const X = N((h, E) => {
808
- const k = (H) => H && !H?.groupHeader && (!H?.group || O?.has(H?.group)) && !H?.disabled && !H?.loading, Y = o.length;
809
- if (Y === 0) return -1;
810
- let S = h;
811
- for (let H = 0; H < Y; H++) {
812
- if (S = (S + E + Y) % Y, !p && y && (E > 0 && S === 0 || E < 0 && S === Y - 1))
813
- return h;
814
- if (k(o[S])) return S;
815
- }
816
- return h;
817
- }, [o, y, p, O]), te = N((h) => {
818
- const E = h.relatedTarget?.closest(".rac-options");
819
- !h.currentTarget.contains(h.relatedTarget) && !E && a(!1);
820
- }, [a]), ne = N(() => {
821
- e || document.hidden || Date.now() - R.current < 100 || i || (a(!0), P.current = !0, setTimeout(() => {
822
- P.current = !1;
823
- }, 200));
824
- }, [e, i, a]), c = N((h) => {
825
- e || h.target.closest(".rac-select-cancel") || P.current || a(!i);
826
- }, [e, i, a]), G = N((h) => {
827
- if (!e)
828
- switch (h.key) {
829
- case "Enter":
830
- case " ":
831
- h.preventDefault(), i ? T !== -1 && o[T] && l(o[T], h) : a(!0);
832
- break;
833
- case "Escape":
834
- h.preventDefault(), a(!1);
835
- break;
836
- case "ArrowDown":
837
- h.preventDefault(), i ? z((E) => X(E, 1)) : a(!0);
838
- break;
839
- case "ArrowUp":
840
- h.preventDefault(), i ? z((E) => X(E, -1)) : a(!0);
841
- break;
842
- case "Tab":
843
- i && a(!1);
844
- break;
863
+ }
864
+ ),
865
+ /* @__PURE__ */ u.jsxs("div", { className: "rac-select-buttons", children: [
866
+ /* @__PURE__ */ u.jsx(
867
+ Fe,
868
+ {
869
+ visibility: F && R && !M && !W && !C && !p,
870
+ style: { display: "grid" },
871
+ duration: B,
872
+ children: ge(m, {
873
+ className: "rac-select-cancel",
874
+ onMouseDown: (H) => {
875
+ H.preventDefault(), H.stopPropagation();
876
+ },
877
+ onClick: V
878
+ })
879
+ }
880
+ ),
881
+ /* @__PURE__ */ u.jsx(
882
+ Fe,
883
+ {
884
+ visibility: N && !p,
885
+ style: { display: "grid" },
886
+ duration: B,
887
+ children: /* @__PURE__ */ u.jsx("span", { className: `rac-select-arrow-wrapper ${k ? "--open" : ""}`, children: ge(l, { className: "rac-select-arrow-wrapper" }) })
888
+ }
889
+ )
890
+ ] }),
891
+ /* @__PURE__ */ u.jsx(
892
+ Pr,
893
+ {
894
+ style: { "--rac-duration": `${B}ms`, ...A },
895
+ onAnimationDone: () => re(!0),
896
+ setBottomDirection: I,
897
+ animateOpacity: x,
898
+ className: L,
899
+ visibility: k,
900
+ selectRef: t,
901
+ duration: B,
902
+ unmount: r,
903
+ easing: se,
904
+ offset: v,
905
+ children: /* @__PURE__ */ u.jsxs(
906
+ "div",
907
+ {
908
+ onScroll: ee,
909
+ className: "rac-select-list",
910
+ "aria-label": "Options",
911
+ role: "listbox",
912
+ tabIndex: "-1",
913
+ children: [
914
+ g,
915
+ !n && ve && /* @__PURE__ */ u.jsxs(
916
+ "div",
917
+ {
918
+ className: "rac-select-option rac-disabled-option rac-loading-option",
919
+ onClick: (H) => H.stopPropagation(),
920
+ children: [
921
+ /* @__PURE__ */ u.jsx("span", { className: "rac-loading-option-title", children: "Loading" }),
922
+ /* @__PURE__ */ u.jsxs("span", { className: "rac-loading-dots", children: [
923
+ /* @__PURE__ */ u.jsx("i", {}),
924
+ /* @__PURE__ */ u.jsx("i", {}),
925
+ /* @__PURE__ */ u.jsx("i", {})
926
+ ] })
927
+ ]
928
+ }
929
+ )
930
+ ]
931
+ }
932
+ )
933
+ }
934
+ )
935
+ ]
845
936
  }
846
- }, [e, i, a, T, o, l, X]);
847
- return de(() => ({
848
- handleBlur: te,
849
- handleFocus: ne,
850
- handleToggle: c,
851
- handleKeyDown: G,
852
- highlightedIndex: T,
853
- setHighlightedIndex: z,
854
- handleListScroll: Q
855
- }), [te, ne, c, G, T, Q]);
856
- }
857
- const _r = ["group", "disabled", "options", "items", "children"], Ie = ["name", "label", "id", "value"], Ne = (e, i = !1) => {
858
- if (i && typeof e.group == "string") return e.group;
859
- const a = Ie.find((l) => e[l] != null && e[l] !== "");
860
- if (a) return String(e[a]);
861
- const o = Object.entries(e).find(([l, n]) => !_r.includes(l) && n != null && n !== "");
862
- return o ? String(o[1]) : null;
937
+ )
938
+ ] });
939
+ }), Ir = ["group", "disabled", "options", "items", "children"], Ue = ["name", "label", "id", "value"], ur = [], De = (e, t = !1) => {
940
+ if (t && typeof e.group == "string") return e.group;
941
+ const o = Ue.find((c) => e[c] != null && e[c] !== "");
942
+ if (o) return String(e[o]);
943
+ const s = Object.entries(e).find(([c, g]) => !Ir.includes(c) && g != null && g !== "");
944
+ return s ? String(s[1]) : null;
863
945
  };
864
- function $r({
865
- options: e = [],
866
- jsxOptions: i = [],
867
- value: a,
868
- defaultValue: o,
869
- onChange: l,
870
- disabled: n = !1,
871
- loading: m = !1,
872
- error: y = !1,
873
- multiple: b = !1,
874
- placeholder: p = "Choose option",
875
- emptyText: L = "No options",
876
- disabledText: j = "Disabled",
877
- loadingText: V = "Loading",
878
- errorText: J = "Failed to load",
879
- disabledOption: O = "Disabled option",
880
- emptyOption: P = "Empty option",
881
- invalidOption: R = "Invalid option",
882
- setVisibility: C,
883
- hasMore: T,
884
- loadButton: z,
885
- setLoadingTitle: U,
886
- loadingTitle: Q,
946
+ function Lr({
947
+ options: e = ur,
948
+ jsxOptions: t = ur,
949
+ value: o,
950
+ defaultValue: s,
951
+ onChange: c,
952
+ disabled: g = !1,
953
+ loading: y = !1,
954
+ error: d = !1,
955
+ multiple: i = !1,
956
+ placeholder: E = "Choose option",
957
+ emptyText: b = "No options",
958
+ disabledText: k = "Disabled",
959
+ loadingText: N = "Loading",
960
+ errorText: R = "Failed to load",
961
+ disabledOption: F = "Disabled option",
962
+ emptyOption: L = "Empty option",
963
+ invalidOption: P = "Invalid option",
964
+ setVisibility: M,
965
+ hasMore: W,
966
+ loadButton: C,
967
+ setLoadingTitle: z,
968
+ loadingTitle: ie,
887
969
  loadMoreText: X,
888
- loadMore: te,
889
- childrenFirst: ne,
890
- groupsClosed: c
970
+ loadMore: Y,
971
+ childrenFirst: T,
972
+ groupsClosed: a
891
973
  }) {
892
- const G = ze(), h = a !== void 0, [E, k] = ue(null), [Y, S] = ue([]), [H, ge] = ue(/* @__PURE__ */ new Set()), K = fe(null), le = N((t) => {
893
- ge((f) => {
894
- const s = new Set(f);
895
- return s.has(t) ? s.delete(t) : s.add(t), s;
974
+ const ee = o !== void 0, [re, V] = le(() => {
975
+ const n = /* @__PURE__ */ new Set();
976
+ if (a) return n;
977
+ const p = (j) => {
978
+ Array.isArray(j) && j.forEach((f) => {
979
+ if (f && typeof f == "object") {
980
+ if (("options" in f || "group" in f && !Ue.some((D) => D in f)) && !f.disabled) {
981
+ const D = De(f, !0) || "Empty group";
982
+ n.add(D);
983
+ }
984
+ f.options && p(f.options);
985
+ }
986
+ });
987
+ };
988
+ return p(e), n;
989
+ }), K = ne(null), de = _((n) => {
990
+ V((p) => {
991
+ const j = new Set(p);
992
+ return j.has(n) ? j.delete(n) : j.add(n), j;
896
993
  });
897
- }, []), ie = N((t, f, s = "n", x = null, _ = !1) => {
898
- const ee = `${G}-${s}-${f}`;
899
- if (t == null || t === "")
900
- return { id: ee, userId: null, name: P, raw: null, disabled: !0, type: "normal", group: x, groupDisabled: _ };
901
- if (typeof t == "function")
902
- return { id: ee, userId: null, name: R, raw: t, disabled: !0, invalid: !0, type: "normal", group: x };
903
- if (typeof t == "object" && !Array.isArray(t)) {
904
- const he = x || t.group || null, se = _ || t.disabled === !0, ye = t.id ?? t.value ?? t.name ?? t.label, D = t.value !== void 0 ? t.value : t.id !== void 0 ? t.id : t;
905
- let u = Ne(t) || (se ? O : P);
994
+ }, []), ae = _((n, p, j = "n", f = null, I = !1) => {
995
+ const D = `${j}-${p}`;
996
+ if (n == null || n === "")
997
+ return { id: D, userId: null, name: L, raw: null, disabled: !0, type: "normal", group: f, groupDisabled: I };
998
+ if (typeof n == "function")
999
+ return { id: D, userId: null, name: P, raw: n, disabled: !0, invalid: !0, type: "normal", group: f };
1000
+ if (typeof n == "object" && !Array.isArray(n)) {
1001
+ const fe = f || n.group || null, q = I || n.disabled === !0, U = n.id ?? n.value ?? n.name ?? n.label, ce = n.value !== void 0 ? n.value : n.id !== void 0 ? n.id : n;
1002
+ let h = De(n) || (q ? F : L);
906
1003
  return {
907
- id: ee,
908
- userId: ye,
909
- name: u,
910
- raw: D,
911
- original: t,
912
- disabled: se || u === P && !se,
913
- type: typeof D == "boolean" ? "boolean" : "normal",
914
- group: he,
915
- groupDisabled: _
1004
+ id: D,
1005
+ userId: U,
1006
+ name: h,
1007
+ raw: ce,
1008
+ original: n,
1009
+ disabled: q || h === L && !q,
1010
+ type: typeof ce == "boolean" ? "boolean" : "normal",
1011
+ group: fe,
1012
+ groupDisabled: I
916
1013
  };
917
1014
  }
918
1015
  return {
919
- id: ee,
920
- userId: t,
921
- name: String(t),
922
- raw: t,
923
- original: t,
924
- disabled: _,
925
- type: typeof t == "boolean" ? "boolean" : "normal",
926
- group: x
1016
+ id: D,
1017
+ userId: n,
1018
+ name: String(n),
1019
+ raw: n,
1020
+ original: n,
1021
+ disabled: I,
1022
+ type: typeof n == "boolean" ? "boolean" : "normal",
1023
+ group: f
927
1024
  };
928
- }, [G, P, R, O]), r = de(() => {
929
- const t = /* @__PURE__ */ new Map(), f = [], s = i.map((u, $) => {
930
- if (u.isGroupMarker) return { ...u, type: "group-marker" };
931
- const W = !u.label && !u.userId && !u.value && (u.value === void 0 || u.value === null || u.value === "") && !u.hasJsx;
1025
+ }, [L, P, F]), A = Ne(() => {
1026
+ const n = /* @__PURE__ */ new Map(), p = [], j = t.map((h, G) => {
1027
+ if (h.isGroupMarker) return { ...h, type: "group-marker" };
1028
+ const Q = !h.label && !h.userId && !h.value && (h.value === void 0 || h.value === null || h.value === "") && !h.hasJsx;
932
1029
  return {
933
- ...u,
934
- id: `jsx-${u.id}`,
935
- index: $,
936
- userId: u.userId,
937
- raw: u.value,
938
- original: u.value,
939
- name: W ? P : u.label || u.userId || String(u.value || ""),
940
- disabled: !!u.disabled || W,
941
- type: typeof u.value == "boolean" ? "boolean" : "normal",
942
- group: u.group || null
1030
+ ...h,
1031
+ id: `jsx-${h.id}`,
1032
+ index: G,
1033
+ userId: h.userId,
1034
+ raw: h.value,
1035
+ original: h.value,
1036
+ name: Q ? L : h.label || h.userId || String(h.value || ""),
1037
+ disabled: !!h.disabled || Q,
1038
+ type: typeof h.value == "boolean" ? "boolean" : "normal",
1039
+ group: h.group || null
943
1040
  };
944
1041
  });
945
- let x = 0;
946
- const _ = (u, $ = null, W = !1, oe = "0") => {
947
- Array.isArray(u) || (u = [u]), u.forEach((F, me) => {
948
- if (!F) return;
949
- const xe = `${oe}-${me}`, ve = typeof F == "object" && !Array.isArray(F);
950
- if (ve && ("options" in F || "group" in F && !Ie.some((M) => M in F))) {
951
- const M = Ne(F, !0) || "Empty group";
952
- t.has(M) || t.set(M, { disabled: !!F.disabled, closedByDefault: !!F.disabled || c, items: [] }), F.options ? _(F.options, M, W || !!F.disabled, xe) : f.push({ id: `empty-${M}-${xe}`, name: M, group: M, isPlaceholder: !0, type: "group-marker", index: x++ });
953
- } else if (ve && !Ie.some((M) => M in F) && !F.group)
954
- Object.entries(F).forEach(([M, we], Oe) => {
955
- const Pe = ie(we, `${xe}-${Oe}`, "normal", $, W);
956
- f.push({ ...Pe, index: x++ });
1042
+ let f = 0;
1043
+ const I = (h, G = null, Q = !1, pe = "0") => {
1044
+ Array.isArray(h) || (h = [h]), h.forEach(($, xe) => {
1045
+ if (!$) return;
1046
+ const me = `${pe}-${xe}`, we = typeof $ == "object" && !Array.isArray($);
1047
+ if (we && ("options" in $ || "group" in $ && !Ue.some((oe) => oe in $))) {
1048
+ const oe = De($, !0) || "Empty group";
1049
+ n.has(oe) || n.set(oe, { disabled: !!$.disabled, closedByDefault: !!$.disabled || a, items: [] }), $.options ? I($.options, oe, Q || !!$.disabled, me) : p.push({ id: `empty-${oe}-${me}`, name: oe, group: oe, isPlaceholder: !0, type: "group-marker", index: f++ });
1050
+ } else if (we && !Ue.some((oe) => oe in $) && !$.group)
1051
+ Object.entries($).forEach(([oe, Pe], Ce) => {
1052
+ const Ie = ae(Pe, `${me}-${Ce}`, "default", G, Q);
1053
+ p.push({ ...Ie, index: f++ });
957
1054
  });
958
1055
  else {
959
- const M = ie(F, xe, "normal", $, W);
960
- f.push({ ...M, index: x++ });
1056
+ const oe = ae($, me, "default", G, Q);
1057
+ p.push({ ...oe, index: f++ });
961
1058
  }
962
1059
  });
963
1060
  };
964
- _(e);
965
- const ee = ne ? [...s, ...f] : [...f, ...s];
1061
+ I(e);
1062
+ const D = T ? [...j, ...p] : [...p, ...j];
966
1063
  if (!K.current)
967
- K.current = new Map(ee.map((u, $) => [u.id, $]));
1064
+ K.current = new Map(D.map((h, G) => [h.id, G]));
968
1065
  else {
969
- let u = !1;
970
- if (ee.forEach(($) => {
971
- K.current.has($.id) || (u = !0);
972
- }), u) {
973
- const $ = /* @__PURE__ */ new Map();
974
- ee.forEach((W, oe) => {
975
- $.set(W.id, oe);
976
- }), K.current = $;
1066
+ let h = !1;
1067
+ if (D.forEach((G) => {
1068
+ K.current.has(G.id) || (h = !0);
1069
+ }), h) {
1070
+ const G = /* @__PURE__ */ new Map();
1071
+ D.forEach((Q, pe) => {
1072
+ G.set(Q.id, pe);
1073
+ }), K.current = G;
977
1074
  }
978
1075
  }
979
- const he = [...ee].sort((u, $) => {
980
- const W = K.current.get(u.id) ?? 999999, oe = K.current.get($.id) ?? 999999;
981
- return W - oe;
982
- }), se = [], ye = /* @__PURE__ */ new Set();
983
- he.forEach((u) => {
984
- if (!u.group)
985
- se.push({ type: "item", data: u });
986
- else if (ye.has(u.group) || (ye.add(u.group), se.push({ type: "group", name: u.group })), !u.isPlaceholder && !u.isGroupMarker) {
987
- const $ = t.get(u.group) || { items: [] };
988
- t.has(u.group) || t.set(u.group, $), $.items.push(u);
1076
+ const fe = [...D].sort((h, G) => {
1077
+ const Q = K.current.get(h.id) ?? 999999, pe = K.current.get(G.id) ?? 999999;
1078
+ return Q - pe;
1079
+ }), q = [], U = /* @__PURE__ */ new Set();
1080
+ fe.forEach((h) => {
1081
+ if (!h.group)
1082
+ q.push({ type: "item", data: h });
1083
+ else if (U.has(h.group) || (U.add(h.group), q.push({ type: "group", name: h.group })), !h.isPlaceholder && !h.isGroupMarker) {
1084
+ const G = n.get(h.group) || { items: [] };
1085
+ n.has(h.group) || n.set(h.group, G), G.items.push(h);
989
1086
  }
990
1087
  });
991
- const D = [];
992
- return se.forEach((u) => {
993
- if (u.type === "item")
994
- D.push(u.data);
1088
+ const ce = [];
1089
+ return q.forEach((h) => {
1090
+ if (h.type === "item")
1091
+ ce.push(h.data);
995
1092
  else {
996
- const $ = u.name, W = t.get($), oe = H.has($);
997
- D.push({
998
- id: `group-header-${$}`,
999
- name: $,
1000
- disabled: !!W?.disabled,
1093
+ const G = h.name, Q = n.get(G), pe = re.has(G);
1094
+ ce.push({
1095
+ id: `group-header-${G}`,
1096
+ name: G,
1097
+ disabled: !!Q?.disabled,
1001
1098
  groupHeader: !0,
1002
- expanded: oe,
1099
+ expanded: pe,
1003
1100
  type: "group",
1004
1101
  hidden: !1
1005
- }), W?.items.forEach((F) => {
1006
- const me = H.size > 0 ? !oe : !!c;
1007
- D.push({ ...F, hidden: me });
1102
+ }), Q?.items.forEach(($) => {
1103
+ const xe = re.size > 0 ? !pe : !!a;
1104
+ ce.push({ ...$, hidden: xe });
1008
1105
  });
1009
1106
  }
1010
- }), T && z && D.push({
1107
+ }), W && C && ce.push({
1011
1108
  id: "special-load-more-id",
1012
- name: Q,
1109
+ name: ie,
1013
1110
  loadMore: !0,
1014
- loading: Q === X,
1111
+ loading: ie === X,
1015
1112
  type: "special"
1016
- }), D;
1017
- }, [e, i, G, ie, ne, T, z, Q, X, c, H, P]);
1018
- re(() => {
1019
- if (H.size > 0 || c) return;
1020
- const t = /* @__PURE__ */ new Set();
1021
- r.forEach((f) => {
1022
- f.groupHeader && !f.disabled && t.add(f.name);
1023
- }), t.size > 0 && ge(t);
1024
- }, [r, c]);
1025
- const g = N((t) => {
1026
- if (t == null) return null;
1027
- const f = r.find((s) => s.original === t);
1028
- if (f) return f.id;
1029
- if (typeof t == "object")
1030
- try {
1031
- const s = JSON.stringify(t);
1032
- return r.find(
1033
- (x) => x.original && typeof x.original == "object" && JSON.stringify(x.original) === s
1034
- )?.id ?? null;
1035
- } catch {
1036
- return null;
1037
- }
1038
- return null;
1039
- }, [r]);
1040
- re(() => {
1041
- const t = h ? a : o;
1042
- if (t == null || Array.isArray(t) && t.length === 0) {
1043
- k(null), S([]);
1044
- return;
1045
- }
1046
- const f = (s) => {
1047
- const x = g(s), _ = r.find((he) => he.id === x);
1048
- if (_) return _;
1049
- const ee = typeof s == "object" ? s.id || s.value || JSON.stringify(s) : String(s);
1050
- return typeof s == "object" && s !== null ? {
1051
- id: `virtual-${ee}`,
1052
- name: Ne(s) || String(s.id || "Selected Object"),
1053
- raw: s.value ?? s.id ?? s,
1054
- original: s,
1055
- userId: s.id ?? s.value ?? null,
1113
+ }), ce;
1114
+ }, [e, t, ae, T, W, C, ie, X, a, re, L]), B = _(() => {
1115
+ const n = ee ? o : s;
1116
+ if (n == null || Array.isArray(n) && n.length === 0)
1117
+ return { initialId: null, initialIDs: [] };
1118
+ const p = /* @__PURE__ */ new Set(), j = (f, I) => {
1119
+ let D = A.find((q) => q.original === f && !p.has(q.id));
1120
+ if (!D && typeof f == "object")
1121
+ try {
1122
+ const q = JSON.stringify(f);
1123
+ D = A.find(
1124
+ (U) => U.original && typeof U.original == "object" && JSON.stringify(U.original) === q && !p.has(U.id)
1125
+ );
1126
+ } catch {
1127
+ }
1128
+ if (D)
1129
+ return p.add(D.id), D;
1130
+ const fe = typeof f == "object" ? f.id || f.value || JSON.stringify(f) : String(f);
1131
+ return typeof f == "object" && f !== null ? {
1132
+ id: `virtual-${fe}-${I}`,
1133
+ name: De(f) || String(f.id || "Selected Object"),
1134
+ raw: f.value ?? f.id ?? f,
1135
+ original: f,
1136
+ userId: f.id ?? f.value ?? null,
1056
1137
  virtual: !0
1057
1138
  } : {
1058
- id: `virtual-${ee}`,
1059
- name: String(s),
1060
- raw: s,
1061
- original: s,
1062
- userId: s,
1139
+ id: `virtual-${fe}-${I}`,
1140
+ name: String(f),
1141
+ raw: f,
1142
+ original: f,
1143
+ userId: f,
1063
1144
  virtual: !0
1064
1145
  };
1065
1146
  };
1066
- if (b) {
1067
- const x = (Array.isArray(t) ? t : [t]).map(f);
1068
- S(x);
1069
- } else {
1070
- const s = Array.isArray(t) ? t[0] : t, x = f(s);
1071
- k((_) => _ === x.id ? _ : x.id);
1147
+ if (i)
1148
+ return { initialId: null, initialIDs: (Array.isArray(n) ? n : [n]).map((D, fe) => j(D, fe)) };
1149
+ {
1150
+ const f = Array.isArray(n) ? n[0] : n;
1151
+ return { initialId: j(f, 0).id, initialIDs: [] };
1072
1152
  }
1073
- }, [a, o, h, r, g, b]);
1074
- const w = de(() => {
1075
- const t = r.find((f) => f.id === E);
1076
- if (t) return t;
1077
- if (!b && E?.startsWith("virtual-")) {
1078
- const f = h ? a : o, s = Array.isArray(f) ? f[0] : f;
1079
- if (s)
1153
+ }, [ee, o, s, A, i]), [se, v] = le(() => B().initialId), [x, r] = le(() => B().initialIDs), l = Ne(() => {
1154
+ const n = A.find((p) => p.id === se);
1155
+ if (n) return n;
1156
+ if (!i && se?.startsWith("virtual-")) {
1157
+ const p = ee ? o : s, j = Array.isArray(p) ? p[0] : p;
1158
+ if (j)
1080
1159
  return {
1081
- id: E,
1082
- name: typeof s == "object" ? Ne(s) : String(s),
1083
- original: s
1160
+ id: se,
1161
+ name: typeof j == "object" ? De(j) : String(j),
1162
+ original: j
1084
1163
  };
1085
1164
  }
1086
1165
  return null;
1087
- }, [E, r, b, h, a, o]), A = N((t, f) => {
1088
- if (t.groupHeader) {
1089
- f?.stopPropagation(), f?.preventDefault(), t.disabled || le(t.name);
1166
+ }, [se, A, i, ee, o, s]), m = _((n, p) => {
1167
+ if (n.groupHeader) {
1168
+ w(p), n.disabled || de(n.name);
1090
1169
  return;
1091
1170
  }
1092
- if (t.disabled || t.loadMore) {
1093
- f?.stopPropagation(), f?.preventDefault(), t.loadMore && !t.loading && (U(X), te());
1171
+ if (n.disabled || n.loadMore) {
1172
+ w(p), n.loadMore && !n.loading && (z(X), Y());
1094
1173
  return;
1095
1174
  }
1096
- if (b) {
1097
- if (t.disabled || t.groupHeader || t.loadMore) {
1098
- f?.stopPropagation(), f?.preventDefault();
1175
+ if (i) {
1176
+ if (n.disabled || n.groupHeader || n.loadMore) {
1177
+ w(p);
1099
1178
  return;
1100
1179
  }
1101
- f?.stopPropagation(), f?.preventDefault();
1102
- const x = Y?.some((_) => _.id === t.id) ? Y.filter((_) => _.id !== t.id) : [...Y, t];
1103
- S(x), l?.(x.map((_) => _.original), x.map((_) => _.userId));
1180
+ w(p);
1181
+ const f = x?.some((I) => I.id === n.id) ? x.filter((I) => I.id !== n.id) : [...x, n];
1182
+ r(f), c?.(f.map((I) => I.original), f.map((I) => I.userId));
1104
1183
  return;
1105
1184
  }
1106
- k(t.id), l?.(t.original, t.userId), C(!1);
1107
- }, [l, C, te, X, U, le]), B = N(() => {
1108
- k(null), S([]), l?.(null, null);
1109
- }, [l]), Z = N((t) => {
1110
- const f = Y.filter((s) => s.id !== t);
1111
- S(f), l?.(f.map((s) => s.original), f.map((s) => s.userId));
1112
- }, [Y, l]);
1185
+ v(n.id), c?.(n.original, n.userId), M(!1);
1186
+ }, [c, M, Y, X, z, de, i, x]), w = _((n) => {
1187
+ n?.stopPropagation(), n?.preventDefault();
1188
+ }, []), ge = _(() => {
1189
+ c?.(null, null), v(null), r([]);
1190
+ }, [c]), ve = _((n) => {
1191
+ const p = x.filter((j) => j.id !== n);
1192
+ r(p), c?.(p.map((j) => j.original), p.map((j) => j.userId));
1193
+ }, [x, c]);
1113
1194
  return {
1114
- normalizedOptions: r,
1115
- selected: w,
1116
- selectOption: A,
1117
- clear: B,
1118
- removeOption: Z,
1119
- hasOptions: r.length > 0,
1120
- active: !y && !m && !n && r.length > 0,
1121
- selectedValue: a ?? o,
1122
- placeholder: p,
1123
- emptyText: L,
1124
- disabledText: j,
1125
- loadingText: V,
1126
- errorText: J,
1127
- disabledOption: O,
1128
- emptyOption: P,
1129
- invalidOption: R,
1130
- disabled: n,
1131
- loading: m,
1132
- error: y,
1133
- expandedGroups: H,
1134
- toggleGroup: le,
1135
- selectedIDs: Y,
1136
- multiple: b,
1137
- setSelectedIds: S
1195
+ normalizedOptions: A,
1196
+ selected: l,
1197
+ selectOption: m,
1198
+ clear: ge,
1199
+ removeOption: ve,
1200
+ hasOptions: A.length > 0,
1201
+ active: !d && !y && !g && A.length > 0,
1202
+ selectedValue: o ?? s,
1203
+ placeholder: E,
1204
+ emptyText: b,
1205
+ disabledText: k,
1206
+ loadingText: N,
1207
+ errorText: R,
1208
+ disabledOption: F,
1209
+ emptyOption: L,
1210
+ invalidOption: P,
1211
+ disabled: g,
1212
+ loading: y,
1213
+ error: d,
1214
+ expandedGroups: re,
1215
+ toggleGroup: de,
1216
+ selectedIDs: x,
1217
+ multiple: i,
1218
+ setSelectedIds: r
1138
1219
  };
1139
1220
  }
1140
- function kr({ visibility: e, children: i, duration: a = 300 }) {
1141
- const o = fe(null);
1142
- return /* @__PURE__ */ d.jsx(
1143
- Te,
1221
+ function Hr({ disabled: e, open: t, setOpen: o, options: s = [], selectOption: c, setDeleting: g, selected: y, selectedIDs: d, multiple: i, hasMore: E, loadMore: b, loadButton: k, loadButtonText: N, setLoadingTitle: R, loadOffset: F, loadAhead: L, expandedGroups: P, onOpen: M, onClose: W, deleting: C }) {
1222
+ const z = ne(!1), ie = ne(0), X = ne(!1), [Y, T] = le(-1);
1223
+ ue(() => {
1224
+ X.current = !1, k && R(N);
1225
+ }, [s.length, E, k, N, R]);
1226
+ const a = _(() => {
1227
+ !E || X.current || (X.current = !0, b());
1228
+ }, [E, b]), ee = _((v) => {
1229
+ if (k || !E || X.current) return;
1230
+ const { scrollTop: x, scrollHeight: r, clientHeight: l } = v.currentTarget(r - x <= l + F) && a();
1231
+ }, [k, E, F, a]);
1232
+ ue(() => {
1233
+ !k && t && E && Y >= s.length - L && a();
1234
+ }, [Y, t, E, s.length, L, k, a]), ue(() => {
1235
+ const v = () => {
1236
+ ie.current = Date.now();
1237
+ };
1238
+ return window.addEventListener("focus", v), () => window.removeEventListener("focus", v);
1239
+ }, []), ue(() => {
1240
+ if (!t) {
1241
+ T(-1);
1242
+ return;
1243
+ }
1244
+ const v = s[Y], x = v && !v.hidden && !v.groupHeader;
1245
+ if (Y >= 0 && Y < s.length && x) return;
1246
+ let r = -1;
1247
+ if (y && !i) {
1248
+ const l = i ? y[0] : y;
1249
+ l && (r = s.findIndex((m) => m.id === l.id && !m.disabled && !m.hidden && !m.groupHeader));
1250
+ }
1251
+ if (i && d.length) {
1252
+ const l = new Set(d.map((m) => m.id));
1253
+ r = s.findIndex(
1254
+ (m) => l.has(m.id) && !m.disabled && !m.hidden && !m.groupHeader
1255
+ );
1256
+ }
1257
+ r === -1 && (r = s.findIndex((l) => !l.disabled && !l.hidden && !l.groupHeader)), T(r);
1258
+ }, [t, s, y]);
1259
+ const re = _((v, x) => {
1260
+ const r = (w) => w && !w?.groupHeader && (!w?.group || P?.has(w?.group)) && !w?.disabled && !w?.loading, l = s.length;
1261
+ if (l === 0) return -1;
1262
+ let m = v;
1263
+ for (let w = 0; w < l; w++) {
1264
+ if (m = (m + x + l) % l, !k && E && (x > 0 && m === 0 || x < 0 && m === l - 1))
1265
+ return v;
1266
+ if (r(s[m])) return m;
1267
+ }
1268
+ return v;
1269
+ }, [s, E, k, P]), V = _((v) => {
1270
+ const x = v.relatedTarget?.closest(".rac-options");
1271
+ !v.currentTarget.contains(v.relatedTarget) && !x && (o(!1), g(!1));
1272
+ }, [o]), K = _(() => {
1273
+ e || C || document.hidden || Date.now() - ie.current < 100 || t || (o(!0), z.current = !0, setTimeout(() => z.current = !1, 200));
1274
+ }, [e, t, o, C]), de = ne(t), ae = ne(M), A = ne(W);
1275
+ ue(() => {
1276
+ ae.current = M, A.current = W;
1277
+ }, [M, W]), ue(() => {
1278
+ de.current !== t && (t ? ae.current?.() : A.current?.(), de.current = t);
1279
+ }, [t]);
1280
+ const B = _((v) => {
1281
+ e || C || v?.target?.closest(".rac-select-cancel") || z.current || o(!t);
1282
+ }, [e, t, o, M, W, C]), se = _((v) => {
1283
+ if (!e)
1284
+ switch (v.key) {
1285
+ case "Enter":
1286
+ case " ":
1287
+ v.preventDefault(), t ? Y !== -1 && s[Y] && c(s[Y], v) : o(!0);
1288
+ break;
1289
+ case "Escape":
1290
+ v.preventDefault(), o(!1);
1291
+ break;
1292
+ case "ArrowDown":
1293
+ v.preventDefault(), t ? T((x) => re(x, 1)) : o(!0);
1294
+ break;
1295
+ case "ArrowUp":
1296
+ v.preventDefault(), t ? T((x) => re(x, -1)) : o(!0);
1297
+ break;
1298
+ case "Tab":
1299
+ t && o(!1);
1300
+ break;
1301
+ }
1302
+ }, [e, t, o, Y, s, c, re]);
1303
+ return Ne(() => ({ handleBlur: V, handleFocus: K, toggleVisibility: B, handleKeyDown: se, highlightedIndex: Y, setHighlightedIndex: T, handleListScroll: ee }), [V, K, B, se, Y, ee]);
1304
+ }
1305
+ function Fr({ visibility: e, children: t, duration: o = 300, className: s }) {
1306
+ const c = ne(null);
1307
+ return /* @__PURE__ */ u.jsx(
1308
+ Xe,
1144
1309
  {
1310
+ onEntering: () => c.current.style.height = c.current.scrollHeight + "px",
1311
+ onExit: () => c.current.style.height = c.current.scrollHeight + "px",
1312
+ onEntered: () => c.current.style.height = "auto",
1313
+ onExiting: () => c.current.style.height = "0px",
1314
+ onEnter: () => c.current.style.height = "0px",
1315
+ classNames: "rac-slide-down",
1316
+ timeout: o,
1317
+ nodeRef: c,
1145
1318
  in: e,
1146
- timeout: 300,
1147
- classNames: "slideDown",
1148
1319
  unmountOnExit: !0,
1149
- nodeRef: o,
1150
- onEnter: () => o.current.style.height = "0px",
1151
- onEntering: () => o.current.style.height = o.current.scrollHeight + "px",
1152
- onEntered: () => o.current.style.height = "auto",
1153
- onExit: () => o.current.style.height = o.current.scrollHeight + "px",
1154
- onExiting: () => o.current.style.height = "0px",
1155
- children: /* @__PURE__ */ d.jsx(
1320
+ children: /* @__PURE__ */ u.jsx(
1156
1321
  "div",
1157
1322
  {
1158
- ref: o,
1159
1323
  style: {
1160
- overflow: "hidden",
1161
- transition: `height ${a}ms ease`,
1162
- paddingLeft: "1em"
1324
+ transition: `height ${o}ms ease`,
1325
+ overflow: "hidden"
1163
1326
  },
1164
- className: "slideDown-enter-done",
1327
+ className: `${s} rac-slide-down-enter-done`,
1328
+ ref: c,
1165
1329
  tabIndex: -1,
1166
- children: i
1330
+ children: t
1167
1331
  }
1168
1332
  )
1169
1333
  }
1170
1334
  );
1171
1335
  }
1172
- const De = (e, i) => {
1336
+ const Ke = (e, t) => {
1173
1337
  if (!e) return null;
1174
- if (typeof e == "string") return /* @__PURE__ */ d.jsx("img", { src: e, ...i, alt: "" });
1175
- if (fr(e)) return gr(e, i);
1338
+ const o = (s = {}) => ({
1339
+ ...t,
1340
+ ...s,
1341
+ style: {
1342
+ ...t?.style,
1343
+ ...s?.style
1344
+ }
1345
+ });
1346
+ if (typeof e == "string") return /* @__PURE__ */ u.jsx("img", { src: e, ...o(), alt: "" });
1347
+ if (vr(e)) return jr(e, o(e.props));
1176
1348
  if (typeof e == "function" || typeof e == "object" && e.$$typeof) {
1177
- const a = e;
1178
- return /* @__PURE__ */ d.jsx(a, { ...i });
1349
+ const s = e;
1350
+ return /* @__PURE__ */ u.jsx(s, { ...o() });
1179
1351
  }
1180
1352
  return null;
1181
- }, Nr = (e, i, a, o, l, n, m, y) => {
1182
- const b = y?.some((p) => p.id === e.id);
1353
+ }, Mr = (e, t, o, s, c, g, y, d) => {
1354
+ const i = d?.some((E) => E.id === e.id);
1183
1355
  return e.groupHeader ? "rac-select-option rac-group-option" : [
1184
1356
  "rac-select-option",
1185
1357
  e.className,
1186
- (b || o === e.id) && "rac-selected",
1187
- i === a && "rac-highlighted",
1358
+ (i || s === e.id) && "rac-selected",
1359
+ t === o && "rac-highlighted",
1188
1360
  (e.disabled || e.loading) && "rac-disabled-option",
1189
- (e.invalid || e.name === m) && "rac-invalid-option",
1190
- e.loadMore && l === n && "rac-loading-option",
1361
+ (e.invalid || e.name === y) && "rac-invalid-option",
1362
+ e.loadMore && c === g && "rac-loading-option",
1191
1363
  typeof e.raw == "boolean" && (e.raw ? "rac-true-option" : "rac-false-option")
1192
1364
  ].filter(Boolean).join(" ");
1193
- }, Or = ur(({
1365
+ }, Dr = hr(({
1194
1366
  unmount: e,
1195
- children: i,
1196
- visibility: a,
1197
- ownBehavior: o = !1,
1198
- alwaysOpen: l = !1,
1199
- duration: n = 300,
1200
- easing: m = "ease-out",
1201
- offset: y = 0,
1202
- animateOpacity: b = !0,
1203
- style: p = {},
1204
- className: L = "",
1205
- ArrowIcon: j = mr,
1206
- ClearIcon: V = qe,
1207
- DelIcon: J = qe,
1208
- CheckIcon: O = Xe,
1209
- hasMore: P = !1,
1210
- loadMore: R = () => {
1367
+ children: t,
1368
+ visibility: o,
1369
+ ownBehavior: s = !1,
1370
+ alwaysOpen: c = !1,
1371
+ duration: g = 300,
1372
+ easing: y = "ease-out",
1373
+ offset: d = 1,
1374
+ animateOpacity: i = !0,
1375
+ style: E = {},
1376
+ className: b = "",
1377
+ ArrowIcon: k = _r,
1378
+ ClearIcon: N = or,
1379
+ DelIcon: R = or,
1380
+ CheckIcon: F = ar,
1381
+ hasMore: L = !1,
1382
+ loadMore: P = () => {
1211
1383
  console.warn("loadMore not implemented");
1212
1384
  },
1213
- loadButton: C = !1,
1214
- loadButtonText: T = "Load more",
1215
- loadMoreText: z = "Loading",
1216
- selectedText: U = void 0,
1217
- loadOffset: Q = 100,
1385
+ loadButton: M = !1,
1386
+ loadButtonText: W = "Load more",
1387
+ loadMoreText: C = "Loading",
1388
+ selectedText: z = void 0,
1389
+ loadOffset: ie = 100,
1218
1390
  loadAhead: X = 3,
1219
- childrenFirst: te = !1,
1220
- groupsClosed: ne = !1,
1221
- optionsClassName: c = "",
1222
- ...G
1223
- }, h) => {
1224
- const E = ze(), k = de(() => E.replace(/:/g, ""), [E]), [Y, S] = ue([]), [H, ge] = ue(!1), [K, le] = ue(C ? T : z), [ie, r] = ue(!1), g = fe(null), w = N((I) => {
1225
- S((q) => {
1226
- const ae = q.findIndex((ce) => ce.id === I.id);
1227
- if (ae !== -1) {
1228
- const ce = q[ae];
1229
- if (ce.label === I.label && ce.value === I.value && ce.disabled === I.disabled && ce.group === I.group)
1230
- return q;
1231
- const je = [...q];
1232
- return je[ae] = I, je;
1391
+ childrenFirst: Y = !1,
1392
+ groupsClosed: T = !1,
1393
+ optionsClassName: a = "",
1394
+ onOpen: ee = () => {
1395
+ },
1396
+ onClose: re = () => {
1397
+ },
1398
+ deleteInline: V = !1,
1399
+ ...K
1400
+ }, de) => {
1401
+ const ae = xr(), A = Ne(() => ae.replace(/:/g, ""), [ae]), [B, se] = le([]), [v, x] = le(!1), [r, l] = le(M ? W : C), [m, w] = le(!1), ge = ne(null), [ve, n] = le(!1), p = _((O) => {
1402
+ se((Z) => {
1403
+ const he = Z.findIndex(($e) => $e.id === O.id);
1404
+ if (he !== -1) {
1405
+ const $e = Z[he];
1406
+ if ($e.label === O.label && $e.value === O.value && $e.disabled === O.disabled && $e.group === O.group)
1407
+ return Z;
1408
+ const We = [...Z];
1409
+ return We[he] = O, We;
1233
1410
  }
1234
- return [...q, I];
1411
+ return [...Z, O];
1235
1412
  });
1236
- }, []), A = N((I) => {
1237
- S((q) => {
1238
- const ae = q.filter((ce) => ce.id !== I);
1239
- return ae.length === q.length ? q : ae;
1413
+ }, []), j = _((O) => {
1414
+ se((Z) => {
1415
+ const he = Z.filter(($e) => $e.id !== O);
1416
+ return he.length === Z.length ? Z : he;
1240
1417
  });
1241
- }, []), B = l ? !0 : o ? !!a : H, Z = N((I) => {
1242
- l || o || ge(I);
1243
- }, [l, o]), t = $r({
1244
- ...G,
1245
- setVisibility: Z,
1246
- jsxOptions: Y,
1247
- hasMore: P,
1248
- loadButton: C,
1249
- loadingTitle: K,
1250
- loadMore: R,
1251
- loadMoreText: z,
1252
- setLoadingTitle: le,
1253
- childrenFirst: te,
1254
- groupsClosed: ne
1255
- }), { multiple: f, normalizedOptions: s, selected: x, selectOption: _, clear: ee, removeOption: he, hasOptions: se, active: ye, selectedValue: D, disabled: u, loading: $, error: W, placeholder: oe, invalidOption: F, emptyText: me, disabledText: xe, loadingText: ve, errorText: Ae, expandedGroups: M, selectedIDs: we, setSelectedIds: Oe } = t, Pe = Sr({ setLoadingTitle: le, loadButton: C, loadButtonText: T, hasMore: P, loadMore: R, disabled: u, multiple: f, open: B, setOpen: Z, options: s, selectOption: _, selected: x, loadOffset: Q, loadAhead: X, expandedGroups: M }), { handleListScroll: er, handleBlur: rr, handleFocus: tr, handleToggle: nr, handleKeyDown: sr, highlightedIndex: Ee, setHighlightedIndex: Ce } = Pe;
1256
- dr(h, () => g.current), re(() => {
1257
- B || r(!1);
1258
- }, [B]), re(() => {
1259
- (W || u || $ || !se) && Z(!1);
1260
- }, [W, u, $, se, Z]), re(() => {
1261
- if (B && ie && Ee !== -1) {
1262
- const I = s[Ee];
1263
- I && document.getElementById(`opt-${k}-${He(I.id)}`)?.scrollIntoView({ block: "nearest" });
1418
+ }, []), f = c ? !0 : s ? !!o : v, I = _((O) => {
1419
+ c || s || x(O);
1420
+ }, [c, s]), D = Lr({
1421
+ ...K,
1422
+ setVisibility: I,
1423
+ jsxOptions: B,
1424
+ hasMore: L,
1425
+ loadButton: M,
1426
+ loadingTitle: r,
1427
+ loadMore: P,
1428
+ loadMoreText: C,
1429
+ setLoadingTitle: l,
1430
+ childrenFirst: Y,
1431
+ groupsClosed: T
1432
+ }), { multiple: fe, normalizedOptions: q, selected: U, selectOption: ce, clear: h, removeOption: G, hasOptions: Q, active: pe, selectedValue: $, disabled: xe, loading: me, error: we, placeholder: Te, invalidOption: oe, emptyText: Pe, disabledText: Ce, loadingText: Ie, errorText: H, expandedGroups: J, selectedIDs: te, setSelectedIds: Le } = D, ye = Hr({ setDeleting: n, setLoadingTitle: l, loadButton: M, loadButtonText: W, hasMore: L, loadMore: P, disabled: xe, multiple: fe, open: f, setOpen: I, options: q, selectOption: ce, selected: U, loadOffset: ie, loadAhead: X, expandedGroups: J, selectedIDs: te, onOpen: ee, onClose: re, deleting: ve }), { handleListScroll: je, handleBlur: Se, handleFocus: be, toggleVisibility: Ge, handleKeyDown: He, highlightedIndex: Ee, setHighlightedIndex: ke } = ye;
1433
+ gr(de, () => ge.current), ue(() => {
1434
+ !f && w(!1);
1435
+ }, [f]), ue(() => {
1436
+ (we || xe || me || !Q) && I(!1);
1437
+ }, [we, xe, me, Q, I]), ue(() => {
1438
+ if (f && m && Ee !== -1) {
1439
+ const O = q[Ee];
1440
+ O && document.getElementById(`${A}-${Ze(O.id)}`)?.scrollIntoView({ block: "nearest" });
1264
1441
  }
1265
- }, [Ee, B, ie, s, k]);
1266
- const $e = de(() => D != null && !(Array.isArray(D) && D.length === 0) && !(typeof D == "object" && Object.keys(D).length === 0), [D]), ir = de(() => {
1267
- if (W) return Ae;
1268
- if ($) return ve;
1269
- if (u) return xe;
1270
- if ($e && U) return U;
1271
- if (x) return x.jsx ?? x.name;
1272
- if ($e) {
1273
- const I = s.find((q) => q.raw === D);
1274
- return I ? I.name : typeof D == "object" && D !== null ? D.name ?? D.label ?? "Selected Object" : String(D);
1442
+ }, [Ee, f, m, q, A]);
1443
+ const Re = Ne(() => $ != null && !(Array.isArray($) && $.length === 0) && !(typeof $ == "object" && Object.keys($).length === 0), [$]), Ae = Ne(() => {
1444
+ if (we) return H;
1445
+ if (me) return Ie;
1446
+ if (xe) return Ce;
1447
+ if (Re && z) return z;
1448
+ if (U) return U.jsx ?? U.name;
1449
+ if (Re) {
1450
+ const O = q.find((Z) => Z.raw === $);
1451
+ return O ? O.name : typeof $ == "object" && $ !== null ? $.name ?? $.label ?? "Selected Object" : String($);
1275
1452
  }
1276
- return se ? oe : me;
1277
- }, [u, $, W, se, x, D, oe, Ae, ve, xe, me, $e, s]), or = de(() => {
1278
- const I = [];
1279
- let q = [], ae = null;
1280
- const ce = s.reduce((v, pe) => (pe.group && (v[pe.group] = (v[pe.group] || 0) + 1), v), {}), je = (v) => {
1281
- v === null || q.length === 0 || (I.push(
1282
- /* @__PURE__ */ d.jsx(
1283
- kr,
1453
+ return Q ? Te : Pe;
1454
+ }, [xe, me, we, Q, U, $, Te, H, Ie, Ce, Pe, Re, q]), Me = Ne(() => {
1455
+ const O = [];
1456
+ let Z = [], he = null;
1457
+ const $e = q.reduce((S, _e) => (_e.group && (S[_e.group] = (S[_e.group] || 0) + 1), S), {}), We = (S) => {
1458
+ S === null || Z.length === 0 || (O.push(
1459
+ /* @__PURE__ */ u.jsx(
1460
+ Fr,
1284
1461
  {
1285
- visibility: M.has(v),
1286
- children: q
1462
+ visibility: J.has(S),
1463
+ className: "rac-group-container",
1464
+ children: Z
1287
1465
  },
1288
- `slide-${v}`
1466
+ `slide-${S}`
1289
1467
  )
1290
- ), q = []);
1291
- }, We = (v, pe) => /* @__PURE__ */ d.jsxs(
1468
+ ), Z = []);
1469
+ }, rr = (S, _e) => /* @__PURE__ */ u.jsxs(
1292
1470
  "div",
1293
1471
  {
1294
- id: `opt-${k}-${He(v.id)}`,
1472
+ className: Mr(S, _e, Ee, U?.id, r, C, oe, te),
1473
+ onMouseEnter: () => !S.disabled && !S.loading && ke(_e),
1474
+ onClick: (Oe) => !S.loading && ce(S, Oe),
1475
+ "aria-disabled": S.disabled || S.loading,
1476
+ "aria-selected": U?.id === S.id,
1477
+ id: `${A}-${Ze(S.id)}`,
1295
1478
  role: "option",
1296
- "aria-selected": x?.id === v.id,
1297
- "aria-disabled": v.disabled || v.loading,
1298
- className: Nr(v, pe, Ee, x?.id, K, z, F, we),
1299
- onClick: (be) => !v.loading && _(v, be),
1300
- onMouseEnter: () => !v.disabled && !v.loading && Ce(pe),
1301
1479
  children: [
1302
- v.jsx ?? v.name,
1303
- v.loading && /* @__PURE__ */ d.jsxs("span", { className: "rac-loading-dots", children: [
1304
- /* @__PURE__ */ d.jsx("i", {}),
1305
- /* @__PURE__ */ d.jsx("i", {}),
1306
- /* @__PURE__ */ d.jsx("i", {})
1480
+ S.jsx ?? /* @__PURE__ */ u.jsx("span", { className: "rac-option-title", children: S.name }),
1481
+ S.loading && /* @__PURE__ */ u.jsxs("span", { className: "rac-loading-dots", children: [
1482
+ /* @__PURE__ */ u.jsx("i", {}),
1483
+ /* @__PURE__ */ u.jsx("i", {}),
1484
+ /* @__PURE__ */ u.jsx("i", {})
1307
1485
  ] }),
1308
- f && !v.disabled ? /* @__PURE__ */ d.jsx("div", { className: "rac-checkbox", children: De(
1309
- Xe,
1310
- {
1311
- className: `
1312
- rac-checkmark
1313
- ${we?.some((be) => be.id === v.id) ? "--checked" : ""}`
1314
- }
1315
- ) }) : null
1486
+ fe && !S.disabled && /* @__PURE__ */ u.jsx("div", { className: "rac-checkbox", children: Ke(ar, { className: `
1487
+ rac-checkmark
1488
+ ${te?.some((Oe) => Oe.id === S.id) ? "--checked" : ""}` }) })
1316
1489
  ]
1317
1490
  },
1318
- v.id
1491
+ S.id
1319
1492
  );
1320
- return s.forEach((v, pe) => {
1321
- const be = v.groupHeader, Je = !!v.group;
1322
- if ((be || !Je && ae !== null) && (je(ae), be || (ae = null)), be) {
1323
- ae = v.name;
1324
- const ar = M.has(v.name), lr = ce[v.name] > 0;
1325
- I.push(
1326
- /* @__PURE__ */ d.jsxs(
1493
+ return q.forEach((S, _e) => {
1494
+ const Oe = S.groupHeader, tr = !!S.group;
1495
+ if ((Oe || !tr && he !== null) && (We(he), Oe || (he = null)), Oe) {
1496
+ he = S.name;
1497
+ const br = J.has(S.name), wr = $e[S.name] > 0;
1498
+ O.push(
1499
+ /* @__PURE__ */ u.jsxs(
1327
1500
  "div",
1328
1501
  {
1502
+ id: S.id,
1329
1503
  className: [
1330
1504
  "rac-group-header",
1331
- v.disabled && "rac-disabled-group"
1505
+ S.disabled && "rac-disabled-group"
1332
1506
  ].filter(Boolean).join(" "),
1333
- onClick: (cr) => _(v, cr),
1507
+ onClick: (Er) => ce(S, Er),
1334
1508
  children: [
1335
- /* @__PURE__ */ d.jsx("span", { className: "rac-group-title-text", children: v.name }),
1336
- /* @__PURE__ */ d.jsx(
1337
- Re,
1509
+ /* @__PURE__ */ u.jsx("span", { className: "rac-group-title-text", children: S.name }),
1510
+ /* @__PURE__ */ u.jsx(
1511
+ Fe,
1338
1512
  {
1339
- visibility: lr && !v.disabled,
1340
- duration: n,
1513
+ visibility: wr && !S.disabled,
1341
1514
  style: { display: "grid" },
1342
- children: /* @__PURE__ */ d.jsx("span", { className: `rac-group-arrow-wrapper ${ar ? "--open" : ""}`, children: De(j, { className: "rac-select-arrow-wrapper" }) })
1515
+ duration: g,
1516
+ children: /* @__PURE__ */ u.jsx("span", { className: `rac-group-arrow-wrapper ${br ? "open" : ""}`, children: Ke(k, { className: "rac-select-arrow-wrapper" }) })
1343
1517
  }
1344
1518
  )
1345
1519
  ]
1346
1520
  },
1347
- v.id
1521
+ S.id
1348
1522
  )
1349
1523
  );
1350
- } else Je ? q.push(We(v, pe)) : I.push(We(v, pe));
1351
- }), je(ae), I;
1352
- }, [
1353
- s,
1354
- _,
1355
- k,
1356
- x,
1357
- Ee,
1358
- K,
1359
- z,
1360
- F,
1361
- Ce,
1362
- M,
1363
- j
1364
- ]);
1365
- return /* @__PURE__ */ d.jsx(
1366
- jr,
1524
+ } else tr ? Z.push(rr(S, _e)) : O.push(rr(S, _e));
1525
+ }), We(he), O;
1526
+ }, [q, ce, A, U, Ee, r, C, oe, ke, J, k]);
1527
+ return /* @__PURE__ */ u.jsx(
1528
+ Cr,
1367
1529
  {
1368
- selectedText: U,
1369
- selectRef: g,
1370
- selectId: k,
1371
- selectedIDs: we,
1372
- setSelectedIds: Oe,
1373
- multiple: f,
1374
- removeOption: he,
1375
- optionsClassName: c,
1376
- renderIcon: De,
1377
- normalizedOptions: s,
1378
- renderOptions: or,
1379
- selected: x,
1380
- title: ir,
1381
- visibility: B,
1382
- active: ye,
1383
- hasOptions: se,
1384
- hasActualValue: $e,
1530
+ setDeleting: n,
1531
+ deleting: ve,
1532
+ selectedText: z,
1533
+ selectRef: ge,
1534
+ selectId: A,
1535
+ selectedIDs: te,
1536
+ setSelectedIds: Le,
1537
+ multiple: fe,
1538
+ removeOption: G,
1539
+ optionsClassName: a,
1540
+ renderIcon: Ke,
1541
+ normalizedOptions: q,
1542
+ renderOptions: Me,
1543
+ selected: U,
1544
+ title: Ae,
1545
+ visibility: f,
1546
+ active: pe,
1547
+ hasOptions: Q,
1548
+ hasActualValue: Re,
1385
1549
  highlightedIndex: Ee,
1386
- animationFinished: ie,
1387
- disabled: u,
1388
- loading: $,
1389
- error: W,
1390
- setVisibility: Z,
1391
- setHighlightedIndex: Ce,
1392
- setAnimationFinished: r,
1393
- handleBlur: rr,
1394
- handleFocus: tr,
1395
- handleToggle: nr,
1396
- handleKeyDown: sr,
1397
- handleListScroll: er,
1398
- selectOption: _,
1399
- clear: ee,
1400
- registerOption: w,
1401
- unregisterOption: A,
1402
- children: i,
1403
- placeholder: oe,
1404
- className: L,
1405
- style: p,
1406
- duration: n,
1407
- easing: m,
1408
- offset: y,
1409
- animateOpacity: b,
1550
+ animationFinished: m,
1551
+ disabled: xe,
1552
+ loading: me,
1553
+ error: we,
1554
+ setVisibility: I,
1555
+ setHighlightedIndex: ke,
1556
+ setAnimationFinished: w,
1557
+ handleBlur: Se,
1558
+ handleFocus: be,
1559
+ toggleVisibility: Ge,
1560
+ handleKeyDown: He,
1561
+ handleListScroll: je,
1562
+ selectOption: ce,
1563
+ clear: h,
1564
+ registerOption: p,
1565
+ unregisterOption: j,
1566
+ children: t,
1567
+ placeholder: Te,
1568
+ className: b,
1569
+ style: E,
1570
+ duration: g,
1571
+ easing: y,
1572
+ offset: d,
1573
+ animateOpacity: i,
1410
1574
  unmount: e,
1411
- ArrowIcon: j,
1412
- ClearIcon: V,
1413
- DelIcon: J,
1414
- hasMore: P,
1415
- loadButton: C
1575
+ ArrowIcon: k,
1576
+ ClearIcon: N,
1577
+ DelIcon: R,
1578
+ hasMore: L,
1579
+ loadButton: M,
1580
+ deleteInline: V
1416
1581
  }
1417
1582
  );
1418
- }), Qe = Ze(null);
1419
- function Pr({ children: e, name: i, label: a, value: o, id: l, emptyGroupText: n = "Empty group" }) {
1420
- const m = Le(Ge), y = de(() => {
1421
- const p = i ?? a ?? o ?? l;
1422
- return p != null && p !== "" ? String(p) : n;
1423
- }, [i, a, o, l, n]), b = de(() => `group-marker-${He(y)}`, [y]);
1424
- return re(() => {
1425
- if (!m) return;
1426
- const p = {
1427
- id: b,
1428
- group: y,
1583
+ }), yr = fr(null);
1584
+ function Gr({ children: e, name: t, label: o, value: s, id: c, emptyGroupText: g = "Empty group" }) {
1585
+ const y = Be(er), d = Ne(() => {
1586
+ const E = t ?? o ?? s ?? c;
1587
+ return E != null && E !== "" ? String(E) : g;
1588
+ }, [t, o, s, c, g]), i = Ne(() => `group-marker-${Ze(d)}`, [d]);
1589
+ return ue(() => {
1590
+ if (!y) return;
1591
+ const E = {
1592
+ id: i,
1593
+ group: d,
1429
1594
  isGroupMarker: !0,
1430
1595
  disabled: !0
1431
1596
  };
1432
- return m.registerOption(p), () => m.unregisterOption(b);
1433
- }, [m.registerOption, m.unregisterOption, b, y]), /* @__PURE__ */ d.jsx(Qe.Provider, { value: y, children: e });
1597
+ return y.registerOption(E), () => y.unregisterOption(i);
1598
+ }, [y.registerOption, y.unregisterOption, i, d]), /* @__PURE__ */ u.jsx(yr.Provider, { value: d, children: e });
1434
1599
  }
1435
- const Ye = (e) => e ? typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(Ye).join(" ").replace(/\s+/g, " ").trim() : Be.isValidElement(e) ? Ye(e.props.children) : "" : "";
1436
- function Cr({ value: e, id: i, className: a, children: o, disabled: l, group: n }) {
1437
- const m = Le(Ge), y = Le(Qe), b = m?.registerOption, p = m?.unregisterOption, L = ze(), j = de(() => i ? String(i) : L.replace(/:/g, ""), [i, L]);
1438
- return re(() => {
1439
- if (!b) return;
1440
- const V = Ye(o), J = o != null;
1441
- let O = "";
1442
- return V ? O = V : i != null && i !== "" ? O = String(i) : e != null && e !== "" && (O = String(e)), b({
1443
- id: j,
1444
- value: e !== void 0 ? e : V,
1445
- label: O,
1446
- jsx: o,
1447
- hasJsx: J,
1448
- className: a,
1449
- disabled: !!l,
1450
- group: n || y || null
1451
- }), () => p(j);
1452
- }, [j, e, o, a, l, n, y, b, p]), null;
1600
+ const Qe = (e) => e ? typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(Qe).join(" ").replace(/\s+/g, " ").trim() : dr.isValidElement(e) ? Qe(e.props.children) : "" : "";
1601
+ function Jr({ value: e, id: t, className: o, children: s, disabled: c, group: g }) {
1602
+ const y = Be(er), d = Be(yr), i = y?.registerOption, E = y?.unregisterOption, b = xr(), k = Ne(() => t ? String(t) : b.replace(/:/g, ""), [t, b]);
1603
+ return ue(() => {
1604
+ if (!i) return;
1605
+ const N = Qe(s), R = s != null;
1606
+ let F = "";
1607
+ return N ? F = N : t != null && t !== "" ? F = String(t) : e != null && e !== "" && (F = String(e)), i({
1608
+ id: k,
1609
+ value: e !== void 0 ? e : N,
1610
+ label: F,
1611
+ jsx: s,
1612
+ hasJsx: R,
1613
+ className: o,
1614
+ disabled: !!c,
1615
+ group: g || d || null
1616
+ }), () => E(k);
1617
+ }, [k, e, s, o, c, g, d, i, E]), null;
1453
1618
  }
1454
1619
  export {
1455
- Pr as OptGroup,
1456
- Cr as Option,
1457
- Or as Select
1620
+ Gr as OptGroup,
1621
+ Jr as Option,
1622
+ Dr as Select
1458
1623
  };