@raketa-builder/support 0.4.0 → 0.5.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @raketa-builder/support@0.4.0 build
2
+ > @raketa-builder/support@0.5.0 build
3
3
  > tsup src/index.js --format cjs --loader ".js=jsx"
4
4
 
5
5
  CLI Building entry: src/index.js
@@ -7,5 +7,5 @@ CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v6.5.0
8
8
  CLI Target: es6
9
9
  CJS Build start
10
- CJS dist/index.js 11.66 KB
11
- CJS ⚡️ Build success in 31ms
10
+ CJS dist/index.js 16.10 KB
11
+ CJS ⚡️ Build success in 244ms
package/dist/index.js CHANGED
@@ -52,6 +52,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
52
52
  // src/index.js
53
53
  var src_exports = {};
54
54
  __export(src_exports, {
55
+ AdminPageRender: () => AdminPageRender_default,
55
56
  Container: () => Container_default,
56
57
  EmbeddedVideo: () => EmbeddedVideo_default,
57
58
  Image: () => Image_default,
@@ -357,8 +358,122 @@ function isImagePresent(value) {
357
358
  return !!value;
358
359
  }
359
360
  var isImagePresent_default = isImagePresent;
361
+
362
+ // src/AdminPageRender/index.js
363
+ var import_react6 = __toESM(require("react"));
364
+
365
+ // src/AdminPageRender/AdminWidgetMinimal.js
366
+ var import_react5 = __toESM(require("react"));
367
+
368
+ // src/AdminPageRender/IconButton.js
369
+ var import_react4 = __toESM(require("react"));
370
+ var import_jsx_runtime4 = require("react/jsx-runtime");
371
+ var ICON_COPY = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY29weSI+PHJlY3QgeD0iOSIgeT0iOSIgd2lkdGg9IjEzIiBoZWlnaHQ9IjEzIiByeD0iMiIgcnk9IjIiPjwvcmVjdD48cGF0aCBkPSJNNSAxNUg0YTIgMiAwIDAgMS0yLTJWNGEyIDIgMCAwIDEgMi0yaDlhMiAyIDAgMCAxIDIgMnYxIj48L3BhdGg+PC9zdmc+";
372
+ var IconButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
373
+ "button",
374
+ __spreadValues({
375
+ type: "button",
376
+ style: {
377
+ display: "inline-block",
378
+ width: "32px",
379
+ height: "32px",
380
+ marginRight: "4px",
381
+ marginLeft: "0px",
382
+ appearance: "none",
383
+ outline: "0",
384
+ border: "0",
385
+ borderRadius: "3px",
386
+ background: "transparent",
387
+ backgroundColor: "#fff",
388
+ backgroundRepeat: "no-repeat",
389
+ backgroundPosition: "center",
390
+ backgroundSize: "50%",
391
+ backgroundImage: `url(${ICON_COPY})`,
392
+ cursor: "pointer"
393
+ }
394
+ }, props)
395
+ );
396
+ var IconButton_default = IconButton;
397
+
398
+ // src/AdminPageRender/AdminWidgetMinimal.js
399
+ var import_jsx_runtime5 = require("react/jsx-runtime");
400
+ function cn() {
401
+ return Array.from(arguments).filter(Boolean).map(String).join(" ");
402
+ }
403
+ var AdminWidgetWrapper = (_a) => {
404
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
405
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", __spreadValues({ className: cn("r-admin-widget-wrapper", className) }, rest));
406
+ };
407
+ var AdminWidgetToolbar = (_a) => {
408
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
409
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
410
+ "div",
411
+ __spreadValues({
412
+ className: cn("r-reset", "r-admin-widget-toolbar", className)
413
+ }, rest)
414
+ );
415
+ };
416
+ var AdminWidgetLabel = (_a) => {
417
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
418
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
419
+ "div",
420
+ __spreadValues({
421
+ className: cn("r-reset", "r-fs-small", "r-admin-widget-label", className)
422
+ }, rest)
423
+ );
424
+ };
425
+ var title = (widget) => {
426
+ return widget.Config.title;
427
+ };
428
+ var deprecated = (widget) => {
429
+ return widget.Config.deprecated;
430
+ };
431
+ var AdminWidgetMinimal = ({ library, adminLibrary, widget, onCopy }) => {
432
+ const currentWidget = library[widget.component];
433
+ const currentAdminWidget = adminLibrary[widget.component];
434
+ if (!currentWidget || !currentAdminWidget) {
435
+ console.error(`Unknown widget: ${widget.component}`);
436
+ return null;
437
+ }
438
+ const handleCopyWidget = () => {
439
+ const widgetsToCopy = [widget];
440
+ onCopy(widgetsToCopy);
441
+ };
442
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(AdminWidgetWrapper, { "data-widget": widget.component, children: [
443
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AdminWidgetToolbar, { "data-toolbar": true, children: !deprecated(currentAdminWidget) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IconButton_default, { onClick: handleCopyWidget }) }),
444
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AdminWidgetLabel, { "data-widget-label": true, children: title(currentAdminWidget) }),
445
+ import_react5.default.createElement(currentWidget, widget.settings)
446
+ ] });
447
+ };
448
+ AdminWidgetMinimal.defaultProps = {
449
+ containerSettings: {}
450
+ };
451
+ var AdminWidgetMinimal_default = AdminWidgetMinimal;
452
+
453
+ // src/AdminPageRender/index.js
454
+ var import_jsx_runtime6 = require("react/jsx-runtime");
455
+ var AdminPageRender = ({ page, library, adminLibrary, identifier }) => {
456
+ const handleCopyWidgets = (widgets) => {
457
+ window.localStorage.setItem(
458
+ `clipboard\u2013${identifier}`,
459
+ JSON.stringify(widgets)
460
+ );
461
+ };
462
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react6.default.Fragment, { children: page.widgets.map(({ widgetId, component, settings }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
463
+ AdminWidgetMinimal_default,
464
+ {
465
+ library,
466
+ adminLibrary,
467
+ widget: { widgetId, component, settings },
468
+ onCopy: handleCopyWidgets
469
+ },
470
+ widgetId
471
+ )) });
472
+ };
473
+ var AdminPageRender_default = AdminPageRender;
360
474
  // Annotate the CommonJS export names for ESM import in node:
