@visactor/react-vtable 0.19.1-alpha.0 → 0.19.2-alpha.0

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.
@@ -4,6 +4,7 @@ export interface BaseComponentProps {
4
4
  }
5
5
  type ComponentProps = BaseComponentProps & {
6
6
  updateId?: number;
7
+ componentId?: number;
7
8
  };
8
9
  export declare const createComponent: <T extends ComponentProps>(componentName: string, optionName: string, supportedEvents?: Record<string, string> | null, isSingle?: boolean) => React.FC<T>;
9
10
  export {};
@@ -33,49 +33,23 @@ Object.defineProperty(exports, "__esModule", {
33
33
  value: !0
34
34
  }), exports.createComponent = void 0;
35
35
 
36
- const react_1 = __importStar(require("react")), vutils_1 = require("@visactor/vutils"), table_1 = __importDefault(require("../context/table")), eventsUtils_1 = require("../eventsUtils"), util_1 = require("../util"), createComponent = (componentName, optionName, supportedEvents, isSingle) => {
37
- const ignoreKeys = [ "id", "updateId" ], notOptionKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys, Comp = props => {
38
- const context = (0, react_1.useContext)(table_1.default), id = react_1.default.useRef((0,
39
- vutils_1.isNil)(props.id) ? (0, util_1.uid)(optionName) : props.id), eventsBinded = react_1.default.useRef(null), updateId = react_1.default.useRef(props.updateId), componentOption = react_1.default.useRef();
36
+ const react_1 = __importStar(require("react")), vutils_1 = require("@visactor/vutils"), table_1 = __importDefault(require("../context/table")), eventsUtils_1 = require("../eventsUtils"), createComponent = (componentName, optionName, supportedEvents, isSingle) => {
37
+ const ignoreKeys = [ "id", "updateId", "componentId" ], notOptionKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys, Comp = props => {
38
+ const context = (0, react_1.useContext)(table_1.default), eventsBinded = react_1.default.useRef(null), updateId = react_1.default.useRef(props.updateId);
40
39
  if (props.updateId !== updateId.current) {
41
40
  updateId.current = props.updateId;
42
41
  !!supportedEvents && (0, eventsUtils_1.bindEventsToTable)(context.table, props, eventsBinded.current, supportedEvents) && (eventsBinded.current = props);
43
- } else {
44
- const newComponentOption = (0, vutils_1.pickWithout)(props, notOptionKeys);
45
- (0, vutils_1.isEqual)(newComponentOption, componentOption.current) || (componentOption.current = newComponentOption,
46
- updateToContext(context, id.current, optionName, isSingle, newComponentOption));
47
42
  }
48
43
  return (0, react_1.useEffect)((() => () => {
49
- supportedEvents && (0, eventsUtils_1.bindEventsToTable)(context.table, null, eventsBinded.current, supportedEvents),
50
- deleteToContext(context, id.current, optionName, isSingle);
44
+ supportedEvents && (0, eventsUtils_1.bindEventsToTable)(context.table, null, eventsBinded.current, supportedEvents);
51
45
  }), []), null;
52
46
  };
53
- return Comp.displayName = componentName, Comp;
47
+ return Comp.displayName = componentName, Comp.parseOption = props => ({
48
+ option: (0, vutils_1.pickWithout)(props, notOptionKeys),
49
+ optionName: optionName,
50
+ isSingle: isSingle
51
+ }), Comp;
54
52
  };
55
53
 
56
54
  exports.createComponent = createComponent;
57
-
58
- const updateToContext = (context, id, optionName, isSingle, props) => {
59
- if (context.optionFromChildren) {
60
- if (isSingle) context.optionFromChildren[optionName] = Object.assign({}, props); else {
61
- context.optionFromChildren[optionName] || (context.optionFromChildren[optionName] = []);
62
- const comps = context.optionFromChildren[optionName], index = comps.findIndex((entry => entry.id === id));
63
- index >= 0 ? comps[index] = Object.assign({
64
- id: id
65
- }, props) : context.optionFromChildren[optionName].push(Object.assign({
66
- id: id
67
- }, props));
68
- }
69
- context.isChildrenUpdated = !0;
70
- }
71
- }, deleteToContext = (context, id, optionName, isSingle) => {
72
- var _a;
73
- if (context.optionFromChildren) if (isSingle) context.optionFromChildren[optionName] = null; else {
74
- const comps = null !== (_a = context.optionFromChildren[optionName]) && void 0 !== _a ? _a : [], index = comps.findIndex((entry => entry.id === id));
75
- if (index >= 0) {
76
- const newComps = comps.slice(0, index - 1).concat(comps.slice(index + 1));
77
- context.optionFromChildren[optionName] = newComps, context.isChildrenUpdated = !0;
78
- }
79
- }
80
- };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CAAC,CAAC,CAAC;YAE1E,OAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;YAClD,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;SAClC;KACF;AACH,CAAC,CAAC","file":"base-component.js","sourcesContent":["import React, { useContext, useEffect } from 'react';\nimport { isEqual, isNil, pickWithout } from '@visactor/vutils';\n\nimport type { TableContextType } from '../context/table';\nimport RootTableContext from '../context/table';\nimport { bindEventsToTable } from '../eventsUtils';\nimport { uid } from '../util';\n\nexport interface BaseComponentProps {\n id?: string | number;\n}\n\ntype ComponentProps = BaseComponentProps & { updateId?: number };\n\nexport const createComponent = <T extends ComponentProps>(\n componentName: string,\n optionName: string,\n supportedEvents?: Record<string, string> | null,\n isSingle?: boolean\n) => {\n const ignoreKeys = ['id', 'updateId'];\n const notOptionKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys;\n\n const Comp: React.FC<T> = (props: T) => {\n const context = useContext(RootTableContext);\n const id = React.useRef<string | number>(isNil(props.id) ? uid(optionName) : props.id);\n\n const eventsBinded = React.useRef<T>(null);\n const updateId = React.useRef<number>(props.updateId);\n const componentOption = React.useRef<Partial<T>>();\n\n if (props.updateId !== updateId.current) {\n // update triggered by table when table is rendered\n updateId.current = props.updateId;\n\n // rebind events after table render\n const hasPrevEventsBinded = supportedEvents\n ? bindEventsToTable(context.table, props, eventsBinded.current, supportedEvents)\n : false;\n if (hasPrevEventsBinded) {\n eventsBinded.current = props;\n }\n } else {\n const newComponentOption: Partial<T> = pickWithout<T>(props, notOptionKeys);\n\n if (!isEqual(newComponentOption, componentOption.current)) {\n componentOption.current = newComponentOption;\n updateToContext(context, id.current, optionName, isSingle, newComponentOption);\n }\n }\n\n useEffect(() => {\n return () => {\n if (supportedEvents) {\n bindEventsToTable(context.table, null, eventsBinded.current, supportedEvents);\n }\n deleteToContext(context, id.current, optionName, isSingle);\n };\n }, []);\n\n return null;\n };\n\n Comp.displayName = componentName;\n return Comp;\n};\n\nconst updateToContext = (\n context: TableContextType,\n id: string | number,\n optionName: string,\n isSingle: boolean,\n props: Partial<ComponentProps>\n) => {\n if (!context.optionFromChildren) {\n return;\n }\n\n if (isSingle) {\n context.optionFromChildren[optionName] = { ...props };\n } else {\n if (!context.optionFromChildren[optionName]) {\n context.optionFromChildren[optionName] = [];\n }\n\n const comps = context.optionFromChildren[optionName];\n const index = comps.findIndex((entry: any) => entry.id === id);\n\n if (index >= 0) {\n comps[index] = {\n id,\n ...props\n };\n } else {\n context.optionFromChildren[optionName].push({\n id,\n ...props\n });\n }\n }\n context.isChildrenUpdated = true;\n};\n\nconst deleteToContext = (context: TableContextType, id: string | number, optionName: string, isSingle: boolean) => {\n if (!context.optionFromChildren) {\n return;\n }\n\n if (isSingle) {\n context.optionFromChildren[optionName] = null;\n } else {\n const comps = context.optionFromChildren[optionName] ?? [];\n const index = comps.findIndex((entry: any) => entry.id === id);\n\n if (index >= 0) {\n const newComps = comps.slice(0, index - 1).concat(comps.slice(index + 1));\n\n context.optionFromChildren[optionName] = newComps;\n context.isChildrenUpdated = true;\n }\n }\n};\n"]}
1
+ {"version":3,"sources":["components/base-component.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,6CAA+D;AAG/D,6DAAgD;AAChD,gDAAmD;AAS5C,MAAM,eAAe,GAAG,CAC7B,aAAqB,EACrB,UAAkB,EAClB,eAA+C,EAC/C,QAAkB,EAClB,EAAE;IACF,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,aAAa,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAErG,MAAM,IAAI,GAAgB,CAAC,KAAQ,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,IAAA,kBA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import { isEqual, isNil, pickWithout } from '@visactor/vutils';\n\nimport type { TableContextType } from '../context/table';\nimport RootTableContext from '../context/table';\nimport { bindEventsToTable } from '../eventsUtils';\nimport { uid } from '../util';\n\nexport interface BaseComponentProps {\n id?: string | number;\n}\n\ntype ComponentProps = BaseComponentProps & { updateId?: number; componentId?: number };\n\nexport const createComponent = <T extends ComponentProps>(\n componentName: string,\n optionName: string,\n supportedEvents?: Record<string, string> | null,\n isSingle?: boolean\n) => {\n const ignoreKeys = ['id', 'updateId', 'componentId'];\n const notOptionKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys;\n\n const Comp: React.FC<T> = (props: T) => {\n const context = useContext(RootTableContext);\n // const id = React.useRef<string | number>(isNil(props.id) ? uid(optionName) : props.id);\n\n const eventsBinded = React.useRef<T>(null);\n const updateId = React.useRef<number>(props.updateId);\n // const componentOption = React.useRef<Partial<T>>();\n\n if (props.updateId !== updateId.current) {\n // update triggered by table when table is rendered\n updateId.current = props.updateId;\n\n // rebind events after table render\n const hasPrevEventsBinded = supportedEvents\n ? bindEventsToTable(context.table, props, eventsBinded.current, supportedEvents)\n : false;\n if (hasPrevEventsBinded) {\n eventsBinded.current = props;\n }\n // } else {\n // const newComponentOption: Partial<T> = pickWithout<T>(props, notOptionKeys);\n\n // if (!isEqual(newComponentOption, componentOption.current)) {\n // componentOption.current = newComponentOption;\n // updateToContext(context, id.current, optionName, isSingle, newComponentOption);\n // }\n }\n\n useEffect(() => {\n return () => {\n if (supportedEvents) {\n bindEventsToTable(context.table, null, eventsBinded.current, supportedEvents);\n }\n // deleteToContext(context, id.current, optionName, isSingle);\n };\n }, []);\n\n return null;\n };\n\n Comp.displayName = componentName;\n\n (Comp as any).parseOption = (props: T & { updateId?: number; componentId?: string }) => {\n const newComponentOption: Partial<T> = pickWithout<T>(props, notOptionKeys);\n\n return {\n option: newComponentOption,\n optionName,\n isSingle\n };\n };\n\n return Comp;\n};\n\n// const updateToContext = (\n// context: TableContextType,\n// id: string | number,\n// optionName: string,\n// isSingle: boolean,\n// props: Partial<ComponentProps>\n// ) => {\n// if (!context.optionFromChildren) {\n// return;\n// }\n\n// if (isSingle) {\n// context.optionFromChildren[optionName] = { ...props };\n// } else {\n// if (!context.optionFromChildren[optionName]) {\n// context.optionFromChildren[optionName] = [];\n// }\n\n// const comps = context.optionFromChildren[optionName];\n// const index = comps.findIndex((entry: any) => entry.id === id);\n\n// if (index >= 0) {\n// comps[index] = {\n// id,\n// ...props\n// };\n// } else {\n// context.optionFromChildren[optionName].push({\n// id,\n// ...props\n// });\n// }\n// }\n// context.isChildrenUpdated = true;\n// };\n\n// const deleteToContext = (context: TableContextType, id: string | number, optionName: string, isSingle: boolean) => {\n// if (!context.optionFromChildren) {\n// return;\n// }\n\n// if (isSingle) {\n// context.optionFromChildren[optionName] = null;\n// } else {\n// const comps = context.optionFromChildren[optionName] ?? [];\n// const index = comps.findIndex((entry: any) => entry.id === id);\n\n// if (index >= 0) {\n// const newComps = comps.slice(0, index - 1).concat(comps.slice(index + 1));\n\n// context.optionFromChildren[optionName] = newComps;\n// context.isChildrenUpdated = true;\n// }\n// }\n// };\n"]}
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import type { ListTable, PivotTable, PivotChart } from '@visactor/vtable';
3
3
  export interface TableContextType {
4
4
  table?: ListTable | PivotTable | PivotChart;
5
- optionFromChildren: any;
6
5
  isChildrenUpdated?: boolean;
7
6
  }
8
7
  declare const TableContext: React.Context<TableContextType>;
@@ -1 +1 @@
1
- {"version":3,"sources":["context/table.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAS1B,MAAM,YAAY,GAAG,eAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AACjE,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,SAAgB,iBAAiB,CAAI,SAAiC;IACpE,MAAM,GAAG,GAAG,eAAK,CAAC,UAAU,CAAS,CAAC,KAAQ,EAAE,GAAG,EAAE,EAAE;QACrD,OAAO,CACL,8BAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,GAAqB,EAAE,EAAE,CAAC,8BAAC,SAAS,kBAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,IAAM,KAAK,EAAI,CAC1D,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC;AAVD,8CAUC;AAED,kBAAe,YAAY,CAAC","file":"table.js","sourcesContent":["import React from 'react';\nimport type { ListTable, PivotTable, PivotChart } from '@visactor/vtable';\n\nexport interface TableContextType {\n table?: ListTable | PivotTable | PivotChart;\n optionFromChildren: any;\n isChildrenUpdated?: boolean;\n}\n\nconst TableContext = React.createContext<TableContextType>(null);\nTableContext.displayName = 'TableContext';\n\nexport function withTableInstance<T>(Component: typeof React.Component) {\n const Com = React.forwardRef<any, T>((props: T, ref) => {\n return (\n <TableContext.Consumer>\n {(ctx: TableContextType) => <Component ref={ref} table={ctx.table} {...props} />}\n </TableContext.Consumer>\n );\n });\n Com.displayName = Component.name;\n return Com;\n}\n\nexport default TableContext;\n"]}
1
+ {"version":3,"sources":["context/table.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAS1B,MAAM,YAAY,GAAG,eAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AACjE,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,SAAgB,iBAAiB,CAAI,SAAiC;IACpE,MAAM,GAAG,GAAG,eAAK,CAAC,UAAU,CAAS,CAAC,KAAQ,EAAE,GAAG,EAAE,EAAE;QACrD,OAAO,CACL,8BAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,GAAqB,EAAE,EAAE,CAAC,8BAAC,SAAS,kBAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,IAAM,KAAK,EAAI,CAC1D,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC;AAVD,8CAUC;AAED,kBAAe,YAAY,CAAC","file":"table.js","sourcesContent":["import React from 'react';\nimport type { ListTable, PivotTable, PivotChart } from '@visactor/vtable';\n\nexport interface TableContextType {\n table?: ListTable | PivotTable | PivotChart;\n // optionFromChildren: any;\n isChildrenUpdated?: boolean;\n}\n\nconst TableContext = React.createContext<TableContextType>(null);\nTableContext.displayName = 'TableContext';\n\nexport function withTableInstance<T>(Component: typeof React.Component) {\n const Com = React.forwardRef<any, T>((props: T, ref) => {\n return (\n <TableContext.Consumer>\n {(ctx: TableContextType) => <Component ref={ref} table={ctx.table} {...props} />}\n </TableContext.Consumer>\n );\n });\n Com.displayName = Component.name;\n return Com;\n}\n\nexport default TableContext;\n"]}
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import type { ContainerProps } from '../containers/withContainer';
4
4
  import type { EventsProps } from '../eventsUtils';
5
5
  export type IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;
6
+ export type IOption = VTable.ListTableConstructorOptions | VTable.PivotTableConstructorOptions | VTable.PivotChartConstructorOptions;
6
7
  export interface BaseTableProps extends EventsProps {
7
8
  type?: string;
8
9
  container?: HTMLDivElement;
@@ -33,19 +33,30 @@ 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" ], BaseTable = react_1.default.forwardRef(((props, ref) => {
37
- const [updateId, setUpdateId] = (0, react_1.useState)(0), tableContext = (0, react_1.useRef)({
38
- optionFromChildren: {}
39
- });
40
- (0, react_1.useImperativeHandle)(ref, (() => tableContext.current.table));
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 => {
37
+ const optionFromChildren = {};
38
+ return (0, util_1.toArray)(props.children).map((child => {
39
+ const parseOption = child && child.type && child.type.parseOption;
40
+ if (parseOption && child.props) {
41
+ const optionResult = parseOption(child.props);
42
+ optionResult.isSingle ? optionFromChildren[optionResult.optionName] = optionResult.option : (optionFromChildren[optionResult.optionName] || (optionFromChildren[optionResult.optionName] = []),
43
+ optionFromChildren[optionResult.optionName].push(optionResult.option));
44
+ }
45
+ })), optionFromChildren;
46
+ }, BaseTable = react_1.default.forwardRef(((props, ref) => {
47
+ const [updateId, setUpdateId] = (0, react_1.useState)(0), tableContext = (0, react_1.useRef)({});
48
+ (0, react_1.useImperativeHandle)(ref, (() => {
49
+ var _a;
50
+ return null === (_a = tableContext.current) || void 0 === _a ? void 0 : _a.table;
51
+ }));
41
52
  const hasOption = !!props.option, hasRecords = !!props.records, isUnmount = (0,
42
- react_1.useRef)(!1), prevOption = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notOptionKeys)), prevRecords = (0,
43
- react_1.useRef)(props.records), eventsBinded = react_1.default.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, parseOption = (0,
53
+ react_1.useRef)(!1), prevOption = (0, react_1.useRef)((0, vutils_1.pickWithout)(props, notOptionKeys)), optionFromChildren = (0,
54
+ react_1.useRef)(null), prevRecords = (0, react_1.useRef)(props.records), eventsBinded = react_1.default.useRef(null), skipFunctionDiff = !!props.skipFunctionDiff, parseOption = (0,
44
55
  react_1.useCallback)((props => hasOption && props.option ? hasRecords && props.records ? Object.assign(Object.assign({}, props.option), {
45
56
  records: props.records
46
57
  }) : props.option : Object.assign(Object.assign({
47
58
  records: props.records
48
- }, prevOption.current), tableContext.current.optionFromChildren)), [ hasOption, hasRecords ]), createTable = (0,
59
+ }, prevOption.current), optionFromChildren.current)), [ hasOption, hasRecords ]), createTable = (0,
49
60
  react_1.useCallback)((props => {
50
61
  let vtable;
51
62
  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)),
@@ -53,68 +64,50 @@ const VTable = __importStar(require("@visactor/vtable")), react_1 = __importStar
53
64
  table: vtable
54
65
  });
55
66
  }), [ parseOption ]), handleTableRender = (0, react_1.useCallback)((() => {
56
- (0, eventsUtils_1.bindEventsToTable)(tableContext.current.table, props, eventsBinded.current, eventsUtils_1.TABLE_EVENTS),
57
- isUnmount.current || (setUpdateId(updateId + 1), props.onReady && props.onReady(tableContext.current.table, 0 === updateId));
58
- }), [ updateId, setUpdateId, props ]), renderTable = (0, react_1.useCallback)((() => {
59
- if (tableContext.current.table) {
60
- const renderPromise = tableContext.current.table.renderAsync().then(handleTableRender);
61
- props.onError && renderPromise.catch(props.onError);
67
+ if (!isUnmount.current) {
68
+ if (!tableContext.current || !tableContext.current.table) return;
69
+ (0, eventsUtils_1.bindEventsToTable)(tableContext.current.table, props, eventsBinded.current, eventsUtils_1.TABLE_EVENTS),
70
+ setUpdateId(updateId + 1), props.onReady && props.onReady(tableContext.current.table, 0 === updateId);
62
71
  }
63
- }), [ handleTableRender, props ]);
72
+ }), [ updateId, setUpdateId, props ]), renderTable = (0, react_1.useCallback)((() => {
73
+ tableContext.current.table && (tableContext.current.table.render(), handleTableRender());
74
+ }), [ handleTableRender ]);
64
75
  return (0, react_1.useEffect)((() => {
65
76
  var _a;
66
- if (!(null === (_a = tableContext.current) || void 0 === _a ? void 0 : _a.table)) return createTable(props),
67
- renderTable(), (0, eventsUtils_1.bindEventsToTable)(tableContext.current.table, props, null, eventsUtils_1.TABLE_EVENTS),
68
- tableContext.current = Object.assign(Object.assign({}, tableContext.current), {
69
- isChildrenUpdated: !1
70
- }), void (eventsBinded.current = props);
71
- if (hasOption) {
72
- if ((0, vutils_1.isEqual)(eventsBinded.current.option, props.option, {
73
- skipFunction: skipFunctionDiff
74
- })) {
75
- if (hasRecords && !(0, vutils_1.isEqual)(eventsBinded.current.records, props.records, {
76
- skipFunction: skipFunctionDiff
77
- })) {
78
- eventsBinded.current = props, tableContext.current.table.setRecords(props.records);
79
- const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
80
- props.onError && updatePromise.catch(props.onError);
81
- }
82
- } else {
83
- eventsBinded.current = props, tableContext.current.table.updateOption(parseOption(props));
84
- const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
85
- props.onError && updatePromise.catch(props.onError);
86
- }
87
- return;
88
- }
77
+ const newOptionFromChildren = hasOption ? null : parseOptionFromChildren(props);
78
+ 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
+ if (hasOption) return void ((0, vutils_1.isEqual)(eventsBinded.current.option, props.option, {
82
+ skipFunction: skipFunctionDiff
83
+ }) ? hasRecords && !(0, vutils_1.isEqual)(eventsBinded.current.records, props.records, {
84
+ skipFunction: skipFunctionDiff
85
+ }) && (eventsBinded.current = props, tableContext.current.table.setRecords(props.records),
86
+ handleTableRender()) : (eventsBinded.current = props, tableContext.current.table.updateOption(parseOption(props)),
87
+ handleTableRender()));
89
88
  const newOption = (0, vutils_1.pickWithout)(props, notOptionKeys);
90
- if (!(0, vutils_1.isEqual)(newOption, prevOption.current, {
89
+ (0, vutils_1.isEqual)(newOption, prevOption.current, {
91
90
  skipFunction: skipFunctionDiff
92
- }) || tableContext.current.isChildrenUpdated) {
93
- prevOption.current = newOption, tableContext.current.table.updateOption(parseOption(props));
94
- const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
95
- props.onError && updatePromise.catch(props.onError);
96
- } else if (hasRecords && !(0, vutils_1.isEqual)(props.records, prevRecords.current, {
91
+ }) && (0, vutils_1.isEqual)(newOptionFromChildren, optionFromChildren.current) ? hasRecords && !(0,
92
+ vutils_1.isEqual)(props.records, prevRecords.current, {
97
93
  skipFunction: skipFunctionDiff
98
- })) {
99
- prevRecords.current = props.records, tableContext.current.table.setRecords(props.records);
100
- const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
101
- props.onError && updatePromise.catch(props.onError);
102
- }
103
- tableContext.current = Object.assign(Object.assign({}, tableContext.current), {
104
- isChildrenUpdated: !1
105
- });
94
+ }) && (prevRecords.current = props.records, tableContext.current.table.setRecords(props.records),
95
+ handleTableRender()) : (prevOption.current = newOption, optionFromChildren.current = newOptionFromChildren,
96
+ tableContext.current.table.updateOption(parseOption(props)), handleTableRender());
106
97
  }), [ createTable, hasOption, hasRecords, parseOption, handleTableRender, renderTable, skipFunctionDiff, props ]),
