@lidofinance/lido-ui 3.30.0 → 3.31.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 (91) 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/cookies-tooltip/cookies-tooltip.js +6 -3
  26. package/dist/cjs/cookies-tooltip/cookies-tooltip.js.map +1 -1
  27. package/dist/cjs/index.js +13 -0
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/esm/chart-line/ChartLine.mjs +88 -0
  30. package/dist/esm/chart-line/ChartLine.mjs.map +1 -0
  31. package/dist/esm/chart-line/ChartLineLabel.mjs +62 -0
  32. package/dist/esm/chart-line/ChartLineLabel.mjs.map +1 -0
  33. package/dist/esm/chart-line/ChartLineStyles.mjs +201 -0
  34. package/dist/esm/chart-line/ChartLineStyles.mjs.map +1 -0
  35. package/dist/esm/chart-line/types.mjs +13 -0
  36. package/dist/esm/chart-line/types.mjs.map +1 -0
  37. package/dist/esm/chart-line/utils/checkViewport.mjs +9 -0
  38. package/dist/esm/chart-line/utils/checkViewport.mjs.map +1 -0
  39. package/dist/esm/chart-line/utils/constants.mjs +6 -0
  40. package/dist/esm/chart-line/utils/constants.mjs.map +1 -0
  41. package/dist/esm/chart-line/utils/getContainerSize.mjs +24 -0
  42. package/dist/esm/chart-line/utils/getContainerSize.mjs.map +1 -0
  43. package/dist/esm/chart-line/utils/handlePositioning.mjs +163 -0
  44. package/dist/esm/chart-line/utils/handlePositioning.mjs.map +1 -0
  45. package/dist/esm/chart-line/utils/processData.mjs +25 -0
  46. package/dist/esm/chart-line/utils/processData.mjs.map +1 -0
  47. package/dist/esm/chart-proportion/ChartProportion.mjs +64 -0
  48. package/dist/esm/chart-proportion/ChartProportion.mjs.map +1 -0
  49. package/dist/esm/chart-proportion/ChartProportionStyles.mjs +124 -0
  50. package/dist/esm/chart-proportion/ChartProportionStyles.mjs.map +1 -0
  51. package/dist/esm/chart-proportion/types.mjs +20 -0
  52. package/dist/esm/chart-proportion/types.mjs.map +1 -0
  53. package/dist/esm/cookies-tooltip/cookies-tooltip.mjs +6 -3
  54. package/dist/esm/cookies-tooltip/cookies-tooltip.mjs.map +1 -1
  55. package/dist/esm/index.mjs +5 -0
  56. package/dist/esm/index.mjs.map +1 -1
  57. package/dist/types/chart-line/ChartLine.d.ts +6 -0
  58. package/dist/types/chart-line/ChartLine.d.ts.map +1 -0
  59. package/dist/types/chart-line/ChartLineLabel.d.ts +14 -0
  60. package/dist/types/chart-line/ChartLineLabel.d.ts.map +1 -0
  61. package/dist/types/chart-line/ChartLineStyles.d.ts +27 -0
  62. package/dist/types/chart-line/ChartLineStyles.d.ts.map +1 -0
  63. package/dist/types/chart-line/index.d.ts +4 -0
  64. package/dist/types/chart-line/index.d.ts.map +1 -0
  65. package/dist/types/chart-line/types.d.ts +43 -0
  66. package/dist/types/chart-line/types.d.ts.map +1 -0
  67. package/dist/types/chart-line/utils/checkViewport.d.ts +2 -0
  68. package/dist/types/chart-line/utils/checkViewport.d.ts.map +1 -0
  69. package/dist/types/chart-line/utils/constants.d.ts +4 -0
  70. package/dist/types/chart-line/utils/constants.d.ts.map +1 -0
  71. package/dist/types/chart-line/utils/getContainerSize.d.ts +5 -0
  72. package/dist/types/chart-line/utils/getContainerSize.d.ts.map +1 -0
  73. package/dist/types/chart-line/utils/handlePositioning.d.ts +9 -0
  74. package/dist/types/chart-line/utils/handlePositioning.d.ts.map +1 -0
  75. package/dist/types/chart-line/utils/index.d.ts +6 -0
  76. package/dist/types/chart-line/utils/index.d.ts.map +1 -0
  77. package/dist/types/chart-line/utils/processData.d.ts +13 -0
  78. package/dist/types/chart-line/utils/processData.d.ts.map +1 -0
  79. package/dist/types/chart-proportion/ChartProportion.d.ts +6 -0
  80. package/dist/types/chart-proportion/ChartProportion.d.ts.map +1 -0
  81. package/dist/types/chart-proportion/ChartProportionStyles.d.ts +20 -0
  82. package/dist/types/chart-proportion/ChartProportionStyles.d.ts.map +1 -0
  83. package/dist/types/chart-proportion/index.d.ts +3 -0
  84. package/dist/types/chart-proportion/index.d.ts.map +1 -0
  85. package/dist/types/chart-proportion/types.d.ts +37 -0
  86. package/dist/types/chart-proportion/types.d.ts.map +1 -0
  87. package/dist/types/cookies-tooltip/cookies-tooltip.d.ts +1 -0
  88. package/dist/types/cookies-tooltip/cookies-tooltip.d.ts.map +1 -1
  89. package/dist/types/index.d.ts +2 -0
  90. package/dist/types/index.d.ts.map +1 -1
  91. package/package.json +1 -1
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const React = require('react');
6
+ require('../loaders/Loader.js');
7
+ const InlineLoader = require('../loaders/InlineLoader.js');
8
+ const ChartLineLabel = require('./ChartLineLabel.js');
9
+ const constants = require('./utils/constants.js');
10
+ const getContainerSize = require('./utils/getContainerSize.js');
11
+ const processData = require('./utils/processData.js');
12
+ const ChartLineStyles = require('./ChartLineStyles.js');
13
+ const jsxRuntime = require('react/jsx-runtime');
14
+
15
+ const ChartLine = /*#__PURE__*/React.forwardRef((props, ref) => {
16
+ const {
17
+ loading = false,
18
+ onClick,
19
+ children,
20
+ height,
21
+ border,
22
+ data,
23
+ showLabels,
24
+ maxValue,
25
+ thresholdType,
26
+ ...rest
27
+ } = props;
28
+ const [containerSize, setContainerSize] = React.useState(null);
29
+ const {
30
+ data: processedData,
31
+ ids
32
+ } = React.useMemo(() => processData.processData(data, maxValue), [data, maxValue]);
33
+ const allPreviousIds = React.useMemo(() => ids.map((_, index) => ids.slice(0, index)), [ids]);
34
+ React.useLayoutEffect(() => {
35
+ if (!showLabels) {
36
+ setContainerSize(null);
37
+ return;
38
+ }
39
+
40
+ const containerSize = getContainerSize.getContainerSize(ids);
41
+ setContainerSize(containerSize);
42
+ }, [ids, showLabels]);
43
+
44
+ if (loading) {
45
+ return /*#__PURE__*/jsxRuntime.jsx(ChartLineStyles.WrapperStyle, {
46
+ $border: border,
47
+ $height: height,
48
+ ref: ref,
49
+ ...rest,
50
+ children: /*#__PURE__*/jsxRuntime.jsx(InlineLoader.InlineLoader, {})
51
+ });
52
+ }
53
+
54
+ return /*#__PURE__*/jsxRuntime.jsx(ChartLineStyles.ContainerStyle, {
55
+ id: constants.CHART_LINE_CONTAINER_ID,
56
+ $alignItems: containerSize?.isCenterAlign ? 'center' : 'flex-start',
57
+ $height: containerSize?.size ?? 0,
58
+ children: /*#__PURE__*/jsxRuntime.jsx(ChartLineStyles.WrapperStyle, {
59
+ $border: border,
60
+ $height: height,
61
+ ref: ref,
62
+ ...rest,
63
+ children: processedData.map((item, index) => {
64
+ const {
65
+ color,
66
+ id,
67
+ width
68
+ } = item;
69
+ const previousIds = allPreviousIds[index];
70
+ return /*#__PURE__*/jsxRuntime.jsx(ChartLineStyles.LineStyle, {
71
+ $width: `${width}%`,
72
+ $backgroundColor: color,
73
+ $zIndex: processedData.length - index,
74
+ $border: border,
75
+ $isFullWidth: width === 100,
76
+ children: /*#__PURE__*/jsxRuntime.jsx(ChartLineLabel.ChartLineLabel, {
77
+ zIndex: processedData.length - index,
78
+ show: showLabels,
79
+ previousIds: previousIds,
80
+ height: height,
81
+ thresholdType: thresholdType,
82
+ ...item
83
+ })
84
+ }, id);
85
+ })
86
+ })
87
+ });
88
+ });
89
+ ChartLine.displayName = 'ChartLine';
90
+
91
+ exports.ChartLine = ChartLine;
92
+ //# sourceMappingURL=ChartLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartLine.js","sources":["../../../packages/chart-line/ChartLine.tsx"],"sourcesContent":["import {\n ForwardedRef,\n forwardRef,\n useMemo,\n useLayoutEffect,\n useState,\n} from 'react'\n\nimport { InlineLoader } from '../loaders/index.js'\n\nimport { ChartLineLabel } from './ChartLineLabel.js'\nimport {\n CHART_LINE_CONTAINER_ID,\n getContainerSize,\n processData,\n} from './utils/index.js'\nimport { ContainerStyle, LineStyle, WrapperStyle } from './ChartLineStyles.js'\nimport { ChartLineProps } from './types.js'\n\nexport const ChartLine = forwardRef(\n (props: ChartLineProps, ref?: ForwardedRef<HTMLDivElement>) => {\n const {\n loading = false,\n onClick,\n children,\n height,\n border,\n data,\n showLabels,\n maxValue,\n thresholdType,\n ...rest\n } = props\n\n const [containerSize, setContainerSize] = useState<{\n size: number\n isCenterAlign: boolean\n } | null>(null)\n\n const { data: processedData, ids } = useMemo(\n () => processData(data, maxValue),\n [data, maxValue],\n )\n\n const allPreviousIds = useMemo(\n () => ids.map((_, index) => ids.slice(0, index)),\n [ids],\n )\n\n useLayoutEffect(() => {\n if (!showLabels) {\n setContainerSize(null)\n return\n }\n const containerSize = getContainerSize(ids)\n setContainerSize(containerSize)\n }, [ids, showLabels])\n\n if (loading) {\n return (\n <WrapperStyle $border={border} $height={height} ref={ref} {...rest}>\n <InlineLoader />\n </WrapperStyle>\n )\n }\n\n return (\n <ContainerStyle\n id={CHART_LINE_CONTAINER_ID}\n $alignItems={containerSize?.isCenterAlign ? 'center' : 'flex-start'}\n $height={containerSize?.size ?? 0}\n >\n <WrapperStyle $border={border} $height={height} ref={ref} {...rest}>\n {processedData.map((item, index) => {\n const { color, id, width } = item\n const previousIds = allPreviousIds[index]\n\n return (\n <LineStyle\n key={id}\n $width={`${width}%`}\n $backgroundColor={color}\n $zIndex={processedData.length - index}\n $border={border}\n $isFullWidth={width === 100}\n >\n <ChartLineLabel\n zIndex={processedData.length - index}\n show={showLabels}\n previousIds={previousIds}\n height={height}\n thresholdType={thresholdType}\n {...item}\n />\n </LineStyle>\n )\n })}\n </WrapperStyle>\n </ContainerStyle>\n )\n },\n)\nChartLine.displayName = 'ChartLine'\n"],"names":["ChartLine","forwardRef","props","ref","loading","onClick","children","height","border","data","showLabels","maxValue","thresholdType","rest","containerSize","setContainerSize","useState","processedData","ids","useMemo","processData","allPreviousIds","map","_","index","slice","useLayoutEffect","getContainerSize","_jsx","WrapperStyle","InlineLoader","ContainerStyle","CHART_LINE_CONTAINER_ID","isCenterAlign","size","item","color","id","width","previousIds","LineStyle","length","ChartLineLabel","displayName"],"mappings":";;;;;;;;;;;;;;AAmBO,MAAMA,SAAS,gBAAGC,gBAAU,CACjC,CAACC,KAAD,EAAwBC,GAAxB,KAA+D;EAC7D,MAAM;AACJC,IAAAA,OAAO,GAAG,KADN;IAEJC,OAFI;IAGJC,QAHI;IAIJC,MAJI;IAKJC,MALI;IAMJC,IANI;IAOJC,UAPI;IAQJC,QARI;IASJC,aATI;IAUJ,GAAGC,IAAAA;AAVC,GAAA,GAWF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 'Module' });
4
+
5
+ const React = require('react');
6
+ const types = require('./types.js');
7
+ const ChartLineStyles = require('./ChartLineStyles.js');
8
+ const handlePositioning = require('./utils/handlePositioning.js');
9
+ const jsxRuntime = require('react/jsx-runtime');
10
+
11
+ const ChartLineLabel = /*#__PURE__*/React.forwardRef((props, ref) => {
12
+ const {
13
+ previousIds,
14
+ id,
15
+ color,
16
+ zIndex,
17
+ show,
18
+ labelPosition,
19
+ thresholdType,
20
+ height,
21
+ threshold,
22
+ ...rest
23
+ } = props;
24
+ React.useLayoutEffect(() => {
25
+ if (!show) return;
26
+
27
+ if (thresholdType !== types.ChartLineThresholdType.flag) {
28
+ handlePositioning.handlePositioning({
29
+ previousIds,
30
+ id,
31
+ reset: true
32
+ });
33
+ } else {
34
+ handlePositioning.handlePositioning({
35
+ previousIds,
36
+ id
37
+ });
38
+ }
39
+ }, [previousIds, id, show, thresholdType]);
40
+ if (!show) return null;
41
+ const backgroundColor = threshold.color || color;
42
+ const content = threshold.descriptionElement || threshold.description;
43
+ return /*#__PURE__*/jsxRuntime.jsx(ChartLineStyles.ThresholdStyle, {
44
+ ref: ref,
45
+ id: id,
46
+ "data-label-position": labelPosition,
47
+ $labelPosition: labelPosition,
48
+ $thresholdType: thresholdType,
49
+ $height: height,
50
+ $backgroundColor: backgroundColor,
51
+ $zIndex: zIndex,
52
+ ...rest,
53
+ children: thresholdType === types.ChartLineThresholdType.flag && /*#__PURE__*/jsxRuntime.jsx(ChartLineStyles.ThresholdLabelStyle, {
54
+ style: {
55
+ backgroundColor
56
+ },
57
+ id: `${id}-description`,
58
+ $labelPosition: labelPosition,
59
+ children: content
60
+ })
61
+ });
62
+ });
63
+ ChartLineLabel.displayName = 'ChartLineLabel';
64
+
65
+ exports.ChartLineLabel = ChartLineLabel;
66
+ //# sourceMappingURL=ChartLineLabel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartLineLabel.js","sources":["../../../packages/chart-line/ChartLineLabel.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { ChartLineLabelProps, ChartLineThresholdType } from './types.js'\nimport { ThresholdLabelStyle, ThresholdStyle } from './ChartLineStyles.js'\nimport { handlePositioning } from './utils/index.js'\n\nexport const ChartLineLabel = forwardRef(\n (props: ChartLineLabelProps, ref?: ForwardedRef<HTMLDivElement>) => {\n const {\n previousIds,\n id,\n color,\n zIndex,\n show,\n labelPosition,\n thresholdType,\n height,\n threshold,\n ...rest\n } = props\n\n useLayoutEffect(() => {\n if (!show) return\n if (thresholdType !== ChartLineThresholdType.flag) {\n handlePositioning({ previousIds, id, reset: true })\n } else {\n handlePositioning({ previousIds, id })\n }\n }, [previousIds, id, show, thresholdType])\n\n if (!show) return null\n\n const backgroundColor = threshold.color || color\n const content = threshold.descriptionElement || threshold.description\n\n return (\n <ThresholdStyle\n ref={ref}\n id={id}\n data-label-position={labelPosition}\n $labelPosition={labelPosition}\n $thresholdType={thresholdType}\n $height={height}\n $backgroundColor={backgroundColor}\n $zIndex={zIndex}\n {...rest}\n >\n {thresholdType === ChartLineThresholdType.flag && (\n <ThresholdLabelStyle\n style={{ backgroundColor }}\n id={`${id}-description`}\n $labelPosition={labelPosition}\n >\n {content}\n </ThresholdLabelStyle>\n )}\n </ThresholdStyle>\n )\n },\n)\nChartLineLabel.displayName = 'ChartLineLabel'\n"],"names":["ChartLineLabel","forwardRef","props","ref","previousIds","id","color","zIndex","show","labelPosition","thresholdType","height","threshold","rest","useLayoutEffect","ChartLineThresholdType","flag","handlePositioning","reset","backgroundColor","content","descriptionElement","description","_jsx","ThresholdStyle","ThresholdLabelStyle","displayName"],"mappings":";;;;;;;;;;AAMO,MAAMA,cAAc,gBAAGC,gBAAU,CACtC,CAACC,KAAD,EAA6BC,GAA7B,KAAoE;EAClE,MAAM;IACJC,WADI;IAEJC,EAFI;IAGJC,KAHI;IAIJC,MAJI;IAKJC,IALI;IAMJC,aANI;IAOJC,aAPI;IAQJC,MARI;IASJC,SATI;IAU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AAEI,aAHlB;MAAA,QAKGW,EAAAA,OAAAA;AALH,KAAA,CAAA;GAbN,CAAA,CAAA;AAuBD,CApDqC,EAAjC;AAsDPpB,cAAc,CAAC0B,WAAf,GAA6B,gBAA7B;;;;"}
@@ -0,0 +1,209 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const styledComponentsWrapper = require('../utils/styled-components-wrapper.js');
6
+ const types = require('./types.js');
7
+ const _styled = require('styled-components');
8
+
9
+ const ContainerStyle = styledComponentsWrapper.default.div`
10
+ display: flex;
11
+ width: 100%;
12
+ align-items: ${_ref => {
13
+ let {
14
+ $alignItems
15
+ } = _ref;
16
+ return $alignItems;
17
+ }};
18
+ height: ${_ref2 => {
19
+ let {
20
+ $height
21
+ } = _ref2;
22
+ return $height;
23
+ }}px;
24
+ `;
25
+ const WrapperStyle = styledComponentsWrapper.default.div`
26
+ display: flex;
27
+ width: 100%;
28
+ height: ${_ref3 => {
29
+ let {
30
+ $height
31
+ } = _ref3;
32
+ return $height;
33
+ }}px;
34
+ background: rgb(19 18 23 / 8%);
35
+ position: relative;
36
+
37
+ ${_ref4 => {
38
+ let {
39
+ $border
40
+ } = _ref4;
41
+
42
+ if ($border === types.ChartLineBorderType.rounded) {
43
+ return _styled.css`
44
+ border-radius: 4px;
45
+ `;
46
+ }
47
+
48
+ return _styled.css``;
49
+ }}
50
+ `;
51
+ const ThresholdStyle = styledComponentsWrapper.default.div`
52
+ height: ${_ref5 => {
53
+ let {
54
+ $height
55
+ } = _ref5;
56
+ return $height + 38;
57
+ }}px;
58
+ width: 5px;
59
+ background-color: ${_ref6 => {
60
+ let {
61
+ $backgroundColor
62
+ } = _ref6;
63
+ return $backgroundColor;
64
+ }};
65
+ z-index: ${_ref7 => {
66
+ let {
67
+ $zIndex
68
+ } = _ref7;
69
+ return $zIndex;
70
+ }};
71
+ position: absolute;
72
+ border-radius: 3px;
73
+ top: -2px;
74
+ right: -2px;
75
+
76
+ ${_ref8 => {
77
+ let {
78
+ $labelPosition
79
+ } = _ref8;
80
+
81
+ if ($labelPosition === 'top') {
82
+ return _styled.css`
83
+ bottom: -2px;
84
+ top: unset;
85
+ `;
86
+ }
87
+
88
+ return _styled.css``;
89
+ }}
90
+
91
+ ${_ref9 => {
92
+ let {
93
+ $thresholdType,
94
+ $height
95
+ } = _ref9;
96
+
97
+ if ($thresholdType === types.ChartLineThresholdType.dash) {
98
+ return _styled.css`
99
+ height: ${$height + 4}px;
100
+ top: -2px;
101
+ `;
102
+ }
103
+
104
+ return _styled.css``;
105
+ }}
106
+ `;
107
+ const ThresholdLabelStyle = styledComponentsWrapper.default.div`
108
+ color: ${_ref10 => {
109
+ let {
110
+ theme
111
+ } = _ref10;
112
+ return theme.colors.foreground;
113
+ }};
114
+ font-size: 12px;
115
+ font-weight: 400;
116
+ line-height: 20px;
117
+ padding: 4px 8px;
118
+ position: absolute;
119
+ bottom: -2px;
120
+ right: 0;
121
+ border-radius: 4px;
122
+ white-space: nowrap;
123
+ box-sizing: border-box;
124
+ max-height: 28px;
125
+
126
+ ${_ref11 => {
127
+ let {
128
+ $labelPosition
129
+ } = _ref11;
130
+
131
+ if ($labelPosition === 'top') {
132
+ return _styled.css`
133
+ top: -2px;
134
+ bottom: unset;
135
+ `;
136
+ }
137
+
138
+ return _styled.css``;
139
+ }};
140
+ `;
141
+ const LineStyle = styledComponentsWrapper.default.div`
142
+ background-color: ${_ref12 => {
143
+ let {
144
+ $backgroundColor
145
+ } = _ref12;
146
+ return $backgroundColor ? $backgroundColor : 'transparent';
147
+ }};
148
+ z-index: ${_ref13 => {
149
+ let {
150
+ $zIndex
151
+ } = _ref13;
152
+ return $zIndex;
153
+ }};
154
+ width: ${_ref14 => {
155
+ let {
156
+ $width
157
+ } = _ref14;
158
+ return $width;
159
+ }};
160
+ height: 100%;
161
+ position: absolute;
162
+ top: 0;
163
+ left: 0;
164
+ bottom: 0;
165
+ border-right: 1px solid ${_ref15 => {
166
+ let {
167
+ theme
168
+ } = _ref15;
169
+ return theme.colors.background;
170
+ }};
171
+
172
+ ${_ref16 => {
173
+ let {
174
+ $border
175
+ } = _ref16;
176
+
177
+ if ($border === types.ChartLineBorderType.rounded) {
178
+ return _styled.css`
179
+ border-radius: 4px 0 0 4px;
180
+ `;
181
+ }
182
+
183
+ return _styled.css``;
184
+ }}
185
+
186
+ &:last-child {
187
+ ${_ref17 => {
188
+ let {
189
+ $border,
190
+ $isFullWidth
191
+ } = _ref17;
192
+
193
+ if ($border === types.ChartLineBorderType.rounded && $isFullWidth) {
194
+ return _styled.css`
195
+ border-radius: 4px;
196
+ `;
197
+ }
198
+
199
+ return _styled.css``;
200
+ }}
201
+ }
202
+ `;
203
+
204
+ exports.ContainerStyle = ContainerStyle;
205
+ exports.LineStyle = LineStyle;
206
+ exports.ThresholdLabelStyle = ThresholdLabelStyle;
207
+ exports.ThresholdStyle = ThresholdStyle;
208
+ exports.WrapperStyle = WrapperStyle;
209
+ //# sourceMappingURL=ChartLineStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartLineStyles.js","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,+BAAM,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,+BAAM,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,EAAI,KAAiB,IAAA;EAAA,IAAhB;AAAEE,IAAAA,OAAAA;GAAc,GAAA,KAAA,CAAA;;AACjB,EAAA,IAAIA,OAAO,KAAKC,yBAAmB,CAACC,OAApC,EAA6C;AAC3C,IAAA,OAAOC,WAAI,CAAA;AACjB;AACA,MAFM,CAAA,CAAA;AAGD,GAAA;;AACD,EAAA,OAAOA,WAAI,CAAX,CAAA,CAAA;AACD,CAAC,CAAA;AACJ,EAlBO;AAoBMC,MAAAA,cAAc,GAAGT,+BAAM,CAACC,GAMlC,CAAA;AACH,UAAY,EAAA,KAAA,IAAA;EAAA,IAAC;AAAEE,IAAAA,OAAAA;GAAH,GAAA,KAAA,CAAA;EAAA,OAAiBA,OAAO,GAAG,EAA3B,CAAA;AAAA,CAA8B,CAAA;AAC1C;AACA,oBAAsB,EAAA,KAAA,IAAA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,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,yBAAmB,CAACC,OAAhC,IAA2CgB,YAA/C,EAA6D;AAC3D,IAAA,OAAOf,WAAI,CAAA;AACnB;AACA,QAFQ,CAAA,CAAA;AAGD,GAAA;;AACD,EAAA,OAAOA,WAAI,CAAX,CAAA,CAAA;AACD,CAAC,CAAA;AACN;AACA;;;;;;;;"}
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ let ChartLineThresholdType = /*#__PURE__*/function (ChartLineThresholdType) {
6
+ ChartLineThresholdType["dash"] = "dash";
7
+ ChartLineThresholdType["flag"] = "flag";
8
+ return ChartLineThresholdType;
9
+ }({});
10
+ let ChartLineBorderType = /*#__PURE__*/function (ChartLineBorderType) {
11
+ ChartLineBorderType["rounded"] = "rounded";
12
+ ChartLineBorderType["square"] = "square";
13
+ return ChartLineBorderType;
14
+ }({});
15
+
16
+ exports.ChartLineBorderType = ChartLineBorderType;
17
+ exports.ChartLineThresholdType = ChartLineThresholdType;
18
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","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,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const constants = require('./constants.js');
6
+
7
+ const checkViewportOverflow = (position, elemSize, viewportSize) => {
8
+ const invertPosition = viewportSize - position;
9
+ return position + elemSize + constants.VIEWPORT_MARGIN > viewportSize && invertPosition + elemSize + constants.VIEWPORT_MARGIN < viewportSize;
10
+ };
11
+
12
+ exports.checkViewportOverflow = checkViewportOverflow;
13
+ //# sourceMappingURL=checkViewport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkViewport.js","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,yBAAtB,GAAwCF,YAAxC,IACAC,cAAc,GAAGF,QAAjB,GAA4BG,yBAA5B,GAA8CF,YAFhD,CAAA;AAID;;;;"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const VIEWPORT_MARGIN = 8;
6
+ const CHART_LINE_CONTAINER_ID = 'chart-line-container';
7
+ const LABEL_HEIGHT_INCREASE = 36;
8
+
9
+ exports.CHART_LINE_CONTAINER_ID = CHART_LINE_CONTAINER_ID;
10
+ exports.LABEL_HEIGHT_INCREASE = LABEL_HEIGHT_INCREASE;
11
+ exports.VIEWPORT_MARGIN = VIEWPORT_MARGIN;
12
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","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,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ // get max height between all elements
6
+ const getContainerSize = elementIds => {
7
+ if (!elementIds.length) return null;
8
+ const isCenterAlign = elementIds.every(id => {
9
+ const element = document.getElementById(id);
10
+ return element?.dataset.labelPosition === 'top' || element?.dataset.labelPosition === 'bottom';
11
+ });
12
+ const size = elementIds.reduce((acc, id) => {
13
+ const element = document.getElementById(id);
14
+
15
+ if (element && element.offsetHeight > 0) {
16
+ return Math.max(acc, element.offsetHeight);
17
+ }
18
+
19
+ return acc;
20
+ }, 0);
21
+ return {
22
+ size: isCenterAlign ? size * 2 : size,
23
+ isCenterAlign
24
+ };
25
+ };
26
+
27
+ exports.getContainerSize = getContainerSize;
28
+ //# sourceMappingURL=getContainerSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getContainerSize.js","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,168 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const checkViewport = require('./checkViewport.js');
6
+ const constants = require('./constants.js');
7
+
8
+ // Get elements and their rects in one go
9
+ const getElementData = id => {
10
+ const threshold = document.getElementById(id);
11
+ const label = document.getElementById(`${id}-description`);
12
+ if (!threshold || !label) return null;
13
+ const container = document.getElementById(constants.CHART_LINE_CONTAINER_ID);
14
+ if (!container) return null; // Temporarily reset transform to get original positions
15
+
16
+ const originalTransform = label.style.transform;
17
+ label.style.removeProperty('transform');
18
+ const thresholdRect = threshold.getBoundingClientRect();
19
+ const labelRect = label.getBoundingClientRect();
20
+ const containerRect = container.getBoundingClientRect(); // Restore transform if it existed
21
+
22
+ if (originalTransform) {
23
+ label.style.setProperty('transform', originalTransform);
24
+ }
25
+
26
+ return {
27
+ elements: {
28
+ threshold,
29
+ label
30
+ },
31
+ rects: {
32
+ threshold: thresholdRect,
33
+ label: labelRect
34
+ },
35
+ containerRect
36
+ };
37
+ }; // Calculate offset needed to keep label within viewport bounds
38
+
39
+
40
+ const calculateLabelOffset = (thresholdRect, labelRect, containerRect, isInverted) => {
41
+ if (isInverted) {
42
+ // Label positioned with left: 0 (extends right from threshold)
43
+ // Check if label extends beyond container right boundary
44
+ const labelRightEdge = thresholdRect.left + labelRect.width;
45
+ const containerRightEdge = containerRect.right - constants.VIEWPORT_MARGIN;
46
+
47
+ if (labelRightEdge > containerRightEdge) {
48
+ return labelRightEdge - containerRightEdge;
49
+ }
50
+ } else {
51
+ // Label positioned with right: 0 (extends left from threshold - default behavior)
52
+ // Check if label left edge goes beyond container left boundary
53
+ const labelLeftEdge = thresholdRect.right - labelRect.width;
54
+ const containerLeftEdge = containerRect.left + constants.VIEWPORT_MARGIN;
55
+
56
+ if (labelLeftEdge < containerLeftEdge) {
57
+ return containerLeftEdge - labelLeftEdge;
58
+ }
59
+ }
60
+
61
+ return 0;
62
+ }; // Calculate if flag should be inverted based on viewport overflow
63
+
64
+
65
+ const shouldInvertLabel = (thresholdRect, labelRect, containerRect, viewportWidth) => {
66
+ const position = containerRect.right - thresholdRect.right;
67
+ const isInverted = checkViewport.checkViewportOverflow(position, labelRect.width, viewportWidth);
68
+ return isInverted;
69
+ };
70
+
71
+ const resetThresholdHeight = threshold => {
72
+ if (!threshold) return;
73
+ threshold.style.removeProperty('height');
74
+ }; // Apply label positioning based on inversion
75
+
76
+ const applyLabelPosition = (label, isInverted) => {
77
+ if (isInverted) {
78
+ label.style.setProperty('left', '0px');
79
+ label.style.setProperty('right', 'auto');
80
+ label.dataset.isInverted = 'true';
81
+ } else {
82
+ label.style.setProperty('right', '0px');
83
+ label.style.setProperty('left', 'auto');
84
+ label.dataset.isInverted = 'false';
85
+ }
86
+ }; // Calculate distance between two thresholds considering label inversion
87
+
88
+
89
+ const calculateFlagDistance = (currentRect, previousRect, currentLabelRect, isPreviousInverted) => {
90
+ return isPreviousInverted ? currentRect.left - previousRect.left - currentLabelRect.width : currentRect.left - previousRect.left;
91
+ }; // Get first previous threshold on the same position as the current threshold
92
+
93
+
94
+ const getPreviousThreshold = (previousIds, currentId) => {
95
+ const currentElement = document.getElementById(currentId);
96
+ if (!currentElement) return null;
97
+ const currentLabelPosition = currentElement.dataset.labelPosition;
98
+
99
+ for (let i = previousIds.length - 1; i >= 0; i--) {
100
+ const id = previousIds[i];
101
+ const element = document.getElementById(id);
102
+
103
+ if (element?.dataset.labelPosition === currentLabelPosition) {
104
+ return id;
105
+ }
106
+ }
107
+
108
+ return null;
109
+ };
110
+
111
+ const handlePositioning = props => {
112
+ const {
113
+ previousIds = [],
114
+ id,
115
+ reset
116
+ } = props; // Check if we are in browser (not SSR)
117
+
118
+ if (typeof window === 'undefined') return;
119
+
120
+ if (reset) {
121
+ resetThresholdHeight(document.getElementById(id));
122
+ return;
123
+ }
124
+
125
+ const currentData = getElementData(id);
126
+ if (!currentData) return;
127
+ const {
128
+ elements: currentElements,
129
+ rects: currentRects,
130
+ containerRect
131
+ } = currentData; // Calculate inversion for current label using container width
132
+
133
+ const currentIsInverted = shouldInvertLabel(currentRects.threshold, currentRects.label, containerRect, containerRect.width); // Apply positioning for current label
134
+
135
+ applyLabelPosition(currentElements.label, currentIsInverted); // Calculate offset needed to keep label within bounds
136
+
137
+ const currentOffset = calculateLabelOffset(currentRects.threshold, currentRects.label, containerRect, currentIsInverted); // Apply offset if needed
138
+
139
+ if (currentOffset > 0) {
140
+ const direction = currentIsInverted ? -currentOffset : currentOffset;
141
+ currentElements.label.style.setProperty('transform', `translateX(${direction}px)`);
142
+ } else {
143
+ currentElements.label.style.removeProperty('transform');
144
+ } // Handle previous threshold positioning if exists
145
+
146
+
147
+ const previousId = getPreviousThreshold(previousIds, id);
148
+ if (!previousId) return;
149
+ const previousData = getElementData(previousId);
150
+ if (!previousData) return;
151
+ const {
152
+ rects: previousRects,
153
+ elements: previousElements
154
+ } = previousData; // Calculate inversion for previous flag using window width (as in original)
155
+
156
+ const previousIsInverted = previousElements.label.dataset.isInverted === 'true'; // Calculate distance and adjust height if needed
157
+
158
+ const distance = calculateFlagDistance(currentRects.threshold, previousRects.threshold, currentRects.label, previousIsInverted);
159
+
160
+ if (distance < currentRects.label.width) {
161
+ const newHeight = previousRects.threshold.height + constants.LABEL_HEIGHT_INCREASE;
162
+ currentElements.threshold.style.setProperty('height', `${newHeight}px`);
163
+ }
164
+ };
165
+
166
+ exports.handlePositioning = handlePositioning;
167
+ exports.resetThresholdHeight = resetThresholdHeight;
168
+ //# sourceMappingURL=handlePositioning.js.map