@cloud-ru/ds-uikit-product-page-layout 2.3.0 → 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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/ds-uikit-product-page-layout",
|
|
3
|
-
"version": "2.3.0",
|
|
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": "
|
|
44
|
-
"@cloud-ru/ds-dropdown": "
|
|
45
|
-
"@cloud-ru/ds-block": "
|
|
46
|
-
"@cloud-ru/ds-
|
|
47
|
-
"@cloud-ru/ds-
|
|
48
|
-
"@cloud-ru/ds-
|
|
49
|
-
"@cloud-ru/ds-
|
|
50
|
-
"@cloud-ru/ds-locale": "
|
|
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": "
|
|
57
|
-
"@cloud-ru/ds-
|
|
58
|
-
"@cloud-ru/ds-
|
|
59
|
-
"@cloud-ru/ds-
|
|
60
|
-
"@cloud-ru/ds-uikit-product-button-predefined": "
|
|
61
|
-
"@cloud-ru/ds-uikit-product-
|
|
62
|
-
"@cloud-ru/ds-
|
|
63
|
-
"@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-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"
|
|
@@ -2,8 +2,9 @@ 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,
|
|
7
|
+
import { quotaLocale, QuotaWidgetContent } from '@cloud-ru/ds-uikit-product-quota';
|
|
7
8
|
import { useDynamicList } from '@cloud-ru/ds-utils';
|
|
8
9
|
import { MouseEvent, ReactNode, useMemo, useRef, useState } from 'react';
|
|
9
10
|
|
|
@@ -11,7 +12,7 @@ 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,14 +24,25 @@ 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);
|
|
35
|
+
const [openQuotaIndex, setOpenQuotaIndex] = useState<number>();
|
|
36
|
+
const activeAction = openQuotaIndex === undefined ? undefined : items[openQuotaIndex];
|
|
37
|
+
const openQuota = activeAction?.variant === BUTTON_TYPE.Quota ? activeAction : undefined;
|
|
30
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
|
+
);
|
|
31
43
|
const { visibleItems, hiddenItems } = useDynamicList({
|
|
32
44
|
parentContainerRef: containerRef,
|
|
33
|
-
items:
|
|
45
|
+
items: measurableItems,
|
|
34
46
|
maxVisibleItems,
|
|
35
47
|
});
|
|
36
48
|
|
|
@@ -40,10 +52,10 @@ function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
|
|
|
40
52
|
return null;
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
const
|
|
44
|
-
const
|
|
55
|
+
const overflowItems = availableItems.filter(action => isOverflowOnly(action) || hiddenItems.includes(action));
|
|
56
|
+
const visibleActions = visibleItems.filter(action => !isOverflowOnly(action));
|
|
45
57
|
|
|
46
|
-
const droplistItems =
|
|
58
|
+
const droplistItems = overflowItems.reduce<Item[]>((acc, action) => {
|
|
47
59
|
if (action.variant === 'custom') {
|
|
48
60
|
const { asListItem } = action.render();
|
|
49
61
|
acc.push({
|
|
@@ -87,19 +99,14 @@ function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
|
|
|
87
99
|
break;
|
|
88
100
|
}
|
|
89
101
|
case BUTTON_TYPE.Quota: {
|
|
90
|
-
// QuotaWidget самодостаточен (свой триггер + dropdown) — рендерим инлайн как inactive-айтем.
|
|
91
|
-
const quotaWidget = <QuotaWidget {...action} buttonProps={{ size: 'm', fullWidth: true }} />;
|
|
92
|
-
|
|
93
102
|
acc.push({
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
],
|
|
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
|
+
},
|
|
103
110
|
});
|
|
104
111
|
break;
|
|
105
112
|
}
|
|
@@ -160,7 +167,31 @@ function MobileActionsBase({ items, maxVisibleItems }: ActionsProps) {
|
|
|
160
167
|
</Droplist>
|
|
161
168
|
)}
|
|
162
169
|
|
|
163
|
-
{
|
|
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) => (
|
|
164
195
|
<ActionView
|
|
165
196
|
{...action}
|
|
166
197
|
key={index}
|