react-animated-select 0.3.6 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,147 +1,147 @@
1
- import Fe, { createContext as He, memo as Ye, useRef as ce, useState as ae, useEffect as B, useCallback as T, useMemo as se, useId as Re, forwardRef as Qe, useImperativeHandle as Be, isValidElement as er, cloneElement as rr, useContext as we } from "react";
2
- import { CSSTransition as ke } from "react-transition-group";
3
- import './index.css';var ye = { exports: {} }, be = {};
4
- var Oe;
5
- function tr() {
6
- if (Oe) return be;
7
- Oe = 1;
8
- var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), n = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function o(s, f, c) {
10
- var p = null;
11
- if (c !== void 0 && (p = "" + c), f.key !== void 0 && (p = "" + f.key), "key" in f) {
1
+ import Xe, { createContext as Ke, memo as Ie, useRef as he, useState as ge, useEffect as oe, useCallback as N, useMemo as pe, useId as Le, forwardRef as ar, useImperativeHandle as or, isValidElement as cr, cloneElement as ur, useContext as Ye } from "react";
2
+ import { CSSTransition as ke, TransitionGroup as dr } from "react-transition-group";
3
+ import './index.css';var _e = { exports: {} }, je = {};
4
+ var Ge;
5
+ function fr() {
6
+ if (Ge) return je;
7
+ Ge = 1;
8
+ var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.fragment");
9
+ function a(n, d, c) {
10
+ var v = null;
11
+ if (c !== void 0 && (v = "" + c), d.key !== void 0 && (v = "" + d.key), "key" in d) {
12
12
  c = {};
13
- for (var v in f)
14
- v !== "key" && (c[v] = f[v]);
15
- } else c = f;
16
- return f = c.ref, {
17
- $$typeof: t,
18
- type: s,
19
- key: p,
20
- ref: f !== void 0 ? f : null,
13
+ for (var m in d)
14
+ m !== "key" && (c[m] = d[m]);
15
+ } else c = d;
16
+ return d = c.ref, {
17
+ $$typeof: r,
18
+ type: n,
19
+ key: v,
20
+ ref: d !== void 0 ? d : null,
21
21
  props: c
22
22
  };
23
23
  }
24
- return be.Fragment = n, be.jsx = o, be.jsxs = o, be;
24
+ return je.Fragment = s, je.jsx = a, je.jsxs = a, je;
25
25
  }
26
- var me = {};
27
- var Ce;
28
- function nr() {
29
- return Ce || (Ce = 1, process.env.NODE_ENV !== "production" && (function() {
30
- function t(e) {
26
+ var we = {};
27
+ var ze;
28
+ function gr() {
29
+ return ze || (ze = 1, process.env.NODE_ENV !== "production" && (function() {
30
+ function r(e) {
31
31
  if (e == null) return null;
32
32
  if (typeof e == "function")
33
- return e.$$typeof === M ? null : e.displayName || e.name || null;
33
+ return e.$$typeof === x ? null : e.displayName || e.name || null;
34
34
  if (typeof e == "string") return e;
35
35
  switch (e) {
36
- case S:
36
+ case H:
37
37
  return "Fragment";
38
- case D:
38
+ case S:
39
39
  return "Profiler";
40
- case H:
40
+ case W:
41
41
  return "StrictMode";
42
- case J:
42
+ case M:
43
43
  return "Suspense";
44
- case U:
44
+ case B:
45
45
  return "SuspenseList";
46
- case E:
46
+ case ee:
47
47
  return "Activity";
48
48
  }
49
49
  if (typeof e == "object")
50
50
  switch (typeof e.tag == "number" && console.error(
51
51
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
52
  ), e.$$typeof) {
53
- case F:
53
+ case O:
54
54
  return "Portal";
55
- case d:
55
+ case u:
56
56
  return e.displayName || "Context";
57
- case W:
57
+ case F:
58
58
  return (e._context.displayName || "Context") + ".Consumer";
59
- case I:
60
- var r = e.render;
61
- return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
- case z:
63
- return r = e.displayName || null, r !== null ? r : t(e.type) || "Memo";
64
- case g:
65
- r = e._payload, e = e._init;
59
+ case U:
60
+ var f = e.render;
61
+ return e = e.displayName, e || (e = f.displayName || f.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
+ case ne:
63
+ return f = e.displayName || null, f !== null ? f : r(e.type) || "Memo";
64
+ case Q:
65
+ f = e._payload, e = e._init;
66
66
  try {
67
- return t(e(r));
67
+ return r(e(f));
68
68
  } catch {
69
69
  }
70
70
  }
71
71
  return null;
72
72
  }
73
- function n(e) {
73
+ function s(e) {
74
74
  return "" + e;
75
75
  }
76
- function o(e) {
76
+ function a(e) {
77
77
  try {
78
- n(e);
79
- var r = !1;
78
+ s(e);
79
+ var f = !1;
80
80
  } catch {
81
- r = !0;
81
+ f = !0;
82
82
  }
83
- if (r) {
84
- r = console;
85
- var l = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
- return l.call(
87
- r,
83
+ if (f) {
84
+ f = console;
85
+ var w = f.error, j = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
+ return w.call(
87
+ f,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- a
90
- ), n(e);
89
+ j
90
+ ), s(e);
91
91
  }
92
92
  }
93
- function s(e) {
94
- if (e === S) return "<>";
95
- if (typeof e == "object" && e !== null && e.$$typeof === g)
93
+ function n(e) {
94
+ if (e === H) return "<>";
95
+ if (typeof e == "object" && e !== null && e.$$typeof === Q)
96
96
  return "<...>";
97
97
  try {
98
- var r = t(e);
99
- return r ? "<" + r + ">" : "<...>";
98
+ var f = r(e);
99
+ return f ? "<" + f + ">" : "<...>";
100
100
  } catch {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function f() {
105
- var e = O.A;
104
+ function d() {
105
+ var e = y.A;
106
106
  return e === null ? null : e.getOwner();
107
107
  }
108
108
  function c() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function p(e) {
112
- if (Y.call(e, "key")) {
113
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
114
- if (r && r.isReactWarning) return !1;
111
+ function v(e) {
112
+ if (R.call(e, "key")) {
113
+ var f = Object.getOwnPropertyDescriptor(e, "key").get;
114
+ if (f && f.isReactWarning) return !1;
115
115
  }
116
116
  return e.key !== void 0;
117
117
  }
118
- function v(e, r) {
119
- function l() {
120
- q || (q = !0, console.error(
118
+ function m(e, f) {
119
+ function w() {
120
+ A || (A = !0, console.error(
121
121
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
122
- r
122
+ f
123
123
  ));
124
124
  }
125
- l.isReactWarning = !0, Object.defineProperty(e, "key", {
126
- get: l,
125
+ w.isReactWarning = !0, Object.defineProperty(e, "key", {
126
+ get: w,
127
127
  configurable: !0
128
128
  });
129
129
  }
130
130
  function h() {
131
- var e = t(this.type);
132
- return C[e] || (C[e] = !0, console.error(
131
+ var e = r(this.type);
132
+ return se[e] || (se[e] = !0, console.error(
133
133
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
134
  )), e = this.props.ref, e !== void 0 ? e : null;
135
135
  }
136
- function x(e, r, l, a, j, _) {
137
- var m = l.ref;
136
+ function p(e, f, w, j, Z, t) {
137
+ var i = w.ref;
138
138
  return e = {
139
- $$typeof: R,
139
+ $$typeof: T,
140
140
  type: e,
141
- key: r,
142
- props: l,
143
- _owner: a
144
- }, (m !== void 0 ? m : null) !== null ? Object.defineProperty(e, "ref", {
141
+ key: f,
142
+ props: w,
143
+ _owner: j
144
+ }, (i !== void 0 ? i : null) !== null ? Object.defineProperty(e, "ref", {
145
145
  enumerable: !1,
146
146
  get: h
147
147
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
@@ -158,112 +158,112 @@ function nr() {
158
158
  configurable: !1,
159
159
  enumerable: !1,
160
160
  writable: !0,
161
- value: j
161
+ value: Z
162
162
  }), Object.defineProperty(e, "_debugTask", {
163
163
  configurable: !1,
164
164
  enumerable: !1,
165
165
  writable: !0,
166
- value: _
166
+ value: t
167
167
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
168
  }
169
- function P(e, r, l, a, j, _) {
170
- var m = r.children;
171
- if (m !== void 0)
172
- if (a)
173
- if (L(m)) {
174
- for (a = 0; a < m.length; a++)
175
- N(m[a]);
176
- Object.freeze && Object.freeze(m);
169
+ function I(e, f, w, j, Z, t) {
170
+ var i = f.children;
171
+ if (i !== void 0)
172
+ if (j)
173
+ if (J(i)) {
174
+ for (j = 0; j < i.length; j++)
175
+ L(i[j]);
176
+ Object.freeze && Object.freeze(i);
177
177
  } else
178
178
  console.error(
179
179
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
180
  );
181
- else N(m);
182
- if (Y.call(r, "key")) {
183
- m = t(e);
184
- var A = Object.keys(r).filter(function(b) {
185
- return b !== "key";
181
+ else L(i);
182
+ if (R.call(f, "key")) {
183
+ i = r(e);
184
+ var g = Object.keys(f).filter(function(q) {
185
+ return q !== "key";
186
186
  });
187
- a = 0 < A.length ? "{key: someKey, " + A.join(": ..., ") + ": ...}" : "{key: someKey}", K[m + a] || (A = 0 < A.length ? "{" + A.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ j = 0 < g.length ? "{key: someKey, " + g.join(": ..., ") + ": ...}" : "{key: someKey}", ie[i + j] || (g = 0 < g.length ? "{" + g.join(": ..., ") + ": ...}" : "{}", console.error(
188
188
  `A props object containing a "key" prop is being spread into JSX:
189
189
  let props = %s;
190
190
  <%s {...props} />
191
191
  React keys must be passed directly to JSX without using spread:
192
192
  let props = %s;
193
193
  <%s key={someKey} {...props} />`,
194
- a,
195
- m,
196
- A,
197
- m
198
- ), K[m + a] = !0);
194
+ j,
195
+ i,
196
+ g,
197
+ i
198
+ ), ie[i + j] = !0);
199
199
  }
200
- if (m = null, l !== void 0 && (o(l), m = "" + l), p(r) && (o(r.key), m = "" + r.key), "key" in r) {
201
- l = {};
202
- for (var i in r)
203
- i !== "key" && (l[i] = r[i]);
204
- } else l = r;
205
- return m && v(
206
- l,
200
+ if (i = null, w !== void 0 && (a(w), i = "" + w), v(f) && (a(f.key), i = "" + f.key), "key" in f) {
201
+ w = {};
202
+ for (var E in f)
203
+ E !== "key" && (w[E] = f[E]);
204
+ } else w = f;
205
+ return i && m(
206
+ w,
207
207
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), x(
208
+ ), p(
209
209
  e,
210
- m,
211
- l,
212
- f(),
213
- j,
214
- _
210
+ i,
211
+ w,
212
+ d(),
213
+ Z,
214
+ t
215
215
  );
216
216
  }
217
- function N(e) {
218
- $(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === g && (e._payload.status === "fulfilled" ? $(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
217
+ function L(e) {
218
+ k(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === Q && (e._payload.status === "fulfilled" ? k(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
219
  }
220
- function $(e) {
221
- return typeof e == "object" && e !== null && e.$$typeof === R;
220
+ function k(e) {
221
+ return typeof e == "object" && e !== null && e.$$typeof === T;
222
222
  }
223
- var w = Fe, R = /* @__PURE__ */ Symbol.for("react.transitional.element"), F = /* @__PURE__ */ Symbol.for("react.portal"), S = /* @__PURE__ */ Symbol.for("react.fragment"), H = /* @__PURE__ */ Symbol.for("react.strict_mode"), D = /* @__PURE__ */ Symbol.for("react.profiler"), W = /* @__PURE__ */ Symbol.for("react.consumer"), d = /* @__PURE__ */ Symbol.for("react.context"), I = /* @__PURE__ */ Symbol.for("react.forward_ref"), J = /* @__PURE__ */ Symbol.for("react.suspense"), U = /* @__PURE__ */ Symbol.for("react.suspense_list"), z = /* @__PURE__ */ Symbol.for("react.memo"), g = /* @__PURE__ */ Symbol.for("react.lazy"), E = /* @__PURE__ */ Symbol.for("react.activity"), M = /* @__PURE__ */ Symbol.for("react.client.reference"), O = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Y = Object.prototype.hasOwnProperty, L = Array.isArray, ee = console.createTask ? console.createTask : function() {
223
+ var P = Xe, T = /* @__PURE__ */ Symbol.for("react.transitional.element"), O = /* @__PURE__ */ Symbol.for("react.portal"), H = /* @__PURE__ */ Symbol.for("react.fragment"), W = /* @__PURE__ */ Symbol.for("react.strict_mode"), S = /* @__PURE__ */ Symbol.for("react.profiler"), F = /* @__PURE__ */ Symbol.for("react.consumer"), u = /* @__PURE__ */ Symbol.for("react.context"), U = /* @__PURE__ */ Symbol.for("react.forward_ref"), M = /* @__PURE__ */ Symbol.for("react.suspense"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), ne = /* @__PURE__ */ Symbol.for("react.memo"), Q = /* @__PURE__ */ Symbol.for("react.lazy"), ee = /* @__PURE__ */ Symbol.for("react.activity"), x = /* @__PURE__ */ Symbol.for("react.client.reference"), y = P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, J = Array.isArray, Y = console.createTask ? console.createTask : function() {
224
224
  return null;
225
225
  };
226
- w = {
226
+ P = {
227
227
  react_stack_bottom_frame: function(e) {
228
228
  return e();
229
229
  }
230
230
  };
231
- var q, C = {}, re = w.react_stack_bottom_frame.bind(
232
- w,
231
+ var A, se = {}, K = P.react_stack_bottom_frame.bind(
232
+ P,
233
233
  c
234
- )(), oe = ee(s(c)), K = {};
235
- me.Fragment = S, me.jsx = function(e, r, l) {
236
- var a = 1e4 > O.recentlyCreatedOwnerStacks++;
237
- return P(
234
+ )(), re = Y(n(c)), ie = {};
235
+ we.Fragment = H, we.jsx = function(e, f, w) {
236
+ var j = 1e4 > y.recentlyCreatedOwnerStacks++;
237
+ return I(
238
238
  e,
239
- r,
240
- l,
239
+ f,
240
+ w,
241
241
  !1,
242
- a ? Error("react-stack-top-frame") : re,
243
- a ? ee(s(e)) : oe
242
+ j ? Error("react-stack-top-frame") : K,
243
+ j ? Y(n(e)) : re
244
244
  );
245
- }, me.jsxs = function(e, r, l) {
246
- var a = 1e4 > O.recentlyCreatedOwnerStacks++;
247
- return P(
245
+ }, we.jsxs = function(e, f, w) {
246
+ var j = 1e4 > y.recentlyCreatedOwnerStacks++;
247
+ return I(
248
248
  e,
249
- r,
250
- l,
249
+ f,
250
+ w,
251
251
  !0,
252
- a ? Error("react-stack-top-frame") : re,
253
- a ? ee(s(e)) : oe
252
+ j ? Error("react-stack-top-frame") : K,
253
+ j ? Y(n(e)) : re
254
254
  );
255
255
  };
256
- })()), me;
256
+ })()), we;
257
257
  }
258
- var Pe;
259
- function sr() {
260
- return Pe || (Pe = 1, process.env.NODE_ENV === "production" ? ye.exports = tr() : ye.exports = nr()), ye.exports;
258
+ var Ve;
259
+ function hr() {
260
+ return Ve || (Ve = 1, process.env.NODE_ENV === "production" ? _e.exports = fr() : _e.exports = gr()), _e.exports;
261
261
  }
262
- var u = sr();
263
- const ir = ({ className: t = "", ...n }) => /* @__PURE__ */ u.jsx(
262
+ var o = hr();
263
+ const We = ({ className: r = "", ...s }) => /* @__PURE__ */ o.jsx(
264
264
  "svg",
265
265
  {
266
- className: t,
266
+ className: r,
267
267
  role: "button",
268
268
  "aria-label": "Clear selection",
269
269
  xmlns: "http://www.w3.org/2000/svg",
@@ -271,119 +271,131 @@ const ir = ({ className: t = "", ...n }) => /* @__PURE__ */ u.jsx(
271
271
  width: "1em",
272
272
  height: "1em",
273
273
  fill: "currentColor",
274
- ...n,
275
- 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" })
274
+ ...s,
275
+ children: /* @__PURE__ */ o.jsx("path", { d: "M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z" })
276
276
  }
277
- ), or = ({ className: t = "", ...n }) => /* @__PURE__ */ u.jsx(
277
+ ), pr = ({ className: r = "", ...s }) => /* @__PURE__ */ o.jsx(
278
278
  "svg",
279
279
  {
280
- className: t,
280
+ className: r,
281
281
  xmlns: "http://www.w3.org/2000/svg",
282
282
  viewBox: "0 0 448 512",
283
283
  width: "1em",
284
284
  height: "1em",
285
285
  fill: "currentColor",
286
- ...n,
287
- 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" })
286
+ ...s,
287
+ children: /* @__PURE__ */ o.jsx("path", { d: "M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z" })
288
288
  }
289
- ), _e = (t, n = "invalid-option", o = "") => {
290
- const s = o ? o.replace(/:/g, "") : "";
291
- if (typeof t != "string" || !t.trim())
292
- return s ? `${n}-${s}` : `${n}-${Math.random().toString(36).slice(2, 8)}`;
293
- const f = t.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, "-").replace(/[^\p{L}\p{N}-]+/gu, "").toLowerCase();
294
- return f ? f || `${n}-${Math.random().toString(36).slice(2, 8)}` : s ? `${n}-${s}` : `${n}-${Math.random().toString(36).slice(2, 8)}`;
295
- }, Te = He(null);
296
- function lr({
297
- visibility: t,
298
- children: n,
299
- selectRef: o,
300
- onAnimationDone: s,
301
- unmount: f = !0,
289
+ ), Me = ({ className: r = "", ...s }) => /* @__PURE__ */ o.jsx(
290
+ "svg",
291
+ {
292
+ className: r,
293
+ xmlns: "http://www.w3.org/2000/svg",
294
+ viewBox: "0 0 24 24",
295
+ width: "1em",
296
+ height: "1em",
297
+ fill: "currentColor",
298
+ ...s,
299
+ children: /* @__PURE__ */ o.jsx("path", { d: "M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z" })
300
+ }
301
+ ), Je = (r, s = "invalid-option", a = "") => {
302
+ const n = a ? a.replace(/:/g, "") : "";
303
+ if (typeof r != "string" || !r.trim())
304
+ return n ? `${s}-${n}` : `${s}-${Math.random().toString(36).slice(2, 8)}`;
305
+ const d = r.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, "-").replace(/[^\p{L}\p{N}-]+/gu, "").toLowerCase();
306
+ return d ? d || `${s}-${Math.random().toString(36).slice(2, 8)}` : n ? `${s}-${n}` : `${s}-${Math.random().toString(36).slice(2, 8)}`;
307
+ }, Ze = Ke(null);
308
+ function xr({
309
+ visibility: r,
310
+ children: s,
311
+ selectRef: a,
312
+ onAnimationDone: n,
313
+ unmount: d = !0,
302
314
  duration: c,
303
- easing: p,
304
- offset: v,
315
+ easing: v,
316
+ offset: m,
305
317
  animateOpacity: h
306
318
  }) {
307
- const x = ce(null), [P, N] = ae(0);
308
- B(() => {
309
- if (!o?.current) return;
310
- N(o.current.offsetHeight);
311
- const I = new ResizeObserver((J) => {
312
- for (let U of J) N(U.target.offsetHeight);
319
+ const p = he(null), [I, L] = ge(0);
320
+ oe(() => {
321
+ if (!a?.current) return;
322
+ L(a.current.offsetHeight);
323
+ const U = new ResizeObserver((M) => {
324
+ for (let B of M) L(B.target.offsetHeight);
313
325
  });
314
- return I.observe(o.current), () => I.disconnect();
315
- }, [o]);
316
- const $ = `height ${c}ms ${p}${h ? `, opacity ${c}ms ${p}` : ""}`, w = {
326
+ return U.observe(a.current), () => U.disconnect();
327
+ }, [a]);
328
+ const k = `height ${c}ms ${v}${h ? `, opacity ${c}ms ${v}` : ""}`, P = {
317
329
  position: "absolute",
318
- top: `calc(100% + ${v}px)`,
330
+ top: `calc(100% + ${m}px)`,
319
331
  left: "0",
320
332
  width: "100%",
321
333
  overflow: "hidden",
322
334
  marginTop: "2px",
323
335
  zIndex: "1",
324
- height: t ? "auto" : "0px",
325
- opacity: h ? t ? 1 : 0 : 1,
326
- pointerEvents: t ? "all" : "none",
327
- visibility: P ? "visible" : "hidden"
328
- }, R = T(() => {
329
- const d = x.current;
330
- d && (d.style.height = "0px", h && (d.style.opacity = "0"), d.style.transition = "");
331
- }, [h]), F = T(() => {
332
- const d = x.current;
333
- d && (d.style.transition = $, d.style.height = `${d.scrollHeight}px`, h && (d.style.opacity = "1"));
334
- }, [$, h]), S = T(() => {
335
- const d = x.current;
336
- d && (d.style.height = "auto", d.style.transition = "", s && s());
337
- }, [s]), H = T(() => {
338
- const d = x.current;
339
- d && (d.style.height = `${d.scrollHeight}px`, h && (d.style.opacity = "1"), d.offsetHeight, d.style.transition = $);
340
- }, [$, h]), D = T(() => {
341
- const d = x.current;
342
- d && (d.style.height = "0px", h && (d.style.opacity = "0"));
343
- }, [h]), W = T(() => {
344
- const d = x.current;
345
- d && (d.style.transition = "");
336
+ height: r ? "auto" : "0px",
337
+ opacity: h ? r ? 1 : 0 : 1,
338
+ pointerEvents: r ? "all" : "none",
339
+ visibility: I ? "visible" : "hidden"
340
+ }, T = N(() => {
341
+ const u = p.current;
342
+ u && (u.style.height = "0px", h && (u.style.opacity = "0"), u.style.transition = "");
343
+ }, [h]), O = N(() => {
344
+ const u = p.current;
345
+ u && (u.style.transition = k, u.style.height = `${u.scrollHeight}px`, h && (u.style.opacity = "1"));
346
+ }, [k, h]), H = N(() => {
347
+ const u = p.current;
348
+ u && (u.style.height = "auto", u.style.transition = "", n && n());
349
+ }, [n]), W = N(() => {
350
+ const u = p.current;
351
+ u && (u.style.height = `${u.scrollHeight}px`, h && (u.style.opacity = "1"), u.offsetHeight, u.style.transition = k);
352
+ }, [k, h]), S = N(() => {
353
+ const u = p.current;
354
+ u && (u.style.height = "0px", h && (u.style.opacity = "0"));
355
+ }, [h]), F = N(() => {
356
+ const u = p.current;
357
+ u && (u.style.transition = "");
346
358
  }, []);
347
- return /* @__PURE__ */ u.jsx(
359
+ return /* @__PURE__ */ o.jsx(
348
360
  ke,
349
361
  {
350
- in: t,
362
+ in: r,
351
363
  timeout: c,
352
364
  classNames: "rac-options",
353
- unmountOnExit: f,
354
- nodeRef: x,
355
- onEnter: R,
356
- onEntering: F,
357
- onEntered: S,
358
- onExit: H,
359
- onExiting: D,
360
- onExited: W,
361
- children: /* @__PURE__ */ u.jsx(
365
+ unmountOnExit: d,
366
+ nodeRef: p,
367
+ onEnter: T,
368
+ onEntering: O,
369
+ onEntered: H,
370
+ onExit: W,
371
+ onExiting: S,
372
+ onExited: F,
373
+ children: /* @__PURE__ */ o.jsx(
362
374
  "div",
363
375
  {
364
- ref: x,
376
+ ref: p,
365
377
  className: "rac-options",
366
- style: w,
367
- children: n
378
+ style: P,
379
+ children: s
368
380
  }
369
381
  )
370
382
  }
371
383
  );
372
384
  }
373
- const ar = Ye(lr, (t, n) => t.visibility === n.visibility && t.duration === n.duration && t.easing === n.easing && t.offset === n.offset && t.animateOpacity === n.animateOpacity && t.selectRef === n.selectRef && t.children === n.children);
374
- function Ee({
375
- visibility: t,
376
- children: n,
377
- duration: o = 300,
378
- unmount: s,
379
- style: f
385
+ const br = Ie(xr, (r, s) => r.visibility === s.visibility && r.duration === s.duration && r.easing === s.easing && r.offset === s.offset && r.animateOpacity === s.animateOpacity && r.selectRef === s.selectRef && r.children === s.children);
386
+ function Re({
387
+ visibility: r,
388
+ children: s,
389
+ duration: a = 300,
390
+ unmount: n,
391
+ style: d
380
392
  }) {
381
- const c = ce(null);
382
- return /* @__PURE__ */ u.jsx(
393
+ const c = he(null);
394
+ return /* @__PURE__ */ o.jsx(
383
395
  ke,
384
396
  {
385
- in: t,
386
- timeout: o,
397
+ in: r,
398
+ timeout: a,
387
399
  classNames: "rac-slide-left",
388
400
  unmountOnExit: !0,
389
401
  nodeRef: c,
@@ -392,747 +404,910 @@ function Ee({
392
404
  onEntered: () => c.current.style.width = "auto",
393
405
  onExit: () => c.current.style.width = c.current.scrollWidth + "px",
394
406
  onExiting: () => c.current.style.width = "0px",
395
- onExited: () => s?.(),
396
- children: /* @__PURE__ */ u.jsx(
407
+ onExited: () => n?.(),
408
+ children: /* @__PURE__ */ o.jsx(
397
409
  "div",
398
410
  {
399
411
  ref: c,
400
412
  style: {
401
- ...f,
413
+ ...d,
402
414
  overflow: "hidden",
403
- transition: `width ${o}ms ease`
415
+ transition: `width ${a}ms ease`
404
416
  },
405
- children: n
417
+ children: s
406
418
  }
407
419
  )
408
420
  }
409
421
  );
410
422
  }
411
- const cr = Ye(({
412
- selectRef: t,
413
- selectId: n,
414
- renderOptions: o,
415
- selected: s,
416
- title: f,
417
- visibility: c,
423
+ const Ue = ({ children: r, duration: s, ...a }) => {
424
+ const n = he(null);
425
+ return /* @__PURE__ */ o.jsx(
426
+ ke,
427
+ {
428
+ nodeRef: n,
429
+ timeout: s,
430
+ classNames: "rac-slide-left",
431
+ ...a,
432
+ onEnter: () => {
433
+ n.current.style.width = "0px", n.current.style.opacity = "0";
434
+ },
435
+ onEntering: () => {
436
+ n.current.style.width = n.current.scrollWidth + "px", n.current.style.opacity = "1";
437
+ },
438
+ onEntered: () => {
439
+ n.current.style.width = "auto", n.current.style.opacity = "1";
440
+ },
441
+ onExit: () => {
442
+ n.current.style.width = n.current.scrollWidth + "px", n.current.style.opacity = "1";
443
+ },
444
+ onExiting: () => {
445
+ n.current.style.width = "0px", n.current.style.opacity = "0", n.current.style.margin = "0";
446
+ },
447
+ children: /* @__PURE__ */ o.jsx(
448
+ "div",
449
+ {
450
+ ref: n,
451
+ style: {
452
+ display: "flex",
453
+ alignItems: "center",
454
+ height: "100%",
455
+ overflow: "hidden",
456
+ whiteSpace: "nowrap",
457
+ transition: `all ${s}ms ease`
458
+ },
459
+ children: r
460
+ }
461
+ )
462
+ }
463
+ );
464
+ }, yr = Ie(({ element: r, index: s, remove: a, renderIcon: n, DelIcon: d, normalizedOptions: c }) => {
465
+ let v = null;
466
+ if (r?.jsx)
467
+ v = r.jsx;
468
+ else if (r?.name)
469
+ v = r.name;
470
+ else if (r?.raw !== void 0) {
471
+ const h = c.find(
472
+ (p) => p.raw === r.raw || p.original === r.raw || p.userId === r.raw
473
+ );
474
+ h && (v = h.jsx ?? h.name);
475
+ }
476
+ v == null && (v = typeof r == "object" ? r.label ?? r.name ?? r.value ?? "Selected item" : String(r));
477
+ const m = N((h) => {
478
+ h.stopPropagation(), h.preventDefault(), a(r.id);
479
+ }, [r.id, a]);
480
+ return /* @__PURE__ */ o.jsxs("div", { className: "rac-multiple-selected-option", children: [
481
+ v,
482
+ n(d, { onClick: m })
483
+ ] });
484
+ }), mr = Ie(({
485
+ selectRef: r,
486
+ selectId: s,
487
+ renderOptions: a,
488
+ selected: n,
489
+ selectedIDs: d,
490
+ setSelectedIds: c,
491
+ normalizedOptions: v,
492
+ title: m,
493
+ visibility: h,
418
494
  active: p,
419
- hasOptions: v,
420
- hasActualValue: h,
421
- disabled: x,
495
+ hasOptions: I,
496
+ hasActualValue: L,
497
+ disabled: k,
422
498
  loading: P,
423
- error: N,
424
- registerOption: $,
425
- unregisterOption: w,
426
- handleBlur: R,
427
- handleFocus: F,
428
- handleToggle: S,
429
- handleKeyDown: H,
430
- handleListScroll: D,
431
- setAnimationFinished: W,
432
- clear: d,
433
- children: I,
434
- renderedDropdown: J,
435
- placeholder: U,
436
- className: z,
437
- style: g,
438
- duration: E,
439
- easing: M,
440
- offset: O,
441
- animateOpacity: Y,
442
- unmount: L,
443
- ArrowIcon: ee,
444
- ClearIcon: q,
445
- renderIcon: C,
446
- hasMore: re,
447
- loadButton: oe
448
- }) => /* @__PURE__ */ u.jsxs(
449
- Te.Provider,
450
- {
451
- value: { registerOption: $, unregisterOption: w },
452
- children: [
453
- I,
454
- J,
455
- /* @__PURE__ */ u.jsxs(
456
- "div",
499
+ error: T,
500
+ registerOption: O,
501
+ unregisterOption: H,
502
+ handleBlur: W,
503
+ handleFocus: S,
504
+ handleToggle: F,
505
+ handleKeyDown: u,
506
+ handleListScroll: U,
507
+ setAnimationFinished: M,
508
+ clear: B,
509
+ children: ne,
510
+ renderedDropdown: Q,
511
+ placeholder: ee,
512
+ className: x,
513
+ style: y,
514
+ duration: R,
515
+ easing: J,
516
+ offset: Y,
517
+ animateOpacity: A,
518
+ unmount: se,
519
+ ArrowIcon: K,
520
+ ClearIcon: re,
521
+ DelIcon: ie,
522
+ renderIcon: e,
523
+ hasMore: f,
524
+ loadButton: w
525
+ }) => {
526
+ const j = N((t) => {
527
+ c((i) => i.filter((g) => g.id !== t));
528
+ }, [c]), Z = d.map((t, i) => /* @__PURE__ */ o.jsx(
529
+ Ue,
530
+ {
531
+ duration: R,
532
+ children: /* @__PURE__ */ o.jsx(
533
+ yr,
457
534
  {
458
- ref: t,
459
- style: { "--rac-duration": `${E}ms`, ...g },
460
- className: `rac-select
461
- ${z}
462
- ${!v || x ? "rac-disabled-style" : ""}
535
+ element: t,
536
+ index: i,
537
+ remove: j,
538
+ renderIcon: e,
539
+ DelIcon: ie,
540
+ normalizedOptions: v
541
+ },
542
+ t.id ?? i
543
+ )
544
+ },
545
+ t.id ?? i
546
+ ));
547
+ return /* @__PURE__ */ o.jsxs(
548
+ Ze.Provider,
549
+ {
550
+ value: { registerOption: O, unregisterOption: H },
551
+ children: [
552
+ ne,
553
+ Q,
554
+ /* @__PURE__ */ o.jsxs(
555
+ "div",
556
+ {
557
+ ref: r,
558
+ style: { "--rac-duration": `${R}ms`, ...y },
559
+ className: `rac-select
560
+ ${x}
561
+ ${!I || k ? "rac-disabled-style" : ""}
463
562
  ${P ? "rac-loading-style" : ""}
464
- ${N ? "rac-error-style" : ""}`,
465
- tabIndex: p ? 0 : -1,
466
- role: "combobox",
467
- "aria-haspopup": "listbox",
468
- "aria-expanded": c,
469
- "aria-controls": `${n}-listbox`,
470
- "aria-label": U,
471
- "aria-disabled": x || !v,
472
- ...p && {
473
- onBlur: R,
474
- onFocus: F,
475
- onClick: S,
476
- onKeyDown: H
477
- },
478
- children: [
479
- /* @__PURE__ */ u.jsxs("div", { className: `rac-select-title ${!N && !P && s?.type === "boolean" ? s.raw ? "rac-true-option" : "rac-false-option" : ""}`, children: [
480
- /* @__PURE__ */ u.jsx("span", { className: "rac-title-text", children: f }, f),
481
- /* @__PURE__ */ u.jsx(Ee, { visibility: P && !N, duration: E, children: /* @__PURE__ */ u.jsxs("span", { className: "rac-loading-dots", children: [
482
- /* @__PURE__ */ u.jsx("i", {}),
483
- /* @__PURE__ */ u.jsx("i", {}),
484
- /* @__PURE__ */ u.jsx("i", {})
485
- ] }) })
486
- ] }),
487
- /* @__PURE__ */ u.jsxs("div", { className: "rac-select-buttons", children: [
488
- /* @__PURE__ */ u.jsx(
489
- Ee,
563
+ ${T ? "rac-error-style" : ""}`,
564
+ tabIndex: p ? 0 : -1,
565
+ role: "combobox",
566
+ "aria-haspopup": "listbox",
567
+ "aria-expanded": h,
568
+ "aria-controls": `${s}-listbox`,
569
+ "aria-label": ee,
570
+ "aria-disabled": k || !I,
571
+ ...p && {
572
+ onBlur: W,
573
+ onFocus: S,
574
+ onClick: F,
575
+ onKeyDown: u
576
+ },
577
+ children: [
578
+ /* @__PURE__ */ o.jsx(
579
+ "div",
490
580
  {
491
- visibility: h && v && !x && !P && !N,
492
- duration: E,
493
- style: { display: "grid" },
494
- children: C(q, {
495
- className: "rac-select-cancel",
496
- onMouseDown: (K) => {
497
- K.preventDefault(), K.stopPropagation();
581
+ className: `rac-select-title
582
+ ${!T && !P && n?.type === "boolean" ? n.raw ? "rac-true-option" : "rac-false-option" : ""}
583
+ `,
584
+ children: /* @__PURE__ */ o.jsx(dr, { component: null, children: d.length ? Z : /* @__PURE__ */ o.jsxs(
585
+ Ue,
586
+ {
587
+ duration: R,
588
+ children: [
589
+ /* @__PURE__ */ o.jsx("span", { className: "rac-title-text", children: m }, m),
590
+ /* @__PURE__ */ o.jsx(Re, { visibility: P && !T, duration: R, children: /* @__PURE__ */ o.jsxs("span", { className: "rac-loading-dots", children: [
591
+ /* @__PURE__ */ o.jsx("i", {}),
592
+ /* @__PURE__ */ o.jsx("i", {}),
593
+ /* @__PURE__ */ o.jsx("i", {})
594
+ ] }) })
595
+ ]
498
596
  },
499
- onClick: d
500
- })
597
+ "placeholder-content"
598
+ ) })
501
599
  }
502
600
  ),
503
- /* @__PURE__ */ u.jsx(
504
- Ee,
601
+ /* @__PURE__ */ o.jsxs("div", { className: "rac-select-buttons", children: [
602
+ /* @__PURE__ */ o.jsx(
603
+ Re,
604
+ {
605
+ visibility: L && I && !k && !P && !T,
606
+ duration: R,
607
+ style: { display: "grid" },
608
+ children: e(re, {
609
+ className: "rac-select-cancel",
610
+ onMouseDown: (t) => {
611
+ t.preventDefault(), t.stopPropagation();
612
+ },
613
+ onClick: B
614
+ })
615
+ }
616
+ ),
617
+ /* @__PURE__ */ o.jsx(
618
+ Re,
619
+ {
620
+ visibility: p,
621
+ duration: R,
622
+ style: { display: "grid" },
623
+ children: /* @__PURE__ */ o.jsx(
624
+ "span",
625
+ {
626
+ className: `rac-select-arrow-wrapper ${h ? "--open" : ""}`,
627
+ children: e(K, {
628
+ className: "rac-select-arrow-wrapper"
629
+ })
630
+ }
631
+ )
632
+ }
633
+ )
634
+ ] }),
635
+ /* @__PURE__ */ o.jsx(
636
+ br,
505
637
  {
506
- visibility: p,
507
- duration: E,
508
- style: { display: "grid" },
509
- children: /* @__PURE__ */ u.jsx(
510
- "span",
638
+ visibility: h,
639
+ selectRef: r,
640
+ onAnimationDone: () => M(!0),
641
+ unmount: se,
642
+ duration: R,
643
+ easing: J,
644
+ offset: Y,
645
+ animateOpacity: A,
646
+ children: /* @__PURE__ */ o.jsxs(
647
+ "div",
511
648
  {
512
- className: `rac-select-arrow-wrapper ${c ? "--open" : ""}`,
513
- children: C(ee, {
514
- className: "rac-select-arrow-wrapper"
515
- })
649
+ onScroll: U,
650
+ tabIndex: "-1",
651
+ className: "rac-select-list",
652
+ role: "listbox",
653
+ "aria-label": "Options",
654
+ children: [
655
+ a,
656
+ !w && f && /* @__PURE__ */ o.jsxs(
657
+ "div",
658
+ {
659
+ className: "rac-select-option rac-disabled-option rac-loading-option",
660
+ onClick: (t) => t.stopPropagation(),
661
+ children: [
662
+ /* @__PURE__ */ o.jsx("span", { className: "rac-loading-option-title", children: "Loading" }),
663
+ /* @__PURE__ */ o.jsxs("span", { className: "rac-loading-dots", children: [
664
+ /* @__PURE__ */ o.jsx("i", {}),
665
+ /* @__PURE__ */ o.jsx("i", {}),
666
+ /* @__PURE__ */ o.jsx("i", {})
667
+ ] })
668
+ ]
669
+ }
670
+ )
671
+ ]
516
672
  }
517
673
  )
518
674
  }
519
675
  )
520
- ] }),
521
- /* @__PURE__ */ u.jsx(
522
- ar,
523
- {
524
- visibility: c,
525
- selectRef: t,
526
- onAnimationDone: () => W(!0),
527
- unmount: L,
528
- duration: E,
529
- easing: M,
530
- offset: O,
531
- animateOpacity: Y,
532
- children: /* @__PURE__ */ u.jsxs(
533
- "div",
534
- {
535
- onScroll: D,
536
- tabIndex: "-1",
537
- className: "rac-select-list",
538
- role: "listbox",
539
- "aria-label": "Options",
540
- children: [
541
- o,
542
- !oe && re && /* @__PURE__ */ u.jsxs(
543
- "div",
544
- {
545
- className: "rac-select-option rac-disabled-option rac-loading-option",
546
- onClick: (K) => K.stopPropagation(),
547
- children: [
548
- /* @__PURE__ */ u.jsx("span", { className: "rac-loading-option-title", children: "Loading" }),
549
- /* @__PURE__ */ u.jsxs("span", { className: "rac-loading-dots", children: [
550
- /* @__PURE__ */ u.jsx("i", {}),
551
- /* @__PURE__ */ u.jsx("i", {}),
552
- /* @__PURE__ */ u.jsx("i", {})
553
- ] })
554
- ]
555
- }
556
- )
557
- ]
558
- }
559
- )
560
- }
561
- )
562
- ]
563
- }
564
- )
565
- ]
566
- }
567
- ));
568
- function ur({
569
- disabled: t,
570
- open: n,
571
- setOpen: o,
572
- options: s = [],
573
- selectOption: f,
676
+ ]
677
+ }
678
+ )
679
+ ]
680
+ }
681
+ );
682
+ });
683
+ function Er({
684
+ disabled: r,
685
+ open: s,
686
+ setOpen: a,
687
+ options: n = [],
688
+ selectOption: d,
574
689
  selected: c,
575
- hasMore: p,
576
- loadMore: v,
577
- loadButton: h,
578
- loadButtonText: x,
579
- setLoadingTitle: P,
580
- loadOffset: N,
581
- loadAhead: $
690
+ multiple: v,
691
+ hasMore: m,
692
+ loadMore: h,
693
+ loadButton: p,
694
+ loadButtonText: I,
695
+ setLoadingTitle: L,
696
+ loadOffset: k,
697
+ loadAhead: P,
698
+ expandedGroups: T
582
699
  }) {
583
- const w = ce(!1), R = ce(0), F = ce(!1), [S, H] = ae(-1);
584
- B(() => {
585
- F.current = !1, h && P(x);
586
- }, [s.length, p, h, x, P]);
587
- const D = T(() => {
588
- !p || F.current || (F.current = !0, v());
589
- }, [p, v]), W = T((g) => {
590
- if (h || !p || F.current) return;
591
- const { scrollTop: E, scrollHeight: M, clientHeight: O } = g.currentTarget;
592
- M - E <= O + N && D();
593
- }, [h, p, N, D]);
594
- B(() => {
595
- !h && n && p && S >= s.length - $ && D();
596
- }, [S, n, p, s.length, $, h, D]), B(() => {
597
- const g = () => {
598
- R.current = Date.now();
700
+ const O = he(!1), H = he(0), W = he(!1), [S, F] = ge(-1);
701
+ oe(() => {
702
+ W.current = !1, p && L(I);
703
+ }, [n.length, m, p, I, L]);
704
+ const u = N(() => {
705
+ !m || W.current || (W.current = !0, h());
706
+ }, [m, h]), U = N((x) => {
707
+ if (p || !m || W.current) return;
708
+ const { scrollTop: y, scrollHeight: R, clientHeight: J } = x.currentTarget;
709
+ R - y <= J + k && u();
710
+ }, [p, m, k, u]);
711
+ oe(() => {
712
+ !p && s && m && S >= n.length - P && u();
713
+ }, [S, s, m, n.length, P, p, u]), oe(() => {
714
+ const x = () => {
715
+ H.current = Date.now();
599
716
  };
600
- return window.addEventListener("focus", g), () => window.removeEventListener("focus", g);
601
- }, []), B(() => {
602
- if (!n) {
603
- H(-1);
717
+ return window.addEventListener("focus", x), () => window.removeEventListener("focus", x);
718
+ }, []), oe(() => {
719
+ if (!s) {
720
+ F(-1);
604
721
  return;
605
722
  }
606
- if (S >= 0 && S < s.length) return;
607
- let g = -1;
608
- c && (g = s.findIndex((E) => E.id === c.id && !E.disabled)), g === -1 && (g = s.findIndex((E) => !E.disabled)), H(g);
609
- }, [n, s, c]);
610
- const d = T((g, E) => {
611
- const M = (L) => L && !L.disabled && !L.loading, O = s.length;
612
- if (O === 0) return -1;
613
- let Y = g;
614
- for (let L = 0; L < O; L++) {
615
- if (Y = (Y + E + O) % O, !h && p && (E > 0 && Y === 0 || E < 0 && Y === O - 1))
616
- return g;
617
- if (M(s[Y])) return Y;
723
+ if (S >= 0 && S < n.length && !(!n[S] || n[S].hidden || n[S].groupHeader))
724
+ return;
725
+ let x = -1;
726
+ if (c) {
727
+ const y = v ? c[0] : c;
728
+ y && (x = n.findIndex((R) => R.id === y.id && !R.disabled && !R.hidden && !R.groupHeader));
618
729
  }
619
- return g;
620
- }, [s, p, h]), I = T((g) => {
621
- g.currentTarget.contains(g.relatedTarget) || o(!1);
622
- }, [o]), J = T(() => {
623
- t || document.hidden || Date.now() - R.current < 100 || n || (o(!0), w.current = !0, setTimeout(() => {
624
- w.current = !1;
730
+ x === -1 && (x = n.findIndex((y) => !y.disabled && !y.hidden && !y.groupHeader)), F(x);
731
+ }, [s, n, c]);
732
+ const M = N((x, y) => {
733
+ const R = (A) => A && !A?.groupHeader && (!A?.group || T?.has(A?.group)) && !A?.disabled && !A?.loading, J = n.length;
734
+ if (J === 0) return -1;
735
+ let Y = x;
736
+ for (let A = 0; A < J; A++) {
737
+ if (Y = (Y + y + J) % J, !p && m && (y > 0 && Y === 0 || y < 0 && Y === J - 1))
738
+ return x;
739
+ if (R(n[Y])) return Y;
740
+ }
741
+ return x;
742
+ }, [n, m, p, T]), B = N((x) => {
743
+ x.currentTarget.contains(x.relatedTarget) || a(!1);
744
+ }, [a]), ne = N(() => {
745
+ r || document.hidden || Date.now() - H.current < 100 || s || (a(!0), O.current = !0, setTimeout(() => {
746
+ O.current = !1;
625
747
  }, 200));
626
- }, [t, n, o]), U = T((g) => {
627
- t || g.target.closest(".rac-select-cancel") || w.current || o(!n);
628
- }, [t, n, o]), z = T((g) => {
629
- if (!t)
630
- switch (g.key) {
748
+ }, [r, s, a]), Q = N((x) => {
749
+ r || x.target.closest(".rac-select-cancel") || O.current || a(!s);
750
+ }, [r, s, a]), ee = N((x) => {
751
+ if (!r)
752
+ switch (x.key) {
631
753
  case "Enter":
632
754
  case " ":
633
- g.preventDefault(), n ? S !== -1 && s[S] && f(s[S], g) : o(!0);
755
+ x.preventDefault(), s ? S !== -1 && n[S] && d(n[S], x) : a(!0);
634
756
  break;
635
757
  case "Escape":
636
- g.preventDefault(), o(!1);
758
+ x.preventDefault(), a(!1);
637
759
  break;
638
760
  case "ArrowDown":
639
- g.preventDefault(), n ? H((E) => d(E, 1)) : o(!0);
761
+ x.preventDefault(), s ? F((y) => M(y, 1)) : a(!0);
640
762
  break;
641
763
  case "ArrowUp":
642
- g.preventDefault(), n ? H((E) => d(E, -1)) : o(!0);
764
+ x.preventDefault(), s ? F((y) => M(y, -1)) : a(!0);
643
765
  break;
644
766
  case "Tab":
645
- n && o(!1);
767
+ s && a(!1);
646
768
  break;
647
769
  }
648
- }, [t, n, o, S, s, f, d]);
649
- return se(() => ({
650
- handleBlur: I,
651
- handleFocus: J,
652
- handleToggle: U,
653
- handleKeyDown: z,
770
+ }, [r, s, a, S, n, d, M]);
771
+ return pe(() => ({
772
+ handleBlur: B,
773
+ handleFocus: ne,
774
+ handleToggle: Q,
775
+ handleKeyDown: ee,
654
776
  highlightedIndex: S,
655
- setHighlightedIndex: H,
656
- handleListScroll: W
657
- }), [I, J, U, z, S, W]);
777
+ setHighlightedIndex: F,
778
+ handleListScroll: U
779
+ }), [B, ne, Q, ee, S, U]);
658
780
  }
659
- const dr = ["group", "disabled", "options", "items", "children"], De = ["name", "label", "id", "value"];
660
- function fr({
661
- options: t = [],
662
- jsxOptions: n = [],
663
- value: o,
664
- defaultValue: s = void 0,
665
- onChange: f,
781
+ const vr = ["group", "disabled", "options", "items", "children"], Oe = ["name", "label", "id", "value"], qe = (r, s = !1) => {
782
+ if (s && typeof r.group == "string") return r.group;
783
+ const a = Oe.find((d) => r[d] != null && r[d] !== "");
784
+ if (a) return String(r[a]);
785
+ const n = Object.entries(r).find(([d, c]) => !vr.includes(d) && c != null && c !== "");
786
+ return n ? String(n[1]) : null;
787
+ };
788
+ function jr({
789
+ options: r = [],
790
+ jsxOptions: s = [],
791
+ value: a,
792
+ defaultValue: n,
793
+ onChange: d,
666
794
  disabled: c = !1,
667
- loading: p = !1,
668
- error: v = !1,
669
- placeholder: h = "Choose option",
670
- emptyText: x = "No options",
671
- disabledText: P = "Disabled",
672
- loadingText: N = "Loading",
673
- errorText: $ = "Failed to load",
674
- disabledOption: w = "Disabled option",
675
- emptyOption: R = "Empty option",
676
- invalidOption: F = "Invalid option",
677
- setVisibility: S,
678
- hasMore: H,
679
- loadButton: D,
680
- setLoadingTitle: W,
681
- loadingTitle: d,
682
- loadMoreText: I,
683
- loadMore: J,
684
- childrenFirst: U
795
+ loading: v = !1,
796
+ error: m = !1,
797
+ multiple: h = !1,
798
+ placeholder: p = "Choose option",
799
+ emptyText: I = "No options",
800
+ disabledText: L = "Disabled",
801
+ loadingText: k = "Loading",
802
+ errorText: P = "Failed to load",
803
+ disabledOption: T = "Disabled option",
804
+ emptyOption: O = "Empty option",
805
+ invalidOption: H = "Invalid option",
806
+ setVisibility: W,
807
+ hasMore: S,
808
+ loadButton: F,
809
+ setLoadingTitle: u,
810
+ loadingTitle: U,
811
+ loadMoreText: M,
812
+ loadMore: B,
813
+ childrenFirst: ne,
814
+ groupsClosed: Q
685
815
  }) {
686
- const z = Re(), g = o !== void 0, [E, M] = ae(null), O = T((r, l = !1) => {
687
- const a = De.find((_) => r[_] !== void 0 && r[_] !== null && r[_] !== "");
688
- if (a) return String(r[a]);
689
- const j = Object.entries(r).find(
690
- ([_, m]) => !dr.includes(_) && m != null && m !== ""
691
- );
692
- return j ? String(j[1]) : l;
693
- }, []), Y = T((r, l, a = "normal", j = null, _ = !1) => {
694
- let m = "", A = r, i = _, b = null, V = j;
695
- return r == null || r === "" ? {
696
- id: `${z}-${a}-${l}`,
697
- userId: null,
698
- name: R,
699
- raw: null,
700
- disabled: !0,
701
- type: "normal",
702
- group: V
703
- } : typeof r == "function" ? {
704
- id: `${z}-inv-${l}`,
705
- userId: null,
706
- name: F,
707
- raw: r,
708
- disabled: !0,
709
- invalid: !0,
710
- type: "normal",
711
- group: V
712
- } : (typeof r == "object" && !Array.isArray(r) ? (V || (V = r.group || null), i = i || !!r.disabled, b = r.id ?? r.value ?? r.name ?? r.label, A = r.value !== void 0 ? r.value : r.id !== void 0 ? r.id : r, m = O(r, i ? w : R), m === R && !i && (i = !0)) : (m = String(r), b = r, A = r), {
713
- id: `${z}-${a}-${l}`,
714
- userId: b,
715
- name: m,
716
- raw: A,
717
- original: r,
718
- disabled: i,
719
- type: typeof A == "boolean" ? "boolean" : "normal",
720
- group: V
816
+ const ee = Le(), x = a !== void 0, [y, R] = ge(null), [J, Y] = ge([]), [A, se] = ge(/* @__PURE__ */ new Set()), K = he(null), re = N((t) => {
817
+ se((i) => {
818
+ const g = new Set(i);
819
+ return g.has(t) ? g.delete(t) : g.add(t), g;
721
820
  });
722
- }, [z, R, F, w, O]), [L, ee] = ae(/* @__PURE__ */ new Set()), q = T((r) => {
723
- ee((l) => {
724
- const a = new Set(l);
725
- return a.has(r) ? a.delete(r) : a.add(r), a;
726
- });
727
- }, []), C = se(() => {
728
- const r = [], l = (i, b, V = null, Z = !1) => {
729
- if (i && typeof i == "object" && !Array.isArray(i) && "options" in i) {
730
- const te = O(i, "Empty group", !0), le = Z || !!i.disabled, Q = i.options;
731
- Array.isArray(Q) ? Q.forEach((ge, de) => l(ge, `${b}-${de}`, te, le)) : Q && typeof Q == "object" ? Object.entries(Q).forEach(([ge, de], xe) => l(de, `${b}-${xe}`, te, le)) : l(Q, `${b}-0`, te, le);
732
- return;
733
- }
734
- if (i && typeof i == "object" && !Array.isArray(i) && !De.some((te) => te in i) && !("group" in i)) {
735
- Object.entries(i).forEach(([te, le], Q) => {
736
- r.push(Y(le, `${b}-${Q}`, "normal", V, Z));
737
- });
738
- return;
739
- }
740
- r.push(Y(i, b, "normal", V, Z));
821
+ }, []), ie = N((t, i, g = "n", E = null, q = !1) => {
822
+ const le = `${ee}-${g}-${i}`;
823
+ if (t == null || t === "")
824
+ return { id: le, userId: null, name: O, raw: null, disabled: !0, type: "normal", group: E, groupDisabled: q };
825
+ if (typeof t == "function")
826
+ return { id: le, userId: null, name: H, raw: t, disabled: !0, invalid: !0, type: "normal", group: E };
827
+ if (typeof t == "object" && !Array.isArray(t)) {
828
+ const ue = E || t.group || null, de = q || t.disabled === !0, D = t.id ?? t.value ?? t.name ?? t.label, X = t.value !== void 0 ? t.value : t.id !== void 0 ? t.id : t;
829
+ let l = qe(t) || (de ? T : O);
830
+ return {
831
+ id: le,
832
+ userId: D,
833
+ name: l,
834
+ raw: X,
835
+ original: t,
836
+ disabled: de || l === O && !de,
837
+ type: typeof X == "boolean" ? "boolean" : "normal",
838
+ group: ue,
839
+ groupDisabled: q
840
+ };
841
+ }
842
+ return {
843
+ id: le,
844
+ userId: t,
845
+ name: String(t),
846
+ raw: t,
847
+ original: t,
848
+ disabled: q,
849
+ type: typeof t == "boolean" ? "boolean" : "normal",
850
+ group: E
741
851
  };
742
- Array.isArray(t) && t.forEach((i, b) => l(i, b));
743
- const a = n.map((i) => {
744
- if (i.isGroupMarker) return { ...i, type: "group-marker" };
745
- const b = (i.value == null || i.value === "") && !i.label;
852
+ }, [ee, O, H, T]), e = pe(() => {
853
+ const t = /* @__PURE__ */ new Map(), i = [], g = s.map((l, _) => {
854
+ if (l.isGroupMarker) return { ...l, type: "group-marker" };
855
+ const G = !l.label && !l.userId && !l.value && (l.value === void 0 || l.value === null || l.value === "") && !l.hasJsx;
746
856
  return {
747
- ...i,
748
- id: `jsx-${i.id}`,
749
- userId: i.id,
750
- raw: i.value,
751
- original: i.value,
752
- name: b ? R : i.label,
753
- disabled: !!i.disabled || b,
754
- type: typeof i.value == "boolean" ? "boolean" : "normal",
755
- group: i.group || null
857
+ ...l,
858
+ id: `jsx-${l.id}`,
859
+ index: _,
860
+ userId: l.userId,
861
+ raw: l.value,
862
+ original: l.value,
863
+ name: G ? O : l.label || l.userId || String(l.value || ""),
864
+ disabled: !!l.disabled || G,
865
+ type: typeof l.value == "boolean" ? "boolean" : "normal",
866
+ group: l.group || null
756
867
  };
757
- }), j = U ? [...a, ...r] : [...r, ...a], _ = [], m = /* @__PURE__ */ new Map(), A = [];
758
- return j.forEach((i) => {
759
- if (!i.group)
760
- A.push({ type: "item", data: i });
761
- else if (m.has(i.group) || (m.set(i.group, []), A.push({ type: "group", name: i.group })), !i.isGroupMarker) {
762
- const b = L.has(i.group);
763
- m.get(i.group).push({ ...i, hidden: !b });
868
+ });
869
+ let E = 0;
870
+ const q = (l, _ = null, G = !1, ae = "0") => {
871
+ Array.isArray(l) || (l = [l]), l.forEach((C, Se) => {
872
+ if (!C) return;
873
+ const xe = `${ae}-${Se}`, me = typeof C == "object" && !Array.isArray(C);
874
+ if (me && ("options" in C || "group" in C && !Oe.some((z) => z in C))) {
875
+ const z = qe(C, !0) || "Empty group";
876
+ t.has(z) || t.set(z, { disabled: !!C.disabled, closedByDefault: !!C.disabled || Q, items: [] }), C.options ? q(C.options, z, G || !!C.disabled, xe) : i.push({ id: `empty-${z}-${xe}`, name: z, group: z, isPlaceholder: !0, type: "group-marker", index: E++ });
877
+ } else if (me && !Oe.some((z) => z in C) && !C.group)
878
+ Object.entries(C).forEach(([z, Te], Ne) => {
879
+ const $e = ie(Te, `${xe}-${Ne}`, "normal", _, G);
880
+ i.push({ ...$e, index: E++ });
881
+ });
882
+ else {
883
+ const z = ie(C, xe, "normal", _, G);
884
+ i.push({ ...z, index: E++ });
885
+ }
886
+ });
887
+ };
888
+ q(r);
889
+ const le = ne ? [...g, ...i] : [...i, ...g];
890
+ if (!K.current)
891
+ K.current = new Map(le.map((l, _) => [l.id, _]));
892
+ else {
893
+ let l = !1;
894
+ if (le.forEach((_) => {
895
+ K.current.has(_.id) || (l = !0);
896
+ }), l) {
897
+ const _ = /* @__PURE__ */ new Map();
898
+ le.forEach((G, ae) => {
899
+ _.set(G.id, ae);
900
+ }), K.current = _;
764
901
  }
765
- }), A.forEach((i, b) => {
766
- if (i.type === "item")
767
- _.push(i.data);
902
+ }
903
+ const ue = [...le].sort((l, _) => {
904
+ const G = K.current.get(l.id) ?? 999999, ae = K.current.get(_.id) ?? 999999;
905
+ return G - ae;
906
+ }), de = [], D = /* @__PURE__ */ new Set();
907
+ ue.forEach((l) => {
908
+ if (!l.group)
909
+ de.push({ type: "item", data: l });
910
+ else if (D.has(l.group) || (D.add(l.group), de.push({ type: "group", name: l.group })), !l.isPlaceholder && !l.isGroupMarker) {
911
+ const _ = t.get(l.group) || { items: [] };
912
+ t.has(l.group) || t.set(l.group, _), _.items.push(l);
913
+ }
914
+ });
915
+ const X = [];
916
+ return de.forEach((l) => {
917
+ if (l.type === "item")
918
+ X.push(l.data);
768
919
  else {
769
- const V = L.has(i.name);
770
- _.push({
771
- id: `group-header-${i.name}-${b}`,
772
- name: i.name,
773
- disabled: !1,
920
+ const _ = l.name, G = t.get(_), ae = A.has(_);
921
+ X.push({
922
+ id: `group-header-${_}`,
923
+ name: _,
924
+ disabled: !!G?.disabled,
774
925
  groupHeader: !0,
775
- expanded: V,
776
- type: "group"
926
+ expanded: ae,
927
+ type: "group",
928
+ hidden: !1
929
+ }), G?.items.forEach((C) => {
930
+ X.push({ ...C, hidden: !ae });
777
931
  });
778
- const Z = m.get(i.name);
779
- _.push(...Z);
780
932
  }
781
- }), H && D && _.push({
933
+ }), S && F && X.push({
782
934
  id: "special-load-more-id",
783
- name: d,
935
+ name: U,
784
936
  loadMore: !0,
785
- loading: d === I,
937
+ loading: U === M,
786
938
  type: "special"
787
- }), _;
788
- }, [t, n, z, Y, U, H, D, d, I, x, R, O]), re = T((r) => {
789
- if (r == null) return null;
790
- const l = C.find((a) => a.original === r || a.raw === r || a.userId === r);
791
- if (l) return l.id;
792
- if (typeof r == "object")
939
+ }), X;
940
+ }, [r, s, ee, ie, ne, S, F, U, M, Q, A, O]);
941
+ oe(() => {
942
+ if (A.size > 0) return;
943
+ const t = /* @__PURE__ */ new Set();
944
+ e.forEach((i) => {
945
+ i.groupHeader && !i.disabled && i.expanded !== !1 && t.add(i.name);
946
+ }), t.size > 0 && se(t);
947
+ }, [e]);
948
+ const f = N((t) => {
949
+ if (t == null) return null;
950
+ const i = e.find((g) => g.original === t || g.raw === t || g.userId === t);
951
+ if (i) return i.id;
952
+ if (typeof t == "object")
793
953
  try {
794
- const a = JSON.stringify(r);
795
- return C.find(
796
- (j) => j.original && typeof j.original == "object" && JSON.stringify(j.original) === a
954
+ const g = JSON.stringify(t);
955
+ return e.find(
956
+ (E) => E.original && typeof E.original == "object" && JSON.stringify(E.original) === g
797
957
  )?.id ?? null;
798
958
  } catch {
799
959
  return null;
800
960
  }
801
961
  return null;
802
- }, [C]);
803
- B(() => {
804
- const r = g ? o : s, l = C.find((j) => j.id === E);
805
- l && (l.original === r || l.raw === r || l.userId === r) || M(re(r));
806
- }, [o, s, g, C, re, E]);
807
- const oe = se(
808
- () => C.find((r) => r.id === E) ?? null,
809
- [E, C]
810
- ), K = T((r, l) => {
811
- if (r.groupHeader) {
812
- l?.stopPropagation(), l?.preventDefault(), q(r.name);
962
+ }, [e]);
963
+ oe(() => {
964
+ const t = x ? a : n, i = e.find((E) => E.id === y);
965
+ i && (i.original === t || i.raw === t || i.userId === t) || R(f(t));
966
+ }, [a, n, x, e, f, y]);
967
+ const w = pe(
968
+ () => e.find((t) => t.id === y) ?? null,
969
+ [y, e]
970
+ ), j = N((t, i) => {
971
+ if (t.groupHeader) {
972
+ i?.stopPropagation(), i?.preventDefault(), t.disabled || re(t.name);
813
973
  return;
814
974
  }
815
- if (r.disabled || r.loadMore) {
816
- l?.stopPropagation(), l?.preventDefault(), r.loadMore && (W(I), J());
975
+ if (t.disabled || t.loadMore) {
976
+ i?.stopPropagation(), i?.preventDefault(), t.loadMore && !t.loading && (u(M), B());
817
977
  return;
818
978
  }
819
- M(r.id), f?.(r.original, r.userId), S(!1);
820
- }, [f, S, J, I, W]), e = T(() => {
821
- M(null), f?.(null, null);
822
- }, [f]);
979
+ if (h) {
980
+ if (t.disabled || t.groupHeader || t.loadMore) {
981
+ i?.stopPropagation(), i?.preventDefault();
982
+ return;
983
+ }
984
+ i?.stopPropagation(), i?.preventDefault(), Y((g) => g.some((E) => E.id === t.id) ? g.filter((E) => E.id !== t.id) : [...g, t]);
985
+ return;
986
+ }
987
+ R(t.id), d?.(t.original, t.userId), W(!1);
988
+ }, [d, W, B, M, u, re]), Z = N(() => {
989
+ R(null), d?.(null, null);
990
+ }, [d]);
823
991
  return {
824
- normalizedOptions: C,
825
- selected: oe,
826
- selectOption: K,
827
- clear: e,
828
- hasOptions: C.length > 0,
829
- active: !v && !p && !c && C.length > 0,
830
- selectedValue: o ?? s,
831
- placeholder: h,
832
- emptyText: x,
833
- disabledText: P,
834
- loadingText: N,
835
- errorText: $,
836
- disabledOption: w,
837
- emptyOption: R,
838
- invalidOption: F,
992
+ normalizedOptions: e,
993
+ selected: w,
994
+ selectOption: j,
995
+ clear: Z,
996
+ hasOptions: e.length > 0,
997
+ active: !m && !v && !c && e.length > 0,
998
+ selectedValue: a ?? n,
999
+ placeholder: p,
1000
+ emptyText: I,
1001
+ disabledText: L,
1002
+ loadingText: k,
1003
+ errorText: P,
1004
+ disabledOption: T,
1005
+ emptyOption: O,
1006
+ invalidOption: H,
839
1007
  disabled: c,
840
- loading: p,
841
- error: v,
842
- expandedGroups: L,
843
- toggleGroup: q,
844
- visibleOptions: C.filter((r) => !r.hidden)
1008
+ loading: v,
1009
+ error: m,
1010
+ expandedGroups: A,
1011
+ toggleGroup: re,
1012
+ selectedIDs: J,
1013
+ multiple: h,
1014
+ setSelectedIds: Y
845
1015
  };
846
1016
  }
847
- function gr({ visibility: t, children: n, duration: o = 300 }) {
848
- const s = ce(null);
849
- return /* @__PURE__ */ u.jsx(
1017
+ function wr({ visibility: r, children: s, duration: a = 300 }) {
1018
+ const n = he(null);
1019
+ return /* @__PURE__ */ o.jsx(
850
1020
  ke,
851
1021
  {
852
- in: t,
1022
+ in: r,
853
1023
  timeout: 300,
854
1024
  classNames: "slideDown",
855
1025
  unmountOnExit: !0,
856
- nodeRef: s,
857
- onEnter: () => s.current.style.height = "0px",
858
- onEntering: () => s.current.style.height = s.current.scrollHeight + "px",
859
- onEntered: () => s.current.style.height = "auto",
860
- onExit: () => s.current.style.height = s.current.scrollHeight + "px",
861
- onExiting: () => s.current.style.height = "0px",
862
- children: /* @__PURE__ */ u.jsx(
1026
+ nodeRef: n,
1027
+ onEnter: () => n.current.style.height = "0px",
1028
+ onEntering: () => n.current.style.height = n.current.scrollHeight + "px",
1029
+ onEntered: () => n.current.style.height = "auto",
1030
+ onExit: () => n.current.style.height = n.current.scrollHeight + "px",
1031
+ onExiting: () => n.current.style.height = "0px",
1032
+ children: /* @__PURE__ */ o.jsx(
863
1033
  "div",
864
1034
  {
865
- ref: s,
1035
+ ref: n,
866
1036
  style: {
867
1037
  overflow: "hidden",
868
- transition: `height ${o}ms ease`,
1038
+ transition: `height ${a}ms ease`,
869
1039
  paddingLeft: "1em"
870
1040
  },
871
1041
  className: "slideDown-enter-done",
872
1042
  tabIndex: -1,
873
- children: n
1043
+ children: s
874
1044
  }
875
1045
  )
876
1046
  }
877
1047
  );
878
1048
  }
879
- const Le = (t, n) => {
880
- if (!t) return null;
881
- if (typeof t == "string") return /* @__PURE__ */ u.jsx("img", { src: t, ...n, alt: "" });
882
- if (er(t)) return rr(t, n);
883
- if (typeof t == "function" || typeof t == "object" && t.$$typeof) {
884
- const o = t;
885
- return /* @__PURE__ */ u.jsx(o, { ...n });
1049
+ const Pe = (r, s) => {
1050
+ if (!r) return null;
1051
+ if (typeof r == "string") return /* @__PURE__ */ o.jsx("img", { src: r, ...s, alt: "" });
1052
+ if (cr(r)) return ur(r, s);
1053
+ if (typeof r == "function" || typeof r == "object" && r.$$typeof) {
1054
+ const a = r;
1055
+ return /* @__PURE__ */ o.jsx(a, { ...s });
886
1056
  }
887
1057
  return null;
888
- }, pr = (t, n, o, s, f, c, p) => t.groupHeader ? "rac-select-option rac-group-option" : [
889
- "rac-select-option",
890
- t.className,
891
- s === t.id && "rac-selected",
892
- n === o && "rac-highlighted",
893
- (t.disabled || t.loading) && "rac-disabled-option",
894
- (t.invalid || t.name === p) && "rac-invalid-option",
895
- t.loadMore && f === c && "rac-loading-option",
896
- typeof t.raw == "boolean" && (t.raw ? "rac-true-option" : "rac-false-option")
897
- ].filter(Boolean).join(" "), mr = Qe(({
898
- unmount: t,
899
- children: n,
900
- renderedDropdown: o,
901
- visibility: s,
902
- ownBehavior: f = !1,
1058
+ }, Sr = (r, s, a, n, d, c, v, m) => {
1059
+ const h = m.some((p) => p.id === r.id);
1060
+ return r.groupHeader ? "rac-select-option rac-group-option" : [
1061
+ "rac-select-option",
1062
+ r.className,
1063
+ (h || n === r.id) && "rac-selected",
1064
+ s === a && "rac-highlighted",
1065
+ (r.disabled || r.loading) && "rac-disabled-option",
1066
+ (r.invalid || r.name === v) && "rac-invalid-option",
1067
+ r.loadMore && d === c && "rac-loading-option",
1068
+ typeof r.raw == "boolean" && (r.raw ? "rac-true-option" : "rac-false-option")
1069
+ ].filter(Boolean).join(" ");
1070
+ }, Tr = ar(({
1071
+ unmount: r,
1072
+ children: s,
1073
+ renderedDropdown: a,
1074
+ visibility: n,
1075
+ ownBehavior: d = !1,
903
1076
  alwaysOpen: c = !1,
904
- duration: p = 300,
905
- easing: v = "ease-out",
1077
+ duration: v = 300,
1078
+ easing: m = "ease-out",
906
1079
  offset: h = 2,
907
- animateOpacity: x = !0,
908
- style: P = {},
909
- className: N = "",
910
- ArrowIcon: $ = or,
911
- ClearIcon: w = ir,
912
- hasMore: R = !1,
913
- loadMore: F = () => {
1080
+ animateOpacity: p = !0,
1081
+ style: I = {},
1082
+ className: L = "",
1083
+ ArrowIcon: k = pr,
1084
+ ClearIcon: P = We,
1085
+ DelIcon: T = We,
1086
+ CheckIcon: O = Me,
1087
+ hasMore: H = !1,
1088
+ loadMore: W = () => {
914
1089
  console.warn("loadMore not implemented");
915
1090
  },
916
1091
  loadButton: S = !1,
917
- loadButtonText: H = "Load more",
918
- loadMoreText: D = "Loading",
919
- loadOffset: W = 100,
920
- loadAhead: d = 3,
921
- childrenFirst: I = !1,
922
- ...J
923
- }, U) => {
924
- const z = Re(), g = se(() => z.replace(/:/g, ""), [z]), [E, M] = ae([]), [O, Y] = ae(!1), [L, ee] = ae(S ? H : D), [q, C] = ae(!1), re = ce(null), oe = T((k) => {
925
- M((G) => {
926
- const X = G.findIndex((ne) => ne.id === k.id);
927
- if (X !== -1) {
928
- const ne = G[X];
929
- if (ne.label === k.label && ne.value === k.value && ne.disabled === k.disabled && ne.group === k.group)
930
- return G;
931
- const pe = [...G];
932
- return pe[X] = k, pe;
1092
+ loadButtonText: F = "Load more",
1093
+ loadMoreText: u = "Loading",
1094
+ loadOffset: U = 100,
1095
+ loadAhead: M = 3,
1096
+ childrenFirst: B = !1,
1097
+ groupsClosed: ne = !1,
1098
+ ...Q
1099
+ }, ee) => {
1100
+ const x = Le(), y = pe(() => x.replace(/:/g, ""), [x]), [R, J] = ge([]), [Y, A] = ge(!1), [se, K] = ge(S ? F : u), [re, ie] = ge(!1), e = he(null), f = N(($) => {
1101
+ J((V) => {
1102
+ const te = V.findIndex((ce) => ce.id === $.id);
1103
+ if (te !== -1) {
1104
+ const ce = V[te];
1105
+ if (ce.label === $.label && ce.value === $.value && ce.disabled === $.disabled && ce.group === $.group)
1106
+ return V;
1107
+ const ve = [...V];
1108
+ return ve[te] = $, ve;
933
1109
  }
934
- return [...G, k];
1110
+ return [...V, $];
935
1111
  });
936
- }, []), K = T((k) => {
937
- M((G) => {
938
- const X = G.filter((ne) => ne.id !== k);
939
- return X.length === G.length ? G : X;
1112
+ }, []), w = N(($) => {
1113
+ J((V) => {
1114
+ const te = V.filter((ce) => ce.id !== $);
1115
+ return te.length === V.length ? V : te;
940
1116
  });
941
- }, []), e = c ? !0 : f ? !!s : O, r = T((k) => {
942
- c || f || Y(k);
943
- }, [c, f]), l = fr({
944
- ...J,
945
- setVisibility: r,
946
- jsxOptions: E,
947
- hasMore: R,
1117
+ }, []), j = c ? !0 : d ? !!n : Y, Z = N(($) => {
1118
+ c || d || A($);
1119
+ }, [c, d]), t = jr({
1120
+ ...Q,
1121
+ setVisibility: Z,
1122
+ jsxOptions: R,
1123
+ hasMore: H,
948
1124
  loadButton: S,
949
- loadingTitle: L,
950
- loadMore: F,
951
- loadMoreText: D,
952
- setLoadingTitle: ee,
953
- childrenFirst: I
954
- }), { normalizedOptions: a, selected: j, selectOption: _, clear: m, hasOptions: A, active: i, selectedValue: b, disabled: V, loading: Z, error: ue, placeholder: te, invalidOption: le, emptyText: Q, disabledText: ge, loadingText: de, errorText: xe, expandedGroups: ve } = l, Ge = ur({ setLoadingTitle: ee, loadButton: S, loadButtonText: H, hasMore: R, loadMore: F, disabled: V, open: e, setOpen: r, options: a, selectOption: _, selected: j, loadOffset: W, loadAhead: d }), { handleListScroll: Ie, handleBlur: ze, handleFocus: Me, handleToggle: We, handleKeyDown: Je, highlightedIndex: fe, setHighlightedIndex: je } = Ge;
955
- Be(U, () => re.current), B(() => {
956
- e || C(!1);
957
- }, [e]), B(() => {
958
- (ue || V || Z || !A) && r(!1);
959
- }, [ue, V, Z, A, r]), B(() => {
960
- if (e && q && fe !== -1) {
961
- const k = a[fe];
962
- k && document.getElementById(`opt-${g}-${_e(k.id)}`)?.scrollIntoView({ block: "nearest" });
1125
+ loadingTitle: se,
1126
+ loadMore: W,
1127
+ loadMoreText: u,
1128
+ setLoadingTitle: K,
1129
+ childrenFirst: B,
1130
+ groupsClosed: ne
1131
+ }), { multiple: i, normalizedOptions: g, selected: E, selectOption: q, clear: le, hasOptions: ue, active: de, selectedValue: D, disabled: X, loading: l, error: _, placeholder: G, invalidOption: ae, emptyText: C, disabledText: Se, loadingText: xe, errorText: me, expandedGroups: Ee, selectedIDs: z, setSelectedIds: Te } = t, Ne = Er({ setLoadingTitle: K, loadButton: S, loadButtonText: F, hasMore: H, loadMore: W, disabled: X, multiple: i, open: j, setOpen: Z, options: g, selectOption: q, selected: E, loadOffset: U, loadAhead: M, expandedGroups: Ee }), { handleListScroll: $e, handleBlur: Be, handleFocus: Qe, handleToggle: er, handleKeyDown: rr, highlightedIndex: ye, setHighlightedIndex: Ae } = Ne;
1132
+ or(ee, () => e.current), oe(() => {
1133
+ j || ie(!1);
1134
+ }, [j]), oe(() => {
1135
+ (_ || X || l || !ue) && Z(!1);
1136
+ }, [_, X, l, ue, Z]), oe(() => {
1137
+ if (j && re && ye !== -1) {
1138
+ const $ = g[ye];
1139
+ $ && document.getElementById(`opt-${y}-${Je($.id)}`)?.scrollIntoView({ block: "nearest" });
963
1140
  }
964
- }, [fe, e, q, a, g]);
965
- const Se = se(() => b != null && !(Array.isArray(b) && b.length === 0) && !(typeof b == "object" && Object.keys(b).length === 0), [b]), Ue = se(() => {
966
- if (ue) return xe;
967
- if (Z) return de;
968
- if (V) return ge;
969
- if (j) return j.jsx ?? j.name;
970
- if (Se) {
971
- const k = a.find((G) => G.raw === b);
972
- return k ? k.name : typeof b == "object" && b !== null ? b.name ?? b.label ?? "Selected Object" : String(b);
1141
+ }, [ye, j, re, g, y]);
1142
+ const Ce = pe(() => D != null && !(Array.isArray(D) && D.length === 0) && !(typeof D == "object" && Object.keys(D).length === 0), [D]), tr = pe(() => {
1143
+ if (_) return me;
1144
+ if (l) return xe;
1145
+ if (X) return Se;
1146
+ if (E) return E.jsx ?? E.name;
1147
+ if (Ce) {
1148
+ const $ = g.find((V) => V.raw === D);
1149
+ return $ ? $.name : typeof D == "object" && D !== null ? D.name ?? D.label ?? "Selected Object" : String(D);
973
1150
  }
974
- return A ? te : Q;
975
- }, [V, Z, ue, A, j, b, te, xe, de, ge, Q, Se, a]), Xe = se(() => {
976
- const k = [];
977
- let G = [], X = null;
978
- const ne = a.reduce((y, ie) => (ie.group && (y[ie.group] = (y[ie.group] || 0) + 1), y), {}), pe = (y) => {
979
- y === null || G.length === 0 || (k.push(
980
- /* @__PURE__ */ u.jsx(
981
- gr,
1151
+ return ue ? G : C;
1152
+ }, [X, l, _, ue, E, D, G, me, xe, Se, C, Ce, g]), nr = pe(() => {
1153
+ const $ = [];
1154
+ let V = [], te = null;
1155
+ const ce = g.reduce((b, fe) => (fe.group && (b[fe.group] = (b[fe.group] || 0) + 1), b), {}), ve = (b) => {
1156
+ b === null || V.length === 0 || ($.push(
1157
+ /* @__PURE__ */ o.jsx(
1158
+ wr,
982
1159
  {
983
- visibility: ve.has(y),
984
- children: G
1160
+ visibility: Ee.has(b),
1161
+ children: V
985
1162
  },
986
- `slide-${y}`
1163
+ `slide-${b}`
987
1164
  )
988
- ), G = []);
989
- }, Ne = (y, ie) => /* @__PURE__ */ u.jsxs(
1165
+ ), V = []);
1166
+ }, He = (b, fe) => /* @__PURE__ */ o.jsxs(
990
1167
  "div",
991
1168
  {
992
- id: `opt-${g}-${_e(y.id)}`,
1169
+ id: `opt-${y}-${Je(b.id)}`,
993
1170
  role: "option",
994
- "aria-selected": j?.id === y.id,
995
- "aria-disabled": y.disabled || y.loading,
996
- className: pr(y, ie, fe, j?.id, L, D, le),
997
- onClick: (he) => !y.loading && _(y, he),
998
- onMouseEnter: () => !y.disabled && !y.loading && je(ie),
1171
+ "aria-selected": E?.id === b.id,
1172
+ "aria-disabled": b.disabled || b.loading,
1173
+ className: Sr(b, fe, ye, E?.id, se, u, ae, z),
1174
+ onClick: (be) => !b.loading && q(b, be),
1175
+ onMouseEnter: () => !b.disabled && !b.loading && Ae(fe),
999
1176
  children: [
1000
- y.jsx ?? y.name,
1001
- y.loading && /* @__PURE__ */ u.jsxs("span", { className: "rac-loading-dots", children: [
1002
- /* @__PURE__ */ u.jsx("i", {}),
1003
- /* @__PURE__ */ u.jsx("i", {}),
1004
- /* @__PURE__ */ u.jsx("i", {})
1005
- ] })
1177
+ b.jsx ?? b.name,
1178
+ b.loading && /* @__PURE__ */ o.jsxs("span", { className: "rac-loading-dots", children: [
1179
+ /* @__PURE__ */ o.jsx("i", {}),
1180
+ /* @__PURE__ */ o.jsx("i", {}),
1181
+ /* @__PURE__ */ o.jsx("i", {})
1182
+ ] }),
1183
+ i && !b.disabled ? /* @__PURE__ */ o.jsx("div", { className: "rac-checkbox", children: Pe(
1184
+ Me,
1185
+ {
1186
+ className: `
1187
+ rac-checkmark
1188
+ ${z.some((be) => be.id === b.id) ? "--checked" : ""}`
1189
+ }
1190
+ ) }) : null
1006
1191
  ]
1007
1192
  },
1008
- y.id
1193
+ b.id
1009
1194
  );
1010
- return a.forEach((y, ie) => {
1011
- const he = y.groupHeader, Ae = !!y.group;
1012
- if ((he || !Ae && X !== null) && (pe(X), he || (X = null)), he) {
1013
- X = y.name;
1014
- const qe = ve.has(y.name), Ke = ne[y.name] > 0;
1015
- k.push(
1016
- /* @__PURE__ */ u.jsxs(
1195
+ return g.forEach((b, fe) => {
1196
+ const be = b.groupHeader, Fe = !!b.group;
1197
+ if ((be || !Fe && te !== null) && (ve(te), be || (te = null)), be) {
1198
+ te = b.name;
1199
+ const sr = Ee.has(b.name), ir = ce[b.name] > 0;
1200
+ $.push(
1201
+ /* @__PURE__ */ o.jsxs(
1017
1202
  "div",
1018
1203
  {
1019
- className: "rac-group-header",
1020
- onClick: (Ze) => _(y, Ze),
1204
+ className: [
1205
+ "rac-group-header",
1206
+ b.disabled && "rac-disabled-group"
1207
+ ].filter(Boolean).join(" "),
1208
+ onClick: (lr) => q(b, lr),
1021
1209
  children: [
1022
- /* @__PURE__ */ u.jsx("span", { className: "rac-group-title-text", children: y.name }),
1023
- /* @__PURE__ */ u.jsx(
1024
- Ee,
1210
+ /* @__PURE__ */ o.jsx("span", { className: "rac-group-title-text", children: b.name }),
1211
+ /* @__PURE__ */ o.jsx(
1212
+ Re,
1025
1213
  {
1026
- visibility: Ke,
1027
- duration: p,
1214
+ visibility: ir && !b.disabled,
1215
+ duration: v,
1028
1216
  style: { display: "grid" },
1029
- children: /* @__PURE__ */ u.jsx("span", { className: `rac-group-arrow-wrapper ${qe ? "--open" : ""}`, children: Le($, { className: "rac-select-arrow-wrapper" }) })
1217
+ children: /* @__PURE__ */ o.jsx("span", { className: `rac-group-arrow-wrapper ${sr ? "--open" : ""}`, children: Pe(k, { className: "rac-select-arrow-wrapper" }) })
1030
1218
  }
1031
1219
  )
1032
1220
  ]
1033
1221
  },
1034
- y.id
1222
+ b.id
1035
1223
  )
1036
1224
  );
1037
- } else Ae ? G.push(Ne(y, ie)) : k.push(Ne(y, ie));
1038
- }), pe(X), k;
1225
+ } else Fe ? V.push(He(b, fe)) : $.push(He(b, fe));
1226
+ }), ve(te), $;
1039
1227
  }, [
1040
- a,
1041
- _,
1042
1228
  g,
1043
- j,
1044
- fe,
1045
- L,
1046
- D,
1047
- le,
1048
- je,
1049
- ve,
1050
- $
1229
+ q,
1230
+ y,
1231
+ E,
1232
+ ye,
1233
+ se,
1234
+ u,
1235
+ ae,
1236
+ Ae,
1237
+ Ee,
1238
+ k
1051
1239
  ]);
1052
- return /* @__PURE__ */ u.jsx(
1053
- cr,
1240
+ return /* @__PURE__ */ o.jsx(
1241
+ mr,
1054
1242
  {
1055
- selectRef: re,
1056
- selectId: g,
1057
- renderIcon: Le,
1058
- normalizedOptions: a,
1059
- renderOptions: Xe,
1060
- selected: j,
1061
- title: Ue,
1062
- visibility: e,
1063
- active: i,
1064
- hasOptions: A,
1065
- hasActualValue: Se,
1066
- highlightedIndex: fe,
1067
- animationFinished: q,
1068
- disabled: V,
1069
- loading: Z,
1070
- error: ue,
1071
- setVisibility: r,
1072
- setHighlightedIndex: je,
1073
- setAnimationFinished: C,
1074
- handleBlur: ze,
1075
- handleFocus: Me,
1076
- handleToggle: We,
1077
- handleKeyDown: Je,
1078
- handleListScroll: Ie,
1079
- selectOption: _,
1080
- clear: m,
1081
- registerOption: oe,
1082
- unregisterOption: K,
1083
- children: n,
1084
- renderedDropdown: o,
1085
- placeholder: te,
1086
- className: N,
1087
- style: P,
1088
- duration: p,
1089
- easing: v,
1243
+ selectRef: e,
1244
+ selectId: y,
1245
+ selectedIDs: z,
1246
+ setSelectedIds: Te,
1247
+ multiple: i,
1248
+ renderIcon: Pe,
1249
+ normalizedOptions: g,
1250
+ renderOptions: nr,
1251
+ selected: E,
1252
+ title: tr,
1253
+ visibility: j,
1254
+ active: de,
1255
+ hasOptions: ue,
1256
+ hasActualValue: Ce,
1257
+ highlightedIndex: ye,
1258
+ animationFinished: re,
1259
+ disabled: X,
1260
+ loading: l,
1261
+ error: _,
1262
+ setVisibility: Z,
1263
+ setHighlightedIndex: Ae,
1264
+ setAnimationFinished: ie,
1265
+ handleBlur: Be,
1266
+ handleFocus: Qe,
1267
+ handleToggle: er,
1268
+ handleKeyDown: rr,
1269
+ handleListScroll: $e,
1270
+ selectOption: q,
1271
+ clear: le,
1272
+ registerOption: f,
1273
+ unregisterOption: w,
1274
+ children: s,
1275
+ renderedDropdown: a,
1276
+ placeholder: G,
1277
+ className: L,
1278
+ style: I,
1279
+ duration: v,
1280
+ easing: m,
1090
1281
  offset: h,
1091
- animateOpacity: x,
1092
- unmount: t,
1093
- ArrowIcon: $,
1094
- ClearIcon: w,
1095
- hasMore: R,
1282
+ animateOpacity: p,
1283
+ unmount: r,
1284
+ ArrowIcon: k,
1285
+ ClearIcon: P,
1286
+ DelIcon: T,
1287
+ hasMore: H,
1096
1288
  loadButton: S
1097
1289
  }
1098
1290
  );
1099
- }), Ve = He(null);
1100
- function xr({ children: t, name: n, label: o, value: s, id: f, emptyGroupText: c = "Empty group" }) {
1101
- const p = we(Te), v = se(() => {
1102
- const x = n ?? o ?? s ?? f;
1103
- return x != null && x !== "" ? String(x) : c;
1104
- }, [n, o, s, f, c]), h = se(() => `group-marker-${_e(v)}`, [v]);
1105
- return B(() => {
1106
- if (!p) return;
1107
- const x = {
1108
- id: h,
1109
- group: v,
1110
- isGroupMarker: !0,
1111
- disabled: !0
1112
- };
1113
- return p.registerOption(x), () => p.unregisterOption(h);
1114
- }, [p.registerOption, p.unregisterOption, h, v]), /* @__PURE__ */ u.jsx(Ve.Provider, { value: v, children: t });
1115
- }
1116
- const $e = (t) => t ? typeof t == "string" || typeof t == "number" ? String(t) : Array.isArray(t) ? t.map($e).join(" ").replace(/\s+/g, " ").trim() : Fe.isValidElement(t) ? $e(t.props.children) : "" : "";
1117
- function yr({ value: t, id: n, className: o, children: s, disabled: f, group: c }) {
1118
- const p = we(Te), v = we(Ve), h = p?.registerOption, x = p?.unregisterOption, P = Re(), N = se(() => n ? String(n) : P.replace(/:/g, ""), [n, P]);
1119
- return B(() => {
1291
+ }), _r = Ke(null), De = (r) => r ? typeof r == "string" || typeof r == "number" ? String(r) : Array.isArray(r) ? r.map(De).join(" ").replace(/\s+/g, " ").trim() : Xe.isValidElement(r) ? De(r.props.children) : "" : "";
1292
+ function Nr({ value: r, id: s, className: a, children: n, disabled: d, group: c }) {
1293
+ const v = Ye(Ze), m = Ye(_r), h = v?.registerOption, p = v?.unregisterOption, I = Le(), L = pe(() => s ? String(s) : I.replace(/:/g, ""), [s, I]);
1294
+ return oe(() => {
1120
1295
  if (!h) return;
1121
- const $ = $e(s);
1122
- let w = "";
1123
- return typeof s == "string" && s !== "" ? w = s : $ ? w = $ : t != null && (w = String(t)), h({
1124
- id: N,
1125
- value: t !== void 0 ? t : $,
1126
- label: w,
1127
- jsx: s,
1128
- className: o,
1129
- disabled: !!f,
1130
- group: c || v || null
1131
- }), () => x(N);
1132
- }, [N, t, s, o, f, c, v, h, x]), null;
1296
+ const k = De(n), P = n != null;
1297
+ let T = "";
1298
+ return k ? T = k : s != null && s !== "" ? T = String(s) : r != null && r !== "" && (T = String(r)), h({
1299
+ id: L,
1300
+ value: r !== void 0 ? r : k,
1301
+ label: T,
1302
+ jsx: n,
1303
+ hasJsx: P,
1304
+ className: a,
1305
+ disabled: !!d,
1306
+ group: c || m || null
1307
+ }), () => p(L);
1308
+ }, [L, r, n, a, d, c, m, h, p]), null;
1133
1309
  }
1134
1310
  export {
1135
- xr as OptGroup,
1136
- yr as Option,
1137
- mr as Select
1311
+ Nr as Option,
1312
+ Tr as Select
1138
1313
  };