107
98
  (0, react_1.useEffect)((() => () => {
108
- tableContext && (tableContext.current.table && tableContext.current.table.release(),
99
+ tableContext && tableContext.current && tableContext.current.table && (tableContext.current.table.release(),
109
100
  tableContext.current = null), isUnmount.current = !0;
110
101
  }), []), react_1.default.createElement(table_1.default.Provider, {
111
102
  value: tableContext.current
112
103
  }, (0, util_1.toArray)(props.children).map(((child, index) => {
113
- var _a, _b, _c;
104
+ if ("string" == typeof child) return;
105
+ const childId = `${child && child.type && (child.type.displayName || child.type.name)}-${index}`;
114
106
  return react_1.default.createElement(react_1.default.Fragment, {
115
- key: null !== (_c = null !== (_b = null === (_a = null == child ? void 0 : child.props) || void 0 === _a ? void 0 : _a.id) && void 0 !== _b ? _b : null == child ? void 0 : child.id) && void 0 !== _c ? _c : `child-${index}`
107
+ key: childId
116
108
  }, react_1.default.cloneElement(child, {
117
- updateId: updateId
109
+ updateId: updateId,
110
+ componentId: childId
118
111
  }));
119
112
  })));
120
113
  })), createTable = (componentName, type, callback) => {
@@ -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;AA0BpF,MAAM,aAAa,GAAG;IACpB,GAAG,+BAAmB;IACtB,GAAG,+BAAiB;IACpB,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,WAAW;CACZ,CAAC;AAEF,MAAM,SAAS,GAAoB,eAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAS,CAAC,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,IAAA,cAAM,EAAmB;QAC5C,kBAAkB,EAAE,EAAE;KACvB,CAAC,CAAC;IACH,IAAA,2BAAmB,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IACjC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;IACnC,MAAM,SAAS,GAAG,IAAA,cAAM,EAAU,KAAK,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG,IAAA,cAAM,EAAC,IAAA,oBAAW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AQ,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;\n\nexport interface BaseTableProps extends EventsProps {\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /** option */\n option?: any;\n /** 数据 */\n records?: any;\n /** 画布宽度 */\n width?: number;\n /** 画布高度 */\n height?: number;\n skipFunctionDiff?: boolean;\n\n /** 表格渲染完成事件 */\n onReady?: (instance: IVTable, isInitial: boolean) => void;\n /** throw error when chart run into an error */\n onError?: (err: Error) => void;\n}\n\ntype Props = React.PropsWithChildren<BaseTableProps>;\n\nconst notOptionKeys = [\n ...REACT_PRIVATE_PROPS,\n ...TABLE_EVENTS_KEYS,\n 'skipFunctionDiff',\n 'onError',\n 'onReady',\n 'option',\n 'records',\n 'container'\n];\n\nconst BaseTable: React.FC<Props> = React.forwardRef((props, ref) => {\n const [updateId, setUpdateId] = useState<number>(0);\n const tableContext = useRef<TableContextType>({\n optionFromChildren: {}\n });\n useImperativeHandle(ref, () => tableContext.current.table);\n const hasOption = !!props.option;\n const hasRecords = !!props.records;\n const isUnmount = useRef<boolean>(false);\n const prevOption = useRef(pickWithout(props, notOptionKeys));\n const prevRecords = useRef(props.records);\n const eventsBinded = React.useRef<BaseTableProps>(null);\n const skipFunctionDiff = !!props.skipFunctionDiff;\n\n const parseOption = useCallback(\n (props: Props) => {\n if (hasOption && props.option) {\n if (hasRecords && props.records) {\n return {\n ...props.option,\n records: props.records\n };\n }\n return props.option;\n }\n\n return {\n records: props.records,\n ...prevOption.current,\n ...tableContext.current.optionFromChildren\n };\n },\n [hasOption, hasRecords]\n );\n\n const createTable = useCallback(\n (props: Props) => {\n let vtable;\n if (props.type === 'pivot-table') {\n vtable = new VTable.PivotTable(props.container, parseOption(props));\n } else if (props.type === 'pivot-chart') {\n vtable = new VTable.PivotChart(props.container, parseOption(props));\n } else {\n vtable = new VTable.ListTable(props.container, parseOption(props));\n }\n tableContext.current = { ...tableContext.current, table: vtable };\n },\n [parseOption]\n );\n\n const handleTableRender = useCallback(() => {\n // rebind events after render\n bindEventsToTable(tableContext.current.table, props, eventsBinded.current, TABLE_EVENTS);\n\n if (!isUnmount.current) {\n // to be fixed\n // will cause another useEffect\n setUpdateId(updateId + 1);\n if (props.onReady) {\n props.onReady(tableContext.current.table, updateId === 0);\n }\n }\n }, [updateId, setUpdateId, props]);\n\n const renderTable = useCallback(() => {\n if (tableContext.current.table) {\n // eslint-disable-next-line promise/catch-or-return\n const renderPromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n renderPromise.catch(props.onError);\n }\n }\n }, [handleTableRender, props]);\n\n useEffect(() => {\n if (!tableContext.current?.table) {\n createTable(props);\n renderTable();\n bindEventsToTable(tableContext.current.table, props, null, TABLE_EVENTS);\n tableContext.current = {\n ...tableContext.current,\n isChildrenUpdated: false\n };\n eventsBinded.current = props;\n return;\n }\n\n if (hasOption) {\n if (!isEqual(eventsBinded.current.option, props.option, { skipFunction: skipFunctionDiff })) {\n eventsBinded.current = props;\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(parseOption(props));\n const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n updatePromise.catch(props.onError);\n }\n } else if (\n hasRecords &&\n !isEqual(eventsBinded.current.records, props.records, { skipFunction: skipFunctionDiff })\n ) {\n eventsBinded.current = props;\n tableContext.current.table.setRecords(props.records);\n const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n updatePromise.catch(props.onError);\n }\n }\n return;\n }\n\n const newOption = pickWithout(props, notOptionKeys);\n\n if (\n !isEqual(newOption, prevOption.current, { skipFunction: skipFunctionDiff }) ||\n tableContext.current.isChildrenUpdated\n ) {\n prevOption.current = newOption;\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(parseOption(props));\n const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n updatePromise.catch(props.onError);\n }\n } else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {\n prevRecords.current = props.records;\n tableContext.current.table.setRecords(props.records);\n const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);\n\n if (props.onError) {\n updatePromise.catch(props.onError);\n }\n }\n tableContext.current = {\n ...tableContext.current,\n isChildrenUpdated: false\n };\n }, [createTable, hasOption, hasRecords, parseOption, handleTableRender, renderTable, skipFunctionDiff, props]);\n\n useEffect(() => {\n return () => {\n if (tableContext) {\n if (tableContext.current.table) {\n tableContext.current.table.release();\n }\n tableContext.current = null;\n }\n isUnmount.current = true;\n };\n }, []);\n\n return (\n <RootTableContext.Provider value={tableContext.current}>\n {toArray(props.children).map((child: React.ReactNode, index: number) => {\n return (\n <React.Fragment key={(child as any)?.props?.id ?? (child as any)?.id ?? `child-${index}`}>\n {React.cloneElement(child as IMarkElement, {\n updateId: updateId\n })}\n </React.Fragment>\n );\n })}\n </RootTableContext.Provider>\n );\n});\n\nexport const createTable = <T extends Props>(componentName: string, type?: string, callback?: (props: T) => T) => {\n const Com = withContainer<ContainerProps, T>(BaseTable as any, componentName, (props: T) => {\n props.type = type;\n\n if (callback) {\n return callback(props);\n }\n\n if (type) {\n return { ...props, type };\n }\n return props;\n });\n Com.displayName = componentName;\n return Com;\n};\n"]}
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,CAAC;YAEvD,IAAI,YAAY,CAAC,QAAQ,EAAE;gBACzB,kBAAkB,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;aACnE;iBAAM;gBACL,IAAI,CAA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,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 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)\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 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"]}
@@ -3242,13 +3242,6 @@
3242
3242
  }
3243
3243
  var reactIsExports = reactIs.exports;
3244
3244
 
3245
- let id = 0;
3246
- const uid = (prefix) => {
3247
- if (prefix) {
3248
- return `${prefix}-${id++}`;
3249
- }
3250
- return `${id++}`;
3251
- };
3252
3245
  const toArray = (children) => {
3253
3246
  let result = [];
3254
3247
  React.Children.forEach(children, child => {
@@ -3356,16 +3349,34 @@
3356
3349
  'records',
3357
3350
  'container'
3358
3351
  ];
3352
+ const parseOptionFromChildren = (props) => {
3353
+ const optionFromChildren = {};
3354
+ toArray(props.children).map(child => {
3355
+ const parseOption = child && child.type && child.type.parseOption;
3356
+ if (parseOption && child.props) {
3357
+ const optionResult = parseOption(child.props);
3358
+ if (optionResult.isSingle) {
3359
+ optionFromChildren[optionResult.optionName] = optionResult.option;
3360
+ }
3361
+ else {
3362
+ if (!optionFromChildren[optionResult.optionName]) {
3363
+ optionFromChildren[optionResult.optionName] = [];
3364
+ }
3365
+ optionFromChildren[optionResult.optionName].push(optionResult.option);
3366
+ }
3367
+ }
3368
+ });
3369
+ return optionFromChildren;
3370
+ };
3359
3371
  const BaseTable = React.forwardRef((props, ref) => {
3360
3372
  const [updateId, setUpdateId] = reactExports.useState(0);
3361
- const tableContext = reactExports.useRef({
3362
- optionFromChildren: {}
3363
- });
3364
- reactExports.useImperativeHandle(ref, () => tableContext.current.table);
3373
+ const tableContext = reactExports.useRef({});
3374
+ reactExports.useImperativeHandle(ref, () => tableContext.current?.table);
3365
3375
  const hasOption = !!props.option;
3366
3376
  const hasRecords = !!props.records;
3367
3377
  const isUnmount = reactExports.useRef(false);
3368
3378
  const prevOption = reactExports.useRef(pickWithout(props, notOptionKeys));
3379
+ const optionFromChildren = reactExports.useRef(null);
3369
3380
  const prevRecords = reactExports.useRef(props.records);
3370
3381
  const eventsBinded = React.useRef(null);
3371
3382
  const skipFunctionDiff = !!props.skipFunctionDiff;
@@ -3382,7 +3393,7 @@
3382
3393
  return {
3383
3394
  records: props.records,
3384
3395
  ...prevOption.current,
3385
- ...tableContext.current.optionFromChildren
3396
+ ...optionFromChildren.current
3386
3397
  };
3387
3398
  }, [hasOption, hasRecords]);
3388
3399
  const createTable = reactExports.useCallback((props) => {
@@ -3399,8 +3410,11 @@
3399
3410
  tableContext.current = { ...tableContext.current, table: vtable };
3400
3411
  }, [parseOption]);
3401
3412
  const handleTableRender = reactExports.useCallback(() => {
3402
- bindEventsToTable(tableContext.current.table, props, eventsBinded.current, TABLE_EVENTS);
3403
3413
  if (!isUnmount.current) {
3414
+ if (!tableContext.current || !tableContext.current.table) {
3415
+ return;
3416
+ }
3417
+ bindEventsToTable(tableContext.current.table, props, eventsBinded.current, TABLE_EVENTS);
3404
3418
  setUpdateId(updateId + 1);
3405
3419
  if (props.onReady) {
3406
3420
  props.onReady(tableContext.current.table, updateId === 0);
@@ -3409,21 +3423,19 @@
3409
3423
  }, [updateId, setUpdateId, props]);
3410
3424
  const renderTable = reactExports.useCallback(() => {
3411
3425
  if (tableContext.current.table) {
3412
- const renderPromise = tableContext.current.table.renderAsync().then(handleTableRender);
3413
- if (props.onError) {
3414
- renderPromise.catch(props.onError);
3415
- }
3426
+ tableContext.current.table.render();
3427
+ handleTableRender();
3416
3428
  }
3417
- }, [handleTableRender, props]);
3429
+ }, [handleTableRender]);
3418
3430
  reactExports.useEffect(() => {
3431
+ const newOptionFromChildren = hasOption ? null : parseOptionFromChildren(props);
3419
3432
  if (!tableContext.current?.table) {
3433
+ if (!hasOption) {
3434
+ optionFromChildren.current = newOptionFromChildren;
3435
+ }
3420
3436
  createTable(props);
3421
3437
  renderTable();
3422
3438
  bindEventsToTable(tableContext.current.table, props, null, TABLE_EVENTS);
3423
- tableContext.current = {
3424
- ...tableContext.current,
3425
- isChildrenUpdated: false
3426
- };
3427
3439
  eventsBinded.current = props;
3428
3440
  return;
3429
3441
  }
@@ -3431,59 +3443,50 @@
3431
3443
  if (!isEqual(eventsBinded.current.option, props.option, { skipFunction: skipFunctionDiff })) {
3432
3444
  eventsBinded.current = props;
3433
3445
  tableContext.current.table.updateOption(parseOption(props));
3434
- const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
3435
- if (props.onError) {
3436
- updatePromise.catch(props.onError);
3437
- }
3446
+ handleTableRender();
3438
3447
  }
3439
3448
  else if (hasRecords &&
3440
3449
  !isEqual(eventsBinded.current.records, props.records, { skipFunction: skipFunctionDiff })) {
3441
3450
  eventsBinded.current = props;
3442
3451
  tableContext.current.table.setRecords(props.records);
3443
- const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
3444
- if (props.onError) {
3445
- updatePromise.catch(props.onError);
3446
- }
3452
+ handleTableRender();
3447
3453
  }
3448
3454
  return;
3449
3455
  }
3450
3456
  const newOption = pickWithout(props, notOptionKeys);
3451
3457
  if (!isEqual(newOption, prevOption.current, { skipFunction: skipFunctionDiff }) ||
3452
- tableContext.current.isChildrenUpdated) {
3458
+ !isEqual(newOptionFromChildren, optionFromChildren.current)) {
3453
3459
  prevOption.current = newOption;
3460
+ optionFromChildren.current = newOptionFromChildren;
3454
3461
  tableContext.current.table.updateOption(parseOption(props));
3455
- const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
3456
- if (props.onError) {
3457
- updatePromise.catch(props.onError);
3458
- }
3462
+ handleTableRender();
3459
3463
  }
3460
3464
  else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {
3461
3465
  prevRecords.current = props.records;
3462
3466
  tableContext.current.table.setRecords(props.records);
3463
- const updatePromise = tableContext.current.table.renderAsync().then(handleTableRender);
3464
- if (props.onError) {
3465
- updatePromise.catch(props.onError);
3466
- }
3467
+ handleTableRender();
3467
3468
  }
3468
- tableContext.current = {
3469
- ...tableContext.current,
3470
- isChildrenUpdated: false
3471
- };
3472
3469
  }, [createTable, hasOption, hasRecords, parseOption, handleTableRender, renderTable, skipFunctionDiff, props]);
3473
3470
  reactExports.useEffect(() => {
3474
3471
  return () => {
3475
3472
  if (tableContext) {
3476
- if (tableContext.current.table) {
3473
+ if (tableContext.current && tableContext.current.table) {
3477
3474
  tableContext.current.table.release();
3475
+ tableContext.current = null;
3478
3476
  }
3479
- tableContext.current = null;
3480
3477
  }
3481
3478
  isUnmount.current = true;
3482
3479
  };
3483
3480
  }, []);
3484
3481
  return (React.createElement(TableContext.Provider, { value: tableContext.current }, toArray(props.children).map((child, index) => {
3485
- return (React.createElement(React.Fragment, { key: child?.props?.id ?? child?.id ?? `child-${index}` }, React.cloneElement(child, {
3486
- updateId: updateId
3482
+ if (typeof child === 'string') {
3483
+ return;
3484
+ }
3485
+ const componentName = child && child.type && (child.type.displayName || child.type.name);
3486
+ const childId = `${componentName}-${index}`;
3487
+ return (React.createElement(React.Fragment, { key: childId }, React.cloneElement(child, {
3488
+ updateId: updateId,
3489
+ componentId: childId
3487
3490
  })));
3488
3491
  })));
3489
3492
  });
@@ -3512,14 +3515,12 @@
3512
3515
  }
3513
3516
 
3514
3517
  const createComponent = (componentName, optionName, supportedEvents, isSingle) => {
3515
- const ignoreKeys = ['id', 'updateId'];
3518
+ const ignoreKeys = ['id', 'updateId', 'componentId'];
3516
3519
  const notOptionKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys;
3517
3520
  const Comp = (props) => {
3518
3521
  const context = reactExports.useContext(TableContext);
3519
- const id = React.useRef(isNil$1(props.id) ? uid(optionName) : props.id);
3520
3522
  const eventsBinded = React.useRef(null);
3521
3523
  const updateId = React.useRef(props.updateId);
3522
- const componentOption = React.useRef();
3523
3524
  if (props.updateId !== updateId.current) {
3524
3525
  updateId.current = props.updateId;
3525
3526
  const hasPrevEventsBinded = supportedEvents
@@ -3529,71 +3530,26 @@
3529
3530
  eventsBinded.current = props;
3530
3531
  }
3531
3532
  }
3532
- else {
3533
- const newComponentOption = pickWithout(props, notOptionKeys);
3534
- if (!isEqual(newComponentOption, componentOption.current)) {
3535
- componentOption.current = newComponentOption;
3536
- updateToContext(context, id.current, optionName, isSingle, newComponentOption);
3537
- }
3538
- }
3539
3533
  reactExports.useEffect(() => {
3540
3534
  return () => {
3541
3535
  if (supportedEvents) {
3542
3536
  bindEventsToTable(context.table, null, eventsBinded.current, supportedEvents);
3543
3537
  }
3544
- deleteToContext(context, id.current, optionName, isSingle);
3545
3538
  };
3546
3539
  }, []);
3547
3540
  return null;
3548
3541
  };
3549
3542
  Comp.displayName = componentName;
3543
+ Comp.parseOption = (props) => {
3544
+ const newComponentOption = pickWithout(props, notOptionKeys);
3545
+ return {
3546
+ option: newComponentOption,
3547
+ optionName,
3548
+ isSingle
3549
+ };
3550
+ };
3550
3551
  return Comp;
3551
3552
  };
3552
- const updateToContext = (context, id, optionName, isSingle, props) => {
3553
- if (!context.optionFromChildren) {
3554
- return;
3555
- }
3556
- if (isSingle) {
3557
- context.optionFromChildren[optionName] = { ...props };
3558
- }
3559
- else {
3560
- if (!context.optionFromChildren[optionName]) {
3561
- context.optionFromChildren[optionName] = [];
3562
- }
3563
- const comps = context.optionFromChildren[optionName];
3564
- const index = comps.findIndex((entry) => entry.id === id);
3565
- if (index >= 0) {
3566
- comps[index] = {
3567
- id,
3568
- ...props
3569
- };
3570
- }
3571
- else {
3572
- context.optionFromChildren[optionName].push({
3573
- id,
3574
- ...props
3575
- });
3576
- }
3577
- }
3578
- context.isChildrenUpdated = true;
3579
- };
3580
- const deleteToContext = (context, id, optionName, isSingle) => {
3581
- if (!context.optionFromChildren) {
3582
- return;
3583
- }
3584
- if (isSingle) {
3585
- context.optionFromChildren[optionName] = null;
3586
- }
3587
- else {
3588
- const comps = context.optionFromChildren[optionName] ?? [];
3589
- const index = comps.findIndex((entry) => entry.id === id);
3590
- if (index >= 0) {
3591
- const newComps = comps.slice(0, index - 1).concat(comps.slice(index + 1));
3592
- context.optionFromChildren[optionName] = newComps;
3593
- context.isChildrenUpdated = true;
3594
- }
3595
- }
3596
- };
3597
3553
 
3598
3554
  const ListColumn = createComponent('ListColumn', 'columns');
3599
3555