@cloud-ru/ds-uikit-product-modal-predefined 1.1.4 → 1.1.5
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 +6 -0
- package/README.md +2 -2
- package/dist/cjs/helperComponents/NoteItem/NoteItem.d.ts +2 -1
- package/dist/cjs/helperComponents/NoteItem/NoteItem.js +2 -2
- package/dist/cjs/helperComponents/NoteItem/styles.module.css +4 -0
- package/dist/cjs/helperComponents/ReleaseNotesContent/ReleaseNotesContent.js +18 -1
- package/dist/cjs/style.css +4 -0
- package/dist/esm/helperComponents/NoteItem/NoteItem.d.ts +2 -1
- package/dist/esm/helperComponents/NoteItem/NoteItem.js +2 -2
- package/dist/esm/helperComponents/NoteItem/styles.module.css +4 -0
- package/dist/esm/helperComponents/ReleaseNotesContent/ReleaseNotesContent.js +19 -2
- package/dist/esm/style.css +4 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/helperComponents/NoteItem/NoteItem.tsx +3 -2
- package/src/helperComponents/NoteItem/styles.module.scss +5 -0
- package/src/helperComponents/ReleaseNotesContent/ReleaseNotesContent.tsx +31 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/ds-uikit-product-modal-predefined",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Product preset-компоненты для delete, recall и release notes сценариев на базе Modal и BottomSheet.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,24 +40,24 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"classnames": "^2.5.1",
|
|
43
|
-
"@cloud-ru/ds-
|
|
44
|
-
"@cloud-ru/ds-
|
|
45
|
-
"@cloud-ru/ds-
|
|
46
|
-
"@cloud-ru/ds-
|
|
47
|
-
"@cloud-ru/ds-icons": "^1.7.
|
|
43
|
+
"@cloud-ru/ds-bottom-sheet": "^2.2.0",
|
|
44
|
+
"@cloud-ru/ds-adaptive": "^1.0.5",
|
|
45
|
+
"@cloud-ru/ds-button": "^1.0.7",
|
|
46
|
+
"@cloud-ru/ds-carousel": "^1.1.11",
|
|
47
|
+
"@cloud-ru/ds-icons": "^1.7.4",
|
|
48
|
+
"@cloud-ru/ds-fields": "^3.0.13",
|
|
48
49
|
"@cloud-ru/ds-locale": "^1.0.0",
|
|
49
|
-
"@cloud-ru/ds-
|
|
50
|
-
"@cloud-ru/ds-markdown": "^1.0.
|
|
51
|
-
"@cloud-ru/ds-
|
|
52
|
-
"@cloud-ru/ds-
|
|
53
|
-
"@cloud-ru/ds-scroll": "^1.0.
|
|
54
|
-
"@cloud-ru/ds-
|
|
50
|
+
"@cloud-ru/ds-info-block": "^1.0.6",
|
|
51
|
+
"@cloud-ru/ds-markdown": "^1.0.60",
|
|
52
|
+
"@cloud-ru/ds-pagination": "^1.1.11",
|
|
53
|
+
"@cloud-ru/ds-modal": "^2.1.3",
|
|
54
|
+
"@cloud-ru/ds-scroll": "^1.0.8",
|
|
55
|
+
"@cloud-ru/ds-tooltip": "^1.0.20",
|
|
56
|
+
"@cloud-ru/ds-truncate-string": "^1.0.21",
|
|
57
|
+
"@cloud-ru/ds-skeleton": "^1.0.5",
|
|
55
58
|
"@cloud-ru/ds-typography": "^1.0.2",
|
|
56
|
-
"@cloud-ru/ds-
|
|
57
|
-
"@cloud-ru/ds-
|
|
58
|
-
"@cloud-ru/ds-uikit-product-copy": "^1.1.19",
|
|
59
|
-
"@cloud-ru/ds-utils": "^1.4.0",
|
|
60
|
-
"@cloud-ru/ds-truncate-string": "^1.0.20"
|
|
59
|
+
"@cloud-ru/ds-uikit-product-copy": "^1.1.20",
|
|
60
|
+
"@cloud-ru/ds-utils": "^1.4.1"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
@@ -14,6 +14,7 @@ const FALLBACK_ICON_SIZE = 48;
|
|
|
14
14
|
|
|
15
15
|
type NoteItemComponentProps = NoteItemProps & {
|
|
16
16
|
surface?: Surface;
|
|
17
|
+
active?: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -93,9 +94,9 @@ function NoteItemMedia({ image, video }: Pick<NoteItemProps, 'image' | 'video'>)
|
|
|
93
94
|
);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
export function NoteItem({ title, description, image, video, surface = SURFACE.Modal }: NoteItemComponentProps) {
|
|
97
|
+
export function NoteItem({ title, description, image, video, surface = SURFACE.Modal, active = true }: NoteItemComponentProps) {
|
|
97
98
|
return (
|
|
98
|
-
<article className={styles.root} data-surface={surface} data-test-id={TEST_IDS.releaseNotesItem}>
|
|
99
|
+
<article className={styles.root} data-surface={surface} data-active={active} data-test-id={TEST_IDS.releaseNotesItem}>
|
|
99
100
|
{/* `key` по источнику: карусель переиспользует слайд, а состояние загрузки относится к файлу. */}
|
|
100
101
|
<NoteItemMedia key={`${video ?? ''}|${image.src}`} image={image} video={video} />
|
|
101
102
|
|
|
@@ -21,6 +21,11 @@ $card-size: calc(6 * #{base.$sn-primitive-dimension-64} - #{base.$sn-primitive-d
|
|
|
21
21
|
row-gap: base.$sn-primitive-dimension-16;
|
|
22
22
|
height: auto;
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
&[data-surface='bottomSheet'][data-active='false'] {
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
height: 0;
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
.media {
|
|
@@ -3,14 +3,17 @@ import { Carousel } from '@cloud-ru/ds-carousel';
|
|
|
3
3
|
import { CrossSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
4
4
|
import { InfoBlock } from '@cloud-ru/ds-info-block';
|
|
5
5
|
import { Typography } from '@cloud-ru/ds-typography';
|
|
6
|
+
import { useLayoutEffect } from '@cloud-ru/ds-utils';
|
|
6
7
|
import cn from 'classnames';
|
|
7
|
-
import { ReactNode } from 'react';
|
|
8
|
+
import { ReactNode, useRef, useState } from 'react';
|
|
8
9
|
|
|
9
|
-
import { CONTENT_STATE, TEST_IDS } from '../../constants';
|
|
10
|
+
import { CONTENT_STATE, SURFACE, TEST_IDS } from '../../constants';
|
|
10
11
|
import { NoteItemProps, ReleaseNotesContentState, Surface } from '../../types';
|
|
11
12
|
import { NoteItem, NoteItemSkeleton } from '../NoteItem';
|
|
12
13
|
import styles from './styles.module.scss';
|
|
13
14
|
|
|
15
|
+
const SLIDE_TRANSITION_MS = 400;
|
|
16
|
+
|
|
14
17
|
export type ReleaseNotesContentProps = {
|
|
15
18
|
/** Визуальное состояние */
|
|
16
19
|
contentState: ReleaseNotesContentState;
|
|
@@ -62,6 +65,24 @@ export function ReleaseNotesContent({
|
|
|
62
65
|
}: ReleaseNotesContentProps) {
|
|
63
66
|
const total = items.length;
|
|
64
67
|
const hasItems = total > 0;
|
|
68
|
+
const isMobileCarousel =
|
|
69
|
+
surface === SURFACE.BottomSheet && !loading && contentState === CONTENT_STATE.Data && hasItems;
|
|
70
|
+
const previousPageIndex = useRef(pageIndex);
|
|
71
|
+
const [outgoingPageIndex, setOutgoingPageIndex] = useState<number>();
|
|
72
|
+
|
|
73
|
+
useLayoutEffect(() => {
|
|
74
|
+
const previousPage = previousPageIndex.current;
|
|
75
|
+
previousPageIndex.current = pageIndex;
|
|
76
|
+
|
|
77
|
+
if (!isMobileCarousel || previousPage === pageIndex) {
|
|
78
|
+
setOutgoingPageIndex(undefined);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setOutgoingPageIndex(previousPage);
|
|
83
|
+
const timeout = window.setTimeout(() => setOutgoingPageIndex(undefined), SLIDE_TRANSITION_MS);
|
|
84
|
+
return () => window.clearTimeout(timeout);
|
|
85
|
+
}, [isMobileCarousel, pageIndex]);
|
|
65
86
|
|
|
66
87
|
if (loading) {
|
|
67
88
|
return (
|
|
@@ -118,11 +139,17 @@ export function ReleaseNotesContent({
|
|
|
118
139
|
arrows={false}
|
|
119
140
|
pagination={false}
|
|
120
141
|
swipe
|
|
142
|
+
transition={SLIDE_TRANSITION_MS / 1000}
|
|
121
143
|
state={{ page: pageIndex, onChange: onPageChange }}
|
|
122
144
|
className={styles.carousel}
|
|
123
145
|
>
|
|
124
|
-
{items.map(item => (
|
|
125
|
-
<NoteItem
|
|
146
|
+
{items.map((item, index) => (
|
|
147
|
+
<NoteItem
|
|
148
|
+
key={`${item.title}-${item.image.src}`}
|
|
149
|
+
{...item}
|
|
150
|
+
surface={surface}
|
|
151
|
+
active={index === pageIndex || index === outgoingPageIndex}
|
|
152
|
+
/>
|
|
126
153
|
))}
|
|
127
154
|
</Carousel>
|
|
128
155
|
</div>
|