pds-dev-kit-web-test 0.2.14 → 0.2.16

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 (58) hide show
  1. package/dist/src/sub/DynamicLayout/components/Section/CustomSection.d.ts +2 -1
  2. package/dist/src/sub/DynamicLayout/components/Section/CustomSection.js +2 -4
  3. package/dist/src/sub/DynamicLayout/components/Section/ErrorBoundary/ErrorBoundary.d.ts +15 -0
  4. package/dist/src/sub/DynamicLayout/components/Section/ErrorBoundary/ErrorBoundary.js +62 -0
  5. package/dist/src/sub/DynamicLayout/components/Section/ErrorBoundary/index.d.ts +1 -0
  6. package/dist/src/sub/DynamicLayout/components/Section/ErrorBoundary/index.js +8 -0
  7. package/dist/src/sub/DynamicLayout/components/Section/components/CustomSectionBackground.d.ts +1 -2
  8. package/dist/src/sub/DynamicLayout/components/Section/components/CustomSectionBackground.js +29 -50
  9. package/dist/src/sub/DynamicLayout/components/Section/components/CustomSectionBackgroundMedia.d.ts +5 -3
  10. package/dist/src/sub/DynamicLayout/components/Section/components/CustomSectionBackgroundMedia.js +53 -28
  11. package/dist/src/sub/DynamicLayout/components/Section/util/parseSectionBackgroundMediaData.d.ts +1 -4
  12. package/dist/src/sub/DynamicLayout/components/Section/util/parseSectionBackgroundMediaData.js +3 -12
  13. package/dist/src/sub/DynamicLayout/mock_customSection.js +9 -1
  14. package/dist/src/sub/DynamicLayout/mock_samplePage.js +1334 -445
  15. package/dist/src/sub/DynamicLayout/nakedMocks.json +8 -0
  16. package/dist/src/sub/DynamicLayout/pagesPreviewMock.d.ts +645 -0
  17. package/dist/src/sub/DynamicLayout/pagesPreviewMock.js +1661 -0
  18. package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.d.ts +3 -2
  19. package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.js +58 -30
  20. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/ComponentBlockMatcher.d.ts +7 -1
  21. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/ComponentBlockMatcher.js +3 -5
  22. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Image/Image.js +2 -2
  23. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/Text.js +7 -2
  24. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/types.d.ts +12 -2
  25. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/components/S_CB_BoxWithShadow.js +4 -12
  26. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/hooks/useCLINK.js +3 -0
  27. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/types.d.ts +1 -1
  28. package/dist/src/sub/DynamicLayout/sections/CustomSection/newUtils/colorUtil.js +6 -3
  29. package/dist/src/sub/DynamicLayout/sections/CustomSection/newUtils/replaceUndefinedValues.js +3 -5
  30. package/dist/src/sub/DynamicLayout/sections/CustomSection/newUtils/textUtil.d.ts +1 -1
  31. package/dist/src/sub/DynamicLayout/sections/CustomSection/newUtils/textUtil.js +98 -13
  32. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/layoutPropParsers/parseLayoutPropArrange.d.ts +1 -1
  33. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/layoutPropParsers/parseLayoutPropArrange.js +2 -2
  34. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/layoutPropParsers/parseSectionPadding.d.ts +23 -0
  35. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/layoutPropParsers/parseSectionPadding.js +26 -0
  36. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/parseCustomSectionPlacement.d.ts +5 -5
  37. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/parseCustomSectionPlacement.js +15 -28
  38. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/parseJsonProperties.d.ts +2 -2
  39. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/parseJsonProperties.js +2 -7
  40. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/index.d.ts +2 -2
  41. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/index.js +1 -1
  42. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropBgColor.js +4 -5
  43. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropBgImage.js +3 -5
  44. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropBgOverlay.d.ts +2 -2
  45. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropBgOverlay.js +6 -12
  46. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropBorder.d.ts +10 -10
  47. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropBorder.js +18 -6
  48. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropDivider.js +17 -5
  49. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropImage.js +12 -3
  50. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropOpacity.js +9 -3
  51. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropShadow.js +7 -4
  52. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropTextSpec.d.ts +2 -33
  53. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/stylePropParsers/parseStylePropTextSpec.js +27 -16
  54. package/dist/src/sub/DynamicLayout/sections/CustomSection/util/types.d.ts +4 -4
  55. package/dist/src/sub/DynamicLayout/types.d.ts +4 -4
  56. package/package.json +2 -2
  57. package/release-note.md +5 -3
  58. package/webhook/node_modules/esrecurse/.babelrc +0 -3
