@veltra/desktop 1.1.32 → 1.1.33

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 (38) 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 +1 -1
  4. package/dist/components/batch-edit/batch-edit.vue.d.ts +1 -1
  5. package/dist/components/cascade/cascade.vue.d.ts +2 -2
  6. package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
  7. package/dist/components/checkbox-group/checkbox-group.vue.d.ts +1 -1
  8. package/dist/components/date-panel/date-panel.vue.d.ts +1 -1
  9. package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
  10. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
  11. package/dist/components/drawer/drawer.vue.d.ts +2 -2
  12. package/dist/components/file-viewer/file-viewer.vue.d.ts +1 -1
  13. package/dist/components/input/input.vue.d.ts +1 -1
  14. package/dist/components/multi-select/multi-select.vue.d.ts +2 -2
  15. package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +2 -2
  16. package/dist/components/number/number.vue.d.ts +1 -1
  17. package/dist/components/number-input/number-input.vue.d.ts +1 -1
  18. package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
  19. package/dist/components/password-input/password-input.vue.d.ts +1 -1
  20. package/dist/components/progress-nodes/progress-nodes.vue.d.ts +2 -2
  21. package/dist/components/radio-group/radio-group.vue.d.ts +1 -1
  22. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
  23. package/dist/components/select/select.vue.d.ts +1 -1
  24. package/dist/components/steps/steps.vue.d.ts +1 -1
  25. package/dist/components/table/node/col.d.ts +5 -0
  26. package/dist/components/table/node/col.js +6 -0
  27. package/dist/components/table/node/col.js.map +1 -1
  28. package/dist/components/table/use-col-resize.js +10 -10
  29. package/dist/components/table/use-col-resize.js.map +1 -1
  30. package/dist/components/tabs/tabs-horizontal.vue.d.ts +2 -2
  31. package/dist/components/tabs/tabs-vertical.vue.d.ts +2 -2
  32. package/dist/components/tabs/tabs.vue.d.ts +2 -2
  33. package/dist/components/textarea/textarea.vue.d.ts +1 -1
  34. package/dist/components/tip/tip.vue.d.ts +1 -1
  35. package/dist/components/tree-select/tree-select.vue.d.ts +2 -2
  36. package/package.json +6 -6
  37. package/src/components/table/node/col.ts +7 -0
  38. package/src/components/table/use-col-resize.ts +18 -16
@@ -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
- type: import("@veltra/utils").ColorType;
10
9
  text: boolean;
11
10
  size: "small" | "default" | "large";
12
- max: number;
11
+ type: import("@veltra/utils").ColorType;
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
- type: ButtonType;
16
15
  text: boolean;
17
16
  size: import("@veltra/utils").ComponentSize;
17
+ type: ButtonType;
18
18
  circle: boolean;
19
19
  loading: boolean;
20
20
  inDropdown: boolean;
@@ -22,9 +22,9 @@ 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
- disabled: boolean;
26
25
  placeholder: string;
27
26
  clearable: boolean;
27
+ disabled: boolean;
28
28
  readonly: boolean;
29
29
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
30
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -7,11 +7,11 @@ declare const __VLS_export: <Model extends IFormModel>(__VLS_props: NonNullable<
7
7
  "onUpdate:selected"?: ((value: Record<string, any> | undefined) => any) | undefined;
8
8
  "onUpdate:checked"?: ((value: Record<string, any>[]) => any) | undefined;
9
9
  "onUpdate:current"?: ((row?: TableRow | undefined) => any) | undefined;
10
+ "onUpdate:data"?: ((value: Record<string, any>[]) => any) | undefined;
10
11
  "onUpdate:rows"?: ((rows: TableRow[]) => any) | undefined;
11
12
  "onUpdate:forest"?: ((rows?: import("@cat-kit/core").Forest<Record<string, unknown>, any> | undefined) => any) | undefined;
12
13
  "onCell-click"?: ((row: TableRow, column: TableColumn, ev: MouseEvent) => any) | undefined;
13
14
  "onRow-click"?: ((row: TableRow, ev: MouseEvent) => any) | undefined;
14
- "onUpdate:data"?: ((value: Record<string, any>[]) => any) | undefined;
15
15
  }> & (typeof globalThis extends {
16
16
  __VLS_PROPS_FALLBACK: infer P;
17
17
  } ? P : {});
@@ -9,7 +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
- disabled: boolean;
13
12
  labelKey: string;
14
13
  valueKey: string;
15
14
  childrenKey: string;
@@ -17,9 +16,10 @@ declare const __VLS_export: import("vue").DefineComponent<CascadeProps, {}, {},
17
16
  placeholder: string;
18
17
  clearable: boolean;
19
18
  filterable: boolean;
19
+ disabled: boolean;
20
20
  readonly: boolean;
21
- separator: string;
22
21
  visibilityLimit: number;
22
+ separator: string;
23
23
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
24
  declare const _default: typeof __VLS_export;
25
25
  //#endregion
@@ -18,8 +18,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
18
18
  onChange?: ((checked: boolean) => any) | undefined;
19
19
  }>, {
20
20
  disabled: boolean;
21
- type: import("@veltra/utils").ColorType;
22
21
  readonly: boolean;
22
+ type: import("@veltra/utils").ColorType;
23
23
  round: boolean;
24
24
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
25
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -12,9 +12,9 @@ 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
- disabled: boolean;
16
15
  labelKey: string;
17
16
  valueKey: string;
17
+ disabled: boolean;
18
18
  readonly: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const _default: typeof __VLS_export;
@@ -7,8 +7,8 @@ declare const __VLS_export: import("vue").DefineComponent<DatePanelProps, {}, {}
7
7
  "onSelect:range-date"?: ((rangeDate?: [import("@cat-kit/core").Dater, import("@cat-kit/core").Dater] | undefined) => any) | undefined;
8
8
  "onSelect:date"?: ((date: import("@cat-kit/core").Dater) => any) | undefined;
9
9
  }>, {
10
- type: "date" | "month" | "year";
11
10
  size: import("@veltra/utils").ComponentSize;
11
+ type: "date" | "month" | "year";
12
12
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
13
  declare const _default: typeof __VLS_export;
14
14
  //#endregion
@@ -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
- disabled: boolean;
9
- type: "date" | "month" | "year";
10
8
  placeholder: string;
11
9
  clearable: boolean;
10
+ disabled: boolean;
12
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
- disabled: boolean;
9
- type: "date" | "month" | "year";
10
8
  placeholder: [string, string];
11
9
  clearable: boolean;
10
+ disabled: boolean;
12
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
@@ -12,12 +12,12 @@ type __VLS_Slots = {} & {
12
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
13
  "update:modelValue": (value: boolean) => any;
14
14
  } & {
15
- close: () => any;
16
15
  "update:modelValue": (value: boolean) => any;
16
+ close: () => any;
17
17
  closed: () => any;
18
18
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
19
- onClose?: (() => any) | undefined;
20
19
  "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
20
+ onClose?: (() => any) | undefined;
21
21
  onClosed?: (() => any) | undefined;
22
22
  }>, {
23
23
  direction: DrawerDirection;
@@ -27,8 +27,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, _Fi
27
27
  error: unknown;
28
28
  }) => any) | undefined;
