@raketa-builder/menu-builder 1.3.6 → 1.3.9
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 +7 -820
- package/package.json +17 -3
- package/CHANGELOG.md +0 -7
- package/biome.json +0 -3
- package/src/MenuBuilder/AddWidget.js +0 -30
- package/src/MenuBuilder/AdminWidget.js +0 -69
- package/src/MenuBuilder/ColumnBuilder.js +0 -136
- package/src/MenuBuilder/ContentBuilder.js +0 -164
- package/src/MenuBuilder/Factories.js +0 -18
- package/src/MenuBuilder/ItemForm.js +0 -114
- package/src/MenuBuilder/MainNavigation.js +0 -58
- package/src/MenuBuilder/RowBuilder.js +0 -108
- package/src/MenuBuilder/WidgetContext.js +0 -3
- package/src/MenuBuilder/icons.js +0 -118
- package/src/MenuBuilder/index.js +0 -93
- package/src/MenuBuilder/utils.js +0 -14
- package/src/index.js +0 -3
- package/src/styles.css +0 -66
- package/tsconfig.json +0 -5
package/dist/index.js
CHANGED
|
@@ -1,827 +1,14 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
58
2
|
|
|
59
|
-
|
|
60
|
-
var index_exports = {};
|
|
61
|
-
__export(index_exports, {
|
|
62
|
-
MenuBuilder: () => MenuBuilder_default
|
|
63
|
-
});
|
|
64
|
-
module.exports = __toCommonJS(index_exports);
|
|
65
|
-
|
|
66
|
-
// src/MenuBuilder/index.js
|
|
67
|
-
var import_react9 = __toESM(require("react"));
|
|
68
|
-
|
|
69
|
-
// src/MenuBuilder/WidgetContext.js
|
|
70
|
-
var import_react = __toESM(require("react"));
|
|
71
|
-
var WidgetContext_default = import_react.default.createContext();
|
|
72
|
-
|
|
73
|
-
// src/MenuBuilder/MainNavigation.js
|
|
74
|
-
var import_react2 = __toESM(require("react"));
|
|
75
|
-
var import_react_sortablejs = require("react-sortablejs");
|
|
76
|
-
|
|
77
|
-
// src/MenuBuilder/utils.js
|
|
78
|
-
var rand = (length) => Math.random().toString(36).substring(length);
|
|
79
|
-
var remove = (items, item) => {
|
|
80
|
-
const idx = items.findIndex((i) => i.id === item.id);
|
|
81
|
-
return [...items.slice(0, idx), ...items.slice(idx + 1)];
|
|
82
|
-
};
|
|
83
|
-
var update = (items, item) => {
|
|
84
|
-
const idx = items.findIndex((i) => i.id === item.id);
|
|
85
|
-
return [...items.slice(0, idx), item, ...items.slice(idx + 1)];
|
|
86
|
-
};
|
|
87
|
-
var append = (items, item) => [...items, item];
|
|
88
|
-
|
|
89
|
-
// src/MenuBuilder/Factories.js
|
|
90
|
-
var Factories = {
|
|
91
|
-
item: () => ({
|
|
92
|
-
id: rand(4),
|
|
93
|
-
html_id: "",
|
|
94
|
-
class_name: "",
|
|
95
|
-
label: "New item",
|
|
96
|
-
url: "#",
|
|
97
|
-
target: "",
|
|
98
|
-
rows: []
|
|
99
|
-
}),
|
|
100
|
-
row: () => ({ id: rand(4), columns: [] }),
|
|
101
|
-
column: () => ({ id: rand(4), widgets: [] }),
|
|
102
|
-
widget: (component, settings) => ({ id: rand(4), component, settings })
|
|
103
|
-
};
|
|
104
|
-
var Factories_default = Factories;
|
|
105
|
-
|
|
106
|
-
// src/MenuBuilder/MainNavigation.js
|
|
107
|
-
var import_ui = require("@raketa-builder/ui");
|
|
108
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
109
|
-
var Item = (_a) => {
|
|
110
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
111
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
112
|
-
"div",
|
|
113
|
-
__spreadValues({
|
|
114
|
-
className: (0, import_ui.cn)(
|
|
115
|
-
"r-reset",
|
|
116
|
-
"r-main-nav-item",
|
|
117
|
-
props.active ? "active" : "",
|
|
118
|
-
className
|
|
119
|
-
)
|
|
120
|
-
}, props)
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
var TabButton = (_a) => {
|
|
124
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
125
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
|
-
"div",
|
|
127
|
-
__spreadValues({
|
|
128
|
-
className: (0, import_ui.cn)("r-reset-button r-main-nav-tab-button", className)
|
|
129
|
-
}, props)
|
|
130
|
-
);
|
|
131
|
-
};
|
|
132
|
-
var MainNavigation = ({ items, tab, onTab, onChange }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Container, { bottom: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { children: [
|
|
133
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
|
-
import_react_sortablejs.ReactSortable,
|
|
135
|
-
{
|
|
136
|
-
list: items,
|
|
137
|
-
setList: onChange,
|
|
138
|
-
direction: "horizontal",
|
|
139
|
-
dragoverBubble: true,
|
|
140
|
-
children: items.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Item, { active: idx === tab, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
141
|
-
TabButton,
|
|
142
|
-
{
|
|
143
|
-
type: "button",
|
|
144
|
-
active: (idx === tab).toString(),
|
|
145
|
-
onClick: () => onTab(idx),
|
|
146
|
-
children: item.label
|
|
147
|
-
}
|
|
148
|
-
) }, item.id))
|
|
149
|
-
}
|
|
150
|
-
),
|
|
151
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
-
import_ui.Button,
|
|
153
|
-
{
|
|
154
|
-
variant: "secondary",
|
|
155
|
-
onClick: () => onChange(append(items, Factories_default.item())),
|
|
156
|
-
children: "Add item"
|
|
157
|
-
}
|
|
158
|
-
)
|
|
159
|
-
] }) });
|
|
160
|
-
var MainNavigation_default = MainNavigation;
|
|
161
|
-
|
|
162
|
-
// src/MenuBuilder/ItemForm.js
|
|
163
|
-
var import_react3 = __toESM(require("react"));
|
|
164
|
-
|
|
165
|
-
// src/MenuBuilder/icons.js
|
|
166
|
-
var import_ui2 = require("@raketa-builder/ui");
|
|
167
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
168
|
-
function filterStyle(props) {
|
|
169
|
-
const value = props.invert ? 1 : 0;
|
|
170
|
-
return { filter: `invert(${value})` };
|
|
171
|
-
}
|
|
172
|
-
function Edit(_a) {
|
|
173
|
-
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
174
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
175
|
-
"svg",
|
|
176
|
-
__spreadProps(__spreadValues({
|
|
177
|
-
className: (0, import_ui2.cn)(
|
|
178
|
-
"r-reset",
|
|
179
|
-
"r-menu-icon",
|
|
180
|
-
"feather",
|
|
181
|
-
"feather-edit-2",
|
|
182
|
-
className
|
|
183
|
-
),
|
|
184
|
-
style: filterStyle(rest),
|
|
185
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
186
|
-
width: "24",
|
|
187
|
-
height: "24",
|
|
188
|
-
viewBox: "0 0 24 24",
|
|
189
|
-
fill: "none",
|
|
190
|
-
stroke: "#000",
|
|
191
|
-
strokeWidth: "2",
|
|
192
|
-
strokeLinecap: "round",
|
|
193
|
-
strokeLinejoin: "round"
|
|
194
|
-
}, rest), {
|
|
195
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z" })
|
|
196
|
-
})
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
function Delete(_a) {
|
|
200
|
-
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
201
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
202
|
-
"svg",
|
|
203
|
-
__spreadProps(__spreadValues({
|
|
204
|
-
className: (0, import_ui2.cn)(
|
|
205
|
-
"r-reset",
|
|
206
|
-
"r-menu-icon",
|
|
207
|
-
"feather",
|
|
208
|
-
"feather-trash",
|
|
209
|
-
className
|
|
210
|
-
),
|
|
211
|
-
style: filterStyle(rest),
|
|
212
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
213
|
-
width: "24",
|
|
214
|
-
height: "24",
|
|
215
|
-
viewBox: "0 0 24 24",
|
|
216
|
-
fill: "none",
|
|
217
|
-
stroke: "#000",
|
|
218
|
-
strokeWidth: "2",
|
|
219
|
-
strokeLinecap: "round",
|
|
220
|
-
strokeLinejoin: "round"
|
|
221
|
-
}, rest), {
|
|
222
|
-
children: [
|
|
223
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "3 6 5 6 21 6" }),
|
|
224
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
225
|
-
]
|
|
226
|
-
})
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
function Copy(_a) {
|
|
230
|
-
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
231
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
232
|
-
"svg",
|
|
233
|
-
__spreadProps(__spreadValues({
|
|
234
|
-
className: (0, import_ui2.cn)(
|
|
235
|
-
"r-reset",
|
|
236
|
-
"r-menu-icon",
|
|
237
|
-
"feather",
|
|
238
|
-
"feather-copy",
|
|
239
|
-
className
|
|
240
|
-
),
|
|
241
|
-
style: filterStyle(rest),
|
|
242
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
243
|
-
width: "24",
|
|
244
|
-
height: "24",
|
|
245
|
-
viewBox: "0 0 24 24",
|
|
246
|
-
fill: "none",
|
|
247
|
-
stroke: "#000",
|
|
248
|
-
strokeWidth: "2",
|
|
249
|
-
strokeLinecap: "round",
|
|
250
|
-
strokeLinejoin: "round"
|
|
251
|
-
}, rest), {
|
|
252
|
-
children: [
|
|
253
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
254
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
255
|
-
]
|
|
256
|
-
})
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// src/MenuBuilder/ItemForm.js
|
|
261
|
-
var import_ui3 = require("@raketa-builder/ui");
|
|
262
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
263
|
-
var ItemForm = ({ item, onChange, onRemove, onDuplicate }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
264
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.Stack, { children: [
|
|
265
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.FormGroup, { children: [
|
|
266
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, { htmlFor: "label", children: "Label" }),
|
|
267
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
268
|
-
import_ui3.Input,
|
|
269
|
-
{
|
|
270
|
-
name: "label",
|
|
271
|
-
type: "text",
|
|
272
|
-
wrapperProps: { style: { marginRight: "0.5em" } },
|
|
273
|
-
value: item.label,
|
|
274
|
-
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
275
|
-
label: e.target.value
|
|
276
|
-
}))
|
|
277
|
-
}
|
|
278
|
-
)
|
|
279
|
-
] }),
|
|
280
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.FormGroup, { children: [
|
|
281
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, { htmlFor: "url", children: "URL" }),
|
|
282
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
283
|
-
import_ui3.Input,
|
|
284
|
-
{
|
|
285
|
-
name: "url",
|
|
286
|
-
type: "text",
|
|
287
|
-
value: item.url,
|
|
288
|
-
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
289
|
-
url: e.target.value
|
|
290
|
-
}))
|
|
291
|
-
}
|
|
292
|
-
)
|
|
293
|
-
] }),
|
|
294
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.FormGroup, { children: [
|
|
295
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, { htmlFor: "html_id", children: "ID" }),
|
|
296
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
297
|
-
import_ui3.Input,
|
|
298
|
-
{
|
|
299
|
-
name: "html_id",
|
|
300
|
-
type: "text",
|
|
301
|
-
value: item.html_id,
|
|
302
|
-
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
303
|
-
html_id: e.target.value
|
|
304
|
-
}))
|
|
305
|
-
}
|
|
306
|
-
)
|
|
307
|
-
] }),
|
|
308
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.FormGroup, { children: [
|
|
309
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, { htmlFor: "class_name", children: "CSS class" }),
|
|
310
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
311
|
-
import_ui3.Input,
|
|
312
|
-
{
|
|
313
|
-
name: "class_name",
|
|
314
|
-
type: "text",
|
|
315
|
-
value: item.class_name,
|
|
316
|
-
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
317
|
-
class_name: e.target.value
|
|
318
|
-
}))
|
|
319
|
-
}
|
|
320
|
-
)
|
|
321
|
-
] }),
|
|
322
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.FormGroup, { children: [
|
|
323
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Label, { htmlFor: "target", children: "Target" }),
|
|
324
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
325
|
-
import_ui3.Select,
|
|
326
|
-
{
|
|
327
|
-
name: "target",
|
|
328
|
-
value: item.target,
|
|
329
|
-
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
330
|
-
target: e.target.value
|
|
331
|
-
})),
|
|
332
|
-
children: [
|
|
333
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "", children: "Please select" }),
|
|
334
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "_self", children: "Open in same tab" }),
|
|
335
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "_blank", children: "Open in new tab" })
|
|
336
|
-
]
|
|
337
|
-
}
|
|
338
|
-
)
|
|
339
|
-
] })
|
|
340
|
-
] }),
|
|
341
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Toolbar, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui3.Stack, { children: [
|
|
342
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Button, { variant: "secondary", onClick: onDuplicate, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Copy, {}) }),
|
|
343
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Button, { variant: "secondary", onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Delete, {}) })
|
|
344
|
-
] }) })
|
|
345
|
-
] });
|
|
346
|
-
var ItemForm_default = ItemForm;
|
|
347
|
-
|
|
348
|
-
// src/MenuBuilder/RowBuilder.js
|
|
349
|
-
var import_react8 = __toESM(require("react"));
|
|
350
|
-
var import_react_sortablejs4 = require("react-sortablejs");
|
|
351
|
-
|
|
352
|
-
// src/MenuBuilder/ColumnBuilder.js
|
|
353
|
-
var import_react7 = __toESM(require("react"));
|
|
354
|
-
var import_react_sortablejs3 = require("react-sortablejs");
|
|
355
|
-
var import_ui7 = require("@raketa-builder/ui");
|
|
356
|
-
|
|
357
|
-
// src/MenuBuilder/ContentBuilder.js
|
|
358
|
-
var import_react6 = __toESM(require("react"));
|
|
359
|
-
var import_react_sortablejs2 = require("react-sortablejs");
|
|
360
|
-
|
|
361
|
-
// src/MenuBuilder/AdminWidget.js
|
|
362
|
-
var import_react4 = __toESM(require("react"));
|
|
363
|
-
var import_ui4 = require("@raketa-builder/ui");
|
|
364
|
-
var import_builder = require("@raketa-builder/builder");
|
|
365
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
366
|
-
function checkForChanges(hasChanges, onClose) {
|
|
367
|
-
if (!hasChanges) {
|
|
368
|
-
onClose();
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
if (!confirm(
|
|
372
|
-
"You\u2019ve made changes to the widget. Are you sure you want to cancel?"
|
|
373
|
-
))
|
|
374
|
-
return;
|
|
375
|
-
onClose();
|
|
376
|
-
}
|
|
377
|
-
var AdminWidget = ({
|
|
378
|
-
widget,
|
|
379
|
-
settings,
|
|
380
|
-
onChange,
|
|
381
|
-
handleChanges,
|
|
382
|
-
onCancel
|
|
383
|
-
}) => {
|
|
384
|
-
const [state, setState] = import_react4.default.useState(settings);
|
|
385
|
-
const areChanges = JSON.stringify(state) !== JSON.stringify(settings);
|
|
386
|
-
const schema = widget.admin;
|
|
387
|
-
if (typeof schema !== "object") {
|
|
388
|
-
console.warn(
|
|
389
|
-
`Legacy widget with React admin definition: "${widget.name}". Update to schema defined inputs!`
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
393
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
394
|
-
import_builder.AdminForm,
|
|
395
|
-
{
|
|
396
|
-
schema,
|
|
397
|
-
value: state,
|
|
398
|
-
onChange: (newState) => {
|
|
399
|
-
console.log({ newState });
|
|
400
|
-
setState(__spreadValues({}, newState));
|
|
401
|
-
handleChanges(__spreadValues({}, newState));
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
),
|
|
405
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
406
|
-
import_ui4.Button,
|
|
407
|
-
{
|
|
408
|
-
type: "submit",
|
|
409
|
-
variant: "primary",
|
|
410
|
-
onClick: () => onChange(__spreadValues({}, state)),
|
|
411
|
-
children: "Save"
|
|
412
|
-
}
|
|
413
|
-
),
|
|
414
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
415
|
-
import_ui4.Button,
|
|
416
|
-
{
|
|
417
|
-
variant: "secondary",
|
|
418
|
-
onClick: () => checkForChanges(areChanges, onCancel),
|
|
419
|
-
children: "Cancel"
|
|
420
|
-
}
|
|
421
|
-
)
|
|
422
|
-
] });
|
|
423
|
-
};
|
|
424
|
-
var AdminWidget_default = AdminWidget;
|
|
3
|
+
var MenuBuilder = require('./MenuBuilder');
|
|
425
4
|
|
|
426
|
-
|
|
427
|
-
var import_react5 = __toESM(require("react"));
|
|
428
|
-
var import_ui5 = require("@raketa-builder/ui");
|
|
429
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
430
|
-
var WidgetButton = (_a) => {
|
|
431
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
432
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", __spreadValues({ className: (0, import_ui5.cn)("r-reset-button r-widget-button", className) }, props));
|
|
433
|
-
};
|
|
434
|
-
var AddWidget = ({ onAdd, onClose }) => {
|
|
435
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Modal, { open: true, title: "Select widget", onClose, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(WidgetContext_default.Consumer, { children: (WIDGETS) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.default.Fragment, { children: Object.keys(WIDGETS).map((widgetName) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
436
|
-
WidgetButton,
|
|
437
|
-
{
|
|
438
|
-
onClick: () => onAdd(widgetName, WIDGETS[widgetName]),
|
|
439
|
-
children: widgetName
|
|
440
|
-
},
|
|
441
|
-
widgetName
|
|
442
|
-
)) }) }) });
|
|
443
|
-
};
|
|
444
|
-
var AddWidget_default = AddWidget;
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
445
6
|
|
|
446
|
-
|
|
447
|
-
var import_ui6 = require("@raketa-builder/ui");
|
|
448
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
449
|
-
var getWidget = (widgets, name) => widgets[name];
|
|
450
|
-
var getTitle = (widgets, widget) => {
|
|
451
|
-
const { component } = widget;
|
|
452
|
-
const primaryField = getWidget(widgets, component).primaryField;
|
|
453
|
-
return primaryField ? `${component}: ${widget.settings[primaryField]}` : component;
|
|
454
|
-
};
|
|
455
|
-
var ContentBuilder = ({ value, onChange }) => {
|
|
456
|
-
const [widget, setWidget] = import_react6.default.useState({
|
|
457
|
-
open: false,
|
|
458
|
-
current: null
|
|
459
|
-
});
|
|
460
|
-
const [open, setOpen] = import_react6.default.useState(false);
|
|
461
|
-
const [state, setState] = import_react6.default.useState(value);
|
|
462
|
-
const [areChanges, setAreChanges] = import_react6.default.useState(false);
|
|
463
|
-
(0, import_react6.useEffect)(() => {
|
|
464
|
-
setState(value);
|
|
465
|
-
}, [value]);
|
|
466
|
-
const addWidget = (items, item) => {
|
|
467
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
468
|
-
widgets: [...items, item]
|
|
469
|
-
});
|
|
470
|
-
setOpen(false);
|
|
471
|
-
setState(newState);
|
|
472
|
-
onChange(newState);
|
|
473
|
-
};
|
|
474
|
-
const removeWidget = (items, item) => {
|
|
475
|
-
if (!confirm("Are you sure?")) return;
|
|
476
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
477
|
-
widgets: remove(items, item)
|
|
478
|
-
});
|
|
479
|
-
setState(newState);
|
|
480
|
-
onChange(newState);
|
|
481
|
-
};
|
|
482
|
-
const reorder = (widgets) => {
|
|
483
|
-
const newState = __spreadProps(__spreadValues({}, state), { widgets });
|
|
484
|
-
setState(newState);
|
|
485
|
-
onChange(newState);
|
|
486
|
-
};
|
|
487
|
-
const closeWidget = () => {
|
|
488
|
-
setWidget({ open: false, current: null });
|
|
489
|
-
setAreChanges(false);
|
|
490
|
-
};
|
|
491
|
-
const updateWidget = (widget2, settings) => {
|
|
492
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
493
|
-
widgets: update(state.widgets, __spreadProps(__spreadValues({}, widget2), { settings }))
|
|
494
|
-
});
|
|
495
|
-
closeWidget();
|
|
496
|
-
setState(newState);
|
|
497
|
-
onChange(newState);
|
|
498
|
-
};
|
|
499
|
-
const handleChanges = (settings) => setAreChanges(widget.current.settings !== settings);
|
|
500
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WidgetContext_default.Consumer, { children: (WIDGETS) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react6.default.Fragment, { children: [
|
|
501
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
502
|
-
import_react_sortablejs2.ReactSortable,
|
|
503
|
-
{
|
|
504
|
-
list: state.widgets,
|
|
505
|
-
setList: (widgets) => reorder(widgets),
|
|
506
|
-
handle: ".r-handle",
|
|
507
|
-
direction: "vertical",
|
|
508
|
-
children: state.widgets.map((widget2) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.PanelTitle, { children: [
|
|
509
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.Stack, { className: "r-stack-align-center", children: [
|
|
510
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Handle, { className: "r-handle" }),
|
|
511
|
-
getTitle(WIDGETS, widget2)
|
|
512
|
-
] }),
|
|
513
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.Stack, { className: "r-stack-align-center", children: [
|
|
514
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
515
|
-
import_ui6.Button,
|
|
516
|
-
{
|
|
517
|
-
variant: "secondary",
|
|
518
|
-
onClick: () => setWidget({ open: true, current: widget2 }),
|
|
519
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Edit, {})
|
|
520
|
-
}
|
|
521
|
-
),
|
|
522
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
523
|
-
import_ui6.Button,
|
|
524
|
-
{
|
|
525
|
-
variant: "secondary",
|
|
526
|
-
onClick: () => removeWidget(state.widgets, widget2),
|
|
527
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Delete, {})
|
|
528
|
-
}
|
|
529
|
-
)
|
|
530
|
-
] })
|
|
531
|
-
] }) }, widget2.id))
|
|
532
|
-
}
|
|
533
|
-
),
|
|
534
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Button, { variant: "secondary", onClick: () => setOpen(true), children: "Add widget" }),
|
|
535
|
-
widget.open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
536
|
-
import_ui6.Modal,
|
|
537
|
-
{
|
|
538
|
-
title: "Settings",
|
|
539
|
-
open: widget.open,
|
|
540
|
-
areChanges,
|
|
541
|
-
onClose: closeWidget,
|
|
542
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
543
|
-
AdminWidget_default,
|
|
544
|
-
{
|
|
545
|
-
widget: getWidget(WIDGETS, widget.current.component),
|
|
546
|
-
settings: widget.current.settings,
|
|
547
|
-
onChange: (settings) => updateWidget(widget.current, settings),
|
|
548
|
-
handleChanges,
|
|
549
|
-
onCancel: closeWidget
|
|
550
|
-
}
|
|
551
|
-
)
|
|
552
|
-
}
|
|
553
|
-
),
|
|
554
|
-
open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
555
|
-
AddWidget_default,
|
|
556
|
-
{
|
|
557
|
-
onAdd: (component, widget2) => addWidget(
|
|
558
|
-
state.widgets,
|
|
559
|
-
Factories_default.widget(component, widget2.defaults)
|
|
560
|
-
),
|
|
561
|
-
onClose: () => setOpen(false)
|
|
562
|
-
}
|
|
563
|
-
)
|
|
564
|
-
] }) });
|
|
565
|
-
};
|
|
566
|
-
var ContentBuilder_default = ContentBuilder;
|
|
7
|
+
var MenuBuilder__default = /*#__PURE__*/_interopDefault(MenuBuilder);
|
|
567
8
|
|
|
568
|
-
// src/MenuBuilder/ColumnBuilder.js
|
|
569
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
570
|
-
var Wrapper = (_a) => {
|
|
571
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
572
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", __spreadValues({ className: (0, import_ui7.cn)("r-reset", className) }, props));
|
|
573
|
-
};
|
|
574
|
-
var ColumnBuilder = ({ value, onChange }) => {
|
|
575
|
-
const [state, setState] = import_react7.default.useState(value);
|
|
576
|
-
(0, import_react7.useEffect)(() => {
|
|
577
|
-
setState(value);
|
|
578
|
-
}, [value]);
|
|
579
|
-
const addColumn = (items, item) => {
|
|
580
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
581
|
-
columns: [...items, item]
|
|
582
|
-
});
|
|
583
|
-
setState(newState);
|
|
584
|
-
onChange(newState);
|
|
585
|
-
};
|
|
586
|
-
const updateColumn = (items, item) => {
|
|
587
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
588
|
-
columns: update(items, item)
|
|
589
|
-
});
|
|
590
|
-
setState(newState);
|
|
591
|
-
onChange(newState);
|
|
592
|
-
};
|
|
593
|
-
const duplicateColumn = (items, item) => {
|
|
594
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
595
|
-
columns: append(items, __spreadProps(__spreadValues({}, item), {
|
|
596
|
-
id: rand(),
|
|
597
|
-
label: `${item.label} (copy)`
|
|
598
|
-
}))
|
|
599
|
-
});
|
|
600
|
-
setState(newState);
|
|
601
|
-
};
|
|
602
|
-
const removeColumn = (items, item) => {
|
|
603
|
-
if (!confirm("Are you sure?")) return;
|
|
604
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
605
|
-
columns: remove(items, item)
|
|
606
|
-
});
|
|
607
|
-
setState(newState);
|
|
608
|
-
onChange(newState);
|
|
609
|
-
};
|
|
610
|
-
const reorder = (columns) => {
|
|
611
|
-
const newState = __spreadProps(__spreadValues({}, state), { columns });
|
|
612
|
-
setState(newState);
|
|
613
|
-
onChange(newState);
|
|
614
|
-
};
|
|
615
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Wrapper, { children: [
|
|
616
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui7.Toolbar, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
617
|
-
import_ui7.Button,
|
|
618
|
-
{
|
|
619
|
-
variant: "secondary",
|
|
620
|
-
onClick: () => addColumn(state.columns, Factories_default.column()),
|
|
621
|
-
children: "Add column"
|
|
622
|
-
}
|
|
623
|
-
) }),
|
|
624
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
625
|
-
import_react_sortablejs3.ReactSortable,
|
|
626
|
-
{
|
|
627
|
-
list: state.columns,
|
|
628
|
-
setList: (columns) => reorder(columns),
|
|
629
|
-
className: "r-list",
|
|
630
|
-
handle: ".r-chandle",
|
|
631
|
-
direction: "vertical",
|
|
632
|
-
children: state.columns.map((column, idx) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui7.Panel, { style: { flex: 1, marginRight: "0.5em" }, children: [
|
|
633
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui7.PanelTitle, { children: [
|
|
634
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui7.Stack, { className: "r-stack-align-center", children: [
|
|
635
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui7.Handle, { className: "r-chandle" }),
|
|
636
|
-
"Column #",
|
|
637
|
-
idx + 1
|
|
638
|
-
] }),
|
|
639
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui7.Stack, { className: "r-stack-align-center", children: [
|
|
640
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
641
|
-
import_ui7.Button,
|
|
642
|
-
{
|
|
643
|
-
variant: "secondary",
|
|
644
|
-
onClick: () => duplicateColumn(state.columns, column),
|
|
645
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, {})
|
|
646
|
-
}
|
|
647
|
-
),
|
|
648
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
649
|
-
import_ui7.Button,
|
|
650
|
-
{
|
|
651
|
-
variant: "secondary",
|
|
652
|
-
onClick: () => removeColumn(state.columns, column),
|
|
653
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Delete, {})
|
|
654
|
-
}
|
|
655
|
-
)
|
|
656
|
-
] })
|
|
657
|
-
] }),
|
|
658
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui7.PanelContent, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
659
|
-
ContentBuilder_default,
|
|
660
|
-
{
|
|
661
|
-
value: column,
|
|
662
|
-
onChange: (column2) => updateColumn(state.columns, column2)
|
|
663
|
-
}
|
|
664
|
-
) })
|
|
665
|
-
] }, column.id))
|
|
666
|
-
}
|
|
667
|
-
)
|
|
668
|
-
] });
|
|
669
|
-
};
|
|
670
|
-
var ColumnBuilder_default = ColumnBuilder;
|
|
671
9
|
|
|
672
|
-
// src/MenuBuilder/RowBuilder.js
|
|
673
|
-
var import_ui8 = require("@raketa-builder/ui");
|
|
674
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
675
|
-
var RowBuilder = ({ value, onChange }) => {
|
|
676
|
-
const [state, setState] = import_react8.default.useState(value);
|
|
677
|
-
(0, import_react8.useEffect)(() => {
|
|
678
|
-
setState(value);
|
|
679
|
-
}, [value]);
|
|
680
|
-
const addRow = (items, item) => {
|
|
681
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
682
|
-
rows: [...items, item]
|
|
683
|
-
});
|
|
684
|
-
setState(newState);
|
|
685
|
-
onChange(newState);
|
|
686
|
-
};
|
|
687
|
-
const updateRow = (items, item) => {
|
|
688
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
689
|
-
rows: update(items, item)
|
|
690
|
-
});
|
|
691
|
-
setState(newState);
|
|
692
|
-
onChange(newState);
|
|
693
|
-
};
|
|
694
|
-
const removeRow = (items, item) => {
|
|
695
|
-
if (!confirm("Are you sure?")) return;
|
|
696
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
697
|
-
rows: remove(items, item)
|
|
698
|
-
});
|
|
699
|
-
setState(newState);
|
|
700
|
-
onChange(newState);
|
|
701
|
-
};
|
|
702
|
-
const reorder = (rows) => {
|
|
703
|
-
const newState = __spreadProps(__spreadValues({}, state), { rows });
|
|
704
|
-
setState(newState);
|
|
705
|
-
onChange(newState);
|
|
706
|
-
};
|
|
707
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react8.default.Fragment, { children: [
|
|
708
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
709
|
-
import_react_sortablejs4.ReactSortable,
|
|
710
|
-
{
|
|
711
|
-
list: state.rows,
|
|
712
|
-
setList: (rows) => reorder(rows),
|
|
713
|
-
handle: ".r-handle",
|
|
714
|
-
direction: "vertical",
|
|
715
|
-
children: state.rows.map((row, idx) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui8.Panel, { children: [
|
|
716
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui8.PanelTitle, { children: [
|
|
717
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_ui8.Stack, { className: "r-stack-align-center", children: [
|
|
718
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui8.Handle, { className: "r-handle" }),
|
|
719
|
-
"Row #",
|
|
720
|
-
idx + 1
|
|
721
|
-
] }),
|
|
722
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
723
|
-
import_ui8.Button,
|
|
724
|
-
{
|
|
725
|
-
variant: "secondary",
|
|
726
|
-
onClick: () => removeRow(state.rows, row),
|
|
727
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Delete, {})
|
|
728
|
-
}
|
|
729
|
-
)
|
|
730
|
-
] }),
|
|
731
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui8.PanelContent, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
732
|
-
ColumnBuilder_default,
|
|
733
|
-
{
|
|
734
|
-
value: row,
|
|
735
|
-
onChange: (row2) => updateRow(state.rows, row2)
|
|
736
|
-
}
|
|
737
|
-
) })
|
|
738
|
-
] }, row.id))
|
|
739
|
-
}
|
|
740
|
-
),
|
|
741
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui8.Toolbar, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
742
|
-
import_ui8.Button,
|
|
743
|
-
{
|
|
744
|
-
variant: "secondary",
|
|
745
|
-
onClick: () => addRow(state.rows, Factories_default.row()),
|
|
746
|
-
children: "Add row"
|
|
747
|
-
}
|
|
748
|
-
) })
|
|
749
|
-
] });
|
|
750
|
-
};
|
|
751
|
-
var RowBuilder_default = RowBuilder;
|
|
752
10
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
var MenuBuilder = ({ widgets, value, onChange }) => {
|
|
757
|
-
const [state, setState] = import_react9.default.useState(value);
|
|
758
|
-
const currentTab = state.tab;
|
|
759
|
-
const currentItem = state.items ? state.items[currentTab] : null;
|
|
760
|
-
const removeItem = (items, item) => {
|
|
761
|
-
if (!confirm("Are you sure?")) return;
|
|
762
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
763
|
-
tab: 0,
|
|
764
|
-
items: remove(items, item)
|
|
765
|
-
});
|
|
766
|
-
setState(newState);
|
|
767
|
-
if (onChange) onChange(newState);
|
|
768
|
-
};
|
|
769
|
-
const updateItem = (items, item) => {
|
|
770
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
771
|
-
items: update(items, item)
|
|
772
|
-
});
|
|
773
|
-
setState(newState);
|
|
774
|
-
if (onChange) onChange(newState);
|
|
775
|
-
};
|
|
776
|
-
const duplicateItem = (items, item) => {
|
|
777
|
-
const newState = __spreadProps(__spreadValues({}, state), {
|
|
778
|
-
items: append(items, __spreadProps(__spreadValues({}, item), {
|
|
779
|
-
id: rand(),
|
|
780
|
-
label: `${item.label} (copy)`
|
|
781
|
-
}))
|
|
782
|
-
});
|
|
783
|
-
setState(newState);
|
|
784
|
-
if (onChange) onChange(newState);
|
|
785
|
-
};
|
|
786
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(WidgetContext_default.Provider, { value: widgets, children: [
|
|
787
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
788
|
-
MainNavigation_default,
|
|
789
|
-
{
|
|
790
|
-
items: state.items,
|
|
791
|
-
tab: currentTab,
|
|
792
|
-
onTab: (tab) => setState(__spreadProps(__spreadValues({}, state), { tab })),
|
|
793
|
-
onChange: (items) => {
|
|
794
|
-
const newState = __spreadProps(__spreadValues({}, state), { items });
|
|
795
|
-
setState(newState);
|
|
796
|
-
if (onChange) onChange(newState);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
),
|
|
800
|
-
currentItem && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
801
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
802
|
-
ItemForm_default,
|
|
803
|
-
{
|
|
804
|
-
item: currentItem,
|
|
805
|
-
onChange: (item) => {
|
|
806
|
-
updateItem(state.items, __spreadValues(__spreadValues({}, currentItem), item));
|
|
807
|
-
},
|
|
808
|
-
onRemove: () => removeItem(state.items, currentItem),
|
|
809
|
-
onDuplicate: () => duplicateItem(state.items, currentItem)
|
|
810
|
-
}
|
|
811
|
-
),
|
|
812
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui9.H, { as: "h4", size: "large", children: "Menu content" }),
|
|
813
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
814
|
-
RowBuilder_default,
|
|
815
|
-
{
|
|
816
|
-
value: currentItem,
|
|
817
|
-
onChange: (item) => updateItem(state.items, __spreadValues(__spreadValues({}, currentItem), item))
|
|
818
|
-
}
|
|
819
|
-
)
|
|
820
|
-
] })
|
|
821
|
-
] });
|
|
822
|
-
};
|
|
823
|
-
var MenuBuilder_default = MenuBuilder;
|
|
824
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
825
|
-
0 && (module.exports = {
|
|
826
|
-
MenuBuilder
|
|
11
|
+
Object.defineProperty(exports, "MenuBuilder", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return MenuBuilder__default.default; }
|
|
827
14
|
});
|