@lidofinance/lido-ui 3.30.0 → 3.30.1

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 (85) hide show
  1. package/dist/cjs/chart-line/ChartLine.js +92 -0
  2. package/dist/cjs/chart-line/ChartLine.js.map +1 -0
  3. package/dist/cjs/chart-line/ChartLineLabel.js +66 -0
  4. package/dist/cjs/chart-line/ChartLineLabel.js.map +1 -0
  5. package/dist/cjs/chart-line/ChartLineStyles.js +209 -0
  6. package/dist/cjs/chart-line/ChartLineStyles.js.map +1 -0
  7. package/dist/cjs/chart-line/types.js +18 -0
  8. package/dist/cjs/chart-line/types.js.map +1 -0
  9. package/dist/cjs/chart-line/utils/checkViewport.js +13 -0
  10. package/dist/cjs/chart-line/utils/checkViewport.js.map +1 -0
  11. package/dist/cjs/chart-line/utils/constants.js +12 -0
  12. package/dist/cjs/chart-line/utils/constants.js.map +1 -0
  13. package/dist/cjs/chart-line/utils/getContainerSize.js +28 -0
  14. package/dist/cjs/chart-line/utils/getContainerSize.js.map +1 -0
  15. package/dist/cjs/chart-line/utils/handlePositioning.js +168 -0
  16. package/dist/cjs/chart-line/utils/handlePositioning.js.map +1 -0
  17. package/dist/cjs/chart-line/utils/processData.js +29 -0
  18. package/dist/cjs/chart-line/utils/processData.js.map +1 -0
  19. package/dist/cjs/chart-proportion/ChartProportion.js +68 -0
  20. package/dist/cjs/chart-proportion/ChartProportion.js.map +1 -0
  21. package/dist/cjs/chart-proportion/ChartProportionStyles.js +132 -0
  22. package/dist/cjs/chart-proportion/ChartProportionStyles.js.map +1 -0
  23. package/dist/cjs/chart-proportion/types.js +26 -0
  24. package/dist/cjs/chart-proportion/types.js.map +1 -0
  25. package/dist/cjs/index.js +13 -0
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/esm/chart-line/ChartLine.mjs +88 -0
  28. package/dist/esm/chart-line/ChartLine.mjs.map +1 -0
  29. package/dist/esm/chart-line/ChartLineLabel.mjs +62 -0
  30. package/dist/esm/chart-line/ChartLineLabel.mjs.map +1 -0
  31. package/dist/esm/chart-line/ChartLineStyles.mjs +201 -0
  32. package/dist/esm/chart-line/ChartLineStyles.mjs.map +1 -0
  33. package/dist/esm/chart-line/types.mjs +13 -0
  34. package/dist/esm/chart-line/types.mjs.map +1 -0
  35. package/dist/esm/chart-line/utils/checkViewport.mjs +9 -0
  36. package/dist/esm/chart-line/utils/checkViewport.mjs.map +1 -0
  37. package/dist/esm/chart-line/utils/constants.mjs +6 -0
  38. package/dist/esm/chart-line/utils/constants.mjs.map +1 -0
  39. package/dist/esm/chart-line/utils/getContainerSize.mjs +24 -0
  40. package/dist/esm/chart-line/utils/getContainerSize.mjs.map +1 -0
  41. package/dist/esm/chart-line/utils/handlePositioning.mjs +163 -0
  42. package/dist/esm/chart-line/utils/handlePositioning.mjs.map +1 -0
  43. package/dist/esm/chart-line/utils/processData.mjs +25 -0
  44. package/dist/esm/chart-line/utils/processData.mjs.map +1 -0
  45. package/dist/esm/chart-proportion/ChartProportion.mjs +64 -0
  46. package/dist/esm/chart-proportion/ChartProportion.mjs.map +1 -0
  47. package/dist/esm/chart-proportion/ChartProportionStyles.mjs +124 -0
  48. package/dist/esm/chart-proportion/ChartProportionStyles.mjs.map +1 -0
  49. package/dist/esm/chart-proportion/types.mjs +20 -0
  50. package/dist/esm/chart-proportion/types.mjs.map +1 -0
  51. package/dist/esm/index.mjs +5 -0
  52. package/dist/esm/index.mjs.map +1 -1
  53. package/dist/types/chart-line/ChartLine.d.ts +6 -0
  54. package/dist/types/chart-line/ChartLine.d.ts.map +1 -0
  55. package/dist/types/chart-line/ChartLineLabel.d.ts +14 -0
  56. package/dist/types/chart-line/ChartLineLabel.d.ts.map +1 -0
  57. package/dist/types/chart-line/ChartLineStyles.d.ts +27 -0
  58. package/dist/types/chart-line/ChartLineStyles.d.ts.map +1 -0
  59. package/dist/types/chart-line/index.d.ts +4 -0
  60. package/dist/types/chart-line/index.d.ts.map +1 -0
  61. package/dist/types/chart-line/types.d.ts +43 -0
  62. package/dist/types/chart-line/types.d.ts.map +1 -0
  63. package/dist/types/chart-line/utils/checkViewport.d.ts +2 -0
  64. package/dist/types/chart-line/utils/checkViewport.d.ts.map +1 -0
  65. package/dist/types/chart-line/utils/constants.d.ts +4 -0
  66. package/dist/types/chart-line/utils/constants.d.ts.map +1 -0
  67. package/dist/types/chart-line/utils/getContainerSize.d.ts +5 -0
  68. package/dist/types/chart-line/utils/getContainerSize.d.ts.map +1 -0
  69. package/dist/types/chart-line/utils/handlePositioning.d.ts +9 -0
  70. package/dist/types/chart-line/utils/handlePositioning.d.ts.map +1 -0
  71. package/dist/types/chart-line/utils/index.d.ts +6 -0
  72. package/dist/types/chart-line/utils/index.d.ts.map +1 -0
  73. package/dist/types/chart-line/utils/processData.d.ts +13 -0
  74. package/dist/types/chart-line/utils/processData.d.ts.map +1 -0
  75. package/dist/types/chart-proportion/ChartProportion.d.ts +6 -0
  76. package/dist/types/chart-proportion/ChartProportion.d.ts.map +1 -0
  77. package/dist/types/chart-proportion/ChartProportionStyles.d.ts +20 -0
  78. package/dist/types/chart-proportion/ChartProportionStyles.d.ts.map +1 -0
  79. package/dist/types/chart-proportion/index.d.ts +3 -0
  80. package/dist/types/chart-proportion/index.d.ts.map +1 -0
  81. package/dist/types/chart-proportion/types.d.ts +37 -0
  82. package/dist/types/chart-proportion/types.d.ts.map +1 -0
  83. package/dist/types/index.d.ts +2 -0
  84. package/dist/types/index.d.ts.map +1 -1
  85. package/package.json +1 -1
