@raketa-builder/support 1.3.3 → 1.3.5

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.
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var IconButton = require('./IconButton');
6
+ var Container = require('../Container');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefault(React);
11
+ var IconButton__default = /*#__PURE__*/_interopDefault(IconButton);
12
+ var Container__default = /*#__PURE__*/_interopDefault(Container);
13
+
14
+ var __defProp = Object.defineProperty;
15
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
18
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
19
+ var __spreadValues = (a, b) => {
20
+ for (var prop in b || (b = {}))
21
+ if (__hasOwnProp.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ if (__getOwnPropSymbols)
24
+ for (var prop of __getOwnPropSymbols(b)) {
25
+ if (__propIsEnum.call(b, prop))
26
+ __defNormalProp(a, prop, b[prop]);
27
+ }
28
+ return a;
29
+ };
30
+ var __objRest = (source, exclude) => {
31
+ var target = {};
32
+ for (var prop in source)
33
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
34
+ target[prop] = source[prop];
35
+ if (source != null && __getOwnPropSymbols)
36
+ for (var prop of __getOwnPropSymbols(source)) {
37
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
38
+ target[prop] = source[prop];
39
+ }
40
+ return target;
41
+ };
42
+ function cn() {
43
+ return Array.from(arguments).filter(Boolean).map(String).join(" ");
44
+ }
45
+ const AdminWidgetWrapper = (_a) => {
46
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
47
+ return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadValues({ className: cn("r-admin-widget-wrapper", className) }, rest));
48
+ };
49
+ const AdminWidgetToolbar = (_c) => {
50
+ var _d = _c, { className } = _d, rest = __objRest(_d, ["className"]);
51
+ return /* @__PURE__ */ jsxRuntime.jsx(
52
+ "div",
53
+ __spreadValues({
54
+ className: cn("r-reset", "r-admin-widget-toolbar", className)
55
+ }, rest)
56
+ );
57
+ };
58
+ const AdminWidgetLabel = (_e) => {
59
+ var _f = _e, { className } = _f, rest = __objRest(_f, ["className"]);
60
+ return /* @__PURE__ */ jsxRuntime.jsx(
61
+ "div",
62
+ __spreadValues({
63
+ className: cn("r-reset", "r-fs-small", "r-admin-widget-label", className)
64
+ }, rest)
65
+ );
66
+ };
67
+ const title = (widget) => {
68
+ return widget.Config.title;
69
+ };
70
+ const deprecated = (widget) => {
71
+ return widget.Config.deprecated;
72
+ };
73
+ const AdminWidgetMinimal = ({
74
+ library,
75
+ adminLibrary,
76
+ widget,
77
+ onCopy,
78
+ onSelectWidget,
79
+ selectedWidgets
80
+ }) => {
81
+ var _a;
82
+ const currentWidget = library[widget.component];
83
+ const currentAdminWidget = adminLibrary[widget.component];
84
+ const containerSettings = ((_a = widget == null ? void 0 : widget.settings) == null ? void 0 : _a.containerSettings) || {};
85
+ const isSelected = selectedWidgets.filter((w) => w === widget.widgetId).length > 0;
86
+ if (!currentWidget || !currentAdminWidget) {
87
+ console.error(`Unknown widget: ${widget.component}`);
88
+ return /* @__PURE__ */ jsxRuntime.jsx(AdminWidgetWrapper, { "data-widget": widget.component, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("r-reset", "r-fs-large", "r-admin-missing-widget"), children: `Unknown widget: ${widget.component}` }) });
89
+ }
90
+ const handleCopyWidget = () => {
91
+ const widgetsToCopy = [widget];
92
+ onCopy(widgetsToCopy);
93
+ };
94
+ const handleSelectWidget = () => onSelectWidget(widget.widgetId);
95
+ return /* @__PURE__ */ jsxRuntime.jsxs(AdminWidgetWrapper, { "data-widget": widget.component, children: [
96
+ isSelected && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "r-selected-widget" }),
97
+ /* @__PURE__ */ jsxRuntime.jsxs(AdminWidgetToolbar, { "data-toolbar": true, children: [
98
+ /* @__PURE__ */ jsxRuntime.jsx(
99
+ "input",
100
+ {
101
+ type: "checkbox",
102
+ style: {
103
+ width: "32px",
104
+ height: "32px"
105
+ },
106
+ onChange: handleSelectWidget,
107
+ checked: isSelected
108
+ }
109
+ ),
110
+ !isSelected && !deprecated(currentAdminWidget) && /* @__PURE__ */ jsxRuntime.jsx(IconButton__default.default, { onClick: handleCopyWidget })
111
+ ] }),
112
+ /* @__PURE__ */ jsxRuntime.jsx(AdminWidgetLabel, { "data-widget-label": true, children: title(currentAdminWidget) }),
113
+ /* @__PURE__ */ jsxRuntime.jsx(Container__default.default, { settings: containerSettings, children: React__default.default.createElement(currentWidget, widget.settings) })
114
+ ] });
115
+ };
116
+ var AdminWidgetMinimal_default = AdminWidgetMinimal;
117
+
118
+ module.exports = AdminWidgetMinimal_default;
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ require('react');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ const ICON_COPY = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY29weSI+PHJlY3QgeD0iOSIgeT0iOSIgd2lkdGg9IjEzIiBoZWlnaHQ9IjEzIiByeD0iMiIgcnk9IjIiPjwvcmVjdD48cGF0aCBkPSJNNSAxNUg0YTIgMiAwIDAgMS0yLTJWNGEyIDIgMCAwIDEgMi0yaDlhMiAyIDAgMCAxIDIgMnYxIj48L3BhdGg+PC9zdmc+";
23
+ const IconButton = (props) => /* @__PURE__ */ jsxRuntime.jsx(
24
+ "button",
25
+ __spreadValues({
26
+ type: "button",
27
+ style: {
28
+ display: "inline-block",
29
+ width: "32px",
30
+ height: "32px",
31
+ marginRight: "4px",
32
+ marginLeft: "0px",
33
+ appearance: "none",
34
+ outline: "0",
35
+ border: "0",
36
+ borderRadius: "3px",
37
+ background: "transparent",
38
+ backgroundColor: "#fff",
39
+ backgroundRepeat: "no-repeat",
40
+ backgroundPosition: "center",
41
+ backgroundSize: "50%",
42
+ backgroundImage: `url(${ICON_COPY})`,
43
+ cursor: "pointer"
44
+ }
45
+ }, props)
46
+ );
47
+ var IconButton_default = IconButton;
48
+
49
+ module.exports = IconButton_default;
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var AdminWidgetMinimal = require('./AdminWidgetMinimal');
6
+ var SelectedWidgetsToolbar = require('../lib/SelectedWidgetsToolbar');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefault(React);
11
+ var AdminWidgetMinimal__default = /*#__PURE__*/_interopDefault(AdminWidgetMinimal);
12
+ var SelectedWidgetsToolbar__default = /*#__PURE__*/_interopDefault(SelectedWidgetsToolbar);
13
+
14
+ var __defProp = Object.defineProperty;
15
+ var __defProps = Object.defineProperties;
16
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
17
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
18
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
19
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
20
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
21
+ var __spreadValues = (a, b) => {
22
+ for (var prop in b || (b = {}))
23
+ if (__hasOwnProp.call(b, prop))
24
+ __defNormalProp(a, prop, b[prop]);
25
+ if (__getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(b)) {
27
+ if (__propIsEnum.call(b, prop))
28
+ __defNormalProp(a, prop, b[prop]);
29
+ }
30
+ return a;
31
+ };
32
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
33
+ const saveToLocalStorage = (identifier, widgets) => window.localStorage.setItem(
34
+ `clipboard\u2013${identifier}`,
35
+ JSON.stringify(widgets)
36
+ );
37
+ const AdminPageRender = ({
38
+ page,
39
+ context = {},
40
+ preloaded = {},
41
+ library,
42
+ adminLibrary,
43
+ identifier,
44
+ detailPath,
45
+ canvasClassName = "",
46
+ layoutMessage = ""
47
+ }) => {
48
+ const [selectedWidgets, setSelectedWidgets] = React__default.default.useState([]);
49
+ const entity = __spreadProps(__spreadValues({}, page), {
50
+ widgets: page.widgets.map((w) => __spreadProps(__spreadValues({}, w), {
51
+ settings: __spreadProps(__spreadValues({}, w.settings), {
52
+ __ctx: context,
53
+ __data: preloaded[w.widgetId]
54
+ })
55
+ }))
56
+ });
57
+ const areAllSelected = selectedWidgets.length === entity.widgets.length;
58
+ const handleSelectWidget = (newWidget) => {
59
+ setSelectedWidgets((oldList) => {
60
+ const isUnique = oldList.filter((w) => w === newWidget).length <= 0;
61
+ if (isUnique) {
62
+ return [...oldList, newWidget];
63
+ } else {
64
+ return oldList.filter((w) => w !== newWidget);
65
+ }
66
+ });
67
+ };
68
+ const handleCopyWidgets = (widgets, copyType) => {
69
+ if (copyType === "multiple") {
70
+ const filterSelected = entity.widgets.filter(
71
+ (w) => widgets.some((c) => w.widgetId === c)
72
+ );
73
+ saveToLocalStorage(identifier, filterSelected);
74
+ setSelectedWidgets([]);
75
+ return;
76
+ }
77
+ saveToLocalStorage(identifier, widgets);
78
+ };
79
+ const handleSelectAll = () => {
80
+ if (areAllSelected) return setSelectedWidgets([]);
81
+ setSelectedWidgets(entity.widgets.map((w) => w.widgetId));
82
+ };
83
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__default.default.Fragment, { children: [
84
+ layoutMessage && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "r-reset r-fs-base r-layout-message", children: layoutMessage }),
85
+ selectedWidgets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
86
+ SelectedWidgetsToolbar__default.default,
87
+ {
88
+ length: selectedWidgets.length,
89
+ onCopy: () => handleCopyWidgets(selectedWidgets, "multiple")
90
+ }
91
+ ),
92
+ entity.widgets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
93
+ "button",
94
+ {
95
+ className: `r-button-reset r-button-select-all ${areAllSelected ? "r-all-selected" : ""}`,
96
+ type: "button",
97
+ title: "Select all (or Deselect all)",
98
+ onClick: () => handleSelectAll()
99
+ }
100
+ ),
101
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: detailPath, className: "r-reset r-details-link", title: "Details" }),
102
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: canvasClassName, children: entity.widgets.map(({ widgetId, component, settings }) => /* @__PURE__ */ jsxRuntime.jsx(
103
+ AdminWidgetMinimal__default.default,
104
+ {
105
+ library,
106
+ adminLibrary,
107
+ widget: { widgetId, component, settings },
108
+ onCopy: handleCopyWidgets,
109
+ onSelectWidget: handleSelectWidget,
110
+ selectedWidgets
111
+ },
112
+ widgetId
113
+ )) })
114
+ ] });
115
+ };
116
+ var AdminPageRender_default = AdminPageRender;
117
+
118
+ module.exports = AdminPageRender_default;
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ require('react');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __defProps = Object.defineProperties;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ const Container = (_a) => {
38
+ var _b = _a, { settings, className, children } = _b, rest = __objRest(_b, ["settings", "className", "children"]);
39
+ const _a2 = settings || {}, { containerID } = _a2, restSettings = __objRest(_a2, ["containerID"]);
40
+ const cssClasses = [...Object.values(restSettings), className].join(" ");
41
+ return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({ id: containerID, className: cssClasses }, rest), { children }));
42
+ };
43
+ var Container_default = Container;
44
+
45
+ module.exports = Container_default;
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ require('react');
5
+
6
+ const VimeoEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ jsxRuntime.jsx(
7
+ "iframe",
8
+ {
9
+ frameBorder: "0",
10
+ allowFullScreen: "0",
11
+ src: `https://player.vimeo.com/video/${videoId2}?color=ffffff&title=0&byline=0&portrait=0&autoplay=${autoplay === true ? "1" : "0"}`,
12
+ className: "content",
13
+ allow: "autoplay"
14
+ }
15
+ );
16
+ const YoukuEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ jsxRuntime.jsx(
17
+ "iframe",
18
+ {
19
+ height: "0",
20
+ width: "0",
21
+ src: `https://player.youku.com/embed/${videoId2}?autoplay=${autoplay === true ? "1" : "0"}`,
22
+ frameBorder: "0",
23
+ allowFullScreen: true,
24
+ className: "content",
25
+ allow: "autoplay"
26
+ }
27
+ );
28
+ const YouTubeEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ jsxRuntime.jsx(
29
+ "iframe",
30
+ {
31
+ frameBorder: "0",
32
+ allowFullScreen: true,
33
+ src: `https://youtube.com/embed/${videoId2}?autoplay=${autoplay === true ? "1" : "0"}`,
34
+ className: "content",
35
+ allow: "autoplay"
36
+ }
37
+ );
38
+ const YouTubeNoCookieEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ jsxRuntime.jsx(
39
+ "iframe",
40
+ {
41
+ frameBorder: "0",
42
+ allowFullScreen: true,
43
+ src: `https://www.youtube-nocookie.com/embed/${videoId2}?autoplay=${autoplay === true ? "1" : "0"}`,
44
+ className: "content",
45
+ allow: "autoplay"
46
+ }
47
+ );
48
+ const WistiaEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ jsxRuntime.jsx(
49
+ "iframe",
50
+ {
51
+ frameBorder: "0",
52
+ allowFullScreen: true,
53
+ src: `https://fast.wistia.net/embed/iframe/${videoId2}${autoplay ? "?autoPlay=true" : ""}`,
54
+ className: "content",
55
+ allow: "autoplay"
56
+ }
57
+ );
58
+ const videoType = (url) => {
59
+ if (url.includes("youtu")) return "youtube";
60
+ if (url.includes("vimeo")) return "vimeo";
61
+ if (url.includes("youku")) return "youku";
62
+ if (url.includes("wistia")) return "wistia";
63
+ };
64
+ const youtubeId = (url) => {
65
+ var _a;
66
+ let matches = url.match(
67
+ /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
68
+ );
69
+ if (matches && matches[5]) {
70
+ return matches[5];
71
+ }
72
+ matches = url.match(new RegExp("youtu\\.be\\/|youtube\\.com\\/shorts\\/(?<id>.*)(\\?.*)?"));
73
+ return ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.id) || "";
74
+ };
75
+ const vimeoId = (url) => {
76
+ const matches = url.match(/http(s?):\/\/(www\.)?vimeo\.com\/(\d+)($|\/)/);
77
+ return matches !== "" && matches !== null ? matches[3] : "";
78
+ };
79
+ const youkuId = (url) => {
80
+ const matches = url.match(
81
+ /http(s?):\/\/v\.youku\.com\/v_show\/id_([A-Za-z0-9=]+)\.html/
82
+ );
83
+ return matches !== "" && matches !== null ? matches[2] : "";
84
+ };
85
+ const wistiaId = (url) => {
86
+ const matches = url.match(
87
+ /http(s?):\/\/fast\.wistia\.net\/embed\/iframe\/(.*)($|\?)/
88
+ );
89
+ return matches !== "" && matches !== null ? matches[2] : "";
90
+ };
91
+ const videoId = (url) => {
92
+ if (videoType(url) === "youtube") return youtubeId(url);
93
+ if (videoType(url) === "vimeo") return vimeoId(url);
94
+ if (videoType(url) === "youku") return youkuId(url);
95
+ if (videoType(url) === "wistia") return wistiaId(url);
96
+ };
97
+ const VideoComponentType = (vType, noCookieDomains) => {
98
+ const components = {
99
+ youtube: YouTubeEmbed,
100
+ vimeo: VimeoEmbed,
101
+ youku: YoukuEmbed,
102
+ wistia: WistiaEmbed
103
+ };
104
+ const noCookiesComponents = {
105
+ youtube: YouTubeNoCookieEmbed,
106
+ vimeo: VimeoEmbed,
107
+ youku: YoukuEmbed,
108
+ wistia: WistiaEmbed
109
+ };
110
+ if (noCookieDomains) {
111
+ return noCookiesComponents[vType];
112
+ } else {
113
+ return components[vType];
114
+ }
115
+ };
116
+ const EmbeddedVideo = ({
117
+ videoUrl,
118
+ autoplay = false,
119
+ noCookieDomains = false
120
+ }) => {
121
+ const vType = videoType(videoUrl);
122
+ const vId = videoId(videoUrl);
123
+ const VideoComponent = VideoComponentType(vType, noCookieDomains);
124
+ if (VideoComponent) {
125
+ return /* @__PURE__ */ jsxRuntime.jsx(VideoComponent, { videoId: vId, autoplay });
126
+ }
127
+ return null;
128
+ };
129
+ var EmbeddedVideo_default = EmbeddedVideo;
130
+
131
+ module.exports = EmbeddedVideo_default;
package/dist/Image.js ADDED
@@ -0,0 +1,132 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ require('react');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __objRest = (source, exclude) => {
23
+ var target = {};
24
+ for (var prop in source)
25
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
+ target[prop] = source[prop];
27
+ if (source != null && __getOwnPropSymbols)
28
+ for (var prop of __getOwnPropSymbols(source)) {
29
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
+ target[prop] = source[prop];
31
+ }
32
+ return target;
33
+ };
34
+ const getWebp = (url) => {
35
+ if (!url) return null;
36
+ const segments = url.split(".");
37
+ segments[segments.length - 1] = "webp";
38
+ return segments.join(".");
39
+ };
40
+ const getAvif = (url) => {
41
+ if (!url) return null;
42
+ const segments = url.split(".");
43
+ segments[segments.length - 1] = "avif";
44
+ return segments.join(".");
45
+ };
46
+ const getDimensions = (src, variant) => {
47
+ var _a, _b, _c;
48
+ if (typeof src === "object" && ((_a = src == null ? void 0 : src.name) == null ? void 0 : _a.includes(".svg"))) {
49
+ const width = src.width || null;
50
+ const height = src.height || null;
51
+ return [width, height];
52
+ }
53
+ if (typeof src === "object") {
54
+ const width = ((_b = src.sizes[variant]) == null ? void 0 : _b.width) || null;
55
+ const height = ((_c = src.sizes[variant]) == null ? void 0 : _c.height) || null;
56
+ return [width, height];
57
+ }
58
+ return [null, null];
59
+ };
60
+ const getAlt = (src) => {
61
+ const type = typeof src;
62
+ if (type === "object" && src.alt) {
63
+ return src.alt;
64
+ }
65
+ if (type === "object") {
66
+ const imageObj = src.image || src;
67
+ const altSetting = ((imageObj == null ? void 0 : imageObj.settings) || []).find(
68
+ (setting) => setting.key === "alt"
69
+ );
70
+ if (altSetting) {
71
+ return altSetting.value;
72
+ }
73
+ }
74
+ return "";
75
+ };
76
+ const getSrc = (src, variant) => {
77
+ var _a, _b, _c;
78
+ if (typeof src === "object") {
79
+ if (((_a = src == null ? void 0 : src.name) == null ? void 0 : _a.includes(".svg")) || ((_b = src == null ? void 0 : src.name) == null ? void 0 : _b.includes(".gif"))) {
80
+ return [null, null, (_c = src.urls) == null ? void 0 : _c.original];
81
+ }
82
+ const fallback = src.urls[variant];
83
+ const webp = getWebp(fallback);
84
+ const avif = getAvif(fallback);
85
+ return [webp, avif, fallback];
86
+ }
87
+ return [null, null, src];
88
+ };
89
+ const getImageObjOrSrc = (value) => {
90
+ const type = typeof value;
91
+ if (type === "object" && value.hasOwnProperty("image")) {
92
+ return value.image;
93
+ }
94
+ return value;
95
+ };
96
+ const Image = (_a) => {
97
+ var _b = _a, { variant, src, alt, loading = "lazy" } = _b, props = __objRest(_b, ["variant", "src", "alt", "loading"]);
98
+ if (!variant) {
99
+ console.error("Image with no variant", { variant, src, alt, props });
100
+ return null;
101
+ }
102
+ if (!src) {
103
+ console.error("Image with no src", { variant, src, alt, props });
104
+ return null;
105
+ }
106
+ const imageObjOrSrc = getImageObjOrSrc(src);
107
+ if (imageObjOrSrc && typeof imageObjOrSrc === "object" && !imageObjOrSrc.sizes) {
108
+ console.error("Image with no sizes", { variant, src, alt, props });
109
+ return null;
110
+ }
111
+ const [width, height] = getDimensions(imageObjOrSrc, variant);
112
+ const altAttr = alt || getAlt(src);
113
+ const [webp, avif, fallback] = getSrc(imageObjOrSrc, variant);
114
+ return /* @__PURE__ */ jsxRuntime.jsxs("picture", { children: [
115
+ avif && /* @__PURE__ */ jsxRuntime.jsx("source", { srcSet: encodeURI(avif), type: "image/avif" }),
116
+ webp && /* @__PURE__ */ jsxRuntime.jsx("source", { srcSet: encodeURI(webp), type: "image/webp" }),
117
+ /* @__PURE__ */ jsxRuntime.jsx("source", { srcSet: encodeURI(fallback), type: src.mime_type }),
118
+ /* @__PURE__ */ jsxRuntime.jsx(
119
+ "img",
120
+ __spreadValues({
121
+ src: fallback,
122
+ alt: altAttr,
123
+ width,
124
+ height,
125
+ loading
126
+ }, props)
127
+ )
128
+ ] });
129
+ };
130
+ var Image_default = Image;
131
+
132
+ module.exports = Image_default;
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var Container = require('../Container');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefault(React);
10
+ var Container__default = /*#__PURE__*/_interopDefault(Container);
11
+
12
+ var __defProp = Object.defineProperty;
13
+ var __defProps = Object.defineProperties;
14
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
15
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
18
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
19
+ var __spreadValues = (a, b) => {
20
+ for (var prop in b || (b = {}))
21
+ if (__hasOwnProp.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ if (__getOwnPropSymbols)
24
+ for (var prop of __getOwnPropSymbols(b)) {
25
+ if (__propIsEnum.call(b, prop))
26
+ __defNormalProp(a, prop, b[prop]);
27
+ }
28
+ return a;
29
+ };
30
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
31
+ const WidgetRender = ({
32
+ library,
33
+ entity,
34
+ page,
35
+ context = {},
36
+ preloaded = {},
37
+ locale = "es"
38
+ }) => {
39
+ var _a;
40
+ const pageData = page || entity;
41
+ context = __spreadProps(__spreadValues({}, context), {
42
+ locale: (_a = context.locale) != null ? _a : locale
43
+ });
44
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: pageData.widgets.map(({ widgetId, component, settings }) => {
45
+ if (!library[component]) {
46
+ console.error(
47
+ `Unknown widget: {widgetId: ${widgetId}, component: ${component}, settings: ${settings}}`
48
+ );
49
+ return null;
50
+ }
51
+ return /* @__PURE__ */ jsxRuntime.jsx(
52
+ Container__default.default,
53
+ {
54
+ settings: (settings == null ? void 0 : settings.containerSettings) || {},
55
+ "data-widget": component,
56
+ children: React__default.default.createElement(library[component], __spreadProps(__spreadValues({}, settings), {
57
+ __ctx: context,
58
+ __data: (preloaded == null ? void 0 : preloaded[widgetId]) || {}
59
+ }))
60
+ },
61
+ widgetId
62
+ );
63
+ }) });
64
+ };
65
+ var WidgetRender_default = WidgetRender;
66
+
67
+ module.exports = WidgetRender_default;
@@ -1,9 +1,11 @@
1
+ 'use strict';
2
+
1
3
  function extractImageValue(value) {
2
4
  if (!value) {
3
5
  return null;
4
6
  }
5
-
6
7
  return value.hasOwnProperty("image") ? value.image : value;
7
8
  }
9
+ var extractImageValue_default = extractImageValue;
8
10
 
9
- export default extractImageValue;
11
+ module.exports = extractImageValue_default;
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const imagePlaceholder = (size) => {
4
+ return `https://placeholder.raketa.cloud/images/${size}`;
5
+ };
6
+ var imagePlaceholder_default = imagePlaceholder;
7
+
8
+ module.exports = imagePlaceholder_default;