@dotcms/react 0.0.1-alpha.3 → 0.0.1-alpha.4
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/index.esm.js +57 -3
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -2527,7 +2527,37 @@ function useEventMessageHandler({
|
|
|
2527
2527
|
reload = window.location.reload
|
|
2528
2528
|
}) {
|
|
2529
2529
|
const rows = useRef([]);
|
|
2530
|
+
const observer = useRef(null);
|
|
2530
2531
|
const [isInsideEditor, setIsInsideEditor] = useState(false);
|
|
2532
|
+
useEffect(() => {
|
|
2533
|
+
var _observer$current;
|
|
2534
|
+
observer.current = new MutationObserver(mutationsList => {
|
|
2535
|
+
for (const {
|
|
2536
|
+
addedNodes,
|
|
2537
|
+
removedNodes,
|
|
2538
|
+
type
|
|
2539
|
+
} of mutationsList) {
|
|
2540
|
+
if (type === 'childList') {
|
|
2541
|
+
const didNodesChanged = [...Array.from(addedNodes), ...Array.from(removedNodes)].filter(node => {
|
|
2542
|
+
var _node$dataset;
|
|
2543
|
+
return ((_node$dataset = node.dataset) == null ? void 0 : _node$dataset.dot) === 'contentlet';
|
|
2544
|
+
}).length;
|
|
2545
|
+
if (didNodesChanged) {
|
|
2546
|
+
postMessageToEditor({
|
|
2547
|
+
action: CUSTOMER_ACTIONS.CONTENT_CHANGE
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
});
|
|
2553
|
+
(_observer$current = observer.current) == null || _observer$current.observe(document, {
|
|
2554
|
+
childList: true,
|
|
2555
|
+
subtree: true
|
|
2556
|
+
});
|
|
2557
|
+
return () => {
|
|
2558
|
+
if (observer.current) observer.current.disconnect();
|
|
2559
|
+
};
|
|
2560
|
+
}, []);
|
|
2531
2561
|
useEffect(() => {
|
|
2532
2562
|
// If the page is not inside an iframe we do nothing.
|
|
2533
2563
|
if (window.parent === window) return;
|
|
@@ -2653,6 +2683,28 @@ var css_248z = ".column-module_col-start-1__GK-q- {\n grid-column-start: 1;\n
|
|
|
2653
2683
|
var styles = {"col-start-1":"column-module_col-start-1__GK-q-","col-start-2":"column-module_col-start-2__1DmkY","col-start-3":"column-module_col-start-3__HNEPh","col-start-4":"column-module_col-start-4__oCAwh","col-start-5":"column-module_col-start-5__re1rB","col-start-6":"column-module_col-start-6__dkB4w","col-start-7":"column-module_col-start-7__kEfJb","col-start-8":"column-module_col-start-8__Yx31z","col-start-9":"column-module_col-start-9__9YiVY","col-start-10":"column-module_col-start-10__6AFbk","col-start-11":"column-module_col-start-11__LP24D","col-start-12":"column-module_col-start-12__8p0QS","col-span-1":"column-module_col-span-1__vOPKg","col-span-2":"column-module_col-span-2__qVdyn","col-span-3":"column-module_col-span-3__brcdA","col-span-4":"column-module_col-span-4__1-c-f","col-span-5":"column-module_col-span-5__nAGLD","col-span-6":"column-module_col-span-6__emtw7","col-span-7":"column-module_col-span-7__Ad5-V","col-span-8":"column-module_col-span-8__gEnsA","col-span-9":"column-module_col-span-9__jWemC","col-span-10":"column-module_col-span-10__Dzuph","col-span-11":"column-module_col-span-11__Xgct2","col-span-12":"column-module_col-span-12__LvJrY"};
|
|
2654
2684
|
styleInject(css_248z);
|
|
2655
2685
|
|
|
2686
|
+
const FAKE_CONTENLET = {
|
|
2687
|
+
identifier: 'TEMP_EMPTY_CONTENTLET',
|
|
2688
|
+
title: 'TEMP_EMPTY_CONTENTLET',
|
|
2689
|
+
contentType: 'TEMP_EMPTY_CONTENTLET_TYPE',
|
|
2690
|
+
inode: 'TEMPY_EMPTY_CONTENTLET_INODE',
|
|
2691
|
+
widgetTitle: 'TEMP_EMPTY_CONTENTLET'
|
|
2692
|
+
};
|
|
2693
|
+
function EmptyContainer() {
|
|
2694
|
+
return jsx("div", {
|
|
2695
|
+
"data-testid": "empty-container",
|
|
2696
|
+
style: {
|
|
2697
|
+
width: '100%',
|
|
2698
|
+
backgroundColor: '#ECF0FD',
|
|
2699
|
+
display: 'flex',
|
|
2700
|
+
justifyContent: 'center',
|
|
2701
|
+
alignItems: 'center',
|
|
2702
|
+
color: '#030E32',
|
|
2703
|
+
height: '10rem'
|
|
2704
|
+
},
|
|
2705
|
+
children: "This container is empty."
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2656
2708
|
function NoContent({
|
|
2657
2709
|
contentType
|
|
2658
2710
|
}) {
|
|
@@ -2684,7 +2736,8 @@ function Container({
|
|
|
2684
2736
|
pageContainers,
|
|
2685
2737
|
path
|
|
2686
2738
|
} = getContainersData(containers, containerRef);
|
|
2687
|
-
const
|
|
2739
|
+
const updatedContentlets = contentlets.length > 0 ? contentlets : [FAKE_CONTENLET];
|
|
2740
|
+
const contentletsId = updatedContentlets.map(contentlet => contentlet.identifier);
|
|
2688
2741
|
const container = {
|
|
2689
2742
|
acceptTypes,
|
|
2690
2743
|
contentletsId,
|
|
@@ -2726,9 +2779,10 @@ function Container({
|
|
|
2726
2779
|
}
|
|
2727
2780
|
});
|
|
2728
2781
|
}
|
|
2729
|
-
const renderContentlets =
|
|
2782
|
+
const renderContentlets = updatedContentlets.map(contentlet => {
|
|
2730
2783
|
var _viewAs$persona2;
|
|
2731
|
-
const
|
|
2784
|
+
const ContentTypeComponent = components[contentlet.contentType] || NoContent;
|
|
2785
|
+
const Component = contentlet.identifier === 'TEMP_EMPTY_CONTENTLET' ? EmptyContainer : ContentTypeComponent;
|
|
2732
2786
|
const contentletPayload = {
|
|
2733
2787
|
container,
|
|
2734
2788
|
contentlet: {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.4",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": "^18",
|
|
6
6
|
"react-dom": "^18",
|
|
7
|
-
"@dotcms/client": "
|
|
7
|
+
"@dotcms/client": "0.0.1-alpha.4"
|
|
8
8
|
},
|
|
9
9
|
"description": "Official React Components library to render a dotCMS page.",
|
|
10
10
|
"repository": {
|