@flozy/editor 6.0.8 → 7.0.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.
Files changed (114) hide show
  1. package/dist/Editor/ChatEditor.js +7 -7
  2. package/dist/Editor/CommonEditor.js +21 -79
  3. package/dist/Editor/DialogWrapper.js +25 -31
  4. package/dist/Editor/Editor.css +16 -21
  5. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  6. package/dist/Editor/Elements/Button/EditorButton.js +9 -25
  7. package/dist/Editor/Elements/Color Picker/ColorButtons.js +12 -57
  8. package/dist/Editor/Elements/Color Picker/ColorPicker.css +1 -25
  9. package/dist/Editor/Elements/Color Picker/ColorPicker.js +4 -4
  10. package/dist/Editor/Elements/Color Picker/Styles.js +1 -1
  11. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +1 -1
  12. package/dist/Editor/Elements/Embed/Image.js +2 -2
  13. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +14 -0
  14. package/dist/Editor/Elements/FreeGrid/styles.js +0 -3
  15. package/dist/Editor/Elements/Grid/GridItem.js +3 -2
  16. package/dist/Editor/Elements/Link/Link.js +43 -70
  17. package/dist/Editor/Elements/SimpleText/index.js +12 -7
  18. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  19. package/dist/Editor/Elements/Table/Table.js +12 -12
  20. package/dist/Editor/Elements/Title/title.js +1 -13
  21. package/dist/Editor/Elements/Variables/Style.js +2 -28
  22. package/dist/Editor/Elements/Variables/VariableButton.js +4 -17
  23. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +3 -27
  24. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +3 -4
  25. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  26. package/dist/Editor/Toolbar/FormatTools/TextSize.js +15 -7
  27. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +8 -9
  28. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +13 -6
  29. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +85 -210
  30. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +1 -2
  31. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +12 -16
  32. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +9 -56
  33. package/dist/Editor/Toolbar/PopupTool/index.js +48 -32
  34. package/dist/Editor/Toolbar/toolbarGroups.js +6 -48
  35. package/dist/Editor/common/ColorPickerButton.js +9 -32
  36. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  37. package/dist/Editor/common/DnD/Draggable.js +1 -0
  38. package/dist/Editor/common/FontLoader/FontList.js +11 -3
  39. package/dist/Editor/common/FontLoader/FontLoader.js +42 -74
  40. package/dist/Editor/common/Icon.js +0 -28
  41. package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -1
  42. package/dist/Editor/common/ImageSelector/Styles.js +9 -3
  43. package/dist/Editor/common/ImageSelector/UploadStyles.js +2 -1
  44. package/dist/Editor/common/MentionsPopup/Styles.js +9 -3
  45. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +1 -2
  46. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +2 -3
  47. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +2 -3
  48. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +2 -3
  49. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +2 -3
  50. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +2 -4
  51. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +2 -3
  52. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +2 -3
  53. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +2 -3
  54. package/dist/Editor/common/RnD/ElementSettings/styles.js +1 -0
  55. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -8
  56. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +3 -6
  57. package/dist/Editor/common/RnD/Utils/gridDropItem.js +4 -5
  58. package/dist/Editor/common/RnD/Utils/index.js +0 -40
  59. package/dist/Editor/common/RnD/index.js +3 -23
  60. package/dist/Editor/common/Section/index.js +89 -60
  61. package/dist/Editor/common/Shorthands/elements.js +0 -54
  62. package/dist/Editor/common/StyleBuilder/buttonStyle.js +2 -4
  63. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
  64. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +2 -12
  65. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +7 -15
  66. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +2 -10
  67. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +11 -35
  68. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +4 -13
  69. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +7 -15
  70. package/dist/Editor/common/Uploader.js +0 -8
  71. package/dist/Editor/commonStyle.js +65 -55
  72. package/dist/Editor/helper/deserialize/index.js +1 -1
  73. package/dist/Editor/helper/index.js +2 -2
  74. package/dist/Editor/helper/theme.js +2 -200
  75. package/dist/Editor/hooks/useDrag.js +11 -17
  76. package/dist/Editor/hooks/useEditorScroll.js +2 -1
  77. package/dist/Editor/hooks/useMouseMove.js +3 -9
  78. package/dist/Editor/plugins/withEmbeds.js +1 -1
  79. package/dist/Editor/plugins/withHTML.js +9 -3
  80. package/dist/Editor/plugins/withLayout.js +1 -1
  81. package/dist/Editor/plugins/withTable.js +1 -1
  82. package/dist/Editor/theme/ThemeList.js +173 -50
  83. package/dist/Editor/utils/SlateUtilityFunctions.js +49 -157
  84. package/dist/Editor/utils/button.js +14 -0
  85. package/dist/Editor/utils/draftToSlate.js +2 -3
  86. package/dist/Editor/utils/font.js +37 -40
  87. package/dist/Editor/utils/helper.js +20 -48
  88. package/dist/Editor/utils/link.js +1 -1
  89. package/package.json +3 -6
  90. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +0 -438
  91. package/dist/Editor/assets/svg/ThemeIcons.js +0 -291
  92. package/dist/Editor/common/CustomColorPicker/index.js +0 -106
  93. package/dist/Editor/common/CustomColorPicker/style.js +0 -53
  94. package/dist/Editor/common/CustomDialog/index.js +0 -94
  95. package/dist/Editor/common/CustomDialog/style.js +0 -67
  96. package/dist/Editor/common/CustomSelect.js +0 -33
  97. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +0 -17
  98. package/dist/Editor/hooks/useEditorTheme.js +0 -153
  99. package/dist/Editor/theme/index.js +0 -144
  100. package/dist/Editor/themeSettings/ActiveTheme.js +0 -72
  101. package/dist/Editor/themeSettings/buttons/index.js +0 -283
  102. package/dist/Editor/themeSettings/buttons/style.js +0 -21
  103. package/dist/Editor/themeSettings/colorTheme/index.js +0 -292
  104. package/dist/Editor/themeSettings/colorTheme/style.js +0 -77
  105. package/dist/Editor/themeSettings/fonts/PreviewElement.js +0 -121
  106. package/dist/Editor/themeSettings/fonts/index.js +0 -220
  107. package/dist/Editor/themeSettings/fonts/style.js +0 -44
  108. package/dist/Editor/themeSettings/icons.js +0 -60
  109. package/dist/Editor/themeSettings/index.js +0 -320
  110. package/dist/Editor/themeSettings/style.js +0 -152
  111. package/dist/Editor/themeSettingsAI/icons.js +0 -96
  112. package/dist/Editor/themeSettingsAI/index.js +0 -356
  113. package/dist/Editor/themeSettingsAI/saveTheme.js +0 -197
  114. package/dist/Editor/themeSettingsAI/style.js +0 -250
