pds-dev-kit-web-test 2.3.8 → 2.3.10
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.
- package/dist/src/sub/DynamicLayout/components/SectionMatcher/SectionMatcher.js +3 -0
- package/dist/src/sub/DynamicLayout/pagesPreviewMock.d.ts +1112 -446
- package/dist/src/sub/DynamicLayout/pagesPreviewMock.js +2071 -814
- package/dist/src/sub/DynamicLayout/sectionActionTypes.d.ts +10 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.d.ts +6 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.js +80 -64
- package/dist/src/sub/DynamicLayout/sections/CustomSection/NewCustomSection.d.ts +3 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/NewCustomSection.js +70 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/ComponentBlockMatcher.d.ts +2 -1
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/ComponentBlockMatcher.js +3 -3
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Button/Button.js +1 -1
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/Text.d.ts +3 -1
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/Text.js +57 -1
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/index.d.ts +1 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/index.js +8 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/components/S_CB_Box.js +1 -1
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/index.d.ts +1 -1
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/index.js +3 -3
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/index.d.ts +1 -1
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/index.js +2 -2
- package/dist/src/sub/DynamicLayout/sections/CustomSection/customSectionContext.d.ts +10 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/customSectionContext.js +21 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/newUtils/textUtil.js +12 -1
- package/dist/src/sub/DynamicLayout/sections/TempCustomSection/FlexGridItem.d.ts +11 -0
- package/dist/src/sub/DynamicLayout/sections/TempCustomSection/FlexGridItem.js +69 -0
- package/dist/src/sub/DynamicLayout/sections/TempCustomSection/TempCustomSection.d.ts +7 -0
- package/dist/src/sub/DynamicLayout/sections/TempCustomSection/TempCustomSection.js +87 -0
- package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useIsMounted.d.ts +1 -0
- package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useIsMounted.js +15 -0
- package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useResizableObserver.d.ts +12 -0
- package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useResizableObserver.js +74 -0
- package/package.json +5 -2
- package/dist/src/sub/SandollFontKit/api/getSandollFonts.d.ts +0 -14
- package/dist/src/sub/SandollFontKit/api/getSandollFonts.js +0 -77
- package/dist/src/sub/SandollFontKit/api/types.d.ts +0 -49
- package/dist/src/sub/SandollFontKit/api/types.js +0 -2
- package/dist/src/sub/SandollFontKit/constants.d.ts +0 -9
- package/dist/src/sub/SandollFontKit/constants.js +0 -33
- package/dist/src/sub/SandollFontKit/headless/SandollFontItem.d.ts +0 -13
- package/dist/src/sub/SandollFontKit/headless/SandollFontItem.js +0 -74
- package/dist/src/sub/SandollFontKit/headless/SandollFontsList.d.ts +0 -18
- package/dist/src/sub/SandollFontKit/headless/SandollFontsList.js +0 -74
- package/dist/src/sub/SandollFontKit/hooks/useQueryParamsReducer.d.ts +0 -30
- package/dist/src/sub/SandollFontKit/hooks/useQueryParamsReducer.js +0 -69
- package/dist/src/sub/SandollFontKit/index.d.ts +0 -5
- package/dist/src/sub/SandollFontKit/index.js +0 -28
- package/dist/src/sub/SandollFontKit/types.d.ts +0 -14
- package/dist/src/sub/SandollFontKit/types.js +0 -2
- package/dist/src/sub/SandollFontKit/utils/createSandollFontLink.d.ts +0 -2
- package/dist/src/sub/SandollFontKit/utils/createSandollFontLink.js +0 -24
- package/dist/src/sub/SandollFontKit/utils/delay.d.ts +0 -1
- package/dist/src/sub/SandollFontKit/utils/delay.js +0 -6
@@ -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;
|
@@ -5,6 +5,7 @@ type Props = {
|
|
5
5
|
cbProps: ComponentBlock;
|
6
6
|
device: Device;
|
7
7
|
index: number;
|
8
|
+
id: number;
|
8
9
|
};
|
9
|
-
export default function ComponentBlockMatcher({ cbProps, device, index }: Props): JSX.Element;
|
10
|
+
export default function ComponentBlockMatcher({ cbProps, device, index, id }: Props): JSX.Element;
|
10
11
|
export {};
|
@@ -23,18 +23,18 @@ var Divider_1 = __importDefault(require("./componentBlocks/Divider/Divider"));
|
|
23
23
|
var Embed_1 = __importDefault(require("./componentBlocks/Embed/Embed"));
|
24
24
|
var Image_1 = __importDefault(require("./componentBlocks/Image/Image"));
|
25
25
|
var RichText_1 = require("./componentBlocks/RichText");
|
26
|
-
var Text_1 =
|
26
|
+
var Text_1 = require("./componentBlocks/Text");
|
27
27
|
var Twitter_1 = __importDefault(require("./componentBlocks/Twitter/Twitter"));
|
28
28
|
var Youtube_1 = require("./componentBlocks/Youtube");
|
29
29
|
function ComponentBlockMatcher(_a) {
|
30
|
-
var cbProps = _a.cbProps, device = _a.device, index = _a.index;
|
30
|
+
var cbProps = _a.cbProps, device = _a.device, index = _a.index, id = _a.id;
|
31
31
|
var componentBlockCode = cbProps.componentBlockCode, data = cbProps.jsonProperties.data;
|
32
32
|
var propsWithValue = device === 'MOBILE' ? (0, newUtils_1.replaceUndefinedValues)(data) : data;
|
33
33
|
switch (componentBlockCode) {
|
34
34
|
case types_1.CB_ALL_CODES.CB_BTN:
|
35
35
|
return (0, jsx_runtime_1.jsx)(Button_1.default, __assign({}, propsWithValue, { index: index }));
|
36
36
|
case types_1.CB_ALL_CODES.CB_TEXT:
|
37
|
-
return (0, jsx_runtime_1.jsx)(Text_1.
|
37
|
+
return (0, jsx_runtime_1.jsx)(Text_1.Text, __assign({}, propsWithValue, { index: index, id: id }));
|
38
38
|
case types_1.CB_ALL_CODES.CB_RICHTEXT:
|
39
39
|
return (0, jsx_runtime_1.jsx)(RichText_1.RichText, __assign({}, propsWithValue, { index: index }));
|
40
40
|
case types_1.CB_ALL_CODES.CB_DIVIDER:
|
@@ -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 :
|
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,
|
@@ -1,5 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import type { CB_TEXT_PROPERTIES_TYPE, IndexForIntersection } from '../../../../util/types';
|
3
|
-
type Props = CB_TEXT_PROPERTIES_TYPE & IndexForIntersection
|
3
|
+
type Props = CB_TEXT_PROPERTIES_TYPE & IndexForIntersection & {
|
4
|
+
id: number;
|
5
|
+
};
|
4
6
|
declare function Text(props: Props): JSX.Element;
|
5
7
|
export default Text;
|
@@ -17,8 +17,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
18
18
|
/* eslint-disable no-console */
|
19
19
|
/* eslint-disable react/destructuring-assignment */
|
20
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
21
|
+
var lodash_1 = require("lodash");
|
20
22
|
var react_1 = require("react");
|
23
|
+
require("react-measure");
|
21
24
|
var DynamicLayout_1 = require("../../../../../../../DynamicLayout");
|
25
|
+
var customSectionContext_1 = require("../../../../../../../DynamicLayout/sections/CustomSection/customSectionContext");
|
22
26
|
var hooks_1 = require("../../../../hooks");
|
23
27
|
var getGoogleFonts_1 = require("../../../../hooks/useGoogleFonts/getGoogleFonts");
|
24
28
|
var useGoogleFonts_1 = __importDefault(require("../../../../hooks/useGoogleFonts/useGoogleFonts"));
|
@@ -30,6 +34,7 @@ var S_HiddenCover_1 = require("../components/S_HiddenCover");
|
|
30
34
|
var useCLINK_1 = __importDefault(require("../hooks/useCLINK"));
|
31
35
|
function Text(props) {
|
32
36
|
var _a = (0, react_1.useContext)(DynamicLayout_1.dynamicLayoutContext), device = _a.device, mode = _a.mode;
|
37
|
+
console.log(props.id);
|
33
38
|
var index = props.index, _b = props.CB_CONTENT_PROP_CLINK, CB_CONTENT_PROP_CLINK_SPEC_SRC = _b.CB_CONTENT_PROP_CLINK_SPEC_SRC, CB_CONTENT_PROP_CLINK_SPEC_TYPE = _b.CB_CONTENT_PROP_CLINK_SPEC_TYPE, CB_CONTENT_PROP_CLINK_SPEC_NEWTAB = _b.CB_CONTENT_PROP_CLINK_SPEC_NEWTAB, CB_CONTENT_PROP_CLINK_SPEC_INTERNALSRC = _b.CB_CONTENT_PROP_CLINK_SPEC_INTERNALSRC, CB_EFFECT_PROP_ENTANIM = props.CB_EFFECT_PROP_ENTANIM;
|
34
39
|
var _c = (0, useCLINK_1.default)({
|
35
40
|
src: CB_CONTENT_PROP_CLINK_SPEC_SRC,
|
@@ -56,7 +61,48 @@ function Text(props) {
|
|
56
61
|
: CB_EFFECT_PROP_ENTANIM['CB_EFFECT_PROP_ENTANIM_SPEC_TYPE:MOBILE'] === 'NONE';
|
57
62
|
var hasEffect = !isNoneEffectType;
|
58
63
|
var effectVisibleStyle = hasEffect ? { opacity: isVisible ? 1 : 0 } : {};
|
59
|
-
|
64
|
+
var _f = (0, customSectionContext_1.useCustomSectionContext)(), setLayouts = _f.setLayouts, rowHeight = _f.rowHeight, sectionActionHandler = _f.sectionActionHandler;
|
65
|
+
var debouncedSectionActionHandler = (0, react_1.useCallback)((0, lodash_1.debounce)(function (payload) {
|
66
|
+
sectionActionHandler &&
|
67
|
+
sectionActionHandler({
|
68
|
+
type: '@CUSTOMSECTION/AUTO_RESIZED_TO_FIT_CONTENT',
|
69
|
+
payload: payload
|
70
|
+
});
|
71
|
+
}, 1000), []);
|
72
|
+
// const handleResize = (contentRect: ContentRect) => {
|
73
|
+
// const breakpoint = device === 'DESKTOP' ? 'lg' : 'sm';
|
74
|
+
// const scrollHeight = contentRect.scroll?.height;
|
75
|
+
// const clientHeight = contentRect.client?.height;
|
76
|
+
// if (!scrollHeight || !clientHeight) {
|
77
|
+
// return;
|
78
|
+
// }
|
79
|
+
// if (clientHeight < scrollHeight) {
|
80
|
+
// return;
|
81
|
+
// }
|
82
|
+
// const { id } = props;
|
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
|
+
// // });
|
102
|
+
// };
|
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)(S_CB_Box_1.S_CB_Box, __assign({ className: "cb-layout-box", normalStyle: __assign(__assign(__assign(__assign(__assign({}, textStyle), propsStyle), layoutStyle), effectCssProperties), {
|
104
|
+
// width: cbRef.current ? calculateCh(cbRef.current, '1rem') : '100%',
|
105
|
+
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 })) }))] }));
|
60
106
|
}
|
61
107
|
function getTextStyles(props, device) {
|
62
108
|
var availableSpecCodes = [
|
@@ -71,4 +117,14 @@ function getTextStyles(props, device) {
|
|
71
117
|
];
|
72
118
|
return (0, textUtil_1.parseStyleTextToCSSProp)({ availableSpecCodes: availableSpecCodes, props: props, device: device, propKey: 'TEXT' });
|
73
119
|
}
|
120
|
+
function calculateCh(element, fontSize) {
|
121
|
+
var zero = document.createElement('span');
|
122
|
+
zero.innerText = '0';
|
123
|
+
zero.style.position = 'absolute';
|
124
|
+
zero.style.fontSize = fontSize;
|
125
|
+
element.appendChild(zero);
|
126
|
+
var chPixels = zero.getBoundingClientRect().width;
|
127
|
+
element.removeChild(zero);
|
128
|
+
return "".concat(320 / chPixels, "ch");
|
129
|
+
}
|
74
130
|
exports.default = Text;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as Text } from './Text';
|
@@ -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.Text = void 0;
|
7
|
+
var Text_1 = require("./Text");
|
8
|
+
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return __importDefault(Text_1).default; } });
|
@@ -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) {
|
package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { default as
|
1
|
+
export { default as ComponentBlockMatcher } from './ComponentBlockMatcher';
|
package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/index.js
CHANGED
@@ -3,6 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.
|
7
|
-
var
|
8
|
-
Object.defineProperty(exports, "
|
6
|
+
exports.ComponentBlockMatcher = void 0;
|
7
|
+
var ComponentBlockMatcher_1 = require("./ComponentBlockMatcher");
|
8
|
+
Object.defineProperty(exports, "ComponentBlockMatcher", { enumerable: true, get: function () { return __importDefault(ComponentBlockMatcher_1).default; } });
|
@@ -1 +1 @@
|
|
1
|
-
export {
|
1
|
+
export { ComponentBlockMatcher } from './ComponentBlock';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.ComponentBlockMatcher = void 0;
|
4
4
|
var ComponentBlock_1 = require("./ComponentBlock");
|
5
|
-
Object.defineProperty(exports, "
|
5
|
+
Object.defineProperty(exports, "ComponentBlockMatcher", { enumerable: true, get: function () { return ComponentBlock_1.ComponentBlockMatcher; } });
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { LayoutsType } from './CustomSection';
|
3
|
+
import type { TypeOfSectionAction } from '../../../DynamicLayout/sectionActionTypes';
|
4
|
+
export interface CustomSectionContext {
|
5
|
+
rowHeight: number;
|
6
|
+
setLayouts: React.Dispatch<React.SetStateAction<LayoutsType>>;
|
7
|
+
sectionActionHandler?: (action: TypeOfSectionAction) => void;
|
8
|
+
}
|
9
|
+
export declare const CustomSectionContext: React.Context<CustomSectionContext | undefined>;
|
10
|
+
export declare function useCustomSectionContext(): CustomSectionContext;
|
@@ -0,0 +1,21 @@
|
|
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.useCustomSectionContext = exports.CustomSectionContext = void 0;
|
7
|
+
var react_1 = __importDefault(require("react"));
|
8
|
+
exports.CustomSectionContext = react_1.default.createContext(undefined);
|
9
|
+
// export const CustomSectionContextProvider: React.FC = ({ children }) => {
|
10
|
+
// const [user, setUser] = React.useState<string>('');
|
11
|
+
// const value = { user, setUser };
|
12
|
+
// return <CustomSectionContext.Provider value={value}>{children}</CustomSectionContext.Provider>;
|
13
|
+
// };
|
14
|
+
function useCustomSectionContext() {
|
15
|
+
var context = react_1.default.useContext(exports.CustomSectionContext);
|
16
|
+
if (context === undefined) {
|
17
|
+
throw new Error('useCustomSectionContext must be used within an AppProvider');
|
18
|
+
}
|
19
|
+
return context;
|
20
|
+
}
|
21
|
+
exports.useCustomSectionContext = useCustomSectionContext;
|
@@ -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
|
-
|
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,69 @@
|
|
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
|
+
var gap = 10;
|
27
|
+
function FlexGridItem(_a) {
|
28
|
+
var cb = _a.cb, index = _a.index, device = _a.device, rowHeight = _a.rowHeight;
|
29
|
+
var defaultHeight = getMaxHeight(cb.jsonProperties.data.CB_PLACEMENT_PROP_PLACEMENT, device, rowHeight);
|
30
|
+
var gridArea = getGridAreaFromCB(cb.jsonProperties.data.CB_PLACEMENT_PROP_PLACEMENT, device);
|
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 getMaxHeight(props, device, rowHeight) {
|
39
|
+
if (device === 'DESKTOP') {
|
40
|
+
var CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS = props.CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS;
|
41
|
+
var height_1 = (CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS * rowHeight) + ((CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS - 1) * gap);
|
42
|
+
return height_1;
|
43
|
+
}
|
44
|
+
var rowsMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS:MOBILE'];
|
45
|
+
var height = (rowsMobile * rowHeight) + ((rowsMobile - 1) * gap);
|
46
|
+
return height;
|
47
|
+
}
|
48
|
+
function getGridAreaFromCB(props, device) {
|
49
|
+
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;
|
50
|
+
if (device === 'DESKTOP') {
|
51
|
+
var colStart_1 = CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX + 1;
|
52
|
+
var rowStart_1 = CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTY + 1;
|
53
|
+
var rowEnd_1 = rows + rowStart_1;
|
54
|
+
var colEnd_1 = cols + colStart_1;
|
55
|
+
// <grid-row-start> / <grid-column-start> / <grid-row-end> / <grid-column-end>;
|
56
|
+
return "".concat(rowStart_1, " / ").concat(colStart_1, " / ").concat(rowEnd_1, " / ").concat(colEnd_1);
|
57
|
+
}
|
58
|
+
var startXMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTX:MOBILE'];
|
59
|
+
var startYMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_STARTY:MOBILE'];
|
60
|
+
var colsMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_COLS:MOBILE'];
|
61
|
+
var rowsMobile = props['CB_PLACEMENT_PROP_PLACEMENT_SPEC_ROWS:MOBILE'];
|
62
|
+
var colStart = startXMobile + 1;
|
63
|
+
var rowStart = startYMobile + 1;
|
64
|
+
var rowEnd = rowsMobile + rowStart;
|
65
|
+
var colEnd = colsMobile + colStart;
|
66
|
+
return "".concat(rowStart, " / ").concat(colStart, " / ").concat(rowEnd, " / ").concat(colEnd);
|
67
|
+
}
|
68
|
+
exports.default = FlexGridItem;
|
69
|
+
var templateObject_1, templateObject_2;
|
@@ -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
|
+
}
|