@antv/infographic 0.2.11 → 0.2.12

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 (300) hide show
  1. package/dist/infographic.min.js +1 -1
  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.js +4 -3
  51. package/esm/designs/structures/chart-wordcloud.js +5 -14
  52. package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
  53. package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
  54. package/esm/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
  55. package/esm/designs/structures/compare-hierarchy-left-right.js +6 -5
  56. package/esm/designs/structures/compare-hierarchy-row.js +3 -2
  57. package/esm/designs/structures/compare-quadrant.js +2 -3
  58. package/esm/designs/structures/hierarchy-mindmap.js +19 -19
  59. package/esm/designs/structures/hierarchy-structure.js +1 -1
  60. package/esm/designs/structures/hierarchy-tree.js +15 -24
  61. package/esm/designs/structures/list-sector.js +5 -6
  62. package/esm/designs/structures/list-zigzag.js +2 -1
  63. package/esm/designs/structures/relation-dagre-flow.js +30 -35
  64. package/esm/designs/structures/relation-network.js +2 -2
  65. package/esm/designs/structures/sequence-funnel.js +1 -1
  66. package/esm/designs/structures/sequence-mountain.js +4 -4
  67. package/esm/designs/structures/sequence-pyramid.js +1 -1
  68. package/esm/designs/structures/sequence-zigzag-steps.js +2 -1
  69. package/esm/designs/utils/color.js +8 -4
  70. package/esm/designs/utils/item.js +3 -2
  71. package/esm/editor/commands/Batch.js +21 -8
  72. package/esm/editor/commands/UpdateElement.js +25 -22
  73. package/esm/editor/commands/UpdateOptions.js +23 -10
  74. package/esm/editor/commands/UpdateText.js +24 -11
  75. package/esm/editor/interactions/brush-select.js +27 -13
  76. package/esm/editor/interactions/click-select.js +13 -3
  77. package/esm/editor/interactions/dblclick-edit-text.js +36 -20
  78. package/esm/editor/interactions/drag-element.js +23 -9
  79. package/esm/editor/interactions/hotkey-history.js +17 -7
  80. package/esm/editor/interactions/select-highlight.js +5 -9
  81. package/esm/editor/interactions/zoom-wheel.js +2 -1
  82. package/esm/editor/managers/command.js +45 -27
  83. package/esm/editor/managers/interaction.js +46 -33
  84. package/esm/editor/managers/state.js +1 -1
  85. package/esm/editor/plugins/edit-bar/components/color-picker.js +9 -6
  86. package/esm/editor/plugins/edit-bar/components/popover.js +15 -12
  87. package/esm/editor/plugins/edit-bar/components/select.js +10 -8
  88. package/esm/editor/plugins/edit-bar/edit-bar.js +7 -25
  89. package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
  90. package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  91. package/esm/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
  92. package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
  93. package/esm/editor/plugins/resize-element.js +6 -4
  94. package/esm/editor/utils/click-handler.js +6 -3
  95. package/esm/editor/utils/coordinate.js +2 -1
  96. package/esm/editor/utils/element.js +2 -1
  97. package/esm/editor/utils/event.js +2 -1
  98. package/esm/editor/utils/extension.js +1 -1
  99. package/esm/editor/utils/hotkey.js +2 -1
  100. package/esm/exporter/font.js +106 -90
  101. package/esm/exporter/png.js +49 -37
  102. package/esm/exporter/svg.js +55 -38
  103. package/esm/jsx/components/Ellipse.js +5 -4
  104. package/esm/jsx/components/Path.js +2 -4
  105. package/esm/jsx/components/Polygon.js +15 -6
  106. package/esm/jsx/components/Text.js +21 -41
  107. package/esm/jsx/renderer.js +15 -7
  108. package/esm/jsx/utils/bounds.js +18 -16
  109. package/esm/jsx/utils/children.js +2 -1
  110. package/esm/jsx/utils/clone.js +13 -2
  111. package/esm/jsx/utils/element.js +2 -1
  112. package/esm/options/parser.js +45 -46
  113. package/esm/renderer/composites/background.js +3 -2
  114. package/esm/renderer/composites/icon.js +14 -19
  115. package/esm/renderer/composites/illus.js +17 -22
  116. package/esm/renderer/composites/shape.js +4 -2
  117. package/esm/renderer/composites/svg.js +2 -1
  118. package/esm/renderer/composites/text.js +5 -3
  119. package/esm/renderer/fonts/loader.js +4 -3
  120. package/esm/renderer/fonts/registry.js +1 -1
  121. package/esm/renderer/palettes/utils.js +3 -2
  122. package/esm/renderer/renderer.js +7 -5
  123. package/esm/renderer/stylize/gradient.js +3 -2
  124. package/esm/renderer/stylize/pattern.js +15 -8
  125. package/esm/renderer/stylize/rough.js +1 -1
  126. package/esm/resource/load-tracker.js +22 -10
  127. package/esm/resource/loader.js +80 -67
  128. package/esm/resource/loaders/image.js +71 -59
  129. package/esm/resource/loaders/remote.js +26 -15
  130. package/esm/resource/loaders/search.js +38 -25
  131. package/esm/resource/utils/parser.js +2 -1
  132. package/esm/runtime/Infographic.js +26 -13
  133. package/esm/runtime/utils.js +5 -8
  134. package/esm/ssr/renderer.js +42 -35
  135. package/esm/syntax/index.js +19 -6
  136. package/esm/syntax/mapper.js +2 -2
  137. package/esm/templates/built-in.js +96 -200
  138. package/esm/templates/hierarchy-mindmap.js +1 -5
  139. package/esm/templates/hierarchy-tree.js +1 -5
  140. package/esm/templates/relation-dagre-flow.js +4 -28
  141. package/esm/themes/generator.js +8 -14
  142. package/esm/utils/fetch.js +48 -35
  143. package/esm/utils/icon.js +1 -4
  144. package/esm/utils/is-browser.js +2 -2
  145. package/esm/utils/measure-text.js +2 -1
  146. package/esm/utils/padding.js +1 -1
  147. package/esm/utils/recognizer.js +2 -1
  148. package/esm/utils/text.js +14 -3
  149. package/esm/version.d.ts +1 -1
  150. package/esm/version.js +1 -1
  151. package/lib/designs/components/Btn.js +15 -4
  152. package/lib/designs/components/BtnsGroup.js +1 -1
  153. package/lib/designs/components/Illus.js +15 -3
  154. package/lib/designs/components/ItemDesc.js +17 -11
  155. package/lib/designs/components/ItemIcon.js +17 -18
  156. package/lib/designs/components/ItemLabel.js +17 -11
  157. package/lib/designs/components/ItemValue.js +17 -12
  158. package/lib/designs/components/ItemsGroup.js +1 -1
  159. package/lib/designs/components/ShapesGroup.js +1 -1
  160. package/lib/designs/components/Title.js +2 -2
  161. package/lib/designs/decorations/simple-arrow.js +14 -2
  162. package/lib/designs/decorations/triangle.js +14 -2
  163. package/lib/designs/defs/DropShadow.js +13 -2
  164. package/lib/designs/defs/LinearGradient.js +1 -1
  165. package/lib/designs/items/BadgeCard.js +2 -2
  166. package/lib/designs/items/CandyCardLite.js +1 -1
  167. package/lib/designs/items/CapsuleItem.js +3 -3
  168. package/lib/designs/items/CircleNode.js +1 -1
  169. package/lib/designs/items/CircularProgress.js +3 -2
  170. package/lib/designs/items/CompactCard.js +1 -1
  171. package/lib/designs/items/DoneList.js +1 -1
  172. package/lib/designs/items/HorizontalIconArrow.js +2 -2
  173. package/lib/designs/items/HorizontalIconLine.js +2 -2
  174. package/lib/designs/items/IconBadge.js +4 -3
  175. package/lib/designs/items/IndexedCard.js +1 -1
  176. package/lib/designs/items/LCornerCard.js +1 -1
  177. package/lib/designs/items/LetterCard.js +4 -3
  178. package/lib/designs/items/LinedText.js +6 -5
  179. package/lib/designs/items/PillBadge.js +2 -2
  180. package/lib/designs/items/PlainText.js +4 -4
  181. package/lib/designs/items/ProgressCard.js +4 -4
  182. package/lib/designs/items/QuarterCircular.js +1 -1
  183. package/lib/designs/items/QuarterSimpleCard.js +1 -1
  184. package/lib/designs/items/RibbonCard.js +2 -2
  185. package/lib/designs/items/RoundedRectNode.js +2 -2
  186. package/lib/designs/items/SimpleCircleNode.js +1 -1
  187. package/lib/designs/items/SimpleHorizontalArrow.js +2 -2
  188. package/lib/designs/items/SimpleIllusItem.js +1 -1
  189. package/lib/designs/items/SimpleItem.js +3 -3
  190. package/lib/designs/items/SimpleVerticalArrow.js +2 -2
  191. package/lib/designs/items/UnderlineText.js +1 -1
  192. package/lib/designs/items/VerticalIconArrow.js +2 -2
  193. package/lib/designs/layouts/Align.js +22 -15
  194. package/lib/designs/layouts/Flex.js +23 -16
  195. package/lib/designs/structures/chart-bar.js +7 -5
  196. package/lib/designs/structures/chart-column.js +3 -2
  197. package/lib/designs/structures/chart-line.js +7 -5
  198. package/lib/designs/structures/chart-pie.js +4 -3
  199. package/lib/designs/structures/chart-wordcloud.js +5 -14
  200. package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
  201. package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
  202. package/lib/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
  203. package/lib/designs/structures/compare-hierarchy-left-right.js +6 -5
  204. package/lib/designs/structures/compare-hierarchy-row.js +3 -2
  205. package/lib/designs/structures/compare-quadrant.js +2 -3
  206. package/lib/designs/structures/hierarchy-mindmap.js +19 -19
  207. package/lib/designs/structures/hierarchy-structure.js +1 -1
  208. package/lib/designs/structures/hierarchy-tree.js +15 -24
  209. package/lib/designs/structures/list-sector.js +5 -6
  210. package/lib/designs/structures/list-zigzag.js +2 -1
  211. package/lib/designs/structures/relation-dagre-flow.js +30 -35
  212. package/lib/designs/structures/relation-network.js +2 -2
  213. package/lib/designs/structures/sequence-funnel.js +1 -1
  214. package/lib/designs/structures/sequence-mountain.js +4 -4
  215. package/lib/designs/structures/sequence-pyramid.js +1 -1
  216. package/lib/designs/structures/sequence-zigzag-steps.js +2 -1
  217. package/lib/designs/utils/color.js +8 -4
  218. package/lib/designs/utils/item.js +3 -2
  219. package/lib/editor/commands/Batch.js +21 -8
  220. package/lib/editor/commands/UpdateElement.js +25 -22
  221. package/lib/editor/commands/UpdateOptions.js +23 -10
  222. package/lib/editor/commands/UpdateText.js +24 -11
  223. package/lib/editor/interactions/brush-select.js +27 -13
  224. package/lib/editor/interactions/click-select.js +13 -3
  225. package/lib/editor/interactions/dblclick-edit-text.js +36 -20
  226. package/lib/editor/interactions/drag-element.js +23 -9
  227. package/lib/editor/interactions/hotkey-history.js +17 -7
  228. package/lib/editor/interactions/select-highlight.js +5 -9
  229. package/lib/editor/interactions/zoom-wheel.js +2 -1
  230. package/lib/editor/managers/command.js +43 -25
  231. package/lib/editor/managers/interaction.js +46 -33
  232. package/lib/editor/managers/state.js +1 -1
  233. package/lib/editor/plugins/edit-bar/components/color-picker.js +9 -6
  234. package/lib/editor/plugins/edit-bar/components/popover.js +15 -12
  235. package/lib/editor/plugins/edit-bar/components/select.js +10 -8
  236. package/lib/editor/plugins/edit-bar/edit-bar.js +7 -25
  237. package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
  238. package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  239. package/lib/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
  240. package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
  241. package/lib/editor/plugins/resize-element.js +6 -4
  242. package/lib/editor/utils/click-handler.js +6 -3
  243. package/lib/editor/utils/coordinate.js +2 -1
  244. package/lib/editor/utils/element.js +2 -1
  245. package/lib/editor/utils/event.js +2 -1
  246. package/lib/editor/utils/extension.js +1 -1
  247. package/lib/editor/utils/hotkey.js +2 -1
  248. package/lib/exporter/font.js +106 -90
  249. package/lib/exporter/png.js +49 -37
  250. package/lib/exporter/svg.js +55 -38
  251. package/lib/jsx/components/Ellipse.js +5 -4
  252. package/lib/jsx/components/Path.js +2 -4
  253. package/lib/jsx/components/Polygon.js +15 -6
  254. package/lib/jsx/components/Text.js +21 -41
  255. package/lib/jsx/renderer.js +15 -7
  256. package/lib/jsx/utils/bounds.js +18 -16
  257. package/lib/jsx/utils/children.js +2 -1
  258. package/lib/jsx/utils/clone.js +13 -2
  259. package/lib/jsx/utils/element.js +2 -1
  260. package/lib/options/parser.js +45 -46
  261. package/lib/renderer/composites/background.js +3 -2
  262. package/lib/renderer/composites/icon.js +14 -19
  263. package/lib/renderer/composites/illus.js +17 -22
  264. package/lib/renderer/composites/shape.js +4 -2
  265. package/lib/renderer/composites/svg.js +2 -1
  266. package/lib/renderer/composites/text.js +5 -3
  267. package/lib/renderer/fonts/loader.js +4 -3
  268. package/lib/renderer/fonts/registry.js +1 -1
  269. package/lib/renderer/palettes/utils.js +3 -2
  270. package/lib/renderer/renderer.js +7 -5
  271. package/lib/renderer/stylize/gradient.js +3 -2
  272. package/lib/renderer/stylize/pattern.js +15 -8
  273. package/lib/renderer/stylize/rough.js +1 -1
  274. package/lib/resource/load-tracker.js +22 -10
  275. package/lib/resource/loader.js +80 -67
  276. package/lib/resource/loaders/image.js +71 -59
  277. package/lib/resource/loaders/remote.js +26 -15
  278. package/lib/resource/loaders/search.js +38 -25
  279. package/lib/resource/utils/parser.js +2 -1
  280. package/lib/runtime/Infographic.js +26 -13
  281. package/lib/runtime/utils.js +5 -8
  282. package/lib/ssr/renderer.js +42 -35
  283. package/lib/syntax/index.js +19 -6
  284. package/lib/syntax/mapper.js +2 -2
  285. package/lib/templates/built-in.js +96 -200
  286. package/lib/templates/hierarchy-mindmap.js +1 -5
  287. package/lib/templates/hierarchy-tree.js +1 -5
  288. package/lib/templates/relation-dagre-flow.js +4 -28
  289. package/lib/themes/generator.js +8 -14
  290. package/lib/utils/fetch.js +48 -35
  291. package/lib/utils/icon.js +1 -4
  292. package/lib/utils/is-browser.js +2 -2
  293. package/lib/utils/measure-text.js +2 -1
  294. package/lib/utils/padding.js +1 -1
  295. package/lib/utils/recognizer.js +2 -1
  296. package/lib/utils/text.js +14 -3
  297. package/lib/version.d.ts +1 -1
  298. package/lib/version.js +1 -1
  299. package/package.json +1 -1
  300. package/src/version.ts +1 -1
