@visactor/vue-vtable 1.10.3 → 1.10.4-alpha.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.
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/tables/base-table.vue.js +14 -9
- package/cjs/tables/list-table.vue.js +6 -46
- package/cjs/tables/pivot-chart.vue.js +7 -42
- package/cjs/tables/pivot-table.vue.js +7 -37
- package/cjs/tables/utils.d.ts +18 -0
- package/cjs/utils/customLayoutUtils.d.ts +5 -0
- package/cjs/{tables/utils.js → utils/customLayoutUtils.js} +17 -21
- package/cjs/utils/slotUtils.d.ts +18 -0
- package/cjs/utils/slotUtils.js +80 -0
- package/cjs/utils/stringUtils.d.ts +2 -0
- package/cjs/utils/stringUtils.js +18 -0
- package/cjs/utils/vnodeUtils.d.ts +1 -0
- package/cjs/utils/vnodeUtils.js +7 -0
- package/cjs/utils.d.ts +4 -0
- package/dist/vue-vtable.js +123 -143
- package/dist/vue-vtable.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/tables/base-table.vue.js +14 -9
- package/es/tables/list-table.vue.js +5 -45
- package/es/tables/pivot-chart.vue.js +6 -41
- package/es/tables/pivot-table.vue.js +6 -36
- package/es/tables/utils.d.ts +18 -0
- package/es/utils/customLayoutUtils.d.ts +5 -0
- package/es/{tables/utils.js → utils/customLayoutUtils.js} +15 -17
- package/es/utils/slotUtils.d.ts +18 -0
- package/es/utils/slotUtils.js +77 -0
- package/es/utils/stringUtils.d.ts +2 -0
- package/es/utils/stringUtils.js +15 -0
- package/es/utils/vnodeUtils.d.ts +1 -0
- package/es/utils/vnodeUtils.js +5 -0
- package/es/utils.d.ts +4 -0
- package/package.json +5 -5
package/dist/vue-vtable.js
CHANGED
|
@@ -23,9 +23,6 @@
|
|
|
23
23
|
|
|
24
24
|
var VTable__namespace = /*#__PURE__*/_interopNamespaceDefault(VTable);
|
|
25
25
|
|
|
26
|
-
function flattenVNodes(vnodes) {
|
|
27
|
-
return vnodes.flatMap(vnode => (Array.isArray(vnode.children) ? flattenVNodes(vnode.children) : vnode));
|
|
28
|
-
}
|
|
29
26
|
function toCamelCase(str) {
|
|
30
27
|
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
31
28
|
}
|
|
@@ -38,7 +35,12 @@
|
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
return newProps;
|
|
41
|
-
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function flattenVNodes(vnodes) {
|
|
41
|
+
return vnodes.flatMap(vnode => (Array.isArray(vnode.children) ? flattenVNodes(vnode.children) : vnode));
|
|
42
|
+
}
|
|
43
|
+
|
|
42
44
|
function isEventProp(key, props) {
|
|
43
45
|
return key.startsWith('on') && vutils.isFunction(props[key]);
|
|
44
46
|
}
|
|
@@ -99,6 +101,90 @@
|
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
103
|
return { rootComponent: createComponent(children) };
|
|
104
|
+
}
|
|
105
|
+
function createCustomLayoutHandler(children) {
|
|
106
|
+
return (args) => {
|
|
107
|
+
const { table, row, col, rect } = args;
|
|
108
|
+
const record = table.getCellOriginRecord(col, row);
|
|
109
|
+
const { height, width } = rect ?? table.getCellRect(col, row);
|
|
110
|
+
const rootContainer = children.customLayout({ table, row, col, rect, record, height, width })[0];
|
|
111
|
+
const { rootComponent } = createCustomLayout(rootContainer);
|
|
112
|
+
return {
|
|
113
|
+
rootContainer: rootComponent,
|
|
114
|
+
renderDefault: false
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function extractPivotSlotOptions(vnodes) {
|
|
120
|
+
const options = {
|
|
121
|
+
columns: [],
|
|
122
|
+
columnHeaderTitle: [],
|
|
123
|
+
rows: [],
|
|
124
|
+
rowHeaderTitle: [],
|
|
125
|
+
indicators: [],
|
|
126
|
+
corner: {},
|
|
127
|
+
tooltip: {},
|
|
128
|
+
menu: {}
|
|
129
|
+
};
|
|
130
|
+
const typeMapping = {
|
|
131
|
+
PivotColumnDimension: 'columns',
|
|
132
|
+
PivotColumnHeaderTitle: 'columnHeaderTitle',
|
|
133
|
+
PivotRowDimension: 'rows',
|
|
134
|
+
PivotRowHeaderTitle: 'rowHeaderTitle',
|
|
135
|
+
PivotCorner: 'corner',
|
|
136
|
+
PivotIndicator: 'indicators',
|
|
137
|
+
Tooltip: 'tooltip',
|
|
138
|
+
Menu: 'menu'
|
|
139
|
+
};
|
|
140
|
+
vnodes.forEach(vnode => {
|
|
141
|
+
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
142
|
+
const typeName = vnode.type?.symbol || vnode.type?.name;
|
|
143
|
+
const optionKey = typeMapping[typeName];
|
|
144
|
+
if (optionKey) {
|
|
145
|
+
if (Array.isArray(options[optionKey])) {
|
|
146
|
+
if (vnode.props.hasOwnProperty('objectHandler')) {
|
|
147
|
+
options[optionKey].push(vnode.props.objectHandler);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
options[optionKey].push(vnode.props);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
options[optionKey] = vnode.props;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return options;
|
|
159
|
+
}
|
|
160
|
+
function extractListSlotOptions(vnodes) {
|
|
161
|
+
const options = {
|
|
162
|
+
columns: [],
|
|
163
|
+
tooltip: {},
|
|
164
|
+
menu: {}
|
|
165
|
+
};
|
|
166
|
+
const typeMapping = {
|
|
167
|
+
ListColumn: 'columns',
|
|
168
|
+
Tooltip: 'tooltip',
|
|
169
|
+
Menu: 'menu'
|
|
170
|
+
};
|
|
171
|
+
vnodes.forEach(vnode => {
|
|
172
|
+
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
173
|
+
const typeName = vnode.type?.symbol || vnode.type?.name;
|
|
174
|
+
const optionKey = typeMapping[typeName];
|
|
175
|
+
if (optionKey) {
|
|
176
|
+
if (optionKey === 'columns' && vnode.children) {
|
|
177
|
+
vnode.props.customLayout = createCustomLayoutHandler(vnode.children);
|
|
178
|
+
}
|
|
179
|
+
if (Array.isArray(options[optionKey])) {
|
|
180
|
+
options[optionKey].push(vnode.props);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
options[optionKey] = vnode.props;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return options;
|
|
102
188
|
}
|
|
103
189
|
|
|
104
190
|
const EVENT_TYPE = {
|
|
@@ -232,17 +318,20 @@
|
|
|
232
318
|
instance.on(TABLE_EVENTS[eventKey], vueEventHandler);
|
|
233
319
|
});
|
|
234
320
|
};
|
|
321
|
+
const createTableInstance = (Type, options) => {
|
|
322
|
+
vTableInstance.value = new Type(vTableContainer.value, options);
|
|
323
|
+
};
|
|
235
324
|
const createVTable = () => {
|
|
236
|
-
if (!vTableContainer.value)
|
|
325
|
+
if (!vTableContainer.value) {
|
|
237
326
|
return;
|
|
327
|
+
}
|
|
238
328
|
if (vTableInstance.value) {
|
|
239
329
|
vTableInstance.value.release();
|
|
240
330
|
}
|
|
241
331
|
const getRecords = () => {
|
|
242
|
-
return props.records !== undefined && props.records !== null && props.records.length > 0
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
vTableInstance.value = new Type(vTableContainer.value, options);
|
|
332
|
+
return props.records !== undefined && props.records !== null && props.records.length > 0
|
|
333
|
+
? props.records
|
|
334
|
+
: props.options.records;
|
|
246
335
|
};
|
|
247
336
|
try {
|
|
248
337
|
switch (props.type) {
|
|
@@ -269,11 +358,13 @@
|
|
|
269
358
|
props.onReady?.(vTableInstance.value, true);
|
|
270
359
|
}
|
|
271
360
|
catch (err) {
|
|
361
|
+
props.onError?.(err);
|
|
272
362
|
}
|
|
273
363
|
};
|
|
274
364
|
const updateVTable = (newOptions) => {
|
|
275
|
-
if (!vTableInstance.value)
|
|
365
|
+
if (!vTableInstance.value) {
|
|
276
366
|
return;
|
|
367
|
+
}
|
|
277
368
|
try {
|
|
278
369
|
switch (props.type) {
|
|
279
370
|
case 'list':
|
|
@@ -299,14 +390,14 @@
|
|
|
299
390
|
};
|
|
300
391
|
vue.onMounted(createVTable);
|
|
301
392
|
vue.onBeforeUnmount(() => vTableInstance.value?.release());
|
|
302
|
-
vue.watch(() => props.options,
|
|
393
|
+
vue.watch(() => props.options, newOptions => {
|
|
303
394
|
if (vTableInstance.value) {
|
|
304
395
|
updateVTable(newOptions);
|
|
305
396
|
}
|
|
306
397
|
else {
|
|
307
398
|
createVTable();
|
|
308
399
|
}
|
|
309
|
-
}
|
|
400
|
+
});
|
|
310
401
|
vue.watch(() => props.records, (newRecords, oldRecords) => {
|
|
311
402
|
if (vTableInstance.value) {
|
|
312
403
|
updateVTable({ ...props.options, records: newRecords });
|
|
@@ -339,7 +430,7 @@
|
|
|
339
430
|
const slots = vue.useSlots();
|
|
340
431
|
const computedOptions = vue.computed(() => {
|
|
341
432
|
const flattenedSlots = flattenVNodes(slots.default?.() || []);
|
|
342
|
-
const slotOptions =
|
|
433
|
+
const slotOptions = extractListSlotOptions(flattenedSlots);
|
|
343
434
|
return {
|
|
344
435
|
...props.options,
|
|
345
436
|
columns: slotOptions.columns.length ? slotOptions.columns : props.options.columns,
|
|
@@ -347,48 +438,6 @@
|
|
|
347
438
|
menu: slotOptions.menu || props.options.menu,
|
|
348
439
|
};
|
|
349
440
|
});
|
|
350
|
-
function extractSlotOptions(vnodes) {
|
|
351
|
-
const options = {
|
|
352
|
-
columns: [],
|
|
353
|
-
tooltip: {},
|
|
354
|
-
menu: {},
|
|
355
|
-
};
|
|
356
|
-
const typeMapping = {
|
|
357
|
-
ListColumn: 'columns',
|
|
358
|
-
Tooltip: 'tooltip',
|
|
359
|
-
Menu: 'menu',
|
|
360
|
-
};
|
|
361
|
-
vnodes.forEach(vnode => {
|
|
362
|
-
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
363
|
-
const typeName = vnode.type?.symbol || vnode.type?.name;
|
|
364
|
-
const optionKey = typeMapping[typeName];
|
|
365
|
-
if (optionKey) {
|
|
366
|
-
if (optionKey === 'columns' && vnode.children) {
|
|
367
|
-
vnode.props.customLayout = createCustomLayoutHandler(vnode.children);
|
|
368
|
-
}
|
|
369
|
-
if (Array.isArray(options[optionKey])) {
|
|
370
|
-
options[optionKey].push(vnode.props);
|
|
371
|
-
}
|
|
372
|
-
else {
|
|
373
|
-
options[optionKey] = vnode.props;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
return options;
|
|
378
|
-
}
|
|
379
|
-
function createCustomLayoutHandler(children) {
|
|
380
|
-
return (args) => {
|
|
381
|
-
const { table, row, col, rect } = args;
|
|
382
|
-
const record = table.getCellOriginRecord(col, row);
|
|
383
|
-
const { height, width } = rect ?? table.getCellRect(col, row);
|
|
384
|
-
const rootContainer = children.customLayout({ table, row, col, rect, record, height, width })[0];
|
|
385
|
-
const { rootComponent } = createCustomLayout(rootContainer);
|
|
386
|
-
return {
|
|
387
|
-
rootContainer: rootComponent,
|
|
388
|
-
renderDefault: false,
|
|
389
|
-
};
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
441
|
__expose({
|
|
393
442
|
vTableInstance: vue.computed(() => baseTableRef.value?.vTableInstance || null),
|
|
394
443
|
});
|
|
@@ -423,49 +472,17 @@
|
|
|
423
472
|
const slots = vue.useSlots();
|
|
424
473
|
const computedOptions = vue.computed(() => {
|
|
425
474
|
const flattenedSlots = flattenVNodes(slots.default?.() || []);
|
|
426
|
-
const
|
|
427
|
-
columns: [],
|
|
428
|
-
columnHeaderTitle: [],
|
|
429
|
-
rows: [],
|
|
430
|
-
rowHeaderTitle: [],
|
|
431
|
-
indicators: [],
|
|
432
|
-
corner: Object,
|
|
433
|
-
tooltip: Object,
|
|
434
|
-
menu: Object,
|
|
435
|
-
};
|
|
436
|
-
const typeMapping = {
|
|
437
|
-
'PivotColumnDimension': 'columns',
|
|
438
|
-
'PivotColumnHeaderTitle': 'columnHeaderTitle',
|
|
439
|
-
'PivotRowDimension': 'rows',
|
|
440
|
-
'PivotRowHeaderTitle': 'rowHeaderTitle',
|
|
441
|
-
'PivotCorner': 'corner',
|
|
442
|
-
'PivotIndicator': 'indicators',
|
|
443
|
-
'Tooltip': 'tooltip',
|
|
444
|
-
'Menu': 'menu',
|
|
445
|
-
};
|
|
446
|
-
flattenedSlots.forEach(vnode => {
|
|
447
|
-
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
448
|
-
const typeName = vnode.type?.symbol || vnode.type?.name;
|
|
449
|
-
const optionKey = typeMapping[typeName];
|
|
450
|
-
if (optionKey) {
|
|
451
|
-
if (Array.isArray(options[optionKey])) {
|
|
452
|
-
options[optionKey].push(vnode.props);
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
options[optionKey] = vnode.props;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
});
|
|
475
|
+
const slotOptions = extractPivotSlotOptions(flattenedSlots);
|
|
459
476
|
return {
|
|
460
477
|
...props.options,
|
|
461
|
-
columns:
|
|
462
|
-
columnHeaderTitle:
|
|
463
|
-
rows:
|
|
464
|
-
rowHeaderTitle:
|
|
465
|
-
indicators:
|
|
466
|
-
corner: props.options.corner ||
|
|
467
|
-
tooltip: props.options.tooltip ||
|
|
468
|
-
menu: props.options.menu ||
|
|
478
|
+
columns: slotOptions.columns.length ? slotOptions.columns : props.options.columns,
|
|
479
|
+
columnHeaderTitle: slotOptions.columnHeaderTitle.length ? slotOptions.columnHeaderTitle : props.options.columnHeaderTitle,
|
|
480
|
+
rows: slotOptions.rows.length ? slotOptions.rows : props.options.rows,
|
|
481
|
+
rowHeaderTitle: slotOptions.rowHeaderTitle.length ? slotOptions.rowHeaderTitle : props.options.rowHeaderTitle,
|
|
482
|
+
indicators: slotOptions.indicators.length ? slotOptions.indicators : props.options.indicators,
|
|
483
|
+
corner: props.options.corner || slotOptions.corner,
|
|
484
|
+
tooltip: props.options.tooltip || slotOptions.tooltip,
|
|
485
|
+
menu: props.options.menu || slotOptions.menu,
|
|
469
486
|
};
|
|
470
487
|
});
|
|
471
488
|
__expose({ vTableInstance: vue.computed(() => baseTableRef.value?.vTableInstance || null) });
|
|
@@ -500,54 +517,17 @@
|
|
|
500
517
|
const slots = vue.useSlots();
|
|
501
518
|
const computedOptions = vue.computed(() => {
|
|
502
519
|
const flattenedSlots = flattenVNodes(slots.default?.() || []);
|
|
503
|
-
const
|
|
504
|
-
columns: [],
|
|
505
|
-
columnHeaderTitle: [],
|
|
506
|
-
rows: [],
|
|
507
|
-
rowHeaderTitle: [],
|
|
508
|
-
indicators: [],
|
|
509
|
-
corner: Object,
|
|
510
|
-
tooltip: Object,
|
|
511
|
-
menu: Object,
|
|
512
|
-
};
|
|
513
|
-
const typeMapping = {
|
|
514
|
-
'PivotColumnDimension': 'columns',
|
|
515
|
-
'PivotColumnHeaderTitle': 'columnHeaderTitle',
|
|
516
|
-
'PivotRowDimension': 'rows',
|
|
517
|
-
'PivotRowHeaderTitle': 'rowHeaderTitle',
|
|
518
|
-
'PivotCorner': 'corner',
|
|
519
|
-
'PivotIndicator': 'indicators',
|
|
520
|
-
'Tooltip': 'tooltip',
|
|
521
|
-
'Menu': 'menu',
|
|
522
|
-
};
|
|
523
|
-
flattenedSlots.forEach(vnode => {
|
|
524
|
-
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
525
|
-
const typeName = vnode.type?.symbol || vnode.type?.name;
|
|
526
|
-
const optionKey = typeMapping[typeName];
|
|
527
|
-
if (optionKey) {
|
|
528
|
-
if (Array.isArray(options[optionKey])) {
|
|
529
|
-
if (vnode.props.hasOwnProperty('objectHandler')) {
|
|
530
|
-
options[optionKey].push(vnode.props.objectHandler);
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
options[optionKey].push(vnode.props);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
options[optionKey] = vnode.props;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
});
|
|
520
|
+
const slotOptions = extractPivotSlotOptions(flattenedSlots);
|
|
541
521
|
return {
|
|
542
522
|
...props.options,
|
|
543
|
-
columns:
|
|
544
|
-
columnHeaderTitle:
|
|
545
|
-
rows:
|
|
546
|
-
rowHeaderTitle:
|
|
547
|
-
indicators:
|
|
548
|
-
corner: options.corner ||
|
|
549
|
-
tooltip: options.tooltip ||
|
|
550
|
-
menu: options.menu ||
|
|
523
|
+
columns: slotOptions.columns.length ? slotOptions.columns : props.options.columns,
|
|
524
|
+
columnHeaderTitle: slotOptions.columnHeaderTitle.length ? slotOptions.columnHeaderTitle : props.options.columnHeaderTitle,
|
|
525
|
+
rows: slotOptions.rows.length ? slotOptions.rows : props.options.rows,
|
|
526
|
+
rowHeaderTitle: slotOptions.rowHeaderTitle.length ? slotOptions.rowHeaderTitle : props.options.rowHeaderTitle,
|
|
527
|
+
indicators: slotOptions.indicators.length ? slotOptions.indicators : props.options.indicators,
|
|
528
|
+
corner: props.options.corner || slotOptions.corner,
|
|
529
|
+
tooltip: props.options.tooltip || slotOptions.tooltip,
|
|
530
|
+
menu: props.options.menu || slotOptions.menu,
|
|
551
531
|
};
|
|
552
532
|
});
|
|
553
533
|
__expose({ vTableInstance: vue.computed(() => baseTableRef.value?.vTableInstance || null) });
|
|
@@ -647,7 +627,7 @@
|
|
|
647
627
|
}
|
|
648
628
|
CheckBox.symbol = 'CheckBox';
|
|
649
629
|
|
|
650
|
-
const version = "1.10.
|
|
630
|
+
const version = "1.10.4-alpha.2";
|
|
651
631
|
|
|
652
632
|
exports.VTable = VTable__namespace;
|
|
653
633
|
Object.defineProperty(exports, 'register', {
|
package/dist/vue-vtable.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@visactor/vtable"),require("vue"),require("@visactor/vutils")):"function"==typeof define&&define.amd?define(["exports","@visactor/vtable","vue","@visactor/vutils"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).VueVTable={},e.VTable,e.vue,e.vutils)}(this,(function(e,o,n,t){"use strict";function r(e){var o=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(o,n,t.get?t:{enumerable:!0,get:function(){return e[n]}})}})),o.default=e,Object.freeze(o)}var l=r(o);function i(e){return e.flatMap((e=>Array.isArray(e.children)?i(e.children):e))}function u(e){return e.replace(/-([a-z])/g,(e=>e[1].toUpperCase()))}function s(e){const o={};for(const n in e)if(e.hasOwnProperty(n)){o[u(n)]=e[n]}return o}function a(e){const o={Group:l.CustomLayout.Group,Image:l.CustomLayout.Image,Text:l.CustomLayout.Text,Tag:l.CustomLayout.Tag,Radio:l.CustomLayout.Radio,CheckBox:l.CustomLayout.CheckBox};return{rootComponent:function e(n){if(!n)return null;const{type:r,children:l}=n,i=s(n.props),a=o[r?.symbol||r?.name];if(!a)return null;const c=new a({...i});!function(e,o){Object.keys(o).forEach((n=>{if(function(e,o){return e.startsWith("on")&&t.isFunction(o[e])}(n,o)){let t;t=n.startsWith("on")?n.slice(2).toLowerCase():u(n.slice(2)).toLowerCase(),e.addEventListener(t,o[n])}}))}(c,i);return function(e){return e?.default?.()||e||[]}(l).forEach((o=>{const n=e(o);n?c.add(n):o.type===Symbol.for("v-fgt")&&o.children.forEach((o=>{const n=e(o);n&&c.add(n)}))})),c}(e)}}const c={...o.ListTable.EVENT_TYPE,...o.PivotTable.EVENT_TYPE,...o.PivotChart.EVENT_TYPE},d={onClickCell:c.CLICK_CELL,onDblClickCell:c.DBLCLICK_CELL,onMouseDownCell:c.MOUSEDOWN_CELL,onMouseUpCell:c.MOUSEUP_CELL,onSelectedCell:c.SELECTED_CELL,onKeyDown:c.KEYDOWN,onMouseEnterTable:c.MOUSEENTER_TABLE,onMouseLeaveTable:c.MOUSELEAVE_TABLE,onMouseDownTable:c.MOUSEDOWN_TABLE,onMouseMoveCell:c.MOUSEMOVE_CELL,onMouseEnterCell:c.MOUSEENTER_CELL,onMouseLeaveCell:c.MOUSELEAVE_CELL,onContextMenuCell:c.CONTEXTMENU_CELL,onResizeColumn:c.RESIZE_COLUMN,onResizeColumnEnd:c.RESIZE_COLUMN_END,onChangeHeaderPosition:c.CHANGE_HEADER_POSITION,onSortClick:c.SORT_CLICK,onFreezeClick:c.FREEZE_CLICK,onScroll:c.SCROLL,onDropdownMenuClick:c.DROPDOWN_MENU_CLICK,onMouseOverChartSymbol:c.MOUSEOVER_CHART_SYMBOL,onDragSelectEnd:c.DRAG_SELECT_END,onDropdownIconClick:c.DROPDOWN_ICON_CLICK,onDropdownMenuClear:c.DROPDOWN_MENU_CLEAR,onTreeHierarchyStateChange:c.TREE_HIERARCHY_STATE_CHANGE,onShowMenu:c.SHOW_MENU,onHideMenu:c.HIDE_MENU,onIconClick:c.ICON_CLICK,onLegendItemClick:c.LEGEND_ITEM_CLICK,onLegendItemHover:c.LEGEND_ITEM_HOVER,onLegendItemUnHover:c.LEGEND_ITEM_UNHOVER,onLegendChange:c.LEGEND_CHANGE,onMouseEnterAxis:c.MOUSEENTER_AXIS,onMouseLeaveAxis:c.MOUSELEAVE_AXIS,onCheckboxStateChange:c.CHECKBOX_STATE_CHANGE,onRadioStateChange:c.RADIO_STATE_CHANGE,onAfterRender:c.AFTER_RENDER,onInitialized:c.INITIALIZED,onPivotSortClick:c.PIVOT_SORT_CLICK,onDrillMenuClick:c.DRILLMENU_CLICK,onVChartEventType:c.VCHART_EVENT_TYPE,onChangCellValue:c.CHANGE_CELL_VALUE,onMousedownFillHandle:c.MOUSEDOWN_FILL_HANDLE,onDragFillHandleEnd:c.DRAG_FILL_HANDLE_END,onDblclickFillHandle:c.DBLCLICK_FILL_HANDLE,onScrollVerticalEnd:c.SCROLL_VERTICAL_END,onScrollHorizontalEnd:c.SCROLL_HORIZONTAL_END},p=Object.keys(d);var C=n.defineComponent({__name:"base-table",props:{type:{type:String,required:!1},options:{type:null,required:!1},records:{type:Array,required:!1},width:{type:[Number,String],required:!1,default:"100%"},height:{type:[Number,String],required:!1,default:"100%"},onReady:{type:Function,required:!1},onError:{type:Function,required:!1},onClickCell:{type:null,required:!1},onDblClickCell:{type:null,required:!1},onMouseDownCell:{type:null,required:!1},onMouseUpCell:{type:null,required:!1},onSelectedCell:{type:null,required:!1},onKeyDown:{type:null,required:!1},onMouseEnterTable:{type:null,required:!1},onMouseLeaveTable:{type:null,required:!1},onMouseDownTable:{type:null,required:!1},onMouseMoveCell:{type:null,required:!1},onMouseEnterCell:{type:null,required:!1},onMouseLeaveCell:{type:null,required:!1},onContextMenuCell:{type:null,required:!1},onResizeColumn:{type:null,required:!1},onResizeColumnEnd:{type:null,required:!1},onChangeHeaderPosition:{type:null,required:!1},onSortClick:{type:null,required:!1},onFreezeClick:{type:null,required:!1},onScroll:{type:null,required:!1},onDropdownMenuClick:{type:null,required:!1},onMouseOverChartSymbol:{type:null,required:!1},onDragSelectEnd:{type:null,required:!1},onDropdownIconClick:{type:null,required:!1},onDropdownMenuClear:{type:null,required:!1},onTreeHierarchyStateChange:{type:null,required:!1},onShowMenu:{type:null,required:!1},onHideMenu:{type:null,required:!1},onIconClick:{type:null,required:!1},onLegendItemClick:{type:null,required:!1},onLegendItemHover:{type:null,required:!1},onLegendItemUnHover:{type:null,required:!1},onLegendChange:{type:null,required:!1},onMouseEnterAxis:{type:null,required:!1},onMouseLeaveAxis:{type:null,required:!1},onCheckboxStateChange:{type:null,required:!1},onRadioStateChange:{type:null,required:!1},onAfterRender:{type:null,required:!1},onInitialized:{type:null,required:!1},onPivotSortClick:{type:null,required:!1},onDrillMenuClick:{type:null,required:!1},onVChartEventType:{type:null,required:!1},onChangCellValue:{type:null,required:!1},onMousedownFillHandle:{type:null,required:!1},onDragFillHandleEnd:{type:null,required:!1},onDblclickFillHandle:{type:null,required:!1},onScrollVerticalEnd:{type:null,required:!1},onScrollHorizontalEnd:{type:null,required:!1}},emits:p,setup(e,{expose:t,emit:r}){const l=e,i=n.ref(null),u=n.shallowRef(null);t({vTableInstance:u});const s=n.computed((()=>"number"==typeof l.width?`${l.width}px`:l.width)),a=n.computed((()=>"number"==typeof l.height?`${l.height}px`:l.height)),c=r,C=()=>{if(!i.value)return;u.value&&u.value.release();const e=()=>void 0!==l.records&&null!==l.records&&l.records.length>0?l.records:l.options.records,n=(e,o)=>{u.value=new e(i.value,o)};try{switch(l.type){case"list":n(o.ListTable,{...l.options,records:e()});break;case"pivot":n(o.PivotTable,{...l.options,records:e()});break;case"chart":n(o.PivotChart,{...l.options,records:e()})}t=u.value,p.forEach((e=>{t.on(d[e],(o=>{c(e,o)}))})),l.onReady?.(u.value,!0)}catch(e){}var t},m=e=>{if(u.value)try{switch(l.type){case"list":u.value instanceof o.ListTable&&u.value.updateOption(e);break;case"pivot":u.value instanceof o.PivotTable&&u.value.updateOption(e);break;case"chart":u.value instanceof o.PivotChart&&u.value.updateOption(e)}}catch(e){l.onError?.(e)}};return n.onMounted(C),n.onBeforeUnmount((()=>u.value?.release())),n.watch((()=>l.options),(e=>{u.value?m(e):C()}),{deep:!0}),n.watch((()=>l.records),((e,o)=>{u.value?m({...l.options,records:e}):C()}),{deep:!0}),(e,o)=>(n.openBlock(),n.createElementBlock("div",{ref_key:"vTableContainer",ref:i,style:n.normalizeStyle([{width:s.value,height:a.value},{position:"relative"}])},null,4))}}),m=n.defineComponent({__name:"list-table",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:o}){const t=e,r=n.ref(null),l=n.useSlots(),u=n.computed((()=>{const e=function(e){const o={columns:[],tooltip:{},menu:{}},n={ListColumn:"columns",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=s(e.props);const t=e.type?.symbol||e.type?.name,r=n[t];var l;r&&("columns"===r&&e.children&&(e.props.customLayout=(l=e.children,e=>{const{table:o,row:n,col:t,rect:r}=e,i=o.getCellOriginRecord(t,n),{height:u,width:s}=r??o.getCellRect(t,n),c=l.customLayout({table:o,row:n,col:t,rect:r,record:i,height:u,width:s})[0],{rootComponent:d}=a(c);return{rootContainer:d,renderDefault:!1}})),Array.isArray(o[r])?o[r].push(e.props):o[r]=e.props)})),o}(i(l.default?.()||[]));return{...t.options,columns:e.columns.length?e.columns:t.options.columns,tooltip:e.tooltip||t.options.tooltip,menu:e.menu||t.options.menu}}));return o({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,o)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(C,n.mergeProps({type:"list",options:u.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}}),y=n.defineComponent({__name:"pivot-table",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:o}){const t=e,r=n.shallowRef(null),l=n.useSlots(),u=n.computed((()=>{const e=i(l.default?.()||[]),o={columns:[],columnHeaderTitle:[],rows:[],rowHeaderTitle:[],indicators:[],corner:Object,tooltip:Object,menu:Object},n={PivotColumnDimension:"columns",PivotColumnHeaderTitle:"columnHeaderTitle",PivotRowDimension:"rows",PivotRowHeaderTitle:"rowHeaderTitle",PivotCorner:"corner",PivotIndicator:"indicators",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=s(e.props);const t=e.type?.symbol||e.type?.name,r=n[t];r&&(Array.isArray(o[r])?o[r].push(e.props):o[r]=e.props)})),{...t.options,columns:o.columns.length?o.columns:t.options.columns,columnHeaderTitle:o.columnHeaderTitle.length?o.columnHeaderTitle:t.options.columnHeaderTitle,rows:o.rows.length?o.rows:t.options.rows,rowHeaderTitle:o.rowHeaderTitle.length?o.rowHeaderTitle:t.options.rowHeaderTitle,indicators:o.indicators.length?o.indicators:t.options.indicators,corner:t.options.corner||o.corner,tooltip:t.options.tooltip||o.tooltip,menu:t.options.menu||o.menu}}));return o({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,o)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(C,n.mergeProps({type:"pivot",options:u.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}}),E=n.defineComponent({__name:"pivot-chart",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:o}){const t=e,r=n.shallowRef(null),l=n.useSlots(),u=n.computed((()=>{const e=i(l.default?.()||[]),o={columns:[],columnHeaderTitle:[],rows:[],rowHeaderTitle:[],indicators:[],corner:Object,tooltip:Object,menu:Object},n={PivotColumnDimension:"columns",PivotColumnHeaderTitle:"columnHeaderTitle",PivotRowDimension:"rows",PivotRowHeaderTitle:"rowHeaderTitle",PivotCorner:"corner",PivotIndicator:"indicators",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=s(e.props);const t=e.type?.symbol||e.type?.name,r=n[t];r&&(Array.isArray(o[r])?e.props.hasOwnProperty("objectHandler")?o[r].push(e.props.objectHandler):o[r].push(e.props):o[r]=e.props)})),{...t.options,columns:o.columns.length?o.columns:t.options.columns,columnHeaderTitle:o.columnHeaderTitle.length?o.columnHeaderTitle:t.options.columnHeaderTitle,rows:o.rows.length?o.rows:t.options.rows,rowHeaderTitle:o.rowHeaderTitle.length?o.rowHeaderTitle:t.options.rowHeaderTitle,indicators:o.indicators.length?o.indicators:t.options.indicators,corner:o.corner||t.options.corner,tooltip:o.tooltip||t.options.tooltip,menu:o.menu||t.options.menu}}));return o({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,o)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(C,n.mergeProps({type:"chart",options:u.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}});function h(e){return null}function T(e){return null}function v(e){return null}function b(e){return null}function f(e){return null}function L(e){return null}function g(e){return null}function w(e){return null}function _(e){return null}function H(){return null}function M(){return null}function O(){return null}function S(e){return null}function q(e){return null}function D(e){return null}h.symbol="ListColumn",T.symbol="PivotColumnDimension",v.symbol="PivotRowDimension",b.symbol="PivotColumnHeaderTitle",f.symbol="PivotRowHeaderTitle",L.symbol="PivotIndicator",g.symbol="PivotCorner",w.symbol="Menu",_.symbol="Tooltip",H.symbol="Group",M.symbol="Image",O.symbol="Text",S.symbol="Tag",q.symbol="Radio",D.symbol="CheckBox";e.VTable=l,Object.defineProperty(e,"register",{enumerable:!0,get:function(){return o.register}}),e.CheckBox=D,e.Group=H,e.Image=M,e.ListColumn=h,e.ListTable=m,e.Menu=w,e.PivotChart=E,e.PivotColumnDimension=T,e.PivotColumnHeaderTitle=b,e.PivotCorner=g,e.PivotIndicator=L,e.PivotRowDimension=v,e.PivotRowHeaderTitle=f,e.PivotTable=y,e.Radio=q,e.Tag=S,e.Text=O,e.Tooltip=_,e.registerChartModule=(e,o)=>{l.register.chartModule(e,o)},e.version="1.10.3"}));
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@visactor/vtable"),require("vue"),require("@visactor/vutils")):"function"==typeof define&&define.amd?define(["exports","@visactor/vtable","vue","@visactor/vutils"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).VueVTable={},e.VTable,e.vue,e.vutils)}(this,(function(e,o,n,t){"use strict";function r(e){var o=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(o,n,t.get?t:{enumerable:!0,get:function(){return e[n]}})}})),o.default=e,Object.freeze(o)}var l=r(o);function i(e){return e.replace(/-([a-z])/g,(e=>e[1].toUpperCase()))}function u(e){const o={};for(const n in e)if(e.hasOwnProperty(n)){o[i(n)]=e[n]}return o}function s(e){return e.flatMap((e=>Array.isArray(e.children)?s(e.children):e))}function a(e){const o={Group:l.CustomLayout.Group,Image:l.CustomLayout.Image,Text:l.CustomLayout.Text,Tag:l.CustomLayout.Tag,Radio:l.CustomLayout.Radio,CheckBox:l.CustomLayout.CheckBox};return{rootComponent:function e(n){if(!n)return null;const{type:r,children:l}=n,s=u(n.props),a=o[r?.symbol||r?.name];if(!a)return null;const c=new a({...s});!function(e,o){Object.keys(o).forEach((n=>{if(function(e,o){return e.startsWith("on")&&t.isFunction(o[e])}(n,o)){let t;t=n.startsWith("on")?n.slice(2).toLowerCase():i(n.slice(2)).toLowerCase(),e.addEventListener(t,o[n])}}))}(c,s);return function(e){return e?.default?.()||e||[]}(l).forEach((o=>{const n=e(o);n?c.add(n):o.type===Symbol.for("v-fgt")&&o.children.forEach((o=>{const n=e(o);n&&c.add(n)}))})),c}(e)}}function c(e){const o={columns:[],columnHeaderTitle:[],rows:[],rowHeaderTitle:[],indicators:[],corner:{},tooltip:{},menu:{}},n={PivotColumnDimension:"columns",PivotColumnHeaderTitle:"columnHeaderTitle",PivotRowDimension:"rows",PivotRowHeaderTitle:"rowHeaderTitle",PivotCorner:"corner",PivotIndicator:"indicators",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=u(e.props);const t=e.type?.symbol||e.type?.name,r=n[t];r&&(Array.isArray(o[r])?e.props.hasOwnProperty("objectHandler")?o[r].push(e.props.objectHandler):o[r].push(e.props):o[r]=e.props)})),o}function d(e){const o={columns:[],tooltip:{},menu:{}},n={ListColumn:"columns",Tooltip:"tooltip",Menu:"menu"};return e.forEach((e=>{e.props=u(e.props);const t=e.type?.symbol||e.type?.name,r=n[t];var l;r&&("columns"===r&&e.children&&(e.props.customLayout=(l=e.children,e=>{const{table:o,row:n,col:t,rect:r}=e,i=o.getCellOriginRecord(t,n),{height:u,width:s}=r??o.getCellRect(t,n),c=l.customLayout({table:o,row:n,col:t,rect:r,record:i,height:u,width:s})[0],{rootComponent:d}=a(c);return{rootContainer:d,renderDefault:!1}})),Array.isArray(o[r])?o[r].push(e.props):o[r]=e.props)})),o}const p={...o.ListTable.EVENT_TYPE,...o.PivotTable.EVENT_TYPE,...o.PivotChart.EVENT_TYPE},C={onClickCell:p.CLICK_CELL,onDblClickCell:p.DBLCLICK_CELL,onMouseDownCell:p.MOUSEDOWN_CELL,onMouseUpCell:p.MOUSEUP_CELL,onSelectedCell:p.SELECTED_CELL,onKeyDown:p.KEYDOWN,onMouseEnterTable:p.MOUSEENTER_TABLE,onMouseLeaveTable:p.MOUSELEAVE_TABLE,onMouseDownTable:p.MOUSEDOWN_TABLE,onMouseMoveCell:p.MOUSEMOVE_CELL,onMouseEnterCell:p.MOUSEENTER_CELL,onMouseLeaveCell:p.MOUSELEAVE_CELL,onContextMenuCell:p.CONTEXTMENU_CELL,onResizeColumn:p.RESIZE_COLUMN,onResizeColumnEnd:p.RESIZE_COLUMN_END,onChangeHeaderPosition:p.CHANGE_HEADER_POSITION,onSortClick:p.SORT_CLICK,onFreezeClick:p.FREEZE_CLICK,onScroll:p.SCROLL,onDropdownMenuClick:p.DROPDOWN_MENU_CLICK,onMouseOverChartSymbol:p.MOUSEOVER_CHART_SYMBOL,onDragSelectEnd:p.DRAG_SELECT_END,onDropdownIconClick:p.DROPDOWN_ICON_CLICK,onDropdownMenuClear:p.DROPDOWN_MENU_CLEAR,onTreeHierarchyStateChange:p.TREE_HIERARCHY_STATE_CHANGE,onShowMenu:p.SHOW_MENU,onHideMenu:p.HIDE_MENU,onIconClick:p.ICON_CLICK,onLegendItemClick:p.LEGEND_ITEM_CLICK,onLegendItemHover:p.LEGEND_ITEM_HOVER,onLegendItemUnHover:p.LEGEND_ITEM_UNHOVER,onLegendChange:p.LEGEND_CHANGE,onMouseEnterAxis:p.MOUSEENTER_AXIS,onMouseLeaveAxis:p.MOUSELEAVE_AXIS,onCheckboxStateChange:p.CHECKBOX_STATE_CHANGE,onRadioStateChange:p.RADIO_STATE_CHANGE,onAfterRender:p.AFTER_RENDER,onInitialized:p.INITIALIZED,onPivotSortClick:p.PIVOT_SORT_CLICK,onDrillMenuClick:p.DRILLMENU_CLICK,onVChartEventType:p.VCHART_EVENT_TYPE,onChangCellValue:p.CHANGE_CELL_VALUE,onMousedownFillHandle:p.MOUSEDOWN_FILL_HANDLE,onDragFillHandleEnd:p.DRAG_FILL_HANDLE_END,onDblclickFillHandle:p.DBLCLICK_FILL_HANDLE,onScrollVerticalEnd:p.SCROLL_VERTICAL_END,onScrollHorizontalEnd:p.SCROLL_HORIZONTAL_END},E=Object.keys(C);var m=n.defineComponent({__name:"base-table",props:{type:{type:String,required:!1},options:{type:null,required:!1},records:{type:Array,required:!1},width:{type:[Number,String],required:!1,default:"100%"},height:{type:[Number,String],required:!1,default:"100%"},onReady:{type:Function,required:!1},onError:{type:Function,required:!1},onClickCell:{type:null,required:!1},onDblClickCell:{type:null,required:!1},onMouseDownCell:{type:null,required:!1},onMouseUpCell:{type:null,required:!1},onSelectedCell:{type:null,required:!1},onKeyDown:{type:null,required:!1},onMouseEnterTable:{type:null,required:!1},onMouseLeaveTable:{type:null,required:!1},onMouseDownTable:{type:null,required:!1},onMouseMoveCell:{type:null,required:!1},onMouseEnterCell:{type:null,required:!1},onMouseLeaveCell:{type:null,required:!1},onContextMenuCell:{type:null,required:!1},onResizeColumn:{type:null,required:!1},onResizeColumnEnd:{type:null,required:!1},onChangeHeaderPosition:{type:null,required:!1},onSortClick:{type:null,required:!1},onFreezeClick:{type:null,required:!1},onScroll:{type:null,required:!1},onDropdownMenuClick:{type:null,required:!1},onMouseOverChartSymbol:{type:null,required:!1},onDragSelectEnd:{type:null,required:!1},onDropdownIconClick:{type:null,required:!1},onDropdownMenuClear:{type:null,required:!1},onTreeHierarchyStateChange:{type:null,required:!1},onShowMenu:{type:null,required:!1},onHideMenu:{type:null,required:!1},onIconClick:{type:null,required:!1},onLegendItemClick:{type:null,required:!1},onLegendItemHover:{type:null,required:!1},onLegendItemUnHover:{type:null,required:!1},onLegendChange:{type:null,required:!1},onMouseEnterAxis:{type:null,required:!1},onMouseLeaveAxis:{type:null,required:!1},onCheckboxStateChange:{type:null,required:!1},onRadioStateChange:{type:null,required:!1},onAfterRender:{type:null,required:!1},onInitialized:{type:null,required:!1},onPivotSortClick:{type:null,required:!1},onDrillMenuClick:{type:null,required:!1},onVChartEventType:{type:null,required:!1},onChangCellValue:{type:null,required:!1},onMousedownFillHandle:{type:null,required:!1},onDragFillHandleEnd:{type:null,required:!1},onDblclickFillHandle:{type:null,required:!1},onScrollVerticalEnd:{type:null,required:!1},onScrollHorizontalEnd:{type:null,required:!1}},emits:E,setup(e,{expose:t,emit:r}){const l=e,i=n.ref(null),u=n.shallowRef(null);t({vTableInstance:u});const s=n.computed((()=>"number"==typeof l.width?`${l.width}px`:l.width)),a=n.computed((()=>"number"==typeof l.height?`${l.height}px`:l.height)),c=r,d=(e,o)=>{u.value=new e(i.value,o)},p=()=>{if(!i.value)return;u.value&&u.value.release();const e=()=>void 0!==l.records&&null!==l.records&&l.records.length>0?l.records:l.options.records;try{switch(l.type){case"list":d(o.ListTable,{...l.options,records:e()});break;case"pivot":d(o.PivotTable,{...l.options,records:e()});break;case"chart":d(o.PivotChart,{...l.options,records:e()})}n=u.value,E.forEach((e=>{n.on(C[e],(o=>{c(e,o)}))})),l.onReady?.(u.value,!0)}catch(e){l.onError?.(e)}var n},m=e=>{if(u.value)try{switch(l.type){case"list":u.value instanceof o.ListTable&&u.value.updateOption(e);break;case"pivot":u.value instanceof o.PivotTable&&u.value.updateOption(e);break;case"chart":u.value instanceof o.PivotChart&&u.value.updateOption(e)}}catch(e){l.onError?.(e)}};return n.onMounted(p),n.onBeforeUnmount((()=>u.value?.release())),n.watch((()=>l.options),(e=>{u.value?m(e):p()})),n.watch((()=>l.records),((e,o)=>{u.value?m({...l.options,records:e}):p()}),{deep:!0}),(e,o)=>(n.openBlock(),n.createElementBlock("div",{ref_key:"vTableContainer",ref:i,style:n.normalizeStyle([{width:s.value,height:a.value},{position:"relative"}])},null,4))}}),y=n.defineComponent({__name:"list-table",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:o}){const t=e,r=n.ref(null),l=n.useSlots(),i=n.computed((()=>{const e=d(s(l.default?.()||[]));return{...t.options,columns:e.columns.length?e.columns:t.options.columns,tooltip:e.tooltip||t.options.tooltip,menu:e.menu||t.options.menu}}));return o({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,o)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(m,n.mergeProps({type:"list",options:i.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}}),h=n.defineComponent({__name:"pivot-table",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:o}){const t=e,r=n.shallowRef(null),l=n.useSlots(),i=n.computed((()=>{const e=c(s(l.default?.()||[]));return{...t.options,columns:e.columns.length?e.columns:t.options.columns,columnHeaderTitle:e.columnHeaderTitle.length?e.columnHeaderTitle:t.options.columnHeaderTitle,rows:e.rows.length?e.rows:t.options.rows,rowHeaderTitle:e.rowHeaderTitle.length?e.rowHeaderTitle:t.options.rowHeaderTitle,indicators:e.indicators.length?e.indicators:t.options.indicators,corner:t.options.corner||e.corner,tooltip:t.options.tooltip||e.tooltip,menu:t.options.menu||e.menu}}));return o({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,o)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(m,n.mergeProps({type:"pivot",options:i.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}}),T=n.defineComponent({__name:"pivot-chart",props:{options:{type:Object,required:!0},records:{type:Array,required:!1},width:{type:[String,Number],required:!1},height:{type:[String,Number],required:!1}},setup(e,{expose:o}){const t=e,r=n.shallowRef(null),l=n.useSlots(),i=n.computed((()=>{const e=c(s(l.default?.()||[]));return{...t.options,columns:e.columns.length?e.columns:t.options.columns,columnHeaderTitle:e.columnHeaderTitle.length?e.columnHeaderTitle:t.options.columnHeaderTitle,rows:e.rows.length?e.rows:t.options.rows,rowHeaderTitle:e.rowHeaderTitle.length?e.rowHeaderTitle:t.options.rowHeaderTitle,indicators:e.indicators.length?e.indicators:t.options.indicators,corner:t.options.corner||e.corner,tooltip:t.options.tooltip||e.tooltip,menu:t.options.menu||e.menu}}));return o({vTableInstance:n.computed((()=>r.value?.vTableInstance||null))}),(e,o)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(m,n.mergeProps({type:"chart",options:i.value,records:e.records,width:e.width,height:e.height,ref_key:"baseTableRef",ref:r},e.$attrs),null,16,["options","records","width","height"]),n.renderSlot(e.$slots,"default")],64))}});function v(e){return null}function f(e){return null}function L(e){return null}function b(e){return null}function g(e){return null}function _(e){return null}function w(e){return null}function M(e){return null}function S(e){return null}function q(){return null}function H(){return null}function O(){return null}function D(e){return null}function I(e){return null}function R(e){return null}v.symbol="ListColumn",f.symbol="PivotColumnDimension",L.symbol="PivotRowDimension",b.symbol="PivotColumnHeaderTitle",g.symbol="PivotRowHeaderTitle",_.symbol="PivotIndicator",w.symbol="PivotCorner",M.symbol="Menu",S.symbol="Tooltip",q.symbol="Group",H.symbol="Image",O.symbol="Text",D.symbol="Tag",I.symbol="Radio",R.symbol="CheckBox";e.VTable=l,Object.defineProperty(e,"register",{enumerable:!0,get:function(){return o.register}}),e.CheckBox=R,e.Group=q,e.Image=H,e.ListColumn=v,e.ListTable=y,e.Menu=M,e.PivotChart=T,e.PivotColumnDimension=f,e.PivotColumnHeaderTitle=b,e.PivotCorner=w,e.PivotIndicator=_,e.PivotRowDimension=L,e.PivotRowHeaderTitle=g,e.PivotTable=h,e.Radio=I,e.Tag=D,e.Text=O,e.Tooltip=S,e.registerChartModule=(e,o)=>{l.register.chartModule(e,o)},e.version="1.10.4-alpha.2"}));
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -21,6 +21,6 @@ export { default as Tag } from './components/custom/tag.js';
|
|
|
21
21
|
export { default as Radio } from './components/custom/radio.js';
|
|
22
22
|
export { default as CheckBox } from './components/custom/checkBox.js';
|
|
23
23
|
|
|
24
|
-
const version = "1.10.
|
|
24
|
+
const version = "1.10.4-alpha.2";
|
|
25
25
|
|
|
26
26
|
export { version };
|
|
@@ -77,18 +77,21 @@ var _sfc_main = defineComponent({
|
|
|
77
77
|
instance.on(TABLE_EVENTS[eventKey], vueEventHandler);
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
|
+
const createTableInstance = (Type, options) => {
|
|
81
|
+
vTableInstance.value = new Type(vTableContainer.value, options);
|
|
82
|
+
};
|
|
80
83
|
const createVTable = () => {
|
|
81
|
-
var _a;
|
|
82
|
-
if (!vTableContainer.value)
|
|
84
|
+
var _a, _b;
|
|
85
|
+
if (!vTableContainer.value) {
|
|
83
86
|
return;
|
|
87
|
+
}
|
|
84
88
|
if (vTableInstance.value) {
|
|
85
89
|
vTableInstance.value.release();
|
|
86
90
|
}
|
|
87
91
|
const getRecords = () => {
|
|
88
|
-
return props.records !== undefined && props.records !== null && props.records.length > 0
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
vTableInstance.value = new Type(vTableContainer.value, options);
|
|
92
|
+
return props.records !== undefined && props.records !== null && props.records.length > 0
|
|
93
|
+
? props.records
|
|
94
|
+
: props.options.records;
|
|
92
95
|
};
|
|
93
96
|
try {
|
|
94
97
|
switch (props.type) {
|
|
@@ -106,12 +109,14 @@ var _sfc_main = defineComponent({
|
|
|
106
109
|
(_a = props.onReady) === null || _a === void 0 ? void 0 : _a.call(props, vTableInstance.value, true);
|
|
107
110
|
}
|
|
108
111
|
catch (err) {
|
|
112
|
+
(_b = props.onError) === null || _b === void 0 ? void 0 : _b.call(props, err);
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
115
|
const updateVTable = (newOptions) => {
|
|
112
116
|
var _a;
|
|
113
|
-
if (!vTableInstance.value)
|
|
117
|
+
if (!vTableInstance.value) {
|
|
114
118
|
return;
|
|
119
|
+
}
|
|
115
120
|
try {
|
|
116
121
|
switch (props.type) {
|
|
117
122
|
case 'list':
|
|
@@ -137,14 +142,14 @@ var _sfc_main = defineComponent({
|
|
|
137
142
|
};
|
|
138
143
|
onMounted(createVTable);
|
|
139
144
|
onBeforeUnmount(() => { var _a; return (_a = vTableInstance.value) === null || _a === void 0 ? void 0 : _a.release(); });
|
|
140
|
-
watch(() => props.options,
|
|
145
|
+
watch(() => props.options, newOptions => {
|
|
141
146
|
if (vTableInstance.value) {
|
|
142
147
|
updateVTable(newOptions);
|
|
143
148
|
}
|
|
144
149
|
else {
|
|
145
150
|
createVTable();
|
|
146
151
|
}
|
|
147
|
-
}
|
|
152
|
+
});
|
|
148
153
|
watch(() => props.records, (newRecords, oldRecords) => {
|
|
149
154
|
if (vTableInstance.value) {
|
|
150
155
|
updateVTable(Object.assign(Object.assign({}, props.options), { records: newRecords }));
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineComponent, ref, useSlots, computed, openBlock, createElementBlock, Fragment, createVNode, mergeProps, renderSlot } from 'vue';
|
|
2
|
-
import { flattenVNodes
|
|
2
|
+
import { flattenVNodes } from '../utils/vnodeUtils.js';
|
|
3
|
+
import '@visactor/vtable';
|
|
4
|
+
import '@visactor/vutils';
|
|
5
|
+
import { extractListSlotOptions } from '../utils/slotUtils.js';
|
|
3
6
|
import _sfc_main$1 from './base-table.vue.js';
|
|
4
7
|
|
|
5
8
|
var _sfc_main = defineComponent({
|
|
@@ -17,52 +20,9 @@ var _sfc_main = defineComponent({
|
|
|
17
20
|
const computedOptions = computed(() => {
|
|
18
21
|
var _a;
|
|
19
22
|
const flattenedSlots = flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
20
|
-
const slotOptions =
|
|
23
|
+
const slotOptions = extractListSlotOptions(flattenedSlots);
|
|
21
24
|
return Object.assign(Object.assign({}, props.options), { columns: slotOptions.columns.length ? slotOptions.columns : props.options.columns, tooltip: slotOptions.tooltip || props.options.tooltip, menu: slotOptions.menu || props.options.menu });
|
|
22
25
|
});
|
|
23
|
-
function extractSlotOptions(vnodes) {
|
|
24
|
-
const options = {
|
|
25
|
-
columns: [],
|
|
26
|
-
tooltip: {},
|
|
27
|
-
menu: {},
|
|
28
|
-
};
|
|
29
|
-
const typeMapping = {
|
|
30
|
-
ListColumn: 'columns',
|
|
31
|
-
Tooltip: 'tooltip',
|
|
32
|
-
Menu: 'menu',
|
|
33
|
-
};
|
|
34
|
-
vnodes.forEach(vnode => {
|
|
35
|
-
var _a, _b;
|
|
36
|
-
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
37
|
-
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
38
|
-
const optionKey = typeMapping[typeName];
|
|
39
|
-
if (optionKey) {
|
|
40
|
-
if (optionKey === 'columns' && vnode.children) {
|
|
41
|
-
vnode.props.customLayout = createCustomLayoutHandler(vnode.children);
|
|
42
|
-
}
|
|
43
|
-
if (Array.isArray(options[optionKey])) {
|
|
44
|
-
options[optionKey].push(vnode.props);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
options[optionKey] = vnode.props;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return options;
|
|
52
|
-
}
|
|
53
|
-
function createCustomLayoutHandler(children) {
|
|
54
|
-
return (args) => {
|
|
55
|
-
const { table, row, col, rect } = args;
|
|
56
|
-
const record = table.getCellOriginRecord(col, row);
|
|
57
|
-
const { height, width } = rect !== null && rect !== void 0 ? rect : table.getCellRect(col, row);
|
|
58
|
-
const rootContainer = children.customLayout({ table, row, col, rect, record, height, width })[0];
|
|
59
|
-
const { rootComponent } = createCustomLayout(rootContainer);
|
|
60
|
-
return {
|
|
61
|
-
rootContainer: rootComponent,
|
|
62
|
-
renderDefault: false,
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
26
|
__expose({
|
|
67
27
|
vTableInstance: computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }),
|
|
68
28
|
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineComponent, shallowRef, useSlots, computed, openBlock, createElementBlock, Fragment, createVNode, mergeProps, renderSlot } from 'vue';
|
|
2
|
-
import { flattenVNodes
|
|
2
|
+
import { flattenVNodes } from '../utils/vnodeUtils.js';
|
|
3
|
+
import '@visactor/vtable';
|
|
4
|
+
import '@visactor/vutils';
|
|
5
|
+
import { extractPivotSlotOptions } from '../utils/slotUtils.js';
|
|
3
6
|
import _sfc_main$1 from './base-table.vue.js';
|
|
4
7
|
|
|
5
8
|
var _sfc_main = defineComponent({
|
|
@@ -17,46 +20,8 @@ var _sfc_main = defineComponent({
|
|
|
17
20
|
const computedOptions = computed(() => {
|
|
18
21
|
var _a;
|
|
19
22
|
const flattenedSlots = flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
columnHeaderTitle: [],
|
|
23
|
-
rows: [],
|
|
24
|
-
rowHeaderTitle: [],
|
|
25
|
-
indicators: [],
|
|
26
|
-
corner: Object,
|
|
27
|
-
tooltip: Object,
|
|
28
|
-
menu: Object,
|
|
29
|
-
};
|
|
30
|
-
const typeMapping = {
|
|
31
|
-
'PivotColumnDimension': 'columns',
|
|
32
|
-
'PivotColumnHeaderTitle': 'columnHeaderTitle',
|
|
33
|
-
'PivotRowDimension': 'rows',
|
|
34
|
-
'PivotRowHeaderTitle': 'rowHeaderTitle',
|
|
35
|
-
'PivotCorner': 'corner',
|
|
36
|
-
'PivotIndicator': 'indicators',
|
|
37
|
-
'Tooltip': 'tooltip',
|
|
38
|
-
'Menu': 'menu',
|
|
39
|
-
};
|
|
40
|
-
flattenedSlots.forEach(vnode => {
|
|
41
|
-
var _a, _b;
|
|
42
|
-
vnode.props = convertPropsToCamelCase(vnode.props);
|
|
43
|
-
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
44
|
-
const optionKey = typeMapping[typeName];
|
|
45
|
-
if (optionKey) {
|
|
46
|
-
if (Array.isArray(options[optionKey])) {
|
|
47
|
-
if (vnode.props.hasOwnProperty('objectHandler')) {
|
|
48
|
-
options[optionKey].push(vnode.props.objectHandler);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
options[optionKey].push(vnode.props);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
options[optionKey] = vnode.props;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return Object.assign(Object.assign({}, props.options), { columns: options.columns.length ? options.columns : props.options.columns, columnHeaderTitle: options.columnHeaderTitle.length ? options.columnHeaderTitle : props.options.columnHeaderTitle, rows: options.rows.length ? options.rows : props.options.rows, rowHeaderTitle: options.rowHeaderTitle.length ? options.rowHeaderTitle : props.options.rowHeaderTitle, indicators: options.indicators.length ? options.indicators : props.options.indicators, corner: options.corner || props.options.corner, tooltip: options.tooltip || props.options.tooltip, menu: options.menu || props.options.menu });
|
|
23
|
+
const slotOptions = extractPivotSlotOptions(flattenedSlots);
|
|
24
|
+
return Object.assign(Object.assign({}, props.options), { columns: slotOptions.columns.length ? slotOptions.columns : props.options.columns, columnHeaderTitle: slotOptions.columnHeaderTitle.length ? slotOptions.columnHeaderTitle : props.options.columnHeaderTitle, rows: slotOptions.rows.length ? slotOptions.rows : props.options.rows, rowHeaderTitle: slotOptions.rowHeaderTitle.length ? slotOptions.rowHeaderTitle : props.options.rowHeaderTitle, indicators: slotOptions.indicators.length ? slotOptions.indicators : props.options.indicators, corner: props.options.corner || slotOptions.corner, tooltip: props.options.tooltip || slotOptions.tooltip, menu: props.options.menu || slotOptions.menu });
|
|
60
25
|
});
|
|
61
26
|
__expose({ vTableInstance: computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
|
|
62
27
|
return (_ctx, _cache) => {
|