@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 @@
1
+ {"version":3,"file":"handlePositioning.js","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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,EAAyC;IACvC,MAAM2C,SAAS,GAAGJ,aAAa,CAAC5D,SAAd,CAAwBiE,MAAxB,GAAiCC,+BAAnD,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,29 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const processData = (data, maxValue) => {
6
+ // Calculate maxValue once if not provided
7
+ const calculatedMaxValue = maxValue ?? Math.max(...data.map(item => item.threshold.value));
8
+ return data.sort((a, b) => a.threshold.value - b.threshold.value).reduce((acc, item, index) => {
9
+ const {
10
+ threshold
11
+ } = item;
12
+ const id = `chart-percent-line-group-${index}-${threshold.label}`;
13
+ const width = threshold.value / (calculatedMaxValue / 100);
14
+ const processedItem = { ...item,
15
+ id,
16
+ index,
17
+ width
18
+ };
19
+ acc.data.push(processedItem);
20
+ acc.ids.push(id);
21
+ return acc;
22
+ }, {
23
+ data: [],
24
+ ids: []
25
+ });
26
+ };
27
+
28
+ exports.processData = processData;
29
+ //# sourceMappingURL=processData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processData.js","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,68 @@
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 ChartProportionStyles = require('./ChartProportionStyles.js');
9
+ const jsxRuntime = require('react/jsx-runtime');
10
+
11
+ const ChartProportion = /*#__PURE__*/React.forwardRef((props, ref) => {
12
+ const {
13
+ loading = false,
14
+ onClick,
15
+ children,
16
+ height,
17
+ border,
18
+ data,
19
+ showLabels,
20
+ margin,
21
+ borderSize,
22
+ ...rest
23
+ } = props;
24
+
25
+ if (loading) {
26
+ return /*#__PURE__*/jsxRuntime.jsx(ChartProportionStyles.WrapperStyle, {
27
+ $height: height,
28
+ ref: ref,
29
+ ...rest,
30
+ children: /*#__PURE__*/jsxRuntime.jsx(InlineLoader.InlineLoader, {})
31
+ });
32
+ }
33
+
34
+ return /*#__PURE__*/jsxRuntime.jsx(ChartProportionStyles.WrapperStyle, {
35
+ $height: height,
36
+ ref: ref,
37
+ ...rest,
38
+ children: data.map((item, index) => {
39
+ const {
40
+ color,
41
+ value,
42
+ progress,
43
+ label
44
+ } = item;
45
+ const isShowLabel = showLabels && label;
46
+ return /*#__PURE__*/jsxRuntime.jsxs(ChartProportionStyles.ProportionStyle, {
47
+ $flexGrow: value,
48
+ $backgroundColor: color,
49
+ $border: border,
50
+ $borderSize: borderSize,
51
+ $margin: margin,
52
+ children: [isShowLabel && /*#__PURE__*/jsxRuntime.jsx(ChartProportionStyles.ProportionLabelStyle, {
53
+ children: label
54
+ }), /*#__PURE__*/jsxRuntime.jsx(ChartProportionStyles.ProportionProgressStyle, {
55
+ $progress: progress,
56
+ $backgroundColor: color,
57
+ $border: border,
58
+ $borderSize: borderSize,
59
+ children: progress !== 100 && /*#__PURE__*/jsxRuntime.jsx(ChartProportionStyles.ProportionProgressLineStyle, {})
60
+ })]
61
+ }, index);
62
+ })
63
+ });
64
+ });
65
+ ChartProportion.displayName = 'ChartProportion';
66
+
67
+ exports.ChartProportion = ChartProportion;
68
+ //# sourceMappingURL=ChartProportion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartProportion.js","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","WrapperStyle","InlineLoader","map","item","index","color","value","progress","label","isShowLabel","_jsxs","ProportionStyle","ProportionLabelStyle","ProportionProgressStyle","ProportionProgressLineStyle","displayName"],"mappings":";;;;;;;;;;AAaO,MAAMA,eAAe,gBAAGC,gBAAU,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,eAACC,kCAAD,EAAA;AAAc,MAAA,OAAO,EAAER,MAAvB;AAA+B,MAAA,GAAG,EAAEJ,GAApC;AAAA,MAAA,GAA6CU,IAA7C;AAAA,MAAA,QAAA,eACEC,eAACE,yBAAD,EAAA,EAAA,CAAA;KAFJ,CAAA,CAAA;AAKD,GAAA;;AAED,EAAA,oBACEF,eAACC,kCAAD,EAAA;AAAc,IAAA,OAAO,EAAER,MAAvB;AAA+B,IAAA,GAAG,EAAEJ,GAApC;AAAA,IAAA,GAA6CU,IAA7C;IAAA,QACGJ,EAAAA,IAAI,CAACQ,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,WAAW,GAAGd,UAAU,IAAIa,KAAlC,CAAA;AAEA,MAAA,oBACEE,gBAACC,qCAAD,EAAA;AAEE,QAAA,SAAS,EAAEL,KAFb;AAGE,QAAA,gBAAgB,EAAED,KAHpB;AAIE,QAAA,OAAO,EAAEZ,MAJX;AAKE,QAAA,WAAW,EAAEI,UALf;AAME,QAAA,OAAO,EAAED,MANX;QAAA,QAQGa,EAAAA,CAAAA,WAAW,iBACVV,cAAA,CAACa,0CAAD,EAAA;UAAA,QAAuBJ,EAAAA,KAAAA;SAT3B,CAAA,eAWET,eAACc,6CAAD,EAAA;AACE,UAAA,SAAS,EAAEN,QADb;AAEE,UAAA,gBAAgB,EAAEF,KAFpB;AAGE,UAAA,OAAO,EAAEZ,MAHX;AAIE,UAAA,WAAW,EAAEI,UAJf;AAAA,UAAA,QAAA,EAMGU,QAAQ,KAAK,GAAb,iBAAoBR,eAACe,iDAAD,EAAA,EAAA,CAAA;SAjBzB,CAAA,CAAA;AAAA,OAAA,EACOV,KADP,CADF,CAAA;KAJD,CAAA;GAFL,CAAA,CAAA;AA+BD,CAtDsC,EAAlC;AAwDPnB,eAAe,CAAC8B,WAAhB,GAA8B,iBAA9B;;;;"}
@@ -0,0 +1,132 @@
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 WrapperStyle = styledComponentsWrapper.default.div`
10
+ display: flex;
11
+ width: 100%;
12
+ height: ${_ref => {
13
+ let {
14
+ $height
15
+ } = _ref;
16
+ return $height;
17
+ }}px;
18
+ position: relative;
19
+ `;
20
+ const borderSizes = {
21
+ sm: '2px',
22
+ md: '4px',
23
+ lg: '8px'
24
+ };
25
+ const marginSizes = {
26
+ sm: '2px',
27
+ md: '4px',
28
+ lg: '8px'
29
+ };
30
+ const ProportionStyle = styledComponentsWrapper.default.div`
31
+ background: rgb(19 18 23 / 4%);
32
+ flex-grow: ${_ref2 => {
33
+ let {
34
+ $flexGrow
35
+ } = _ref2;
36
+ return $flexGrow;
37
+ }};
38
+ height: 100%;
39
+ position: relative;
40
+
41
+ ${_ref3 => {
42
+ let {
43
+ $border,
44
+ $borderSize
45
+ } = _ref3;
46
+
47
+ if ($border === types.ChartProportionBorderType.rounded) {
48
+ return _styled.css`
49
+ border-radius: ${borderSizes[$borderSize]};
50
+ `;
51
+ }
52
+
53
+ return _styled.css``;
54
+ }}
55
+
56
+ &:not(:last-child) {
57
+ ${_ref4 => {
58
+ let {
59
+ $margin
60
+ } = _ref4;
61
+ return _styled.css`
62
+ margin-right: ${marginSizes[$margin]};
63
+ `;
64
+ }}
65
+ }
66
+ `;
67
+ const ProportionProgressStyle = styledComponentsWrapper.default.div`
68
+ background-color: ${_ref5 => {
69
+ let {
70
+ $backgroundColor
71
+ } = _ref5;
72
+ return $backgroundColor ? $backgroundColor : 'transparent';
73
+ }};
74
+ height: 100%;
75
+ width: ${_ref6 => {
76
+ let {
77
+ $progress
78
+ } = _ref6;
79
+ return $progress;
80
+ }}%;
81
+ position: relative;
82
+
83
+ ${_ref7 => {
84
+ let {
85
+ $border,
86
+ $borderSize,
87
+ $progress
88
+ } = _ref7;
89
+
90
+ if ($border === types.ChartProportionBorderType.rounded) {
91
+ if ($progress !== 100) {
92
+ return _styled.css`
93
+ border-radius: ${borderSizes[$borderSize]} 0 0
94
+ ${borderSizes[$borderSize]};
95
+ `;
96
+ }
97
+
98
+ return _styled.css`
99
+ border-radius: ${borderSizes[$borderSize]};
100
+ `;
101
+ }
102
+
103
+ return _styled.css``;
104
+ }}
105
+ `;
106
+ const ProportionProgressLineStyle = styledComponentsWrapper.default.div`
107
+ position: absolute;
108
+ right: 0;
109
+ background-color: #273852;
110
+ height: calc(100% + 2px);
111
+ top: -1px;
112
+ bottom: -1px;
113
+ width: 2px;
114
+ margin-left: auto;
115
+ border-radius: 2px;
116
+ `;
117
+ const ProportionLabelStyle = styledComponentsWrapper.default.div`
118
+ position: absolute;
119
+ top: -22px;
120
+ right: 0;
121
+ white-space: nowrap;
122
+ font-size: 10px;
123
+ line-height: 20px;
124
+ color: #7a8aa0;
125
+ `;
126
+
127
+ exports.ProportionLabelStyle = ProportionLabelStyle;
128
+ exports.ProportionProgressLineStyle = ProportionProgressLineStyle;
129
+ exports.ProportionProgressStyle = ProportionProgressStyle;
130
+ exports.ProportionStyle = ProportionStyle;
131
+ exports.WrapperStyle = WrapperStyle;
132
+ //# sourceMappingURL=ChartProportionStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartProportionStyles.js","sources":["../../../packages/chart-proportion/ChartProportionStyles.tsx"],"sourcesContent":["import styled, { css } from '../utils/styled-components-wrapper.js'\nimport {\n ChartProportionBorderSize,\n ChartProportionBorderType,\n MarginSize,\n} from './types.js'\n\nexport const WrapperStyle = styled.div<{\n $height: number\n}>`\n display: flex;\n width: 100%;\n height: ${({ $height }) => $height}px;\n position: relative;\n`\n\nconst borderSizes = {\n sm: '2px',\n md: '4px',\n lg: '8px',\n}\n\nconst marginSizes = {\n sm: '2px',\n md: '4px',\n lg: '8px',\n}\n\nexport const ProportionStyle = styled.div<{\n $border: ChartProportionBorderType\n $borderSize: ChartProportionBorderSize\n $margin: MarginSize\n $flexGrow: number\n $backgroundColor?: string\n}>`\n background: rgb(19 18 23 / 4%);\n flex-grow: ${({ $flexGrow }) => $flexGrow};\n height: 100%;\n position: relative;\n\n ${({ $border, $borderSize }) => {\n if ($border === ChartProportionBorderType.rounded) {\n return css`\n border-radius: ${borderSizes[$borderSize]};\n `\n }\n return css``\n }}\n\n &:not(:last-child) {\n ${({ $margin }) => {\n return css`\n margin-right: ${marginSizes[$margin]};\n `\n }}\n }\n`\n\nexport const ProportionProgressStyle = styled.div<{\n $progress: number\n $backgroundColor?: string\n $border: ChartProportionBorderType\n $borderSize: ChartProportionBorderSize\n}>`\n background-color: ${({ $backgroundColor }) =>\n $backgroundColor ? $backgroundColor : 'transparent'};\n height: 100%;\n width: ${({ $progress }) => $progress}%;\n position: relative;\n\n ${({ $border, $borderSize, $progress }) => {\n if ($border === ChartProportionBorderType.rounded) {\n if ($progress !== 100) {\n return css`\n border-radius: ${borderSizes[$borderSize]} 0 0\n ${borderSizes[$borderSize]};\n `\n }\n return css`\n border-radius: ${borderSizes[$borderSize]};\n `\n }\n\n return css``\n }}\n`\n\nexport const ProportionProgressLineStyle = styled.div`\n position: absolute;\n right: 0;\n background-color: #273852;\n height: calc(100% + 2px);\n top: -1px;\n bottom: -1px;\n width: 2px;\n margin-left: auto;\n border-radius: 2px;\n`\nexport const ProportionLabelStyle = styled.div`\n position: absolute;\n top: -22px;\n right: 0;\n white-space: nowrap;\n font-size: 10px;\n line-height: 20px;\n color: #7a8aa0;\n`\n"],"names":["WrapperStyle","styled","div","$height","borderSizes","sm","md","lg","marginSizes","ProportionStyle","$flexGrow","$border","$borderSize","ChartProportionBorderType","rounded","css","$margin","ProportionProgressStyle","$backgroundColor","$progress","ProportionProgressLineStyle","ProportionLabelStyle"],"mappings":";;;;;;;;AAOaA,MAAAA,YAAY,GAAGC,+BAAM,CAACC,GAEhC,CAAA;AACH;AACA;AACA,UAAY,EAAA,IAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,OAAAA;GAAH,GAAA,IAAA,CAAA;AAAA,EAAA,OAAiBA,OAAjB,CAAA;AAAA,CAAyB,CAAA;AACrC;AACA,EAPO;AASP,MAAMC,WAAW,GAAG;AAClBC,EAAAA,EAAE,EAAE,KADc;AAElBC,EAAAA,EAAE,EAAE,KAFc;AAGlBC,EAAAA,EAAE,EAAE,KAAA;AAHc,CAApB,CAAA;AAMA,MAAMC,WAAW,GAAG;AAClBH,EAAAA,EAAE,EAAE,KADc;AAElBC,EAAAA,EAAE,EAAE,KAFc;AAGlBC,EAAAA,EAAE,EAAE,KAAA;AAHc,CAApB,CAAA;AAMaE,MAAAA,eAAe,GAAGR,+BAAM,CAACC,GAMnC,CAAA;AACH;AACA,aAAe,EAAA,KAAA,IAAA;EAAA,IAAC;AAAEQ,IAAAA,SAAAA;GAAH,GAAA,KAAA,CAAA;AAAA,EAAA,OAAmBA,SAAnB,CAAA;AAAA,CAA6B,CAAA;AAC5C;AACA;AACA;AACA,EAAA,EAAI,KAA8B,IAAA;EAAA,IAA7B;IAAEC,OAAF;AAAWC,IAAAA,WAAAA;GAAkB,GAA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AD,CAAc,CAAA;AACvC,QAHQ,CAAA,CAAA;AAID,KAAA;;AACD,IAAA,OAAOG,WAAI,CAAA;AACjB,uBAAyBX,EAAAA,WAAW,CAACQ,WAAD,CAAc,CAAA;AAClD,MAFM,CAAA,CAAA;AAGD,GAAA;;AAED,EAAA,OAAOG,WAAI,CAAX,CAAA,CAAA;AACD,CAAC,CAAA;AACJ,EA3BO;AA6BMK,MAAAA,2BAA2B,GAAGnB,+BAAM,CAACC,GAAI,CAAA;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAVO;AAWMmB,MAAAA,oBAAoB,GAAGpB,+BAAM,CAACC,GAAI,CAAA;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;"}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ let ChartProportionBorderType = /*#__PURE__*/function (ChartProportionBorderType) {
6
+ ChartProportionBorderType["rounded"] = "rounded";
7
+ ChartProportionBorderType["square"] = "square";
8
+ return ChartProportionBorderType;
9
+ }({});
10
+ let ChartProportionBorderSize = /*#__PURE__*/function (ChartProportionBorderSize) {
11
+ ChartProportionBorderSize["sm"] = "sm";
12
+ ChartProportionBorderSize["md"] = "md";
13
+ ChartProportionBorderSize["lg"] = "lg";
14
+ return ChartProportionBorderSize;
15
+ }({});
16
+ let MarginSize = /*#__PURE__*/function (MarginSize) {
17
+ MarginSize["sm"] = "sm";
18
+ MarginSize["md"] = "md";
19
+ MarginSize["lg"] = "lg";
20
+ return MarginSize;
21
+ }({});
22
+
23
+ exports.ChartProportionBorderSize = ChartProportionBorderSize;
24
+ exports.ChartProportionBorderType = ChartProportionBorderType;
25
+ exports.MarginSize = MarginSize;
26
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../packages/chart-proportion/types.tsx"],"sourcesContent":["import { LidoComponentProps } from '../utils/index.js'\nexport type { Theme } from '../theme/index.js'\n\nexport enum ChartProportionBorderType {\n rounded = 'rounded',\n square = 'square',\n}\nexport type ChartProportionBorderTypes = keyof typeof ChartProportionBorderType\n\nexport enum ChartProportionBorderSize {\n sm = 'sm',\n md = 'md',\n lg = 'lg',\n}\nexport type ChartProportionBorderSizes = keyof typeof ChartProportionBorderSize\n\nexport enum MarginSize {\n sm = 'sm',\n md = 'md',\n lg = 'lg',\n}\nexport type MarginSizes = keyof typeof MarginSize\n\nexport type ChartProportionConfig = {\n height: number\n border: ChartProportionBorderType\n borderSize: ChartProportionBorderSize\n margin: MarginSize\n showLabels?: boolean\n loading?: boolean\n data: ChartProportionData[]\n}\n\nexport type ChartProportionData = {\n show?: boolean\n color?: string\n value: number\n progress: number\n label?: string\n}\n\nexport type ChartProportionProps = LidoComponentProps<\n 'div',\n ChartProportionConfig\n>\n"],"names":["ChartProportionBorderType","ChartProportionBorderSize","MarginSize"],"mappings":";;;;AAGYA,IAAAA,yBAAZ,0BAAYA,yBAAZ,EAAA;EAAYA,yBAAZ,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAYA,yBAAZ,CAAA,QAAA,CAAA,GAAA,QAAA,CAAA;AAAA,EAAA,OAAYA,yBAAZ,CAAA;AAAA,CAAA,CAAA,EAAA,EAAA;AAMYC,IAAAA,yBAAZ,0BAAYA,yBAAZ,EAAA;EAAYA,yBAAZ,CAAA,IAAA,CAAA,GAAA,IAAA,CAAA;EAAYA,yBAAZ,CAAA,IAAA,CAAA,GAAA,IAAA,CAAA;EAAYA,yBAAZ,CAAA,IAAA,CAAA,GAAA,IAAA,CAAA;AAAA,EAAA,OAAYA,yBAAZ,CAAA;AAAA,CAAA,CAAA,EAAA,EAAA;AAOYC,IAAAA,UAAZ,0BAAYA,UAAZ,EAAA;EAAYA,UAAZ,CAAA,IAAA,CAAA,GAAA,IAAA,CAAA;EAAYA,UAAZ,CAAA,IAAA,CAAA,GAAA,IAAA,CAAA;EAAYA,UAAZ,CAAA,IAAA,CAAA,GAAA,IAAA,CAAA;AAAA,EAAA,OAAYA,UAAZ,CAAA;AAAA,CAAA,CAAA,EAAA;;;;;;"}
@@ -14,6 +14,7 @@ const CookiesTooltip = _ref => {
14
14
  let {
15
15
  privacyText,
16
16
  privacyLink,
17
+ privacyLinkEnabled = true,
17
18
  ...rest
18
19
  } = _ref;
19
20
  const [isVisible, setVisibility] = React.useState(false);
@@ -38,9 +39,11 @@ const CookiesTooltip = _ref => {
38
39
  return /*#__PURE__*/jsxRuntime.jsx(styles.Wrap, { ...rest,
39
40
  children: /*#__PURE__*/jsxRuntime.jsxs(styles.Box, {
40
41
  children: [/*#__PURE__*/jsxRuntime.jsxs(styles.Text, {
41
- children: [privacyText ?? /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
42
- children: "Cookies are used to collect anonymous site visitation data to\xA0improve website performance. For\xA0more info, read\xA0"
43
- }), /*#__PURE__*/jsxRuntime.jsx(styles.ExternalLink, {
42
+ children: [privacyText ?? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
43
+ children: ["Cookies are used to collect anonymous site visitation data to\xA0improve website performance.", privacyLinkEnabled && /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
44
+ children: "\xA0For\xA0more info, read\xA0"
45
+ })]
46
+ }), privacyLinkEnabled && /*#__PURE__*/jsxRuntime.jsx(styles.ExternalLink, {
44
47
  href: privacyLink ?? 'https://lido.fi/privacy-notice',
45
48
  children: "Privacy Notice"
46
49
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"cookies-tooltip.js","sources":["../../../packages/cookies-tooltip/cookies-tooltip.tsx"],"sourcesContent":["import {\n FC,\n useEffect,\n useState,\n useCallback,\n ComponentPropsWithoutRef,\n ReactNode,\n} from 'react'\nimport { getCrossDomainCookieClientSide } from '../utils/index.js'\nimport {\n Wrap,\n Box,\n Text,\n ButtonsWrap,\n AllowButton,\n DeclineButton,\n ExternalLink,\n} from './styles.js'\nimport { allowCookies, declineCookies } from './utils.js'\nimport { COOKIE_ALLOWED_KEY } from './constants.js'\n\nexport type CookiesTooltipProps = Omit<\n ComponentPropsWithoutRef<'div'>,\n 'children'\n> & {\n privacyText?: ReactNode\n privacyLink?: string\n}\n\nexport const CookiesTooltip: FC<CookiesTooltipProps> = ({\n privacyText,\n privacyLink,\n ...rest\n}) => {\n const [isVisible, setVisibility] = useState(false)\n\n const checkCookieAllowedEarlier = useCallback(() => {\n // Check if user allowed/declined in other tab or third level domain\n if (getCrossDomainCookieClientSide(COOKIE_ALLOWED_KEY)) {\n setVisibility(false)\n\n window.removeEventListener('focus', checkCookieAllowedEarlier)\n }\n }, [])\n\n useEffect(() => {\n // Check cookie after page loaded\n if (getCrossDomainCookieClientSide(COOKIE_ALLOWED_KEY)) {\n return\n }\n\n setVisibility(true)\n\n // This code runs after returned to this browser tab (window) from other\n window.addEventListener('focus', checkCookieAllowedEarlier)\n }, [checkCookieAllowedEarlier])\n\n if (!isVisible) return <></>\n\n return (\n <Wrap {...rest}>\n <Box>\n <Text>\n {privacyText ?? (\n <>\n Cookies are used to collect anonymous site visitation data\n to&nbsp;improve website performance. For&nbsp;more info,\n read&nbsp;\n </>\n )}\n <ExternalLink href={privacyLink ?? 'https://lido.fi/privacy-notice'}>\n Privacy Notice\n </ExternalLink>\n </Text>\n <ButtonsWrap>\n <AllowButton\n onClick={() => {\n allowCookies()\n setVisibility(false)\n }}\n >\n Allow\n </AllowButton>\n <DeclineButton\n onClick={() => {\n declineCookies()\n setVisibility(false)\n }}\n >\n Decline\n </DeclineButton>\n </ButtonsWrap>\n </Box>\n </Wrap>\n )\n}\n"],"names":["CookiesTooltip","privacyText","privacyLink","rest","isVisible","setVisibility","useState","checkCookieAllowedEarlier","useCallback","getCrossDomainCookieClientSide","COOKIE_ALLOWED_KEY","window","removeEventListener","useEffect","addEventListener","_jsx","_Fragment","Wrap","_jsxs","Box","Text","ExternalLink","ButtonsWrap","AllowButton","allowCookies","DeclineButton","declineC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A,EAAA,gBAAA;SARF,CAAA,CAAA;OADF,CAAA,eAaEgB,gBAACI,kBAAD,EAAA;AAAA,QAAA,QAAA,EAAA,cACEP,eAACQ,kBAAD,EAAA;AACE,UAAA,OAAO,EAAE,MAAM;YACbC,kBAAY,EAAA,CAAA;YACZnB,aAAa,CAAC,KAAD,CAAb,CAAA;WAHJ;AAAA,UAAA,QAAA,EAAA,OAAA;SADF,CAAA,eASEU,eAACU,oBAAD,EAAA;AACE,UAAA,OAAO,EAAE,MAAM;YACbC,oBAAc,EAAA,CAAA;YACdrB,aAAa,CAAC,KAAD,CAAb,CAAA;WAHJ;AAAA,UAAA,QAAA,EAAA,SAAA;SATF,CAAA,CAAA;OAbF,CAAA,CAAA;AAAA,KAAA,CAAA;GAFJ,CAAA,CAAA;AAoCD;;;;"}
1
+ {"version":3,"file":"cookies-tooltip.js","sources":["../../../packages/cookies-tooltip/cookies-tooltip.tsx"],"sourcesContent":["import {\n FC,\n useEffect,\n useState,\n useCallback,\n ComponentPropsWithoutRef,\n ReactNode,\n} from 'react'\nimport { getCrossDomainCookieClientSide } from '../utils/index.js'\nimport {\n Wrap,\n Box,\n Text,\n ButtonsWrap,\n AllowButton,\n DeclineButton,\n ExternalLink,\n} from './styles.js'\nimport { allowCookies, declineCookies } from './utils.js'\nimport { COOKIE_ALLOWED_KEY } from './constants.js'\n\nexport type CookiesTooltipProps = Omit<\n ComponentPropsWithoutRef<'div'>,\n 'children'\n> & {\n privacyText?: ReactNode\n privacyLink?: string\n privacyLinkEnabled?: boolean\n}\n\nexport const CookiesTooltip: FC<CookiesTooltipProps> = ({\n privacyText,\n privacyLink,\n privacyLinkEnabled = true,\n ...rest\n}) => {\n const [isVisible, setVisibility] = useState(false)\n\n const checkCookieAllowedEarlier = useCallback(() => {\n // Check if user allowed/declined in other tab or third level domain\n if (getCrossDomainCookieClientSide(COOKIE_ALLOWED_KEY)) {\n setVisibility(false)\n\n window.removeEventListener('focus', checkCookieAllowedEarlier)\n }\n }, [])\n\n useEffect(() => {\n // Check cookie after page loaded\n if (getCrossDomainCookieClientSide(COOKIE_ALLOWED_KEY)) {\n return\n }\n\n setVisibility(true)\n\n // This code runs after returned to this browser tab (window) from other\n window.addEventListener('focus', checkCookieAllowedEarlier)\n }, [checkCookieAllowedEarlier])\n\n if (!isVisible) return <></>\n\n return (\n <Wrap {...rest}>\n <Box>\n <Text>\n {privacyText ?? (\n <>\n Cookies are used to collect anonymous site visitation data\n to&nbsp;improve website performance.\n {privacyLinkEnabled && <>&nbsp;For&nbsp;more info, read&nbsp;</>}\n </>\n )}\n {privacyLinkEnabled && (\n <ExternalLink\n href={privacyLink ?? 'https://lido.fi/privacy-notice'}\n >\n Privacy Notice\n </ExternalLink>\n )}\n </Text>\n <ButtonsWrap>\n <AllowButton\n onClick={() => {\n allowCookies()\n setVisibility(false)\n }}\n >\n Allow\n </AllowButton>\n <DeclineButton\n onClick={() => {\n declineCookies()\n setVisibility(false)\n }}\n >\n Decline\n </DeclineButton>\n </ButtonsWrap>\n </Box>\n </Wrap>\n )\n}\n"],"names":["CookiesTooltip","privacyText","privacyLink","privacyLinkEnabled","rest","isVisible","setVisibility","useState","checkCookieAllowedEarlier","useCallback","getCrossDomainCookieClientSide","COOKIE_ALLOWED_KEY","window","removeEventListener","useEffect","addEventListener","_jsx","_Fragment","Wrap","_jsxs","Box","Text","ExternalLink","ButtonsWrap","AllowButton","allowCookies","DeclineButton","declineCookies"],"mappings":";;;;;;;;;;;;AA8BO,MAAMA,cAAuC,GAAG,IAKjD,IAAA;EAAA,IALkD;IACtDC,WADsD;IAEtDC,WAFsD;AAGtDC,IAAAA,kBAAkB,GAAG,IAHiC;IAItD,GAAGC,IAAAA;GACC,GAAA,IAAA,CAAA;EACJ,MAAM,CAACC,SAAD,EAAYC,aAAZ,IAA6BC,cAAQ,CAAC,KAAD,CAA3C,CAAA;AAEA,EAAA,MAAMC,yBAAyB,GAAGC,iBAAW,CAAC,MAAM;AAClD;AACA,IAAA,IAAIC,gDA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;YACZnB,aAAa,CAAC,KAAD,CAAb,CAAA;WAHJ;AAAA,UAAA,QAAA,EAAA,OAAA;SADF,CAAA,eASEU,eAACU,oBAAD,EAAA;AACE,UAAA,OAAO,EAAE,MAAM;YACbC,oBAAc,EAAA,CAAA;YACdrB,aAAa,CAAC,KAAD,CAAb,CAAA;WAHJ;AAAA,UAAA,QAAA,EAAA,SAAA;SATF,CAAA,CAAA;OAjBF,CAAA,CAAA;AAAA,KAAA,CAAA;GAFJ,CAAA,CAAA;AAwCD;;;;"}
package/dist/cjs/index.js CHANGED
@@ -105,6 +105,11 @@ const cookieThemeToggler = require('./cookie-theme-toggler/cookie-theme-toggler.
105
105
  const contentTheme = require('./content-theme/content-theme.js');
106
106
  const cookiesTooltip = require('./cookies-tooltip/cookies-tooltip.js');
107
107
  const utils = require('./cookies-tooltip/utils.js');
108
+ const ChartLine = require('./chart-line/ChartLine.js');
109
+ const ChartLineLabel = require('./chart-line/ChartLineLabel.js');
110
+ const types$h = require('./chart-line/types.js');
111
+ const ChartProportion = require('./chart-proportion/ChartProportion.js');
112
+ const types$i = require('./chart-proportion/types.js');
108
113
  const modalRoot = require('./utils/modalRoot.js');
109
114
  const elementFonts = require('./theme/document-head-contents/element-fonts.js');
110
115
  const getTopLevelDomain = require('./utils/get-top-level-domain.js');
@@ -338,6 +343,14 @@ exports.ThemeToggler = cookieThemeToggler.ThemeToggler;
338
343
  exports.ContentTheme = contentTheme.ContentTheme;
339
344
  exports.CookiesTooltip = cookiesTooltip.CookiesTooltip;
340
345
  exports.migrationAllowCookieToCrossDomainCookieClientSide = utils.migrationAllowCookieToCrossDomainCookieClientSide;
346
+ exports.ChartLine = ChartLine.ChartLine;
347
+ exports.ChartLineLabel = ChartLineLabel.ChartLineLabel;
348
+ exports.ChartLineBorderType = types$h.ChartLineBorderType;
349
+ exports.ChartLineThresholdType = types$h.ChartLineThresholdType;
350
+ exports.ChartProportion = ChartProportion.ChartProportion;
351
+ exports.ChartProportionBorderSize = types$i.ChartProportionBorderSize;
352
+ exports.ChartProportionBorderType = types$i.ChartProportionBorderType;
353
+ exports.MarginSize = types$i.MarginSize;
341
354
  exports.modalRoot = modalRoot;
342
355
  exports.Fonts = elementFonts.Fonts;
343
356
  exports.getTopLevelDomain = getTopLevelDomain.getTopLevelDomain;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,88 @@
1
+ import { forwardRef, useState, useMemo, useLayoutEffect } from 'react';
2
+ import '../loaders/Loader.mjs';
3
+ import { InlineLoader } from '../loaders/InlineLoader.mjs';
4
+ import { ChartLineLabel } from './ChartLineLabel.mjs';
5
+ import { CHART_LINE_CONTAINER_ID } from './utils/constants.mjs';
6
+ import { getContainerSize } from './utils/getContainerSize.mjs';
7
+ import { processData } from './utils/processData.mjs';
8
+ import { WrapperStyle, ContainerStyle, LineStyle } from './ChartLineStyles.mjs';
9
+ import { jsx } from 'react/jsx-runtime';
10
+
11
+ const ChartLine = /*#__PURE__*/forwardRef((props, ref) => {
12
+ const {
13
+ loading = false,
14
+ onClick,
15
+ children,
16
+ height,
17
+ border,
18
+ data,
19
+ showLabels,
20
+ maxValue,
21
+ thresholdType,
22
+ ...rest
23
+ } = props;
24
+ const [containerSize, setContainerSize] = useState(null);
25
+ const {
26
+ data: processedData,
27
+ ids
28
+ } = useMemo(() => processData(data, maxValue), [data, maxValue]);
29
+ const allPreviousIds = useMemo(() => ids.map((_, index) => ids.slice(0, index)), [ids]);
30
+ useLayoutEffect(() => {
31
+ if (!showLabels) {
32
+ setContainerSize(null);
33
+ return;
34
+ }
35
+
36
+ const containerSize = getContainerSize(ids);
37
+ setContainerSize(containerSize);
38
+ }, [ids, showLabels]);
39
+
40
+ if (loading) {
41
+ return /*#__PURE__*/jsx(WrapperStyle, {
42
+ $border: border,
43
+ $height: height,
44
+ ref: ref,
45
+ ...rest,
46
+ children: /*#__PURE__*/jsx(InlineLoader, {})
47
+ });
48
+ }
49
+
50
+ return /*#__PURE__*/jsx(ContainerStyle, {
51
+ id: CHART_LINE_CONTAINER_ID,
52
+ $alignItems: containerSize?.isCenterAlign ? 'center' : 'flex-start',
53
+ $height: containerSize?.size ?? 0,
54
+ children: /*#__PURE__*/jsx(WrapperStyle, {
55
+ $border: border,
56
+ $height: height,
57
+ ref: ref,
58
+ ...rest,
59
+ children: processedData.map((item, index) => {
60
+ const {
61
+ color,
62
+ id,
63
+ width
64
+ } = item;
65
+ const previousIds = allPreviousIds[index];
66
+ return /*#__PURE__*/jsx(LineStyle, {
67
+ $width: `${width}%`,
68
+ $backgroundColor: color,
69
+ $zIndex: processedData.length - index,
70
+ $border: border,
71
+ $isFullWidth: width === 100,
72
+ children: /*#__PURE__*/jsx(ChartLineLabel, {
73
+ zIndex: processedData.length - index,
74
+ show: showLabels,
75
+ previousIds: previousIds,
76
+ height: height,
77
+ thresholdType: thresholdType,
78
+ ...item
79
+ })
80
+ }, id);
81
+ })
82
+ })
83
+ });
84
+ });
85
+ ChartLine.displayName = 'ChartLine';
86
+
87
+ export { ChartLine };
88
+ //# sourceMappingURL=ChartLine.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartLine.mjs","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","CHART_LINE_CONTAINER_ID","isCenterAlign","size","item","color","id","width","previousIds","length","displayName"],"mappings":";;;;;;;;;;AAmBO,MAAMA,SAAS,gBAAGC,UAAU,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,GAWFX,KAXJ,CAAA;EAaA,MAAM,CAACY,aAAD,EAAgBC,gBAAhB,IAAoCC,QAAQ,CAGxC,IAHwC,CAAlD,CAAA;EAKA,MAAM;AAAEP,IAAAA,IAAI,EAAEQ,aAAR;AAAuBC,IAAAA,GAAAA;AAAvB,GAAA,GAA+BC,OAAO,CAC1C,MAAMC,WAAW,CAACX,IAAD,EAAOE,QAAP,CADyB,EAE1C,CA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AACK,GAAd,CAAkB,CAACU,IAAD,EAAOR,KAAP,KAAiB;QAClC,MAAM;UAAES,KAAF;UAASC,EAAT;AAAaC,UAAAA,KAAAA;AAAb,SAAA,GAAuBH,IAA7B,CAAA;AACA,QAAA,MAAMI,WAAW,GAAGf,cAAc,CAACG,KAAD,CAAlC,CAAA;AAEA,QAAA,oBACEI,IAAC,SAAD,EAAA;UAEE,MAAM,EAAG,CAAEO,EAAAA,KAAM,CAFnB,CAAA,CAAA;AAGE,UAAA,gBAAgB,EAAEF,KAHpB;AAIE,UAAA,OAAO,EAAEhB,aAAa,CAACoB,MAAd,GAAuBb,KAJlC;AAKE,UAAA,OAAO,EAAEhB,MALX;UAME,YAAY,EAAE2B,KAAK,KAAK,GAN1B;AAAA,UAAA,QAAA,eAQEP,IAAC,cAAD,EAAA;AACE,YAAA,MAAM,EAAEX,aAAa,CAACoB,MAAd,GAAuBb,KADjC;AAEE,YAAA,IAAI,EAAEd,UAFR;AAGE,YAAA,WAAW,EAAE0B,WAHf;AAIE,YAAA,MAAM,EAAE7B,MAJV;AAKE,YAAA,aAAa,EAAEK,aALjB;YAAA,GAMMoB,IAAAA;AANN,WAAA,CAAA;AARF,SAAA,EACOE,EADP,CADF,CAAA;OAJD,CAAA;AADH,KAAA,CAAA;GANJ,CAAA,CAAA;AAkCD,CAjFgC,EAA5B;AAmFPlC,SAAS,CAACsC,WAAV,GAAwB,WAAxB;;;;"}
@@ -0,0 +1,62 @@
1
+ import { forwardRef, useLayoutEffect } from 'react';
2
+ import { ChartLineThresholdType } from './types.mjs';
3
+ import { ThresholdStyle, ThresholdLabelStyle } from './ChartLineStyles.mjs';
4
+ import { handlePositioning } from './utils/handlePositioning.mjs';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ const ChartLineLabel = /*#__PURE__*/forwardRef((props, ref) => {
8
+ const {
9
+ previousIds,
10
+ id,
11
+ color,
12
+ zIndex,
13
+ show,
14
+ labelPosition,
15
+ thresholdType,
16
+ height,
17
+ threshold,
18
+ ...rest
19
+ } = props;
20
+ useLayoutEffect(() => {
21
+ if (!show) return;
22
+
23
+ if (thresholdType !== ChartLineThresholdType.flag) {
24
+ handlePositioning({
25
+ previousIds,
26
+ id,
27
+ reset: true
28
+ });
29
+ } else {
30
+ handlePositioning({
31
+ previousIds,
32
+ id
33
+ });
34
+ }
35
+ }, [previousIds, id, show, thresholdType]);
36
+ if (!show) return null;
37
+ const backgroundColor = threshold.color || color;
38
+ const content = threshold.descriptionElement || threshold.description;
39
+ return /*#__PURE__*/jsx(ThresholdStyle, {
40
+ ref: ref,
41
+ id: id,
42
+ "data-label-position": labelPosition,
43
+ $labelPosition: labelPosition,
44
+ $thresholdType: thresholdType,
45
+ $height: height,
46
+ $backgroundColor: backgroundColor,
47
+ $zIndex: zIndex,
48
+ ...rest,
49
+ children: thresholdType === ChartLineThresholdType.flag && /*#__PURE__*/jsx(ThresholdLabelStyle, {
50
+ style: {
51
+ backgroundColor
52
+ },
53
+ id: `${id}-description`,
54
+ $labelPosition: labelPosition,
55
+ children: content
56
+ })
57
+ });
58
+ });
59
+ ChartLineLabel.displayName = 'ChartLineLabel';
60
+
61
+ export { ChartLineLabel };
62
+ //# sourceMappingURL=ChartLineLabel.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartLineLabel.mjs","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","displayName"],"mappings":";;;;;;AAMO,MAAMA,cAAc,gBAAGC,UAAU,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;IAUJ,GAAGC,IAAAA;AAVC,GAAA,GAWFX,KAXJ,CAAA;AAaAY,EAAAA,eAAe,CAAC,MAAM;IACpB,IAAI,CAACN,IAAL,EAAW,OAAA;;AACX,IAAA,IAAIE,aAAa,KAAKK,sBAAsB,CAACC,IAA7C,EAAmD;AACjDC,MAAAA,iBAAiB,CAAC;QAAEb,WAAF;QAAeC,EAAf;AAAmBa,QAAAA,KAAK,EAAE,IAAA;AAA1B,OAAD,CAAjB,CAAA;AACD,KAFD,MAEO;AACLD,MAAAA,iBAAiB,CAAC;QAAEb,WAAF;AAAeC,QAAAA,EAAAA;AAAf,OAAD,CAAjB,CAA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