k-react-vtable 1.0.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.
Files changed (268) hide show
  1. package/README.md +93 -0
  2. package/cjs/components/avatar/avatar.d.ts +14 -0
  3. package/cjs/components/avatar/avatar.js +84 -0
  4. package/cjs/components/avatar/avatar.js.map +1 -0
  5. package/cjs/components/button/button.d.ts +27 -0
  6. package/cjs/components/button/button.js +107 -0
  7. package/cjs/components/button/button.js.map +1 -0
  8. package/cjs/components/checkbox/checkbox.d.ts +17 -0
  9. package/cjs/components/checkbox/checkbox.js +69 -0
  10. package/cjs/components/checkbox/checkbox.js.map +1 -0
  11. package/cjs/components/index.d.ts +7 -0
  12. package/cjs/components/index.js +24 -0
  13. package/cjs/components/index.js.map +1 -0
  14. package/cjs/components/link/link.d.ts +30 -0
  15. package/cjs/components/link/link.js +119 -0
  16. package/cjs/components/link/link.js.map +1 -0
  17. package/cjs/components/popover/popover.d.ts +14 -0
  18. package/cjs/components/popover/popover.js +283 -0
  19. package/cjs/components/popover/popover.js.map +1 -0
  20. package/cjs/components/radio/radio.d.ts +15 -0
  21. package/cjs/components/radio/radio.js +68 -0
  22. package/cjs/components/radio/radio.js.map +1 -0
  23. package/cjs/components/tag/tag.d.ts +13 -0
  24. package/cjs/components/tag/tag.js +47 -0
  25. package/cjs/components/tag/tag.js.map +1 -0
  26. package/cjs/components/vrender-components/checkbox.d.ts +4 -0
  27. package/cjs/components/vrender-components/checkbox.js +6 -0
  28. package/cjs/components/vrender-components/checkbox.js.map +1 -0
  29. package/cjs/components/vrender-components/component-creater.d.ts +1 -0
  30. package/cjs/components/vrender-components/component-creater.js +22 -0
  31. package/cjs/components/vrender-components/component-creater.js.map +1 -0
  32. package/cjs/components/vrender-components/radio.d.ts +4 -0
  33. package/cjs/components/vrender-components/radio.js +6 -0
  34. package/cjs/components/vrender-components/radio.js.map +1 -0
  35. package/cjs/components/vrender-components/tag.d.ts +4 -0
  36. package/cjs/components/vrender-components/tag.js +6 -0
  37. package/cjs/components/vrender-components/tag.js.map +1 -0
  38. package/cjs/components/vrender-components/type.d.ts +6 -0
  39. package/cjs/components/vrender-components/type.js +6 -0
  40. package/cjs/components/vrender-components/type.js.map +1 -0
  41. package/cjs/constants.d.ts +1 -0
  42. package/cjs/constants.js +6 -0
  43. package/cjs/constants.js.map +1 -0
  44. package/cjs/containers/withContainer.d.ts +8 -0
  45. package/cjs/containers/withContainer.js +63 -0
  46. package/cjs/containers/withContainer.js.map +1 -0
  47. package/cjs/context/table.d.ts +9 -0
  48. package/cjs/context/table.js +25 -0
  49. package/cjs/context/table.js.map +1 -0
  50. package/cjs/eventsUtils.d.ts +130 -0
  51. package/cjs/eventsUtils.js +93 -0
  52. package/cjs/eventsUtils.js.map +1 -0
  53. package/cjs/index.d.ts +4 -0
  54. package/cjs/index.js +22 -0
  55. package/cjs/index.js.map +1 -0
  56. package/cjs/table-components/base-component.d.ts +12 -0
  57. package/cjs/table-components/base-component.js +87 -0
  58. package/cjs/table-components/base-component.js.map +1 -0
  59. package/cjs/table-components/component/emptyTip.d.ts +20 -0
  60. package/cjs/table-components/component/emptyTip.js +10 -0
  61. package/cjs/table-components/component/emptyTip.js.map +1 -0
  62. package/cjs/table-components/component/menu.d.ts +10 -0
  63. package/cjs/table-components/component/menu.js +10 -0
  64. package/cjs/table-components/component/menu.js.map +1 -0
  65. package/cjs/table-components/component/title.d.ts +4 -0
  66. package/cjs/table-components/component/title.js +10 -0
  67. package/cjs/table-components/component/title.js.map +1 -0
  68. package/cjs/table-components/component/tooltip.d.ts +7 -0
  69. package/cjs/table-components/component/tooltip.js +10 -0
  70. package/cjs/table-components/component/tooltip.js.map +1 -0
  71. package/cjs/table-components/custom/custom-layout.d.ts +11 -0
  72. package/cjs/table-components/custom/custom-layout.js +107 -0
  73. package/cjs/table-components/custom/custom-layout.js.map +1 -0
  74. package/cjs/table-components/custom/graphic.d.ts +19 -0
  75. package/cjs/table-components/custom/graphic.js +9 -0
  76. package/cjs/table-components/custom/graphic.js.map +1 -0
  77. package/cjs/table-components/custom/reconciler.d.ts +2 -0
  78. package/cjs/table-components/custom/reconciler.js +107 -0
  79. package/cjs/table-components/custom/reconciler.js.map +1 -0
  80. package/cjs/table-components/custom/vtable-browser-env-contribution.d.ts +6 -0
  81. package/cjs/table-components/custom/vtable-browser-env-contribution.js +35 -0
  82. package/cjs/table-components/custom/vtable-browser-env-contribution.js.map +1 -0
  83. package/cjs/table-components/custom/vtable-react-attribute-plugin.d.ts +21 -0
  84. package/cjs/table-components/custom/vtable-react-attribute-plugin.js +135 -0
  85. package/cjs/table-components/custom/vtable-react-attribute-plugin.js.map +1 -0
  86. package/cjs/table-components/custom-component.d.ts +17 -0
  87. package/cjs/table-components/custom-component.js +98 -0
  88. package/cjs/table-components/custom-component.js.map +1 -0
  89. package/cjs/table-components/index.d.ts +20 -0
  90. package/cjs/table-components/index.js +130 -0
  91. package/cjs/table-components/index.js.map +1 -0
  92. package/cjs/table-components/list/list-column.d.ts +4 -0
  93. package/cjs/table-components/list/list-column.js +10 -0
  94. package/cjs/table-components/list/list-column.js.map +1 -0
  95. package/cjs/table-components/pivot/pivot-corner.d.ts +4 -0
  96. package/cjs/table-components/pivot/pivot-corner.js +10 -0
  97. package/cjs/table-components/pivot/pivot-corner.js.map +1 -0
  98. package/cjs/table-components/pivot/pivot-dimension.d.ts +6 -0
  99. package/cjs/table-components/pivot/pivot-dimension.js +11 -0
  100. package/cjs/table-components/pivot/pivot-dimension.js.map +1 -0
  101. package/cjs/table-components/pivot/pivot-header-title.d.ts +5 -0
  102. package/cjs/table-components/pivot/pivot-header-title.js +11 -0
  103. package/cjs/table-components/pivot/pivot-header-title.js.map +1 -0
  104. package/cjs/table-components/pivot/pivot-indicator.d.ts +4 -0
  105. package/cjs/table-components/pivot/pivot-indicator.js +10 -0
  106. package/cjs/table-components/pivot/pivot-indicator.js.map +1 -0
  107. package/cjs/tables/base-table.d.ts +23 -0
  108. package/cjs/tables/base-table.js +199 -0
  109. package/cjs/tables/base-table.js.map +1 -0
  110. package/cjs/tables/index.d.ts +6 -0
  111. package/cjs/tables/index.js +65 -0
  112. package/cjs/tables/index.js.map +1 -0
  113. package/cjs/tables/list-table-simple.d.ts +8 -0
  114. package/cjs/tables/list-table-simple.js +13 -0
  115. package/cjs/tables/list-table-simple.js.map +1 -0
  116. package/cjs/tables/list-table.d.ts +8 -0
  117. package/cjs/tables/list-table.js +13 -0
  118. package/cjs/tables/list-table.js.map +1 -0
  119. package/cjs/tables/pivot-chart.d.ts +13 -0
  120. package/cjs/tables/pivot-chart.js +17 -0
  121. package/cjs/tables/pivot-chart.js.map +1 -0
  122. package/cjs/tables/pivot-table-simple.d.ts +8 -0
  123. package/cjs/tables/pivot-table-simple.js +13 -0
  124. package/cjs/tables/pivot-table-simple.js.map +1 -0
  125. package/cjs/tables/pivot-table.d.ts +8 -0
  126. package/cjs/tables/pivot-table.js +13 -0
  127. package/cjs/tables/pivot-table.js.map +1 -0
  128. package/cjs/util.d.ts +8 -0
  129. package/cjs/util.js +56 -0
  130. package/cjs/util.js.map +1 -0
  131. package/cjs/vtable.d.ts +1 -0
  132. package/cjs/vtable.js +2 -0
  133. package/cjs/vtable.js.map +1 -0
  134. package/dist/react-vtable.js +7662 -0
  135. package/dist/react-vtable.min.js +10 -0
  136. package/es/components/avatar/avatar.d.ts +14 -0
  137. package/es/components/avatar/avatar.js +82 -0
  138. package/es/components/avatar/avatar.js.map +1 -0
  139. package/es/components/button/button.d.ts +27 -0
  140. package/es/components/button/button.js +84 -0
  141. package/es/components/button/button.js.map +1 -0
  142. package/es/components/checkbox/checkbox.d.ts +17 -0
  143. package/es/components/checkbox/checkbox.js +48 -0
  144. package/es/components/checkbox/checkbox.js.map +1 -0
  145. package/es/components/index.d.ts +7 -0
  146. package/es/components/index.js +14 -0
  147. package/es/components/index.js.map +1 -0
  148. package/es/components/link/link.d.ts +30 -0
  149. package/es/components/link/link.js +96 -0
  150. package/es/components/link/link.js.map +1 -0
  151. package/es/components/popover/popover.d.ts +14 -0
  152. package/es/components/popover/popover.js +260 -0
  153. package/es/components/popover/popover.js.map +1 -0
  154. package/es/components/radio/radio.d.ts +15 -0
  155. package/es/components/radio/radio.js +47 -0
  156. package/es/components/radio/radio.js.map +1 -0
  157. package/es/components/tag/tag.d.ts +13 -0
  158. package/es/components/tag/tag.js +45 -0
  159. package/es/components/tag/tag.js.map +1 -0
  160. package/es/components/vrender-components/checkbox.d.ts +4 -0
  161. package/es/components/vrender-components/checkbox.js +2 -0
  162. package/es/components/vrender-components/checkbox.js.map +1 -0
  163. package/es/components/vrender-components/component-creater.d.ts +1 -0
  164. package/es/components/vrender-components/component-creater.js +14 -0
  165. package/es/components/vrender-components/component-creater.js.map +1 -0
  166. package/es/components/vrender-components/radio.d.ts +4 -0
  167. package/es/components/vrender-components/radio.js +2 -0
  168. package/es/components/vrender-components/radio.js.map +1 -0
  169. package/es/components/vrender-components/tag.d.ts +4 -0
  170. package/es/components/vrender-components/tag.js +2 -0
  171. package/es/components/vrender-components/tag.js.map +1 -0
  172. package/es/components/vrender-components/type.d.ts +6 -0
  173. package/es/components/vrender-components/type.js +2 -0
  174. package/es/components/vrender-components/type.js.map +1 -0
  175. package/es/constants.d.ts +1 -0
  176. package/es/constants.js +2 -0
  177. package/es/constants.js.map +1 -0
  178. package/es/containers/withContainer.d.ts +8 -0
  179. package/es/containers/withContainer.js +32 -0
  180. package/es/containers/withContainer.js.map +1 -0
  181. package/es/context/table.d.ts +9 -0
  182. package/es/context/table.js +16 -0
  183. package/es/context/table.js.map +1 -0
  184. package/es/eventsUtils.d.ts +130 -0
  185. package/es/eventsUtils.js +86 -0
  186. package/es/eventsUtils.js.map +1 -0
  187. package/es/index.d.ts +4 -0
  188. package/es/index.js +8 -0
  189. package/es/index.js.map +1 -0
  190. package/es/table-components/base-component.d.ts +12 -0
  191. package/es/table-components/base-component.js +60 -0
  192. package/es/table-components/base-component.js.map +1 -0
  193. package/es/table-components/component/emptyTip.d.ts +20 -0
  194. package/es/table-components/component/emptyTip.js +4 -0
  195. package/es/table-components/component/emptyTip.js.map +1 -0
  196. package/es/table-components/component/menu.d.ts +10 -0
  197. package/es/table-components/component/menu.js +4 -0
  198. package/es/table-components/component/menu.js.map +1 -0
  199. package/es/table-components/component/title.d.ts +4 -0
  200. package/es/table-components/component/title.js +4 -0
  201. package/es/table-components/component/title.js.map +1 -0
  202. package/es/table-components/component/tooltip.d.ts +7 -0
  203. package/es/table-components/component/tooltip.js +4 -0
  204. package/es/table-components/component/tooltip.js.map +1 -0
  205. package/es/table-components/custom/custom-layout.d.ts +11 -0
  206. package/es/table-components/custom/custom-layout.js +79 -0
  207. package/es/table-components/custom/custom-layout.js.map +1 -0
  208. package/es/table-components/custom/graphic.d.ts +19 -0
  209. package/es/table-components/custom/graphic.js +22 -0
  210. package/es/table-components/custom/graphic.js.map +1 -0
  211. package/es/table-components/custom/reconciler.d.ts +2 -0
  212. package/es/table-components/custom/reconciler.js +106 -0
  213. package/es/table-components/custom/reconciler.js.map +1 -0
  214. package/es/table-components/custom/vtable-browser-env-contribution.d.ts +6 -0
  215. package/es/table-components/custom/vtable-browser-env-contribution.js +33 -0
  216. package/es/table-components/custom/vtable-browser-env-contribution.js.map +1 -0
  217. package/es/table-components/custom/vtable-react-attribute-plugin.d.ts +21 -0
  218. package/es/table-components/custom/vtable-react-attribute-plugin.js +127 -0
  219. package/es/table-components/custom/vtable-react-attribute-plugin.js.map +1 -0
  220. package/es/table-components/custom-component.d.ts +17 -0
  221. package/es/table-components/custom-component.js +67 -0
  222. package/es/table-components/custom-component.js.map +1 -0
  223. package/es/table-components/index.d.ts +20 -0
  224. package/es/table-components/index.js +26 -0
  225. package/es/table-components/index.js.map +1 -0
  226. package/es/table-components/list/list-column.d.ts +4 -0
  227. package/es/table-components/list/list-column.js +4 -0
  228. package/es/table-components/list/list-column.js.map +1 -0
  229. package/es/table-components/pivot/pivot-corner.d.ts +4 -0
  230. package/es/table-components/pivot/pivot-corner.js +4 -0
  231. package/es/table-components/pivot/pivot-corner.js.map +1 -0
  232. package/es/table-components/pivot/pivot-dimension.d.ts +6 -0
  233. package/es/table-components/pivot/pivot-dimension.js +6 -0
  234. package/es/table-components/pivot/pivot-dimension.js.map +1 -0
  235. package/es/table-components/pivot/pivot-header-title.d.ts +5 -0
  236. package/es/table-components/pivot/pivot-header-title.js +6 -0
  237. package/es/table-components/pivot/pivot-header-title.js.map +1 -0
  238. package/es/table-components/pivot/pivot-indicator.d.ts +4 -0
  239. package/es/table-components/pivot/pivot-indicator.js +4 -0
  240. package/es/table-components/pivot/pivot-indicator.js.map +1 -0
  241. package/es/tables/base-table.d.ts +23 -0
  242. package/es/tables/base-table.js +178 -0
  243. package/es/tables/base-table.js.map +1 -0
  244. package/es/tables/index.d.ts +6 -0
  245. package/es/tables/index.js +12 -0
  246. package/es/tables/index.js.map +1 -0
  247. package/es/tables/list-table-simple.d.ts +8 -0
  248. package/es/tables/list-table-simple.js +9 -0
  249. package/es/tables/list-table-simple.js.map +1 -0
  250. package/es/tables/list-table.d.ts +8 -0
  251. package/es/tables/list-table.js +9 -0
  252. package/es/tables/list-table.js.map +1 -0
  253. package/es/tables/pivot-chart.d.ts +13 -0
  254. package/es/tables/pivot-chart.js +15 -0
  255. package/es/tables/pivot-chart.js.map +1 -0
  256. package/es/tables/pivot-table-simple.d.ts +8 -0
  257. package/es/tables/pivot-table-simple.js +9 -0
  258. package/es/tables/pivot-table-simple.js.map +1 -0
  259. package/es/tables/pivot-table.d.ts +8 -0
  260. package/es/tables/pivot-table.js +9 -0
  261. package/es/tables/pivot-table.js.map +1 -0
  262. package/es/util.d.ts +8 -0
  263. package/es/util.js +35 -0
  264. package/es/util.js.map +1 -0
  265. package/es/vtable.d.ts +1 -0
  266. package/es/vtable.js +2 -0
  267. package/es/vtable.js.map +1 -0
  268. package/package.json +104 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/component/title.tsx"],"names":[],"mappings":";;;AAEA,sDAAoD;AAIvC,QAAA,KAAK,GAAG,IAAA,gCAAe,EAAa,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC","file":"title.js","sourcesContent":["import type { TYPES } from 'k-vtable';\nimport type { BaseComponentProps } from '../base-component';\nimport { createComponent } from '../base-component';\n\nexport type TitleProps = TYPES.ITitle & BaseComponentProps;\n\nexport const Title = createComponent<TitleProps>('Title', 'title', undefined, true);\n"]}