@@ -1,39 +1,54 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { createElement, getElementByRole, getViewBox, setAttributes, setElementRole, traverse, } from '../utils/index.js';
2
11
  import { embedFonts } from './font.js';
3
- export async function exportToSVGString(svg, options = {}) {
4
- const node = await exportToSVG(svg, options);
5
- const str = new XMLSerializer().serializeToString(node);
6
- return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(str);
7
- }
8
- export async function exportToSVG(svg, options = {}) {
9
- const { embedResources = true, removeIds = false } = options;
10
- const clonedSVG = svg.cloneNode(true);
11
- const { width, height } = getViewBox(svg);
12
- setAttributes(clonedSVG, { width, height });
13
- if (removeIds) {
14
- inlineUseElements(clonedSVG);
15
- inlineDefsReferences(clonedSVG);
16
- }
17
- else {
18
- await embedIcons(clonedSVG);
19
- }
20
- await embedFonts(clonedSVG, embedResources);
21
- cleanSVG(clonedSVG);
22
- return clonedSVG;
12
+ export function exportToSVGString(svg_1) {
13
+ return __awaiter(this, arguments, void 0, function* (svg, options = {}) {
14
+ const node = yield exportToSVG(svg, options);
15
+ const str = new XMLSerializer().serializeToString(node);
16
+ return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(str);
17
+ });
23
18
  }
24
- async function embedIcons(svg) {
25
- const icons = svg.querySelectorAll('use');
26
- const defs = getDefs(svg);
27
- icons.forEach((icon) => {
28
- const href = icon.getAttribute('href');
29
- if (!href)
30
- return;
31
- const existsSymbol = svg.querySelector(href);
32
- if (!existsSymbol) {
33
- const symbolElement = document.querySelector(href);
34
- if (symbolElement)
35
- defs.appendChild(symbolElement.cloneNode(true));
19
+ export function exportToSVG(svg_1) {
20
+ return __awaiter(this, arguments, void 0, function* (svg, options = {}) {
21
+ const { embedResources = true, removeIds = false } = options;
22
+ const clonedSVG = svg.cloneNode(true);
23
+ const { width, height } = getViewBox(svg);
24
+ setAttributes(clonedSVG, { width, height });
25
+ if (removeIds) {
26
+ inlineUseElements(clonedSVG);
27
+ inlineDefsReferences(clonedSVG);
36
28
  }
29
+ else {
30
+ yield embedIcons(clonedSVG);
31
+ }
32
+ yield embedFonts(clonedSVG, embedResources);
33
+ cleanSVG(clonedSVG);
34
+ return clonedSVG;
35
+ });
36
+ }
37
+ function embedIcons(svg) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const icons = svg.querySelectorAll('use');
40
+ const defs = getDefs(svg);
41
+ icons.forEach((icon) => {
42
+ const href = icon.getAttribute('href');
43
+ if (!href)
44
+ return;
45
+ const existsSymbol = svg.querySelector(href);
46
+ if (!existsSymbol) {
47
+ const symbolElement = document.querySelector(href);
48
+ if (symbolElement)
49
+ defs.appendChild(symbolElement.cloneNode(true));
50
+ }
51
+ });
37
52
  });
38
53
  }
39
54
  const iconRole = 'icon-defs';
@@ -64,7 +79,8 @@ function inlineUseElements(svg) {
64
79
  });
65
80
  }
