@gravity-ui/page-constructor 4.42.3 → 4.42.5-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 (37) hide show
  1. package/build/cjs/blocks/Form/Form.css +1 -0
  2. package/build/cjs/blocks/Header/schema.d.ts +33 -3
  3. package/build/cjs/blocks/HeaderSlider/schema.d.ts +11 -1
  4. package/build/cjs/blocks/Media/schema.d.ts +22 -2
  5. package/build/cjs/blocks/PromoFeaturesBlock/schema.d.ts +11 -1
  6. package/build/cjs/blocks/Tabs/schema.d.ts +11 -1
  7. package/build/cjs/components/Media/Iframe/Iframe.css +0 -4
  8. package/build/cjs/components/Media/Iframe/Iframe.js +64 -4
  9. package/build/cjs/grid/Col/Col.d.ts +1 -1
  10. package/build/cjs/models/constructor-items/common.d.ts +4 -2
  11. package/build/cjs/schema/constants.d.ts +15 -271
  12. package/build/cjs/schema/validators/common.d.ts +11 -1
  13. package/build/cjs/schema/validators/common.js +5 -1
  14. package/build/cjs/sub-blocks/LayoutItem/schema.d.ts +11 -1
  15. package/build/cjs/sub-blocks/MediaCard/schema.d.ts +11 -1
  16. package/build/cjs/sub-blocks/PriceCard/schema.d.ts +4 -270
  17. package/build/cjs/sub-blocks/PriceCard/schema.js +2 -1
  18. package/build/esm/blocks/Form/Form.css +1 -0
  19. package/build/esm/blocks/Header/schema.d.ts +33 -3
  20. package/build/esm/blocks/HeaderSlider/schema.d.ts +11 -1
  21. package/build/esm/blocks/Media/schema.d.ts +22 -2
  22. package/build/esm/blocks/PromoFeaturesBlock/schema.d.ts +11 -1
  23. package/build/esm/blocks/Tabs/schema.d.ts +11 -1
  24. package/build/esm/components/Media/Iframe/Iframe.css +0 -4
  25. package/build/esm/components/Media/Iframe/Iframe.js +64 -4
  26. package/build/esm/grid/Col/Col.d.ts +1 -1
  27. package/build/esm/models/constructor-items/common.d.ts +4 -2
  28. package/build/esm/schema/constants.d.ts +15 -271
  29. package/build/esm/schema/validators/common.d.ts +11 -1
  30. package/build/esm/schema/validators/common.js +5 -1
  31. package/build/esm/sub-blocks/LayoutItem/schema.d.ts +11 -1
  32. package/build/esm/sub-blocks/MediaCard/schema.d.ts +11 -1
  33. package/build/esm/sub-blocks/PriceCard/schema.d.ts +4 -270
  34. package/build/esm/sub-blocks/PriceCard/schema.js +3 -2
  35. package/package.json +1 -1
  36. package/server/models/constructor-items/common.d.ts +4 -2
  37. package/widget/index.js +1 -1
@@ -266,11 +266,21 @@ export declare const MediaCardBlock: {
266
266
  type: string;
267
267
  };
268
268
  height: {
269
- type: string;
269
+ oneOf: ({
270
+ type: string;
271
+ enum?: undefined;
272
+ } | {
273
+ type: string;
274
+ enum: string[];
275
+ })[];
270
276
  };
271
277
  width: {
272
278
  type: string;
273
279
  };
280
+ justifyContent: {
281
+ type: string;
282
+ enum: string[];
283
+ };
274
284
  };
275
285
  };
