@visactor/react-vtable 1.3.3-alpha.0 → 1.3.3-alpha.1

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.
Files changed (71) hide show
  1. package/cjs/components/base-component.d.ts +0 -2
  2. package/cjs/components/base-component.js +8 -20
  3. package/cjs/components/base-component.js.map +1 -1
  4. package/cjs/components/index.d.ts +0 -3
  5. package/cjs/components/index.js +1 -25
  6. package/cjs/components/index.js.map +1 -1
  7. package/cjs/eventsUtils.js +2 -1
  8. package/cjs/index.d.ts +3 -2
  9. package/cjs/index.js +19 -4
  10. package/cjs/index.js.map +1 -1
  11. package/cjs/tables/base-table.d.ts +1 -2
  12. package/cjs/tables/base-table.js +5 -14
  13. package/cjs/tables/base-table.js.map +1 -1
  14. package/dist/react-vtable.js +110 -10081
  15. package/dist/react-vtable.min.js +3 -30
  16. package/es/components/base-component.d.ts +0 -2
  17. package/es/components/base-component.js +7 -21
  18. package/es/components/base-component.js.map +1 -1
  19. package/es/components/index.d.ts +0 -3
  20. package/es/components/index.js +0 -6
  21. package/es/components/index.js.map +1 -1
  22. package/es/eventsUtils.js +2 -1
  23. package/es/index.d.ts +3 -2
  24. package/es/index.js +4 -3
  25. package/es/index.js.map +1 -1
  26. package/es/tables/base-table.d.ts +1 -2
  27. package/es/tables/base-table.js +4 -17
  28. package/es/tables/base-table.js.map +1 -1
  29. package/package.json +6 -8
  30. package/cjs/components/custom/component.d.ts +0 -12
  31. package/cjs/components/custom/component.js +0 -6
  32. package/cjs/components/custom/component.js.map +0 -1
  33. package/cjs/components/custom/custom-layout.d.ts +0 -10
  34. package/cjs/components/custom/custom-layout.js +0 -96
  35. package/cjs/components/custom/custom-layout.js.map +0 -1
  36. package/cjs/components/custom/graphic.d.ts +0 -32
  37. package/cjs/components/custom/graphic.js +0 -9
  38. package/cjs/components/custom/graphic.js.map +0 -1
  39. package/cjs/components/custom/reconciler.d.ts +0 -5
  40. package/cjs/components/custom/reconciler.js +0 -105
  41. package/cjs/components/custom/reconciler.js.map +0 -1
  42. package/cjs/components/custom/vtable-browser-env-contribution.d.ts +0 -2
  43. package/cjs/components/custom/vtable-browser-env-contribution.js +0 -35
  44. package/cjs/components/custom/vtable-browser-env-contribution.js.map +0 -1
  45. package/cjs/components/custom/vtable-react-attribute-plugin.d.ts +0 -17
  46. package/cjs/components/custom/vtable-react-attribute-plugin.js +0 -92
  47. package/cjs/components/custom/vtable-react-attribute-plugin.js.map +0 -1
  48. package/cjs/vtable.d.ts +0 -2
  49. package/cjs/vtable.js +0 -35
  50. package/cjs/vtable.js.map +0 -1
  51. package/es/components/custom/component.d.ts +0 -12
  52. package/es/components/custom/component.js +0 -2
  53. package/es/components/custom/component.js.map +0 -1
  54. package/es/components/custom/custom-layout.d.ts +0 -10
  55. package/es/components/custom/custom-layout.js +0 -70
  56. package/es/components/custom/custom-layout.js.map +0 -1
  57. package/es/components/custom/graphic.d.ts +0 -32
  58. package/es/components/custom/graphic.js +0 -22
  59. package/es/components/custom/graphic.js.map +0 -1
  60. package/es/components/custom/reconciler.d.ts +0 -5
  61. package/es/components/custom/reconciler.js +0 -105
  62. package/es/components/custom/reconciler.js.map +0 -1
  63. package/es/components/custom/vtable-browser-env-contribution.d.ts +0 -2
  64. package/es/components/custom/vtable-browser-env-contribution.js +0 -33
  65. package/es/components/custom/vtable-browser-env-contribution.js.map +0 -1
  66. package/es/components/custom/vtable-react-attribute-plugin.d.ts +0 -17
  67. package/es/components/custom/vtable-react-attribute-plugin.js +0 -86
  68. package/es/components/custom/vtable-react-attribute-plugin.js.map +0 -1
  69. package/es/vtable.d.ts +0 -2
  70. package/es/vtable.js +0 -4
  71. package/es/vtable.js.map +0 -1
