@anguszhu/kroma-ui 0.1.0 → 0.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.
@@ -1,25 +1,25 @@
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";
1
+ import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
2
+ import { createContext as r, useContext as i, useEffect as a, useMemo as o, useRef as s, useState as c } from "react";
3
3
  //#region src/react/utils/cx.ts
4
- function c(...e) {
4
+ function l(...e) {
5
5
  return e.filter(Boolean).join(" ");
6
6
  }
7
7
  //#endregion
8
8
  //#region src/react/components/KrChevron.tsx
9
- function l({ className: t, ...n }) {
10
- return /* @__PURE__ */ e("div", {
11
- className: c("kr-chevron", t),
9
+ function u({ className: e, ...n }) {
10
+ return /* @__PURE__ */ t("div", {
11
+ className: l("kr-chevron", e),
12
12
  ...n
13
13
  });
14
14
  }
15
15
  //#endregion
16
16
  //#region src/react/components/KrEmpty.tsx
17
- var u = /* @__PURE__ */ t("svg", {
17
+ var d = /* @__PURE__ */ n("svg", {
18
18
  viewBox: "0 0 64 64",
19
19
  fill: "none",
20
20
  xmlns: "http://www.w3.org/2000/svg",
21
21
  children: [
22
- /* @__PURE__ */ e("rect", {
22
+ /* @__PURE__ */ t("rect", {
23
23
  x: "10",
24
24
  y: "24",
25
25
  width: "44",
@@ -28,13 +28,13 @@ var u = /* @__PURE__ */ t("svg", {
28
28
  stroke: "var(--kr-on-surface-tertiary)",
29
29
  strokeWidth: "2"
30
30
  }),
31
- /* @__PURE__ */ e("path", {
31
+ /* @__PURE__ */ t("path", {
32
32
  d: "M10 26L18 10H46L54 26",
33
33
  stroke: "var(--kr-on-surface-tertiary)",
34
34
  strokeWidth: "2",
35
35
  strokeLinejoin: "round"
36
36
  }),
37
- /* @__PURE__ */ e("path", {
37
+ /* @__PURE__ */ t("path", {
38
38
  d: "M24 34H40",
39
39
  stroke: "var(--kr-theme)",
40
40
  strokeWidth: "2",
@@ -42,20 +42,20 @@ var u = /* @__PURE__ */ t("svg", {
42
42
  })
43
43
  ]
44
44
  });
45
- function d({ title: n, description: r, icon: i, className: a, ...o }) {
46
- return /* @__PURE__ */ t("div", {
47
- className: c("kr-empty", a),
45
+ function f({ title: e, description: r, icon: i, className: a, ...o }) {
46
+ return /* @__PURE__ */ n("div", {
47
+ className: l("kr-empty", a),
48
48
  ...o,
49
49
  children: [
50
- /* @__PURE__ */ e("div", {
50
+ /* @__PURE__ */ t("div", {
51
51
  className: "kr-empty__icon",
52
- children: i ?? u
52
+ children: i ?? d
53
53
  }),
54
- /* @__PURE__ */ e("h1", {
54
+ /* @__PURE__ */ t("h1", {
55
55
  className: "kr-empty__title",
56
- children: n
56
+ children: e
57
57
  }),
58
- /* @__PURE__ */ e("p", {
58
+ /* @__PURE__ */ t("p", {
59
59
  className: "kr-empty__description",
60
60
  children: r
61
61
  })
@@ -64,20 +64,20 @@ function d({ title: n, description: r, icon: i, className: a, ...o }) {
64
64
  }
65
65
  //#endregion
66
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),
67
+ function p({ title: e, subtitle: r, className: i, children: a, ...o }) {
68
+ return /* @__PURE__ */ n("section", {
69
+ className: l("kr-section", i),
70
70
  ...o,
71
- children: [(n || r) && /* @__PURE__ */ t("header", {
71
+ children: [(e || r) && /* @__PURE__ */ n("header", {
72
72
  className: "kr-section__header",
73
- children: [n && /* @__PURE__ */ e("h1", {
73
+ children: [e && /* @__PURE__ */ t("h1", {
74
74
  className: "kr-section__title",
75
- children: n
76
- }), r && /* @__PURE__ */ e("h2", {
75
+ children: e
76
+ }), r && /* @__PURE__ */ t("h2", {
77
77
  className: "kr-section__subtitle",
78
78
  children: r
79
79
  })]
80
- }), /* @__PURE__ */ e("div", {
80
+ }), /* @__PURE__ */ t("div", {
81
81
  className: "kr-section__content",
82
82
  children: a
83
83
  })]
@@ -85,16 +85,16 @@ function f({ title: n, subtitle: r, className: i, children: a, ...o }) {
85
85
  }
86
86
  //#endregion
87
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),
88
+ function m({ title: e, value: r, disabled: i, type: a, icon: o, className: s, ...c }) {
89
+ return a === "divider" ? /* @__PURE__ */ t("hr", { className: l("kr-menu-item--divider", s) }) : /* @__PURE__ */ n("button", {
90
+ className: l("kr-menu-item", s),
91
91
  disabled: i,
92
92
  role: "menuitem",
93
- ...l,
94
- children: [/* @__PURE__ */ e("div", {
93
+ ...c,
94
+ children: [/* @__PURE__ */ t("div", {
95
95
  className: "kr-menu-item__content",
96
- children: n
97
- }), o && /* @__PURE__ */ e("div", {
96
+ children: e
97
+ }), o && /* @__PURE__ */ t("div", {
98
98
  className: "kr-menu-item__icon",
99
99
  "aria-hidden": "true",
100
100
  children: o
@@ -103,115 +103,318 @@ function p({ title: n, value: r, disabled: i, type: a, icon: o, className: s, ..
103
103
  }
104
104
  //#endregion
105
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),
106
+ function h({ type: e = "primary", className: n, children: r, ...i }) {
107
+ return /* @__PURE__ */ t("button", {
108
+ className: l("kr-button", `kr-button--${e}`, n),
109
109
  ...i,
110
110
  children: r
111
111
  });
112
112
  }
113
113
  //#endregion
114
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,
115
+ function g({ checked: e = !1, disabled: r = !1, inset: i = !1, className: a, ...o }) {
116
+ return /* @__PURE__ */ n("div", {
117
+ className: l("kr-switch", i && "kr-switch--inset", a),
118
+ "data-checked": e,
119
119
  "data-disabled": r,
120
120
  "aria-hidden": "true",
121
121
  ...o,
122
- children: [/* @__PURE__ */ e("div", { className: "kr-switch__track" }), /* @__PURE__ */ e("div", { className: "kr-switch__thumb" })]
122
+ children: [/* @__PURE__ */ t("div", { className: "kr-switch__track" }), /* @__PURE__ */ t("div", { className: "kr-switch__thumb" })]
123
123
  });
124
124
  }
125
125
  //#endregion
126
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 }) {
127
+ function _({ checked: e = !1, onCheckedChange: r, title: i, subtitle: a, disabled: o = !1, hideSeparator: s = !1, className: c, ...u }) {
128
128
  function d(e) {
129
129
  r?.(e.target.checked);
130
130
  }
131
- return /* @__PURE__ */ t("label", {
132
- className: c("kr-toggle-row", !s && "kr-toggle-row--with-separator", o && "kr-toggle-row--disabled", l),
131
+ return /* @__PURE__ */ n("label", {
132
+ className: l("kr-toggle-row", !s && "kr-toggle-row--with-separator", o && "kr-toggle-row--disabled", c),
133
133
  ...u,
134
134
  children: [
135
- /* @__PURE__ */ e("input", {
135
+ /* @__PURE__ */ t("input", {
136
136
  className: "kr-toggle-row__native",
137
137
  type: "checkbox",
138
138
  role: "switch",
139
- checked: n,
139
+ checked: e,
140
140
  disabled: o,
141
141
  "aria-label": i,
142
142
  onChange: d
143
143
  }),
144
- /* @__PURE__ */ t("div", {
144
+ /* @__PURE__ */ n("div", {
145
145
  className: "kr-toggle-row__label",
146
- children: [i && /* @__PURE__ */ e("div", {
146
+ children: [i && /* @__PURE__ */ t("div", {
147
147
  className: "kr-toggle-row__title",
148
148
  children: i
149
- }), a && /* @__PURE__ */ e("div", {
149
+ }), a && /* @__PURE__ */ t("div", {
150
150
  className: "kr-toggle-row__subtitle",
151
151
  children: a
152
152
  })]
153
153
  }),
154
- /* @__PURE__ */ e(h, {
155
- checked: n,
154
+ /* @__PURE__ */ t(g, {
155
+ checked: e,
156
156
  disabled: o
157
157
  })
158
158
  ]
159
159
  });
160
160
  }
161
161
  //#endregion
162
+ //#region src/react/components/KrRadioRow.tsx
163
+ function v({ checked: e = !1, onCheckedChange: r, name: i, value: a, title: o, subtitle: s, disabled: c = !1, hideSeparator: u = !1, className: d, ...f }) {
164
+ function p(e) {
165
+ r?.(e.target.checked);
166
+ }
167
+ return /* @__PURE__ */ n("label", {
168
+ className: l("kr-radio-row", !u && "kr-radio-row--with-separator", e && "kr-radio-row--checked", c && "kr-radio-row--disabled", d),
169
+ ...f,
170
+ children: [
171
+ /* @__PURE__ */ t("input", {
172
+ className: "kr-radio-row__native",
173
+ type: "radio",
174
+ name: i,
175
+ value: a,
176
+ checked: e,
177
+ disabled: c,
178
+ "aria-label": o,
179
+ onChange: p
180
+ }),
181
+ /* @__PURE__ */ t("div", {
182
+ className: "kr-radio-row__radio",
183
+ "aria-hidden": "true",
184
+ children: /* @__PURE__ */ t("div", { className: "kr-radio-row__radio-dot" })
185
+ }),
186
+ /* @__PURE__ */ n("div", {
187
+ className: "kr-radio-row__label",
188
+ children: [o && /* @__PURE__ */ t("div", {
189
+ className: "kr-radio-row__title",
190
+ children: o
191
+ }), s && /* @__PURE__ */ t("div", {
192
+ className: "kr-radio-row__subtitle",
193
+ children: s
194
+ })]
195
+ })
196
+ ]
197
+ });
198
+ }
199
+ //#endregion
200
+ //#region src/react/components/KrCheckboxRow.tsx
201
+ function y({ checked: e = !1, indeterminate: r = !1, onCheckedChange: i, name: o, value: c, title: u, subtitle: d, disabled: f = !1, hideSeparator: p = !1, className: m, ...h }) {
202
+ let g = s(null);
203
+ a(() => {
204
+ g.current && (g.current.indeterminate = r);
205
+ }, [r]);
206
+ function _(e) {
207
+ i?.(e.target.checked);
208
+ }
209
+ return /* @__PURE__ */ n("label", {
210
+ className: l("kr-checkbox-row", !p && "kr-checkbox-row--with-separator", e && "kr-checkbox-row--checked", r && "kr-checkbox-row--indeterminate", f && "kr-checkbox-row--disabled", m),
211
+ ...h,
212
+ children: [
213
+ /* @__PURE__ */ t("input", {
214
+ ref: g,
215
+ className: "kr-checkbox-row__native",
216
+ type: "checkbox",
217
+ name: o,
218
+ value: c,
219
+ checked: e,
220
+ disabled: f,
221
+ "aria-label": u,
222
+ onChange: _
223
+ }),
224
+ /* @__PURE__ */ t("div", {
225
+ className: "kr-checkbox-row__checkbox",
226
+ "aria-hidden": "true",
227
+ children: /* @__PURE__ */ t("svg", {
228
+ className: "kr-checkbox-row__check",
229
+ viewBox: "0 0 24 24",
230
+ fill: "none",
231
+ children: r ? /* @__PURE__ */ t("path", {
232
+ d: "M5 12h14",
233
+ stroke: "currentColor",
234
+ strokeWidth: "3",
235
+ strokeLinecap: "round"
236
+ }) : /* @__PURE__ */ t("path", {
237
+ d: "M20 6L9 17l-5-5",
238
+ stroke: "currentColor",
239
+ strokeWidth: "3",
240
+ strokeLinecap: "round",
241
+ strokeLinejoin: "round"
242
+ })
243
+ })
244
+ }),
245
+ /* @__PURE__ */ n("div", {
246
+ className: "kr-checkbox-row__label",
247
+ children: [u && /* @__PURE__ */ t("div", {
248
+ className: "kr-checkbox-row__title",
249
+ children: u
250
+ }), d && /* @__PURE__ */ t("div", {
251
+ className: "kr-checkbox-row__subtitle",
252
+ children: d
253
+ })]
254
+ })
255
+ ]
256
+ });
257
+ }
258
+ //#endregion
259
+ //#region src/react/components/KrButtonRow.tsx
260
+ function b({ title: e, subtitle: r, buttonLabel: i, buttonType: a = "secondary", onButtonClick: o, disabled: s = !1, hideSeparator: c = !1, className: u, ...d }) {
261
+ return /* @__PURE__ */ n("div", {
262
+ className: l("kr-button-row", !c && "kr-button-row--with-separator", s && "kr-button-row--disabled", u),
263
+ ...d,
264
+ children: [/* @__PURE__ */ n("div", {
265
+ className: "kr-button-row__label",
266
+ children: [e && /* @__PURE__ */ t("div", {
267
+ className: "kr-button-row__title",
268
+ children: e
269
+ }), r && /* @__PURE__ */ t("div", {
270
+ className: "kr-button-row__subtitle",
271
+ children: r
272
+ })]
273
+ }), /* @__PURE__ */ t(h, {
274
+ className: "kr-button-row__button",
275
+ type: a,
276
+ disabled: s,
277
+ onClick: o,
278
+ children: i
279
+ })]
280
+ });
281
+ }
282
+ //#endregion
283
+ //#region src/react/components/KrLinkRow.tsx
284
+ var x = /* @__PURE__ */ n("svg", {
285
+ viewBox: "0 0 24 24",
286
+ fill: "none",
287
+ width: "1em",
288
+ height: "1em",
289
+ children: [
290
+ /* @__PURE__ */ t("path", {
291
+ d: "M15 3h6v6",
292
+ stroke: "currentColor",
293
+ strokeWidth: "2",
294
+ strokeLinecap: "round",
295
+ strokeLinejoin: "round"
296
+ }),
297
+ /* @__PURE__ */ t("path", {
298
+ d: "M10 14L21 3",
299
+ stroke: "currentColor",
300
+ strokeWidth: "2",
301
+ strokeLinecap: "round",
302
+ strokeLinejoin: "round"
303
+ }),
304
+ /* @__PURE__ */ t("path", {
305
+ d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",
306
+ stroke: "currentColor",
307
+ strokeWidth: "2",
308
+ strokeLinecap: "round",
309
+ strokeLinejoin: "round"
310
+ })
311
+ ]
312
+ });
313
+ function S({ title: r, subtitle: i, href: a, target: o = "_blank", rel: s = "noopener noreferrer", onClick: c, disabled: u = !1, hideSeparator: d = !1, icon: f, className: p }) {
314
+ let m = l("kr-link-row", !d && "kr-link-row--with-separator", u && "kr-link-row--disabled", p), h = /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ n("div", {
315
+ className: "kr-link-row__label",
316
+ children: [r && /* @__PURE__ */ t("div", {
317
+ className: "kr-link-row__title",
318
+ children: r
319
+ }), i && /* @__PURE__ */ t("div", {
320
+ className: "kr-link-row__subtitle",
321
+ children: i
322
+ })]
323
+ }), /* @__PURE__ */ t("div", {
324
+ className: "kr-link-row__icon",
325
+ "aria-hidden": "true",
326
+ children: f ?? x
327
+ })] });
328
+ return a ? /* @__PURE__ */ t("a", {
329
+ className: m,
330
+ href: u ? void 0 : a,
331
+ target: o,
332
+ rel: s,
333
+ "aria-disabled": u,
334
+ onClick: c,
335
+ children: h
336
+ }) : /* @__PURE__ */ t("button", {
337
+ type: "button",
338
+ className: m,
339
+ disabled: u,
340
+ onClick: c,
341
+ children: h
342
+ });
343
+ }
344
+ //#endregion
345
+ //#region src/react/components/KrNavigationRow.tsx
346
+ function C({ title: e, subtitle: r, disabled: i = !1, hideSeparator: a = !1, destructive: o = !1, className: s, ...c }) {
347
+ return /* @__PURE__ */ n("button", {
348
+ type: "button",
349
+ className: l("kr-navigation-row", !a && "kr-navigation-row--with-separator", o && "kr-navigation-row--destructive", i && "kr-navigation-row--disabled", s),
350
+ disabled: i,
351
+ ...c,
352
+ children: [/* @__PURE__ */ n("div", {
353
+ className: "kr-navigation-row__label",
354
+ children: [e && /* @__PURE__ */ t("div", {
355
+ className: "kr-navigation-row__title",
356
+ children: e
357
+ }), r && /* @__PURE__ */ t("div", {
358
+ className: "kr-navigation-row__subtitle",
359
+ children: r
360
+ })]
361
+ }), /* @__PURE__ */ t(u, { className: "kr-navigation-row__chevron" })]
362
+ });
363
+ }
364
+ //#endregion
162
365
  //#region src/react/components/KrTextField.tsx
163
- function _({ value: n, onValueChange: r, label: i, error: a, autofocus: o, className: s, ...l }) {
366
+ function w({ value: e, onValueChange: r, label: i, error: a, autofocus: o, className: s, ...c }) {
164
367
  function u(e) {
165
368
  r?.(e.target.value.trim());
166
369
  }
167
- return /* @__PURE__ */ t("label", {
168
- className: c("kr-textfield", s),
169
- children: [i && /* @__PURE__ */ e("span", {
370
+ return /* @__PURE__ */ n("label", {
371
+ className: l("kr-textfield", s),
372
+ children: [i && /* @__PURE__ */ t("span", {
170
373
  className: "kr-textfield__label-text",
171
374
  children: i
172
- }), /* @__PURE__ */ e("input", {
375
+ }), /* @__PURE__ */ t("input", {
173
376
  type: "text",
174
- className: c("kr-textfield__input", a && "kr-textfield__input--error"),
175
- value: n,
377
+ className: l("kr-textfield__input", a && "kr-textfield__input--error"),
378
+ value: e,
176
379
  onChange: u,
177
380
  autoFocus: o,
178
- ...l
381
+ ...c
179
382
  })]
180
383
  });
181
384
  }
182
385
  //#endregion
183
386
  //#region src/react/components/KrSearchInput.tsx
184
- var v = /* @__PURE__ */ t("svg", {
387
+ var T = /* @__PURE__ */ n("svg", {
185
388
  viewBox: "0 0 24 24",
186
389
  fill: "none",
187
390
  width: "1em",
188
391
  height: "1em",
189
- children: [/* @__PURE__ */ e("circle", {
392
+ children: [/* @__PURE__ */ t("circle", {
190
393
  cx: "11",
191
394
  cy: "11",
192
395
  r: "7",
193
396
  stroke: "currentColor",
194
397
  strokeWidth: "2"
195
- }), /* @__PURE__ */ e("path", {
398
+ }), /* @__PURE__ */ t("path", {
196
399
  d: "M20 20L16.65 16.65",
197
400
  stroke: "currentColor",
198
401
  strokeWidth: "2",
199
402
  strokeLinecap: "round"
200
403
  })]
201
- }), y = /* @__PURE__ */ e("svg", {
404
+ }), E = /* @__PURE__ */ t("svg", {
202
405
  viewBox: "0 0 24 24",
203
406
  fill: "none",
204
407
  width: "1em",
205
408
  height: "1em",
206
- children: /* @__PURE__ */ e("path", {
409
+ children: /* @__PURE__ */ t("path", {
207
410
  d: "M6 6L18 18M18 6L6 18",
208
411
  stroke: "currentColor",
209
412
  strokeWidth: "2",
210
413
  strokeLinecap: "round"
211
414
  })
212
415
  });
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);
416
+ function D({ value: e = "", onValueChange: r, autofocus: i = !0, label: a = "Search", clearLabel: o = "Clear", icon: c, clearIcon: l }) {
417
+ let u = s(null);
215
418
  function d(e) {
216
419
  r?.(e), i && u.current?.focus();
217
420
  }
@@ -224,62 +427,62 @@ function b({ value: n = "", onValueChange: r, autofocus: i = !0, label: a = "Sea
224
427
  function m(e) {
225
428
  e.key === "Enter" && p();
226
429
  }
227
- return /* @__PURE__ */ t("div", {
430
+ return /* @__PURE__ */ n("div", {
228
431
  className: "kr-search-input",
229
432
  children: [
230
- /* @__PURE__ */ e("div", {
433
+ /* @__PURE__ */ t("div", {
231
434
  className: "kr-search-input__icon",
232
- children: c ?? v
435
+ children: c ?? T
233
436
  }),
234
- /* @__PURE__ */ e("input", {
437
+ /* @__PURE__ */ t("input", {
235
438
  ref: u,
236
439
  className: "kr-search-input__input",
237
440
  type: "text",
238
- value: n,
441
+ value: e,
239
442
  onChange: f,
240
443
  autoFocus: i,
241
444
  "aria-label": a
242
445
  }),
243
- /* @__PURE__ */ e("div", {
446
+ /* @__PURE__ */ t("div", {
244
447
  className: "kr-search-input__icon kr-search-input__icon--clear",
245
- style: { display: n ? void 0 : "none" },
448
+ style: { display: e ? void 0 : "none" },
246
449
  onClick: p,
247
450
  role: "button",
248
451
  tabIndex: 0,
249
- "aria-label": s,
452
+ "aria-label": o,
250
453
  onKeyDown: m,
251
- children: l ?? y
454
+ children: l ?? E
252
455
  })
253
456
  ]
254
457
  });
255
458
  }
256
459
  //#endregion
257
460
  //#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));
461
+ var O = r(null);
462
+ function k({ value: e, label: r, title: a, selected: o, disabled: s, variant: c = "default", shape: u = "rounded", circle: d, stretch: f, showItemLabel: p = !0, onSelect: m, children: h }) {
463
+ let g = i(O), _ = (g?.value ?? o) === e, v = g?.variant ?? c, y = d ? "circle" : g?.shape ?? u, b = g?.showItemLabel ?? p ? r ?? a : "";
464
+ function x(t) {
465
+ s || (m?.(e), g?.onSelect(e));
263
466
  }
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}`),
467
+ return /* @__PURE__ */ n("label", {
468
+ className: l("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
469
  title: a,
267
470
  children: [
268
- /* @__PURE__ */ e("input", {
471
+ /* @__PURE__ */ t("input", {
269
472
  className: "kr-select-item__input",
270
473
  type: "radio",
271
474
  name: g?.name,
272
- value: n,
475
+ value: e,
273
476
  checked: _,
274
477
  disabled: s,
275
- "aria-label": i || a || String(n),
276
- onChange: S
478
+ "aria-label": r || a || String(e),
479
+ onChange: x
277
480
  }),
278
- /* @__PURE__ */ e("div", {
481
+ /* @__PURE__ */ t("div", {
279
482
  className: "kr-select-item__content",
280
483
  children: h
281
484
  }),
282
- b && /* @__PURE__ */ e("div", {
485
+ b && /* @__PURE__ */ t("div", {
283
486
  className: "kr-select-item__label",
284
487
  children: b
285
488
  })
@@ -288,8 +491,8 @@ function S({ value: n, label: i, title: a, selected: o, disabled: s, variant: l
288
491
  }
289
492
  //#endregion
290
493
  //#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" ? {
494
+ function A({ title: e, subtitle: r, items: i, showItemLabel: a = !0, showTooltip: s = !0, value: u, onValueChange: d, hideSeparator: f, columns: p = "auto", gap: m = "12px", variant: h = "default", shape: g = "rounded", className: _, style: v, renderItem: y }) {
495
+ let [b] = c(() => `kr-select-group-${Math.random().toString(36).slice(2)}`), x = p === "auto" ? {
293
496
  display: "flex",
294
497
  flexWrap: "wrap",
295
498
  gap: m
@@ -298,79 +501,79 @@ function C({ title: n, subtitle: r, items: i, showItemLabel: o = !0, showTooltip
298
501
  gridTemplateColumns: `repeat(${p}, 1fr)`,
299
502
  gap: m
300
503
  };
301
- function w(e) {
504
+ function S(e) {
302
505
  d?.(e);
303
506
  }
304
- let T = a(() => ({
507
+ let C = o(() => ({
305
508
  value: u,
306
509
  variant: h,
307
510
  shape: g,
308
- showItemLabel: o,
511
+ showItemLabel: a,
309
512
  name: b,
310
- onSelect: w
513
+ onSelect: S
311
514
  }), [
312
515
  u,
313
516
  h,
314
517
  g,
315
- o,
518
+ a,
316
519
  b,
317
520
  d
318
521
  ]);
319
- return /* @__PURE__ */ t("div", {
320
- className: c("kr-select-group", !f && "kr-select-group--with-separator", _),
522
+ return /* @__PURE__ */ n("div", {
523
+ className: l("kr-select-group", !f && "kr-select-group--with-separator", _),
321
524
  style: v,
322
- children: [(n || r) && /* @__PURE__ */ t("div", {
525
+ children: [(e || r) && /* @__PURE__ */ n("div", {
323
526
  className: "kr-select-group__header",
324
- children: [n && /* @__PURE__ */ e("div", {
527
+ children: [e && /* @__PURE__ */ t("div", {
325
528
  className: "kr-select-group__header__title",
326
- children: n
327
- }), r && /* @__PURE__ */ e("div", {
529
+ children: e
530
+ }), r && /* @__PURE__ */ t("div", {
328
531
  className: "kr-select-group__header__subtitle",
329
532
  children: r
330
533
  })]
331
- }), /* @__PURE__ */ e("div", {
534
+ }), /* @__PURE__ */ t("div", {
332
535
  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,
536
+ style: x,
537
+ children: /* @__PURE__ */ t(O.Provider, {
538
+ value: C,
539
+ children: y ? i.map((e) => /* @__PURE__ */ t("div", { children: y(e, u === e.value, S) }, e.value)) : i.map((e) => /* @__PURE__ */ t(k, {
540
+ value: e.value,
541
+ label: e.label,
339
542
  selected: u,
340
- disabled: t.disabled,
543
+ disabled: e.disabled,
341
544
  variant: h,
342
545
  shape: g,
343
- showItemLabel: o,
344
- title: l ? t.label : void 0,
345
- children: h === "color" ? /* @__PURE__ */ e("div", {
546
+ showItemLabel: a,
547
+ title: s ? e.label : void 0,
548
+ children: h === "color" ? /* @__PURE__ */ t("div", {
346
549
  className: "kr-color-swatch",
347
- style: { background: t.hex }
348
- }) : h === "icon" && t.icon ? /* @__PURE__ */ e("svg", {
550
+ style: { background: e.hex }
551
+ }) : h === "icon" && e.icon ? /* @__PURE__ */ t("svg", {
349
552
  className: "kr-select-item-icon",
350
553
  viewBox: "0 0 32 32",
351
- children: /* @__PURE__ */ e("path", { d: t.icon })
352
- }) : t.label
353
- }, t.value))
554
+ children: /* @__PURE__ */ t("path", { d: e.icon })
555
+ }) : e.label
556
+ }, e.value))
354
557
  })
355
558
  })]
356
559
  });
357
560
  }
358
561
  //#endregion
359
562
  //#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;
563
+ function j(e, t) {
564
+ let [n, r] = c(e ? "entered" : "left"), [i, o] = c(!1), u = s(null);
565
+ return a(() => {
566
+ r(e ? (e) => e === "entering" || e === "entered" ? e : (o(!0), "entering") : (e) => e === "leaving" || e === "left" ? e : (o(!1), "leaving"));
567
+ }, [e]), a(() => {
568
+ let e = n === "entering" && i ? !1 : n === "leaving" && !i || null;
366
569
  if (e === null) return;
367
570
  let t = -1, r = requestAnimationFrame(() => {
368
- t = requestAnimationFrame(() => l(e));
571
+ t = requestAnimationFrame(() => o(e));
369
572
  });
370
573
  return () => {
371
574
  cancelAnimationFrame(r), cancelAnimationFrame(t);
372
575
  };
373
- }, [n, a]), i(() => {
576
+ }, [n, i]), a(() => {
374
577
  if (n !== "entering" && n !== "leaving") return;
375
578
  let e = u.current;
376
579
  if (!e) return;
@@ -380,32 +583,32 @@ function w(e, t) {
380
583
  return e.addEventListener("transitionend", t), () => e.removeEventListener("transitionend", t);
381
584
  }, [n]), {
382
585
  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,
586
+ transitionClassName: n === "entering" ? l(`${t}-enter-active`, i && `${t}-enter-from`) : n === "leaving" ? l(`${t}-leave-active`, i && `${t}-leave-to`) : void 0,
384
587
  ref: u
385
588
  };
386
589
  }
387
590
  //#endregion
388
591
  //#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", {
592
+ function M({ show: e, onShowChange: r, centered: i = !1, background: a, contentStyle: o, contentTransition: s = "fade-in", children: c }) {
593
+ let { shouldRender: u, transitionClassName: d, ref: f } = j(e, `kr-${s}-content`);
594
+ return u ? /* @__PURE__ */ n("div", {
392
595
  ref: f,
393
- className: c("kr-overlay", i && "kr-overlay--centered", d),
596
+ className: l("kr-overlay", i && "kr-overlay--centered", d),
394
597
  style: { "--kr-overlay-background": a },
395
598
  role: "application",
396
- children: [/* @__PURE__ */ e("div", {
599
+ children: [/* @__PURE__ */ t("div", {
397
600
  className: "kr-overlay__scrim",
398
601
  onClick: () => r?.(!1)
399
- }), /* @__PURE__ */ e("div", {
602
+ }), /* @__PURE__ */ t("div", {
400
603
  className: "kr-overlay__content",
401
604
  style: o,
402
- children: l
605
+ children: c
403
606
  })]
404
607
  }) : null;
405
608
  }
406
609
  //#endregion
407
610
  //#region src/core/toastTimer.ts
408
- function E(e) {
611
+ function N(e) {
409
612
  let t, n;
410
613
  function r() {
411
614
  t !== void 0 && (clearTimeout(t), t = void 0), n !== void 0 && (clearInterval(n), n = void 0);
@@ -426,38 +629,38 @@ function E(e) {
426
629
  }
427
630
  //#endregion
428
631
  //#region src/react/components/KrToast.tsx
429
- var D = /* @__PURE__ */ e("svg", {
632
+ var P = /* @__PURE__ */ t("svg", {
430
633
  viewBox: "0 0 24 24",
431
634
  fill: "none",
432
635
  width: "1em",
433
636
  height: "1em",
434
- children: /* @__PURE__ */ e("path", {
637
+ children: /* @__PURE__ */ t("path", {
435
638
  d: "M20 6L9 17L4 12",
436
639
  stroke: "currentColor",
437
640
  strokeWidth: "2",
438
641
  strokeLinecap: "round",
439
642
  strokeLinejoin: "round"
440
643
  })
441
- }), O = /* @__PURE__ */ t("svg", {
644
+ }), F = /* @__PURE__ */ n("svg", {
442
645
  viewBox: "0 0 24 24",
443
646
  fill: "none",
444
647
  width: "1em",
445
648
  height: "1em",
446
649
  children: [
447
- /* @__PURE__ */ e("circle", {
650
+ /* @__PURE__ */ t("circle", {
448
651
  cx: "12",
449
652
  cy: "12",
450
653
  r: "9",
451
654
  stroke: "currentColor",
452
655
  strokeWidth: "2"
453
656
  }),
454
- /* @__PURE__ */ e("path", {
657
+ /* @__PURE__ */ t("path", {
455
658
  d: "M12 8V13",
456
659
  stroke: "currentColor",
457
660
  strokeWidth: "2",
458
661
  strokeLinecap: "round"
459
662
  }),
460
- /* @__PURE__ */ e("circle", {
663
+ /* @__PURE__ */ t("circle", {
461
664
  cx: "12",
462
665
  cy: "16",
463
666
  r: "1",
@@ -465,49 +668,49 @@ var D = /* @__PURE__ */ e("svg", {
465
668
  })
466
669
  ]
467
670
  });
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);
671
+ function I({ show: e = !1, onShowChange: r, text: i, icon: o, iconContent: u, timeout: d = 3, actionText: f, onAction: p, showCountdown: m }) {
672
+ let [h, g] = c(d), _ = s(r);
470
673
  _.current = r;
471
- let v = o(null);
472
- v.current ||= E({
674
+ let v = s(null);
675
+ v.current ||= N({
473
676
  onDismiss: () => _.current?.(!1),
474
677
  onTick: (e) => g(e)
475
- }), i(() => {
476
- n ? v.current.start({
678
+ }), a(() => {
679
+ e ? v.current.start({
477
680
  timeoutSeconds: d,
478
681
  showCountdown: m
479
682
  }) : v.current.clear();
480
- }, [n]), i(() => () => v.current?.clear(), []);
481
- let { shouldRender: y, transitionClassName: b, ref: x } = w(n, "kr-fade-in-up");
683
+ }, [e]), a(() => () => v.current?.clear(), []);
684
+ let { shouldRender: y, transitionClassName: b, ref: x } = j(e, "kr-fade-in-up");
482
685
  function S(e) {
483
686
  e.stopPropagation(), p?.(), _.current?.(!1);
484
687
  }
485
688
  function C() {
486
689
  f || _.current?.(!1);
487
690
  }
488
- return y ? /* @__PURE__ */ t("div", {
691
+ return y ? /* @__PURE__ */ n("div", {
489
692
  ref: x,
490
- className: c("kr-toast", b),
693
+ className: l("kr-toast", b),
491
694
  role: "status",
492
695
  "aria-live": "polite",
493
696
  onClick: C,
494
697
  children: [
495
- l && /* @__PURE__ */ e("div", {
698
+ o && /* @__PURE__ */ t("div", {
496
699
  className: "kr-toast__icon",
497
- children: u ?? (l === "success" ? D : O)
700
+ children: u ?? (o === "success" ? P : F)
498
701
  }),
499
- /* @__PURE__ */ e("div", {
702
+ /* @__PURE__ */ t("div", {
500
703
  className: "kr-toast__text",
501
- children: a
704
+ children: i
502
705
  }),
503
- f && /* @__PURE__ */ t("div", {
706
+ f && /* @__PURE__ */ n("div", {
504
707
  className: "kr-toast__actions",
505
- children: [/* @__PURE__ */ e("button", {
708
+ children: [/* @__PURE__ */ t("button", {
506
709
  className: "kr-toast__action",
507
710
  type: "button",
508
711
  onClick: S,
509
712
  children: f
510
- }), m && /* @__PURE__ */ t("span", {
713
+ }), m && /* @__PURE__ */ n("span", {
511
714
  className: "kr-toast__countdown",
512
715
  "aria-hidden": "true",
513
716
  children: [h, "s"]
@@ -518,21 +721,21 @@ function k({ show: n = !1, onShowChange: r, text: a, icon: l, iconContent: u, ti
518
721
  }
519
722
  //#endregion
520
723
  //#region src/core/focusTrap.ts
521
- function A(e) {
724
+ function L(e) {
522
725
  return Array.from(e?.querySelectorAll("button:not([disabled]), input:not([disabled])") ?? []);
523
726
  }
524
- function j(e) {
525
- let t = A(e), n = t.findIndex((e) => e === document.activeElement);
727
+ function R(e) {
728
+ let t = L(e), n = t.findIndex((e) => e === document.activeElement);
526
729
  (n === t.length - 1 ? t[0] : t[n + 1])?.focus();
527
730
  }
528
- function M(e) {
529
- let t = A(e), n = t.findIndex((e) => e === document.activeElement);
731
+ function z(e) {
732
+ let t = L(e), n = t.findIndex((e) => e === document.activeElement);
530
733
  (n <= 0 ? t[t.length - 1] : t[n - 1])?.focus();
531
734
  }
532
735
  //#endregion
533
736
  //#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);
737
+ function B({ show: e = !1, onShowChange: r, title: i = "", text: a = "", actions: o = [], cancelText: l = "Cancel", hideCancel: u = !1, children: d }) {
738
+ let [f, p] = c(!1), m = s(null);
536
739
  function g() {
537
740
  r?.(!1);
538
741
  }
@@ -551,50 +754,50 @@ function N({ show: n = !1, onShowChange: r, title: i = "", text: a = "", actions
551
754
  e.preventDefault(), r?.(!1);
552
755
  return;
553
756
  }
554
- e.key === "Tab" && (e.preventDefault(), e.shiftKey ? M(h.current) : j(h.current));
757
+ e.key === "Tab" && (e.preventDefault(), e.shiftKey ? z(m.current) : R(m.current));
555
758
  }
556
- return /* @__PURE__ */ e(T, {
557
- show: n,
759
+ return /* @__PURE__ */ t(M, {
760
+ show: e,
558
761
  onShowChange: r,
559
762
  centered: !0,
560
- children: /* @__PURE__ */ t("dialog", {
561
- ref: h,
763
+ children: /* @__PURE__ */ n("dialog", {
764
+ ref: m,
562
765
  className: "kr-dialog",
563
- open: n,
766
+ open: e,
564
767
  onKeyDown: v,
565
768
  children: [
566
- i && /* @__PURE__ */ e("h2", {
769
+ i && /* @__PURE__ */ t("h2", {
567
770
  className: "kr-dialog__title",
568
771
  children: i
569
772
  }),
570
- /* @__PURE__ */ t("div", {
773
+ /* @__PURE__ */ n("div", {
571
774
  className: "kr-dialog__content",
572
- children: [a && /* @__PURE__ */ e("div", {
775
+ children: [a && /* @__PURE__ */ t("div", {
573
776
  className: "kr-dialog__content__text",
574
777
  children: a
575
- }), d && /* @__PURE__ */ e("div", {
778
+ }), d && /* @__PURE__ */ t("div", {
576
779
  className: "kr-dialog__content__form",
577
780
  children: d
578
781
  })]
579
782
  }),
580
- /* @__PURE__ */ t("div", {
783
+ /* @__PURE__ */ n("div", {
581
784
  className: "kr-dialog__actions",
582
- children: [!u && /* @__PURE__ */ e(m, {
785
+ children: [!u && /* @__PURE__ */ t(h, {
583
786
  type: "secondary",
584
787
  disabled: f,
585
788
  onClick: g,
586
789
  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))]
790
+ }), o.map((e) => /* @__PURE__ */ t(h, {
791
+ disabled: f || e.disabled,
792
+ onClick: () => _(e.action),
793
+ children: e.text
794
+ }, e.text))]
592
795
  })
593
796
  ]
594
797
  })
595
798
  });
596
799
  }
597
800
  //#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 };
801
+ export { h as KrButton, b as KrButtonRow, y as KrCheckboxRow, u as KrChevron, B as KrDialog, f as KrEmpty, S as KrLinkRow, m as KrMenuItem, C as KrNavigationRow, M as KrOverlay, v as KrRadioRow, D as KrSearchInput, p as KrSection, A as KrSelectGroup, O as KrSelectGroupContext, k as KrSelectItem, g as KrSwitch, w as KrTextField, I as KrToast, _ as KrToggleRow };
599
802
 
600
803
  //# sourceMappingURL=kroma-react.js.map