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