276
286
  margins: {
@@ -3,6 +3,10 @@ export declare const PriceCardBlock: {
3
3
  additionalProperties: boolean;
4
4
  required: string[];
5
5
  properties: {
6
+ theme: {
7
+ type: string;
8
+ enum: string[];
9
+ };
6
10
  title: {
7
11
  type: string;
8
12
  };
@@ -394,276 +398,6 @@ export declare const PriceCardBlock: {
394
398
  type: string;
395
399
  };
396
400
  };
397
- animated: {
398
- type: string;
399
- };
400
- color: {
401
- type: string;
402
- };
403
- image: {
404
- oneOf: ({
405
- optionName: string;
406
- oneOf: ({
407
- type: string;
408
- properties: {
409
- when: {
410
- type: string;
411
- };
412
- };
413
- } | {
414
- type: string;
415
- pattern: string;
416
- optionName: string;
417
- })[];
418
- type?: undefined;
419
- items?: undefined;
420
- } | {
421
- type: string;
422
- items: {
423
- oneOf: ({
424
- type: string;
425
- properties: {
426
- when: {
427
- type: string;
428
- };
429
- };
430
- } | {
431
- type: string;
432
- pattern: string;
433
- optionName: string;
434
- })[];
435
- };
436
- optionName: string;
437
- })[];
438
- };
439
- video: {
440
- type: string;
441
- additionalProperties: boolean;
442
- required: string[];
443
- properties: {
444
- src: {
445
- type: string;
446
- items: {
447
- type: string;
448
- };
449
- };
450
- loop: {
451
- oneOf: ({
452
- optionName: string;
453
- type: string;
454
- additionalProperties: boolean;
455
- required: string[];
456
- properties: {
457
- start: {
458
- type: string;
459
- };
460
- end: {
461
- type: string;
462
- };
463
- };
464
- } | {
465
- type: string;
466
- optionName: string;
467
- })[];
468
- };
469
- type: {
470
- type: string;
471
- enum: string[];
472
- };
473
- muted: {
474
- type: string;
475
- };
476
- autoplay: {
477
- type: string;
478
- };
479
- elapsedTime: {
480
- type: string;
481
- };
482
- playButton: {
483
- type: string;
484
- additionalProperties: boolean;
485
- properties: {
486
- type: {
487
- type: string;
488
- enum: string[];
489
- };
490
- theme: {
491
- type: string;
492
- enum: string[];
493
- };
494
- text: {
495
- type: string;
496
- contentType: string;
497
- };
498
- };
499
- };
500
- controls: {
501
- type: string;
502
- enum: import("../..").MediaVideoControlsType[];
503
- };
504
- customControlsOptions: {
505
- type: string;
506
- additionalProperties: boolean;
507
- properties: {
508
- type: {
509
- type: string;
510
- enum: import("../..").CustomControlsType[];
511
- };
512
- muteButtonShown: {
513
- type: string;
514
- };
515
- positioning: {
516
- type: string;
517
- enum: import("../..").CustomControlsButtonPositioning[];
518
- };
519
- };
520
- };
521
- ariaLabel: {
522
- type: string;
523
- };
524
- };
525
- };
526
- youtube: {
527
- type: string;
528
- };
529
- parallax: {
530
- type: string;
531
- };
532
- height: {
533
- type: string;
534
- };
535
- previewImg: {
536
- type: string;
537
- };
538
- dataLens: {
539
- oneOf: ({
540
- type: string;
541
- optionName: string;
542
- } | {
543
- optionName: string;
544
- type: string;
545
- additionalProperties: boolean;
546
- required: string[];
547
- properties: {
548
- id: {
549
- type: string;
550
- };
551
- theme: {
552
- type: string;
553
- enum: string[];
554
- };
555
- };
556
- })[];
557
- };
558
- fullscreen: {
559
- type: string;
560
- };
561
- analyticsEvents: {
562
- anyOf: ({
563
- type: string;
564
- additionalProperties: {
565
- type: string;
566
- };
567
- required: string[];
568
- properties: {
569
- name: {
570
- type: string;
571
- };
572
- type: {
573
- type: string;
574
- };
575
- counters: {
576
- type: string;
577
- additionalProperties: boolean;
578
- required: never[];
579
- properties: {
580
- include: {
581
- type: string;
582
- items: {
583
- type: string;
584
- };
585
- };
586
- exclude: {
587
- type: string;
588
- items: {
589
- type: string;
590
- };
591
- };
592
- };
593
- };
594
- context: {
595
- type: string;
596
- };
597
- };
598
- } | {
599
- type: string;
600
- items: {
601
- type: string;
602
- additionalProperties: {
603
- type: string;
604
- };
605
- required: string[];
606
- properties: {
607
- name: {
608
- type: string;
609
- };
610
- type: {
611
- type: string;
612
- };
613
- counters: {
614
- type: string;
615
- additionalProperties: boolean;
616
- required: never[];
617
- properties: {
618
- include: {
619
- type: string;
620
- items: {
621
- type: string;
622
- };
623
- };
624
- exclude: {
625
- type: string;
626
- items: {
627
- type: string;
628
- };
629
- };
630
- };
631
- };
632
- context: {
633
- type: string;
634
- };
635
- };
636
- };
637
- })[];
638
- };
639
- ratio: {
640
- type: string;
641
- };
642
- iframe: {
643
- type: string;
644
- additionalProperties: boolean;
645
- required: string[];
646
- properties: {
647
- src: {
648
- type: string;
649
- };
650
- name: {
651
- type: string;
652
- };
653
- title: {
654
- type: string;
655
- };
656
- height: {
657
- type: string;
658
- };
659
- width: {
660
- type: string;
661
- };
662
- };
663
- };
664
- margins: {
665
- type: string;
666
- };
667
401
  border: {
668
402
  type: string;
669
403
  enum: string[];
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PriceCardBlock = void 0;
4
4
  const common_1 = require("../../schema/validators/common");
5
+ const schema_1 = require("../Content/schema");
5
6
  exports.PriceCardBlock = {
6
7
  'price-card': {
7
8
  additionalProperties: false,
8
9
  required: ['title', 'price'],
9
- properties: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, common_1.BaseProps), common_1.CardBase), common_1.MediaProps), common_1.AnimatableProps), { title: {
10
+ properties: Object.assign(Object.assign(Object.assign({}, common_1.BaseProps), common_1.CardBase), { theme: schema_1.ContentBase.theme, title: {
10
11
  type: 'string',
11
12
  }, price: {
12
13
  type: 'string',
@@ -27,6 +27,7 @@ unpredictable css rules order in build */
27
27
  height: 100%;
28
28
  width: 100%;
29
29
  object-fit: cover;
30
+ object-position: top;
30
31
  }
31
32
  .pc-form-block__row_direction_form-content {
32
33
  flex-direction: row-reverse;
@@ -266,11 +266,21 @@ export declare const HeaderBackgroundProps: {
266
266
  type: string;
267
267
  };
268
268
  height: {
269
- type: string;
269
+ oneOf: ({
270
+ type: string;
271
+ enum?: undefined;
272
+ } | {
273
+ type: string;
274
+ enum: string[];
275
+ })[];
270
276
  };
271
277
  width: {
272
278
  type: string;
273
279
  };
280
+ justifyContent: {
281
+ type: string;
282
+ enum: string[];
283
+ };
274
284
  };
275
285
  };
276
286
  margins: {
@@ -726,11 +736,21 @@ export declare const HeaderProperties: {
726
736
  type: string;
727
737
  };
728
738
  height: {
729
- type: string;
739
+ oneOf: ({
740
+ type: string;
741
+ enum?: undefined;
742
+ } | {
743
+ type: string;
744
+ enum: string[];
745
+ })[];
730
746
  };
731
747
  width: {
732
748
  type: string;
733
749
  };
750
+ justifyContent: {
751
+ type: string;
752
+ enum: string[];
753
+ };
734
754
  };
735
755
  };
736
756
  margins: {
@@ -1235,11 +1255,21 @@ export declare const HeaderBlock: {
1235
1255
  type: string;
1236
1256
  };
1237
1257
  height: {
1238
- type: string;
1258
+ oneOf: ({
1259
+ type: string;
1260
+ enum?: undefined;
1261
+ } | {
1262
+ type: string;
1263
+ enum: string[];
1264
+ })[];
1239
1265
  };
1240
1266
  width: {
1241
1267
  type: string;
1242
1268
  };
1269
+ justifyContent: {
1270
+ type: string;
1271
+ enum: string[];
1272
+ };
1243
1273
  };
1244
1274
  };
1245
1275
  margins: {
@@ -457,11 +457,21 @@ export declare const HeaderSliderBlock: {
457
457
  type: string;
458
458
  };
459
459
  height: {
460
- type: string;
460
+ oneOf: ({
461
+ type: string;
462
+ enum?: undefined;
463
+ } | {
464
+ type: string;
465
+ enum: string[];
466
+ })[];
461
467
  };
462
468
  width: {
463
469
  type: string;
464
470
  };
471
+ justifyContent: {
472
+ type: string;
473
+ enum: string[];
474
+ };
465
475
  };
466
476
  };
467
477
  margins: {
@@ -260,11 +260,21 @@ export declare const Media: {
260
260
  type: string;
261
261
  };
262
262
  height: {
263
- type: string;
263
+ oneOf: ({
264
+ type: string;
265
+ enum?: undefined;
266
+ } | {
267
+ type: string;
268
+ enum: string[];
269
+ })[];
264
270
  };
265
271
  width: {
266
272
  type: string;
267
273
  };
274
+ justifyContent: {
275
+ type: string;
276
+ enum: string[];
277
+ };
268
278
  };
269
279
  };
