@raketa-builder/support 1.1.7 → 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 +68 -34
- package/package.json +12 -12
- package/src/Container.js +2 -2
- package/src/WidgetRender/index.js +47 -0
- package/src/index.js +2 -0
package/dist/index.js
CHANGED
|
@@ -47,39 +47,42 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
47
47
|
return to;
|
|
48
48
|
};
|
|
49
49
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
50
54
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
51
55
|
mod
|
|
52
56
|
));
|
|
53
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
54
58
|
|
|
55
59
|
// src/index.js
|
|
56
|
-
var
|
|
57
|
-
__export(
|
|
60
|
+
var index_exports = {};
|
|
61
|
+
__export(index_exports, {
|
|
58
62
|
AdminPageRender: () => AdminPageRender_default,
|
|
59
63
|
Container: () => Container_default,
|
|
60
64
|
EmbeddedVideo: () => EmbeddedVideo_default,
|
|
61
65
|
Image: () => Image_default,
|
|
66
|
+
WidgetRender: () => WidgetRender_default,
|
|
62
67
|
extractImageValue: () => extractImageValue_default,
|
|
63
68
|
imagePlaceholder: () => imagePlaceholder_default,
|
|
64
69
|
imageSrc: () => imageSrc_default,
|
|
65
70
|
isImagePresent: () => isImagePresent_default,
|
|
66
71
|
toHTML: () => toHTML_default
|
|
67
72
|
});
|
|
68
|
-
module.exports = __toCommonJS(
|
|
73
|
+
module.exports = __toCommonJS(index_exports);
|
|
69
74
|
|
|
70
75
|
// src/Image.js
|
|
71
76
|
var import_react = __toESM(require("react"));
|
|
72
77
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
73
78
|
var getWebp = (url) => {
|
|
74
|
-
if (!url)
|
|
75
|
-
return null;
|
|
79
|
+
if (!url) return null;
|
|
76
80
|
const segments = url.split(".");
|
|
77
81
|
segments[segments.length - 1] = "webp";
|
|
78
82
|
return segments.join(".");
|
|
79
83
|
};
|
|
80
84
|
var getAvif = (url) => {
|
|
81
|
-
if (!url)
|
|
82
|
-
return null;
|
|
85
|
+
if (!url) return null;
|
|
83
86
|
const segments = url.split(".");
|
|
84
87
|
segments[segments.length - 1] = "avif";
|
|
85
88
|
return segments.join(".");
|
|
@@ -176,10 +179,8 @@ var imageSrc = (src, variant) => {
|
|
|
176
179
|
console.warn(`WARNING: Image with empty {}: ${variant}`);
|
|
177
180
|
if (typeof src === "object" && "name" in src && (src.name.includes(".svg") || src.name.includes(".gif")))
|
|
178
181
|
return src.urls.original;
|
|
179
|
-
if (typeof src === "object" && "name" in src)
|
|
180
|
-
|
|
181
|
-
if (typeof src === "string")
|
|
182
|
-
return src;
|
|
182
|
+
if (typeof src === "object" && "name" in src) return src.urls[variant];
|
|
183
|
+
if (typeof src === "string") return src;
|
|
183
184
|
return null;
|
|
184
185
|
};
|
|
185
186
|
var imageSrc_default = imageSrc;
|
|
@@ -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
|
|
|
@@ -256,14 +258,10 @@ var WistiaEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ (0, impor
|
|
|
256
258
|
}
|
|
257
259
|
);
|
|
258
260
|
var videoType = (url) => {
|
|
259
|
-
if (url.includes("youtu"))
|
|
260
|
-
|
|
261
|
-
if (url.includes("
|
|
262
|
-
|
|
263
|
-
if (url.includes("youku"))
|
|
264
|
-
return "youku";
|
|
265
|
-
if (url.includes("wistia"))
|
|
266
|
-
return "wistia";
|
|
261
|
+
if (url.includes("youtu")) return "youtube";
|
|
262
|
+
if (url.includes("vimeo")) return "vimeo";
|
|
263
|
+
if (url.includes("youku")) return "youku";
|
|
264
|
+
if (url.includes("wistia")) return "wistia";
|
|
267
265
|
};
|
|
268
266
|
var youtubeId = (url) => {
|
|
269
267
|
var _a;
|
|
@@ -293,14 +291,10 @@ var wistiaId = (url) => {
|
|
|
293
291
|
return matches !== "" && matches !== null ? matches[2] : "";
|
|
294
292
|
};
|
|
295
293
|
var videoId = (url) => {
|
|
296
|
-
if (videoType(url) === "youtube")
|
|
297
|
-
|
|
298
|
-
if (videoType(url) === "
|
|
299
|
-
|
|
300
|
-
if (videoType(url) === "youku")
|
|
301
|
-
return youkuId(url);
|
|
302
|
-
if (videoType(url) === "wistia")
|
|
303
|
-
return wistiaId(url);
|
|
294
|
+
if (videoType(url) === "youtube") return youtubeId(url);
|
|
295
|
+
if (videoType(url) === "vimeo") return vimeoId(url);
|
|
296
|
+
if (videoType(url) === "youku") return youkuId(url);
|
|
297
|
+
if (videoType(url) === "wistia") return wistiaId(url);
|
|
304
298
|
};
|
|
305
299
|
var VideoComponentType = (vType, noCookieDomains) => {
|
|
306
300
|
const components = {
|
|
@@ -343,13 +337,14 @@ var parser = new import_markdown_it.default({
|
|
|
343
337
|
html: true,
|
|
344
338
|
breaks: true
|
|
345
339
|
}).use(import_markdown_it_attrs.default, {
|
|
340
|
+
// optional, these are default options
|
|
346
341
|
leftDelimiter: "{",
|
|
347
342
|
rightDelimiter: "}",
|
|
348
343
|
allowedAttributes: []
|
|
344
|
+
// empty array = all attributes are allowed
|
|
349
345
|
});
|
|
350
346
|
var toHTML = (string, inline = false) => {
|
|
351
|
-
if (!string)
|
|
352
|
-
return;
|
|
347
|
+
if (!string) return;
|
|
353
348
|
return inline ? parser.renderInline(string) : parser.render(string);
|
|
354
349
|
};
|
|
355
350
|
var toHTML_default = toHTML;
|
|
@@ -585,8 +580,7 @@ var AdminPageRender = ({
|
|
|
585
580
|
saveToLocalStorage(identifier, widgets);
|
|
586
581
|
};
|
|
587
582
|
const handleSelectAll = () => {
|
|
588
|
-
if (areAllSelected)
|
|
589
|
-
return setSelectedWidgets([]);
|
|
583
|
+
if (areAllSelected) return setSelectedWidgets([]);
|
|
590
584
|
setSelectedWidgets(entity.widgets.map((w) => w.widgetId));
|
|
591
585
|
};
|
|
592
586
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react6.default.Fragment, { children: [
|
|
@@ -624,6 +618,45 @@ var AdminPageRender = ({
|
|
|
624
618
|
};
|
|
625
619
|
var AdminPageRender_default = AdminPageRender;
|
|
626
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
|
+
|
|
627
660
|
// src/extractImageValue.js
|
|
628
661
|
function extractImageValue(value) {
|
|
629
662
|
if (!value) {
|
|
@@ -638,6 +671,7 @@ var extractImageValue_default = extractImageValue;
|
|
|
638
671
|
Container,
|
|
639
672
|
EmbeddedVideo,
|
|
640
673
|
Image,
|
|
674
|
+
WidgetRender,
|
|
641
675
|
extractImageValue,
|
|
642
676
|
imagePlaceholder,
|
|
643
677
|
imageSrc,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-builder/support",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,21 +11,21 @@
|
|
|
11
11
|
"lint": "biome lint --max-diagnostics=5000 ."
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"react": "
|
|
15
|
-
"react-dom": "
|
|
14
|
+
"react": "19.0.0",
|
|
15
|
+
"react-dom": "19.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"markdown-it": "
|
|
19
|
-
"markdown-it-attrs": "4.1
|
|
18
|
+
"markdown-it": "14.1.0",
|
|
19
|
+
"markdown-it-attrs": "4.3.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@biomejs/biome": "1.
|
|
23
|
-
"@types/react": "
|
|
24
|
-
"@types/react-dom": "
|
|
25
|
-
"prettier": "3.
|
|
26
|
-
"react": "
|
|
22
|
+
"@biomejs/biome": "1.9.4",
|
|
23
|
+
"@types/react": "19.0.12",
|
|
24
|
+
"@types/react-dom": "19.0.4",
|
|
25
|
+
"prettier": "3.5.3",
|
|
26
|
+
"react": "19.0.0",
|
|
27
27
|
"tsconfig": "*",
|
|
28
|
-
"tsup": "
|
|
29
|
-
"typescript": "
|
|
28
|
+
"tsup": "8.4.0",
|
|
29
|
+
"typescript": "5.8.2"
|
|
30
30
|
}
|
|
31
31
|
}
|
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
|
};
|