@raketa-builder/image-input 0.10.0 → 0.12.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/image-input@0.10.0 build
2
+ > @raketa-builder/image-input@0.12.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 307.82 KB
11
- CJS ⚡️ Build success in 179ms
10
+ CJS dist/index.js 321.38 KB
11
+ CJS ⚡️ Build success in 65ms
package/dist/index.js CHANGED
@@ -114,6 +114,7 @@ var require_dist = __commonJS({
114
114
  var src_exports2 = {};
115
115
  __export2(src_exports2, {
116
116
  Button: () => Button_default,
117
+ CategoriesMenu: () => CategoriesMenu_default,
117
118
  Col: () => Col,
118
119
  Container: () => Container_default,
119
120
  DataGrid: () => DataGrid_default,
@@ -219,11 +220,24 @@ var require_dist = __commonJS({
219
220
  var import_react32 = __toESM2(require("react"));
220
221
  var import_jsx_runtime32 = require("react/jsx-runtime");
221
222
  var Button5 = (_a) => {
222
- var _b = _a, { as = "button", size, variant, className } = _b, rest = __objRest2(_b, ["as", "size", "variant", "className"]);
223
+ var _b = _a, {
224
+ as = "button",
225
+ size = "md",
226
+ variant = "primary",
227
+ className,
228
+ type = "button"
229
+ } = _b, rest = __objRest2(_b, [
230
+ "as",
231
+ "size",
232
+ "variant",
233
+ "className",
234
+ "type"
235
+ ]);
223
236
  const Component = as;
224
237
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
225
238
  Component,
226
239
  __spreadValues2({
240
+ type,
227
241
  className: cn7(
228
242
  "r-reset",
229
243
  "r-reset-button",
@@ -235,11 +249,6 @@ var require_dist = __commonJS({
235
249
  }, rest)
236
250
  );
237
251
  };
238
- Button5.defaultProps = {
239
- type: "button",
240
- size: "md",
241
- variant: "primary"
242
- };
243
252
  Button5.variants = ["primary", "secondary", "success", "danger"];
244
253
  Button5.sizes = {
245
254
  sm: "sm",
@@ -453,6 +462,7 @@ var require_dist = __commonJS({
453
462
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
454
463
  "button",
455
464
  __spreadValues2({
465
+ type: "button",
456
466
  className: cn7("r-reset-button r-modal-close-btn", className)
457
467
  }, props)
458
468
  );
@@ -465,37 +475,47 @@ var require_dist = __commonJS({
465
475
  var _b = _a, { className } = _b, props = __objRest2(_b, ["className"]);
466
476
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", __spreadValues2({ className: cn7("r-reset", "r-modal-content", className) }, props));
467
477
  };
478
+ function checkForChanges(hasChanges, onClose) {
479
+ if (!hasChanges) {
480
+ onClose();
481
+ return;
482
+ }
483
+ if (!confirm(
484
+ "You\u2019ve made changes to the widget. Are you sure you want to cancel?"
485
+ ))
486
+ return;
487
+ onClose();
488
+ }
468
489
  var Modal2 = (_a) => {
469
490
  var _b = _a, {
470
491
  title,
471
492
  children,
472
493
  customWrapper,
473
494
  FooterContent,
474
- onClose
495
+ onClose,
496
+ areChanges
475
497
  } = _b, rest = __objRest2(_b, [
476
498
  "title",
477
499
  "children",
478
500
  "customWrapper",
479
501
  "FooterContent",
480
- "onClose"
502
+ "onClose",
503
+ "areChanges"
481
504
  ]);
482
- const handleKeyUp = ({ key }) => {
483
- if (key === "Escape")
484
- onClose();
485
- };
486
- import_react17.default.useEffect(() => {
487
- document.addEventListener("keyup", handleKeyUp);
488
- return () => {
489
- document.removeEventListener("keyup", handleKeyUp);
490
- };
491
- });
492
505
  const ModalWrapper = customWrapper ? customWrapper : Wrapper;
493
506
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react17.default.Fragment, { children: [
494
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, { onClick: onClose }),
507
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, {}),
495
508
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ModalWrapper, __spreadProps2(__spreadValues2({}, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Inner, { children: [
496
509
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(TitleBar, { children: [
497
510
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Title, { children: title }),
498
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CloseButton, { type: "button", onClick: onClose, children: "\xD7" })
511
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
512
+ CloseButton,
513
+ {
514
+ type: "button",
515
+ onClick: () => checkForChanges(areChanges, onClose),
516
+ children: "\xD7"
517
+ }
518
+ )
499
519
  ] }),
500
520
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Content, { children }),
501
521
  FooterContent && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterBar, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterContent, {}) })
@@ -730,7 +750,7 @@ var require_dist = __commonJS({
730
750
  var import_react24 = __toESM2(require("react"));
731
751
  var import_jsx_runtime24 = require("react/jsx-runtime");
732
752
  var ImageAvatar = (_a) => {
733
- var _b = _a, { size, className } = _b, props = __objRest2(_b, ["size", "className"]);
753
+ var _b = _a, { size = "24px", className } = _b, props = __objRest2(_b, ["size", "className"]);
734
754
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
735
755
  "img",
736
756
  __spreadValues2({
@@ -743,9 +763,6 @@ var require_dist = __commonJS({
743
763
  }, props)
744
764
  );
745
765
  };
746
- ImageAvatar.defaultProps = {
747
- size: "24px"
748
- };
749
766
  var ImageAvatar_default = ImageAvatar;
750
767
  var import_react25 = __toESM2(require("react"));
751
768
  var import_jsx_runtime25 = require("react/jsx-runtime");
@@ -786,14 +803,53 @@ var require_dist = __commonJS({
786
803
  );
787
804
  };
788
805
  var DefaultAvatar = (_a) => {
789
- var _b = _a, { initials } = _b, props = __objRest2(_b, ["initials"]);
790
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DefaultAvatarStyles, __spreadProps2(__spreadValues2({ initials }, props), { children: initials }));
791
- };
792
- DefaultAvatar.defaultProps = {
793
- size: "24px",
794
- initials: "AA"
806
+ var _b = _a, { initials = "AA", size = "24px" } = _b, props = __objRest2(_b, ["initials", "size"]);
807
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DefaultAvatarStyles, __spreadProps2(__spreadValues2({ initials, size }, props), { children: initials }));
795
808
  };
796
809
  var DefaultAvatar_default = DefaultAvatar;
810
+ var import_react26 = __toESM2(require("react"));
811
+ var import_jsx_runtime26 = require("react/jsx-runtime");
812
+ var IconsWrapper = () => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "r-reset r-categories-icons-wrapper", children: [
813
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
814
+ "img",
815
+ {
816
+ style: {
817
+ color: "#fff",
818
+ width: "24px",
819
+ height: "24px",
820
+ filter: "invert(1)"
821
+ },
822
+ alt: "directions",
823
+ src: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItZ3JpZCI+PHJlY3QgeD0iMyIgeT0iMyIgd2lkdGg9IjciIGhlaWdodD0iNyI+PC9yZWN0PjxyZWN0IHg9IjE0IiB5PSIzIiB3aWR0aD0iNyIgaGVpZ2h0PSI3Ij48L3JlY3Q+PHJlY3QgeD0iMTQiIHk9IjE0IiB3aWR0aD0iNyIgaGVpZ2h0PSI3Ij48L3JlY3Q+PHJlY3QgeD0iMyIgeT0iMTQiIHdpZHRoPSI3IiBoZWlnaHQ9IjciPjwvcmVjdD48L3N2Zz4="
824
+ }
825
+ ),
826
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
827
+ "img",
828
+ {
829
+ className: "r-reset r-category-chevron",
830
+ alt: "directions",
831
+ src: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAyMiAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTIxIDExLjVMMTEgMS41TDEgMTEuNSIgc3Ryb2tlPSIjMEMwQTA5IiBzdHJva2Utd2lkdGg9IjIiLz4KPC9zdmc+Cg=="
832
+ }
833
+ )
834
+ ] });
835
+ var Title2 = () => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "r-categories-title", children: "Categories" });
836
+ var CategoriesInner = (_a) => {
837
+ var props = __objRest2(_a, []);
838
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", __spreadProps2(__spreadValues2({}, props), { className: "r-reset r-categories-inner" }));
839
+ };
840
+ var CategoriesHiddenMenu = ({ paths }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "r-reset r-categories-hidden-menu", children: paths.map(({ title, link }, idx) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("a", { href: link, className: "r-reset r-category-link", children: title }, `${idx}-${link}`)) });
841
+ var CategoriesMenuWrapper = (_a) => {
842
+ var props = __objRest2(_a, []);
843
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", __spreadValues2({ className: "r-reset r-categories-menu" }, props));
844
+ };
845
+ var CategoriesMenu = ({ paths }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(CategoriesMenuWrapper, { children: [
846
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(CategoriesInner, { children: [
847
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(IconsWrapper, {}),
848
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Title2, {})
849
+ ] }),
850
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CategoriesHiddenMenu, { paths })
851
+ ] });
852
+ var CategoriesMenu_default = CategoriesMenu;
797
853
  }
798
854
  });
