@doyourjob/gravity-ui-page-constructor 5.31.252 → 5.31.254
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/build/cjs/blocks/LogoRotator/LogoRotator.js +32 -24
- package/build/cjs/blocks/LogoRotator/schema.d.ts +3 -0
- package/build/cjs/blocks/LogoRotator/schema.js +2 -0
- package/build/cjs/models/constructor-items/blocks.d.ts +1 -0
- package/build/cjs/sub-blocks/MiniCaseCard/MiniCaseCard.js +4 -3
- package/build/esm/blocks/LogoRotator/LogoRotator.js +32 -24
- package/build/esm/blocks/LogoRotator/schema.d.ts +3 -0
- package/build/esm/blocks/LogoRotator/schema.js +2 -0
- package/build/esm/models/constructor-items/blocks.d.ts +1 -0
- package/build/esm/sub-blocks/MiniCaseCard/MiniCaseCard.js +4 -3
- package/package.json +1 -1
- package/schema/index.js +1 -1
- package/server/models/constructor-items/blocks.d.ts +1 -0
- package/widget/index.js +1 -1
|
@@ -6,12 +6,32 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
6
6
|
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
7
|
const components_1 = require("../../components");
|
|
8
8
|
const AnimateBlock_1 = tslib_1.__importDefault(require("../../components/AnimateBlock/AnimateBlock"));
|
|
9
|
+
const constants_1 = require("../../constants");
|
|
9
10
|
const grid_1 = require("../../grid");
|
|
11
|
+
const useWindowBreakpoint_1 = tslib_1.__importDefault(require("../../hooks/useWindowBreakpoint"));
|
|
10
12
|
const utils_1 = require("../../utils");
|
|
11
13
|
const Item_1 = tslib_1.__importDefault(require("./Item"));
|
|
12
14
|
const b = (0, utils_1.block)('logo-rotator-block');
|
|
13
15
|
const DEFAULT_MIN_ROTATE_COUNT = 2;
|
|
14
16
|
const DEFAULT_MAX_ROTATE_COUNT = 4;
|
|
17
|
+
const getInitialSlots = (items, count) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const staticIdxList = items.map((item, i) => (item.isStatic ? i : -1)).filter((i) => i !== -1);
|
|
20
|
+
const rotatableIdxList = items
|
|
21
|
+
.map((item, i) => (item.isStatic ? -1 : i))
|
|
22
|
+
.filter((i) => i !== -1);
|
|
23
|
+
const initial = [];
|
|
24
|
+
let rotatablePointer = 0;
|
|
25
|
+
for (let slot = 0; slot < count; slot++) {
|
|
26
|
+
if (slot < staticIdxList.length) {
|
|
27
|
+
initial.push(staticIdxList[slot]);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
initial.push((_a = rotatableIdxList[rotatablePointer++]) !== null && _a !== void 0 ? _a : 0);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return initial;
|
|
34
|
+
};
|
|
15
35
|
const pickRandomSlots = (slotIndices, count) => {
|
|
16
36
|
const shuffled = [...slotIndices];
|
|
17
37
|
for (let i = shuffled.length - 1; i > 0; i--) {
|
|
@@ -21,38 +41,26 @@ const pickRandomSlots = (slotIndices, count) => {
|
|
|
21
41
|
return shuffled.slice(0, count);
|
|
22
42
|
};
|
|
23
43
|
const LogoRotatorBlock = (props) => {
|
|
24
|
-
const { animated, title, theme, items, count, minRotateCount = DEFAULT_MIN_ROTATE_COUNT, maxRotateCount = DEFAULT_MAX_ROTATE_COUNT, colSizes, rowMode, } = props;
|
|
44
|
+
const { animated, title, theme, items, count, desktopCount, minRotateCount = DEFAULT_MIN_ROTATE_COUNT, maxRotateCount = DEFAULT_MAX_ROTATE_COUNT, colSizes, rowMode, } = props;
|
|
45
|
+
const breakpoint = (0, useWindowBreakpoint_1.default)();
|
|
46
|
+
const activeCount = desktopCount !== undefined && breakpoint >= constants_1.BREAKPOINTS.md ? desktopCount : count;
|
|
25
47
|
// Индексы логотипов, которые участвуют в ротации (не статичные)
|
|
26
48
|
const rotatableIndices = (0, react_1.useMemo)(() => items.map((item, i) => (item.isStatic ? -1 : i)).filter((i) => i !== -1), [items]);
|
|
27
49
|
// Инициализация слотов: статичные вставляются в начало, остальные по порядку
|
|
28
|
-
const [slots, setSlots] = (0, react_1.useState)(() =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.map((item, i) => (item.isStatic ? i : -1))
|
|
32
|
-
.filter((i) => i !== -1);
|
|
33
|
-
const rotatableIdxList = items
|
|
34
|
-
.map((item, i) => (item.isStatic ? -1 : i))
|
|
35
|
-
.filter((i) => i !== -1);
|
|
36
|
-
const initial = [];
|
|
37
|
-
let rotatablePointer = 0;
|
|
38
|
-
for (let slot = 0; slot < count; slot++) {
|
|
39
|
-
if (slot < staticIdxList.length) {
|
|
40
|
-
initial.push(staticIdxList[slot]);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
initial.push((_a = rotatableIdxList[rotatablePointer++]) !== null && _a !== void 0 ? _a : 0);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return initial;
|
|
47
|
-
});
|
|
48
|
-
const [hidden, setHidden] = (0, react_1.useState)(() => Array(count).fill(false));
|
|
49
|
-
const nextIndexRef = (0, react_1.useRef)(count - 1);
|
|
50
|
+
const [slots, setSlots] = (0, react_1.useState)(() => getInitialSlots(items, activeCount));
|
|
51
|
+
const [hidden, setHidden] = (0, react_1.useState)(() => Array(activeCount).fill(false));
|
|
52
|
+
const nextIndexRef = (0, react_1.useRef)(activeCount - 1);
|
|
50
53
|
const isHoveredRef = (0, react_1.useRef)(false);
|
|
51
54
|
// Держим актуальные slots в ref, чтобы не пересоздавать интервал при каждом изменении
|
|
52
55
|
const slotsRef = (0, react_1.useRef)(slots);
|
|
53
56
|
(0, react_1.useEffect)(() => {
|
|
54
57
|
slotsRef.current = slots;
|
|
55
58
|
}, [slots]);
|
|
59
|
+
(0, react_1.useEffect)(() => {
|
|
60
|
+
setSlots(getInitialSlots(items, activeCount));
|
|
61
|
+
setHidden(Array(activeCount).fill(false));
|
|
62
|
+
nextIndexRef.current = activeCount - 1;
|
|
63
|
+
}, [activeCount, items]);
|
|
56
64
|
(0, react_1.useEffect)(() => {
|
|
57
65
|
let timeout = null;
|
|
58
66
|
const interval = setInterval(() => {
|
|
@@ -104,7 +112,7 @@ const LogoRotatorBlock = (props) => {
|
|
|
104
112
|
clearTimeout(timeout);
|
|
105
113
|
}
|
|
106
114
|
};
|
|
107
|
-
}, [
|
|
115
|
+
}, [activeCount, items, maxRotateCount, minRotateCount, rotatableIndices]);
|
|
108
116
|
const renderItems = (0, react_1.useMemo)(() => slots.map((slot, index) => (react_1.default.createElement(Item_1.default, { key: index, colSizes: colSizes, url: items[slot].url, src: items[slot].src, hidden: hidden[index] }))), [colSizes, hidden, items, slots]);
|
|
109
117
|
const titleProps = !title || typeof title === 'string'
|
|
110
118
|
? { text: title, textSize: 'l' }
|
|
@@ -12,9 +12,10 @@ const MiniCaseCardAuthor = ({ showQuote, avatar, author, position, }) => {
|
|
|
12
12
|
return (react_1.default.createElement("div", { className: b('author') },
|
|
13
13
|
avatar && react_1.default.createElement(components_1.Image, { src: avatar, className: b('author-avatar') }),
|
|
14
14
|
(author || position) && (react_1.default.createElement("div", { className: b('author-text') },
|
|
15
|
-
author && react_1.default.createElement("span", { className: b('author-name') },
|
|
16
|
-
|
|
17
|
-
position && react_1.default.createElement("span", { className: b('author-position') },
|
|
15
|
+
author && (react_1.default.createElement("span", { className: b('author-name') },
|
|
16
|
+
react_1.default.createElement(components_1.HTML, null, author))),
|
|
17
|
+
position && (react_1.default.createElement("span", { className: b('author-position') },
|
|
18
|
+
react_1.default.createElement(components_1.HTML, null, position)))))));
|
|
18
19
|
};
|
|
19
20
|
const MiniCaseCardTags = ({ tagUsecase, tagIndustry }) => {
|
|
20
21
|
if (!(tagUsecase === null || tagUsecase === void 0 ? void 0 : tagUsecase.length) && !(tagIndustry === null || tagIndustry === void 0 ? void 0 : tagIndustry.length)) {
|
|
@@ -2,13 +2,33 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { Link } from '@gravity-ui/uikit';
|
|
3
3
|
import { ImageBase, Title } from '../../components';
|
|
4
4
|
import AnimateBlock from '../../components/AnimateBlock/AnimateBlock';
|
|
5
|
+
import { BREAKPOINTS } from '../../constants';
|
|
5
6
|
import { Grid, Row } from '../../grid';
|
|
7
|
+
import useWindowBreakpoint from '../../hooks/useWindowBreakpoint';
|
|
6
8
|
import { block } from '../../utils';
|
|
7
9
|
import Item from './Item';
|
|
8
10
|
import './LogoRotator.css';
|
|
9
11
|
const b = block('logo-rotator-block');
|
|
10
12
|
const DEFAULT_MIN_ROTATE_COUNT = 2;
|
|
11
13
|
const DEFAULT_MAX_ROTATE_COUNT = 4;
|
|
14
|
+
const getInitialSlots = (items, count) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const staticIdxList = items.map((item, i) => (item.isStatic ? i : -1)).filter((i) => i !== -1);
|
|
17
|
+
const rotatableIdxList = items
|
|
18
|
+
.map((item, i) => (item.isStatic ? -1 : i))
|
|
19
|
+
.filter((i) => i !== -1);
|
|
20
|
+
const initial = [];
|
|
21
|
+
let rotatablePointer = 0;
|
|
22
|
+
for (let slot = 0; slot < count; slot++) {
|
|
23
|
+
if (slot < staticIdxList.length) {
|
|
24
|
+
initial.push(staticIdxList[slot]);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
initial.push((_a = rotatableIdxList[rotatablePointer++]) !== null && _a !== void 0 ? _a : 0);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return initial;
|
|
31
|
+
};
|
|
12
32
|
const pickRandomSlots = (slotIndices, count) => {
|
|
13
33
|
const shuffled = [...slotIndices];
|
|
14
34
|
for (let i = shuffled.length - 1; i > 0; i--) {
|
|
@@ -18,38 +38,26 @@ const pickRandomSlots = (slotIndices, count) => {
|
|
|
18
38
|
return shuffled.slice(0, count);
|
|
19
39
|
};
|
|
20
40
|
export const LogoRotatorBlock = (props) => {
|
|
21
|
-
const { animated, title, theme, items, count, minRotateCount = DEFAULT_MIN_ROTATE_COUNT, maxRotateCount = DEFAULT_MAX_ROTATE_COUNT, colSizes, rowMode, } = props;
|
|
41
|
+
const { animated, title, theme, items, count, desktopCount, minRotateCount = DEFAULT_MIN_ROTATE_COUNT, maxRotateCount = DEFAULT_MAX_ROTATE_COUNT, colSizes, rowMode, } = props;
|
|
42
|
+
const breakpoint = useWindowBreakpoint();
|
|
43
|
+
const activeCount = desktopCount !== undefined && breakpoint >= BREAKPOINTS.md ? desktopCount : count;
|
|
22
44
|
// Индексы логотипов, которые участвуют в ротации (не статичные)
|
|
23
45
|
const rotatableIndices = useMemo(() => items.map((item, i) => (item.isStatic ? -1 : i)).filter((i) => i !== -1), [items]);
|
|
24
46
|
// Инициализация слотов: статичные вставляются в начало, остальные по порядку
|
|
25
|
-
const [slots, setSlots] = useState(() =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.map((item, i) => (item.isStatic ? i : -1))
|
|
29
|
-
.filter((i) => i !== -1);
|
|
30
|
-
const rotatableIdxList = items
|
|
31
|
-
.map((item, i) => (item.isStatic ? -1 : i))
|
|
32
|
-
.filter((i) => i !== -1);
|
|
33
|
-
const initial = [];
|
|
34
|
-
let rotatablePointer = 0;
|
|
35
|
-
for (let slot = 0; slot < count; slot++) {
|
|
36
|
-
if (slot < staticIdxList.length) {
|
|
37
|
-
initial.push(staticIdxList[slot]);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
initial.push((_a = rotatableIdxList[rotatablePointer++]) !== null && _a !== void 0 ? _a : 0);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return initial;
|
|
44
|
-
});
|
|
45
|
-
const [hidden, setHidden] = useState(() => Array(count).fill(false));
|
|
46
|
-
const nextIndexRef = useRef(count - 1);
|
|
47
|
+
const [slots, setSlots] = useState(() => getInitialSlots(items, activeCount));
|
|
48
|
+
const [hidden, setHidden] = useState(() => Array(activeCount).fill(false));
|
|
49
|
+
const nextIndexRef = useRef(activeCount - 1);
|
|
47
50
|
const isHoveredRef = useRef(false);
|
|
48
51
|
// Держим актуальные slots в ref, чтобы не пересоздавать интервал при каждом изменении
|
|
49
52
|
const slotsRef = useRef(slots);
|
|
50
53
|
useEffect(() => {
|
|
51
54
|
slotsRef.current = slots;
|
|
52
55
|
}, [slots]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
setSlots(getInitialSlots(items, activeCount));
|
|
58
|
+
setHidden(Array(activeCount).fill(false));
|
|
59
|
+
nextIndexRef.current = activeCount - 1;
|
|
60
|
+
}, [activeCount, items]);
|
|
53
61
|
useEffect(() => {
|
|
54
62
|
let timeout = null;
|
|
55
63
|
const interval = setInterval(() => {
|
|
@@ -101,7 +109,7 @@ export const LogoRotatorBlock = (props) => {
|
|
|
101
109
|
clearTimeout(timeout);
|
|
102
110
|
}
|
|
103
111
|
};
|
|
104
|
-
}, [
|
|
112
|
+
}, [activeCount, items, maxRotateCount, minRotateCount, rotatableIndices]);
|
|
105
113
|
const renderItems = useMemo(() => slots.map((slot, index) => (React.createElement(Item, { key: index, colSizes: colSizes, url: items[slot].url, src: items[slot].src, hidden: hidden[index] }))), [colSizes, hidden, items, slots]);
|
|
106
114
|
const titleProps = !title || typeof title === 'string'
|
|
107
115
|
? { text: title, textSize: 'l' }
|
|
@@ -10,9 +10,10 @@ const MiniCaseCardAuthor = ({ showQuote, avatar, author, position, }) => {
|
|
|
10
10
|
return (React.createElement("div", { className: b('author') },
|
|
11
11
|
avatar && React.createElement(Image, { src: avatar, className: b('author-avatar') }),
|
|
12
12
|
(author || position) && (React.createElement("div", { className: b('author-text') },
|
|
13
|
-
author && React.createElement("span", { className: b('author-name') },
|
|
14
|
-
|
|
15
|
-
position && React.createElement("span", { className: b('author-position') },
|
|
13
|
+
author && (React.createElement("span", { className: b('author-name') },
|
|
14
|
+
React.createElement(HTML, null, author))),
|
|
15
|
+
position && (React.createElement("span", { className: b('author-position') },
|
|
16
|
+
React.createElement(HTML, null, position)))))));
|
|
16
17
|
};
|
|
17
18
|
const MiniCaseCardTags = ({ tagUsecase, tagIndustry }) => {
|
|
18
19
|
if (!(tagUsecase === null || tagUsecase === void 0 ? void 0 : tagUsecase.length) && !(tagIndustry === null || tagIndustry === void 0 ? void 0 : tagIndustry.length)) {
|