@visactor/react-vtable 0.21.1 → 0.21.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.
@@ -51,5 +51,4 @@ const react_1 = __importStar(require("react")), vutils_1 = require("@visactor/vu
51
51
  }), Comp;
52
52
  };
53
53
 
54
- exports.createComponent = createComponent;
55
- //# sourceMappingURL=base-component.js.map
54
+ exports.createComponent = createComponent;
@@ -51,7 +51,7 @@ exports.TABLE_EVENTS = {
51
51
  const findEventProps = (props, supportedEvents = exports.TABLE_EVENTS) => {
52
52
  const result = {};
53
53
  return Object.keys(props).forEach((key => {
54
- supportedEvents[key] && (result[key] = props[key]);
54
+ supportedEvents[key] && props[key] && (result[key] = props[key]);
55
55
  })), result;
56
56
  };
57
57
 
@@ -1 +1 @@
1
- {"version":3,"sources":["eventsUtils.ts"],"names":[],"mappings":";;;AAAA,6CAAqE;AAMrE,MAAM,UAAU,iDACX,kBAAS,CAAC,UAAU,GACpB,mBAAU,CAAC,UAAU,GACrB,mBAAU,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,iB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AAC,QAAQ,CAAC,KAAK,aAAa,CAAC,QAAQ,CAAC,EAAE;gBACxG,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAmD,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;aAChH;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 '@visactor/vtable';\nimport type { IVTable } from './tables/base-table';\nimport type { TYPES } from '@visactor/vtable';\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<TYPES.TableEventHandlersEventArgumentMap['click_cell']>;\n onDblClickCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dblclick_cell']>;\n onMouseDownCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mousedown_cell']>;\n onMouseUpCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseup_cell']>;\n onSelectedCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['selected_cell']>;\n onKeyDown?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['keydown']>;\n onMouseEnterTable?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_table']>;\n onMouseLeaveTable?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_table']>;\n onMouseMoveCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mousemove_cell']>;\n onMouseEnterCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_cell']>;\n onMouseLeaveCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_cell']>;\n onContextMenuCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['contextmenu_cell']>;\n onResizeColumn?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['resize_column']>;\n onResizeColumnEnd?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['resize_column_end']>;\n onChangeHeaderPosition?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['change_header_position']>;\n onSortClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['sort_click']>;\n onFreezeClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['freeze_click']>;\n onScroll?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['scroll']>;\n onDropdownMenuClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_menu_click']>;\n onMouseOverChartSymbol?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseover_chart_symbol']>;\n onDragSelectEnd?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['drag_select_end']>;\n\n onDropdownIconClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_icon_click']>;\n onDropdownMenuClear?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_menu_clear']>;\n\n onTreeHierarchyStateChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['tree_hierarchy_state_change']>;\n\n onShowMenu?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['show_menu']>;\n onHideMenu?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['hide_menu']>;\n\n onIconClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['icon_click']>;\n\n onLegendItemClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_click']>;\n onLegendItemHover?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_hover']>;\n onLegendItemUnHover?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_unHover']>;\n onLegendChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_change']>;\n\n onMouseEnterAxis?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_axis']>;\n onMouseLeaveAxis?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_axis']>;\n\n onCheckboxStateChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['checkbox_state_change']>;\n onAfterRender?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['after_render']>;\n onInitialized?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['initialized']>;\n\n // pivot table only\n onPivotSortClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['pivot_sort_click']>;\n onDrillMenuClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['drillmenu_click']>;\n\n // pivot chart only\n onVChartEventType?: EventCallback<TYPES.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 TYPES.TableEventHandlersEventArgumentMap, newEventProps[eventKey]);\n }\n });\n }\n\n return true;\n};\n"]}
1
+ {"version":3,"sources":["eventsUtils.ts"],"names":[],"mappings":";;;AAAA,6CAAqE;AAMrE,MAAM,UAAU,iDACX,kBAAS,CAAC,UAAU,GACpB,mBAAU,CAAC,UAAU,GACrB,mBAAU,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;IACzD,WA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Aa,CAAC,QAAQ,CAAC,EAAE;gBACxG,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAmD,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;aAChH;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 '@visactor/vtable';\nimport type { IVTable } from './tables/base-table';\nimport type { TYPES } from '@visactor/vtable';\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<TYPES.TableEventHandlersEventArgumentMap['click_cell']>;\n onDblClickCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dblclick_cell']>;\n onMouseDownCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mousedown_cell']>;\n onMouseUpCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseup_cell']>;\n onSelectedCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['selected_cell']>;\n onKeyDown?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['keydown']>;\n onMouseEnterTable?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_table']>;\n onMouseLeaveTable?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_table']>;\n onMouseMoveCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mousemove_cell']>;\n onMouseEnterCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_cell']>;\n onMouseLeaveCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_cell']>;\n onContextMenuCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['contextmenu_cell']>;\n onResizeColumn?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['resize_column']>;\n onResizeColumnEnd?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['resize_column_end']>;\n onChangeHeaderPosition?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['change_header_position']>;\n onSortClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['sort_click']>;\n onFreezeClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['freeze_click']>;\n onScroll?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['scroll']>;\n onDropdownMenuClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_menu_click']>;\n onMouseOverChartSymbol?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseover_chart_symbol']>;\n onDragSelectEnd?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['drag_select_end']>;\n\n onDropdownIconClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_icon_click']>;\n onDropdownMenuClear?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_menu_clear']>;\n\n onTreeHierarchyStateChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['tree_hierarchy_state_change']>;\n\n onShowMenu?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['show_menu']>;\n onHideMenu?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['hide_menu']>;\n\n onIconClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['icon_click']>;\n\n onLegendItemClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_click']>;\n onLegendItemHover?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_hover']>;\n onLegendItemUnHover?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_unHover']>;\n onLegendChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_change']>;\n\n onMouseEnterAxis?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_axis']>;\n onMouseLeaveAxis?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_axis']>;\n\n onCheckboxStateChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['checkbox_state_change']>;\n onAfterRender?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['after_render']>;\n onInitialized?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['initialized']>;\n\n // pivot table only\n onPivotSortClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['pivot_sort_click']>;\n onDrillMenuClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['drillmenu_click']>;\n\n // pivot chart only\n onVChartEventType?: EventCallback<TYPES.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] && props[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 TYPES.TableEventHandlersEventArgumentMap, newEventProps[eventKey]);\n }\n });\n }\n\n return true;\n};\n"]}
package/cjs/index.d.ts CHANGED
@@ -2,3 +2,4 @@ import * as VTable from '@visactor/vtable';
2
2
  export * from './tables';
3
3
  export * from './components';
4
4
  export { VTable };
5
+ export declare const version = "0.21.2";
package/cjs/index.js CHANGED
@@ -29,8 +29,10 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
29
29
 
30
30
  Object.defineProperty(exports, "__esModule", {
31
31
  value: !0
32
- }), exports.VTable = void 0;
32
+ }), exports.version = exports.VTable = void 0;
33
33
 
34
34
  const VTable = __importStar(require("@visactor/vtable"));
35
35
 