799
855
 
@@ -6354,11 +6410,14 @@ var require_dist2 = __commonJS({
6354
6410
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
6355
6411
  var src_exports2 = {};
6356
6412
  __export2(src_exports2, {
6413
+ AdminPageRender: () => AdminPageRender_default,
6357
6414
  Container: () => Container_default,
6358
6415
  EmbeddedVideo: () => EmbeddedVideo_default,
6359
6416
  Image: () => Image_default,
6417
+ extractImageValue: () => extractImageValue_default,
6360
6418
  imagePlaceholder: () => imagePlaceholder_default,
6361
6419
  imageSrc: () => imageSrc_default,
6420
+ isImagePresent: () => isImagePresent_default,
6362
6421
  toHTML: () => toHTML_default
6363
6422
  });
6364
6423
  module2.exports = __toCommonJS2(src_exports2);
@@ -6374,8 +6433,8 @@ var require_dist2 = __commonJS({
6374
6433
  var getDimensions = (src, variant) => {
6375
6434
  var _a, _b, _c;
6376
6435
  if (typeof src === "object" && ((_a = src == null ? void 0 : src.name) == null ? void 0 : _a.includes(".svg"))) {
6377
- const width = src.width;
6378
- const height = src.height;
6436
+ const width = src.width || null;
6437
+ const height = src.height || null;
6379
6438
  return [width, height];
6380
6439
  }
6381
6440
  if (typeof src === "object") {
@@ -6421,7 +6480,7 @@ var require_dist2 = __commonJS({
6421
6480
  return value;
6422
6481
  };
6423
6482
  var Image3 = (_a) => {
6424
- var _b = _a, { variant, src, alt, loading } = _b, props = __objRest2(_b, ["variant", "src", "alt", "loading"]);
6483
+ var _b = _a, { variant, src, alt, loading = "lazy" } = _b, props = __objRest2(_b, ["variant", "src", "alt", "loading"]);
6425
6484
  if (!variant) {
6426
6485
  console.error("Image with no variant", { variant, src, alt, props });
6427
6486
  return null;
@@ -6453,9 +6512,6 @@ var require_dist2 = __commonJS({
6453
6512
  )
6454
6513
  ] });
6455
6514
  };
6456
- Image3.defaultProps = {
6457
- loading: "lazy"
6458
- };
6459
6515
  var Image_default = Image3;
6460
6516
  var imageSrc = (src, variant) => {
6461
6517
  if (typeof src === "object" && !("name" in src))
@@ -6631,6 +6687,257 @@ var require_dist2 = __commonJS({
6631
6687
  return inline ? parser.renderInline(string) : parser.render(string);
6632
6688
  };
6633
6689
  var toHTML_default = toHTML;
6690
+ function isImagePresent(value) {
6691
+ if (!value) {
6692
+ return false;
6693
+ }
6694
+ if (value.hasOwnProperty("image")) {
6695
+ return !!value.image;
6696
+ }
6697
+ if (typeof value === "string" && value) {
6698
+ return true;
6699
+ }
6700
+ return !!value;
6701
+ }
6702
+ var isImagePresent_default = isImagePresent;
6703
+ var import_react62 = __toESM2(require("react"));
6704
+ var import_react52 = __toESM2(require("react"));
6705
+ var import_react42 = __toESM2(require("react"));
6706
+ var import_jsx_runtime42 = require("react/jsx-runtime");
6707
+ var ICON_COPY = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY29weSI+PHJlY3QgeD0iOSIgeT0iOSIgd2lkdGg9IjEzIiBoZWlnaHQ9IjEzIiByeD0iMiIgcnk9IjIiPjwvcmVjdD48cGF0aCBkPSJNNSAxNUg0YTIgMiAwIDAgMS0yLTJWNGEyIDIgMCAwIDEgMi0yaDlhMiAyIDAgMCAxIDIgMnYxIj48L3BhdGg+PC9zdmc+";
6708
+ var IconButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
6709
+ "button",
6710
+ __spreadValues2({
6711
+ type: "button",
6712
+ style: {
6713
+ display: "inline-block",
6714
+ width: "32px",
6715
+ height: "32px",
6716
+ marginRight: "4px",
6717
+ marginLeft: "0px",
6718
+ appearance: "none",
6719
+ outline: "0",
6720
+ border: "0",
6721
+ borderRadius: "3px",
6722
+ background: "transparent",
6723
+ backgroundColor: "#fff",
6724
+ backgroundRepeat: "no-repeat",
6725
+ backgroundPosition: "center",
6726
+ backgroundSize: "50%",
6727
+ backgroundImage: `url(${ICON_COPY})`,
6728
+ cursor: "pointer"
6729
+ }
6730
+ }, props)
6731
+ );
6732
+ var IconButton_default = IconButton;
6733
+ var import_jsx_runtime52 = require("react/jsx-runtime");
6734
+ function cn7() {
6735
+ return Array.from(arguments).filter(Boolean).map(String).join(" ");
6736
+ }
6737
+ var AdminWidgetWrapper = (_a) => {
6738
+ var _b = _a, { className } = _b, rest = __objRest2(_b, ["className"]);
6739
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", __spreadValues2({ className: cn7("r-admin-widget-wrapper", className) }, rest));
6740
+ };
6741
+ var AdminWidgetToolbar = (_a) => {
6742
+ var _b = _a, { className } = _b, rest = __objRest2(_b, ["className"]);
6743
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
6744
+ "div",
6745
+ __spreadValues2({
6746
+ className: cn7("r-reset", "r-admin-widget-toolbar", className)
6747
+ }, rest)
6748
+ );
6749
+ };
6750
+ var AdminWidgetLabel = (_a) => {
6751
+ var _b = _a, { className } = _b, rest = __objRest2(_b, ["className"]);
6752
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
6753
+ "div",
6754
+ __spreadValues2({
6755
+ className: cn7("r-reset", "r-fs-small", "r-admin-widget-label", className)
6756
+ }, rest)
6757
+ );
6758
+ };
6759
+ var title = (widget) => {
6760
+ return widget.Config.title;
6761
+ };
6762
+ var deprecated = (widget) => {
6763
+ return widget.Config.deprecated;
6764
+ };
6765
+ var AdminWidgetMinimal = ({
6766
+ library,
6767
+ adminLibrary,
6768
+ widget,
6769
+ onCopy,
6770
+ onSelectWidget,
6771
+ selectedWidgets
6772
+ }) => {
6773
+ var _a;
6774
+ const currentWidget = library[widget.component];
6775
+ const currentAdminWidget = adminLibrary[widget.component];
6776
+ const containerSettings = ((_a = widget == null ? void 0 : widget.settings) == null ? void 0 : _a.containerSettings) || {};
6777
+ const isSelected = selectedWidgets.filter((w) => w === widget.widgetId).length > 0;
6778
+ if (!currentWidget || !currentAdminWidget) {
6779
+ console.error(`Unknown widget: ${widget.component}`);
6780
+ return null;
6781
+ }
6782
+ const handleCopyWidget = () => {
6783
+ const widgetsToCopy = [widget];
6784
+ onCopy(widgetsToCopy);
6785
+ };
6786
+ const handleSelectWidget = () => onSelectWidget(widget.widgetId);
6787
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(AdminWidgetWrapper, { "data-widget": widget.component, children: [
6788
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "r-selected-widget" }),
6789
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(AdminWidgetToolbar, { "data-toolbar": true, children: [
6790
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
6791
+ "input",
6792
+ {
6793
+ type: "checkbox",
6794
+ style: {
6795
+ width: "32px",
6796
+ height: "32px"
6797
+ },
6798
+ onChange: handleSelectWidget,
6799
+ checked: isSelected
6800
+ }
6801
+ ),
6802
+ !isSelected && !deprecated(currentAdminWidget) && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(IconButton_default, { onClick: handleCopyWidget })
6803
+ ] }),
6804
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(AdminWidgetLabel, { "data-widget-label": true, children: title(currentAdminWidget) }),
6805
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Container_default, { settings: containerSettings, children: import_react52.default.createElement(currentWidget, widget.settings) })
6806
+ ] });
6807
+ };
6808
+ var AdminWidgetMinimal_default = AdminWidgetMinimal;
6809
+ var import_jsx_runtime62 = require("react/jsx-runtime");
6810
+ var IconCopy = () => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
6811
+ "svg",
6812
+ {
6813
+ xmlns: "http://www.w3.org/2000/svg",
6814
+ width: "16",
6815
+ height: "16",
6816
+ viewBox: "0 0 16 16",
6817
+ fill: "none",
6818
+ children: [
6819
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("g", { clipPath: "url(#clip0_2312_498)", children: [
6820
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6821
+ "path",
6822
+ {
6823
+ 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",
6824
+ stroke: "white",
6825
+ strokeWidth: "2",
6826
+ strokeLinecap: "round",
6827
+ strokeLinejoin: "round"
6828
+ }
6829
+ ),
6830
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
6831
+ "path",
6832
+ {
6833
+ 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",
6834
+ stroke: "white",
6835
+ strokeWidth: "2",
6836
+ strokeLinecap: "round",
6837
+ strokeLinejoin: "round"
6838
+ }
6839
+ )
6840
+ ] }),
6841
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("clipPath", { id: "clip0_2312_498", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("rect", { width: "16", height: "16", fill: "white" }) }) })
6842
+ ]
6843
+ }
6844
+ );
6845
+ var SelectedWidgetsToolbar = ({ length, onCopy }) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "r-selected-widgets-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "r-toolbar-inner", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
6846
+ "button",
6847
+ {
6848
+ type: "button",
6849
+ className: "r-button-reset r-toolbar-button",
6850
+ onClick: onCopy,
6851
+ children: [
6852
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(IconCopy, {}),
6853
+ "Copy selected (",
6854
+ length,
6855
+ ")"
6856
+ ]
6857
+ }
6858
+ ) }) });
6859
+ var SelectedWidgetsToolbar_default = SelectedWidgetsToolbar;
6860
+ var import_jsx_runtime72 = require("react/jsx-runtime");
6861
+ var saveToLocalStorage = (identifier, widgets) => window.localStorage.setItem(
6862
+ `clipboard\u2013${identifier}`,
6863
+ JSON.stringify(widgets)
6864
+ );
6865
+ var AdminPageRender = ({
6866
+ page,
6867
+ library,
6868
+ adminLibrary,
6869
+ identifier,
6870
+ detailPath,
6871
+ canvasClassName = ""
6872
+ }) => {
6873
+ const [selectedWidgets, setSelectedWidgets] = import_react62.default.useState([]);
6874
+ const areAllSelected = selectedWidgets.length === page.widgets.length;
6875
+ const handleSelectWidget = (newWidget) => {
6876
+ setSelectedWidgets((oldList) => {
6877
+ const isUnique = oldList.filter((w) => w === newWidget).length <= 0;
6878
+ if (isUnique) {
6879
+ return [...oldList, newWidget];
6880
+ } else {
6881
+ return oldList.filter((w) => w !== newWidget);
6882
+ }
6883
+ });
6884
+ };
6885
+ const handleCopyWidgets = (widgets, copyType) => {
6886
+ if (copyType === "multiple") {
6887
+ const filterSelected = page.widgets.filter(
6888
+ (w) => widgets.some((c) => w.widgetId === c)
6889
+ );
6890
+ saveToLocalStorage(identifier, filterSelected);
6891
+ setSelectedWidgets([]);
6892
+ return;
6893
+ }
6894
+ saveToLocalStorage(identifier, widgets);
6895
+ };
6896
+ const handleSelectAll = () => {
6897
+ if (areAllSelected)
6898
+ return setSelectedWidgets([]);
6899
+ setSelectedWidgets(page.widgets.map((w) => w.widgetId));
6900
+ };
6901
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_react62.default.Fragment, { children: [
6902
+ selectedWidgets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6903
+ SelectedWidgetsToolbar_default,
6904
+ {
6905
+ length: selectedWidgets.length,
6906
+ onCopy: () => handleCopyWidgets(selectedWidgets, "multiple")
6907
+ }
6908
+ ),
6909
+ page.widgets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6910
+ "button",
6911
+ {
6912
+ className: `r-button-reset r-button-select-all ${areAllSelected ? "r-all-selected" : ""}`,
6913
+ type: "button",
6914
+ title: "Select all (or Deselect all)",
6915
+ onClick: () => handleSelectAll()
6916
+ }
6917
+ ),
6918
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("a", { href: detailPath, className: "r-reset r-details-link", title: "Details" }),
6919
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: canvasClassName, children: page.widgets.map(({ widgetId, component, settings }) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
6920
+ AdminWidgetMinimal_default,
6921
+ {
6922
+ library,
6923
+ adminLibrary,
6924
+ widget: { widgetId, component, settings },
6925
+ onCopy: handleCopyWidgets,
6926
+ onSelectWidget: handleSelectWidget,
6927
+ selectedWidgets
6928
+ },
6929
+ widgetId
6930
+ )) })
6931
+ ] });
6932
+ };
6933
+ var AdminPageRender_default = AdminPageRender;
6934
+ function extractImageValue(value) {
6935
+ if (!value) {
6936
+ return null;
6937
+ }
6938
+ return value.hasOwnProperty("image") ? value.image : value;
6939
+ }
6940
+ var extractImageValue_default = extractImageValue;
6634
6941
  }
