@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.
- package/LICENSE +21 -0
- package/README.md +185 -0
- package/dist/core/focusTrap.d.ts +3 -0
- package/dist/core/toastTimer.d.ts +13 -0
- package/dist/core/types.d.ts +35 -0
- package/dist/kroma-react.cjs +2 -0
- package/dist/kroma-react.cjs.map +1 -0
- package/dist/kroma-react.d.ts +2 -0
- package/dist/kroma-react.js +600 -0
- package/dist/kroma-react.js.map +1 -0
- package/dist/kroma-ui.css +804 -0
- package/dist/kroma-vue.cjs +2 -0
- package/dist/kroma-vue.cjs.map +1 -0
- package/dist/kroma-vue.d.ts +2 -0
- package/dist/kroma-vue.js +706 -0
- package/dist/kroma-vue.js.map +1 -0
- package/dist/kroma.css +804 -0
- package/dist/react/components/KrButton.d.ts +7 -0
- package/dist/react/components/KrChevron.d.ts +3 -0
- package/dist/react/components/KrDialog.d.ts +14 -0
- package/dist/react/components/KrEmpty.d.ts +7 -0
- package/dist/react/components/KrMenuItem.d.ts +7 -0
- package/dist/react/components/KrOverlay.d.ts +11 -0
- package/dist/react/components/KrSearchInput.d.ts +11 -0
- package/dist/react/components/KrSection.d.ts +6 -0
- package/dist/react/components/KrSelectGroup.d.ts +21 -0
- package/dist/react/components/KrSelectItem.d.ts +17 -0
- package/dist/react/components/KrSwitch.d.ts +7 -0
- package/dist/react/components/KrTextField.d.ts +10 -0
- package/dist/react/components/KrToast.d.ts +15 -0
- package/dist/react/components/KrToggleRow.d.ts +10 -0
- package/dist/react/hooks/useCssTransition.d.ts +12 -0
- package/dist/react/index.d.ts +28 -0
- package/dist/react/utils/cx.d.ts +1 -0
- package/dist/vue/components/KrButton.vue.d.ts +20 -0
- package/dist/vue/components/KrChevron.vue.d.ts +3 -0
- package/dist/vue/components/KrDialog.vue.d.ts +34 -0
- package/dist/vue/components/KrEmpty.vue.d.ts +17 -0
- package/dist/vue/components/KrMenuItem.vue.d.ts +15 -0
- package/dist/vue/components/KrOverlay.vue.d.ts +28 -0
- package/dist/vue/components/KrSearchInput.vue.d.ts +30 -0
- package/dist/vue/components/KrSection.vue.d.ts +17 -0
- package/dist/vue/components/KrSelectGroup.vue.d.ts +44 -0
- package/dist/vue/components/KrSelectItem.vue.d.ts +25 -0
- package/dist/vue/components/KrSwitch.vue.d.ts +12 -0
- package/dist/vue/components/KrTextField.vue.d.ts +13 -0
- package/dist/vue/components/KrToast.vue.d.ts +32 -0
- package/dist/vue/components/KrToggleRow.vue.d.ts +18 -0
- package/dist/vue/index.d.ts +20 -0
- package/package.json +92 -0
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
import { Fragment as e, Transition as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, inject as u, mergeProps as d, normalizeClass as f, normalizeStyle as p, onBeforeUnmount as m, openBlock as h, provide as g, ref as _, renderList as v, renderSlot as y, toDisplayString as b, unref as x, vModelCheckbox as S, vModelText as C, vShow as w, watch as T, withCtx as E, withDirectives as D, withKeys as O, withModifiers as k } from "vue";
|
|
2
|
+
//#endregion
|
|
3
|
+
//#region src/vue/components/KrButton.vue
|
|
4
|
+
var A = /* @__PURE__ */ l({
|
|
5
|
+
__name: "KrButton",
|
|
6
|
+
props: { type: { default: "primary" } },
|
|
7
|
+
setup(e) {
|
|
8
|
+
return (t, n) => (h(), a("button", { class: f(["kr-button", "kr-button--" + e.type]) }, [y(t.$slots, "default")], 2));
|
|
9
|
+
}
|
|
10
|
+
}), j = /* @__PURE__ */ l({
|
|
11
|
+
__name: "KrOverlay",
|
|
12
|
+
props: {
|
|
13
|
+
modelValue: { type: Boolean },
|
|
14
|
+
centered: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: !1
|
|
17
|
+
},
|
|
18
|
+
background: {},
|
|
19
|
+
contentStyle: { type: [
|
|
20
|
+
Boolean,
|
|
21
|
+
null,
|
|
22
|
+
String,
|
|
23
|
+
Object,
|
|
24
|
+
Array
|
|
25
|
+
] },
|
|
26
|
+
contentTransition: { default: "fade-in" }
|
|
27
|
+
},
|
|
28
|
+
emits: ["update:modelValue"],
|
|
29
|
+
setup(e, { emit: n }) {
|
|
30
|
+
let s = n;
|
|
31
|
+
return (n, c) => (h(), r(t, { name: `kr-${e.contentTransition}-content` }, {
|
|
32
|
+
default: E(() => [e.modelValue ? (h(), a("div", {
|
|
33
|
+
key: 0,
|
|
34
|
+
class: f(["kr-overlay", { "kr-overlay--centered": e.centered }]),
|
|
35
|
+
style: p({ "--kr-overlay-background": e.background }),
|
|
36
|
+
role: "application"
|
|
37
|
+
}, [o("div", {
|
|
38
|
+
class: "kr-overlay__scrim",
|
|
39
|
+
onClick: c[0] ||= (e) => s("update:modelValue", !1)
|
|
40
|
+
}), o("div", {
|
|
41
|
+
class: "kr-overlay__content",
|
|
42
|
+
style: p(e.contentStyle)
|
|
43
|
+
}, [y(n.$slots, "default")], 4)], 6)) : i("", !0)]),
|
|
44
|
+
_: 3
|
|
45
|
+
}, 8, ["name"]));
|
|
46
|
+
}
|
|
47
|
+
}), ee = { class: "kr-section" }, te = {
|
|
48
|
+
key: 0,
|
|
49
|
+
class: "kr-section__header"
|
|
50
|
+
}, ne = {
|
|
51
|
+
key: 0,
|
|
52
|
+
class: "kr-section__title"
|
|
53
|
+
}, M = {
|
|
54
|
+
key: 1,
|
|
55
|
+
class: "kr-section__subtitle"
|
|
56
|
+
}, N = { class: "kr-section__content" }, P = /* @__PURE__ */ l({
|
|
57
|
+
__name: "KrSection",
|
|
58
|
+
props: {
|
|
59
|
+
title: {},
|
|
60
|
+
subtitle: {}
|
|
61
|
+
},
|
|
62
|
+
setup(e) {
|
|
63
|
+
return (t, n) => (h(), a("section", ee, [e.title || e.subtitle ? (h(), a("header", te, [e.title ? (h(), a("h1", ne, b(e.title), 1)) : i("", !0), e.subtitle ? (h(), a("h2", M, b(e.subtitle), 1)) : i("", !0)])) : i("", !0), o("div", N, [y(t.$slots, "default")])]));
|
|
64
|
+
}
|
|
65
|
+
}), F = ["title"], I = [
|
|
66
|
+
"name",
|
|
67
|
+
"value",
|
|
68
|
+
"checked",
|
|
69
|
+
"disabled",
|
|
70
|
+
"aria-label"
|
|
71
|
+
], L = { class: "kr-select-item__content" }, R = {
|
|
72
|
+
key: 0,
|
|
73
|
+
class: "kr-select-item__label"
|
|
74
|
+
}, z = /* @__PURE__ */ l({
|
|
75
|
+
__name: "KrSelectItem",
|
|
76
|
+
props: {
|
|
77
|
+
value: {},
|
|
78
|
+
label: {},
|
|
79
|
+
title: {},
|
|
80
|
+
selected: {},
|
|
81
|
+
disabled: { type: Boolean },
|
|
82
|
+
variant: { default: "default" },
|
|
83
|
+
shape: { default: "rounded" },
|
|
84
|
+
circle: { type: Boolean },
|
|
85
|
+
stretch: { type: Boolean },
|
|
86
|
+
showItemLabel: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: !0
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
emits: ["update:selected", "select"],
|
|
92
|
+
setup(e, { emit: t }) {
|
|
93
|
+
let r = e, s = t, c = u("krSelectGroupContext", null), l = n(() => (c?.modelValue?.value ?? r.selected) === r.value), d = n(() => c?.variant?.value ?? r.variant), p = n(() => r.circle ? "circle" : c?.shape?.value ?? r.shape), m = n(() => c?.showItemLabel?.value ?? r.showItemLabel ? r.label ?? r.title : "");
|
|
94
|
+
function g() {
|
|
95
|
+
r.disabled || (s("update:selected", r.value), s("select", r.value), c?.onSelect?.(r.value));
|
|
96
|
+
}
|
|
97
|
+
let _ = n(() => ({
|
|
98
|
+
"kr-select-item": !0,
|
|
99
|
+
"kr-select-item--selected": l.value,
|
|
100
|
+
"kr-select-item--disabled": r.disabled,
|
|
101
|
+
"kr-select-item--stretch": r.stretch,
|
|
102
|
+
[`kr-select-item--${d.value}`]: !0,
|
|
103
|
+
[`kr-select-item--${p.value}`]: !0
|
|
104
|
+
}));
|
|
105
|
+
return (t, n) => (h(), a("label", {
|
|
106
|
+
class: f(["kr-select-item", _.value]),
|
|
107
|
+
title: e.title
|
|
108
|
+
}, [
|
|
109
|
+
o("input", {
|
|
110
|
+
class: "kr-select-item__input",
|
|
111
|
+
type: "radio",
|
|
112
|
+
name: x(c)?.name,
|
|
113
|
+
value: e.value,
|
|
114
|
+
checked: l.value,
|
|
115
|
+
disabled: e.disabled,
|
|
116
|
+
"aria-label": e.label || e.title || String(e.value),
|
|
117
|
+
onChange: g
|
|
118
|
+
}, null, 40, I),
|
|
119
|
+
o("div", L, [y(t.$slots, "default")]),
|
|
120
|
+
m.value ? (h(), a("div", R, b(m.value), 1)) : i("", !0)
|
|
121
|
+
], 10, F));
|
|
122
|
+
}
|
|
123
|
+
}), B = {
|
|
124
|
+
key: 0,
|
|
125
|
+
class: "kr-select-group__header"
|
|
126
|
+
}, V = {
|
|
127
|
+
key: 0,
|
|
128
|
+
class: "kr-select-group__header__title"
|
|
129
|
+
}, H = {
|
|
130
|
+
key: 1,
|
|
131
|
+
class: "kr-select-group__header__subtitle"
|
|
132
|
+
}, U = {
|
|
133
|
+
key: 1,
|
|
134
|
+
class: "kr-select-item-icon",
|
|
135
|
+
viewBox: "0 0 32 32"
|
|
136
|
+
}, W = ["d"], G = /* @__PURE__ */ l({
|
|
137
|
+
__name: "KrSelectGroup",
|
|
138
|
+
props: {
|
|
139
|
+
title: {},
|
|
140
|
+
subtitle: {},
|
|
141
|
+
items: {},
|
|
142
|
+
showItemLabel: {
|
|
143
|
+
type: Boolean,
|
|
144
|
+
default: !0
|
|
145
|
+
},
|
|
146
|
+
showTooltip: {
|
|
147
|
+
type: Boolean,
|
|
148
|
+
default: !0
|
|
149
|
+
},
|
|
150
|
+
modelValue: {},
|
|
151
|
+
hideSeparator: { type: Boolean },
|
|
152
|
+
columns: { default: "auto" },
|
|
153
|
+
gap: { default: "12px" },
|
|
154
|
+
variant: { default: "default" },
|
|
155
|
+
shape: { default: "rounded" }
|
|
156
|
+
},
|
|
157
|
+
emits: ["update:modelValue"],
|
|
158
|
+
setup(t, { emit: c }) {
|
|
159
|
+
let l = t, u = c, d = `kr-select-group-${Math.random().toString(36).slice(2)}`, m = n(() => l.columns === "auto" ? {
|
|
160
|
+
display: "flex",
|
|
161
|
+
flexWrap: "wrap",
|
|
162
|
+
gap: l.gap
|
|
163
|
+
} : {
|
|
164
|
+
display: "grid",
|
|
165
|
+
gridTemplateColumns: `repeat(${l.columns}, 1fr)`,
|
|
166
|
+
gap: l.gap
|
|
167
|
+
});
|
|
168
|
+
function _(e) {
|
|
169
|
+
u("update:modelValue", e);
|
|
170
|
+
}
|
|
171
|
+
return g("krSelectGroupContext", {
|
|
172
|
+
modelValue: n(() => l.modelValue),
|
|
173
|
+
variant: n(() => l.variant),
|
|
174
|
+
shape: n(() => l.shape),
|
|
175
|
+
showItemLabel: n(() => l.showItemLabel),
|
|
176
|
+
name: d,
|
|
177
|
+
onSelect: _
|
|
178
|
+
}), (n, c) => (h(), a("div", { class: f(["kr-select-group", { "kr-select-group--with-separator": !t.hideSeparator }]) }, [t.title || t.subtitle ? (h(), a("div", B, [t.title ? (h(), a("div", V, b(t.title), 1)) : i("", !0), t.subtitle ? (h(), a("div", H, b(t.subtitle), 1)) : i("", !0)])) : i("", !0), o("div", {
|
|
179
|
+
class: "kr-select-group__items",
|
|
180
|
+
style: p(m.value)
|
|
181
|
+
}, [n.$slots.item ? (h(!0), a(e, { key: 0 }, v(t.items, (e) => y(n.$slots, "item", {
|
|
182
|
+
item: e,
|
|
183
|
+
selected: t.modelValue === e.value,
|
|
184
|
+
setSelected: _
|
|
185
|
+
}, void 0, void 0, e.value)), 128)) : (h(!0), a(e, { key: 1 }, v(t.items, (n) => (h(), r(z, {
|
|
186
|
+
key: n.value,
|
|
187
|
+
value: n.value,
|
|
188
|
+
label: n.label,
|
|
189
|
+
selected: t.modelValue,
|
|
190
|
+
disabled: n.disabled,
|
|
191
|
+
variant: t.variant,
|
|
192
|
+
shape: t.shape,
|
|
193
|
+
"show-item-label": t.showItemLabel,
|
|
194
|
+
title: t.showTooltip ? n.label : void 0,
|
|
195
|
+
onSelect: _
|
|
196
|
+
}, {
|
|
197
|
+
default: E(() => [t.variant === "color" ? (h(), a("div", {
|
|
198
|
+
key: 0,
|
|
199
|
+
class: "kr-color-swatch",
|
|
200
|
+
style: p({ background: n.hex })
|
|
201
|
+
}, null, 4)) : t.variant === "icon" && n.icon ? (h(), a("svg", U, [o("path", { d: n.icon }, null, 8, W)])) : (h(), a(e, { key: 2 }, [s(b(n.label), 1)], 64))]),
|
|
202
|
+
_: 2
|
|
203
|
+
}, 1032, [
|
|
204
|
+
"value",
|
|
205
|
+
"label",
|
|
206
|
+
"selected",
|
|
207
|
+
"disabled",
|
|
208
|
+
"variant",
|
|
209
|
+
"shape",
|
|
210
|
+
"show-item-label",
|
|
211
|
+
"title"
|
|
212
|
+
]))), 128))], 4)], 2));
|
|
213
|
+
}
|
|
214
|
+
}), K = ["data-checked", "data-disabled"], q = /* @__PURE__ */ l({
|
|
215
|
+
__name: "KrSwitch",
|
|
216
|
+
props: {
|
|
217
|
+
modelValue: {
|
|
218
|
+
type: Boolean,
|
|
219
|
+
default: !1
|
|
220
|
+
},
|
|
221
|
+
disabled: {
|
|
222
|
+
type: Boolean,
|
|
223
|
+
default: !1
|
|
224
|
+
},
|
|
225
|
+
inset: {
|
|
226
|
+
type: Boolean,
|
|
227
|
+
default: !1
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
setup(e) {
|
|
231
|
+
return (t, n) => (h(), a("div", {
|
|
232
|
+
class: f(["kr-switch", { "kr-switch--inset": e.inset }]),
|
|
233
|
+
"data-checked": e.modelValue,
|
|
234
|
+
"data-disabled": e.disabled,
|
|
235
|
+
"aria-hidden": "true"
|
|
236
|
+
}, [...n[0] ||= [o("div", { class: "kr-switch__track" }, null, -1), o("div", { class: "kr-switch__thumb" }, null, -1)]], 10, K));
|
|
237
|
+
}
|
|
238
|
+
}), J = ["disabled", "aria-label"], Y = { class: "kr-toggle-row__label" }, X = {
|
|
239
|
+
key: 0,
|
|
240
|
+
class: "kr-toggle-row__title"
|
|
241
|
+
}, Z = {
|
|
242
|
+
key: 1,
|
|
243
|
+
class: "kr-toggle-row__subtitle"
|
|
244
|
+
}, re = /* @__PURE__ */ l({
|
|
245
|
+
__name: "KrToggleRow",
|
|
246
|
+
props: {
|
|
247
|
+
modelValue: {
|
|
248
|
+
type: Boolean,
|
|
249
|
+
default: !1
|
|
250
|
+
},
|
|
251
|
+
title: {},
|
|
252
|
+
subtitle: {},
|
|
253
|
+
disabled: {
|
|
254
|
+
type: Boolean,
|
|
255
|
+
default: !1
|
|
256
|
+
},
|
|
257
|
+
hideSeparator: {
|
|
258
|
+
type: Boolean,
|
|
259
|
+
default: !1
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
emits: ["update:modelValue"],
|
|
263
|
+
setup(e, { emit: t }) {
|
|
264
|
+
let r = e, s = t, l = n({
|
|
265
|
+
get() {
|
|
266
|
+
return r.modelValue;
|
|
267
|
+
},
|
|
268
|
+
set(e) {
|
|
269
|
+
s("update:modelValue", e);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
return (t, n) => (h(), a("label", { class: f(["kr-toggle-row", {
|
|
273
|
+
"kr-toggle-row--with-separator": !e.hideSeparator,
|
|
274
|
+
"kr-toggle-row--disabled": e.disabled
|
|
275
|
+
}]) }, [
|
|
276
|
+
D(o("input", {
|
|
277
|
+
class: "kr-toggle-row__native",
|
|
278
|
+
type: "checkbox",
|
|
279
|
+
role: "switch",
|
|
280
|
+
"onUpdate:modelValue": n[0] ||= (e) => l.value = e,
|
|
281
|
+
disabled: e.disabled,
|
|
282
|
+
"aria-label": e.title
|
|
283
|
+
}, null, 8, J), [[S, l.value]]),
|
|
284
|
+
o("div", Y, [e.title ? (h(), a("div", X, b(e.title), 1)) : i("", !0), e.subtitle ? (h(), a("div", Z, b(e.subtitle), 1)) : i("", !0)]),
|
|
285
|
+
c(q, {
|
|
286
|
+
"model-value": l.value,
|
|
287
|
+
disabled: e.disabled
|
|
288
|
+
}, null, 8, ["model-value", "disabled"])
|
|
289
|
+
], 2));
|
|
290
|
+
}
|
|
291
|
+
}), ie = { class: "kr-textfield" }, ae = {
|
|
292
|
+
key: 0,
|
|
293
|
+
class: "kr-textfield__label-text"
|
|
294
|
+
}, oe = /* @__PURE__ */ l({
|
|
295
|
+
__name: "KrTextField",
|
|
296
|
+
props: {
|
|
297
|
+
modelValue: {},
|
|
298
|
+
label: {},
|
|
299
|
+
error: { type: Boolean },
|
|
300
|
+
autofocus: { type: Boolean }
|
|
301
|
+
},
|
|
302
|
+
emits: ["update:modelValue"],
|
|
303
|
+
setup(e, { emit: t }) {
|
|
304
|
+
let r = e, s = t, c = n({
|
|
305
|
+
get() {
|
|
306
|
+
return r.modelValue;
|
|
307
|
+
},
|
|
308
|
+
set(e) {
|
|
309
|
+
s("update:modelValue", e);
|
|
310
|
+
}
|
|
311
|
+
}), l = { mounted: (e) => r.autofocus && e.focus() };
|
|
312
|
+
return (t, n) => (h(), a("label", ie, [e.label ? (h(), a("span", ae, b(e.label), 1)) : i("", !0), D(o("input", d({
|
|
313
|
+
type: "text",
|
|
314
|
+
class: ["kr-textfield__input", { "kr-textfield__input--error": e.error }],
|
|
315
|
+
"onUpdate:modelValue": n[0] ||= (e) => c.value = e
|
|
316
|
+
}, t.$attrs), null, 16), [[
|
|
317
|
+
C,
|
|
318
|
+
c.value,
|
|
319
|
+
void 0,
|
|
320
|
+
{ trim: !0 }
|
|
321
|
+
], [l]])]));
|
|
322
|
+
}
|
|
323
|
+
}), se = { class: "kr-search-input" }, ce = { class: "kr-search-input__icon" }, le = ["autofocus", "aria-label"], ue = ["aria-label"], de = /* @__PURE__ */ l({
|
|
324
|
+
__name: "KrSearchInput",
|
|
325
|
+
props: {
|
|
326
|
+
modelValue: { default: "" },
|
|
327
|
+
autofocus: {
|
|
328
|
+
type: Boolean,
|
|
329
|
+
default: !0
|
|
330
|
+
},
|
|
331
|
+
label: { default: "Search" },
|
|
332
|
+
clearLabel: { default: "Clear" }
|
|
333
|
+
},
|
|
334
|
+
emits: ["update:modelValue"],
|
|
335
|
+
setup(e, { emit: t }) {
|
|
336
|
+
let r = e, i = _(null), s = t, c = n({
|
|
337
|
+
get() {
|
|
338
|
+
return r.modelValue;
|
|
339
|
+
},
|
|
340
|
+
set(e) {
|
|
341
|
+
s("update:modelValue", e), r.autofocus && i.value?.focus();
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
function l() {
|
|
345
|
+
c.value = "";
|
|
346
|
+
}
|
|
347
|
+
return (t, n) => (h(), a("div", se, [
|
|
348
|
+
o("div", ce, [y(t.$slots, "icon", {}, () => [n[1] ||= o("svg", {
|
|
349
|
+
viewBox: "0 0 24 24",
|
|
350
|
+
fill: "none",
|
|
351
|
+
width: "1em",
|
|
352
|
+
height: "1em"
|
|
353
|
+
}, [o("circle", {
|
|
354
|
+
cx: "11",
|
|
355
|
+
cy: "11",
|
|
356
|
+
r: "7",
|
|
357
|
+
stroke: "currentColor",
|
|
358
|
+
"stroke-width": "2"
|
|
359
|
+
}), o("path", {
|
|
360
|
+
d: "M20 20L16.65 16.65",
|
|
361
|
+
stroke: "currentColor",
|
|
362
|
+
"stroke-width": "2",
|
|
363
|
+
"stroke-linecap": "round"
|
|
364
|
+
})], -1)])]),
|
|
365
|
+
D(o("input", {
|
|
366
|
+
ref_key: "inputRef",
|
|
367
|
+
ref: i,
|
|
368
|
+
class: "kr-search-input__input",
|
|
369
|
+
type: "text",
|
|
370
|
+
"onUpdate:modelValue": n[0] ||= (e) => c.value = e,
|
|
371
|
+
autofocus: e.autofocus,
|
|
372
|
+
"aria-label": e.label
|
|
373
|
+
}, null, 8, le), [[C, c.value]]),
|
|
374
|
+
D(o("div", {
|
|
375
|
+
class: "kr-search-input__icon kr-search-input__icon--clear",
|
|
376
|
+
onClick: l,
|
|
377
|
+
role: "button",
|
|
378
|
+
tabindex: "0",
|
|
379
|
+
"aria-label": e.clearLabel,
|
|
380
|
+
onKeydown: O(l, ["enter"])
|
|
381
|
+
}, [y(t.$slots, "clear-icon", {}, () => [n[2] ||= o("svg", {
|
|
382
|
+
viewBox: "0 0 24 24",
|
|
383
|
+
fill: "none",
|
|
384
|
+
width: "1em",
|
|
385
|
+
height: "1em"
|
|
386
|
+
}, [o("path", {
|
|
387
|
+
d: "M6 6L18 18M18 6L6 18",
|
|
388
|
+
stroke: "currentColor",
|
|
389
|
+
"stroke-width": "2",
|
|
390
|
+
"stroke-linecap": "round"
|
|
391
|
+
})], -1)])], 40, ue), [[w, c.value]])
|
|
392
|
+
]));
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/core/toastTimer.ts
|
|
397
|
+
function fe(e) {
|
|
398
|
+
let t, n;
|
|
399
|
+
function r() {
|
|
400
|
+
t !== void 0 && (clearTimeout(t), t = void 0), n !== void 0 && (clearInterval(n), n = void 0);
|
|
401
|
+
}
|
|
402
|
+
function i({ timeoutSeconds: i, showCountdown: a }) {
|
|
403
|
+
if (r(), e.onTick?.(Math.max(0, Math.ceil(i))), i <= 0) return;
|
|
404
|
+
let o = Date.now() + i * 1e3;
|
|
405
|
+
t = setTimeout(() => {
|
|
406
|
+
e.onDismiss();
|
|
407
|
+
}, i * 1e3), a && (n = setInterval(() => {
|
|
408
|
+
e.onTick?.(Math.max(0, Math.ceil((o - Date.now()) / 1e3)));
|
|
409
|
+
}, 200));
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
start: i,
|
|
413
|
+
clear: r
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/vue/components/KrToast.vue?vue&type=script&setup=true&lang.ts
|
|
418
|
+
var pe = {
|
|
419
|
+
key: 0,
|
|
420
|
+
class: "kr-toast__icon"
|
|
421
|
+
}, me = {
|
|
422
|
+
key: 0,
|
|
423
|
+
viewBox: "0 0 24 24",
|
|
424
|
+
fill: "none",
|
|
425
|
+
width: "1em",
|
|
426
|
+
height: "1em"
|
|
427
|
+
}, he = {
|
|
428
|
+
key: 1,
|
|
429
|
+
viewBox: "0 0 24 24",
|
|
430
|
+
fill: "none",
|
|
431
|
+
width: "1em",
|
|
432
|
+
height: "1em"
|
|
433
|
+
}, ge = { class: "kr-toast__text" }, _e = {
|
|
434
|
+
key: 1,
|
|
435
|
+
class: "kr-toast__actions"
|
|
436
|
+
}, ve = {
|
|
437
|
+
key: 0,
|
|
438
|
+
class: "kr-toast__countdown",
|
|
439
|
+
"aria-hidden": "true"
|
|
440
|
+
}, ye = /* @__PURE__ */ l({
|
|
441
|
+
__name: "KrToast",
|
|
442
|
+
props: {
|
|
443
|
+
show: {
|
|
444
|
+
type: Boolean,
|
|
445
|
+
default: !1
|
|
446
|
+
},
|
|
447
|
+
text: {},
|
|
448
|
+
icon: {},
|
|
449
|
+
timeout: { default: 3 },
|
|
450
|
+
actionText: {},
|
|
451
|
+
showCountdown: { type: Boolean }
|
|
452
|
+
},
|
|
453
|
+
emits: ["update:show", "action"],
|
|
454
|
+
setup(e, { emit: s }) {
|
|
455
|
+
let c = e, l = s, u = n({
|
|
456
|
+
get() {
|
|
457
|
+
return c.show;
|
|
458
|
+
},
|
|
459
|
+
set(e) {
|
|
460
|
+
l("update:show", e);
|
|
461
|
+
}
|
|
462
|
+
}), d = _(c.timeout), f = fe({
|
|
463
|
+
onTick: (e) => {
|
|
464
|
+
d.value = e;
|
|
465
|
+
},
|
|
466
|
+
onDismiss: () => {
|
|
467
|
+
u.value = !1;
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
function p() {
|
|
471
|
+
l("action"), u.value = !1;
|
|
472
|
+
}
|
|
473
|
+
function g() {
|
|
474
|
+
c.actionText || (u.value = !1);
|
|
475
|
+
}
|
|
476
|
+
return T(() => c.show, (e) => {
|
|
477
|
+
e ? f.start({
|
|
478
|
+
timeoutSeconds: c.timeout,
|
|
479
|
+
showCountdown: c.showCountdown
|
|
480
|
+
}) : f.clear();
|
|
481
|
+
}, { immediate: !0 }), m(f.clear), (n, s) => (h(), r(t, { name: "kr-fade-in-up" }, {
|
|
482
|
+
default: E(() => [u.value ? (h(), a("div", {
|
|
483
|
+
key: 0,
|
|
484
|
+
class: "kr-toast",
|
|
485
|
+
role: "status",
|
|
486
|
+
"aria-live": "polite",
|
|
487
|
+
onClick: g
|
|
488
|
+
}, [
|
|
489
|
+
e.icon ? (h(), a("div", pe, [y(n.$slots, "icon", {}, () => [e.icon === "success" ? (h(), a("svg", me, [...s[0] ||= [o("path", {
|
|
490
|
+
d: "M20 6L9 17L4 12",
|
|
491
|
+
stroke: "currentColor",
|
|
492
|
+
"stroke-width": "2",
|
|
493
|
+
"stroke-linecap": "round",
|
|
494
|
+
"stroke-linejoin": "round"
|
|
495
|
+
}, null, -1)]])) : (h(), a("svg", he, [...s[1] ||= [
|
|
496
|
+
o("circle", {
|
|
497
|
+
cx: "12",
|
|
498
|
+
cy: "12",
|
|
499
|
+
r: "9",
|
|
500
|
+
stroke: "currentColor",
|
|
501
|
+
"stroke-width": "2"
|
|
502
|
+
}, null, -1),
|
|
503
|
+
o("path", {
|
|
504
|
+
d: "M12 8V13",
|
|
505
|
+
stroke: "currentColor",
|
|
506
|
+
"stroke-width": "2",
|
|
507
|
+
"stroke-linecap": "round"
|
|
508
|
+
}, null, -1),
|
|
509
|
+
o("circle", {
|
|
510
|
+
cx: "12",
|
|
511
|
+
cy: "16",
|
|
512
|
+
r: "1",
|
|
513
|
+
fill: "currentColor"
|
|
514
|
+
}, null, -1)
|
|
515
|
+
]]))])])) : i("", !0),
|
|
516
|
+
o("div", ge, b(e.text), 1),
|
|
517
|
+
e.actionText ? (h(), a("div", _e, [o("button", {
|
|
518
|
+
class: "kr-toast__action",
|
|
519
|
+
type: "button",
|
|
520
|
+
onClick: k(p, ["stop"])
|
|
521
|
+
}, b(e.actionText), 1), e.showCountdown ? (h(), a("span", ve, b(d.value) + "s", 1)) : i("", !0)])) : i("", !0)
|
|
522
|
+
])) : i("", !0)]),
|
|
523
|
+
_: 3
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
}), be = { class: "kr-empty" }, xe = { class: "kr-empty__icon" }, Se = { class: "kr-empty__title" }, Ce = { class: "kr-empty__description" }, we = /* @__PURE__ */ l({
|
|
527
|
+
__name: "KrEmpty",
|
|
528
|
+
props: {
|
|
529
|
+
title: {},
|
|
530
|
+
description: {}
|
|
531
|
+
},
|
|
532
|
+
setup(e) {
|
|
533
|
+
return (t, n) => (h(), a("div", be, [
|
|
534
|
+
o("div", xe, [y(t.$slots, "icon", {}, () => [n[0] ||= o("svg", {
|
|
535
|
+
viewBox: "0 0 64 64",
|
|
536
|
+
fill: "none",
|
|
537
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
538
|
+
}, [
|
|
539
|
+
o("rect", {
|
|
540
|
+
x: "10",
|
|
541
|
+
y: "24",
|
|
542
|
+
width: "44",
|
|
543
|
+
height: "30",
|
|
544
|
+
rx: "4",
|
|
545
|
+
stroke: "var(--kr-on-surface-tertiary)",
|
|
546
|
+
"stroke-width": "2"
|
|
547
|
+
}),
|
|
548
|
+
o("path", {
|
|
549
|
+
d: "M10 26L18 10H46L54 26",
|
|
550
|
+
stroke: "var(--kr-on-surface-tertiary)",
|
|
551
|
+
"stroke-width": "2",
|
|
552
|
+
"stroke-linejoin": "round"
|
|
553
|
+
}),
|
|
554
|
+
o("path", {
|
|
555
|
+
d: "M24 34H40",
|
|
556
|
+
stroke: "var(--kr-theme)",
|
|
557
|
+
"stroke-width": "2",
|
|
558
|
+
"stroke-linecap": "round"
|
|
559
|
+
})
|
|
560
|
+
], -1)])]),
|
|
561
|
+
o("h1", Se, b(e.title), 1),
|
|
562
|
+
o("p", Ce, b(e.description), 1)
|
|
563
|
+
]));
|
|
564
|
+
}
|
|
565
|
+
}), Te = {
|
|
566
|
+
key: 0,
|
|
567
|
+
class: "kr-menu-item--divider"
|
|
568
|
+
}, Ee = ["disabled"], De = { class: "kr-menu-item__content" }, Oe = {
|
|
569
|
+
key: 0,
|
|
570
|
+
class: "kr-menu-item__icon",
|
|
571
|
+
"aria-hidden": "true"
|
|
572
|
+
}, Q = /* @__PURE__ */ l({
|
|
573
|
+
__name: "KrMenuItem",
|
|
574
|
+
props: {
|
|
575
|
+
title: {},
|
|
576
|
+
value: {},
|
|
577
|
+
disabled: { type: Boolean },
|
|
578
|
+
type: {}
|
|
579
|
+
},
|
|
580
|
+
setup(e) {
|
|
581
|
+
return (t, n) => e.type === "divider" ? (h(), a("hr", Te)) : (h(), a("button", {
|
|
582
|
+
key: 1,
|
|
583
|
+
class: "kr-menu-item",
|
|
584
|
+
disabled: e.disabled,
|
|
585
|
+
role: "menuitem"
|
|
586
|
+
}, [o("div", De, b(e.title), 1), t.$slots.icon ? (h(), a("div", Oe, [y(t.$slots, "icon")])) : i("", !0)], 8, Ee));
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/core/focusTrap.ts
|
|
591
|
+
function $(e) {
|
|
592
|
+
return Array.from(e?.querySelectorAll("button:not([disabled]), input:not([disabled])") ?? []);
|
|
593
|
+
}
|
|
594
|
+
function ke(e) {
|
|
595
|
+
let t = $(e), n = t.findIndex((e) => e === document.activeElement);
|
|
596
|
+
(n === t.length - 1 ? t[0] : t[n + 1])?.focus();
|
|
597
|
+
}
|
|
598
|
+
function Ae(e) {
|
|
599
|
+
let t = $(e), n = t.findIndex((e) => e === document.activeElement);
|
|
600
|
+
(n <= 0 ? t[t.length - 1] : t[n - 1])?.focus();
|
|
601
|
+
}
|
|
602
|
+
//#endregion
|
|
603
|
+
//#region src/vue/components/KrDialog.vue?vue&type=script&setup=true&lang.ts
|
|
604
|
+
var je = ["open", "onKeydown"], Me = {
|
|
605
|
+
key: 0,
|
|
606
|
+
class: "kr-dialog__title"
|
|
607
|
+
}, Ne = { class: "kr-dialog__content" }, Pe = {
|
|
608
|
+
key: 0,
|
|
609
|
+
class: "kr-dialog__content__text"
|
|
610
|
+
}, Fe = {
|
|
611
|
+
key: 1,
|
|
612
|
+
class: "kr-dialog__content__form"
|
|
613
|
+
}, Ie = { class: "kr-dialog__actions" }, Le = /* @__PURE__ */ l({
|
|
614
|
+
__name: "KrDialog",
|
|
615
|
+
props: {
|
|
616
|
+
show: {
|
|
617
|
+
type: Boolean,
|
|
618
|
+
default: !1
|
|
619
|
+
},
|
|
620
|
+
title: { default: "" },
|
|
621
|
+
text: { default: "" },
|
|
622
|
+
actions: { default: () => [] },
|
|
623
|
+
cancelText: { default: "Cancel" },
|
|
624
|
+
hideCancel: {
|
|
625
|
+
type: Boolean,
|
|
626
|
+
default: !1
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
emits: ["update:show"],
|
|
630
|
+
setup(t, { emit: c }) {
|
|
631
|
+
let l = t, u = c, d = _(!1), f = n({
|
|
632
|
+
get() {
|
|
633
|
+
return l.show;
|
|
634
|
+
},
|
|
635
|
+
set(e) {
|
|
636
|
+
u("update:show", e);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
function p() {
|
|
640
|
+
u("update:show", !1);
|
|
641
|
+
}
|
|
642
|
+
async function m(e) {
|
|
643
|
+
if (!d.value) {
|
|
644
|
+
d.value = !0;
|
|
645
|
+
try {
|
|
646
|
+
await e();
|
|
647
|
+
} finally {
|
|
648
|
+
d.value = !1;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
let g = _(null);
|
|
653
|
+
function x(e) {
|
|
654
|
+
e.preventDefault(), ke(g.value);
|
|
655
|
+
}
|
|
656
|
+
function S(e) {
|
|
657
|
+
e.preventDefault(), Ae(g.value);
|
|
658
|
+
}
|
|
659
|
+
return (n, c) => (h(), r(j, {
|
|
660
|
+
modelValue: f.value,
|
|
661
|
+
"onUpdate:modelValue": c[1] ||= (e) => f.value = e,
|
|
662
|
+
centered: ""
|
|
663
|
+
}, {
|
|
664
|
+
default: E(() => [o("dialog", {
|
|
665
|
+
ref_key: "dialogRef",
|
|
666
|
+
ref: g,
|
|
667
|
+
class: "kr-dialog",
|
|
668
|
+
open: f.value,
|
|
669
|
+
onKeydown: [
|
|
670
|
+
c[0] ||= O(k((e) => f.value = !1, ["prevent"]), ["esc"]),
|
|
671
|
+
O(k(x, ["exact"]), ["tab"]),
|
|
672
|
+
O(k(S, ["shift"]), ["tab"])
|
|
673
|
+
]
|
|
674
|
+
}, [
|
|
675
|
+
t.title ? (h(), a("h2", Me, b(t.title), 1)) : i("", !0),
|
|
676
|
+
o("div", Ne, [t.text ? (h(), a("div", Pe, b(t.text), 1)) : i("", !0), n.$slots.default ? (h(), a("div", Fe, [y(n.$slots, "default")])) : i("", !0)]),
|
|
677
|
+
o("div", Ie, [t.hideCancel ? i("", !0) : (h(), r(A, {
|
|
678
|
+
key: 0,
|
|
679
|
+
type: "secondary",
|
|
680
|
+
disabled: d.value,
|
|
681
|
+
onClick: p
|
|
682
|
+
}, {
|
|
683
|
+
default: E(() => [s(b(t.cancelText), 1)]),
|
|
684
|
+
_: 1
|
|
685
|
+
}, 8, ["disabled"])), (h(!0), a(e, null, v(t.actions, (e) => (h(), r(A, {
|
|
686
|
+
key: e.text,
|
|
687
|
+
disabled: d.value || e.disabled,
|
|
688
|
+
onClick: (t) => m(e.action)
|
|
689
|
+
}, {
|
|
690
|
+
default: E(() => [s(b(e.text), 1)]),
|
|
691
|
+
_: 2
|
|
692
|
+
}, 1032, ["disabled", "onClick"]))), 128))])
|
|
693
|
+
], 40, je)]),
|
|
694
|
+
_: 3
|
|
695
|
+
}, 8, ["modelValue"]));
|
|
696
|
+
}
|
|
697
|
+
}), Re = { class: "kr-chevron" }, ze = /* @__PURE__ */ l({
|
|
698
|
+
__name: "KrChevron",
|
|
699
|
+
setup(e) {
|
|
700
|
+
return (e, t) => (h(), a("div", Re));
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
//#endregion
|
|
704
|
+
export { A as KrButton, ze as KrChevron, Le as KrDialog, we as KrEmpty, Q as KrMenuItem, j as KrOverlay, de as KrSearchInput, P as KrSection, G as KrSelectGroup, z as KrSelectItem, q as KrSwitch, oe as KrTextField, ye as KrToast, re as KrToggleRow };
|
|
705
|
+
|
|
706
|
+
//# sourceMappingURL=kroma-vue.js.map
|