@doyourjob/gravity-ui-page-constructor 5.31.264 → 5.31.266

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.
Files changed (32) hide show
  1. package/build/cjs/blocks/Header/Header.css +49 -1
  2. package/build/cjs/blocks/Header/Header.js +7 -6
  3. package/build/cjs/blocks/Header/schema.d.ts +8 -0
  4. package/build/cjs/blocks/Header/schema.js +4 -0
  5. package/build/cjs/blocks/HeaderSlider/schema.d.ts +4 -0
  6. package/build/cjs/blocks/LogoRotator/Item.js +1 -2
  7. package/build/cjs/blocks/LogoRotator/LogoRotator.css +7 -0
  8. package/build/cjs/blocks/LogoRotator/LogoRotator.js +55 -3
  9. package/build/cjs/blocks/LogoRotator/schema.d.ts +6 -4
  10. package/build/cjs/blocks/LogoRotator/schema.js +10 -6
  11. package/build/cjs/blocks/LogoRotator/utils.d.ts +7 -0
  12. package/build/cjs/blocks/LogoRotator/utils.js +34 -1
  13. package/build/cjs/models/constructor-items/blocks.d.ts +4 -2
  14. package/build/cjs/sub-blocks/MiniCaseCard/MiniCaseCard.css +0 -5
  15. package/build/esm/blocks/Header/Header.css +49 -1
  16. package/build/esm/blocks/Header/Header.js +8 -7
  17. package/build/esm/blocks/Header/schema.d.ts +8 -0
  18. package/build/esm/blocks/Header/schema.js +5 -1
  19. package/build/esm/blocks/HeaderSlider/schema.d.ts +4 -0
  20. package/build/esm/blocks/LogoRotator/Item.js +2 -3
  21. package/build/esm/blocks/LogoRotator/LogoRotator.css +7 -0
  22. package/build/esm/blocks/LogoRotator/LogoRotator.js +56 -4
  23. package/build/esm/blocks/LogoRotator/schema.d.ts +6 -4
  24. package/build/esm/blocks/LogoRotator/schema.js +10 -6
  25. package/build/esm/blocks/LogoRotator/utils.d.ts +7 -0
  26. package/build/esm/blocks/LogoRotator/utils.js +31 -0
  27. package/build/esm/models/constructor-items/blocks.d.ts +4 -2
  28. package/build/esm/sub-blocks/MiniCaseCard/MiniCaseCard.css +0 -5
  29. package/package.json +1 -1
  30. package/schema/index.js +1 -1
  31. package/server/models/constructor-items/blocks.d.ts +4 -2
  32. package/widget/index.js +1 -1
@@ -7,11 +7,15 @@ import { Grid, Row } from '../../grid';
7
7
  import useWindowBreakpoint from '../../hooks/useWindowBreakpoint';
8
8
  import { block } from '../../utils';
9
9
  import Item from './Item';
10
- import { DEFAULT_SWAP_ANIMATION, SWAP_ANIMATION_DURATIONS, getInitialSlots, getLayerModifiers, } from './utils';
10
+ import { DEFAULT_SWAP_ANIMATION, SWAP_ANIMATION_DURATIONS, getActiveBreakpointValue, getInitialSlots, getLayerModifiers, getLogoRotatorColSizes, } from './utils';
11
11
  import './LogoRotator.css';
12
12
  const b = block('logo-rotator-block');
13
13
  const DEFAULT_MIN_ROTATE_COUNT = 2;
14
14
  const DEFAULT_MAX_ROTATE_COUNT = 4;
15
+ const GRID_COLUMNS_COUNT = 12;
16
+ const MIN_COLUMN_COUNT = 2;
17
+ const MAX_COLUMN_COUNT = 7;
18
+ const ROW_MODE_ITEM_MIN_WIDTH = 160;
15
19
  const emptyTransitions = (count) => Array(count).fill(undefined);
16
20
  const pickRandomSlots = (slotIndices, count) => {
17
21
  const shuffled = [...slotIndices];
@@ -21,10 +25,58 @@ const pickRandomSlots = (slotIndices, count) => {
21
25
  }
22
26
  return shuffled.slice(0, count);
23
27
  };
