@cloud-ru/ds-uikit-product-page-layout 2.2.1 → 2.3.1-preview-93c4db1d.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +80 -12
  3. package/dist/cjs/components/Actions/ActionView.d.ts +1 -1
  4. package/dist/cjs/components/Actions/ActionView.js +6 -2
  5. package/dist/cjs/components/Actions/MobileActions.js +37 -16
  6. package/dist/cjs/components/Actions/styles.module.css +5 -0
  7. package/dist/cjs/components/Actions/types.d.ts +16 -7
  8. package/dist/cjs/components/PageForm/styles.module.css +4 -3
  9. package/dist/cjs/components/PageServices/MobilePageServices.d.ts +2 -2
  10. package/dist/cjs/components/PageServices/MobilePageServices.js +2 -2
  11. package/dist/cjs/style.css +9 -3
  12. package/dist/esm/components/Actions/ActionView.d.ts +1 -1
  13. package/dist/esm/components/Actions/ActionView.js +6 -2
  14. package/dist/esm/components/Actions/MobileActions.js +39 -18
  15. package/dist/esm/components/Actions/styles.module.css +5 -0
  16. package/dist/esm/components/Actions/types.d.ts +16 -7
  17. package/dist/esm/components/PageForm/styles.module.css +4 -3
  18. package/dist/esm/components/PageServices/MobilePageServices.d.ts +2 -2
  19. package/dist/esm/components/PageServices/MobilePageServices.js +2 -2
  20. package/dist/esm/style.css +9 -3
  21. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  22. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  23. package/package.json +22 -22
  24. package/src/components/Actions/ActionView.tsx +8 -9
  25. package/src/components/Actions/MobileActions.tsx +68 -21
  26. package/src/components/Actions/styles.module.scss +4 -0
  27. package/src/components/Actions/types.ts +14 -7
  28. package/src/components/PageForm/styles.module.scss +4 -2
  29. 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.2.1",
3
+ "version": "2.3.1-preview-93c4db1d.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.4",
44
- "@cloud-ru/ds-icon-predefined": "^1.0.5",
45
- "@cloud-ru/ds-dropdown": "^1.2.2",
46
- "@cloud-ru/ds-list": "^3.1.2",
47
- "@cloud-ru/ds-button": "^1.0.6",
48
- "@cloud-ru/ds-locale": "^1.0.0",
49
- "@cloud-ru/ds-loader": "^1.0.5",
50
- "@cloud-ru/ds-icons": "^1.7.3",
51
- "@cloud-ru/ds-modal": "^2.1.2",
52
- "@cloud-ru/ds-popover": "^1.1.4",
53
- "@cloud-ru/ds-status": "^1.1.17",
54
- "@cloud-ru/ds-search": "^1.0.20",
55
- "@cloud-ru/ds-tree": "^1.0.46",
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",
60
- "@cloud-ru/ds-typography": "^1.0.2",
61
- "@cloud-ru/ds-uikit-product-copy": "^1.1.19",
62
- "@cloud-ru/ds-utils": "^1.4.0",
63
- "@cloud-ru/ds-block": "^1.0.5"
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-button": "1.0.7",
47
+ "@cloud-ru/ds-icon-predefined": "1.0.6",
48
+ "@cloud-ru/ds-list": "3.1.3",
49
+ "@cloud-ru/ds-loader": "1.0.6",
50
+ "@cloud-ru/ds-locale": "1.0.0",
51
+ "@cloud-ru/ds-icons": "1.7.4",
52
+ "@cloud-ru/ds-modal": "2.1.3",
53
+ "@cloud-ru/ds-search": "1.0.21",
54
+ "@cloud-ru/ds-status": "1.1.18",
55
+ "@cloud-ru/ds-tree": "1.0.47",
56
+ "@cloud-ru/ds-tooltip": "1.0.20",
57
+ "@cloud-ru/ds-typography": "1.0.2",
58
+ "@cloud-ru/ds-truncate-string": "1.0.21",
59
+ "@cloud-ru/ds-popover": "1.1.5",
60
+ "@cloud-ru/ds-uikit-product-button-predefined": "1.0.46",
61
+ "@cloud-ru/ds-uikit-product-copy": "1.1.20",
62
+ "@cloud-ru/ds-uikit-product-quota": "2.1.2-preview-93c4db1d.0",
63
+ "@cloud-ru/ds-utils": "1.4.1"
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
- variant,
21
- tooltip,
22
- hidden = false,
23
- commonProps,
24
- ...buttonProps
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.
@@ -2,16 +2,17 @@ import { LAYOUT_TYPE, withLayoutType } from '@cloud-ru/ds-adaptive';
2
2
  import { Button, VIEW } from '@cloud-ru/ds-button';
