yy-vue-easytable 2.27.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 (205) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +187 -0
  3. package/libs/font/demo.css +539 -0
  4. package/libs/font/demo_index.html +400 -0
  5. package/libs/font/iconfont.css +57 -0
  6. package/libs/font/iconfont.eot +0 -0
  7. package/libs/font/iconfont.js +1 -0
  8. package/libs/font/iconfont.json +79 -0
  9. package/libs/font/iconfont.svg +56 -0
  10. package/libs/font/iconfont.ttf +0 -0
  11. package/libs/font/iconfont.woff +0 -0
  12. package/libs/font/iconfont.woff2 +0 -0
  13. package/libs/locale/lang/af-ZA.js +48 -0
  14. package/libs/locale/lang/en-US.js +48 -0
  15. package/libs/locale/lang/fr-FR.js +48 -0
  16. package/libs/locale/lang/ko-KR.js +48 -0
  17. package/libs/locale/lang/pt-BR.js +48 -0
  18. package/libs/locale/lang/ru-RU.js +48 -0
  19. package/libs/locale/lang/zh-CN.js +48 -0
  20. package/libs/locale/lang/zh-TW.js +48 -0
  21. package/libs/locale/lang/zu-ZA.js +48 -0
  22. package/libs/main.js +1 -0
  23. package/libs/theme-dark/base.css +1 -0
  24. package/libs/theme-dark/index.css +1253 -0
  25. package/libs/theme-dark/var.css +7 -0
  26. package/libs/theme-dark/ve-checkbox.css +150 -0
  27. package/libs/theme-dark/ve-contextmenu.css +71 -0
  28. package/libs/theme-dark/ve-dropdown.css +177 -0
  29. package/libs/theme-dark/ve-icon.css +10 -0
  30. package/libs/theme-dark/ve-loading.css +218 -0
  31. package/libs/theme-dark/ve-pagination.css +136 -0
  32. package/libs/theme-dark/ve-radio.css +111 -0
  33. package/libs/theme-dark/ve-select.css +50 -0
  34. package/libs/theme-dark/ve-table.css +385 -0
  35. package/libs/theme-default/base.css +1 -0
  36. package/libs/theme-default/index.css +1253 -0
  37. package/libs/theme-default/var.css +7 -0
  38. package/libs/theme-default/ve-checkbox.css +150 -0
  39. package/libs/theme-default/ve-contextmenu.css +71 -0
  40. package/libs/theme-default/ve-dropdown.css +177 -0
  41. package/libs/theme-default/ve-icon.css +10 -0
  42. package/libs/theme-default/ve-loading.css +218 -0
  43. package/libs/theme-default/ve-pagination.css +136 -0
  44. package/libs/theme-default/ve-radio.css +111 -0
  45. package/libs/theme-default/ve-select.css +50 -0
  46. package/libs/theme-default/ve-table.css +385 -0
  47. package/libs/umd/index.js +9 -0
  48. package/libs/ve-checkbox-group.js +1 -0
  49. package/libs/ve-checkbox.js +1 -0
  50. package/libs/ve-contextmenu.js +1 -0
  51. package/libs/ve-dropdown.js +1 -0
  52. package/libs/ve-icon.js +1 -0
  53. package/libs/ve-loading.js +1 -0
  54. package/libs/ve-locale.js +1 -0
  55. package/libs/ve-pagination.js +1 -0
  56. package/libs/ve-radio.js +1 -0
  57. package/libs/ve-select.js +1 -0
  58. package/libs/ve-table.js +1 -0
  59. package/package.json +142 -0
  60. package/packages/font/demo.css +539 -0
  61. package/packages/font/demo_index.html +400 -0
  62. package/packages/font/iconfont.css +57 -0
  63. package/packages/font/iconfont.eot +0 -0
  64. package/packages/font/iconfont.js +1 -0
  65. package/packages/font/iconfont.json +79 -0
  66. package/packages/font/iconfont.svg +56 -0
  67. package/packages/font/iconfont.ttf +0 -0
  68. package/packages/font/iconfont.woff +0 -0
  69. package/packages/font/iconfont.woff2 +0 -0
  70. package/packages/index.js +75 -0
  71. package/packages/src/comps/resize-observer/index.js +2 -0
  72. package/packages/src/comps/resize-observer/src/index.jsx +38 -0
  73. package/packages/src/directives/clickoutside.js +31 -0
  74. package/packages/src/directives/events-outside.js +79 -0
  75. package/packages/src/directives/focus.js +28 -0
  76. package/packages/src/locale/index.js +27 -0
  77. package/packages/src/locale/lang/af-ZA.js +29 -0
  78. package/packages/src/locale/lang/en-US.js +30 -0
  79. package/packages/src/locale/lang/fr-FR.js +29 -0
  80. package/packages/src/locale/lang/ko-KR.js +29 -0
  81. package/packages/src/locale/lang/pt-BR.js +29 -0
  82. package/packages/src/locale/lang/ru-RU.js +29 -0
  83. package/packages/src/locale/lang/zh-CN.js +30 -0
  84. package/packages/src/locale/lang/zh-TW.js +29 -0
  85. package/packages/src/locale/lang/zu-ZA.js +29 -0
  86. package/packages/src/mixins/emitter.js +39 -0
  87. package/packages/src/utils/animation-frame.js +39 -0
  88. package/packages/src/utils/auto-resize.js +179 -0
  89. package/packages/src/utils/constant.js +42 -0
  90. package/packages/src/utils/dom.js +239 -0
  91. package/packages/src/utils/event-key-codes.js +53 -0
  92. package/packages/src/utils/hooks-manager.js +76 -0
  93. package/packages/src/utils/index.js +161 -0
  94. package/packages/src/utils/mouse-event.js +24 -0
  95. package/packages/src/utils/random.js +6 -0
  96. package/packages/src/utils/request-animation-timeout.js +36 -0
  97. package/packages/src/utils/resize-event.js +40 -0
  98. package/packages/src/utils/scroll-bar.js +27 -0
  99. package/packages/style/ve-checkbox.less +179 -0
  100. package/packages/style/ve-contextmenu.less +76 -0
  101. package/packages/style/ve-dropdown.less +204 -0
  102. package/packages/style/ve-icon.less +3 -0
  103. package/packages/style/ve-loading.less +242 -0
  104. package/packages/style/ve-pagination.less +153 -0
  105. package/packages/style/ve-radio.less +126 -0
  106. package/packages/style/ve-select.less +48 -0
  107. package/packages/style/ve-table.less +539 -0
  108. package/packages/theme-dark/base.less +1 -0
  109. package/packages/theme-dark/index.less +12 -0
  110. package/packages/theme-dark/var.less +111 -0
  111. package/packages/theme-dark/ve-checkbox.less +2 -0
  112. package/packages/theme-dark/ve-contextmenu.less +2 -0
  113. package/packages/theme-dark/ve-dropdown.less +2 -0
  114. package/packages/theme-dark/ve-icon.less +2 -0
  115. package/packages/theme-dark/ve-loading.less +2 -0
  116. package/packages/theme-dark/ve-pagination.less +2 -0
  117. package/packages/theme-dark/ve-radio.less +2 -0
  118. package/packages/theme-dark/ve-select.less +2 -0
  119. package/packages/theme-dark/ve-table.less +2 -0
  120. package/packages/theme-default/base.less +1 -0
  121. package/packages/theme-default/index.less +12 -0
  122. package/packages/theme-default/var.less +111 -0
  123. package/packages/theme-default/ve-checkbox.less +2 -0
  124. package/packages/theme-default/ve-contextmenu.less +2 -0
  125. package/packages/theme-default/ve-dropdown.less +2 -0
  126. package/packages/theme-default/ve-icon.less +2 -0
  127. package/packages/theme-default/ve-loading.less +2 -0
  128. package/packages/theme-default/ve-pagination.less +2 -0
  129. package/packages/theme-default/ve-radio.less +2 -0
  130. package/packages/theme-default/ve-select.less +2 -0
  131. package/packages/theme-default/ve-table.less +2 -0
  132. package/packages/ve-checkbox/index.js +7 -0
  133. package/packages/ve-checkbox/src/index.jsx +175 -0
  134. package/packages/ve-checkbox/src/util/constant.js +14 -0
  135. package/packages/ve-checkbox/src/util/index.js +10 -0
  136. package/packages/ve-checkbox-group/index.js +7 -0
  137. package/packages/ve-checkbox-group/src/index.jsx +53 -0
  138. package/packages/ve-checkbox-group/src/util/constant.js +14 -0
  139. package/packages/ve-checkbox-group/src/util/index.js +10 -0
  140. package/packages/ve-contextmenu/index.js +7 -0
  141. package/packages/ve-contextmenu/src/index.jsx +731 -0
  142. package/packages/ve-contextmenu/src/util/constant.js +29 -0
  143. package/packages/ve-contextmenu/src/util/index.js +10 -0
  144. package/packages/ve-dropdown/index.js +7 -0
  145. package/packages/ve-dropdown/src/index.jsx +720 -0
  146. package/packages/ve-dropdown/src/util/constant.js +15 -0
  147. package/packages/ve-dropdown/src/util/index.js +10 -0
  148. package/packages/ve-icon/index.js +7 -0
  149. package/packages/ve-icon/src/index.jsx +52 -0
  150. package/packages/ve-icon/src/util/constant.js +10 -0
  151. package/packages/ve-icon/src/util/index.js +10 -0
  152. package/packages/ve-loading/index.js +8 -0
  153. package/packages/ve-loading/src/bounce.jsx +50 -0
  154. package/packages/ve-loading/src/flow.jsx +51 -0
  155. package/packages/ve-loading/src/grid.jsx +57 -0
  156. package/packages/ve-loading/src/index.js +106 -0
  157. package/packages/ve-loading/src/loading.jsx +63 -0
  158. package/packages/ve-loading/src/plane.jsx +38 -0
  159. package/packages/ve-loading/src/pulse.jsx +38 -0
  160. package/packages/ve-loading/src/util/constant.js +31 -0
  161. package/packages/ve-loading/src/util/index.js +10 -0
  162. package/packages/ve-loading/src/wave.jsx +53 -0
  163. package/packages/ve-locale/index.js +28 -0
  164. package/packages/ve-pagination/index.js +7 -0
  165. package/packages/ve-pagination/src/index.jsx +304 -0
  166. package/packages/ve-pagination/src/pager.jsx +166 -0
  167. package/packages/ve-pagination/src/util/constant.js +16 -0
  168. package/packages/ve-pagination/src/util/index.js +10 -0
  169. package/packages/ve-radio/index.js +7 -0
  170. package/packages/ve-radio/src/index.jsx +121 -0
  171. package/packages/ve-radio/src/util/constant.js +13 -0
  172. package/packages/ve-radio/src/util/index.js +10 -0
  173. package/packages/ve-select/index.js +7 -0
  174. package/packages/ve-select/src/index.jsx +193 -0
  175. package/packages/ve-select/src/util/constant.js +13 -0
  176. package/packages/ve-select/src/util/index.js +10 -0
  177. package/packages/ve-table/index.js +7 -0
  178. package/packages/ve-table/src/body/body-checkbox-content.jsx +126 -0
  179. package/packages/ve-table/src/body/body-radio-content.jsx +113 -0
  180. package/packages/ve-table/src/body/body-td.jsx +671 -0
  181. package/packages/ve-table/src/body/body-tr-scrolling.jsx +38 -0
  182. package/packages/ve-table/src/body/body-tr.jsx +383 -0
  183. package/packages/ve-table/src/body/expand-tr-icon.jsx +80 -0
  184. package/packages/ve-table/src/body/expand-tr.jsx +147 -0
  185. package/packages/ve-table/src/body/index.jsx +943 -0
  186. package/packages/ve-table/src/colgroup/index.jsx +48 -0
  187. package/packages/ve-table/src/column-resizer/index.jsx +318 -0
  188. package/packages/ve-table/src/editor/constant.js +5 -0
  189. package/packages/ve-table/src/editor/index.jsx +533 -0
  190. package/packages/ve-table/src/footer/footer-td.jsx +396 -0
  191. package/packages/ve-table/src/footer/footer-tr.jsx +249 -0
  192. package/packages/ve-table/src/footer/index.jsx +108 -0
  193. package/packages/ve-table/src/header/header-checkbox-content.jsx +69 -0
  194. package/packages/ve-table/src/header/header-filter-content.jsx +100 -0
  195. package/packages/ve-table/src/header/header-filter-custom-content.jsx +110 -0
  196. package/packages/ve-table/src/header/header-th.jsx +664 -0
  197. package/packages/ve-table/src/header/header-tr.jsx +255 -0
  198. package/packages/ve-table/src/header/index.jsx +195 -0
  199. package/packages/ve-table/src/index.jsx +4196 -0
  200. package/packages/ve-table/src/selection/constant.js +5 -0
  201. package/packages/ve-table/src/selection/index.jsx +1643 -0
  202. package/packages/ve-table/src/util/clipboard.js +428 -0
  203. package/packages/ve-table/src/util/constant.js +269 -0
  204. package/packages/ve-table/src/util/index.js +1585 -0
  205. package/packages/ve-table/src/util/store.js +14 -0