66
81
  function getUseHref(use) {
67
- return use.getAttribute('href') ?? use.getAttribute('xlink:href');
82
+ var _a;
83
+ return (_a = use.getAttribute('href')) !== null && _a !== void 0 ? _a : use.getAttribute('xlink:href');
68
84
  }
69
85
  function resolveUseTarget(svg, href) {
70
86
  const localTarget = svg.querySelector(href);
@@ -112,10 +128,11 @@ function materializeElement(use, source) {
112
128
  return wrapper;
113
129
  }
114
130
  function buildUseTransform(use) {
131
+ var _a;
115
132
  const x = use.getAttribute('x');
116
133
  const y = use.getAttribute('y');
117
- const translate = x || y ? `translate(${x ?? 0} ${y ?? 0})` : '';
118
- const transform = use.getAttribute('transform') ?? '';
134
+ const translate = x || y ? `translate(${x !== null && x !== void 0 ? x : 0} ${y !== null && y !== void 0 ? y : 0})` : '';
135
+ const transform = (_a = use.getAttribute('transform')) !== null && _a !== void 0 ? _a : '';
119
136
  if (translate && transform)
120
137
  return `${translate} ${transform}`;
121
138
  return translate || transform || null;
@@ -269,13 +286,13 @@ function cleanSVG(svg) {
269
286
  }
270
287
  function removeBtnGroup(svg) {
271
288
  const btnGroup = getElementByRole(svg, "btns-group" /* ElementTypeEnum.BtnsGroup */);
272
- btnGroup?.remove();
289
+ btnGroup === null || btnGroup === void 0 ? void 0 : btnGroup.remove();
273
290
  const btnIconDefs = getElementByRole(svg, 'btn-icon-defs');
274
- btnIconDefs?.remove();
291
+ btnIconDefs === null || btnIconDefs === void 0 ? void 0 : btnIconDefs.remove();
275
292
  }
276
293
  function removeTransientContainer(svg) {
277
294
  const transientContainer = svg.querySelector('[data-element-type=transient-container]');
278
- transientContainer?.remove();
295
+ transientContainer === null || transientContainer === void 0 ? void 0 : transientContainer.remove();
279
296
  }
280
297
  function removeUselessAttrs(svg) {
281
298
  const groups = svg.querySelectorAll('g');
@@ -1,9 +1,10 @@
1
1
  export function Ellipse(props) {
2
+ var _a, _b, _c, _d;
2
3
  const { x = 0, y = 0, width = 0, height = 0 } = props;
3
- props.cx ?? (props.cx = x + width / 2);
4
- props.cy ?? (props.cy = y + height / 2);
5
- props.rx ?? (props.rx = width / 2);
6
- props.ry ?? (props.ry = height / 2);
4
+ (_a = props.cx) !== null && _a !== void 0 ? _a : (props.cx = x + width / 2);
5
+ (_b = props.cy) !== null && _b !== void 0 ? _b : (props.cy = y + height / 2);
6
+ (_c = props.rx) !== null && _c !== void 0 ? _c : (props.rx = width / 2);
7
+ (_d = props.ry) !== null && _d !== void 0 ? _d : (props.ry = height / 2);
7
8
  const node = {
8
9
  type: 'ellipse',
9
10
  props,
@@ -1,10 +1,8 @@
1
1
  export function Path(props) {
2
2
  const { x, y } = props;
3
- const finalProps = {
4
- ...props,
5
- };
3
+ const finalProps = Object.assign({}, props);
6
4
  if (x !== undefined || y !== undefined) {
7
- finalProps.transform = `translate(${x ?? 0}, ${y ?? 0})`;
5
+ finalProps.transform = `translate(${x !== null && x !== void 0 ? x : 0}, ${y !== null && y !== void 0 ? y : 0})`;
8
6
  }
9
7
  const node = {
10
8
  type: 'path',
@@ -1,13 +1,22 @@
1
- export function Polygon({ points = [], ...props }) {
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ export function Polygon(_a) {
13
+ var { points = [] } = _a, props = __rest(_a, ["points"]);
2
14
  const { x, y } = props;
3
15
  const pointsStr = points.map(({ x, y }) => `${x},${y}`).join(' ');
4
- const finalProps = {
5
- ...props,
6
- points: pointsStr,
7
- };
16
+ const finalProps = Object.assign(Object.assign({}, props), { points: pointsStr });
8
17
  if (x !== undefined || y !== undefined) {
9
18
  finalProps.transform =
10
- `translate(${x ?? 0}, ${y ?? 0})` + (finalProps.transform || '');
19
+ `translate(${x !== null && x !== void 0 ? x : 0}, ${y !== null && y !== void 0 ? y : 0})` + (finalProps.transform || '');
11
20
  }
12
21
  const node = {
13
22
  type: 'polygon',
@@ -1,6 +1,17 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { measureText } from '../../utils/index.js';
2
13
  export function Text(props) {
3
- const { id, x = 0, y = 0, width: w, height: h, alignHorizontal = 'left', alignVertical = 'top', children, fontSize = 14, fontFamily, fontStyle, fontWeight, textDecoration, letterSpacing, wordSpacing, opacity, fill = 'black', lineHeight, wordWrap, backgroundColor = 'none', backgroundOpacity = 1, backgroundRadius = 0, ...restProps } = props;
14
+ const { id, x = 0, y = 0, width: w, height: h, alignHorizontal = 'left', alignVertical = 'top', children, fontSize = 14, fontFamily, fontStyle, fontWeight, textDecoration, letterSpacing, wordSpacing, opacity, fill = 'black', lineHeight, wordWrap, backgroundColor = 'none', backgroundOpacity = 1, backgroundRadius = 0 } = props, restProps = __rest(props, ["id", "x", "y", "width", "height", "alignHorizontal", "alignVertical", "children", "fontSize", "fontFamily", "fontStyle", "fontWeight", "textDecoration", "letterSpacing", "wordSpacing", "opacity", "fill", "lineHeight", "wordWrap", "backgroundColor", "backgroundOpacity", "backgroundRadius"]);
4
15
  let width = w;
5
16
  let height = h;
6
17
  let textX = 0;
@@ -27,12 +38,8 @@ export function Text(props) {
27
38
  ? height
28
39
  : 0;
29
40
  }
30
- const dataAttrs = Object.entries({
31
- width,
32
- height,
33
- ...(lineHeight !== undefined && { 'line-height': lineHeight }),
34
- ...(wordWrap !== undefined && { 'data-word-wrap': wordWrap }),
35
- }).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
41
+ const dataAttrs = Object.entries(Object.assign(Object.assign({ width,
42
+ height }, (lineHeight !== undefined && { 'line-height': lineHeight })), (wordWrap !== undefined && { 'data-word-wrap': wordWrap }))).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [key]: value })), {});
36
43
  const textAnchor = alignHorizontal === 'center'
37
44
  ? 'middle'
38
45
  : alignHorizontal === 'right'
@@ -43,37 +50,13 @@ export function Text(props) {
43
50
  : alignVertical === 'bottom'
44
51
  ? 'baseline'
45
52
  : 'hanging';
46
- const textProps = {
47
- 'data-element-type': 'text',
48
- width,
49
- height,
50
- x: textX,
51
- y: textY,
52
- 'data-x': 0,
53
- 'data-y': 0,
54
- fill,
53
+ const textProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ 'data-element-type': 'text', width,
54
+ height, x: textX, y: textY, 'data-x': 0, 'data-y': 0, fill,
55
55
  fontSize,
56
56
  textAnchor,
57
- dominantBaseline,
58
- 'data-horizontal-align': alignHorizontal.toUpperCase(),
59
- 'data-vertical-align': alignVertical.toUpperCase(),
60
- children,
61
- ...dataAttrs,
62
- ...restProps,
63
- ...(fontFamily && { fontFamily }),
64
- ...(fontStyle && { fontStyle }),
65
- ...(fontWeight && { fontWeight }),
66
- ...(textDecoration && textDecoration !== 'none' && { textDecoration }),
67
- ...(letterSpacing && { letterSpacing }),
68
- ...(wordSpacing && { wordSpacing }),
69
- ...(opacity !== undefined && opacity !== 1 && { opacity }),
70
- };
71
- const containerProps = {
72
- ...(x !== 0 || y !== 0 ? { x, y, transform: `translate(${x}, ${y})` } : {}),
73
- width,
74
- height,
75
- ...(id && { id }),
76
- };
57
+ dominantBaseline, 'data-horizontal-align': alignHorizontal.toUpperCase(), 'data-vertical-align': alignVertical.toUpperCase(), children }, dataAttrs), restProps), (fontFamily && { fontFamily })), (fontStyle && { fontStyle })), (fontWeight && { fontWeight })), (textDecoration && textDecoration !== 'none' && { textDecoration })), (letterSpacing && { letterSpacing })), (wordSpacing && { wordSpacing })), (opacity !== undefined && opacity !== 1 && { opacity }));
58
+ const containerProps = Object.assign(Object.assign(Object.assign({}, (x !== 0 || y !== 0 ? { x, y, transform: `translate(${x}, ${y})` } : {})), { width,
59
+ height }), (id && { id }));
77
60
  const hasBackground = backgroundColor && backgroundColor !== 'none';