@@ -1,153 +0,0 @@
1
- import { useSlate } from "slate-react";
2
- import { defaultTheme } from "../theme";
3
- import { getPageSettings, updatePageSettings } from "../utils/pageSettings";
4
- import { HEADING_THEME_FIELDS, PARAGRAPH_THEME_FIELDS } from "../helper/theme";
5
- import { useEditorContext } from "./useMouseMove";
6
- const MAP_FIELDS = {
7
- HEADING: HEADING_THEME_FIELDS,
8
- PARAGRAPH: PARAGRAPH_THEME_FIELDS
9
- };
10
- const MAP_FONT_FIELD_KEYS = {
11
- HEADING: "headingFontFamily",
12
- PARAGRAPH: "paragraphFontFamily"
13
- };
14
- function getUpdatePayload(prevTheme = {}, update, actionData) {
15
- const {
16
- action,
17
- fieldName
18
- } = actionData || {};
19
- const {
20
- theme: prev
21
- } = prevTheme;
22
- let theme = {};
23
- let themeProps = {};
24
- switch (action) {
25
- case "THEME_CHANGE":
26
- theme = update;
27
- break;
28
- case "CSS_VAR_CHANGE":
29
- const prevCssVars = prev?.cssVars || {};
30
- const prevValue = prevCssVars[fieldName] || {};
31
- themeProps = {
32
- ...(prev || {}),
33
- cssVars: {
34
- ...prevCssVars,
35
- [fieldName]: {
36
- ...prevValue,
37
- ...update
38
- }
39
- }
40
- };
41
- theme = {
42
- ...prevTheme,
43
- theme: themeProps
44
- };
45
- break;
46
- case "ELEMENT_PROPS_CHANGE":
47
- const prevEleProps = prev?.elementProps || {};
48
- const prevEleValue = prevEleProps[fieldName] || {};
49
- themeProps = {
50
- ...(prev || {}),
51
- elementProps: {
52
- ...prevEleProps,
53
- [fieldName]: {
54
- ...prevEleValue,
55
- ...update
56
- }
57
- }
58
- };
59
- theme = {
60
- ...prevTheme,
61
- theme: themeProps
62
- };
63
- break;
64
- case "OTHER_PROPS_CHANGE":
65
- themeProps = {
66
- ...(prev || {}),
67
- otherProps: {
68
- ...(prev.otherProps || {}),
69
- ...update
70
- }
71
- };
72
- theme = {
73
- ...prevTheme,
74
- theme: themeProps
75
- };
76
- break;
77
- case "FONT_CHANGE":
78
- const {
79
- elementProps = {},
80
- otherProps = {}
81
- } = prev;
82
- const {
83
- fieldType
84
- } = actionData || {};
85
- const fields = MAP_FIELDS[fieldType];
86
- const fontFieldsUpdate = {};
87
- fields?.forEach(field => {
88
- const prevFieldData = elementProps[field];
89
- fontFieldsUpdate[field] = {
90
- ...prevFieldData,
91
- ...update
92
- };
93
- });
94
- const FONT_KEY_FOR_FIELD = MAP_FONT_FIELD_KEYS[fieldType];
95
- themeProps = {
96
- ...(prev || {}),
97
- elementProps: {
98
- ...elementProps,
99
- ...fontFieldsUpdate
100
- },
101
- otherProps: {
102
- ...otherProps,
103
- [FONT_KEY_FOR_FIELD]: update?.fontFamily
104
- }
105
- };
106
- theme = {
107
- ...prevTheme,
108
- theme: themeProps
109
- };
110
- break;
111
- default:
112
- theme = {
113
- ...prevTheme,
114
- ...(update || {})
115
- };
116
- break;
117
- }
118
- return theme;
119
- }
120
- const updateTheme = (editor, pageSt, update, actionData, triggerRender) => {
121
- const {
122
- pageProps
123
- } = pageSt || {};
124
- const {
125
- theme
126
- } = pageProps || {};
127
- const updatedTheme = getUpdatePayload(theme, update, actionData);
128
- updatePageSettings(editor, {
129
- ...(pageProps || {}),
130
- theme: updatedTheme
131
- });
132
- triggerRender();
133
- };
134
- export const useEditorTheme = () => {
135
- const editor = useSlate();
136
- const {
137
- triggerRender
138
- } = useEditorContext();
139
- const {
140
- element: pageSt
141
- } = getPageSettings(editor) || {};
142
- const {
143
- pageProps
144
- } = pageSt || {};
145
- const {
146
- theme
147
- } = pageProps || {};
148
- return {
149
- selectedTheme: theme?.theme || defaultTheme?.theme,
150
- updateTheme: (update, actionData) => updateTheme(editor, pageSt, update, actionData, triggerRender),
151
- theme
152
- };
153
- };
@@ -1,144 +0,0 @@
1
- const themeClassName = ".theme-element";
2
- function getTextStyles(props) {
3
- const {
4
- fontSize,
5
- textDecoration,
6
- ...rest
7
- } = props;
8
- return {
9
- ...rest,
10
- '& span[data-slate-string="true"]': {
11
- textDecoration,
12
- fontSize
13
- }
14
-
15
- // "&::after": {
16
- // // for placeholder
17
- // fontSize,
18
- // },
19
- };
20
- }
21
-
22
- const transformHeading = (props, elementType) => {
23
- return {
24
- [`& ${elementType}${themeClassName}`]: getTextStyles(props)
25
- };
26
- };
27
- const transformParagraph = (props, paraType) => {
28
- return {
29
- [`& p${themeClassName}.${paraType}`]: getTextStyles(props)
30
- };
31
- };
32
- const transformButton = props => {
33
- const {
34
- borderRadius,
35
- lockRadius,
36
- bannerSpacing,
37
- buttonIcon,
38
- hover,
39
- ...classProps
40
- } = props;
41
- return {
42
- [`& .button${themeClassName}`]: {
43
- ...classProps,
44
- "&:hover": hover
45
- },
46
- buttonTheme: {
47
- borderRadius,
48
- lockRadius,
49
- bannerSpacing,
50
- buttonIcon
51
- }
52
- };
53
- };
54
- const transformProps = (elementType, props) => {
55
- let transformedProp = {};
56
- let otherProps = {};
57
- switch (elementType) {
58
- case "h1":
59
- case "h2":
60
- case "h3":
61
- case "h4":
62
- case "h5":
63
- case "h6":
64
- transformedProp = transformHeading(props, elementType);
65
- break;
66
- case "para1":
67
- case "para2":
68
- case "para3":
69
- transformedProp = transformParagraph(props, elementType);
70
- break;
71
- case "button":
72
- const {
73
- buttonTheme,
74
- ...classProps
75
- } = transformButton(props, elementType);
76
- transformedProp = classProps;
77
- otherProps = {
78
- buttonTheme
79
- };
80
- break;
81
- default:
82
- }
83
- return {
84
- transformedProp,
85
- otherProps
86
- };
87
- };
88
- export const transformTheme = (selectedTheme = {}) => {
89
- let sxProps = {};
90
- let others = {};
91
- const {
92
- elementProps
93
- } = selectedTheme;
94
- if (elementProps) {
95
- Object.entries(elementProps).forEach(([key, value]) => {
96
- const {
97
- transformedProp,
98
- otherProps
99
- } = transformProps(key, value);
100
- sxProps = {
101
- ...sxProps,
102
- ...transformedProp
103
- };
104
- others = {
105
- ...others,
106
- ...otherProps
107
- };
108
- });
109
- }
110
- return {
111
- sxProps,
112
- ...others
113
- };
114
- };
115
- export const defaultTheme = {
116
- theme: {
117
- cssVars: {},
118
- elementProps: {
119
- button: {
120
- color: "#FFFFFF",
121
- background: "#2563EB",
122
- fontFamily: "PoppinsRegular",
123
- fontWeight: 400,
124
- fontSize: "inherit",
125
- borderColor: "transparent",
126
- borderRadius: {
127
- topLeft: 30,
128
- topRight: 30,
129
- bottomLeft: 30,
130
- bottomRight: 30
131
- },
132
- bannerSpacing: {
133
- left: 16,
134
- top: 8,
135
- right: 16,
136
- bottom: 8
137
- }
138
- }
139
- }
140
- }
141
- };
142
- export function getTheme(selectedTheme) {
143
- return transformTheme(selectedTheme?.theme || defaultTheme.theme);
144
- }
@@ -1,72 +0,0 @@
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",
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
- color: "textSecondary",
37
- className: "fs-12",
38
- style: {
39
- marginLeft: "4px"
40
- },
41
- children: [id ? ` - ` : null, id ? mood_name : "Select 'Explore More' to activate a theme and customize your design."]
42
- })]
43
- }), /*#__PURE__*/_jsxs(Grid, {
44
- container: true,
45
- justifyContent: "space-between",
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",
66
- onClick: onExplore,
67
- children: "Explore More"
68
- })]
69
- })]
70
- });
71
- }
72
- export default ActiveTheme;
@@ -1,283 +0,0 @@
1
- import React, { useRef, useState } from "react";
2
- import { Accordion, AccordionDetails, AccordionSummary, Button, Fade, Grid, IconButton, Popper, Typography, styled } from "@mui/material";
3
- import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
4
-
5
- // Style
6
- import Style from "./style";
7
- import { PenIcon } from "../icons";
8
- import StyleBuilder from "../../common/StyleBuilder";
9
- import { fontOptions } from "../../utils/font";
10
- import { useEditorTheme } from "../../hooks/useEditorTheme";
11
- import { getBreakPointsValue, getElementProperty, getTRBLBreakPoints } from "../../helper/theme";
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
- } = props;
190
- const [anchorEl, setAnchorEl] = useState();
191
- const {
192
- selectedTheme,
193
- updateTheme
194
- } = useEditorTheme();
195
- const {
196
- button
197
- } = selectedTheme?.elementProps || {};
198
- const buttonEl = useRef();
199
- const elementProps = convertThemeToElementProps(button, buttonEl);
200
-
201
- // State
202
- return /*#__PURE__*/_jsxs(Grid, {
203
- className: className,
204
- children: [/*#__PURE__*/_jsxs(Accordion, {
205
- className: "settingAccordion",
206
- children: [/*#__PURE__*/_jsx(AccordionSummary, {
207
- expandIcon: /*#__PURE__*/_jsx(ExpandMoreIcon, {}),
208
- "aria-controls": "panel1-content",
209
- id: "panel1-header",
210
- children: "Buttons"
211
- }), /*#__PURE__*/_jsx(AccordionDetails, {
212
- children: /*#__PURE__*/_jsxs(Grid, {
213
- container: true,
214
- className: "buttonTypeItem",
215
- justifyContent: "space-between",
216
- alignItems: "center",
217
- wrap: "nowrap",
218
- onClick: e => setAnchorEl(e.currentTarget),
219
- children: [/*#__PURE__*/_jsxs(Grid, {
220
- item: true,
221
- style: {
222
- maxWidth: "calc(100% - 50px)",
223
- overflowX: "auto"
224
- },
225
- children: [/*#__PURE__*/_jsx(Typography, {
226
- variant: "body1",
227
- className: "fw-600 fs-14",
228
- style: {
229
- marginBottom: "10px"
230
- },
231
- children: "Primary Button"
232
- }), /*#__PURE__*/_jsx(Button, {
233
- sx: getBtnSxProps(button),
234
- ref: buttonEl,
235
- children: "Button"
236
- })]
237
- }), /*#__PURE__*/_jsx(IconButton, {
238
- className: "editIcon",
239
- children: /*#__PURE__*/_jsx(PenIcon, {})
240
- })]
241
- })
242
- })]
243
- }), /*#__PURE__*/_jsx(Popper, {
244
- open: Boolean(anchorEl),
245
- anchorEl: anchorEl,
246
- transition: true,
247
- sx: {
248
- zIndex: "100000",
249
- background: "white"
250
- },
251
- placement: "left-start",
252
- children: ({
253
- TransitionProps
254
- }) => /*#__PURE__*/_jsx(Fade, {
255
- ...TransitionProps,
256
- timeout: 350,
257
- children: /*#__PURE__*/_jsx("div", {
258
- children: /*#__PURE__*/_jsx(StyleBuilder, {
259
- title: "Button",
260
- type: "buttonStyle",
261
- element: elementProps,
262
- onSave: data => {
263
- const props = getProps(data, MAP_ELEMENT_TO_THEME_KEYS);
264
- updateTheme(props, {
265
- action: "ELEMENT_PROPS_CHANGE",
266
- fieldName: "button"
267
- });
268
- setAnchorEl(null);
269
- },
270
- onClose: () => {
271
- setAnchorEl(null);
272
- },
273
- renderTabs: buttonStyle,
274
- customProps: {
275
- disableEditTheme: true
276
- }
277
- })
278
- })
279
- })
280
- })]
281
- });
282
- };
283
- export default styled(Buttons)(Style);
@@ -1,21 +0,0 @@
1
- const Style = () => ({
2
- ".buttonTypeItem": {
3
- padding: "8px 10px",
4
- width: "calc(100% + 20px)",
5
- margin: "0 -10px",
6
- "&:hover": {
7
- background: "#ECF2FF",
8
- ".editIcon": {
9
- opacity: "1",
10
- visibility: "visible"
11
- }
12
- },
13
- ".editIcon": {
14
- opacity: "0",
15
- visibility: "hidden",
16
- width: "30px",
17
- height: "30px"
18
- }
19
- }
20
- });
21
- export default Style;