@@ -0,0 +1,201 @@
1
+ import styled from '../utils/styled-components-wrapper.mjs';
2
+ import { ChartLineBorderType, ChartLineThresholdType } from './types.mjs';
3
+ import { css } from 'styled-components';
4
+
5
+ const ContainerStyle = styled.div`
6
+ display: flex;
7
+ width: 100%;
8
+ align-items: ${_ref => {
9
+ let {
10
+ $alignItems
11
+ } = _ref;
12
+ return $alignItems;
13
+ }};
14
+ height: ${_ref2 => {
15
+ let {
16
+ $height
17
+ } = _ref2;
18
+ return $height;
19
+ }}px;
20
+ `;
21
+ const WrapperStyle = styled.div`
22
+ display: flex;
23
+ width: 100%;
24
+ height: ${_ref3 => {
25
+ let {
26
+ $height
27
+ } = _ref3;
28
+ return $height;
29
+ }}px;
30
+ background: rgb(19 18 23 / 8%);
31
+ position: relative;
32
+
33
+ ${_ref4 => {
34
+ let {
35
+ $border
36
+ } = _ref4;
37
+
38
+ if ($border === ChartLineBorderType.rounded) {
39
+ return css`
40
+ border-radius: 4px;
41
+ `;
42
+ }
43
+
44
+ return css``;
45
+ }}
46
+ `;
47
+ const ThresholdStyle = styled.div`
48
+ height: ${_ref5 => {
49
+ let {
50
+ $height
51
+ } = _ref5;
52
+ return $height + 38;
53
+ }}px;
54
+ width: 5px;
55
+ background-color: ${_ref6 => {
56
+ let {
57
+ $backgroundColor
58
+ } = _ref6;
59
+ return $backgroundColor;
60
+ }};
61
+ z-index: ${_ref7 => {
62
+ let {
63
+ $zIndex
64
+ } = _ref7;
65
+ return $zIndex;
66
+ }};
67
+ position: absolute;
68
+ border-radius: 3px;
69
+ top: -2px;
70
+ right: -2px;
71
+
72
+ ${_ref8 => {
73
+ let {
74
+ $labelPosition
75
+ } = _ref8;
76
+
77
+ if ($labelPosition === 'top') {
78
+ return css`
79
+ bottom: -2px;
80
+ top: unset;
81
+ `;
82
+ }
83
+
84
+ return css``;
85
+ }}
86
+
87
+ ${_ref9 => {
88
+ let {
89
+ $thresholdType,
90
+ $height
91
+ } = _ref9;
92
+
93
+ if ($thresholdType === ChartLineThresholdType.dash) {
94
+ return css`
95
+ height: ${$height + 4}px;
96
+ top: -2px;
97
+ `;
98
+ }
99
+
100
+ return css``;
101
+ }}
102
+ `;
103
+ const ThresholdLabelStyle = styled.div`
104
+ color: ${_ref10 => {
105
+ let {
106
+ theme
107
+ } = _ref10;
108
+ return theme.colors.foreground;
109
+ }};
110
+ font-size: 12px;
111
+ font-weight: 400;
112
+ line-height: 20px;
113
+ padding: 4px 8px;
114
+ position: absolute;
115
+ bottom: -2px;
116
+ right: 0;
117
+ border-radius: 4px;
118
+ white-space: nowrap;
119
+ box-sizing: border-box;
120
+ max-height: 28px;
121
+
122
+ ${_ref11 => {
123
+ let {
124
+ $labelPosition
125
+ } = _ref11;
126
+
127
+ if ($labelPosition === 'top') {
128
+ return css`
129
+ top: -2px;
130
+ bottom: unset;
131
+ `;
132
+ }
133
+
134
+ return css``;
135
+ }};
136
+ `;
137
+ const LineStyle = styled.div`
138
+ background-color: ${_ref12 => {
139
+ let {
140
+ $backgroundColor
141
+ } = _ref12;
142
+ return $backgroundColor ? $backgroundColor : 'transparent';
143
+ }};
144
+ z-index: ${_ref13 => {
145
+ let {
146
+ $zIndex
147
+ } = _ref13;
148
+ return $zIndex;
149
+ }};
150
+ width: ${_ref14 => {
151
+ let {
152
+ $width
153
+ } = _ref14;
154
+ return $width;
155
+ }};
156
+ height: 100%;
157
+ position: absolute;
158
+ top: 0;
159
+ left: 0;
160
+ bottom: 0;
161
+ border-right: 1px solid ${_ref15 => {
162
+ let {
163
+ theme
164
+ } = _ref15;
165
+ return theme.colors.background;
166
+ }};
167
+
168
+ ${_ref16 => {
169
+ let {
170
+ $border
171
+ } = _ref16;
172
+
173
+ if ($border === ChartLineBorderType.rounded) {
174
+ return css`
175
+ border-radius: 4px 0 0 4px;
176
+ `;
177
+ }
178
+
179
+ return css``;
180
+ }}
181
+
182
+ &:last-child {
183
+ ${_ref17 => {
184
+ let {
185
+ $border,
186
+ $isFullWidth
187
+ } = _ref17;
188
+
189
+ if ($border === ChartLineBorderType.rounded && $isFullWidth) {
190
+ return css`
191
+ border-radius: 4px;
192
+ `;
193
+ }
194
+
195
+ return css``;
196
+ }}
197
+ }
198
+ `;
199
+
200
+ export { ContainerStyle, LineStyle, ThresholdLabelStyle, ThresholdStyle, WrapperStyle };
201
+ //# sourceMappingURL=ChartLineStyles.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartLineStyles.mjs","sources":["../../../packages/chart-line/ChartLineStyles.tsx"],"sourcesContent":["import styled, { css } from '../utils/styled-components-wrapper.js'\nimport { ChartLineBorderType, ChartLineThresholdType } from './types.js'\n\nexport const ContainerStyle = styled.div<{\n $alignItems: 'center' | 'flex-start'\n $height: number\n}>`\n display: flex;\n width: 100%;\n align-items: ${({ $alignItems }) => $alignItems};\n height: ${({ $height }) => $height}px;\n`\n\nexport const WrapperStyle = styled.div<{\n $border: ChartLineBorderType\n $height: number\n}>`\n display: flex;\n width: 100%;\n height: ${({ $height }) => $height}px;\n background: rgb(19 18 23 / 8%);\n position: relative;\n\n ${({ $border }) => {\n if ($border === ChartLineBorderType.rounded) {\n return css`\n border-radius: 4px;\n `\n }\n return css``\n }}\n`\n\nexport const ThresholdStyle = styled.div<{\n $labelPosition?: 'top' | 'bottom'\n $thresholdType: ChartLineThresholdType\n $height: number\n $backgroundColor?: string\n $zIndex: number\n}>`\n height: ${({ $height }) => $height + 38}px;\n width: 5px;\n background-color: ${({ $backgroundColor }) => $backgroundColor};\n z-index: ${({ $zIndex }) => $zIndex};\n position: absolute;\n border-radius: 3px;\n top: -2px;\n right: -2px;\n\n ${({ $labelPosition }) => {\n if ($labelPosition === 'top') {\n return css`\n bottom: -2px;\n top: unset;\n `\n }\n return css``\n }}\n\n ${({ $thresholdType, $height }) => {\n if ($thresholdType === ChartLineThresholdType.dash) {\n return css`\n height: ${$height + 4}px;\n top: -2px;\n `\n }\n return css``\n }}\n`\n\nexport const ThresholdLabelStyle = styled.div<{\n $labelPosition?: 'top' | 'bottom'\n}>`\n color: ${({ theme }) => theme.colors.foreground};\n font-size: 12px;\n font-weight: 400;\n line-height: 20px;\n padding: 4px 8px;\n position: absolute;\n bottom: -2px;\n right: 0;\n border-radius: 4px;\n white-space: nowrap;\n box-sizing: border-box;\n max-height: 28px;\n\n ${({ $labelPosition }) => {\n if ($labelPosition === 'top') {\n return css`\n top: -2px;\n bottom: unset;\n `\n }\n return css``\n }};\n`\n\nexport const LineStyle = styled.div<{\n $border: ChartLineBorderType\n $isFullWidth: boolean\n $width: string\n $backgroundColor?: string\n $zIndex: number\n}>`\n background-color: ${({ $backgroundColor }) =>\n $backgroundColor ? $backgroundColor : 'transparent'};\n z-index: ${({ $zIndex }) => $zIndex};\n width: ${({ $width }) => $width};\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n border-right: 1px solid ${({ theme }) => theme.colors.background};\n\n ${({ $border }) => {\n if ($border === ChartLineBorderType.rounded) {\n return css`\n border-radius: 4px 0 0 4px;\n `\n }\n return css``\n }}\n\n &:last-child {\n ${({ $border, $isFullWidth }) => {\n if ($border === ChartLineBorderType.rounded && $isFullWidth) {\n return css`\n border-radius: 4px;\n `\n }\n return css``\n }}\n }\n`\n"],"names":["ContainerStyle","styled","div","$alignItems","$height","WrapperStyle","$border","ChartLineBorderType","rounded","css","ThresholdStyle","$backgroundColor","$zIndex","$labelPosition","$thresholdType","ChartLineThresholdType","dash","ThresholdLabelStyle","theme","colors","foreground","LineStyle","$width","background","$isFullWidth"],"mappings":";;;;AAGaA,MAAAA,cAAc,GAAGC,MAAM,CAACC,GAGlC,CAAA;AACH;AACA;AACA,eAAiB,EAAA,IAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,WAAAA;GAAH,GAAA,IAAA,CAAA;AAAA,EAAA,OAAqBA,WAArB,CAAA;AAAA,CAAiC,CAAA;AAClD,UAAY,EAAA,KAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,OAAAA;GAAH,GAAA,KAAA,CAAA;AAAA,EAAA,OAAiBA,OAAjB,CAAA;AAAA,CAAyB,CAAA;AACrC,EARO;AAUMC,MAAAA,YAAY,GAAGJ,MAAM,CAACC,GAGhC,CAAA;AACH;AACA;AACA,UAAY,EAAA,KAAA,IAAA;EAAA,IAAC;AAAEE,IAAAA,OAAAA;GAAH,GAAA,KAAA,CAAA;AAAA,EAAA,OAAiBA,OAAjB,CAAA;AAAA,CAAyB,CAAA;AACrC;AACA;AACA;AACA,EAAA,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AA,OAAgBA,MAAhB,CAAA;AAAA,CAAuB,CAAA;AAClC;AACA;AACA;AACA;AACA;AACA,0BAA4B,EAAA,MAAA,IAAA;EAAA,IAAC;AAAEJ,IAAAA,KAAAA;GAAH,GAAA,MAAA,CAAA;AAAA,EAAA,OAAeA,KAAK,CAACC,MAAN,CAAaI,UAA5B,CAAA;AAAA,CAAuC,CAAA;AACnE;AACA,EAAA,EAAI,MAAiB,IAAA;EAAA,IAAhB;AAAEjB,IAAAA,OAAAA;GAAc,GAAA,MAAA,CAAA;;AACjB,EAAA,IAAIA,OAAO,KAAKC,mBAAmB,CAACC,OAApC,EAA6C;AAC3C,IAAA,OAAOC,GAAI,CAAA;AACjB;AACA,MAFM,CAAA,CAAA;AAGD,GAAA;;AACD,EAAA,OAAOA,GAAI,CAAX,CAAA,CAAA;AACD,CAAC,CAAA;AACJ;AACA;AACA,IAAA,EAAM,MAA+B,IAAA;EAAA,IAA9B;IAAEH,OAAF;AAAWkB,IAAAA,YAAAA;GAAmB,GAAA,MAAA,CAAA;;AAC/B,EAAA,IAAIlB,OAAO,KAAKC,mBAAmB,CAACC,OAAhC,IAA2CgB,YAA/C,EAA6D;AAC3D,IAAA,OAAOf,GAAI,CAAA;AACnB;AACA,QAFQ,CAAA,CAAA;AAGD,GAAA;;AACD,EAAA,OAAOA,GAAI,CAAX,CAAA,CAAA;AACD,CAAC,CAAA;AACN;AACA;;;;"}
@@ -0,0 +1,13 @@
1
+ let ChartLineThresholdType = /*#__PURE__*/function (ChartLineThresholdType) {
2
+ ChartLineThresholdType["dash"] = "dash";
3
+ ChartLineThresholdType["flag"] = "flag";
4
+ return ChartLineThresholdType;
5
+ }({});
6
+ let ChartLineBorderType = /*#__PURE__*/function (ChartLineBorderType) {
7
+ ChartLineBorderType["rounded"] = "rounded";
8
+ ChartLineBorderType["square"] = "square";
9
+ return ChartLineBorderType;
10
+ }({});
11
+
12
+ export { ChartLineBorderType, ChartLineThresholdType };
13
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sources":["../../../packages/chart-line/types.tsx"],"sourcesContent":["import { LidoComponentProps } from '../utils/index.js'\nexport type { Theme } from '../theme/index.js'\n\nexport enum ChartLineThresholdType {\n dash = 'dash',\n flag = 'flag',\n}\nexport type ChartLineThresholdTypes = keyof typeof ChartLineThresholdType\nexport enum ChartLineBorderType {\n rounded = 'rounded',\n square = 'square',\n}\nexport type ChartLineBorderTypes = keyof typeof ChartLineBorderType\n\nexport type ChartLineConfig = {\n loading?: boolean\n data: LineData[]\n thresholdType: ChartLineThresholdType\n height: number\n border: ChartLineBorderType\n maxValue?: number\n showLabels?: boolean\n}\n\nexport type LineData = {\n color?: string\n labelPosition?: 'top' | 'bottom'\n threshold: {\n value: number\n color?: string\n label: string\n description: string\n descriptionElement?: React.ReactNode\n }\n}\n\nexport type ChartLineProps = LidoComponentProps<'div', ChartLineConfig>\n\nexport type ChartLineLabelProps = LidoComponentProps<\n 'div',\n {\n id: string\n previousIds?: string[]\n zIndex: number\n show?: boolean\n height: number\n thresholdType: ChartLineThresholdType\n } & LineData\n>\n"],"names":["ChartLineThresholdType","ChartLineBorderType"],"mappings":"AAGYA,IAAAA,sBAAZ,0BAAYA,sBAAZ,EAAA;EAAYA,sBAAZ,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;EAAYA,sBAAZ,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;AAAA,EAAA,OAAYA,sBAAZ,CAAA;AAAA,CAAA,CAAA,EAAA,EAAA;AAKYC,IAAAA,mBAAZ,0BAAYA,mBAAZ,EAAA;EAAYA,mBAAZ,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAYA,mBAAZ,CAAA,QAAA,CAAA,GAAA,QAAA,CAAA;AAAA,EAAA,OAAYA,mBAAZ,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
@@ -0,0 +1,9 @@
1
+ import { VIEWPORT_MARGIN } from './constants.mjs';
2
+
3
+ const checkViewportOverflow = (position, elemSize, viewportSize) => {
4
+ const invertPosition = viewportSize - position;
5
+ return position + elemSize + VIEWPORT_MARGIN > viewportSize && invertPosition + elemSize + VIEWPORT_MARGIN < viewportSize;
6
+ };
7
+
8
+ export { checkViewportOverflow };
9
+ //# sourceMappingURL=checkViewport.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkViewport.mjs","sources":["../../../../packages/chart-line/utils/checkViewport.ts"],"sourcesContent":["import { VIEWPORT_MARGIN } from './constants.js'\n\n// Check if element overflows viewport and should be inverted\nexport const checkViewportOverflow = (\n position: number,\n elemSize: number,\n viewportSize: number,\n) => {\n const invertPosition = viewportSize - position\n return (\n position + elemSize + VIEWPORT_MARGIN > viewportSize &&\n invertPosition + elemSize + VIEWPORT_MARGIN < viewportSize\n )\n}\n"],"names":["checkViewportOverflow","position","elemSize","viewportSize","invertPosition","VIEWPORT_MARGIN"],"mappings":";;AAGO,MAAMA,qBAAqB,GAAG,CACnCC,QADmC,EAEnCC,QAFmC,EAGnCC,YAHmC,KAIhC;AACH,EAAA,MAAMC,cAAc,GAAGD,YAAY,GAAGF,QAAtC,CAAA;AACA,EAAA,OACEA,QAAQ,GAAGC,QAAX,GAAsBG,eAAtB,GAAwCF,YAAxC,IACAC,cAAc,GAAGF,QAAjB,GAA4BG,eAA5B,GAA8CF,YAFhD,CAAA;AAID;;;;"}
@@ -0,0 +1,6 @@
1
+ const VIEWPORT_MARGIN = 8;
2
+ const CHART_LINE_CONTAINER_ID = 'chart-line-container';
3
+ const LABEL_HEIGHT_INCREASE = 36;
4
+
5
+ export { CHART_LINE_CONTAINER_ID, LABEL_HEIGHT_INCREASE, VIEWPORT_MARGIN };
6
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sources":["../../../../packages/chart-line/utils/constants.ts"],"sourcesContent":["export const VIEWPORT_MARGIN = 8\nexport const CHART_LINE_CONTAINER_ID = 'chart-line-container'\nexport const LABEL_HEIGHT_INCREASE = 36\n"],"names":["VIEWPORT_MARGIN","CHART_LINE_CONTAINER_ID","LABEL_HEIGHT_INCREASE"],"mappings":"AAAO,MAAMA,eAAe,GAAG,EAAxB;AACA,MAAMC,uBAAuB,GAAG,uBAAhC;AACA,MAAMC,qBAAqB,GAAG;;;;"}
@@ -0,0 +1,24 @@
1
+ // get max height between all elements
2
+ const getContainerSize = elementIds => {
3
+ if (!elementIds.length) return null;
4
+ const isCenterAlign = elementIds.every(id => {
5
+ const element = document.getElementById(id);
6
+ return element?.dataset.labelPosition === 'top' || element?.dataset.labelPosition === 'bottom';
7
+ });
8
+ const size = elementIds.reduce((acc, id) => {
9
+ const element = document.getElementById(id);
10
+
11
+ if (element && element.offsetHeight > 0) {
12
+ return Math.max(acc, element.offsetHeight);
13
+ }
14
+
15
+ return acc;
16
+ }, 0);
17
+ return {
18
+ size: isCenterAlign ? size * 2 : size,
19
+ isCenterAlign
20
+ };
21
+ };
22
+
23
+ export { getContainerSize };
24
+ //# sourceMappingURL=getContainerSize.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getContainerSize.mjs","sources":["../../../../packages/chart-line/utils/getContainerSize.ts"],"sourcesContent":["// get max height between all elements\nexport const getContainerSize = (elementIds: string[]) => {\n if (!elementIds.length) return null\n\n const isCenterAlign = elementIds.every((id) => {\n const element = document.getElementById(id)\n return (\n element?.dataset.labelPosition === 'top' ||\n element?.dataset.labelPosition === 'bottom'\n )\n })\n\n const size = elementIds.reduce((acc, id) => {\n const element = document.getElementById(id)\n if (element && element.offsetHeight > 0) {\n return Math.max(acc, element.offsetHeight)\n }\n return acc\n }, 0)\n\n return {\n size: isCenterAlign ? size * 2 : size,\n isCenterAlign,\n }\n}\n"],"names":["getContainerSize","elementIds","length","isCenterAlign","every","id","element","document","getElementById","dataset","labelPosition","size","reduce","acc","offsetHeight","Math","max"],"mappings":"AAAA;AACaA,MAAAA,gBAAgB,GAAIC,UAAD,IAA0B;AACxD,EAAA,IAAI,CAACA,UAAU,CAACC,MAAhB,EAAwB,OAAO,IAAP,CAAA;AAExB,EAAA,MAAMC,aAAa,GAAGF,UAAU,CAACG,KAAX,CAAkBC,EAAD,IAAQ;AAC7C,IAAA,MAAMC,OAAO,GAAGC,QAAQ,CAACC,cAAT,CAAwBH,EAAxB,CAAhB,CAAA;AACA,IAAA,OACEC,OAAO,EAAEG,OAAT,CAAiBC,aAAjB,KAAmC,KAAnC,IACAJ,OAAO,EAAEG,OAAT,CAAiBC,aAAjB,KAAmC,QAFrC,CAAA;AAID,GANqB,CAAtB,CAAA;EAQA,MAAMC,IAAI,GAAGV,UAAU,CAACW,MAAX,CAAkB,CAACC,GAAD,EAAMR,EAAN,KAAa;AAC1C,IAAA,MAAMC,OAAO,GAAGC,QAAQ,CAACC,cAAT,CAAwBH,EAAxB,CAAhB,CAAA;;AACA,IAAA,IAAIC,OAAO,IAAIA,OAAO,CAACQ,YAAR,GAAuB,CAAtC,EAAyC;MACvC,OAAOC,IAAI,CAACC,GAAL,CAASH,GAAT,EAAcP,OAAO,CAACQ,YAAtB,CAAP,CAAA;AACD,KAAA;;AACD,IAAA,OAAOD,GAAP,CAAA;GALW,EAMV,CANU,CAAb,CAAA;EAQA,OAAO;AACLF,IAAAA,IAAI,EAAER,aAAa,GAAGQ,IAAI,GAAG,CAAV,GAAcA,IAD5B;AAELR,IAAAA,aAAAA;GAFF,CAAA;AAID;;;;"}
@@ -0,0 +1,163 @@
1
+ import { checkViewportOverflow } from './checkViewport.mjs';
2
+ import { LABEL_HEIGHT_INCREASE, CHART_LINE_CONTAINER_ID, VIEWPORT_MARGIN } from './constants.mjs';
3
+
4
+ // Get elements and their rects in one go
5
+ const getElementData = id => {
6
+ const threshold = document.getElementById(id);
7
+ const label = document.getElementById(`${id}-description`);
8
+ if (!threshold || !label) return null;
9
+ const container = document.getElementById(CHART_LINE_CONTAINER_ID);
10
+ if (!container) return null; // Temporarily reset transform to get original positions
11
+
12
+ const originalTransform = label.style.transform;
13
+ label.style.removeProperty('transform');
14
+ const thresholdRect = threshold.getBoundingClientRect();
15
+ const labelRect = label.getBoundingClientRect();
16
+ const containerRect = container.getBoundingClientRect(); // Restore transform if it existed
17
+
18
+ if (originalTransform) {
19
+ label.style.setProperty('transform', originalTransform);
20
+ }
21
+
22
+ return {
23
+ elements: {
24
+ threshold,
25
+ label
26
+ },
27
+ rects: {
28
+ threshold: thresholdRect,
29
+ label: labelRect
30
+ },
31
+ containerRect
32
+ };
33
+ }; // Calculate offset needed to keep label within viewport bounds
34
+
35
+
36
+ const calculateLabelOffset = (thresholdRect, labelRect, containerRect, isInverted) => {
37
+ if (isInverted) {
38
+ // Label positioned with left: 0 (extends right from threshold)
39
+ // Check if label extends beyond container right boundary
40
+ const labelRightEdge = thresholdRect.left + labelRect.width;
41
+ const containerRightEdge = containerRect.right - VIEWPORT_MARGIN;
42
+
43
+ if (labelRightEdge > containerRightEdge) {
44
+ return labelRightEdge - containerRightEdge;
45
+ }
46
+ } else {
47
+ // Label positioned with right: 0 (extends left from threshold - default behavior)
48
+ // Check if label left edge goes beyond container left boundary
49
+ const labelLeftEdge = thresholdRect.right - labelRect.width;
50
+ const containerLeftEdge = containerRect.left + VIEWPORT_MARGIN;
51
+
52
+ if (labelLeftEdge < containerLeftEdge) {
53
+ return containerLeftEdge - labelLeftEdge;
54
+ }
55
+ }
56
+
57
+ return 0;
58
+ }; // Calculate if flag should be inverted based on viewport overflow
59
+
60
+
61
+ const shouldInvertLabel = (thresholdRect, labelRect, containerRect, viewportWidth) => {
62
+ const position = containerRect.right - thresholdRect.right;
63
+ const isInverted = checkViewportOverflow(position, labelRect.width, viewportWidth);
64
+ return isInverted;
65
+ };
66
+
67
+ const resetThresholdHeight = threshold => {
68
+ if (!threshold) return;
69
+ threshold.style.removeProperty('height');
70
+ }; // Apply label positioning based on inversion
71
+
72
+ const applyLabelPosition = (label, isInverted) => {
73
+ if (isInverted) {
74
+ label.style.setProperty('left', '0px');
75
+ label.style.setProperty('right', 'auto');
76
+ label.dataset.isInverted = 'true';
77
+ } else {
78
+ label.style.setProperty('right', '0px');
79
+ label.style.setProperty('left', 'auto');
80
+ label.dataset.isInverted = 'false';
81
+ }
82
+ }; // Calculate distance between two thresholds considering label inversion
83
+
84
+
85
+ const calculateFlagDistance = (currentRect, previousRect, currentLabelRect, isPreviousInverted) => {
86
+ return isPreviousInverted ? currentRect.left - previousRect.left - currentLabelRect.width : currentRect.left - previousRect.left;
87
+ }; // Get first previous threshold on the same position as the current threshold
88
+
89
+
90
+ const getPreviousThreshold = (previousIds, currentId) => {
91
+ const currentElement = document.getElementById(currentId);
92
+ if (!currentElement) return null;
93
+ const currentLabelPosition = currentElement.dataset.labelPosition;
94
+
95
+ for (let i = previousIds.length - 1; i >= 0; i--) {
96
+ const id = previousIds[i];
97
+ const element = document.getElementById(id);
98
+
99
+ if (element?.dataset.labelPosition === currentLabelPosition) {
100
+ return id;
101
+ }
102
+ }
103
+
104
+ return null;
105
+ };
106
+
107
+ const handlePositioning = props => {
108
+ const {
109
+ previousIds = [],
110
+ id,
111
+ reset
112
+ } = props; // Check if we are in browser (not SSR)
113
+
114
+ if (typeof window === 'undefined') return;
115
+
116
+ if (reset) {
117
+ resetThresholdHeight(document.getElementById(id));
118
+ return;
119
+ }
120
+
121
+ const currentData = getElementData(id);
122
+ if (!currentData) return;
123
+ const {
124
+ elements: currentElements,
125
+ rects: currentRects,
126
+ containerRect
127
+ } = currentData; // Calculate inversion for current label using container width
128
+
129
+ const currentIsInverted = shouldInvertLabel(currentRects.threshold, currentRects.label, containerRect, containerRect.width); // Apply positioning for current label
130
+
131
+ applyLabelPosition(currentElements.label, currentIsInverted); // Calculate offset needed to keep label within bounds
132
+
133
+ const currentOffset = calculateLabelOffset(currentRects.threshold, currentRects.label, containerRect, currentIsInverted); // Apply offset if needed
134
+
135
+ if (currentOffset > 0) {
136
+ const direction = currentIsInverted ? -currentOffset : currentOffset;
137
+ currentElements.label.style.setProperty('transform', `translateX(${direction}px)`);
138
+ } else {
139
+ currentElements.label.style.removeProperty('transform');
140
+ } // Handle previous threshold positioning if exists
141
+
142
+
143
+ const previousId = getPreviousThreshold(previousIds, id);
144
+ if (!previousId) return;
145
+ const previousData = getElementData(previousId);
146
+ if (!previousData) return;
147
+ const {
148
+ rects: previousRects,
149
+ elements: previousElements
150
+ } = previousData; // Calculate inversion for previous flag using window width (as in original)
151
+
152
+ const previousIsInverted = previousElements.label.dataset.isInverted === 'true'; // Calculate distance and adjust height if needed
153
+
154
+ const distance = calculateFlagDistance(currentRects.threshold, previousRects.threshold, currentRects.label, previousIsInverted);
155
+
156
+ if (distance < currentRects.label.width) {
157
+ const newHeight = previousRects.threshold.height + LABEL_HEIGHT_INCREASE;
158
+ currentElements.threshold.style.setProperty('height', `${newHeight}px`);
159
+ }
160
+ };
161
+
162
+ export { handlePositioning, resetThresholdHeight };
163
+ //# sourceMappingURL=handlePositioning.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlePositioning.mjs","sources":["../../../../packages/chart-line/utils/handlePositioning.ts"],"sourcesContent":["import { checkViewportOverflow } from './checkViewport.js'\nimport {\n CHART_LINE_CONTAINER_ID,\n LABEL_HEIGHT_INCREASE,\n VIEWPORT_MARGIN,\n} from './constants.js'\n\ntype HandlePositioningProps = {\n previousIds?: string[]\n id: string\n reset?: boolean\n}\n\ntype PositioningData = {\n elements: {\n threshold: HTMLElement\n label: HTMLElement\n }\n rects: {\n threshold: DOMRect\n label: DOMRect\n }\n containerRect: DOMRect\n}\n\n// Get elements and their rects in one go\nconst getElementData = (id: string): PositioningData | null => {\n const threshold = document.getElementById(id)\n const label = document.getElementById(`${id}-description`)\n\n if (!threshold || !label) return null\n\n const container = document.getElementById(CHART_LINE_CONTAINER_ID)\n if (!container) return null\n\n // Temporarily reset transform to get original positions\n const originalTransform = label.style.transform\n label.style.removeProperty('transform')\n\n const thresholdRect = threshold.getBoundingClientRect()\n const labelRect = label.getBoundingClientRect()\n const containerRect = container.getBoundingClientRect()\n\n // Restore transform if it existed\n if (originalTransform) {\n label.style.setProperty('transform', originalTransform)\n }\n\n return {\n elements: { threshold, label },\n rects: { threshold: thresholdRect, label: labelRect },\n containerRect,\n }\n}\n\n// Calculate offset needed to keep label within viewport bounds\nconst calculateLabelOffset = (\n thresholdRect: DOMRect,\n labelRect: DOMRect,\n containerRect: DOMRect,\n isInverted: boolean,\n): number => {\n if (isInverted) {\n // Label positioned with left: 0 (extends right from threshold)\n // Check if label extends beyond container right boundary\n const labelRightEdge = thresholdRect.left + labelRect.width\n const containerRightEdge = containerRect.right - VIEWPORT_MARGIN\n\n if (labelRightEdge > containerRightEdge) {\n return labelRightEdge - containerRightEdge\n }\n } else {\n // Label positioned with right: 0 (extends left from threshold - default behavior)\n // Check if label left edge goes beyond container left boundary\n const labelLeftEdge = thresholdRect.right - labelRect.width\n const containerLeftEdge = containerRect.left + VIEWPORT_MARGIN\n\n if (labelLeftEdge < containerLeftEdge) {\n return containerLeftEdge - labelLeftEdge\n }\n }\n return 0\n}\n\n// Calculate if flag should be inverted based on viewport overflow\nconst shouldInvertLabel = (\n thresholdRect: DOMRect,\n labelRect: DOMRect,\n containerRect: DOMRect,\n viewportWidth: number,\n): boolean => {\n const position = containerRect.right - thresholdRect.right\n\n const isInverted = checkViewportOverflow(\n position,\n labelRect.width,\n viewportWidth,\n )\n\n return isInverted\n}\n\nexport const resetThresholdHeight = (threshold: HTMLElement | null): void => {\n if (!threshold) return\n\n threshold.style.removeProperty('height')\n}\n\n// Apply label positioning based on inversion\nconst applyLabelPosition = (label: HTMLElement, isInverted: boolean): void => {\n if (isInverted) {\n label.style.setProperty('left', '0px')\n label.style.setProperty('right', 'auto')\n label.dataset.isInverted = 'true'\n } else {\n label.style.setProperty('right', '0px')\n label.style.setProperty('left', 'auto')\n label.dataset.isInverted = 'false'\n }\n}\n\n// Calculate distance between two thresholds considering label inversion\nconst calculateFlagDistance = (\n currentRect: DOMRect,\n previousRect: DOMRect,\n currentLabelRect: DOMRect,\n isPreviousInverted: boolean,\n): number => {\n return isPreviousInverted\n ? currentRect.left - previousRect.left - currentLabelRect.width\n : currentRect.left - previousRect.left\n}\n\n// Get first previous threshold on the same position as the current threshold\nconst getPreviousThreshold = (\n previousIds: string[],\n currentId: string,\n): string | null => {\n const currentElement = document.getElementById(currentId)\n if (!currentElement) return null\n\n const currentLabelPosition = currentElement.dataset.labelPosition\n\n for (let i = previousIds.length - 1; i >= 0; i--) {\n const id = previousIds[i]\n const element = document.getElementById(id)\n if (element?.dataset.labelPosition === currentLabelPosition) {\n return id\n }\n }\n\n return null\n}\n\nexport const handlePositioning = (props: HandlePositioningProps): void => {\n const { previousIds = [], id, reset } = props\n\n // Check if we are in browser (not SSR)\n if (typeof window === 'undefined') return\n\n if (reset) {\n resetThresholdHeight(document.getElementById(id))\n return\n }\n\n const currentData = getElementData(id)\n if (!currentData) return\n\n const {\n elements: currentElements,\n rects: currentRects,\n containerRect,\n } = currentData\n\n // Calculate inversion for current label using container width\n const currentIsInverted = shouldInvertLabel(\n currentRects.threshold,\n currentRects.label,\n containerRect,\n containerRect.width,\n )\n\n // Apply positioning for current label\n applyLabelPosition(currentElements.label, currentIsInverted)\n\n // Calculate offset needed to keep label within bounds\n const currentOffset = calculateLabelOffset(\n currentRects.threshold,\n currentRects.label,\n containerRect,\n currentIsInverted,\n )\n\n // Apply offset if needed\n if (currentOffset > 0) {\n const direction = currentIsInverted ? -currentOffset : currentOffset\n currentElements.label.style.setProperty(\n 'transform',\n `translateX(${direction}px)`,\n )\n } else {\n currentElements.label.style.removeProperty('transform')\n }\n\n // Handle previous threshold positioning if exists\n const previousId = getPreviousThreshold(previousIds, id)\n if (!previousId) return\n\n const previousData = getElementData(previousId)\n if (!previousData) return\n\n const { rects: previousRects, elements: previousElements } = previousData\n\n // Calculate inversion for previous flag using window width (as in original)\n const previousIsInverted =\n previousElements.label.dataset.isInverted === 'true'\n\n // Calculate distance and adjust height if needed\n const distance = calculateFlagDistance(\n currentRects.threshold,\n previousRects.threshold,\n currentRects.label,\n previousIsInverted,\n )\n\n if (distance < currentRects.label.width) {\n const newHeight = previousRects.threshold.height + LABEL_HEIGHT_INCREASE\n currentElements.threshold.style.setProperty('height', `${newHeight}px`)\n }\n}\n"],"names":["getElementData","id","threshold","document","getElementById","label","container","CHART_LINE_CONTAINER_ID","originalTransform","style","transform","removeProperty","thresholdRect","getBoundingClientRect","labelRect","containerRect","setProperty","elements","rects","calculateLabelOffset","isInverted","labelRightEdge","left","width","containerRightEdge","right","VIEWPORT_MARGIN","labelLeftEdge","containerLeftEdge","shouldInvertLabel","viewportWidth","position","checkViewportOverflow","resetThresholdHeight","applyLabelPosition","dataset","calculateFlagDistance","currentRect","previousRect","currentLabelRect","isPreviousInverted","getPreviousThreshold","previousIds","currentId","currentElement","currentLabelPosition","labelPosition","i","length","element","handlePositioning","props","reset","window","currentData","currentElements","currentRects","currentIsInverted","currentOffset","direction","previousId","previousData","previousRects","previousElements","previousIsInverted","distance","newHeight","height","LABEL_HEIGHT_INCREASE"],"mappings":";;;AAyBA;AACA,MAAMA,cAAc,GAAIC,EAAD,IAAwC;AAC7D,EAAA,MAAMC,SAAS,GAAGC,QAAQ,CAACC,cAAT,CAAwBH,EAAxB,CAAlB,CAAA;EACA,MAAMI,KAAK,GAAGF,QAAQ,CAACC,cAAT,CAAyB,CAAA,EAAEH,EAAG,CAAA,YAAA,CAA9B,CAAd,CAAA;AAEA,EAAA,IAAI,CAACC,SAAD,IAAc,CAACG,KAAnB,EAA0B,OAAO,IAAP,CAAA;AAE1B,EAAA,MAAMC,SAAS,GAAGH,QAAQ,CAACC,cAAT,CAAwBG,uBAAxB,CAAlB,CAAA;AACA,EAAA,IAAI,CAACD,SAAL,EAAgB,OAAO,IAAP,CAP6C;;AAU7D,EAAA,MAAME,iBAAiB,GAAGH,KAAK,CAACI,KAAN,CAAYC,SAAtC,CAAA;AACAL,EAAAA,KAAK,CAACI,KAAN,CAAYE,cAAZ,CAA2B,WAA3B,CAAA,CAAA;AAEA,EAA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MC,YAAY,GAAG7D,cAAc,CAAC4D,UAAD,CAAnC,CAAA;EACA,IAAI,CAACC,YAAL,EAAmB,OAAA;EAEnB,MAAM;AAAE3C,IAAAA,KAAK,EAAE4C,aAAT;AAAwB7C,IAAAA,QAAQ,EAAE8C,gBAAAA;GAAqBF,GAAAA,YAA7D,CAzDwE;;AA4DxE,EAAA,MAAMG,kBAAkB,GACtBD,gBAAgB,CAAC1D,KAAjB,CAAuB8B,OAAvB,CAA+Bf,UAA/B,KAA8C,MADhD,CA5DwE;;AAgExE,EAAA,MAAM6C,QAAQ,GAAG7B,qBAAqB,CACpCoB,YAAY,CAACtD,SADuB,EAEpC4D,aAAa,CAAC5D,SAFsB,EAGpCsD,YAAY,CAACnD,KAHuB,EAIpC2D,kBAJoC,CAAtC,CAAA;;AAOA,EAAA,IAAIC,QAAQ,GAAGT,YAAY,CAACnD,KAAb,CAAmBkB,KAAlC,EAAyC;IACvC,MAAM2C,SAAS,GAAGJ,aAAa,CAAC5D,SAAd,CAAwBiE,MAAxB,GAAiCC,qBAAnD,CAAA;IACAb,eAAe,CAACrD,SAAhB,CAA0BO,KAA1B,CAAgCO,WAAhC,CAA4C,QAA5C,EAAuD,CAAEkD,EAAAA,SAAU,CAAnE,EAAA,CAAA,CAAA,CAAA;AACD,GAAA;AACF;;;;"}
@@ -0,0 +1,25 @@
1
+ const processData = (data, maxValue) => {
2
+ // Calculate maxValue once if not provided
3
+ const calculatedMaxValue = maxValue ?? Math.max(...data.map(item => item.threshold.value));
4
+ return data.sort((a, b) => a.threshold.value - b.threshold.value).reduce((acc, item, index) => {
5
+ const {
6
+ threshold
7
+ } = item;
8
+ const id = `chart-percent-line-group-${index}-${threshold.label}`;
9
+ const width = threshold.value / (calculatedMaxValue / 100);
10
+ const processedItem = { ...item,
11
+ id,
12
+ index,
13
+ width
14
+ };
15
+ acc.data.push(processedItem);
16
+ acc.ids.push(id);
17
+ return acc;
18
+ }, {
19
+ data: [],
20
+ ids: []
21
+ });
22
+ };
23
+
24
+ export { processData };
25
+ //# sourceMappingURL=processData.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processData.mjs","sources":["../../../../packages/chart-line/utils/processData.ts"],"sourcesContent":["import { LineData } from '../types.js'\n\ntype ProcessedLineData = LineData & {\n id: string\n index: number\n width: number\n}\n\ntype ProcessedData = {\n data: ProcessedLineData[]\n ids: string[]\n}\n\nexport const processData = (\n data: LineData[],\n maxValue?: number,\n): ProcessedData => {\n // Calculate maxValue once if not provided\n const calculatedMaxValue =\n maxValue ?? Math.max(...data.map((item) => item.threshold.value))\n\n return data\n .sort((a, b) => a.threshold.value - b.threshold.value)\n .reduce<ProcessedData>(\n (acc, item, index) => {\n const { threshold } = item\n const id = `chart-percent-line-group-${index}-${threshold.label}`\n const width = threshold.value / (calculatedMaxValue / 100)\n\n const processedItem: ProcessedLineData = {\n ...item,\n id,\n index,\n width,\n }\n\n acc.data.push(processedItem)\n acc.ids.push(id)\n\n return acc\n },\n { data: [], ids: [] },\n )\n}\n"],"names":["processData","data","maxValue","calculatedMaxValue","Math","max","map","item","threshold","value","sort","a","b","reduce","acc","index","id","label","width","processedItem","push","ids"],"mappings":"MAaaA,WAAW,GAAG,CACzBC,IADyB,EAEzBC,QAFyB,KAGP;AAClB;EACA,MAAMC,kBAAkB,GACtBD,QAAQ,IAAIE,IAAI,CAACC,GAAL,CAAS,GAAGJ,IAAI,CAACK,GAAL,CAAUC,IAAD,IAAUA,IAAI,CAACC,SAAL,CAAeC,KAAlC,CAAZ,CADd,CAAA;AAGA,EAAA,OAAOR,IAAI,CACRS,IADI,CACC,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAACH,SAAF,CAAYC,KAAZ,GAAoBG,CAAC,CAACJ,SAAF,CAAYC,KAD3C,CAEJI,CAAAA,MAFI,CAGH,CAACC,GAAD,EAAMP,IAAN,EAAYQ,KAAZ,KAAsB;IACpB,MAAM;AAAEP,MAAAA,SAAAA;AAAF,KAAA,GAAgBD,IAAtB,CAAA;IACA,MAAMS,EAAE,GAAI,CAA2BD,yBAAAA,EAAAA,KAAM,IAAGP,SAAS,CAACS,KAAM,CAAhE,CAAA,CAAA;IACA,MAAMC,KAAK,GAAGV,SAAS,CAACC,KAAV,IAAmBN,kBAAkB,GAAG,GAAxC,CAAd,CAAA;AAEA,IAAA,MAAMgB,aAAgC,GAAG,EACvC,GAAGZ,IADoC;MAEvCS,EAFuC;MAGvCD,KAHuC;AAIvCG,MAAAA,KAAAA;KAJF,CAAA;AAOAJ,IAAAA,GAAG,CAACb,IAAJ,CAASmB,IAAT,CAAcD,aAAd,CAAA,CAAA;AACAL,IAAAA,GAAG,CAACO,GAAJ,CAAQD,IAAR,CAAaJ,EAAb,CAAA,CAAA;AAEA,IAAA,OAAOF,GAAP,CAAA;AACD,GAnBE,EAoBH;AAAEb,IAAAA,IAAI,EAAE,EAAR;AAAYoB,IAAAA,GAAG,EAAE,EAAA;AAAjB,GApBG,CAAP,CAAA;AAsBD;;;;"}
@@ -0,0 +1,64 @@
1
+ import { forwardRef } from 'react';
2
+ import '../loaders/Loader.mjs';
3
+ import { InlineLoader } from '../loaders/InlineLoader.mjs';
4
+ import { WrapperStyle, ProportionStyle, ProportionLabelStyle, ProportionProgressStyle, ProportionProgressLineStyle } from './ChartProportionStyles.mjs';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+
7
+ const ChartProportion = /*#__PURE__*/forwardRef((props, ref) => {
8
+ const {
9
+ loading = false,
10
+ onClick,
11
+ children,
12
+ height,
13
+ border,
14
+ data,
15
+ showLabels,
16
+ margin,
17
+ borderSize,
18
+ ...rest
19
+ } = props;
20
+
21
+ if (loading) {
22
+ return /*#__PURE__*/jsx(WrapperStyle, {
23
+ $height: height,
24
+ ref: ref,
25
+ ...rest,
26
+ children: /*#__PURE__*/jsx(InlineLoader, {})
27
+ });
28
+ }
29
+
30
+ return /*#__PURE__*/jsx(WrapperStyle, {
31
+ $height: height,
32
+ ref: ref,
33
+ ...rest,
34
+ children: data.map((item, index) => {
35
+ const {
36
+ color,
37
+ value,
38
+ progress,
39
+ label
40
+ } = item;
41
+ const isShowLabel = showLabels && label;
42
+ return /*#__PURE__*/jsxs(ProportionStyle, {
43
+ $flexGrow: value,
44
+ $backgroundColor: color,
45
+ $border: border,
46
+ $borderSize: borderSize,
47
+ $margin: margin,
48
+ children: [isShowLabel && /*#__PURE__*/jsx(ProportionLabelStyle, {
49
+ children: label
50
+ }), /*#__PURE__*/jsx(ProportionProgressStyle, {
51
+ $progress: progress,
52
+ $backgroundColor: color,
53
+ $border: border,
54
+ $borderSize: borderSize,
55
+ children: progress !== 100 && /*#__PURE__*/jsx(ProportionProgressLineStyle, {})
56
+ })]
57
+ }, index);
58
+ })
59
+ });
60
+ });
61
+ ChartProportion.displayName = 'ChartProportion';
62
+
63
+ export { ChartProportion };
64
+ //# sourceMappingURL=ChartProportion.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartProportion.mjs","sources":["../../../packages/chart-proportion/ChartProportion.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\n\nimport { InlineLoader } from '../loaders/index.js'\n\nimport {\n ProportionStyle,\n WrapperStyle,\n ProportionProgressStyle,\n ProportionProgressLineStyle,\n ProportionLabelStyle,\n} from './ChartProportionStyles.js'\nimport { ChartProportionProps } from './types.js'\n\nexport const ChartProportion = forwardRef(\n (props: ChartProportionProps, ref?: ForwardedRef<HTMLDivElement>) => {\n const {\n loading = false,\n onClick,\n children,\n height,\n border,\n data,\n showLabels,\n margin,\n borderSize,\n ...rest\n } = props\n\n if (loading) {\n return (\n <WrapperStyle $height={height} ref={ref} {...rest}>\n <InlineLoader />\n </WrapperStyle>\n )\n }\n\n return (\n <WrapperStyle $height={height} ref={ref} {...rest}>\n {data.map((item, index) => {\n const { color, value, progress, label } = item\n const isShowLabel = showLabels && label\n\n return (\n <ProportionStyle\n key={index}\n $flexGrow={value}\n $backgroundColor={color}\n $border={border}\n $borderSize={borderSize}\n $margin={margin}\n >\n {isShowLabel && (\n <ProportionLabelStyle>{label}</ProportionLabelStyle>\n )}\n <ProportionProgressStyle\n $progress={progress}\n $backgroundColor={color}\n $border={border}\n $borderSize={borderSize}\n >\n {progress !== 100 && <ProportionProgressLineStyle />}\n </ProportionProgressStyle>\n </ProportionStyle>\n )\n })}\n </WrapperStyle>\n )\n },\n)\nChartProportion.displayName = 'ChartProportion'\n"],"names":["ChartProportion","forwardRef","props","ref","loading","onClick","children","height","border","data","showLabels","margin","borderSize","rest","_jsx","map","item","index","color","value","progress","label","isShowLabel","_jsxs","displayName"],"mappings":";;;;;;AAaO,MAAMA,eAAe,gBAAGC,UAAU,CACvC,CAACC,KAAD,EAA8BC,GAA9B,KAAqE;EACnE,MAAM;AACJC,IAAAA,OAAO,GAAG,KADN;IAEJC,OAFI;IAGJC,QAHI;IAIJC,MAJI;IAKJC,MALI;IAMJC,IANI;IAOJC,UAPI;IAQJC,MARI;IASJC,UATI;IAUJ,GAAGC,IAAAA;AAVC,GAAA,GAWFX,KAXJ,CAAA;;AAaA,EAAA,IAAIE,OAAJ,EAAa;AACX,IAAA,oBACEU,IAAC,YAAD,EAAA;AAAc,MAAA,OAAO,EAAEP,MAAvB;AAA+B,MAAA,GAAG,EAAEJ,GAApC;AAAA,MAAA,GAA6CU,IAA7C;AAAA,MAAA,QAAA,eACEC,IAAC,YAAD,EAAA,EAAA,CAAA;KAFJ,CAAA,CAAA;AAKD,GAAA;;AAED,EAAA,oBACEA,IAAC,YAAD,EAAA;AAAc,IAAA,OAAO,EAAEP,MAAvB;AAA+B,IAAA,GAAG,EAAEJ,GAApC;AAAA,IAAA,GAA6CU,IAA7C;IAAA,QACGJ,EAAAA,IAAI,CAACM,GAAL,CAAS,CAACC,IAAD,EAAOC,KAAP,KAAiB;MACzB,MAAM;QAAEC,KAAF;QAASC,KAAT;QAAgBC,QAAhB;AAA0BC,QAAAA,KAAAA;AAA1B,OAAA,GAAoCL,IAA1C,CAAA;AACA,MAAA,MAAMM,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