@raketa-builder/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/.turbo/turbo-build.log +8 -0
- package/.turbo/turbo-lint.log +13 -0
- package/CHANGELOG.md +7 -0
- package/dist/index.js +3247 -0
- package/package.json +31 -0
- package/src/Canvas.js +70 -0
- package/src/Container.js +15 -0
- package/src/EmbeddedVideo.js +143 -0
- package/src/ErrorBoundary/ErrorBoundary.js +28 -0
- package/src/ErrorBoundary/index.js +3 -0
- package/src/HostContext.js +5 -0
- package/src/LibraryContext.js +5 -0
- package/src/List.js +307 -0
- package/src/ListInput.js +13 -0
- package/src/MediaManager.js +15 -0
- package/src/PageBuilder.js +234 -0
- package/src/contexts/BuilderContext.js +8 -0
- package/src/dialogs/Dialog.js +49 -0
- package/src/dialogs/ReorderDialog.js +136 -0
- package/src/dialogs/SettingsDialog.js +180 -0
- package/src/forms/Button.js +33 -0
- package/src/forms/ButtonSettings.js +152 -0
- package/src/forms/LinkSettings.js +138 -0
- package/src/forms/RichText.js +22 -0
- package/src/forms/SelectMenu.js +68 -0
- package/src/forms/TextArea.js +11 -0
- package/src/forms/TextInput.js +31 -0
- package/src/helpers/humanize.js +9 -0
- package/src/helpers/imageSrc.js +17 -0
- package/src/helpers/widgetData.js +34 -0
- package/src/index.js +59 -0
- package/src/lib/AdminSidebar.js +178 -0
- package/src/lib/AdminWidget.js +132 -0
- package/src/lib/Image.js +78 -0
- package/src/lib/LanguageSwitcher.js +162 -0
- package/src/lib/Link.js +19 -0
- package/src/lib/SideNav.js +164 -0
- package/src/lib/SidebarItem.js +20 -0
- package/src/lists/index.js +41 -0
- package/src/pickers/ImagePicker/ImageInput.js +17 -0
- package/src/pickers/ImagePicker/ImagePicker.js +22 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { reset, Hint } from "@raketa-builder/ui";
|
|
4
|
+
import BuilderContext from "../contexts/BuilderContext";
|
|
5
|
+
|
|
6
|
+
import TextInput from "./TextInput";
|
|
7
|
+
import SelectMenu from "./SelectMenu";
|
|
8
|
+
|
|
9
|
+
const SettingsIcon = styled.span`
|
|
10
|
+
display: inline-block;
|
|
11
|
+
width: ${(props) => props.theme.font.base};
|
|
12
|
+
height: ${(props) => props.theme.font.base};
|
|
13
|
+
margin-right: ${(props) => `calc(${props.theme.font.base} / 2)`};
|
|
14
|
+
background-size: 100% auto;
|
|
15
|
+
background-repeat: none;
|
|
16
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItc2xpZGVycyI+PGxpbmUgeDE9IjQiIHkxPSIyMSIgeDI9IjQiIHkyPSIxNCI+PC9saW5lPjxsaW5lIHgxPSI0IiB5MT0iMTAiIHgyPSI0IiB5Mj0iMyI+PC9saW5lPjxsaW5lIHgxPSIxMiIgeTE9IjIxIiB4Mj0iMTIiIHkyPSIxMiI+PC9saW5lPjxsaW5lIHgxPSIxMiIgeTE9IjgiIHgyPSIxMiIgeTI9IjMiPjwvbGluZT48bGluZSB4MT0iMjAiIHkxPSIyMSIgeDI9IjIwIiB5Mj0iMTYiPjwvbGluZT48bGluZSB4MT0iMjAiIHkxPSIxMiIgeDI9IjIwIiB5Mj0iMyI+PC9saW5lPjxsaW5lIHgxPSIxIiB5MT0iMTQiIHgyPSI3IiB5Mj0iMTQiPjwvbGluZT48bGluZSB4MT0iOSIgeTE9IjgiIHgyPSIxNSIgeTI9IjgiPjwvbGluZT48bGluZSB4MT0iMTciIHkxPSIxNiIgeDI9IjIzIiB5Mj0iMTYiPjwvbGluZT48L3N2Zz4=);
|
|
17
|
+
}`;
|
|
18
|
+
|
|
19
|
+
const ThreeColumns = styled.div`
|
|
20
|
+
${reset}
|
|
21
|
+
display: flex;
|
|
22
|
+
|
|
23
|
+
& > div {
|
|
24
|
+
width: 33.33%;
|
|
25
|
+
padding-right: ${(props) => props.theme.font.base};
|
|
26
|
+
|
|
27
|
+
&:last-child {
|
|
28
|
+
padding-right: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:last-child {
|
|
33
|
+
& > div {
|
|
34
|
+
margin-bottom: 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const FormSectionTitle = styled.h6`
|
|
40
|
+
${reset}
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
width: 100%;
|
|
44
|
+
margin-bottom: ${(props) => `calc(${props.theme.font.base} / 2)`};
|
|
45
|
+
font-size: ${(props) => props.theme.font.small};
|
|
46
|
+
text-transform: uppercase;
|
|
47
|
+
font-weight: bold;
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const ButtonControl = styled.div`
|
|
51
|
+
${reset}
|
|
52
|
+
margin-bottom: 0;
|
|
53
|
+
|
|
54
|
+
& + div {
|
|
55
|
+
margin-top: ${(props) => props.theme.font.base};
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const DEFAULT_BUTTON_STYLES = [
|
|
60
|
+
["primary", "Primary"],
|
|
61
|
+
["secondary", "Secondary"],
|
|
62
|
+
["text", "Text"],
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const mergeSettings = (settings, key, value) =>
|
|
66
|
+
Object.assign({}, settings, { [key]: value });
|
|
67
|
+
|
|
68
|
+
const ButtonSettings = ({ label, hint, value, onChange }) => {
|
|
69
|
+
const { buttonStyles } =
|
|
70
|
+
React.useContext(BuilderContext) || DEFAULT_BUTTON_STYLES;
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<ButtonControl>
|
|
74
|
+
<FormSectionTitle>
|
|
75
|
+
<SettingsIcon /> {label}
|
|
76
|
+
</FormSectionTitle>
|
|
77
|
+
|
|
78
|
+
<ThreeColumns>
|
|
79
|
+
<TextInput
|
|
80
|
+
label="Label"
|
|
81
|
+
value={value.label}
|
|
82
|
+
onChange={(label) => onChange(mergeSettings(value, "label", label))}
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<TextInput
|
|
86
|
+
label="Link"
|
|
87
|
+
value={value.link}
|
|
88
|
+
onChange={(link) => onChange(mergeSettings(value, "link", link))}
|
|
89
|
+
/>
|
|
90
|
+
|
|
91
|
+
<TextInput
|
|
92
|
+
label="ID"
|
|
93
|
+
value={value.id}
|
|
94
|
+
onChange={(id) => onChange(mergeSettings(value, "id", id))}
|
|
95
|
+
/>
|
|
96
|
+
</ThreeColumns>
|
|
97
|
+
|
|
98
|
+
<ThreeColumns>
|
|
99
|
+
<SelectMenu
|
|
100
|
+
label="Type"
|
|
101
|
+
options={buttonStyles}
|
|
102
|
+
value={value.type}
|
|
103
|
+
placeholder=""
|
|
104
|
+
onChange={(type) => onChange(mergeSettings(value, "type", type))}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<SelectMenu
|
|
108
|
+
label="Target"
|
|
109
|
+
options={[
|
|
110
|
+
["_self", "Self"],
|
|
111
|
+
["_blank", "New Tab"],
|
|
112
|
+
]}
|
|
113
|
+
value={value.target}
|
|
114
|
+
onChange={(target) =>
|
|
115
|
+
onChange(mergeSettings(value, "target", target))
|
|
116
|
+
}
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
<SelectMenu
|
|
120
|
+
label="Follow Link"
|
|
121
|
+
options={[
|
|
122
|
+
["follow", "Follow"],
|
|
123
|
+
["nofollow", "No Follow"],
|
|
124
|
+
]}
|
|
125
|
+
value={value.rel}
|
|
126
|
+
onChange={(rel) => onChange(mergeSettings(value, "rel", rel))}
|
|
127
|
+
/>
|
|
128
|
+
</ThreeColumns>
|
|
129
|
+
|
|
130
|
+
{hint ? <Hint>{hint}</Hint> : ""}
|
|
131
|
+
</ButtonControl>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const DEFAULTS = {
|
|
136
|
+
label: "Button",
|
|
137
|
+
link: "#",
|
|
138
|
+
id: "",
|
|
139
|
+
type: "primary",
|
|
140
|
+
target: "_self",
|
|
141
|
+
rel: "follow",
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
ButtonSettings.defaultProps = {
|
|
145
|
+
label: "Button",
|
|
146
|
+
value: DEFAULTS,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
ButtonSettings.defaults = DEFAULTS;
|
|
150
|
+
ButtonSettings.defaultButtonStyles = DEFAULT_BUTTON_STYLES;
|
|
151
|
+
|
|
152
|
+
export default ButtonSettings;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { reset, Hint } from "@raketa-builder/ui";
|
|
4
|
+
|
|
5
|
+
import TextInput from "./TextInput";
|
|
6
|
+
import SelectMenu from "./SelectMenu";
|
|
7
|
+
|
|
8
|
+
const SettingsIcon = styled.span`
|
|
9
|
+
display: inline-block;
|
|
10
|
+
width: ${(props) => props.theme.font.base};
|
|
11
|
+
height: ${(props) => props.theme.font.base};
|
|
12
|
+
margin-right: ${(props) => `calc(${props.theme.font.base} / 2)`};
|
|
13
|
+
background-size: 100% auto;
|
|
14
|
+
background-repeat: none;
|
|
15
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItc2xpZGVycyI+PGxpbmUgeDE9IjQiIHkxPSIyMSIgeDI9IjQiIHkyPSIxNCI+PC9saW5lPjxsaW5lIHgxPSI0IiB5MT0iMTAiIHgyPSI0IiB5Mj0iMyI+PC9saW5lPjxsaW5lIHgxPSIxMiIgeTE9IjIxIiB4Mj0iMTIiIHkyPSIxMiI+PC9saW5lPjxsaW5lIHgxPSIxMiIgeTE9IjgiIHgyPSIxMiIgeTI9IjMiPjwvbGluZT48bGluZSB4MT0iMjAiIHkxPSIyMSIgeDI9IjIwIiB5Mj0iMTYiPjwvbGluZT48bGluZSB4MT0iMjAiIHkxPSIxMiIgeDI9IjIwIiB5Mj0iMyI+PC9saW5lPjxsaW5lIHgxPSIxIiB5MT0iMTQiIHgyPSI3IiB5Mj0iMTQiPjwvbGluZT48bGluZSB4MT0iOSIgeTE9IjgiIHgyPSIxNSIgeTI9IjgiPjwvbGluZT48bGluZSB4MT0iMTciIHkxPSIxNiIgeDI9IjIzIiB5Mj0iMTYiPjwvbGluZT48L3N2Zz4=);
|
|
16
|
+
|
|
17
|
+
}`;
|
|
18
|
+
|
|
19
|
+
const ThreeColumns = styled.div`
|
|
20
|
+
${reset}
|
|
21
|
+
display: flex;
|
|
22
|
+
|
|
23
|
+
& > div {
|
|
24
|
+
width: 33.33%;
|
|
25
|
+
padding-right: ${(props) => props.theme.font.base};
|
|
26
|
+
|
|
27
|
+
&:last-child {
|
|
28
|
+
padding-right: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:last-child {
|
|
33
|
+
& > div {
|
|
34
|
+
margin-bottom: 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const FormSectionTitle = styled.h6`
|
|
40
|
+
${reset}
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
width: 100%;
|
|
44
|
+
margin-bottom: ${(props) => `calc(${props.theme.font.base} / 2)`};
|
|
45
|
+
font-size: ${(props) => props.theme.font.small};
|
|
46
|
+
text-transform: uppercase;
|
|
47
|
+
font-weight: bold;
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const ButtonControl = styled.div`
|
|
51
|
+
${reset}
|
|
52
|
+
margin-bottom: 0;
|
|
53
|
+
|
|
54
|
+
& + div {
|
|
55
|
+
margin-top: ${(props) => props.theme.font.base};
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const mergeSettings = (settings, key, value) =>
|
|
60
|
+
Object.assign({}, settings, { [key]: value });
|
|
61
|
+
|
|
62
|
+
const LinkSettings = ({ label, hint, value, onChange }) => (
|
|
63
|
+
<ButtonControl>
|
|
64
|
+
<FormSectionTitle>
|
|
65
|
+
<SettingsIcon /> {label}
|
|
66
|
+
</FormSectionTitle>
|
|
67
|
+
|
|
68
|
+
<ThreeColumns>
|
|
69
|
+
<TextInput
|
|
70
|
+
label="Label"
|
|
71
|
+
value={value.label}
|
|
72
|
+
onChange={(label) => onChange(mergeSettings(value, "label", label))}
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
<TextInput
|
|
76
|
+
label="Link"
|
|
77
|
+
value={value.link}
|
|
78
|
+
onChange={(link) => onChange(mergeSettings(value, "link", link))}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<TextInput
|
|
82
|
+
label="ID"
|
|
83
|
+
value={value.id}
|
|
84
|
+
onChange={(id) => onChange(mergeSettings(value, "id", id))}
|
|
85
|
+
/>
|
|
86
|
+
</ThreeColumns>
|
|
87
|
+
|
|
88
|
+
<ThreeColumns>
|
|
89
|
+
<TextInput
|
|
90
|
+
label="CSS Class"
|
|
91
|
+
value={value.className}
|
|
92
|
+
onChange={(className) =>
|
|
93
|
+
onChange(mergeSettings(value, "className", className))
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<SelectMenu
|
|
98
|
+
label="Target"
|
|
99
|
+
options={[
|
|
100
|
+
["_self", "Self"],
|
|
101
|
+
["_blank", "New Tab"],
|
|
102
|
+
]}
|
|
103
|
+
value={value.target}
|
|
104
|
+
onChange={(target) => onChange(mergeSettings(value, "target", target))}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<SelectMenu
|
|
108
|
+
label="Follow Link"
|
|
109
|
+
options={[
|
|
110
|
+
["follow", "Follow"],
|
|
111
|
+
["nofollow", "No Follow"],
|
|
112
|
+
]}
|
|
113
|
+
value={value.rel}
|
|
114
|
+
onChange={(rel) => onChange(mergeSettings(value, "rel", rel))}
|
|
115
|
+
/>
|
|
116
|
+
</ThreeColumns>
|
|
117
|
+
|
|
118
|
+
{hint ? <Hint>{hint}</Hint> : ""}
|
|
119
|
+
</ButtonControl>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const DEFAULTS = {
|
|
123
|
+
label: "link",
|
|
124
|
+
link: "#",
|
|
125
|
+
id: "",
|
|
126
|
+
className: "",
|
|
127
|
+
target: "_self",
|
|
128
|
+
rel: "follow",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
LinkSettings.defaultProps = {
|
|
132
|
+
label: "Link ",
|
|
133
|
+
value: DEFAULTS,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
LinkSettings.defaults = DEFAULTS;
|
|
137
|
+
|
|
138
|
+
export default LinkSettings;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
const RichText = () => (
|
|
4
|
+
<div>
|
|
5
|
+
<p>
|
|
6
|
+
RichText is no longer part of @raketa-builder/builder. Please use
|
|
7
|
+
@raketa-cms/raketa-rte
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<strong>Update your imports</strong>
|
|
11
|
+
<p>
|
|
12
|
+
<code>{`import {RichText} from '@raketa-cms/raketa-rte';`}</code>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<strong>Update usage in JSON adminFields</strong>
|
|
16
|
+
<p>
|
|
17
|
+
<code>{`text: { type: 'custom', component: RichText },`}</code>
|
|
18
|
+
</p>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default RichText;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FormGroup, Label, Select, Hint } from "@raketa-builder/ui";
|
|
3
|
+
import { randomString } from "../lists";
|
|
4
|
+
|
|
5
|
+
const getOptions = (options, placeholder) => {
|
|
6
|
+
const initialOptions = placeholder ? [{ value: "", text: placeholder }] : [];
|
|
7
|
+
const preparedOptions = options.map((o) => ({ value: o[0], text: o[1] }));
|
|
8
|
+
|
|
9
|
+
return [...initialOptions, ...preparedOptions];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const SelectField = (props) => {
|
|
13
|
+
const id = randomString();
|
|
14
|
+
const { label, hint, options, placeholder, onChange } = props;
|
|
15
|
+
const inputProps = Object.assign({}, props);
|
|
16
|
+
delete inputProps.label;
|
|
17
|
+
delete inputProps.hint;
|
|
18
|
+
delete inputProps.options;
|
|
19
|
+
delete inputProps.placeholder;
|
|
20
|
+
delete inputProps.onChange;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<FormGroup>
|
|
24
|
+
{label ? (
|
|
25
|
+
<Label htmlFor={id} error={props.error}>
|
|
26
|
+
{label}
|
|
27
|
+
</Label>
|
|
28
|
+
) : (
|
|
29
|
+
""
|
|
30
|
+
)}
|
|
31
|
+
<Select
|
|
32
|
+
id={id}
|
|
33
|
+
onChange={(e) => onChange(e.target.value)}
|
|
34
|
+
{...inputProps}
|
|
35
|
+
>
|
|
36
|
+
{placeholder ? (
|
|
37
|
+
<option key="placeholder" value={null}>
|
|
38
|
+
{placeholder}
|
|
39
|
+
</option>
|
|
40
|
+
) : (
|
|
41
|
+
""
|
|
42
|
+
)}
|
|
43
|
+
{options.map((o) => (
|
|
44
|
+
<option key={o.value} value={o.value}>
|
|
45
|
+
{o.text}
|
|
46
|
+
</option>
|
|
47
|
+
))}
|
|
48
|
+
</Select>
|
|
49
|
+
{hint ? <Hint>{hint}</Hint> : ""}
|
|
50
|
+
</FormGroup>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const SelectMenu = ({ label, options, placeholder, onChange, value }) => (
|
|
55
|
+
<SelectField
|
|
56
|
+
label={label}
|
|
57
|
+
options={getOptions(options, placeholder)}
|
|
58
|
+
value={value}
|
|
59
|
+
onChange={onChange}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
SelectMenu.defaultProps = {
|
|
64
|
+
value: "",
|
|
65
|
+
placeholder: "Please select...",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default SelectMenu;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FormGroup, Label, Input, Textarea, Hint } from "@raketa-builder/ui";
|
|
3
|
+
import { randomString } from "../lists";
|
|
4
|
+
|
|
5
|
+
const TextField = ({ label, hint, multiline, error, onChange, ...rest }) => {
|
|
6
|
+
const id = randomString();
|
|
7
|
+
const Component = multiline ? Textarea : Input;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<FormGroup>
|
|
11
|
+
{label ? (
|
|
12
|
+
<Label htmlFor={id} error={error}>
|
|
13
|
+
{label}
|
|
14
|
+
</Label>
|
|
15
|
+
) : (
|
|
16
|
+
""
|
|
17
|
+
)}
|
|
18
|
+
<Component id={id} onChange={(e) => onChange(e.target.value)} {...rest} />
|
|
19
|
+
{hint ? <Hint>{hint}</Hint> : ""}
|
|
20
|
+
</FormGroup>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const TextInput = (props) => <TextField {...props} />;
|
|
25
|
+
|
|
26
|
+
TextInput.defaultProps = {
|
|
27
|
+
value: "",
|
|
28
|
+
placeholder: "",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default TextInput;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const toUnderscore = (string) =>
|
|
2
|
+
string.replace(/([A-Z])/g, ($1) => `_${$1.toLowerCase()}`);
|
|
3
|
+
|
|
4
|
+
export const humanize = (string) => toUnderscore(string).replace(/_/g, " ");
|
|
5
|
+
|
|
6
|
+
export const capitalize = (s) => {
|
|
7
|
+
if (typeof s !== "string") return "";
|
|
8
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
9
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const imgageSrc = (src, variant) => {
|
|
2
|
+
if (typeof src === "object" && !("name" in src))
|
|
3
|
+
console.warn(`WARNING: Image with empty {}: ${variant}`);
|
|
4
|
+
|
|
5
|
+
if (
|
|
6
|
+
typeof src === "object" &&
|
|
7
|
+
"name" in src &&
|
|
8
|
+
(src.name.includes(".svg") || src.name.includes(".gif"))
|
|
9
|
+
)
|
|
10
|
+
return src.urls.original;
|
|
11
|
+
if (typeof src === "object" && "name" in src) return src.urls[variant];
|
|
12
|
+
if (typeof src === "string") return src;
|
|
13
|
+
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default imgageSrc;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const title = (widget) => {
|
|
2
|
+
return widget.Config.title;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const adminFields = (widget) => {
|
|
6
|
+
return widget.Admin;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const category = (widget) => {
|
|
10
|
+
return widget.Config.category;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const deprecated = (widget) => {
|
|
14
|
+
return widget.Config.deprecated;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const primaryField = (widget) => {
|
|
18
|
+
return widget.Config.primaryField;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const defaults = (widget) => {
|
|
22
|
+
return widget.Defaults;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const widgetData = {
|
|
26
|
+
title,
|
|
27
|
+
adminFields,
|
|
28
|
+
category,
|
|
29
|
+
deprecated,
|
|
30
|
+
defaults,
|
|
31
|
+
primaryField,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default widgetData;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { theme, Label, FormGroup } from "@raketa-builder/ui";
|
|
4
|
+
|
|
5
|
+
import PageBuilder from "./PageBuilder";
|
|
6
|
+
import TextInput from "./forms/TextInput";
|
|
7
|
+
import TextArea from "./forms/TextArea";
|
|
8
|
+
import RichText from "./forms/RichText";
|
|
9
|
+
import SelectMenu from "./forms/SelectMenu";
|
|
10
|
+
import ImagePicker from "./pickers/ImagePicker/ImagePicker";
|
|
11
|
+
import ImageInput from "./pickers/ImagePicker/ImageInput";
|
|
12
|
+
import Dialog from "./dialogs/Dialog";
|
|
13
|
+
import Img from "./lib/Image";
|
|
14
|
+
import List from "./List";
|
|
15
|
+
import Container from "./Container";
|
|
16
|
+
import EmbeddedVideo from "./EmbeddedVideo";
|
|
17
|
+
import MediaManager from "./MediaManager";
|
|
18
|
+
import ListInput from "./ListInput";
|
|
19
|
+
import imageSrc from "./helpers/imageSrc";
|
|
20
|
+
import Button from "./forms/Button";
|
|
21
|
+
import ButtonSettings from "./forms/ButtonSettings";
|
|
22
|
+
import LinkSettings from "./forms/LinkSettings";
|
|
23
|
+
import Link from "./lib/Link";
|
|
24
|
+
import BuilderContext from "./contexts/BuilderContext";
|
|
25
|
+
|
|
26
|
+
const RaketaUIProvider = ({ theme, children }) => (
|
|
27
|
+
<ThemeProvider theme={theme}>{children}</ThemeProvider>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
RaketaUIProvider.defaultProps = {
|
|
31
|
+
theme: theme,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
PageBuilder,
|
|
36
|
+
TextInput,
|
|
37
|
+
TextArea,
|
|
38
|
+
RichText,
|
|
39
|
+
SelectMenu,
|
|
40
|
+
Dialog,
|
|
41
|
+
Img,
|
|
42
|
+
List,
|
|
43
|
+
Container,
|
|
44
|
+
EmbeddedVideo,
|
|
45
|
+
MediaManager,
|
|
46
|
+
ImagePicker,
|
|
47
|
+
ImageInput,
|
|
48
|
+
ListInput,
|
|
49
|
+
imageSrc,
|
|
50
|
+
Button,
|
|
51
|
+
ButtonSettings,
|
|
52
|
+
LinkSettings,
|
|
53
|
+
Link,
|
|
54
|
+
Label,
|
|
55
|
+
theme,
|
|
56
|
+
FormGroup,
|
|
57
|
+
RaketaUIProvider,
|
|
58
|
+
BuilderContext,
|
|
59
|
+
};
|