36
- exports.VTable = VTable, __exportStar(require("./tables"), exports), __exportStar(require("./components"), exports);
36
+ exports.VTable = VTable, __exportStar(require("./tables"), exports), __exportStar(require("./components"), exports),
37
+ exports.version = "0.21.2";
38
+ //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAIlC,wBAAM;AAFf,2CAAyB;AACzB,+CAA6B","file":"index.js","sourcesContent":["import * as VTable from '@visactor/vtable';\n\nexport * from './tables';\nexport * from './components';\nexport { VTable };\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAIlC,wBAAM;AAFf,2CAAyB;AACzB,+CAA6B;AAGhB,QAAA,OAAO,GAAG,QAAQ,CAAC","file":"index.js","sourcesContent":["import * as VTable from '@visactor/vtable';\n\nexport * from './tables';\nexport * from './components';\nexport { VTable };\n\nexport const version = \"0.21.2\";\n"]}
@@ -8,7 +8,7 @@ export interface BaseTableProps extends EventsProps {
8
8
  type?: string;
9
9
  container?: HTMLDivElement;
10
10
  option?: any;
11
- records?: any;
11
+ records?: Record<string, unknown>[];
12
12
  width?: number;
13
13
  height?: number;
14
14
  skipFunctionDiff?: boolean;
@@ -33,12 +33,14 @@ Object.defineProperty(exports, "__esModule", {
33
33
  value: !0
34
34
  }), exports.createTable = void 0;
35
35
 
36
- const VTable = __importStar(require("@visactor/vtable")), 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" ], parseOptionFromChildren = props => {
36
+ const VTable = __importStar(require("@visactor/vtable")), 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" ], getComponentId = (child, index) => `${child && child.type && (child.type.displayName || child.type.name)}-${index}`, parseOptionFromChildren = props => {
37
37
  const optionFromChildren = {};
38
- return (0, util_1.toArray)(props.children).map((child => {
38
+ return (0, util_1.toArray)(props.children).map(((child, index) => {
39
39
  const parseOption = child && child.type && child.type.parseOption;
40
40
  if (parseOption && child.props) {
41
- const optionResult = parseOption(child.props);
41
+ const optionResult = parseOption((0, vutils_1.isNil)(child.props.componentId) ? Object.assign(Object.assign({}, child.props), {
42
+ componentId: getComponentId(child, index)
43
+ }) : child.props);
42
44
  optionResult.isSingle ? optionFromChildren[optionResult.optionName] = optionResult.option : (optionFromChildren[optionResult.optionName] || (optionFromChildren[optionResult.optionName] = []),
43
45
  optionFromChildren[optionResult.optionName].push(optionResult.option));
44
46
  }
@@ -62,7 +64,7 @@ const VTable = __importStar(require("@visactor/vtable")), react_1 = __importStar
62
64
  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)),
63
65
  tableContext.current = Object.assign(Object.assign({}, tableContext.current), {
64
66
  table: vtable
65
- });
67
+ }), isUnmount.current = !1;
66
68
  }), [ parseOption ]), handleTableRender = (0, react_1.useCallback)((() => {
67
69
  if (!isUnmount.current) {
68
70
  if (!tableContext.current || !tableContext.current.table) return;
@@ -76,8 +78,7 @@ const VTable = __importStar(require("@visactor/vtable")), react_1 = __importStar
76
78
  var _a, _b;
77
79
  const newOptionFromChildren = hasOption ? null : parseOptionFromChildren(props);
78
80
  if (!(null === (_a = tableContext.current) || void 0 === _a ? void 0 : _a.table)) return hasOption || (optionFromChildren.current = newOptionFromChildren),
79
- createTable(props), renderTable(), (0, eventsUtils_1.bindEventsToTable)(tableContext.current.table, props, null, eventsUtils_1.TABLE_EVENTS),
80
- void (eventsBinded.current = props);
81
+ createTable(props), renderTable(), void (eventsBinded.current = props);
81
82
  if (hasOption) return void ((0, vutils_1.isEqual)(eventsBinded.current.option, props.option, {
82
83
  skipFunction: skipFunctionDiff
83
84
  }) ? hasRecords && !(0, vutils_1.isEqual)(eventsBinded.current.records, props.records, {
@@ -100,12 +101,12 @@ const VTable = __importStar(require("@visactor/vtable")), react_1 = __importStar
100
101
  }), [ createTable, hasOption, hasRecords, parseOption, handleTableRender, renderTable, skipFunctionDiff, props ]),
101
102
  (0, react_1.useEffect)((() => () => {
102
103
  tableContext && tableContext.current && tableContext.current.table && (tableContext.current.table.release(),
103
- tableContext.current = null), isUnmount.current = !0;
104
+ tableContext.current = null), eventsBinded.current = null, isUnmount.current = !0;
104
105
  }), []), react_1.default.createElement(table_1.default.Provider, {
105
106
  value: tableContext.current
106
107
  }, (0, util_1.toArray)(props.children).map(((child, index) => {
107
108
  if ("string" == typeof child) return;
108
- const childId = `${child && child.type && (child.type.displayName || child.type.name)}-${index}`;
109
+ const childId = getComponentId(child, index);
109
110
  return react_1.default.createElement(react_1.default.Fragment, {
110
111
  key: childId
111
112
  }, react_1.default.cloneElement(child, {
@@ -1 +1 @@
1
- {"version":3,"sources":["tables/base-table.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA2C;AAC3C,+CAA6F;AAE7F,gFAAwD;AAExD,6DAAgD;AAChD,6CAAwD;AACxD,kCAAkC;AAClC,4CAAmD;AAanD,gDAAoF;AA8BpF,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,uBAAuB,GAAG,CAAC,KAAY,EAAE,EAAE;IAC/C,MAAM,kBAAkB,GAAwD,EAAE,CAAC;IAEnF,IAAA,cAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAClC,MAAM,WAAW,GAAG,KAAK,IAAK,KAAa,CAAC,IAAI,IAAK,KAAa,CAAC,IAAI,CAAC,WAAW,CAAC;QAEpF,IAAI,WAAW,IAAK,KAAa,CAAC,KAAK,EAAE;YACvC,MAAM,YAAY,GAAG,WAAW,CAAE,KAAa,CAAC,KAAK,CAAC,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E;QACrE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO;SACR;QAED,MAAM,aAAa,GACjB,KAAK,IAAK,KAAa,CAAC,IAAI,IAAI,CAAE,KAAa,CAAC,IAAI,CAAC,WAAW,IAAK,KAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChG,MAAM,OAAO,GAAG,GAAG,aAAa,IAAI,KAAK,EAAE,CAAC;QAE5C,OAAO,CAML,8BAAC,eAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,OAAO,IACzB,eAAK,CAAC,YAAY,CAAC,KAAkE,EAAE;YACtF,QAAQ,EAAE,QAAQ;YAClB,WAAW,EAAE,OAAO;SACrB,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 */\nimport * as VTable from '@visactor/vtable';\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;\nexport type IOption =\n | VTable.ListTableConstructorOptions\n | VTable.PivotTableConstructorOptions\n | VTable.PivotChartConstructorOptions;\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 parseOptionFromChildren = (props: Props) => {\n const optionFromChildren: Omit<IOption, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map(child => {\n const parseOption = child && (child as any).type && (child as any).type.parseOption;\n\n if (parseOption && (child as any).props) {\n const optionResult = parseOption((child as any).props);\n\n if (optionResult.isSingle) {\n optionFromChildren[optionResult.optionName] = optionResult.option;\n } else {\n if (!optionFromChildren[optionResult.optionName]) {\n optionFromChildren[optionResult.optionName] = [];\n }\n\n optionFromChildren[optionResult.optionName].push(optionResult.option);\n }\n }\n });\n\n return optionFromChildren;\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 optionFromChildren = useRef<Omit<IOption, 'records'>>(null);\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 return {\n records: props.records,\n ...prevOption.current,\n ...optionFromChildren.current\n // ...tableContext.current?.optionFromChildren\n } as IOption;\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 if (!isUnmount.current) {\n if (!tableContext.current || !tableContext.current.table) {\n return;\n }\n // rebind events after render\n bindEventsToTable(tableContext.current.table, props, eventsBinded.current, TABLE_EVENTS);\n\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 tableContext.current.table.render();\n handleTableRender();\n }\n }, [handleTableRender]);\n\n useEffect(() => {\n const newOptionFromChildren = hasOption ? null : parseOptionFromChildren(props);\n\n if (!tableContext.current?.table) {\n if (!hasOption) {\n optionFromChildren.current = newOptionFromChildren;\n }\n\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 handleTableRender();\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 restoreHierarchyState: props.option.restoreHierarchyState\n });\n handleTableRender();\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 !isEqual(newOptionFromChildren, optionFromChildren.current, { skipFunction: skipFunctionDiff })\n ) {\n prevOption.current = newOption;\n optionFromChildren.current = newOptionFromChildren;\n\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(parseOption(props));\n handleTableRender();\n } else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {\n prevRecords.current = props.records;\n tableContext.current.table.setRecords(props.records, {\n restoreHierarchyState: props.option?.restoreHierarchyState\n });\n handleTableRender();\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 && tableContext.current.table) {\n tableContext.current.table.release();\n tableContext.current = null;\n }\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 if (typeof child === 'string') {\n return;\n }\n\n const componentName =\n child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n const childId = `${componentName}-${index}`;\n\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 <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\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"]}
1
+ {"version":3,"sources":["tables/base-table.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA2C;AAC3C,+CAA6F;AAE7F,gFAAwD;AAExD,6DAAgD;AAChD,6CAA+D;AAC/D,kCAAkC;AAClC,4CAAmD;AAanD,gDAAoF;AA8BpF,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,cAAc,GAAG,CAAC,KAAsB,EAAE,KAAa,EAAE,EAAE;IAC/D,MAAM,aAAa,GAAG,KAAK,IAAK,KAAa,CAAC,IAAI,IAAI,CAAE,KAAa,CAAC,IAAI,CAAC,WAAW,IAAK,KAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpH,OAAO,GAAG,aAAa,IAAI,KAAK,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,KAAY,EAAE,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AAE;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 */\nimport * as VTable from '@visactor/vtable';\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, isNil, 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;\nexport type IOption =\n | VTable.ListTableConstructorOptions\n | VTable.PivotTableConstructorOptions\n | VTable.PivotChartConstructorOptions;\n\nexport interface BaseTableProps extends EventsProps {\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /** option */\n option?: any;\n /** 数据 */\n records?: Record<string, unknown>[];\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 getComponentId = (child: React.ReactNode, index: number) => {\n const componentName = child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n return `${componentName}-${index}`;\n};\n\nconst parseOptionFromChildren = (props: Props) => {\n const optionFromChildren: Omit<IOption, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map((child, index) => {\n const parseOption = child && (child as any).type && (child as any).type.parseOption;\n\n if (parseOption && (child as any).props) {\n const childProps = isNil((child as any).props.componentId)\n ? {\n ...(child as any).props,\n componentId: getComponentId(child, index)\n }\n : (child as any).props;\n\n const optionResult = parseOption(childProps);\n\n if (optionResult.isSingle) {\n optionFromChildren[optionResult.optionName] = optionResult.option;\n } else {\n if (!optionFromChildren[optionResult.optionName]) {\n optionFromChildren[optionResult.optionName] = [];\n }\n\n optionFromChildren[optionResult.optionName].push(optionResult.option);\n }\n }\n });\n\n return optionFromChildren;\n};\n\nconst BaseTable: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const tableContext = useRef<TableContextType>({});\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 optionFromChildren = useRef<Omit<IOption, 'records'>>(null);\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 return {\n records: props.records,\n ...prevOption.current,\n ...optionFromChildren.current\n // ...tableContext.current?.optionFromChildren\n } as IOption;\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 isUnmount.current = false;\n },\n [parseOption]\n );\n\n const handleTableRender = useCallback(() => {\n if (!isUnmount.current) {\n if (!tableContext.current || !tableContext.current.table) {\n return;\n }\n // rebind events after render\n bindEventsToTable(tableContext.current.table, props, eventsBinded.current, TABLE_EVENTS);\n\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 tableContext.current.table.render();\n handleTableRender();\n }\n }, [handleTableRender]);\n\n useEffect(() => {\n const newOptionFromChildren = hasOption ? null : parseOptionFromChildren(props);\n\n if (!tableContext.current?.table) {\n if (!hasOption) {\n optionFromChildren.current = newOptionFromChildren;\n }\n\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 handleTableRender();\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 as any[], {\n restoreHierarchyState: props.option.restoreHierarchyState\n });\n handleTableRender();\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 !isEqual(newOptionFromChildren, optionFromChildren.current, { skipFunction: skipFunctionDiff })\n ) {\n prevOption.current = newOption;\n optionFromChildren.current = newOptionFromChildren;\n\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(parseOption(props));\n handleTableRender();\n } else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {\n prevRecords.current = props.records;\n tableContext.current.table.setRecords(props.records, {\n restoreHierarchyState: props.option?.restoreHierarchyState\n });\n handleTableRender();\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 && tableContext.current.table) {\n tableContext.current.table.release();\n tableContext.current = null;\n }\n }\n eventsBinded.current = null;\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 if (typeof child === 'string') {\n return;\n }\n\n const childId = getComponentId(child, index);\n\n // const componentName =\n // child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n // const childId = `${componentName}-${index}`;\n\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 <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\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"]}
package/cjs/util.js CHANGED
@@ -53,5 +53,4 @@ const findChildByType = (children, type) => {
53
53
  return null == result ? void 0 : result[0];
54
54
  };
55
55
 
56
- exports.findChildByType = findChildByType;
57
- //# sourceMappingURL=util.js.map
56
+ exports.findChildByType = findChildByType;
@@ -3310,7 +3310,7 @@
3310
3310
  const findEventProps = (props, supportedEvents = TABLE_EVENTS) => {
3311
3311
  const result = {};
3312
3312
  Object.keys(props).forEach(key => {
3313
- if (supportedEvents[key]) {
3313
+ if (supportedEvents[key] && props[key]) {
3314
3314
  result[key] = props[key];
3315
3315
  }
3316
3316
  });
@@ -3349,12 +3349,22 @@
3349
3349
  'records',
3350
3350
  'container'
3351
3351
  ];
3352
+ const getComponentId = (child, index) => {
3353
+ const componentName = child && child.type && (child.type.displayName || child.type.name);
3354
+ return `${componentName}-${index}`;
3355
+ };
3352
3356
  const parseOptionFromChildren = (props) => {
3353
3357
  const optionFromChildren = {};
3354
- toArray(props.children).map(child => {
3358
+ toArray(props.children).map((child, index) => {
3355
3359
  const parseOption = child && child.type && child.type.parseOption;
3356
3360
  if (parseOption && child.props) {
3357
- const optionResult = parseOption(child.props);
3361
+ const childProps = isNil$1(child.props.componentId)
3362
+ ? {
3363
+ ...child.props,
3364
+ componentId: getComponentId(child, index)
3365
+ }
3366
+ : child.props;
3367
+ const optionResult = parseOption(childProps);
3358
3368
  if (optionResult.isSingle) {
3359
3369
  optionFromChildren[optionResult.optionName] = optionResult.option;
3360
3370
  }
@@ -3408,6 +3418,7 @@
3408
3418
  vtable = new VTable__namespace.ListTable(props.container, parseOption(props));
3409
3419
  }
3410
3420
  tableContext.current = { ...tableContext.current, table: vtable };
3421
+ isUnmount.current = false;
3411
3422
  }, [parseOption]);
3412
3423
  const handleTableRender = reactExports.useCallback(() => {
3413
3424
  if (!isUnmount.current) {
@@ -3435,7 +3446,6 @@
3435
3446
  }
3436
3447
  createTable(props);
3437
3448
  renderTable();
3438
- bindEventsToTable(tableContext.current.table, props, null, TABLE_EVENTS);
3439
3449
  eventsBinded.current = props;
3440
3450
  return;
3441
3451
  }
@@ -3479,6 +3489,7 @@
3479
3489
  tableContext.current = null;
3480
3490
  }
3481
3491
  }
3492
+ eventsBinded.current = null;
3482
3493
  isUnmount.current = true;
3483
3494
  };
3484
3495
  }, []);
@@ -3486,8 +3497,7 @@
3486
3497
  if (typeof child === 'string') {
3487
3498
  return;
3488
3499
  }
3489
- const componentName = child && child.type && (child.type.displayName || child.type.name);
3490
- const childId = `${componentName}-${index}`;
3500
+ const childId = getComponentId(child, index);
3491
3501
  return (React.createElement(React.Fragment, { key: childId }, React.cloneElement(child, {
3492
3502
  updateId: updateId,
3493
3503
  componentId: childId
@@ -3571,6 +3581,8 @@
3571
3581
 
3572
3582
  const Tooltip = createComponent('Tooltip', 'tooltip', undefined, true);
3573
3583
 
3584
+ const version = "0.21.2";
3585
+
3574
3586
  exports.VTable = VTable__namespace;
3575
3587
  exports.ListColumn = ListColumn;
3576
3588
  exports.ListTable = ListTable;
@@ -3585,5 +3597,6 @@
3585
3597
  exports.PivotTable = PivotTable;
3586
3598
  exports.Tooltip = Tooltip;
3587
3599
  exports.registerChartModule = registerChartModule;
3600
+ exports.version = version;
3588
3601
 
3589
3602
  }));
@@ -16,4 +16,4 @@
16
16
  *
17
17
  * This source code is licensed under the MIT license found in the
18
18
  * LICENSE file in the root directory of this source tree.
19
- */"production"===process.env.NODE_ENV?w.exports=function(){if(O)return R;O=1;var e,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),i=Symbol.for("react.context"),c=Symbol.for("react.server_context"),s=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen");function m(e){if("object"==typeof e&&null!==e){var y=e.$$typeof;switch(y){case t:switch(e=e.type){case n:case a:case o:case l:case f:return e;default:switch(e=e&&e.$$typeof){case c:case i:case s:case d:case p:case u:return e;default:return y}}case r:return y}}}return e=Symbol.for("react.module.reference"),R.ContextConsumer=i,R.ContextProvider=u,R.Element=t,R.ForwardRef=s,R.Fragment=n,R.Lazy=d,R.Memo=p,R.Portal=r,R.Profiler=a,R.StrictMode=o,R.Suspense=l,R.SuspenseList=f,R.isAsyncMode=function(){return!1},R.isConcurrentMode=function(){return!1},R.isContextConsumer=function(e){return m(e)===i},R.isContextProvider=function(e){return m(e)===u},R.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},R.isForwardRef=function(e){return m(e)===s},R.isFragment=function(e){return m(e)===n},R.isLazy=function(e){return m(e)===d},R.isMemo=function(e){return m(e)===p},R.isPortal=function(e){return m(e)===r},R.isProfiler=function(e){return m(e)===a},R.isStrictMode=function(e){return m(e)===o},R.isSuspense=function(e){return m(e)===l},R.isSuspenseList=function(e){return m(e)===f},R.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===a||t===o||t===l||t===f||t===y||"object"==typeof t&&null!==t&&(t.$$typeof===d||t.$$typeof===p||t.$$typeof===u||t.$$typeof===i||t.$$typeof===s||t.$$typeof===e||void 0!==t.getModuleId)},R.typeOf=m,R}():w.exports=(k||(k=1,"production"!==process.env.NODE_ENV&&function(){var e,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),i=Symbol.for("react.context"),c=Symbol.for("react.server_context"),s=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen");function m(e){if("object"==typeof e&&null!==e){var y=e.$$typeof;switch(y){case t:var m=e.type;switch(m){case n:case a:case o:case l:case f:return m;default:var v=m&&m.$$typeof;switch(v){case c:case i:case s:case d:case p:case u:return v;default:return y}}case r:return y}}}e=Symbol.for("react.module.reference");var v=i,h=u,b=t,_=s,g=n,E=d,C=p,S=r,O=a,w=o,R=l,k=f,P=!1,L=!1;T.ContextConsumer=v,T.ContextProvider=h,T.Element=b,T.ForwardRef=_,T.Fragment=g,T.Lazy=E,T.Memo=C,T.Portal=S,T.Profiler=O,T.StrictMode=w,T.Suspense=R,T.SuspenseList=k,T.isAsyncMode=function(e){return P||(P=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1},T.isConcurrentMode=function(e){return L||(L=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1},T.isContextConsumer=function(e){return m(e)===i},T.isContextProvider=function(e){return m(e)===u},T.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},T.isForwardRef=function(e){return m(e)===s},T.isFragment=function(e){return m(e)===n},T.isLazy=function(e){return m(e)===d},T.isMemo=function(e){return m(e)===p},T.isPortal=function(e){return m(e)===r},T.isProfiler=function(e){return m(e)===a},T.isStrictMode=function(e){return m(e)===o},T.isSuspense=function(e){return m(e)===l},T.isSuspenseList=function(e){return m(e)===f},T.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===a||t===o||t===l||t===f||t===y||"object"==typeof t&&null!==t&&(t.$$typeof===d||t.$$typeof===p||t.$$typeof===u||t.$$typeof===i||t.$$typeof===s||t.$$typeof===e||void 0!==t.getModuleId)},T.typeOf=m}()),T);var P=w.exports;const L=e=>{let t=[];return f.Children.forEach(e,(e=>{m(e)||(P.isFragment(e)?t=t.concat(L(e.props.children)):t.push(e))})),t},j={...t.ListTable.EVENT_TYPE,...t.PivotTable.EVENT_TYPE,...t.PivotChart.EVENT_TYPE},$={onClickCell:j.CLICK_CELL,onDblClickCell:j.DBLCLICK_CELL,onMouseDownCell:j.MOUSEDOWN_CELL,onMouseUpCell:j.MOUSEUP_CELL,onSelectedCell:j.SELECTED_CELL,onKeyDown:j.KEYDOWN,onMouseEnterTable:j.MOUSEENTER_TABLE,onMouseLeaveTable:j.MOUSELEAVE_TABLE,onMouseMoveCell:j.MOUSEMOVE_CELL,onMouseEnterCell:j.MOUSEENTER_CELL,onMouseLeaveCell:j.MOUSELEAVE_CELL,onContextMenuCell:j.CONTEXTMENU_CELL,onResizeColumn:j.RESIZE_COLUMN,onResizeColumnEnd:j.RESIZE_COLUMN_END,onChangeHeaderPosition:j.CHANGE_HEADER_POSITION,onSortClick:j.SORT_CLICK,onFreezeClick:j.FREEZE_CLICK,onScroll:j.SCROLL,onDropdownMenuClick:j.DROPDOWN_MENU_CLICK,onMouseOverChartSymbol:j.MOUSEOVER_CHART_SYMBOL,onDragSelectEnd:j.DRAG_SELECT_END,onDropdownIconClick:j.DROPDOWN_ICON_CLICK,onDropdownMenuClear:j.DROPDOWN_MENU_CLEAR,onTreeHierarchyStateChange:j.TREE_HIERARCHY_STATE_CHANGE,onShowMenu:j.SHOW_MENU,onHideMenu:j.HIDE_MENU,onIconClick:j.ICON_CLICK,onLegendItemClick:j.LEGEND_ITEM_CLICK,onLegendItemHover:j.LEGEND_ITEM_HOVER,onLegendItemUnHover:j.LEGEND_ITEM_UNHOVER,onLegendChange:j.LEGEND_CHANGE,onMouseEnterAxis:j.MOUSEENTER_AXIS,onMouseLeaveAxis:j.MOUSELEAVE_AXIS,onCheckboxStateChange:j.CHECKBOX_STATE_CHANGE,onAfterRender:j.AFTER_RENDER,onInitialized:j.INITIALIZED,onPivotSortClick:j.PIVOT_SORT_CLICK,onDrillMenuClick:j.DRILLMENU_CLICK,onVChartEventType:j.VCHART_EVENT_TYPE},N=Object.keys($),I=(e,t=$)=>{const r={};return Object.keys(e).forEach((n=>{t[n]&&(r[n]=e[n])})),r},x=(e,t,r,n=$)=>{if(!t&&!r||!e)return!1;const o=r?I(r,n):null,a=t?I(t,n):null;return o&&Object.keys(o).forEach((t=>{a&&a[t]&&a[t]===o[t]||e.off(n[t],r[t])})),a&&Object.keys(a).forEach((t=>{o&&o[t]&&o[t]===a[t]||e.on(n[t],a[t])})),!0},M=["children","hooks","ref",...N,"skipFunctionDiff","onError","onReady","option","records","container"],D=f.forwardRef(((e,t)=>{const[r,o]=l.useState(0),a=l.useRef({});l.useImperativeHandle(t,(()=>a.current?.table));const u=!!e.option,i=!!e.records,c=l.useRef(!1),s=l.useRef(g(e,M)),d=l.useRef(null),y=l.useRef(e.records),m=f.useRef(null),v=!!e.skipFunctionDiff,h=l.useCallback((e=>u&&e.option?i&&e.records?{...e.option,records:e.records}:e.option:{records:e.records,...s.current,...d.current}),[u,i]),b=l.useCallback((e=>{let t;t="pivot-table"===e.type?new n.PivotTable(e.container,h(e)):"pivot-chart"===e.type?new n.PivotChart(e.container,h(e)):new n.ListTable(e.container,h(e)),a.current={...a.current,table:t}}),[h]),_=l.useCallback((()=>{if(!c.current){if(!a.current||!a.current.table)return;x(a.current.table,e,m.current,$),o(r+1),e.onReady&&e.onReady(a.current.table,0===r)}}),[r,o,e]),E=l.useCallback((()=>{a.current.table&&(a.current.table.render(),_())}),[_]);return l.useEffect((()=>{const t=u?null:(e=>{const t={};return L(e.children).map((e=>{const r=e&&e.type&&e.type.parseOption;if(r&&e.props){const n=r(e.props);n.isSingle?t[n.optionName]=n.option:(t[n.optionName]||(t[n.optionName]=[]),t[n.optionName].push(n.option))}})),t})(e);if(!a.current?.table)return u||(d.current=t),b(e),E(),x(a.current.table,e,null,$),void(m.current=e);if(u)return void(S(m.current.option,e.option,{skipFunction:v})?i&&!S(m.current.records,e.records,{skipFunction:v})&&(m.current=e,a.current.table.setRecords(e.records,{restoreHierarchyState:e.option.restoreHierarchyState}),_()):(m.current=e,a.current.table.updateOption(h(e)),_()));const r=g(e,M);S(r,s.current,{skipFunction:v})&&S(t,d.current,{skipFunction:v})?i&&!S(e.records,y.current,{skipFunction:v})&&(y.current=e.records,a.current.table.setRecords(e.records,{restoreHierarchyState:e.option?.restoreHierarchyState}),_()):(s.current=r,d.current=t,a.current.table.updateOption(h(e)),_())}),[b,u,i,h,_,E,v,e]),l.useEffect((()=>()=>{a&&a.current&&a.current.table&&(a.current.table.release(),a.current=null),c.current=!0}),[]),f.createElement(p.Provider,{value:a.current},L(e.children).map(((e,t)=>{if("string"==typeof e)return;const n=`${e&&e.type&&(e.type.displayName||e.type.name)}-${t}`;return f.createElement(f.Fragment,{key:n},f.cloneElement(e,{updateId:r,componentId:n}))})))})),A=(e,t,r)=>{const n=function(e,t="TableContainer",r){const n=f.forwardRef(((t,n)=>{const o=l.useRef(),[a,u]=l.useState(!1),{className:i,style:c,width:s,...p}=t;return l.useLayoutEffect((()=>{u(!0)}),[]),f.createElement("div",{ref:o,className:i,style:{position:"relative",height:t.height||"100%",width:t.width||"100%",...c}},a?f.createElement(e,{ref:n,container:o.current,...r?r(p):p}):f.createElement(f.Fragment,null))}));return n.displayName=t||e.name,n}(D,e,(e=>(e.type=t,r?r(e):t?{...e,type:t}:e)));return n.displayName=e,n},F=A("ListTable","list-table"),V=A("PivotTable","pivot-table"),U=A("PivotChart","pivot-chart");const H=(e,t,r,n)=>{const o=["id","updateId","componentId"],a=r?Object.keys(r).concat(o):o,u=e=>{const t=l.useContext(p),n=f.useRef(null),o=f.useRef(e.updateId);if(e.updateId!==o.current){o.current=e.updateId;!!r&&x(t.table,e,n.current,r)&&(n.current=e)}return l.useEffect((()=>()=>{r&&x(t.table,null,n.current,r)}),[]),null};return u.displayName=e,u.parseOption=e=>({option:g(e,a),optionName:t,isSingle:n}),u},z=H("ListColumn","columns"),B=H("PivotColumnDimension","columns"),Y=H("PivotRowDimension","rows"),K=H("PivotIndicator","indicators"),q=H("PivotColumnHeaderTitle","columnHeaderTitle",void 0,!0),W=H("PivotRowHeaderTitle","rowHeaderTitle",void 0,!0),G=H("PivotCorner","corner",void 0,!0),X=H("Menu","menu",void 0,!0),Z=H("Tooltip","tooltip",void 0,!0);e.VTable=n,e.ListColumn=z,e.ListTable=F,e.Menu=X,e.PivotChart=U,e.PivotColumnDimension=B,e.PivotColumnHeaderTitle=q,e.PivotCorner=G,e.PivotIndicator=K,e.PivotRowDimension=Y,e.PivotRowHeaderTitle=W,e.PivotTable=V,e.Tooltip=Z,e.registerChartModule=function(e,t){n.register.chartModule(e,t)}}));
19
+ */"production"===process.env.NODE_ENV?w.exports=function(){if(O)return R;O=1;var e,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),i=Symbol.for("react.context"),c=Symbol.for("react.server_context"),s=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen");function m(e){if("object"==typeof e&&null!==e){var y=e.$$typeof;switch(y){case t:switch(e=e.type){case n:case a:case o:case l:case f:return e;default:switch(e=e&&e.$$typeof){case c:case i:case s:case d:case p:case u:return e;default:return y}}case r:return y}}}return e=Symbol.for("react.module.reference"),R.ContextConsumer=i,R.ContextProvider=u,R.Element=t,R.ForwardRef=s,R.Fragment=n,R.Lazy=d,R.Memo=p,R.Portal=r,R.Profiler=a,R.StrictMode=o,R.Suspense=l,R.SuspenseList=f,R.isAsyncMode=function(){return!1},R.isConcurrentMode=function(){return!1},R.isContextConsumer=function(e){return m(e)===i},R.isContextProvider=function(e){return m(e)===u},R.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},R.isForwardRef=function(e){return m(e)===s},R.isFragment=function(e){return m(e)===n},R.isLazy=function(e){return m(e)===d},R.isMemo=function(e){return m(e)===p},R.isPortal=function(e){return m(e)===r},R.isProfiler=function(e){return m(e)===a},R.isStrictMode=function(e){return m(e)===o},R.isSuspense=function(e){return m(e)===l},R.isSuspenseList=function(e){return m(e)===f},R.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===a||t===o||t===l||t===f||t===y||"object"==typeof t&&null!==t&&(t.$$typeof===d||t.$$typeof===p||t.$$typeof===u||t.$$typeof===i||t.$$typeof===s||t.$$typeof===e||void 0!==t.getModuleId)},R.typeOf=m,R}():w.exports=(k||(k=1,"production"!==process.env.NODE_ENV&&function(){var e,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),i=Symbol.for("react.context"),c=Symbol.for("react.server_context"),s=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen");function m(e){if("object"==typeof e&&null!==e){var y=e.$$typeof;switch(y){case t:var m=e.type;switch(m){case n:case a:case o:case l:case f:return m;default:var v=m&&m.$$typeof;switch(v){case c:case i:case s:case d:case p:case u:return v;default:return y}}case r:return y}}}e=Symbol.for("react.module.reference");var v=i,h=u,b=t,_=s,g=n,E=d,C=p,S=r,O=a,w=o,R=l,k=f,P=!1,L=!1;T.ContextConsumer=v,T.ContextProvider=h,T.Element=b,T.ForwardRef=_,T.Fragment=g,T.Lazy=E,T.Memo=C,T.Portal=S,T.Profiler=O,T.StrictMode=w,T.Suspense=R,T.SuspenseList=k,T.isAsyncMode=function(e){return P||(P=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1},T.isConcurrentMode=function(e){return L||(L=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1},T.isContextConsumer=function(e){return m(e)===i},T.isContextProvider=function(e){return m(e)===u},T.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},T.isForwardRef=function(e){return m(e)===s},T.isFragment=function(e){return m(e)===n},T.isLazy=function(e){return m(e)===d},T.isMemo=function(e){return m(e)===p},T.isPortal=function(e){return m(e)===r},T.isProfiler=function(e){return m(e)===a},T.isStrictMode=function(e){return m(e)===o},T.isSuspense=function(e){return m(e)===l},T.isSuspenseList=function(e){return m(e)===f},T.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===a||t===o||t===l||t===f||t===y||"object"==typeof t&&null!==t&&(t.$$typeof===d||t.$$typeof===p||t.$$typeof===u||t.$$typeof===i||t.$$typeof===s||t.$$typeof===e||void 0!==t.getModuleId)},T.typeOf=m}()),T);var P=w.exports;const L=e=>{let t=[];return f.Children.forEach(e,(e=>{m(e)||(P.isFragment(e)?t=t.concat(L(e.props.children)):t.push(e))})),t},j={...t.ListTable.EVENT_TYPE,...t.PivotTable.EVENT_TYPE,...t.PivotChart.EVENT_TYPE},$={onClickCell:j.CLICK_CELL,onDblClickCell:j.DBLCLICK_CELL,onMouseDownCell:j.MOUSEDOWN_CELL,onMouseUpCell:j.MOUSEUP_CELL,onSelectedCell:j.SELECTED_CELL,onKeyDown:j.KEYDOWN,onMouseEnterTable:j.MOUSEENTER_TABLE,onMouseLeaveTable:j.MOUSELEAVE_TABLE,onMouseMoveCell:j.MOUSEMOVE_CELL,onMouseEnterCell:j.MOUSEENTER_CELL,onMouseLeaveCell:j.MOUSELEAVE_CELL,onContextMenuCell:j.CONTEXTMENU_CELL,onResizeColumn:j.RESIZE_COLUMN,onResizeColumnEnd:j.RESIZE_COLUMN_END,onChangeHeaderPosition:j.CHANGE_HEADER_POSITION,onSortClick:j.SORT_CLICK,onFreezeClick:j.FREEZE_CLICK,onScroll:j.SCROLL,onDropdownMenuClick:j.DROPDOWN_MENU_CLICK,onMouseOverChartSymbol:j.MOUSEOVER_CHART_SYMBOL,onDragSelectEnd:j.DRAG_SELECT_END,onDropdownIconClick:j.DROPDOWN_ICON_CLICK,onDropdownMenuClear:j.DROPDOWN_MENU_CLEAR,onTreeHierarchyStateChange:j.TREE_HIERARCHY_STATE_CHANGE,onShowMenu:j.SHOW_MENU,onHideMenu:j.HIDE_MENU,onIconClick:j.ICON_CLICK,onLegendItemClick:j.LEGEND_ITEM_CLICK,onLegendItemHover:j.LEGEND_ITEM_HOVER,onLegendItemUnHover:j.LEGEND_ITEM_UNHOVER,onLegendChange:j.LEGEND_CHANGE,onMouseEnterAxis:j.MOUSEENTER_AXIS,onMouseLeaveAxis:j.MOUSELEAVE_AXIS,onCheckboxStateChange:j.CHECKBOX_STATE_CHANGE,onAfterRender:j.AFTER_RENDER,onInitialized:j.INITIALIZED,onPivotSortClick:j.PIVOT_SORT_CLICK,onDrillMenuClick:j.DRILLMENU_CLICK,onVChartEventType:j.VCHART_EVENT_TYPE},N=Object.keys($),I=(e,t=$)=>{const r={};return Object.keys(e).forEach((n=>{t[n]&&e[n]&&(r[n]=e[n])})),r},x=(e,t,r,n=$)=>{if(!t&&!r||!e)return!1;const o=r?I(r,n):null,a=t?I(t,n):null;return o&&Object.keys(o).forEach((t=>{a&&a[t]&&a[t]===o[t]||e.off(n[t],r[t])})),a&&Object.keys(a).forEach((t=>{o&&o[t]&&o[t]===a[t]||e.on(n[t],a[t])})),!0},M=["children","hooks","ref",...N,"skipFunctionDiff","onError","onReady","option","records","container"],D=(e,t)=>`${e&&e.type&&(e.type.displayName||e.type.name)}-${t}`,A=f.forwardRef(((e,t)=>{const[r,o]=l.useState(0),a=l.useRef({});l.useImperativeHandle(t,(()=>a.current?.table));const u=!!e.option,i=!!e.records,c=l.useRef(!1),s=l.useRef(g(e,M)),d=l.useRef(null),y=l.useRef(e.records),v=f.useRef(null),h=!!e.skipFunctionDiff,b=l.useCallback((e=>u&&e.option?i&&e.records?{...e.option,records:e.records}:e.option:{records:e.records,...s.current,...d.current}),[u,i]),_=l.useCallback((e=>{let t;t="pivot-table"===e.type?new n.PivotTable(e.container,b(e)):"pivot-chart"===e.type?new n.PivotChart(e.container,b(e)):new n.ListTable(e.container,b(e)),a.current={...a.current,table:t},c.current=!1}),[b]),E=l.useCallback((()=>{if(!c.current){if(!a.current||!a.current.table)return;x(a.current.table,e,v.current,$),o(r+1),e.onReady&&e.onReady(a.current.table,0===r)}}),[r,o,e]),C=l.useCallback((()=>{a.current.table&&(a.current.table.render(),E())}),[E]);return l.useEffect((()=>{const t=u?null:(e=>{const t={};return L(e.children).map(((e,r)=>{const n=e&&e.type&&e.type.parseOption;if(n&&e.props){const o=n(m(e.props.componentId)?{...e.props,componentId:D(e,r)}:e.props);o.isSingle?t[o.optionName]=o.option:(t[o.optionName]||(t[o.optionName]=[]),t[o.optionName].push(o.option))}})),t})(e);if(!a.current?.table)return u||(d.current=t),_(e),C(),void(v.current=e);if(u)return void(S(v.current.option,e.option,{skipFunction:h})?i&&!S(v.current.records,e.records,{skipFunction:h})&&(v.current=e,a.current.table.setRecords(e.records,{restoreHierarchyState:e.option.restoreHierarchyState}),E()):(v.current=e,a.current.table.updateOption(b(e)),E()));const r=g(e,M);S(r,s.current,{skipFunction:h})&&S(t,d.current,{skipFunction:h})?i&&!S(e.records,y.current,{skipFunction:h})&&(y.current=e.records,a.current.table.setRecords(e.records,{restoreHierarchyState:e.option?.restoreHierarchyState}),E()):(s.current=r,d.current=t,a.current.table.updateOption(b(e)),E())}),[_,u,i,b,E,C,h,e]),l.useEffect((()=>()=>{a&&a.current&&a.current.table&&(a.current.table.release(),a.current=null),v.current=null,c.current=!0}),[]),f.createElement(p.Provider,{value:a.current},L(e.children).map(((e,t)=>{if("string"==typeof e)return;const n=D(e,t);return f.createElement(f.Fragment,{key:n},f.cloneElement(e,{updateId:r,componentId:n}))})))})),F=(e,t,r)=>{const n=function(e,t="TableContainer",r){const n=f.forwardRef(((t,n)=>{const o=l.useRef(),[a,u]=l.useState(!1),{className:i,style:c,width:s,...p}=t;return l.useLayoutEffect((()=>{u(!0)}),[]),f.createElement("div",{ref:o,className:i,style:{position:"relative",height:t.height||"100%",width:t.width||"100%",...c}},a?f.createElement(e,{ref:n,container:o.current,...r?r(p):p}):f.createElement(f.Fragment,null))}));return n.displayName=t||e.name,n}(A,e,(e=>(e.type=t,r?r(e):t?{...e,type:t}:e)));return n.displayName=e,n},V=F("ListTable","list-table"),U=F("PivotTable","pivot-table"),H=F("PivotChart","pivot-chart");const z=(e,t,r,n)=>{const o=["id","updateId","componentId"],a=r?Object.keys(r).concat(o):o,u=e=>{const t=l.useContext(p),n=f.useRef(null),o=f.useRef(e.updateId);if(e.updateId!==o.current){o.current=e.updateId;!!r&&x(t.table,e,n.current,r)&&(n.current=e)}return l.useEffect((()=>()=>{r&&x(t.table,null,n.current,r)}),[]),null};return u.displayName=e,u.parseOption=e=>({option:g(e,a),optionName:t,isSingle:n}),u},B=z("ListColumn","columns"),Y=z("PivotColumnDimension","columns"),K=z("PivotRowDimension","rows"),q=z("PivotIndicator","indicators"),W=z("PivotColumnHeaderTitle","columnHeaderTitle",void 0,!0),G=z("PivotRowHeaderTitle","rowHeaderTitle",void 0,!0),X=z("PivotCorner","corner",void 0,!0),Z=z("Menu","menu",void 0,!0),J=z("Tooltip","tooltip",void 0,!0);e.VTable=n,e.ListColumn=B,e.ListTable=V,e.Menu=Z,e.PivotChart=H,e.PivotColumnDimension=Y,e.PivotColumnHeaderTitle=W,e.PivotCorner=X,e.PivotIndicator=q,e.PivotRowDimension=K,e.PivotRowHeaderTitle=G,e.PivotTable=U,e.Tooltip=J,e.registerChartModule=function(e,t){n.register.chartModule(e,t)},e.version="0.21.2"}));
@@ -22,5 +22,4 @@ export const createComponent = (componentName, optionName, supportedEvents, isSi
22
22
  optionName: optionName,
23
23
  isSingle: isSingle
24
24
  }), Comp;
