@movk/nuxt 1.3.1 → 1.4.1

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.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +12 -2
  4. package/dist/runtime/components/ColorChooser.d.vue.ts +2 -2
  5. package/dist/runtime/components/ColorChooser.vue.d.ts +2 -2
  6. package/dist/runtime/components/DataTable.d.vue.ts +2 -2
  7. package/dist/runtime/components/DataTable.vue +38 -10
  8. package/dist/runtime/components/DataTable.vue.d.ts +2 -2
  9. package/dist/runtime/components/DatePicker.d.vue.ts +3 -3
  10. package/dist/runtime/components/DatePicker.vue +1 -1
  11. package/dist/runtime/components/DatePicker.vue.d.ts +3 -3
  12. package/dist/runtime/components/PillGroup.d.vue.ts +1 -1
  13. package/dist/runtime/components/PillGroup.vue.d.ts +1 -1
  14. package/dist/runtime/components/SearchForm.d.vue.ts +3 -3
  15. package/dist/runtime/components/SearchForm.vue +14 -5
  16. package/dist/runtime/components/SearchForm.vue.d.ts +3 -3
  17. package/dist/runtime/components/StarRating.d.vue.ts +2 -2
  18. package/dist/runtime/components/StarRating.vue.d.ts +2 -2
  19. package/dist/runtime/components/Tree.d.vue.ts +44 -0
  20. package/dist/runtime/components/Tree.vue +375 -0
  21. package/dist/runtime/components/Tree.vue.d.ts +44 -0
  22. package/dist/runtime/composables/useDownloadWithProgress.d.ts +6 -5
  23. package/dist/runtime/composables/useDownloadWithProgress.js +4 -16
  24. package/dist/runtime/composables/useUploadWithProgress.d.ts +6 -5
  25. package/dist/runtime/composables/useUploadWithProgress.js +4 -16
  26. package/dist/runtime/domains/auto-form/controls.d.ts +16 -16
  27. package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +1 -1
  28. package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +1 -1
  29. package/dist/runtime/domains/tree/components/TreeToolbar.d.vue.ts +45 -0
  30. package/dist/runtime/domains/tree/components/TreeToolbar.vue +81 -0
  31. package/dist/runtime/domains/tree/components/TreeToolbar.vue.d.ts +45 -0
  32. package/dist/runtime/domains/tree/resolve-tree.d.ts +13 -0
  33. package/dist/runtime/domains/tree/resolve-tree.js +17 -0
  34. package/dist/runtime/domains/tree/tree-disabled.d.ts +3 -0
  35. package/dist/runtime/domains/tree/tree-disabled.js +12 -0
  36. package/dist/runtime/domains/tree/tree-icon.d.ts +3 -0
  37. package/dist/runtime/domains/tree/tree-icon.js +5 -0
  38. package/dist/runtime/domains/tree/tree-lazy.d.ts +19 -0
  39. package/dist/runtime/domains/tree/tree-lazy.js +19 -0
  40. package/dist/runtime/domains/tree/tree-search.d.ts +9 -0
  41. package/dist/runtime/domains/tree/tree-search.js +9 -0
  42. package/dist/runtime/types/auto-form/search-form.d.ts +3 -3
  43. package/dist/runtime/types/components/index.d.ts +1 -0
  44. package/dist/runtime/types/components/message-box.d.ts +3 -3
  45. package/dist/runtime/types/components/tree.d.ts +147 -0
  46. package/dist/runtime/types/components/tree.js +0 -0
  47. package/dist/runtime/types/data-table/columns.d.ts +1 -17
  48. package/dist/runtime/types/data-table/component.d.ts +5 -0
  49. package/dist/runtime/types/shared.d.ts +13 -0
  50. package/dist/runtime/utils/extend-theme.d.ts +2 -2
  51. package/dist/runtime/utils/tree-expand.d.ts +22 -0
  52. package/dist/runtime/utils/tree-expand.js +18 -0
  53. package/dist/runtime/utils/tree-selection.d.ts +37 -0
  54. package/dist/runtime/utils/tree-selection.js +59 -0
  55. package/dist/shared/{nuxt.DfBEyjld.mjs → nuxt.CXM2nhP4.mjs} +76 -4
  56. package/dist/unplugin.d.mts +4 -2
  57. package/dist/unplugin.mjs +1 -35
  58. package/dist/vite.mjs +1 -1
  59. package/package.json +9 -8
  60. package/dist/runtime/domains/data-table/tree-selection.d.ts +0 -9
  61. package/dist/runtime/domains/data-table/tree-selection.js +0 -76