28
+ const getFiniteCssValue = (value) => {
29
+ const result = Number.parseFloat(value);
30
+ return Number.isFinite(result) ? result : 0;
31
+ };
32
+ const getSupportedColumnCount = (columns) => {
33
+ const columnCount = Math.min(Math.max(Math.floor(columns), MIN_COLUMN_COUNT), MAX_COLUMN_COUNT);
34
+ return String(columnCount);
35
+ };
36
+ const getActiveGridColumnCount = (colSizes, breakpoint) => {
37
+ const activeColSize = getActiveBreakpointValue(getLogoRotatorColSizes(colSizes), breakpoint);
38
+ return getSupportedColumnCount(GRID_COLUMNS_COUNT / activeColSize);
39
+ };
40
+ const getRowModeColumnCount = (width, gap) => {
41
+ const columns = Math.floor((width + gap) / (ROW_MODE_ITEM_MIN_WIDTH + gap));
42
+ return getSupportedColumnCount(columns);
43
+ };
44
+ const getActiveCount = (count, columnCount) => count[columnCount];
45
+ const noop = () => { };
46
+ const useRowModeColumnCount = (rowMode, breakpoint, rowItemsRef) => {
47
+ const [columnCount, setColumnCount] = useState(getSupportedColumnCount(MIN_COLUMN_COUNT));
48
+ useEffect(() => {
49
+ if (!rowMode) {
50
+ setColumnCount(getSupportedColumnCount(MIN_COLUMN_COUNT));
51
+ return noop;
52
+ }
53
+ const rowItems = rowItemsRef.current;
54
+ if (!rowItems)
55
+ return noop;
56
+ const updateColumnCount = (width) => {
57
+ const nextColumnCount = breakpoint <= BREAKPOINTS.md
58
+ ? getSupportedColumnCount(MIN_COLUMN_COUNT)
59
+ : getRowModeColumnCount(width, getFiniteCssValue(window.getComputedStyle(rowItems).columnGap));
60
+ setColumnCount((currentColumnCount) => currentColumnCount === nextColumnCount ? currentColumnCount : nextColumnCount);
61
+ };
62
+ updateColumnCount(rowItems.clientWidth);
63
+ if (typeof ResizeObserver === 'undefined')
64
+ return noop;
65
+ const observer = new ResizeObserver(([entry]) => {
66
+ updateColumnCount(entry.contentRect.width);
67
+ });
68
+ observer.observe(rowItems);
69
+ return () => observer.disconnect();
70
+ }, [breakpoint, rowItemsRef, rowMode]);
71
+ return columnCount;
72
+ };
24
73
  export const LogoRotatorBlock = (props) => {
25
- const { animated, title, text, theme, items, countMobile, countDesktop, minRotateCount = DEFAULT_MIN_ROTATE_COUNT, maxRotateCount = DEFAULT_MAX_ROTATE_COUNT, swapAnimation = DEFAULT_SWAP_ANIMATION, colSizes, rowMode, } = props;
74
+ const { animated, title, text, theme, items, count, minRotateCount = DEFAULT_MIN_ROTATE_COUNT, maxRotateCount = DEFAULT_MAX_ROTATE_COUNT, swapAnimation = DEFAULT_SWAP_ANIMATION, colSizes, rowMode, } = props;
26
75
  const breakpoint = useWindowBreakpoint();
27
- const activeCount = countDesktop !== undefined && breakpoint >= BREAKPOINTS.md ? countDesktop : countMobile;
76
+ const rowItemsRef = useRef(null);
77
+ const rowModeColumnCount = useRowModeColumnCount(rowMode, breakpoint, rowItemsRef);
78
+ const gridColumnCount = useMemo(() => getActiveGridColumnCount(colSizes, breakpoint), [breakpoint, colSizes]);
79
+ const activeCount = getActiveCount(count, rowMode ? rowModeColumnCount : gridColumnCount);
28
80
  // Индексы логотипов, которые участвуют в ротации (не статичные)
29
81
  const rotatableIndices = useMemo(() => items.map((item, i) => (item.isStatic ? -1 : i)).filter((i) => i !== -1), [items]);
30
82
  // Инициализация слотов: статичные вставляются в начало, остальные по порядку
@@ -148,7 +200,7 @@ export const LogoRotatorBlock = (props) => {
148
200
  title || text ? (React.createElement("div", { className: b('head') },
149
201
  title && React.createElement("h2", { className: b('title') }, title),
150
202
  text && React.createElement("div", { className: b('text') }, text))) : null,
151
- rowMode ? (React.createElement("div", { className: b('row-items') }, slots.map((slot, index) => {
203
+ rowMode ? (React.createElement("div", { className: b('row-items'), ref: rowItemsRef }, slots.map((slot, index) => {
152
204
  var _a;
153
205
  const transition = transitions[index];
154
206
  const item = items[(_a = transition === null || transition === void 0 ? void 0 : transition.to) !== null && _a !== void 0 ? _a : slot];
@@ -32,11 +32,13 @@ export declare const LogoRotatorBlock: {
32
32
  };
33
33
  };
34
34
  };
35
- countMobile: {
36
- type: string;
37
- };
38
- countDesktop: {
35
+ count: {
39
36
  type: string;
37
+ additionalProperties: boolean;
38
+ required: string[];
39
+ properties: Record<string, {
40
+ type: 'number';
41
+ }>;
40
42
  };
41
43
  minRotateCount: {
42
44
  type: string;
@@ -1,8 +1,16 @@
1
1
  import { AnimatableProps, BaseProps, ThemeProps, containerSizesObject, } from '../../schema/validators/common';
2
+ const countColumns = ['2', '3', '4', '5', '6', '7'];
3
+ const countByColumnsProperties = countColumns.reduce((acc, columns) => (Object.assign(Object.assign({}, acc), { [columns]: { type: 'number' } })), {});
4
+ const countByColumns = {
5
+ type: 'object',
6
+ additionalProperties: false,
7
+ required: countColumns,
8
+ properties: countByColumnsProperties,
9
+ };
2
10
  export const LogoRotatorBlock = {
3
11
  'logo-rotator-block': {
4
12
  additionalProperties: false,
5
- required: ['items', 'countMobile'],
13
+ required: ['items', 'count'],
6
14
  properties: Object.assign(Object.assign(Object.assign({}, BaseProps), AnimatableProps), { title: {
7
15
  type: 'string',
8
16
  }, text: {
@@ -19,11 +27,7 @@ export const LogoRotatorBlock = {
19
27
  isStatic: { type: 'boolean' },
20
28
  },
21
29
  },
22
- }, countMobile: {
23
- type: 'number',
24
- }, countDesktop: {
25
- type: 'number',
26
- }, minRotateCount: {
30
+ }, count: countByColumns, minRotateCount: {
27
31
  type: 'number',
28
32
  }, maxRotateCount: {
29
33
  type: 'number',
@@ -1,7 +1,14 @@
1
+ import { GridColumnSize, GridColumnSizesType } from '../../grid';
1
2
  import { LogoRotatorBlockProps } from '../../models';
2
3
  export type LogoRotatorLayer = 'current' | 'from' | 'to';
3
4
  export type LogoRotatorSwapAnimation = NonNullable<LogoRotatorBlockProps['swapAnimation']>;
4
5
  export declare const DEFAULT_SWAP_ANIMATION: LogoRotatorSwapAnimation;
5
6
  export declare const SWAP_ANIMATION_DURATIONS: Record<LogoRotatorSwapAnimation, number>;
7
+ export declare const getActiveBreakpointValue: <T>(values: Partial<Record<GridColumnSize, T>> & {
8
+ all: T;
9
+ }, breakpoint: number) => T | (undefined & T);
10
+ export declare const getLogoRotatorColSizes: (colSizes: LogoRotatorBlockProps['colSizes']) => GridColumnSizesType & {
11
+ all: number;
12
+ };
6
13
  export declare const getLayerModifiers: (layer: LogoRotatorLayer, swapAnimation: LogoRotatorSwapAnimation) => Record<string, boolean>;
7
14
  export declare const getInitialSlots: (items: LogoRotatorBlockProps['items'], count: number) => number[];
@@ -1,8 +1,39 @@
1
+ import { BREAKPOINTS } from '../../constants';
2
+ import { GridColumnSize } from '../../grid';
1
3
  export const DEFAULT_SWAP_ANIMATION = 'fade';
2
4
  export const SWAP_ANIMATION_DURATIONS = {
3
5
  fade: 1100,
4
6
  morph: 500,
5
7
  };
8
+ const defaultColSizes = { all: 3 };
9
+ const maxMobileColSize = 6;
10
+ const gridBreakpoints = [
11
+ [GridColumnSize.All, BREAKPOINTS.xs],
12
+ [GridColumnSize.Sm, BREAKPOINTS.sm],
13
+ [GridColumnSize.Md, BREAKPOINTS.md],
14
+ [GridColumnSize.Lg, BREAKPOINTS.lg],
15
+ [GridColumnSize.Xl, BREAKPOINTS.xl],
16
+ ];
17
+ export const getActiveBreakpointValue = (values, breakpoint) => {
18
+ let result = values.all;
19
+ gridBreakpoints.forEach(([size, minWidth]) => {
20
+ const value = values[size];
21
+ if (breakpoint >= minWidth && value !== undefined) {
22
+ result = value;
23
+ }
24
+ });
25
+ return result;
26
+ };
27
+ export const getLogoRotatorColSizes = (colSizes) => {
28
+ const sizes = Object.assign(Object.assign({}, defaultColSizes), colSizes);
29
+ [GridColumnSize.All, GridColumnSize.Sm].forEach((size) => {
30
+ const colSize = sizes[size];
31
+ if (colSize !== undefined) {
32
+ sizes[size] = Math.min(colSize, maxMobileColSize);
33
+ }
34
+ });
35
+ return sizes;
36
+ };
6
37
  export const getLayerModifiers = (layer, swapAnimation) => {
7
38
  const animationModifier = layer === 'current' ? undefined : `${swapAnimation}-${layer}`;
8
39
  const modifiers = { [layer]: true };
@@ -204,6 +204,7 @@ export interface SwitchingTitleProps {
204
204
  export type HeaderButtonType = Pick<ButtonProps, 'url' | 'text' | 'img' | 'theme' | 'primary' | 'size' | 'extraProps'>;
205
205
  export interface HeaderBlockProps {
206
206
  title: string;
207
+ titleSize?: TitleTextSize;
207
208
  switchingTitle?: SwitchingTitleProps;
208
209
  topTags?: HeaderTag[];
209
210
  bottomTags?: HeaderTag[];
@@ -301,6 +302,8 @@ export interface QuestionBlockItemProps extends QuestionItem {
301
302
  }
302
303
  export interface BannerBlockProps extends BannerCardProps, Animatable {
303
304
  }
305
+ export type LogoRotatorColumnCount = '2' | '3' | '4' | '5' | '6' | '7';
306
+ export type LogoRotatorCountConfig = Record<LogoRotatorColumnCount, number>;
304
307
  export interface LogoRotatorBlockProps extends Animatable {
305
308
  title?: string;
306
309
  text?: string;
@@ -309,8 +312,7 @@ export interface LogoRotatorBlockProps extends Animatable {
309
312
  src: string;
310
313
  isStatic?: boolean;
311
314
  }[];
312
- countMobile: number;
313
- countDesktop?: number;
315
+ count: LogoRotatorCountConfig;
314
316
  minRotateCount?: number;
315
317
  maxRotateCount?: number;
316
318
  swapAnimation?: 'fade' | 'morph';
@@ -48,11 +48,6 @@ unpredictable css rules order in build */
48
48
  flex-flow: row wrap;
49
49
  gap: 8px;
50
50
  }
51
- @media (max-width: 769px) {
52
- .pc-mini-case-card__tags {
53
- flex-wrap: wrap;
54
- }
55
- }
56
51
  .pc-mini-case-card__tag {
57
52
  display: flex;
58
53
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor",
3
- "version": "5.31.264",
3
+ "version": "5.31.266",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {