tintora 1.1.0 → 1.2.0

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 (93) hide show
  1. package/README.md +15 -0
  2. package/dist/Alert/Alert2.cjs +1 -0
  3. package/dist/Alert/Alert2.js +73 -0
  4. package/dist/Avatar/Avatar2.cjs +1 -0
  5. package/dist/Avatar/Avatar2.js +23 -0
  6. package/dist/Avatar/utils.cjs +1 -0
  7. package/dist/Avatar/utils.js +8 -0
  8. package/dist/BottomSheet/BottomSheet2.cjs +1 -0
  9. package/dist/BottomSheet/BottomSheet2.js +51 -0
  10. package/dist/Button/Button2.cjs +1 -0
  11. package/dist/Button/Button2.js +42 -0
  12. package/dist/Card/Card2.cjs +1 -0
  13. package/dist/Card/Card2.js +20 -0
  14. package/dist/Checkbox/Checkbox2.cjs +1 -0
  15. package/dist/Checkbox/Checkbox2.js +52 -0
  16. package/dist/Chip/Chip2.cjs +1 -0
  17. package/dist/Chip/Chip2.js +15 -0
  18. package/dist/Dot/Dot2.cjs +1 -0
  19. package/dist/Dot/Dot2.js +15 -0
  20. package/dist/Drawer/Drawer2.cjs +1 -0
  21. package/dist/Drawer/Drawer2.js +33 -0
  22. package/dist/IconButton/IconButton2.cjs +1 -0
  23. package/dist/IconButton/IconButton2.js +27 -0
  24. package/dist/Modal/Modal2.cjs +1 -0
  25. package/dist/Modal/Modal2.js +71 -0
  26. package/dist/Popover/Popover2.cjs +1 -0
  27. package/dist/Popover/Popover2.js +70 -0
  28. package/dist/ProgressBar/ProgressBar2.cjs +1 -0
  29. package/dist/ProgressBar/ProgressBar2.js +40 -0
  30. package/dist/Radio/Radio2.cjs +1 -0
  31. package/dist/Radio/Radio2.js +27 -0
  32. package/dist/Radio/RadioContext.cjs +1 -0
  33. package/dist/Radio/RadioContext.js +11 -0
  34. package/dist/Radio/RadioGroup.cjs +1 -0
  35. package/dist/Radio/RadioGroup.js +26 -0
  36. package/dist/SearchInput/SearchInput2.cjs +1 -0
  37. package/dist/SearchInput/SearchInput2.js +30 -0
  38. package/dist/Select/Select2.cjs +1 -0
  39. package/dist/Select/Select2.js +128 -0
  40. package/dist/Select/SelectContext.cjs +1 -0
  41. package/dist/Select/SelectContext.js +10 -0
  42. package/dist/Select/SelectOption.cjs +1 -0
  43. package/dist/Select/SelectOption.js +20 -0
  44. package/dist/SettingsRow/SettingsRow2.cjs +1 -0
  45. package/dist/SettingsRow/SettingsRow2.js +22 -0
  46. package/dist/Skeleton/Skeleton2.cjs +1 -0
  47. package/dist/Skeleton/Skeleton2.js +21 -0
  48. package/dist/Spinner/Spinner2.cjs +1 -0
  49. package/dist/Spinner/Spinner2.js +47 -0
  50. package/dist/Switch/Switch2.cjs +1 -0
  51. package/dist/Switch/Switch2.js +29 -0
  52. package/dist/Tabs/Tab.cjs +1 -0
  53. package/dist/Tabs/Tab.js +22 -0
  54. package/dist/Tabs/Tabs2.cjs +1 -0
  55. package/dist/Tabs/Tabs2.js +40 -0
  56. package/dist/Tabs/TabsContext.cjs +1 -0
  57. package/dist/Tabs/TabsContext.js +11 -0
  58. package/dist/Tag/Tag2.cjs +1 -0
  59. package/dist/Tag/Tag2.js +13 -0
  60. package/dist/TextField/TextField2.cjs +1 -0
  61. package/dist/TextField/TextField2.js +34 -0
  62. package/dist/Toast/Toast2.cjs +1 -0
  63. package/dist/Toast/Toast2.js +74 -0
  64. package/dist/Toast/ToastIcons.cjs +1 -0
  65. package/dist/Toast/ToastIcons.js +77 -0
  66. package/dist/Toggle/Toggle2.cjs +1 -0
  67. package/dist/Toggle/Toggle2.js +57 -0
  68. package/dist/Toggle/ToggleContext.cjs +1 -0
  69. package/dist/Toggle/ToggleContext.js +11 -0
  70. package/dist/Toggle/ToggleItem.cjs +1 -0
  71. package/dist/Toggle/ToggleItem.js +21 -0
  72. package/dist/Tooltip/Tooltip2.cjs +1 -0
  73. package/dist/Tooltip/Tooltip2.js +66 -0
  74. package/dist/hooks/useCheckedState.cjs +1 -0
  75. package/dist/hooks/useCheckedState.js +13 -0
  76. package/dist/hooks/useEscapeKey.cjs +1 -0
  77. package/dist/hooks/useEscapeKey.js +15 -0
  78. package/dist/hooks/useLatest.cjs +1 -0
  79. package/dist/hooks/useLatest.js +10 -0
  80. package/dist/hooks/useOutsidePress.cjs +1 -0
  81. package/dist/hooks/useOutsidePress.js +19 -0
  82. package/dist/hooks/useTopLayerPosition.cjs +1 -0
  83. package/dist/hooks/useTopLayerPosition.js +25 -0
  84. package/dist/index.cjs +1 -1
  85. package/dist/index.js +31 -1294
  86. package/dist/utils/clsx.cjs +1 -0
  87. package/dist/utils/clsx.d.ts +9 -0
  88. package/dist/utils/clsx.js +6 -0
  89. package/dist/utils/outside.cjs +1 -0
  90. package/dist/utils/outside.js +8 -0
  91. package/dist/utils/placement.cjs +1 -0
  92. package/dist/utils/placement.js +53 -0
  93. package/package.json +5 -4
package/dist/index.js CHANGED
@@ -1,1295 +1,32 @@
1
1
  import "./tintora.css";
