@kernel4632/kima 0.0.0-stage → 0.6.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 +166 -2
- package/dist/THIRD_PARTY_NOTICES.txt +2676 -0
- package/dist/kima-elements-core.js +53209 -0
- package/dist/kima-elements.js +126371 -0
- package/dist/kima-theme.js +1583 -0
- package/dist/kima.js +141 -0
- package/dist/style.css +2 -0
- package/dist/vue/_virtual/_plugin-vue_export-helper.js +7 -0
- package/dist/vue/components/advanced-input/calendar.ce.js +216 -0
- package/dist/vue/components/advanced-input/date-range-picker.ce.js +224 -0
- package/dist/vue/components/advanced-input/editable.ce.js +160 -0
- package/dist/vue/components/advanced-input/mention.ce.js +181 -0
- package/dist/vue/components/advanced-input/range-slider.ce.js +111 -0
- package/dist/vue/components/advanced-input/time-range-picker.ce.js +120 -0
- package/dist/vue/components/advanced-input/transfer.ce.js +192 -0
- package/dist/vue/components/content/chart.ce.js +282 -0
- package/dist/vue/components/content/code-editor.ce.js +309 -0
- package/dist/vue/components/content/equation.ce.js +69 -0
- package/dist/vue/components/content/heatmap.ce.js +148 -0
- package/dist/vue/components/content/rich-text-editor.ce.js +319 -0
- package/dist/vue/components/core/badge.ce.js +66 -0
- package/dist/vue/components/core/button-group.ce.js +142 -0
- package/dist/vue/components/core/button.ce.js +73 -0
- package/dist/vue/components/core/card.ce.js +73 -0
- package/dist/vue/components/core/cascader.ce.js +329 -0
- package/dist/vue/components/core/checkbox.ce.js +116 -0
- package/dist/vue/components/core/code-block.ce.js +108 -0
- package/dist/vue/components/core/combobox.ce.js +354 -0
- package/dist/vue/components/core/date-picker.ce.js +433 -0
- package/dist/vue/components/core/dialog.ce.js +118 -0
- package/dist/vue/components/core/divider.ce.js +49 -0
- package/dist/vue/components/core/drawer.ce.js +235 -0
- package/dist/vue/components/core/empty-state.ce.js +58 -0
- package/dist/vue/components/core/icon-button.ce.js +93 -0
- package/dist/vue/components/core/icon.ce.js +42 -0
- package/dist/vue/components/core/layout.ce.js +68 -0
- package/dist/vue/components/core/menu.ce.js +178 -0
- package/dist/vue/components/core/notification.ce.js +158 -0
- package/dist/vue/components/core/pagination.ce.js +158 -0
- package/dist/vue/components/core/progress.ce.js +49 -0
- package/dist/vue/components/core/select.ce.js +325 -0
- package/dist/vue/components/core/slider.ce.js +116 -0
- package/dist/vue/components/core/switch.ce.js +100 -0
- package/dist/vue/components/core/tabs.ce.js +193 -0
- package/dist/vue/components/core/text-field.ce.js +194 -0
- package/dist/vue/components/core/time-picker.ce.js +486 -0
- package/dist/vue/components/core/tooltip.ce.js +125 -0
- package/dist/vue/components/core/tree.ce.js +248 -0
- package/dist/vue/components/core/virtual-scroll.ce.js +176 -0
- package/dist/vue/components/data/copy-button.ce.js +75 -0
- package/dist/vue/components/data/image-preview.ce.js +226 -0
- package/dist/vue/components/data/infinite-scroll.ce.js +126 -0
- package/dist/vue/components/data/long-text.ce.js +70 -0
- package/dist/vue/components/data/relative-time.ce.js +77 -0
- package/dist/vue/components/data/ring-progress.ce.js +87 -0
- package/dist/vue/components/data/table.ce.js +491 -0
- package/dist/vue/components/data/virtual-table.ce.js +178 -0
- package/dist/vue/components/data/virtual-tree.ce.js +213 -0
- package/dist/vue/components/display/alert.ce.js +101 -0
- package/dist/vue/components/display/avatar-group.ce.js +65 -0
- package/dist/vue/components/display/avatar.ce.js +84 -0
- package/dist/vue/components/display/blockquote.ce.js +44 -0
- package/dist/vue/components/display/countdown.ce.js +77 -0
- package/dist/vue/components/display/descriptions.ce.js +43 -0
- package/dist/vue/components/display/highlight.ce.js +48 -0
- package/dist/vue/components/display/image.ce.js +146 -0
- package/dist/vue/components/display/list.ce.js +68 -0
- package/dist/vue/components/display/result.ce.js +57 -0
- package/dist/vue/components/display/skeleton.ce.js +67 -0
- package/dist/vue/components/display/spinner.ce.js +42 -0
- package/dist/vue/components/display/statistic.ce.js +71 -0
- package/dist/vue/components/display/timeline.ce.js +59 -0
- package/dist/vue/components/form-completion/angle-slider.ce.js +103 -0
- package/dist/vue/components/form-completion/color-picker.ce.js +286 -0
- package/dist/vue/components/form-completion/date-field.ce.js +131 -0
- package/dist/vue/components/form-completion/dynamic-input.ce.js +158 -0
- package/dist/vue/components/form-completion/form.ce.js +248 -0
- package/dist/vue/components/form-completion/json-input.ce.js +114 -0
- package/dist/vue/components/form-completion/masked-input.ce.js +88 -0
- package/dist/vue/components/form-completion/period-picker.ce.js +147 -0
- package/dist/vue/components/form-completion/time-field.ce.js +120 -0
- package/dist/vue/components/form-completion/upload-manager.ce.js +223 -0
- package/dist/vue/components/foundation/banner.ce.js +106 -0
- package/dist/vue/components/foundation/error-state.ce.js +108 -0
- package/dist/vue/components/foundation/field-group.ce.js +146 -0
- package/dist/vue/components/foundation/flex.ce.js +60 -0
- package/dist/vue/components/foundation/grid.ce.js +52 -0
- package/dist/vue/components/foundation/input-group.ce.js +34 -0
- package/dist/vue/components/foundation/page-header.ce.js +55 -0
- package/dist/vue/components/foundation/time-display.ce.js +129 -0
- package/dist/vue/components/foundation/typography.ce.js +71 -0
- package/dist/vue/components/input/checkbox-group.ce.js +93 -0
- package/dist/vue/components/input/field.ce.js +74 -0
- package/dist/vue/components/input/file-upload.ce.js +142 -0
- package/dist/vue/components/input/number-field.ce.js +103 -0
- package/dist/vue/components/input/pin-input.ce.js +112 -0
- package/dist/vue/components/input/radio-group.ce.js +96 -0
- package/dist/vue/components/input/rating.ce.js +115 -0
- package/dist/vue/components/input/tags-input.ce.js +153 -0
- package/dist/vue/components/input/textarea.ce.js +180 -0
- package/dist/vue/components/input/toggle.ce.js +58 -0
- package/dist/vue/components/interaction/chip.ce.js +95 -0
- package/dist/vue/components/interaction/command.ce.js +161 -0
- package/dist/vue/components/interaction/context-menu.ce.js +113 -0
- package/dist/vue/components/interaction/hover-card.ce.js +92 -0
- package/dist/vue/components/interaction/loading-overlay.ce.js +70 -0
- package/dist/vue/components/interaction/menubar.ce.js +134 -0
- package/dist/vue/components/interaction/multi-select.ce.js +264 -0
- package/dist/vue/components/interaction/popconfirm.ce.js +95 -0
- package/dist/vue/components/interaction/popover.ce.js +83 -0
- package/dist/vue/components/interaction/tree-select.ce.js +195 -0
- package/dist/vue/components/navigation/accordion.ce.js +114 -0
- package/dist/vue/components/navigation/anchor.ce.js +125 -0
- package/dist/vue/components/navigation/back-top.ce.js +67 -0
- package/dist/vue/components/navigation/breadcrumb.ce.js +48 -0
- package/dist/vue/components/navigation/carousel.ce.js +114 -0
- package/dist/vue/components/navigation/collapsible.ce.js +57 -0
- package/dist/vue/components/navigation/link.ce.js +62 -0
- package/dist/vue/components/navigation/navigation-menu.ce.js +91 -0
- package/dist/vue/components/navigation/overflow-list.ce.js +67 -0
- package/dist/vue/components/navigation/scroll-area.ce.js +47 -0
- package/dist/vue/components/navigation/splitter.ce.js +131 -0
- package/dist/vue/components/navigation/stepper.ce.js +74 -0
- package/dist/vue/components/navigation/toolbar.ce.js +93 -0
- package/dist/vue/components/navigation/visually-hidden.ce.js +16 -0
- package/dist/vue/components/shell/app-shell.ce.js +87 -0
- package/dist/vue/components/shell/config-provider.ce.js +110 -0
- package/dist/vue/components/shell/marquee.ce.js +92 -0
- package/dist/vue/components/shell/masonry.ce.js +50 -0
- package/dist/vue/components/shell/sidebar.ce.js +125 -0
- package/dist/vue/components/utility/affix.ce.js +64 -0
- package/dist/vue/components/utility/alert-dialog.ce.js +124 -0
- package/dist/vue/components/utility/animated-number.ce.js +66 -0
- package/dist/vue/components/utility/float-button.ce.js +104 -0
- package/dist/vue/components/utility/listbox.ce.js +81 -0
- package/dist/vue/components/utility/loading-bar.ce.js +85 -0
- package/dist/vue/components/utility/log-viewer.ce.js +124 -0
- package/dist/vue/components/utility/notification-queue.ce.js +109 -0
- package/dist/vue/components/utility/progress-group.ce.js +59 -0
- package/dist/vue/components/utility/qr-code.ce.js +62 -0
- package/dist/vue/components/utility/tag-group.ce.js +124 -0
- package/dist/vue/components/utility/tour.ce.js +214 -0
- package/dist/vue/components/utility/virtual-select.ce.js +207 -0
- package/dist/vue/components/utility/watermark.ce.js +44 -0
- package/dist/vue/internal/menu-items.js +184 -0
- package/dist/vue/internal/navigation-items.js +110 -0
- package/dist/vue/utils/code-highlight.js +142 -0
- package/dist/vue/utils/config.js +47 -0
- package/dist/vue/utils/content-motion.js +37 -0
- package/dist/vue/utils/content.js +83 -0
- package/dist/vue/utils/display-status.js +31 -0
- package/dist/vue/utils/foundation.js +65 -0
- package/dist/vue/utils/input-state.js +38 -0
- package/dist/vue/utils/interaction.js +103 -0
- package/dist/vue/utils/local-date.js +48 -0
- package/dist/vue/utils/motion.js +80 -0
- package/dist/vue/utils/native-slots.js +30 -0
- package/dist/vue/utils/navigation.js +44 -0
- package/dist/vue/utils/notifications.js +60 -0
- package/dist/vue/utils/qr.js +20 -0
- package/dist/vue/utils/remote-options.js +65 -0
- package/dist/vue/utils/ripple.js +20 -0
- package/dist/vue/utils/scoped-slots.js +22 -0
- package/dist/vue/utils/shell.js +43 -0
- package/dist/vue/utils/theme.js +50 -0
- package/dist/vue/utils/utility-choice.js +56 -0
- package/package.json +99 -4
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { useNativeSlots as e } from "../../utils/native-slots.js";
|
|
2
|
+
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
3
|
+
import { collapseTransition as n } from "../../utils/motion.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { Transition as r, computed as i, createElementBlock as a, createElementVNode as o, createVNode as s, mergeProps as c, onBeforeUnmount as l, openBlock as u, ref as d, renderSlot as f, toDisplayString as p, unref as m, vShow as h, withCtx as g, withDirectives as _, withModifiers as v } from "vue";
|
|
6
|
+
// src/components/form-completion/form.ce.vue
|
|
7
|
+
var y = [
|
|
8
|
+
"aria-busy",
|
|
9
|
+
"data-dirty",
|
|
10
|
+
"data-submitted",
|
|
11
|
+
"novalidate"
|
|
12
|
+
], b = ["disabled"], x = ["inert", "aria-hidden"], S = {
|
|
13
|
+
class: "kima-form__error",
|
|
14
|
+
role: "alert"
|
|
15
|
+
}, C = /*#__PURE__*/ t({
|
|
16
|
+
__name: "form.ce",
|
|
17
|
+
props: {
|
|
18
|
+
disabled: Boolean,
|
|
19
|
+
loading: Boolean,
|
|
20
|
+
novalidate: Boolean,
|
|
21
|
+
handleSubmit: Function,
|
|
22
|
+
submitHandler: Function,
|
|
23
|
+
rules: {
|
|
24
|
+
type: Object,
|
|
25
|
+
default: () => ({})
|
|
26
|
+
},
|
|
27
|
+
context: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: () => ({})
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
emits: [
|
|
33
|
+
"submit",
|
|
34
|
+
"success",
|
|
35
|
+
"error",
|
|
36
|
+
"invalid",
|
|
37
|
+
"reset",
|
|
38
|
+
"state-change",
|
|
39
|
+
"validate"
|
|
40
|
+
],
|
|
41
|
+
setup(t, { expose: C, emit: w }) {
|
|
42
|
+
let T = t, E = w, D = d(null);
|
|
43
|
+
e(D);
|
|
44
|
+
let O = d(!1), k = d(""), A = d(""), j = d(!1), M = d([]), N = d([]), P = d([]), F = d({}), I = d(!1), L = i(() => T.loading || O.value || I.value), R = 0, z = !1, B = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Set();
|
|
45
|
+
function H() {
|
|
46
|
+
return [...D.value?.elements || []].filter((e) => e.willValidate);
|
|
47
|
+
}
|
|
48
|
+
function U() {
|
|
49
|
+
return Object.fromEntries(H().filter((e) => e.name).map((e) => [e.name, e.value]));
|
|
50
|
+
}
|
|
51
|
+
function W() {
|
|
52
|
+
return {
|
|
53
|
+
pending: L.value,
|
|
54
|
+
validating: I.value,
|
|
55
|
+
submitted: j.value,
|
|
56
|
+
dirty: [...M.value],
|
|
57
|
+
touched: [...N.value],
|
|
58
|
+
invalid: [...P.value],
|
|
59
|
+
errors: { ...F.value },
|
|
60
|
+
error: k.value
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function G() {
|
|
64
|
+
E("state-change", W());
|
|
65
|
+
}
|
|
66
|
+
function K() {
|
|
67
|
+
P.value = [...new Set(H().filter((e) => !e.validity.valid).map((e) => e.name || e.getAttribute("aria-label") || "unnamed"))];
|
|
68
|
+
}
|
|
69
|
+
function q(e) {
|
|
70
|
+
let t = T.rules?.[e];
|
|
71
|
+
return typeof t == "function" ? { validator: t } : t || {};
|
|
72
|
+
}
|
|
73
|
+
function J(e) {
|
|
74
|
+
return e === !0 || e == null || e === "" ? "" : e === !1 ? "输入无效" : String(e);
|
|
75
|
+
}
|
|
76
|
+
function Y(e) {
|
|
77
|
+
return H().filter((t) => t.name === e);
|
|
78
|
+
}
|
|
79
|
+
function X(e, t) {
|
|
80
|
+
for (let n of Y(e)) n.setCustomValidity(t || ""), t ? n.setAttribute("aria-invalid", "true") : n.dataset.kimaRuleInvalid && n.removeAttribute("aria-invalid"), n.dataset.kimaRuleInvalid = t ? "true" : "";
|
|
81
|
+
for (let n of D.value?.querySelectorAll(".kima-field") || []) n.querySelector(`[name="${CSS.escape(e)}"]`) && (t ? n.setAttribute("data-kima-validation-error", t) : n.removeAttribute("data-kima-validation-error"));
|
|
82
|
+
}
|
|
83
|
+
async function Z(e, t = U()[e], n = "change") {
|
|
84
|
+
let r = q(e), i = typeof r == "function" ? r : r.validator || r.sync || r.async;
|
|
85
|
+
if (typeof i != "function") return "";
|
|
86
|
+
let a = B.get(e);
|
|
87
|
+
a && V.delete(`${e}:${a}`);
|
|
88
|
+
let o = (a || 0) + 1;
|
|
89
|
+
B.set(e, o);
|
|
90
|
+
let s = `${e}:${o}`;
|
|
91
|
+
V.add(s), I.value = !0, G();
|
|
92
|
+
try {
|
|
93
|
+
let a = {
|
|
94
|
+
name: e,
|
|
95
|
+
model: U(),
|
|
96
|
+
context: T.context,
|
|
97
|
+
source: n,
|
|
98
|
+
form: D.value
|
|
99
|
+
}, s;
|
|
100
|
+
if (typeof r.sync == "function" && (s = r.sync(t, a)), J(s) || (typeof r.async == "function" ? s = await r.async(t, a) : (typeof r.validator == "function" || typeof r == "function") && (s = await i(t, a))), B.get(e) !== o) return null;
|
|
101
|
+
let c = J(s);
|
|
102
|
+
return F.value = {
|
|
103
|
+
...F.value,
|
|
104
|
+
[e]: c
|
|
105
|
+
}, X(e, c), E("validate", {
|
|
106
|
+
name: e,
|
|
107
|
+
value: t,
|
|
108
|
+
valid: !c,
|
|
109
|
+
message: c
|
|
110
|
+
}), c;
|
|
111
|
+
} catch (n) {
|
|
112
|
+
if (B.get(e) !== o) return null;
|
|
113
|
+
let r = n?.message || String(n);
|
|
114
|
+
return F.value = {
|
|
115
|
+
...F.value,
|
|
116
|
+
[e]: r
|
|
117
|
+
}, X(e, r), E("validate", {
|
|
118
|
+
name: e,
|
|
119
|
+
value: t,
|
|
120
|
+
valid: !1,
|
|
121
|
+
message: r
|
|
122
|
+
}), r;
|
|
123
|
+
} finally {
|
|
124
|
+
V.delete(s), I.value = V.size > 0, G();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async function Q(e = "submit") {
|
|
128
|
+
let t = Object.keys(T.rules || {});
|
|
129
|
+
try {
|
|
130
|
+
let n = await Promise.all(t.map((t) => Z(t, U()[t], e))), r = Object.fromEntries(t.map((e, t) => [e, n[t] || ""]).filter(([, e]) => e));
|
|
131
|
+
return F.value = {
|
|
132
|
+
...F.value,
|
|
133
|
+
...r
|
|
134
|
+
}, Object.keys(r).length === 0;
|
|
135
|
+
} finally {
|
|
136
|
+
e === "submit" && (V.clear(), I.value = !1, G());
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function $(e, t) {
|
|
140
|
+
let n = t === "dirty" ? M : N, r = e.target.name;
|
|
141
|
+
r && !n.value.includes(r) && (n.value = [...n.value, r]), r && t === "dirty" && Z(r, e.target.value, t), K(), G();
|
|
142
|
+
}
|
|
143
|
+
function ee(e) {
|
|
144
|
+
e.target?.willValidate && (K(), j.value = !0, E("invalid", {
|
|
145
|
+
control: e.target,
|
|
146
|
+
message: e.target.validationMessage,
|
|
147
|
+
field: e.target.closest(".kima-field")
|
|
148
|
+
}), G());
|
|
149
|
+
}
|
|
150
|
+
async function te(e) {
|
|
151
|
+
if (z) return;
|
|
152
|
+
if (O.value || T.loading || T.disabled) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
let t = !!(T.handleSubmit || T.submitHandler), n = Object.keys(T.rules || {}).length > 0;
|
|
157
|
+
if ((t || n) && e.preventDefault(), j.value = !0, K(), !t && !n) {
|
|
158
|
+
E("submit", e), G();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!await Q("submit") || !T.novalidate && !D.value.checkValidity()) {
|
|
162
|
+
e.preventDefault(), K(), D.value.reportValidity();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
let r = {
|
|
166
|
+
form: D.value,
|
|
167
|
+
event: e,
|
|
168
|
+
submitter: e.submitter,
|
|
169
|
+
data: new FormData(D.value, e.submitter || void 0),
|
|
170
|
+
model: U(),
|
|
171
|
+
errors: { ...F.value },
|
|
172
|
+
context: T.context
|
|
173
|
+
};
|
|
174
|
+
if (E("submit", e, r), !t) {
|
|
175
|
+
G(), z = !0;
|
|
176
|
+
try {
|
|
177
|
+
D.value.requestSubmit(e.submitter || void 0);
|
|
178
|
+
} finally {
|
|
179
|
+
z = !1;
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
e.preventDefault(), O.value = !0, k.value = "";
|
|
184
|
+
let i = ++R;
|
|
185
|
+
G();
|
|
186
|
+
try {
|
|
187
|
+
let t = T.handleSubmit ? await T.handleSubmit(r) : await T.submitHandler(e, r);
|
|
188
|
+
i === R && E("success", t);
|
|
189
|
+
} catch (e) {
|
|
190
|
+
i === R && (k.value = e?.message || String(e), A.value = k.value, E("error", e));
|
|
191
|
+
} finally {
|
|
192
|
+
i === R && (O.value = !1, G());
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function ne(e) {
|
|
196
|
+
E("reset", e), queueMicrotask(() => {
|
|
197
|
+
!e.defaultPrevented && D.value && (R += 1, O.value = !1, I.value = !1, k.value = "", j.value = !1, M.value = [], N.value = [], P.value = [], F.value = {}, B.clear(), V.clear(), G());
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return l(() => {
|
|
201
|
+
R += 1;
|
|
202
|
+
}), C({
|
|
203
|
+
form: D,
|
|
204
|
+
requestSubmit: () => D.value?.requestSubmit(),
|
|
205
|
+
reset: () => D.value?.reset(),
|
|
206
|
+
checkValidity: () => D.value?.checkValidity() && Object.values(F.value).every((e) => !e),
|
|
207
|
+
validate: Q,
|
|
208
|
+
validateField: Z,
|
|
209
|
+
getState: W
|
|
210
|
+
}), (e, i) => (u(), a("form", {
|
|
211
|
+
ref_key: "root",
|
|
212
|
+
ref: D,
|
|
213
|
+
class: "kima-form",
|
|
214
|
+
"aria-busy": L.value || void 0,
|
|
215
|
+
"data-dirty": !!M.value.length,
|
|
216
|
+
"data-submitted": j.value,
|
|
217
|
+
novalidate: t.novalidate,
|
|
218
|
+
onSubmit: v(te, ["stop"]),
|
|
219
|
+
onReset: v(ne, ["stop"]),
|
|
220
|
+
onInvalidCapture: ee,
|
|
221
|
+
onInputCapture: i[0] ||= (e) => $(e, "dirty"),
|
|
222
|
+
onChangeCapture: i[1] ||= (e) => $(e, "dirty"),
|
|
223
|
+
onFocusoutCapture: i[2] ||= (e) => $(e, "touched")
|
|
224
|
+
}, [
|
|
225
|
+
o("fieldset", {
|
|
226
|
+
class: "kima-form__fields",
|
|
227
|
+
disabled: t.disabled
|
|
228
|
+
}, [f(e.$slots, "default", {
|
|
229
|
+
pending: L.value,
|
|
230
|
+
error: k.value,
|
|
231
|
+
state: W()
|
|
232
|
+
}, void 0, !0)], 8, b),
|
|
233
|
+
s(r, c({ css: !1 }, m(n)), {
|
|
234
|
+
default: g(() => [_(o("div", {
|
|
235
|
+
inert: !k.value,
|
|
236
|
+
"aria-hidden": !k.value || void 0
|
|
237
|
+
}, [o("p", S, p(A.value), 1)], 8, x), [[h, k.value]])]),
|
|
238
|
+
_: 1
|
|
239
|
+
}, 16),
|
|
240
|
+
f(e.$slots, "status", {
|
|
241
|
+
pending: L.value,
|
|
242
|
+
error: k.value,
|
|
243
|
+
state: W()
|
|
244
|
+
}, void 0, !0)
|
|
245
|
+
], 40, y));
|
|
246
|
+
}
|
|
247
|
+
}, [["__scopeId", "data-v-f8f70e6f"]]);
|
|
248
|
+
export { C as default };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import e from "../../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import t from "../core/button.ce.js";
|
|
3
|
+
import { useInputAttrs as n, useInputState as r } from "../../utils/input-state.js";
|
|
4
|
+
import { useContentMotion as i } from "../../utils/content-motion.js";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { Fragment as a, computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, mergeProps as f, normalizeClass as p, normalizeStyle as m, openBlock as h, ref as g, toDisplayString as _, unref as v, watch as y, withCtx as b, withModifiers as x } from "vue";
|
|
7
|
+
// src/components/form-completion/json-input.ce.vue
|
|
8
|
+
var S = [
|
|
9
|
+
"value",
|
|
10
|
+
"name",
|
|
11
|
+
"aria-label",
|
|
12
|
+
"rows",
|
|
13
|
+
"required",
|
|
14
|
+
"disabled",
|
|
15
|
+
"readonly"
|
|
16
|
+
], C = {
|
|
17
|
+
key: 0,
|
|
18
|
+
role: "alert"
|
|
19
|
+
}, w = {
|
|
20
|
+
key: 1,
|
|
21
|
+
role: "status"
|
|
22
|
+
}, T = /*#__PURE__*/ e({
|
|
23
|
+
__name: "json-input.ce",
|
|
24
|
+
props: {
|
|
25
|
+
modelValue: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: ""
|
|
28
|
+
},
|
|
29
|
+
name: String,
|
|
30
|
+
label: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "JSON"
|
|
33
|
+
},
|
|
34
|
+
required: Boolean,
|
|
35
|
+
disabled: Boolean,
|
|
36
|
+
readonly: Boolean,
|
|
37
|
+
rows: {
|
|
38
|
+
type: Number,
|
|
39
|
+
default: 8
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
emits: [
|
|
43
|
+
"update:modelValue",
|
|
44
|
+
"change",
|
|
45
|
+
"parse"
|
|
46
|
+
],
|
|
47
|
+
setup(e, { expose: T, emit: E }) {
|
|
48
|
+
let D = e, O = E, k = g(null), A = g(null), { attrs: j, controlAttrs: M } = n(), { local: N, update: P } = r(D, O, k, (e) => String(e ?? "")), F = o(() => {
|
|
49
|
+
try {
|
|
50
|
+
return {
|
|
51
|
+
value: JSON.parse(N.value),
|
|
52
|
+
error: null
|
|
53
|
+
};
|
|
54
|
+
} catch (e) {
|
|
55
|
+
let t = /position\s+(\d+)/i.exec(e.message);
|
|
56
|
+
return {
|
|
57
|
+
value: void 0,
|
|
58
|
+
error: {
|
|
59
|
+
message: e.message,
|
|
60
|
+
position: t ? Number(t[1]) : null
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
y(F, (e) => {
|
|
66
|
+
A.value?.setCustomValidity(e.error?.message || ""), O("parse", e);
|
|
67
|
+
}, { immediate: !0 });
|
|
68
|
+
function I() {
|
|
69
|
+
F.value.error || P(JSON.stringify(F.value.value, null, 2));
|
|
70
|
+
}
|
|
71
|
+
T({
|
|
72
|
+
format: I,
|
|
73
|
+
parse: () => F.value
|
|
74
|
+
});
|
|
75
|
+
let L = g(null);
|
|
76
|
+
return i(L, () => !!F.value.error), (n, r) => (h(), c("div", {
|
|
77
|
+
ref_key: "root",
|
|
78
|
+
ref: k,
|
|
79
|
+
class: p(["kima-json-input", v(j).class]),
|
|
80
|
+
style: m(v(j).style)
|
|
81
|
+
}, [
|
|
82
|
+
l("textarea", f({
|
|
83
|
+
ref_key: "area",
|
|
84
|
+
ref: A
|
|
85
|
+
}, v(M), {
|
|
86
|
+
class: "kima-json-input__control",
|
|
87
|
+
value: v(N),
|
|
88
|
+
name: e.name,
|
|
89
|
+
"aria-label": v(M)["aria-label"] || e.label,
|
|
90
|
+
rows: e.rows,
|
|
91
|
+
required: e.required,
|
|
92
|
+
disabled: e.disabled,
|
|
93
|
+
readonly: e.readonly,
|
|
94
|
+
spellcheck: "false",
|
|
95
|
+
onInput: r[0] ||= x((e) => v(P)(e.target.value, !1), ["stop"]),
|
|
96
|
+
onChange: r[1] ||= x((e) => O("change", v(N)), ["stop"])
|
|
97
|
+
}), null, 16, S),
|
|
98
|
+
l("div", {
|
|
99
|
+
ref_key: "message",
|
|
100
|
+
ref: L,
|
|
101
|
+
class: "kima-json-input__message"
|
|
102
|
+
}, [F.value.error ? (h(), c("p", C, [u(_(F.value.error.message), 1), F.value.error.position === null ? s("", !0) : (h(), c(a, { key: 0 }, [u(" · 位置 " + _(F.value.error.position), 1)], 64))])) : (h(), c("p", w, "JSON 有效"))], 512),
|
|
103
|
+
d(t, {
|
|
104
|
+
variant: "tonal",
|
|
105
|
+
disabled: e.disabled || e.readonly || !!F.value.error,
|
|
106
|
+
onClick: I
|
|
107
|
+
}, {
|
|
108
|
+
default: b(() => [...r[2] ||= [u("格式化", -1)]]),
|
|
109
|
+
_: 1
|
|
110
|
+
}, 8, ["disabled"])
|
|
111
|
+
], 6));
|
|
112
|
+
}
|
|
113
|
+
}, [["__scopeId", "data-v-15a17728"]]);
|
|
114
|
+
export { T as default };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import e from "../../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import { useInputAttrs as t, useInputState as n } from "../../utils/input-state.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { createElementBlock as r, createElementVNode as i, mergeProps as a, normalizeClass as o, normalizeStyle as s, openBlock as c, ref as l, unref as u, withModifiers as d } from "vue";
|
|
5
|
+
// src/components/form-completion/masked-input.ce.vue
|
|
6
|
+
var f = [
|
|
7
|
+
"value",
|
|
8
|
+
"name",
|
|
9
|
+
"aria-label",
|
|
10
|
+
"placeholder",
|
|
11
|
+
"required",
|
|
12
|
+
"disabled",
|
|
13
|
+
"readonly"
|
|
14
|
+
], p = /*#__PURE__*/ e({
|
|
15
|
+
__name: "masked-input.ce",
|
|
16
|
+
props: {
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: ""
|
|
20
|
+
},
|
|
21
|
+
mask: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: ""
|
|
24
|
+
},
|
|
25
|
+
name: String,
|
|
26
|
+
label: String,
|
|
27
|
+
placeholder: String,
|
|
28
|
+
required: Boolean,
|
|
29
|
+
disabled: Boolean,
|
|
30
|
+
readonly: Boolean
|
|
31
|
+
},
|
|
32
|
+
emits: ["update:modelValue", "change"],
|
|
33
|
+
setup(e, { emit: p }) {
|
|
34
|
+
let m = e, h = p, g = l(null), _ = l(null), { attrs: v, controlAttrs: y } = t(), { local: b, update: x } = n(m, h, g, (e) => String(e || ""));
|
|
35
|
+
function S(e, t) {
|
|
36
|
+
return e === "#" ? /\d/.test(t) : e === "A" ? /[a-z]/i.test(t) : e === "*" ? /[a-z0-9]/i.test(t) : t === e;
|
|
37
|
+
}
|
|
38
|
+
function C(e, t) {
|
|
39
|
+
if (!m.mask) {
|
|
40
|
+
x(e, !1);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let n = "", r = 0, i = 0, a = m.mask;
|
|
44
|
+
for (; i < a.length && r < e.length;) {
|
|
45
|
+
let t = a[i], o = e[r++];
|
|
46
|
+
t === "#" || t === "A" || t === "*" ? S(t, o) && (n += o, i++) : o === t ? (n += t, i++) : (n += t, i++, r--);
|
|
47
|
+
}
|
|
48
|
+
x(n, !1), requestAnimationFrame(() => {
|
|
49
|
+
let e = Math.min(n.length, t);
|
|
50
|
+
_.value?.setSelectionRange(e, e);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function w(e) {
|
|
54
|
+
C(e.target.value, e.target.selectionStart || 0);
|
|
55
|
+
}
|
|
56
|
+
function T() {
|
|
57
|
+
let e = !m.mask || b.value.length === m.mask.length;
|
|
58
|
+
_.value?.setCustomValidity(e ? "" : "请完成掩码输入");
|
|
59
|
+
}
|
|
60
|
+
return (t, n) => (c(), r("div", {
|
|
61
|
+
ref_key: "root",
|
|
62
|
+
ref: g,
|
|
63
|
+
class: o(["kima-masked-input", u(v).class]),
|
|
64
|
+
style: s(u(v).style)
|
|
65
|
+
}, [i("input", a({
|
|
66
|
+
ref_key: "input",
|
|
67
|
+
ref: _
|
|
68
|
+
}, u(y), {
|
|
69
|
+
class: "kima-masked-input__control",
|
|
70
|
+
value: u(b),
|
|
71
|
+
name: e.name,
|
|
72
|
+
"aria-label": u(y)["aria-label"] || e.label,
|
|
73
|
+
placeholder: e.placeholder || e.mask,
|
|
74
|
+
required: e.required,
|
|
75
|
+
disabled: e.disabled,
|
|
76
|
+
readonly: e.readonly,
|
|
77
|
+
onInput: n[0] ||= d((e) => {
|
|
78
|
+
T();
|
|
79
|
+
}, ["stop"]),
|
|
80
|
+
onPaste: () => {},
|
|
81
|
+
onCompositionend: w,
|
|
82
|
+
onChange: n[1] ||= d((e) => {
|
|
83
|
+
T(), h("change", u(b));
|
|
84
|
+
}, ["stop"])
|
|
85
|
+
}), null, 16, f)], 6));
|
|
86
|
+
}
|
|
87
|
+
}, [["__scopeId", "data-v-f96e752a"]]);
|
|
88
|
+
export { p as default };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { useRipple as e } from "../../utils/ripple.js";
|
|
2
|
+
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
3
|
+
import { useInputState as n } from "../../utils/input-state.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { Fragment as r, computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, openBlock as c, ref as l, toDisplayString as u, unref as d, watch as f, watchEffect as p, withModifiers as m } from "vue";
|
|
6
|
+
// src/components/form-completion/period-picker.ce.vue
|
|
7
|
+
var h = ["aria-label"], g = [
|
|
8
|
+
"type",
|
|
9
|
+
"aria-label",
|
|
10
|
+
"name",
|
|
11
|
+
"value",
|
|
12
|
+
"min",
|
|
13
|
+
"max",
|
|
14
|
+
"minlength",
|
|
15
|
+
"maxlength",
|
|
16
|
+
"required",
|
|
17
|
+
"disabled"
|
|
18
|
+
], _ = [
|
|
19
|
+
"type",
|
|
20
|
+
"aria-label",
|
|
21
|
+
"name",
|
|
22
|
+
"value",
|
|
23
|
+
"min",
|
|
24
|
+
"max",
|
|
25
|
+
"minlength",
|
|
26
|
+
"maxlength",
|
|
27
|
+
"required",
|
|
28
|
+
"disabled"
|
|
29
|
+
], v = [
|
|
30
|
+
"type",
|
|
31
|
+
"aria-label",
|
|
32
|
+
"name",
|
|
33
|
+
"value",
|
|
34
|
+
"min",
|
|
35
|
+
"max",
|
|
36
|
+
"minlength",
|
|
37
|
+
"maxlength",
|
|
38
|
+
"required",
|
|
39
|
+
"disabled"
|
|
40
|
+
], y = {
|
|
41
|
+
key: 2,
|
|
42
|
+
role: "alert"
|
|
43
|
+
}, b = /*#__PURE__*/ t({
|
|
44
|
+
__name: "period-picker.ce",
|
|
45
|
+
props: {
|
|
46
|
+
modelValue: {
|
|
47
|
+
type: [String, Array],
|
|
48
|
+
default: null
|
|
49
|
+
},
|
|
50
|
+
mode: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: "month"
|
|
53
|
+
},
|
|
54
|
+
range: Boolean,
|
|
55
|
+
name: String,
|
|
56
|
+
startName: String,
|
|
57
|
+
endName: String,
|
|
58
|
+
label: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: "期间"
|
|
61
|
+
},
|
|
62
|
+
required: Boolean,
|
|
63
|
+
disabled: Boolean,
|
|
64
|
+
min: String,
|
|
65
|
+
max: String
|
|
66
|
+
},
|
|
67
|
+
emits: ["update:modelValue", "change"],
|
|
68
|
+
setup(t, { emit: b }) {
|
|
69
|
+
let x = t, S = b, C = l(null), w = l([]), T = i(() => x.mode === "year" ? /^\d{4}$/ : /^\d{4}-(0[1-9]|1[0-2])$/);
|
|
70
|
+
function E(e) {
|
|
71
|
+
return x.range ? [D(e?.[0]) ? e[0] : null, D(e?.[1]) ? e[1] : null] : D(e) ? e : null;
|
|
72
|
+
}
|
|
73
|
+
function D(e) {
|
|
74
|
+
return typeof e == "string" && T.value.test(e) ? e : null;
|
|
75
|
+
}
|
|
76
|
+
let { local: O, update: k } = n(x, S, C, E);
|
|
77
|
+
e(C), f(() => [x.mode, x.range], () => k(x.range ? [null, null] : null, !1));
|
|
78
|
+
let A = i(() => x.mode === "year" ? "number" : "month"), j = i(() => [x.startName || (x.name ? `${x.name}[start]` : void 0), x.endName || (x.name ? `${x.name}[end]` : void 0)]), M = i(() => x.range && O.value[0] && O.value[1] && O.value[0] > O.value[1] ? "结束期间不能早于开始期间" : "");
|
|
79
|
+
p(() => {
|
|
80
|
+
for (let e of w.value) e?.setCustomValidity(M.value);
|
|
81
|
+
}, { flush: "post" });
|
|
82
|
+
function N(e, t) {
|
|
83
|
+
if (!x.range) k(D(t));
|
|
84
|
+
else {
|
|
85
|
+
let n = [...O.value];
|
|
86
|
+
n[e] = D(t), k(n);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return i(() => x.mode === "year" ? Number(String(x.min || "0001").slice(0, 4)) : void 0), i(() => x.mode === "year" ? Number(String(x.max || "9999").slice(0, 4)) : void 0), (e, n) => (c(), o("div", {
|
|
90
|
+
ref_key: "root",
|
|
91
|
+
ref: C,
|
|
92
|
+
class: "kima-period-picker",
|
|
93
|
+
role: "group",
|
|
94
|
+
"aria-label": t.label
|
|
95
|
+
}, [t.range ? (c(), o(r, { key: 0 }, [
|
|
96
|
+
s("input", {
|
|
97
|
+
ref: (e) => w.value[0] = e,
|
|
98
|
+
class: "kima-period-picker__input",
|
|
99
|
+
type: A.value,
|
|
100
|
+
"aria-label": `${t.label}开始`,
|
|
101
|
+
name: d(O)[0] ? j.value[0] : void 0,
|
|
102
|
+
value: d(O)[0] || "",
|
|
103
|
+
min: t.min,
|
|
104
|
+
max: d(O)[1] || t.max,
|
|
105
|
+
minlength: t.mode === "year" ? 4 : void 0,
|
|
106
|
+
maxlength: t.mode === "year" ? 4 : void 0,
|
|
107
|
+
required: t.required,
|
|
108
|
+
disabled: t.disabled,
|
|
109
|
+
onInput: n[0] ||= m((e) => N(0, e.target.value), ["stop"]),
|
|
110
|
+
onChange: n[1] ||= m(() => {}, ["stop"])
|
|
111
|
+
}, null, 40, g),
|
|
112
|
+
n[6] ||= s("span", { "aria-hidden": "true" }, "→", -1),
|
|
113
|
+
s("input", {
|
|
114
|
+
ref: (e) => w.value[1] = e,
|
|
115
|
+
class: "kima-period-picker__input",
|
|
116
|
+
type: A.value,
|
|
117
|
+
"aria-label": `${t.label}结束`,
|
|
118
|
+
name: d(O)[1] ? j.value[1] : void 0,
|
|
119
|
+
value: d(O)[1] || "",
|
|
120
|
+
min: d(O)[0] || t.min,
|
|
121
|
+
max: t.max,
|
|
122
|
+
minlength: t.mode === "year" ? 4 : void 0,
|
|
123
|
+
maxlength: t.mode === "year" ? 4 : void 0,
|
|
124
|
+
required: t.required,
|
|
125
|
+
disabled: t.disabled,
|
|
126
|
+
onInput: n[2] ||= m((e) => N(1, e.target.value), ["stop"]),
|
|
127
|
+
onChange: n[3] ||= m(() => {}, ["stop"])
|
|
128
|
+
}, null, 40, _)
|
|
129
|
+
], 64)) : (c(), o("input", {
|
|
130
|
+
key: 1,
|
|
131
|
+
class: "kima-period-picker__input",
|
|
132
|
+
type: A.value,
|
|
133
|
+
"aria-label": t.label,
|
|
134
|
+
name: d(O) ? t.name : void 0,
|
|
135
|
+
value: d(O) || "",
|
|
136
|
+
min: t.min,
|
|
137
|
+
max: t.max,
|
|
138
|
+
minlength: t.mode === "year" ? 4 : void 0,
|
|
139
|
+
maxlength: t.mode === "year" ? 4 : void 0,
|
|
140
|
+
required: t.required,
|
|
141
|
+
disabled: t.disabled,
|
|
142
|
+
onInput: n[4] ||= m((e) => N(0, e.target.value), ["stop"]),
|
|
143
|
+
onChange: n[5] ||= m(() => {}, ["stop"])
|
|
144
|
+
}, null, 40, v)), M.value ? (c(), o("p", y, u(M.value), 1)) : a("", !0)], 8, h));
|
|
145
|
+
}
|
|
146
|
+
}, [["__scopeId", "data-v-28cc9011"]]);
|
|
147
|
+
export { b as default };
|