@visactor/vue-vtable 1.10.3 → 1.10.4
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 +2 -2
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -40,7 +40,7 @@ function _interopNamespaceDefault(e) {
|
|
|
40
40
|
|
|
41
41
|
var VTable__namespace = /*#__PURE__*/_interopNamespaceDefault(VTable);
|
|
42
42
|
|
|
43
|
-
const version = "1.10.
|
|
43
|
+
const version = "1.10.4";
|
|
44
44
|
|
|
45
45
|
exports.VTable = VTable__namespace;
|
|
46
46
|
Object.defineProperty(exports, 'register', {
|
|
@@ -79,18 +79,21 @@ var _sfc_main = vue.defineComponent({
|
|
|
79
79
|
instance.on(eventsUtils.TABLE_EVENTS[eventKey], vueEventHandler);
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
|
+
const createTableInstance = (Type, options) => {
|
|
83
|
+
vTableInstance.value = new Type(vTableContainer.value, options);
|
|
84
|
+
};
|
|
82
85
|
const createVTable = () => {
|
|
83
|
-
var _a;
|
|
84
|
-
if (!vTableContainer.value)
|
|
86
|
+
var _a, _b;
|
|
87
|
+
if (!vTableContainer.value) {
|
|
85
88
|
return;
|
|
89
|
+
}
|
|
86
90
|
if (vTableInstance.value) {
|
|
87
91
|
vTableInstance.value.release();
|
|
88
92
|
}
|
|
89
93
|
const getRecords = () => {
|
|
90
|
-
return props.records !== undefined && props.records !== null && props.records.length > 0
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
vTableInstance.value = new Type(vTableContainer.value, options);
|
|
94
|
+
return props.records !== undefined && props.records !== null && props.records.length > 0
|
|
95
|
+
? props.records
|
|
96
|
+
: props.options.records;
|
|
94
97
|
};
|
|
95
98
|
try {
|
|
96
99
|
switch (props.type) {
|
|
@@ -108,12 +111,14 @@ var _sfc_main = vue.defineComponent({
|
|
|
108
111
|
(_a = props.onReady) === null || _a === void 0 ? void 0 : _a.call(props, vTableInstance.value, true);
|
|
109
112
|
}
|
|
110
113
|
catch (err) {
|
|
114
|
+
(_b = props.onError) === null || _b === void 0 ? void 0 : _b.call(props, err);
|
|
111
115
|
}
|
|
112
116
|
};
|
|
113
117
|
const updateVTable = (newOptions) => {
|
|
114
118
|
var _a;
|
|
115
|
-
if (!vTableInstance.value)
|
|
119
|
+
if (!vTableInstance.value) {
|
|
116
120
|
return;
|
|
121
|
+
}
|
|
117
122
|
try {
|
|
118
123
|
switch (props.type) {
|
|
119
124
|
case 'list':
|
|
@@ -139,14 +144,14 @@ var _sfc_main = vue.defineComponent({
|
|
|
139
144
|
};
|
|
140
145
|
vue.onMounted(createVTable);
|
|
141
146
|
vue.onBeforeUnmount(() => { var _a; return (_a = vTableInstance.value) === null || _a === void 0 ? void 0 : _a.release(); });
|
|
142
|
-
vue.watch(() => props.options,
|
|
147
|
+
vue.watch(() => props.options, newOptions => {
|
|
143
148
|
if (vTableInstance.value) {
|
|
144
149
|
updateVTable(newOptions);
|
|
145
150
|
}
|
|
146
151
|
else {
|
|
147
152
|
createVTable();
|
|
148
153
|
}
|
|
149
|
-
}
|
|
154
|
+
});
|
|
150
155
|
vue.watch(() => props.records, (newRecords, oldRecords) => {
|
|
151
156
|
if (vTableInstance.value) {
|
|
152
157
|
updateVTable(Object.assign(Object.assign({}, props.options), { records: newRecords }));
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var vue = require('vue');
|
|
4
|
-
var
|
|
4
|
+
var vnodeUtils = require('../utils/vnodeUtils.js');
|
|
5
|
+
require('@visactor/vtable');
|
|
6
|
+
require('@visactor/vutils');
|
|
7
|
+
var slotUtils = require('../utils/slotUtils.js');
|
|
5
8
|
var baseTable_vue_vue_type_script_setup_true_lang = require('./base-table.vue.js');
|
|
6
9
|
|
|
7
10
|
var _sfc_main = vue.defineComponent({
|
|
@@ -18,53 +21,10 @@ var _sfc_main = vue.defineComponent({
|
|
|
18
21
|
const slots = vue.useSlots();
|
|
19
22
|
const computedOptions = vue.computed(() => {
|
|
20
23
|
var _a;
|
|
21
|
-
const flattenedSlots =
|
|
22
|
-
const slotOptions =
|
|
24
|
+
const flattenedSlots = vnodeUtils.flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
25
|
+
const slotOptions = slotUtils.extractListSlotOptions(flattenedSlots);
|
|
23
26
|
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 });
|
|
24
27
|
});
|
|
25
|
-
function extractSlotOptions(vnodes) {
|
|
26
|
-
const options = {
|
|
27
|
-
columns: [],
|
|
28
|
-
tooltip: {},
|
|
29
|
-
menu: {},
|
|
30
|
-
};
|
|
31
|
-
const typeMapping = {
|
|
32
|
-
ListColumn: 'columns',
|
|
33
|
-
Tooltip: 'tooltip',
|
|
34
|
-
Menu: 'menu',
|
|
35
|
-
};
|
|
36
|
-
vnodes.forEach(vnode => {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
vnode.props = utils.convertPropsToCamelCase(vnode.props);
|
|
39
|
-
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
40
|
-
const optionKey = typeMapping[typeName];
|
|
41
|
-
if (optionKey) {
|
|
42
|
-
if (optionKey === 'columns' && vnode.children) {
|
|
43
|
-
vnode.props.customLayout = createCustomLayoutHandler(vnode.children);
|
|
44
|
-
}
|
|
45
|
-
if (Array.isArray(options[optionKey])) {
|
|
46
|
-
options[optionKey].push(vnode.props);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
options[optionKey] = vnode.props;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return options;
|
|
54
|
-
}
|
|
55
|
-
function createCustomLayoutHandler(children) {
|
|
56
|
-
return (args) => {
|
|
57
|
-
const { table, row, col, rect } = args;
|
|
58
|
-
const record = table.getCellOriginRecord(col, row);
|
|
59
|
-
const { height, width } = rect !== null && rect !== void 0 ? rect : table.getCellRect(col, row);
|
|
60
|
-
const rootContainer = children.customLayout({ table, row, col, rect, record, height, width })[0];
|
|
61
|
-
const { rootComponent } = utils.createCustomLayout(rootContainer);
|
|
62
|
-
return {
|
|
63
|
-
rootContainer: rootComponent,
|
|
64
|
-
renderDefault: false,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
28
|
__expose({
|
|
69
29
|
vTableInstance: vue.computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }),
|
|
70
30
|
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var vue = require('vue');
|
|
4
|
-
var
|
|
4
|
+
var vnodeUtils = require('../utils/vnodeUtils.js');
|
|
5
|
+
require('@visactor/vtable');
|
|
6
|
+
require('@visactor/vutils');
|
|
7
|
+
var slotUtils = require('../utils/slotUtils.js');
|
|
5
8
|
var baseTable_vue_vue_type_script_setup_true_lang = require('./base-table.vue.js');
|
|
6
9
|
|
|
7
10
|
var _sfc_main = vue.defineComponent({
|
|
@@ -18,47 +21,9 @@ var _sfc_main = vue.defineComponent({
|
|
|
18
21
|
const slots = vue.useSlots();
|
|
19
22
|
const computedOptions = vue.computed(() => {
|
|
20
23
|
var _a;
|
|
21
|
-
const flattenedSlots =
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
columnHeaderTitle: [],
|
|
25
|
-
rows: [],
|
|
26
|
-
rowHeaderTitle: [],
|
|
27
|
-
indicators: [],
|
|
28
|
-
corner: Object,
|
|
29
|
-
tooltip: Object,
|
|
30
|
-
menu: Object,
|
|
31
|
-
};
|
|
32
|
-
const typeMapping = {
|
|
33
|
-
'PivotColumnDimension': 'columns',
|
|
34
|
-
'PivotColumnHeaderTitle': 'columnHeaderTitle',
|
|
35
|
-
'PivotRowDimension': 'rows',
|
|
36
|
-
'PivotRowHeaderTitle': 'rowHeaderTitle',
|
|
37
|
-
'PivotCorner': 'corner',
|
|
38
|
-
'PivotIndicator': 'indicators',
|
|
39
|
-
'Tooltip': 'tooltip',
|
|
40
|
-
'Menu': 'menu',
|
|
41
|
-
};
|
|
42
|
-
flattenedSlots.forEach(vnode => {
|
|
43
|
-
var _a, _b;
|
|
44
|
-
vnode.props = utils.convertPropsToCamelCase(vnode.props);
|
|
45
|
-
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
46
|
-
const optionKey = typeMapping[typeName];
|
|
47
|
-
if (optionKey) {
|
|
48
|
-
if (Array.isArray(options[optionKey])) {
|
|
49
|
-
if (vnode.props.hasOwnProperty('objectHandler')) {
|
|
50
|
-
options[optionKey].push(vnode.props.objectHandler);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
options[optionKey].push(vnode.props);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
options[optionKey] = vnode.props;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
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 });
|
|
24
|
+
const flattenedSlots = vnodeUtils.flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
25
|
+
const slotOptions = slotUtils.extractPivotSlotOptions(flattenedSlots);
|
|
26
|
+
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 });
|
|
62
27
|
});
|
|
63
28
|
__expose({ vTableInstance: vue.computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
|
|
64
29
|
return (_ctx, _cache) => {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var vue = require('vue');
|
|
4
|
-
var
|
|
4
|
+
var vnodeUtils = require('../utils/vnodeUtils.js');
|
|
5
|
+
require('@visactor/vtable');
|
|
6
|
+
require('@visactor/vutils');
|
|
7
|
+
var slotUtils = require('../utils/slotUtils.js');
|
|
5
8
|
var baseTable_vue_vue_type_script_setup_true_lang = require('./base-table.vue.js');
|
|
6
9
|
|
|
7
10
|
var _sfc_main = vue.defineComponent({
|
|
@@ -18,42 +21,9 @@ var _sfc_main = vue.defineComponent({
|
|
|
18
21
|
const slots = vue.useSlots();
|
|
19
22
|
const computedOptions = vue.computed(() => {
|
|
20
23
|
var _a;
|
|
21
|
-
const flattenedSlots =
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
columnHeaderTitle: [],
|
|
25
|
-
rows: [],
|
|
26
|
-
rowHeaderTitle: [],
|
|
27
|
-
indicators: [],
|
|
28
|
-
corner: Object,
|
|
29
|
-
tooltip: Object,
|
|
30
|
-
menu: Object,
|
|
31
|
-
};
|
|
32
|
-
const typeMapping = {
|
|
33
|
-
'PivotColumnDimension': 'columns',
|
|
34
|
-
'PivotColumnHeaderTitle': 'columnHeaderTitle',
|
|
35
|
-
'PivotRowDimension': 'rows',
|
|
36
|
-
'PivotRowHeaderTitle': 'rowHeaderTitle',
|
|
37
|
-
'PivotCorner': 'corner',
|
|
38
|
-
'PivotIndicator': 'indicators',
|
|
39
|
-
'Tooltip': 'tooltip',
|
|
40
|
-
'Menu': 'menu',
|
|
41
|
-
};
|
|
42
|
-
flattenedSlots.forEach(vnode => {
|
|
43
|
-
var _a, _b;
|
|
44
|
-
vnode.props = utils.convertPropsToCamelCase(vnode.props);
|
|
45
|
-
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
46
|
-
const optionKey = typeMapping[typeName];
|
|
47
|
-
if (optionKey) {
|
|
48
|
-
if (Array.isArray(options[optionKey])) {
|
|
49
|
-
options[optionKey].push(vnode.props);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
options[optionKey] = vnode.props;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
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: props.options.corner || options.corner, tooltip: props.options.tooltip || options.tooltip, menu: props.options.menu || options.menu });
|
|
24
|
+
const flattenedSlots = vnodeUtils.flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
25
|
+
const slotOptions = slotUtils.extractPivotSlotOptions(flattenedSlots);
|
|
26
|
+
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 });
|
|
57
27
|
});
|
|
58
28
|
__expose({ vTableInstance: vue.computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }) });
|
|
59
29
|
return (_ctx, _cache) => {
|
package/cjs/tables/utils.d.ts
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
import * as VTable from '@visactor/vtable';
|
|
2
|
+
import type { TooltipProps } from '../components/component/tooltip';
|
|
3
|
+
import type { MenuProps } from '../components/component/menu';
|
|
1
4
|
export declare function flattenVNodes(vnodes: any[]): any[];
|
|
2
5
|
export declare function toCamelCase(str: string): string;
|
|
3
6
|
export declare function convertPropsToCamelCase(props: Record<string, any>): Record<string, any>;
|
|
4
7
|
export declare function createCustomLayout(children: any): any;
|
|
8
|
+
export declare function extractPivotSlotOptions(vnodes: any[]): {
|
|
9
|
+
columns: VTable.TYPES.ColumnDefine[];
|
|
10
|
+
columnHeaderTitle: VTable.TYPES.ITitleDefine[];
|
|
11
|
+
rows: VTable.TYPES.IDimension[];
|
|
12
|
+
rowHeaderTitle: VTable.TYPES.ITitleDefine[];
|
|
13
|
+
indicators: VTable.TYPES.IIndicator[];
|
|
14
|
+
corner: VTable.TYPES.ICornerDefine;
|
|
15
|
+
tooltip: TooltipProps;
|
|
16
|
+
menu: MenuProps;
|
|
17
|
+
};
|
|
18
|
+
export declare function extractListSlotOptions(vnodes: any[]): {
|
|
19
|
+
columns: VTable.TYPES.ColumnDefine[];
|
|
20
|
+
tooltip: TooltipProps;
|
|
21
|
+
menu: MenuProps;
|
|
22
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var VTable = require('@visactor/vtable');
|
|
4
|
+
var stringUtils = require('./stringUtils.js');
|
|
4
5
|
var vutils = require('@visactor/vutils');
|
|
5
6
|
|
|
6
7
|
function _interopNamespaceDefault(e) {
|
|
@@ -22,22 +23,6 @@ function _interopNamespaceDefault(e) {
|
|
|
22
23
|
|
|
23
24
|
var VTable__namespace = /*#__PURE__*/_interopNamespaceDefault(VTable);
|
|
24
25
|
|
|
25
|
-
function flattenVNodes(vnodes) {
|
|
26
|
-
return vnodes.flatMap(vnode => (Array.isArray(vnode.children) ? flattenVNodes(vnode.children) : vnode));
|
|
27
|
-
}
|
|
28
|
-
function toCamelCase(str) {
|
|
29
|
-
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
30
|
-
}
|
|
31
|
-
function convertPropsToCamelCase(props) {
|
|
32
|
-
const newProps = {};
|
|
33
|
-
for (const key in props) {
|
|
34
|
-
if (props.hasOwnProperty(key)) {
|
|
35
|
-
const camelCaseKey = toCamelCase(key);
|
|
36
|
-
newProps[camelCaseKey] = props[key];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return newProps;
|
|
40
|
-
}
|
|
41
26
|
function isEventProp(key, props) {
|
|
42
27
|
return key.startsWith('on') && vutils.isFunction(props[key]);
|
|
43
28
|
}
|
|
@@ -55,7 +40,7 @@ function createCustomLayout(children) {
|
|
|
55
40
|
return null;
|
|
56
41
|
}
|
|
57
42
|
const { type, children: childChildren } = child;
|
|
58
|
-
const props = convertPropsToCamelCase(child.props);
|
|
43
|
+
const props = stringUtils.convertPropsToCamelCase(child.props);
|
|
59
44
|
const componentName = (type === null || type === void 0 ? void 0 : type.symbol) || (type === null || type === void 0 ? void 0 : type.name);
|
|
60
45
|
const ComponentClass = componentMap[componentName];
|
|
61
46
|
if (!ComponentClass) {
|
|
@@ -92,16 +77,27 @@ function createCustomLayout(children) {
|
|
|
92
77
|
eventName = key.slice(2).toLowerCase();
|
|
93
78
|
}
|
|
94
79
|
else {
|
|
95
|
-
eventName = toCamelCase(key.slice(2)).toLowerCase();
|
|
80
|
+
eventName = stringUtils.toCamelCase(key.slice(2)).toLowerCase();
|
|
96
81
|
}
|
|
97
82
|
component.addEventListener(eventName, props[key]);
|
|
98
83
|
}
|
|
99
84
|
});
|
|
100
85
|
}
|
|
101
86
|
return { rootComponent: createComponent(children) };
|
|
87
|
+
}
|
|
88
|
+
function createCustomLayoutHandler(children) {
|
|
89
|
+
return (args) => {
|
|
90
|
+
const { table, row, col, rect } = args;
|
|
91
|
+
const record = table.getCellOriginRecord(col, row);
|
|
92
|
+
const { height, width } = rect !== null && rect !== void 0 ? rect : table.getCellRect(col, row);
|
|
93
|
+
const rootContainer = children.customLayout({ table, row, col, rect, record, height, width })[0];
|
|
94
|
+
const { rootComponent } = createCustomLayout(rootContainer);
|
|
95
|
+
return {
|
|
96
|
+
rootContainer: rootComponent,
|
|
97
|
+
renderDefault: false
|
|
98
|
+
};
|
|
99
|
+
};
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
exports.convertPropsToCamelCase = convertPropsToCamelCase;
|
|
105
102
|
exports.createCustomLayout = createCustomLayout;
|
|
106
|
-
exports.
|
|
107
|
-
exports.toCamelCase = toCamelCase;
|
|
103
|
+
exports.createCustomLayoutHandler = createCustomLayoutHandler;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ColumnDefine, ICornerDefine, IIndicator, IDimension, ITitleDefine } from '@visactor/vtable';
|
|
2
|
+
import type { TooltipProps } from '../components/component/tooltip';
|
|
3
|
+
import type { MenuProps } from '../components/component/menu';
|
|
4
|
+
export declare function extractPivotSlotOptions(vnodes: any[]): {
|
|
5
|
+
columns: ColumnDefine[];
|
|
6
|
+
columnHeaderTitle: ITitleDefine[];
|
|
7
|
+
rows: IDimension[];
|
|
8
|
+
rowHeaderTitle: ITitleDefine[];
|
|
9
|
+
indicators: IIndicator[];
|
|
10
|
+
corner: ICornerDefine;
|
|
11
|
+
tooltip: TooltipProps;
|
|
12
|
+
menu: MenuProps;
|
|
13
|
+
};
|
|
14
|
+
export declare function extractListSlotOptions(vnodes: any[]): {
|
|
15
|
+
columns: ColumnDefine[];
|
|
16
|
+
tooltip: TooltipProps;
|
|
17
|
+
menu: MenuProps;
|
|
18
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stringUtils = require('./stringUtils.js');
|
|
4
|
+
var customLayoutUtils = require('./customLayoutUtils.js');
|
|
5
|
+
|
|
6
|
+
function extractPivotSlotOptions(vnodes) {
|
|
7
|
+
const options = {
|
|
8
|
+
columns: [],
|
|
9
|
+
columnHeaderTitle: [],
|
|
10
|
+
rows: [],
|
|
11
|
+
rowHeaderTitle: [],
|
|
12
|
+
indicators: [],
|
|
13
|
+
corner: {},
|
|
14
|
+
tooltip: {},
|
|
15
|
+
menu: {}
|
|
16
|
+
};
|
|
17
|
+
const typeMapping = {
|
|
18
|
+
PivotColumnDimension: 'columns',
|
|
19
|
+
PivotColumnHeaderTitle: 'columnHeaderTitle',
|
|
20
|
+
PivotRowDimension: 'rows',
|
|
21
|
+
PivotRowHeaderTitle: 'rowHeaderTitle',
|
|
22
|
+
PivotCorner: 'corner',
|
|
23
|
+
PivotIndicator: 'indicators',
|
|
24
|
+
Tooltip: 'tooltip',
|
|
25
|
+
Menu: 'menu'
|
|
26
|
+
};
|
|
27
|
+
vnodes.forEach(vnode => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
vnode.props = stringUtils.convertPropsToCamelCase(vnode.props);
|
|
30
|
+
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
31
|
+
const optionKey = typeMapping[typeName];
|
|
32
|
+
if (optionKey) {
|
|
33
|
+
if (Array.isArray(options[optionKey])) {
|
|
34
|
+
if (vnode.props.hasOwnProperty('objectHandler')) {
|
|
35
|
+
options[optionKey].push(vnode.props.objectHandler);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
options[optionKey].push(vnode.props);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
options[optionKey] = vnode.props;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return options;
|
|
47
|
+
}
|
|
48
|
+
function extractListSlotOptions(vnodes) {
|
|
49
|
+
const options = {
|
|
50
|
+
columns: [],
|
|
51
|
+
tooltip: {},
|
|
52
|
+
menu: {}
|
|
53
|
+
};
|
|
54
|
+
const typeMapping = {
|
|
55
|
+
ListColumn: 'columns',
|
|
56
|
+
Tooltip: 'tooltip',
|
|
57
|
+
Menu: 'menu'
|
|
58
|
+
};
|
|
59
|
+
vnodes.forEach(vnode => {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
vnode.props = stringUtils.convertPropsToCamelCase(vnode.props);
|
|
62
|
+
const typeName = ((_a = vnode.type) === null || _a === void 0 ? void 0 : _a.symbol) || ((_b = vnode.type) === null || _b === void 0 ? void 0 : _b.name);
|
|
63
|
+
const optionKey = typeMapping[typeName];
|
|
64
|
+
if (optionKey) {
|
|
65
|
+
if (optionKey === 'columns' && vnode.children) {
|
|
66
|
+
vnode.props.customLayout = customLayoutUtils.createCustomLayoutHandler(vnode.children);
|
|
67
|
+
}
|
|
68
|
+
if (Array.isArray(options[optionKey])) {
|
|
69
|
+
options[optionKey].push(vnode.props);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
options[optionKey] = vnode.props;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return options;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.extractListSlotOptions = extractListSlotOptions;
|
|
80
|
+
exports.extractPivotSlotOptions = extractPivotSlotOptions;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function toCamelCase(str) {
|
|
4
|
+
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
5
|
+
}
|
|
6
|
+
function convertPropsToCamelCase(props) {
|
|
7
|
+
const newProps = {};
|
|
8
|
+
for (const key in props) {
|
|
9
|
+
if (props.hasOwnProperty(key)) {
|
|
10
|
+
const camelCaseKey = toCamelCase(key);
|
|
11
|
+
newProps[camelCaseKey] = props[key];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return newProps;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.convertPropsToCamelCase = convertPropsToCamelCase;
|
|
18
|
+
exports.toCamelCase = toCamelCase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function flattenVNodes(vnodes: any[]): any[];
|
package/cjs/utils.d.ts
ADDED