@gravity-ui/page-constructor 1.20.5 → 1.22.0-alpha.0

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 (95) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/cjs/blocks/CardLayout/CardLayout.d.ts +3 -5
  3. package/build/cjs/blocks/CardLayout/CardLayout.js +2 -6
  4. package/build/cjs/blocks/FilterBlock/FilterBlock.css +50 -0
  5. package/build/cjs/blocks/FilterBlock/FilterBlock.d.ts +4 -0
  6. package/build/cjs/blocks/FilterBlock/FilterBlock.js +48 -0
  7. package/build/cjs/blocks/FilterBlock/i18n/en.json +3 -0
  8. package/build/cjs/blocks/FilterBlock/i18n/index.d.ts +2 -0
  9. package/build/cjs/blocks/FilterBlock/i18n/index.js +8 -0
  10. package/build/cjs/blocks/FilterBlock/i18n/ru.json +3 -0
  11. package/build/cjs/blocks/FilterBlock/schema.d.ts +229 -0
  12. package/build/cjs/blocks/FilterBlock/schema.js +41 -0
  13. package/build/cjs/blocks/Tabs/Tabs.css +27 -18
  14. package/build/cjs/blocks/index.d.ts +1 -0
  15. package/build/cjs/blocks/index.js +3 -1
  16. package/build/cjs/components/Button/Button.css +4 -0
  17. package/build/cjs/components/ButtonTabs/ButtonTabs.css +16 -3
  18. package/build/cjs/components/ButtonTabs/ButtonTabs.d.ts +7 -4
  19. package/build/cjs/components/ButtonTabs/ButtonTabs.js +2 -6
  20. package/build/cjs/components/Title/Title.css +8 -2
  21. package/build/cjs/components/Title/Title.d.ts +1 -1
  22. package/build/cjs/components/Title/Title.js +4 -2
  23. package/build/cjs/constructor-items.d.ts +2 -1
  24. package/build/cjs/constructor-items.js +1 -0
  25. package/build/cjs/containers/PageConstructor/PageConstructor.css +8 -0
  26. package/build/cjs/containers/PageConstructor/PageConstructor.js +13 -14
  27. package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts +3 -5
  28. package/build/cjs/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +3 -3
  29. package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.d.ts +3 -3
  30. package/build/cjs/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +4 -4
  31. package/build/cjs/context/innerContext/InnerContext.d.ts +4 -1
  32. package/build/cjs/context/innerContext/InnerContext.js +2 -0
  33. package/build/cjs/models/constructor-items/blocks.d.ts +26 -3
  34. package/build/cjs/models/constructor-items/blocks.js +1 -0
  35. package/build/cjs/models/constructor-items/common.d.ts +1 -1
  36. package/build/cjs/models/navigation.d.ts +21 -1
  37. package/build/cjs/models/navigation.js +15 -1
  38. package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +2 -0
  39. package/build/cjs/navigation/components/NavigationItem/components/GithubButton/GithubButton.css +14 -0
  40. package/build/cjs/navigation/components/NavigationItem/components/GithubButton/GithubButton.d.ts +5 -0
  41. package/build/cjs/navigation/components/NavigationItem/components/GithubButton/GithubButton.js +47 -0
  42. package/build/cjs/utils/blocks.d.ts +2 -1
  43. package/build/cjs/utils/blocks.js +8 -1
  44. package/build/esm/blocks/CardLayout/CardLayout.d.ts +3 -5
  45. package/build/esm/blocks/CardLayout/CardLayout.js +3 -7
  46. package/build/esm/blocks/FilterBlock/FilterBlock.css +50 -0
  47. package/build/esm/blocks/FilterBlock/FilterBlock.d.ts +5 -0
  48. package/build/esm/blocks/FilterBlock/FilterBlock.js +46 -0
  49. package/build/esm/blocks/FilterBlock/i18n/en.json +3 -0
  50. package/build/esm/blocks/FilterBlock/i18n/index.d.ts +2 -0
  51. package/build/esm/blocks/FilterBlock/i18n/index.js +5 -0
  52. package/build/esm/blocks/FilterBlock/i18n/ru.json +3 -0
  53. package/build/esm/blocks/FilterBlock/schema.d.ts +229 -0
  54. package/build/esm/blocks/FilterBlock/schema.js +38 -0
  55. package/build/esm/blocks/Tabs/Tabs.css +27 -18
  56. package/build/esm/blocks/index.d.ts +1 -0
  57. package/build/esm/blocks/index.js +1 -0
  58. package/build/esm/components/Button/Button.css +4 -0
  59. package/build/esm/components/ButtonTabs/ButtonTabs.css +16 -3
  60. package/build/esm/components/ButtonTabs/ButtonTabs.d.ts +7 -4
  61. package/build/esm/components/ButtonTabs/ButtonTabs.js +2 -6
  62. package/build/esm/components/Title/Title.css +8 -2
  63. package/build/esm/components/Title/Title.d.ts +1 -1
  64. package/build/esm/components/Title/Title.js +4 -2
  65. package/build/esm/constructor-items.d.ts +2 -1
  66. package/build/esm/constructor-items.js +2 -1
  67. package/build/esm/containers/PageConstructor/PageConstructor.css +8 -0
  68. package/build/esm/containers/PageConstructor/PageConstructor.js +15 -16
  69. package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.d.ts +3 -5
  70. package/build/esm/containers/PageConstructor/components/ConstructorBlock/ConstructorBlock.js +3 -3
  71. package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.d.ts +3 -3
  72. package/build/esm/containers/PageConstructor/components/ConstructorBlocks/ConstructorBlocks.js +4 -4
  73. package/build/esm/context/innerContext/InnerContext.d.ts +4 -1
  74. package/build/esm/context/innerContext/InnerContext.js +2 -0
  75. package/build/esm/models/constructor-items/blocks.d.ts +26 -3
  76. package/build/esm/models/constructor-items/blocks.js +1 -0
  77. package/build/esm/models/constructor-items/common.d.ts +1 -1
  78. package/build/esm/models/navigation.d.ts +21 -1
  79. package/build/esm/models/navigation.js +14 -0
  80. package/build/esm/navigation/components/NavigationItem/NavigationItem.js +2 -0
  81. package/build/esm/navigation/components/NavigationItem/components/GithubButton/GithubButton.css +14 -0
  82. package/build/esm/navigation/components/NavigationItem/components/GithubButton/GithubButton.d.ts +6 -0
  83. package/build/esm/navigation/components/NavigationItem/components/GithubButton/GithubButton.js +43 -0
  84. package/build/esm/utils/blocks.d.ts +2 -1
  85. package/build/esm/utils/blocks.js +6 -0
  86. package/package.json +5 -1
  87. package/server/models/constructor-items/blocks.d.ts +26 -3
  88. package/server/models/constructor-items/blocks.js +1 -0
  89. package/server/models/constructor-items/common.d.ts +1 -1
  90. package/server/models/navigation.d.ts +21 -1
  91. package/server/models/navigation.js +15 -1
  92. package/server/utils/blocks.d.ts +2 -1
  93. package/server/utils/blocks.js +8 -1
  94. package/styles/mixins.scss +71 -12
  95. package/styles/root.scss +10 -0
