@nice2dev/ui 1.3.7 → 1.3.8

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/NiceCodeEditor-B5YtKZOe.js +1222 -0
  3. package/dist/NiceCodeEditor-D0QZW88r.cjs +268 -0
  4. package/dist/NiceColorPicker-Bzvei7D6.cjs +1 -0
  5. package/dist/NiceColorPicker-DzzJhSXT.js +552 -0
  6. package/dist/NiceDataGrid-BSaBBoNr.js +2267 -0
  7. package/dist/NiceDataGrid-C_E6zIGS.cjs +10 -0
  8. package/dist/NiceForm-D2P6XuaT.cjs +1 -0
  9. package/dist/NiceForm-_kaB4Ikt.js +5017 -0
  10. package/dist/NiceHtmlEditor-CBCJdjmy.cjs +10 -0
  11. package/dist/NiceHtmlEditor-DfkdSxL3.js +901 -0
  12. package/dist/NiceLoginForm-BFvbroGJ.js +820 -0
  13. package/dist/NiceLoginForm-FGf32sro.cjs +1 -0
  14. package/dist/NiceMention-CctjYriS.cjs +430 -0
  15. package/dist/NiceMention-umOghLCf.js +11653 -0
  16. package/dist/NiceModal-BRVzjuUN.cjs +1 -0
  17. package/dist/NiceModal-CU9FqzIH.js +83 -0
  18. package/dist/NiceModuleLifecyclePanel-DQT_forg.js +7404 -0
  19. package/dist/NiceModuleLifecyclePanel-DtOlPChV.cjs +1 -0
  20. package/dist/NicePagination-CK4ZJgu4.cjs +1 -0
  21. package/dist/NicePagination-flHgG-FT.js +200 -0
  22. package/dist/NicePivotGrid-99ZeQ9j6.js +1180 -0
  23. package/dist/NicePivotGrid-CpsBxUhq.cjs +152 -0
  24. package/dist/NiceSavedQueryPanel-Br1LQR7u.js +5311 -0
  25. package/dist/NiceSavedQueryPanel-C4SU6W22.cjs +586 -0
  26. package/dist/NiceScheduler-CeYqH0Ux.cjs +5 -0
  27. package/dist/NiceScheduler-yTpVRxfe.js +1710 -0
  28. package/dist/NiceSelect-C3NqDYwR.js +495 -0
  29. package/dist/NiceSelect-CTwSAb8G.cjs +1 -0
  30. package/dist/charts-B0tHOpJ7.cjs +768 -0
  31. package/dist/charts-C3u-VyJj.js +5019 -0
  32. package/dist/charts.cjs +1 -1
  33. package/dist/charts.mjs +1 -1
  34. package/dist/core-lazy-Bglo0hFt.cjs +1 -0
  35. package/dist/core-lazy-CRBgQkQl.js +351 -0
  36. package/dist/data.cjs +1 -1
  37. package/dist/data.mjs +3 -3
  38. package/dist/devops-Bzp3ZqZ3.cjs +18 -0
  39. package/dist/devops-fLElpPvD.js +9128 -0
  40. package/dist/devops.cjs +1 -1
  41. package/dist/devops.mjs +1 -1
  42. package/dist/editors.cjs +1 -1
  43. package/dist/editors.d.ts +5 -0
  44. package/dist/editors.mjs +7 -7
  45. package/dist/feedback.cjs +1 -1
  46. package/dist/feedback.mjs +3 -3
  47. package/dist/index.cjs +251 -251
  48. package/dist/index.d.ts +76 -9
  49. package/dist/index.mjs +15550 -15248
  50. package/dist/lazy.cjs +1 -1
  51. package/dist/lazy.mjs +18 -18
  52. package/dist/navigation.cjs +1 -1
  53. package/dist/navigation.d.ts +42 -3
  54. package/dist/navigation.mjs +2 -2
  55. package/dist/no-code-Bt7SWzsN.js +8318 -0
  56. package/dist/no-code-DnT061qn.cjs +331 -0
  57. package/dist/no-code.cjs +1 -1
  58. package/dist/no-code.mjs +1 -1
  59. package/package.json +4 -4
