@thl-ui/vue 0.0.0-stage → 0.1.1
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 +58 -2
- package/dist/components/basic.d.ts +397 -0
- package/dist/components/basic.js +303 -0
- package/dist/components/basic.js.map +1 -0
- package/dist/components/data.d.ts +690 -0
- package/dist/components/data.js +919 -0
- package/dist/components/data.js.map +1 -0
- package/dist/components/form.d.ts +764 -0
- package/dist/components/form.js +1212 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/layout.d.ts +219 -0
- package/dist/components/layout.js +480 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/nav.d.ts +295 -0
- package/dist/components/nav.js +398 -0
- package/dist/components/nav.js.map +1 -0
- package/dist/components/overlay.d.ts +303 -0
- package/dist/components/overlay.js +437 -0
- package/dist/components/overlay.js.map +1 -0
- package/dist/components/util.d.ts +26 -0
- package/dist/components/util.js +35 -0
- package/dist/components/util.js.map +1 -0
- package/dist/context.d.ts +47 -0
- package/dist/context.js +81 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -4
|
@@ -0,0 +1,1212 @@
|
|
|
1
|
+
import { defineComponent as g, h as a, ref as S, watch as A, onMounted as N, computed as U, inject as J, onBeforeUnmount as O, onUpdated as Z, provide as ee, nextTick as ae } from "vue";
|
|
2
|
+
import { bem as x, addMonths as E, weekdayNames as le, monthGrid as te, isSameDay as z, cx as V, isBetween as ne, parseISODate as D, toISODate as B, presetRanges as oe, uid as R, stepValue as I, roundToStep as re, createSelect as ie, clickOutside as K, percentOf as M, clamp as j, createUpload as se, formatBytes as ue, validate as de, linkFieldLabel as ce, valueFromPosition as me } from "@thl-ui/core";
|
|
3
|
+
import { usePrefix as f, useI18n as $, useThlContext as pe, useDefaults as G, useStore as W } from "../context.js";
|
|
4
|
+
import { icon as w, any as k, str as X } from "./util.js";
|
|
5
|
+
import { ThlButton as _ } from "./basic.js";
|
|
6
|
+
const Y = /* @__PURE__ */ Symbol("thl-form"), xe = /* @__PURE__ */ g({
|
|
7
|
+
name: "ThlForm",
|
|
8
|
+
props: {
|
|
9
|
+
layout: X("vertical"),
|
|
10
|
+
bordered: Boolean,
|
|
11
|
+
values: { type: Object, default: () => ({}) }
|
|
12
|
+
},
|
|
13
|
+
emits: ["submit"],
|
|
14
|
+
setup(e, { slots: s, emit: t, expose: o }) {
|
|
15
|
+
const i = f(), l = /* @__PURE__ */ new Map(), d = S(!1);
|
|
16
|
+
ee(Y, {
|
|
17
|
+
register: (n, r) => (l.set(n, r), () => l.delete(n)),
|
|
18
|
+
values: U(() => e.values),
|
|
19
|
+
submitted: d
|
|
20
|
+
});
|
|
21
|
+
const v = () => {
|
|
22
|
+
let n = !0;
|
|
23
|
+
return l.forEach((r) => {
|
|
24
|
+
r.validate() && (n = !1);
|
|
25
|
+
}), n;
|
|
26
|
+
};
|
|
27
|
+
return o({
|
|
28
|
+
validate: v,
|
|
29
|
+
reset: () => {
|
|
30
|
+
d.value = !1, l.forEach((n) => n.reset());
|
|
31
|
+
}
|
|
32
|
+
}), () => a(
|
|
33
|
+
"form",
|
|
34
|
+
{
|
|
35
|
+
novalidate: !0,
|
|
36
|
+
class: x("form", i.value)({ horizontal: e.layout === "horizontal", bordered: e.bordered }),
|
|
37
|
+
onSubmit: (n) => {
|
|
38
|
+
n.preventDefault(), d.value = !0, t("submit", v(), n);
|
|
39
|
+
},
|
|
40
|
+
onReset: () => {
|
|
41
|
+
d.value = !1, l.forEach((n) => n.reset());
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
s.default?.()
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}), Te = /* @__PURE__ */ g({
|
|
48
|
+
name: "ThlField",
|
|
49
|
+
props: {
|
|
50
|
+
label: String,
|
|
51
|
+
help: String,
|
|
52
|
+
error: String,
|
|
53
|
+
required: Boolean,
|
|
54
|
+
name: String,
|
|
55
|
+
value: k(),
|
|
56
|
+
rules: Array,
|
|
57
|
+
status: String,
|
|
58
|
+
for: String
|
|
59
|
+
},
|
|
60
|
+
setup(e, { slots: s }) {
|
|
61
|
+
const t = f(), { t: o } = $(), i = J(Y, null), l = R("field"), d = S(null), v = () => d.value = de(e.value, e.rules ?? [], i?.values.value);
|
|
62
|
+
let n;
|
|
63
|
+
N(() => {
|
|
64
|
+
i && e.name && (n = i.register(e.name, { validate: v, reset: () => d.value = null }));
|
|
65
|
+
}), O(() => n?.()), A(
|
|
66
|
+
() => e.value,
|
|
67
|
+
() => {
|
|
68
|
+
i?.submitted.value && e.name && v();
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
const r = S(), c = S();
|
|
72
|
+
let u = { describedBy: void 0, invalid: !1 };
|
|
73
|
+
const m = () => ce(r.value, c.value, { id: e.for ?? `${l}-input`, ...u });
|
|
74
|
+
return N(m), Z(m), () => {
|
|
75
|
+
const p = x("field", t.value), b = e.error ?? (d.value ? o(d.value.key, d.value.params) : void 0), T = e.for ?? `${l}-input`, y = b ? `${l}-err` : e.help ? `${l}-help` : void 0;
|
|
76
|
+
return u = { describedBy: y, invalid: !!b }, a(
|
|
77
|
+
"div",
|
|
78
|
+
{ class: V(p(), { "has-error": !!b || e.status === "error", "has-success": e.status === "success", "has-warning": e.status === "warning" }) },
|
|
79
|
+
[
|
|
80
|
+
e.label ? a("label", { ref: c, class: V(p("label"), e.required && `${p("label")}--required`), for: T }, e.label) : null,
|
|
81
|
+
a("div", { ref: r }, [
|
|
82
|
+
s.default?.({ id: T, describedBy: y, invalid: !!b }),
|
|
83
|
+
b ? a("div", { id: `${l}-err`, class: p("error"), role: "alert" }, b) : e.help ? a("div", { id: `${l}-help`, class: p("help") }, e.help) : null
|
|
84
|
+
])
|
|
85
|
+
]
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}), we = /* @__PURE__ */ g({
|
|
90
|
+
name: "ThlFormActions",
|
|
91
|
+
setup(e, { slots: s }) {
|
|
92
|
+
const t = f();
|
|
93
|
+
return () => a("div", { class: `${t.value}-form__actions` }, s.default?.());
|
|
94
|
+
}
|
|
95
|
+
}), $e = /* @__PURE__ */ g({
|
|
96
|
+
name: "ThlInput",
|
|
97
|
+
inheritAttrs: !1,
|
|
98
|
+
props: { modelValue: k(), size: String, variant: String, rounded: Boolean, invalid: Boolean },
|
|
99
|
+
emits: ["update:modelValue"],
|
|
100
|
+
setup(e, { attrs: s, emit: t, expose: o }) {
|
|
101
|
+
const i = f(), l = G("Input", e), d = S();
|
|
102
|
+
return o({ focus: () => d.value?.focus(), el: d }), () => a("input", {
|
|
103
|
+
...s,
|
|
104
|
+
ref: d,
|
|
105
|
+
value: e.modelValue ?? "",
|
|
106
|
+
"aria-invalid": e.invalid || void 0,
|
|
107
|
+
class: V(
|
|
108
|
+
x(
|
|
109
|
+
"input",
|
|
110
|
+
i.value
|
|
111
|
+
)({
|
|
112
|
+
size: l.value.size !== "md" ? l.value.size : void 0,
|
|
113
|
+
[l.value.variant ?? ""]: !!l.value.variant && l.value.variant !== "default",
|
|
114
|
+
rounded: e.rounded
|
|
115
|
+
}),
|
|
116
|
+
s.class
|
|
117
|
+
),
|
|
118
|
+
onInput: (v) => t("update:modelValue", v.target.value)
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}), Ce = /* @__PURE__ */ g({
|
|
122
|
+
name: "ThlTextarea",
|
|
123
|
+
inheritAttrs: !1,
|
|
124
|
+
props: { modelValue: String, variant: String },
|
|
125
|
+
emits: ["update:modelValue"],
|
|
126
|
+
setup(e, { attrs: s, emit: t }) {
|
|
127
|
+
const o = f();
|
|
128
|
+
return () => a("textarea", {
|
|
129
|
+
...s,
|
|
130
|
+
value: e.modelValue ?? "",
|
|
131
|
+
class: V(x("input", o.value)({ textarea: !0, [e.variant ?? ""]: !!e.variant && e.variant !== "default" }), s.class),
|
|
132
|
+
onInput: (i) => t("update:modelValue", i.target.value)
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}), De = /* @__PURE__ */ g({
|
|
136
|
+
name: "ThlNativeSelect",
|
|
137
|
+
inheritAttrs: !1,
|
|
138
|
+
props: { modelValue: k(), options: Array, size: String },
|
|
139
|
+
emits: ["update:modelValue"],
|
|
140
|
+
setup(e, { attrs: s, emit: t, slots: o }) {
|
|
141
|
+
const i = f();
|
|
142
|
+
return () => a(
|
|
143
|
+
"select",
|
|
144
|
+
{
|
|
145
|
+
...s,
|
|
146
|
+
value: e.modelValue,
|
|
147
|
+
class: V(x("input", i.value)({ size: e.size && e.size !== "md" ? e.size : void 0 }), s.class),
|
|
148
|
+
onChange: (l) => t("update:modelValue", l.target.value)
|
|
149
|
+
},
|
|
150
|
+
[...(e.options ?? []).map((l) => a("option", { key: l.value, value: l.value, selected: l.value === e.modelValue }, l.label)), o.default?.()]
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}), Ae = /* @__PURE__ */ g({
|
|
154
|
+
name: "ThlInputGroup",
|
|
155
|
+
props: { prepend: String, append: String },
|
|
156
|
+
setup(e, { slots: s }) {
|
|
157
|
+
const t = f(), o = (i) => i ? a("span", { class: `${t.value}-input-group__addon` }, i) : null;
|
|
158
|
+
return () => a("div", { class: `${t.value}-input-group` }, [
|
|
159
|
+
s.prepend ? s.prepend() : o(e.prepend),
|
|
160
|
+
s.default?.(),
|
|
161
|
+
s.append ? s.append() : o(e.append)
|
|
162
|
+
]);
|
|
163
|
+
}
|
|
164
|
+
}), Be = /* @__PURE__ */ g({
|
|
165
|
+
name: "ThlFloatingLabel",
|
|
166
|
+
props: { label: { type: String, required: !0 }, for: { type: String, required: !0 } },
|
|
167
|
+
setup(e, { slots: s }) {
|
|
168
|
+
const t = f();
|
|
169
|
+
return () => a("div", { class: `${t.value}-float` }, [s.default?.(), a("label", { for: e.for, class: `${t.value}-float__label` }, e.label)]);
|
|
170
|
+
}
|
|
171
|
+
}), ve = /* @__PURE__ */ g({
|
|
172
|
+
name: "ThlCheckbox",
|
|
173
|
+
inheritAttrs: !1,
|
|
174
|
+
props: {
|
|
175
|
+
modelValue: k(),
|
|
176
|
+
value: k(),
|
|
177
|
+
color: String,
|
|
178
|
+
label: String,
|
|
179
|
+
indeterminate: Boolean,
|
|
180
|
+
skin: String,
|
|
181
|
+
disabled: Boolean
|
|
182
|
+
},
|
|
183
|
+
emits: ["update:modelValue", "change"],
|
|
184
|
+
setup(e, { attrs: s, slots: t, emit: o }) {
|
|
185
|
+
const i = f(), l = S();
|
|
186
|
+
A(
|
|
187
|
+
() => e.indeterminate,
|
|
188
|
+
(n) => {
|
|
189
|
+
l.value && (l.value.indeterminate = n);
|
|
190
|
+
},
|
|
191
|
+
{ flush: "post" }
|
|
192
|
+
), N(() => {
|
|
193
|
+
l.value && (l.value.indeterminate = e.indeterminate);
|
|
194
|
+
});
|
|
195
|
+
const d = U(() => Array.isArray(e.modelValue) ? e.modelValue.includes(e.value) : !!e.modelValue), v = (n) => {
|
|
196
|
+
const r = n.target.checked, c = Array.isArray(e.modelValue) ? r ? [...e.modelValue, e.value] : e.modelValue.filter((u) => u !== e.value) : r;
|
|
197
|
+
o("update:modelValue", c), o("change", r);
|
|
198
|
+
};
|
|
199
|
+
return () => {
|
|
200
|
+
const n = x("check", i.value);
|
|
201
|
+
return a(
|
|
202
|
+
"label",
|
|
203
|
+
{
|
|
204
|
+
class: V(n({ [e.color ?? ""]: !!e.color, [e.skin ?? ""]: !!e.skin && e.skin !== "default" }), { "is-disabled": e.disabled }, s.class)
|
|
205
|
+
},
|
|
206
|
+
[
|
|
207
|
+
a("input", {
|
|
208
|
+
...s,
|
|
209
|
+
class: n("input"),
|
|
210
|
+
ref: l,
|
|
211
|
+
type: "checkbox",
|
|
212
|
+
checked: d.value,
|
|
213
|
+
disabled: e.disabled,
|
|
214
|
+
"aria-checked": e.indeterminate ? "mixed" : void 0,
|
|
215
|
+
onChange: v
|
|
216
|
+
}),
|
|
217
|
+
a("span", { class: n("box"), "aria-hidden": "true" }),
|
|
218
|
+
e.label || t.default ? a("span", t.default ? t.default() : e.label) : null
|
|
219
|
+
]
|
|
220
|
+
);
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}), be = /* @__PURE__ */ g({
|
|
224
|
+
name: "ThlRadio",
|
|
225
|
+
inheritAttrs: !1,
|
|
226
|
+
props: { modelValue: k(), value: k(), color: String, label: String, skin: String, disabled: Boolean, name: String },
|
|
227
|
+
emits: ["update:modelValue"],
|
|
228
|
+
setup(e, { attrs: s, slots: t, emit: o }) {
|
|
229
|
+
const i = f();
|
|
230
|
+
return () => {
|
|
231
|
+
const l = x("check", i.value);
|
|
232
|
+
return a(
|
|
233
|
+
"label",
|
|
234
|
+
{ class: V(l({ radio: !0, [e.color ?? ""]: !!e.color, [e.skin ?? ""]: !!e.skin && e.skin !== "default" }), { "is-disabled": e.disabled }) },
|
|
235
|
+
[
|
|
236
|
+
a("input", {
|
|
237
|
+
...s,
|
|
238
|
+
type: "radio",
|
|
239
|
+
name: e.name,
|
|
240
|
+
class: l("input"),
|
|
241
|
+
checked: e.modelValue === e.value,
|
|
242
|
+
disabled: e.disabled,
|
|
243
|
+
onChange: () => o("update:modelValue", e.value)
|
|
244
|
+
}),
|
|
245
|
+
a("span", { class: l("box"), "aria-hidden": "true" }),
|
|
246
|
+
e.label || t.default ? a("span", t.default ? t.default() : e.label) : null
|
|
247
|
+
]
|
|
248
|
+
);
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}), _e = /* @__PURE__ */ g({
|
|
252
|
+
name: "ThlCheckboxGroup",
|
|
253
|
+
props: {
|
|
254
|
+
modelValue: { type: Array, default: () => [] },
|
|
255
|
+
options: { type: Array, required: !0 },
|
|
256
|
+
color: String,
|
|
257
|
+
vertical: Boolean
|
|
258
|
+
},
|
|
259
|
+
emits: ["update:modelValue"],
|
|
260
|
+
setup(e, { emit: s }) {
|
|
261
|
+
const t = f();
|
|
262
|
+
return () => a(
|
|
263
|
+
"div",
|
|
264
|
+
{ role: "group", class: x("check-group", t.value)({ vertical: e.vertical }) },
|
|
265
|
+
e.options.map(
|
|
266
|
+
(o) => a(ve, {
|
|
267
|
+
key: String(o.value),
|
|
268
|
+
modelValue: e.modelValue,
|
|
269
|
+
value: o.value,
|
|
270
|
+
label: o.label,
|
|
271
|
+
color: e.color,
|
|
272
|
+
disabled: o.disabled,
|
|
273
|
+
"onUpdate:modelValue": (i) => s("update:modelValue", i)
|
|
274
|
+
})
|
|
275
|
+
)
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
}), ze = /* @__PURE__ */ g({
|
|
279
|
+
name: "ThlRadioGroup",
|
|
280
|
+
props: {
|
|
281
|
+
modelValue: k(),
|
|
282
|
+
options: { type: Array, required: !0 },
|
|
283
|
+
color: String,
|
|
284
|
+
vertical: Boolean,
|
|
285
|
+
name: String
|
|
286
|
+
},
|
|
287
|
+
emits: ["update:modelValue"],
|
|
288
|
+
setup(e, { emit: s }) {
|
|
289
|
+
const t = f(), o = R("radio");
|
|
290
|
+
return () => a(
|
|
291
|
+
"div",
|
|
292
|
+
{ role: "radiogroup", class: x("check-group", t.value)({ vertical: e.vertical }) },
|
|
293
|
+
e.options.map(
|
|
294
|
+
(i) => a(be, {
|
|
295
|
+
key: String(i.value),
|
|
296
|
+
name: e.name ?? o,
|
|
297
|
+
modelValue: e.modelValue,
|
|
298
|
+
value: i.value,
|
|
299
|
+
label: i.label,
|
|
300
|
+
color: e.color,
|
|
301
|
+
disabled: i.disabled,
|
|
302
|
+
"onUpdate:modelValue": (l) => s("update:modelValue", l)
|
|
303
|
+
})
|
|
304
|
+
)
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
}), Le = /* @__PURE__ */ g({
|
|
308
|
+
name: "ThlSwitch",
|
|
309
|
+
inheritAttrs: !1,
|
|
310
|
+
props: { modelValue: Boolean, color: String, size: String, label: String, disabled: Boolean },
|
|
311
|
+
emits: ["update:modelValue"],
|
|
312
|
+
setup(e, { attrs: s, emit: t }) {
|
|
313
|
+
const o = f();
|
|
314
|
+
return () => {
|
|
315
|
+
const i = x("switch", o.value);
|
|
316
|
+
return a("label", { class: i({ [e.color ?? ""]: !!e.color, size: e.size && e.size !== "md" ? e.size : void 0 }) }, [
|
|
317
|
+
a("input", {
|
|
318
|
+
...s,
|
|
319
|
+
type: "checkbox",
|
|
320
|
+
role: "switch",
|
|
321
|
+
class: i("input"),
|
|
322
|
+
checked: e.modelValue,
|
|
323
|
+
disabled: e.disabled,
|
|
324
|
+
onChange: (l) => t("update:modelValue", l.target.checked)
|
|
325
|
+
}),
|
|
326
|
+
a("span", { class: i("track"), "aria-hidden": "true" }),
|
|
327
|
+
e.label ? a("span", e.label) : null
|
|
328
|
+
]);
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}), Ie = /* @__PURE__ */ g({
|
|
332
|
+
name: "ThlNumberInput",
|
|
333
|
+
props: {
|
|
334
|
+
modelValue: k(),
|
|
335
|
+
min: Number,
|
|
336
|
+
max: Number,
|
|
337
|
+
step: { type: Number, default: 1 },
|
|
338
|
+
prefix: String,
|
|
339
|
+
suffix: String,
|
|
340
|
+
disabled: Boolean,
|
|
341
|
+
id: String,
|
|
342
|
+
size: String
|
|
343
|
+
},
|
|
344
|
+
emits: ["update:modelValue"],
|
|
345
|
+
setup(e, { emit: s }) {
|
|
346
|
+
const t = f(), { t: o } = $(), i = (l) => s("update:modelValue", j(l, e.min, e.max));
|
|
347
|
+
return () => {
|
|
348
|
+
const l = x("number", t.value), d = e.modelValue ?? 0, v = { step: e.step, min: e.min, max: e.max };
|
|
349
|
+
return a("div", { class: l() }, [
|
|
350
|
+
e.prefix ? a("span", { class: `${t.value}-input-group__addon` }, e.prefix) : null,
|
|
351
|
+
a(
|
|
352
|
+
"button",
|
|
353
|
+
{
|
|
354
|
+
type: "button",
|
|
355
|
+
class: l("btn"),
|
|
356
|
+
tabindex: -1,
|
|
357
|
+
"aria-label": "-",
|
|
358
|
+
disabled: e.disabled || e.min !== void 0 && d <= e.min,
|
|
359
|
+
onClick: () => i(I(d, -1, v))
|
|
360
|
+
},
|
|
361
|
+
w("minus")
|
|
362
|
+
),
|
|
363
|
+
a("input", {
|
|
364
|
+
id: e.id,
|
|
365
|
+
type: "number",
|
|
366
|
+
inputmode: "decimal",
|
|
367
|
+
class: x("input", t.value)({ size: e.size && e.size !== "md" ? e.size : void 0 }),
|
|
368
|
+
value: e.modelValue ?? "",
|
|
369
|
+
min: e.min,
|
|
370
|
+
max: e.max,
|
|
371
|
+
step: e.step,
|
|
372
|
+
disabled: e.disabled,
|
|
373
|
+
"aria-label": o("validation.number"),
|
|
374
|
+
onInput: (n) => {
|
|
375
|
+
const r = n.target.value;
|
|
376
|
+
s("update:modelValue", r === "" ? null : Number(r));
|
|
377
|
+
},
|
|
378
|
+
onBlur: () => e.modelValue != null && i(re(e.modelValue, e.step, e.min ?? 0)),
|
|
379
|
+
onKeydown: (n) => {
|
|
380
|
+
n.key === "ArrowUp" && (n.preventDefault(), i(I(d, 1, v))), n.key === "ArrowDown" && (n.preventDefault(), i(I(d, -1, v)));
|
|
381
|
+
}
|
|
382
|
+
}),
|
|
383
|
+
a(
|
|
384
|
+
"button",
|
|
385
|
+
{
|
|
386
|
+
type: "button",
|
|
387
|
+
class: l("btn"),
|
|
388
|
+
tabindex: -1,
|
|
389
|
+
"aria-label": "+",
|
|
390
|
+
disabled: e.disabled || e.max !== void 0 && d >= e.max,
|
|
391
|
+
onClick: () => i(I(d, 1, v))
|
|
392
|
+
},
|
|
393
|
+
w("plus")
|
|
394
|
+
),
|
|
395
|
+
e.suffix ? a("span", { class: `${t.value}-input-group__addon` }, e.suffix) : null
|
|
396
|
+
]);
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
}), Ne = /* @__PURE__ */ g({
|
|
400
|
+
name: "ThlSlider",
|
|
401
|
+
props: {
|
|
402
|
+
modelValue: { type: [Number, Array], required: !0 },
|
|
403
|
+
min: { type: Number, default: 0 },
|
|
404
|
+
max: { type: Number, default: 100 },
|
|
405
|
+
step: { type: Number, default: 1 },
|
|
406
|
+
color: String,
|
|
407
|
+
disabled: Boolean,
|
|
408
|
+
showTip: { type: Boolean, default: !0 },
|
|
409
|
+
showScale: Boolean,
|
|
410
|
+
format: { type: Function, default: String },
|
|
411
|
+
ariaLabel: String
|
|
412
|
+
},
|
|
413
|
+
emits: ["update:modelValue"],
|
|
414
|
+
setup(e, { emit: s }) {
|
|
415
|
+
const t = f(), { t: o } = $(), i = S(), l = (n) => {
|
|
416
|
+
const r = i.value, c = r.getBoundingClientRect(), u = (n - c.left) / c.width;
|
|
417
|
+
return me(getComputedStyle(r).direction === "rtl" ? 1 - u : u, { min: e.min, max: e.max, step: e.step });
|
|
418
|
+
}, d = (n, r) => {
|
|
419
|
+
if (!Array.isArray(e.modelValue)) return s("update:modelValue", r);
|
|
420
|
+
const c = [...e.modelValue];
|
|
421
|
+
c[n] = r, c[0] > c[1] && c.reverse(), s("update:modelValue", c);
|
|
422
|
+
}, v = (n) => (r) => {
|
|
423
|
+
if (e.disabled) return;
|
|
424
|
+
r.target.setPointerCapture?.(r.pointerId);
|
|
425
|
+
const c = (m) => d(n, l(m.clientX)), u = () => {
|
|
426
|
+
window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", u);
|
|
427
|
+
};
|
|
428
|
+
window.addEventListener("pointermove", c), window.addEventListener("pointerup", u);
|
|
429
|
+
};
|
|
430
|
+
return () => {
|
|
431
|
+
const n = x("slider", t.value), r = Array.isArray(e.modelValue) ? e.modelValue : [e.modelValue], c = Array.isArray(e.modelValue), u = c ? M(r[0], e.min, e.max) : 0, m = M(r[r.length - 1], e.min, e.max);
|
|
432
|
+
return a("div", { class: V(n({ [e.color ?? ""]: !!e.color }), { "is-disabled": e.disabled }) }, [
|
|
433
|
+
a(
|
|
434
|
+
"div",
|
|
435
|
+
{
|
|
436
|
+
ref: i,
|
|
437
|
+
class: n("rail"),
|
|
438
|
+
onPointerdown: (p) => {
|
|
439
|
+
if (e.disabled || p.target !== p.currentTarget) return;
|
|
440
|
+
const b = l(p.clientX);
|
|
441
|
+
d(c ? Math.abs(b - r[0]) <= Math.abs(b - r[1]) ? 0 : 1 : 0, b);
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
[
|
|
445
|
+
a("div", { class: n("fill"), style: { insetInlineStart: `${u}%`, width: `${m - u}%` } }),
|
|
446
|
+
...r.map(
|
|
447
|
+
(p, b) => a(
|
|
448
|
+
"div",
|
|
449
|
+
{
|
|
450
|
+
key: b,
|
|
451
|
+
role: "slider",
|
|
452
|
+
tabindex: e.disabled ? -1 : 0,
|
|
453
|
+
"aria-valuemin": e.min,
|
|
454
|
+
"aria-valuemax": e.max,
|
|
455
|
+
"aria-valuenow": p,
|
|
456
|
+
"aria-valuetext": e.format(p),
|
|
457
|
+
"aria-label": e.ariaLabel ?? (r.length > 1 ? o(b === 0 ? "common.min" : "common.max") : o("common.value")),
|
|
458
|
+
class: n("thumb"),
|
|
459
|
+
style: { insetInlineStart: `${M(p, e.min, e.max)}%` },
|
|
460
|
+
onPointerdown: v(b),
|
|
461
|
+
onKeydown: (T) => {
|
|
462
|
+
const y = T.key;
|
|
463
|
+
let C = p;
|
|
464
|
+
if (y === "ArrowRight" || y === "ArrowUp") C = p + e.step;
|
|
465
|
+
else if (y === "ArrowLeft" || y === "ArrowDown") C = p - e.step;
|
|
466
|
+
else if (y === "Home") C = e.min;
|
|
467
|
+
else if (y === "End") C = e.max;
|
|
468
|
+
else if (y === "PageUp") C = p + e.step * 10;
|
|
469
|
+
else if (y === "PageDown") C = p - e.step * 10;
|
|
470
|
+
else return;
|
|
471
|
+
T.preventDefault(), d(b, j(C, e.min, e.max));
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
e.showTip ? a("span", { class: n("tip") }, e.format(p)) : void 0
|
|
475
|
+
)
|
|
476
|
+
)
|
|
477
|
+
]
|
|
478
|
+
),
|
|
479
|
+
e.showScale ? a("div", { class: n("scale") }, [a("span", e.format(e.min)), a("span", e.format(Math.round((e.min + e.max) / 2))), a("span", e.format(e.max))]) : null
|
|
480
|
+
]);
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
}), he = /* @__PURE__ */ g({
|
|
484
|
+
name: "ThlSelect",
|
|
485
|
+
props: {
|
|
486
|
+
modelValue: k(),
|
|
487
|
+
options: { type: Array, required: !0 },
|
|
488
|
+
multiple: Boolean,
|
|
489
|
+
searchable: { type: Boolean, default: void 0 },
|
|
490
|
+
clearable: { type: Boolean, default: void 0 },
|
|
491
|
+
creatable: Boolean,
|
|
492
|
+
placeholder: String,
|
|
493
|
+
disabled: Boolean,
|
|
494
|
+
id: String,
|
|
495
|
+
max: Number
|
|
496
|
+
},
|
|
497
|
+
emits: ["update:modelValue", "change"],
|
|
498
|
+
setup(e, { emit: s }) {
|
|
499
|
+
const t = f(), { t: o } = $(), i = G("Select", e), l = ie({
|
|
500
|
+
options: e.options,
|
|
501
|
+
value: e.modelValue,
|
|
502
|
+
multiple: e.multiple,
|
|
503
|
+
creatable: e.creatable,
|
|
504
|
+
max: e.max,
|
|
505
|
+
onChange: (u) => {
|
|
506
|
+
s("update:modelValue", u), s("change", u);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
A(
|
|
510
|
+
() => e.options,
|
|
511
|
+
(u) => l.setOptions(u)
|
|
512
|
+
), A(
|
|
513
|
+
() => e.modelValue,
|
|
514
|
+
(u) => l.setValue(u)
|
|
515
|
+
);
|
|
516
|
+
const d = W(l.state), v = S(), n = S(), r = R("listbox");
|
|
517
|
+
let c = null;
|
|
518
|
+
return A(
|
|
519
|
+
() => d.value.open,
|
|
520
|
+
(u) => {
|
|
521
|
+
c?.(), c = u ? K([v.value], l.close) : null;
|
|
522
|
+
}
|
|
523
|
+
), O(() => c?.()), () => {
|
|
524
|
+
const u = x("select", t.value), m = l.selectedOptions(), p = l.filtered(), b = d.value, T = i.value.searchable || e.multiple || e.creatable, y = e.placeholder ?? o("select.placeholder");
|
|
525
|
+
let C;
|
|
526
|
+
const q = [];
|
|
527
|
+
return p.forEach((h, L) => {
|
|
528
|
+
h.group && h.group !== C && q.push(a("li", { key: `g-${h.group}`, class: u("group"), role: "presentation" }, h.group)), C = h.group;
|
|
529
|
+
const F = l.isSelected(h.value);
|
|
530
|
+
q.push(
|
|
531
|
+
a(
|
|
532
|
+
"li",
|
|
533
|
+
{
|
|
534
|
+
key: String(h.value),
|
|
535
|
+
id: `${r}-${L}`,
|
|
536
|
+
role: "option",
|
|
537
|
+
"aria-selected": F,
|
|
538
|
+
"aria-disabled": h.disabled,
|
|
539
|
+
class: V(u("option"), { "is-highlighted": L === b.highlighted, "is-selected": F, "is-disabled": h.disabled }),
|
|
540
|
+
onMousedown: (Q) => Q.preventDefault(),
|
|
541
|
+
onClick: () => l.select(h.value)
|
|
542
|
+
},
|
|
543
|
+
[h.label, F ? w("check") : null]
|
|
544
|
+
)
|
|
545
|
+
);
|
|
546
|
+
}), a("div", { ref: v, class: V(u(), { "is-disabled": e.disabled }) }, [
|
|
547
|
+
a(
|
|
548
|
+
"div",
|
|
549
|
+
{
|
|
550
|
+
class: V(u("control"), { "is-focused": b.open }),
|
|
551
|
+
onClick: () => {
|
|
552
|
+
e.disabled || (l.open(), n.value?.focus());
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
[
|
|
556
|
+
...e.multiple ? m.map(
|
|
557
|
+
(h) => a("span", { key: String(h.value), class: u("tag") }, [
|
|
558
|
+
h.label,
|
|
559
|
+
a(
|
|
560
|
+
"button",
|
|
561
|
+
{
|
|
562
|
+
type: "button",
|
|
563
|
+
"aria-label": `${o("common.remove")} ${h.label}`,
|
|
564
|
+
onClick: (L) => {
|
|
565
|
+
L.stopPropagation(), l.remove(h.value);
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
"×"
|
|
569
|
+
)
|
|
570
|
+
])
|
|
571
|
+
) : [],
|
|
572
|
+
!e.multiple && m[0] && !b.query ? a("span", { class: u("value") }, m[0].label) : null,
|
|
573
|
+
!m.length && !b.query && !T ? a("span", { class: u("placeholder") }, y) : null,
|
|
574
|
+
T ? a("input", {
|
|
575
|
+
ref: n,
|
|
576
|
+
id: e.id,
|
|
577
|
+
class: u("search"),
|
|
578
|
+
value: b.query,
|
|
579
|
+
disabled: e.disabled,
|
|
580
|
+
role: "combobox",
|
|
581
|
+
"aria-expanded": b.open,
|
|
582
|
+
"aria-controls": r,
|
|
583
|
+
"aria-autocomplete": "list",
|
|
584
|
+
"aria-activedescendant": b.open && b.highlighted >= 0 ? `${r}-${b.highlighted}` : void 0,
|
|
585
|
+
placeholder: m.length ? "" : y,
|
|
586
|
+
onInput: (h) => l.setQuery(h.target.value),
|
|
587
|
+
onKeydown: (h) => l.onKeyDown(h)
|
|
588
|
+
}) : a(
|
|
589
|
+
"button",
|
|
590
|
+
{
|
|
591
|
+
type: "button",
|
|
592
|
+
id: e.id,
|
|
593
|
+
class: `${t.value}-sr-only`,
|
|
594
|
+
role: "combobox",
|
|
595
|
+
"aria-expanded": b.open,
|
|
596
|
+
"aria-controls": r,
|
|
597
|
+
"aria-label": m[0]?.label ?? y,
|
|
598
|
+
"data-thl-auto-label": "",
|
|
599
|
+
onKeydown: (h) => l.onKeyDown(h)
|
|
600
|
+
},
|
|
601
|
+
m[0]?.label ?? y
|
|
602
|
+
),
|
|
603
|
+
a("span", { class: u("indicators") }, [
|
|
604
|
+
i.value.clearable && m.length ? a(
|
|
605
|
+
"button",
|
|
606
|
+
{
|
|
607
|
+
type: "button",
|
|
608
|
+
"aria-label": o("common.clear"),
|
|
609
|
+
onClick: (h) => {
|
|
610
|
+
h.stopPropagation(), l.clear();
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
w("x")
|
|
614
|
+
) : null,
|
|
615
|
+
w("chevron-down")
|
|
616
|
+
])
|
|
617
|
+
]
|
|
618
|
+
),
|
|
619
|
+
b.open ? a(
|
|
620
|
+
"ul",
|
|
621
|
+
{ id: r, role: "listbox", "aria-multiselectable": e.multiple || void 0, class: u("menu") },
|
|
622
|
+
p.length === 0 ? [
|
|
623
|
+
e.creatable && b.query ? a("li", { class: u("option"), onClick: () => l.create() }, `${o("select.addTag")}: “${b.query}”`) : a("li", { class: u("empty") }, o("select.noOptions"))
|
|
624
|
+
] : q
|
|
625
|
+
) : null
|
|
626
|
+
]);
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
}), Ee = /* @__PURE__ */ g({
|
|
630
|
+
name: "ThlTagsInput",
|
|
631
|
+
props: { modelValue: { type: Array, default: () => [] }, placeholder: String, id: String },
|
|
632
|
+
emits: ["update:modelValue"],
|
|
633
|
+
setup(e, { emit: s }) {
|
|
634
|
+
return () => a(he, {
|
|
635
|
+
id: e.id,
|
|
636
|
+
options: e.modelValue.map((t) => ({ label: t, value: t })),
|
|
637
|
+
modelValue: e.modelValue,
|
|
638
|
+
multiple: !0,
|
|
639
|
+
creatable: !0,
|
|
640
|
+
placeholder: e.placeholder,
|
|
641
|
+
"onUpdate:modelValue": (t) => s("update:modelValue", t)
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
function P() {
|
|
646
|
+
const e = S(!1), s = S();
|
|
647
|
+
let t = null;
|
|
648
|
+
const o = (i) => i.key === "Escape" && (e.value = !1);
|
|
649
|
+
return A(e, async (i) => {
|
|
650
|
+
t?.(), t = null, document.removeEventListener("keydown", o), i && (await ae(), t = K([s.value], () => e.value = !1), document.addEventListener("keydown", o));
|
|
651
|
+
}), O(() => {
|
|
652
|
+
t?.(), document.removeEventListener("keydown", o);
|
|
653
|
+
}), { open: e, root: s };
|
|
654
|
+
}
|
|
655
|
+
const H = /* @__PURE__ */ g({
|
|
656
|
+
name: "ThlCalendarGrid",
|
|
657
|
+
props: {
|
|
658
|
+
month: { type: Date, required: !0 },
|
|
659
|
+
selected: k(),
|
|
660
|
+
rangeStart: k(),
|
|
661
|
+
rangeEnd: k(),
|
|
662
|
+
hover: k(),
|
|
663
|
+
min: k(),
|
|
664
|
+
max: k()
|
|
665
|
+
},
|
|
666
|
+
emits: ["update:month", "select", "hover"],
|
|
667
|
+
setup(e, { emit: s }) {
|
|
668
|
+
const t = f(), { t: o, d: i, intlLocale: l } = $(), d = pe();
|
|
669
|
+
return () => {
|
|
670
|
+
const v = d.config.value.components.DatePicker?.weekStartsOn ?? 1, n = l(), r = x("calendar-grid", t.value), c = e.rangeEnd ?? e.hover;
|
|
671
|
+
return a("div", { class: r() }, [
|
|
672
|
+
a("div", { class: r("head") }, [
|
|
673
|
+
a(
|
|
674
|
+
"button",
|
|
675
|
+
{ type: "button", onClick: () => s("update:month", E(e.month, -1)), "aria-label": o("common.previous") },
|
|
676
|
+
w("chevron-left")
|
|
677
|
+
),
|
|
678
|
+
a("span", { "aria-live": "polite" }, new Intl.DateTimeFormat(n, { month: "long", year: "numeric" }).format(e.month)),
|
|
679
|
+
a("button", { type: "button", onClick: () => s("update:month", E(e.month, 1)), "aria-label": o("common.next") }, w("chevron-right"))
|
|
680
|
+
]),
|
|
681
|
+
a("table", { role: "grid" }, [
|
|
682
|
+
a(
|
|
683
|
+
"thead",
|
|
684
|
+
a(
|
|
685
|
+
"tr",
|
|
686
|
+
le(n, v, "short").map((u) => a("th", { key: u, scope: "col" }, u))
|
|
687
|
+
)
|
|
688
|
+
),
|
|
689
|
+
a(
|
|
690
|
+
"tbody",
|
|
691
|
+
te(e.month.getFullYear(), e.month.getMonth(), v).map(
|
|
692
|
+
(u, m) => a(
|
|
693
|
+
"tr",
|
|
694
|
+
{ key: m },
|
|
695
|
+
u.map((p) => {
|
|
696
|
+
const b = e.min && p.date < e.min || e.max && p.date > e.max, T = z(p.date, e.selected) || z(p.date, e.rangeStart) || z(p.date, e.rangeEnd);
|
|
697
|
+
return a(
|
|
698
|
+
"td",
|
|
699
|
+
{ key: p.key },
|
|
700
|
+
a(
|
|
701
|
+
"button",
|
|
702
|
+
{
|
|
703
|
+
type: "button",
|
|
704
|
+
disabled: !!b,
|
|
705
|
+
"aria-pressed": T,
|
|
706
|
+
"aria-label": i(p.date, { dateStyle: "full" }),
|
|
707
|
+
class: V(r("day"), {
|
|
708
|
+
"is-outside": !p.inMonth,
|
|
709
|
+
"is-today": p.today,
|
|
710
|
+
"is-selected": T,
|
|
711
|
+
"is-in-range": !T && !!e.rangeStart && ne(p.date, e.rangeStart, c)
|
|
712
|
+
}),
|
|
713
|
+
onClick: () => s("select", p.date),
|
|
714
|
+
onMouseenter: () => s("hover", p.date)
|
|
715
|
+
},
|
|
716
|
+
p.date.getDate()
|
|
717
|
+
)
|
|
718
|
+
);
|
|
719
|
+
})
|
|
720
|
+
)
|
|
721
|
+
)
|
|
722
|
+
)
|
|
723
|
+
])
|
|
724
|
+
]);
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
}), Pe = /* @__PURE__ */ g({
|
|
728
|
+
name: "ThlDatePicker",
|
|
729
|
+
props: {
|
|
730
|
+
modelValue: k(),
|
|
731
|
+
placeholder: String,
|
|
732
|
+
min: String,
|
|
733
|
+
max: String,
|
|
734
|
+
id: String,
|
|
735
|
+
disabled: Boolean,
|
|
736
|
+
clearable: { type: Boolean, default: !0 },
|
|
737
|
+
inline: Boolean
|
|
738
|
+
},
|
|
739
|
+
emits: ["update:modelValue"],
|
|
740
|
+
setup(e, { emit: s }) {
|
|
741
|
+
const t = f(), { t: o, d: i } = $(), { open: l, root: d } = P(), v = S(D(e.modelValue) ?? /* @__PURE__ */ new Date());
|
|
742
|
+
return A(
|
|
743
|
+
() => e.modelValue,
|
|
744
|
+
(n) => {
|
|
745
|
+
const r = D(n);
|
|
746
|
+
r && (v.value = r);
|
|
747
|
+
}
|
|
748
|
+
), () => {
|
|
749
|
+
const n = D(e.modelValue), r = a(H, {
|
|
750
|
+
month: v.value,
|
|
751
|
+
selected: n,
|
|
752
|
+
min: D(e.min) ?? void 0,
|
|
753
|
+
max: D(e.max) ?? void 0,
|
|
754
|
+
"onUpdate:month": (c) => v.value = c,
|
|
755
|
+
onSelect: (c) => {
|
|
756
|
+
s("update:modelValue", B(c)), l.value = !1;
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
return e.inline ? a("div", { class: `${t.value}-card ${t.value}-p-3`, style: { display: "inline-block" } }, r) : a("div", { ref: d, class: `${t.value}-picker` }, [
|
|
760
|
+
a("div", { class: `${t.value}-input-group` }, [
|
|
761
|
+
a("input", {
|
|
762
|
+
id: e.id,
|
|
763
|
+
readonly: !0,
|
|
764
|
+
class: `${t.value}-input`,
|
|
765
|
+
value: n ? i(n) : "",
|
|
766
|
+
placeholder: e.placeholder ?? o("datepicker.selectDate"),
|
|
767
|
+
disabled: e.disabled,
|
|
768
|
+
role: "combobox",
|
|
769
|
+
"aria-haspopup": "dialog",
|
|
770
|
+
"aria-expanded": String(l.value),
|
|
771
|
+
"aria-label": e.placeholder ?? o("datepicker.selectDate"),
|
|
772
|
+
onClick: () => !e.disabled && (l.value = !0)
|
|
773
|
+
}),
|
|
774
|
+
a(_, { "aria-label": o("datepicker.selectDate"), disabled: e.disabled, onClick: () => l.value = !l.value }, () => w("calendar"))
|
|
775
|
+
]),
|
|
776
|
+
l.value ? a("div", { class: `${t.value}-picker__panel`, role: "dialog", style: { flexDirection: "column" } }, [
|
|
777
|
+
r,
|
|
778
|
+
a("div", { class: `${t.value}-picker__footer` }, [
|
|
779
|
+
a(
|
|
780
|
+
_,
|
|
781
|
+
{
|
|
782
|
+
size: "sm",
|
|
783
|
+
onClick: () => {
|
|
784
|
+
s("update:modelValue", B(/* @__PURE__ */ new Date())), l.value = !1;
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
() => o("datepicker.today")
|
|
788
|
+
),
|
|
789
|
+
e.clearable ? a(
|
|
790
|
+
_,
|
|
791
|
+
{
|
|
792
|
+
size: "sm",
|
|
793
|
+
variant: "link",
|
|
794
|
+
onClick: () => {
|
|
795
|
+
s("update:modelValue", null), l.value = !1;
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
() => o("datepicker.clear")
|
|
799
|
+
) : null
|
|
800
|
+
])
|
|
801
|
+
]) : null
|
|
802
|
+
]);
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
}), qe = /* @__PURE__ */ g({
|
|
806
|
+
name: "ThlDateRangePicker",
|
|
807
|
+
props: {
|
|
808
|
+
modelValue: { type: Array, default: () => [null, null] },
|
|
809
|
+
id: String,
|
|
810
|
+
presets: { type: Boolean, default: !0 }
|
|
811
|
+
},
|
|
812
|
+
emits: ["update:modelValue"],
|
|
813
|
+
setup(e, { emit: s }) {
|
|
814
|
+
const t = f(), { t: o, d: i } = $(), { open: l, root: d } = P(), v = S(D(e.modelValue[0]) ?? /* @__PURE__ */ new Date()), n = S(null), r = S(null), c = (u) => {
|
|
815
|
+
if (!n.value) {
|
|
816
|
+
n.value = u;
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
const [m, p] = u < n.value ? [u, n.value] : [n.value, u];
|
|
820
|
+
s("update:modelValue", [B(m), B(p)]), n.value = null, l.value = !1;
|
|
821
|
+
};
|
|
822
|
+
return () => {
|
|
823
|
+
const [u, m] = [D(e.modelValue[0]), D(e.modelValue[1])], p = {
|
|
824
|
+
rangeStart: n.value ?? u,
|
|
825
|
+
rangeEnd: n.value ? null : m,
|
|
826
|
+
hover: n.value ? r.value : null,
|
|
827
|
+
onSelect: c,
|
|
828
|
+
onHover: (b) => r.value = b
|
|
829
|
+
};
|
|
830
|
+
return a("div", { ref: d, class: `${t.value}-picker` }, [
|
|
831
|
+
a("div", { class: `${t.value}-input-group` }, [
|
|
832
|
+
a("span", { class: `${t.value}-input-group__addon` }, w("calendar")),
|
|
833
|
+
a("input", {
|
|
834
|
+
id: e.id,
|
|
835
|
+
readonly: !0,
|
|
836
|
+
class: `${t.value}-input`,
|
|
837
|
+
value: u && m ? `${i(u)} – ${i(m)}` : "",
|
|
838
|
+
placeholder: `${o("datepicker.startDate")} – ${o("datepicker.endDate")}`,
|
|
839
|
+
onClick: () => l.value = !0,
|
|
840
|
+
role: "combobox",
|
|
841
|
+
"aria-haspopup": "dialog",
|
|
842
|
+
"aria-expanded": String(l.value),
|
|
843
|
+
"aria-label": `${o("datepicker.startDate")} – ${o("datepicker.endDate")}`
|
|
844
|
+
})
|
|
845
|
+
]),
|
|
846
|
+
l.value ? a("div", { class: `${t.value}-picker__panel`, role: "dialog" }, [
|
|
847
|
+
e.presets ? a(
|
|
848
|
+
"ul",
|
|
849
|
+
{ class: `${t.value}-picker__ranges` },
|
|
850
|
+
Object.entries(oe()).map(
|
|
851
|
+
([b, [T, y]]) => a(
|
|
852
|
+
"li",
|
|
853
|
+
{ key: b },
|
|
854
|
+
a(
|
|
855
|
+
"button",
|
|
856
|
+
{
|
|
857
|
+
type: "button",
|
|
858
|
+
class: V({ "is-active": z(T, u) && z(y, m) }),
|
|
859
|
+
onClick: () => {
|
|
860
|
+
s("update:modelValue", [B(T), B(y)]), l.value = !1;
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
o(`datepicker.ranges.${b}`)
|
|
864
|
+
)
|
|
865
|
+
)
|
|
866
|
+
)
|
|
867
|
+
) : null,
|
|
868
|
+
a("div", { style: { display: "flex", gap: "16px", flexWrap: "wrap" } }, [
|
|
869
|
+
a(H, { month: v.value, "onUpdate:month": (b) => v.value = b, ...p }),
|
|
870
|
+
a(H, { month: E(v.value, 1), "onUpdate:month": (b) => v.value = E(b, -1), ...p })
|
|
871
|
+
])
|
|
872
|
+
]) : null
|
|
873
|
+
]);
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
}), Fe = /* @__PURE__ */ g({
|
|
877
|
+
name: "ThlTimePicker",
|
|
878
|
+
props: { modelValue: k(), step: { type: Number, default: 5 }, id: String, placeholder: String },
|
|
879
|
+
emits: ["update:modelValue"],
|
|
880
|
+
setup(e, { emit: s }) {
|
|
881
|
+
const t = f(), { t: o, d: i } = $(), { open: l, root: d } = P(), v = (n, r) => s("update:modelValue", `${String(n).padStart(2, "0")}:${String(r).padStart(2, "0")}`);
|
|
882
|
+
return () => {
|
|
883
|
+
const [n, r] = (e.modelValue ?? "").split(":").map(Number);
|
|
884
|
+
return a("div", { ref: d, class: `${t.value}-picker` }, [
|
|
885
|
+
a("div", { class: `${t.value}-input-group` }, [
|
|
886
|
+
a("input", {
|
|
887
|
+
id: e.id,
|
|
888
|
+
readonly: !0,
|
|
889
|
+
class: `${t.value}-input`,
|
|
890
|
+
value: e.modelValue ? i(new Date(2e3, 0, 1, n, r), { hour: "numeric", minute: "2-digit" }) : "",
|
|
891
|
+
placeholder: e.placeholder ?? o("datepicker.selectTime"),
|
|
892
|
+
role: "combobox",
|
|
893
|
+
"aria-haspopup": "dialog",
|
|
894
|
+
"aria-expanded": String(l.value),
|
|
895
|
+
"aria-label": e.placeholder ?? o("datepicker.selectTime"),
|
|
896
|
+
onClick: () => l.value = !0
|
|
897
|
+
}),
|
|
898
|
+
a(_, { "aria-label": o("datepicker.selectTime"), onClick: () => l.value = !l.value }, () => w("clock"))
|
|
899
|
+
]),
|
|
900
|
+
l.value ? a("div", { class: `${t.value}-picker__panel`, style: { minWidth: 0, flexDirection: "column" } }, [
|
|
901
|
+
a("div", { class: `${t.value}-time-list` }, [
|
|
902
|
+
a(
|
|
903
|
+
"ul",
|
|
904
|
+
{ "aria-label": "hours" },
|
|
905
|
+
Array.from(
|
|
906
|
+
{ length: 24 },
|
|
907
|
+
(c, u) => a(
|
|
908
|
+
"li",
|
|
909
|
+
{ key: u },
|
|
910
|
+
a(
|
|
911
|
+
"button",
|
|
912
|
+
{ type: "button", class: V({ "is-selected": u === n }), onClick: () => v(u, Number.isNaN(r) ? 0 : r) },
|
|
913
|
+
String(u).padStart(2, "0")
|
|
914
|
+
)
|
|
915
|
+
)
|
|
916
|
+
)
|
|
917
|
+
),
|
|
918
|
+
a(
|
|
919
|
+
"ul",
|
|
920
|
+
{ "aria-label": "minutes" },
|
|
921
|
+
Array.from({ length: 60 / e.step }, (c, u) => u * e.step).map(
|
|
922
|
+
(c) => a(
|
|
923
|
+
"li",
|
|
924
|
+
{ key: c },
|
|
925
|
+
a(
|
|
926
|
+
"button",
|
|
927
|
+
{
|
|
928
|
+
type: "button",
|
|
929
|
+
class: V({ "is-selected": c === r }),
|
|
930
|
+
onClick: () => {
|
|
931
|
+
v(Number.isNaN(n) ? 0 : n, c), l.value = !1;
|
|
932
|
+
}
|
|
933
|
+
},
|
|
934
|
+
String(c).padStart(2, "0")
|
|
935
|
+
)
|
|
936
|
+
)
|
|
937
|
+
)
|
|
938
|
+
)
|
|
939
|
+
]),
|
|
940
|
+
a(
|
|
941
|
+
"div",
|
|
942
|
+
{ class: `${t.value}-picker__footer` },
|
|
943
|
+
a(
|
|
944
|
+
_,
|
|
945
|
+
{
|
|
946
|
+
size: "sm",
|
|
947
|
+
onClick: () => {
|
|
948
|
+
const c = /* @__PURE__ */ new Date();
|
|
949
|
+
v(c.getHours(), c.getMinutes()), l.value = !1;
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
() => o("datepicker.now")
|
|
953
|
+
)
|
|
954
|
+
)
|
|
955
|
+
]) : null
|
|
956
|
+
]);
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
}), ge = [
|
|
960
|
+
"#0283cc",
|
|
961
|
+
"#00bbd9",
|
|
962
|
+
"#2ecc71",
|
|
963
|
+
"#ffb136",
|
|
964
|
+
"#e74a25",
|
|
965
|
+
"#4a23ad",
|
|
966
|
+
"#282f32",
|
|
967
|
+
"#8d9498",
|
|
968
|
+
"#0078bc",
|
|
969
|
+
"#25bf67",
|
|
970
|
+
"#f2a225",
|
|
971
|
+
"#d93c17",
|
|
972
|
+
"#693fd5",
|
|
973
|
+
"#4b555b",
|
|
974
|
+
"#e5ebec",
|
|
975
|
+
"#ffffff"
|
|
976
|
+
], Me = /* @__PURE__ */ g({
|
|
977
|
+
name: "ThlColorPicker",
|
|
978
|
+
props: { modelValue: { type: String, default: "#0283cc" }, id: String, palette: { type: Array, default: () => ge } },
|
|
979
|
+
emits: ["update:modelValue"],
|
|
980
|
+
setup(e, { emit: s }) {
|
|
981
|
+
const t = f(), { t: o } = $(), { open: i, root: l } = P();
|
|
982
|
+
return () => a("div", { ref: l, class: `${t.value}-picker` }, [
|
|
983
|
+
a("div", { class: `${t.value}-input-group` }, [
|
|
984
|
+
a("span", { class: `${t.value}-input-group__addon` }, a("span", { class: `${t.value}-color-swatch`, style: { background: e.modelValue } })),
|
|
985
|
+
a("input", {
|
|
986
|
+
id: e.id,
|
|
987
|
+
class: `${t.value}-input`,
|
|
988
|
+
value: e.modelValue,
|
|
989
|
+
"aria-label": o("common.color"),
|
|
990
|
+
spellcheck: !1,
|
|
991
|
+
onInput: (d) => s("update:modelValue", d.target.value),
|
|
992
|
+
onFocus: () => i.value = !0
|
|
993
|
+
}),
|
|
994
|
+
a("input", {
|
|
995
|
+
type: "color",
|
|
996
|
+
value: e.modelValue,
|
|
997
|
+
"aria-label": o("common.color"),
|
|
998
|
+
onInput: (d) => s("update:modelValue", d.target.value),
|
|
999
|
+
style: { width: "44px", height: "auto", border: "1px solid var(--thl-border-color)", padding: "2px", background: "var(--thl-surface)" }
|
|
1000
|
+
})
|
|
1001
|
+
]),
|
|
1002
|
+
i.value ? a(
|
|
1003
|
+
"div",
|
|
1004
|
+
{ class: `${t.value}-picker__panel`, style: { minWidth: 0 } },
|
|
1005
|
+
a(
|
|
1006
|
+
"div",
|
|
1007
|
+
{ class: `${t.value}-color-palette` },
|
|
1008
|
+
e.palette.map(
|
|
1009
|
+
(d) => a("button", {
|
|
1010
|
+
key: d,
|
|
1011
|
+
type: "button",
|
|
1012
|
+
"aria-label": d,
|
|
1013
|
+
class: V({ "is-selected": d.toLowerCase() === e.modelValue.toLowerCase() }),
|
|
1014
|
+
style: { background: d },
|
|
1015
|
+
onClick: () => {
|
|
1016
|
+
s("update:modelValue", d), i.value = !1;
|
|
1017
|
+
}
|
|
1018
|
+
})
|
|
1019
|
+
)
|
|
1020
|
+
)
|
|
1021
|
+
) : null
|
|
1022
|
+
]);
|
|
1023
|
+
}
|
|
1024
|
+
}), He = /* @__PURE__ */ g({
|
|
1025
|
+
name: "ThlUpload",
|
|
1026
|
+
props: {
|
|
1027
|
+
accept: String,
|
|
1028
|
+
maxSize: Number,
|
|
1029
|
+
multiple: { type: Boolean, default: void 0 },
|
|
1030
|
+
maxFiles: Number,
|
|
1031
|
+
request: Function,
|
|
1032
|
+
variant: X("list"),
|
|
1033
|
+
hint: String
|
|
1034
|
+
},
|
|
1035
|
+
emits: ["change"],
|
|
1036
|
+
setup(e, { emit: s }) {
|
|
1037
|
+
const t = f(), { t: o } = $(), i = G("Upload", e), l = U(() => i.value.multiple ?? e.variant === "list"), d = se({
|
|
1038
|
+
accept: i.value.accept,
|
|
1039
|
+
maxSize: i.value.maxSize,
|
|
1040
|
+
multiple: l.value,
|
|
1041
|
+
maxFiles: e.maxFiles,
|
|
1042
|
+
request: e.request,
|
|
1043
|
+
onChange: (r) => s("change", r)
|
|
1044
|
+
}), v = W(d.state), n = S();
|
|
1045
|
+
return () => {
|
|
1046
|
+
const r = x("upload", t.value), c = v.value, u = e.variant === "single" ? c.files[0] : void 0;
|
|
1047
|
+
return a("div", { class: r() }, [
|
|
1048
|
+
a(
|
|
1049
|
+
"div",
|
|
1050
|
+
{
|
|
1051
|
+
role: "button",
|
|
1052
|
+
tabindex: 0,
|
|
1053
|
+
class: V(r("zone"), { "is-dragging": c.dragging }),
|
|
1054
|
+
onClick: () => n.value?.click(),
|
|
1055
|
+
onKeydown: (m) => {
|
|
1056
|
+
(m.key === "Enter" || m.key === " ") && (m.preventDefault(), n.value?.click());
|
|
1057
|
+
},
|
|
1058
|
+
onDragenter: d.dragHandlers.onDragEnter,
|
|
1059
|
+
onDragover: d.dragHandlers.onDragOver,
|
|
1060
|
+
onDragleave: d.dragHandlers.onDragLeave,
|
|
1061
|
+
onDrop: d.dragHandlers.onDrop
|
|
1062
|
+
},
|
|
1063
|
+
[
|
|
1064
|
+
...u ? [
|
|
1065
|
+
a("div", { class: r("preview") }, [
|
|
1066
|
+
u.preview ? a("img", { src: u.preview, alt: u.name }) : w("file", { class: r("icon") }),
|
|
1067
|
+
a("div", { class: r("name") }, u.name),
|
|
1068
|
+
a("small", o("upload.replace"))
|
|
1069
|
+
])
|
|
1070
|
+
] : [
|
|
1071
|
+
w("cloud-upload", { class: r("icon") }),
|
|
1072
|
+
a("div", e.variant === "single" ? o("upload.dropHere") : o("upload.dropMultiple")),
|
|
1073
|
+
e.hint ? a("small", e.hint) : null
|
|
1074
|
+
],
|
|
1075
|
+
a("input", {
|
|
1076
|
+
ref: n,
|
|
1077
|
+
type: "file",
|
|
1078
|
+
class: r("input"),
|
|
1079
|
+
accept: i.value.accept,
|
|
1080
|
+
multiple: l.value,
|
|
1081
|
+
tabindex: -1,
|
|
1082
|
+
"aria-hidden": "true",
|
|
1083
|
+
onChange: (m) => {
|
|
1084
|
+
const p = m.target;
|
|
1085
|
+
p.files && d.add(p.files), p.value = "";
|
|
1086
|
+
}
|
|
1087
|
+
})
|
|
1088
|
+
]
|
|
1089
|
+
),
|
|
1090
|
+
c.errors.length ? a(
|
|
1091
|
+
"div",
|
|
1092
|
+
{ class: r("errors"), role: "alert" },
|
|
1093
|
+
c.errors.map((m, p) => a("div", { key: p }, o(m.key, m.params)))
|
|
1094
|
+
) : null,
|
|
1095
|
+
e.variant === "list" && c.files.length ? a(
|
|
1096
|
+
"ul",
|
|
1097
|
+
{ class: r("list") },
|
|
1098
|
+
c.files.map(
|
|
1099
|
+
(m) => a("li", { key: m.id, class: V(r("file"), { "is-error": m.status === "error" }) }, [
|
|
1100
|
+
m.preview ? a("img", { src: m.preview, alt: "" }) : w("file-text", { size: 40 }),
|
|
1101
|
+
a("div", { class: r("name"), title: m.name }, m.name),
|
|
1102
|
+
a(
|
|
1103
|
+
"div",
|
|
1104
|
+
{ class: r("meta") },
|
|
1105
|
+
`${ue(m.size)} · ${m.status === "uploading" ? `${m.progress}%` : m.status === "done" ? o("upload.uploaded") : m.status === "error" ? o("upload.failed") : ""}`
|
|
1106
|
+
),
|
|
1107
|
+
m.status === "uploading" ? a(
|
|
1108
|
+
"div",
|
|
1109
|
+
{ class: `${t.value}-progress ${t.value}-progress--size-xs`, style: { margin: "6px 0 0" } },
|
|
1110
|
+
a("div", { class: `${t.value}-progress__bar`, style: { width: `${m.progress}%` } })
|
|
1111
|
+
) : null,
|
|
1112
|
+
a("button", { type: "button", class: r("remove"), onClick: () => d.remove(m.id), "aria-label": `${o("upload.remove")} ${m.name}` }, "×")
|
|
1113
|
+
])
|
|
1114
|
+
)
|
|
1115
|
+
) : null,
|
|
1116
|
+
u ? a(
|
|
1117
|
+
"div",
|
|
1118
|
+
{ class: `${t.value}-mt-2` },
|
|
1119
|
+
a(_, { size: "sm", variant: "danger", outline: !0, onClick: () => d.clear() }, () => o("upload.remove"))
|
|
1120
|
+
) : null
|
|
1121
|
+
]);
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
}), Ue = /* @__PURE__ */ g({
|
|
1125
|
+
name: "ThlEditor",
|
|
1126
|
+
props: { modelValue: { type: String, default: "" }, placeholder: String, minHeight: Number, ariaLabel: String },
|
|
1127
|
+
emits: ["update:modelValue"],
|
|
1128
|
+
setup(e, { emit: s }) {
|
|
1129
|
+
const t = f(), { t: o } = $(), i = S();
|
|
1130
|
+
N(() => {
|
|
1131
|
+
i.value && (i.value.innerHTML = e.modelValue);
|
|
1132
|
+
}), A(
|
|
1133
|
+
() => e.modelValue,
|
|
1134
|
+
(v) => {
|
|
1135
|
+
i.value && i.value.innerHTML !== v && (i.value.innerHTML = v);
|
|
1136
|
+
}
|
|
1137
|
+
);
|
|
1138
|
+
const l = (v, n) => {
|
|
1139
|
+
document.execCommand(v, !1, n), i.value?.focus(), s("update:modelValue", i.value?.innerHTML ?? "");
|
|
1140
|
+
}, d = [
|
|
1141
|
+
["bold", "bold"],
|
|
1142
|
+
["italic", "italic"],
|
|
1143
|
+
["underline", "underline"],
|
|
1144
|
+
["list", "insertUnorderedList"],
|
|
1145
|
+
["list-ordered", "insertOrderedList"],
|
|
1146
|
+
["quote", "formatBlock", "blockquote"],
|
|
1147
|
+
["link", "createLink"],
|
|
1148
|
+
["undo-2", "undo"],
|
|
1149
|
+
["redo-2", "redo"]
|
|
1150
|
+
];
|
|
1151
|
+
return () => {
|
|
1152
|
+
const v = x("editor", t.value);
|
|
1153
|
+
return a("div", { class: v() }, [
|
|
1154
|
+
a(
|
|
1155
|
+
"div",
|
|
1156
|
+
{ class: v("toolbar"), role: "toolbar", "aria-label": o("common.editor") },
|
|
1157
|
+
d.map(
|
|
1158
|
+
([n, r, c]) => a(
|
|
1159
|
+
"button",
|
|
1160
|
+
{
|
|
1161
|
+
key: r + (c ?? ""),
|
|
1162
|
+
type: "button",
|
|
1163
|
+
"aria-label": r,
|
|
1164
|
+
onMousedown: (u) => u.preventDefault(),
|
|
1165
|
+
onClick: () => l(r, r === "createLink" ? window.prompt("URL") ?? void 0 : c)
|
|
1166
|
+
},
|
|
1167
|
+
w(n)
|
|
1168
|
+
)
|
|
1169
|
+
)
|
|
1170
|
+
),
|
|
1171
|
+
a("div", {
|
|
1172
|
+
ref: i,
|
|
1173
|
+
class: v("content"),
|
|
1174
|
+
contenteditable: "true",
|
|
1175
|
+
role: "textbox",
|
|
1176
|
+
"aria-multiline": "true",
|
|
1177
|
+
"aria-label": e.ariaLabel ?? e.placeholder ?? o("common.editor"),
|
|
1178
|
+
"data-placeholder": e.placeholder,
|
|
1179
|
+
style: { minHeight: e.minHeight ? `${e.minHeight}px` : void 0 },
|
|
1180
|
+
onInput: (n) => s("update:modelValue", n.target.innerHTML)
|
|
1181
|
+
})
|
|
1182
|
+
]);
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
export {
|
|
1187
|
+
H as ThlCalendarGrid,
|
|
1188
|
+
ve as ThlCheckbox,
|
|
1189
|
+
_e as ThlCheckboxGroup,
|
|
1190
|
+
Me as ThlColorPicker,
|
|
1191
|
+
Pe as ThlDatePicker,
|
|
1192
|
+
qe as ThlDateRangePicker,
|
|
1193
|
+
Ue as ThlEditor,
|
|
1194
|
+
Te as ThlField,
|
|
1195
|
+
Be as ThlFloatingLabel,
|
|
1196
|
+
xe as ThlForm,
|
|
1197
|
+
we as ThlFormActions,
|
|
1198
|
+
$e as ThlInput,
|
|
1199
|
+
Ae as ThlInputGroup,
|
|
1200
|
+
De as ThlNativeSelect,
|
|
1201
|
+
Ie as ThlNumberInput,
|
|
1202
|
+
be as ThlRadio,
|
|
1203
|
+
ze as ThlRadioGroup,
|
|
1204
|
+
he as ThlSelect,
|
|
1205
|
+
Ne as ThlSlider,
|
|
1206
|
+
Le as ThlSwitch,
|
|
1207
|
+
Ee as ThlTagsInput,
|
|
1208
|
+
Ce as ThlTextarea,
|
|
1209
|
+
Fe as ThlTimePicker,
|
|
1210
|
+
He as ThlUpload
|
|
1211
|
+
};
|
|
1212
|
+
//# sourceMappingURL=form.js.map
|