@doyourjob/gravity-ui-page-constructor 5.31.54 → 5.31.56

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.
@@ -5,14 +5,25 @@ unpredictable css rules order in build */
5
5
  column-gap: 28px;
6
6
  align-items: center;
7
7
  justify-content: center;
8
+ padding: 0 20px;
9
+ border: 1px solid transparent;
10
+ }
11
+ .pc-highlight-table-block__legend_left {
12
+ justify-content: flex-start;
13
+ }
14
+ .pc-highlight-table-block__legend_right {
15
+ justify-content: flex-end;
16
+ }
17
+ .pc-highlight-table-block__legend_position-top {
8
18
  margin-top: 16px;
9
19
  margin-bottom: 12px;
10
20
  }
21
+ .pc-highlight-table-block__legend_position-bottom {
22
+ margin-top: 12px;
23
+ }
11
24
  .pc-highlight-table-block__legend-item {
12
25
  display: flex;
13
26
  align-items: center;
14
- font-size: 15px;
15
- line-height: 20px;
16
27
  }
17
28
  .pc-highlight-table-block__legend-item img {
18
29
  display: inline-block;
@@ -1,3 +1,3 @@
1
1
  import { HighlightTableBlockProps } from '../../models';
2
- export declare const HighlightTableBlock: (props: HighlightTableBlockProps) => JSX.Element;
2
+ export declare const HighlightTableBlock: ({ title, description, table, legend, contentSize, legendPosition, legendAlign, }: HighlightTableBlockProps) => JSX.Element;
3
3
  export default HighlightTableBlock;
@@ -3,12 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HighlightTableBlock = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
+ const uikit_1 = require("@gravity-ui/uikit");
6
7
  const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
7
8
  const components_1 = require("../../components");
8
9
  const utils_1 = require("../../utils");
9
10
  const b = (0, utils_1.block)('highlight-table-block');
10
- const HighlightTableBlock = (props) => {
11
- const { title, description, table, legend } = props;
11
+ const getTextStyles = (contentSize) => {
12
+ switch (contentSize) {
13
+ case 'l':
14
+ return 'body-2';
15
+ default:
16
+ return 'body-1';
17
+ }
18
+ };
19
+ const HighlightTableBlock = ({ title, description, table, legend, contentSize = 's', legendPosition = 'top', legendAlign = 'center', }) => {
12
20
  const firstRow = table.content[0] || [];
13
21
  const otherRows = table.content.slice(1);
14
22
  const customColumnWidth = table.customColumnWidth || [];
@@ -22,6 +30,7 @@ const HighlightTableBlock = (props) => {
22
30
  const tableContentRef = (0, react_1.useRef)(null);
23
31
  const scrollBarRef = (0, react_1.useRef)(null);
24
32
  const scrollThumbRef = (0, react_1.useRef)(null);
33
+ const textStyles = (0, uikit_1.text)({ variant: getTextStyles(contentSize) });
25
34
  (0, react_1.useEffect)(() => {
26
35
  const blockElem = blockRef.current;
27
36
  const tableContentElem = tableContentRef.current;
@@ -68,15 +77,22 @@ const HighlightTableBlock = (props) => {
68
77
  react_1.default.createElement(components_1.HTML, null, cell)));
69
78
  })));
70
79
  }, [table.customColumnWidth, table.highlighter, table.justify]);
