@oiij/naive-ui 0.0.76 → 0.0.77
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 +15 -80
- 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 +17 -17
- 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 +33 -37
- 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 +6 -6
- 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/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/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 +5 -4
- package/dist/composables/use-naive-menu.js +2 -50
- package/dist/composables/use-naive-theme.d.ts +27 -14
- package/dist/composables/use-naive-theme.js +22 -4
- 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
|
@@ -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
|
]),
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import { DataObject } from "../../composables/use-data-request.js";
|
|
2
2
|
import { PresetPickerEmits, PresetPickerExpose, PresetPickerProps, PresetPickerValue } from "./index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as vue40 from "vue";
|
|
4
4
|
import { DataTableColumns } from "naive-ui";
|
|
5
5
|
|
|
6
6
|
//#region src/components/preset-picker/PresetPicker.vue.d.ts
|
|
7
7
|
declare const __VLS_export: <V extends PresetPickerValue, R 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<{
|
|
8
|
-
props:
|
|
9
|
-
onClose?: (() => any) | undefined;
|
|
8
|
+
props: vue40.PublicProps & __VLS_PrettifyLocal<PresetPickerProps<V, R> & {
|
|
10
9
|
"onUpdate:value"?: ((val: V | null, raw: R | R[] | null) => any) | undefined;
|
|
11
|
-
onAfterEnter?: (() => any) | undefined;
|
|
12
|
-
onAfterLeave?: (() => any) | undefined;
|
|
13
|
-
onEsc?: (() => any) | undefined;
|
|
14
|
-
onMaskClick?: (() => any) | undefined;
|
|
15
10
|
onNegativeClick?: (() => any) | undefined;
|
|
16
11
|
onPositiveClick?: (() => any) | undefined;
|
|
17
|
-
"onUpdate:show"?: ((value: boolean) => any) | undefined;
|
|
18
12
|
}> & (typeof globalThis extends {
|
|
19
13
|
__VLS_PROPS_FALLBACK: infer P;
|
|
20
14
|
} ? P : {});
|
|
21
|
-
expose: (exposed:
|
|
15
|
+
expose: (exposed: vue40.ShallowUnwrapRef<PresetPickerExpose<R>>) => void;
|
|
22
16
|
attrs: any;
|
|
23
17
|
slots: {
|
|
24
18
|
'button-icon'?: (props: {}) => any;
|
|
@@ -43,6 +37,7 @@ declare const __VLS_export: <V extends PresetPickerValue, R extends DataObject>(
|
|
|
43
37
|
clearValue: () => void;
|
|
44
38
|
setCheckedRowKeys: (keys: (string | number)[]) => void;
|
|
45
39
|
setCheckedRows: (rows: R[]) => void;
|
|
40
|
+
onLoadedRows: (rows: R[]) => void;
|
|
46
41
|
}) => any;
|
|
47
42
|
} & {
|
|
48
43
|
'modal-action'?: (props: {}) => any;
|
|
@@ -54,7 +49,7 @@ declare const __VLS_export: <V extends PresetPickerValue, R extends DataObject>(
|
|
|
54
49
|
'modal-close'?: (props: {}) => any;
|
|
55
50
|
};
|
|
56
51
|
emit: PresetPickerEmits<V, R>;
|
|
57
|
-
}>) =>
|
|
52
|
+
}>) => vue40.VNode & {
|
|
58
53
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
59
54
|
};
|
|
60
55
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,53 +7,67 @@ import { ComponentExposed } from "vue-component-type-helpers";
|
|
|
7
7
|
import { TableSelectionColumn } from "naive-ui/es/data-table/src/interface";
|
|
8
8
|
|
|
9
9
|
//#region src/components/preset-picker/index.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* 预设选择器值类型
|
|
12
|
+
*/
|
|
10
13
|
type PresetPickerValue = string | number | (string | number)[] | null;
|
|
14
|
+
/**
|
|
15
|
+
* 预设选择器暴露的方法
|
|
16
|
+
* @template R 列表项类型
|
|
17
|
+
*/
|
|
11
18
|
type PresetPickerExpose<R extends DataObject = DataObject> = {
|
|
12
|
-
showModalFlag: Ref<boolean, boolean>;
|
|
13
|
-
checkedRowKeys: Ref<(string | number)[], (string | number)[]>;
|
|
14
|
-
checkedRows: Ref<R[], R[]>;
|
|
15
|
-
columns: DataTableColumns<any>;
|
|
16
|
-
showModal: () => void;
|
|
19
|
+
/** 显示模态框标志 */showModalFlag: Ref<boolean, boolean>; /** 选中行键 */
|
|
20
|
+
checkedRowKeys: Ref<(string | number)[], (string | number)[]>; /** 选中行数据 */
|
|
21
|
+
checkedRows: Ref<R[], R[]>; /** 表格列配置 */
|
|
22
|
+
columns: DataTableColumns<any>; /** 显示模态框 */
|
|
23
|
+
showModal: () => void; /** 更新选中行键效果 */
|
|
17
24
|
updateCheckedRowKeysEffect: (keys: (string | number)[], rows: (R | undefined)[], meta: {
|
|
18
25
|
row: R | undefined;
|
|
19
26
|
action: 'check' | 'uncheck' | 'checkAll' | 'uncheckAll';
|
|
20
|
-
}, currentData: R[]) => void;
|
|
21
|
-
clickRowEffect: (row: R) => void;
|
|
22
|
-
clearValue: () => void;
|
|
23
|
-
setCheckedRowKeys: (keys: (string | number)[]) => void;
|
|
27
|
+
}, currentData: R[]) => void; /** 点击行效果 */
|
|
28
|
+
clickRowEffect: (row: R) => void; /** 清空值 */
|
|
29
|
+
clearValue: () => void; /** 设置选中行键 */
|
|
30
|
+
setCheckedRowKeys: (keys: (string | number)[]) => void; /** 设置选中行数据 */
|
|
24
31
|
setCheckedRows: (rows: R[]) => void;
|
|
25
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* 预设选择器属性
|
|
35
|
+
* @template V 值类型
|
|
36
|
+
* @template R 列表项类型
|
|
37
|
+
*/
|
|
26
38
|
type PresetPickerProps<V extends PresetPickerValue, R extends DataObject = DataObject> = {
|
|
27
|
-
value?: V;
|
|
28
|
-
fallbackLabel?: string | ((val: string | number) => string);
|
|
29
|
-
multiple?: boolean;
|
|
30
|
-
disabled?: boolean;
|
|
31
|
-
clearable?: boolean;
|
|
32
|
-
tooltip?: boolean;
|
|
33
|
-
placeholder?: string;
|
|
34
|
-
type?: ButtonProps['type'];
|
|
35
|
-
columns?: DataTableColumns<R>;
|
|
36
|
-
selectionOptions?: TableSelectionColumn;
|
|
39
|
+
/** 值 */value?: V; /** 回退标签 */
|
|
40
|
+
fallbackLabel?: string | ((val: string | number) => string); /** 是否多选 */
|
|
41
|
+
multiple?: boolean; /** 是否禁用 */
|
|
42
|
+
disabled?: boolean; /** 是否可清空 */
|
|
43
|
+
clearable?: boolean; /** 是否显示提示 */
|
|
44
|
+
tooltip?: boolean; /** 占位符 */
|
|
45
|
+
placeholder?: string; /** 按钮类型 */
|
|
46
|
+
type?: ButtonProps['type']; /** 表格列配置 */
|
|
47
|
+
columns?: DataTableColumns<R>; /** 选择列选项 */
|
|
48
|
+
selectionOptions?: TableSelectionColumn; /** 字段映射 */
|
|
37
49
|
fields?: {
|
|
38
50
|
label?: string;
|
|
39
51
|
value?: string;
|
|
40
|
-
};
|
|
41
|
-
buttonProps?: ButtonProps & ClassStyle;
|
|
42
|
-
clearButtonProps?: ButtonProps & ClassStyle;
|
|
43
|
-
badgeProps?: BadgeProps & ClassStyle;
|
|
52
|
+
}; /** 按钮属性 */
|
|
53
|
+
buttonProps?: ButtonProps & ClassStyle; /** 清空按钮属性 */
|
|
54
|
+
clearButtonProps?: ButtonProps & ClassStyle; /** 徽标属性 */
|
|
55
|
+
badgeProps?: BadgeProps & ClassStyle; /** 模态框属性 */
|
|
44
56
|
modalProps?: ModalProps & ClassStyle;
|
|
45
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* 预设选择器事件
|
|
60
|
+
* @template V 值类型
|
|
61
|
+
* @template R 列表项类型
|
|
62
|
+
*/
|
|
46
63
|
type PresetPickerEmits<V extends PresetPickerValue, R extends DataObject = DataObject> = {
|
|
47
|
-
(e: 'update:value', val: V | null, raw: R | R[] | null): void;
|
|
48
|
-
(e: '
|
|
49
|
-
(e: 'afterLeave'): void;
|
|
50
|
-
(e: 'esc'): void;
|
|
51
|
-
(e: 'maskClick'): void;
|
|
52
|
-
(e: 'update:show', value: boolean): void;
|
|
53
|
-
(e: 'close'): void;
|
|
54
|
-
(e: 'negativeClick'): void;
|
|
64
|
+
/** 更新值事件 */(e: 'update:value', val: V | null, raw: R | R[] | null): void; /** 点击取消按钮事件 */
|
|
65
|
+
(e: 'negativeClick'): void; /** 点击确认按钮事件 */
|
|
55
66
|
(e: 'positiveClick'): void;
|
|
56
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* 预设选择器实例类型
|
|
70
|
+
*/
|
|
57
71
|
type PresetPickerInst = ComponentExposed<typeof _default>;
|
|
58
72
|
//#endregion
|
|
59
73
|
export { PresetPickerEmits, PresetPickerExpose, PresetPickerInst, PresetPickerProps, PresetPickerValue };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useDataRequest } from "../../composables/use-data-request.js";
|
|
2
2
|
import { useDebounceFn } from "@vueuse/core";
|
|
3
|
-
import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, reactive, ref, renderSlot, toRaw,
|
|
3
|
+
import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, reactive, ref, renderSlot, toRaw, unref, useTemplateRef, withCtx } from "vue";
|
|
4
4
|
import { NFlex, NPagination, NSelect } from "naive-ui";
|
|
5
5
|
|
|
6
6
|
//#region src/components/preset-select/PresetSelect.vue
|
|
@@ -37,12 +37,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
37
37
|
"success",
|
|
38
38
|
"error",
|
|
39
39
|
"finally",
|
|
40
|
-
"blur",
|
|
41
|
-
"clear",
|
|
42
|
-
"create",
|
|
43
|
-
"focus",
|
|
44
|
-
"scroll",
|
|
45
40
|
"search",
|
|
41
|
+
"update:show",
|
|
46
42
|
"update:value",
|
|
47
43
|
"update:page",
|
|
48
44
|
"update:pageSize"
|
|
@@ -63,7 +59,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
63
59
|
...__props.fields
|
|
64
60
|
};
|
|
65
61
|
const paginationProps = reactive({ ...__props.pagination && typeof __props.pagination === "boolean" ? {} : __props.pagination });
|
|
66
|
-
const _dataCache = [];
|
|
67
62
|
const { loading, data, error, params, list, pagination: paginationRef, run, runAsync, refresh, refreshAsync, cancel, mutate, setParams, runParams, runParamsAsync, onBefore, onSuccess, onError, onFinally } = useDataRequest(__props.api, {
|
|
68
63
|
defaultParams: {
|
|
69
64
|
[_fields.search]: null,
|
|
@@ -79,9 +74,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
79
74
|
});
|
|
80
75
|
onSuccess((data, params) => {
|
|
81
76
|
emit("success", data, params);
|
|
82
|
-
data?.[_fields.list]?.forEach((f) => {
|
|
83
|
-
if (!_dataCache.some((s) => s?.[_fields.rowKey] === f?.[_fields.rowKey])) _dataCache.push(f);
|
|
84
|
-
});
|
|
85
77
|
});
|
|
86
78
|
onError((err, params) => {
|
|
87
79
|
emit("error", err, params);
|
|
@@ -90,7 +82,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
90
82
|
emit("finally", params, data, err);
|
|
91
83
|
});
|
|
92
84
|
const optionsReactive = computed(() => {
|
|
93
|
-
|
|
85
|
+
if (typeof __props.optionFormat === "function") return list.value.map((m) => __props.optionFormat(m)).filter(Boolean);
|
|
86
|
+
return list.value.map((m) => {
|
|
94
87
|
return {
|
|
95
88
|
[_fields.label]: m?.[_fields.label],
|
|
96
89
|
[_fields.value]: m?.[_fields.value],
|
|
@@ -106,55 +99,36 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
106
99
|
});
|
|
107
100
|
}, typeof __props.debounce === "number" ? __props.debounce : 500);
|
|
108
101
|
const vOnSelect = {
|
|
109
|
-
onBlur: (ev) => {
|
|
110
|
-
emit("blur", ev);
|
|
111
|
-
},
|
|
112
|
-
onClear: () => {
|
|
113
|
-
emit("clear");
|
|
114
|
-
},
|
|
115
|
-
onCreate: (label) => {
|
|
116
|
-
return emit("create", label);
|
|
117
|
-
},
|
|
118
|
-
onFocus: (ev) => {
|
|
119
|
-
emit("focus", ev);
|
|
120
|
-
},
|
|
121
|
-
onScroll: (ev) => {
|
|
122
|
-
emit("scroll", ev);
|
|
123
|
-
},
|
|
124
102
|
onUpdateValue: (val, option) => {
|
|
125
|
-
emit("update:value", val, option, toRaw(
|
|
103
|
+
emit("update:value", val, option, toRaw(Array.isArray(val) ? list.value.filter((f) => val.includes(f?.[_fields.value])) : list.value.find((f) => f?.[_fields.value] === val) ?? null));
|
|
126
104
|
},
|
|
127
105
|
onSearch: (val) => {
|
|
106
|
+
emit("search", val);
|
|
128
107
|
searchValue.value = val;
|
|
129
108
|
if (loading.value) return;
|
|
130
109
|
__props.debounce ? debounceSearch() : runParams({
|
|
131
110
|
[_fields.page]: 1,
|
|
132
|
-
[_fields.search]:
|
|
111
|
+
[_fields.search]: val
|
|
133
112
|
});
|
|
134
113
|
},
|
|
135
114
|
onUpdateShow: (show) => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
115
|
+
emit("update:show", show);
|
|
116
|
+
if (show && !data.value && __props.manual) runParams({
|
|
117
|
+
[_fields.page]: 1,
|
|
118
|
+
[_fields.pageSize]: 10,
|
|
119
|
+
[_fields.search]: null,
|
|
120
|
+
...__props.defaultParams ?? {}
|
|
121
|
+
});
|
|
146
122
|
}
|
|
147
123
|
};
|
|
148
124
|
const vOnPagination = {
|
|
149
125
|
onUpdatePage: (page) => {
|
|
150
126
|
emit("update:page", page);
|
|
151
|
-
if (loading.value)
|
|
152
|
-
runParams({ [_fields.page]: page });
|
|
127
|
+
if (!loading.value) runParams({ [_fields.page]: page });
|
|
153
128
|
},
|
|
154
129
|
onUpdatePageSize: (pageSize) => {
|
|
155
130
|
emit("update:pageSize", pageSize);
|
|
156
|
-
if (loading.value)
|
|
157
|
-
runParams({ [_fields.pageSize]: pageSize });
|
|
131
|
+
if (!loading.value) runParams({ [_fields.pageSize]: pageSize });
|
|
158
132
|
}
|
|
159
133
|
};
|
|
160
134
|
function fallbackOption(val) {
|
|
@@ -188,13 +162,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
188
162
|
const templateBind = computed(() => {
|
|
189
163
|
return {
|
|
190
164
|
...expose,
|
|
191
|
-
loading:
|
|
192
|
-
data:
|
|
193
|
-
error:
|
|
194
|
-
params:
|
|
195
|
-
list:
|
|
196
|
-
pagination:
|
|
197
|
-
selectInst:
|
|
165
|
+
loading: loading.value,
|
|
166
|
+
data: data.value,
|
|
167
|
+
error: error.value,
|
|
168
|
+
params: params.value,
|
|
169
|
+
list: list.value,
|
|
170
|
+
pagination: paginationRef.value,
|
|
171
|
+
selectInst: selectInstRef.value
|
|
198
172
|
};
|
|
199
173
|
});
|
|
200
174
|
__expose(expose);
|
|
@@ -214,11 +188,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
214
188
|
"fallback-option": fallbackOption,
|
|
215
189
|
loading: unref(loading)
|
|
216
190
|
}, __props.selectProps, {
|
|
217
|
-
onBlur: vOnSelect.onBlur,
|
|
218
|
-
onClear: vOnSelect.onClear,
|
|
219
|
-
onCreate: vOnSelect.onCreate,
|
|
220
|
-
onFocus: vOnSelect.onFocus,
|
|
221
|
-
onScroll: vOnSelect.onScroll,
|
|
222
191
|
onSearch: vOnSelect.onSearch,
|
|
223
192
|
"onUpdate:show": vOnSelect.onUpdateShow,
|
|
224
193
|
"onUpdate:value": vOnSelect.onUpdateValue
|
|
@@ -256,11 +225,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
256
225
|
"children-field",
|
|
257
226
|
"value",
|
|
258
227
|
"loading",
|
|
259
|
-
"onBlur",
|
|
260
|
-
"onClear",
|
|
261
|
-
"onCreate",
|
|
262
|
-
"onFocus",
|
|
263
|
-
"onScroll",
|
|
264
228
|
"onSearch",
|
|
265
229
|
"onUpdate:show",
|
|
266
230
|
"onUpdate:value"
|