@gravity-ui/page-constructor 2.1.1 → 2.2.1-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 (135) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/cjs/blocks/index.d.ts +0 -2
  3. package/build/cjs/blocks/index.js +1 -5
  4. package/build/cjs/blocks/validators.d.ts +0 -2
  5. package/build/cjs/blocks/validators.js +0 -2
  6. package/build/cjs/components/HTML/HTML.d.ts +1 -1
  7. package/build/cjs/components/ReactPlayer/ReactPlayer.js +3 -1
  8. package/build/cjs/components/ReactPlayer/utils.d.ts +1 -0
  9. package/build/cjs/components/ReactPlayer/utils.js +24 -0
  10. package/build/cjs/constructor-items.d.ts +0 -6
  11. package/build/cjs/constructor-items.js +0 -6
  12. package/build/cjs/hooks/index.d.ts +0 -1
  13. package/build/cjs/hooks/index.js +1 -3
  14. package/build/cjs/models/constructor-items/blocks.d.ts +2 -23
  15. package/build/cjs/models/constructor-items/blocks.js +0 -2
  16. package/build/cjs/models/constructor-items/common.d.ts +0 -14
  17. package/build/cjs/models/constructor-items/common.js +1 -6
  18. package/build/cjs/models/constructor-items/sub-blocks.d.ts +9 -25
  19. package/build/cjs/models/constructor-items/sub-blocks.js +6 -7
  20. package/build/cjs/schema/index.js +2 -4
  21. package/build/cjs/schema/validators/blocks.d.ts +0 -2
  22. package/build/cjs/schema/validators/blocks.js +0 -2
  23. package/build/cjs/schema/validators/sub-blocks.d.ts +0 -1
  24. package/build/cjs/schema/validators/sub-blocks.js +0 -1
  25. package/build/cjs/sub-blocks/HubspotForm/HubspotForm.css +0 -1
  26. package/build/cjs/sub-blocks/index.d.ts +0 -1
  27. package/build/cjs/sub-blocks/index.js +1 -3
  28. package/build/cjs/text-transform/blocks.js +0 -32
  29. package/build/cjs/utils/index.d.ts +0 -1
  30. package/build/cjs/utils/index.js +0 -1
  31. package/build/esm/blocks/index.d.ts +0 -2
  32. package/build/esm/blocks/index.js +0 -2
  33. package/build/esm/blocks/validators.d.ts +0 -2
  34. package/build/esm/blocks/validators.js +0 -2
  35. package/build/esm/components/HTML/HTML.d.ts +1 -1
  36. package/build/esm/components/ReactPlayer/ReactPlayer.js +3 -1
  37. package/build/esm/components/ReactPlayer/utils.d.ts +1 -0
  38. package/build/esm/components/ReactPlayer/utils.js +20 -0
  39. package/build/esm/constructor-items.d.ts +0 -6
  40. package/build/esm/constructor-items.js +2 -8
  41. package/build/esm/hooks/index.d.ts +0 -1
  42. package/build/esm/hooks/index.js +0 -1
  43. package/build/esm/models/constructor-items/blocks.d.ts +2 -23
  44. package/build/esm/models/constructor-items/blocks.js +0 -2
  45. package/build/esm/models/constructor-items/common.d.ts +0 -14
  46. package/build/esm/models/constructor-items/common.js +0 -5
  47. package/build/esm/models/constructor-items/sub-blocks.d.ts +9 -25
  48. package/build/esm/models/constructor-items/sub-blocks.js +6 -7
  49. package/build/esm/schema/index.js +4 -6
  50. package/build/esm/schema/validators/blocks.d.ts +0 -2
  51. package/build/esm/schema/validators/blocks.js +0 -2
  52. package/build/esm/schema/validators/sub-blocks.d.ts +0 -1
  53. package/build/esm/schema/validators/sub-blocks.js +0 -1
  54. package/build/esm/sub-blocks/HubspotForm/HubspotForm.css +0 -1
  55. package/build/esm/sub-blocks/index.d.ts +0 -1
  56. package/build/esm/sub-blocks/index.js +0 -1
  57. package/build/esm/text-transform/blocks.js +0 -32
  58. package/build/esm/utils/index.d.ts +0 -1
  59. package/build/esm/utils/index.js +0 -1
  60. package/package.json +5 -2
  61. package/server/models/constructor-items/blocks.d.ts +2 -23
  62. package/server/models/constructor-items/blocks.js +0 -2
  63. package/server/models/constructor-items/common.d.ts +0 -14
  64. package/server/models/constructor-items/common.js +1 -6
  65. package/server/models/constructor-items/sub-blocks.d.ts +9 -25
  66. package/server/models/constructor-items/sub-blocks.js +6 -7
  67. package/server/text-transform/blocks.js +0 -32
  68. package/server/utils/index.d.ts +0 -1
  69. package/server/utils/index.js +0 -1
  70. package/build/cjs/blocks/Preview/MediaContent/MediaContent.css +0 -50
  71. package/build/cjs/blocks/Preview/MediaContent/MediaContent.d.ts +0 -13
  72. package/build/cjs/blocks/Preview/MediaContent/MediaContent.js +0 -49
  73. package/build/cjs/blocks/Preview/MediaContent/PreviewContent.css +0 -106
  74. package/build/cjs/blocks/Preview/MediaContent/PreviewContent.d.ts +0 -11
  75. package/build/cjs/blocks/Preview/MediaContent/PreviewContent.js +0 -17
  76. package/build/cjs/blocks/Preview/MediaContent/PreviewMedia.css +0 -54
  77. package/build/cjs/blocks/Preview/MediaContent/PreviewMedia.d.ts +0 -9
  78. package/build/cjs/blocks/Preview/MediaContent/PreviewMedia.js +0 -13
  79. package/build/cjs/blocks/Preview/Preview.css +0 -50
  80. package/build/cjs/blocks/Preview/Preview.d.ts +0 -3
  81. package/build/cjs/blocks/Preview/Preview.js +0 -130
  82. package/build/cjs/blocks/Preview/schema.d.ts +0 -40
  83. package/build/cjs/blocks/Preview/schema.js +0 -53
  84. package/build/cjs/blocks/Simple/Simple.css +0 -22
  85. package/build/cjs/blocks/Simple/Simple.d.ts +0 -3
  86. package/build/cjs/blocks/Simple/Simple.js +0 -22
  87. package/build/cjs/blocks/Simple/schema.d.ts +0 -68
  88. package/build/cjs/blocks/Simple/schema.js +0 -14
  89. package/build/cjs/context/breakpointContext/breakpointContext.d.ts +0 -2
  90. package/build/cjs/context/breakpointContext/breakpointContext.js +0 -7
  91. package/build/cjs/context/breakpointContext/index.d.ts +0 -1
  92. package/build/cjs/context/breakpointContext/index.js +0 -4
  93. package/build/cjs/hooks/useIntersection.d.ts +0 -1
  94. package/build/cjs/hooks/useIntersection.js +0 -21
  95. package/build/cjs/sub-blocks/CardWithImage/CardWithImage.css +0 -19
  96. package/build/cjs/sub-blocks/CardWithImage/CardWithImage.d.ts +0 -3
  97. package/build/cjs/sub-blocks/CardWithImage/CardWithImage.js +0 -16
  98. package/build/cjs/sub-blocks/CardWithImage/schema.d.ts +0 -154
  99. package/build/cjs/sub-blocks/CardWithImage/schema.js +0 -46
  100. package/build/cjs/utils/scroll.d.ts +0 -15
  101. package/build/cjs/utils/scroll.js +0 -34
  102. package/build/esm/blocks/Preview/MediaContent/MediaContent.css +0 -50
  103. package/build/esm/blocks/Preview/MediaContent/MediaContent.d.ts +0 -14
  104. package/build/esm/blocks/Preview/MediaContent/MediaContent.js +0 -47
  105. package/build/esm/blocks/Preview/MediaContent/PreviewContent.css +0 -106
  106. package/build/esm/blocks/Preview/MediaContent/PreviewContent.d.ts +0 -12
  107. package/build/esm/blocks/Preview/MediaContent/PreviewContent.js +0 -15
  108. package/build/esm/blocks/Preview/MediaContent/PreviewMedia.css +0 -54
  109. package/build/esm/blocks/Preview/MediaContent/PreviewMedia.d.ts +0 -10
  110. package/build/esm/blocks/Preview/MediaContent/PreviewMedia.js +0 -11
  111. package/build/esm/blocks/Preview/Preview.css +0 -50
  112. package/build/esm/blocks/Preview/Preview.d.ts +0 -4
  113. package/build/esm/blocks/Preview/Preview.js +0 -126
  114. package/build/esm/blocks/Preview/schema.d.ts +0 -40
  115. package/build/esm/blocks/Preview/schema.js +0 -50
  116. package/build/esm/blocks/Simple/Simple.css +0 -22
  117. package/build/esm/blocks/Simple/Simple.d.ts +0 -4
  118. package/build/esm/blocks/Simple/Simple.js +0 -18
  119. package/build/esm/blocks/Simple/schema.d.ts +0 -68
  120. package/build/esm/blocks/Simple/schema.js +0 -11
  121. package/build/esm/context/breakpointContext/breakpointContext.d.ts +0 -2
  122. package/build/esm/context/breakpointContext/breakpointContext.js +0 -3
  123. package/build/esm/context/breakpointContext/index.d.ts +0 -1
  124. package/build/esm/context/breakpointContext/index.js +0 -1
  125. package/build/esm/hooks/useIntersection.d.ts +0 -1
  126. package/build/esm/hooks/useIntersection.js +0 -17
  127. package/build/esm/sub-blocks/CardWithImage/CardWithImage.css +0 -19
  128. package/build/esm/sub-blocks/CardWithImage/CardWithImage.d.ts +0 -4
  129. package/build/esm/sub-blocks/CardWithImage/CardWithImage.js +0 -14
  130. package/build/esm/sub-blocks/CardWithImage/schema.d.ts +0 -154
  131. package/build/esm/sub-blocks/CardWithImage/schema.js +0 -43
  132. package/build/esm/utils/scroll.d.ts +0 -15
  133. package/build/esm/utils/scroll.js +0 -30
  134. package/server/utils/scroll.d.ts +0 -15
  135. package/server/utils/scroll.js +0 -34
@@ -1,126 +0,0 @@
1
- import { block, doSmoothScroll } from '../../utils';
2
- import React, { useCallback, useContext, useEffect, useState } from 'react';
3
- import { BreakpointContext } from '../../context/breakpointContext';
4
- import AnimateBlock from '../../components/AnimateBlock/AnimateBlock';
5
- import MediaContent from './MediaContent/MediaContent';
6
- import { Row } from '../../grid';
7
- import { BREAKPOINTS } from '../../constants';
8
- import { useIntersection } from '../../hooks/useIntersection';
9
- import './Preview.css';
10
- const b = block('preview-block');
11
- const SWITCHING_INTERVAL = 5 * 1000;
12
- const WIDTH_MENU_ITEM_MD_SIZE = 275;
13
- const INDENT_MENU_ITEM_MD_SIZE = 16;
14
- const SCROLL_ITEM_SECONDS = 1;
15
- const SCROLL_ITEM_SPEED = 2;
16
- const CLASSNAME_DESCRIPTION_YFM_BLOCK = 'yfm';
17
- const CLASSNAME_CONTENT_WRAPPER = 'preview-media-content-block__content-wrapper';
18
- const INDENT_BETWEEN_TITLE_DESCRIPTION = 16;
19
- export const PreviewBlock = (props) => {
20
- const { direction = 'content-media', animated, items, title, description, ratioMediaContent = '1-1', stopVideo = false,
21
- // TODO YDB-server doesn't see previewRef.current and doesn't update the component CLOUDFRONT-9395
22
- showImmediately = false, } = props;
23
- const breakpoint = useContext(BreakpointContext);
24
- const isDesktop = breakpoint >= BREAKPOINTS.md;
25
- const menuRef = React.useRef(null);
26
- const previewRef = React.useRef(null);
27
- const inViewport = useIntersection(previewRef.current);
28
- const [stopSwitching, setStopSwitching] = useState(stopVideo);
29
- const [activeSlide, setActiveSlide] = useState(-1);
30
- const [autoSwitchTimerId, setAutoSwitchTimerId] = useState(0);
31
- const isActiveBlock = useCallback((id, isMediaBlock = false) => {
32
- return isMediaBlock || inViewport ? activeSlide === id : false;
33
- }, [inViewport, activeSlide]);
34
- const changeActiveSlide = useCallback((params) => {
35
- const { current, nextSlide, currentSlide, timerId } = params;
36
- if (isDesktop) {
37
- changeDescriptionHeight(current, nextSlide, currentSlide);
38
- }
39
- else {
40
- changeMenuScroll(current, nextSlide, currentSlide);
41
- }
42
- setActiveSlide(nextSlide);
43
- clearTimeout(timerId);
44
- }, [isDesktop]);
45
- useEffect(() => {
46
- // TODO YDB-server doesn't see previewRef.current and doesn't update the component CLOUDFRONT-9395
47
- if (!items[activeSlide] && (showImmediately || inViewport)) {
48
- setActiveSlide(0);
49
- if (isDesktop) {
50
- changeDescriptionHeight(menuRef.current, 0);
51
- }
52
- }
53
- }, [inViewport, activeSlide, isDesktop, items, showImmediately]);
54
- useEffect(() => {
55
- if (stopSwitching || !inViewport) {
56
- return () => { };
57
- }
58
- const timerId = setTimeout(() => {
59
- if (stopSwitching) {
60
- clearTimeout(timerId);
61
- return;
62
- }
63
- const nextSlide = activeSlide + 1 >= items.length ? 0 : activeSlide + 1;
64
- changeActiveSlide({
65
- current: menuRef.current,
66
- nextSlide,
67
- currentSlide: activeSlide,
68
- timerId: timerId,
69
- });
70
- }, SWITCHING_INTERVAL);
71
- setAutoSwitchTimerId(timerId);
72
- return () => clearTimeout(timerId);
73
- }, [changeActiveSlide, activeSlide, items.length, stopSwitching, inViewport]);
74
- const showMediaContent = useCallback((nextSlide) => {
75
- changeActiveSlide({
76
- current: menuRef.current,
77
- nextSlide,
78
- currentSlide: activeSlide,
79
- timerId: autoSwitchTimerId,
80
- });
81
- setStopSwitching(true);
82
- }, [changeActiveSlide, activeSlide, autoSwitchTimerId]);
83
- return (React.createElement(AnimateBlock, { className: b(), animate: animated },
84
- React.createElement(Row, { ref: previewRef, className: b('row', { reverse: direction === 'media-content' }) },
85
- React.createElement(MediaContent, { ref: menuRef, items: items, title: title, description: description, ratioMediaContent: ratioMediaContent, switching: !stopSwitching, isActiveBlock: isActiveBlock, showMediaContent: showMediaContent }))));
86
- };
87
- function changeMenuScroll(element, nextSlide, activeSlide) {
88
- if (!element) {
89
- return;
90
- }
91
- const scrollPosition = element.scrollLeft;
92
- const endPosition = nextSlide === 0 ? 0 : nextSlide * WIDTH_MENU_ITEM_MD_SIZE + INDENT_MENU_ITEM_MD_SIZE;
93
- const distance = Math.abs(scrollPosition - endPosition);
94
- const isReverse = nextSlide === 0 || nextSlide < activeSlide;
95
- const scrollOptions = {
96
- distance,
97
- timeSeconds: SCROLL_ITEM_SECONDS,
98
- speed: SCROLL_ITEM_SPEED,
99
- reverseParams: isReverse ? { distance } : undefined,
100
- };
101
- doSmoothScroll(element, scrollPosition, scrollOptions);
102
- }
103
- function changeDescriptionHeight(element, nextActiveSlide, prevActiveSlide = 0) {
104
- const contentWrapper = element === null || element === void 0 ? void 0 : element.getElementsByClassName(CLASSNAME_CONTENT_WRAPPER);
105
- if (!contentWrapper || contentWrapper.length === 0) {
106
- return;
107
- }
108
- const menuItems = contentWrapper[0].children;
109
- updateHeight(menuItems, nextActiveSlide);
110
- if (nextActiveSlide !== prevActiveSlide) {
111
- updateHeight(menuItems, prevActiveSlide, false);
112
- }
113
- }
114
- function updateHeight(menuItems, slide, isExpand = true) {
115
- const item = menuItems[slide];
116
- const yfmBlock = item.getElementsByClassName(CLASSNAME_DESCRIPTION_YFM_BLOCK)[0];
117
- if (yfmBlock) {
118
- const yfmBlockElement = yfmBlock;
119
- const yfmBlockHeight = yfmBlockElement.offsetHeight;
120
- const yfmBlockOffsetParent = yfmBlockElement.offsetParent;
121
- yfmBlockOffsetParent.style.height = isExpand
122
- ? `${yfmBlockHeight + INDENT_BETWEEN_TITLE_DESCRIPTION}px`
123
- : '0px';
124
- }
125
- }
126
- export default PreviewBlock;
@@ -1,40 +0,0 @@
1
- export declare const PreviewBlock: {
2
- 'preview-block': {
3
- additionalProperties: boolean;
4
- required: string[];
5
- properties: {
6
- title: {
7
- type: string;
8
- contentType: string;
9
- };
10
- description: {
11
- type: string;
12
- contentType: string;
13
- };
14
- direction: {
15
- type: string;
16
- enum: string[];
17
- };
18
- ratioMediaContent: {
19
- type: string;
20
- enum: string[];
21
- };
22
- items: {
23
- type: string;
24
- items: {
25
- type: string;
26
- properties: {
27
- when: {
28
- type: string;
29
- };
30
- };
31
- };
32
- };
33
- animated: {
34
- type: string;
35
- };
36
- type: {};
37
- when: {};
38
- };
39
- };
40
- };
@@ -1,50 +0,0 @@
1
- import { filteredArray } from '../../schema/validators/utils';
2
- import { AnimatableProps, BaseProps, mediaDirection, withTheme, } from '../../schema/validators/common';
3
- import { Media } from '../Media/schema';
4
- const previewRatioMediaContent = ['2-1', '1-1'];
5
- const PreviewContentItem = {
6
- additionalProperties: false,
7
- required: ['title', 'description'],
8
- properties: {
9
- title: {
10
- type: 'string',
11
- contentType: 'text',
12
- },
13
- description: {
14
- type: 'string',
15
- contentType: 'yfm',
16
- },
17
- },
18
- };
19
- const PreviewItem = {
20
- type: 'object',
21
- additionalProperties: false,
22
- required: ['type', 'media', 'content'],
23
- properties: {
24
- type: {
25
- type: 'string',
26
- enum: ['video', 'image'],
27
- },
28
- media: withTheme(Media),
29
- content: PreviewContentItem,
30
- },
31
- };
32
- export const PreviewBlock = {
33
- 'preview-block': {
34
- additionalProperties: false,
35
- required: ['title', 'items'],
36
- properties: Object.assign(Object.assign(Object.assign({}, BaseProps), AnimatableProps), { title: {
37
- type: 'string',
38
- contentType: 'text',
39
- }, description: {
40
- type: 'string',
41
- contentType: 'yfm',
42
- }, direction: {
43
- type: 'string',
44
- enum: mediaDirection,
45
- }, ratioMediaContent: {
46
- type: 'string',
47
- enum: previewRatioMediaContent,
48
- }, items: filteredArray(PreviewItem) }),
49
- },
50
- };
@@ -1,22 +0,0 @@
1
- /* use this for style redefinitions to awoid problems with
2
- unpredictable css rules order in build */
3
- @media (min-width: 769px) {
4
- .pc-simple-block.pc-AnimateBlock .pc-simple-block__animate-block, .pc-AnimateBlock .pc-simple-block .pc-simple-block__animate-block {
5
- position: relative;
6
- top: 100px;
7
- opacity: 0;
8
- }
9
- .pc-simple-block.pc-AnimateBlock.animate .pc-simple-block__animate-block, .pc-AnimateBlock .pc-simple-block.animate .pc-simple-block__animate-block {
10
- top: 0;
11
- opacity: 1;
12
- transition: top 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
13
- transition-delay: 0.5s;
14
- }
15
- }
16
- .pc-simple-block__animate-block {
17
- margin-top: 20px;
18
- }
19
- .pc-simple-block__description {
20
- margin-top: 16px;
21
- font-size: var(--yc-text-body-2-font-size);
22
- }
@@ -1,4 +0,0 @@
1
- import { SimpleBlockProps, WithChildren } from '../../models';
2
- import './Simple.css';
3
- export declare const SimpleBlock: (props: WithChildren<SimpleBlockProps>) => JSX.Element;
4
- export default SimpleBlock;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { block } from '../../utils';
3
- import AnimateBlock from '../../components/AnimateBlock/AnimateBlock';
4
- import BlockHeader from '../../components/BlockHeader/BlockHeader';
5
- import YFMWrapper from '../../components/YFMWrapper/YFMWrapper';
6
- import './Simple.css';
7
- const b = block('simple-block');
8
- export const SimpleBlock = (props) => {
9
- const { title, description, animated = true, children } = props;
10
- const blockHeader = title && React.createElement(BlockHeader, { title: title });
11
- return (React.createElement(AnimateBlock, { className: b(), animate: animated },
12
- React.createElement("div", null,
13
- blockHeader,
14
- React.createElement("div", { className: b('description') },
15
- React.createElement(YFMWrapper, { content: description, modifiers: { constructor: true } })),
16
- React.createElement("div", { className: b('animate-block') }, children))));
17
- };
18
- export default SimpleBlock;
@@ -1,68 +0,0 @@
1
- export declare const SimpleBlock: {
2
- 'simple-block': {
3
- additionalProperties: boolean;
4
- required: string[];
5
- properties: {
6
- children: {
7
- type: string;
8
- items: {
9
- $ref: string;
10
- };
11
- };
12
- animated: {
13
- type: string;
14
- };
15
- anchor: {
16
- type: string;
17
- additionalProperties: boolean;
18
- required: string[];
19
- properties: {
20
- text: {
21
- type: string;
22
- contentType: string;
23
- };
24
- url: {
25
- type: string;
26
- };
27
- };
28
- };
29
- visible: {
30
- type: string;
31
- enum: string[];
32
- };
33
- resetPaddings: {
34
- type: string;
35
- };
36
- context: {
37
- type: string;
38
- };
39
- type: {};
40
- when: {};
41
- title: {
42
- type: string;
43
- additionalProperties: boolean;
44
- required: string[];
45
- properties: {
46
- text: {
47
- type: string;
48
- contentType: string;
49
- };
50
- textSize: {
51
- type: string;
52
- enum: string[];
53
- };
54
- url: {
55
- type: string;
56
- };
57
- resetMargin: {
58
- type: string;
59
- };
60
- };
61
- };
62
- description: {
63
- type: string;
64
- contentType: string;
65
- };
66
- };
67
- };
68
- };
@@ -1,11 +0,0 @@
1
- import { BlockBaseProps, TitleProps, AnimatableProps, ChildrenProps, } from '../../schema/validators/common';
2
- export const SimpleBlock = {
3
- 'simple-block': {
4
- additionalProperties: false,
5
- required: ['title', 'description'],
6
- properties: Object.assign(Object.assign(Object.assign({ title: TitleProps, description: {
7
- type: 'string',
8
- contentType: 'yfm',
9
- } }, BlockBaseProps), AnimatableProps), { children: ChildrenProps }),
10
- },
11
- };
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const BreakpointContext: React.Context<number>;
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import { BREAKPOINTS } from '../../constants';
3
- export const BreakpointContext = React.createContext(BREAKPOINTS.sm);
@@ -1 +0,0 @@
1
- export * from './breakpointContext';
@@ -1 +0,0 @@
1
- export * from './breakpointContext';
@@ -1 +0,0 @@
1
- export declare const useIntersection: (element?: Element, startMargin?: string, threshold?: number) => boolean;
@@ -1,17 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- export const useIntersection = (element, startMargin = '0px', threshold = 0.2) => {
3
- const [isVisible, setState] = useState(false);
4
- useEffect(() => {
5
- const observer = new IntersectionObserver(([entry]) => {
6
- setState(entry.isIntersecting);
7
- }, {
8
- rootMargin: startMargin,
9
- threshold,
10
- });
11
- if (element) {
12
- observer.observe(element);
13
- }
14
- return () => element && observer.unobserve(element);
15
- }, [element, startMargin, threshold]);
16
- return isVisible;
17
- };
@@ -1,19 +0,0 @@
1
- /* use this for style redefinitions to awoid problems with
2
- unpredictable css rules order in build */
3
- .pc-card-with-image__content {
4
- padding-right: 16px;
5
- }
6
- .pc-card-with-image__image {
7
- width: 100%;
8
- display: block;
9
- margin-bottom: 16px;
10
- border-radius: var(--pc-border-radius);
11
- }
12
- .pc-card-with-image__image_border {
13
- border: 1px solid var(--yc-color-line-generic);
14
- }
15
- .pc-card-with-image__image-item {
16
- width: 100%;
17
- display: block;
18
- border-radius: var(--pc-border-radius);
19
- }
@@ -1,4 +0,0 @@
1
- import { CardWithImageProps } from '../../models';
2
- import './CardWithImage.css';
3
- declare const CardWithImage: ({ title, description, image, disableCompress, links, border, fullScreen, className, additionalInfo, buttons, }: CardWithImageProps) => JSX.Element;
4
- export default CardWithImage;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { block } from '../../utils';
3
- import { Image, FullscreenImage } from '../../components';
4
- import { Content } from '../';
5
- import './CardWithImage.css';
6
- const b = block('card-with-image');
7
- const CardWithImage = ({ title, description, image, disableCompress, links, border, fullScreen, className, additionalInfo, buttons, }) => {
8
- const unifiedLinks = links === null || links === void 0 ? void 0 : links.map((link) => (Object.assign(Object.assign({ theme: 'normal' }, link), { text: link.title, url: link.link })));
9
- return (React.createElement("div", { className: b(null, className) },
10
- React.createElement("div", { className: b('image', { border }) }, fullScreen ? (React.createElement(FullscreenImage, { src: image, imageClassName: b('image-item'), disableCompress: disableCompress })) : (React.createElement(Image, { className: b('image-item'), src: image, alt: 'card-image', disableCompress: disableCompress }))),
11
- React.createElement("div", { className: b('content') },
12
- React.createElement(Content, { title: title, text: description, links: unifiedLinks, additionalInfo: additionalInfo, buttons: buttons, size: "s", colSizes: { all: 12, md: 12 } }))));
13
- };
14
- export default CardWithImage;
@@ -1,154 +0,0 @@
1
- export declare const CardWithImageItem: {
2
- additionalProperties: boolean;
3
- required: string[];
4
- properties: {
5
- image: {
6
- type: string;
7
- };
8
- description: {
9
- type: string;
10
- contentType: string;
11
- };
12
- disableCompress: {
13
- type: string;
14
- };
15
- border: {
16
- type: string;
17
- };
18
- fullScreen: {
19
- type: string;
20
- };
21
- links: {
22
- type: string;
23
- items: {
24
- type: string;
25
- properties: {
26
- when: {
27
- type: string;
28
- };
29
- };
30
- };
31
- };
32
- title: {
33
- oneOf: ({
34
- type: string;
35
- additionalProperties: boolean;
36
- required: string[];
37
- properties: {
38
- text: {
39
- type: string;
40
- contentType: string;
41
- };
42
- textSize: {
43
- type: string;
44
- enum: string[];
45
- };
46
- url: {
47
- type: string;
48
- };
49
- resetMargin: {
50
- type: string;
51
- };
52
- };
53
- } | {
54
- type: string;
55
- contentType: string;
56
- })[];
57
- };
58
- additionalInfo: {
59
- type: string;
60
- contentType: string;
61
- };
62
- buttons: {
63
- type: string;
64
- items: {
65
- type: string;
66
- properties: {
67
- when: {
68
- type: string;
69
- };
70
- };
71
- };
72
- };
73
- type: {};
74
- when: {};
75
- };
76
- };
77
- export declare const CardWithImage: {
78
- 'card-with-image': {
79
- additionalProperties: boolean;
80
- required: string[];
81
- properties: {
82
- image: {
83
- type: string;
84
- };
85
- description: {
86
- type: string;
87
- contentType: string;
88
- };
89
- disableCompress: {
90
- type: string;
91
- };
92
- border: {
93
- type: string;
94
- };
95
- fullScreen: {
96
- type: string;
97
- };
98
- links: {
99
- type: string;
100
- items: {
101
- type: string;
102
- properties: {
103
- when: {
104
- type: string;
105
- };
106
- };
107
- };
108
- };
109
- title: {
110
- oneOf: ({
111
- type: string;
112
- additionalProperties: boolean;
113
- required: string[];
114
- properties: {
115
- text: {
116
- type: string;
117
- contentType: string;
118
- };
119
- textSize: {
120
- type: string;
121
- enum: string[];
122
- };
123
- url: {
124
- type: string;
125
- };
126
- resetMargin: {
127
- type: string;
128
- };
129
- };
130
- } | {
131
- type: string;
132
- contentType: string;
133
- })[];
134
- };
135
- additionalInfo: {
136
- type: string;
137
- contentType: string;
138
- };
139
- buttons: {
140
- type: string;
141
- items: {
142
- type: string;
143
- properties: {
144
- when: {
145
- type: string;
146
- };
147
- };
148
- };
149
- };
150
- type: {};
151
- when: {};
152
- };
153
- };
154
- };
@@ -1,43 +0,0 @@
1
- import { omit } from 'lodash';
2
- import { BaseProps, textSize } from '../../schema/validators/common';
3
- import { filteredArray } from '../../schema/validators/utils';
4
- import { ContentBase } from '../../sub-blocks/Content/schema';
5
- const CardWithImageContentProps = omit(ContentBase, ['links', 'size', 'text', 'theme']);
6
- const CardWithImageLinks = {
7
- type: 'object',
8
- additionalProperties: false,
9
- required: ['title', 'link'],
10
- properties: Object.assign(Object.assign({}, BaseProps), { title: {
11
- type: 'string',
12
- contentType: 'text',
13
- }, link: {
14
- type: 'string',
15
- }, arrow: {
16
- type: 'boolean',
17
- }, theme: {
18
- type: 'string',
19
- enum: ['back', 'file-link', 'normal'],
20
- }, textSize: {
21
- type: 'string',
22
- enum: textSize,
23
- } }),
24
- };
25
- export const CardWithImageItem = {
26
- additionalProperties: false,
27
- required: ['image'],
28
- properties: Object.assign(Object.assign(Object.assign({}, BaseProps), CardWithImageContentProps), { image: {
29
- type: 'string',
30
- }, description: {
31
- type: 'string',
32
- contentType: 'yfm',
33
- }, disableCompress: {
34
- type: 'boolean',
35
- }, border: {
36
- type: 'boolean',
37
- }, fullScreen: {
38
- type: 'boolean',
39
- }, links: filteredArray(CardWithImageLinks) }),
40
- };
41
- export const CardWithImage = {
42
- 'card-with-image': CardWithImageItem,
43
- };
@@ -1,15 +0,0 @@
1
- export declare enum ScrollDirection {
2
- HORIZONTAL = "scrollLeft",
3
- VERTICAL = "scrollTop"
4
- }
5
- export interface ScrollReverseParams {
6
- distance?: number;
7
- }
8
- export interface ScrollOptions {
9
- distance: number;
10
- timeSeconds: number;
11
- speed: number;
12
- direction?: ScrollDirection;
13
- reverseParams?: ScrollReverseParams;
14
- }
15
- export declare function doSmoothScroll(element: HTMLDivElement, startPosition: number, scrollOptions: ScrollOptions): void;
@@ -1,30 +0,0 @@
1
- export var ScrollDirection;
2
- (function (ScrollDirection) {
3
- ScrollDirection["HORIZONTAL"] = "scrollLeft";
4
- ScrollDirection["VERTICAL"] = "scrollTop";
5
- })(ScrollDirection || (ScrollDirection = {}));
6
- export function doSmoothScroll(element, startPosition, scrollOptions) {
7
- const { distance, timeSeconds, speed, direction = ScrollDirection.HORIZONTAL, reverseParams, } = scrollOptions;
8
- let scrollShift = 0;
9
- let currentTimeChanges = 0;
10
- const changeScrollFunction = getChangeScrollFunction(direction, Boolean(reverseParams));
11
- const scrollDistance = (reverseParams === null || reverseParams === void 0 ? void 0 : reverseParams.distance) || distance;
12
- const timeChanges = getTimeChanges(scrollDistance, timeSeconds, speed);
13
- while (scrollShift < scrollDistance) {
14
- window.setTimeout(changeScrollFunction, currentTimeChanges, element, scrollShift, startPosition);
15
- currentTimeChanges += timeChanges;
16
- scrollShift++;
17
- }
18
- }
19
- function getChangeScrollFunction(direction, isReverse) {
20
- return (element, scrollPosition, startPosition) => {
21
- element[direction] = isReverse
22
- ? startPosition - scrollPosition
23
- : startPosition + scrollPosition;
24
- };
25
- }
26
- function getTimeChanges(distance, timeSeconds, acceleration) {
27
- const physicalSpeed = distance / timeSeconds;
28
- const programSpeedMilliseconds = (1 / physicalSpeed) * 1000;
29
- return programSpeedMilliseconds / acceleration;
30
- }