@visactor/react-vtable 0.15.0-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/README.md +151 -0
- package/cjs/components/base-component.d.ts +9 -0
- package/cjs/components/base-component.js +81 -0
- package/cjs/components/base-component.js.map +1 -0
- package/cjs/components/component/menu.d.ts +9 -0
- package/cjs/components/component/menu.js +10 -0
- package/cjs/components/component/menu.js.map +1 -0
- package/cjs/components/component/tooltip.d.ts +7 -0
- package/cjs/components/component/tooltip.js +10 -0
- package/cjs/components/component/tooltip.js.map +1 -0
- package/cjs/components/index.d.ts +14 -0
- package/cjs/components/index.js +79 -0
- package/cjs/components/index.js.map +1 -0
- package/cjs/components/list/list-column.d.ts +4 -0
- package/cjs/components/list/list-column.js +10 -0
- package/cjs/components/list/list-column.js.map +1 -0
- package/cjs/components/pivot/pivot-corner.d.ts +4 -0
- package/cjs/components/pivot/pivot-corner.js +10 -0
- package/cjs/components/pivot/pivot-corner.js.map +1 -0
- package/cjs/components/pivot/pivot-dimension.d.ts +5 -0
- package/cjs/components/pivot/pivot-dimension.js +11 -0
- package/cjs/components/pivot/pivot-dimension.js.map +1 -0
- package/cjs/components/pivot/pivot-header-title.d.ts +5 -0
- package/cjs/components/pivot/pivot-header-title.js +11 -0
- package/cjs/components/pivot/pivot-header-title.js.map +1 -0
- package/cjs/components/pivot/pivot-indicator.d.ts +4 -0
- package/cjs/components/pivot/pivot-indicator.js +10 -0
- package/cjs/components/pivot/pivot-indicator.js.map +1 -0
- package/cjs/constants.d.ts +1 -0
- package/cjs/constants.js +6 -0
- package/cjs/constants.js.map +1 -0
- package/cjs/containers/withContainer.d.ts +8 -0
- package/cjs/containers/withContainer.js +64 -0
- package/cjs/containers/withContainer.js.map +1 -0
- package/cjs/context/table.d.ts +10 -0
- package/cjs/context/table.js +25 -0
- package/cjs/context/table.js.map +1 -0
- package/cjs/eventsUtils.d.ts +88 -0
- package/cjs/eventsUtils.js +72 -0
- package/cjs/eventsUtils.js.map +1 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +20 -0
- package/cjs/index.js.map +1 -0
- package/cjs/index_old.d.ts +5 -0
- package/cjs/index_old.js +36 -0
- package/cjs/index_old.js.map +1 -0
- package/cjs/tables/base-table.d.ts +19 -0
- package/cjs/tables/base-table.js +127 -0
- package/cjs/tables/base-table.js.map +1 -0
- package/cjs/tables/index.d.ts +3 -0
- package/cjs/tables/index.js +38 -0
- package/cjs/tables/index.js.map +1 -0
- package/cjs/tables/list-table.d.ts +8 -0
- package/cjs/tables/list-table.js +10 -0
- package/cjs/tables/list-table.js.map +1 -0
- package/cjs/tables/pivot-chart.d.ts +9 -0
- package/cjs/tables/pivot-chart.js +40 -0
- package/cjs/tables/pivot-chart.js.map +1 -0
- package/cjs/tables/pivot-table.d.ts +8 -0
- package/cjs/tables/pivot-table.js +10 -0
- package/cjs/tables/pivot-table.js.map +1 -0
- package/cjs/util.d.ts +8 -0
- package/cjs/util.js +57 -0
- package/cjs/util.js.map +1 -0
- package/dist/react-vtable.js +3628 -0
- package/dist/react-vtable.min.js +19 -0
- package/es/components/base-component.d.ts +9 -0
- package/es/components/base-component.js +53 -0
- package/es/components/base-component.js.map +1 -0
- package/es/components/component/menu.d.ts +9 -0
- package/es/components/component/menu.js +4 -0
- package/es/components/component/menu.js.map +1 -0
- package/es/components/component/tooltip.d.ts +7 -0
- package/es/components/component/tooltip.js +4 -0
- package/es/components/component/tooltip.js.map +1 -0
- package/es/components/index.d.ts +14 -0
- package/es/components/index.js +14 -0
- package/es/components/index.js.map +1 -0
- package/es/components/list/list-column.d.ts +4 -0
- package/es/components/list/list-column.js +4 -0
- package/es/components/list/list-column.js.map +1 -0
- package/es/components/pivot/pivot-corner.d.ts +4 -0
- package/es/components/pivot/pivot-corner.js +4 -0
- package/es/components/pivot/pivot-corner.js.map +1 -0
- package/es/components/pivot/pivot-dimension.d.ts +5 -0
- package/es/components/pivot/pivot-dimension.js +6 -0
- package/es/components/pivot/pivot-dimension.js.map +1 -0
- package/es/components/pivot/pivot-header-title.d.ts +5 -0
- package/es/components/pivot/pivot-header-title.js +6 -0
- package/es/components/pivot/pivot-header-title.js.map +1 -0
- package/es/components/pivot/pivot-indicator.d.ts +4 -0
- package/es/components/pivot/pivot-indicator.js +4 -0
- package/es/components/pivot/pivot-indicator.js.map +1 -0
- package/es/constants.d.ts +1 -0
- package/es/constants.js +2 -0
- package/es/constants.js.map +1 -0
- package/es/containers/withContainer.d.ts +8 -0
- package/es/containers/withContainer.js +33 -0
- package/es/containers/withContainer.js.map +1 -0
- package/es/context/table.d.ts +10 -0
- package/es/context/table.js +16 -0
- package/es/context/table.js.map +1 -0
- package/es/eventsUtils.d.ts +88 -0
- package/es/eventsUtils.js +65 -0
- package/es/eventsUtils.js.map +1 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -0
- package/es/index.js.map +1 -0
- package/es/index_old.d.ts +5 -0
- package/es/index_old.js +29 -0
- package/es/index_old.js.map +1 -0
- package/es/tables/base-table.d.ts +19 -0
- package/es/tables/base-table.js +104 -0
- package/es/tables/base-table.js.map +1 -0
- package/es/tables/index.d.ts +3 -0
- package/es/tables/index.js +6 -0
- package/es/tables/index.js.map +1 -0
- package/es/tables/list-table.d.ts +8 -0
- package/es/tables/list-table.js +4 -0
- package/es/tables/list-table.js.map +1 -0
- package/es/tables/pivot-chart.d.ts +9 -0
- package/es/tables/pivot-chart.js +10 -0
- package/es/tables/pivot-chart.js.map +1 -0
- package/es/tables/pivot-table.d.ts +8 -0
- package/es/tables/pivot-table.js +4 -0
- package/es/tables/pivot-table.js.map +1 -0
- package/es/util.d.ts +8 -0
- package/es/util.js +36 -0
- package/es/util.js.map +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: !0
|
|
11
|
+
}), exports.withTableInstance = void 0;
|
|
12
|
+
|
|
13
|
+
const react_1 = __importDefault(require("react")), TableContext = react_1.default.createContext(null);
|
|
14
|
+
|
|
15
|
+
function withTableInstance(Component) {
|
|
16
|
+
const Com = react_1.default.forwardRef(((props, ref) => react_1.default.createElement(TableContext.Consumer, null, (ctx => react_1.default.createElement(Component, Object.assign({
|
|
17
|
+
ref: ref,
|
|
18
|
+
table: ctx.table
|
|
19
|
+
}, props))))));
|
|
20
|
+
return Com.displayName = Component.name, Com;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
TableContext.displayName = "TableContext", exports.withTableInstance = withTableInstance,
|
|
24
|
+
exports.default = TableContext;
|
|
25
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["context/table.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAS1B,MAAM,YAAY,GAAG,eAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AACjE,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,SAAgB,iBAAiB,CAAI,SAAiC;IACpE,MAAM,GAAG,GAAG,eAAK,CAAC,UAAU,CAAS,CAAC,KAAQ,EAAE,GAAG,EAAE,EAAE;QACrD,OAAO,CACL,8BAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,GAAqB,EAAE,EAAE,CAAC,8BAAC,SAAS,kBAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,IAAM,KAAK,EAAI,CAC1D,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC;AAVD,8CAUC;AAED,kBAAe,YAAY,CAAC","file":"table.js","sourcesContent":["import React from 'react';\nimport type { ListTable, PivotTable, PivotChart } from './../../../vtable/src/index.ts';\n\nexport interface TableContextType {\n table?: ListTable | PivotTable | PivotChart;\n optionFromChildren: any;\n isChildrenUpdated?: boolean;\n}\n\nconst TableContext = React.createContext<TableContextType>(null);\nTableContext.displayName = 'TableContext';\n\nexport function withTableInstance<T>(Component: typeof React.Component) {\n const Com = React.forwardRef<any, T>((props: T, ref) => {\n return (\n <TableContext.Consumer>\n {(ctx: TableContextType) => <Component ref={ref} table={ctx.table} {...props} />}\n </TableContext.Consumer>\n );\n });\n Com.displayName = Component.name;\n return Com;\n}\n\nexport default TableContext;\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { IVTable } from './tables/base-table';
|
|
2
|
+
import type { TableEventHandlersEventArgumentMap } from './../../vtable/src/index.ts/src/ts-types';
|
|
3
|
+
export type EventCallback<Params> = (params: Params) => void;
|
|
4
|
+
export interface EventsProps {
|
|
5
|
+
onClickCell?: EventCallback<TableEventHandlersEventArgumentMap['click_cell']>;
|
|
6
|
+
onDblClickCell?: EventCallback<TableEventHandlersEventArgumentMap['dblclick_cell']>;
|
|
7
|
+
onMouseDownCell?: EventCallback<TableEventHandlersEventArgumentMap['mousedown_cell']>;
|
|
8
|
+
onMouseUpCell?: EventCallback<TableEventHandlersEventArgumentMap['mouseup_cell']>;
|
|
9
|
+
onSelectedCell?: EventCallback<TableEventHandlersEventArgumentMap['selected_cell']>;
|
|
10
|
+
onKeyDown?: EventCallback<TableEventHandlersEventArgumentMap['keydown']>;
|
|
11
|
+
onMouseEnterTable?: EventCallback<TableEventHandlersEventArgumentMap['mouseenter_table']>;
|
|
12
|
+
onMouseLeaveTable?: EventCallback<TableEventHandlersEventArgumentMap['mouseleave_table']>;
|
|
13
|
+
onMouseMoveCell?: EventCallback<TableEventHandlersEventArgumentMap['mousemove_cell']>;
|
|
14
|
+
onMouseEnterCell?: EventCallback<TableEventHandlersEventArgumentMap['mouseenter_cell']>;
|
|
15
|
+
onMouseLeaveCell?: EventCallback<TableEventHandlersEventArgumentMap['mouseleave_cell']>;
|
|
16
|
+
onContextMenuCell?: EventCallback<TableEventHandlersEventArgumentMap['contextmenu_cell']>;
|
|
17
|
+
onResizeColumn?: EventCallback<TableEventHandlersEventArgumentMap['resize_column']>;
|
|
18
|
+
onResizeColumnEnd?: EventCallback<TableEventHandlersEventArgumentMap['resize_column_end']>;
|
|
19
|
+
onChangeHeaderPosition?: EventCallback<TableEventHandlersEventArgumentMap['change_header_position']>;
|
|
20
|
+
onSortClick?: EventCallback<TableEventHandlersEventArgumentMap['sort_click']>;
|
|
21
|
+
onFreezeClick?: EventCallback<TableEventHandlersEventArgumentMap['freeze_click']>;
|
|
22
|
+
onScroll?: EventCallback<TableEventHandlersEventArgumentMap['scroll']>;
|
|
23
|
+
onDropdownMenuClick?: EventCallback<TableEventHandlersEventArgumentMap['dropdown_menu_click']>;
|
|
24
|
+
onMouseOverChartSymbol?: EventCallback<TableEventHandlersEventArgumentMap['mouseover_chart_symbol']>;
|
|
25
|
+
onDragSelectEnd?: EventCallback<TableEventHandlersEventArgumentMap['drag_select_end']>;
|
|
26
|
+
onDropdownIconClick?: EventCallback<TableEventHandlersEventArgumentMap['dropdown_icon_click']>;
|
|
27
|
+
onDropdownMenuClear?: EventCallback<TableEventHandlersEventArgumentMap['dropdown_menu_clear']>;
|
|
28
|
+
onTreeHierarchyStateChange?: EventCallback<TableEventHandlersEventArgumentMap['tree_hierarchy_state_change']>;
|
|
29
|
+
onShowMenu?: EventCallback<TableEventHandlersEventArgumentMap['show_menu']>;
|
|
30
|
+
onHideMenu?: EventCallback<TableEventHandlersEventArgumentMap['hide_menu']>;
|
|
31
|
+
onIconClick?: EventCallback<TableEventHandlersEventArgumentMap['icon_click']>;
|
|
32
|
+
onLegendItemClick?: EventCallback<TableEventHandlersEventArgumentMap['legend_item_click']>;
|
|
33
|
+
onLegendItemHover?: EventCallback<TableEventHandlersEventArgumentMap['legend_item_hover']>;
|
|
34
|
+
onLegendItemUnHover?: EventCallback<TableEventHandlersEventArgumentMap['legend_item_unHover']>;
|
|
35
|
+
onLegendChange?: EventCallback<TableEventHandlersEventArgumentMap['legend_change']>;
|
|
36
|
+
onMouseEnterAxis?: EventCallback<TableEventHandlersEventArgumentMap['mouseenter_axis']>;
|
|
37
|
+
onMouseLeaveAxis?: EventCallback<TableEventHandlersEventArgumentMap['mouseleave_axis']>;
|
|
38
|
+
onCheckboxStateChange?: EventCallback<TableEventHandlersEventArgumentMap['checkbox_state_change']>;
|
|
39
|
+
onAfterRender?: EventCallback<TableEventHandlersEventArgumentMap['after_render']>;
|
|
40
|
+
onInitialized?: EventCallback<TableEventHandlersEventArgumentMap['initialized']>;
|
|
41
|
+
onPivotSortClick?: EventCallback<TableEventHandlersEventArgumentMap['pivot_sort_click']>;
|
|
42
|
+
onDrillMenuClick?: EventCallback<TableEventHandlersEventArgumentMap['drillmenu_click']>;
|
|
43
|
+
onVChartEventType?: EventCallback<TableEventHandlersEventArgumentMap['vchart_event_type']>;
|
|
44
|
+
}
|
|
45
|
+
export declare const TABLE_EVENTS: {
|
|
46
|
+
onClickCell: any;
|
|
47
|
+
onDblClickCell: any;
|
|
48
|
+
onMouseDownCell: any;
|
|
49
|
+
onMouseUpCell: any;
|
|
50
|
+
onSelectedCell: any;
|
|
51
|
+
onKeyDown: any;
|
|
52
|
+
onMouseEnterTable: any;
|
|
53
|
+
onMouseLeaveTable: any;
|
|
54
|
+
onMouseMoveCell: any;
|
|
55
|
+
onMouseEnterCell: any;
|
|
56
|
+
onMouseLeaveCell: any;
|
|
57
|
+
onContextMenuCell: any;
|
|
58
|
+
onResizeColumn: any;
|
|
59
|
+
onResizeColumnEnd: any;
|
|
60
|
+
onChangeHeaderPosition: any;
|
|
61
|
+
onSortClick: any;
|
|
62
|
+
onFreezeClick: any;
|
|
63
|
+
onScroll: any;
|
|
64
|
+
onDropdownMenuClick: any;
|
|
65
|
+
onMouseOverChartSymbol: any;
|
|
66
|
+
onDragSelectEnd: any;
|
|
67
|
+
onDropdownIconClick: any;
|
|
68
|
+
onDropdownMenuClear: any;
|
|
69
|
+
onTreeHierarchyStateChange: any;
|
|
70
|
+
onShowMenu: any;
|
|
71
|
+
onHideMenu: any;
|
|
72
|
+
onIconClick: any;
|
|
73
|
+
onLegendItemClick: any;
|
|
74
|
+
onLegendItemHover: any;
|
|
75
|
+
onLegendItemUnHover: any;
|
|
76
|
+
onLegendChange: any;
|
|
77
|
+
onMouseEnterAxis: any;
|
|
78
|
+
onMouseLeaveAxis: any;
|
|
79
|
+
onCheckboxStateChange: any;
|
|
80
|
+
onAfterRender: any;
|
|
81
|
+
onInitialized: any;
|
|
82
|
+
onPivotSortClick: any;
|
|
83
|
+
onDrillMenuClick: any;
|
|
84
|
+
onVChartEventType: any;
|
|
85
|
+
};
|
|
86
|
+
export declare const TABLE_EVENTS_KEYS: string[];
|
|
87
|
+
export declare const findEventProps: <T extends EventsProps>(props: T, supportedEvents?: Record<string, string>) => EventsProps;
|
|
88
|
+
export declare const bindEventsToTable: <T>(table: IVTable, newProps?: T, prevProps?: T, supportedEvents?: Record<string, string>) => boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.bindEventsToTable = exports.findEventProps = exports.TABLE_EVENTS_KEYS = exports.TABLE_EVENTS = void 0;
|
|
6
|
+
|
|
7
|
+
const index_ts_1 = require("./../../vtable/src/index.ts"), EVENT_TYPE = Object.assign(Object.assign(Object.assign({}, index_ts_1.ListTable.EVENT_TYPE), index_ts_1.PivotTable.EVENT_TYPE), index_ts_1.PivotChart.EVENT_TYPE);
|
|
8
|
+
|
|
9
|
+
exports.TABLE_EVENTS = {
|
|
10
|
+
onClickCell: EVENT_TYPE.CLICK_CELL,
|
|
11
|
+
onDblClickCell: EVENT_TYPE.DBLCLICK_CELL,
|
|
12
|
+
onMouseDownCell: EVENT_TYPE.MOUSEDOWN_CELL,
|
|
13
|
+
onMouseUpCell: EVENT_TYPE.MOUSEUP_CELL,
|
|
14
|
+
onSelectedCell: EVENT_TYPE.SELECTED_CELL,
|
|
15
|
+
onKeyDown: EVENT_TYPE.KEYDOWN,
|
|
16
|
+
onMouseEnterTable: EVENT_TYPE.MOUSEENTER_TABLE,
|
|
17
|
+
onMouseLeaveTable: EVENT_TYPE.MOUSELEAVE_TABLE,
|
|
18
|
+
onMouseMoveCell: EVENT_TYPE.MOUSEMOVE_CELL,
|
|
19
|
+
onMouseEnterCell: EVENT_TYPE.MOUSEENTER_CELL,
|
|
20
|
+
onMouseLeaveCell: EVENT_TYPE.MOUSELEAVE_CELL,
|
|
21
|
+
onContextMenuCell: EVENT_TYPE.CONTEXTMENU_CELL,
|
|
22
|
+
onResizeColumn: EVENT_TYPE.RESIZE_COLUMN,
|
|
23
|
+
onResizeColumnEnd: EVENT_TYPE.RESIZE_COLUMN_END,
|
|
24
|
+
onChangeHeaderPosition: EVENT_TYPE.CHANGE_HEADER_POSITION,
|
|
25
|
+
onSortClick: EVENT_TYPE.SORT_CLICK,
|
|
26
|
+
onFreezeClick: EVENT_TYPE.FREEZE_CLICK,
|
|
27
|
+
onScroll: EVENT_TYPE.SCROLL,
|
|
28
|
+
onDropdownMenuClick: EVENT_TYPE.DROPDOWN_MENU_CLICK,
|
|
29
|
+
onMouseOverChartSymbol: EVENT_TYPE.MOUSEOVER_CHART_SYMBOL,
|
|
30
|
+
onDragSelectEnd: EVENT_TYPE.DRAG_SELECT_END,
|
|
31
|
+
onDropdownIconClick: EVENT_TYPE.DROPDOWN_ICON_CLICK,
|
|
32
|
+
onDropdownMenuClear: EVENT_TYPE.DROPDOWN_MENU_CLEAR,
|
|
33
|
+
onTreeHierarchyStateChange: EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE,
|
|
34
|
+
onShowMenu: EVENT_TYPE.SHOW_MENU,
|
|
35
|
+
onHideMenu: EVENT_TYPE.HIDE_MENU,
|
|
36
|
+
onIconClick: EVENT_TYPE.ICON_CLICK,
|
|
37
|
+
onLegendItemClick: EVENT_TYPE.LEGEND_ITEM_CLICK,
|
|
38
|
+
onLegendItemHover: EVENT_TYPE.LEGEND_ITEM_HOVER,
|
|
39
|
+
onLegendItemUnHover: EVENT_TYPE.LEGEND_ITEM_UNHOVER,
|
|
40
|
+
onLegendChange: EVENT_TYPE.LEGEND_CHANGE,
|
|
41
|
+
onMouseEnterAxis: EVENT_TYPE.MOUSEENTER_AXIS,
|
|
42
|
+
onMouseLeaveAxis: EVENT_TYPE.MOUSELEAVE_AXIS,
|
|
43
|
+
onCheckboxStateChange: EVENT_TYPE.CHECKBOX_STATE_CHANGE,
|
|
44
|
+
onAfterRender: EVENT_TYPE.AFTER_RENDER,
|
|
45
|
+
onInitialized: EVENT_TYPE.INITIALIZED,
|
|
46
|
+
onPivotSortClick: EVENT_TYPE.PIVOT_SORT_CLICK,
|
|
47
|
+
onDrillMenuClick: EVENT_TYPE.DRILLMENU_CLICK,
|
|
48
|
+
onVChartEventType: EVENT_TYPE.VCHART_EVENT_TYPE
|
|
49
|
+
}, exports.TABLE_EVENTS_KEYS = Object.keys(exports.TABLE_EVENTS);
|
|
50
|
+
|
|
51
|
+
const findEventProps = (props, supportedEvents = exports.TABLE_EVENTS) => {
|
|
52
|
+
const result = {};
|
|
53
|
+
return Object.keys(props).forEach((key => {
|
|
54
|
+
supportedEvents[key] && (result[key] = props[key]);
|
|
55
|
+
})), result;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.findEventProps = findEventProps;
|
|
59
|
+
|
|
60
|
+
const bindEventsToTable = (table, newProps, prevProps, supportedEvents = exports.TABLE_EVENTS) => {
|
|
61
|
+
if (!newProps && !prevProps || !table) return !1;
|
|
62
|
+
const prevEventProps = prevProps ? (0, exports.findEventProps)(prevProps, supportedEvents) : null, newEventProps = newProps ? (0,
|
|
63
|
+
exports.findEventProps)(newProps, supportedEvents) : null;
|
|
64
|
+
return prevEventProps && Object.keys(prevEventProps).forEach((eventKey => {
|
|
65
|
+
newEventProps && newEventProps[eventKey] && newEventProps[eventKey] === prevEventProps[eventKey] || table.off(supportedEvents[eventKey], prevProps[eventKey]);
|
|
66
|
+
})), newEventProps && Object.keys(newEventProps).forEach((eventKey => {
|
|
67
|
+
prevEventProps && prevEventProps[eventKey] && prevEventProps[eventKey] === newEventProps[eventKey] || table.on(supportedEvents[eventKey], newEventProps[eventKey]);
|
|
68
|
+
})), !0;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
exports.bindEventsToTable = bindEventsToTable;
|
|
72
|
+
//# sourceMappingURL=eventsUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["eventsUtils.ts"],"names":[],"mappings":";;;AAAA,0DAAgF;AAMhF,MAAM,UAAU,iDACX,oBAAS,CAAC,UAAU,GACpB,qBAAU,CAAC,UAAU,GACrB,qBAAU,CAAC,UAAU,CACzB,CAAC;AAuDW,QAAA,YAAY,GAAG;IAC1B,WAAW,EAAE,UAAU,CAAC,UAAU;IAClC,cAAc,EAAE,UAAU,CAAC,aAAa;IACxC,eAAe,EAAE,UAAU,CAAC,cAAc;IAC1C,aAAa,EAAE,UAAU,CAAC,YAAY;IACtC,cAAc,EAAE,UAAU,CAAC,aAAa;IACxC,SAAS,EAAE,UAAU,CAAC,OAAO;IAC7B,iBAAiB,EAAE,UAAU,CAAC,gBAAgB;IAC9C,iBAAiB,EAAE,UAAU,CAAC,gBAAgB;IAC9C,eAAe,EAAE,UAAU,CAAC,cAAc;IAC1C,gBAAgB,EAAE,UAAU,CAAC,eAAe;IAC5C,gBAAgB,EAAE,UAAU,CAAC,eAAe;IAC5C,iBAAiB,EAAE,UAAU,CAAC,gBAAgB;IAC9C,cAAc,EAAE,UAAU,CAAC,aAAa;IACxC,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;IAC/C,sBAAsB,EAAE,UAAU,CAAC,sBAAsB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C,EAAE;gBACxG,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,CAA6C,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC1G;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AA9BW,QAAA,iBAAiB,qBA8B5B","file":"eventsUtils.js","sourcesContent":["import { ListTable, PivotTable, PivotChart } from './../../vtable/src/index.ts';\nimport type { IVTable } from './tables/base-table';\nimport type { TableEventHandlersEventArgumentMap } from './../../vtable/src/index.ts/src/ts-types';\n\nexport type EventCallback<Params> = (params: Params) => void;\n\nconst EVENT_TYPE = {\n ...ListTable.EVENT_TYPE,\n ...PivotTable.EVENT_TYPE,\n ...PivotChart.EVENT_TYPE\n};\n\nexport interface EventsProps {\n onClickCell?: EventCallback<TableEventHandlersEventArgumentMap['click_cell']>;\n onDblClickCell?: EventCallback<TableEventHandlersEventArgumentMap['dblclick_cell']>;\n onMouseDownCell?: EventCallback<TableEventHandlersEventArgumentMap['mousedown_cell']>;\n onMouseUpCell?: EventCallback<TableEventHandlersEventArgumentMap['mouseup_cell']>;\n onSelectedCell?: EventCallback<TableEventHandlersEventArgumentMap['selected_cell']>;\n onKeyDown?: EventCallback<TableEventHandlersEventArgumentMap['keydown']>;\n onMouseEnterTable?: EventCallback<TableEventHandlersEventArgumentMap['mouseenter_table']>;\n onMouseLeaveTable?: EventCallback<TableEventHandlersEventArgumentMap['mouseleave_table']>;\n onMouseMoveCell?: EventCallback<TableEventHandlersEventArgumentMap['mousemove_cell']>;\n onMouseEnterCell?: EventCallback<TableEventHandlersEventArgumentMap['mouseenter_cell']>;\n onMouseLeaveCell?: EventCallback<TableEventHandlersEventArgumentMap['mouseleave_cell']>;\n onContextMenuCell?: EventCallback<TableEventHandlersEventArgumentMap['contextmenu_cell']>;\n onResizeColumn?: EventCallback<TableEventHandlersEventArgumentMap['resize_column']>;\n onResizeColumnEnd?: EventCallback<TableEventHandlersEventArgumentMap['resize_column_end']>;\n onChangeHeaderPosition?: EventCallback<TableEventHandlersEventArgumentMap['change_header_position']>;\n onSortClick?: EventCallback<TableEventHandlersEventArgumentMap['sort_click']>;\n onFreezeClick?: EventCallback<TableEventHandlersEventArgumentMap['freeze_click']>;\n onScroll?: EventCallback<TableEventHandlersEventArgumentMap['scroll']>;\n onDropdownMenuClick?: EventCallback<TableEventHandlersEventArgumentMap['dropdown_menu_click']>;\n onMouseOverChartSymbol?: EventCallback<TableEventHandlersEventArgumentMap['mouseover_chart_symbol']>;\n onDragSelectEnd?: EventCallback<TableEventHandlersEventArgumentMap['drag_select_end']>;\n\n onDropdownIconClick?: EventCallback<TableEventHandlersEventArgumentMap['dropdown_icon_click']>;\n onDropdownMenuClear?: EventCallback<TableEventHandlersEventArgumentMap['dropdown_menu_clear']>;\n\n onTreeHierarchyStateChange?: EventCallback<TableEventHandlersEventArgumentMap['tree_hierarchy_state_change']>;\n\n onShowMenu?: EventCallback<TableEventHandlersEventArgumentMap['show_menu']>;\n onHideMenu?: EventCallback<TableEventHandlersEventArgumentMap['hide_menu']>;\n\n onIconClick?: EventCallback<TableEventHandlersEventArgumentMap['icon_click']>;\n\n onLegendItemClick?: EventCallback<TableEventHandlersEventArgumentMap['legend_item_click']>;\n onLegendItemHover?: EventCallback<TableEventHandlersEventArgumentMap['legend_item_hover']>;\n onLegendItemUnHover?: EventCallback<TableEventHandlersEventArgumentMap['legend_item_unHover']>;\n onLegendChange?: EventCallback<TableEventHandlersEventArgumentMap['legend_change']>;\n\n onMouseEnterAxis?: EventCallback<TableEventHandlersEventArgumentMap['mouseenter_axis']>;\n onMouseLeaveAxis?: EventCallback<TableEventHandlersEventArgumentMap['mouseleave_axis']>;\n\n onCheckboxStateChange?: EventCallback<TableEventHandlersEventArgumentMap['checkbox_state_change']>;\n onAfterRender?: EventCallback<TableEventHandlersEventArgumentMap['after_render']>;\n onInitialized?: EventCallback<TableEventHandlersEventArgumentMap['initialized']>;\n\n // pivot table only\n onPivotSortClick?: EventCallback<TableEventHandlersEventArgumentMap['pivot_sort_click']>;\n onDrillMenuClick?: EventCallback<TableEventHandlersEventArgumentMap['drillmenu_click']>;\n\n // pivot chart only\n onVChartEventType?: EventCallback<TableEventHandlersEventArgumentMap['vchart_event_type']>;\n}\n\nexport const TABLE_EVENTS = {\n onClickCell: EVENT_TYPE.CLICK_CELL,\n onDblClickCell: EVENT_TYPE.DBLCLICK_CELL,\n onMouseDownCell: EVENT_TYPE.MOUSEDOWN_CELL,\n onMouseUpCell: EVENT_TYPE.MOUSEUP_CELL,\n onSelectedCell: EVENT_TYPE.SELECTED_CELL,\n onKeyDown: EVENT_TYPE.KEYDOWN,\n onMouseEnterTable: EVENT_TYPE.MOUSEENTER_TABLE,\n onMouseLeaveTable: EVENT_TYPE.MOUSELEAVE_TABLE,\n onMouseMoveCell: EVENT_TYPE.MOUSEMOVE_CELL,\n onMouseEnterCell: EVENT_TYPE.MOUSEENTER_CELL,\n onMouseLeaveCell: EVENT_TYPE.MOUSELEAVE_CELL,\n onContextMenuCell: EVENT_TYPE.CONTEXTMENU_CELL,\n onResizeColumn: EVENT_TYPE.RESIZE_COLUMN,\n onResizeColumnEnd: EVENT_TYPE.RESIZE_COLUMN_END,\n onChangeHeaderPosition: EVENT_TYPE.CHANGE_HEADER_POSITION,\n onSortClick: EVENT_TYPE.SORT_CLICK,\n onFreezeClick: EVENT_TYPE.FREEZE_CLICK,\n onScroll: EVENT_TYPE.SCROLL,\n onDropdownMenuClick: EVENT_TYPE.DROPDOWN_MENU_CLICK,\n onMouseOverChartSymbol: EVENT_TYPE.MOUSEOVER_CHART_SYMBOL,\n onDragSelectEnd: EVENT_TYPE.DRAG_SELECT_END,\n\n onDropdownIconClick: EVENT_TYPE.DROPDOWN_ICON_CLICK,\n onDropdownMenuClear: EVENT_TYPE.DROPDOWN_MENU_CLEAR,\n\n onTreeHierarchyStateChange: EVENT_TYPE.TREE_HIERARCHY_STATE_CHANGE,\n\n onShowMenu: EVENT_TYPE.SHOW_MENU,\n onHideMenu: EVENT_TYPE.HIDE_MENU,\n\n onIconClick: EVENT_TYPE.ICON_CLICK,\n\n onLegendItemClick: EVENT_TYPE.LEGEND_ITEM_CLICK,\n onLegendItemHover: EVENT_TYPE.LEGEND_ITEM_HOVER,\n onLegendItemUnHover: EVENT_TYPE.LEGEND_ITEM_UNHOVER,\n onLegendChange: EVENT_TYPE.LEGEND_CHANGE,\n\n onMouseEnterAxis: EVENT_TYPE.MOUSEENTER_AXIS,\n onMouseLeaveAxis: EVENT_TYPE.MOUSELEAVE_AXIS,\n\n onCheckboxStateChange: EVENT_TYPE.CHECKBOX_STATE_CHANGE,\n onAfterRender: EVENT_TYPE.AFTER_RENDER,\n onInitialized: EVENT_TYPE.INITIALIZED,\n\n // pivot table only\n onPivotSortClick: EVENT_TYPE.PIVOT_SORT_CLICK,\n onDrillMenuClick: EVENT_TYPE.DRILLMENU_CLICK,\n\n // pivot chart only\n onVChartEventType: EVENT_TYPE.VCHART_EVENT_TYPE\n};\n\nexport const TABLE_EVENTS_KEYS = Object.keys(TABLE_EVENTS);\n\nexport const findEventProps = <T extends EventsProps>(\n props: T,\n supportedEvents: Record<string, string> = TABLE_EVENTS\n): EventsProps => {\n const result: EventsProps = {};\n\n Object.keys(props).forEach(key => {\n if (supportedEvents[key]) {\n result[key] = props[key];\n }\n });\n\n return result;\n};\n\nexport const bindEventsToTable = <T>(\n table: IVTable,\n newProps?: T | null,\n prevProps?: T | null,\n supportedEvents: Record<string, string> = TABLE_EVENTS\n) => {\n if ((!newProps && !prevProps) || !table) {\n return false;\n }\n\n const prevEventProps = prevProps ? findEventProps(prevProps, supportedEvents) : null;\n const newEventProps = newProps ? findEventProps(newProps, supportedEvents) : null;\n\n if (prevEventProps) {\n Object.keys(prevEventProps).forEach(eventKey => {\n if (!newEventProps || !newEventProps[eventKey] || newEventProps[eventKey] !== prevEventProps[eventKey]) {\n table.off(supportedEvents[eventKey], prevProps[eventKey]);\n }\n });\n }\n\n if (newEventProps) {\n Object.keys(newEventProps).forEach(eventKey => {\n if (!prevEventProps || !prevEventProps[eventKey] || prevEventProps[eventKey] !== newEventProps[eventKey]) {\n table.on(supportedEvents[eventKey] as keyof TableEventHandlersEventArgumentMap, newEventProps[eventKey]);\n }\n });\n }\n\n return true;\n};\n"]}
|
package/cjs/index.d.ts
ADDED
package/cjs/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
15
|
+
for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), __exportStar(require("./tables"), exports), __exportStar(require("./components"), exports);
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B","file":"index.js","sourcesContent":["export * from './tables';\nexport * from './components';\n"]}
|
package/cjs/index_old.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = this && this.__rest || function(s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
6
|
+
if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
|
|
7
|
+
var i = 0;
|
|
8
|
+
for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
}, __importDefault = this && this.__importDefault || function(mod) {
|
|
12
|
+
return mod && mod.__esModule ? mod : {
|
|
13
|
+
default: mod
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
Object.defineProperty(exports, "__esModule", {
|
|
18
|
+
value: !0
|
|
19
|
+
}), exports.ReactVTable = void 0;
|
|
20
|
+
|
|
21
|
+
const index_ts_1 = require("./../../vtable/src/index.ts"), react_1 = __importDefault(require("react")), react_2 = require("react"), ReactVTable = props => {
|
|
22
|
+
const {type: type, option: option, height: height = "100%", style: style} = props, restProps = __rest(props, [ "type", "option", "height", "style" ]), containerRef = (0,
|
|
23
|
+
react_2.useRef)(null);
|
|
24
|
+
return (0, react_2.useEffect)((() => {
|
|
25
|
+
containerRef.current && (option.container = containerRef.current, new index_ts_1.ListTable(option));
|
|
26
|
+
}), [ option, type ]), react_1.default.createElement("div", Object.assign({
|
|
27
|
+
style: Object.assign(Object.assign({}, style), {
|
|
28
|
+
height: height
|
|
29
|
+
})
|
|
30
|
+
}, restProps, {
|
|
31
|
+
ref: containerRef,
|
|
32
|
+
id: "react-VTable"
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.ReactVTable = ReactVTable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index_old.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,0DAAwD;AAExD,kDAA0B;AAC1B,iCAA0C;AAInC,MAAM,WAAW,GAAc,KAAK,CAAC,EAAE;IAC5C,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAA9D,qCAAsD,CAAQ,CAAC;IACrE,MAAM,YAAY,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAElD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;YACxC,IAAI,oBAAS,CAAC,MAAM,CAAC,CAAC;SACvB;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,qDACE,KAAK,kCACA,KAAK,KACR,MAAM,OAEJ,SAAS,IACb,GAAG,EAAE,YAAY,EACjB,EAAE,EAAC,cAAc,IACjB,CACH,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,WAAW,eAsBtB","file":"index_old.js","sourcesContent":["/* eslint-disable @typescript-eslint/no-duplicate-imports */\n/* eslint-disable @typescript-eslint/consistent-type-imports */\nimport { ListTable } from './../../vtable/src/index.ts';\nimport type { FC } from 'react';\nimport React from 'react';\nimport { useEffect, useRef } from 'react';\n\ntype Props = React.PropsWithChildren<any>;\n\nexport const ReactVTable: FC<Props> = props => {\n const { type, option, height = '100%', style, ...restProps } = props;\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (containerRef.current) {\n option.container = containerRef.current;\n new ListTable(option);\n }\n }, [option, type]);\n\n return (\n <div\n style={{\n ...style,\n height\n }}\n {...restProps}\n ref={containerRef}\n id=\"react-VTable\"\n />\n );\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as VTable from './../../../vtable/src/index.ts';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { ContainerProps } from '../containers/withContainer';
|
|
4
|
+
import type { EventsProps } from '../eventsUtils';
|
|
5
|
+
export type IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;
|
|
6
|
+
export interface BaseTableProps extends EventsProps {
|
|
7
|
+
type?: string;
|
|
8
|
+
container?: HTMLDivElement;
|
|
9
|
+
option?: any;
|
|
10
|
+
records?: any;
|
|
11
|
+
width?: number;
|
|
12
|
+
height?: number;
|
|
13
|
+
skipFunctionDiff?: boolean;
|
|
14
|
+
onReady?: (instance: IVTable, isInitial: boolean) => void;
|
|
15
|
+
onError?: (err: Error) => void;
|
|
16
|
+
}
|
|
17
|
+
type Props = React.PropsWithChildren<BaseTableProps>;
|
|
18
|
+
export declare const createTable: <T extends Props>(componentName: string, type?: string, callback?: (props: T) => T) => React.ForwardRefExoticComponent<React.PropsWithoutRef<T & ContainerProps> & React.RefAttributes<any>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", {
|
|
16
|
+
enumerable: !0,
|
|
17
|
+
value: v
|
|
18
|
+
});
|
|
19
|
+
} : function(o, v) {
|
|
20
|
+
o.default = v;
|
|
21
|
+
}), __importStar = this && this.__importStar || function(mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
|
|
25
|
+
return __setModuleDefault(result, mod), result;
|
|
26
|
+
}, __importDefault = this && this.__importDefault || function(mod) {
|
|
27
|
+
return mod && mod.__esModule ? mod : {
|
|
28
|
+
default: mod
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
Object.defineProperty(exports, "__esModule", {
|
|
33
|
+
value: !0
|
|
34
|
+
}), exports.createTable = void 0;
|
|
35
|
+
|
|
36
|
+
const VTable = __importStar(require("./../../../vtable/src/index.ts")), react_1 = __importStar(require("react")), withContainer_1 = __importDefault(require("../containers/withContainer")), table_1 = __importDefault(require("../context/table")), vutils_1 = require("@visactor/vutils"), util_1 = require("../util"), constants_1 = require("../constants"), eventsUtils_1 = require("../eventsUtils"), notOptionKeys = [ ...constants_1.REACT_PRIVATE_PROPS, ...eventsUtils_1.TABLE_EVENTS_KEYS, "skipFunctionDiff", "onError", "onReady", "option", "records", "container" ], BaseTable = react_1.default.forwardRef(((props, ref) => {
|
|
37
|
+
const [updateId, setUpdateId] = (0, react_1.useState)(0), tableContext = (0, react_1.useRef)({
|
|
38
|
+
optionFromChildren: {}
|
|
39
|
+
});
|
|
40
|
+
(0, react_1.useImperativeHandle)(ref, (() => tableContext.current.table));
|
|
41
|
+
const hasOption = !!props.option, hasRecords = !!props.records, isUnmount = (0,
|
|
42
|
+
react_1.useRef)(!1), prevOption = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notOptionKeys)), prevRecords = (0,
|
|
43
|
+
react_1.useRef)(props.records), eventsBinded = react_1.default.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, parseOption = (0,
|
|
44
|
+
react_1.useCallback)((props => hasOption && props.option ? hasRecords && props.records ? Object.assign(Object.assign({}, props.option), {
|
|
45
|
+
records: props.records
|
|
46
|
+
}) : props.option : Object.assign(Object.assign({
|
|
47
|
+
records: props.records
|
|
48
|
+
}, prevOption.current), tableContext.current.optionFromChildren)), [ hasOption, hasRecords ]), createTable = (0,
|
|
49
|
+
react_1.useCallback)((props => {
|
|
50
|
+
let vtable;
|
|
51
|
+
vtable = "pivot-table" === props.type ? new VTable.PivotTable(props.container, parseOption(props)) : "pivot-chart" === props.type ? new VTable.PivotChart(props.container, parseOption(props)) : new VTable.ListTable(props.container, parseOption(props)),
|
|
52
|
+
tableContext.current = Object.assign(Object.assign({}, tableContext.current), {
|
|
53
|
+
table: vtable
|
|
54
|
+
});
|
|
55
|
+
}), [ parseOption ]), handleTableRender = (0, react_1.useCallback)((() => {
|
|
56
|
+
(0, eventsUtils_1.bindEventsToTable)(tableContext.current.table, props, eventsBinded.current, eventsUtils_1.TABLE_EVENTS),
|
|
57
|
+
isUnmount.current || (setUpdateId(updateId + 1), props.onReady && props.onReady(tableContext.current.table, 0 === updateId));
|
|
58
|
+
}), [ updateId, setUpdateId, props ]), renderTable = (0, react_1.useCallback)((() => {
|
|
59
|
+
if (tableContext.current.table) {
|
|
60
|
+
const renderPromise = tableContext.current.table.renderAsync().then(handleTableRender);
|
|
61
|
+
props.onError && renderPromise.catch(props.onError);
|
|
62
|
+
}
|
|
63
|
+
}), [ handleTableRender, props ]);
|
|
64
|
+
return (0, react_1.useEffect)((() => {
|
|
65
|
+
if (!tableContext.current.table) return createTable(props), renderTable(), (0, eventsUtils_1.bindEventsToTable)(tableContext.current.table, props, null, eventsUtils_1.TABLE_EVENTS),
|
|
66
|
+
tableContext.current = Object.assign(Object.assign({}, tableContext.current), {
|
|
67
|
+
isChildrenUpdated: !1
|
|
68
|
+
}), void (eventsBinded.current = props);
|
|
69
|
+
if (hasOption) {
|
|
70
|
+
if ((0, vutils_1.isEqual)(eventsBinded.current.option, props.option, {
|
|
71
|
+
skipFunction: skipFunctionDiff
|
|
72
|
+
})) {
|
|
73
|
+
if (hasRecords && !(0, vutils_1.isEqual)(eventsBinded.current.records, props.records, {
|
|
74
|
+
skipFunction: skipFunctionDiff
|
|
75
|
+
})) {
|
|
76
|
+
eventsBinded.current = props, tableContext.current.table.setRecords(props.records);
|
|
77
|
+
const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
|
|
78
|
+
props.onError && updatePromise.catch(props.onError);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
eventsBinded.current = props, tableContext.current.table.updateOption(parseOption(props));
|
|
82
|
+
const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
|
|
83
|
+
props.onError && updatePromise.catch(props.onError);
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const newOption = (0, vutils_1.pickWithout)(props, notOptionKeys);
|
|
88
|
+
if (!(0, vutils_1.isEqual)(newOption, prevOption.current, {
|
|
89
|
+
skipFunction: skipFunctionDiff
|
|
90
|
+
}) || tableContext.current.isChildrenUpdated) {
|
|
91
|
+
prevOption.current = newOption, tableContext.current.table.updateOption(parseOption(props));
|
|
92
|
+
const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
|
|
93
|
+
props.onError && updatePromise.catch(props.onError);
|
|
94
|
+
} else if (hasRecords && !(0, vutils_1.isEqual)(props.records, prevRecords.current, {
|
|
95
|
+
skipFunction: skipFunctionDiff
|
|
96
|
+
})) {
|
|
97
|
+
prevRecords.current = props.records, tableContext.current.table.setRecords(props.records);
|
|
98
|
+
const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
|
|
99
|
+
props.onError && updatePromise.catch(props.onError);
|
|
100
|
+
}
|
|
101
|
+
tableContext.current = Object.assign(Object.assign({}, tableContext.current), {
|
|
102
|
+
isChildrenUpdated: !1
|
|
103
|
+
});
|
|
104
|
+
}), [ createTable, hasOption, hasRecords, parseOption, handleTableRender, renderTable, skipFunctionDiff, props ]),
|
|
105
|
+
(0, react_1.useEffect)((() => () => {
|
|
106
|
+
tableContext && (tableContext.current.table && tableContext.current.table.release(),
|
|
107
|
+
tableContext.current = null), isUnmount.current = !0;
|
|
108
|
+
}), []), react_1.default.createElement(table_1.default.Provider, {
|
|
109
|
+
value: tableContext.current
|
|
110
|
+
}, (0, util_1.toArray)(props.children).map(((child, index) => {
|
|
111
|
+
var _a, _b, _c;
|
|
112
|
+
return react_1.default.createElement(react_1.default.Fragment, {
|
|
113
|
+
key: null !== (_c = null !== (_b = null === (_a = null == child ? void 0 : child.props) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : null == child ? void 0 : child.id) && void 0 !== _c ? _c : `child-${index}`
|
|
114
|
+
}, react_1.default.cloneElement(child, {
|
|
115
|
+
updateId: updateId
|
|
116
|
+
}));
|
|
117
|
+
})));
|
|
118
|
+
})), createTable = (componentName, type, callback) => {
|
|
119
|
+
const Com = (0, withContainer_1.default)(BaseTable, componentName, (props => (props.type = type,
|
|
120
|
+
callback ? callback(props) : type ? Object.assign(Object.assign({}, props), {
|
|
121
|
+
type: type
|
|
122
|
+
}) : props)));
|
|
123
|
+
return Com.displayName = componentName, Com;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
exports.createTable = createTable;
|
|
127
|
+
//# sourceMappingURL=base-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["tables/base-table.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,uEAAyD;AACzD,+CAA6F;AAE7F,gFAAwD;AAExD,6DAAgD;AAChD,6CAAwD;AACxD,kCAAkC;AAClC,4CAAmD;AAanD,gDAAoF;AA0BpF,MAAM,aAAa,GAAG;IACpB,GAAG,+BAAmB;IACtB,GAAG,+BAAiB;IACpB,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,WAAW;CACZ,CAAC;AAEF,MAAM,SAAS,GAAoB,eAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,g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L,KAAK,CAAU,EAAE,mCAAI,SAAS,KAAK,EAAE,IACrF,eAAK,CAAC,YAAY,CAAC,KAAqB,EAAE;YACzC,QAAQ,EAAE,QAAQ;SACnB,CAAC,CACa,CAClB,CAAC;IACJ,CAAC,CAAC,CACwB,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,MAAM,WAAW,GAAG,CAAkB,aAAqB,EAAE,IAAa,EAAE,QAA0B,EAAE,EAAE;IAC/G,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAQ,EAAE,EAAE;QACzF,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAElB,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;QAED,IAAI,IAAI,EAAE;YACR,uCAAY,KAAK,KAAE,IAAI,IAAG;SAC3B;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB","file":"base-table.js","sourcesContent":["/* eslint-disable react/display-name */\n// import type { IData, IInitOption, ISpec } from '@visactor/vchart';\n// import VChart from '@visactor/vchart';\nimport * as VTable from './../../../vtable/src/index.ts';\nimport React, { useState, useEffect, useRef, useImperativeHandle, useCallback } from 'react';\nimport type { ContainerProps } from '../containers/withContainer';\nimport withContainer from '../containers/withContainer';\nimport type { TableContextType } from '../context/table';\nimport RootTableContext from '../context/table';\nimport { isEqual, pickWithout } from '@visactor/vutils';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport type { IMarkElement } from '../components';\nimport type {\n EventsProps\n // LegendEventProps,\n // ScrollBarEventProps,\n // BrushEventProps,\n // DataZoomEventProps,\n // PlayerEventProps,\n // DimensionEventProps,\n // HierarchyEventProps,\n // TableLifeCycleEventProps\n} from '../eventsUtils';\nimport { bindEventsToTable, TABLE_EVENTS_KEYS, TABLE_EVENTS } from '../eventsUtils';\n\nexport type IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport interface BaseTableProps extends EventsProps {\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /** option */\n option?: any;\n /** 数据 */\n records?: any;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n skipFunctionDiff?: boolean;\n\n /** 表格渲染完成事件 */\n onReady?: (instance: IVTable, isInitial: boolean) => void;\n /** throw error when chart run into an error */\n onError?: (err: Error) => void;\n}\n\ntype Props = React.PropsWithChildren<BaseTableProps>;\n\nconst notOptionKeys = [\n ...REACT_PRIVATE_PROPS,\n ...TABLE_EVENTS_KEYS,\n 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'option',\n 'records',\n 'container'\n];\n\nconst BaseTable: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const tableContext = useRef<TableContextType>({\n optionFromChildren: {}\n });\n useImperativeHandle(ref, () => tableContext.current.table);\n const hasOption = !!props.option;\n const hasRecords = !!props.records;\n const isUnmount = useRef<boolean>(false);\n const prevOption = useRef(pickWithout(props, notOptionKeys));\n const prevRecords = useRef(props.records);\n const eventsBinded = React.useRef<BaseTableProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n\n const parseOption = useCallback(\n (props: Props) => {\n if (hasOption && props.option) {\n if (hasRecords && props.records) {\n return {\n ...props.option,\n records: props.records\n };\n }\n return props.option;\n }\n\n return {\n records: props.records,\n ...prevOption.current,\n ...tableContext.current.optionFromChildren\n };\n },\n [hasOption, hasRecords]\n );\n\n const createTable = useCallback(\n (props: Props) => {\n let vtable;\n if (props.type === 'pivot-table') {\n vtable = new VTable.PivotTable(props.container, parseOption(props));\n } else if (props.type === 'pivot-chart') {\n vtable = new VTable.PivotChart(props.container, parseOption(props));\n } else {\n vtable = new VTable.ListTable(props.container, parseOption(props));\n }\n tableContext.current = { ...tableContext.current, table: vtable };\n },\n [parseOption]\n );\n\n const handleTableRender = useCallback(() => {\n // rebind events after render\n bindEventsToTable(tableContext.current.table, props, eventsBinded.current, TABLE_EVENTS);\n\n if (!isUnmount.current) {\n // to be fixed\n // will cause another useEffect\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(tableContext.current.table, updateId === 0);\n }\n }\n }, [updateId, setUpdateId, props]);\n\n const renderTable = useCallback(() => {\n if (tableContext.current.table) {\n // eslint-disable-next-line promise/catch-or-return\n const renderPromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n renderPromise.catch(props.onError);\n }\n }\n }, [handleTableRender, props]);\n\n useEffect(() => {\n if (!tableContext.current.table) {\n createTable(props);\n renderTable();\n bindEventsToTable(tableContext.current.table, props, null, TABLE_EVENTS);\n tableContext.current = {\n ...tableContext.current,\n isChildrenUpdated: false\n };\n eventsBinded.current = props;\n return;\n }\n\n if (hasOption) {\n if (!isEqual(eventsBinded.current.option, props.option, { skipFunction: skipFunctionDiff })) {\n eventsBinded.current = props;\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(parseOption(props));\n const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n updatePromise.catch(props.onError);\n }\n } else if (\n hasRecords &&\n !isEqual(eventsBinded.current.records, props.records, { skipFunction: skipFunctionDiff })\n ) {\n eventsBinded.current = props;\n tableContext.current.table.setRecords(props.records);\n const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n updatePromise.catch(props.onError);\n }\n }\n return;\n }\n\n const newOption = pickWithout(props, notOptionKeys);\n\n if (\n !isEqual(newOption, prevOption.current, { skipFunction: skipFunctionDiff }) ||\n tableContext.current.isChildrenUpdated\n ) {\n prevOption.current = newOption;\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(parseOption(props));\n const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n updatePromise.catch(props.onError);\n }\n } else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {\n prevRecords.current = props.records;\n tableContext.current.table.setRecords(props.records);\n const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n updatePromise.catch(props.onError);\n }\n }\n tableContext.current = {\n ...tableContext.current,\n isChildrenUpdated: false\n };\n }, [createTable, hasOption, hasRecords, parseOption, handleTableRender, renderTable, skipFunctionDiff, props]);\n\n useEffect(() => {\n return () => {\n if (tableContext) {\n if (tableContext.current.table) {\n tableContext.current.table.release();\n }\n tableContext.current = null;\n }\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootTableContext.Provider value={tableContext.current}>\n {toArray(props.children).map((child: React.ReactNode, index: number) => {\n return (\n <React.Fragment key={(child as any)?.props?.id ?? (child as any)?.id ?? `child-${index}`}>\n {React.cloneElement(child as IMarkElement, {\n updateId: updateId\n })}\n </React.Fragment>\n );\n })}\n </RootTableContext.Provider>\n );\n});\n\nexport const createTable = <T extends Props>(componentName: string, type?: string, callback?: (props: T) => T) => {\n const Com = withContainer<ContainerProps, T>(BaseTable as any, componentName, (props: T) => {\n props.type = type;\n\n if (callback) {\n return callback(props);\n }\n\n if (type) {\n return { ...props, type };\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.registerChartModule = exports.PivotChart = exports.PivotTable = exports.ListTable = void 0;
|
|
6
|
+
|
|
7
|
+
var list_table_1 = require("./list-table");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "ListTable", {
|
|
10
|
+
enumerable: !0,
|
|
11
|
+
get: function() {
|
|
12
|
+
return list_table_1.ListTable;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var pivot_table_1 = require("./pivot-table");
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "PivotTable", {
|
|
19
|
+
enumerable: !0,
|
|
20
|
+
get: function() {
|
|
21
|
+
return pivot_table_1.PivotTable;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
var pivot_chart_1 = require("./pivot-chart");
|
|
26
|
+
|
|
27
|
+
Object.defineProperty(exports, "PivotChart", {
|
|
28
|
+
enumerable: !0,
|
|
29
|
+
get: function() {
|
|
30
|
+
return pivot_chart_1.PivotChart;
|
|
31
|
+
}
|
|
32
|
+
}), Object.defineProperty(exports, "registerChartModule", {
|
|
33
|
+
enumerable: !0,
|
|
34
|
+
get: function() {
|
|
35
|
+
return pivot_chart_1.registerChartModule;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["tables/index.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6CAAgE;AAAvD,yGAAA,UAAU,OAAA;AAAE,kHAAA,mBAAmB,OAAA","file":"index.js","sourcesContent":["export { ListTable } from './list-table';\nexport { PivotTable } from './pivot-table';\nexport { PivotChart, registerChartModule } from './pivot-chart';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ListTableConstructorOptions } from './../../../vtable/src/index.ts';
|
|
3
|
+
import type { BaseTableProps } from './base-table';
|
|
4
|
+
export interface ListTableProps extends Omit<BaseTableProps, 'option' | 'records' | 'type'>, Omit<ListTableConstructorOptions, 'container'> {
|
|
5
|
+
}
|
|
6
|
+
export declare const ListTable: React.ForwardRefExoticComponent<Omit<ListTableProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & import("../containers/withContainer").ContainerProps, "ref"> & React.RefAttributes<any>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.ListTable = void 0;
|
|
6
|
+
|
|
7
|
+
const base_table_1 = require("./base-table");
|
|
8
|
+
|
|
9
|
+
exports.ListTable = (0, base_table_1.createTable)("ListTable", "list-table");
|
|
10
|
+
//# sourceMappingURL=list-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["tables/list-table.tsx"],"names":[],"mappings":";;;AAGA,6CAA2C;AAM9B,QAAA,SAAS,GAAG,IAAA,wBAAW,EAA0C,WAAW,EAAE,YAAY,CAAC,CAAC","file":"list-table.js","sourcesContent":["import type React from 'react';\nimport type { ListTableConstructorOptions } from './../../../vtable/src/index.ts';\nimport type { BaseTableProps } from './base-table';\nimport { createTable } from './base-table';\n\nexport interface ListTableProps\n extends Omit<BaseTableProps, 'option' | 'records' | 'type'>,\n Omit<ListTableConstructorOptions, 'container'> {}\n\nexport const ListTable = createTable<React.PropsWithChildren<ListTableProps>>('ListTable', 'list-table');\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { PivotChartConstructorOptions } from './../../../vtable/src/index.ts';
|
|
3
|
+
import type { BaseTableProps } from './base-table';
|
|
4
|
+
export interface PivotChartProps extends Omit<BaseTableProps, 'option' | 'records' | 'type'>, Omit<PivotChartConstructorOptions, 'container'> {
|
|
5
|
+
}
|
|
6
|
+
export declare const PivotChart: React.ForwardRefExoticComponent<Omit<PivotChartProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & import("../containers/withContainer").ContainerProps, "ref"> & React.RefAttributes<any>>;
|
|
9
|
+
export declare function registerChartModule(name: string, chart: any): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", {
|
|
16
|
+
enumerable: !0,
|
|
17
|
+
value: v
|
|
18
|
+
});
|
|
19
|
+
} : function(o, v) {
|
|
20
|
+
o.default = v;
|
|
21
|
+
}), __importStar = this && this.__importStar || function(mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
|
|
25
|
+
return __setModuleDefault(result, mod), result;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
Object.defineProperty(exports, "__esModule", {
|
|
29
|
+
value: !0
|
|
30
|
+
}), exports.registerChartModule = exports.PivotChart = void 0;
|
|
31
|
+
|
|
32
|
+
const VTable = __importStar(require("./../../../vtable/src/index.ts")), base_table_1 = require("./base-table");
|
|
33
|
+
|
|
34
|
+
function registerChartModule(name, chart) {
|
|
35
|
+
VTable.register.chartModule(name, chart);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.PivotChart = (0, base_table_1.createTable)("PivotChart", "pivot-chart"),
|
|
39
|
+
exports.registerChartModule = registerChartModule;
|
|
40
|
+
//# sourceMappingURL=pivot-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["tables/pivot-chart.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uEAAyD;AAGzD,6CAA2C;AAM9B,QAAA,UAAU,GAAG,IAAA,wBAAW,EAA2C,YAAY,EAAE,aAAa,CAAC,CAAC;AAE7G,SAAgB,mBAAmB,CAAC,IAAY,EAAE,KAAU;IAC1D,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAFD,kDAEC","file":"pivot-chart.js","sourcesContent":["import type React from 'react';\nimport * as VTable from './../../../vtable/src/index.ts';\nimport type { PivotChartConstructorOptions } from './../../../vtable/src/index.ts';\nimport type { BaseTableProps } from './base-table';\nimport { createTable } from './base-table';\n\nexport interface PivotChartProps\n extends Omit<BaseTableProps, 'option' | 'records' | 'type'>,\n Omit<PivotChartConstructorOptions, 'container'> {}\n\nexport const PivotChart = createTable<React.PropsWithChildren<PivotChartProps>>('PivotChart', 'pivot-chart');\n\nexport function registerChartModule(name: string, chart: any) {\n VTable.register.chartModule(name, chart);\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { PivotTableConstructorOptions } from './../../../vtable/src/index.ts';
|
|
3
|
+
import type { BaseTableProps } from './base-table';
|
|
4
|
+
export interface PivotTableProps extends Omit<BaseTableProps, 'option' | 'records' | 'type'>, Omit<PivotTableConstructorOptions, 'container'> {
|
|
5
|
+
}
|
|
6
|
+
export declare const PivotTable: React.ForwardRefExoticComponent<Omit<PivotTableProps & {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
} & import("../containers/withContainer").ContainerProps, "ref"> & React.RefAttributes<any>>;
|