@@ -1,4 +1,5 @@
1
- import { CSSProperties } from 'react';
1
+ /// <reference types="react" />
2
+ import { CSSProperties } from 'styled-components';
2
3
  import type { ISection } from '../../types';
3
4
  declare type SectionPropTypes = ISection & {
4
5
  children?: React.ReactNode;
@@ -30,17 +30,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  var jsx_runtime_1 = require("react/jsx-runtime");
33
- var react_1 = require("react");
34
33
  var styled_components_1 = __importDefault(require("styled-components"));
35
34
  var CustomSectionBackground_1 = __importDefault(require("./components/CustomSectionBackground"));
36
35
  var sectionContext_1 = require("./sectionContext");
37
36
  function CustomSection(_a) {
38
37
  var _b;
39
38
  var children = _a.children, overrideStyles = _a.overrideStyles, _c = _a.isMobile, isMobile = _c === void 0 ? false : _c, props = __rest(_a, ["children", "overrideStyles", "isMobile"]);
40
- var _d = (0, react_1.useState)(false), isHover = _d[0], setIsHover = _d[1];
41
- return ((0, jsx_runtime_1.jsx)(sectionContext_1.sectionContext.Provider, __assign({ value: __assign({}, props) }, { children: (0, jsx_runtime_1.jsxs)(S_Section, __assign({ style: overrideStyles, isIframeSection: ((_b = props.manifest) === null || _b === void 0 ? void 0 : _b.schema) === 'EXP_IFRAME', onMouseEnter: function () { return setIsHover(true); }, onMouseMove: function () { return !isHover && setIsHover(true); }, onMouseLeave: function () { return setIsHover(false); } }, { children: [(0, jsx_runtime_1.jsx)(CustomSectionBackground_1.default, { isHover: isHover, isMobile: isMobile }, void 0), children] }), void 0) }), void 0));
39
+ return ((0, jsx_runtime_1.jsx)(sectionContext_1.sectionContext.Provider, __assign({ value: __assign({}, props) }, { children: (0, jsx_runtime_1.jsxs)(S_Section, __assign({ style: overrideStyles, isIframeSection: ((_b = props.manifest) === null || _b === void 0 ? void 0 : _b.schema) === 'EXP_IFRAME' }, { children: [(0, jsx_runtime_1.jsx)(CustomSectionBackground_1.default, { isMobile: isMobile }, void 0), children] }), void 0) }), void 0));
42
40
  }
43
- var S_Section = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-sizing: border-box;\n height: ", ";\n position: relative;\n width: 100%;\n z-index: 0;\n"], ["\n box-sizing: border-box;\n height: ", ";\n position: relative;\n width: 100%;\n z-index: 0;\n"])), function (_a) {
41
+ var S_Section = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n align-items: center;\n box-sizing: border-box;\n display: flex;\n height: ", ";\n justify-content: center;\n position: relative;\n width: 100%;\n z-index: 0;\n"], ["\n align-items: center;\n box-sizing: border-box;\n display: flex;\n height: ", ";\n justify-content: center;\n position: relative;\n width: 100%;\n z-index: 0;\n"])), function (_a) {
44
42
  var isIframeSection = _a.isIframeSection;
45
43
  return (isIframeSection ? '100%' : 'auto');
46
44
  });
