@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
|
@@ -7,6 +7,7 @@ import { cva } from '../../utils/cva';
|
|
|
7
7
|
import { getInertProps } from '../../utils/getInertProps';
|
|
8
8
|
import { CellInner } from './CellInner';
|
|
9
9
|
import { dataGridCellClassnames } from './constants';
|
|
10
|
+
import { LinkWrapper } from './LinkWrapper';
|
|
10
11
|
import { Wrapper } from './styles';
|
|
11
12
|
import { useLogic } from './useLogic';
|
|
12
13
|
const cellCva = cva(dataGridCellClassnames.root, {
|
|
@@ -28,11 +29,14 @@ const cellCva = cva(dataGridCellClassnames.root, {
|
|
|
28
29
|
isActionColumn: {
|
|
29
30
|
true: dataGridCellClassnames.actionColumn,
|
|
30
31
|
},
|
|
32
|
+
withLink: {
|
|
33
|
+
true: dataGridCellClassnames.withLink,
|
|
34
|
+
},
|
|
31
35
|
},
|
|
32
36
|
});
|
|
33
37
|
export const Cell = (props) => {
|
|
34
|
-
const { formattedValue, hasStartAdornment, isActionColumn, label, hideTitleOnMobile, isTabularNums, onCellClick, } = useLogic(props);
|
|
35
|
-
const { className, startAdornment, row, cell, isDisabled, isHidePersonalData, isHideOnMobile, hasNestedChildren, rootRowElement,
|
|
38
|
+
const { formattedValue, hasStartAdornment, isActionColumn, label, hideTitleOnMobile, isTabularNums, linkProps, hasLink, onCellClick, } = useLogic(props);
|
|
39
|
+
const { className, startAdornment, row, cell, isDisabled, isHidePersonalData, isHideOnMobile, hasNestedChildren, rootRowElement, } = props;
|
|
36
40
|
const { renderCell, align = 'left' } = cell;
|
|
37
41
|
const { isMobile } = useViewportType();
|
|
38
42
|
const hidePersonalDataClassname = useHidePersonalData({
|
|
@@ -44,7 +48,8 @@ export const Cell = (props) => {
|
|
|
44
48
|
withStartAdornment: hasStartAdornment,
|
|
45
49
|
align,
|
|
46
50
|
isActionColumn,
|
|
47
|
-
|
|
51
|
+
withLink: hasLink,
|
|
52
|
+
})), ...getInertProps(isDisabled), onClick: onCellClick, children: _jsx(LinkWrapper, { row: row, ...linkProps, children: _jsx(CellInner, { row: row, label: label, hideTitleOnMobile: hideTitleOnMobile, isActionColumn: isActionColumn, isTabularNums: isTabularNums, startAdornment: startAdornment, renderCell: renderCell, formattedValue: formattedValue, hidePersonalDataClassname: hidePersonalDataClassname }) }) }));
|
|
48
53
|
if (isActionColumn && isMobile && hasNestedChildren) {
|
|
49
54
|
if (!rootRowElement) {
|
|
50
55
|
return null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type CellInnerProps } from './types';
|
|
2
|
-
export declare const CellInner: ({ row, label, hideTitleOnMobile, isActionColumn, isTabularNums, startAdornment, renderCell, formattedValue, hidePersonalDataClassname,
|
|
2
|
+
export declare const CellInner: ({ row, label, hideTitleOnMobile, isActionColumn, isTabularNums, startAdornment, renderCell, formattedValue, hidePersonalDataClassname, }: CellInnerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { OverflowTypography } from '../../../OverflowTypography';
|
|
3
3
|
import { cva } from '../../../utils/cva';
|
|
4
4
|
import { dataGridCellClassnames } from '../constants';
|
|
5
|
-
import {
|
|
5
|
+
import { CellContent, ColumnLabel } from './styles';
|
|
6
6
|
const cellContentCva = cva(dataGridCellClassnames.cellContent, {
|
|
7
7
|
variants: {
|
|
8
8
|
isActionColumn: {
|
|
@@ -20,12 +20,8 @@ const columnLabelCva = cva(dataGridCellClassnames.columnLabel, {
|
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
|
-
export const CellInner = ({ row, label, hideTitleOnMobile, isActionColumn, isTabularNums, startAdornment, renderCell, formattedValue, hidePersonalDataClassname,
|
|
24
|
-
|
|
23
|
+
export const CellInner = ({ row, label, hideTitleOnMobile, isActionColumn, isTabularNums, startAdornment, renderCell, formattedValue, hidePersonalDataClassname, }) => {
|
|
24
|
+
return (_jsxs(_Fragment, { children: [startAdornment, _jsxs(CellContent, { className: cellContentCva({ isActionColumn, isTabularNums }), children: [_jsx(ColumnLabel, { variant: "caption", color: "textSecondary", className: columnLabelCva({
|
|
25
25
|
hidden: hideTitleOnMobile || isActionColumn,
|
|
26
26
|
}), children: label }), renderCell?.(row), !renderCell && (_jsx(OverflowTypography, { rowsCount: 2, tooltipProps: { className: hidePersonalDataClassname }, children: _jsx(_Fragment, { children: formattedValue }) }))] })] }));
|
|
27
|
-
if (href && !isActionColumn) {
|
|
28
|
-
return (_jsx(Anchor, { href: href, target: target, rel: "noopener noreferrer", children: content }));
|
|
29
|
-
}
|
|
30
|
-
return content;
|
|
31
27
|
};
|
|
@@ -14,7 +14,3 @@ export declare const CellContent: import("../../../styled").StyledComponent<{
|
|
|
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("../../../styled").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>, {}>;
|
|
@@ -32,18 +32,3 @@ export const CellContent = styled.div `
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
`;
|
|
35
|
-
export const Anchor = styled.a `
|
|
36
|
-
display: flex;
|
|
37
|
-
align-items: inherit;
|
|
38
|
-
justify-content: inherit;
|
|
39
|
-
|
|
40
|
-
width: 100%;
|
|
41
|
-
height: 100%;
|
|
42
|
-
|
|
43
|
-
color: inherit;
|
|
44
|
-
text-decoration: none;
|
|
45
|
-
|
|
46
|
-
&:focus-visible {
|
|
47
|
-
outline: none;
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
@@ -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,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Оборачивает содержимое ячейки в ссылку
|
|
4
|
+
*/
|
|
5
|
+
export const LinkWrapper = ({ children, row, renderLink, href, target, }) => {
|
|
6
|
+
if (renderLink) {
|
|
7
|
+
return renderLink({ children, row }) ?? children;
|
|
8
|
+
}
|
|
9
|
+
if (href) {
|
|
10
|
+
return (_jsx("a", { href: href, target: target, rel: "noopener noreferrer", children: children }));
|
|
11
|
+
}
|
|
12
|
+
return children;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LinkWrapper } from './LinkWrapper';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LinkWrapper } from './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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,4 +14,5 @@ export const dataGridCellClassnames = {
|
|
|
14
14
|
grouped: createUIKitClassname('data-grid__cell_grouped'),
|
|
15
15
|
tabularNums: createUIKitClassname('data-grid__cell_tabular-nums'),
|
|
16
16
|
anchorCell: createUIKitClassname('data-grid__cell_anchor-cell'),
|
|
17
|
+
withLink: createUIKitClassname('data-grid__cell_with-link'),
|
|
17
18
|
};
|
|
@@ -30,6 +30,26 @@ export const Wrapper = styled.div `
|
|
|
30
30
|
justify-content: flex-end;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
&.${dataGridCellClassnames.withLink} {
|
|
34
|
+
& > * {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: inherit;
|
|
37
|
+
justify-content: inherit;
|
|
38
|
+
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
& a {
|
|
44
|
+
color: inherit;
|
|
45
|
+
text-decoration: none;
|
|
46
|
+
|
|
47
|
+
&:focus-visible {
|
|
48
|
+
outline: none;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
33
53
|
${({ theme }) => theme.breakpoints.down('mobile')} {
|
|
34
54
|
justify-content: space-between;
|
|
35
55
|
|
|
@@ -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 {};
|
|
@@ -2,7 +2,7 @@ import { useContext, useMemo } from 'react';
|
|
|
2
2
|
import { redirectToLink } from '../../../utils/redirectToLink';
|
|
3
3
|
import { DataGridContext } from '../../DataGridContext';
|
|
4
4
|
export const useLogic = ({ row, href, target, cell, emptyCellValue, startAdornment, }) => {
|
|
5
|
-
const { isTabularNums: contextIsTabularNums } = useContext(DataGridContext);
|
|
5
|
+
const { isTabularNums: contextIsTabularNums, renderLink } = useContext(DataGridContext);
|
|
6
6
|
const { format, field, label, hideTitleOnMobile, isTabularNums: cellIsTabularNums, } = cell;
|
|
7
7
|
const isTabularNums = cellIsTabularNums ?? contextIsTabularNums;
|
|
8
8
|
const isValidValue = (value) => {
|
|
@@ -24,6 +24,9 @@ export const useLogic = ({ row, href, target, cell, emptyCellValue, startAdornme
|
|
|
24
24
|
return redirectToLink(href, target);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
// Колонка действий не оборачивается в ссылку: её элементы кликабельны сами
|
|
28
|
+
const linkProps = isActionColumn ? undefined : { href, target, renderLink };
|
|
29
|
+
const hasLink = Boolean(linkProps?.renderLink || linkProps?.href);
|
|
27
30
|
return {
|
|
28
31
|
formattedValue,
|
|
29
32
|
hasStartAdornment,
|
|
@@ -31,6 +34,8 @@ export const useLogic = ({ row, href, target, cell, emptyCellValue, startAdornme
|
|
|
31
34
|
label,
|
|
32
35
|
hideTitleOnMobile,
|
|
33
36
|
isTabularNums,
|
|
37
|
+
linkProps,
|
|
38
|
+
hasLink,
|
|
34
39
|
onCellClick,
|
|
35
40
|
};
|
|
36
41
|
};
|
|
@@ -58,7 +58,7 @@ const bodyCva = cva(dataGridClassnames.body, {
|
|
|
58
58
|
export const DataGrid = (props) => {
|
|
59
59
|
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, } = useLogic(props);
|
|
60
60
|
const { emptySymbol } = useContext(ConfigContext);
|
|
61
|
-
const { columns, selectedRows = [], minDisplayRows = MIN_DISPLAY_ROWS_BY_DEFAULT, variant = Variant.Tree, footer, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, isTabularNums, renderRow, } = props;
|
|
61
|
+
const { columns, selectedRows = [], minDisplayRows = MIN_DISPLAY_ROWS_BY_DEFAULT, variant = Variant.Tree, footer, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, isTabularNums, renderRow, renderLink, } = props;
|
|
62
62
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
63
63
|
const { isInitialExpanded = false, expandedLevel = EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
64
64
|
const Wrapper = isDataGridDisabled
|
|
@@ -98,7 +98,7 @@ export const DataGrid = (props) => {
|
|
|
98
98
|
isDisabled: isDataGridDisabled,
|
|
99
99
|
}), isDisabled: isDataGridDisabled, headProps: headProps, gridColumns: gridColumns, bodyProps: commonBodyProps, isNoData: isNoData }) }));
|
|
100
100
|
};
|
|
101
|
-
return (_jsx(DataGridContextProvider, { isLoading: isLoading, isTabularNums: isTabularNums, gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, keyId: keyId, columns: columns, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, children: _jsxs(Container, { ref: containerRef, style: containerCssVars, className: cn(dataGridClassName, dataGridCva({
|
|
101
|
+
return (_jsx(DataGridContextProvider, { isLoading: isLoading, isTabularNums: isTabularNums, gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, keyId: keyId, columns: columns, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, children: _jsxs(Container, { ref: containerRef, style: containerCssVars, className: cn(dataGridClassName, dataGridCva({
|
|
102
102
|
isAllowHorizontalScroll,
|
|
103
103
|
hasPinnedColumns,
|
|
104
104
|
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 {};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { DataGridStorageProvider } from '../../DataGridStorageContext';
|
|
4
4
|
import { DataGridContext } from '../DataGridContext';
|
|
5
|
-
export const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, }) => {
|
|
5
|
+
export const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, }) => {
|
|
6
6
|
const contextValue = useMemo(() => ({
|
|
7
7
|
isLoading,
|
|
8
8
|
isTabularNums,
|
|
@@ -13,6 +13,7 @@ export const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns,
|
|
|
13
13
|
columns,
|
|
14
14
|
onRowClick,
|
|
15
15
|
mobileDisplayVariant,
|
|
16
|
+
renderLink,
|
|
16
17
|
}), [
|
|
17
18
|
isLoading,
|
|
18
19
|
isTabularNums,
|
|
@@ -23,6 +24,7 @@ export const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns,
|
|
|
23
24
|
columns,
|
|
24
25
|
onRowClick,
|
|
25
26
|
mobileDisplayVariant,
|
|
27
|
+
renderLink,
|
|
26
28
|
]);
|
|
27
29
|
return (_jsx(DataGridContext.Provider, { value: contextValue, children: _jsx(DataGridStorageProvider, { children: children }) }));
|
|
28
30
|
};
|
|
@@ -19,7 +19,8 @@ export const NestedChildren = (props) => {
|
|
|
19
19
|
if (!data || !data.length) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
-
return (_jsx(Collapse, { in: isOpen, unmountOnExit: true, children: _jsxs(NestedRows, { "$level": level, "$isShowConnector": isShowConnector, className: rootCva({ variant }), children: [initialVisibleChildren.map((
|
|
22
|
+
return (_jsx(Collapse, { in: isOpen, unmountOnExit: true, children: _jsxs(NestedRows, { "$level": level, "$isShowConnector": isShowConnector, className: rootCva({ variant }), children: [initialVisibleChildren.map((nestedRow) => {
|
|
23
|
+
const { children, options } = nestedRow;
|
|
23
24
|
const nestedRowId = nestedRow[keyId];
|
|
24
25
|
return renderRow({
|
|
25
26
|
key: nestedRowId,
|
|
@@ -29,7 +30,8 @@ export const NestedChildren = (props) => {
|
|
|
29
30
|
level: nextLevel,
|
|
30
31
|
className: dataGridRowClassnames.nestedChildren,
|
|
31
32
|
});
|
|
32
|
-
}), isOpen && (_jsxs(_Fragment, { children: [_jsx(Collapse, { in: isShowAllChildren, component: "li", unmountOnExit: true, children: _jsx(NestedRows, { "$level": level, "$isShowConnector": isShowConnector, className: nestedChildrenClassnames.additionalRows, children: otherChildren.map((
|
|
33
|
+
}), isOpen && (_jsxs(_Fragment, { children: [_jsx(Collapse, { in: isShowAllChildren, component: "li", unmountOnExit: true, children: _jsx(NestedRows, { "$level": level, "$isShowConnector": isShowConnector, className: nestedChildrenClassnames.additionalRows, children: otherChildren.map((nestedRow) => {
|
|
34
|
+
const { children, options } = nestedRow;
|
|
33
35
|
const nestedRowId = nestedRow[keyId];
|
|
34
36
|
return renderRow({
|
|
35
37
|
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>;
|
|
@@ -43,12 +43,12 @@ const dataGridInfiniteCva = cva(dataGridClassnames.root, {
|
|
|
43
43
|
export const DataGridInfinite = (props) => {
|
|
44
44
|
const { imagesMap, emptySymbol } = useContext(ConfigContext);
|
|
45
45
|
const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isEndReached, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, hasGroupedColumns, gridViewMode, gridColumns, handleSelectRow, mobileDisplayVariant, isSelfContained, isNotRenderHeader, initialTopMostItemIndex, } = useLogic(props);
|
|
46
|
-
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, isTabularNums, renderRow, } = props;
|
|
46
|
+
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, isTabularNums, renderRow, renderLink, } = props;
|
|
47
47
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
48
48
|
const { isInitialExpanded = false, expandedLevel = EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
49
49
|
const { isSelectable } = rowProps;
|
|
50
50
|
const TableContainer = isDisabled ? DisabledDataGridWrapper : DataGridWrapper;
|
|
51
|
-
return (_jsx(DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: _jsx(DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, children: _jsxs(StyledContainer, { style: containerCssVars, className: cn(dataGridInfiniteCva({
|
|
51
|
+
return (_jsx(DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: _jsx(DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, children: _jsxs(StyledContainer, { style: containerCssVars, className: cn(dataGridInfiniteCva({
|
|
52
52
|
hasGroupedColumns,
|
|
53
53
|
gridViewMode,
|
|
54
54
|
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;
|
|
@@ -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
|
});
|
package/components/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -10,6 +10,7 @@ const cva_1 = require("../../utils/cva");
|
|
|
10
10
|
const getInertProps_1 = require("../../utils/getInertProps");
|
|
11
11
|
const CellInner_1 = require("./CellInner");
|
|
12
12
|
const constants_1 = require("./constants");
|
|
13
|
+
const LinkWrapper_1 = require("./LinkWrapper");
|
|
13
14
|
const styles_1 = require("./styles");
|
|
14
15
|
const useLogic_1 = require("./useLogic");
|
|
15
16
|
const cellCva = (0, cva_1.cva)(constants_1.dataGridCellClassnames.root, {
|
|
@@ -31,11 +32,14 @@ const cellCva = (0, cva_1.cva)(constants_1.dataGridCellClassnames.root, {
|
|
|
31
32
|
isActionColumn: {
|
|
32
33
|
true: constants_1.dataGridCellClassnames.actionColumn,
|
|
33
34
|
},
|
|
35
|
+
withLink: {
|
|
36
|
+
true: constants_1.dataGridCellClassnames.withLink,
|
|
37
|
+
},
|
|
34
38
|
},
|
|
35
39
|
});
|
|
36
40
|
const Cell = (props) => {
|
|
37
|
-
const { formattedValue, hasStartAdornment, isActionColumn, label, hideTitleOnMobile, isTabularNums, onCellClick, } = (0, useLogic_1.useLogic)(props);
|
|
38
|
-
const { className, startAdornment, row, cell, isDisabled, isHidePersonalData, isHideOnMobile, hasNestedChildren, rootRowElement,
|
|
41
|
+
const { formattedValue, hasStartAdornment, isActionColumn, label, hideTitleOnMobile, isTabularNums, linkProps, hasLink, onCellClick, } = (0, useLogic_1.useLogic)(props);
|
|
42
|
+
const { className, startAdornment, row, cell, isDisabled, isHidePersonalData, isHideOnMobile, hasNestedChildren, rootRowElement, } = props;
|
|
39
43
|
const { renderCell, align = 'left' } = cell;
|
|
40
44
|
const { isMobile } = (0, useViewportType_1.useViewportType)();
|
|
41
45
|
const hidePersonalDataClassname = (0, personalDataSecurity_1.useHidePersonalData)({
|
|
@@ -47,7 +51,8 @@ const Cell = (props) => {
|
|
|
47
51
|
withStartAdornment: hasStartAdornment,
|
|
48
52
|
align,
|
|
49
53
|
isActionColumn,
|
|
50
|
-
|
|
54
|
+
withLink: hasLink,
|
|
55
|
+
})), ...(0, getInertProps_1.getInertProps)(isDisabled), onClick: onCellClick, children: (0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { row: row, ...linkProps, children: (0, jsx_runtime_1.jsx)(CellInner_1.CellInner, { row: row, label: label, hideTitleOnMobile: hideTitleOnMobile, isActionColumn: isActionColumn, isTabularNums: isTabularNums, startAdornment: startAdornment, renderCell: renderCell, formattedValue: formattedValue, hidePersonalDataClassname: hidePersonalDataClassname }) }) }));
|
|
51
56
|
if (isActionColumn && isMobile && hasNestedChildren) {
|
|
52
57
|
if (!rootRowElement) {
|
|
53
58
|
return null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type CellInnerProps } from './types';
|
|
2
|
-
export declare const CellInner: ({ row, label, hideTitleOnMobile, isActionColumn, isTabularNums, startAdornment, renderCell, formattedValue, hidePersonalDataClassname,
|
|
2
|
+
export declare const CellInner: ({ row, label, hideTitleOnMobile, isActionColumn, isTabularNums, startAdornment, renderCell, formattedValue, hidePersonalDataClassname, }: CellInnerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -23,13 +23,9 @@ const columnLabelCva = (0, cva_1.cva)(constants_1.dataGridCellClassnames.columnL
|
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
|
-
const CellInner = ({ row, label, hideTitleOnMobile, isActionColumn, isTabularNums, startAdornment, renderCell, formattedValue, hidePersonalDataClassname,
|
|
27
|
-
|
|
26
|
+
const CellInner = ({ row, label, hideTitleOnMobile, isActionColumn, isTabularNums, startAdornment, renderCell, formattedValue, hidePersonalDataClassname, }) => {
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [startAdornment, (0, jsx_runtime_1.jsxs)(styles_1.CellContent, { className: cellContentCva({ isActionColumn, isTabularNums }), children: [(0, jsx_runtime_1.jsx)(styles_1.ColumnLabel, { variant: "caption", color: "textSecondary", className: columnLabelCva({
|
|
28
28
|
hidden: hideTitleOnMobile || isActionColumn,
|
|
29
29
|
}), children: label }), renderCell?.(row), !renderCell && ((0, jsx_runtime_1.jsx)(OverflowTypography_1.OverflowTypography, { rowsCount: 2, tooltipProps: { className: hidePersonalDataClassname }, children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: formattedValue }) }))] })] }));
|
|
30
|
-
if (href && !isActionColumn) {
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(styles_1.Anchor, { href: href, target: target, rel: "noopener noreferrer", children: content }));
|
|
32
|
-
}
|
|
33
|
-
return content;
|
|
34
30
|
};
|
|
35
31
|
exports.CellInner = CellInner;
|