@dotcms/react 0.0.1-alpha.42 → 0.0.1-alpha.44
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 +58 -18
- package/package.json +4 -4
- package/src/lib/hooks/useCheckHaveContent.d.ts +5 -0
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useEffect, createContext, useContext, createElement as createElement$1, forwardRef
|
|
2
|
+
import { useState, useEffect, createContext, useRef, useContext, createElement as createElement$1, forwardRef } from 'react';
|
|
3
3
|
import { isInsideEditor, initEditor, updateNavigation, destroyEditor, DotCmsClient, postMessageToEditor, CUSTOMER_ACTIONS } from '@dotcms/client';
|
|
4
4
|
import { Editor } from '@tinymce/tinymce-react';
|
|
5
5
|
|
|
@@ -1757,10 +1757,14 @@ function styleInject(css, ref) {
|
|
|
1757
1757
|
}
|
|
1758
1758
|
}
|
|
1759
1759
|
|
|
1760
|
-
var css_248z$1 = ".
|
|
1761
|
-
var styles$1 = {"row":"
|
|
1760
|
+
var css_248z$1 = ".Row-module_row__5JPdv {\n display: grid;\n grid-template-columns: repeat(12, 1fr);\n gap: 1rem;\n}\n";
|
|
1761
|
+
var styles$1 = {"row":"Row-module_row__5JPdv"};
|
|
1762
1762
|
styleInject(css_248z$1);
|
|
1763
1763
|
|
|
1764
|
+
var css_248z = ".Column-module_col-start-1__Pxl7H {\n grid-column-start: 1;\n}\n\n.Column-module_col-start-2__jA-nF {\n grid-column-start: 2;\n}\n\n.Column-module_col-start-3__11BXf {\n grid-column-start: 3;\n}\n\n.Column-module_col-start-4__3XRrP {\n grid-column-start: 4;\n}\n\n.Column-module_col-start-5__KQqeO {\n grid-column-start: 5;\n}\n\n.Column-module_col-start-6__P0y54 {\n grid-column-start: 6;\n}\n\n.Column-module_col-start-7__9h9qb {\n grid-column-start: 7;\n}\n\n.Column-module_col-start-8__QwgxN {\n grid-column-start: 8;\n}\n\n.Column-module_col-start-9__Ofunb {\n grid-column-start: 9;\n}\n\n.Column-module_col-start-10__QWMJ3 {\n grid-column-start: 10;\n}\n\n.Column-module_col-start-11__D-Fu9 {\n grid-column-start: 11;\n}\n\n.Column-module_col-start-12__Hf-dO {\n grid-column-start: 12;\n}\n\n.Column-module_col-end-1__MH5yV {\n grid-column-end: 1;\n}\n\n.Column-module_col-end-2__5rzK5 {\n grid-column-end: 2;\n}\n\n.Column-module_col-end-3__KrlkX {\n grid-column-end: 3;\n}\n\n.Column-module_col-end-4__00jk1 {\n grid-column-end: 4;\n}\n\n.Column-module_col-end-5__Y3ls6 {\n grid-column-end: 5;\n}\n\n.Column-module_col-end-6__zmu9A {\n grid-column-end: 6;\n}\n\n.Column-module_col-end-7__PRWOp {\n grid-column-end: 7;\n}\n\n.Column-module_col-end-8__MylGK {\n grid-column-end: 8;\n}\n\n.Column-module_col-end-9__2vhSX {\n grid-column-end: 9;\n}\n\n.Column-module_col-end-10__TBtYO {\n grid-column-end: 10;\n}\n\n.Column-module_col-end-11__Xyk8E {\n grid-column-end: 11;\n}\n\n.Column-module_col-end-12__cOzYW {\n grid-column-end: 12;\n}\n\n.Column-module_col-end-13__cTngu {\n grid-column-end: 13;\n}\n";
|
|
1765
|
+
var styles = {"col-start-1":"Column-module_col-start-1__Pxl7H","col-start-2":"Column-module_col-start-2__jA-nF","col-start-3":"Column-module_col-start-3__11BXf","col-start-4":"Column-module_col-start-4__3XRrP","col-start-5":"Column-module_col-start-5__KQqeO","col-start-6":"Column-module_col-start-6__P0y54","col-start-7":"Column-module_col-start-7__9h9qb","col-start-8":"Column-module_col-start-8__QwgxN","col-start-9":"Column-module_col-start-9__Ofunb","col-start-10":"Column-module_col-start-10__QWMJ3","col-start-11":"Column-module_col-start-11__D-Fu9","col-start-12":"Column-module_col-start-12__Hf-dO","col-end-1":"Column-module_col-end-1__MH5yV","col-end-2":"Column-module_col-end-2__5rzK5","col-end-3":"Column-module_col-end-3__KrlkX","col-end-4":"Column-module_col-end-4__00jk1","col-end-5":"Column-module_col-end-5__Y3ls6","col-end-6":"Column-module_col-end-6__zmu9A","col-end-7":"Column-module_col-end-7__PRWOp","col-end-8":"Column-module_col-end-8__MylGK","col-end-9":"Column-module_col-end-9__2vhSX","col-end-10":"Column-module_col-end-10__TBtYO","col-end-11":"Column-module_col-end-11__Xyk8E","col-end-12":"Column-module_col-end-12__cOzYW","col-end-13":"Column-module_col-end-13__cTngu"};
|
|
1766
|
+
styleInject(css_248z);
|
|
1767
|
+
|
|
1764
1768
|
const endClassMap = {
|
|
1765
1769
|
1: 'col-end-1',
|
|
1766
1770
|
2: 'col-end-2',
|
|
@@ -1843,10 +1847,6 @@ const getPositionStyleClasses = (start, end) => {
|
|
|
1843
1847
|
};
|
|
1844
1848
|
};
|
|
1845
1849
|
|
|
1846
|
-
var css_248z = ".column-module_col-start-1__GK-q- {\n grid-column-start: 1;\n}\n\n.column-module_col-start-2__1DmkY {\n grid-column-start: 2;\n}\n\n.column-module_col-start-3__HNEPh {\n grid-column-start: 3;\n}\n\n.column-module_col-start-4__oCAwh {\n grid-column-start: 4;\n}\n\n.column-module_col-start-5__re1rB {\n grid-column-start: 5;\n}\n\n.column-module_col-start-6__dkB4w {\n grid-column-start: 6;\n}\n\n.column-module_col-start-7__kEfJb {\n grid-column-start: 7;\n}\n\n.column-module_col-start-8__Yx31z {\n grid-column-start: 8;\n}\n\n.column-module_col-start-9__9YiVY {\n grid-column-start: 9;\n}\n\n.column-module_col-start-10__6AFbk {\n grid-column-start: 10;\n}\n\n.column-module_col-start-11__LP24D {\n grid-column-start: 11;\n}\n\n.column-module_col-start-12__8p0QS {\n grid-column-start: 12;\n}\n\n.column-module_col-end-1__G9axv {\n grid-column-end: 1;\n}\n\n.column-module_col-end-2__pYjHG {\n grid-column-end: 2;\n}\n\n.column-module_col-end-3__4woe6 {\n grid-column-end: 3;\n}\n\n.column-module_col-end-4__zlBaT {\n grid-column-end: 4;\n}\n\n.column-module_col-end-5__aC-y8 {\n grid-column-end: 5;\n}\n\n.column-module_col-end-6__YljAP {\n grid-column-end: 6;\n}\n\n.column-module_col-end-7__lpQrW {\n grid-column-end: 7;\n}\n\n.column-module_col-end-8__F6UVd {\n grid-column-end: 8;\n}\n\n.column-module_col-end-9__kvQ3T {\n grid-column-end: 9;\n}\n\n.column-module_col-end-10__XJhrd {\n grid-column-end: 10;\n}\n\n.column-module_col-end-11__nx-lF {\n grid-column-end: 11;\n}\n\n.column-module_col-end-12__LIRnk {\n grid-column-end: 12;\n}\n\n.column-module_col-end-13__0p7YI {\n grid-column-end: 13;\n}\n";
|
|
1847
|
-
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-end-1":"column-module_col-end-1__G9axv","col-end-2":"column-module_col-end-2__pYjHG","col-end-3":"column-module_col-end-3__4woe6","col-end-4":"column-module_col-end-4__zlBaT","col-end-5":"column-module_col-end-5__aC-y8","col-end-6":"column-module_col-end-6__YljAP","col-end-7":"column-module_col-end-7__lpQrW","col-end-8":"column-module_col-end-8__F6UVd","col-end-9":"column-module_col-end-9__kvQ3T","col-end-10":"column-module_col-end-10__XJhrd","col-end-11":"column-module_col-end-11__nx-lF","col-end-12":"column-module_col-end-12__LIRnk","col-end-13":"column-module_col-end-13__0p7YI"};
|
|
1848
|
-
styleInject(css_248z);
|
|
1849
|
-
|
|
1850
1850
|
var NATIVE_BIND$1 = functionBindNative;
|
|
1851
1851
|
|
|
1852
1852
|
var FunctionPrototype = Function.prototype;
|
|
@@ -2022,6 +2022,30 @@ if ($stringify) {
|
|
|
2022
2022
|
});
|
|
2023
2023
|
}
|
|
2024
2024
|
|
|
2025
|
+
const useCheckHaveContent = () => {
|
|
2026
|
+
const contentletDivRef = useRef(null);
|
|
2027
|
+
const [haveContent, setHaveContent] = useState(false);
|
|
2028
|
+
useEffect(() => {
|
|
2029
|
+
if (!contentletDivRef.current) {
|
|
2030
|
+
return;
|
|
2031
|
+
}
|
|
2032
|
+
const childElement = contentletDivRef.current.firstElementChild;
|
|
2033
|
+
if (!childElement) {
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
const height = childElement.getBoundingClientRect().height;
|
|
2037
|
+
if (height > 0) {
|
|
2038
|
+
setHaveContent(true);
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
setHaveContent(false);
|
|
2042
|
+
}, [contentletDivRef]);
|
|
2043
|
+
return {
|
|
2044
|
+
contentletDivRef,
|
|
2045
|
+
haveContent
|
|
2046
|
+
};
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2025
2049
|
/**
|
|
2026
2050
|
* Component to render when there is no component for the content type.
|
|
2027
2051
|
*
|
|
@@ -2062,6 +2086,10 @@ function Container({
|
|
|
2062
2086
|
identifier,
|
|
2063
2087
|
uuid
|
|
2064
2088
|
} = containerRef;
|
|
2089
|
+
const {
|
|
2090
|
+
haveContent,
|
|
2091
|
+
contentletDivRef
|
|
2092
|
+
} = useCheckHaveContent();
|
|
2065
2093
|
// Get the containers from the global context
|
|
2066
2094
|
const {
|
|
2067
2095
|
pageAsset: {
|
|
@@ -2106,6 +2134,10 @@ function Container({
|
|
|
2106
2134
|
"data-dot-type": contentlet.contentType,
|
|
2107
2135
|
"data-dot-container": JSON.stringify(container),
|
|
2108
2136
|
"data-dot-on-number-of-pages": contentlet.onNumberOfPages,
|
|
2137
|
+
ref: contentletDivRef,
|
|
2138
|
+
style: {
|
|
2139
|
+
minHeight: haveContent ? undefined : '4rem'
|
|
2140
|
+
},
|
|
2109
2141
|
children: jsx(Component, Object.assign({}, contentlet))
|
|
2110
2142
|
}, contentlet.identifier) : ( /*#__PURE__*/createElement$1(Component, Object.assign({}, contentlet, {
|
|
2111
2143
|
key: contentlet.identifier
|
|
@@ -2145,16 +2177,19 @@ function Column({
|
|
|
2145
2177
|
startClass,
|
|
2146
2178
|
endClass
|
|
2147
2179
|
} = getPositionStyleClasses(column.leftOffset, column.width + column.leftOffset);
|
|
2148
|
-
const combinedClasses = combineClasses([styles[endClass], styles[startClass]
|
|
2180
|
+
const combinedClasses = combineClasses([styles[endClass], styles[startClass]]);
|
|
2149
2181
|
const columnProps = isInsideEditor ? {
|
|
2150
2182
|
'data-dot': 'column',
|
|
2151
2183
|
'data-testid': 'column'
|
|
2152
2184
|
} : {};
|
|
2153
2185
|
return jsx("div", Object.assign({}, columnProps, {
|
|
2154
2186
|
className: combinedClasses,
|
|
2155
|
-
children:
|
|
2156
|
-
|
|
2157
|
-
|
|
2187
|
+
children: jsx("div", {
|
|
2188
|
+
className: column.styleClass,
|
|
2189
|
+
children: column.containers.map(container => jsx(Container, {
|
|
2190
|
+
containerRef: container
|
|
2191
|
+
}, `${container.identifier}-${container.uuid}`))
|
|
2192
|
+
})
|
|
2158
2193
|
}));
|
|
2159
2194
|
}
|
|
2160
2195
|
|
|
@@ -2173,18 +2208,23 @@ const Row = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2173
2208
|
const {
|
|
2174
2209
|
row
|
|
2175
2210
|
} = props;
|
|
2176
|
-
const combinedClasses = combineClasses([styles$1.row, row.styleClass]);
|
|
2177
2211
|
const rowProps = isInsideEditor ? {
|
|
2178
2212
|
'data-dot': 'row',
|
|
2179
2213
|
'data-testid': 'row',
|
|
2180
2214
|
ref
|
|
2181
2215
|
} : {};
|
|
2182
|
-
return jsx("div",
|
|
2183
|
-
className:
|
|
2184
|
-
children:
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2216
|
+
return jsx("div", {
|
|
2217
|
+
className: row.styleClass,
|
|
2218
|
+
children: jsx("div", {
|
|
2219
|
+
className: "container",
|
|
2220
|
+
children: jsx("div", Object.assign({}, rowProps, {
|
|
2221
|
+
className: styles$1.row,
|
|
2222
|
+
children: row.columns.map((column, index) => jsx(Column, {
|
|
2223
|
+
column: column
|
|
2224
|
+
}, index))
|
|
2225
|
+
}))
|
|
2226
|
+
})
|
|
2227
|
+
});
|
|
2188
2228
|
});
|
|
2189
2229
|
|
|
2190
2230
|
/**
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.44",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=18",
|
|
6
6
|
"react-dom": ">=18",
|
|
7
|
-
"@dotcms/client": "0.0.1-alpha.
|
|
7
|
+
"@dotcms/client": "0.0.1-alpha.44",
|
|
8
8
|
"@tinymce/tinymce-react": "^5.1.1"
|
|
9
9
|
},
|
|
10
10
|
"description": "Official React Components library to render a dotCMS page.",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/dotCMS/core.git#
|
|
13
|
+
"url": "git+https://github.com/dotCMS/core.git#main"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"dotCMS",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"bugs": {
|
|
27
27
|
"url": "https://github.com/dotCMS/core/issues"
|
|
28
28
|
},
|
|
29
|
-
"homepage": "https://github.com/dotCMS/core/tree/
|
|
29
|
+
"homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/react/README.md",
|
|
30
30
|
"module": "./index.esm.js",
|
|
31
31
|
"type": "module",
|
|
32
32
|
"main": "./index.esm.js",
|