29
29
  }>, {
30
- open: boolean;
31
30
  modelValue: string;
31
+ open: boolean;
32
32
  sidebarWidth: string | number | false;
33
33
  sheetMaxRows: number;
34
34
  downloadable: boolean;
@@ -32,9 +32,9 @@ 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
- disabled: boolean;
36
35
  placeholder: string;
37
36
  clearable: boolean;
37
+ disabled: boolean;
38
38
  readonly: boolean;
39
39
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
40
40
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -26,12 +26,12 @@ 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
- minWidth: string;
30
- disabled: boolean;
31
29
  labelKey: string;
32
30
  valueKey: string;
33
31
  placeholder: string;
34
32
  clearable: boolean;
33
+ minWidth: string;
34
+ disabled: boolean;
35
35
  readonly: boolean;
36
36
  visibilityLimit: number;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -21,14 +21,14 @@ 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
- minWidth: string;
25
- disabled: boolean;
26
24
  expandAll: boolean;
27
25
  labelKey: string;
28
26
  valueKey: string;
29
27
  placeholder: string;
30
28
  clearable: boolean;
31
29
  filterable: boolean;
30
+ minWidth: string;
31
+ disabled: boolean;
32
32
  readonly: boolean;
33
33
  visibilityLimit: number;
34
34
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -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
- format: "currency" | "percent" | "decimal";
5
4
  duration: number;
5
+ format: "currency" | "percent" | "decimal";
6
6
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  //#endregion
@@ -20,9 +20,9 @@ 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
- disabled: boolean;
24
23
  placeholder: string;
25
24
  clearable: boolean;
25
+ disabled: boolean;
26
26
  readonly: boolean;
27
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -22,8 +22,8 @@ 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
- disabled: boolean;
26
25
  clearable: boolean;
26
+ disabled: boolean;
27
27
  readonly: boolean;
28
28
  startPlaceholder: string;
29
29
  endPlaceholder: string;
@@ -13,8 +13,8 @@ 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
- disabled: boolean;
17
16
  clearable: boolean;
17
+ disabled: boolean;
18
18
  readonly: boolean;
19
19
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -13,11 +13,11 @@ type __VLS_Slots = {} & {
13
13
  default?: (props: typeof __VLS_3) => any;
14
14
  };
15
15
  declare const __VLS_base: import("vue").DefineComponent<ProgressNodesProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
16
- click: (node: Record<string, any>, index: number) => any;
17
16
  "update:modelValue": (value: string | number) => any;
17
+ click: (node: Record<string, any>, index: number) => any;
18
18
  }, string, import("vue").PublicProps, Readonly<ProgressNodesProps> & Readonly<{
19
- onClick?: ((node: Record<string, any>, index: number) => any) | undefined;
20
19
  "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
20
+ onClick?: ((node: Record<string, any>, index: number) => any) | undefined;
21
21
  }>, {
22
22
  labelKey: string;
23
23
  valueKey: string;
@@ -14,9 +14,9 @@ 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
- disabled: boolean;
18
17
  labelKey: string;
19
18
  valueKey: string;
19
+ disabled: boolean;
20
20
  readonly: boolean;
21
21
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
22
  declare const _default: typeof __VLS_export;
@@ -10,8 +10,8 @@ declare const __VLS_export: import("vue").DefineComponent<RichTextEditorProps &
10
10
  }> & Readonly<{
11
11
  "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
12
12
  }>, {
13
- disabled: boolean;
14
13
  placeholder: string;
14
+ disabled: boolean;
15
15
  readonly: boolean;
16
16
  format: RichTextFormat;
17
17
  toolbar: ToolbarItem[];
@@ -24,11 +24,11 @@ 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
- disabled: boolean;
28
27
  labelKey: string;
29
28
  valueKey: string;
30
29
  placeholder: string;
31
30
  clearable: boolean;
31
+ disabled: boolean;
32
32
  readonly: boolean;
33
33
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
34
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -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>;
@@ -37,6 +37,11 @@ declare class ColumnNode extends TreeNode<TableColumn, ColumnNode> {
37
37
  get isFirstFixed(): boolean;
38
38
  /** 是否是可调整宽度的列 */
39
39
  get resizable(): boolean;
40
+ /**
41
+ * 是否在列配置上显式指定了 width,或经表头拖拽锁定。
42
+ * 此类列不参与剩余宽度的均分。
43
+ */
44
+ explicitWidth: boolean;
40
45
  style: Record<string, number>;
41
46
  constructor(val: TableColumn, index: number, depth: number, parent?: ColumnNode);
42
47
  }
@@ -74,9 +74,15 @@ var ColumnNode = class extends TreeNode {
74
74
  get resizable() {
75
75
  return this.data.resizable ?? true;
76
76
  }
77
+ /**
78
+ * 是否在列配置上显式指定了 width,或经表头拖拽锁定。
79
+ * 此类列不参与剩余宽度的均分。
80
+ */
81
+ explicitWidth;
77
82
  style = reactive({});
78
83
  constructor(val, index, depth, parent) {
79
84
  super(isReactive(val) ? val : shallowReactive(val), index, depth, parent);
85
+ this.explicitWidth = val.width !== void 0;
80
86
  }
81
87
  };
82
88
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"col.js","names":[],"sources":["../../../../src/components/table/node/col.ts"],"sourcesContent":["import { TreeNode } from '@cat-kit/core'\nimport { isReactive, reactive, shallowReactive } from 'vue'\n\nimport type { TableColumn, TableColumnAlign } from '../../../types'\n\nexport class ColumnNode extends TreeNode<TableColumn, ColumnNode> {\n declare children?: ColumnNode[] | undefined\n declare parent?: ColumnNode\n /** 叶子节点数量 */\n leafs?: number\n\n nextNode: ColumnNode | null = null\n\n /** 列key */\n get key(): string {\n return this.data.key\n }\n set key(val) {\n this.data.key = val\n }\n /** 列名 */\n get name(): string {\n return this.data.name\n }\n set name(val) {\n this.data.name = val\n }\n\n /**\n * 列对齐方式\n * @default 'left'\n */\n get align(): TableColumnAlign {\n return this.data.align ?? 'left'\n }\n set align(val) {\n this.data.align = val\n }\n\n get headerAlign(): TableColumnAlign {\n return this.data.headerAlign ?? this.align\n }\n set headerAlign(val) {\n this.data.headerAlign = val\n }\n\n /** 宽度 */\n get width(): number | undefined {\n const { width } = this.data\n if (!width || (this.minWidth && width && width < this.minWidth)) {\n return this.minWidth\n }\n return width\n }\n set width(val) {\n if (this.minWidth && val && val < this.minWidth) {\n val = this.minWidth\n }\n this.data.width = val\n }\n /** 最小宽度 */\n get minWidth(): number | undefined {\n const minWidth = this.data.minWidth\n if (!minWidth && this.isLeaf) {\n return 100\n }\n return minWidth\n }\n set minWidth(val) {\n this.data.minWidth = val\n }\n\n /** 列固定方向 */\n get fixed(): 'left' | 'right' | undefined {\n if (this.depth > 0) return\n return this.data.fixed\n }\n set fixed(val) {\n this.data.fixed = val\n }\n\n /** 是否是左侧的最后一个固定列 */\n get isLastFixed(): boolean {\n return this.data.isLastFixed ?? false\n }\n\n /** 是否是右侧的第一个固定列 */\n get isFirstFixed(): boolean {\n return this.data.isFirstFixed ?? false\n }\n\n /** 是否是可调整宽度的列 */\n get resizable(): boolean {\n return this.data.resizable ?? true\n }\n\n style: Record<string, number> = reactive({})\n\n constructor(val: TableColumn, index: number, depth: number, parent?: ColumnNode) {\n super(isReactive(val) ? val : shallowReactive(val), index, depth, parent)\n }\n}\n"],"mappings":";;;AAKA,IAAa,aAAb,cAAgC,SAAkC;;CAIhE;CAEA,WAA8B;;CAG9B,IAAI,MAAc;EAChB,OAAO,KAAK,KAAK;CACnB;CACA,IAAI,IAAI,KAAK;EACX,KAAK,KAAK,MAAM;CAClB;;CAEA,IAAI,OAAe;EACjB,OAAO,KAAK,KAAK;CACnB;CACA,IAAI,KAAK,KAAK;EACZ,KAAK,KAAK,OAAO;CACnB;;;;;CAMA,IAAI,QAA0B;EAC5B,OAAO,KAAK,KAAK,SAAS;CAC5B;CACA,IAAI,MAAM,KAAK;EACb,KAAK,KAAK,QAAQ;CACpB;CAEA,IAAI,cAAgC;EAClC,OAAO,KAAK,KAAK,eAAe,KAAK;CACvC;CACA,IAAI,YAAY,KAAK;EACnB,KAAK,KAAK,cAAc;CAC1B;;CAGA,IAAI,QAA4B;EAC9B,MAAM,EAAE,UAAU,KAAK;EACvB,IAAI,CAAC,SAAU,KAAK,YAAY,SAAS,QAAQ,KAAK,UACpD,OAAO,KAAK;EAEd,OAAO;CACT;CACA,IAAI,MAAM,KAAK;EACb,IAAI,KAAK,YAAY,OAAO,MAAM,KAAK,UACrC,MAAM,KAAK;EAEb,KAAK,KAAK,QAAQ;CACpB;;CAEA,IAAI,WAA+B;EACjC,MAAM,WAAW,KAAK,KAAK;EAC3B,IAAI,CAAC,YAAY,KAAK,QACpB,OAAO;EAET,OAAO;CACT;CACA,IAAI,SAAS,KAAK;EAChB,KAAK,KAAK,WAAW;CACvB;;CAGA,IAAI,QAAsC;EACxC,IAAI,KAAK,QAAQ,GAAG;EACpB,OAAO,KAAK,KAAK;CACnB;CACA,IAAI,MAAM,KAAK;EACb,KAAK,KAAK,QAAQ;CACpB;;CAGA,IAAI,cAAuB;EACzB,OAAO,KAAK,KAAK,eAAe;CAClC;;CAGA,IAAI,eAAwB;EAC1B,OAAO,KAAK,KAAK,gBAAgB;CACnC;;CAGA,IAAI,YAAqB;EACvB,OAAO,KAAK,KAAK,aAAa;CAChC;CAEA,QAAgC,SAAS,CAAC,CAAC;CAE3C,YAAY,KAAkB,OAAe,OAAe,QAAqB;EAC/E,MAAM,WAAW,GAAG,IAAI,MAAM,gBAAgB,GAAG,GAAG,OAAO,OAAO,MAAM;CAC1E;AACF"}
1
+ {"version":3,"file":"col.js","names":[],"sources":["../../../../src/components/table/node/col.ts"],"sourcesContent":["import { TreeNode } from '@cat-kit/core'\nimport { isReactive, reactive, shallowReactive } from 'vue'\n\nimport type { TableColumn, TableColumnAlign } from '../../../types'\n\nexport class ColumnNode extends TreeNode<TableColumn, ColumnNode> {\n declare children?: ColumnNode[] | undefined\n declare parent?: ColumnNode\n /** 叶子节点数量 */\n leafs?: number\n\n nextNode: ColumnNode | null = null\n\n /** 列key */\n get key(): string {\n return this.data.key\n }\n set key(val) {\n this.data.key = val\n }\n /** 列名 */\n get name(): string {\n return this.data.name\n }\n set name(val) {\n this.data.name = val\n }\n\n /**\n * 列对齐方式\n * @default 'left'\n */\n get align(): TableColumnAlign {\n return this.data.align ?? 'left'\n }\n set align(val) {\n this.data.align = val\n }\n\n get headerAlign(): TableColumnAlign {\n return this.data.headerAlign ?? this.align\n }\n set headerAlign(val) {\n this.data.headerAlign = val\n }\n\n /** 宽度 */\n get width(): number | undefined {\n const { width } = this.data\n if (!width || (this.minWidth && width && width < this.minWidth)) {\n return this.minWidth\n }\n return width\n }\n set width(val) {\n if (this.minWidth && val && val < this.minWidth) {\n val = this.minWidth\n }\n this.data.width = val\n }\n /** 最小宽度 */\n get minWidth(): number | undefined {\n const minWidth = this.data.minWidth\n if (!minWidth && this.isLeaf) {\n return 100\n }\n return minWidth\n }\n set minWidth(val) {\n this.data.minWidth = val\n }\n\n /** 列固定方向 */\n get fixed(): 'left' | 'right' | undefined {\n if (this.depth > 0) return\n return this.data.fixed\n }\n set fixed(val) {\n this.data.fixed = val\n }\n\n /** 是否是左侧的最后一个固定列 */\n get isLastFixed(): boolean {\n return this.data.isLastFixed ?? false\n }\n\n /** 是否是右侧的第一个固定列 */\n get isFirstFixed(): boolean {\n return this.data.isFirstFixed ?? false\n }\n\n /** 是否是可调整宽度的列 */\n get resizable(): boolean {\n return this.data.resizable ?? true\n }\n\n /**\n * 是否在列配置上显式指定了 width,或经表头拖拽锁定。\n * 此类列不参与剩余宽度的均分。\n */\n explicitWidth: boolean\n\n style: Record<string, number> = reactive({})\n\n constructor(val: TableColumn, index: number, depth: number, parent?: ColumnNode) {\n super(isReactive(val) ? val : shallowReactive(val), index, depth, parent)\n this.explicitWidth = val.width !== undefined\n }\n}\n"],"mappings":";;;AAKA,IAAa,aAAb,cAAgC,SAAkC;;CAIhE;CAEA,WAA8B;;CAG9B,IAAI,MAAc;EAChB,OAAO,KAAK,KAAK;CACnB;CACA,IAAI,IAAI,KAAK;EACX,KAAK,KAAK,MAAM;CAClB;;CAEA,IAAI,OAAe;EACjB,OAAO,KAAK,KAAK;CACnB;CACA,IAAI,KAAK,KAAK;EACZ,KAAK,KAAK,OAAO;CACnB;;;;;CAMA,IAAI,QAA0B;EAC5B,OAAO,KAAK,KAAK,SAAS;CAC5B;CACA,IAAI,MAAM,KAAK;EACb,KAAK,KAAK,QAAQ;CACpB;CAEA,IAAI,cAAgC;EAClC,OAAO,KAAK,KAAK,eAAe,KAAK;CACvC;CACA,IAAI,YAAY,KAAK;EACnB,KAAK,KAAK,cAAc;CAC1B;;CAGA,IAAI,QAA4B;EAC9B,MAAM,EAAE,UAAU,KAAK;EACvB,IAAI,CAAC,SAAU,KAAK,YAAY,SAAS,QAAQ,KAAK,UACpD,OAAO,KAAK;EAEd,OAAO;CACT;CACA,IAAI,MAAM,KAAK;EACb,IAAI,KAAK,YAAY,OAAO,MAAM,KAAK,UACrC,MAAM,KAAK;EAEb,KAAK,KAAK,QAAQ;CACpB;;CAEA,IAAI,WAA+B;EACjC,MAAM,WAAW,KAAK,KAAK;EAC3B,IAAI,CAAC,YAAY,KAAK,QACpB,OAAO;EAET,OAAO;CACT;CACA,IAAI,SAAS,KAAK;EAChB,KAAK,KAAK,WAAW;CACvB;;CAGA,IAAI,QAAsC;EACxC,IAAI,KAAK,QAAQ,GAAG;EACpB,OAAO,KAAK,KAAK;CACnB;CACA,IAAI,MAAM,KAAK;EACb,KAAK,KAAK,QAAQ;CACpB;;CAGA,IAAI,cAAuB;EACzB,OAAO,KAAK,KAAK,eAAe;CAClC;;CAGA,IAAI,eAAwB;EAC1B,OAAO,KAAK,KAAK,gBAAgB;CACnC;;CAGA,IAAI,YAAqB;EACvB,OAAO,KAAK,KAAK,aAAa;CAChC;;;;;CAMA;CAEA,QAAgC,SAAS,CAAC,CAAC;CAE3C,YAAY,KAAkB,OAAe,OAAe,QAAqB;EAC/E,MAAM,WAAW,GAAG,IAAI,MAAM,gBAAgB,GAAG,GAAG,OAAO,OAAO,MAAM;EACxE,KAAK,gBAAgB,IAAI,UAAU,KAAA;CACrC;AACF"}
@@ -13,17 +13,16 @@ function useColResize(options) {
13
13
  function correctColumnStyle() {
14
14
  const containerWidth = scrollRef.value?.containerRef?.clientWidth;
15
15
  if (!containerWidth || !leafColumns.value.length) return;
16
- const allColumnsWidth = leafColumns.value.reduce((acc, cur) => {
17
- return acc + (cur.width ?? cur.minWidth);
18
- }, 0);
19
- if (allColumnsWidth < containerWidth) {
20
- const freeWidth = containerWidth - allColumnsWidth;
21
- const allocatableColumns = leafColumns.value.filter((column) => column.resizable !== false);
22
- const allocatedWidth = freeWidth / allocatableColumns.length;
23
- allocatableColumns.forEach((column) => {
24
- column.width = (column.width ?? column.minWidth) + allocatedWidth;
16
+ const flexColumns = leafColumns.value.filter((column) => !column.explicitWidth);
17
+ const totalBase = leafColumns.value.filter((column) => column.explicitWidth).reduce((acc, cur) => acc + (cur.width ?? cur.minWidth), 0) + flexColumns.reduce((acc, cur) => acc + cur.minWidth, 0);
18
+ if (flexColumns.length > 0 && totalBase < containerWidth) {
19
+ const allocatedWidth = (containerWidth - totalBase) / flexColumns.length;
20
+ flexColumns.forEach((column) => {
21
+ column.width = column.minWidth + allocatedWidth;
25
22
  });
26
- }
23
+ } else flexColumns.forEach((column) => {
24
+ column.data.width = void 0;
25
+ });
27
26
  const fixedLeft = leafColumns.value.filter((column) => column.fixed === "left");
28
27
  const fixedRight = leafColumns.value.filter((column) => column.fixed === "right");
29
28
  fixedLeft.reduce((acc, cur) => {
@@ -64,6 +63,7 @@ function useColResize(options) {
64
63
  }
65
64
  function handleResizeMouseup(e) {
66
65
  currentResizeColumn.width = Math.max(originWidth + e.pageX - originX, currentResizeColumn.minWidth);
66
+ currentResizeColumn.explicitWidth = true;
67
67
  showResizeLine.value = false;
68
68
  currentResizeColumn = null;
69
69
  correctColumnStyle();
@@ -1 +1 @@
1
- {"version":3,"file":"use-col-resize.js","names":[],"sources":["../../../src/components/table/use-col-resize.ts"],"sourcesContent":["import { nextTick, provide, shallowRef, watchEffect, type ShallowRef } from 'vue'\n\nimport type { ScrollExposed } from '../../types'\nimport { TableResizeKey } from './di'\nimport type { ColumnNode } from './node/col'\n\ninterface Options {\n scrollRef: ShallowRef<ScrollExposed | undefined>\n leafColumns: ShallowRef<ColumnNode[]>\n}\n\ninterface UseColResizeReturned {\n resizeLineRef: ShallowRef<HTMLElement | undefined>\n colgroupRef: ShallowRef<HTMLElement | undefined>\n showResizeLine: ShallowRef<boolean>\n handleResizeMousedown: (e: MouseEvent, resizeColumn: ColumnNode) => void\n}\n\nexport function useColResize(options: Options): UseColResizeReturned {\n const { scrollRef, leafColumns } = options\n\n const showResizeLine = shallowRef(false)\n\n const resizeLineRef = shallowRef<HTMLElement>()\n const colgroupRef = shallowRef<HTMLElement>()\n const headerRef = shallowRef<HTMLElement>()\n\n /**\n * 修正列样式\n */\n function correctColumnStyle() {\n // 获取表格容器宽度\n const containerWidth = scrollRef.value?.containerRef?.clientWidth\n\n if (!containerWidth || !leafColumns.value.length) return\n\n // 如果每个列都设置了宽度, 有两种情况\n // 1. 表格容器宽度大于所有列宽度之和,则将剩下的宽度均匀分布到所有列中\n // 2. 表格容器宽度小于所有列宽度之和,则什么也不管\n const allColumnsWidth = leafColumns.value.reduce((acc, cur) => {\n return acc + (cur.width ?? cur.minWidth!)\n }, 0)\n\n if (allColumnsWidth < containerWidth) {\n const freeWidth = containerWidth - allColumnsWidth\n\n const allocatableColumns = leafColumns.value.filter((column) => column.resizable !== false)\n\n const allocatedWidth = freeWidth / allocatableColumns.length\n\n allocatableColumns.forEach((column) => {\n column.width = (column.width ?? column.minWidth!) + allocatedWidth\n })\n }\n\n const fixedLeft = leafColumns.value.filter((column) => column.fixed === 'left')\n const fixedRight = leafColumns.value.filter((column) => column.fixed === 'right')\n\n fixedLeft.reduce((acc, cur) => {\n cur.style.left = acc\n return acc + (cur.width ?? cur.minWidth!)\n }, 0)\n\n fixedRight.reduceRight((acc, cur) => {\n cur.style.right = acc\n return acc + (cur.width ?? cur.minWidth!)\n }, 0)\n }\n\n watchEffect(correctColumnStyle)\n\n function updateResizeLine(transformX: number): void {\n if (!resizeLineRef.value) return\n resizeLineRef.value.style.transform = `translateX(${transformX}px)`\n }\n\n // 表格相对于页面左边缘的偏移量,\n // 此处作为缓存以减少频繁地调用 getBoundingClientRect 方法\n let containerLeft = 0\n let originX = 0\n let originWidth = 0\n let currentResizeColumn: ColumnNode | null = null\n\n function handleResizeMousedown(e: MouseEvent, resizeColumn: ColumnNode): void {\n const tableEl = scrollRef.value?.el\n if (!tableEl) return\n\n showResizeLine.value = true\n currentResizeColumn = resizeColumn\n originX = e.pageX\n originWidth = resizeColumn.width ?? 0\n\n const { left } = tableEl.getBoundingClientRect()\n containerLeft = left\n\n nextTick(() => {\n updateResizeLine(e.pageX - left)\n })\n\n document.addEventListener('mousemove', handleResizeMousemove)\n document.addEventListener('mouseup', handleResizeMouseup)\n }\n\n function handleResizeMousemove(e: MouseEvent): void {\n updateResizeLine(e.pageX - containerLeft)\n }\n\n function handleResizeMouseup(e: MouseEvent): void {\n currentResizeColumn!.width = Math.max(\n originWidth + e.pageX - originX,\n currentResizeColumn!.minWidth!\n )\n\n showResizeLine.value = false\n currentResizeColumn = null\n correctColumnStyle()\n\n document.removeEventListener('mouseup', handleResizeMouseup)\n document.removeEventListener('mousemove', handleResizeMousemove)\n }\n\n provide(TableResizeKey, { handleResizeMousedown, headerRef })\n\n return { resizeLineRef, colgroupRef, showResizeLine, handleResizeMousedown }\n}\n"],"mappings":";;;AAkBA,SAAgB,aAAa,SAAwC;CACnE,MAAM,EAAE,WAAW,gBAAgB;CAEnC,MAAM,iBAAiB,WAAW,KAAK;CAEvC,MAAM,gBAAgB,WAAwB;CAC9C,MAAM,cAAc,WAAwB;CAC5C,MAAM,YAAY,WAAwB;;;;CAK1C,SAAS,qBAAqB;EAE5B,MAAM,iBAAiB,UAAU,OAAO,cAAc;EAEtD,IAAI,CAAC,kBAAkB,CAAC,YAAY,MAAM,QAAQ;EAKlD,MAAM,kBAAkB,YAAY,MAAM,QAAQ,KAAK,QAAQ;GAC7D,OAAO,OAAO,IAAI,SAAS,IAAI;EACjC,GAAG,CAAC;EAEJ,IAAI,kBAAkB,gBAAgB;GACpC,MAAM,YAAY,iBAAiB;GAEnC,MAAM,qBAAqB,YAAY,MAAM,QAAQ,WAAW,OAAO,cAAc,KAAK;GAE1F,MAAM,iBAAiB,YAAY,mBAAmB;GAEtD,mBAAmB,SAAS,WAAW;IACrC,OAAO,SAAS,OAAO,SAAS,OAAO,YAAa;GACtD,CAAC;EACH;EAEA,MAAM,YAAY,YAAY,MAAM,QAAQ,WAAW,OAAO,UAAU,MAAM;EAC9E,MAAM,aAAa,YAAY,MAAM,QAAQ,WAAW,OAAO,UAAU,OAAO;EAEhF,UAAU,QAAQ,KAAK,QAAQ;GAC7B,IAAI,MAAM,OAAO;GACjB,OAAO,OAAO,IAAI,SAAS,IAAI;EACjC,GAAG,CAAC;EAEJ,WAAW,aAAa,KAAK,QAAQ;GACnC,IAAI,MAAM,QAAQ;GAClB,OAAO,OAAO,IAAI,SAAS,IAAI;EACjC,GAAG,CAAC;CACN;CAEA,YAAY,kBAAkB;CAE9B,SAAS,iBAAiB,YAA0B;EAClD,IAAI,CAAC,cAAc,OAAO;EAC1B,cAAc,MAAM,MAAM,YAAY,cAAc,WAAW;CACjE;CAIA,IAAI,gBAAgB;CACpB,IAAI,UAAU;CACd,IAAI,cAAc;CAClB,IAAI,sBAAyC;CAE7C,SAAS,sBAAsB,GAAe,cAAgC;EAC5E,MAAM,UAAU,UAAU,OAAO;EACjC,IAAI,CAAC,SAAS;EAEd,eAAe,QAAQ;EACvB,sBAAsB;EACtB,UAAU,EAAE;EACZ,cAAc,aAAa,SAAS;EAEpC,MAAM,EAAE,SAAS,QAAQ,sBAAsB;EAC/C,gBAAgB;EAEhB,eAAe;GACb,iBAAiB,EAAE,QAAQ,IAAI;EACjC,CAAC;EAED,SAAS,iBAAiB,aAAa,qBAAqB;EAC5D,SAAS,iBAAiB,WAAW,mBAAmB;CAC1D;CAEA,SAAS,sBAAsB,GAAqB;EAClD,iBAAiB,EAAE,QAAQ,aAAa;CAC1C;CAEA,SAAS,oBAAoB,GAAqB;EAChD,oBAAqB,QAAQ,KAAK,IAChC,cAAc,EAAE,QAAQ,SACxB,oBAAqB,QACvB;EAEA,eAAe,QAAQ;EACvB,sBAAsB;EACtB,mBAAmB;EAEnB,SAAS,oBAAoB,WAAW,mBAAmB;EAC3D,SAAS,oBAAoB,aAAa,qBAAqB;CACjE;CAEA,QAAQ,gBAAgB;EAAE;EAAuB;CAAU,CAAC;CAE5D,OAAO;EAAE;EAAe;EAAa;EAAgB;CAAsB;AAC7E"}
1
+ {"version":3,"file":"use-col-resize.js","names":[],"sources":["../../../src/components/table/use-col-resize.ts"],"sourcesContent":["import { nextTick, provide, shallowRef, watchEffect, type ShallowRef } from 'vue'\n\nimport type { ScrollExposed } from '../../types'\nimport { TableResizeKey } from './di'\nimport type { ColumnNode } from './node/col'\n\ninterface Options {\n scrollRef: ShallowRef<ScrollExposed | undefined>\n leafColumns: ShallowRef<ColumnNode[]>\n}\n\ninterface UseColResizeReturned {\n resizeLineRef: ShallowRef<HTMLElement | undefined>\n colgroupRef: ShallowRef<HTMLElement | undefined>\n showResizeLine: ShallowRef<boolean>\n handleResizeMousedown: (e: MouseEvent, resizeColumn: ColumnNode) => void\n}\n\nexport function useColResize(options: Options): UseColResizeReturned {\n const { scrollRef, leafColumns } = options\n\n const showResizeLine = shallowRef(false)\n\n const resizeLineRef = shallowRef<HTMLElement>()\n const colgroupRef = shallowRef<HTMLElement>()\n const headerRef = shallowRef<HTMLElement>()\n\n /**\n * 修正列样式\n */\n function correctColumnStyle() {\n // 获取表格容器宽度\n const containerWidth = scrollRef.value?.containerRef?.clientWidth\n\n if (!containerWidth || !leafColumns.value.length) return\n\n const flexColumns = leafColumns.value.filter((column) => !column.explicitWidth)\n const fixedWidthTotal = leafColumns.value\n .filter((column) => column.explicitWidth)\n .reduce((acc, cur) => acc + (cur.width ?? cur.minWidth!), 0)\n const flexBaseTotal = flexColumns.reduce((acc, cur) => acc + cur.minWidth!, 0)\n const totalBase = fixedWidthTotal + flexBaseTotal\n\n // 仅未显式指定 width 的列参与剩余宽度均分;指定了 width 的列保持该宽度。\n if (flexColumns.length > 0 && totalBase < containerWidth) {\n const allocatedWidth = (containerWidth - totalBase) / flexColumns.length\n\n flexColumns.forEach((column) => {\n column.width = column.minWidth! + allocatedWidth\n })\n } else {\n flexColumns.forEach((column) => {\n column.data.width = undefined\n })\n }\n\n const fixedLeft = leafColumns.value.filter((column) => column.fixed === 'left')\n const fixedRight = leafColumns.value.filter((column) => column.fixed === 'right')\n\n fixedLeft.reduce((acc, cur) => {\n cur.style.left = acc\n return acc + (cur.width ?? cur.minWidth!)\n }, 0)\n\n fixedRight.reduceRight((acc, cur) => {\n cur.style.right = acc\n return acc + (cur.width ?? cur.minWidth!)\n }, 0)\n }\n\n watchEffect(correctColumnStyle)\n\n function updateResizeLine(transformX: number): void {\n if (!resizeLineRef.value) return\n resizeLineRef.value.style.transform = `translateX(${transformX}px)`\n }\n\n // 表格相对于页面左边缘的偏移量,\n // 此处作为缓存以减少频繁地调用 getBoundingClientRect 方法\n let containerLeft = 0\n let originX = 0\n let originWidth = 0\n let currentResizeColumn: ColumnNode | null = null\n\n function handleResizeMousedown(e: MouseEvent, resizeColumn: ColumnNode): void {\n const tableEl = scrollRef.value?.el\n if (!tableEl) return\n\n showResizeLine.value = true\n currentResizeColumn = resizeColumn\n originX = e.pageX\n originWidth = resizeColumn.width ?? 0\n\n const { left } = tableEl.getBoundingClientRect()\n containerLeft = left\n\n nextTick(() => {\n updateResizeLine(e.pageX - left)\n })\n\n document.addEventListener('mousemove', handleResizeMousemove)\n document.addEventListener('mouseup', handleResizeMouseup)\n }\n\n function handleResizeMousemove(e: MouseEvent): void {\n updateResizeLine(e.pageX - containerLeft)\n }\n\n function handleResizeMouseup(e: MouseEvent): void {\n currentResizeColumn!.width = Math.max(\n originWidth + e.pageX - originX,\n currentResizeColumn!.minWidth!\n )\n currentResizeColumn!.explicitWidth = true\n\n showResizeLine.value = false\n currentResizeColumn = null\n correctColumnStyle()\n\n document.removeEventListener('mouseup', handleResizeMouseup)\n document.removeEventListener('mousemove', handleResizeMousemove)\n }\n\n provide(TableResizeKey, { handleResizeMousedown, headerRef })\n\n return { resizeLineRef, colgroupRef, showResizeLine, handleResizeMousedown }\n}\n"],"mappings":";;;AAkBA,SAAgB,aAAa,SAAwC;CACnE,MAAM,EAAE,WAAW,gBAAgB;CAEnC,MAAM,iBAAiB,WAAW,KAAK;CAEvC,MAAM,gBAAgB,WAAwB;CAC9C,MAAM,cAAc,WAAwB;CAC5C,MAAM,YAAY,WAAwB;;;;CAK1C,SAAS,qBAAqB;EAE5B,MAAM,iBAAiB,UAAU,OAAO,cAAc;EAEtD,IAAI,CAAC,kBAAkB,CAAC,YAAY,MAAM,QAAQ;EAElD,MAAM,cAAc,YAAY,MAAM,QAAQ,WAAW,CAAC,OAAO,aAAa;EAK9E,MAAM,YAJkB,YAAY,MACjC,QAAQ,WAAW,OAAO,aAAa,EACvC,QAAQ,KAAK,QAAQ,OAAO,IAAI,SAAS,IAAI,WAAY,CAE5B,IADV,YAAY,QAAQ,KAAK,QAAQ,MAAM,IAAI,UAAW,CAC5B;EAGhD,IAAI,YAAY,SAAS,KAAK,YAAY,gBAAgB;GACxD,MAAM,kBAAkB,iBAAiB,aAAa,YAAY;GAElE,YAAY,SAAS,WAAW;IAC9B,OAAO,QAAQ,OAAO,WAAY;GACpC,CAAC;EACH,OACE,YAAY,SAAS,WAAW;GAC9B,OAAO,KAAK,QAAQ,KAAA;EACtB,CAAC;EAGH,MAAM,YAAY,YAAY,MAAM,QAAQ,WAAW,OAAO,UAAU,MAAM;EAC9E,MAAM,aAAa,YAAY,MAAM,QAAQ,WAAW,OAAO,UAAU,OAAO;EAEhF,UAAU,QAAQ,KAAK,QAAQ;GAC7B,IAAI,MAAM,OAAO;GACjB,OAAO,OAAO,IAAI,SAAS,IAAI;EACjC,GAAG,CAAC;EAEJ,WAAW,aAAa,KAAK,QAAQ;GACnC,IAAI,MAAM,QAAQ;GAClB,OAAO,OAAO,IAAI,SAAS,IAAI;EACjC,GAAG,CAAC;CACN;CAEA,YAAY,kBAAkB;CAE9B,SAAS,iBAAiB,YAA0B;EAClD,IAAI,CAAC,cAAc,OAAO;EAC1B,cAAc,MAAM,MAAM,YAAY,cAAc,WAAW;CACjE;CAIA,IAAI,gBAAgB;CACpB,IAAI,UAAU;CACd,IAAI,cAAc;CAClB,IAAI,sBAAyC;CAE7C,SAAS,sBAAsB,GAAe,cAAgC;EAC5E,MAAM,UAAU,UAAU,OAAO;EACjC,IAAI,CAAC,SAAS;EAEd,eAAe,QAAQ;EACvB,sBAAsB;EACtB,UAAU,EAAE;EACZ,cAAc,aAAa,SAAS;EAEpC,MAAM,EAAE,SAAS,QAAQ,sBAAsB;EAC/C,gBAAgB;EAEhB,eAAe;GACb,iBAAiB,EAAE,QAAQ,IAAI;EACjC,CAAC;EAED,SAAS,iBAAiB,aAAa,qBAAqB;EAC5D,SAAS,iBAAiB,WAAW,mBAAmB;CAC1D;CAEA,SAAS,sBAAsB,GAAqB;EAClD,iBAAiB,EAAE,QAAQ,aAAa;CAC1C;CAEA,SAAS,oBAAoB,GAAqB;EAChD,oBAAqB,QAAQ,KAAK,IAChC,cAAc,EAAE,QAAQ,SACxB,oBAAqB,QACvB;EACA,oBAAqB,gBAAgB;EAErC,eAAe,QAAQ;EACvB,sBAAsB;EACtB,mBAAmB;EAEnB,SAAS,oBAAoB,WAAW,mBAAmB;EAC3D,SAAS,oBAAoB,aAAa,qBAAqB;CACjE;CAEA,QAAQ,gBAAgB;EAAE;EAAuB;CAAU,CAAC;CAE5D,OAAO;EAAE;EAAe;EAAa;EAAgB;CAAsB;AAC7E"}
@@ -14,13 +14,13 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
14
14
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
15
  "update:modelValue": (value: string | undefined) => any;
16
16
  } & {
17
+ "update:modelValue": (value: string) => any;
17
18
  close: (item: TabItem, index: number) => any;
18
19
  click: (item: TabItem, index: number) => any;
19
- "update:modelValue": (value: string) => any;
20
20
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
21
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
21
22
  onClose?: ((item: TabItem, index: number) => any) | undefined;
22
23
  onClick?: ((item: TabItem, index: number) => any) | undefined;
23
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
24
24
  }>, {
25
25
  closable: boolean;
26
26
  position: "top" | "bottom";
@@ -14,13 +14,13 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
14
14
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
15
  "update:modelValue": (value: string | undefined) => any;
16
16
  } & {
17
+ "update:modelValue": (value: string) => any;
17
18
  close: (item: TabItem, index: number) => any;
18
19
  click: (item: TabItem, index: number) => any;
19
- "update:modelValue": (value: string) => any;
20
20
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
21
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
21
22
  onClose?: ((item: TabItem, index: number) => any) | undefined;
22
23
  onClick?: ((item: TabItem, index: number) => any) | undefined;
23
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
24
24
  }>, {
25
25
  closable: boolean;
26
26
  position: "left" | "right";
@@ -9,13 +9,13 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
9
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
10
  "update:modelValue": (value: string | undefined) => any;
11
11
  } & {
12
+ "update:modelValue": (value: string) => any;
12
13
  close: (item: TabItem, index: number) => any;
13
14
  click: (item: TabItem, index: number) => any;
14
- "update:modelValue": (value: string) => any;
15
15
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
16
17
  onClose?: ((item: TabItem, index: number) => any) | undefined;
17
18
  onClick?: ((item: TabItem, index: number) => any) | undefined;
18
- "onUpdate:modelValue"?: ((value: string) => any) | undefined;
19
19
  }>, {
20
20
  closable: boolean;
21
21
  position: "left" | "right" | "top" | "bottom";
@@ -20,9 +20,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
20
20
  onFocus?: (() => any) | undefined;
21
21
  onBlur?: (() => any) | undefined;
22
22
  }>, {
23
- disabled: boolean;
24
23
  placeholder: string;
25
24
  clearable: boolean;
25
+ disabled: boolean;
26
26
  readonly: boolean;
27
27
  resize: boolean;
28
28
  autosize: boolean;
@@ -9,11 +9,11 @@ declare const __VLS_base: import("vue").DefineComponent<TipProps, {}, {}, {}, {}
9
9
  }, string, import("vue").PublicProps, Readonly<TipProps> & Readonly<{
10
10
  "onUpdate:visible"?: ((value: boolean) => any) | undefined;
11
11
  }>, {
12
+ content: string;
12
13
  trigger: "hover" | "click";
13
14
  contentTag: string;
14
15
  visible: boolean;
15
16
  direction: TipDirection;
16
- content: string;
17
17
  alignment: TipAlign;
18
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
19
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -23,14 +23,14 @@ 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
- minWidth: string;
27
- disabled: boolean;
28
26
  expandAll: boolean;
29
27
  labelKey: string;
30
28
  valueKey: string;
31
29
  placeholder: string;
32
30
  clearable: boolean;
33
31
  filterable: boolean;
32
+ minWidth: string;
33
+ disabled: boolean;
34
34
  readonly: boolean;
35
35
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
36
36
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltra/desktop",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
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.1.32",
72
- "@veltra/directives": "1.1.32",
73
- "@veltra/icons": "1.1.32",
74
- "@veltra/styles": "1.1.32",
75
- "@veltra/utils": "1.1.32",
71
+ "@veltra/compositions": "1.1.33",
72
+ "@veltra/directives": "1.1.33",
73
+ "@veltra/icons": "1.1.33",
74
+ "@veltra/styles": "1.1.33",
75
+ "@veltra/utils": "1.1.33",
76
76
  "vue": ">=3.5.0"
77
77
  }
78
78
  }
@@ -94,9 +94,16 @@ export class ColumnNode extends TreeNode<TableColumn, ColumnNode> {
94
94
  return this.data.resizable ?? true
95
95
  }
96
96
 
97
+ /**
98
+ * 是否在列配置上显式指定了 width,或经表头拖拽锁定。
99
+ * 此类列不参与剩余宽度的均分。
100
+ */
101
+ explicitWidth: boolean
102
+
97
103
  style: Record<string, number> = reactive({})
98
104
 
99
105
  constructor(val: TableColumn, index: number, depth: number, parent?: ColumnNode) {
100
106
  super(isReactive(val) ? val : shallowReactive(val), index, depth, parent)
107
+ this.explicitWidth = val.width !== undefined
101
108
  }
102
109
  }
@@ -34,22 +34,23 @@ export function useColResize(options: Options): UseColResizeReturned {
34
34
 
35
35
  if (!containerWidth || !leafColumns.value.length) return
36
36
 
37
- // 如果每个列都设置了宽度, 有两种情况
38
- // 1. 表格容器宽度大于所有列宽度之和,则将剩下的宽度均匀分布到所有列中
39
- // 2. 表格容器宽度小于所有列宽度之和,则什么也不管
40
- const allColumnsWidth = leafColumns.value.reduce((acc, cur) => {
41
- return acc + (cur.width ?? cur.minWidth!)
42
- }, 0)
43
-
44
- if (allColumnsWidth < containerWidth) {
45
- const freeWidth = containerWidth - allColumnsWidth
46
-
47
- const allocatableColumns = leafColumns.value.filter((column) => column.resizable !== false)
48
-
49
- const allocatedWidth = freeWidth / allocatableColumns.length
50
-
51
- allocatableColumns.forEach((column) => {
52
- column.width = (column.width ?? column.minWidth!) + allocatedWidth
37
+ const flexColumns = leafColumns.value.filter((column) => !column.explicitWidth)
38
+ const fixedWidthTotal = leafColumns.value
39
+ .filter((column) => column.explicitWidth)
40
+ .reduce((acc, cur) => acc + (cur.width ?? cur.minWidth!), 0)
41
+ const flexBaseTotal = flexColumns.reduce((acc, cur) => acc + cur.minWidth!, 0)
42
+ const totalBase = fixedWidthTotal + flexBaseTotal
43
+
44
+ // 仅未显式指定 width 的列参与剩余宽度均分;指定了 width 的列保持该宽度。
45
+ if (flexColumns.length > 0 && totalBase < containerWidth) {
46
+ const allocatedWidth = (containerWidth - totalBase) / flexColumns.length
47
+
48
+ flexColumns.forEach((column) => {
49
+ column.width = column.minWidth! + allocatedWidth
50
+ })
51
+ } else {
52
+ flexColumns.forEach((column) => {
53
+ column.data.width = undefined
53
54
  })
54
55
  }
55
56
 
@@ -110,6 +111,7 @@ export function useColResize(options: Options): UseColResizeReturned {
110
111
  originWidth + e.pageX - originX,
111
112
  currentResizeColumn!.minWidth!
112
113
  )
114
+ currentResizeColumn!.explicitWidth = true
113
115
 
114
116
  showResizeLine.value = false
115
117
  currentResizeColumn = null