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,20 @@
1
+ import type { BaseComponentProps } from '../base-component';
2
+ export type EmptyTipProps = {
3
+ text?: string;
4
+ textStyle?: {
5
+ fontSize?: number;
6
+ fontFamily?: string;
7
+ fontWeight?: string | number;
8
+ fontVariant?: string;
9
+ lineHeight?: number | string;
10
+ underline?: number;
11
+ lineThrough?: number;
12
+ color?: string;
13
+ };
14
+ icon?: {
15
+ width?: number;
16
+ height?: number;
17
+ image: string;
18
+ };
19
+ } & BaseComponentProps;
20
+ export declare const EmptyTip: import("react").FC<EmptyTipProps>;
@@ -0,0 +1,4 @@
1
+ import { createComponent } from "../base-component";
2
+
3
+ export const EmptyTip = createComponent("EmptyTip", "emptyTip", void 0, !0);
4
+ //# sourceMappingURL=emptyTip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/component/emptyTip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsBpD,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAgB,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC","file":"emptyTip.js","sourcesContent":["import { createComponent } from '../base-component';\nimport type { BaseComponentProps } from '../base-component';\n\nexport type EmptyTipProps = {\n text?: string;\n textStyle?: {\n fontSize?: number;\n fontFamily?: string;\n fontWeight?: string | number;\n fontVariant?: string;\n lineHeight?: number | string;\n underline?: number;\n lineThrough?: number;\n color?: string;\n };\n icon?: {\n width?: number;\n height?: number;\n image: string;\n };\n} & BaseComponentProps;\n\nexport const EmptyTip = createComponent<EmptyTipProps>('EmptyTip', 'emptyTip', undefined, true);\n"]}
@@ -0,0 +1,10 @@
1
+ import type { BaseTable } from 'k-vtable/es/core';
2
+ import type { BaseComponentProps } from '../base-component';
3
+ import type { TYPES } from 'k-vtable';
4
+ export type MenuProps = {
5
+ renderMode?: 'canvas' | 'html';
6
+ defaultHeaderMenuItems?: TYPES.MenuListItem[];
7
+ contextMenuItems?: TYPES.MenuListItem[] | ((field: string, row: number, col: number, table?: BaseTable) => TYPES.MenuListItem[]);
8
+ dropDownMenuHighlight?: TYPES.DropDownMenuHighlightInfo[];
9
+ } & BaseComponentProps;
10
+ export declare const Menu: import("react").FC<MenuProps>;
@@ -0,0 +1,4 @@
1
+ import { createComponent } from "../base-component";
2
+
3
+ export const Menu = createComponent("Menu", "menu", void 0, !0);
4
+ //# sourceMappingURL=menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/component/menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAgBpD,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAY,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC","file":"menu.js","sourcesContent":["import type { BaseTable } from 'k-vtable/es/core';\nimport type { BaseComponentProps } from '../base-component';\nimport { createComponent } from '../base-component';\nimport type { TYPES } from 'k-vtable';\n\nexport type MenuProps = {\n /** 代替原来的option.menuType html目前实现较完整 先默认html渲染方式*/\n renderMode?: 'canvas' | 'html';\n /** 内置下拉菜单的全局设置项 目前只针对基本表格有效 会对每个表头单元格开启默认的下拉菜单功能。代替原来的option.dropDownMenu*/\n defaultHeaderMenuItems?: TYPES.MenuListItem[];\n /** 右键菜单。代替原来的option.contextmenu */\n contextMenuItems?:\n | TYPES.MenuListItem[]\n | ((field: string, row: number, col: number, table?: BaseTable) => TYPES.MenuListItem[]);\n /** 设置选中状态的菜单。代替原来的option.dropDownMenuHighlight */\n dropDownMenuHighlight?: TYPES.DropDownMenuHighlightInfo[];\n} & BaseComponentProps;\n\nexport const Menu = createComponent<MenuProps>('Menu', 'menu', undefined, true);\n"]}
@@ -0,0 +1,4 @@
1
+ import type { TYPES } from 'k-vtable';
2
+ import type { BaseComponentProps } from '../base-component';
3
+ export type TitleProps = TYPES.ITitle & BaseComponentProps;
4
+ export declare const Title: import("react").FC<any>;
@@ -0,0 +1,4 @@
1
+ import { createComponent } from "../base-component";
2
+
3
+ export const Title = createComponent("Title", "title", void 0, !0);
4
+ //# sourceMappingURL=title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/component/title.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAa,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,4 @@
1
+ import { createComponent } from "../base-component";
2
+
3
+ export const Tooltip = createComponent("Tooltip", "tooltip", void 0, !0);
4
+ //# sourceMappingURL=tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/component/tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAWpD,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAe,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,79 @@
1
+ import React, { isValidElement, useCallback, useContext, useLayoutEffect, useRef } from "react";
2
+
3
+ import RootTableContext from "../../context/table";
4
+
5
+ import { Group } from "k-vtable/es/vrender";
6
+
7
+ import { reconcilor } from "./reconciler";
8
+
9
+ import { LegacyRoot } from "react-reconciler/constants";
10
+
11
+ export const CustomLayout = (props, ref) => {
12
+ const {componentId: componentId, children: children} = props;
13
+ if (!isValidElement(children)) return null;
14
+ const context = useContext(RootTableContext), {table: table} = context, isHeaderCustomLayout = "header-custom-layout" === children.props.role, container = useRef(new Map), createGraphic = useCallback((args => {
15
+ var _a, _b;
16
+ const key = `${null !== (_a = args.originCol) && void 0 !== _a ? _a : args.col}-${null !== (_b = args.originRow) && void 0 !== _b ? _b : args.row}${args.forComputation ? "-forComputation" : ""}`;
17
+ let group;
18
+ if (container.current.has(key)) {
19
+ const currentContainer = container.current.get(key);
20
+ reconcilorUpdateContainer(children, currentContainer, args), group = currentContainer.containerInfo;
21
+ } else {
22
+ group = new Group({});
23
+ const currentContainer = reconcilor.createContainer(group, LegacyRoot, null, null, null, "custom", null, null);
24
+ container.current.set(key, currentContainer), reconcilorUpdateContainer(children, currentContainer, args);
25
+ }
26
+ return {
27
+ rootContainer: group,
28
+ renderDefault: !!children.props.renderDefault
29
+ };
30
+ }), [ children ]), removeContainer = useCallback(((col, row) => {
31
+ const key = `${col}-${row}`;
32
+ if (container.current.has(key)) {
33
+ const currentContainer = container.current.get(key);
34
+ reconcilor.updateContainer(null, currentContainer, null), currentContainer.containerInfo.delete(),
35
+ container.current.delete(key);
36
+ }
37
+ }), []), removeAllContainer = useCallback((() => {
38
+ container.current.forEach(((value, key) => {
39
+ const currentContainer = value;
40
+ reconcilor.updateContainer(null, currentContainer, null), currentContainer.containerInfo.delete();
41
+ })), container.current.clear();
42
+ }), []);
43
+ return useLayoutEffect((() => () => {}), []), useLayoutEffect((() => {
44
+ var _a, _b, _c, _d, _e, _f;
45
+ null == table || table.checkReactCustomLayout(), null === (_a = null == table ? void 0 : table.reactCustomLayout) || void 0 === _a || _a.setReactRemoveAllGraphic(componentId, removeAllContainer, isHeaderCustomLayout),
46
+ 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),
47
+ null === (_d = table.reactCustomLayout) || void 0 === _d || _d.setReactRemoveGraphic(componentId, removeContainer, isHeaderCustomLayout),
48
+ null === (_e = table.reactCustomLayout) || void 0 === _e || _e.updateCustomCell(componentId, isHeaderCustomLayout)) : table && (null === (_f = table.reactCustomLayout) || void 0 === _f || _f.setReactCreateGraphic(componentId, createGraphic, isHeaderCustomLayout),
49
+ container.current.forEach(((value, key) => {
50
+ const [col, row] = key.split("-").map(Number), {width: width, height: height} = getCellRect(col, row, table), currentContainer = value, args = {
51
+ col: col,
52
+ row: row,
53
+ dataValue: table.getCellOriginValue(col, row),
54
+ value: table.getCellValue(col, row) || "",
55
+ rect: {
56
+ left: 0,
57
+ top: 0,
58
+ right: width,
59
+ bottom: height,
60
+ width: width,
61
+ height: height
62
+ },
63
+ table: table
64
+ };
65
+ currentContainer.containerInfo;
66
+ reconcilorUpdateContainer(children, currentContainer, args), table.scenegraph.updateNextFrame();
67
+ })));
68
+ })), null;
69
+ };
70
+
71
+ function reconcilorUpdateContainer(children, currentContainer, args) {
72
+ reconcilor.updateContainer(React.cloneElement(children, Object.assign({}, args)), currentContainer, null);
73
+ }
74
+
75
+ function getCellRect(col, row, table) {
76
+ const range = table.getCellRange(col, row);
77
+ return table.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row);
78
+ }
79
+ //# sourceMappingURL=custom-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/custom-layout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AASxD,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,KAA2C,EAAE,GAAG,EAAE,EAAE;IAC5G,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACxC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;QAC7B,OAAO,IAAI,CAAC;KACb;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAE1B,MAAM,oBAAoB,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAsB,CAAC;IAG5E,MAAM,SAAS,GAAG,MAAM,CAAyB,IAAI,GAAG,EAAE,CAAC,CAAC;IAG5D,MAAM,aAAa,GAAqB,WAAW,CACjD,IAAI,CAAC,EAAE;;QACL,MAAM,GAAG,GAAG,GAAG,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,GAAG,IAAI,MAAA,IAAI,CAAC,SAAS,mCAAI,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AAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;gBAE5D,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;YACrC,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,SAAS,yBAAyB,CAAC,QAAsB,EAAE,gBAAqB,EAAE,IAAS;IACzF,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,oBAAO,IAAI,EAAG,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAUhG,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,GAAW,EAAE,KAAU;IACvD,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC;AACd,CAAC","file":"custom-layout.js","sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\nimport type { PropsWithChildren, ReactElement } from 'react';\nimport React, { isValidElement, useCallback, useContext, useLayoutEffect, useRef } from 'react';\nimport RootTableContext from '../../context/table';\nimport { Group } from '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,22 @@
1
+ export const Group = "group";
2
+
3
+ export const Text = "text";
4
+
5
+ export const Arc = "arc";
6
+
7
+ export const Circle = "circle";
8
+
9
+ export const Image = "image";
10
+
11
+ export const Line = "line";
12
+
13
+ export const Path = "path";
14
+
15
+ export const Rect = "rect";
16
+
17
+ export const Symbol = "symbol";
18
+
19
+ export const RichText = "richtext";
20
+
21
+ export const Polygon = "polygon";
22
+ //# sourceMappingURL=graphic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/graphic.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,KAAK,GAGhB,OAAc,CAAC;AAEjB,MAAM,CAAC,MAAM,IAAI,GAGf,MAAa,CAAC;AAEhB,MAAM,CAAC,MAAM,GAAG,GAGd,KAAY,CAAC;AAEf,MAAM,CAAC,MAAM,MAAM,GAGjB,QAAe,CAAC;AAElB,MAAM,CAAC,MAAM,KAAK,GAGhB,OAAc,CAAC;AAEjB,MAAM,CAAC,MAAM,IAAI,GAGf,MAAa,CAAC;AAEhB,MAAM,CAAC,MAAM,IAAI,GAGf,MAAa,CAAC;AAEhB,MAAM,CAAC,MAAM,IAAI,GAGf,MAAa,CAAC;AAEhB,MAAM,CAAC,MAAM,MAAM,GAGjB,QAAe,CAAC;AAElB,MAAM,CAAC,MAAM,QAAQ,GAKjB,UAAiB,CAAC;AAEtB,MAAM,CAAC,MAAM,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,106 @@
1
+ import { application, REACT_TO_CANOPUS_EVENTS } from "k-vtable/es/vrender";
2
+
3
+ import { isFunction, merge } 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
+ import { createVRenderComponent } from "../../components/vrender-components/component-creater";
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
+ const component = createVRenderComponent(type, props);
80
+ if (component) return component;
81
+ if (!application.graphicService.creator[type]) return;
82
+ return application.graphicService.creator[type](props.attribute);
83
+ }
84
+
85
+ function isEventProp(key, props) {
86
+ return key.startsWith("on") && isFunction(props[key]);
87
+ }
88
+
89
+ function bindEventsToGraphic(graphic, props) {
90
+ for (const key in props) isEventProp(key, props) && REACT_TO_CANOPUS_EVENTS[key] && graphic.addEventListener(REACT_TO_CANOPUS_EVENTS[key], props[key]);
91
+ }
92
+
93
+ function updateGraphicProps(graphic, newProps, oldProps) {
94
+ var _a;
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
+ const attribute = null !== (_a = newProps.attribute) && void 0 !== _a ? _a : merge({}, newProps);
98
+ graphic.initAttributes(attribute), "image" === graphic.type && graphic.loadImage(attribute.image);
99
+ }
100
+
101
+ //# sourceMappingURL=reconciler.js.map
102
+ reconcilor.injectIntoDevTools({
103
+ bundleType: 0,
104
+ version: React.version,
105
+ rendererPackageName: "react-vtable"
106
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/reconciler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAO,MAAM,qBAAqB,CAAC;AAEhF,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,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KAAK,EAAE;QACvB,IAAI,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,uBAAuB,CAAC,GAA2C,CAAC,EAAE;YACnG,OAAO,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,GAA2C,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;SAC5G;KACF;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAiB,EAAE,QAAa,EAAE,QAAa;;IAEzE,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,CACzB,uBAAuB,CAAC,OAA+C,CAAC,EACxE,QAAQ,CAAC,OAAO,CAAC,CAClB,CAAC;SACH;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,CACtB,uBAAuB,CAAC,OAA+C,CAAC,EACxE,QAAQ,CAAC,OAAO,CAAC,CAClB,CAAC;SACH;KACF;IAED,MAAM,SAAS,GAAG,MAAA,QAAQ,CAAC,SAAS,mCAAI,KAAK,CAAC,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,33 @@
1
+ import { getTargetCell } from "k-vtable";
2
+
3
+ import { ContainerModule, EnvContribution, BrowserEnvContribution } from "k-vtable/es/vrender";
4
+
5
+ import { isString } from "@visactor/vutils";
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 && params.graphic) {
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["table-components/custom/vtable-browser-env-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAO5C,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAClF,IAAI,CAAC,4BAA4B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC/D,IAAI,OAAO,CAAC,eAAe,CAAC,EAAE;QAC5B,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;KACjE;SAAM;QACL,IAAI,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;KAC/D;AACH,CAAC,CAAC,CAAC;AAEH,MAAM,4BAA6B,SAAQ,sBAAsB;IAC/D,SAAS,CAAC,GAAgB,EAAE,MAAoC;;QAC9D,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,CAAC;QACnC,IAAI,QAAQ,IAAI,MAAM,CAAC,OAAO,EAAE;YAC9B,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC3C,MAAM,IAAI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G,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,127 @@
1
+ import { DefaultAttribute, ReactAttributePlugin, application } from "k-vtable/es/vrender";
2
+
3
+ import { calculateAnchorOfBounds, isFunction, isNil, isObject, isString, styleStringToObject } from "@visactor/vutils";
4
+
5
+ export class VTableReactAttributePlugin extends ReactAttributePlugin {
6
+ removeElement(id) {
7
+ super.removeElement(id), delete this.htmlMap[id];
8
+ }
9
+ renderGraphicHTML(graphic) {
10
+ var _a;
11
+ const {react: react} = graphic.attribute;
12
+ if (!react) return;
13
+ const stage = graphic.stage;
14
+ if (!stage) return;
15
+ const ReactDOM = stage.params.ReactDOM, {element: element} = react;
16
+ let {container: container} = react;
17
+ if (container && (container = checkFrozenContainer(graphic)), !element || !ReactDOM || !ReactDOM.createRoot && !ReactDOM.render) return;
18
+ const id = isNil(react.id) ? `${null !== (_a = graphic.id) && void 0 !== _a ? _a : graphic._uid}_react` : react.id;
19
+ if (this.htmlMap && this.htmlMap[id] && container && container !== this.htmlMap[id].container && this.removeElement(id),
20
+ this.htmlMap && this.htmlMap[id]) ReactDOM.createRoot ? this.htmlMap[id].root.render(element) : ReactDOM.render(element, this.htmlMap[id].wrapContainer); else {
21
+ const {wrapContainer: wrapContainer, nativeContainer: nativeContainer} = this.getWrapContainer(stage, container);
22
+ if (wrapContainer) if (this.htmlMap || (this.htmlMap = {}), ReactDOM.createRoot) {
23
+ const root = ReactDOM.createRoot(wrapContainer);
24
+ root.render(element), this.htmlMap[id] = {
25
+ root: root,
26
+ wrapContainer: wrapContainer,
27
+ nativeContainer: nativeContainer,
28
+ container: container,
29
+ renderId: this.renderId,
30
+ graphic: graphic
31
+ };
32
+ } else ReactDOM.render(element, wrapContainer), this.htmlMap[id] = {
33
+ wrapContainer: wrapContainer,
34
+ nativeContainer: nativeContainer,
35
+ container: container,
36
+ renderId: this.renderId,
37
+ unmount: () => {
38
+ ReactDOM.unmountComponentAtNode(wrapContainer);
39
+ },
40
+ graphic: graphic
41
+ };
42
+ }
43
+ if (!this.htmlMap || !this.htmlMap[id]) return;
44
+ const {wrapContainer: wrapContainer, nativeContainer: nativeContainer} = this.htmlMap[id];
45
+ this.updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, react),
46
+ this.htmlMap[id].renderId = this.renderId;
47
+ }
48
+ getWrapContainer(stage, userContainer, domParams) {
49
+ let nativeContainer;
50
+ return nativeContainer = userContainer ? "string" == typeof userContainer ? application.global.getElementById(userContainer) : userContainer : stage.window.getContainer(),
51
+ {
52
+ wrapContainer: application.global.createDom(Object.assign({
53
+ tagName: "div",
54
+ parent: nativeContainer
55
+ }, domParams)),
56
+ nativeContainer: nativeContainer
57
+ };
58
+ }
59
+ updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, options) {
60
+ const {pointerEvents: pointerEvents, penetrateEventList: penetrateEventList = []} = options;
61
+ let calculateStyle = this.parseDefaultStyleFromGraphic(graphic);
62
+ calculateStyle.display = !1 !== graphic.attribute.visible ? "block" : "none", calculateStyle.pointerEvents = !0 === pointerEvents ? "all" : pointerEvents || "none",
63
+ "none" !== calculateStyle.pointerEvents && (this.removeWrapContainerEventListener(wrapContainer),
64
+ penetrateEventList.forEach((event => {
65
+ "wheel" === event && (wrapContainer.addEventListener("wheel", this.onWheel), wrapContainer.addEventListener("wheel", (e => {
66
+ e.preventDefault();
67
+ }), !0));
68
+ }))), wrapContainer.style.position || (wrapContainer.style.position = "absolute");
69
+ let left = 0, top = 0;
70
+ const b = graphic.globalAABBBounds;
71
+ let anchorType = options.anchorType;
72
+ if (isNil(anchorType) && (anchorType = "text" === graphic.type ? "position" : "boundsLeftTop"),
73
+ "boundsLeftTop" === anchorType && (anchorType = "top-left"), "position" === anchorType || b.empty()) {
74
+ const matrix = graphic.globalTransMatrix;
75
+ left = matrix.e, top = matrix.f;
76
+ } else {
77
+ const anchor = calculateAnchorOfBounds(b, anchorType);
78
+ left = anchor.x, top = anchor.y;
79
+ }
80
+ const containerTL = application.global.getElementTopLeft(nativeContainer, !1), windowTL = stage.window.getTopLeft(!1), offsetX = left + windowTL.left - containerTL.left, offsetTop = top + windowTL.top - containerTL.top;
81
+ if (calculateStyle.left = `${offsetX}px`, calculateStyle.top = `${offsetTop}px`,
82
+ "text" === graphic.type && "position" === anchorType && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), this.getTransformOfText(graphic))),
83
+ isFunction(options.style)) {
84
+ const userStyle = options.style({
85
+ top: offsetTop,
86
+ left: offsetX,
87
+ width: b.width(),
88
+ height: b.height()
89
+ }, graphic, wrapContainer);
90
+ userStyle && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), userStyle));
91
+ } 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)));
92
+ application.global.updateDom(wrapContainer, {
93
+ width: options.width,
94
+ height: options.height,
95
+ style: calculateStyle,
96
+ graphic: graphic
97
+ });
98
+ }
99
+ drawHTML() {
100
+ var _a;
101
+ "browser" === (null === (_a = null == application ? void 0 : application.global) || void 0 === _a ? void 0 : _a.env) && (this.pluginService.stage.children.sort(((a, b) => {
102
+ var _a, _b;
103
+ return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
104
+ })).forEach((group => {
105
+ this.renderGroupHTML(group);
106
+ })), this.clearCacheContainer());
107
+ }
108
+ }
109
+
110
+ function checkFrozenContainer(graphic) {
111
+ const targetGroup = getTargetGroup(graphic);
112
+ if (!targetGroup) return null;
113
+ const {col: col, row: row, stage: stage} = targetGroup;
114
+ let {container: container} = graphic.attribute.react;
115
+ const {table: table} = stage;
116
+ 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),
117
+ container;
118
+ }
119
+
120
+ function getTargetGroup(target) {
121
+ for (;target && target.parent; ) {
122
+ if ("custom-container" === target.name) return target;
123
+ target = target.parent;
124
+ }
125
+ return null;
126
+ }
127
+ //# sourceMappingURL=vtable-react-attribute-plugin.js.map