@@ -20,7 +20,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
20
20
  props: import("vue").PublicProps & {
21
21
  buttonProps?: import("@nuxt/ui").ButtonProps | undefined;
22
22
  ui?: (Record<string, import("tailwind-variants").ClassValue> & {
23
- [x: string]: import("tailwind-variants").ClassValue;
23
+ [x: string]: import("@nuxt/ui").SlotClass;
24
24
  }) | undefined;
25
25
  as?: any;
26
26
  id?: string | undefined;
@@ -86,7 +86,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
86
86
  props: import("vue").PublicProps & {
87
87
  buttonProps?: import("@nuxt/ui").ButtonProps | undefined;
88
88
  ui?: (Record<string, import("tailwind-variants").ClassValue> & {
89
- [x: string]: import("tailwind-variants").ClassValue;
89
+ [x: string]: import("@nuxt/ui").SlotClass;
90
90
  }) | undefined;
91
91
  as?: any;
92
92
  id?: string | undefined;
@@ -151,7 +151,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
151
151
  buttonProps?: import("@nuxt/ui").ButtonProps | undefined;
152
152
  tooltipProps?: import("@nuxt/ui").TooltipProps | undefined;
153
153
  ui?: (Record<string, import("tailwind-variants").ClassValue> & {
154
- [x: string]: import("tailwind-variants").ClassValue;
154
+ [x: string]: import("@nuxt/ui").SlotClass;
155
155
  }) | undefined;
156
156
  as?: any;
157
157
  id?: string | undefined;
@@ -217,7 +217,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
217
217
  props: import("vue").PublicProps & {
218
218
  maxLength?: number | undefined;
219
219
  ui?: (Record<string, import("tailwind-variants").ClassValue> & {
220
- [x: string]: import("tailwind-variants").ClassValue;
220
+ [x: string]: import("@nuxt/ui").SlotClass;
221
221
  }) | undefined;
222
222
  as?: any;
223
223
  id?: string | undefined;
@@ -284,7 +284,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
284
284
  size?: string | number | symbol | undefined;
285
285
  clearButtonProps?: import("@nuxt/ui").ButtonProps | undefined;
286
286
  ui?: (Record<string, import("tailwind-variants").ClassValue> & {
287
- [x: string]: import("tailwind-variants").ClassValue;
287
+ [x: string]: import("@nuxt/ui").SlotClass;
288
288
  }) | undefined;
289
289
  as?: any;
290
290
  id?: string | undefined;
@@ -350,7 +350,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
350
350
  mask?: string | undefined;
351
351
  dialCode?: string | undefined;
352
352
  ui?: (Record<string, import("tailwind-variants").ClassValue> & {
353
- [x: string]: import("tailwind-variants").ClassValue;
353
+ [x: string]: import("@nuxt/ui").SlotClass;
354
354
  }) | undefined;
355
355
  as?: any;
356
356
  id?: string | undefined;
@@ -423,12 +423,12 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
423
423
  modelValue?: number;
424
424
  }> & Readonly<{
425
425
  onChange?: ((value: number) => any) | undefined;
426
- onHover?: ((value: number | null) => any) | undefined;
427
426
  "onUpdate:modelValue"?: ((value: number) => any) | undefined;
427
+ onHover?: ((value: number | null) => any) | undefined;
428
428
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
429
429
  change: (value: number) => any;
430
- hover: (value: number | null) => any;
431
430
  "update:modelValue": (value: number) => any;
431
+ hover: (value: number | null) => any;
432
432
  }, import("vue").PublicProps, {
433
433
  max: number;
434
434
  showBadge: boolean;
@@ -448,8 +448,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
448
448
  modelValue?: number;
449
449
  }> & Readonly<{
450
450
  onChange?: ((value: number) => any) | undefined;
451
- onHover?: ((value: number | null) => any) | undefined;
452
451
  "onUpdate:modelValue"?: ((value: number) => any) | undefined;
452
+ onHover?: ((value: number | null) => any) | undefined;
453
453
  }>, {}, {}, {}, {}, {
454
454
  max: number;
455
455
  showBadge: boolean;
@@ -466,12 +466,12 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
466
466
  modelValue?: number;
467
467
  }> & Readonly<{
468
468
  onChange?: ((value: number) => any) | undefined;
469
- onHover?: ((value: number | null) => any) | undefined;
470
469
  "onUpdate:modelValue"?: ((value: number) => any) | undefined;
470
+ onHover?: ((value: number | null) => any) | undefined;
471
471
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
472
472
  change: (value: number) => any;
473
- hover: (value: number | null) => any;
474
473
  "update:modelValue": (value: number) => any;
474
+ hover: (value: number | null) => any;
475
475
  }, string, {
476
476
  max: number;
477
477
  showBadge: boolean;
@@ -500,7 +500,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
500
500
  readonly colorChooser: <M extends "click" | "hover">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
501
501
  slots: import("../../types").ColorChooserSlots;
502
502
  attrs: any;
503
- emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:open", open: boolean) => void) & ((evt: "update:modelValue", value: string | undefined) => void) & ((evt: "format-change", format: import("../../types").ColorFormat) => void)) & ((event: "update:modelValue", value: string | undefined) => void);
503
+ emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:modelValue", value: string | undefined) => void) & ((evt: "update:open", open: boolean) => void) & ((evt: "format-change", format: import("../../types").ColorFormat) => void)) & ((event: "update:modelValue", value: string | undefined) => void);
504
504
  }, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
505
505
  props: import("vue").PublicProps & {
506
506
  id?: string | undefined;
@@ -522,7 +522,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
522
522
  icon?: import("@nuxt/ui").IconProps["name"];
523
523
  colorPickerProps?: Omit<import("@nuxt/ui").ColorPickerProps, "modelValue" | "format" | "disabled"> | undefined;
524
524
  ui?: (Record<string, import("tailwind-variants").ClassValue> & {
525
- [x: string]: import("tailwind-variants").ClassValue;
525
+ [x: string]: import("@nuxt/ui").SlotClass;
526
526
  }) | undefined;
527
527
  mode?: M | undefined;
528
528
  content?: (Omit<import("reka-ui").PopoverContentProps, "as" | "asChild" | "forceMount"> & Partial<import("@nuxt/ui").EmitsToProps<import("reka-ui").PopoverContentEmits>>) | undefined;
@@ -538,8 +538,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
538
538
  onClear?: (() => any) | undefined;
539
539
  onChange?: ((value: string | undefined) => any) | undefined;
540
540
  onCopy?: ((value: string) => any) | undefined;
541
- "onUpdate:open"?: ((open: boolean) => any) | undefined;
542
541
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
542
+ "onUpdate:open"?: ((open: boolean) => any) | undefined;
543
543
  "onFormat-change"?: ((format: import("../../types").ColorFormat) => any) | undefined;
544
544
  } & (typeof globalThis extends {
545
545
  __VLS_PROPS_FALLBACK: infer P;
@@ -547,7 +547,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
547
547
  expose: (exposed: {}) => void;
548
548
  attrs: any;
549
549
  slots: import("../../types").ColorChooserSlots;
550
- emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:open", open: boolean) => void) & ((evt: "update:modelValue", value: string | undefined) => void) & ((evt: "format-change", format: import("../../types").ColorFormat) => void)) & ((event: "update:modelValue", value: string | undefined) => void);
550
+ emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:modelValue", value: string | undefined) => void) & ((evt: "update:open", open: boolean) => void) & ((evt: "format-change", format: import("../../types").ColorFormat) => void)) & ((event: "update:modelValue", value: string | undefined) => void);
551
551
  }>) => import("vue").VNode & {
552
552
  __ctx?: Awaited<typeof __VLS_setup>;
553
553
  };
@@ -655,7 +655,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
655
655
  modelValue?: (import("@nuxt/ui").GetModelValue<T, VK, M, undefined> & import("@nuxt/ui").GetModelValue<T, VK, M>) | undefined;
656
656
  class?: import("tailwind-variants").ClassValue;
657
657
  ui?: (Record<string, import("tailwind-variants").ClassValue> & {
658
- [x: string]: import("tailwind-variants").ClassValue;
658
+ [x: string]: import("@nuxt/ui").SlotClass;
659
659
  }) | undefined;
660
660
  onBlur?: ((event: FocusEvent) => any) | undefined;
661
661
  onChange?: ((value: import("@nuxt/ui").GetModelValue<T, VK, M, undefined>) => any) | undefined;
@@ -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("tailwind-variants").ClassValue;
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("tailwind-variants").ClassValue;
7
+ [x: string]: import("@nuxt/ui").SlotClass;
8
8
  };
9
9
  };