@@ -0,0 +1,15 @@
1
+ import React, { Component, ErrorInfo, ReactNode } from 'react';
2
+ declare type Props = {
3
+ children: ReactNode;
4
+ };
5
+ declare type State = {
6
+ hasError: boolean;
7
+ };
8
+ declare class ErrorBoundary extends Component<Props, State> {
9
+ constructor(props: Props);
10
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
11
+ static getDerivedStateFromError(): State;
12
+ reset(): void;
13
+ render(): React.ReactNode;
14
+ }
15
+ export default ErrorBoundary;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
18
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
19
+ return cooked;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ var jsx_runtime_1 = require("react/jsx-runtime");
26
+ /* eslint-disable react/destructuring-assignment */
27
+ /* eslint-disable no-console */
28
+ var react_1 = require("react");
29
+ var styled_components_1 = __importDefault(require("styled-components"));
30
+ var ErrorBoundary = /** @class */ (function (_super) {
31
+ __extends(ErrorBoundary, _super);
32
+ function ErrorBoundary(props) {
33
+ var _this = _super.call(this, props) || this;
34
+ _this.state = {
35
+ hasError: false
36
+ };
37
+ return _this;
38
+ }
39
+ ErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
40
+ console.error('Uncaught error:', error, errorInfo);
41
+ };
42
+ ErrorBoundary.getDerivedStateFromError = function () {
43
+ return { hasError: true };
44
+ };
45
+ ErrorBoundary.prototype.reset = function () {
46
+ this.setState({
47
+ hasError: false
48
+ });
49
+ };
50
+ ErrorBoundary.prototype.render = function () {
51
+ var hasError = this.state.hasError;
52
+ if (hasError) {
53
+ return (0, jsx_runtime_1.jsx)(ErrorWrapper, { children: "Error" }, void 0);
54
+ }
55
+ var children = this.props.children;
56
+ return children;
57
+ };
58
+ return ErrorBoundary;
59
+ }(react_1.Component));
60
+ var ErrorWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n flex-direction: row;\n height: 100%;\n justify-content: center;\n width: 100%;\n"], ["\n align-items: center;\n display: flex;\n flex-direction: row;\n height: 100%;\n justify-content: center;\n width: 100%;\n"])));
61
+ exports.default = ErrorBoundary;
62
+ var templateObject_1;
@@ -0,0 +1 @@
1
+ export { default as ErrorBoundary } from './ErrorBoundary';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ErrorBoundary = void 0;
7
+ var ErrorBoundary_1 = require("./ErrorBoundary");
8
+ Object.defineProperty(exports, "ErrorBoundary", { enumerable: true, get: function () { return __importDefault(ErrorBoundary_1).default; } });
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare function CustomSectionBackground({ isHover, isMobile }: {
3
- isHover: boolean;
2
+ declare function CustomSectionBackground({ isMobile }: {
4
3
  isMobile?: boolean;
5
4
  }): JSX.Element;
6
5
  export default CustomSectionBackground;
@@ -26,81 +26,60 @@ var styled_components_1 = __importDefault(require("styled-components"));
26
26
  var sectionContext_1 = require("../sectionContext");
27
27
  var CustomSectionBackgroundMedia_1 = require("./CustomSectionBackgroundMedia");
28
28
  function CustomSectionBackground(_a) {
29
- var isHover = _a.isHover, _b = _a.isMobile, isMobile = _b === void 0 ? false : _b;
29
+ var _b = _a.isMobile, isMobile = _b === void 0 ? false : _b;
30
30
  var context = (0, react_1.useContext)(sectionContext_1.sectionContext);
31
31
  var id = context.id, jsonProperties = context.jsonProperties;
32
32
  var backgroundRef = (0, react_1.useRef)(null);
33
- var backgroundOverlayRef = (0, react_1.useRef)(null);
34
33
  var _c = jsonProperties || {}, CB_STYLE_PROP_BGOVERLAY = _c.CB_STYLE_PROP_BGOVERLAY, CB_STYLE_PROP_BGMEDIA = _c.CB_STYLE_PROP_BGMEDIA;
35
- var _d = (0, util_1.parseJsonProperties)(jsonProperties, isMobile ? 'MOBILE' : 'DESKTOP'), style = _d.style, hoverStyle = _d.hoverStyle, overlayStyle = _d.overlayStyle, overlayHoverStyle = _d.overlayHoverStyle, layout = _d.layout, effect = _d.effect;
36
- var isOverlay = getIsOverlay(isMobile, isHover, CB_STYLE_PROP_BGOVERLAY);
37
- var isBgMedia = getIsBgMedia(isMobile, isHover, CB_STYLE_PROP_BGMEDIA);
38
- var mediaType = getMediaType(isMobile, isHover, CB_STYLE_PROP_BGMEDIA);
39
- (0, react_1.useEffect)(function () {
40
- var sectionElement = backgroundRef.current;
41
- var sectionOverlayElement = backgroundOverlayRef.current;
42
- if (sectionElement) {
43
- if (isHover && style && 'background' in style) {
44
- sectionElement.style.background = style.background;
45
- }
46
- if (!isHover && hoverStyle && 'background' in hoverStyle) {
47
- sectionElement.style.background = hoverStyle.background;
48
- }
49
- }
50
- if (sectionOverlayElement) {
51
- if (isHover && overlayHoverStyle && 'background' in overlayHoverStyle) {
52
- sectionOverlayElement.style.background = overlayHoverStyle.background;
53
- }
54
- if (!isHover && overlayStyle && 'background' in overlayStyle) {
55
- sectionOverlayElement.style.background = overlayStyle.background;
56
- }
57
- }
58
- }, [isHover, style, hoverStyle, overlayStyle, overlayHoverStyle]);
59
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isOverlay && CB_STYLE_PROP_BGOVERLAY && ((0, jsx_runtime_1.jsx)(S_CustomBackgroundOverlay, { className: "Overlay", ref: backgroundOverlayRef }, void 0)), (0, jsx_runtime_1.jsx)(S_CustomBackgroundWrapper, __assign({ className: "CustomSection", ref: backgroundRef, style: __assign(__assign(__assign(__assign({}, layout), effect), style), { visibility: isHover ? hoverStyle.visibility : style.visibility }) }, { children: isBgMedia && CB_STYLE_PROP_BGMEDIA && ((0, jsx_runtime_1.jsx)(CustomSectionBackgroundMedia_1.CustomSectionBackgroundMedia, { specs: CB_STYLE_PROP_BGMEDIA, playerId: id, mediaType: mediaType || 'NONE', isHover: isHover, device: isMobile ? 'MOBILE' : 'DESKTOP' }, void 0)) }), void 0)] }, void 0));
34
+ var _d = (0, util_1.parseJsonProperties)(jsonProperties, isMobile ? 'MOBILE' : 'DESKTOP'), style = _d.style, overlayStyle = _d.overlayStyle, effect = _d.effect;
35
+ var isOverlay = getIsOverlay(isMobile, CB_STYLE_PROP_BGOVERLAY);
36
+ var isBgMedia = getIsBgMedia(isMobile, CB_STYLE_PROP_BGMEDIA);
37
+ var mediaType = getMediaType(isMobile, CB_STYLE_PROP_BGMEDIA);
38
+ var _e = imageStyleDivideProvider(style), componentStyle = _e.componentStyle, wrapperStyle = _e.wrapperStyle;
39
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isOverlay && CB_STYLE_PROP_BGOVERLAY && ((0, jsx_runtime_1.jsx)(S_CustomBackgroundOverlay, { className: "Overlay", style: __assign({}, overlayStyle) }, void 0)), (0, jsx_runtime_1.jsx)(S_CustomBackgroundWrapper, __assign({ className: "CustomSection", ref: backgroundRef, style: __assign(__assign({}, effect), wrapperStyle) }, { children: isBgMedia && CB_STYLE_PROP_BGMEDIA && ((0, jsx_runtime_1.jsx)(CustomSectionBackgroundMedia_1.CustomSectionBackgroundMedia, { specs: CB_STYLE_PROP_BGMEDIA, componentStyle: componentStyle, playerId: id, mediaType: mediaType || 'NONE', device: isMobile ? 'MOBILE' : 'DESKTOP', backgroundRef: backgroundRef }, void 0)) }), void 0)] }, void 0));
60
40
  }
