@raketa-builder/menu-builder 0.7.0 → 0.9.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/.turbo/turbo-build.log +6 -3
- package/biome.json +3 -0
- package/dist/index.js +165 -49
- package/package.json +6 -5
- package/src/MenuBuilder/AdminWidget.js +30 -2
- package/src/MenuBuilder/ContentBuilder.js +15 -2
- package/src/MenuBuilder/MainNavigation.js +1 -1
- package/src/MenuBuilder/icons.js +3 -3
- package/src/styles.css +0 -1
- package/tsconfig.json +1 -1
- package/.turbo/turbo-lint.log +0 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
> @raketa-builder/menu-builder@0.9.0 build
|
|
3
|
+
> tsup src/index.js --format cjs --loader ".js=jsx"
|
|
4
|
+
|
|
2
5
|
CLI Building entry: src/index.js
|
|
3
6
|
CLI Using tsconfig: tsconfig.json
|
|
4
7
|
CLI tsup v6.5.0
|
|
5
8
|
CLI Target: es6
|
|
6
9
|
CJS Build start
|
|
7
|
-
CJS dist/index.js
|
|
8
|
-
CJS ⚡️ Build success in
|
|
10
|
+
CJS dist/index.js 63.18 KB
|
|
11
|
+
CJS ⚡️ Build success in 41ms
|
package/biome.json
ADDED
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,9 +220,22 @@ 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 Button7 = (_a) => {
|
|
222
|
-
var _b = _a, {
|
|
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
|
+
]);
|
|
236
|
+
const Component = as;
|
|
223
237
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
224
|
-
|
|
238
|
+
Component,
|
|
225
239
|
__spreadValues2({
|
|
226
240
|
type,
|
|
227
241
|
className: cn5(
|
|
@@ -232,14 +246,9 @@ var require_dist = __commonJS({
|
|
|
232
246
|
`r-button-${variant}`,
|
|
233
247
|
className
|
|
234
248
|
)
|
|
235
|
-
},
|
|
249
|
+
}, rest)
|
|
236
250
|
);
|
|
237
251
|
};
|
|
238
|
-
Button7.defaultProps = {
|
|
239
|
-
type: "button",
|
|
240
|
-
size: "md",
|
|
241
|
-
variant: "primary"
|
|
242
|
-
};
|
|
243
252
|
Button7.variants = ["primary", "secondary", "success", "danger"];
|
|
244
253
|
Button7.sizes = {
|
|
245
254
|
sm: "sm",
|
|
@@ -285,8 +294,8 @@ var require_dist = __commonJS({
|
|
|
285
294
|
var import_react52 = __toESM2(require("react"));
|
|
286
295
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
287
296
|
var Input2 = (_a) => {
|
|
288
|
-
var _b = _a, { className } = _b,
|
|
289
|
-
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("input", __spreadValues2({ className: cn5("r-reset", "r-input", className) },
|
|
297
|
+
var _b = _a, { className } = _b, rest = __objRest2(_b, ["className"]);
|
|
298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("input", __spreadValues2({ className: cn5("r-reset", "r-input", className) }, rest));
|
|
290
299
|
};
|
|
291
300
|
var Input_default = Input2;
|
|
292
301
|
var import_react62 = __toESM2(require("react"));
|
|
@@ -453,34 +462,64 @@ 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: cn5("r-reset-button r-modal-close-btn", className)
|
|
457
467
|
}, props)
|
|
458
468
|
);
|
|
459
469
|
};
|
|
470
|
+
var FooterBar = (_a) => {
|
|
471
|
+
var _b = _a, { className } = _b, props = __objRest2(_b, ["className"]);
|
|
472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", __spreadValues2({ className: cn5("r-reset", "r-modal-footer-bar", className) }, props));
|
|
473
|
+
};
|
|
460
474
|
var Content = (_a) => {
|
|
461
475
|
var _b = _a, { className } = _b, props = __objRest2(_b, ["className"]);
|
|
462
476
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", __spreadValues2({ className: cn5("r-reset", "r-modal-content", className) }, props));
|
|
463
477
|
};
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
478
|
+
function checkForChanges2(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
|
+
}
|
|
489
|
+
var Modal3 = (_a) => {
|
|
490
|
+
var _b = _a, {
|
|
491
|
+
title,
|
|
492
|
+
children,
|
|
493
|
+
customWrapper,
|
|
494
|
+
FooterContent,
|
|
495
|
+
onClose,
|
|
496
|
+
areChanges
|
|
497
|
+
} = _b, rest = __objRest2(_b, [
|
|
498
|
+
"title",
|
|
499
|
+
"children",
|
|
500
|
+
"customWrapper",
|
|
501
|
+
"FooterContent",
|
|
502
|
+
"onClose",
|
|
503
|
+
"areChanges"
|
|
504
|
+
]);
|
|
505
|
+
const ModalWrapper = customWrapper ? customWrapper : Wrapper2;
|
|
475
506
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react17.default.Fragment, { children: [
|
|
476
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, {
|
|
477
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
507
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, {}),
|
|
508
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ModalWrapper, __spreadProps2(__spreadValues2({}, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Inner, { children: [
|
|
478
509
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(TitleBar, { children: [
|
|
479
510
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Title, { children: title }),
|
|
480
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
512
|
+
CloseButton,
|
|
513
|
+
{
|
|
514
|
+
type: "button",
|
|
515
|
+
onClick: () => checkForChanges2(areChanges, onClose),
|
|
516
|
+
children: "\xD7"
|
|
517
|
+
}
|
|
518
|
+
)
|
|
481
519
|
] }),
|
|
482
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Content, { children })
|
|
483
|
-
|
|
520
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Content, { children }),
|
|
521
|
+
FooterContent && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterBar, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterContent, {}) })
|
|
522
|
+
] }) }))
|
|
484
523
|
] });
|
|
485
524
|
};
|
|
486
525
|
var Modal_default = Modal3;
|
|
@@ -711,7 +750,7 @@ var require_dist = __commonJS({
|
|
|
711
750
|
var import_react24 = __toESM2(require("react"));
|
|
712
751
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
713
752
|
var ImageAvatar = (_a) => {
|
|
714
|
-
var _b = _a, { size, className } = _b, props = __objRest2(_b, ["size", "className"]);
|
|
753
|
+
var _b = _a, { size = "24px", className } = _b, props = __objRest2(_b, ["size", "className"]);
|
|
715
754
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
716
755
|
"img",
|
|
717
756
|
__spreadValues2({
|
|
@@ -724,9 +763,6 @@ var require_dist = __commonJS({
|
|
|
724
763
|
}, props)
|
|
725
764
|
);
|
|
726
765
|
};
|
|
727
|
-
ImageAvatar.defaultProps = {
|
|
728
|
-
size: "24px"
|
|
729
|
-
};
|
|
730
766
|
var ImageAvatar_default = ImageAvatar;
|
|
731
767
|
var import_react25 = __toESM2(require("react"));
|
|
732
768
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
@@ -767,14 +803,53 @@ var require_dist = __commonJS({
|
|
|
767
803
|
);
|
|
768
804
|
};
|
|
769
805
|
var DefaultAvatar = (_a) => {
|
|
770
|
-
var _b = _a, { initials } = _b, props = __objRest2(_b, ["initials"]);
|
|
771
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DefaultAvatarStyles, __spreadProps2(__spreadValues2({ initials }, props), { children: initials }));
|
|
772
|
-
};
|
|
773
|
-
DefaultAvatar.defaultProps = {
|
|
774
|
-
size: "24px",
|
|
775
|
-
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 }));
|
|
776
808
|
};
|
|
777
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;
|
|
778
853
|
}
|
|
779
854
|
});
|
|
780
855
|
|
|
@@ -863,7 +938,7 @@ var MainNavigation = ({ items, tab, onTab, onChange }) => /* @__PURE__ */ (0, im
|
|
|
863
938
|
TabButton,
|
|
864
939
|
{
|
|
865
940
|
type: "button",
|
|
866
|
-
active: idx === tab,
|
|
941
|
+
active: (idx === tab).toString(),
|
|
867
942
|
onClick: () => onTab(idx),
|
|
868
943
|
children: item.label
|
|
869
944
|
}
|
|
@@ -937,7 +1012,7 @@ function Delete(_a) {
|
|
|
937
1012
|
viewBox: "0 0 24 24",
|
|
938
1013
|
fill: "none",
|
|
939
1014
|
stroke: "#000",
|
|
940
|
-
|
|
1015
|
+
strokeWidth: "2",
|
|
941
1016
|
strokeLinecap: "round",
|
|
942
1017
|
strokeLinejoin: "round"
|
|
943
1018
|
}, rest), {
|
|
@@ -967,7 +1042,7 @@ function Copy(_a) {
|
|
|
967
1042
|
viewBox: "0 0 24 24",
|
|
968
1043
|
fill: "none",
|
|
969
1044
|
stroke: "#000",
|
|
970
|
-
|
|
1045
|
+
strokeWidth: "2",
|
|
971
1046
|
strokeLinecap: "round",
|
|
972
1047
|
strokeLinejoin: "round"
|
|
973
1048
|
}, rest), {
|
|
@@ -1084,9 +1159,27 @@ var import_react_sortablejs2 = require("react-sortablejs");
|
|
|
1084
1159
|
var import_react4 = __toESM(require("react"));
|
|
1085
1160
|
var import_ui4 = __toESM(require_dist());
|
|
1086
1161
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1087
|
-
|
|
1162
|
+
function checkForChanges(hasChanges, onClose) {
|
|
1163
|
+
if (!hasChanges) {
|
|
1164
|
+
onClose();
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
if (!confirm(
|
|
1168
|
+
"You\u2019ve made changes to the widget. Are you sure you want to cancel?"
|
|
1169
|
+
))
|
|
1170
|
+
return;
|
|
1171
|
+
onClose();
|
|
1172
|
+
}
|
|
1173
|
+
var AdminWidget = ({
|
|
1174
|
+
Component,
|
|
1175
|
+
settings,
|
|
1176
|
+
onChange,
|
|
1177
|
+
handleChanges,
|
|
1178
|
+
onCancel
|
|
1179
|
+
}) => {
|
|
1088
1180
|
const [state, setState] = import_react4.default.useState(settings);
|
|
1089
1181
|
const Form = Component.admin;
|
|
1182
|
+
const areChanges = JSON.stringify(state) !== JSON.stringify(settings);
|
|
1090
1183
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
1091
1184
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1092
1185
|
Form,
|
|
@@ -1094,6 +1187,7 @@ var AdminWidget = ({ Component, settings, onChange, onCancel }) => {
|
|
|
1094
1187
|
settings: state,
|
|
1095
1188
|
onChange: (key, value) => {
|
|
1096
1189
|
setState(__spreadValues(__spreadValues({}, state), { [key]: value }));
|
|
1190
|
+
handleChanges(__spreadValues(__spreadValues({}, state), { [key]: value }));
|
|
1097
1191
|
}
|
|
1098
1192
|
}
|
|
1099
1193
|
),
|
|
@@ -1106,7 +1200,14 @@ var AdminWidget = ({ Component, settings, onChange, onCancel }) => {
|
|
|
1106
1200
|
children: "Save"
|
|
1107
1201
|
}
|
|
1108
1202
|
),
|
|
1109
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1203
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1204
|
+
import_ui4.Button,
|
|
1205
|
+
{
|
|
1206
|
+
variant: "secondary",
|
|
1207
|
+
onClick: () => checkForChanges(areChanges, onCancel),
|
|
1208
|
+
children: "Cancel"
|
|
1209
|
+
}
|
|
1210
|
+
)
|
|
1110
1211
|
] });
|
|
1111
1212
|
};
|
|
1112
1213
|
var AdminWidget_default = AdminWidget;
|
|
@@ -1147,6 +1248,7 @@ var ContentBuilder = ({ value, onChange }) => {
|
|
|
1147
1248
|
});
|
|
1148
1249
|
const [open, setOpen] = import_react6.default.useState(false);
|
|
1149
1250
|
const [state, setState] = import_react6.default.useState(value);
|
|
1251
|
+
const [areChanges, setAreChanges] = import_react6.default.useState(false);
|
|
1150
1252
|
(0, import_react6.useEffect)(() => {
|
|
1151
1253
|
setState(value);
|
|
1152
1254
|
}, [value]);
|
|
@@ -1172,7 +1274,10 @@ var ContentBuilder = ({ value, onChange }) => {
|
|
|
1172
1274
|
setState(newState);
|
|
1173
1275
|
onChange(newState);
|
|
1174
1276
|
};
|
|
1175
|
-
const closeWidget = () =>
|
|
1277
|
+
const closeWidget = () => {
|
|
1278
|
+
setWidget({ open: false, current: null });
|
|
1279
|
+
setAreChanges(false);
|
|
1280
|
+
};
|
|
1176
1281
|
const updateWidget = (widget2, settings) => {
|
|
1177
1282
|
const newState = __spreadProps(__spreadValues({}, state), {
|
|
1178
1283
|
widgets: update(state.widgets, __spreadProps(__spreadValues({}, widget2), { settings }))
|
|
@@ -1181,6 +1286,7 @@ var ContentBuilder = ({ value, onChange }) => {
|
|
|
1181
1286
|
setState(newState);
|
|
1182
1287
|
onChange(newState);
|
|
1183
1288
|
};
|
|
1289
|
+
const handleChanges = (settings) => setAreChanges(widget.current.settings !== settings);
|
|
1184
1290
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WidgetContext_default.Consumer, { children: (WIDGETS) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react6.default.Fragment, { children: [
|
|
1185
1291
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1186
1292
|
import_react_sortablejs2.ReactSortable,
|
|
@@ -1216,15 +1322,25 @@ var ContentBuilder = ({ value, onChange }) => {
|
|
|
1216
1322
|
}
|
|
1217
1323
|
),
|
|
1218
1324
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Button, { variant: "secondary", onClick: () => setOpen(true), children: "Add widget" }),
|
|
1219
|
-
widget.open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1220
|
-
|
|
1325
|
+
widget.open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1326
|
+
import_ui6.Modal,
|
|
1221
1327
|
{
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1328
|
+
title: "Settings",
|
|
1329
|
+
open: widget.open,
|
|
1330
|
+
areChanges,
|
|
1331
|
+
onClose: closeWidget,
|
|
1332
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1333
|
+
AdminWidget_default,
|
|
1334
|
+
{
|
|
1335
|
+
Component: getWidget(WIDGETS, widget.current.component),
|
|
1336
|
+
settings: widget.current.settings,
|
|
1337
|
+
onChange: (settings) => updateWidget(widget.current, settings),
|
|
1338
|
+
handleChanges,
|
|
1339
|
+
onCancel: closeWidget
|
|
1340
|
+
}
|
|
1341
|
+
)
|
|
1226
1342
|
}
|
|
1227
|
-
)
|
|
1343
|
+
),
|
|
1228
1344
|
open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1229
1345
|
AddWidget_default,
|
|
1230
1346
|
{
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-builder/menu-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"lint": "TIMING=1 eslint \"**/*.js\"",
|
|
9
8
|
"build": "tsup src/index.js --format cjs --loader \".js=jsx\"",
|
|
10
|
-
"dev": "tsup src/index.js --format cjs --loader \".js=jsx\" --watch"
|
|
9
|
+
"dev": "tsup src/index.js --format cjs --loader \".js=jsx\" --watch",
|
|
10
|
+
"format": "prettier --write .",
|
|
11
|
+
"lint": "biome lint --max-diagnostics=5000 ."
|
|
11
12
|
},
|
|
12
13
|
"peerDependencies": {
|
|
13
14
|
"react": "18.2.0",
|
|
@@ -18,10 +19,10 @@
|
|
|
18
19
|
"ui": "*"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
22
|
+
"@biomejs/biome": "1.5.2",
|
|
21
23
|
"@types/react": "17.0.37",
|
|
22
24
|
"@types/react-dom": "17.0.11",
|
|
23
|
-
"
|
|
24
|
-
"eslint-config-custom": "*",
|
|
25
|
+
"prettier": "3.2.4",
|
|
25
26
|
"react": "18.2.0",
|
|
26
27
|
"tsconfig": "*",
|
|
27
28
|
"tsup": "6.5.0",
|
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Button } from "@raketa-builder/ui";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
function checkForChanges(hasChanges, onClose) {
|
|
5
|
+
if (!hasChanges) {
|
|
6
|
+
onClose();
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (
|
|
11
|
+
!confirm(
|
|
12
|
+
"You’ve made changes to the widget. Are you sure you want to cancel?"
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
return;
|
|
16
|
+
|
|
17
|
+
onClose();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const AdminWidget = ({
|
|
21
|
+
Component,
|
|
22
|
+
settings,
|
|
23
|
+
onChange,
|
|
24
|
+
handleChanges,
|
|
25
|
+
onCancel,
|
|
26
|
+
}) => {
|
|
5
27
|
const [state, setState] = React.useState(settings);
|
|
6
28
|
const Form = Component.admin;
|
|
7
29
|
|
|
30
|
+
const areChanges = JSON.stringify(state) !== JSON.stringify(settings);
|
|
31
|
+
|
|
8
32
|
return (
|
|
9
33
|
<div>
|
|
10
34
|
<Form
|
|
11
35
|
settings={state}
|
|
12
36
|
onChange={(key, value) => {
|
|
13
37
|
setState({ ...state, ...{ [key]: value } });
|
|
38
|
+
handleChanges({ ...state, ...{ [key]: value } });
|
|
14
39
|
}}
|
|
15
40
|
/>
|
|
16
41
|
|
|
@@ -21,7 +46,10 @@ const AdminWidget = ({ Component, settings, onChange, onCancel }) => {
|
|
|
21
46
|
>
|
|
22
47
|
Save
|
|
23
48
|
</Button>
|
|
24
|
-
<Button
|
|
49
|
+
<Button
|
|
50
|
+
variant="secondary"
|
|
51
|
+
onClick={() => checkForChanges(areChanges, onCancel)}
|
|
52
|
+
>
|
|
25
53
|
Cancel
|
|
26
54
|
</Button>
|
|
27
55
|
</div>
|
|
@@ -31,6 +31,7 @@ const ContentBuilder = ({ value, onChange }) => {
|
|
|
31
31
|
});
|
|
32
32
|
const [open, setOpen] = React.useState(false);
|
|
33
33
|
const [state, setState] = React.useState(value);
|
|
34
|
+
const [areChanges, setAreChanges] = React.useState(false);
|
|
34
35
|
|
|
35
36
|
useEffect(() => {
|
|
36
37
|
setState(value);
|
|
@@ -66,7 +67,10 @@ const ContentBuilder = ({ value, onChange }) => {
|
|
|
66
67
|
onChange(newState);
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
const closeWidget = () =>
|
|
70
|
+
const closeWidget = () => {
|
|
71
|
+
setWidget({ open: false, current: null });
|
|
72
|
+
setAreChanges(false);
|
|
73
|
+
};
|
|
70
74
|
|
|
71
75
|
const updateWidget = (widget, settings) => {
|
|
72
76
|
const newState = {
|
|
@@ -79,6 +83,9 @@ const ContentBuilder = ({ value, onChange }) => {
|
|
|
79
83
|
onChange(newState);
|
|
80
84
|
};
|
|
81
85
|
|
|
86
|
+
const handleChanges = (settings) =>
|
|
87
|
+
setAreChanges(widget.current.settings !== settings);
|
|
88
|
+
|
|
82
89
|
return (
|
|
83
90
|
<WidgetContext.Consumer>
|
|
84
91
|
{(WIDGETS) => (
|
|
@@ -121,11 +128,17 @@ const ContentBuilder = ({ value, onChange }) => {
|
|
|
121
128
|
</Button>
|
|
122
129
|
|
|
123
130
|
{widget.open && (
|
|
124
|
-
<Modal
|
|
131
|
+
<Modal
|
|
132
|
+
title="Settings"
|
|
133
|
+
open={widget.open}
|
|
134
|
+
areChanges={areChanges}
|
|
135
|
+
onClose={closeWidget}
|
|
136
|
+
>
|
|
125
137
|
<AdminWidget
|
|
126
138
|
Component={getWidget(WIDGETS, widget.current.component)}
|
|
127
139
|
settings={widget.current.settings}
|
|
128
140
|
onChange={(settings) => updateWidget(widget.current, settings)}
|
|
141
|
+
handleChanges={handleChanges}
|
|
129
142
|
onCancel={closeWidget}
|
|
130
143
|
/>
|
|
131
144
|
</Modal>
|
package/src/MenuBuilder/icons.js
CHANGED
|
@@ -50,7 +50,7 @@ export function Delete({ className, ...rest }) {
|
|
|
50
50
|
viewBox="0 0 24 24"
|
|
51
51
|
fill="none"
|
|
52
52
|
stroke="#000"
|
|
53
|
-
|
|
53
|
+
strokeWidth="2"
|
|
54
54
|
strokeLinecap="round"
|
|
55
55
|
strokeLinejoin="round"
|
|
56
56
|
{...rest}
|
|
@@ -78,7 +78,7 @@ export function Plus({ className, ...rest }) {
|
|
|
78
78
|
viewBox="0 0 24 24"
|
|
79
79
|
fill="none"
|
|
80
80
|
stroke="#000"
|
|
81
|
-
|
|
81
|
+
strokeWidth="2"
|
|
82
82
|
strokeLinecap="round"
|
|
83
83
|
strokeLinejoin="round"
|
|
84
84
|
{...rest}
|
|
@@ -106,7 +106,7 @@ export function Copy({ className, ...rest }) {
|
|
|
106
106
|
viewBox="0 0 24 24"
|
|
107
107
|
fill="none"
|
|
108
108
|
stroke="#000"
|
|
109
|
-
|
|
109
|
+
strokeWidth="2"
|
|
110
110
|
strokeLinecap="round"
|
|
111
111
|
strokeLinejoin="round"
|
|
112
112
|
{...rest}
|
package/src/styles.css
CHANGED
package/tsconfig.json
CHANGED
package/.turbo/turbo-lint.log
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
$ TIMING=1 eslint "**/*.js"
|
|
2
|
-
Rule | Time (ms) | Relative
|
|
3
|
-
:---------------------------------|----------:|--------:
|
|
4
|
-
react/display-name | 28.043 | 25.4%
|
|
5
|
-
react/no-direct-mutation-state | 27.800 | 25.2%
|
|
6
|
-
react/require-render-return | 20.287 | 18.4%
|
|
7
|
-
react/no-deprecated | 4.712 | 4.3%
|
|
8
|
-
react-hooks/exhaustive-deps | 4.033 | 3.7%
|
|
9
|
-
react-hooks/rules-of-hooks | 3.917 | 3.5%
|
|
10
|
-
react/no-string-refs | 3.201 | 2.9%
|
|
11
|
-
react/no-unescaped-entities | 2.490 | 2.3%
|
|
12
|
-
react/jsx-no-comment-textnodes | 1.645 | 1.5%
|
|
13
|
-
jsx-a11y/role-supports-aria-props | 1.306 | 1.2%
|