@astrato-io/visualizations 0.6.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +32 -2
  3. package/THIRD_PARTY_NOTICES.md +68 -205
  4. package/VISUALIZATION_DEFINITIONS.md +68 -114
  5. package/chunks/Button-BrGKp9Nm.js +110 -0
  6. package/chunks/DefaultPropsProvider-BsfB7QTn.js +257 -0
  7. package/chunks/FieldTypeIcon-Drs6hSJF.js +22 -0
  8. package/chunks/{LinearProgress-CUZ0D8_t.js → LinearProgress-VtfFx2vJ.js} +51 -51
  9. package/chunks/MenuOption-ByRqhRdX.js +3934 -0
  10. package/chunks/Title-CO5dP1ma.js +1691 -0
  11. package/chunks/ToggleButton-KOBAimC1.js +112 -0
  12. package/chunks/app-filter-bar.compiler-TwVTeoj5.js +64 -0
  13. package/chunks/bar.compiler-DuQg8EUb.js +374 -0
  14. package/chunks/builder-DEDvNq1k.js +201 -0
  15. package/chunks/{color-settings-ZIvgNTq1.js → color-rules-CN7TcGrC.js} +2 -6
  16. package/chunks/color-settings-3VRlf_Vw.js +6 -0
  17. package/chunks/colorManipulator-D8Pjy1pf.js +45 -0
  18. package/chunks/coloring-CncX_JRX.js +278 -0
  19. package/chunks/{src-BC7cGcJ-.js → definitions-BPJQTx16.js} +650 -464
  20. package/chunks/{escobar-BGqT1EsE.js → escobar-DRhRMYRE.js} +6282 -4931
  21. package/chunks/event-bus-CrLB-Y8z.js +3 -0
  22. package/chunks/extend-preset-CUFNpmPe.js +4398 -0
  23. package/chunks/filter.compiler-w27dlv0C.js +70 -0
  24. package/chunks/filtering-cc7WqWpg.js +1153 -0
  25. package/chunks/handlers-TOT-7INo.js +12871 -0
  26. package/chunks/icon-picker-styles-CoJmwTRi.js +2246 -0
  27. package/chunks/isEqual-B8loyPsC.js +12 -0
  28. package/chunks/label-format-type-weq1XfcX.js +8 -0
  29. package/chunks/line.compiler-Ct1WhN2p.js +198 -0
  30. package/chunks/logger-DpQtYQnX.js +1163 -0
  31. package/chunks/lookup-BWllin0q.js +36 -0
  32. package/chunks/{metadata-CPXdYoln.js → metadata-WABZrt7Y.js} +1 -1
  33. package/chunks/number.compiler-D8TPly-4.js +53 -0
  34. package/chunks/{src-C0LgoUWY.js → operations-Dh4v1Ovt.js} +7716 -7541
  35. package/chunks/{range-DrzdfBX4.js → range-Bi-7zT0k.js} +2 -2
  36. package/chunks/registry-KervaxqJ.js +31 -0
  37. package/chunks/render-wrappers-OEmtaM8g.js +2 -0
  38. package/chunks/{registry-CExpGJ1N.js → requirements-PAoRaJyb.js} +294 -326
  39. package/chunks/responsive.styles-DSiOGD7u.js +82 -0
  40. package/chunks/shared-Bn4N5QcZ.js +1218 -0
  41. package/chunks/src-77e3mC7i.js +391 -0
  42. package/chunks/standalone-B55oyW6c.js +689 -0
  43. package/chunks/{standalone-CY57qwZ-.js → standalone-BDhPQtzQ.js} +386 -352
  44. package/chunks/{standalone-BDCwI6Hn.js → standalone-BGkmozIb.js} +1108 -953
  45. package/chunks/standalone-BMTCb10X.js +179 -0
  46. package/chunks/standalone-BXKRE_Se.js +468 -0
  47. package/chunks/standalone-Bes8srx1.js +354 -0
  48. package/chunks/standalone-BjZp0QMe.js +2 -0
  49. package/chunks/{standalone-BH5NqDwp.js → standalone-BlMIwpEe.js} +687 -573
  50. package/chunks/{standalone-CCNtaJ7s.js → standalone-C8ZAEutO.js} +44 -43
  51. package/chunks/standalone-C8qAelL4.js +2 -0
  52. package/chunks/standalone-CJvIXsQE.js +743 -0
  53. package/chunks/standalone-CLmGb7nn2.js +355 -0
  54. package/chunks/{ui-D1HQNIBy.js → standalone-CM5XcAN5.js} +15946 -17658
  55. package/chunks/standalone-CXNP6-xD.js +420 -0
  56. package/chunks/{standalone-BYm1UjLr.js → standalone-D5Q5ngsD.js} +59 -57
  57. package/chunks/standalone-DLlyRIE6.js +287 -0
  58. package/chunks/standalone-DMcI1afI.js +396 -0
  59. package/chunks/{standalone-jiz0L2Dg.js → standalone-DN4S1MjT.js} +1113 -1094
  60. package/chunks/{standalone-QJ1kKMnO.js → standalone-DT0wKji7.js} +2 -2
  61. package/chunks/{standalone-D5vnf-9y.js → standalone-DVTJwsTY.js} +1110 -1035
  62. package/chunks/standalone-DW6NT205.js +518 -0
  63. package/chunks/standalone-DYQIQH4c.js +2095 -0
  64. package/chunks/standalone-D__XCp-h.js +1003 -0
  65. package/chunks/standalone-XTgSsTAa.js +354 -0
  66. package/chunks/standalone-XuGksArp.js +68 -0
  67. package/chunks/{standalone-CNyNHKVx.js → standalone-we5D5MIn.js} +176 -172
  68. package/chunks/table.compiler-DMeeHxb6.js +222 -0
  69. package/chunks/useFieldName-Cjn9KCVp.js +7 -0
  70. package/chunks/useSlotProps-DLbQp4lc.js +166 -0
  71. package/chunks/{utils-Ba9T0TqC.js → utils-vdmi_2PK.js} +6266 -6517
  72. package/chunks/{src-DvX5LU9T.js → view-BuwQugKb.js} +2893 -5956
  73. package/chunks/visualization-filters-Cc4KU-l-.js +7455 -0
  74. package/chunks/web-components-DqClFkgO.js +1185 -0
  75. package/chunks/with-html-element-D0uY2zjI.js +7328 -0
  76. package/definitions.js +3 -3
  77. package/docs/operations/astrato-app-filter-bar.md +17 -17
  78. package/docs/operations/bar.md +1006 -1071
  79. package/docs/operations/combo.md +717 -738
  80. package/docs/operations/date-picker.md +27 -27
  81. package/docs/operations/distribution-gauge.md +471 -607
  82. package/docs/operations/dot.md +787 -879
  83. package/docs/operations/filter.md +139 -163
  84. package/docs/operations/gauge.md +491 -627
  85. package/docs/operations/heatMap.md +834 -916
  86. package/docs/operations/histogram.md +166 -180
  87. package/docs/operations/iframe.md +5 -5
  88. package/docs/operations/image.md +16 -16
  89. package/docs/operations/index.md +12 -12
  90. package/docs/operations/line.md +811 -888
  91. package/docs/operations/number.md +470 -536
  92. package/docs/operations/pie.md +825 -958
  93. package/docs/operations/radar.md +599 -679
  94. package/docs/operations/sankey.md +462 -584
  95. package/docs/operations/scatter.md +823 -929
  96. package/docs/operations/shape.md +34 -34
  97. package/docs/operations/simpleTextObject.md +18 -25
  98. package/docs/operations/slider.md +33 -43
  99. package/docs/operations/table.md +1177 -1150
  100. package/docs/operations/tree.md +404 -397
  101. package/docs/operations/treemap.md +595 -673
  102. package/docs/operations/waterfall.md +369 -379
  103. package/docs/operations/word-cloud.md +512 -583
  104. package/getters.js +7 -7
  105. package/index.js +3 -1183
  106. package/metadata.js +18 -18
  107. package/operations.js +13 -13
  108. package/package.json +133 -88
  109. package/render.js +10 -0
  110. package/src/charts/bar.d.ts +1 -0
  111. package/src/charts/combo.d.ts +1 -0
  112. package/src/charts/dot.d.ts +1 -0
  113. package/src/charts/gauge-distribution.d.ts +1 -0
  114. package/src/charts/gauge.d.ts +1 -0
  115. package/src/charts/heat-map.d.ts +1 -0
  116. package/src/charts/histogram.d.ts +1 -0
  117. package/src/charts/line.d.ts +1 -0
  118. package/src/charts/pie.d.ts +1 -0
  119. package/src/charts/radar.d.ts +1 -0
  120. package/src/charts/sankey.d.ts +1 -0
  121. package/src/charts/scatter.d.ts +1 -0
  122. package/src/charts/table.d.ts +1 -0
  123. package/src/charts/tree.d.ts +1 -0
  124. package/src/charts/treemap.d.ts +1 -0
  125. package/src/charts/waterfall.d.ts +1 -0
  126. package/src/charts/word-cloud.d.ts +1 -0
  127. package/src/definitions/index.d.ts +2 -2
  128. package/src/definitions/{shared/lib → model/definitions}/available-fields.d.ts +0 -1
  129. package/src/definitions/{shared/lib/compilers/index.d.ts → model/definitions/compilers/compile.d.ts} +1 -1
  130. package/src/definitions/model/definitions/data-item-resolution.d.ts +19 -0
  131. package/src/definitions/model/definitions/descriptors/descriptor-metadata.d.ts +1364 -0
  132. package/src/definitions/model/definitions/descriptors/json-schema.d.ts +2 -0
  133. package/src/definitions/model/definitions/diagnostics.d.ts +5 -0
  134. package/src/definitions/model/definitions/field-suggestions.d.ts +2 -0
  135. package/src/definitions/model/definitions/index.d.ts +23 -0
  136. package/src/definitions/{shared/lib → model/definitions}/registry/compile.d.ts +1 -1
  137. package/src/definitions/model/definitions/registry/descriptor-registry.d.ts +3 -0
  138. package/src/definitions/model/definitions/schema-registry.d.ts +660 -0
  139. package/src/definitions/{shared/lib → model/definitions}/schemas/broad-chart.schema.d.ts +1 -1
  140. package/src/definitions/{shared/lib → model/definitions}/schemas/common.schema.d.ts +0 -1
  141. package/src/definitions/model/definitions/schemas/index.d.ts +9 -0
  142. package/src/definitions/{shared/lib → model/definitions}/schemas/object.schema.d.ts +8 -8
  143. package/src/definitions/{shared/lib → model/definitions}/types/compilation.types.d.ts +10 -0
  144. package/src/definitions/{shared/lib → model/definitions}/types/definition.types.d.ts +1 -1
  145. package/src/definitions/model/definitions/types/index.d.ts +3 -0
  146. package/src/definitions/{shared/lib/registry → model/definitions}/validation.d.ts +1 -1
  147. package/src/getters/index.d.ts +3 -3
  148. package/src/index.d.ts +1 -1
  149. package/src/objects/app-filter-bar.d.ts +1 -0
  150. package/src/objects/date-picker.d.ts +1 -0
  151. package/src/objects/filter.d.ts +1 -0
  152. package/src/objects/iframe.d.ts +1 -0
  153. package/src/objects/image.d.ts +1 -0
  154. package/src/objects/number.d.ts +1 -0
  155. package/src/objects/shape.d.ts +1 -0
  156. package/src/objects/slider.d.ts +1 -0
  157. package/src/objects/text.d.ts +1 -0
  158. package/src/operations/index.d.ts +3 -3
  159. package/src/registry/create-visualization-registry.d.ts +5 -0
  160. package/src/render/index.d.ts +34 -0
  161. package/src/runtime/index.d.ts +2 -2
  162. package/src/types.d.ts +9 -4
  163. package/src/web-components/index.d.ts +3 -3
  164. package/chunks/Radio-Ciu-F4CU.js +0 -957
  165. package/chunks/ToggleButton-BCJc3Jlc.js +0 -153
  166. package/chunks/_baseFlatten-DPXPOrea.js +0 -7076
  167. package/chunks/app-filter-bar.compiler-j_CVoWTa.js +0 -55
  168. package/chunks/bar.compiler-oqaPzIut.js +0 -370
  169. package/chunks/coloring-C16AUZEi.js +0 -663
  170. package/chunks/data-item-resolution-1lvYB5ln.js +0 -53
  171. package/chunks/event-bus-KiSiCJrC.js +0 -2683
  172. package/chunks/events-WZut5Ow6.js +0 -4
  173. package/chunks/filter.compiler-CuLtc_02.js +0 -60
  174. package/chunks/filtering-Yq4DEa0t.js +0 -953
  175. package/chunks/gauge-target-type-BkKXAqkX.js +0 -4
  176. package/chunks/grouping-type-BX_9Ix5q.js +0 -3
  177. package/chunks/interfaces-VUY4_yVO.js +0 -8742
  178. package/chunks/line-settings-DfYTUyPz.js +0 -4
  179. package/chunks/line.compiler-BpA_6Tc7.js +0 -188
  180. package/chunks/number.compiler-DbkWcG4S.js +0 -44
  181. package/chunks/pie-uv42Eqal.js +0 -10
  182. package/chunks/requirements-DNhuShLS.js +0 -6
  183. package/chunks/shared-CKDL4hx9.js +0 -1171
  184. package/chunks/src-Cum_2NLV.js +0 -12145
  185. package/chunks/src-Dun_jXtz.js +0 -10295
  186. package/chunks/standalone-87YV_m9n.js +0 -687
  187. package/chunks/standalone-BLVAWLNJ.js +0 -385
  188. package/chunks/standalone-BPomtAVs.js +0 -2
  189. package/chunks/standalone-BXyBcUOQ.js +0 -2
  190. package/chunks/standalone-BllF4rDp.js +0 -383
  191. package/chunks/standalone-BmfMt74U.js +0 -726
  192. package/chunks/standalone-BqWyrnZI.js +0 -281
  193. package/chunks/standalone-C85u7U6I.js +0 -340
  194. package/chunks/standalone-CDQnr6qT.js +0 -345
  195. package/chunks/standalone-CZynjFG7.js +0 -12979
  196. package/chunks/standalone-DFPva_ku.js +0 -299
  197. package/chunks/standalone-DQxxNwF8.js +0 -675
  198. package/chunks/standalone-DS9T0FZ-.js +0 -830
  199. package/chunks/standalone-Dx3MLlrO.js +0 -512
  200. package/chunks/standalone-DzixzZAL.js +0 -411
  201. package/chunks/standalone-lBm9hQ-q.js +0 -179
  202. package/chunks/standalone-rJ45Zfl1.js +0 -68
  203. package/chunks/table.compiler-BrXkm4Fz.js +0 -213
  204. package/chunks/toInteger-DVZr-D1j.js +0 -11
  205. package/chunks/treemap-x_zmJoG7.js +0 -23
  206. package/chunks/types-dVVCsDWD.js +0 -4
  207. package/chunks/useFieldName-oqQ3bvnO.js +0 -7
  208. package/chunks/view-CLqWMV7Z.js +0 -156
  209. package/src/definitions/shared/index.d.ts +0 -5
  210. package/src/definitions/shared/lib/registry/descriptor-registry.d.ts +0 -587
  211. package/src/definitions/shared/lib/registry/index.d.ts +0 -3
  212. package/src/definitions/shared/lib/schemas/index.d.ts +0 -9
  213. package/src/definitions/shared/lib/types/index.d.ts +0 -3
  214. package/src/definitions/{shared/lib → model/definitions}/schemas/app-filter-bar.schema.d.ts +0 -0
  215. package/src/definitions/{shared/lib → model/definitions}/schemas/bar.schema.d.ts +0 -0
  216. package/src/definitions/{shared/lib → model/definitions}/schemas/filter.schema.d.ts +0 -0
  217. package/src/definitions/{shared/lib → model/definitions}/schemas/line.schema.d.ts +0 -0
  218. package/src/definitions/{shared/lib → model/definitions}/schemas/number.schema.d.ts +0 -0
  219. package/src/definitions/{shared/lib → model/definitions}/schemas/table.schema.d.ts +4 -4
  220. /package/src/definitions/{shared/lib → model/definitions}/types/descriptor.types.d.ts +0 -0
