@doyourjob/gravity-ui-page-constructor 5.31.64 → 5.31.66

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 (28) hide show
  1. package/build/cjs/blocks/Header/Header.css +3 -0
  2. package/build/cjs/blocks/Header/Header.js +6 -3
  3. package/build/cjs/blocks/Header/SwitchingTitle/SwitchingTitle.css +5 -0
  4. package/build/cjs/blocks/Header/SwitchingTitle/SwitchingTtitle.d.ts +3 -0
  5. package/build/cjs/blocks/Header/SwitchingTitle/SwitchingTtitle.js +28 -0
  6. package/build/cjs/blocks/Header/schema.d.ts +18 -0
  7. package/build/cjs/blocks/Header/schema.js +15 -0
  8. package/build/cjs/blocks/Header/utils.d.ts +1 -0
  9. package/build/cjs/blocks/Header/utils.js +15 -1
  10. package/build/cjs/blocks/HeaderSlider/schema.d.ts +9 -0
  11. package/build/cjs/blocks/Reports/Reports.js +1 -7
  12. package/build/cjs/models/constructor-items/blocks.d.ts +5 -0
  13. package/build/esm/blocks/Header/Header.css +3 -0
  14. package/build/esm/blocks/Header/Header.js +6 -3
  15. package/build/esm/blocks/Header/SwitchingTitle/SwitchingTitle.css +5 -0
  16. package/build/esm/blocks/Header/SwitchingTitle/SwitchingTtitle.d.ts +4 -0
  17. package/build/esm/blocks/Header/SwitchingTitle/SwitchingTtitle.js +26 -0
  18. package/build/esm/blocks/Header/schema.d.ts +18 -0
  19. package/build/esm/blocks/Header/schema.js +15 -0
  20. package/build/esm/blocks/Header/utils.d.ts +1 -0
  21. package/build/esm/blocks/Header/utils.js +13 -0
  22. package/build/esm/blocks/HeaderSlider/schema.d.ts +9 -0
  23. package/build/esm/blocks/Reports/Reports.js +1 -7
  24. package/build/esm/models/constructor-items/blocks.d.ts +5 -0
  25. package/package.json +1 -1
  26. package/schema/index.js +1 -1
  27. package/server/models/constructor-items/blocks.d.ts +5 -0
  28. package/widget/index.js +1 -1
@@ -93,6 +93,9 @@ unpredictable css rules order in build */
93
93
  --pc-text-header-color: var(--g-color-text-link-hover);
94
94
  color: var(--g-color-text-link-hover);
95
95
  }
96
+ .pc-header-block__title_pre-wrap {
97
+ white-space: pre-wrap;
98
+ }
96
99
  .pc-header-block__description {
97
100
  margin-top: 16px;
98
101
  }
