@cloud-ru/ds-uikit-product-page-layout 2.1.2-preview-de7dadcf.0 → 2.1.2-preview-b67f9a8d.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/README.md CHANGED
@@ -104,7 +104,7 @@ import {
104
104
 
105
105
  | Prop | Type | Default | Description |
106
106
  |------|------|---------|-------------|
107
- | `actions` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `QuotaWidgetPropsBase` | — | |
107
+ | `actions` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `CustomAction` \| `QuotaWidgetPropsBase` | — | |
108
108
  | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
109
109
  | `className` | `string` | — | CSS-класс |
110
110
  | `data-test-id` | `string` | — | |
@@ -113,7 +113,7 @@ import {
113
113
 
114
114
  ##### Related types
115
115
 
116
- - `Action` = `{ tooltip?: TooltipProps; hidden?: boolean; } & (({ variant?: typeof BUTTON_TYPE.Filled; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Outline; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Tonal; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Function; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Simple; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Dropdown; } & { 'data-test-id'?: string; } & AriaAttributes & Omit<ButtonProps, "view" | "icon" | "size" | "iconPosition"> & { size?: "xs" | NonNullable<Size | undefined>; className?: string; open?: boolean; onOpenChange?: (open: boolean) => void; } & { items: Item[]; closeOnPopstate?: boolean | undefined; triggerClassName?: string | undefined; placement?: Placement | undefined; closeDroplistOnItemClick?: boolean | undefined; }) | ({ variant: typeof BUTTON_TYPE.Kebab; } & ButtonKebabProps) | ({ variant: typeof BUTTON_TYPE.Droplist; } & ButtonDroplistProps) | ({ variant: typeof BUTTON_TYPE.Quota; } & { 'data-test-id'?: string; } & AriaAttributes & QuotaWidgetPropsBase & { quotasUrl: string; onQuotasUrlClick?: () => void; buttonProps?: Pick<ButtonProps, "size" | "className" | "fullWidth" | "label" | "appearance" | "disabled" | "view">; }))`
116
+ - `Action` = `CustomAction | StandardAction`
117
117
 
118
118
  **ButtonDroplistProps**
119
119
 
@@ -129,6 +129,16 @@ import {
129
129
  | `button` | `ButtonProps` | — | |
130
130
  | `list` | `DroplistListProps` \| `DroplistMobileSlots` \| `DroplistProps` \| `EmptyState` \| `PublicListContextType` \| `ScrollProps` \| `SelectionState` | — | |
131
131
 
132
+ **CustomAction**
133
+
134
+ | Prop | Type | Default | Description |
135
+ |------|------|---------|-------------|
136
+ | `hidden` | `boolean \| undefined` | — | |
137
+ | `render` | `() => { default: ReactNode; asListItem: Item; }` | — | Вызывается при рендеринге; React hooks следует использовать внутри компонента default. |
138
+ | `tooltip` | `TooltipProps` | — | |
139
+ | `type` | `"custom"` | — | |
140
+ | `variant` | `undefined` | — | |
141
+
132
142
  ## PageServices
133
143
 
134
144
  Детальная страница инстанса — селект раздела, заголовок со статусом, действия и контент. Адаптивная — на mobile селект выносится наверх full-bleed-строкой.
@@ -162,7 +172,7 @@ import {
162
172
 
163
173
  | Prop | Type | Default | Description |
164
174
  |------|------|---------|-------------|
165
- | `actions` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `QuotaWidgetPropsBase` | — | |
175
+ | `actions` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `CustomAction` \| `QuotaWidgetPropsBase` | — | |
166
176
  | `autoHeight` | `boolean` | — | |
167
177
  | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
168
178
  | `className` | `string` | — | |
@@ -178,7 +188,7 @@ import {
178
188
 
179
189
  ##### Related types
180
190
 
181
- - `Action` = `{ tooltip?: TooltipProps; hidden?: boolean; } & (({ variant?: typeof BUTTON_TYPE.Filled; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Outline; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Tonal; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Function; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Simple; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Dropdown; } & { 'data-test-id'?: string; } & AriaAttributes & Omit<ButtonProps, "view" | "icon" | "size" | "iconPosition"> & { size?: "xs" | NonNullable<Size | undefined>; className?: string; open?: boolean; onOpenChange?: (open: boolean) => void; } & { items: Item[]; closeOnPopstate?: boolean | undefined; triggerClassName?: string | undefined; placement?: Placement | undefined; closeDroplistOnItemClick?: boolean | undefined; }) | ({ variant: typeof BUTTON_TYPE.Kebab; } & ButtonKebabProps) | ({ variant: typeof BUTTON_TYPE.Droplist; } & ButtonDroplistProps) | ({ variant: typeof BUTTON_TYPE.Quota; } & { 'data-test-id'?: string; } & AriaAttributes & QuotaWidgetPropsBase & { quotasUrl: string; onQuotasUrlClick?: () => void; buttonProps?: Pick<ButtonProps, "size" | "className" | "fullWidth" | "label" | "appearance" | "disabled" | "view">; }))`
191
+ - `Action` = `CustomAction | StandardAction`
182
192
 
183
193
  **ButtonDroplistProps**
184
194
 
@@ -194,6 +204,16 @@ import {
194
204
  | `button` | `ButtonProps` | — | |
195
205
  | `list` | `DroplistListProps` \| `DroplistMobileSlots` \| `DroplistProps` \| `EmptyState` \| `PublicListContextType` \| `ScrollProps` \| `SelectionState` | — | |
196
206
 
207
+ **CustomAction**
208
+
209
+ | Prop | Type | Default | Description |
210
+ |------|------|---------|-------------|
211
+ | `hidden` | `boolean \| undefined` | — | |
212
+ | `render` | `() => { default: ReactNode; asListItem: Item; }` | — | Вызывается при рендеринге; React hooks следует использовать внутри компонента default. |
213
+ | `tooltip` | `TooltipProps` | — | |
214
+ | `type` | `"custom"` | — | |
215
+ | `variant` | `undefined` | — | |
216
+
197
217
  **Documentation**
198
218
 
199
219
  | Prop | Type | Default | Description |
@@ -238,6 +258,27 @@ import {
238
258
  | `label` | `string` | — | |
239
259
  | `onClick` | `((e: MouseEvent<HTMLElement>) => void) \| undefined` | — | |
240
260
 
261
+ ### Кастомные действия
262
+
263
+ Элемент `type: 'custom'` возвращает два представления: `default` для панели действий и `asListItem` (тип `Item` из `@cloud-ru/ds-list`) для меню при нехватке места на мобильном экране. `hidden` скрывает действие. Функция `render` должна быть чистой; React hooks используются внутри компонента, возвращаемого в `default`.
264
+
265
+ ```tsx
266
+ const actions: Action[] = [
267
+ {
268
+ type: 'custom',
269
+ render: () => ({
270
+ default: <Button label='Создать снимок диска' onClick={createSnapshot} />,
271
+ asListItem: {
272
+ content: { label: 'Создать снимок диска' },
273
+ onClick: createSnapshot,
274
+ },
275
+ }),
276
+ },
277
+ ];
278
+ ```
279
+
280
+ Свойство `hidden` поддерживается и для кастомных действий: скрытое действие не занимает место в панели, не попадает в меню, его `render` не вызывается.
281
+
241
282
  ## PageForm
242
283
 
243
284
  Раскладка формы создания/настройки — степпер, контент, сайд-блок и sticky-футер с оценкой бюджета. Адаптивная.
@@ -544,7 +585,7 @@ import {
544
585
  | `disabled` | `boolean` | — | Отключена |
545
586
  | `error` | `boolean` | — | Флаг ошибки при загрузке квот |
546
587
  | `fullWidth` | `boolean` | — | На всю ширину |
547
- | `hidden` | `boolean` | `false` | |
588
+ | `hidden` | `boolean` | — | |
548
589
  | `href` | `string` | — | |
549
590
  | `icon` | `ReactNode` | — | Иконка |
550
591
  | `iconPosition` | `"after"` \| `"before"` | — | Позиция иконки относительно текста |
@@ -564,11 +605,13 @@ import {
564
605
  | `projectName` | `string` | — | Название проекта, по которому отображаются квоты |
565
606
  | `quotas` | `QuotaItem[]` | — | Список квот для отображения |
566
607
  | `quotasUrl` | `string` | — | Ссылка на страницу квот по проекту |
608
+ | `render` | `() => { default: ReactNode; asListItem: Item; }` | — | Вызывается при рендеринге; React hooks следует использовать внутри компонента default. |
567
609
  | `size` | `"l"` \| `"m"` \| `"s"` \| `"xs"` | — | Размер <br/> Размер триггера; для `xs` применяется кнопка `s`. |
568
610
  | `skeletonRowCount` | `number` | `4` | Количество строк-заглушек, пока идёт загрузка. <br/> Строка — это ряд сетки: в две колонки (desktop-дропдаун) она даёт две карточки, <br/> в одну (mobile, аккордеон `QuotaWidgetMini`) — одну. |
569
611
  | `target` | `HTMLAttributeAnchorTarget` | — | |
570
612
  | `tooltip` | `TooltipProps` | — | |
571
613
  | `triggerClassName` | `string` | — | CSS-класс триггера |
614
+ | `type` | `"custom"` | — | |
572
615
  | `variant` | `"dropdown"` \| `"droplist"` \| `"filled"` \| `"function"` \| `"kebab"` \| `"outline"` \| `"quota"` \| `"simple"` \| `"tonal"` | — | |
573
616
  | `view` | `"elevated"` \| `"filled"` \| `"function"` \| `"outline"` \| `"simple"` \| `"tonal"` | — | Вариант кнопки (Figma: filled, outline, function, simple, elevated) |
574
617
 
@@ -749,12 +792,12 @@ import {
749
792
 
750
793
  | Prop | Type | Default | Description |
751
794
  |------|------|---------|-------------|
752
- | `items` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `QuotaWidgetPropsBase` | — | |
795
+ | `items` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `CustomAction` \| `QuotaWidgetPropsBase` | — | |
753
796
  | `maxVisibleItems` | `number` | — | |
754
797
 
755
798
  #### Related types
756
799
 
757
- - `Action` = `{ tooltip?: TooltipProps; hidden?: boolean; } & (({ variant?: typeof BUTTON_TYPE.Filled; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Outline; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Tonal; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Function; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Simple; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Dropdown; } & { 'data-test-id'?: string; } & AriaAttributes & Omit<ButtonProps, "view" | "icon" | "size" | "iconPosition"> & { size?: "xs" | NonNullable<Size | undefined>; className?: string; open?: boolean; onOpenChange?: (open: boolean) => void; } & { items: Item[]; closeOnPopstate?: boolean | undefined; triggerClassName?: string | undefined; placement?: Placement | undefined; closeDroplistOnItemClick?: boolean | undefined; }) | ({ variant: typeof BUTTON_TYPE.Kebab; } & ButtonKebabProps) | ({ variant: typeof BUTTON_TYPE.Droplist; } & ButtonDroplistProps) | ({ variant: typeof BUTTON_TYPE.Quota; } & { 'data-test-id'?: string; } & AriaAttributes & QuotaWidgetPropsBase & { quotasUrl: string; onQuotasUrlClick?: () => void; buttonProps?: Pick<ButtonProps, "size" | "className" | "fullWidth" | "label" | "appearance" | "disabled" | "view">; }))`
800
+ - `Action` = `CustomAction | StandardAction`
758
801
 
759
802
  **ButtonDroplistProps**
760
803
 
@@ -770,13 +813,23 @@ import {
770
813
  | `button` | `ButtonProps` | — | |
771
814
  | `list` | `DroplistListProps` \| `DroplistMobileSlots` \| `DroplistProps` \| `EmptyState` \| `PublicListContextType` \| `ScrollProps` \| `SelectionState` | — | |
772
815
 
816
+ **CustomAction**
817
+
818
+ | Prop | Type | Default | Description |
819
+ |------|------|---------|-------------|
820
+ | `hidden` | `boolean \| undefined` | — | |
821
+ | `render` | `() => { default: ReactNode; asListItem: Item; }` | — | Вызывается при рендеринге; React hooks следует использовать внутри компонента default. |
822
+ | `tooltip` | `TooltipProps` | — | |
823
+ | `type` | `"custom"` | — | |
824
+ | `variant` | `undefined` | — | |
825
+
773
826
  ## MobilePageCatalog
774
827
 
775
828
  ### Props `MobilePageCatalogProps`
776
829
 
777
830
  | Prop | Type | Default | Description |
778
831
  |------|------|---------|-------------|
779
- | `actions` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `QuotaWidgetPropsBase` | `[]` | |
832
+ | `actions` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `CustomAction` \| `QuotaWidgetPropsBase` | `[]` | |
780
833
  | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
781
834
  | `className` | `string` | — | |
782
835
  | `data-test-id` | `string` | — | |
@@ -785,7 +838,7 @@ import {
785
838
 
786
839
  #### Related types
787
840
 
788
- - `Action` = `{ tooltip?: TooltipProps; hidden?: boolean; } & (({ variant?: typeof BUTTON_TYPE.Filled; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Outline; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Tonal; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Function; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Simple; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Dropdown; } & { 'data-test-id'?: string; } & AriaAttributes & Omit<ButtonProps, "view" | "icon" | "size" | "iconPosition"> & { size?: "xs" | NonNullable<Size | undefined>; className?: string; open?: boolean; onOpenChange?: (open: boolean) => void; } & { items: Item[]; closeOnPopstate?: boolean | undefined; triggerClassName?: string | undefined; placement?: Placement | undefined; closeDroplistOnItemClick?: boolean | undefined; }) | ({ variant: typeof BUTTON_TYPE.Kebab; } & ButtonKebabProps) | ({ variant: typeof BUTTON_TYPE.Droplist; } & ButtonDroplistProps) | ({ variant: typeof BUTTON_TYPE.Quota; } & { 'data-test-id'?: string; } & AriaAttributes & QuotaWidgetPropsBase & { quotasUrl: string; onQuotasUrlClick?: () => void; buttonProps?: Pick<ButtonProps, "size" | "className" | "fullWidth" | "label" | "appearance" | "disabled" | "view">; }))`
841
+ - `Action` = `CustomAction | StandardAction`
789
842
 
790
843
  **ButtonDroplistProps**
791
844
 
@@ -801,6 +854,16 @@ import {
801
854
  | `button` | `ButtonProps` | — | |
802
855
  | `list` | `DroplistListProps` \| `DroplistMobileSlots` \| `DroplistProps` \| `EmptyState` \| `PublicListContextType` \| `ScrollProps` \| `SelectionState` | — | |
803
856
 
857
+ **CustomAction**
858
+
859
+ | Prop | Type | Default | Description |
860
+ |------|------|---------|-------------|
861
+ | `hidden` | `boolean \| undefined` | — | |
862
+ | `render` | `() => { default: ReactNode; asListItem: Item; }` | — | Вызывается при рендеринге; React hooks следует использовать внутри компонента default. |
863
+ | `tooltip` | `TooltipProps` | — | |
864
+ | `type` | `"custom"` | — | |
865
+ | `variant` | `undefined` | — | |
866
+
804
867
  ## MobilePageForm
805
868
 
806
869
  ### Props `DesktopPageFormProps`
@@ -830,7 +893,7 @@ import {
830
893
 
831
894
  | Prop | Type | Default | Description |
832
895
  |------|------|---------|-------------|
833
- | `actions` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `QuotaWidgetPropsBase` | `[]` | |
896
+ | `actions` | `Action` \| `ButtonDropdownDroplistConfig` \| `ButtonDroplistProps` \| `ButtonKebabProps` \| `CustomAction` \| `QuotaWidgetPropsBase` | `[]` | |
834
897
  | `children` | `string \| number \| boolean \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal \| null \| undefined` | — | |
835
898
  | `className` | `string` | — | |
836
899
  | `data-test-id` | `string` | — | |
@@ -843,7 +906,7 @@ import {
843
906
 
844
907
  #### Related types
845
908
 
846
- - `Action` = `{ tooltip?: TooltipProps; hidden?: boolean; } & (({ variant?: typeof BUTTON_TYPE.Filled; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Outline; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Tonal; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Function; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Simple; } & ActionButtonProps) | ({ variant: typeof BUTTON_TYPE.Dropdown; } & { 'data-test-id'?: string; } & AriaAttributes & Omit<ButtonProps, "view" | "icon" | "size" | "iconPosition"> & { size?: "xs" | NonNullable<Size | undefined>; className?: string; open?: boolean; onOpenChange?: (open: boolean) => void; } & { items: Item[]; closeOnPopstate?: boolean | undefined; triggerClassName?: string | undefined; placement?: Placement | undefined; closeDroplistOnItemClick?: boolean | undefined; }) | ({ variant: typeof BUTTON_TYPE.Kebab; } & ButtonKebabProps) | ({ variant: typeof BUTTON_TYPE.Droplist; } & ButtonDroplistProps) | ({ variant: typeof BUTTON_TYPE.Quota; } & { 'data-test-id'?: string; } & AriaAttributes & QuotaWidgetPropsBase & { quotasUrl: string; onQuotasUrlClick?: () => void; buttonProps?: Pick<ButtonProps, "size" | "className" | "fullWidth" | "label" | "appearance" | "disabled" | "view">; }))`
909
+ - `Action` = `CustomAction | StandardAction`
847
910
 
848
911
  **ButtonDroplistProps**
849
912
 
@@ -859,6 +922,16 @@ import {
859
922
  | `button` | `ButtonProps` | — | |
860
923
  | `list` | `DroplistListProps` \| `DroplistMobileSlots` \| `DroplistProps` \| `EmptyState` \| `PublicListContextType` \| `ScrollProps` \| `SelectionState` | — | |
861
924
 
925
+ **CustomAction**
926
+
927
+ | Prop | Type | Default | Description |
928
+ |------|------|---------|-------------|
929
+ | `hidden` | `boolean \| undefined` | — | |
930
+ | `render` | `() => { default: ReactNode; asListItem: Item; }` | — | Вызывается при рендеринге; React hooks следует использовать внутри компонента default. |
931
+ | `tooltip` | `TooltipProps` | — | |
932
+ | `type` | `"custom"` | — | |
933
+ | `variant` | `undefined` | — | |
934
+
862
935
  - `SidebarItem` = `SidebarItemWithHref | SidebarItemWithItems`
863
936
 
864
937
  **SidebarItemBase**
@@ -11,7 +11,7 @@ type CommonProps = {
11
11
  * `@ds`-примитивы, которые берут раскладку из `AdaptiveProvider`. Раскладку фиксируют обёртки
12
12
  * `DesktopActions` / `MobileActions` (`withLayoutType`), поэтому отдельный проп `layoutType` не нужен.
13
13
  */
14
- export declare function ActionView({ variant, tooltip, hidden, commonProps, ...buttonProps }: Action & {
14
+ export declare function ActionView({ hidden, type, tooltip, commonProps, ...action }: Action & {
15
15
  commonProps: CommonProps;
16
16
  }): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
17
17
  export {};
@@ -14,10 +14,14 @@ const constants_1 = require("./constants");
14
14
  * `@ds`-примитивы, которые берут раскладку из `AdaptiveProvider`. Раскладку фиксируют обёртки
15
15
  * `DesktopActions` / `MobileActions` (`withLayoutType`), поэтому отдельный проп `layoutType` не нужен.
16
16
  */
17
- function ActionView({ variant, tooltip, hidden = false, commonProps, ...buttonProps }) {
18
- if (hidden) {
17
+ function ActionView({ hidden, type, tooltip, commonProps, ...action }) {
18
+ if (hidden)
19
19
  return null;
20
+ if (type === 'custom' && 'render' in action) {
21
+ const content = (0, jsx_runtime_1.jsx)("div", { className: commonProps.className, children: action.render().default });
22
+ return tooltip ? (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { ...tooltip, children: content }) : content;
20
23
  }
24
+ const { variant, ...buttonProps } = action;
21
25
  // disableSpanWrapper — кнопка остаётся ПРЯМЫМ flex-потомком контейнера действий: без него Tooltip
22
26
  // добавляет span-обёртку (`flex:0 1 auto`), и `fullWidth`-кнопка (`flex:1 1 0`) не растягивается на
23
27
  // всю ширину (mobile: 2 действия должны делить строку). Как в MobilePageForm ButtonGroup.
@@ -22,7 +22,12 @@ const utils_2 = require("./utils");
22
22
  function MobileActionsBase({ items, maxVisibleItems }) {
23
23
  const containerRef = (0, react_2.useRef)(null);
24
24
  const [isOpen, setIsOpen] = (0, react_2.useState)(false);
25
- const { visibleItems, hiddenItems } = (0, utils_1.useDynamicList)({ parentContainerRef: containerRef, items, maxVisibleItems });
25
+ const availableItems = (0, react_2.useMemo)(() => items.filter(item => !item.hidden), [items]);
26
+ const { visibleItems, hiddenItems } = (0, utils_1.useDynamicList)({
27
+ parentContainerRef: containerRef,
28
+ items: availableItems,
29
+ maxVisibleItems,
30
+ });
26
31
  const { t: tQuota } = uikit_product_quota_1.quotaLocale.useTranslations();
27
32
  if (!(0, utils_2.hasVisibleActions)(items)) {
28
33
  return null;
@@ -30,6 +35,20 @@ function MobileActionsBase({ items, maxVisibleItems }) {
30
35
  const hiddenItemsWithKebab = hiddenItems.concat(visibleItems.filter(item => item.variant === constants_2.BUTTON_TYPE.Kebab));
31
36
  const visibleItemsWithoutKebab = visibleItems.filter(item => item.variant !== constants_2.BUTTON_TYPE.Kebab);
32
37
  const droplistItems = hiddenItemsWithKebab.reduce((acc, action) => {
38
+ if (action.hidden)
39
+ return acc;
40
+ if (action.type === 'custom') {
41
+ const { asListItem } = action.render();
42
+ acc.push({
43
+ ...asListItem,
44
+ onClick: (event) => {
45
+ setIsOpen(false);
46
+ if ('onClick' in asListItem)
47
+ asListItem.onClick?.(event);
48
+ },
49
+ });
50
+ return acc;
51
+ }
33
52
  switch (action.variant) {
34
53
  case constants_2.BUTTON_TYPE.Tonal:
35
54
  case constants_2.BUTTON_TYPE.Simple:
@@ -26,4 +26,9 @@
26
26
  }
27
27
  .button[data-variant=icon-only]{
28
28
  flex:0 0 auto;
29
+ }
30
+
31
+ .mobileActionsWrapper .button[data-full-width]:not([data-variant=icon-only]){
32
+ min-width:-moz-max-content;
33
+ min-width:max-content;
29
34
  }
@@ -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
  import { ButtonDroplistProps } from './buttons/ButtonDroplist';
5
7
  import { ButtonKebabProps } from './buttons/ButtonKebab';
6
8
  import { ButtonQuotaProps } from './buttons/ButtonQuota';
@@ -15,13 +17,21 @@ export type ActionButtonProps = (ButtonProps & {
15
17
  }) | (Omit<ButtonProps<'a'>, 'as'> & {
16
18
  as: 'a';
17
19
  });
18
- /**
19
- * Action — один элемент панели действий. Дискриминированный union по `variant` (`BUTTON_TYPE`).
20
- * Простые кнопки (`filled`/`outline`/`tonal`/`function`/`simple`) маппятся на единый `Button` из
21
- * `@cloud-ru/ds-button` с соответствующим `view`; составные (`dropdown`/`kebab`/`droplist`/`quota`) — на
22
- * предопределённые обёртки.
23
- */
24
- export type Action = {
20
+ /** Кастомное действие с представлениями для панели и выпадающего меню. */
21
+ export type CustomAction = {
22
+ type: 'custom';
23
+ variant?: never;
24
+ hidden?: boolean;
25
+ tooltip?: TooltipProps;
26
+ /** Вызывается при рендеринге; React hooks следует использовать внутри компонента default. */
27
+ render(): {
28
+ default: ReactNode;
29
+ asListItem: Item;
30
+ };
31
+ };
32
+ export type Action = CustomAction | StandardAction;
33
+ type StandardAction = {
34
+ type?: never;
25
35
  tooltip?: TooltipProps;
26
36
  hidden?: boolean;
27
37
  } & (({
@@ -47,3 +57,4 @@ export type ActionsProps = {
47
57
  items: Action[];
48
58
  maxVisibleItems?: number;
49
59
  };
60
+ export {};
@@ -27,6 +27,11 @@
27
27
  .button[data-variant=icon-only]{
28
28
  flex:0 0 auto;
29
29
  }
30
+
31
+ .mobileActionsWrapper .button[data-full-width]:not([data-variant=icon-only]){
32
+ min-width:-moz-max-content;
33
+ min-width:max-content;
34
+ }
30
35
  .subtitle{
31
36
  display:flex;
32
37
  flex-direction:row;
@@ -11,7 +11,7 @@ type CommonProps = {
11
11
  * `@ds`-примитивы, которые берут раскладку из `AdaptiveProvider`. Раскладку фиксируют обёртки
12
12
  * `DesktopActions` / `MobileActions` (`withLayoutType`), поэтому отдельный проп `layoutType` не нужен.
13
13
  */
14
- export declare function ActionView({ variant, tooltip, hidden, commonProps, ...buttonProps }: Action & {
14
+ export declare function ActionView({ hidden, type, tooltip, commonProps, ...action }: Action & {
15
15
  commonProps: CommonProps;
16
16
  }): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
17
17
  export {};
@@ -11,10 +11,14 @@ import { BUTTON_TYPE } from './constants.js';
11
11
  * `@ds`-примитивы, которые берут раскладку из `AdaptiveProvider`. Раскладку фиксируют обёртки
12
12
  * `DesktopActions` / `MobileActions` (`withLayoutType`), поэтому отдельный проп `layoutType` не нужен.
13
13
  */
14
- export function ActionView({ variant, tooltip, hidden = false, commonProps, ...buttonProps }) {
15
- if (hidden) {
14
+ export function ActionView({ hidden, type, tooltip, commonProps, ...action }) {
15
+ if (hidden)
16
16
  return null;
17
+ if (type === 'custom' && 'render' in action) {
18
+ const content = _jsx("div", { className: commonProps.className, children: action.render().default });
19
+ return tooltip ? _jsx(Tooltip, { ...tooltip, children: content }) : content;
17
20
  }
21
+ const { variant, ...buttonProps } = action;
18
22
  // disableSpanWrapper — кнопка остаётся ПРЯМЫМ flex-потомком контейнера действий: без него Tooltip
19
23
  // добавляет span-обёртку (`flex:0 1 auto`), и `fullWidth`-кнопка (`flex:1 1 0`) не растягивается на
20
24
  // всю ширину (mobile: 2 действия должны делить строку). Как в MobilePageForm ButtonGroup.
@@ -7,7 +7,7 @@ import { Droplist } from '@cloud-ru/ds-list';
7
7
  import { Tooltip } from '@cloud-ru/ds-tooltip';
8
8
  import { quotaLocale, QuotaWidget } from '@cloud-ru/ds-uikit-product-quota';
9
9
  import { useDynamicList } from '@cloud-ru/ds-utils';
10
- import { useRef, useState } from 'react';
10
+ import { useMemo, useRef, useState } from 'react';
11
11
  import { TEST_IDS } from '../../constants.js';
12
12
  import { ActionView } from './ActionView.js';
13
13
  import { BUTTON_TYPE } from './constants.js';
@@ -16,7 +16,12 @@ import { hasVisibleActions } from './utils.js';
16
16
  function MobileActionsBase({ items, maxVisibleItems }) {
17
17
  const containerRef = useRef(null);
18
18
  const [isOpen, setIsOpen] = useState(false);
19
- const { visibleItems, hiddenItems } = useDynamicList({ parentContainerRef: containerRef, items, maxVisibleItems });
19
+ const availableItems = useMemo(() => items.filter(item => !item.hidden), [items]);
20
+ const { visibleItems, hiddenItems } = useDynamicList({
21
+ parentContainerRef: containerRef,
22
+ items: availableItems,
23
+ maxVisibleItems,
24
+ });
20
25
  const { t: tQuota } = quotaLocale.useTranslations();
21
26
  if (!hasVisibleActions(items)) {
22
27
  return null;
@@ -24,6 +29,20 @@ function MobileActionsBase({ items, maxVisibleItems }) {
24
29
  const hiddenItemsWithKebab = hiddenItems.concat(visibleItems.filter(item => item.variant === BUTTON_TYPE.Kebab));
25
30
  const visibleItemsWithoutKebab = visibleItems.filter(item => item.variant !== BUTTON_TYPE.Kebab);
26
31
  const droplistItems = hiddenItemsWithKebab.reduce((acc, action) => {
32
+ if (action.hidden)
33
+ return acc;
34
+ if (action.type === 'custom') {
35
+ const { asListItem } = action.render();
36
+ acc.push({
37
+ ...asListItem,
38
+ onClick: (event) => {
39
+ setIsOpen(false);
40
+ if ('onClick' in asListItem)
41
+ asListItem.onClick?.(event);
42
+ },
43
+ });
44
+ return acc;
45
+ }
27
46
  switch (action.variant) {
28
47
  case BUTTON_TYPE.Tonal:
29
48
  case BUTTON_TYPE.Simple:
@@ -26,4 +26,9 @@
26
26
  }
27
27
  .button[data-variant=icon-only]{
28
28
  flex:0 0 auto;
29
+ }
30
+
31
+ .mobileActionsWrapper .button[data-full-width]:not([data-variant=icon-only]){
32
+ min-width:-moz-max-content;
33
+ min-width:max-content;
29
34
  }
@@ -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
  import { ButtonDroplistProps } from './buttons/ButtonDroplist.js';
5
7
  import { ButtonKebabProps } from './buttons/ButtonKebab.js';
6
8
  import { ButtonQuotaProps } from './buttons/ButtonQuota.js';
@@ -15,13 +17,21 @@ export type ActionButtonProps = (ButtonProps & {
15
17
  }) | (Omit<ButtonProps<'a'>, 'as'> & {
16
18
  as: 'a';
17
19
  });
18
- /**
19
- * Action — один элемент панели действий. Дискриминированный union по `variant` (`BUTTON_TYPE`).
20
- * Простые кнопки (`filled`/`outline`/`tonal`/`function`/`simple`) маппятся на единый `Button` из
21
- * `@cloud-ru/ds-button` с соответствующим `view`; составные (`dropdown`/`kebab`/`droplist`/`quota`) — на
22
- * предопределённые обёртки.
23
- */
24
- export type Action = {
20
+ /** Кастомное действие с представлениями для панели и выпадающего меню. */
21
+ export type CustomAction = {
22
+ type: 'custom';
23
+ variant?: never;
24
+ hidden?: boolean;
25
+ tooltip?: TooltipProps;
26
+ /** Вызывается при рендеринге; React hooks следует использовать внутри компонента default. */
27
+ render(): {
28
+ default: ReactNode;
29
+ asListItem: Item;
30
+ };
31
+ };
32
+ export type Action = CustomAction | StandardAction;
33
+ type StandardAction = {
34
+ type?: never;
25
35
  tooltip?: TooltipProps;
26
36
  hidden?: boolean;
27
37
  } & (({
@@ -47,3 +57,4 @@ export type ActionsProps = {
47
57
  items: Action[];
48
58
  maxVisibleItems?: number;
49
59
  };
60
+ export {};
@@ -27,6 +27,11 @@
27
27
  .button[data-variant=icon-only]{
28
28
  flex:0 0 auto;
29
29
  }
30
+
31
+ .mobileActionsWrapper .button[data-full-width]:not([data-variant=icon-only]){
32
+ min-width:-moz-max-content;
33
+ min-width:max-content;
34
+ }
30
35
  .subtitle{
31
36
  display:flex;
32
37
  flex-direction:row;