@unovis/ts 1.1.1-beta.7 → 1.1.1-beta.8

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 (710) hide show
  1. package/components/area/config.d.ts +25 -0
  2. package/components/area/config.js +16 -0
  3. package/components/area/config.js.map +1 -0
  4. package/components/area/index.d.ts +19 -0
  5. package/components/area/index.js +102 -0
  6. package/components/area/index.js.map +1 -0
  7. package/components/area/style.d.ts +3 -0
  8. package/{src/components/area/style.ts → components/area/style.js} +10 -9
  9. package/components/area/style.js.map +1 -0
  10. package/components/area/types.d.ts +6 -0
  11. package/components/axis/config.d.ts +71 -0
  12. package/components/axis/config.js +32 -0
  13. package/components/axis/config.js.map +1 -0
  14. package/components/axis/index.d.ts +44 -0
  15. package/components/axis/index.js +305 -0
  16. package/components/axis/index.js.map +1 -0
  17. package/components/axis/style.d.ts +9 -0
  18. package/{src/components/axis/style.ts → components/axis/style.js} +22 -27
  19. package/components/axis/style.js.map +1 -0
  20. package/components/axis/types.d.ts +4 -0
  21. package/components/axis/types.js +8 -0
  22. package/components/axis/types.js.map +1 -0
  23. package/components/brush/config.d.ts +42 -0
  24. package/components/brush/config.js +24 -0
  25. package/components/brush/config.js.map +1 -0
  26. package/components/brush/index.d.ts +28 -0
  27. package/components/brush/index.js +199 -0
  28. package/components/brush/index.js.map +1 -0
  29. package/components/brush/style.d.ts +5 -0
  30. package/{src/components/brush/style.ts → components/brush/style.js} +14 -15
  31. package/components/brush/style.js.map +1 -0
  32. package/components/brush/types.d.ts +7 -0
  33. package/components/brush/types.js +8 -0
  34. package/components/brush/types.js.map +1 -0
  35. package/components/bullet-legend/config.d.ts +34 -0
  36. package/components/bullet-legend/config.js +16 -0
  37. package/components/bullet-legend/config.js.map +1 -0
  38. package/components/bullet-legend/index.d.ts +19 -0
  39. package/components/bullet-legend/index.js +79 -0
  40. package/components/bullet-legend/index.js.map +1 -0
  41. package/components/bullet-legend/style.d.ts +6 -0
  42. package/{src/components/bullet-legend/style.ts → components/bullet-legend/style.js} +16 -18
  43. package/components/bullet-legend/style.js.map +1 -0
  44. package/components/bullet-legend/types.d.ts +7 -0
  45. package/components/bullet-legend/types.js +2 -0
  46. package/components/bullet-legend/types.js.map +1 -0
  47. package/components/chord-diagram/config.d.ts +44 -0
  48. package/components/chord-diagram/config.js +25 -0
  49. package/components/chord-diagram/config.js.map +1 -0
  50. package/components/chord-diagram/index.d.ts +42 -0
  51. package/components/chord-diagram/index.js +305 -0
  52. package/components/chord-diagram/index.js.map +1 -0
  53. package/components/chord-diagram/modules/label.d.ts +8 -0
  54. package/components/chord-diagram/modules/label.js +115 -0
  55. package/components/chord-diagram/modules/label.js.map +1 -0
  56. package/components/chord-diagram/modules/link.d.ts +21 -0
  57. package/components/chord-diagram/modules/link.js +63 -0
  58. package/components/chord-diagram/modules/link.js.map +1 -0
  59. package/components/chord-diagram/modules/node.d.ts +17 -0
  60. package/components/chord-diagram/modules/node.js +52 -0
  61. package/components/chord-diagram/modules/node.js.map +1 -0
  62. package/components/chord-diagram/style.d.ts +13 -0
  63. package/{src/components/chord-diagram/style.ts → components/chord-diagram/style.js} +30 -39
  64. package/components/chord-diagram/style.js.map +1 -0
  65. package/components/chord-diagram/types.d.ts +58 -0
  66. package/components/chord-diagram/types.js +8 -0
  67. package/components/chord-diagram/types.js.map +1 -0
  68. package/components/crosshair/config.d.ts +43 -0
  69. package/components/crosshair/config.js +19 -0
  70. package/components/crosshair/config.js.map +1 -0
  71. package/components/crosshair/index.d.ts +35 -0
  72. package/components/crosshair/index.js +183 -0
  73. package/components/crosshair/index.js.map +1 -0
  74. package/components/crosshair/style.d.ts +4 -0
  75. package/{src/components/crosshair/style.ts → components/crosshair/style.js} +12 -12
  76. package/components/crosshair/style.js.map +1 -0
  77. package/components/crosshair/types.d.ts +13 -0
  78. package/components/crosshair/types.js +2 -0
  79. package/components/crosshair/types.js.map +1 -0
  80. package/components/donut/config.d.ts +59 -0
  81. package/components/donut/config.js +28 -0
  82. package/components/donut/config.js.map +1 -0
  83. package/components/donut/index.d.ts +21 -0
  84. package/components/donut/index.js +107 -0
  85. package/components/donut/index.js.map +1 -0
  86. package/components/donut/modules/arc.d.ts +10 -0
  87. package/components/donut/modules/arc.js +59 -0
  88. package/components/donut/modules/arc.js.map +1 -0
  89. package/components/donut/style.d.ts +7 -0
  90. package/{src/components/donut/style.ts → components/donut/style.js} +18 -20
  91. package/components/donut/style.js.map +1 -0
  92. package/components/donut/types.d.ts +20 -0
  93. package/components/flow-legend/config.d.ts +29 -0
  94. package/components/flow-legend/config.js +18 -0
  95. package/components/flow-legend/config.js.map +1 -0
  96. package/components/flow-legend/index.d.ts +16 -0
  97. package/components/flow-legend/index.js +75 -0
  98. package/components/flow-legend/index.js.map +1 -0
  99. package/components/flow-legend/style.d.ts +8 -0
  100. package/{src/components/flow-legend/style.ts → components/flow-legend/style.js} +21 -25
  101. package/components/flow-legend/style.js.map +1 -0
  102. package/components/flow-legend/types.d.ts +9 -0
  103. package/components/flow-legend/types.js +8 -0
  104. package/components/flow-legend/types.js.map +1 -0
  105. package/components/free-brush/config.d.ts +45 -0
  106. package/components/free-brush/config.js +24 -0
  107. package/components/free-brush/config.js.map +1 -0
  108. package/components/free-brush/index.d.ts +20 -0
  109. package/components/free-brush/index.js +192 -0
  110. package/components/free-brush/index.js.map +1 -0
  111. package/components/free-brush/style.d.ts +4 -0
  112. package/{src/components/free-brush/style.ts → components/free-brush/style.js} +12 -12
  113. package/components/free-brush/style.js.map +1 -0
  114. package/components/free-brush/types.d.ts +7 -0
  115. package/components/free-brush/types.js +9 -0
  116. package/components/free-brush/types.js.map +1 -0
  117. package/components/graph/config.d.ts +238 -0
  118. package/components/graph/config.js +84 -0
  119. package/components/graph/config.js.map +1 -0
  120. package/components/graph/index.d.ts +126 -0
  121. package/components/graph/index.js +656 -0
  122. package/components/graph/index.js.map +1 -0
  123. package/components/graph/modules/layout-helpers.d.ts +21 -0
  124. package/components/graph/modules/layout-helpers.js +69 -0
  125. package/components/graph/modules/layout-helpers.js.map +1 -0
  126. package/components/graph/modules/layout.d.ts +10 -0
  127. package/components/graph/modules/layout.js +399 -0
  128. package/components/graph/modules/layout.js.map +1 -0
  129. package/components/graph/modules/link/helper.d.ts +25 -0
  130. package/components/graph/modules/link/helper.js +74 -0
  131. package/components/graph/modules/link/helper.js.map +1 -0
  132. package/components/graph/modules/link/index.d.ts +11 -0
  133. package/components/graph/modules/link/index.js +212 -0
  134. package/components/graph/modules/link/index.js.map +1 -0
  135. package/components/graph/modules/link/style.d.ts +15 -0
  136. package/{src/components/graph/modules/link/style.ts → components/graph/modules/link/style.js} +34 -45
  137. package/components/graph/modules/link/style.js.map +1 -0
  138. package/components/graph/modules/node/helper.d.ts +21 -0
  139. package/components/graph/modules/node/helper.js +126 -0
  140. package/components/graph/modules/node/helper.js.map +1 -0
  141. package/components/graph/modules/node/index.d.ts +11 -0
  142. package/components/graph/modules/node/index.js +252 -0
  143. package/components/graph/modules/node/index.js.map +1 -0
  144. package/components/graph/modules/node/style.d.ts +24 -0
  145. package/{src/components/graph/modules/node/style.ts → components/graph/modules/node/style.js} +52 -72
  146. package/components/graph/modules/node/style.js.map +1 -0
  147. package/components/graph/modules/panel/helper.d.ts +18 -0
  148. package/components/graph/modules/panel/helper.js +111 -0
  149. package/components/graph/modules/panel/helper.js.map +1 -0
  150. package/components/graph/modules/panel/index.d.ts +7 -0
  151. package/components/graph/modules/panel/index.js +98 -0
  152. package/components/graph/modules/panel/index.js.map +1 -0
  153. package/components/graph/modules/panel/style.d.ts +14 -0
  154. package/{src/components/graph/modules/panel/style.ts → components/graph/modules/panel/style.js} +32 -42
  155. package/components/graph/modules/panel/style.js.map +1 -0
  156. package/components/graph/modules/shape.d.ts +6 -0
  157. package/components/graph/modules/shape.js +80 -0
  158. package/components/graph/modules/shape.js.map +1 -0
  159. package/components/graph/modules/zoom-levels.d.ts +6 -0
  160. package/components/graph/modules/zoom-levels.js +10 -0
  161. package/components/graph/modules/zoom-levels.js.map +1 -0
  162. package/components/graph/style.d.ts +6 -0
  163. package/components/graph/style.js +66 -0
  164. package/components/graph/style.js.map +1 -0
  165. package/components/graph/types.d.ts +125 -0
  166. package/components/graph/types.js +30 -0
  167. package/components/graph/types.js.map +1 -0
  168. package/components/grouped-bar/config.d.ts +36 -0
  169. package/components/grouped-bar/config.js +20 -0
  170. package/components/grouped-bar/config.js.map +1 -0
  171. package/components/grouped-bar/index.d.ts +32 -0
  172. package/components/grouped-bar/index.js +249 -0
  173. package/components/grouped-bar/index.js.map +1 -0
  174. package/components/grouped-bar/style.d.ts +5 -0
  175. package/{src/components/grouped-bar/style.ts → components/grouped-bar/style.js} +14 -15
  176. package/components/grouped-bar/style.js.map +1 -0
  177. package/components/leaflet-flow-map/config.d.ts +46 -0
  178. package/components/leaflet-flow-map/config.js +25 -0
  179. package/components/leaflet-flow-map/config.js.map +1 -0
  180. package/components/leaflet-flow-map/index.d.ts +52 -0
  181. package/components/leaflet-flow-map/index.js +220 -0
  182. package/components/leaflet-flow-map/index.js.map +1 -0
  183. package/components/leaflet-flow-map/renderer-utils.d.ts +5 -0
  184. package/components/leaflet-flow-map/renderer-utils.js +15 -0
  185. package/components/leaflet-flow-map/renderer-utils.js.map +1 -0
  186. package/components/leaflet-flow-map/renderer.d.ts +26 -0
  187. package/components/leaflet-flow-map/renderer.js +117 -0
  188. package/components/leaflet-flow-map/renderer.js.map +1 -0
  189. package/components/leaflet-flow-map/shaders.d.ts +2 -0
  190. package/{src/components/leaflet-flow-map/shaders.ts → components/leaflet-flow-map/shaders.js} +7 -4
  191. package/components/leaflet-flow-map/shaders.js.map +1 -0
  192. package/components/leaflet-flow-map/types.d.ts +23 -0
  193. package/components/leaflet-map/config.d.ts +193 -0
  194. package/components/leaflet-map/config.js +71 -0
  195. package/components/leaflet-map/config.js.map +1 -0
  196. package/components/leaflet-map/index.d.ts +130 -0
  197. package/components/leaflet-map/index.js +690 -0
  198. package/components/leaflet-map/index.js.map +1 -0
  199. package/components/leaflet-map/leaflet.css.js +5 -0
  200. package/components/leaflet-map/leaflet.css.js.map +1 -0
  201. package/components/leaflet-map/modules/clusterBackground.d.ts +5 -0
  202. package/components/leaflet-map/modules/clusterBackground.js +27 -0
  203. package/components/leaflet-map/modules/clusterBackground.js.map +1 -0
  204. package/components/leaflet-map/modules/donut.d.ts +3 -0
  205. package/components/leaflet-map/modules/donut.js +25 -0
  206. package/components/leaflet-map/modules/donut.js.map +1 -0
  207. package/components/leaflet-map/modules/map.d.ts +14 -0
  208. package/components/leaflet-map/modules/map.js +154 -0
  209. package/components/leaflet-map/modules/map.js.map +1 -0
  210. package/components/leaflet-map/modules/node.d.ts +9 -0
  211. package/components/leaflet-map/modules/node.js +162 -0
  212. package/components/leaflet-map/modules/node.js.map +1 -0
  213. package/components/leaflet-map/modules/selectionRing.d.ts +7 -0
  214. package/components/leaflet-map/modules/selectionRing.js +41 -0
  215. package/components/leaflet-map/modules/selectionRing.js.map +1 -0
  216. package/components/leaflet-map/modules/utils.d.ts +50 -0
  217. package/components/leaflet-map/modules/utils.js +210 -0
  218. package/components/leaflet-map/modules/utils.js.map +1 -0
  219. package/{src/components → components}/leaflet-map/renderer/leaflet-maplibre-gl.js +78 -76
  220. package/components/leaflet-map/renderer/leaflet-maplibre-gl.js.map +1 -0
  221. package/components/leaflet-map/renderer/map-style.d.ts +4 -0
  222. package/components/leaflet-map/renderer/map-style.js +15 -0
  223. package/components/leaflet-map/renderer/map-style.js.map +1 -0
  224. package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js +40 -0
  225. package/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json.js.map +1 -0
  226. package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js +40 -0
  227. package/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json.js.map +1 -0
  228. package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js +4981 -0
  229. package/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json.js.map +1 -0
  230. package/components/leaflet-map/renderer/mapboxgl-layer.d.ts +8 -0
  231. package/components/leaflet-map/renderer/mapboxgl-layer.js +27 -0
  232. package/components/leaflet-map/renderer/mapboxgl-layer.js.map +1 -0
  233. package/components/leaflet-map/renderer/mapboxgl-utils.d.ts +4 -0
  234. package/components/leaflet-map/renderer/mapboxgl-utils.js +39 -0
  235. package/components/leaflet-map/renderer/mapboxgl-utils.js.map +1 -0
  236. package/{src/components → components}/leaflet-map/renderer/maplibre-gl.css.js +4 -2
  237. package/components/leaflet-map/renderer/maplibre-gl.css.js.map +1 -0
  238. package/components/leaflet-map/style.d.ts +52 -0
  239. package/components/leaflet-map/style.js +183 -0
  240. package/components/leaflet-map/style.js.map +1 -0
  241. package/components/leaflet-map/types.d.ts +75 -0
  242. package/components/leaflet-map/types.js +15 -0
  243. package/components/leaflet-map/types.js.map +1 -0
  244. package/components/line/config.d.ts +30 -0
  245. package/components/line/config.js +17 -0
  246. package/components/line/config.js.map +1 -0
  247. package/components/line/index.d.ts +27 -0
  248. package/components/line/index.js +152 -0
  249. package/components/line/index.js.map +1 -0
  250. package/components/line/style.d.ts +6 -0
  251. package/{src/components/line/style.ts → components/line/style.js} +16 -18
  252. package/components/line/style.js.map +1 -0
  253. package/components/line/types.d.ts +12 -0
  254. package/components/nested-donut/config.d.ts +59 -0
  255. package/components/nested-donut/config.js +19 -0
  256. package/components/nested-donut/config.js.map +1 -0
  257. package/components/nested-donut/index.d.ts +38 -0
  258. package/components/nested-donut/index.js +133 -0
  259. package/components/nested-donut/index.js.map +1 -0
  260. package/components/nested-donut/modules/arc.d.ts +17 -0
  261. package/components/nested-donut/modules/arc.js +50 -0
  262. package/components/nested-donut/modules/arc.js.map +1 -0
  263. package/components/nested-donut/modules/label.d.ts +7 -0
  264. package/components/nested-donut/modules/label.js +34 -0
  265. package/components/nested-donut/modules/label.js.map +1 -0
  266. package/components/nested-donut/style.d.ts +26 -0
  267. package/components/nested-donut/style.js +70 -0
  268. package/components/nested-donut/style.js.map +1 -0
  269. package/components/nested-donut/types.d.ts +24 -0
  270. package/components/nested-donut/types.js +11 -0
  271. package/components/nested-donut/types.js.map +1 -0
  272. package/components/sankey/config.d.ts +162 -0
  273. package/components/sankey/config.js +65 -0
  274. package/components/sankey/config.js.map +1 -0
  275. package/components/sankey/index.d.ts +59 -0
  276. package/components/sankey/index.js +306 -0
  277. package/components/sankey/index.js.map +1 -0
  278. package/components/sankey/modules/label.d.ts +23 -0
  279. package/components/sankey/modules/label.js +168 -0
  280. package/components/sankey/modules/label.js.map +1 -0
  281. package/components/sankey/modules/link.d.ts +14 -0
  282. package/components/sankey/modules/link.js +108 -0
  283. package/components/sankey/modules/link.js.map +1 -0
  284. package/components/sankey/modules/node.d.ts +10 -0
  285. package/components/sankey/modules/node.js +156 -0
  286. package/components/sankey/modules/node.js.map +1 -0
  287. package/components/sankey/style.d.ts +20 -0
  288. package/{src/components/sankey/style.ts → components/sankey/style.js} +44 -60
  289. package/components/sankey/style.js.map +1 -0
  290. package/components/sankey/types.d.ts +84 -0
  291. package/components/sankey/types.js +34 -0
  292. package/components/sankey/types.js.map +1 -0
  293. package/components/scatter/config.d.ts +44 -0
  294. package/components/scatter/config.js +23 -0
  295. package/components/scatter/config.js.map +1 -0
  296. package/components/scatter/index.d.ts +28 -0
  297. package/components/scatter/index.js +167 -0
  298. package/components/scatter/index.js.map +1 -0
  299. package/components/scatter/modules/point.d.ts +7 -0
  300. package/components/scatter/modules/point.js +86 -0
  301. package/components/scatter/modules/point.js.map +1 -0
  302. package/components/scatter/modules/utils.d.ts +11 -0
  303. package/components/scatter/modules/utils.js +112 -0
  304. package/components/scatter/modules/utils.js.map +1 -0
  305. package/components/scatter/style.d.ts +5 -0
  306. package/{src/components/scatter/style.ts → components/scatter/style.js} +14 -15
  307. package/components/scatter/style.js.map +1 -0
  308. package/components/scatter/types.d.ts +19 -0
  309. package/components/stacked-bar/config.d.ts +38 -0
  310. package/components/stacked-bar/config.js +20 -0
  311. package/components/stacked-bar/config.js.map +1 -0
  312. package/components/stacked-bar/index.d.ts +28 -0
  313. package/components/stacked-bar/index.js +208 -0
  314. package/components/stacked-bar/index.js.map +1 -0
  315. package/components/stacked-bar/style.d.ts +5 -0
  316. package/{src/components/stacked-bar/style.ts → components/stacked-bar/style.js} +14 -15
  317. package/components/stacked-bar/style.js.map +1 -0
  318. package/components/stacked-bar/types.d.ts +5 -0
  319. package/components/timeline/config.d.ts +43 -0
  320. package/components/timeline/config.js +24 -0
  321. package/components/timeline/config.js.map +1 -0
  322. package/components/timeline/index.d.ts +41 -0
  323. package/components/timeline/index.js +244 -0
  324. package/components/timeline/index.js.map +1 -0
  325. package/components/timeline/style.d.ts +13 -0
  326. package/{src/components/timeline/style.ts → components/timeline/style.js} +30 -39
  327. package/components/timeline/style.js.map +1 -0
  328. package/components/tooltip/config.d.ts +68 -0
  329. package/components/tooltip/config.js +20 -0
  330. package/components/tooltip/config.js.map +1 -0
  331. package/components/tooltip/index.d.ts +36 -0
  332. package/components/tooltip/index.js +184 -0
  333. package/components/tooltip/index.js.map +1 -0
  334. package/{src/components → components}/tooltip/style.js +14 -11
  335. package/components/tooltip/style.js.map +1 -0
  336. package/components/topojson-map/config.d.ts +99 -0
  337. package/components/topojson-map/config.js +42 -0
  338. package/components/topojson-map/config.js.map +1 -0
  339. package/components/topojson-map/index.d.ts +52 -0
  340. package/components/topojson-map/index.js +355 -0
  341. package/components/topojson-map/index.js.map +1 -0
  342. package/components/topojson-map/style.d.ts +11 -0
  343. package/{src/components/topojson-map/style.ts → components/topojson-map/style.js} +26 -33
  344. package/components/topojson-map/style.js.map +1 -0
  345. package/components/topojson-map/types.d.ts +78 -0
  346. package/components/topojson-map/types.js +80 -0
  347. package/components/topojson-map/types.js.map +1 -0
  348. package/components/topojson-map/utils.d.ts +3 -0
  349. package/components/topojson-map/utils.js +30 -0
  350. package/components/topojson-map/utils.js.map +1 -0
  351. package/components/vis-controls/config.d.ts +12 -0
  352. package/components/vis-controls/config.js +13 -0
  353. package/components/vis-controls/config.js.map +1 -0
  354. package/components/vis-controls/index.d.ts +14 -0
  355. package/components/vis-controls/index.js +52 -0
  356. package/components/vis-controls/index.js.map +1 -0
  357. package/components/vis-controls/style.d.ts +11 -0
  358. package/{src/components/vis-controls/style.ts → components/vis-controls/style.js} +27 -34
  359. package/components/vis-controls/style.js.map +1 -0
  360. package/components/vis-controls/types.d.ts +13 -0
  361. package/components/vis-controls/types.js +8 -0
  362. package/components/vis-controls/types.js.map +1 -0
  363. package/components/xy-labels/config.d.ts +48 -0
  364. package/components/xy-labels/config.js +25 -0
  365. package/components/xy-labels/config.js.map +1 -0
  366. package/components/xy-labels/index.d.ts +15 -0
  367. package/components/xy-labels/index.js +87 -0
  368. package/components/xy-labels/index.js.map +1 -0
  369. package/components/xy-labels/modules/label.d.ts +9 -0
  370. package/components/xy-labels/modules/label.js +107 -0
  371. package/components/xy-labels/modules/label.js.map +1 -0
  372. package/components/xy-labels/style.d.ts +5 -0
  373. package/{src/components/xy-labels/style.ts → components/xy-labels/style.js} +14 -15
  374. package/components/xy-labels/style.js.map +1 -0
  375. package/components/xy-labels/types.d.ts +23 -0
  376. package/components/xy-labels/types.js +9 -0
  377. package/components/xy-labels/types.js.map +1 -0
  378. package/components.d.ts +51 -0
  379. package/components.js +29 -0
  380. package/components.js.map +1 -0
  381. package/containers/single-container/config.d.ts +12 -0
  382. package/containers/single-container/config.js +12 -0
  383. package/containers/single-container/config.js.map +1 -0
  384. package/containers/single-container/index.d.ts +19 -0
  385. package/containers/single-container/index.js +128 -0
  386. package/containers/single-container/index.js.map +1 -0
  387. package/containers/xy-container/config.d.ts +99 -0
  388. package/containers/xy-container/config.js +30 -0
  389. package/containers/xy-container/config.js.map +1 -0
  390. package/containers/xy-container/index.d.ts +34 -0
  391. package/containers/xy-container/index.js +330 -0
  392. package/containers/xy-container/index.js.map +1 -0
  393. package/containers.d.ts +6 -0
  394. package/containers.js +4 -0
  395. package/containers.js.map +1 -0
  396. package/core/component/config.d.ts +58 -0
  397. package/core/component/config.js +14 -0
  398. package/core/component/config.js.map +1 -0
  399. package/core/component/index.d.ts +43 -0
  400. package/core/component/index.js +118 -0
  401. package/core/component/index.js.map +1 -0
  402. package/core/component/types.d.ts +2 -0
  403. package/core/component/types.js +2 -0
  404. package/core/component/types.js.map +1 -0
  405. package/core/config/index.d.ts +3 -0
  406. package/core/config/index.js +16 -0
  407. package/core/config/index.js.map +1 -0
  408. package/core/container/config.d.ts +48 -0
  409. package/core/container/config.js +29 -0
  410. package/core/container/config.js.map +1 -0
  411. package/core/container/index.d.ts +26 -0
  412. package/core/container/index.js +106 -0
  413. package/core/container/index.js.map +1 -0
  414. package/core/xy-component/config.d.ts +38 -0
  415. package/core/xy-component/config.js +20 -0
  416. package/core/xy-component/config.js.map +1 -0
  417. package/core/xy-component/index.d.ts +27 -0
  418. package/core/xy-component/index.js +74 -0
  419. package/core/xy-component/index.js.map +1 -0
  420. package/data-models/core.d.ts +6 -0
  421. package/data-models/core.js +14 -0
  422. package/data-models/core.js.map +1 -0
  423. package/data-models/graph.d.ts +24 -0
  424. package/data-models/graph.js +107 -0
  425. package/data-models/graph.js.map +1 -0
  426. package/data-models/map-graph.d.ts +21 -0
  427. package/data-models/map-graph.js +62 -0
  428. package/data-models/map-graph.js.map +1 -0
  429. package/data-models/map.d.ts +5 -0
  430. package/data-models/map.js +12 -0
  431. package/data-models/map.js.map +1 -0
  432. package/data-models/series.d.ts +6 -0
  433. package/data-models/series.js +19 -0
  434. package/data-models/series.js.map +1 -0
  435. package/index.d.ts +7 -0
  436. package/index.js +55 -0
  437. package/index.js.map +1 -0
  438. package/maps/china-provinces.json.js +140373 -0
  439. package/maps/fr-regions.json.js +14162 -0
  440. package/maps/germany-regions.json.js +35760 -0
  441. package/maps/ind-regions.json.js +290584 -0
  442. package/maps/uk-regions.json.js +96233 -0
  443. package/maps/us-counties.json.js +206318 -0
  444. package/maps/us-states.json.js +16345 -0
  445. package/maps/world-110m-alpha.json.js +251366 -0
  446. package/maps/world-simple.json.js +89428 -0
  447. package/maps/world-simplest.json.js +28175 -0
  448. package/maps.d.ts +60 -0
  449. package/maps.js +23 -0
  450. package/package.json +1 -1
  451. package/styles/colors.d.ts +7 -0
  452. package/styles/colors.js +24 -0
  453. package/styles/colors.js.map +1 -0
  454. package/styles/index.d.ts +7 -0
  455. package/styles/index.js +38 -0
  456. package/styles/index.js.map +1 -0
  457. package/styles/sizes.d.ts +2 -0
  458. package/{src/styles/sizes.ts → styles/sizes.js} +8 -6
  459. package/styles/sizes.js.map +1 -0
  460. package/types/accessor.d.ts +5 -0
  461. package/types/accessor.js +2 -0
  462. package/types/accessor.js.map +1 -0
  463. package/types/component.d.ts +13 -0
  464. package/types/component.js +14 -0
  465. package/types/component.js.map +1 -0
  466. package/types/curve.d.ts +40 -0
  467. package/types/curve.js +46 -0
  468. package/types/curve.js.map +1 -0
  469. package/types/data.d.ts +7 -0
  470. package/types/data.js +2 -0
  471. package/types/data.js.map +1 -0
  472. package/types/direction.d.ts +6 -0
  473. package/types/direction.js +10 -0
  474. package/types/direction.js.map +1 -0
  475. package/types/graph.d.ts +35 -0
  476. package/types/graph.js +2 -0
  477. package/types/graph.js.map +1 -0
  478. package/types/map.d.ts +4 -0
  479. package/types/map.js +2 -0
  480. package/types/map.js.map +1 -0
  481. package/types/misc.d.ts +8 -0
  482. package/types/position.d.ts +20 -0
  483. package/types/position.js +27 -0
  484. package/types/position.js.map +1 -0
  485. package/types/scale.d.ts +23 -0
  486. package/types/scale.js +27 -0
  487. package/types/scale.js.map +1 -0
  488. package/types/shape.d.ts +7 -0
  489. package/types/shape.js +11 -0
  490. package/types/shape.js.map +1 -0
  491. package/types/spacing.d.ts +6 -0
  492. package/types/spacing.js +2 -0
  493. package/types/spacing.js.map +1 -0
  494. package/types/svg.d.ts +18 -0
  495. package/types/svg.js +22 -0
  496. package/types/svg.js.map +1 -0
  497. package/types/symbol.d.ts +18 -0
  498. package/types/symbol.js +24 -0
  499. package/types/symbol.js.map +1 -0
  500. package/types/text.d.ts +47 -0
  501. package/types/text.js +26 -0
  502. package/types/text.js.map +1 -0
  503. package/types.d.ts +27 -0
  504. package/types.js +30 -0
  505. package/types.js.map +1 -0
  506. package/utils/color.d.ts +10 -0
  507. package/utils/color.js +32 -0
  508. package/utils/color.js.map +1 -0
  509. package/utils/d3.d.ts +3 -0
  510. package/utils/d3.js +16 -0
  511. package/utils/d3.js.map +1 -0
  512. package/utils/data.d.ts +45 -0
  513. package/utils/data.js +274 -0
  514. package/utils/data.js.map +1 -0
  515. package/utils/html.d.ts +1 -0
  516. package/utils/html.js +16 -0
  517. package/utils/html.js.map +1 -0
  518. package/utils/map.d.ts +2 -0
  519. package/utils/map.js +20 -0
  520. package/utils/map.js.map +1 -0
  521. package/utils/misc.d.ts +9 -0
  522. package/utils/misc.js +47 -0
  523. package/utils/misc.js.map +1 -0
  524. package/utils/path.d.ts +23 -0
  525. package/utils/path.js +144 -0
  526. package/utils/path.js.map +1 -0
  527. package/utils/scale.d.ts +1 -0
  528. package/utils/style.d.ts +6 -0
  529. package/utils/style.js +24 -0
  530. package/utils/style.js.map +1 -0
  531. package/utils/svg.d.ts +3 -0
  532. package/utils/text.d.ts +139 -0
  533. package/utils/text.js +443 -0
  534. package/utils/text.js.map +1 -0
  535. package/utils/type.d.ts +5 -0
  536. package/declaration.d.ts +0 -1
  537. package/index.ts +0 -1
  538. package/licences.txt +0 -43
  539. package/maps.ts +0 -1
  540. package/rollup.config.js +0 -71
  541. package/rules/ts-getter-setter.js +0 -35
  542. package/src/components/area/config.ts +0 -29
  543. package/src/components/area/index.ts +0 -133
  544. package/src/components/area/types.ts +0 -2
  545. package/src/components/axis/config.ts +0 -76
  546. package/src/components/axis/index.ts +0 -363
  547. package/src/components/axis/types.ts +0 -4
  548. package/src/components/brush/config.ts +0 -51
  549. package/src/components/brush/index.ts +0 -233
  550. package/src/components/brush/types.ts +0 -8
  551. package/src/components/bullet-legend/config.ts +0 -38
  552. package/src/components/bullet-legend/index.ts +0 -104
  553. package/src/components/bullet-legend/types.ts +0 -7
  554. package/src/components/chord-diagram/config.ts +0 -53
  555. package/src/components/chord-diagram/index.ts +0 -401
  556. package/src/components/chord-diagram/modules/label.ts +0 -155
  557. package/src/components/chord-diagram/modules/link.ts +0 -91
  558. package/src/components/chord-diagram/modules/node.ts +0 -80
  559. package/src/components/chord-diagram/types.ts +0 -68
  560. package/src/components/crosshair/config.ts +0 -48
  561. package/src/components/crosshair/index.ts +0 -220
  562. package/src/components/crosshair/types.ts +0 -15
  563. package/src/components/donut/config.ts +0 -65
  564. package/src/components/donut/index.ts +0 -148
  565. package/src/components/donut/modules/arc.ts +0 -86
  566. package/src/components/donut/types.ts +0 -17
  567. package/src/components/flow-legend/config.ts +0 -31
  568. package/src/components/flow-legend/index.ts +0 -103
  569. package/src/components/flow-legend/types.ts +0 -10
  570. package/src/components/free-brush/config.ts +0 -54
  571. package/src/components/free-brush/index.ts +0 -207
  572. package/src/components/free-brush/types.ts +0 -8
  573. package/src/components/graph/config.ts +0 -280
  574. package/src/components/graph/index.ts +0 -809
  575. package/src/components/graph/modules/layout-helpers.ts +0 -96
  576. package/src/components/graph/modules/layout.ts +0 -502
  577. package/src/components/graph/modules/link/helper.ts +0 -105
  578. package/src/components/graph/modules/link/index.ts +0 -302
  579. package/src/components/graph/modules/node/helper.ts +0 -162
  580. package/src/components/graph/modules/node/index.ts +0 -343
  581. package/src/components/graph/modules/panel/helper.ts +0 -160
  582. package/src/components/graph/modules/panel/index.ts +0 -137
  583. package/src/components/graph/modules/shape.ts +0 -108
  584. package/src/components/graph/modules/zoom-levels.ts +0 -6
  585. package/src/components/graph/style.ts +0 -72
  586. package/src/components/graph/types.ts +0 -152
  587. package/src/components/grouped-bar/config.ts +0 -40
  588. package/src/components/grouped-bar/index.ts +0 -325
  589. package/src/components/leaflet-flow-map/config.ts +0 -60
  590. package/src/components/leaflet-flow-map/index.ts +0 -279
  591. package/src/components/leaflet-flow-map/renderer-utils.ts +0 -14
  592. package/src/components/leaflet-flow-map/renderer.ts +0 -146
  593. package/src/components/leaflet-flow-map/types.ts +0 -18
  594. package/src/components/leaflet-map/config.ts +0 -234
  595. package/src/components/leaflet-map/index.ts +0 -808
  596. package/src/components/leaflet-map/leaflet.css +0 -625
  597. package/src/components/leaflet-map/modules/clusterBackground.ts +0 -34
  598. package/src/components/leaflet-map/modules/donut.ts +0 -37
  599. package/src/components/leaflet-map/modules/map.ts +0 -178
  600. package/src/components/leaflet-map/modules/node.ts +0 -208
  601. package/src/components/leaflet-map/modules/selectionRing.ts +0 -63
  602. package/src/components/leaflet-map/modules/utils.ts +0 -290
  603. package/src/components/leaflet-map/renderer/map-style.ts +0 -24
  604. package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-dark-theme.json +0 -35
  605. package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-light-theme.json +0 -35
  606. package/src/components/leaflet-map/renderer/mapboxgl/mapboxgl-settings.json +0 -2185
  607. package/src/components/leaflet-map/renderer/mapboxgl-layer.ts +0 -43
  608. package/src/components/leaflet-map/renderer/mapboxgl-utils.ts +0 -40
  609. package/src/components/leaflet-map/style.ts +0 -217
  610. package/src/components/leaflet-map/types.ts +0 -75
  611. package/src/components/line/config.ts +0 -34
  612. package/src/components/line/index.ts +0 -188
  613. package/src/components/line/types.ts +0 -3
  614. package/src/components/nested-donut/config.ts +0 -75
  615. package/src/components/nested-donut/index.ts +0 -176
  616. package/src/components/nested-donut/modules/arc.ts +0 -78
  617. package/src/components/nested-donut/modules/label.ts +0 -63
  618. package/src/components/nested-donut/style.ts +0 -82
  619. package/src/components/nested-donut/types.ts +0 -29
  620. package/src/components/sankey/config.ts +0 -195
  621. package/src/components/sankey/index.ts +0 -387
  622. package/src/components/sankey/modules/label.ts +0 -228
  623. package/src/components/sankey/modules/link.ts +0 -141
  624. package/src/components/sankey/modules/node.ts +0 -221
  625. package/src/components/sankey/types.ts +0 -95
  626. package/src/components/scatter/config.ts +0 -49
  627. package/src/components/scatter/index.ts +0 -220
  628. package/src/components/scatter/modules/point.ts +0 -123
  629. package/src/components/scatter/modules/utils.ts +0 -150
  630. package/src/components/scatter/types.ts +0 -21
  631. package/src/components/stacked-bar/config.ts +0 -42
  632. package/src/components/stacked-bar/index.ts +0 -267
  633. package/src/components/stacked-bar/types.ts +0 -5
  634. package/src/components/timeline/config.ts +0 -49
  635. package/src/components/timeline/index.ts +0 -302
  636. package/src/components/tooltip/config.ts +0 -69
  637. package/src/components/tooltip/index.ts +0 -220
  638. package/src/components/topojson-map/config.ts +0 -124
  639. package/src/components/topojson-map/index.ts +0 -436
  640. package/src/components/topojson-map/types.ts +0 -123
  641. package/src/components/topojson-map/utils.ts +0 -29
  642. package/src/components/vis-controls/config.ts +0 -16
  643. package/src/components/vis-controls/index.ts +0 -68
  644. package/src/components/vis-controls/types.ts +0 -14
  645. package/src/components/xy-labels/config.ts +0 -56
  646. package/src/components/xy-labels/index.ts +0 -109
  647. package/src/components/xy-labels/modules/label.ts +0 -140
  648. package/src/components/xy-labels/types.ts +0 -26
  649. package/src/components.ts +0 -56
  650. package/src/containers/single-container/config.ts +0 -15
  651. package/src/containers/single-container/index.ts +0 -150
  652. package/src/containers/xy-container/config.ts +0 -112
  653. package/src/containers/xy-container/index.ts +0 -407
  654. package/src/containers.ts +0 -6
  655. package/src/core/component/config.ts +0 -61
  656. package/src/core/component/index.ts +0 -154
  657. package/src/core/component/types.ts +0 -9
  658. package/src/core/config/index.ts +0 -12
  659. package/src/core/container/config.ts +0 -56
  660. package/src/core/container/index.ts +0 -136
  661. package/src/core/xy-component/config.ts +0 -46
  662. package/src/core/xy-component/index.ts +0 -90
  663. package/src/data-models/core.ts +0 -15
  664. package/src/data-models/graph.ts +0 -138
  665. package/src/data-models/map-graph.ts +0 -72
  666. package/src/data-models/map.ts +0 -18
  667. package/src/data-models/series.ts +0 -16
  668. package/src/index.ts +0 -7
  669. package/src/maps/china-provinces.json +0 -1
  670. package/src/maps/fr-regions.json +0 -1
  671. package/src/maps/germany-regions.json +0 -1
  672. package/src/maps/ind-regions.json +0 -1
  673. package/src/maps/uk-regions.json +0 -1
  674. package/src/maps/us-counties.json +0 -1
  675. package/src/maps/us-states.json +0 -1
  676. package/src/maps/world-110m-alpha.json +0 -1
  677. package/src/maps/world-simple.json +0 -1
  678. package/src/maps/world-simplest.json +0 -1
  679. package/src/maps.ts +0 -34
  680. package/src/styles/colors.ts +0 -28
  681. package/src/styles/index.ts +0 -38
  682. package/src/types/accessor.ts +0 -5
  683. package/src/types/component.ts +0 -15
  684. package/src/types/curve.ts +0 -62
  685. package/src/types/data.ts +0 -5
  686. package/src/types/direction.ts +0 -6
  687. package/src/types/graph.ts +0 -40
  688. package/src/types/map.ts +0 -5
  689. package/src/types/misc.ts +0 -10
  690. package/src/types/position.ts +0 -23
  691. package/src/types/scale.ts +0 -47
  692. package/src/types/shape.ts +0 -7
  693. package/src/types/spacing.ts +0 -6
  694. package/src/types/svg.ts +0 -32
  695. package/src/types/symbol.ts +0 -21
  696. package/src/types/text.ts +0 -71
  697. package/src/types.ts +0 -31
  698. package/src/utils/color.ts +0 -41
  699. package/src/utils/d3.ts +0 -15
  700. package/src/utils/data.ts +0 -328
  701. package/src/utils/html.ts +0 -13
  702. package/src/utils/map.ts +0 -29
  703. package/src/utils/misc.ts +0 -54
  704. package/src/utils/path.ts +0 -196
  705. package/src/utils/scale.ts +0 -1
  706. package/src/utils/style.ts +0 -37
  707. package/src/utils/svg.ts +0 -49
  708. package/src/utils/text.ts +0 -529
  709. package/src/utils/type.ts +0 -9
  710. package/tsconfig.json +0 -29