@@ -17,6 +17,7 @@ const Breadcrumbs_1 = tslib_1.__importDefault(require("./Breadcrumbs/Breadcrumbs
17
17
  const HeaderStock_1 = tslib_1.__importDefault(require("./HeaderStock/HeaderStock"));
18
18
  const HeaderTag_1 = tslib_1.__importDefault(require("./HeaderTag/HeaderTag"));
19
19
  const HeaderTags_1 = tslib_1.__importDefault(require("./HeaderTags/HeaderTags"));
20
+ const SwitchingTtitle_1 = tslib_1.__importDefault(require("./SwitchingTitle/SwitchingTtitle"));
20
21
  const utils_3 = require("./utils");
21
22
  const b = (0, utils_2.block)('header-block');
22
23
  const Background = ({ background, isMobile }) => {
@@ -28,7 +29,7 @@ const Background = ({ background, isMobile }) => {
28
29
  const FullWidthBackground = ({ background }) => (react_1.default.createElement("div", { className: b('background', { ['full-width']: true }), style: { backgroundColor: background === null || background === void 0 ? void 0 : background.color } }));
29
30
  // eslint-disable-next-line complexity
30
31
  const HeaderBlock = (props) => {
31
- const { title, topTags, bottomTags, overtitle, description, buttons, stock, stockPrice, stockShares, image, video, width = 's', imageSize, offset = 'default', background, theme: textTheme = 'light', verticalOffset = 'm', className, breadcrumbs, status, renderTitle, children, mediaView = 'full', } = props;
32
+ const { title, switchingTitle, topTags, bottomTags, overtitle, description, buttons, stock, stockPrice, stockShares, image, video, width = 's', imageSize, offset = 'default', background, theme: textTheme = 'light', verticalOffset = 'm', className, breadcrumbs, status, renderTitle, children, mediaView = 'full', } = props;
32
33
  const isMobile = (0, react_1.useContext)(mobileContext_1.MobileContext);
33
34
  const { backButton, blockTag } = (0, react_1.useContext)(headerContext_1.HeaderContext);
34
35
  const theme = (0, theme_1.useTheme)();
@@ -68,10 +69,12 @@ const HeaderBlock = (props) => {
68
69
  react_1.default.createElement("div", null,
69
70
  overtitle && (react_1.default.createElement("div", { className: b('overtitle') },
70
71
  react_1.default.createElement(components_1.HTML, null, overtitle))),
71
- react_1.default.createElement("h1", { className: b('title'), id: titleId },
72
+ react_1.default.createElement("h1", { className: b('title', {
73
+ 'pre-wrap': Boolean(switchingTitle),
74
+ }), id: titleId },
72
75
  react_1.default.createElement(HeaderTag_1.default, { tag: blockTag }),
73
76
  status,
74
- renderTitle ? (renderTitle(title)) : (react_1.default.createElement(components_1.HTML, null, title))),
77
+ switchingTitle ? (react_1.default.createElement(SwitchingTtitle_1.default, Object.assign({}, switchingTitle))) : (react_1.default.createElement(react_1.default.Fragment, null, renderTitle ? (renderTitle(title)) : (react_1.default.createElement(components_1.HTML, null, title))))),
75
78
  description && (react_1.default.createElement("div", { className: b('description', { theme: textTheme }) },
76
79
  react_1.default.createElement(YFMWrapper_1.default, { content: description, modifiers: {
77
80
  constructor: true,
@@ -0,0 +1,5 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-switching-title__title-part {
4
+ transition: opacity ease-in-out 0.2s;
5
+ }
@@ -0,0 +1,3 @@
1
+ import { SwitchingTitleProps } from '../../../models';
2
+ declare const SwitchingTitle: (props: SwitchingTitleProps) => JSX.Element;
3
+ export default SwitchingTitle;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const utils_1 = require("../../../utils");
6
+ const utils_2 = require("../utils");
7
+ const b = (0, utils_1.block)('switching-title');
8
+ const SwitchingTitle = (props) => {
9
+ const { text, switchingTime } = props;
10
+ const [currentIndex, setCurrentIndex] = (0, react_1.useState)(0);
11
+ const [opacity, setOpacity] = (0, react_1.useState)(1);
12
+ const texts = (0, react_1.useMemo)(() => (0, utils_2.partitionSwitchingTitleInput)(text), [text]);
13
+ const textSizesCommonMultiple = (0, react_1.useMemo)(() => texts.reduce((acc, curr) => acc * curr.length, 1), [texts]);
14
+ (0, react_1.useEffect)(() => {
15
+ const intervalHandle = setInterval(() => {
16
+ setOpacity(0);
17
+ setTimeout(() => {
18
+ setCurrentIndex((c) => (c + 1) % textSizesCommonMultiple);
19
+ setOpacity(1);
20
+ }, 200);
21
+ }, switchingTime);
22
+ return () => clearInterval(intervalHandle);
23
+ }, [texts, switchingTime, textSizesCommonMultiple]);
24
+ return (react_1.default.createElement("span", null, texts.map((lines, index) => (react_1.default.createElement("span", { className: b('title-part'), style: {
25
+ opacity: lines.length > 1 ? opacity : 1,
26
+ }, key: index }, lines[currentIndex % lines.length])))));
27
+ };
28
+ exports.default = SwitchingTitle;
@@ -320,6 +320,15 @@ export declare const HeaderProperties: {
320
320
  type: string;
321
321
  contentType: string;
322
322
  };
323
+ switchingTitle: {
324
+ type: string;
325
+ additionalProperties: string;
326
+ required: string[];
327
+ properties: {
328
+ name: string;
329
+ type: string;
330
+ }[];
331
+ };
323
332
  overtitle: {
324
333
  type: string;
325
334
  contentType: string;
@@ -980,6 +989,15 @@ export declare const HeaderBlock: {
980
989
  type: string;
981
990
  contentType: string;
982
991
  };
992
+ switchingTitle: {
993
+ type: string;
994
+ additionalProperties: string;
995
+ required: string[];
996
+ properties: {
997
+ name: string;
998
+ type: string;
999
+ }[];
1000
+ };
983
1001
  overtitle: {
984
1002
  type: string;
985
1003
  contentType: string;
@@ -16,6 +16,21 @@ exports.HeaderProperties = {
16
16
  type: 'string',
17
17
  contentType: 'text',
18
18
  },
19
+ switchingTitle: {
20
+ type: 'object',
21
+ additionalProperties: 'false',
22
+ required: ['text'],
23
+ properties: [
24
+ {
25
+ name: 'text',
26
+ type: 'string',
27
+ },
28
+ {
29
+ name: 'switchingTime',
30
+ type: 'number',
31
+ },
32
+ ],
33
+ },
19
34
  overtitle: {
20
35
  type: 'string',
21
36
  contentType: 'text',
@@ -18,3 +18,4 @@ export declare function getTitleSizes(width: HeaderWidth): {
18
18
  md?: undefined;
19
19
  };
20
20
  export declare function getImageSize(width: HeaderWidth): "s" | "m";
21
+ export declare const partitionSwitchingTitleInput: (str: string) => string[][];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImageSize = exports.getTitleSizes = exports.titleWithImageSizes = void 0;
3
+ exports.partitionSwitchingTitleInput = exports.getImageSize = exports.getTitleSizes = exports.titleWithImageSizes = void 0;
4
4
  function titleWithImageSizes(imageSize) {
5
5
  switch (imageSize) {
6
6
  case 's':
@@ -49,3 +49,17 @@ function getImageSize(width) {
49
49
  }
50
50
  }
51
51
  exports.getImageSize = getImageSize;
52
+ const partitionSwitchingTitleInput = (str) => {
53
+ if (str.length === 0)
54
+ return [['']];
55
+ const fixedRegExp = new RegExp('\\[.*', 's');
56
+ const fixedPart = str.replace(fixedRegExp, '');
57
+ if (fixedPart === str)
58
+ return [[fixedPart]];
59
+ const switchingPartRegExp = new RegExp('\\][^/].*', 's');
60
+ const switchingPart = str.slice(fixedPart.length + 1).replace(switchingPartRegExp, '');
61
+ const switchingPartArr = switchingPart.replace(/[[\]]/g, '').split('/');
62
+ const rest = str.slice(fixedPart.length + switchingPart.length + 2);
63
+ return [[fixedPart], switchingPartArr, ...(0, exports.partitionSwitchingTitleInput)(rest)].filter((arr) => arr.length !== 0 && (arr.length !== 1 || arr[0] !== ''));
64
+ };
65
+ exports.partitionSwitchingTitleInput = partitionSwitchingTitleInput;
@@ -14,6 +14,15 @@ export declare const HeaderSliderBlock: {
14
14
  type: string;
15
15
  contentType: string;
16
16
  };
17
+ switchingTitle: {
18
+ type: string;
19
+ additionalProperties: string;
20
+ required: string[];
21
+ properties: {
22
+ name: string;
23
+ type: string;
24
+ }[];
25
+ };
17
26
  overtitle: {
18
27
  type: string;
19
28
  contentType: string;
@@ -21,13 +21,7 @@ const ReportsBlock = ({ title, typeKey, empty }) => {
21
21
  const filteredItems = (0, react_1.useMemo)(() => {
22
22
  const f = Object.entries(localFilters).filter(([_, value]) => value !== 'all');
23
23
  return f.length
24
- ? items.filter((item) => f.reduce((acc, [key, value]) => {
25
- var _a, _b;
26
- if ((_b = (_a = item.filters) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.includes(value)) {
27
- return true;
28
- }
29
- return acc;
30
- }, false))
24
+ ? items.filter((item) => f.every(([key, value]) => { var _a, _b; return (_b = (_a = item.filters) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.includes(value); }))
31
25
  : items;
32
26
  }, [items, localFilters]);
33
27
  const paginatedItems = (0, react_1.useMemo)(() => {
@@ -158,8 +158,13 @@ export interface HeaderStockSharesProps {
158
158
  }[];
159
159
  description?: string;
160
160
  }
161
+ export interface SwitchingTitleProps {
162
+ text: string;
163
+ switchingTime?: number;
164
+ }
161
165
  export interface HeaderBlockProps {
162
166
  title: string;
167
+ switchingTitle?: SwitchingTitleProps;
163
168
  topTags?: HeaderTag[];
164
169
  bottomTags?: HeaderTag[];
165
170
  overtitle?: string;
@@ -93,6 +93,9 @@ unpredictable css rules order in build */
93
93
  --pc-text-header-color: var(--g-color-text-link-hover);
94
94
  color: var(--g-color-text-link-hover);
95
95
  }
96
+ .pc-header-block__title_pre-wrap {
97
+ white-space: pre-wrap;
98
+ }
96
99
  .pc-header-block__description {
97
100
  margin-top: 16px;
98
101
  }
@@ -13,6 +13,7 @@ import Breadcrumbs from './Breadcrumbs/Breadcrumbs';
13
13
  import HeaderStock from './HeaderStock/HeaderStock';
14
14
  import HeaderTag from './HeaderTag/HeaderTag';
15
15
  import HeaderTags from './HeaderTags/HeaderTags';
16
+ import SwitchingTitle from './SwitchingTitle/SwitchingTtitle';
16
17
  import { getImageSize, getTitleSizes, titleWithImageSizes } from './utils';
17
18
  import './Header.css';
18
19
  const b = block('header-block');
@@ -25,7 +26,7 @@ const Background = ({ background, isMobile }) => {
25
26
  const FullWidthBackground = ({ background }) => (React.createElement("div", { className: b('background', { ['full-width']: true }), style: { backgroundColor: background === null || background === void 0 ? void 0 : background.color } }));
26
27
  // eslint-disable-next-line complexity
27
28
  export const HeaderBlock = (props) => {
28
- const { title, topTags, bottomTags, overtitle, description, buttons, stock, stockPrice, stockShares, image, video, width = 's', imageSize, offset = 'default', background, theme: textTheme = 'light', verticalOffset = 'm', className, breadcrumbs, status, renderTitle, children, mediaView = 'full', } = props;
29
+ const { title, switchingTitle, topTags, bottomTags, overtitle, description, buttons, stock, stockPrice, stockShares, image, video, width = 's', imageSize, offset = 'default', background, theme: textTheme = 'light', verticalOffset = 'm', className, breadcrumbs, status, renderTitle, children, mediaView = 'full', } = props;
29
30
  const isMobile = useContext(MobileContext);
30
31
  const { backButton, blockTag } = useContext(HeaderContext);
31
32
  const theme = useTheme();
@@ -65,10 +66,12 @@ export const HeaderBlock = (props) => {
65
66
  React.createElement("div", null,
66
67
  overtitle && (React.createElement("div", { className: b('overtitle') },
67
68
  React.createElement(HTML, null, overtitle))),
68
- React.createElement("h1", { className: b('title'), id: titleId },
69
+ React.createElement("h1", { className: b('title', {
70
+ 'pre-wrap': Boolean(switchingTitle),
71
+ }), id: titleId },
69
72
  React.createElement(HeaderTag, { tag: blockTag }),
70
73
  status,
71
- renderTitle ? (renderTitle(title)) : (React.createElement(HTML, null, title))),
74
+ switchingTitle ? (React.createElement(SwitchingTitle, Object.assign({}, switchingTitle))) : (React.createElement(React.Fragment, null, renderTitle ? (renderTitle(title)) : (React.createElement(HTML, null, title))))),
72
75
  description && (React.createElement("div", { className: b('description', { theme: textTheme }) },
73
76
  React.createElement(YFMWrapper, { content: description, modifiers: {
74
77
  constructor: true,
@@ -0,0 +1,5 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-switching-title__title-part {
4
+ transition: opacity ease-in-out 0.2s;
5
+ }
@@ -0,0 +1,4 @@
1
+ import { SwitchingTitleProps } from '../../../models';
2
+ import './SwitchingTitle.css';
3
+ declare const SwitchingTitle: (props: SwitchingTitleProps) => JSX.Element;
4
+ export default SwitchingTitle;
@@ -0,0 +1,26 @@
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import { block } from '../../../utils';
3
+ import { partitionSwitchingTitleInput } from '../utils';
4
+ import './SwitchingTitle.css';
5
+ const b = block('switching-title');
6
+ const SwitchingTitle = (props) => {
7
+ const { text, switchingTime } = props;
8
+ const [currentIndex, setCurrentIndex] = useState(0);
9
+ const [opacity, setOpacity] = useState(1);
10
+ const texts = useMemo(() => partitionSwitchingTitleInput(text), [text]);
11
+ const textSizesCommonMultiple = useMemo(() => texts.reduce((acc, curr) => acc * curr.length, 1), [texts]);
12
+ useEffect(() => {
13
+ const intervalHandle = setInterval(() => {
14
+ setOpacity(0);
15
+ setTimeout(() => {
16
+ setCurrentIndex((c) => (c + 1) % textSizesCommonMultiple);
17
+ setOpacity(1);
18
+ }, 200);
19
+ }, switchingTime);
20
+ return () => clearInterval(intervalHandle);
21
+ }, [texts, switchingTime, textSizesCommonMultiple]);
22
+ return (React.createElement("span", null, texts.map((lines, index) => (React.createElement("span", { className: b('title-part'), style: {
23
+ opacity: lines.length > 1 ? opacity : 1,
24
+ }, key: index }, lines[currentIndex % lines.length])))));
25
+ };
26
+ export default SwitchingTitle;
@@ -320,6 +320,15 @@ export declare const HeaderProperties: {
320
320
  type: string;
321
321
  contentType: string;
322
322
  };
323
+ switchingTitle: {
324
+ type: string;
325
+ additionalProperties: string;
326
+ required: string[];
327
+ properties: {
328
+ name: string;
329
+ type: string;
330
+ }[];
331
+ };
323
332
  overtitle: {
324
333
  type: string;
325
334
  contentType: string;
@@ -980,6 +989,15 @@ export declare const HeaderBlock: {
980
989
  type: string;
981
990
  contentType: string;
982
991
  };
992
+ switchingTitle: {
993
+ type: string;
994
+ additionalProperties: string;
995
+ required: string[];
996
+ properties: {
997
+ name: string;
998
+ type: string;
999
+ }[];
1000
+ };
983
1001
  overtitle: {
984
1002
  type: string;
985
1003
  contentType: string;
@@ -13,6 +13,21 @@ export const HeaderProperties = {
13
13
  type: 'string',
14
14
  contentType: 'text',
15
15
  },
16
+ switchingTitle: {
17
+ type: 'object',
18
+ additionalProperties: 'false',
19
+ required: ['text'],
20
+ properties: [
21
+ {
22
+ name: 'text',
23
+ type: 'string',
24
+ },
25
+ {
26
+ name: 'switchingTime',
27
+ type: 'number',
28
+ },
29
+ ],
30
+ },
16
31
  overtitle: {
17
32
  type: 'string',
18
33
  contentType: 'text',
@@ -18,3 +18,4 @@ export declare function getTitleSizes(width: HeaderWidth): {
18
18
  md?: undefined;
19
19
  };
20
20
  export declare function getImageSize(width: HeaderWidth): "s" | "m";
21
+ export declare const partitionSwitchingTitleInput: (str: string) => string[][];
@@ -43,3 +43,16 @@ export function getImageSize(width) {
43
43
  return 'm';
44
44
  }
45
45
  }
46
+ export const partitionSwitchingTitleInput = (str) => {
47
+ if (str.length === 0)
48
+ return [['']];
49
+ const fixedRegExp = new RegExp('\\[.*', 's');
50
+ const fixedPart = str.replace(fixedRegExp, '');
51
+ if (fixedPart === str)
52
+ return [[fixedPart]];
53
+ const switchingPartRegExp = new RegExp('\\][^/].*', 's');
54
+ const switchingPart = str.slice(fixedPart.length + 1).replace(switchingPartRegExp, '');
55
+ const switchingPartArr = switchingPart.replace(/[[\]]/g, '').split('/');
56
+ const rest = str.slice(fixedPart.length + switchingPart.length + 2);
57
+ return [[fixedPart], switchingPartArr, ...partitionSwitchingTitleInput(rest)].filter((arr) => arr.length !== 0 && (arr.length !== 1 || arr[0] !== ''));
58
+ };
@@ -14,6 +14,15 @@ export declare const HeaderSliderBlock: {
14
14
  type: string;
15
15
  contentType: string;
16
16
  };
17
+ switchingTitle: {
18
+ type: string;
19
+ additionalProperties: string;
20
+ required: string[];
21
+ properties: {
22
+ name: string;
23
+ type: string;
24
+ }[];
25
+ };
17
26
  overtitle: {
18
27
  type: string;
19
28
  contentType: string;
@@ -18,13 +18,7 @@ export const ReportsBlock = ({ title, typeKey, empty }) => {
18
18
  const filteredItems = useMemo(() => {
19
19
  const f = Object.entries(localFilters).filter(([_, value]) => value !== 'all');
20
20
  return f.length
21
- ? items.filter((item) => f.reduce((acc, [key, value]) => {
22
- var _a, _b;
23
- if ((_b = (_a = item.filters) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.includes(value)) {
24
- return true;
25
- }
26
- return acc;
27
- }, false))
21
+ ? items.filter((item) => f.every(([key, value]) => { var _a, _b; return (_b = (_a = item.filters) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b.includes(value); }))
28
22
  : items;
29
23
  }, [items, localFilters]);
30
24
  const paginatedItems = useMemo(() => {
@@ -158,8 +158,13 @@ export interface HeaderStockSharesProps {
158
158
  }[];
159
159
  description?: string;
160
160
  }
161
+ export interface SwitchingTitleProps {
162
+ text: string;
163
+ switchingTime?: number;
164
+ }
161
165
  export interface HeaderBlockProps {
162
166
  title: string;
167
+ switchingTitle?: SwitchingTitleProps;
163
168
  topTags?: HeaderTag[];
164
169
  bottomTags?: HeaderTag[];
165
170
  overtitle?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor",
3
- "version": "5.31.64",
3
+ "version": "5.31.66",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {