billboard.js 4.0.3 → 4.1.0-next.2

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 (271) hide show
  1. package/README.md +82 -7
  2. package/dist/billboard.css +1 -1
  3. package/dist/billboard.js +1848 -494
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +19 -24
  6. package/dist/billboard.pkgd.js +1844 -679
  7. package/dist/billboard.pkgd.min.js +24 -29
  8. package/dist/billboard.react.js +205 -0
  9. package/dist/billboard.react.min.js +9 -0
  10. package/dist/billboard.worker.js +10 -0
  11. package/dist/plugin/billboardjs-plugin-bubblecompare.js +5 -3
  12. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-sparkline.js +6 -3
  14. package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
  15. package/dist/plugin/billboardjs-plugin-stanford.js +6 -3
  16. package/dist/plugin/billboardjs-plugin-stanford.min.js +3 -3
  17. package/dist/plugin/billboardjs-plugin-tableview.js +59 -27
  18. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  19. package/dist/plugin/billboardjs-plugin-textoverlap.js +75 -55
  20. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +5 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  23. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +6 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +3 -3
  25. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +6 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  27. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +59 -27
  28. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +11 -11
  29. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +68 -3557
  30. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +8 -8
  31. package/dist/theme/dark.css +1 -1
  32. package/dist/theme/dark.min.css +1 -1
  33. package/dist/theme/datalab.css +1 -1
  34. package/dist/theme/datalab.min.css +1 -1
  35. package/dist/theme/graph.css +1 -1
  36. package/dist/theme/graph.min.css +1 -1
  37. package/dist/theme/insight.css +1 -1
  38. package/dist/theme/insight.min.css +1 -1
  39. package/dist/theme/modern.css +1 -1
  40. package/dist/theme/modern.min.css +1 -1
  41. package/dist-esm/Chart/Chart.js +134 -152
  42. package/dist-esm/Chart/api/axis.js +217 -237
  43. package/dist-esm/Chart/api/category.js +54 -54
  44. package/dist-esm/Chart/api/chart.js +172 -215
  45. package/dist-esm/Chart/api/color.js +21 -21
  46. package/dist-esm/Chart/api/data.js +172 -173
  47. package/dist-esm/Chart/api/export.js +242 -262
  48. package/dist-esm/Chart/api/flow.js +198 -254
  49. package/dist-esm/Chart/api/focus.js +136 -143
  50. package/dist-esm/Chart/api/grid.js +191 -190
  51. package/dist-esm/Chart/api/group.js +31 -34
  52. package/dist-esm/Chart/api/legend.js +54 -63
  53. package/dist-esm/Chart/api/load.js +237 -257
  54. package/dist-esm/Chart/api/regions.js +148 -168
  55. package/dist-esm/Chart/api/selection.js +181 -139
  56. package/dist-esm/Chart/api/show.js +133 -147
  57. package/dist-esm/Chart/api/stubs.js +43 -42
  58. package/dist-esm/Chart/api/subchart.js +155 -172
  59. package/dist-esm/Chart/api/tooltip.js +132 -177
  60. package/dist-esm/Chart/api/x.js +67 -71
  61. package/dist-esm/Chart/api/zoom.js +183 -220
  62. package/dist-esm/ChartInternal/Axis/Axis.js +1059 -1266
  63. package/dist-esm/ChartInternal/Axis/AxisRenderer.js +408 -540
  64. package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +113 -149
  65. package/dist-esm/ChartInternal/ChartInternal.js +573 -749
  66. package/dist-esm/ChartInternal/data/convert.helper.js +133 -159
  67. package/dist-esm/ChartInternal/data/convert.js +200 -229
  68. package/dist-esm/ChartInternal/data/data.js +967 -1153
  69. package/dist-esm/ChartInternal/data/load.js +145 -197
  70. package/dist-esm/ChartInternal/interactions/drag.js +86 -122
  71. package/dist-esm/ChartInternal/interactions/eventrect.js +455 -621
  72. package/dist-esm/ChartInternal/interactions/flow.js +151 -215
  73. package/dist-esm/ChartInternal/interactions/interaction.js +214 -252
  74. package/dist-esm/ChartInternal/interactions/subchart.js +425 -300
  75. package/dist-esm/ChartInternal/interactions/zoom.js +321 -440
  76. package/dist-esm/ChartInternal/internals/category.js +18 -18
  77. package/dist-esm/ChartInternal/internals/class.js +89 -99
  78. package/dist-esm/ChartInternal/internals/clip.js +88 -119
  79. package/dist-esm/ChartInternal/internals/color.js +233 -288
  80. package/dist-esm/ChartInternal/internals/domain.js +452 -588
  81. package/dist-esm/ChartInternal/internals/format.js +64 -77
  82. package/dist-esm/ChartInternal/internals/grid.js +333 -457
  83. package/dist-esm/ChartInternal/internals/legend.js +675 -927
  84. package/dist-esm/ChartInternal/internals/redraw.js +200 -289
  85. package/dist-esm/ChartInternal/internals/region.js +106 -159
  86. package/dist-esm/ChartInternal/internals/scale.js +186 -215
  87. package/dist-esm/ChartInternal/internals/selection.js +132 -159
  88. package/dist-esm/ChartInternal/internals/size.axis.js +92 -139
  89. package/dist-esm/ChartInternal/internals/size.js +286 -394
  90. package/dist-esm/ChartInternal/internals/style.js +39 -41
  91. package/dist-esm/ChartInternal/internals/subchart.util.js +49 -0
  92. package/dist-esm/ChartInternal/internals/text.arc.js +155 -219
  93. package/dist-esm/ChartInternal/internals/text.js +368 -528
  94. package/dist-esm/ChartInternal/internals/text.util.js +179 -239
  95. package/dist-esm/ChartInternal/internals/title.js +96 -121
  96. package/dist-esm/ChartInternal/internals/tooltip.js +450 -586
  97. package/dist-esm/ChartInternal/internals/transform.js +79 -97
  98. package/dist-esm/ChartInternal/internals/type.js +285 -236
  99. package/dist-esm/ChartInternal/shape/arc.js +825 -1112
  100. package/dist-esm/ChartInternal/shape/area.js +73 -94
  101. package/dist-esm/ChartInternal/shape/bar.js +227 -288
  102. package/dist-esm/ChartInternal/shape/bubble.js +9 -8
  103. package/dist-esm/ChartInternal/shape/candlestick.js +110 -138
  104. package/dist-esm/ChartInternal/shape/core/barRadius.js +197 -133
  105. package/dist-esm/ChartInternal/shape/core/bubble.js +64 -73
  106. package/dist-esm/ChartInternal/shape/core/candlestick.js +93 -86
  107. package/dist-esm/ChartInternal/shape/core/dataRegion.js +68 -75
  108. package/dist-esm/ChartInternal/shape/core/geometry.js +112 -112
  109. package/dist-esm/ChartInternal/shape/core/path.js +142 -115
  110. package/dist-esm/ChartInternal/shape/core/point.js +105 -125
  111. package/dist-esm/ChartInternal/shape/core/treemap.js +83 -88
  112. package/dist-esm/ChartInternal/shape/funnel.js +310 -338
  113. package/dist-esm/ChartInternal/shape/gauge.js +71 -103
  114. package/dist-esm/ChartInternal/shape/line.js +208 -278
  115. package/dist-esm/ChartInternal/shape/point.js +310 -425
  116. package/dist-esm/ChartInternal/shape/polar.js +84 -109
  117. package/dist-esm/ChartInternal/shape/radar.js +228 -318
  118. package/dist-esm/ChartInternal/shape/shape.js +782 -843
  119. package/dist-esm/ChartInternal/shape/treemap.js +152 -190
  120. package/dist-esm/canvas/CanvasAxisRenderer.js +1180 -1328
  121. package/dist-esm/canvas/CanvasEngine.js +148 -166
  122. package/dist-esm/canvas/CanvasPainter.js +395 -411
  123. package/dist-esm/canvas/CanvasRenderer.js +1584 -1834
  124. package/dist-esm/canvas/CanvasTheme.js +899 -802
  125. package/dist-esm/canvas/HitDetector.js +394 -463
  126. package/dist-esm/canvas/axisTicks.js +672 -786
  127. package/dist-esm/canvas/classes.js +19 -17
  128. package/dist-esm/canvas/color.js +40 -59
  129. package/dist-esm/canvas/geometry.js +38 -38
  130. package/dist-esm/canvas/labels.js +318 -371
  131. package/dist-esm/canvas/pointPattern.js +578 -580
  132. package/dist-esm/canvas/util.js +242 -262
  133. package/dist-esm/config/Options/Options.js +29 -32
  134. package/dist-esm/config/Options/axis/axis.js +101 -101
  135. package/dist-esm/config/Options/axis/x.js +759 -755
  136. package/dist-esm/config/Options/axis/y.js +525 -522
  137. package/dist-esm/config/Options/axis/y2.js +501 -485
  138. package/dist-esm/config/Options/common/boost.js +93 -32
  139. package/dist-esm/config/Options/common/color.js +88 -87
  140. package/dist-esm/config/Options/common/grid.js +74 -73
  141. package/dist-esm/config/Options/common/legend.js +180 -179
  142. package/dist-esm/config/Options/common/main.js +474 -473
  143. package/dist-esm/config/Options/common/point.js +160 -159
  144. package/dist-esm/config/Options/common/title.js +47 -46
  145. package/dist-esm/config/Options/common/tooltip.js +253 -252
  146. package/dist-esm/config/Options/data/axis.js +173 -172
  147. package/dist-esm/config/Options/data/data.js +958 -957
  148. package/dist-esm/config/Options/data/selection.js +131 -130
  149. package/dist-esm/config/Options/interaction/interaction.js +53 -52
  150. package/dist-esm/config/Options/interaction/subchart.js +164 -73
  151. package/dist-esm/config/Options/interaction/zoom.js +86 -85
  152. package/dist-esm/config/Options/shape/arc.js +150 -149
  153. package/dist-esm/config/Options/shape/area.js +69 -68
  154. package/dist-esm/config/Options/shape/bar.js +147 -146
  155. package/dist-esm/config/Options/shape/bubble.js +35 -34
  156. package/dist-esm/config/Options/shape/candlestick.js +61 -60
  157. package/dist-esm/config/Options/shape/donut.js +181 -180
  158. package/dist-esm/config/Options/shape/funnel.js +49 -48
  159. package/dist-esm/config/Options/shape/gauge.js +237 -236
  160. package/dist-esm/config/Options/shape/line.js +58 -57
  161. package/dist-esm/config/Options/shape/pie.js +185 -184
  162. package/dist-esm/config/Options/shape/polar.js +167 -166
  163. package/dist-esm/config/Options/shape/radar.js +76 -75
  164. package/dist-esm/config/Options/shape/scatter.js +36 -36
  165. package/dist-esm/config/Options/shape/spline.js +46 -46
  166. package/dist-esm/config/Options/shape/treemap.js +80 -79
  167. package/dist-esm/config/Store/Element.js +64 -62
  168. package/dist-esm/config/Store/State.js +189 -200
  169. package/dist-esm/config/Store/Store.js +25 -26
  170. package/dist-esm/config/classes.js +157 -155
  171. package/dist-esm/config/config.js +26 -35
  172. package/dist-esm/config/const.js +120 -128
  173. package/dist-esm/config/resolver/axis.core.js +25 -25
  174. package/dist-esm/config/resolver/axis.js +26 -27
  175. package/dist-esm/config/resolver/canvas.js +2071 -2472
  176. package/dist-esm/config/resolver/canvasShape.js +201 -177
  177. package/dist-esm/config/resolver/category.js +26 -27
  178. package/dist-esm/config/resolver/export.js +24 -26
  179. package/dist-esm/config/resolver/flow.js +29 -31
  180. package/dist-esm/config/resolver/grid.js +34 -35
  181. package/dist-esm/config/resolver/interaction/selection.js +17 -17
  182. package/dist-esm/config/resolver/interaction/subchart.js +17 -17
  183. package/dist-esm/config/resolver/interaction/zoom.js +17 -17
  184. package/dist-esm/config/resolver/regions.js +30 -31
  185. package/dist-esm/config/resolver/shape/arc.helpers.js +19 -19
  186. package/dist-esm/config/resolver/shape/area.js +17 -17
  187. package/dist-esm/config/resolver/shape/axis.helpers.js +28 -25
  188. package/dist-esm/config/resolver/shape/bar.js +13 -13
  189. package/dist-esm/config/resolver/shape/bubble.js +18 -14
  190. package/dist-esm/config/resolver/shape/candlestick.js +13 -13
  191. package/dist-esm/config/resolver/shape/donut.js +11 -11
  192. package/dist-esm/config/resolver/shape/funnel.js +11 -11
  193. package/dist-esm/config/resolver/shape/gauge.js +12 -12
  194. package/dist-esm/config/resolver/shape/line.js +10 -10
  195. package/dist-esm/config/resolver/shape/pie.js +11 -11
  196. package/dist-esm/config/resolver/shape/polar.js +12 -12
  197. package/dist-esm/config/resolver/shape/radar.js +22 -14
  198. package/dist-esm/config/resolver/shape/scatter.js +13 -13
  199. package/dist-esm/config/resolver/shape/treemap.js +11 -11
  200. package/dist-esm/core.js +208 -211
  201. package/dist-esm/index.canvas.js +14 -13
  202. package/dist-esm/index.esm.js +25 -24
  203. package/dist-esm/module/Cache.js +117 -129
  204. package/dist-esm/module/browser.js +30 -35
  205. package/dist-esm/module/dsv.js +107 -127
  206. package/dist-esm/module/error.js +45 -52
  207. package/dist-esm/module/generator.js +75 -83
  208. package/dist-esm/module/sanitize.js +302 -399
  209. package/dist-esm/module/util/brush.js +27 -38
  210. package/dist-esm/module/util/dom.js +288 -348
  211. package/dist-esm/module/util/object.js +277 -341
  212. package/dist-esm/module/util/type-checks.js +21 -25
  213. package/dist-esm/module/worker.js +312 -130
  214. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +185 -198
  215. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +442 -450
  216. package/dist-esm/plugin/billboardjs-plugin-stanford.js +813 -950
  217. package/dist-esm/plugin/billboardjs-plugin-tableview.js +708 -788
  218. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +344 -301
  219. package/dist-esm/react/index.js +157 -0
  220. package/package.json +28 -8
  221. package/src/Chart/api/selection.ts +130 -5
  222. package/src/ChartInternal/Axis/Axis.ts +164 -65
  223. package/src/ChartInternal/Axis/AxisRenderer.ts +41 -8
  224. package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
  225. package/src/ChartInternal/ChartInternal.ts +1 -1
  226. package/src/ChartInternal/data/convert.ts +54 -4
  227. package/src/ChartInternal/data/data.ts +4 -1
  228. package/src/ChartInternal/interactions/eventrect.ts +8 -2
  229. package/src/ChartInternal/interactions/subchart.ts +437 -66
  230. package/src/ChartInternal/internals/color.ts +2 -2
  231. package/src/ChartInternal/internals/domain.ts +15 -3
  232. package/src/ChartInternal/internals/grid.ts +21 -1
  233. package/src/ChartInternal/internals/scale.ts +9 -2
  234. package/src/ChartInternal/internals/selection.ts +1 -1
  235. package/src/ChartInternal/internals/subchart.util.ts +55 -0
  236. package/src/ChartInternal/internals/text.arc.ts +3 -1
  237. package/src/ChartInternal/internals/text.ts +18 -5
  238. package/src/ChartInternal/internals/transform.ts +8 -2
  239. package/src/ChartInternal/internals/type.ts +105 -1
  240. package/src/ChartInternal/shape/IShape.ts +6 -3
  241. package/src/ChartInternal/shape/bar.ts +62 -31
  242. package/src/ChartInternal/shape/core/barRadius.ts +129 -0
  243. package/src/ChartInternal/shape/core/candlestick.ts +1 -1
  244. package/src/ChartInternal/shape/core/path.ts +76 -9
  245. package/src/ChartInternal/shape/funnel.ts +2 -3
  246. package/src/ChartInternal/shape/point.ts +2 -2
  247. package/src/ChartInternal/shape/shape.ts +149 -17
  248. package/src/Plugin/stanford/index.ts +0 -4
  249. package/src/Plugin/tableview/index.ts +85 -3
  250. package/src/Plugin/textoverlap/index.ts +9 -15
  251. package/src/canvas/CanvasAxisRenderer.ts +184 -36
  252. package/src/canvas/CanvasRenderer.ts +247 -160
  253. package/src/canvas/CanvasTheme.ts +212 -0
  254. package/src/canvas/axisTicks.ts +122 -40
  255. package/src/config/Options/axis/y2.ts +13 -0
  256. package/src/config/Options/common/boost.ts +64 -4
  257. package/src/config/Options/common/color.ts +2 -2
  258. package/src/config/Options/interaction/subchart.ts +98 -1
  259. package/src/config/Options/shape/gauge.ts +1 -1
  260. package/src/config/Options/shape/treemap.ts +2 -2
  261. package/src/config/Store/Element.ts +3 -1
  262. package/src/config/Store/State.ts +1 -0
  263. package/src/config/classes.ts +1 -0
  264. package/src/config/resolver/canvas.ts +92 -10
  265. package/src/module/util/type-checks.ts +3 -1
  266. package/src/module/voronoi.ts +119 -0
  267. package/src/module/worker.entry.ts +61 -0
  268. package/src/module/worker.ts +346 -63
  269. package/src/react/index.ts +193 -0
  270. package/types/options.d.ts +206 -3
  271. package/types/react/index.d.ts +27 -0
@@ -5,591 +5,482 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 4.0.3
8
+ * @version 4.1.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
12
- /**
13
- * Copyright (c) 2017 ~ present NAVER Corp.
14
- * billboard.js project is licensed under the MIT license
15
- * @ignore
16
- */
12
+ //#region src/module/util/type-checks.ts
13
+ const isFunction = (v) => typeof v === "function";
14
+ const isString = (v) => typeof v === "string";
17
15
  const isNumber = (v) => typeof v === "number";
18
16
  const isDefined = (v) => typeof v !== "undefined";
17
+ const isBoolean = (v) => typeof v === "boolean";
19
18
  const isObjectType = (v) => typeof v === "object";
20
-
21
19
  /**
22
- * Copyright (c) 2017 ~ present NAVER Corp.
23
- * billboard.js project is licensed under the MIT license
24
- * @ignore
25
- */
20
+ * Check if is array
21
+ * @param {Array} arr Data to be checked
22
+ * @returns {boolean}
23
+ * @private
24
+ */
25
+ const isArray = (arr) => Array.isArray(arr);
26
+ //#endregion
27
+ //#region src/module/sanitize.ts
28
+ /**
29
+ * Copyright (c) 2017 ~ present NAVER Corp.
30
+ * billboard.js project is licensed under the MIT license
31
+ * @ignore
32
+ */
26
33
  /**
27
- * HTML/SVG Sanitization module
28
- * Pure whitelist approach - only explicitly allowed tags, attributes, and protocols pass through
29
- */
30
- // Whitelist of allowed HTML/SVG tags
31
- const ALLOWED_TAGS = new Set([
32
- // HTML tags for tooltip/legend templates
33
- "span",
34
- "div",
35
- "p",
36
- "br",
37
- "b",
38
- "i",
39
- "em",
40
- "small",
41
- "strong",
42
- "mark",
43
- "u",
44
- "s",
45
- "sub",
46
- "sup",
47
- "h1",
48
- "h2",
49
- "h3",
50
- "h4",
51
- "h5",
52
- "h6",
53
- "ul",
54
- "ol",
55
- "li",
56
- "dl",
57
- "dt",
58
- "dd",
59
- "table",
60
- "thead",
61
- "tbody",
62
- "tfoot",
63
- "tr",
64
- "th",
65
- "td",
66
- "caption",
67
- "colgroup",
68
- "col",
69
- "hr",
70
- "pre",
71
- "code",
72
- "blockquote",
73
- "abbr",
74
- "ins",
75
- "del",
76
- "a",
77
- "img",
78
- "figure",
79
- "figcaption",
80
- // SVG tags for point patterns
81
- "svg",
82
- "g",
83
- "path",
84
- "circle",
85
- "ellipse",
86
- "rect",
87
- "line",
88
- "polyline",
89
- "polygon",
90
- "text",
91
- "tspan",
92
- "textPath",
93
- "use",
94
- "defs",
95
- "symbol",
96
- "clipPath",
97
- "mask",
98
- "linearGradient",
99
- "radialGradient",
100
- "stop",
101
- "pattern",
102
- "marker",
103
- "title",
104
- "desc"
34
+ * HTML/SVG Sanitization module
35
+ * Pure whitelist approach - only explicitly allowed tags, attributes, and protocols pass through
36
+ */
37
+ const ALLOWED_TAGS = /* @__PURE__ */ new Set([
38
+ "span",
39
+ "div",
40
+ "p",
41
+ "br",
42
+ "b",
43
+ "i",
44
+ "em",
45
+ "small",
46
+ "strong",
47
+ "mark",
48
+ "u",
49
+ "s",
50
+ "sub",
51
+ "sup",
52
+ "h1",
53
+ "h2",
54
+ "h3",
55
+ "h4",
56
+ "h5",
57
+ "h6",
58
+ "ul",
59
+ "ol",
60
+ "li",
61
+ "dl",
62
+ "dt",
63
+ "dd",
64
+ "table",
65
+ "thead",
66
+ "tbody",
67
+ "tfoot",
68
+ "tr",
69
+ "th",
70
+ "td",
71
+ "caption",
72
+ "colgroup",
73
+ "col",
74
+ "hr",
75
+ "pre",
76
+ "code",
77
+ "blockquote",
78
+ "abbr",
79
+ "ins",
80
+ "del",
81
+ "a",
82
+ "img",
83
+ "figure",
84
+ "figcaption",
85
+ "svg",
86
+ "g",
87
+ "path",
88
+ "circle",
89
+ "ellipse",
90
+ "rect",
91
+ "line",
92
+ "polyline",
93
+ "polygon",
94
+ "text",
95
+ "tspan",
96
+ "textPath",
97
+ "use",
98
+ "defs",
99
+ "symbol",
100
+ "clipPath",
101
+ "mask",
102
+ "linearGradient",
103
+ "radialGradient",
104
+ "stop",
105
+ "pattern",
106
+ "marker",
107
+ "title",
108
+ "desc"
109
+ ]);
110
+ const ALLOWED_ATTRS = /* @__PURE__ */ new Set([
111
+ "class",
112
+ "id",
113
+ "style",
114
+ "title",
115
+ "lang",
116
+ "dir",
117
+ "href",
118
+ "src",
119
+ "alt",
120
+ "width",
121
+ "height",
122
+ "colspan",
123
+ "rowspan",
124
+ "scope",
125
+ "headers",
126
+ "d",
127
+ "points",
128
+ "x",
129
+ "y",
130
+ "x1",
131
+ "x2",
132
+ "y1",
133
+ "y2",
134
+ "cx",
135
+ "cy",
136
+ "r",
137
+ "rx",
138
+ "ry",
139
+ "dx",
140
+ "dy",
141
+ "viewBox",
142
+ "preserveAspectRatio",
143
+ "transform",
144
+ "fill",
145
+ "fill-opacity",
146
+ "fill-rule",
147
+ "stroke",
148
+ "stroke-width",
149
+ "stroke-opacity",
150
+ "stroke-linecap",
151
+ "stroke-linejoin",
152
+ "stroke-dasharray",
153
+ "stroke-dashoffset",
154
+ "opacity",
155
+ "clip-path",
156
+ "clip-rule",
157
+ "mask",
158
+ "font-family",
159
+ "font-size",
160
+ "font-weight",
161
+ "font-style",
162
+ "text-anchor",
163
+ "dominant-baseline",
164
+ "offset",
165
+ "stop-color",
166
+ "stop-opacity",
167
+ "gradientUnits",
168
+ "gradientTransform",
169
+ "spreadMethod",
170
+ "patternUnits",
171
+ "patternTransform",
172
+ "marker-start",
173
+ "marker-mid",
174
+ "marker-end",
175
+ "markerWidth",
176
+ "markerHeight",
177
+ "refX",
178
+ "refY",
179
+ "xlink:href"
105
180
  ]);
106
- // Whitelist of allowed attributes
107
- const ALLOWED_ATTRS = new Set([
108
- // Common attributes
109
- "class",
110
- "id",
111
- "style",
112
- "title",
113
- "lang",
114
- "dir",
115
- // HTML specific
116
- "href",
117
- "src",
118
- "alt",
119
- "width",
120
- "height",
121
- "colspan",
122
- "rowspan",
123
- "scope",
124
- "headers",
125
- // SVG presentation attributes
126
- "d",
127
- "points",
128
- "x",
129
- "y",
130
- "x1",
131
- "x2",
132
- "y1",
133
- "y2",
134
- "cx",
135
- "cy",
136
- "r",
137
- "rx",
138
- "ry",
139
- "dx",
140
- "dy",
141
- "viewBox",
142
- "preserveAspectRatio",
143
- "transform",
144
- "fill",
145
- "fill-opacity",
146
- "fill-rule",
147
- "stroke",
148
- "stroke-width",
149
- "stroke-opacity",
150
- "stroke-linecap",
151
- "stroke-linejoin",
152
- "stroke-dasharray",
153
- "stroke-dashoffset",
154
- "opacity",
155
- "clip-path",
156
- "clip-rule",
157
- "mask",
158
- "font-family",
159
- "font-size",
160
- "font-weight",
161
- "font-style",
162
- "text-anchor",
163
- "dominant-baseline",
164
- "offset",
165
- "stop-color",
166
- "stop-opacity",
167
- "gradientUnits",
168
- "gradientTransform",
169
- "spreadMethod",
170
- "patternUnits",
171
- "patternTransform",
172
- "marker-start",
173
- "marker-mid",
174
- "marker-end",
175
- "markerWidth",
176
- "markerHeight",
177
- "refX",
178
- "refY",
179
- "xlink:href"
181
+ const TAG_CASE_MAP = /* @__PURE__ */ new Map();
182
+ ALLOWED_TAGS.forEach((tag) => TAG_CASE_MAP.set(tag.toLowerCase(), tag));
183
+ const ATTR_CASE_MAP = /* @__PURE__ */ new Map();
184
+ ALLOWED_ATTRS.forEach((attr) => ATTR_CASE_MAP.set(attr.toLowerCase(), attr));
185
+ const ALLOWED_URI_PROTOCOLS = /* @__PURE__ */ new Set([
186
+ "http:",
187
+ "https:",
188
+ "mailto:"
180
189
  ]);
181
- // Case-insensitive lookup maps: lowercase key → canonical casing from whitelists
182
- const TAG_CASE_MAP = new Map();
183
- ALLOWED_TAGS.forEach(tag => TAG_CASE_MAP.set(tag.toLowerCase(), tag));
184
- const ATTR_CASE_MAP = new Map();
185
- ALLOWED_ATTRS.forEach(attr => ATTR_CASE_MAP.set(attr.toLowerCase(), attr));
186
- // Whitelist of allowed URI protocols
187
- const ALLOWED_URI_PROTOCOLS = new Set([
188
- "http:",
189
- "https:",
190
- "mailto:"
190
+ const URI_ATTRS = /* @__PURE__ */ new Set([
191
+ "href",
192
+ "src",
193
+ "xlink:href"
191
194
  ]);
192
- // Attributes that contain URIs
193
- const URI_ATTRS = new Set(["href", "src", "xlink:href"]);
194
- // Pre-compiled regex patterns for performance
195
195
  const TAG_NAME_REGEX = /^<\/?([a-zA-Z][a-zA-Z0-9]*)/;
196
196
  const CLOSING_TAG_REGEX = /^<\/([a-zA-Z][a-zA-Z0-9]*)\s*>$/;
197
197
  const OPENING_TAG_REGEX = /^<([a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?)>$/;
198
198
  const ATTR_REGEX = /([a-zA-Z][\w:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
199
199
  const URL_IN_STYLE_REGEX = /url\s*\(\s*["']?([^"')]+)["']?\s*\)/gi;
200
- // Dangerous CSS patterns
201
200
  const DANGEROUS_CSS_PATTERNS = [
202
- "expression(",
203
- "behavior:",
204
- "binding:",
205
- "@import",
206
- "@charset",
207
- "-moz-binding:"
201
+ "expression(",
202
+ "behavior:",
203
+ "binding:",
204
+ "@import",
205
+ "@charset",
206
+ "-moz-binding:"
208
207
  ];
209
208
  /**
210
- * Decode HTML entities in a string
211
- * @param {string} str String with potential HTML entities
212
- * @returns {string} Decoded string
213
- * @private
214
- */
209
+ * Decode HTML entities in a string
210
+ * @param {string} str String with potential HTML entities
211
+ * @returns {string} Decoded string
212
+ * @private
213
+ */
215
214
  function decodeHTMLEntities(str) {
216
- return str
217
- // Named entities
218
- .replace(/&colon;/gi, ":")
219
- .replace(/&newline;/gi, "\n")
220
- .replace(/&tab;/gi, "\t")
221
- .replace(/&nbsp;/gi, " ")
222
- .replace(/&lt;/gi, "<")
223
- .replace(/&gt;/gi, ">")
224
- .replace(/&amp;/gi, "&")
225
- .replace(/&quot;/gi, "\"")
226
- .replace(/&apos;/gi, "'")
227
- // Numeric entities (decimal) - trailing semicolon is optional per HTML5 tokenizer
228
- .replace(/&#(\d+);?/gi, (_, code) => String.fromCharCode(parseInt(code, 10)))
229
- // Numeric entities (hex) - trailing semicolon is optional per HTML5 tokenizer
230
- .replace(/&#x([0-9a-f]+);?/gi, (_, code) => String.fromCharCode(parseInt(code, 16)));
215
+ return str.replace(/&colon;/gi, ":").replace(/&newline;/gi, "\n").replace(/&tab;/gi, " ").replace(/&nbsp;/gi, " ").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&amp;/gi, "&").replace(/&quot;/gi, "\"").replace(/&apos;/gi, "'").replace(/&#(\d+);?/gi, (_, code) => String.fromCharCode(parseInt(code, 10))).replace(/&#x([0-9a-f]+);?/gi, (_, code) => String.fromCharCode(parseInt(code, 16)));
231
216
  }
232
217
  /**
233
- * Check if a URI is safe (whitelist approach)
234
- * @param {string} uri URI to check
235
- * @returns {boolean} Whether the URI is safe
236
- * @private
237
- */
218
+ * Check if a URI is safe (whitelist approach)
219
+ * @param {string} uri URI to check
220
+ * @returns {boolean} Whether the URI is safe
221
+ * @private
222
+ */
238
223
  function isSafeURI(uri) {
239
- // Decode HTML entities first to prevent bypass
240
- const decoded = decodeHTMLEntities(uri).trim();
241
- // Remove any whitespace/control characters that could be used for bypass
242
- // eslint-disable-next-line no-control-regex
243
- const normalized = decoded.replace(/[\s\u0000-\u001f]/g, "").toLowerCase();
244
- // Empty or fragment-only URIs are safe
245
- if (!normalized || normalized.startsWith("#")) {
246
- return true;
247
- }
248
- // A ':' appearing before the first '/', '?' or '#' denotes a URI scheme.
249
- // Reject the value unless that scheme is whitelisted - do NOT infer safety
250
- // merely from the absence of a literal colon (which could be reconstructed
251
- // from an alternate encoding once assigned to innerHTML).
252
- const schemeMatch = normalized.match(/^[^/?#]*:/);
253
- if (schemeMatch) {
254
- return ALLOWED_URI_PROTOCOLS.has(schemeMatch[0]);
255
- }
256
- // No scheme → relative path / query / fragment only → safe
257
- return true;
224
+ const normalized = decodeHTMLEntities(uri).trim().replace(/[\s\u0000-\u001f]/g, "").toLowerCase();
225
+ if (!normalized || normalized.startsWith("#")) return true;
226
+ const schemeMatch = normalized.match(/^[^/?#]*:/);
227
+ if (schemeMatch) return ALLOWED_URI_PROTOCOLS.has(schemeMatch[0]);
228
+ return true;
258
229
  }
259
230
  /**
260
- * Check if a style value is safe (whitelist approach)
261
- * @param {string} style Style attribute value
262
- * @returns {string|null} Sanitized style or null if unsafe
263
- * @private
264
- */
231
+ * Check if a style value is safe (whitelist approach)
232
+ * @param {string} style Style attribute value
233
+ * @returns {string|null} Sanitized style or null if unsafe
234
+ * @private
235
+ */
265
236
  function sanitizeStyleValue(style) {
266
- // Decode HTML entities first
267
- const decoded = decodeHTMLEntities(style);
268
- // Remove any control characters
269
- // eslint-disable-next-line no-control-regex
270
- const cleaned = decoded.replace(/[\u0000-\u001f]/g, "");
271
- // Check for url() - only allow safe URIs inside
272
- URL_IN_STYLE_REGEX.lastIndex = 0;
273
- let match;
274
- while ((match = URL_IN_STYLE_REGEX.exec(cleaned)) !== null) {
275
- if (!isSafeURI(match[1])) {
276
- return null;
277
- }
278
- }
279
- // Check for dangerous CSS patterns (expression, behavior, etc.)
280
- const normalizedLower = cleaned.toLowerCase().replace(/\s/g, "");
281
- for (const pattern of DANGEROUS_CSS_PATTERNS) {
282
- if (normalizedLower.includes(pattern)) {
283
- return null;
284
- }
285
- }
286
- return style;
237
+ const cleaned = decodeHTMLEntities(style).replace(/[\u0000-\u001f]/g, "");
238
+ URL_IN_STYLE_REGEX.lastIndex = 0;
239
+ let match;
240
+ while ((match = URL_IN_STYLE_REGEX.exec(cleaned)) !== null) if (!isSafeURI(match[1])) return null;
241
+ const normalizedLower = cleaned.toLowerCase().replace(/\s/g, "");
242
+ for (const pattern of DANGEROUS_CSS_PATTERNS) if (normalizedLower.includes(pattern)) return null;
243
+ return style;
287
244
  }
288
- // Lookup table for encoding dangerous characters in attribute values
289
245
  const ATTR_ENCODE_MAP = {
290
- "\"": "&quot;",
291
- "'": "&#39;",
292
- "`": "&#96;"
246
+ "\"": "&quot;",
247
+ "'": "&#39;",
248
+ "`": "&#96;"
293
249
  };
294
250
  const ATTR_ENCODE_REGEX = /["'`]/g;
295
251
  /**
296
- * Encode dangerous characters in attribute values to HTML entities
297
- * This prevents attribute injection attacks where quotes/backticks break out of the attribute context
298
- * @param {string} value Attribute value
299
- * @returns {string} Encoded value
300
- * @private
301
- */
252
+ * Encode dangerous characters in attribute values to HTML entities
253
+ * This prevents attribute injection attacks where quotes/backticks break out of the attribute context
254
+ * @param {string} value Attribute value
255
+ * @returns {string} Encoded value
256
+ * @private
257
+ */
302
258
  function encodeAttrValue(value) {
303
- return value.replace(ATTR_ENCODE_REGEX, char => ATTR_ENCODE_MAP[char]);
259
+ return value.replace(ATTR_ENCODE_REGEX, (char) => ATTR_ENCODE_MAP[char]);
304
260
  }
305
261
  /**
306
- * Sanitize attribute value using whitelist approach
307
- * @param {string} name Attribute name
308
- * @param {string} value Attribute value
309
- * @param {boolean} wasUnquoted Whether the value was originally unquoted
310
- * @returns {string|null} Sanitized value if safe, null if should be removed
311
- * @private
312
- */
262
+ * Sanitize attribute value using whitelist approach
263
+ * @param {string} name Attribute name
264
+ * @param {string} value Attribute value
265
+ * @param {boolean} wasUnquoted Whether the value was originally unquoted
266
+ * @returns {string|null} Sanitized value if safe, null if should be removed
267
+ * @private
268
+ */
313
269
  function sanitizeAttrValue(name, value, wasUnquoted = false) {
314
- // Check URI attributes with whitelist
315
- if (URI_ATTRS.has(name)) {
316
- if (!isSafeURI(value)) {
317
- return null;
318
- }
319
- // Encode dangerous characters in URI values to prevent attribute injection
320
- return wasUnquoted ? encodeAttrValue(value) : value;
321
- }
322
- // Check style attribute
323
- if (name === "style") {
324
- const sanitizedStyle = sanitizeStyleValue(value);
325
- if (sanitizedStyle === null) {
326
- return null;
327
- }
328
- // Encode dangerous characters in style values
329
- return wasUnquoted ? encodeAttrValue(sanitizedStyle) : sanitizedStyle;
330
- }
331
- // For other attributes, check for embedded event handlers
332
- const decoded = decodeHTMLEntities(value).toLowerCase().replace(/\s/g, "");
333
- if (/\bon\w+=/.test(decoded)) {
334
- return null;
335
- }
336
- // Encode dangerous characters to prevent attribute injection
337
- return wasUnquoted ? encodeAttrValue(value) : value;
270
+ if (URI_ATTRS.has(name)) {
271
+ if (!isSafeURI(value)) return null;
272
+ return wasUnquoted ? encodeAttrValue(value) : value;
273
+ }
274
+ if (name === "style") {
275
+ const sanitizedStyle = sanitizeStyleValue(value);
276
+ if (sanitizedStyle === null) return null;
277
+ return wasUnquoted ? encodeAttrValue(sanitizedStyle) : sanitizedStyle;
278
+ }
279
+ const decoded = decodeHTMLEntities(value).toLowerCase().replace(/\s/g, "");
280
+ if (/\bon\w+=/.test(decoded)) return null;
281
+ return wasUnquoted ? encodeAttrValue(value) : value;
338
282
  }
339
283
  /**
340
- * Extract tag name from a tag string
341
- * Returns null if not a valid tag format
342
- * @param {string} tag Tag string starting with <
343
- * @returns {string|null} Lowercase tag name or null
344
- * @private
345
- */
284
+ * Extract tag name from a tag string
285
+ * Returns null if not a valid tag format
286
+ * @param {string} tag Tag string starting with <
287
+ * @returns {string|null} Lowercase tag name or null
288
+ * @private
289
+ */
346
290
  function extractTagName(tag) {
347
- // Must start with < followed immediately by letter (no spaces allowed)
348
- const match = tag.match(TAG_NAME_REGEX);
349
- return match ? match[1].toLowerCase() : null;
291
+ const match = tag.match(TAG_NAME_REGEX);
292
+ return match ? match[1].toLowerCase() : null;
350
293
  }
351
294
  /**
352
- * Check if a tag is in the whitelist
353
- * @param {string} tag Tag string
354
- * @returns {boolean} Whether tag is allowed
355
- * @private
356
- */
295
+ * Check if a tag is in the whitelist
296
+ * @param {string} tag Tag string
297
+ * @returns {boolean} Whether tag is allowed
298
+ * @private
299
+ */
357
300
  function isAllowedTag(tag) {
358
- const tagName = extractTagName(tag);
359
- return tagName !== null && TAG_CASE_MAP.has(tagName);
301
+ const tagName = extractTagName(tag);
302
+ return tagName !== null && TAG_CASE_MAP.has(tagName);
360
303
  }
361
304
  /**
362
- * Sanitize a single HTML/SVG tag (only called for allowed tags)
363
- * @param {string} fullTag The full tag string including < and >
364
- * @returns {string} Sanitized tag
365
- * @private
366
- */
305
+ * Sanitize a single HTML/SVG tag (only called for allowed tags)
306
+ * @param {string} fullTag The full tag string including < and >
307
+ * @returns {string} Sanitized tag
308
+ * @private
309
+ */
367
310
  function sanitizeTag(fullTag) {
368
- // Closing tag
369
- const closingMatch = fullTag.match(CLOSING_TAG_REGEX);
370
- if (closingMatch) {
371
- const lowerName = closingMatch[1].toLowerCase();
372
- return `</${TAG_CASE_MAP.get(lowerName) ?? lowerName}>`;
373
- }
374
- // Opening tag
375
- const openingMatch = fullTag.match(OPENING_TAG_REGEX);
376
- if (!openingMatch) {
377
- return "";
378
- }
379
- const [, tagName, attrString, selfClose] = openingMatch;
380
- const lowerTagName = tagName.toLowerCase();
381
- const canonicalTagName = TAG_CASE_MAP.get(lowerTagName) ?? lowerTagName;
382
- // Parse and filter attributes, preserving original quote style
383
- const allowedAttrs = [];
384
- ATTR_REGEX.lastIndex = 0;
385
- let attrMatch;
386
- while ((attrMatch = ATTR_REGEX.exec(attrString)) !== null) {
387
- const lowerAttrName = attrMatch[1].toLowerCase();
388
- const doubleQuotedValue = attrMatch[2];
389
- const singleQuotedValue = attrMatch[3];
390
- const unquotedValue = attrMatch[4];
391
- // Skip event handlers (on*)
392
- if (lowerAttrName.startsWith("on")) {
393
- continue;
394
- }
395
- const canonicalAttrName = ATTR_CASE_MAP.get(lowerAttrName) ?? lowerAttrName;
396
- // Determine original quote style and value
397
- let attrValue;
398
- let quoteChar;
399
- if (doubleQuotedValue !== undefined) {
400
- attrValue = doubleQuotedValue;
401
- quoteChar = "\"";
402
- }
403
- else if (singleQuotedValue !== undefined) {
404
- attrValue = singleQuotedValue;
405
- quoteChar = "'";
406
- }
407
- else if (unquotedValue !== undefined) {
408
- attrValue = unquotedValue;
409
- quoteChar = "\"";
410
- }
411
- else {
412
- // Boolean attribute (no value)
413
- if (ATTR_CASE_MAP.has(lowerAttrName)) {
414
- allowedAttrs.push(canonicalAttrName);
415
- }
416
- continue;
417
- }
418
- if (ATTR_CASE_MAP.has(lowerAttrName)) {
419
- const wasUnquoted = unquotedValue !== undefined;
420
- const sanitizedValue = sanitizeAttrValue(lowerAttrName, attrValue, wasUnquoted);
421
- if (sanitizedValue !== null) {
422
- allowedAttrs.push(`${canonicalAttrName}=${quoteChar}${sanitizedValue}${quoteChar}`);
423
- }
424
- }
425
- }
426
- const attrsStr = allowedAttrs.length > 0 ? ` ${allowedAttrs.join(" ")}` : "";
427
- const selfCloseStr = selfClose ? "/>" : ">";
428
- return `<${canonicalTagName}${attrsStr}${selfCloseStr}`;
311
+ const closingMatch = fullTag.match(CLOSING_TAG_REGEX);
312
+ if (closingMatch) {
313
+ const lowerName = closingMatch[1].toLowerCase();
314
+ return `</${TAG_CASE_MAP.get(lowerName) ?? lowerName}>`;
315
+ }
316
+ const openingMatch = fullTag.match(OPENING_TAG_REGEX);
317
+ if (!openingMatch) return "";
318
+ const [, tagName, attrString, selfClose] = openingMatch;
319
+ const lowerTagName = tagName.toLowerCase();
320
+ const canonicalTagName = TAG_CASE_MAP.get(lowerTagName) ?? lowerTagName;
321
+ const allowedAttrs = [];
322
+ ATTR_REGEX.lastIndex = 0;
323
+ let attrMatch;
324
+ while ((attrMatch = ATTR_REGEX.exec(attrString)) !== null) {
325
+ const lowerAttrName = attrMatch[1].toLowerCase();
326
+ const doubleQuotedValue = attrMatch[2];
327
+ const singleQuotedValue = attrMatch[3];
328
+ const unquotedValue = attrMatch[4];
329
+ if (lowerAttrName.startsWith("on")) continue;
330
+ const canonicalAttrName = ATTR_CASE_MAP.get(lowerAttrName) ?? lowerAttrName;
331
+ let attrValue;
332
+ let quoteChar;
333
+ if (doubleQuotedValue !== void 0) {
334
+ attrValue = doubleQuotedValue;
335
+ quoteChar = "\"";
336
+ } else if (singleQuotedValue !== void 0) {
337
+ attrValue = singleQuotedValue;
338
+ quoteChar = "'";
339
+ } else if (unquotedValue !== void 0) {
340
+ attrValue = unquotedValue;
341
+ quoteChar = "\"";
342
+ } else {
343
+ if (ATTR_CASE_MAP.has(lowerAttrName)) allowedAttrs.push(canonicalAttrName);
344
+ continue;
345
+ }
346
+ if (ATTR_CASE_MAP.has(lowerAttrName)) {
347
+ const sanitizedValue = sanitizeAttrValue(lowerAttrName, attrValue, unquotedValue !== void 0);
348
+ if (sanitizedValue !== null) allowedAttrs.push(`${canonicalAttrName}=${quoteChar}${sanitizedValue}${quoteChar}`);
349
+ }
350
+ }
351
+ return `<${canonicalTagName}${allowedAttrs.length > 0 ? ` ${allowedAttrs.join(" ")}` : ""}${selfClose ? "/>" : ">"}`;
429
352
  }
430
353
  /**
431
- * Sanitize HTML string to prevent XSS attacks
432
- * Pure whitelist approach - allowed tags are sanitized, others are escaped
433
- * @param {string} str Target string value
434
- * @returns {string} Sanitized string with only allowed elements
435
- * @private
436
- */
354
+ * Sanitize HTML string to prevent XSS attacks
355
+ * Pure whitelist approach - allowed tags are sanitized, others are escaped
356
+ * @param {string} str Target string value
357
+ * @returns {string} Sanitized string with only allowed elements
358
+ * @private
359
+ */
437
360
  function sanitize(str) {
438
- if (typeof str !== "string" || !str || str.indexOf("<") === -1) {
439
- return str;
440
- }
441
- // Single pass: sanitize allowed tags, escape disallowed ones
442
- // Also match orphaned fragments like "ipt>" from broken tags
443
- return str.replace(/<\/?[^>]*>|[^<>\s]+>/g, match => {
444
- // Remove HTML comments
445
- if (match.startsWith("<!--")) {
446
- return "";
447
- }
448
- // Orphaned fragment (e.g., "ipt>") → escape '>'
449
- if (!match.startsWith("<")) {
450
- return match.slice(0, -1) + "&gt;";
451
- }
452
- // Allowed tag → sanitize attributes
453
- if (isAllowedTag(match)) {
454
- return sanitizeTag(match);
455
- }
456
- // Disallowed tag → escape all '<' to prevent execution
457
- return match.replace(/</g, "&lt;");
458
- });
361
+ if (typeof str !== "string" || !str || str.indexOf("<") === -1) return str;
362
+ return str.replace(/<\/?[^>]*>|[^<>\s]+>/g, (match) => {
363
+ if (match.startsWith("<!--")) return "";
364
+ if (!match.startsWith("<")) return match.slice(0, -1) + "&gt;";
365
+ if (isAllowedTag(match)) return sanitizeTag(match);
366
+ return match.replace(/</g, "&lt;");
367
+ });
459
368
  }
460
-
461
- /**
462
- * Copyright (c) 2017 ~ present NAVER Corp.
463
- * billboard.js project is licensed under the MIT license
464
- * @ignore
465
- */
369
+ //#endregion
370
+ //#region src/module/util/object.ts
466
371
  /**
467
- * Process the template & return bound string
468
- * @param {string} tpl Template string
469
- * @param {object} data Data value to be replaced
470
- * @returns {string}
471
- * @private
472
- */
372
+ * Process the template & return bound string
373
+ * @param {string} tpl Template string
374
+ * @param {object} data Data value to be replaced
375
+ * @returns {string}
376
+ * @private
377
+ */
473
378
  function tplProcess(tpl, data) {
474
- return sanitize(tpl.replace(/\{=([^}]+)\}/g, (_, key) => data[key] ?? ""));
379
+ return sanitize(tpl.replace(/\{=([^}]+)\}/g, (_, key) => data[key] ?? ""));
475
380
  }
476
-
381
+ //#endregion
382
+ //#region src/config/config.ts
477
383
  /**
478
- * Load configuration option
479
- * @param {object} config User's generation config value
480
- * @private
481
- */
384
+ * Load configuration option
385
+ * @param {object} config User's generation config value
386
+ * @private
387
+ */
482
388
  function loadConfig(config) {
483
- const thisConfig = this.config;
484
- let target;
485
- let keys;
486
- let read;
487
- const find = () => {
488
- const key = keys.shift();
489
- if (key && target && isObjectType(target) && key in target) {
490
- target = target[key];
491
- return find();
492
- }
493
- else if (!key) {
494
- return target;
495
- }
496
- return undefined;
497
- };
498
- Object.keys(thisConfig).forEach(key => {
499
- target = config;
500
- keys = key.split("_");
501
- read = find();
502
- if (isDefined(read)) {
503
- thisConfig[key] = read;
504
- }
505
- });
506
- // only should run in the ChartInternal context
507
- if (this.api) {
508
- this.state.orgConfig = config;
509
- }
389
+ const thisConfig = this.config;
390
+ let target;
391
+ let keys;
392
+ let read;
393
+ const find = () => {
394
+ const key = keys.shift();
395
+ if (key && target && isObjectType(target) && key in target) {
396
+ target = target[key];
397
+ return find();
398
+ } else if (!key) return target;
399
+ };
400
+ Object.keys(thisConfig).forEach((key) => {
401
+ target = config;
402
+ keys = key.split("_");
403
+ read = find();
404
+ if (isDefined(read)) thisConfig[key] = read;
405
+ });
406
+ if (this.api) this.state.orgConfig = config;
510
407
  }
511
-
512
- /**
513
- * Copyright (c) 2017 ~ present NAVER Corp.
514
- * billboard.js project is licensed under the MIT license
515
- */
408
+ //#endregion
409
+ //#region src/Plugin/Plugin.ts
516
410
  /**
517
- * Base class to generate billboard.js plugin
518
- * @class Plugin
519
- */
520
- /**
521
- * Version info string for plugin
522
- * @name version
523
- * @static
524
- * @memberof Plugin
525
- * @type {string}
526
- * @example
527
- * bb.plugin.stanford.version; // ex) 1.9.0
528
- */
529
- class Plugin {
530
- $$;
531
- options;
532
- config;
533
- static version = "4.0.3";
534
- /**
535
- * Constructor
536
- * @param {Any} options config option object
537
- * @private
538
- */
539
- constructor(options = {}) {
540
- this.options = options;
541
- }
542
- /**
543
- * Load plugin config from options
544
- * @private
545
- */
546
- loadConfig() {
547
- loadConfig.call(this, this.options);
548
- }
549
- /**
550
- * Lifecycle hook for 'beforeInit' phase.
551
- * @private
552
- */
553
- $beforeInit() { }
554
- /**
555
- * Lifecycle hook for 'init' phase.
556
- * @private
557
- */
558
- $init() { }
559
- /**
560
- * Lifecycle hook for 'afterInit' phase.
561
- * @private
562
- */
563
- $afterInit() { }
564
- /**
565
- * Lifecycle hook for 'redraw' phase.
566
- * @private
567
- */
568
- $redraw() { }
569
- /**
570
- * Lifecycle hook for 'willDestroy' phase.
571
- * @private
572
- */
573
- $willDestroy() {
574
- Object.keys(this).forEach(key => {
575
- this[key] = null;
576
- delete this[key];
577
- });
578
- }
579
- }
580
-
411
+ * Copyright (c) 2017 ~ present NAVER Corp.
412
+ * billboard.js project is licensed under the MIT license
413
+ */
581
414
  /**
582
- * Copyright (c) 2021 ~ present NAVER Corp.
583
- * billboard.js project is licensed under the MIT license
584
- */
415
+ * Base class to generate billboard.js plugin
416
+ * @class Plugin
417
+ */
585
418
  /**
586
- * Constants values for plugin option
587
- * @ignore
588
- */
419
+ * Version info string for plugin
420
+ * @name version
421
+ * @static
422
+ * @memberof Plugin
423
+ * @type {string}
424
+ * @example
425
+ * bb.plugin.stanford.version; // ex) 1.9.0
426
+ */
427
+ var Plugin = class {
428
+ $$;
429
+ options;
430
+ config;
431
+ static version = "4.1.0-next.2";
432
+ /**
433
+ * Constructor
434
+ * @param {Any} options config option object
435
+ * @private
436
+ */
437
+ constructor(options = {}) {
438
+ this.options = options;
439
+ }
440
+ /**
441
+ * Load plugin config from options
442
+ * @private
443
+ */
444
+ loadConfig() {
445
+ loadConfig.call(this, this.options);
446
+ }
447
+ /**
448
+ * Lifecycle hook for 'beforeInit' phase.
449
+ * @private
450
+ */
451
+ $beforeInit() {}
452
+ /**
453
+ * Lifecycle hook for 'init' phase.
454
+ * @private
455
+ */
456
+ $init() {}
457
+ /**
458
+ * Lifecycle hook for 'afterInit' phase.
459
+ * @private
460
+ */
461
+ $afterInit() {}
462
+ /**
463
+ * Lifecycle hook for 'redraw' phase.
464
+ * @private
465
+ */
466
+ $redraw() {}
467
+ /**
468
+ * Lifecycle hook for 'willDestroy' phase.
469
+ * @private
470
+ */
471
+ $willDestroy() {
472
+ Object.keys(this).forEach((key) => {
473
+ this[key] = null;
474
+ delete this[key];
475
+ });
476
+ }
477
+ };
478
+ //#endregion
479
+ //#region src/Plugin/tableview/const.ts
589
480
  const defaultStyle = {
590
- id: "__tableview-style__",
591
- class: "bb-tableview",
592
- rule: `.bb-tableview {
481
+ id: "__tableview-style__",
482
+ class: "bb-tableview",
483
+ rule: `.bb-tableview {
593
484
  border-collapse:collapse;
594
485
  border-spacing:0;
595
486
  background:#fff;
@@ -615,273 +506,302 @@ const defaultStyle = {
615
506
  margin-bottom: -1px;
616
507
  }`
617
508
  };
618
- // template
619
509
  const tpl = {
620
- body: `<caption>{=title}</caption>
510
+ body: `<caption>{=title}</caption>
621
511
  <thead><tr>{=thead}</tr></thead>
622
512
  <tbody>{=tbody}</tbody>`,
623
- thead: `<th scope="col">{=title}</th>`,
624
- tbodyHeader: `<th scope="row">{=value}</th>`,
625
- tbody: `<td>{=value}</td>`
513
+ thead: `<th scope="col">{=title}</th>`,
514
+ tbodyHeader: `<th scope="row">{=value}</th>`,
515
+ tbody: `<td>{=value}</td>`
626
516
  };
627
-
517
+ //#endregion
518
+ //#region src/Plugin/tableview/Options.ts
628
519
  /**
629
- * Copyright (c) 2021 ~ present NAVER Corp.
630
- * billboard.js project is licensed under the MIT license
631
- */
520
+ * Copyright (c) 2021 ~ present NAVER Corp.
521
+ * billboard.js project is licensed under the MIT license
522
+ */
632
523
  /**
633
- * TableView plugin option class
634
- * @class TableviewOptions
635
- * @param {Options} options TableView plugin options
636
- * @augments Plugin
637
- * @returns {TableviewOptions}
638
- * @private
639
- */
640
- class Options {
641
- constructor() {
642
- return {
643
- /**
644
- * Set tableview holder selector.
645
- * - **NOTE:** If not set, will append new holder element dynamically right after chart element.
646
- * @name selector
647
- * @memberof plugin-tableview
648
- * @type {string}
649
- * @default undefined
650
- * @example
651
- * selector: "#table-holder"
652
- */
653
- selector: undefined,
654
- /**
655
- * Set category title text
656
- * @name categoryTitle
657
- * @memberof plugin-tableview
658
- * @type {string}
659
- * @default "Category"
660
- * @example
661
- * categoryTitle: "#table-holder"
662
- */
663
- categoryTitle: "Category",
664
- /**
665
- * Set category text format function.
666
- * @name categoryFormat
667
- * @memberof plugin-tableview
668
- * @type {function}
669
- * @returns {string}
670
- * @default function(v) { // will return formatted value according x Axis type }}
671
- * @example
672
- * categoryFormat: "#table-holder"
673
- */
674
- categoryFormat: function (v) {
675
- let category = v;
676
- if (this.$$.axis.isCategorized()) {
677
- category = this.$$.categoryName(v);
678
- }
679
- else if (this.$$.axis.isTimeSeries()) {
680
- category = v.toLocaleDateString();
681
- }
682
- return category;
683
- },
684
- /**
685
- * Set tableview holder class name.
686
- * @name class
687
- * @memberof plugin-tableview
688
- * @type {string}
689
- * @default undefined
690
- * @example
691
- * class: "table-class-name"
692
- */
693
- class: undefined,
694
- /**
695
- * Set to apply default style(`.bb-tableview`) to tableview element.
696
- * @name style
697
- * @memberof plugin-tableview
698
- * @type {boolean}
699
- * @default true
700
- * @example
701
- * style: false
702
- */
703
- style: true,
704
- /**
705
- * Set tableview title text.
706
- * - **NOTE:** If set [title.text](https://naver.github.io/billboard.js/release/latest/doc/Options.html#.title), will be used when this option value is empty.
707
- * @name title
708
- * @memberof plugin-tableview
709
- * @type {string}
710
- * @default undefined
711
- * @example
712
- * title: "Table Title Text"
713
- */
714
- title: undefined,
715
- /**
716
- * Update tableview from data visibility update(ex. legend toggle).
717
- * @name updateOnToggle
718
- * @memberof plugin-tableview
719
- * @type {boolean}
720
- * @default true
721
- * @example
722
- * legendToggleUpdate: false
723
- */
724
- updateOnToggle: true,
725
- /**
726
- * Set how null value to be shown.
727
- * @name nullString
728
- * @memberof plugin-tableview
729
- * @type {string}
730
- * @default "-"
731
- * @example
732
- * nullString: "N/A"
733
- */
734
- nullString: "-",
735
- /**
736
- * Set number format function.
737
- * @name numberFormat
738
- * @memberof plugin-tableview
739
- * @type {function}
740
- * @returns {string}
741
- * @default function(v) { // will return formatted value according to locale settings }
742
- * @example
743
- * numberFormat: function(v) {
744
- * return v.toLocaleString();
745
- * }
746
- */
747
- numberFormat: function (v) {
748
- return v.toLocaleString();
749
- }
750
- };
751
- }
752
- }
753
-
524
+ * TableView plugin option class
525
+ * @class TableviewOptions
526
+ * @param {Options} options TableView plugin options
527
+ * @augments Plugin
528
+ * @returns {TableviewOptions}
529
+ * @private
530
+ */
531
+ var Options = class {
532
+ constructor() {
533
+ return {
534
+ /**
535
+ * Set tableview holder selector.
536
+ * - **NOTE:** If not set, will append new holder element dynamically right after chart element.
537
+ * @name selector
538
+ * @memberof plugin-tableview
539
+ * @type {string}
540
+ * @default undefined
541
+ * @example
542
+ * selector: "#table-holder"
543
+ */
544
+ selector: void 0,
545
+ /**
546
+ * Set category title text
547
+ * @name categoryTitle
548
+ * @memberof plugin-tableview
549
+ * @type {string}
550
+ * @default "Category"
551
+ * @example
552
+ * categoryTitle: "#table-holder"
553
+ */
554
+ categoryTitle: "Category",
555
+ /**
556
+ * Set category text format function.
557
+ * @name categoryFormat
558
+ * @memberof plugin-tableview
559
+ * @type {function}
560
+ * @returns {string}
561
+ * @default function(v) { // will return formatted value according x Axis type }}
562
+ * @example
563
+ * categoryFormat: "#table-holder"
564
+ */
565
+ categoryFormat: function(v) {
566
+ let category = v;
567
+ if (this.$$.axis.isCategorized()) category = this.$$.categoryName(v);
568
+ else if (this.$$.axis.isTimeSeries()) category = v.toLocaleDateString();
569
+ return category;
570
+ },
571
+ /**
572
+ * Set tableview holder class name.
573
+ * @name class
574
+ * @memberof plugin-tableview
575
+ * @type {string}
576
+ * @default undefined
577
+ * @example
578
+ * class: "table-class-name"
579
+ */
580
+ class: void 0,
581
+ /**
582
+ * Set to apply default style(`.bb-tableview`) to tableview element.
583
+ * @name style
584
+ * @memberof plugin-tableview
585
+ * @type {boolean}
586
+ * @default true
587
+ * @example
588
+ * style: false
589
+ */
590
+ style: true,
591
+ /**
592
+ * Set tableview title text.
593
+ * - **NOTE:** If set [title.text](https://naver.github.io/billboard.js/release/latest/doc/Options.html#.title), will be used when this option value is empty.
594
+ * @name title
595
+ * @memberof plugin-tableview
596
+ * @type {string}
597
+ * @default undefined
598
+ * @example
599
+ * title: "Table Title Text"
600
+ */
601
+ title: void 0,
602
+ /**
603
+ * Update tableview from data visibility update(ex. legend toggle).
604
+ * @name updateOnToggle
605
+ * @memberof plugin-tableview
606
+ * @type {boolean}
607
+ * @default true
608
+ * @example
609
+ * legendToggleUpdate: false
610
+ */
611
+ updateOnToggle: true,
612
+ /**
613
+ * Set how null value to be shown.
614
+ * @name nullString
615
+ * @memberof plugin-tableview
616
+ * @type {string}
617
+ * @default "-"
618
+ * @example
619
+ * nullString: "N/A"
620
+ */
621
+ nullString: "-",
622
+ /**
623
+ * Set number format function.
624
+ * @name numberFormat
625
+ * @memberof plugin-tableview
626
+ * @type {function}
627
+ * @returns {string}
628
+ * @default function(v) { // will return formatted value according to locale settings }
629
+ * @example
630
+ * numberFormat: function(v) {
631
+ * return v.toLocaleString();
632
+ * }
633
+ */
634
+ numberFormat: function(v) {
635
+ return v.toLocaleString();
636
+ }
637
+ };
638
+ }
639
+ };
640
+ //#endregion
641
+ //#region src/Plugin/tableview/index.ts
754
642
  /**
755
- * Copyright (c) 2021 ~ present NAVER Corp.
756
- * billboard.js project is licensed under the MIT license
757
- */
643
+ * Copyright (c) 2021 ~ present NAVER Corp.
644
+ * billboard.js project is licensed under the MIT license
645
+ */
758
646
  /**
759
- * Table view plugin.<br>
760
- * Generates table view for bound dataset.
761
- * - **NOTE:**
762
- * - Plugins aren't built-in. Need to be loaded or imported to be used.
763
- * - Non required modules from billboard.js core, need to be installed separately.
764
- * @class plugin-tableview
765
- * @param {object} options table view plugin options
766
- * @augments Plugin
767
- * @returns {TableView}
768
- * @example
769
- * // Plugin must be loaded before the use.
770
- * <script src="$YOUR_PATH/plugin/billboardjs-plugin-tableview.js"></script>
771
- *
772
- * var chart = bb.generate({
773
- * ...
774
- * plugins: [
775
- * new bb.plugin.tableview({
776
- * selector: "#my-table-view",
777
- * categoryTitle: "Category",
778
- * categoryFormat: function(v) {
779
- * // do some transformation
780
- * ...
781
- * return v;
782
- * },
783
- * class: "my-class-name",
784
- * style: true,
785
- * title: "My Data List",
786
- * updateOnToggle: false,
787
- * nullString: "N/A"
788
- * }),
789
- * ]
790
- * });
791
- * @example
792
- * import {bb} from "billboard.js";
793
- * import TableView from "billboard.js/dist/billboardjs-plugin-tableview";
794
- *
795
- * bb.generate({
796
- * ...
797
- * plugins: [
798
- * new TableView({ ... })
799
- * ]
800
- * })
801
- */
802
- class TableView extends Plugin {
803
- element;
804
- constructor(options) {
805
- super(options);
806
- this.config = new Options();
807
- return this;
808
- }
809
- $beforeInit() {
810
- this.loadConfig();
811
- }
812
- $init() {
813
- const { class: className, selector, style } = this.config;
814
- let element = document.querySelector(selector || `.${className || defaultStyle.class}`);
815
- if (!element) {
816
- const chart = this.$$.$el.chart.node();
817
- element = document.createElement("table");
818
- chart.parentNode.insertBefore(element, chart.nextSibling);
819
- }
820
- if (element.tagName !== "TABLE") {
821
- const table = document.createElement("table");
822
- element.appendChild(table);
823
- element = table;
824
- }
825
- // append default css style
826
- if (style && !document.getElementById(defaultStyle.id)) {
827
- const s = document.createElement("style");
828
- s.id = defaultStyle.id;
829
- s.innerHTML = defaultStyle.rule;
830
- (document.head || document.getElementsByTagName("head")[0])
831
- .appendChild(s);
832
- }
833
- element.classList.add(...[style && defaultStyle.class, className].filter(Boolean));
834
- this.element = element;
835
- }
836
- /**
837
- * Generate table
838
- * @private
839
- */
840
- generateTable() {
841
- const { $$, config, element } = this;
842
- const dataToShow = $$.filterTargetsToShow($$.data.targets);
843
- let thead = tplProcess(tpl.thead, {
844
- title: dataToShow.length ? this.config.categoryTitle : ""
845
- });
846
- let tbody = "";
847
- const rows = [];
848
- dataToShow.forEach(v => {
849
- thead += tplProcess(tpl.thead, { title: v.id });
850
- // make up value rows
851
- v.values.forEach((d, i) => {
852
- if (!rows[i]) {
853
- rows[i] = [d.x];
854
- }
855
- rows[i].push(d.value);
856
- });
857
- });
858
- rows.forEach(v => {
859
- tbody += `<tr>${v.map((d, i) => tplProcess(i ? tpl.tbody : tpl.tbodyHeader, {
860
- value: i === 0 ?
861
- config.categoryFormat.bind(this)(d) :
862
- (isNumber(d) ? config.numberFormat.bind(this)(d) : config.nullString)
863
- })).join("")}</tr>`;
864
- });
865
- element.innerHTML = tplProcess(tpl.body, {
866
- ...config,
867
- title: config.title || $$.config.title_text || "",
868
- thead,
869
- tbody
870
- });
871
- }
872
- $redraw() {
873
- const { state } = this.$$;
874
- const doNotUpdate = state.resizing || (!this.config.updateOnToggle && state.toggling);
875
- !doNotUpdate && this.generateTable();
876
- }
877
- $willDestroy() {
878
- this.element.parentNode?.removeChild(this.element);
879
- // remove default css style when left one chart instance
880
- if (this.$$.charts.length === 1) {
881
- const s = document.getElementById(defaultStyle.id);
882
- s?.parentNode?.removeChild(s);
883
- }
884
- }
647
+ * Expected value type for each supported option, used to validate user input.
648
+ * Acts as the single source of truth for the set of allowed option keys.
649
+ * @private
650
+ */
651
+ const optionValidators = {
652
+ selector: isString,
653
+ categoryTitle: isString,
654
+ categoryFormat: isFunction,
655
+ class: isString,
656
+ style: isBoolean,
657
+ title: isString,
658
+ updateOnToggle: isBoolean,
659
+ nullString: isString,
660
+ numberFormat: isFunction
661
+ };
662
+ /**
663
+ * Check whether the given value is a valid TableView options object.
664
+ * An empty object is valid (every option falls back to its default) and
665
+ * unknown keys are ignored, so only a known option holding a value of the
666
+ * wrong type makes the object invalid. An explicit `undefined` value is
667
+ * allowed so a consumer can opt out of an option and let it fall back to
668
+ * the default.
669
+ * @param {unknown} options Value given to the TableView constructor
670
+ * @returns {boolean} `true` when `options` is a valid TableView options object
671
+ * @private
672
+ */
673
+ function isValidTableViewOptions(options) {
674
+ if (!isObjectType(options) || isArray(options) || options === null) return false;
675
+ return Object.entries(options).every(([key, value]) => {
676
+ const validate = optionValidators[key];
677
+ return !isFunction(validate) || value === void 0 || validate(value);
678
+ });
885
679
  }
886
-
887
- export { TableView as default };
680
+ /**
681
+ * Table view plugin.<br>
682
+ * Generates table view for bound dataset.
683
+ * - **NOTE:**
684
+ * - Plugins aren't built-in. Need to be loaded or imported to be used.
685
+ * - Non required modules from billboard.js core, need to be installed separately.
686
+ * @class plugin-tableview
687
+ * @param {object} options table view plugin options
688
+ * @augments Plugin
689
+ * @returns {TableView}
690
+ * @example
691
+ * // Plugin must be loaded before the use.
692
+ * <script src="$YOUR_PATH/plugin/billboardjs-plugin-tableview.js"><\/script>
693
+ *
694
+ * var chart = bb.generate({
695
+ * ...
696
+ * plugins: [
697
+ * new bb.plugin.tableview({
698
+ * selector: "#my-table-view",
699
+ * categoryTitle: "Category",
700
+ * categoryFormat: function(v) {
701
+ * // do some transformation
702
+ * ...
703
+ * return v;
704
+ * },
705
+ * class: "my-class-name",
706
+ * style: true,
707
+ * title: "My Data List",
708
+ * updateOnToggle: false,
709
+ * nullString: "N/A",
710
+ * numberFormat: function(v) {
711
+ * // do some transformation like number formatting
712
+ * // return typeof v === "number" ? v.toFixed(2) : v;
713
+ * // or use d3.format
714
+ * // return typeof v === "number" ? d3.format(".2f")(v) : v;
715
+ * // or use Intl.NumberFormat
716
+ * // return typeof v === "number" ? new Intl.NumberFormat("en-US", {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(v) : v;
717
+ * // or any other number formatting library
718
+ * ...
719
+ * return v;
720
+ * }
721
+ * }),
722
+ * ]
723
+ * });
724
+ * @example
725
+ * import {bb} from "billboard.js";
726
+ * import TableView from "billboard.js/dist/billboardjs-plugin-tableview";
727
+ *
728
+ * bb.generate({
729
+ * ...
730
+ * plugins: [
731
+ * new TableView({ ... })
732
+ * ]
733
+ * })
734
+ */
735
+ var TableView = class extends Plugin {
736
+ constructor(options = {}) {
737
+ super(options);
738
+ if (!isValidTableViewOptions(options)) console?.error?.("[billboard.js] TableView plugin received invalid options; unsupported values will be ignored.", options);
739
+ this.config = new Options();
740
+ return this;
741
+ }
742
+ $beforeInit() {
743
+ this.loadConfig();
744
+ }
745
+ $init() {
746
+ const { class: className, selector, style } = this.config;
747
+ let element = document.querySelector(selector || `.${className || defaultStyle.class}`);
748
+ if (!element) {
749
+ const chart = this.$$.$el.chart.node();
750
+ element = document.createElement("table");
751
+ chart.parentNode.insertBefore(element, chart.nextSibling);
752
+ }
753
+ if (element.tagName !== "TABLE") {
754
+ const table = document.createElement("table");
755
+ element.appendChild(table);
756
+ element = table;
757
+ }
758
+ if (style && !document.getElementById(defaultStyle.id)) {
759
+ const s = document.createElement("style");
760
+ s.id = defaultStyle.id;
761
+ s.innerHTML = defaultStyle.rule;
762
+ (document.head || document.getElementsByTagName("head")[0]).appendChild(s);
763
+ }
764
+ element.classList.add(...[style && defaultStyle.class, className].filter(Boolean));
765
+ this.element = element;
766
+ }
767
+ /**
768
+ * Generate table
769
+ * @private
770
+ */
771
+ generateTable() {
772
+ const { $$, config, element } = this;
773
+ const dataToShow = $$.filterTargetsToShow($$.data.targets);
774
+ let thead = tplProcess(tpl.thead, { title: dataToShow.length ? this.config.categoryTitle : "" });
775
+ let tbody = "";
776
+ const rows = [];
777
+ dataToShow.forEach((v) => {
778
+ thead += tplProcess(tpl.thead, { title: v.id });
779
+ v.values.forEach((d, i) => {
780
+ if (!rows[i]) rows[i] = [d.x];
781
+ rows[i].push(d.value);
782
+ });
783
+ });
784
+ rows.forEach((v) => {
785
+ tbody += `<tr>${v.map((d, i) => tplProcess(i ? tpl.tbody : tpl.tbodyHeader, { value: i === 0 ? config.categoryFormat.bind(this)(d) : isNumber(d) ? config.numberFormat.bind(this)(d) : config.nullString })).join("")}</tr>`;
786
+ });
787
+ element.innerHTML = tplProcess(tpl.body, {
788
+ ...config,
789
+ title: config.title || $$.config.title_text || "",
790
+ thead,
791
+ tbody
792
+ });
793
+ }
794
+ $redraw() {
795
+ const { state } = this.$$;
796
+ !(state.resizing || !this.config.updateOnToggle && state.toggling) && this.generateTable();
797
+ }
798
+ $willDestroy() {
799
+ this.element.parentNode?.removeChild(this.element);
800
+ if (this.$$.charts.length === 1) {
801
+ const s = document.getElementById(defaultStyle.id);
802
+ s?.parentNode?.removeChild(s);
803
+ }
804
+ }
805
+ };
806
+ //#endregion
807
+ export { TableView as default, isValidTableViewOptions };