@visactor/vtable 0.13.4 → 0.14.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 (311) hide show
  1. package/cjs/PivotTable.d.ts +2 -1
  2. package/cjs/PivotTable.js.map +1 -1
  3. package/cjs/body-helper/style/CheckboxStyle.d.ts +8 -2
  4. package/cjs/body-helper/style/CheckboxStyle.js +17 -3
  5. package/cjs/body-helper/style/CheckboxStyle.js.map +1 -1
  6. package/cjs/components/axis/get-axis-attributes.d.ts +7 -0
  7. package/cjs/components/axis/get-axis-attributes.js +13 -17
  8. package/cjs/components/axis/get-axis-attributes.js.map +1 -1
  9. package/cjs/components/legend/continue-legend/continue-legend.js +1 -0
  10. package/cjs/components/legend/continue-legend/continue-legend.js.map +1 -1
  11. package/cjs/components/legend/discrete-legend/discrete-legend.js +1 -0
  12. package/cjs/components/legend/discrete-legend/discrete-legend.js.map +1 -1
  13. package/cjs/components/title/title.js +7 -6
  14. package/cjs/components/title/title.js.map +1 -1
  15. package/cjs/core/BaseTable.d.ts +1 -0
  16. package/cjs/core/BaseTable.js +28 -2
  17. package/cjs/core/BaseTable.js.map +1 -1
  18. package/cjs/dataset/dataset.d.ts +0 -1
  19. package/cjs/dataset/dataset.js +3 -43
  20. package/cjs/dataset/dataset.js.map +1 -1
  21. package/cjs/header-helper/header-helper.d.ts +2 -1
  22. package/cjs/header-helper/style/CheckboxStyle.d.ts +8 -2
  23. package/cjs/header-helper/style/CheckboxStyle.js +15 -1
  24. package/cjs/header-helper/style/CheckboxStyle.js.map +1 -1
  25. package/cjs/index.d.ts +1 -1
  26. package/cjs/index.js +1 -1
  27. package/cjs/index.js.map +1 -1
  28. package/cjs/layout/chart-helper/get-axis-config.js +71 -35
  29. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  30. package/cjs/layout/chart-helper/get-axis-domain.d.ts +1 -1
  31. package/cjs/layout/chart-helper/get-axis-domain.js +18 -8
  32. package/cjs/layout/chart-helper/get-axis-domain.js.map +1 -1
  33. package/cjs/layout/chart-helper/get-chart-spec.js +33 -17
  34. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  35. package/cjs/layout/chart-helper/zero-align.js.map +1 -0
  36. package/cjs/layout/pivot-header-layout.js +20 -11
  37. package/cjs/layout/pivot-header-layout.js.map +1 -1
  38. package/cjs/layout/simple-header-layout.js +2 -1
  39. package/cjs/layout/simple-header-layout.js.map +1 -1
  40. package/cjs/render/layout/arc.d.ts +10 -21
  41. package/cjs/render/layout/arc.js +7 -9
  42. package/cjs/render/layout/arc.js.map +1 -1
  43. package/cjs/render/layout/circle.d.ts +10 -17
  44. package/cjs/render/layout/circle.js +5 -6
  45. package/cjs/render/layout/circle.js.map +1 -1
  46. package/cjs/render/layout/container.d.ts +10 -48
  47. package/cjs/render/layout/container.js +15 -100
  48. package/cjs/render/layout/container.js.map +1 -1
  49. package/cjs/render/layout/group-element.d.ts +4 -24
  50. package/cjs/render/layout/group-element.js +4 -40
  51. package/cjs/render/layout/group-element.js.map +1 -1
  52. package/cjs/render/layout/group.d.ts +12 -0
  53. package/cjs/render/layout/group.js +18 -0
  54. package/cjs/render/layout/group.js.map +1 -0
  55. package/cjs/render/layout/icon.d.ts +10 -10
  56. package/cjs/render/layout/icon.js +11 -9
  57. package/cjs/render/layout/icon.js.map +1 -1
  58. package/cjs/render/layout/image.d.ts +10 -17
  59. package/cjs/render/layout/image.js +6 -7
  60. package/cjs/render/layout/image.js.map +1 -1
  61. package/cjs/render/layout/index.d.ts +2 -0
  62. package/cjs/render/layout/index.js +2 -1
  63. package/cjs/render/layout/index.js.map +1 -1
  64. package/cjs/render/layout/percent-calc.d.ts +1 -4
  65. package/cjs/render/layout/percent-calc.js.map +1 -1
  66. package/cjs/render/layout/rect.d.ts +10 -20
  67. package/cjs/render/layout/rect.js +5 -6
  68. package/cjs/render/layout/rect.js.map +1 -1
  69. package/cjs/render/layout/tag.d.ts +14 -0
  70. package/cjs/render/layout/tag.js +21 -0
  71. package/cjs/render/layout/tag.js.map +1 -0
  72. package/cjs/render/layout/text.d.ts +9 -46
  73. package/cjs/render/layout/text.js +8 -18
  74. package/cjs/render/layout/text.js.map +1 -1
  75. package/cjs/scenegraph/component/custom.d.ts +2 -2
  76. package/cjs/scenegraph/component/custom.js +14 -6
  77. package/cjs/scenegraph/component/custom.js.map +1 -1
  78. package/cjs/scenegraph/graphic/group.d.ts +6 -2
  79. package/cjs/scenegraph/graphic/group.js.map +1 -1
  80. package/cjs/scenegraph/group-creater/cell-helper.d.ts +3 -3
  81. package/cjs/scenegraph/group-creater/cell-helper.js +40 -40
  82. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  83. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js +2 -2
  84. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  85. package/cjs/scenegraph/group-creater/cell-type/checkbox-cell.js +22 -3
  86. package/cjs/scenegraph/group-creater/cell-type/checkbox-cell.js.map +1 -1
  87. package/cjs/scenegraph/group-creater/cell-type/text-cell.d.ts +2 -2
  88. package/cjs/scenegraph/group-creater/cell-type/text-cell.js +2 -2
  89. package/cjs/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
  90. package/cjs/scenegraph/group-creater/column-helper.d.ts +3 -2
  91. package/cjs/scenegraph/group-creater/column-helper.js +78 -46
  92. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  93. package/cjs/scenegraph/group-creater/progress/proxy.js +1 -1
  94. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  95. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +2 -3
  96. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  97. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +4 -5
  98. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  99. package/cjs/scenegraph/icon/icon-update.d.ts +17 -0
  100. package/cjs/scenegraph/icon/icon-update.js +165 -0
  101. package/cjs/scenegraph/icon/icon-update.js.map +1 -0
  102. package/cjs/scenegraph/layout/compute-col-width.js +22 -15
  103. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  104. package/cjs/scenegraph/layout/compute-row-height.js +49 -15
  105. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  106. package/cjs/scenegraph/layout/move-cell.js +8 -27
  107. package/cjs/scenegraph/layout/move-cell.js.map +1 -1
  108. package/cjs/scenegraph/layout/update-height.js +39 -29
  109. package/cjs/scenegraph/layout/update-height.js.map +1 -1
  110. package/cjs/scenegraph/layout/update-row.js +6 -2
  111. package/cjs/scenegraph/layout/update-row.js.map +1 -1
  112. package/cjs/scenegraph/layout/update-width.js +43 -29
  113. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  114. package/cjs/scenegraph/scenegraph.d.ts +7 -13
  115. package/cjs/scenegraph/scenegraph.js +25 -141
  116. package/cjs/scenegraph/scenegraph.js.map +1 -1
  117. package/cjs/scenegraph/stick-text/index.js +77 -38
  118. package/cjs/scenegraph/stick-text/index.js.map +1 -1
  119. package/cjs/scenegraph/utils/is-merge-cell-group.d.ts +2 -0
  120. package/cjs/scenegraph/utils/is-merge-cell-group.js +16 -0
  121. package/cjs/scenegraph/utils/is-merge-cell-group.js.map +1 -0
  122. package/cjs/scenegraph/utils/text-icon-layout.d.ts +1 -1
  123. package/cjs/scenegraph/utils/text-icon-layout.js +11 -5
  124. package/cjs/scenegraph/utils/text-icon-layout.js.map +1 -1
  125. package/cjs/state/cell-move/index.js +14 -12
  126. package/cjs/state/cell-move/index.js.map +1 -1
  127. package/cjs/state/hover/is-cell-hover.js +4 -2
  128. package/cjs/state/hover/is-cell-hover.js.map +1 -1
  129. package/cjs/state/hover/update-cell.js +10 -5
  130. package/cjs/state/hover/update-cell.js.map +1 -1
  131. package/cjs/state/state.js +1 -1
  132. package/cjs/state/state.js.map +1 -1
  133. package/cjs/themes/BRIGHT.js +2 -1
  134. package/cjs/themes/DARK.js +1 -2
  135. package/cjs/tools/calc.js +1 -1
  136. package/cjs/tools/util.js +1 -1
  137. package/cjs/tools/util.js.map +1 -1
  138. package/cjs/ts-types/base-table.d.ts +9 -1
  139. package/cjs/ts-types/base-table.js.map +1 -1
  140. package/cjs/ts-types/column/style.d.ts +4 -1
  141. package/cjs/ts-types/column/style.js.map +1 -1
  142. package/cjs/ts-types/common.d.ts +2 -0
  143. package/cjs/ts-types/common.js.map +1 -1
  144. package/cjs/ts-types/table-engine.d.ts +13 -0
  145. package/cjs/ts-types/table-engine.js.map +1 -1
  146. package/dist/vtable.js +22152 -11275
  147. package/dist/vtable.min.js +2 -2
  148. package/es/PivotTable.d.ts +2 -1
  149. package/es/PivotTable.js.map +1 -1
  150. package/es/body-helper/style/CheckboxStyle.d.ts +8 -2
  151. package/es/body-helper/style/CheckboxStyle.js +17 -3
  152. package/es/body-helper/style/CheckboxStyle.js.map +1 -1
  153. package/es/components/axis/get-axis-attributes.d.ts +7 -0
  154. package/es/components/axis/get-axis-attributes.js +1 -1
  155. package/es/components/axis/get-axis-attributes.js.map +1 -1
  156. package/es/components/legend/continue-legend/continue-legend.js +1 -0
  157. package/es/components/legend/continue-legend/continue-legend.js.map +1 -1
  158. package/es/components/legend/discrete-legend/discrete-legend.js +1 -0
  159. package/es/components/legend/discrete-legend/discrete-legend.js.map +1 -1
  160. package/es/components/title/title.js +6 -6
  161. package/es/components/title/title.js.map +1 -1
  162. package/es/core/BaseTable.d.ts +1 -0
  163. package/es/core/BaseTable.js +28 -2
  164. package/es/core/BaseTable.js.map +1 -1
  165. package/es/dataset/dataset.d.ts +0 -1
  166. package/es/dataset/dataset.js +2 -46
  167. package/es/dataset/dataset.js.map +1 -1
  168. package/es/header-helper/header-helper.d.ts +2 -1
  169. package/es/header-helper/style/CheckboxStyle.d.ts +8 -2
  170. package/es/header-helper/style/CheckboxStyle.js +15 -1
  171. package/es/header-helper/style/CheckboxStyle.js.map +1 -1
  172. package/es/index.d.ts +1 -1
  173. package/es/index.js +1 -1
  174. package/es/index.js.map +1 -1
  175. package/es/layout/chart-helper/get-axis-config.js +72 -33
  176. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  177. package/es/layout/chart-helper/get-axis-domain.d.ts +1 -1
  178. package/es/layout/chart-helper/get-axis-domain.js +20 -8
  179. package/es/layout/chart-helper/get-axis-domain.js.map +1 -1
  180. package/es/layout/chart-helper/get-chart-spec.js +33 -12
  181. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  182. package/es/layout/chart-helper/zero-align.js.map +1 -0
  183. package/es/layout/pivot-header-layout.js +20 -11
  184. package/es/layout/pivot-header-layout.js.map +1 -1
  185. package/es/layout/simple-header-layout.js +2 -1
  186. package/es/layout/simple-header-layout.js.map +1 -1
  187. package/es/render/layout/arc.d.ts +10 -21
  188. package/es/render/layout/arc.js +7 -7
  189. package/es/render/layout/arc.js.map +1 -1
  190. package/es/render/layout/circle.d.ts +10 -17
  191. package/es/render/layout/circle.js +7 -6
  192. package/es/render/layout/circle.js.map +1 -1
  193. package/es/render/layout/container.d.ts +10 -48
  194. package/es/render/layout/container.js +16 -107
  195. package/es/render/layout/container.js.map +1 -1
  196. package/es/render/layout/group-element.d.ts +4 -24
  197. package/es/render/layout/group-element.js +4 -42
  198. package/es/render/layout/group-element.js.map +1 -1
  199. package/es/render/layout/group.d.ts +12 -0
  200. package/es/render/layout/group.js +12 -0
  201. package/es/render/layout/group.js.map +1 -0
  202. package/es/render/layout/icon.d.ts +10 -10
  203. package/es/render/layout/icon.js +12 -10
  204. package/es/render/layout/icon.js.map +1 -1
  205. package/es/render/layout/image.d.ts +10 -17
  206. package/es/render/layout/image.js +8 -7
  207. package/es/render/layout/image.js.map +1 -1
  208. package/es/render/layout/index.d.ts +2 -0
  209. package/es/render/layout/index.js +4 -0
  210. package/es/render/layout/index.js.map +1 -1
  211. package/es/render/layout/percent-calc.d.ts +1 -4
  212. package/es/render/layout/percent-calc.js.map +1 -1
  213. package/es/render/layout/rect.d.ts +10 -20
  214. package/es/render/layout/rect.js +7 -6
  215. package/es/render/layout/rect.js.map +1 -1
  216. package/es/render/layout/tag.d.ts +14 -0
  217. package/es/render/layout/tag.js +15 -0
  218. package/es/render/layout/tag.js.map +1 -0
  219. package/es/render/layout/text.d.ts +9 -46
  220. package/es/render/layout/text.js +10 -18
  221. package/es/render/layout/text.js.map +1 -1
  222. package/es/scenegraph/component/custom.d.ts +2 -2
  223. package/es/scenegraph/component/custom.js +15 -7
  224. package/es/scenegraph/component/custom.js.map +1 -1
  225. package/es/scenegraph/graphic/group.d.ts +6 -2
  226. package/es/scenegraph/graphic/group.js.map +1 -1
  227. package/es/scenegraph/group-creater/cell-helper.d.ts +3 -3
  228. package/es/scenegraph/group-creater/cell-helper.js +41 -40
  229. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  230. package/es/scenegraph/group-creater/cell-type/chart-cell.js +2 -2
  231. package/es/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  232. package/es/scenegraph/group-creater/cell-type/checkbox-cell.js +22 -2
  233. package/es/scenegraph/group-creater/cell-type/checkbox-cell.js.map +1 -1
  234. package/es/scenegraph/group-creater/cell-type/text-cell.d.ts +2 -2
  235. package/es/scenegraph/group-creater/cell-type/text-cell.js +2 -2
  236. package/es/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
  237. package/es/scenegraph/group-creater/column-helper.d.ts +3 -2
  238. package/es/scenegraph/group-creater/column-helper.js +75 -44
  239. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  240. package/es/scenegraph/group-creater/progress/proxy.js +1 -1
  241. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  242. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -4
  243. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  244. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +3 -6
  245. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  246. package/es/scenegraph/icon/icon-update.d.ts +17 -0
  247. package/es/scenegraph/icon/icon-update.js +154 -0
  248. package/es/scenegraph/icon/icon-update.js.map +1 -0
  249. package/es/scenegraph/layout/compute-col-width.js +23 -14
  250. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  251. package/es/scenegraph/layout/compute-row-height.js +51 -15
  252. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  253. package/es/scenegraph/layout/move-cell.js +8 -27
  254. package/es/scenegraph/layout/move-cell.js.map +1 -1
  255. package/es/scenegraph/layout/update-height.js +41 -27
  256. package/es/scenegraph/layout/update-height.js.map +1 -1
  257. package/es/scenegraph/layout/update-row.js +6 -1
  258. package/es/scenegraph/layout/update-row.js.map +1 -1
  259. package/es/scenegraph/layout/update-width.js +45 -27
  260. package/es/scenegraph/layout/update-width.js.map +1 -1
  261. package/es/scenegraph/scenegraph.d.ts +7 -13
  262. package/es/scenegraph/scenegraph.js +25 -142
  263. package/es/scenegraph/scenegraph.js.map +1 -1
  264. package/es/scenegraph/stick-text/index.js +75 -38
  265. package/es/scenegraph/stick-text/index.js.map +1 -1
  266. package/es/scenegraph/utils/is-merge-cell-group.d.ts +2 -0
  267. package/es/scenegraph/utils/is-merge-cell-group.js +6 -0
  268. package/es/scenegraph/utils/is-merge-cell-group.js.map +1 -0
  269. package/es/scenegraph/utils/text-icon-layout.d.ts +1 -1
  270. package/es/scenegraph/utils/text-icon-layout.js +11 -5
  271. package/es/scenegraph/utils/text-icon-layout.js.map +1 -1
  272. package/es/state/cell-move/index.js +14 -12
  273. package/es/state/cell-move/index.js.map +1 -1
  274. package/es/state/hover/is-cell-hover.js +3 -1
  275. package/es/state/hover/is-cell-hover.js.map +1 -1
  276. package/es/state/hover/update-cell.js +4 -2
  277. package/es/state/hover/update-cell.js.map +1 -1
  278. package/es/state/state.js +1 -1
  279. package/es/state/state.js.map +1 -1
  280. package/es/themes/BRIGHT.js +2 -1
  281. package/es/themes/DARK.js +1 -2
  282. package/es/tools/calc.js +1 -1
  283. package/es/tools/util.js +1 -1
  284. package/es/tools/util.js.map +1 -1
  285. package/es/ts-types/base-table.d.ts +9 -1
  286. package/es/ts-types/base-table.js.map +1 -1
  287. package/es/ts-types/column/style.d.ts +4 -1
  288. package/es/ts-types/column/style.js.map +1 -1
  289. package/es/ts-types/common.d.ts +2 -0
  290. package/es/ts-types/common.js.map +1 -1
  291. package/es/ts-types/table-engine.d.ts +13 -0
  292. package/es/ts-types/table-engine.js.map +1 -1
  293. package/package.json +3 -3
  294. package/cjs/dataset/util/zero-align.js.map +0 -1
  295. package/cjs/scenegraph/header-icon/layout.d.ts +0 -3
  296. package/cjs/scenegraph/header-icon/layout.js +0 -75
  297. package/cjs/scenegraph/header-icon/layout.js.map +0 -1
  298. package/cjs/scenegraph/hover-state.d.ts +0 -14
  299. package/cjs/scenegraph/hover-state.js +0 -27
  300. package/cjs/scenegraph/hover-state.js.map +0 -1
  301. package/es/dataset/util/zero-align.js.map +0 -1
  302. package/es/scenegraph/header-icon/layout.d.ts +0 -3
  303. package/es/scenegraph/header-icon/layout.js +0 -69
  304. package/es/scenegraph/header-icon/layout.js.map +0 -1
  305. package/es/scenegraph/hover-state.d.ts +0 -14
  306. package/es/scenegraph/hover-state.js +0 -19
  307. package/es/scenegraph/hover-state.js.map +0 -1
  308. /package/cjs/{dataset/util → layout/chart-helper}/zero-align.d.ts +0 -0
  309. /package/cjs/{dataset/util → layout/chart-helper}/zero-align.js +0 -0
  310. /package/es/{dataset/util → layout/chart-helper}/zero-align.d.ts +0 -0
  311. /package/es/{dataset/util → layout/chart-helper}/zero-align.js +0 -0
