@veltra/desktop 1.2.2 → 1.2.4

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 (31) hide show
  1. package/dist/components/action/action-group.vue.d.ts +2 -2
  2. package/dist/components/action/action.vue.d.ts +1 -1
  3. package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
  4. package/dist/components/cascade/cascade.vue.d.ts +3 -3
  5. package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
  6. package/dist/components/checkbox/checkbox.vue.d.ts +1 -1
  7. package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
  8. package/dist/components/code-editor/code-editor.vue.d.ts +1 -1
  9. package/dist/components/date-picker/date-picker.vue.d.ts +3 -3
  10. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +3 -3
  11. package/dist/components/empty/empty.vue.d.ts +1 -1
  12. package/dist/components/input/input.vue.d.ts +2 -2
  13. package/dist/components/multi-select/multi-select.vue.d.ts +3 -3
  14. package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +3 -3
  15. package/dist/components/number/number.vue.d.ts +1 -1
  16. package/dist/components/number-input/number-input.vue.d.ts +2 -2
  17. package/dist/components/number-range-input/number-range-input.vue.d.ts +2 -2
  18. package/dist/components/palette/palette.vue.d.ts +1 -1
  19. package/dist/components/password-input/password-input.vue.d.ts +2 -2
  20. package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
  21. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +2 -2
  22. package/dist/components/select/select.vue.d.ts +2 -2
  23. package/dist/components/steps/steps.vue.d.ts +1 -1
  24. package/dist/components/switch/switch.vue.d.ts +1 -1
  25. package/dist/components/table/use-columns.js +14 -12
  26. package/dist/components/table/use-columns.js.map +1 -1
  27. package/dist/components/textarea/textarea.vue.d.ts +2 -2
  28. package/dist/components/tip/tip.vue.d.ts +1 -1
  29. package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
  30. package/package.json +6 -6
  31. package/src/components/table/use-columns.ts +23 -20
@@ -6,11 +6,11 @@ type __VLS_Slots = {
6
6
  default?: () => VNode[];
7
7
  };
