tabula-vue 1.0.0 → 1.0.2

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 (204) hide show
  1. package/es/component.mjs +4 -0
  2. package/es/components/dialog/index.d.ts +30 -30
  3. package/es/components/dialog/src/index.vue.d.ts +2 -2
  4. package/es/components/dialog-form/index.d.ts +2 -2
  5. package/es/components/dialog-form/src/index.vue.d.ts +2 -2
  6. package/es/components/display-item/index.d.ts +25 -25
  7. package/es/components/display-item/src/index.vue.d.ts +7 -7
  8. package/es/components/drawer-form/index.d.ts +50 -50
  9. package/es/components/drawer-form/src/index.vue.d.ts +10 -10
  10. package/es/components/form/index.d.ts +99 -99
  11. package/es/components/form/src/form-content.vue.d.ts +12 -12
  12. package/es/components/form/src/index.vue.d.ts +11 -11
  13. package/es/components/form-item/index.d.ts +80 -80
  14. package/es/components/form-item/src/index.vue.d.ts +9 -9
  15. package/es/components/index.d.ts +2 -0
  16. package/es/components/index.mjs +6 -0
  17. package/es/components/input-tag/index.d.ts +6 -6
  18. package/es/components/input-tag/src/index.vue.d.ts +6 -6
  19. package/es/components/layout/index.d.ts +30 -30
  20. package/es/components/layout/src/index.vue.d.ts +10 -10
  21. package/es/components/page/index.d.ts +9087 -4864
  22. package/es/components/page/src/index.vue.d.ts +1903 -513
  23. package/es/components/page/src/index.vue2.mjs +43 -12
  24. package/es/components/popover/index.d.ts +49 -49
  25. package/es/components/popover/src/index.vue.d.ts +3 -3
  26. package/es/components/render/index.d.ts +14 -14
  27. package/es/components/render/src/index.vue.d.ts +1 -1
  28. package/es/components/search/index.d.ts +298 -298
  29. package/es/components/search/src/index.vue.d.ts +84 -84
  30. package/es/components/sidebar/index.d.ts +31 -31
  31. package/es/components/sidebar/src/index.vue.d.ts +5 -5
  32. package/es/components/table/index.d.ts +165 -180
  33. package/es/components/table/index.mjs +3 -0
  34. package/es/components/table/src/index.vue.d.ts +12 -21
  35. package/es/components/table/src/index.vue2.mjs +11 -34
  36. package/es/components/table/src/table-action-bar-content.vue.d.ts +78 -0
  37. package/es/components/table/src/table-action-bar-content.vue.mjs +6 -0
  38. package/es/components/table/src/table-action-bar-content.vue2.mjs +395 -0
  39. package/es/components/table/src/table-action-bar.vue.d.ts +4 -4
  40. package/es/components/table/src/table-action-bar.vue2.mjs +30 -353
  41. package/es/components/table/src/table-column-drag-sort.vue.d.ts +1 -1
  42. package/es/components/table/src/table-column-index.vue.d.ts +1 -1
  43. package/es/components/table/src/table-column.vue.d.ts +22 -29
  44. package/es/components/table/src/table-column.vue2.mjs +4 -57
  45. package/es/components/table/src/table-title-bar.vue.d.ts +2 -2
  46. package/es/components/table/src/type.d.ts +0 -11
  47. package/es/components/table/src/use-columns.d.ts +26 -0
  48. package/es/components/table/src/use-columns.mjs +40 -0
  49. package/es/components/table-lite/index.d.ts +1783 -0
  50. package/es/components/table-lite/index.mjs +6 -0
  51. package/es/components/table-lite/src/index.vue.d.ts +672 -0
  52. package/es/components/table-lite/src/index.vue.mjs +6 -0
  53. package/es/components/table-lite/src/index.vue2.mjs +681 -0
  54. package/es/components/table-lite/src/type.d.ts +91 -0
  55. package/es/components/table-lite/src/type.mjs +1 -0
  56. package/es/components/table-lite/style/css.d.ts +16 -0
  57. package/es/components/table-lite/style/css.mjs +16 -0
  58. package/es/components/table-lite/style/index.d.ts +16 -0
  59. package/es/components/table-lite/style/index.mjs +16 -0
  60. package/es/components/table-v2/index.d.ts +174 -0
  61. package/es/components/table-v2/index.mjs +7 -0
  62. package/es/components/table-v2/src/column-converter.d.ts +27 -0
  63. package/es/components/table-v2/src/column-converter.mjs +42 -0
  64. package/es/components/table-v2/src/index.vue.d.ts +157 -0
  65. package/es/components/table-v2/src/index.vue.mjs +6 -0
  66. package/es/components/table-v2/src/index.vue2.mjs +491 -0
  67. package/es/components/table-v2/src/special-columns.d.ts +61 -0
  68. package/es/components/table-v2/src/special-columns.mjs +76 -0
  69. package/es/components/table-v2/src/table-v2-cell.d.ts +104 -0
  70. package/es/components/table-v2/src/table-v2-cell.mjs +139 -0
  71. package/es/components/table-v2/src/table-v2-header-cell.vue.d.ts +61 -0
  72. package/es/components/table-v2/src/table-v2-header-cell.vue.mjs +6 -0
  73. package/es/components/table-v2/src/table-v2-header-cell.vue2.mjs +92 -0
  74. package/es/components/table-v2/src/type.d.ts +95 -0
  75. package/es/components/table-v2/src/type.mjs +1 -0
  76. package/es/components/table-v2/src/use-table-v2-columns.d.ts +43 -0
  77. package/es/components/table-v2/src/use-table-v2-columns.mjs +47 -0
  78. package/es/components/table-v2/style/css.d.ts +17 -0
  79. package/es/components/table-v2/style/css.mjs +17 -0
  80. package/es/components/table-v2/style/index.d.ts +17 -0
  81. package/es/components/table-v2/style/index.mjs +17 -0
  82. package/es/index.mjs +6 -0
  83. package/es/version.d.ts +1 -1
  84. package/es/version.mjs +1 -1
  85. package/index.css +1 -1
  86. package/index.js +1850 -279
  87. package/index.min.js +9 -6
  88. package/index.min.mjs +9 -6
  89. package/index.mjs +1813 -248
  90. package/lib/component.js +42 -38
  91. package/lib/components/dialog/index.d.ts +30 -30
  92. package/lib/components/dialog/src/index.vue.d.ts +2 -2
  93. package/lib/components/dialog-form/index.d.ts +2 -2
  94. package/lib/components/dialog-form/src/index.vue.d.ts +2 -2
  95. package/lib/components/display-item/index.d.ts +25 -25
  96. package/lib/components/display-item/src/index.vue.d.ts +7 -7
  97. package/lib/components/drawer-form/index.d.ts +50 -50
  98. package/lib/components/drawer-form/src/index.vue.d.ts +10 -10
  99. package/lib/components/form/index.d.ts +99 -99
  100. package/lib/components/form/src/form-content.vue.d.ts +12 -12
  101. package/lib/components/form/src/index.vue.d.ts +11 -11
  102. package/lib/components/form-item/index.d.ts +80 -80
  103. package/lib/components/form-item/src/index.vue.d.ts +9 -9
  104. package/lib/components/index.d.ts +2 -0
  105. package/lib/components/index.js +51 -39
  106. package/lib/components/input-tag/index.d.ts +6 -6
  107. package/lib/components/input-tag/src/index.vue.d.ts +6 -6
  108. package/lib/components/layout/index.d.ts +30 -30
  109. package/lib/components/layout/src/index.vue.d.ts +10 -10
  110. package/lib/components/page/index.d.ts +9087 -4864
  111. package/lib/components/page/src/index.vue.d.ts +1903 -513
  112. package/lib/components/page/src/index.vue2.js +46 -15
  113. package/lib/components/popover/index.d.ts +49 -49
  114. package/lib/components/popover/src/index.vue.d.ts +3 -3
  115. package/lib/components/render/index.d.ts +14 -14
  116. package/lib/components/render/src/index.vue.d.ts +1 -1
  117. package/lib/components/search/index.d.ts +298 -298
  118. package/lib/components/search/src/index.vue.d.ts +84 -84
  119. package/lib/components/sidebar/index.d.ts +31 -31
  120. package/lib/components/sidebar/src/index.vue.d.ts +5 -5
  121. package/lib/components/table/index.d.ts +165 -180
  122. package/lib/components/table/index.js +6 -0
  123. package/lib/components/table/src/index.vue.d.ts +12 -21
  124. package/lib/components/table/src/index.vue2.js +10 -33
  125. package/lib/components/table/src/table-action-bar-content.vue.d.ts +78 -0
  126. package/lib/components/table/src/table-action-bar-content.vue.js +10 -0
  127. package/lib/components/table/src/table-action-bar-content.vue2.js +399 -0
  128. package/lib/components/table/src/table-action-bar.vue.d.ts +4 -4
  129. package/lib/components/table/src/table-action-bar.vue2.js +28 -351
  130. package/lib/components/table/src/table-column-drag-sort.vue.d.ts +1 -1
  131. package/lib/components/table/src/table-column-index.vue.d.ts +1 -1
  132. package/lib/components/table/src/table-column.vue.d.ts +22 -29
  133. package/lib/components/table/src/table-column.vue2.js +2 -55
  134. package/lib/components/table/src/table-title-bar.vue.d.ts +2 -2
  135. package/lib/components/table/src/type.d.ts +0 -11
  136. package/lib/components/table/src/use-columns.d.ts +26 -0
  137. package/lib/components/table/src/use-columns.js +42 -0
  138. package/lib/components/table-lite/index.d.ts +1783 -0
  139. package/lib/components/table-lite/index.js +8 -0
  140. package/lib/components/table-lite/src/index.vue.d.ts +672 -0
  141. package/lib/components/table-lite/src/index.vue.js +10 -0
  142. package/lib/components/table-lite/src/index.vue2.js +685 -0
  143. package/lib/components/table-lite/src/type.d.ts +91 -0
  144. package/lib/components/table-lite/src/type.js +2 -0
  145. package/lib/components/table-lite/style/css.d.ts +16 -0
  146. package/lib/components/table-lite/style/css.js +19 -0
  147. package/lib/components/table-lite/style/index.d.ts +16 -0
  148. package/lib/components/table-lite/style/index.js +19 -0
  149. package/lib/components/table-v2/index.d.ts +174 -0
  150. package/lib/components/table-v2/index.js +10 -0
  151. package/lib/components/table-v2/src/column-converter.d.ts +27 -0
  152. package/lib/components/table-v2/src/column-converter.js +44 -0
  153. package/lib/components/table-v2/src/index.vue.d.ts +157 -0
  154. package/lib/components/table-v2/src/index.vue.js +10 -0
  155. package/lib/components/table-v2/src/index.vue2.js +495 -0
  156. package/lib/components/table-v2/src/special-columns.d.ts +61 -0
  157. package/lib/components/table-v2/src/special-columns.js +80 -0
  158. package/lib/components/table-v2/src/table-v2-cell.d.ts +104 -0
  159. package/lib/components/table-v2/src/table-v2-cell.js +143 -0
  160. package/lib/components/table-v2/src/table-v2-header-cell.vue.d.ts +61 -0
  161. package/lib/components/table-v2/src/table-v2-header-cell.vue.js +10 -0
  162. package/lib/components/table-v2/src/table-v2-header-cell.vue2.js +96 -0
  163. package/lib/components/table-v2/src/type.d.ts +95 -0
  164. package/lib/components/table-v2/src/type.js +2 -0
  165. package/lib/components/table-v2/src/use-table-v2-columns.d.ts +43 -0
  166. package/lib/components/table-v2/src/use-table-v2-columns.js +51 -0
  167. package/lib/components/table-v2/style/css.d.ts +17 -0
  168. package/lib/components/table-v2/style/css.js +20 -0
  169. package/lib/components/table-v2/style/index.d.ts +17 -0
  170. package/lib/components/table-v2/style/index.js +20 -0
  171. package/lib/index.js +51 -39
  172. package/lib/version.d.ts +1 -1
  173. package/lib/version.js +1 -1
  174. package/locale/en.js +1 -1
  175. package/locale/en.min.js +1 -1
  176. package/locale/en.min.mjs +1 -1
  177. package/locale/en.mjs +1 -1
  178. package/locale/ja.js +1 -1
  179. package/locale/ja.min.js +1 -1
  180. package/locale/ja.min.mjs +1 -1
  181. package/locale/ja.mjs +1 -1
  182. package/locale/ko.js +1 -1
  183. package/locale/ko.min.js +1 -1
  184. package/locale/ko.min.mjs +1 -1
  185. package/locale/ko.mjs +1 -1
  186. package/locale/zh-cn.js +1 -1
  187. package/locale/zh-cn.min.js +1 -1
  188. package/locale/zh-cn.min.mjs +1 -1
  189. package/locale/zh-cn.mjs +1 -1
  190. package/locale/zh-hk.js +1 -1
  191. package/locale/zh-hk.min.js +1 -1
  192. package/locale/zh-hk.min.mjs +1 -1
  193. package/locale/zh-hk.mjs +1 -1
  194. package/locale/zh-tw.js +1 -1
  195. package/locale/zh-tw.min.js +1 -1
  196. package/locale/zh-tw.min.mjs +1 -1
  197. package/locale/zh-tw.mjs +1 -1
  198. package/package.json +1 -1
  199. package/theme-chalk/index.css +1 -1
  200. package/theme-chalk/plus-table-lite.css +1 -0
  201. package/theme-chalk/plus-table-v2.css +1 -0
  202. package/theme-chalk/src/index.scss +2 -0
  203. package/theme-chalk/src/table-lite.scss +53 -0
  204. package/theme-chalk/src/table-v2.scss +71 -0
