@gravity-ui/page-constructor 3.6.2 → 3.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.8.0](https://github.com/gravity-ui/page-constructor/compare/v3.7.0...v3.8.0) (2023-06-22)
4
+
5
+
6
+ ### Features
7
+
8
+ * add yfm transoform for editor demo ([#420](https://github.com/gravity-ui/page-constructor/issues/420)) ([1c1a2aa](https://github.com/gravity-ui/page-constructor/commit/1c1a2aa134a3c4d18e01537c1ca874720f23649d))
9
+ * update dynamic forms and fix form render performance ([#418](https://github.com/gravity-ui/page-constructor/issues/418)) ([eb9437d](https://github.com/gravity-ui/page-constructor/commit/eb9437df0d38a9a3433e85d111c45b3a49dbd9aa))
10
+
11
+ ## [3.7.0](https://github.com/gravity-ui/page-constructor/compare/v3.6.2...v3.7.0) (2023-06-21)
12
+
13
+
14
+ ### Features
15
+
16
+ * **Tabs:** provide an to change tab text size ([#417](https://github.com/gravity-ui/page-constructor/issues/417)) ([005a686](https://github.com/gravity-ui/page-constructor/commit/005a68662ecc29ee07eff7d958a27842c38206f7))
17
+
3
18
  ## [3.6.2](https://github.com/gravity-ui/page-constructor/compare/v3.6.1...v3.6.2) (2023-06-19)
4
19
 
5
20
 
package/README.md CHANGED
@@ -325,6 +325,16 @@ When you receive the approval of your pull-request from the code owners and pass
325
325
  4. Check your changes in CHANGELOG.md and approve robot's PR.
326
326
  5. Squash and merge PR. You can see release process on [the Actions tab](https://github.com/gravity-ui/page-constructor/actions).
327
327
 
328
+ ### Alpha versions release
329
+
330
+ If you want to release alpha version of the package from your branch you can do it manually:
331
+
332
+ 1. Go to tab Actions
333
+ 2. Select workflow "Release alpha version" on the left page's side
334
+ 3. You can see on the right side the button "Run workflow". Here you can choose the branch.
335
+ 4. You can also see field with manually version. If you release alpha in your branch for the first time, do not set anything here. After first release you have to set the new version manually because we don't change package.json in case that the branch can expire very soon. Use the prefix `alpha` in you manual version otherwise you will get error.
336
+ 5. Push "Run workflow" and wait until the action will finish. You can release versions as many as you want but do not abuse it and release versions if you really need it. In other cases use [npm pack](https://docs.npmjs.com/cli/v7/commands/npm-pack).
337
+
328
338
  ### Beta-major versions release
329
339
 
330
340
  If you want to release a new major version, you will probably need for a beta versions before a stable one, please do the following:
@@ -1,3 +1,3 @@
1
1
  import { TabsBlockProps } from '../../models';
2
- export declare const TabsBlock: ({ items, title, description, animated, tabsColSizes, centered, direction, }: TabsBlockProps) => JSX.Element;
2
+ export declare const TabsBlock: ({ items, title, description, animated, tabsColSizes, centered, direction, contentSize, }: TabsBlockProps) => JSX.Element;
3
3
  export default TabsBlock;
@@ -15,7 +15,7 @@ const grid_1 = require("../../grid");
15
15
  const sub_blocks_1 = require("../../sub-blocks");
16
16
  const utils_2 = require("../../utils");
17
17
  const b = (0, utils_2.block)('tabs-block');
18
- const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered, direction = 'media-content', }) => {
18
+ const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered, direction = 'media-content', contentSize = 's', }) => {
19
19
  var _a;
20
20
  const [activeTab, setActiveTab] = (0, react_1.useState)(items[0].tabName);
21
21
  const [play, setPlay] = (0, react_1.useState)(false);
@@ -37,7 +37,7 @@ const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered
37
37
  react_1.default.createElement("div", { className: b('content-wrapper', {
38
38
  margin: Boolean(((activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) || imageProps) && !isReverse),
39
39
  }) },
40
- react_1.default.createElement(sub_blocks_1.Content, { title: activeTabData.title, text: activeTabData.text, additionalInfo: activeTabData.additionalInfo, size: "s", links: [
40
+ react_1.default.createElement(sub_blocks_1.Content, { title: activeTabData.title, text: activeTabData.text, additionalInfo: activeTabData.additionalInfo, size: contentSize, links: [
41
41
  ...(activeTabData.link ? [activeTabData.link] : []),
42
42
  ...(activeTabData.links || []),
43
43
  ], buttons: activeTabData.buttons, colSizes: { all: 12 } }))));
@@ -474,6 +474,10 @@ export declare const TabsBlock: {
474
474
  };
475
475
  };
476
476
  };
477
+ contentSize: {
478
+ type: string;
479
+ enum: string[];
480
+ };
477
481
  title: {
478
482
  oneOf: ({
479
483
  type: string;
@@ -31,6 +31,9 @@ exports.TabsBlock = {
31
31
  properties: Object.assign(Object.assign(Object.assign({}, common_1.BlockBaseProps), common_1.BlockHeaderProps), { tabsColSizes: common_1.containerSizesArray.reduce((acc, size) => (Object.assign(Object.assign({}, acc), { [size]: common_1.sizeNumber })), {}), direction: {
32
32
  type: 'string',
33
33
  enum: common_1.mediaDirection,
34
- }, centered: { type: 'boolean' }, items: (0, utils_1.filteredArray)(exports.tabsItem) }),
34
+ }, centered: { type: 'boolean' }, items: (0, utils_1.filteredArray)(exports.tabsItem), contentSize: {
35
+ type: 'string',
36
+ enum: common_1.contentSizes,
37
+ } }),
35
38
  },
36
39
  };
@@ -8,7 +8,7 @@ export declare const blockMap: {
8
8
  "media-block": (props: import("./models").MediaBlockProps) => JSX.Element;
9
9
  "info-block": (props: import("./models").InfoBlockProps) => JSX.Element;
10
10
  "table-block": (props: import("./models").TableBlockProps) => JSX.Element;
11
- "tabs-block": ({ items, title, description, animated, tabsColSizes, centered, direction, }: import("./models").TabsBlockProps) => JSX.Element;
11
+ "tabs-block": ({ items, title, description, animated, tabsColSizes, centered, direction, contentSize, }: import("./models").TabsBlockProps) => JSX.Element;
12
12
  "header-block": (props: import("./models").WithChildren<import("./models").HeaderBlockProps & import("./models").ClassNameProps>) => JSX.Element;
13
13
  "icons-block": ({ title, size, items }: import("./models").IconsBlockProps) => JSX.Element;
14
14
  "header-slider-block": ({ items, arrows, ...props }: import("./models").HeaderSliderBlockProps) => JSX.Element;
@@ -10,24 +10,19 @@ const config_1 = require("../../dynamic-forms-custom/config");
10
10
  const usePreviousValue_1 = tslib_1.__importDefault(require("../../hooks/usePreviousValue"));
11
11
  exports.BlockForm = (0, react_1.memo)((_a) => {
12
12
  var _b = _a.data, { type } = _b, content = tslib_1.__rest(_b, ["type"]), { onChange, onSelect, active, spec: specRaw } = _a;
13
- // get initial values only at first render, then the form manages data
14
- // eslint-disable-next-line react-hooks/exhaustive-deps
15
- const initialValues = (0, react_1.useMemo)(() => ({ content }), []);
13
+ const initialValues = (0, react_1.useMemo)(() => ({ content }), [content]);
16
14
  const prevContent = (0, usePreviousValue_1.default)(content);
17
15
  const spec = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, specRaw), { viewSpec: Object.assign(Object.assign({}, specRaw.viewSpec), { layoutOpen: active }) })), [specRaw, active]);
18
- return (react_1.default.createElement(react_final_form_1.Form, { initialValues: initialValues, onSubmit: lodash_1.default.noop }, () => (react_1.default.createElement("div", { onClick: () => {
19
- if (!active) {
20
- onSelect();
21
- }
22
- } },
16
+ if (!active) {
17
+ return (react_1.default.createElement(dynamic_forms_1.SimpleVerticalAccordeon, { open: false, name: type, title: spec.viewSpec.layoutTitle || type, onOpenChange: onSelect }, 1));
18
+ }
19
+ return (react_1.default.createElement(react_final_form_1.Form, { initialValues: initialValues, onSubmit: lodash_1.default.noop }, () => (react_1.default.createElement("div", null,
23
20
  react_1.default.createElement(react_final_form_1.FormSpy, { onChange: ({ values }) => {
24
21
  // fix for FormSpy onChange called twice without content changes
25
22
  if (!lodash_1.default.isEqual(values.content, prevContent)) {
26
23
  onChange(Object.assign({ type }, values.content));
27
24
  }
28
25
  }, subscription: { values: true } }),
29
- react_1.default.createElement(dynamic_forms_1.DynamicField, { name: "content",
30
- // there is no way other way to manage with form open/close state now
31
- key: String(active), spec: spec, config: config_1.dynamicConfig })))));
26
+ react_1.default.createElement(dynamic_forms_1.DynamicField, { name: "content", spec: spec, config: config_1.dynamicConfig, withoutInsertFFDebounce: true })))));
32
27
  });
33
28
  exports.BlockForm.displayName = 'BlockForm';
@@ -210,6 +210,7 @@ export interface TabsBlockProps extends Animatable {
210
210
  centered?: boolean;
211
211
  direction?: MediaDirection;
212
212
  items: TabsBlockItem[];
213
+ contentSize?: ContentSize;
213
214
  }
214
215
  export interface CardLayoutBlockProps extends Childable, Animatable, LoadableChildren {
215
216
  title?: TitleItemProps | string;
@@ -1,4 +1,4 @@
1
1
  import { TabsBlockProps } from '../../models';
2
2
  import './Tabs.css';
3
- export declare const TabsBlock: ({ items, title, description, animated, tabsColSizes, centered, direction, }: TabsBlockProps) => JSX.Element;
3
+ export declare const TabsBlock: ({ items, title, description, animated, tabsColSizes, centered, direction, contentSize, }: TabsBlockProps) => JSX.Element;
4
4
  export default TabsBlock;
@@ -12,7 +12,7 @@ import { Content } from '../../sub-blocks';
12
12
  import { block, getThemedValue } from '../../utils';
13
13
  import './Tabs.css';
14
14
  const b = block('tabs-block');
15
- export const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered, direction = 'media-content', }) => {
15
+ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, centered, direction = 'media-content', contentSize = 's', }) => {
16
16
  var _a;
17
17
  const [activeTab, setActiveTab] = useState(items[0].tabName);
18
18
  const [play, setPlay] = useState(false);
@@ -34,7 +34,7 @@ export const TabsBlock = ({ items, title, description, animated, tabsColSizes, c
34
34
  React.createElement("div", { className: b('content-wrapper', {
35
35
  margin: Boolean(((activeTabData === null || activeTabData === void 0 ? void 0 : activeTabData.media) || imageProps) && !isReverse),
36
36
  }) },
37
- React.createElement(Content, { title: activeTabData.title, text: activeTabData.text, additionalInfo: activeTabData.additionalInfo, size: "s", links: [
37
+ React.createElement(Content, { title: activeTabData.title, text: activeTabData.text, additionalInfo: activeTabData.additionalInfo, size: contentSize, links: [
38
38
  ...(activeTabData.link ? [activeTabData.link] : []),
39
39
  ...(activeTabData.links || []),
40
40
  ], buttons: activeTabData.buttons, colSizes: { all: 12 } }))));
@@ -474,6 +474,10 @@ export declare const TabsBlock: {
474
474
  };
475
475
  };
476
476
  };
477
+ contentSize: {
478
+ type: string;
479
+ enum: string[];
480
+ };
477
481
  title: {
478
482
  oneOf: ({
479
483
  type: string;
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import { ImageProps } from '../../components/Image/schema';
3
- import { BlockBaseProps, BlockHeaderProps, LinkProps, MediaProps, containerSizesArray, mediaDirection, sizeNumber, withTheme, } from '../../schema/validators/common';
3
+ import { BlockBaseProps, BlockHeaderProps, LinkProps, MediaProps, containerSizesArray, contentSizes, mediaDirection, sizeNumber, withTheme, } from '../../schema/validators/common';
4
4
  import { filteredArray } from '../../schema/validators/utils';
5
5
  import { ContentBase } from '../../sub-blocks/Content/schema';
6
6
  const TabsItemContentProps = _.omit(ContentBase, ['size', 'colSizes', 'centered', 'theme']);
@@ -27,6 +27,9 @@ export const TabsBlock = {
27
27
  properties: Object.assign(Object.assign(Object.assign({}, BlockBaseProps), BlockHeaderProps), { tabsColSizes: containerSizesArray.reduce((acc, size) => (Object.assign(Object.assign({}, acc), { [size]: sizeNumber })), {}), direction: {
28
28
  type: 'string',
29
29
  enum: mediaDirection,
30
- }, centered: { type: 'boolean' }, items: filteredArray(tabsItem) }),
30
+ }, centered: { type: 'boolean' }, items: filteredArray(tabsItem), contentSize: {
31
+ type: 'string',
32
+ enum: contentSizes,
33
+ } }),
31
34
  },
32
35
  };
@@ -8,7 +8,7 @@ export declare const blockMap: {
8
8
  "media-block": (props: import("./models").MediaBlockProps) => JSX.Element;
9
9
  "info-block": (props: import("./models").InfoBlockProps) => JSX.Element;
10
10
  "table-block": (props: import("./models").TableBlockProps) => JSX.Element;
11
- "tabs-block": ({ items, title, description, animated, tabsColSizes, centered, direction, }: import("./models").TabsBlockProps) => JSX.Element;
11
+ "tabs-block": ({ items, title, description, animated, tabsColSizes, centered, direction, contentSize, }: import("./models").TabsBlockProps) => JSX.Element;
12
12
  "header-block": (props: import("./models").WithChildren<import("./models").HeaderBlockProps & import("./models").ClassNameProps>) => JSX.Element;
13
13
  "icons-block": ({ title, size, items }: import("./models").IconsBlockProps) => JSX.Element;
14
14
  "header-slider-block": ({ items, arrows, ...props }: import("./models").HeaderSliderBlockProps) => JSX.Element;
@@ -1,30 +1,25 @@
1
1
  import { __rest } from "tslib";
2
2
  import React, { memo, useMemo } from 'react';
3
- import { DynamicField } from '@gravity-ui/dynamic-forms';
3
+ import { DynamicField, SimpleVerticalAccordeon } from '@gravity-ui/dynamic-forms';
4
4
  import _ from 'lodash';
5
5
  import { Form as FinalForm, FormSpy } from 'react-final-form';
6
6
  import { dynamicConfig } from '../../dynamic-forms-custom/config';
7
7
  import usePreviousValue from '../../hooks/usePreviousValue';
8
8
  export const BlockForm = memo((_a) => {
9
9
  var _b = _a.data, { type } = _b, content = __rest(_b, ["type"]), { onChange, onSelect, active, spec: specRaw } = _a;
10
- // get initial values only at first render, then the form manages data
11
- // eslint-disable-next-line react-hooks/exhaustive-deps
12
- const initialValues = useMemo(() => ({ content }), []);
10
+ const initialValues = useMemo(() => ({ content }), [content]);
13
11
  const prevContent = usePreviousValue(content);
14
12
  const spec = useMemo(() => (Object.assign(Object.assign({}, specRaw), { viewSpec: Object.assign(Object.assign({}, specRaw.viewSpec), { layoutOpen: active }) })), [specRaw, active]);
15
- return (React.createElement(FinalForm, { initialValues: initialValues, onSubmit: _.noop }, () => (React.createElement("div", { onClick: () => {
16
- if (!active) {
17
- onSelect();
18
- }
19
- } },
13
+ if (!active) {
14
+ return (React.createElement(SimpleVerticalAccordeon, { open: false, name: type, title: spec.viewSpec.layoutTitle || type, onOpenChange: onSelect }, 1));
15
+ }
16
+ return (React.createElement(FinalForm, { initialValues: initialValues, onSubmit: _.noop }, () => (React.createElement("div", null,
20
17
  React.createElement(FormSpy, { onChange: ({ values }) => {
21
18
  // fix for FormSpy onChange called twice without content changes
22
19
  if (!_.isEqual(values.content, prevContent)) {
23
20
  onChange(Object.assign({ type }, values.content));
24
21
  }
25
22
  }, subscription: { values: true } }),
26
- React.createElement(DynamicField, { name: "content",
27
- // there is no way other way to manage with form open/close state now
28
- key: String(active), spec: spec, config: dynamicConfig })))));
23
+ React.createElement(DynamicField, { name: "content", spec: spec, config: dynamicConfig, withoutInsertFFDebounce: true })))));
29
24
  });
30
25
  BlockForm.displayName = 'BlockForm';
@@ -210,6 +210,7 @@ export interface TabsBlockProps extends Animatable {
210
210
  centered?: boolean;
211
211
  direction?: MediaDirection;
212
212
  items: TabsBlockItem[];
213
+ contentSize?: ContentSize;
213
214
  }
214
215
  export interface CardLayoutBlockProps extends Childable, Animatable, LoadableChildren {
215
216
  title?: TitleItemProps | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "3.6.2",
3
+ "version": "3.8.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -77,7 +77,7 @@
77
77
  "test:watch": "jest --watchAll"
78
78
  },
79
79
  "dependencies": {
80
- "@gravity-ui/dynamic-forms": "1.7.1",
80
+ "@gravity-ui/dynamic-forms": "^1.9.2",
81
81
  "@gravity-ui/i18n": "^1.0.0",
82
82
  "bem-cn-lite": "^4.0.0",
83
83
  "final-form": "^4.20.9",
@@ -89,7 +89,7 @@
89
89
  "react-spring": "^9.3.0",
90
90
  "react-transition-group": "^4.4.2",
91
91
  "react-waypoint": "^10.1.0",
92
- "sanitize-html": "^2.6.1",
92
+ "sanitize-html": "2.6.1",
93
93
  "snakecase-keys": "^5.1.0",
94
94
  "typograf": "^6.14.0",
95
95
  "uuid": "^9.0.0"
@@ -125,7 +125,7 @@
125
125
  "@types/react-dom": "^18.0.10",
126
126
  "@types/react-slick": "^0.23.7",
127
127
  "@types/react-transition-group": "^4.4.4",
128
- "@types/sanitize-html": "^2.6.0",
128
+ "@types/sanitize-html": "2.6.1",
129
129
  "@types/uuid": "^9.0.0",
130
130
  "es5-ext": "0.10.53",
131
131
  "eslint": "^8.34.0",
@@ -137,6 +137,7 @@
137
137
  "gulp-replace": "^1.1.3",
138
138
  "gulp-typescript": "^6.0.0-alpha.1",
139
139
  "html-loader": "^1.3.2",
140
+ "htmlparser2": "^6.1.0",
140
141
  "husky": "^7.0.4",
141
142
  "jest": "^29.3.1",
142
143
  "jest-environment-jsdom": "^29.3.1",
@@ -210,6 +210,7 @@ export interface TabsBlockProps extends Animatable {
210
210
  centered?: boolean;
211
211
  direction?: MediaDirection;
212
212
  items: TabsBlockItem[];
213
+ contentSize?: ContentSize;
213
214
  }
214
215
  export interface CardLayoutBlockProps extends Childable, Animatable, LoadableChildren {
215
216
  title?: TitleItemProps | string;