@raketa-builder/support 1.3.0 → 1.3.2

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 DELETED
@@ -1,680 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
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
- var __export = (target, all) => {
38
- for (var name in all)
39
- __defProp(target, name, { get: all[name], enumerable: true });
40
- };
41
- var __copyProps = (to, from, except, desc) => {
42
- if (from && typeof from === "object" || typeof from === "function") {
43
- for (let key of __getOwnPropNames(from))
44
- if (!__hasOwnProp.call(to, key) && key !== except)
45
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
- }
47
- return to;
48
- };
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.
54
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
- mod
56
- ));
57
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
-
59
- // src/index.js
60
- var index_exports = {};
61
- __export(index_exports, {
62
- AdminPageRender: () => AdminPageRender_default,
63
- Container: () => Container_default,
64
- EmbeddedVideo: () => EmbeddedVideo_default,
65
- Image: () => Image_default,
66
- WidgetRender: () => WidgetRender_default,
67
- extractImageValue: () => extractImageValue_default,
68
- imagePlaceholder: () => imagePlaceholder_default,
69
- imageSrc: () => imageSrc_default,
70
- isImagePresent: () => isImagePresent_default,
71
- toHTML: () => toHTML_default
72
- });
73
- module.exports = __toCommonJS(index_exports);
74
-
75
- // src/Image.js
76
- var import_react = __toESM(require("react"));
77
- var import_jsx_runtime = require("react/jsx-runtime");
78
- var getWebp = (url) => {
79
- if (!url) return null;
80
- const segments = url.split(".");
81
- segments[segments.length - 1] = "webp";
82
- return segments.join(".");
83
- };
84
- var getAvif = (url) => {
85
- if (!url) return null;
86
- const segments = url.split(".");
87
- segments[segments.length - 1] = "avif";
88
- return segments.join(".");
89
- };
90
- var getDimensions = (src, variant) => {
91
- var _a, _b, _c;
92
- if (typeof src === "object" && ((_a = src == null ? void 0 : src.name) == null ? void 0 : _a.includes(".svg"))) {
93
- const width = src.width || null;
94
- const height = src.height || null;
95
- return [width, height];
96
- }
97
- if (typeof src === "object") {
98
- const width = ((_b = src.sizes[variant]) == null ? void 0 : _b.width) || null;
99
- const height = ((_c = src.sizes[variant]) == null ? void 0 : _c.height) || null;
100
- return [width, height];
101
- }
102
- return [null, null];
103
- };
104
- var getAlt = (src) => {
105
- const type = typeof src;
106
- if (type === "object" && src.alt) {
107
- return src.alt;
108
- }
109
- if (type === "object") {
110
- const imageObj = src.image || src;
111
- const altSetting = ((imageObj == null ? void 0 : imageObj.settings) || []).find(
112
- (setting) => setting.key === "alt"
113
- );
114
- if (altSetting) {
115
- return altSetting.value;
116
- }
117
- }
118
- return "";
119
- };
120
- var getSrc = (src, variant) => {
121
- var _a, _b, _c;
122
- if (typeof src === "object") {
123
- 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"))) {
124
- return [null, null, (_c = src.urls) == null ? void 0 : _c.original];
125
- }
126
- const fallback = src.urls[variant];
127
- const webp = getWebp(fallback);
128
- const avif = getAvif(fallback);
129
- return [webp, avif, fallback];
130
- }
131
- return [null, null, src];
132
- };
133
- var getImageObjOrSrc = (value) => {
134
- const type = typeof value;
135
- if (type === "object" && value.hasOwnProperty("image")) {
136
- return value.image;
137
- }
138
- return value;
139
- };
140
- var Image = (_a) => {
141
- var _b = _a, { variant, src, alt, loading = "lazy" } = _b, props = __objRest(_b, ["variant", "src", "alt", "loading"]);
142
- if (!variant) {
143
- console.error("Image with no variant", { variant, src, alt, props });
144
- return null;
145
- }
146
- if (!src) {
147
- console.error("Image with no src", { variant, src, alt, props });
148
- return null;
149
- }
150
- const imageObjOrSrc = getImageObjOrSrc(src);
151
- if (imageObjOrSrc && typeof imageObjOrSrc === "object" && !imageObjOrSrc.sizes) {
152
- console.error("Image with no sizes", { variant, src, alt, props });
153
- return null;
154
- }
155
- const [width, height] = getDimensions(imageObjOrSrc, variant);
156
- const altAttr = alt || getAlt(src);
157
- const [webp, avif, fallback] = getSrc(imageObjOrSrc, variant);
158
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("picture", { children: [
159
- avif && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("source", { srcSet: encodeURI(avif), type: "image/avif" }),
160
- webp && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("source", { srcSet: encodeURI(webp), type: "image/webp" }),
161
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("source", { srcSet: encodeURI(fallback), type: src.mime_type }),
162
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
- "img",
164
- __spreadValues({
165
- src: fallback,
166
- alt: altAttr,
167
- width,
168
- height,
169
- loading
170
- }, props)
171
- )
172
- ] });
173
- };
174
- var Image_default = Image;
175
-
176
- // src/imageSrc.js
177
- var imageSrc = (src, variant) => {
178
- if (typeof src === "object" && !("name" in src))
179
- console.warn(`WARNING: Image with empty {}: ${variant}`);
180
- if (typeof src === "object" && "name" in src && (src.name.includes(".svg") || src.name.includes(".gif")))
181
- return src.urls.original;
182
- if (typeof src === "object" && "name" in src) return src.urls[variant];
183
- if (typeof src === "string") return src;
184
- return null;
185
- };
186
- var imageSrc_default = imageSrc;
187
-
188
- // src/imagePlaceholder.js
189
- var imagePlaceholder = (size) => {
190
- return `https://placeholder.raketa.cloud/images/${size}`;
191
- };
192
- var imagePlaceholder_default = imagePlaceholder;
193
-
194
- // src/Container.js
195
- var import_react2 = __toESM(require("react"));
196
- var import_jsx_runtime2 = require("react/jsx-runtime");
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"]);
200
- const cssClasses = [...Object.values(restSettings), className].join(" ");
201
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", __spreadProps(__spreadValues({ id: containerID, className: cssClasses }, rest), { children }));
202
- };
203
- var Container_default = Container;
204
-
205
- // src/EmbeddedVideo.js
206
- var import_react3 = __toESM(require("react"));
207
- var import_jsx_runtime3 = require("react/jsx-runtime");
208
- var VimeoEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
209
- "iframe",
210
- {
211
- frameBorder: "0",
212
- allowFullScreen: "0",
213
- src: `https://player.vimeo.com/video/${videoId2}?color=ffffff&title=0&byline=0&portrait=0&autoplay=${autoplay === true ? "1" : "0"}`,
214
- className: "content",
215
- allow: "autoplay"
216
- }
217
- );
218
- var YoukuEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
219
- "iframe",
220
- {
221
- height: "0",
222
- width: "0",
223
- src: `https://player.youku.com/embed/${videoId2}?autoplay=${autoplay === true ? "1" : "0"}`,
224
- frameBorder: "0",
225
- allowFullScreen: true,
226
- className: "content",
227
- allow: "autoplay"
228
- }
229
- );
230
- var YouTubeEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
231
- "iframe",
232
- {
233
- frameBorder: "0",
234
- allowFullScreen: true,
235
- src: `https://youtube.com/embed/${videoId2}?autoplay=${autoplay === true ? "1" : "0"}`,
236
- className: "content",
237
- allow: "autoplay"
238
- }
239
- );
240
- var YouTubeNoCookieEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
241
- "iframe",
242
- {
243
- frameBorder: "0",
244
- allowFullScreen: true,
245
- src: `https://www.youtube-nocookie.com/embed/${videoId2}?autoplay=${autoplay === true ? "1" : "0"}`,
246
- className: "content",
247
- allow: "autoplay"
248
- }
249
- );
250
- var WistiaEmbed = ({ videoId: videoId2, autoplay }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
251
- "iframe",
252
- {
253
- frameBorder: "0",
254
- allowFullScreen: true,
255
- src: `https://fast.wistia.net/embed/iframe/${videoId2}${autoplay ? "?autoPlay=true" : ""}`,
256
- className: "content",
257
- allow: "autoplay"
258
- }
259
- );
260
- var videoType = (url) => {
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";
265
- };
266
- var youtubeId = (url) => {
267
- var _a;
268
- let matches = url.match(
269
- /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
270
- );
271
- if (matches && matches[5]) {
272
- return matches[5];
273
- }
274
- matches = url.match(new RegExp("youtu\\.be\\/|youtube\\.com\\/shorts\\/(?<id>.*)(\\?.*)?"));
275
- return ((_a = matches == null ? void 0 : matches.groups) == null ? void 0 : _a.id) || "";
276
- };
277
- var vimeoId = (url) => {
278
- const matches = url.match(/http(s?):\/\/(www\.)?vimeo\.com\/(\d+)($|\/)/);
279
- return matches !== "" && matches !== null ? matches[3] : "";
280
- };
281
- var youkuId = (url) => {
282
- const matches = url.match(
283
- /http(s?):\/\/v\.youku\.com\/v_show\/id_([A-Za-z0-9=]+)\.html/
284
- );
285
- return matches !== "" && matches !== null ? matches[2] : "";
286
- };
287
- var wistiaId = (url) => {
288
- const matches = url.match(
289
- /http(s?):\/\/fast\.wistia\.net\/embed\/iframe\/(.*)($|\?)/
290
- );
291
- return matches !== "" && matches !== null ? matches[2] : "";
292
- };
293
- var videoId = (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);
298
- };
299
- var VideoComponentType = (vType, noCookieDomains) => {
300
- const components = {
301
- youtube: YouTubeEmbed,
302
- vimeo: VimeoEmbed,
303
- youku: YoukuEmbed,
304
- wistia: WistiaEmbed
305
- };
306
- const noCookiesComponents = {
307
- youtube: YouTubeNoCookieEmbed,
308
- vimeo: VimeoEmbed,
309
- youku: YoukuEmbed,
310
- wistia: WistiaEmbed
311
- };
312
- if (noCookieDomains) {
313
- return noCookiesComponents[vType];
314
- } else {
315
- return components[vType];
316
- }
317
- };
318
- var EmbeddedVideo = ({
319
- videoUrl,
320
- autoplay = false,
321
- noCookieDomains = false
322
- }) => {
323
- const vType = videoType(videoUrl);
324
- const vId = videoId(videoUrl);
325
- const VideoComponent = VideoComponentType(vType, noCookieDomains);
326
- if (VideoComponent) {
327
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(VideoComponent, { videoId: vId, autoplay });
328
- }
329
- return null;
330
- };
331
- var EmbeddedVideo_default = EmbeddedVideo;
332
-
333
- // src/toHTML.js
334
- var import_markdown_it = __toESM(require("markdown-it"));
335
- var import_markdown_it_attrs = __toESM(require("markdown-it-attrs"));
336
- var parser = new import_markdown_it.default({
337
- html: true,
338
- breaks: true
339
- }).use(import_markdown_it_attrs.default, {
340
- // optional, these are default options
341
- leftDelimiter: "{",
342
- rightDelimiter: "}",
343
- allowedAttributes: []
344
- // empty array = all attributes are allowed
345
- });
346
- var toHTML = (string, inline = false) => {
347
- if (!string) return;
348
- return inline ? parser.renderInline(string) : parser.render(string);
349
- };
350
- var toHTML_default = toHTML;
351
-
352
- // src/isImagePresent.js
353
- function isImagePresent(value) {
354
- if (!value) {
355
- return false;
356
- }
357
- if (value.hasOwnProperty("image")) {
358
- return !!value.image;
359
- }
360
- if (typeof value === "string" && value) {
361
- return true;
362
- }
363
- return !!value;
364
- }
365
- var isImagePresent_default = isImagePresent;
366
-
367
- // src/AdminPageRender/index.js
368
- var import_react6 = __toESM(require("react"));
369
-
370
- // src/AdminPageRender/AdminWidgetMinimal.js
371
- var import_react5 = __toESM(require("react"));
372
-
373
- // src/AdminPageRender/IconButton.js
374
- var import_react4 = __toESM(require("react"));
375
- var import_jsx_runtime4 = require("react/jsx-runtime");
376
- var ICON_COPY = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY29weSI+PHJlY3QgeD0iOSIgeT0iOSIgd2lkdGg9IjEzIiBoZWlnaHQ9IjEzIiByeD0iMiIgcnk9IjIiPjwvcmVjdD48cGF0aCBkPSJNNSAxNUg0YTIgMiAwIDAgMS0yLTJWNGEyIDIgMCAwIDEgMi0yaDlhMiAyIDAgMCAxIDIgMnYxIj48L3BhdGg+PC9zdmc+";
377
- var IconButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
378
- "button",
379
- __spreadValues({
380
- type: "button",
381
- style: {
382
- display: "inline-block",
383
- width: "32px",
384
- height: "32px",
385
- marginRight: "4px",
386
- marginLeft: "0px",
387
- appearance: "none",
388
- outline: "0",
389
- border: "0",
390
- borderRadius: "3px",
391
- background: "transparent",
392
- backgroundColor: "#fff",
393
- backgroundRepeat: "no-repeat",
394
- backgroundPosition: "center",
395
- backgroundSize: "50%",
396
- backgroundImage: `url(${ICON_COPY})`,
397
- cursor: "pointer"
398
- }
399
- }, props)
400
- );
401
- var IconButton_default = IconButton;
402
-
403
- // src/AdminPageRender/AdminWidgetMinimal.js
404
- var import_jsx_runtime5 = require("react/jsx-runtime");
405
- function cn() {
406
- return Array.from(arguments).filter(Boolean).map(String).join(" ");
407
- }
408
- var AdminWidgetWrapper = (_a) => {
409
- var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
410
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", __spreadValues({ className: cn("r-admin-widget-wrapper", className) }, rest));
411
- };
412
- var AdminWidgetToolbar = (_a) => {
413
- var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
414
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
415
- "div",
416
- __spreadValues({
417
- className: cn("r-reset", "r-admin-widget-toolbar", className)
418
- }, rest)
419
- );
420
- };
421
- var AdminWidgetLabel = (_a) => {
422
- var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
423
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
424
- "div",
425
- __spreadValues({
426
- className: cn("r-reset", "r-fs-small", "r-admin-widget-label", className)
427
- }, rest)
428
- );
429
- };
430
- var title = (widget) => {
431
- return widget.Config.title;
432
- };
433
- var deprecated = (widget) => {
434
- return widget.Config.deprecated;
435
- };
436
- var AdminWidgetMinimal = ({
437
- library,
438
- adminLibrary,
439
- widget,
440
- onCopy,
441
- onSelectWidget,
442
- selectedWidgets
443
- }) => {
444
- var _a;
445
- const currentWidget = library[widget.component];
446
- const currentAdminWidget = adminLibrary[widget.component];
447
- const containerSettings = ((_a = widget == null ? void 0 : widget.settings) == null ? void 0 : _a.containerSettings) || {};
448
- const isSelected = selectedWidgets.filter((w) => w === widget.widgetId).length > 0;
449
- if (!currentWidget || !currentAdminWidget) {
450
- console.error(`Unknown widget: ${widget.component}`);
451
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AdminWidgetWrapper, { "data-widget": widget.component, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: cn("r-reset", "r-fs-large", "r-admin-missing-widget"), children: `Unknown widget: ${widget.component}` }) });
452
- }
453
- const handleCopyWidget = () => {
454
- const widgetsToCopy = [widget];
455
- onCopy(widgetsToCopy);
456
- };
457
- const handleSelectWidget = () => onSelectWidget(widget.widgetId);
458
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(AdminWidgetWrapper, { "data-widget": widget.component, children: [
459
- isSelected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "r-selected-widget" }),
460
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(AdminWidgetToolbar, { "data-toolbar": true, children: [
461
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
462
- "input",
463
- {
464
- type: "checkbox",
465
- style: {
466
- width: "32px",
467
- height: "32px"
468
- },
469
- onChange: handleSelectWidget,
470
- checked: isSelected
471
- }
472
- ),
473
- !isSelected && !deprecated(currentAdminWidget) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IconButton_default, { onClick: handleCopyWidget })
474
- ] }),
475
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AdminWidgetLabel, { "data-widget-label": true, children: title(currentAdminWidget) }),
476
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Container_default, { settings: containerSettings, children: import_react5.default.createElement(currentWidget, widget.settings) })
477
- ] });
478
- };
479
- var AdminWidgetMinimal_default = AdminWidgetMinimal;
480
-
481
- // src/lib/SelectedWidgetsToolbar.js
482
- var import_jsx_runtime6 = require("react/jsx-runtime");
483
- var IconCopy = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
484
- "svg",
485
- {
486
- xmlns: "http://www.w3.org/2000/svg",
487
- width: "16",
488
- height: "16",
489
- viewBox: "0 0 16 16",
490
- fill: "none",
491
- children: [
492
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("g", { clipPath: "url(#clip0_2312_498)", children: [
493
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
494
- "path",
495
- {
496
- d: "M13.3334 5.33331H6.66671C5.93033 5.33331 5.33337 5.93027 5.33337 6.66665V13.3333C5.33337 14.0697 5.93033 14.6666 6.66671 14.6666H13.3334C14.0698 14.6666 14.6667 14.0697 14.6667 13.3333V6.66665C14.6667 5.93027 14.0698 5.33331 13.3334 5.33331Z",
497
- stroke: "white",
498
- strokeWidth: "2",
499
- strokeLinecap: "round",
500
- strokeLinejoin: "round"
501
- }
502
- ),
503
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
504
- "path",
505
- {
506
- d: "M2.66671 10.6666C1.93337 10.6666 1.33337 10.0666 1.33337 9.33331V2.66665C1.33337 1.93331 1.93337 1.33331 2.66671 1.33331H9.33337C10.0667 1.33331 10.6667 1.93331 10.6667 2.66665",
507
- stroke: "white",
508
- strokeWidth: "2",
509
- strokeLinecap: "round",
510
- strokeLinejoin: "round"
511
- }
512
- )
513
- ] }),
514
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("clipPath", { id: "clip0_2312_498", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("rect", { width: "16", height: "16", fill: "white" }) }) })
515
- ]
516
- }
517
- );
518
- var SelectedWidgetsToolbar = ({ length, onCopy }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "r-selected-widgets-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "r-toolbar-inner", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
519
- "button",
520
- {
521
- type: "button",
522
- className: "r-button-reset r-toolbar-button",
523
- onClick: onCopy,
524
- children: [
525
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IconCopy, {}),
526
- "Copy selected (",
527
- length,
528
- ")"
529
- ]
530
- }
531
- ) }) });
532
- var SelectedWidgetsToolbar_default = SelectedWidgetsToolbar;
533
-
534
- // src/AdminPageRender/index.js
535
- var import_jsx_runtime7 = require("react/jsx-runtime");
536
- var saveToLocalStorage = (identifier, widgets) => window.localStorage.setItem(
537
- `clipboard\u2013${identifier}`,
538
- JSON.stringify(widgets)
539
- );
540
- var AdminPageRender = ({
541
- page,
542
- context = {},
543
- preloaded = {},
544
- library,
545
- adminLibrary,
546
- identifier,
547
- detailPath,
548
- canvasClassName = "",
549
- layoutMessage = ""
550
- }) => {
551
- const [selectedWidgets, setSelectedWidgets] = import_react6.default.useState([]);
552
- const entity = __spreadProps(__spreadValues({}, page), {
553
- widgets: page.widgets.map((w) => __spreadProps(__spreadValues({}, w), {
554
- settings: __spreadProps(__spreadValues({}, w.settings), {
555
- __ctx: context,
556
- __data: preloaded[w.widgetId]
557
- })
558
- }))
559
- });
560
- const areAllSelected = selectedWidgets.length === entity.widgets.length;
561
- const handleSelectWidget = (newWidget) => {
562
- setSelectedWidgets((oldList) => {
563
- const isUnique = oldList.filter((w) => w === newWidget).length <= 0;
564
- if (isUnique) {
565
- return [...oldList, newWidget];
566
- } else {
567
- return oldList.filter((w) => w !== newWidget);
568
- }
569
- });
570
- };
571
- const handleCopyWidgets = (widgets, copyType) => {
572
- if (copyType === "multiple") {
573
- const filterSelected = entity.widgets.filter(
574
- (w) => widgets.some((c) => w.widgetId === c)
575
- );
576
- saveToLocalStorage(identifier, filterSelected);
577
- setSelectedWidgets([]);
578
- return;
579
- }
580
- saveToLocalStorage(identifier, widgets);
581
- };
582
- const handleSelectAll = () => {
583
- if (areAllSelected) return setSelectedWidgets([]);
584
- setSelectedWidgets(entity.widgets.map((w) => w.widgetId));
585
- };
586
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react6.default.Fragment, { children: [
587
- layoutMessage && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "r-reset r-fs-base r-layout-message", children: layoutMessage }),
588
- selectedWidgets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
589
- SelectedWidgetsToolbar_default,
590
- {
591
- length: selectedWidgets.length,
592
- onCopy: () => handleCopyWidgets(selectedWidgets, "multiple")
593
- }
594
- ),
595
- entity.widgets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
596
- "button",
597
- {
598
- className: `r-button-reset r-button-select-all ${areAllSelected ? "r-all-selected" : ""}`,
599
- type: "button",
600
- title: "Select all (or Deselect all)",
601
- onClick: () => handleSelectAll()
602
- }
603
- ),
604
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: detailPath, className: "r-reset r-details-link", title: "Details" }),
605
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: canvasClassName, children: entity.widgets.map(({ widgetId, component, settings }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
606
- AdminWidgetMinimal_default,
607
- {
608
- library,
609
- adminLibrary,
610
- widget: { widgetId, component, settings },
611
- onCopy: handleCopyWidgets,
612
- onSelectWidget: handleSelectWidget,
613
- selectedWidgets
614
- },
615
- widgetId
616
- )) })
617
- ] });
618
- };
619
- var AdminPageRender_default = AdminPageRender;
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
-
660
- // src/extractImageValue.js
661
- function extractImageValue(value) {
662
- if (!value) {
663
- return null;
664
- }
665
- return value.hasOwnProperty("image") ? value.image : value;
666
- }
667
- var extractImageValue_default = extractImageValue;
668
- // Annotate the CommonJS export names for ESM import in node:
669
- 0 && (module.exports = {
670
- AdminPageRender,
671
- Container,
672
- EmbeddedVideo,
673
- Image,
674
- WidgetRender,
675
- extractImageValue,
676
- imagePlaceholder,
677
- imageSrc,
678
- isImagePresent,
679
- toHTML
680
- });