10
10
  }> & (typeof globalThis extends {
@@ -0,0 +1,45 @@
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
+ /** 禁用工具栏全部控件 */
13
+ disabled?: boolean;
14
+ selectionSummary?: TreeSelectionSummary;
15
+ ui: {
16
+ toolbar?: string;
17
+ toolbarButton?: string;
18
+ search?: string;
19
+ };
20
+ };
21
+ declare var __VLS_1: {}, __VLS_39: {};
22
+ type __VLS_Slots = {} & {
23
+ leading?: (props: typeof __VLS_1) => any;
24
+ } & {
25
+ trailing?: (props: typeof __VLS_39) => any;
26
+ };
27
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
+ clear: () => any;
29
+ "select-all": () => any;
30
+ "update:search": (value: string) => any;
31
+ "toggle-expand": () => any;
32
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
33
+ onClear?: (() => any) | undefined;
34
+ "onSelect-all"?: (() => any) | undefined;
35
+ "onUpdate:search"?: ((value: string) => any) | undefined;
36
+ "onToggle-expand"?: (() => any) | undefined;
37
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
39
+ declare const _default: typeof __VLS_export;
40
+ export default _default;
41
+ type __VLS_WithSlots<T, S> = T & {
42
+ new (): {
43
+ $slots: S;
44
+ };
45
+ };
@@ -0,0 +1,81 @@
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
+ disabled: { type: Boolean, required: false },
13
+ selectionSummary: { type: Object, required: false },
14
+ ui: { type: Object, required: true }
15
+ });
16
+ const emit = defineEmits(["update:search", "toggle-expand", "select-all", "clear"]);
17
+ const checkboxLabel = computed(() => {
18
+ const count = props.selectionSummary?.checkedCount ?? 0;
19
+ return count > 0 ? `\u5DF2\u9009 ${count}` : "\u5168\u9009";
20
+ });
21
+ const expandTooltip = computed(() => props.expanded ? "\u6298\u53E0\u5168\u90E8" : "\u5C55\u5F00\u5168\u90E8");
22
+ function onToggleAll(checked) {
23
+ if (checked) emit("select-all");
24
+ else emit("clear");
25
+ }
26
+ </script>
27
+
28
+ <template>
29
+ <div :class="ui.toolbar">
30
+ <slot name="leading" />
31
+
32
+ <UInput
33
+ v-if="searchable"
34
+ :model-value="search"
35
+ icon="i-lucide-search"
36
+ placeholder="搜索节点"
37
+ :size="size"
38
+ :disabled="disabled"
39
+ :class="ui.search"
40
+ @update:model-value="emit('update:search', String($event))"
41
+ >
42
+ <template v-if="search" #trailing>
43
+ <UButton
44
+ icon="i-lucide-x"
45
+ color="neutral"
46
+ variant="link"
47
+ :size="size"
48
+ :disabled="disabled"
49
+ aria-label="清除搜索"
50
+ @click="emit('update:search', '')"
51
+ />
52
+ </template>
53
+ </UInput>
54
+
55
+ <UTooltip v-if="toolbar" :text="expandTooltip">
56
+ <UButton
57
+ :icon="expanded ? 'i-lucide-chevrons-down-up' : 'i-lucide-chevrons-up-down'"
58
+ color="neutral"
59
+ variant="ghost"
60
+ :size="size"
61
+ :disabled="disabled"
62
+ :class="ui.toolbarButton"
63
+ :aria-label="expandTooltip"
64
+ @click="emit('toggle-expand')"
65
+ />
66
+ </UTooltip>
67
+
68
+ <UCheckbox
69
+ v-if="toolbar && checkable"
70
+ :model-value="selectionSummary?.allChecked ?? false"
71
+ :indeterminate="selectionSummary?.indeterminate ?? false"
72
+ :size="size"
73
+ :color="color"
74
+ :disabled="disabled"
75
+ :label="checkboxLabel"
76
+ @update:model-value="onToggleAll(Boolean($event))"
77
+ />
78
+
79
+ <slot name="trailing" />
80
+ </div>
81
+ </template>
@@ -0,0 +1,45 @@
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
+ /** 禁用工具栏全部控件 */
13
+ disabled?: boolean;
14
+ selectionSummary?: TreeSelectionSummary;
15
+ ui: {
16
+ toolbar?: string;
17
+ toolbarButton?: string;
18
+ search?: string;
19
+ };
20
+ };
21
+ declare var __VLS_1: {}, __VLS_39: {};
22
+ type __VLS_Slots = {} & {
23
+ leading?: (props: typeof __VLS_1) => any;
24
+ } & {
25
+ trailing?: (props: typeof __VLS_39) => any;
26
+ };
27
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
+ clear: () => any;
29
+ "select-all": () => any;
30
+ "update:search": (value: string) => any;
31
+ "toggle-expand": () => any;
32
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
33
+ onClear?: (() => any) | undefined;
34
+ "onSelect-all"?: (() => any) | undefined;
35
+ "onUpdate:search"?: ((value: string) => any) | undefined;
36
+ "onToggle-expand"?: (() => any) | undefined;
37
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
39
+ declare const _default: typeof __VLS_export;
40
+ export default _default;
41
+ type __VLS_WithSlots<T, S> = T & {
42
+ new (): {
43
+ $slots: S;
44
+ };
45
+ };
@@ -0,0 +1,13 @@
1
+ import type { AnyObject } from '@movk/core';
2
+ /**
3
+ * 构造与 UTree 一致的取键函数
4
+ *
5
+ * 复刻 UTree:提供 getKey 时取其返回值(为空则回退 label),否则按 labelKey 取值(支持点路径,与 UTree 内部 get 一致)。
6
+ */
7
+ export declare function createGetKey<T extends AnyObject>(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 AnyObject>(items: T[], childrenKey?: string): T[];
@@ -0,0 +1,17 @@
1
+ import { getPath } from "@movk/core";
2
+ export function createGetKey(getKey, labelKey = "label") {
3
+ return (node) => {
4
+ const label = getPath(node, labelKey);
5
+ const key = getKey ? getKey(node) || label : label;
6
+ return String(key);
7
+ };
8
+ }
9
+ export function normalizeChildren(items, childrenKey = "children") {
10
+ if (childrenKey === "children") return items;
11
+ return items.map((node) => {
12
+ const raw = node[childrenKey];
13
+ const { [childrenKey]: _omit, ...rest } = node;
14
+ if (!Array.isArray(raw)) return rest;
15
+ return { ...rest, children: normalizeChildren(raw, childrenKey) };
16
+ });
17
+ }
@@ -0,0 +1,3 @@
1
+ import type { AnyObject } from '@movk/core';
2
+ /** 收集 disabled 子树的全部 key:节点自身 disabled 或祖先 disabled 即纳入 */
3
+ export declare function collectDisabledKeys<T extends AnyObject>(items: T[], getKey: (node: T) => string): Set<string>;
@@ -0,0 +1,12 @@
1
+ export function collectDisabledKeys(items, getKey) {
2
+ const set = /* @__PURE__ */ new Set();
3
+ const walk = (nodes, ancestorDisabled) => {
4
+ for (const node of nodes) {
5
+ const disabled = ancestorDisabled || !!node.disabled;
6
+ if (disabled) set.add(getKey(node));
7
+ if (Array.isArray(node.children)) walk(node.children, disabled);
8
+ }
9
+ };
10
+ walk(items, false);
11
+ return set;
12
+ }
@@ -0,0 +1,3 @@
1
+ import type { AnyObject } from '@movk/core';
2
+ /** 复刻 UTree 的 leading 图标解析:item.icon 优先,父节点回退传入的 folder 图标,叶子无图标返回 undefined */
3
+ export declare function resolveLeadingIcon(node: AnyObject, folderIcon: string): string | undefined;
@@ -0,0 +1,5 @@
1
+ export function resolveLeadingIcon(node, folderIcon) {
2
+ if (node.icon) return node.icon;
3
+ if (Array.isArray(node.children) && node.children.length) return folderIcon;
4
+ return void 0;
5
+ }
@@ -0,0 +1,19 @@
1
+ import type { AnyObject } from '@movk/core';
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: AnyObject): boolean;
13
+ /**
14
+ * 为懒加载父节点注入占位子节点
15
+ *
16
+ * UTree 仅在 `children.length` 为真时渲染展开箭头;对 `children` 未加载(缺省)且非叶子的节点,
17
+ * 注入一个占位子节点使其可展开。展开时再由 `Tree.updateNode` 用真实子节点替换。不修改入参。
18
+ */
19
+ export declare function markLazyPlaceholders<T extends AnyObject>(items: T[], getKey: (node: T) => string, labelKey?: string): T[];
@@ -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
+ }
@@ -0,0 +1,9 @@
1
+ import type { AnyObject } from '@movk/core';
2
+ /**
3
+ * 默认搜索谓词:不区分大小写的文本包含匹配,空关键字视为全部命中
4
+ *
5
+ * 作为 `Tree.filter` 的默认匹配函数;高亮切分由 `@movk/core` 的 `splitHighlight` 承担。
6
+ */
7
+ export declare function matchLabel(label: unknown, term: string): boolean;
8
+ /** 按 labelKey 取节点文本(点路径,与 nodeLabel / createGetKey 一致)后做默认匹配 */
9
+ export declare function matchNode(node: AnyObject, labelKey: string, term: string): boolean;
@@ -0,0 +1,9 @@
1
+ import { getPath } from "@movk/core";
2
+ export function matchLabel(label, term) {
3
+ if (!term.trim()) return true;
4
+ if (label == null) return false;
5
+ return String(label).toLowerCase().includes(term.toLowerCase());
6
+ }
7
+ export function matchNode(node, labelKey, term) {
8
+ return matchLabel(getPath(node, labelKey), term);
9
+ }
@@ -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 { ClassNameValue, SemanticColor } from '../shared';
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, ClassNameValue>;
58
+ ui?: Record<string, SlotClass>;
59
59
  }
