@astral/ui 4.108.0 → 4.110.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/DataGrid/Cell/Cell.js +8 -3
- package/components/DataGrid/Cell/CellInner/CellInner.d.ts +1 -1
- package/components/DataGrid/Cell/CellInner/CellInner.js +3 -7
- package/components/DataGrid/Cell/CellInner/styles.d.ts +0 -4
- package/components/DataGrid/Cell/CellInner/styles.js +0 -15
- package/components/DataGrid/Cell/CellInner/types.d.ts +1 -9
- package/components/DataGrid/Cell/LinkWrapper/LinkWrapper.d.ts +6 -0
- package/components/DataGrid/Cell/LinkWrapper/LinkWrapper.js +13 -0
- package/components/DataGrid/Cell/LinkWrapper/index.d.ts +1 -0
- package/components/DataGrid/Cell/LinkWrapper/index.js +1 -0
- package/components/DataGrid/Cell/LinkWrapper/types.d.ts +24 -0
- package/components/DataGrid/Cell/LinkWrapper/types.js +1 -0
- package/components/DataGrid/Cell/constants.d.ts +1 -0
- package/components/DataGrid/Cell/constants.js +1 -0
- package/components/DataGrid/Cell/styles.js +20 -0
- package/components/DataGrid/Cell/useLogic/useLogic.d.ts +7 -0
- package/components/DataGrid/Cell/useLogic/useLogic.js +6 -1
- package/components/DataGrid/DataGrid.js +2 -2
- package/components/DataGrid/DataGridContext/DataGridContext.d.ts +2 -1
- package/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.d.ts +2 -2
- package/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.js +3 -1
- package/components/DataGrid/Row/NestedChildren/NestedChildren.js +4 -2
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/public.d.ts +1 -1
- package/components/DataGrid/types.d.ts +22 -0
- package/components/DataGridInfinite/DataGridInfinite.js +2 -2
- 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/components/index.d.ts +1 -1
- package/node/components/DataGrid/Cell/Cell.js +8 -3
- package/node/components/DataGrid/Cell/CellInner/CellInner.d.ts +1 -1
- package/node/components/DataGrid/Cell/CellInner/CellInner.js +2 -6
- package/node/components/DataGrid/Cell/CellInner/styles.d.ts +0 -4
- package/node/components/DataGrid/Cell/CellInner/styles.js +1 -16
- package/node/components/DataGrid/Cell/CellInner/types.d.ts +1 -9
- package/node/components/DataGrid/Cell/LinkWrapper/LinkWrapper.d.ts +6 -0
- package/node/components/DataGrid/Cell/LinkWrapper/LinkWrapper.js +17 -0
- package/node/components/DataGrid/Cell/LinkWrapper/index.d.ts +1 -0
- package/node/components/DataGrid/Cell/LinkWrapper/index.js +5 -0
- package/node/components/DataGrid/Cell/LinkWrapper/types.d.ts +24 -0
- package/node/components/DataGrid/Cell/LinkWrapper/types.js +2 -0
- package/node/components/DataGrid/Cell/constants.d.ts +1 -0
- package/node/components/DataGrid/Cell/constants.js +1 -0
- package/node/components/DataGrid/Cell/styles.js +20 -0
- package/node/components/DataGrid/Cell/useLogic/useLogic.d.ts +7 -0
- package/node/components/DataGrid/Cell/useLogic/useLogic.js +6 -1
- package/node/components/DataGrid/DataGrid.js +2 -2
- package/node/components/DataGrid/DataGridContext/DataGridContext.d.ts +2 -1
- package/node/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.d.ts +2 -2
- package/node/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.js +3 -1
- package/node/components/DataGrid/Row/NestedChildren/NestedChildren.js +4 -2
- package/node/components/DataGrid/index.d.ts +1 -1
- package/node/components/DataGrid/public.d.ts +1 -1
- package/node/components/DataGrid/types.d.ts +22 -0
- package/node/components/DataGridInfinite/DataGridInfinite.js +2 -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/node/components/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,3 @@ export declare const CellContent: import("@emotion/styled/dist/declarations/src/
|
|
|
14
14
|
theme?: import("@emotion/react").Theme | undefined;
|
|
15
15
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
16
16
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
17
|
-
export declare const Anchor: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
18
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
19
|
-
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
20
|
-
}, import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, {}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CellContent = exports.ColumnLabel = void 0;
|
|
4
4
|
const styled_1 = require("../../../styled");
|
|
5
5
|
const Typography_1 = require("../../../Typography");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
@@ -35,18 +35,3 @@ exports.CellContent = styled_1.styled.div `
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
|
-
exports.Anchor = styled_1.styled.a `
|
|
39
|
-
display: flex;
|
|
40
|
-
align-items: inherit;
|
|
41
|
-
justify-content: inherit;
|
|
42
|
-
|
|
43
|
-
width: 100%;
|
|
44
|
-
height: 100%;
|
|
45
|
-
|
|
46
|
-
color: inherit;
|
|
47
|
-
text-decoration: none;
|
|
48
|
-
|
|
49
|
-
&:focus-visible {
|
|
50
|
-
outline: none;
|
|
51
|
-
}
|
|
52
|
-
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
2
|
import { type RenderCell } from '../../types';
|
|
3
3
|
export type CellInnerProps = {
|
|
4
4
|
/**
|
|
@@ -37,12 +37,4 @@ export type CellInnerProps = {
|
|
|
37
37
|
* Класс для скрытия персональных данных
|
|
38
38
|
*/
|
|
39
39
|
hidePersonalDataClassname?: string;
|
|
40
|
-
/**
|
|
41
|
-
* URL ссылки. Если задан, содержимое оборачивается в ссылку
|
|
42
|
-
*/
|
|
43
|
-
href?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Целевая область для ссылки
|
|
46
|
-
*/
|
|
47
|
-
target?: HTMLAttributeAnchorTarget;
|
|
48
40
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type LinkWrapperProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Оборачивает содержимое ячейки в ссылку
|
|
5
|
+
*/
|
|
6
|
+
export declare const LinkWrapper: <TData extends Record<string, unknown>>({ children, row, renderLink, href, target, }: LinkWrapperProps<TData>) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinkWrapper = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* Оборачивает содержимое ячейки в ссылку
|
|
7
|
+
*/
|
|
8
|
+
const LinkWrapper = ({ children, row, renderLink, href, target, }) => {
|
|
9
|
+
if (renderLink) {
|
|
10
|
+
return renderLink({ children, row }) ?? children;
|
|
11
|
+
}
|
|
12
|
+
if (href) {
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("a", { href: href, target: target, rel: "noopener noreferrer", children: children }));
|
|
14
|
+
}
|
|
15
|
+
return children;
|
|
16
|
+
};
|
|
17
|
+
exports.LinkWrapper = LinkWrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LinkWrapper } from './LinkWrapper';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinkWrapper = void 0;
|
|
4
|
+
var LinkWrapper_1 = require("./LinkWrapper");
|
|
5
|
+
Object.defineProperty(exports, "LinkWrapper", { enumerable: true, get: function () { return LinkWrapper_1.LinkWrapper; } });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type HTMLAttributeAnchorTarget, type ReactNode } from 'react';
|
|
2
|
+
import { type CellValue, type DataGridRenderLink, type DataGridRowWithOptions } from '../../types';
|
|
3
|
+
export type LinkWrapperProps<TData extends Record<string, CellValue>> = {
|
|
4
|
+
/**
|
|
5
|
+
* Содержимое ячейки
|
|
6
|
+
*/
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Данные строки вместе с её options
|
|
10
|
+
*/
|
|
11
|
+
row: DataGridRowWithOptions<TData>;
|
|
12
|
+
/**
|
|
13
|
+
* Кастомная отрисовка ссылки строки
|
|
14
|
+
*/
|
|
15
|
+
renderLink?: DataGridRenderLink<TData>;
|
|
16
|
+
/**
|
|
17
|
+
* URL ссылки
|
|
18
|
+
*/
|
|
19
|
+
href?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Целевая область для ссылки
|
|
22
|
+
*/
|
|
23
|
+
target?: HTMLAttributeAnchorTarget;
|
|
24
|
+
};
|
|
@@ -17,4 +17,5 @@ exports.dataGridCellClassnames = {
|
|
|
17
17
|
grouped: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__cell_grouped'),
|
|
18
18
|
tabularNums: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__cell_tabular-nums'),
|
|
19
19
|
anchorCell: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__cell_anchor-cell'),
|
|
20
|
+
withLink: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__cell_with-link'),
|
|
20
21
|
};
|
|
@@ -33,6 +33,26 @@ exports.Wrapper = styled_1.styled.div `
|
|
|
33
33
|
justify-content: flex-end;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
&.${constants_3.dataGridCellClassnames.withLink} {
|
|
37
|
+
& > * {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: inherit;
|
|
40
|
+
justify-content: inherit;
|
|
41
|
+
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
& a {
|
|
47
|
+
color: inherit;
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
|
|
50
|
+
&:focus-visible {
|
|
51
|
+
outline: none;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
36
56
|
${({ theme }) => theme.breakpoints.down('mobile')} {
|
|
37
57
|
justify-content: space-between;
|
|
38
58
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { CellValue } from '../../types';
|
|
2
3
|
import type { CellProps } from '../types';
|
|
3
4
|
type UseLogicParams<TData extends Record<string, CellValue>> = CellProps<TData>;
|
|
@@ -8,6 +9,12 @@ export declare const useLogic: <TData extends Record<string, unknown>>({ row, hr
|
|
|
8
9
|
label: string | undefined;
|
|
9
10
|
hideTitleOnMobile: boolean | undefined;
|
|
10
11
|
isTabularNums: boolean | undefined;
|
|
12
|
+
linkProps: {
|
|
13
|
+
href: string | undefined;
|
|
14
|
+
target: import("react").HTMLAttributeAnchorTarget | undefined;
|
|
15
|
+
renderLink: import("../../types").DataGridRenderLink<Record<string, unknown>> | undefined;
|
|
16
|
+
} | undefined;
|
|
17
|
+
hasLink: boolean;
|
|
11
18
|
onCellClick: () => void;
|
|
12
19
|
};
|
|
13
20
|
export {};
|
|
@@ -5,7 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const redirectToLink_1 = require("../../../utils/redirectToLink");
|
|
6
6
|
const DataGridContext_1 = require("../../DataGridContext");
|
|
7
7
|
const useLogic = ({ row, href, target, cell, emptyCellValue, startAdornment, }) => {
|
|
8
|
-
const { isTabularNums: contextIsTabularNums } = (0, react_1.useContext)(DataGridContext_1.DataGridContext);
|
|
8
|
+
const { isTabularNums: contextIsTabularNums, renderLink } = (0, react_1.useContext)(DataGridContext_1.DataGridContext);
|
|
9
9
|
const { format, field, label, hideTitleOnMobile, isTabularNums: cellIsTabularNums, } = cell;
|
|
10
10
|
const isTabularNums = cellIsTabularNums ?? contextIsTabularNums;
|
|
11
11
|
const isValidValue = (value) => {
|
|
@@ -27,6 +27,9 @@ const useLogic = ({ row, href, target, cell, emptyCellValue, startAdornment, })
|
|
|
27
27
|
return (0, redirectToLink_1.redirectToLink)(href, target);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
+
// Колонка действий не оборачивается в ссылку: её элементы кликабельны сами
|
|
31
|
+
const linkProps = isActionColumn ? undefined : { href, target, renderLink };
|
|
32
|
+
const hasLink = Boolean(linkProps?.renderLink || linkProps?.href);
|
|
30
33
|
return {
|
|
31
34
|
formattedValue,
|
|
32
35
|
hasStartAdornment,
|
|
@@ -34,6 +37,8 @@ const useLogic = ({ row, href, target, cell, emptyCellValue, startAdornment, })
|
|
|
34
37
|
label,
|
|
35
38
|
hideTitleOnMobile,
|
|
36
39
|
isTabularNums,
|
|
40
|
+
linkProps,
|
|
41
|
+
hasLink,
|
|
37
42
|
onCellClick,
|
|
38
43
|
};
|
|
39
44
|
};
|
|
@@ -61,7 +61,7 @@ const bodyCva = (0, cva_1.cva)(constants_2.dataGridClassnames.body, {
|
|
|
61
61
|
const DataGrid = (props) => {
|
|
62
62
|
const { dataGridClassName, isDataGridDisabled, treeRenderConfig, headColumns, headProps, bodyProps, gridColumns, loaderProps, renderRows, isAllowHorizontalScroll, isHideHead, hasPinnedColumns, contentStateProps, rowHoverProps, containerRef, sections, isNoData, isMobile, mobileSkeletonProps, isLoading, containerCssVars, hasGroupedColumns, gridViewMode, mobileDisplayVariant, isSelfContained, } = (0, useLogic_1.useLogic)(props);
|
|
63
63
|
const { emptySymbol } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
64
|
-
const { columns, selectedRows = [], minDisplayRows = constants_2.MIN_DISPLAY_ROWS_BY_DEFAULT, variant = enums_1.Variant.Tree, footer, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, isTabularNums, renderRow, } = props;
|
|
64
|
+
const { columns, selectedRows = [], minDisplayRows = constants_2.MIN_DISPLAY_ROWS_BY_DEFAULT, variant = enums_1.Variant.Tree, footer, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, isTabularNums, renderRow, renderLink, } = props;
|
|
65
65
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
66
66
|
const { isInitialExpanded = false, expandedLevel = constants_2.EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = constants_2.INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
67
67
|
const Wrapper = isDataGridDisabled
|
|
@@ -101,7 +101,7 @@ const DataGrid = (props) => {
|
|
|
101
101
|
isDisabled: isDataGridDisabled,
|
|
102
102
|
}), isDisabled: isDataGridDisabled, headProps: headProps, gridColumns: gridColumns, bodyProps: commonBodyProps, isNoData: isNoData }) }));
|
|
103
103
|
};
|
|
104
|
-
return ((0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContextProvider, { isLoading: isLoading, isTabularNums: isTabularNums, gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, keyId: keyId, columns: columns, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, children: (0, jsx_runtime_1.jsxs)(styles_1.Container, { ref: containerRef, style: containerCssVars, className: (0, cn_1.cn)(dataGridClassName, dataGridCva({
|
|
104
|
+
return ((0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContextProvider, { isLoading: isLoading, isTabularNums: isTabularNums, gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, keyId: keyId, columns: columns, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, children: (0, jsx_runtime_1.jsxs)(styles_1.Container, { ref: containerRef, style: containerCssVars, className: (0, cn_1.cn)(dataGridClassName, dataGridCva({
|
|
105
105
|
isAllowHorizontalScroll,
|
|
106
106
|
hasPinnedColumns,
|
|
107
107
|
gridViewMode,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import { type DataGridColumns } from '../types';
|
|
2
|
+
import { type DataGridColumns, type DataGridRenderLink } from '../types';
|
|
3
3
|
export type DataGridContextProps = {
|
|
4
4
|
isLoading?: boolean;
|
|
5
5
|
isTabularNums?: boolean;
|
|
@@ -10,5 +10,6 @@ export type DataGridContextProps = {
|
|
|
10
10
|
columns: DataGridColumns<Record<string, unknown>>[];
|
|
11
11
|
onRowClick?: (row: Record<string, unknown>) => void;
|
|
12
12
|
mobileDisplayVariant?: 'list' | 'cards';
|
|
13
|
+
renderLink?: DataGridRenderLink<Record<string, unknown>>;
|
|
13
14
|
};
|
|
14
15
|
export declare const DataGridContext: import("react").Context<DataGridContextProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type DataGridContextProps } from '../DataGridContext';
|
|
3
|
-
type DataGridContextProviderProps = Pick<DataGridContextProps, 'isLoading' | 'isTabularNums' | 'gridColumns' | 'emptyCellValue' | 'activeRowId' | 'keyId' | 'columns' | 'onRowClick' | 'mobileDisplayVariant'> & {
|
|
3
|
+
type DataGridContextProviderProps = Pick<DataGridContextProps, 'isLoading' | 'isTabularNums' | 'gridColumns' | 'emptyCellValue' | 'activeRowId' | 'keyId' | 'columns' | 'onRowClick' | 'mobileDisplayVariant' | 'renderLink'> & {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
};
|
|
6
|
-
export declare const DataGridContextProvider: ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, }: DataGridContextProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const DataGridContextProvider: ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, }: DataGridContextProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const DataGridStorageContext_1 = require("../../DataGridStorageContext");
|
|
7
7
|
const DataGridContext_1 = require("../DataGridContext");
|
|
8
|
-
const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, }) => {
|
|
8
|
+
const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, }) => {
|
|
9
9
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
10
10
|
isLoading,
|
|
11
11
|
isTabularNums,
|
|
@@ -16,6 +16,7 @@ const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyC
|
|
|
16
16
|
columns,
|
|
17
17
|
onRowClick,
|
|
18
18
|
mobileDisplayVariant,
|
|
19
|
+
renderLink,
|
|
19
20
|
}), [
|
|
20
21
|
isLoading,
|
|
21
22
|
isTabularNums,
|
|
@@ -26,6 +27,7 @@ const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyC
|
|
|
26
27
|
columns,
|
|
27
28
|
onRowClick,
|
|
28
29
|
mobileDisplayVariant,
|
|
30
|
+
renderLink,
|
|
29
31
|
]);
|
|
30
32
|
return ((0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(DataGridStorageContext_1.DataGridStorageProvider, { children: children }) }));
|
|
31
33
|
};
|
|
@@ -22,7 +22,8 @@ const NestedChildren = (props) => {
|
|
|
22
22
|
if (!data || !data.length) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { in: isOpen, unmountOnExit: true, children: (0, jsx_runtime_1.jsxs)(styles_1.NestedRows, { "$level": level, "$isShowConnector": isShowConnector, className: rootCva({ variant }), children: [initialVisibleChildren.map((
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { in: isOpen, unmountOnExit: true, children: (0, jsx_runtime_1.jsxs)(styles_1.NestedRows, { "$level": level, "$isShowConnector": isShowConnector, className: rootCva({ variant }), children: [initialVisibleChildren.map((nestedRow) => {
|
|
26
|
+
const { children, options } = nestedRow;
|
|
26
27
|
const nestedRowId = nestedRow[keyId];
|
|
27
28
|
return renderRow({
|
|
28
29
|
key: nestedRowId,
|
|
@@ -32,7 +33,8 @@ const NestedChildren = (props) => {
|
|
|
32
33
|
level: nextLevel,
|
|
33
34
|
className: constants_1.dataGridRowClassnames.nestedChildren,
|
|
34
35
|
});
|
|
35
|
-
}), isOpen && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { in: isShowAllChildren, component: "li", unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(styles_1.NestedRows, { "$level": level, "$isShowConnector": isShowConnector, className: constants_2.nestedChildrenClassnames.additionalRows, children: otherChildren.map((
|
|
36
|
+
}), isOpen && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { in: isShowAllChildren, component: "li", unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(styles_1.NestedRows, { "$level": level, "$isShowConnector": isShowConnector, className: constants_2.nestedChildrenClassnames.additionalRows, children: otherChildren.map((nestedRow) => {
|
|
37
|
+
const { children, options } = nestedRow;
|
|
36
38
|
const nestedRowId = nestedRow[keyId];
|
|
37
39
|
return renderRow({
|
|
38
40
|
key: nestedRowId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DataGrid } from './DataGrid';
|
|
2
|
-
export type { DataGridProps, DataGridColumns, DataGridSingleColumn, DataGridRow, DataGridRowOptions, DataGridSort, DataGridRowWithOptions, DataGridRowOptionColumns, } from './types';
|
|
2
|
+
export type { DataGridProps, DataGridRenderLink, DataGridRenderLinkParams, DataGridColumns, DataGridSingleColumn, DataGridRow, DataGridRowOptions, DataGridSort, DataGridRowWithOptions, DataGridRowOptionColumns, } from './types';
|
|
3
3
|
export { dataGridClassnames } from './constants';
|
|
4
4
|
export { MobileSkeleton } from './MobileSkeleton';
|
|
5
5
|
export { RowBase, type RowBaseProps } from './RowBase';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { dataGridClassnames } from './constants';
|
|
2
2
|
export { DataGrid } from './DataGrid';
|
|
3
|
-
export type { DataGridColumns, DataGridProps, DataGridRow, DataGridRowOptionColumns, DataGridRowOptions, DataGridRowWithOptions, DataGridSort, } from './types';
|
|
3
|
+
export type { DataGridColumns, DataGridProps, DataGridRenderLink, DataGridRenderLinkParams, DataGridRow, DataGridRowOptionColumns, DataGridRowOptions, DataGridRowWithOptions, DataGridSort, } from './types';
|
|
@@ -185,6 +185,11 @@ export type DataGridProps<TData extends Record<string, CellValue> = DataGridRow,
|
|
|
185
185
|
* @example <DataGrid renderRow={(row) => <DataGridCollapsibleRow><CustomContent row={row} /></DataGridCollapsibleRow>} />
|
|
186
186
|
*/
|
|
187
187
|
renderRow?: (row: TData, index: number) => ReactNode;
|
|
188
|
+
/**
|
|
189
|
+
* Оборачивает строку в свой компонент ссылки
|
|
190
|
+
* @example <DataGrid renderLink={({ children, row }) => <Link to={`/docs/${row.id}`}>{children}</Link>} />
|
|
191
|
+
*/
|
|
192
|
+
renderLink?: DataGridRenderLink<TData>;
|
|
188
193
|
/**
|
|
189
194
|
* Вариант отображения таблицы на мобильных устройствах
|
|
190
195
|
*/
|
|
@@ -332,13 +337,30 @@ export type DataGridRowOptions<TData extends Record<string, CellValue>> = {
|
|
|
332
337
|
childrenColumns?: DataGridRowOptionColumns<TData>[];
|
|
333
338
|
/**
|
|
334
339
|
* Ссылка для перехода на другую страницу при клике на строку
|
|
340
|
+
* @deprecated Используйте `renderLink`.
|
|
335
341
|
*/
|
|
336
342
|
href?: string;
|
|
337
343
|
/**
|
|
338
344
|
* Способ открытия ссылки
|
|
345
|
+
* @deprecated Используйте `renderLink`.
|
|
339
346
|
*/
|
|
340
347
|
target?: HTMLAttributeAnchorTarget;
|
|
341
348
|
};
|
|
349
|
+
export type DataGridRenderLinkParams<TData extends Record<string, CellValue>> = {
|
|
350
|
+
/**
|
|
351
|
+
* Содержимое ячейки, которое нужно обернуть в ссылку
|
|
352
|
+
*/
|
|
353
|
+
children: ReactNode;
|
|
354
|
+
/**
|
|
355
|
+
* Данные строки вместе с её options
|
|
356
|
+
*/
|
|
357
|
+
row: DataGridRowWithOptions<TData>;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Вызывается для каждой ячейки строки, кроме колонки действий.
|
|
361
|
+
* Должен вернуть элемент, который рендерит нативный `<a>`
|
|
362
|
+
*/
|
|
363
|
+
export type DataGridRenderLink<TData extends Record<string, CellValue>> = (params: DataGridRenderLinkParams<TData>) => ReactNode;
|
|
342
364
|
export type DataGridRow = Record<string, CellValue>;
|
|
343
365
|
export type DataGridRowWithOptions<TData extends DataGridRow> = TData & {
|
|
344
366
|
options?: DataGridRowOptions<TData>;
|
|
@@ -46,12 +46,12 @@ const dataGridInfiniteCva = (0, cva_1.cva)(constants_2.dataGridClassnames.root,
|
|
|
46
46
|
const DataGridInfinite = (props) => {
|
|
47
47
|
const { imagesMap, emptySymbol } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
48
48
|
const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isEndReached, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, hasGroupedColumns, gridViewMode, gridColumns, handleSelectRow, mobileDisplayVariant, isSelfContained, isNotRenderHeader, initialTopMostItemIndex, } = (0, useLogic_1.useLogic)(props);
|
|
49
|
-
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = enums_1.Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, isTabularNums, renderRow, } = props;
|
|
49
|
+
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = enums_1.Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, isTabularNums, renderRow, renderLink, } = props;
|
|
50
50
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
51
51
|
const { isInitialExpanded = false, expandedLevel = constants_2.EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = constants_2.INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
52
52
|
const { isSelectable } = rowProps;
|
|
53
53
|
const TableContainer = isDisabled ? styles_1.DisabledDataGridWrapper : styles_1.DataGridWrapper;
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(DataGridInfiniteContext_1.DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: (0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, children: (0, jsx_runtime_1.jsxs)(styles_1.StyledContainer, { style: containerCssVars, className: (0, cn_1.cn)(dataGridInfiniteCva({
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(DataGridInfiniteContext_1.DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: (0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, children: (0, jsx_runtime_1.jsxs)(styles_1.StyledContainer, { style: containerCssVars, className: (0, cn_1.cn)(dataGridInfiniteCva({
|
|
55
55
|
hasGroupedColumns,
|
|
56
56
|
gridViewMode,
|
|
57
57
|
mobileDisplayVariant,
|
|
@@ -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;
|
|
@@ -131,7 +131,7 @@ export * from './MenuItem';
|
|
|
131
131
|
export * from './MenuList';
|
|
132
132
|
export { MinimalisticPagination, type MinimalisticPaginationProps, } from './MinimalisticPagination';
|
|
133
133
|
export * from './NavMenu';
|
|
134
|
-
export { type DataGridColumns, type DataGridRow, type DataGridRowOptions, type DataGridSort, DataGrid, type DataGridProps, } from './DataGrid';
|
|
134
|
+
export { type DataGridColumns, type DataGridRenderLink, type DataGridRenderLinkParams, type DataGridRow, type DataGridRowOptions, type DataGridSort, DataGrid, type DataGridProps, } from './DataGrid';
|
|
135
135
|
export { DataGridInfinite, type DataGridInfiniteProps, } from './DataGridInfinite';
|
|
136
136
|
export { DataGridColumnHintIcon, type DataGridColumnHintIconProps, } from './DataGridColumnHintIcon';
|
|
137
137
|
export { type DateItemProps, type DateRangePickerProps, type DateRangePickerValue, DateRangePicker, } from './DateRangePicker';
|