25
- };
26
- //# sourceMappingURL=base-component.js.map
25
+ };
package/es/eventsUtils.js CHANGED
@@ -49,7 +49,7 @@ export const TABLE_EVENTS_KEYS = Object.keys(TABLE_EVENTS);
49
49
  export const findEventProps = (props, supportedEvents = TABLE_EVENTS) => {
50
50
  const result = {};
51
51
  return Object.keys(props).forEach((key => {
52
- supportedEvents[key] && (result[key] = props[key]);
52
+ supportedEvents[key] && props[key] && (result[key] = props[key]);
53
53
  })), result;
54
54
  };
55
55
 
@@ -1 +1 @@
1
- {"version":3,"sources":["eventsUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,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AAC,IAAI,CAAC;IACrF,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAElF,IAAI,cAAc,EAAE;QAClB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC7C,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,QAAQ,CAAC,EAAE;gBACtG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC3D;QACH,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,aAAa,EAAE;QACjB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC5C,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,QAAQ,CAAC,EAAE;gBACxG,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAmD,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;aAChH;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","file":"eventsUtils.js","sourcesContent":["import { ListTable, PivotTable, PivotChart } from '@visactor/vtable';\nimport type { IVTable } from './tables/base-table';\nimport type { TYPES } from '@visactor/vtable';\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<TYPES.TableEventHandlersEventArgumentMap['click_cell']>;\n onDblClickCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dblclick_cell']>;\n onMouseDownCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mousedown_cell']>;\n onMouseUpCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseup_cell']>;\n onSelectedCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['selected_cell']>;\n onKeyDown?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['keydown']>;\n onMouseEnterTable?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_table']>;\n onMouseLeaveTable?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_table']>;\n onMouseMoveCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mousemove_cell']>;\n onMouseEnterCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_cell']>;\n onMouseLeaveCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_cell']>;\n onContextMenuCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['contextmenu_cell']>;\n onResizeColumn?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['resize_column']>;\n onResizeColumnEnd?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['resize_column_end']>;\n onChangeHeaderPosition?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['change_header_position']>;\n onSortClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['sort_click']>;\n onFreezeClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['freeze_click']>;\n onScroll?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['scroll']>;\n onDropdownMenuClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_menu_click']>;\n onMouseOverChartSymbol?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseover_chart_symbol']>;\n onDragSelectEnd?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['drag_select_end']>;\n\n onDropdownIconClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_icon_click']>;\n onDropdownMenuClear?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_menu_clear']>;\n\n onTreeHierarchyStateChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['tree_hierarchy_state_change']>;\n\n onShowMenu?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['show_menu']>;\n onHideMenu?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['hide_menu']>;\n\n onIconClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['icon_click']>;\n\n onLegendItemClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_click']>;\n onLegendItemHover?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_hover']>;\n onLegendItemUnHover?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_unHover']>;\n onLegendChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_change']>;\n\n onMouseEnterAxis?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_axis']>;\n onMouseLeaveAxis?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_axis']>;\n\n onCheckboxStateChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['checkbox_state_change']>;\n onAfterRender?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['after_render']>;\n onInitialized?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['initialized']>;\n\n // pivot table only\n onPivotSortClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['pivot_sort_click']>;\n onDrillMenuClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['drillmenu_click']>;\n\n // pivot chart only\n onVChartEventType?: EventCallback<TYPES.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 TYPES.TableEventHandlersEventArgumentMap, newEventProps[eventKey]);\n }\n });\n }\n\n return true;\n};\n"]}
1
+ {"version":3,"sources":["eventsUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMrE,MAAM,U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CAAC,IAAI,CAAC;IACrF,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAElF,IAAI,cAAc,EAAE;QAClB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC7C,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,cAAc,CAAC,QAAQ,CAAC,EAAE;gBACtG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC3D;QACH,CAAC,CAAC,CAAC;KACJ;IAED,IAAI,aAAa,EAAE;QACjB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC5C,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC,QAAQ,CAAC,EAAE;gBACxG,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAmD,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;aAChH;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","file":"eventsUtils.js","sourcesContent":["import { ListTable, PivotTable, PivotChart } from '@visactor/vtable';\nimport type { IVTable } from './tables/base-table';\nimport type { TYPES } from '@visactor/vtable';\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<TYPES.TableEventHandlersEventArgumentMap['click_cell']>;\n onDblClickCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dblclick_cell']>;\n onMouseDownCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mousedown_cell']>;\n onMouseUpCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseup_cell']>;\n onSelectedCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['selected_cell']>;\n onKeyDown?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['keydown']>;\n onMouseEnterTable?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_table']>;\n onMouseLeaveTable?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_table']>;\n onMouseMoveCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mousemove_cell']>;\n onMouseEnterCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_cell']>;\n onMouseLeaveCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_cell']>;\n onContextMenuCell?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['contextmenu_cell']>;\n onResizeColumn?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['resize_column']>;\n onResizeColumnEnd?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['resize_column_end']>;\n onChangeHeaderPosition?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['change_header_position']>;\n onSortClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['sort_click']>;\n onFreezeClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['freeze_click']>;\n onScroll?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['scroll']>;\n onDropdownMenuClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_menu_click']>;\n onMouseOverChartSymbol?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseover_chart_symbol']>;\n onDragSelectEnd?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['drag_select_end']>;\n\n onDropdownIconClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_icon_click']>;\n onDropdownMenuClear?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['dropdown_menu_clear']>;\n\n onTreeHierarchyStateChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['tree_hierarchy_state_change']>;\n\n onShowMenu?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['show_menu']>;\n onHideMenu?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['hide_menu']>;\n\n onIconClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['icon_click']>;\n\n onLegendItemClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_click']>;\n onLegendItemHover?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_hover']>;\n onLegendItemUnHover?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_item_unHover']>;\n onLegendChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['legend_change']>;\n\n onMouseEnterAxis?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseenter_axis']>;\n onMouseLeaveAxis?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['mouseleave_axis']>;\n\n onCheckboxStateChange?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['checkbox_state_change']>;\n onAfterRender?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['after_render']>;\n onInitialized?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['initialized']>;\n\n // pivot table only\n onPivotSortClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['pivot_sort_click']>;\n onDrillMenuClick?: EventCallback<TYPES.TableEventHandlersEventArgumentMap['drillmenu_click']>;\n\n // pivot chart only\n onVChartEventType?: EventCallback<TYPES.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] && props[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 TYPES.TableEventHandlersEventArgumentMap, newEventProps[eventKey]);\n }\n });\n }\n\n return true;\n};\n"]}
package/es/index.d.ts CHANGED
@@ -2,3 +2,4 @@ import * as VTable from '@visactor/vtable';
2
2
  export * from './tables';
3
3
  export * from './components';
4
4
  export { VTable };
5
+ export declare const version = "0.21.2";
package/es/index.js CHANGED
@@ -4,4 +4,7 @@ export * from "./tables";
4
4
 
5
5
  export * from "./components";
6
6
 
7
- export { VTable };
7
+ export { VTable };
8
+
9
+ export const version = "0.21.2";
10
+ //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,CAAC","file":"index.js","sourcesContent":["import * as VTable from '@visactor/vtable';\n\nexport * from './tables';\nexport * from './components';\nexport { VTable };\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","file":"index.js","sourcesContent":["import * as VTable from '@visactor/vtable';\n\nexport * from './tables';\nexport * from './components';\nexport { VTable };\n\nexport const version = \"0.21.2\";\n"]}
@@ -8,7 +8,7 @@ export interface BaseTableProps extends EventsProps {
8
8
  type?: string;
9
9
  container?: HTMLDivElement;
10
10
  option?: any;
11
- records?: any;
11
+ records?: Record<string, unknown>[];
12
12
  width?: number;
13
13
  height?: number;
14
14
  skipFunctionDiff?: boolean;
@@ -6,7 +6,7 @@ import withContainer from "../containers/withContainer";
6
6
 
7
7
  import RootTableContext from "../context/table";
8
8
 
9
- import { isEqual, pickWithout } from "@visactor/vutils";
9
+ import { isEqual, isNil, pickWithout } from "@visactor/vutils";
10
10
 
11
11
  import { toArray } from "../util";
12
12
 
@@ -14,12 +14,14 @@ import { REACT_PRIVATE_PROPS } from "../constants";
14
14
 
15
15
  import { bindEventsToTable, TABLE_EVENTS_KEYS, TABLE_EVENTS } from "../eventsUtils";
16
16
 
17
- const notOptionKeys = [ ...REACT_PRIVATE_PROPS, ...TABLE_EVENTS_KEYS, "skipFunctionDiff", "onError", "onReady", "option", "records", "container" ], parseOptionFromChildren = props => {
17
+ const notOptionKeys = [ ...REACT_PRIVATE_PROPS, ...TABLE_EVENTS_KEYS, "skipFunctionDiff", "onError", "onReady", "option", "records", "container" ], getComponentId = (child, index) => `${child && child.type && (child.type.displayName || child.type.name)}-${index}`, parseOptionFromChildren = props => {
18
18
  const optionFromChildren = {};
19
- return toArray(props.children).map((child => {
19
+ return toArray(props.children).map(((child, index) => {
20
20
  const parseOption = child && child.type && child.type.parseOption;
21
21
  if (parseOption && child.props) {
22
- const optionResult = parseOption(child.props);
22
+ const optionResult = parseOption(isNil(child.props.componentId) ? Object.assign(Object.assign({}, child.props), {
23
+ componentId: getComponentId(child, index)
24
+ }) : child.props);
23
25
  optionResult.isSingle ? optionFromChildren[optionResult.optionName] = optionResult.option : (optionFromChildren[optionResult.optionName] || (optionFromChildren[optionResult.optionName] = []),
24
26
  optionFromChildren[optionResult.optionName].push(optionResult.option));
25
27
  }
@@ -39,7 +41,7 @@ const notOptionKeys = [ ...REACT_PRIVATE_PROPS, ...TABLE_EVENTS_KEYS, "skipFunct
39
41
  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)),
40
42
  tableContext.current = Object.assign(Object.assign({}, tableContext.current), {
41
43
  table: vtable
42
- });
44
+ }), isUnmount.current = !1;
43
45
  }), [ parseOption ]), handleTableRender = useCallback((() => {
44
46
  if (!isUnmount.current) {
45
47
  if (!tableContext.current || !tableContext.current.table) return;
@@ -53,8 +55,7 @@ const notOptionKeys = [ ...REACT_PRIVATE_PROPS, ...TABLE_EVENTS_KEYS, "skipFunct
53
55
  var _a, _b;
54
56
  const newOptionFromChildren = hasOption ? null : parseOptionFromChildren(props);
55
57
  if (!(null === (_a = tableContext.current) || void 0 === _a ? void 0 : _a.table)) return hasOption || (optionFromChildren.current = newOptionFromChildren),
56
- createTable(props), renderTable(), bindEventsToTable(tableContext.current.table, props, null, TABLE_EVENTS),
57
- void (eventsBinded.current = props);
58
+ createTable(props), renderTable(), void (eventsBinded.current = props);
58
59
  if (hasOption) return void (isEqual(eventsBinded.current.option, props.option, {
59
60
  skipFunction: skipFunctionDiff
60
61
  }) ? hasRecords && !isEqual(eventsBinded.current.records, props.records, {
@@ -77,12 +78,12 @@ const notOptionKeys = [ ...REACT_PRIVATE_PROPS, ...TABLE_EVENTS_KEYS, "skipFunct
77
78
  }), [ createTable, hasOption, hasRecords, parseOption, handleTableRender, renderTable, skipFunctionDiff, props ]),
78
79
  useEffect((() => () => {
79
80
  tableContext && tableContext.current && tableContext.current.table && (tableContext.current.table.release(),
80
- tableContext.current = null), isUnmount.current = !0;
81
+ tableContext.current = null), eventsBinded.current = null, isUnmount.current = !0;
81
82
  }), []), React.createElement(RootTableContext.Provider, {
82
83
  value: tableContext.current
83
84
  }, toArray(props.children).map(((child, index) => {
84
85
  if ("string" == typeof child) return;
85
- const childId = `${child && child.type && (child.type.displayName || child.type.name)}-${index}`;
86
+ const childId = getComponentId(child, index);
86
87
  return React.createElement(React.Fragment, {
87
88
  key: childId
88
89
  }, React.cloneElement(child, {
@@ -1 +1 @@
1
- {"version":3,"sources":["tables/base-table.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE7F,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAExD,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CA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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","file":"base-table.js","sourcesContent":["/* eslint-disable react/display-name */\nimport * as VTable from '@visactor/vtable';\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;\nexport type IOption =\n | VTable.ListTableConstructorOptions\n | VTable.PivotTableConstructorOptions\n | VTable.PivotChartConstructorOptions;\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 parseOptionFromChildren = (props: Props) => {\n const optionFromChildren: Omit<IOption, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map(child => {\n const parseOption = child && (child as any).type && (child as any).type.parseOption;\n\n if (parseOption && (child as any).props) {\n const optionResult = parseOption((child as any).props);\n\n if (optionResult.isSingle) {\n optionFromChildren[optionResult.optionName] = optionResult.option;\n } else {\n if (!optionFromChildren[optionResult.optionName]) {\n optionFromChildren[optionResult.optionName] = [];\n }\n\n optionFromChildren[optionResult.optionName].push(optionResult.option);\n }\n }\n });\n\n return optionFromChildren;\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 optionFromChildren = useRef<Omit<IOption, 'records'>>(null);\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 return {\n records: props.records,\n ...prevOption.current,\n ...optionFromChildren.current\n // ...tableContext.current?.optionFromChildren\n } as IOption;\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 if (!isUnmount.current) {\n if (!tableContext.current || !tableContext.current.table) {\n return;\n }\n // rebind events after render\n bindEventsToTable(tableContext.current.table, props, eventsBinded.current, TABLE_EVENTS);\n\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 tableContext.current.table.render();\n handleTableRender();\n }\n }, [handleTableRender]);\n\n useEffect(() => {\n const newOptionFromChildren = hasOption ? null : parseOptionFromChildren(props);\n\n if (!tableContext.current?.table) {\n if (!hasOption) {\n optionFromChildren.current = newOptionFromChildren;\n }\n\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 handleTableRender();\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 restoreHierarchyState: props.option.restoreHierarchyState\n });\n handleTableRender();\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 !isEqual(newOptionFromChildren, optionFromChildren.current, { skipFunction: skipFunctionDiff })\n ) {\n prevOption.current = newOption;\n optionFromChildren.current = newOptionFromChildren;\n\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(parseOption(props));\n handleTableRender();\n } else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {\n prevRecords.current = props.records;\n tableContext.current.table.setRecords(props.records, {\n restoreHierarchyState: props.option?.restoreHierarchyState\n });\n handleTableRender();\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 && tableContext.current.table) {\n tableContext.current.table.release();\n tableContext.current = null;\n }\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 if (typeof child === 'string') {\n return;\n }\n\n const componentName =\n child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n const childId = `${componentName}-${index}`;\n\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 <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\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"]}
1
+ {"version":3,"sources":["tables/base-table.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,WAAW,E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K,KAAK,QAAQ,EAAE;YAC7B,OAAO;SACR;QAED,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAM7C,OAAO,CAML,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,OAAO,IACzB,KAAK,CAAC,YAAY,CAAC,KAAkE,EAAE;YACtF,QAAQ,EAAE,QAAQ;YAClB,WAAW,EAAE,OAAO;SACrB,CAAC,CACa,CAClB,CAAC;IACJ,CAAC,CAAC,CACwB,CAC7B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAkB,aAAqB,EAAE,IAAa,EAAE,QAA0B,EAAE,EAAE;IAC/G,MAAM,GAAG,GAAG,aAAa,CAAoB,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","file":"base-table.js","sourcesContent":["/* eslint-disable react/display-name */\nimport * as VTable from '@visactor/vtable';\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, isNil, 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;\nexport type IOption =\n | VTable.ListTableConstructorOptions\n | VTable.PivotTableConstructorOptions\n | VTable.PivotChartConstructorOptions;\n\nexport interface BaseTableProps extends EventsProps {\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /** option */\n option?: any;\n /** 数据 */\n records?: Record<string, unknown>[];\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 getComponentId = (child: React.ReactNode, index: number) => {\n const componentName = child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n return `${componentName}-${index}`;\n};\n\nconst parseOptionFromChildren = (props: Props) => {\n const optionFromChildren: Omit<IOption, 'type' | 'data' | 'width' | 'height'> = {};\n\n toArray(props.children).map((child, index) => {\n const parseOption = child && (child as any).type && (child as any).type.parseOption;\n\n if (parseOption && (child as any).props) {\n const childProps = isNil((child as any).props.componentId)\n ? {\n ...(child as any).props,\n componentId: getComponentId(child, index)\n }\n : (child as any).props;\n\n const optionResult = parseOption(childProps);\n\n if (optionResult.isSingle) {\n optionFromChildren[optionResult.optionName] = optionResult.option;\n } else {\n if (!optionFromChildren[optionResult.optionName]) {\n optionFromChildren[optionResult.optionName] = [];\n }\n\n optionFromChildren[optionResult.optionName].push(optionResult.option);\n }\n }\n });\n\n return optionFromChildren;\n};\n\nconst BaseTable: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const tableContext = useRef<TableContextType>({});\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 optionFromChildren = useRef<Omit<IOption, 'records'>>(null);\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 return {\n records: props.records,\n ...prevOption.current,\n ...optionFromChildren.current\n // ...tableContext.current?.optionFromChildren\n } as IOption;\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 isUnmount.current = false;\n },\n [parseOption]\n );\n\n const handleTableRender = useCallback(() => {\n if (!isUnmount.current) {\n if (!tableContext.current || !tableContext.current.table) {\n return;\n }\n // rebind events after render\n bindEventsToTable(tableContext.current.table, props, eventsBinded.current, TABLE_EVENTS);\n\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 tableContext.current.table.render();\n handleTableRender();\n }\n }, [handleTableRender]);\n\n useEffect(() => {\n const newOptionFromChildren = hasOption ? null : parseOptionFromChildren(props);\n\n if (!tableContext.current?.table) {\n if (!hasOption) {\n optionFromChildren.current = newOptionFromChildren;\n }\n\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 handleTableRender();\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 as any[], {\n restoreHierarchyState: props.option.restoreHierarchyState\n });\n handleTableRender();\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 !isEqual(newOptionFromChildren, optionFromChildren.current, { skipFunction: skipFunctionDiff })\n ) {\n prevOption.current = newOption;\n optionFromChildren.current = newOptionFromChildren;\n\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(parseOption(props));\n handleTableRender();\n } else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {\n prevRecords.current = props.records;\n tableContext.current.table.setRecords(props.records, {\n restoreHierarchyState: props.option?.restoreHierarchyState\n });\n handleTableRender();\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 && tableContext.current.table) {\n tableContext.current.table.release();\n tableContext.current = null;\n }\n }\n eventsBinded.current = null;\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 if (typeof child === 'string') {\n return;\n }\n\n const childId = getComponentId(child, index);\n\n // const componentName =\n // child && (child as any).type && ((child as any).type.displayName || (child as any).type.name);\n // const childId = `${componentName}-${index}`;\n\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 <React.Fragment key={childId}>\n {React.cloneElement(child as React.ReactElement<any, React.JSXElementConstructor<any>>, {\n updateId: updateId,\n componentId: childId\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"]}
package/es/util.js CHANGED
@@ -32,5 +32,4 @@ export const findAllByType = (children, type) => {
32
32
  export const findChildByType = (children, type) => {
33
33
  const result = findAllByType(children, type);
34
34
  return null == result ? void 0 : result[0];
35
- };
36
- //# sourceMappingURL=util.js.map
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/react-vtable",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "description": "The react version of VTable",
5
5
  "keywords": [
6
6
  "react",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@visactor/vutils": "~0.18.1",
47
47
  "react-is": "^18.2.0",
48
- "@visactor/vtable": "0.21.1"
48
+ "@visactor/vtable": "0.21.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@visactor/vchart": "1.9.6",
@@ -88,8 +88,8 @@
88
88
  "form-data": "~4.0.0",
89
89
  "axios": "^1.4.0",
90
90
  "@types/react-is": "^17.0.3",
91
- "@internal/eslint-config": "0.0.1",
92
91
  "@internal/bundler": "0.0.1",
92
+ "@internal/eslint-config": "0.0.1",
93
93
  "@internal/ts-config": "0.0.1"
94
94
  },
95
95
  "scripts": {
@@ -1,5 +0,0 @@
1
- import type { FC } from 'react';
2
- import React from 'react';
3
- type Props = React.PropsWithChildren<any>;
4
- export declare const ReactVTable: FC<Props>;
5
- export {};
package/cjs/index_old.js DELETED
@@ -1,36 +0,0 @@
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 vtable_1 = require("@visactor/vtable"), 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 vtable_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;
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index_old.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,6CAA6C;AAE7C,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,kBAAS,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 '@visactor/vtable';\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"]}
package/es/index_old.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { FC } from 'react';
2
- import React from 'react';
3
- type Props = React.PropsWithChildren<any>;
4
- export declare const ReactVTable: FC<Props>;
5
- export {};
package/es/index_old.js DELETED
@@ -1,29 +0,0 @@
1
- var __rest = this && this.__rest || function(s, e) {
2
- var t = {};
3
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
4
- if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
5
- var i = 0;
6
- 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]]);
7
- }
8
- return t;
9
- };
10
-
11
- import { ListTable } from "@visactor/vtable";
12
-
13
- import React from "react";
14
-
15
- import { useEffect, useRef } from "react";
16
-
17
- export const ReactVTable = props => {
18
- const {type: type, option: option, height: height = "100%", style: style} = props, restProps = __rest(props, [ "type", "option", "height", "style" ]), containerRef = useRef(null);
19
- return useEffect((() => {
20
- containerRef.current && (option.container = containerRef.current, new ListTable(option));
21
- }), [ option, type ]), React.createElement("div", Object.assign({
22
- style: Object.assign(Object.assign({}, style), {
23
- height: height
24
- })
25
- }, restProps, {
26
- ref: containerRef,
27
- id: "react-VTable"
28
- }));
29
- };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index_old.tsx"],"names":[],"mappings":";;;;;;;;;;;AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAI1C,MAAM,CAAC,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,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;YACxC,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;SACvB;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,2CACE,KAAK,kCACA,KAAK,KACR,MAAM,OAEJ,SAAS,IACb,GAAG,EAAE,YAAY,EACjB,EAAE,EAAC,cAAc,IACjB,CACH,CAAC;AACJ,CAAC,CAAC","file":"index_old.js","sourcesContent":["/* eslint-disable @typescript-eslint/no-duplicate-imports */\n/* eslint-disable @typescript-eslint/consistent-type-imports */\nimport { ListTable } from '@visactor/vtable';\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"]}