61
- function getIsOverlay(isMobile, isHover, specs) {
41
+ function getIsOverlay(isMobile, specs) {
62
42
  if (!specs) {
63
43
  return false;
64
44
  }
65
45
  if (isMobile) {
66
- return isHover
67
- ? specs['CB_STYLE_PROP_BGOVERLAY_SPEC_TYPE:MOBILE:HOVER'] !== 'NONE'
68
- : specs['CB_STYLE_PROP_BGOVERLAY_SPEC_TYPE:MOBILE'] !== 'NONE';
46
+ return specs['CB_STYLE_PROP_BGOVERLAY_SPEC_TYPE:MOBILE'] !== 'NONE';
69
47
  }
70
- return isHover
71
- ? specs['CB_STYLE_PROP_BGOVERLAY_SPEC_TYPE:HOVER'] !== 'NONE'
72
- : specs.CB_STYLE_PROP_BGOVERLAY_SPEC_TYPE !== 'NONE';
48
+ return specs.CB_STYLE_PROP_BGOVERLAY_SPEC_TYPE !== 'NONE';
73
49
  }
74
- function getIsBgMedia(isMobile, isHover, specs) {
50
+ function getIsBgMedia(isMobile, specs) {
75
51
  if (!specs) {
76
52
  return false;
77
53
  }
78
54
  if (isMobile) {
79
- return isHover
80
- ? specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:MOBILE:HOVER'] !== 'NONE'
81
- : specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:MOBILE'] !== 'NONE';
55
+ return specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:MOBILE'] !== 'NONE';
82
56
  }
83
- return isHover
84
- ? specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:HOVER'] !== 'NONE'
85
- : specs.CB_STYLE_PROP_BGMEDIA_SPEC_TYPE !== 'NONE';
57
+ return specs.CB_STYLE_PROP_BGMEDIA_SPEC_TYPE !== 'NONE';
86
58
  }
87
- function getMediaType(isMobile, isHover, specs) {
59
+ function getMediaType(isMobile, specs) {
88
60
  if (!specs) {
89
61
  return 'NONE';
90
62
  }
91
63
  if (isMobile) {
92
- if (isHover) {
93
- return (0, isNullOrUndefined_1.default)(specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:MOBILE:HOVER'])
94
- ? specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:HOVER']
95
- : specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:MOBILE:HOVER'];
96
- }
97
64
  return (0, isNullOrUndefined_1.default)(specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:MOBILE'])
98
65
  ? specs.CB_STYLE_PROP_BGMEDIA_SPEC_TYPE
99
66
  : specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:MOBILE'];
100
67
  }
101
- return isHover
102
- ? specs['CB_STYLE_PROP_BGMEDIA_SPEC_TYPE:HOVER']
103
- : specs.CB_STYLE_PROP_BGMEDIA_SPEC_TYPE;
68
+ return specs.CB_STYLE_PROP_BGMEDIA_SPEC_TYPE;
69
+ }
70
+ function imageStyleDivideProvider(style) {
71
+ return {
72
+ componentStyle: {
73
+ display: style.display,
74
+ objectFit: style.objectFit
75
+ },
76
+ wrapperStyle: {
77
+ alignItems: style.alignItems,
78
+ visibility: style.visibility,
79
+ justifyContent: style.justifyContent,
80
+ background: style.background
81
+ }
82
+ };
104
83
  }
105
84
  var S_CustomBackgroundWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n align-items: center;\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n overflow: hidden;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -2;\n"], ["\n align-items: center;\n bottom: 0;\n display: flex;\n justify-content: center;\n left: 0;\n overflow: hidden;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -2;\n"])));
106
85
  var S_CustomBackgroundOverlay = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n bottom: 0;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n"], ["\n bottom: 0;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n"])));
@@ -1,12 +1,14 @@
1
- /// <reference types="react" />
1
+ import { MutableRefObject } from 'react';
2
+ import { CSSProperties } from 'styled-components';
2
3
  import type { Device } from '../../../../DynamicLayout/sections/CustomSection/util/types';
3
4
  import type { CB_STYLE_PROP_BGMEDIA_SPECS } from '../../../../DynamicLayout/types';
4
5
  declare type Props = {
5
6
  specs: CB_STYLE_PROP_BGMEDIA_SPECS;
6
7
  playerId: number;
7
8
  mediaType: string;
8
- isHover: boolean;
9
+ componentStyle: CSSProperties;
9
10
  device: Device;
11
+ backgroundRef: MutableRefObject<HTMLDivElement | null>;
10
12
  };
11
- export declare function CustomSectionBackgroundMedia({ specs, playerId, mediaType, isHover, device }: Props): JSX.Element;
13
+ export declare function CustomSectionBackgroundMedia({ specs, playerId, mediaType, componentStyle, device, backgroundRef }: Props): JSX.Element;
12
14
  export {};
@@ -20,41 +20,60 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.CustomSectionBackgroundMedia = void 0;
22
22
  var jsx_runtime_1 = require("react/jsx-runtime");
23
- /* eslint-disable @typescript-eslint/no-unused-vars */
24
- require("react");
23
+ var react_1 = require("react");
25
24
  var styled_components_1 = __importDefault(require("styled-components"));
26
25
  var pdsOriginal_1 = require("../../pdsOriginal");
27
26
  var YouTubeIframe_1 = require("../../YouTubeIframe");
28
27
  var util_1 = require("../util");
29
28
  function CustomSectionBackgroundMedia(_a) {
30
- var specs = _a.specs, playerId = _a.playerId, mediaType = _a.mediaType, isHover = _a.isHover, device = _a.device;
31
- var _b = (0, util_1.parseSectionBackgroundMediaData)(specs, device), normal = _b.normal, hover = _b.hover;
32
- var scaleType = getScaleType(isHover
33
- ? hover.CB_STYLE_PROP_BGMEDIA_SPEC_IMAGEFIT
34
- : normal.CB_STYLE_PROP_BGMEDIA_SPEC_IMAGEFIT);
29
+ var specs = _a.specs, playerId = _a.playerId, mediaType = _a.mediaType, componentStyle = _a.componentStyle, device = _a.device, backgroundRef = _a.backgroundRef;
30
+ var _b = (0, util_1.parseSectionBackgroundMediaData)(specs, device), CB_STYLE_PROP_BGMEDIA_SPEC_YSRC = _b.CB_STYLE_PROP_BGMEDIA_SPEC_YSRC, CB_STYLE_PROP_BGMEDIA_SPEC_REPLAY = _b.CB_STYLE_PROP_BGMEDIA_SPEC_REPLAY, CB_STYLE_PROP_BGMEDIA_SPEC_STARTTIME = _b.CB_STYLE_PROP_BGMEDIA_SPEC_STARTTIME, CB_STYLE_PROP_BGMEDIA_SPEC_ENDTIME = _b.CB_STYLE_PROP_BGMEDIA_SPEC_ENDTIME, CB_STYLE_PROP_BGMEDIA_SPEC_SCROLL = _b.CB_STYLE_PROP_BGMEDIA_SPEC_SCROLL, CB_STYLE_PROP_BGMEDIA_SPEC_IMAGEFIT = _b.CB_STYLE_PROP_BGMEDIA_SPEC_IMAGEFIT, CB_STYLE_PROP_BGMEDIA_SPEC_IMAGESELECTOR = _b.CB_STYLE_PROP_BGMEDIA_SPEC_IMAGESELECTOR;
31
+ var _c = (0, react_1.useState)({ width: 0, height: 0 }), youtubeSize = _c[0], setYoutubeSize = _c[1];
32
+ var getResponsiveYoutubeSize = (0, react_1.useCallback)(function () {
33
+ var backgroundWrapper = backgroundRef.current;
34
+ if (!backgroundWrapper)
35
+ return { width: 0, height: 0 };
36
+ var backgroundSize = {
37
+ width: backgroundWrapper.getBoundingClientRect().width,
38
+ height: backgroundWrapper.getBoundingClientRect().height
39
+ };
40
+ var isHorizontal = backgroundSize.width / backgroundSize.height > 1;
41
+ var isOverRatio = backgroundSize.width / backgroundSize.height > 16 / 9;
42
+ var youtubeSize = isHorizontal && isOverRatio
43
+ ? { width: backgroundSize.width, height: backgroundSize.width * (9 / 16) }
44
+ : { width: backgroundSize.height * (16 / 9), height: backgroundSize.height };
45
+ return youtubeSize;
46
+ }, [backgroundRef.current]);
47
+ var scaleType = getScaleType(String(CB_STYLE_PROP_BGMEDIA_SPEC_IMAGEFIT));
48
+ (0, react_1.useEffect)(function () {
49
+ if (mediaType !== 'YOUTUBE')
50
+ return;
51
+ setYoutubeSize(getResponsiveYoutubeSize());
52
+ }, [getResponsiveYoutubeSize, CB_STYLE_PROP_BGMEDIA_SPEC_YSRC]);
53
+ (0, react_1.useEffect)(function () {
54
+ if (mediaType !== 'YOUTUBE')
55
+ return;
56
+ function onResize() {
57
+ setYoutubeSize(getResponsiveYoutubeSize());
58
+ }
59
+ var element = backgroundRef.current;
60
+ if (!element)
61
+ return;
62
+ var observer = new ResizeObserver(function (entries) {
63
+ entries.forEach(function () {
64
+ onResize();
65
+ });
66
+ });
67
+ observer.observe(element);
68
+ return function () {
69
+ observer.disconnect();
70
+ };
71
+ }, []);
35
72
  switch (mediaType) {
36
73
  case 'IMAGE':
37
- return ((0, jsx_runtime_1.jsx)(S_ImageWrapper, __assign({ isOverflowScroll: isHover
38
- ? hover.CB_STYLE_PROP_BGMEDIA_SPEC_SCROLL
39
- : normal.CB_STYLE_PROP_BGMEDIA_SPEC_SCROLL, scaleType: isHover
40
- ? hover.CB_STYLE_PROP_BGMEDIA_SPEC_IMAGEFIT
41
- : normal.CB_STYLE_PROP_BGMEDIA_SPEC_IMAGEFIT }, { children: (0, jsx_runtime_1.jsx)(pdsOriginal_1.ImageView, { src: isHover
42
- ? hover.CB_STYLE_PROP_BGMEDIA_SPEC_IMAGESELECTOR
43
- : normal.CB_STYLE_PROP_BGMEDIA_SPEC_IMAGESELECTOR, width: "responsive", height: "responsive", scaleType: scaleType, shapeType: "rectangle" }, void 0) }), void 0));
74
+ return ((0, jsx_runtime_1.jsx)(S_ImageWrapper, __assign({ isOverflowScroll: !!CB_STYLE_PROP_BGMEDIA_SPEC_SCROLL, scaleType: getScaleType(String(CB_STYLE_PROP_BGMEDIA_SPEC_IMAGEFIT)), style: __assign({}, componentStyle) }, { children: (0, jsx_runtime_1.jsx)(pdsOriginal_1.ImageView, { src: String(CB_STYLE_PROP_BGMEDIA_SPEC_IMAGESELECTOR), width: "responsive", height: "responsive", scaleType: scaleType, shapeType: "rectangle" }, void 0) }), void 0));
44
75
  case 'YOUTUBE':
45
- return ((0, jsx_runtime_1.jsx)(S_YoutubeContainer, { children: (0, jsx_runtime_1.jsx)(YouTubeIframe_1.YouTubeIframe, { id: playerId, src: isHover
46
- ? hover.CB_STYLE_PROP_BGMEDIA_SPEC_YSRC
47
- : normal.CB_STYLE_PROP_BGMEDIA_SPEC_YSRC, loopMode: isHover
48
- ? hover.CB_STYLE_PROP_BGMEDIA_SPEC_REPLAY
49
- ? 'use'
50
- : 'none'
51
- : normal.CB_STYLE_PROP_BGMEDIA_SPEC_REPLAY
52
- ? 'use'
53
- : 'none', startSeconds: isHover
54
- ? hover.CB_STYLE_PROP_BGMEDIA_SPEC_STARTTIME
55
- : normal.CB_STYLE_PROP_BGMEDIA_SPEC_STARTTIME, endSeconds: isHover
56
- ? hover.CB_STYLE_PROP_BGMEDIA_SPEC_ENDTIME
57
- : normal.CB_STYLE_PROP_BGMEDIA_SPEC_ENDTIME }, void 0) }, void 0));
76
+ return ((0, jsx_runtime_1.jsx)(S_YoutubeContainer, __assign({}, youtubeSize, { children: (0, jsx_runtime_1.jsx)(YouTubeIframe_1.YouTubeIframe, { id: playerId, src: String(CB_STYLE_PROP_BGMEDIA_SPEC_YSRC), loopMode: CB_STYLE_PROP_BGMEDIA_SPEC_REPLAY ? 'use' : 'none', startSeconds: Number(CB_STYLE_PROP_BGMEDIA_SPEC_STARTTIME), endSeconds: Number(CB_STYLE_PROP_BGMEDIA_SPEC_ENDTIME) }, void 0) }), void 0));
58
77
  case 'NONE':
59
78
  default:
60
79
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}, void 0);
@@ -87,5 +106,11 @@ var S_ImageWrapper = styled_components_1.default.div(templateObject_1 || (templa
87
106
  return "height: auto;\n width: auto";
88
107
  }
89
108
  });
90
- var S_YoutubeContainer = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: 100%;\n width: 100%;\n"], ["\n height: 100%;\n width: 100%;\n"])));
109
+ var S_YoutubeContainer = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: ", ";\n width: ", ";\n"], ["\n height: ", ";\n width: ", ";\n"])), function (_a) {
110
+ var height = _a.height;
111
+ return height + "px";
112
+ }, function (_a) {
113
+ var width = _a.width;
114
+ return width + "px";
115
+ });
91
116
  var templateObject_1, templateObject_2;
@@ -2,8 +2,5 @@ import type { Device } from '../../../../DynamicLayout/sections/CustomSection/ut
2
2
  import type { CB_STYLE_PROP_BGMEDIA_SPECS } from '../../../../DynamicLayout/types';
3
3
  declare type SpecKeys = keyof Omit<CB_STYLE_PROP_BGMEDIA_SPECS, 'CB_STYLE_PROP_BGMEDIA_SPEC_MPLAY'>;
4
4
  declare type ValueSetType = Partial<Record<SpecKeys, string | number | boolean | undefined>>;
5
- export default function UseCustomSectionBackgroundMediaData(specs: CB_STYLE_PROP_BGMEDIA_SPECS, device: Device): {
6
- normal: ValueSetType;
7
- hover: ValueSetType;
8
- };
5
+ export default function UseCustomSectionBackgroundMediaData(specs: CB_STYLE_PROP_BGMEDIA_SPECS, device: Device): ValueSetType;
9
6
  export {};
@@ -29,19 +29,10 @@ var AVAILABLE_SPECS = [
29
29
  ];
30
30
  function UseCustomSectionBackgroundMediaData(specs, device) {
31
31
  return AVAILABLE_SPECS.reduce(function (acc, cur) {
32
- var _a, _b;
32
+ var _a;
33
33
  var baseKey = device === 'DESKTOP' ? cur : cur + ":MOBILE";
34
34
  var value = (0, isNullOrUndefined_1.default)(specs[baseKey]) ? specs[cur] : specs[baseKey];
35
- var hoverValue = (0, isNullOrUndefined_1.default)(specs[baseKey + ":HOVER"])
36
- ? specs[cur + ":HOVER"]
37
- : specs[baseKey + ":HOVER"];
38
- return {
39
- normal: __assign(__assign({}, acc.normal), (_a = {}, _a[cur] = value, _a)),
40
- hover: __assign(__assign({}, acc.hover), (_b = {}, _b[cur] = hoverValue, _b))
41
- };
42
- }, {
43
- normal: {},
44
- hover: {}
45
- });
35
+ return __assign(__assign({}, acc), (_a = {}, _a[cur] = value, _a));
36
+ }, {});
46
37
  }
