@astral/ui 4.108.0 → 4.109.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/components/DonutChart/DonutChart.d.ts +1 -1
- package/components/DonutChart/DonutChart.js +2 -2
- package/components/DonutChart/styles.js +1 -1
- package/components/DonutChart/types.d.ts +5 -0
- package/components/DonutChart/useLogic/useLogic.d.ts +1 -1
- package/components/DonutChart/useLogic/useLogic.js +10 -2
- package/components/DonutChart/useLogic/utils/getDonutChartCssVars/getDonutChartCssVars.d.ts +3 -2
- package/components/DonutChart/useLogic/utils/getDonutChartCssVars/getDonutChartCssVars.js +3 -2
- package/node/components/DonutChart/DonutChart.d.ts +1 -1
- package/node/components/DonutChart/DonutChart.js +2 -2
- package/node/components/DonutChart/styles.js +1 -1
- package/node/components/DonutChart/types.d.ts +5 -0
- package/node/components/DonutChart/useLogic/useLogic.d.ts +1 -1
- package/node/components/DonutChart/useLogic/useLogic.js +10 -2
- package/node/components/DonutChart/useLogic/utils/getDonutChartCssVars/getDonutChartCssVars.d.ts +3 -2
- package/node/components/DonutChart/useLogic/utils/getDonutChartCssVars/getDonutChartCssVars.js +3 -2
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DonutChartProps } from './types';
|
|
2
|
-
export declare const DonutChart: ({ value, maxValue, children, color, colorIntensity, className, style, }: DonutChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DonutChart: ({ value, maxValue, children, color, colorIntensity, trackColorIntensity, className, style, }: DonutChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { cn } from '../utils/cn';
|
|
|
3
3
|
import { donutChartClassnames } from './constants';
|
|
4
4
|
import { Content, ProgressArc, Svg, TrackArc, Wrapper } from './styles';
|
|
5
5
|
import { useLogic } from './useLogic';
|
|
6
|
-
export const DonutChart = ({ value, maxValue, children, color = 'primary', colorIntensity = '700', className, style, }) => {
|
|
7
|
-
const { rootRef, svgViewBox, arcCx, arcCy, donutParams, meterAriaValue } = useLogic({ value, maxValue, color, colorIntensity });
|
|
6
|
+
export const DonutChart = ({ value, maxValue, children, color = 'primary', colorIntensity = '700', trackColorIntensity = '100', className, style, }) => {
|
|
7
|
+
const { rootRef, svgViewBox, arcCx, arcCy, donutParams, meterAriaValue } = useLogic({ value, maxValue, color, colorIntensity, trackColorIntensity });
|
|
8
8
|
return (_jsxs(Wrapper, { ref: rootRef, className: cn(donutChartClassnames.root, className), role: "meter", "aria-label": meterAriaValue.label, "aria-valuemin": meterAriaValue.min, "aria-valuemax": meterAriaValue.max, "aria-valuenow": meterAriaValue.now, style: { ...donutParams?.cssVars, ...style }, children: [donutParams && (_jsxs(Svg, { className: donutChartClassnames.svg, viewBox: svgViewBox, "aria-hidden": true, children: [_jsx(TrackArc, { className: donutChartClassnames.track, cx: arcCx, cy: arcCy, r: donutParams.arcR }), _jsx(ProgressArc, { className: donutChartClassnames.progress, d: donutParams.arcPath, pathLength: 1, strokeDasharray: 1, strokeDashoffset: donutParams.progressOffset })] })), children && (_jsx(Content, { className: donutChartClassnames.content, children: children }))] }));
|
|
9
9
|
};
|
|
@@ -16,7 +16,7 @@ export const Svg = styled.svg `
|
|
|
16
16
|
`;
|
|
17
17
|
export const TrackArc = styled.circle `
|
|
18
18
|
fill: none;
|
|
19
|
-
stroke:
|
|
19
|
+
stroke: var(--donut-chart-track-color);
|
|
20
20
|
stroke-linecap: round;
|
|
21
21
|
stroke-width: var(--donut-chart-stroke-width);
|
|
22
22
|
`;
|
|
@@ -16,6 +16,11 @@ export type DonutChartProps = {
|
|
|
16
16
|
* Интенсивность цвета.
|
|
17
17
|
*/
|
|
18
18
|
colorIntensity?: DonutChartColorIntensity;
|
|
19
|
+
/**
|
|
20
|
+
* Интенсивность цвета для фонового кольца.
|
|
21
|
+
* @default '100'
|
|
22
|
+
*/
|
|
23
|
+
trackColorIntensity?: DonutChartColorIntensity;
|
|
19
24
|
/**
|
|
20
25
|
* CSS-класс для корневого элемента.
|
|
21
26
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DonutChartProps } from '../types';
|
|
3
|
-
export declare const useLogic: ({ value, maxValue, color, colorIntensity, }: DonutChartProps) => {
|
|
3
|
+
export declare const useLogic: ({ value, maxValue, color, colorIntensity, trackColorIntensity, }: DonutChartProps) => {
|
|
4
4
|
rootRef: import("react").RefObject<HTMLDivElement | null>;
|
|
5
5
|
svgViewBox: "0 0 100 100";
|
|
6
6
|
arcCx: number;
|
|
@@ -8,7 +8,7 @@ import { getMeterAriaValue } from './utils/getMeterAriaValue';
|
|
|
8
8
|
import { getProgressCirclePath } from './utils/getProgressCirclePath';
|
|
9
9
|
import { getProgressOffset } from './utils/getProgressOffset';
|
|
10
10
|
import { getProgressPercent } from './utils/getProgressPercent';
|
|
11
|
-
export const useLogic = ({ value, maxValue, color = 'primary', colorIntensity = '700', }) => {
|
|
11
|
+
export const useLogic = ({ value, maxValue, color = 'primary', colorIntensity = '700', trackColorIntensity = '100', }) => {
|
|
12
12
|
const theme = useTheme();
|
|
13
13
|
const { rootRef, renderWidth } = useRenderWidth();
|
|
14
14
|
const progressPercent = getProgressPercent(value, maxValue);
|
|
@@ -25,10 +25,18 @@ export const useLogic = ({ value, maxValue, color = 'primary', colorIntensity =
|
|
|
25
25
|
cssVars: getDonutChartCssVars(theme, {
|
|
26
26
|
color,
|
|
27
27
|
colorIntensity,
|
|
28
|
+
trackColorIntensity,
|
|
28
29
|
strokeWidth: stroke,
|
|
29
30
|
}),
|
|
30
31
|
};
|
|
31
|
-
}, [
|
|
32
|
+
}, [
|
|
33
|
+
renderWidth,
|
|
34
|
+
progressPercent,
|
|
35
|
+
color,
|
|
36
|
+
colorIntensity,
|
|
37
|
+
trackColorIntensity,
|
|
38
|
+
theme,
|
|
39
|
+
]);
|
|
32
40
|
return {
|
|
33
41
|
rootRef,
|
|
34
42
|
svgViewBox: DONUT_CHART_SVG_VIEWBOX,
|
|
@@ -4,13 +4,14 @@ import type { DonutChartColor, DonutChartColorIntensity } from '../../../types';
|
|
|
4
4
|
type GetDonutChartCssVarsParams = {
|
|
5
5
|
color: DonutChartColor;
|
|
6
6
|
colorIntensity: DonutChartColorIntensity;
|
|
7
|
+
trackColorIntensity: DonutChartColorIntensity;
|
|
7
8
|
strokeWidth: number;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* Генерирует CSS переменные для стилизации DonutChart по теме и цвету.
|
|
11
12
|
* @param theme - Объект темы с палитрой цветов
|
|
12
|
-
* @param params - Параметры цвета, интенсивности и ширины stroke
|
|
13
|
+
* @param params - Параметры цвета, интенсивности дуги и трека, ширины stroke
|
|
13
14
|
* @returns CSS свойства для диаграммы
|
|
14
15
|
*/
|
|
15
|
-
export declare const getDonutChartCssVars: (theme: Theme, { color, colorIntensity, strokeWidth }: GetDonutChartCssVarsParams) => CSSProperties;
|
|
16
|
+
export declare const getDonutChartCssVars: (theme: Theme, { color, colorIntensity, trackColorIntensity, strokeWidth, }: GetDonutChartCssVarsParams) => CSSProperties;
|
|
16
17
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Генерирует CSS переменные для стилизации DonutChart по теме и цвету.
|
|
3
3
|
* @param theme - Объект темы с палитрой цветов
|
|
4
|
-
* @param params - Параметры цвета, интенсивности и ширины stroke
|
|
4
|
+
* @param params - Параметры цвета, интенсивности дуги и трека, ширины stroke
|
|
5
5
|
* @returns CSS свойства для диаграммы
|
|
6
6
|
*/
|
|
7
|
-
export const getDonutChartCssVars = (theme, { color, colorIntensity, strokeWidth }) => ({
|
|
7
|
+
export const getDonutChartCssVars = (theme, { color, colorIntensity, trackColorIntensity, strokeWidth, }) => ({
|
|
8
8
|
'--donut-chart-stroke-width': String(strokeWidth),
|
|
9
9
|
'--donut-chart-progress-color': theme.palette[color][colorIntensity],
|
|
10
|
+
'--donut-chart-track-color': theme.palette.grey[trackColorIntensity],
|
|
10
11
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DonutChartProps } from './types';
|
|
2
|
-
export declare const DonutChart: ({ value, maxValue, children, color, colorIntensity, className, style, }: DonutChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DonutChart: ({ value, maxValue, children, color, colorIntensity, trackColorIntensity, className, style, }: DonutChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,8 +6,8 @@ const cn_1 = require("../utils/cn");
|
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const styles_1 = require("./styles");
|
|
8
8
|
const useLogic_1 = require("./useLogic");
|
|
9
|
-
const DonutChart = ({ value, maxValue, children, color = 'primary', colorIntensity = '700', className, style, }) => {
|
|
10
|
-
const { rootRef, svgViewBox, arcCx, arcCy, donutParams, meterAriaValue } = (0, useLogic_1.useLogic)({ value, maxValue, color, colorIntensity });
|
|
9
|
+
const DonutChart = ({ value, maxValue, children, color = 'primary', colorIntensity = '700', trackColorIntensity = '100', className, style, }) => {
|
|
10
|
+
const { rootRef, svgViewBox, arcCx, arcCy, donutParams, meterAriaValue } = (0, useLogic_1.useLogic)({ value, maxValue, color, colorIntensity, trackColorIntensity });
|
|
11
11
|
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { ref: rootRef, className: (0, cn_1.cn)(constants_1.donutChartClassnames.root, className), role: "meter", "aria-label": meterAriaValue.label, "aria-valuemin": meterAriaValue.min, "aria-valuemax": meterAriaValue.max, "aria-valuenow": meterAriaValue.now, style: { ...donutParams?.cssVars, ...style }, children: [donutParams && ((0, jsx_runtime_1.jsxs)(styles_1.Svg, { className: constants_1.donutChartClassnames.svg, viewBox: svgViewBox, "aria-hidden": true, children: [(0, jsx_runtime_1.jsx)(styles_1.TrackArc, { className: constants_1.donutChartClassnames.track, cx: arcCx, cy: arcCy, r: donutParams.arcR }), (0, jsx_runtime_1.jsx)(styles_1.ProgressArc, { className: constants_1.donutChartClassnames.progress, d: donutParams.arcPath, pathLength: 1, strokeDasharray: 1, strokeDashoffset: donutParams.progressOffset })] })), children && ((0, jsx_runtime_1.jsx)(styles_1.Content, { className: constants_1.donutChartClassnames.content, children: children }))] }));
|
|
12
12
|
};
|
|
13
13
|
exports.DonutChart = DonutChart;
|
|
@@ -19,7 +19,7 @@ exports.Svg = styled_1.styled.svg `
|
|
|
19
19
|
`;
|
|
20
20
|
exports.TrackArc = styled_1.styled.circle `
|
|
21
21
|
fill: none;
|
|
22
|
-
stroke:
|
|
22
|
+
stroke: var(--donut-chart-track-color);
|
|
23
23
|
stroke-linecap: round;
|
|
24
24
|
stroke-width: var(--donut-chart-stroke-width);
|
|
25
25
|
`;
|
|
@@ -16,6 +16,11 @@ export type DonutChartProps = {
|
|
|
16
16
|
* Интенсивность цвета.
|
|
17
17
|
*/
|
|
18
18
|
colorIntensity?: DonutChartColorIntensity;
|
|
19
|
+
/**
|
|
20
|
+
* Интенсивность цвета для фонового кольца.
|
|
21
|
+
* @default '100'
|
|
22
|
+
*/
|
|
23
|
+
trackColorIntensity?: DonutChartColorIntensity;
|
|
19
24
|
/**
|
|
20
25
|
* CSS-класс для корневого элемента.
|
|
21
26
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DonutChartProps } from '../types';
|
|
3
|
-
export declare const useLogic: ({ value, maxValue, color, colorIntensity, }: DonutChartProps) => {
|
|
3
|
+
export declare const useLogic: ({ value, maxValue, color, colorIntensity, trackColorIntensity, }: DonutChartProps) => {
|
|
4
4
|
rootRef: import("react").RefObject<HTMLDivElement | null>;
|
|
5
5
|
svgViewBox: "0 0 100 100";
|
|
6
6
|
arcCx: number;
|
|
@@ -11,7 +11,7 @@ const getMeterAriaValue_1 = require("./utils/getMeterAriaValue");
|
|
|
11
11
|
const getProgressCirclePath_1 = require("./utils/getProgressCirclePath");
|
|
12
12
|
const getProgressOffset_1 = require("./utils/getProgressOffset");
|
|
13
13
|
const getProgressPercent_1 = require("./utils/getProgressPercent");
|
|
14
|
-
const useLogic = ({ value, maxValue, color = 'primary', colorIntensity = '700', }) => {
|
|
14
|
+
const useLogic = ({ value, maxValue, color = 'primary', colorIntensity = '700', trackColorIntensity = '100', }) => {
|
|
15
15
|
const theme = (0, useTheme_1.useTheme)();
|
|
16
16
|
const { rootRef, renderWidth } = (0, hooks_1.useRenderWidth)();
|
|
17
17
|
const progressPercent = (0, getProgressPercent_1.getProgressPercent)(value, maxValue);
|
|
@@ -28,10 +28,18 @@ const useLogic = ({ value, maxValue, color = 'primary', colorIntensity = '700',
|
|
|
28
28
|
cssVars: (0, getDonutChartCssVars_1.getDonutChartCssVars)(theme, {
|
|
29
29
|
color,
|
|
30
30
|
colorIntensity,
|
|
31
|
+
trackColorIntensity,
|
|
31
32
|
strokeWidth: stroke,
|
|
32
33
|
}),
|
|
33
34
|
};
|
|
34
|
-
}, [
|
|
35
|
+
}, [
|
|
36
|
+
renderWidth,
|
|
37
|
+
progressPercent,
|
|
38
|
+
color,
|
|
39
|
+
colorIntensity,
|
|
40
|
+
trackColorIntensity,
|
|
41
|
+
theme,
|
|
42
|
+
]);
|
|
35
43
|
return {
|
|
36
44
|
rootRef,
|
|
37
45
|
svgViewBox: constants_1.DONUT_CHART_SVG_VIEWBOX,
|
package/node/components/DonutChart/useLogic/utils/getDonutChartCssVars/getDonutChartCssVars.d.ts
CHANGED
|
@@ -4,13 +4,14 @@ import type { DonutChartColor, DonutChartColorIntensity } from '../../../types';
|
|
|
4
4
|
type GetDonutChartCssVarsParams = {
|
|
5
5
|
color: DonutChartColor;
|
|
6
6
|
colorIntensity: DonutChartColorIntensity;
|
|
7
|
+
trackColorIntensity: DonutChartColorIntensity;
|
|
7
8
|
strokeWidth: number;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* Генерирует CSS переменные для стилизации DonutChart по теме и цвету.
|
|
11
12
|
* @param theme - Объект темы с палитрой цветов
|
|
12
|
-
* @param params - Параметры цвета, интенсивности и ширины stroke
|
|
13
|
+
* @param params - Параметры цвета, интенсивности дуги и трека, ширины stroke
|
|
13
14
|
* @returns CSS свойства для диаграммы
|
|
14
15
|
*/
|
|
15
|
-
export declare const getDonutChartCssVars: (theme: Theme, { color, colorIntensity, strokeWidth }: GetDonutChartCssVarsParams) => CSSProperties;
|
|
16
|
+
export declare const getDonutChartCssVars: (theme: Theme, { color, colorIntensity, trackColorIntensity, strokeWidth, }: GetDonutChartCssVarsParams) => CSSProperties;
|
|
16
17
|
export {};
|
package/node/components/DonutChart/useLogic/utils/getDonutChartCssVars/getDonutChartCssVars.js
CHANGED
|
@@ -4,11 +4,12 @@ exports.getDonutChartCssVars = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Генерирует CSS переменные для стилизации DonutChart по теме и цвету.
|
|
6
6
|
* @param theme - Объект темы с палитрой цветов
|
|
7
|
-
* @param params - Параметры цвета, интенсивности и ширины stroke
|
|
7
|
+
* @param params - Параметры цвета, интенсивности дуги и трека, ширины stroke
|
|
8
8
|
* @returns CSS свойства для диаграммы
|
|
9
9
|
*/
|
|
10
|
-
const getDonutChartCssVars = (theme, { color, colorIntensity, strokeWidth }) => ({
|
|
10
|
+
const getDonutChartCssVars = (theme, { color, colorIntensity, trackColorIntensity, strokeWidth, }) => ({
|
|
11
11
|
'--donut-chart-stroke-width': String(strokeWidth),
|
|
12
12
|
'--donut-chart-progress-color': theme.palette[color][colorIntensity],
|
|
13
|
+
'--donut-chart-track-color': theme.palette.grey[trackColorIntensity],
|
|
13
14
|
});
|
|
14
15
|
exports.getDonutChartCssVars = getDonutChartCssVars;
|