pds-dev-kit-web-test 2.2.99 → 2.3.2

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 (19) hide show
  1. package/dist/src/sub/DynamicLayout/components/SectionMatcher/SectionMatcher.js +7 -1
  2. package/dist/src/sub/DynamicLayout/pagesPreviewMock.js +9 -9
  3. package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.d.ts +5 -0
  4. package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.js +20 -10
  5. package/dist/src/sub/DynamicLayout/sections/CustomSection/NewCustomSection.d.ts +3 -0
  6. package/dist/src/sub/DynamicLayout/sections/CustomSection/NewCustomSection.js +70 -0
  7. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Button/Button.js +1 -1
  8. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/Text.js +41 -24
  9. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/components/S_CB_Box.js +1 -1
  10. package/dist/src/sub/DynamicLayout/sections/CustomSection/newUtils/textUtil.js +12 -1
  11. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/FlexGridItem.d.ts +11 -0
  12. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/FlexGridItem.js +59 -0
  13. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/TempCustomSection.d.ts +7 -0
  14. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/TempCustomSection.js +87 -0
  15. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useIsMounted.d.ts +1 -0
  16. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useIsMounted.js +15 -0
  17. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useResizableObserver.d.ts +12 -0
  18. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useResizableObserver.js +74 -0
  19. package/package.json +1 -1
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare function NewCustomSection(): JSX.Element;
3
+ export default NewCustomSection;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ var jsx_runtime_1 = require("react/jsx-runtime");
18
+ require("publ-echo");
19
+ var ReactGridLayout_1 = __importDefault(require("publ-echo/dist/lib/GridLayoutEditor/ReactGridLayout"));
20
+ var react_1 = require("react");
21
+ var react_measure_1 = __importDefault(require("react-measure"));
22
+ var CustomSection_1 = require("./CustomSection");
23
+ function NewCustomSection() {
24
+ var _a = (0, react_1.useState)([
25
+ {
26
+ i: 'a',
27
+ x: 0,
28
+ y: 0,
29
+ w: 3,
30
+ h: 6,
31
+ text: 'iam AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA',
32
+ autoSize: true
33
+ },
34
+ { i: 'b', x: 1, y: 0, w: 3, h: 2, text: 'iam BBBBBBBB' },
35
+ { i: 'c', x: 4, y: 0, w: 1, h: 2, text: 'iam CCCCCCCC' }
36
+ ]), layout = _a[0], setLayout = _a[1];
37
+ function onSizeChange(size, index) {
38
+ setLayout(function (prev) {
39
+ var copy = JSON.parse(JSON.stringify(prev));
40
+ // From formula pixelHeight = (rowHeight * h) + (marginH * (h - 1))
41
+ // h = (pixelHeight + marginH) / (marginH + rowHeight)
42
+ var newH = (size.height + 50) / (50 + 30);
43
+ copy[index].h = newH;
44
+ copy[index].minH = newH;
45
+ console.log('size changed so setLayout');
46
+ return copy;
47
+ });
48
+ // const placeholder = document.querySelector('.react-grid-placeholder')
49
+ // placeholder.height = 100;
50
+ }
51
+ return ((0, jsx_runtime_1.jsx)(CustomSection_1.S_gleStyles, __assign({ style: { backgroundColor: 'white' } }, { children: (0, jsx_runtime_1.jsx)(ReactGridLayout_1.default, __assign({ layout: layout,
52
+ // onLayoutChange={onLayoutChange}
53
+ allowOverlap: true, margin: [50, 50], cols: 12, rowHeight: 30, width: 1200, resizeHandles: ['n', 'e', 'w', 'sw', 'se', 's', 'nw', 'ne'] }, { children: layout.map(function (item, index) { return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(MeasuredCB, { text: item.text, onSizeChange: function (size) { return onSizeChange(size, index); } }) }, item.i)); }) })) })));
54
+ }
55
+ var MeasuredCB = function (_a) {
56
+ var text = _a.text, onSizeChange = _a.onSizeChange;
57
+ var handleResize = function (contentRect) {
58
+ if (contentRect.bounds) {
59
+ onSizeChange({
60
+ width: contentRect.bounds.width,
61
+ height: contentRect.bounds.height
62
+ });
63
+ }
64
+ };
65
+ return ((0, jsx_runtime_1.jsx)(react_measure_1.default, __assign({ bounds: true, onResize: handleResize }, { children: function (_a) {
66
+ var measureRef = _a.measureRef;
67
+ return ((0, jsx_runtime_1.jsx)("div", __assign({ ref: measureRef, contentEditable: true, style: { outline: 'none' } }, { children: text })));
68
+ } })));
69
+ };
70
+ exports.default = NewCustomSection;
@@ -66,7 +66,7 @@ function Button(props) {
66
66
  ? CB_EFFECT_PROP_ENTANIM.CB_EFFECT_PROP_ENTANIM_SPEC_TYPE === 'NONE'
67
67
  : CB_EFFECT_PROP_ENTANIM['CB_EFFECT_PROP_ENTANIM_SPEC_TYPE:MOBILE'] === 'NONE';
68
68
  var hasEffect = !isNoneEffectType;
69
- var effectVisibleStyle = hasEffect ? { opacity: isVisible ? 1 : 0 } : {};
69
+ var effectVisibleStyle = hasEffect ? { opacity: isVisible ? 1 : 1 } : {};
70
70
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isEditModeAndHidden && (0, jsx_runtime_1.jsx)(S_HiddenCover_1.S_HiddenCover, {}), (0, jsx_runtime_1.jsx)(S_CB_AnimationObserverBox_1.S_CB_AnimationObserverBox, __assign({ ref: hasEffect ? cbRef : null, effectVisibleStyle: effectVisibleStyle, style: {
71
71
  paddingLeft: paddingLeft,
72
72
  paddingRight: paddingRight,
@@ -62,42 +62,49 @@ function Text(props) {
62
62
  var effectVisibleStyle = hasEffect ? { opacity: isVisible ? 1 : 0 } : {};
63
63
  var _f = (0, customSectionContext_1.useCustomSectionContext)(), setLayouts = _f.setLayouts, rowHeight = _f.rowHeight, sectionActionHandler = _f.sectionActionHandler;
64
64
  var debouncedSectionActionHandler = (0, react_1.useCallback)((0, lodash_1.debounce)(function (payload) {
65
- console.log('called');
66
65
  sectionActionHandler &&
67
66
  sectionActionHandler({
68
67
  type: '@CUSTOMSECTION/AUTO_RESIZED_TO_FIT_CONTENT',
69
68
  payload: payload
70
69
  });
71
- }, 1000), [sectionActionHandler]);
70
+ }, 1000), []);
72
71
  var handleResize = function (contentRect) {
72
+ var _a, _b;
73
73
  var breakpoint = device === 'DESKTOP' ? 'lg' : 'sm';
74
- if (!contentRect.bounds) {
74
+ var scrollHeight = (_a = contentRect.scroll) === null || _a === void 0 ? void 0 : _a.height;
75
+ var clientHeight = (_b = contentRect.client) === null || _b === void 0 ? void 0 : _b.height;
76
+ if (!scrollHeight || !clientHeight) {
77
+ return;
78
+ }
79
+ if (clientHeight < scrollHeight) {
75
80
  return;
76
81
  }
77
- var height = contentRect.bounds.height;
78
82
  var id = props.id;
79
- setLayouts(function (prev) {
80
- var copy = JSON.parse(JSON.stringify(prev));
81
- var targetIndex = copy[breakpoint].findIndex(function (each) { return each.i === id.toString(); });
82
- var newH = Math.ceil((height + 10) / (10 + rowHeight));
83
- copy[breakpoint][targetIndex].h = newH;
84
- copy[breakpoint][targetIndex].minH = newH;
85
- debouncedSectionActionHandler({
86
- layout: copy[breakpoint],
87
- cb: {
88
- i: id,
89
- h: newH,
90
- w: copy[breakpoint][targetIndex].w,
91
- x: copy[breakpoint][targetIndex].x,
92
- y: copy[breakpoint][targetIndex].y
93
- }
94
- });
95
- return copy;
96
- });
83
+ // setLayouts((prev) => {
84
+ // const copy: any = JSON.parse(JSON.stringify(prev));
85
+ // const targetIndex = copy[breakpoint].findIndex((each: any) => each.i === id.toString());
86
+ // const newH = Math.ceil((clientHeight + 10) / (10 + rowHeight));
87
+ // copy[breakpoint][targetIndex].h = newH;
88
+ // copy[breakpoint][targetIndex].minH = newH;
89
+ // debouncedSectionActionHandler({
90
+ // layout: copy[breakpoint],
91
+ // cb: {
92
+ // i: id,
93
+ // h: newH,
94
+ // w: copy[breakpoint][targetIndex].w,
95
+ // x: copy[breakpoint][targetIndex].x,
96
+ // y: copy[breakpoint][targetIndex].y
97
+ // }
98
+ // });
99
+ // // console.log(copy[breakpoint][targetIndex]);
100
+ // return copy;
101
+ // });
97
102
  };
98
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isEditModeAndHidden && (0, jsx_runtime_1.jsx)(S_HiddenCover_1.S_HiddenCover, {}), (0, jsx_runtime_1.jsx)(S_CB_AnimationObserverBox_1.S_CB_AnimationObserverBox, __assign({ ref: hasEffect ? cbRef : null, effectVisibleStyle: effectVisibleStyle }, { children: (0, jsx_runtime_1.jsx)(react_measure_1.default, __assign({ bounds: true, onResize: handleResize }, { children: function (_a) {
103
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isEditModeAndHidden && (0, jsx_runtime_1.jsx)(S_HiddenCover_1.S_HiddenCover, {}), (0, jsx_runtime_1.jsx)(S_CB_AnimationObserverBox_1.S_CB_AnimationObserverBox, __assign({ ref: hasEffect ? cbRef : null, effectVisibleStyle: effectVisibleStyle }, { children: (0, jsx_runtime_1.jsx)(react_measure_1.default, __assign({ client: true, scroll: true, onResize: handleResize }, { children: function (_a) {
99
104
  var measureRef = _a.measureRef;
100
- return ((0, jsx_runtime_1.jsx)("div", __assign({ ref: measureRef }, { children: (0, jsx_runtime_1.jsx)(S_CB_Box_1.S_CB_Box, __assign({ className: "cb-layout-box", normalStyle: __assign(__assign(__assign(__assign(__assign({}, textStyle), propsStyle), layoutStyle), effectCssProperties), { whiteSpace: 'pre-wrap', wordBreak: 'break-word', cursor: CLINKCursor }), hoverStyle: __assign(__assign(__assign({}, textHoverStyle), propsHoverStyle), { whiteSpace: 'pre-wrap', wordBreak: 'break-word' }), onClick: onClickCLINK }, { children: props.CB_CONTENT_PROP_TEXT.CB_CONTENT_PROP_TEXT_SPEC_TEXT })) })));
105
+ return ((0, jsx_runtime_1.jsx)("div", __assign({ ref: measureRef }, { children: (0, jsx_runtime_1.jsx)(S_CB_Box_1.S_CB_Box, __assign({ className: "cb-layout-box", normalStyle: __assign(__assign(__assign(__assign(__assign({}, textStyle), propsStyle), layoutStyle), effectCssProperties), {
106
+ // width: cbRef.current ? calculateCh(cbRef.current, '1rem') : '100%',
107
+ width: '100%', whiteSpace: 'pre-wrap', wordBreak: 'break-word', cursor: CLINKCursor }), hoverStyle: __assign(__assign(__assign({}, textHoverStyle), propsHoverStyle), { whiteSpace: 'pre-wrap', wordBreak: 'break-word' }), onClick: onClickCLINK }, { children: props.CB_CONTENT_PROP_TEXT.CB_CONTENT_PROP_TEXT_SPEC_TEXT })) })));
101
108
  } })) }))] }));
102
109
  }
103
110
  function getTextStyles(props, device) {
@@ -113,4 +120,14 @@ function getTextStyles(props, device) {
113
120
  ];
114
121
  return (0, textUtil_1.parseStyleTextToCSSProp)({ availableSpecCodes: availableSpecCodes, props: props, device: device, propKey: 'TEXT' });
115
122
  }
123
+ function calculateCh(element, fontSize) {
124
+ var zero = document.createElement('span');
125
+ zero.innerText = '0';
126
+ zero.style.position = 'absolute';
127
+ zero.style.fontSize = fontSize;
128
+ element.appendChild(zero);
129
+ var chPixels = zero.getBoundingClientRect().width;
130
+ element.removeChild(zero);
131
+ return "".concat(320 / chPixels, "ch");
132
+ }
116
133
  exports.default = Text;
@@ -40,7 +40,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.S_CB_Box = void 0;
42
42
  var styled_components_1 = __importStar(require("styled-components"));
43
- exports.S_CB_Box = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n /*\n Introduced in IE 10.\n See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/\n */\n\n height: 100%;\n width: 100%;\n\n ", ";\n\n &:hover {\n ", ";\n }\n"], ["\n /*\n Introduced in IE 10.\n See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/\n */\n\n height: 100%;\n width: 100%;\n\n ", ";\n\n &:hover {\n ", ";\n }\n"])), function (_a) {
43
+ exports.S_CB_Box = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n /*\n Introduced in IE 10.\n See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/\n */\n\n /* font-size: calc(0.8rem + (2rem - 0.8rem) * ((100vw - 20rem) / (50rem - 20rem))); */\n font-size: calc(0.8rem + 1.2 * ((100vw - 20rem) / 30));\n height: 100%;\n width: 100%;\n\n ", ";\n\n &:hover {\n ", ";\n }\n"], ["\n /*\n Introduced in IE 10.\n See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/\n */\n\n /* font-size: calc(0.8rem + (2rem - 0.8rem) * ((100vw - 20rem) / (50rem - 20rem))); */\n font-size: calc(0.8rem + 1.2 * ((100vw - 20rem) / 30));\n height: 100%;\n width: 100%;\n\n ", ";\n\n &:hover {\n ", ";\n }\n"])), function (_a) {
44
44
  var normalStyle = _a.normalStyle;
45
45
  return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), __assign(__assign({}, normalStyle), { boxShadow: '' }));
46
46
  }, function (_a) {
@@ -208,5 +208,16 @@ function getEmFontSize(device, size) {
208
208
  if (device === 'DESKTOP') {
209
209
  return "".concat((size / 16).toFixed(3), "em");
210
210
  }
211
- return "".concat((size / 16).toFixed(3), "em");
211
+ var value = clampBuilder(320, 960, 1, 3);
212
+ return value;
213
+ // return `${(size / 16).toFixed(3)}em`;
214
+ }
215
+ function clampBuilder(minWidthPx, maxWidthPx, minFontSize, maxFontSize) {
216
+ var root = document.querySelector('html');
217
+ var pixelsPerRem = Number(getComputedStyle(root).fontSize.slice(0, -2));
218
+ var minWidth = minWidthPx / pixelsPerRem;
219
+ var maxWidth = maxWidthPx / pixelsPerRem;
220
+ var slope = (maxFontSize - minFontSize) / (maxWidth - minWidth);
221
+ var yAxisIntersection = -minWidth * slope + minFontSize;
222
+ return "clamp( ".concat(minFontSize, "rem, ").concat(yAxisIntersection, "rem + ").concat(slope * 100, "vw, ").concat(maxFontSize, "rem )");
212
223
  }
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { type ComponentBlock } from '../CustomSection/types';
3
+ import type { Device } from '../CustomSection/util/types';
4
+ type Props = {
5
+ cb: ComponentBlock;
6
+ index: number;
7
+ device: Device;
8
+ rowHeight: number;
9
+ };
10
+ declare function FlexGridItem({ cb, index, device, rowHeight }: Props): JSX.Element;
11
+ export default FlexGridItem;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var jsx_runtime_1 = require("react/jsx-runtime");
22
+ require("react");
23
+ var styled_components_1 = __importDefault(require("styled-components"));
24
+ var components_1 = require("../CustomSection/components");
25
+ var types_1 = require("../CustomSection/types");
26
+ function FlexGridItem(_a) {
27
+ var cb = _a.cb, index = _a.index, device = _a.device, rowHeight = _a.rowHeight;
28
+ var CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS = cb.jsonProperties.data.CB_PLACEMENT_PROP_PLACEMENT.CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS;
29
+ var gridArea = getGridAreaFromCB(cb.jsonProperties.data.CB_PLACEMENT_PROP_PLACEMENT, device);
30
+ var defaultHeight = CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS * rowHeight;
31
+ return ((0, jsx_runtime_1.jsx)(GridItem, __assign({ style: {
32
+ gridArea: gridArea,
33
+ maxHeight: cb.componentBlockCode !== types_1.CB_ALL_CODES.CB_TEXT ? defaultHeight : undefined
34
+ } }, { children: (0, jsx_runtime_1.jsx)(components_1.ComponentBlockMatcher, { id: Number(cb.id), cbProps: cb, device: device, index: index }) })));
35
+ }
36
+ var S_CB = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: 1px solid red;\n /* max-height: fit-content; */\n min-height: ", ";\n"], ["\n border: 1px solid red;\n /* max-height: fit-content; */\n min-height: ", ";\n"])), function (props) { return "".concat(props.defaultHeight, "px"); });
37
+ var GridItem = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n height: auto;\n max-height: fit-content;\n word-break: break-word;\n"], ["\n height: auto;\n max-height: fit-content;\n word-break: break-word;\n"])));
38
+ function getGridAreaFromCB(props, device) {
39
+ var CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX = props.CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX, CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTY = props.CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTY, cols = props.CB_PLACEMENT_PROP_PLACEMENT_SPEC_COLS, rows = props.CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS;
40
+ if (device === 'DESKTOP') {
41
+ var colStart_1 = CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX + 1;
42
+ var rowStart_1 = CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTY + 1;
43
+ var rowEnd_1 = rows + rowStart_1;
44
+ var colEnd_1 = cols + colStart_1;
45
+ // <grid-row-start> / <grid-column-start> / <grid-row-end> / <grid-column-end>;
46
+ return "".concat(rowStart_1, " / ").concat(colStart_1, " / ").concat(rowEnd_1, " / ").concat(colEnd_1);
47
+ }
48
+ var startXMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX:MOBILE'];
49
+ var startYMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTY:MOBILE'];
50
+ var colsMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_COLS:MOBILE'];
51
+ var rowsMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS:MOBILE'];
52
+ var colStart = startXMobile + 1;
53
+ var rowStart = startYMobile + 1;
54
+ var rowEnd = rowsMobile + rowStart;
55
+ var colEnd = colsMobile + colStart;
56
+ return "".concat(rowStart, " / ").concat(colStart, " / ").concat(rowEnd, " / ").concat(colEnd);
57
+ }
58
+ exports.default = FlexGridItem;
59
+ var templateObject_1, templateObject_2;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { ISection } from '../../../DynamicLayout/types';
3
+ type Props = {
4
+ section: ISection;
5
+ };
6
+ declare function TempCustomSection({ section }: Props): JSX.Element;
7
+ export default TempCustomSection;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var jsx_runtime_1 = require("react/jsx-runtime");
22
+ var react_1 = require("react");
23
+ var components_1 = require("../../../DynamicLayout/components");
24
+ var ErrorBoundary_1 = require("../../../DynamicLayout/components/Section/ErrorBoundary");
25
+ var dynamicLayoutContext_1 = require("../../../DynamicLayout/dynamicLayoutContext");
26
+ var styled_components_1 = __importDefault(require("styled-components"));
27
+ var CustomSection_1 = require("../CustomSection/CustomSection");
28
+ var customSectionContext_1 = require("../CustomSection/customSectionContext");
29
+ var util_1 = require("../CustomSection/util");
30
+ var parseSectionPadding_1 = __importDefault(require("../CustomSection/util/layoutPropParsers/parseSectionPadding"));
31
+ var FlexGridItem_1 = __importDefault(require("./FlexGridItem"));
32
+ var useResizableObserver_1 = require("./useResizableObserver");
33
+ function TempCustomSection(_a) {
34
+ var _b;
35
+ var section = _a.section;
36
+ var _c = (0, react_1.useContext)(dynamicLayoutContext_1.dynamicLayoutContext), device = _c.device, editingSectionId = _c.editingSectionId, mode = _c.mode, shortcutKeyMode = _c.shortcutKeyMode, sectionActionHandler = _c.sectionActionHandler;
37
+ var isMobile = device === 'MOBILE';
38
+ var ref = (0, react_1.useRef)(null);
39
+ var size = (0, useResizableObserver_1.useResizeObserver)({ ref: ref, box: 'border-box' });
40
+ if (!section.jsonProperties) {
41
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "Error: No JsonProperties of section" });
42
+ }
43
+ var _d = section.jsonProperties.data, CB_PLACEMENT_PROP_SECTION = _d.CB_PLACEMENT_PROP_SECTION, CB_LAYOUT_PROP_PADDING = _d.CB_LAYOUT_PROP_PADDING;
44
+ var sectionRow = CB_PLACEMENT_PROP_SECTION.CB_PLACEMENT_PROP_SECTION_SPEC_ROWS;
45
+ var _e = (0, util_1.parseCustomSectionPlacement)({
46
+ isMobile: isMobile,
47
+ customSectionProps: CB_PLACEMENT_PROP_SECTION
48
+ }), rows = _e.rows, width = _e.width, minHeight = _e.minHeight, isFullWidth = _e.isFullWidth;
49
+ var padding = (0, parseSectionPadding_1.default)(CB_LAYOUT_PROP_PADDING, 'DESKTOP');
50
+ var customSectionStyles = {
51
+ minHeight: "".concat(minHeight, "vh"),
52
+ width: '100%',
53
+ maxWidth: isFullWidth ? '' : "".concat(width, "px")
54
+ };
55
+ var rowHeight = (function () {
56
+ if (!size.width) {
57
+ return 50;
58
+ }
59
+ // NOTE: local환경에서 CB_CONTENT_PROP_SECTION이 없는 경우가 있음.
60
+ // const responsiveFontMode =
61
+ // !!CB_CONTENT_PROP_SECTION?.CB_CONTENT_PROP_SECTION_SPEC_VARIABLEROOTFONTSIZE;
62
+ if (device === 'MOBILE') {
63
+ var cellWidth_1 = size.width / CustomSection_1.MOBILE_GRID_COLS;
64
+ // baseFontSize !== 16 && setBaseFontSize(16);
65
+ return cellWidth_1 * 0.56;
66
+ }
67
+ var cellWidth = size.width / CustomSection_1.DESKTOP_GRID_COLS;
68
+ return cellWidth * 0.56;
69
+ // responsiveFontMode ? setBaseFontSize(cellWidth / 2.35) : setBaseFontSize(16);
70
+ })();
71
+ return ((0, jsx_runtime_1.jsx)(S_SectionWrapper, { children: (0, jsx_runtime_1.jsx)(customSectionContext_1.CustomSectionContext.Provider, __assign({ value: { rowHeight: rowHeight, setLayouts: null, sectionActionHandler: null } }, { children: (0, jsx_runtime_1.jsx)(components_1.CustomSection, __assign({}, section, { overrideStyles: {
72
+ minHeight: customSectionStyles.minHeight,
73
+ paddingTop: padding.top,
74
+ paddingBottom: padding.bottom,
75
+ paddingRight: padding.right,
76
+ paddingLeft: padding.left
77
+ } }, { children: (0, jsx_runtime_1.jsx)(GridContainer, __assign({ ref: ref, cols: isMobile ? 8 : 24, rowHeight: rowHeight, sectionRow: sectionRow, style: {
78
+ width: customSectionStyles.width,
79
+ maxWidth: customSectionStyles.maxWidth,
80
+ minWidth: isMobile ? CustomSection_1.GLE_MIN_WIDTH_MOBILE_PX : CustomSection_1.GLE_MIN_WIDTH_DESKTOP_PX,
81
+ fontSize: "16px"
82
+ } }, { children: (_b = section.componentBlocks) === null || _b === void 0 ? void 0 : _b.map(function (cb, index) { return ((0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: (0, jsx_runtime_1.jsx)(FlexGridItem_1.default, { cb: cb, index: index, device: device, rowHeight: rowHeight }) }, cb.id)); }) })) })) })) }));
83
+ }
84
+ var S_SectionWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
85
+ var GridContainer = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: grid; /* Space between grid items */\n gap: 10px;\n grid-template-columns: repeat(", ", 1fr);\n grid-template-rows: repeat(\n ", ",\n minmax(", ", auto)\n );\n\n * {\n box-sizing: border-box;\n }\n"], ["\n display: grid; /* Space between grid items */\n gap: 10px;\n grid-template-columns: repeat(", ", 1fr);\n grid-template-rows: repeat(\n ", ",\n minmax(", ", auto)\n );\n\n * {\n box-sizing: border-box;\n }\n"])), function (props) { return props.cols; }, function (props) { return props.sectionRow; }, function (props) { return "".concat(props.rowHeight, "px"); });
86
+ exports.default = TempCustomSection;
87
+ var templateObject_1, templateObject_2;
@@ -0,0 +1 @@
1
+ export declare function useIsMounted(): () => boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsMounted = void 0;
4
+ var react_1 = require("react");
5
+ function useIsMounted() {
6
+ var isMounted = (0, react_1.useRef)(false);
7
+ (0, react_1.useEffect)(function () {
8
+ isMounted.current = true;
9
+ return function () {
10
+ isMounted.current = false;
11
+ };
12
+ }, []);
13
+ return (0, react_1.useCallback)(function () { return isMounted.current; }, []);
14
+ }
15
+ exports.useIsMounted = useIsMounted;
@@ -0,0 +1,12 @@
1
+ import type { RefObject } from 'react';
2
+ type Size = {
3
+ width: number | undefined;
4
+ height: number | undefined;
5
+ };
6
+ type UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = {
7
+ ref: RefObject<T>;
8
+ onResize?: (size: Size) => void;
9
+ box?: 'border-box' | 'content-box' | 'device-pixel-content-box';
10
+ };
11
+ export declare function useResizeObserver<T extends HTMLElement = HTMLElement>(options: UseResizeObserverOptions<T>): Size;
12
+ export {};
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.useResizeObserver = void 0;
15
+ var react_1 = require("react");
16
+ var useIsMounted_1 = require("./useIsMounted");
17
+ var initialSize = {
18
+ width: undefined,
19
+ height: undefined
20
+ };
21
+ function useResizeObserver(options) {
22
+ var ref = options.ref, _a = options.box, box = _a === void 0 ? 'content-box' : _a;
23
+ var _b = (0, react_1.useState)(initialSize), _c = _b[0], width = _c.width, height = _c.height, setSize = _b[1];
24
+ var isMounted = (0, useIsMounted_1.useIsMounted)();
25
+ var previousSize = (0, react_1.useRef)(__assign({}, initialSize));
26
+ var onResize = (0, react_1.useRef)(undefined);
27
+ onResize.current = options.onResize;
28
+ (0, react_1.useEffect)(function () {
29
+ if (!ref.current)
30
+ return;
31
+ if (typeof window === 'undefined' || !('ResizeObserver' in window))
32
+ return;
33
+ var observer = new ResizeObserver(function (_a) {
34
+ var entry = _a[0];
35
+ var boxProp = box === 'border-box'
36
+ ? 'borderBoxSize'
37
+ : box === 'device-pixel-content-box'
38
+ ? 'devicePixelContentBoxSize'
39
+ : 'contentBoxSize';
40
+ var newWidth = extractSize(entry, boxProp, 'inlineSize');
41
+ var newHeight = extractSize(entry, boxProp, 'blockSize');
42
+ var hasChanged = previousSize.current.width !== newWidth || previousSize.current.height !== newHeight;
43
+ if (hasChanged) {
44
+ var newSize = { width: newWidth, height: newHeight };
45
+ previousSize.current.width = newWidth;
46
+ previousSize.current.height = newHeight;
47
+ if (onResize.current) {
48
+ onResize.current(newSize);
49
+ }
50
+ else if (isMounted()) {
51
+ setSize(newSize);
52
+ }
53
+ }
54
+ });
55
+ observer.observe(ref.current, { box: box });
56
+ return function () {
57
+ observer.disconnect();
58
+ };
59
+ }, [box, ref, isMounted]);
60
+ return { width: width, height: height };
61
+ }
62
+ exports.useResizeObserver = useResizeObserver;
63
+ function extractSize(entry, box, sizeType) {
64
+ if (!entry[box]) {
65
+ if (box === 'contentBoxSize') {
66
+ return entry.contentRect[sizeType === 'inlineSize' ? 'width' : 'height'];
67
+ }
68
+ return undefined;
69
+ }
70
+ return Array.isArray(entry[box])
71
+ ? entry[box][0][sizeType]
72
+ : // @ts-ignore Support Firefox's non-standard behavior
73
+ entry[box][sizeType];
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "2.2.99",
3
+ "version": "2.3.02",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",