2
- import { jsx as e, jsxs as t } from "react/jsx-runtime";
3
- import { cloneElement as n, createContext as r, useContext as i, useEffect as a, useId as o, useLayoutEffect as s, useRef as c, useState as l } from "react";
4
- //#region node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
5
- function u(e) {
6
- var t, n, r = "";
7
- if (typeof e == "string" || typeof e == "number") r += e;
8
- else if (typeof e == "object") {
9
- if (Array.isArray(e)) {
10
- var i = e.length;
11
- for (t = 0; t < i; t++) e[t] && (n = u(e[t])) && (r && (r += " "), r += n);
12
- } else for (n in e) e[n] && (r && (r += " "), r += n);
13
- }
14
- return r;
15
- }
16
- function d() {
17
- for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = u(e)) && (r && (r += " "), r += t);
18
- return r;
19
- }
20
- //#endregion
21
- //#region src/Alert/Alert.tsx
22
- var f = {
23
- info: /* @__PURE__ */ e("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 16v-4M12 8h.01" }),
24
- success: /* @__PURE__ */ e("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM8 12.5l2.7 2.7L16 9.8" }),
25
- warning: /* @__PURE__ */ e("path", { d: "M10.3 3.9L1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01" }),
26
- error: /* @__PURE__ */ e("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM15 9l-6 6M9 9l6 6" })
27
- }, p = ({ status: t }) => /* @__PURE__ */ e("svg", {
28
- width: "22",
29
- height: "22",
30
- viewBox: "0 0 24 24",
31
- fill: "none",
32
- stroke: `var(--tintora-status-${t}-fg)`,
33
- strokeWidth: "2",
34
- strokeLinecap: "round",
35
- strokeLinejoin: "round",
36
- "aria-hidden": "true",
37
- style: {
38
- flex: "0 0 auto",
39
- marginTop: 1
40
- },
41
- children: f[t]
42
- });
43
- function m({ status: n = "info", variant: r = "alert", title: i, children: a, action: o, onDismiss: s, className: c, ...l }) {
44
- return /* @__PURE__ */ t("div", {
45
- ...l,
46
- role: r === "alert" && n === "error" ? "alert" : "status",
47
- className: d("tintora-alert", r === "announcement" ? "tintora-alert--announcement" : `tintora-alert--${n}`, c),
48
- children: [
49
- r === "alert" && /* @__PURE__ */ e(p, { status: n }),
50
- /* @__PURE__ */ t("div", {
51
- className: d("tintora-alert__content", r === "announcement" && "tintora-alert__content--announcement"),
52
- children: [
53
- i && /* @__PURE__ */ e("span", {
54
- className: "tintora-alert__content__title",
55
- children: i
56
- }),
57
- a && /* @__PURE__ */ e("span", {
58
- className: "tintora-alert__content__sub-title",
59
- children: a
60
- }),
61
- o && /* @__PURE__ */ e("button", {
62
- type: "button",
63
- onClick: o.onClick,
64
- className: d("tintora-alert__content__action", r === "alert" && `tintora-alert__content__action--${n}`),
65
- children: o.label
66
- })
67
- ]
68
- }),
69
- r === "alert" && s && /* @__PURE__ */ e("button", {
70
- type: "button",
71
- "aria-label": "Dismiss",
72
- className: "tintora-alert__close",
73
- onClick: s,
74
- children: /* @__PURE__ */ e("svg", {
75
- width: "16",
76
- height: "16",
77
- viewBox: "0 0 24 24",
78
- fill: "none",
79
- stroke: "currentColor",
80
- strokeWidth: "2",
81
- strokeLinecap: "round",
82
- "aria-hidden": "true",
83
- children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" })
84
- })
85
- })
86
- ]
87
- });
88
- }
89
- //#endregion
90
- //#region src/Avatar/utils.ts
91
- function h(e) {
92
- if (!e.length) return "";
93
- let t = e.trim().split(/\s+/).map((e) => e.match(/\p{L}\p{M}*/u)?.[0]).filter((e) => !!e);
94
- return `${t[0] ?? ""}${t.length > 1 ? t.at(-1) ?? "" : ""}`.toLocaleUpperCase();
95
- }
96
- //#endregion
97
- //#region src/Avatar/Avatar.tsx
98
- function g({ name: t, src: n, size: r = "medium", className: i, ...a }) {
99
- let [o, s] = l(), c = !!n && n !== o;
100
- return /* @__PURE__ */ e("span", {
101
- role: "img",
102
- "aria-label": t,
103
- ...a,
104
- className: d("tintora-avatar", `tintora-avatar--${r}`, i),
105
- children: c ? /* @__PURE__ */ e("img", {
106
- src: n,
107
- alt: "",
108
- onError: () => s(n)
109
- }) : h(t)
110
- });
111
- }
112
- //#endregion
113
- //#region src/utils/outside.ts
114
- function _(e, t) {
115
- if (e.target !== e.currentTarget) return;
116
- let { left: n, right: r, top: i, bottom: a } = e.currentTarget.getBoundingClientRect();
117
- (e.clientX < n || e.clientX > r || e.clientY < i || e.clientY > a) && t();
118
- }
119
- //#endregion
120
- //#region src/Drawer/Drawer.tsx
121
- var v = (e) => typeof e == "number" ? `${e}px` : e;
122
- function y({ open: t, from: n = "right", width: r, height: i, children: o, onClose: s, className: l, ...u }) {
123
- let f = c(null);
124
- a(() => {
125
- let e = f.current;
126
- e && (t && !e.open ? (e.showModal(), e.querySelector("[data-autofocus]")?.focus()) : !t && e.open && e.close());
127
- }, [t]);
128
- let p = {
129
- ...u.style,
130
- ...r !== void 0 && { "--tintora-drawer-width": v(r) },
131
- ...i !== void 0 && { "--tintora-drawer-height": v(i) }
132
- };
133
- return /* @__PURE__ */ e("dialog", {
134
- ...u,
135
- ref: f,
136
- className: d("tintora-drawer", `tintora-drawer--from-${n}`, l),
137
- onCancel: (e) => {
138
- e.preventDefault(), s();
139
- },
140
- onClick: (e) => _(e, s),
141
- style: p,
142
- children: o
143
- });
144
- }
145
- //#endregion
146
- //#region src/BottomSheet/BottomSheet.tsx
147
- function b({ title: n, children: r, className: i, ...a }) {
148
- let s = o();
149
- return /* @__PURE__ */ t(y, {
150
- ...a,
151
- from: "bottom",
152
- "aria-labelledby": s,
153
- className: d("tintora-bottom-sheet", i),
154
- children: [
155
- /* @__PURE__ */ e("span", {
156
- className: "tintora-bottom-sheet__grabber",
157
- "aria-hidden": "true"
158
- }),
159
- /* @__PURE__ */ e("div", {
160
- id: s,
161
- className: "tintora-bottom-sheet__title",
162
- children: n
163
- }),
164
- r
165
- ]
166
- });
167
- }
168
- function x({ selected: n = !1, className: r, children: i, ...a }) {
169
- return /* @__PURE__ */ t("button", {
170
- type: "button",
171
- ...a,
172
- "aria-pressed": n,
173
- className: d("tintora-bottom-sheet__option", r),
174
- children: [/* @__PURE__ */ e("span", { children: i }), /* @__PURE__ */ e("svg", {
175
- className: "tintora-bottom-sheet__check",
176
- width: "18",
177
- height: "18",
178
- viewBox: "0 0 24 24",
179
- fill: "none",
180
- stroke: "currentColor",
181
- strokeWidth: "2.4",
182
- strokeLinecap: "round",
183
- strokeLinejoin: "round",
184
- "aria-hidden": "true",
185
- children: /* @__PURE__ */ e("path", { d: "M5 12.5l4.5 4.5L19 7.5" })
186
- })]
187
- });
188
- }
189
- //#endregion
190
- //#region src/Spinner/Spinner.tsx
191
- var S = {
192
- small: {
193
- width: 16,
194
- height: 16,
195
- strokeWidth: 3.5
196
- },
197
- medium: {
198
- width: 24,
199
- height: 24,
200
- strokeWidth: 3
201
- },
202
- large: {
203
- width: 40,
204
- height: 40,
205
- strokeWidth: 2.4
206
- }
207
- };
208
- function C({ size: n = "medium", color: r = "accent" }) {
209
- let { width: i, height: a, strokeWidth: o } = S[n];
210
- return /* @__PURE__ */ t("svg", {
211
- className: "tintora-spinner",
212
- width: i,
213
- height: a,
214
- viewBox: "0 0 24 24",
215
- fill: "none",
216
- role: "img",
217
- "aria-label": "Loading",
218
- children: [/* @__PURE__ */ e("circle", {
219
- cx: "12",
220
- cy: "12",
221
- r: "9",
222
- stroke: "currentColor",
223
- strokeOpacity: r === "accent" ? .25 : .35,
224
- strokeWidth: o
225
- }), /* @__PURE__ */ e("path", {
226
- d: "M21 12a9 9 0 0 0-9-9",
227
- stroke: r === "accent" ? "var(--tintora-control-fill)" : "currentColor",
228
- strokeWidth: o,
229
- strokeLinecap: "round"
230
- })]
231
- });
232
- }
233
- //#endregion
234
- //#region src/Button/Button.tsx
235
- function w({ children: n, className: r, variant: i, disabled: a, leadingIcon: o, trailingIcon: s, size: c = "medium", type: l = "button", loading: u = !1, fullWidth: f = !1, ...p }) {
236
- return /* @__PURE__ */ t("button", {
237
- type: l,
238
- className: d("tintora-button", `tintora-button--${i}`, `tintora-button--${c}`, {
239
- "tintora-button--leading-icon": !!o || u,
240
- "tintora-button--loading": u,
241
- "tintora-button--trailing-icon": !!s,
242
- "tintora-button--full-width": f
243
- }, r),
244
- disabled: a || u,
245
- "aria-busy": u || void 0,
246
- ...p,
247
- children: [
248
- u && /* @__PURE__ */ e("span", {
249
- className: "tintora-button__icon",
250
- "aria-hidden": "true",
251
- children: /* @__PURE__ */ e(C, {
252
- size: "small",
253
- color: "current"
254
- })
255
- }),
256
- !u && o && /* @__PURE__ */ e("span", {
257
- className: "tintora-button__icon",
258
- "aria-hidden": "true",
259
- children: o
260
- }),
261
- n,
262
- s && /* @__PURE__ */ e("span", {
263
- className: "tintora-button__icon",
264
- "aria-hidden": "true",
265
- children: s
266
- })
267
- ]
268
- });
269
- }
270
- //#endregion
271
- //#region src/Card/Card.tsx
272
- function T({ as: t = "article", variant: n = "surface", className: r, ...i }) {
273
- return /* @__PURE__ */ e(t, {
274
- ...i,
275
- className: d("tintora-card", `tintora-card--${n}`, r)
276
- });
277
- }
278
- function E({ selected: t = !1, className: n, ...r }) {
279
- return /* @__PURE__ */ e("button", {
280
- ...r,
281
- type: "button",
282
- "aria-pressed": t,
283
- className: d("tintora-card", "tintora-card--surface", "tintora-card--selectable", t && "tintora-card--selected", n)
284
- });
285
- }
286
- //#endregion
287
- //#region src/hooks/useCheckedState.ts
288
- function D({ checked: e, defaultChecked: t = !1, onCheckedChange: n }) {
289
- let [r, i] = l(t), a = e !== void 0;
290
- return {
291
- checked: a ? e : r,
292
- onChange: (e) => {
293
- a || i(e.target.checked), n?.(e.target.checked);
294
- }
295
- };
296
- }
297
- //#endregion
298
- //#region src/Checkbox/Checkbox.tsx
299
- function O({ checked: n, defaultChecked: r, onCheckedChange: i, indeterminate: a = !1, className: o, ...l }) {
300
- let u = c(null), f = D({
301
- checked: n,
302
- defaultChecked: r,
303
- onCheckedChange: i
304
- });
305
- return s(() => {
306
- u.current && (u.current.indeterminate = a);
307
- }), /* @__PURE__ */ t("span", {
308
- className: d("tintora-checkbox", o),
309
- children: [/* @__PURE__ */ e("input", {
310
- ...l,
311
- ref: u,
312
- type: "checkbox",
313
- className: "tintora-checkbox__input",
314
- checked: f.checked,
315
- onChange: f.onChange
316
- }), /* @__PURE__ */ t("span", {
317
- className: "tintora-checkbox__box",
318
- "aria-hidden": "true",
319
- children: [/* @__PURE__ */ e("svg", {
320
- className: "tintora-checkbox__check",
321
- width: "14",
322
- height: "14",
323
- viewBox: "0 0 24 24",
324
- fill: "none",
325
- strokeWidth: "3.2",
326
- strokeLinecap: "round",
327
- strokeLinejoin: "round",
328
- children: /* @__PURE__ */ e("path", { d: "M5 12.5l4.5 4.5L19 7.5" })
329
- }), /* @__PURE__ */ e("svg", {
330
- className: "tintora-checkbox__dash",
331
- width: "14",
332
- height: "14",
333
- viewBox: "0 0 24 24",
334
- fill: "none",
335
- strokeWidth: "3.2",
336
- strokeLinecap: "round",
337
- children: /* @__PURE__ */ e("path", { d: "M6 12h12" })
338
- })]
339
- })]
340
- });
341
- }
342
- //#endregion
343
- //#region src/Chip/Chip.tsx
344
- function k({ children: t, selected: n, className: r, "aria-pressed": i, ...a }) {
345
- return /* @__PURE__ */ e("button", {
346
- ...a,
347
- type: "button",
348
- className: d("tintora-chip", r),
349
- "aria-pressed": n ?? i,
350
- children: t
351
- });
352
- }
353
- //#endregion
354
- //#region src/Dot/Dot.tsx
355
- function A({ variant: t = "unread", label: n, className: r, ...i }) {
356
- return /* @__PURE__ */ e("span", {
357
- ...i,
358
- className: d("tintora-dot", `tintora-dot--${t}`, r),
359
- role: n ? "img" : void 0,
360
- "aria-label": n,
361
- "aria-hidden": !n || void 0
362
- });
363
- }
364
- //#endregion
365
- //#region src/IconButton/IconButton.tsx
366
- var j = {
367
- round: "secondary",
368
- field: "secondary",
369
- nav: "ghost"
370
- };
371
- function M({ icon: t, variant: n = "round", size: r, selected: i, className: a, ...o }) {
372
- let s = n === "round" ? r ?? "large" : void 0;
373
- return /* @__PURE__ */ e(w, {
374
- ...o,
375
- variant: j[n],
376
- "aria-current": i ? "page" : void 0,
377
- className: d("tintora-icon-button", `tintora-icon-button--${n}`, s && `tintora-icon-button--${s}`, a),
378
- ...s && { size: s },
379
- children: /* @__PURE__ */ e("span", {
380
- className: "tintora-icon-button__icon",
381
- "aria-hidden": "true",
382
- children: t
383
- })
384
- });
385
- }
386
- //#endregion
387
- //#region src/Modal/Modal.tsx
388
- var N = () => /* @__PURE__ */ e("svg", {
389
- width: "16",
390
- height: "16",
391
- viewBox: "0 0 24 24",
392
- fill: "none",
393
- stroke: "currentColor",
394
- strokeWidth: "2",
395
- strokeLinecap: "round",
396
- children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" })
397
- });
398
- function P({ open: n, onClose: r, title: i, description: s, icon: l, status: u = "info", actions: f, size: p = "md", align: m = "start", role: h = "dialog", closeButton: g = !0, className: v, children: y, ...b }) {
399
- let x = c(null), S = o(), C = o();
400
- return a(() => {
401
- let e = x.current;
402
- e && (n && !e.open ? (e.showModal(), e.querySelector("[data-autofocus]")?.focus()) : !n && e.open && e.close());
403
- }, [n]), /* @__PURE__ */ t("dialog", {
404
- ...b,
405
- ref: x,
406
- role: h,
407
- "aria-labelledby": S,
408
- "aria-describedby": s ? C : void 0,
409
- className: d("tintora-modal", `tintora-modal--${p}`, m === "center" && "tintora-modal--center", v),
410
- onCancel: (e) => {
411
- e.preventDefault(), r();
412
- },
413
- onClick: (e) => {
414
- h === "dialog" && _(e, r);
415
- },
416
- children: [
417
- l && /* @__PURE__ */ e("span", {
418
- className: d("tintora-modal__icon", `tintora-modal__icon--${u}`),
419
- "aria-hidden": "true",
420
- children: l
421
- }),
422
- /* @__PURE__ */ t("div", {
423
- className: "tintora-modal__text",
424
- children: [/* @__PURE__ */ e("h2", {
425
- id: S,
426
- className: "tintora-modal__title",
427
- children: i
428
- }), s && /* @__PURE__ */ e("p", {
429
- id: C,
430
- className: "tintora-modal__description",
431
- children: s
432
- })]
433
- }),
434
- g && /* @__PURE__ */ e(M, {
435
- className: "tintora-modal__close",
436
- size: "medium",
437
- "aria-label": "Close",
438
- icon: /* @__PURE__ */ e(N, {}),
439
- onClick: r
440
- }),
441
- y,
442
- f && /* @__PURE__ */ e("div", {
443
- className: "tintora-modal__actions",
444
- children: f
445
- })
446
- ]
447
- });
448
- }
449
- //#endregion
450
- //#region src/hooks/useLatest.ts
451
- function F(e) {
452
- let t = c(e);
453
- return a(() => {
454
- t.current = e;
455
- }, [e]), t;
456
- }
457
- //#endregion
458
- //#region src/hooks/useEscapeKey.ts
459
- function I(e, t) {
460
- let n = F(t);
461
- a(() => {
462
- if (!e) return;
463
- let t = (e) => {
464
- e.key === "Escape" && n.current();
465
- };
466
- return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
467
- }, [e, n]);
468
- }
469
- //#endregion
470
- //#region src/hooks/useOutsidePress.ts
471
- function L(e, t, n) {
472
- let r = F(n);
473
- a(() => {
474
- if (!e) return;
475
- let n = (e) => {
476
- t.current?.contains(e.target) || r.current();
477
- };
478
- return document.addEventListener("pointerdown", n), () => document.removeEventListener("pointerdown", n);
479
- }, [
480
- e,
481
- t,
482
- r
483
- ]);
484
- }
485
- //#endregion
486
- //#region src/hooks/useTopLayerPosition.ts
487
- function R(e, t, n, r) {
488
- let [i, a] = l(null);
489
- return s(() => {
490
- let r = t.current;
491
- if (!e || !r) {
492
- a(null);
493
- return;
494
- }
495
- r.showPopover();
496
- let i = () => a(n()), o = (e) => {
497
- r.contains(e.target) || i();
498
- };
499
- return i(), window.addEventListener("scroll", o, !0), window.addEventListener("resize", i), () => {
500
- window.removeEventListener("scroll", o, !0), window.removeEventListener("resize", i);
501
- };
502
- }, [
503
- e,
504
- t,
505
- ...r
506
- ]), i;
507
- }
508
- //#endregion
509
- //#region src/utils/placement.ts
510
- var z = {
511
- gap: 10,
512
- margin: 8,
513
- arrowInset: 12
514
- }, B = {
515
- top: "bottom",
516
- bottom: "top",
517
- left: "right",
518
- right: "left"
519
- }, V = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n));
520
- function H(e, t, n, r, { gap: i, margin: a }) {
521
- let o = (t) => {
522
- switch (t) {
523
- case "top": return e.top;
524
- case "bottom": return r.height - e.bottom;
525
- case "left": return e.left;
526
- case "right": return r.width - e.right;
527
- }
528
- }, s = (n === "top" || n === "bottom" ? t.height : t.width) + i + a, c = o(n);
529
- return c >= s || o(B[n]) <= c ? n : B[n];
530
- }
531
- function U(e, t, n, r = {
532
- width: window.innerWidth,
533
- height: window.innerHeight
534
- }, i = {}) {
535
- let a = {
536
- ...z,
537
- ...i
538
- }, { gap: o, margin: s, arrowInset: c } = a, l = H(e, t, n, r, a), u = l === "top" || l === "bottom", d, f;
539
- switch (l) {
540
- case "top":
541
- d = e.y - t.height - o, f = e.x + e.width / 2 - t.width / 2;
542
- break;
543
- case "bottom":
544
- d = e.y + e.height + o, f = e.x + e.width / 2 - t.width / 2;
545
- break;
546
- case "left":
547
- d = e.y + e.height / 2 - t.height / 2, f = e.x - t.width - o;
548
- break;
549
- case "right": d = e.y + e.height / 2 - t.height / 2, f = e.x + e.width + o;
550
- }
551
- u ? f = V(f, s, r.width - t.width - s) : d = V(d, s, r.height - t.height - s);
552
- let p = u ? e.x + e.width / 2 - f : e.y + e.height / 2 - d, m = u ? t.width : t.height;
553
- return {
554
- top: d,
555
- left: f,
556
- placement: l,
557
- arrowOffset: V(p, c, m - c)
558
- };
559
- }
560
- //#endregion
561
- //#region src/Popover/Popover.tsx
562
- var W = [
563
- "button:not([disabled])",
564
- "[href]",
565
- "input:not([disabled])",
566
- "select:not([disabled])",
567
- "textarea:not([disabled])",
568
- "[tabindex]:not([tabindex=\"-1\"])"
569
- ].join(", ");
570
- function G({ open: r, onOpenChange: i, trigger: l, title: u, children: f, role: p = "dialog", size: m = "md", placement: h = "bottom", className: g }) {
571
- let _ = o(), v = c(null), y = c(null), b = c(!1), x = () => i(!1);
572
- I(r, x), L(r, v, x);
573
- let S = (e) => {
574
- l.props.onClick?.(e), e.defaultPrevented || i(!r);
575
- }, C = R(r, y, () => {
576
- let e = y.current, t = v.current?.firstElementChild;
577
- return !e || !t ? null : U(t.getBoundingClientRect(), {
578
- width: e.offsetWidth,
579
- height: e.offsetHeight
580
- }, h, void 0, { gap: 12 });
581
- }, [
582
- h,
583
- u,
584
- f
585
- ]), w = C ? {
586
- top: C.top,
587
- left: C.left,
588
- "--tintora-popover-arrow-offset": `${C.arrowOffset}px`
589
- } : { visibility: "hidden" }, T = C !== null;
590
- return s(() => {
591
- let e = y.current;
592
- r && T && e && (e.querySelector("[data-autofocus]") ?? e.querySelector(W) ?? e).focus();
593
- }, [r, T]), a(() => {
594
- if (b.current && !r) {
595
- let e = document.activeElement;
596
- (!e || e === document.body) && v.current?.querySelector("*")?.focus();
597
- }
598
- b.current = r;
599
- }, [r]), /* @__PURE__ */ t("span", {
600
- ref: v,
601
- className: "tintora-popover-root",
602
- children: [n(l, {
603
- "aria-haspopup": "dialog",
604
- "aria-expanded": r,
605
- "aria-controls": r ? _ : void 0,
606
- onClick: S
607
- }), r && /* @__PURE__ */ e("div", {
608
- id: _,
609
- ref: y,
610
- role: p,
611
- "aria-label": u,
612
- popover: "manual",
613
- tabIndex: -1,
614
- className: d("tintora-popover", `tintora-popover--${m}`, `tintora-popover--${C?.placement ?? h}`, g),
615
- style: w,
616
- children: f
617
- })]
618
- });
619
- }
620
- //#endregion
621
- //#region src/ProgressBar/ProgressBar.tsx
622
- function K({ title: n, progress: r, indeterminate: i, valueLabel: a, className: s, "aria-label": c }) {
623
- let l = o(), u = i ? void 0 : Math.min(100, Math.max(0, Number.isFinite(r) ? r : 0)), f = u === 100, p = a ?? (i ? "Indeterminate" : `${u}%`);
624
- return /* @__PURE__ */ t("div", {
625
- className: d("tintora-progress-bar", s),
626
- children: [n && /* @__PURE__ */ t("div", {
627
- className: "tintora-progress-bar__header",
628
- children: [/* @__PURE__ */ e("span", {
629
- id: l,
630
- children: n
631
- }), /* @__PURE__ */ e("span", {
632
- className: "tintora-progress-bar__value",
633
- children: p
634
- })]
635
- }), /* @__PURE__ */ e("div", {
636
- role: "progressbar",
637
- "aria-label": c,
638
- "aria-labelledby": n ? l : void 0,
639
- "aria-valuemin": i ? void 0 : 0,
640
- "aria-valuemax": i ? void 0 : 100,
641
- "aria-valuenow": u,
642
- "aria-valuetext": a,
643
- className: "tintora-progress-bar__track",
644
- children: /* @__PURE__ */ e("div", {
645
- className: d("tintora-progress-bar__fill", {
646
- "tintora-progress-bar__fill--indeterminate": i,
647
- "tintora-progress-bar__fill--complete": f
648
- }),
649
- style: u === void 0 ? void 0 : { width: `${u}%` }
650
- })
651
- })]
652
- });
653
- }
654
- //#endregion
655
- //#region src/Radio/RadioContext.ts
656
- var q = r(null);
657
- function J() {
658
- let e = i(q);
659
- if (!e) throw Error("Radio must be rendered inside a RadioGroup");
660
- return e;
661
- }
662
- //#endregion
663
- //#region src/Radio/Radio.tsx
664
- function Y({ value: n, className: r, disabled: i, ...a }) {
665
- let o = J();
666
- return /* @__PURE__ */ t("span", {
667
- className: d("tintora-radio", r),
668
- children: [/* @__PURE__ */ e("input", {
669
- ...a,
670
- type: "radio",
671
- className: "tintora-radio__input",
672
- name: o.name,
673
- value: n,
674
- checked: o.value === n,
675
- disabled: i || o.disabled,
676
- onChange: () => o.select(n)
677
- }), /* @__PURE__ */ e("span", {
678
- className: "tintora-radio__circle",
679
- "aria-hidden": "true"
680
- })]
681
- });
682
- }
683
- //#endregion
684
- //#region src/Radio/RadioGroup.tsx
685
- function ee({ value: t, defaultValue: n, onValueChange: r, disabled: i = !1, name: a, className: s, ...c }) {
686
- let u = o(), [f, p] = l(n ?? null), m = t !== void 0, h = m ? t : f;
687
- return /* @__PURE__ */ e(q.Provider, {
688
- value: {
689
- name: a ?? u,
690
- value: h,
691
- select: (e) => {
692
- e !== h && (m || p(e), r?.(e));
693
- },
694
- disabled: i
695
- },
696
- children: /* @__PURE__ */ e("div", {
697
- ...c,
698
- role: "radiogroup",
699
- className: d("tintora-radio-group", s)
700
- })
701
- });
702
- }
703
- //#endregion
704
- //#region src/SearchInput/SearchInput.tsx
705
- function te({ className: n, disabled: r, ...i }) {
706
- return /* @__PURE__ */ t("label", {
707
- className: d("tintora-search-input", r && "tintora-search-input--disabled", n),
708
- children: [/* @__PURE__ */ t("svg", {
709
- className: "tintora-search-input__icon",
710
- viewBox: "0 0 24 24",
711
- fill: "none",
712
- stroke: "currentColor",
713
- strokeWidth: "2",
714
- strokeLinecap: "round",
715
- "aria-hidden": "true",
716
- children: [/* @__PURE__ */ e("circle", {
717
- cx: "11",
718
- cy: "11",
719
- r: "7"
720
- }), /* @__PURE__ */ e("path", { d: "M20 20l-3.5-3.5" })]
721
- }), /* @__PURE__ */ e("input", {
722
- ...i,
723
- type: "search",
724
- disabled: r,
725
- className: "tintora-search-input__input"
726
- })]
727
- });
728
- }
729
- //#endregion
730
- //#region src/Select/SelectContext.ts
731
- var X = r(null), ne = () => {
732
- let e = i(X);
733
- if (!e) throw Error("SelectOption must be rendered inside a Select");
734
- return e;
735
- };
736
- //#endregion
737
- //#region src/Select/SelectOption.tsx
738
- function re({ label: t, value: n, disabled: r }) {
739
- let { select: i, activate: a, optionId: o, value: s, activeValue: c } = ne();
740
- return /* @__PURE__ */ e("div", {
741
- id: o(n),
742
- role: "option",
743
- "aria-selected": s === n,
744
- "aria-disabled": r || void 0,
745
- className: d("tintora-select__option", c === n && "tintora-select__option--active"),
746
- onClick: () => i(n),
747
- onMouseMove: () => !r && a(n),
748
- children: t
749
- });
750
- }
751
- //#endregion
752
- //#region src/Select/Select.tsx
753
- var Z = 4;
754
- function ie({ defaultValue: n, options: r, disabled: i, value: s, placeholder: u, onValueChange: f, name: p, className: m, onClick: h, onKeyDown: g, onKeyUp: _, "aria-label": v, ...y }) {
755
- let b = o(), x = c(null), S = c(null), C = c(null), [w, T] = l(n ?? null), [E, D] = l(!1), [O, k] = l(-1), A = s !== void 0, j = A ? s : w, M = r.findIndex((e) => e.value === j), N = (e) => r[e]?.disabled !== !0, P = () => r.findIndex((e, t) => N(t)), F = (e, t) => {
756
- for (let n = e + t; n >= 0 && n < r.length; n += t) if (N(n)) return n;
757
- return e;
758
- }, I = () => {
759
- let e = F(r.length, -1);
760
- return e === r.length ? -1 : e;
761
- }, z = (e) => r.findIndex((t) => t.value === e), B = () => {
762
- k(M >= 0 && N(M) ? M : P()), D(!0);
763
- }, V = () => D(!1), H = (e) => {
764
- let t = z(e);
765
- t < 0 || !N(t) || (V(), e !== j && (A || T(e), f?.(e)));
766
- }, U = (e) => {
767
- if (g?.(e), e.defaultPrevented) return;
768
- let { key: t } = e;
769
- if (t === "Tab") return V();
770
- if (!E) {
771
- [
772
- "Enter",
773
- " ",
774
- "ArrowDown",
775
- "ArrowUp"
776
- ].includes(t) && (e.preventDefault(), B());
777
- return;
778
- }
779
- let n = {
780
- ArrowDown: () => O < 0 ? P() : F(O, 1),
781
- ArrowUp: () => O < 0 ? P() : F(O, -1),
782
- Home: P,
783
- End: I
784
- };
785
- t in n ? (e.preventDefault(), k(n[t]())) : t === "Enter" || t === " " ? (e.preventDefault(), O >= 0 ? H(r[O].value) : V()) : t === "Escape" && (e.preventDefault(), V());
786
- }, W = (e) => {
787
- _?.(e), e.key === " " && e.preventDefault();
788
- }, G = R(E, C, () => {
789
- let e = C.current, t = S.current;
790
- if (!e || !t) return null;
791
- let n = t.getBoundingClientRect(), r = e.offsetHeight, i = n.bottom + Z + r <= window.innerHeight, a = n.top - Z - r >= 0;
792
- return {
793
- top: i || !a ? n.bottom + Z : n.top - Z - r,
794
- left: n.left,
795
- minWidth: n.width
796
- };
797
- }, []), K = (e) => {
798
- h?.(e), !e.defaultPrevented && (E ? V() : B());
799
- };
800
- L(E, x, V), a(() => {
801
- E && O >= 0 && C.current?.children.item(O)?.scrollIntoView?.({ block: "nearest" });
802
- }, [E, O]);
803
- let q = (e) => `${b}-option-${z(e)}`, J = E ? r[O]?.value ?? null : null, Y = r[M]?.label;
804
- return /* @__PURE__ */ e(X.Provider, {
805
- value: {
806
- value: j,
807
- activeValue: J,
808
- select: H,
809
- optionId: q,
810
- activate: (e) => k(z(e))
811
- },
812
- children: /* @__PURE__ */ t("div", {
813
- ref: x,
814
- className: "tintora-select",
815
- children: [
816
- /* @__PURE__ */ t("button", {
817
- ...y,
818
- ref: S,
819
- type: "button",
820
- role: "combobox",
821
- "aria-label": v,
822
- "aria-haspopup": "listbox",
823
- "aria-expanded": E,
824
- "aria-controls": E ? b : void 0,
825
- "aria-activedescendant": J === null ? void 0 : q(J),
826
- disabled: i,
827
- className: d("tintora-select__trigger", m),
828
- onClick: K,
829
- onKeyDown: U,
830
- onKeyUp: W,
831
- children: [/* @__PURE__ */ e("span", {
832
- className: d("tintora-select__value", Y === void 0 && "tintora-select__value--placeholder"),
833
- children: Y ?? u
834
- }), /* @__PURE__ */ e("svg", {
835
- className: "tintora-select__chevron",
836
- width: "10",
837
- height: "10",
838
- viewBox: "0 0 24 24",
839
- fill: "none",
840
- stroke: "currentColor",
841
- strokeWidth: "3",
842
- strokeLinecap: "round",
843
- strokeLinejoin: "round",
844
- "aria-hidden": "true",
845
- children: /* @__PURE__ */ e("path", { d: "M6 9l6 6 6-6" })
846
- })]
847
- }),
848
- E && /* @__PURE__ */ e("div", {
849
- ref: C,
850
- id: b,
851
- role: "listbox",
852
- "aria-label": v,
853
- popover: "manual",
854
- className: "tintora-select__menu",
855
- style: G ?? {},
856
- onMouseDown: (e) => e.preventDefault(),
857
- children: r.map((t) => /* @__PURE__ */ e(re, { ...t }, t.value))
858
- }),
859
- p && /* @__PURE__ */ e("input", {
860
- type: "hidden",
861
- name: p,
862
- value: j ?? "",
863
- disabled: i
864
- })
865
- ]
866
- })
867
- });
868
- }
869
- //#endregion
870
- //#region src/SettingsRow/SettingsRow.tsx
871
- function ae({ title: n, description: r, children: i, controlPosition: a = "end", className: o, ...s }) {
872
- return /* @__PURE__ */ t("div", {
873
- ...s,
874
- className: d("tintora-settings-row", `tintora-settings-row--control-${a}`, r && "tintora-settings-row--described", o),
875
- children: [/* @__PURE__ */ t("div", {
876
- className: "tintora-settings-row__text",
877
- children: [/* @__PURE__ */ e("div", {
878
- className: "tintora-settings-row__title",
879
- children: n
880
- }), r && /* @__PURE__ */ e("div", {
881
- className: "tintora-settings-row__description",
882
- children: r
883
- })]
884
- }), i]
885
- });
886
- }
887
- //#endregion
888
- //#region src/Skeleton/Skeleton.tsx
889
- function oe({ width: t, height: n, className: r, style: i, ...a }) {
890
- let o = {
891
- ...t !== void 0 && { width: t },
892
- ...n !== void 0 && { height: n }
893
- };
894
- return /* @__PURE__ */ e("span", {
895
- ...a,
896
- "aria-hidden": "true",
897
- className: d("tintora-skeleton", r),
898
- style: {
899
- ...o,
900
- ...i
901
- }
902
- });
903
- }
904
- //#endregion
905
- //#region src/Switch/Switch.tsx
906
- function se({ checked: n, defaultChecked: r, onCheckedChange: i, className: a, ...o }) {
907
- let s = D({
908
- checked: n,
909
- defaultChecked: r,
910
- onCheckedChange: i
911
- });
912
- return /* @__PURE__ */ t("span", {
913
- className: d("tintora-switch", a),
914
- children: [/* @__PURE__ */ e("input", {
915
- ...o,
916
- type: "checkbox",
917
- role: "switch",
918
- className: "tintora-switch__input",
919
- checked: s.checked,
920
- onChange: s.onChange
921
- }), /* @__PURE__ */ e("span", {
922
- className: "tintora-switch__track",
923
- "aria-hidden": "true"
924
- })]
925
- });
926
- }
927
- //#endregion
928
- //#region src/Tabs/TabsContext.ts
929
- var Q = r(null);
930
- function ce() {
931
- let e = i(Q);
932
- if (!e) throw Error("Tab must be rendered inside Tabs");
933
- return e;
934
- }
935
- //#endregion
936
- //#region src/Tabs/Tab.tsx
937
- function le({ value: t, className: n, onClick: r, children: i, ...a }) {
938
- let o = ce(), s = o.value === t, c = (e) => {
939
- r?.(e), e.defaultPrevented || o.select(t);
940
- };
941
- return /* @__PURE__ */ e("button", {
942
- ...a,
943
- type: "button",
944
- role: "tab",
945
- "aria-selected": s,
946
- tabIndex: s ? 0 : -1,
947
- className: d("tintora-tab", n),
948
- onClick: c,
949
- children: i
950
- });
951
- }
952
- //#endregion
953
- //#region src/Tabs/Tabs.tsx
954
- var ue = [
955
- "ArrowLeft",
956
- "ArrowRight",
957
- "Home",
958
- "End"
959
- ];
960
- function de({ value: t, defaultValue: n, onValueChange: r, variant: i = "segmented", className: a, children: o, onKeyDown: s, ...c }) {
961
- let [u, f] = l(n), p = t !== void 0, m = p ? t : u, h = (e) => {
962
- e !== m && (p || f(e), r?.(e));
963
- }, g = (e) => {
964
- if (s?.(e), e.defaultPrevented || !ue.includes(e.key)) return;
965
- let t = Array.from(e.currentTarget.querySelectorAll("[role=\"tab\"]:not(:disabled)")), n = t.indexOf(e.target);
966
- if (n < 0) return;
967
- e.preventDefault();
968
- let r = t.length - 1, i = e.key === "Home" ? 0 : e.key === "End" ? r : (n + (e.key === "ArrowRight" ? 1 : -1) + t.length) % t.length;
969
- t[i].focus(), t[i].click();
970
- };
971
- return /* @__PURE__ */ e(Q.Provider, {
972
- value: {
973
- value: m,
974
- select: h
975
- },
976
- children: /* @__PURE__ */ e("div", {
977
- ...c,
978
- role: "tablist",
979
- className: d("tintora-tabs", `tintora-tabs--${i}`, a),
980
- onKeyDown: g,
981
- children: o
982
- })
983
- });
984
- }
985
- //#endregion
986
- //#region src/Tag/Tag.tsx
987
- function fe({ children: t, className: n, variant: r = "neutral", size: i = "medium", ...a }) {
988
- return /* @__PURE__ */ e("span", {
989
- ...a,
990
- className: d("tintora-tag", `tintora-tag--${r}`, `tintora-tag--${i}`, n),
991
- children: t
992
- });
993
- }
994
- //#endregion
995
- //#region src/TextField/TextField.tsx
996
- function pe({ label: n, hint: r, error: i, id: a, className: s, disabled: c, "aria-describedby": l, "aria-invalid": u, ...f }) {
997
- let p = o(), m = a ?? p, h = `${m}-message`, g = i ?? r;
998
- return /* @__PURE__ */ t("div", {
999
- className: d("tintora-textfield", c && "tintora-textfield--disabled", s),
1000
- children: [
1001
- /* @__PURE__ */ e("label", {
1002
- htmlFor: m,
1003
- className: "tintora-textfield__label",
1004
- children: n
1005
- }),
1006
- /* @__PURE__ */ e("input", {
1007
- ...f,
1008
- id: m,
1009
- disabled: c,
1010
- className: "tintora-textfield__input",
1011
- "aria-invalid": i ? !0 : u,
1012
- "aria-describedby": d(g && h, l) || void 0
1013
- }),
1014
- g && /* @__PURE__ */ e("span", {
1015
- id: h,
1016
- className: d("tintora-textfield__hint", i && "tintora-textfield__hint--error"),
1017
- children: g
1018
- })
1019
- ]
1020
- });
1021
- }
1022
- //#endregion
1023
- //#region src/Toast/ToastIcons.tsx
1024
- function me() {
1025
- return /* @__PURE__ */ e("svg", {
1026
- width: "20",
1027
- height: "20",
1028
- viewBox: "0 0 24 24",
1029
- fill: "none",
1030
- stroke: "var(--tintora-toast-icon-success)",
1031
- strokeWidth: "2",
1032
- strokeLinecap: "round",
1033
- strokeLinejoin: "round",
1034
- "aria-hidden": "true",
1035
- style: { flex: "0 0 auto" },
1036
- children: /* @__PURE__ */ e("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM8 12.5l2.7 2.7L16 9.8" })
1037
- });
1038
- }
1039
- function he() {
1040
- return /* @__PURE__ */ e("svg", {
1041
- width: "20",
1042
- height: "20",
1043
- viewBox: "0 0 24 24",
1044
- fill: "none",
1045
- stroke: "var(--tintora-toast-icon-error)",
1046
- strokeWidth: "2",
1047
- strokeLinecap: "round",
1048
- strokeLinejoin: "round",
1049
- "aria-hidden": "true",
1050
- style: { flex: "0 0 auto" },
1051
- children: /* @__PURE__ */ e("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM15 9l-6 6M9 9l6 6" })
1052
- });
1053
- }
1054
- function ge() {
1055
- return /* @__PURE__ */ e("svg", {
1056
- width: "20",
1057
- height: "20",
1058
- viewBox: "0 0 24 24",
1059
- fill: "none",
1060
- stroke: "var(--tintora-toast-icon-info)",
1061
- strokeWidth: "2",
1062
- strokeLinecap: "round",
1063
- strokeLinejoin: "round",
1064
- "aria-hidden": "true",
1065
- style: { flex: "0 0 auto" },
1066
- children: /* @__PURE__ */ e("path", { d: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 16v-4M12 8h.01" })
1067
- });
1068
- }
1069
- function _e() {
1070
- return /* @__PURE__ */ e("svg", {
1071
- width: "20",
1072
- height: "20",
1073
- viewBox: "0 0 24 24",
1074
- fill: "none",
1075
- stroke: "var(--tintora-toast-icon-warning)",
1076
- strokeWidth: "2",
1077
- strokeLinecap: "round",
1078
- strokeLinejoin: "round",
1079
- "aria-hidden": "true",
1080
- style: { flex: "0 0 auto" },
1081
- children: /* @__PURE__ */ e("path", { d: "M10.3 3.9L1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01" })
1082
- });
1083
- }
1084
- function ve() {
1085
- return /* @__PURE__ */ e("svg", {
1086
- width: "14",
1087
- height: "14",
1088
- viewBox: "0 0 24 24",
1089
- fill: "none",
1090
- stroke: "currentColor",
1091
- strokeWidth: "2.2",
1092
- strokeLinecap: "round",
1093
- "aria-hidden": "true",
1094
- children: /* @__PURE__ */ e("path", { d: "M18 6L6 18M6 6l12 12" })
1095
- });
1096
- }
1097
- //#endregion
1098
- //#region src/Toast/Toast.tsx
1099
- var ye = {
1100
- success: /* @__PURE__ */ e(me, {}),
1101
- error: /* @__PURE__ */ e(he, {}),
1102
- info: /* @__PURE__ */ e(ge, {}),
1103
- warning: /* @__PURE__ */ e(_e, {})
1104
- };
1105
- function be({ status: n, children: r, action: i, onDismiss: o, duration: s = 5e3, timerBar: u = !1, className: f, ...p }) {
1106
- let [m, h] = l(!1), [g, _] = l(!1), v = m || g, y = F(o), b = c(s);
1107
- a(() => {
1108
- b.current = s;
1109
- }, [s]), a(() => {
1110
- if (s <= 0 || v) return;
1111
- let e = Date.now(), t = setTimeout(() => y.current(), b.current);
1112
- return () => {
1113
- clearTimeout(t), b.current -= Date.now() - e;
1114
- };
1115
- }, [
1116
- s,
1117
- v,
1118
- y
1119
- ]);
1120
- let x = u && s > 0, S = { "--tintora-toast-animation-duration": `${s}ms` };
1121
- return /* @__PURE__ */ t("div", {
1122
- ...p,
1123
- role: "status",
1124
- className: d("tintora-toast", x && "tintora-toast--timer", v && "tintora-toast--paused", f),
1125
- onMouseEnter: (e) => {
1126
- p.onMouseEnter?.(e), h(!0);
1127
- },
1128
- onMouseLeave: (e) => {
1129
- p.onMouseLeave?.(e), h(!1);
1130
- },
1131
- onFocus: (e) => {
1132
- p.onFocus?.(e), _(!0);
1133
- },
1134
- onBlur: (e) => {
1135
- p.onBlur?.(e), e.currentTarget.contains(e.relatedTarget) || _(!1);
1136
- },
1137
- children: [
1138
- n && ye[n],
1139
- /* @__PURE__ */ e("span", {
1140
- className: "tintora-toast__message",
1141
- children: r
1142
- }),
1143
- i && /* @__PURE__ */ e("button", {
1144
- type: "button",
1145
- className: "tintora-toast__action",
1146
- onClick: i.onClick,
1147
- children: i.label
1148
- }),
1149
- /* @__PURE__ */ e("button", {
1150
- type: "button",
1151
- className: "tintora-toast__close",
1152
- "aria-label": "Dismiss",
1153
- onClick: o,
1154
- children: /* @__PURE__ */ e(ve, {})
1155
- }),
1156
- x && /* @__PURE__ */ e("span", {
1157
- className: "tintora-toast__progress",
1158
- style: S
1159
- })
1160
- ]
1161
- });
1162
- }
1163
- //#endregion
1164
- //#region src/Toggle/ToggleContext.ts
1165
- var $ = r(null);
1166
- function xe() {
1167
- let e = i($);
1168
- if (!e) throw Error("ToggleItem must be rendered inside a Toggle");
1169
- return e;
1170
- }
1171
- //#endregion
1172
- //#region src/Toggle/Toggle.tsx
1173
- function Se({ children: n, value: r, defaultValue: i, onValueChange: a, disabled: o = !1, className: u, ...f }) {
1174
- let [p, m] = l(i), h = r !== void 0, g = h ? r : p, _ = n.findIndex((e) => e.props.value === g), v = c(null), [y, b] = l({
1175
- x: 0,
1176
- width: 0
1177
- });
1178
- s(() => {
1179
- let e = v.current;
1180
- if (!e) return;
1181
- let t = () => {
1182
- let t = e.children.item(_);
1183
- if (!t) return;
1184
- let n = {
1185
- x: t.offsetLeft,
1186
- width: t.offsetWidth
1187
- };
1188
- b((e) => e.x === n.x && e.width === n.width ? e : n);
1189
- };
1190
- t();
1191
- let n = new ResizeObserver(t);
1192
- return n.observe(e), () => {
1193
- n.disconnect();
1194
- };
1195
- }, [_]);
1196
- let x = {
1197
- "--tintora-toggle-thumb-x": `${y.x}px`,
1198
- "--tintora-toggle-thumb-width": `${y.width}px`
1199
- };
1200
- return /* @__PURE__ */ e($.Provider, {
1201
- value: {
1202
- value: g,
1203
- select: (e) => {
1204
- e !== g && (h || m(e), a?.(e));
1205
- },
1206
- disabled: o
1207
- },
1208
- children: /* @__PURE__ */ t("div", {
1209
- ...f,
1210
- role: "group",
1211
- ref: v,
1212
- className: d("tintora-toggle", o && "tintora-toggle--disabled", u),
1213
- children: [n, /* @__PURE__ */ e("span", {
1214
- "aria-hidden": "true",
1215
- className: "tintora-toggle__thumb",
1216
- style: x
1217
- })]
1218
- })
1219
- });
1220
- }
1221
- //#endregion
1222
- //#region src/Toggle/ToggleItem.tsx
1223
- function Ce({ value: t, children: n, className: r, disabled: i, onClick: a, ...o }) {
1224
- let s = xe(), c = (e) => {
1225
- a?.(e), e.defaultPrevented || s.select(t);
1226
- };
1227
- return /* @__PURE__ */ e("button", {
1228
- ...o,
1229
- type: "button",
1230
- className: d("tintora-toggle__item", r),
1231
- "aria-pressed": s.value === t,
1232
- disabled: i || s.disabled,
1233
- onClick: c,
1234
- children: n
1235
- });
1236
- }
1237
- //#endregion
1238
- //#region src/Tooltip/Tooltip.tsx
1239
- var we = 100;
1240
- function Te({ title: r, content: i, shortcut: s, children: u, className: f, placement: p = "top" }) {
1241
- let m = o(), [h, g] = l(!1), _ = c(null), v = c(null), y = c(void 0), b = () => {
1242
- window.clearTimeout(y.current), g(!0);
1243
- }, x = () => {
1244
- window.clearTimeout(y.current), y.current = window.setTimeout(() => g(!1), we);
1245
- }, S = R(h, v, () => {
1246
- let e = v.current, t = _.current?.firstElementChild;
1247
- return !e || !t ? null : U(t.getBoundingClientRect(), {
1248
- width: e.offsetWidth,
1249
- height: e.offsetHeight
1250
- }, p);
1251
- }, [
1252
- p,
1253
- r,
1254
- i,
1255
- s
1256
- ]);
1257
- I(h, () => g(!1)), a(() => () => window.clearTimeout(y.current), []);
1258
- let C = S ? {
1259
- top: S.top,
1260
- left: S.left,
1261
- "--tintora-tooltip-arrow-offset": `${S.arrowOffset}px`
1262
- } : { visibility: "hidden" };
1263
- return /* @__PURE__ */ t("span", {
1264
- ref: _,
1265
- className: "tintora-tooltip",
1266
- onMouseEnter: b,
1267
- onMouseLeave: x,
1268
- onFocus: b,
1269
- onBlur: x,
1270
- children: [n(u, { "aria-describedby": d(u.props["aria-describedby"], h && m) || void 0 }), h && /* @__PURE__ */ t("div", {
1271
- id: m,
1272
- ref: v,
1273
- role: "tooltip",
1274
- popover: "manual",
1275
- style: C,
1276
- className: d("tintora-tooltip__content", `tintora-tooltip__content--${S?.placement ?? p}`, r && "tintora-tooltip__content--rich", f),
1277
- children: [
1278
- r && /* @__PURE__ */ e("span", {
1279
- className: "tintora-tooltip__title",
1280
- children: r
1281
- }),
1282
- /* @__PURE__ */ e("span", {
1283
- className: "tintora-tooltip__text",
1284
- children: i
1285
- }),
1286
- s && /* @__PURE__ */ e("kbd", {
1287
- className: "tintora-tooltip__shortcut",
1288
- children: s
1289
- })
1290
- ]
1291
- })]
1292
- });
1293
- }
1294
- //#endregion
1295
- export { m as Alert, g as Avatar, b as BottomSheet, x as BottomSheetOption, w as Button, T as Card, O as Checkbox, k as Chip, A as Dot, y as Drawer, M as IconButton, P as Modal, G as Popover, K as ProgressBar, Y as Radio, ee as RadioGroup, te as SearchInput, ie as Select, E as SelectableCard, ae as SettingsRow, oe as Skeleton, C as Spinner, se as Switch, le as Tab, de as Tabs, fe as Tag, pe as TextField, be as Toast, Se as Toggle, Ce as ToggleItem, Te as Tooltip };
2
+ /* empty css */
3
+ import { Alert as e } from "./Alert/Alert2.js";
4
+ import { Avatar as t } from "./Avatar/Avatar2.js";
5
+ import { Drawer as n } from "./Drawer/Drawer2.js";
6
+ import { BottomSheet as r, BottomSheetOption as i } from "./BottomSheet/BottomSheet2.js";
7
+ import { Spinner as a } from "./Spinner/Spinner2.js";
8
+ import { Button as o } from "./Button/Button2.js";
9
+ import { Card as s, SelectableCard as c } from "./Card/Card2.js";
10
+ import { Checkbox as l } from "./Checkbox/Checkbox2.js";
11
+ import { Chip as u } from "./Chip/Chip2.js";
12
+ import { Dot as d } from "./Dot/Dot2.js";
13
+ import { IconButton as f } from "./IconButton/IconButton2.js";
14
+ import { Modal as p } from "./Modal/Modal2.js";
15
+ import { Popover as m } from "./Popover/Popover2.js";
16
+ import { ProgressBar as h } from "./ProgressBar/ProgressBar2.js";
17
+ import { Radio as g } from "./Radio/Radio2.js";
18
+ import { RadioGroup as _ } from "./Radio/RadioGroup.js";
19
+ import { SearchInput as v } from "./SearchInput/SearchInput2.js";
20
+ import { Select as y } from "./Select/Select2.js";
21
+ import { SettingsRow as b } from "./SettingsRow/SettingsRow2.js";
22
+ import { Skeleton as x } from "./Skeleton/Skeleton2.js";
23
+ import { Switch as S } from "./Switch/Switch2.js";
24
+ import { Tab as C } from "./Tabs/Tab.js";
25
+ import { Tabs as w } from "./Tabs/Tabs2.js";
26
+ import { Tag as T } from "./Tag/Tag2.js";
27
+ import { TextField as E } from "./TextField/TextField2.js";
28
+ import { Toast as D } from "./Toast/Toast2.js";
29
+ import { Toggle as O } from "./Toggle/Toggle2.js";
30
+ import { ToggleItem as k } from "./Toggle/ToggleItem.js";
31
+ import { Tooltip as A } from "./Tooltip/Tooltip2.js";
32
+ export { e as Alert, t as Avatar, r as BottomSheet, i as BottomSheetOption, o as Button, s as Card, l as Checkbox, u as Chip, d as Dot, n as Drawer, f as IconButton, p as Modal, m as Popover, h as ProgressBar, g as Radio, _ as RadioGroup, v as SearchInput, y as Select, c as SelectableCard, b as SettingsRow, x as Skeleton, a as Spinner, S as Switch, C as Tab, w as Tabs, T as Tag, E as TextField, D as Toast, O as Toggle, k as ToggleItem, A as Tooltip };