react-animated-select 0.5.6 → 0.6.6

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