@raketa-builder/menu-builder 1.3.8 → 1.3.10
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/MenuBuilder/AddWidget.js +23 -0
- package/dist/MenuBuilder/AdminWidget.js +67 -0
- package/dist/MenuBuilder/ColumnBuilder.js +113 -0
- package/dist/MenuBuilder/ContentBuilder.js +132 -0
- package/{src → dist}/MenuBuilder/Factories.js +6 -4
- package/dist/MenuBuilder/ItemForm.js +92 -0
- package/dist/MenuBuilder/MainNavigation.js +62 -0
- package/dist/MenuBuilder/RowBuilder.js +89 -0
- package/dist/MenuBuilder/WidgetContext.js +6 -0
- package/dist/MenuBuilder/icons.js +127 -0
- package/dist/MenuBuilder/index.js +80 -0
- package/dist/MenuBuilder/utils.js +14 -0
- package/dist/chunk-ORMEWXMH.js +33 -0
- package/dist/index.js +2 -827
- package/package.json +19 -5
- 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/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
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { __objRest, __spreadProps, __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { cn } from '@raketa-builder/ui';
|
|
4
|
+
|
|
5
|
+
function filterStyle(props) {
|
|
6
|
+
const value = props.invert ? 1 : 0;
|
|
7
|
+
return { filter: `invert(${value})` };
|
|
8
|
+
}
|
|
9
|
+
function Edit(_a) {
|
|
10
|
+
var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"svg",
|
|
13
|
+
__spreadProps(__spreadValues({
|
|
14
|
+
className: cn(
|
|
15
|
+
"r-reset",
|
|
16
|
+
"r-menu-icon",
|
|
17
|
+
"feather",
|
|
18
|
+
"feather-edit-2",
|
|
19
|
+
className
|
|
20
|
+
),
|
|
21
|
+
style: filterStyle(rest),
|
|
22
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
23
|
+
width: "24",
|
|
24
|
+
height: "24",
|
|
25
|
+
viewBox: "0 0 24 24",
|
|
26
|
+
fill: "none",
|
|
27
|
+
stroke: "#000",
|
|
28
|
+
strokeWidth: "2",
|
|
29
|
+
strokeLinecap: "round",
|
|
30
|
+
strokeLinejoin: "round"
|
|
31
|
+
}, rest), {
|
|
32
|
+
children: /* @__PURE__ */ jsx("path", { d: "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z" })
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function Delete(_c) {
|
|
37
|
+
var _d = _c, { className } = _d, rest = __objRest(_d, ["className"]);
|
|
38
|
+
return /* @__PURE__ */ jsxs(
|
|
39
|
+
"svg",
|
|
40
|
+
__spreadProps(__spreadValues({
|
|
41
|
+
className: cn(
|
|
42
|
+
"r-reset",
|
|
43
|
+
"r-menu-icon",
|
|
44
|
+
"feather",
|
|
45
|
+
"feather-trash",
|
|
46
|
+
className
|
|
47
|
+
),
|
|
48
|
+
style: filterStyle(rest),
|
|
49
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
50
|
+
width: "24",
|
|
51
|
+
height: "24",
|
|
52
|
+
viewBox: "0 0 24 24",
|
|
53
|
+
fill: "none",
|
|
54
|
+
stroke: "#000",
|
|
55
|
+
strokeWidth: "2",
|
|
56
|
+
strokeLinecap: "round",
|
|
57
|
+
strokeLinejoin: "round"
|
|
58
|
+
}, rest), {
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ jsx("polyline", { points: "3 6 5 6 21 6" }),
|
|
61
|
+
/* @__PURE__ */ 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" })
|
|
62
|
+
]
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
function Plus(_e) {
|
|
67
|
+
var _f = _e, { className } = _f, rest = __objRest(_f, ["className"]);
|
|
68
|
+
return /* @__PURE__ */ jsxs(
|
|
69
|
+
"svg",
|
|
70
|
+
__spreadProps(__spreadValues({
|
|
71
|
+
className: cn(
|
|
72
|
+
"r-reset",
|
|
73
|
+
"r-menu-icon",
|
|
74
|
+
"feather",
|
|
75
|
+
"feather-plus",
|
|
76
|
+
className
|
|
77
|
+
),
|
|
78
|
+
style: filterStyle(rest),
|
|
79
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
80
|
+
width: "24",
|
|
81
|
+
height: "24",
|
|
82
|
+
viewBox: "0 0 24 24",
|
|
83
|
+
fill: "none",
|
|
84
|
+
stroke: "#000",
|
|
85
|
+
strokeWidth: "2",
|
|
86
|
+
strokeLinecap: "round",
|
|
87
|
+
strokeLinejoin: "round"
|
|
88
|
+
}, rest), {
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
91
|
+
/* @__PURE__ */ jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function Copy(_g) {
|
|
97
|
+
var _h = _g, { className } = _h, rest = __objRest(_h, ["className"]);
|
|
98
|
+
return /* @__PURE__ */ jsxs(
|
|
99
|
+
"svg",
|
|
100
|
+
__spreadProps(__spreadValues({
|
|
101
|
+
className: cn(
|
|
102
|
+
"r-reset",
|
|
103
|
+
"r-menu-icon",
|
|
104
|
+
"feather",
|
|
105
|
+
"feather-copy",
|
|
106
|
+
className
|
|
107
|
+
),
|
|
108
|
+
style: filterStyle(rest),
|
|
109
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
110
|
+
width: "24",
|
|
111
|
+
height: "24",
|
|
112
|
+
viewBox: "0 0 24 24",
|
|
113
|
+
fill: "none",
|
|
114
|
+
stroke: "#000",
|
|
115
|
+
strokeWidth: "2",
|
|
116
|
+
strokeLinecap: "round",
|
|
117
|
+
strokeLinejoin: "round"
|
|
118
|
+
}, rest), {
|
|
119
|
+
children: [
|
|
120
|
+
/* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
121
|
+
/* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
122
|
+
]
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { Copy, Delete, Edit, Plus };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { __spreadProps, __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import WidgetContext from './WidgetContext';
|
|
5
|
+
import MainNavigation from './MainNavigation';
|
|
6
|
+
import ItemForm from './ItemForm';
|
|
7
|
+
import RowBuilder from './RowBuilder';
|
|
8
|
+
import { remove, update, append, rand } from './utils';
|
|
9
|
+
import { H } from '@raketa-builder/ui';
|
|
10
|
+
|
|
11
|
+
const MenuBuilder = ({ widgets, value, onChange }) => {
|
|
12
|
+
const [state, setState] = React.useState(value);
|
|
13
|
+
const currentTab = state.tab;
|
|
14
|
+
const currentItem = state.items ? state.items[currentTab] : null;
|
|
15
|
+
const removeItem = (items, item) => {
|
|
16
|
+
if (!confirm("Are you sure?")) return;
|
|
17
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
18
|
+
tab: 0,
|
|
19
|
+
items: remove(items, item)
|
|
20
|
+
});
|
|
21
|
+
setState(newState);
|
|
22
|
+
if (onChange) onChange(newState);
|
|
23
|
+
};
|
|
24
|
+
const updateItem = (items, item) => {
|
|
25
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
26
|
+
items: update(items, item)
|
|
27
|
+
});
|
|
28
|
+
setState(newState);
|
|
29
|
+
if (onChange) onChange(newState);
|
|
30
|
+
};
|
|
31
|
+
const duplicateItem = (items, item) => {
|
|
32
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
33
|
+
items: append(items, __spreadProps(__spreadValues({}, item), {
|
|
34
|
+
id: rand(),
|
|
35
|
+
label: `${item.label} (copy)`
|
|
36
|
+
}))
|
|
37
|
+
});
|
|
38
|
+
setState(newState);
|
|
39
|
+
if (onChange) onChange(newState);
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ jsxs(WidgetContext.Provider, { value: widgets, children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
MainNavigation,
|
|
44
|
+
{
|
|
45
|
+
items: state.items,
|
|
46
|
+
tab: currentTab,
|
|
47
|
+
onTab: (tab) => setState(__spreadProps(__spreadValues({}, state), { tab })),
|
|
48
|
+
onChange: (items) => {
|
|
49
|
+
const newState = __spreadProps(__spreadValues({}, state), { items });
|
|
50
|
+
setState(newState);
|
|
51
|
+
if (onChange) onChange(newState);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
currentItem && /* @__PURE__ */ jsxs("div", { children: [
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
ItemForm,
|
|
58
|
+
{
|
|
59
|
+
item: currentItem,
|
|
60
|
+
onChange: (item) => {
|
|
61
|
+
updateItem(state.items, __spreadValues(__spreadValues({}, currentItem), item));
|
|
62
|
+
},
|
|
63
|
+
onRemove: () => removeItem(state.items, currentItem),
|
|
64
|
+
onDuplicate: () => duplicateItem(state.items, currentItem)
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsx(H, { as: "h4", size: "large", children: "Menu content" }),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
RowBuilder,
|
|
70
|
+
{
|
|
71
|
+
value: currentItem,
|
|
72
|
+
onChange: (item) => updateItem(state.items, __spreadValues(__spreadValues({}, currentItem), item))
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] })
|
|
76
|
+
] });
|
|
77
|
+
};
|
|
78
|
+
var MenuBuilder_default = MenuBuilder;
|
|
79
|
+
|
|
80
|
+
export { MenuBuilder_default as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '../chunk-ORMEWXMH.js';
|
|
2
|
+
|
|
3
|
+
const rand = (length) => Math.random().toString(36).substring(length);
|
|
4
|
+
const remove = (items, item) => {
|
|
5
|
+
const idx = items.findIndex((i) => i.id === item.id);
|
|
6
|
+
return [...items.slice(0, idx), ...items.slice(idx + 1)];
|
|
7
|
+
};
|
|
8
|
+
const update = (items, item) => {
|
|
9
|
+
const idx = items.findIndex((i) => i.id === item.id);
|
|
10
|
+
return [...items.slice(0, idx), item, ...items.slice(idx + 1)];
|
|
11
|
+
};
|
|
12
|
+
const append = (items, item) => [...items, item];
|
|
13
|
+
|
|
14
|
+
export { append, rand, remove, update };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { __objRest, __spreadProps, __spreadValues };
|