78
61
  const rectProps = hasBackground
79
62
  ? {
@@ -90,12 +73,9 @@ export function Text(props) {
90
73
  : undefined;
91
74
  return {
92
75
  type: 'g',
93
- props: {
94
- ...containerProps,
95
- children: [
76
+ props: Object.assign(Object.assign({}, containerProps), { children: [
96
77
  ...(rectProps ? [{ type: 'rect', props: rectProps }] : []),
97
78
  { type: 'text', props: textProps },
98
- ],
99
- },
79
+ ] }),
100
80
  };
101
81
  }
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { DefsSymbol } from './components/index.js';
2
13
  import { Fragment } from './jsx-runtime.js';
3
14
  import { isLayoutComponent, performLayout } from './layout.js';
@@ -97,14 +108,11 @@ export function renderSVG(element, props = {}) {
97
108
  const content = Array.isArray(processed)
98
109
  ? processed.map((el) => render(el, context)).join('')
99
110
  : render(processed, context);
100
- const { x, y, width, height, style, ...rest } = props;
101
- const finalProps = {
102
- ...rest,
103
- xmlns: 'http://www.w3.org/2000/svg',
104
- };
111
+ const { x, y, width, height, style } = props, rest = __rest(props, ["x", "y", "width", "height", "style"]);
112
+ const finalProps = Object.assign(Object.assign({}, rest), { xmlns: 'http://www.w3.org/2000/svg' });
105
113
  if (!finalProps.viewBox) {
106
114
  if (width && height) {
107
- finalProps.viewBox = `${x ?? 0} ${y ?? 0} ${width ?? 0} ${height ?? 0}`;
115
+ finalProps.viewBox = `${x !== null && x !== void 0 ? x : 0} ${y !== null && y !== void 0 ? y : 0} ${width !== null && width !== void 0 ? width : 0} ${height !== null && height !== void 0 ? height : 0}`;
108
116
  }
109
117
  else {
110
118
  const bounds = getElementBounds(processed);
@@ -129,7 +137,7 @@ export function renderSVG(element, props = {}) {
129
137
  function renderAttrs(props) {
130
138
  if (!props)
131
139
  return '';
132
- const { children, ...attributes } = props;
140
+ const { children } = props, attributes = __rest(props, ["children"]);
133
141
  return Object.entries(attributes)
134
142
  .filter(([, value]) => value !== undefined && value !== null)
135
143
  .map(([key, value]) => {
@@ -37,6 +37,7 @@ export function getCombinedBounds(list) {
37
37
  };
38
38
  }
39
39
  export function getElementBounds(node) {
40
+ var _a, _b, _c, _d;
40
41
  if (!node)
41
42
  return zero();
42
43
  if (Array.isArray(node)) {
@@ -51,8 +52,8 @@ export function getElementBounds(node) {
51
52
  return getElementBounds(layoutResult);
52
53
  }
53
54
  if (typeof type === 'function') {
54
- const externalX = props.x ?? 0;
55
- const externalY = props.y ?? 0;
55
+ const externalX = (_a = props.x) !== null && _a !== void 0 ? _a : 0;
56
+ const externalY = (_b = props.y) !== null && _b !== void 0 ? _b : 0;
56
57
  const externalWidth = props.width;
57
58
  const externalHeight = props.height;
58
59
  if (isNumber(externalWidth) && isNumber(externalHeight)) {
@@ -68,8 +69,8 @@ export function getElementBounds(node) {
68
69
  return {
69
70
  x: externalX,
70
71
  y: externalY,
71
- width: externalWidth ?? 0,
72
- height: externalHeight ?? 0,
72
+ width: externalWidth !== null && externalWidth !== void 0 ? externalWidth : 0,
73
+ height: externalHeight !== null && externalHeight !== void 0 ? externalHeight : 0,
73
74
  };
74
75
  }
75
76
  if (Array.isArray(renderedResult)) {
@@ -84,8 +85,8 @@ export function getElementBounds(node) {
84
85
  height: externalHeight,
85
86
  };
86
87
  }
87
- const width = innerBounds.width !== 0 ? innerBounds.width : (externalWidth ?? 0);
88
- const height = innerBounds.height !== 0 ? innerBounds.height : (externalHeight ?? 0);
88
+ const width = innerBounds.width !== 0 ? innerBounds.width : (externalWidth !== null && externalWidth !== void 0 ? externalWidth : 0);
89
+ const height = innerBounds.height !== 0 ? innerBounds.height : (externalHeight !== null && externalHeight !== void 0 ? externalHeight : 0);
89
90
  return {
90
91
  x: externalX + innerBounds.x,
91
92
  y: externalY + innerBounds.y,
@@ -134,8 +135,8 @@ export function getElementBounds(node) {
134
135
  };
135
136
  }
136
137
  }
137
- const width = innerBounds.width !== 0 ? innerBounds.width : (externalWidth ?? 0);
138
- const height = innerBounds.height !== 0 ? innerBounds.height : (externalHeight ?? 0);
138
+ const width = innerBounds.width !== 0 ? innerBounds.width : (externalWidth !== null && externalWidth !== void 0 ? externalWidth : 0);
139
+ const height = innerBounds.height !== 0 ? innerBounds.height : (externalHeight !== null && externalHeight !== void 0 ? externalHeight : 0);
139
140
  return {
140
141
  x: innerHasSamePosition ? innerBounds.x : externalX + innerBounds.x,
141
142
  y: innerHasSamePosition ? innerBounds.y : externalY + innerBounds.y,
@@ -146,12 +147,12 @@ export function getElementBounds(node) {
146
147
  return {
147
148
  x: externalX,
148
149
  y: externalY,
149
- width: externalWidth ?? 0,
150
- height: externalHeight ?? 0,
150
+ width: externalWidth !== null && externalWidth !== void 0 ? externalWidth : 0,
151
+ height: externalHeight !== null && externalHeight !== void 0 ? externalHeight : 0,
151
152
  };
152
153
  }
153
- const x = props.x ?? 0;
154
- const y = props.y ?? 0;
154
+ const x = (_c = props.x) !== null && _c !== void 0 ? _c : 0;
155
+ const y = (_d = props.y) !== null && _d !== void 0 ? _d : 0;
155
156
  const width = isNumber(props.width) ? props.width : undefined;
156
157
  const height = isNumber(props.height) ? props.height : undefined;
157
158
  if (isNumber(width) && isNumber(height)) {
@@ -173,8 +174,8 @@ export function getElementBounds(node) {
173
174
  return {
174
175
  x,
175
176
  y,
176
- width: width ?? 0,
177
- height: height ?? 0,
177
+ width: width !== null && width !== void 0 ? width : 0,
178
+ height: height !== null && height !== void 0 ? height : 0,
178
179
  };
179
180
  }
180
181
  export function getElementsBounds(elements) {
@@ -194,7 +195,7 @@ export function getElementsBounds(elements) {
194
195
  return getCombinedBounds(list);
195
196
  }
196
197
  function isPassthrough(innerElement, externalProps) {
197
- if (!innerElement?.props || !externalProps) {
198
+ if (!(innerElement === null || innerElement === void 0 ? void 0 : innerElement.props) || !externalProps) {
198
199
  return false;
199
200
  }
200
201
  const inner = innerElement.props;
@@ -229,8 +230,9 @@ function isPassthrough(innerElement, externalProps) {
229
230
  return false;
230
231
  }
231
232
  function getChildrenFromElement(element) {
233
+ var _a;
232
234
  // React 风格:只从 props.children 获取子元素
233
- const children = element.props?.children;
235
+ const children = (_a = element.props) === null || _a === void 0 ? void 0 : _a.children;
234
236
  if (!children) {
235
237
  return [];
236
238
  }
@@ -1,5 +1,6 @@
1
1
  import { nodeToRenderableNodes } from './element.js';
2
2
  export function getRenderableChildrenOf(element) {
3
+ var _a;
3
4
  if (element === null ||
4
5
  element === undefined ||
5
6
  typeof element === 'boolean') {
@@ -8,7 +9,7 @@ export function getRenderableChildrenOf(element) {
8
9
  if (Array.isArray(element))
9
10
  return nodeToRenderableNodes(element);
10
11
  if (typeof element === 'object') {
11
- return nodeToRenderableNodes(element.props?.children);
12
+ return nodeToRenderableNodes((_a = element.props) === null || _a === void 0 ? void 0 : _a.children);
12
13
  }
13
14
  return [element];
14
15
  }
@@ -1,4 +1,15 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  export const cloneElement = (element, props) => {
2
- const { type, props: originalProps, ...rest } = element;
3
- return { type, props: { ...originalProps, ...props }, ...rest };
13
+ const { type, props: originalProps } = element, rest = __rest(element, ["type", "props"]);
14
+ return Object.assign({ type, props: Object.assign(Object.assign({}, originalProps), props) }, rest);
4
15
  };
@@ -4,6 +4,7 @@ export function nodeToElements(node) {
4
4
  return nodeToRenderableNodes(node).filter(isJSXElement);
5
5
  }
6
6
  export function nodeToRenderableNodes(node, result = []) {
7
+ var _a;
7
8
  if (!node || typeof node === 'boolean') {
8
9
  return result;
9
10
  }
@@ -12,7 +13,7 @@ export function nodeToRenderableNodes(node, result = []) {
12
13
  }
13
14
  else {
14
15
  if (isFragment(node)) {
15
- const children = node.props?.children;
16
+ const children = (_a = node.props) === null || _a === void 0 ? void 0 : _a.children;
16
17
  (Array.isArray(children) ? children : [children])
17
18
  .filter(Boolean)
18
19
  .forEach((child) => {