@movk/nuxt 1.3.0 → 1.4.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/.nuxt/movk-ui.css +1 -1
- package/README.md +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +12 -2
- package/dist/runtime/components/AutoForm.vue +7 -2
- package/dist/runtime/components/ColorChooser.d.vue.ts +2 -2
- package/dist/runtime/components/ColorChooser.vue.d.ts +2 -2
- package/dist/runtime/components/DataTable.d.vue.ts +2 -2
- package/dist/runtime/components/DataTable.vue +38 -10
- package/dist/runtime/components/DataTable.vue.d.ts +2 -2
- package/dist/runtime/components/DatePicker.d.vue.ts +3 -3
- package/dist/runtime/components/DatePicker.vue +1 -1
- package/dist/runtime/components/DatePicker.vue.d.ts +3 -3
- package/dist/runtime/components/PillGroup.d.vue.ts +1 -1
- package/dist/runtime/components/PillGroup.vue.d.ts +1 -1
- package/dist/runtime/components/SearchForm.d.vue.ts +3 -3
- package/dist/runtime/components/SearchForm.vue +14 -5
- package/dist/runtime/components/SearchForm.vue.d.ts +3 -3
- package/dist/runtime/components/StarRating.d.vue.ts +2 -2
- package/dist/runtime/components/StarRating.vue.d.ts +2 -2
- package/dist/runtime/components/Tree.d.vue.ts +44 -0
- package/dist/runtime/components/Tree.vue +332 -0
- package/dist/runtime/components/Tree.vue.d.ts +44 -0
- package/dist/runtime/composables/useDateFormatter.js +7 -5
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +6 -5
- package/dist/runtime/composables/useDownloadWithProgress.js +4 -16
- package/dist/runtime/composables/useTheme.d.ts +14 -12
- package/dist/runtime/composables/useUploadWithProgress.d.ts +6 -5
- package/dist/runtime/composables/useUploadWithProgress.js +4 -16
- package/dist/runtime/domains/auto-form/controls.d.ts +651 -11
- package/dist/runtime/domains/auto-form/controls.js +1 -0
- package/dist/runtime/domains/auto-form/provider.js +3 -2
- package/dist/runtime/domains/auto-form/schema.d.ts +5 -0
- package/dist/runtime/domains/auto-form/schema.js +13 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +34 -2
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +1 -1
- package/dist/runtime/domains/data-table/columns/style.js +4 -3
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +1 -1
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +1 -1
- package/dist/runtime/domains/tree/components/TreeToolbar.d.vue.ts +43 -0
- package/dist/runtime/domains/tree/components/TreeToolbar.vue +76 -0
- package/dist/runtime/domains/tree/components/TreeToolbar.vue.d.ts +43 -0
- package/dist/runtime/domains/tree/resolve-tree.d.ts +14 -0
- package/dist/runtime/domains/tree/resolve-tree.js +16 -0
- package/dist/runtime/domains/tree/tree-lazy.d.ts +20 -0
- package/dist/runtime/domains/tree/tree-lazy.js +19 -0
- package/dist/runtime/domains/tree/tree-search.d.ts +6 -0
- package/dist/runtime/domains/tree/tree-search.js +5 -0
- package/dist/runtime/types/auto-form/search-form.d.ts +3 -3
- package/dist/runtime/types/components/index.d.ts +1 -0
- package/dist/runtime/types/components/message-box.d.ts +3 -3
- package/dist/runtime/types/components/tree.d.ts +134 -0
- package/dist/runtime/types/components/tree.js +0 -0
- package/dist/runtime/types/data-table/columns.d.ts +1 -17
- package/dist/runtime/types/data-table/component.d.ts +5 -0
- package/dist/runtime/types/shared.d.ts +13 -0
- package/dist/runtime/utils/extend-theme.d.ts +2 -2
- package/dist/runtime/utils/tree-expand.d.ts +22 -0
- package/dist/runtime/utils/tree-expand.js +18 -0
- package/dist/runtime/utils/tree-selection.d.ts +37 -0
- package/dist/runtime/utils/tree-selection.js +59 -0
- package/dist/shared/{nuxt.DfBEyjld.mjs → nuxt.CXM2nhP4.mjs} +76 -4
- package/dist/unplugin.d.mts +4 -2
- package/dist/unplugin.mjs +1 -35
- package/dist/vite.mjs +1 -1
- package/package.json +21 -21
- package/dist/runtime/domains/data-table/tree-selection.d.ts +0 -9
- package/dist/runtime/domains/data-table/tree-selection.js +0 -76
|
@@ -98,9 +98,10 @@ export function useAutoFormProvider(state, slots) {
|
|
|
98
98
|
{
|
|
99
99
|
...wrappedProps,
|
|
100
100
|
"onUpdate:modelValue": (v) => {
|
|
101
|
-
|
|
101
|
+
const next = v === null && field.decorators?.isOptional ? void 0 : v;
|
|
102
|
+
context.setValue(next);
|
|
102
103
|
if (typeof userOnUpdate === "function") {
|
|
103
|
-
userOnUpdate(
|
|
104
|
+
userOnUpdate(next, context);
|
|
104
105
|
}
|
|
105
106
|
},
|
|
106
107
|
"modelValue": unref(context.value)
|
|
@@ -5,3 +5,8 @@ import type { ZodAutoFormFieldMeta } from '../../types/zod';
|
|
|
5
5
|
export declare function introspectSchema(schema: z.ZodType, mapping: AutoFormControls, path: string, globalMeta?: ZodAutoFormFieldMeta): AutoFormField[];
|
|
6
6
|
/** 将含布局标记的 schema 还原为纯字段 schema,用于 Zod 表单校验 */
|
|
7
7
|
export declare function extractPureSchema<T extends z.ZodObject<any, any>>(schema: T): z.ZodObject<any, any>;
|
|
8
|
+
/**
|
|
9
|
+
* 从校验 schema 中剔除指定顶层字段。
|
|
10
|
+
* 用于让 meta.if 隐藏的字段不参与校验,使校验集与渲染保持一致。
|
|
11
|
+
*/
|
|
12
|
+
export declare function omitFields(schema: z.ZodObject<any, any>, keys: string[]): z.ZodObject<any, any>;
|
|
@@ -205,3 +205,16 @@ export function extractPureSchema(schema) {
|
|
|
205
205
|
const pureShape = processLayoutShape(shape);
|
|
206
206
|
return zod.object(pureShape);
|
|
207
207
|
}
|
|
208
|
+
export function omitFields(schema, keys) {
|
|
209
|
+
const shape = schema.shape;
|
|
210
|
+
if (!shape || typeof shape !== "object") {
|
|
211
|
+
return schema;
|
|
212
|
+
}
|
|
213
|
+
const present = keys.filter((key) => key in shape);
|
|
214
|
+
if (!present.length) {
|
|
215
|
+
return schema;
|
|
216
|
+
}
|
|
217
|
+
const mask = {};
|
|
218
|
+
for (const key of present) mask[key] = true;
|
|
219
|
+
return schema.omit(mask);
|
|
220
|
+
}
|
|
@@ -110,10 +110,42 @@ export function renderHeaderActions(ctx, col, options, label, sortable, pinable,
|
|
|
110
110
|
if (sortable) actions.push(buildSortAction(col, options));
|
|
111
111
|
const leading = actions.filter((a) => a.position === "leading").map((a) => a.render(ctx));
|
|
112
112
|
const trailing = actions.filter((a) => a.position === "trailing").map((a) => a.render(ctx));
|
|
113
|
+
const startResize = (e) => {
|
|
114
|
+
const id = ctx.column.id;
|
|
115
|
+
const seeded = !(id in ctx.table.getState().columnSizing);
|
|
116
|
+
if (seeded) {
|
|
117
|
+
const th = e.currentTarget?.closest("th");
|
|
118
|
+
const w = th ? Math.round(th.getBoundingClientRect().width) : 0;
|
|
119
|
+
if (w > 0) ctx.table.setColumnSizing((prev) => ({ ...prev, [id]: w }));
|
|
120
|
+
}
|
|
121
|
+
ctx.header.getResizeHandler()(e);
|
|
122
|
+
if (!seeded) return;
|
|
123
|
+
const startX = "touches" in e ? e.touches[0]?.clientX ?? 0 : e.clientX;
|
|
124
|
+
let moved = false;
|
|
125
|
+
const onMove = (ev) => {
|
|
126
|
+
const x = "touches" in ev ? ev.touches[0]?.clientX : ev.clientX;
|
|
127
|
+
if (typeof x === "number" && Math.abs(x - startX) > 2) moved = true;
|
|
128
|
+
};
|
|
129
|
+
const onEnd = () => {
|
|
130
|
+
if (!moved) {
|
|
131
|
+
ctx.table.setColumnSizing(
|
|
132
|
+
(prev) => Object.fromEntries(Object.entries(prev).filter(([key]) => key !== id))
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
window.removeEventListener("mousemove", onMove);
|
|
136
|
+
window.removeEventListener("mouseup", onEnd);
|
|
137
|
+
window.removeEventListener("touchmove", onMove);
|
|
138
|
+
window.removeEventListener("touchend", onEnd);
|
|
139
|
+
};
|
|
140
|
+
window.addEventListener("mousemove", onMove);
|
|
141
|
+
window.addEventListener("mouseup", onEnd);
|
|
142
|
+
window.addEventListener("touchmove", onMove);
|
|
143
|
+
window.addEventListener("touchend", onEnd);
|
|
144
|
+
};
|
|
113
145
|
const resizeHandle = resizable ? h("div", {
|
|
114
146
|
class: "absolute top-0 bottom-0 right-0 w-4 -mr-2 cursor-col-resize select-none touch-none flex items-center justify-center group/resize",
|
|
115
|
-
onMousedown:
|
|
116
|
-
onTouchstart:
|
|
147
|
+
onMousedown: startResize,
|
|
148
|
+
onTouchstart: startResize,
|
|
117
149
|
onClick: (e) => e.stopPropagation()
|
|
118
150
|
}, [
|
|
119
151
|
h("div", {
|
|
@@ -36,7 +36,7 @@ function buildSpecialColumnDef(col, type, ctx, render) {
|
|
|
36
36
|
if (col.visibility === false) ctx.visibility[id] = false;
|
|
37
37
|
ctx.allColumnIds.push(id);
|
|
38
38
|
const effectivePinable = col.pinable ?? options.pinable === true;
|
|
39
|
-
const effectiveResizable = col.resizable ??
|
|
39
|
+
const effectiveResizable = col.resizable ?? false;
|
|
40
40
|
ctx.flags.hasPinning ||= effectivePinable;
|
|
41
41
|
ctx.flags.hasResizing ||= effectiveResizable;
|
|
42
42
|
const effectiveAlign = col.align ?? defaults.align;
|
|
@@ -3,9 +3,10 @@ import { resolvePresetSize } from "./utils.js";
|
|
|
3
3
|
export function resolveColumnSize(ctx) {
|
|
4
4
|
const { columnDef } = ctx.column;
|
|
5
5
|
const table = ctx.getContext().table;
|
|
6
|
-
const isPinned = ctx.column.getIsPinned();
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
const isPinned = !!ctx.column.getIsPinned();
|
|
7
|
+
const isSized = ctx.column.id in table.getState().columnSizing;
|
|
8
|
+
const hasExplicitSize = columnDef.size != table._getDefaultColumnDef().size;
|
|
9
|
+
if (isPinned || isSized || hasExplicitSize) {
|
|
9
10
|
const w = `${ctx.column.getSize()}px`;
|
|
10
11
|
return { width: w, minWidth: w, maxWidth: w };
|
|
11
12
|
}
|
|
@@ -4,7 +4,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
4
4
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<DataTablePaginationProps<T> & {
|
|
5
5
|
uiConfig?: DataTablePaginationUi & {
|
|
6
6
|
ui?: {
|
|
7
|
-
[x: string]: import("
|
|
7
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
}> & (typeof globalThis extends {
|
|
@@ -4,7 +4,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
4
4
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<DataTablePaginationProps<T> & {
|
|
5
5
|
uiConfig?: DataTablePaginationUi & {
|
|
6
6
|
ui?: {
|
|
7
|
-
[x: string]: import("
|
|
7
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
}> & (typeof globalThis extends {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TreeProps, TreeSelectionSummary } from '../../../types/components/tree';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** 是否渲染展开/折叠切换与全选控件 */
|
|
4
|
+
toolbar?: boolean;
|
|
5
|
+
searchable?: boolean;
|
|
6
|
+
checkable?: boolean;
|
|
7
|
+
search?: string;
|
|
8
|
+
size?: TreeProps['size'];
|
|
9
|
+
color?: TreeProps['color'];
|
|
10
|
+
/** 是否已全部展开,驱动展开/折叠切换按钮 */
|
|
11
|
+
expanded?: boolean;
|
|
12
|
+
selectionSummary?: TreeSelectionSummary;
|
|
13
|
+
ui: {
|
|
14
|
+
toolbar?: string;
|
|
15
|
+
toolbarButton?: string;
|
|
16
|
+
search?: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
declare var __VLS_1: {}, __VLS_39: {};
|
|
20
|
+
type __VLS_Slots = {} & {
|
|
21
|
+
leading?: (props: typeof __VLS_1) => any;
|
|
22
|
+
} & {
|
|
23
|
+
trailing?: (props: typeof __VLS_39) => any;
|
|
24
|
+
};
|
|
25
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
26
|
+
clear: () => any;
|
|
27
|
+
"select-all": () => any;
|
|
28
|
+
"update:search": (value: string) => any;
|
|
29
|
+
"toggle-expand": () => any;
|
|
30
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
31
|
+
onClear?: (() => any) | undefined;
|
|
32
|
+
"onSelect-all"?: (() => any) | undefined;
|
|
33
|
+
"onUpdate:search"?: ((value: string) => any) | undefined;
|
|
34
|
+
"onToggle-expand"?: (() => any) | undefined;
|
|
35
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
36
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
37
|
+
declare const _default: typeof __VLS_export;
|
|
38
|
+
export default _default;
|
|
39
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
40
|
+
new (): {
|
|
41
|
+
$slots: S;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { UButton, UCheckbox, UInput, UTooltip } from "#components";
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
toolbar: { type: Boolean, required: false },
|
|
6
|
+
searchable: { type: Boolean, required: false },
|
|
7
|
+
checkable: { type: Boolean, required: false },
|
|
8
|
+
search: { type: String, required: false },
|
|
9
|
+
size: { type: null, required: false },
|
|
10
|
+
color: { type: null, required: false },
|
|
11
|
+
expanded: { type: Boolean, required: false },
|
|
12
|
+
selectionSummary: { type: Object, required: false },
|
|
13
|
+
ui: { type: Object, required: true }
|
|
14
|
+
});
|
|
15
|
+
const emit = defineEmits(["update:search", "toggle-expand", "select-all", "clear"]);
|
|
16
|
+
const checkboxLabel = computed(() => {
|
|
17
|
+
const count = props.selectionSummary?.checkedCount ?? 0;
|
|
18
|
+
return count > 0 ? `\u5DF2\u9009 ${count}` : "\u5168\u9009";
|
|
19
|
+
});
|
|
20
|
+
const expandTooltip = computed(() => props.expanded ? "\u6298\u53E0\u5168\u90E8" : "\u5C55\u5F00\u5168\u90E8");
|
|
21
|
+
function onToggleAll(checked) {
|
|
22
|
+
if (checked) emit("select-all");
|
|
23
|
+
else emit("clear");
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<div :class="ui.toolbar">
|
|
29
|
+
<slot name="leading" />
|
|
30
|
+
|
|
31
|
+
<UInput
|
|
32
|
+
v-if="searchable"
|
|
33
|
+
:model-value="search"
|
|
34
|
+
icon="i-lucide-search"
|
|
35
|
+
placeholder="搜索节点"
|
|
36
|
+
:size="size"
|
|
37
|
+
:class="ui.search"
|
|
38
|
+
@update:model-value="emit('update:search', String($event))"
|
|
39
|
+
>
|
|
40
|
+
<template v-if="search" #trailing>
|
|
41
|
+
<UButton
|
|
42
|
+
icon="i-lucide-x"
|
|
43
|
+
color="neutral"
|
|
44
|
+
variant="link"
|
|
45
|
+
:size="size"
|
|
46
|
+
aria-label="清除搜索"
|
|
47
|
+
@click="emit('update:search', '')"
|
|
48
|
+
/>
|
|
49
|
+
</template>
|
|
50
|
+
</UInput>
|
|
51
|
+
|
|
52
|
+
<UTooltip v-if="toolbar" :text="expandTooltip">
|
|
53
|
+
<UButton
|
|
54
|
+
:icon="expanded ? 'i-lucide-chevrons-down-up' : 'i-lucide-chevrons-up-down'"
|
|
55
|
+
color="neutral"
|
|
56
|
+
variant="ghost"
|
|
57
|
+
:size="size"
|
|
58
|
+
:class="ui.toolbarButton"
|
|
59
|
+
:aria-label="expandTooltip"
|
|
60
|
+
@click="emit('toggle-expand')"
|
|
61
|
+
/>
|
|
62
|
+
</UTooltip>
|
|
63
|
+
|
|
64
|
+
<UCheckbox
|
|
65
|
+
v-if="toolbar && checkable"
|
|
66
|
+
:model-value="selectionSummary?.allChecked ?? false"
|
|
67
|
+
:indeterminate="selectionSummary?.indeterminate ?? false"
|
|
68
|
+
:size="size"
|
|
69
|
+
:color="color"
|
|
70
|
+
:label="checkboxLabel"
|
|
71
|
+
@update:model-value="onToggleAll(Boolean($event))"
|
|
72
|
+
/>
|
|
73
|
+
|
|
74
|
+
<slot name="trailing" />
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TreeProps, TreeSelectionSummary } from '../../../types/components/tree';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** 是否渲染展开/折叠切换与全选控件 */
|
|
4
|
+
toolbar?: boolean;
|
|
5
|
+
searchable?: boolean;
|
|
6
|
+
checkable?: boolean;
|
|
7
|
+
search?: string;
|
|
8
|
+
size?: TreeProps['size'];
|
|
9
|
+
color?: TreeProps['color'];
|
|
10
|
+
/** 是否已全部展开,驱动展开/折叠切换按钮 */
|
|
11
|
+
expanded?: boolean;
|
|
12
|
+
selectionSummary?: TreeSelectionSummary;
|
|
13
|
+
ui: {
|
|
14
|
+
toolbar?: string;
|
|
15
|
+
toolbarButton?: string;
|
|
16
|
+
search?: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
declare var __VLS_1: {}, __VLS_39: {};
|
|
20
|
+
type __VLS_Slots = {} & {
|
|
21
|
+
leading?: (props: typeof __VLS_1) => any;
|
|
22
|
+
} & {
|
|
23
|
+
trailing?: (props: typeof __VLS_39) => any;
|
|
24
|
+
};
|
|
25
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
26
|
+
clear: () => any;
|
|
27
|
+
"select-all": () => any;
|
|
28
|
+
"update:search": (value: string) => any;
|
|
29
|
+
"toggle-expand": () => any;
|
|
30
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
31
|
+
onClear?: (() => any) | undefined;
|
|
32
|
+
"onSelect-all"?: (() => any) | undefined;
|
|
33
|
+
"onUpdate:search"?: ((value: string) => any) | undefined;
|
|
34
|
+
"onToggle-expand"?: (() => any) | undefined;
|
|
35
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
36
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
37
|
+
declare const _default: typeof __VLS_export;
|
|
38
|
+
export default _default;
|
|
39
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
40
|
+
new (): {
|
|
41
|
+
$slots: S;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type AnyNode = Record<string, any>;
|
|
2
|
+
/**
|
|
3
|
+
* 构造与 UTree 一致的取键函数
|
|
4
|
+
*
|
|
5
|
+
* 复刻 UTree:提供 getKey 时取其返回值(为空则回退 label),否则取 labelKey 字段。
|
|
6
|
+
*/
|
|
7
|
+
export declare function createGetKey<T extends AnyNode>(getKey?: (node: T) => string, labelKey?: string): (node: T) => string;
|
|
8
|
+
/**
|
|
9
|
+
* 将自定义 childrenKey 归一化为 UTree 的 children 字段(UTree 写死 children)
|
|
10
|
+
*
|
|
11
|
+
* childrenKey 为默认 children 时原样返回(零拷贝);否则深拷贝重命名并移除原字段,不修改入参。
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeChildren<T extends AnyNode>(items: T[], childrenKey?: string): T[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function createGetKey(getKey, labelKey = "label") {
|
|
2
|
+
return (node) => {
|
|
3
|
+
const label = node[labelKey];
|
|
4
|
+
const key = getKey ? getKey(node) || label : label;
|
|
5
|
+
return String(key);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function normalizeChildren(items, childrenKey = "children") {
|
|
9
|
+
if (childrenKey === "children") return items;
|
|
10
|
+
return items.map((node) => {
|
|
11
|
+
const raw = node[childrenKey];
|
|
12
|
+
const { [childrenKey]: _omit, ...rest } = node;
|
|
13
|
+
if (!Array.isArray(raw)) return rest;
|
|
14
|
+
return { ...rest, children: normalizeChildren(raw, childrenKey) };
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type AnyNode = Record<string, any>;
|
|
2
|
+
/** 懒加载占位节点标记字段 */
|
|
3
|
+
export declare const PLACEHOLDER_FLAG = "__movkLazyPlaceholder";
|
|
4
|
+
/**
|
|
5
|
+
* 懒加载节点的稳定内部 key 字段
|
|
6
|
+
*
|
|
7
|
+
* 取值为 getKey(node),供 Tree.updateNode 按字段匹配定位节点。getKey 可被用户自定义,
|
|
8
|
+
* 而 updateNode 仅支持按字段名匹配,写入此字段后无论 getKey 与 labelKey 是否一致都能命中。
|
|
9
|
+
*/
|
|
10
|
+
export declare const LAZY_KEY_FIELD = "__movkKey";
|
|
11
|
+
/** 判断节点是否为懒加载占位 */
|
|
12
|
+
export declare function isPlaceholder(node: AnyNode): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 为懒加载父节点注入占位子节点
|
|
15
|
+
*
|
|
16
|
+
* UTree 仅在 `children.length` 为真时渲染展开箭头;对 `children` 未加载(缺省)且非叶子的节点,
|
|
17
|
+
* 注入一个占位子节点使其可展开。展开时再由 `Tree.updateNode` 用真实子节点替换。不修改入参。
|
|
18
|
+
*/
|
|
19
|
+
export declare function markLazyPlaceholders<T extends AnyNode>(items: T[], getKey: (node: T) => string, labelKey?: string): T[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const PLACEHOLDER_FLAG = "__movkLazyPlaceholder";
|
|
2
|
+
export const LAZY_KEY_FIELD = "__movkKey";
|
|
3
|
+
export function isPlaceholder(node) {
|
|
4
|
+
return !!node[PLACEHOLDER_FLAG];
|
|
5
|
+
}
|
|
6
|
+
export function markLazyPlaceholders(items, getKey, labelKey = "label") {
|
|
7
|
+
return items.map((node) => {
|
|
8
|
+
const children = node.children;
|
|
9
|
+
if (Array.isArray(children)) {
|
|
10
|
+
return { ...node, [LAZY_KEY_FIELD]: getKey(node), children: markLazyPlaceholders(children, getKey, labelKey) };
|
|
11
|
+
}
|
|
12
|
+
if (node.isLeaf) return node;
|
|
13
|
+
const placeholder = {
|
|
14
|
+
[labelKey]: `${PLACEHOLDER_FLAG}:${getKey(node)}`,
|
|
15
|
+
[PLACEHOLDER_FLAG]: true
|
|
16
|
+
};
|
|
17
|
+
return { ...node, [LAZY_KEY_FIELD]: getKey(node), children: [placeholder] };
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -69,9 +69,9 @@ export interface SearchFormProps<S extends z.ZodObject> extends BaseAutoFormProp
|
|
|
69
69
|
*/
|
|
70
70
|
defaultExpanded?: boolean;
|
|
71
71
|
}
|
|
72
|
-
export interface SearchFormEmits {
|
|
73
|
-
'reset': [];
|
|
74
|
-
'clear': [];
|
|
72
|
+
export interface SearchFormEmits<S extends z.ZodObject = z.ZodObject> {
|
|
73
|
+
'reset': [state: Partial<InferInput<S>>];
|
|
74
|
+
'clear': [state: Partial<InferInput<S>>];
|
|
75
75
|
'expand': [expanded: boolean];
|
|
76
76
|
'update:expanded': [expanded: boolean];
|
|
77
77
|
'error': [event: FormErrorEvent];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { ColorChooserEmits, ColorChooserProps, ColorChooserSlots, ColorChooserTrigger, ColorFormat } from './color-chooser';
|
|
2
2
|
export type { DatePickerEmits, DatePickerLabelFormatter, DatePickerPreset, DatePickerProps, FormattedValue, LabelFormat, ValueFormat } from './date-picker';
|
|
3
3
|
export type { MessageBoxEmits, MessageBoxProps, MessageBoxSlots } from './message-box';
|
|
4
|
+
export type { MTreeItem, TreeEmits, TreeExposed, TreeFilter, TreeItem, TreeLoadChildren, TreeProps, TreeSelectionResult, TreeSelectionStrategy, TreeSelectionSummary, TreeSlots } from './tree';
|
|
4
5
|
export type { PopconfirmEmits, PopconfirmProps, PopconfirmSlots } from './popconfirm';
|
|
5
6
|
export type { SlideVerifyEmits, SlideVerifyProps, SlideVerifySlots } from './slide-verify';
|
|
6
7
|
export type { StarRatingEmits, StarRatingProps } from './star-rating';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ButtonProps, IconProps, ModalProps, ModalSlots } from '@nuxt/ui';
|
|
1
|
+
import type { ButtonProps, IconProps, ModalProps, ModalSlots, SlotClass } from '@nuxt/ui';
|
|
2
2
|
import type { OmitByKey } from '@movk/core';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SemanticColor } from '../shared';
|
|
4
4
|
export interface MessageBoxProps extends /** @vue-ignore */ OmitByKey<ModalProps, 'title' | 'open' | 'defaultOpen' | 'dismissible' | 'ui'> {
|
|
5
5
|
/**
|
|
6
6
|
* 模态框标题文本。
|
|
@@ -55,7 +55,7 @@ export interface MessageBoxProps extends /** @vue-ignore */ OmitByKey<ModalProps
|
|
|
55
55
|
* 仅在 `mode='confirm'` 时渲染。
|
|
56
56
|
*/
|
|
57
57
|
cancelButton?: ButtonProps;
|
|
58
|
-
ui?: Record<string,
|
|
58
|
+
ui?: Record<string, SlotClass>;
|
|
59
59
|
}
|
|
60
60
|
export interface MessageBoxEmits {
|
|
61
61
|
/**
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { TreeEmits as NuxtTreeEmits, TreeProps as NuxtTreeProps, TreeSlots as NuxtTreeSlots, TreeItem } from '@nuxt/ui';
|
|
2
|
+
import type { OmitByKey } from '@movk/core';
|
|
3
|
+
import type { VNode } from 'vue';
|
|
4
|
+
import type { ClassNameValue, TreeSelectionResult } from '../shared';
|
|
5
|
+
export type { TreeSelectionResult } from '../shared';
|
|
6
|
+
export type { TreeItem } from '@nuxt/ui';
|
|
7
|
+
/** 在 UTree 节点基础上补充懒加载叶子标识 */
|
|
8
|
+
export interface MTreeItem extends TreeItem {
|
|
9
|
+
/** 标记节点为叶子,懒加载模式下不渲染展开占位 */
|
|
10
|
+
isLeaf?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** 搜索匹配谓词,返回 true 表示该节点命中关键字 */
|
|
13
|
+
export type TreeFilter<T extends TreeItem = TreeItem> = (node: T, term: string) => boolean;
|
|
14
|
+
/** 异步加载子节点,返回该节点的子节点数组 */
|
|
15
|
+
export type TreeLoadChildren<T extends TreeItem = TreeItem> = (node: T) => Promise<T[]>;
|
|
16
|
+
export interface TreeProps<T extends TreeItem[] = TreeItem[], M extends boolean = false> extends /** @vue-ignore */ OmitByKey<NuxtTreeProps<T, M>, 'ui' | 'defaultExpanded'> {
|
|
17
|
+
/** 树数据源,按 childrenKey 解析层级 */
|
|
18
|
+
items?: T;
|
|
19
|
+
/**
|
|
20
|
+
* 取子节点数组的字段名,归一化为 UTree 的 children
|
|
21
|
+
* @defaultValue 'children'
|
|
22
|
+
*/
|
|
23
|
+
childrenKey?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 展示字段名
|
|
26
|
+
* @defaultValue 'label'
|
|
27
|
+
*/
|
|
28
|
+
labelKey?: NuxtTreeProps<T, M>['labelKey'];
|
|
29
|
+
/** 自定义节点 key,缺省取 labelKey 字段值 */
|
|
30
|
+
getKey?: NuxtTreeProps<T, M>['getKey'];
|
|
31
|
+
/**
|
|
32
|
+
* 初始展开策略,缺省回退节点上的 defaultExpanded 标记
|
|
33
|
+
* - true 展开全部父级
|
|
34
|
+
* - number 展开 depth 小于该值的父级
|
|
35
|
+
* - 函数 按节点与深度自定义
|
|
36
|
+
*/
|
|
37
|
+
defaultExpanded?: boolean | number | ((node: T[number], depth: number) => boolean);
|
|
38
|
+
/** 选中节点 key 列表,可用 v-model:selectedKeys 双向绑定 */
|
|
39
|
+
selectedKeys?: string[];
|
|
40
|
+
/** 开启多选 */
|
|
41
|
+
multiple?: M & boolean;
|
|
42
|
+
/**
|
|
43
|
+
* 多选 / checkable 下的父子勾选策略
|
|
44
|
+
* - 'cascade' 父子级联(propagateSelect + bubbleSelect)
|
|
45
|
+
* - 'isolated' 父子互不关联
|
|
46
|
+
* @defaultValue 'cascade'
|
|
47
|
+
*/
|
|
48
|
+
strategy?: TreeSelectionStrategy;
|
|
49
|
+
/** 选中父节点时级联选中子节点。cascade 策略下默认开启,显式 true 可在 isolated 下强制开启;关闭级联请用 strategy='isolated' */
|
|
50
|
+
propagateSelect?: NuxtTreeProps<T, M>['propagateSelect'];
|
|
51
|
+
/** 子节点全部选中时回填父节点。cascade 策略下默认开启,显式 true 可在 isolated 下强制开启;关闭级联请用 strategy='isolated' */
|
|
52
|
+
bubbleSelect?: NuxtTreeProps<T, M>['bubbleSelect'];
|
|
53
|
+
/** 尺寸 */
|
|
54
|
+
size?: NuxtTreeProps<T, M>['size'];
|
|
55
|
+
/** 主色 */
|
|
56
|
+
color?: NuxtTreeProps<T, M>['color'];
|
|
57
|
+
/** 开启顶部搜索过滤 */
|
|
58
|
+
searchable?: boolean;
|
|
59
|
+
/** 自定义匹配谓词,缺省按 labelKey 文本不区分大小写包含匹配 */
|
|
60
|
+
filter?: TreeFilter<T[number]>;
|
|
61
|
+
/**
|
|
62
|
+
* 高亮命中文本,仅在 searchable 时生效
|
|
63
|
+
* @defaultValue true
|
|
64
|
+
*/
|
|
65
|
+
highlight?: boolean;
|
|
66
|
+
/** 开启异步懒加载子节点 */
|
|
67
|
+
lazy?: boolean;
|
|
68
|
+
/** 懒加载回调,展开未加载的父节点时调用 */
|
|
69
|
+
loadChildren?: TreeLoadChildren<T[number]>;
|
|
70
|
+
/** 开启顶部工具栏(展开/折叠,checkable 时附带全选/清空) */
|
|
71
|
+
toolbar?: boolean;
|
|
72
|
+
/** 渲染复选框并启用多选(multiple + strategy,默认 cascade) */
|
|
73
|
+
checkable?: M & boolean;
|
|
74
|
+
ui?: Record<string, ClassNameValue>;
|
|
75
|
+
}
|
|
76
|
+
/** 父子勾选策略 */
|
|
77
|
+
export type TreeSelectionStrategy = 'cascade' | 'isolated';
|
|
78
|
+
/** 组件实例暴露的命令式 API */
|
|
79
|
+
export interface TreeExposed<T extends TreeItem[] = TreeItem[]> {
|
|
80
|
+
/** 展开全部可展开节点 */
|
|
81
|
+
expandAll: () => void;
|
|
82
|
+
/** 收起全部节点 */
|
|
83
|
+
collapseAll: () => void;
|
|
84
|
+
/** 展开到指定层级,depth=0 收起全部 */
|
|
85
|
+
expandToDepth: (depth: number) => void;
|
|
86
|
+
/** 选中全部可选节点 */
|
|
87
|
+
selectAll: () => void;
|
|
88
|
+
/** 清空选中 */
|
|
89
|
+
clearSelection: () => void;
|
|
90
|
+
/** 当前选中结果分类 */
|
|
91
|
+
treeSelection: TreeSelectionResult<T[number]>;
|
|
92
|
+
}
|
|
93
|
+
/** 工具栏选中态摘要 */
|
|
94
|
+
export interface TreeSelectionSummary {
|
|
95
|
+
/** 已选节点数 */
|
|
96
|
+
checkedCount: number;
|
|
97
|
+
/** 可选节点总数 */
|
|
98
|
+
total: number;
|
|
99
|
+
/** 是否全部选中 */
|
|
100
|
+
allChecked: boolean;
|
|
101
|
+
/** 是否处于半选态 */
|
|
102
|
+
indeterminate: boolean;
|
|
103
|
+
}
|
|
104
|
+
export type TreeEmits<T extends TreeItem[] = TreeItem[], M extends boolean = false> = NuxtTreeEmits<T, M> & {
|
|
105
|
+
'update:search': [value: string];
|
|
106
|
+
'change': [
|
|
107
|
+
payload: {
|
|
108
|
+
value: NuxtTreeProps<T, M>['modelValue'];
|
|
109
|
+
keys: string[];
|
|
110
|
+
selection: TreeSelectionResult<T[number]>;
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
};
|
|
114
|
+
interface TreeExtraSlots<T extends TreeItem[] = TreeItem[]> {
|
|
115
|
+
'toolbar'?(props: {
|
|
116
|
+
expandAll: () => void;
|
|
117
|
+
collapseAll: () => void;
|
|
118
|
+
toggleExpand: () => void;
|
|
119
|
+
allExpanded: boolean;
|
|
120
|
+
selectAll: () => void;
|
|
121
|
+
clear: () => void;
|
|
122
|
+
search: string;
|
|
123
|
+
selectionSummary: TreeSelectionSummary;
|
|
124
|
+
}): VNode[];
|
|
125
|
+
/** 默认工具栏起始处追加内容 */
|
|
126
|
+
'toolbar-leading'?(): VNode[];
|
|
127
|
+
/** 默认工具栏末尾追加内容 */
|
|
128
|
+
'toolbar-trailing'?(): VNode[];
|
|
129
|
+
'empty'?(): VNode[];
|
|
130
|
+
'loading'?(props: {
|
|
131
|
+
node: T[number];
|
|
132
|
+
}): VNode[];
|
|
133
|
+
}
|
|
134
|
+
export type TreeSlots<T extends TreeItem[] = TreeItem[]> = NuxtTreeSlots<T> & TreeExtraSlots<T>;
|
|
File without changes
|
|
@@ -217,20 +217,4 @@ export interface DataTableActionsColumn<T = unknown> extends DataTableSpecialCol
|
|
|
217
217
|
export type DataTableColumn<T> = DataTableDataColumn<T> | DataTableGroupColumn<T> | DataTableSelectionColumn<T> | DataTableIndexColumn<T> | DataTableExpandColumn<T> | DataTableRowPinningColumn<T> | DataTableActionsColumn<T> | TableColumn<T>;
|
|
218
218
|
export declare function isDataColumn<T>(col: DataTableColumn<T>): col is DataTableDataColumn<T>;
|
|
219
219
|
export declare function isGroupColumn<T>(col: DataTableColumn<T>): col is DataTableGroupColumn<T>;
|
|
220
|
-
export
|
|
221
|
-
/** TanStack 原生语义:所有 selected=true 的行对象 */
|
|
222
|
-
selected: T[];
|
|
223
|
-
/** 只包含叶子节点(无子节点)且被勾选的行 */
|
|
224
|
-
leaves: T[];
|
|
225
|
-
/** 父节点且所有子孙叶子均已选中(「全选」的父) */
|
|
226
|
-
parents: T[];
|
|
227
|
-
/** 父节点且子孙叶子部分选中(indeterminate) */
|
|
228
|
-
halfSelected: T[];
|
|
229
|
-
/**
|
|
230
|
-
* 严格被用户勾选:排除因父级联而带上的子节点。
|
|
231
|
-
* - 'isolated' / 'leaf':等价于 `selected`
|
|
232
|
-
* - 'cascade':若自身被选且父节点也在 selected 中,视为级联产物,剔除
|
|
233
|
-
*/
|
|
234
|
-
strictlyChecked: T[];
|
|
235
|
-
}
|
|
236
|
-
export {};
|
|
220
|
+
export type { TreeSelectionResult } from '../shared';
|
|
@@ -115,6 +115,11 @@ export interface DataTableProps<T extends TableData> extends /* @vue-ignore */ O
|
|
|
115
115
|
* @defaultValue '1rem'
|
|
116
116
|
*/
|
|
117
117
|
indentSize?: number | string | ((ctx: CellContext<T, unknown>) => string);
|
|
118
|
+
/**
|
|
119
|
+
* 树形模式下的默认展开行为,仅在未提供 expanded / expandedKeys 时生效。true 展开全部父级行,number 展开 depth 小于该值的父级行,函数按行与深度自定义
|
|
120
|
+
* @defaultValue false
|
|
121
|
+
*/
|
|
122
|
+
defaultExpanded?: boolean | number | ((row: T, depth: number) => boolean);
|
|
118
123
|
expandedOptions?: TableProps<T>['expandedOptions'];
|
|
119
124
|
/** @defaultValue false */
|
|
120
125
|
expandOnRowClick?: boolean;
|
|
@@ -3,3 +3,16 @@ export type ClassNameValue = ClassValue;
|
|
|
3
3
|
export type ClassNameArray = ClassNameValue[];
|
|
4
4
|
export type SemanticSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
5
5
|
export type SemanticColor = 'primary' | 'info' | 'success' | 'warning' | 'error' | 'neutral';
|
|
6
|
+
/** 树形选中结果分类,DataTable 与 Tree 共用 */
|
|
7
|
+
export interface TreeSelectionResult<T> {
|
|
8
|
+
/** 所有被选中的行/节点 */
|
|
9
|
+
selected: T[];
|
|
10
|
+
/** 选中且无子节点的叶子 */
|
|
11
|
+
leaves: T[];
|
|
12
|
+
/** 子孙叶子全部选中的父级 */
|
|
13
|
+
parents: T[];
|
|
14
|
+
/** 子孙叶子部分选中的父级(半选) */
|
|
15
|
+
halfSelected: T[];
|
|
16
|
+
/** 严格被勾选:cascade 下排除因父级联带上的子节点 */
|
|
17
|
+
strictlyChecked: T[];
|
|
18
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ComputedRef } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SlotClass } from '@nuxt/ui';
|
|
3
3
|
type SlotsLike = {
|
|
4
4
|
slots: Record<string, unknown>;
|
|
5
5
|
};
|
|
6
6
|
type MergeParams = {
|
|
7
|
-
ui?: Record<string,
|
|
7
|
+
ui?: Record<string, SlotClass | SlotClass[]>;
|
|
8
8
|
variants?: Record<string, unknown>;
|
|
9
9
|
};
|
|
10
10
|
type BaseKeys<P extends SlotsLike> = string & keyof P['slots'];
|