@@ -0,0 +1,6 @@
1
+ import type { KebabToCamelCase, RemovePrefix } from "./type";
2
+ export declare function getCssVarNames<T extends Record<string, unknown>, Prefix extends string = '--vis-'>(cssVarsObject: T, prefix?: Prefix): {
3
+ [Property in Extract<keyof T, string> as KebabToCamelCase<RemovePrefix<Property, Prefix>>]: Property;
4
+ };
5
+ export declare function injectGlobalCssVariables<T extends Record<string, string | number | undefined>>(cssVarsObject: T, componentRootClassName: string): void;
6
+ export declare function cssvar<T extends string>(name: T): `var(${T})`;
package/utils/style.js ADDED
@@ -0,0 +1,24 @@
1
+ import { injectGlobal } from '@emotion/css';
2
+ import { kebabCaseToCamel } from './text.js';
3
+
4
+ function getCssVarNames(cssVarsObject, prefix) {
5
+ const defaultPrefix = '--vis-';
6
+ const entries = Object.entries(cssVarsObject);
7
+ return Object.fromEntries(entries.map(([key]) => [kebabCaseToCamel(key.replace(prefix !== null && prefix !== void 0 ? prefix : defaultPrefix, '')), key]));
8
+ }
9
+ function injectGlobalCssVariables(cssVarsObject, componentRootClassName) {
10
+ injectGlobal({
11
+ ':root': cssVarsObject,
12
+ [`body.theme-dark .${componentRootClassName}`]: Object.keys(cssVarsObject)
13
+ .filter(key => key.includes('--vis-dark'))
14
+ .map(key => ({
15
+ [key.replace('--vis-dark', '--vis')]: `var(${key})`,
16
+ })),
17
+ });
18
+ }
19
+ function cssvar(name) {
20
+ return `var(${name})`;
21
+ }
22
+
23
+ export { cssvar, getCssVarNames, injectGlobalCssVariables };
24
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sources":["../../src/utils/style.ts"],"sourcesContent":["import { injectGlobal } from '@emotion/css'\n\nimport { kebabCaseToCamel } from 'utils/text'\nimport type { KebabToCamelCase, RemovePrefix } from 'utils/type'\n\nexport function getCssVarNames<\n T extends Record<string, unknown>,\n Prefix extends string = '--vis-',\n> (cssVarsObject: T, prefix?: Prefix): {\n [Property in Extract<keyof T, string> as KebabToCamelCase<RemovePrefix<Property, Prefix>>]: Property\n} {\n const defaultPrefix = '--vis-'\n const entries = Object.entries(cssVarsObject)\n return Object.fromEntries(\n entries.map(([key]) => [kebabCaseToCamel(key.replace(prefix ?? defaultPrefix, '')), key])\n ) as {\n [Property in Extract<keyof T, string> as KebabToCamelCase<RemovePrefix<Property, Prefix>>]: Property\n }\n}\n\nexport function injectGlobalCssVariables<T extends Record<string, string | number | undefined>> (\n cssVarsObject: T,\n componentRootClassName: string\n): void {\n injectGlobal({\n ':root': cssVarsObject,\n [`body.theme-dark .${componentRootClassName}`]: Object.keys(cssVarsObject)\n .filter(key => key.includes('--vis-dark'))\n .map(key => ({\n [key.replace('--vis-dark', '--vis')]: `var(${key})`,\n })),\n })\n}\n\nexport function cssvar<T extends string> (name: T): `var(${T})` {\n return `var(${name})` as `var(${T})`\n}\n"],"names":[],"mappings":";;;AAKgB,SAAA,cAAc,CAG3B,aAAgB,EAAE,MAAe,EAAA;IAGlC,MAAM,aAAa,GAAG,QAAQ,CAAA;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;AAC7C,IAAA,OAAO,MAAM,CAAC,WAAW,CACvB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,KAAA,IAAA,IAAN,MAAM,KAAA,KAAA,CAAA,GAAN,MAAM,GAAI,aAAa,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAG1F,CAAA;AACH,CAAC;AAEe,SAAA,wBAAwB,CACtC,aAAgB,EAChB,sBAA8B,EAAA;AAE9B,IAAA,YAAY,CAAC;AACX,QAAA,OAAO,EAAE,aAAa;QACtB,CAAC,CAAA,iBAAA,EAAoB,sBAAsB,CAAA,CAAE,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;aACvE,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACzC,aAAA,GAAG,CAAC,GAAG,KAAK;AACX,YAAA,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAO,IAAA,EAAA,GAAG,CAAG,CAAA,CAAA;AACpD,SAAA,CAAC,CAAC;AACN,KAAA,CAAC,CAAA;AACJ,CAAC;AAEK,SAAU,MAAM,CAAoB,IAAO,EAAA;IAC/C,OAAO,CAAA,IAAA,EAAO,IAAI,CAAA,CAAA,CAAkB,CAAA;AACtC;;;;"}
package/utils/svg.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { TransformValues } from "../types/svg";
2
+ export declare function getTransformValues(svgElement: SVGElement): TransformValues;
3
+ export declare function transformValuesToString(transformValues: TransformValues): string;
@@ -0,0 +1,139 @@
1
+ import { Selection } from 'd3-selection';
2
+ import { TrimMode, UnovisText, UnovisTextFrameOptions, UnovisTextOptions, UnovisWrappedText } from "../types/text";
3
+ /**
4
+ * Converts a kebab-case string to camelCase.
5
+ *
6
+ * @param {string} str - The kebab-case string to be converted.
7
+ * @returns {string} The resulting camelCase string.
8
+ */
9
+ export declare function kebabCaseToCamel(str: string): string;
10
+ /**
11
+ * Converts a given string to kebab-case.
12
+ * @param {string} str - The input string to be converted to kebab-case.
13
+ * @returns {string} - The kebab-cased string.
14
+ */
15
+ export declare function kebabCase(str: string): string;
16
+ /**
17
+ * Trims the input string from the start, leaving only the specified maximum length.
18
+ * @param {string} [str=''] - The input string to be trimmed.
19
+ * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.
20
+ * @returns {string} - The trimmed string.
21
+ */
22
+ export declare function trimStringStart(str?: string, maxLength?: number): string;
23
+ /**
24
+ * Trims the input string from the middle, leaving only the specified maximum length.
25
+ * @param {string} [str=''] - The input string to be trimmed.
26
+ * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.
27
+ * @returns {string} - The trimmed string.
28
+ */
29
+ export declare function trimStringMiddle(str?: string, maxLength?: number): string;
30
+ /**
31
+ * Trims the input string from the end, leaving only the specified maximum length.
32
+ * @param {string} [str=''] - The input string to be trimmed.
33
+ * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.
34
+ * @returns {string} - The trimmed string.
35
+ */
36
+ export declare function trimStringEnd(str?: string, maxLength?: number): string;
37
+ /**
38
+ * Trims the input string according to the specified trim mode.
39
+ * @param {string} [str=''] - The input string to be trimmed.
40
+ * @param {number} [length=15] - The maximum allowed length of the trimmed string.
41
+ * @param {TrimMode} [type=TrimMode.Middle] - The trim mode to be applied.
42
+ * @returns {string} - The trimmed string.
43
+ */
44
+ export declare function trimString(str?: string, length?: number, type?: TrimMode): string;
45
+ /**
46
+ * Splits the input string according to the specified separators.
47
+ * @param {string} text - The input string to be split.
48
+ * @param {string[]} [separators=[' ']] - The array of separators to be used for splitting.
49
+ * @returns {string[]} - The array of split words.
50
+ */
51
+ export declare function splitString(text: string, separators?: string[]): string[];
52
+ /**
53
+ * Wraps an SVG text element to fit within the specified width.
54
+ * @param {Selection<SVGTextElement, any, SVGElement, any>} textElement - The SVG text element to be wrapped.
55
+ * @param {number} width - The maximum allowed width for the text element.
56
+ * @param {(string | string[])} [separator=[' ', '-', '.', ',']] - The separator(s) to be used for wrapping.
57
+ */
58
+ export declare function wrapSVGText(textElement: Selection<SVGTextElement, any, SVGElement, any>, width: number, separator?: string | string[]): void;
59
+ /**
60
+ * Trims an SVG text element based on the specified max width, trim type, and other options.
61
+ * @param {Selection<SVGTextElement, any, SVGElement, any>} svgTextSelection - The D3 selection of the SVG text element to be trimmed.
62
+ * @param {number} [maxWidth=50] - The maximum width of the text element.
63
+ * @param {TrimMode} [trimType=TrimMode.Middle] - The type of trim (start, middle, or end).
64
+ * @param {boolean} [fastMode=true] - Whether to use a fast estimation method for text length calculation.
65
+ * @param {number} [fontSize=0] - The font size of the text.
66
+ * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio.
67
+ * @returns {boolean} True if the text was trimmed, false otherwise.
68
+ */
69
+ export declare function trimSVGText(svgTextSelection: Selection<SVGTextElement, any, SVGElement, any>, maxWidth?: number, trimType?: TrimMode, fastMode?: boolean, fontSize?: number, fontWidthToHeightRatio?: number): boolean;
70
+ /**
71
+ * Estimates the length of a string in pixels.
72
+ * @param {string} str - The string to be measured.
73
+ * @param {number} fontSize - The font size of the string.
74
+ * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio.
75
+ * @returns {number} The estimated length of the string in pixels.
76
+ */
77
+ export declare function estimateStringPixelLength(str: string, fontSize: number, fontWidthToHeightRatio?: number): number;
78
+ /**
79
+ * Calculates the precise length of a string in pixels.
80
+ * @param {string} str - The string to be measured.
81
+ * @param {string} [fontFamily] - The font family of the string.
82
+ * @param {(string | number)} [fontSize] - The font size of the string.
83
+ * @returns {number} The precise length of the string in pixels.
84
+ */
85
+ export declare function getPreciseStringLengthPx(str: string, fontFamily?: string, fontSize?: string | number): number;
86
+ /**
87
+ * Estimates the dimensions of an SVG text element.
88
+ *
89
+ * @export
90
+ * @param {Selection<SVGTextElement, any, SVGElement, any>} svgTextSelection - The D3 selection of the SVG text element.
91
+ * @param {number} fontSize - The font size.
92
+ * @param {number} [dy=0.32] - The line height scaling factor.
93
+ * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.
94
+ * @param {number} [fontWidthToHeightRatio] - The font width-to-height ratio.
95
+ * @returns {{width: number, height: number}} - The estimated dimensions of the text element.
96
+ */
97
+ export declare function estimateTextSize(svgTextSelection: Selection<SVGTextElement, any, SVGElement, any>, fontSize: number, dy?: number, fastMode?: boolean, fontWidthToHeightRatio?: number): {
98
+ width: number;
99
+ height: number;
100
+ };
101
+ /**
102
+ * Wraps a text or array of texts to fit within specified width and height, if provided.
103
+ *
104
+ * @export
105
+ * @param {UnovisText | UnovisText[]} text - The text or array of texts to wrap.
106
+ * @param {number | undefined} [width=undefined] - The maximum width of a line in pixels.
107
+ * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.
108
+ * @param {string | string[]} [separator] - The word separators.
109
+ * @returns {UnovisWrappedText[]} - The wrapped texts.
110
+ */
111
+ export declare function getWrappedText(text: UnovisText | UnovisText[], width?: number | undefined, height?: number | undefined, fastMode?: boolean, separator?: string | string[], wordBreak?: boolean): UnovisWrappedText[];
112
+ /**
113
+ * Estimates the height of wrapped text blocks.
114
+ *
115
+ * @export
116
+ * @param {UnovisWrappedText[]} blocks - The wrapped text blocks.
117
+ * @returns {number} - The estimated height of the wrapped text blocks.
118
+ */
119
+ export declare function estimateWrappedTextHeight(blocks: UnovisWrappedText[]): number;
120
+ /**
121
+ * Renders a text or array of texts to an SVG text element.
122
+ * Calling this function will replace the contents of the specified SVG text element.
123
+ *
124
+ * @export
125
+ * @param {SVGTextElement} textElement - The SVG text element to render the text into.
126
+ * @param {UnovisText | UnovisText[]} text - The text or array of texts to render.
127
+ * @param {UnovisTextOptions} options - The text options.
128
+ */
129
+ export declare function renderTextToSvgTextElement(textElement: SVGTextElement, text: UnovisText | UnovisText[], options: UnovisTextOptions): void;
130
+ /**
131
+ * Renders a text or array of texts into a frame.
132
+ * Calling this function will replace the contents of the specified SVG group.
133
+ *
134
+ * @export
135
+ * @param {SVGGElement} group - The SVG group element to render the text into.
136
+ * @param {UnovisText | UnovisText[]} text - The text or array of texts to render.
137
+ * @param {UnovisTextFrameOptions} frameOptions - The text frame options.
138
+ */
139
+ export declare function renderTextIntoFrame(group: SVGGElement, text: UnovisText | UnovisText[], frameOptions: UnovisTextFrameOptions): void;
package/utils/text.js ADDED
@@ -0,0 +1,443 @@
1
+ import { sum } from 'd3-array';
2
+ import { TrimMode, VerticalAlign, TextAlign } from '../types/text.js';
3
+ import { flatten, isArray, merge } from './data.js';
4
+ import { getTextAnchorFromTextAlign } from '../types/svg.js';
5
+ import { getFontWidthToHeightRatio, UNOVIS_TEXT_SEPARATOR_DEFAULT, UNOVIS_TEXT_DEFAULT } from '../styles/index.js';
6
+
7
+ /**
8
+ * Converts a kebab-case string to camelCase.
9
+ *
10
+ * @param {string} str - The kebab-case string to be converted.
11
+ * @returns {string} The resulting camelCase string.
12
+ */
13
+ function kebabCaseToCamel(str) {
14
+ return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
15
+ }
16
+ /**
17
+ * Converts a given string to kebab-case.
18
+ * @param {string} str - The input string to be converted to kebab-case.
19
+ * @returns {string} - The kebab-cased string.
20
+ */
21
+ function kebabCase(str) {
22
+ var _a;
23
+ return (_a = str.match(/[A-Z]{2,}(?=[A-Z][a-z0-9]*|\b)|[A-Z]?[a-z0-9]*|[A-Z]|[0-9]+/g)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).map(x => x.toLowerCase()).join('-');
24
+ }
25
+ /**
26
+ * Trims the input string from the start, leaving only the specified maximum length.
27
+ * @param {string} [str=''] - The input string to be trimmed.
28
+ * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.
29
+ * @returns {string} - The trimmed string.
30
+ */
31
+ function trimStringStart(str = '', maxLength = 15) {
32
+ return str.length > maxLength ? `…${str.substr(str.length - maxLength, maxLength)}` : str;
33
+ }
34
+ /**
35
+ * Trims the input string from the middle, leaving only the specified maximum length.
36
+ * @param {string} [str=''] - The input string to be trimmed.
37
+ * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.
38
+ * @returns {string} - The trimmed string.
39
+ */
40
+ function trimStringMiddle(str = '', maxLength = 15) {
41
+ const dist = Math.floor((maxLength - 3) / 2);
42
+ return str.length > maxLength ? `${str.substr(0, dist)}…${str.substr(-dist, dist)}` : str;
43
+ }
44
+ /**
45
+ * Trims the input string from the end, leaving only the specified maximum length.
46
+ * @param {string} [str=''] - The input string to be trimmed.
47
+ * @param {number} [maxLength=15] - The maximum allowed length of the trimmed string.
48
+ * @returns {string} - The trimmed string.
49
+ */
50
+ function trimStringEnd(str = '', maxLength = 15) {
51
+ return str.length > maxLength ? `${str.substr(0, maxLength)}…` : str;
52
+ }
53
+ /**
54
+ * Trims the input string according to the specified trim mode.
55
+ * @param {string} [str=''] - The input string to be trimmed.
56
+ * @param {number} [length=15] - The maximum allowed length of the trimmed string.
57
+ * @param {TrimMode} [type=TrimMode.Middle] - The trim mode to be applied.
58
+ * @returns {string} - The trimmed string.
59
+ */
60
+ function trimString(str = '', length = 15, type = TrimMode.Middle) {
61
+ let result = trimStringEnd(str, length);
62
+ if (type === TrimMode.Start)
63
+ result = trimStringStart(str, length);
64
+ else if (type === TrimMode.Middle)
65
+ result = trimStringMiddle(str, length);
66
+ return result;
67
+ }
68
+ /**
69
+ * Splits the input string according to the specified separators.
70
+ * @param {string} text - The input string to be split.
71
+ * @param {string[]} [separators=[' ']] - The array of separators to be used for splitting.
72
+ * @returns {string[]} - The array of split words.
73
+ */
74
+ function splitString(text, separators = [' ']) {
75
+ let result = [text];
76
+ for (let i = 0; i < separators.length; i++) {
77
+ const sep = separators[i];
78
+ result.forEach((d, id) => {
79
+ const separated = d.split(sep);
80
+ const words = separated.map((word, j) => `${word}${j === separated.length - 1 ? '' : sep}`);
81
+ result[id] = words;
82
+ });
83
+ result = flatten(result);
84
+ }
85
+ return result;
86
+ }
87
+ /**
88
+ * Wraps an SVG text element to fit within the specified width.
89
+ * @param {Selection<SVGTextElement, any, SVGElement, any>} textElement - The SVG text element to be wrapped.
90
+ * @param {number} width - The maximum allowed width for the text element.
91
+ * @param {(string | string[])} [separator=[' ', '-', '.', ',']] - The separator(s) to be used for wrapping.
92
+ */
93
+ function wrapSVGText(textElement, width, separator = [' ', '-', '.', ',']) {
94
+ const text = textElement.text();
95
+ if (!text)
96
+ return;
97
+ // Wrap
98
+ const separators = (isArray(separator) ? separator : [separator]);
99
+ const words = splitString(text, separators);
100
+ const x = parseFloat(textElement.attr('x')) || 0;
101
+ textElement.text('');
102
+ let tspan = textElement.append('tspan').attr('x', x);
103
+ let tspanContent = `${words[0]}`;
104
+ tspan.text(tspanContent);
105
+ words.forEach((word, i) => {
106
+ if (i === 0)
107
+ return;
108
+ const tspanText = `${tspanContent}${word}`;
109
+ tspan.text(tspanText);
110
+ const tspanWidth = tspan.node().getComputedTextLength();
111
+ if (tspanWidth > width) {
112
+ tspan.text(tspanContent.trim());
113
+ tspan = textElement.append('tspan')
114
+ .attr('x', x)
115
+ .attr('dy', '1.2em')
116
+ .text(word);
117
+ tspanContent = word;
118
+ }
119
+ else
120
+ tspanContent += word;
121
+ });
122
+ }
123
+ /**
124
+ * Trims an SVG text element based on the specified max width, trim type, and other options.
125
+ * @param {Selection<SVGTextElement, any, SVGElement, any>} svgTextSelection - The D3 selection of the SVG text element to be trimmed.
126
+ * @param {number} [maxWidth=50] - The maximum width of the text element.
127
+ * @param {TrimMode} [trimType=TrimMode.Middle] - The type of trim (start, middle, or end).
128
+ * @param {boolean} [fastMode=true] - Whether to use a fast estimation method for text length calculation.
129
+ * @param {number} [fontSize=0] - The font size of the text.
130
+ * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio.
131
+ * @returns {boolean} True if the text was trimmed, false otherwise.
132
+ */
133
+ function trimSVGText(svgTextSelection, maxWidth, trimType, fastMode, fontSize, fontWidthToHeightRatio) {
134
+ var _a;
135
+ if (maxWidth === void 0) { maxWidth = 50; }
136
+ if (trimType === void 0) { trimType = TrimMode.Middle; }
137
+ if (fastMode === void 0) { fastMode = true; }
138
+ if (fontSize === void 0) { fontSize = +((_a = window.getComputedStyle(svgTextSelection.node())) === null || _a === void 0 ? void 0 : _a.fontSize) || 0; }
139
+ if (fontWidthToHeightRatio === void 0) { fontWidthToHeightRatio = getFontWidthToHeightRatio(); }
140
+ const text = svgTextSelection.text();
141
+ const textLength = text.length;
142
+ const textWidth = fastMode ? fontSize * textLength * fontWidthToHeightRatio : svgTextSelection.node().getComputedTextLength();
143
+ const tolerance = 1.1;
144
+ const maxCharacters = Math.ceil(textLength * maxWidth / (tolerance * textWidth));
145
+ if (maxCharacters < textLength) {
146
+ svgTextSelection.text(trimString(text, maxCharacters, trimType));
147
+ return true;
148
+ }
149
+ return false;
150
+ }
151
+ /**
152
+ * Estimates the length of a string in pixels.
153
+ * @param {string} str - The string to be measured.
154
+ * @param {number} fontSize - The font size of the string.
155
+ * @param {number} [fontWidthToHeightRatio=getFontWidthToHeightRatio()] - The font width to height ratio.
156
+ * @returns {number} The estimated length of the string in pixels.
157
+ */
158
+ function estimateStringPixelLength(str, fontSize, fontWidthToHeightRatio = getFontWidthToHeightRatio()) {
159
+ return str.length * fontSize * fontWidthToHeightRatio || 0;
160
+ }
161
+ /**
162
+ * Calculates the precise length of a string in pixels.
163
+ * @param {string} str - The string to be measured.
164
+ * @param {string} [fontFamily] - The font family of the string.
165
+ * @param {(string | number)} [fontSize] - The font size of the string.
166
+ * @returns {number} The precise length of the string in pixels.
167
+ */
168
+ function getPreciseStringLengthPx(str, fontFamily, fontSize) {
169
+ const svgNS = 'http://www.w3.org/2000/svg';
170
+ const svg = document.createElementNS(svgNS, 'svg');
171
+ const text = document.createElementNS(svgNS, 'text');
172
+ text.textContent = str;
173
+ text.setAttribute('font-size', `${fontSize}`);
174
+ text.setAttribute('font-family', fontFamily);
175
+ svg.appendChild(text);
176
+ document.body.appendChild(svg);
177
+ const length = text.getComputedTextLength();
178
+ document.body.removeChild(svg);
179
+ return length;
180
+ }
181
+ /**
182
+ * Estimates the dimensions of an SVG text element.
183
+ *
184
+ * @export
185
+ * @param {Selection<SVGTextElement, any, SVGElement, any>} svgTextSelection - The D3 selection of the SVG text element.
186
+ * @param {number} fontSize - The font size.
187
+ * @param {number} [dy=0.32] - The line height scaling factor.
188
+ * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.
189
+ * @param {number} [fontWidthToHeightRatio] - The font width-to-height ratio.
190
+ * @returns {{width: number, height: number}} - The estimated dimensions of the text element.
191
+ */
192
+ function estimateTextSize(svgTextSelection, fontSize, dy = 0.32, fastMode = true, fontWidthToHeightRatio) {
193
+ fontWidthToHeightRatio = fontWidthToHeightRatio || getFontWidthToHeightRatio();
194
+ const tspanSelection = svgTextSelection.selectAll('tspan');
195
+ const lines = tspanSelection.size() || 1;
196
+ const height = svgTextSelection.text() ? 0.85 * fontSize * lines * (1 + dy) - dy : 0;
197
+ let width = 0;
198
+ if (tspanSelection.empty()) {
199
+ const textLength = svgTextSelection.text().length;
200
+ width = fastMode ? fontSize * textLength * fontWidthToHeightRatio : svgTextSelection.node().getComputedTextLength();
201
+ }
202
+ else {
203
+ for (const tspan of tspanSelection.nodes()) {
204
+ const tspanTextLength = tspan.textContent.length;
205
+ const w = fastMode ? fontSize * tspanTextLength * fontWidthToHeightRatio : tspan.getComputedTextLength();
206
+ if (w > width)
207
+ width = w;
208
+ }
209
+ }
210
+ return { width, height };
211
+ }
212
+ /**
213
+ * Breaks a text block into lines based on the specified width.
214
+ *
215
+ * @param {UnovisText} textBlock - The text block to break into lines.
216
+ * @param {number | undefined} [width=undefined] - The maximum width of a line in pixels.
217
+ * @param {(number | undefined)} [height=undefined] - The height limit for the wrapped text in pixels.
218
+ * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.
219
+ * @param {string | string[]} [separator] - The word separators.
220
+ * @returns {string[]} - The text split into lines.
221
+ */
222
+ function breakTextIntoLines(textBlock, width = undefined, fastMode = true, separator = UNOVIS_TEXT_SEPARATOR_DEFAULT, wordBreak = false) {
223
+ const text = `${textBlock.text}`;
224
+ if (!text)
225
+ return [];
226
+ const separators = Array.isArray(separator) ? separator : [separator];
227
+ const splitByNewLine = text.split('\n');
228
+ return splitByNewLine.map((str) => {
229
+ const lines = [];
230
+ if (!width)
231
+ return [str];
232
+ const words = splitString(str, separators);
233
+ let line = '';
234
+ for (let i = 0; i < words.length; i += 1) {
235
+ const textLengthPx = fastMode
236
+ ? estimateStringPixelLength(line + words[i], textBlock.fontSize, textBlock.fontWidthToHeightRatio)
237
+ : getPreciseStringLengthPx(line + words[i], textBlock.fontFamily, textBlock.fontSize);
238
+ if (textLengthPx < width || i === 0) {
239
+ line += words[i];
240
+ }
241
+ else {
242
+ lines.push(line.trim());
243
+ line = words[i];
244
+ }
245
+ // Word break functionality
246
+ if (wordBreak) {
247
+ while (line.length > 0) {
248
+ const subLineLengthPx = fastMode
249
+ ? estimateStringPixelLength(line, textBlock.fontSize, textBlock.fontWidthToHeightRatio)
250
+ : getPreciseStringLengthPx(line, textBlock.fontFamily, textBlock.fontSize);
251
+ if (subLineLengthPx > width) {
252
+ let breakIndex = (line.trim()).length - 2; // Place at least 2 characters onto the next line
253
+ while (breakIndex > 0) {
254
+ const subLine = `${line.substring(0, breakIndex)}-`; // Use hyphen when force breaking words
255
+ const subLinePx = fastMode
256
+ ? estimateStringPixelLength(subLine, textBlock.fontSize, textBlock.fontWidthToHeightRatio)
257
+ : getPreciseStringLengthPx(subLine, textBlock.fontFamily, textBlock.fontSize);
258
+ if (subLinePx <= width) {
259
+ lines.push(subLine.trim());
260
+ line = line.substring(breakIndex);
261
+ break;
262
+ }
263
+ breakIndex--;
264
+ }
265
+ }
266
+ else {
267
+ break;
268
+ }
269
+ }
270
+ }
271
+ if (i === words.length - 1)
272
+ lines.push(line.trim());
273
+ }
274
+ return lines;
275
+ }).flat();
276
+ }
277
+ /**
278
+ * Wraps a text or array of texts to fit within specified width and height, if provided.
279
+ *
280
+ * @export
281
+ * @param {UnovisText | UnovisText[]} text - The text or array of texts to wrap.
282
+ * @param {number | undefined} [width=undefined] - The maximum width of a line in pixels.
283
+ * @param {boolean} [fastMode=true] - Whether to use a fast estimation method or a more accurate one.
284
+ * @param {string | string[]} [separator] - The word separators.
285
+ * @returns {UnovisWrappedText[]} - The wrapped texts.
286
+ */
287
+ function getWrappedText(text, width = undefined, height = undefined, fastMode = true, separator = UNOVIS_TEXT_SEPARATOR_DEFAULT, wordBreak = false) {
288
+ // Merge input text with default values and convert it to an array if it's not already
289
+ const textArrays = Array.isArray(text) ? text.map(t => merge(UNOVIS_TEXT_DEFAULT, t)) : [merge(UNOVIS_TEXT_DEFAULT, text)];
290
+ // Break input text into lines based on width and separator
291
+ const textWrapped = textArrays.map(block => breakTextIntoLines(block, width, fastMode, separator, wordBreak));
292
+ const firstBlock = textArrays[0];
293
+ let h = -firstBlock.fontSize * (firstBlock.lineHeight - 1);
294
+ const blocks = [];
295
+ // Process each text block and its lines based on height limit
296
+ textArrays.forEach((text, i) => {
297
+ let lines = textWrapped[i];
298
+ const prevBlock = i > 0 ? blocks[i - 1] : undefined;
299
+ const prevBlockMarginBottomPx = prevBlock ? prevBlock.marginBottom : 0;
300
+ const marginTopPx = text.marginTop;
301
+ const effectiveMarginPx = Math.max(prevBlockMarginBottomPx, marginTopPx);
302
+ h += effectiveMarginPx;
303
+ const dh = text.fontSize * text.lineHeight;
304
+ // Iterate over lines and handle text overflow based on the height limit if provided
305
+ for (let k = 0; k < lines.length; k += 1) {
306
+ const line = lines[k];
307
+ h += dh;
308
+ if (height && (h + dh) > height && (k !== lines.length - 1)) {
309
+ const textLengthPx = fastMode
310
+ ? estimateStringPixelLength(line, text.fontSize, text.fontWidthToHeightRatio)
311
+ : getPreciseStringLengthPx(line, text.fontFamily, text.fontSize);
312
+ if (textLengthPx < width) {
313
+ lines[k] += ' …';
314
+ }
315
+ else {
316
+ lines[k] = `${lines[k].substr(0, lines[k].length - 2)}…`;
317
+ }
318
+ lines = lines.slice(0, k + 1);
319
+ break;
320
+ }
321
+ }
322
+ // Create wrapped text block with its calculated properties
323
+ blocks.push(Object.assign(Object.assign({}, text), { _lines: lines, _estimatedHeight: h - ((prevBlock === null || prevBlock === void 0 ? void 0 : prevBlock._estimatedHeight) || 0) }));
324
+ });
325
+ return blocks;
326
+ }
327
+ /**
328
+ * Renders a text or array of texts to SVG tspan strings.
329
+ *
330
+ * @param {UnovisWrappedText[]} blocks - The wrapped text blocks.
331
+ * @param {number} [x=0] - The x-coordinate for the tspan elements.
332
+ * @param {number} [y] - The y-coordinate for the tspan elements.
333
+ * @returns {string[]} - The SVG tspan strings.
334
+ */
335
+ function renderTextToTspanStrings(blocks, x = 0, y) {
336
+ return blocks.map((b, i) => {
337
+ const prevBlock = i > 0 ? blocks[i - 1] : undefined;
338
+ const prevBlockMarginBottomEm = prevBlock ? prevBlock.marginBottom / prevBlock.fontSize : 0;
339
+ const marginTopEm = b.marginTop / b.fontSize;
340
+ const marginEm = Math.max(prevBlockMarginBottomEm, marginTopEm);
341
+ const attributes = {
342
+ fontSize: b.fontSize,
343
+ fontFamily: b.fontFamily,
344
+ fill: b.color,
345
+ y: (i === 0) && y,
346
+ };
347
+ const attributesString = Object.entries(attributes)
348
+ .filter(([_, value]) => value)
349
+ .map(([key, value]) => `${kebabCase(key)}="${escape(value.toString())}"`)
350
+ .join(' ');
351
+ return `<tspan xmlns="http://www.w3.org/2000/svg" ${attributesString}>${b._lines.map((line, k) => {
352
+ let dy;
353
+ if (i === 0 && k === 0)
354
+ dy = 0.8 + marginEm;
355
+ else if (k === 0)
356
+ dy = marginEm + b.lineHeight;
357
+ else
358
+ dy = b.lineHeight;
359
+ return `<tspan x="${x}" dy="${dy}em">${line.length ? line : ' '}</tspan>`;
360
+ }).join('')}</tspan>`;
361
+ });
362
+ }
363
+ /**
364
+ * Estimates the height of wrapped text blocks.
365
+ *
366
+ * @export
367
+ * @param {UnovisWrappedText[]} blocks - The wrapped text blocks.
368
+ * @returns {number} - The estimated height of the wrapped text blocks.
369
+ */
370
+ function estimateWrappedTextHeight(blocks) {
371
+ return sum(blocks, b => b._estimatedHeight);
372
+ }
373
+ /**
374
+ * Renders a text or array of texts to an SVG text element.
375
+ * Calling this function will replace the contents of the specified SVG text element.
376
+ *
377
+ * @export
378
+ * @param {SVGTextElement} textElement - The SVG text element to render the text into.
379
+ * @param {UnovisText | UnovisText[]} text - The text or array of texts to render.
380
+ * @param {UnovisTextOptions} options - The text options.
381
+ */
382
+ function renderTextToSvgTextElement(textElement, text, options) {
383
+ const wrappedText = getWrappedText(text, options.width, undefined, options.fastMode, options.separator, options.wordBreak);
384
+ const textElementX = +textElement.getAttribute('x');
385
+ const textElementY = +textElement.getAttribute('y');
386
+ const x = textElementX !== null && textElementX !== void 0 ? textElementX : 0;
387
+ let y = textElementY !== null && textElementY !== void 0 ? textElementY : 0;
388
+ if (options.textAlign)
389
+ textElement.setAttribute('text-anchor', getTextAnchorFromTextAlign(options.textAlign));
390
+ if (options.verticalAlign && options.verticalAlign !== VerticalAlign.Top) {
391
+ const height = estimateWrappedTextHeight(wrappedText);
392
+ const dy = options.verticalAlign === VerticalAlign.Middle ? -height / 2
393
+ : options.verticalAlign === VerticalAlign.Bottom ? -height : 0;
394
+ y += dy;
395
+ }
396
+ const parser = new DOMParser();
397
+ textElement.textContent = '';
398
+ wrappedText.forEach(block => {
399
+ const svgCode = renderTextToTspanStrings([block], x, y).join('');
400
+ const parsedSvgCode = parser.parseFromString(svgCode, 'image/svg+xml').firstChild;
401
+ textElement.appendChild(parsedSvgCode);
402
+ });
403
+ }
404
+ /**
405
+ * Renders a text or array of texts into a frame.
406
+ * Calling this function will replace the contents of the specified SVG group.
407
+ *
408
+ * @export
409
+ * @param {SVGGElement} group - The SVG group element to render the text into.
410
+ * @param {UnovisText | UnovisText[]} text - The text or array of texts to render.
411
+ * @param {UnovisTextFrameOptions} frameOptions - The text frame options.
412
+ */
413
+ function renderTextIntoFrame(group, text, frameOptions) {
414
+ var _a, _b;
415
+ const wrappedText = getWrappedText(text, frameOptions.width, frameOptions.height, frameOptions.fastMode, frameOptions.separator, frameOptions.wordBreak);
416
+ const x = frameOptions.textAlign === TextAlign.Center ? frameOptions.width / 2
417
+ : frameOptions.textAlign === TextAlign.Right ? frameOptions.width : 0;
418
+ let y = 0;
419
+ const height = estimateWrappedTextHeight(wrappedText);
420
+ if (frameOptions.height && height < frameOptions.height) {
421
+ const height = estimateWrappedTextHeight(wrappedText);
422
+ const dh = frameOptions.height - height;
423
+ y = frameOptions.verticalAlign === VerticalAlign.Middle ? dh / 2
424
+ : frameOptions.verticalAlign === VerticalAlign.Bottom ? dh : 0;
425
+ }
426
+ const translate = (frameOptions.x || frameOptions.y)
427
+ ? `transform="translate(${(_a = frameOptions.x) !== null && _a !== void 0 ? _a : 0},${(_b = frameOptions.y) !== null && _b !== void 0 ? _b : 0})"`
428
+ : '';
429
+ const svgCode = `<text
430
+ xmlns="http://www.w3.org/2000/svg"
431
+ text-anchor="${getTextAnchorFromTextAlign(frameOptions.textAlign)}"
432
+ ${translate}
433
+ >
434
+ ${renderTextToTspanStrings(wrappedText, x, y).join('')}
435
+ </text>`;
436
+ const parser = new DOMParser();
437
+ const parsedSvgCode = parser.parseFromString(svgCode, 'image/svg+xml').firstChild;
438
+ group.textContent = '';
439
+ group.appendChild(parsedSvgCode);
440
+ }
441
+
442
+ export { estimateStringPixelLength, estimateTextSize, estimateWrappedTextHeight, getPreciseStringLengthPx, getWrappedText, kebabCase, kebabCaseToCamel, renderTextIntoFrame, renderTextToSvgTextElement, splitString, trimSVGText, trimString, trimStringEnd, trimStringMiddle, trimStringStart, wrapSVGText };
443
+ //# sourceMappingURL=text.js.map