6635
6942
  });
6636
6943
 
@@ -6687,7 +6994,7 @@ var TextField = (props) => {
6687
6994
  hint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.P, { children: hint }) : ""
6688
6995
  ] });
6689
6996
  };
6690
- var TextInput = ({ label, onChange, value, placeholder }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
6997
+ var TextInput = ({ label, onChange, value = "", placeholder = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
6691
6998
  TextField,
6692
6999
  {
6693
7000
  label,
@@ -6696,10 +7003,6 @@ var TextInput = ({ label, onChange, value, placeholder }) => /* @__PURE__ */ (0,
6696
7003
  onChange
6697
7004
  }
6698
7005
  );
6699
- TextInput.defaultProps = {
6700
- value: "",
6701
- placeholder: ""
6702
- };
6703
7006
  var TextInput_default = TextInput;
6704
7007
 
6705
7008
  // src/dialogs/Dialog.js
@@ -6738,10 +7041,6 @@ var Dialog = ({
6738
7041
  secondaryLabel && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Button, { type: "button", variant: "secondary", onClick: onClose, children: secondaryLabel })
6739
7042
  ] })
6740
7043
  ] });
6741
- Dialog.defaultProps = {
6742
- children: [],
6743
- dialogSize: ""
6744
- };
6745
7044
  var Dialog_default = Dialog;
