@doyourjob/gravity-ui-page-constructor 5.31.248 → 5.31.250

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.
@@ -130,7 +130,7 @@ export declare const MapBlock: {
130
130
  mediaOnly: {
131
131
  type: string;
132
132
  };
133
- imageWidthAuto: {
133
+ imageMaxWidth: {
134
134
  type: string;
135
135
  };
136
136
  disableShadow: {
@@ -330,7 +330,7 @@ export declare const MediaBlockBaseProps: {
330
330
  mediaOnly: {
331
331
  type: string;
332
332
  };
333
- imageWidthAuto: {
333
+ imageMaxWidth: {
334
334
  type: string;
335
335
  };
336
336
  /**
@@ -1214,7 +1214,7 @@ export declare const MediaBlock: {
1214
1214
  mediaOnly: {
1215
1215
  type: string;
1216
1216
  };
1217
- imageWidthAuto: {
1217
+ imageMaxWidth: {
1218
1218
  type: string;
1219
1219
  };
1220
1220
  /**
@@ -27,8 +27,8 @@ exports.MediaBlockBaseProps = Object.assign(Object.assign(Object.assign(Object.a
27
27
  type: 'boolean',
28
28
  }, mediaOnly: {
29
29
  type: 'boolean',
30
- }, imageWidthAuto: {
31
- type: 'boolean',
30
+ }, imageMaxWidth: {
31
+ type: 'number',
32
32
  },
33
33
  /**
34
34
  * @deprecated use border='none' or border='line' instead
@@ -24,6 +24,65 @@ const scrollToChild = (content, child, behavior = 'smooth') => {
24
24
  const left = child.offsetLeft - (content.offsetWidth - child.offsetWidth) / 2;
25
25
  content.scrollTo({ left, behavior });
26
26
  };
27
+ const MIDDLE_COPY = 1;
28
+ const normalizeToMiddleCopy = (content, childCount) => {
29
+ const centeredIndex = getCenteredChildIndex(content);
30
+ const logicalIndex = centeredIndex % childCount;
31
+ const currentCopy = Math.floor(centeredIndex / childCount);
32
+ if (currentCopy === MIDDLE_COPY) {
33
+ return false;
34
+ }
35
+ const middleChild = getChild(content, childCount + logicalIndex);
36
+ if (middleChild) {
37
+ scrollToChild(content, middleChild, 'auto');
38
+ }
39
+ return true;
40
+ };
41
+ const getTargetPhysicalIndex = (centeredPhysicalIndex, targetLogicalIndex, childCount, preferForward) => {
42
+ const currentLogical = centeredPhysicalIndex % childCount;
43
+ const forwardSteps = (targetLogicalIndex - currentLogical + childCount) % childCount;
44
+ const backwardSteps = (currentLogical - targetLogicalIndex + childCount) % childCount;
45
+ if (preferForward || forwardSteps <= backwardSteps) {
46
+ if (forwardSteps === 0) {
47
+ return MIDDLE_COPY * childCount + targetLogicalIndex;
48
+ }
49
+ return centeredPhysicalIndex + forwardSteps;
50
+ }
51
+ if (backwardSteps === 0) {
52
+ return MIDDLE_COPY * childCount + targetLogicalIndex;
53
+ }
54
+ return centeredPhysicalIndex - backwardSteps;
55
+ };
56
+ const SCROLL_IDLE_MS = 200;
57
+ const NORMALIZE_BEFORE_SNAP_MS = 100;
58
+ const scrollToMiddleCopyIndex = (content, targetLogicalIndex, childCount) => {
59
+ const runScroll = () => {
60
+ const targetChild = getChild(content, childCount + targetLogicalIndex);
61
+ if (targetChild) {
62
+ scrollToChild(content, targetChild);
63
+ }
64
+ };
65
+ if (normalizeToMiddleCopy(content, childCount)) {
66
+ requestAnimationFrame(runScroll);
67
+ return;
68
+ }
69
+ runScroll();
70
+ };
71
+ const scrollToLogicalIndex = (content, targetLogicalIndex, childCount, preferForward) => {
72
+ const runScroll = () => {
73
+ const centeredIndex = getCenteredChildIndex(content);
74
+ const targetPhysical = getTargetPhysicalIndex(centeredIndex, targetLogicalIndex, childCount, preferForward);
75
+ const targetChild = getChild(content, targetPhysical);
76
+ if (targetChild) {
77
+ scrollToChild(content, targetChild);
78
+ }
79
+ };
80
+ if (normalizeToMiddleCopy(content, childCount)) {
81
+ requestAnimationFrame(runScroll);
82
+ return;
83
+ }
84
+ runScroll();
85
+ };
27
86
  const PlayIcon = () => {
28
87
  return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "30", height: "30", viewBox: "0 0 30 30", fill: "none" },
29
88
  react_1.default.createElement("path", { d: "M13.765 9.83831L20.3154 13.7086C21.2977 14.289 21.298 15.7102 20.3159 16.2911L13.7714 20.1618C12.7719 20.7529 11.5086 20.033 11.5078 18.8718L11.502 11.1309C11.5011 9.96894 12.7646 9.24725 13.765 9.83831Z", fill: "currentColor" })));
@@ -33,14 +92,17 @@ const PauseIcon = () => {
33
92
  react_1.default.createElement("path", { d: "M12.5 10C13.3284 10 14 10.6716 14 11.5V18.5C14 19.3284 13.3284 20 12.5 20C11.6716 20 11 19.3284 11 18.5V11.5C11 10.6716 11.6716 10 12.5 10ZM17.5 10C18.3284 10 19 10.6716 19 11.5V18.5C19 19.3284 18.3284 20 17.5 20C16.6716 20 16 19.3284 16 18.5V11.5C16 10.6716 16.6716 10 17.5 10Z", fill: "currentColor" })));
34
93
  };
35
94
  const ScrollerBlock = (props) => {
36
- const { animated, widths, gapLong, fullWidth, scrollSnapCenter, children, autoScroll = true, autoScrollInterval = 3000, infinite = false, } = props;
95
+ const { animated, widths, gapLong, fullWidth, children, autoScroll = true, autoScrollInterval = 3000, infinite = false, } = props;
37
96
  const childCount = react_1.default.Children.count(children);
38
97
  const rootRef = (0, react_1.useRef)(null);
39
98
  const contentRef = (0, react_1.useRef)(null);
40
99
  const [currentElement, setCurrentElement] = (0, react_1.useState)(0);
41
100
  const [isPaused, setIsPaused] = (0, react_1.useState)(true);
42
101
  const [scrollInProgress, setScrollInProgress] = (0, react_1.useState)(false);
43
- const scrollIntervalRef = (0, react_1.useRef)(null);
102
+ const scrollIdleTimeoutRef = (0, react_1.useRef)(null);
103
+ const normalizeSettleTimeoutRef = (0, react_1.useRef)(null);
104
+ const scrollInProgressRef = (0, react_1.useRef)(false);
105
+ const isNormalizingRef = (0, react_1.useRef)(false);
44
106
  (0, react_1.useEffect)(() => {
45
107
  const content = contentRef.current;
46
108
  const root = rootRef.current;
@@ -86,6 +148,15 @@ const ScrollerBlock = (props) => {
86
148
  }
87
149
  };
88
150
  const handleInfiniteScroll = () => {
151
+ if (isNormalizingRef.current) {
152
+ return;
153
+ }
154
+ const wasNotInProgress = !scrollInProgressRef.current;
155
+ if (wasNotInProgress) {
156
+ isNormalizingRef.current = true;
157
+ normalizeToMiddleCopy(content, childCount);
158
+ isNormalizingRef.current = false;
159
+ }
89
160
  const scrollLeft = content.scrollLeft;
90
161
  const endCopyChild = getChild(content, endCopyStartIndex);
91
162
  const copyStartChild = getChild(content, copyStartIndex);
@@ -102,18 +173,34 @@ const ScrollerBlock = (props) => {
102
173
  content.scrollTo(endChild.offsetLeft - content.clientWidth, 0);
103
174
  }
104
175
  }
176
+ scrollInProgressRef.current = true;
105
177
  setScrollInProgress(true);
106
- if (scrollIntervalRef.current) {
107
- clearTimeout(scrollIntervalRef.current);
178
+ if (scrollIdleTimeoutRef.current) {
179
+ clearTimeout(scrollIdleTimeoutRef.current);
108
180
  }
109
- scrollIntervalRef.current = setTimeout(() => {
110
- setScrollInProgress(false);
111
- }, 200);
181
+ if (normalizeSettleTimeoutRef.current) {
182
+ clearTimeout(normalizeSettleTimeoutRef.current);
183
+ }
184
+ scrollIdleTimeoutRef.current = setTimeout(() => {
185
+ isNormalizingRef.current = true;
186
+ normalizeToMiddleCopy(content, childCount);
187
+ isNormalizingRef.current = false;
188
+ normalizeSettleTimeoutRef.current = setTimeout(() => {
189
+ scrollInProgressRef.current = false;
190
+ setScrollInProgress(false);
191
+ }, NORMALIZE_BEFORE_SNAP_MS);
192
+ }, SCROLL_IDLE_MS);
112
193
  };
113
194
  content.addEventListener('scroll', handleInfiniteScroll, { passive: true });
114
195
  scrollToMiddle();
115
196
  return () => {
116
197
  content.removeEventListener('scroll', handleInfiniteScroll);
198
+ if (scrollIdleTimeoutRef.current) {
199
+ clearTimeout(scrollIdleTimeoutRef.current);
200
+ }
201
+ if (normalizeSettleTimeoutRef.current) {
202
+ clearTimeout(normalizeSettleTimeoutRef.current);
203
+ }
117
204
  };
118
205
  }, [infinite, childCount]);
119
206
  (0, react_1.useEffect)(() => {
@@ -127,11 +214,8 @@ const ScrollerBlock = (props) => {
127
214
  return;
128
215
  }
129
216
  if (infinite) {
130
- const centeredIndex = getCenteredChildIndex(content);
131
- const nextElement = getChild(content, centeredIndex + 1);
132
- if (nextElement) {
133
- scrollToChild(content, nextElement);
134
- }
217
+ const nextLogical = ((getCenteredChildIndex(content) % childCount) + 1) % childCount;
218
+ scrollToLogicalIndex(content, nextLogical, childCount, true);
135
219
  return;
136
220
  }
137
221
  const nextIndex = (currentElement + 1) % childCount;
@@ -140,7 +224,7 @@ const ScrollerBlock = (props) => {
140
224
  scrollToChild(content, nextElement);
141
225
  }
142
226
  }, [childCount, currentElement, infinite]);
143
- const scrollToIndex = (0, react_1.useCallback)((targetIndex) => {
227
+ const scrollToPaginationIndex = (0, react_1.useCallback)((targetIndex) => {
144
228
  if (autoScroll) {
145
229
  setIsPaused(true);
146
230
  }
@@ -155,27 +239,26 @@ const ScrollerBlock = (props) => {
155
239
  }
156
240
  return;
157
241
  }
158
- const centeredIndex = getCenteredChildIndex(content);
159
- const currentCopy = Math.floor(centeredIndex / childCount);
160
- const logicalIndex = centeredIndex % childCount;
161
- const middleCopy = 1;
162
- const scrollToTargetInMiddleCopy = () => {
163
- const targetChild = getChild(content, childCount + targetIndex);
164
- if (targetChild) {
165
- scrollToChild(content, targetChild);
166
- }
167
- };
168
- if (currentCopy !== middleCopy) {
169
- const middleChild = getChild(content, childCount + logicalIndex);
170
- if (middleChild) {
171
- const left = middleChild.offsetLeft -
172
- (content.offsetWidth - middleChild.offsetWidth) / 2;
173
- content.scrollTo({ left, behavior: 'auto' });
242
+ scrollToMiddleCopyIndex(content, targetIndex, childCount);
243
+ }, [autoScroll, childCount, infinite]);
244
+ const scrollToItemIndex = (0, react_1.useCallback)((targetIndex) => {
245
+ if (autoScroll) {
246
+ setIsPaused(true);
247
+ }
248
+ const content = contentRef.current;
249
+ if (!content || childCount <= 1 || targetIndex < 0 || targetIndex >= childCount) {
250
+ return;
251
+ }
252
+ if (!infinite) {
253
+ const child = getChild(content, targetIndex);
254
+ if (child) {
255
+ scrollToChild(content, child);
174
256
  }
175
- requestAnimationFrame(scrollToTargetInMiddleCopy);
176
257
  return;
177
258
  }
178
- scrollToTargetInMiddleCopy();
259
+ const logicalIndex = getCenteredChildIndex(content) % childCount;
260
+ const isNext = targetIndex === (logicalIndex + 1) % childCount;
261
+ scrollToLogicalIndex(content, targetIndex, childCount, isNext);
179
262
  }, [autoScroll, childCount, infinite]);
180
263
  (0, react_1.useEffect)(() => {
181
264
  let timeout = null;
@@ -195,23 +278,23 @@ const ScrollerBlock = (props) => {
195
278
  react_1.default.createElement("div", { className: b('content', {
196
279
  gapLong,
197
280
  fullWidth,
198
- 'scroll-snap-center': infinite ? !scrollInProgress : scrollSnapCenter,
281
+ 'scroll-snap-center': infinite ? !scrollInProgress : true,
199
282
  }), ref: contentRef }, (infinite ? [0, 1, 2] : [0])
200
283
  .map((mi) => react_1.default.Children.map(children, (child, index) => {
201
284
  const physicalIndex = mi * childCount + index;
202
- return (react_1.default.createElement("div", { key: physicalIndex, role: "button", tabIndex: 0, className: b('item'), style: { width: (widths === null || widths === void 0 ? void 0 : widths[index]) || 'auto' }, onClick: () => scrollToIndex(index), onKeyDown: (event) => {
285
+ return (react_1.default.createElement("div", { key: physicalIndex, role: "button", tabIndex: 0, className: b('item'), style: { width: (widths === null || widths === void 0 ? void 0 : widths[index]) || 'auto' }, onClick: () => scrollToItemIndex(index), onKeyDown: (event) => {
203
286
  if (event.key === 'Enter' || event.key === ' ') {
204
287
  event.preventDefault();
205
- scrollToIndex(index);
288
+ scrollToItemIndex(index);
206
289
  }
207
290
  } }, child));
208
291
  }))
209
292
  .flat())),
210
293
  childCount > 0 && (react_1.default.createElement("div", { className: b('pagination-container') },
211
- react_1.default.createElement("div", { className: b('pagination') }, Array.from({ length: childCount }, (_, index) => (react_1.default.createElement("div", { key: index, role: "button", tabIndex: 0, className: b('pip', { active: index === currentElement }), onClick: () => scrollToIndex(index), onKeyDown: (event) => {
294
+ react_1.default.createElement("div", { className: b('pagination') }, Array.from({ length: childCount }, (_, index) => (react_1.default.createElement("div", { key: index, role: "button", tabIndex: 0, className: b('pip', { active: index === currentElement }), onClick: () => scrollToPaginationIndex(index), onKeyDown: (event) => {
212
295
  if (event.key === 'Enter' || event.key === ' ') {
213
296
  event.preventDefault();
214
- scrollToIndex(index);
297
+ scrollToPaginationIndex(index);
215
298
  }
216
299
  } }, autoScroll && (react_1.default.createElement("div", { style: {
217
300
  transition: `width ${autoScrollInterval}ms, opacity 0.5s ease`,
@@ -2,9 +2,6 @@ export declare const ScrollerControlsProps: {
2
2
  infinite: {
3
3
  type: string;
4
4
  };
5
- scrollSnapCenter: {
6
- type: string;
7
- };
8
5
  autoScroll: {
9
6
  type: string;
10
7
  };
@@ -26,9 +23,6 @@ export declare const ScrollerBlock: {
26
23
  infinite: {
27
24
  type: string;
28
25
  };
29
- scrollSnapCenter: {
30
- type: string;
31
- };
32
26
  autoScroll: {
33
27
  type: string;
34
28
  };
@@ -6,9 +6,6 @@ exports.ScrollerControlsProps = {
6
6
  infinite: {
7
7
  type: 'boolean',
8
8
  },
9
- scrollSnapCenter: {
10
- type: 'boolean',
11
- },
12
9
  autoScroll: {
13
10
  type: 'boolean',
14
11
  },
@@ -7,12 +7,12 @@ const NewsCard_1 = tslib_1.__importDefault(require("../../sub-blocks/NewsCard/Ne
7
7
  const utils_1 = require("../../utils");
8
8
  const Scroller_1 = tslib_1.__importDefault(require("../Scroller/Scroller"));
9
9
  const b = (0, utils_1.block)('whats-new-block');
10
- const WhatsNew = ({ title, items, footnote, links, animated, infinite, scrollSnapCenter, autoScroll, autoScrollInterval, }) => {
10
+ const WhatsNew = ({ title, items, footnote, links, animated, infinite, autoScroll, autoScrollInterval, }) => {
11
11
  return (react_1.default.createElement(components_1.AnimateBlock, { className: b(), animate: animated },
12
12
  react_1.default.createElement("div", { className: b('root') },
13
13
  title && (react_1.default.createElement("div", { className: b('head') },
14
14
  react_1.default.createElement("h2", { className: b('title') }, title))),
15
- react_1.default.createElement(Scroller_1.default, { fullWidth: true, infinite: infinite, scrollSnapCenter: scrollSnapCenter, autoScroll: autoScroll !== null && autoScroll !== void 0 ? autoScroll : true, autoScrollInterval: autoScrollInterval }, items.map((item, index) => (react_1.default.createElement(NewsCard_1.default, Object.assign({ key: index }, item))))),
15
+ react_1.default.createElement(Scroller_1.default, { fullWidth: true, infinite: infinite, autoScroll: autoScroll !== null && autoScroll !== void 0 ? autoScroll : true, autoScrollInterval: autoScrollInterval }, items.map((item, index) => (react_1.default.createElement(NewsCard_1.default, Object.assign({ key: index }, item))))),
16
16
  (footnote || (links === null || links === void 0 ? void 0 : links.length)) && (react_1.default.createElement("div", { className: b('footer') },
17
17
  footnote && react_1.default.createElement("div", { className: b('footnote') }, footnote),
18
18
  (links === null || links === void 0 ? void 0 : links.length) ? (react_1.default.createElement("div", { className: b('links') }, links.map((link, index) => (react_1.default.createElement("a", { key: index, href: link.url, className: b('link'), target: "_blank", rel: "noopener noreferrer" },
@@ -59,9 +59,6 @@ export declare const WhatsNewBlock: {
59
59
  infinite: {
60
60
  type: string;
61
61
  };
62
- scrollSnapCenter: {
63
- type: string;
64
- };
65
62
  autoScroll: {
66
63
  type: string;
67
64
  };
@@ -16,11 +16,6 @@ unpredictable css rules order in build */
16
16
  .pc-media-base__card img {
17
17
  width: 100%;
18
18
  }
19
- @media (min-width: 769px) {
20
- .pc-media-base__card_imageWidthAuto img {
21
- width: auto;
22
- }
23
- }
24
19
  .pc-media-base__card img,
25
20
  .pc-media-base__card video,
26
21
  .pc-media-base__card iframe,
@@ -11,7 +11,7 @@ const MediaBaseContent_1 = tslib_1.__importDefault(require("./MediaBaseContent")
11
11
  const b = (0, utils_1.block)('media-base');
12
12
  const Card = () => null;
13
13
  const MediaBase = (props) => {
14
- const { children, largeMedia, smallMedia, direction = 'content-media', mobileDirection = 'content-media', animated, mediaOnly, imageWidthAuto, onScroll, mediaOnlyColSizes = { all: 12, md: 8 } } = props, mediaContentProps = tslib_1.__rest(props, ["children", "largeMedia", "smallMedia", "direction", "mobileDirection", "animated", "mediaOnly", "imageWidthAuto", "onScroll", "mediaOnlyColSizes"]);
14
+ const { children, largeMedia, smallMedia, direction = 'content-media', mobileDirection = 'content-media', animated, mediaOnly, imageMaxWidth, onScroll, mediaOnlyColSizes = { all: 12, md: 8 } } = props, mediaContentProps = tslib_1.__rest(props, ["children", "largeMedia", "smallMedia", "direction", "mobileDirection", "animated", "mediaOnly", "imageMaxWidth", "onScroll", "mediaOnlyColSizes"]);
15
15
  const { title, description } = mediaContentProps;
16
16
  const mediaSizes = (0, react_1.useMemo)(() => {
17
17
  let md = 6;
@@ -47,7 +47,7 @@ const MediaBase = (props) => {
47
47
  }) },
48
48
  react_1.default.createElement(grid_1.Col, { className: b('content'), sizes: contentSizes }, mediaContent),
49
49
  card ? (react_1.default.createElement(grid_1.Col, { sizes: mediaSizes },
50
- react_1.default.createElement("div", { className: b('card', { imageWidthAuto }) }, card))) : null)))));
50
+ react_1.default.createElement("div", { className: b('card'), style: imageMaxWidth ? { maxWidth: `${imageMaxWidth}px` } : {} }, card))) : null)))));
51
51
  };