270
280
  margins: {
@@ -931,11 +941,21 @@ export declare const MediaBlock: {
931
941
  type: string;
932
942
  };
933
943
  height: {
934
- type: string;
944
+ oneOf: ({
945
+ type: string;
946
+ enum?: undefined;
947
+ } | {
948
+ type: string;
949
+ enum: string[];
950
+ })[];
935
951
  };
936
952
  width: {
937
953
  type: string;
938
954
  };
955
+ justifyContent: {
956
+ type: string;
957
+ enum: string[];
958
+ };
939
959
  };
940
960
  };
941
961
  margins: {
@@ -276,11 +276,21 @@ export declare const PromoFeaturesItem: {
276
276
  type: string;
277
277
  };
278
278
  height: {
279
- type: string;
279
+ oneOf: ({
280
+ type: string;
281
+ enum?: undefined;
282
+ } | {
283
+ type: string;
284
+ enum: string[];
285
+ })[];
280
286
  };
281
287
  width: {
282
288
  type: string;
283
289
  };
290
+ justifyContent: {
291
+ type: string;
292
+ enum: string[];
293
+ };
284
294
  };
285
295
  };
286
296
  margins: {
@@ -271,11 +271,21 @@ export declare const tabsItem: {
271
271
  type: string;
272
272
  };
273
273
  height: {
274
- type: string;
274
+ oneOf: ({
275
+ type: string;
276
+ enum?: undefined;
277
+ } | {
278
+ type: string;
279
+ enum: string[];
280
+ })[];
275
281
  };
276
282
  width: {
277
283
  type: string;
278
284
  };
285
+ justifyContent: {
286
+ type: string;
287
+ enum: string[];
288
+ };
279
289
  };