80
+ const renderLegend = (0, react_1.useMemo)(() => (legend === null || legend === void 0 ? void 0 : legend.length) && (react_1.default.createElement("div", { className: `${b('legend', {
81
+ left: legendAlign === 'left',
82
+ right: legendAlign === 'right',
83
+ 'position-top': legendPosition === 'top',
84
+ 'position-bottom': legendPosition === 'bottom',
85
+ })} ${textStyles}` }, legend.map((item, index) => (react_1.default.createElement(components_1.HTML, { className: b('legend-item'), block: true, key: String(index) }, item))))), [legend, legendAlign, legendPosition, textStyles]);
71
86
  return (react_1.default.createElement("div", { ref: blockRef, className: b() },
72
87
  (title || description) && react_1.default.createElement(components_1.Title, { title: title, subtitle: description }),
73
- (legend === null || legend === void 0 ? void 0 : legend.length) && (react_1.default.createElement("div", { className: b('legend') }, legend.map((item, index) => (react_1.default.createElement(components_1.HTML, { className: b('legend-item'), block: true, key: String(index) }, item))))),
74
- react_1.default.createElement("div", { ref: tableRef, className: b('table') },
88
+ legendPosition === 'top' && renderLegend,
89
+ react_1.default.createElement("div", { ref: tableRef, className: `${b('table')} ${textStyles}` },
75
90
  react_1.default.createElement("div", { ref: tableContentRef, className: b('content') },
76
91
  react_1.default.createElement("div", { className: b('head') }, renderRow(firstRow, 0)),
77
92
  react_1.default.createElement("div", { className: b('body') }, otherRows.map(renderRow)))),
78
93
  react_1.default.createElement("div", { ref: scrollBarRef, className: b('scrollbar') },
79
- react_1.default.createElement("div", { ref: scrollThumbRef }))));
94
+ react_1.default.createElement("div", { ref: scrollThumbRef })),
95
+ legendPosition === 'bottom' && renderLegend));
80
96
  };
81
97
  exports.HighlightTableBlock = HighlightTableBlock;
82
98
  exports.default = exports.HighlightTableBlock;
@@ -15,6 +15,18 @@ export declare const HighlightTableBlock: {
15
15
  type: string;
16
16
  };
17
17
  };
