@kubit-ui-web/react-charts 0.1.0 → 1.1.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 (230) hide show
  1. package/README.md +31 -36
  2. package/dist/cjs/charts/barChart/barChart.js +12 -29
  3. package/dist/cjs/charts/barChart/barChart.type.js +1 -2
  4. package/dist/cjs/charts/barChart/barChartStructure.js +25 -29
  5. package/dist/cjs/charts/barChart/context/barChartContext.js +2 -5
  6. package/dist/cjs/charts/barChart/context/buildBarContextValues.js +17 -21
  7. package/dist/cjs/charts/barChart/fragments/barChartPath.js +12 -16
  8. package/dist/cjs/charts/barChart/fragments/barChartSeparator.js +10 -14
  9. package/dist/cjs/charts/barChart/fragments/barChartXAxis.js +10 -14
  10. package/dist/cjs/charts/barChart/fragments/barChartYAxis.js +13 -17
  11. package/dist/cjs/charts/barChart/fragments/fixture/barContextData.js +3 -6
  12. package/dist/cjs/charts/barChart/fragments/fixture/index.js +1 -5
  13. package/dist/cjs/charts/barChart/index.js +1 -17
  14. package/dist/cjs/charts/barChart/utils/countBarChildren.js +5 -9
  15. package/dist/cjs/charts/barChart/utils/getAxisExtraSpacing.js +31 -35
  16. package/dist/cjs/charts/barChart/utils/getBarDataValue.js +1 -5
  17. package/dist/cjs/charts/barChart/utils/getRoundedBarMaxValue.js +1 -5
  18. package/dist/cjs/charts/index.js +3 -19
  19. package/dist/cjs/charts/lineChart/context/buildLineContextValue.js +17 -21
  20. package/dist/cjs/charts/lineChart/context/index.js +2 -7
  21. package/dist/cjs/charts/lineChart/context/lineChartContext.js +2 -5
  22. package/dist/cjs/charts/lineChart/fragments/fixture/contextData.js +1 -4
  23. package/dist/cjs/charts/lineChart/fragments/fixture/index.js +1 -5
  24. package/dist/cjs/charts/lineChart/fragments/index.js +4 -11
  25. package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +31 -35
  26. package/dist/cjs/charts/lineChart/fragments/lineChartProjection.js +6 -10
  27. package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.js +10 -14
  28. package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.js +14 -18
  29. package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.js +17 -21
  30. package/dist/cjs/charts/lineChart/hook/index.js +3 -9
  31. package/dist/cjs/charts/lineChart/hook/useAutoClick.js +6 -10
  32. package/dist/cjs/charts/lineChart/hook/useHover.js +5 -9
  33. package/dist/cjs/charts/lineChart/hook/useIndicator.js +5 -9
  34. package/dist/cjs/charts/lineChart/index.js +1 -17
  35. package/dist/cjs/charts/lineChart/lineChart.js +12 -29
  36. package/dist/cjs/charts/lineChart/lineChart.type.js +1 -2
  37. package/dist/cjs/charts/lineChart/lineChartStructure.js +34 -38
  38. package/dist/cjs/charts/lineChart/utils/accessibilityTemplateProcessor.js +6 -10
  39. package/dist/cjs/charts/lineChart/utils/findSurroundingNumber.js +2 -7
  40. package/dist/cjs/charts/lineChart/utils/getDataValues.js +1 -5
  41. package/dist/cjs/charts/lineChart/utils/getExtraSpacing.js +26 -30
  42. package/dist/cjs/charts/lineChart/utils/getPathData.js +1 -5
  43. package/dist/cjs/charts/lineChart/utils/getProjection.js +1 -5
  44. package/dist/cjs/charts/lineChart/utils/getRoundedMaxValue.js +2 -7
  45. package/dist/cjs/charts/lineChart/utils/handleNodesFocus.js +1 -5
  46. package/dist/cjs/charts/lineChart/utils/index.js +6 -17
  47. package/dist/cjs/charts/pieChart/context/buildPieContextValue.js +8 -12
  48. package/dist/cjs/charts/pieChart/context/index.js +2 -7
  49. package/dist/cjs/charts/pieChart/context/pieChartContext.js +2 -5
  50. package/dist/cjs/charts/pieChart/fragments/index.js +2 -7
  51. package/dist/cjs/charts/pieChart/fragments/pieChartForeign.js +7 -11
  52. package/dist/cjs/charts/pieChart/fragments/pieChartPath.js +12 -16
  53. package/dist/cjs/charts/pieChart/fragments/pieChartSegment.js +6 -10
  54. package/dist/cjs/charts/pieChart/index.js +1 -17
  55. package/dist/cjs/charts/pieChart/pieChart.js +8 -25
  56. package/dist/cjs/charts/pieChart/pieChart.type.js +1 -2
  57. package/dist/cjs/charts/pieChart/pieChartStructure.js +16 -20
  58. package/dist/cjs/charts/pieChart/utils/buildL.js +1 -5
  59. package/dist/cjs/charts/pieChart/utils/calculatePoint.js +1 -5
  60. package/dist/cjs/charts/pieChart/utils/calculateSegmentPath.js +10 -14
  61. package/dist/cjs/charts/pieChart/utils/drawSegmentPath.js +6 -10
  62. package/dist/cjs/charts/pieChart/utils/index.js +2 -7
  63. package/dist/cjs/charts/pieChart/utils/rotationDirection.js +3 -7
  64. package/dist/cjs/components/axisChart/index.js +2 -18
  65. package/dist/cjs/components/axisChart/utils/filterLineProps/filterLineProps.js +1 -5
  66. package/dist/cjs/components/axisChart/utils/index.js +1 -17
  67. package/dist/cjs/components/axisChart/xAxis/index.js +2 -18
  68. package/dist/cjs/components/axisChart/xAxis/xAxis.js +14 -18
  69. package/dist/cjs/components/axisChart/xAxis/xAxis.types.js +1 -2
  70. package/dist/cjs/components/axisChart/yAxis/index.js +2 -18
  71. package/dist/cjs/components/axisChart/yAxis/yAxis.js +13 -17
  72. package/dist/cjs/components/axisChart/yAxis/yAxis.types.js +1 -2
  73. package/dist/cjs/components/bar/bar.js +9 -13
  74. package/dist/cjs/components/bar/bar.type.js +1 -4
  75. package/dist/cjs/components/bar/fragments/barChartSegment.js +3 -7
  76. package/dist/cjs/components/bar/index.js +2 -18
  77. package/dist/cjs/components/bar/utils/buildD.js +5 -9
  78. package/dist/cjs/components/bar/utils/getSegments.js +3 -7
  79. package/dist/cjs/components/chartText/chartText.js +3 -7
  80. package/dist/cjs/components/chartText/chartText.types.js +1 -2
  81. package/dist/cjs/components/chartText/index.js +2 -18
  82. package/dist/cjs/components/foreignObject/foreignObject.js +3 -7
  83. package/dist/cjs/components/foreignObject/foreignObject.types.js +1 -2
  84. package/dist/cjs/components/foreignObject/index.js +2 -18
  85. package/dist/cjs/components/index.js +10 -26
  86. package/dist/cjs/components/line/index.js +2 -18
  87. package/dist/cjs/components/line/line.js +3 -7
  88. package/dist/cjs/components/line/line.types.js +1 -2
  89. package/dist/cjs/components/node/components/circle/circle.js +4 -7
  90. package/dist/cjs/components/node/components/hexagon/hexagon.js +6 -9
  91. package/dist/cjs/components/node/components/pentagon/pentagon.js +6 -9
  92. package/dist/cjs/components/node/components/square/square.js +4 -7
  93. package/dist/cjs/components/node/components/star/star.js +6 -9
  94. package/dist/cjs/components/node/components/straight/straight.js +4 -7
  95. package/dist/cjs/components/node/components/triangle/triangle.js +4 -7
  96. package/dist/cjs/components/node/index.js +2 -18
  97. package/dist/cjs/components/node/node.js +22 -25
  98. package/dist/cjs/components/node/node.types.js +1 -4
  99. package/dist/cjs/components/node/utils/calculateShapePoints/calculateShapePoints.js +1 -5
  100. package/dist/cjs/components/path/components/nodePath/nodePath.js +9 -12
  101. package/dist/cjs/components/path/index.js +2 -18
  102. package/dist/cjs/components/path/path.js +20 -23
  103. package/dist/cjs/components/path/path.types.js +1 -2
  104. package/dist/cjs/components/plot/components/circle/circle.js +4 -7
  105. package/dist/cjs/components/plot/components/index.js +3 -19
  106. package/dist/cjs/components/plot/components/square/square.js +4 -7
  107. package/dist/cjs/components/plot/components/triangle/triangle.js +4 -7
  108. package/dist/cjs/components/plot/index.js +2 -18
  109. package/dist/cjs/components/plot/plot.js +21 -24
  110. package/dist/cjs/components/plot/plot.types.js +8 -11
  111. package/dist/cjs/components/svgContainer/index.js +1 -17
  112. package/dist/cjs/components/svgContainer/svgContainer.js +5 -8
  113. package/dist/cjs/components/svgContainer/svgContainer.types.js +1 -2
  114. package/dist/cjs/components/svgContainer/utils/buildViewBox/buildViewBox.js +1 -5
  115. package/dist/cjs/components/svgContainer/utils/index.js +1 -17
  116. package/dist/cjs/components/tick/index.js +2 -18
  117. package/dist/cjs/components/tick/tick.js +4 -8
  118. package/dist/cjs/components/tick/tick.types.js +1 -4
  119. package/dist/cjs/components/zoomArea/components/HandlerIcon.js +3 -7
  120. package/dist/cjs/components/zoomArea/components/LineRenderer.js +3 -7
  121. package/dist/cjs/components/zoomArea/components/SelectionArea.js +9 -14
  122. package/dist/cjs/components/zoomArea/components/ZoomHandler.js +6 -10
  123. package/dist/cjs/components/zoomArea/components/index.js +4 -12
  124. package/dist/cjs/components/zoomArea/hooks/index.js +5 -13
  125. package/dist/cjs/components/zoomArea/hooks/useDragInteraction.js +19 -23
  126. package/dist/cjs/components/zoomArea/hooks/useKeyboardNavigation.js +18 -22
  127. package/dist/cjs/components/zoomArea/hooks/useResponsiveCanvas.js +12 -16
  128. package/dist/cjs/components/zoomArea/hooks/useZoomAreaFocus.js +6 -10
  129. package/dist/cjs/components/zoomArea/hooks/useZoomData.js +8 -12
  130. package/dist/cjs/components/zoomArea/index.js +5 -21
  131. package/dist/cjs/components/zoomArea/utils/accessibilityLabels.js +6 -11
  132. package/dist/cjs/components/zoomArea/utils/index.js +3 -14
  133. package/dist/cjs/components/zoomArea/utils/indexRounding.js +5 -11
  134. package/dist/cjs/components/zoomArea/utils/interactionConfig.js +1 -5
  135. package/dist/cjs/components/zoomArea/utils/pathGeneration.js +4 -9
  136. package/dist/cjs/components/zoomArea/utils/rangeAndPositions.js +5 -13
  137. package/dist/cjs/components/zoomArea/utils/selectionConfig.js +1 -5
  138. package/dist/cjs/components/zoomArea/zoomArea.js +35 -39
  139. package/dist/cjs/components/zoomArea/zoomArea.type.js +1 -4
  140. package/dist/cjs/hooks/index.js +2 -18
  141. package/dist/cjs/hooks/useFocus/useFocus.js +5 -9
  142. package/dist/cjs/hooks/useFocus/useFocus.types.js +1 -2
  143. package/dist/cjs/hooks/useHover/useHover.js +5 -9
  144. package/dist/cjs/hooks/useHover/useHover.types.js +1 -2
  145. package/dist/cjs/index.js +3 -19
  146. package/dist/cjs/types/canvas.type.js +1 -4
  147. package/dist/cjs/types/errors.type.js +1 -4
  148. package/dist/cjs/types/focusConfig.type.js +1 -4
  149. package/dist/cjs/types/index.js +4 -20
  150. package/dist/cjs/types/position.enum.js +1 -4
  151. package/dist/cjs/types/unit.enum.js +1 -4
  152. package/dist/cjs/types/valueFormatter.type.js +1 -2
  153. package/dist/cjs/utils/ajustedTextSpace/ajustedTextSpace.js +1 -5
  154. package/dist/cjs/utils/buildErrors/buildErrors.js +3 -7
  155. package/dist/cjs/utils/buildTickValues/buildTickValues.js +2 -7
  156. package/dist/cjs/utils/calculateFocusOutline/calculateFocusOutline.js +8 -13
  157. package/dist/cjs/utils/classNames/classNames.js +1 -5
  158. package/dist/cjs/utils/cssGradientToSvg/cssGradientToSvg.js +4 -8
  159. package/dist/cjs/utils/cssGradientToSvg/cssGradientToSvg.types.js +1 -2
  160. package/dist/cjs/utils/cursorNear/isNear.js +1 -5
  161. package/dist/cjs/utils/getAxisData/getAxisData.js +1 -5
  162. package/dist/cjs/utils/getCanvasDimensions/getCanvasDimensions.js +8 -12
  163. package/dist/cjs/utils/getChildrenAttr/getChildrenAttr.js +4 -8
  164. package/dist/cjs/utils/getCoordinates/getCoordinates.js +9 -14
  165. package/dist/cjs/utils/getDataFingerprint/getDataFingerprint.js +1 -5
  166. package/dist/cjs/utils/getPoints/getPoints.js +1 -5
  167. package/dist/cjs/utils/getTickTextCoordinate/getTickTextCoordinates.js +5 -10
  168. package/dist/cjs/utils/getTicks/getTicks.js +2 -7
  169. package/dist/cjs/utils/index.js +8 -24
  170. package/dist/cjs/utils/parseStringToNumberPx.ts/parseStringToNumberPx.js +3 -7
  171. package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.js +1 -5
  172. package/dist/cjs/utils/shadowSvg/shadowSvg.js +3 -7
  173. package/dist/cjs/utils/shadowSvg/shadowSvg.types.js +1 -2
  174. package/dist/cjs/utils/textBound/textBound.js +1 -5
  175. package/dist/kubit-ui-web-react-charts.cjs.js +1 -10
  176. package/dist/kubit-ui-web-react-charts.es.js +1 -10
  177. package/dist/kubit-ui-web-react-charts.umd.js +1 -10
  178. package/dist/types/charts/barChart/barChart.d.ts +5 -5
  179. package/dist/types/charts/barChart/barChart.type.d.ts +1 -1
  180. package/dist/types/charts/barChart/context/barChartContext.d.ts +1 -1
  181. package/dist/types/charts/barChart/fragments/barChartSeparator.d.ts +1 -1
  182. package/dist/types/charts/barChart/fragments/barChartXAxis.d.ts +1 -1
  183. package/dist/types/charts/barChart/fragments/barChartYAxis.d.ts +1 -1
  184. package/dist/types/charts/lineChart/context/lineChartContext.d.ts +1 -1
  185. package/dist/types/charts/lineChart/fragments/lineChartPath.d.ts +1 -1
  186. package/dist/types/charts/lineChart/fragments/lineChartProjection.d.ts +1 -1
  187. package/dist/types/charts/lineChart/fragments/lineChartSeparator.d.ts +1 -1
  188. package/dist/types/charts/lineChart/fragments/lineChartXAxis.d.ts +1 -1
  189. package/dist/types/charts/lineChart/lineChart.d.ts +5 -5
  190. package/dist/types/charts/lineChart/lineChart.type.d.ts +1 -1
  191. package/dist/types/charts/lineChart/lineChartStructure.d.ts +1 -1
  192. package/dist/types/charts/pieChart/context/pieChartContext.d.ts +1 -1
  193. package/dist/types/charts/pieChart/fragments/pieChartForeign.d.ts +1 -1
  194. package/dist/types/charts/pieChart/fragments/pieChartPath.d.ts +1 -1
  195. package/dist/types/charts/pieChart/pieChart.d.ts +3 -3
  196. package/dist/types/charts/pieChart/pieChart.type.d.ts +1 -1
  197. package/dist/types/charts/pieChart/pieChartStructure.d.ts +1 -1
  198. package/dist/types/components/axisChart/xAxis/xAxis.d.ts +1 -1
  199. package/dist/types/components/axisChart/yAxis/yAxis.d.ts +1 -1
  200. package/dist/types/components/bar/bar.d.ts +1 -1
  201. package/dist/types/components/bar/fragments/barChartSegment.d.ts +1 -1
  202. package/dist/types/components/chartText/chartText.d.ts +1 -1
  203. package/dist/types/components/foreignObject/foreignObject.d.ts +1 -1
  204. package/dist/types/components/foreignObject/foreignObject.types.d.ts +1 -1
  205. package/dist/types/components/line/line.d.ts +1 -1
  206. package/dist/types/components/node/components/circle/circle.d.ts +1 -1
  207. package/dist/types/components/node/components/hexagon/hexagon.d.ts +1 -1
  208. package/dist/types/components/node/components/pentagon/pentagon.d.ts +1 -1
  209. package/dist/types/components/node/components/square/square.d.ts +1 -1
  210. package/dist/types/components/node/components/star/star.d.ts +1 -1
  211. package/dist/types/components/node/components/straight/straight.d.ts +1 -1
  212. package/dist/types/components/node/components/triangle/triangle.d.ts +1 -1
  213. package/dist/types/components/node/node.d.ts +1 -1
  214. package/dist/types/components/path/components/nodePath/nodePath.d.ts +2 -2
  215. package/dist/types/components/path/path.d.ts +1 -1
  216. package/dist/types/components/path/path.types.d.ts +1 -1
  217. package/dist/types/components/plot/components/circle/circle.d.ts +1 -1
  218. package/dist/types/components/plot/components/square/square.d.ts +1 -1
  219. package/dist/types/components/plot/components/triangle/triangle.d.ts +1 -1
  220. package/dist/types/components/plot/plot.d.ts +1 -1
  221. package/dist/types/components/svgContainer/svgContainer.d.ts +1 -1
  222. package/dist/types/components/tick/tick.d.ts +1 -1
  223. package/dist/types/components/zoomArea/components/HandlerIcon.d.ts +1 -1
  224. package/dist/types/components/zoomArea/components/LineRenderer.d.ts +1 -1
  225. package/dist/types/components/zoomArea/components/SelectionArea.d.ts +1 -1
  226. package/dist/types/components/zoomArea/components/ZoomHandler.d.ts +1 -1
  227. package/dist/types/hooks/useFocus/useFocus.types.d.ts +1 -1
  228. package/dist/types/hooks/useHover/useHover.types.d.ts +1 -1
  229. package/dist/types/utils/getChildrenAttr/getChildrenAttr.d.ts +1 -1
  230. package/package.json +44 -47
