@flozy/editor 9.8.5 → 9.8.7
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/Editor/ChatEditor.js +17 -16
- package/dist/Editor/CommonEditor.js +119 -17
- package/dist/Editor/DialogWrapper.js +31 -25
- package/dist/Editor/Editor.css +17 -9
- package/dist/Editor/Elements/AI/PopoverAIInput.js +11 -3
- package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
- package/dist/Editor/Elements/Button/EditorButton.js +25 -9
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +61 -14
- package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
- package/dist/Editor/Elements/Color Picker/ColorPicker.js +10 -7
- package/dist/Editor/Elements/Color Picker/Styles.js +15 -13
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +4 -2
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +448 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +21 -6
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +5 -1
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +3 -2
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +11 -0
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +8 -4
- package/dist/Editor/Elements/Embed/Image.js +2 -2
- package/dist/Editor/Elements/Embed/Video.js +1 -1
- package/dist/Editor/Elements/Form/Workflow/Styles.js +24 -22
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +48 -22
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +25 -4
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +46 -3
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -2
- package/dist/Editor/Elements/FreeGrid/styles.js +3 -0
- package/dist/Editor/Elements/Grid/GridItem.js +1 -1
- package/dist/Editor/Elements/List/CheckList.js +4 -1
- package/dist/Editor/Elements/SimpleText/index.js +9 -1
- package/dist/Editor/Elements/SimpleText/style.js +2 -2
- package/dist/Editor/Elements/Table/Table.js +3 -3
- package/dist/Editor/Elements/Title/title.js +6 -6
- package/dist/Editor/Elements/Variables/VariableButton.js +10 -1
- package/dist/Editor/MiniEditor.js +2 -1
- package/dist/Editor/Styles/EditorStyles.js +5 -5
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +10 -13
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/MiniColorPicker.js +4 -2
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +6 -13
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +167 -42
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +7 -4
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +2 -1
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +72 -12
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +95 -23
- package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +439 -0
- package/dist/Editor/Toolbar/PopupTool/index.js +1 -1
- package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
- package/dist/Editor/assets/svg/BackIcon.js +18 -0
- package/dist/Editor/assets/svg/ClearAllRounded.js +31 -0
- package/dist/Editor/assets/svg/ResetIconNew.js +23 -0
- package/dist/Editor/assets/svg/ThemeIcons.js +293 -0
- package/dist/Editor/common/ColorPickerButton.js +38 -16
- package/dist/Editor/common/CustomColorPicker/index.js +131 -0
- package/dist/Editor/common/CustomColorPicker/style.js +53 -0
- package/dist/Editor/common/CustomDialog2/index.js +94 -0
- package/dist/Editor/common/CustomDialog2/style.js +67 -0
- package/dist/Editor/common/CustomSelect.js +43 -0
- package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
- package/dist/Editor/common/FontLoader/FontLoader.js +3 -0
- package/dist/Editor/common/Icon.js +31 -1
- package/dist/Editor/common/ImageSelector/Styles.js +3 -9
- package/dist/Editor/common/RnD/ContextMenu/CMenus.js +24 -0
- package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +4 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
- package/dist/Editor/common/RnD/ElementSettings/Settings/TextSettings.js +3 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +3 -2
- package/dist/Editor/common/RnD/ShadowElement.js +2 -1
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +8 -2
- package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
- package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +73 -9
- package/dist/Editor/common/RnD/Utils/index.js +3 -0
- package/dist/Editor/common/RnD/VirtualElement/BoxHeaderAutoAlignment.js +43 -0
- package/dist/Editor/common/RnD/VirtualElement/ForceAutoAlignment.js +44 -0
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +134 -0
- package/dist/Editor/common/RnD/VirtualElement/helper.js +382 -0
- package/dist/Editor/common/RnD/VirtualElement/index.js +187 -103
- package/dist/Editor/common/RnD/VirtualElement/styles.js +155 -7
- package/dist/Editor/common/RnD/VirtualElement/updateAutoProps.js +5 -3
- package/dist/Editor/common/RnD/index.js +59 -3
- package/dist/Editor/common/Shorthands/elements.js +54 -0
- package/dist/Editor/common/SnackBar/index.js +43 -0
- package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
- package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
- package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +16 -8
- package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +36 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +16 -7
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +7 -6
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +5 -7
- package/dist/Editor/common/Uploader.js +8 -0
- package/dist/Editor/common/iconslist.js +7 -8
- package/dist/Editor/commonStyle.js +95 -60
- package/dist/Editor/helper/textIndeces.js +58 -0
- package/dist/Editor/helper/theme.js +202 -2
- package/dist/Editor/hooks/useAutoScroll.js +38 -0
- package/dist/Editor/hooks/useEditorTheme.js +153 -0
- package/dist/Editor/hooks/useMouseMove.js +9 -3
- package/dist/Editor/hooks/useThemeValues.js +63 -0
- package/dist/Editor/plugins/withEmbeds.js +1 -1
- package/dist/Editor/plugins/withHTML.js +10 -7
- package/dist/Editor/plugins/withLinks.js +9 -10
- package/dist/Editor/plugins/withTable.js +1 -1
- package/dist/Editor/theme/ThemeList.js +50 -173
- package/dist/Editor/theme/index.js +149 -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 +23 -0
- package/dist/Editor/themeSettings/colorTheme/index.js +309 -0
- package/dist/Editor/themeSettings/colorTheme/style.js +81 -0
- package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
- package/dist/Editor/themeSettings/fonts/index.js +240 -0
- package/dist/Editor/themeSettings/fonts/style.js +62 -0
- package/dist/Editor/themeSettings/icons.js +60 -0
- package/dist/Editor/themeSettings/index.js +361 -0
- package/dist/Editor/themeSettings/style.js +292 -0
- package/dist/Editor/themeSettingsAI/icons.js +96 -0
- package/dist/Editor/themeSettingsAI/index.js +355 -0
- package/dist/Editor/themeSettingsAI/saveTheme.js +202 -0
- package/dist/Editor/themeSettingsAI/style.js +324 -0
- package/dist/Editor/utils/SlateUtilityFunctions.js +171 -45
- package/dist/Editor/utils/button.js +1 -17
- package/dist/Editor/utils/draftToSlate.js +3 -2
- package/dist/Editor/utils/font.js +40 -37
- package/dist/Editor/utils/freegrid.js +2 -3
- package/dist/Editor/utils/helper.js +90 -19
- package/package.json +4 -4
@@ -0,0 +1,149 @@
|
|
1
|
+
import { getDevice } from "../helper/theme";
|
2
|
+
const themeClassName = ".theme-element";
|
3
|
+
function getTextStyles(props) {
|
4
|
+
const {
|
5
|
+
fontSize,
|
6
|
+
textDecoration,
|
7
|
+
color,
|
8
|
+
...rest
|
9
|
+
} = props;
|
10
|
+
const device = getDevice();
|
11
|
+
const fontS = typeof fontSize === "object" ? fontSize[device] : fontSize;
|
12
|
+
return {
|
13
|
+
...rest,
|
14
|
+
'& span[data-slate-string="true"]': {
|
15
|
+
textDecoration,
|
16
|
+
fontSize: fontS,
|
17
|
+
color: color || "inherit"
|
18
|
+
}
|
19
|
+
|
20
|
+
// "&::after": {
|
21
|
+
// // for placeholder
|
22
|
+
// fontSize,
|
23
|
+
// },
|
24
|
+
};
|
25
|
+
}
|
26
|
+
|
27
|
+
const transformHeading = (props, elementType) => {
|
28
|
+
return {
|
29
|
+
[`& ${elementType}${themeClassName}`]: getTextStyles(props)
|
30
|
+
};
|
31
|
+
};
|
32
|
+
const transformParagraph = (props, paraType) => {
|
33
|
+
return {
|
34
|
+
[`& p${themeClassName}.${paraType}`]: getTextStyles(props)
|
35
|
+
};
|
36
|
+
};
|
37
|
+
const transformButton = props => {
|
38
|
+
const {
|
39
|
+
borderRadius,
|
40
|
+
lockRadius,
|
41
|
+
bannerSpacing,
|
42
|
+
buttonIcon,
|
43
|
+
hover,
|
44
|
+
...classProps
|
45
|
+
} = props;
|
46
|
+
return {
|
47
|
+
[`& .button${themeClassName}`]: {
|
48
|
+
...classProps,
|
49
|
+
"&:hover": hover
|
50
|
+
},
|
51
|
+
buttonTheme: {
|
52
|
+
borderRadius,
|
53
|
+
lockRadius,
|
54
|
+
bannerSpacing,
|
55
|
+
buttonIcon
|
56
|
+
}
|
57
|
+
};
|
58
|
+
};
|
59
|
+
const transformProps = (elementType, props) => {
|
60
|
+
let transformedProp = {};
|
61
|
+
let otherProps = {};
|
62
|
+
switch (elementType) {
|
63
|
+
case "h1":
|
64
|
+
case "h2":
|
65
|
+
case "h3":
|
66
|
+
case "h4":
|
67
|
+
case "h5":
|
68
|
+
case "h6":
|
69
|
+
transformedProp = transformHeading(props, elementType);
|
70
|
+
break;
|
71
|
+
case "para1":
|
72
|
+
case "para2":
|
73
|
+
case "para3":
|
74
|
+
transformedProp = transformParagraph(props, elementType);
|
75
|
+
break;
|
76
|
+
case "button":
|
77
|
+
const {
|
78
|
+
buttonTheme,
|
79
|
+
...classProps
|
80
|
+
} = transformButton(props, elementType);
|
81
|
+
transformedProp = classProps;
|
82
|
+
otherProps = {
|
83
|
+
buttonTheme
|
84
|
+
};
|
85
|
+
break;
|
86
|
+
default:
|
87
|
+
}
|
88
|
+
return {
|
89
|
+
transformedProp,
|
90
|
+
otherProps
|
91
|
+
};
|
92
|
+
};
|
93
|
+
export const transformTheme = (selectedTheme = {}) => {
|
94
|
+
let sxProps = {};
|
95
|
+
let others = {};
|
96
|
+
const {
|
97
|
+
elementProps
|
98
|
+
} = selectedTheme;
|
99
|
+
if (elementProps) {
|
100
|
+
Object.entries(elementProps).forEach(([key, value]) => {
|
101
|
+
const {
|
102
|
+
transformedProp,
|
103
|
+
otherProps
|
104
|
+
} = transformProps(key, value);
|
105
|
+
sxProps = {
|
106
|
+
...sxProps,
|
107
|
+
...transformedProp
|
108
|
+
};
|
109
|
+
others = {
|
110
|
+
...others,
|
111
|
+
...otherProps
|
112
|
+
};
|
113
|
+
});
|
114
|
+
}
|
115
|
+
return {
|
116
|
+
sxProps,
|
117
|
+
...others
|
118
|
+
};
|
119
|
+
};
|
120
|
+
export const defaultTheme = {
|
121
|
+
theme: {
|
122
|
+
cssVars: {},
|
123
|
+
elementProps: {
|
124
|
+
button: {
|
125
|
+
color: "#FFFFFF",
|
126
|
+
background: "#2563EB",
|
127
|
+
fontFamily: "PoppinsRegular",
|
128
|
+
fontWeight: 400,
|
129
|
+
fontSize: "inherit",
|
130
|
+
borderColor: "transparent",
|
131
|
+
borderRadius: {
|
132
|
+
topLeft: 30,
|
133
|
+
topRight: 30,
|
134
|
+
bottomLeft: 30,
|
135
|
+
bottomRight: 30
|
136
|
+
},
|
137
|
+
bannerSpacing: {
|
138
|
+
left: 16,
|
139
|
+
top: 8,
|
140
|
+
right: 16,
|
141
|
+
bottom: 8
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
};
|
147
|
+
export function getTheme(selectedTheme) {
|
148
|
+
return transformTheme(selectedTheme?.theme || defaultTheme.theme);
|
149
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { Grid, Link, Typography } from "@mui/material";
|
2
|
+
import { useEditorTheme } from "../hooks/useEditorTheme";
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
5
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
6
|
+
function ActiveTheme(props) {
|
7
|
+
const {
|
8
|
+
onExplore
|
9
|
+
} = props;
|
10
|
+
const {
|
11
|
+
theme
|
12
|
+
} = useEditorTheme();
|
13
|
+
const {
|
14
|
+
colors = {}
|
15
|
+
} = theme?.theme?.cssVars || {};
|
16
|
+
const {
|
17
|
+
id,
|
18
|
+
name,
|
19
|
+
mood_name = ""
|
20
|
+
} = theme || {};
|
21
|
+
const themeColors = Object.values(colors || {});
|
22
|
+
return /*#__PURE__*/_jsxs(Grid, {
|
23
|
+
className: "activeThemeInnner",
|
24
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
25
|
+
variant: "body1",
|
26
|
+
className: "title activeThemeTitle",
|
27
|
+
children: id ? "Active Theme" : "No theme activated"
|
28
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
29
|
+
className: "flexAlign",
|
30
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
31
|
+
variant: "body1",
|
32
|
+
className: "fs-14",
|
33
|
+
children: name
|
34
|
+
}), /*#__PURE__*/_jsxs(Typography, {
|
35
|
+
variant: "body2",
|
36
|
+
className: "fs-12 textSecondary",
|
37
|
+
style: {
|
38
|
+
marginLeft: id ? "4px" : "0px"
|
39
|
+
},
|
40
|
+
children: [id ? ` - ` : null, id ? mood_name : "Select 'Explore More' to activate a theme and customize your design."]
|
41
|
+
})]
|
42
|
+
}), /*#__PURE__*/_jsxs(Grid, {
|
43
|
+
container: true,
|
44
|
+
justifyContent: "space-between",
|
45
|
+
alignItems: "end",
|
46
|
+
sx: {
|
47
|
+
mt: 1
|
48
|
+
},
|
49
|
+
children: [/*#__PURE__*/_jsx(Grid, {
|
50
|
+
className: "flexAlign",
|
51
|
+
sx: {
|
52
|
+
gap: "10px"
|
53
|
+
},
|
54
|
+
children: id ? /*#__PURE__*/_jsx(_Fragment, {
|
55
|
+
children: themeColors?.map((color, i) => {
|
56
|
+
return /*#__PURE__*/_jsx(Grid, {
|
57
|
+
className: "activeColorBox",
|
58
|
+
style: {
|
59
|
+
background: color
|
60
|
+
}
|
61
|
+
}, i);
|
62
|
+
})
|
63
|
+
}) : null
|
64
|
+
}), onExplore && /*#__PURE__*/_jsx(Link, {
|
65
|
+
className: "pointer fs-12 fw-500 exploreBtn",
|
66
|
+
onClick: onExplore,
|
67
|
+
children: "Explore More"
|
68
|
+
})]
|
69
|
+
})]
|
70
|
+
});
|
71
|
+
}
|
72
|
+
export default ActiveTheme;
|
@@ -0,0 +1,290 @@
|
|
1
|
+
import React, { useRef, useState } from "react";
|
2
|
+
import { Accordion, AccordionDetails, AccordionSummary, Button, Fade, Grid, IconButton, Popper, Typography, styled } from "@mui/material";
|
3
|
+
|
4
|
+
// Style
|
5
|
+
import Style from "./style";
|
6
|
+
import { PenIcon } from "../icons";
|
7
|
+
import StyleBuilder from "../../common/StyleBuilder";
|
8
|
+
import { fontOptions } from "../../utils/font";
|
9
|
+
import { useEditorTheme } from "../../hooks/useEditorTheme";
|
10
|
+
import { getBreakPointsValue, getElementProperty, getTRBLBreakPoints } from "../../helper/theme";
|
11
|
+
import { KeyboardArrowDownRounded } from "@mui/icons-material";
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
14
|
+
const buttonStyle = [{
|
15
|
+
tab: "General",
|
16
|
+
value: "size",
|
17
|
+
fields: [{
|
18
|
+
label: "Font Family",
|
19
|
+
key: "fontFamily",
|
20
|
+
type: "textOptions",
|
21
|
+
options: fontOptions,
|
22
|
+
webFont: true,
|
23
|
+
width: 7,
|
24
|
+
renderOption: option => {
|
25
|
+
return /*#__PURE__*/_jsx("span", {
|
26
|
+
style: {
|
27
|
+
fontFamily: option.value
|
28
|
+
},
|
29
|
+
children: option.text
|
30
|
+
});
|
31
|
+
}
|
32
|
+
}, {
|
33
|
+
label: "Font Size",
|
34
|
+
key: "textSize",
|
35
|
+
type: "fontSize",
|
36
|
+
width: 5,
|
37
|
+
placeholder: "16px or 1em"
|
38
|
+
}]
|
39
|
+
}, {
|
40
|
+
tab: "Colors",
|
41
|
+
value: "colors",
|
42
|
+
fields: [{
|
43
|
+
label: "Text Color",
|
44
|
+
key: "textColor",
|
45
|
+
type: "color",
|
46
|
+
needPreview: true
|
47
|
+
}, {
|
48
|
+
label: "Button Color",
|
49
|
+
key: "bgColor",
|
50
|
+
type: "color",
|
51
|
+
themeEnabled: true
|
52
|
+
}]
|
53
|
+
}, {
|
54
|
+
tab: "Banner Spacing",
|
55
|
+
value: "bannerSpacing",
|
56
|
+
fields: [{
|
57
|
+
label: "Banner Spacing",
|
58
|
+
key: "bannerSpacing",
|
59
|
+
type: "bannerSpacing"
|
60
|
+
}]
|
61
|
+
}, {
|
62
|
+
tab: "Border",
|
63
|
+
value: "border",
|
64
|
+
fields: [{
|
65
|
+
label: "Border Radius",
|
66
|
+
key: "borderRadius",
|
67
|
+
type: "borderRadius"
|
68
|
+
}]
|
69
|
+
}, {
|
70
|
+
tab: "Hover Colors",
|
71
|
+
value: "hoverColors",
|
72
|
+
fields: [{
|
73
|
+
label: "Hover Text Color",
|
74
|
+
key: "textColorHover",
|
75
|
+
type: "color",
|
76
|
+
needPreview: true
|
77
|
+
}, {
|
78
|
+
label: "Hover Button Color",
|
79
|
+
key: "bgColorHover",
|
80
|
+
type: "color"
|
81
|
+
}]
|
82
|
+
}];
|
83
|
+
function getBtnSxProps(buttonStyle = {}) {
|
84
|
+
const newStyle = {
|
85
|
+
...buttonStyle
|
86
|
+
};
|
87
|
+
if (newStyle?.bannerSpacing) {
|
88
|
+
newStyle.padding = newStyle?.bannerSpacing;
|
89
|
+
}
|
90
|
+
newStyle.borderRadius = {
|
91
|
+
...getBreakPointsValue(newStyle?.borderRadius || {}, null, "overrideBorderRadius", true)
|
92
|
+
};
|
93
|
+
newStyle.padding = {
|
94
|
+
...getTRBLBreakPoints(newStyle?.bannerSpacing || {})
|
95
|
+
};
|
96
|
+
delete newStyle?.bannerSpacing;
|
97
|
+
if (newStyle?.hover) {
|
98
|
+
newStyle["&:hover"] = newStyle.hover;
|
99
|
+
delete newStyle.hover;
|
100
|
+
}
|
101
|
+
return newStyle;
|
102
|
+
}
|
103
|
+
const MAP_HOVER_KEYS = {
|
104
|
+
color: "textColorHover",
|
105
|
+
background: "bgColorHover"
|
106
|
+
};
|
107
|
+
const MAP_THEME_TO_ELEMENT_KEYS = {
|
108
|
+
color: "textColor",
|
109
|
+
background: "bgColor",
|
110
|
+
fontFamily: (value, prev, buttonEl) => {
|
111
|
+
if (!buttonEl?.current) {
|
112
|
+
return prev;
|
113
|
+
}
|
114
|
+
const val = getElementProperty(buttonEl?.current, "font-family");
|
115
|
+
return {
|
116
|
+
...prev,
|
117
|
+
fontFamily: val
|
118
|
+
};
|
119
|
+
},
|
120
|
+
fontSize: "textSize",
|
121
|
+
borderRadius: "borderRadius",
|
122
|
+
bannerSpacing: "bannerSpacing",
|
123
|
+
lockRadius: "lockRadius",
|
124
|
+
lockbannerSpacing: "lockbannerSpacing",
|
125
|
+
// fontWeight
|
126
|
+
|
127
|
+
hover: (value = {}, prev = {}) => {
|
128
|
+
const props = getProps(value, MAP_HOVER_KEYS);
|
129
|
+
return {
|
130
|
+
...prev,
|
131
|
+
...props
|
132
|
+
};
|
133
|
+
}
|
134
|
+
};
|
135
|
+
const MAP_ELEMENT_TO_THEME_KEYS = {
|
136
|
+
textSize: "fontSize",
|
137
|
+
textColor: "color",
|
138
|
+
bgColor: "background",
|
139
|
+
bannerSpacing: "bannerSpacing",
|
140
|
+
borderRadius: "borderRadius",
|
141
|
+
lockRadius: "lockRadius",
|
142
|
+
lockbannerSpacing: "lockbannerSpacing",
|
143
|
+
textColorHover: (value, prev) => {
|
144
|
+
const hover = {
|
145
|
+
...(prev?.hover || {})
|
146
|
+
};
|
147
|
+
hover.color = value;
|
148
|
+
return {
|
149
|
+
...prev,
|
150
|
+
hover
|
151
|
+
};
|
152
|
+
},
|
153
|
+
bgColorHover: (value, prev) => {
|
154
|
+
const hover = {
|
155
|
+
...(prev?.hover || {})
|
156
|
+
};
|
157
|
+
hover.background = value;
|
158
|
+
return {
|
159
|
+
...prev,
|
160
|
+
hover
|
161
|
+
};
|
162
|
+
},
|
163
|
+
fontFamily: "fontFamily"
|
164
|
+
};
|
165
|
+
function getProps(buttonStyle, MAP_KEYS, buttonEl) {
|
166
|
+
let props = {};
|
167
|
+
Object.entries(buttonStyle).forEach(([key, value]) => {
|
168
|
+
const elementKey = MAP_KEYS[key];
|
169
|
+
if (elementKey) {
|
170
|
+
if (typeof elementKey === "string") {
|
171
|
+
props[elementKey] = value;
|
172
|
+
} else {
|
173
|
+
props = elementKey(value, props, buttonEl);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
});
|
177
|
+
return props;
|
178
|
+
}
|
179
|
+
function convertThemeToElementProps(button = {}, buttonEl) {
|
180
|
+
const props = getProps(button, MAP_THEME_TO_ELEMENT_KEYS, buttonEl);
|
181
|
+
return props;
|
182
|
+
}
|
183
|
+
|
184
|
+
// icons
|
185
|
+
|
186
|
+
const Buttons = props => {
|
187
|
+
const {
|
188
|
+
className,
|
189
|
+
customProps,
|
190
|
+
openSettings,
|
191
|
+
onSettingsChange,
|
192
|
+
type
|
193
|
+
} = props;
|
194
|
+
const [anchorEl, setAnchorEl] = useState();
|
195
|
+
const {
|
196
|
+
selectedTheme,
|
197
|
+
updateTheme
|
198
|
+
} = useEditorTheme();
|
199
|
+
const {
|
200
|
+
button
|
201
|
+
} = selectedTheme?.elementProps || {};
|
202
|
+
const buttonEl = useRef();
|
203
|
+
const elementProps = convertThemeToElementProps(button, buttonEl);
|
204
|
+
|
205
|
+
// State
|
206
|
+
return /*#__PURE__*/_jsxs(Grid, {
|
207
|
+
className: className,
|
208
|
+
children: [/*#__PURE__*/_jsxs(Accordion, {
|
209
|
+
className: "settingAccordion",
|
210
|
+
onChange: () => onSettingsChange(type),
|
211
|
+
expanded: openSettings === type,
|
212
|
+
children: [/*#__PURE__*/_jsx(AccordionSummary, {
|
213
|
+
expandIcon: /*#__PURE__*/_jsx(KeyboardArrowDownRounded, {}),
|
214
|
+
"aria-controls": "panel1-content",
|
215
|
+
id: "panel1-header",
|
216
|
+
children: "Buttons"
|
217
|
+
}), /*#__PURE__*/_jsx(AccordionDetails, {
|
218
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
219
|
+
container: true,
|
220
|
+
className: "buttonTypeItem",
|
221
|
+
justifyContent: "space-between",
|
222
|
+
alignItems: "center",
|
223
|
+
wrap: "nowrap",
|
224
|
+
onClick: e => setAnchorEl(e.currentTarget),
|
225
|
+
children: [/*#__PURE__*/_jsxs(Grid, {
|
226
|
+
item: true,
|
227
|
+
style: {
|
228
|
+
maxWidth: "calc(100% - 50px)",
|
229
|
+
overflowX: "auto"
|
230
|
+
},
|
231
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
232
|
+
variant: "body1",
|
233
|
+
className: "fw-600 fs-14",
|
234
|
+
style: {
|
235
|
+
marginBottom: "10px"
|
236
|
+
},
|
237
|
+
children: "Theme Button"
|
238
|
+
}), /*#__PURE__*/_jsx(Button, {
|
239
|
+
sx: getBtnSxProps(button),
|
240
|
+
ref: buttonEl,
|
241
|
+
children: "Button"
|
242
|
+
})]
|
243
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
244
|
+
className: "editIcon",
|
245
|
+
children: /*#__PURE__*/_jsx(PenIcon, {})
|
246
|
+
})]
|
247
|
+
})
|
248
|
+
})]
|
249
|
+
}), /*#__PURE__*/_jsx(Popper, {
|
250
|
+
open: Boolean(anchorEl),
|
251
|
+
anchorEl: anchorEl,
|
252
|
+
transition: true,
|
253
|
+
sx: {
|
254
|
+
zIndex: "100000",
|
255
|
+
background: "white"
|
256
|
+
},
|
257
|
+
placement: "left-start",
|
258
|
+
children: ({
|
259
|
+
TransitionProps
|
260
|
+
}) => /*#__PURE__*/_jsx(Fade, {
|
261
|
+
...TransitionProps,
|
262
|
+
timeout: 350,
|
263
|
+
children: /*#__PURE__*/_jsx("div", {
|
264
|
+
children: /*#__PURE__*/_jsx(StyleBuilder, {
|
265
|
+
title: "Button",
|
266
|
+
type: "buttonStyle",
|
267
|
+
element: elementProps,
|
268
|
+
onSave: data => {
|
269
|
+
const props = getProps(data, MAP_ELEMENT_TO_THEME_KEYS);
|
270
|
+
updateTheme(props, {
|
271
|
+
action: "ELEMENT_PROPS_CHANGE",
|
272
|
+
fieldName: "button"
|
273
|
+
});
|
274
|
+
setAnchorEl(null);
|
275
|
+
},
|
276
|
+
onClose: () => {
|
277
|
+
setAnchorEl(null);
|
278
|
+
},
|
279
|
+
renderTabs: buttonStyle,
|
280
|
+
customProps: {
|
281
|
+
disableEditTheme: true,
|
282
|
+
translation: customProps?.translation || (() => {})
|
283
|
+
}
|
284
|
+
})
|
285
|
+
})
|
286
|
+
})
|
287
|
+
})]
|
288
|
+
});
|
289
|
+
};
|
290
|
+
export default styled(Buttons)(Style);
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const Style = ({
|
2
|
+
appTheme
|
3
|
+
}) => ({
|
4
|
+
".buttonTypeItem": {
|
5
|
+
padding: "8px 10px",
|
6
|
+
width: "calc(100% + 20px)",
|
7
|
+
margin: "0 -10px",
|
8
|
+
"&:hover": {
|
9
|
+
background: appTheme?.palette?.editor?.tv_hover_bg,
|
10
|
+
".editIcon": {
|
11
|
+
opacity: "1",
|
12
|
+
visibility: "visible"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
".editIcon": {
|
16
|
+
opacity: "0",
|
17
|
+
visibility: "hidden",
|
18
|
+
width: "30px",
|
19
|
+
height: "30px"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
});
|
23
|
+
export default Style;
|