8
8
  declare const __VLS_base: import("vue").DefineComponent<ActionGroupProps, _ActionGroupExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ActionGroupProps> & Readonly<{}>, {
9
+ text: boolean;
9
10
  size: "small" | "default" | "large";
10
11
  type: import("@veltra/utils").ColorType;
11
- text: boolean;
12
- max: number;
13
12
  circle: boolean;
13
+ max: number;
14
14
  loading: boolean;
15
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
16
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -12,9 +12,9 @@ declare const __VLS_base: import("vue").DefineComponent<ActionProps, {}, {}, {},
12
12
  }, string, import("vue").PublicProps, Readonly<ActionProps> & Readonly<{
13
13
  onRun?: (() => any) | undefined;
14
14
  }>, {
15
+ text: boolean;
15
16
  size: import("@veltra/utils").ComponentSize;
16
17
  type: ButtonType;
17
- text: boolean;
18
18
  circle: boolean;
19
19
  loading: boolean;
20
20
  inDropdown: boolean;
@@ -22,10 +22,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
22
22
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
23
23
  onSelect?: ((value: string) => any) | undefined;
24
24
  }>, {
25
- readonly: boolean;
26
- disabled: boolean;
27
25
  placeholder: string;
28
26
  clearable: boolean;
27
+ disabled: boolean;
28
+ readonly: boolean;
29
29
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
30
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
31
31
  declare const _default: typeof __VLS_export;
@@ -9,8 +9,6 @@ declare const __VLS_export: import("vue").DefineComponent<CascadeProps, {}, {},
9
9
  onClear?: (() => any) | undefined;
10
10
  onChange?: ((...args: [value?: string | undefined, label?: string | undefined, item?: Record<string, any> | undefined] | [value: string[], label: string[], data: Record<string, any>[]]) => any) | undefined;
11
11
  }>, {
12
- readonly: boolean;
13
- disabled: boolean;
14
12
  labelKey: string;
15
13
  valueKey: string;
16
14
  childrenKey: string;
@@ -18,8 +16,10 @@ declare const __VLS_export: import("vue").DefineComponent<CascadeProps, {}, {},
18
16
  placeholder: string;
19
17
  clearable: boolean;
20
18
  filterable: boolean;
21
- visibilityLimit: number;
19
+ disabled: boolean;
20
+ readonly: boolean;
22
21
  separator: string;
22
+ visibilityLimit: number;
23
23
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
24
  declare const _default: typeof __VLS_export;
25
25
  //#endregion
@@ -17,8 +17,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
17
17
  "onUpdate:modelValue"?: ((checked: boolean) => any) | undefined;
18
18
  onChange?: ((checked: boolean) => any) | undefined;
19
19
  }>, {
20
- readonly: boolean;
21
20
  disabled: boolean;
21
+ readonly: boolean;
22
22
  type: import("@veltra/utils").ColorType;
23
23
  round: boolean;
24
24
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -18,8 +18,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
18
18
  "onUpdate:modelValue"?: ((checked: boolean) => any) | undefined;
19
19
  onChange?: ((checked: boolean, e: MouseEvent) => any) | undefined;
20
20
  }>, {
21
- readonly: boolean;
22
21
  disabled: boolean;
22
+ readonly: boolean;
23
23
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
24
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
25
25
  declare const _default: typeof __VLS_export;
@@ -12,10 +12,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
12
12
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
13
13
  "onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
14
14
  }>, {
15
- readonly: boolean;
16
- disabled: boolean;
17
15
  labelKey: string;
18
16
  valueKey: string;
17
+ disabled: boolean;
18
+ readonly: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const _default: typeof __VLS_export;
21
21
  //#endregion
@@ -10,8 +10,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
10
10
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
11
11
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
12
12
  }>, {
13
- readonly: boolean;
14
13
  disabled: boolean;
14
+ readonly: boolean;
15
15
  dark: boolean;
16
16
  defaultLines: number;
17
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -5,11 +5,11 @@ declare const __VLS_export: import("vue").DefineComponent<DatePickerProps, {}, {
5
5
  }, string, import("vue").PublicProps, Readonly<DatePickerProps> & Readonly<{
6
6
  "onUpdate:modelValue"?: ((value?: string | number | Date | undefined) => any) | undefined;
7
7
  }>, {
8
- readonly: boolean;
9
- disabled: boolean;
10
- type: "date" | "month" | "year";
11
8
  placeholder: string;
12
9
  clearable: boolean;
10
+ disabled: boolean;
11
+ readonly: boolean;
12
+ type: "date" | "month" | "year";
13
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
14
  declare const _default: typeof __VLS_export;
15
15
  //#endregion
@@ -5,11 +5,11 @@ declare const __VLS_export: import("vue").DefineComponent<DateRangePickerProps,
5
5
  }, string, import("vue").PublicProps, Readonly<DateRangePickerProps> & Readonly<{
6
6
  "onUpdate:modelValue"?: ((value?: [string, string] | undefined) => any) | undefined;
7
7
  }>, {
8
- readonly: boolean;
9
- disabled: boolean;
10
- type: "date" | "month" | "year";
11
8
  placeholder: [string, string];
12
9
  clearable: boolean;
10
+ disabled: boolean;
11
+ readonly: boolean;
12
+ type: "date" | "month" | "year";
13
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
14
  declare const _default: typeof __VLS_export;
15
15
  //#endregion
@@ -1,8 +1,8 @@
1
1
  import { EmptyProps } from "../../types/empty.js";
2
2
  //#region src/components/empty/empty.vue.d.ts
3
3
  declare const __VLS_export: import("vue").DefineComponent<EmptyProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<EmptyProps> & Readonly<{}>, {
4
- size: number;
5
4
  text: string;
5
+ size: number;
6
6
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  //#endregion
@@ -32,10 +32,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, _Inpu
32
32
  onBlur?: ((value?: string | undefined) => any) | undefined;
33
33
  "onNative:input"?: ((ev: Event) => any) | undefined;
34
34
  }>, {
35
- readonly: boolean;
36
- disabled: boolean;
37
35
  placeholder: string;
38
36
  clearable: boolean;
37
+ disabled: boolean;
38
+ readonly: boolean;
39
39
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
40
40
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
41
41
  declare const _default: typeof __VLS_export;
@@ -26,13 +26,13 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
26
26
  "onUpdate:modelValue"?: ((value: any[]) => any) | undefined;
27
27
  onChange?: ((options: Record<string, any>[]) => any) | undefined;
28
28
  }>, {
29
- readonly: boolean;
30
- disabled: boolean;
31
- minWidth: string;
32
29
  labelKey: string;
33
30
  valueKey: string;
34
31
  placeholder: string;
35
32
  clearable: boolean;
33
+ minWidth: string;
34
+ disabled: boolean;
35
+ readonly: boolean;
36
36
  visibilityLimit: number;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -21,15 +21,15 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
21
21
  onClear?: (() => any) | undefined;
22
22
  onChange?: ((checked: Record<string, any>[]) => any) | undefined;
23
23
  }>, {
24
- readonly: boolean;
25
- disabled: boolean;
26
- minWidth: string;
27
24
  expandAll: boolean;
28
25
  labelKey: string;
29
26
  valueKey: string;
30
27
  placeholder: string;
31
28
  clearable: boolean;
32
29
  filterable: boolean;
30
+ minWidth: string;
31
+ disabled: boolean;
32
+ readonly: boolean;
33
33
  visibilityLimit: number;
34
34
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
35
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,8 +1,8 @@
1
1
  import { NumberProps } from "../../types/number.js";
2
2
  //#region src/components/number/number.vue.d.ts
3
3
  declare const __VLS_export: import("vue").DefineComponent<NumberProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<NumberProps> & Readonly<{}>, {
4
- duration: number;
5
4
  format: "currency" | "percent" | "decimal";
5
+ duration: number;
6
6
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  //#endregion
@@ -20,10 +20,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
20
20
  onClear?: (() => any) | undefined;
21
21
  onChange?: ((value?: number | undefined) => any) | undefined;
22
22
  }>, {
23
- readonly: boolean;
24
- disabled: boolean;
25
23
  placeholder: string;
26
24
  clearable: boolean;
25
+ disabled: boolean;
26
+ readonly: boolean;
27
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
29
  declare const _default: typeof __VLS_export;
@@ -22,9 +22,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
22
22
  "onUpdate:start"?: ((value: number | undefined) => any) | undefined;
23
23
  "onUpdate:end"?: ((value: number | undefined) => any) | undefined;
24
24
  }>, {
25
- readonly: boolean;
26
- disabled: boolean;
27
25
  clearable: boolean;
26
+ disabled: boolean;
27
+ readonly: boolean;
28
28
  startPlaceholder: string;
29
29
  endPlaceholder: string;
30
30
  separator: string;
@@ -10,8 +10,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
10
10
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
11
11
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
12
12
  }>, {
13
- readonly: boolean;
14
13
  disabled: boolean;
14
+ readonly: boolean;
15
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
16
  declare const _default: typeof __VLS_export;
17
17
  //#endregion
@@ -13,9 +13,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
13
13
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
14
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
15
15
  }>, {
16
- readonly: boolean;
17
- disabled: boolean;
18
16
  clearable: boolean;
17
+ disabled: boolean;
18
+ readonly: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
21
  declare const _default: typeof __VLS_export;
@@ -14,10 +14,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
14
14
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
15
15
  onChange?: ((item: Record<string, any>) => any) | undefined;
16
16
  }>, {
17
- readonly: boolean;
18
- disabled: boolean;
19
17
  labelKey: string;
20
18
  valueKey: string;
19
+ disabled: boolean;
20
+ readonly: boolean;
21
21
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
22
  declare const _default: typeof __VLS_export;
23
23
  //#endregion
@@ -10,9 +10,9 @@ declare const __VLS_export: import("vue").DefineComponent<RichTextEditorProps &
10
10
  }> & Readonly<{
11
11
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
12
12
  }>, {
13
- readonly: boolean;
14
- disabled: boolean;
15
13
  placeholder: string;
14
+ disabled: boolean;
15
+ readonly: boolean;
16
16
  format: RichTextFormat;
17
17
  toolbar: ToolbarItem[];
18
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -24,12 +24,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
24
24
  "onUpdate:text"?: ((value: any) => any) | undefined;
25
25
  "onUpdate:label"?: ((label?: string | undefined) => any) | undefined;
26
26
  }>, {
27
- readonly: boolean;
28
- disabled: boolean;
29
27
  labelKey: string;
30
28
  valueKey: string;
31
29
  placeholder: string;
32
30
  clearable: boolean;
31
+ disabled: boolean;
32
+ readonly: boolean;
33
33
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
34
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
35
35
  declare const _default: typeof __VLS_export;
@@ -12,8 +12,8 @@ declare const __VLS_base: import("vue").DefineComponent<StepsProps, {}, {}, {},
12
12
  "onUpdate:current"?: ((value?: string | number | undefined) => any) | undefined;
13
13
  "onItem-click"?: ((item: Record<string, any>, index: number) => any) | undefined;
14
14
  }>, {
15
- direction: "horizontal" | "vertical";
16
15
  labelKey: string;
16
+ direction: "horizontal" | "vertical";
17
17
  finishedStepType: import("@veltra/utils").ColorType;
18
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
19
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -14,8 +14,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
14
14
  "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
15
15
  onChange?: ((value: boolean) => any) | undefined;
16
16
  }>, {
17
- readonly: boolean;
18
17
  disabled: boolean;
18
+ readonly: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const _default: typeof __VLS_export;
21
21
  //#endregion
@@ -83,18 +83,20 @@ function useColumns(options) {
83
83
  ...unfixed,
84
84
  ...fixedOnRight
85
85
  ];
86
- const firstColumn = { ...sortedColumns[0] };
87
- sortedColumns[0] = firstColumn;
88
- if ((!!tree || expandable) && firstColumn) {
89
- firstColumn.align = "left";
90
- firstColumn.width = firstColumn.width ? firstColumn.width + 60 : void 0;
91
- const oldNameRender = firstColumn.nameRender;
92
- firstColumn.nameRender = oldNameRender ? (ctx) => {
93
- const oldNodes = oldNameRender(ctx);
94
- return [renderExpandAll(), ...Array.isArray(oldNodes) ? oldNodes : [oldNodes]];
95
- } : () => {
96
- return [renderExpandAll(), firstColumn.name];
97
- };
86
+ if (sortedColumns.length > 0) {
87
+ const firstColumn = { ...sortedColumns[0] };
88
+ sortedColumns[0] = firstColumn;
89
+ if (tree || expandable) {
90
+ firstColumn.align = "left";
91
+ firstColumn.width = firstColumn.width ? firstColumn.width + 60 : void 0;
92
+ const oldNameRender = firstColumn.nameRender;
93
+ firstColumn.nameRender = oldNameRender ? (ctx) => {
94
+ const oldNodes = oldNameRender(ctx);
95
+ return [renderExpandAll(), ...Array.isArray(oldNodes) ? oldNodes : [oldNodes]];
96
+ } : () => {
97
+ return [renderExpandAll(), firstColumn.name];
98
+ };
99
+ }
98
100
  }
99
101
  columnForest.value = new Forest({
100
102
  data: sortedColumns,
@@ -1 +1 @@
1
- {"version":3,"file":"use-columns.js","names":["UButton","UIcon"],"sources":["../../../src/components/table/use-columns.ts"],"sourcesContent":["import { Forest, dfs, last } from '@cat-kit/core'\nimport { ArrowRight } from '@veltra/icons/normal'\nimport { type BEM } from '@veltra/utils'\nimport { computed, createVNode, shallowRef, watch, type ComputedRef, type ShallowRef } from 'vue'\n\nimport type { TableColumn, TableProps } from '../../types'\nimport { UButton } from '../button'\nimport { UIcon } from '../icon'\nimport { ColumnNode } from './node/col'\n\n/**\n * 定义表格列\n * @param columns 表格列\n */\nexport function defineTableColumns(\n columns: TableColumn[],\n commonProps?: Partial<Pick<TableColumn, 'align' | 'minWidth'>>\n): TableColumn[] {\n columns.forEach((col) => {\n dfs(col, (node) => {\n for (const key in commonProps) {\n if (node[key] !== undefined) continue\n node[key] = commonProps[key]\n }\n })\n })\n return columns\n}\n\nexport interface ColumnConfig {\n /** 表头 */\n headers: ComputedRef<ColumnNode[][]>\n\n /**\n * body列, 在body中使用\n */\n columns: ShallowRef<ColumnNode[]>\n\n /** 所有叶子列 */\n leafColumns: ShallowRef<ColumnNode[]>\n\n /** 第一列 */\n expandColumn: ShallowRef<ColumnNode | undefined>\n}\n\ninterface Options {\n props: TableProps\n cls: BEM<'table'>\n /** 创建复选框 */\n createCheckColumn: () => TableColumn\n createSelectColumn: () => TableColumn\n toggleAllTreeRowExpand: () => void\n}\n\nexport function useColumns(options: Options): ColumnConfig {\n const { props, createCheckColumn, createSelectColumn, toggleAllTreeRowExpand, cls } = options\n\n /** 前置列 */\n const preColumns = computed<TableColumn[]>(() => {\n const { selectable, checkable, showIndex } = props\n\n const columns: TableColumn[] = []\n\n if (selectable) {\n columns.push(createSelectColumn())\n } else if (checkable) {\n columns.push(createCheckColumn())\n }\n if (showIndex) {\n columns.push({\n key: '__index__',\n name: '#',\n resizable: false,\n width: 60,\n minWidth: 60,\n align: 'center',\n fixed: 'left',\n render({ row }) {\n return row.index + 1\n }\n })\n }\n\n return columns\n })\n\n const columnForest = shallowRef<Forest<TableColumn, any>>()\n\n const renderExpandAll = () =>\n createVNode(\n UButton,\n {\n text: true,\n title: '展开或收起全部',\n class: cls.e('expand-all'),\n type: 'primary',\n size: 'small',\n circle: true,\n onClick: (e) => {\n e.stopPropagation()\n toggleAllTreeRowExpand()\n }\n },\n () => [createVNode(UIcon, undefined, () => [createVNode(ArrowRight)])]\n )\n\n watch(\n [preColumns, () => props.columns, () => props.tree, () => props.expandable],\n ([preColumns, columns, tree, expandable]) => {\n /** 固定到左侧的列 */\n const fixedOnLeft: TableColumn[] = [...preColumns]\n /** 未固定的列 */\n const unfixed: TableColumn[] = []\n /** 固定到右侧的列 */\n const fixedOnRight: TableColumn[] = []\n\n columns?.forEach((column) => {\n if (!column.fixed || column.children) {\n column.fixed = undefined\n return unfixed.push(column)\n }\n if (column.fixed === 'left') {\n fixedOnLeft.push(column)\n } else {\n fixedOnRight.push(column)\n }\n })\n\n if (last(fixedOnLeft)) {\n last(fixedOnLeft)!.isLastFixed = true\n }\n if (fixedOnRight[0]) {\n fixedOnRight[0].isFirstFixed = true\n }\n\n const sortedColumns = [...fixedOnLeft, ...unfixed, ...fixedOnRight]\n // 操作时避免改变原数据\n const firstColumn = { ...sortedColumns[0] } as TableColumn\n sortedColumns[0] = firstColumn\n\n // 树形表格需要给第一列添加展开按钮\n // 因此要重新设置第一列的宽度和对齐方式\n if ((!!tree || expandable) && firstColumn) {\n firstColumn.align = 'left'\n firstColumn.width = firstColumn.width ? firstColumn.width + 60 : undefined\n\n const oldNameRender = firstColumn.nameRender\n\n firstColumn.nameRender = oldNameRender\n ? (ctx) => {\n const oldNodes = oldNameRender!(ctx)\n return [renderExpandAll(), ...(Array.isArray(oldNodes) ? oldNodes : [oldNodes])]\n }\n : () => {\n return [renderExpandAll(), firstColumn.name]\n }\n }\n\n const result = new Forest<TableColumn, any>({\n data: sortedColumns,\n createNode(data, index, depth, _f, parent) {\n return new ColumnNode(data, index, depth, parent)\n }\n })\n\n columnForest.value = result\n },\n { immediate: true }\n )\n\n const headers = computed(() => {\n const headers: ColumnNode[][] = []\n const forest = columnForest.value\n if (!forest) return headers\n\n // Forest.bfs 对每个根单独 BFS,按 depth 拼行会把后续根节点错放到深层,且根节点无 parent,\n // 回溯 leafs 时会读到 undefined。这里从所有根一次性层序遍历,与多列表头布局一致。\n const queue: ColumnNode[] = [...forest.roots]\n while (queue.length > 0) {\n const size = queue.length\n const layer: ColumnNode[] = []\n for (let i = 0; i < size; i++) {\n const node = queue.shift()!\n layer.push(node)\n const ch = node.children\n if (ch?.length) {\n for (const c of ch) {\n queue.push(c)\n }\n }\n }\n headers.push(layer)\n }\n\n // 从叶子节点开始回溯计算每个节点的累计叶子节点数量,叶子节点数量代表表头的宽度\n for (let i = headers.length - 1; i > 0; i--) {\n const header = headers[i]!\n\n header.forEach((node) => {\n const parent = node.parent\n if (!parent) return\n if (parent.leafs !== undefined) return\n parent.leafs = parent.children!.reduce((sum, node) => {\n return sum + (node.leafs ?? 1)\n }, 0)\n })\n }\n\n return headers\n })\n\n /** 除展开按钮之外的列 */\n const columns = shallowRef<ColumnNode[]>([])\n\n /** 所有叶子节点 */\n const leafColumns = shallowRef<ColumnNode[]>([])\n\n const expandColumn = shallowRef<ColumnNode>()\n\n // 监听列的变化\n watch(\n [columnForest, () => props.tree, () => props.expandable],\n ([forest, tree, expandable]) => {\n const _columns: ColumnNode[] = []\n\n forest?.dfs((node) => {\n if (node.isLeaf) {\n _columns.push(node)\n }\n })\n\n leafColumns.value = _columns\n\n if (tree || expandable) {\n expandColumn.value = _columns[0]\n columns.value = _columns.slice(1)\n } else {\n columns.value = _columns\n expandColumn.value = undefined\n }\n },\n { immediate: true }\n )\n\n return {\n /** 第一列 */\n expandColumn,\n /** 所有列 */\n leafColumns,\n /** 列 */\n columns,\n /** 表格头的分层展示 */\n headers\n }\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,mBACd,SACA,aACe;CACf,QAAQ,SAAS,QAAQ;EACvB,IAAI,MAAM,SAAS;GACjB,KAAK,MAAM,OAAO,aAAa;IAC7B,IAAI,KAAK,SAAS,KAAA,GAAW;IAC7B,KAAK,OAAO,YAAY;GAC1B;EACF,CAAC;CACH,CAAC;CACD,OAAO;AACT;AA2BA,SAAgB,WAA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MAAM,SAAS,KAAK;GACpB,IAAI,CAAC,QAAQ;GACb,IAAI,OAAO,UAAU,KAAA,GAAW;GAChC,OAAO,QAAQ,OAAO,SAAU,QAAQ,KAAK,SAAS;IACpD,OAAO,OAAO,KAAK,SAAS;GAC9B,GAAG,CAAC;EACN,CAAC;EAGH,OAAO;CACT,CAAC;;CAGD,MAAM,UAAU,WAAyB,CAAC,CAAC;;CAG3C,MAAM,cAAc,WAAyB,CAAC,CAAC;CAE/C,MAAM,eAAe,WAAuB;CAG5C,MACE;EAAC;QAAoB,MAAM;QAAY,MAAM;CAAU,IACtD,CAAC,QAAQ,MAAM,gBAAgB;EAC9B,MAAM,WAAyB,CAAC;EAEhC,QAAQ,KAAK,SAAS;GACpB,IAAI,KAAK,QACP,SAAS,KAAK,IAAI;EAEtB,CAAC;EAED,YAAY,QAAQ;EAEpB,IAAI,QAAQ,YAAY;GACtB,aAAa,QAAQ,SAAS;GAC9B,QAAQ,QAAQ,SAAS,MAAM,CAAC;EAClC,OAAO;GACL,QAAQ,QAAQ;GAChB,aAAa,QAAQ,KAAA;EACvB;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAEA,OAAO;;EAEL;;EAEA;;EAEA;;EAEA;CACF;AACF"}
1
+ {"version":3,"file":"use-columns.js","names":["UButton","UIcon"],"sources":["../../../src/components/table/use-columns.ts"],"sourcesContent":["import { Forest, dfs, last } from '@cat-kit/core'\nimport { ArrowRight } from '@veltra/icons/normal'\nimport { type BEM } from '@veltra/utils'\nimport { computed, createVNode, shallowRef, watch, type ComputedRef, type ShallowRef } from 'vue'\n\nimport type { TableColumn, TableProps } from '../../types'\nimport { UButton } from '../button'\nimport { UIcon } from '../icon'\nimport { ColumnNode } from './node/col'\n\n/**\n * 定义表格列\n * @param columns 表格列\n */\nexport function defineTableColumns(\n columns: TableColumn[],\n commonProps?: Partial<Pick<TableColumn, 'align' | 'minWidth'>>\n): TableColumn[] {\n columns.forEach((col) => {\n dfs(col, (node) => {\n for (const key in commonProps) {\n if (node[key] !== undefined) continue\n node[key] = commonProps[key]\n }\n })\n })\n return columns\n}\n\nexport interface ColumnConfig {\n /** 表头 */\n headers: ComputedRef<ColumnNode[][]>\n\n /**\n * body列, 在body中使用\n */\n columns: ShallowRef<ColumnNode[]>\n\n /** 所有叶子列 */\n leafColumns: ShallowRef<ColumnNode[]>\n\n /** 第一列 */\n expandColumn: ShallowRef<ColumnNode | undefined>\n}\n\ninterface Options {\n props: TableProps\n cls: BEM<'table'>\n /** 创建复选框 */\n createCheckColumn: () => TableColumn\n createSelectColumn: () => TableColumn\n toggleAllTreeRowExpand: () => void\n}\n\nexport function useColumns(options: Options): ColumnConfig {\n const { props, createCheckColumn, createSelectColumn, toggleAllTreeRowExpand, cls } = options\n\n /** 前置列 */\n const preColumns = computed<TableColumn[]>(() => {\n const { selectable, checkable, showIndex } = props\n\n const columns: TableColumn[] = []\n\n if (selectable) {\n columns.push(createSelectColumn())\n } else if (checkable) {\n columns.push(createCheckColumn())\n }\n if (showIndex) {\n columns.push({\n key: '__index__',\n name: '#',\n resizable: false,\n width: 60,\n minWidth: 60,\n align: 'center',\n fixed: 'left',\n render({ row }) {\n return row.index + 1\n }\n })\n }\n\n return columns\n })\n\n const columnForest = shallowRef<Forest<TableColumn, any>>()\n\n const renderExpandAll = () =>\n createVNode(\n UButton,\n {\n text: true,\n title: '展开或收起全部',\n class: cls.e('expand-all'),\n type: 'primary',\n size: 'small',\n circle: true,\n onClick: (e) => {\n e.stopPropagation()\n toggleAllTreeRowExpand()\n }\n },\n () => [createVNode(UIcon, undefined, () => [createVNode(ArrowRight)])]\n )\n\n watch(\n [preColumns, () => props.columns, () => props.tree, () => props.expandable],\n ([preColumns, columns, tree, expandable]) => {\n /** 固定到左侧的列 */\n const fixedOnLeft: TableColumn[] = [...preColumns]\n /** 未固定的列 */\n const unfixed: TableColumn[] = []\n /** 固定到右侧的列 */\n const fixedOnRight: TableColumn[] = []\n\n columns?.forEach((column) => {\n if (!column.fixed || column.children) {\n column.fixed = undefined\n return unfixed.push(column)\n }\n if (column.fixed === 'left') {\n fixedOnLeft.push(column)\n } else {\n fixedOnRight.push(column)\n }\n })\n\n if (last(fixedOnLeft)) {\n last(fixedOnLeft)!.isLastFixed = true\n }\n if (fixedOnRight[0]) {\n fixedOnRight[0].isFirstFixed = true\n }\n\n const sortedColumns = [...fixedOnLeft, ...unfixed, ...fixedOnRight]\n\n if (sortedColumns.length > 0) {\n // 操作时避免改变原数据\n const firstColumn = { ...sortedColumns[0] } as TableColumn\n sortedColumns[0] = firstColumn\n\n // 树形表格需要给第一列添加展开按钮\n // 因此要重新设置第一列的宽度和对齐方式\n if (tree || expandable) {\n firstColumn.align = 'left'\n firstColumn.width = firstColumn.width ? firstColumn.width + 60 : undefined\n\n const oldNameRender = firstColumn.nameRender\n\n firstColumn.nameRender = oldNameRender\n ? (ctx) => {\n const oldNodes = oldNameRender!(ctx)\n return [renderExpandAll(), ...(Array.isArray(oldNodes) ? oldNodes : [oldNodes])]\n }\n : () => {\n return [renderExpandAll(), firstColumn.name]\n }\n }\n }\n\n const result = new Forest<TableColumn, any>({\n data: sortedColumns,\n createNode(data, index, depth, _f, parent) {\n return new ColumnNode(data, index, depth, parent)\n }\n })\n\n columnForest.value = result\n },\n { immediate: true }\n )\n\n const headers = computed(() => {\n const headers: ColumnNode[][] = []\n const forest = columnForest.value\n if (!forest) return headers\n\n // Forest.bfs 对每个根单独 BFS,按 depth 拼行会把后续根节点错放到深层,且根节点无 parent,\n // 回溯 leafs 时会读到 undefined。这里从所有根一次性层序遍历,与多列表头布局一致。\n const queue: ColumnNode[] = [...forest.roots]\n while (queue.length > 0) {\n const size = queue.length\n const layer: ColumnNode[] = []\n for (let i = 0; i < size; i++) {\n const node = queue.shift()!\n layer.push(node)\n const ch = node.children\n if (ch?.length) {\n for (const c of ch) {\n queue.push(c)\n }\n }\n }\n headers.push(layer)\n }\n\n // 从叶子节点开始回溯计算每个节点的累计叶子节点数量,叶子节点数量代表表头的宽度\n for (let i = headers.length - 1; i > 0; i--) {\n const header = headers[i]!\n\n header.forEach((node) => {\n const parent = node.parent\n if (!parent) return\n if (parent.leafs !== undefined) return\n parent.leafs = parent.children!.reduce((sum, node) => {\n return sum + (node.leafs ?? 1)\n }, 0)\n })\n }\n\n return headers\n })\n\n /** 除展开按钮之外的列 */\n const columns = shallowRef<ColumnNode[]>([])\n\n /** 所有叶子节点 */\n const leafColumns = shallowRef<ColumnNode[]>([])\n\n const expandColumn = shallowRef<ColumnNode>()\n\n // 监听列的变化\n watch(\n [columnForest, () => props.tree, () => props.expandable],\n ([forest, tree, expandable]) => {\n const _columns: ColumnNode[] = []\n\n forest?.dfs((node) => {\n if (node.isLeaf) {\n _columns.push(node)\n }\n })\n\n leafColumns.value = _columns\n\n if (tree || expandable) {\n expandColumn.value = _columns[0]\n columns.value = _columns.slice(1)\n } else {\n columns.value = _columns\n expandColumn.value = undefined\n }\n },\n { immediate: true }\n )\n\n return {\n /** 第一列 */\n expandColumn,\n /** 所有列 */\n leafColumns,\n /** 列 */\n columns,\n /** 表格头的分层展示 */\n headers\n }\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,mBACd,SACA,aACe;CACf,QAAQ,SAAS,QAAQ;EACvB,IAAI,MAAM,SAAS;GACjB,KAAK,MAAM,OAAO,aAAa;IAC7B,IAAI,KAAK,SAAS,KAAA,GAAW;IAC7B,KAAK,OAAO,YAAY;GAC1B;EACF,CAAC;CACH,CAAC;CACD,OAAO;AACT;AA2BA,SAAgB,WAAW,SAAgC;CACzD,MAAM,EAAE,OAAO,mBAAmB,oBAAoB,wBAAwB,QAAQ;;CAGtF,MAAM,aAAa,eAA8B;EAC/C,MAAM,EAAE,YAAY,WAAW,cAAc;EAE7C,MAAM,UAAyB,CAAC;EAEhC,IAAI,YACF,QAAQ,KAAK,mBAAmB,CAAC;OAC5B,IAAI,WACT,QAAQ,KAAK,kBAAkB,CAAC;EAElC,IAAI,WACF,QAAQ,KAAK;GACX,KAAK;GACL,M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CAAC,CAAC;CAE/C,MAAM,eAAe,WAAuB;CAG5C,MACE;EAAC;QAAoB,MAAM;QAAY,MAAM;CAAU,IACtD,CAAC,QAAQ,MAAM,gBAAgB;EAC9B,MAAM,WAAyB,CAAC;EAEhC,QAAQ,KAAK,SAAS;GACpB,IAAI,KAAK,QACP,SAAS,KAAK,IAAI;EAEtB,CAAC;EAED,YAAY,QAAQ;EAEpB,IAAI,QAAQ,YAAY;GACtB,aAAa,QAAQ,SAAS;GAC9B,QAAQ,QAAQ,SAAS,MAAM,CAAC;EAClC,OAAO;GACL,QAAQ,QAAQ;GAChB,aAAa,QAAQ,KAAA;EACvB;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAEA,OAAO;;EAEL;;EAEA;;EAEA;;EAEA;CACF;AACF"}
@@ -20,10 +20,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
20
20
  onFocus?: (() => any) | undefined;
21
21
  onBlur?: (() => any) | undefined;
22
22
  }>, {
23
- readonly: boolean;
24
- disabled: boolean;
25
23
  placeholder: string;
26
24
  clearable: boolean;
25
+ disabled: boolean;
26
+ readonly: boolean;
27
27
  resize: boolean;
28
28
  autosize: boolean;
29
29
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -13,8 +13,8 @@ declare const __VLS_base: import("vue").DefineComponent<TipProps, {}, {}, {}, {}
13
13
  contentTag: string;
14
14
  visible: boolean;
15
15
  direction: TipDirection;
16
- alignment: TipAlign;
17
16
  content: string;
17
+ alignment: TipAlign;
18
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
19
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
20
20
  declare const _default: typeof __VLS_export;
@@ -23,15 +23,15 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
23
23
  onChange?: ((value?: string | number | undefined, selectedData?: Record<string, any> | undefined) => any) | undefined;
24
24
  "onUpdate:text"?: ((text?: string | undefined) => any) | undefined;
25
25
  }>, {
26
- readonly: boolean;
27
- disabled: boolean;
28
- minWidth: string;
29
26
  expandAll: boolean;
30
27
  labelKey: string;
31
28
  valueKey: string;
32
29
  placeholder: string;
33
30
  clearable: boolean;
34
31
  filterable: boolean;
32
+ minWidth: string;
33
+ disabled: boolean;
34
+ readonly: boolean;
35
35
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
36
36
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
37
37
  declare const _default: typeof __VLS_export;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltra/desktop",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -68,11 +68,11 @@
68
68
  "@cat-kit/core": ">=1.1.6",
69
69
  "@cat-kit/excel": ">=1.0.0",
70
70
  "@cat-kit/fe": "^1.1.6",
71
- "@veltra/compositions": "1.2.2",
72
- "@veltra/directives": "1.2.2",
73
- "@veltra/icons": "1.2.2",
74
- "@veltra/styles": "1.2.2",
75
- "@veltra/utils": "1.2.2",
71
+ "@veltra/compositions": "1.2.4",
72
+ "@veltra/directives": "1.2.4",
73
+ "@veltra/icons": "1.2.4",
74
+ "@veltra/styles": "1.2.4",
75
+ "@veltra/utils": "1.2.4",
76
76
  "vue": ">=3.5.0"
77
77
  }
78
78
  }
@@ -134,26 +134,29 @@ export function useColumns(options: Options): ColumnConfig {
134
134
  }
135
135
 
136
136
  const sortedColumns = [...fixedOnLeft, ...unfixed, ...fixedOnRight]
137
- // 操作时避免改变原数据
138
- const firstColumn = { ...sortedColumns[0] } as TableColumn
139
- sortedColumns[0] = firstColumn
140
-
141
- // 树形表格需要给第一列添加展开按钮
142
- // 因此要重新设置第一列的宽度和对齐方式
143
- if ((!!tree || expandable) && firstColumn) {
144
- firstColumn.align = 'left'
145
- firstColumn.width = firstColumn.width ? firstColumn.width + 60 : undefined
146
-
147
- const oldNameRender = firstColumn.nameRender
148
-
149
- firstColumn.nameRender = oldNameRender
150
- ? (ctx) => {
151
- const oldNodes = oldNameRender!(ctx)
152
- return [renderExpandAll(), ...(Array.isArray(oldNodes) ? oldNodes : [oldNodes])]
153
- }
154
- : () => {
155
- return [renderExpandAll(), firstColumn.name]
156
- }
137
+
138
+ if (sortedColumns.length > 0) {
139
+ // 操作时避免改变原数据
140
+ const firstColumn = { ...sortedColumns[0] } as TableColumn
141
+ sortedColumns[0] = firstColumn
142
+
143
+ // 树形表格需要给第一列添加展开按钮
144
+ // 因此要重新设置第一列的宽度和对齐方式
145
+ if (tree || expandable) {
146
+ firstColumn.align = 'left'
147
+ firstColumn.width = firstColumn.width ? firstColumn.width + 60 : undefined
148
+
149
+ const oldNameRender = firstColumn.nameRender
150
+
151
+ firstColumn.nameRender = oldNameRender
152
+ ? (ctx) => {
153
+ const oldNodes = oldNameRender!(ctx)
154
+ return [renderExpandAll(), ...(Array.isArray(oldNodes) ? oldNodes : [oldNodes])]
155
+ }
156
+ : () => {
157
+ return [renderExpandAll(), firstColumn.name]
158
+ }
159
+ }
157
160
  }
158
161
 
159
162
  const result = new Forest<TableColumn, any>({