@@ -1,14 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFullRange = exports.createDefaultRange = exports.clampRange = exports.mouseToDataIndex = exports.calculateHandlerPositions = exports.calculateLinesPathData = exports.generateCurvedPath = exports.getInteractionConfig = void 0;
4
- var interactionConfig_1 = require("./interactionConfig");
5
- Object.defineProperty(exports, "getInteractionConfig", { enumerable: true, get: function () { return interactionConfig_1.getInteractionConfig; } });
6
- var pathGeneration_1 = require("./pathGeneration");
7
- Object.defineProperty(exports, "generateCurvedPath", { enumerable: true, get: function () { return pathGeneration_1.generateCurvedPath; } });
8
- Object.defineProperty(exports, "calculateLinesPathData", { enumerable: true, get: function () { return pathGeneration_1.calculateLinesPathData; } });
9
- var rangeAndPositions_1 = require("./rangeAndPositions");
10
- Object.defineProperty(exports, "calculateHandlerPositions", { enumerable: true, get: function () { return rangeAndPositions_1.calculateHandlerPositions; } });
11
- Object.defineProperty(exports, "mouseToDataIndex", { enumerable: true, get: function () { return rangeAndPositions_1.mouseToDataIndex; } });
12
- Object.defineProperty(exports, "clampRange", { enumerable: true, get: function () { return rangeAndPositions_1.clampRange; } });
13
- Object.defineProperty(exports, "createDefaultRange", { enumerable: true, get: function () { return rangeAndPositions_1.createDefaultRange; } });
14
- Object.defineProperty(exports, "isFullRange", { enumerable: true, get: function () { return rangeAndPositions_1.isFullRange; } });
1
+ export { getInteractionConfig } from './interactionConfig';
2
+ export { generateCurvedPath, calculateLinesPathData } from './pathGeneration';
3
+ export { calculateHandlerPositions, mouseToDataIndex, clampRange, createDefaultRange, isFullRange, } from './rangeAndPositions';
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Index rounding utilities for consistent data filtering and accessibility labels.
4
3
  *