@@ -0,0 +1,383 @@
1
+ import BodyTd from "./body-td";
2
+ import { clsName } from "../util";
3
+ import { COMPS_NAME, EMIT_EVENTS, COMPS_CUSTOM_ATTRS } from "../util/constant";
4
+ import VueDomResizeObserver from "../../../src/comps/resize-observer";
5
+ import emitter from "../../../src/mixins/emitter";
6
+ import { isEmptyValue } from "../../../src/utils";
7
+ export default {
8
+ name: COMPS_NAME.VE_TABLE_BODY_TR,
9
+ mixins: [emitter],
10
+ props: {
11
+ rowData: {
12
+ type: Object,
13
+ required: true,
14
+ },
15
+ rowIndex: {
16
+ type: Number,
17
+ required: true,
18
+ },
19
+ colgroups: {
20
+ type: Array,
21
+ required: true,
22
+ },
23
+ columnCollection: {
24
+ type: Array,
25
+ required: true,
26
+ },
27
+ rowKeyFieldName: {
28
+ type: String,
29
+ default: null,
30
+ },
31
+ allRowKeys: {
32
+ type: Array,
33
+ required: true,
34
+ },
35
+ /*
36
+ expand
37
+ */
38
+ // expand row option
39
+ expandOption: {
40
+ type: Object,
41
+ default: function () {
42
+ return null;
43
+ },
44
+ },
45
+ // is expand row
46
+ isExpandRow: {
47
+ type: Boolean,
48
+ required: true,
49
+ },
50
+ // expanded row keys
51
+ expandedRowkeys: {
52
+ type: Array,
53
+ default: function () {
54
+ return [];
55
+ },
56
+ },
57
+ // expand row change
58
+ expandRowChange: {
59
+ type: Function,
60
+ default: null,
61
+ },
62
+
63
+ /*
64
+ checkbox
65
+ */
66
+ // checkbox option
67
+ checkboxOption: {
68
+ type: Object,
69
+ default: function () {
70
+ return null;
71
+ },
72
+ },
73
+ internalCheckboxSelectedRowKeys: {
74
+ type: Array,
75
+ default: function () {
76
+ return null;
77
+ },
78
+ },
79
+
80
+ /*
81
+ radio
82
+ */
83
+ radioOption: {
84
+ type: Object,
85
+ default: function () {
86
+ return null;
87
+ },
88
+ },
89
+ internalRadioSelectedRowKey: {
90
+ type: [String, Number],
91
+ default: null,
92
+ },
93
+ // is virtual scroll
94
+ isVirtualScroll: {
95
+ type: Boolean,
96
+ default: false,
97
+ },
98
+ // cell style option
99
+ cellStyleOption: {
100
+ type: Object,
101
+ default: function () {
102
+ return null;
103
+ },
104
+ },
105
+ // highlight row key
106
+ highlightRowKey: {
107
+ type: [String, Number],
108
+ default: null,
109
+ },
110
+ // event custom option
111
+ eventCustomOption: {
112
+ type: Object,
113
+ default: function () {
114
+ return null;
115
+ },
116
+ },
117
+ // cell selection data
118
+ cellSelectionData: {
119
+ type: Object,
120
+ default: function () {
121
+ return null;
122
+ },
123
+ },
124
+ // cell selection range data
125
+ cellSelectionRangeData: {
126
+ type: Object,
127
+ default: function () {
128
+ return null;
129
+ },
130
+ },
131
+ bodyIndicatorRowKeys: {
132
+ type: Object,
133
+ default: function () {
134
+ return null;
135
+ },
136
+ },
137
+ // cell span option
138
+ cellSpanOption: {
139
+ type: Object,
140
+ default: function () {
141
+ return null;
142
+ },
143
+ },
144
+ // edit opttion
145
+ editOption: {
146
+ type: Object,
147
+ default: function () {
148
+ return null;
149
+ },
150
+ },
151
+ },
152
+ computed: {
153
+ // current row key
154
+ currentRowKey() {
155
+ const { rowKeyFieldName } = this;
156
+ return rowKeyFieldName ? this.rowData[rowKeyFieldName] : null;
157
+ },
158
+ // tr class
159
+ trClass() {
160
+ let result = null;
161
+
162
+ const { highlightRowKey, currentRowKey } = this;
163
+
164
+ let isHighlight = false;
165
+
166
+ if (!isEmptyValue(highlightRowKey)) {
167
+ if (highlightRowKey === currentRowKey) {
168
+ isHighlight = true;
169
+ }
170
+ }
171
+
172
+ result = {
173
+ [clsName("body-tr")]: true,
174
+ [clsName("tr-highlight")]: isHighlight,
175
+ };
176
+
177
+ return result;
178
+ },
179
+ },
180
+
181
+ methods: {
182
+ // click
183
+ rowClick(e, fn) {
184
+ fn && fn(e);
185
+
186
+ const { rowData, rowIndex } = this;
187
+
188
+ this.dispatch(
189
+ COMPS_NAME.VE_TABLE_BODY,
190
+ EMIT_EVENTS.BODY_ROW_CLICK,
191
+ {
192
+ rowData,
193
+ rowIndex,
194
+ },
195
+ );
196
+ },
197
+ // dblclick
198
+ rowDblclick(e, fn) {
199
+ fn && fn(e);
200
+ },
201
+ // contextmenu
202
+ rowContextmenu(e, fn) {
203
+ fn && fn(e);
204
+ },
205
+ // mouseenter
206
+ rowMouseenter(e, fn) {
207
+ fn && fn(e);
208
+ },
209
+ // mouseleave
210
+ rowMouseleave(e, fn) {
211
+ fn && fn(e);
212
+ },
213
+ // mousemove
214
+ rowMousemove(e, fn) {
215
+ fn && fn(e);
216
+ },
217
+ // mouseover
218
+ rowMouseover(e, fn) {
219
+ fn && fn(e);
220
+ },
221
+ // mousedown
222
+ rowMousedown(e, fn) {
223
+ fn && fn(e);
224
+ },
225
+ // mouseup
226
+ rowMouseup(e, fn) {
227
+ fn && fn(e);
228
+ },
229
+ },
230
+
231
+ render() {
232
+ const {
233
+ colgroups,
234
+ expandOption,
235
+ expandRowChange,
236
+ isExpandRow,
237
+ expandedRowkeys,
238
+ checkboxOption,
239
+ rowKeyFieldName,
240
+ rowIndex,
241
+ rowData,
242
+ internalCheckboxSelectedRowKeys,
243
+ internalRadioSelectedRowKey,
244
+ radioOption,
245
+ cellStyleOption,
246
+ eventCustomOption,
247
+ } = this;
248
+
249
+ // get td content
250
+ const getTdContent = () => {
251
+ return colgroups.map((column) => {
252
+ const tdProps = {
253
+ key: column.key,
254
+ props: {
255
+ rowIndex,
256
+ rowData,
257
+ column,
258
+ columnCollection: this.columnCollection,
259
+ colgroups,
260
+ expandOption,
261
+ expandedRowkeys,
262
+ checkboxOption,
263
+ rowKeyFieldName,
264
+ allRowKeys: this.allRowKeys,
265
+ isExpandRow,
266
+ internalCheckboxSelectedRowKeys,
267
+ internalRadioSelectedRowKey,
268
+ radioOption,
269
+ cellStyleOption,
270
+ cellSpanOption: this.cellSpanOption,
271
+ eventCustomOption,
272
+ cellSelectionData: this.cellSelectionData,
273
+ cellSelectionRangeData: this.cellSelectionRangeData,
274
+ bodyIndicatorRowKeys: this.bodyIndicatorRowKeys,
275
+ editOption: this.editOption,
276
+ },
277
+ on: {
278
+ [EMIT_EVENTS.EXPAND_ROW_CHANGE]: () =>
279
+ expandRowChange(rowData, rowIndex),
280
+ },
281
+ };
282
+ return <BodyTd {...tdProps} />;
283
+ });
284
+ };
285
+
286
+ let result = null;
287
+
288
+ // custom on row event
289
+ let customEvents = {};
290
+ if (eventCustomOption) {
291
+ const { bodyRowEvents } = eventCustomOption;
292
+ customEvents = bodyRowEvents
293
+ ? bodyRowEvents({ row: rowData, rowIndex })
294
+ : {};
295
+ }
296
+
297
+ const {
298
+ click,
299
+ dblclick,
300
+ contextmenu,
301
+ mouseenter,
302
+ mouseleave,
303
+ mousemove,
304
+ mouseover,
305
+ mousedown,
306
+ mouseup,
307
+ } = customEvents;
308
+
309
+ const events = {
310
+ click: (e) => {
311
+ this.rowClick(e, click);
312
+ },
313
+ dblclick: (e) => {
314
+ this.rowDblclick(e, dblclick);
315
+ },
316
+ contextmenu: (e) => {
317
+ this.rowContextmenu(e, contextmenu);
318
+ },
319
+ mouseenter: (e) => {
320
+ this.rowMouseenter(e, mouseenter);
321
+ },
322
+ mouseleave: (e) => {
323
+ this.rowMouseleave(e, mouseleave);
324
+ },
325
+ mousemove: (e) => {
326
+ this.rowMousemove(e, mousemove);
327
+ },
328
+ mouseover: (e) => {
329
+ this.rowMouseover(e, mouseover);
330
+ },
331
+ mousedown: (e) => {
332
+ this.rowMousedown(e, mousedown);
333
+ },
334
+ mouseup: (e) => {
335
+ this.rowMouseup(e, mouseup);
336
+ },
337
+ };
338
+
339
+ if (this.isVirtualScroll) {
340
+ const props = {
341
+ class: this.trClass,
342
+ props: {
343
+ tagName: "tr",
344
+ id: this.currentRowKey,
345
+ },
346
+ attrs: {
347
+ [COMPS_CUSTOM_ATTRS.BODY_ROW_KEY]: this.currentRowKey,
348
+ },
349
+ on: {
350
+ "on-dom-resize-change": ({ key, height }) => {
351
+ this.dispatch(
352
+ COMPS_NAME.VE_TABLE,
353
+ EMIT_EVENTS.BODY_ROW_HEIGHT_CHANGE,
354
+ {
355
+ rowKey: key,
356
+ height,
357
+ },
358
+ );
359
+ },
360
+ },
361
+ nativeOn: events,
362
+ };
363
+
364
+ result = (
365
+ <VueDomResizeObserver {...props}>
366
+ {getTdContent()}
367
+ </VueDomResizeObserver>
368
+ );
369
+ } else {
370
+ const props = {
371
+ class: this.trClass,
372
+ attrs: {
373
+ [COMPS_CUSTOM_ATTRS.BODY_ROW_KEY]: this.currentRowKey,
374
+ },
375
+ on: events,
376
+ };
377
+
378
+ result = <tr {...props}>{getTdContent()}</tr>;
379
+ }
380
+
381
+ return result;
382
+ },
383
+ };
@@ -0,0 +1,80 @@
1
+ import { clsName } from "../util";
2
+ import { COMPS_NAME, COLUMN_TYPES } from "../util/constant";
3
+ import VeIcon from "vue-easytable/packages/ve-icon";
4
+ import { ICON_NAMES } from "../../../src/utils/constant";
5
+
6
+ export default {
7
+ name: COMPS_NAME.VE_TABLE_EXPAND_TR_ICON,
8
+ props: {
9
+ column: {
10
+ type: Object,
11
+ required: true,
12
+ },
13
+ // expand row option
14
+ expandOption: {
15
+ type: Object,
16
+ default: function () {
17
+ return null;
18
+ },
19
+ },
20
+ rowData: {
21
+ type: Object,
22
+ required: true,
23
+ },
24
+ // expanded row keys
25
+ expandedRowkeys: {
26
+ type: Array,
27
+ default: function () {
28
+ return [];
29
+ },
30
+ },
31
+ rowKeyFieldName: {
32
+ type: String,
33
+ default: null,
34
+ },
35
+ // row expand click event
36
+ cellClick: {
37
+ type: Function,
38
+ default: null,
39
+ },
40
+ },
41
+ computed: {
42
+ // is row expanded
43
+ isExpanded() {
44
+ let result = false;
45
+
46
+ const { column, rowData, expandedRowkeys, rowKeyFieldName } = this;
47
+
48
+ if (column.type === COLUMN_TYPES.EXPAND) {
49
+ const rowKey = rowData[rowKeyFieldName];
50
+ result = expandedRowkeys.includes(rowKey);
51
+ }
52
+
53
+ return result;
54
+ },
55
+ // expand row icon class
56
+ expandRowIconContainerClass() {
57
+ return {
58
+ [clsName("row-expand-icon")]: true,
59
+ [clsName("expand-icon-collapsed")]: this.isExpanded,
60
+ };
61
+ },
62
+ },
63
+ render() {
64
+ let content = null;
65
+
66
+ const { cellClick, column, expandRowIconContainerClass } = this;
67
+
68
+ if (column.type === COLUMN_TYPES.EXPAND) {
69
+ content = (
70
+ <span
71
+ onClick={(e) => cellClick(e)}
72
+ class={expandRowIconContainerClass}
73
+ >
74
+ <VeIcon name={ICON_NAMES.RIGHT_ARROW} />
75
+ </span>
76
+ );
77
+ }
78
+ return content;
79
+ },
80
+ };
@@ -0,0 +1,147 @@
1
+ import { clsName } from "../util";
2
+ import { COMPS_NAME } from "../util/constant";
3
+ import emitter from "../../../src/mixins/emitter";
4
+
5
+ export default {
6
+ name: COMPS_NAME.VE_TABLE_EXPAND_TR,
7
+ mixins: [emitter],
8
+ props: {
9
+ tableViewportWidth: {
10
+ type: Number,
11
+ default: 0,
12
+ },
13
+ // expand column
14
+ expandColumn: {
15
+ type: Object,
16
+ default: function () {
17
+ return null;
18
+ },
19
+ },
20
+ colgroups: {
21
+ type: Array,
22
+ required: true,
23
+ },
24
+ // expand row option
25
+ expandOption: {
26
+ type: Object,
27
+ default: function () {
28
+ return null;
29
+ },
30
+ },
31
+ // expanded row keys
32
+ expandedRowkeys: {
33
+ type: Array,
34
+ default: function () {
35
+ return [];
36
+ },
37
+ },
38
+ rowData: {
39
+ type: Object,
40
+ required: true,
41
+ },
42
+ rowIndex: {
43
+ type: Number,
44
+ required: true,
45
+ },
46
+ rowKeyFieldName: {
47
+ type: String,
48
+ default: null,
49
+ },
50
+ },
51
+ computed: {
52
+ // get column count
53
+ columnCount() {
54
+ return this.colgroups.length;
55
+ },
56
+ // current row key
57
+ currentRowKey() {
58
+ return this.rowData[this.rowKeyFieldName];
59
+ },
60
+ // is row expanded
61
+ isRowExpanded() {
62
+ let result = false;
63
+
64
+ const { expandOption, expandedRowkeys, currentRowKey } = this;
65
+
66
+ // defalut expand all rows
67
+ if (expandOption.defaultExpandAllRows) {
68
+ result = true;
69
+ }
70
+ // defaultExpandedRowKeys includes currentRowKey
71
+ else if (expandedRowkeys.includes(currentRowKey)) {
72
+ result = true;
73
+ }
74
+
75
+ return result;
76
+ },
77
+ // expand row class
78
+ expanRowClass() {
79
+ let result = {
80
+ [clsName("expand-tr")]: true,
81
+ };
82
+ return result;
83
+ },
84
+
85
+ // has left fixed column
86
+ hasLeftFixedColumn() {
87
+ return this.colgroups.some((x) => x.fixed === "left");
88
+ },
89
+
90
+ // expand td content style
91
+ expandTdContentStyle() {
92
+ let result = {};
93
+
94
+ const { hasLeftFixedColumn, tableViewportWidth } = this;
95
+
96
+ if (hasLeftFixedColumn) {
97
+ // table width
98
+ if (tableViewportWidth) {
99
+ result["width"] = tableViewportWidth + "px";
100
+ }
101
+ }
102
+
103
+ return result;
104
+ },
105
+ },
106
+ methods: {
107
+ // get expande row content
108
+ getExpandRowContent(h) {
109
+ const { expandOption } = this;
110
+ let result =
111
+ expandOption.render &&
112
+ expandOption.render(
113
+ {
114
+ row: this.rowData,
115
+ column: this.expandColumn,
116
+ rowIndex: this.rowIndex,
117
+ },
118
+ h,
119
+ );
120
+
121
+ return result;
122
+ },
123
+ },
124
+ render(h) {
125
+ const { isRowExpanded, columnCount, getExpandRowContent } = this;
126
+
127
+ let result = null;
128
+
129
+ if (isRowExpanded) {
130
+ let content = getExpandRowContent(h);
131
+ result = (
132
+ <tr class={this.expanRowClass}>
133
+ <td class={clsName("expand-td")} colSpan={columnCount}>
134
+ <div
135
+ class={clsName("expand-td-content")}
136
+ style={this.expandTdContentStyle}
137
+ >
138
+ {content}
139
+ </div>
140
+ </td>
141
+ </tr>
142
+ );
143
+ }
144
+
145
+ return result;
146
+ },
147
+ };