280
290
  };
281
291
  margins: {
@@ -11,8 +11,4 @@ unpredictable css rules order in build */
11
11
  }
12
12
  .pc-media-component-iframe .pc-media-component-iframe__iframe {
13
13
  border-radius: 0;
14
- }
15
- .pc-media-component-iframe__item {
16
- width: 100%;
17
- height: 100%;
18
14
  }
@@ -1,12 +1,72 @@
1
- import React from 'react';
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { v4 as uuidv4 } from 'uuid';
2
3
  import { block } from '../../../utils';
3
4
  import i18n from './i18n';
4
5
  import './Iframe.css';
5
6
  const b = block('media-component-iframe');
6
7
  const Iframe = (props) => {
7
8
  const { iframe, margins = true } = props;
8
- const { height = 400, src, width, name, title } = iframe;
9
- return iframe ? (React.createElement("div", { className: b({ margins }), style: { height } },
10
- React.createElement("iframe", { className: b('item'), loading: "lazy", title: title || i18n('iframe-title'), frameBorder: 0, src: src, width: width, height: height, name: name }))) : null;
9
+ const { height = 400, src, width = '100%', name, title, justifyContent = 'center' } = iframe;
10
+ const formContainerRef = useRef(null);
11
+ const iframeRef = useRef();
12
+ const [iframeId] = useState(uuidv4());
13
+ const updateFormIframe = useCallback((container) => {
14
+ if (iframeRef.current) {
15
+ iframeRef.current.src = src;
16
+ }
17
+ else {
18
+ const iframeWidth = typeof width === 'number' ? `${width}px` : width;
19
+ let iframeHeight = typeof height === 'number' ? `${height}px` : height;
20
+ if (height === 'auto') {
21
+ iframeHeight = undefined;
22
+ }
23
+ iframeRef.current = document.createElement('iframe');
24
+ iframeRef.current.src = src;
25
+ iframeRef.current.id = iframeId;
26
+ iframeRef.current.name = name || iframeId;
27
+ iframeRef.current.setAttribute('loading', 'lazy');
28
+ iframeRef.current.setAttribute('title', title || i18n('iframe-title'));
29
+ iframeRef.current.frameBorder = '0';
30
+ iframeRef.current.scrolling = 'no';
31
+ iframeRef.current.width = iframeWidth;
32
+ iframeRef.current.style.width = iframeWidth;
33
+ if (iframeHeight) {
34
+ iframeRef.current.style.height = iframeHeight;
35
+ }
36
+ container.appendChild(iframeRef.current);
37
+ }
38
+ }, [src, width, iframeId, name, title, height]);
39
+ const handleMessage = useCallback(({ data }) => {
40
+ if (height !== 'auto' && typeof height === 'number' && iframeRef.current) {
41
+ iframeRef.current.height = `${height}px`;
42
+ return;
43
+ }
44
+ try {
45
+ const parsed = JSON.parse(data);
46
+ const iframeHeight = parsed['iframe-height'];
47
+ const { message, name: iframeName } = parsed;
48
+ if (iframeName !== name && iframeName !== iframeId) {
49
+ return;
50
+ }
51
+ if (iframeRef.current && iframeHeight && !message) {
52
+ iframeRef.current.height = `${iframeHeight}px`;
53
+ }
54
+ }
55
+ catch (error) {
56
+ return;
57
+ }
58
+ }, [height, iframeId, name]);
59
+ const addIframe = useCallback(() => {
60
+ const container = formContainerRef.current;
61
+ if (container) {
62
+ updateFormIframe(container);
63
+ window.addEventListener('message', handleMessage, { passive: true });
64
+ }
65
+ }, [updateFormIframe, handleMessage]);
66
+ useEffect(() => {
67
+ addIframe();
68
+ return () => window.removeEventListener('message', handleMessage);
69
+ }, [addIframe, handleMessage]);
70
+ return iframe ? (React.createElement("div", { className: b({ margins }), ref: formContainerRef, style: { height, textAlign: justifyContent } })) : null;
11
71
  };
