@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,23 @@
|
|
|
1
|
+
import { __objRest, __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Modal, cn } from '@raketa-builder/ui';
|
|
5
|
+
import WidgetContext from './WidgetContext';
|
|
6
|
+
|
|
7
|
+
const WidgetButton = (_a) => {
|
|
8
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
9
|
+
return /* @__PURE__ */ jsx("div", __spreadValues({ className: cn("r-reset-button r-widget-button", className) }, props));
|
|
10
|
+
};
|
|
11
|
+
const AddWidget = ({ onAdd, onClose }) => {
|
|
12
|
+
return /* @__PURE__ */ jsx(Modal, { open: true, title: "Select widget", onClose, children: /* @__PURE__ */ jsx(WidgetContext.Consumer, { children: (WIDGETS) => /* @__PURE__ */ jsx(React.Fragment, { children: Object.keys(WIDGETS).map((widgetName) => /* @__PURE__ */ jsx(
|
|
13
|
+
WidgetButton,
|
|
14
|
+
{
|
|
15
|
+
onClick: () => onAdd(widgetName, WIDGETS[widgetName]),
|
|
16
|
+
children: widgetName
|
|
17
|
+
},
|
|
18
|
+
widgetName
|
|
19
|
+
)) }) }) });
|
|
20
|
+
};
|
|
21
|
+
var AddWidget_default = AddWidget;
|
|
22
|
+
|
|
23
|
+
export { AddWidget_default as default };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Button } from '@raketa-builder/ui';
|
|
5
|
+
import { AdminForm } from '@raketa-builder/builder';
|
|
6
|
+
|
|
7
|
+
function checkForChanges(hasChanges, onClose) {
|
|
8
|
+
if (!hasChanges) {
|
|
9
|
+
onClose();
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!confirm(
|
|
13
|
+
"You\u2019ve made changes to the widget. Are you sure you want to cancel?"
|
|
14
|
+
))
|
|
15
|
+
return;
|
|
16
|
+
onClose();
|
|
17
|
+
}
|
|
18
|
+
const AdminWidget = ({
|
|
19
|
+
widget,
|
|
20
|
+
settings,
|
|
21
|
+
onChange,
|
|
22
|
+
handleChanges,
|
|
23
|
+
onCancel
|
|
24
|
+
}) => {
|
|
25
|
+
const [state, setState] = React.useState(settings);
|
|
26
|
+
const areChanges = JSON.stringify(state) !== JSON.stringify(settings);
|
|
27
|
+
const schema = widget.admin;
|
|
28
|
+
if (typeof schema !== "object") {
|
|
29
|
+
console.warn(
|
|
30
|
+
`Legacy widget with React admin definition: "${widget.name}". Update to schema defined inputs!`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
AdminForm,
|
|
36
|
+
{
|
|
37
|
+
schema,
|
|
38
|
+
value: state,
|
|
39
|
+
onChange: (newState) => {
|
|
40
|
+
console.log({ newState });
|
|
41
|
+
setState(__spreadValues({}, newState));
|
|
42
|
+
handleChanges(__spreadValues({}, newState));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
Button,
|
|
48
|
+
{
|
|
49
|
+
type: "submit",
|
|
50
|
+
variant: "primary",
|
|
51
|
+
onClick: () => onChange(__spreadValues({}, state)),
|
|
52
|
+
children: "Save"
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ jsx(
|
|
56
|
+
Button,
|
|
57
|
+
{
|
|
58
|
+
variant: "secondary",
|
|
59
|
+
onClick: () => checkForChanges(areChanges, onCancel),
|
|
60
|
+
children: "Cancel"
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] });
|
|
64
|
+
};
|
|
65
|
+
var AdminWidget_default = AdminWidget;
|
|
66
|
+
|
|
67
|
+
export { AdminWidget_default as default };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { __spreadProps, __spreadValues, __objRest } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
import { ReactSortable } from 'react-sortablejs';
|
|
5
|
+
import Factories from './Factories';
|
|
6
|
+
import { update, append, rand, remove } from './utils';
|
|
7
|
+
import { Copy, Delete } from './icons';
|
|
8
|
+
import { Toolbar, Button, Panel, PanelTitle, Stack, Handle, PanelContent, cn } from '@raketa-builder/ui';
|
|
9
|
+
import ContentBuilder from './ContentBuilder';
|
|
10
|
+
|
|
11
|
+
const Wrapper = (_a) => {
|
|
12
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
13
|
+
return /* @__PURE__ */ jsx("div", __spreadValues({ className: cn("r-reset", className) }, props));
|
|
14
|
+
};
|
|
15
|
+
const ColumnBuilder = ({ value, onChange }) => {
|
|
16
|
+
const [state, setState] = React.useState(value);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setState(value);
|
|
19
|
+
}, [value]);
|
|
20
|
+
const addColumn = (items, item) => {
|
|
21
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
22
|
+
columns: [...items, item]
|
|
23
|
+
});
|
|
24
|
+
setState(newState);
|
|
25
|
+
onChange(newState);
|
|
26
|
+
};
|
|
27
|
+
const updateColumn = (items, item) => {
|
|
28
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
29
|
+
columns: update(items, item)
|
|
30
|
+
});
|
|
31
|
+
setState(newState);
|
|
32
|
+
onChange(newState);
|
|
33
|
+
};
|
|
34
|
+
const duplicateColumn = (items, item) => {
|
|
35
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
36
|
+
columns: append(items, __spreadProps(__spreadValues({}, item), {
|
|
37
|
+
id: rand(),
|
|
38
|
+
label: `${item.label} (copy)`
|
|
39
|
+
}))
|
|
40
|
+
});
|
|
41
|
+
setState(newState);
|
|
42
|
+
};
|
|
43
|
+
const removeColumn = (items, item) => {
|
|
44
|
+
if (!confirm("Are you sure?")) return;
|
|
45
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
46
|
+
columns: remove(items, item)
|
|
47
|
+
});
|
|
48
|
+
setState(newState);
|
|
49
|
+
onChange(newState);
|
|
50
|
+
};
|
|
51
|
+
const reorder = (columns) => {
|
|
52
|
+
const newState = __spreadProps(__spreadValues({}, state), { columns });
|
|
53
|
+
setState(newState);
|
|
54
|
+
onChange(newState);
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ jsxs(Wrapper, { children: [
|
|
57
|
+
/* @__PURE__ */ jsx(Toolbar, { children: /* @__PURE__ */ jsx(
|
|
58
|
+
Button,
|
|
59
|
+
{
|
|
60
|
+
variant: "secondary",
|
|
61
|
+
onClick: () => addColumn(state.columns, Factories.column()),
|
|
62
|
+
children: "Add column"
|
|
63
|
+
}
|
|
64
|
+
) }),
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
ReactSortable,
|
|
67
|
+
{
|
|
68
|
+
list: state.columns,
|
|
69
|
+
setList: (columns) => reorder(columns),
|
|
70
|
+
className: "r-list",
|
|
71
|
+
handle: ".r-chandle",
|
|
72
|
+
direction: "vertical",
|
|
73
|
+
children: state.columns.map((column, idx) => /* @__PURE__ */ jsxs(Panel, { style: { flex: 1, marginRight: "0.5em" }, children: [
|
|
74
|
+
/* @__PURE__ */ jsxs(PanelTitle, { children: [
|
|
75
|
+
/* @__PURE__ */ jsxs(Stack, { className: "r-stack-align-center", children: [
|
|
76
|
+
/* @__PURE__ */ jsx(Handle, { className: "r-chandle" }),
|
|
77
|
+
"Column #",
|
|
78
|
+
idx + 1
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ jsxs(Stack, { className: "r-stack-align-center", children: [
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
Button,
|
|
83
|
+
{
|
|
84
|
+
variant: "secondary",
|
|
85
|
+
onClick: () => duplicateColumn(state.columns, column),
|
|
86
|
+
children: /* @__PURE__ */ jsx(Copy, {})
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
Button,
|
|
91
|
+
{
|
|
92
|
+
variant: "secondary",
|
|
93
|
+
onClick: () => removeColumn(state.columns, column),
|
|
94
|
+
children: /* @__PURE__ */ jsx(Delete, {})
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
] })
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ jsx(PanelContent, { children: /* @__PURE__ */ jsx(
|
|
100
|
+
ContentBuilder,
|
|
101
|
+
{
|
|
102
|
+
value: column,
|
|
103
|
+
onChange: (column2) => updateColumn(state.columns, column2)
|
|
104
|
+
}
|
|
105
|
+
) })
|
|
106
|
+
] }, column.id))
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] });
|
|
110
|
+
};
|
|
111
|
+
var ColumnBuilder_default = ColumnBuilder;
|
|
112
|
+
|
|
113
|
+
export { ColumnBuilder_default as default };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { __spreadProps, __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
import { ReactSortable } from 'react-sortablejs';
|
|
5
|
+
import WidgetContext from './WidgetContext';
|
|
6
|
+
import Factories from './Factories';
|
|
7
|
+
import AdminWidget from './AdminWidget';
|
|
8
|
+
import AddWidget from './AddWidget';
|
|
9
|
+
import { remove, update } from './utils';
|
|
10
|
+
import { Edit, Delete } from './icons';
|
|
11
|
+
import { Panel, PanelTitle, Stack, Handle, Button, Modal } from '@raketa-builder/ui';
|
|
12
|
+
|
|
13
|
+
const getWidget = (widgets, name) => widgets[name];
|
|
14
|
+
const getTitle = (widgets, widget) => {
|
|
15
|
+
const { component } = widget;
|
|
16
|
+
const primaryField = getWidget(widgets, component).primaryField;
|
|
17
|
+
return primaryField ? `${component}: ${widget.settings[primaryField]}` : component;
|
|
18
|
+
};
|
|
19
|
+
const ContentBuilder = ({ value, onChange }) => {
|
|
20
|
+
const [widget, setWidget] = React.useState({
|
|
21
|
+
open: false,
|
|
22
|
+
current: null
|
|
23
|
+
});
|
|
24
|
+
const [open, setOpen] = React.useState(false);
|
|
25
|
+
const [state, setState] = React.useState(value);
|
|
26
|
+
const [areChanges, setAreChanges] = React.useState(false);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setState(value);
|
|
29
|
+
}, [value]);
|
|
30
|
+
const addWidget = (items, item) => {
|
|
31
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
32
|
+
widgets: [...items, item]
|
|
33
|
+
});
|
|
34
|
+
setOpen(false);
|
|
35
|
+
setState(newState);
|
|
36
|
+
onChange(newState);
|
|
37
|
+
};
|
|
38
|
+
const removeWidget = (items, item) => {
|
|
39
|
+
if (!confirm("Are you sure?")) return;
|
|
40
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
41
|
+
widgets: remove(items, item)
|
|
42
|
+
});
|
|
43
|
+
setState(newState);
|
|
44
|
+
onChange(newState);
|
|
45
|
+
};
|
|
46
|
+
const reorder = (widgets) => {
|
|
47
|
+
const newState = __spreadProps(__spreadValues({}, state), { widgets });
|
|
48
|
+
setState(newState);
|
|
49
|
+
onChange(newState);
|
|
50
|
+
};
|
|
51
|
+
const closeWidget = () => {
|
|
52
|
+
setWidget({ open: false, current: null });
|
|
53
|
+
setAreChanges(false);
|
|
54
|
+
};
|
|
55
|
+
const updateWidget = (widget2, settings) => {
|
|
56
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
57
|
+
widgets: update(state.widgets, __spreadProps(__spreadValues({}, widget2), { settings }))
|
|
58
|
+
});
|
|
59
|
+
closeWidget();
|
|
60
|
+
setState(newState);
|
|
61
|
+
onChange(newState);
|
|
62
|
+
};
|
|
63
|
+
const handleChanges = (settings) => setAreChanges(widget.current.settings !== settings);
|
|
64
|
+
return /* @__PURE__ */ jsx(WidgetContext.Consumer, { children: (WIDGETS) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
ReactSortable,
|
|
67
|
+
{
|
|
68
|
+
list: state.widgets,
|
|
69
|
+
setList: (widgets) => reorder(widgets),
|
|
70
|
+
handle: ".r-handle",
|
|
71
|
+
direction: "vertical",
|
|
72
|
+
children: state.widgets.map((widget2) => /* @__PURE__ */ jsx(Panel, { children: /* @__PURE__ */ jsxs(PanelTitle, { children: [
|
|
73
|
+
/* @__PURE__ */ jsxs(Stack, { className: "r-stack-align-center", children: [
|
|
74
|
+
/* @__PURE__ */ jsx(Handle, { className: "r-handle" }),
|
|
75
|
+
getTitle(WIDGETS, widget2)
|
|
76
|
+
] }),
|
|
77
|
+
/* @__PURE__ */ jsxs(Stack, { className: "r-stack-align-center", children: [
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
Button,
|
|
80
|
+
{
|
|
81
|
+
variant: "secondary",
|
|
82
|
+
onClick: () => setWidget({ open: true, current: widget2 }),
|
|
83
|
+
children: /* @__PURE__ */ jsx(Edit, {})
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
Button,
|
|
88
|
+
{
|
|
89
|
+
variant: "secondary",
|
|
90
|
+
onClick: () => removeWidget(state.widgets, widget2),
|
|
91
|
+
children: /* @__PURE__ */ jsx(Delete, {})
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
] })
|
|
95
|
+
] }) }, widget2.id))
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => setOpen(true), children: "Add widget" }),
|
|
99
|
+
widget.open && /* @__PURE__ */ jsx(
|
|
100
|
+
Modal,
|
|
101
|
+
{
|
|
102
|
+
title: "Settings",
|
|
103
|
+
open: widget.open,
|
|
104
|
+
areChanges,
|
|
105
|
+
onClose: closeWidget,
|
|
106
|
+
children: /* @__PURE__ */ jsx(
|
|
107
|
+
AdminWidget,
|
|
108
|
+
{
|
|
109
|
+
widget: getWidget(WIDGETS, widget.current.component),
|
|
110
|
+
settings: widget.current.settings,
|
|
111
|
+
onChange: (settings) => updateWidget(widget.current, settings),
|
|
112
|
+
handleChanges,
|
|
113
|
+
onCancel: closeWidget
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
open && /* @__PURE__ */ jsx(
|
|
119
|
+
AddWidget,
|
|
120
|
+
{
|
|
121
|
+
onAdd: (component, widget2) => addWidget(
|
|
122
|
+
state.widgets,
|
|
123
|
+
Factories.widget(component, widget2.defaults)
|
|
124
|
+
),
|
|
125
|
+
onClose: () => setOpen(false)
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
] }) });
|
|
129
|
+
};
|
|
130
|
+
var ContentBuilder_default = ContentBuilder;
|
|
131
|
+
|
|
132
|
+
export { ContentBuilder_default as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { rand } from './utils';
|
|
2
3
|
|
|
3
4
|
const Factories = {
|
|
4
5
|
item: () => ({
|
|
@@ -8,11 +9,12 @@ const Factories = {
|
|
|
8
9
|
label: "New item",
|
|
9
10
|
url: "#",
|
|
10
11
|
target: "",
|
|
11
|
-
rows: []
|
|
12
|
+
rows: []
|
|
12
13
|
}),
|
|
13
14
|
row: () => ({ id: rand(4), columns: [] }),
|
|
14
15
|
column: () => ({ id: rand(4), widgets: [] }),
|
|
15
|
-
widget: (component, settings) => ({ id: rand(4), component, settings })
|
|
16
|
+
widget: (component, settings) => ({ id: rand(4), component, settings })
|
|
16
17
|
};
|
|
18
|
+
var Factories_default = Factories;
|
|
17
19
|
|
|
18
|
-
export default
|
|
20
|
+
export { Factories_default as default };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { __spreadProps, __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import { Copy, Delete } from './icons';
|
|
5
|
+
import { Stack, FormGroup, Label, Input, Select, Toolbar, Button } from '@raketa-builder/ui';
|
|
6
|
+
|
|
7
|
+
const ItemForm = ({ item, onChange, onRemove, onDuplicate }) => /* @__PURE__ */ jsxs("div", { children: [
|
|
8
|
+
/* @__PURE__ */ jsxs(Stack, { children: [
|
|
9
|
+
/* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
10
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "label", children: "Label" }),
|
|
11
|
+
/* @__PURE__ */ jsx(
|
|
12
|
+
Input,
|
|
13
|
+
{
|
|
14
|
+
name: "label",
|
|
15
|
+
type: "text",
|
|
16
|
+
wrapperProps: { style: { marginRight: "0.5em" } },
|
|
17
|
+
value: item.label,
|
|
18
|
+
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
19
|
+
label: e.target.value
|
|
20
|
+
}))
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
] }),
|
|
24
|
+
/* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
25
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "url", children: "URL" }),
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
Input,
|
|
28
|
+
{
|
|
29
|
+
name: "url",
|
|
30
|
+
type: "text",
|
|
31
|
+
value: item.url,
|
|
32
|
+
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
33
|
+
url: e.target.value
|
|
34
|
+
}))
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "html_id", children: "ID" }),
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
Input,
|
|
42
|
+
{
|
|
43
|
+
name: "html_id",
|
|
44
|
+
type: "text",
|
|
45
|
+
value: item.html_id,
|
|
46
|
+
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
47
|
+
html_id: e.target.value
|
|
48
|
+
}))
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
53
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "class_name", children: "CSS class" }),
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
Input,
|
|
56
|
+
{
|
|
57
|
+
name: "class_name",
|
|
58
|
+
type: "text",
|
|
59
|
+
value: item.class_name,
|
|
60
|
+
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
61
|
+
class_name: e.target.value
|
|
62
|
+
}))
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
] }),
|
|
66
|
+
/* @__PURE__ */ jsxs(FormGroup, { children: [
|
|
67
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "target", children: "Target" }),
|
|
68
|
+
/* @__PURE__ */ jsxs(
|
|
69
|
+
Select,
|
|
70
|
+
{
|
|
71
|
+
name: "target",
|
|
72
|
+
value: item.target,
|
|
73
|
+
onChange: (e) => onChange(__spreadProps(__spreadValues({}, item), {
|
|
74
|
+
target: e.target.value
|
|
75
|
+
})),
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Please select" }),
|
|
78
|
+
/* @__PURE__ */ jsx("option", { value: "_self", children: "Open in same tab" }),
|
|
79
|
+
/* @__PURE__ */ jsx("option", { value: "_blank", children: "Open in new tab" })
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
] })
|
|
84
|
+
] }),
|
|
85
|
+
/* @__PURE__ */ jsx(Toolbar, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
86
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: onDuplicate, children: /* @__PURE__ */ jsx(Copy, {}) }),
|
|
87
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: onRemove, children: /* @__PURE__ */ jsx(Delete, {}) })
|
|
88
|
+
] }) })
|
|
89
|
+
] });
|
|
90
|
+
var ItemForm_default = ItemForm;
|
|
91
|
+
|
|
92
|
+
export { ItemForm_default as default };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { __objRest, __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import { ReactSortable } from 'react-sortablejs';
|
|
5
|
+
import { append } from './utils';
|
|
6
|
+
import Factories from './Factories';
|
|
7
|
+
import { Container, Stack, Button, cn } from '@raketa-builder/ui';
|
|
8
|
+
|
|
9
|
+
const Item = (_a) => {
|
|
10
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"div",
|
|
13
|
+
__spreadValues({
|
|
14
|
+
className: cn(
|
|
15
|
+
"r-reset",
|
|
16
|
+
"r-main-nav-item",
|
|
17
|
+
props.active ? "active" : "",
|
|
18
|
+
className
|
|
19
|
+
)
|
|
20
|
+
}, props)
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
const TabButton = (_c) => {
|
|
24
|
+
var _d = _c, { className } = _d, props = __objRest(_d, ["className"]);
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
"div",
|
|
27
|
+
__spreadValues({
|
|
28
|
+
className: cn("r-reset-button r-main-nav-tab-button", className)
|
|
29
|
+
}, props)
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
const MainNavigation = ({ items, tab, onTab, onChange }) => /* @__PURE__ */ jsx(Container, { bottom: true, children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
ReactSortable,
|
|
35
|
+
{
|
|
36
|
+
list: items,
|
|
37
|
+
setList: onChange,
|
|
38
|
+
direction: "horizontal",
|
|
39
|
+
dragoverBubble: true,
|
|
40
|
+
children: items.map((item, idx) => /* @__PURE__ */ jsx(Item, { active: idx === tab, children: /* @__PURE__ */ jsx(
|
|
41
|
+
TabButton,
|
|
42
|
+
{
|
|
43
|
+
type: "button",
|
|
44
|
+
active: (idx === tab).toString(),
|
|
45
|
+
onClick: () => onTab(idx),
|
|
46
|
+
children: item.label
|
|
47
|
+
}
|
|
48
|
+
) }, item.id))
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
Button,
|
|
53
|
+
{
|
|
54
|
+
variant: "secondary",
|
|
55
|
+
onClick: () => onChange(append(items, Factories.item())),
|
|
56
|
+
children: "Add item"
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] }) });
|
|
60
|
+
var MainNavigation_default = MainNavigation;
|
|
61
|
+
|
|
62
|
+
export { MainNavigation_default as default };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { __spreadProps, __spreadValues } from '../chunk-ORMEWXMH.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
import { ReactSortable } from 'react-sortablejs';
|
|
5
|
+
import Factories from './Factories';
|
|
6
|
+
import { update, remove } from './utils';
|
|
7
|
+
import ColumnBuilder from './ColumnBuilder';
|
|
8
|
+
import { Delete } from './icons';
|
|
9
|
+
import { Panel, PanelTitle, Stack, Handle, Button, PanelContent, Toolbar } from '@raketa-builder/ui';
|
|
10
|
+
|
|
11
|
+
const RowBuilder = ({ value, onChange }) => {
|
|
12
|
+
const [state, setState] = React.useState(value);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
setState(value);
|
|
15
|
+
}, [value]);
|
|
16
|
+
const addRow = (items, item) => {
|
|
17
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
18
|
+
rows: [...items, item]
|
|
19
|
+
});
|
|
20
|
+
setState(newState);
|
|
21
|
+
onChange(newState);
|
|
22
|
+
};
|
|
23
|
+
const updateRow = (items, item) => {
|
|
24
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
25
|
+
rows: update(items, item)
|
|
26
|
+
});
|
|
27
|
+
setState(newState);
|
|
28
|
+
onChange(newState);
|
|
29
|
+
};
|
|
30
|
+
const removeRow = (items, item) => {
|
|
31
|
+
if (!confirm("Are you sure?")) return;
|
|
32
|
+
const newState = __spreadProps(__spreadValues({}, state), {
|
|
33
|
+
rows: remove(items, item)
|
|
34
|
+
});
|
|
35
|
+
setState(newState);
|
|
36
|
+
onChange(newState);
|
|
37
|
+
};
|
|
38
|
+
const reorder = (rows) => {
|
|
39
|
+
const newState = __spreadProps(__spreadValues({}, state), { rows });
|
|
40
|
+
setState(newState);
|
|
41
|
+
onChange(newState);
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
ReactSortable,
|
|
46
|
+
{
|
|
47
|
+
list: state.rows,
|
|
48
|
+
setList: (rows) => reorder(rows),
|
|
49
|
+
handle: ".r-handle",
|
|
50
|
+
direction: "vertical",
|
|
51
|
+
children: state.rows.map((row, idx) => /* @__PURE__ */ jsxs(Panel, { children: [
|
|
52
|
+
/* @__PURE__ */ jsxs(PanelTitle, { children: [
|
|
53
|
+
/* @__PURE__ */ jsxs(Stack, { className: "r-stack-align-center", children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Handle, { className: "r-handle" }),
|
|
55
|
+
"Row #",
|
|
56
|
+
idx + 1
|
|
57
|
+
] }),
|
|
58
|
+
/* @__PURE__ */ jsx(
|
|
59
|
+
Button,
|
|
60
|
+
{
|
|
61
|
+
variant: "secondary",
|
|
62
|
+
onClick: () => removeRow(state.rows, row),
|
|
63
|
+
children: /* @__PURE__ */ jsx(Delete, {})
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ jsx(PanelContent, { children: /* @__PURE__ */ jsx(
|
|
68
|
+
ColumnBuilder,
|
|
69
|
+
{
|
|
70
|
+
value: row,
|
|
71
|
+
onChange: (row2) => updateRow(state.rows, row2)
|
|
72
|
+
}
|
|
73
|
+
) })
|
|
74
|
+
] }, row.id))
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ jsx(Toolbar, { children: /* @__PURE__ */ jsx(
|
|
78
|
+
Button,
|
|
79
|
+
{
|
|
80
|
+
variant: "secondary",
|
|
81
|
+
onClick: () => addRow(state.rows, Factories.row()),
|
|
82
|
+
children: "Add row"
|
|
83
|
+
}
|
|
84
|
+
) })
|
|
85
|
+
] });
|
|
86
|
+
};
|
|
87
|
+
var RowBuilder_default = RowBuilder;
|
|
88
|
+
|
|
89
|
+
export { RowBuilder_default as default };
|