@@ -0,0 +1,495 @@
1
+ import { jsxs as v, jsx as t, Fragment as Ie } from "react/jsx-runtime";
2
+ import { NiceThemeContext as We, useInputEngine as Be, useOverlayFocus as Ve, useNiceAccessMode as Ge, useNiceTranslation as Je, useComponentDisplayStyle as Qe, useComponentDisplayClass as Xe, useControlId as Ye, useDisplayModeEdit as Ze, useNiceLookupSource as en, useIntent as nn, COMMON_SHORTCUTS as ge, NiceKeyboardHint as tn, DisplayModeView as sn, NiceIcon as oe } from "@nice2dev/ui-core";
3
+ import cn, { useRef as de, useState as N, useContext as ln, useLayoutEffect as ae, useEffect as rn, forwardRef as on, useMemo as B, useCallback as V } from "react";
4
+ import { createPortal as an } from "react-dom";
5
+ import { s as dn } from "./devops-fLElpPvD.js";
6
+ function un(g, y, D, _) {
7
+ const G = _?.maxHeight ?? 320, M = _?.anchorKey, w = de(null), [ye, J] = N(null), [ue, Q] = N(!1), [fe, A] = N(""), k = ln(We)?.portalTarget ?? (typeof document < "u" ? document.body : null), a = de(D);
8
+ a.current = D;
9
+ const H = Be();
10
+ return Ve(w, {
11
+ open: g,
12
+ modal: !1,
13
+ initialFocus: "none",
14
+ onClose: () => a.current(),
15
+ closeHint: !1
16
+ }), ae(() => {
17
+ if (!g || !y.current)
18
+ return;
19
+ A(dn(y.current)), Q(!1);
20
+ const s = () => {
21
+ const $ = y.current;
22
+ if (!$)
23
+ return;
24
+ const r = $.getBoundingClientRect(), R = w.current?.offsetHeight ?? G;
25
+ let T = r.bottom;
26
+ T + R > window.innerHeight - 8 && r.top - R > 8 && (T = r.top - R);
27
+ let x = r.left;
28
+ x + r.width > window.innerWidth - 8 && (x = Math.max(8, window.innerWidth - r.width - 8)), J(
29
+ (o) => o && o.left === x && o.top === T && o.width === r.width ? o : { left: x, top: T, width: r.width }
30
+ );
31
+ };
32
+ s();
33
+ const I = requestAnimationFrame(() => {
34
+ s(), Q(!0);
35
+ }), p = ($) => {
36
+ const r = $.target;
37
+ r instanceof Node && (w.current?.contains(r) || y.current?.contains(r)) || a.current();
38
+ }, h = () => a.current();
39
+ return window.addEventListener("scroll", p, !0), window.addEventListener("resize", h), () => {
40
+ cancelAnimationFrame(I), window.removeEventListener("scroll", p, !0), window.removeEventListener("resize", h);
41
+ };
42
+ }, [g, y, G, M]), rn(() => {
43
+ if (!g)
44
+ return;
45
+ const s = (p) => {
46
+ const h = p.target;
47
+ y.current?.contains(h) || w.current?.contains(h) || (h instanceof Element ? h : h?.parentElement ?? null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]') || a.current();
48
+ }, I = (p) => {
49
+ if (p.key !== "Escape" || p.defaultPrevented)
50
+ return;
51
+ const h = H?.topOverlay();
52
+ h && h.element !== w.current || a.current();
53
+ };
54
+ return document.addEventListener("mousedown", s), document.addEventListener("keydown", I), () => {
55
+ document.removeEventListener("mousedown", s), document.removeEventListener("keydown", I);
56
+ };
57
+ }, [g, y, H]), { popupRef: w, coords: ye, ready: ue, themeClass: fe, portalTarget: k };
58
+ }
59
+ const fn = /* @__PURE__ */ Object.assign(
60
+ /* @__PURE__ */ on(
61
+ ({
62
+ label: g,
63
+ "aria-label": y,
64
+ helperText: D,
65
+ error: _,
66
+ required: G,
67
+ disabled: M,
68
+ size: w = "md",
69
+ name: ye,
70
+ id: J,
71
+ className: ue,
72
+ style: Q,
73
+ accessMode: fe,
74
+ displayStyle: A,
75
+ options: we,
76
+ value: k,
77
+ onChange: a,
78
+ placeholder: H,
79
+ multiple: s = !1,
80
+ searchable: I = !0,
81
+ clearable: p = !1,
82
+ emptyText: h,
83
+ maxHeight: $ = 240,
84
+ optionsSource: r,
85
+ valueField: R,
86
+ labelField: T,
87
+ virtualScroll: x,
88
+ optionHeight: o = 36,
89
+ onSearch: O,
90
+ loading: E,
91
+ renderOption: X,
92
+ multipleAutosize: Y = !1,
93
+ showKeyboardHints: Le,
94
+ labelPlacement: Te,
95
+ errorPlacement: Z,
96
+ labelWidth: ee,
97
+ controlWidth: j,
98
+ displayMode: Oe
99
+ }, ne) => {
100
+ const he = Ge(fe, J), Fe = he === "hidden";
101
+ (he === "disabled" || he === "readOnly") && (M = !0);
102
+ const { t: C } = Je(), Ae = Qe("input", A), He = Xe("input", A), S = Ye(J), xe = Ze({ enabled: Oe, disabled: M }), [d, F] = N(!1), [te, ie] = N(""), [u, z] = N(-1), [be, Re] = N(0), Ne = de(null), K = de(null), [ke, je] = N(null);
103
+ ae(() => {
104
+ !E && K.current && je(K.current.offsetWidth);
105
+ }, [E, k, A]);
106
+ const [P, ze] = N(null);
107
+ ae(() => {
108
+ s && !Y && K.current && P == null && ze(K.current.offsetWidth);
109
+ }, [s, Y, P]);
110
+ const Ke = en(
111
+ r ?? null,
112
+ R ?? r?.keyField ?? "id",
113
+ T ?? "name"
114
+ ), L = r ? Ke.options : (we ?? []).map(
115
+ (e) => typeof e == "string" ? { value: e, label: e } : e
116
+ ), { popupRef: se, coords: q, ready: $e, themeClass: ce, portalTarget: Ee } = un(
117
+ d,
118
+ Ne,
119
+ () => {
120
+ F(!1), ie("");
121
+ }
122
+ ), c = B(() => k ? Array.isArray(k) ? k : [k] : [], [k]), l = B(() => {
123
+ if (!te && !O || O)
124
+ return L;
125
+ const e = te.toLowerCase();
126
+ return L.filter(
127
+ (n) => n.label.toLowerCase().includes(e) || String(n.value).toLowerCase().includes(e)
128
+ );
129
+ }, [L, te, O]), Ce = B(() => {
130
+ const e = /* @__PURE__ */ new Map();
131
+ for (const n of l) {
132
+ const i = n.group || "";
133
+ e.has(i) || e.set(i, []), e.get(i).push(n);
134
+ }
135
+ return e;
136
+ }, [l]), U = V(
137
+ (e) => {
138
+ if (s) {
139
+ const n = c.includes(e) ? c.filter((i) => i !== e) : [...c, e];
140
+ a?.(n);
141
+ } else
142
+ a?.(e), F(!1), ie("");
143
+ },
144
+ [s, c, a]
145
+ ), le = V(() => {
146
+ const e = l.findIndex((n) => c.includes(String(n.value)));
147
+ z(e >= 0 ? e : 0), F(!0);
148
+ }, [l, c]), pe = V(
149
+ (e) => z((n) => Math.max(0, Math.min(l.length - 1, e(n)))),
150
+ [l.length]
151
+ ), Se = V(
152
+ (e) => {
153
+ const n = e.target instanceof HTMLInputElement;
154
+ if (e.key === "Escape") {
155
+ F(!1), ie("");
156
+ return;
157
+ }
158
+ if ((e.key === "Delete" || e.key === "Backspace") && !n && p && c.length > 0) {
159
+ e.preventDefault(), a?.(s ? [] : "");
160
+ return;
161
+ }
162
+ if (e.key === "Enter" || e.key === " " && !n) {
163
+ if (!d) {
164
+ le(), e.preventDefault();
165
+ return;
166
+ }
167
+ u >= 0 && l[u] && (U(l[u].value), e.preventDefault());
168
+ return;
169
+ }
170
+ const i = {
171
+ ArrowDown: (f) => f + 1,
172
+ ArrowUp: (f) => f - 1,
173
+ PageDown: (f) => f + 10,
174
+ PageUp: (f) => f - 10
175
+ };
176
+ n || (i.Home = () => 0, i.End = () => l.length - 1);
177
+ const b = i[e.key];
178
+ b && (e.preventDefault(), d ? pe(b) : le());
179
+ },
180
+ [
181
+ d,
182
+ u,
183
+ l,
184
+ U,
185
+ le,
186
+ pe,
187
+ p,
188
+ c.length,
189
+ a,
190
+ s
191
+ ]
192
+ ), De = I || !!O, me = `${S}-listbox`, ve = (e) => `${S}-opt-${e}`, Me = d && u >= 0 && l[u] ? ve(u) : void 0;
193
+ ae(() => {
194
+ const e = se.current;
195
+ if (!(!d || u < 0 || !e)) {
196
+ if (x) {
197
+ const n = u * o;
198
+ n < e.scrollTop ? e.scrollTop = n : n + o > e.scrollTop + e.clientHeight && (e.scrollTop = n + o - e.clientHeight);
199
+ return;
200
+ }
201
+ e.querySelector(`[data-nice-option-index="${u}"]`)?.scrollIntoView?.({ block: "nearest" });
202
+ }
203
+ }, [d, u, x, o, se]), nn(
204
+ ["navigate", "activate"],
205
+ (e) => {
206
+ if (e.source === "keyboard")
207
+ return !1;
208
+ if (e.intent === "activate") {
209
+ const n = l[u];
210
+ n && !n.disabled && U(String(n.value));
211
+ return;
212
+ }
213
+ if (e.direction !== "up" && e.direction !== "down")
214
+ return !1;
215
+ pe((n) => n + (e.direction === "down" ? 1 : -1));
216
+ },
217
+ { ref: se, enabled: d && De }
218
+ );
219
+ const _e = B(() => c.length === 0 ? null : s ? c.map((e) => L.find((n) => n.value === e)?.label || e).join(", ") : L.find((e) => e.value === c[0])?.label || c[0], [c, L, s]), Pe = V(
220
+ (e) => {
221
+ e.stopPropagation(), a?.(s ? [] : "");
222
+ },
223
+ [a, s]
224
+ ), qe = B(
225
+ () => [
226
+ { key: "Enter", description: C("shortcuts.select", "Select") },
227
+ { key: "Space", description: C("shortcuts.openDropdown", "Open dropdown") },
228
+ ge.moveUp,
229
+ ge.moveDown,
230
+ ge.cancel
231
+ ],
232
+ [C]
233
+ );
234
+ return Fe ? null : /* @__PURE__ */ v(
235
+ "div",
236
+ {
237
+ className: `nice-field ${j == null ? "nice-field--select-auto" : ""} nice-field--${w} ${Te === "left" ? "nice-field--label-left" : ""} ${E ? "nice-field--loading" : ""} ${ue || ""}`,
238
+ style: {
239
+ ...Q,
240
+ ...ee != null && {
241
+ "--nice-field-label-width": typeof ee == "number" ? `${ee}px` : ee
242
+ },
243
+ ...j != null && {
244
+ "--nice-field-control-width": typeof j == "number" ? `${j}px` : j
245
+ },
246
+ ...E && ke != null && { "--nice-select-locked-width": `${ke}px` }
247
+ },
248
+ "aria-busy": E || void 0,
249
+ children: [
250
+ g && /* @__PURE__ */ v(
251
+ "label",
252
+ {
253
+ htmlFor: S,
254
+ className: `nice-field__label ${G ? "nice-field__label--required" : ""}`,
255
+ children: [
256
+ g,
257
+ Le && /* @__PURE__ */ t(tn, { shortcuts: qe, size: "sm" })
258
+ ]
259
+ }
260
+ ),
261
+ /* @__PURE__ */ v("div", { className: "nice-field__control", children: [
262
+ xe.isDisplay ? /* @__PURE__ */ t(
263
+ sn,
264
+ {
265
+ value: _e,
266
+ placeholder: H || C("controls.select", "Select..."),
267
+ disabled: M,
268
+ onActivate: () => {
269
+ xe.enterEdit(), F(!0);
270
+ },
271
+ ariaLabel: g ?? y
272
+ }
273
+ ) : /* @__PURE__ */ v("div", { className: "nice-select", ref: Ne, children: [
274
+ /* @__PURE__ */ v(
275
+ "button",
276
+ {
277
+ ref: (e) => {
278
+ K.current = e, typeof ne == "function" ? ne(e) : ne && (ne.current = e);
279
+ },
280
+ type: "button",
281
+ id: S,
282
+ role: "combobox",
283
+ "aria-label": g ? void 0 : y,
284
+ "aria-expanded": d,
285
+ "aria-haspopup": "listbox",
286
+ "aria-controls": d ? me : void 0,
287
+ "aria-activedescendant": De ? void 0 : Me,
288
+ "aria-invalid": !!_,
289
+ "aria-keyshortcuts": p && c.length > 0 ? "Delete" : void 0,
290
+ className: `nice-select__trigger nice-select__trigger--${w} nice-select--ds-${He} ${d ? "nice-select__trigger--open" : ""} ${_ ? "nice-select__trigger--error" : ""} ${M ? "nice-select__trigger--disabled" : ""}`,
291
+ style: {
292
+ ...Ae,
293
+ ...s && !Y && P != null ? {
294
+ width: P,
295
+ maxWidth: P,
296
+ overflow: "hidden"
297
+ } : {}
298
+ },
299
+ disabled: M,
300
+ onClick: () => d ? F(!1) : le(),
301
+ onKeyDown: Se,
302
+ children: [
303
+ _e ? /* @__PURE__ */ t(
304
+ "span",
305
+ {
306
+ style: s && !Y ? {
307
+ flex: 1,
308
+ minWidth: 0,
309
+ overflow: "hidden",
310
+ textOverflow: "ellipsis",
311
+ whiteSpace: "nowrap"
312
+ } : void 0,
313
+ children: _e
314
+ }
315
+ ) : /* @__PURE__ */ t("span", { className: "nice-select__placeholder", children: H || C("controls.select", "Select...") }),
316
+ /* @__PURE__ */ v("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
317
+ p && c.length > 0 && // the pointer's shortcut for Delete / Backspace on the trigger
318
+ /* @__PURE__ */ t("span", { className: "nice-input__clear", onClick: Pe, role: "presentation", children: /* @__PURE__ */ t(oe, { name: "close", size: 14 }) }),
319
+ /* @__PURE__ */ t(
320
+ "span",
321
+ {
322
+ className: `nice-select__chevron ${d ? "nice-select__chevron--open" : ""}`,
323
+ children: /* @__PURE__ */ t(oe, { name: "chevron-down", size: 16 })
324
+ }
325
+ )
326
+ ] })
327
+ ]
328
+ }
329
+ ),
330
+ d && q && Ee && an(
331
+ /* @__PURE__ */ v(
332
+ "div",
333
+ {
334
+ ref: se,
335
+ className: `nice-select__dropdown${ce ? ` ${ce}` : ""}`,
336
+ "data-theme": ce === "nice-dark" ? "dark" : ce === "nice-light" ? "light" : void 0,
337
+ role: "listbox",
338
+ id: me,
339
+ "aria-multiselectable": s || void 0,
340
+ style: {
341
+ maxHeight: $,
342
+ position: "fixed",
343
+ left: q.left,
344
+ top: q.top,
345
+ width: q.width,
346
+ minWidth: q.width,
347
+ zIndex: 1e3,
348
+ // Hidden until measured so the estimate frame never paints above.
349
+ opacity: $e ? 1 : 0,
350
+ pointerEvents: $e ? void 0 : "none"
351
+ },
352
+ onScroll: x ? (e) => Re(e.currentTarget.scrollTop) : void 0,
353
+ children: [
354
+ (I || O) && /* @__PURE__ */ t("div", { className: "nice-select__search", children: /* @__PURE__ */ t(
355
+ "input",
356
+ {
357
+ type: "text",
358
+ value: te,
359
+ onChange: (e) => {
360
+ ie(e.target.value), z(0), O?.(e.target.value);
361
+ },
362
+ onKeyDown: Se,
363
+ placeholder: C("controls.search", "Search..."),
364
+ "aria-label": C("controls.search", "Search..."),
365
+ "aria-controls": me,
366
+ "aria-activedescendant": Me,
367
+ "aria-autocomplete": "list",
368
+ autoFocus: !0
369
+ }
370
+ ) }),
371
+ E && /* @__PURE__ */ t("div", { className: "nice-select__loading", children: /* @__PURE__ */ t(
372
+ "div",
373
+ {
374
+ className: "nice-spinner nice-spinner--sm",
375
+ style: { margin: "8px auto" }
376
+ }
377
+ ) }),
378
+ !E && l.length === 0 ? /* @__PURE__ */ t("div", { className: "nice-select__empty", children: h || C("controls.noResults", "No results found") }) : x && !Array.from(Ce.keys()).some((e) => e !== "") ? (() => {
379
+ const n = l.length * o, i = Math.max(
380
+ 0,
381
+ Math.floor(be / o) - 3
382
+ ), b = Math.min(
383
+ l.length,
384
+ Math.ceil((be + $) / o) + 3
385
+ ), f = l.slice(i, b);
386
+ return /* @__PURE__ */ t("div", { style: { height: n, position: "relative" }, children: f.map((m, Ue) => {
387
+ const W = i + Ue, re = c.includes(m.value);
388
+ return (
389
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keys: the combobox (aria-activedescendant)
390
+ /* @__PURE__ */ t(
391
+ "div",
392
+ {
393
+ id: ve(W),
394
+ "data-nice-option-index": W,
395
+ role: "option",
396
+ "aria-selected": re,
397
+ "aria-disabled": m.disabled || void 0,
398
+ className: `nice-select__option ${re ? "nice-select__option--selected" : ""} ${W === u ? "nice-select__option--highlighted" : ""} ${m.disabled ? "nice-select__option--disabled" : ""}`,
399
+ style: {
400
+ position: "absolute",
401
+ top: W * o,
402
+ left: 0,
403
+ right: 0,
404
+ height: o,
405
+ display: "flex",
406
+ alignItems: "center",
407
+ padding: "0 12px"
408
+ },
409
+ onClick: () => !m.disabled && U(String(m.value)),
410
+ onMouseEnter: () => z(W),
411
+ children: X ? X(m, re) : /* @__PURE__ */ v(Ie, { children: [
412
+ m.icon && /* @__PURE__ */ t("span", { children: m.icon }),
413
+ /* @__PURE__ */ v("div", { style: { flex: 1 }, children: [
414
+ /* @__PURE__ */ t("div", { children: m.label }),
415
+ m.description && /* @__PURE__ */ t("div", { className: "nice-select__option-desc", children: m.description })
416
+ ] }),
417
+ re && /* @__PURE__ */ t(
418
+ oe,
419
+ {
420
+ name: "check",
421
+ size: 16,
422
+ className: "nice-select__option-check"
423
+ }
424
+ )
425
+ ] })
426
+ },
427
+ m.value
428
+ )
429
+ );
430
+ }) });
431
+ })() : Array.from(Ce.entries()).map(([e, n]) => /* @__PURE__ */ v(cn.Fragment, { children: [
432
+ e && /* @__PURE__ */ t("div", { className: "nice-select__group-label", children: e }),
433
+ n.map((i) => {
434
+ const b = c.includes(i.value), f = l.indexOf(i);
435
+ return (
436
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keys: the combobox (aria-activedescendant)
437
+ /* @__PURE__ */ t(
438
+ "div",
439
+ {
440
+ id: ve(f),
441
+ "data-nice-option-index": f,
442
+ role: "option",
443
+ "aria-selected": b,
444
+ "aria-disabled": i.disabled || void 0,
445
+ className: `nice-select__option ${b ? "nice-select__option--selected" : ""} ${f === u ? "nice-select__option--highlighted" : ""} ${i.disabled ? "nice-select__option--disabled" : ""}`,
446
+ onClick: () => !i.disabled && U(String(i.value)),
447
+ onMouseEnter: () => z(f),
448
+ children: X ? X(i, b) : /* @__PURE__ */ v(Ie, { children: [
449
+ i.icon && /* @__PURE__ */ t("span", { children: i.icon }),
450
+ /* @__PURE__ */ v("div", { style: { flex: 1 }, children: [
451
+ /* @__PURE__ */ t("div", { children: i.label }),
452
+ i.description && /* @__PURE__ */ t("div", { className: "nice-select__option-desc", children: i.description })
453
+ ] }),
454
+ b && /* @__PURE__ */ t(
455
+ oe,
456
+ {
457
+ name: "check",
458
+ size: 16,
459
+ className: "nice-select__option-check"
460
+ }
461
+ )
462
+ ] })
463
+ },
464
+ i.value
465
+ )
466
+ );
467
+ })
468
+ ] }, e))
469
+ ]
470
+ }
471
+ ),
472
+ Ee
473
+ )
474
+ ] }),
475
+ E && /* @__PURE__ */ t("span", { className: "nice-field__spinner", children: /* @__PURE__ */ t("span", { className: "nice-spinner nice-spinner--sm" }) }),
476
+ Z === "right" && _ && /* @__PURE__ */ t("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: _ }),
477
+ Z === "right" && !_ && D && /* @__PURE__ */ t("div", { id: `${S}-helper`, className: "nice-field__helper", children: D })
478
+ ] }),
479
+ Z !== "right" && _ && /* @__PURE__ */ t("div", { id: `${S}-error`, className: "nice-field__error", role: "alert", children: _ }),
480
+ Z !== "right" && !_ && D && /* @__PURE__ */ t("div", { id: `${S}-helper`, className: "nice-field__helper", children: D })
481
+ ]
482
+ }
483
+ );
484
+ }
485
+ ),
486
+ { displayName: "NiceSelect" }
487
+ ), gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
488
+ __proto__: null,
489
+ NiceSelect: fn
490
+ }, Symbol.toStringTag, { value: "Module" }));
491
+ export {
492
+ fn as N,
493
+ gn as a,
494
+ un as u
495
+ };
@@ -0,0 +1 @@
1
+ "use strict";const t=require("react/jsx-runtime"),c=require("@nice2dev/ui-core"),s=require("react"),He=require("react-dom"),ze=require("./devops-Bzp3ZqZ3.cjs");function ke(y,g,E,_){const B=_?.maxHeight??320,M=_?.anchorKey,w=s.useRef(null),[he,V]=s.useState(null),[le,G]=s.useState(!1),[re,R]=s.useState(""),b=s.useContext(c.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),u=s.useRef(E);u.current=E;const F=c.useInputEngine();return c.useOverlayFocus(w,{open:y,modal:!1,initialFocus:"none",onClose:()=>u.current(),closeHint:!1}),s.useLayoutEffect(()=>{if(!y||!g.current)return;R(ze.scopeThemeClass(g.current)),G(!1);const l=()=>{const k=g.current;if(!k)return;const a=k.getBoundingClientRect(),q=w.current?.offsetHeight??B;let D=a.bottom;D+q>window.innerHeight-8&&a.top-q>8&&(D=a.top-q);let j=a.left;j+a.width>window.innerWidth-8&&(j=Math.max(8,window.innerWidth-a.width-8)),V(d=>d&&d.left===j&&d.top===D&&d.width===a.width?d:{left:j,top:D,width:a.width})};l();const I=requestAnimationFrame(()=>{l(),G(!0)}),v=k=>{const a=k.target;a instanceof Node&&(w.current?.contains(a)||g.current?.contains(a))||u.current()},m=()=>u.current();return window.addEventListener("scroll",v,!0),window.addEventListener("resize",m),()=>{cancelAnimationFrame(I),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",m)}},[y,g,B,M]),s.useEffect(()=>{if(!y)return;const l=v=>{const m=v.target;g.current?.contains(m)||w.current?.contains(m)||(m instanceof Element?m:m?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||u.current()},I=v=>{if(v.key!=="Escape"||v.defaultPrevented)return;const m=F?.topOverlay();m&&m.element!==w.current||u.current()};return document.addEventListener("mousedown",l),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",I)}},[y,g,F]),{popupRef:w,coords:he,ready:le,themeClass:re,portalTarget:b}}const Se=Object.assign(s.forwardRef(({label:y,"aria-label":g,helperText:E,error:_,required:B,disabled:M,size:w="md",name:he,id:V,className:le,style:G,accessMode:re,displayStyle:R,options:pe,value:b,onChange:u,placeholder:F,multiple:l=!1,searchable:I=!0,clearable:v=!1,emptyText:m,maxHeight:k=240,optionsSource:a,valueField:q,labelField:D,virtualScroll:j,optionHeight:d=36,onSearch:T,loading:S,renderOption:J,multipleAutosize:Q=!1,showKeyboardHints:$e,labelPlacement:Ce,errorPlacement:X,labelWidth:Y,controlWidth:A,displayMode:Ee},Z)=>{const oe=c.useNiceAccessMode(re,V),Me=oe==="hidden";(oe==="disabled"||oe==="readOnly")&&(M=!0);const{t:$}=c.useNiceTranslation(),Ie=c.useComponentDisplayStyle("input",R),Le=c.useComponentDisplayClass("input",R),C=c.useControlId(V),me=c.useDisplayModeEdit({enabled:Ee,disabled:M}),[f,O]=s.useState(!1),[ee,te]=s.useState(""),[h,H]=s.useState(-1),[ve,De]=s.useState(0),xe=s.useRef(null),z=s.useRef(null),[_e,Te]=s.useState(null);s.useLayoutEffect(()=>{!S&&z.current&&Te(z.current.offsetWidth)},[S,b,R]);const[K,Oe]=s.useState(null);s.useLayoutEffect(()=>{l&&!Q&&z.current&&K==null&&Oe(z.current.offsetWidth)},[l,Q,K]);const Re=c.useNiceLookupSource(a??null,q??a?.keyField??"id",D??"name"),L=a?Re.options:(pe??[]).map(e=>typeof e=="string"?{value:e,label:e}:e),{popupRef:ne,coords:P,ready:ye,themeClass:se,portalTarget:ge}=ke(f,xe,()=>{O(!1),te("")}),r=s.useMemo(()=>b?Array.isArray(b)?b:[b]:[],[b]),o=s.useMemo(()=>{if(!ee&&!T||T)return L;const e=ee.toLowerCase();return L.filter(n=>n.label.toLowerCase().includes(e)||String(n.value).toLowerCase().includes(e))},[L,ee,T]),we=s.useMemo(()=>{const e=new Map;for(const n of o){const i=n.group||"";e.has(i)||e.set(i,[]),e.get(i).push(n)}return e},[o]),U=s.useCallback(e=>{if(l){const n=r.includes(e)?r.filter(i=>i!==e):[...r,e];u?.(n)}else u?.(e),O(!1),te("")},[l,r,u]),ie=s.useCallback(()=>{const e=o.findIndex(n=>r.includes(String(n.value)));H(e>=0?e:0),O(!0)},[o,r]),ae=s.useCallback(e=>H(n=>Math.max(0,Math.min(o.length-1,e(n)))),[o.length]),je=s.useCallback(e=>{const n=e.target instanceof HTMLInputElement;if(e.key==="Escape"){O(!1),te("");return}if((e.key==="Delete"||e.key==="Backspace")&&!n&&v&&r.length>0){e.preventDefault(),u?.(l?[]:"");return}if(e.key==="Enter"||e.key===" "&&!n){if(!f){ie(),e.preventDefault();return}h>=0&&o[h]&&(U(o[h].value),e.preventDefault());return}const i={ArrowDown:p=>p+1,ArrowUp:p=>p-1,PageDown:p=>p+10,PageUp:p=>p-10};n||(i.Home=()=>0,i.End=()=>o.length-1);const N=i[e.key];N&&(e.preventDefault(),f?ae(N):ie())},[f,h,o,U,ie,ae,v,r.length,u,l]),Ne=I||!!T,de=`${C}-listbox`,ue=e=>`${C}-opt-${e}`,be=f&&h>=0&&o[h]?ue(h):void 0;s.useLayoutEffect(()=>{const e=ne.current;if(!(!f||h<0||!e)){if(j){const n=h*d;n<e.scrollTop?e.scrollTop=n:n+d>e.scrollTop+e.clientHeight&&(e.scrollTop=n+d-e.clientHeight);return}e.querySelector(`[data-nice-option-index="${h}"]`)?.scrollIntoView?.({block:"nearest"})}},[f,h,j,d,ne]),c.useIntent(["navigate","activate"],e=>{if(e.source==="keyboard")return!1;if(e.intent==="activate"){const n=o[h];n&&!n.disabled&&U(String(n.value));return}if(e.direction!=="up"&&e.direction!=="down")return!1;ae(n=>n+(e.direction==="down"?1:-1))},{ref:ne,enabled:f&&Ne});const fe=s.useMemo(()=>r.length===0?null:l?r.map(e=>L.find(n=>n.value===e)?.label||e).join(", "):L.find(e=>e.value===r[0])?.label||r[0],[r,L,l]),Fe=s.useCallback(e=>{e.stopPropagation(),u?.(l?[]:"")},[u,l]),qe=s.useMemo(()=>[{key:"Enter",description:$("shortcuts.select","Select")},{key:"Space",description:$("shortcuts.openDropdown","Open dropdown")},c.COMMON_SHORTCUTS.moveUp,c.COMMON_SHORTCUTS.moveDown,c.COMMON_SHORTCUTS.cancel],[$]);return Me?null:t.jsxs("div",{className:`nice-field ${A==null?"nice-field--select-auto":""} nice-field--${w} ${Ce==="left"?"nice-field--label-left":""} ${S?"nice-field--loading":""} ${le||""}`,style:{...G,...Y!=null&&{"--nice-field-label-width":typeof Y=="number"?`${Y}px`:Y},...A!=null&&{"--nice-field-control-width":typeof A=="number"?`${A}px`:A},...S&&_e!=null&&{"--nice-select-locked-width":`${_e}px`}},"aria-busy":S||void 0,children:[y&&t.jsxs("label",{htmlFor:C,className:`nice-field__label ${B?"nice-field__label--required":""}`,children:[y,$e&&t.jsx(c.NiceKeyboardHint,{shortcuts:qe,size:"sm"})]}),t.jsxs("div",{className:"nice-field__control",children:[me.isDisplay?t.jsx(c.DisplayModeView,{value:fe,placeholder:F||$("controls.select","Select..."),disabled:M,onActivate:()=>{me.enterEdit(),O(!0)},ariaLabel:y??g}):t.jsxs("div",{className:"nice-select",ref:xe,children:[t.jsxs("button",{ref:e=>{z.current=e,typeof Z=="function"?Z(e):Z&&(Z.current=e)},type:"button",id:C,role:"combobox","aria-label":y?void 0:g,"aria-expanded":f,"aria-haspopup":"listbox","aria-controls":f?de:void 0,"aria-activedescendant":Ne?void 0:be,"aria-invalid":!!_,"aria-keyshortcuts":v&&r.length>0?"Delete":void 0,className:`nice-select__trigger nice-select__trigger--${w} nice-select--ds-${Le} ${f?"nice-select__trigger--open":""} ${_?"nice-select__trigger--error":""} ${M?"nice-select__trigger--disabled":""}`,style:{...Ie,...l&&!Q&&K!=null?{width:K,maxWidth:K,overflow:"hidden"}:{}},disabled:M,onClick:()=>f?O(!1):ie(),onKeyDown:je,children:[fe?t.jsx("span",{style:l&&!Q?{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:void 0,children:fe}):t.jsx("span",{className:"nice-select__placeholder",children:F||$("controls.select","Select...")}),t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[v&&r.length>0&&t.jsx("span",{className:"nice-input__clear",onClick:Fe,role:"presentation",children:t.jsx(c.NiceIcon,{name:"close",size:14})}),t.jsx("span",{className:`nice-select__chevron ${f?"nice-select__chevron--open":""}`,children:t.jsx(c.NiceIcon,{name:"chevron-down",size:16})})]})]}),f&&P&&ge&&He.createPortal(t.jsxs("div",{ref:ne,className:`nice-select__dropdown${se?` ${se}`:""}`,"data-theme":se==="nice-dark"?"dark":se==="nice-light"?"light":void 0,role:"listbox",id:de,"aria-multiselectable":l||void 0,style:{maxHeight:k,position:"fixed",left:P.left,top:P.top,width:P.width,minWidth:P.width,zIndex:1e3,opacity:ye?1:0,pointerEvents:ye?void 0:"none"},onScroll:j?e=>De(e.currentTarget.scrollTop):void 0,children:[(I||T)&&t.jsx("div",{className:"nice-select__search",children:t.jsx("input",{type:"text",value:ee,onChange:e=>{te(e.target.value),H(0),T?.(e.target.value)},onKeyDown:je,placeholder:$("controls.search","Search..."),"aria-label":$("controls.search","Search..."),"aria-controls":de,"aria-activedescendant":be,"aria-autocomplete":"list",autoFocus:!0})}),S&&t.jsx("div",{className:"nice-select__loading",children:t.jsx("div",{className:"nice-spinner nice-spinner--sm",style:{margin:"8px auto"}})}),!S&&o.length===0?t.jsx("div",{className:"nice-select__empty",children:m||$("controls.noResults","No results found")}):j&&!Array.from(we.keys()).some(e=>e!=="")?(()=>{const n=o.length*d,i=Math.max(0,Math.floor(ve/d)-3),N=Math.min(o.length,Math.ceil((ve+k)/d)+3),p=o.slice(i,N);return t.jsx("div",{style:{height:n,position:"relative"},children:p.map((x,Ae)=>{const W=i+Ae,ce=r.includes(x.value);return t.jsx("div",{id:ue(W),"data-nice-option-index":W,role:"option","aria-selected":ce,"aria-disabled":x.disabled||void 0,className:`nice-select__option ${ce?"nice-select__option--selected":""} ${W===h?"nice-select__option--highlighted":""} ${x.disabled?"nice-select__option--disabled":""}`,style:{position:"absolute",top:W*d,left:0,right:0,height:d,display:"flex",alignItems:"center",padding:"0 12px"},onClick:()=>!x.disabled&&U(String(x.value)),onMouseEnter:()=>H(W),children:J?J(x,ce):t.jsxs(t.Fragment,{children:[x.icon&&t.jsx("span",{children:x.icon}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:x.label}),x.description&&t.jsx("div",{className:"nice-select__option-desc",children:x.description})]}),ce&&t.jsx(c.NiceIcon,{name:"check",size:16,className:"nice-select__option-check"})]})},x.value)})})})():Array.from(we.entries()).map(([e,n])=>t.jsxs(s.Fragment,{children:[e&&t.jsx("div",{className:"nice-select__group-label",children:e}),n.map(i=>{const N=r.includes(i.value),p=o.indexOf(i);return t.jsx("div",{id:ue(p),"data-nice-option-index":p,role:"option","aria-selected":N,"aria-disabled":i.disabled||void 0,className:`nice-select__option ${N?"nice-select__option--selected":""} ${p===h?"nice-select__option--highlighted":""} ${i.disabled?"nice-select__option--disabled":""}`,onClick:()=>!i.disabled&&U(String(i.value)),onMouseEnter:()=>H(p),children:J?J(i,N):t.jsxs(t.Fragment,{children:[i.icon&&t.jsx("span",{children:i.icon}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{children:i.label}),i.description&&t.jsx("div",{className:"nice-select__option-desc",children:i.description})]}),N&&t.jsx(c.NiceIcon,{name:"check",size:16,className:"nice-select__option-check"})]})},i.value)})]},e))]}),ge)]}),S&&t.jsx("span",{className:"nice-field__spinner",children:t.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),X==="right"&&_&&t.jsx("div",{id:`${C}-error`,className:"nice-field__error",role:"alert",children:_}),X==="right"&&!_&&E&&t.jsx("div",{id:`${C}-helper`,className:"nice-field__helper",children:E})]}),X!=="right"&&_&&t.jsx("div",{id:`${C}-error`,className:"nice-field__error",role:"alert",children:_}),X!=="right"&&!_&&E&&t.jsx("div",{id:`${C}-helper`,className:"nice-field__helper",children:E})]})}),{displayName:"NiceSelect"}),Ke=Object.freeze(Object.defineProperty({__proto__:null,NiceSelect:Se},Symbol.toStringTag,{value:"Module"}));exports.NiceSelect=Se;exports.NiceSelect$1=Ke;exports.useAnchoredPopup=ke;