@guoyg578/k-ui 0.1.4 → 0.1.6
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/dist/components/KAutoComplete.vue.d.ts +2 -0
- package/dist/components/KAutoComplete.vue.js +1 -1
- package/dist/components/KAutoComplete.vue_vue_type_script_setup_true_lang.js +89 -29
- package/dist/components/KCalendar.vue.js +1 -1
- package/dist/components/KCalendar.vue_vue_type_script_setup_true_lang.js +132 -39
- package/dist/components/KCascader.vue.d.ts +2 -0
- package/dist/components/KCascader.vue.js +1 -1
- package/dist/components/KCascader.vue_vue_type_script_setup_true_lang.js +45 -43
- package/dist/components/KCheckbox.vue.d.ts +6 -2
- package/dist/components/KCheckbox.vue.js +1 -1
- package/dist/components/KCheckbox.vue_vue_type_script_setup_true_lang.js +38 -18
- package/dist/components/KCheckboxGroup.vue.d.ts +2 -0
- package/dist/components/KCheckboxGroup.vue.js +1 -1
- package/dist/components/KCheckboxGroup.vue_vue_type_script_setup_true_lang.js +23 -15
- package/dist/components/KCollapse.vue.d.ts +3 -1
- package/dist/components/KCollapse.vue.js +1 -1
- package/dist/components/KCollapse.vue_vue_type_script_setup_true_lang.js +27 -16
- package/dist/components/KCombobox.vue.js +1 -1
- package/dist/components/KCombobox.vue_vue_type_script_setup_true_lang.js +48 -47
- package/dist/components/KDataTable.vue.d.ts +48 -1
- package/dist/components/KDataTable.vue.js +1 -1
- package/dist/components/KDataTable.vue_vue_type_script_setup_true_lang.js +305 -74
- package/dist/components/KDatePicker.vue.d.ts +8 -0
- package/dist/components/KDatePicker.vue_vue_type_script_setup_true_lang.js +32 -22
- package/dist/components/KDialog.vue.d.ts +4 -4
- package/dist/components/KDialog.vue.js +1 -1
- package/dist/components/KDialog.vue_vue_type_script_setup_true_lang.js +83 -73
- package/dist/components/KDrawer.vue.js +1 -1
- package/dist/components/KDrawer.vue_vue_type_script_setup_true_lang.js +36 -35
- package/dist/components/KDropdown.vue.d.ts +4 -3
- package/dist/components/KDropdown.vue_vue_type_script_setup_true_lang.js +48 -30
- package/dist/components/KDynamicInput.vue.d.ts +2 -0
- package/dist/components/KDynamicInput.vue.js +1 -1
- package/dist/components/KDynamicInput.vue_vue_type_script_setup_true_lang.js +17 -6
- package/dist/components/KDynamicTags.vue.d.ts +2 -0
- package/dist/components/KDynamicTags.vue.js +1 -1
- package/dist/components/KDynamicTags.vue_vue_type_script_setup_true_lang.js +11 -10
- package/dist/components/KForm.vue.d.ts +12 -0
- package/dist/components/KForm.vue.js +1 -1
- package/dist/components/KForm.vue_vue_type_script_setup_true_lang.js +26 -4
- package/dist/components/KFormField.vue.d.ts +3 -1
- package/dist/components/KFormField.vue.js +1 -1
- package/dist/components/KFormField.vue_vue_type_script_setup_true_lang.js +124 -61
- package/dist/components/KInputNumber.vue.js +1 -1
- package/dist/components/KInputNumber.vue_vue_type_script_setup_true_lang.js +35 -29
- package/dist/components/KMention.vue.d.ts +2 -0
- package/dist/components/KMention.vue.js +1 -1
- package/dist/components/KMention.vue_vue_type_script_setup_true_lang.js +34 -33
- package/dist/components/KMenu.vue.js +1 -1
- package/dist/components/KMenu.vue_vue_type_script_setup_true_lang.js +132 -51
- package/dist/components/KMenuItem.vue.js +1 -1
- package/dist/components/KMenuItem.vue_vue_type_script_setup_true_lang.js +21 -6
- package/dist/components/KMessage.d.ts +5 -0
- package/dist/components/KMessage.js +36 -23
- package/dist/components/KNotification.d.ts +8 -0
- package/dist/components/KNotification.js +45 -29
- package/dist/components/KNotificationProvider.vue.js +3 -8
- package/dist/components/KNotificationProvider.vue_vue_type_script_setup_true_lang.js +11 -0
- package/dist/components/KPagination.vue.d.ts +4 -1
- package/dist/components/KPagination.vue.js +1 -1
- package/dist/components/KPagination.vue_vue_type_script_setup_true_lang.js +36 -33
- package/dist/components/KPopover.vue_vue_type_script_setup_true_lang.js +15 -14
- package/dist/components/KRadio.vue.d.ts +1 -0
- package/dist/components/KRadio.vue.js +1 -1
- package/dist/components/KRadio.vue_vue_type_script_setup_true_lang.js +22 -14
- package/dist/components/KRadioGroup.vue.d.ts +4 -2
- package/dist/components/KRadioGroup.vue.js +1 -1
- package/dist/components/KRadioGroup.vue_vue_type_script_setup_true_lang.js +16 -4
- package/dist/components/KRate.vue.d.ts +5 -0
- package/dist/components/KRate.vue.js +1 -1
- package/dist/components/KRate.vue_vue_type_script_setup_true_lang.js +72 -24
- package/dist/components/KSelect.vue.d.ts +2 -2
- package/dist/components/KSelect.vue.js +1 -1
- package/dist/components/KSelect.vue_vue_type_script_setup_true_lang.js +60 -59
- package/dist/components/KSlider.vue.d.ts +2 -0
- package/dist/components/KSlider.vue.js +1 -1
- package/dist/components/KSlider.vue_vue_type_script_setup_true_lang.js +17 -16
- package/dist/components/KTextarea.vue.d.ts +2 -0
- package/dist/components/KTextarea.vue.js +1 -1
- package/dist/components/KTextarea.vue_vue_type_script_setup_true_lang.js +10 -9
- package/dist/components/KTimePicker.vue.d.ts +2 -0
- package/dist/components/KTimePicker.vue.js +1 -1
- package/dist/components/KTimePicker.vue_vue_type_script_setup_true_lang.js +63 -49
- package/dist/components/KTooltip.vue_vue_type_script_setup_true_lang.js +13 -12
- package/dist/components/KTransfer.vue.d.ts +2 -0
- package/dist/components/KTransfer.vue.js +1 -1
- package/dist/components/KTransfer.vue_vue_type_script_setup_true_lang.js +35 -34
- package/dist/components/KTreeSelect.vue.d.ts +2 -0
- package/dist/components/KTreeSelect.vue.js +1 -1
- package/dist/components/KTreeSelect.vue_vue_type_script_setup_true_lang.js +20 -18
- package/dist/components/KUpload.vue.d.ts +14 -0
- package/dist/components/KUpload.vue.js +1 -1
- package/dist/components/KUpload.vue_vue_type_script_setup_true_lang.js +159 -117
- package/dist/components/checkbox-context.d.ts +10 -0
- package/dist/components/checkbox-context.js +4 -0
- package/dist/components/form-context.d.ts +19 -2
- package/dist/components/form-context.js +31 -1
- package/dist/components/menu-context.d.ts +4 -0
- package/dist/components/radio-context.d.ts +6 -1
- package/dist/k-ui.css +1 -1
- package/dist/styles/tokens.css +40 -1
- package/package.json +1 -1
|
@@ -8,12 +8,20 @@ type __VLS_Props = {
|
|
|
8
8
|
requireMarkPlacement?: string;
|
|
9
9
|
size?: 'small' | 'sm' | 'medium' | 'md' | 'large' | 'lg';
|
|
10
10
|
disabled?: boolean;
|
|
11
|
+
/** rules 变化时自动重校已校验过的字段 */
|
|
12
|
+
validateOnRuleChange?: boolean;
|
|
13
|
+
/** 提交校验失败时自动滚动到第一个错误字段 */
|
|
14
|
+
scrollToError?: boolean;
|
|
11
15
|
};
|
|
12
16
|
declare function validate(): Promise<boolean>;
|
|
13
17
|
declare function validateField(name: string): Promise<boolean>;
|
|
14
18
|
declare function resetFields(): void;
|
|
15
19
|
declare function clearValidate(): void;
|
|
16
20
|
declare function restoreValidation(): void;
|
|
21
|
+
/** 滚动到指定字段 */
|
|
22
|
+
declare function scrollToField(name: string): void;
|
|
23
|
+
/** 滚动到第一个有错误的字段 (按注册/挂载顺序) */
|
|
24
|
+
declare function scrollToFirstError(): void;
|
|
17
25
|
declare var __VLS_1: {};
|
|
18
26
|
type __VLS_Slots = {} & {
|
|
19
27
|
default?: (props: typeof __VLS_1) => any;
|
|
@@ -24,6 +32,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
24
32
|
resetFields: typeof resetFields;
|
|
25
33
|
clearValidate: typeof clearValidate;
|
|
26
34
|
restoreValidation: typeof restoreValidation;
|
|
35
|
+
scrollToField: typeof scrollToField;
|
|
36
|
+
scrollToFirstError: typeof scrollToFirstError;
|
|
27
37
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
28
38
|
submit: (ev: Event) => any;
|
|
29
39
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
@@ -33,6 +43,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
33
43
|
disabled: boolean;
|
|
34
44
|
labelWidth: string | number;
|
|
35
45
|
labelPosition: "top" | "left";
|
|
46
|
+
validateOnRuleChange: boolean;
|
|
47
|
+
scrollToError: boolean;
|
|
36
48
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
37
49
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
38
50
|
declare const _default: typeof __VLS_export;
|
|
@@ -2,6 +2,6 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
|
|
|
2
2
|
import t from "./KForm.vue_vue_type_script_setup_true_lang.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region components/KForm.vue
|
|
5
|
-
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-
|
|
5
|
+
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-f18a487d"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { n as default };
|
|
@@ -14,6 +14,14 @@ var s = /* @__PURE__ */ n({
|
|
|
14
14
|
disabled: {
|
|
15
15
|
type: Boolean,
|
|
16
16
|
default: !1
|
|
17
|
+
},
|
|
18
|
+
validateOnRuleChange: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: !0
|
|
21
|
+
},
|
|
22
|
+
scrollToError: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: !0
|
|
17
25
|
}
|
|
18
26
|
},
|
|
19
27
|
emits: ["submit"],
|
|
@@ -47,6 +55,9 @@ var s = /* @__PURE__ */ n({
|
|
|
47
55
|
get disabled() {
|
|
48
56
|
return l.disabled;
|
|
49
57
|
},
|
|
58
|
+
get validateOnRuleChange() {
|
|
59
|
+
return l.validateOnRuleChange;
|
|
60
|
+
},
|
|
50
61
|
registerField: f,
|
|
51
62
|
unregisterField: p
|
|
52
63
|
});
|
|
@@ -66,18 +77,29 @@ var s = /* @__PURE__ */ n({
|
|
|
66
77
|
function y() {
|
|
67
78
|
v();
|
|
68
79
|
}
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
function b(e) {
|
|
81
|
+
d.get(e)?.scrollIntoView();
|
|
82
|
+
}
|
|
83
|
+
function x() {
|
|
84
|
+
for (let e of d.values()) if (e.hasError()) {
|
|
85
|
+
e.scrollIntoView();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function S(e) {
|
|
90
|
+
e.preventDefault(), await h() ? u("submit", e) : l.scrollToError && x();
|
|
71
91
|
}
|
|
72
92
|
return s({
|
|
73
93
|
validate: h,
|
|
74
94
|
validateField: g,
|
|
75
95
|
resetFields: _,
|
|
76
96
|
clearValidate: v,
|
|
77
|
-
restoreValidation: y
|
|
97
|
+
restoreValidation: y,
|
|
98
|
+
scrollToField: b,
|
|
99
|
+
scrollToFirstError: x
|
|
78
100
|
}), (e, n) => (r(), t("form", {
|
|
79
101
|
class: "k-form",
|
|
80
|
-
onSubmit:
|
|
102
|
+
onSubmit: S
|
|
81
103
|
}, [o(e.$slots, "default", {}, void 0, !0)], 32));
|
|
82
104
|
}
|
|
83
105
|
});
|
|
@@ -7,13 +7,15 @@ type __VLS_Props = {
|
|
|
7
7
|
required?: boolean;
|
|
8
8
|
hint?: string;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
/** trigger 省略 = 全量(所有规则); 传 'blur'/'change' = 只跑匹配该时机的规则 */
|
|
11
|
+
declare function validate(trigger?: string): Promise<boolean>;
|
|
11
12
|
declare function reset(): void;
|
|
12
13
|
declare function clearValidate(): void;
|
|
13
14
|
declare var __VLS_1: {
|
|
14
15
|
error: boolean;
|
|
15
16
|
validate: typeof validate;
|
|
16
17
|
disabled: boolean;
|
|
18
|
+
size: "sm" | "md" | "lg";
|
|
17
19
|
};
|
|
18
20
|
type __VLS_Slots = {} & {
|
|
19
21
|
default?: (props: typeof __VLS_1) => any;
|
|
@@ -2,6 +2,6 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
|
|
|
2
2
|
import t from "./KFormField.vue_vue_type_script_setup_true_lang.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region components/KFormField.vue
|
|
5
|
-
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-
|
|
5
|
+
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-e5f8f061"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { n as default };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { computed as
|
|
1
|
+
import { cloneValue as e, formContextKey as t, getByPath as n, setByPath as r } from "./form-context.js";
|
|
2
|
+
import { computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, defineComponent as l, inject as u, normalizeClass as d, normalizeStyle as f, onBeforeUnmount as p, onMounted as m, openBlock as h, ref as g, renderSlot as _, toDisplayString as v, unref as y, watch as b } from "vue";
|
|
3
3
|
//#region components/KFormField.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
-
var
|
|
4
|
+
var x = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "k-field__required"
|
|
7
|
-
},
|
|
7
|
+
}, S = {
|
|
8
8
|
key: 0,
|
|
9
9
|
class: "k-field__hint"
|
|
10
|
-
},
|
|
10
|
+
}, C = {
|
|
11
11
|
key: 1,
|
|
12
12
|
class: "k-field__error"
|
|
13
|
-
},
|
|
13
|
+
}, w = /* @__PURE__ */ l({
|
|
14
14
|
__name: "KFormField",
|
|
15
15
|
props: {
|
|
16
16
|
name: {},
|
|
@@ -20,78 +20,141 @@ var _ = {
|
|
|
20
20
|
required: { type: Boolean },
|
|
21
21
|
hint: {}
|
|
22
22
|
},
|
|
23
|
-
setup(
|
|
24
|
-
let
|
|
25
|
-
if (!
|
|
26
|
-
let
|
|
27
|
-
let e =
|
|
28
|
-
return
|
|
29
|
-
}),
|
|
30
|
-
function
|
|
23
|
+
setup(l, { expose: w }) {
|
|
24
|
+
let T = l, E = u(t);
|
|
25
|
+
if (!E) throw Error("KFormField 必须放在 <KForm> 内");
|
|
26
|
+
let D = g(), O = g(), k = g(""), A = g(!1), j = g(void 0), M = i(() => T.name ?? T.path ?? ""), N = i(() => {
|
|
27
|
+
let e = T.rules ?? E.rules?.[M.value] ?? [], t = Array.isArray(e) ? [...e] : [e];
|
|
28
|
+
return T.required && !t.some((e) => e.required) && t.unshift({ required: !0 }), t.filter(Boolean);
|
|
29
|
+
}), P = i(() => T.required || N.value.some((e) => e.required));
|
|
30
|
+
function F(e) {
|
|
31
31
|
return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
let I = {
|
|
34
|
+
email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
35
|
+
url: /^(https?:\/\/|\/\/)?[\w-]+(\.[\w-]+)+([/?#].*)?$/i
|
|
36
|
+
};
|
|
37
|
+
function L(e, t) {
|
|
38
|
+
let n = e.type;
|
|
39
|
+
if (!n || n === "string" || F(t)) return null;
|
|
40
|
+
if (n === "number" || n === "integer") {
|
|
41
|
+
if (typeof t != "number" || Number.isNaN(t)) return e.message ?? "必须是数字";
|
|
42
|
+
if (n === "integer" && !Number.isInteger(t)) return e.message ?? "必须是整数";
|
|
43
|
+
} else if (n === "array") {
|
|
44
|
+
if (!Array.isArray(t)) return e.message ?? "必须是数组";
|
|
45
|
+
} else if (n === "boolean") {
|
|
46
|
+
if (typeof t != "boolean") return e.message ?? "必须是布尔值";
|
|
47
|
+
} else if (I[n] && !I[n].test(String(t))) return e.message ?? (n === "email" ? "邮箱格式不正确" : "URL 格式不正确");
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
function R(e, t) {
|
|
51
|
+
if (F(t)) return null;
|
|
52
|
+
if (e.type === "number" || e.type === "integer") {
|
|
53
|
+
let n = Number(t);
|
|
54
|
+
if (e.len !== void 0 && n !== e.len) return e.message ?? `必须等于 ${e.len}`;
|
|
55
|
+
if (e.min !== void 0 && n < e.min) return e.message ?? `不能小于 ${e.min}`;
|
|
56
|
+
if (e.max !== void 0 && n > e.max) return e.message ?? `不能大于 ${e.max}`;
|
|
57
|
+
} else if (typeof t == "string" || Array.isArray(t)) {
|
|
58
|
+
if (e.len !== void 0 && t.length !== e.len) return e.message ?? `长度必须为 ${e.len}`;
|
|
59
|
+
if (e.min !== void 0 && t.length < e.min) return e.message ?? `至少 ${e.min} 个字符`;
|
|
60
|
+
if (e.max !== void 0 && t.length > e.max) return e.message ?? `最多 ${e.max} 个字符`;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
function z(e, t) {
|
|
65
|
+
return e.trigger ? (Array.isArray(e.trigger) ? e.trigger : [e.trigger]).includes(t) : !0;
|
|
66
|
+
}
|
|
67
|
+
async function B(e) {
|
|
68
|
+
let t = n(E.model, M.value), r = e ? N.value.filter((t) => z(t, e)) : N.value;
|
|
69
|
+
if (e && r.length === 0) return !k.value;
|
|
70
|
+
for (let e of r) {
|
|
71
|
+
if (e.validator) {
|
|
37
72
|
try {
|
|
38
|
-
let n = await (
|
|
39
|
-
if (n === !1) return
|
|
40
|
-
if (typeof n == "string") return
|
|
41
|
-
if (n instanceof Error) return
|
|
42
|
-
} catch (
|
|
43
|
-
return
|
|
73
|
+
let n = await (e.validator.length >= 2 ? e.validator(e, t) : e.validator(t));
|
|
74
|
+
if (n === !1) return k.value = e.message ?? "校验失败", !1;
|
|
75
|
+
if (typeof n == "string") return k.value = n, !1;
|
|
76
|
+
if (n instanceof Error) return k.value = n.message || e.message || "校验失败", !1;
|
|
77
|
+
} catch (t) {
|
|
78
|
+
return k.value = t?.message || e.message || "校验失败", !1;
|
|
44
79
|
}
|
|
45
80
|
continue;
|
|
46
81
|
}
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
82
|
+
if (e.required && F(t)) return k.value = e.message ?? `${T.label || M.value} 必填`, !1;
|
|
83
|
+
let n = L(e, t);
|
|
84
|
+
if (n) return k.value = n, !1;
|
|
85
|
+
let r = R(e, t);
|
|
86
|
+
if (r) return k.value = r, !1;
|
|
87
|
+
if (e.pattern && !F(t) && !e.pattern.test(String(t))) return k.value = e.message ?? "格式不正确", !1;
|
|
54
88
|
}
|
|
55
|
-
return
|
|
89
|
+
return k.value = "", !0;
|
|
56
90
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
91
|
+
function V(e) {
|
|
92
|
+
let t = e.relatedTarget;
|
|
93
|
+
t && O.value?.contains(t) || (A.value = !0, B("blur"));
|
|
94
|
+
}
|
|
95
|
+
b(() => n(E.model, M.value), () => {
|
|
96
|
+
A.value && B("change");
|
|
97
|
+
}, { deep: !0 }), b(N, () => {
|
|
98
|
+
E.validateOnRuleChange && A.value && k.value && B();
|
|
99
|
+
});
|
|
100
|
+
function H() {
|
|
101
|
+
M.value && r(E.model, M.value, e(j.value)), k.value = "", A.value = !1;
|
|
59
102
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
103
|
+
function U() {
|
|
104
|
+
k.value = "";
|
|
62
105
|
}
|
|
63
|
-
let
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
106
|
+
let W = {
|
|
107
|
+
get name() {
|
|
108
|
+
return M.value;
|
|
109
|
+
},
|
|
110
|
+
validate: (e) => (e || (A.value = !0), B(e)),
|
|
111
|
+
reset: H,
|
|
112
|
+
clearValidate: U,
|
|
113
|
+
hasError: () => !!k.value,
|
|
114
|
+
scrollIntoView: () => D.value?.scrollIntoView({
|
|
115
|
+
behavior: "smooth",
|
|
116
|
+
block: "center"
|
|
117
|
+
})
|
|
67
118
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}),
|
|
71
|
-
|
|
119
|
+
m(() => {
|
|
120
|
+
M.value && (j.value = e(n(E.model, M.value)), E.registerField(M.value, W));
|
|
121
|
+
}), b(M, (t, r) => {
|
|
122
|
+
r && E.unregisterField(r), t && (j.value = e(n(E.model, t)), E.registerField(t, W));
|
|
123
|
+
}), p(() => {
|
|
124
|
+
M.value && E.unregisterField(M.value);
|
|
72
125
|
});
|
|
73
|
-
let
|
|
74
|
-
width:
|
|
126
|
+
let G = i(() => E.labelPosition === "left" ? {
|
|
127
|
+
width: E.labelWidth,
|
|
75
128
|
textAlign: "right"
|
|
76
129
|
} : {});
|
|
77
|
-
return
|
|
78
|
-
validate:
|
|
79
|
-
reset:
|
|
80
|
-
clearValidate:
|
|
81
|
-
}), (e, t) => (
|
|
130
|
+
return w({
|
|
131
|
+
validate: B,
|
|
132
|
+
reset: H,
|
|
133
|
+
clearValidate: U
|
|
134
|
+
}), (e, t) => (h(), o("div", {
|
|
135
|
+
ref_key: "root",
|
|
136
|
+
ref: D,
|
|
137
|
+
class: d(["k-field", `k-field--${y(E).labelPosition}`])
|
|
138
|
+
}, [l.label ? (h(), o("label", {
|
|
82
139
|
key: 0,
|
|
83
140
|
class: "k-field__label",
|
|
84
|
-
style:
|
|
85
|
-
}, [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
141
|
+
style: f(G.value)
|
|
142
|
+
}, [P.value ? (h(), o("span", x, "*")) : a("", !0), c(" " + v(l.label), 1)], 4)) : a("", !0), s("div", {
|
|
143
|
+
ref_key: "control",
|
|
144
|
+
ref: O,
|
|
145
|
+
class: "k-field__control",
|
|
146
|
+
onFocusout: V
|
|
147
|
+
}, [
|
|
148
|
+
_(e.$slots, "default", {
|
|
149
|
+
error: !!k.value,
|
|
150
|
+
validate: B,
|
|
151
|
+
disabled: y(E).disabled,
|
|
152
|
+
size: y(E).size
|
|
90
153
|
}, void 0, !0),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
])], 2));
|
|
154
|
+
l.hint && !k.value ? (h(), o("p", S, v(l.hint), 1)) : a("", !0),
|
|
155
|
+
k.value ? (h(), o("p", C, v(k.value), 1)) : a("", !0)
|
|
156
|
+
], 544)], 2));
|
|
94
157
|
}
|
|
95
158
|
});
|
|
96
159
|
//#endregion
|
|
97
|
-
export {
|
|
160
|
+
export { w as default };
|
|
@@ -2,6 +2,6 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
|
|
|
2
2
|
import t from "./KInputNumber.vue_vue_type_script_setup_true_lang.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region components/KInputNumber.vue
|
|
5
|
-
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-
|
|
5
|
+
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-44b2fe3d"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { n as default };
|
|
@@ -52,22 +52,28 @@ var m = {
|
|
|
52
52
|
}
|
|
53
53
|
return e;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let t =
|
|
58
|
-
|
|
55
|
+
function w(e) {
|
|
56
|
+
if (!Number.isFinite(e)) return 0;
|
|
57
|
+
let [t, n] = e.toExponential().split("e"), r = parseInt(n, 10), i = (t.split(".")[1] ?? "").length;
|
|
58
|
+
return Math.max(0, i - r);
|
|
59
59
|
}
|
|
60
|
-
let
|
|
61
|
-
function
|
|
62
|
-
x.disabled || x.readonly
|
|
63
|
-
|
|
60
|
+
let T = e(() => x.disabled || x.readonly || x.max !== void 0 && (x.modelValue ?? 0) >= x.max), E = e(() => x.disabled || x.readonly || x.min !== void 0 && (x.modelValue ?? 0) <= x.min);
|
|
61
|
+
function D(e) {
|
|
62
|
+
if (x.disabled || x.readonly) return;
|
|
63
|
+
let t = x.modelValue ?? x.min ?? 0, n = 10 ** (x.precision ?? w(x.step)), r = C(Math.round((t + e * x.step) * n) / n);
|
|
64
|
+
S("update:modelValue", r), S("change", r);
|
|
65
|
+
}
|
|
66
|
+
let O = null, k = null;
|
|
67
|
+
function A(e) {
|
|
68
|
+
x.disabled || x.readonly || (D(e), O = window.setTimeout(() => {
|
|
69
|
+
k = window.setInterval(() => D(e), 60);
|
|
64
70
|
}, 400));
|
|
65
71
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
72
|
+
function j() {
|
|
73
|
+
O &&= (clearTimeout(O), null), k &&= (clearInterval(k), null);
|
|
68
74
|
}
|
|
69
|
-
s(
|
|
70
|
-
function
|
|
75
|
+
s(j);
|
|
76
|
+
function M(e) {
|
|
71
77
|
let t = e.target.value;
|
|
72
78
|
if (t === "" || t === "-") {
|
|
73
79
|
S("update:modelValue", null);
|
|
@@ -76,16 +82,16 @@ var m = {
|
|
|
76
82
|
let n = Number(t);
|
|
77
83
|
Number.isNaN(n) || S("update:modelValue", n);
|
|
78
84
|
}
|
|
79
|
-
function
|
|
85
|
+
function N() {
|
|
80
86
|
if (x.modelValue === null || x.modelValue === void 0) return;
|
|
81
87
|
let e = C(x.modelValue);
|
|
82
88
|
e !== x.modelValue && (S("update:modelValue", e), S("change", e));
|
|
83
89
|
}
|
|
84
|
-
function
|
|
85
|
-
x.disabled || x.readonly || (e.key === "ArrowUp" ? (e.preventDefault(),
|
|
90
|
+
function P(e) {
|
|
91
|
+
x.disabled || x.readonly || (e.key === "ArrowUp" ? (e.preventDefault(), D(1)) : e.key === "ArrowDown" && (e.preventDefault(), D(-1)));
|
|
86
92
|
}
|
|
87
|
-
let
|
|
88
|
-
return (e, s) => (c(), n("div", { class: o(["k-num", [`k-num--${
|
|
93
|
+
let F = e(() => x.modelValue === null || x.modelValue === void 0 ? "" : String(x.modelValue)), I = e(() => x.size === "tiny" || x.size === "xs" || x.size === "small" || x.size === "sm" ? "sm" : x.size === "large" || x.size === "lg" ? "lg" : "md");
|
|
94
|
+
return (e, s) => (c(), n("div", { class: o(["k-num", [`k-num--${I.value}`, {
|
|
89
95
|
"k-num--error": a.error,
|
|
90
96
|
"k-num--disabled": a.disabled
|
|
91
97
|
}]]) }, [
|
|
@@ -93,32 +99,32 @@ var m = {
|
|
|
93
99
|
r("input", {
|
|
94
100
|
type: "text",
|
|
95
101
|
inputmode: "decimal",
|
|
96
|
-
value:
|
|
102
|
+
value: F.value,
|
|
97
103
|
disabled: a.disabled,
|
|
98
104
|
readonly: a.readonly,
|
|
99
105
|
placeholder: a.placeholder,
|
|
100
106
|
class: "k-num__inner",
|
|
101
|
-
onInput:
|
|
102
|
-
onBlur:
|
|
103
|
-
onKeydown:
|
|
107
|
+
onInput: M,
|
|
108
|
+
onBlur: N,
|
|
109
|
+
onKeydown: P
|
|
104
110
|
}, null, 40, h),
|
|
105
111
|
e.$slots.suffix ? (c(), n("span", g, [l(e.$slots, "suffix", {}, void 0, !0)])) : t("", !0),
|
|
106
112
|
a.showButton ? (c(), n("div", _, [r("button", {
|
|
107
113
|
type: "button",
|
|
108
114
|
tabindex: "-1",
|
|
109
115
|
class: "k-num__step k-num__step--up",
|
|
110
|
-
disabled:
|
|
111
|
-
onMousedown: s[0] ||= d((e) =>
|
|
112
|
-
onMouseup:
|
|
113
|
-
onMouseleave:
|
|
116
|
+
disabled: T.value,
|
|
117
|
+
onMousedown: s[0] ||= d((e) => A(1), ["prevent"]),
|
|
118
|
+
onMouseup: j,
|
|
119
|
+
onMouseleave: j
|
|
114
120
|
}, [i(u(p), { size: 11 })], 40, v), r("button", {
|
|
115
121
|
type: "button",
|
|
116
122
|
tabindex: "-1",
|
|
117
123
|
class: "k-num__step k-num__step--down",
|
|
118
|
-
disabled:
|
|
119
|
-
onMousedown: s[1] ||= d((e) =>
|
|
120
|
-
onMouseup:
|
|
121
|
-
onMouseleave:
|
|
124
|
+
disabled: E.value,
|
|
125
|
+
onMousedown: s[1] ||= d((e) => A(-1), ["prevent"]),
|
|
126
|
+
onMouseup: j,
|
|
127
|
+
onMouseleave: j
|
|
122
128
|
}, [i(u(f), { size: 11 })], 40, y)])) : t("", !0)
|
|
123
129
|
], 2));
|
|
124
130
|
}
|
|
@@ -7,6 +7,7 @@ type __VLS_Props = {
|
|
|
7
7
|
options?: MentionOption[];
|
|
8
8
|
prefix?: string;
|
|
9
9
|
placeholder?: string;
|
|
10
|
+
size?: 'tiny' | 'xs' | 'small' | 'sm' | 'medium' | 'md' | 'large' | 'lg';
|
|
10
11
|
rows?: number;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
};
|
|
@@ -17,6 +18,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
17
18
|
"onUpdate:modelValue"?: ((v: string) => any) | undefined;
|
|
18
19
|
onMention?: ((o: MentionOption) => any) | undefined;
|
|
19
20
|
}>, {
|
|
21
|
+
size: "tiny" | "xs" | "small" | "sm" | "medium" | "md" | "large" | "lg";
|
|
20
22
|
disabled: boolean;
|
|
21
23
|
modelValue: string;
|
|
22
24
|
prefix: string;
|
|
@@ -3,6 +3,6 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
|
|
|
3
3
|
import t from "./KMention.vue_vue_type_script_setup_true_lang.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
//#region components/KMention.vue
|
|
6
|
-
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-
|
|
6
|
+
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-97f07a69"]]);
|
|
7
7
|
//#endregion
|
|
8
8
|
export { n as default };
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, nextTick as o,
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, nextTick as o, normalizeClass as s, openBlock as c, ref as l, renderList as u, toDisplayString as d, withModifiers as f } from "vue";
|
|
2
2
|
//#region components/KMention.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
-
var
|
|
3
|
+
var p = { class: "k-mention" }, m = [
|
|
4
4
|
"value",
|
|
5
5
|
"rows",
|
|
6
6
|
"placeholder",
|
|
7
7
|
"disabled"
|
|
8
|
-
],
|
|
8
|
+
], h = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "k-mention__list k-menu-surface"
|
|
11
|
-
},
|
|
11
|
+
}, g = ["onMousedown"], _ = /* @__PURE__ */ a({
|
|
12
12
|
__name: "KMention",
|
|
13
13
|
props: {
|
|
14
14
|
modelValue: { default: "" },
|
|
15
15
|
options: { default: () => [] },
|
|
16
16
|
prefix: { default: "@" },
|
|
17
17
|
placeholder: {},
|
|
18
|
+
size: { default: "md" },
|
|
18
19
|
rows: { default: 3 },
|
|
19
20
|
disabled: {
|
|
20
21
|
type: Boolean,
|
|
@@ -22,52 +23,52 @@ var f = { class: "k-mention" }, p = [
|
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
emits: ["update:modelValue", "mention"],
|
|
25
|
-
setup(a, { emit:
|
|
26
|
-
let
|
|
27
|
-
function
|
|
28
|
-
let t = e.selectionStart ?? 0, n = e.value.slice(0, t), r =
|
|
29
|
-
i ? (
|
|
26
|
+
setup(a, { emit: _ }) {
|
|
27
|
+
let v = a, y = _, b = l(null), x = l(!1), S = l(""), C = -1, w = t(() => v.size === "tiny" || v.size === "xs" || v.size === "small" || v.size === "sm" ? "sm" : v.size === "large" || v.size === "lg" ? "lg" : "md");
|
|
28
|
+
function T(e) {
|
|
29
|
+
let t = e.selectionStart ?? 0, n = e.value.slice(0, t), r = v.prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.match(RegExp(`(?:^|\\s)${r}([^\\s${r}]*)$`));
|
|
30
|
+
i ? (S.value = i[1], C = t - i[1].length - v.prefix.length, x.value = !0) : x.value = !1;
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function E(e) {
|
|
32
33
|
let t = e.target;
|
|
33
|
-
|
|
34
|
+
y("update:modelValue", t.value), T(t);
|
|
34
35
|
}
|
|
35
|
-
let
|
|
36
|
-
let e =
|
|
37
|
-
return (
|
|
36
|
+
let D = t(() => {
|
|
37
|
+
let e = S.value.toLowerCase();
|
|
38
|
+
return (v.options ?? []).filter((t) => t.label.toLowerCase().includes(e));
|
|
38
39
|
});
|
|
39
|
-
async function
|
|
40
|
-
let t =
|
|
40
|
+
async function O(e) {
|
|
41
|
+
let t = b.value;
|
|
41
42
|
if (!t) return;
|
|
42
|
-
let n = t.selectionStart ?? 0, r =
|
|
43
|
-
|
|
44
|
-
let a =
|
|
43
|
+
let n = t.selectionStart ?? 0, r = v.modelValue ?? "", i = `${v.prefix}${e.label} `;
|
|
44
|
+
y("update:modelValue", r.slice(0, C) + i + r.slice(n)), y("mention", e), x.value = !1, await o(), t.focus();
|
|
45
|
+
let a = C + i.length;
|
|
45
46
|
t.setSelectionRange(a, a);
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
48
|
+
function k(e) {
|
|
49
|
+
x.value && e.key === "Enter" && D.value.length ? (e.preventDefault(), O(D.value[0])) : e.key === "Escape" && (x.value = !1);
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
setTimeout(() =>
|
|
51
|
+
function A() {
|
|
52
|
+
setTimeout(() => x.value = !1, 120);
|
|
52
53
|
}
|
|
53
|
-
return (t, o) => (
|
|
54
|
+
return (t, o) => (c(), r("div", p, [i("textarea", {
|
|
54
55
|
ref_key: "ta",
|
|
55
|
-
ref:
|
|
56
|
-
class: "k-mention__input",
|
|
56
|
+
ref: b,
|
|
57
|
+
class: s(["k-mention__input", `k-mention__input--${w.value}`]),
|
|
57
58
|
value: a.modelValue,
|
|
58
59
|
rows: a.rows,
|
|
59
60
|
placeholder: a.placeholder,
|
|
60
61
|
disabled: a.disabled,
|
|
61
|
-
onInput:
|
|
62
|
-
onKeydown:
|
|
63
|
-
onBlur:
|
|
64
|
-
}, null,
|
|
62
|
+
onInput: E,
|
|
63
|
+
onKeydown: k,
|
|
64
|
+
onBlur: A
|
|
65
|
+
}, null, 42, m), x.value && D.value.length ? (c(), r("div", h, [(c(!0), r(e, null, u(D.value, (e) => (c(), r("button", {
|
|
65
66
|
key: e.value ?? e.label,
|
|
66
67
|
type: "button",
|
|
67
68
|
class: "k-mention__item",
|
|
68
|
-
onMousedown:
|
|
69
|
-
},
|
|
69
|
+
onMousedown: f((t) => O(e), ["prevent"])
|
|
70
|
+
}, d(e.label), 41, g))), 128))])) : n("", !0)]));
|
|
70
71
|
}
|
|
71
72
|
});
|
|
72
73
|
//#endregion
|
|
73
|
-
export {
|
|
74
|
+
export { _ as default };
|
|
@@ -4,6 +4,6 @@ import t from "./KMenu.vue_vue_type_script_setup_true_lang.js";
|
|
|
4
4
|
/* empty css */
|
|
5
5
|
/* empty css */
|
|
6
6
|
//#region components/KMenu.vue
|
|
7
|
-
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-
|
|
7
|
+
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-29b58dd2"]]);
|
|
8
8
|
//#endregion
|
|
9
9
|
export { n as default };
|