ics-ui-kit 0.1.0-alpha.74 → 0.1.0-alpha.76

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.
@@ -1,14 +1,14 @@
1
- import { jsx as e, jsxs as D, Fragment as B } from "react/jsx-runtime";
2
- import M, { useState as L, useCallback as x, useEffect as E, forwardRef as Z, useMemo as P, useRef as q } from "react";
3
- import { T as F } from "../index-BVqs-uqP.js";
4
- import { u as H, S as fe } from "../SearchSelectTag-DFCX9zT1.js";
5
- import { b as Se, g as ee, C as re, c as te, e as ge, i as ve } from "../Command-BhbfL5wm.js";
6
- import { I as K } from "../Icon-DH3ev9GK.js";
7
- import { b as ye, P as j, a as _ } from "../Popover-Dvr7y0YY.js";
8
- import { m as be, s as Ce } from "../Select-d1VUmFM3.js";
1
+ import { jsx as e, jsxs as D, Fragment as q } from "react/jsx-runtime";
2
+ import F, { useState as w, useCallback as x, useEffect as A, forwardRef as ee, useMemo as M, useRef as H } from "react";
3
+ import { T as Q } from "../index-BVqs-uqP.js";
4
+ import { u as K, S as fe } from "../SearchSelectTag-DFCX9zT1.js";
5
+ import { b as Se, g as re, C as te, c as ne, e as ge, i as ve } from "../Command-BhbfL5wm.js";
6
+ import { I as j } from "../Icon-DH3ev9GK.js";
7
+ import { b as ye, P as _, a as $ } from "../Popover-Dvr7y0YY.js";
8
+ import { m as Ce, s as be } from "../Select-DRwv6-eZ.js";
9
9
  import { C as Ne } from "../chevron-down-CAOItu8X.js";
10
- import { C as ne } from "../check-CeyaOoZv.js";
11
- import { L as ae } from "../Loader-BpHiL6W-.js";
10
+ import { C as ae } from "../check-CeyaOoZv.js";
11
+ import { L as se } from "../Loader-BpHiL6W-.js";
12
12
  import { u as Oe } from "../useDebounce-BRah78CF.js";
13
13
  import { E as xe } from "../EmptyState-DRKjscH-.js";
14
14
  import { E as Ie } from "../ErrorState-B26k67-z.js";