12
72
  export default Iframe;
@@ -5,4 +5,4 @@ export interface GridColumnProps extends GridColumnClassParams, Refable<HTMLDivE
5
5
  style?: CSSProperties;
6
6
  children?: React.ReactNode;
7
7
  }
8
- export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "sizes" | "className" | "hidden" | "role" | "qa" | "reset" | "visible" | "offsets" | "orders" | "alignSelf" | "justifyContent"> & React.RefAttributes<HTMLDivElement>>;
8
+ export declare const Col: React.ForwardRefExoticComponent<Pick<WithChildren<GridColumnProps>, "style" | "children" | "sizes" | "className" | "hidden" | "role" | "qa" | "reset" | "visible" | "justifyContent" | "offsets" | "orders" | "alignSelf"> & React.RefAttributes<HTMLDivElement>>;
@@ -257,12 +257,14 @@ export interface DataLensObjectProps {
257
257
  id: string;
258
258
  theme: 'dark' | 'light';
259
259
  }
260
+ export type JustifyValues = 'left' | 'right' | 'center';
260
261
  export interface IframeProps {
261
262
  src: string;
262
- width?: number;
263
- height?: number;
263
+ width?: number | string;
264
+ height?: number | string;
264
265
  title?: string;
265
266
  name?: string;
267
+ justifyContent?: JustifyValues;
266
268
  }
267
269
  export type DataLensProps = string | DataLensObjectProps;
268
270
  export interface AuthorItem {