@anguszhu/kroma-ui 0.1.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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +185 -0
  3. package/dist/core/focusTrap.d.ts +3 -0
  4. package/dist/core/toastTimer.d.ts +13 -0
  5. package/dist/core/types.d.ts +35 -0
  6. package/dist/kroma-react.cjs +2 -0
  7. package/dist/kroma-react.cjs.map +1 -0
  8. package/dist/kroma-react.d.ts +2 -0
  9. package/dist/kroma-react.js +600 -0
  10. package/dist/kroma-react.js.map +1 -0
  11. package/dist/kroma-ui.css +804 -0
  12. package/dist/kroma-vue.cjs +2 -0
  13. package/dist/kroma-vue.cjs.map +1 -0
  14. package/dist/kroma-vue.d.ts +2 -0
  15. package/dist/kroma-vue.js +706 -0
  16. package/dist/kroma-vue.js.map +1 -0
  17. package/dist/kroma.css +804 -0
  18. package/dist/react/components/KrButton.d.ts +7 -0
  19. package/dist/react/components/KrChevron.d.ts +3 -0
  20. package/dist/react/components/KrDialog.d.ts +14 -0
  21. package/dist/react/components/KrEmpty.d.ts +7 -0
  22. package/dist/react/components/KrMenuItem.d.ts +7 -0
  23. package/dist/react/components/KrOverlay.d.ts +11 -0
  24. package/dist/react/components/KrSearchInput.d.ts +11 -0
  25. package/dist/react/components/KrSection.d.ts +6 -0
  26. package/dist/react/components/KrSelectGroup.d.ts +21 -0
  27. package/dist/react/components/KrSelectItem.d.ts +17 -0
  28. package/dist/react/components/KrSwitch.d.ts +7 -0
  29. package/dist/react/components/KrTextField.d.ts +10 -0
  30. package/dist/react/components/KrToast.d.ts +15 -0
  31. package/dist/react/components/KrToggleRow.d.ts +10 -0
  32. package/dist/react/hooks/useCssTransition.d.ts +12 -0
  33. package/dist/react/index.d.ts +28 -0
  34. package/dist/react/utils/cx.d.ts +1 -0
  35. package/dist/vue/components/KrButton.vue.d.ts +20 -0
  36. package/dist/vue/components/KrChevron.vue.d.ts +3 -0
  37. package/dist/vue/components/KrDialog.vue.d.ts +34 -0
  38. package/dist/vue/components/KrEmpty.vue.d.ts +17 -0
  39. package/dist/vue/components/KrMenuItem.vue.d.ts +15 -0
  40. package/dist/vue/components/KrOverlay.vue.d.ts +28 -0
  41. package/dist/vue/components/KrSearchInput.vue.d.ts +30 -0
  42. package/dist/vue/components/KrSection.vue.d.ts +17 -0
  43. package/dist/vue/components/KrSelectGroup.vue.d.ts +44 -0
  44. package/dist/vue/components/KrSelectItem.vue.d.ts +25 -0
  45. package/dist/vue/components/KrSwitch.vue.d.ts +12 -0
  46. package/dist/vue/components/KrTextField.vue.d.ts +13 -0
  47. package/dist/vue/components/KrToast.vue.d.ts +32 -0
  48. package/dist/vue/components/KrToggleRow.vue.d.ts +18 -0
  49. package/dist/vue/index.d.ts +20 -0
  50. package/package.json +92 -0