18
+ legendPosition: {
19
+ type: string;
20
+ enum: string[];
21
+ };
22
+ legendAlign: {
23
+ type: string;
24
+ enum: string[];
25
+ };
26
+ contentSize: {
27
+ type: string;
28
+ enum: string[];
29
+ };
18
30
  table: {
19
31
  additionalProperties: boolean;
20
32
  required: string[];
@@ -15,6 +15,15 @@ exports.HighlightTableBlock = {
15
15
  items: {
16
16
  type: 'string',
17
17
  },
18
+ }, legendPosition: {
19
+ type: 'string',
20
+ enum: ['top', 'bottom'],
21
+ }, legendAlign: {
22
+ type: 'string',
23
+ enum: ['left', 'center', 'right'],
24
+ }, contentSize: {
25
+ type: 'string',
26
+ enum: common_1.contentSizes,
18
27
  }, table: {
19
28
  additionalProperties: false,
20
29
  required: ['content'],
@@ -24,7 +24,7 @@ export declare const blockMap: {
24
24
  "blog-feed-block": ({ image, title }: import("./models").BlogFeedBlockProps) => JSX.Element;
25
25
  "relevant-posts-block": ({ title, description, slider, date, dateStart, dateEnd, tags, services, pinnedPost, }: import("./models").RelevantPostsBlockProps) => JSX.Element;
26
26
  "press-releases-block": ({ title }: import("./models").PressReleasesBlockProps) => JSX.Element;
27
- "highlight-table-block": (props: import("./models").HighlightTableBlockProps) => JSX.Element;
27
+ "highlight-table-block": ({ title, description, table, legend, contentSize, legendPosition, legendAlign, }: import("./models").HighlightTableBlockProps) => JSX.Element;
28
28
  "link-table-block": ({ title, items }: import("./models").LinkTableBlockProps) => JSX.Element;
29
29
  "services-block": ({ title, serviceLinkType }: import("./models").ServicesBlockProps) => JSX.Element;
30
30
  "quotes-block": ({ theme: localTheme, items, background, backgroundColor, }: import("./models").QuotesBlockProps) => JSX.Element;
@@ -303,6 +303,9 @@ export interface HighlightTableBlockProps {
303
303
  description?: string;
304
304
  table: HighlightTableData;
305
305
  legend?: string[];
306
+ legendPosition?: 'top' | 'bottom';
307
+ legendAlign?: 'left' | 'center' | 'right';
308
+ contentSize?: ContentSize;
306
309
  }
307
310
  export interface TabsBlockItem extends Omit<ContentBlockProps, 'size' | 'colSizes' | 'centered' | 'theme'>, WithBorder {
308
311
  tabName: string;
@@ -5,14 +5,25 @@ unpredictable css rules order in build */
5
5
  column-gap: 28px;
6
6
  align-items: center;
7
7
  justify-content: center;
8
+ padding: 0 20px;
9
+ border: 1px solid transparent;
10
+ }
11
+ .pc-highlight-table-block__legend_left {
12
+ justify-content: flex-start;
13
+ }
14
+ .pc-highlight-table-block__legend_right {
15
+ justify-content: flex-end;
16
+ }
17
+ .pc-highlight-table-block__legend_position-top {
8
18
  margin-top: 16px;
9
19
  margin-bottom: 12px;
10
20
  }
21
+ .pc-highlight-table-block__legend_position-bottom {
22
+ margin-top: 12px;
23
+ }
11
24
  .pc-highlight-table-block__legend-item {
12
25
  display: flex;
13
26
  align-items: center;
14
- font-size: 15px;
15
- line-height: 20px;
16
27
  }
17
28
  .pc-highlight-table-block__legend-item img {
18
29
  display: inline-block;
@@ -1,4 +1,4 @@
1
1
  import { HighlightTableBlockProps } from '../../models';
2
2
  import './HighlightTable.css';
3
- export declare const HighlightTableBlock: (props: HighlightTableBlockProps) => JSX.Element;
3
+ export declare const HighlightTableBlock: ({ title, description, table, legend, contentSize, legendPosition, legendAlign, }: HighlightTableBlockProps) => JSX.Element;
4
4
  export default HighlightTableBlock;
@@ -1,11 +1,19 @@
1
- import React, { useCallback, useEffect, useRef } from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
2
+ import { text } from '@gravity-ui/uikit';
2
3
  import debounce from 'lodash/debounce';
3
4
  import { HTML, Title } from '../../components';
4
5
  import { block } from '../../utils';
5
6
  import './HighlightTable.css';
6
7
  const b = block('highlight-table-block');
7
- export const HighlightTableBlock = (props) => {
8
- const { title, description, table, legend } = props;
8
+ const getTextStyles = (contentSize) => {
9
+ switch (contentSize) {
10
+ case 'l':
11
+ return 'body-2';
12
+ default:
13
+ return 'body-1';
14
+ }
15
+ };
16
+ export const HighlightTableBlock = ({ title, description, table, legend, contentSize = 's', legendPosition = 'top', legendAlign = 'center', }) => {
9
17
  const firstRow = table.content[0] || [];
10
18
  const otherRows = table.content.slice(1);
11
19
  const customColumnWidth = table.customColumnWidth || [];
@@ -19,6 +27,7 @@ export const HighlightTableBlock = (props) => {
19
27
  const tableContentRef = useRef(null);
20
28
  const scrollBarRef = useRef(null);
21
29
  const scrollThumbRef = useRef(null);
30
+ const textStyles = text({ variant: getTextStyles(contentSize) });
22
31
  useEffect(() => {
23
32
  const blockElem = blockRef.current;
24
33
  const tableContentElem = tableContentRef.current;
@@ -65,14 +74,21 @@ export const HighlightTableBlock = (props) => {
65
74
  React.createElement(HTML, null, cell)));
66
75
  })));
67
76
  }, [table.customColumnWidth, table.highlighter, table.justify]);
77
+ const renderLegend = useMemo(() => (legend === null || legend === void 0 ? void 0 : legend.length) && (React.createElement("div", { className: `${b('legend', {
78
+ left: legendAlign === 'left',
79
+ right: legendAlign === 'right',
80
+ 'position-top': legendPosition === 'top',
81
+ 'position-bottom': legendPosition === 'bottom',
82
+ })} ${textStyles}` }, legend.map((item, index) => (React.createElement(HTML, { className: b('legend-item'), block: true, key: String(index) }, item))))), [legend, legendAlign, legendPosition, textStyles]);
68
83
  return (React.createElement("div", { ref: blockRef, className: b() },
69
84
  (title || description) && React.createElement(Title, { title: title, subtitle: description }),
70
- (legend === null || legend === void 0 ? void 0 : legend.length) && (React.createElement("div", { className: b('legend') }, legend.map((item, index) => (React.createElement(HTML, { className: b('legend-item'), block: true, key: String(index) }, item))))),
71
- React.createElement("div", { ref: tableRef, className: b('table') },
85
+ legendPosition === 'top' && renderLegend,
86
+ React.createElement("div", { ref: tableRef, className: `${b('table')} ${textStyles}` },
72
87
  React.createElement("div", { ref: tableContentRef, className: b('content') },
73
88
  React.createElement("div", { className: b('head') }, renderRow(firstRow, 0)),
74
89
  React.createElement("div", { className: b('body') }, otherRows.map(renderRow)))),
75
90
  React.createElement("div", { ref: scrollBarRef, className: b('scrollbar') },
76
- React.createElement("div", { ref: scrollThumbRef }))));
91
+ React.createElement("div", { ref: scrollThumbRef })),
92
+ legendPosition === 'bottom' && renderLegend));
77
93
  };