@@ -5,13 +5,12 @@ import { InnerContext } from '../../../../context/innerContext';
5
5
  import { ConstructorLoadable } from '../ConstructorLoadable';
6
6
  import { ConstructorItem } from '../ConstructorItem';
7
7
  import { ConstructorBlock } from '../ConstructorBlock/ConstructorBlock';
8
- export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
9
- const { blockTypes, loadables, itemMap } = useContext(InnerContext);
8
+ export const ConstructorBlocks = ({ items }) => {
9
+ const { blockTypes, loadables, itemMap, shouldRenderBlock } = useContext(InnerContext);
10
10
  const renderer = (parentId = '', item, index) => {
11
11
  if (!itemMap[item.type]) {
12
12
  return null;
13
13
  }
14
- let children;
15
14
  let itemElement;
16
15
  const key = getBlockKey(item, index);
17
16
  const blockId = parentId ? `${parentId}_${key}` : key;
@@ -27,12 +26,13 @@ export const ConstructorBlocks = ({ items, shouldRenderBlock }) => {
27
26
  itemElement = (React.createElement(ConstructorLoadable, { block: item, key: blockId, blockKey: blockId, config: config, serviceId: serviceId, params: params }));
28
27
  }
29
28
  else {
29
+ let children;
30
30
  if ('children' in item && item.children) {
31
31
  children = item.children.map(renderer.bind(null, blockId));
32
32
  }
33
33
  itemElement = (React.createElement(ConstructorItem, { data: item, key: blockId, blockKey: blockId }, children));
34
34
  }
35
- return blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item, key: blockId, Component: itemElement })) : (itemElement);
35
+ return blockTypes.includes(item.type) ? (React.createElement(ConstructorBlock, { data: item, key: blockId }, itemElement)) : (itemElement);
36
36
  };
37
37
  return React.createElement(Fragment, null, items.map(renderer.bind(null, '')));
38
38
  };
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
2
  import { ItemMap } from '../../containers/PageConstructor/PageConstructor';
3
- import { LoadableConfig } from '../../models';
3
+ import { LoadableConfig, ShouldRenderBlock } from '../../models';
4
4
  export interface InnerContextType {
5
5
  blockTypes: string[];
6
+ subBlockTypes: string[];
7
+ headerBlockTypes: string[];
6
8
  itemMap: ItemMap;
7
9
  loadables?: LoadableConfig;
10
+ shouldRenderBlock?: ShouldRenderBlock;
8
11
  }