@@ -0,0 +1,600 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import { createContext as n, useContext as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
3
+ //#region src/react/utils/cx.ts
4
+ function c(...e) {
5
+ return e.filter(Boolean).join(" ");
6
+ }
7
+ //#endregion
8
+ //#region src/react/components/KrChevron.tsx
9
+ function l({ className: t, ...n }) {
10
+ return /* @__PURE__ */ e("div", {
11
+ className: c("kr-chevron", t),
12
+ ...n
13
+ });
14
+ }
15
+ //#endregion
16
+ //#region src/react/components/KrEmpty.tsx
17
+ var u = /* @__PURE__ */ t("svg", {
18
+ viewBox: "0 0 64 64",
19
+ fill: "none",
20
+ xmlns: "http://www.w3.org/2000/svg",
21
+ children: [
22
+ /* @__PURE__ */ e("rect", {
23
+ x: "10",
24
+ y: "24",
25
+ width: "44",
26
+ height: "30",
27
+ rx: "4",
28
+ stroke: "var(--kr-on-surface-tertiary)",
29
+ strokeWidth: "2"
30
+ }),
31
+ /* @__PURE__ */ e("path", {
32
+ d: "M10 26L18 10H46L54 26",
33
+ stroke: "var(--kr-on-surface-tertiary)",
34
+ strokeWidth: "2",
35
+ strokeLinejoin: "round"
36
+ }),
37
+ /* @__PURE__ */ e("path", {
38
+ d: "M24 34H40",
39
+ stroke: "var(--kr-theme)",
40
+ strokeWidth: "2",
41
+ strokeLinecap: "round"
42
+ })
43
+ ]
44
+ });
45
+ function d({ title: n, description: r, icon: i, className: a, ...o }) {
46
+ return /* @__PURE__ */ t("div", {
47
+ className: c("kr-empty", a),
48
+ ...o,
49
+ children: [
50
+ /* @__PURE__ */ e("div", {
51
+ className: "kr-empty__icon",
52
+ children: i ?? u
53
+ }),
54
+ /* @__PURE__ */ e("h1", {
55
+ className: "kr-empty__title",
56
+ children: n
57
+ }),
58
+ /* @__PURE__ */ e("p", {
59
+ className: "kr-empty__description",
60
+ children: r
61
+ })
62
+ ]
63
+ });
64
+ }
65
+ //#endregion
66
+ //#region src/react/components/KrSection.tsx
67
+ function f({ title: n, subtitle: r, className: i, children: a, ...o }) {
68
+ return /* @__PURE__ */ t("section", {
69
+ className: c("kr-section", i),
70
+ ...o,
71
+ children: [(n || r) && /* @__PURE__ */ t("header", {
72
+ className: "kr-section__header",
73
+ children: [n && /* @__PURE__ */ e("h1", {
74
+ className: "kr-section__title",
75
+ children: n
76
+ }), r && /* @__PURE__ */ e("h2", {
77
+ className: "kr-section__subtitle",
78
+ children: r
79
+ })]
80
+ }), /* @__PURE__ */ e("div", {
81
+ className: "kr-section__content",
82
+ children: a
83
+ })]
84
+ });
85
+ }
86
+ //#endregion
87
+ //#region src/react/components/KrMenuItem.tsx
88
+ function p({ title: n, value: r, disabled: i, type: a, icon: o, className: s, ...l }) {
89
+ return a === "divider" ? /* @__PURE__ */ e("hr", { className: c("kr-menu-item--divider", s) }) : /* @__PURE__ */ t("button", {
90
+ className: c("kr-menu-item", s),
91
+ disabled: i,
92
+ role: "menuitem",
93
+ ...l,
94
+ children: [/* @__PURE__ */ e("div", {
95
+ className: "kr-menu-item__content",
96
+ children: n
97
+ }), o && /* @__PURE__ */ e("div", {
98
+ className: "kr-menu-item__icon",
99
+ "aria-hidden": "true",
100
+ children: o
101
+ })]
102
+ });
103
+ }
104
+ //#endregion
105
+ //#region src/react/components/KrButton.tsx
106
+ function m({ type: t = "primary", className: n, children: r, ...i }) {
107
+ return /* @__PURE__ */ e("button", {
108
+ className: c("kr-button", `kr-button--${t}`, n),
109
+ ...i,
110
+ children: r
111
+ });
112
+ }
113
+ //#endregion
114
+ //#region src/react/components/KrSwitch.tsx
115
+ function h({ checked: n = !1, disabled: r = !1, inset: i = !1, className: a, ...o }) {
116
+ return /* @__PURE__ */ t("div", {
117
+ className: c("kr-switch", i && "kr-switch--inset", a),
118
+ "data-checked": n,
119
+ "data-disabled": r,
120
+ "aria-hidden": "true",
121
+ ...o,
122
+ children: [/* @__PURE__ */ e("div", { className: "kr-switch__track" }), /* @__PURE__ */ e("div", { className: "kr-switch__thumb" })]
123
+ });
124
+ }
125
+ //#endregion
126
+ //#region src/react/components/KrToggleRow.tsx
127
+ function g({ checked: n = !1, onCheckedChange: r, title: i, subtitle: a, disabled: o = !1, hideSeparator: s = !1, className: l, ...u }) {
128
+ function d(e) {
129
+ r?.(e.target.checked);
130
+ }
131
+ return /* @__PURE__ */ t("label", {
132
+ className: c("kr-toggle-row", !s && "kr-toggle-row--with-separator", o && "kr-toggle-row--disabled", l),
133
+ ...u,
134
+ children: [
135
+ /* @__PURE__ */ e("input", {
136
+ className: "kr-toggle-row__native",
137
+ type: "checkbox",
138
+ role: "switch",
139
+ checked: n,
140
+ disabled: o,
141
+ "aria-label": i,
142
+ onChange: d
143
+ }),
144
+ /* @__PURE__ */ t("div", {
145
+ className: "kr-toggle-row__label",
146
+ children: [i && /* @__PURE__ */ e("div", {
147
+ className: "kr-toggle-row__title",
148
+ children: i
149
+ }), a && /* @__PURE__ */ e("div", {
150
+ className: "kr-toggle-row__subtitle",
151
+ children: a
152
+ })]
153
+ }),
154
+ /* @__PURE__ */ e(h, {
155
+ checked: n,
156
+ disabled: o
157
+ })
158
+ ]
159
+ });
160
+ }
161
+ //#endregion
162
+ //#region src/react/components/KrTextField.tsx
163
+ function _({ value: n, onValueChange: r, label: i, error: a, autofocus: o, className: s, ...l }) {
164
+ function u(e) {
165
+ r?.(e.target.value.trim());
166
+ }
167
+ return /* @__PURE__ */ t("label", {
168
+ className: c("kr-textfield", s),
169
+ children: [i && /* @__PURE__ */ e("span", {
170
+ className: "kr-textfield__label-text",
171
+ children: i
172
+ }), /* @__PURE__ */ e("input", {
173
+ type: "text",
174
+ className: c("kr-textfield__input", a && "kr-textfield__input--error"),
175
+ value: n,
176
+ onChange: u,
177
+ autoFocus: o,
178
+ ...l
179
+ })]
180
+ });
181
+ }
182
+ //#endregion
183
+ //#region src/react/components/KrSearchInput.tsx
184
+ var v = /* @__PURE__ */ t("svg", {
185
+ viewBox: "0 0 24 24",
186
+ fill: "none",
187
+ width: "1em",
188
+ height: "1em",
189
+ children: [/* @__PURE__ */ e("circle", {
190
+ cx: "11",
191
+ cy: "11",
192
+ r: "7",
193
+ stroke: "currentColor",
194
+ strokeWidth: "2"
195
+ }), /* @__PURE__ */ e("path", {
196
+ d: "M20 20L16.65 16.65",
197
+ stroke: "currentColor",
198
+ strokeWidth: "2",
199
+ strokeLinecap: "round"
200
+ })]
201
+ }), y = /* @__PURE__ */ e("svg", {
202
+ viewBox: "0 0 24 24",
203
+ fill: "none",
204
+ width: "1em",
205
+ height: "1em",
206
+ children: /* @__PURE__ */ e("path", {
207
+ d: "M6 6L18 18M18 6L6 18",
208
+ stroke: "currentColor",
209
+ strokeWidth: "2",
210
+ strokeLinecap: "round"
211
+ })
212
+ });
213
+ function b({ value: n = "", onValueChange: r, autofocus: i = !0, label: a = "Search", clearLabel: s = "Clear", icon: c, clearIcon: l }) {
214
+ let u = o(null);
215
+ function d(e) {
216
+ r?.(e), i && u.current?.focus();
217
+ }
218
+ function f(e) {
219
+ d(e.target.value);
220
+ }
221
+ function p() {
222
+ d("");
223
+ }
224
+ function m(e) {
225
+ e.key === "Enter" && p();
226
+ }
227
+ return /* @__PURE__ */ t("div", {
228
+ className: "kr-search-input",
229
+ children: [
230
+ /* @__PURE__ */ e("div", {
231
+ className: "kr-search-input__icon",
232
+ children: c ?? v
233
+ }),
234
+ /* @__PURE__ */ e("input", {
235
+ ref: u,
236
+ className: "kr-search-input__input",
237
+ type: "text",
238
+ value: n,
239
+ onChange: f,
240
+ autoFocus: i,
241
+ "aria-label": a
242
+ }),
243
+ /* @__PURE__ */ e("div", {
244
+ className: "kr-search-input__icon kr-search-input__icon--clear",
245
+ style: { display: n ? void 0 : "none" },
246
+ onClick: p,
247
+ role: "button",
248
+ tabIndex: 0,
249
+ "aria-label": s,
250
+ onKeyDown: m,
251
+ children: l ?? y
252
+ })
253
+ ]
254
+ });
255
+ }
256
+ //#endregion
257
+ //#region src/react/components/KrSelectItem.tsx
258
+ var x = n(null);
259
+ function S({ value: n, label: i, title: a, selected: o, disabled: s, variant: l = "default", shape: u = "rounded", circle: d, stretch: f, showItemLabel: p = !0, onSelect: m, children: h }) {
260
+ let g = r(x), _ = (g?.value ?? o) === n, v = g?.variant ?? l, y = d ? "circle" : g?.shape ?? u, b = g?.showItemLabel ?? p ? i ?? a : "";
261
+ function S(e) {
262
+ s || (m?.(n), g?.onSelect(n));
263
+ }
264
+ return /* @__PURE__ */ t("label", {
265
+ className: c("kr-select-item", _ && "kr-select-item--selected", s && "kr-select-item--disabled", f && "kr-select-item--stretch", `kr-select-item--${v}`, `kr-select-item--${y}`),
266
+ title: a,
267
+ children: [
268
+ /* @__PURE__ */ e("input", {
269
+ className: "kr-select-item__input",
270
+ type: "radio",
271
+ name: g?.name,
272
+ value: n,
273
+ checked: _,
274
+ disabled: s,
275
+ "aria-label": i || a || String(n),
276
+ onChange: S
277
+ }),
278
+ /* @__PURE__ */ e("div", {
279
+ className: "kr-select-item__content",
280
+ children: h
281
+ }),
282
+ b && /* @__PURE__ */ e("div", {
283
+ className: "kr-select-item__label",
284
+ children: b
285
+ })
286
+ ]
287
+ });
288
+ }
289
+ //#endregion
290
+ //#region src/react/components/KrSelectGroup.tsx
291
+ function C({ title: n, subtitle: r, items: i, showItemLabel: o = !0, showTooltip: l = !0, value: u, onValueChange: d, hideSeparator: f, columns: p = "auto", gap: m = "12px", variant: h = "default", shape: g = "rounded", className: _, style: v, renderItem: y }) {
292
+ let [b] = s(() => `kr-select-group-${Math.random().toString(36).slice(2)}`), C = p === "auto" ? {
293
+ display: "flex",
294
+ flexWrap: "wrap",
295
+ gap: m
296
+ } : {
297
+ display: "grid",
298
+ gridTemplateColumns: `repeat(${p}, 1fr)`,
299
+ gap: m
300
+ };
301
+ function w(e) {
302
+ d?.(e);
303
+ }
304
+ let T = a(() => ({
305
+ value: u,
306
+ variant: h,
307
+ shape: g,
308
+ showItemLabel: o,
309
+ name: b,
310
+ onSelect: w
311
+ }), [
312
+ u,
313
+ h,
314
+ g,
315
+ o,
316
+ b,
317
+ d
318
+ ]);
319
+ return /* @__PURE__ */ t("div", {
320
+ className: c("kr-select-group", !f && "kr-select-group--with-separator", _),
321
+ style: v,
322
+ children: [(n || r) && /* @__PURE__ */ t("div", {
323
+ className: "kr-select-group__header",
324
+ children: [n && /* @__PURE__ */ e("div", {
325
+ className: "kr-select-group__header__title",
326
+ children: n
327
+ }), r && /* @__PURE__ */ e("div", {
328
+ className: "kr-select-group__header__subtitle",
329
+ children: r
330
+ })]
331
+ }), /* @__PURE__ */ e("div", {
332
+ className: "kr-select-group__items",
333
+ style: C,
334
+ children: /* @__PURE__ */ e(x.Provider, {
335
+ value: T,
336
+ children: y ? i.map((t) => /* @__PURE__ */ e("div", { children: y(t, u === t.value, w) }, t.value)) : i.map((t) => /* @__PURE__ */ e(S, {
337
+ value: t.value,
338
+ label: t.label,
339
+ selected: u,
340
+ disabled: t.disabled,
341
+ variant: h,
342
+ shape: g,
343
+ showItemLabel: o,
344
+ title: l ? t.label : void 0,
345
+ children: h === "color" ? /* @__PURE__ */ e("div", {
346
+ className: "kr-color-swatch",
347
+ style: { background: t.hex }
348
+ }) : h === "icon" && t.icon ? /* @__PURE__ */ e("svg", {
349
+ className: "kr-select-item-icon",
350
+ viewBox: "0 0 32 32",
351
+ children: /* @__PURE__ */ e("path", { d: t.icon })
352
+ }) : t.label
353
+ }, t.value))
354
+ })
355
+ })]
356
+ });
357
+ }
358
+ //#endregion
359
+ //#region src/react/hooks/useCssTransition.ts
360
+ function w(e, t) {
361
+ let [n, r] = s(e ? "entered" : "left"), [a, l] = s(!1), u = o(null);
362
+ return i(() => {
363
+ r(e ? (e) => e === "entering" || e === "entered" ? e : (l(!0), "entering") : (e) => e === "leaving" || e === "left" ? e : (l(!1), "leaving"));
364
+ }, [e]), i(() => {
365
+ let e = n === "entering" && a ? !1 : n === "leaving" && !a || null;
366
+ if (e === null) return;
367
+ let t = -1, r = requestAnimationFrame(() => {
368
+ t = requestAnimationFrame(() => l(e));
369
+ });
370
+ return () => {
371
+ cancelAnimationFrame(r), cancelAnimationFrame(t);
372
+ };
373
+ }, [n, a]), i(() => {
374
+ if (n !== "entering" && n !== "leaving") return;
375
+ let e = u.current;
376
+ if (!e) return;
377
+ function t(t) {
378
+ t.target === e && r((e) => e === "entering" ? "entered" : e === "leaving" ? "left" : e);
379
+ }
380
+ return e.addEventListener("transitionend", t), () => e.removeEventListener("transitionend", t);
381
+ }, [n]), {
382
+ shouldRender: n !== "left",
383
+ transitionClassName: n === "entering" ? c(`${t}-enter-active`, a && `${t}-enter-from`) : n === "leaving" ? c(`${t}-leave-active`, a && `${t}-leave-to`) : void 0,
384
+ ref: u
385
+ };
386
+ }
387
+ //#endregion
388
+ //#region src/react/components/KrOverlay.tsx
389
+ function T({ show: n, onShowChange: r, centered: i = !1, background: a, contentStyle: o, contentTransition: s = "fade-in", children: l }) {
390
+ let { shouldRender: u, transitionClassName: d, ref: f } = w(n, `kr-${s}-content`);
391
+ return u ? /* @__PURE__ */ t("div", {
392
+ ref: f,
393
+ className: c("kr-overlay", i && "kr-overlay--centered", d),
394
+ style: { "--kr-overlay-background": a },
395
+ role: "application",
396
+ children: [/* @__PURE__ */ e("div", {
397
+ className: "kr-overlay__scrim",
398
+ onClick: () => r?.(!1)
399
+ }), /* @__PURE__ */ e("div", {
400
+ className: "kr-overlay__content",
401
+ style: o,
402
+ children: l
403
+ })]
404
+ }) : null;
405
+ }
406
+ //#endregion
407
+ //#region src/core/toastTimer.ts
408
+ function E(e) {
409
+ let t, n;
410
+ function r() {
411
+ t !== void 0 && (clearTimeout(t), t = void 0), n !== void 0 && (clearInterval(n), n = void 0);
412
+ }
413
+ function i({ timeoutSeconds: i, showCountdown: a }) {
414
+ if (r(), e.onTick?.(Math.max(0, Math.ceil(i))), i <= 0) return;
415
+ let o = Date.now() + i * 1e3;
416
+ t = setTimeout(() => {
417
+ e.onDismiss();
418
+ }, i * 1e3), a && (n = setInterval(() => {
419
+ e.onTick?.(Math.max(0, Math.ceil((o - Date.now()) / 1e3)));
420
+ }, 200));
421
+ }
422
+ return {
423
+ start: i,
424
+ clear: r
425
+ };
426
+ }
427
+ //#endregion
428
+ //#region src/react/components/KrToast.tsx
429
+ var D = /* @__PURE__ */ e("svg", {
430
+ viewBox: "0 0 24 24",
431
+ fill: "none",
432
+ width: "1em",
433
+ height: "1em",
434
+ children: /* @__PURE__ */ e("path", {
435
+ d: "M20 6L9 17L4 12",
436
+ stroke: "currentColor",
437
+ strokeWidth: "2",
438
+ strokeLinecap: "round",
439
+ strokeLinejoin: "round"
440
+ })
441
+ }), O = /* @__PURE__ */ t("svg", {
442
+ viewBox: "0 0 24 24",
443
+ fill: "none",
444
+ width: "1em",
445
+ height: "1em",
446
+ children: [
447
+ /* @__PURE__ */ e("circle", {
448
+ cx: "12",
449
+ cy: "12",
450
+ r: "9",
451
+ stroke: "currentColor",
452
+ strokeWidth: "2"
453
+ }),
454
+ /* @__PURE__ */ e("path", {
455
+ d: "M12 8V13",
456
+ stroke: "currentColor",
457
+ strokeWidth: "2",
458
+ strokeLinecap: "round"
459
+ }),
460
+ /* @__PURE__ */ e("circle", {
461
+ cx: "12",
462
+ cy: "16",
463
+ r: "1",
464
+ fill: "currentColor"
465
+ })
466
+ ]
467
+ });
468
+ function k({ show: n = !1, onShowChange: r, text: a, icon: l, iconContent: u, timeout: d = 3, actionText: f, onAction: p, showCountdown: m }) {
469
+ let [h, g] = s(d), _ = o(r);
470
+ _.current = r;
471
+ let v = o(null);
472
+ v.current ||= E({
473
+ onDismiss: () => _.current?.(!1),
474
+ onTick: (e) => g(e)
475
+ }), i(() => {
476
+ n ? v.current.start({
477
+ timeoutSeconds: d,
478
+ showCountdown: m
479
+ }) : v.current.clear();
480
+ }, [n]), i(() => () => v.current?.clear(), []);
481
+ let { shouldRender: y, transitionClassName: b, ref: x } = w(n, "kr-fade-in-up");
482
+ function S(e) {
483
+ e.stopPropagation(), p?.(), _.current?.(!1);
484
+ }
485
+ function C() {
486
+ f || _.current?.(!1);
487
+ }
488
+ return y ? /* @__PURE__ */ t("div", {
489
+ ref: x,
490
+ className: c("kr-toast", b),
491
+ role: "status",
492
+ "aria-live": "polite",
493
+ onClick: C,
494
+ children: [
495
+ l && /* @__PURE__ */ e("div", {
496
+ className: "kr-toast__icon",
497
+ children: u ?? (l === "success" ? D : O)
498
+ }),
499
+ /* @__PURE__ */ e("div", {
500
+ className: "kr-toast__text",
501
+ children: a
502
+ }),
503
+ f && /* @__PURE__ */ t("div", {
504
+ className: "kr-toast__actions",
505
+ children: [/* @__PURE__ */ e("button", {
506
+ className: "kr-toast__action",
507
+ type: "button",
508
+ onClick: S,
509
+ children: f
510
+ }), m && /* @__PURE__ */ t("span", {
511
+ className: "kr-toast__countdown",
512
+ "aria-hidden": "true",
513
+ children: [h, "s"]
514
+ })]
515
+ })
516
+ ]
517
+ }) : null;
518
+ }
519
+ //#endregion
520
+ //#region src/core/focusTrap.ts
521
+ function A(e) {
522
+ return Array.from(e?.querySelectorAll("button:not([disabled]), input:not([disabled])") ?? []);
523
+ }
524
+ function j(e) {
525
+ let t = A(e), n = t.findIndex((e) => e === document.activeElement);
526
+ (n === t.length - 1 ? t[0] : t[n + 1])?.focus();
527
+ }
528
+ function M(e) {
529
+ let t = A(e), n = t.findIndex((e) => e === document.activeElement);
530
+ (n <= 0 ? t[t.length - 1] : t[n - 1])?.focus();
531
+ }
532
+ //#endregion
533
+ //#region src/react/components/KrDialog.tsx
534
+ function N({ show: n = !1, onShowChange: r, title: i = "", text: a = "", actions: c = [], cancelText: l = "Cancel", hideCancel: u = !1, children: d }) {
535
+ let [f, p] = s(!1), h = o(null);
536
+ function g() {
537
+ r?.(!1);
538
+ }
539
+ async function _(e) {
540
+ if (!f) {
541
+ p(!0);
542
+ try {
543
+ await e();
544
+ } finally {
545
+ p(!1);
546
+ }
547
+ }
548
+ }
549
+ function v(e) {
550
+ if (e.key === "Escape") {
551
+ e.preventDefault(), r?.(!1);
552
+ return;
553
+ }
554
+ e.key === "Tab" && (e.preventDefault(), e.shiftKey ? M(h.current) : j(h.current));
555
+ }
556
+ return /* @__PURE__ */ e(T, {
557
+ show: n,
558
+ onShowChange: r,
559
+ centered: !0,
560
+ children: /* @__PURE__ */ t("dialog", {
561
+ ref: h,
562
+ className: "kr-dialog",
563
+ open: n,
564
+ onKeyDown: v,
565
+ children: [
566
+ i && /* @__PURE__ */ e("h2", {
567
+ className: "kr-dialog__title",
568
+ children: i
569
+ }),
570
+ /* @__PURE__ */ t("div", {
571
+ className: "kr-dialog__content",
572
+ children: [a && /* @__PURE__ */ e("div", {
573
+ className: "kr-dialog__content__text",
574
+ children: a
575
+ }), d && /* @__PURE__ */ e("div", {
576
+ className: "kr-dialog__content__form",
577
+ children: d
578
+ })]
579
+ }),
580
+ /* @__PURE__ */ t("div", {
581
+ className: "kr-dialog__actions",
582
+ children: [!u && /* @__PURE__ */ e(m, {
583
+ type: "secondary",
584
+ disabled: f,
585
+ onClick: g,
586
+ children: l
587
+ }), c.map((t) => /* @__PURE__ */ e(m, {
588
+ disabled: f || t.disabled,
589
+ onClick: () => _(t.action),
590
+ children: t.text
591
+ }, t.text))]
592
+ })
593
+ ]
594
+ })
595
+ });
596
+ }
597
+ //#endregion
598
+ export { m as KrButton, l as KrChevron, N as KrDialog, d as KrEmpty, p as KrMenuItem, T as KrOverlay, b as KrSearchInput, f as KrSection, C as KrSelectGroup, x as KrSelectGroupContext, S as KrSelectItem, h as KrSwitch, _ as KrTextField, k as KrToast, g as KrToggleRow };
599
+
600
+ //# sourceMappingURL=kroma-react.js.map