@@ -1,105 +0,0 @@
1
- import { VRender } from "@visactor/vtable";
2
-
3
- import { isFunction } from "@visactor/vutils";
4
-
5
- import React from "react";
6
-
7
- import ReactReconciler from "react-reconciler";
8
-
9
- import { DefaultEventPriority } from "react-reconciler/constants.js";
10
-
11
- const {application: application, createText: createText, REACT_TO_CANOPUS_EVENTS: REACT_TO_CANOPUS_EVENTS, Tag: Tag} = VRender;
12
-
13
- export const reconcilor = ReactReconciler({
14
- supportsMutation: !0,
15
- supportsPersistence: !1,
16
- createInstance: (type, props, instance) => {
17
- const graphic = createGraphic(type, props);
18
- if (graphic) return bindEventsToGraphic(graphic, props), graphic;
19
- },
20
- createTextInstance: (text, instance) => {},
21
- appendInitialChild: (parentInstance, childInstance) => {
22
- parentInstance.add(childInstance);
23
- },
24
- finalizeInitialChildren: () => !1,
25
- prepareUpdate: () => !0,
26
- shouldSetTextContent: () => !1,
27
- getRootHostContext: () => null,
28
- getChildHostContext: () => null,
29
- getPublicInstance: instance => instance,
30
- prepareForCommit: () => null,
31
- resetAfterCommit: () => {},
32
- preparePortalMount: () => null,
33
- scheduleTimeout: setTimeout,
34
- cancelTimeout: clearTimeout,
35
- noTimeout: -1,
36
- isPrimaryRenderer: !1,
37
- getCurrentEventPriority: () => DefaultEventPriority,
38
- getInstanceFromNode: node => null,
39
- beforeActiveInstanceBlur: () => {},
40
- afterActiveInstanceBlur: () => {},
41
- prepareScopeUpdate: () => {},
42
- getInstanceFromScope: () => {},
43
- detachDeletedInstance: () => {},
44
- supportsHydration: !1,
45
- appendChild: (parentInstance, child) => {
46
- parentInstance.add(child);
47
- },
48
- appendChildToContainer: (container, child) => {
49
- container.add(child);
50
- },
51
- insertBefore: (parentInstance, child, beforeChild) => {
52
- parentInstance.insertBefore(child, beforeChild);
53
- },
54
- insertInContainerBefore: (parentInstance, child, beforeChild) => {
55
- parentInstance.insertBefore(child, beforeChild);
56
- },
57
- removeChild: (parentInstance, child) => {
58
- child.delete();
59
- },
60
- removeChildFromContainer: (parentInstance, child) => {
61
- child.delete();
62
- },
63
- commitUpdate: (instance, updatePayload, type, oldProps, newProps) => {
64
- updateGraphicProps(instance, newProps, oldProps);
65
- },
66
- hideInstance: instance => {
67
- instance.setAttribute("visible", !1);
68
- },
69
- unhideInstance: (instance, props) => {
70
- instance.setAttribute("visible", !0);
71
- },
72
- clearContainer: container => {
73
- container.removeAllChild();
74
- },
75
- commitTextUpdate: (textInstance, oldText, newText) => {}
76
- });
77
-
78
- function createGraphic(type, props) {
79
- if ("tag" === type) {
80
- return new Tag(props.attribute);
81
- }
82
- if (!application.graphicService.creator[type]) return;
83
- return application.graphicService.creator[type](props.attribute);
84
- }
85
-
86
- function isEventProp(key, props) {
87
- return key.startsWith("on") && isFunction(props[key]);
88
- }
89
-
90
- function bindEventsToGraphic(graphic, props) {
91
- for (const key in props) isEventProp(key, props) && graphic.addEventListener(REACT_TO_CANOPUS_EVENTS[key], props[key]);
92
- }
93
-
94
- function updateGraphicProps(graphic, newProps, oldProps) {
95
- for (const propKey in oldProps) isEventProp(propKey, oldProps) && oldProps[propKey] !== newProps[propKey] && graphic.removeEventListener(REACT_TO_CANOPUS_EVENTS[propKey], oldProps[propKey]);
96
- for (const propKey in newProps) isEventProp(propKey, newProps) && oldProps[propKey] !== newProps[propKey] && graphic.addEventListener(REACT_TO_CANOPUS_EVENTS[propKey], newProps[propKey]);
97
- graphic.initAttributes(newProps.attribute);
98
- }
99
-
100
- //# sourceMappingURL=reconciler.js.map
101
- reconcilor.injectIntoDevTools({
102
- bundleType: "production" !== process.env.NODE_ENV ? 1 : 0,
103
- version: React.version,
104
- rendererPackageName: "react-vtable"
105
- });
@@ -1 +0,0 @@
1
- {"version":3,"sources":["components/custom/reconciler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,uBAAuB,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAI1E,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AK,EAAE;QACvB,IAAI,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE;YAC3B,OAAO,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;SACpE;KACF;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAgB,EAAE,QAAa,EAAE,QAAa;IAExE,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,IAAI,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC7E,OAAO,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;SAClF;KACF;IACD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,IAAI,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC7E,OAAO,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;SAC/E;KACF;IAGD,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","file":"reconciler.js","sourcesContent":["import { VRender } from '@visactor/vtable';\nimport { isFunction } from '@visactor/vutils';\nimport React from 'react';\nimport ReactReconciler from 'react-reconciler';\nimport { DefaultEventPriority } from 'react-reconciler/constants.js';\n\nconst { application, createText, REACT_TO_CANOPUS_EVENTS, Tag } = VRender;\ntype Graphic = VRender.Graphic;\ntype Instance = Graphic;\n\nexport const reconcilor = ReactReconciler({\n supportsMutation: true,\n supportsPersistence: false,\n\n createInstance: (type: string, props: any, instance) => {\n const graphic = createGraphic(type, props);\n if (graphic) {\n bindEventsToGraphic(graphic, props);\n } else {\n return undefined;\n // createInstance\n // graphic = createGraphic('group', {});\n }\n return graphic;\n },\n\n createTextInstance: (text, instance) => {\n // const textGraphic = createText({ text });\n // return textGraphic;\n // debugger;\n // return document.createTextNode(text);\n return undefined;\n },\n\n appendInitialChild: (parentInstance: Instance, childInstance: Instance) => {\n parentInstance.add(childInstance);\n },\n\n finalizeInitialChildren: () => false,\n\n prepareUpdate: () => true,\n\n shouldSetTextContent: () => false,\n\n getRootHostContext: () => null,\n\n getChildHostContext: () => null,\n\n getPublicInstance: (instance: Instance) => {\n return instance;\n },\n\n prepareForCommit: () => null,\n\n resetAfterCommit: () => undefined,\n\n preparePortalMount: () => null,\n\n // eslint-disable-next-line no-undef\n scheduleTimeout: setTimeout,\n // eslint-disable-next-line no-undef\n cancelTimeout: clearTimeout,\n\n noTimeout: -1,\n isPrimaryRenderer: false,\n\n getCurrentEventPriority: () => DefaultEventPriority,\n\n getInstanceFromNode: node => null,\n\n beforeActiveInstanceBlur: () => undefined,\n\n afterActiveInstanceBlur: () => undefined,\n\n prepareScopeUpdate: () => undefined,\n\n getInstanceFromScope: () => undefined,\n\n detachDeletedInstance: () => undefined,\n\n supportsHydration: false,\n\n appendChild: (parentInstance: Instance, child: Instance) => {\n parentInstance.add(child);\n },\n appendChildToContainer: (container: Instance, child: Instance) => {\n container.add(child);\n },\n\n insertBefore: (parentInstance: Instance, child: Instance, beforeChild: Instance) => {\n parentInstance.insertBefore(child, beforeChild);\n },\n\n insertInContainerBefore: (parentInstance: Instance, child: Instance, beforeChild: Instance) => {\n parentInstance.insertBefore(child, beforeChild);\n },\n\n removeChild: (parentInstance: Instance, child: Instance) => {\n child.delete();\n },\n\n removeChildFromContainer: (parentInstance: Instance, child: Instance) => {\n child.delete();\n },\n\n commitUpdate: (instance, updatePayload, type, oldProps, newProps) => {\n updateGraphicProps(instance, newProps, oldProps);\n },\n\n hideInstance: (instance: Instance) => {\n instance.setAttribute('visible', false);\n },\n\n unhideInstance: (instance, props) => {\n instance.setAttribute('visible', true);\n },\n\n clearContainer: (container: Instance) => {\n container.removeAllChild();\n },\n\n commitTextUpdate: (textInstance: any, oldText: string, newText: string) => {\n // debugger;\n }\n});\n\nreconcilor.injectIntoDevTools({\n // findFiberByHostInstance: () => {},\n // @ts-ignore\n // eslint-disable-next-line no-undef\n bundleType: process.env.NODE_ENV !== 'production' ? 1 : 0,\n version: React.version,\n rendererPackageName: 'react-vtable'\n});\n\nfunction createGraphic(type: string, props: any) {\n // may have unwanted onxxx prop\n if (type === 'tag') {\n const tag = new Tag(props.attribute);\n return tag;\n } else if (!application.graphicService.creator[type]) {\n return;\n }\n const graphic = application.graphicService.creator[type]((props as any).attribute);\n return graphic;\n}\n\nfunction isEventProp(key: string, props: any) {\n return key.startsWith('on') && isFunction(props[key]);\n}\n\nfunction bindEventsToGraphic(graphic: Graphic, props: any) {\n for (const key in props) {\n if (isEventProp(key, props)) {\n graphic.addEventListener(REACT_TO_CANOPUS_EVENTS[key], props[key]);\n }\n }\n}\n\nfunction updateGraphicProps(graphic: Graphic, newProps: any, oldProps: any) {\n // deal width event update\n for (const propKey in oldProps) {\n if (isEventProp(propKey, oldProps) && oldProps[propKey] !== newProps[propKey]) {\n graphic.removeEventListener(REACT_TO_CANOPUS_EVENTS[propKey], oldProps[propKey]);\n }\n }\n for (const propKey in newProps) {\n if (isEventProp(propKey, newProps) && oldProps[propKey] !== newProps[propKey]) {\n graphic.addEventListener(REACT_TO_CANOPUS_EVENTS[propKey], newProps[propKey]);\n }\n }\n\n // update all attribute\n graphic.initAttributes(newProps.attribute);\n}\n"]}
@@ -1,2 +0,0 @@
1
- import { VRender } from '@visactor/vtable';
2
- export declare const reactEnvModule: VRender.ContainerModule;
@@ -1,33 +0,0 @@
1
- import { getTargetCell, VRender } from "@visactor/vtable";
2
-
3
- import { isString } from "@visactor/vutils";
4
-
5
- const {ContainerModule: ContainerModule, EnvContribution: EnvContribution, BrowserEnvContribution: BrowserEnvContribution} = VRender;
6
-
7
- export const reactEnvModule = new ContainerModule(((bind, unbind, isBound, rebind) => {
8
- bind(VTableBrowserEnvContribution).toSelf().inSingletonScope(), isBound(EnvContribution) ? rebind(EnvContribution).toService(VTableBrowserEnvContribution) : bind(EnvContribution).toService(VTableBrowserEnvContribution);
9
- }));
10
-
11
- class VTableBrowserEnvContribution extends BrowserEnvContribution {
12
- updateDom(dom, params) {
13
- var _a, _b;
14
- const tableDiv = dom.parentElement;
15
- if (tableDiv) {
16
- const top = parseInt(params.style.top, 10), left = parseInt(params.style.left, 10);
17
- let domWidth, domHeight;
18
- if (dom.style.display = "none") {
19
- const cellGroup = getTargetCell(params.graphic);
20
- domWidth = null !== (_a = cellGroup.attribute.width) && void 0 !== _a ? _a : 1,
21
- domHeight = null !== (_b = cellGroup.attribute.height) && void 0 !== _b ? _b : 1;
22
- } else domWidth = dom.offsetWidth, domHeight = dom.offsetHeight;
23
- if (top + domHeight < 0 || left + domWidth < 0 || top > tableDiv.offsetHeight || left > tableDiv.offsetWidth) return dom.style.display = "none",
24
- !1;
25
- }
26
- const {width: width, height: height, style: style} = params;
27
- return style && (isString(style) ? dom.setAttribute("style", style) : Object.keys(style).forEach((k => {
28
- dom.style[k] = style[k];
29
- }))), null != width && (dom.style.width = `${width}px`), null != height && (dom.style.height = `${height}px`),
30
- !0;
31
- }
32
- }
33
- //# sourceMappingURL=vtable-browser-env-contribution.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["components/custom/vtable-browser-env-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC;AAG7E,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE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WAAW,EAAE;gBAC5G,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;gBAC3B,OAAO,KAAK,CAAC;aACd;SACF;QAED,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAExC,IAAI,KAAK,EAAE;YACT,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACnB,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;aAClC;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBAC7B,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC1B,CAAC,CAAC,CAAC;aACJ;SACF;QACD,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,KAAK,IAAI,CAAC;SAChC;QACD,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC;SAClC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","file":"vtable-browser-env-contribution.js","sourcesContent":["import { getTargetCell, VRender } from '@visactor/vtable';\nimport { isString } from '@visactor/vutils';\n\nconst { ContainerModule, EnvContribution, BrowserEnvContribution } = VRender;\ntype CreateDOMParamsType = VRender.CreateDOMParamsType;\n\nexport const reactEnvModule = new ContainerModule((bind, unbind, isBound, rebind) => {\n bind(VTableBrowserEnvContribution).toSelf().inSingletonScope();\n if (isBound(EnvContribution)) {\n rebind(EnvContribution).toService(VTableBrowserEnvContribution);\n } else {\n bind(EnvContribution).toService(VTableBrowserEnvContribution);\n }\n});\n\nclass VTableBrowserEnvContribution extends BrowserEnvContribution {\n updateDom(dom: HTMLElement, params: CreateDOMParamsType): boolean {\n const tableDiv = dom.parentElement;\n if (tableDiv) {\n const top = parseInt(params.style.top, 10);\n const left = parseInt(params.style.left, 10);\n\n let domWidth;\n let domHeight;\n if ((dom.style.display = 'none')) {\n const cellGroup = getTargetCell(params.graphic);\n domWidth = cellGroup.attribute.width ?? 1;\n domHeight = cellGroup.attribute.height ?? 1;\n } else {\n domWidth = dom.offsetWidth;\n domHeight = dom.offsetHeight;\n }\n if (top + domHeight < 0 || left + domWidth < 0 || top > tableDiv.offsetHeight || left > tableDiv.offsetWidth) {\n dom.style.display = 'none';\n return false;\n }\n }\n\n const { width, height, style } = params;\n\n if (style) {\n if (isString(style)) {\n dom.setAttribute('style', style);\n } else {\n Object.keys(style).forEach(k => {\n dom.style[k] = style[k];\n });\n }\n }\n if (width != null) {\n dom.style.width = `${width}px`;\n }\n if (height != null) {\n dom.style.height = `${height}px`;\n }\n\n return true;\n }\n}\n"]}
@@ -1,17 +0,0 @@
1
- import { VRender } from '@visactor/vtable';
2
- declare const ReactAttributePlugin: typeof VRender.ReactAttributePlugin;
3
- type CommonDomOptions = VRender.CommonDomOptions;
4
- type CreateDOMParamsType = VRender.CreateDOMParamsType;
5
- type IGraphic = VRender.CreateDOMParamsType;
6
- type IStage = VRender.CreateDOMParamsType;
7
- type SimpleDomStyleOptions = VRender.CreateDOMParamsType;
8
- export declare class VTableReactAttributePlugin extends ReactAttributePlugin {
9
- removeElement(id: string): void;
10
- renderGraphicHTML(graphic: IGraphic): void;
11
- getWrapContainer(stage: IStage, userContainer?: string | HTMLElement | null, domParams?: CreateDOMParamsType): {
12
- wrapContainer: HTMLElement;
13
- nativeContainer: any;
14
- };
15
- updateStyleOfWrapContainer(graphic: IGraphic, stage: IStage, wrapContainer: HTMLElement, nativeContainer: HTMLElement, options: SimpleDomStyleOptions & CommonDomOptions): void;
16
- }
17
- export {};
@@ -1,86 +0,0 @@
1
- import { VRender } from "@visactor/vtable";
2
-
3
- import { calculateAnchorOfBounds, isFunction, isNil, isObject, isString, styleStringToObject } from "@visactor/vutils";
4
-
5
- const {ReactAttributePlugin: ReactAttributePlugin, application: application} = VRender;
6
-
7
- export class VTableReactAttributePlugin extends ReactAttributePlugin {
8
- removeElement(id) {
9
- super.removeElement(id), delete this.htmlMap[id];
10
- }
11
- renderGraphicHTML(graphic) {
12
- var _a;
13
- const {react: react} = graphic.attribute;
14
- if (!react) return;
15
- const stage = graphic.stage;
16
- if (!stage) return;
17
- const ReactDOM = stage.params.ReactDOM, {element: element, container: container} = react;
18
- if (!(element && ReactDOM && ReactDOM.createRoot)) return;
19
- const id = isNil(react.id) ? `${null !== (_a = graphic.id) && void 0 !== _a ? _a : graphic._uid}_react` : react.id;
20
- if (this.htmlMap && this.htmlMap[id] && container && container !== this.htmlMap[id].container && this.removeElement(id),
21
- this.htmlMap && this.htmlMap[id]) this.htmlMap[id].root.render(element); else {
22
- const {wrapContainer: wrapContainer, nativeContainer: nativeContainer} = this.getWrapContainer(stage, container);
23
- if (wrapContainer) {
24
- const root = ReactDOM.createRoot(wrapContainer);
25
- root.render(element), this.htmlMap || (this.htmlMap = {}), this.htmlMap[id] = {
26
- root: root,
27
- wrapContainer: wrapContainer,
28
- nativeContainer: nativeContainer,
29
- container: container,
30
- renderId: this.renderId
31
- };
32
- }
33
- }
34
- if (!this.htmlMap || !this.htmlMap[id]) return;
35
- const {wrapContainer: wrapContainer, nativeContainer: nativeContainer} = this.htmlMap[id];
36
- this.updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, react),
37
- this.htmlMap[id].renderId = this.renderId;
38
- }
39
- getWrapContainer(stage, userContainer, domParams) {
40
- let nativeContainer;
41
- return nativeContainer = userContainer ? "string" == typeof userContainer ? application.global.getElementById(userContainer) : userContainer : stage.window.getContainer(),
42
- {
43
- wrapContainer: application.global.createDom(Object.assign({
44
- tagName: "div",
45
- parent: nativeContainer
46
- }, domParams)),
47
- nativeContainer: nativeContainer
48
- };
49
- }
50
- updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, options) {
51
- const {pointerEvents: pointerEvents} = options;
52
- let calculateStyle = this.parseDefaultStyleFromGraphic(graphic);
53
- calculateStyle.display = !1 !== graphic.attribute.visible ? "block" : "none", calculateStyle.pointerEvents = !0 === pointerEvents ? "all" : pointerEvents || "none",
54
- wrapContainer.style.position || (wrapContainer.style.position = "absolute", nativeContainer.style.position = "relative");
55
- let left = 0, top = 0;
56
- const b = graphic.globalAABBBounds;
57
- let anchorType = options.anchorType;
58
- if (isNil(anchorType) && (anchorType = "text" === graphic.type ? "position" : "boundsLeftTop"),
59
- "boundsLeftTop" === anchorType && (anchorType = "top-left"), "position" === anchorType || b.empty()) {
60
- const matrix = graphic.globalTransMatrix;
61
- left = matrix.e, top = matrix.f;
62
- } else {
63
- const anchor = calculateAnchorOfBounds(b, anchorType);
64
- left = anchor.x, top = anchor.y;
65
- }
66
- const containerTL = application.global.getElementTopLeft(nativeContainer, !1), windowTL = stage.window.getTopLeft(!1), offsetX = left + windowTL.left - containerTL.left, offsetTop = top + windowTL.top - containerTL.top;
67
- if (calculateStyle.left = `${offsetX}px`, calculateStyle.top = `${offsetTop}px`,
68
- "text" === graphic.type && "position" === anchorType && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), this.getTransformOfText(graphic))),
69
- isFunction(options.style)) {
70
- const userStyle = options.style({
71
- top: offsetTop,
72
- left: offsetX,
73
- width: b.width(),
74
- height: b.height()
75
- }, graphic, wrapContainer);
76
- userStyle && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), userStyle));
77
- } else isObject(options.style) ? calculateStyle = Object.assign(Object.assign({}, calculateStyle), options.style) : isString(options.style) && options.style && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), styleStringToObject(options.style)));
78
- application.global.updateDom(wrapContainer, {
79
- width: options.width,
80
- height: options.width,
81
- style: calculateStyle,
82
- graphic: graphic
83
- });
84
- }
85
- }
86
- //# sourceMappingURL=vtable-react-attribute-plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["components/custom/vtable-react-attribute-plugin.ts"],"names":[],"mapp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EAAE;YAC7B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAC7B,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EACvE,OAAO,EACP,aAAa,CACd,CAAC;YAEF,IAAI,SAAS,EAAE;gBACb,cAAc,mCAAQ,cAAc,GAAK,SAAS,CAAE,CAAC;aACtD;SACF;aAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAClC,cAAc,mCAAQ,cAAc,GAAK,OAAO,CAAC,KAAK,CAAE,CAAC;SAC1D;aAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,EAAE;YACnD,cAAc,mCAAQ,cAAc,GAAK,mBAAmB,CAAC,OAAO,CAAC,KAAe,CAAC,CAAE,CAAC;SACzF;QAGD,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE;YAC1C,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,KAAK;YACrB,KAAK,EAAE,cAAc;YACrB,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF","file":"vtable-react-attribute-plugin.js","sourcesContent":["import { VRender } from '@visactor/vtable';\nimport { calculateAnchorOfBounds, isFunction, isNil, isObject, isString, styleStringToObject } from '@visactor/vutils';\n\nconst { ReactAttributePlugin, application } = VRender;\ntype CommonDomOptions = VRender.CommonDomOptions;\ntype CreateDOMParamsType = VRender.CreateDOMParamsType;\ntype IGraphic = VRender.CreateDOMParamsType;\ntype IStage = VRender.CreateDOMParamsType;\ntype IText = VRender.CreateDOMParamsType;\ntype SimpleDomStyleOptions = VRender.CreateDOMParamsType;\n\nexport class VTableReactAttributePlugin extends ReactAttributePlugin {\n removeElement(id: string) {\n super.removeElement(id);\n delete this.htmlMap[id];\n }\n\n renderGraphicHTML(graphic: IGraphic) {\n const { react } = graphic.attribute;\n if (!react) {\n return;\n }\n const stage = graphic.stage;\n if (!stage) {\n return;\n }\n const ReactDOM = stage.params.ReactDOM;\n const { element, container } = react;\n if (!(element && ReactDOM && ReactDOM.createRoot)) {\n return;\n }\n const id = isNil(react.id) ? `${graphic.id ?? graphic._uid}_react` : react.id;\n\n if (this.htmlMap && this.htmlMap[id] && container && container !== this.htmlMap[id].container) {\n this.removeElement(id);\n }\n\n if (!this.htmlMap || !this.htmlMap[id]) {\n // createa a wrapper contianer to be the root of react element\n const { wrapContainer, nativeContainer } = this.getWrapContainer(stage, container);\n\n if (wrapContainer) {\n const root = ReactDOM.createRoot(wrapContainer);\n root.render(element);\n\n if (!this.htmlMap) {\n this.htmlMap = {};\n }\n\n this.htmlMap[id] = { root, wrapContainer, nativeContainer, container, renderId: this.renderId };\n }\n } else {\n // update react element\n this.htmlMap[id].root.render(element);\n }\n\n if (!this.htmlMap || !this.htmlMap[id]) {\n return;\n }\n\n const { wrapContainer, nativeContainer } = this.htmlMap[id];\n\n this.updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, react);\n this.htmlMap[id].renderId = this.renderId;\n }\n\n getWrapContainer(stage: IStage, userContainer?: string | HTMLElement | null, domParams?: CreateDOMParamsType) {\n let nativeContainer;\n if (userContainer) {\n if (typeof userContainer === 'string') {\n nativeContainer = application.global.getElementById(userContainer);\n } else {\n nativeContainer = userContainer;\n }\n } else {\n nativeContainer = stage.window.getContainer();\n }\n // 创建wrapGroup\n return {\n wrapContainer: application.global.createDom({ tagName: 'div', parent: nativeContainer, ...domParams }),\n nativeContainer\n };\n }\n\n updateStyleOfWrapContainer(\n graphic: IGraphic,\n stage: IStage,\n wrapContainer: HTMLElement,\n nativeContainer: HTMLElement,\n options: SimpleDomStyleOptions & CommonDomOptions\n ) {\n const { pointerEvents } = options;\n let calculateStyle = this.parseDefaultStyleFromGraphic(graphic);\n\n calculateStyle.display = graphic.attribute.visible !== false ? 'block' : 'none';\n // 事件穿透\n calculateStyle.pointerEvents = pointerEvents === true ? 'all' : pointerEvents ? pointerEvents : 'none';\n // 定位wrapGroup\n if (!wrapContainer.style.position) {\n wrapContainer.style.position = 'absolute';\n nativeContainer.style.position = 'relative';\n }\n let left: number = 0;\n let top: number = 0;\n const b = graphic.globalAABBBounds;\n\n let anchorType = options.anchorType;\n\n if (isNil(anchorType)) {\n anchorType = graphic.type === 'text' ? 'position' : 'boundsLeftTop';\n }\n\n if (anchorType === 'boundsLeftTop') {\n // 兼容老的配置,统一配置\n anchorType = 'top-left';\n }\n if (anchorType === 'position' || b.empty()) {\n const matrix = graphic.globalTransMatrix;\n left = matrix.e;\n top = matrix.f;\n } else {\n const anchor = calculateAnchorOfBounds(b, anchorType);\n\n left = anchor.x;\n top = anchor.y;\n }\n\n // 查看wrapGroup的位置\n // const wrapGroupTL = application.global.getElementTopLeft(wrapGroup, false);\n const containerTL = application.global.getElementTopLeft(nativeContainer, false);\n const windowTL = stage.window.getTopLeft(false);\n const offsetX = left + windowTL.left - containerTL.left;\n const offsetTop = top + windowTL.top - containerTL.top;\n // wrapGroup.style.transform = `translate(${offsetX}px, ${offsetTop}px)`;\n calculateStyle.left = `${offsetX}px`;\n calculateStyle.top = `${offsetTop}px`;\n\n if (graphic.type === 'text' && anchorType === 'position') {\n calculateStyle = {\n ...calculateStyle,\n ...this.getTransformOfText(graphic as IText)\n };\n }\n\n if (isFunction(options.style)) {\n const userStyle = options.style(\n { top: offsetTop, left: offsetX, width: b.width(), height: b.height() },\n graphic,\n wrapContainer\n );\n\n if (userStyle) {\n calculateStyle = { ...calculateStyle, ...userStyle };\n }\n } else if (isObject(options.style)) {\n calculateStyle = { ...calculateStyle, ...options.style };\n } else if (isString(options.style) && options.style) {\n calculateStyle = { ...calculateStyle, ...styleStringToObject(options.style as string) };\n }\n\n // 更新样式\n application.global.updateDom(wrapContainer, {\n width: options.width,\n height: options.width,\n style: calculateStyle,\n graphic\n });\n }\n}\n"]}
package/es/vtable.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import * as VTable from '@visactor/vtable';
2
- export { VTable };
package/es/vtable.js DELETED
@@ -1,4 +0,0 @@
1
- import * as VTable from "@visactor/vtable";
2
-
3
- export { VTable };
4
- //# sourceMappingURL=vtable.js.map
package/es/vtable.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["vtable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,CAAC","file":"vtable.js","sourcesContent":["import * as VTable from '@visactor/vtable';\n\nexport { VTable };\n"]}