@@ -21,220 +21,220 @@ const Te = ({
21
21
  onChange: a,
22
22
  valueOption: s
23
23
  }) => {
24
- const [l, o] = L(void 0), f = x(
25
- (u) => {
26
- if (u !== void 0) {
27
- const h = r.find((S) => S.value === u) || l;
28
- h && h.value === u && (o(h), a?.(u, h));
24
+ const [l, c] = w(void 0), f = x(
25
+ (d) => {
26
+ if (d !== void 0) {
27
+ const u = r.find((S) => S.value === d) || l;
28
+ u && u.value === d && (c(u), a?.(d, u));
29
29
  }
30
30
  },
31
31
  [a, r, l]
32
- ), [c, m] = H({
32
+ ), [o, h] = K({
33
33
  value: t,
34
34
  defaultValue: n,
35
35
  onChange: f
36
36
  });
37
- E(() => {
38
- if (c !== void 0) {
39
- if (l && l.value === c)
37
+ A(() => {
38
+ if (o !== void 0) {
39
+ if (l && l.value === o)
40
40
  return;
41
- const u = r.find((h) => h.value === c);
42
- u ? o(u) : s && s.value === c && o(s);
41
+ const d = r.find((u) => u.value === o);
42
+ d ? c(d) : s && s.value === o && c(s);
43
43
  } else
44
- o(void 0);
45
- }, [c, r, l, s]);
46
- const d = x(
47
- (u) => {
48
- const h = r.find((S) => S.label === u);
49
- h && m(h.value);
44
+ c(void 0);
45
+ }, [o, r, l, s]);
46
+ const i = x(
47
+ (d) => {
48
+ const u = r.find((S) => S.label === d);
49
+ u && h(u.value);
50
50
  },
51
- [m, r]
51
+ [h, r]
52
52
  );
53
53
  return {
54
- selectedValue: c,
54
+ selectedValue: o,
55
55
  selectedOption: l,
56
- setSelectedByLabel: d,
57
- setSelectedValue: m
56
+ setSelectedByLabel: i,
57
+ setSelectedValue: h
58
58
  };
59
- }, De = F({
59
+ }, De = Q({
60
60
  base: "self-center pl-1.5"
61
- }), se = ({ children: r, className: t }) => /* @__PURE__ */ e("span", { className: De({ className: t }), children: r }), Re = F({
61
+ }), le = ({ children: r, className: t }) => /* @__PURE__ */ e("span", { className: De({ className: t }), children: r }), Re = Q({
62
62
  base: "pointer-events-none self-center pl-1.5 text-muted"
63
- }), Ve = ({ children: r, className: t }) => /* @__PURE__ */ e("span", { className: Re({ className: t }), children: r }), Pe = F({
64
- extend: Ce,
63
+ }), Ve = ({ children: r, className: t }) => /* @__PURE__ */ e("span", { className: Re({ className: t }), children: r }), Pe = Q({
64
+ extend: be,
65
65
  base: "group/search-select-trigger min-h-10 items-start py-[0.3125rem] pl-1.5 pr-3 lg:min-h-9 lg:py-[0.3125rem] lg:pl-1.5 lg:pr-2.5",
66
66
  slots: {
67
67
  buttonWrapper: "ml-auto flex gap-2.5 pl-2.5",
68
68
  iconWrapper: "min-h-7 lg:min-h-6",
69
69
  startIcon: "flex min-h-7 items-center pl-1.5 pr-0.5 text-muted lg:min-h-6",
70
- clearButton: "h-auto p-0"
70
+ clearButton: "h-auto p-0 opacity-0 group-hover/search-select-trigger:opacity-100 group-focus-visible/search-select-trigger:opacity-100"
71
71
  }
72
- }), W = M.forwardRef(
73
- ({ className: r, children: t, disabled: n, open: a, invalid: s, placeholder: l, startIcon: o, onClear: f, ...c }, m) => {
74
- const d = Pe({ disabled: n, invalid: s });
72
+ }), k = F.forwardRef(
73
+ ({ className: r, children: t, disabled: n, open: a, invalid: s, placeholder: l, startIcon: c, onClear: f, ...o }, h) => {
74
+ const i = Pe({ disabled: n, invalid: s });
75
75
  return /* @__PURE__ */ D(
76
76
  "button",
77
77
  {
78
- ...c,
78
+ ...o,
79
79
  disabled: n,
80
- className: d.base({ className: r }),
81
- ref: m,
80
+ className: i.base({ className: r }),
81
+ ref: h,
82
82
  role: "combobox",
83
83
  "aria-expanded": a,
84
84
  "aria-invalid": s,
85
85
  "aria-haspopup": "listbox",
86
86
  children: [
87
- o && /* @__PURE__ */ e("div", { className: d.startIcon(), children: o }),
87
+ c && /* @__PURE__ */ e("div", { className: i.startIcon(), children: c }),
88
88
  t !== void 0 ? t : /* @__PURE__ */ e(Ve, { children: l }),
89
- /* @__PURE__ */ D("div", { className: d.buttonWrapper(), children: [
90
- f && /* @__PURE__ */ e("div", { className: d.iconWrapper(), children: /* @__PURE__ */ e(be, { onClear: f, className: d.clearButton() }) }),
91
- !n && /* @__PURE__ */ e("div", { className: d.iconWrapper(), children: /* @__PURE__ */ e(K, { icon: Ne, className: d.icon() }) })
89
+ /* @__PURE__ */ D("div", { className: i.buttonWrapper(), children: [
90
+ f && /* @__PURE__ */ e("div", { className: i.iconWrapper(), children: /* @__PURE__ */ e(Ce, { onClear: f, className: i.clearButton() }) }),
91
+ !n && /* @__PURE__ */ e("div", { className: i.iconWrapper(), children: /* @__PURE__ */ e(j, { icon: Ne, className: i.icon() }) })
92
92
  ] })
93
93
  ]
94
94
  }
95
95
  );
96
96
  }
97
97
  );
98
- W.displayName = "SearchSelectTrigger";
99
- const Me = F({
98
+ k.displayName = "SearchSelectTrigger";
99
+ const Me = Q({
100
100
  base: "w-full min-w-[var(--radix-popper-anchor-width)] border-secondary-border p-0"
101
- }), k = M.forwardRef(
101
+ }), z = F.forwardRef(
102
102
  ({ className: r, children: t, ...n }, a) => /* @__PURE__ */ e(ye, { ref: a, className: Me({ className: r }), align: "start", ...n, children: t })
103
103
  );
104
- k.displayName = "SearchSelectContent";
105
- const $ = M.forwardRef(({ placeholder: r = "Find", ...t }, n) => /* @__PURE__ */ e(Se, { ref: n, placeholder: r, ...t }));
106
- $.displayName = "SearchSelectInput";
107
- const Ee = F({ base: "" }), le = Z(
104
+ z.displayName = "SearchSelectContent";
105
+ const G = F.forwardRef(({ placeholder: r = "Find", ...t }, n) => /* @__PURE__ */ e(Se, { ref: n, placeholder: r, ...t }));
106
+ G.displayName = "SearchSelectInput";
107
+ const Ee = Q({ base: "" }), oe = ee(
108
108
  (r, t) => {
109
109
  const {
110
110
  id: n,
111
111
  className: a,
112
112
  options: s,
113
113
  valueOption: l,
114
- renderOption: o,
114
+ renderOption: c,
115
115
  placeholder: f = "Выберите значение",
116
- value: c,
117
- defaultValue: m,
118
- onBlur: d,
119
- onChange: u,
120
- onClear: h,
116
+ value: o,
117
+ defaultValue: h,
118
+ onBlur: i,
119
+ onChange: d,
120
+ onClear: u,
121
121
  disabled: S,
122
122
  invalid: b,
123
- searchPlaceholder: g = "Найти",
124
- emptyText: i = "Результатов не найдено",
125
- shouldFilter: N = !0,
126
- footerContent: v,
127
- onSearchChange: p,
128
- onOpenChange: w,
123
+ searchPlaceholder: v = "Найти",
124
+ emptyText: g = "Результатов не найдено",
125
+ shouldFilter: p = !0,
126
+ footerContent: m,
127
+ onSearchChange: y,
128
+ onOpenChange: I,
129
129
  startIcon: R,
130
- hideSearch: I,
130
+ hideSearch: L,
131
131
  ...V
132
- } = r, [y, T] = L(!1), [C, A] = L(""), { selectedValue: G, selectedOption: Q, setSelectedByLabel: J } = Te({
132
+ } = r, [P, C] = w(!1), [T, N] = w(""), { selectedValue: E, selectedOption: W, setSelectedByLabel: J } = Te({
133
133
  options: s,
134
- value: c,
135
- defaultValue: m,
134
+ value: o,
135
+ defaultValue: h,
136
136
  valueOption: l,
137
- onChange: u
137
+ onChange: d
138
138
  }), U = x(
139
139
  (O) => {
140
- J(O), T(!1);
140
+ J(O), C(!1);
141
141
  },
142
- [J, T]
143
- ), ie = x(
142
+ [J, C]
143
+ ), de = x(
144
144
  (O) => {
145
- A(O), p?.(O);
145
+ N(O), y?.(O);
146
146
  },
147
- [p]
148
- ), de = x(
147
+ [y]
148
+ ), ue = x(
149
149
  (O) => {
150
- T(O), w?.(O);
150
+ C(O), I?.(O);
151
151
  },
152
- [w]
153
- ), ue = P(() => {
154
- if (Q) {
155
- if (o) {
156
- const O = o({ option: Q, type: "trigger" });
152
+ [I]
153
+ ), X = M(() => {
154
+ if (W) {
155
+ if (c) {
156
+ const O = c({ option: W, type: "trigger" });
157
157
  if (O !== void 0)
158
158
  return O;
159
159
  }
160
- return /* @__PURE__ */ e(se, { children: Q.label });
160
+ return /* @__PURE__ */ e(le, { children: W.label });
161
161
  }
162
- }, [Q, o]), he = P(() => s.map((O, me) => {
163
- const z = O.disabled ?? !1, X = G === O.value, pe = () => {
164
- if (o) {
165
- const Y = o({
162
+ }, [W, c]), he = M(() => s.map((O, pe) => {
163
+ const B = O.disabled ?? !1, Y = E === O.value, me = () => {
164
+ if (c) {
165
+ const Z = c({
166
166
  option: O,
167
167
  type: "list",
168
- isSelected: X,
169
- isDisabled: z,
170
- searchQuery: C,
171
- index: me
168
+ isSelected: Y,
169
+ isDisabled: B,
170
+ searchQuery: T,
171
+ index: pe
172
172
  });
173
- if (Y !== void 0)
174
- return Y;
173
+ if (Z !== void 0)
174
+ return Z;
175
175
  }
176
- return /* @__PURE__ */ D(B, { children: [
176
+ return /* @__PURE__ */ D(q, { children: [
177
177
  O.label,
178
- X && /* @__PURE__ */ e(K, { icon: ne, className: "ml-auto" })
178
+ Y && /* @__PURE__ */ e(j, { icon: ae, className: "ml-auto" })
179
179
  ] });
180
180
  };
181
181
  return /* @__PURE__ */ e(
182
- ee,
182
+ re,
183
183
  {
184
184
  value: O.label,
185
- onSelect: z ? void 0 : U,
186
- disabled: z,
187
- children: pe()
185
+ onSelect: B ? void 0 : U,
186
+ disabled: B,
187
+ children: me()
188
188
  },
189
189
  O.value
190
190
  );
191
- }), [s, G, U, o, C]);
192
- return /* @__PURE__ */ e(j, { ...V, open: y, onOpenChange: de, children: /* @__PURE__ */ D("div", { className: Ee({ className: a }), children: [
193
- /* @__PURE__ */ e(_, { asChild: !0, children: /* @__PURE__ */ e(
194
- W,
191
+ }), [s, E, U, c, T]);
192
+ return /* @__PURE__ */ e(_, { ...V, open: P, onOpenChange: ue, children: /* @__PURE__ */ D("div", { className: Ee({ className: a }), children: [
193
+ /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(
194
+ k,
195
195
  {
196
- onClear: h,
196
+ onClear: X ? u : void 0,
197
197
  disabled: S,
198
198
  invalid: b,
199
- open: y,
199
+ open: P,
200
200
  placeholder: f,
201
201
  id: n,
202
- onBlur: d,
202
+ onBlur: i,
203
203
  ref: t,
204
204
  startIcon: R,
205
- children: ue
205
+ children: X
206
206
  }
207
207
  ) }),
208
- /* @__PURE__ */ e(k, { children: /* @__PURE__ */ D(re, { shouldFilter: N, children: [
209
- !I && /* @__PURE__ */ e($, { placeholder: g, onValueChange: ie }),
210
- /* @__PURE__ */ D(te, { className: "p-1", children: [
208
+ /* @__PURE__ */ e(z, { children: /* @__PURE__ */ D(te, { shouldFilter: p, children: [
209
+ !L && /* @__PURE__ */ e(G, { placeholder: v, onValueChange: de }),
210
+ /* @__PURE__ */ D(ne, { className: "p-1", children: [
211
211
  he,
212
- /* @__PURE__ */ e(ge, { children: i }),
213
- v
214
- ] }, `list-${C}`)
212
+ /* @__PURE__ */ e(ge, { children: g }),
213
+ m
214
+ ] }, `list-${T}`)
215
215
  ] }) })
216
216
  ] }) });
217
217
  }
218
218
  );
219
- le.displayName = "SearchSelect";
220
- const Fe = F({
219
+ oe.displayName = "SearchSelect";
220
+ const Fe = Q({
221
221
  base: "py-2 text-center text-sm text-muted-foreground"
222
- }), ce = M.forwardRef(
222
+ }), ce = F.forwardRef(
223
223
  ({ onLoad: r, hasMore: t, loadingText: n = "Загрузка...", className: a }, s) => {
224
- const l = q(null), o = Fe({ className: a });
225
- return M.useImperativeHandle(s, () => l.current), E(() => {
224
+ const l = H(null), c = Fe({ className: a });
225
+ return F.useImperativeHandle(s, () => l.current), A(() => {
226
226
  const f = l.current;
227
227
  if (!f || !t) return;
228
- const c = new IntersectionObserver(
229
- ([m]) => {
230
- m.isIntersecting && r();
228
+ const o = new IntersectionObserver(
229
+ ([h]) => {
230
+ h.isIntersecting && r();
231
231
  },
232
232
  { rootMargin: "50px" }
233
233
  );
234
- return c.observe(f), () => {
235
- c.disconnect();
234
+ return o.observe(f), () => {
235
+ o.disconnect();
236
236
  };
237
- }, [r, t]), t ? /* @__PURE__ */ e("div", { ref: l, className: o, children: /* @__PURE__ */ e(ae, { className: "flex-row", children: n }) }) : null;
237
+ }, [r, t]), t ? /* @__PURE__ */ e("div", { ref: l, className: c, children: /* @__PURE__ */ e(se, { className: "flex-row", children: n }) }) : null;
238
238
  }
239
239
  );
240
240
  ce.displayName = "LoadMoreTrigger";
@@ -247,87 +247,87 @@ const Ae = (r, t) => {
247
247
  for (let l = 0; l < n.length && s < a.length; l++)
248
248
  n[l] === a[s] && s++;
249
249
  return s === a.length ? 1 : 0;
250
- }, Qe = Z(
250
+ }, Qe = ee(
251
251
  (r, t) => {
252
252
  const {
253
253
  options: n,
254
254
  pageSize: a = 50,
255
255
  filter: s = Ae,
256
256
  defaultValue: l,
257
- value: o,
257
+ value: c,
258
258
  ...f
259
- } = r, [c, m] = L(a), [d, u] = L(""), [h, S] = L(void 0);
260
- E(() => m(a), [d, a]), E(() => {
261
- const p = o || l;
262
- p && !h && S(n.find((w) => w.value === p));
263
- }, [l, o, n, h]);
264
- const { visibleOptions: b, hasMoreItems: g } = P(() => {
265
- const p = d ? n.map((I) => ({
266
- option: I,
267
- score: s(I.label, d)
268
- })).filter(({ score: I }) => I > 0).sort((I, V) => V.score - I.score).map(({ option: I }) => I) : n, w = p.slice(0, c), R = c < p.length;
259
+ } = r, [o, h] = w(a), [i, d] = w(""), [u, S] = w(void 0);
260
+ A(() => h(a), [i, a]), A(() => {
261
+ const y = c || l;
262
+ y && !u && S(n.find((I) => I.value === y));
263
+ }, [l, c, n, u]);
264
+ const { visibleOptions: b, hasMoreItems: v } = M(() => {
265
+ const y = i ? n.map((L) => ({
266
+ option: L,
267
+ score: s(L.label, i)
268
+ })).filter(({ score: L }) => L > 0).sort((L, V) => V.score - L.score).map(({ option: L }) => L) : n, I = y.slice(0, o), R = o < y.length;
269
269
  return {
270
- visibleOptions: w,
270
+ visibleOptions: I,
271
271
  hasMoreItems: R
272
272
  };
273
- }, [n, d, c, s]), i = x(() => {
274
- m((p) => p + a);
275
- }, [a]), N = x((p) => {
276
- u(p);
277
- }, []), v = x(
278
- (p) => {
279
- p && d && u("");
273
+ }, [n, i, o, s]), g = x(() => {
274
+ h((y) => y + a);
275
+ }, [a]), p = x((y) => {
276
+ d(y);
277
+ }, []), m = x(
278
+ (y) => {
279
+ y && i && d("");
280
280
  },
281
- [d, u]
281
+ [i, d]
282
282
  );
283
283
  return /* @__PURE__ */ e(
284
- le,
284
+ oe,
285
285
  {
286
286
  ...f,
287
287
  ref: t,
288
288
  options: b,
289
- value: o,
289
+ value: c,
290
290
  defaultValue: l,
291
- valueOption: h,
291
+ valueOption: u,
292
292
  shouldFilter: !1,
293
- footerContent: /* @__PURE__ */ e(ce, { onLoad: i, hasMore: g }),
294
- onSearchChange: N,
295
- onOpenChange: v
293
+ footerContent: /* @__PURE__ */ e(ce, { onLoad: g, hasMore: v }),
294
+ onSearchChange: p,
295
+ onOpenChange: m
296
296
  }
297
297
  );
298
298
  }
299
299
  );
300
300
  Qe.displayName = "LazySearchSelect";
301
- const We = M.forwardRef((r, t) => /* @__PURE__ */ e(ve, { ref: t, ...r }));
301
+ const We = F.forwardRef((r, t) => /* @__PURE__ */ e(ve, { ref: t, ...r }));
302
302
  We.displayName = "SearchSelectSeparator";
303
303
  const ke = ({ loadOptions: r }) => {
304
- const [t, n] = L([]), [a, s] = L("idle"), [l, o] = L(null), f = q(null), c = q(0), m = x(() => {
304
+ const [t, n] = w([]), [a, s] = w("idle"), [l, c] = w(null), f = H(null), o = H(0), h = x(() => {
305
305
  f.current && f.current.abort();
306
- }, []), d = x(
307
- async (u) => {
308
- m();
309
- const h = ++c.current, S = new AbortController();
310
- f.current = S, s("loading"), o(null);
306
+ }, []), i = x(
307
+ async (d) => {
308
+ h();
309
+ const u = ++o.current, S = new AbortController();
310
+ f.current = S, s("loading"), c(null);
311
311
  try {
312
312
  const b = await r({
313
- searchQuery: u,
313
+ searchQuery: d,
314
314
  signal: S.signal
315
315
  });
316
- if (h !== c.current) return;
316
+ if (u !== o.current) return;
317
317
  n(b.options), s("success");
318
318
  } catch (b) {
319
- if (b instanceof Error && b.name === "AbortError" || h !== c.current) return;
320
- o(b instanceof Error ? b.message : "Неизвестная ошибка"), s("error");
319
+ if (b instanceof Error && b.name === "AbortError" || u !== o.current) return;
320
+ c(b instanceof Error ? b.message : "Неизвестная ошибка"), s("error");
321
321
  }
322
322
  },
323
- [r, m]
323
+ [r, h]
324
324
  );
325
- return E(() => () => m(), [m]), {
325
+ return A(() => () => h(), [h]), {
326
326
  options: t,
327
327
  loadingState: a,
328
328
  error: l,
329
- loadData: d,
330
- cancelRequests: m
329
+ loadData: i,
330
+ cancelRequests: h
331
331
  };
332
332
  }, ze = ({
333
333
  options: r,
@@ -336,107 +336,107 @@ const ke = ({ loadOptions: r }) => {
336
336
  isSelected: a,
337
337
  searchQuery: s,
338
338
  loadMode: l,
339
- minInputLength: o,
339
+ minInputLength: c,
340
340
  onSelect: f,
341
- renderOption: c,
342
- loadingText: m,
343
- errorText: d,
344
- inputHintText: u,
345
- emptyText: h
341
+ renderOption: o,
342
+ loadingText: h,
343
+ errorText: i,
344
+ inputHintText: d,
345
+ emptyText: u
346
346
  }) => {
347
- const S = P(() => r.map((g, i) => ({
348
- option: g,
349
- index: i,
350
- isSelected: a?.(g) ?? !1,
351
- isDisabled: g.disabled ?? !1
347
+ const S = M(() => r.map((v, g) => ({
348
+ option: v,
349
+ index: g,
350
+ isSelected: a?.(v) ?? !1,
351
+ isDisabled: v.disabled ?? !1
352
352
  })), [r, a]), b = x(
353
353
  ({
354
- option: g,
355
- isSelected: i,
356
- isDisabled: N,
357
- index: v
354
+ option: v,
355
+ isSelected: g,
356
+ isDisabled: p,
357
+ index: m
358
358
  }) => {
359
- if (c) {
360
- const p = c({
361
- option: g,
359
+ if (o) {
360
+ const y = o({
361
+ option: v,
362
362
  type: "list",
363
- isSelected: i,
364
- isDisabled: N,
363
+ isSelected: g,
364
+ isDisabled: p,
365
365
  searchQuery: s,
366
- index: v
366
+ index: m
367
367
  });
368
- if (p !== void 0)
369
- return p;
368
+ if (y !== void 0)
369
+ return y;
370
370
  }
371
- return /* @__PURE__ */ D(B, { children: [
372
- g.label,
373
- i && /* @__PURE__ */ e(K, { icon: ne, className: "ml-auto" })
371
+ return /* @__PURE__ */ D(q, { children: [
372
+ v.label,
373
+ g && /* @__PURE__ */ e(j, { icon: ae, className: "ml-auto" })
374
374
  ] });
375
375
  },
376
- [c, s]
376
+ [o, s]
377
377
  );
378
- return t === "error" ? /* @__PURE__ */ e(Ie, { className: "py-6", children: n || d }) : t === "loading" ? /* @__PURE__ */ e(ae, { className: "py-6", children: m }) : l === "input" && s.length < o ? /* @__PURE__ */ e(Le, { className: "py-6", children: u }) : r.length === 0 && t === "success" ? /* @__PURE__ */ e(xe, { className: "py-6", children: h }) : /* @__PURE__ */ e(B, { children: S.map(({ option: g, index: i, isSelected: N, isDisabled: v }) => /* @__PURE__ */ e(
379
- ee,
378
+ return t === "error" ? /* @__PURE__ */ e(Ie, { className: "py-6", children: n || i }) : t === "loading" ? /* @__PURE__ */ e(se, { className: "py-6", children: h }) : l === "input" && s.length < c ? /* @__PURE__ */ e(Le, { className: "py-6", children: d }) : r.length === 0 && t === "success" ? /* @__PURE__ */ e(xe, { className: "py-6", children: u }) : /* @__PURE__ */ e(q, { children: S.map(({ option: v, index: g, isSelected: p, isDisabled: m }) => /* @__PURE__ */ e(
379
+ re,
380
380
  {
381
- value: g.label,
382
- onSelect: v ? void 0 : f,
383
- disabled: v,
381
+ value: v.label,
382
+ onSelect: m ? void 0 : f,
383
+ disabled: m,
384
384
  children: b({
385
- option: g,
386
- isSelected: N,
387
- isDisabled: v,
388
- index: i
385
+ option: v,
386
+ isSelected: p,
387
+ isDisabled: m,
388
+ index: g
389
389
  })
390
390
  },
391
- g.value
391
+ v.value
392
392
  )) });
393
- }, oe = (r) => {
393
+ }, ie = (r) => {
394
394
  const {
395
395
  loadOptions: t,
396
396
  loadMode: n = "auto",
397
397
  minInputLength: a = 3,
398
398
  debounceMs: s = 300,
399
399
  searchPlaceholder: l = "Найти",
400
- loadingText: o = "Загружаем...",
400
+ loadingText: c = "Загружаем...",
401
401
  errorText: f = "Ошибка загрузки",
402
- inputHintText: c = "Введите текст для поиска",
403
- emptyText: m = "Результатов не найдено",
404
- renderOption: d,
405
- onSelect: u,
406
- isSelected: h,
402
+ inputHintText: o = "Введите текст для поиска",
403
+ emptyText: h = "Результатов не найдено",
404
+ renderOption: i,
405
+ onSelect: d,
406
+ isSelected: u,
407
407
  hideSearch: S
408
- } = r, [b, g] = L(""), i = Oe(b, s), { options: N, loadingState: v, error: p, loadData: w } = ke({
408
+ } = r, [b, v] = w(""), g = Oe(b, s), { options: p, loadingState: m, error: y, loadData: I } = ke({
409
409
  loadOptions: t
410
- }), R = P(() => n === "auto" ? !0 : n === "input" ? i.length >= a : !1, [n, i, a]);
411
- E(() => {
412
- R && w(i);
413
- }, [R, i, w]);
414
- const I = x(
410
+ }), R = M(() => n === "auto" ? !0 : n === "input" ? g.length >= a : !1, [n, g, a]);
411
+ A(() => {
412
+ R && I(g);
413
+ }, [R, g, I]);
414
+ const L = x(
415
415
  (V) => {
416
- u(N.find((y) => y.label === V) || null);
416
+ d(p.find((P) => P.label === V) || null);
417
417
  },
418
- [u, N]
418
+ [d, p]
419
419
  );
420
- return /* @__PURE__ */ D(re, { shouldFilter: !1, children: [
421
- !S && /* @__PURE__ */ e($, { placeholder: l, onValueChange: g }),
422
- /* @__PURE__ */ e(te, { className: "p-1", children: /* @__PURE__ */ e(
420
+ return /* @__PURE__ */ D(te, { shouldFilter: !1, children: [
421
+ !S && /* @__PURE__ */ e(G, { placeholder: l, onValueChange: v }),
422
+ /* @__PURE__ */ e(ne, { className: "p-1", children: /* @__PURE__ */ e(
423
423
  ze,
424
424
  {
425
- options: N,
426
- loadingState: v,
427
- error: p,
428
- isSelected: h,
429
- searchQuery: i,
425
+ options: p,
426
+ loadingState: m,
427
+ error: y,
428
+ isSelected: u,
429
+ searchQuery: g,
430
430
  loadMode: n,
431
431
  minInputLength: a,
432
- onSelect: I,
433
- renderOption: d,
434
- loadingText: o,
432
+ onSelect: L,
433
+ renderOption: i,
434
+ loadingText: c,
435
435
  errorText: f,
436
- inputHintText: c,
437
- emptyText: m
436
+ inputHintText: o,
437
+ emptyText: h
438
438
  }
439
- ) }, `list-${i}`)
439
+ ) }, `list-${g}`)
440
440
  ] });
441
441
  }, ar = (r) => {
442
442
  const {
@@ -445,47 +445,47 @@ const ke = ({ loadOptions: r }) => {
445
445
  value: a,
446
446
  defaultValue: s,
447
447
  disabled: l,
448
- invalid: o,
448
+ invalid: c,
449
449
  onChange: f,
450
- startIcon: c,
451
- onClear: m,
452
- ...d
453
- } = r, [u, h] = L(!1), [S, b] = H({
450
+ startIcon: o,
451
+ onClear: h,
452
+ ...i
453
+ } = r, [d, u] = w(!1), [S, b] = K({
454
454
  value: a,
455
455
  defaultValue: s,
456
456
  onChange: f
457
- }), g = P(() => {
457
+ }), v = M(() => {
458
458
  if (S) {
459
459
  if (t) {
460
- const v = t({ option: S, type: "trigger" });
461
- if (v !== void 0)
462
- return v;
460
+ const m = t({ option: S, type: "trigger" });
461
+ if (m !== void 0)
462
+ return m;
463
463
  }
464
- return /* @__PURE__ */ e(se, { children: S.label });
464
+ return /* @__PURE__ */ e(le, { children: S.label });
465
465
  }
466
- }, [S, t]), i = x(
467
- (v) => {
468
- v && b(v), h(!1);
466
+ }, [S, t]), g = x(
467
+ (m) => {
468
+ m && b(m), u(!1);
469
469
  },
470
- [b, h]
471
- ), N = x(
472
- (v) => S?.value === v.value,
470
+ [b, u]
471
+ ), p = x(
472
+ (m) => S?.value === m.value,
473
473
  [S]
474
474
  );
475
- return /* @__PURE__ */ D(j, { ...d, open: u, onOpenChange: h, children: [
476
- /* @__PURE__ */ e(_, { asChild: !0, children: /* @__PURE__ */ e(
477
- W,
475
+ return /* @__PURE__ */ D(_, { ...i, open: d, onOpenChange: u, children: [
476
+ /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(
477
+ k,
478
478
  {
479
479
  placeholder: n,
480
480
  disabled: l,
481
- invalid: o,
482
- open: u,
483
- startIcon: c,
484
- onClear: m,
485
- children: g
481
+ invalid: c,
482
+ open: d,
483
+ startIcon: o,
484
+ onClear: v ? h : void 0,
485
+ children: v
486
486
  }
487
487
  ) }),
488
- /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(oe, { ...r, onSelect: i, isSelected: N }) })
488
+ /* @__PURE__ */ e(z, { children: /* @__PURE__ */ e(ie, { ...r, onSelect: g, isSelected: p }) })
489
489
  ] });
490
490
  }, Be = (r) => {
491
491
  const {
@@ -494,85 +494,86 @@ const ke = ({ loadOptions: r }) => {
494
494
  value: a,
495
495
  defaultValue: s,
496
496
  onChange: l,
497
- disabled: o,
497
+ disabled: c,
498
498
  invalid: f,
499
- keepOpenOnSelect: c = !0,
500
- onClear: m,
501
- onLabelClick: d,
502
- renderOption: u,
503
- startIcon: h,
504
- ...S
505
- } = r, [b, g] = L(!1), [i, N] = H({
499
+ keepOpenOnSelect: o = !0,
500
+ onClear: h,
501
+ onLabelClick: i,
502
+ renderOption: d,
503
+ startIcon: u,
504
+ portalContainer: S,
505
+ ...b
506
+ } = r, [v, g] = w(!1), [p, m] = K({
506
507
  value: a,
507
508
  defaultValue: s,
508
509
  onChange: l
509
- }), v = x(
510
- (y) => {
511
- if (y) {
512
- const T = i?.find((C) => C.value === y.value);
513
- N(T ? (C) => C?.filter((A) => A.value !== y.value) || [] : (C) => [...C || [], y]);
510
+ }), y = x(
511
+ (C) => {
512
+ if (C) {
513
+ const T = p?.find((N) => N.value === C.value);
514
+ m(T ? (N) => N?.filter((E) => E.value !== C.value) || [] : (N) => [...N || [], C]);
514
515
  }
515
- c || g(!1);
516
+ o || g(!1);
516
517
  },
517
- [i, c, N, g]
518
- ), p = x(
519
- (y) => {
520
- i?.find((C) => C.value === y.value) && N((C) => C?.filter((A) => A.value !== y.value) || []);
518
+ [p, o, m, g]
519
+ ), I = x(
520
+ (C) => {
521
+ p?.find((N) => N.value === C.value) && m((N) => N?.filter((E) => E.value !== C.value) || []);
521
522
  },
522
- [i, N]
523
- ), w = x(
524
- (y) => i?.some((T) => T.value === y.value) ?? !1,
525
- [i]
526
- ), { handleKeyDown: R, isFocused: I } = we({
527
- items: i || [],
528
- onEnter: d,
529
- onDelete: p
530
- }), V = P(() => {
531
- if (!(!i || i.length === 0))
532
- return i.map((y, T) => {
533
- if (u) {
534
- const C = u({
535
- option: y,
523
+ [p, m]
524
+ ), R = x(
525
+ (C) => p?.some((T) => T.value === C.value) ?? !1,
526
+ [p]
527
+ ), { handleKeyDown: L, isFocused: V } = we({
528
+ items: p || [],
529
+ onEnter: i,
530
+ onDelete: I
531
+ }), P = M(() => {
532
+ if (!(!p || p.length === 0))
533
+ return p.map((C, T) => {
534
+ if (d) {
535
+ const N = d({
536
+ option: C,
536
537
  type: "trigger",
537
538
  onClose: () => {
538
- p(y);
539
+ I(C);
539
540
  }
540
541
  });
541
- if (C !== void 0)
542
- return C;
542
+ if (N !== void 0)
543
+ return N;
543
544
  }
544
545
  return /* @__PURE__ */ e(
545
546
  fe,
546
547
  {
547
- onLabelClick: (C) => {
548
- C.preventDefault(), d?.(y);
548
+ onLabelClick: (N) => {
549
+ N.preventDefault(), i?.(C);
549
550
  },
550
- onClose: (C) => {
551
- C.preventDefault(), p(y);
551
+ onClose: (N) => {
552
+ N.preventDefault(), I(C);
552
553
  },
553
- isFocused: I(T),
554
- children: y.label
554
+ isFocused: V(T),
555
+ children: C.label
555
556
  },
556
- y.value
557
+ C.value
557
558
  );
558
559
  });
559
- }, [i, u, p, d, I]);
560
- return /* @__PURE__ */ e("div", { className: t, children: /* @__PURE__ */ D(j, { open: b, onOpenChange: g, ...S, children: [
561
- /* @__PURE__ */ e(_, { asChild: !0, children: /* @__PURE__ */ e(
562
- W,
560
+ }, [p, d, I, i, V]);
561
+ return /* @__PURE__ */ e("div", { className: t, children: /* @__PURE__ */ D(_, { open: v, onOpenChange: g, ...b, children: [
562
+ /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(
563
+ k,
563
564
  {
564
- onKeyDown: R,
565
- disabled: o,
566
- open: b,
565
+ onKeyDown: L,
566
+ disabled: c,
567
+ open: v,
567
568
  placeholder: n,
568
569
  invalid: f,
569
- startIcon: h,
570
- onClear: m,
570
+ startIcon: u,
571
+ onClear: h,
571
572
  className: "h-auto lg:h-auto",
572
- children: V && /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5 pl-1.5 lg:gap-1", children: V })
573
+ children: P && /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5 pl-1.5 lg:gap-1", children: P })
573
574
  }
574
575
  ) }),
575
- /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(oe, { ...r, onSelect: v, isSelected: w }) })
576
+ /* @__PURE__ */ e(z, { portalContainer: S, children: /* @__PURE__ */ e(ie, { ...r, onSelect: y, isSelected: R }) })
576
577
  ] }) });
577
578
  };
578
579
  Be.displayName = "MultiSelect";
@@ -582,12 +583,12 @@ export {
582
583
  Qe as LazySearchSelect,
583
584
  ce as LoadMoreTrigger,
584
585
  Be as MultiSelect,
585
- le as SearchSelect,
586
- k as SearchSelectContent,
587
- $ as SearchSelectInput,
586
+ oe as SearchSelect,
587
+ z as SearchSelectContent,
588
+ G as SearchSelectInput,
588
589
  We as SearchSelectSeparator,
589
590
  fe as SearchSelectTag,
590
- W as SearchSelectTrigger,
591
+ k as SearchSelectTrigger,
591
592
  Ae as defaultFuzzyFilter,
592
593
  ke as useAsyncDataLoader,
593
594
  Te as useSearchSelect