@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.
- package/README.md +31 -36
- package/dist/cjs/charts/barChart/barChart.js +12 -29
- package/dist/cjs/charts/barChart/barChart.type.js +1 -2
- package/dist/cjs/charts/barChart/barChartStructure.js +25 -29
- package/dist/cjs/charts/barChart/context/barChartContext.js +2 -5
- package/dist/cjs/charts/barChart/context/buildBarContextValues.js +17 -21
- package/dist/cjs/charts/barChart/fragments/barChartPath.js +12 -16
- package/dist/cjs/charts/barChart/fragments/barChartSeparator.js +10 -14
- package/dist/cjs/charts/barChart/fragments/barChartXAxis.js +10 -14
- package/dist/cjs/charts/barChart/fragments/barChartYAxis.js +13 -17
- package/dist/cjs/charts/barChart/fragments/fixture/barContextData.js +3 -6
- package/dist/cjs/charts/barChart/fragments/fixture/index.js +1 -5
- package/dist/cjs/charts/barChart/index.js +1 -17
- package/dist/cjs/charts/barChart/utils/countBarChildren.js +5 -9
- package/dist/cjs/charts/barChart/utils/getAxisExtraSpacing.js +31 -35
- package/dist/cjs/charts/barChart/utils/getBarDataValue.js +1 -5
- package/dist/cjs/charts/barChart/utils/getRoundedBarMaxValue.js +1 -5
- package/dist/cjs/charts/index.js +3 -19
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.js +17 -21
- package/dist/cjs/charts/lineChart/context/index.js +2 -7
- package/dist/cjs/charts/lineChart/context/lineChartContext.js +2 -5
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.js +1 -4
- package/dist/cjs/charts/lineChart/fragments/fixture/index.js +1 -5
- package/dist/cjs/charts/lineChart/fragments/index.js +4 -11
- package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +31 -35
- package/dist/cjs/charts/lineChart/fragments/lineChartProjection.js +6 -10
- package/dist/cjs/charts/lineChart/fragments/lineChartSeparator.js +10 -14
- package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.js +14 -18
- package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.js +17 -21
- package/dist/cjs/charts/lineChart/hook/index.js +3 -9
- package/dist/cjs/charts/lineChart/hook/useAutoClick.js +6 -10
- package/dist/cjs/charts/lineChart/hook/useHover.js +5 -9
- package/dist/cjs/charts/lineChart/hook/useIndicator.js +5 -9
- package/dist/cjs/charts/lineChart/index.js +1 -17
- package/dist/cjs/charts/lineChart/lineChart.js +12 -29
- package/dist/cjs/charts/lineChart/lineChart.type.js +1 -2
- package/dist/cjs/charts/lineChart/lineChartStructure.js +34 -38
- package/dist/cjs/charts/lineChart/utils/accessibilityTemplateProcessor.js +6 -10
- package/dist/cjs/charts/lineChart/utils/findSurroundingNumber.js +2 -7
- package/dist/cjs/charts/lineChart/utils/getDataValues.js +1 -5
- package/dist/cjs/charts/lineChart/utils/getExtraSpacing.js +26 -30
- package/dist/cjs/charts/lineChart/utils/getPathData.js +1 -5
- package/dist/cjs/charts/lineChart/utils/getProjection.js +1 -5
- package/dist/cjs/charts/lineChart/utils/getRoundedMaxValue.js +2 -7
- package/dist/cjs/charts/lineChart/utils/handleNodesFocus.js +1 -5
- package/dist/cjs/charts/lineChart/utils/index.js +6 -17
- package/dist/cjs/charts/pieChart/context/buildPieContextValue.js +8 -12
- package/dist/cjs/charts/pieChart/context/index.js +2 -7
- package/dist/cjs/charts/pieChart/context/pieChartContext.js +2 -5
- package/dist/cjs/charts/pieChart/fragments/index.js +2 -7
- package/dist/cjs/charts/pieChart/fragments/pieChartForeign.js +7 -11
- package/dist/cjs/charts/pieChart/fragments/pieChartPath.js +12 -16
- package/dist/cjs/charts/pieChart/fragments/pieChartSegment.js +6 -10
- package/dist/cjs/charts/pieChart/index.js +1 -17
- package/dist/cjs/charts/pieChart/pieChart.js +8 -25
- package/dist/cjs/charts/pieChart/pieChart.type.js +1 -2
- package/dist/cjs/charts/pieChart/pieChartStructure.js +16 -20
- package/dist/cjs/charts/pieChart/utils/buildL.js +1 -5
- package/dist/cjs/charts/pieChart/utils/calculatePoint.js +1 -5
- package/dist/cjs/charts/pieChart/utils/calculateSegmentPath.js +10 -14
- package/dist/cjs/charts/pieChart/utils/drawSegmentPath.js +6 -10
- package/dist/cjs/charts/pieChart/utils/index.js +2 -7
- package/dist/cjs/charts/pieChart/utils/rotationDirection.js +3 -7
- package/dist/cjs/components/axisChart/index.js +2 -18
- package/dist/cjs/components/axisChart/utils/filterLineProps/filterLineProps.js +1 -5
- package/dist/cjs/components/axisChart/utils/index.js +1 -17
- package/dist/cjs/components/axisChart/xAxis/index.js +2 -18
- package/dist/cjs/components/axisChart/xAxis/xAxis.js +14 -18
- package/dist/cjs/components/axisChart/xAxis/xAxis.types.js +1 -2
- package/dist/cjs/components/axisChart/yAxis/index.js +2 -18
- package/dist/cjs/components/axisChart/yAxis/yAxis.js +13 -17
- package/dist/cjs/components/axisChart/yAxis/yAxis.types.js +1 -2
- package/dist/cjs/components/bar/bar.js +9 -13
- package/dist/cjs/components/bar/bar.type.js +1 -4
- package/dist/cjs/components/bar/fragments/barChartSegment.js +3 -7
- package/dist/cjs/components/bar/index.js +2 -18
- package/dist/cjs/components/bar/utils/buildD.js +5 -9
- package/dist/cjs/components/bar/utils/getSegments.js +3 -7
- package/dist/cjs/components/chartText/chartText.js +3 -7
- package/dist/cjs/components/chartText/chartText.types.js +1 -2
- package/dist/cjs/components/chartText/index.js +2 -18
- package/dist/cjs/components/foreignObject/foreignObject.js +3 -7
- package/dist/cjs/components/foreignObject/foreignObject.types.js +1 -2
- package/dist/cjs/components/foreignObject/index.js +2 -18
- package/dist/cjs/components/index.js +10 -26
- package/dist/cjs/components/line/index.js +2 -18
- package/dist/cjs/components/line/line.js +3 -7
- package/dist/cjs/components/line/line.types.js +1 -2
- package/dist/cjs/components/node/components/circle/circle.js +4 -7
- package/dist/cjs/components/node/components/hexagon/hexagon.js +6 -9
- package/dist/cjs/components/node/components/pentagon/pentagon.js +6 -9
- package/dist/cjs/components/node/components/square/square.js +4 -7
- package/dist/cjs/components/node/components/star/star.js +6 -9
- package/dist/cjs/components/node/components/straight/straight.js +4 -7
- package/dist/cjs/components/node/components/triangle/triangle.js +4 -7
- package/dist/cjs/components/node/index.js +2 -18
- package/dist/cjs/components/node/node.js +22 -25
- package/dist/cjs/components/node/node.types.js +1 -4
- package/dist/cjs/components/node/utils/calculateShapePoints/calculateShapePoints.js +1 -5
- package/dist/cjs/components/path/components/nodePath/nodePath.js +9 -12
- package/dist/cjs/components/path/index.js +2 -18
- package/dist/cjs/components/path/path.js +20 -23
- package/dist/cjs/components/path/path.types.js +1 -2
- package/dist/cjs/components/plot/components/circle/circle.js +4 -7
- package/dist/cjs/components/plot/components/index.js +3 -19
- package/dist/cjs/components/plot/components/square/square.js +4 -7
- package/dist/cjs/components/plot/components/triangle/triangle.js +4 -7
- package/dist/cjs/components/plot/index.js +2 -18
- package/dist/cjs/components/plot/plot.js +21 -24
- package/dist/cjs/components/plot/plot.types.js +8 -11
- package/dist/cjs/components/svgContainer/index.js +1 -17
- package/dist/cjs/components/svgContainer/svgContainer.js +5 -8
- package/dist/cjs/components/svgContainer/svgContainer.types.js +1 -2
- package/dist/cjs/components/svgContainer/utils/buildViewBox/buildViewBox.js +1 -5
- package/dist/cjs/components/svgContainer/utils/index.js +1 -17
- package/dist/cjs/components/tick/index.js +2 -18
- package/dist/cjs/components/tick/tick.js +4 -8
- package/dist/cjs/components/tick/tick.types.js +1 -4
- package/dist/cjs/components/zoomArea/components/HandlerIcon.js +3 -7
- package/dist/cjs/components/zoomArea/components/LineRenderer.js +3 -7
- package/dist/cjs/components/zoomArea/components/SelectionArea.js +9 -14
- package/dist/cjs/components/zoomArea/components/ZoomHandler.js +6 -10
- package/dist/cjs/components/zoomArea/components/index.js +4 -12
- package/dist/cjs/components/zoomArea/hooks/index.js +5 -13
- package/dist/cjs/components/zoomArea/hooks/useDragInteraction.js +19 -23
- package/dist/cjs/components/zoomArea/hooks/useKeyboardNavigation.js +18 -22
- package/dist/cjs/components/zoomArea/hooks/useResponsiveCanvas.js +12 -16
- package/dist/cjs/components/zoomArea/hooks/useZoomAreaFocus.js +6 -10
- package/dist/cjs/components/zoomArea/hooks/useZoomData.js +8 -12
- package/dist/cjs/components/zoomArea/index.js +5 -21
- package/dist/cjs/components/zoomArea/utils/accessibilityLabels.js +6 -11
- package/dist/cjs/components/zoomArea/utils/index.js +3 -14
- package/dist/cjs/components/zoomArea/utils/indexRounding.js +5 -11
- package/dist/cjs/components/zoomArea/utils/interactionConfig.js +1 -5
- package/dist/cjs/components/zoomArea/utils/pathGeneration.js +4 -9
- package/dist/cjs/components/zoomArea/utils/rangeAndPositions.js +5 -13
- package/dist/cjs/components/zoomArea/utils/selectionConfig.js +1 -5
- package/dist/cjs/components/zoomArea/zoomArea.js +35 -39
- package/dist/cjs/components/zoomArea/zoomArea.type.js +1 -4
- package/dist/cjs/hooks/index.js +2 -18
- package/dist/cjs/hooks/useFocus/useFocus.js +5 -9
- package/dist/cjs/hooks/useFocus/useFocus.types.js +1 -2
- package/dist/cjs/hooks/useHover/useHover.js +5 -9
- package/dist/cjs/hooks/useHover/useHover.types.js +1 -2
- package/dist/cjs/index.js +3 -19
- package/dist/cjs/types/canvas.type.js +1 -4
- package/dist/cjs/types/errors.type.js +1 -4
- package/dist/cjs/types/focusConfig.type.js +1 -4
- package/dist/cjs/types/index.js +4 -20
- package/dist/cjs/types/position.enum.js +1 -4
- package/dist/cjs/types/unit.enum.js +1 -4
- package/dist/cjs/types/valueFormatter.type.js +1 -2
- package/dist/cjs/utils/ajustedTextSpace/ajustedTextSpace.js +1 -5
- package/dist/cjs/utils/buildErrors/buildErrors.js +3 -7
- package/dist/cjs/utils/buildTickValues/buildTickValues.js +2 -7
- package/dist/cjs/utils/calculateFocusOutline/calculateFocusOutline.js +8 -13
- package/dist/cjs/utils/classNames/classNames.js +1 -5
- package/dist/cjs/utils/cssGradientToSvg/cssGradientToSvg.js +4 -8
- package/dist/cjs/utils/cssGradientToSvg/cssGradientToSvg.types.js +1 -2
- package/dist/cjs/utils/cursorNear/isNear.js +1 -5
- package/dist/cjs/utils/getAxisData/getAxisData.js +1 -5
- package/dist/cjs/utils/getCanvasDimensions/getCanvasDimensions.js +8 -12
- package/dist/cjs/utils/getChildrenAttr/getChildrenAttr.js +4 -8
- package/dist/cjs/utils/getCoordinates/getCoordinates.js +9 -14
- package/dist/cjs/utils/getDataFingerprint/getDataFingerprint.js +1 -5
- package/dist/cjs/utils/getPoints/getPoints.js +1 -5
- package/dist/cjs/utils/getTickTextCoordinate/getTickTextCoordinates.js +5 -10
- package/dist/cjs/utils/getTicks/getTicks.js +2 -7
- package/dist/cjs/utils/index.js +8 -24
- package/dist/cjs/utils/parseStringToNumberPx.ts/parseStringToNumberPx.js +3 -7
- package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.js +1 -5
- package/dist/cjs/utils/shadowSvg/shadowSvg.js +3 -7
- package/dist/cjs/utils/shadowSvg/shadowSvg.types.js +1 -2
- package/dist/cjs/utils/textBound/textBound.js +1 -5
- package/dist/kubit-ui-web-react-charts.cjs.js +1 -10
- package/dist/kubit-ui-web-react-charts.es.js +1 -10
- package/dist/kubit-ui-web-react-charts.umd.js +1 -10
- package/dist/types/charts/barChart/barChart.d.ts +5 -5
- package/dist/types/charts/barChart/barChart.type.d.ts +1 -1
- package/dist/types/charts/barChart/context/barChartContext.d.ts +1 -1
- package/dist/types/charts/barChart/fragments/barChartSeparator.d.ts +1 -1
- package/dist/types/charts/barChart/fragments/barChartXAxis.d.ts +1 -1
- package/dist/types/charts/barChart/fragments/barChartYAxis.d.ts +1 -1
- package/dist/types/charts/lineChart/context/lineChartContext.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartPath.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartProjection.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartSeparator.d.ts +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartXAxis.d.ts +1 -1
- package/dist/types/charts/lineChart/lineChart.d.ts +5 -5
- package/dist/types/charts/lineChart/lineChart.type.d.ts +1 -1
- package/dist/types/charts/lineChart/lineChartStructure.d.ts +1 -1
- package/dist/types/charts/pieChart/context/pieChartContext.d.ts +1 -1
- package/dist/types/charts/pieChart/fragments/pieChartForeign.d.ts +1 -1
- package/dist/types/charts/pieChart/fragments/pieChartPath.d.ts +1 -1
- package/dist/types/charts/pieChart/pieChart.d.ts +3 -3
- package/dist/types/charts/pieChart/pieChart.type.d.ts +1 -1
- package/dist/types/charts/pieChart/pieChartStructure.d.ts +1 -1
- package/dist/types/components/axisChart/xAxis/xAxis.d.ts +1 -1
- package/dist/types/components/axisChart/yAxis/yAxis.d.ts +1 -1
- package/dist/types/components/bar/bar.d.ts +1 -1
- package/dist/types/components/bar/fragments/barChartSegment.d.ts +1 -1
- package/dist/types/components/chartText/chartText.d.ts +1 -1
- package/dist/types/components/foreignObject/foreignObject.d.ts +1 -1
- package/dist/types/components/foreignObject/foreignObject.types.d.ts +1 -1
- package/dist/types/components/line/line.d.ts +1 -1
- package/dist/types/components/node/components/circle/circle.d.ts +1 -1
- package/dist/types/components/node/components/hexagon/hexagon.d.ts +1 -1
- package/dist/types/components/node/components/pentagon/pentagon.d.ts +1 -1
- package/dist/types/components/node/components/square/square.d.ts +1 -1
- package/dist/types/components/node/components/star/star.d.ts +1 -1
- package/dist/types/components/node/components/straight/straight.d.ts +1 -1
- package/dist/types/components/node/components/triangle/triangle.d.ts +1 -1
- package/dist/types/components/node/node.d.ts +1 -1
- package/dist/types/components/path/components/nodePath/nodePath.d.ts +2 -2
- package/dist/types/components/path/path.d.ts +1 -1
- package/dist/types/components/path/path.types.d.ts +1 -1
- package/dist/types/components/plot/components/circle/circle.d.ts +1 -1
- package/dist/types/components/plot/components/square/square.d.ts +1 -1
- package/dist/types/components/plot/components/triangle/triangle.d.ts +1 -1
- package/dist/types/components/plot/plot.d.ts +1 -1
- package/dist/types/components/svgContainer/svgContainer.d.ts +1 -1
- package/dist/types/components/tick/tick.d.ts +1 -1
- package/dist/types/components/zoomArea/components/HandlerIcon.d.ts +1 -1
- package/dist/types/components/zoomArea/components/LineRenderer.d.ts +1 -1
- package/dist/types/components/zoomArea/components/SelectionArea.d.ts +1 -1
- package/dist/types/components/zoomArea/components/ZoomHandler.d.ts +1 -1
- package/dist/types/hooks/useFocus/useFocus.types.d.ts +1 -1
- package/dist/types/hooks/useHover/useHover.types.d.ts +1 -1
- package/dist/types/utils/getChildrenAttr/getChildrenAttr.d.ts +1 -1
- package/package.json +44 -47
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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:
|
|
71
|
-
startIndex:
|
|
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
|
-
?
|
|
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
|
-
? `${
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 =
|
|
34
|
+
const resolvedInteractionConfig = getInteractionConfig(interactionConfig);
|
|
38
35
|
// Resolve selection config with defaults
|
|
39
|
-
const resolvedSelectionConfig =
|
|
36
|
+
const resolvedSelectionConfig = getSelectionConfig(selectionConfig);
|
|
40
37
|
// Resolve focus config with defaults
|
|
41
|
-
const resolvedFocusConfig =
|
|
38
|
+
const resolvedFocusConfig = getFocusConfig(focusConfig);
|
|
42
39
|
// Hook for core data filtering functionality
|
|
43
|
-
const { currentRange, handleRangeChange } =
|
|
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 } =
|
|
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 =
|
|
53
|
+
const dataFingerprint = getDataFingerprint(data);
|
|
57
54
|
const linesFingerprint = JSON.stringify(lines);
|
|
58
|
-
const accessibilityLabels =
|
|
55
|
+
const accessibilityLabels = generateAccessibilityLabels(data, xKey, currentRange, screenReaderTextConfig);
|
|
59
56
|
// Memoize expensive line calculations
|
|
60
|
-
const linesData =
|
|
61
|
-
return
|
|
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 } =
|
|
61
|
+
const { endX, startX } = useMemo(() => calculateHandlerPositions(currentRange, data.length, parsedCanvas.width), [currentRange, dataFingerprint, parsedCanvas.width]);
|
|
65
62
|
// Interaction hooks
|
|
66
|
-
const { handleBlur, handleFocus, isFocused } =
|
|
67
|
-
const { handleKeyDown } =
|
|
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 } =
|
|
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 ((
|
|
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: [(
|
|
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
|
-
|
|
4
|
+
export const ZoomAreaElements = {
|
|
8
5
|
END_HANDLER: 'END_HANDLER',
|
|
9
6
|
SELECTION_AREA: 'SELECTION_AREA',
|
|
10
7
|
START_HANDLER: 'START_HANDLER',
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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] =
|
|
19
|
-
const handleFocus =
|
|
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 =
|
|
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
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
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] =
|
|
17
|
-
const handleMouseEnter =
|
|
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 =
|
|
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
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
7
|
+
export const DefaultCanvasConfig = {
|
|
11
8
|
extraSpace: 0,
|
|
12
9
|
height: 80,
|
|
13
10
|
width: 100,
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
8
|
+
export const Unit = {
|
|
12
9
|
PERCENTAGE: '%',
|
|
13
10
|
REM: 'rem',
|
|
14
11
|
};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5
|
+
export const ErrorsRecord = {
|
|
9
6
|
INVALID_X_TICK: new Error(INVALID_X_TICK_ERROR),
|
|
10
7
|
};
|
|
11
|
-
const buildError = (error) =>
|
|
12
|
-
exports.buildError = buildError;
|
|
8
|
+
export const buildError = (error) => ErrorsRecord[error];
|