9
12
  export declare const InnerContext: React.Context<InnerContextType>;
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  export const InnerContext = React.createContext({
3
3
  blockTypes: [],
4
+ subBlockTypes: [],
5
+ headerBlockTypes: [],
4
6
  itemMap: {},
5
7
  });
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
+ import { ButtonSize } from '@gravity-ui/uikit';
2
3
  import { BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, Justify, LinkProps, LinkTheme, MediaDirection, MediaProps, MapProps, PreviewItemProps, PreviewRatioMediaContent, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleProps, LegendTableMarkerType, AnchorProps, TitleBaseProps, Animatable, BlockHeaderProps, ImageDeviceProps } from './common';
3
4
  import { ThemeSupporting } from '../../utils';
4
5
  import { GridColumnSize, GridColumnSizesType } from '../../grid/types';
5
- import { BannerCardProps, SubBlock } from './sub-blocks';
6
+ import { BannerCardProps, SubBlock, SubBlockModels } from './sub-blocks';
6
7
  export declare enum BlockType {
7
8
  PromoFeaturesBlock = "promo-features-block",
8
9
  ExtendedFeaturesBlock = "extended-features-block",
@@ -26,7 +27,8 @@ export declare enum BlockType {
26
27
  CardLayoutBlock = "card-layout-block",
27
28
  ContentLayoutBlock = "content-layout-block",
28
29
  ShareBlock = "share-block",
29
- MapBlock = "map-block"
30
+ MapBlock = "map-block",
31
+ FilterBlock = "filter-block"
30
32
  }
31
33
  export declare const BlockTypes: BlockType[];
32
34
  export declare const HeaderBlockTypes: BlockType[];
@@ -251,6 +253,24 @@ export interface CardLayoutBlockProps extends Childable, Animatable, LoadableChi
251
253
  description?: string;
252
254
  colSizes?: GridColumnSizesType;
253
255
  }
256
+ export type FilterTag = {
257
+ id: string;
258
+ label: string;
259
+ };
260
+ export type FilterItem = {
261
+ tags: string[];
262
+ card: SubBlockModels;
263
+ };
264
+ export interface FilterBlockProps extends Animatable, LoadableChildren {
265
+ title?: TitleProps | string;
266
+ description?: string;
267
+ tags: FilterTag[];
268
+ items: FilterItem[];
269
+ tagButtonSize?: ButtonSize;
270
+ allTag?: boolean | string;
271
+ colSizes?: GridColumnSizesType;
272
+ centered?: boolean;
273
+ }
254
274
  export interface IconsBlockProps {
255
275
  title?: string;
256
276
  size?: 's' | 'm' | 'l';
@@ -350,6 +370,9 @@ export type LinkTableBlockModel = {
350
370
  export type CardLayoutBlockModel = {
351
371
  type: BlockType.CardLayoutBlock;
352
372
  } & CardLayoutBlockProps;
373
+ export type FilterBlockModel = {
374
+ type: BlockType.FilterBlock;
375
+ } & FilterBlockProps;
353
376
  export type IconsBlockModel = {
354
377
  type: BlockType.IconsBlock;
355
378
  } & IconsBlockProps;
@@ -362,6 +385,6 @@ export type ContentLayoutBlockModel = {
362
385
  export type ShareBLockModel = {
363
386
  type: BlockType.ShareBlock;
364
387
  } & ShareBlockProps;
365
- type BlockModels = SliderBlockModel | ServiceDemoBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | CalculatorBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | SecurityBlockModel | TableBlockModel | TabsBlockModel | SimpleBlockModel | LinkTableBlockModel | HeaderBlockModel | PreviewBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel;
388
+ type BlockModels = SliderBlockModel | ServiceDemoBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | CalculatorBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | SecurityBlockModel | TableBlockModel | TabsBlockModel | SimpleBlockModel | LinkTableBlockModel | HeaderBlockModel | PreviewBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel | FilterBlockModel;
366
389
  export type Block = BlockModels & BlockBaseProps;
367
390
  export {};
@@ -23,6 +23,7 @@ export var BlockType;
23
23
  BlockType["ContentLayoutBlock"] = "content-layout-block";
24
24
  BlockType["ShareBlock"] = "share-block";
25
25
  BlockType["MapBlock"] = "map-block";
26
+ BlockType["FilterBlock"] = "filter-block";
26
27
  })(BlockType || (BlockType = {}));
27
28
  export const BlockTypes = Object.values(BlockType);
28
29
  export const HeaderBlockTypes = [BlockType.HeaderBlock, BlockType.HeaderSliderBlock];
@@ -38,7 +38,7 @@ export declare enum MediaVideoControlsType {
38
38
  Custom = "custom"
39
39
  }
40
40
  export type TextTheme = 'light' | 'dark';
41
- export type TextSize = 's' | 'm' | 'l';
41
+ export type TextSize = 'xs' | 's' | 'm' | 'l';
42
42
  export type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';
43
43
  export type HeaderWidth = 's' | 'm' | 'l';
44
44
  export type HeaderImageSize = 's' | 'm';
@@ -4,13 +4,33 @@ export declare enum NavigationItemType {
4
4
  Link = "link",
5
5
  Dropdown = "dropdown",
6
6
  Button = "button",
7
- Social = "social"
7
+ Social = "social",
8
+ GithubButton = "github-button"
8
9
  }
9
10
  export interface NavigationItemBase {
10
11
  text: string;
11
12
  icon?: ImageProps;
12
13
  url?: string;
13
14
  }
15
+ export declare enum NavigationGithubButtonIcon {
16
+ heart = "octicon-heart",
17
+ eye = "octicon-eye",
18
+ star = "octicon-star",
19
+ fork = "octicon-repo-forked",
20
+ issue = "octicon-issue-opened",
21
+ comment = "octicon-comment-discussion",
22
+ download = "octicon-download",
23
+ package = "octicon-package",
24
+ template = "octicon-repo-template",
25
+ play = "octicon-play"
26
+ }
27
+ export interface NavigationGithubButton extends Omit<NavigationItemBase, 'icon'> {
28
+ type: NavigationItemType.GithubButton;
29
+ url: string;
30
+ label?: string;
31
+ icon?: keyof typeof NavigationGithubButtonIcon;
32
+ size?: string;
33
+ }
14
34
  export interface NavigationLinkItem extends Omit<NavigationItemBase, 'url'> {
15
35
  type: NavigationItemType.Link;
16
36
  url: string;
@@ -4,4 +4,18 @@ export var NavigationItemType;
4
4
  NavigationItemType["Dropdown"] = "dropdown";
5
5
  NavigationItemType["Button"] = "button";
6
6
  NavigationItemType["Social"] = "social";
7
+ NavigationItemType["GithubButton"] = "github-button";
7
8
  })(NavigationItemType || (NavigationItemType = {}));