6746
7045
 
6747
7046
  // src/pickers/ImagePicker/BrowseTab.js
@@ -6953,7 +7252,7 @@ var DropzoneLabel = (_a) => {
6953
7252
  }, rest)
6954
7253
  );
6955
7254
  };
6956
- var Dropbox = ({ buttonLabel, onDrop }) => {
7255
+ var Dropbox = ({ buttonLabel = "Select files...", onDrop }) => {
6957
7256
  const dropzoneRef = import_react4.default.createRef();
6958
7257
  const handleOpen = () => dropzoneRef.current.open();
6959
7258
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.default.Fragment, { children: [
@@ -6974,7 +7273,6 @@ var Dropbox = ({ buttonLabel, onDrop }) => {
6974
7273
  )
6975
7274
  ] });
6976
7275
  };
6977
- Dropbox.defaultProps = { buttonLabel: "Select files..." };
6978
7276
  var Dropbox_default = Dropbox;
6979
7277
 
6980
7278
  // src/lib/ProgressBar.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-builder/image-input",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -44,9 +44,4 @@ const Dialog = ({
44
44
  </Modal>
45
45
  );
46
46
 
47
- Dialog.defaultProps = {
48
- children: [],
49
- dialogSize: "",
50
- };
51
-
52
47
  export default Dialog;
