@kubit-ui-web/react-charts 1.0.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 (178) hide show
  1. package/README.md +2 -0
  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/package.json +31 -33
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZoomHandler = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const calculateFocusOutline_1 = require("../../../utils/calculateFocusOutline/calculateFocusOutline");
6
- const HandlerIcon_1 = require("./HandlerIcon");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { calculateFocusOutline } from '../../../utils/calculateFocusOutline/calculateFocusOutline';
3
+ import { HandlerIcon } from './HandlerIcon';
7
4
  /**
8
5
  * Default colors for zoom handlers
9
6
  */
@@ -42,11 +39,11 @@ const getHandlerStyles = (handlerConfig) => ({
42
39
  /**
43
40
  * Individual zoom handler with line, circle, and icon
44
41
  */
45
- const ZoomHandler = ({ dataTestId, focusConfig, handlerConfig, height, isFocused, max, min, onBlur, onFocus, onKeyDown, onMouseDown, onTouchStart, screenReaderText, x, }) => {
42
+ export const ZoomHandler = ({ dataTestId, focusConfig, handlerConfig, height, isFocused, max, min, onBlur, onFocus, onKeyDown, onMouseDown, onTouchStart, screenReaderText, x, }) => {
46
43
  const centerY = height / 2;
47
44
  const styles = getHandlerStyles(handlerConfig);
48
45
  // Calculate focus ring dimensions using the new util
49
- const focusOutline = (0, calculateFocusOutline_1.calculateFocusOutline)({
46
+ const focusOutline = calculateFocusOutline({
50
47
  elementHeight: styles.radius * 2,
51
48
  elementPosition: { x, y: centerY },
52
49
  elementStrokeWidth: typeof styles.strokeWidth === 'number'
@@ -58,6 +55,5 @@ const ZoomHandler = ({ dataTestId, focusConfig, handlerConfig, height, isFocused
58
55
  innerStrokeWidth: focusConfig.innerStrokeWidth,
59
56
  outlineStrokeWidth: focusConfig.outlineStrokeWidth,
60
57
  });
61
- return ((0, jsx_runtime_1.jsxs)("g", { "data-testid": `${dataTestId}-group`, children: [(0, jsx_runtime_1.jsx)("line", { pointerEvents: "none", stroke: styles.verticalLineStroke, strokeWidth: styles.verticalLineStrokeWidth, x1: x, x2: x, y1: 0, y2: height }), (0, jsx_runtime_1.jsx)("circle", { "aria-label": screenReaderText, "aria-valuemax": max, "aria-valuemin": min, "aria-valuetext": screenReaderText, cursor: "ew-resize", cx: x, cy: centerY, "data-testid": dataTestId, fill: styles.fill, r: styles.radius, role: "slider", stroke: styles.stroke, strokeWidth: styles.strokeWidth, style: { outline: 'none' }, tabIndex: 0, onBlur: onBlur, onFocus: onFocus, onKeyDown: onKeyDown, onMouseDown: onMouseDown, onTouchStart: onTouchStart }), (0, jsx_runtime_1.jsx)(HandlerIcon_1.HandlerIcon, { fill: styles.iconColor, x: x, y: centerY }), isFocused && focusOutline.type === 'circle' && ((0, jsx_runtime_1.jsxs)("g", { pointerEvents: "none", children: [(0, jsx_runtime_1.jsx)("circle", { cx: focusOutline.outer.cx, cy: focusOutline.outer.cy, fill: "none", r: focusOutline.outer.r, stroke: focusConfig.outlineColor, strokeWidth: focusConfig.outlineStrokeWidth }), (0, jsx_runtime_1.jsx)("circle", { cx: focusOutline.inner.cx, cy: focusOutline.inner.cy, fill: "none", r: focusOutline.inner.r, stroke: focusConfig.innerColor, strokeWidth: focusConfig.innerStrokeWidth })] }))] }));
58
+ return (_jsxs("g", { "data-testid": `${dataTestId}-group`, children: [_jsx("line", { pointerEvents: "none", stroke: styles.verticalLineStroke, strokeWidth: styles.verticalLineStrokeWidth, x1: x, x2: x, y1: 0, y2: height }), _jsx("circle", { "aria-label": screenReaderText, "aria-valuemax": max, "aria-valuemin": min, "aria-valuetext": screenReaderText, cursor: "ew-resize", cx: x, cy: centerY, "data-testid": dataTestId, fill: styles.fill, r: styles.radius, role: "slider", stroke: styles.stroke, strokeWidth: styles.strokeWidth, style: { outline: 'none' }, tabIndex: 0, onBlur: onBlur, onFocus: onFocus, onKeyDown: onKeyDown, onMouseDown: onMouseDown, onTouchStart: onTouchStart }), _jsx(HandlerIcon, { fill: styles.iconColor, x: x, y: centerY }), isFocused && focusOutline.type === 'circle' && (_jsxs("g", { pointerEvents: "none", children: [_jsx("circle", { cx: focusOutline.outer.cx, cy: focusOutline.outer.cy, fill: "none", r: focusOutline.outer.r, stroke: focusConfig.outlineColor, strokeWidth: focusConfig.outlineStrokeWidth }), _jsx("circle", { cx: focusOutline.inner.cx, cy: focusOutline.inner.cy, fill: "none", r: focusOutline.inner.r, stroke: focusConfig.innerColor, strokeWidth: focusConfig.innerStrokeWidth })] }))] }));
62
59
  };
63
- exports.ZoomHandler = ZoomHandler;
@@ -1,12 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZoomHandler = exports.SelectionAreaFocusRing = exports.SelectionArea = exports.LineRenderer = exports.HandlerIcon = void 0;
4
- var HandlerIcon_1 = require("./HandlerIcon");
5
- Object.defineProperty(exports, "HandlerIcon", { enumerable: true, get: function () { return HandlerIcon_1.HandlerIcon; } });
6
- var LineRenderer_1 = require("./LineRenderer");
7
- Object.defineProperty(exports, "LineRenderer", { enumerable: true, get: function () { return LineRenderer_1.LineRenderer; } });
8
- var SelectionArea_1 = require("./SelectionArea");
9
- Object.defineProperty(exports, "SelectionArea", { enumerable: true, get: function () { return SelectionArea_1.SelectionArea; } });
10
- Object.defineProperty(exports, "SelectionAreaFocusRing", { enumerable: true, get: function () { return SelectionArea_1.SelectionAreaFocusRing; } });
11
- var ZoomHandler_1 = require("./ZoomHandler");
12
- Object.defineProperty(exports, "ZoomHandler", { enumerable: true, get: function () { return ZoomHandler_1.ZoomHandler; } });
1
+ export { HandlerIcon } from './HandlerIcon';
2
+ export { LineRenderer } from './LineRenderer';
3
+ export { SelectionArea, SelectionAreaFocusRing } from './SelectionArea';
4
+ export { ZoomHandler } from './ZoomHandler';
@@ -1,13 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useZoomData = exports.useZoomAreaFocus = exports.useResponsiveCanvas = exports.useKeyboardNavigation = exports.useDragInteraction = void 0;
4
- var useDragInteraction_1 = require("./useDragInteraction");
5
- Object.defineProperty(exports, "useDragInteraction", { enumerable: true, get: function () { return useDragInteraction_1.useDragInteraction; } });
6
- var useKeyboardNavigation_1 = require("./useKeyboardNavigation");
7
- Object.defineProperty(exports, "useKeyboardNavigation", { enumerable: true, get: function () { return useKeyboardNavigation_1.useKeyboardNavigation; } });
8
- var useResponsiveCanvas_1 = require("./useResponsiveCanvas");
9
- Object.defineProperty(exports, "useResponsiveCanvas", { enumerable: true, get: function () { return useResponsiveCanvas_1.useResponsiveCanvas; } });
10
- var useZoomAreaFocus_1 = require("./useZoomAreaFocus");
11
- Object.defineProperty(exports, "useZoomAreaFocus", { enumerable: true, get: function () { return useZoomAreaFocus_1.useZoomAreaFocus; } });
12
- var useZoomData_1 = require("./useZoomData");
13
- Object.defineProperty(exports, "useZoomData", { enumerable: true, get: function () { return useZoomData_1.useZoomData; } });
1
+ export { useDragInteraction } from './useDragInteraction';
2
+ export { useKeyboardNavigation } from './useKeyboardNavigation';
3
+ export { useResponsiveCanvas } from './useResponsiveCanvas';
4
+ export { useZoomAreaFocus } from './useZoomAreaFocus';
5
+ export { useZoomData } from './useZoomData';
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useDragInteraction = void 0;
4
- const react_1 = require("react");
5
- const rangeAndPositions_1 = require("../utils/rangeAndPositions");
6
- const zoomArea_type_1 = require("../zoomArea.type");
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { clampRange, mouseToDataIndex } from '../utils/rangeAndPositions';
3
+ import { ZoomAreaElements } from '../zoomArea.type';
7
4
  /**
8
5
  * Calculate new range based on drag type and pointer position
9
6
  */
10
7
  const calculateNewRange = (dragType, currentRange, dataIndex, dataLength, interactionConfig) => {
11
8
  const newRange = { ...currentRange };
12
- if (dragType === zoomArea_type_1.ZoomAreaElements.START_HANDLER) {
9
+ if (dragType === ZoomAreaElements.START_HANDLER) {
13
10
  newRange.start = Math.max(0, Math.min(dataIndex, currentRange.end - interactionConfig.minHandlerDistance));
14
11
  }
15
- else if (dragType === zoomArea_type_1.ZoomAreaElements.END_HANDLER) {
12
+ else if (dragType === ZoomAreaElements.END_HANDLER) {
16
13
  newRange.end = Math.min(dataLength - 1, Math.max(dataIndex, currentRange.start + interactionConfig.minHandlerDistance));
17
14
  }
18
- else if (dragType === zoomArea_type_1.ZoomAreaElements.SELECTION_AREA) {
15
+ else if (dragType === ZoomAreaElements.SELECTION_AREA) {
19
16
  // Moving entire selection
20
17
  const selectionWidth = currentRange.end - currentRange.start;
21
18
  const newStart = Math.max(0, Math.min(dataLength - 1 - selectionWidth, dataIndex - selectionWidth / 2));
@@ -34,22 +31,22 @@ const calculateNewRange = (dragType, currentRange, dataIndex, dataLength, intera
34
31
  * @param params - Configuration parameters for drag functionality
35
32
  * @returns Object with drag handlers and state
36
33
  */
37
- const useDragInteraction = (params) => {
34
+ export const useDragInteraction = (params) => {
38
35
  const { currentRange, dataLength, interactionConfig, onRangeChange, width } = params;
39
- const groupRef = (0, react_1.useRef)(null);
40
- const [isDragging, setIsDragging] = (0, react_1.useState)(null);
41
- const handleMouseDown = (0, react_1.useCallback)((target) => {
36
+ const groupRef = useRef(null);
37
+ const [isDragging, setIsDragging] = useState(null);
38
+ const handleMouseDown = useCallback((target) => {
42
39
  return () => {
43
40
  setIsDragging(target);
44
41
  };
45
42
  }, []);
46
- const handleTouchStart = (0, react_1.useCallback)((target) => {
43
+ const handleTouchStart = useCallback((target) => {
47
44
  return () => {
48
45
  setIsDragging(target);
49
46
  };
50
47
  }, []);
51
48
  // Common logic for handling pointer movement (mouse or touch)
52
- const handlePointerMove = (0, react_1.useCallback)((clientX) => {
49
+ const handlePointerMove = useCallback((clientX) => {
53
50
  if (!isDragging || !groupRef.current) {
54
51
  return;
55
52
  }
@@ -62,15 +59,15 @@ const useDragInteraction = (params) => {
62
59
  const rect = svgElement.getBoundingClientRect();
63
60
  const pointerX = clientX - rect.left;
64
61
  // Convert pointer X to data index (0 to dataLength-1)
65
- const dataIndex = (0, rangeAndPositions_1.mouseToDataIndex)(pointerX, width, dataLength);
62
+ const dataIndex = mouseToDataIndex(pointerX, width, dataLength);
66
63
  const newRange = calculateNewRange(isDragging, currentRange, dataIndex, dataLength, interactionConfig);
67
- const clampedRange = (0, rangeAndPositions_1.clampRange)(newRange, dataLength, interactionConfig.minHandlerDistance);
64
+ const clampedRange = clampRange(newRange, dataLength, interactionConfig.minHandlerDistance);
68
65
  onRangeChange(clampedRange);
69
66
  }, [isDragging, width, dataLength, currentRange, onRangeChange, interactionConfig]);
70
- const handleMouseMove = (0, react_1.useCallback)((event) => {
67
+ const handleMouseMove = useCallback((event) => {
71
68
  handlePointerMove(event.clientX);
72
69
  }, [handlePointerMove]);
73
- const handleTouchMove = (0, react_1.useCallback)((event) => {
70
+ const handleTouchMove = useCallback((event) => {
74
71
  if (event.touches.length === 0) {
75
72
  return;
76
73
  }
@@ -78,14 +75,14 @@ const useDragInteraction = (params) => {
78
75
  event.preventDefault();
79
76
  handlePointerMove(event.touches[0].clientX);
80
77
  }, [handlePointerMove]);
81
- const handleMouseUp = (0, react_1.useCallback)(() => {
78
+ const handleMouseUp = useCallback(() => {
82
79
  setIsDragging(null);
83
80
  }, []);
84
- const handleTouchEnd = (0, react_1.useCallback)(() => {
81
+ const handleTouchEnd = useCallback(() => {
85
82
  setIsDragging(null);
86
83
  }, []);
87
84
  // Set up global mouse and touch events when dragging
88
- (0, react_1.useEffect)(() => {
85
+ useEffect(() => {
89
86
  if (isDragging) {
90
87
  // Mouse events
91
88
  document.addEventListener('mousemove', handleMouseMove);
@@ -111,4 +108,3 @@ const useDragInteraction = (params) => {
111
108
  isDragging,
112
109
  };
113
110
  };
114
- exports.useDragInteraction = useDragInteraction;
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useKeyboardNavigation = void 0;
4
- const react_1 = require("react");
5
- const rangeAndPositions_1 = require("../utils/rangeAndPositions");
6
- const zoomArea_type_1 = require("../zoomArea.type");
1
+ import { useCallback } from 'react';
2
+ import { clampRange } from '../utils/rangeAndPositions';
3
+ import { ZoomAreaElements } from '../zoomArea.type';
7
4
  /**
8
5
  * Handle left arrow and down arrow key movement (decrease values)
9
6
  */
10
7
  const handleArrowLeft = (target, currentRange, step, interactionConfig) => {
11
8
  const newRange = { ...currentRange };
12
- if (target === zoomArea_type_1.ZoomAreaElements.START_HANDLER) {
9
+ if (target === ZoomAreaElements.START_HANDLER) {
13
10
  newRange.start = Math.max(0, currentRange.start - step);
14
11
  }
15
- else if (target === zoomArea_type_1.ZoomAreaElements.END_HANDLER) {
12
+ else if (target === ZoomAreaElements.END_HANDLER) {
16
13
  newRange.end = Math.max(currentRange.start + interactionConfig.minHandlerDistance, currentRange.end - step);
17
14
  }
18
- else if (target === zoomArea_type_1.ZoomAreaElements.SELECTION_AREA) {
15
+ else if (target === ZoomAreaElements.SELECTION_AREA) {
19
16
  // Move entire selection left
20
17
  const selectionWidth = currentRange.end - currentRange.start;
21
18
  const newStart = Math.max(0, currentRange.start - step);
@@ -29,13 +26,13 @@ const handleArrowLeft = (target, currentRange, step, interactionConfig) => {
29
26
  */
30
27
  const handleArrowRight = (target, currentRange, step, dataLength, interactionConfig) => {
31
28
  const newRange = { ...currentRange };
32
- if (target === zoomArea_type_1.ZoomAreaElements.START_HANDLER) {
29
+ if (target === ZoomAreaElements.START_HANDLER) {
33
30
  newRange.start = Math.min(currentRange.end - interactionConfig.minHandlerDistance, currentRange.start + step);
34
31
  }
35
- else if (target === zoomArea_type_1.ZoomAreaElements.END_HANDLER) {
32
+ else if (target === ZoomAreaElements.END_HANDLER) {
36
33
  newRange.end = Math.min(dataLength - 1, currentRange.end + step);
37
34
  }
38
- else if (target === zoomArea_type_1.ZoomAreaElements.SELECTION_AREA) {
35
+ else if (target === ZoomAreaElements.SELECTION_AREA) {
39
36
  // Move entire selection right
40
37
  const selectionWidth = currentRange.end - currentRange.start;
41
38
  const newStart = Math.min(dataLength - 1 - selectionWidth, currentRange.start + step);
@@ -49,13 +46,13 @@ const handleArrowRight = (target, currentRange, step, dataLength, interactionCon
49
46
  */
50
47
  const handleHome = (target, currentRange, dataLength) => {
51
48
  const newRange = { ...currentRange };
52
- if (target === zoomArea_type_1.ZoomAreaElements.START_HANDLER) {
49
+ if (target === ZoomAreaElements.START_HANDLER) {
53
50
  newRange.start = 0;
54
51
  }
55
- else if (target === zoomArea_type_1.ZoomAreaElements.END_HANDLER) {
52
+ else if (target === ZoomAreaElements.END_HANDLER) {
56
53
  newRange.end = dataLength - 1;
57
54
  }
58
- else if (target === zoomArea_type_1.ZoomAreaElements.SELECTION_AREA) {
55
+ else if (target === ZoomAreaElements.SELECTION_AREA) {
59
56
  const selectionWidth = currentRange.end - currentRange.start;
60
57
  newRange.start = 0;
61
58
  newRange.end = selectionWidth;
@@ -67,13 +64,13 @@ const handleHome = (target, currentRange, dataLength) => {
67
64
  */
68
65
  const handleEnd = (target, currentRange, dataLength, interactionConfig) => {
69
66
  const newRange = { ...currentRange };
70
- if (target === zoomArea_type_1.ZoomAreaElements.START_HANDLER) {
67
+ if (target === ZoomAreaElements.START_HANDLER) {
71
68
  newRange.start = currentRange.end - interactionConfig.minHandlerDistance;
72
69
  }
73
- else if (target === zoomArea_type_1.ZoomAreaElements.END_HANDLER) {
70
+ else if (target === ZoomAreaElements.END_HANDLER) {
74
71
  newRange.end = dataLength - 1;
75
72
  }
76
- else if (target === zoomArea_type_1.ZoomAreaElements.SELECTION_AREA) {
73
+ else if (target === ZoomAreaElements.SELECTION_AREA) {
77
74
  const selectionWidth = currentRange.end - currentRange.start;
78
75
  newRange.start = dataLength - 1 - selectionWidth;
79
76
  newRange.end = dataLength - 1;
@@ -86,9 +83,9 @@ const handleEnd = (target, currentRange, dataLength, interactionConfig) => {
86
83
  * @param params - Configuration parameters for keyboard navigation
87
84
  * @returns Object with keyboard event handlers
88
85
  */
89
- const useKeyboardNavigation = (params) => {
86
+ export const useKeyboardNavigation = (params) => {
90
87
  const { currentRange, dataLength, interactionConfig, onRangeChange } = params;
91
- const handleKeyDown = (0, react_1.useCallback)((target) => {
88
+ const handleKeyDown = useCallback((target) => {
92
89
  return (event) => {
93
90
  // Shift key = fast navigation, normal keys = precise control
94
91
  const step = event.shiftKey
@@ -117,10 +114,9 @@ const useKeyboardNavigation = (params) => {
117
114
  default:
118
115
  return; // Don't handle other keys
119
116
  }
120
- const clampedRange = (0, rangeAndPositions_1.clampRange)(newRange, dataLength, interactionConfig.minHandlerDistance);
117
+ const clampedRange = clampRange(newRange, dataLength, interactionConfig.minHandlerDistance);
121
118
  onRangeChange(clampedRange);
122
119
  };
123
120
  }, [currentRange, dataLength, onRangeChange, interactionConfig]);
124
121
  return { handleKeyDown };
125
122
  };
126
- exports.useKeyboardNavigation = useKeyboardNavigation;
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useResponsiveCanvas = void 0;
4
- const react_1 = require("react");
5
- const buildViewBox_1 = require("../../../components/svgContainer/utils/buildViewBox/buildViewBox");
6
- const getCanvasDimensions_1 = require("../../../utils/getCanvasDimensions/getCanvasDimensions");
7
- const parseStringToNumberPx_1 = require("../../../utils/parseStringToNumberPx.ts/parseStringToNumberPx");
8
- const useResponsiveCanvas = ({ canvasConfig, dataTestId, extraSpace = 0, height, width, }) => {
1
+ import { useEffect, useMemo, useState } from 'react';
2
+ import { buildViewBox } from '../../../components/svgContainer/utils/buildViewBox/buildViewBox';
3
+ import { getCanvasDimensions } from '../../../utils/getCanvasDimensions/getCanvasDimensions';
4
+ import { parseStringToNumberPx } from '../../../utils/parseStringToNumberPx.ts/parseStringToNumberPx';
5
+ export const useResponsiveCanvas = ({ canvasConfig, dataTestId, extraSpace = 0, height, width, }) => {
9
6
  // State for parsed/calculated dimensions
10
- const [parsedCanvas, setParsedCanvas] = (0, react_1.useState)({
7
+ const [parsedCanvas, setParsedCanvas] = useState({
11
8
  height: 0,
12
9
  width: 0,
13
10
  });
14
11
  // Determine effective configuration (legacy vs modern API)
15
- const effectiveCanvasConfig = (0, react_1.useMemo)(() => {
12
+ const effectiveCanvasConfig = useMemo(() => {
16
13
  if (canvasConfig) {
17
14
  // Legacy mode: use provided canvasConfig
18
15
  return canvasConfig;
@@ -27,17 +24,17 @@ const useResponsiveCanvas = ({ canvasConfig, dataTestId, extraSpace = 0, height,
27
24
  // Extract and parse canvas configuration
28
25
  const { extraSpace: canvasExtraSpace, height: canvasHeight, width: canvasWidth, } = effectiveCanvasConfig;
29
26
  const parsedCanvasExtraSpace = canvasExtraSpace
30
- ? (0, parseStringToNumberPx_1.parseStringToNumberPx)(canvasExtraSpace)
27
+ ? parseStringToNumberPx(canvasExtraSpace)
31
28
  : undefined;
32
29
  // Set up responsive dimensions with ResizeObserver
33
- (0, react_1.useEffect)(() => {
30
+ useEffect(() => {
34
31
  // Find the SVG element for this specific component instance
35
32
  const svgElement = document.querySelector(`[data-testid="${dataTestId}"]`);
36
33
  if (!svgElement) {
37
34
  return;
38
35
  }
39
36
  const calculateDimensions = () => {
40
- const { parsedCanvasHeight, parsedCanvasWidth } = (0, getCanvasDimensions_1.getCanvasDimensions)({
37
+ const { parsedCanvasHeight, parsedCanvasWidth } = getCanvasDimensions({
41
38
  canvasHeight,
42
39
  canvasWidth,
43
40
  svgElement,
@@ -62,8 +59,8 @@ const useResponsiveCanvas = ({ canvasConfig, dataTestId, extraSpace = 0, height,
62
59
  };
63
60
  }, [canvasWidth, canvasHeight, dataTestId]);
64
61
  // Calculate viewBox based on parsed dimensions
65
- const viewBox = (0, react_1.useMemo)(() => {
66
- const calculatedViewBox = (0, buildViewBox_1.buildViewBox)(parsedCanvas.width, parsedCanvas.height, parsedCanvasExtraSpace);
62
+ const viewBox = useMemo(() => {
63
+ const calculatedViewBox = buildViewBox(parsedCanvas.width, parsedCanvas.height, parsedCanvasExtraSpace);
67
64
  return calculatedViewBox;
68
65
  }, [parsedCanvas.width, parsedCanvas.height, parsedCanvasExtraSpace]);
69
66
  return {
@@ -71,4 +68,3 @@ const useResponsiveCanvas = ({ canvasConfig, dataTestId, extraSpace = 0, height,
71
68
  viewBox,
72
69
  };
73
70
  };
74
- exports.useResponsiveCanvas = useResponsiveCanvas;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useZoomAreaFocus = void 0;
4
- const react_1 = require("react");
1
+ import { useCallback, useState } from 'react';
5
2
  /**
6
3
  * Custom hook for managing focus state of zoom area elements.
7
4
  *
@@ -11,16 +8,16 @@ const react_1 = require("react");
11
8
  * @param params - Configuration parameters for the hook
12
9
  * @returns Object with focus handlers and utilities
13
10
  */
14
- const useZoomAreaFocus = () => {
15
- const [focusedElement, setFocusedElement] = (0, react_1.useState)(null);
16
- const handleFocus = (0, react_1.useCallback)((target) => {
11
+ export const useZoomAreaFocus = () => {
12
+ const [focusedElement, setFocusedElement] = useState(null);
13
+ const handleFocus = useCallback((target) => {
17
14
  return () => setFocusedElement(target);
18
15
  }, []);
19
- const handleBlur = (0, react_1.useCallback)(() => {
16
+ const handleBlur = useCallback(() => {
20
17
  setFocusedElement(null);
21
18
  }, []);
22
19
  // Helper function to check focus state
23
- const isFocused = (0, react_1.useCallback)((target) => {
20
+ const isFocused = useCallback((target) => {
24
21
  return focusedElement === target;
25
22
  }, [focusedElement]);
26
23
  return {
@@ -29,4 +26,3 @@ const useZoomAreaFocus = () => {
29
26
  isFocused,
30
27
  };
31
28
  };
32
- exports.useZoomAreaFocus = useZoomAreaFocus;
@@ -1,20 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useZoomData = void 0;
4
- const react_1 = require("react");
5
- const indexRounding_1 = require("../utils/indexRounding");
6
- const rangeAndPositions_1 = require("../utils/rangeAndPositions");
7
- const useZoomData = ({ data, initialRange, onDataChange, }) => {
1
+ import { useEffect, useState } from 'react';
2
+ import { getRangeIndices } from '../utils/indexRounding';
3
+ import { createDefaultRange } from '../utils/rangeAndPositions';
4
+ export const useZoomData = ({ data, initialRange, onDataChange, }) => {
8
5
  // Initialize range state
9
- const defaultRange = initialRange || (0, rangeAndPositions_1.createDefaultRange)(data.length);
10
- const [currentRange, setCurrentRange] = (0, react_1.useState)(defaultRange);
6
+ const defaultRange = initialRange || createDefaultRange(data.length);
7
+ const [currentRange, setCurrentRange] = useState(defaultRange);
11
8
  // Filter data based on current range and emit changes
12
9
  const filterData = (range) => {
13
10
  if (!onDataChange || data.length === 0) {
14
11
  return;
15
12
  }
16
13
  // Use centralized rounding logic to ensure consistency with accessibility labels
17
- const { endIndex, startIndex } = (0, indexRounding_1.getRangeIndices)(range, data.length);
14
+ const { endIndex, startIndex } = getRangeIndices(range, data.length);
18
15
  const filteredData = data.slice(startIndex, endIndex + 1);
19
16
  onDataChange(filteredData);
20
17
  };
@@ -24,7 +21,7 @@ const useZoomData = ({ data, initialRange, onDataChange, }) => {
24
21
  filterData(newRange);
25
22
  };
26
23
  // Emit initial filtered data on mount
27
- (0, react_1.useEffect)(() => {
24
+ useEffect(() => {
28
25
  filterData(currentRange);
29
26
  }, []);
30
27
  return {
@@ -32,4 +29,3 @@ const useZoomData = ({ data, initialRange, onDataChange, }) => {
32
29
  handleRangeChange,
33
30
  };
34
31
  };
35
- exports.useZoomData = useZoomData;
@@ -1,21 +1,5 @@
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("./components"), exports);
18
- __exportStar(require("./hooks"), exports);
19
- __exportStar(require("./utils"), exports);
20
- __exportStar(require("./zoomArea"), exports);
21
- __exportStar(require("./zoomArea.type"), exports);
1
+ export * from './components';
2
+ export * from './hooks';
3
+ export * from './utils';
4
+ export * from './zoomArea';
5
+ export * from './zoomArea.type';
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateAccessibilityLabels = exports.getXAxisValue = void 0;
4
- const indexRounding_1 = require("./indexRounding");
1
+ import { getRangeIndices } from './indexRounding';
5
2
  // Template keys for accessibility labels
6
3
  const ACCESSIBILITY_START_VALUE_KEY = '{{startValue}}';
7
4
  const ACCESSIBILITY_END_VALUE_KEY = '{{endValue}}';
@@ -13,11 +10,10 @@ const ACCESSIBILITY_END_VALUE_KEY = '{{endValue}}';
13
10
  * @param index - Integer index (should be pre-rounded using indexRounding utils)
14
11
  * @returns String representation of the X-axis value, or fallback to string index
15
12
  */
16
- const getXAxisValue = (data, xKey, index) => {
13
+ export const getXAxisValue = (data, xKey, index) => {
17
14
  // Index should already be rounded and clamped by getRangeIndices()
18
15
  return data[index]?.[xKey]?.toString() || `${index}`;
19
16
  };
20
- exports.getXAxisValue = getXAxisValue;
21
17
  /**
22
18
  * Builds screen reader text by replacing template keys with actual values
23
19
  *
@@ -46,11 +42,11 @@ const buildScreenReaderText = (template, startValue, endValue) => {
46
42
  * @param config - Optional configuration for custom label templates
47
43
  * @returns Object with formatted accessibility labels for UI components
48
44
  */
49
- const generateAccessibilityLabels = (data, xKey, currentRange, config) => {
45
+ export const generateAccessibilityLabels = (data, xKey, currentRange, config) => {
50
46
  // Use EXACT same indexing logic as useZoomData.filterData() via shared utilities
51
- const { endIndex, startIndex } = (0, indexRounding_1.getRangeIndices)(currentRange, data.length);
52
- const startValue = (0, exports.getXAxisValue)(data, xKey, startIndex);
53
- const endValue = (0, exports.getXAxisValue)(data, xKey, endIndex);
47
+ const { endIndex, startIndex } = getRangeIndices(currentRange, data.length);
48
+ const startValue = getXAxisValue(data, xKey, startIndex);
49
+ const endValue = getXAxisValue(data, xKey, endIndex);
54
50
  // Use custom templates or fall back to simple defaults (just the values)
55
51
  const startHandler = buildScreenReaderText(config?.startHandler, startValue, endValue) ?? startValue;
56
52
  const endHandler = buildScreenReaderText(config?.endHandler, startValue, endValue) ?? endValue;
@@ -62,4 +58,3 @@ const generateAccessibilityLabels = (data, xKey, currentRange, config) => {
62
58
  startHandler,
63
59
  };
64
60
  };
65
- exports.generateAccessibilityLabels = generateAccessibilityLabels;
@@ -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;