@@ -6,8 +5,6 @@
6
5
  * (generateAccessibilityLabels) use exactly the same rounding logic, preventing
7
6
  * inconsistencies between what users see and what screen readers announce.
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getRangeIndices = exports.roundEndIndex = exports.roundStartIndex = void 0;
11
8
  /**
12
9
  * Rounds a fractional index to be used as a start index (inclusive lower bound).
13
10
  * Uses Math.floor() to include the current data point and everything after it.
@@ -22,11 +19,10 @@ exports.getRangeIndices = exports.roundEndIndex = exports.roundStartIndex = void
22
19
  * roundStartIndex(-0.5, 4); // Math.floor(-0.5) = -1, clamped to [0,4] → 0
23
20
  * ```
24
21
  */
25
- const roundStartIndex = (index, maxIndex) => {
22
+ export const roundStartIndex = (index, maxIndex) => {
26
23
  const rounded = Math.floor(index);
27
24
  return Math.max(0, Math.min(maxIndex, rounded));
28
25
  };
29
- exports.roundStartIndex = roundStartIndex;
30
26
  /**
31
27
  * Rounds a fractional index to be used as an end index (inclusive upper bound).
32
28
  * Uses Math.ceil() to include the current data point and everything before it.
@@ -41,11 +37,10 @@ exports.roundStartIndex = roundStartIndex;
41
37
  * roundEndIndex(5.2, 4); // Math.ceil(5.2) = 6, clamped to [0,4] → 4
42
38
  * ```
43
39
  */
44
- const roundEndIndex = (index, maxIndex) => {
40
+ export const roundEndIndex = (index, maxIndex) => {
45
41
  const rounded = Math.ceil(index);
46
42
  return Math.max(0, Math.min(maxIndex, rounded));
47
43
  };
48
- exports.roundEndIndex = roundEndIndex;
49
44
  /**
50
45
  * Converts a fractional range to integer indices using consistent rounding.
51
46
  * This is the core function that both data filtering and accessibility use.
@@ -64,11 +59,10 @@ exports.roundEndIndex = roundEndIndex;
64
59
  * // 2. Accessibility: data[startIndex][xKey] to data[endIndex][xKey]
65
60
  * ```
66
61
  */
67
- const getRangeIndices = (range, dataLength) => {
62
+ export const getRangeIndices = (range, dataLength) => {
68
63
  const maxIndex = Math.max(0, dataLength - 1);
69
64
  return {
70
- endIndex: (0, exports.roundEndIndex)(range.end, maxIndex),
71
- startIndex: (0, exports.roundStartIndex)(range.start, maxIndex),
65
+ endIndex: roundEndIndex(range.end, maxIndex),
66
+ startIndex: roundStartIndex(range.start, maxIndex),
72
67
  };
73
68
  };
74
- exports.getRangeIndices = getRangeIndices;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInteractionConfig = void 0;
4
1
  /**
5
2
  * Default configuration for ZoomArea interactions
6
3
  */
@@ -19,9 +16,8 @@ const DEFAULT_INTERACTION_CONFIG = {
19
16
  * @param config - Optional user configuration
20
17
  * @returns Complete interaction configuration with defaults applied
21
18
  */
22
- const getInteractionConfig = (config) => ({
19
+ export const getInteractionConfig = (config) => ({
23
20
  keyboardFastStep: config?.keyboardFastStep ?? DEFAULT_INTERACTION_CONFIG.KEYBOARD_FAST_STEP,
24
21
  keyboardStep: config?.keyboardStep ?? DEFAULT_INTERACTION_CONFIG.KEYBOARD_STEP,
25
22
  minHandlerDistance: config?.minHandlerDistance ?? DEFAULT_INTERACTION_CONFIG.MIN_HANDLER_DISTANCE,
26
23
  });
27
- exports.getInteractionConfig = getInteractionConfig;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateLinesPathData = exports.generateCurvedPath = void 0;
4
1
  /**
5
2
  * Path generation utilities for ZoomArea SVG rendering
6
3
  */
@@ -21,7 +18,7 @@ exports.calculateLinesPathData = exports.generateCurvedPath = void 0;
21
18
  * // Returns: "M 0 10 C 3 10, 7 20, 10 20 C 13 20, 17 15, 20 15"
22
19
  * ```
23
20
  */
24
- const generateCurvedPath = (points) => {
21
+ export const generateCurvedPath = (points) => {
25
22
  if (points.length === 0) {
26
23
  return '';
27
24
  }
@@ -42,7 +39,6 @@ const generateCurvedPath = (points) => {
42
39
  });
43
40
  return path;
44
41
  };
45
- exports.generateCurvedPath = generateCurvedPath;
46
42
  /**
47
43
  * Calculates path data for all lines with unified Y-scale, supporting both curved and straight lines.
48
44
  *
@@ -72,7 +68,7 @@ exports.generateCurvedPath = generateCurvedPath;
72
68
  * // Returns: [{ linePath: "M 0 80 C...", fillPath: "", config: {...} }, ...]
73
69
  * ```
74
70
  */
75
- const calculateLinesPathData = (data, lines, width, height) => {
71
+ export const calculateLinesPathData = (data, lines, width, height) => {
76
72
  if (data.length === 0 || lines.length === 0) {
77
73
  return [];
78
74
  }
@@ -97,14 +93,14 @@ const calculateLinesPathData = (data, lines, width, height) => {
97
93
  });
98
94
  // Generate line path - curved or straight based on config
99
95
  const linePath = lineConfig.curved
100
- ? (0, exports.generateCurvedPath)(pathPoints)
96
+ ? generateCurvedPath(pathPoints)
101
97
  : `M ${pathPoints.map(([x, y]) => `${x},${y}`).join(' L ')}`;
102
98
  // Generate fill path if needed
103
99
  let fillPath = '';
104
100
  if (lineConfig.fill) {
105
101
  // For fill, extend to the bottom of the chart (full height)
106
102
  fillPath = lineConfig.curved
107
- ? `${(0, exports.generateCurvedPath)(pathPoints)} L ${width} ${height} L 0 ${height} Z`
103
+ ? `${generateCurvedPath(pathPoints)} L ${width} ${height} L 0 ${height} Z`
108
104
  : `${linePath} L ${width},${height} L 0,${height} Z`;
109
105
  }
110
106
  return {
@@ -114,4 +110,3 @@ const calculateLinesPathData = (data, lines, width, height) => {
114
110
  };
115
111
  });
116
112
  };
117
- exports.calculateLinesPathData = calculateLinesPathData;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFullRange = exports.createDefaultRange = exports.clampRange = exports.mouseToDataIndex = exports.calculateHandlerPositions = void 0;
4
1
  /**
5
2
  * Range operations and position calculation utilities for ZoomArea
6
3
  */
@@ -12,12 +9,11 @@ exports.isFullRange = exports.createDefaultRange = exports.clampRange = exports.
12
9
  * @param width - Canvas width for scaling
13
10
  * @returns Object with startX and endX positions
14
11
  */
15
- const calculateHandlerPositions = (currentRange, dataLength, width) => {
12
+ export const calculateHandlerPositions = (currentRange, dataLength, width) => {
16
13
  const startX = (currentRange.start / Math.max(1, dataLength - 1)) * width;
17
14
  const endX = (currentRange.end / Math.max(1, dataLength - 1)) * width;
18
15
  return { endX, startX };
19
16
  };
20
- exports.calculateHandlerPositions = calculateHandlerPositions;
21
17
  /**
22
18
  * Converts mouse position to continuous data index
23
19
  *
@@ -26,12 +22,11 @@ exports.calculateHandlerPositions = calculateHandlerPositions;
26
22
  * @param dataLength - Total length of the dataset
27
23
  * @returns Data index
28
24
  */
29
- const mouseToDataIndex = (mouseX, width, dataLength) => {
25
+ export const mouseToDataIndex = (mouseX, width, dataLength) => {
30
26
  const relativeX = Math.max(0, Math.min(width, mouseX));
31
27
  const normalizedPosition = relativeX / width;
32
28
  return Math.round(normalizedPosition * (dataLength - 1));
33
29
  };
34
- exports.mouseToDataIndex = mouseToDataIndex;
35
30
  /**
36
31
  * Clamps a range to valid bounds
37
32
  *
@@ -40,7 +35,7 @@ exports.mouseToDataIndex = mouseToDataIndex;
40
35
  * @param minDistance - Minimum distance between start and end (default: 0.1)
41
36
  * @returns Clamped range within valid bounds
42
37
  */
43
- const clampRange = (range, dataLength, minDistance = 0.1) => {
38
+ export const clampRange = (range, dataLength, minDistance = 0.1) => {
44
39
  const clampedStart = Math.max(0, Math.min(range.start, dataLength - 1 - minDistance));
45
40
  const clampedEnd = Math.min(dataLength - 1, Math.max(range.end, clampedStart + minDistance));
46
41
  return {
@@ -48,18 +43,16 @@ const clampRange = (range, dataLength, minDistance = 0.1) => {
48
43
  start: clampedStart,
49
44
  };
50
45
  };
51
- exports.clampRange = clampRange;
52
46
  /**
53
47
  * Creates a default range for the given data length
54
48
  *
55
49
  * @param dataLength - Total length of the dataset
56
50
  * @returns Default range covering the full dataset
57
51
  */
58
- const createDefaultRange = (dataLength) => ({
52
+ export const createDefaultRange = (dataLength) => ({
59
53
  end: Math.max(0, dataLength - 1),
60
54
  start: 0,
61
55
  });
62
- exports.createDefaultRange = createDefaultRange;
63
56
  /**
64
57
  * Determines if the current range covers the full dataset.
65
58
  * According to design specs: overlay is "only visible when a range is defined".
@@ -77,7 +70,6 @@ exports.createDefaultRange = createDefaultRange;
77
70
  * isFullRange({ start: 0, end: 7 }, 10); // false - partial selection
78
71
  * ```
79
72
  */
80
- const isFullRange = (range, dataLength) => {
73
+ export const isFullRange = (range, dataLength) => {
81
74
  return range.start === 0 && range.end === dataLength - 1;
82
75
  };
83
- exports.isFullRange = isFullRange;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSelectionConfig = void 0;
4
1
  /**
5
2
  * Default configuration for ZoomArea selection area
6
3
  */
@@ -23,11 +20,10 @@ const DEFAULT_SELECTION_CONFIG = {
23
20
  * @param config - Optional user configuration
24
21
  * @returns Complete selection configuration with defaults applied
25
22
  */
26
- const getSelectionConfig = (config) => ({
23
+ export const getSelectionConfig = (config) => ({
27
24
  fill: config?.fill ?? DEFAULT_SELECTION_CONFIG.FILL,
28
25
  fillOpacity: config?.fillOpacity ?? DEFAULT_SELECTION_CONFIG.FILL_OPACITY,
29
26
  hideOverlayOnFullRange: config?.hideOverlayOnFullRange ?? DEFAULT_SELECTION_CONFIG.HIDE_OVERLAY_ON_FULL_RANGE,
30
27
  stroke: config?.stroke ?? DEFAULT_SELECTION_CONFIG.STROKE,
31
28
  strokeWidth: config?.strokeWidth ?? DEFAULT_SELECTION_CONFIG.STROKE_WIDTH,
32
29
  });
33
- exports.getSelectionConfig = getSelectionConfig;
@@ -1,25 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZoomArea = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const svgContainer_1 = require("../../components/svgContainer/svgContainer");
7
- const calculateFocusOutline_1 = require("../../utils/calculateFocusOutline/calculateFocusOutline");
8
- const getDataFingerprint_1 = require("../../utils/getDataFingerprint/getDataFingerprint");
9
- const LineRenderer_1 = require("./components/LineRenderer");
10
- const SelectionArea_1 = require("./components/SelectionArea");
11
- const ZoomHandler_1 = require("./components/ZoomHandler");
12
- const useDragInteraction_1 = require("./hooks/useDragInteraction");
13
- const useKeyboardNavigation_1 = require("./hooks/useKeyboardNavigation");
14
- const useResponsiveCanvas_1 = require("./hooks/useResponsiveCanvas");
15
- const useZoomAreaFocus_1 = require("./hooks/useZoomAreaFocus");
16
- const useZoomData_1 = require("./hooks/useZoomData");
17
- const accessibilityLabels_1 = require("./utils/accessibilityLabels");
18
- const interactionConfig_1 = require("./utils/interactionConfig");
19
- const pathGeneration_1 = require("./utils/pathGeneration");
20
- const rangeAndPositions_1 = require("./utils/rangeAndPositions");
21
- const selectionConfig_1 = require("./utils/selectionConfig");
22
- const zoomArea_type_1 = require("./zoomArea.type");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { SvgContainer } from '../../components/svgContainer/svgContainer';
4
+ import { getFocusConfig } from '../../utils/calculateFocusOutline/calculateFocusOutline';
5
+ import { getDataFingerprint } from '../../utils/getDataFingerprint/getDataFingerprint';
6
+ import { LineRenderer } from './components/LineRenderer';
7
+ import { SelectionArea, SelectionAreaFocusRing } from './components/SelectionArea';
8
+ import { ZoomHandler } from './components/ZoomHandler';
9
+ import { useDragInteraction } from './hooks/useDragInteraction';
10
+ import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
11
+ import { useResponsiveCanvas } from './hooks/useResponsiveCanvas';
12
+ import { useZoomAreaFocus } from './hooks/useZoomAreaFocus';
13
+ import { useZoomData } from './hooks/useZoomData';
14
+ import { generateAccessibilityLabels } from './utils/accessibilityLabels';
15
+ import { getInteractionConfig } from './utils/interactionConfig';
16
+ import { calculateLinesPathData } from './utils/pathGeneration';
17
+ import { calculateHandlerPositions } from './utils/rangeAndPositions';
18
+ import { getSelectionConfig } from './utils/selectionConfig';
19
+ import { ZoomAreaElements } from './zoomArea.type';
23
20
  /**
24
21
  * `ZoomArea` component that renders a scaled chart with draggable zoom handlers for interactive data filtering.
25
22
  *
@@ -29,56 +26,55 @@ const zoomArea_type_1 = require("./zoomArea.type");
29
26
  *
30
27
  * @returns A React functional component that renders an SVG-based zoom area with interactive handlers and accessibility features.
31
28
  */
32
- const ZoomArea = ({ ariaHidden, ariaLabel, backgroundColor, canvasConfig, // Optional - auto-calculated based on width/height if not provided
29
+ export const ZoomArea = ({ ariaHidden, ariaLabel, backgroundColor, canvasConfig, // Optional - auto-calculated based on width/height if not provided
33
30
  caption, classNames, data, focusConfig, handlerConfig, height = '40px', // 2.5rem, defined by size_400 token in Figma
34
31
  initialRange, interactionConfig, lines, onDataChange, role, screenReaderTextConfig, selectionConfig, width = '100%', xKey, ...eventHandlers }) => {
35
32
  const dataTestId = 'zoom-area';
36
33
  // Resolve interaction config with defaults
37
- const resolvedInteractionConfig = (0, interactionConfig_1.getInteractionConfig)(interactionConfig);
34
+ const resolvedInteractionConfig = getInteractionConfig(interactionConfig);
38
35
  // Resolve selection config with defaults
39
- const resolvedSelectionConfig = (0, selectionConfig_1.getSelectionConfig)(selectionConfig);
36
+ const resolvedSelectionConfig = getSelectionConfig(selectionConfig);
40
37
  // Resolve focus config with defaults
41
- const resolvedFocusConfig = (0, calculateFocusOutline_1.getFocusConfig)(focusConfig);
38
+ const resolvedFocusConfig = getFocusConfig(focusConfig);
42
39
  // Hook for core data filtering functionality
43
- const { currentRange, handleRangeChange } = (0, useZoomData_1.useZoomData)({
40
+ const { currentRange, handleRangeChange } = useZoomData({
44
41
  data,
45
42
  initialRange,
46
43
  onDataChange,
47
44
  });
48
45
  // Hook for responsive dimensions of the component when set as percentage
49
- const { parsedCanvas, viewBox } = (0, useResponsiveCanvas_1.useResponsiveCanvas)({
46
+ const { parsedCanvas, viewBox } = useResponsiveCanvas({
50
47
  canvasConfig,
51
48
  dataTestId,
52
49
  height,
53
50
  width,
54
51
  });
55
52
  // Create a fingerprint of the data/lines to avoid unnecessary updates
56
- const dataFingerprint = (0, getDataFingerprint_1.getDataFingerprint)(data);
53
+ const dataFingerprint = getDataFingerprint(data);
57
54
  const linesFingerprint = JSON.stringify(lines);
58
- const accessibilityLabels = (0, accessibilityLabels_1.generateAccessibilityLabels)(data, xKey, currentRange, screenReaderTextConfig);
55
+ const accessibilityLabels = generateAccessibilityLabels(data, xKey, currentRange, screenReaderTextConfig);
59
56
  // Memoize expensive line calculations
60
- const linesData = (0, react_1.useMemo)(() => {
61
- return (0, pathGeneration_1.calculateLinesPathData)(data, lines, parsedCanvas.width, parsedCanvas.height);
57
+ const linesData = useMemo(() => {
58
+ return calculateLinesPathData(data, lines, parsedCanvas.width, parsedCanvas.height);
62
59
  }, [dataFingerprint, linesFingerprint, parsedCanvas.width, parsedCanvas.height]);
63
60
  // Memoize handler positions calculation
64
- const { endX, startX } = (0, react_1.useMemo)(() => (0, rangeAndPositions_1.calculateHandlerPositions)(currentRange, data.length, parsedCanvas.width), [currentRange, dataFingerprint, parsedCanvas.width]);
61
+ const { endX, startX } = useMemo(() => calculateHandlerPositions(currentRange, data.length, parsedCanvas.width), [currentRange, dataFingerprint, parsedCanvas.width]);
65
62
  // Interaction hooks
66
- const { handleBlur, handleFocus, isFocused } = (0, useZoomAreaFocus_1.useZoomAreaFocus)();
67
- const { handleKeyDown } = (0, useKeyboardNavigation_1.useKeyboardNavigation)({
63
+ const { handleBlur, handleFocus, isFocused } = useZoomAreaFocus();
64
+ const { handleKeyDown } = useKeyboardNavigation({
68
65
  currentRange,
69
66
  dataLength: data.length,
70
67
  interactionConfig: resolvedInteractionConfig,
71
68
  onRangeChange: handleRangeChange,
72
69
  });
73
- const { groupRef, handleMouseDown, handleTouchStart } = (0, useDragInteraction_1.useDragInteraction)({
70
+ const { groupRef, handleMouseDown, handleTouchStart } = useDragInteraction({
74
71
  currentRange,
75
72
  dataLength: data.length,
76
73
  interactionConfig: resolvedInteractionConfig,
77
74
  onRangeChange: handleRangeChange,
78
75
  width: parsedCanvas.width,
79
76
  });
80
- return ((0, jsx_runtime_1.jsxs)(svgContainer_1.SvgContainer, { ref: groupRef, ariaHidden: ariaHidden, ariaLabel: ariaLabel, backgroundColor: backgroundColor, caption: caption, className: classNames, "data-testid": dataTestId, height: height,
77
+ return (_jsxs(SvgContainer, { ref: groupRef, ariaHidden: ariaHidden, ariaLabel: ariaLabel, backgroundColor: backgroundColor, caption: caption, className: classNames, "data-testid": dataTestId, height: height,
81
78
  // set overflow visible so handlers and focus rings are visible always
82
- overflow: "visible", role: role, viewBox: viewBox, width: width, ...eventHandlers, children: [(0, jsx_runtime_1.jsx)(LineRenderer_1.LineRenderer, { linesData: linesData }), (0, jsx_runtime_1.jsx)(SelectionArea_1.SelectionArea, { currentRange: currentRange, dataLength: data.length, dataTestId: `${dataTestId}-selection-area`, endX: endX, height: parsedCanvas.height, screenReaderText: accessibilityLabels.selectionArea, selectionConfig: resolvedSelectionConfig, startX: startX, onBlur: handleBlur, onFocus: handleFocus(zoomArea_type_1.ZoomAreaElements.SELECTION_AREA), onKeyDown: handleKeyDown(zoomArea_type_1.ZoomAreaElements.SELECTION_AREA), onMouseDown: handleMouseDown(zoomArea_type_1.ZoomAreaElements.SELECTION_AREA), onTouchStart: handleTouchStart(zoomArea_type_1.ZoomAreaElements.SELECTION_AREA) }), (0, jsx_runtime_1.jsx)(ZoomHandler_1.ZoomHandler, { dataTestId: `${dataTestId}-start-handler`, focusConfig: resolvedFocusConfig, handlerConfig: handlerConfig, height: parsedCanvas.height, isFocused: isFocused(zoomArea_type_1.ZoomAreaElements.START_HANDLER), max: currentRange.end - resolvedInteractionConfig.minHandlerDistance, min: 0, screenReaderText: accessibilityLabels.startHandler, type: zoomArea_type_1.ZoomAreaElements.START_HANDLER, value: currentRange.start, x: startX, onBlur: handleBlur, onFocus: handleFocus(zoomArea_type_1.ZoomAreaElements.START_HANDLER), onKeyDown: handleKeyDown(zoomArea_type_1.ZoomAreaElements.START_HANDLER), onMouseDown: handleMouseDown(zoomArea_type_1.ZoomAreaElements.START_HANDLER), onTouchStart: handleTouchStart(zoomArea_type_1.ZoomAreaElements.START_HANDLER) }), (0, jsx_runtime_1.jsx)(ZoomHandler_1.ZoomHandler, { dataTestId: `${dataTestId}-end-handler`, focusConfig: resolvedFocusConfig, handlerConfig: handlerConfig, height: parsedCanvas.height, isFocused: isFocused(zoomArea_type_1.ZoomAreaElements.END_HANDLER), max: data.length - 1, min: currentRange.start + resolvedInteractionConfig.minHandlerDistance, screenReaderText: accessibilityLabels.endHandler, type: zoomArea_type_1.ZoomAreaElements.END_HANDLER, value: currentRange.end, x: endX, onBlur: handleBlur, onFocus: handleFocus(zoomArea_type_1.ZoomAreaElements.END_HANDLER), onKeyDown: handleKeyDown(zoomArea_type_1.ZoomAreaElements.END_HANDLER), onMouseDown: handleMouseDown(zoomArea_type_1.ZoomAreaElements.END_HANDLER), onTouchStart: handleTouchStart(zoomArea_type_1.ZoomAreaElements.END_HANDLER) }), (0, jsx_runtime_1.jsx)(SelectionArea_1.SelectionAreaFocusRing, { endX: endX, focusConfig: resolvedFocusConfig, height: parsedCanvas.height, isFocused: isFocused(zoomArea_type_1.ZoomAreaElements.SELECTION_AREA), startX: startX })] }));
79
+ overflow: "visible", role: role, viewBox: viewBox, width: width, ...eventHandlers, children: [_jsx(LineRenderer, { linesData: linesData }), _jsx(SelectionArea, { currentRange: currentRange, dataLength: data.length, dataTestId: `${dataTestId}-selection-area`, endX: endX, height: parsedCanvas.height, screenReaderText: accessibilityLabels.selectionArea, selectionConfig: resolvedSelectionConfig, startX: startX, onBlur: handleBlur, onFocus: handleFocus(ZoomAreaElements.SELECTION_AREA), onKeyDown: handleKeyDown(ZoomAreaElements.SELECTION_AREA), onMouseDown: handleMouseDown(ZoomAreaElements.SELECTION_AREA), onTouchStart: handleTouchStart(ZoomAreaElements.SELECTION_AREA) }), _jsx(ZoomHandler, { dataTestId: `${dataTestId}-start-handler`, focusConfig: resolvedFocusConfig, handlerConfig: handlerConfig, height: parsedCanvas.height, isFocused: isFocused(ZoomAreaElements.START_HANDLER), max: currentRange.end - resolvedInteractionConfig.minHandlerDistance, min: 0, screenReaderText: accessibilityLabels.startHandler, type: ZoomAreaElements.START_HANDLER, value: currentRange.start, x: startX, onBlur: handleBlur, onFocus: handleFocus(ZoomAreaElements.START_HANDLER), onKeyDown: handleKeyDown(ZoomAreaElements.START_HANDLER), onMouseDown: handleMouseDown(ZoomAreaElements.START_HANDLER), onTouchStart: handleTouchStart(ZoomAreaElements.START_HANDLER) }), _jsx(ZoomHandler, { dataTestId: `${dataTestId}-end-handler`, focusConfig: resolvedFocusConfig, handlerConfig: handlerConfig, height: parsedCanvas.height, isFocused: isFocused(ZoomAreaElements.END_HANDLER), max: data.length - 1, min: currentRange.start + resolvedInteractionConfig.minHandlerDistance, screenReaderText: accessibilityLabels.endHandler, type: ZoomAreaElements.END_HANDLER, value: currentRange.end, x: endX, onBlur: handleBlur, onFocus: handleFocus(ZoomAreaElements.END_HANDLER), onKeyDown: handleKeyDown(ZoomAreaElements.END_HANDLER), onMouseDown: handleMouseDown(ZoomAreaElements.END_HANDLER), onTouchStart: handleTouchStart(ZoomAreaElements.END_HANDLER) }), _jsx(SelectionAreaFocusRing, { endX: endX, focusConfig: resolvedFocusConfig, height: parsedCanvas.height, isFocused: isFocused(ZoomAreaElements.SELECTION_AREA), startX: startX })] }));
83
80
  };
84
- exports.ZoomArea = ZoomArea;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZoomAreaElements = void 0;
4
1
  /**
5
2
  * Target enumeration for zoom area elements
6
3
  */
7
- exports.ZoomAreaElements = {
4
+ export const ZoomAreaElements = {
8
5
  END_HANDLER: 'END_HANDLER',
9
6
  SELECTION_AREA: 'SELECTION_AREA',
10
7
  START_HANDLER: 'START_HANDLER',
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./useFocus/useFocus"), exports);
18
- __exportStar(require("./useHover/useHover"), exports);
1
+ export * from './useFocus/useFocus';
2
+ export * from './useHover/useHover';
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFocus = void 0;
4
- const react_1 = require("react");
1
+ import { useCallback, useState } from 'react';
5
2
  /**
6
3
  * Custom React hook to manage focus state and handle focus/blur events for an element.
7
4
  *
@@ -14,16 +11,15 @@ const react_1 = require("react");
14
11
  * @param onBlur - An optional custom blur event handler of type `FocusHandler<T>`. It is called when the element loses focus.
15
12
  * @returns An object of type `UseFocusReturn<T>` containing the focus state (`isFocused`), and functions to handle focus (`handleFocus`) and blur (`handleBlur`) events.
16
13
  */
17
- const useFocus = (onFocus, onBlur) => {
18
- const [isFocused, setIsFocused] = (0, react_1.useState)(false);
19
- const handleFocus = (0, react_1.useCallback)((event) => {
14
+ export const useFocus = (onFocus, onBlur) => {
15
+ const [isFocused, setIsFocused] = useState(false);
16
+ const handleFocus = useCallback((event) => {
20
17
  setIsFocused(true);
21
18
  onFocus?.(event);
22
19
  }, [onFocus]);
23
- const handleBlur = (0, react_1.useCallback)((event) => {
20
+ const handleBlur = useCallback((event) => {
24
21
  setIsFocused(false);
25
22
  onBlur?.(event);
26
23
  }, [onBlur]);
27
24
  return { handleBlur, handleFocus, isFocused };
28
25
  };
29
- exports.useFocus = useFocus;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useHover = void 0;
4
- const react_1 = require("react");
1
+ import { useCallback, useState } from 'react';
5
2
  /**
6
3
  * A custom hook that manages hover state and provides event handlers for mouse enter and leave events,
7
4
  * with optional custom handlers. It returns the hover state and functions to handle mouse enter and leave events,
@@ -12,13 +9,13 @@ const react_1 = require("react");
12
9
  * @param onMouseLeave - An optional custom mouse leave event handler of type `MouseHandler<T>`. It is called when the element is no longer hovered.
13
10
  * @returns An object of type `UseHoverReturn<T>` containing the hover state (`isHovered`), and functions to handle mouse enter (`handleMouseEnter`) and leave (`handleMouseLeave`) events.
14
11
  */
15
- const useHover = (onMouseEnter, onMouseLeave) => {
16
- const [isHovered, setIsHovered] = (0, react_1.useState)(false);
17
- const handleMouseEnter = (0, react_1.useCallback)((event) => {
12
+ export const useHover = (onMouseEnter, onMouseLeave) => {
13
+ const [isHovered, setIsHovered] = useState(false);
14
+ const handleMouseEnter = useCallback((event) => {
18
15
  setIsHovered(true);
19
16
  onMouseEnter?.(event);
20
17
  }, [onMouseEnter]);
21
- const handleMouseLeave = (0, react_1.useCallback)((event) => {
18
+ const handleMouseLeave = useCallback((event) => {
22
19
  setIsHovered(false);
23
20
  onMouseLeave?.(event);
24
21
  }, [onMouseLeave]);
@@ -28,4 +25,3 @@ const useHover = (onMouseEnter, onMouseLeave) => {
28
25
  isHovered,
29
26
  };
30
27
  };
31
- exports.useHover = useHover;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/cjs/index.js CHANGED
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./charts"), exports);
18
- __exportStar(require("./components"), exports);
19
- __exportStar(require("./types"), exports);
1
+ export * from './charts';
2
+ export * from './components';
3
+ export * from './types';
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultCanvasConfig = void 0;
4
1
  /**
5
2
  * Provides default configuration for a canvas element.
6
3
  *
7
4
  * This configuration sets the canvas width to 100 pixels, height to 80 pixels,
8
5
  * and includes no additional extra space around the canvas by default.
9
6
  */
10
- exports.DefaultCanvasConfig = {
7
+ export const DefaultCanvasConfig = {
11
8
  extraSpace: 0,
12
9
  height: 80,
13
10
  width: 100,
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorType = void 0;
4
- exports.ErrorType = {
1
+ export const ErrorType = {
5
2
  GENERIC: 'GENERIC',
6
3
  };
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FOCUS_DEFAULT = void 0;
4
- exports.FOCUS_DEFAULT = {
1
+ export const FOCUS_DEFAULT = {
5
2
  /** Focus ring color */
6
3
  FOCUS_COLOR: '#0078D4',
7
4
  /** Focus ring inner border */
@@ -1,20 +1,4 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./canvas.type"), exports);
18
- __exportStar(require("./errors.type"), exports);
19
- __exportStar(require("./focusConfig.type"), exports);
20
- __exportStar(require("./position.enum"), exports);
1
+ export * from './canvas.type';
2
+ export * from './errors.type';
3
+ export * from './focusConfig.type';
4
+ export * from './position.enum';
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * Enum for specifying the position of elements or components.
4
3
  *
@@ -8,9 +7,7 @@
8
7
  *
9
8
  * @enum {string}
10
9
  */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Positions = void 0;
13
- exports.Positions = {
10
+ export const Positions = {
14
11
  BOTTOM: 'BOTTOM',
15
12
  CENTER: 'CENTER',
16
13
  CUSTOM: 'CUSTOM',
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Unit = void 0;
4
1
  /**
5
2
  * Enumeration representing units of measurement that need some transformation to pixels (px).
6
3
  *
@@ -8,7 +5,7 @@ exports.Unit = void 0;
8
5
  * @property {string} PERCENTAGE - Represents a percentage unit ('%').
9
6
  * @property {string} REM - Represents a rem unit ('rem')
10
7
  */
11
- exports.Unit = {
8
+ export const Unit = {
12
9
  PERCENTAGE: '%',
13
10
  REM: 'rem',
14
11
  };
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ajustedTextSpace = void 0;
4
- const ajustedTextSpace = (textAnchor, value, extra) => {
1
+ export const ajustedTextSpace = (textAnchor, value, extra) => {
5
2
  let ajusted = 0;
6
3
  switch (textAnchor) {
7
4
  case 'middle':
@@ -16,4 +13,3 @@ const ajustedTextSpace = (textAnchor, value, extra) => {
16
13
  }
17
14
  return ajusted;
18
15
  };
19
- exports.ajustedTextSpace = ajustedTextSpace;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildError = exports.ErrorsRecord = exports.BuildError = void 0;
4
- exports.BuildError = {
1
+ export const BuildError = {
5
2
  INVALID_X_TICK: 'INVALID_X_TICK',
6
3
  };
7
4
  const INVALID_X_TICK_ERROR = '[getXTicks] Invalid X tick values calculated';
8
- exports.ErrorsRecord = {
5
+ export const ErrorsRecord = {
9
6
  INVALID_X_TICK: new Error(INVALID_X_TICK_ERROR),
10
7
  };
11
- const buildError = (error) => exports.ErrorsRecord[error];
12
- exports.buildError = buildError;
8
+ export const buildError = (error) => ErrorsRecord[error];