3
3
  import { KebabSVG } from '@cloud-ru/ds-icons/interface/system';
4
4
  import { Droplist, DroplistProps, Item } from '@cloud-ru/ds-list';
5
+ import { ModalCustom } from '@cloud-ru/ds-modal';
5
6
  import { Tooltip } from '@cloud-ru/ds-tooltip';
6
- import { quotaLocale, QuotaWidget } from '@cloud-ru/ds-uikit-product-quota';
7
+ import { quotaLocale, QuotaWidgetContent } from '@cloud-ru/ds-uikit-product-quota';
7
8
  import { useDynamicList } from '@cloud-ru/ds-utils';
8
- import { MouseEvent, ReactNode, useRef, useState } from 'react';
9
+ import { MouseEvent, ReactNode, useMemo, useRef, useState } from 'react';
9
10
 
10
11
  import { TEST_IDS } from '../../constants';
11
12
  import { ActionView } from './ActionView';
12
13
  import { BUTTON_TYPE } from './constants';
13
14
  import styles from './styles.module.scss';
14
- import { ActionsProps } from './types';
15
+ import { Action, ActionsProps } from './types';
15
16
  import { hasVisibleActions } from './utils';
16
17
 
17
18
  /** Узкий тип action'а-кнопки внутри droplist'а: читаем только используемые слоты. */
@@ -23,11 +24,27 @@ type SimpleButtonAction = {
23
24
  onClick?(event: MouseEvent<HTMLElement>): void;
24
25
  };
25
26
 
27
+ function isOverflowOnly(action: Action) {
28
+ return action.variant === BUTTON_TYPE.Kebab || action.variant === BUTTON_TYPE.Quota;
29
+ }
30
+
26
31
  function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
27
32
  const containerRef = useRef<HTMLDivElement>(null);
28
33
 
29
34
  const [isOpen, setIsOpen] = useState(false);
30
- const { visibleItems, hiddenItems } = useDynamicList({ parentContainerRef: containerRef, items, maxVisibleItems });
35
+ const [openQuotaIndex, setOpenQuotaIndex] = useState<number>();
36
+ const activeAction = openQuotaIndex === undefined ? undefined : items[openQuotaIndex];
37
+ const openQuota = activeAction?.variant === BUTTON_TYPE.Quota ? activeAction : undefined;
38
+ const availableItems = useMemo(() => items.filter(item => !item.hidden), [items]);
39
+ const measurableItems = useMemo(
40
+ () => availableItems.filter(action => action.variant !== BUTTON_TYPE.Quota),
41
+ [availableItems],
42
+ );
43
+ const { visibleItems, hiddenItems } = useDynamicList({
44
+ parentContainerRef: containerRef,
45
+ items: measurableItems,
46
+ maxVisibleItems,
47
+ });
31
48
 
32
49
  const { t: tQuota } = quotaLocale.useTranslations();
33
50
 
@@ -35,10 +52,21 @@ function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
35
52
  return null;
36
53
  }
37
54
 
