@gravity-ui/page-constructor 4.31.1 → 4.34.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 (105) hide show
  1. package/build/cjs/blocks/Form/Form.css +136 -0
  2. package/build/cjs/blocks/Form/Form.d.ts +4 -0
  3. package/build/cjs/blocks/Form/Form.js +59 -0
  4. package/build/cjs/blocks/Form/InnerForm/InnerForm.d.ts +9 -0
  5. package/build/cjs/blocks/Form/InnerForm/InnerForm.js +28 -0
  6. package/build/cjs/blocks/Form/schema.d.ts +202 -0
  7. package/build/cjs/blocks/Form/schema.js +44 -0
  8. package/build/cjs/blocks/Header/Header.js +6 -2
  9. package/build/cjs/blocks/Tabs/Tabs.js +8 -1
  10. package/build/cjs/blocks/index.d.ts +1 -0
  11. package/build/cjs/blocks/index.js +3 -1
  12. package/build/cjs/components/BackLink/BackLink.d.ts +3 -2
  13. package/build/cjs/components/BackLink/BackLink.js +2 -2
  14. package/build/cjs/components/Button/Button.d.ts +0 -1
  15. package/build/cjs/components/DefaultVideo/DefaultVideo.css +5 -0
  16. package/build/cjs/components/DefaultVideo/DefaultVideo.d.ts +11 -0
  17. package/build/cjs/components/DefaultVideo/DefaultVideo.js +60 -0
  18. package/build/cjs/components/FileLink/FileLink.js +2 -2
  19. package/build/cjs/components/FullscreenImage/FullscreenImage.d.ts +2 -1
  20. package/build/cjs/components/FullscreenImage/FullscreenImage.js +2 -2
  21. package/build/cjs/components/Image/Image.js +2 -2
  22. package/build/cjs/components/Link/Link.js +4 -4
  23. package/build/cjs/components/Media/Video/Video.css +0 -5
  24. package/build/cjs/components/Media/Video/Video.js +3 -7
  25. package/build/cjs/components/Title/Title.d.ts +2 -1
  26. package/build/cjs/components/Title/Title.js +2 -2
  27. package/build/cjs/components/Title/TitleItem.css +3 -3
  28. package/build/cjs/components/YandexForm/YandexForm.d.ts +2 -17
  29. package/build/cjs/components/YandexForm/YandexForm.js +6 -4
  30. package/build/cjs/components/YandexForm/schema.d.ts +16 -0
  31. package/build/cjs/components/YandexForm/schema.js +13 -0
  32. package/build/cjs/constructor-items.d.ts +1 -0
  33. package/build/cjs/constructor-items.js +1 -0
  34. package/build/cjs/editor/data/templates/form-block.json +20 -0
  35. package/build/cjs/models/constructor-items/blocks.d.ts +33 -4
  36. package/build/cjs/models/constructor-items/blocks.js +13 -1
  37. package/build/cjs/models/constructor-items/common.d.ts +22 -3
  38. package/build/cjs/models/guards.d.ts +3 -1
  39. package/build/cjs/models/guards.js +9 -1
  40. package/build/cjs/schema/constants.js +2 -1
  41. package/build/cjs/schema/validators/blocks.d.ts +1 -0
  42. package/build/cjs/schema/validators/blocks.js +1 -0
  43. package/build/cjs/sub-blocks/BasicCard/BasicCard.js +5 -2
  44. package/build/cjs/sub-blocks/Content/Content.js +12 -5
  45. package/build/cjs/sub-blocks/HubspotForm/HubspotForm.css +10 -10
  46. package/build/cjs/sub-blocks/HubspotForm/schema.d.ts +22 -0
  47. package/build/cjs/sub-blocks/HubspotForm/schema.js +17 -0
  48. package/build/cjs/sub-blocks/LayoutItem/utils.d.ts +1 -0
  49. package/build/cjs/sub-blocks/Quote/Quote.css +0 -2
  50. package/build/esm/blocks/Form/Form.css +136 -0
  51. package/build/esm/blocks/Form/Form.d.ts +5 -0
  52. package/build/esm/blocks/Form/Form.js +57 -0
  53. package/build/esm/blocks/Form/InnerForm/InnerForm.d.ts +9 -0
  54. package/build/esm/blocks/Form/InnerForm/InnerForm.js +26 -0
  55. package/build/esm/blocks/Form/schema.d.ts +202 -0
  56. package/build/esm/blocks/Form/schema.js +40 -0
  57. package/build/esm/blocks/Header/Header.js +6 -2
  58. package/build/esm/blocks/Tabs/Tabs.js +8 -1
  59. package/build/esm/blocks/index.d.ts +1 -0
  60. package/build/esm/blocks/index.js +1 -0
  61. package/build/esm/components/BackLink/BackLink.d.ts +3 -2
  62. package/build/esm/components/BackLink/BackLink.js +2 -2
  63. package/build/esm/components/Button/Button.d.ts +0 -1
  64. package/build/esm/components/DefaultVideo/DefaultVideo.css +5 -0
  65. package/build/esm/components/DefaultVideo/DefaultVideo.d.ts +12 -0
  66. package/build/esm/components/DefaultVideo/DefaultVideo.js +57 -0
  67. package/build/esm/components/FileLink/FileLink.js +2 -2
  68. package/build/esm/components/FullscreenImage/FullscreenImage.d.ts +2 -1
  69. package/build/esm/components/FullscreenImage/FullscreenImage.js +2 -2
  70. package/build/esm/components/Image/Image.js +3 -2
  71. package/build/esm/components/Link/Link.js +4 -4
  72. package/build/esm/components/Media/Video/Video.css +0 -5
  73. package/build/esm/components/Media/Video/Video.js +3 -7
  74. package/build/esm/components/Title/Title.d.ts +2 -1
  75. package/build/esm/components/Title/Title.js +2 -2
  76. package/build/esm/components/Title/TitleItem.css +3 -3
  77. package/build/esm/components/YandexForm/YandexForm.d.ts +2 -17
  78. package/build/esm/components/YandexForm/YandexForm.js +5 -3
  79. package/build/esm/components/YandexForm/schema.d.ts +16 -0
  80. package/build/esm/components/YandexForm/schema.js +10 -0
  81. package/build/esm/constructor-items.d.ts +1 -0
  82. package/build/esm/constructor-items.js +2 -1
  83. package/build/esm/editor/data/templates/form-block.json +20 -0
  84. package/build/esm/models/constructor-items/blocks.d.ts +33 -4
  85. package/build/esm/models/constructor-items/blocks.js +12 -0
  86. package/build/esm/models/constructor-items/common.d.ts +22 -3
  87. package/build/esm/models/guards.d.ts +3 -1
  88. package/build/esm/models/guards.js +7 -1
  89. package/build/esm/schema/constants.js +3 -2
  90. package/build/esm/schema/validators/blocks.d.ts +1 -0
  91. package/build/esm/schema/validators/blocks.js +1 -0
  92. package/build/esm/sub-blocks/BasicCard/BasicCard.js +5 -2
  93. package/build/esm/sub-blocks/Content/Content.js +12 -5
  94. package/build/esm/sub-blocks/HubspotForm/HubspotForm.css +10 -10
  95. package/build/esm/sub-blocks/HubspotForm/schema.d.ts +22 -0
  96. package/build/esm/sub-blocks/HubspotForm/schema.js +14 -0
  97. package/build/esm/sub-blocks/LayoutItem/utils.d.ts +1 -0
  98. package/build/esm/sub-blocks/Quote/Quote.css +0 -2
  99. package/package.json +1 -1
  100. package/server/models/constructor-items/blocks.d.ts +33 -4
  101. package/server/models/constructor-items/blocks.js +13 -1
  102. package/server/models/constructor-items/common.d.ts +22 -3
  103. package/server/models/guards.d.ts +3 -1
  104. package/server/models/guards.js +9 -1
  105. package/widget/index.js +1 -1
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const react_1 = tslib_1.__importDefault(require("react"));
5
+ const uikit_1 = require("@gravity-ui/uikit");
5
6
  const components_1 = require("../../components");
