stk-table-vue 1.2.4 → 1.2.6

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 (68) hide show
  1. package/README.md +194 -194
  2. package/lib/{Dropdown-D_9cB0rD.js → Dropdown-BAANgg_5.js} +2 -2
  3. package/lib/{StkTable-CVcmlZi9.js → StkTable-CGcxwpdb.js} +22 -6
  4. package/lib/src/StkTable/StkTable.vue.d.ts +18 -4
  5. package/lib/src/StkTable/types/index.d.ts +4 -1
  6. package/lib/src/StkTable/useVirtualScroll.d.ts +6 -1
  7. package/lib/stk-table-vue.js +3 -3
  8. package/lib/style.css +1 -1
  9. package/package.json +93 -93
  10. package/src/StkTable/StkTable.vue +2362 -2338
  11. package/src/StkTable/components/DragHandle.vue +9 -9
  12. package/src/StkTable/components/SortIcon.vue +6 -6
  13. package/src/StkTable/components/TreeNodeCell.vue +19 -19
  14. package/src/StkTable/components/TriangleIcon.vue +3 -3
  15. package/src/StkTable/const.ts +50 -50
  16. package/src/StkTable/custom-cells/ChangeCell/ChangeCell.less +34 -34
  17. package/src/StkTable/custom-cells/ChangeCell/createChangeCell.ts +90 -90
  18. package/src/StkTable/custom-cells/ChangeCell/index.ts +4 -4
  19. package/src/StkTable/custom-cells/CheckboxCell/CheckboxCell.less +14 -14
  20. package/src/StkTable/custom-cells/CheckboxCell/CheckboxCell.vue +56 -56
  21. package/src/StkTable/custom-cells/CheckboxCell/createCheckboxCell.ts +146 -146
  22. package/src/StkTable/custom-cells/CheckboxCell/index.ts +5 -5
  23. package/src/StkTable/custom-cells/FilterCell/Dropdown/index.ts +16 -16
  24. package/src/StkTable/custom-cells/FilterCell/Dropdown/index.vue +186 -186
  25. package/src/StkTable/custom-cells/FilterCell/Filter.less +118 -118
  26. package/src/StkTable/custom-cells/FilterCell/Filter.vue +66 -66
  27. package/src/StkTable/custom-cells/FilterCell/createFilterCell.ts +120 -120
  28. package/src/StkTable/custom-cells/FilterCell/index.ts +6 -6
  29. package/src/StkTable/custom-cells/FilterCell/types.ts +43 -43
  30. package/src/StkTable/custom-cells/NumberCell/createNumberCell.ts +43 -43
  31. package/src/StkTable/custom-cells/NumberCell/index.ts +2 -2
  32. package/src/StkTable/custom-cells/utils/formatNumber.ts +137 -137
  33. package/src/StkTable/features/const.ts +1 -1
  34. package/src/StkTable/features/index.ts +1 -1
  35. package/src/StkTable/features/useAreaSelection.ts +1240 -1239
  36. package/src/StkTable/index.ts +20 -20
  37. package/src/StkTable/mergeCellsCache.ts +69 -69
  38. package/src/StkTable/registerFeature.ts +40 -40
  39. package/src/StkTable/style.less +791 -791
  40. package/src/StkTable/types/highlightDimOptions.ts +28 -28
  41. package/src/StkTable/types/index.ts +503 -500
  42. package/src/StkTable/useAutoResize.ts +87 -87
  43. package/src/StkTable/useColResize.ts +202 -202
  44. package/src/StkTable/useFixedCol.ts +168 -168
  45. package/src/StkTable/useFixedStyle.ts +75 -75
  46. package/src/StkTable/useGetFixedColPosition.ts +63 -63
  47. package/src/StkTable/useHighlight.ts +270 -270
  48. package/src/StkTable/useIndexResolver.ts +29 -29
  49. package/src/StkTable/useKeyboardArrowScroll.ts +114 -114
  50. package/src/StkTable/useMaxRowSpan.ts +60 -60
  51. package/src/StkTable/useMergeCells.ts +541 -541
  52. package/src/StkTable/useRowExpand.ts +81 -81
  53. package/src/StkTable/useScrollRowByRow.ts +96 -96
  54. package/src/StkTable/useScrollbar.ts +177 -177
  55. package/src/StkTable/useSorter.ts +267 -267
  56. package/src/StkTable/useTableColumns.ts +142 -142
  57. package/src/StkTable/useThDrag.ts +94 -94
  58. package/src/StkTable/useTrDrag.ts +100 -100
  59. package/src/StkTable/useTree.ts +253 -253
  60. package/src/StkTable/useVirtualScroll.ts +1032 -1025
  61. package/src/StkTable/useWheeling.ts +23 -23
  62. package/src/StkTable/utils/constRefUtils.ts +29 -29
  63. package/src/StkTable/utils/index.ts +331 -331
  64. package/src/StkTable/utils/rowHeightFenwickTree.ts +74 -74
  65. package/src/StkTable/utils/useTriggerRef.ts +33 -33
  66. package/src/VirtualTree.vue +622 -622
  67. package/src/VirtualTreeSelect.vue +367 -367
  68. package/src/vite-env.d.ts +10 -10
