@antv/infographic 0.2.11 → 0.2.13

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 (328) hide show
  1. package/dist/infographic.min.js +98 -94
  2. package/dist/infographic.min.js.map +1 -1
  3. package/esm/designs/components/Btn.js +15 -4
  4. package/esm/designs/components/BtnsGroup.js +1 -1
  5. package/esm/designs/components/Illus.js +15 -3
  6. package/esm/designs/components/ItemDesc.js +17 -11
  7. package/esm/designs/components/ItemIcon.js +17 -18
  8. package/esm/designs/components/ItemLabel.js +17 -11
  9. package/esm/designs/components/ItemValue.js +17 -12
  10. package/esm/designs/components/ItemsGroup.js +1 -1
  11. package/esm/designs/components/ShapesGroup.js +1 -1
  12. package/esm/designs/components/Title.js +2 -2
  13. package/esm/designs/decorations/simple-arrow.js +14 -2
  14. package/esm/designs/decorations/triangle.js +14 -2
  15. package/esm/designs/defs/DropShadow.js +13 -2
  16. package/esm/designs/defs/LinearGradient.js +1 -1
  17. package/esm/designs/items/BadgeCard.js +2 -2
  18. package/esm/designs/items/CandyCardLite.js +1 -1
  19. package/esm/designs/items/CapsuleItem.js +3 -3
  20. package/esm/designs/items/CircleNode.js +1 -1
  21. package/esm/designs/items/CircularProgress.js +3 -2
  22. package/esm/designs/items/CompactCard.js +1 -1
  23. package/esm/designs/items/DoneList.js +1 -1
  24. package/esm/designs/items/HorizontalIconArrow.js +2 -2
  25. package/esm/designs/items/HorizontalIconLine.js +2 -2
  26. package/esm/designs/items/IconBadge.js +4 -3
  27. package/esm/designs/items/IndexedCard.js +1 -1
  28. package/esm/designs/items/LCornerCard.js +1 -1
  29. package/esm/designs/items/LetterCard.js +4 -3
  30. package/esm/designs/items/LinedText.js +6 -5
  31. package/esm/designs/items/PillBadge.js +2 -2
  32. package/esm/designs/items/PlainText.js +4 -4
  33. package/esm/designs/items/ProgressCard.js +4 -4
  34. package/esm/designs/items/QuarterCircular.js +1 -1
  35. package/esm/designs/items/QuarterSimpleCard.js +1 -1
  36. package/esm/designs/items/RibbonCard.js +2 -2
  37. package/esm/designs/items/RoundedRectNode.js +2 -2
  38. package/esm/designs/items/SimpleCircleNode.js +1 -1
  39. package/esm/designs/items/SimpleHorizontalArrow.js +2 -2
  40. package/esm/designs/items/SimpleIllusItem.js +1 -1
  41. package/esm/designs/items/SimpleItem.js +3 -3
  42. package/esm/designs/items/SimpleVerticalArrow.js +2 -2
  43. package/esm/designs/items/UnderlineText.js +1 -1
  44. package/esm/designs/items/VerticalIconArrow.js +2 -2
  45. package/esm/designs/layouts/Align.js +22 -15
  46. package/esm/designs/layouts/Flex.js +23 -16
  47. package/esm/designs/structures/chart-bar.js +7 -5
  48. package/esm/designs/structures/chart-column.js +3 -2
  49. package/esm/designs/structures/chart-line.js +7 -5
  50. package/esm/designs/structures/chart-pie.d.ts +25 -0
  51. package/esm/designs/structures/chart-pie.js +186 -26
  52. package/esm/designs/structures/chart-wordcloud.js +5 -14
  53. package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
  54. package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
  55. package/esm/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
  56. package/esm/designs/structures/compare-hierarchy-left-right.js +6 -5
  57. package/esm/designs/structures/compare-hierarchy-row.js +3 -2
  58. package/esm/designs/structures/compare-quadrant.js +2 -3
  59. package/esm/designs/structures/hierarchy-mindmap.js +19 -19
  60. package/esm/designs/structures/hierarchy-structure.js +1 -1
  61. package/esm/designs/structures/hierarchy-tree.js +15 -24
  62. package/esm/designs/structures/list-sector.js +5 -6
  63. package/esm/designs/structures/list-zigzag.js +2 -1
  64. package/esm/designs/structures/relation-dagre-flow.js +30 -35
  65. package/esm/designs/structures/relation-network.js +2 -2
  66. package/esm/designs/structures/sequence-funnel.js +1 -1
  67. package/esm/designs/structures/sequence-mountain.js +4 -4
  68. package/esm/designs/structures/sequence-pyramid.js +1 -1
  69. package/esm/designs/structures/sequence-zigzag-steps.js +2 -1
  70. package/esm/designs/utils/color.js +8 -4
  71. package/esm/designs/utils/index.d.ts +1 -0
  72. package/esm/designs/utils/index.js +1 -0
  73. package/esm/designs/utils/item.js +3 -2
  74. package/esm/designs/utils/normalize-percent.d.ts +19 -0
  75. package/esm/designs/utils/normalize-percent.js +32 -0
  76. package/esm/editor/commands/Batch.js +21 -8
  77. package/esm/editor/commands/UpdateElement.js +25 -22
  78. package/esm/editor/commands/UpdateOptions.js +23 -10
  79. package/esm/editor/commands/UpdateText.js +24 -11
  80. package/esm/editor/interactions/brush-select.js +27 -13
  81. package/esm/editor/interactions/click-select.js +13 -3
  82. package/esm/editor/interactions/dblclick-edit-text.js +36 -20
  83. package/esm/editor/interactions/drag-element.js +23 -9
  84. package/esm/editor/interactions/hotkey-history.js +17 -7
  85. package/esm/editor/interactions/select-highlight.js +5 -9
  86. package/esm/editor/interactions/zoom-wheel.d.ts +3 -0
  87. package/esm/editor/interactions/zoom-wheel.js +46 -22
  88. package/esm/editor/managers/command.js +45 -27
  89. package/esm/editor/managers/interaction.js +46 -33
  90. package/esm/editor/managers/state.js +9 -3
  91. package/esm/editor/plugins/edit-bar/components/color-picker.js +9 -6
  92. package/esm/editor/plugins/edit-bar/components/popover.js +15 -12
  93. package/esm/editor/plugins/edit-bar/components/select.js +10 -8
  94. package/esm/editor/plugins/edit-bar/edit-bar.js +7 -25
  95. package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
  96. package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  97. package/esm/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
  98. package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
  99. package/esm/editor/plugins/resize-element.js +6 -4
  100. package/esm/editor/utils/click-handler.js +6 -3
  101. package/esm/editor/utils/coordinate.js +2 -1
  102. package/esm/editor/utils/element.js +2 -1
  103. package/esm/editor/utils/event.js +2 -1
  104. package/esm/editor/utils/extension.js +1 -1
  105. package/esm/editor/utils/hotkey.js +2 -1
  106. package/esm/exporter/font.js +106 -90
  107. package/esm/exporter/png.js +49 -37
  108. package/esm/exporter/svg.js +55 -38
  109. package/esm/jsx/components/Ellipse.js +5 -4
  110. package/esm/jsx/components/Path.js +2 -4
  111. package/esm/jsx/components/Polygon.js +15 -6
  112. package/esm/jsx/components/Text.js +21 -41
  113. package/esm/jsx/renderer.js +15 -7
  114. package/esm/jsx/utils/bounds.js +18 -16
  115. package/esm/jsx/utils/children.js +2 -1
  116. package/esm/jsx/utils/clone.js +13 -2
  117. package/esm/jsx/utils/element.js +2 -1
  118. package/esm/options/parser.js +45 -46
  119. package/esm/renderer/composites/background.js +3 -2
  120. package/esm/renderer/composites/icon.js +14 -19
  121. package/esm/renderer/composites/illus.js +17 -22
  122. package/esm/renderer/composites/shape.js +4 -2
  123. package/esm/renderer/composites/svg.js +2 -1
  124. package/esm/renderer/composites/text.js +5 -3
  125. package/esm/renderer/fonts/loader.js +4 -3
  126. package/esm/renderer/fonts/registry.js +1 -1
  127. package/esm/renderer/palettes/utils.js +3 -2
  128. package/esm/renderer/renderer.js +7 -5
  129. package/esm/renderer/stylize/gradient.js +3 -2
  130. package/esm/renderer/stylize/pattern.js +15 -8
  131. package/esm/renderer/stylize/rough.js +1 -1
  132. package/esm/resource/load-tracker.js +22 -10
  133. package/esm/resource/loader.js +80 -67
  134. package/esm/resource/loaders/image.js +71 -59
  135. package/esm/resource/loaders/remote.js +26 -15
  136. package/esm/resource/loaders/search.js +38 -25
  137. package/esm/resource/utils/parser.js +2 -1
  138. package/esm/runtime/Infographic.js +26 -13
  139. package/esm/runtime/utils.js +5 -8
  140. package/esm/ssr/renderer.js +42 -35
  141. package/esm/syntax/index.js +19 -6
  142. package/esm/syntax/mapper.js +2 -2
  143. package/esm/templates/built-in.js +91 -269
  144. package/esm/templates/chart-pie.d.ts +2 -0
  145. package/esm/templates/chart-pie.js +87 -0
  146. package/esm/templates/hierarchy-mindmap.js +1 -5
  147. package/esm/templates/hierarchy-tree.js +1 -5
  148. package/esm/templates/relation-dagre-flow.js +4 -28
  149. package/esm/themes/generator.js +8 -14
  150. package/esm/utils/fetch.js +48 -35
  151. package/esm/utils/icon.js +1 -4
  152. package/esm/utils/is-browser.js +2 -2
  153. package/esm/utils/measure-text.js +2 -1
  154. package/esm/utils/padding.js +1 -1
  155. package/esm/utils/recognizer.js +2 -1
  156. package/esm/utils/text.js +14 -3
  157. package/esm/utils/viewbox.d.ts +20 -0
  158. package/esm/utils/viewbox.js +10 -0
  159. package/esm/version.d.ts +1 -1
  160. package/esm/version.js +1 -1
  161. package/lib/designs/components/Btn.js +15 -4
  162. package/lib/designs/components/BtnsGroup.js +1 -1
  163. package/lib/designs/components/Illus.js +15 -3
  164. package/lib/designs/components/ItemDesc.js +17 -11
  165. package/lib/designs/components/ItemIcon.js +17 -18
  166. package/lib/designs/components/ItemLabel.js +17 -11
  167. package/lib/designs/components/ItemValue.js +17 -12
  168. package/lib/designs/components/ItemsGroup.js +1 -1
  169. package/lib/designs/components/ShapesGroup.js +1 -1
  170. package/lib/designs/components/Title.js +2 -2
  171. package/lib/designs/decorations/simple-arrow.js +14 -2
  172. package/lib/designs/decorations/triangle.js +14 -2
  173. package/lib/designs/defs/DropShadow.js +13 -2
  174. package/lib/designs/defs/LinearGradient.js +1 -1
  175. package/lib/designs/items/BadgeCard.js +2 -2
  176. package/lib/designs/items/CandyCardLite.js +1 -1
  177. package/lib/designs/items/CapsuleItem.js +3 -3
  178. package/lib/designs/items/CircleNode.js +1 -1
  179. package/lib/designs/items/CircularProgress.js +3 -2
  180. package/lib/designs/items/CompactCard.js +1 -1
  181. package/lib/designs/items/DoneList.js +1 -1
  182. package/lib/designs/items/HorizontalIconArrow.js +2 -2
  183. package/lib/designs/items/HorizontalIconLine.js +2 -2
  184. package/lib/designs/items/IconBadge.js +4 -3
  185. package/lib/designs/items/IndexedCard.js +1 -1
  186. package/lib/designs/items/LCornerCard.js +1 -1
  187. package/lib/designs/items/LetterCard.js +4 -3
  188. package/lib/designs/items/LinedText.js +6 -5
  189. package/lib/designs/items/PillBadge.js +2 -2
  190. package/lib/designs/items/PlainText.js +4 -4
  191. package/lib/designs/items/ProgressCard.js +4 -4
  192. package/lib/designs/items/QuarterCircular.js +1 -1
  193. package/lib/designs/items/QuarterSimpleCard.js +1 -1
  194. package/lib/designs/items/RibbonCard.js +2 -2
  195. package/lib/designs/items/RoundedRectNode.js +2 -2
  196. package/lib/designs/items/SimpleCircleNode.js +1 -1
  197. package/lib/designs/items/SimpleHorizontalArrow.js +2 -2
  198. package/lib/designs/items/SimpleIllusItem.js +1 -1
  199. package/lib/designs/items/SimpleItem.js +3 -3
  200. package/lib/designs/items/SimpleVerticalArrow.js +2 -2
  201. package/lib/designs/items/UnderlineText.js +1 -1
  202. package/lib/designs/items/VerticalIconArrow.js +2 -2
  203. package/lib/designs/layouts/Align.js +22 -15
  204. package/lib/designs/layouts/Flex.js +23 -16
  205. package/lib/designs/structures/chart-bar.js +7 -5
  206. package/lib/designs/structures/chart-column.js +3 -2
  207. package/lib/designs/structures/chart-line.js +7 -5
  208. package/lib/designs/structures/chart-pie.d.ts +25 -0
  209. package/lib/designs/structures/chart-pie.js +186 -25
  210. package/lib/designs/structures/chart-wordcloud.js +5 -14
  211. package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
  212. package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
  213. package/lib/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
  214. package/lib/designs/structures/compare-hierarchy-left-right.js +6 -5
  215. package/lib/designs/structures/compare-hierarchy-row.js +3 -2
  216. package/lib/designs/structures/compare-quadrant.js +2 -3
  217. package/lib/designs/structures/hierarchy-mindmap.js +19 -19
  218. package/lib/designs/structures/hierarchy-structure.js +1 -1
  219. package/lib/designs/structures/hierarchy-tree.js +15 -24
  220. package/lib/designs/structures/list-sector.js +5 -6
  221. package/lib/designs/structures/list-zigzag.js +2 -1
  222. package/lib/designs/structures/relation-dagre-flow.js +30 -35
  223. package/lib/designs/structures/relation-network.js +2 -2
  224. package/lib/designs/structures/sequence-funnel.js +1 -1
  225. package/lib/designs/structures/sequence-mountain.js +4 -4
  226. package/lib/designs/structures/sequence-pyramid.js +1 -1
  227. package/lib/designs/structures/sequence-zigzag-steps.js +2 -1
  228. package/lib/designs/utils/color.js +8 -4
  229. package/lib/designs/utils/index.d.ts +1 -0
  230. package/lib/designs/utils/index.js +1 -0
  231. package/lib/designs/utils/item.js +3 -2
  232. package/lib/designs/utils/normalize-percent.d.ts +19 -0
  233. package/lib/designs/utils/normalize-percent.js +35 -0
  234. package/lib/editor/commands/Batch.js +21 -8
  235. package/lib/editor/commands/UpdateElement.js +25 -22
  236. package/lib/editor/commands/UpdateOptions.js +23 -10
  237. package/lib/editor/commands/UpdateText.js +24 -11
  238. package/lib/editor/interactions/brush-select.js +27 -13
  239. package/lib/editor/interactions/click-select.js +13 -3
  240. package/lib/editor/interactions/dblclick-edit-text.js +36 -20
  241. package/lib/editor/interactions/drag-element.js +23 -9
  242. package/lib/editor/interactions/hotkey-history.js +17 -7
  243. package/lib/editor/interactions/select-highlight.js +5 -9
  244. package/lib/editor/interactions/zoom-wheel.d.ts +3 -0
  245. package/lib/editor/interactions/zoom-wheel.js +45 -21
  246. package/lib/editor/managers/command.js +43 -25
  247. package/lib/editor/managers/interaction.js +46 -33
  248. package/lib/editor/managers/state.js +9 -3
  249. package/lib/editor/plugins/edit-bar/components/color-picker.js +9 -6
  250. package/lib/editor/plugins/edit-bar/components/popover.js +15 -12
  251. package/lib/editor/plugins/edit-bar/components/select.js +10 -8
  252. package/lib/editor/plugins/edit-bar/edit-bar.js +7 -25
  253. package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
  254. package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  255. package/lib/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
  256. package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
  257. package/lib/editor/plugins/resize-element.js +6 -4
  258. package/lib/editor/utils/click-handler.js +6 -3
  259. package/lib/editor/utils/coordinate.js +2 -1
  260. package/lib/editor/utils/element.js +2 -1
  261. package/lib/editor/utils/event.js +2 -1
  262. package/lib/editor/utils/extension.js +1 -1
  263. package/lib/editor/utils/hotkey.js +2 -1
  264. package/lib/exporter/font.js +106 -90
  265. package/lib/exporter/png.js +49 -37
  266. package/lib/exporter/svg.js +55 -38
  267. package/lib/jsx/components/Ellipse.js +5 -4
  268. package/lib/jsx/components/Path.js +2 -4
  269. package/lib/jsx/components/Polygon.js +15 -6
  270. package/lib/jsx/components/Text.js +21 -41
  271. package/lib/jsx/renderer.js +15 -7
  272. package/lib/jsx/utils/bounds.js +18 -16
  273. package/lib/jsx/utils/children.js +2 -1
  274. package/lib/jsx/utils/clone.js +13 -2
  275. package/lib/jsx/utils/element.js +2 -1
  276. package/lib/options/parser.js +45 -46
  277. package/lib/renderer/composites/background.js +3 -2
  278. package/lib/renderer/composites/icon.js +14 -19
  279. package/lib/renderer/composites/illus.js +17 -22
  280. package/lib/renderer/composites/shape.js +4 -2
  281. package/lib/renderer/composites/svg.js +2 -1
  282. package/lib/renderer/composites/text.js +5 -3
  283. package/lib/renderer/fonts/loader.js +4 -3
  284. package/lib/renderer/fonts/registry.js +1 -1
  285. package/lib/renderer/palettes/utils.js +3 -2
  286. package/lib/renderer/renderer.js +7 -5
  287. package/lib/renderer/stylize/gradient.js +3 -2
  288. package/lib/renderer/stylize/pattern.js +15 -8
  289. package/lib/renderer/stylize/rough.js +1 -1
  290. package/lib/resource/load-tracker.js +22 -10
  291. package/lib/resource/loader.js +80 -67
  292. package/lib/resource/loaders/image.js +71 -59
  293. package/lib/resource/loaders/remote.js +26 -15
  294. package/lib/resource/loaders/search.js +38 -25
  295. package/lib/resource/utils/parser.js +2 -1
  296. package/lib/runtime/Infographic.js +26 -13
  297. package/lib/runtime/utils.js +5 -8
  298. package/lib/ssr/renderer.js +42 -35
  299. package/lib/syntax/index.js +19 -6
  300. package/lib/syntax/mapper.js +2 -2
  301. package/lib/templates/built-in.js +91 -269
  302. package/lib/templates/chart-pie.d.ts +2 -0
  303. package/lib/templates/chart-pie.js +90 -0
  304. package/lib/templates/hierarchy-mindmap.js +1 -5
  305. package/lib/templates/hierarchy-tree.js +1 -5
  306. package/lib/templates/relation-dagre-flow.js +4 -28
  307. package/lib/themes/generator.js +8 -14
  308. package/lib/utils/fetch.js +48 -35
  309. package/lib/utils/icon.js +1 -4
  310. package/lib/utils/is-browser.js +2 -2
  311. package/lib/utils/measure-text.js +2 -1
  312. package/lib/utils/padding.js +1 -1
  313. package/lib/utils/recognizer.js +2 -1
  314. package/lib/utils/text.js +14 -3
  315. package/lib/utils/viewbox.d.ts +20 -0
  316. package/lib/utils/viewbox.js +12 -0
  317. package/lib/version.d.ts +1 -1
  318. package/lib/version.js +1 -1
  319. package/package.json +1 -2
  320. package/src/designs/structures/chart-pie.tsx +259 -26
  321. package/src/designs/utils/index.ts +1 -0
  322. package/src/designs/utils/normalize-percent.ts +33 -0
  323. package/src/editor/interactions/zoom-wheel.ts +64 -22
  324. package/src/editor/managers/state.ts +10 -5
  325. package/src/templates/built-in.ts +2 -81
  326. package/src/templates/chart-pie.ts +89 -0
  327. package/src/utils/viewbox.ts +23 -0
  328. package/src/version.ts +1 -1
