@raketa-builder/support 1.2.1 → 1.3.0
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/index.js +45 -3
- package/package.json +1 -1
- package/src/Container.js +2 -2
- package/src/WidgetRender/index.js +47 -0
- package/src/index.js +2 -0
package/dist/index.js
CHANGED
|
@@ -63,6 +63,7 @@ __export(index_exports, {
|
|
|
63
63
|
Container: () => Container_default,
|
|
64
64
|
EmbeddedVideo: () => EmbeddedVideo_default,
|
|
65
65
|
Image: () => Image_default,
|
|
66
|
+
WidgetRender: () => WidgetRender_default,
|
|
66
67
|
extractImageValue: () => extractImageValue_default,
|
|
67
68
|
imagePlaceholder: () => imagePlaceholder_default,
|
|
68
69
|
imageSrc: () => imageSrc_default,
|
|
@@ -193,10 +194,11 @@ var imagePlaceholder_default = imagePlaceholder;
|
|
|
193
194
|
// src/Container.js
|
|
194
195
|
var import_react2 = __toESM(require("react"));
|
|
195
196
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
196
|
-
var Container = (
|
|
197
|
-
|
|
197
|
+
var Container = (_a) => {
|
|
198
|
+
var _b = _a, { settings, className, children } = _b, rest = __objRest(_b, ["settings", "className", "children"]);
|
|
199
|
+
const _a2 = settings || {}, { containerID } = _a2, restSettings = __objRest(_a2, ["containerID"]);
|
|
198
200
|
const cssClasses = [...Object.values(restSettings), className].join(" ");
|
|
199
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { id: containerID, className: cssClasses, children });
|
|
201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", __spreadProps(__spreadValues({ id: containerID, className: cssClasses }, rest), { children }));
|
|
200
202
|
};
|
|
201
203
|
var Container_default = Container;
|
|
202
204
|
|
|
@@ -616,6 +618,45 @@ var AdminPageRender = ({
|
|
|
616
618
|
};
|
|
617
619
|
var AdminPageRender_default = AdminPageRender;
|
|
618
620
|
|
|
621
|
+
// src/WidgetRender/index.js
|
|
622
|
+
var import_react7 = __toESM(require("react"));
|
|
623
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
624
|
+
var WidgetRender = ({
|
|
625
|
+
library,
|
|
626
|
+
entity,
|
|
627
|
+
page,
|
|
628
|
+
context = {},
|
|
629
|
+
preloaded = {},
|
|
630
|
+
locale = "es"
|
|
631
|
+
}) => {
|
|
632
|
+
var _a;
|
|
633
|
+
const pageData = page || entity;
|
|
634
|
+
context = __spreadProps(__spreadValues({}, context), {
|
|
635
|
+
locale: (_a = context.locale) != null ? _a : locale
|
|
636
|
+
});
|
|
637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: pageData.widgets.map(({ widgetId, component, settings }) => {
|
|
638
|
+
if (!library[component]) {
|
|
639
|
+
console.error(
|
|
640
|
+
`Unknown widget: {widgetId: ${widgetId}, component: ${component}, settings: ${settings}}`
|
|
641
|
+
);
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
645
|
+
Container_default,
|
|
646
|
+
{
|
|
647
|
+
settings: (settings == null ? void 0 : settings.containerSettings) || {},
|
|
648
|
+
"data-widget": component,
|
|
649
|
+
children: import_react7.default.createElement(library[component], __spreadProps(__spreadValues({}, settings), {
|
|
650
|
+
__ctx: context,
|
|
651
|
+
__data: (preloaded == null ? void 0 : preloaded[widgetId]) || {}
|
|
652
|
+
}))
|
|
653
|
+
},
|
|
654
|
+
widgetId
|
|
655
|
+
);
|
|
656
|
+
}) });
|
|
657
|
+
};
|
|
658
|
+
var WidgetRender_default = WidgetRender;
|
|
659
|
+
|
|
619
660
|
// src/extractImageValue.js
|
|
620
661
|
function extractImageValue(value) {
|
|
621
662
|
if (!value) {
|
|
@@ -630,6 +671,7 @@ var extractImageValue_default = extractImageValue;
|
|
|
630
671
|
Container,
|
|
631
672
|
EmbeddedVideo,
|
|
632
673
|
Image,
|
|
674
|
+
WidgetRender,
|
|
633
675
|
extractImageValue,
|
|
634
676
|
imagePlaceholder,
|
|
635
677
|
imageSrc,
|
package/package.json
CHANGED
package/src/Container.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
const Container = ({ settings, className, children }) => {
|
|
3
|
+
const Container = ({ settings, className, children, ...rest }) => {
|
|
4
4
|
const { containerID, ...restSettings } = settings || {};
|
|
5
5
|
|
|
6
6
|
const cssClasses = [...Object.values(restSettings), className].join(" ");
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
|
-
<div id={containerID} className={cssClasses}>
|
|
9
|
+
<div id={containerID} className={cssClasses} {...rest}>
|
|
10
10
|
{children}
|
|
11
11
|
</div>
|
|
12
12
|
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Container from "../Container";
|
|
3
|
+
|
|
4
|
+
const WidgetRender = ({
|
|
5
|
+
library,
|
|
6
|
+
entity,
|
|
7
|
+
page,
|
|
8
|
+
context = {},
|
|
9
|
+
preloaded = {},
|
|
10
|
+
locale = "es",
|
|
11
|
+
}) => {
|
|
12
|
+
const pageData = page || entity;
|
|
13
|
+
|
|
14
|
+
context = {
|
|
15
|
+
...context,
|
|
16
|
+
locale: context.locale ?? locale,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
{pageData.widgets.map(({ widgetId, component, settings }) => {
|
|
22
|
+
if (!library[component]) {
|
|
23
|
+
console.error(
|
|
24
|
+
`Unknown widget: {widgetId: ${widgetId}, component: ${component}, settings: ${settings}}`
|
|
25
|
+
);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Container
|
|
31
|
+
key={widgetId}
|
|
32
|
+
settings={settings?.containerSettings || {}}
|
|
33
|
+
data-widget={component}
|
|
34
|
+
>
|
|
35
|
+
{React.createElement(library[component], {
|
|
36
|
+
...settings,
|
|
37
|
+
__ctx: context,
|
|
38
|
+
__data: preloaded?.[widgetId] || {},
|
|
39
|
+
})}
|
|
40
|
+
</Container>
|
|
41
|
+
);
|
|
42
|
+
})}
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default WidgetRender;
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import EmbeddedVideo from "./EmbeddedVideo";
|
|
|
6
6
|
import toHTML from "./toHTML";
|
|
7
7
|
import isImagePresent from "./isImagePresent";
|
|
8
8
|
import AdminPageRender from "./AdminPageRender";
|
|
9
|
+
import WidgetRender from "./WidgetRender";
|
|
9
10
|
import extractImageValue from "./extractImageValue";
|
|
10
11
|
|
|
11
12
|
export {
|
|
@@ -18,4 +19,5 @@ export {
|
|
|
18
19
|
EmbeddedVideo,
|
|
19
20
|
toHTML,
|
|
20
21
|
AdminPageRender,
|
|
22
|
+
WidgetRender,
|
|
21
23
|
};
|