@@ -0,0 +1,495 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var lodashEs = require('lodash-es');
7
+ var elementPlus = require('element-plus');
8
+ var index = require('../../pagination/index.js');
9
+ require('../../../constants/index.js');
10
+ require('../../utils/index.js');
11
+ require('../../table/index.js');
12
+ require('../../../hooks/index.js');
13
+ var columnConverter = require('./column-converter.js');
14
+ var specialColumns = require('./special-columns.js');
15
+ var useTableV2Columns = require('./use-table-v2-columns.js');
16
+ var tableV2Cell = require('./table-v2-cell.js');
17
+ var useLocale = require('../../../hooks/useLocale.js');
18
+ var page = require('../../../constants/page.js');
19
+ var useColumns = require('../../table/src/use-columns.js');
20
+ var is = require('../../utils/is.js');
21
+ var tableActionBarContent = require('../../table/src/table-action-bar-content.vue.js');
22
+ var form = require('../../../constants/form.js');
23
+ var tableTitleBar = require('../../table/src/table-title-bar.vue.js');
24
+
25
+ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
26
+ ...{
27
+ name: "PlusTableV2",
28
+ inheritAttrs: false
29
+ },
30
+ __name: "index",
31
+ props: {
32
+ tableData: { default: () => [] },
33
+ data: { default: () => [] },
34
+ columns: { default: () => [] },
35
+ defaultSize: { default: "default" },
36
+ pagination: { type: [Boolean, Object], default: false },
37
+ actionBar: { type: [Boolean, Object], default: false },
38
+ hasIndexColumn: { type: Boolean, default: false },
39
+ titleBar: { type: [Boolean, Object], default: true },
40
+ isSelection: { type: Boolean, default: false },
41
+ isRadio: { type: Boolean, default: false },
42
+ specialColumnsOrder: { default: () => ["radio", "selection", "index"] },
43
+ loadingStatus: { type: Boolean, default: false },
44
+ height: { default: void 0 },
45
+ width: { default: void 0 },
46
+ rowHeight: { default: void 0 },
47
+ headerHeight: { default: 50 },
48
+ headerCellStyle: { default: () => ({
49
+ "background-color": "var(--el-fill-color-light)"
50
+ }) },
51
+ rowKey: { default: "id" },
52
+ defaultSelectedRadioRow: { default: void 0 },
53
+ radioProps: { default: void 0 },
54
+ selectionTableColumnProps: { default: () => ({ width: 40 }) },
55
+ radioTableColumnProps: { default: () => ({ width: 50 }) },
56
+ indexTableColumnProps: { default: () => ({}) },
57
+ indexContentStyle: { type: [Object, Function], default: () => ({}) },
58
+ editable: { type: [Boolean, String], default: false },
59
+ adaptive: { type: [Boolean, Object], default: false },
60
+ emptyValue: { default: void 0 }
61
+ },
62
+ emits: ["paginationChange", "clickAction", "clickActionConfirmCancel", "formChange", "refresh", "edited", "cell-click", "cell-dblclick", "filterTableHeader", "radioChange", "selection-change", "row-click", "row-dblclick"],
63
+ setup(__props, { expose: __expose, emit: __emit }) {
64
+ var _a, _b;
65
+ const props = __props;
66
+ const emit = __emit;
67
+ const { t } = useLocale.useLocale();
68
+ const slots = vue.useSlots();
69
+ const tableWrapperInstance = vue.ref(null);
70
+ const tableInstance = vue.shallowRef(null);
71
+ const paginationInstance = vue.ref(null);
72
+ const state = vue.reactive({
73
+ size: props.defaultSize,
74
+ subPageInfo: {
75
+ ...((_a = props.pagination) == null ? void 0 : _a.modelValue) || page.DefaultPageInfo
76
+ }
77
+ });
78
+ const __tableData = vue.computed(
79
+ () => {
80
+ var _a2;
81
+ return ((_a2 = props.tableData) == null ? void 0 : _a2.length) ? props.tableData : props.data;
82
+ }
83
+ );
84
+ const { subColumns, filterColumns, columnsIsChange, setFilterColumns } = useColumns.useTableColumns({
85
+ columns: () => props.columns
86
+ });
87
+ const formRefs = vue.shallowRef({});
88
+ const formFieldRefs = vue.shallowRef({});
89
+ const sizeRowHeightMap = {
90
+ default: 50,
91
+ large: 60,
92
+ small: 40
93
+ };
94
+ const currentRowHeight = vue.computed(() => {
95
+ var _a2, _b2;
96
+ return (_b2 = (_a2 = props.rowHeight) != null ? _a2 : sizeRowHeightMap[state.size]) != null ? _b2 : 50;
97
+ });
98
+ const containerWidth = vue.ref(0);
99
+ const fillHeight = vue.ref(400);
100
+ const tableWidth = vue.computed(() => {
101
+ if (props.width !== void 0) return useTableV2Columns.toColumnNumber(props.width);
102
+ return Math.max(containerWidth.value, 1);
103
+ });
104
+ const tableHeight = vue.computed(() => {
105
+ if (props.height !== void 0) return useTableV2Columns.toColumnNumber(props.height);
106
+ return fillHeight.value;
107
+ });
108
+ const bodyHeight = vue.computed(() => `${tableHeight.value}px`);
109
+ const calcFillHeight = () => {
110
+ var _a2;
111
+ if (!tableWrapperInstance.value) return;
112
+ let offsetBottom = 20;
113
+ if (is.isPlainObject(props.adaptive)) {
114
+ offsetBottom = (_a2 = props.adaptive.offsetBottom) != null ? _a2 : offsetBottom;
115
+ }
116
+ const paginationHeight = paginationInstance.value && props.pagination ? paginationInstance.value.$el.offsetHeight : 0;
117
+ const top = tableWrapperInstance.value.getBoundingClientRect().top;
118
+ fillHeight.value = Math.max(window.innerHeight - top - offsetBottom - paginationHeight, 100);
119
+ };
120
+ const handleResize = ({ width }) => {
121
+ containerWidth.value = width;
122
+ };
123
+ const debounceCalcFillHeight = lodashEs.debounce(
124
+ calcFillHeight,
125
+ is.isPlainObject(props.adaptive) ? (_b = props.adaptive.timeout) != null ? _b : 60 : 60
126
+ );
127
+ const radioRow = vue.ref({});
128
+ vue.watch(
129
+ () => props.defaultSelectedRadioRow,
130
+ (val) => {
131
+ radioRow.value = val != null ? val : {};
132
+ },
133
+ { immediate: true }
134
+ );
135
+ const selectedRows = vue.ref([]);
136
+ const getRowKeyValue = (row) => row == null ? void 0 : row[props.rowKey];
137
+ const isRowSelected = (row) => {
138
+ const key = getRowKeyValue(row);
139
+ return selectedRows.value.some((item) => getRowKeyValue(item) === key);
140
+ };
141
+ const isAllSelected = () => __tableData.value.length > 0 && selectedRows.value.length === __tableData.value.length;
142
+ const isIndeterminate = () => selectedRows.value.length > 0 && selectedRows.value.length < __tableData.value.length;
143
+ const handleToggleRow = (row, checked) => {
144
+ const key = getRowKeyValue(row);
145
+ const rest = selectedRows.value.filter((item) => getRowKeyValue(item) !== key);
146
+ selectedRows.value = checked ? [...rest, row] : rest;
147
+ emit("selection-change", selectedRows.value);
148
+ };
149
+ const handleToggleAll = (checked) => {
150
+ selectedRows.value = checked ? [...__tableData.value] : [];
151
+ emit("selection-change", selectedRows.value);
152
+ };
153
+ const handleRadioChange = (value, row) => {
154
+ radioRow.value = value ? row : {};
155
+ emit("radioChange", row, __tableData.value.indexOf(row), !!value);
156
+ };
157
+ const handleFormChange = (data) => {
158
+ emit("formChange", data);
159
+ };
160
+ const handleRefresh = () => {
161
+ emit("refresh");
162
+ };
163
+ const handleClickDensity = (size) => {
164
+ state.size = size;
165
+ };
166
+ const handleFilterTableConfirm = (list, eventType) => {
167
+ setFilterColumns(list);
168
+ emit("filterTableHeader", list, eventType);
169
+ };
170
+ const handlePaginationChange = () => {
171
+ emit("paginationChange", { ...state.subPageInfo });
172
+ };
173
+ const getCellForm = (row, column) => {
174
+ var _a2;
175
+ const rowIndex = __tableData.value.indexOf(row);
176
+ const columnIndex = subColumns.value.findIndex((item) => item.prop === column.prop);
177
+ if (rowIndex < 0 || columnIndex < 0) return null;
178
+ return ((_a2 = formRefs.value[rowIndex]) == null ? void 0 : _a2[columnIndex]) || null;
179
+ };
180
+ const currentForm = vue.shallowRef(null);
181
+ const startCellEdit = (row, column) => {
182
+ var _a2;
183
+ const cellForm = getCellForm(row, column);
184
+ if (!cellForm) return;
185
+ document.addEventListener("click", handleStopEditClick);
186
+ (_a2 = currentForm.value) == null ? void 0 : _a2.stopCellEdit();
187
+ currentForm.value = cellForm;
188
+ cellForm.startCellEdit();
189
+ const unwatch = vue.watch(
190
+ () => formFieldRefs.value.valueIsReady,
191
+ (val) => {
192
+ var _a3, _b2;
193
+ if ((val == null ? void 0 : val.value) && ((_b2 = (_a3 = formFieldRefs.value) == null ? void 0 : _a3.fieldInstance) == null ? void 0 : _b2.focus)) {
194
+ formFieldRefs.value.fieldInstance.focus();
195
+ unwatch();
196
+ }
197
+ }
198
+ );
199
+ };
200
+ const handleStopEditClick = (event) => {
201
+ var _a2;
202
+ if (!tableWrapperInstance.value || !currentForm.value) return;
203
+ const target = event == null ? void 0 : event.target;
204
+ if ((_a2 = target == null ? void 0 : target.classList) == null ? void 0 : _a2.contains("el-icon")) return;
205
+ if (tableWrapperInstance.value.contains(target)) return;
206
+ currentForm.value.stopCellEdit();
207
+ currentForm.value = null;
208
+ emit("edited");
209
+ document.removeEventListener("click", handleStopEditClick);
210
+ };
211
+ const handleCellClick = (row, column, event) => {
212
+ if (props.editable === "click") startCellEdit(row, column);
213
+ emit("cell-click", row, column, event.currentTarget, event);
214
+ };
215
+ const handleCellDblclick = (row, column, event) => {
216
+ if (props.editable === "dblclick") startCellEdit(row, column);
217
+ emit("cell-dblclick", row, column, event.currentTarget, event);
218
+ };
219
+ const getCellSlots = () => {
220
+ const cellSlots = {};
221
+ Object.keys(slots).forEach((key) => {
222
+ if (key.startsWith("plus-") || key === "edit-icon") {
223
+ cellSlots[key] = slots[key];
224
+ }
225
+ });
226
+ return cellSlots;
227
+ };
228
+ const renderCell = ({
229
+ column,
230
+ row,
231
+ rowIndex,
232
+ columnIndex
233
+ }) => vue.h(
234
+ tableV2Cell.default,
235
+ {
236
+ column,
237
+ row,
238
+ index: rowIndex,
239
+ cellIndex: columnIndex,
240
+ editable: props.editable,
241
+ emptyValue: props.emptyValue,
242
+ onCellClick: handleCellClick,
243
+ onCellDblclick: handleCellDblclick,
244
+ onFormChange: handleFormChange
245
+ },
246
+ getCellSlots()
247
+ );
248
+ const dataColumns = vue.computed(
249
+ () => columnConverter.buildDataColumns({
250
+ columns: subColumns.value,
251
+ renderCell,
252
+ slots
253
+ })
254
+ );
255
+ const actionBarColumn = vue.computed(() => {
256
+ var _a2;
257
+ if (!props.actionBar) return null;
258
+ const actionBar = props.actionBar;
259
+ return {
260
+ key: "actionBar",
261
+ title: actionBar.label || t("plus.table.action"),
262
+ width: useTableV2Columns.toColumnNumber(actionBar.width) || 200,
263
+ fixed: actionBar.fixed || "right",
264
+ align: (_a2 = actionBar.actionBarTableColumnProps) == null ? void 0 : _a2.align,
265
+ cellRenderer: ({ rowData, rowIndex }) => vue.h(
266
+ tableActionBarContent.default,
267
+ {
268
+ row: rowData,
269
+ index: rowIndex,
270
+ type: actionBar.type,
271
+ buttons: actionBar.buttons,
272
+ showNumber: actionBar.showNumber,
273
+ showLimitIncludeMore: actionBar.showLimitIncludeMore,
274
+ confirmType: actionBar.confirmType,
275
+ moreType: actionBar.moreType,
276
+ onClickAction: (data) => emit("clickAction", data),
277
+ onClickActionConfirmCancel: (data) => emit("clickActionConfirmCancel", data)
278
+ },
279
+ {
280
+ "action-bar-more-icon": () => {
281
+ var _a3;
282
+ return (_a3 = slots["action-bar-more-icon"]) == null ? void 0 : _a3.call(slots);
283
+ }
284
+ }
285
+ )
286
+ };
287
+ });
288
+ const specialColumns$1 = vue.computed(() => {
289
+ const activeList = [];
290
+ if (props.isRadio) activeList.push("radio");
291
+ if (props.isSelection) activeList.push("selection");
292
+ if (props.hasIndexColumn) activeList.push("index");
293
+ const defaultOrder = ["radio", "selection", "index"];
294
+ const order = [...props.specialColumnsOrder || [], ...defaultOrder].filter(
295
+ (item, index, array) => array.indexOf(item) === index
296
+ );
297
+ return order.filter((item) => activeList.includes(item)).map((item) => {
298
+ if (item === "radio") {
299
+ return specialColumns.buildRadioColumn({
300
+ radioRow: () => radioRow.value,
301
+ onChange: handleRadioChange,
302
+ radioProps: props.radioProps,
303
+ columnProps: props.radioTableColumnProps
304
+ });
305
+ }
306
+ if (item === "selection") {
307
+ return specialColumns.buildSelectionColumn({
308
+ isSelected: isRowSelected,
309
+ isAllSelected,
310
+ isIndeterminate,
311
+ onToggleRow: handleToggleRow,
312
+ onToggleAll: handleToggleAll,
313
+ columnProps: props.selectionTableColumnProps
314
+ });
315
+ }
316
+ return specialColumns.buildIndexColumn({
317
+ pageInfo: state.subPageInfo,
318
+ indexContentStyle: props.indexContentStyle,
319
+ columnProps: props.indexTableColumnProps
320
+ });
321
+ });
322
+ });
323
+ const allColumns = vue.computed(() => {
324
+ const list = [...specialColumns$1.value, ...dataColumns.value];
325
+ if (actionBarColumn.value) list.push(actionBarColumn.value);
326
+ return list;
327
+ });
328
+ const { resolvedColumns } = useTableV2Columns.useTableV2Columns({
329
+ columns: () => allColumns.value,
330
+ containerWidth: () => tableWidth.value
331
+ });
332
+ const headerCellProps = () => ({ style: props.headerCellStyle });
333
+ const rowEventHandlers = vue.computed(() => ({
334
+ onClick: ({ rowData, rowIndex, event }) => {
335
+ emit("row-click", rowData, rowIndex, event);
336
+ },
337
+ onDblclick: ({ rowData, rowIndex, event }) => {
338
+ emit("row-dblclick", rowData, rowIndex, event);
339
+ }
340
+ }));
341
+ vue.onMounted(() => {
342
+ calcFillHeight();
343
+ window.addEventListener("resize", debounceCalcFillHeight);
344
+ });
345
+ vue.onBeforeUnmount(() => {
346
+ window.removeEventListener("resize", debounceCalcFillHeight);
347
+ document.removeEventListener("click", handleStopEditClick);
348
+ });
349
+ vue.provide(form.TableFormRefInjectionKey, formRefs);
350
+ vue.provide(form.TableFormFieldRefInjectionKey, formFieldRefs);
351
+ __expose({
352
+ formRefs,
353
+ tableInstance,
354
+ /** 滚动到指定垂直位置 */
355
+ scrollToTop: (top) => {
356
+ var _a2;
357
+ return (_a2 = tableInstance.value) == null ? void 0 : _a2.scrollToTop(top);
358
+ },
359
+ /** 滚动到指定水平位置 */
360
+ scrollToLeft: (left) => {
361
+ var _a2;
362
+ return (_a2 = tableInstance.value) == null ? void 0 : _a2.scrollToLeft(left);
363
+ },
364
+ /** 滚动到指定行 */
365
+ scrollToRow: (row, strategy) => {
366
+ var _a2;
367
+ return (_a2 = tableInstance.value) == null ? void 0 : _a2.scrollToRow(row, strategy);
368
+ }
369
+ });
370
+ return (_ctx, _cache) => {
371
+ return vue.openBlock(), vue.createElementBlock(
372
+ "div",
373
+ {
374
+ ref_key: "tableWrapperInstance",
375
+ ref: tableWrapperInstance,
376
+ class: "plus-table-v2"
377
+ },
378
+ [
379
+ vue.createCommentVNode(" \u6807\u9898\u680F\uFF1A\u5237\u65B0 / \u5BC6\u5EA6 / \u5217\u8BBE\u7F6E\uFF0C\u4E0E el-table \u7248\u672C\u590D\u7528\u540C\u4E00\u7EC4\u4EF6 "),
380
+ _ctx.titleBar ? (vue.openBlock(), vue.createBlock(vue.unref(tableTitleBar.default), {
381
+ key: 0,
382
+ "origin-columns": _ctx.columns,
383
+ columns: vue.unref(filterColumns),
384
+ "default-size": state.size,
385
+ "columns-is-change": vue.unref(columnsIsChange),
386
+ "title-bar": _ctx.titleBar,
387
+ onClickDensity: handleClickDensity,
388
+ onFilterTableHeader: handleFilterTableConfirm,
389
+ onRefresh: handleRefresh
390
+ }, vue.createSlots({
391
+ title: vue.withCtx(() => [
392
+ vue.renderSlot(_ctx.$slots, "title")
393
+ ]),
394
+ toolbar: vue.withCtx(() => [
395
+ vue.renderSlot(_ctx.$slots, "toolbar")
396
+ ]),
397
+ _: 2
398
+ /* DYNAMIC */
399
+ }, [
400
+ _ctx.$slots["column-settings-icon"] ? {
401
+ name: "column-settings-icon",
402
+ fn: vue.withCtx(() => [
403
+ vue.renderSlot(_ctx.$slots, "column-settings-icon")
404
+ ]),
405
+ key: "0"
406
+ } : void 0,
407
+ _ctx.$slots["density-icon"] ? {
408
+ name: "density-icon",
409
+ fn: vue.withCtx(() => [
410
+ vue.renderSlot(_ctx.$slots, "density-icon")
411
+ ]),
412
+ key: "1"
413
+ } : void 0
414
+ ]), 1032, ["origin-columns", "columns", "default-size", "columns-is-change", "title-bar"])) : vue.createCommentVNode("v-if", true),
415
+ vue.createCommentVNode(" \u865A\u62DF\u8868\u683C\u4E3B\u4F53\uFF1A\u5BBD\u5EA6\u6491\u6EE1\u7236\u5BB9\u5668\uFF0C\u9AD8\u5EA6\u6309 props.height / adaptive \u8BA1\u7B97 "),
416
+ vue.withDirectives((vue.openBlock(), vue.createElementBlock(
417
+ "div",
418
+ {
419
+ class: "plus-table-v2__body",
420
+ style: vue.normalizeStyle({ height: bodyHeight.value })
421
+ },
422
+ [
423
+ vue.createVNode(vue.unref(elementPlus.ElAutoResizer), {
424
+ "disable-height": true,
425
+ "on-resize": handleResize
426
+ }, {
427
+ default: vue.withCtx(() => [
428
+ vue.createVNode(vue.unref(elementPlus.ElTableV2), vue.mergeProps({
429
+ ref_key: "tableInstance",
430
+ ref: tableInstance,
431
+ columns: vue.unref(resolvedColumns),
432
+ data: __tableData.value,
433
+ width: tableWidth.value,
434
+ height: tableHeight.value,
435
+ "row-height": currentRowHeight.value,
436
+ "header-height": _ctx.headerHeight,
437
+ "row-key": _ctx.rowKey,
438
+ "header-cell-props": headerCellProps,
439
+ "row-event-handlers": rowEventHandlers.value,
440
+ fixed: true,
441
+ "scrollbar-always-on": true
442
+ }, _ctx.$attrs), {
443
+ empty: vue.withCtx(() => [
444
+ vue.renderSlot(_ctx.$slots, "empty", {}, () => [
445
+ vue.createVNode(vue.unref(elementPlus.ElEmpty))
446
+ ])
447
+ ]),
448
+ _: 3
449
+ /* FORWARDED */
450
+ }, 16, ["columns", "data", "width", "height", "row-height", "header-height", "row-key", "row-event-handlers"])
451
+ ]),
452
+ _: 3
453
+ /* FORWARDED */
454
+ })
455
+ ],
456
+ 4
457
+ /* STYLE */
458
+ )), [
459
+ [vue.unref(elementPlus.vLoading), _ctx.loadingStatus]
460
+ ]),
461
+ vue.createCommentVNode(" \u5206\u9875 "),
462
+ _ctx.pagination ? (vue.openBlock(), vue.createBlock(vue.unref(index.PlusPagination), vue.mergeProps({
463
+ key: 1,
464
+ ref_key: "paginationInstance",
465
+ ref: paginationInstance,
466
+ modelValue: state.subPageInfo,
467
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.subPageInfo = $event)
468
+ }, _ctx.pagination, { onChange: handlePaginationChange }), vue.createSlots({
469
+ _: 2
470
+ /* DYNAMIC */
471
+ }, [
472
+ _ctx.$slots["pagination-left"] ? {
473
+ name: "pagination-left",
474
+ fn: vue.withCtx(() => [
475
+ vue.renderSlot(_ctx.$slots, "pagination-left")
476
+ ]),
477
+ key: "0"
478
+ } : void 0,
479
+ _ctx.$slots["pagination-right"] ? {
480
+ name: "pagination-right",
481
+ fn: vue.withCtx(() => [
482
+ vue.renderSlot(_ctx.$slots, "pagination-right")
483
+ ]),
484
+ key: "1"
485
+ } : void 0
486
+ ]), 1040, ["modelValue"])) : vue.createCommentVNode("v-if", true)
487
+ ],
488
+ 512
489
+ /* NEED_PATCH */
490
+ );
491
+ };
492
+ }
493
+ });
494
+
495
+ exports.default = _sfc_main;
@@ -0,0 +1,61 @@
1
+ import { PageInfo, RecordType } from 'tabula-vue/es/types';
2
+ import { PlusRadioProps } from 'tabula-vue/es/components/radio';
3
+ import { Column } from 'element-plus';
4
+ import { CSSProperties } from 'vue';
5
+
6
+ /** 列配置的宽松类型(兼容 el-table 的 width / fixed / align 等) */
7
+ type ColumnConfig = RecordType;
8
+ /**
9
+ * 序号列参数
10
+ */
11
+ export interface BuildIndexColumnParams {
12
+ /** 当前页码信息,用于计算跨页序号 */
13
+ pageInfo?: PageInfo;
14
+ /** 单元格样式 */
15
+ indexContentStyle?: Partial<CSSProperties> | ((row: RecordType, index: number) => Partial<CSSProperties>);
16
+ /** 列配置(兼容 el-table 的 width / fixed / align 等) */
17
+ columnProps?: ColumnConfig;
18
+ }
19
+ /**
20
+ * 构建序号列
21
+ */
22
+ export declare const buildIndexColumn: ({ pageInfo, indexContentStyle, columnProps }: BuildIndexColumnParams) => Column;
23
+ /**
24
+ * 单选列参数
25
+ */
26
+ export interface BuildRadioColumnParams {
27
+ /** 当前选中的行 */
28
+ radioRow: () => RecordType;
29
+ /** 选中变化 */
30
+ onChange: (value: PlusRadioProps['modelValue'], row: RecordType) => void;
31
+ /** PlusRadio 的 props */
32
+ radioProps?: Partial<PlusRadioProps>;
33
+ /** 列配置 */
34
+ columnProps?: ColumnConfig;
35
+ }
36
+ /**
37
+ * 构建单选列
38
+ */
39
+ export declare const buildRadioColumn: ({ radioRow, onChange, radioProps, columnProps }: BuildRadioColumnParams) => Column;
40
+ /**
41
+ * 多选列参数
42
+ */
43
+ export interface BuildSelectionColumnParams {
44
+ /** 判断某行是否选中 */
45
+ isSelected: (row: RecordType) => boolean;
46
+ /** 当前是否全选 */
47
+ isAllSelected: () => boolean;
48
+ /** 是否半选 */
49
+ isIndeterminate: () => boolean;
50
+ /** 单行选中变化 */
51
+ onToggleRow: (row: RecordType, checked: boolean) => void;
52
+ /** 全选变化 */
53
+ onToggleAll: (checked: boolean) => void;
54
+ /** 列配置 */
55
+ columnProps?: ColumnConfig;
56
+ }
57
+ /**
58
+ * 构建多选列(含表头全选)
59
+ */
60
+ export declare const buildSelectionColumn: ({ isSelected, isAllSelected, isIndeterminate, onToggleRow, onToggleAll, columnProps }: BuildSelectionColumnParams) => Column;
61
+ export {};
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+ var elementPlus = require('element-plus');
5
+ var index = require('../../radio/index.js');
6
+ require('../../utils/index.js');
7
+ var lodashEs = require('lodash-es');
8
+ var is = require('../../utils/is.js');
9
+
10
+ const toNumber = (value, fallback) => {
11
+ const num = Number(value);
12
+ return Number.isFinite(num) && num > 0 ? num : fallback;
13
+ };
14
+ const buildIndexColumn = ({
15
+ pageInfo,
16
+ indexContentStyle,
17
+ columnProps = {}
18
+ }) => {
19
+ const getIndex = lodashEs.isNumber(columnProps.index) ? () => columnProps.index : is.isFunction(columnProps.index) ? columnProps.index : (index) => (((pageInfo == null ? void 0 : pageInfo.page) || 1) - 1) * ((pageInfo == null ? void 0 : pageInfo.pageSize) || 10) + index + 1;
20
+ const resolveStyle = (row, index) => {
21
+ if (is.isFunction(indexContentStyle)) return indexContentStyle(row, index);
22
+ if (is.isPlainObject(indexContentStyle)) return indexContentStyle;
23
+ return {};
24
+ };
25
+ return {
26
+ key: "index",
27
+ title: "#",
28
+ width: toNumber(columnProps.width, 60),
29
+ fixed: elementPlus.TableV2FixedDir.LEFT,
30
+ align: "center",
31
+ cellRenderer: ({ rowData, rowIndex }) => vue.h("div", { class: "plus-table-v2-index", style: resolveStyle(rowData, rowIndex) }, [
32
+ String(getIndex(rowIndex))
33
+ ])
34
+ };
35
+ };
36
+ const buildRadioColumn = ({
37
+ radioRow,
38
+ onChange,
39
+ radioProps,
40
+ columnProps = {}
41
+ }) => ({
42
+ key: "radio",
43
+ title: "",
44
+ width: toNumber(columnProps.width, 50),
45
+ fixed: elementPlus.TableV2FixedDir.LEFT,
46
+ align: "center",
47
+ cellRenderer: ({ rowData }) => vue.h(index.PlusRadio, {
48
+ modelValue: lodashEs.isEqual(radioRow(), rowData),
49
+ options: [{ value: true }],
50
+ ...radioProps,
51
+ onChange: (value) => onChange(value, rowData)
52
+ })
53
+ });
54
+ const buildSelectionColumn = ({
55
+ isSelected,
56
+ isAllSelected,
57
+ isIndeterminate,
58
+ onToggleRow,
59
+ onToggleAll,
60
+ columnProps = {}
61
+ }) => ({
62
+ key: "selection",
63
+ title: "",
64
+ width: toNumber(columnProps.width, 40),
65
+ fixed: elementPlus.TableV2FixedDir.LEFT,
66
+ align: "center",
67
+ headerCellRenderer: () => vue.h(elementPlus.ElCheckbox, {
68
+ modelValue: isAllSelected(),
69
+ indeterminate: isIndeterminate(),
70
+ "onUpdate:modelValue": (checked) => onToggleAll(Boolean(checked))
71
+ }),
72
+ cellRenderer: ({ rowData }) => vue.h(elementPlus.ElCheckbox, {
73
+ modelValue: isSelected(rowData),
74
+ "onUpdate:modelValue": (checked) => onToggleRow(rowData, Boolean(checked))
75
+ })
76
+ });
77
+
78
+ exports.buildIndexColumn = buildIndexColumn;
79
+ exports.buildRadioColumn = buildRadioColumn;
80
+ exports.buildSelectionColumn = buildSelectionColumn;