@oiij/naive-ui 0.0.76 → 0.0.78
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/config-providers/ConfigProviders.vue.d.ts +2 -2
- package/dist/components/config-providers/index.d.ts +16 -7
- package/dist/components/copy-button/CopyButton.js +2 -2
- package/dist/components/copy-button/CopyButton.vue.d.ts +4 -4
- package/dist/components/copy-button/index.d.ts +6 -3
- package/dist/components/data-table-plus/DataTablePlus.js +74 -125
- package/dist/components/data-table-plus/DataTablePlus.vue.d.ts +46 -111
- package/dist/components/data-table-plus/index.d.ts +52 -32
- package/dist/components/index.d.ts +2 -4
- package/dist/components/loading-provider/LoadingProvider.js +2 -2
- package/dist/components/loading-provider/LoadingProvider.vue.d.ts +2 -2
- package/dist/components/loading-provider/index.d.ts +19 -10
- package/dist/components/loading-provider/index.js +5 -2
- package/dist/components/preset-form/PresetForm.js +42 -21
- package/dist/components/preset-form/PresetForm.vue.d.ts +21 -21
- package/dist/components/preset-form/_utils.js +23 -8
- package/dist/components/preset-form/index.d.ts +32 -13
- package/dist/components/preset-input/PresetInput.vue.d.ts +3 -3
- package/dist/components/preset-input/index.d.ts +30 -20
- package/dist/components/preset-picker/PresetPicker.js +31 -34
- package/dist/components/preset-picker/PresetPicker.vue.d.ts +5 -10
- package/dist/components/preset-picker/index.d.ts +45 -31
- package/dist/components/preset-select/PresetSelect.js +23 -59
- package/dist/components/preset-select/PresetSelect.vue.d.ts +35 -39
- package/dist/components/preset-select/index.d.ts +56 -22
- package/dist/components/remote-request/RemoteRequest.js +7 -7
- package/dist/components/remote-request/RemoteRequest.vue.d.ts +13 -13
- package/dist/components/remote-request/index.d.ts +30 -8
- package/dist/components/search-input/SearchInput.vue.d.ts +4 -4
- package/dist/components/search-input/index.d.ts +10 -7
- package/dist/components/toggle-input/ToggleInput.vue.d.ts +4 -4
- package/dist/components/tooltip-button/TooltipButton.vue.d.ts +4 -4
- package/dist/components/tooltip-button/index.d.ts +5 -2
- package/dist/components/transition/BaseTransition.vue.d.ts +2 -2
- package/dist/components/transition/index.d.ts +4 -1
- package/dist/components.d.ts +2 -4
- package/dist/components.js +2 -3
- package/dist/composables/_helper.d.ts +7 -4
- package/dist/composables/_helper.js +47 -0
- package/dist/composables/index.d.ts +1 -1
- package/dist/composables/use-data-request.d.ts +25 -18
- package/dist/composables/use-data-request.js +22 -3
- package/dist/composables/use-loading.d.ts +6 -0
- package/dist/composables/use-loading.js +8 -2
- package/dist/composables/use-naive-form.d.ts +21 -13
- package/dist/composables/use-naive-form.js +48 -39
- package/dist/composables/use-naive-menu.d.ts +20 -5
- package/dist/composables/use-naive-menu.js +19 -61
- package/dist/composables/use-naive-theme.d.ts +27 -14
- package/dist/composables/use-naive-theme.js +22 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +5 -7
- package/dist/components/_utils/prismjs.js +0 -16
- package/dist/components/icons/MageArrowUp.js +0 -29
- package/dist/components/type-writer/TypeWriter.js +0 -75
- package/dist/components/type-writer/TypeWriter.vue.d.ts +0 -22
- package/dist/components/type-writer/index.d.ts +0 -13
- package/dist/components/type-writer/type-writer.cssr.js +0 -27
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useNaiveForm } from "../../composables/use-naive-form.js";
|
|
2
2
|
import PresetInput_default from "../preset-input/PresetInput.js";
|
|
3
3
|
import { mergeRule } from "./_utils.js";
|
|
4
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString,
|
|
4
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useTemplateRef, withCtx } from "vue";
|
|
5
5
|
import { NButton, NCollapseTransition, NDivider, NForm, NFormItem, NGi, NGrid } from "naive-ui";
|
|
6
6
|
|
|
7
7
|
//#region src/components/preset-form/PresetForm.vue
|
|
@@ -27,15 +27,36 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
27
27
|
emit("validated", value);
|
|
28
28
|
});
|
|
29
29
|
const filterCollapsed = ref(false);
|
|
30
|
+
const visibleOptions = computed(() => {
|
|
31
|
+
return __props.options?.filter((f) => typeof f.hidden === "function" ? !f.hidden() : !f.hidden) || [];
|
|
32
|
+
});
|
|
30
33
|
const _options = computed(() => {
|
|
31
|
-
return
|
|
34
|
+
return visibleOptions.value.filter((f) => typeof f.collapsed === "function" ? !f.collapsed() : !f.collapsed);
|
|
32
35
|
});
|
|
33
36
|
const _collapsedOptions = computed(() => {
|
|
34
|
-
return
|
|
37
|
+
return visibleOptions.value.filter((f) => typeof f.collapsed === "function" ? f.collapsed() : f.collapsed);
|
|
35
38
|
});
|
|
36
39
|
function onPresetInputUpdate(val, key) {
|
|
37
40
|
if (key) setValue({ [key]: val });
|
|
38
41
|
}
|
|
42
|
+
function presetFormProps(options) {
|
|
43
|
+
return options.map((option) => {
|
|
44
|
+
const { key, label, required, span, rule, itemProps, render, ...inputOption } = option;
|
|
45
|
+
const { offset, suffix, ...extraItemProps } = itemProps ?? {};
|
|
46
|
+
return {
|
|
47
|
+
key: typeof key === "string" ? key : void 0,
|
|
48
|
+
label: typeof label === "function" ? label() : label,
|
|
49
|
+
span: typeof span === "function" ? span() : span ?? itemProps?.span,
|
|
50
|
+
required,
|
|
51
|
+
rule,
|
|
52
|
+
offset,
|
|
53
|
+
suffix,
|
|
54
|
+
itemProps: extraItemProps,
|
|
55
|
+
render,
|
|
56
|
+
inputOption
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
39
60
|
const expose = {
|
|
40
61
|
formInst,
|
|
41
62
|
formValue,
|
|
@@ -52,10 +73,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
52
73
|
const templateBind = computed(() => {
|
|
53
74
|
return {
|
|
54
75
|
...expose,
|
|
55
|
-
formInst:
|
|
56
|
-
formValue:
|
|
57
|
-
formRules:
|
|
58
|
-
formProps:
|
|
76
|
+
formInst: formInst.value,
|
|
77
|
+
formValue: formValue.value,
|
|
78
|
+
formRules: formRules.value,
|
|
79
|
+
formProps: _formProps
|
|
59
80
|
};
|
|
60
81
|
});
|
|
61
82
|
__expose(expose);
|
|
@@ -68,30 +89,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
68
89
|
default: withCtx(() => [
|
|
69
90
|
renderSlot(_ctx.$slots, "header", normalizeProps(guardReactiveProps(templateBind.value))),
|
|
70
91
|
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(templateBind.value)), () => [_options.value && _options.value.length > 0 ? (openBlock(), createBlock(unref(NGrid), normalizeProps(mergeProps({ key: 0 }, __props.gridProps)), {
|
|
71
|
-
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_options.value, ({
|
|
92
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(presetFormProps(_options.value), ({ span, offset, suffix, label, key, required, rule, itemProps, render, inputOption }, index) => {
|
|
72
93
|
return openBlock(), createBlock(unref(NGi), mergeProps({
|
|
73
|
-
key:
|
|
74
|
-
span
|
|
94
|
+
key: index,
|
|
95
|
+
span
|
|
75
96
|
}, { ref_for: true }, {
|
|
76
97
|
offset,
|
|
77
98
|
suffix
|
|
78
99
|
}), {
|
|
79
100
|
default: withCtx(({ overflow }) => [createVNode(unref(NFormItem), mergeProps({
|
|
80
|
-
label
|
|
81
|
-
path:
|
|
101
|
+
label,
|
|
102
|
+
path: key,
|
|
82
103
|
rule: unref(mergeRule)({
|
|
83
104
|
key,
|
|
84
105
|
label,
|
|
85
106
|
required,
|
|
86
107
|
rule
|
|
87
108
|
})
|
|
88
|
-
}, { ref_for: true },
|
|
109
|
+
}, { ref_for: true }, itemProps), {
|
|
89
110
|
default: withCtx(() => [render ? (openBlock(), createBlock(resolveDynamicComponent(render({
|
|
90
111
|
...expose,
|
|
91
112
|
overflow
|
|
92
113
|
})), { key: 0 })) : (openBlock(), createBlock(unref(PresetInput_default), {
|
|
93
114
|
key: 1,
|
|
94
|
-
options:
|
|
115
|
+
options: inputOption,
|
|
95
116
|
value: key ? unref(formValue)[key] : void 0,
|
|
96
117
|
"onUpdate:value": (val) => onPresetInputUpdate(val, key)
|
|
97
118
|
}, null, 8, [
|
|
@@ -120,30 +141,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
120
141
|
_: 1
|
|
121
142
|
}), createVNode(unref(NCollapseTransition), { show: filterCollapsed.value }, {
|
|
122
143
|
default: withCtx(() => [createVNode(unref(NGrid), normalizeProps(guardReactiveProps(__props.gridProps)), {
|
|
123
|
-
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_collapsedOptions.value, ({
|
|
144
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(presetFormProps(_collapsedOptions.value), ({ span, offset, suffix, label, key, required, rule, itemProps, render, inputOption }, index) => {
|
|
124
145
|
return openBlock(), createBlock(unref(NGi), mergeProps({
|
|
125
|
-
key:
|
|
126
|
-
span
|
|
146
|
+
key: index,
|
|
147
|
+
span
|
|
127
148
|
}, { ref_for: true }, {
|
|
128
149
|
offset,
|
|
129
150
|
suffix
|
|
130
151
|
}), {
|
|
131
152
|
default: withCtx(({ overflow }) => [createVNode(unref(NFormItem), mergeProps({
|
|
132
|
-
label
|
|
133
|
-
path:
|
|
153
|
+
label,
|
|
154
|
+
path: key,
|
|
134
155
|
rule: unref(mergeRule)({
|
|
135
156
|
key,
|
|
136
157
|
label,
|
|
137
158
|
required,
|
|
138
159
|
rule
|
|
139
160
|
})
|
|
140
|
-
}, { ref_for: true },
|
|
161
|
+
}, { ref_for: true }, itemProps), {
|
|
141
162
|
default: withCtx(() => [render ? (openBlock(), createBlock(resolveDynamicComponent(render({
|
|
142
163
|
...expose,
|
|
143
164
|
overflow
|
|
144
165
|
})), { key: 0 })) : (openBlock(), createBlock(unref(PresetInput_default), {
|
|
145
166
|
key: 1,
|
|
146
|
-
options:
|
|
167
|
+
options: inputOption,
|
|
147
168
|
value: key ? unref(formValue)[key] : void 0,
|
|
148
169
|
"onUpdate:value": (val) => onPresetInputUpdate(val, key)
|
|
149
170
|
}, null, 8, [
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { DataObject } from "../../composables/use-data-request.js";
|
|
2
2
|
import { PresetFormExpose, PresetFormProps } from "./index.js";
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
3
|
+
import * as _vueuse_core56 from "@vueuse/core";
|
|
4
|
+
import * as vue49 from "vue";
|
|
5
|
+
import * as naive_ui1 from "naive-ui";
|
|
6
6
|
import { FormInst, FormRules } from "naive-ui";
|
|
7
7
|
import * as async_validator0 from "async-validator";
|
|
8
8
|
|
|
9
9
|
//#region src/components/preset-form/PresetForm.vue.d.ts
|
|
10
10
|
declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
11
|
-
props:
|
|
11
|
+
props: vue49.PublicProps & __VLS_PrettifyLocal<PresetFormProps<V> & {
|
|
12
12
|
onValidated?: ((val: V) => any) | undefined;
|
|
13
13
|
}> & (typeof globalThis extends {
|
|
14
14
|
__VLS_PROPS_FALLBACK: infer P;
|
|
15
15
|
} ? P : {});
|
|
16
|
-
expose: (exposed:
|
|
16
|
+
expose: (exposed: vue49.ShallowUnwrapRef<PresetFormExpose<V>>) => void;
|
|
17
17
|
attrs: any;
|
|
18
18
|
slots: {
|
|
19
19
|
header?: (props: {
|
|
20
20
|
formInst: FormInst | null;
|
|
21
21
|
formValue: V;
|
|
22
|
-
formRules: Partial<Record<keyof V, FormRules |
|
|
22
|
+
formRules: Partial<Record<keyof V, FormRules | naive_ui1.FormItemRule | naive_ui1.FormItemRule[]>>;
|
|
23
23
|
formProps: {
|
|
24
|
-
model:
|
|
25
|
-
rules:
|
|
24
|
+
model: vue49.Reactive<V>;
|
|
25
|
+
rules: vue49.Reactive<Partial<Record<keyof V, FormRules | naive_ui1.FormItemRule | naive_ui1.FormItemRule[]>>>;
|
|
26
26
|
};
|
|
27
|
-
setValue: (
|
|
27
|
+
setValue: (value: Partial<V>) => void;
|
|
28
28
|
validate: () => Promise<{
|
|
29
29
|
warnings?: async_validator0.ValidateError[][];
|
|
30
30
|
}>;
|
|
@@ -32,18 +32,18 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
32
32
|
resetForm: () => void;
|
|
33
33
|
reset: () => void;
|
|
34
34
|
clear: () => void;
|
|
35
|
-
onValidated:
|
|
35
|
+
onValidated: _vueuse_core56.EventHookOn<[V]>;
|
|
36
36
|
}) => any;
|
|
37
37
|
} & {
|
|
38
38
|
default?: (props: {
|
|
39
39
|
formInst: FormInst | null;
|
|
40
40
|
formValue: V;
|
|
41
|
-
formRules: Partial<Record<keyof V, FormRules |
|
|
41
|
+
formRules: Partial<Record<keyof V, FormRules | naive_ui1.FormItemRule | naive_ui1.FormItemRule[]>>;
|
|
42
42
|
formProps: {
|
|
43
|
-
model:
|
|
44
|
-
rules:
|
|
43
|
+
model: vue49.Reactive<V>;
|
|
44
|
+
rules: vue49.Reactive<Partial<Record<keyof V, FormRules | naive_ui1.FormItemRule | naive_ui1.FormItemRule[]>>>;
|
|
45
45
|
};
|
|
46
|
-
setValue: (
|
|
46
|
+
setValue: (value: Partial<V>) => void;
|
|
47
47
|
validate: () => Promise<{
|
|
48
48
|
warnings?: async_validator0.ValidateError[][];
|
|
49
49
|
}>;
|
|
@@ -51,18 +51,18 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
51
51
|
resetForm: () => void;
|
|
52
52
|
reset: () => void;
|
|
53
53
|
clear: () => void;
|
|
54
|
-
onValidated:
|
|
54
|
+
onValidated: _vueuse_core56.EventHookOn<[V]>;
|
|
55
55
|
}) => any;
|
|
56
56
|
} & {
|
|
57
57
|
footer?: (props: {
|
|
58
58
|
formInst: FormInst | null;
|
|
59
59
|
formValue: V;
|
|
60
|
-
formRules: Partial<Record<keyof V, FormRules |
|
|
60
|
+
formRules: Partial<Record<keyof V, FormRules | naive_ui1.FormItemRule | naive_ui1.FormItemRule[]>>;
|
|
61
61
|
formProps: {
|
|
62
|
-
model:
|
|
63
|
-
rules:
|
|
62
|
+
model: vue49.Reactive<V>;
|
|
63
|
+
rules: vue49.Reactive<Partial<Record<keyof V, FormRules | naive_ui1.FormItemRule | naive_ui1.FormItemRule[]>>>;
|
|
64
64
|
};
|
|
65
|
-
setValue: (
|
|
65
|
+
setValue: (value: Partial<V>) => void;
|
|
66
66
|
validate: () => Promise<{
|
|
67
67
|
warnings?: async_validator0.ValidateError[][];
|
|
68
68
|
}>;
|
|
@@ -70,11 +70,11 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
70
70
|
resetForm: () => void;
|
|
71
71
|
reset: () => void;
|
|
72
72
|
clear: () => void;
|
|
73
|
-
onValidated:
|
|
73
|
+
onValidated: _vueuse_core56.EventHookOn<[V]>;
|
|
74
74
|
}) => any;
|
|
75
75
|
};
|
|
76
76
|
emit: (e: "validated", val: V) => void;
|
|
77
|
-
}>) =>
|
|
77
|
+
}>) => vue49.VNode & {
|
|
78
78
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
79
79
|
};
|
|
80
80
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
//#region src/components/preset-form/_utils.ts
|
|
2
2
|
function mergeRule(option) {
|
|
3
3
|
const { key, label, required, rule } = option ?? {};
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const _required = typeof required === "function" ? required() : required;
|
|
5
|
+
if (!_required && !rule) return;
|
|
6
|
+
const getLabelText = () => {
|
|
7
|
+
if (typeof label === "string") return label;
|
|
8
|
+
if (typeof label === "function") return label();
|
|
9
|
+
if (typeof key === "string") return key;
|
|
10
|
+
return "字段";
|
|
9
11
|
};
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
if (_required) {
|
|
13
|
+
const requiredRule = {
|
|
14
|
+
required: true,
|
|
15
|
+
message: `${getLabelText()}不能为空`,
|
|
16
|
+
trigger: ["input", "blur"]
|
|
17
|
+
};
|
|
18
|
+
if (rule) {
|
|
19
|
+
if (Array.isArray(rule)) return [requiredRule, ...rule];
|
|
20
|
+
return {
|
|
21
|
+
...requiredRule,
|
|
22
|
+
...rule
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return requiredRule;
|
|
26
|
+
}
|
|
27
|
+
return rule;
|
|
13
28
|
}
|
|
14
29
|
|
|
15
30
|
//#endregion
|
|
@@ -8,29 +8,48 @@ import { FormItemProps, FormItemRule, FormProps, FormRules, GridItemProps, GridP
|
|
|
8
8
|
import { ComponentExposed } from "vue-component-type-helpers";
|
|
9
9
|
|
|
10
10
|
//#region src/components/preset-form/index.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* 预设表单暴露的方法
|
|
13
|
+
* @template V 表单值类型
|
|
14
|
+
*/
|
|
11
15
|
type PresetFormExpose<V extends DataObject = DataObject> = UseNaiveFormReturns<V>;
|
|
16
|
+
/**
|
|
17
|
+
* 预设表单选项项
|
|
18
|
+
* @template V 表单值类型
|
|
19
|
+
*/
|
|
12
20
|
type PresetFormOptionItem<V extends DataObject = DataObject> = PresetInputOptions & {
|
|
13
|
-
key?: keyof V;
|
|
14
|
-
label?: string | (() => string);
|
|
15
|
-
required?: boolean | (() => boolean);
|
|
16
|
-
collapsed?: boolean | (() => boolean);
|
|
17
|
-
span?: string | number | (() => string | number);
|
|
18
|
-
hidden?: boolean | (() => boolean);
|
|
19
|
-
rule?: FormRules | FormItemRule | FormItemRule[];
|
|
20
|
-
itemProps?: FormItemProps & GridItemProps & ClassStyle;
|
|
21
|
+
/** 字段键名 */key?: keyof V; /** 标签 */
|
|
22
|
+
label?: string | (() => string); /** 是否必填 */
|
|
23
|
+
required?: boolean | (() => boolean); /** 是否折叠 */
|
|
24
|
+
collapsed?: boolean | (() => boolean); /** 跨度 */
|
|
25
|
+
span?: string | number | (() => string | number); /** 是否隐藏 */
|
|
26
|
+
hidden?: boolean | (() => boolean); /** 验证规则 */
|
|
27
|
+
rule?: FormRules | FormItemRule | FormItemRule[]; /** 表单项属性 */
|
|
28
|
+
itemProps?: FormItemProps & GridItemProps & ClassStyle; /** 自定义渲染函数 */
|
|
21
29
|
render?: (params: PresetFormExpose<V> & {
|
|
22
30
|
overflow: boolean;
|
|
23
31
|
}) => VNode | null;
|
|
24
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* 预设表单选项
|
|
35
|
+
* @template V 表单值类型
|
|
36
|
+
*/
|
|
25
37
|
type PresetFormOptions<V extends DataObject = DataObject> = PresetFormOptionItem<V>[];
|
|
38
|
+
/**
|
|
39
|
+
* 预设表单属性
|
|
40
|
+
* @template V 表单值类型
|
|
41
|
+
*/
|
|
26
42
|
type PresetFormProps<V extends DataObject = DataObject> = {
|
|
27
|
-
options?: PresetFormOptions<V>;
|
|
28
|
-
value?: V;
|
|
29
|
-
rules?: UseNaiveFormRules<V>;
|
|
30
|
-
clearRules?: UseNaiveFormClearRules;
|
|
31
|
-
formProps?: FormProps & ClassStyle;
|
|
43
|
+
/** 表单选项 */options?: PresetFormOptions<V>; /** 表单值 */
|
|
44
|
+
value?: V; /** 验证规则 */
|
|
45
|
+
rules?: UseNaiveFormRules<V>; /** 清空规则 */
|
|
46
|
+
clearRules?: UseNaiveFormClearRules; /** 表单属性 */
|
|
47
|
+
formProps?: FormProps & ClassStyle; /** 网格属性 */
|
|
32
48
|
gridProps?: GridProps & ClassStyle;
|
|
33
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* 预设表单实例类型
|
|
52
|
+
*/
|
|
34
53
|
type PresetFormInst = ComponentExposed<typeof _default>;
|
|
35
54
|
//#endregion
|
|
36
55
|
export { PresetFormExpose, PresetFormInst, PresetFormOptionItem, PresetFormOptions, PresetFormProps };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PresetInputProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue44 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/preset-input/PresetInput.vue.d.ts
|
|
5
5
|
declare const __VLS_export: <V>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
6
|
-
props:
|
|
6
|
+
props: vue44.PublicProps & __VLS_PrettifyLocal<PresetInputProps<V> & {
|
|
7
7
|
"onUpdate:value"?: ((val?: V | undefined) => any) | undefined;
|
|
8
8
|
}> & (typeof globalThis extends {
|
|
9
9
|
__VLS_PROPS_FALLBACK: infer P;
|
|
@@ -12,7 +12,7 @@ declare const __VLS_export: <V>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
12
12
|
attrs: any;
|
|
13
13
|
slots: {};
|
|
14
14
|
emit: (e: "update:value", val?: V) => void;
|
|
15
|
-
}>) =>
|
|
15
|
+
}>) => vue44.VNode & {
|
|
16
16
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
17
17
|
};
|
|
18
18
|
declare const _default: typeof __VLS_export;
|
|
@@ -6,23 +6,26 @@ import { ButtonProps, CheckboxGroupProps, CheckboxProps, ColorPickerProps, DateP
|
|
|
6
6
|
|
|
7
7
|
//#region src/components/preset-input/index.d.ts
|
|
8
8
|
type RawChildren = string | number | boolean | VNode | VNodeArrayChildren | (() => any);
|
|
9
|
+
/**
|
|
10
|
+
* 预设输入类型
|
|
11
|
+
*/
|
|
9
12
|
type PresetInputType = {
|
|
10
|
-
'button': {
|
|
11
|
-
props?: ButtonProps & {
|
|
13
|
+
/** 按钮 */'button': {
|
|
14
|
+
/** 属性 */props?: ButtonProps & {
|
|
12
15
|
label?: string;
|
|
13
|
-
};
|
|
16
|
+
}; /** 插槽 */
|
|
14
17
|
slots?: {
|
|
15
18
|
default?: () => RawChildren;
|
|
16
19
|
icon?: () => RawChildren;
|
|
17
20
|
};
|
|
18
|
-
};
|
|
21
|
+
}; /** 颜色选择器 */
|
|
19
22
|
'color-picker': {
|
|
20
23
|
props?: ColorPickerProps;
|
|
21
24
|
slots?: {
|
|
22
25
|
label?: (color: string | null) => RawChildren;
|
|
23
26
|
action?: () => RawChildren;
|
|
24
27
|
};
|
|
25
|
-
};
|
|
28
|
+
}; /** 复选框 */
|
|
26
29
|
'checkbox': {
|
|
27
30
|
props?: CheckboxGroupProps & {
|
|
28
31
|
options?: CheckboxProps[];
|
|
@@ -30,17 +33,17 @@ type PresetInputType = {
|
|
|
30
33
|
slots?: {
|
|
31
34
|
default?: () => RawChildren;
|
|
32
35
|
};
|
|
33
|
-
};
|
|
36
|
+
}; /** 分割线 */
|
|
34
37
|
'divider': {
|
|
35
38
|
props?: DividerProps;
|
|
36
39
|
slots?: {
|
|
37
40
|
default?: () => RawChildren;
|
|
38
41
|
};
|
|
39
|
-
};
|
|
42
|
+
}; /** 日期选择器 */
|
|
40
43
|
'date-picker': {
|
|
41
44
|
props?: DatePickerProps;
|
|
42
45
|
slots?: undefined;
|
|
43
|
-
};
|
|
46
|
+
}; /** 动态标签 */
|
|
44
47
|
'dynamic-tags': {
|
|
45
48
|
props?: DynamicTagsProps;
|
|
46
49
|
slots?: {
|
|
@@ -53,7 +56,7 @@ type PresetInputType = {
|
|
|
53
56
|
disabled: boolean;
|
|
54
57
|
}) => RawChildren;
|
|
55
58
|
};
|
|
56
|
-
};
|
|
59
|
+
}; /** 输入框 */
|
|
57
60
|
'input': {
|
|
58
61
|
props?: InputProps;
|
|
59
62
|
slots?: {
|
|
@@ -67,7 +70,7 @@ type PresetInputType = {
|
|
|
67
70
|
separator?: () => RawChildren;
|
|
68
71
|
suffix?: () => RawChildren;
|
|
69
72
|
};
|
|
70
|
-
};
|
|
73
|
+
}; /** 数字输入框 */
|
|
71
74
|
'input-number': {
|
|
72
75
|
props?: InputNumberProps;
|
|
73
76
|
slots?: {
|
|
@@ -76,7 +79,7 @@ type PresetInputType = {
|
|
|
76
79
|
prefix?: () => RawChildren;
|
|
77
80
|
suffix?: () => RawChildren;
|
|
78
81
|
};
|
|
79
|
-
};
|
|
82
|
+
}; /** 搜索框 */
|
|
80
83
|
'search': {
|
|
81
84
|
props?: SearchInputProps;
|
|
82
85
|
slots?: {
|
|
@@ -88,7 +91,7 @@ type PresetInputType = {
|
|
|
88
91
|
}) => RawChildren;
|
|
89
92
|
buttonIcon?: () => RawChildren;
|
|
90
93
|
};
|
|
91
|
-
};
|
|
94
|
+
}; /** 单选框 */
|
|
92
95
|
'radio': {
|
|
93
96
|
props?: RadioGroupProps & {
|
|
94
97
|
options?: RadioProps[];
|
|
@@ -96,7 +99,7 @@ type PresetInputType = {
|
|
|
96
99
|
slots?: {
|
|
97
100
|
default?: () => RawChildren;
|
|
98
101
|
};
|
|
99
|
-
};
|
|
102
|
+
}; /** 评分 */
|
|
100
103
|
'rate': {
|
|
101
104
|
props?: RateProps;
|
|
102
105
|
slots?: {
|
|
@@ -104,7 +107,7 @@ type PresetInputType = {
|
|
|
104
107
|
index: number;
|
|
105
108
|
}) => RawChildren;
|
|
106
109
|
};
|
|
107
|
-
};
|
|
110
|
+
}; /** 选择器 */
|
|
108
111
|
'select': {
|
|
109
112
|
props?: SelectProps;
|
|
110
113
|
slots?: {
|
|
@@ -113,13 +116,13 @@ type PresetInputType = {
|
|
|
113
116
|
empty?: () => RawChildren;
|
|
114
117
|
arrow?: () => RawChildren;
|
|
115
118
|
};
|
|
116
|
-
};
|
|
119
|
+
}; /** 滑块 */
|
|
117
120
|
'slider': {
|
|
118
121
|
props?: SliderProps;
|
|
119
122
|
slots?: {
|
|
120
123
|
thumb?: () => RawChildren;
|
|
121
124
|
};
|
|
122
|
-
};
|
|
125
|
+
}; /** 开关 */
|
|
123
126
|
'switch': {
|
|
124
127
|
props?: SwitchProps;
|
|
125
128
|
slots?: {
|
|
@@ -129,7 +132,7 @@ type PresetInputType = {
|
|
|
129
132
|
unchecked?: () => RawChildren;
|
|
130
133
|
uncheckedIcon?: () => RawChildren;
|
|
131
134
|
};
|
|
132
|
-
};
|
|
135
|
+
}; /** 时间选择器 */
|
|
133
136
|
'time-picker': {
|
|
134
137
|
props?: TimePickerProps;
|
|
135
138
|
slots?: {
|
|
@@ -137,13 +140,20 @@ type PresetInputType = {
|
|
|
137
140
|
};
|
|
138
141
|
};
|
|
139
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* 预设输入选项
|
|
145
|
+
*/
|
|
140
146
|
type PresetInputOptions = { [K in keyof PresetInputType]: {
|
|
141
|
-
type?: K;
|
|
142
|
-
props?: PresetInputType[K]['props'] & ClassStyle;
|
|
147
|
+
/** 类型 */type?: K; /** 属性 */
|
|
148
|
+
props?: PresetInputType[K]['props'] & ClassStyle; /** 插槽 */
|
|
143
149
|
slots?: PresetInputType[K]['slots'];
|
|
144
150
|
} }[keyof PresetInputType];
|
|
151
|
+
/**
|
|
152
|
+
* 预设输入属性
|
|
153
|
+
* @template V 值类型
|
|
154
|
+
*/
|
|
145
155
|
type PresetInputProps<V> = {
|
|
146
|
-
value?: V;
|
|
156
|
+
/** 值 */value?: V; /** 选项 */
|
|
147
157
|
options?: PresetInputOptions;
|
|
148
158
|
};
|
|
149
159
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MageMultiplyCircleFill_default from "../icons/MageMultiplyCircleFill.js";
|
|
2
|
-
import { computed, createBlock, createCommentVNode, createElementVNode, createVNode, defineComponent,
|
|
2
|
+
import { computed, createBlock, createCommentVNode, createElementVNode, createVNode, defineComponent, mergeProps, openBlock, reactive, ref, renderSlot, toDisplayString, toRaw, toValue, unref, watch, withCtx, withModifiers } from "vue";
|
|
3
3
|
import { NBadge, NButton, NButtonGroup, NModal, NTooltip } from "naive-ui";
|
|
4
4
|
import { cloneDeep } from "es-toolkit/object";
|
|
5
5
|
|
|
@@ -28,12 +28,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
28
28
|
},
|
|
29
29
|
emits: [
|
|
30
30
|
"update:value",
|
|
31
|
-
"afterEnter",
|
|
32
|
-
"afterLeave",
|
|
33
|
-
"esc",
|
|
34
|
-
"maskClick",
|
|
35
|
-
"update:show",
|
|
36
|
-
"close",
|
|
37
31
|
"negativeClick",
|
|
38
32
|
"positiveClick"
|
|
39
33
|
],
|
|
@@ -63,15 +57,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
63
57
|
showModalFlag.value = true;
|
|
64
58
|
}
|
|
65
59
|
function clickRowEffect(row) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const rowValue = row?.[_fields.value];
|
|
61
|
+
if (__props.multiple) {
|
|
62
|
+
const index = checkedRowKeys.value.indexOf(rowValue);
|
|
63
|
+
if (index > -1) {
|
|
64
|
+
checkedRowKeys.value.splice(index, 1);
|
|
65
|
+
checkedRows.value = checkedRows.value.filter((f) => f?.[_fields.value] !== rowValue);
|
|
66
|
+
} else {
|
|
67
|
+
checkedRowKeys.value.push(rowValue);
|
|
68
|
+
checkedRows.value.push(row);
|
|
69
|
+
}
|
|
69
70
|
} else {
|
|
70
|
-
checkedRowKeys.value
|
|
71
|
-
checkedRows.value.push(row);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
checkedRowKeys.value = [row?.[_fields.value]];
|
|
71
|
+
checkedRowKeys.value = [rowValue];
|
|
75
72
|
checkedRows.value = [row];
|
|
76
73
|
}
|
|
77
74
|
}
|
|
@@ -107,20 +104,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
107
104
|
emit("update:value", null, null);
|
|
108
105
|
}
|
|
109
106
|
const _label = computed(() => {
|
|
110
|
-
if (Array.isArray(__props.value)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return item && item?.[_fields.label] ? item?.[_fields.label] : typeof __props.fallbackLabel === "function" ? __props.fallbackLabel(__props.value) : __props.fallbackLabel ?? __props.value;
|
|
107
|
+
if (Array.isArray(__props.value)) {
|
|
108
|
+
if (__props.value.length === 0) return __props.placeholder;
|
|
109
|
+
if (typeof __props.fallbackLabel === "string") return __props.fallbackLabel;
|
|
110
|
+
return __props.value.map((m) => {
|
|
111
|
+
return checkedRows.value.find((f) => f?.[_fields.value] === m)?.[_fields.label] ?? (typeof __props.fallbackLabel === "function" ? __props.fallbackLabel(m) : m);
|
|
112
|
+
}).join(",");
|
|
117
113
|
}
|
|
114
|
+
if (__props.value !== void 0 && __props.value !== null) return checkedRows.value.find((f) => f?.[_fields.value] === __props.value)?.[_fields.label] ?? (typeof __props.fallbackLabel === "function" ? __props.fallbackLabel(__props.value) : __props.fallbackLabel ?? __props.value);
|
|
118
115
|
return __props.placeholder;
|
|
119
116
|
});
|
|
120
117
|
const showClearButton = computed(() => {
|
|
121
118
|
return __props.clearable && (Array.isArray(__props.value) ? __props.value.length > 0 : !!__props.value);
|
|
122
119
|
});
|
|
123
120
|
const checkedCount = computed(() => Array.isArray(__props.value) ? __props.value.length : void 0);
|
|
121
|
+
function handleLoadedRows(rows) {
|
|
122
|
+
const newRows = rows.filter((f) => {
|
|
123
|
+
return checkedRowKeys.value.includes(f?.[_fields.value]) && !checkedRows.value.some((s) => s?.[_fields.value] === f?.[_fields.value]);
|
|
124
|
+
});
|
|
125
|
+
checkedRows.value.push(...newRows);
|
|
126
|
+
}
|
|
124
127
|
const expose = {
|
|
125
128
|
showModalFlag,
|
|
126
129
|
checkedRowKeys,
|
|
@@ -140,10 +143,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
140
143
|
const templateBind = computed(() => {
|
|
141
144
|
return {
|
|
142
145
|
...expose,
|
|
143
|
-
showModalFlag:
|
|
144
|
-
checkedRowKeys:
|
|
145
|
-
checkedRows:
|
|
146
|
-
columns:
|
|
146
|
+
showModalFlag: showModalFlag.value,
|
|
147
|
+
checkedRowKeys: checkedRowKeys.value,
|
|
148
|
+
checkedRows: checkedRows.value,
|
|
149
|
+
columns: _columns
|
|
147
150
|
};
|
|
148
151
|
});
|
|
149
152
|
__expose(expose);
|
|
@@ -184,19 +187,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
184
187
|
"negative-text": "取消"
|
|
185
188
|
}, __props.modalProps, {
|
|
186
189
|
onPositiveClick,
|
|
187
|
-
onNegativeClick
|
|
188
|
-
onClose: _cache[1] || (_cache[1] = ($event) => emit("close")),
|
|
189
|
-
onAfterEnter: _cache[2] || (_cache[2] = ($event) => emit("afterEnter")),
|
|
190
|
-
onAfterLeave: _cache[3] || (_cache[3] = ($event) => emit("afterLeave")),
|
|
191
|
-
onEsc: _cache[4] || (_cache[4] = ($event) => emit("esc")),
|
|
192
|
-
onMaskClick: _cache[5] || (_cache[5] = ($event) => emit("maskClick")),
|
|
193
|
-
"onUpdate:show": _cache[6] || (_cache[6] = (val) => emit("update:show", val))
|
|
190
|
+
onNegativeClick
|
|
194
191
|
}), {
|
|
195
192
|
action: withCtx(() => [renderSlot(_ctx.$slots, "modal-action")]),
|
|
196
193
|
header: withCtx(() => [renderSlot(_ctx.$slots, "modal-header")]),
|
|
197
194
|
icon: withCtx(() => [renderSlot(_ctx.$slots, "modal-icon")]),
|
|
198
195
|
close: withCtx(() => [renderSlot(_ctx.$slots, "modal-close")]),
|
|
199
|
-
default: withCtx(() => [renderSlot(_ctx.$slots, "default",
|
|
196
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", mergeProps(templateBind.value, { onLoadedRows: handleLoadedRows }))]),
|
|
200
197
|
_: 3
|
|
201
198
|
}, 16, ["show", "title"])
|
|
202
199
|
]),
|