ics-ui-kit 0.1.0-alpha.16 → 0.1.0-alpha.17

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