@cloud-ru/ds-uikit-product-modal-predefined 1.1.4-preview-e8fe6b56.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ds-uikit-product-modal-predefined",
3
- "version": "1.1.4-preview-e8fe6b56.0",
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-adaptive": "1.0.4-preview-e8fe6b56.0",
44
- "@cloud-ru/ds-button": "1.0.6-preview-e8fe6b56.0",
45
- "@cloud-ru/ds-bottom-sheet": "2.1.2-preview-e8fe6b56.0",
46
- "@cloud-ru/ds-fields": "3.0.12-preview-e8fe6b56.0",
47
- "@cloud-ru/ds-icons": "1.7.3-preview-e8fe6b56.0",
48
- "@cloud-ru/ds-locale": "1.0.0",
49
- "@cloud-ru/ds-info-block": "1.0.5-preview-e8fe6b56.0",
50
- "@cloud-ru/ds-modal": "2.1.2-preview-e8fe6b56.0",
51
- "@cloud-ru/ds-markdown": "1.0.59-preview-e8fe6b56.0",
52
- "@cloud-ru/ds-pagination": "1.1.10-preview-e8fe6b56.0",
53
- "@cloud-ru/ds-skeleton": "1.0.4-preview-e8fe6b56.0",
54
- "@cloud-ru/ds-scroll": "1.0.7-preview-e8fe6b56.0",
55
- "@cloud-ru/ds-tooltip": "1.0.19-preview-e8fe6b56.0",
56
- "@cloud-ru/ds-truncate-string": "1.0.20-preview-e8fe6b56.0",
57
- "@cloud-ru/ds-typography": "1.0.2",
58
- "@cloud-ru/ds-utils": "1.3.1-preview-e8fe6b56.0",
59
- "@cloud-ru/ds-uikit-product-copy": "1.1.19-preview-e8fe6b56.0",
60
- "@cloud-ru/ds-carousel": "1.1.10-preview-e8fe6b56.0"
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",
49
+ "@cloud-ru/ds-locale": "^1.0.0",
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",
58
+ "@cloud-ru/ds-typography": "^1.0.2",
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 key={`${item.title}-${item.image.src}`} {...item} surface={surface} />
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>