@flozy/editor 3.9.8 → 3.9.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +55 -45
- package/dist/Editor/CommonEditor.js +180 -111
- package/dist/Editor/Editor.css +9 -2
- package/dist/Editor/Elements/AI/AIInput.js +18 -24
- package/dist/Editor/Elements/AI/CustomSelect.js +19 -12
- package/dist/Editor/Elements/AI/PopoverAIInput.js +66 -89
- package/dist/Editor/Elements/AI/Styles.js +2 -1
- package/dist/Editor/Elements/AI/VoiceToText/AudioWave.js +73 -0
- package/dist/Editor/Elements/AI/VoiceToText/index.js +184 -0
- package/dist/Editor/Elements/AI/VoiceToText/style.js +40 -0
- package/dist/Editor/Elements/AI/helper.js +5 -3
- package/dist/Editor/Elements/Accordion/Accordion.js +74 -7
- package/dist/Editor/Elements/Accordion/AccordionBtnPopup.js +3 -2
- package/dist/Editor/Elements/Accordion/AccordionSummary.js +4 -60
- package/dist/Editor/Elements/AppHeader/AppHeader.js +26 -4
- package/dist/Editor/Elements/Button/EditorButton.js +28 -16
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +60 -17
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
- package/dist/Editor/Elements/Color Picker/Styles.js +2 -1
- package/dist/Editor/Elements/Embed/Image.js +29 -21
- package/dist/Editor/Elements/Embed/Video.js +15 -11
- package/dist/Editor/Elements/Emoji/EmojiPicker.js +4 -2
- package/dist/Editor/Elements/Form/Form.js +1 -1
- package/dist/Editor/Elements/Form/Workflow/FormWorkflow.js +12 -3
- package/dist/Editor/Elements/Form/Workflow/UserInputs.js +2 -1
- package/dist/Editor/Elements/Grid/Grid.js +33 -16
- package/dist/Editor/Elements/Grid/GridItem.js +3 -1
- package/dist/Editor/Elements/Link/Link.js +6 -1
- package/dist/Editor/Elements/Link/LinkButton.js +4 -2
- package/dist/Editor/Elements/Link/LinkPopup.js +10 -3
- package/dist/Editor/Elements/Link/LinkPopupStyles.js +28 -0
- package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +8 -4
- package/dist/Editor/Elements/Redo/RedoButton.js +14 -0
- package/dist/Editor/Elements/Signature/SignaturePopup.js +20 -5
- package/dist/Editor/Elements/Table/Styles.js +23 -1
- package/dist/Editor/Elements/Table/Table.js +3 -2
- package/dist/Editor/Elements/Table/TableCell.js +70 -8
- package/dist/Editor/Elements/TableContextMenu/TableContextMenu.js +1 -0
- package/dist/Editor/Elements/Undo/UndoButton.js +14 -0
- package/dist/Editor/MiniEditor.js +3 -1
- package/dist/Editor/Styles/EditorStyles.js +1 -1
- package/dist/Editor/Toolbar/Basic/index.js +4 -2
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +26 -2
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +29 -18
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +29 -3
- package/dist/Editor/Toolbar/Mini/Options/Options.js +10 -0
- package/dist/Editor/Toolbar/Mini/Styles.js +7 -0
- package/dist/Editor/Toolbar/PopupTool/ButtonTemplatesCard.js +12 -13
- package/dist/Editor/Toolbar/PopupTool/FullViewCard.js +12 -13
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +4 -11
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +213 -86
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +40 -33
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +52 -7
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +438 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +4 -5
- package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
- package/dist/Editor/assets/svg/AIIcons.js +153 -1
- package/dist/Editor/assets/svg/AddTemplateIcon.js +13 -10
- package/dist/Editor/assets/svg/RedoIcon.js +27 -0
- package/dist/Editor/assets/svg/SettingsIcon.js +28 -0
- package/dist/Editor/assets/svg/TextIcon.js +8 -5
- package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
- package/dist/Editor/assets/svg/UndoIcon.js +27 -0
- package/dist/Editor/common/ColorPickerButton.js +25 -9
- package/dist/Editor/common/CustomColorPicker/index.js +106 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog/index.js +94 -0
- package/dist/Editor/common/CustomDialog/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +33 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +56 -47
- package/dist/Editor/common/EditorCmds.js +35 -0
- package/dist/Editor/common/Icon.js +43 -3
- package/dist/Editor/common/LinkSettings/NavComponents.js +5 -2
- package/dist/Editor/common/LinkSettings/index.js +4 -2
- package/dist/Editor/common/LinkSettings/navOptions.js +7 -2
- package/dist/Editor/common/LinkSettings/style.js +11 -8
- package/dist/Editor/common/MentionsPopup/MentionsListCard.js +6 -1
- package/dist/Editor/common/MentionsPopup/Styles.js +5 -2
- package/dist/Editor/common/Section/index.js +57 -7
- package/dist/Editor/common/Section/styles.js +11 -0
- package/dist/Editor/common/Shorthands/elements.js +54 -0
- package/dist/Editor/common/StyleBuilder/accordionTitleBtnStyle.js +7 -7
- package/dist/Editor/common/StyleBuilder/accordionTitleStyle.js +16 -16
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +13 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/buttonLink.js +1 -1
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +31 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
- package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +14 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +14 -4
- package/dist/Editor/common/StyleBuilder/index.js +1 -1
- package/dist/Editor/common/iconslist.js +0 -31
- package/dist/Editor/helper/deserialize/index.js +14 -9
- package/dist/Editor/helper/theme.js +190 -4
- package/dist/Editor/hooks/useEditorTheme.js +139 -0
- package/dist/Editor/hooks/useMouseMove.js +4 -2
- package/dist/Editor/hooks/useWindowMessage.js +10 -7
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +47 -5
- package/dist/Editor/plugins/withLayout.js +15 -10
- package/dist/Editor/plugins/withTable.js +2 -2
- package/dist/Editor/theme/ThemeList.js +50 -173
- package/dist/Editor/theme/index.js +144 -0
- package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
- package/dist/Editor/themeSettings/buttons/index.js +290 -0
- package/dist/Editor/themeSettings/buttons/style.js +21 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +290 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +77 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +123 -0
- package/dist/Editor/themeSettings/fonts/index.js +213 -0
- package/dist/Editor/themeSettings/fonts/style.js +44 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +320 -0
- package/dist/Editor/themeSettings/style.js +152 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +356 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +190 -0
- package/dist/Editor/themeSettingsAI/style.js +247 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +161 -25
- package/dist/Editor/utils/button.js +1 -17
- package/dist/Editor/utils/draftToSlate.js +1 -1
- package/dist/Editor/utils/events.js +65 -6
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/helper.js +74 -14
- package/dist/Editor/utils/table.js +51 -43
- package/package.json +3 -2
@@ -0,0 +1,356 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button, Checkbox, CircularProgress, Divider, Drawer, FormControlLabel, Grid, IconButton, InputAdornment, Tab, Tabs, TextField, TextareaAutosize, Typography, styled } from "@mui/material";
|
3
|
+
|
4
|
+
// Style
|
5
|
+
import Style from "./style";
|
6
|
+
|
7
|
+
// icons
|
8
|
+
import { CloseIcon } from "../common/iconslist";
|
9
|
+
import { CloudIcon } from "./icons";
|
10
|
+
import { TickIcon } from "./icons";
|
11
|
+
import { ResetIcon } from "./icons";
|
12
|
+
import { useEditorTheme } from "../hooks/useEditorTheme";
|
13
|
+
import ActiveTheme from "../themeSettings/ActiveTheme";
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
15
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
16
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
17
|
+
function generateUniqueId() {
|
18
|
+
const timestamp = Date.now(); // current timestamp in milliseconds
|
19
|
+
const randomNum = Math.floor(Math.random() * 1000000); // random number for uniqueness
|
20
|
+
return `id_${timestamp}_${randomNum}`;
|
21
|
+
}
|
22
|
+
async function getTheme(fileInputRef, onThemeChange, setLoading) {
|
23
|
+
const file = fileInputRef.current?.files[0];
|
24
|
+
if (file) {
|
25
|
+
setLoading(true);
|
26
|
+
// Create a FormData object to hold the file
|
27
|
+
const formData = new FormData();
|
28
|
+
formData.append("file", file); // 'image' is the key that your backend will use to access the file
|
29
|
+
|
30
|
+
try {
|
31
|
+
// Send the file using the fetch API
|
32
|
+
const response = await fetch("https://aicheck.agenciflow.com/create", {
|
33
|
+
method: "POST",
|
34
|
+
body: formData
|
35
|
+
});
|
36
|
+
|
37
|
+
// Handle the response
|
38
|
+
if (response.ok) {
|
39
|
+
const data = await response.json(); // Assuming the response is JSON
|
40
|
+
const theme = JSON.parse(data?.response || "{}");
|
41
|
+
onThemeChange({
|
42
|
+
id: generateUniqueId(),
|
43
|
+
name: "AI Generated",
|
44
|
+
theme: theme
|
45
|
+
});
|
46
|
+
} else {
|
47
|
+
console.error("Error:", response.statusText);
|
48
|
+
}
|
49
|
+
} catch (error) {
|
50
|
+
console.error("Fetch error:", error);
|
51
|
+
}
|
52
|
+
setLoading(false);
|
53
|
+
} else {
|
54
|
+
console.log("No file selected");
|
55
|
+
}
|
56
|
+
}
|
57
|
+
const ThemeSettingsAI = props => {
|
58
|
+
const {
|
59
|
+
className,
|
60
|
+
openAITheme,
|
61
|
+
setOpenAITheme
|
62
|
+
} = props;
|
63
|
+
|
64
|
+
// State
|
65
|
+
// const [themeDrawer, setThemeDrawer] = useState(true);
|
66
|
+
const [themeTabType, setThemeTabType] = React.useState(0);
|
67
|
+
const [enableGenerateTheme, setEnableGenerateTheme] = React.useState(false);
|
68
|
+
const [generateTheme] = React.useState(false);
|
69
|
+
const [loading, setLoading] = React.useState(false);
|
70
|
+
const [imageSrc, setImageSrc] = useState(null);
|
71
|
+
const {
|
72
|
+
updateTheme
|
73
|
+
} = useEditorTheme();
|
74
|
+
const onThemeChange = theme => {
|
75
|
+
updateTheme(theme, {
|
76
|
+
action: "THEME_CHANGE"
|
77
|
+
});
|
78
|
+
};
|
79
|
+
|
80
|
+
// image upload
|
81
|
+
const fileInputRef = React.useRef(null);
|
82
|
+
const handleDivClick = () => {
|
83
|
+
// Trigger the click event on the hidden file input element
|
84
|
+
fileInputRef.current.click();
|
85
|
+
};
|
86
|
+
const handleImageUpload = event => {
|
87
|
+
const file = event.target.files[0];
|
88
|
+
if (file) {
|
89
|
+
const reader = new FileReader();
|
90
|
+
reader.onload = () => {
|
91
|
+
setImageSrc(reader.result);
|
92
|
+
};
|
93
|
+
reader.readAsDataURL(file);
|
94
|
+
setEnableGenerateTheme(true);
|
95
|
+
}
|
96
|
+
};
|
97
|
+
const handleTabChange = (event, newValue) => {
|
98
|
+
setThemeTabType(newValue);
|
99
|
+
};
|
100
|
+
const handleClose = () => {
|
101
|
+
setOpenAITheme(false);
|
102
|
+
};
|
103
|
+
|
104
|
+
// themeCard
|
105
|
+
// const ThemeCard = () => {
|
106
|
+
// return (
|
107
|
+
// <Grid className="themeCardWrapper">
|
108
|
+
// {/* remove selected based on condition */}
|
109
|
+
// <Grid
|
110
|
+
// container
|
111
|
+
// justifyContent={"space-between"}
|
112
|
+
// className="themeCard selected"
|
113
|
+
// >
|
114
|
+
// <TickIcon />
|
115
|
+
// <Grid>
|
116
|
+
// <Typography variant="body1" className="fs-14 fw-500">
|
117
|
+
// Slate Gray
|
118
|
+
// </Typography>
|
119
|
+
// <Typography
|
120
|
+
// variant="body2"
|
121
|
+
// color={"textSecondary"}
|
122
|
+
// className="fs-12"
|
123
|
+
// >
|
124
|
+
// Muted Elegance
|
125
|
+
// </Typography>
|
126
|
+
// </Grid>
|
127
|
+
// <Grid className="flexAlign" sx={{ gap: "5px" }}>
|
128
|
+
// <Grid className="primaryCard"></Grid>
|
129
|
+
// <Grid className="secondaryCard"></Grid>
|
130
|
+
// <Grid className="otherColors" sx={{ gap: "5px" }}>
|
131
|
+
// <Grid className="smallCard"></Grid>
|
132
|
+
// <Grid className="smallCard"></Grid>
|
133
|
+
// <Grid className="smallCard"></Grid>
|
134
|
+
// <Grid className="smallCard"></Grid>
|
135
|
+
// </Grid>
|
136
|
+
// </Grid>
|
137
|
+
// </Grid>
|
138
|
+
// </Grid>
|
139
|
+
// );
|
140
|
+
// };
|
141
|
+
|
142
|
+
return /*#__PURE__*/_jsx(Grid, {
|
143
|
+
className: className,
|
144
|
+
children: /*#__PURE__*/_jsx(Drawer, {
|
145
|
+
className: className,
|
146
|
+
open: openAITheme,
|
147
|
+
onClose: handleClose,
|
148
|
+
anchor: "right",
|
149
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
150
|
+
className: "settingsContainer",
|
151
|
+
children: [/*#__PURE__*/_jsxs(Grid, {
|
152
|
+
container: true,
|
153
|
+
justifyContent: "space-between",
|
154
|
+
wrap: "nowrap",
|
155
|
+
className: "header",
|
156
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
157
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
158
|
+
variant: "body1",
|
159
|
+
className: "title",
|
160
|
+
children: "Create theme with AI"
|
161
|
+
})
|
162
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
163
|
+
className: "closeBtn",
|
164
|
+
onClick: handleClose,
|
165
|
+
children: /*#__PURE__*/_jsx(CloseIcon, {})
|
166
|
+
})]
|
167
|
+
}), /*#__PURE__*/_jsxs(Tabs, {
|
168
|
+
value: themeTabType,
|
169
|
+
onChange: handleTabChange,
|
170
|
+
variant: "scrollable",
|
171
|
+
scrollButtons: false,
|
172
|
+
"aria-label": "scrollable prevent tabs example",
|
173
|
+
sx: {
|
174
|
+
mb: 2
|
175
|
+
},
|
176
|
+
children: [/*#__PURE__*/_jsx(Tab, {
|
177
|
+
label: /*#__PURE__*/_jsx(Typography, {
|
178
|
+
variant: "body1",
|
179
|
+
className: "fs-14 fw-500 transformNone",
|
180
|
+
children: "Image"
|
181
|
+
})
|
182
|
+
}), /*#__PURE__*/_jsx(Tab, {
|
183
|
+
label: /*#__PURE__*/_jsx(Typography, {
|
184
|
+
variant: "body1",
|
185
|
+
className: "fs-14 fw-500 transformNone",
|
186
|
+
children: "Text"
|
187
|
+
})
|
188
|
+
}), /*#__PURE__*/_jsx(Tab, {
|
189
|
+
label: /*#__PURE__*/_jsx(Typography, {
|
190
|
+
variant: "body1",
|
191
|
+
className: "fs-14 fw-500 transformNone",
|
192
|
+
children: "Image link"
|
193
|
+
})
|
194
|
+
})]
|
195
|
+
}), themeTabType === 0 && /*#__PURE__*/_jsx(Grid, {
|
196
|
+
className: "imageUpload",
|
197
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
198
|
+
container: true,
|
199
|
+
justifyContent: "center",
|
200
|
+
alignItems: "center",
|
201
|
+
className: "imgUploadInner",
|
202
|
+
onClick: handleDivClick,
|
203
|
+
children: [/*#__PURE__*/_jsx("input", {
|
204
|
+
type: "file",
|
205
|
+
accept: ".png",
|
206
|
+
ref: fileInputRef,
|
207
|
+
onChange: handleImageUpload,
|
208
|
+
style: {
|
209
|
+
display: "none"
|
210
|
+
}
|
211
|
+
}), imageSrc ? /*#__PURE__*/_jsxs(_Fragment, {
|
212
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
213
|
+
className: "resetIcon",
|
214
|
+
onClick: () => setImageSrc(null),
|
215
|
+
children: /*#__PURE__*/_jsx(ResetIcon, {})
|
216
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
217
|
+
className: "changeImgText",
|
218
|
+
children: "Change Image"
|
219
|
+
}), /*#__PURE__*/_jsx("img", {
|
220
|
+
src: imageSrc,
|
221
|
+
alt: "Uploaded Preview",
|
222
|
+
className: "uploadedImage"
|
223
|
+
})]
|
224
|
+
}) : /*#__PURE__*/_jsxs(Grid, {
|
225
|
+
container: true,
|
226
|
+
justifyContent: "center",
|
227
|
+
alignItems: "center",
|
228
|
+
direction: "column",
|
229
|
+
children: [/*#__PURE__*/_jsx(CloudIcon, {}), /*#__PURE__*/_jsx(Typography, {
|
230
|
+
variant: "body1",
|
231
|
+
className: "fw-600",
|
232
|
+
sx: {
|
233
|
+
pb: 0.5
|
234
|
+
},
|
235
|
+
children: "Upload a logo or image"
|
236
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
237
|
+
variant: "body2",
|
238
|
+
className: "fs-12",
|
239
|
+
color: "textSecondary",
|
240
|
+
children: "Click here to upload PDF, PPT, and image files."
|
241
|
+
})]
|
242
|
+
})]
|
243
|
+
})
|
244
|
+
}), themeTabType === 1 && /*#__PURE__*/_jsx(Grid, {
|
245
|
+
className: "textArea",
|
246
|
+
children: /*#__PURE__*/_jsx(TextareaAutosize, {
|
247
|
+
placeholder: "Describe the theme you are interested in..."
|
248
|
+
})
|
249
|
+
}), themeTabType === 2 && /*#__PURE__*/_jsxs(_Fragment, {
|
250
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
251
|
+
className: "textArea imageUrl invalidUrl",
|
252
|
+
children: /*#__PURE__*/_jsx(TextField, {
|
253
|
+
fullWidth: true,
|
254
|
+
placeholder: "Add Image URL",
|
255
|
+
size: "small"
|
256
|
+
// value={imageUrl}
|
257
|
+
,
|
258
|
+
id: "outlined-basic",
|
259
|
+
variant: "outlined",
|
260
|
+
InputProps: {
|
261
|
+
endAdornment: /*#__PURE__*/_jsx(InputAdornment, {
|
262
|
+
position: "end",
|
263
|
+
children: /*#__PURE__*/_jsx(TickIcon, {})
|
264
|
+
})
|
265
|
+
}
|
266
|
+
})
|
267
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
268
|
+
className: "imageUpload",
|
269
|
+
children: /*#__PURE__*/_jsx(Grid, {
|
270
|
+
container: true,
|
271
|
+
justifyContent: "center",
|
272
|
+
justifyItems: "center",
|
273
|
+
className: "imgUploadInner",
|
274
|
+
children: /*#__PURE__*/_jsx(Grid, {
|
275
|
+
container: true,
|
276
|
+
justifyContent: "center",
|
277
|
+
alignItems: "center",
|
278
|
+
direction: "column",
|
279
|
+
children: /*#__PURE__*/_jsx("img", {
|
280
|
+
src: "",
|
281
|
+
alt: ""
|
282
|
+
})
|
283
|
+
})
|
284
|
+
})
|
285
|
+
})]
|
286
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
287
|
+
children: [/*#__PURE__*/_jsx(FormControlLabel, {
|
288
|
+
sx: {
|
289
|
+
mb: 1,
|
290
|
+
mt: 1
|
291
|
+
},
|
292
|
+
control: /*#__PURE__*/_jsx(Checkbox, {
|
293
|
+
checked: enableGenerateTheme,
|
294
|
+
onChange: event => setEnableGenerateTheme(event.target.checked),
|
295
|
+
size: "small"
|
296
|
+
}),
|
297
|
+
label: /*#__PURE__*/_jsx(Typography, {
|
298
|
+
variant: "body2",
|
299
|
+
className: "fs-12",
|
300
|
+
children: "a generated theme is used, the site text style will also change."
|
301
|
+
})
|
302
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
303
|
+
container: true,
|
304
|
+
justifyContent: generateTheme ? "space-between" : "flex-end",
|
305
|
+
children: [generateTheme && /*#__PURE__*/_jsx(Button, {
|
306
|
+
className: "outlineBtn",
|
307
|
+
variant: "outlined",
|
308
|
+
size: "small",
|
309
|
+
color: "primary",
|
310
|
+
children: "Regenerate theme"
|
311
|
+
}), /*#__PURE__*/_jsxs(Button, {
|
312
|
+
variant: "contained",
|
313
|
+
size: "small",
|
314
|
+
className: `blueBtn ${enableGenerateTheme ? "eanbled" : "disabled"}`,
|
315
|
+
disabled: loading,
|
316
|
+
onClick: () => {
|
317
|
+
// setGenerateTheme(true);
|
318
|
+
getTheme(fileInputRef, onThemeChange, setLoading);
|
319
|
+
},
|
320
|
+
children: [loading ? /*#__PURE__*/_jsx(CircularProgress, {
|
321
|
+
size: 18,
|
322
|
+
style: {
|
323
|
+
marginRight: "10px"
|
324
|
+
}
|
325
|
+
}) : null, loading ? "Generating..." : "Generate Theme"]
|
326
|
+
})]
|
327
|
+
})]
|
328
|
+
}), /*#__PURE__*/_jsx(Divider, {
|
329
|
+
sx: {
|
330
|
+
mt: 2,
|
331
|
+
mb: 2
|
332
|
+
}
|
333
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
334
|
+
variant: "body1",
|
335
|
+
className: "fs-14 fw-600",
|
336
|
+
sx: {
|
337
|
+
mt: 1,
|
338
|
+
mb: 1
|
339
|
+
},
|
340
|
+
children: "Active Theme"
|
341
|
+
}), /*#__PURE__*/_jsx(Grid, {
|
342
|
+
className: "themeCardWrapper",
|
343
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
344
|
+
container: true,
|
345
|
+
justifyContent: "space-between",
|
346
|
+
className: "themeCard selected",
|
347
|
+
children: [/*#__PURE__*/_jsx(TickIcon, {}), /*#__PURE__*/_jsx(ActiveTheme, {
|
348
|
+
explore: false
|
349
|
+
})]
|
350
|
+
})
|
351
|
+
})]
|
352
|
+
})
|
353
|
+
})
|
354
|
+
});
|
355
|
+
};
|
356
|
+
export default styled(ThemeSettingsAI)(Style);
|
@@ -0,0 +1,190 @@
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
import { Button, CircularProgress, Dialog, Divider, Grid, IconButton, TextField, Typography, styled } from "@mui/material";
|
3
|
+
|
4
|
+
// Style
|
5
|
+
import Style from "./style";
|
6
|
+
|
7
|
+
// icons
|
8
|
+
import { CloseIcon } from "../common/iconslist";
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
12
|
+
const SaveTheme = props => {
|
13
|
+
const {
|
14
|
+
className,
|
15
|
+
enableGenerateTheme,
|
16
|
+
saveBtnLabel,
|
17
|
+
loading,
|
18
|
+
onSave,
|
19
|
+
defaultFormData = {}
|
20
|
+
} = props;
|
21
|
+
|
22
|
+
// State
|
23
|
+
const [saveTheme, setSaveTheme] = useState(false);
|
24
|
+
const [error, setError] = useState({});
|
25
|
+
const [form, setForm] = useState(defaultFormData);
|
26
|
+
const {
|
27
|
+
name,
|
28
|
+
mood_name
|
29
|
+
} = form;
|
30
|
+
const updateForm = update => {
|
31
|
+
setForm(prev => ({
|
32
|
+
...prev,
|
33
|
+
...update
|
34
|
+
}));
|
35
|
+
};
|
36
|
+
useEffect(() => {
|
37
|
+
setForm(defaultFormData);
|
38
|
+
}, [defaultFormData]);
|
39
|
+
const onClose = () => {
|
40
|
+
setSaveTheme(false);
|
41
|
+
setError({});
|
42
|
+
setForm({});
|
43
|
+
};
|
44
|
+
const validate = () => {
|
45
|
+
let err = {};
|
46
|
+
if (!name) {
|
47
|
+
err.name = "This field is required!";
|
48
|
+
}
|
49
|
+
if (!mood_name) {
|
50
|
+
err.mood_name = "This field is required!";
|
51
|
+
}
|
52
|
+
return err;
|
53
|
+
};
|
54
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
55
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
56
|
+
variant: "contained",
|
57
|
+
size: "small",
|
58
|
+
className: `blueBtn ${enableGenerateTheme ? "eanbled" : "disabled"}`
|
59
|
+
// disabled={!enableGenerateTheme}
|
60
|
+
,
|
61
|
+
onClick: () => setSaveTheme(true),
|
62
|
+
children: saveBtnLabel
|
63
|
+
}), /*#__PURE__*/_jsx(Dialog, {
|
64
|
+
fullWidth: true,
|
65
|
+
maxWidth: "sm",
|
66
|
+
open: saveTheme,
|
67
|
+
onClose: onClose,
|
68
|
+
className: className,
|
69
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
70
|
+
className: "saveThemeContainer",
|
71
|
+
sx: {
|
72
|
+
p: 2
|
73
|
+
},
|
74
|
+
children: [/*#__PURE__*/_jsxs(Grid, {
|
75
|
+
container: true,
|
76
|
+
justifyContent: "space-between",
|
77
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
78
|
+
variant: "h4",
|
79
|
+
sx: {
|
80
|
+
fontSize: "20px"
|
81
|
+
},
|
82
|
+
className: "fw-600",
|
83
|
+
children: "Save Your theme"
|
84
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
85
|
+
onClick: onClose,
|
86
|
+
className: "closeBtn",
|
87
|
+
children: /*#__PURE__*/_jsx(CloseIcon, {})
|
88
|
+
})]
|
89
|
+
}), /*#__PURE__*/_jsx(Divider, {
|
90
|
+
sx: {
|
91
|
+
mt: 1,
|
92
|
+
mb: 1
|
93
|
+
}
|
94
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
95
|
+
variant: "body1",
|
96
|
+
className: "fw-500",
|
97
|
+
sx: {
|
98
|
+
pb: 0.5
|
99
|
+
},
|
100
|
+
children: "Theme name"
|
101
|
+
}), /*#__PURE__*/_jsx(TextField, {
|
102
|
+
variant: "outlined",
|
103
|
+
fullWidth: true,
|
104
|
+
size: "small",
|
105
|
+
placeholder: "Ex : Forest green",
|
106
|
+
onChange: e => updateForm({
|
107
|
+
name: e.target.value
|
108
|
+
}),
|
109
|
+
value: name
|
110
|
+
}), /*#__PURE__*/_jsx(Error, {
|
111
|
+
error: error?.name
|
112
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
113
|
+
variant: "body1",
|
114
|
+
className: "fw-500",
|
115
|
+
sx: {
|
116
|
+
pt: 1,
|
117
|
+
pb: 0.5
|
118
|
+
},
|
119
|
+
children: "Category"
|
120
|
+
}), /*#__PURE__*/_jsx(TextField, {
|
121
|
+
variant: "outlined",
|
122
|
+
size: "small",
|
123
|
+
placeholder: "Ex : Nature and Calm",
|
124
|
+
fullWidth: true,
|
125
|
+
onChange: e => updateForm({
|
126
|
+
mood_name: e.target.value
|
127
|
+
}),
|
128
|
+
value: mood_name
|
129
|
+
}), /*#__PURE__*/_jsx(Error, {
|
130
|
+
error: error?.mood_name
|
131
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
132
|
+
container: true,
|
133
|
+
justifyContent: "flex-end",
|
134
|
+
sx: {
|
135
|
+
mt: 3
|
136
|
+
},
|
137
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
138
|
+
variant: "outlined",
|
139
|
+
className: "seondaryOutlineBtn",
|
140
|
+
color: "secondary",
|
141
|
+
onClick: onClose,
|
142
|
+
children: "Cancel"
|
143
|
+
}), /*#__PURE__*/_jsxs(Button, {
|
144
|
+
variant: "contained",
|
145
|
+
color: "primary",
|
146
|
+
className: "blueBtn",
|
147
|
+
sx: {
|
148
|
+
ml: 1
|
149
|
+
},
|
150
|
+
disabled: loading,
|
151
|
+
onClick: async () => {
|
152
|
+
const err = validate();
|
153
|
+
setError(err);
|
154
|
+
if (Object.keys(err)?.length) {
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
await onSave({
|
158
|
+
...form
|
159
|
+
});
|
160
|
+
onClose();
|
161
|
+
},
|
162
|
+
children: [loading ? /*#__PURE__*/_jsx(CircularProgress, {
|
163
|
+
size: 14,
|
164
|
+
style: {
|
165
|
+
marginRight: "10px"
|
166
|
+
}
|
167
|
+
}) : null, saveBtnLabel]
|
168
|
+
})]
|
169
|
+
})]
|
170
|
+
})
|
171
|
+
})]
|
172
|
+
});
|
173
|
+
};
|
174
|
+
export default styled(SaveTheme)(Style);
|
175
|
+
function Error({
|
176
|
+
error = ""
|
177
|
+
}) {
|
178
|
+
if (error) {
|
179
|
+
return /*#__PURE__*/_jsx(Typography, {
|
180
|
+
variant: "body1",
|
181
|
+
sx: {
|
182
|
+
color: "red",
|
183
|
+
mt: 1
|
184
|
+
},
|
185
|
+
children: error
|
186
|
+
});
|
187
|
+
} else {
|
188
|
+
return /*#__PURE__*/_jsx(_Fragment, {});
|
189
|
+
}
|
190
|
+
}
|