38
- const hiddenItemsWithKebab = hiddenItems.concat(visibleItems.filter(item => item.variant === BUTTON_TYPE.Kebab));
39
- const visibleItemsWithoutKebab = visibleItems.filter(item => item.variant !== BUTTON_TYPE.Kebab);
40
-
41
- const droplistItems = hiddenItemsWithKebab.reduce<Item[]>((acc, action) => {
55
+ const overflowItems = availableItems.filter(action => isOverflowOnly(action) || hiddenItems.includes(action));
56
+ const visibleActions = visibleItems.filter(action => !isOverflowOnly(action));
57
+
58
+ const droplistItems = overflowItems.reduce<Item[]>((acc, action) => {
59
+ if (action.variant === 'custom') {
60
+ const { asListItem } = action.render();
61
+ acc.push({
62
+ ...asListItem,
63
+ onClick: (event: MouseEvent<HTMLElement>) => {
64
+ setIsOpen(false);
65
+ if ('onClick' in asListItem) asListItem.onClick?.(event);
66
+ },
67
+ });
68
+ return acc;
69
+ }
42
70
  switch (action.variant) {
43
71
  case BUTTON_TYPE.Tonal:
44
72
  case BUTTON_TYPE.Simple:
@@ -71,19 +99,14 @@ function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
71
99
  break;
72
100
  }
73
101
  case BUTTON_TYPE.Quota: {
74
- // QuotaWidget самодостаточен (свой триггер + dropdown) — рендерим инлайн как inactive-айтем.
75
- const quotaWidget = <QuotaWidget {...action} buttonProps={{ size: 'm', fullWidth: true }} />;
76
-
77
102
  acc.push({
78
- type: 'group',
79
- label: tQuota('quotas'),
80
- divider: acc.length > 0,
81
- items: [
82
- {
83
- inactive: true,
84
- content: action.tooltip ? <Tooltip {...action.tooltip}>{quotaWidget}</Tooltip> : quotaWidget,
85
- },
86
- ],
103
+ content: { label: action.buttonProps?.label ?? tQuota('quotas') },
104
+ disabled: action.buttonProps?.disabled,
105
+ onClick: () => {
106
+ setIsOpen(false);
107
+ setOpenQuotaIndex(items.indexOf(action));
108
+ action.onWidgetOpen?.();
109
+ },
87
110
  });
88
111
  break;
89
112
  }
@@ -144,7 +167,31 @@ function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
144
167
  </Droplist>
145
168
  )}
146
169
 
147
- {visibleItemsWithoutKebab.map((action, index) => (
170
+ {openQuota && (
171
+ <ModalCustom open onClose={() => setOpenQuotaIndex(undefined)} snapPoints={[1]}>
172
+ <ModalCustom.Header title={tQuota('quotas')} subtitle={openQuota.projectName} />
173
+ <ModalCustom.Body
174
+ content={
175
+ <QuotaWidgetContent
176
+ quotas={openQuota.quotas}
177
+ quotasUrl={openQuota.quotasUrl}
178
+ projectName={openQuota.projectName}
179
+ loading={openQuota.loading}
180
+ error={openQuota.error}
181
+ onRefresh={openQuota.onRefresh}
182
+ canEditQuota={openQuota.canEditQuota}
183
+ onIncreaseQuotaClick={openQuota.onIncreaseQuotaClick}
184
+ onQuotasUrlClick={openQuota.onQuotasUrlClick}
185
+ disableSorting={openQuota.disableSorting}
186
+ skeletonRowCount={openQuota.skeletonRowCount}
187
+ hideMobileHeader
188
+ />
189
+ }
190
+ />
191
+ </ModalCustom>
192
+ )}
193
+
194
+ {visibleActions.map((action, index) => (
148
195
  <ActionView
149
196
  {...action}
150
197
  key={index}
@@ -34,3 +34,7 @@
34
34
  flex: 0 0 auto;
35
35
  }
36
36
  }
37
+
38
+ .mobileActionsWrapper .button[data-full-width]:not([data-variant='icon-only']) {
39
+ min-width: max-content;
40
+ }
@@ -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
- * Action — один элемент панели действий. Дискриминированный union по `variant` (`BUTTON_TYPE`).
19
- * Простые кнопки (`filled`/`outline`/`tonal`/`function`/`simple`) маппятся на единый `Button` из
20
- * `@cloud-ru/ds-button` с соответствующим `view`; составные (`dropdown`/`kebab`/`droplist`/`quota`) — на
21
- * предопределённые обёртки.
22
- */
23
- export type Action = {
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
- min-width: fit-content;
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}