@kubit-ui-web/react-charts 1.6.0 → 1.7.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/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/context/buildLineContextValue.js +64 -128
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/fixture/contextData.js +8 -6
- package/dist/cjs/charts/lineChart/fragments/lineChartPath.js +3 -3
- package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartXAxis.js +3 -8
- package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/fragments/lineChartYAxis.js +9 -9
- package/dist/cjs/charts/lineChart/lineChart.type.d.ts +12 -7
- package/dist/cjs/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/lineChartStructure.js +11 -10
- package/dist/cjs/charts/lineChart/utils/getCoordinates.d.ts +25 -0
- package/dist/cjs/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
- package/dist/cjs/charts/lineChart/utils/getCoordinates.js +55 -0
- package/dist/cjs/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
- package/dist/cjs/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/utils/getExtraSpacing.js +68 -51
- package/dist/cjs/charts/lineChart/utils/getTicks.d.ts +21 -0
- package/dist/cjs/charts/lineChart/utils/getTicks.d.ts.map +1 -0
- package/dist/cjs/charts/lineChart/utils/getTicks.js +36 -0
- package/dist/cjs/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
- package/dist/cjs/charts/lineChart/utils/handleNodesFocus.js +14 -25
- package/dist/cjs/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
- package/dist/cjs/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
- package/dist/cjs/charts/lineChart/utils/tickTextPosition.js +109 -0
- package/dist/cjs/charts/lineChart/utils/validations.d.ts +54 -0
- package/dist/cjs/charts/lineChart/utils/validations.d.ts.map +1 -0
- package/dist/cjs/charts/lineChart/utils/validations.js +117 -0
- package/dist/cjs/components/chartText/chartText.d.ts.map +1 -1
- package/dist/cjs/components/chartText/chartText.js +2 -2
- package/dist/cjs/components/line/line.d.ts.map +1 -1
- package/dist/cjs/components/line/line.js +2 -2
- package/dist/cjs/components/line/line.types.d.ts +2 -0
- package/dist/cjs/components/line/line.types.d.ts.map +1 -1
- package/dist/cjs/components/node/node.d.ts.map +1 -1
- package/dist/cjs/components/node/node.js +1 -1
- package/dist/cjs/components/node/node.types.d.ts +2 -0
- package/dist/cjs/components/node/node.types.d.ts.map +1 -1
- package/dist/cjs/components/path/path.js +1 -1
- package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
- package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
- package/dist/cjs/utils/pickCustomAttributes/pickCustomAttributes.js +8 -7
- package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
- package/dist/esm/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/context/buildLineContextValue.js +64 -128
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/fixture/contextData.js +8 -6
- package/dist/esm/charts/lineChart/fragments/lineChartPath.js +3 -3
- package/dist/esm/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartXAxis.js +3 -8
- package/dist/esm/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/fragments/lineChartYAxis.js +9 -9
- package/dist/esm/charts/lineChart/lineChart.type.d.ts +12 -7
- package/dist/esm/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/lineChartStructure.js +11 -10
- package/dist/esm/charts/lineChart/utils/getCoordinates.d.ts +25 -0
- package/dist/esm/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
- package/dist/esm/charts/lineChart/utils/getCoordinates.js +55 -0
- package/dist/esm/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
- package/dist/esm/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/utils/getExtraSpacing.js +68 -51
- package/dist/esm/charts/lineChart/utils/getTicks.d.ts +21 -0
- package/dist/esm/charts/lineChart/utils/getTicks.d.ts.map +1 -0
- package/dist/esm/charts/lineChart/utils/getTicks.js +36 -0
- package/dist/esm/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
- package/dist/esm/charts/lineChart/utils/handleNodesFocus.js +14 -25
- package/dist/esm/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
- package/dist/esm/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
- package/dist/esm/charts/lineChart/utils/tickTextPosition.js +109 -0
- package/dist/esm/charts/lineChart/utils/validations.d.ts +54 -0
- package/dist/esm/charts/lineChart/utils/validations.d.ts.map +1 -0
- package/dist/esm/charts/lineChart/utils/validations.js +117 -0
- package/dist/esm/components/chartText/chartText.d.ts.map +1 -1
- package/dist/esm/components/chartText/chartText.js +2 -2
- package/dist/esm/components/line/line.d.ts.map +1 -1
- package/dist/esm/components/line/line.js +2 -2
- package/dist/esm/components/line/line.types.d.ts +2 -0
- package/dist/esm/components/line/line.types.d.ts.map +1 -1
- package/dist/esm/components/node/node.d.ts.map +1 -1
- package/dist/esm/components/node/node.js +1 -1
- package/dist/esm/components/node/node.types.d.ts +2 -0
- package/dist/esm/components/node/node.types.d.ts.map +1 -1
- package/dist/esm/components/path/path.js +1 -1
- package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
- package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
- package/dist/esm/utils/pickCustomAttributes/pickCustomAttributes.js +8 -7
- package/dist/kubit-ui-web-react-charts.cjs.js +1 -1
- package/dist/kubit-ui-web-react-charts.es.js +1 -1
- package/dist/kubit-ui-web-react-charts.umd.js +1 -1
- package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts +1 -3
- package/dist/types/charts/lineChart/context/buildLineContextValue.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts +2 -43
- package/dist/types/charts/lineChart/fragments/fixture/contextData.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartXAxis.d.ts.map +1 -1
- package/dist/types/charts/lineChart/fragments/lineChartYAxis.d.ts.map +1 -1
- package/dist/types/charts/lineChart/lineChart.type.d.ts +12 -7
- package/dist/types/charts/lineChart/lineChart.type.d.ts.map +1 -1
- package/dist/types/charts/lineChart/utils/getCoordinates.d.ts +25 -0
- package/dist/types/charts/lineChart/utils/getCoordinates.d.ts.map +1 -0
- package/dist/types/charts/lineChart/utils/getExtraSpacing.d.ts +1 -3
- package/dist/types/charts/lineChart/utils/getExtraSpacing.d.ts.map +1 -1
- package/dist/types/charts/lineChart/utils/getTicks.d.ts +21 -0
- package/dist/types/charts/lineChart/utils/getTicks.d.ts.map +1 -0
- package/dist/types/charts/lineChart/utils/handleNodesFocus.d.ts.map +1 -1
- package/dist/types/charts/lineChart/utils/tickTextPosition.d.ts +33 -0
- package/dist/types/charts/lineChart/utils/tickTextPosition.d.ts.map +1 -0
- package/dist/types/charts/lineChart/utils/validations.d.ts +54 -0
- package/dist/types/charts/lineChart/utils/validations.d.ts.map +1 -0
- package/dist/types/components/chartText/chartText.d.ts.map +1 -1
- package/dist/types/components/line/line.d.ts.map +1 -1
- package/dist/types/components/line/line.types.d.ts +2 -0
- package/dist/types/components/line/line.types.d.ts.map +1 -1
- package/dist/types/components/node/node.d.ts.map +1 -1
- package/dist/types/components/node/node.types.d.ts +2 -0
- package/dist/types/components/node/node.types.d.ts.map +1 -1
- package/dist/types/utils/pickCustomAttributes/pickCustomAttributes.d.ts +7 -6
- package/dist/types/utils/pickCustomAttributes/pickCustomAttributes.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,45 +1,34 @@
|
|
|
1
1
|
export const handleNodesFocus = ({ data, getNodeFocusInfo, nodes, ref, }) => {
|
|
2
|
-
let refFocused = false;
|
|
3
2
|
let currentNode = undefined;
|
|
4
3
|
const g = ref.querySelector('[data-draw]');
|
|
5
|
-
//* callbacks
|
|
6
4
|
const handleKeyDown = (e) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
let newCurrentNode = undefined;
|
|
6
|
+
if (e.key === 'ArrowRight') {
|
|
7
|
+
newCurrentNode =
|
|
8
|
+
currentNode === undefined || currentNode === nodes.length - 1 ? 0 : currentNode + 1;
|
|
9
|
+
}
|
|
10
|
+
else if (e.key === 'ArrowLeft') {
|
|
11
|
+
newCurrentNode =
|
|
12
|
+
currentNode === undefined || currentNode === 0 ? nodes.length - 1 : currentNode - 1;
|
|
13
|
+
}
|
|
14
|
+
if (newCurrentNode !== undefined) {
|
|
15
|
+
currentNode = newCurrentNode;
|
|
16
|
+
if (nodes[currentNode]) {
|
|
17
17
|
nodes[currentNode].focus();
|
|
18
18
|
getNodeFocusInfo?.(data[currentNode]);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
const handleFocusin = () => {
|
|
23
|
-
refFocused = true;
|
|
24
|
-
};
|
|
25
|
-
const handleFocusout = () => {
|
|
26
|
-
refFocused = false;
|
|
27
|
-
};
|
|
28
22
|
const handleFocus = () => {
|
|
29
23
|
currentNode = undefined;
|
|
30
24
|
};
|
|
31
|
-
//* listeners
|
|
32
25
|
const mount = () => {
|
|
33
|
-
ref.addEventListener('focusin', handleFocusin);
|
|
34
|
-
ref.addEventListener('focusout', handleFocusout);
|
|
35
26
|
g?.addEventListener('focus', handleFocus);
|
|
36
|
-
|
|
27
|
+
ref.addEventListener('keydown', (e) => handleKeyDown(e));
|
|
37
28
|
};
|
|
38
29
|
const unmount = () => {
|
|
39
|
-
ref.removeEventListener('focusin', handleFocusin);
|
|
40
|
-
ref.removeEventListener('focusout', handleFocusout);
|
|
41
30
|
g?.removeEventListener('focus', handleFocus);
|
|
42
|
-
|
|
31
|
+
ref.removeEventListener('keydown', (e) => handleKeyDown(e));
|
|
43
32
|
};
|
|
44
33
|
return { mount, unmount };
|
|
45
34
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Positions } from '../../../types/position.enum';
|
|
2
|
+
import type { LineChartXAxisProps, LineChartYAxisProps } from '../lineChart.type';
|
|
3
|
+
type GetYAxisTextXCoordinate = (params: {
|
|
4
|
+
tickText?: LineChartYAxisProps['tickText'];
|
|
5
|
+
yAxisPosition: LineChartYAxisProps['position'];
|
|
6
|
+
textWidth: number;
|
|
7
|
+
yAxisX1: number;
|
|
8
|
+
}) => number;
|
|
9
|
+
export declare const getYAxisTextXCoordinate: GetYAxisTextXCoordinate;
|
|
10
|
+
type GetYAxisLeftTextSpacing = (params: {
|
|
11
|
+
tickText?: LineChartYAxisProps['tickText'];
|
|
12
|
+
textWidth: number;
|
|
13
|
+
yAxisPosition: (typeof Positions)[keyof typeof Positions];
|
|
14
|
+
}) => number;
|
|
15
|
+
export declare const getYAxisLeftTextSpacing: GetYAxisLeftTextSpacing;
|
|
16
|
+
type GetYAxisRightTextSpacing = (params: {
|
|
17
|
+
tickText?: LineChartYAxisProps['tickText'];
|
|
18
|
+
textWidth: number;
|
|
19
|
+
yAxisPosition: (typeof Positions)[keyof typeof Positions];
|
|
20
|
+
}) => number;
|
|
21
|
+
export declare const getYAxisRightTextSpacing: GetYAxisRightTextSpacing;
|
|
22
|
+
type GetXAxisLeftTextSpacing = (params: {
|
|
23
|
+
tickText?: LineChartXAxisProps['tickText'];
|
|
24
|
+
textWidth: number;
|
|
25
|
+
}) => number;
|
|
26
|
+
export declare const getXAxisLeftTextSpacing: GetXAxisLeftTextSpacing;
|
|
27
|
+
type GetXAxisRightTextSpacing = (params: {
|
|
28
|
+
tickText?: LineChartXAxisProps['tickText'];
|
|
29
|
+
textWidth: number;
|
|
30
|
+
}) => number;
|
|
31
|
+
export declare const getXAxisRightTextSpacing: GetXAxisRightTextSpacing;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=tickTextPosition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tickTextPosition.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/tickTextPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAElF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,aAAa,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBA8BrC,CAAC;AAEF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;CAC3D,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBAmCrC,CAAC;AAEF,KAAK,wBAAwB,GAAG,CAAC,MAAM,EAAE;IACvC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;CAC3D,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,wBAAwB,EAAE,wBAmCtC,CAAC;AAEF,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE;IACtC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,uBAAuB,EAAE,uBASrC,CAAC;AAEF,KAAK,wBAAwB,GAAG,CAAC,MAAM,EAAE;IACvC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,MAAM,CAAC;AAEb,eAAO,MAAM,wBAAwB,EAAE,wBAStC,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Positions } from '../../../types/position.enum';
|
|
2
|
+
import { ajustedTextSpace } from '../../../utils/ajustedTextSpace/ajustedTextSpace';
|
|
3
|
+
import { getTickTextXCoordinate } from '../../../utils/getTickTextCoordinate/getTickTextCoordinates';
|
|
4
|
+
export const getYAxisTextXCoordinate = ({ tickText, yAxisPosition, textWidth, yAxisX1, }) => {
|
|
5
|
+
if (tickText?.useAxisAsOrigin) {
|
|
6
|
+
let xTickText = yAxisX1;
|
|
7
|
+
xTickText += tickText.right ?? 0;
|
|
8
|
+
xTickText -= tickText.left ?? 0;
|
|
9
|
+
return xTickText;
|
|
10
|
+
}
|
|
11
|
+
// TODO Review this logic, I don't understand the logic behind it
|
|
12
|
+
// Maybe it only makes sense when anchor is middle
|
|
13
|
+
// IMPORTANT: When changing or deleting this logic, review the getYAxisLeftTextSpacing and getYAxisRightTextSpacing functions
|
|
14
|
+
const textAnchor = tickText?.textAnchor || 'middle';
|
|
15
|
+
let ajustedSpace = 0;
|
|
16
|
+
if (yAxisPosition === Positions.RIGHT) {
|
|
17
|
+
ajustedSpace = tickText?.right ?? 0;
|
|
18
|
+
}
|
|
19
|
+
else if (yAxisPosition === Positions.LEFT) {
|
|
20
|
+
ajustedSpace = tickText?.left ?? 0;
|
|
21
|
+
}
|
|
22
|
+
const ajustedText = ajustedTextSpace(textAnchor, textWidth, ajustedSpace);
|
|
23
|
+
const xTickText = getTickTextXCoordinate(yAxisPosition, yAxisX1, ajustedText);
|
|
24
|
+
return xTickText;
|
|
25
|
+
};
|
|
26
|
+
export const getYAxisLeftTextSpacing = ({ tickText, textWidth, yAxisPosition, }) => {
|
|
27
|
+
if (yAxisPosition !== Positions.LEFT) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
if (tickText?.useAxisAsOrigin) {
|
|
31
|
+
const { textAnchor = 'start' } = tickText;
|
|
32
|
+
let res = 0;
|
|
33
|
+
if (textAnchor === 'end') {
|
|
34
|
+
res = textWidth;
|
|
35
|
+
}
|
|
36
|
+
if (textAnchor === 'middle') {
|
|
37
|
+
res = textWidth / 2;
|
|
38
|
+
}
|
|
39
|
+
res += tickText.left ?? 0;
|
|
40
|
+
res -= tickText.right ?? 0;
|
|
41
|
+
return Math.max(0, res);
|
|
42
|
+
}
|
|
43
|
+
// TODO Review this logic, I don't understand the logic behind it
|
|
44
|
+
// This left spacing is applied because the logic in getYAxisTextXCoordinate
|
|
45
|
+
const textAnchor = tickText?.textAnchor;
|
|
46
|
+
const extraSpace = tickText?.left ?? 0;
|
|
47
|
+
if (textAnchor === 'start') {
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
if (textAnchor === 'middle') {
|
|
51
|
+
return textWidth + extraSpace;
|
|
52
|
+
}
|
|
53
|
+
if (textAnchor === 'end') {
|
|
54
|
+
return 2 * textWidth + extraSpace;
|
|
55
|
+
}
|
|
56
|
+
return textWidth / 2 + extraSpace;
|
|
57
|
+
};
|
|
58
|
+
export const getYAxisRightTextSpacing = ({ tickText, textWidth, yAxisPosition, }) => {
|
|
59
|
+
if (yAxisPosition !== Positions.RIGHT) {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
if (tickText?.useAxisAsOrigin) {
|
|
63
|
+
const { textAnchor = 'start' } = tickText;
|
|
64
|
+
let res = textWidth;
|
|
65
|
+
if (textAnchor === 'end') {
|
|
66
|
+
res = 0;
|
|
67
|
+
}
|
|
68
|
+
if (textAnchor === 'middle') {
|
|
69
|
+
res = textWidth / 2;
|
|
70
|
+
}
|
|
71
|
+
res -= tickText.left ?? 0;
|
|
72
|
+
res += tickText.right ?? 0;
|
|
73
|
+
return Math.max(0, res);
|
|
74
|
+
}
|
|
75
|
+
// TODO Review this logic, I don't understand the logic behind it
|
|
76
|
+
// This size is applied because the logic in getYAxisTextXCoordinate
|
|
77
|
+
const textAnchor = tickText?.textAnchor;
|
|
78
|
+
const extraSpace = tickText?.right ?? 0;
|
|
79
|
+
if (textAnchor === 'start') {
|
|
80
|
+
return textWidth;
|
|
81
|
+
}
|
|
82
|
+
if (textAnchor === 'middle') {
|
|
83
|
+
return textWidth + extraSpace;
|
|
84
|
+
}
|
|
85
|
+
if (textAnchor === 'end') {
|
|
86
|
+
return textWidth + extraSpace;
|
|
87
|
+
}
|
|
88
|
+
return 2 * textWidth - textWidth / 2 + extraSpace;
|
|
89
|
+
};
|
|
90
|
+
export const getXAxisLeftTextSpacing = ({ tickText, textWidth }) => {
|
|
91
|
+
const textAnchor = tickText?.textAnchor ?? 'start';
|
|
92
|
+
if (textAnchor === 'start') {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
if (textAnchor === 'middle') {
|
|
96
|
+
return textWidth / 2;
|
|
97
|
+
}
|
|
98
|
+
return textWidth;
|
|
99
|
+
};
|
|
100
|
+
export const getXAxisRightTextSpacing = ({ tickText, textWidth }) => {
|
|
101
|
+
const textAnchor = tickText?.textAnchor ?? 'start';
|
|
102
|
+
if (textAnchor === 'end') {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
if (textAnchor === 'middle') {
|
|
106
|
+
return textWidth / 2;
|
|
107
|
+
}
|
|
108
|
+
return textWidth;
|
|
109
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TickData } from '../../../components/tick/tick.types';
|
|
2
|
+
import type { ChartError, ErrorType } from '../../../types/errors.type';
|
|
3
|
+
import type { IDataPoint } from '../lineChart.type';
|
|
4
|
+
type ValidateData = (params: {
|
|
5
|
+
data: IDataPoint[];
|
|
6
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
7
|
+
}) => {
|
|
8
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare const validateData: ValidateData;
|
|
11
|
+
type ValidateCanvasDimensions = (params: {
|
|
12
|
+
canvasWidth: number;
|
|
13
|
+
canvasHeight: number;
|
|
14
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
15
|
+
}) => {
|
|
16
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
17
|
+
};
|
|
18
|
+
export declare const validateCanvasDimensions: ValidateCanvasDimensions;
|
|
19
|
+
type ValidateYTickValues = (params: {
|
|
20
|
+
yTickValues: TickData[];
|
|
21
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
22
|
+
}) => {
|
|
23
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
24
|
+
};
|
|
25
|
+
export declare const validateYTickValues: ValidateYTickValues;
|
|
26
|
+
type ValidateXTickValues = (params: {
|
|
27
|
+
xTickValues: TickData[];
|
|
28
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
29
|
+
}) => {
|
|
30
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
31
|
+
};
|
|
32
|
+
export declare const validateXTickValues: ValidateXTickValues;
|
|
33
|
+
type ValidateXCoordinates = (params: {
|
|
34
|
+
xCoordinates: {
|
|
35
|
+
x1: number;
|
|
36
|
+
x2: number;
|
|
37
|
+
};
|
|
38
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
39
|
+
}) => {
|
|
40
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
41
|
+
};
|
|
42
|
+
export declare const validateXCoordinates: ValidateXCoordinates;
|
|
43
|
+
type ValidateYCoordinates = (params: {
|
|
44
|
+
yCoordinates: {
|
|
45
|
+
y1: number;
|
|
46
|
+
y2: number;
|
|
47
|
+
};
|
|
48
|
+
addError?: (errorType: keyof typeof ErrorType, error: Omit<ChartError, 'type'>) => void;
|
|
49
|
+
}) => {
|
|
50
|
+
error: Omit<ChartError, 'type'> | undefined;
|
|
51
|
+
};
|
|
52
|
+
export declare const validateYCoordinates: ValidateYCoordinates;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=validations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../../../../src/charts/lineChart/utils/validations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE;IAC3B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,M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AU,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,eAAO,MAAM,mBAAmB,EAAE,mBAqCjC,CAAC;AAEF,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE;IACnC,YAAY,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,OAAO,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CACzF,KAAK;IAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,eAAO,MAAM,oBAAoB,EAAE,oBAWlC,CAAC;AAEF,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE;IACnC,YAAY,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,OAAO,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CACzF,KAAK;IAAE,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,eAAO,MAAM,oBAAoB,EAAE,oBAYlC,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { BuildError, buildCanvasDimensionsError, buildError, } from '../../../utils/buildErrors/buildErrors';
|
|
2
|
+
import { AXIS_VALIDATION } from '../../constants/chartDefaults';
|
|
3
|
+
export const validateData = ({ data, addError }) => {
|
|
4
|
+
let error = undefined;
|
|
5
|
+
if (!data || data.length === 0) {
|
|
6
|
+
const dataError = {
|
|
7
|
+
error: buildError(BuildError.LINE_CHART_NO_DATA),
|
|
8
|
+
};
|
|
9
|
+
addError?.('LINE_CHART_CONTEXT_ERROR', dataError);
|
|
10
|
+
error = dataError;
|
|
11
|
+
}
|
|
12
|
+
if (data && data.length === 1) {
|
|
13
|
+
const singlePointError = {
|
|
14
|
+
error: buildError(BuildError.LINE_CHART_SINGLE_POINT),
|
|
15
|
+
};
|
|
16
|
+
addError?.('LINE_CHART_CONTEXT_ERROR', singlePointError);
|
|
17
|
+
error = singlePointError;
|
|
18
|
+
}
|
|
19
|
+
return { error };
|
|
20
|
+
};
|
|
21
|
+
export const validateCanvasDimensions = ({ canvasWidth, canvasHeight, addError, }) => {
|
|
22
|
+
let error = undefined;
|
|
23
|
+
if (canvasWidth <= 0 || canvasHeight <= 0) {
|
|
24
|
+
const canvasError = {
|
|
25
|
+
error: buildCanvasDimensionsError(canvasWidth, canvasHeight),
|
|
26
|
+
};
|
|
27
|
+
addError?.('LINE_CHART_CONTEXT_ERROR', canvasError);
|
|
28
|
+
error = canvasError;
|
|
29
|
+
}
|
|
30
|
+
return { error };
|
|
31
|
+
};
|
|
32
|
+
export const validateYTickValues = ({ yTickValues, addError }) => {
|
|
33
|
+
let error = undefined;
|
|
34
|
+
if (yTickValues) {
|
|
35
|
+
const hasInsufficientTicks = yTickValues.length < AXIS_VALIDATION.MIN_TICK_COUNT;
|
|
36
|
+
const hasIdenticalValues = yTickValues.length >= AXIS_VALIDATION.MIN_TICK_COUNT &&
|
|
37
|
+
new Set(yTickValues.map(tick => tick.value)).size === AXIS_VALIDATION.UNIQUE_VALUE_THRESHOLD;
|
|
38
|
+
if (hasInsufficientTicks) {
|
|
39
|
+
const yAxisError = {
|
|
40
|
+
error: buildError(BuildError.LINE_CHART_Y_AXIS_INSUFFICIENT_TICKS),
|
|
41
|
+
};
|
|
42
|
+
addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
|
|
43
|
+
if (!error) {
|
|
44
|
+
error = yAxisError;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (hasIdenticalValues) {
|
|
48
|
+
const yAxisError = {
|
|
49
|
+
error: buildError(BuildError.LINE_CHART_Y_AXIS_IDENTICAL_VALUES),
|
|
50
|
+
};
|
|
51
|
+
addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
|
|
52
|
+
if (!error) {
|
|
53
|
+
error = yAxisError;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { error };
|
|
58
|
+
};
|
|
59
|
+
export const validateXTickValues = ({ xTickValues, addError }) => {
|
|
60
|
+
let error = undefined;
|
|
61
|
+
// Validate X-axis tick values
|
|
62
|
+
if (xTickValues) {
|
|
63
|
+
if ((xTickValues ?? []).some(({ position }) => isNaN(position))) {
|
|
64
|
+
const xTickError = {
|
|
65
|
+
error: buildError(BuildError.INVALID_X_TICK),
|
|
66
|
+
};
|
|
67
|
+
addError?.('LINE_CHART_CONTEXT_ERROR', xTickError);
|
|
68
|
+
error = xTickError;
|
|
69
|
+
}
|
|
70
|
+
const hasInsufficientTicks = xTickValues.length < AXIS_VALIDATION.MIN_TICK_COUNT;
|
|
71
|
+
const hasIdenticalValues = xTickValues.length >= AXIS_VALIDATION.MIN_TICK_COUNT &&
|
|
72
|
+
new Set(xTickValues.map(tick => tick.value)).size === AXIS_VALIDATION.UNIQUE_VALUE_THRESHOLD;
|
|
73
|
+
if (hasInsufficientTicks) {
|
|
74
|
+
const xAxisError = {
|
|
75
|
+
error: buildError(BuildError.LINE_CHART_X_AXIS_INSUFFICIENT_TICKS),
|
|
76
|
+
};
|
|
77
|
+
addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
|
|
78
|
+
if (!error) {
|
|
79
|
+
error = xAxisError;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (hasIdenticalValues) {
|
|
83
|
+
const xAxisError = {
|
|
84
|
+
error: buildError(BuildError.LINE_CHART_X_AXIS_IDENTICAL_VALUES),
|
|
85
|
+
};
|
|
86
|
+
addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
|
|
87
|
+
if (!error) {
|
|
88
|
+
error = xAxisError;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return { error };
|
|
93
|
+
};
|
|
94
|
+
export const validateXCoordinates = ({ xCoordinates, addError }) => {
|
|
95
|
+
let error = undefined;
|
|
96
|
+
if (xCoordinates.x1 === xCoordinates.x2) {
|
|
97
|
+
const xAxisError = {
|
|
98
|
+
error: buildError(BuildError.LINE_CHART_X_AXIS_ZERO_LENGTH),
|
|
99
|
+
};
|
|
100
|
+
addError?.('LINE_CHART_X_AXIS_ERROR', xAxisError);
|
|
101
|
+
error = xAxisError;
|
|
102
|
+
}
|
|
103
|
+
return { error };
|
|
104
|
+
};
|
|
105
|
+
export const validateYCoordinates = ({ yCoordinates, addError }) => {
|
|
106
|
+
let error = undefined;
|
|
107
|
+
if (yCoordinates.y1 === yCoordinates.y2) {
|
|
108
|
+
const yAxisError = {
|
|
109
|
+
error: buildError(BuildError.LINE_CHART_Y_AXIS_ZERO_LENGTH),
|
|
110
|
+
};
|
|
111
|
+
addError?.('LINE_CHART_Y_AXIS_ERROR', yAxisError);
|
|
112
|
+
if (!error) {
|
|
113
|
+
error = yAxisError;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { error };
|
|
117
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartText.d.ts","sourceRoot":"","sources":["../../../../src/components/chartText/chartText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"chartText.d.ts","sourceRoot":"","sources":["../../../../src/components/chartText/chartText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAMxC,CAAC"}
|
|
@@ -13,6 +13,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
* @param {React.ReactNode} props.children - The text content to be rendered within the `<text>` element.
|
|
14
14
|
* @returns {React.ReactElement} A React element representing the SVG text.
|
|
15
15
|
*/
|
|
16
|
-
export const ChartText = ({ children, className = 'circle',
|
|
17
|
-
return (_jsx("text", { className: className,
|
|
16
|
+
export const ChartText = ({ children, className = 'circle', ...props }) => {
|
|
17
|
+
return (_jsx("text", { className: className, ...props, children: children }));
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../../src/components/line/line.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../../src/components/line/line.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAE9B,CAAC"}
|
|
@@ -4,6 +4,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
*
|
|
5
5
|
* @returns A `line` SVG element with the specified properties and attributes.
|
|
6
6
|
*/
|
|
7
|
-
export const Line = ({ ariaLabel
|
|
8
|
-
return
|
|
7
|
+
export const Line = ({ ariaLabel, className = 'line', dataTestId, ...props }) => {
|
|
8
|
+
return _jsx("line", { ...props, "aria-label": ariaLabel, className: className, "data-testid": dataTestId });
|
|
9
9
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* Props for the `Line` component, defining the visual appearance and behavior of a line element.
|
|
3
4
|
*
|
|
@@ -38,6 +39,7 @@ export interface LineProps {
|
|
|
38
39
|
className?: string;
|
|
39
40
|
tabIndex?: number;
|
|
40
41
|
ariaLabel?: string;
|
|
42
|
+
role?: HTMLAttributes<SVGElement>['role'];
|
|
41
43
|
dataTestId?: string;
|
|
42
44
|
}
|
|
43
45
|
//# sourceMappingURL=line.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.types.d.ts","sourceRoot":"","sources":["../../../../src/components/line/line.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAA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AAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/components/node/node.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAIlB,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../src/components/node/node.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAIlB,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,cAAc,CAAC;AA2IxD,eAAO,MAAM,IAAI,EAAgC,CAC/C,KAAK,EAAE,SAAS,GAAG;IACjB,GAAG,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;CACnC,KACE,GAAG,CAAC,OAAO,CAAC"}
|
|
@@ -93,6 +93,6 @@ const NodeComponent = ({ dataTestId = 'node', haloConfig, hasHalo = false, onBlu
|
|
|
93
93
|
strokeWidth: haloConfig?.strokeWidth || props.strokeWidth,
|
|
94
94
|
};
|
|
95
95
|
const InnerNode = Component[type];
|
|
96
|
-
return (_jsxs(_Fragment, { children: [hasHalo && (_jsx(InnerNode, { ...haloProps, "aria-hidden": "true", dataTestId: `${dataTestId}-halo`, position: position, size: size + size / 2
|
|
96
|
+
return (_jsxs(_Fragment, { children: [hasHalo && (_jsx(InnerNode, { ...haloProps, "aria-hidden": "true", dataTestId: `${dataTestId}-halo`, position: position, size: size + size / 2 })), _jsx(InnerNode, { ...nodeProps, ref: clickRef, dataTestId: dataTestId, position: position, size: size })] }));
|
|
97
97
|
};
|
|
98
98
|
export const Node = forwardRef(NodeComponent);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* Enum for node types.
|
|
3
4
|
*
|
|
@@ -61,6 +62,7 @@ export interface NodeProps {
|
|
|
61
62
|
y: number;
|
|
62
63
|
};
|
|
63
64
|
};
|
|
65
|
+
role?: HTMLAttributes<SVGElement>['role'];
|
|
64
66
|
onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, data?: {
|
|
65
67
|
index?: number;
|
|
66
68
|
dataValue?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.types.d.ts","sourceRoot":"","sources":["../../../../src/components/node/node.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;;;;;;;;CAQX,CAAC;AAEX;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QAC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V,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,EAC1C,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,GAAG,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KACxE,IAAI,CAAC;IACV,OAAO,CAAC,EAAE,CACR,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EACvC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,GAAG,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KACxE,IAAI,CAAC;IACV,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IAC3D,YAAY,CAAC,EAAE,CACb,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,EACnD,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,GAAG,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KACxE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;CAC9E"}
|
|
@@ -100,7 +100,7 @@ const PathComponent = ({ classNames = '', fill = 'transparent', stroke = '#0000F
|
|
|
100
100
|
...(isFocused && focusConfig),
|
|
101
101
|
...(isHovered && hoverConfig),
|
|
102
102
|
};
|
|
103
|
-
return (_jsxs("g", { ref: mainRef,
|
|
103
|
+
return (_jsxs("g", { ref: mainRef, children: [gradientSvgElement && gradientSvgElement, mergedProps.shadowSvgConfig && (_jsx(ShadowSvg, { id: SHADOW_FILTER_ID, shadowSvgConfig: mergedProps.shadowSvgConfig })), _jsxs("g", { "aria-label": mergedProps.ariaLabel, className: mergedProps.classNames, "data-draw": true, filter: mergedProps.shadowSvgConfig && mergedProps.filter, opacity: mergedProps.opacity, orientation: mergedProps.orientation, role: mergedProps.role, rotate: mergedProps.rotate, tabIndex: mergedProps.tabIndex, transform: mergedProps.transform, visibility: mergedProps.visibility, ...customAttributes, onBlur: handleBlur, onClick: handleClick, onDoubleClick: handleDoubleClick, onFocus: handleFocus, onKeyDown: handleKeyDown, onMouseDown: handleMouseDown, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [_jsx("path", { ref: pathRef, d: mergedProps.d, "data-testid": mergedProps.dataTestId, fill: mergedProps.dFill ? 'transparent' : mergedProps.fill, fillOpacity: mergedProps.fillOpacity, fillRule: mergedProps.fillRule, stroke: mergedProps.stroke, strokeDasharray: mergedProps.strokeDasharray, strokeDashoffset: mergedProps.strokeDashoffset, strokeLinecap: mergedProps.strokeLinecap, strokeLinejoin: mergedProps.strokeLinejoin, strokeMiterlimit: mergedProps.strokeMiterlimit, strokeOpacity: mergedProps.strokeOpacity, strokeWidth: mergedProps.strokeWidth, children: mergedProps.title && _jsx("title", { children: mergedProps.title }) }), mergedProps.dFill && (_jsx("path", { d: mergedProps.dFill, fill: mergedProps.fill, fillOpacity: mergedProps.fillOpacity, fillRule: mergedProps.fillRule }))] }), mergedProps.points &&
|
|
104
104
|
mergedProps.nodeConfig &&
|
|
105
105
|
mergedProps.points.map(([x, y], index) => {
|
|
106
106
|
const nodeData = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Filters and extracts only aria-* and
|
|
2
|
+
* Filters and extracts only aria-*, data-* and role attributes from a given object,
|
|
3
3
|
* converting all values to strings for HTML compatibility.
|
|
4
4
|
*
|
|
5
5
|
* This function is useful for extracting accessibility and data attributes
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* - Keys can be strings representing attribute names.
|
|
11
11
|
* - Values can be strings, booleans, numbers, or any other type.
|
|
12
12
|
*
|
|
13
|
-
* @returns A new object containing only aria-* and
|
|
14
|
-
* - Only includes attributes that start with `aria-` or `data
|
|
13
|
+
* @returns A new object containing only aria-*, data-* and role attributes:
|
|
14
|
+
* - Only includes attributes that start with `aria-` or `data-` or are exactly `role`.
|
|
15
15
|
* - All values are converted to strings for HTML compatibility.
|
|
16
16
|
* - Null and undefined values are excluded.
|
|
17
17
|
*
|
|
@@ -20,13 +20,14 @@
|
|
|
20
20
|
* const props = {
|
|
21
21
|
* 'aria-label': 'Button',
|
|
22
22
|
* 'data-testid': 'my-button',
|
|
23
|
-
* 'onClick': () => {},
|
|
23
|
+
* 'onClick': () => {},g
|
|
24
24
|
* 'className': 'btn',
|
|
25
|
-
* 'aria-hidden': true
|
|
25
|
+
* 'aria-hidden': true,
|
|
26
|
+
* 'role': 'button',
|
|
26
27
|
* };
|
|
27
28
|
*
|
|
28
29
|
* const result = pickCustomAttributes(props);
|
|
29
|
-
* // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true' }
|
|
30
|
+
* // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true', 'role': 'button' }
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
33
|
export declare const pickCustomAttributes: (attributes?: Record<string, any>) => Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickCustomAttributes.d.ts","sourceRoot":"","sources":["../../../../src/utils/pickCustomAttributes/pickCustomAttributes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pickCustomAttributes.d.ts","sourceRoot":"","sources":["../../../../src/utils/pickCustomAttributes/pickCustomAttributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,oBAAoB,GAE/B,aAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC/B,MAAM,CAAC,MAAM,EAAE,MAAM,CAkBvB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Filters and extracts only aria-* and
|
|
2
|
+
* Filters and extracts only aria-*, data-* and role attributes from a given object,
|
|
3
3
|
* converting all values to strings for HTML compatibility.
|
|
4
4
|
*
|
|
5
5
|
* This function is useful for extracting accessibility and data attributes
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* - Keys can be strings representing attribute names.
|
|
11
11
|
* - Values can be strings, booleans, numbers, or any other type.
|
|
12
12
|
*
|
|
13
|
-
* @returns A new object containing only aria-* and
|
|
14
|
-
* - Only includes attributes that start with `aria-` or `data
|
|
13
|
+
* @returns A new object containing only aria-*, data-* and role attributes:
|
|
14
|
+
* - Only includes attributes that start with `aria-` or `data-` or are exactly `role`.
|
|
15
15
|
* - All values are converted to strings for HTML compatibility.
|
|
16
16
|
* - Null and undefined values are excluded.
|
|
17
17
|
*
|
|
@@ -20,13 +20,14 @@
|
|
|
20
20
|
* const props = {
|
|
21
21
|
* 'aria-label': 'Button',
|
|
22
22
|
* 'data-testid': 'my-button',
|
|
23
|
-
* 'onClick': () => {},
|
|
23
|
+
* 'onClick': () => {},g
|
|
24
24
|
* 'className': 'btn',
|
|
25
|
-
* 'aria-hidden': true
|
|
25
|
+
* 'aria-hidden': true,
|
|
26
|
+
* 'role': 'button',
|
|
26
27
|
* };
|
|
27
28
|
*
|
|
28
29
|
* const result = pickCustomAttributes(props);
|
|
29
|
-
* // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true' }
|
|
30
|
+
* // Result: { 'aria-label': 'Button', 'data-testid': 'my-button', 'aria-hidden': 'true', 'role': 'button' }
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
33
|
export const pickCustomAttributes = (
|
|
@@ -36,7 +37,7 @@ attributes) => {
|
|
|
36
37
|
return {};
|
|
37
38
|
}
|
|
38
39
|
return Object.entries(attributes).reduce((acc, [key, value]) => {
|
|
39
|
-
if ((key.startsWith('aria-') || key.startsWith('data-')) &&
|
|
40
|
+
if ((key.startsWith('aria-') || key.startsWith('data-') || key === 'role') &&
|
|
40
41
|
value !== null &&
|
|
41
42
|
value !== undefined) {
|
|
42
43
|
acc[key] = String(value);
|