@astral/ui 4.109.0 → 4.111.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/Link/Link.d.ts +25 -5
- package/components/Link/Link.js +4 -3
- package/components/index.d.ts +1 -1
- package/components/theme/components/MuiOutlinedInput.js +4 -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/Link/Link.d.ts +25 -5
- package/node/components/Link/Link.js +4 -3
- package/node/components/index.d.ts +1 -1
- package/node/components/theme/components/MuiOutlinedInput.js +4 -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,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { LinkProps as MuiLinkProps } from '@mui/material/Link';
|
|
2
|
+
import { type ComponentPropsWithRef, type ElementType } from 'react';
|
|
3
3
|
import { type WithoutEmotionSpecific } from '../types/WithoutEmotionSpecific';
|
|
4
|
-
export type LinkProps = Pick<WithoutEmotionSpecific<MuiLinkProps>, 'rel' | 'href' | 'className' | 'classes' | 'style' | 'children' | 'key' | 'target'> & {
|
|
4
|
+
export type LinkProps<TComponent extends ElementType = ElementType> = Pick<WithoutEmotionSpecific<MuiLinkProps>, 'rel' | 'href' | 'className' | 'classes' | 'style' | 'children' | 'key' | 'target'> & {
|
|
5
5
|
/**
|
|
6
6
|
* Добавление иконки
|
|
7
7
|
*/
|
|
@@ -20,8 +20,18 @@ export type LinkProps = Pick<WithoutEmotionSpecific<MuiLinkProps>, 'rel' | 'href
|
|
|
20
20
|
* Позволяет переключить цвета ссылки на более контрастные
|
|
21
21
|
*/
|
|
22
22
|
isContrast?: boolean;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Тип элемента
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* <Link component={RouterLink} to="/documents">
|
|
28
|
+
* Документы
|
|
29
|
+
* </Link>
|
|
30
|
+
* @default 'a'
|
|
31
|
+
*/
|
|
32
|
+
component?: TComponent;
|
|
33
|
+
} & (ElementType extends TComponent ? {} : ComponentPropsWithRef<TComponent>);
|
|
34
|
+
export declare const Link: <TComponent extends ElementType>(props: Pick<WithoutEmotionSpecific<MuiLinkProps>, "classes" | "className" | "style" | "rel" | "children" | "target" | "href" | "key"> & {
|
|
25
35
|
/**
|
|
26
36
|
* Добавление иконки
|
|
27
37
|
*/
|
|
@@ -40,4 +50,14 @@ export declare const Link: import("react").ForwardRefExoticComponent<Pick<Withou
|
|
|
40
50
|
* Позволяет переключить цвета ссылки на более контрастные
|
|
41
51
|
*/
|
|
42
52
|
isContrast?: boolean | undefined;
|
|
43
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Тип элемента
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* <Link component={RouterLink} to="/documents">
|
|
58
|
+
* Документы
|
|
59
|
+
* </Link>
|
|
60
|
+
* @default 'a'
|
|
61
|
+
*/
|
|
62
|
+
component?: TComponent | undefined;
|
|
63
|
+
} & (ElementType extends TComponent ? {} : ComponentPropsWithRef<TComponent>) & import("react").RefAttributes<HTMLAnchorElement>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
package/components/Link/Link.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
2
|
import { DownloadVOutlineSm } from '../../icons/DownloadVOutlineSm';
|
|
4
3
|
import { OpenLinkOutlineSm } from '../../icons/OpenLinkOutlineSm';
|
|
4
|
+
import { forwardRefWithGeneric } from '../forwardRefWithGeneric';
|
|
5
5
|
import { cn } from '../utils/cn';
|
|
6
6
|
import { cva } from '../utils/cva';
|
|
7
7
|
import { linkClassnames } from './constants';
|
|
@@ -13,7 +13,8 @@ const linkCva = cva(linkClassnames.root, {
|
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
const UnwrappedLink = ({ withAdornment, isDownload, downloadFilename, isContrast, children, className, ...props }, ref) => {
|
|
17
17
|
const icon = isDownload ? _jsx(DownloadVOutlineSm, {}) : _jsx(OpenLinkOutlineSm, {});
|
|
18
18
|
return (_jsxs(StyledLink, { download: downloadFilename ?? isDownload, className: cn(linkCva({ isContrast }), className), ref: ref, ...props, children: [withAdornment === 'start' && icon, children, withAdornment === 'end' && icon, !withAdornment && isDownload && _jsx(DownloadVOutlineSm, {})] }));
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
|
+
export const Link = forwardRefWithGeneric(UnwrappedLink);
|
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';
|
|
@@ -15,6 +15,9 @@ export const MuiOutlinedInput = {
|
|
|
15
15
|
'&:hover': {
|
|
16
16
|
background: theme.palette.background.elementHover,
|
|
17
17
|
},
|
|
18
|
+
'&:hover .MuiOutlinedInput-input:autofill': {
|
|
19
|
+
boxShadow: `0 0 0 1000px ${theme.palette.background.elementHover} inset`,
|
|
20
|
+
},
|
|
18
21
|
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
19
22
|
borderColor: theme.palette.grey[800],
|
|
20
23
|
transition: theme.transitions.create(['border-color'], {
|
|
@@ -50,7 +53,7 @@ export const MuiOutlinedInput = {
|
|
|
50
53
|
? theme.spacing(1)
|
|
51
54
|
: theme.spacing(3),
|
|
52
55
|
'&:autofill': {
|
|
53
|
-
boxShadow:
|
|
56
|
+
boxShadow: `0 0 0 1000px ${theme.palette.common.white} inset`,
|
|
54
57
|
},
|
|
55
58
|
'&::placeholder': {
|
|
56
59
|
opacity: 1,
|
|
@@ -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;
|
|
@@ -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,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { LinkProps as MuiLinkProps } from '@mui/material/Link';
|
|
2
|
+
import { type ComponentPropsWithRef, type ElementType } from 'react';
|
|
3
3
|
import { type WithoutEmotionSpecific } from '../types/WithoutEmotionSpecific';
|
|
4
|
-
export type LinkProps = Pick<WithoutEmotionSpecific<MuiLinkProps>, 'rel' | 'href' | 'className' | 'classes' | 'style' | 'children' | 'key' | 'target'> & {
|
|
4
|
+
export type LinkProps<TComponent extends ElementType = ElementType> = Pick<WithoutEmotionSpecific<MuiLinkProps>, 'rel' | 'href' | 'className' | 'classes' | 'style' | 'children' | 'key' | 'target'> & {
|
|
5
5
|
/**
|
|
6
6
|
* Добавление иконки
|
|
7
7
|
*/
|
|
@@ -20,8 +20,18 @@ export type LinkProps = Pick<WithoutEmotionSpecific<MuiLinkProps>, 'rel' | 'href
|
|
|
20
20
|
* Позволяет переключить цвета ссылки на более контрастные
|
|
21
21
|
*/
|
|
22
22
|
isContrast?: boolean;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Тип элемента
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* <Link component={RouterLink} to="/documents">
|
|
28
|
+
* Документы
|
|
29
|
+
* </Link>
|
|
30
|
+
* @default 'a'
|
|
31
|
+
*/
|
|
32
|
+
component?: TComponent;
|
|
33
|
+
} & (ElementType extends TComponent ? {} : ComponentPropsWithRef<TComponent>);
|
|
34
|
+
export declare const Link: <TComponent extends ElementType>(props: Pick<WithoutEmotionSpecific<MuiLinkProps>, "classes" | "className" | "style" | "rel" | "children" | "target" | "href" | "key"> & {
|
|
25
35
|
/**
|
|
26
36
|
* Добавление иконки
|
|
27
37
|
*/
|
|
@@ -40,4 +50,14 @@ export declare const Link: import("react").ForwardRefExoticComponent<Pick<Withou
|
|
|
40
50
|
* Позволяет переключить цвета ссылки на более контрастные
|
|
41
51
|
*/
|
|
42
52
|
isContrast?: boolean | undefined;
|
|
43
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Тип элемента
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* <Link component={RouterLink} to="/documents">
|
|
58
|
+
* Документы
|
|
59
|
+
* </Link>
|
|
60
|
+
* @default 'a'
|
|
61
|
+
*/
|
|
62
|
+
component?: TComponent | undefined;
|
|
63
|
+
} & (ElementType extends TComponent ? {} : ComponentPropsWithRef<TComponent>) & import("react").RefAttributes<HTMLAnchorElement>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Link = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
5
|
const DownloadVOutlineSm_1 = require("../../icons/DownloadVOutlineSm");
|
|
7
6
|
const OpenLinkOutlineSm_1 = require("../../icons/OpenLinkOutlineSm");
|
|
7
|
+
const forwardRefWithGeneric_1 = require("../forwardRefWithGeneric");
|
|
8
8
|
const cn_1 = require("../utils/cn");
|
|
9
9
|
const cva_1 = require("../utils/cva");
|
|
10
10
|
const constants_1 = require("./constants");
|
|
@@ -16,7 +16,8 @@ const linkCva = (0, cva_1.cva)(constants_1.linkClassnames.root, {
|
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
|
-
|
|
19
|
+
const UnwrappedLink = ({ withAdornment, isDownload, downloadFilename, isContrast, children, className, ...props }, ref) => {
|
|
20
20
|
const icon = isDownload ? (0, jsx_runtime_1.jsx)(DownloadVOutlineSm_1.DownloadVOutlineSm, {}) : (0, jsx_runtime_1.jsx)(OpenLinkOutlineSm_1.OpenLinkOutlineSm, {});
|
|
21
21
|
return ((0, jsx_runtime_1.jsxs)(styles_1.StyledLink, { download: downloadFilename ?? isDownload, className: (0, cn_1.cn)(linkCva({ isContrast }), className), ref: ref, ...props, children: [withAdornment === 'start' && icon, children, withAdornment === 'end' && icon, !withAdornment && isDownload && (0, jsx_runtime_1.jsx)(DownloadVOutlineSm_1.DownloadVOutlineSm, {})] }));
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
|
+
exports.Link = (0, forwardRefWithGeneric_1.forwardRefWithGeneric)(UnwrappedLink);
|
|
@@ -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';
|
|
@@ -18,6 +18,9 @@ exports.MuiOutlinedInput = {
|
|
|
18
18
|
'&:hover': {
|
|
19
19
|
background: theme.palette.background.elementHover,
|
|
20
20
|
},
|
|
21
|
+
'&:hover .MuiOutlinedInput-input:autofill': {
|
|
22
|
+
boxShadow: `0 0 0 1000px ${theme.palette.background.elementHover} inset`,
|
|
23
|
+
},
|
|
21
24
|
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
22
25
|
borderColor: theme.palette.grey[800],
|
|
23
26
|
transition: theme.transitions.create(['border-color'], {
|
|
@@ -53,7 +56,7 @@ exports.MuiOutlinedInput = {
|
|
|
53
56
|
? theme.spacing(1)
|
|
54
57
|
: theme.spacing(3),
|
|
55
58
|
'&:autofill': {
|
|
56
|
-
boxShadow:
|
|
59
|
+
boxShadow: `0 0 0 1000px ${theme.palette.common.white} inset`,
|
|
57
60
|
},
|
|
58
61
|
'&::placeholder': {
|
|
59
62
|
opacity: 1,
|