@@ -0,0 +1,2 @@
1
+ import type { TemplateOptions } from './types';
2
+ export declare const chartPieTemplates: Record<string, TemplateOptions>;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chartPieTemplates = void 0;
4
+ exports.chartPieTemplates = {
5
+ 'chart-pie-plain-text': {
6
+ design: {
7
+ title: 'default',
8
+ structure: {
9
+ type: 'chart-pie',
10
+ },
11
+ items: [
12
+ {
13
+ type: 'plain-text',
14
+ },
15
+ ],
16
+ },
17
+ },
18
+ 'chart-pie-compact-card': {
19
+ design: {
20
+ title: 'default',
21
+ structure: {
22
+ type: 'chart-pie',
23
+ avoidLabelOverlap: true,
24
+ },
25
+ items: [
26
+ {
27
+ type: 'compact-card',
28
+ },
29
+ ],
30
+ },
31
+ },
32
+ 'chart-pie-pill-badge': {
33
+ design: {
34
+ title: 'default',
35
+ structure: {
36
+ type: 'chart-pie',
37
+ avoidLabelOverlap: true,
38
+ },
39
+ items: [
40
+ {
41
+ type: 'pill-badge',
42
+ },
43
+ ],
44
+ },
45
+ },
46
+ 'chart-pie-donut-plain-text': {
47
+ design: {
48
+ title: 'default',
49
+ structure: {
50
+ type: 'chart-pie',
51
+ innerRadius: 90,
52
+ },
53
+ items: [
54
+ {
55
+ type: 'plain-text',
56
+ },
57
+ ],
58
+ },
59
+ },
60
+ 'chart-pie-donut-compact-card': {
61
+ design: {
62
+ title: 'default',
63
+ structure: {
64
+ type: 'chart-pie',
65
+ innerRadius: 90,
66
+ avoidLabelOverlap: true,
67
+ },
68
+ items: [
69
+ {
70
+ type: 'compact-card',
71
+ },
72
+ ],
73
+ },
74
+ },
75
+ 'chart-pie-donut-pill-badge': {
76
+ design: {
77
+ title: 'default',
78
+ structure: {
79
+ type: 'chart-pie',
80
+ innerRadius: 90,
81
+ avoidLabelOverlap: true,
82
+ },
83
+ items: [
84
+ {
85
+ type: 'pill-badge',
86
+ },
87
+ ],
88
+ },
89
+ },
90
+ };
@@ -36,11 +36,7 @@ const ROUNDED_RECT_NODE = {
36
36
  const COMPACT_CARD = {
37
37
  type: 'compact-card',
38
38
  };
39
- const createStructure = (gradient, edgeAlign) => ({
40
- type: 'hierarchy-mindmap',
41
- ...(edgeAlign !== undefined ? { edgeAlign } : {}),
42
- ...gradient,
43
- });
39
+ const createStructure = (gradient, edgeAlign) => (Object.assign(Object.assign({ type: 'hierarchy-mindmap' }, (edgeAlign !== undefined ? { edgeAlign } : {})), gradient));
44
40
  const createTemplate = (key, gradient, item, edgeAlign) => [
45
41
  key,
46
42
  {
@@ -67,11 +67,7 @@ for (const item of items) {
67
67
  const templateName = createTemplateName(key, name, item);
68
68
  exports.hierarchyTreeTemplates[templateName] = {
69
69
  design: {
70
- structure: {
71
- type: 'hierarchy-tree',
72
- ...(orientation ? { orientation } : {}),
73
- ...structureProps,
74
- },
70
+ structure: Object.assign(Object.assign({ type: 'hierarchy-tree' }, (orientation ? { orientation } : {})), structureProps),
75
71
  item: {
76
72
  type: item,
77
73
  },
@@ -23,34 +23,10 @@ const baseStructureAttrs = {
23
23
  colorMode: 'node',
24
24
  };
25
25
  const structures = {
26
- tb: {
27
- ...baseStructureAttrs,
28
- rankdir: 'TB',
29
- edgeRouting: 'orth',
30
- },
31
- lr: {
32
- ...baseStructureAttrs,
33
- rankdir: 'LR',
34
- edgeRouting: 'orth',
35
- },
36
- 'tb-animated': {
37
- ...baseStructureAttrs,
38
- rankdir: 'TB',
39
- edgeCornerRadius: 12,
40
- edgeRouting: 'orth',
41
- edgeAnimation: 'ant-line',
42
- edgeDashPattern: '8,4',
43
- edgeAnimationSpeed: 1,
44
- },
45
- 'lr-animated': {
46
- ...baseStructureAttrs,
47
- rankdir: 'LR',
48
- edgeCornerRadius: 12,
49
- edgeRouting: 'orth',
50
- edgeAnimation: 'ant-line',
51
- edgeDashPattern: '8,4',
52
- edgeAnimationSpeed: 1,
53
- },
26
+ tb: Object.assign(Object.assign({}, baseStructureAttrs), { rankdir: 'TB', edgeRouting: 'orth' }),
27
+ lr: Object.assign(Object.assign({}, baseStructureAttrs), { rankdir: 'LR', edgeRouting: 'orth' }),
28
+ 'tb-animated': Object.assign(Object.assign({}, baseStructureAttrs), { rankdir: 'TB', edgeCornerRadius: 12, edgeRouting: 'orth', edgeAnimation: 'ant-line', edgeDashPattern: '8,4', edgeAnimationSpeed: 1 }),
29
+ 'lr-animated': Object.assign(Object.assign({}, baseStructureAttrs), { rankdir: 'LR', edgeCornerRadius: 12, edgeRouting: 'orth', edgeAnimation: 'ant-line', edgeDashPattern: '8,4', edgeAnimationSpeed: 1 }),
54
30
  };
55
31
  exports.relationDagreFlowTemplates = {};
56
32
  const omit = ['lr-capsule', 'tb-capsule'];
@@ -15,7 +15,7 @@ const generateThemeColors = ({ colorPrimary, colorBg = '#ffffff', isDarkMode = f
15
15
  };
16
16
  exports.generateThemeColors = generateThemeColors;
17
17
  const generatePrimaryBg = (primaryColor, isDarkMode) => {
18
- return ((0, culori_1.formatHex8)({ ...primaryColor, alpha: isDarkMode ? 0.2 : 0.1 }) || '#ffffff');
18
+ return ((0, culori_1.formatHex8)(Object.assign(Object.assign({}, primaryColor), { alpha: isDarkMode ? 0.2 : 0.1 })) || '#ffffff');
19
19
  };
20
20
  const generateTextColor = (bgColor, isDarkMode) => {
21
21
  if (isDarkMode) {
@@ -27,7 +27,7 @@ const generateTextColor = (bgColor, isDarkMode) => {
27
27
  };
28
28
  const generateSecondaryTextColor = (colorText) => {
29
29
  const parsed = (0, culori_1.oklch)((0, culori_1.parse)(colorText));
30
- const lighter = { ...parsed, l: Math.min(1, parsed.l + 0.2) };
30
+ const lighter = Object.assign(Object.assign({}, parsed), { l: Math.min(1, parsed.l + 0.2) });
31
31
  return (0, culori_1.formatHex)(lighter);
32
32
  };
33
33
  const generatePrimaryTextColor = (colorPrimaryBg, isDarkMode) => {
@@ -50,7 +50,7 @@ const generatePrimaryTextColor = (colorPrimaryBg, isDarkMode) => {
50
50
  const generateElevatedBg = (bgColor, isDarkMode) => {
51
51
  const parsed = (0, culori_1.oklch)(bgColor);
52
52
  if (isDarkMode) {
53
- const lightened = { ...parsed, l: Math.min(1, parsed.l + 0.1) };
53
+ const lightened = Object.assign(Object.assign({}, parsed), { l: Math.min(1, parsed.l + 0.1) });
54
54
  return safeFormatHex(lightened, '#1f1f1f');
55
55
  }
56
56
  else {
@@ -58,7 +58,7 @@ const generateElevatedBg = (bgColor, isDarkMode) => {
58
58
  return '#ffffff';
59
59
  }
60
60
  else {
61
- const lightened = { ...parsed, l: Math.min(1, parsed.l + 0.05) };
61
+ const lightened = Object.assign(Object.assign({}, parsed), { l: Math.min(1, parsed.l + 0.05) });
62
62
  return safeFormatHex(lightened, '#ffffff');
63
63
  }
64
64
  }
@@ -71,16 +71,10 @@ const createBaseTheme = ({ primaryColor, bgColor, }) => ({
71
71
  const addDerivedColors = (baseTheme, { primaryColor, bgColor, isDarkMode, }) => {
72
72
  const textColor = generateTextColor(bgColor, isDarkMode);
73
73
  const colorPrimaryBg = generatePrimaryBg(primaryColor, isDarkMode);
74
- return {
75
- ...baseTheme,
76
- isDarkMode,
77
- colorPrimaryBg,
78
- colorText: textColor,
79
- colorTextSecondary: generateSecondaryTextColor(textColor),
80
- colorPrimaryText: generatePrimaryTextColor(colorPrimaryBg, isDarkMode),
81
- colorBgElevated: generateElevatedBg(bgColor, isDarkMode),
82
- };
74
+ return Object.assign(Object.assign({}, baseTheme), { isDarkMode,
75
+ colorPrimaryBg, colorText: textColor, colorTextSecondary: generateSecondaryTextColor(textColor), colorPrimaryText: generatePrimaryTextColor(colorPrimaryBg, isDarkMode), colorBgElevated: generateElevatedBg(bgColor, isDarkMode) });
83
76
  };
84
77
  function safeFormatHex(color, fallback = '#000000') {
85
- return (0, culori_1.formatHex)(color) ?? fallback;
78
+ var _a;
79
+ return (_a = (0, culori_1.formatHex)(color)) !== null && _a !== void 0 ? _a : fallback;
86
80
  }
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -27,41 +36,45 @@ function buildCacheKey(request) {
27
36
  function buildResponse(entry) {
28
37
  return new Response(entry.body.slice(0), entry.init);
29
38
  }
30
- async function fetchAndCache(request, key) {
31
- try {
32
- const response = await nativeFetch(request);
33
- const body = await response.arrayBuffer();
34
- const entry = {
35
- body,
36
- init: {
37
- status: response.status,
38
- statusText: response.statusText,
39
- headers: Array.from(response.headers.entries()),
40
- },
41
- };
42
- if (response.ok) {
43
- responseCache.set(key, entry);
39
+ function fetchAndCache(request, key) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ try {
42
+ const response = yield nativeFetch(request);
43
+ const body = yield response.arrayBuffer();
44
+ const entry = {
45
+ body,
46
+ init: {
47
+ status: response.status,
48
+ statusText: response.statusText,
49
+ headers: Array.from(response.headers.entries()),
50
+ },
51
+ };
52
+ if (response.ok) {
53
+ responseCache.set(key, entry);
54
+ }
55
+ return entry;
56
+ }
57
+ finally {
58
+ pendingRequests.delete(key);
44
59
  }
45
- return entry;
46
- }
47
- finally {
48
- pendingRequests.delete(key);
49
- }
60
+ });
50
61
  }
51
- async function fetchWithCache(input, init) {
52
- const request = new Request(input, init);
53
- if (request.method !== 'GET') {
54
- return nativeFetch(request);
55
- }
56
- const key = buildCacheKey(request);
57
- if (responseCache.has(key)) {
58
- return buildResponse(responseCache.get(key));
59
- }
60
- let pending = pendingRequests.get(key);
61
- if (!pending) {
62
- pending = fetchAndCache(request, key);
63
- pendingRequests.set(key, pending);
64
- }
65
- const entry = await pending;
66
- return buildResponse(entry);
62
+ function fetchWithCache(input, init) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const request = new Request(input, init);
65
+ if (request.method !== 'GET') {
66
+ return nativeFetch(request);
67
+ }
68
+ const key = buildCacheKey(request);
69
+ if (responseCache.has(key)) {
70
+ return buildResponse(responseCache.get(key));
71
+ }
72
+ let pending = pendingRequests.get(key);
73
+ if (!pending) {
74
+ pending = fetchAndCache(request, key);
75
+ pendingRequests.set(key, pending);
76
+ }
77
+ const entry = yield pending;
78
+ return buildResponse(entry);
79
+ });
67
80
  }
package/lib/utils/icon.js CHANGED
@@ -13,10 +13,7 @@ function getIconResourceConfig(icon) {
13
13
  return ICON_RESOURCE_CACHE.get(icon) || null;
14
14
  }
15
15
  function createIconElement(value, attrs = {}) {
16
- const icon = (0, svg_1.createElement)('use', {
17
- ...attrs,
18
- href: (0, resource_1.getResourceHref)(value),
19
- });
16
+ const icon = (0, svg_1.createElement)('use', Object.assign(Object.assign({}, attrs), { href: (0, resource_1.getResourceHref)(value) }));
20
17
  applyIconColor(icon);
21
18
  ICON_RESOURCE_CACHE.set(icon, value);
22
19
  return icon;
@@ -36,7 +36,7 @@ function isBrowser() {
36
36
  rect.left !== 0 &&
37
37
  rect.top !== 0;
38
38
  }
39
- catch {
39
+ catch (_a) {
40
40
  hasRealLayout = false;
41
41
  }
42
42
  if (!hasRealLayout) {
@@ -58,7 +58,7 @@ function isBrowser() {
58
58
  metrics.width > 0 &&
59
59
  metrics.width < 1000;
60
60
  }
61
- catch {
61
+ catch (_b) {
62
62
  hasRealCanvas = false;
63
63
  }
64
64
  if (hasRealCanvas)
@@ -86,6 +86,7 @@ function measureTextInBrowser(content, { fontFamily, fontSize, fontWeight, lineH
86
86
  return { width: rect.width, height: rect.height };
87
87
  }
88
88
  function measureText(text = '', attrs) {
89
+ var _a;
89
90
  if (attrs.width && attrs.height) {
90
91
  return { width: attrs.width, height: attrs.height };
91
92
  }
@@ -102,7 +103,7 @@ function measureText(text = '', attrs) {
102
103
  };
103
104
  const fallback = () => (0, measury_1.measureText)(content, options);
104
105
  const metrics = (0, is_browser_1.isBrowser)()
105
- ? (measureTextInBrowser(content, options) ?? fallback())
106
+ ? ((_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback())
106
107
  : fallback();
107
108
  // 额外添加 1% 宽高
108
109
  return {
@@ -52,7 +52,7 @@ function setSVGPadding(svg, padding) {
52
52
  subtree: true,
53
53
  });
54
54
  }
55
- catch {
55
+ catch (_a) {
56
56
  setSVGPaddingInNode(svg, padding);
57
57
  }
58
58
  }
@@ -12,7 +12,8 @@ const constants_1 = require("../constants");
12
12
  const element_1 = require("./element");
13
13
  const text_1 = require("./text");
14
14
  const is = (element, role) => {
15
- return element?.dataset?.elementType === role;
15
+ var _a;
16
+ return ((_a = element === null || element === void 0 ? void 0 : element.dataset) === null || _a === void 0 ? void 0 : _a.elementType) === role;
16
17
  };
17
18
  const isTagName = (element, tagName) => {
18
19
  return element.tagName.toLowerCase() === tagName.toLowerCase();
package/lib/utils/text.js CHANGED
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.getTextEntity = getTextEntity;
4
15
  exports.createTextElement = createTextElement;
@@ -39,7 +50,7 @@ function updateTextElement(text, props) {
39
50
  if (entity) {
40
51
  Object.assign(entity.style, getTextStyle(attributes));
41
52
  if (!width || !height) {
42
- const content = textContent ?? getTextContent(text);
53
+ const content = textContent !== null && textContent !== void 0 ? textContent : getTextContent(text);
43
54
  const { fontFamily, fontSize, fontWeight, lineHeight } = entity.style;
44
55
  const fSize = fontSize ? parseFloat(String(fontSize)) : 12;
45
56
  const rect = (0, measure_text_1.measureText)(content, {
@@ -116,7 +127,7 @@ function getTextStyle(attributes) {
116
127
  ['data-vertical-align']: verticalAlign, // omit
117
128
  ['font-size']: fontSize, ['letter-spacing']: letterSpacing, ['line-height']: lineHeight, fill, ['stroke-width']: strokeWidth, ['text-anchor']: textAnchor, // omit
118
129
  ['dominant-baseline']: dominantBaseline, // omit
119
- ['font-family']: fontFamily, ...restAttrs } = attributes;
130
+ ['font-family']: fontFamily } = attributes, restAttrs = __rest(attributes, ["x", "y", "width", "height", 'data-horizontal-align', 'data-vertical-align', 'font-size', 'letter-spacing', 'line-height', "fill", 'stroke-width', 'text-anchor', 'dominant-baseline', 'font-family']);
120
131
  const style = {
121
132
  overflow: 'visible',
122
133
  // userSelect: 'none',
@@ -153,7 +164,7 @@ function setTextContent(text, content) {
153
164
  try {
154
165
  entity.innerText = content;
155
166
  }
156
- catch {
167
+ catch (_a) {
157
168
  entity.textContent = content;
158
169
  }
159
170
  }
@@ -4,3 +4,23 @@ export declare function getViewBox(svg: SVGSVGElement): {
4
4
  width: number;
5
5
  height: number;
6
6
  };
7
+ export declare function calculateZoomedViewBox(current: {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ }, factor: number, pivot: {
13
+ x: number;
14
+ y: number;
15
+ }): {
16
+ x: number;
17
+ y: number;
18
+ width: number;
19
+ height: number;
20
+ };
21
+ export declare function viewBoxToString(box: {
22
+ x: number;
23
+ y: number;
24
+ width: number;
25
+ height: number;
26
+ }): string;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getViewBox = getViewBox;
4
+ exports.calculateZoomedViewBox = calculateZoomedViewBox;
5
+ exports.viewBoxToString = viewBoxToString;
4
6
  function getViewBox(svg) {
5
7
  const viewBox = svg.getAttribute('viewBox');
6
8
  if (viewBox) {
@@ -13,3 +15,13 @@ function getViewBox(svg) {
13
15
  const height = Number(heightStr) || 0;
14
16
  return { x: 0, y: 0, width, height };
15
17
  }
18
+ function calculateZoomedViewBox(current, factor, pivot) {
19
+ const newWidth = current.width * factor;
20
+ const newHeight = current.height * factor;
21
+ const newX = pivot.x - (pivot.x - current.x) * factor;
22
+ const newY = pivot.y - (pivot.y - current.y) * factor;
23
+ return { x: newX, y: newY, width: newWidth, height: newHeight };
24
+ }
25
+ function viewBoxToString(box) {
26
+ return `${box.x} ${box.y} ${box.width} ${box.height}`;
27
+ }
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.2.11";
1
+ export declare const VERSION = "0.2.13";
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.2.11';
4
+ exports.VERSION = '0.2.13';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/infographic",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "An Infographic Generation and Rendering Framework, bring words to life!",
5
5
  "keywords": [
6
6
  "antv",
@@ -126,7 +126,6 @@
126
126
  "@types/node": "^24.3.1",
127
127
  "@types/tinycolor2": "^1.4.6",
128
128
  "@vitest/coverage-v8": "^3.2.4",
129
- "any-skills": "^0.1.1",
130
129
  "csstype": "^3.2.2",
131
130
  "eslint": "^9.35.0",
132
131
  "globals": "^16.4.0",