6
7
  const Link_1 = tslib_1.__importDefault(require("../../components/Link/Link"));
7
8
  const grid_1 = require("../../grid");
@@ -37,16 +38,18 @@ function getButtonSize(size) {
37
38
  }
38
39
  }
39
40
  const Content = (props) => {
40
- const { title, text, additionalInfo, size = 'l', links, buttons, colSizes = { all: 12, sm: 8 }, centered, theme, className, list, qa, } = props;
41
+ const { title, titleId: titleIdFromProps, text, textId, additionalInfo, size = 'l', links, buttons, colSizes = { all: 12, sm: 8 }, centered, theme, className, list, qa, } = props;
41
42
  const qaAttributes = (0, blocks_1.getQaAttrubutes)(qa, ['links', 'link', 'buttons', 'button', 'list']);
42
43
  const titleProps = !title || typeof title === 'string'
43
44
  ? { text: title, textSize: getTextSize(size) }
44
45
  : title;
45
46
  const hasTitle = Boolean(title);
47
+ const defaultTitleId = (0, uikit_1.useUniqId)();
48
+ const titleId = titleIdFromProps || defaultTitleId;
46
49
  return (react_1.default.createElement(grid_1.Col, { className: b({ size, centered, theme }, className), reset: true, sizes: colSizes, qa: qaAttributes.container },
47
- title && react_1.default.createElement(components_1.Title, { className: b('title'), title: titleProps, colSizes: { all: 12 } }),
50
+ title && (react_1.default.createElement(components_1.Title, { className: b('title'), title: titleProps, colSizes: { all: 12 }, id: titleId })),
48
51
  text && (react_1.default.createElement("div", { className: b('text', { ['without-title']: !hasTitle }) },
49
- react_1.default.createElement(components_1.YFMWrapper, { content: text, modifiers: { constructor: true, [`constructor-size-${size}`]: true } }))),
52
+ react_1.default.createElement(components_1.YFMWrapper, { content: text, modifiers: { constructor: true, [`constructor-size-${size}`]: true }, id: textId }))),
50
53
  (list === null || list === void 0 ? void 0 : list.length) ? react_1.default.createElement(ContentList_1.default, { list: list, size: size, qa: qaAttributes.list }) : null,
51
54
  additionalInfo && (react_1.default.createElement("div", { className: b('notice') },
52
55
  react_1.default.createElement(components_1.YFMWrapper, { content: additionalInfo, modifiers: {
@@ -54,7 +57,11 @@ const Content = (props) => {
54
57
  'constructor-notice': true,
55
58
  [`constructor-size-${size}`]: true,
56
59
  } }))),
57
- links && (react_1.default.createElement("div", { className: b('links'), "data-qa": qaAttributes.links }, links.map((link) => (react_1.default.createElement(Link_1.default, Object.assign({ className: b('link') }, link, { textSize: getLinkSize(size), key: link.url, qa: qaAttributes.link })))))),
58
- buttons && (react_1.default.createElement("div", { className: b('buttons'), "data-qa": qaAttributes.buttons }, buttons.map((item) => (react_1.default.createElement(components_1.Button, Object.assign({ className: b('button') }, item, { key: item.url, size: getButtonSize(size), qa: qaAttributes.button }))))))));
60
+ links && (react_1.default.createElement("div", { className: b('links'), "data-qa": qaAttributes.links }, links.map((link) => (react_1.default.createElement(Link_1.default, Object.assign({ className: b('link') }, link, { textSize: getLinkSize(size), key: link.url, qa: qaAttributes.link, extraProps: {
61
+ 'aria-describedby': link.urlTitle ? undefined : titleId,
62
+ } })))))),
63
+ buttons && (react_1.default.createElement("div", { className: b('buttons'), "data-qa": qaAttributes.buttons }, buttons.map((item) => (react_1.default.createElement(components_1.Button, Object.assign({ className: b('button') }, item, { key: item.url, size: getButtonSize(size), qa: qaAttributes.button, extraProps: {
64
+ 'aria-describedby': item.urlTitle ? undefined : titleId,
65
+ } }))))))));
59
66
  };