9
+ export var NavigationGithubButtonIcon;
10
+ (function (NavigationGithubButtonIcon) {
11
+ NavigationGithubButtonIcon["heart"] = "octicon-heart";
12
+ NavigationGithubButtonIcon["eye"] = "octicon-eye";
13
+ NavigationGithubButtonIcon["star"] = "octicon-star";
14
+ NavigationGithubButtonIcon["fork"] = "octicon-repo-forked";
15
+ NavigationGithubButtonIcon["issue"] = "octicon-issue-opened";
16
+ NavigationGithubButtonIcon["comment"] = "octicon-comment-discussion";
17
+ NavigationGithubButtonIcon["download"] = "octicon-download";
18
+ NavigationGithubButtonIcon["package"] = "octicon-package";
19
+ NavigationGithubButtonIcon["template"] = "octicon-repo-template";
20
+ NavigationGithubButtonIcon["play"] = "octicon-play";
21
+ })(NavigationGithubButtonIcon || (NavigationGithubButtonIcon = {}));
@@ -6,6 +6,7 @@ import { BlockIdContext } from '../../../context/blockIdContext';
6
6
  import { NavigationButton } from './components/NavigationButton/NavigationButton';
7
7
  import { NavigationDropdown } from './components/NavigationDropdown/NavigationDropdown';
8
8
  import { NavigationLink } from './components/NavigationLink/NavigationLink';
9
+ import { GithubButton } from './components/GithubButton/GithubButton';
9
10
  const ANALYTICS_ID = 'navigation';
10
11
  //todo: add types support form component in map
11
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -14,6 +15,7 @@ const NavigationItemsMap = {
14
15
  [NavigationItemType.Social]: SocialIcon,
15
16
  [NavigationItemType.Dropdown]: NavigationDropdown,
16
17
  [NavigationItemType.Link]: NavigationLink,
18
+ [NavigationItemType.GithubButton]: GithubButton,
17
19
  };