52
52
  exports.MediaBase = MediaBase;
53
53
  exports.MediaBase.Card = Card;
@@ -363,7 +363,6 @@ export interface ScrollerBlockProps extends Animatable {
363
363
  gapLong?: boolean;
364
364
  fullWidth?: boolean;
365
365
  infinite?: boolean;
366
- scrollSnapCenter?: boolean;
367
366
  autoScroll?: boolean;
368
367
  autoScrollInterval?: number;
369
368
  }
@@ -378,7 +377,7 @@ export interface MediaBaseBlockProps extends Animatable, MediaContentProps {
378
377
  largeMedia?: boolean;
379
378
  smallMedia?: boolean;
380
379
  mediaOnly?: boolean;
381
- imageWidthAuto?: boolean;
380
+ imageMaxWidth?: number;
382
381
  mediaOnlyColSizes?: GridColumnSizesType;
383
382
  }
384
383
  export interface MediaContentProps extends Omit<ContentBlockProps, 'colSizes' | 'text' | 'title' | 'theme' | 'centered'> {
@@ -647,7 +646,7 @@ export interface BenchmarkBlockProps extends Animatable {
647
646
  postfix?: string;
648
647
  }[];
649
648
  }
650
- export interface WhatsNewBlockProps extends Animatable, Pick<ScrollerBlockProps, 'infinite' | 'scrollSnapCenter' | 'autoScroll' | 'autoScrollInterval'> {
649
+ export interface WhatsNewBlockProps extends Animatable, Pick<ScrollerBlockProps, 'infinite' | 'autoScroll' | 'autoScrollInterval'> {
651
650
  title?: string;
652
651
  items: NewsCardProps[];
653
652
  footnote?: string;
@@ -130,7 +130,7 @@ export declare const MapBlock: {
130
130
  mediaOnly: {
131
131
  type: string;
132
132
  };
133
- imageWidthAuto: {
133
+ imageMaxWidth: {
134
134
  type: string;
135
135
  };
136
136
  disableShadow: {
@@ -330,7 +330,7 @@ export declare const MediaBlockBaseProps: {
330
330
  mediaOnly: {
331
331
  type: string;
332
332
  };
333
- imageWidthAuto: {
333
+ imageMaxWidth: {
334
334
  type: string;
335
335
  };
336
336
  /**
@@ -1214,7 +1214,7 @@ export declare const MediaBlock: {
1214
1214
  mediaOnly: {
1215
1215
  type: string;
1216
1216
  };
1217
- imageWidthAuto: {
1217
+ imageMaxWidth: {
1218
1218
  type: string;
1219
1219
  };
1220
1220
  /**
@@ -23,8 +23,8 @@ export const MediaBlockBaseProps = Object.assign(Object.assign(Object.assign(Obj
23
23
  type: 'boolean',
24
24
  }, mediaOnly: {
25
25
  type: 'boolean',
26
- }, imageWidthAuto: {
27
- type: 'boolean',
26
+ }, imageMaxWidth: {
27
+ type: 'number',
28
28
  },
29
29
  /**
30
30
  * @deprecated use border='none' or border='line' instead