60
67
  exports.default = Content;
@@ -239,16 +239,6 @@ unpredictable css rules order in build */
239
239
  font-weight: var(--g-text-body-font-weight);
240
240
  margin: 20px 0;
241
241
  }
242
- .pc-hubspot-form .hs-richtext a:focus {
243
- box-shadow: 0 0 0 2px var(--g-color-line-focus);
244
- }
245
- .pc-hubspot-form .hs-richtext a:focus:not(:focus-visible) {
246
- box-shadow: none;
247
- }
248
- .pc-hubspot-form .hs-richtext a:focus {
249
- outline: 0;
250
- border-radius: var(--g-focus-border-radius);
251
- }
252
242
  .pc-hubspot-form .hs_error_rollup {
253
243
  padding-left: 10px;
254
244
  font-size: var(--g-text-body-1-font-size);
@@ -390,6 +380,16 @@ unpredictable css rules order in build */
390
380
  .pc-hubspot-form_mobile .hs-button.primary {
391
381
  width: 80%;
392
382
  }
383
+ .pc-hubspot-form a:focus {
384
+ box-shadow: 0 0 0 2px var(--g-color-line-focus);
385
+ }
386
+ .pc-hubspot-form a:focus:not(:focus-visible) {
387
+ box-shadow: none;
388
+ }
389
+ .pc-hubspot-form a:focus {
390
+ outline: 0;
391
+ border-radius: var(--g-focus-border-radius);
392
+ }
393
393
  .pc-hubspot-form_theme_dark {
394
394
  --g-color-line-focus: var(--pc-color-line-focus-dark);
395
395
  }
@@ -0,0 +1,22 @@
1
+ export declare const HubspotFormProps: {
2
+ type: string;
3
+ required: string[];
4
+ properties: {
5
+ region: {
6
+ type: string;
7
+ };
8
+ portalId: {
9
+ type: string;
10
+ };
11
+ formId: {
12
+ type: string;
13
+ };
14
+ formInstanceId: {
15
+ type: string;
16
+ };
17
+ type: {};
18
+ when: {
19
+ type: string;
20
+ };
21
+ };
22
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HubspotFormProps = void 0;
4
+ const common_1 = require("../../schema/validators/common");
5
+ exports.HubspotFormProps = {
6
+ type: 'object',
7
+ required: ['portalId', 'formId'],
8
+ properties: Object.assign(Object.assign({}, common_1.BaseProps), { region: {
9
+ type: 'string',
10
+ }, portalId: {
11
+ type: 'string',
12
+ }, formId: {
13
+ type: 'string',
14
+ }, formInstanceId: {
15
+ type: 'string',
16
+ } }),
17
+ };
@@ -10,6 +10,7 @@ export declare const getLayoutItemLinks: (links: LayoutItemProps['content']['lin
10
10
  target?: string | undefined;
11
11
  metrikaGoals?: import("../../models").MetrikaGoal | undefined;
12
12
  pixelEvents?: import("../../models").ButtonPixel | undefined;
13
+ extraProps?: import("react").HTMLProps<HTMLAnchorElement> | undefined;
13
14
  analyticsEvents?: {
14
15
  name: string;
15
16
  type?: string | undefined;
@@ -62,7 +62,6 @@ unpredictable css rules order in build */
62
62
  }
63
63
  .pc-quote__content_quote-type_chevron::before {
64
64
  position: absolute;
65
- top: -1px;
66
65
  left: -10px;
67
66
  content: "«";
68
67
  }
@@ -71,7 +70,6 @@ unpredictable css rules order in build */
71
70
  }
72
71
  .pc-quote__content_quote-type_english-double::before {
73
72
  position: absolute;
74
- top: -1px;
75
73
  left: -8px;
76
74
  content: "“";
77
75
  }
@@ -0,0 +1,136 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-form-block {
4
+ border-radius: 32px;
5
+ position: relative;
6
+ }
7
+ .pc-form-block__title {
8
+ margin: 0 0 24px 10px;
9
+ }
10
+ .pc-form-block__title_mobile {
11
+ margin-left: 4px;
12
+ }
13
+ .pc-form-block__full-form {
14
+ background-color: var(--g-color-base-background);
15
+ padding: 48px 64px 48px calc(64px - 10px);
16
+ border-radius: var(--pc-border-radius);
17
+ }
18
+ .pc-form-block__media {
19
+ position: absolute;
20
+ top: 0;
21
+ left: 0;
22
+ bottom: 0;
23
+ right: 0;
24
+ border-radius: 32px;
25
+ }
26
+ .pc-form-block__image {
27
+ height: 100%;
28
+ width: 100%;
29
+ object-fit: cover;
30
+ }
31
+ .pc-form-block__row_direction_form-content {
32
+ flex-direction: row-reverse;
33
+ }
34
+ .pc-form-block__row_direction_center {
35
+ padding-top: 64px;
36
+ padding-bottom: 48px;
37
+ flex-direction: column;
38
+ }
39
+ .pc-form-block__row_direction_center .pc-form-block__content-wrapper {
40
+ margin-bottom: 32px;
41
+ }
42
+ .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__full-form {
43
+ box-shadow: 0 4px 24px var(--pc-color-sfx-shadow), 0 2px 8px var(--pc-color-sfx-shadow);
44
+ }
45
+ .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row_direction_form-content .pc-form-block__content-wrapper {
46
+ padding: 48px 0 64px 64px;
47
+ }
48
+ .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row_direction_content-form .pc-form-block__content-wrapper {
49
+ padding: 48px 64px 64px 0;
50
+ }
51
+ .pc-form-block_with-background .pc-form-block__row_direction_form-content .pc-form-block__form-wrapper {
52
+ padding: 16px 0 24px 16px;
53
+ }
54
+ .pc-form-block_with-background .pc-form-block__row_direction_content-form .pc-form-block__form-wrapper {
55
+ padding: 16px 16px 24px 0;
56
+ }
57
+ .pc-form-block_with-background .pc-form-block__row_direction_form-content .pc-form-block__content-wrapper, .pc-form-block_with-background .pc-form-block__row_direction_content-form .pc-form-block__content-wrapper {
58
+ padding: 64px;
59
+ }
60
+ @media (min-width: 1081px) {
61
+ .pc-form-block_form-type_yandex .pc-form-block__row_direction_form-content .pc-form-block__content-col, .pc-form-block_form-type_yandex .pc-form-block__row_direction_content-form .pc-form-block__content-col {
62
+ flex: 1 0 0;
63
+ }
64
+ .pc-form-block_form-type_yandex .pc-form-block__row_direction_form-content .pc-form-block__form, .pc-form-block_form-type_yandex .pc-form-block__row_direction_content-form .pc-form-block__form, .pc-form-block_form-type_yandex .pc-form-block__row_direction_center .pc-form-block__form {
65
+ min-width: 475px;
66
+ }
67
+ .pc-form-block_form-type_yandex .pc-form-block__row_direction_form-content .pc-form-block__form-col, .pc-form-block_form-type_yandex .pc-form-block__row_direction_content-form .pc-form-block__form-col, .pc-form-block_form-type_yandex .pc-form-block__row_direction_center .pc-form-block__form-col {
68
+ max-width: initial;
69
+ width: fit-content;
70
+ }
71
+ }
72
+ @media (max-width: 1081px) and (min-width: 769px) {
73
+ .pc-form-block__row {
74
+ flex-direction: column;
75
+ }
76
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__form-wrapper,
77
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__content-wrapper, .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__form-wrapper,
78
+ .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__content-wrapper {
79
+ max-width: 609px;
80
+ }
81
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__center,
82
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__form-wrapper,
83
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__content-wrapper, .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__center,
84
+ .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__form-wrapper,
85
+ .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__content-wrapper {
86
+ margin: 0 auto;
87
+ padding-right: 0;
88
+ padding-left: 0;
89
+ }
90
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__form-wrapper, .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__form-wrapper {
91
+ padding-top: 0;
92
+ }
93
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__content-wrapper, .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__content-wrapper {
94
+ text-align: center;
95
+ padding-bottom: 32px;
96
+ }
97
+ .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__content-wrapper {
98
+ padding: 0 0 32px 0;
99
+ }
100
+ }
101
+ @media (max-width: 769px) {
102
+ .pc-form-block__full-form {
103
+ padding: 32px;
104
+ }
105
+ .pc-form-block_with-background .pc-form-block__row, .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row {
106
+ padding: 0;
107
+ }
108
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__form-wrapper,
109
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__content-wrapper, .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__form-wrapper,
110
+ .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__content-wrapper {
111
+ padding: 0;
112
+ }
113
+ .pc-form-block_with-background .pc-form-block__row .pc-form-block__content-wrapper, .pc-form-block:not(.pc-form-block_with-background) .pc-form-block__row .pc-form-block__content-wrapper {
114
+ padding-bottom: 32px;
115
+ margin-bottom: 0;
116
+ }
117
+ .pc-form-block_with-background {
118
+ padding: 0 8px;
119
+ }
120
+ .pc-form-block_with-background .pc-form-block__row {
121
+ padding-top: 48px;
122
+ }
123
+ .pc-form-block_with-background .pc-form-block__row_padding-bottom_m {
124
+ padding-bottom: 32px;
125
+ }
126
+ .pc-form-block_with-background .pc-form-block__row_padding-bottom_l {
127
+ padding-bottom: 48px;
128
+ }
129
+ .pc-form-block_with-background .pc-form-block__row_direction_form-content .pc-form-block__content-wrapper, .pc-form-block_with-background .pc-form-block__row_direction_content-form .pc-form-block__content-wrapper, .pc-form-block_with-background .pc-form-block__row_direction_center .pc-form-block__content-wrapper {
130
+ padding-right: 16px;
131
+ padding-left: 16px;
132
+ }
133
+ .pc-form-block_with-background .pc-form-block__row_direction_form-content, .pc-form-block_with-background .pc-form-block__row_direction_content-form {
134
+ padding-top: 32px;
135
+ }
136
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { FormBlockProps } from '../../models';
3
+ import './Form.css';
4
+ declare const FormBlock: React.FC<FormBlockProps>;
5
+ export default FormBlock;
@@ -0,0 +1,57 @@
1
+ import React, { useCallback, useContext, useState } from 'react';
2
+ import { BackgroundImage, Title } from '../../components';
3
+ import { MobileContext } from '../../context/mobileContext';
4
+ import { Col, Grid, GridAlignItems, GridColumnSize, Row } from '../../grid';
5
+ import { FormBlockDataTypes, FormBlockDirection, isHubspotDataForm, isYandexDataForm, } from '../../models';
6
+ import { Content } from '../../sub-blocks';
7
+ import { block } from '../../utils';
8
+ import InnerForm from './InnerForm/InnerForm';
9
+ import './Form.css';
10
+ const b = block('form-block');
11
+ const colSizes = { [GridColumnSize.Lg]: 6, [GridColumnSize.All]: 12 };
12
+ const FormBlock = (props) => {
13
+ var _a;
14
+ const { formData, title, textContent, direction = FormBlockDirection.Center, background } = props;
15
+ const [contentLoaded, setContentLoaded] = useState(false);
16
+ const isMobile = useContext(MobileContext);
17
+ const hasImage = background && (background.src || background.desktop);
18
+ const paddingBottom = background && ((_a = background.style) === null || _a === void 0 ? void 0 : _a.backgroundColor) && !hasImage ? 'l' : 'm'; // bigger padding for case with background color and no image
19
+ const onContentLoad = useCallback(() => {
20
+ setContentLoaded(true);
21
+ }, []);
22
+ if (!formData) {
23
+ return null;
24
+ }
25
+ let formType;
26
+ if (isYandexDataForm(formData)) {
27
+ formType = FormBlockDataTypes.YANDEX;
28
+ }
29
+ else if (isHubspotDataForm(formData)) {
30
+ formType = FormBlockDataTypes.HUBSPOT;
31
+ }
32
+ return (React.createElement("div", { className: b({
33
+ 'with-background': Boolean(background),
34
+ 'form-type': formType,
35
+ }) },
36
+ background && (React.createElement(BackgroundImage, Object.assign({}, background, { className: b('media'), imageClassName: b('image') }))),
37
+ React.createElement(Grid, null,
38
+ React.createElement(Row, { alignItems: direction === FormBlockDirection.Center
39
+ ? GridAlignItems.Center
40
+ : GridAlignItems.Start, className: b('row', {
41
+ direction,
42
+ 'padding-bottom': paddingBottom,
43
+ }) },
44
+ React.createElement(Col, { sizes: colSizes, className: b('content-col') }, textContent && (React.createElement("div", { className: b('content-wrapper') },
45
+ React.createElement(Content, Object.assign({ theme: "default" }, textContent, { centered: direction === FormBlockDirection.Center, colSizes: { all: 12 }, className: b('content') }))))),
46
+ React.createElement(Col, { sizes: colSizes, className: b('form-col') },
47
+ React.createElement("div", { className: b('form-wrapper') },
48
+ React.createElement("div", { className: b('full-form', {
49
+ hidden: !contentLoaded,
50
+ }) },
51
+ title && (React.createElement(Title, { title: {
52
+ text: title,
53
+ textSize: 's',
54
+ }, className: b('title', { mobile: isMobile }), colSizes: { all: 12 } })),
55
+ React.createElement(InnerForm, { className: b('form'), formData: formData, onContentLoad: onContentLoad }))))))));
56
+ };
57
+ export default FormBlock;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { FormBlockData } from '../../../models';
3
+ interface InnerFormProps {
4
+ formData: FormBlockData;
5
+ onContentLoad: () => void;
6
+ className?: string;
7
+ }
8
+ declare const InnerForm: React.FC<InnerFormProps>;
9
+ export default InnerForm;
@@ -0,0 +1,26 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useEffect } from 'react';
3
+ import { YandexForm } from '../../../components';
4
+ import { isHubspotDataForm, isYandexDataForm } from '../../../models';
5
+ import { HubspotForm } from '../../../sub-blocks';
6
+ const InnerForm = (props) => {
7
+ const { formData, onContentLoad, className } = props;
8
+ useEffect(() => {
9
+ if (isHubspotDataForm(formData)) {
10
+ onContentLoad();
11
+ }
12
+ }, [onContentLoad, formData]);
13
+ if (isYandexDataForm(formData)) {
14
+ const _a = formData.yandex, { onLoad } = _a, rest = __rest(_a, ["onLoad"]);
15
+ return (React.createElement("div", { className: className },
16
+ React.createElement(YandexForm, Object.assign({}, rest, { onLoad: () => {
17
+ onContentLoad();
18
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad();
19
+ } }))));
20
+ }
21
+ if (isHubspotDataForm(formData)) {
22
+ return React.createElement(HubspotForm, Object.assign({ createDOMElement: true }, formData.hubspot));
23
+ }
24
+ return null;
25
+ };
26
+ export default InnerForm;
@@ -0,0 +1,202 @@
1
+ export declare const FormBlock: {
2
+ 'form-block': {
3
+ additionalProperties: boolean;
4
+ required: string[];
5
+ properties: {
6
+ title: {
7
+ type: string;
8
+ };
9
+ formData: {
10
+ oneOf: ({
11
+ type: string;
12
+ optionName: string;
13
+ properties: {
14
+ yandex: {
15
+ type: string;
16
+ required: string[];
17
+ properties: {
18
+ id: {
19
+ type: string;
20
+ };
21
+ containerId: {
22
+ type: string;
23
+ };
24
+ type: {};
25
+ when: {
26
+ type: string;
27
+ };
28
+ };
29
+ };
30
+ hubspot?: undefined;
31
+ };
32
+ } | {
33
+ type: string;
34
+ optionName: string;
35
+ properties: {
36
+ hubspot: {
37
+ type: string;
38
+ required: string[];
39
+ properties: {
40
+ region: {
41
+ type: string;
42
+ };
43
+ portalId: {
44
+ type: string;
45
+ };
46
+ formId: {
47
+ type: string;
48
+ };
49
+ formInstanceId: {
50
+ type: string;
51
+ };
52
+ type: {};
53
+ when: {
54
+ type: string;
55
+ };
56
+ };
57
+ };
58
+ yandex?: undefined;
59
+ };
60
+ })[];
61
+ };
62
+ textContent: {
63
+ additionalProperties: boolean;
64
+ properties: Partial<{
65
+ title: {
66
+ oneOf: ({
67
+ type: string;
68
+ contentType: string;
69
+ optionName: string;
70
+ } | {
71
+ optionName: string;
72
+ type: string;
73
+ additionalProperties: boolean;
74
+ required: string[];
75
+ properties: {
76
+ text: {
77
+ type: string;
78
+ contentType: string;
79
+ };
80
+ textSize: {
81
+ type: string;
82
+ enum: string[];
83
+ };
84
+ url: {
85
+ type: string;
86
+ };
87
+ urlTitle: {
88
+ type: string;
89
+ };
90
+ resetMargin: {
91
+ type: string;
92
+ };
93
+ };
94
+ contentType?: undefined;
95
+ })[];
96
+ };
97
+ text: {
98
+ type: string;
99
+ contentType: string;
100
+ inputType: string;
101
+ };
102
+ additionalInfo: {
103
+ type: string;
104
+ contentType: string;
105
+ };
106
+ size: {
107
+ type: string;
108
+ enum: string[];
109
+ };
110
+ links: {
111
+ type: string;
112
+ items: {
113
+ type: string;
114
+ properties: {
115
+ when: {
116
+ type: string;
117
+ };
118
+ };
119
+ };
120
+ };
121
+ buttons: {
122
+ type: string;
123
+ items: {
124
+ type: string;
125
+ properties: {
126
+ when: {
127
+ type: string;
128
+ };
129
+ };
130
+ };
131
+ };
132
+ theme: {
133
+ type: string;
134
+ enum: string[];
135
+ };
136
+ list: {
137
+ type: string;
138
+ items: {
139
+ type: string;
140
+ properties: {
141
+ when: {
142
+ type: string;
143
+ };
144
+ };
145
+ };
146
+ };
147
+ }>;
148
+ };
149
+ direction: {
150
+ enum: string[];
151
+ };
152
+ image: {
153
+ oneOf: ({
154
+ type: string;
155
+ properties: {
156
+ when: {
157
+ type: string;
158
+ };
159
+ };
160
+ } | {
161
+ type: string;
162
+ pattern: string;
163
+ optionName: string;
164
+ })[];
165
+ };
166
+ backgroundColor: {
167
+ type: string;
168
+ };
169
+ anchor: {
170
+ type: string;
171
+ additionalProperties: boolean;
172
+ required: string[];
173
+ properties: {
174
+ text: {
175
+ type: string;
176
+ contentType: string;
177
+ };
178
+ url: {
179
+ type: string;
180
+ };
181
+ urlTitle: {
182
+ type: string;
183
+ };
184
+ };
185
+ };
186
+ visible: {
187
+ type: string;
188
+ enum: string[];
189
+ };
190
+ resetPaddings: {
191
+ type: string;
192
+ };
193
+ context: {
194
+ type: string;
195
+ };
196
+ type: {};
197
+ when: {
198
+ type: string;
199
+ };
200
+ };
201
+ };
202
+ };
@@ -0,0 +1,40 @@
1
+ import omit from 'lodash/omit';
2
+ import { ImageProps } from '../../components/Image/schema';
3
+ import { YandexFormProps } from '../../components/YandexForm/schema';
4
+ import { BlockBaseProps } from '../../schema/validators/common';
5
+ import { ContentBase } from '../../sub-blocks/Content/schema';
6
+ import { HubspotFormProps } from '../../sub-blocks/HubspotForm/schema';
7
+ const FormBlockContentProps = omit(ContentBase, ['size', 'centered', 'colSizes']);
8
+ export const FormBlock = {
9
+ 'form-block': {
10
+ additionalProperties: false,
11
+ required: ['formData'],
12
+ properties: Object.assign(Object.assign({}, BlockBaseProps), { title: {
13
+ type: 'string',
14
+ }, formData: {
15
+ oneOf: [
16
+ {
17
+ type: 'object',
18
+ optionName: 'yandex',
19
+ properties: {
20
+ yandex: YandexFormProps,
21
+ },
22
+ },
23
+ {
24
+ type: 'object',
25
+ optionName: 'hubspot',
26
+ properties: {
27
+ hubspot: HubspotFormProps,
28
+ },
29
+ },
30
+ ],
31
+ }, textContent: {
32
+ additionalProperties: false,
33
+ properties: FormBlockContentProps,
34
+ }, direction: {
35
+ enum: ['content-form', 'form-content', 'center'],
36
+ }, image: ImageProps, backgroundColor: {
37
+ type: 'string',
38
+ } }),
39
+ },
40
+ };
@@ -1,4 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
+ import { useUniqId } from '@gravity-ui/uikit';
2
3
  import { Button, HTML, Media, RouterLink } from '../../components';
3
4
  import HeaderBreadcrumbs from '../../components/HeaderBreadcrumbs/HeaderBreadcrumbs';
4
5
  import { getMediaImage } from '../../components/Media/Image/utils';
@@ -32,6 +33,7 @@ export const HeaderBlock = (props) => {
32
33
  const imageThemed = image && getThemedValue(image, theme);
33
34
  const videoThemed = video && getThemedValue(video, theme);
34
35
  const fullWidth = (backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidth) || (backgroundThemed === null || backgroundThemed === void 0 ? void 0 : backgroundThemed.fullWidthMedia);
36
+ const titleId = useUniqId();
35
37
  return (React.createElement("header", { className: b({
36
38
  ['has-media']: hasRightSideImage,
37
39
  ['full-width']: fullWidth,
@@ -54,7 +56,7 @@ export const HeaderBlock = (props) => {
54
56
  React.createElement(Col, { sizes: titleSizes, className: b('content-inner') },
55
57
  overtitle && (React.createElement("div", { className: b('overtitle') },
56
58
  React.createElement(HTML, null, overtitle))),
57
- React.createElement("h1", { className: b('title') },
59
+ React.createElement("h1", { className: b('title'), id: titleId },
58
60
  status,
59
61
  renderTitle ? renderTitle(title) : React.createElement(HTML, null, title)),
60
62
  description && (React.createElement("div", { className: b('description') },
@@ -63,7 +65,9 @@ export const HeaderBlock = (props) => {
63
65
  constructorTheme: textTheme,
64
66
  } }))),
65
67
  buttons && (React.createElement("div", { className: b('buttons'), "data-qa": "header-buttons" }, buttons.map((button, index) => (React.createElement(RouterLink, { href: button.url, key: index },
66
- React.createElement(Button, Object.assign({ key: index, className: b('button'), size: "xl" }, button))))))),
68
+ React.createElement(Button, Object.assign({ key: index, className: b('button'), size: "xl", extraProps: {
69
+ 'aria-describedby': titleId,
70
+ } }, button))))))),
67
71
  children))),
68
72
  hasRightSideImage && (React.createElement(Media, { className: b('media', { [curImageSize]: true }), videoClassName: b('video'), imageClassName: b('image'), video: videoThemed, image: imageThemed })))))));
69
73
  };