60
60
  export interface MessageBoxEmits {
61
61
  /**
@@ -0,0 +1,147 @@
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
+ * 父节点展开时的图标
59
+ * @defaultValue 取 app.config 的 ui.icons.folderOpen
60
+ */
61
+ expandedIcon?: NuxtTreeProps<T, M>['expandedIcon'];
62
+ /**
63
+ * 父节点折叠时的图标
64
+ * @defaultValue 取 app.config 的 ui.icons.folder
65
+ */
66
+ collapsedIcon?: NuxtTreeProps<T, M>['collapsedIcon'];
67
+ /** 禁用整棵树,阻断点击、工具栏与复选框的展开、折叠、选中 */
68
+ disabled?: NuxtTreeProps<T, M>['disabled'];
69
+ /** 开启顶部搜索过滤 */
70
+ searchable?: boolean;
71
+ /** 自定义匹配谓词,缺省按 labelKey 文本不区分大小写包含匹配 */
72
+ filter?: TreeFilter<T[number]>;
73
+ /**
74
+ * 高亮命中文本,仅在 searchable 时生效
75
+ * @defaultValue true
76
+ */
77
+ highlight?: boolean;
78
+ /** 开启异步懒加载子节点 */
79
+ lazy?: boolean;
80
+ /** 懒加载回调,展开未加载的父节点时调用 */
81
+ loadChildren?: TreeLoadChildren<T[number]>;
82
+ /** 开启顶部工具栏(展开/折叠,checkable 时附带全选/清空) */
83
+ toolbar?: boolean;
84
+ /** 渲染复选框并启用多选(multiple + strategy,默认 cascade) */
85
+ checkable?: M & boolean;
86
+ ui?: Record<string, ClassNameValue>;
87
+ }
88
+ /** 父子勾选策略 */
89
+ export type TreeSelectionStrategy = 'cascade' | 'isolated';
90
+ /** 组件实例暴露的命令式 API */
91
+ export interface TreeExposed<T extends TreeItem[] = TreeItem[]> {
92
+ /** 展开全部可展开节点 */
93
+ expandAll: () => void;
94
+ /** 收起全部节点 */
95
+ collapseAll: () => void;
96
+ /** 展开到指定层级,depth=0 收起全部 */
97
+ expandToDepth: (depth: number) => void;
98
+ /** 选中全部可选节点 */
99
+ selectAll: () => void;
100
+ /** 清空选中 */
101
+ clearSelection: () => void;
102
+ /** 当前选中结果分类 */
103
+ treeSelection: TreeSelectionResult<T[number]>;
104
+ }
105
+ /** 工具栏选中态摘要 */
106
+ export interface TreeSelectionSummary {
107
+ /** 已选节点数 */
108
+ checkedCount: number;
109
+ /** 可选节点总数 */
110
+ total: number;
111
+ /** 是否全部选中 */
112
+ allChecked: boolean;
113
+ /** 是否处于半选态 */
114
+ indeterminate: boolean;
115
+ }
116
+ export type TreeEmits<T extends TreeItem[] = TreeItem[], M extends boolean = false> = NuxtTreeEmits<T, M> & {
117
+ 'update:search': [value: string];
118
+ 'change': [
119
+ payload: {
120
+ value: NuxtTreeProps<T, M>['modelValue'];
121
+ keys: string[];
122
+ selection: TreeSelectionResult<T[number]>;
123
+ }
124
+ ];
125
+ };
126
+ interface TreeExtraSlots<T extends TreeItem[] = TreeItem[]> {
127
+ 'toolbar'?(props: {
128
+ expandAll: () => void;
129
+ collapseAll: () => void;
130
+ toggleExpand: () => void;
131
+ allExpanded: boolean;
132
+ selectAll: () => void;
133
+ clear: () => void;
134
+ search: string;
135
+ disabled?: boolean;
136
+ selectionSummary: TreeSelectionSummary;
137
+ }): VNode[];
138
+ /** 默认工具栏起始处追加内容 */
139
+ 'toolbar-leading'?(): VNode[];
140
+ /** 默认工具栏末尾追加内容 */
141
+ 'toolbar-trailing'?(): VNode[];
142
+ 'empty'?(): VNode[];
143
+ 'loading'?(props: {
144
+ node: T[number];
145
+ }): VNode[];
146
+ }
147
+ export type TreeSlots<T extends TreeItem[] = TreeItem[]> = NuxtTreeSlots<T> & TreeExtraSlots<T>;
File without changes