@astral/ui 4.47.1 → 4.48.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/DescriptionList/DescriptionList.d.ts +1 -1
- package/components/DescriptionList/DescriptionList.js +31 -8
- package/components/DescriptionList/constants.d.ts +13 -0
- package/components/DescriptionList/constants.js +13 -0
- package/components/DescriptionList/styles.d.ts +0 -2
- package/components/DescriptionList/styles.js +35 -12
- package/components/DescriptionList/types.d.ts +4 -0
- package/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/useGroupedDescriptionItems.d.ts +1 -1
- package/components/DescriptionList/useLogic/index.d.ts +1 -0
- package/components/DescriptionList/useLogic/index.js +1 -0
- package/components/DescriptionList/useLogic/useLogic.d.ts +8 -0
- package/components/DescriptionList/useLogic/useLogic.js +21 -0
- package/node/components/DescriptionList/DescriptionList.d.ts +1 -1
- package/node/components/DescriptionList/DescriptionList.js +31 -8
- package/node/components/DescriptionList/constants.d.ts +13 -0
- package/node/components/DescriptionList/constants.js +16 -0
- package/node/components/DescriptionList/styles.d.ts +0 -2
- package/node/components/DescriptionList/styles.js +34 -11
- package/node/components/DescriptionList/types.d.ts +4 -0
- package/node/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/useGroupedDescriptionItems.d.ts +1 -1
- package/node/components/DescriptionList/useLogic/index.d.ts +1 -0
- package/node/components/DescriptionList/useLogic/index.js +17 -0
- package/node/components/DescriptionList/useLogic/useLogic.d.ts +8 -0
- package/node/components/DescriptionList/useLogic/useLogic.js +25 -0
- package/package.json +1 -1
- /package/components/DescriptionList/{hooks → useLogic/hooks}/index.d.ts +0 -0
- /package/components/DescriptionList/{hooks → useLogic/hooks}/index.js +0 -0
- /package/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/index.d.ts +0 -0
- /package/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/index.js +0 -0
- /package/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/useGroupedDescriptionItems.js +0 -0
- /package/node/components/DescriptionList/{hooks → useLogic/hooks}/index.d.ts +0 -0
- /package/node/components/DescriptionList/{hooks → useLogic/hooks}/index.js +0 -0
- /package/node/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/index.d.ts +0 -0
- /package/node/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/index.js +0 -0
- /package/node/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/useGroupedDescriptionItems.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DescriptionListProps } from './types';
|
|
2
|
-
export declare const DescriptionList: ({ items, variant: listVariant, title, direction, ...props }: DescriptionListProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DescriptionList: ({ items, variant: listVariant, title, direction, alignNameWidth, leader, ...props }: DescriptionListProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,11 +4,32 @@ import { Description } from '../Description';
|
|
|
4
4
|
import { GuidTypography } from '../GuidTypography';
|
|
5
5
|
import { Tag } from '../Tag';
|
|
6
6
|
import { Typography } from '../Typography';
|
|
7
|
-
import {
|
|
7
|
+
import { cva } from '../utils/cva';
|
|
8
|
+
import { descriptionListClassnames } from './constants';
|
|
8
9
|
import { DescriptionWrapper, ListWrapper, StyledDescriptionName, StyledDescriptionValue, Title, Wrapper, } from './styles';
|
|
10
|
+
import { useLogic } from './useLogic';
|
|
9
11
|
import { getTooltipProps } from './utils';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const descriptionList = cva(descriptionListClassnames.root, {
|
|
13
|
+
variants: {
|
|
14
|
+
variant: {
|
|
15
|
+
contained: descriptionListClassnames.contained,
|
|
16
|
+
default: descriptionListClassnames.default,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const descriptionItem = cva(descriptionListClassnames.item, {
|
|
21
|
+
variants: {
|
|
22
|
+
alignNameWidth: {
|
|
23
|
+
true: descriptionListClassnames.itemAlignNameWidth,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
export const DescriptionList = ({ items, variant: listVariant = 'default', title, direction, alignNameWidth, leader, ...props }) => {
|
|
28
|
+
const { descriptionItems, descriptionListStyles } = useLogic({
|
|
29
|
+
items,
|
|
30
|
+
alignNameWidth,
|
|
31
|
+
leader,
|
|
32
|
+
});
|
|
12
33
|
const render = useCallback((value, optionProps) => {
|
|
13
34
|
const { renderValue, color, canCopy, copyPosition, variant, copyText } = optionProps;
|
|
14
35
|
if (renderValue) {
|
|
@@ -25,19 +46,21 @@ export const DescriptionList = ({ items, variant: listVariant = 'default', title
|
|
|
25
46
|
}, []);
|
|
26
47
|
const renderTitle = () => {
|
|
27
48
|
if (typeof title === 'string') {
|
|
28
|
-
return _jsx(Title, { variant: "h6", children: title });
|
|
49
|
+
return (_jsx(Title, { variant: "h6", className: descriptionListClassnames.title, children: title }));
|
|
29
50
|
}
|
|
30
|
-
return _jsx(Title, { component: "div", children: title });
|
|
51
|
+
return (_jsx(Title, { component: "div", className: descriptionListClassnames.title, children: title }));
|
|
31
52
|
};
|
|
32
53
|
const renderNote = (note) => {
|
|
33
54
|
if (typeof note === 'string') {
|
|
34
|
-
return (_jsx(Typography, { variant: "caption", color: "textSecondary", children: note }));
|
|
55
|
+
return (_jsx(Typography, { variant: "caption", color: "textSecondary", className: descriptionListClassnames.note, children: note }));
|
|
35
56
|
}
|
|
36
57
|
return note;
|
|
37
58
|
};
|
|
38
59
|
const renderItem = (value, name, options) => {
|
|
39
60
|
const { nameMaxWidth, note, ...restOptions } = options || {};
|
|
40
|
-
return (_jsxs(DescriptionWrapper, {
|
|
61
|
+
return (_jsxs(DescriptionWrapper, { className: descriptionItem({
|
|
62
|
+
alignNameWidth: Boolean(alignNameWidth),
|
|
63
|
+
}), children: [_jsxs(Description, { direction: direction, leader: leader, ...props, component: "div", children: [_jsx(StyledDescriptionName, { "$nameMaxWidth": nameMaxWidth, "$direction": direction, children: name }), render(value, restOptions)] }), note && renderNote(note)] }, `${name}:${value}`));
|
|
41
64
|
};
|
|
42
|
-
return (_jsxs(Wrapper, {
|
|
65
|
+
return (_jsxs(Wrapper, { className: descriptionList({ variant: listVariant }), style: descriptionListStyles, children: [title && renderTitle(), descriptionItems.map((group, groupIndex) => (_jsx(ListWrapper, { "$direction": direction, "$hasDivider": groupIndex !== 0, "$variant": listVariant, children: group.map(({ name, value, options }) => renderItem(value, name, options)) }, groupIndex)))] }));
|
|
43
66
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const descriptionListVariantClassnames: {
|
|
2
|
+
contained: string;
|
|
3
|
+
default: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const descriptionListClassnames: {
|
|
6
|
+
contained: string;
|
|
7
|
+
default: string;
|
|
8
|
+
root: string;
|
|
9
|
+
title: string;
|
|
10
|
+
item: string;
|
|
11
|
+
itemAlignNameWidth: string;
|
|
12
|
+
note: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createUIKitClassname } from '../utils/createUIKitClassname';
|
|
2
|
+
export const descriptionListVariantClassnames = {
|
|
3
|
+
contained: createUIKitClassname('description-list_variant-contained'),
|
|
4
|
+
default: createUIKitClassname('description-list_variant-default'),
|
|
5
|
+
};
|
|
6
|
+
export const descriptionListClassnames = {
|
|
7
|
+
root: createUIKitClassname('description-list'),
|
|
8
|
+
title: createUIKitClassname('description-list__title'),
|
|
9
|
+
item: createUIKitClassname('description-list__item'),
|
|
10
|
+
itemAlignNameWidth: createUIKitClassname('description-list__item_align-name-width'),
|
|
11
|
+
note: createUIKitClassname('description-list__note'),
|
|
12
|
+
...descriptionListVariantClassnames,
|
|
13
|
+
};
|
|
@@ -11,8 +11,6 @@ export declare const StyledDescriptionName: import("../styled").StyledComponent<
|
|
|
11
11
|
export declare const Wrapper: import("../styled").StyledComponent<{
|
|
12
12
|
theme?: import("@emotion/react").Theme | undefined;
|
|
13
13
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
14
|
-
} & {
|
|
15
|
-
$variant: DescriptionListVariant;
|
|
16
14
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
|
|
17
15
|
export declare const ListWrapper: import("../styled").StyledComponent<{
|
|
18
16
|
theme?: import("@emotion/react").Theme | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Description } from '../Description';
|
|
1
|
+
import { Description, descriptionClassnames } from '../Description';
|
|
2
2
|
import { styled } from '../styled';
|
|
3
3
|
import { Typography } from '../Typography';
|
|
4
|
+
import { descriptionListClassnames } from './constants';
|
|
4
5
|
export const StyledDescriptionName = styled(Description.Name, {
|
|
5
6
|
shouldForwardProp: (prop) => !['$nameMaxWidth', '$direction'].includes(prop),
|
|
6
7
|
}) `
|
|
@@ -11,20 +12,17 @@ export const StyledDescriptionName = styled(Description.Name, {
|
|
|
11
12
|
margin-bottom: ${({ theme, $direction }) => Object.is($direction, 'row') ? 0 : theme.spacing(1)};
|
|
12
13
|
}
|
|
13
14
|
`;
|
|
14
|
-
export const Wrapper = styled
|
|
15
|
-
shouldForwardProp: (prop) => !['$variant'].includes(prop),
|
|
16
|
-
}) `
|
|
15
|
+
export const Wrapper = styled.article `
|
|
17
16
|
display: grid;
|
|
18
17
|
|
|
19
|
-
padding: ${({ $variant, theme }) => $variant === 'contained' ? theme.spacing(4) : 0};
|
|
20
|
-
|
|
21
|
-
background-color: ${({ $variant, theme }) => $variant === 'contained'
|
|
22
|
-
? theme.palette.background.default
|
|
23
|
-
: 'transparent'};
|
|
24
|
-
border: ${({ $variant, theme }) => $variant === 'contained'
|
|
25
|
-
? `1px solid ${theme.palette.grey[300]}`
|
|
26
|
-
: 'unset'};
|
|
27
18
|
border-radius: ${({ theme }) => theme.shape.small};
|
|
19
|
+
|
|
20
|
+
&.${descriptionListClassnames.contained} {
|
|
21
|
+
padding: ${({ theme }) => theme.spacing(4)};
|
|
22
|
+
|
|
23
|
+
background-color: ${({ theme }) => theme.palette.background.default};
|
|
24
|
+
border: 1px solid ${({ theme }) => theme.palette.grey[300]};
|
|
25
|
+
}
|
|
28
26
|
`;
|
|
29
27
|
export const ListWrapper = styled('dl', {
|
|
30
28
|
shouldForwardProp: (prop) => !['$direction', '$hasDivider', '$variant'].includes(prop),
|
|
@@ -60,6 +58,31 @@ export const DescriptionWrapper = styled.div `
|
|
|
60
58
|
display: flex;
|
|
61
59
|
flex-direction: column;
|
|
62
60
|
gap: ${({ theme }) => theme.spacing(1)};
|
|
61
|
+
|
|
62
|
+
${({ theme }) => theme.breakpoints.up('sm')} {
|
|
63
|
+
&.${descriptionListClassnames.itemAlignNameWidth} {
|
|
64
|
+
display: grid;
|
|
65
|
+
grid-template-columns: var(--name-desktop-width) 1fr;
|
|
66
|
+
|
|
67
|
+
& .${descriptionListClassnames.note} {
|
|
68
|
+
grid-column: 1 / -1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
& .${descriptionClassnames.root} {
|
|
72
|
+
display: grid;
|
|
73
|
+
grid-column: 1 / -1;
|
|
74
|
+
grid-template-columns: inherit;
|
|
75
|
+
gap: ${({ theme }) => theme.spacing(1)};
|
|
76
|
+
|
|
77
|
+
/* Причина игнора: прогрессивное улучшение */
|
|
78
|
+
/* stylelint-disable plugin/no-unsupported-browser-features */
|
|
79
|
+
@supports (grid-template-columns: subgrid) {
|
|
80
|
+
grid-template-columns: subgrid;
|
|
81
|
+
}
|
|
82
|
+
/* stylelint-enable plugin/no-unsupported-browser-features */
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
63
86
|
`;
|
|
64
87
|
export const Title = styled(Typography) `
|
|
65
88
|
margin-bottom: ${({ theme }) => theme.spacing(3)};
|
|
@@ -37,4 +37,8 @@ export type DescriptionListProps = Pick<DescriptionProps, 'justifyContent' | 'le
|
|
|
37
37
|
* Заголовок блока
|
|
38
38
|
*/
|
|
39
39
|
title?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Включает выравнивание колонок DescriptionList с указанной шириной для поля наименования.
|
|
42
|
+
*/
|
|
43
|
+
alignNameWidth?: `${string}px`;
|
|
40
44
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DescriptionListItem, DescriptionListProps } from '
|
|
1
|
+
import type { DescriptionListItem, DescriptionListProps } from '../../../types';
|
|
2
2
|
type UseNormalizedDescriptionItemsParams = Pick<DescriptionListProps, 'items'>;
|
|
3
3
|
/**
|
|
4
4
|
* Группирует элементы описания в логические секции для рендеринга.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
import type { DescriptionListProps } from '../types';
|
|
3
|
+
type UseLogicParams = Pick<DescriptionListProps, 'items' | 'alignNameWidth' | 'leader'>;
|
|
4
|
+
export declare const useLogic: ({ items, alignNameWidth, leader }: UseLogicParams) => {
|
|
5
|
+
descriptionItems: import("../types").DescriptionListItem[][];
|
|
6
|
+
descriptionListStyles: CSSProperties;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useGroupedDescriptionItems } from './hooks';
|
|
3
|
+
export const useLogic = ({ items, alignNameWidth, leader }) => {
|
|
4
|
+
const descriptionItems = useGroupedDescriptionItems({ items });
|
|
5
|
+
const getDescriptionListStyles = () => {
|
|
6
|
+
if (!alignNameWidth) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
return { '--name-desktop-width': alignNameWidth };
|
|
10
|
+
};
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (leader && alignNameWidth) {
|
|
13
|
+
// biome-ignore lint/suspicious/noConsole: Сообщение для интеграторов
|
|
14
|
+
console.error('DescriptionList: Параметры leader и alignNameWidth не могут быть использованы вместе');
|
|
15
|
+
}
|
|
16
|
+
}, [leader, alignNameWidth]);
|
|
17
|
+
return {
|
|
18
|
+
descriptionItems,
|
|
19
|
+
descriptionListStyles: getDescriptionListStyles(),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DescriptionListProps } from './types';
|
|
2
|
-
export declare const DescriptionList: ({ items, variant: listVariant, title, direction, ...props }: DescriptionListProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const DescriptionList: ({ items, variant: listVariant, title, direction, alignNameWidth, leader, ...props }: DescriptionListProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,11 +7,32 @@ const Description_1 = require("../Description");
|
|
|
7
7
|
const GuidTypography_1 = require("../GuidTypography");
|
|
8
8
|
const Tag_1 = require("../Tag");
|
|
9
9
|
const Typography_1 = require("../Typography");
|
|
10
|
-
const
|
|
10
|
+
const cva_1 = require("../utils/cva");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
11
12
|
const styles_1 = require("./styles");
|
|
13
|
+
const useLogic_1 = require("./useLogic");
|
|
12
14
|
const utils_1 = require("./utils");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
+
const descriptionList = (0, cva_1.cva)(constants_1.descriptionListClassnames.root, {
|
|
16
|
+
variants: {
|
|
17
|
+
variant: {
|
|
18
|
+
contained: constants_1.descriptionListClassnames.contained,
|
|
19
|
+
default: constants_1.descriptionListClassnames.default,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const descriptionItem = (0, cva_1.cva)(constants_1.descriptionListClassnames.item, {
|
|
24
|
+
variants: {
|
|
25
|
+
alignNameWidth: {
|
|
26
|
+
true: constants_1.descriptionListClassnames.itemAlignNameWidth,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const DescriptionList = ({ items, variant: listVariant = 'default', title, direction, alignNameWidth, leader, ...props }) => {
|
|
31
|
+
const { descriptionItems, descriptionListStyles } = (0, useLogic_1.useLogic)({
|
|
32
|
+
items,
|
|
33
|
+
alignNameWidth,
|
|
34
|
+
leader,
|
|
35
|
+
});
|
|
15
36
|
const render = (0, react_1.useCallback)((value, optionProps) => {
|
|
16
37
|
const { renderValue, color, canCopy, copyPosition, variant, copyText } = optionProps;
|
|
17
38
|
if (renderValue) {
|
|
@@ -28,20 +49,22 @@ const DescriptionList = ({ items, variant: listVariant = 'default', title, direc
|
|
|
28
49
|
}, []);
|
|
29
50
|
const renderTitle = () => {
|
|
30
51
|
if (typeof title === 'string') {
|
|
31
|
-
return (0, jsx_runtime_1.jsx)(styles_1.Title, { variant: "h6", children: title });
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.Title, { variant: "h6", className: constants_1.descriptionListClassnames.title, children: title }));
|
|
32
53
|
}
|
|
33
|
-
return (0, jsx_runtime_1.jsx)(styles_1.Title, { component: "div", children: title });
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.Title, { component: "div", className: constants_1.descriptionListClassnames.title, children: title }));
|
|
34
55
|
};
|
|
35
56
|
const renderNote = (note) => {
|
|
36
57
|
if (typeof note === 'string') {
|
|
37
|
-
return ((0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "caption", color: "textSecondary", children: note }));
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "caption", color: "textSecondary", className: constants_1.descriptionListClassnames.note, children: note }));
|
|
38
59
|
}
|
|
39
60
|
return note;
|
|
40
61
|
};
|
|
41
62
|
const renderItem = (value, name, options) => {
|
|
42
63
|
const { nameMaxWidth, note, ...restOptions } = options || {};
|
|
43
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.DescriptionWrapper, {
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.DescriptionWrapper, { className: descriptionItem({
|
|
65
|
+
alignNameWidth: Boolean(alignNameWidth),
|
|
66
|
+
}), children: [(0, jsx_runtime_1.jsxs)(Description_1.Description, { direction: direction, leader: leader, ...props, component: "div", children: [(0, jsx_runtime_1.jsx)(styles_1.StyledDescriptionName, { "$nameMaxWidth": nameMaxWidth, "$direction": direction, children: name }), render(value, restOptions)] }), note && renderNote(note)] }, `${name}:${value}`));
|
|
44
67
|
};
|
|
45
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, {
|
|
68
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: descriptionList({ variant: listVariant }), style: descriptionListStyles, children: [title && renderTitle(), descriptionItems.map((group, groupIndex) => ((0, jsx_runtime_1.jsx)(styles_1.ListWrapper, { "$direction": direction, "$hasDivider": groupIndex !== 0, "$variant": listVariant, children: group.map(({ name, value, options }) => renderItem(value, name, options)) }, groupIndex)))] }));
|
|
46
69
|
};
|
|
47
70
|
exports.DescriptionList = DescriptionList;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const descriptionListVariantClassnames: {
|
|
2
|
+
contained: string;
|
|
3
|
+
default: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const descriptionListClassnames: {
|
|
6
|
+
contained: string;
|
|
7
|
+
default: string;
|
|
8
|
+
root: string;
|
|
9
|
+
title: string;
|
|
10
|
+
item: string;
|
|
11
|
+
itemAlignNameWidth: string;
|
|
12
|
+
note: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.descriptionListClassnames = exports.descriptionListVariantClassnames = void 0;
|
|
4
|
+
const createUIKitClassname_1 = require("../utils/createUIKitClassname");
|
|
5
|
+
exports.descriptionListVariantClassnames = {
|
|
6
|
+
contained: (0, createUIKitClassname_1.createUIKitClassname)('description-list_variant-contained'),
|
|
7
|
+
default: (0, createUIKitClassname_1.createUIKitClassname)('description-list_variant-default'),
|
|
8
|
+
};
|
|
9
|
+
exports.descriptionListClassnames = {
|
|
10
|
+
root: (0, createUIKitClassname_1.createUIKitClassname)('description-list'),
|
|
11
|
+
title: (0, createUIKitClassname_1.createUIKitClassname)('description-list__title'),
|
|
12
|
+
item: (0, createUIKitClassname_1.createUIKitClassname)('description-list__item'),
|
|
13
|
+
itemAlignNameWidth: (0, createUIKitClassname_1.createUIKitClassname)('description-list__item_align-name-width'),
|
|
14
|
+
note: (0, createUIKitClassname_1.createUIKitClassname)('description-list__note'),
|
|
15
|
+
...exports.descriptionListVariantClassnames,
|
|
16
|
+
};
|
|
@@ -11,8 +11,6 @@ export declare const StyledDescriptionName: import("@emotion/styled/dist/declara
|
|
|
11
11
|
export declare const Wrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
12
12
|
theme?: import("@emotion/react").Theme | undefined;
|
|
13
13
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
14
|
-
} & {
|
|
15
|
-
$variant: DescriptionListVariant;
|
|
16
14
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
|
|
17
15
|
export declare const ListWrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
18
16
|
theme?: import("@emotion/react").Theme | undefined;
|
|
@@ -4,6 +4,7 @@ exports.Title = exports.DescriptionWrapper = exports.StyledDescriptionValue = ex
|
|
|
4
4
|
const Description_1 = require("../Description");
|
|
5
5
|
const styled_1 = require("../styled");
|
|
6
6
|
const Typography_1 = require("../Typography");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
7
8
|
exports.StyledDescriptionName = (0, styled_1.styled)(Description_1.Description.Name, {
|
|
8
9
|
shouldForwardProp: (prop) => !['$nameMaxWidth', '$direction'].includes(prop),
|
|
9
10
|
}) `
|
|
@@ -14,20 +15,17 @@ exports.StyledDescriptionName = (0, styled_1.styled)(Description_1.Description.N
|
|
|
14
15
|
margin-bottom: ${({ theme, $direction }) => Object.is($direction, 'row') ? 0 : theme.spacing(1)};
|
|
15
16
|
}
|
|
16
17
|
`;
|
|
17
|
-
exports.Wrapper =
|
|
18
|
-
shouldForwardProp: (prop) => !['$variant'].includes(prop),
|
|
19
|
-
}) `
|
|
18
|
+
exports.Wrapper = styled_1.styled.article `
|
|
20
19
|
display: grid;
|
|
21
20
|
|
|
22
|
-
padding: ${({ $variant, theme }) => $variant === 'contained' ? theme.spacing(4) : 0};
|
|
23
|
-
|
|
24
|
-
background-color: ${({ $variant, theme }) => $variant === 'contained'
|
|
25
|
-
? theme.palette.background.default
|
|
26
|
-
: 'transparent'};
|
|
27
|
-
border: ${({ $variant, theme }) => $variant === 'contained'
|
|
28
|
-
? `1px solid ${theme.palette.grey[300]}`
|
|
29
|
-
: 'unset'};
|
|
30
21
|
border-radius: ${({ theme }) => theme.shape.small};
|
|
22
|
+
|
|
23
|
+
&.${constants_1.descriptionListClassnames.contained} {
|
|
24
|
+
padding: ${({ theme }) => theme.spacing(4)};
|
|
25
|
+
|
|
26
|
+
background-color: ${({ theme }) => theme.palette.background.default};
|
|
27
|
+
border: 1px solid ${({ theme }) => theme.palette.grey[300]};
|
|
28
|
+
}
|
|
31
29
|
`;
|
|
32
30
|
exports.ListWrapper = (0, styled_1.styled)('dl', {
|
|
33
31
|
shouldForwardProp: (prop) => !['$direction', '$hasDivider', '$variant'].includes(prop),
|
|
@@ -63,6 +61,31 @@ exports.DescriptionWrapper = styled_1.styled.div `
|
|
|
63
61
|
display: flex;
|
|
64
62
|
flex-direction: column;
|
|
65
63
|
gap: ${({ theme }) => theme.spacing(1)};
|
|
64
|
+
|
|
65
|
+
${({ theme }) => theme.breakpoints.up('sm')} {
|
|
66
|
+
&.${constants_1.descriptionListClassnames.itemAlignNameWidth} {
|
|
67
|
+
display: grid;
|
|
68
|
+
grid-template-columns: var(--name-desktop-width) 1fr;
|
|
69
|
+
|
|
70
|
+
& .${constants_1.descriptionListClassnames.note} {
|
|
71
|
+
grid-column: 1 / -1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
& .${Description_1.descriptionClassnames.root} {
|
|
75
|
+
display: grid;
|
|
76
|
+
grid-column: 1 / -1;
|
|
77
|
+
grid-template-columns: inherit;
|
|
78
|
+
gap: ${({ theme }) => theme.spacing(1)};
|
|
79
|
+
|
|
80
|
+
/* Причина игнора: прогрессивное улучшение */
|
|
81
|
+
/* stylelint-disable plugin/no-unsupported-browser-features */
|
|
82
|
+
@supports (grid-template-columns: subgrid) {
|
|
83
|
+
grid-template-columns: subgrid;
|
|
84
|
+
}
|
|
85
|
+
/* stylelint-enable plugin/no-unsupported-browser-features */
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
66
89
|
`;
|
|
67
90
|
exports.Title = (0, styled_1.styled)(Typography_1.Typography) `
|
|
68
91
|
margin-bottom: ${({ theme }) => theme.spacing(3)};
|
|
@@ -37,4 +37,8 @@ export type DescriptionListProps = Pick<DescriptionProps, 'justifyContent' | 'le
|
|
|
37
37
|
* Заголовок блока
|
|
38
38
|
*/
|
|
39
39
|
title?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Включает выравнивание колонок DescriptionList с указанной шириной для поля наименования.
|
|
42
|
+
*/
|
|
43
|
+
alignNameWidth?: `${string}px`;
|
|
40
44
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DescriptionListItem, DescriptionListProps } from '
|
|
1
|
+
import type { DescriptionListItem, DescriptionListProps } from '../../../types';
|
|
2
2
|
type UseNormalizedDescriptionItemsParams = Pick<DescriptionListProps, 'items'>;
|
|
3
3
|
/**
|
|
4
4
|
* Группирует элементы описания в логические секции для рендеринга.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useLogic"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
import type { DescriptionListProps } from '../types';
|
|
3
|
+
type UseLogicParams = Pick<DescriptionListProps, 'items' | 'alignNameWidth' | 'leader'>;
|
|
4
|
+
export declare const useLogic: ({ items, alignNameWidth, leader }: UseLogicParams) => {
|
|
5
|
+
descriptionItems: import("../types").DescriptionListItem[][];
|
|
6
|
+
descriptionListStyles: CSSProperties;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLogic = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const hooks_1 = require("./hooks");
|
|
6
|
+
const useLogic = ({ items, alignNameWidth, leader }) => {
|
|
7
|
+
const descriptionItems = (0, hooks_1.useGroupedDescriptionItems)({ items });
|
|
8
|
+
const getDescriptionListStyles = () => {
|
|
9
|
+
if (!alignNameWidth) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
return { '--name-desktop-width': alignNameWidth };
|
|
13
|
+
};
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
if (leader && alignNameWidth) {
|
|
16
|
+
// biome-ignore lint/suspicious/noConsole: Сообщение для интеграторов
|
|
17
|
+
console.error('DescriptionList: Параметры leader и alignNameWidth не могут быть использованы вместе');
|
|
18
|
+
}
|
|
19
|
+
}, [leader, alignNameWidth]);
|
|
20
|
+
return {
|
|
21
|
+
descriptionItems,
|
|
22
|
+
descriptionListStyles: getDescriptionListStyles(),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.useLogic = useLogic;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
/package/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/index.d.ts
RENAMED
|
File without changes
|
/package/components/DescriptionList/{hooks → useLogic/hooks}/useGroupedDescriptionItems/index.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|