@yourbestsoft/studio-screen-ui-kit 0.0.10 → 0.0.12

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.
@@ -0,0 +1,586 @@
1
+ import { jsx as s, jsxs as f, Fragment as A } from "react/jsx-runtime";
2
+ import i from "classnames";
3
+ import G, { forwardRef as b, createContext as I, useState as D, useRef as P, useEffect as w, useContext as x } from "react";
4
+ import { Eye as J, EyeOff as Q, X as U, Search as Y } from "lucide-react";
5
+ const Z = "_text_4m304_1", tt = "_tertiary_4m304_1", et = "_secondary_4m304_1", ot = "_primary_4m304_1", nt = "_fullWidth_4m304_50", st = "_buttonWithIcon_4m304_54", rt = "_content_4m304_61", ct = "_shortcut_4m304_70", at = "_disabled_4m304_82", C = {
6
+ text: Z,
7
+ tertiary: tt,
8
+ secondary: et,
9
+ primary: ot,
10
+ fullWidth: nt,
11
+ buttonWithIcon: st,
12
+ content: rt,
13
+ shortcut: ct,
14
+ disabled: at
15
+ }, it = ({
16
+ children: t,
17
+ className: e,
18
+ component: o = "button",
19
+ disabled: n,
20
+ fullWidth: c,
21
+ icon: a,
22
+ shortcut: r,
23
+ variant: d = "primary",
24
+ ...u
25
+ }, l) => {
26
+ const _ = /* @__PURE__ */ f("div", { className: C.buttonWithIcon, children: [
27
+ /* @__PURE__ */ f("div", { className: C.content, children: [
28
+ a,
29
+ t
30
+ ] }),
31
+ /* @__PURE__ */ s("div", { className: C.shortcut, children: r })
32
+ ] });
33
+ return /* @__PURE__ */ s(
34
+ o,
35
+ {
36
+ className: i(
37
+ C[d],
38
+ c && C.fullWidth,
39
+ n && C.disabled,
40
+ a && C.icon,
41
+ e
42
+ ),
43
+ children: a ? _ : t,
44
+ disabled: n,
45
+ ref: l,
46
+ ...u
47
+ }
48
+ );
49
+ }, Be = b(it), lt = "_content_23x5h_1", dt = "_header_23x5h_1", ut = "_root_23x5h_7", _t = "_contentAfterHeader_23x5h_22", E = {
50
+ content: lt,
51
+ header: dt,
52
+ root: ut,
53
+ contentAfterHeader: _t
54
+ }, q = b(
55
+ ({ className: t, ...e }, o) => /* @__PURE__ */ s("div", { className: i(E.root, t), ref: o, ...e })
56
+ ), ht = b(
57
+ ({ className: t, ignoreHeader: e, ...o }, n) => /* @__PURE__ */ s(
58
+ "div",
59
+ {
60
+ className: i(
61
+ E.content,
62
+ !e && E.contentAfterHeader,
63
+ t
64
+ ),
65
+ ref: n,
66
+ ...o
67
+ }
68
+ )
69
+ ), mt = b(
70
+ ({ className: t, ...e }, o) => /* @__PURE__ */ s("div", { className: i(E.header, t), ref: o, ...e })
71
+ ), Ve = Object.assign(q, {
72
+ Content: ht,
73
+ Header: mt,
74
+ Root: q
75
+ }), ft = "_root_1xfv8_1", bt = "_dropdownContent_1xfv8_6", gt = "_left_1xfv8_17", pt = "_center_1xfv8_21", Ct = "_right_1xfv8_26", vt = "_top_1xfv8_30", wt = "_bottom_1xfv8_34", yt = "_fixedPosition_1xfv8_38", N = {
76
+ root: ft,
77
+ dropdownContent: bt,
78
+ left: gt,
79
+ center: pt,
80
+ right: Ct,
81
+ top: vt,
82
+ bottom: wt,
83
+ fixedPosition: yt
84
+ }, B = I(
85
+ void 0
86
+ ), W = () => {
87
+ const t = x(B);
88
+ if (!t)
89
+ throw new Error("useDropDownContext must be used within a DropDown.Root");
90
+ return t;
91
+ }, k = [], xt = ({
92
+ children: t,
93
+ closeOnEsc: e = !0,
94
+ closeOnOutsideClick: o = !0,
95
+ defaultVisible: n = !1
96
+ }) => {
97
+ const [c, a] = D(n), r = P(null), d = () => {
98
+ c ? u() : (a(!0), r.current && k.push(r.current));
99
+ }, u = () => {
100
+ if (a(!1), r.current) {
101
+ const l = k.indexOf(r.current);
102
+ l !== -1 && k.splice(l, 1);
103
+ }
104
+ };
105
+ return w(() => {
106
+ if (!o) return;
107
+ const l = (_) => {
108
+ r.current && !r.current.contains(_.target) && u();
109
+ };
110
+ return document.addEventListener("mousedown", l), () => {
111
+ document.removeEventListener("mousedown", l);
112
+ };
113
+ }, [o]), w(() => {
114
+ if (!e) return;
115
+ const l = (_) => {
116
+ _.key === "Escape" && c && k[k.length - 1] === r.current && u();
117
+ };
118
+ return document.addEventListener("keydown", l), () => {
119
+ document.removeEventListener("keydown", l);
120
+ };
121
+ }, [e, c]), /* @__PURE__ */ s(B.Provider, { value: { close: u, toggle: d, visible: c }, children: /* @__PURE__ */ s("div", { ref: r, className: N.root, children: t }) });
122
+ }, kt = ({ children: t }) => {
123
+ const { toggle: e } = W();
124
+ return /* @__PURE__ */ s("div", { onClick: e, children: t });
125
+ }, Nt = ({
126
+ children: t,
127
+ className: e,
128
+ fixedPosition: o = !1,
129
+ horizontal: n = "left",
130
+ vertical: c = "bottom"
131
+ }) => {
132
+ const { visible: a } = W();
133
+ return a ? /* @__PURE__ */ s(
134
+ "div",
135
+ {
136
+ className: i(
137
+ N.dropdownContent,
138
+ N[n],
139
+ N[c],
140
+ { [N.fixedPosition]: o },
141
+ e
142
+ ),
143
+ children: t
144
+ }
145
+ ) : null;
146
+ }, Tt = ({ children: t, onClick: e }) => {
147
+ const { close: o } = W();
148
+ return /* @__PURE__ */ s("div", { onClick: (c) => {
149
+ e && e(c), o();
150
+ }, children: t });
151
+ }, je = { Content: Nt, Root: xt, Trigger: kt, Close: Tt }, Dt = (t, e = {}) => {
152
+ const {
153
+ enabled: o = !0,
154
+ preventDefault: n = !1,
155
+ stopPropagation: c = !1
156
+ } = e;
157
+ w(() => {
158
+ if (!o) return;
159
+ const a = (r) => {
160
+ n && r.preventDefault(), c && r.stopPropagation(), t.forEach((d) => d(r));
161
+ };
162
+ return window.addEventListener("keydown", a), () => {
163
+ window.removeEventListener("keydown", a);
164
+ };
165
+ }, [t, o, n, c]);
166
+ }, Et = (t, e, o = {}) => (n) => {
167
+ const {
168
+ ctrlKey: c = !1,
169
+ shiftKey: a = !1,
170
+ altKey: r = !1,
171
+ metaKey: d = !1
172
+ } = o;
173
+ n.key === t && n.ctrlKey === c && n.shiftKey === a && n.altKey === r && n.metaKey === d && e(n);
174
+ }, St = (t) => Et("Escape", t), $t = (t, e = !0) => (o) => {
175
+ if (!e || o.key !== "Tab" || !t.current) return;
176
+ const n = t.current.querySelectorAll(
177
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
178
+ ), c = n[0], a = n[n.length - 1];
179
+ o.shiftKey ? document.activeElement === c && (o.preventDefault(), a?.focus()) : document.activeElement === a && (o.preventDefault(), c?.focus());
180
+ }, Ot = "_dialogOverlay_1h2c4_1", Rt = "_dialogTrigger_1h2c4_13", It = "_dialogContent_1h2c4_21", Pt = "_dialogClose_1h2c4_34", Wt = "_dialogTitle_1h2c4_42", Ht = "_dialogSeparator_1h2c4_47", y = {
181
+ dialogOverlay: Ot,
182
+ dialogTrigger: Rt,
183
+ dialogContent: It,
184
+ dialogClose: Pt,
185
+ dialogTitle: Wt,
186
+ dialogSeparator: Ht
187
+ }, S = G.createContext(null), Lt = ({
188
+ children: t,
189
+ isOpen: e,
190
+ onStateChange: o
191
+ }) => {
192
+ const n = P(null), [c, a] = D(!1), r = e !== void 0 ? e : c, d = (l) => {
193
+ e === void 0 && a(l), o && o(l);
194
+ }, u = [
195
+ St(() => d(!1)),
196
+ $t(n, r)
197
+ ];
198
+ return Dt(u, { enabled: r }), w(() => (r ? document.body.style.overflow = "hidden" : document.body.style.overflow = "unset", () => {
199
+ document.body.style.overflow = "unset";
200
+ }), [r]), w(() => {
201
+ if (r && n.current) {
202
+ const _ = n.current.querySelectorAll(
203
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
204
+ )[0];
205
+ _ && _.focus();
206
+ }
207
+ }, [r]), /* @__PURE__ */ s(S.Provider, { value: { dialogRef: n, isOpen: r, setIsOpen: d }, children: /* @__PURE__ */ s("div", { children: t }) });
208
+ }, qt = ({
209
+ as: t,
210
+ children: e,
211
+ ...o
212
+ }) => {
213
+ const n = x(S);
214
+ if (!n) throw new Error("Trigger must be used within a Dialog.Root");
215
+ const { setIsOpen: c } = n;
216
+ return /* @__PURE__ */ s(
217
+ t || "button",
218
+ {
219
+ onClick: () => {
220
+ c(!0);
221
+ },
222
+ ...o,
223
+ className: y.dialogTrigger,
224
+ role: t && t !== "button" ? "button" : void 0,
225
+ children: e
226
+ }
227
+ );
228
+ }, Kt = b(
229
+ ({ children: t, classNameOverlay: e, className: o, closeOnBackdropClick: n = !0 }, c) => {
230
+ const a = x(S);
231
+ if (!a) throw new Error("Content must be used within a Dialog.Root");
232
+ const { dialogRef: r, isOpen: d, setIsOpen: u } = a, l = (_) => {
233
+ n && _.target === _.currentTarget && u(!1);
234
+ };
235
+ return d ? /* @__PURE__ */ s(
236
+ "div",
237
+ {
238
+ ref: r,
239
+ className: i(y.dialogOverlay, e),
240
+ onClick: l,
241
+ role: "dialog",
242
+ "aria-modal": "true",
243
+ children: /* @__PURE__ */ s(
244
+ "div",
245
+ {
246
+ className: i(y.dialogContent, o),
247
+ onClick: (_) => _.stopPropagation(),
248
+ children: t
249
+ }
250
+ )
251
+ }
252
+ ) : null;
253
+ }
254
+ ), Ft = ({
255
+ as: t,
256
+ children: e,
257
+ ...o
258
+ }) => {
259
+ const n = x(S);
260
+ if (!n) throw new Error("Close must be used within a Dialog.Root");
261
+ const { setIsOpen: c } = n;
262
+ return /* @__PURE__ */ s(
263
+ t || "button",
264
+ {
265
+ onClick: () => {
266
+ c(!1);
267
+ },
268
+ ...o,
269
+ className: i(y.dialogClose, o.className),
270
+ role: t && t !== "button" ? "button" : void 0,
271
+ children: e
272
+ }
273
+ );
274
+ }, At = ({ children: t, className: e }) => /* @__PURE__ */ s("h2", { className: i(y.dialogTitle, e), children: t }), Bt = ({}) => /* @__PURE__ */ s("div", { className: y.dialogSeparator }), Me = {
275
+ Close: Ft,
276
+ Content: Kt,
277
+ Root: Lt,
278
+ Separator: Bt,
279
+ Title: At,
280
+ Trigger: qt
281
+ }, Vt = "_sidebar_dg2au_12", jt = "_trigger_dg2au_16", Mt = "_content_dg2au_21", zt = "_left_dg2au_34", Xt = "_open_dg2au_38", Gt = "_right_dg2au_42", Jt = "_bottom_dg2au_50", Qt = "_top_dg2au_63", v = {
282
+ sidebar: Vt,
283
+ trigger: jt,
284
+ content: Mt,
285
+ left: zt,
286
+ open: Xt,
287
+ right: Gt,
288
+ bottom: Jt,
289
+ top: Qt
290
+ }, V = I(
291
+ void 0
292
+ ), H = () => {
293
+ const t = x(V);
294
+ if (!t)
295
+ throw new Error("useSidebarContext must be used within a SidebarProvider");
296
+ return t;
297
+ }, Ut = ({ children: t, isOpen: e, setIsOpen: o }) => /* @__PURE__ */ s(
298
+ V.Provider,
299
+ {
300
+ value: {
301
+ isOpen: e,
302
+ setIsOpen: () => o(!e)
303
+ },
304
+ children: t
305
+ }
306
+ ), Yt = ({ children: t }) => {
307
+ const { setIsOpen: e } = H(), o = (n) => {
308
+ n.preventDefault(), e(!0);
309
+ };
310
+ return /* @__PURE__ */ s("div", { className: v.trigger, onClick: o, children: t });
311
+ }, Zt = ({
312
+ children: t,
313
+ className: e,
314
+ closeOnOutsideClick: o = !0,
315
+ position: n = "right"
316
+ }) => {
317
+ const { isOpen: c, setIsOpen: a } = H(), r = P(null);
318
+ return w(() => {
319
+ if (!o) return;
320
+ const d = (u) => {
321
+ r.current && !r.current.contains(u.target) && a(!1);
322
+ };
323
+ return c && document.addEventListener("mousedown", d), () => {
324
+ document.removeEventListener("mousedown", d);
325
+ };
326
+ }, [c, a, o]), /* @__PURE__ */ s(
327
+ "div",
328
+ {
329
+ ref: r,
330
+ className: i(
331
+ v[n],
332
+ v.content,
333
+ {
334
+ [v.close]: !c,
335
+ [v.open]: c
336
+ },
337
+ e
338
+ ),
339
+ children: t
340
+ }
341
+ );
342
+ }, te = ({ children: t }) => {
343
+ const { setIsOpen: e } = H(), o = (n) => {
344
+ n.preventDefault(), e(!1);
345
+ };
346
+ return /* @__PURE__ */ s("button", { className: v.close, onClick: o, children: t });
347
+ }, ze = {
348
+ Close: te,
349
+ Content: Zt,
350
+ Root: Ut,
351
+ Trigger: Yt
352
+ }, ee = "_switcher_k6tdq_1", oe = "_buttons_k6tdq_6", ne = "_separator_k6tdq_10", R = {
353
+ switcher: ee,
354
+ buttons: oe,
355
+ separator: ne
356
+ }, Xe = b(
357
+ ({
358
+ className: t,
359
+ component: e,
360
+ componentValues: o,
361
+ containerProps: n,
362
+ onChange: c,
363
+ selectedValue: a,
364
+ slot: r
365
+ }, d) => {
366
+ const [u, l] = D(
367
+ a || o[0].value
368
+ ), _ = (m) => {
369
+ l(m), c && c(m);
370
+ };
371
+ return /* @__PURE__ */ f("div", { ref: d, className: R.switcher, ...n, children: [
372
+ /* @__PURE__ */ s("div", { className: i(R.buttons, t), children: o.map((m, p) => /* @__PURE__ */ s(
373
+ e,
374
+ {
375
+ ...m,
376
+ selected: u === m.value,
377
+ onClick: () => _(m.value)
378
+ },
379
+ p
380
+ )) }),
381
+ r && /* @__PURE__ */ f(A, { children: [
382
+ /* @__PURE__ */ s("div", { className: R.separator }),
383
+ r
384
+ ] })
385
+ ] });
386
+ }
387
+ ), se = "_root_1b0i5_13", re = "_header_1b0i5_19", ce = "_footer_1b0i5_23", ae = "_row_1b0i5_28", ie = "_body_1b0i5_41", le = "_head_1b0i5_19", de = "_cell_1b0i5_48", ue = "_caption_1b0i5_65", _e = "_storiesFooterCellOne_1b0i5_70", he = "_storiesFooterCellTwo_1b0i5_73", g = {
388
+ root: se,
389
+ header: re,
390
+ footer: ce,
391
+ row: ae,
392
+ body: ie,
393
+ head: le,
394
+ cell: de,
395
+ caption: ue,
396
+ storiesFooterCellOne: _e,
397
+ storiesFooterCellTwo: he
398
+ }, K = ({ children: t, className: e }) => /* @__PURE__ */ s("table", { className: i(g.root, e), children: t }), me = ({ children: t, className: e }) => /* @__PURE__ */ s("caption", { className: i(g.caption, e), children: t }), fe = ({ children: t, className: e }) => /* @__PURE__ */ s("thead", { className: i(g.header, e), children: t }), be = ({
399
+ children: t,
400
+ className: e,
401
+ onBlur: o,
402
+ onClick: n,
403
+ onDoubleClick: c
404
+ }) => /* @__PURE__ */ s(
405
+ "tr",
406
+ {
407
+ className: i(g.row, e),
408
+ onClick: n,
409
+ onDoubleClick: c,
410
+ onBlur: o,
411
+ children: t
412
+ }
413
+ ), ge = ({ children: t, className: e }) => /* @__PURE__ */ s("th", { className: i(g.head, e), children: t }), pe = ({ children: t, className: e }) => /* @__PURE__ */ s("tbody", { className: i(g.body, e), children: t }), Ce = ({ children: t, className: e }) => /* @__PURE__ */ s("td", { className: i(g.cell, e), children: t }), ve = ({ children: t, className: e }) => /* @__PURE__ */ s("tfoot", { className: i(g.footer, e), children: t }), Ge = Object.assign(K, {
414
+ Body: pe,
415
+ Caption: me,
416
+ Cell: Ce,
417
+ Footer: ve,
418
+ Head: ge,
419
+ Header: fe,
420
+ Root: K,
421
+ Row: be
422
+ }), we = "_inputContainer_iqbs3_1", ye = "_input_iqbs3_1", xe = "_inputSearch_iqbs3_40", ke = "_error_iqbs3_43", Ne = "_button_iqbs3_58", Te = "_buttonWithLabel_iqbs3_68", De = "_resetSearchValue_iqbs3_73", Ee = "_searchOutline_iqbs3_80", Se = "_errorMessage_iqbs3_87", h = {
423
+ inputContainer: we,
424
+ input: ye,
425
+ inputSearch: xe,
426
+ error: ke,
427
+ button: Ne,
428
+ buttonWithLabel: Te,
429
+ resetSearchValue: De,
430
+ searchOutline: Ee,
431
+ errorMessage: Se
432
+ }, Je = b(({ className: t, error: e, label: o, onChange: n, required: c, ...a }, r) => {
433
+ const [d, u] = D(!1), l = (p) => n(p.currentTarget.value), _ = i(h.input, e && h.error, t);
434
+ let m;
435
+ if (!a.as || a.as === "input") {
436
+ const { inputType: p, ...z } = a, $ = p === "search", L = p === "password", X = d ? "text" : "password";
437
+ m = /* @__PURE__ */ f(A, { children: [
438
+ /* @__PURE__ */ s(
439
+ "input",
440
+ {
441
+ className: i(_, $ && h.inputSearch),
442
+ onChange: l,
443
+ ref: r,
444
+ type: L ? X : p,
445
+ ...z
446
+ }
447
+ ),
448
+ L && (d ? /* @__PURE__ */ s(
449
+ J,
450
+ {
451
+ strokeWidth: 2.5,
452
+ width: 20,
453
+ className: i(h.button, o && h.buttonWithLabel),
454
+ onClick: () => u((O) => !O)
455
+ }
456
+ ) : /* @__PURE__ */ s(
457
+ Q,
458
+ {
459
+ strokeWidth: 2.5,
460
+ width: 20,
461
+ className: i(h.button, o && h.buttonWithLabel),
462
+ onClick: () => u((O) => !O)
463
+ }
464
+ )),
465
+ $ && a.value && /* @__PURE__ */ s(
466
+ U,
467
+ {
468
+ onClick: () => n(""),
469
+ className: i(
470
+ h.button,
471
+ o && h.buttonWithLabel,
472
+ h.resetSearchValue
473
+ ),
474
+ strokeWidth: 2.5,
475
+ size: 24
476
+ }
477
+ ),
478
+ $ && /* @__PURE__ */ s(
479
+ Y,
480
+ {
481
+ className: i(
482
+ h.searchOutline,
483
+ o && h.searchOutlineWithLabel
484
+ ),
485
+ size: 20
486
+ }
487
+ )
488
+ ] });
489
+ }
490
+ return a.as === "textarea" && (m = /* @__PURE__ */ s(
491
+ "textarea",
492
+ {
493
+ className: _,
494
+ onChange: l,
495
+ ref: r,
496
+ ...a
497
+ }
498
+ )), /* @__PURE__ */ f("div", { className: h.root, children: [
499
+ /* @__PURE__ */ f("span", { className: h.title, children: [
500
+ o,
501
+ c && /* @__PURE__ */ s("span", { className: h.titleError, children: "*" })
502
+ ] }),
503
+ /* @__PURE__ */ s("div", { className: h.inputContainer, children: m }),
504
+ /* @__PURE__ */ s("div", { className: h.errorMessage, children: e })
505
+ ] });
506
+ }), j = I(void 0), Qe = ({ children: t }) => {
507
+ const e = M() || "system", [o, n] = D(e);
508
+ return /* @__PURE__ */ s(j.Provider, { value: { setTheme: n, theme: o }, children: t });
509
+ }, Ue = () => {
510
+ const t = x(j);
511
+ if (!t)
512
+ throw new Error("useTheme must be used within a ThemeProvider");
513
+ return $e(t.theme), t;
514
+ }, $e = (t) => {
515
+ const e = M();
516
+ Oe(t || e);
517
+ }, Oe = (t) => {
518
+ const e = window.matchMedia("(prefers-color-scheme: dark)");
519
+ if (t === "system") {
520
+ const o = e.matches ? "dark" : "light";
521
+ localStorage.setItem("theme", t), F(o);
522
+ } else
523
+ localStorage.setItem("theme", t), F(t);
524
+ }, F = (t) => {
525
+ document.documentElement.setAttribute("data-theme", t);
526
+ }, M = () => {
527
+ const t = localStorage.getItem("theme");
528
+ if (t) return t;
529
+ }, Re = "_root_17w6h_1", Ie = "_icon_17w6h_11", Pe = "_active_17w6h_27", We = "_disabled_17w6h_31", He = "_keybinding_17w6h_44", T = {
530
+ root: Re,
531
+ icon: Ie,
532
+ active: Pe,
533
+ disabled: We,
534
+ keybinding: He
535
+ }, Ye = b(
536
+ (t, e) => {
537
+ const { classes: o, disabled: n, icon: c, isActive: a, keybinding: r, onClick: d, title: u } = t, l = Le(o, a, n);
538
+ return /* @__PURE__ */ f("label", { className: T.root, title: u, children: [
539
+ /* @__PURE__ */ s(
540
+ "div",
541
+ {
542
+ className: l.icon,
543
+ ref: e,
544
+ tabIndex: n ? -1 : 0,
545
+ role: "button",
546
+ "aria-pressed": a,
547
+ "aria-disabled": n,
548
+ onClick: n ? void 0 : d,
549
+ children: c
550
+ }
551
+ ),
552
+ r && /* @__PURE__ */ s("span", { className: l.keybinding, children: r })
553
+ ] });
554
+ }
555
+ ), Le = (t, e, o) => ({
556
+ icon: i(
557
+ T.icon,
558
+ {
559
+ [T.active]: e,
560
+ [T.disabled]: o
561
+ },
562
+ t?.icon
563
+ ),
564
+ keybinding: i(T.keybinding, t?.keybinding)
565
+ });
566
+ export {
567
+ Be as B,
568
+ q as C,
569
+ je as D,
570
+ V as S,
571
+ Ge as T,
572
+ Ue as a,
573
+ it as b,
574
+ ht as c,
575
+ mt as d,
576
+ Ve as e,
577
+ Me as f,
578
+ H as g,
579
+ ze as h,
580
+ Xe as i,
581
+ Je as j,
582
+ Ye as k,
583
+ Qe as l,
584
+ Dt as u
585
+ };
586
+ //# sourceMappingURL=ToolIconButton-BezvcpMB.js.map