@raketa-builder/builder 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +3 -3
- package/dist/index.js +259 -196
- package/package.json +1 -1
- package/src/List.js +1 -5
- package/src/PageBuilder.js +3 -1
- package/src/dialogs/Dialog.js +44 -29
- package/src/dialogs/ReorderDialog.js +1 -5
- package/src/dialogs/SettingsDialog.js +7 -4
- package/src/forms/ButtonSettings.js +15 -15
- package/src/forms/LinkSettings.js +10 -15
- package/src/forms/SelectMenu.js +7 -6
- package/src/forms/TextArea.js +5 -6
- package/src/forms/TextInput.js +17 -7
- package/src/index.js +0 -11
- package/src/lib/AdminWidget.js +0 -4
- package/src/lib/Image.js +3 -6
package/package.json
CHANGED
package/src/List.js
CHANGED
|
@@ -173,7 +173,7 @@ const Item = ({
|
|
|
173
173
|
|
|
174
174
|
const List = ({
|
|
175
175
|
label,
|
|
176
|
-
items: defaultItems,
|
|
176
|
+
items: defaultItems = [],
|
|
177
177
|
listItem,
|
|
178
178
|
template,
|
|
179
179
|
primaryField,
|
|
@@ -299,8 +299,4 @@ const List = ({
|
|
|
299
299
|
);
|
|
300
300
|
};
|
|
301
301
|
|
|
302
|
-
List.defaultProps = {
|
|
303
|
-
items: [],
|
|
304
|
-
};
|
|
305
|
-
|
|
306
302
|
export default List;
|
package/src/PageBuilder.js
CHANGED
|
@@ -277,7 +277,9 @@ const PageBuilder = ({
|
|
|
277
277
|
<HostContext.Provider value={{ host }}>
|
|
278
278
|
<LibraryContext.Provider value={{ library, adminLibrary }}>
|
|
279
279
|
{notifications.length > 0 &&
|
|
280
|
-
notifications.map((notif) =>
|
|
280
|
+
notifications.map((notif) => {
|
|
281
|
+
return <Notification key={notif.id} {...notif} />;
|
|
282
|
+
})}
|
|
281
283
|
|
|
282
284
|
<div style={{ paddingLeft: "64px" }}>
|
|
283
285
|
{!reorderOpen && selectedWidgets.length > 0 && (
|
package/src/dialogs/Dialog.js
CHANGED
|
@@ -1,46 +1,61 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Modal, Button
|
|
2
|
+
import { Modal, Button } from "@raketa-builder/ui";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
);
|
|
4
|
+
function checkForChanges(hasChanges, onClose) {
|
|
5
|
+
if (!hasChanges) {
|
|
6
|
+
onClose();
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
if (
|
|
11
|
+
!confirm(
|
|
12
|
+
"You’ve made changes to the widget. Are you sure you want to cancel?"
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
return;
|
|
16
|
+
|
|
17
|
+
onClose();
|
|
18
|
+
}
|
|
11
19
|
|
|
12
20
|
const Dialog = ({
|
|
13
21
|
open,
|
|
14
22
|
onClose,
|
|
15
23
|
title,
|
|
16
|
-
children,
|
|
24
|
+
children = [],
|
|
17
25
|
primaryLabel,
|
|
18
26
|
secondaryLabel = "Cancel",
|
|
19
27
|
onPrimary,
|
|
28
|
+
areChanges,
|
|
20
29
|
}) => (
|
|
21
|
-
<Modal
|
|
22
|
-
|
|
30
|
+
<Modal
|
|
31
|
+
open={open}
|
|
32
|
+
title={title}
|
|
33
|
+
onClose={onClose}
|
|
34
|
+
areChanges={areChanges}
|
|
35
|
+
FooterContent={() =>
|
|
36
|
+
(primaryLabel || secondaryLabel) && (
|
|
37
|
+
<>
|
|
38
|
+
{primaryLabel && (
|
|
39
|
+
<Button type="button" variant="primary" onClick={onPrimary}>
|
|
40
|
+
{primaryLabel}
|
|
41
|
+
</Button>
|
|
42
|
+
)}
|
|
23
43
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)}
|
|
44
|
+
{secondaryLabel && (
|
|
45
|
+
<Button
|
|
46
|
+
type="button"
|
|
47
|
+
variant="secondary"
|
|
48
|
+
onClick={() => checkForChanges(areChanges, onClose)}
|
|
49
|
+
>
|
|
50
|
+
{secondaryLabel}
|
|
51
|
+
</Button>
|
|
52
|
+
)}
|
|
53
|
+
</>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
39
58
|
</Modal>
|
|
40
59
|
);
|
|
41
60
|
|
|
42
|
-
Dialog.defaultProps = {
|
|
43
|
-
children: [],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
61
|
export default Dialog;
|
|
@@ -43,7 +43,7 @@ const getWidgetTitle = (library, widget) => {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
const ReorderDialog = ({
|
|
46
|
-
widgets,
|
|
46
|
+
widgets = [],
|
|
47
47
|
onClose,
|
|
48
48
|
onChange,
|
|
49
49
|
onDelete,
|
|
@@ -170,8 +170,4 @@ const ReorderDialog = ({
|
|
|
170
170
|
);
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
-
ReorderDialog.defaultProps = {
|
|
174
|
-
widgets: [],
|
|
175
|
-
};
|
|
176
|
-
|
|
177
173
|
export default ReorderDialog;
|
|
@@ -119,7 +119,7 @@ const renderAdmin = (schema = {}, settings = {}, onChange) =>
|
|
|
119
119
|
Object.keys(schema).map((field) => {
|
|
120
120
|
const opts = Object.assign(
|
|
121
121
|
{ label: capitalize(humanize(field)) },
|
|
122
|
-
schema[field]
|
|
122
|
+
schema[field]
|
|
123
123
|
);
|
|
124
124
|
|
|
125
125
|
return renderField(field, settings[field], onChange, opts);
|
|
@@ -147,8 +147,8 @@ const SettingsDialog = ({ widget, settings, onSave, onClose }) => {
|
|
|
147
147
|
if (typeof schema !== "object") {
|
|
148
148
|
console.warn(
|
|
149
149
|
`Legacy widget with React admin definition: ${widgetData.title(
|
|
150
|
-
widget
|
|
151
|
-
)}. Update to custom inputs.
|
|
150
|
+
widget
|
|
151
|
+
)}. Update to custom inputs. `
|
|
152
152
|
);
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -158,9 +158,11 @@ const SettingsDialog = ({ widget, settings, onSave, onClose }) => {
|
|
|
158
158
|
const containerAdminFields = renderAdmin(
|
|
159
159
|
containerAdmin,
|
|
160
160
|
containerSettings,
|
|
161
|
-
handleChangeContainer
|
|
161
|
+
handleChangeContainer
|
|
162
162
|
);
|
|
163
163
|
|
|
164
|
+
const areChanges = JSON.stringify(settings) !== JSON.stringify(localSettings);
|
|
165
|
+
|
|
164
166
|
return (
|
|
165
167
|
<Dialog
|
|
166
168
|
open
|
|
@@ -168,6 +170,7 @@ const SettingsDialog = ({ widget, settings, onSave, onClose }) => {
|
|
|
168
170
|
primaryLabel="OK"
|
|
169
171
|
onPrimary={() => onSave(localSettings)}
|
|
170
172
|
onClose={onClose}
|
|
173
|
+
areChanges={areChanges}
|
|
171
174
|
>
|
|
172
175
|
<Tabs>
|
|
173
176
|
<div title="Content">{fields}</div>
|
|
@@ -33,7 +33,21 @@ const DEFAULT_BUTTON_STYLES = [
|
|
|
33
33
|
const mergeSettings = (settings, key, value) =>
|
|
34
34
|
Object.assign({}, settings, { [key]: value });
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const DEFAULTS = {
|
|
37
|
+
label: "Button",
|
|
38
|
+
link: "#",
|
|
39
|
+
id: "",
|
|
40
|
+
type: "primary",
|
|
41
|
+
target: "_self",
|
|
42
|
+
rel: "follow",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const ButtonSettings = ({
|
|
46
|
+
label = "Button",
|
|
47
|
+
hint,
|
|
48
|
+
value = DEFAULTS,
|
|
49
|
+
onChange,
|
|
50
|
+
}) => {
|
|
37
51
|
const { buttonStyles } =
|
|
38
52
|
React.useContext(BuilderContext) || DEFAULT_BUTTON_STYLES;
|
|
39
53
|
|
|
@@ -99,20 +113,6 @@ const ButtonSettings = ({ label, hint, value, onChange }) => {
|
|
|
99
113
|
);
|
|
100
114
|
};
|
|
101
115
|
|
|
102
|
-
const DEFAULTS = {
|
|
103
|
-
label: "Button",
|
|
104
|
-
link: "#",
|
|
105
|
-
id: "",
|
|
106
|
-
type: "primary",
|
|
107
|
-
target: "_self",
|
|
108
|
-
rel: "follow",
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
ButtonSettings.defaultProps = {
|
|
112
|
-
label: "Button",
|
|
113
|
-
value: DEFAULTS,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
116
|
ButtonSettings.defaults = DEFAULTS;
|
|
117
117
|
ButtonSettings.defaultButtonStyles = DEFAULT_BUTTON_STYLES;
|
|
118
118
|
|
|
@@ -26,7 +26,16 @@ const ButtonControl = ({ className, ...props }) => (
|
|
|
26
26
|
const mergeSettings = (settings, key, value) =>
|
|
27
27
|
Object.assign({}, settings, { [key]: value });
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const DEFAULTS = {
|
|
30
|
+
label: "link",
|
|
31
|
+
link: "#",
|
|
32
|
+
id: "",
|
|
33
|
+
className: "",
|
|
34
|
+
target: "_self",
|
|
35
|
+
rel: "follow",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const LinkSettings = ({ label = "Link", hint, value = DEFAULTS, onChange }) => (
|
|
30
39
|
<ButtonControl>
|
|
31
40
|
<FormSectionTitle>
|
|
32
41
|
<SettingsIcon /> {label}
|
|
@@ -86,20 +95,6 @@ const LinkSettings = ({ label, hint, value, onChange }) => (
|
|
|
86
95
|
</ButtonControl>
|
|
87
96
|
);
|
|
88
97
|
|
|
89
|
-
const DEFAULTS = {
|
|
90
|
-
label: "link",
|
|
91
|
-
link: "#",
|
|
92
|
-
id: "",
|
|
93
|
-
className: "",
|
|
94
|
-
target: "_self",
|
|
95
|
-
rel: "follow",
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
LinkSettings.defaultProps = {
|
|
99
|
-
label: "Link ",
|
|
100
|
-
value: DEFAULTS,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
98
|
LinkSettings.defaults = DEFAULTS;
|
|
104
99
|
|
|
105
100
|
export default LinkSettings;
|
package/src/forms/SelectMenu.js
CHANGED
|
@@ -51,7 +51,13 @@ const SelectField = (props) => {
|
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
const SelectMenu = ({
|
|
54
|
+
const SelectMenu = ({
|
|
55
|
+
label,
|
|
56
|
+
options,
|
|
57
|
+
placeholder = "Please select...",
|
|
58
|
+
onChange,
|
|
59
|
+
value = "",
|
|
60
|
+
}) => (
|
|
55
61
|
<SelectField
|
|
56
62
|
label={label}
|
|
57
63
|
options={getOptions(options, placeholder)}
|
|
@@ -60,9 +66,4 @@ const SelectMenu = ({ label, options, placeholder, onChange, value }) => (
|
|
|
60
66
|
/>
|
|
61
67
|
);
|
|
62
68
|
|
|
63
|
-
SelectMenu.defaultProps = {
|
|
64
|
-
value: "",
|
|
65
|
-
placeholder: "Please select...",
|
|
66
|
-
};
|
|
67
|
-
|
|
68
69
|
export default SelectMenu;
|
package/src/forms/TextArea.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import TextInput from "./TextInput";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
4
|
+
function TextArea({ value = "", placeholder = "", ...rest }) {
|
|
5
|
+
return (
|
|
6
|
+
<TextInput multiline value={value} placeholder={placeholder} {...rest} />
|
|
7
|
+
);
|
|
8
|
+
}
|
|
10
9
|
|
|
11
10
|
export default TextArea;
|
package/src/forms/TextInput.js
CHANGED
|
@@ -2,7 +2,16 @@ import React from "react";
|
|
|
2
2
|
import { FormGroup, Label, Input, Textarea, Hint } from "@raketa-builder/ui";
|
|
3
3
|
import { randomString } from "../lists";
|
|
4
4
|
|
|
5
|
-
const TextField = ({
|
|
5
|
+
const TextField = ({
|
|
6
|
+
label,
|
|
7
|
+
hint,
|
|
8
|
+
multiline,
|
|
9
|
+
error,
|
|
10
|
+
onChange,
|
|
11
|
+
value = "",
|
|
12
|
+
placeholder = "",
|
|
13
|
+
...rest
|
|
14
|
+
}) => {
|
|
6
15
|
const id = randomString();
|
|
7
16
|
const Component = multiline ? Textarea : Input;
|
|
8
17
|
|
|
@@ -15,7 +24,13 @@ const TextField = ({ label, hint, multiline, error, onChange, ...rest }) => {
|
|
|
15
24
|
) : (
|
|
16
25
|
""
|
|
17
26
|
)}
|
|
18
|
-
<Component
|
|
27
|
+
<Component
|
|
28
|
+
id={id}
|
|
29
|
+
onChange={(e) => onChange(e.target.value)}
|
|
30
|
+
value={value}
|
|
31
|
+
placeholder={placeholder}
|
|
32
|
+
{...rest}
|
|
33
|
+
/>
|
|
19
34
|
{hint ? <Hint>{hint}</Hint> : ""}
|
|
20
35
|
</FormGroup>
|
|
21
36
|
);
|
|
@@ -23,9 +38,4 @@ const TextField = ({ label, hint, multiline, error, onChange, ...rest }) => {
|
|
|
23
38
|
|
|
24
39
|
const TextInput = (props) => <TextField {...props} />;
|
|
25
40
|
|
|
26
|
-
TextInput.defaultProps = {
|
|
27
|
-
value: "",
|
|
28
|
-
placeholder: "",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
41
|
export default TextInput;
|
package/src/index.js
CHANGED
|
@@ -18,15 +18,6 @@ import LinkSettings from "./forms/LinkSettings";
|
|
|
18
18
|
import Link from "./lib/Link";
|
|
19
19
|
import BuilderContext from "./contexts/BuilderContext";
|
|
20
20
|
|
|
21
|
-
const theme = {};
|
|
22
|
-
const RaketaUIProvider = ({ children }) => (
|
|
23
|
-
<React.Fragment>{children}</React.Fragment>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
RaketaUIProvider.defaultProps = {
|
|
27
|
-
theme: theme,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
21
|
export {
|
|
31
22
|
PageBuilder,
|
|
32
23
|
TextInput,
|
|
@@ -45,8 +36,6 @@ export {
|
|
|
45
36
|
LinkSettings,
|
|
46
37
|
Link,
|
|
47
38
|
Label,
|
|
48
|
-
theme,
|
|
49
39
|
FormGroup,
|
|
50
|
-
RaketaUIProvider,
|
|
51
40
|
BuilderContext,
|
|
52
41
|
};
|
package/src/lib/AdminWidget.js
CHANGED
package/src/lib/Image.js
CHANGED
|
@@ -38,7 +38,7 @@ const getAlt = (src) => {
|
|
|
38
38
|
const imageObj = src.image || src;
|
|
39
39
|
|
|
40
40
|
const altSetting = (imageObj?.settings || []).find(
|
|
41
|
-
(setting) => setting.key === "alt"
|
|
41
|
+
(setting) => setting.key === "alt"
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
if (altSetting) {
|
|
@@ -74,7 +74,8 @@ const getImageObjOrSrc = (value) => {
|
|
|
74
74
|
return value;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
const Image = ({ variant, src, alt, loading, ...props }) => {
|
|
77
|
+
const Image = ({ variant, src, alt, loading = "lazy", ...props }) => {
|
|
78
|
+
console.log(props);
|
|
78
79
|
if (!variant) {
|
|
79
80
|
console.error("Image with no variant", { variant, src, alt, props });
|
|
80
81
|
return null;
|
|
@@ -116,8 +117,4 @@ const Image = ({ variant, src, alt, loading, ...props }) => {
|
|
|
116
117
|
);
|
|
117
118
|
};
|
|
118
119
|
|
|
119
|
-
Image.defaultProps = {
|
|
120
|
-
loading: "lazy",
|
|
121
|
-
};
|
|
122
|
-
|
|
123
120
|
export default Image;
|