@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.
- package/README.md +2 -0
- 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/package.json +31 -33
|
@@ -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];
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildTickValues = exports.getDivisor = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Returns the divisor for a given number.
|
|
6
3
|
* The divisor is determined based on the number's divisibility by 2, 3, 4, or 5.
|
|
@@ -9,7 +6,7 @@ exports.buildTickValues = exports.getDivisor = void 0;
|
|
|
9
6
|
* @param number - The number for which to determine the divisor.
|
|
10
7
|
* @returns The divisor for the given number.
|
|
11
8
|
*/
|
|
12
|
-
const getDivisor = (number) => {
|
|
9
|
+
export const getDivisor = (number) => {
|
|
13
10
|
if (number % 3 === 0) {
|
|
14
11
|
return 3;
|
|
15
12
|
}
|
|
@@ -24,7 +21,6 @@ const getDivisor = (number) => {
|
|
|
24
21
|
}
|
|
25
22
|
return 1;
|
|
26
23
|
};
|
|
27
|
-
exports.getDivisor = getDivisor;
|
|
28
24
|
/**
|
|
29
25
|
* Builds the tick values for YAxis of a chart based on the provided data.
|
|
30
26
|
* This is a fallback function that is used just in case no tickValues are provided as prop
|
|
@@ -33,7 +29,7 @@ exports.getDivisor = getDivisor;
|
|
|
33
29
|
* @param data - An array of string values representing the data points.
|
|
34
30
|
* @returns An object containing the numeric fallback tickValues for the YAxis of the chart.
|
|
35
31
|
*/
|
|
36
|
-
const buildTickValues = (data) => {
|
|
32
|
+
export const buildTickValues = (data) => {
|
|
37
33
|
if (data.length === 0) {
|
|
38
34
|
return { numeric: { max: 2, min: 0, step: 1 } };
|
|
39
35
|
}
|
|
@@ -49,4 +45,3 @@ const buildTickValues = (data) => {
|
|
|
49
45
|
},
|
|
50
46
|
};
|
|
51
47
|
};
|
|
52
|
-
exports.buildTickValues = buildTickValues;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFocusConfig = exports.calculateFocusOutline = void 0;
|
|
4
|
-
const focusConfig_type_1 = require("../../types/focusConfig.type");
|
|
1
|
+
import { FOCUS_DEFAULT } from '../../types/focusConfig.type';
|
|
5
2
|
/**
|
|
6
3
|
* Calculates the dimensions of the focus outlines (outer and inner) for an SVG element.
|
|
7
4
|
* Supports elements with different width and height dimensions.
|
|
@@ -9,7 +6,7 @@ const focusConfig_type_1 = require("../../types/focusConfig.type");
|
|
|
9
6
|
* @param config - Configuration for the calculation.
|
|
10
7
|
* @returns Object with the dimensions and positions of the outer and inner rectangles.
|
|
11
8
|
*/
|
|
12
|
-
const calculateFocusOutline = ({ elementHeight, elementPosition, elementStrokeWidth = 0, elementType, elementWidth, gap = 0, innerStrokeWidth = 2, outlineStrokeWidth = 2, }) => {
|
|
9
|
+
export const calculateFocusOutline = ({ elementHeight, elementPosition, elementStrokeWidth = 0, elementType, elementWidth, gap = 0, innerStrokeWidth = 2, outlineStrokeWidth = 2, }) => {
|
|
13
10
|
if (elementType === 'circle') {
|
|
14
11
|
// For circles, work with radius
|
|
15
12
|
const elementRadius = elementWidth / 2;
|
|
@@ -71,15 +68,13 @@ const calculateFocusOutline = ({ elementHeight, elementPosition, elementStrokeWi
|
|
|
71
68
|
type: 'rectangle',
|
|
72
69
|
};
|
|
73
70
|
};
|
|
74
|
-
exports.calculateFocusOutline = calculateFocusOutline;
|
|
75
71
|
/**
|
|
76
72
|
* Helper function to get focus complete config
|
|
77
73
|
*/
|
|
78
|
-
const getFocusConfig = (focusConfig) => ({
|
|
79
|
-
gap: focusConfig?.gap ??
|
|
80
|
-
innerColor: focusConfig?.innerColor ??
|
|
81
|
-
innerStrokeWidth: focusConfig?.innerStrokeWidth ??
|
|
82
|
-
outlineColor: focusConfig?.outlineColor ??
|
|
83
|
-
outlineStrokeWidth: focusConfig?.outlineStrokeWidth ??
|
|
74
|
+
export const getFocusConfig = (focusConfig) => ({
|
|
75
|
+
gap: focusConfig?.gap ?? FOCUS_DEFAULT.OUTLINES_GAP,
|
|
76
|
+
innerColor: focusConfig?.innerColor ?? FOCUS_DEFAULT.FOCUS_INNER,
|
|
77
|
+
innerStrokeWidth: focusConfig?.innerStrokeWidth ?? FOCUS_DEFAULT.INNER_FOCUS_STROKE_WIDTH,
|
|
78
|
+
outlineColor: focusConfig?.outlineColor ?? FOCUS_DEFAULT.FOCUS_COLOR,
|
|
79
|
+
outlineStrokeWidth: focusConfig?.outlineStrokeWidth ?? FOCUS_DEFAULT.OUTER_FOCUS_STROKE_WIDTH,
|
|
84
80
|
});
|
|
85
|
-
exports.getFocusConfig = getFocusConfig;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.classNames = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Generates a string of class names based on the provided arguments.
|
|
6
3
|
* Each argument can be:
|
|
@@ -11,7 +8,7 @@ exports.classNames = void 0;
|
|
|
11
8
|
* @param args - A rest parameter that accepts an array of strings, arrays of strings, or objects with string keys and boolean values.
|
|
12
9
|
* @returns A string of class names, separated by spaces.
|
|
13
10
|
*/
|
|
14
|
-
const classNames = (...args) => {
|
|
11
|
+
export const classNames = (...args) => {
|
|
15
12
|
return args
|
|
16
13
|
.flatMap(arg => {
|
|
17
14
|
if (typeof arg === 'string') {
|
|
@@ -26,4 +23,3 @@ const classNames = (...args) => {
|
|
|
26
23
|
})
|
|
27
24
|
.join(' ');
|
|
28
25
|
};
|
|
29
|
-
exports.classNames = classNames;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cssGradientToSVG = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
5
2
|
/**
|
|
6
3
|
* Converts a CSS linear gradient string into an SVG linear gradient.
|
|
7
4
|
*
|
|
@@ -21,7 +18,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
21
18
|
* CSS gradient string. If the angle is not supported, it returns an empty
|
|
22
19
|
* React fragment.
|
|
23
20
|
*/
|
|
24
|
-
const cssGradientToSVG = (cssGradient, id = 'gradientePath') => {
|
|
21
|
+
export const cssGradientToSVG = (cssGradient, id = 'gradientePath') => {
|
|
25
22
|
const parts = cssGradient.split(',').map(part => part.trim());
|
|
26
23
|
const angle = parseInt(parts[0], 10); // Extract the angle
|
|
27
24
|
const stops = parts.slice(1).map(part => {
|
|
@@ -43,8 +40,7 @@ const cssGradientToSVG = (cssGradient, id = 'gradientePath') => {
|
|
|
43
40
|
default:
|
|
44
41
|
// eslint-disable-next-line no-console
|
|
45
42
|
console.error('Unsupported angle');
|
|
46
|
-
return (
|
|
43
|
+
return _jsx(_Fragment, {}); // Return an empty fragment for unsupported angles
|
|
47
44
|
}
|
|
48
|
-
return ((
|
|
45
|
+
return (_jsx("defs", { children: _jsx("linearGradient", { id: id, x1: x1, x2: x2, y1: y1, y2: y2, children: stops.map((stop, index) => (_jsx("stop", { offset: stop.offset, stopColor: stop.color }, `${index}-${stop.offset}`.toString()))) }) }));
|
|
49
46
|
};
|
|
50
|
-
exports.cssGradientToSVG = cssGradientToSVG;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNear = void 0;
|
|
4
|
-
const isNear = (cursor, position, extraArea = 1) => {
|
|
1
|
+
export const isNear = (cursor, position, extraArea = 1) => {
|
|
5
2
|
return cursor >= position - extraArea && cursor <= position + extraArea;
|
|
6
3
|
};
|
|
7
|
-
exports.isNear = isNear;
|