@@ -1,146 +1,146 @@
1
- /* eslint-disable vue/one-component-per-file */
2
- import type { CustomCellProps } from '../../types';
3
- import { computed, defineComponent, getCurrentInstance, h, markRaw } from 'vue';
4
- import CheckboxVue from './CheckboxCell.vue';
5
-
6
- /** createCheckboxCell 配置选项 */
7
- export interface createCheckboxCellOptions<T = any> {
8
- /**
9
- * 行数据中表示选中状态的字段名
10
- * @default '_isChecked'
11
- */
12
- field?: string;
13
- /**
14
- * 自定义 checkbox 组件(如 Element Plus / Ant Design Vue 的 Checkbox)
15
- * 不传则使用原生 input[type=checkbox]
16
- */
17
- checkboxComponent?: any;
18
- /**
19
- * 单元格 checkbox 状态变更回调
20
- * @param checked 是否选中
21
- * @param row 当前行数据
22
- */
23
- onChange?: (checked: boolean, row: T) => void;
24
- /**
25
- * 全选 checkbox 状态变更回调
26
- * @param checked 是否全选
27
- */
28
- onSelectAll?: (checked: boolean) => void;
29
- }
30
-
31
- /**
32
- * 查找最近的 StkTable 组件实例
33
- */
34
- function findStkTableInstance(curIns: any) {
35
- let current = curIns;
36
- while ((current = current.parent)) {
37
- if (current.type?.name === 'StkTable') {
38
- return current;
39
- }
40
- }
41
- return null;
42
- }
43
-
44
- /**
45
- * Checkbox 工厂函数
46
- *
47
- * 用于快速创建多选框单元格和表头单元格组件。
48
- *
49
- * @param options 配置选项
50
- * @returns 包含 CheckboxCell 和 CheckboxAllCell 组件的对象
51
- *
52
- * @example
53
- * ```ts
54
- * const { CheckboxCell, CheckboxAllCell } = createCheckboxCell({
55
- * field: '_isChecked',
56
- * onChange: (checked, row) => { row._isChecked = checked },
57
- * });
58
- *
59
- * const columns = [
60
- * {
61
- * dataIndex: 'checkbox',
62
- * width: 50,
63
- * customCell: CheckboxCell,
64
- * customHeaderCell: CheckboxAllCell,
65
- * },
66
- * // ...other columns
67
- * ];
68
- * ```
69
- */
70
- export function createCheckboxCell<T extends Record<string, any> = any>(options?: createCheckboxCellOptions<T>) {
71
- const field = options?.field ?? '_isChecked';
72
- const customComponent = options?.checkboxComponent;
73
-
74
- /** 单元格 Checkbox 组件 - 用于 customCell */
75
- function CheckboxCellComponent() {
76
- return markRaw(
77
- defineComponent({
78
- // eslint-disable-next-line vue/require-prop-types
79
- props: ['row', 'col', 'cellValue', 'rowIndex', 'colIndex', 'expanded', 'treeExpanded'],
80
- setup(props: CustomCellProps<any>) {
81
- const isChecked = computed(() => !!props.row[field]);
82
-
83
- function handleChange(checked: boolean) {
84
- // eslint-disable-next-line vue/no-mutating-props
85
- props.row[field] = checked;
86
- options?.onChange?.(checked, props.row);
87
- }
88
-
89
- return () =>
90
- h(CheckboxVue, {
91
- checked: isChecked.value,
92
- customComponent,
93
- onChange: handleChange,
94
- });
95
- },
96
- }),
97
- );
98
- }
99
-
100
- /** 表头 Checkbox 组件 - 用于 customHeaderCell(全选/半选) */
101
- function CheckboxAllCellComponent() {
102
- return markRaw(
103
- defineComponent({
104
- // eslint-disable-next-line vue/require-prop-types
105
- props: ['col', 'colIndex', 'rowIndex'],
106
- setup() {
107
- const currentInstance = getCurrentInstance();
108
- const stkTableInstance = findStkTableInstance(currentInstance);
109
-
110
- const dataSource = computed<any[]>(() => stkTableInstance?.props?.dataSource || []);
111
-
112
- const isCheckAll = computed(() => {
113
- const data = dataSource.value;
114
- return data.length > 0 && data.every((item: any) => !!item[field]);
115
- });
116
-
117
- const isIndeterminate = computed(() => {
118
- const data = dataSource.value;
119
- const checkedCount = data.filter((item: any) => !!item[field]).length;
120
- return checkedCount > 0 && checkedCount < data.length;
121
- });
122
-
123
- function handleChange(checked: boolean) {
124
- dataSource.value.forEach((item: any) => {
125
- item[field] = checked;
126
- });
127
- options?.onSelectAll?.(checked);
128
- }
129
-
130
- return () =>
131
- h(CheckboxVue, {
132
- checked: isCheckAll.value,
133
- indeterminate: isIndeterminate.value,
134
- customComponent,
135
- onChange: handleChange,
136
- });
137
- },
138
- }),
139
- );
140
- }
141
-
142
- return {
143
- CheckboxCell: CheckboxCellComponent,
144
- CheckboxAllCell: CheckboxAllCellComponent,
145
- };
146
- }
1
+ /* eslint-disable vue/one-component-per-file */
2
+ import type { CustomCellProps } from '../../types';
3
+ import { computed, defineComponent, getCurrentInstance, h, markRaw } from 'vue';
4
+ import CheckboxVue from './CheckboxCell.vue';
5
+
6
+ /** createCheckboxCell 配置选项 */
7
+ export interface createCheckboxCellOptions<T = any> {
8
+ /**
9
+ * 行数据中表示选中状态的字段名
10
+ * @default '_isChecked'
11
+ */
12
+ field?: string;
13
+ /**
14
+ * 自定义 checkbox 组件(如 Element Plus / Ant Design Vue 的 Checkbox)
15
+ * 不传则使用原生 input[type=checkbox]
16
+ */
17
+ checkboxComponent?: any;
18
+ /**
19
+ * 单元格 checkbox 状态变更回调
20
+ * @param checked 是否选中
21
+ * @param row 当前行数据
22
+ */
23
+ onChange?: (checked: boolean, row: T) => void;
24
+ /**
25
+ * 全选 checkbox 状态变更回调
26
+ * @param checked 是否全选
27
+ */
28
+ onSelectAll?: (checked: boolean) => void;
29
+ }
30
+
31
+ /**
32
+ * 查找最近的 StkTable 组件实例
33
+ */
34
+ function findStkTableInstance(curIns: any) {
35
+ let current = curIns;
36
+ while ((current = current.parent)) {
37
+ if (current.type?.name === 'StkTable') {
38
+ return current;
39
+ }
40
+ }
41
+ return null;
42
+ }
43
+
44
+ /**
45
+ * Checkbox 工厂函数
46
+ *
47
+ * 用于快速创建多选框单元格和表头单元格组件。
48
+ *
49
+ * @param options 配置选项
50
+ * @returns 包含 CheckboxCell 和 CheckboxAllCell 组件的对象
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const { CheckboxCell, CheckboxAllCell } = createCheckboxCell({
55
+ * field: '_isChecked',
56
+ * onChange: (checked, row) => { row._isChecked = checked },
57
+ * });
58
+ *
59
+ * const columns = [
60
+ * {
61
+ * dataIndex: 'checkbox',
62
+ * width: 50,
63
+ * customCell: CheckboxCell,
64
+ * customHeaderCell: CheckboxAllCell,
65
+ * },
66
+ * // ...other columns
67
+ * ];
68
+ * ```
69
+ */
70
+ export function createCheckboxCell<T extends Record<string, any> = any>(options?: createCheckboxCellOptions<T>) {
71
+ const field = options?.field ?? '_isChecked';
72
+ const customComponent = options?.checkboxComponent;
73
+
74
+ /** 单元格 Checkbox 组件 - 用于 customCell */
75
+ function CheckboxCellComponent() {
76
+ return markRaw(
77
+ defineComponent({
78
+ // eslint-disable-next-line vue/require-prop-types
79
+ props: ['row', 'col', 'cellValue', 'rowIndex', 'colIndex', 'expanded', 'treeExpanded'],
80
+ setup(props: CustomCellProps<any>) {
81
+ const isChecked = computed(() => !!props.row[field]);
82
+
83
+ function handleChange(checked: boolean) {
84
+ // eslint-disable-next-line vue/no-mutating-props
85
+ props.row[field] = checked;
86
+ options?.onChange?.(checked, props.row);
87
+ }
88
+
89
+ return () =>
90
+ h(CheckboxVue, {
91
+ checked: isChecked.value,
92
+ customComponent,
93
+ onChange: handleChange,
94
+ });
95
+ },
96
+ }),
97
+ );
98
+ }
99
+
100
+ /** 表头 Checkbox 组件 - 用于 customHeaderCell(全选/半选) */
101
+ function CheckboxAllCellComponent() {
102
+ return markRaw(
103
+ defineComponent({
104
+ // eslint-disable-next-line vue/require-prop-types
105
+ props: ['col', 'colIndex', 'rowIndex'],
106
+ setup() {
107
+ const currentInstance = getCurrentInstance();
108
+ const stkTableInstance = findStkTableInstance(currentInstance);
109
+
110
+ const dataSource = computed<any[]>(() => stkTableInstance?.props?.dataSource || []);
111
+
112
+ const isCheckAll = computed(() => {
113
+ const data = dataSource.value;
114
+ return data.length > 0 && data.every((item: any) => !!item[field]);
115
+ });
116
+
117
+ const isIndeterminate = computed(() => {
118
+ const data = dataSource.value;
119
+ const checkedCount = data.filter((item: any) => !!item[field]).length;
120
+ return checkedCount > 0 && checkedCount < data.length;
121
+ });
122
+
123
+ function handleChange(checked: boolean) {
124
+ dataSource.value.forEach((item: any) => {
125
+ item[field] = checked;
126
+ });
127
+ options?.onSelectAll?.(checked);
128
+ }
129
+
130
+ return () =>
131
+ h(CheckboxVue, {
132
+ checked: isCheckAll.value,
133
+ indeterminate: isIndeterminate.value,
134
+ customComponent,
135
+ onChange: handleChange,
136
+ });
137
+ },
138
+ }),
139
+ );
140
+ }
141
+
142
+ return {
143
+ CheckboxCell: CheckboxCellComponent,
144
+ CheckboxAllCell: CheckboxAllCellComponent,
145
+ };
146
+ }
@@ -1,5 +1,5 @@
1
- // 导出 Checkbox 组件相关模块
2
- export { createCheckboxCell } from './createCheckboxCell';
3
- export type { createCheckboxCellOptions } from './createCheckboxCell';
4
-
5
- import './CheckboxCell.less';
1
+ // 导出 Checkbox 组件相关模块
2
+ export { createCheckboxCell } from './createCheckboxCell';
3
+ export type { createCheckboxCellOptions } from './createCheckboxCell';
4
+
5
+ import './CheckboxCell.less';
@@ -1,16 +1,16 @@
1
- import { createApp } from 'vue';
2
- import type Dropdown from './index.vue';
3
-
4
- let DropdownIns: InstanceType<typeof Dropdown> | null = null;
5
-
6
- export async function getDropdownIns() {
7
- if (!DropdownIns) {
8
- const div = document.createElement('div');
9
- div.classList.add('stk-filter-dropdown-wrapper');
10
- document.body.appendChild(div);
11
-
12
- const DropdownApp = await import('./index.vue').then(module => module.default);
13
- DropdownIns = createApp(DropdownApp).mount(div) as InstanceType<typeof DropdownApp>;
14
- }
15
- return DropdownIns;
16
- }
1
+ import { createApp } from 'vue';
2
+ import type Dropdown from './index.vue';
3
+
4
+ let DropdownIns: InstanceType<typeof Dropdown> | null = null;
5
+
6
+ export async function getDropdownIns() {
7
+ if (!DropdownIns) {
8
+ const div = document.createElement('div');
9
+ div.classList.add('stk-filter-dropdown-wrapper');
10
+ document.body.appendChild(div);
11
+
12
+ const DropdownApp = await import('./index.vue').then(module => module.default);
13
+ DropdownIns = createApp(DropdownApp).mount(div) as InstanceType<typeof DropdownApp>;
14
+ }
15
+ return DropdownIns;
16
+ }