@@ -4,107 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Container = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), direction_1 = require("./direction"), element_1 = require("./element"), line_1 = require("./line"), rect_1 = require("./rect");
7
+ const vutils_1 = require("@visactor/vutils"), vrender_1 = require("@visactor/vrender");
8
8
 
9
- class Container extends element_1.BaseElement {
10
- constructor(options) {
11
- super(options), this.type = "container", this.needCalcSize = !1, this.lines = [],
12
- this.currentLineY = 0, this.offsetY = 0, this.direction = options.direction || "row",
13
- this.justifyContent = options.justifyContent || "start", this.alignItems = options.alignItems || "start",
14
- this.alignContent = options.alignContent || "start", (0, vutils_1.isNumber)(options.width) ? this.width = options.width : (this._widthObj = options.width,
15
- this.needCalcSize = !0), (0, vutils_1.isNumber)(options.height) ? this.height = options.height : (this._heightObj = options.height,
16
- this.needCalcSize = !0), this.directionKey = direction_1.DIRECTION_KEY[this.direction],
17
- this.showBounds = options.showBounds || !1, this.initLayoutSize();
18
- }
19
- add(element) {
20
- if (this.needCalcSize) throw new Error("Need to specify a parent element before adding a child element when use percent size!");
21
- "container" === element.type && element.calcSize(this.width, this.height), this.currentLine && this.currentLine.canAdd(element) ? this.currentLine.add(element) : (this.currentLine && (this.currentLine.addAble = !1,
22
- this.currentLineY += this.currentLine[this.directionKey.height], this.currentLine.lineFinish()),
23
- this.currentLine = new line_1.Line(this[this.directionKey.width], this.direction, this.justifyContent, this.alignItems),
24
- this.currentLine[this.directionKey.y] = this.currentLineY, this.currentLine.add(element),
25
- this.lines.push(this.currentLine));
26
- }
27
- updateYAlign() {
28
- const offsetY = this[this.directionKey.height] - this.currentLineY;
29
- "center" === this.alignContent ? this.offsetY = offsetY / 2 : "start" === this.alignContent ? this.offsetY = 0 : this.offsetY = offsetY;
30
- }
31
- getSize() {
32
- const result = {
33
- width: 0,
34
- height: 0
35
- };
36
- this.currentLine && this.currentLine.addAble ? result[this.directionKey.height] = this.currentLineY + this.currentLine[this.directionKey.height] : result[this.directionKey.height] = this.currentLineY;
37
- for (let i = 0; i < this.lines.length; i++) {
38
- const line = this.lines[i];
39
- result[this.directionKey.width] < line[this.directionKey.width] && (result[this.directionKey.width] = line[this.directionKey.width]);
40
- }
41
- return result;
42
- }
43
- getContentSize() {
44
- const result = {
45
- width: 0,
46
- height: 0
47
- }, calcFlag = {
48
- width: !0,
49
- height: !0
50
- };
51
- this.isRoot || this._heightObj || (calcFlag.height = !1, result.height = this.height),
52
- this.isRoot || this._widthObj || (calcFlag.width = !1, result.width = this.width);
53
- for (let i = 0; i < this.lines.length; i++) {
54
- const size = this.lines[i].getContentSize();
55
- calcFlag[this.directionKey.width] && result[this.directionKey.width] < size[this.directionKey.width] && (result[this.directionKey.width] = size[this.directionKey.width]),
56
- calcFlag[this.directionKey.height] && (result[this.directionKey.height] += size[this.directionKey.height]);
57
- }
58
- return result;
59
- }
60
- calcSize(parentWidth, parentHeight) {
61
- this._heightObj && (this.height = parentHeight * this._heightObj.percent / 100 + this._heightObj.delta,
62
- this.needCalcSize = !1, this.initLayoutSize()), this._widthObj && (this.width = parentWidth * this._widthObj.percent / 100 + this._widthObj.delta,
63
- this.needCalcSize = !1, this.initLayoutSize());
64
- }
65
- getElements(parentPos = {
66
- parentX: 0,
67
- parentY: 0
68
- }, isHover = !1, isSelect = !1) {
69
- var _a, _b, _c;
70
- this.currentLine && this.currentLine.addAble && (this.currentLine.addAble = !1,
71
- this.currentLineY += this.currentLine[this.directionKey.height], this.currentLine.lineFinish()),
72
- this.updateYAlign();
73
- const elements = [];
74
- if (this.background && this.background.fill) {
75
- const backgroundRect = new rect_1.Rect({
76
- width: this.width,
77
- height: this.height,
78
- stroke: null !== (_a = this.background.stroke) && void 0 !== _a && _a,
79
- fill: this.background.fill,
80
- cornerRadius: null !== (_b = this.background.cornerRadius) && void 0 !== _b ? _b : 0,
81
- lineWidth: null !== (_c = this.background.lineWidth) && void 0 !== _c ? _c : 1
82
- });
83
- backgroundRect.x += this.x + parentPos.parentX, backgroundRect.y += this.y + parentPos.parentY,
84
- elements.push(backgroundRect);
85
- }
86
- if (this.showBounds) {
87
- const boundsRect = new rect_1.Rect({
88
- width: this.width,
89
- height: this.height,
90
- cornerRadius: 0,
91
- stroke: "red",
92
- fill: "rgba(255, 0, 0, 0.2)",
93
- lineWidth: 4
94
- });
95
- boundsRect.x += this.x + parentPos.parentX, boundsRect.y += this.y + parentPos.parentY,
96
- elements.push(boundsRect);
97
- }
98
- for (let i = 0; i < this.lines.length; i++) {
99
- const line = this.lines[i];
100
- line[this.directionKey.y] += this.offsetY;
101
- const linesElements = line.getElements({
102
- [this.directionKey.parentX]: this.x + parentPos.parentX,
103
- [this.directionKey.parentY]: this.y + parentPos.parentY
104
- }, isHover, isSelect);
105
- elements.push(...linesElements);
106
- }
107
- return elements;
9
+ class Container extends vrender_1.Group {
10
+ constructor(containerOptions) {
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
12
+ containerOptions.direction && (containerOptions.flexDirection = containerOptions.direction),
13
+ !containerOptions.justifyContent || "start" !== containerOptions.justifyContent && "end" !== containerOptions.justifyContent || (containerOptions.justifyContent = "flex-" + containerOptions.justifyContent),
14
+ !containerOptions.alignItems || "start" !== containerOptions.alignItems && "end" !== containerOptions.alignItems || (containerOptions.alignItems = "flex-" + containerOptions.alignItems),
15
+ !containerOptions.alignContent || "start" !== containerOptions.alignContent && "end" !== containerOptions.alignContent || (containerOptions.alignContent = "flex-" + containerOptions.alignContent),
16
+ containerOptions.display = "flex", containerOptions.flexDirection || (containerOptions.flexDirection = "row"),
17
+ containerOptions.clip = !0, containerOptions.fill = null === (_a = null == containerOptions ? void 0 : containerOptions.background) || void 0 === _a ? void 0 : _a.fill,
18
+ containerOptions.stroke = null === (_b = null == containerOptions ? void 0 : containerOptions.background) || void 0 === _b ? void 0 : _b.stroke,
19
+ containerOptions.lineWidth = null === (_c = null == containerOptions ? void 0 : containerOptions.background) || void 0 === _c ? void 0 : _c.lineWidth,
20
+ containerOptions.cornerRadius = null === (_d = null == containerOptions ? void 0 : containerOptions.background) || void 0 === _d ? void 0 : _d.cornerRadius;
21
+ const isPaddingNumber = (0, vutils_1.isArray)(containerOptions.boundsPadding), padding = [ null !== (_f = null !== (_e = containerOptions.marginTop) && void 0 !== _e ? _e : isPaddingNumber ? containerOptions.boundsPadding[0] : containerOptions.boundsPadding) && void 0 !== _f ? _f : 0, null !== (_h = null !== (_g = containerOptions.marginRight) && void 0 !== _g ? _g : isPaddingNumber ? containerOptions.boundsPadding[1] : containerOptions.boundsPadding) && void 0 !== _h ? _h : 0, null !== (_l = null !== (_j = containerOptions.marginBottom) && void 0 !== _j ? _j : isPaddingNumber ? null !== (_k = containerOptions.boundsPadding[2]) && void 0 !== _k ? _k : containerOptions.boundsPadding[0] : containerOptions.boundsPadding) && void 0 !== _l ? _l : 0, null !== (_p = null !== (_m = containerOptions.marginLeft) && void 0 !== _m ? _m : isPaddingNumber ? null !== (_o = containerOptions.boundsPadding[3]) && void 0 !== _o ? _o : containerOptions.boundsPadding[1] : containerOptions.boundsPadding) && void 0 !== _p ? _p : 0 ];
22
+ containerOptions.boundsPadding = padding, super(containerOptions);
108
23
  }
109
24
  }
110
25
 
@@ -1 +1 @@
1
- {"version":3,"sources":["render/layout/container.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG5C,2CAA4C;AAE5C,uCAAwC;AACxC,iCAA8B;AAE9B,iCAA8B;AAY9B,MAAa,SAAU,SAAQ,qBAAW;IAoBxC,YAAY,OAAyB;QACnC,KAAK,CAAC,OAAO,CAAC,CAAC;QApBjB,SAAI,GAAgB,WAAW,CAAC;QAKhC,iBAAY,GAAG,KAAK,CAAC;QAKrB,UAAK,GAAW,EAAE,CAAC;QAEnB,iBAAY,GAAG,CAAC,CAAC;QAIjB,YAAO,GAAG,CAAC,CAAC;QAKV,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC;QAEpD,IAAI,IAAA,iBAAQ,EAAC,O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BACf,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,sBAAsB;gBAC5B,SAAS,EAAE,CAAC;aACb,CAAC,CAAC;YACH,UAAU,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC3C,UAAU,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC3B;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC;YAE1C,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,CACpC;gBACE,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO;gBACvD,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO;aACjD,EACR,OAAO,EACP,QAAQ,CACT,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;SACjC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AArND,8BAqNC","file":"container.js","sourcesContent":["import { isNumber } from '@visactor/vutils';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport type { DirectionKey } from './direction';\nimport { DIRECTION_KEY } from './direction';\nimport type { ElementOptions } from './element';\nimport { BaseElement } from './element';\nimport { Line } from './line';\nimport type { percentCalcObj } from './percent-calc';\nimport { Rect } from './rect';\n\ntype containerOptions = {\n width?: number | percentCalcObj;\n height?: number | percentCalcObj;\n direction?: 'row' | 'column'; // 布局主方向\n justifyContent?: 'start' | 'end' | 'center'; // 布局方向上的对齐方式\n alignItems?: 'start' | 'end' | 'center'; // 布局交叉方向上的对齐方式\n alignContent?: 'start' | 'end' | 'center'; // 布局交叉方向上多根轴线的对齐方式\n showBounds?: boolean; // 是否显示bounds\n} & ElementOptions;\n\nexport class Container extends BaseElement {\n type: 'container' = 'container';\n declare width: number;\n _widthObj: percentCalcObj;\n declare height: number;\n _heightObj: percentCalcObj;\n needCalcSize = false;\n direction: 'row' | 'column'; // 布局主方向\n justifyContent: 'start' | 'end' | 'center'; // 布局方向上的对齐方式\n alignItems: 'start' | 'end' | 'center'; // 布局交叉方向上的对齐方式\n alignContent: 'start' | 'end' | 'center'; // 布局交叉方向上多根轴线的对齐方式\n lines: Line[] = [];\n currentLine?: Line;\n currentLineY = 0;\n table: BaseTableAPI;\n directionKey: DirectionKey;\n showBounds: boolean;\n offsetY = 0;\n isRoot?: boolean;\n\n constructor(options: containerOptions) {\n super(options);\n this.direction = options.direction || 'row';\n this.justifyContent = options.justifyContent || 'start';\n this.alignItems = options.alignItems || 'start';\n this.alignContent = options.alignContent || 'start';\n\n if (isNumber(options.width)) {\n this.width = options.width as number;\n } else {\n this._widthObj = options.width as percentCalcObj;\n this.needCalcSize = true;\n }\n if (isNumber(options.height)) {\n this.height = options.height as number;\n } else {\n this._heightObj = options.height as percentCalcObj;\n this.needCalcSize = true;\n }\n\n this.directionKey = DIRECTION_KEY[this.direction];\n\n this.showBounds = options.showBounds || false;\n\n this.initLayoutSize();\n }\n\n add(element: BaseElement) {\n if (this.needCalcSize) {\n throw new Error('Need to specify a parent element before adding a child element when use percent size!');\n }\n\n if (element.type === 'container') {\n (element as Container).calcSize(this.width, this.height);\n }\n\n if (this.currentLine && this.currentLine.canAdd(element)) {\n this.currentLine.add(element);\n } else {\n if (this.currentLine) {\n this.currentLine.addAble = false; // 关闭当前行\n this.currentLineY += this.currentLine[this.directionKey.height]; // 更新目前line y位置\n this.currentLine.lineFinish();\n }\n // this.currentLine = new Line(this.width);\n this.currentLine = new Line(this[this.directionKey.width], this.direction, this.justifyContent, this.alignItems);\n this.currentLine[this.directionKey.y] = this.currentLineY;\n this.currentLine.add(element);\n this.lines.push(this.currentLine);\n }\n }\n\n // 交叉方向上多根轴线的对齐方式\n updateYAlign() {\n const offsetY = this[this.directionKey.height] - this.currentLineY;\n if (this.alignContent === 'center') {\n this.offsetY = offsetY / 2;\n } else if (this.alignContent === 'start') {\n this.offsetY = 0;\n } else {\n this.offsetY = offsetY;\n }\n }\n\n getSize() {\n const result = {\n width: 0,\n height: 0\n };\n if (this.currentLine && this.currentLine.addAble) {\n result[this.directionKey.height] = this.currentLineY + this.currentLine[this.directionKey.height];\n } else {\n result[this.directionKey.height] = this.currentLineY;\n }\n\n for (let i = 0; i < this.lines.length; i++) {\n const line = this.lines[i];\n if (result[this.directionKey.width] < line[this.directionKey.width]) {\n result[this.directionKey.width] = line[this.directionKey.width];\n }\n }\n return result;\n }\n\n getContentSize() {\n const result = {\n width: 0,\n height: 0\n };\n\n const calcFlag = {\n width: true,\n height: true\n };\n\n if (!this.isRoot && !this._heightObj) {\n calcFlag.height = false;\n result.height = this.height;\n }\n if (!this.isRoot && !this._widthObj) {\n calcFlag.width = false;\n result.width = this.width;\n }\n\n for (let i = 0; i < this.lines.length; i++) {\n const line = this.lines[i];\n const size = line.getContentSize();\n if (calcFlag[this.directionKey.width] && result[this.directionKey.width] < size[this.directionKey.width]) {\n result[this.directionKey.width] = size[this.directionKey.width];\n }\n\n if (calcFlag[this.directionKey.height]) {\n result[this.directionKey.height] += size[this.directionKey.height];\n }\n }\n\n return result;\n }\n\n calcSize(parentWidth: number, parentHeight: number) {\n if (this._heightObj) {\n this.height = (parentHeight * this._heightObj.percent) / 100 + this._heightObj.delta;\n this.needCalcSize = false;\n this.initLayoutSize();\n }\n if (this._widthObj) {\n this.width = (parentWidth * this._widthObj.percent) / 100 + this._widthObj.delta;\n this.needCalcSize = false;\n this.initLayoutSize();\n }\n }\n\n // 获取平坦后的全部子图元,更新子图元xy位置信息\n getElements(\n parentPos: { parentX: number; parentY: number } = { parentX: 0, parentY: 0 },\n isHover = false,\n isSelect = false\n ) {\n // 关闭最后一行\n if (this.currentLine && this.currentLine.addAble) {\n this.currentLine.addAble = false; // 关闭当前行\n this.currentLineY += this.currentLine[this.directionKey.height]; // 更新目前line y位置\n this.currentLine.lineFinish();\n }\n\n // 处理alignContent\n this.updateYAlign();\n\n const elements = [];\n if (this.background && this.background.fill) {\n const backgroundRect = new Rect({\n width: this.width,\n height: this.height,\n stroke: this.background.stroke ?? false,\n fill: this.background.fill,\n cornerRadius: this.background.cornerRadius ?? 0,\n lineWidth: this.background.lineWidth ?? 1\n });\n backgroundRect.x += this.x + parentPos.parentX;\n backgroundRect.y += this.y + parentPos.parentY;\n elements.push(backgroundRect);\n }\n if (this.showBounds) {\n const boundsRect = new Rect({\n width: this.width,\n height: this.height,\n cornerRadius: 0,\n stroke: 'red',\n fill: 'rgba(255, 0, 0, 0.2)',\n lineWidth: 4\n });\n boundsRect.x += this.x + parentPos.parentX;\n boundsRect.y += this.y + parentPos.parentY;\n elements.push(boundsRect);\n }\n // const parentPos = { parentX, parentY };\n for (let i = 0; i < this.lines.length; i++) {\n const line = this.lines[i];\n line[this.directionKey.y] += this.offsetY;\n // const linesElements = line.getElements(table, this.x + parentX, this.y + parentY);\n const linesElements = line.getElements(\n {\n [this.directionKey.parentX]: this.x + parentPos.parentX,\n [this.directionKey.parentY]: this.y + parentPos.parentY\n } as any,\n isHover,\n isSelect\n );\n elements.push(...linesElements);\n }\n\n return elements;\n }\n}\n"]}
1
+ {"version":3,"sources":["render/layout/container.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAE3C,+CAA0C;AAY1C,MAAa,SAAU,SAAQ,eAAK;IAClC,YAAY,gBAAmC;;QAC7C,IAAK,gBAAwB,CAAC,SAAS,EAAE;YACvC,gBAAgB,CAAC,aAAa,GAAI,gBAAwB,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MAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,UAAkB,0CAAE,YAAY,CAAC;QAGpF,MAAM,eAAe,GAAG,IAAA,gBAAO,EAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG;YACd,MAAA,MAAA,gBAAgB,CAAC,SAAS,mCACxB,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,mCACtF,CAAC;YACH,MAAA,MAAA,gBAAgB,CAAC,WAAW,mCAC1B,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,mCACtF,CAAC;YACH,MAAA,MAAA,gBAAgB,CAAC,YAAY,mCAC3B,CAAC,eAAe;gBACd,CAAC,CAAC,MAAA,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;gBACxE,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,mCACnC,CAAC;YACH,MAAA,MAAA,gBAAgB,CAAC,UAAU,mCACzB,CAAC,eAAe;gBACd,CAAC,CAAC,MAAA,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;gBACxE,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,mCACnC,CAAC;SACJ,CAAC;QACF,gBAAgB,CAAC,aAAa,GAAG,OAAO,CAAC;QAEzC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC1B,CAAC;CACF;AA5DD,8BA4DC","file":"container.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport type { IGroupGraphicAttribute } from '@visactor/vrender';\nimport { Group } from '@visactor/vrender';\nimport type { percentCalcObj } from './percent-calc';\n\nexport type IContainerOptions = {\n width?: number | percentCalcObj;\n height?: number | percentCalcObj;\n marginTop?: number;\n marginRight?: number;\n marginBottom?: number;\n marginLeft?: number;\n} & IGroupGraphicAttribute;\n\nexport class Container extends Group {\n constructor(containerOptions: IContainerOptions) {\n if ((containerOptions as any).direction) {\n containerOptions.flexDirection = (containerOptions as any).direction;\n }\n if (\n containerOptions.justifyContent &&\n ((containerOptions.justifyContent as any) === 'start' || (containerOptions.justifyContent as any) === 'end')\n ) {\n containerOptions.justifyContent = ('flex-' + containerOptions.justifyContent) as any;\n }\n\n if (\n containerOptions.alignItems &&\n ((containerOptions.alignItems as any) === 'start' || (containerOptions.alignItems as any) === 'end')\n ) {\n containerOptions.alignItems = ('flex-' + containerOptions.alignItems) as any;\n }\n\n if (\n containerOptions.alignContent &&\n ((containerOptions.alignContent as any) === 'start' || (containerOptions.alignContent as any) === 'end')\n ) {\n containerOptions.alignContent = ('flex-' + containerOptions.alignContent) as any;\n }\n containerOptions.display = 'flex';\n if (!containerOptions.flexDirection) {\n containerOptions.flexDirection = 'row';\n }\n\n containerOptions.clip = true;\n containerOptions.fill = (containerOptions?.background as any)?.fill;\n containerOptions.stroke = (containerOptions?.background as any)?.stroke;\n containerOptions.lineWidth = (containerOptions?.background as any)?.lineWidth;\n containerOptions.cornerRadius = (containerOptions?.background as any)?.cornerRadius;\n // containerOptions.flexWrap = 'nowrap';\n\n const isPaddingNumber = isArray(containerOptions.boundsPadding);\n const padding = [\n containerOptions.marginTop ??\n (isPaddingNumber ? containerOptions.boundsPadding[0] : containerOptions.boundsPadding) ??\n 0,\n containerOptions.marginRight ??\n (isPaddingNumber ? containerOptions.boundsPadding[1] : containerOptions.boundsPadding) ??\n 0,\n containerOptions.marginBottom ??\n (isPaddingNumber\n ? containerOptions.boundsPadding[2] ?? containerOptions.boundsPadding[0]\n : containerOptions.boundsPadding) ??\n 0,\n containerOptions.marginLeft ??\n (isPaddingNumber\n ? containerOptions.boundsPadding[3] ?? containerOptions.boundsPadding[1]\n : containerOptions.boundsPadding) ??\n 0\n ];\n containerOptions.boundsPadding = padding;\n\n super(containerOptions);\n }\n}\n"]}
@@ -1,25 +1,5 @@
1
- import type { AlignItems, DirectionKey } from './direction';
2
- import type { ElementOptions } from './element';
3
- import { BaseElement } from './element';
4
- type GroupElementOptions = {
5
- direction?: 'row' | 'column';
6
- alignItems?: AlignItems;
7
- } & ElementOptions;
8
- export declare class GroupElement extends BaseElement {
9
- type: 'group-element';
10
- direction: 'row' | 'column';
11
- alignItems?: AlignItems;
12
- width: number;
13
- height: number;
14
- children: BaseElement[];
15
- directionKey: DirectionKey;
16
- constructor(options: GroupElementOptions);
17
- add(element: BaseElement): void;
18
- updateHeight(element: BaseElement): void;
19
- getOffsetY(element: BaseElement): number;
20
- getElements(parentPos?: {
21
- parentX: number;
22
- parentY: number;
23
- }, isHover?: boolean, isSelect?: boolean): BaseElement[];
1
+ import type { IContainerOptions } from './container';
2
+ import { Container } from './container';
3
+ export declare class GroupElement extends Container {
4
+ constructor(option: IContainerOptions);
24
5
  }
25
- export {};
@@ -4,47 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.GroupElement = void 0;
6
6
 
7
- const direction_1 = require("./direction"), element_1 = require("./element");
7
+ const container_1 = require("./container");
8
8
 
9
- class GroupElement extends element_1.BaseElement {
10
- constructor(options) {
11
- super(options), this.type = "group-element", this.width = 0, this.height = 0, this.children = [],
12
- this.direction = options.direction || "row", this.alignItems = options.alignItems || "start",
13
- this.directionKey = direction_1.DIRECTION_KEY[this.direction];
14
- }
15
- add(element) {
16
- element.x = this.width, this.width += element.layoutWidth, this.children.push(element),
17
- this.updateHeight(element), this.initLayoutSize();
18
- }
19
- updateHeight(element) {
20
- element.layoutHeight > this.height && (this.height = element.layoutHeight);
21
- }
22
- getOffsetY(element) {
23
- switch (this.alignItems) {
24
- case "start":
25
- default:
26
- return 0;
27
-
28
- case "center":
29
- return (this[this.directionKey.height] - element[this.directionKey.layoutHeight]) / 2;
30
-
31
- case "end":
32
- return this[this.directionKey.height] - element[this.directionKey.layoutHeight];
33
- }
34
- }
35
- getElements(parentPos = {
36
- parentX: 0,
37
- parentY: 0
38
- }, isHover = !1, isSelect = !1) {
39
- var _a, _b;
40
- const elements = [];
41
- for (let i = 0; i < this.children.length; i++) {
42
- const element = this.children[i];
43
- "icon" === element.type && ("mouseenter_cell" === (null === (_a = element.cache) || void 0 === _a ? void 0 : _a.visibleTime) && !isHover || "click_cell" === (null === (_b = element.cache) || void 0 === _b ? void 0 : _b.visibleTime) && !isSelect) || (element[this.directionKey.x] += this[this.directionKey.dx] + this[this.directionKey.x] + parentPos.parentX,
44
- element[this.directionKey.y] += this.getOffsetY(element) + this[this.directionKey.dy] + this[this.directionKey.y] + parentPos.parentY,
45
- elements.push(element));
46
- }
47
- return elements;
9
+ class GroupElement extends container_1.Container {
10
+ constructor(option) {
11
+ option.flexWrap = "nowrap", super(option);
48
12
  }
49
13
  }
50
14
 
@@ -1 +1 @@
1
- {"version":3,"sources":["render/layout/group-element.ts"],"names":[],"mappings":";;;AACA,2CAA4C;AAE5C,uCAAwC;AAQxC,MAAa,YAAa,SAAQ,qBAAW;IAS3C,YAAY,OAA4B;QACtC,KAAK,CAAC,OAAO,CAAC,CAAC;QATjB,SAAI,GAAoB,eAAe,CAAC;QAGxC,UAAK,GAAG,CAAC,CAAC;QACV,WAAM,GAAG,CAAC,CAAC;QACX,aAAQ,GAAkB,EAAE,CAAC;QAK3B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;QAC5C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC;QAEhD,IAAI,CAAC,YAAY,GAAG,yBAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,GAAG,CAAC,OAAoB;QACtB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,IAAI,CAAC,KAA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,KAAK,0CAAE,WAAW,MAAK,iBAAiB,IAAI,CAAC,OAAO,CAAC;oBACvE,CAAC,CAAA,MAAC,OAAgB,CAAC,KAAK,0CAAE,WAAW,MAAK,YAAY,IAAI,CAAC,QAAQ,CAAC,CAAC,EACvE;gBACA,SAAS;aACV;YAED,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC3G,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;gBAC1B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YACxG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA1ED,oCA0EC","file":"group-element.js","sourcesContent":["import type { AlignItems, DirectionKey } from './direction';\nimport { DIRECTION_KEY } from './direction';\nimport type { ElementOptions } from './element';\nimport { BaseElement } from './element';\nimport type { Icon } from './icon';\n\ntype GroupElementOptions = {\n direction?: 'row' | 'column';\n alignItems?: AlignItems;\n} & ElementOptions;\n\nexport class GroupElement extends BaseElement {\n type: 'group-element' = 'group-element';\n direction: 'row' | 'column';\n alignItems?: AlignItems;\n width = 0;\n height = 0;\n children: BaseElement[] = [];\n directionKey: DirectionKey;\n\n constructor(options: GroupElementOptions) {\n super(options);\n this.direction = options.direction || 'row';\n this.alignItems = options.alignItems || 'start';\n\n this.directionKey = DIRECTION_KEY[this.direction];\n }\n\n add(element: BaseElement) {\n element.x = this.width;\n this.width += element.layoutWidth;\n this.children.push(element);\n this.updateHeight(element);\n this.initLayoutSize();\n }\n\n updateHeight(element: BaseElement) {\n if (element.layoutHeight > this.height) {\n this.height = element.layoutHeight;\n }\n }\n\n getOffsetY(element: BaseElement): number {\n switch (this.alignItems) {\n case 'start':\n return 0;\n case 'center':\n return (this[this.directionKey.height] - element[this.directionKey.layoutHeight]) / 2;\n case 'end':\n return this[this.directionKey.height] - element[this.directionKey.layoutHeight];\n default:\n return 0;\n }\n }\n\n // 获取平坦后的全部子图元,更新子图元xy位置信息\n getElements(\n parentPos: { parentX: number; parentY: number } = { parentX: 0, parentY: 0 },\n isHover = false,\n isSelect = false\n ) {\n const elements = [];\n for (let i = 0; i < this.children.length; i++) {\n const element = this.children[i];\n // element.getSize(table);\n // element.x = this.width;\n // this.width += element.layoutWidth;\n // this.updateHeight(element);\n\n if (\n element.type === 'icon' &&\n (((element as Icon).cache?.visibleTime === 'mouseenter_cell' && !isHover) ||\n ((element as Icon).cache?.visibleTime === 'click_cell' && !isSelect))\n ) {\n continue;\n }\n\n element[this.directionKey.x] += this[this.directionKey.dx] + this[this.directionKey.x] + parentPos.parentX;\n element[this.directionKey.y] +=\n this.getOffsetY(element) + this[this.directionKey.dy] + this[this.directionKey.y] + parentPos.parentY;\n elements.push(element);\n }\n\n return elements;\n }\n}\n"]}
1
+ {"version":3,"sources":["render/layout/group-element.ts"],"names":[],"mappings":";;;AACA,2CAAwC;AAExC,MAAa,YAAa,SAAQ,qBAAS;IACzC,YAAY,MAAyB;QACnC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3B,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;CACF;AALD,oCAKC","file":"group-element.js","sourcesContent":["import type { IContainerOptions } from './container';\nimport { Container } from './container';\n\nexport class GroupElement extends Container {\n constructor(option: IContainerOptions) {\n option.flexWrap = 'nowrap';\n super(option);\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { IGroupGraphicAttribute } from '@visactor/vrender';
2
+ import { Group as VGroup } from '@visactor/vrender';
3
+ type IGroupOption = {
4
+ marginTop?: number;
5
+ marginRight?: number;
6
+ marginBottom?: number;
7
+ marginLeft?: number;
8
+ } & IGroupGraphicAttribute;
9
+ export declare class Group extends VGroup {
10
+ constructor(options: IGroupOption);
11
+ }
12
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.Group = void 0;
6
+
7
+ const vrender_1 = require("@visactor/vrender"), vutils_1 = require("@visactor/vutils");
8
+
9
+ class Group extends vrender_1.Group {
10
+ constructor(options) {
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
12
+ const isPaddingNumber = (0, vutils_1.isArray)(options.boundsPadding), padding = [ null !== (_b = null !== (_a = options.marginTop) && void 0 !== _a ? _a : isPaddingNumber ? options.boundsPadding[0] : options.boundsPadding) && void 0 !== _b ? _b : 0, null !== (_d = null !== (_c = options.marginRight) && void 0 !== _c ? _c : isPaddingNumber ? options.boundsPadding[1] : options.boundsPadding) && void 0 !== _d ? _d : 0, null !== (_g = null !== (_e = options.marginBottom) && void 0 !== _e ? _e : isPaddingNumber ? null !== (_f = options.boundsPadding[2]) && void 0 !== _f ? _f : options.boundsPadding[0] : options.boundsPadding) && void 0 !== _g ? _g : 0, null !== (_k = null !== (_h = options.marginLeft) && void 0 !== _h ? _h : isPaddingNumber ? null !== (_j = options.boundsPadding[3]) && void 0 !== _j ? _j : options.boundsPadding[1] : options.boundsPadding) && void 0 !== _k ? _k : 0 ];
13
+ options.boundsPadding = padding, super(options);
14
+ }
15
+ }
16
+
17
+ exports.Group = Group;
18
+ //# sourceMappingURL=group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["render/layout/group.ts"],"names":[],"mappings":";;;AACA,+CAAoD;AACpD,6CAA2C;AAS3C,MAAa,KAAM,SAAQ,eAAM;IAC/B,YAAY,OAAqB;;QAC/B,MAAM,eAAe,GAAG,IAAA,gBAAO,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG;YACd,MAAA,MAAA,OAAO,CAAC,SAAS,mCAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,CAAC;YAC9F,MAAA,MAAA,OAAO,CAAC,WAAW,mCAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,CAAC;YAChG,MAAA,MAAA,OAAO,CAAC,YAAY,mCAClB,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAChG,CAAC;YACH,MAAA,MAAA,OAAO,CAAC,UAAU,mCAChB,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAChG,CAAC;SACJ,CAAC;QACF,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAjBD,sBAiBC","file":"group.js","sourcesContent":["import type { IGroupGraphicAttribute } from '@visactor/vrender';\nimport { Group as VGroup } from '@visactor/vrender';\nimport { isArray } from '@visactor/vutils';\n\ntype IGroupOption = {\n marginTop?: number;\n marginRight?: number;\n marginBottom?: number;\n marginLeft?: number;\n} & IGroupGraphicAttribute;\n\nexport class Group extends VGroup {\n constructor(options: IGroupOption) {\n const isPaddingNumber = isArray(options.boundsPadding);\n const padding = [\n options.marginTop ?? (isPaddingNumber ? options.boundsPadding[0] : options.boundsPadding) ?? 0,\n options.marginRight ?? (isPaddingNumber ? options.boundsPadding[1] : options.boundsPadding) ?? 0,\n options.marginBottom ??\n (isPaddingNumber ? options.boundsPadding[2] ?? options.boundsPadding[0] : options.boundsPadding) ??\n 0,\n options.marginLeft ??\n (isPaddingNumber ? options.boundsPadding[3] ?? options.boundsPadding[1] : options.boundsPadding) ??\n 0\n ];\n options.boundsPadding = padding;\n\n super(options);\n }\n}\n"]}
@@ -1,21 +1,21 @@
1
- import type { ElementOptions } from './element';
2
- import { BaseElement } from './element';
1
+ import type { IImageGraphicAttribute } from '@visactor/vrender';
2
+ import { Image } from '@visactor/vrender';
3
3
  import type { ColumnIconOption } from '../../ts-types';
4
- type IconOptions = {
4
+ type IIconOptions = {
5
5
  width: number;
6
6
  height: number;
7
7
  svg?: string;
8
8
  iconName?: string;
9
- } & ElementOptions;
10
- export declare class Icon extends BaseElement {
9
+ marginTop?: number;
10
+ marginRight?: number;
11
+ marginBottom?: number;
12
+ marginLeft?: number;
13
+ } & IImageGraphicAttribute;
14
+ export declare class Icon extends Image {
11
15
  id: string;
12
- type: 'icon';
13
- width: number;
14
- height: number;
15
16
  svg: string;
16
17
  iconName: string;
17
- cursor?: string;
18
18
  cache?: ColumnIconOption;
19
- constructor(options: IconOptions);
19
+ constructor(options: IIconOptions);
20
20
  }
21
21
  export {};
@@ -29,18 +29,20 @@ Object.defineProperty(exports, "__esModule", {
29
29
  value: !0
30
30
  }), exports.Icon = void 0;
31
31
 
32
- const vutils_1 = require("@visactor/vutils"), element_1 = require("./element"), registerIcons = __importStar(require("../../icons"));
32
+ const vrender_1 = require("@visactor/vrender"), vutils_1 = require("@visactor/vutils"), registerIcons = __importStar(require("../../icons"));
33
33
 
34
- class Icon extends element_1.BaseElement {
34
+ class Icon extends vrender_1.Image {
35
35
  constructor(options) {
36
- var _a, _b, _c;
37
- if (super(options), this.type = "icon", this.iconName = options.iconName, (0, vutils_1.isString)(this.iconName)) {
38
- const cache = registerIcons.get()[this.iconName];
39
- cache && (this.cache = cache, this.width = cache.width, this.height = cache.height,
40
- this.svg = cache.svg, this.cursor = cache.cursor);
36
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
37
+ let cache;
38
+ if ((0, vutils_1.isString)(options.iconName)) {
39
+ cache = registerIcons.get()[options.iconName], cache && (options.width = null !== (_a = options.width) && void 0 !== _a ? _a : cache.width,
40
+ options.height = null !== (_b = options.height) && void 0 !== _b ? _b : cache.height,
41
+ options.svg = cache.svg, options.cursor = cache.cursor);
41
42
  }
42
- this.width = null !== (_a = options.width) && void 0 !== _a ? _a : this.width, this.height = null !== (_b = options.height) && void 0 !== _b ? _b : this.height,
43
- this.svg = null !== (_c = options.svg) && void 0 !== _c ? _c : this.svg, this.initLayoutSize();
43
+ options.svg && (options.image = options.svg);
44
+ const isPaddingNumber = (0, vutils_1.isArray)(options.boundsPadding), padding = [ null !== (_d = null !== (_c = options.marginTop) && void 0 !== _c ? _c : isPaddingNumber ? options.boundsPadding[0] : options.boundsPadding) && void 0 !== _d ? _d : 0, null !== (_f = null !== (_e = options.marginRight) && void 0 !== _e ? _e : isPaddingNumber ? options.boundsPadding[1] : options.boundsPadding) && void 0 !== _f ? _f : 0, null !== (_j = null !== (_g = options.marginBottom) && void 0 !== _g ? _g : isPaddingNumber ? null !== (_h = options.boundsPadding[2]) && void 0 !== _h ? _h : options.boundsPadding[0] : options.boundsPadding) && void 0 !== _j ? _j : 0, null !== (_m = null !== (_k = options.marginLeft) && void 0 !== _k ? _k : isPaddingNumber ? null !== (_l = options.boundsPadding[3]) && void 0 !== _l ? _l : options.boundsPadding[1] : options.boundsPadding) && void 0 !== _m ? _m : 0 ];
45
+ options.boundsPadding = padding, super(options), this.cache = cache;
44
46
  }
45
47
  }
46
48
 
@@ -1 +1 @@
1
- {"version":3,"sources":["render/layout/icon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAE5C,uCAAwC;AACxC,2DAA6C;AAU7C,MAAa,IAAK,SAAQ,qBAAW;IAUnC,YAAY,OAAoB;;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;QATjB,SAAI,GAAW,MAAM,CAAC;QAUpB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC3B,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;YACvC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,KAAK,EAAE;gBACT,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;gBACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;gBACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;gBAC3B,IAAI,CAAC,GAAG,GAAI,KAAa,CAAC,GAAG,CAAC;gBAC9B,IAAI,CAAC,MAAM,GAAI,KAAa,CAAC,MAAM,CAAC;aACrC;SACF;QAGD,IAAI,CAAC,KAAK,GAAG,MAAA,OAAO,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,IAAI,CAAC,MAAM,CAAC;QAC5C,IAAI,CAAC,GAAG,GAAG,MAAA,OAAO,CAAC,GAAG,mCAAI,IAAI,CAAC,GAAG,CAAC;QAEnC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF;AAhCD,oBAgCC","file":"icon.js","sourcesContent":["import { isString } from '@visactor/vutils';\nimport type { ElementOptions } from './element';\nimport { BaseElement } from './element';\nimport * as registerIcons from '../../icons';\nimport type { ColumnIconOption } from '../../ts-types';\n\ntype IconOptions = {\n width: number;\n height: number;\n svg?: string;\n iconName?: string;\n} & ElementOptions;\n\nexport class Icon extends BaseElement {\n declare id: string;\n type: 'icon' = 'icon';\n declare width: number;\n declare height: number;\n svg: string;\n iconName: string;\n cursor?: string;\n cache?: ColumnIconOption;\n\n constructor(options: IconOptions) {\n super(options);\n this.iconName = options.iconName;\n if (isString(this.iconName)) {\n const regedIcons = registerIcons.get();\n const cache = regedIcons[this.iconName];\n if (cache) {\n this.cache = cache;\n this.width = cache.width;\n this.height = cache.height;\n this.svg = (cache as any).svg;\n this.cursor = (cache as any).cursor;\n }\n }\n\n // options中的配置可以覆盖cache\n this.width = options.width ?? this.width;\n this.height = options.height ?? this.height;\n this.svg = options.svg ?? this.svg;\n\n this.initLayoutSize();\n }\n}\n"]}
1
+ {"version":3,"sources":["render/layout/icon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAA0C;AAC1C,6CAAqD;AACrD,2DAA6C;AAc7C,MAAa,IAAK,SAAQ,eAAK;IAM7B,YAAY,OAAqB;;QAC/B,IAAI,KAAK,CAAC;QACV,IAAI,IAAA,iBAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC9B,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;YACvC,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,KAAK,EAAE;gBACT,OAAO,CAAC,KAAK,GAAG,MAAA,OAAO,CAAC,KAAK,mCAAI,KAAK,CAAC,KAAK,CAAC;gBAC7C,OAAO,CAAC,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,KAAK,CAAC,MAAM,CAAC;gBAChD,OAAO,CAAC,GAAG,GAAI,KAAa,CAAC,GAAG,CAAC;gBACjC,OAAO,CAAC,MAAM,GAAI,KAAa,CAAC,MAAM,CAAC;aACxC;SACF;QACD,IAAI,OAAO,CAAC,GAAG,EAAE;YACf,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC;SAC7B;QAED,MAAM,eAAe,GAAG,IAAA,gBAAO,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG;YACd,MAAA,MAAA,OAAO,CAAC,SAAS,mCAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,CAAC;YAC9F,MAAA,MAAA,OAAO,CAAC,WAAW,mCAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,CAAC;YAChG,MAAA,MAAA,OAAO,CAAC,YAAY,mCAClB,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAChG,CAAC;YACH,MAAA,MAAA,OAAO,CAAC,UAAU,mCAChB,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAChG,CAAC;SACJ,CAAC;QACF,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAtCD,oBAsCC","file":"icon.js","sourcesContent":["import type { IImageGraphicAttribute } from '@visactor/vrender';\nimport { Image } from '@visactor/vrender';\nimport { isArray, isString } from '@visactor/vutils';\nimport * as registerIcons from '../../icons';\nimport type { ColumnIconOption } from '../../ts-types';\n\ntype IIconOptions = {\n width: number;\n height: number;\n svg?: string;\n iconName?: string;\n marginTop?: number;\n marginRight?: number;\n marginBottom?: number;\n marginLeft?: number;\n} & IImageGraphicAttribute;\n\nexport class Icon extends Image {\n declare id: string;\n svg: string;\n iconName: string;\n cache?: ColumnIconOption;\n\n constructor(options: IIconOptions) {\n let cache;\n if (isString(options.iconName)) {\n const regedIcons = registerIcons.get();\n cache = regedIcons[options.iconName];\n if (cache) {\n options.width = options.width ?? cache.width;\n options.height = options.height ?? cache.height;\n options.svg = (cache as any).svg;\n options.cursor = (cache as any).cursor;\n }\n }\n if (options.svg) {\n options.image = options.svg;\n }\n\n const isPaddingNumber = isArray(options.boundsPadding);\n const padding = [\n options.marginTop ?? (isPaddingNumber ? options.boundsPadding[0] : options.boundsPadding) ?? 0,\n options.marginRight ?? (isPaddingNumber ? options.boundsPadding[1] : options.boundsPadding) ?? 0,\n options.marginBottom ??\n (isPaddingNumber ? options.boundsPadding[2] ?? options.boundsPadding[0] : options.boundsPadding) ??\n 0,\n options.marginLeft ??\n (isPaddingNumber ? options.boundsPadding[3] ?? options.boundsPadding[1] : options.boundsPadding) ??\n 0\n ];\n options.boundsPadding = padding;\n\n super(options);\n this.cache = cache;\n }\n}\n"]}
@@ -1,21 +1,14 @@
1
- import type { ElementOptions } from './element';
2
- import { BaseElement } from './element';
3
- import type { ColumnIconOption } from '../../ts-types';
4
- type ImageOptions = {
5
- width: number;
6
- height: number;
1
+ import type { IImageGraphicAttribute } from '@visactor/vrender';
2
+ import { Image as VImage } from '@visactor/vrender';
3
+ type IImageOptions = {
7
4
  src?: string;
8
5
  shape?: 'circle' | 'square';
9
- } & ElementOptions;
10
- export declare class Image extends BaseElement {
11
- id: string;
12
- type: 'image';
13
- width: number;
14
- height: number;
15
- src: string;
16
- cursor?: string;
17
- cache?: ColumnIconOption;
18
- shape?: 'circle' | 'square';
19
- constructor(options: ImageOptions);
6
+ marginTop?: number;
7
+ marginRight?: number;
8
+ marginBottom?: number;
9
+ marginLeft?: number;
10
+ } & IImageGraphicAttribute;
11
+ export declare class Image extends VImage {
12
+ constructor(options: IImageOptions);
20
13
  }
21
14
  export {};
@@ -4,15 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Image = void 0;
6
6
 
7
- const element_1 = require("./element");
7
+ const vrender_1 = require("@visactor/vrender"), vutils_1 = require("@visactor/vutils");
8
8
 
9
- class Image extends element_1.BaseElement {
9
+ class Image extends vrender_1.Image {
10
10
  constructor(options) {
11
- var _a, _b, _c, _d;
12
- super(options), this.type = "image", this.width = null !== (_a = options.width) && void 0 !== _a ? _a : this.width,
13
- this.height = null !== (_b = options.height) && void 0 !== _b ? _b : this.height,
14
- this.src = null !== (_c = options.src) && void 0 !== _c ? _c : this.src, this.shape = null !== (_d = options.shape) && void 0 !== _d ? _d : this.shape,
15
- this.initLayoutSize();
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
12
+ options.src && (options.image = options.src), "circle" === options.shape && (options.cornerRadius = options.width / 2);
13
+ const isPaddingNumber = (0, vutils_1.isArray)(options.boundsPadding), padding = [ null !== (_b = null !== (_a = options.marginTop) && void 0 !== _a ? _a : isPaddingNumber ? options.boundsPadding[0] : options.boundsPadding) && void 0 !== _b ? _b : 0, null !== (_d = null !== (_c = options.marginRight) && void 0 !== _c ? _c : isPaddingNumber ? options.boundsPadding[1] : options.boundsPadding) && void 0 !== _d ? _d : 0, null !== (_g = null !== (_e = options.marginBottom) && void 0 !== _e ? _e : isPaddingNumber ? null !== (_f = options.boundsPadding[2]) && void 0 !== _f ? _f : options.boundsPadding[0] : options.boundsPadding) && void 0 !== _g ? _g : 0, null !== (_k = null !== (_h = options.marginLeft) && void 0 !== _h ? _h : isPaddingNumber ? null !== (_j = options.boundsPadding[3]) && void 0 !== _j ? _j : options.boundsPadding[1] : options.boundsPadding) && void 0 !== _k ? _k : 0 ];
14
+ options.boundsPadding = padding, super(options);
16
15
  }
17
16
  }
18
17
 
@@ -1 +1 @@
1
- {"version":3,"sources":["render/layout/image.ts"],"names":[],"mappings":";;;AACA,uCAAwC;AAUxC,MAAa,KAAM,SAAQ,qBAAW;IASpC,YAAY,OAAqB;;QAC/B,KAAK,CAAC,OAAO,CAAC,CAAC;QARjB,SAAI,GAAY,OAAO,CAAC;QAUtB,IAAI,CAAC,KAAK,GAAG,MAAA,OAAO,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,IAAI,CAAC,MAAM,CAAC;QAC5C,IAAI,CAAC,GAAG,GAAG,MAAA,OAAO,CAAC,GAAG,mCAAI,IAAI,CAAC,GAAG,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,MAAA,OAAO,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC;QACzC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF;AAlBD,sBAkBC","file":"image.js","sourcesContent":["import type { ElementOptions } from './element';\nimport { BaseElement } from './element';\nimport type { ColumnIconOption } from '../../ts-types';\n\ntype ImageOptions = {\n width: number;\n height: number;\n src?: string;\n shape?: 'circle' | 'square';\n} & ElementOptions;\n\nexport class Image extends BaseElement {\n declare id: string;\n type: 'image' = 'image';\n declare width: number;\n declare height: number;\n src: string;\n cursor?: string;\n cache?: ColumnIconOption;\n shape?: 'circle' | 'square';\n constructor(options: ImageOptions) {\n super(options);\n // options中的配置可以覆盖cache\n this.width = options.width ?? this.width;\n this.height = options.height ?? this.height;\n this.src = options.src ?? this.src;\n this.shape = options.shape ?? this.shape;\n this.initLayoutSize();\n }\n}\n"]}
1
+ {"version":3,"sources":["render/layout/image.ts"],"names":[],"mappings":";;;AACA,+CAAoD;AACpD,6CAA2C;AAU3C,MAAa,KAAM,SAAQ,eAAM;IAC/B,YAAY,OAAsB;;QAChC,IAAI,OAAO,CAAC,GAAG,EAAE;YACf,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC;SAC7B;QACD,IAAI,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE;YAC9B,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;SAC1C;QAED,MAAM,eAAe,GAAG,IAAA,gBAAO,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG;YACd,MAAA,MAAA,OAAO,CAAC,SAAS,mCAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,CAAC;YAC9F,MAAA,MAAA,OAAO,CAAC,WAAW,mCAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,CAAC;YAChG,MAAA,MAAA,OAAO,CAAC,YAAY,mCAClB,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAChG,CAAC;YACH,MAAA,MAAA,OAAO,CAAC,UAAU,mCAChB,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAChG,CAAC;SACJ,CAAC;QACF,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAxBD,sBAwBC","file":"image.js","sourcesContent":["import type { IImageGraphicAttribute } from '@visactor/vrender';\nimport { Image as VImage } from '@visactor/vrender';\nimport { isArray } from '@visactor/vutils';\n\ntype IImageOptions = {\n src?: string;\n shape?: 'circle' | 'square';\n marginTop?: number;\n marginRight?: number;\n marginBottom?: number;\n marginLeft?: number;\n} & IImageGraphicAttribute;\nexport class Image extends VImage {\n constructor(options: IImageOptions) {\n if (options.src) {\n options.image = options.src;\n }\n if (options.shape === 'circle') {\n options.cornerRadius = options.width / 2;\n }\n\n const isPaddingNumber = isArray(options.boundsPadding);\n const padding = [\n options.marginTop ?? (isPaddingNumber ? options.boundsPadding[0] : options.boundsPadding) ?? 0,\n options.marginRight ?? (isPaddingNumber ? options.boundsPadding[1] : options.boundsPadding) ?? 0,\n options.marginBottom ??\n (isPaddingNumber ? options.boundsPadding[2] ?? options.boundsPadding[0] : options.boundsPadding) ??\n 0,\n options.marginLeft ??\n (isPaddingNumber ? options.boundsPadding[3] ?? options.boundsPadding[1] : options.boundsPadding) ??\n 0\n ];\n options.boundsPadding = padding;\n\n super(options);\n }\n}\n"]}
@@ -7,3 +7,5 @@ export * from './rect';
7
7
  export * from './text';
8
8
  export * from './percent-calc';
9
9
  export * from './arc';
10
+ export * from './tag';
11
+ export * from './group';
@@ -21,5 +21,6 @@ Object.defineProperty(exports, "__esModule", {
21
21
  __exportStar(require("./group-element"), exports), __exportStar(require("./icon"), exports),
22
22
  __exportStar(require("./image"), exports), __exportStar(require("./rect"), exports),
23
23
  __exportStar(require("./text"), exports), __exportStar(require("./percent-calc"), exports),
24
- __exportStar(require("./arc"), exports);
24
+ __exportStar(require("./arc"), exports), __exportStar(require("./tag"), exports),
25
+ __exportStar(require("./group"), exports);
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["render/layout/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,kDAAgC;AAChC,yCAAuB;AACvB,0CAAwB;AACxB,yCAAuB;AACvB,yCAAuB;AACvB,iDAA+B;AAC/B,wCAAsB","file":"index.js","sourcesContent":["export * from './circle';\nexport * from './container';\nexport * from './group-element';\nexport * from './icon';\nexport * from './image';\nexport * from './rect';\nexport * from './text';\nexport * from './percent-calc';\nexport * from './arc';\n"]}
1
+ {"version":3,"sources":["render/layout/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,kDAAgC;AAChC,yCAAuB;AACvB,0CAAwB;AACxB,yCAAuB;AACvB,yCAAuB;AACvB,iDAA+B;AAC/B,wCAAsB;AACtB,wCAAsB;AACtB,0CAAwB","file":"index.js","sourcesContent":["export * from './circle';\nexport * from './container';\nexport * from './group-element';\nexport * from './icon';\nexport * from './image';\nexport * from './rect';\nexport * from './text';\nexport * from './percent-calc';\nexport * from './arc';\nexport * from './tag';\nexport * from './group';\n"]}
@@ -2,7 +2,4 @@ export type percentCalcObj = {
2
2
  percent: number;
3
3
  delta: number;
4
4
  };
5
- export declare function percentCalc(percent: number, delta?: number): {
6
- percent: number;
7
- delta: number;
8
- };
5
+ export declare function percentCalc(percent: number, delta?: number): percentCalcObj;
@@ -1 +1 @@
1
- {"version":3,"sources":["render/layout/percent-calc.ts"],"names":[],"mappings":";;;AAKA,SAAgB,WAAW,CAAC,OAAe,EAAE,KAAK,GAAG,CAAC;IACpD,OAAO;QACL,OAAO;QACP,KAAK;KACN,CAAC;AACJ,CAAC;AALD,kCAKC","file":"percent-calc.js","sourcesContent":["export type percentCalcObj = {\n percent: number;\n delta: number;\n};\n\nexport function percentCalc(percent: number, delta = 0) {\n return {\n percent,\n delta\n };\n}\n"]}
1
+ {"version":3,"sources":["render/layout/percent-calc.ts"],"names":[],"mappings":";;;AAKA,SAAgB,WAAW,CAAC,OAAe,EAAE,KAAK,GAAG,CAAC;IACpD,OAAO;QACL,OAAO;QACP,KAAK;KACN,CAAC;AACJ,CAAC;AALD,kCAKC","file":"percent-calc.js","sourcesContent":["export type percentCalcObj = {\n percent: number;\n delta: number;\n};\n\nexport function percentCalc(percent: number, delta = 0): percentCalcObj {\n return {\n percent,\n delta\n };\n}\n"]}
@@ -1,22 +1,12 @@
1
- import type { ElementOptions } from './element';
2
- import { BaseElement } from './element';
3
- type RectOptions = {
4
- width: number;
5
- height: number;
6
- lineWidth?: number;
7
- cornerRadius?: number;
8
- fill?: string | boolean;
9
- stroke?: string | boolean;
10
- } & ElementOptions;
11
- export declare class Rect extends BaseElement {
12
- type: 'rect';
13
- width: number;
14
- height: number;
15
- lineWidth: number;
16
- cornerRadius: number;
17
- radius: number;
18
- fill: string | boolean;
19
- stroke: string | boolean;
20
- constructor(options: RectOptions);
1
+ import type { IRectGraphicAttribute } from '@visactor/vrender';
2
+ import { Rect as VRect } from '@visactor/vrender';
3
+ type IRectOption = {
4
+ marginTop?: number;
5
+ marginRight?: number;
6
+ marginBottom?: number;
7
+ marginLeft?: number;
8
+ } & IRectGraphicAttribute;
9
+ export declare class Rect extends VRect {
10
+ constructor(options: IRectOption);
21
11
  }
22
12
  export {};
@@ -4,14 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Rect = void 0;
6
6
 
7
- const element_1 = require("./element");
7
+ const vrender_1 = require("@visactor/vrender"), vutils_1 = require("@visactor/vutils");
8
8
 
9
- class Rect extends element_1.BaseElement {
9
+ class Rect extends vrender_1.Rect {
10
10
  constructor(options) {
11
- super(options), this.type = "rect", this.width = options.width, this.height = options.height,
12
- this.lineWidth = options.lineWidth || 0, this.cornerRadius = options.cornerRadius || 0,
13
- this.radius = this.cornerRadius, this.fill = options.fill || "#777", this.stroke = options.stroke || void 0,
14
- this.initLayoutSize();
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
12
+ const isPaddingNumber = (0, vutils_1.isArray)(options.boundsPadding), padding = [ null !== (_b = null !== (_a = options.marginTop) && void 0 !== _a ? _a : isPaddingNumber ? options.boundsPadding[0] : options.boundsPadding) && void 0 !== _b ? _b : 0, null !== (_d = null !== (_c = options.marginRight) && void 0 !== _c ? _c : isPaddingNumber ? options.boundsPadding[1] : options.boundsPadding) && void 0 !== _d ? _d : 0, null !== (_g = null !== (_e = options.marginBottom) && void 0 !== _e ? _e : isPaddingNumber ? null !== (_f = options.boundsPadding[2]) && void 0 !== _f ? _f : options.boundsPadding[0] : options.boundsPadding) && void 0 !== _g ? _g : 0, null !== (_k = null !== (_h = options.marginLeft) && void 0 !== _h ? _h : isPaddingNumber ? null !== (_j = options.boundsPadding[3]) && void 0 !== _j ? _j : options.boundsPadding[1] : options.boundsPadding) && void 0 !== _k ? _k : 0 ];
13
+ options.boundsPadding = padding, super(options);
15
14
  }
16
15
  }
17
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["render/layout/rect.ts"],"names":[],"mappings":";;;AACA,uCAAwC;AAWxC,MAAa,IAAK,SAAQ,qBAAW;IAUnC,YAAY,OAAoB;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAVjB,SAAI,GAAW,MAAM,CAAC;QAWpB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC;QAE1C,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF;AAtBD,oBAsBC","file":"rect.js","sourcesContent":["import type { ElementOptions } from './element';\nimport { BaseElement } from './element';\n\ntype RectOptions = {\n width: number;\n height: number;\n lineWidth?: number;\n cornerRadius?: number;\n fill?: string | boolean;\n stroke?: string | boolean;\n} & ElementOptions;\n\nexport class Rect extends BaseElement {\n type: 'rect' = 'rect';\n declare width: number;\n declare height: number;\n lineWidth: number;\n cornerRadius: number;\n radius: number;\n fill: string | boolean;\n stroke: string | boolean;\n\n constructor(options: RectOptions) {\n super(options);\n this.width = options.width;\n this.height = options.height;\n this.lineWidth = options.lineWidth || 0;\n this.cornerRadius = options.cornerRadius || 0;\n this.radius = this.cornerRadius;\n this.fill = options.fill || '#777';\n this.stroke = options.stroke || undefined;\n\n this.initLayoutSize();\n }\n}\n"]}
1
+ {"version":3,"sources":["render/layout/rect.ts"],"names":[],"mappings":";;;AACA,+CAAkD;AAClD,6CAA2C;AAS3C,MAAa,IAAK,SAAQ,cAAK;IAC7B,YAAY,OAAoB;;QAC9B,MAAM,eAAe,GAAG,IAAA,gBAAO,EAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG;YACd,MAAA,MAAA,OAAO,CAAC,SAAS,mCAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,CAAC;YAC9F,MAAA,MAAA,OAAO,CAAC,WAAW,mCAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,CAAC;YAChG,MAAA,MAAA,OAAO,CAAC,YAAY,mCAClB,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAChG,CAAC;YACH,MAAA,MAAA,OAAO,CAAC,UAAU,mCAChB,CAAC,eAAe,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,mCAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,mCAChG,CAAC;SACJ,CAAC;QACF,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC;QAEhC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAjBD,oBAiBC","file":"rect.js","sourcesContent":["import type { IRectGraphicAttribute } from '@visactor/vrender';\nimport { Rect as VRect } from '@visactor/vrender';\nimport { isArray } from '@visactor/vutils';\n\ntype IRectOption = {\n marginTop?: number;\n marginRight?: number;\n marginBottom?: number;\n marginLeft?: number;\n} & IRectGraphicAttribute;\n\nexport class Rect extends VRect {\n constructor(options: IRectOption) {\n const isPaddingNumber = isArray(options.boundsPadding);\n const padding = [\n options.marginTop ?? (isPaddingNumber ? options.boundsPadding[0] : options.boundsPadding) ?? 0,\n options.marginRight ?? (isPaddingNumber ? options.boundsPadding[1] : options.boundsPadding) ?? 0,\n options.marginBottom ??\n (isPaddingNumber ? options.boundsPadding[2] ?? options.boundsPadding[0] : options.boundsPadding) ??\n 0,\n options.marginLeft ??\n (isPaddingNumber ? options.boundsPadding[3] ?? options.boundsPadding[1] : options.boundsPadding) ??\n 0\n ];\n options.boundsPadding = padding;\n\n super(options);\n }\n}\n"]}