18
20
  const NavigationItem = (_a) => {
19
21
  var { data, className } = _a, props = __rest(_a, ["data", "className"]);
@@ -0,0 +1,14 @@
1
+ .pc-github-button {
2
+ position: relative;
3
+ display: flex;
4
+ align-items: center;
5
+ white-space: nowrap;
6
+ display: flex;
7
+ align-items: center;
8
+ height: 100%;
9
+ }
10
+ .pc-github-button span {
11
+ display: flex;
12
+ flex-direction: column;
13
+ justify-content: center;
14
+ }
@@ -0,0 +1,6 @@
1
+ import { NavigationItemProps } from '../../NavigationItem';
2
+ import { NavigationGithubButton } from '../../../../../models';
3
+ import './GithubButton.css';
4
+ type NavigationGithubButtonProps = NavigationItemProps & NavigationGithubButton;
5
+ export declare const GithubButton: ({ text, url, className, label, size, icon, }: NavigationGithubButtonProps) => JSX.Element;
6
+ export {};
@@ -0,0 +1,43 @@
1
+ import React, { useRef, useEffect } from 'react';
2
+ import { block } from '../../../../../utils';
3
+ import { NavigationGithubButtonIcon } from '../../../../../models';
4
+ import './GithubButton.css';
5
+ const b = block('github-button');
6
+ const DEFAULT_LABEL = 'Stars on GitHub';
7
+ /* More information about github-buttons in https://buttons.github.io/ */
8
+ export const GithubButton = ({ text, url, className, label, size, icon, }) => {
9
+ const containerRef = useRef(null);
10
+ const linkRef = useRef(null);
11
+ useEffect(() => {
12
+ const paint = () => {
13
+ if (containerRef.current) {
14
+ const githubButton = containerRef.current.appendChild(document.createElement('span'));
15
+ import(/* webpackMode: "eager" */ 'github-buttons').then(({ render }) => {
16
+ if (linkRef.current !== null) {
17
+ render(githubButton.appendChild(linkRef.current), (el) => {
18
+ try {
19
+ if (githubButton.parentNode) {
20
+ githubButton.parentNode.replaceChild(el, githubButton);
21
+ }
22
+ }
23
+ catch (_) { }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ };
29
+ const reset = () => {
30
+ var _a;
31
+ if (((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.lastChild) && linkRef.current) {
32
+ containerRef.current.replaceChild(linkRef.current, containerRef.current.lastChild);
33
+ }
34
+ };
35
+ paint();
36
+ return () => {
37
+ reset();
38
+ };
39
+ }, []);
40
+ return (React.createElement("div", { className: b(null, className) },
41
+ React.createElement("span", { ref: containerRef },
42
+ React.createElement("a", Object.assign({ href: url, ref: linkRef, "data-show-count": "true", "aria-label": label || DEFAULT_LABEL }, (icon && { 'data-icon': NavigationGithubButtonIcon[icon] }), (size && { 'data-size': size })), text))));
43
+ };
@@ -1,10 +1,11 @@
1
1
  import { ConstructorBlock } from '../models/constructor';
2
2
  import { TextSize, CustomConfig, PCShareSocialNetwork } from '../models';
3
- export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4";
3
+ export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
4
4
  export declare function getBlockKey(block: ConstructorBlock, index: number): string;
5
5
  export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
6
6
  export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
7
7
  [x: string]: any;
8
8
  };
9
+ export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
9
10
  export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
10
11
  export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
@@ -5,6 +5,8 @@ export function getHeaderTag(size) {
5
5
  return 'h1';
6
6
  case 's':
7
7
  return 'h4';
8
+ case 'xs':
9
+ return 'h5';
8
10
  case 'm':
9
11
  default:
10
12
  return 'h2';
@@ -18,6 +20,10 @@ export const getCustomBlockTypes = ({ blocks = {}, headers = {} } = {}) => [
18
20
  ...Object.keys(headers),
19
21
  ];
20
22
  export const getCustomItems = ({ blocks = {}, headers = {}, subBlocks = {} } = {}) => (Object.assign(Object.assign(Object.assign({}, blocks), headers), subBlocks));
23
+ export const getCustomSubBlockTypes = (customBlocks = {}) => {
24
+ const { subBlocks = {} } = customBlocks;
25
+ return Object.keys(subBlocks);
26
+ };
21
27
  export const getCustomHeaderTypes = (customBlocks = {}) => {
22
28
  const { headers = {} } = customBlocks;
23
29
  return Object.keys(headers);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "1.20.5",
3
+ "version": "1.22.0-alpha.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -48,6 +48,7 @@
48
48
  "dependencies": {
49
49
  "@gravity-ui/i18n": "^1.0.0",
50
50
  "bem-cn-lite": "^4.0.0",
51
+ "github-buttons": "2.23.0",
51
52
  "lodash": "^4.17.21",
52
53
  "react-player": "^2.9.0",
53
54
  "react-slick": "^0.28.1",
@@ -135,5 +136,8 @@
135
136
  "*.{json,yaml,yml,md}": [
136
137
  "prettier --write"
137
138
  ]
139
+ },
140
+ "publishConfig": {
141
+ "tag": "alpha"
138
142
  }
139
143
  }
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
+ import { ButtonSize } from '@gravity-ui/uikit';
2
3
  import { BackgroundImageProps, ButtonProps, ContentSize, ContentTextSize, ContentTheme, FileLinkProps, HeaderBreadCrumbsProps, HeaderImageSize, HeaderOffset, HeaderWidth, Justify, LinkProps, LinkTheme, MediaDirection, MediaProps, MapProps, PreviewItemProps, PreviewRatioMediaContent, TextSize, TextTheme, ThemedImage, ThemedMediaProps, ThemedMediaVideoProps, TitleProps, LegendTableMarkerType, AnchorProps, TitleBaseProps, Animatable, BlockHeaderProps, ImageDeviceProps } from './common';
3
4
  import { ThemeSupporting } from '../../utils';
4
5
  import { GridColumnSize, GridColumnSizesType } from '../../grid/types';
5
- import { BannerCardProps, SubBlock } from './sub-blocks';
6
+ import { BannerCardProps, SubBlock, SubBlockModels } from './sub-blocks';
6
7
  export declare enum BlockType {
7
8
  PromoFeaturesBlock = "promo-features-block",
8
9
  ExtendedFeaturesBlock = "extended-features-block",
@@ -26,7 +27,8 @@ export declare enum BlockType {
26
27
  CardLayoutBlock = "card-layout-block",
27
28
  ContentLayoutBlock = "content-layout-block",
28
29
  ShareBlock = "share-block",
29
- MapBlock = "map-block"
30
+ MapBlock = "map-block",
31
+ FilterBlock = "filter-block"
30
32
  }
31
33
  export declare const BlockTypes: BlockType[];
32
34
  export declare const HeaderBlockTypes: BlockType[];
@@ -251,6 +253,24 @@ export interface CardLayoutBlockProps extends Childable, Animatable, LoadableChi
251
253
  description?: string;
252
254
  colSizes?: GridColumnSizesType;
253
255
  }
256
+ export type FilterTag = {
257
+ id: string;
258
+ label: string;
259
+ };
260
+ export type FilterItem = {
261
+ tags: string[];
262
+ card: SubBlockModels;
263
+ };
264
+ export interface FilterBlockProps extends Animatable, LoadableChildren {
265
+ title?: TitleProps | string;
266
+ description?: string;
267
+ tags: FilterTag[];
268
+ items: FilterItem[];
269
+ tagButtonSize?: ButtonSize;
270
+ allTag?: boolean | string;
271
+ colSizes?: GridColumnSizesType;
272
+ centered?: boolean;
273
+ }
254
274
  export interface IconsBlockProps {
255
275
  title?: string;
256
276
  size?: 's' | 'm' | 'l';
@@ -350,6 +370,9 @@ export type LinkTableBlockModel = {
350
370
  export type CardLayoutBlockModel = {
351
371
  type: BlockType.CardLayoutBlock;
352
372
  } & CardLayoutBlockProps;
373
+ export type FilterBlockModel = {
374
+ type: BlockType.FilterBlock;
375
+ } & FilterBlockProps;
353
376
  export type IconsBlockModel = {
354
377
  type: BlockType.IconsBlock;
355
378
  } & IconsBlockProps;
@@ -362,6 +385,6 @@ export type ContentLayoutBlockModel = {
362
385
  export type ShareBLockModel = {
363
386
  type: BlockType.ShareBlock;
364
387
  } & ShareBlockProps;
365
- type BlockModels = SliderBlockModel | ServiceDemoBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | CalculatorBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | SecurityBlockModel | TableBlockModel | TabsBlockModel | SimpleBlockModel | LinkTableBlockModel | HeaderBlockModel | PreviewBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel;
388
+ type BlockModels = SliderBlockModel | ServiceDemoBlockModel | ExtendedFeaturesBlockModel | PromoFeaturesBlockModel | QuestionsBlockModel | CalculatorBlockModel | BannerBlockModel | CompaniesBlockModel | MediaBlockModel | MapBlockModel | InfoBlockModel | SecurityBlockModel | TableBlockModel | TabsBlockModel | SimpleBlockModel | LinkTableBlockModel | HeaderBlockModel | PreviewBlockModel | IconsBlockModel | HeaderSliderBlockModel | CardLayoutBlockModel | ContentLayoutBlockModel | ShareBLockModel | FilterBlockModel;
366
389
  export type Block = BlockModels & BlockBaseProps;
367
390
  export {};
@@ -26,6 +26,7 @@ var BlockType;
26
26
  BlockType["ContentLayoutBlock"] = "content-layout-block";
27
27
  BlockType["ShareBlock"] = "share-block";
28
28
  BlockType["MapBlock"] = "map-block";
29
+ BlockType["FilterBlock"] = "filter-block";
29
30
  })(BlockType = exports.BlockType || (exports.BlockType = {}));
30
31
  exports.BlockTypes = Object.values(BlockType);
31
32
  exports.HeaderBlockTypes = [BlockType.HeaderBlock, BlockType.HeaderSliderBlock];
@@ -38,7 +38,7 @@ export declare enum MediaVideoControlsType {
38
38
  Custom = "custom"
39
39
  }
40
40
  export type TextTheme = 'light' | 'dark';
41
- export type TextSize = 's' | 'm' | 'l';
41
+ export type TextSize = 'xs' | 's' | 'm' | 'l';
42
42
  export type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';
43
43
  export type HeaderWidth = 's' | 'm' | 'l';
44
44
  export type HeaderImageSize = 's' | 'm';
@@ -4,13 +4,33 @@ export declare enum NavigationItemType {
4
4
  Link = "link",
5
5
  Dropdown = "dropdown",
6
6
  Button = "button",
7
- Social = "social"
7
+ Social = "social",
8
+ GithubButton = "github-button"
8
9
  }
9
10
  export interface NavigationItemBase {
10
11
  text: string;
11
12
  icon?: ImageProps;
12
13
  url?: string;
13
14
  }
15
+ export declare enum NavigationGithubButtonIcon {
16
+ heart = "octicon-heart",
17
+ eye = "octicon-eye",
18
+ star = "octicon-star",
19
+ fork = "octicon-repo-forked",
20
+ issue = "octicon-issue-opened",
21
+ comment = "octicon-comment-discussion",
22
+ download = "octicon-download",
23
+ package = "octicon-package",
24
+ template = "octicon-repo-template",
25
+ play = "octicon-play"
26
+ }
27
+ export interface NavigationGithubButton extends Omit<NavigationItemBase, 'icon'> {
28
+ type: NavigationItemType.GithubButton;
29
+ url: string;
30
+ label?: string;
31
+ icon?: keyof typeof NavigationGithubButtonIcon;
32
+ size?: string;
33
+ }
14
34
  export interface NavigationLinkItem extends Omit<NavigationItemBase, 'url'> {
15
35
  type: NavigationItemType.Link;
16
36
  url: string;
@@ -1,10 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NavigationItemType = void 0;
3
+ exports.NavigationGithubButtonIcon = exports.NavigationItemType = void 0;
4
4
  var NavigationItemType;
5
5
  (function (NavigationItemType) {
6
6
  NavigationItemType["Link"] = "link";
7
7
  NavigationItemType["Dropdown"] = "dropdown";
8
8
  NavigationItemType["Button"] = "button";
9
9
  NavigationItemType["Social"] = "social";
10
+ NavigationItemType["GithubButton"] = "github-button";
10
11
  })(NavigationItemType = exports.NavigationItemType || (exports.NavigationItemType = {}));
12
+ var NavigationGithubButtonIcon;
13
+ (function (NavigationGithubButtonIcon) {
14
+ NavigationGithubButtonIcon["heart"] = "octicon-heart";
15
+ NavigationGithubButtonIcon["eye"] = "octicon-eye";
16
+ NavigationGithubButtonIcon["star"] = "octicon-star";
17
+ NavigationGithubButtonIcon["fork"] = "octicon-repo-forked";
18
+ NavigationGithubButtonIcon["issue"] = "octicon-issue-opened";
19
+ NavigationGithubButtonIcon["comment"] = "octicon-comment-discussion";
20
+ NavigationGithubButtonIcon["download"] = "octicon-download";
21
+ NavigationGithubButtonIcon["package"] = "octicon-package";
22
+ NavigationGithubButtonIcon["template"] = "octicon-repo-template";
23
+ NavigationGithubButtonIcon["play"] = "octicon-play";
24
+ })(NavigationGithubButtonIcon = exports.NavigationGithubButtonIcon || (exports.NavigationGithubButtonIcon = {}));
@@ -1,10 +1,11 @@
1
1
  import { ConstructorBlock } from '../models/constructor';
2
2
  import { TextSize, CustomConfig, PCShareSocialNetwork } from '../models';
3
- export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4";
3
+ export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
4
4
  export declare function getBlockKey(block: ConstructorBlock, index: number): string;
5
5
  export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
6
6
  export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
7
7
  [x: string]: any;
8
8
  };
9
+ export declare const getCustomSubBlockTypes: (customBlocks?: CustomConfig) => string[];
9
10
  export declare const getCustomHeaderTypes: (customBlocks?: CustomConfig) => string[];
10
11
  export declare const getShareLink: (url: string, type: PCShareSocialNetwork, title?: string, text?: string) => string | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getShareLink = exports.getCustomHeaderTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
3
+ exports.getShareLink = exports.getCustomHeaderTypes = exports.getCustomSubBlockTypes = exports.getCustomItems = exports.getCustomBlockTypes = exports.getBlockKey = exports.getHeaderTag = void 0;
4
4
  const models_1 = require("../models");
5
5
  function getHeaderTag(size) {
6
6
  switch (size) {
@@ -8,6 +8,8 @@ function getHeaderTag(size) {
8
8
  return 'h1';
9
9
  case 's':
10
10
  return 'h4';
11
+ case 'xs':
12
+ return 'h5';
11
13
  case 'm':
12
14
  default:
13
15
  return 'h2';
@@ -25,6 +27,11 @@ const getCustomBlockTypes = ({ blocks = {}, headers = {} } = {}) => [
25
27
  exports.getCustomBlockTypes = getCustomBlockTypes;
26
28
  const getCustomItems = ({ blocks = {}, headers = {}, subBlocks = {} } = {}) => (Object.assign(Object.assign(Object.assign({}, blocks), headers), subBlocks));
27
29
  exports.getCustomItems = getCustomItems;
30
+ const getCustomSubBlockTypes = (customBlocks = {}) => {
31
+ const { subBlocks = {} } = customBlocks;
32
+ return Object.keys(subBlocks);
33
+ };
34
+ exports.getCustomSubBlockTypes = getCustomSubBlockTypes;
28
35
  const getCustomHeaderTypes = (customBlocks = {}) => {
29
36
  const { headers = {} } = customBlocks;
30
37
  return Object.keys(headers);
@@ -141,15 +141,17 @@
141
141
  }
142
142
 
143
143
  @mixin label($size: m) {
144
- @include text-size(body-1);
144
+ @if $size == m {
145
+ @include text-size(body-1);
145
146
 
146
- $label-height: 20px;
147
+ $label-height: 20px;
147
148
 
148
- display: inline-block;
149
- padding: 0 8px;
150
- border-radius: 2px;
151
- height: $label-height;
152
- line-height: $label-height;
149
+ display: inline-block;
150
+ padding: 0 8px;
151
+ border-radius: 2px;
152
+ height: $label-height;
153
+ line-height: $label-height;
154
+ }
153
155
 
154
156
  @if $size == s {
155
157
  @include text-size(caption-2);
@@ -481,12 +483,69 @@ unpredictable css rules order in build */
481
483
  }
482
484
  }
483
485
 
484
- @mixin monochromeButton() {
485
- --yc-button-background-color: var(--pc-monochrome-button-background-color);
486
- --yc-button-background-color-hover: var(--pc-monochrome-button-background-color-hover);
487
- color: var(--pc-monochrome-button-color);
486
+ @mixin button($color, $backgroundColor, $hoverColor: $color, $hoverBackgroundColor) {
487
+ --yc-button-background-color: #{$backgroundColor};
488
+ --yc-button-background-color-hover: #{$hoverBackgroundColor};
489
+
490
+ &,
491
+ &:link,
492
+ &:visited,
493
+ &:active,
494
+ &:focus {
495
+ color: $color;
496
+ }
488
497
 
489
498
  &:hover {
490
- color: var(--pc-monochrome-button-color);
499
+ color: $hoverColor;
500
+ }
501
+ }
502
+
503
+ @mixin monochrome-button() {
504
+ @include button(
505
+ var(--pc-monochrome-button-color),
506
+ var(--pc-monochrome-button-background-color),
507
+ $hoverBackgroundColor: var(--pc-monochrome-button-background-color-hover)
508
+ );
509
+ }
510
+
511
+ @mixin centerable-title() {
512
+ &_centered {
513
+ text-align: center;
514
+
515
+ & > * {
516
+ margin: 0 auto;
517
+ }
518
+ }
519
+ }
520
+
521
+ @mixin tab-panel() {
522
+ display: flex;
523
+ flex-wrap: nowrap;
524
+ justify-content: flex-start;
525
+ overflow: auto;
526
+
527
+ &_centered {
528
+ display: flex;
529
+ justify-content: center;
530
+ flex-wrap: wrap;
531
+ }
532
+
533
+ @media (max-width: map-get($gridBreakpoints, 'md')) {
534
+ display: flex;
535
+ flex-wrap: nowrap;
536
+ justify-content: flex-start;
537
+ overflow: auto;
538
+
539
+ margin-left: -$indentL;
540
+ margin-right: -$indentL;
541
+ padding-left: $indentL;
542
+ padding-right: $indentL - $indentXXXS;
543
+ }
544
+
545
+ @media (max-width: map-get($gridBreakpoints, 'sm')) {
546
+ margin-left: -$indentSM;
547
+ margin-right: -$indentSM;
548
+ padding-left: $indentSM;
549
+ padding-right: $indentXS;
491
550
  }
492
551
  }
package/styles/root.scss CHANGED
@@ -19,6 +19,16 @@
19
19
  --pc-text-header-color: var(--yc-color-text-primary);
20
20
  --pc-media-card-meta-info-color: var(--yc-color-text-secondary);
21
21
 
22
+ --pc-tab-item-color: var(--yc-color-text-primary);
23
+ --pc-tab-item-background-color: var(--yc-color-base-generic);
24
+ --pc-tab-item-background-color-hover: var(--yc-color-base-generic-hover);
25
+
26
+ --pc-selected-tab-item-color: var(--pc-monochrome-button-color);
27
+ --pc-selected-tab-item-background-color: var(--pc-monochrome-button-background-color);
28
+ --pc-selected-tab-item-background-color-hover: var(
29
+ --pc-monochrome-button-background-color-hover
30
+ );
31
+
22
32
  &.yc-root_theme_dark {
23
33
  --pc-color-sfx-shadow: var(--yc-color-sfx-shadow);
24
34
  --pc-color-line-generic-active-solid: #6c6c70;