@@ -33,7 +33,7 @@ const TextField = (props) => {
33
33
  );
34
34
  };
35
35
 
36
- const TextInput = ({ label, onChange, value, placeholder }) => (
36
+ const TextInput = ({ label, onChange, value = "", placeholder = "" }) => (
37
37
  <TextField
38
38
  label={label}
39
39
  value={value}
@@ -42,9 +42,4 @@ const TextInput = ({ label, onChange, value, placeholder }) => (
42
42
  />
43
43
  );
44
44
 
45
- TextInput.defaultProps = {
46
- value: "",
47
- placeholder: "",
48
- };
49
-
50
45
  export default TextInput;
@@ -17,7 +17,7 @@ const DropzoneLabel = ({ className, ...rest }) => (
17
17
  />
18
18
  );
19
19
 
20
- const Dropbox = ({ buttonLabel, onDrop }) => {
20
+ const Dropbox = ({ buttonLabel = "Select files...", onDrop }) => {
21
21
  const dropzoneRef = React.createRef();
22
22
 
23
23
  const handleOpen = () => dropzoneRef.current.open();
@@ -48,6 +48,4 @@ const Dropbox = ({ buttonLabel, onDrop }) => {
48
48
  );
49
49
  };
50
50
 
51
- Dropbox.defaultProps = { buttonLabel: "Select files..." };
52
-
53
51
  export default Dropbox;
@@ -1,22 +0,0 @@
1
-
2
- > @raketa-builder/image-input@0.6.0 format
3
- > prettier --write .
4
-
5
- biome.json 432ms (unchanged)
6
- CHANGELOG.md 357ms (unchanged)
7
- dist/index.js 4221ms
8
- package.json 43ms (unchanged)
9
- src/dialogs/Dialog.js 111ms (unchanged)
10
- src/forms/TextInput.js 47ms (unchanged)
11
- src/index.js 4ms (unchanged)
12
- src/lib/Dropbox.js 96ms (unchanged)
13
- src/lib/ProgressBar.js 54ms (unchanged)
14
- src/lists/index.js 90ms
15
- src/MediaManager.js 152ms
16
- src/MediaManagerContext.js 3ms (unchanged)
17
- src/pickers/ImagePicker/BrowseTab.js 51ms (unchanged)
18
- src/pickers/ImagePicker/ImageInput.js 71ms (unchanged)
19
- src/pickers/ImagePicker/ImagePicker.js 175ms (unchanged)
20
- src/pickers/ImagePicker/UploadTab.js 86ms (unchanged)
21
- src/styles.css 590ms
22
- tsconfig.json 4ms
File without changes