@cloud-ru/ds-uikit-product-page-layout 2.2.1 → 2.3.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/CHANGELOG.md +12 -0
- package/README.md +80 -12
- package/dist/cjs/components/Actions/ActionView.d.ts +1 -1
- package/dist/cjs/components/Actions/ActionView.js +6 -2
- package/dist/cjs/components/Actions/MobileActions.js +18 -1
- package/dist/cjs/components/Actions/styles.module.css +5 -0
- package/dist/cjs/components/Actions/types.d.ts +16 -7
- package/dist/cjs/components/PageForm/styles.module.css +4 -3
- package/dist/cjs/components/PageServices/MobilePageServices.d.ts +2 -2
- package/dist/cjs/components/PageServices/MobilePageServices.js +2 -2
- package/dist/cjs/style.css +9 -3
- package/dist/esm/components/Actions/ActionView.d.ts +1 -1
- package/dist/esm/components/Actions/ActionView.js +6 -2
- package/dist/esm/components/Actions/MobileActions.js +19 -2
- package/dist/esm/components/Actions/styles.module.css +5 -0
- package/dist/esm/components/Actions/types.d.ts +16 -7
- package/dist/esm/components/PageForm/styles.module.css +4 -3
- package/dist/esm/components/PageServices/MobilePageServices.d.ts +2 -2
- package/dist/esm/components/PageServices/MobilePageServices.js +2 -2
- package/dist/esm/style.css +9 -3
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +20 -20
- package/src/components/Actions/ActionView.tsx +8 -9
- package/src/components/Actions/MobileActions.tsx +18 -2
- package/src/components/Actions/styles.module.scss +4 -0
- package/src/components/Actions/types.ts +14 -7
- package/src/components/PageForm/styles.module.scss +4 -2
- package/src/components/PageServices/MobilePageServices.tsx +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/ds-uikit-product-page-layout",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Набор страничных раскладок продуктового кабинета — каталог, детальная страница сервиса, форма, дерево-навигация, сайдбар и общие слоты — с адаптацией desktop/mobile через AdaptiveProvider.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,27 +40,27 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"classnames": "^2.5.1",
|
|
43
|
-
"@cloud-ru/ds-adaptive": "^1.0.
|
|
44
|
-
"@cloud-ru/ds-
|
|
45
|
-
"@cloud-ru/ds-
|
|
46
|
-
"@cloud-ru/ds-
|
|
47
|
-
"@cloud-ru/ds-
|
|
43
|
+
"@cloud-ru/ds-adaptive": "^1.0.5",
|
|
44
|
+
"@cloud-ru/ds-dropdown": "^1.2.3",
|
|
45
|
+
"@cloud-ru/ds-block": "^1.0.6",
|
|
46
|
+
"@cloud-ru/ds-icon-predefined": "^1.0.6",
|
|
47
|
+
"@cloud-ru/ds-loader": "^1.0.6",
|
|
48
|
+
"@cloud-ru/ds-icons": "^1.7.4",
|
|
49
|
+
"@cloud-ru/ds-list": "^3.1.3",
|
|
48
50
|
"@cloud-ru/ds-locale": "^1.0.0",
|
|
49
|
-
"@cloud-ru/ds-
|
|
50
|
-
"@cloud-ru/ds-
|
|
51
|
-
"@cloud-ru/ds-
|
|
52
|
-
"@cloud-ru/ds-
|
|
53
|
-
"@cloud-ru/ds-
|
|
54
|
-
"@cloud-ru/ds-
|
|
55
|
-
"@cloud-ru/ds-
|
|
56
|
-
"@cloud-ru/ds-tooltip": "^1.0.19",
|
|
57
|
-
"@cloud-ru/ds-truncate-string": "^1.0.20",
|
|
58
|
-
"@cloud-ru/ds-uikit-product-button-predefined": "^1.0.45",
|
|
59
|
-
"@cloud-ru/ds-uikit-product-quota": "^2.1.0",
|
|
51
|
+
"@cloud-ru/ds-modal": "^2.1.3",
|
|
52
|
+
"@cloud-ru/ds-popover": "^1.1.5",
|
|
53
|
+
"@cloud-ru/ds-status": "^1.1.18",
|
|
54
|
+
"@cloud-ru/ds-tree": "^1.0.47",
|
|
55
|
+
"@cloud-ru/ds-search": "^1.0.21",
|
|
56
|
+
"@cloud-ru/ds-tooltip": "^1.0.20",
|
|
57
|
+
"@cloud-ru/ds-truncate-string": "^1.0.21",
|
|
60
58
|
"@cloud-ru/ds-typography": "^1.0.2",
|
|
61
|
-
"@cloud-ru/ds-uikit-product-copy": "^1.1.
|
|
62
|
-
"@cloud-ru/ds-
|
|
63
|
-
"@cloud-ru/ds-
|
|
59
|
+
"@cloud-ru/ds-uikit-product-copy": "^1.1.20",
|
|
60
|
+
"@cloud-ru/ds-uikit-product-button-predefined": "^1.0.46",
|
|
61
|
+
"@cloud-ru/ds-uikit-product-quota": "^2.1.1",
|
|
62
|
+
"@cloud-ru/ds-utils": "^1.4.1",
|
|
63
|
+
"@cloud-ru/ds-button": "^1.0.7"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
@@ -16,17 +16,16 @@ type CommonProps = { className?: string; size?: Size; fullWidth?: boolean };
|
|
|
16
16
|
* `@ds`-примитивы, которые берут раскладку из `AdaptiveProvider`. Раскладку фиксируют обёртки
|
|
17
17
|
* `DesktopActions` / `MobileActions` (`withLayoutType`), поэтому отдельный проп `layoutType` не нужен.
|
|
18
18
|
*/
|
|
19
|
-
export function ActionView({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}: Action & { commonProps: CommonProps }) {
|
|
26
|
-
if (hidden) {
|
|
27
|
-
return null;
|
|
19
|
+
export function ActionView({ hidden, tooltip, commonProps, ...action }: Action & { commonProps: CommonProps }) {
|
|
20
|
+
if (hidden) return null;
|
|
21
|
+
|
|
22
|
+
if (action.variant === 'custom') {
|
|
23
|
+
const content = <div className={commonProps.className}>{action.render().default}</div>;
|
|
24
|
+
return tooltip ? <Tooltip {...tooltip}>{content}</Tooltip> : content;
|
|
28
25
|
}
|
|
29
26
|
|
|
27
|
+
const { variant, ...buttonProps } = action;
|
|
28
|
+
|
|
30
29
|
// disableSpanWrapper — кнопка остаётся ПРЯМЫМ flex-потомком контейнера действий: без него Tooltip
|
|
31
30
|
// добавляет span-обёртку (`flex:0 1 auto`), и `fullWidth`-кнопка (`flex:1 1 0`) не растягивается на
|
|
32
31
|
// всю ширину (mobile: 2 действия должны делить строку). Как в MobilePageForm ButtonGroup.
|
|
@@ -5,7 +5,7 @@ import { Droplist, DroplistProps, Item } from '@cloud-ru/ds-list';
|
|
|
5
5
|
import { Tooltip } from '@cloud-ru/ds-tooltip';
|
|
6
6
|
import { quotaLocale, QuotaWidget } from '@cloud-ru/ds-uikit-product-quota';
|
|
7
7
|
import { useDynamicList } from '@cloud-ru/ds-utils';
|
|
8
|
-
import { MouseEvent, ReactNode, useRef, useState } from 'react';
|
|
8
|
+
import { MouseEvent, ReactNode, useMemo, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { TEST_IDS } from '../../constants';
|
|
11
11
|
import { ActionView } from './ActionView';
|
|
@@ -27,7 +27,12 @@ function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
|
|
|
27
27
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
28
28
|
|
|
29
29
|
const [isOpen, setIsOpen] = useState(false);
|
|
30
|
-
const
|
|
30
|
+
const availableItems = useMemo(() => items.filter(item => !item.hidden), [items]);
|
|
31
|
+
const { visibleItems, hiddenItems } = useDynamicList({
|
|
32
|
+
parentContainerRef: containerRef,
|
|
33
|
+
items: availableItems,
|
|
34
|
+
maxVisibleItems,
|
|
35
|
+
});
|
|
31
36
|
|
|
32
37
|
const { t: tQuota } = quotaLocale.useTranslations();
|
|
33
38
|
|
|
@@ -39,6 +44,17 @@ function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
|
|
|
39
44
|
const visibleItemsWithoutKebab = visibleItems.filter(item => item.variant !== BUTTON_TYPE.Kebab);
|
|
40
45
|
|
|
41
46
|
const droplistItems = hiddenItemsWithKebab.reduce<Item[]>((acc, action) => {
|
|
47
|
+
if (action.variant === 'custom') {
|
|
48
|
+
const { asListItem } = action.render();
|
|
49
|
+
acc.push({
|
|
50
|
+
...asListItem,
|
|
51
|
+
onClick: (event: MouseEvent<HTMLElement>) => {
|
|
52
|
+
setIsOpen(false);
|
|
53
|
+
if ('onClick' in asListItem) asListItem.onClick?.(event);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return acc;
|
|
57
|
+
}
|
|
42
58
|
switch (action.variant) {
|
|
43
59
|
case BUTTON_TYPE.Tonal:
|
|
44
60
|
case BUTTON_TYPE.Simple:
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ButtonProps } from '@cloud-ru/ds-button';
|
|
2
|
+
import { Item } from '@cloud-ru/ds-list';
|
|
2
3
|
import { TooltipProps } from '@cloud-ru/ds-tooltip';
|
|
3
4
|
import { ButtonDropdownProps } from '@cloud-ru/ds-uikit-product-button-predefined';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
4
6
|
|
|
5
7
|
import { ButtonDroplistProps } from './buttons/ButtonDroplist';
|
|
6
8
|
import { ButtonKebabProps } from './buttons/ButtonKebab';
|
|
@@ -14,13 +16,18 @@ import { BUTTON_TYPE } from './constants';
|
|
|
14
16
|
export type ActionButtonProps =
|
|
15
17
|
(ButtonProps & { href?: never; target?: never }) | (Omit<ButtonProps<'a'>, 'as'> & { as: 'a' });
|
|
16
18
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
|
|
19
|
+
/** Кастомное действие с представлениями для панели и выпадающего меню. */
|
|
20
|
+
export type CustomAction = {
|
|
21
|
+
variant: 'custom';
|
|
22
|
+
hidden?: boolean;
|
|
23
|
+
tooltip?: TooltipProps;
|
|
24
|
+
/** Вызывается при рендеринге; React hooks следует использовать внутри компонента default. */
|
|
25
|
+
render(): { default: ReactNode; asListItem: Item };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type Action = CustomAction | StandardAction;
|
|
29
|
+
|
|
30
|
+
type StandardAction = {
|
|
24
31
|
tooltip?: TooltipProps;
|
|
25
32
|
hidden?: boolean;
|
|
26
33
|
} & (
|
|
@@ -7,10 +7,11 @@ $card-padding: block.$sn-block-anatomy-l-padding;
|
|
|
7
7
|
.container {
|
|
8
8
|
display: flex;
|
|
9
9
|
gap: base.$sn-primitive-dimension-24;
|
|
10
|
-
justify-content: center;
|
|
10
|
+
justify-content: safe center;
|
|
11
11
|
|
|
12
12
|
box-sizing: border-box;
|
|
13
|
-
|
|
13
|
+
width: 100%;
|
|
14
|
+
min-width: 0;
|
|
14
15
|
min-height: 100%;
|
|
15
16
|
padding: base.$sn-density-spacing-interval-l;
|
|
16
17
|
}
|
|
@@ -114,6 +115,7 @@ $card-padding: block.$sn-block-anatomy-l-padding;
|
|
|
114
115
|
|
|
115
116
|
display: flex;
|
|
116
117
|
flex-direction: column;
|
|
118
|
+
flex-shrink: 0;
|
|
117
119
|
gap: base.$sn-primitive-dimension-4;
|
|
118
120
|
align-self: flex-start;
|
|
119
121
|
// 304px — фиксированная ширина боковой колонки, токена нет.
|
|
@@ -9,7 +9,7 @@ import styles from './mobileStyles.module.scss';
|
|
|
9
9
|
|
|
10
10
|
export type MobilePageServicesProps = WithSupportProps<
|
|
11
11
|
PropsWithChildren<
|
|
12
|
-
Pick<HeadlineProps, 'title' | 'slotBeforeTitle' | 'subtitle' | 'slotAfterTitle'> & {
|
|
12
|
+
Pick<HeadlineProps, 'title' | 'slotBeforeTitle' | 'subtitle' | 'slotAfterTitle' | 'truncateTitle'> & {
|
|
13
13
|
className?: string;
|
|
14
14
|
sidebar?: SidebarSelectProps;
|
|
15
15
|
actions?: ActionsProps['items'];
|
|
@@ -28,6 +28,7 @@ export function MobilePageServices({
|
|
|
28
28
|
subtitle,
|
|
29
29
|
slotBeforeTitle,
|
|
30
30
|
maxVisibleActionsItems,
|
|
31
|
+
truncateTitle,
|
|
31
32
|
...rest
|
|
32
33
|
}: MobilePageServicesProps) {
|
|
33
34
|
return (
|
|
@@ -36,6 +37,7 @@ export function MobilePageServices({
|
|
|
36
37
|
<div className={styles.headlineWrapper}>
|
|
37
38
|
<Headline
|
|
38
39
|
title={title}
|
|
40
|
+
truncateTitle={truncateTitle}
|
|
39
41
|
slotBeforeTitle={slotBeforeTitle}
|
|
40
42
|
slotAfterTitle={slotAfterTitle}
|
|
41
43
|
subtitle={subtitle}
|