@cloud-ru/ds-uikit-product-page-layout 2.1.2-preview-de7dadcf.0 → 2.1.2-preview-2e992735.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 +85 -11
- 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 +20 -1
- package/dist/cjs/components/Actions/styles.module.css +5 -0
- package/dist/cjs/components/Actions/types.d.ts +18 -7
- package/dist/cjs/components/PageServices/MobilePageServices.d.ts +2 -2
- package/dist/cjs/components/PageServices/MobilePageServices.js +2 -2
- package/dist/cjs/style.css +5 -0
- 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 +21 -2
- package/dist/esm/components/Actions/styles.module.css +5 -0
- package/dist/esm/components/Actions/types.d.ts +18 -7
- package/dist/esm/components/PageServices/MobilePageServices.d.ts +2 -2
- package/dist/esm/components/PageServices/MobilePageServices.js +2 -2
- package/dist/esm/style.css +5 -0
- 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 +19 -2
- package/src/components/Actions/styles.module.scss +4 -0
- package/src/components/Actions/types.ts +16 -7
- package/src/components/PageServices/MobilePageServices.tsx +3 -1
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` = `
|
|
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` = `
|
|
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` |
|
|
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` = `
|
|
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` = `
|
|
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` | — | |
|
|
@@ -840,10 +903,11 @@ import {
|
|
|
840
903
|
| `slotBeforeTitle` | `ReactNode` | — | Слот перед заголовком (например, кнопка «назад») |
|
|
841
904
|
| `subtitle` | `ReactNode` | — | Подзаголовок под заголовком |
|
|
842
905
|
| `title` | `string` | — | Заголовок страницы |
|
|
906
|
+
| `truncateTitle` | `boolean` | — | Обрезать заголовок в одну строку с многоточием |
|
|
843
907
|
|
|
844
908
|
#### Related types
|
|
845
909
|
|
|
846
|
-
- `Action` = `
|
|
910
|
+
- `Action` = `CustomAction | StandardAction`
|
|
847
911
|
|
|
848
912
|
**ButtonDroplistProps**
|
|
849
913
|
|
|
@@ -859,6 +923,16 @@ import {
|
|
|
859
923
|
| `button` | `ButtonProps` | — | |
|
|
860
924
|
| `list` | `DroplistListProps` \| `DroplistMobileSlots` \| `DroplistProps` \| `EmptyState` \| `PublicListContextType` \| `ScrollProps` \| `SelectionState` | — | |
|
|
861
925
|
|
|
926
|
+
**CustomAction**
|
|
927
|
+
|
|
928
|
+
| Prop | Type | Default | Description |
|
|
929
|
+
|------|------|---------|-------------|
|
|
930
|
+
| `hidden` | `boolean \| undefined` | — | |
|
|
931
|
+
| `render` | `() => { default: ReactNode; asListItem: Item; }` | — | Вызывается при рендеринге; React hooks следует использовать внутри компонента default. |
|
|
932
|
+
| `tooltip` | `TooltipProps` | — | |
|
|
933
|
+
| `type` | `"custom"` | — | |
|
|
934
|
+
| `variant` | `undefined` | — | |
|
|
935
|
+
|
|
862
936
|
- `SidebarItem` = `SidebarItemWithHref | SidebarItemWithItems`
|
|
863
937
|
|
|
864
938
|
**SidebarItemBase**
|
|
@@ -11,7 +11,7 @@ type CommonProps = {
|
|
|
11
11
|
* `@ds`-примитивы, которые берут раскладку из `AdaptiveProvider`. Раскладку фиксируют обёртки
|
|
12
12
|
* `DesktopActions` / `MobileActions` (`withLayoutType`), поэтому отдельный проп `layoutType` не нужен.
|
|
13
13
|
*/
|
|
14
|
-
export declare function ActionView({
|
|
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({
|
|
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
|
|
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:
|
|
@@ -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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 {};
|
|
@@ -3,10 +3,10 @@ import { PropsWithChildren } from 'react';
|
|
|
3
3
|
import { ActionsProps } from '../Actions';
|
|
4
4
|
import { HeadlineProps } from '../Headline';
|
|
5
5
|
import { SidebarSelectProps } from '../PageSidebar';
|
|
6
|
-
export type MobilePageServicesProps = WithSupportProps<PropsWithChildren<Pick<HeadlineProps, 'title' | 'slotBeforeTitle' | 'subtitle' | 'slotAfterTitle'> & {
|
|
6
|
+
export type MobilePageServicesProps = WithSupportProps<PropsWithChildren<Pick<HeadlineProps, 'title' | 'slotBeforeTitle' | 'subtitle' | 'slotAfterTitle' | 'truncateTitle'> & {
|
|
7
7
|
className?: string;
|
|
8
8
|
sidebar?: SidebarSelectProps;
|
|
9
9
|
actions?: ActionsProps['items'];
|
|
10
10
|
maxVisibleActionsItems?: ActionsProps['maxVisibleItems'];
|
|
11
11
|
}>>;
|
|
12
|
-
export declare function MobilePageServices({ children, title, actions, className, sidebar, slotAfterTitle, subtitle, slotBeforeTitle, maxVisibleActionsItems, ...rest }: MobilePageServicesProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function MobilePageServices({ children, title, actions, className, sidebar, slotAfterTitle, subtitle, slotBeforeTitle, maxVisibleActionsItems, truncateTitle, ...rest }: MobilePageServicesProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,6 +11,6 @@ const Actions_1 = require("../Actions");
|
|
|
11
11
|
const Headline_1 = require("../Headline");
|
|
12
12
|
const PageSidebar_1 = require("../PageSidebar");
|
|
13
13
|
const mobileStyles_module_scss_1 = __importDefault(require('./mobileStyles.module.css'));
|
|
14
|
-
function MobilePageServices({ children, title, actions = [], className, sidebar, slotAfterTitle, subtitle, slotBeforeTitle, maxVisibleActionsItems, ...rest }) {
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(mobileStyles_module_scss_1.default.wrapper, className), ...(0, utils_1.extractSupportProps)(rest), children: (0, jsx_runtime_1.jsxs)("div", { className: mobileStyles_module_scss_1.default.body, children: [(0, jsx_runtime_1.jsxs)("div", { className: mobileStyles_module_scss_1.default.headlineWrapper, children: [(0, jsx_runtime_1.jsx)(Headline_1.Headline, { title: title, slotBeforeTitle: slotBeforeTitle, slotAfterTitle: slotAfterTitle, subtitle: subtitle }), sidebar && (0, jsx_runtime_1.jsx)(PageSidebar_1.SidebarSelect, { ...sidebar }), actions.length > 0 && (0, jsx_runtime_1.jsx)(Actions_1.MobileActions, { items: actions, maxVisibleItems: maxVisibleActionsItems })] }), (0, jsx_runtime_1.jsx)("div", { className: mobileStyles_module_scss_1.default.childWrapper, children: children })] }) }));
|
|
14
|
+
function MobilePageServices({ children, title, actions = [], className, sidebar, slotAfterTitle, subtitle, slotBeforeTitle, maxVisibleActionsItems, truncateTitle, ...rest }) {
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(mobileStyles_module_scss_1.default.wrapper, className), ...(0, utils_1.extractSupportProps)(rest), children: (0, jsx_runtime_1.jsxs)("div", { className: mobileStyles_module_scss_1.default.body, children: [(0, jsx_runtime_1.jsxs)("div", { className: mobileStyles_module_scss_1.default.headlineWrapper, children: [(0, jsx_runtime_1.jsx)(Headline_1.Headline, { title: title, truncateTitle: truncateTitle, slotBeforeTitle: slotBeforeTitle, slotAfterTitle: slotAfterTitle, subtitle: subtitle }), sidebar && (0, jsx_runtime_1.jsx)(PageSidebar_1.SidebarSelect, { ...sidebar }), actions.length > 0 && (0, jsx_runtime_1.jsx)(Actions_1.MobileActions, { items: actions, maxVisibleItems: maxVisibleActionsItems })] }), (0, jsx_runtime_1.jsx)("div", { className: mobileStyles_module_scss_1.default.childWrapper, children: children })] }) }));
|
|
16
16
|
}
|
package/dist/cjs/style.css
CHANGED
|
@@ -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({
|
|
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({
|
|
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
|
|
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:
|
|
@@ -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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 {};
|
|
@@ -3,10 +3,10 @@ import { PropsWithChildren } from 'react';
|
|
|
3
3
|
import { ActionsProps } from '../Actions/index.js';
|
|
4
4
|
import { HeadlineProps } from '../Headline/index.js';
|
|
5
5
|
import { SidebarSelectProps } from '../PageSidebar/index.js';
|
|
6
|
-
export type MobilePageServicesProps = WithSupportProps<PropsWithChildren<Pick<HeadlineProps, 'title' | 'slotBeforeTitle' | 'subtitle' | 'slotAfterTitle'> & {
|
|
6
|
+
export type MobilePageServicesProps = WithSupportProps<PropsWithChildren<Pick<HeadlineProps, 'title' | 'slotBeforeTitle' | 'subtitle' | 'slotAfterTitle' | 'truncateTitle'> & {
|
|
7
7
|
className?: string;
|
|
8
8
|
sidebar?: SidebarSelectProps;
|
|
9
9
|
actions?: ActionsProps['items'];
|
|
10
10
|
maxVisibleActionsItems?: ActionsProps['maxVisibleItems'];
|
|
11
11
|
}>>;
|
|
12
|
-
export declare function MobilePageServices({ children, title, actions, className, sidebar, slotAfterTitle, subtitle, slotBeforeTitle, maxVisibleActionsItems, ...rest }: MobilePageServicesProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function MobilePageServices({ children, title, actions, className, sidebar, slotAfterTitle, subtitle, slotBeforeTitle, maxVisibleActionsItems, truncateTitle, ...rest }: MobilePageServicesProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,6 +5,6 @@ import { MobileActions } from '../Actions/index.js';
|
|
|
5
5
|
import { Headline } from '../Headline/index.js';
|
|
6
6
|
import { SidebarSelect } from '../PageSidebar/index.js';
|
|
7
7
|
import styles from './mobileStyles.module.css';
|
|
8
|
-
export function MobilePageServices({ children, title, actions = [], className, sidebar, slotAfterTitle, subtitle, slotBeforeTitle, maxVisibleActionsItems, ...rest }) {
|
|
9
|
-
return (_jsx("div", { className: cn(styles.wrapper, className), ...extractSupportProps(rest), children: _jsxs("div", { className: styles.body, children: [_jsxs("div", { className: styles.headlineWrapper, children: [_jsx(Headline, { title: title, slotBeforeTitle: slotBeforeTitle, slotAfterTitle: slotAfterTitle, subtitle: subtitle }), sidebar && _jsx(SidebarSelect, { ...sidebar }), actions.length > 0 && _jsx(MobileActions, { items: actions, maxVisibleItems: maxVisibleActionsItems })] }), _jsx("div", { className: styles.childWrapper, children: children })] }) }));
|
|
8
|
+
export function MobilePageServices({ children, title, actions = [], className, sidebar, slotAfterTitle, subtitle, slotBeforeTitle, maxVisibleActionsItems, truncateTitle, ...rest }) {
|
|
9
|
+
return (_jsx("div", { className: cn(styles.wrapper, className), ...extractSupportProps(rest), children: _jsxs("div", { className: styles.body, children: [_jsxs("div", { className: styles.headlineWrapper, children: [_jsx(Headline, { title: title, truncateTitle: truncateTitle, slotBeforeTitle: slotBeforeTitle, slotAfterTitle: slotAfterTitle, subtitle: subtitle }), sidebar && _jsx(SidebarSelect, { ...sidebar }), actions.length > 0 && _jsx(MobileActions, { items: actions, maxVisibleItems: maxVisibleActionsItems })] }), _jsx("div", { className: styles.childWrapper, children: children })] }) }));
|
|
10
10
|
}
|
package/dist/esm/style.css
CHANGED
|
@@ -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;
|