@@ -0,0 +1,7 @@
1
+ import type { BaseComponentProps } from '../base-component';
2
+ export type TooltipProps = {
3
+ renderMode?: 'html';
4
+ isShowOverflowTextTooltip?: boolean;
5
+ confine?: boolean;
6
+ } & BaseComponentProps;
7
+ export declare const Tooltip: import("react").FC<TooltipProps>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.Tooltip = void 0;
6
+
7
+ const base_component_1 = require("../base-component");
8
+
9
+ exports.Tooltip = (0, base_component_1.createComponent)("Tooltip", "tooltip", void 0, !0);
10
+ //# sourceMappingURL=tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/component/tooltip.tsx"],"names":[],"mappings":";;;AACA,sDAAoD;AAWvC,QAAA,OAAO,GAAG,IAAA,gCAAe,EAAe,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC","file":"tooltip.js","sourcesContent":["import type { BaseComponentProps } from '../base-component';\nimport { createComponent } from '../base-component';\n\nexport type TooltipProps = {\n /** html目前实现较完整 先默认html渲染方式 */\n renderMode?: 'html'; // 目前暂不支持canvas方案\n /** 代替原来hover:isShowTooltip配置 暂时需要将renderMode配置为html才能显示,canvas的还未开发*/\n isShowOverflowTextTooltip?: boolean;\n /** 是否将 tooltip 框限制在画布区域内,默认开启。针对renderMode:\"html\"有效 */\n confine?: boolean;\n} & BaseComponentProps;\n\nexport const Tooltip = createComponent<TooltipProps>('Tooltip', 'tooltip', undefined, true);\n"]}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { CustomRenderFunctionArg } from 'k-vtable/es/ts-types';
3
+ type CustomLayoutProps = {
4
+ componentId: string;
5
+ };
6
+ export type CustomLayoutFunctionArg = Partial<CustomRenderFunctionArg> & {
7
+ role?: 'custom-layout' | 'header-custom-layout';
8
+ renderDefault?: boolean;
9
+ };
10
+ export declare const CustomLayout: React.FC<CustomLayoutProps>;
11
+ export {};
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
4
+ void 0 === k2 && (k2 = k);
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
7
+ enumerable: !0,
8
+ get: function() {
9
+ return m[k];
10
+ }
11
+ }), Object.defineProperty(o, k2, desc);
12
+ } : function(o, m, k, k2) {
13
+ void 0 === k2 && (k2 = k), o[k2] = m[k];
14
+ }), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
15
+ Object.defineProperty(o, "default", {
16
+ enumerable: !0,
17
+ value: v
18
+ });
19
+ } : function(o, v) {
20
+ o.default = v;
21
+ }), __importStar = this && this.__importStar || function(mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
25
+ return __setModuleDefault(result, mod), result;
26
+ }, __importDefault = this && this.__importDefault || function(mod) {
27
+ return mod && mod.__esModule ? mod : {
28
+ default: mod
29
+ };
30
+ };
31
+
32
+ Object.defineProperty(exports, "__esModule", {
33
+ value: !0
34
+ }), exports.CustomLayout = void 0;
35
+
36
+ const react_1 = __importStar(require("react")), table_1 = __importDefault(require("../../context/table")), vrender_1 = require("k-vtable/es/vrender"), reconciler_1 = require("./reconciler"), constants_1 = require("react-reconciler/constants"), CustomLayout = (props, ref) => {
37
+ const {componentId: componentId, children: children} = props;
38
+ if (!(0, react_1.isValidElement)(children)) return null;
39
+ const context = (0, react_1.useContext)(table_1.default), {table: table} = context, isHeaderCustomLayout = "header-custom-layout" === children.props.role, container = (0,
40
+ react_1.useRef)(new Map), createGraphic = (0, react_1.useCallback)((args => {
41
+ var _a, _b;
42
+ 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" : ""}`;
43
+ let group;
44
+ if (container.current.has(key)) {
45
+ const currentContainer = container.current.get(key);
46
+ reconcilorUpdateContainer(children, currentContainer, args), group = currentContainer.containerInfo;
47
+ } else {
48
+ group = new vrender_1.Group({});
49
+ const currentContainer = reconciler_1.reconcilor.createContainer(group, constants_1.LegacyRoot, null, null, null, "custom", null, null);
50
+ container.current.set(key, currentContainer), reconcilorUpdateContainer(children, currentContainer, args);
51
+ }
52
+ return {
53
+ rootContainer: group,
54
+ renderDefault: !!children.props.renderDefault
55
+ };
56
+ }), [ children ]), removeContainer = (0, react_1.useCallback)(((col, row) => {
57
+ const key = `${col}-${row}`;
58
+ if (container.current.has(key)) {
59
+ const currentContainer = container.current.get(key);
60
+ reconciler_1.reconcilor.updateContainer(null, currentContainer, null), currentContainer.containerInfo.delete(),
61
+ container.current.delete(key);
62
+ }
63
+ }), []), removeAllContainer = (0, react_1.useCallback)((() => {
64
+ container.current.forEach(((value, key) => {
65
+ const currentContainer = value;
66
+ reconciler_1.reconcilor.updateContainer(null, currentContainer, null), currentContainer.containerInfo.delete();
67
+ })), container.current.clear();
68
+ }), []);
69
+ return (0, react_1.useLayoutEffect)((() => () => {}), []), (0, react_1.useLayoutEffect)((() => {
70
+ var _a, _b, _c, _d, _e, _f;
71
+ null == table || table.checkReactCustomLayout(), null === (_a = null == table ? void 0 : table.reactCustomLayout) || void 0 === _a || _a.setReactRemoveAllGraphic(componentId, removeAllContainer, isHeaderCustomLayout),
72
+ table && !(null === (_b = table.reactCustomLayout) || void 0 === _b ? void 0 : _b.hasReactCreateGraphic(componentId, isHeaderCustomLayout)) ? (null === (_c = table.reactCustomLayout) || void 0 === _c || _c.setReactCreateGraphic(componentId, createGraphic, isHeaderCustomLayout),
73
+ null === (_d = table.reactCustomLayout) || void 0 === _d || _d.setReactRemoveGraphic(componentId, removeContainer, isHeaderCustomLayout),
74
+ null === (_e = table.reactCustomLayout) || void 0 === _e || _e.updateCustomCell(componentId, isHeaderCustomLayout)) : table && (null === (_f = table.reactCustomLayout) || void 0 === _f || _f.setReactCreateGraphic(componentId, createGraphic, isHeaderCustomLayout),
75
+ container.current.forEach(((value, key) => {
76
+ const [col, row] = key.split("-").map(Number), {width: width, height: height} = getCellRect(col, row, table), currentContainer = value, args = {
77
+ col: col,
78
+ row: row,
79
+ dataValue: table.getCellOriginValue(col, row),
80
+ value: table.getCellValue(col, row) || "",
81
+ rect: {
82
+ left: 0,
83
+ top: 0,
84
+ right: width,
85
+ bottom: height,
86
+ width: width,
87
+ height: height
88
+ },
89
+ table: table
90
+ };
91
+ currentContainer.containerInfo;
92
+ reconcilorUpdateContainer(children, currentContainer, args), table.scenegraph.updateNextFrame();
93
+ })));
94
+ })), null;
95
+ };
96
+
97
+ function reconcilorUpdateContainer(children, currentContainer, args) {
98
+ reconciler_1.reconcilor.updateContainer(react_1.default.cloneElement(children, Object.assign({}, args)), currentContainer, null);
99
+ }
100
+
101
+ function getCellRect(col, row, table) {
102
+ const range = table.getCellRange(col, row);
103
+ return table.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row);
104
+ }
105
+
106
+ //# sourceMappingURL=custom-layout.js.map
107
+ exports.CustomLayout = CustomLayout;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/custom-layout.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+CAAgG;AAChG,gEAAmD;AACnD,iDAA4C;AAG5C,6CAA0C;AAC1C,0DAAwD;AASjD,MAAM,YAAY,G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,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 'k-vtable/es/vrender';\nimport type { ICustomLayoutFuc, CustomRenderFunctionArg } from 'k-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"]}
@@ -0,0 +1,19 @@
1
+ import type { ReactElement, ReactNode, Ref, JSXElementConstructor } from 'react';
2
+ import type { IGraphic, IGroupGraphicAttribute, ITextGraphicAttribute, IEventParamsType, IArcGraphicAttribute, ICircleGraphicAttribute, IImageGraphicAttribute, ILineGraphicAttribute, IPathGraphicAttribute, IRectGraphicAttribute, ISymbolGraphicAttribute, IRichTextGraphicAttribute, IPolygonGraphicAttribute } from 'k-vtable/es/vrender';
3
+ type GraphicProps<IGraphicGraphicAttribute> = {
4
+ attribute: IGraphicGraphicAttribute;
5
+ ref?: Ref<IGraphic>;
6
+ children?: ReactNode;
7
+ } & IEventParamsType;
8
+ export declare const Group: (props: GraphicProps<IGroupGraphicAttribute>) => ReactElement<GraphicProps<IGroupGraphicAttribute>, JSXElementConstructor<GraphicProps<IGroupGraphicAttribute>>>;
9
+ export declare const Text: (props: GraphicProps<ITextGraphicAttribute>) => ReactElement<GraphicProps<ITextGraphicAttribute>, JSXElementConstructor<GraphicProps<ITextGraphicAttribute>>>;
10
+ export declare const Arc: (props: GraphicProps<IArcGraphicAttribute>) => ReactElement<GraphicProps<IArcGraphicAttribute>, JSXElementConstructor<GraphicProps<IArcGraphicAttribute>>>;
11
+ export declare const Circle: (props: GraphicProps<ICircleGraphicAttribute>) => ReactElement<GraphicProps<ICircleGraphicAttribute>, JSXElementConstructor<GraphicProps<ICircleGraphicAttribute>>>;
12
+ export declare const Image: (props: GraphicProps<IImageGraphicAttribute>) => ReactElement<GraphicProps<IImageGraphicAttribute>, JSXElementConstructor<GraphicProps<IImageGraphicAttribute>>>;
13
+ export declare const Line: (props: GraphicProps<ILineGraphicAttribute>) => ReactElement<GraphicProps<ILineGraphicAttribute>, JSXElementConstructor<GraphicProps<ILineGraphicAttribute>>>;
14
+ export declare const Path: (props: GraphicProps<IPathGraphicAttribute>) => ReactElement<GraphicProps<IPathGraphicAttribute>, JSXElementConstructor<GraphicProps<IPathGraphicAttribute>>>;
15
+ export declare const Rect: (props: GraphicProps<IRectGraphicAttribute>) => ReactElement<GraphicProps<IRectGraphicAttribute>, JSXElementConstructor<GraphicProps<IRectGraphicAttribute>>>;
16
+ export declare const Symbol: (props: GraphicProps<ISymbolGraphicAttribute>) => ReactElement<GraphicProps<ISymbolGraphicAttribute>, JSXElementConstructor<GraphicProps<ISymbolGraphicAttribute>>>;
17
+ export declare const RichText: (props: GraphicProps<IRichTextGraphicAttribute>) => ReactElement<GraphicProps<IRichTextGraphicAttribute>, JSXElementConstructor<GraphicProps<IRichTextGraphicAttribute>>>;
18
+ export declare const Polygon: (props: GraphicProps<IPolygonGraphicAttribute>) => ReactElement<GraphicProps<IPolygonGraphicAttribute>, JSXElementConstructor<GraphicProps<IPolygonGraphicAttribute>>>;
19
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.Polygon = exports.RichText = exports.Symbol = exports.Rect = exports.Path = exports.Line = exports.Image = exports.Circle = exports.Arc = exports.Text = exports.Group = void 0,
6
+ exports.Group = "group", exports.Text = "text", exports.Arc = "arc", exports.Circle = "circle",
7
+ exports.Image = "image", exports.Line = "line", exports.Path = "path", exports.Rect = "rect",
8
+ exports.Symbol = "symbol", exports.RichText = "richtext", exports.Polygon = "polygon";
9
+ //# sourceMappingURL=graphic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/graphic.ts"],"names":[],"mappings":";;;AA2Ba,QAAA,KAAK,GAGhB,OAAc,CAAC;AAEJ,QAAA,IAAI,GAGf,MAAa,CAAC;AAEH,QAAA,GAAG,GAGd,KAAY,CAAC;AAEF,QAAA,MAAM,GAGjB,QAAe,CAAC;AAEL,QAAA,KAAK,GAGhB,OAAc,CAAC;AAEJ,QAAA,IAAI,GAGf,MAAa,CAAC;AAEH,QAAA,IAAI,GAGf,MAAa,CAAC;AAEH,QAAA,IAAI,GAGf,MAAa,CAAC;AAEH,QAAA,MAAM,GAGjB,QAAe,CAAC;AAEL,QAAA,QAAQ,GAKjB,UAAiB,CAAC;AAET,QAAA,OAAO,GAKhB,SAAgB,CAAC","file":"graphic.js","sourcesContent":["// export const Group = 'group';\n// export const Rect = 'rect';\n// export const Text = 'text';\n\nimport type { ReactElement, ReactNode, Ref, JSXElementConstructor } from 'react';\nimport type {\n IGraphic,\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n IEventParamsType,\n IArcGraphicAttribute,\n ICircleGraphicAttribute,\n IImageGraphicAttribute,\n ILineGraphicAttribute,\n IPathGraphicAttribute,\n IRectGraphicAttribute,\n ISymbolGraphicAttribute,\n IRichTextGraphicAttribute,\n IPolygonGraphicAttribute\n} from 'k-vtable/es/vrender';\n\ntype GraphicProps<IGraphicGraphicAttribute> = {\n attribute: IGraphicGraphicAttribute;\n ref?: Ref<IGraphic>;\n children?: ReactNode;\n} & IEventParamsType;\n\nexport const Group: (\n props: GraphicProps<IGroupGraphicAttribute>\n) => ReactElement<GraphicProps<IGroupGraphicAttribute>, JSXElementConstructor<GraphicProps<IGroupGraphicAttribute>>> =\n 'group' as any;\n\nexport const Text: (\n props: GraphicProps<ITextGraphicAttribute>\n) => ReactElement<GraphicProps<ITextGraphicAttribute>, JSXElementConstructor<GraphicProps<ITextGraphicAttribute>>> =\n 'text' as any;\n\nexport const Arc: (\n props: GraphicProps<IArcGraphicAttribute>\n) => ReactElement<GraphicProps<IArcGraphicAttribute>, JSXElementConstructor<GraphicProps<IArcGraphicAttribute>>> =\n 'arc' as any;\n\nexport const Circle: (\n props: GraphicProps<ICircleGraphicAttribute>\n) => ReactElement<GraphicProps<ICircleGraphicAttribute>, JSXElementConstructor<GraphicProps<ICircleGraphicAttribute>>> =\n 'circle' as any;\n\nexport const Image: (\n props: GraphicProps<IImageGraphicAttribute>\n) => ReactElement<GraphicProps<IImageGraphicAttribute>, JSXElementConstructor<GraphicProps<IImageGraphicAttribute>>> =\n 'image' as any;\n\nexport const Line: (\n props: GraphicProps<ILineGraphicAttribute>\n) => ReactElement<GraphicProps<ILineGraphicAttribute>, JSXElementConstructor<GraphicProps<ILineGraphicAttribute>>> =\n 'line' as any;\n\nexport const Path: (\n props: GraphicProps<IPathGraphicAttribute>\n) => ReactElement<GraphicProps<IPathGraphicAttribute>, JSXElementConstructor<GraphicProps<IPathGraphicAttribute>>> =\n 'path' as any;\n\nexport const Rect: (\n props: GraphicProps<IRectGraphicAttribute>\n) => ReactElement<GraphicProps<IRectGraphicAttribute>, JSXElementConstructor<GraphicProps<IRectGraphicAttribute>>> =\n 'rect' as any;\n\nexport const Symbol: (\n props: GraphicProps<ISymbolGraphicAttribute>\n) => ReactElement<GraphicProps<ISymbolGraphicAttribute>, JSXElementConstructor<GraphicProps<ISymbolGraphicAttribute>>> =\n 'symbol' as any;\n\nexport const RichText: (\n props: GraphicProps<IRichTextGraphicAttribute>\n) => ReactElement<\n GraphicProps<IRichTextGraphicAttribute>,\n JSXElementConstructor<GraphicProps<IRichTextGraphicAttribute>>\n> = 'richtext' as any;\n\nexport const Polygon: (\n props: GraphicProps<IPolygonGraphicAttribute>\n) => ReactElement<\n GraphicProps<IPolygonGraphicAttribute>,\n JSXElementConstructor<GraphicProps<IPolygonGraphicAttribute>>\n> = 'polygon' as any;\n"]}
@@ -0,0 +1,2 @@
1
+ import ReactReconciler from 'react-reconciler';
2
+ export declare const reconcilor: ReactReconciler.Reconciler<Graphic, any, any, Graphic, Graphic>;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ var __importDefault = this && this.__importDefault || function(mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ default: mod
6
+ };
7
+ };
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: !0
11
+ }), exports.reconcilor = void 0;
12
+
13
+ const vrender_1 = require("k-vtable/es/vrender"), vutils_1 = require("@visactor/vutils"), react_1 = __importDefault(require("react")), react_reconciler_1 = __importDefault(require("react-reconciler")), constants_js_1 = require("react-reconciler/constants.js"), component_creater_1 = require("../../components/vrender-components/component-creater");
14
+
15
+ function createGraphic(type, props) {
16
+ const component = (0, component_creater_1.createVRenderComponent)(type, props);
17
+ if (component) return component;
18
+ if (!vrender_1.application.graphicService.creator[type]) return;
19
+ return vrender_1.application.graphicService.creator[type](props.attribute);
20
+ }
21
+
22
+ function isEventProp(key, props) {
23
+ return key.startsWith("on") && (0, vutils_1.isFunction)(props[key]);
24
+ }
25
+
26
+ function bindEventsToGraphic(graphic, props) {
27
+ for (const key in props) isEventProp(key, props) && vrender_1.REACT_TO_CANOPUS_EVENTS[key] && graphic.addEventListener(vrender_1.REACT_TO_CANOPUS_EVENTS[key], props[key]);
28
+ }
29
+
30
+ function updateGraphicProps(graphic, newProps, oldProps) {
31
+ var _a;
32
+ for (const propKey in oldProps) isEventProp(propKey, oldProps) && oldProps[propKey] !== newProps[propKey] && graphic.removeEventListener(vrender_1.REACT_TO_CANOPUS_EVENTS[propKey], oldProps[propKey]);
33
+ for (const propKey in newProps) isEventProp(propKey, newProps) && oldProps[propKey] !== newProps[propKey] && graphic.addEventListener(vrender_1.REACT_TO_CANOPUS_EVENTS[propKey], newProps[propKey]);
34
+ const attribute = null !== (_a = newProps.attribute) && void 0 !== _a ? _a : (0,
35
+ vutils_1.merge)({}, newProps);
36
+ graphic.initAttributes(attribute), "image" === graphic.type && graphic.loadImage(attribute.image);
37
+ }
38
+
39
+ //# sourceMappingURL=reconciler.js.map
40
+ exports.reconcilor = (0, react_reconciler_1.default)({
41
+ supportsMutation: !0,
42
+ supportsPersistence: !1,
43
+ createInstance: (type, props, instance) => {
44
+ const graphic = createGraphic(type, props);
45
+ if (graphic) return bindEventsToGraphic(graphic, props), graphic;
46
+ },
47
+ createTextInstance: (text, instance) => {},
48
+ appendInitialChild: (parentInstance, childInstance) => {
49
+ parentInstance.add(childInstance);
50
+ },
51
+ finalizeInitialChildren: () => !1,
52
+ prepareUpdate: () => !0,
53
+ shouldSetTextContent: () => !1,
54
+ getRootHostContext: () => null,
55
+ getChildHostContext: () => null,
56
+ getPublicInstance: instance => instance,
57
+ prepareForCommit: () => null,
58
+ resetAfterCommit: () => {},
59
+ preparePortalMount: () => null,
60
+ scheduleTimeout: setTimeout,
61
+ cancelTimeout: clearTimeout,
62
+ noTimeout: -1,
63
+ isPrimaryRenderer: !1,
64
+ getCurrentEventPriority: () => constants_js_1.DefaultEventPriority,
65
+ getInstanceFromNode: node => null,
66
+ beforeActiveInstanceBlur: () => {},
67
+ afterActiveInstanceBlur: () => {},
68
+ prepareScopeUpdate: () => {},
69
+ getInstanceFromScope: () => {},
70
+ detachDeletedInstance: () => {},
71
+ supportsHydration: !1,
72
+ appendChild: (parentInstance, child) => {
73
+ parentInstance.add(child);
74
+ },
75
+ appendChildToContainer: (container, child) => {
76
+ container.add(child);
77
+ },
78
+ insertBefore: (parentInstance, child, beforeChild) => {
79
+ parentInstance.insertBefore(child, beforeChild);
80
+ },
81
+ insertInContainerBefore: (parentInstance, child, beforeChild) => {
82
+ parentInstance.insertBefore(child, beforeChild);
83
+ },
84
+ removeChild: (parentInstance, child) => {
85
+ child.delete();
86
+ },
87
+ removeChildFromContainer: (parentInstance, child) => {
88
+ child.delete();
89
+ },
90
+ commitUpdate: (instance, updatePayload, type, oldProps, newProps) => {
91
+ updateGraphicProps(instance, newProps, oldProps);
92
+ },
93
+ hideInstance: instance => {
94
+ instance.setAttribute("visible", !1);
95
+ },
96
+ unhideInstance: (instance, props) => {
97
+ instance.setAttribute("visible", !0);
98
+ },
99
+ clearContainer: container => {
100
+ container.removeAllChild();
101
+ },
102
+ commitTextUpdate: (textInstance, oldText, newText) => {}
103
+ }), exports.reconcilor.injectIntoDevTools({
104
+ bundleType: 0,
105
+ version: react_1.default.version,
106
+ rendererPackageName: "react-vtable"
107
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/reconciler.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAgF;AAEhF,6CAAqD;AACrD,kDAA0B;AAC1B,wEAA+C;AAC/C,gEAAqE;AACrE,6FAA+F;AAIlF,QAAA,UAAU,GAAG,IAAA,0BAAe,EAAC;IACxC,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,KAAK;IAE1B,cAAc,EAAE,CAAC,IAAY,EAAE,KAAU,EAAE,QAAQ,EAAE,EAAE;QACrD,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3C,IAAI,OAAO,EAAE;YACX,mBAAmB,CAAC,OAAmB,EAAE,KAAK,CAAC,CAAC;SACjD;aAAM;YACL,OAAO,SAAS,CAAC;SAGlB;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,kBAAkB,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;QAKrC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,kBAAkB,EAAE,CAAC,cAAwB,EAAE,aAAuB,EAAE,EAAE;QACxE,cAAc,CAAC,GAAG,CAAC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AM,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,CACtB,iCAAuB,CAAC,OAA+C,CAAC,EACxE,QAAQ,CAAC,OAAO,CAAC,CAClB,CAAC;SACH;KACF;IAED,MAAM,SAAS,GAAG,MAAA,QAAQ,CAAC,SAAS,mCAAI,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5D,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAClC,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE;QAC5B,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACpC;AACH,CAAC","file":"reconciler.js","sourcesContent":["import { application, REACT_TO_CANOPUS_EVENTS, Tag } from 'k-vtable/es/vrender';\nimport type { Graphic, IGraphic, IGraphicCreator } from 'k-vtable/es/vrender';\nimport { isFunction, merge } from '@visactor/vutils';\nimport React from 'react';\nimport ReactReconciler from 'react-reconciler';\nimport { DefaultEventPriority } from 'react-reconciler/constants.js';\nimport { createVRenderComponent } from '../../components/vrender-components/component-creater';\n\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 as IGraphic, 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: \"production\" !== 'production' ? 1 : 0,\n version: React.version,\n rendererPackageName: 'react-vtable'\n});\n\nfunction createGraphic(type: string, props: any) {\n const component = createVRenderComponent(type, props);\n if (component) {\n return component;\n }\n if (!application.graphicService.creator[type as keyof IGraphicCreator]) {\n return undefined;\n }\n const graphic = application.graphicService.creator[type as keyof IGraphicCreator]((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: IGraphic, props: any) {\n for (const key in props) {\n if (isEventProp(key, props) && REACT_TO_CANOPUS_EVENTS[key as keyof typeof REACT_TO_CANOPUS_EVENTS]) {\n graphic.addEventListener(REACT_TO_CANOPUS_EVENTS[key as keyof typeof REACT_TO_CANOPUS_EVENTS], props[key]);\n }\n }\n}\n\nfunction updateGraphicProps(graphic: IGraphic, 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(\n REACT_TO_CANOPUS_EVENTS[propKey as keyof typeof REACT_TO_CANOPUS_EVENTS],\n oldProps[propKey]\n );\n }\n }\n for (const propKey in newProps) {\n if (isEventProp(propKey, newProps) && oldProps[propKey] !== newProps[propKey]) {\n graphic.addEventListener(\n REACT_TO_CANOPUS_EVENTS[propKey as keyof typeof REACT_TO_CANOPUS_EVENTS],\n newProps[propKey]\n );\n }\n }\n // update all attribute\n const attribute = newProps.attribute ?? merge({}, newProps);\n graphic.initAttributes(attribute);\n if (graphic.type === 'image') {\n graphic.loadImage(attribute.image);\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { CreateDOMParamsType, IGraphic } from 'k-vtable/es/vrender';
2
+ export type CreateDOMParamsTypeForVTable = CreateDOMParamsType & {
3
+ graphic: IGraphic;
4
+ style?: Record<string, any>;
5
+ };
6
+ export declare const reactEnvModule: any;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.reactEnvModule = void 0;
6
+
7
+ const k_vtable_1 = require("k-vtable"), vrender_1 = require("k-vtable/es/vrender"), vutils_1 = require("@visactor/vutils");
8
+
9
+ exports.reactEnvModule = new vrender_1.ContainerModule(((bind, unbind, isBound, rebind) => {
10
+ bind(VTableBrowserEnvContribution).toSelf().inSingletonScope(), isBound(vrender_1.EnvContribution) ? rebind(vrender_1.EnvContribution).toService(VTableBrowserEnvContribution) : bind(vrender_1.EnvContribution).toService(VTableBrowserEnvContribution);
11
+ }));
12
+
13
+ class VTableBrowserEnvContribution extends vrender_1.BrowserEnvContribution {
14
+ updateDom(dom, params) {
15
+ var _a, _b;
16
+ const tableDiv = dom.parentElement;
17
+ if (tableDiv && params.graphic) {
18
+ const top = parseInt(params.style.top, 10), left = parseInt(params.style.left, 10);
19
+ let domWidth, domHeight;
20
+ if (dom.style.display = "none") {
21
+ const cellGroup = (0, k_vtable_1.getTargetCell)(params.graphic);
22
+ domWidth = null !== (_a = cellGroup.attribute.width) && void 0 !== _a ? _a : 1,
23
+ domHeight = null !== (_b = cellGroup.attribute.height) && void 0 !== _b ? _b : 1;
24
+ } else domWidth = dom.offsetWidth, domHeight = dom.offsetHeight;
25
+ if (top + domHeight < 0 || left + domWidth < 0 || top > tableDiv.offsetHeight || left > tableDiv.offsetWidth) return dom.style.display = "none",
26
+ !1;
27
+ }
28
+ const {width: width, height: height, style: style} = params;
29
+ return style && ((0, vutils_1.isString)(style) ? dom.setAttribute("style", style) : Object.keys(style).forEach((k => {
30
+ dom.style[k] = style[k];
31
+ }))), null != width && (dom.style.width = `${width}px`), null != height && (dom.style.height = `${height}px`),
32
+ !0;
33
+ }
34
+ }
35
+ //# sourceMappingURL=vtable-browser-env-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/vtable-browser-env-contribution.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AAEzC,iDAA+F;AAC/F,6CAA4C;AAO/B,QAAA,cAAc,GAAG,IAAI,yBAAe,CAAC,CAAC,IAAI,E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,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,CAAC,YAAY,IAAI,IAAI,GAAG,QAAQ,CAAC,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,IAAA,iBAAQ,EAAC,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,CAAM,EAAE,EAAE;oBACpC,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 } from 'k-vtable';\nimport type { CreateDOMParamsType, IGraphic } from 'k-vtable/es/vrender';\nimport { ContainerModule, EnvContribution, BrowserEnvContribution } from 'k-vtable/es/vrender';\nimport { isString } from '@visactor/vutils';\n\nexport type CreateDOMParamsTypeForVTable = CreateDOMParamsType & {\n graphic: IGraphic;\n style?: Record<string, any>;\n};\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: CreateDOMParamsTypeForVTable): boolean {\n const tableDiv = dom.parentElement;\n if (tableDiv && params.graphic) {\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: any) => {\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"]}
@@ -0,0 +1,21 @@
1
+ import type { CommonDomOptions, CreateDOMParamsType, IGraphic, IStage, SimpleDomStyleOptions } from 'k-vtable/es/vrender';
2
+ import { ReactAttributePlugin } from 'k-vtable/es/vrender';
3
+ export declare class VTableReactAttributePlugin extends ReactAttributePlugin {
4
+ htmlMap: Record<string, {
5
+ root?: any;
6
+ unmount?: () => void;
7
+ wrapContainer: HTMLElement;
8
+ nativeContainer: HTMLElement;
9
+ container: string | HTMLElement | null;
10
+ renderId: number;
11
+ graphic: IGraphic;
12
+ }>;
13
+ removeElement(id: string): void;
14
+ renderGraphicHTML(graphic: IGraphic): void;
15
+ getWrapContainer(stage: IStage, userContainer?: string | HTMLElement | null, domParams?: CreateDOMParamsType): {
16
+ wrapContainer: any;
17
+ nativeContainer: any;
18
+ };
19
+ updateStyleOfWrapContainer(graphic: IGraphic, stage: IStage, wrapContainer: HTMLElement, nativeContainer: HTMLElement, options: SimpleDomStyleOptions & CommonDomOptions): void;
20
+ protected drawHTML(): void;
21
+ }
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.VTableReactAttributePlugin = void 0;
6
+
7
+ const vrender_1 = require("k-vtable/es/vrender"), vutils_1 = require("@visactor/vutils");
8
+
9
+ class VTableReactAttributePlugin extends vrender_1.ReactAttributePlugin {
10
+ removeElement(id) {
11
+ super.removeElement(id), delete this.htmlMap[id];
12
+ }
13
+ renderGraphicHTML(graphic) {
14
+ var _a;
15
+ const {react: react} = graphic.attribute;
16
+ if (!react) return;
17
+ const stage = graphic.stage;
18
+ if (!stage) return;
19
+ const ReactDOM = stage.params.ReactDOM, {element: element} = react;
20
+ let {container: container} = react;
21
+ if (container && (container = checkFrozenContainer(graphic)), !element || !ReactDOM || !ReactDOM.createRoot && !ReactDOM.render) return;
22
+ const id = (0, vutils_1.isNil)(react.id) ? `${null !== (_a = graphic.id) && void 0 !== _a ? _a : graphic._uid}_react` : react.id;
23
+ if (this.htmlMap && this.htmlMap[id] && container && container !== this.htmlMap[id].container && this.removeElement(id),
24
+ this.htmlMap && this.htmlMap[id]) ReactDOM.createRoot ? this.htmlMap[id].root.render(element) : ReactDOM.render(element, this.htmlMap[id].wrapContainer); else {
25
+ const {wrapContainer: wrapContainer, nativeContainer: nativeContainer} = this.getWrapContainer(stage, container);
26
+ if (wrapContainer) if (this.htmlMap || (this.htmlMap = {}), ReactDOM.createRoot) {
27
+ const root = ReactDOM.createRoot(wrapContainer);
28
+ root.render(element), this.htmlMap[id] = {
29
+ root: root,
30
+ wrapContainer: wrapContainer,
31
+ nativeContainer: nativeContainer,
32
+ container: container,
33
+ renderId: this.renderId,
34
+ graphic: graphic
35
+ };
36
+ } else ReactDOM.render(element, wrapContainer), this.htmlMap[id] = {
37
+ wrapContainer: wrapContainer,
38
+ nativeContainer: nativeContainer,
39
+ container: container,
40
+ renderId: this.renderId,
41
+ unmount: () => {
42
+ ReactDOM.unmountComponentAtNode(wrapContainer);
43
+ },
44
+ graphic: graphic
45
+ };
46
+ }
47
+ if (!this.htmlMap || !this.htmlMap[id]) return;
48
+ const {wrapContainer: wrapContainer, nativeContainer: nativeContainer} = this.htmlMap[id];
49
+ this.updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, react),
50
+ this.htmlMap[id].renderId = this.renderId;
51
+ }
52
+ getWrapContainer(stage, userContainer, domParams) {
53
+ let nativeContainer;
54
+ return nativeContainer = userContainer ? "string" == typeof userContainer ? vrender_1.application.global.getElementById(userContainer) : userContainer : stage.window.getContainer(),
55
+ {
56
+ wrapContainer: vrender_1.application.global.createDom(Object.assign({
57
+ tagName: "div",
58
+ parent: nativeContainer
59
+ }, domParams)),
60
+ nativeContainer: nativeContainer
61
+ };
62
+ }
63
+ updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, options) {
64
+ const {pointerEvents: pointerEvents, penetrateEventList: penetrateEventList = []} = options;
65
+ let calculateStyle = this.parseDefaultStyleFromGraphic(graphic);
66
+ calculateStyle.display = !1 !== graphic.attribute.visible ? "block" : "none", calculateStyle.pointerEvents = !0 === pointerEvents ? "all" : pointerEvents || "none",
67
+ "none" !== calculateStyle.pointerEvents && (this.removeWrapContainerEventListener(wrapContainer),
68
+ penetrateEventList.forEach((event => {
69
+ "wheel" === event && (wrapContainer.addEventListener("wheel", this.onWheel), wrapContainer.addEventListener("wheel", (e => {
70
+ e.preventDefault();
71
+ }), !0));
72
+ }))), wrapContainer.style.position || (wrapContainer.style.position = "absolute");
73
+ let left = 0, top = 0;
74
+ const b = graphic.globalAABBBounds;
75
+ let anchorType = options.anchorType;
76
+ if ((0, vutils_1.isNil)(anchorType) && (anchorType = "text" === graphic.type ? "position" : "boundsLeftTop"),
77
+ "boundsLeftTop" === anchorType && (anchorType = "top-left"), "position" === anchorType || b.empty()) {
78
+ const matrix = graphic.globalTransMatrix;
79
+ left = matrix.e, top = matrix.f;
80
+ } else {
81
+ const anchor = (0, vutils_1.calculateAnchorOfBounds)(b, anchorType);
82
+ left = anchor.x, top = anchor.y;
83
+ }
84
+ const containerTL = vrender_1.application.global.getElementTopLeft(nativeContainer, !1), windowTL = stage.window.getTopLeft(!1), offsetX = left + windowTL.left - containerTL.left, offsetTop = top + windowTL.top - containerTL.top;
85
+ if (calculateStyle.left = `${offsetX}px`, calculateStyle.top = `${offsetTop}px`,
86
+ "text" === graphic.type && "position" === anchorType && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), this.getTransformOfText(graphic))),
87
+ (0, vutils_1.isFunction)(options.style)) {
88
+ const userStyle = options.style({
89
+ top: offsetTop,
90
+ left: offsetX,
91
+ width: b.width(),
92
+ height: b.height()
93
+ }, graphic, wrapContainer);
94
+ userStyle && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), userStyle));
95
+ } else (0, vutils_1.isObject)(options.style) ? calculateStyle = Object.assign(Object.assign({}, calculateStyle), options.style) : (0,
96
+ vutils_1.isString)(options.style) && options.style && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), (0,
97
+ vutils_1.styleStringToObject)(options.style)));
98
+ vrender_1.application.global.updateDom(wrapContainer, {
99
+ width: options.width,
100
+ height: options.height,
101
+ style: calculateStyle,
102
+ graphic: graphic
103
+ });
104
+ }
105
+ drawHTML() {
106
+ var _a;
107
+ "browser" === (null === (_a = null === vrender_1.application || void 0 === vrender_1.application ? void 0 : vrender_1.application.global) || void 0 === _a ? void 0 : _a.env) && (this.pluginService.stage.children.sort(((a, b) => {
108
+ var _a, _b;
109
+ return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : vrender_1.DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : vrender_1.DefaultAttribute.zIndex);
110
+ })).forEach((group => {
111
+ this.renderGroupHTML(group);
112
+ })), this.clearCacheContainer());
113
+ }
114
+ }
115
+
116
+ function checkFrozenContainer(graphic) {
117
+ const targetGroup = getTargetGroup(graphic);
118
+ if (!targetGroup) return null;
119
+ const {col: col, row: row, stage: stage} = targetGroup;
120
+ let {container: container} = graphic.attribute.react;
121
+ const {table: table} = stage;
122
+ return container === table.bodyDomContainer && col < table.frozenColCount && row >= table.rowCount - table.bottomFrozenRowCount ? container = table.bottomFrozenBodyDomContainer : container === table.bodyDomContainer && col >= table.colCount - table.rightFrozenColCount && row >= table.rowCount - table.bottomFrozenRowCount ? container = table.rightFrozenBottomDomContainer : container === table.bodyDomContainer && row >= table.rowCount - table.bottomFrozenRowCount ? container = table.bottomFrozenBodyDomContainer : container === table.bodyDomContainer && col < table.frozenColCount ? container = table.frozenBodyDomContainer : container === table.bodyDomContainer && col >= table.colCount - table.rightFrozenColCount ? container = table.rightFrozenBodyDomContainer : container === table.headerDomContainer && col < table.frozenColCount ? container = table.frozenHeaderDomContainer : container === table.headerDomContainer && col >= table.colCount - table.rightFrozenColCount && (container = table.rightFrozenHeaderDomContainer),
123
+ container;
124
+ }
125
+
126
+ function getTargetGroup(target) {
127
+ for (;target && target.parent; ) {
128
+ if ("custom-container" === target.name) return target;
129
+ target = target.parent;
130
+ }
131
+ return null;
132
+ }
133
+
134
+ //# sourceMappingURL=vtable-react-attribute-plugin.js.map
135
+ exports.VTableReactAttributePlugin = VTableReactAttributePlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/vtable-react-attribute-plugin.ts"],"names":[],"mappings":";;;AASA,iDAA0F;AAC1F,6CAAuH;AAGvH,MAAa,0BAA2B,SAAQ,8BAAoB;IAalE,aAAa,CAAC,EAAU;QACtB,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAED,iBAAiB,CAAC,OAAiB;;QACjC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,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I,MAAM,CAAC,MAAM,EAAE;QAC9B,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE;YACtC,OAAO,MAAM,CAAC;SACf;QACD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;KACxB;IACD,OAAO,IAAI,CAAC;AACd,CAAC","file":"vtable-react-attribute-plugin.js","sourcesContent":["import type {\n CommonDomOptions,\n CreateDOMParamsType,\n IGraphic,\n IGroup,\n IStage,\n IText,\n SimpleDomStyleOptions\n} from 'k-vtable/es/vrender';\nimport { DefaultAttribute, ReactAttributePlugin, application } from 'k-vtable/es/vrender';\nimport { calculateAnchorOfBounds, isFunction, isNil, isObject, isString, styleStringToObject } from '@visactor/vutils';\nimport type { CreateDOMParamsTypeForVTable } from './vtable-browser-env-contribution';\n\nexport class VTableReactAttributePlugin extends ReactAttributePlugin {\n declare htmlMap: Record<\n string,\n {\n root?: any;\n unmount?: () => void;\n wrapContainer: HTMLElement;\n nativeContainer: HTMLElement;\n container: string | HTMLElement | null;\n renderId: number;\n graphic: IGraphic;\n }\n >;\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 } = react;\n let { container } = react;\n // deal with frozen container\n if (container) {\n container = checkFrozenContainer(graphic);\n }\n\n if (!(element && ReactDOM && (ReactDOM.createRoot || ReactDOM.render))) {\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 if (!this.htmlMap) {\n this.htmlMap = {};\n }\n\n if (ReactDOM.createRoot) {\n const root = ReactDOM.createRoot(wrapContainer);\n root.render(element);\n this.htmlMap[id] = { root, wrapContainer, nativeContainer, container, renderId: this.renderId, graphic };\n } else {\n ReactDOM.render(element, wrapContainer);\n\n this.htmlMap[id] = {\n wrapContainer,\n nativeContainer,\n container,\n renderId: this.renderId,\n unmount: () => {\n ReactDOM.unmountComponentAtNode(wrapContainer);\n },\n graphic\n };\n }\n }\n } else {\n // update react element\n if (ReactDOM.createRoot) {\n this.htmlMap[id].root.render(element);\n } else {\n ReactDOM.render(element, this.htmlMap[id].wrapContainer);\n }\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, penetrateEventList = [] } = 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 if (calculateStyle.pointerEvents !== 'none') {\n // 删除所有的事件\n this.removeWrapContainerEventListener(wrapContainer);\n // 监听所有的事件\n penetrateEventList.forEach(event => {\n if (event === 'wheel') {\n wrapContainer.addEventListener('wheel', this.onWheel);\n\n // hack for preventing drag touch cause page jump\n wrapContainer.addEventListener(\n 'wheel',\n e => {\n e.preventDefault();\n },\n true\n );\n }\n });\n }\n\n // 定位wrapGroup\n if (!wrapContainer.style.position) {\n wrapContainer.style.position = 'absolute';\n // nativeContainer.style.position = 'relative'; // 'relative' will cause the problem of container position\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.height,\n style: calculateStyle,\n graphic\n } as CreateDOMParamsTypeForVTable);\n }\n\n protected drawHTML() {\n if (application?.global?.env === 'browser') {\n (this.pluginService.stage as any).children // fix interactive layer problem\n .sort((a: IGraphic, b: IGraphic) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach((group: IGroup) => {\n this.renderGroupHTML(group);\n });\n\n this.clearCacheContainer();\n }\n }\n}\n\nfunction checkFrozenContainer(graphic: IGraphic) {\n const targetGroup = getTargetGroup(graphic);\n if (!targetGroup) {\n return null;\n }\n const { col, row, stage } = targetGroup;\n let { container } = graphic.attribute.react;\n const { table } = stage as any;\n // deal with react dom container\n if (\n container === table.bodyDomContainer &&\n col < table.frozenColCount &&\n row >= table.rowCount - table.bottomFrozenRowCount\n ) {\n container = table.bottomFrozenBodyDomContainer;\n } else if (\n container === table.bodyDomContainer &&\n col >= table.colCount - table.rightFrozenColCount &&\n row >= table.rowCount - table.bottomFrozenRowCount\n ) {\n container = table.rightFrozenBottomDomContainer;\n } else if (container === table.bodyDomContainer && row >= table.rowCount - table.bottomFrozenRowCount) {\n container = table.bottomFrozenBodyDomContainer;\n } else if (container === table.bodyDomContainer && col < table.frozenColCount) {\n container = table.frozenBodyDomContainer;\n } else if (container === table.bodyDomContainer && col >= table.colCount - table.rightFrozenColCount) {\n container = table.rightFrozenBodyDomContainer;\n } else if (container === table.headerDomContainer && col < table.frozenColCount) {\n container = table.frozenHeaderDomContainer;\n } else if (container === table.headerDomContainer && col >= table.colCount - table.rightFrozenColCount) {\n container = table.rightFrozenHeaderDomContainer;\n }\n\n // graphic.attribute.react.container = container;\n return container;\n}\n\nfunction getTargetGroup(target: any) {\n while (target && target.parent) {\n if (target.name === 'custom-container') {\n return target;\n }\n target = target.parent;\n }\n return null;\n}\n"]}