361
475
  0 && (module.exports = {
476
+ AdminPageRender,
362
477
  Container,
363
478
  EmbeddedVideo,
364
479
  Image,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-builder/support",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -0,0 +1,70 @@
1
+ /* eslint-disable no-undef */
2
+ import React from "react";
3
+ import IconButton from "./IconButton";
4
+
5
+ function cn() {
6
+ return Array.from(arguments).filter(Boolean).map(String).join(" ");
7
+ }
8
+
9
+ const AdminWidgetWrapper = ({ className, ...rest }) => (
10
+ <div className={cn("r-admin-widget-wrapper", className)} {...rest} />
11
+ );
12
+
13
+ const AdminWidgetToolbar = ({ className, ...rest }) => (
14
+ <div
15
+ className={cn("r-reset", "r-admin-widget-toolbar", className)}
16
+ {...rest}
17
+ />
18
+ );
19
+
20
+ const AdminWidgetLabel = ({ className, ...rest }) => (
21
+ <div
22
+ className={cn("r-reset", "r-fs-small", "r-admin-widget-label", className)}
23
+ {...rest}
24
+ />
25
+ );
26
+
27
+ const title = (widget) => {
28
+ return widget.Config.title;
29
+ };
30
+
31
+ const deprecated = (widget) => {
32
+ return widget.Config.deprecated;
33
+ };
34
+
35
+ const AdminWidgetMinimal = ({ library, adminLibrary, widget, onCopy }) => {
36
+ const currentWidget = library[widget.component];
37
+ const currentAdminWidget = adminLibrary[widget.component];
38
+
39
+ if (!currentWidget || !currentAdminWidget) {
40
+ console.error(`Unknown widget: ${widget.component}`);
41
+ return null;
42
+ }
43
+
44
+ const handleCopyWidget = () => {
45
+ const widgetsToCopy = [widget];
46
+ onCopy(widgetsToCopy);
47
+ };
48
+
49
+ return (
50
+ <AdminWidgetWrapper data-widget={widget.component}>
51
+ <AdminWidgetToolbar data-toolbar>
52
+ {!deprecated(currentAdminWidget) && (
53
+ <IconButton onClick={handleCopyWidget} />
54
+ )}
55
+ </AdminWidgetToolbar>
56
+
57
+ <AdminWidgetLabel data-widget-label>
58
+ {title(currentAdminWidget)}
59
+ </AdminWidgetLabel>
60
+
61
+ {React.createElement(currentWidget, widget.settings)}
62
+ </AdminWidgetWrapper>
63
+ );
64
+ };
65
+
66
+ AdminWidgetMinimal.defaultProps = {
67
+ containerSettings: {},
68
+ };
69
+
70
+ export default AdminWidgetMinimal;
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+
3
+ const ICON_COPY =
4
+ "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY29weSI+PHJlY3QgeD0iOSIgeT0iOSIgd2lkdGg9IjEzIiBoZWlnaHQ9IjEzIiByeD0iMiIgcnk9IjIiPjwvcmVjdD48cGF0aCBkPSJNNSAxNUg0YTIgMiAwIDAgMS0yLTJWNGEyIDIgMCAwIDEgMi0yaDlhMiAyIDAgMCAxIDIgMnYxIj48L3BhdGg+PC9zdmc+";
5
+
6
+ const IconButton = (props) => (
7
+ <button
8
+ type="button"
9
+ style={{
10
+ display: "inline-block",
11
+ width: "32px",
12
+ height: "32px",
13
+ marginRight: "4px",
14
+ marginLeft: "0px",
15
+ appearance: "none",
16
+ outline: "0",
17
+ border: "0",
18
+ borderRadius: "3px",
19
+ background: "transparent",
20
+ backgroundColor: "#fff",
21
+ backgroundRepeat: "no-repeat",
22
+ backgroundPosition: "center",
23
+ backgroundSize: "50%",
24
+ backgroundImage: `url(${ICON_COPY})`,
25
+ cursor: "pointer",
26
+ }}
27
+ {...props}
28
+ />
29
+ );
30
+
31
+ export default IconButton;
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import AdminWidgetMinimal from "./AdminWidgetMinimal";
3
+
4
+ const AdminPageRender = ({ page, library, adminLibrary, identifier }) => {
5
+ const handleCopyWidgets = (widgets) => {
6
+ window.localStorage.setItem(
7
+ `clipboard–${identifier}`,
8
+ JSON.stringify(widgets)
9
+ );
10
+ };
11
+
12
+ return (
13
+ <React.Fragment>
14
+ {page.widgets.map(({ widgetId, component, settings }) => (
15
+ <AdminWidgetMinimal
16
+ key={widgetId}
17
+ library={library}
18
+ adminLibrary={adminLibrary}
19
+ widget={{ widgetId, component, settings }}
20
+ onCopy={handleCopyWidgets}
21
+ />
22
+ ))}
23
+ </React.Fragment>
24
+ );
25
+ };
26
+
27
+ export default AdminPageRender;
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ import Container from "./Container";
5
5
  import EmbeddedVideo from "./EmbeddedVideo";
6
6
  import toHTML from "./toHTML";
7
7
  import isImagePresent from "./isImagePresent";
8
+ import AdminPageRender from "./AdminPageRender";
8
9
 
9
10
  export {
10
11
  Image,
@@ -14,4 +15,5 @@ export {
14
15
  Container,
15
16
  EmbeddedVideo,
16
17
  toHTML,
18
+ AdminPageRender,
17
19
  };