47
38
  exports.default = UseCustomSectionBackgroundMediaData;
@@ -273,7 +273,15 @@ exports.customSectionMock1 = {
273
273
  CB_STYLE_PROP_TEXT_SPEC_COLOR: '#fffc00eb',
274
274
  'CB_STYLE_PROP_TEXT_SPEC_COLOR:HOVER': '#ff2727',
275
275
  'CB_STYLE_PROP_TEXT_SPEC_COLOR:MOBILE': undefined,
276
- 'CB_STYLE_PROP_TEXT_SPEC_COLOR:MOBILE:HOVER': undefined
276
+ 'CB_STYLE_PROP_TEXT_SPEC_COLOR:MOBILE:HOVER': undefined,
277
+ CB_STYLE_PROP_TEXT_SPEC_HORIZONTAL: 'LEFT',
278
+ 'CB_STYLE_PROP_TEXT_SPEC_HORIZONTAL:HOVER': 'CENTER',
279
+ 'CB_STYLE_PROP_TEXT_SPEC_HORIZONTAL:MOBILE': undefined,
280
+ 'CB_STYLE_PROP_TEXT_SPEC_HORIZONTAL:MOBILE:HOVER': undefined,
281
+ CB_STYLE_PROP_TEXT_SPEC_VERTICAL: 'TOP',
282
+ 'CB_STYLE_PROP_TEXT_SPEC_VERTICAL:HOVER': 'CENTER',
283
+ 'CB_STYLE_PROP_TEXT_SPEC_VERTICAL:MOBILE': undefined,
284
+ 'CB_STYLE_PROP_TEXT_SPEC_VERTICAL:MOBILE:HOVER': undefined
277
285
  },
278
286
  CB_STYLE_PROP_OPACITY: {
279
287
  CB_STYLE_PROP_OPACITY_SPEC_OPACITY: 1,