pds-dev-kit-web-test 0.3.25 → 0.3.27
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/sections/CustomSection/CustomSection.js +30 -8
- package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/Text.js +0 -7
- package/dist/src/sub/DynamicLayout/sections/CustomSection/hooks/useGroupDrag/useGroupDrag.d.ts +3 -2
- package/dist/src/sub/DynamicLayout/sections/CustomSection/hooks/useGroupDrag/useGroupDrag.js +14 -8
- package/dist/src/sub/DynamicLayout/sections/CustomSection/hooks/useGroupDrag/utils.js +23 -12
- package/dist/src/sub/DynamicLayout/sections/CustomSection/hooks/useIntersectionObserver.js +0 -3
- package/package.json +1 -1
- package/release-note.md +3 -2
|
@@ -53,6 +53,8 @@ var styled_components_1 = __importDefault(require("styled-components"));
|
|
|
53
53
|
var components_1 = require("../../components");
|
|
54
54
|
var ComponentBlockMatcher_1 = __importDefault(require("./components/ComponentBlock/ComponentBlockMatcher"));
|
|
55
55
|
var useGroupDrag_1 = require("./hooks/useGroupDrag");
|
|
56
|
+
var useGroupDrag_2 = require("./hooks/useGroupDrag/useGroupDrag");
|
|
57
|
+
var utils_1 = require("./hooks/useGroupDrag/utils");
|
|
56
58
|
var util_1 = require("./util");
|
|
57
59
|
var parseSectionPadding_1 = __importDefault(require("./util/layoutPropParsers/parseSectionPadding"));
|
|
58
60
|
var WidthProvidedRGL = (0, publ_echo_1.WidthProvider)(ReactGridLayout_1.default);
|
|
@@ -80,20 +82,40 @@ function CustomSection(props) {
|
|
|
80
82
|
sm: sm
|
|
81
83
|
};
|
|
82
84
|
}), layouts = _f[0], setLayouts = _f[1];
|
|
85
|
+
var _g = (0, useGroupDrag_1.useGroupDrag)({
|
|
86
|
+
setLayouts: setLayouts,
|
|
87
|
+
device: device,
|
|
88
|
+
sectionActionHandler: sectionActionHandler
|
|
89
|
+
}), setGroupCB = _g.setGroupCB, breakGroupCB = _g.breakGroupCB, makeAllInOneGroup = _g.makeAllInOneGroup, escapeFromGroup = _g.escapeFromGroup;
|
|
83
90
|
(0, react_1.useEffect)(function () {
|
|
84
91
|
var _a = (0, util_1.parsePlacement)(componentBlocks !== null && componentBlocks !== void 0 ? componentBlocks : []), lg = _a.lg, sm = _a.sm;
|
|
85
|
-
setLayouts(
|
|
86
|
-
|
|
92
|
+
setLayouts(function (prev) {
|
|
93
|
+
var groupInLG = (0, useGroupDrag_2.getGroupCB)(prev.lg);
|
|
94
|
+
var groupInSM = (0, useGroupDrag_2.getGroupCB)(prev.sm);
|
|
95
|
+
var groupedCBIdsInLG = (groupInLG === null || groupInLG === void 0 ? void 0 : groupInLG.childrenIds) || [];
|
|
96
|
+
var groupedCBIdsInSM = (groupInSM === null || groupInSM === void 0 ? void 0 : groupInSM.childrenIds) || [];
|
|
97
|
+
var filteredLG = (0, useGroupDrag_2.filterItemsById)(lg, groupedCBIdsInLG);
|
|
98
|
+
var filteredSM = (0, useGroupDrag_2.filterItemsById)(sm, groupedCBIdsInSM);
|
|
99
|
+
if (groupInLG === null || groupInLG === void 0 ? void 0 : groupInLG.groupLayouts) {
|
|
100
|
+
var newGroupLayout = (0, utils_1.getGroupForMultiple)(lg.filter(function (each) { return groupedCBIdsInLG.includes(each.i); }));
|
|
101
|
+
filteredLG.push(newGroupLayout);
|
|
102
|
+
// eslint-disable-next-line no-console
|
|
103
|
+
console.log({ newGroupLG: newGroupLayout });
|
|
104
|
+
}
|
|
105
|
+
if (groupInSM === null || groupInSM === void 0 ? void 0 : groupInSM.groupLayouts) {
|
|
106
|
+
var newGroupLayout = (0, utils_1.getGroupForMultiple)(sm.filter(function (each) { return groupedCBIdsInSM.includes(each.i); }));
|
|
107
|
+
filteredSM.push(newGroupLayout);
|
|
108
|
+
// eslint-disable-next-line no-console
|
|
109
|
+
console.log({ newGroupSM: newGroupLayout });
|
|
110
|
+
}
|
|
111
|
+
return { lg: filteredLG, sm: filteredSM };
|
|
112
|
+
});
|
|
113
|
+
}, [componentBlocks, useGroupDrag_2.getGroupCB]);
|
|
87
114
|
(0, react_1.useEffect)(function () {
|
|
88
115
|
if (editingSectionId !== props.id) {
|
|
89
116
|
setSelectedCB(null);
|
|
90
117
|
}
|
|
91
118
|
}, [editingSectionId]);
|
|
92
|
-
var _g = (0, useGroupDrag_1.useGroupDrag)({
|
|
93
|
-
setLayouts: setLayouts,
|
|
94
|
-
device: device,
|
|
95
|
-
sectionActionHandler: sectionActionHandler
|
|
96
|
-
}), setGroupCB = _g.setGroupCB, breakGroupCB = _g.breakGroupCB, makeAllInOneGroup = _g.makeAllInOneGroup, escapeFromGroup = _g.escapeFromGroup, getGroupCB = _g.getGroupCB;
|
|
97
119
|
var _h = (0, util_1.parseCustomSectionPlacement)({
|
|
98
120
|
isMobile: isMobile,
|
|
99
121
|
customSectionProps: CB_PLACEMENT_PROP_SECTION
|
|
@@ -206,7 +228,7 @@ function CustomSection(props) {
|
|
|
206
228
|
if (!isEditMode) {
|
|
207
229
|
return;
|
|
208
230
|
}
|
|
209
|
-
if (getGroupCB(layouts[layoutByDevice])) {
|
|
231
|
+
if ((0, useGroupDrag_2.getGroupCB)(layouts[layoutByDevice])) {
|
|
210
232
|
breakGroupCB();
|
|
211
233
|
}
|
|
212
234
|
setSelectedCB(null);
|
|
@@ -48,19 +48,12 @@ function Text(props) {
|
|
|
48
48
|
var cbRef = (0, react_1.useRef)(null);
|
|
49
49
|
var entry = (0, hooks_1.useIntersectionObserver)(cbRef, { threshold: 0.2, freezeOnceVisible: false });
|
|
50
50
|
var isVisible = !!(entry === null || entry === void 0 ? void 0 : entry.isIntersecting);
|
|
51
|
-
console.log('CB-REF', {
|
|
52
|
-
cbRef: cbRef,
|
|
53
|
-
current: cbRef.current,
|
|
54
|
-
text: props.CB_CONTENT_PROP_TEXT.CB_CONTENT_PROP_TEXT_SPEC_TEXT,
|
|
55
|
-
entry: entry
|
|
56
|
-
});
|
|
57
51
|
var effectCssProperties = isVisible ? effect : {};
|
|
58
52
|
var isNoneEffectType = device === 'DESKTOP'
|
|
59
53
|
? CB_EFFECT_PROP_ENTANIM.CB_EFFECT_PROP_ENTANIM_SPEC_TYPE === 'NONE'
|
|
60
54
|
: CB_EFFECT_PROP_ENTANIM['CB_EFFECT_PROP_ENTANIM_SPEC_TYPE:MOBILE'] === 'NONE';
|
|
61
55
|
var hasEffect = !isNoneEffectType;
|
|
62
56
|
var effectVisibleStyle = hasEffect ? { opacity: isVisible ? 1 : 0 } : {};
|
|
63
|
-
console.log({ hasEffect: hasEffect, effectVisibleStyle: effectVisibleStyle });
|
|
64
57
|
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), { 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 })) }))] }));
|
|
65
58
|
}
|
|
66
59
|
function getTextStyles(props, device) {
|
package/dist/src/sub/DynamicLayout/sections/CustomSection/hooks/useGroupDrag/useGroupDrag.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { LayoutItemWithGroupType } from './utils';
|
|
|
3
3
|
import type { LayoutsType } from '../../CustomSection';
|
|
4
4
|
import type { Device } from '../../util/types';
|
|
5
5
|
import type { DynamicLayoutProps } from '../../../../../DynamicLayout/types';
|
|
6
|
-
import type { Layout } from 'publ-echo/dist/lib';
|
|
6
|
+
import type { Layout, LayoutItem } from 'publ-echo/dist/lib';
|
|
7
7
|
type Props = {
|
|
8
8
|
device: Device;
|
|
9
9
|
setLayouts: React.Dispatch<React.SetStateAction<LayoutsType>>;
|
|
@@ -12,8 +12,9 @@ type Props = {
|
|
|
12
12
|
declare function useGroupDrag({ device, setLayouts, sectionActionHandler }: Props): {
|
|
13
13
|
setGroupCB: (selectedId: number | 'group', newId: number) => void;
|
|
14
14
|
breakGroupCB: () => void;
|
|
15
|
-
getGroupCB: (layout: Layout) => LayoutItemWithGroupType | null;
|
|
16
15
|
makeAllInOneGroup: () => void;
|
|
17
16
|
escapeFromGroup: (id: string) => void;
|
|
18
17
|
};
|
|
18
|
+
export declare function getGroupCB(layout: Layout): LayoutItemWithGroupType | null;
|
|
19
|
+
export declare const filterItemsById: (layout: Layout, idsToRemove: string[]) => LayoutItem[];
|
|
19
20
|
export default useGroupDrag;
|
package/dist/src/sub/DynamicLayout/sections/CustomSection/hooks/useGroupDrag/useGroupDrag.js
CHANGED
|
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.filterItemsById = exports.getGroupCB = void 0;
|
|
14
15
|
var utils_1 = require("./utils");
|
|
15
16
|
function useGroupDrag(_a) {
|
|
16
17
|
var device = _a.device, setLayouts = _a.setLayouts, sectionActionHandler = _a.sectionActionHandler;
|
|
@@ -107,14 +108,19 @@ function useGroupDrag(_a) {
|
|
|
107
108
|
}
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return groupItem;
|
|
111
|
+
return { setGroupCB: setGroupCB, breakGroupCB: breakGroupCB, makeAllInOneGroup: makeAllInOneGroup, escapeFromGroup: escapeFromGroup };
|
|
112
|
+
}
|
|
113
|
+
function getGroupCB(layout) {
|
|
114
|
+
var groupIdx = layout.findIndex(function (item) { return item.i === 'group'; });
|
|
115
|
+
if (groupIdx < 0) {
|
|
116
|
+
return null;
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
var groupItem = layout[groupIdx];
|
|
119
|
+
return groupItem;
|
|
119
120
|
}
|
|
121
|
+
exports.getGroupCB = getGroupCB;
|
|
122
|
+
var filterItemsById = function (layout, idsToRemove) {
|
|
123
|
+
return layout.filter(function (item) { return !idsToRemove.includes(item.i); });
|
|
124
|
+
};
|
|
125
|
+
exports.filterItemsById = filterItemsById;
|
|
120
126
|
exports.default = useGroupDrag;
|
|
@@ -57,18 +57,28 @@ function getGroupForMultiple(elems) {
|
|
|
57
57
|
if (elems.length === 0) {
|
|
58
58
|
throw new Error('Array must contain at least one element.');
|
|
59
59
|
}
|
|
60
|
-
var _a = elems.reduce(function (acc, elem) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
minX
|
|
68
|
-
minY
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
var _a = elems.reduce(function (acc, elem, idx, arr) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
if (idx === arr.length - 1) {
|
|
63
|
+
return acc;
|
|
64
|
+
}
|
|
65
|
+
var elem1 = idx === 0 ? elem : acc;
|
|
66
|
+
var elem2 = arr[idx + 1];
|
|
67
|
+
var minX = Math.min(elem1.x, elem2.x);
|
|
68
|
+
var minY = Math.min(elem1.y, elem2.y);
|
|
69
|
+
var elem1W = elem1.x - minX + elem1.w;
|
|
70
|
+
var elem2W = elem2.x - minX + elem2.w;
|
|
71
|
+
var elem1H = elem1.y - minY + elem1.h;
|
|
72
|
+
var elem2H = elem2.y - minY + elem2.h;
|
|
73
|
+
var maxZ = Math.max((_a = elem1 === null || elem1 === void 0 ? void 0 : elem1.z) !== null && _a !== void 0 ? _a : 0, (_b = elem2 === null || elem2 === void 0 ? void 0 : elem2.z) !== null && _b !== void 0 ? _b : 0);
|
|
74
|
+
return {
|
|
75
|
+
x: Math.min(elem1.x, elem2.x),
|
|
76
|
+
y: Math.min(elem1.y, elem2.y),
|
|
77
|
+
w: Math.max(elem1W, elem2W),
|
|
78
|
+
h: Math.max(elem1H, elem2H),
|
|
79
|
+
z: maxZ
|
|
80
|
+
};
|
|
81
|
+
}, { x: 0, y: 0, w: 0, h: 0, z: 0 }), minX = _a.x, minY = _a.y, maxW = _a.w, maxH = _a.h, maxZ = _a.z;
|
|
72
82
|
var groupLayouts = elems.map(function (elem) { return (__assign(__assign({}, elem), { x: elem.x - minX, y: elem.y - minY })); });
|
|
73
83
|
var childrenIds = elems.map(function (elem) { return elem.i; });
|
|
74
84
|
return {
|
|
@@ -77,6 +87,7 @@ function getGroupForMultiple(elems) {
|
|
|
77
87
|
y: minY,
|
|
78
88
|
w: maxW,
|
|
79
89
|
h: maxH,
|
|
90
|
+
z: maxZ,
|
|
80
91
|
groupLayouts: groupLayouts,
|
|
81
92
|
childrenIds: childrenIds
|
|
82
93
|
};
|
|
@@ -15,15 +15,12 @@ function useIntersectionObserver(elementRef, _a) {
|
|
|
15
15
|
var node = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current; // DOM Ref
|
|
16
16
|
var hasIOSupport = !!window.IntersectionObserver;
|
|
17
17
|
if (!hasIOSupport || frozen || !node) {
|
|
18
|
-
console.log('returned', { hasIOSupport: hasIOSupport, frozen: frozen, node: node });
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
var observerParams = { threshold: threshold, root: root, rootMargin: rootMargin };
|
|
22
21
|
var observer = new IntersectionObserver(updateEntry, observerParams);
|
|
23
22
|
observer.observe(node);
|
|
24
|
-
console.log('observe');
|
|
25
23
|
return function () {
|
|
26
|
-
console.log('disconnect,', { observer: observer });
|
|
27
24
|
observer.disconnect();
|
|
28
25
|
};
|
|
29
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
package/package.json
CHANGED