@visactor/react-vtable 1.17.3-alpha.8 → 1.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './tables';
2
2
  export * from './table-components';
3
3
  export * from './components';
4
- export declare const version = "1.17.3-alpha.8";
4
+ export declare const version = "1.17.3";
package/es/index.js CHANGED
@@ -4,5 +4,5 @@ export * from "./table-components";
4
4
 
5
5
  export * from "./components";
6
6
 
7
- export const version = "1.17.3-alpha.8";
7
+ export const version = "1.17.3";
8
8
  //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","file":"index.js","sourcesContent":["export * from './tables';\nexport * from './table-components';\nexport * from './components';\n\nexport const version = \"1.17.3-alpha.8\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","file":"index.js","sourcesContent":["export * from './tables';\nexport * from './table-components';\nexport * from './components';\n\nexport const version = \"1.17.3\";\n"]}
@@ -13,7 +13,7 @@ export const CustomLayout = (props, ref) => {
13
13
  if (!isValidElement(children)) return null;
14
14
  const context = useContext(RootTableContext), {table: table} = context, isHeaderCustomLayout = "header-custom-layout" === children.props.role, container = useRef(new Map), createGraphic = useCallback((args => {
15
15
  var _a, _b;
16
- const key = `${null !== (_a = args.originCol) && void 0 !== _a ? _a : args.col}-${null !== (_b = args.originRow) && void 0 !== _b ? _b : args.row}`;
16
+ const key = `${null !== (_a = args.originCol) && void 0 !== _a ? _a : args.col}-${null !== (_b = args.originRow) && void 0 !== _b ? _b : args.row}${args.forComputation ? "-forComputation" : ""}`;
17
17
  let group;
18
18
  if (container.current.has(key)) {
19
19
  const currentContainer = container.current.get(key);
@@ -1 +1 @@
1
- {"version":3,"sources":["table-components/custom/custom-layout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AASxD,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,KAA2C,EAAE,GAAG,EAAE,EAAE;IAC5G,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACxC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;QAC7B,OAAO,IAAI,CAAC;KACb;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAE1B,MAAM,oBAAoB,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAsB,CAAC;IAG5E,MAAM,SAAS,GAAG,MAAM,CAAyB,IAAI,GAAG,EAAE,CAAC,CAAC;IAG5D,MAAM,aAAa,GAAqB,WAAW,CACjD,IAAI,CAAC,EAAE;;QACL,MAAM,GAAG,GAAG,GAAG,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,GAAG,IAAI,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1E,IAAI,KAAK,CAAC;QACV,IAAI,SAAS,CAAC,OAAO,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AC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,SAAS,yBAAyB,CAAC,QAAsB,EAAE,gBAAqB,EAAE,IAAS;IACzF,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,oBAAO,IAAI,EAAG,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAUhG,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,GAAW,EAAE,KAAU;IACvD,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC;AACd,CAAC","file":"custom-layout.js","sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\nimport type { PropsWithChildren, ReactElement } from 'react';\nimport React, { isValidElement, useCallback, useContext, useLayoutEffect, useRef } from 'react';\nimport RootTableContext from '../../context/table';\nimport { Group } from '@visactor/vtable/es/vrender';\nimport type { ICustomLayoutFuc, CustomRenderFunctionArg } from '@visactor/vtable/es/ts-types';\nimport type { FiberRoot } from 'react-reconciler';\nimport { reconcilor } from './reconciler';\nimport { LegacyRoot } from 'react-reconciler/constants';\n\ntype CustomLayoutProps = { componentId: string };\n\nexport type CustomLayoutFunctionArg = Partial<CustomRenderFunctionArg> & {\n role?: 'custom-layout' | 'header-custom-layout';\n renderDefault?: boolean;\n};\n\nexport const CustomLayout: React.FC<CustomLayoutProps> = (props: PropsWithChildren<CustomLayoutProps>, ref) => {\n const { componentId, children } = props;\n if (!isValidElement(children)) {\n return null;\n }\n const context = useContext(RootTableContext);\n const { table } = context;\n\n const isHeaderCustomLayout = children.props.role === 'header-custom-layout';\n\n // react customLayout component container cache\n const container = useRef<Map<string, FiberRoot>>(new Map());\n\n // customLayout function for vtable\n const createGraphic: ICustomLayoutFuc = useCallback(\n args => {\n const key = `${args.originCol ?? args.col}-${args.originRow ?? args.row}`;\n let group;\n if (container.current.has(key)) {\n const currentContainer = container.current.get(key);\n // reconcilor.updateContainer(React.cloneElement(children, { ...args }), currentContainer, null);\n reconcilorUpdateContainer(children, currentContainer, args);\n group = currentContainer.containerInfo;\n // 这里更新group,可能会残留dx dy\n } else {\n group = new Group({});\n const currentContainer = reconcilor.createContainer(group, LegacyRoot, null, null, null, 'custom', null, null);\n container.current.set(key, currentContainer);\n reconcilorUpdateContainer(children, currentContainer, args);\n // const ele = React.cloneElement(children, { ...args });\n // reconcilor.updateContainer(ele, currentContainer, null);\n }\n\n return {\n rootContainer: group,\n renderDefault: !!children.props.renderDefault\n };\n },\n [children]\n );\n\n const removeContainer = useCallback((col: number, row: number) => {\n const key = `${col}-${row}`;\n if (container.current.has(key)) {\n const currentContainer = container.current.get(key);\n reconcilor.updateContainer(null, currentContainer, null);\n // group = currentContainer.containerInfo;\n currentContainer.containerInfo.delete();\n container.current.delete(key);\n }\n }, []);\n\n const removeAllContainer = useCallback(() => {\n container.current.forEach((value, key) => {\n const currentContainer = value;\n reconcilor.updateContainer(null, currentContainer, null);\n currentContainer.containerInfo.delete();\n });\n container.current.clear();\n }, []);\n\n useLayoutEffect(() => {\n // init and release\n // eslint-disable-next-line no-undef\n console.log('init', props, table);\n // table && (table._reactCreateGraphic = createGraphic); // never go to here\n // table?.renderWithRecreateCells();\n return () => {\n // eslint-disable-next-line no-undef\n console.log('release', props, table);\n };\n }, []);\n\n useLayoutEffect(() => {\n // update props\n // eslint-disable-next-line no-undef\n console.log('update props', props, table);\n\n table?.checkReactCustomLayout(); // init reactCustomLayout component\n table?.reactCustomLayout?.setReactRemoveAllGraphic(componentId, removeAllContainer, isHeaderCustomLayout); // set customLayout function\n\n if (table && !table.reactCustomLayout?.hasReactCreateGraphic(componentId, isHeaderCustomLayout)) {\n table.reactCustomLayout?.setReactCreateGraphic(\n componentId,\n createGraphic,\n // container.current,\n isHeaderCustomLayout\n ); // set customLayout function\n table.reactCustomLayout?.setReactRemoveGraphic(componentId, removeContainer, isHeaderCustomLayout); // set customLayout function\n table.reactCustomLayout?.updateCustomCell(componentId, isHeaderCustomLayout); // update cell content\n } else if (table) {\n table.reactCustomLayout?.setReactCreateGraphic(\n componentId,\n createGraphic,\n // container.current,\n isHeaderCustomLayout\n ); // update customLayout function\n // update all container\n container.current.forEach((value, key) => {\n const [col, row] = key.split('-').map(Number);\n // const width = table.getColWidth(col); // to be fixed: may be merge cell\n // const height = table.getRowHeight(row); // to be fixed: may be merge cell\n const { width, height } = getCellRect(col, row, table);\n const currentContainer = value;\n const args = {\n col,\n row,\n dataValue: table.getCellOriginValue(col, row),\n value: table.getCellValue(col, row) || '',\n rect: {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height\n },\n table\n };\n // update element in container\n const group = currentContainer.containerInfo;\n reconcilorUpdateContainer(children, currentContainer, args);\n // reconcilor.updateContainer(React.cloneElement(children, { ...args }), currentContainer, null);\n table.scenegraph.updateNextFrame();\n });\n }\n });\n\n return null;\n};\n\nfunction reconcilorUpdateContainer(children: ReactElement, currentContainer: any, args: any) {\n reconcilor.updateContainer(React.cloneElement(children, { ...args }), currentContainer, null);\n // group = group.firstChild;\n // if (isReactElement(group.attribute.html?.dom)) {\n // const div = document.createElement('div');\n // const root = ReactDOM.createRoot(div as HTMLElement);\n // root.render(group.attribute.html.dom);\n // group.attribute.html.dom = div;\n // // debugger;\n // // group.html.dom = div;\n // }\n}\n\nfunction getCellRect(col: number, row: number, table: any) {\n const range = table.getCellRange(col, row);\n const rect = table.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row);\n return rect;\n}\n"]}
1
+ {"version":3,"sources":["table-components/custom/custom-layout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,cAAc,EAA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,EAAG,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAUhG,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,GAAW,EAAE,KAAU;IACvD,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC;AACd,CAAC","file":"custom-layout.js","sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\nimport type { PropsWithChildren, ReactElement } from 'react';\nimport React, { isValidElement, useCallback, useContext, useLayoutEffect, useRef } from 'react';\nimport RootTableContext from '../../context/table';\nimport { Group } from '@visactor/vtable/es/vrender';\nimport type { ICustomLayoutFuc, CustomRenderFunctionArg } from '@visactor/vtable/es/ts-types';\nimport type { FiberRoot } from 'react-reconciler';\nimport { reconcilor } from './reconciler';\nimport { LegacyRoot } from 'react-reconciler/constants';\n\ntype CustomLayoutProps = { componentId: string };\n\nexport type CustomLayoutFunctionArg = Partial<CustomRenderFunctionArg> & {\n role?: 'custom-layout' | 'header-custom-layout';\n renderDefault?: boolean;\n};\n\nexport const CustomLayout: React.FC<CustomLayoutProps> = (props: PropsWithChildren<CustomLayoutProps>, ref) => {\n const { componentId, children } = props;\n if (!isValidElement(children)) {\n return null;\n }\n const context = useContext(RootTableContext);\n const { table } = context;\n\n const isHeaderCustomLayout = children.props.role === 'header-custom-layout';\n\n // react customLayout component container cache\n const container = useRef<Map<string, FiberRoot>>(new Map());\n\n // customLayout function for vtable\n const createGraphic: ICustomLayoutFuc = useCallback(\n args => {\n const key = `${args.originCol ?? args.col}-${args.originRow ?? args.row}${\n args.forComputation ? '-forComputation' : ''\n }`;\n let group;\n if (container.current.has(key)) {\n const currentContainer = container.current.get(key);\n reconcilorUpdateContainer(children, currentContainer, args);\n group = currentContainer.containerInfo;\n } else {\n group = new Group({});\n const currentContainer = reconcilor.createContainer(\n group as any,\n LegacyRoot,\n null,\n null,\n null,\n 'custom',\n null,\n null\n );\n container.current.set(key, currentContainer);\n reconcilorUpdateContainer(children, currentContainer, args);\n }\n\n return {\n rootContainer: group,\n renderDefault: !!children.props.renderDefault\n };\n },\n [children]\n );\n\n const removeContainer = useCallback((col: number, row: number) => {\n const key = `${col}-${row}`;\n if (container.current.has(key)) {\n const currentContainer = container.current.get(key);\n reconcilor.updateContainer(null, currentContainer, null);\n // group = currentContainer.containerInfo;\n currentContainer.containerInfo.delete();\n container.current.delete(key);\n }\n }, []);\n\n const removeAllContainer = useCallback(() => {\n container.current.forEach((value, key) => {\n const currentContainer = value;\n reconcilor.updateContainer(null, currentContainer, null);\n currentContainer.containerInfo.delete();\n });\n container.current.clear();\n }, []);\n\n useLayoutEffect(() => {\n // init and release\n // eslint-disable-next-line no-undef\n console.log('init', props, table);\n // table && (table._reactCreateGraphic = createGraphic); // never go to here\n // table?.renderWithRecreateCells();\n return () => {\n // eslint-disable-next-line no-undef\n console.log('release', props, table);\n };\n }, []);\n\n useLayoutEffect(() => {\n // update props\n // eslint-disable-next-line no-undef\n console.log('update props', props, table);\n\n table?.checkReactCustomLayout(); // init reactCustomLayout component\n table?.reactCustomLayout?.setReactRemoveAllGraphic(componentId, removeAllContainer, isHeaderCustomLayout); // set customLayout function\n\n if (table && !table.reactCustomLayout?.hasReactCreateGraphic(componentId, isHeaderCustomLayout)) {\n table.reactCustomLayout?.setReactCreateGraphic(\n componentId,\n createGraphic,\n // container.current,\n isHeaderCustomLayout\n ); // set customLayout function\n table.reactCustomLayout?.setReactRemoveGraphic(componentId, removeContainer, isHeaderCustomLayout); // set customLayout function\n table.reactCustomLayout?.updateCustomCell(componentId, isHeaderCustomLayout); // update cell content\n } else if (table) {\n table.reactCustomLayout?.setReactCreateGraphic(\n componentId,\n createGraphic,\n // container.current,\n isHeaderCustomLayout\n ); // update customLayout function\n // update all container\n container.current.forEach((value, key) => {\n const [col, row] = key.split('-').map(Number);\n // const width = table.getColWidth(col); // to be fixed: may be merge cell\n // const height = table.getRowHeight(row); // to be fixed: may be merge cell\n const { width, height } = getCellRect(col, row, table);\n const currentContainer = value;\n const args = {\n col,\n row,\n dataValue: table.getCellOriginValue(col, row),\n value: table.getCellValue(col, row) || '',\n rect: {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height\n },\n table\n };\n // update element in container\n const group = currentContainer.containerInfo;\n reconcilorUpdateContainer(children, currentContainer, args);\n // reconcilor.updateContainer(React.cloneElement(children, { ...args }), currentContainer, null);\n table.scenegraph.updateNextFrame();\n });\n }\n });\n\n return null;\n};\n\nfunction reconcilorUpdateContainer(children: ReactElement, currentContainer: any, args: any) {\n reconcilor.updateContainer(React.cloneElement(children, { ...args }), currentContainer, null);\n // group = group.firstChild;\n // if (isReactElement(group.attribute.html?.dom)) {\n // const div = document.createElement('div');\n // const root = ReactDOM.createRoot(div as HTMLElement);\n // root.render(group.attribute.html.dom);\n // group.attribute.html.dom = div;\n // // debugger;\n // // group.html.dom = div;\n // }\n}\n\nfunction getCellRect(col: number, row: number, table: any) {\n const range = table.getCellRange(col, row);\n const rect = table.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row);\n return rect;\n}\n"]}
@@ -11,6 +11,7 @@ export { Title } from './component/title';
11
11
  export { CustomComponent } from './custom-component';
12
12
  export { CustomLayout, type CustomLayoutFunctionArg } from './custom/custom-layout';
13
13
  export * from './custom/graphic';
14
+ export * from './custom/vtable-react-attribute-plugin';
14
15
  type Props = {
15
16
  updateId?: number;
16
17
  };
@@ -21,4 +21,6 @@ export { CustomComponent } from "./custom-component";
21
21
  export { CustomLayout } from "./custom/custom-layout";
22
22
 
23
23
  export * from "./custom/graphic";
24
+
25
+ export * from "./custom/vtable-react-attribute-plugin";
24
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["table-components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAgC,MAAM,wBAAwB,CAAC;AACpF,cAAc,kBAAkB,CAAC","file":"index.js","sourcesContent":["import type React from 'react';\nexport { ListColumn } from './list/list-column';\nexport { PivotColumnDimension, PivotRowDimension } from './pivot/pivot-dimension';\nexport { PivotIndicator } from './pivot/pivot-indicator';\nexport { PivotColumnHeaderTitle, PivotRowHeaderTitle } from './pivot/pivot-header-title';\nexport { PivotCorner } from './pivot/pivot-corner';\nexport { Menu } from './component/menu';\nexport { Tooltip } from './component/tooltip';\nexport { EmptyTip } from './component/emptyTip';\nexport { Title } from './component/title';\n\nexport { CustomComponent } from './custom-component';\nexport { CustomLayout, type CustomLayoutFunctionArg } from './custom/custom-layout';\nexport * from './custom/graphic';\n\ntype Props = { updateId?: number };\n\nexport interface IMarkElement extends React.ReactElement<Props, React.JSXElementConstructor<Props>> {\n id: string | number;\n}\n"]}
1
+ {"version":3,"sources":["table-components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAgC,MAAM,wBAAwB,CAAC;AACpF,cAAc,kBAAkB,CAAC;AAEjC,cAAc,wCAAwC,CAAC","file":"index.js","sourcesContent":["import type React from 'react';\nexport { ListColumn } from './list/list-column';\nexport { PivotColumnDimension, PivotRowDimension } from './pivot/pivot-dimension';\nexport { PivotIndicator } from './pivot/pivot-indicator';\nexport { PivotColumnHeaderTitle, PivotRowHeaderTitle } from './pivot/pivot-header-title';\nexport { PivotCorner } from './pivot/pivot-corner';\nexport { Menu } from './component/menu';\nexport { Tooltip } from './component/tooltip';\nexport { EmptyTip } from './component/emptyTip';\nexport { Title } from './component/title';\n\nexport { CustomComponent } from './custom-component';\nexport { CustomLayout, type CustomLayoutFunctionArg } from './custom/custom-layout';\nexport * from './custom/graphic';\n\nexport * from './custom/vtable-react-attribute-plugin';\n\ntype Props = { updateId?: number };\n\nexport interface IMarkElement extends React.ReactElement<Props, React.JSXElementConstructor<Props>> {\n id: string | number;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { ContainerProps } from '../containers/withContainer';
3
3
  import type { EventsProps } from '../eventsUtils';
4
+ import { VTableReactAttributePlugin } from '../table-components/custom/vtable-react-attribute-plugin';
4
5
  import type { ListTable, PivotTable, PivotChart, ListTableConstructorOptions, PivotTableConstructorOptions, PivotChartConstructorOptions } from '@visactor/vtable';
5
6
  export type IVTable = ListTable | PivotTable | PivotChart;
6
7
  export type IOption = ListTableConstructorOptions | PivotTableConstructorOptions | PivotChartConstructorOptions;
@@ -15,6 +16,7 @@ export type BaseTableProps = EventsProps & IOption & {
15
16
  skipFunctionDiff?: boolean;
16
17
  keepColumnWidthChange?: boolean;
17
18
  ReactDOM?: any;
19
+ reactAttributePlugin?: VTableReactAttributePlugin;
18
20
  onReady?: (instance: IVTable, isInitial: boolean) => void;
19
21
  onError?: (err: Error) => void;
20
22
  };
@@ -51,8 +51,9 @@ const notOptionKeys = [ ...REACT_PRIVATE_PROPS, ...TABLE_EVENTS_KEYS, "skipFunct
51
51
  createReactContainer: !0
52
52
  })
53
53
  })), [ hasOption, hasRecords ]), createTable = useCallback((props => {
54
+ var _a;
54
55
  const vtable = new props.vtableConstrouctor(props.container, parseOption(props));
55
- vtable.scenegraph.stage.reactAttribute = props.ReactDOM, vtable.scenegraph.stage.pluginService.register(new VTableReactAttributePlugin),
56
+ vtable.scenegraph.stage.reactAttribute = props.ReactDOM, vtable.scenegraph.stage.pluginService.register(null !== (_a = props.reactAttributePlugin) && void 0 !== _a ? _a : new VTableReactAttributePlugin),
56
57
  vtable.scenegraph.stage.params.ReactDOM = props.ReactDOM, tableContext.current = Object.assign(Object.assign({}, tableContext.current), {
57
58
  table: vtable
58
59
  }), isUnmount.current = !1, columnWidths.current.clear(), pivotColumnWidths.current = [],
@@ -1 +1 @@
1
- {"version":3,"sources":["tables/base-table.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE7F,OAAO,aAAa,MAAM,6BAA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,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,aAAqB,EACrB,YAAyB,EACzB,QAA0B,EAC1B,EAAE;IACF,MAAM,GAAG,GAAG,aAAa,CAAoB,SAAgB,EAAE,aAAa,EAAE,CAAC,KAAQ,EAAE,EAAE;QAGzF,IAAI,YAAY,EAAE;YAChB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SAC3C;QASD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,SAAS,gBAAgB,CACvB,YAAiC,EACjC,iBAA0E,EAC1E,KAAc;IAEd,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE;QACxB,OAAO,iBAAiB,CAAC;KAC1B;IACD,MAAM,iBAAiB,GAAqC,EAAE,CAAC;IAC/D,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAClC,iBAAiB,CAAC,IAAI,CAAC;YACrB,GAAG;YACH,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","file":"base-table.js","sourcesContent":["/* eslint-disable react/display-name */\n// import * as VTable from '@visactor/vtable';\n// import { VTable } from '../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, isNumber, pickWithout } from '@visactor/vutils';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport type { IMarkElement } from '../table-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';\nimport { VTableReactAttributePlugin } from '../table-components/custom/vtable-react-attribute-plugin';\nimport { reactEnvModule } from '../table-components/custom/vtable-browser-env-contribution';\nimport { container, isBrowserEnv } from '@visactor/vtable/es/vrender';\nimport type {\n ListTable,\n PivotTable,\n PivotChart,\n ListTableConstructorOptions,\n PivotTableConstructorOptions,\n PivotChartConstructorOptions\n} from '@visactor/vtable';\nimport type { TYPES } from '@visactor/vtable';\n\nexport type IVTable = ListTable | PivotTable | PivotChart;\nexport type IOption = ListTableConstructorOptions | PivotTableConstructorOptions | PivotChartConstructorOptions;\n\nexport type BaseTableProps = EventsProps &\n IOption & {\n vtableConstrouctor?: any;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /** option */\n option?: IOption;\n /** 数据 */\n records?: Record<string, unknown>[];\n /** 画布宽度 */\n width?: number | string;\n /** 画布高度 */\n height?: number | string;\n skipFunctionDiff?: boolean;\n keepColumnWidthChange?: boolean;\n\n ReactDOM?: any;\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\n// for react-vtable\nif (isBrowserEnv()) {\n container.load(reactEnvModule);\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 'vtableConstrouctor'\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'> = {} as any;\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) as {\n optionName: keyof Omit<IOption, 'type' | 'data' | 'width' | 'height'>;\n isSingle: boolean;\n option: any;\n };\n\n if ((child as React.ReactElement).key) {\n optionResult.option.key = (child as React.ReactElement).key;\n }\n\n if (optionResult.isSingle) {\n optionFromChildren[optionResult.optionName] = optionResult.option as never;\n } else {\n if (!optionFromChildren[optionResult.optionName]) {\n optionFromChildren[optionResult.optionName] = [] as never;\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 const keepColumnWidthChange = !!props.keepColumnWidthChange;\n const columnWidths = useRef<Map<string, number>>(new Map());\n const pivotColumnWidths = useRef<{ dimensions: TYPES.IDimensionInfo[]; width: number }[]>([]);\n const pivotHeaderColumnWidths = useRef<number[]>([]);\n\n const parseOption = useCallback(\n (props: Props) => {\n if (hasOption && props.option) {\n if (hasRecords && props.records) {\n return {\n ...props.option,\n clearDOM: false,\n records: props.records\n };\n }\n return {\n ...props.option,\n clearDOM: false\n };\n }\n\n return {\n records: props.records,\n ...prevOption.current,\n ...optionFromChildren.current,\n clearDOM: false,\n customConfig: {\n ...prevOption.current.customConfig,\n createReactContainer: true\n }\n // ...tableContext.current?.optionFromChildren\n };\n },\n [hasOption, hasRecords]\n );\n\n const createTable = useCallback(\n (props: Props) => {\n const vtable = new props.vtableConstrouctor(props.container, parseOption(props));\n vtable.scenegraph.stage.reactAttribute = props.ReactDOM;\n vtable.scenegraph.stage.pluginService.register(new VTableReactAttributePlugin());\n vtable.scenegraph.stage.params.ReactDOM = props.ReactDOM;\n tableContext.current = { ...tableContext.current, table: vtable };\n isUnmount.current = false;\n\n columnWidths.current.clear();\n pivotColumnWidths.current = [];\n pivotHeaderColumnWidths.current = [];\n\n vtable.on('resize_column_end', (args: { col: number; colWidths: number[] }) => {\n const table = tableContext.current.table;\n if (!keepColumnWidthChange) {\n return;\n }\n const { col, colWidths } = args;\n const width = colWidths[col];\n if (vtable.isPivotTable()) {\n const path = (table as PivotTable).getCellHeaderPaths(col, table.columnHeaderLevelCount);\n let dimensions;\n if (path.cellLocation === 'rowHeader') {\n dimensions = path.rowHeaderPaths as TYPES.IDimensionInfo[];\n } else {\n dimensions = path.colHeaderPaths as TYPES.IDimensionInfo[];\n }\n\n let found = false;\n pivotColumnWidths.current.forEach(item => {\n if (JSON.stringify(item.dimensions) === JSON.stringify(dimensions)) {\n item.width = width;\n found = true;\n }\n });\n if (!found) {\n pivotColumnWidths.current.push({ dimensions, width });\n }\n } else {\n const define = table.getBodyColumnDefine(col, 0);\n if ((define as any)?.key) {\n columnWidths.current.set((define as any).key, width);\n }\n }\n });\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 const option = parseOption(props);\n if (keepColumnWidthChange) {\n const columnWidthConfig = updateWidthCache(\n columnWidths.current,\n pivotColumnWidths.current,\n tableContext.current.table\n );\n (option as any).columnWidthConfig = columnWidthConfig;\n (option as any).columnWidthConfigForRowHeader = columnWidthConfig;\n }\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(option as any);\n handleTableRender();\n eventsBinded.current = props;\n } else if (\n hasRecords &&\n !isEqual(eventsBinded.current.records, props.records, { skipFunction: skipFunctionDiff })\n ) {\n if (keepColumnWidthChange) {\n const columnWidthConfig = updateWidthCache(\n columnWidths.current,\n pivotColumnWidths.current,\n tableContext.current.table\n );\n (tableContext.current.table.internalProps as any).columnWidthConfig = columnWidthConfig;\n (tableContext.current.table.internalProps as any).columnWidthConfigForRowHeader = columnWidthConfig;\n }\n tableContext.current.table.setRecords(props.records as any[]);\n handleTableRender();\n eventsBinded.current = props;\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 const option = parseOption(props);\n if (keepColumnWidthChange) {\n const columnWidthConfig = updateWidthCache(\n columnWidths.current,\n pivotColumnWidths.current,\n tableContext.current.table\n );\n (option as any).columnWidthConfig = columnWidthConfig;\n (option as any).columnWidthConfigForRowHeader = columnWidthConfig;\n }\n tableContext.current.table.updateOption(option as any);\n\n // columnWidths.current = [];\n handleTableRender();\n eventsBinded.current = props;\n } else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {\n prevRecords.current = props.records;\n\n if (keepColumnWidthChange) {\n const columnWidthConfig = updateWidthCache(\n columnWidths.current,\n pivotColumnWidths.current,\n tableContext.current.table\n );\n (tableContext.current.table.internalProps as any).columnWidthConfig = columnWidthConfig;\n (tableContext.current.table.internalProps as any).columnWidthConfigForRowHeader = columnWidthConfig;\n }\n\n tableContext.current.table.setRecords(props.records);\n handleTableRender();\n eventsBinded.current = props;\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 componentIndex: index\n })}\n </React.Fragment>\n );\n })}\n </RootTableContext.Provider>\n );\n});\n\nexport const createTable = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n callback?: (props: T) => T\n) => {\n const Com = withContainer<ContainerProps, T>(BaseTable as any, componentName, (props: T) => {\n // props.type = type;\n\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\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\nfunction updateWidthCache(\n columnWidths: Map<string, number>,\n pivotColumnWidths: { dimensions: TYPES.IDimensionInfo[]; width: number }[],\n table: IVTable\n) {\n if (table.isPivotTable()) {\n return pivotColumnWidths;\n }\n const columnWidthConfig: { key: string; width: number }[] = [];\n columnWidths.forEach((width, key) => {\n columnWidthConfig.push({\n key,\n width\n });\n });\n return columnWidthConfig;\n}\n"]}
1
+ {"version":3,"sources":["tables/base-table.tsx"],"names":[],"mappings":"AAGA,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,KAAK,EAAY,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAanD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AACtG,OAAO,EAAE,cAAc,EAAE,MAAM,4DAA4D,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA0CtE,IAAI,YAAY,EAAE,EAAE;IAClB,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;CAChC;AAID,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AAO,iBAAiB,CAAC;KAC1B;IACD,MAAM,iBAAiB,GAAqC,EAAE,CAAC;IAC/D,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAClC,iBAAiB,CAAC,IAAI,CAAC;YACrB,GAAG;YACH,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","file":"base-table.js","sourcesContent":["/* eslint-disable react/display-name */\n// import * as VTable from '@visactor/vtable';\n// import { VTable } from '../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, isNumber, pickWithout } from '@visactor/vutils';\nimport { toArray } from '../util';\nimport { REACT_PRIVATE_PROPS } from '../constants';\nimport type { IMarkElement } from '../table-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';\nimport { VTableReactAttributePlugin } from '../table-components/custom/vtable-react-attribute-plugin';\nimport { reactEnvModule } from '../table-components/custom/vtable-browser-env-contribution';\nimport { container, isBrowserEnv } from '@visactor/vtable/es/vrender';\nimport type {\n ListTable,\n PivotTable,\n PivotChart,\n ListTableConstructorOptions,\n PivotTableConstructorOptions,\n PivotChartConstructorOptions\n} from '@visactor/vtable';\nimport type { TYPES } from '@visactor/vtable';\n\nexport type IVTable = ListTable | PivotTable | PivotChart;\nexport type IOption = ListTableConstructorOptions | PivotTableConstructorOptions | PivotChartConstructorOptions;\n\nexport type BaseTableProps = EventsProps &\n IOption & {\n vtableConstrouctor?: any;\n type?: string;\n /** 上层container */\n container?: HTMLDivElement;\n /** option */\n option?: IOption;\n /** 数据 */\n records?: Record<string, unknown>[];\n /** 画布宽度 */\n width?: number | string;\n /** 画布高度 */\n height?: number | string;\n skipFunctionDiff?: boolean;\n keepColumnWidthChange?: boolean;\n\n ReactDOM?: any;\n\n reactAttributePlugin?: VTableReactAttributePlugin;\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\n// for react-vtable\nif (isBrowserEnv()) {\n container.load(reactEnvModule);\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 'vtableConstrouctor'\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'> = {} as any;\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) as {\n optionName: keyof Omit<IOption, 'type' | 'data' | 'width' | 'height'>;\n isSingle: boolean;\n option: any;\n };\n\n if ((child as React.ReactElement).key) {\n optionResult.option.key = (child as React.ReactElement).key;\n }\n\n if (optionResult.isSingle) {\n optionFromChildren[optionResult.optionName] = optionResult.option as never;\n } else {\n if (!optionFromChildren[optionResult.optionName]) {\n optionFromChildren[optionResult.optionName] = [] as never;\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 const keepColumnWidthChange = !!props.keepColumnWidthChange;\n const columnWidths = useRef<Map<string, number>>(new Map());\n const pivotColumnWidths = useRef<{ dimensions: TYPES.IDimensionInfo[]; width: number }[]>([]);\n const pivotHeaderColumnWidths = useRef<number[]>([]);\n\n const parseOption = useCallback(\n (props: Props) => {\n if (hasOption && props.option) {\n if (hasRecords && props.records) {\n return {\n ...props.option,\n clearDOM: false,\n records: props.records\n };\n }\n return {\n ...props.option,\n clearDOM: false\n };\n }\n\n return {\n records: props.records,\n ...prevOption.current,\n ...optionFromChildren.current,\n clearDOM: false,\n customConfig: {\n ...prevOption.current.customConfig,\n createReactContainer: true\n }\n // ...tableContext.current?.optionFromChildren\n };\n },\n [hasOption, hasRecords]\n );\n\n const createTable = useCallback(\n (props: Props) => {\n const vtable = new props.vtableConstrouctor(props.container, parseOption(props));\n vtable.scenegraph.stage.reactAttribute = props.ReactDOM;\n vtable.scenegraph.stage.pluginService.register(props.reactAttributePlugin ?? new VTableReactAttributePlugin());\n vtable.scenegraph.stage.params.ReactDOM = props.ReactDOM;\n tableContext.current = { ...tableContext.current, table: vtable };\n isUnmount.current = false;\n\n columnWidths.current.clear();\n pivotColumnWidths.current = [];\n pivotHeaderColumnWidths.current = [];\n\n vtable.on('resize_column_end', (args: { col: number; colWidths: number[] }) => {\n const table = tableContext.current.table;\n if (!keepColumnWidthChange) {\n return;\n }\n const { col, colWidths } = args;\n const width = colWidths[col];\n if (vtable.isPivotTable()) {\n const path = (table as PivotTable).getCellHeaderPaths(col, table.columnHeaderLevelCount);\n let dimensions;\n if (path.cellLocation === 'rowHeader') {\n dimensions = path.rowHeaderPaths as TYPES.IDimensionInfo[];\n } else {\n dimensions = path.colHeaderPaths as TYPES.IDimensionInfo[];\n }\n\n let found = false;\n pivotColumnWidths.current.forEach(item => {\n if (JSON.stringify(item.dimensions) === JSON.stringify(dimensions)) {\n item.width = width;\n found = true;\n }\n });\n if (!found) {\n pivotColumnWidths.current.push({ dimensions, width });\n }\n } else {\n const define = table.getBodyColumnDefine(col, 0);\n if ((define as any)?.key) {\n columnWidths.current.set((define as any).key, width);\n }\n }\n });\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 const option = parseOption(props);\n if (keepColumnWidthChange) {\n const columnWidthConfig = updateWidthCache(\n columnWidths.current,\n pivotColumnWidths.current,\n tableContext.current.table\n );\n (option as any).columnWidthConfig = columnWidthConfig;\n (option as any).columnWidthConfigForRowHeader = columnWidthConfig;\n }\n // eslint-disable-next-line promise/catch-or-return\n tableContext.current.table.updateOption(option as any);\n handleTableRender();\n eventsBinded.current = props;\n } else if (\n hasRecords &&\n !isEqual(eventsBinded.current.records, props.records, { skipFunction: skipFunctionDiff })\n ) {\n if (keepColumnWidthChange) {\n const columnWidthConfig = updateWidthCache(\n columnWidths.current,\n pivotColumnWidths.current,\n tableContext.current.table\n );\n (tableContext.current.table.internalProps as any).columnWidthConfig = columnWidthConfig;\n (tableContext.current.table.internalProps as any).columnWidthConfigForRowHeader = columnWidthConfig;\n }\n tableContext.current.table.setRecords(props.records as any[]);\n handleTableRender();\n eventsBinded.current = props;\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 const option = parseOption(props);\n if (keepColumnWidthChange) {\n const columnWidthConfig = updateWidthCache(\n columnWidths.current,\n pivotColumnWidths.current,\n tableContext.current.table\n );\n (option as any).columnWidthConfig = columnWidthConfig;\n (option as any).columnWidthConfigForRowHeader = columnWidthConfig;\n }\n tableContext.current.table.updateOption(option as any);\n\n // columnWidths.current = [];\n handleTableRender();\n eventsBinded.current = props;\n } else if (hasRecords && !isEqual(props.records, prevRecords.current, { skipFunction: skipFunctionDiff })) {\n prevRecords.current = props.records;\n\n if (keepColumnWidthChange) {\n const columnWidthConfig = updateWidthCache(\n columnWidths.current,\n pivotColumnWidths.current,\n tableContext.current.table\n );\n (tableContext.current.table.internalProps as any).columnWidthConfig = columnWidthConfig;\n (tableContext.current.table.internalProps as any).columnWidthConfigForRowHeader = columnWidthConfig;\n }\n\n tableContext.current.table.setRecords(props.records);\n handleTableRender();\n eventsBinded.current = props;\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 componentIndex: index\n })}\n </React.Fragment>\n );\n })}\n </RootTableContext.Provider>\n );\n});\n\nexport const createTable = <T extends Props>(\n componentName: string,\n defaultProps?: Partial<T>,\n callback?: (props: T) => T\n) => {\n const Com = withContainer<ContainerProps, T>(BaseTable as any, componentName, (props: T) => {\n // props.type = type;\n\n if (defaultProps) {\n return Object.assign(props, defaultProps);\n }\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\nfunction updateWidthCache(\n columnWidths: Map<string, number>,\n pivotColumnWidths: { dimensions: TYPES.IDimensionInfo[]; width: number }[],\n table: IVTable\n) {\n if (table.isPivotTable()) {\n return pivotColumnWidths;\n }\n const columnWidthConfig: { key: string; width: number }[] = [];\n columnWidths.forEach((width, key) => {\n columnWidthConfig.push({\n key,\n width\n });\n });\n return columnWidthConfig;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/react-vtable",
3
- "version": "1.17.3-alpha.8",
3
+ "version": "1.17.3",
4
4
  "description": "The react version of VTable",
5
5
  "keywords": [
6
6
  "react",
@@ -43,10 +43,10 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@visactor/vtable": "1.17.3-alpha.8",
47
46
  "@visactor/vutils": "~0.19.1",
48
47
  "react-is": "^18.2.0",
49
- "react-reconciler": "0.29.2"
48
+ "react-reconciler": "0.29.2",
49
+ "@visactor/vtable": "1.17.3"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@visactor/vchart": "1.13.3-alpha.2",
@@ -91,9 +91,9 @@
91
91
  "@types/react-is": "^17.0.3",
92
92
  "@arco-design/web-react": "2.60.2",
93
93
  "@types/react-reconciler": "0.28.8",
94
- "@internal/eslint-config": "0.0.1",
95
94
  "@internal/bundler": "0.0.1",
96
- "@internal/ts-config": "0.0.1"
95
+ "@internal/ts-config": "0.0.1",
96
+ "@internal/eslint-config": "0.0.1"
97
97
  },
98
98
  "scripts": {
99
99
  "start": "vite ./demo",