@raketa-builder/menu-builder 0.1.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/dist/index.js ADDED
@@ -0,0 +1,1663 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __commonJS = (cb, mod) => function __require() {
26
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
27
+ };
28
+ var __export = (target, all) => {
29
+ for (var name in all)
30
+ __defProp(target, name, { get: all[name], enumerable: true });
31
+ };
32
+ var __copyProps = (to, from, except, desc) => {
33
+ if (from && typeof from === "object" || typeof from === "function") {
34
+ for (let key of __getOwnPropNames(from))
35
+ if (!__hasOwnProp.call(to, key) && key !== except)
36
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
37
+ }
38
+ return to;
39
+ };
40
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
41
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
42
+ mod
43
+ ));
44
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
45
+
46
+ // ../ui/dist/index.js
47
+ var require_dist = __commonJS({
48
+ "../ui/dist/index.js"(exports, module2) {
49
+ "use strict";
50
+ var __create2 = Object.create;
51
+ var __defProp2 = Object.defineProperty;
52
+ var __defProps2 = Object.defineProperties;
53
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
54
+ var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
55
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
56
+ var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
57
+ var __getProtoOf2 = Object.getPrototypeOf;
58
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
59
+ var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
60
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
61
+ var __spreadValues2 = (a, b) => {
62
+ for (var prop in b || (b = {}))
63
+ if (__hasOwnProp2.call(b, prop))
64
+ __defNormalProp2(a, prop, b[prop]);
65
+ if (__getOwnPropSymbols2)
66
+ for (var prop of __getOwnPropSymbols2(b)) {
67
+ if (__propIsEnum2.call(b, prop))
68
+ __defNormalProp2(a, prop, b[prop]);
69
+ }
70
+ return a;
71
+ };
72
+ var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
73
+ var __objRest = (source, exclude) => {
74
+ var target = {};
75
+ for (var prop in source)
76
+ if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
77
+ target[prop] = source[prop];
78
+ if (source != null && __getOwnPropSymbols2)
79
+ for (var prop of __getOwnPropSymbols2(source)) {
80
+ if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop))
81
+ target[prop] = source[prop];
82
+ }
83
+ return target;
84
+ };
85
+ var __export2 = (target, all) => {
86
+ for (var name in all)
87
+ __defProp2(target, name, { get: all[name], enumerable: true });
88
+ };
89
+ var __copyProps2 = (to, from, except, desc) => {
90
+ if (from && typeof from === "object" || typeof from === "function") {
91
+ for (let key of __getOwnPropNames2(from))
92
+ if (!__hasOwnProp2.call(to, key) && key !== except)
93
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
94
+ }
95
+ return to;
96
+ };
97
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
98
+ isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
99
+ mod
100
+ ));
101
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
102
+ var src_exports2 = {};
103
+ __export2(src_exports2, {
104
+ Button: () => Button_default,
105
+ Col: () => Col,
106
+ Container: () => Container_default,
107
+ DataGrid: () => DataGrid_default,
108
+ Field: () => Field_default,
109
+ FormGroup: () => FormGroup_default,
110
+ H: () => H_default,
111
+ Handle: () => Handle_default,
112
+ Hint: () => Hint_default,
113
+ Input: () => Input_default,
114
+ Label: () => Label_default,
115
+ LanguageSwitcher: () => LanguageSwitcher_default,
116
+ Modal: () => Modal_default,
117
+ NavItem: () => NavItem,
118
+ Navigation: () => Navigation,
119
+ P: () => P_default,
120
+ PageTitle: () => PageTitle_default,
121
+ Pagination: () => Pagination_default,
122
+ Panel: () => Panel4,
123
+ PanelContent: () => PanelContent3,
124
+ PanelTitle: () => PanelTitle4,
125
+ Row: () => Row,
126
+ Select: () => Select_default,
127
+ Shift: () => Shift,
128
+ Stack: () => Stack_default,
129
+ Tabs: () => Tabs_default,
130
+ Textarea: () => Textarea_default,
131
+ Toolbar: () => Toolbar_default,
132
+ buttonReset: () => buttonReset_default,
133
+ reset: () => reset_default,
134
+ theme: () => theme_default
135
+ });
136
+ module2.exports = __toCommonJS2(src_exports2);
137
+ var base = 14;
138
+ var fraction = 1.25;
139
+ var small = base / fraction;
140
+ var tiny = small / fraction;
141
+ var medium = base * fraction;
142
+ var large = medium * fraction;
143
+ var xlarge = large * fraction;
144
+ var xxlarge = xlarge * fraction;
145
+ var huge = xxlarge * fraction;
146
+ var theme = {
147
+ font: {
148
+ tiny: `${tiny}px`,
149
+ small: `${small}px`,
150
+ base: `${base}px`,
151
+ medium: `${medium}px`,
152
+ large: `${large}px`,
153
+ xlarge: `${xlarge}px`,
154
+ xxlarge: `${xxlarge}px`,
155
+ huge: `${huge}px`,
156
+ line: 1.5
157
+ },
158
+ colors: {
159
+ trueBlack: "#000",
160
+ black: "#2C2C2C",
161
+ darkerGray: "#4B4B4B",
162
+ darkGray: "#6E6E6E",
163
+ gray: "#B3B3B3",
164
+ lightGray: "#E1E1E1",
165
+ lighterGray: "#F5F5F5",
166
+ white: "#FAFAFA",
167
+ trueWhite: "#fff",
168
+ primaryDarker: "#095aba",
169
+ primaryDark: "#0d66d0",
170
+ primary: "#1473e6",
171
+ primaryRGB06: "rgba(20, 115, 230, 0.6)",
172
+ primaryLight: "#2680eb",
173
+ successDarker: "#107154",
174
+ successDark: "#12805c",
175
+ success: "#268e6c",
176
+ successLight: "#2d9d78",
177
+ dangerDarker: "#bb121a",
178
+ dangerDark: "#c9252d",
179
+ danger: "#d7373f",
180
+ dangerLight: "#e34850"
181
+ }
182
+ };
183
+ var theme_default = theme;
184
+ var import_styled_components5 = require("styled-components");
185
+ var reset2 = import_styled_components5.css`
186
+ box-sizing: border-box;
187
+ color: ${theme_default.colors.black};
188
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
189
+ Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
190
+ font-size: ${theme_default.font.base};
191
+ line-height: ${theme_default.font.line};
192
+ `;
193
+ var reset_default = reset2;
194
+ var import_styled_components22 = require("styled-components");
195
+ var buttonReset3 = import_styled_components22.css`
196
+ ${reset_default};
197
+ background: none;
198
+ border: 0;
199
+ outline: 0;
200
+ cursor: pointer;
201
+ `;
202
+ var buttonReset_default = buttonReset3;
203
+ var import_styled_components32 = __toESM2(require("styled-components"));
204
+ var H_default = import_styled_components32.default.div`
205
+ ${reset_default};
206
+ margin: 0;
207
+ padding: 0;
208
+ font-size: ${(props) => props.theme.font[props.size]};
209
+ padding-bottom: 0.5em;
210
+ `;
211
+ var import_styled_components42 = __toESM2(require("styled-components"));
212
+ var P_default = import_styled_components42.default.p`
213
+ ${reset_default};
214
+ margin: 0;
215
+ padding: 0;
216
+ padding-bottom: 1em;
217
+ `;
218
+ var import_styled_components52 = __toESM2(require("styled-components"));
219
+ var variants = {
220
+ primary: {
221
+ border: "primary",
222
+ background: "primary",
223
+ color: "white",
224
+ hoverBorder: "primaryDark",
225
+ hoverBackground: "primaryDark",
226
+ hoverColor: "white",
227
+ activeBorder: "primaryDarker",
228
+ activeBackground: "primaryDarker",
229
+ activeColor: "white"
230
+ },
231
+ secondary: {
232
+ border: "darkerGray",
233
+ background: "white",
234
+ color: "darkerGray",
235
+ hoverBorder: "darkGray",
236
+ hoverBackground: "darkGray",
237
+ hoverColor: "white",
238
+ activeBorder: "darkerGray",
239
+ activeBackground: "darkerGray",
240
+ activeColor: "white"
241
+ },
242
+ success: {
243
+ border: "success",
244
+ background: "success",
245
+ color: "white",
246
+ hoverBorder: "successDark",
247
+ hoverBackground: "successDark",
248
+ hoverColor: "white",
249
+ activeBorder: "successDarker",
250
+ activeBackground: "successDarker",
251
+ activeColor: "white"
252
+ },
253
+ danger: {
254
+ border: "danger",
255
+ background: "danger",
256
+ color: "white",
257
+ hoverBorder: "dangerDark",
258
+ hoverBackground: "dangerDark",
259
+ hoverColor: "white",
260
+ activeBorder: "dangerDarker",
261
+ activeBackground: "dangerDarker",
262
+ activeColor: "white"
263
+ }
264
+ };
265
+ var getColor = (props, variant, key) => props.theme.colors[variants[variant][key]];
266
+ var Button7 = import_styled_components52.default.button`
267
+ ${buttonReset_default};
268
+ padding: 0.5em 1em;
269
+ margin-right: 0.25em;
270
+ border: 2px solid ${(props) => getColor(props, props.variant, "border")};
271
+ border-radius: 48px;
272
+ background-color: ${(props) => getColor(props, props.variant, "background")};
273
+ color: ${(props) => getColor(props, props.variant, "color")};
274
+ font-size: ${(props) => Button7.sizes[props.size]};
275
+ font-weight: 700;
276
+ line-height: 1;
277
+ transition: 0.2s ease-in-out all;
278
+
279
+ &:focus {
280
+ border-color: ${(props) => getColor(props, props.variant, "activeBorder")};
281
+ }
282
+
283
+ &:hover {
284
+ border-color: ${(props) => getColor(props, props.variant, "hoverBorder")};
285
+ background-color: ${(props) => getColor(props, props.variant, "hoverBackground")};
286
+ color: ${(props) => getColor(props, props.variant, "hoverColor")};
287
+ }
288
+
289
+ &:active {
290
+ border-color: ${(props) => getColor(props, props.variant, "activeBorder")};
291
+ background-color: ${(props) => getColor(props, props.variant, "activeBackground")};
292
+ color: ${(props) => getColor(props, props.variant, "activeColor")};
293
+ }
294
+
295
+ &:last-of-type {
296
+ margin-right: 0;
297
+ }
298
+ `;
299
+ Button7.defaultProps = {
300
+ type: "button",
301
+ size: "md",
302
+ variant: "primary"
303
+ };
304
+ Button7.variants = ["primary", "secondary", "success", "danger"];
305
+ Button7.sizes = {
306
+ sm: theme_default.font.small,
307
+ md: theme_default.font.base,
308
+ lg: theme_default.font.medium
309
+ };
310
+ var Button_default = Button7;
311
+ var import_react10 = __toESM2(require("react"));
312
+ var import_styled_components6 = __toESM2(require("styled-components"));
313
+ var import_jsx_runtime9 = require("react/jsx-runtime");
314
+ var TabsWrapper = import_styled_components6.default.div`
315
+ ${reset_default};
316
+ display: inline-flex;
317
+ margin-bottom: 1em;
318
+ border-bottom: 3px solid ${(props) => props.theme.colors.lightGray};
319
+ `;
320
+ var Tab = import_styled_components6.default.button`
321
+ ${buttonReset_default};
322
+ position: relative;
323
+ top: 3px;
324
+ margin-right: 2em;
325
+ padding: 0 0 0.5em 0;
326
+ border-bottom: 3px solid
327
+ ${(props) => props.active ? props.theme.colors.black : "transparent"};
328
+ color: ${(props) => props.active ? props.theme.colors.black : props.theme.colors.darkGray};
329
+ font-weight: 500;
330
+
331
+ &:hover {
332
+ border-color: ${(props) => props.theme.colors.black};
333
+ }
334
+
335
+ &:last-of-type {
336
+ margin-right: 4em;
337
+ }
338
+ `;
339
+ var Tabs = ({ initial = 0, children }) => {
340
+ const [current, setCurrent] = import_react10.default.useState(initial);
341
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_react10.default.Fragment, { children: [
342
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TabsWrapper, { children: children.map((child, idx) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
343
+ Tab,
344
+ {
345
+ type: "button",
346
+ active: idx === current,
347
+ onClick: () => setCurrent(idx),
348
+ children: child.props.title
349
+ },
350
+ idx
351
+ )) }),
352
+ children[current]
353
+ ] });
354
+ };
355
+ var Tabs_default = Tabs;
356
+ var import_styled_components7 = __toESM2(require("styled-components"));
357
+ var Input_default = import_styled_components7.default.input`
358
+ ${reset_default};
359
+ border: 0;
360
+ outline: 0;
361
+ border-radius: 4px;
362
+ border: 0;
363
+ width: 100%;
364
+ padding: 0.5em 0.75em;
365
+ border: 1px solid ${(props) => props.theme.colors.gray};
366
+ background-color: ${(props) => props.theme.colors.trueWhite};
367
+ transition: all 0.2s ease-in-out;
368
+
369
+ &:hover {
370
+ border-color: ${(props) => props.theme.colors.darkGray};
371
+ }
372
+
373
+ &:focus {
374
+ border-color: ${(props) => props.theme.colors.primary};
375
+ }
376
+ `;
377
+ var import_styled_components8 = __toESM2(require("styled-components"));
378
+ var Textarea_default = import_styled_components8.default.textarea`
379
+ ${reset_default};
380
+ border: 0;
381
+ outline: 0;
382
+ border-radius: 4px;
383
+ border: 0;
384
+ width: 100%;
385
+ height: 100px;
386
+ padding: 0.5em 0.75em;
387
+ border: 1px solid ${(props) => props.theme.colors.gray};
388
+ background-color: ${(props) => props.theme.colors.trueWhite};
389
+ transition: all 0.2s ease-in-out;
390
+
391
+ &:hover {
392
+ border-color: ${(props) => props.theme.colors.darkGray};
393
+ }
394
+
395
+ &:focus {
396
+ border-color: ${(props) => props.theme.colors.primary};
397
+ }
398
+ `;
399
+ var import_styled_components9 = __toESM2(require("styled-components"));
400
+ var Select_default = import_styled_components9.default.select`
401
+ ${reset_default};
402
+ -webkit-appearance: none;
403
+ -moz-appearance: none;
404
+ border: 0;
405
+ outline: 0;
406
+ border-radius: 4px;
407
+ border: 0;
408
+ width: 100%;
409
+ padding: 0.5em 0.75em;
410
+ border: 1px solid ${(props) => props.theme.colors.gray};
411
+ background-size: 16px;
412
+ background-repeat: no-repeat;
413
+ background-position: center right 0.25em;
414
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLWNoZXZyb24tZG93biI+PHBvbHlsaW5lIHBvaW50cz0iNiA5IDEyIDE1IDE4IDkiPjwvcG9seWxpbmU+PC9zdmc+);
415
+ background-color: ${(props) => props.theme.colors.trueWhite};
416
+ transition: all 0.2s ease-in-out;
417
+
418
+ &:hover {
419
+ border-color: ${(props) => props.theme.colors.darkGray};
420
+ }
421
+
422
+ &:focus {
423
+ border-color: ${(props) => props.theme.colors.primary};
424
+ }
425
+ `;
426
+ var import_styled_components10 = __toESM2(require("styled-components"));
427
+ var FormGroup_default = import_styled_components10.default.div`
428
+ ${reset_default};
429
+ width: 100%;
430
+ margin-bottom: 1em;
431
+ `;
432
+ var import_styled_components11 = __toESM2(require("styled-components"));
433
+ var Label_default = import_styled_components11.default.label`
434
+ ${reset_default};
435
+ display: block;
436
+ margin-bottom: 0.25em;
437
+ color: ${(props) => props.theme.colors.darkerGray};
438
+ font-size: ${(props) => props.theme.font.small};
439
+ font-weight: 600;
440
+ cursor: pointer;
441
+ `;
442
+ var import_react22 = __toESM2(require("react"));
443
+ var import_styled_components12 = __toESM2(require("styled-components"));
444
+ var Hint = import_styled_components12.default.div`
445
+ ${reset_default};
446
+
447
+ font-size: ${(props) => props.theme.font.small};
448
+ opacity: 0.7;
449
+ color: ${(props) => props.type === "error" && props.theme.colors.danger};
450
+ `;
451
+ var Hint_default = Hint;
452
+ var import_jsx_runtime22 = require("react/jsx-runtime");
453
+ var Field = (_a) => {
454
+ var _b = _a, {
455
+ as = "input",
456
+ r,
457
+ name,
458
+ label,
459
+ hint = "",
460
+ error = "",
461
+ wrapperProps
462
+ } = _b, props = __objRest(_b, [
463
+ "as",
464
+ "r",
465
+ "name",
466
+ "label",
467
+ "hint",
468
+ "error",
469
+ "wrapperProps"
470
+ ]);
471
+ const types = {
472
+ input: Input_default,
473
+ select: Select_default,
474
+ textarea: Textarea_default
475
+ };
476
+ const Component = types[as];
477
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(FormGroup_default, __spreadProps2(__spreadValues2({}, wrapperProps), { children: [
478
+ label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Label_default, { htmlFor: name, children: label }),
479
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Component, __spreadValues2({ ref: r, id: name, name }, props)),
480
+ hint && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Hint_default, { children: hint }),
481
+ error && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Hint_default, { type: "error", children: error })
482
+ ] }));
483
+ };
484
+ var Field_default = Field;
485
+ var import_styled_components13 = __toESM2(require("styled-components"));
486
+ var Toolbar_default = import_styled_components13.default.div`
487
+ ${reset_default};
488
+
489
+ display: flex;
490
+ align-items: center;
491
+ gap: 0.5em;
492
+ margin-bottom: ${(props) => props.mb || 0};
493
+ `;
494
+ var import_styled_components14 = __toESM2(require("styled-components"));
495
+ var Stack_default = import_styled_components14.default.div`
496
+ display: flex;
497
+ justify-content: ${(props) => props.h};
498
+ align-items: ${(props) => props.v};
499
+ gap: ${(props) => props.g};
500
+ `;
501
+ var import_styled_components15 = __toESM2(require("styled-components"));
502
+ var Container_default = import_styled_components15.default.div`
503
+ ${reset_default};
504
+ width: 100%;
505
+ padding: 0 calc(1em / 2);
506
+
507
+ padding-top: ${(props) => props.top && "1em"};
508
+ padding-bottom: ${(props) => props.bottom && "1em"};
509
+
510
+ @media (min-width: 1184px) {
511
+ width: 98%;
512
+ margin: 0 auto;
513
+ }
514
+ `;
515
+ var import_styled_components16 = __toESM2(require("styled-components"));
516
+ var Panel4 = import_styled_components16.default.div`
517
+ ${reset_default};
518
+ margin-bottom: 0.5em;
519
+ border: 1px solid #ddd;
520
+ border-radius: 3px;
521
+ background-color: #fff;
522
+
523
+ &.sortable-selected {
524
+ background-color: #0a0a;
525
+ }
526
+ `;
527
+ var PanelTitle4 = import_styled_components16.default.div`
528
+ ${reset_default};
529
+ display: flex;
530
+ justify-content: space-between;
531
+ align-items: center;
532
+ padding: 0.25em 0.25em 0.25em;
533
+ border-bottom: 1px solid #ddd;
534
+ background-color: ${(props) => props.theme.colors.lighterGray};
535
+ font-weight: 700;
536
+ `;
537
+ var PanelContent3 = import_styled_components16.default.div`
538
+ padding: 1em;
539
+ `;
540
+ var import_styled_components17 = __toESM2(require("styled-components"));
541
+ var Handle_default = import_styled_components17.default.div`
542
+ width: 2em;
543
+ height: 2em;
544
+ background-size: 50%;
545
+ background-repeat: no-repeat;
546
+ background-position: center;
547
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLW1vcmUtdmVydGljYWwiPjxjaXJjbGUgY3g9IjEyIiBjeT0iMTIiIHI9IjEiPjwvY2lyY2xlPjxjaXJjbGUgY3g9IjEyIiBjeT0iNSIgcj0iMSI+PC9jaXJjbGU+PGNpcmNsZSBjeD0iMTIiIGN5PSIxOSIgcj0iMSI+PC9jaXJjbGU+PC9zdmc+);
548
+ cursor: grabbing;
549
+ filter: invert(${(props) => props.active ? 1 : 0});
550
+ `;
551
+ var import_react32 = __toESM2(require("react"));
552
+ var import_styled_components18 = __toESM2(require("styled-components"));
553
+ var import_jsx_runtime32 = require("react/jsx-runtime");
554
+ var Overlay = import_styled_components18.default.div`
555
+ ${reset_default};
556
+ position: fixed;
557
+ top: 0;
558
+ right: 0;
559
+ bottom: 0;
560
+ left: 0;
561
+ z-index: 11;
562
+ background-color: rgba(0, 0, 0, 0.6);
563
+ cursor: pointer;
564
+ `;
565
+ var Wrapper2 = import_styled_components18.default.div`
566
+ ${reset_default};
567
+ position: fixed;
568
+ top: 0;
569
+ right: 0;
570
+ bottom: 0;
571
+ left: 0;
572
+ z-index: 12;
573
+ display: flex;
574
+ justify-content: center;
575
+ align-items: center;
576
+ pointer-events: none;
577
+ `;
578
+ var Inner = import_styled_components18.default.div`
579
+ ${reset_default};
580
+ width: 80%;
581
+ border-radius: 5px;
582
+ background-color: ${(props) => props.theme.colors.lighterGray};
583
+ box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
584
+ pointer-events: all;
585
+ `;
586
+ var TitleBar = import_styled_components18.default.div`
587
+ ${reset_default};
588
+ display: flex;
589
+ justify-content: space-between;
590
+ align-items: center;
591
+ padding: 1em;
592
+ border-bottom: 2px solid ${(props) => props.theme.colors.lightGray};
593
+ `;
594
+ var Title = import_styled_components18.default.div`
595
+ ${reset_default};
596
+ font-size: 1.25em;
597
+ font-weight: 500;
598
+ `;
599
+ var CloseButton = import_styled_components18.default.button`
600
+ ${buttonReset_default};
601
+ position: relative;
602
+ right: -4px;
603
+ z-index: 13;
604
+ width: 2em;
605
+ height: 2em;
606
+ margin: 0;
607
+ padding: 0;
608
+ background-repeat: no-repeat;
609
+ background-size: 80%;
610
+ background-position: center;
611
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXgiPjxsaW5lIHgxPSIxOCIgeTE9IjYiIHgyPSI2IiB5Mj0iMTgiPjwvbGluZT48bGluZSB4MT0iNiIgeTE9IjYiIHgyPSIxOCIgeTI9IjE4Ij48L2xpbmU+PC9zdmc+);
612
+ font-size: 1em;
613
+ overflow: hidden;
614
+ text-indent: -9999px;
615
+ `;
616
+ var Content = import_styled_components18.default.div`
617
+ ${reset_default};
618
+ padding: 0.5em 1em 1em 1em;
619
+ `;
620
+ var Modal3 = ({ title, children, onClose }) => {
621
+ const handleKeyUp = ({ key }) => {
622
+ if (key === "Escape")
623
+ onClose();
624
+ };
625
+ import_react32.default.useEffect(() => {
626
+ document.addEventListener("keyup", handleKeyUp);
627
+ return () => {
628
+ document.removeEventListener("keyup", handleKeyUp);
629
+ };
630
+ });
631
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_react32.default.Fragment, { children: [
632
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Overlay, { onClick: onClose }),
633
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper2, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Inner, { children: [
634
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(TitleBar, { children: [
635
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Title, { children: title }),
636
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(CloseButton, { type: "button", onClick: onClose, children: "\xD7" })
637
+ ] }),
638
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Content, { children })
639
+ ] }) })
640
+ ] });
641
+ };
642
+ var Modal_default = Modal3;
643
+ var import_react42 = __toESM2(require("react"));
644
+ var import_styled_components19 = __toESM2(require("styled-components"));
645
+ var import_jsx_runtime42 = require("react/jsx-runtime");
646
+ var Wrapper22 = import_styled_components19.default.div`
647
+ ${reset_default}
648
+
649
+ table {
650
+ border-collapse: collapse;
651
+ width: 100%;
652
+ margin-bottom: 1em;
653
+
654
+ th,
655
+ td {
656
+ padding: 0.5em;
657
+ text-align: left;
658
+ }
659
+
660
+ tr {
661
+ border-bottom: 1px solid ${(props) => props.theme.colors.lightGray};
662
+ transition: all 0.3s ease-in-out;
663
+ }
664
+
665
+ a {
666
+ color: ${(props) => props.theme.colors.primary};
667
+ }
668
+
669
+ tbody {
670
+ tr {
671
+ &:hover {
672
+ border-color: ${(props) => props.theme.colors.gray};
673
+
674
+ td {
675
+ background-color: ${(props) => props.theme.colors.lighterGray};
676
+ }
677
+ }
678
+ }
679
+ }
680
+
681
+ .actions {
682
+ width: 50px;
683
+ white-space: nowrap;
684
+
685
+ div:first-of-type {
686
+ display: flex;
687
+ align-items: center;
688
+ }
689
+
690
+ a,
691
+ button {
692
+ margin-left: 0.5em;
693
+ }
694
+ }
695
+ }
696
+ `;
697
+ var DataGrid = ({ list, header, row }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Wrapper22, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("table", { children: [
698
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("tr", { children: header() }) }),
699
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("tbody", { children: list.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("tr", { children: row(item) }, item.id || idx)) })
700
+ ] }) });
701
+ var DataGrid_default = DataGrid;
702
+ var import_styled_components20 = __toESM2(require("styled-components"));
703
+ var Row = import_styled_components20.default.div`
704
+ ${reset_default};
705
+
706
+ @media (min-width: 1184px) {
707
+ display: grid;
708
+ grid-template-columns: repeat(12, 1fr);
709
+ grid-column-gap: ${(props) => props.gutter || "1em"};
710
+ grid-row-gap: ${(props) => props.gutter || "1em"};
711
+ margin: 0;
712
+ }
713
+ `;
714
+ var Col = import_styled_components20.default.div`
715
+ ${reset_default};
716
+
717
+ grid-column: span ${(props) => props.s || 12};
718
+ `;
719
+ var getShift = (s) => {
720
+ const SHIFTS = {
721
+ 1: "2 / span 10",
722
+ 2: "3 / span 8",
723
+ 3: "4 / span 6"
724
+ };
725
+ return SHIFTS[s];
726
+ };
727
+ var Shift = import_styled_components20.default.div`
728
+ ${reset_default};
729
+
730
+ grid-column: ${(props) => getShift(props.s)};
731
+ `;
732
+ var import_styled_components21 = __toESM2(require("styled-components"));
733
+ var Navigation = import_styled_components21.default.div`
734
+ ${reset_default};
735
+
736
+ position: fixed;
737
+ top: 0;
738
+ bottom: 0;
739
+ left: 0;
740
+ display: flex;
741
+ gap: 8px;
742
+ flex-direction: column;
743
+ align-items: center;
744
+ width: 64px;
745
+ padding: 8px 0;
746
+ background-color: ${(props) => props.theme.colors.black};
747
+ `;
748
+ var NavItem = import_styled_components21.default.div`
749
+ ${reset_default};
750
+
751
+ width: 48px;
752
+ height: 48px;
753
+ border-radius: 4px;
754
+ background-color: ${(props) => props.active ? props.theme.colors.darkerGray : "transparent"};
755
+ transition: all 0.2s ease-in-out;
756
+
757
+ &:hover {
758
+ background-color: ${(props) => props.theme.colors.darkerGray};
759
+ }
760
+
761
+ a,
762
+ button {
763
+ display: flex;
764
+ justify-content: center;
765
+ align-items: center;
766
+ width: 100%;
767
+ height: 100%;
768
+ }
769
+ `;
770
+ var import_react52 = __toESM2(require("react"));
771
+ var import_styled_components222 = __toESM2(require("styled-components"));
772
+ var import_jsx_runtime52 = require("react/jsx-runtime");
773
+ var Wrapper3 = import_styled_components222.default.div`
774
+ ${reset_default};
775
+
776
+ margin: 1em 0;
777
+ `;
778
+ var PageTitle = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Wrapper3, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
779
+ H_default,
780
+ {
781
+ as: "h1",
782
+ size: "xlarge",
783
+ style: { fontFamily: "sans-serif", fontWeight: 700 },
784
+ children
785
+ }
786
+ ) });
787
+ var PageTitle_default = PageTitle;
788
+ var import_react62 = __toESM2(require("react"));
789
+ var import_styled_components23 = __toESM2(require("styled-components"));
790
+ var import_jsx_runtime62 = require("react/jsx-runtime");
791
+ var Wrapper4 = import_styled_components23.default.div`
792
+ ${reset_default}
793
+
794
+ display: flex;
795
+ justify-content: center;
796
+ flex-wrap: wrap;
797
+ gap: 0.25em;
798
+ padding: 1em 0 1em 0;
799
+
800
+ a,
801
+ span {
802
+ display: block;
803
+ min-width: 1.25em;
804
+ padding: 0.5em 0.75em;
805
+ font-weight: 500;
806
+ text-align: center;
807
+ }
808
+
809
+ a {
810
+ color: ${(props) => props.theme.colors.primary};
811
+ border: 1px solid ${(props) => props.theme.colors.lightGray};
812
+ border-radius: 4px;
813
+ transition: all 0.2s ease-in-out;
814
+
815
+ &:hover {
816
+ border-color: ${(props) => props.theme.colors.primary};
817
+ background-color: ${(props) => props.theme.colors.primary};
818
+ color: ${(props) => props.theme.colors.white};
819
+ }
820
+ }
821
+ `;
822
+ var Prev = ({ LinkComponent, router, currentPage }) => {
823
+ if (currentPage === 1) {
824
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: "Previous" });
825
+ }
826
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
827
+ LinkComponent,
828
+ {
829
+ href: {
830
+ pathname: router.pathname,
831
+ query: __spreadValues2(__spreadValues2({}, router.query), { page: currentPage - 1 })
832
+ },
833
+ children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("a", { children: "Previous" })
834
+ }
835
+ );
836
+ };
837
+ var Next = ({ currentPage, pagesCount, LinkComponent, router }) => {
838
+ if (currentPage === pagesCount) {
839
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: "Next" });
840
+ }
841
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
842
+ LinkComponent,
843
+ {
844
+ href: {
845
+ pathname: router.pathname,
846
+ query: __spreadValues2(__spreadValues2({}, router.query), { page: currentPage + 1 })
847
+ },
848
+ children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("a", { children: "Next" })
849
+ }
850
+ );
851
+ };
852
+ var Pagination = ({ pagination, LinkComponent, router }) => {
853
+ const { currentPage, pagesCount } = pagination;
854
+ const pages = Array(pagesCount).fill(1);
855
+ if (pagesCount <= 1 || router === null) {
856
+ return "";
857
+ }
858
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Wrapper4, { children: [
859
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
860
+ Prev,
861
+ {
862
+ LinkComponent,
863
+ router,
864
+ currentPage
865
+ }
866
+ ),
867
+ pages.map((_, idx) => {
868
+ const pageNum = idx + 1;
869
+ if (pageNum === currentPage) {
870
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: pageNum }, pageNum);
871
+ } else {
872
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
873
+ LinkComponent,
874
+ {
875
+ href: {
876
+ pathname: router.pathname,
877
+ query: __spreadValues2(__spreadValues2({}, router.query), { page: pageNum })
878
+ },
879
+ children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("a", { children: pageNum })
880
+ },
881
+ pageNum
882
+ );
883
+ }
884
+ }),
885
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
886
+ Next,
887
+ {
888
+ LinkComponent,
889
+ router,
890
+ currentPage,
891
+ pagesCount
892
+ }
893
+ )
894
+ ] });
895
+ };
896
+ var Pagination_default = Pagination;
897
+ var import_react72 = __toESM2(require("react"));
898
+ var import_styled_components24 = __toESM2(require("styled-components"));
899
+ var import_jsx_runtime72 = require("react/jsx-runtime");
900
+ var LanguageSwitcherWrapper = import_styled_components24.default.div`
901
+ ${reset_default};
902
+ position: relative;
903
+ display: flex;
904
+ flex-wrap: nowrap;
905
+ width: 100%;
906
+ height: 100%;
907
+ color: #fff;
908
+
909
+ &:hover {
910
+ [data-switcher] {
911
+ left: 48px;
912
+ opacity: 1;
913
+ }
914
+ }
915
+ `;
916
+ var LanguageSwitcherMenu = import_styled_components24.default.div`
917
+ ${reset_default};
918
+ position: absolute;
919
+ z-index: 9;
920
+ left: -1000px;
921
+ display: flex;
922
+ flex-wrap: nowrap;
923
+ height: 100%;
924
+ background-color: ${(props) => props.theme.colors.trueBlack};
925
+ opacity: 0;
926
+ transition: all ease-in-out 0.3s;
927
+ `;
928
+ var LanguageSwitcherItem = import_styled_components24.default.div`
929
+ ${reset_default};
930
+ display: flex;
931
+ justify-content: center;
932
+ align-items: center;
933
+ width: 48px;
934
+ height: 48px;
935
+ background-color: ${(props) => props.theme.colors.trueBlack};
936
+ text-transform: uppercase;
937
+
938
+ a {
939
+ color: ${(props) => props.theme.colors.trueWhite};
940
+ font-weight: 500;
941
+ text-decoration: none;
942
+
943
+ :hover {
944
+ background-color: ${(props) => props.theme.colors.primaryRGB06};
945
+ }
946
+ }
947
+ `;
948
+ var LanguageSwitcherNewItem = import_styled_components24.default.div`
949
+ ${reset_default};
950
+ position: relative;
951
+ width: 48px;
952
+ height: 48px;
953
+ background-color: ${(props) => props.theme.colors.trueBlack};
954
+ text-transform: uppercase;
955
+
956
+ span {
957
+ display: flex;
958
+ justify-content: center;
959
+ align-items: center;
960
+ width: 100%;
961
+ height: 100%;
962
+ opacity: 0.6;
963
+
964
+ color: ${(props) => props.theme.colors.trueWhite};
965
+ font-weight: 500;
966
+ text-decoration: none;
967
+ }
968
+
969
+ a {
970
+ position: absolute;
971
+ top: 0;
972
+ bottom: 0;
973
+ left: 0;
974
+ right: 0;
975
+ z-index: 3;
976
+
977
+ color: ${(props) => props.theme.colors.trueWhite};
978
+ font-weight: 700;
979
+ text-decoration: none;
980
+
981
+ :hover {
982
+ background-color: ${(props) => props.theme.colors.primaryRGB06};
983
+ }
984
+ }
985
+ `;
986
+ var LanguageSwitcherCurrent = import_styled_components24.default.div`
987
+ ${reset_default};
988
+ position: relative;
989
+ z-index: 10;
990
+ display: flex;
991
+ justify-content: center;
992
+ align-items: center;
993
+ width: 100%;
994
+ height: 100%;
995
+ border-radius: 4px;
996
+ background-color: ${(props) => props.theme.colors.primary};
997
+ text-transform: uppercase;
998
+ cursor: pointer;
999
+ `;
1000
+ var LanguageSwitcherItemComponent = ({ path, label }) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(LanguageSwitcherItem, { children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("a", { href: path, children: label }) });
1001
+ var LanguageSwitcherNewItemComponent = ({ path, label }) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(LanguageSwitcherNewItem, { children: [
1002
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { children: label }),
1003
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("a", { href: path, children: "+" })
1004
+ ] });
1005
+ var LanguageSwitcher = ({ current, navigation }) => {
1006
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(LanguageSwitcherWrapper, { children: [
1007
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(LanguageSwitcherCurrent, { children: current }),
1008
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(LanguageSwitcherMenu, { "data-switcher": true, children: navigation.map((navItem, idx) => {
1009
+ const LinkComponent = navItem.newItem ? LanguageSwitcherNewItemComponent : LanguageSwitcherItemComponent;
1010
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
1011
+ LinkComponent,
1012
+ {
1013
+ path: navItem.path,
1014
+ label: navItem.label
1015
+ },
1016
+ idx
1017
+ );
1018
+ }) })
1019
+ ] });
1020
+ };
1021
+ var LanguageSwitcher_default = LanguageSwitcher;
1022
+ }
1023
+ });
1024
+
1025
+ // src/index.js
1026
+ var src_exports = {};
1027
+ __export(src_exports, {
1028
+ MenuBuilder: () => MenuBuilder_default
1029
+ });
1030
+ module.exports = __toCommonJS(src_exports);
1031
+
1032
+ // src/MenuBuilder/index.js
1033
+ var import_react9 = __toESM(require("react"));
1034
+
1035
+ // src/MenuBuilder/WidgetContext.js
1036
+ var import_react = __toESM(require("react"));
1037
+ var WidgetContext_default = import_react.default.createContext();
1038
+
1039
+ // src/MenuBuilder/MainNavigation.js
1040
+ var import_react2 = __toESM(require("react"));
1041
+ var import_styled_components = __toESM(require("styled-components"));
1042
+ var import_react_sortablejs = require("react-sortablejs");
1043
+
1044
+ // src/MenuBuilder/utils.js
1045
+ var rand = (length) => Math.random().toString(36).substring(length);
1046
+ var remove = (items, item) => {
1047
+ const idx = items.findIndex((i) => i.id === item.id);
1048
+ return [...items.slice(0, idx), ...items.slice(idx + 1)];
1049
+ };
1050
+ var update = (items, item) => {
1051
+ const idx = items.findIndex((i) => i.id === item.id);
1052
+ return [...items.slice(0, idx), item, ...items.slice(idx + 1)];
1053
+ };
1054
+ var append = (items, item) => [...items, item];
1055
+
1056
+ // src/MenuBuilder/Factories.js
1057
+ var Factories = {
1058
+ item: () => ({
1059
+ id: rand(4),
1060
+ label: "New item",
1061
+ url: "#",
1062
+ target: "",
1063
+ rows: []
1064
+ }),
1065
+ row: () => ({ id: rand(4), columns: [] }),
1066
+ column: () => ({ id: rand(4), widgets: [] }),
1067
+ widget: (component, settings) => ({ id: rand(4), component, settings })
1068
+ };
1069
+ var Factories_default = Factories;
1070
+
1071
+ // src/MenuBuilder/MainNavigation.js
1072
+ var import_ui = __toESM(require_dist());
1073
+ var import_jsx_runtime = require("react/jsx-runtime");
1074
+ var Item = import_styled_components.default.div`
1075
+ ${import_ui.reset};
1076
+ display: inline-flex;
1077
+ align-items: center;
1078
+ padding: 0;
1079
+ margin-right: 0.5em;
1080
+ border: 1px solid
1081
+ ${(props) => props.active ? props.theme.colors.primary : props.theme.colors.gray};
1082
+ border-radius: 48px;
1083
+ background-color: ${(props) => props.active ? props.theme.colors.primary : props.theme.colors.white};
1084
+ font-weight: 700;
1085
+ transition: 0.1s ease-in-out all;
1086
+
1087
+ &:hover {
1088
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
1089
+ }
1090
+ `;
1091
+ var TabButton = import_styled_components.default.button`
1092
+ ${import_ui.buttonReset};
1093
+ padding: 0.5em 1em;
1094
+ color: ${(props) => props.active ? props.theme.colors.white : props.theme.colors.black};
1095
+ font-weight: 700;
1096
+ `;
1097
+ 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: [
1098
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1099
+ import_react_sortablejs.ReactSortable,
1100
+ {
1101
+ list: items,
1102
+ setList: onChange,
1103
+ direction: "horizontal",
1104
+ dragoverBubble: true,
1105
+ children: items.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Item, { active: idx === tab, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1106
+ TabButton,
1107
+ {
1108
+ type: "button",
1109
+ active: idx === tab,
1110
+ onClick: () => onTab(idx),
1111
+ children: item.label
1112
+ }
1113
+ ) }, item.id))
1114
+ }
1115
+ ),
1116
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1117
+ import_ui.Button,
1118
+ {
1119
+ variant: "secondary",
1120
+ onClick: () => onChange(append(items, Factories_default.item())),
1121
+ children: "Add item"
1122
+ }
1123
+ )
1124
+ ] }) });
1125
+ var MainNavigation_default = MainNavigation;
1126
+
1127
+ // src/MenuBuilder/ItemForm.js
1128
+ var import_react3 = __toESM(require("react"));
1129
+
1130
+ // src/MenuBuilder/icons/index.js
1131
+ var import_styled_components2 = __toESM(require("styled-components"));
1132
+ var Icon = import_styled_components2.default.span`
1133
+ display: inline-block;
1134
+ width: 16px;
1135
+ height: 16px;
1136
+ background-repeat: no-repeat;
1137
+ background-position: center;
1138
+ background-size: 100%;
1139
+ line-height: 1;
1140
+ filter: invert(${(props) => props.invert ? 1 : 0});
1141
+ `;
1142
+ var Edit = (0, import_styled_components2.default)(Icon)`
1143
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLWVkaXQtMiI+PHBhdGggZD0iTTE3IDNhMi44MjggMi44MjggMCAxIDEgNCA0TDcuNSAyMC41IDIgMjJsMS41LTUuNUwxNyAzeiI+PC9wYXRoPjwvc3ZnPg==);
1144
+ `;
1145
+ var Delete = (0, import_styled_components2.default)(Icon)`
1146
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXRyYXNoIj48cG9seWxpbmUgcG9pbnRzPSIzIDYgNSA2IDIxIDYiPjwvcG9seWxpbmU+PHBhdGggZD0iTTE5IDZ2MTRhMiAyIDAgMCAxLTIgMkg3YTIgMiAwIDAgMS0yLTJWNm0zIDBWNGEyIDIgMCAwIDEgMi0yaDRhMiAyIDAgMCAxIDIgMnYyIj48L3BhdGg+PC9zdmc+);
1147
+ `;
1148
+ var Plus = (0, import_styled_components2.default)(Icon)`
1149
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXBsdXMiPjxsaW5lIHgxPSIxMiIgeTE9IjUiIHgyPSIxMiIgeTI9IjE5Ij48L2xpbmU+PGxpbmUgeDE9IjUiIHkxPSIxMiIgeDI9IjE5IiB5Mj0iMTIiPjwvbGluZT48L3N2Zz4=);
1150
+ `;
1151
+ var Copy = (0, import_styled_components2.default)(Icon)`
1152
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLWNvcHkiPjxyZWN0IHg9IjkiIHk9IjkiIHdpZHRoPSIxMyIgaGVpZ2h0PSIxMyIgcng9IjIiIHJ5PSIyIj48L3JlY3Q+PHBhdGggZD0iTTUgMTVINGEyIDIgMCAwIDEtMi0yVjRhMiAyIDAgMCAxIDItMmg5YTIgMiAwIDAgMSAyIDJ2MSI+PC9wYXRoPjwvc3ZnPg==);
1153
+ `;
1154
+
1155
+ // src/MenuBuilder/ItemForm.js
1156
+ var import_ui2 = __toESM(require_dist());
1157
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1158
+ var ItemForm = ({ item, onChange, onRemove, onDuplicate }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
1159
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui2.Stack, { children: [
1160
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui2.FormGroup, { children: [
1161
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Label, { htmlFor: "label", children: "Label" }),
1162
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1163
+ import_ui2.Input,
1164
+ {
1165
+ name: "label",
1166
+ type: "text",
1167
+ wrapperProps: { style: { marginRight: "0.5em" } },
1168
+ value: item.label,
1169
+ onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
1170
+ label: e.target.value
1171
+ }))
1172
+ }
1173
+ )
1174
+ ] }),
1175
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui2.FormGroup, { children: [
1176
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Label, { htmlFor: "url", children: "URL" }),
1177
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1178
+ import_ui2.Input,
1179
+ {
1180
+ name: "url",
1181
+ type: "text",
1182
+ value: item.url,
1183
+ onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
1184
+ url: e.target.value
1185
+ }))
1186
+ }
1187
+ )
1188
+ ] }),
1189
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui2.FormGroup, { children: [
1190
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Label, { htmlFor: "target", children: "Target" }),
1191
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1192
+ import_ui2.Select,
1193
+ {
1194
+ name: "target",
1195
+ value: item.target,
1196
+ onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
1197
+ target: e.target.value
1198
+ })),
1199
+ children: [
1200
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", children: "Please select" }),
1201
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "_self", children: "Open in same tab" }),
1202
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "_blank", children: "Open in new tab" })
1203
+ ]
1204
+ }
1205
+ )
1206
+ ] })
1207
+ ] }),
1208
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Toolbar, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui2.Stack, { children: [
1209
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Button, { variant: "secondary", onClick: onDuplicate, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Copy, {}) }),
1210
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Button, { variant: "secondary", onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Delete, {}) })
1211
+ ] }) })
1212
+ ] });
1213
+ var ItemForm_default = ItemForm;
1214
+
1215
+ // src/MenuBuilder/RowBuilder.js
1216
+ var import_react8 = __toESM(require("react"));
1217
+ var import_react_sortablejs4 = require("react-sortablejs");
1218
+
1219
+ // src/MenuBuilder/ColumnBuilder.js
1220
+ var import_react7 = __toESM(require("react"));
1221
+ var import_styled_components4 = __toESM(require("styled-components"));
1222
+ var import_react_sortablejs3 = require("react-sortablejs");
1223
+ var import_ui6 = __toESM(require_dist());
1224
+
1225
+ // src/MenuBuilder/ContentBuilder.js
1226
+ var import_react6 = __toESM(require("react"));
1227
+ var import_react_sortablejs2 = require("react-sortablejs");
1228
+
1229
+ // src/MenuBuilder/AdminWidget.js
1230
+ var import_react4 = __toESM(require("react"));
1231
+ var import_ui3 = __toESM(require_dist());
1232
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1233
+ var AdminWidget = ({ Component, settings, onChange, onCancel }) => {
1234
+ const [state, setState] = import_react4.default.useState(settings);
1235
+ const Form = Component.admin;
1236
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
1237
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1238
+ Form,
1239
+ {
1240
+ settings: state,
1241
+ onChange: (key, value) => {
1242
+ setState(__spreadValues(__spreadValues({}, state), { [key]: value }));
1243
+ }
1244
+ }
1245
+ ),
1246
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1247
+ import_ui3.Button,
1248
+ {
1249
+ type: "submit",
1250
+ variant: "primary",
1251
+ onClick: () => onChange(__spreadValues({}, state)),
1252
+ children: "Save"
1253
+ }
1254
+ ),
1255
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui3.Button, { variant: "secondary", onClick: onCancel, children: "Cancel" })
1256
+ ] });
1257
+ };
1258
+ var AdminWidget_default = AdminWidget;
1259
+
1260
+ // src/MenuBuilder/AddWidget.js
1261
+ var import_react5 = __toESM(require("react"));
1262
+ var import_styled_components3 = __toESM(require("styled-components"));
1263
+ var import_ui4 = __toESM(require_dist());
1264
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1265
+ var WidgetButton = import_styled_components3.default.button`
1266
+ ${import_ui4.buttonReset};
1267
+ width: 100%;
1268
+ margin-bottom: 0.5em;
1269
+ padding: 1em;
1270
+ border: 1px solid ${(props) => props.theme.colors.gray};
1271
+ border-radius: 3px;
1272
+ font-weight: 500;
1273
+ text-align: left;
1274
+
1275
+ &:hover {
1276
+ background-color: ${(props) => props.theme.colors.primaryLight};
1277
+ border-color: ${(props) => props.theme.colors.primary};
1278
+ color: ${(props) => props.theme.colors.primary};
1279
+ }
1280
+ `;
1281
+ var AddWidget = ({ onAdd, onClose }) => {
1282
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_ui4.Modal, { open: true, title: "Select widget", onClose, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WidgetContext_default.Consumer, { children: (WIDGETS) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react5.default.Fragment, { children: Object.keys(WIDGETS).map((widgetName) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1283
+ WidgetButton,
1284
+ {
1285
+ onClick: () => onAdd(widgetName, WIDGETS[widgetName]),
1286
+ children: widgetName
1287
+ },
1288
+ widgetName
1289
+ )) }) }) });
1290
+ };
1291
+ var AddWidget_default = AddWidget;
1292
+
1293
+ // src/MenuBuilder/ContentBuilder.js
1294
+ var import_ui5 = __toESM(require_dist());
1295
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1296
+ var getWidget = (widgets, name) => widgets[name];
1297
+ var getTitle = (widgets, widget) => {
1298
+ const { component } = widget;
1299
+ const primaryField = getWidget(widgets, component).primaryField;
1300
+ return primaryField ? `${component}: ${widget.settings[primaryField]}` : component;
1301
+ };
1302
+ var ContentBuilder = ({ value, onChange }) => {
1303
+ const [widget, setWidget] = import_react6.default.useState({
1304
+ open: false,
1305
+ current: null
1306
+ });
1307
+ const [open, setOpen] = import_react6.default.useState(false);
1308
+ const [state, setState] = import_react6.default.useState(value);
1309
+ (0, import_react6.useEffect)(() => {
1310
+ setState(value);
1311
+ }, [value]);
1312
+ const addWidget = (items, item) => {
1313
+ const newState = __spreadProps(__spreadValues({}, state), {
1314
+ widgets: [...items, item]
1315
+ });
1316
+ setOpen(false);
1317
+ setState(newState);
1318
+ onChange(newState);
1319
+ };
1320
+ const removeWidget = (items, item) => {
1321
+ if (!confirm("Are you sure?"))
1322
+ return;
1323
+ const newState = __spreadProps(__spreadValues({}, state), {
1324
+ widgets: remove(items, item)
1325
+ });
1326
+ setState(newState);
1327
+ onChange(newState);
1328
+ };
1329
+ const reorder = (widgets) => {
1330
+ const newState = __spreadProps(__spreadValues({}, state), { widgets });
1331
+ setState(newState);
1332
+ onChange(newState);
1333
+ };
1334
+ const closeWidget = () => setWidget({ open: false, current: null });
1335
+ const updateWidget = (widget2, settings) => {
1336
+ const newState = __spreadProps(__spreadValues({}, state), {
1337
+ widgets: update(state.widgets, __spreadProps(__spreadValues({}, widget2), { settings }))
1338
+ });
1339
+ closeWidget();
1340
+ setState(newState);
1341
+ onChange(newState);
1342
+ };
1343
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(WidgetContext_default.Consumer, { children: (WIDGETS) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react6.default.Fragment, { children: [
1344
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1345
+ import_react_sortablejs2.ReactSortable,
1346
+ {
1347
+ list: state.widgets,
1348
+ setList: (widgets) => reorder(widgets),
1349
+ handle: ".r-handle",
1350
+ direction: "vertical",
1351
+ children: state.widgets.map((widget2) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui5.PanelTitle, { children: [
1352
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui5.Stack, { v: "center", children: [
1353
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Handle, { className: "r-handle" }),
1354
+ getTitle(WIDGETS, widget2)
1355
+ ] }),
1356
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui5.Stack, { v: "center", children: [
1357
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1358
+ import_ui5.Button,
1359
+ {
1360
+ variant: "secondary",
1361
+ onClick: () => setWidget({ open: true, current: widget2 }),
1362
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Edit, {})
1363
+ }
1364
+ ),
1365
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1366
+ import_ui5.Button,
1367
+ {
1368
+ variant: "secondary",
1369
+ onClick: () => removeWidget(state.widgets, widget2),
1370
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Delete, {})
1371
+ }
1372
+ )
1373
+ ] })
1374
+ ] }) }, widget2.id))
1375
+ }
1376
+ ),
1377
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Button, { variant: "secondary", onClick: () => setOpen(true), children: "Add widget" }),
1378
+ widget.open && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui5.Modal, { title: "Settings", open: widget.open, onClose: closeWidget, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1379
+ AdminWidget_default,
1380
+ {
1381
+ Component: getWidget(WIDGETS, widget.current.component),
1382
+ settings: widget.current.settings,
1383
+ onChange: (settings) => updateWidget(widget.current, settings),
1384
+ onCancel: closeWidget
1385
+ }
1386
+ ) }),
1387
+ open && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1388
+ AddWidget_default,
1389
+ {
1390
+ onAdd: (component, widget2) => addWidget(
1391
+ state.widgets,
1392
+ Factories_default.widget(component, widget2.defaults)
1393
+ ),
1394
+ onClose: () => setOpen(false)
1395
+ }
1396
+ )
1397
+ ] }) });
1398
+ };
1399
+ var ContentBuilder_default = ContentBuilder;
1400
+
1401
+ // src/MenuBuilder/ColumnBuilder.js
1402
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1403
+ var Wrapper = import_styled_components4.default.div`
1404
+ .r-list {
1405
+ display: flex;
1406
+ }
1407
+ `;
1408
+ var ColumnBuilder = ({ value, onChange }) => {
1409
+ const [state, setState] = import_react7.default.useState(value);
1410
+ (0, import_react7.useEffect)(() => {
1411
+ setState(value);
1412
+ }, [value]);
1413
+ const addColumn = (items, item) => {
1414
+ const newState = __spreadProps(__spreadValues({}, state), {
1415
+ columns: [...items, item]
1416
+ });
1417
+ setState(newState);
1418
+ onChange(newState);
1419
+ };
1420
+ const updateColumn = (items, item) => {
1421
+ const newState = __spreadProps(__spreadValues({}, state), {
1422
+ columns: update(items, item)
1423
+ });
1424
+ setState(newState);
1425
+ onChange(newState);
1426
+ };
1427
+ const duplicateColumn = (items, item) => {
1428
+ const newState = __spreadProps(__spreadValues({}, state), {
1429
+ columns: append(items, __spreadProps(__spreadValues({}, item), {
1430
+ id: rand(),
1431
+ label: `${item.label} (copy)`
1432
+ }))
1433
+ });
1434
+ setState(newState);
1435
+ };
1436
+ const removeColumn = (items, item) => {
1437
+ if (!confirm("Are you sure?"))
1438
+ return;
1439
+ const newState = __spreadProps(__spreadValues({}, state), {
1440
+ columns: remove(items, item)
1441
+ });
1442
+ setState(newState);
1443
+ onChange(newState);
1444
+ };
1445
+ const reorder = (columns) => {
1446
+ const newState = __spreadProps(__spreadValues({}, state), { columns });
1447
+ setState(newState);
1448
+ onChange(newState);
1449
+ };
1450
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Wrapper, { children: [
1451
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Toolbar, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1452
+ import_ui6.Button,
1453
+ {
1454
+ variant: "secondary",
1455
+ onClick: () => addColumn(state.columns, Factories_default.column()),
1456
+ children: "Add column"
1457
+ }
1458
+ ) }),
1459
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1460
+ import_react_sortablejs3.ReactSortable,
1461
+ {
1462
+ list: state.columns,
1463
+ setList: (columns) => reorder(columns),
1464
+ className: "r-list",
1465
+ handle: ".r-chandle",
1466
+ direction: "vertical",
1467
+ children: state.columns.map((column, idx) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.Panel, { style: { flex: 1, marginRight: "0.5em" }, children: [
1468
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.PanelTitle, { children: [
1469
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.Stack, { v: "center", children: [
1470
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.Handle, { className: "r-chandle" }),
1471
+ "Column #",
1472
+ idx + 1
1473
+ ] }),
1474
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui6.Stack, { v: "center", children: [
1475
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1476
+ import_ui6.Button,
1477
+ {
1478
+ variant: "secondary",
1479
+ onClick: () => duplicateColumn(state.columns, column),
1480
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Copy, {})
1481
+ }
1482
+ ),
1483
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1484
+ import_ui6.Button,
1485
+ {
1486
+ variant: "secondary",
1487
+ onClick: () => removeColumn(state.columns, column),
1488
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Delete, {})
1489
+ }
1490
+ )
1491
+ ] })
1492
+ ] }),
1493
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui6.PanelContent, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1494
+ ContentBuilder_default,
1495
+ {
1496
+ value: column,
1497
+ onChange: (column2) => updateColumn(state.columns, column2)
1498
+ }
1499
+ ) })
1500
+ ] }, column.id))
1501
+ }
1502
+ )
1503
+ ] });
1504
+ };
1505
+ var ColumnBuilder_default = ColumnBuilder;
1506
+
1507
+ // src/MenuBuilder/RowBuilder.js
1508
+ var import_ui7 = __toESM(require_dist());
1509
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1510
+ var RowBuilder = ({ value, onChange }) => {
1511
+ const [state, setState] = import_react8.default.useState(value);
1512
+ (0, import_react8.useEffect)(() => {
1513
+ setState(value);
1514
+ }, [value]);
1515
+ const addRow = (items, item) => {
1516
+ const newState = __spreadProps(__spreadValues({}, state), {
1517
+ rows: [...items, item]
1518
+ });
1519
+ setState(newState);
1520
+ onChange(newState);
1521
+ };
1522
+ const updateRow = (items, item) => {
1523
+ const newState = __spreadProps(__spreadValues({}, state), {
1524
+ rows: update(items, item)
1525
+ });
1526
+ setState(newState);
1527
+ onChange(newState);
1528
+ };
1529
+ const removeRow = (items, item) => {
1530
+ if (!confirm("Are you sure?"))
1531
+ return;
1532
+ const newState = __spreadProps(__spreadValues({}, state), {
1533
+ rows: remove(items, item)
1534
+ });
1535
+ setState(newState);
1536
+ onChange(newState);
1537
+ };
1538
+ const reorder = (rows) => {
1539
+ const newState = __spreadProps(__spreadValues({}, state), { rows });
1540
+ setState(newState);
1541
+ onChange(newState);
1542
+ };
1543
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react8.default.Fragment, { children: [
1544
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1545
+ import_react_sortablejs4.ReactSortable,
1546
+ {
1547
+ list: state.rows,
1548
+ setList: (rows) => reorder(rows),
1549
+ handle: ".r-handle",
1550
+ direction: "vertical",
1551
+ children: state.rows.map((row, idx) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui7.Panel, { children: [
1552
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui7.PanelTitle, { children: [
1553
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui7.Stack, { v: "center", children: [
1554
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui7.Handle, { className: "r-handle" }),
1555
+ "Row #",
1556
+ idx + 1
1557
+ ] }),
1558
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1559
+ import_ui7.Button,
1560
+ {
1561
+ variant: "secondary",
1562
+ onClick: () => removeRow(state.rows, row),
1563
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Delete, {})
1564
+ }
1565
+ )
1566
+ ] }),
1567
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui7.PanelContent, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1568
+ ColumnBuilder_default,
1569
+ {
1570
+ value: row,
1571
+ onChange: (row2) => updateRow(state.rows, row2)
1572
+ }
1573
+ ) })
1574
+ ] }, row.id))
1575
+ }
1576
+ ),
1577
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui7.Toolbar, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1578
+ import_ui7.Button,
1579
+ {
1580
+ variant: "secondary",
1581
+ onClick: () => addRow(state.rows, Factories_default.row()),
1582
+ children: "Add row"
1583
+ }
1584
+ ) })
1585
+ ] });
1586
+ };
1587
+ var RowBuilder_default = RowBuilder;
1588
+
1589
+ // src/MenuBuilder/index.js
1590
+ var import_ui8 = __toESM(require_dist());
1591
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1592
+ var MenuBuilder = ({ widgets, value, onChange }) => {
1593
+ const [state, setState] = import_react9.default.useState(value);
1594
+ const currentTab = state.tab;
1595
+ const currentItem = state.items ? state.items[currentTab] : null;
1596
+ const removeItem = (items, item) => {
1597
+ if (!confirm("Are you sure?"))
1598
+ return;
1599
+ const newState = __spreadProps(__spreadValues({}, state), {
1600
+ tab: 0,
1601
+ items: remove(items, item)
1602
+ });
1603
+ setState(newState);
1604
+ if (onChange)
1605
+ onChange(newState);
1606
+ };
1607
+ const updateItem = (items, item) => {
1608
+ const newState = __spreadProps(__spreadValues({}, state), {
1609
+ items: update(items, item)
1610
+ });
1611
+ setState(newState);
1612
+ if (onChange)
1613
+ onChange(newState);
1614
+ };
1615
+ const duplicateItem = (items, item) => {
1616
+ const newState = __spreadProps(__spreadValues({}, state), {
1617
+ items: append(items, __spreadProps(__spreadValues({}, item), {
1618
+ id: rand(),
1619
+ label: `${item.label} (copy)`
1620
+ }))
1621
+ });
1622
+ setState(newState);
1623
+ if (onChange)
1624
+ onChange(newState);
1625
+ };
1626
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(WidgetContext_default.Provider, { value: widgets, children: [
1627
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1628
+ MainNavigation_default,
1629
+ {
1630
+ items: state.items,
1631
+ tab: currentTab,
1632
+ onTab: (tab) => setState(__spreadProps(__spreadValues({}, state), { tab })),
1633
+ onChange: (items) => setState(__spreadProps(__spreadValues({}, state), { items }))
1634
+ }
1635
+ ),
1636
+ currentItem && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
1637
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1638
+ ItemForm_default,
1639
+ {
1640
+ item: currentItem,
1641
+ onChange: (item) => {
1642
+ updateItem(state.items, __spreadValues(__spreadValues({}, currentItem), item));
1643
+ },
1644
+ onRemove: () => removeItem(state.items, currentItem),
1645
+ onDuplicate: () => duplicateItem(state.items, currentItem)
1646
+ }
1647
+ ),
1648
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ui8.H, { as: "h4", size: "large", children: "Menu content" }),
1649
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1650
+ RowBuilder_default,
1651
+ {
1652
+ value: currentItem,
1653
+ onChange: (item) => updateItem(state.items, __spreadValues(__spreadValues({}, currentItem), item))
1654
+ }
1655
+ )
1656
+ ] })
1657
+ ] });
1658
+ };
1659
+ var MenuBuilder_default = MenuBuilder;
1660
+ // Annotate the CommonJS export names for ESM import in node:
1661
+ 0 && (module.exports = {
1662
+ MenuBuilder
1663
+ });