@@ -1,299 +0,0 @@
1
- import { o as e } from "./rolldown-runtime-DleVn1XH.js";
2
- import { Fa as t, La as n, Na as r, No as i, Oi as a, Pa as o, Pn as s, Ta as c, Ti as l, os as u, pc as d, ss as f } from "./interfaces-VUY4_yVO.js";
3
- import { G as p, Ki as m, Wn as h, Zt as g, d as _, pn as v, wi as y } from "./utils-Ba9T0TqC.js";
4
- import { r as b } from "./ui-D1HQNIBy.js";
5
- import { s as x } from "./coloring-C16AUZEi.js";
6
- var S = /* @__PURE__ */ e(m()), C = (e, n) => {
7
- switch (e.thresholdType) {
8
- case t.Range: return T(n, e.rangeThresholds ?? []);
9
- case t.Target: return w(n, e.targetThreshold);
10
- case t.None: return {};
11
- }
12
- }, w = (e, t) => {
13
- let n = s(t?.target, 0), { belowTargetColorAndIcon: r, targetColorAndIcon: i, aboveTargetColorAndIcon: a } = t || {};
14
- return e < n * (1 - t.targetTolerance) ? r : e > n * (1 + t.targetTolerance) ? a : i;
15
- }, T = (e, t) => [...t].sort((e, t) => s(t.rangeTo, 0) - s(e.rangeTo, 0)).reduce((t, n) => e < s(n.rangeTo, 0) ? n.colorAndIcon : t, {}), E = (e) => {
16
- let t = ["numberColor"], n = ["comparisonColor"];
17
- switch (e) {
18
- case "main": return t;
19
- case "comparison": return n;
20
- case "both": return [...t, ...n];
21
- }
22
- }, D = (e, t, n) => n.reduce((n, r) => t in e ? {
23
- ...n,
24
- [r]: e[t]
25
- } : n, {}), O = {
26
- numberColor: "#1f1c3b",
27
- iconColor: "#1f1c3b",
28
- iconPosition: i.Left,
29
- comparisonColor: "#1f1c3b",
30
- comparisonPosition: i.Bottom
31
- }, k = {
32
- numberValue: 0,
33
- textAlign: u.Center,
34
- horizontalAlign: u.Center,
35
- verticalAlign: f.Middle,
36
- numberStyle: {
37
- fontSize: 12,
38
- fontFamily: "Roboto",
39
- bold: !1,
40
- italic: !1,
41
- underlined: !1,
42
- strikethrough: !1
43
- },
44
- comparisonStyle: {
45
- relativeFontSizePercentage: a.relativeFontSizePercentage,
46
- fontFamily: "Roboto",
47
- bold: !1,
48
- italic: !1,
49
- underlined: !1,
50
- strikethrough: !1
51
- },
52
- comparisonGap: r.SmallGap,
53
- ...O
54
- }, A = (e, t, r) => {
55
- if (!r?.length || !e) return k;
56
- let i = t || c, a = i.fonts.general.fontFamily, o = F(r, e.measures.find((e) => l(e) && e.role === n.NUMBER_MEASURE), !0), { numberValue: s, numberFormat: u, comparisonNumberValue: d, comparisonFormat: f } = j(e, r);
57
- return {
58
- ...N(e, i, o, d),
59
- numberValue: s,
60
- numberFormat: u,
61
- comparisonNumberValue: d,
62
- comparisonFormat: f,
63
- numberStyle: {
64
- fontSize: e.numberSettings?.numberStyle?.fontSize ?? k.numberStyle.fontSize,
65
- fontFamily: e.numberSettings?.numberStyle?.fontFamily ?? a,
66
- bold: e.numberSettings?.numberStyle?.bold ?? k.numberStyle.bold,
67
- weight: e.numberSettings?.numberStyle?.weight,
68
- italic: e.numberSettings?.numberStyle?.italic ?? k.numberStyle.italic,
69
- underlined: e.numberSettings?.numberStyle?.underlined ?? k.numberStyle.underlined,
70
- strikethrough: e.numberSettings?.numberStyle?.strikethrough ?? k.numberStyle.strikethrough
71
- },
72
- comparisonStyle: {
73
- relativeFontSizePercentage: e.numberSettings?.comparisonStyle?.relativeFontSizePercentage ?? k.comparisonStyle.relativeFontSizePercentage,
74
- fontFamily: e.numberSettings?.comparisonStyle?.fontFamily ?? a,
75
- bold: e.numberSettings?.comparisonStyle?.bold ?? k.comparisonStyle.bold,
76
- weight: e.numberSettings?.comparisonStyle?.weight,
77
- italic: e.numberSettings?.comparisonStyle?.italic ?? k.comparisonStyle.italic,
78
- underlined: e.numberSettings?.comparisonStyle?.underlined ?? k.comparisonStyle.underlined,
79
- strikethrough: e.numberSettings?.comparisonStyle?.strikethrough ?? k.comparisonStyle.strikethrough
80
- },
81
- textAlign: e.numberSettings?.position?.textAlign ?? k.textAlign,
82
- horizontalAlign: e.numberSettings?.position?.numberHorizontalAlign ?? k.horizontalAlign,
83
- verticalAlign: e.numberSettings?.position?.numberVerticalAlign ?? k.verticalAlign,
84
- comparisonGap: e.numberSettings?.position?.comparisonGap ?? k.comparisonGap
85
- };
86
- }, j = (e, t) => {
87
- let r, i, a, o, s = e.measures.filter(l), c = s.filter((e) => e.role === n.NUMBER_MEASURE), u = s.filter((e) => e.role === n.NUMBER_COMPARISON), d = c[0], f = u[0];
88
- return r = F(t, d, !0), a = M(e, t), d?.formatter && typeof d?.formatter?.format != "string" && (i = d.formatter), f?.formatter && typeof f?.formatter?.format != "string" && (o = f.formatter), f && e.numberSettings?.data?.showOnlyComparison && (r = a, i = o, a = void 0, o = void 0), {
89
- numberValue: r,
90
- numberFormat: i,
91
- comparisonNumberValue: a,
92
- comparisonFormat: o
93
- };
94
- }, M = (e, t) => {
95
- let r = e.measures.filter(l), i = r.filter((e) => e.role === n.NUMBER_MEASURE), a = r.filter((e) => e.role === n.NUMBER_COMPARISON), s = i[0], c = a[0];
96
- if (!c) return;
97
- let u = +F(t, s), d = +F(t, c), f = e.numberSettings?.data?.comparisonType, p = Math.abs(d);
98
- return f === o.PercentageToComparison ? u === 0 && d === 0 ? 1 : u / p : f === o.PercentageAboveBelow ? u === 0 && d === 0 ? 0 : (u - d) / p : f === o.Difference ? u - d : d;
99
- }, N = (e, r, i, a) => {
100
- let o = e.measures.filter(l), s = o.filter((e) => e.role === n.NUMBER_MEASURE), c = o.filter((e) => e.role === n.NUMBER_COMPARISON), u = s[0], d = c[0];
101
- return (e.numberSettings?.thresholds ?? []).filter((e) => e.thresholdType !== t.None).reduce((e, t) => {
102
- if (t.measureRule === "main" ? u : d) {
103
- let n = C(t, t.measureRule === "main" ? i : a);
104
- return {
105
- ...e,
106
- ...D(n, "icon", ["icon"]),
107
- ...D(n, "iconColor", ["iconColor"]),
108
- ...D(n, "numberColor", E(t.colorRule)),
109
- backgroundColor: n.backgroundColor ?? e.backgroundColor
110
- };
111
- }
112
- return e;
113
- }, P(e, r));
114
- }, P = (e, t) => {
115
- let { icon: n, iconColor: r } = e.numberSettings?.colorAndIcon || {};
116
- return {
117
- icon: n,
118
- iconColor: x(t, r ?? "black"),
119
- iconPosition: e?.numberSettings?.position?.iconPosition ?? i.Left,
120
- numberColor: x(t, e?.numberSettings?.numberStyle?.fontColor ?? t.fonts.general.color),
121
- ...I(e, t, e.numberSettings?.comparisonStyle?.fontColor)
122
- };
123
- }, F = (e, t, n = !1) => {
124
- let r = d(t?.dataItem), i = (e?.[0])?.items?.[0]?.[r], a = +`${i}`, o = n && (!t?.formatter || t?.formatter?.format === "string") ? `${i}` : 0;
125
- return isNaN(a) ? o : a;
126
- }, I = (e, t, r) => !e.measures.filter(l).filter((e) => e.role === n.NUMBER_COMPARISON)[0] || e.numberSettings.data?.showOnlyComparison ? {
127
- comparisonPosition: void 0,
128
- comparisonColor: void 0
129
- } : {
130
- comparisonColor: x(t, r ?? t.fonts.general.color),
131
- comparisonPosition: e.numberSettings?.position?.comparisonPosition ?? i.Left
132
- }, L = p({
133
- mainContainer: {
134
- width: "100%",
135
- height: "100%",
136
- display: "flex",
137
- lineHeight: 1,
138
- overflow: "hidden"
139
- },
140
- numbersContainer: {
141
- display: "flex",
142
- justifyContent: "center",
143
- letterSpacing: "0.05em"
144
- },
145
- number: { fontSize: "1em" },
146
- comparisonIconContainer: {
147
- display: "flex",
148
- justifyContent: "center"
149
- }
150
- }), R = (e) => {
151
- switch (e) {
152
- case f.Top:
153
- case u.Left: return "flex-start";
154
- case f.Bottom:
155
- case u.Right: return "flex-end";
156
- default: return "center";
157
- }
158
- }, z = (e) => {
159
- let t = e.comparisonPosition ?? e.iconPosition;
160
- return t === i.Top || t === i.Bottom ? R(e.textAlign) : "center";
161
- }, B = (e, t, n, r = !1) => {
162
- let i, a, o = 0;
163
- r && Math.floor(e) !== e && (o = e.toString().split(".")[1].length || 0);
164
- let s = async (c) => {
165
- a === void 0 && (a = c);
166
- let l = c - a, u = Math.min(l / 500, 1), d = t + (e - t) * u;
167
- r && (d = Number(d.toFixed(o))), n(d), l < 500 ? i = requestAnimationFrame(s) : (n(e), cancelAnimationFrame(i));
168
- };
169
- return e !== t && (i = requestAnimationFrame(s)), () => cancelAnimationFrame(i);
170
- }, V = .5, H = `${V}em`, U = (e, t) => !(t === i.Left || t === i.Right) || !e || e === r.None ? {} : e === r.SmallGap ? { gap: H } : {
171
- width: "100%",
172
- justifyContent: e
173
- }, W = (e, t) => e ? t === i.Top || t === i.Bottom ? "0.33em" : "0.5em" : t === i.Top || t === i.Bottom ? "0.5em" : "1.0em", G = (e) => {
174
- switch (e) {
175
- case i.Top: return "column";
176
- case i.Bottom: return "column-reverse";
177
- case i.Right: return "row-reverse";
178
- default: return "row";
179
- }
180
- }, K = (e, t) => !e && !t ? "inherit" : `${e ? "underline" : ""} ${t ? "line-through" : ""}`, q = ({ numberSize: e, comparisonNumberSize: t, numberProps: n, elementSize: a, fontSize: o }) => {
181
- let s = n.comparisonNumberValue != null && !!t && (n.comparisonPosition === i.Left || n.comparisonPosition === i.Right), c = !!n.icon && (n.iconPosition === i.Left || n.iconPosition === i.Right), l = s ? e.width + t.width : Math.max(e.width, t?.width ?? 0);
182
- return s && n.comparisonGap === r.SmallGap && (l += V * o), c && (l += e.height), l <= a.width;
183
- }, J = ({ numberSize: e, comparisonNumberSize: t, numberProps: n, elementSize: r }) => {
184
- let a = n.comparisonNumberValue != null && !!t && (n.comparisonPosition === i.Top || n.comparisonPosition === i.Bottom), o = !!n.icon && (n.iconPosition === i.Top || n.iconPosition === i.Bottom), s = a ? e.height + t.height : Math.max(e.height, t?.height ?? 0);
185
- return o && (s += e.height), s <= r.height;
186
- }, Y = 1.2, X = ({ number: e, comparisonNumber: t }, n, r) => {
187
- let { numberStyle: i, comparisonStyle: o } = n;
188
- if (r.width === 0) return i.fontSize;
189
- let s = h(), c = (o.relativeFontSizePercentage ?? a.relativeFontSizePercentage) / 100, l = 1;
190
- for (let a = i.fontSize; a >= 1; --a) {
191
- let u, d;
192
- if (e && (u = {
193
- width: s.getTextSize({
194
- size: a,
195
- label: e,
196
- fontFamily: i.fontFamily,
197
- letterSpacing: "0.05em",
198
- fontWeight: 400
199
- }).width,
200
- height: a * Y
201
- }), t) {
202
- let e = a * c;
203
- d = {
204
- width: s.getTextSize({
205
- size: e,
206
- label: t,
207
- fontFamily: o.fontFamily,
208
- letterSpacing: "0.05em",
209
- fontWeight: 400
210
- }).width,
211
- height: e * Y
212
- };
213
- }
214
- if (q({
215
- numberSize: u,
216
- comparisonNumberSize: d,
217
- numberProps: n,
218
- elementSize: r,
219
- fontSize: a
220
- }) && J({
221
- numberSize: u,
222
- comparisonNumberSize: d,
223
- numberProps: n,
224
- elementSize: r,
225
- fontSize: a
226
- })) {
227
- l = a;
228
- break;
229
- }
230
- }
231
- return s.cleanDOM(), l;
232
- }, Z = y(), Q = g((0, S.memo)(({ vSpec: e, vTheme: t, elementSize: n, data: r, vizProperties: i }) => {
233
- let [o, s] = (0, S.useState)(0), c = L(), l = _(), u = A(e, t, r), { numberValue: d, numberFormat: f, comparisonNumberValue: p, comparisonFormat: m, backgroundColor: h } = u, g = o, y = f ? v(f, o) : o, x = m ? v(m, p) : p, C = y === "" || y == null, w = C ? void 0 : `${y}`, T = x === "" || x == null ? void 0 : `${x}`, E = C ? u.numberStyle.fontSize || 14 : X({
234
- number: w,
235
- comparisonNumber: T
236
- }, u, n);
237
- return (0, S.useEffect)(() => {
238
- let e;
239
- return !i?.disable?.animations && typeof d == "number" ? (typeof g != "number" && (s(0), g = 0), e = B(d, g, s, !f)) : s(d), () => {
240
- e && e();
241
- };
242
- }, [d]), (0, S.useEffect)(() => {
243
- e && l();
244
- }, [e]), /* @__PURE__ */ (0, Z.jsx)("div", {
245
- className: c.mainContainer,
246
- style: {
247
- fontSize: `${E}px`,
248
- alignItems: R(u.verticalAlign),
249
- justifyContent: R(u.horizontalAlign),
250
- backgroundColor: h
251
- },
252
- children: /* @__PURE__ */ (0, Z.jsxs)("div", {
253
- className: c.numbersContainer,
254
- style: {
255
- alignItems: z(u),
256
- flexDirection: G(u.comparisonPosition ?? u.iconPosition),
257
- ...U(u.comparisonGap, u.comparisonPosition)
258
- },
259
- children: [/* @__PURE__ */ (0, Z.jsxs)("div", {
260
- className: c.comparisonIconContainer,
261
- style: {
262
- alignItems: R(u.textAlign),
263
- flexDirection: G(u.iconPosition)
264
- },
265
- children: [/* @__PURE__ */ (0, Z.jsx)(b, {
266
- name: u.icon,
267
- testId: "indicator-icon",
268
- style: {
269
- fontSize: W(u.comparisonPosition, u.iconPosition),
270
- color: u.iconColor ?? "inherit"
271
- }
272
- }), /* @__PURE__ */ (0, Z.jsx)("div", {
273
- "data-testid": "number-comparison",
274
- style: {
275
- fontSize: `${(u.comparisonStyle.relativeFontSizePercentage ?? a.relativeFontSizePercentage) / 100}em`,
276
- fontFamily: u.comparisonStyle.fontFamily,
277
- fontStyle: u.comparisonStyle.italic ? "italic" : "normal",
278
- fontWeight: u.comparisonStyle.weight || (u.comparisonStyle.bold ? "bold" : "normal"),
279
- textDecoration: K(u.comparisonStyle.underlined, u.comparisonStyle.strikethrough),
280
- color: u.comparisonColor ?? "inherit"
281
- },
282
- children: T
283
- })]
284
- }), /* @__PURE__ */ (0, Z.jsx)("div", {
285
- className: c.number,
286
- "data-testid": "number-base",
287
- style: {
288
- fontFamily: u.numberStyle.fontFamily,
289
- fontStyle: u.numberStyle.italic ? "italic" : "normal",
290
- fontWeight: u.numberStyle.weight || (u.numberStyle.bold ? "bold" : "normal"),
291
- textDecoration: K(u.numberStyle.underlined, u.numberStyle.strikethrough),
292
- color: u.numberColor
293
- },
294
- children: f && typeof o == "number" ? v(f, o) : o
295
- })]
296
- })
297
- });
298
- }));
299
- export { Q as Number };