78
94
  export default HighlightTableBlock;
@@ -15,6 +15,18 @@ export declare const HighlightTableBlock: {
15
15
  type: string;
16
16
  };
17
17
  };
18
+ legendPosition: {
19
+ type: string;
20
+ enum: string[];
21
+ };
22
+ legendAlign: {
23
+ type: string;
24
+ enum: string[];
25
+ };
26
+ contentSize: {
27
+ type: string;
28
+ enum: string[];
29
+ };
18
30
  table: {
19
31
  additionalProperties: boolean;
20
32
  required: string[];
@@ -1,4 +1,4 @@
1
- import { BaseProps, BlockBaseProps } from '../../schema/validators/common';
1
+ import { BaseProps, BlockBaseProps, contentSizes } from '../../schema/validators/common';
2
2
  export const HighlightTableBlock = {
3
3
  'highlight-table-block': {
4
4
  additionalProperties: false,
@@ -12,6 +12,15 @@ export const HighlightTableBlock = {
12
12
  items: {
13
13
  type: 'string',
14
14
  },
15
+ }, legendPosition: {
16
+ type: 'string',
17
+ enum: ['top', 'bottom'],
18
+ }, legendAlign: {
19
+ type: 'string',
20
+ enum: ['left', 'center', 'right'],
21
+ }, contentSize: {
22
+ type: 'string',
23
+ enum: contentSizes,
15
24
  }, table: {
16
25
  additionalProperties: false,
17
26
  required: ['content'],
@@ -24,7 +24,7 @@ export declare const blockMap: {
24
24
  "blog-feed-block": ({ image, title }: import("./models").BlogFeedBlockProps) => JSX.Element;
25
25
  "relevant-posts-block": ({ title, description, slider, date, dateStart, dateEnd, tags, services, pinnedPost, }: import("./models").RelevantPostsBlockProps) => JSX.Element;
26
26
  "press-releases-block": ({ title }: import("./models").PressReleasesBlockProps) => JSX.Element;
27
- "highlight-table-block": (props: import("./models").HighlightTableBlockProps) => JSX.Element;
27
+ "highlight-table-block": ({ title, description, table, legend, contentSize, legendPosition, legendAlign, }: import("./models").HighlightTableBlockProps) => JSX.Element;
28
28
  "link-table-block": ({ title, items }: import("./models").LinkTableBlockProps) => JSX.Element;
29
29
  "services-block": ({ title, serviceLinkType }: import("./models").ServicesBlockProps) => JSX.Element;
30
30
  "quotes-block": ({ theme: localTheme, items, background, backgroundColor, }: import("./models").QuotesBlockProps) => JSX.Element;
@@ -303,6 +303,9 @@ export interface HighlightTableBlockProps {
303
303
  description?: string;
304
304
  table: HighlightTableData;
305
305
  legend?: string[];
306
+ legendPosition?: 'top' | 'bottom';
307
+ legendAlign?: 'left' | 'center' | 'right';
308
+ contentSize?: ContentSize;
306
309
  }
307
310
  export interface TabsBlockItem extends Omit<ContentBlockProps, 'size' | 'colSizes' | 'centered' | 'theme'>, WithBorder {
308
311
  tabName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor",
3
- "version": "5.31.54",
3
+ "version": "5.31.56",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {