@flozy/editor 8.0.7 → 8.0.8

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 (132) hide show
  1. package/dist/Editor/ChatEditor.js +2 -1
  2. package/dist/Editor/CommonEditor.js +112 -33
  3. package/dist/Editor/DialogWrapper.js +31 -25
  4. package/dist/Editor/Editor.css +32 -16
  5. package/dist/Editor/Elements/AppHeader/AppHeader.js +3 -3
  6. package/dist/Editor/Elements/Button/EditorButton.js +25 -9
  7. package/dist/Editor/Elements/Color Picker/ColorButtons.js +57 -12
  8. package/dist/Editor/Elements/Color Picker/ColorPicker.css +25 -1
  9. package/dist/Editor/Elements/Color Picker/ColorPicker.js +9 -7
  10. package/dist/Editor/Elements/Color Picker/Styles.js +1 -1
  11. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +4 -1
  12. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +3 -4
  13. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +6 -1
  14. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +19 -9
  15. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +1 -1
  16. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +32 -2
  17. package/dist/Editor/Elements/DataView/Layouts/TableView.js +126 -29
  18. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +3 -3
  19. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +1 -1
  20. package/dist/Editor/Elements/DataView/styles.js +8 -8
  21. package/dist/Editor/Elements/Embed/Image.js +2 -2
  22. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +0 -14
  23. package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +2 -1
  24. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +2 -1
  25. package/dist/Editor/Elements/FreeGrid/styles.js +3 -0
  26. package/dist/Editor/Elements/Grid/GridItem.js +2 -3
  27. package/dist/Editor/Elements/Link/Link.js +70 -43
  28. package/dist/Editor/Elements/SimpleText/index.js +7 -12
  29. package/dist/Editor/Elements/SimpleText/style.js +2 -2
  30. package/dist/Editor/Elements/Table/Table.js +17 -16
  31. package/dist/Editor/Elements/Table/TableCell.js +4 -3
  32. package/dist/Editor/Elements/Title/title.js +13 -1
  33. package/dist/Editor/Elements/Variables/Style.js +28 -2
  34. package/dist/Editor/Elements/Variables/VariableButton.js +17 -4
  35. package/dist/Editor/Styles/EditorStyles.js +287 -291
  36. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +27 -3
  37. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -3
  38. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +2 -2
  39. package/dist/Editor/Toolbar/FormatTools/TextSize.js +7 -15
  40. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +1 -0
  41. package/dist/Editor/Toolbar/PopupTool/AddTemplates.js +9 -8
  42. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectFontSize.js +6 -13
  43. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/SelectTypography.js +210 -85
  44. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +2 -1
  45. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +16 -12
  46. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +56 -9
  47. package/dist/Editor/Toolbar/PopupTool/ThemeTextFormat.js +438 -0
  48. package/dist/Editor/Toolbar/PopupTool/index.js +34 -56
  49. package/dist/Editor/Toolbar/toolbarGroups.js +48 -6
  50. package/dist/Editor/assets/svg/ThemeIcons.js +291 -0
  51. package/dist/Editor/common/ColorPickerButton.js +35 -9
  52. package/dist/Editor/common/CustomColorPicker/index.js +106 -0
  53. package/dist/Editor/common/CustomColorPicker/style.js +53 -0
  54. package/dist/Editor/common/CustomDialog/index.js +90 -0
  55. package/dist/Editor/common/CustomDialog/style.js +67 -0
  56. package/dist/Editor/common/CustomDialog/styles.js +80 -0
  57. package/dist/Editor/common/CustomSelect.js +33 -0
  58. package/dist/Editor/common/DnD/DragHandleButton.js +1 -1
  59. package/dist/Editor/common/DnD/Draggable.js +0 -1
  60. package/dist/Editor/common/FontLoader/FontList.js +3 -11
  61. package/dist/Editor/common/FontLoader/FontLoader.js +74 -42
  62. package/dist/Editor/common/Icon.js +28 -0
  63. package/dist/Editor/common/ImageSelector/Options/Upload.js +2 -2
  64. package/dist/Editor/common/ImageSelector/Styles.js +3 -9
  65. package/dist/Editor/common/ImageSelector/UploadStyles.js +9 -10
  66. package/dist/Editor/common/LinkSettings/NavComponents.js +0 -5
  67. package/dist/Editor/common/LinkSettings/index.js +0 -5
  68. package/dist/Editor/common/MentionsPopup/Styles.js +6 -12
  69. package/dist/Editor/common/RnD/ElementSettings/OtherSettings/Settings.js +2 -1
  70. package/dist/Editor/common/RnD/ElementSettings/Settings/AppHeaderSettings.js +3 -2
  71. package/dist/Editor/common/RnD/ElementSettings/Settings/BoxSettings.js +3 -2
  72. package/dist/Editor/common/RnD/ElementSettings/Settings/ButtonSettings.js +3 -2
  73. package/dist/Editor/common/RnD/ElementSettings/Settings/CodeSettings.js +3 -2
  74. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +4 -2
  75. package/dist/Editor/common/RnD/ElementSettings/Settings/ImageSettings.js +3 -2
  76. package/dist/Editor/common/RnD/ElementSettings/Settings/TableSettings.js +3 -2
  77. package/dist/Editor/common/RnD/ElementSettings/Settings/VideoSettings.js +3 -2
  78. package/dist/Editor/common/RnD/ElementSettings/styles.js +0 -2
  79. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +8 -2
  80. package/dist/Editor/common/RnD/Theme/MainThemeProvider.js +17 -0
  81. package/dist/Editor/common/RnD/Theme/ViewportStimulator.js +6 -3
  82. package/dist/Editor/common/RnD/Utils/gridDropItem.js +5 -4
  83. package/dist/Editor/common/RnD/Utils/index.js +45 -0
  84. package/dist/Editor/common/RnD/index.js +23 -3
  85. package/dist/Editor/common/Section/index.js +60 -89
  86. package/dist/Editor/common/Shorthands/elements.js +54 -0
  87. package/dist/Editor/common/StyleBuilder/buttonStyle.js +4 -2
  88. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
  89. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +12 -2
  90. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +15 -7
  91. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
  92. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +35 -11
  93. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +13 -4
  94. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +15 -7
  95. package/dist/Editor/common/Uploader.js +8 -0
  96. package/dist/Editor/commonStyle.js +114 -69
  97. package/dist/Editor/helper/deserialize/index.js +1 -1
  98. package/dist/Editor/helper/index.js +2 -2
  99. package/dist/Editor/helper/theme.js +200 -2
  100. package/dist/Editor/hooks/useDrag.js +17 -11
  101. package/dist/Editor/hooks/useEditorScroll.js +1 -2
  102. package/dist/Editor/hooks/useEditorTheme.js +153 -0
  103. package/dist/Editor/hooks/useMouseMove.js +9 -3
  104. package/dist/Editor/plugins/withEmbeds.js +1 -1
  105. package/dist/Editor/plugins/withHTML.js +20 -21
  106. package/dist/Editor/plugins/withLayout.js +1 -1
  107. package/dist/Editor/plugins/withTable.js +1 -1
  108. package/dist/Editor/theme/ThemeList.js +50 -173
  109. package/dist/Editor/theme/index.js +144 -0
  110. package/dist/Editor/themeSettings/ActiveTheme.js +72 -0
  111. package/dist/Editor/themeSettings/buttons/index.js +283 -0
  112. package/dist/Editor/themeSettings/buttons/style.js +21 -0
  113. package/dist/Editor/themeSettings/colorTheme/index.js +292 -0
  114. package/dist/Editor/themeSettings/colorTheme/style.js +77 -0
  115. package/dist/Editor/themeSettings/fonts/PreviewElement.js +121 -0
  116. package/dist/Editor/themeSettings/fonts/index.js +220 -0
  117. package/dist/Editor/themeSettings/fonts/style.js +44 -0
  118. package/dist/Editor/themeSettings/icons.js +60 -0
  119. package/dist/Editor/themeSettings/index.js +320 -0
  120. package/dist/Editor/themeSettings/style.js +152 -0
  121. package/dist/Editor/themeSettingsAI/icons.js +96 -0
  122. package/dist/Editor/themeSettingsAI/index.js +356 -0
  123. package/dist/Editor/themeSettingsAI/saveTheme.js +197 -0
  124. package/dist/Editor/themeSettingsAI/style.js +250 -0
  125. package/dist/Editor/utils/SlateUtilityFunctions.js +157 -49
  126. package/dist/Editor/utils/button.js +0 -14
  127. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +23 -0
  128. package/dist/Editor/utils/draftToSlate.js +3 -2
  129. package/dist/Editor/utils/font.js +40 -37
  130. package/dist/Editor/utils/helper.js +59 -19
  131. package/dist/Editor/utils/link.js +1 -1
  132. package/package.json +6 -3
@@ -1,11 +1,15 @@
1
1
  import React, { useState } from "react";
2
- import { Box, IconButton, Popover } from "@mui/material";
2
+ import { Box, IconButton, Popover, Typography, useTheme } from "@mui/material";
3
3
  import KeyboardArrowDownRoundedIcon from "@mui/icons-material/KeyboardArrowDownRounded";
4
4
  import Button from "../../common/Button";
5
5
  import { colors } from "./defaultColors";
6
6
  import ColorPicker from "./colorPicker.svg";
7
+ import { useSlateStatic } from "slate-react";
8
+ import { Transforms } from "slate";
9
+ import { useEditorContext } from "../../hooks/useMouseMove";
7
10
  import { jsx as _jsx } from "react/jsx-runtime";
8
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { Fragment as _Fragment } from "react/jsx-runtime";
9
13
  let c = [];
10
14
  const ColorChunks = (recentColors = []) => [...recentColors, ...colors].reduce((a, b, i) => {
11
15
  if (i % 7 === 0) {
@@ -110,12 +114,18 @@ const ColorButtons = props => {
110
114
  openColorTool,
111
115
  onClose,
112
116
  onColorPickerClick,
117
+ disableEditTheme,
113
118
  defaultColors = []
114
119
  } = props;
115
120
  const [row1, ...restRows] = ColorChunks([]);
116
121
  const [anchorEl, setAnchorEl] = useState(null);
117
122
  const open = Boolean(anchorEl);
118
123
  const firstRow = defaultColors?.length ? defaultColors : row1;
124
+ const theme = useTheme();
125
+ const editor = useSlateStatic();
126
+ const {
127
+ setOpenTheme
128
+ } = useEditorContext();
119
129
  const handleMore = e => {
120
130
  setAnchorEl(e.currentTarget);
121
131
  };
@@ -128,6 +138,7 @@ const ColorButtons = props => {
128
138
  const handleSelect = color => () => {
129
139
  onSelect(color);
130
140
  };
141
+ const colorVars = theme?.vars?.colors || {};
131
142
  return /*#__PURE__*/_jsxs(Box, {
132
143
  component: "span",
133
144
  sx: classes.colorButtons,
@@ -144,7 +155,7 @@ const ColorButtons = props => {
144
155
  activeColor: activeColor
145
156
  }, `si_btn_row1_${m}_${i}`);
146
157
  })
147
- }), /*#__PURE__*/_jsxs(Popover, {
158
+ }), /*#__PURE__*/_jsx(Popover, {
148
159
  open: open || openColorTool,
149
160
  anchorEl: anchorEl || openColorTool,
150
161
  onClose: handleClose,
@@ -158,9 +169,39 @@ const ColorButtons = props => {
158
169
  },
159
170
  sx: classes.colorPopper,
160
171
  className: "colorPopper",
161
- children: [/*#__PURE__*/_jsx(Box, {
172
+ children: /*#__PURE__*/_jsxs(Box, {
162
173
  sx: classes.colorButtonsInner,
163
- children: restRows.map((m, i) => {
174
+ children: [Object.values(colorVars)?.length ? /*#__PURE__*/_jsxs(_Fragment, {
175
+ children: [/*#__PURE__*/_jsxs(Box, {
176
+ component: "div",
177
+ className: "singleColorTitleWrapper",
178
+ children: [/*#__PURE__*/_jsx(Typography, {
179
+ variant: "subtitle2",
180
+ children: "Theme colours"
181
+ }), disableEditTheme ? null : /*#__PURE__*/_jsx("div", {
182
+ className: "editBtn",
183
+ onClick: () => {
184
+ Transforms.deselect(editor, {
185
+ at: editor.selection
186
+ });
187
+ setOpenTheme("editThemeColor");
188
+ },
189
+ children: "Edit"
190
+ })]
191
+ }), /*#__PURE__*/_jsx(SingleColorButton, {
192
+ crs: Object.values(colorVars),
193
+ handleSelect: handleSelect,
194
+ classes: classes,
195
+ activeColor: activeColor
196
+ })]
197
+ }) : null, /*#__PURE__*/_jsx(Box, {
198
+ component: "div",
199
+ className: "singleColorTitleWrapper",
200
+ children: /*#__PURE__*/_jsx(Typography, {
201
+ variant: "subtitle2",
202
+ children: "Custom colour"
203
+ })
204
+ }), restRows.map((m, i) => {
164
205
  return /*#__PURE__*/_jsx(SingleColorButton, {
165
206
  id: `p2_${id}`,
166
207
  crs: m,
@@ -169,14 +210,18 @@ const ColorButtons = props => {
169
210
  classes: classes,
170
211
  activeColor: activeColor
171
212
  }, `si_btn_${m}_${i}`);
172
- })
173
- }), forMiniTool ? /*#__PURE__*/_jsx(IconButton, {
174
- onClick: onColorPickerClick,
175
- children: /*#__PURE__*/_jsx("img", {
176
- src: ColorPicker,
177
- alt: "color wheel"
178
- })
179
- }) : null]
213
+ }), forMiniTool ? /*#__PURE__*/_jsx(IconButton, {
214
+ onClick: onColorPickerClick,
215
+ style: {
216
+ alignSelf: "start",
217
+ margin: "6px"
218
+ },
219
+ children: /*#__PURE__*/_jsx("img", {
220
+ src: ColorPicker,
221
+ alt: "color wheel"
222
+ })
223
+ }) : null]
224
+ })
180
225
  })]
181
226
  });
182
227
  };
@@ -60,4 +60,28 @@
60
60
  padding: 0 15px !important;
61
61
  width: 60px !important;
62
62
  flex-shrink: 0;
63
- }
63
+ }
64
+
65
+
66
+ .singleColorTitleWrapper {
67
+ display: flex;
68
+ justify-content: space-between;
69
+ align-items: center;
70
+ padding: 10px;
71
+ width: 100%;
72
+ border-bottom: 1px solid #DCE4EC;
73
+ }
74
+
75
+ .singleColorTitleWrapper .MuiTypography-root {
76
+ font-weight: 600;
77
+ }
78
+
79
+ .singleColorTitleWrapper .editBtn {
80
+ text-transform: none;
81
+ color: #2563EB;
82
+ text-decoration: underline;
83
+ padding: 0px;
84
+ min-width: unset;
85
+ cursor: pointer;
86
+ font-size: 14px;
87
+ }
@@ -1,7 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import { ReactEditor } from "slate-react";
3
3
  import { Transforms } from "slate";
4
- import ColorPickerTool from "react-gcolor-picker";
5
4
  import { IconButton, Tooltip, Box, Popover } from "@mui/material";
6
5
  import { addMarkData, activeMark } from "../../utils/SlateUtilityFunctions";
7
6
  import ColorButtons from "./ColorButtons";
@@ -9,6 +8,7 @@ import ColorPickerStyles from "./Styles";
9
8
  import colorWheel from "./colorWheel.png";
10
9
  import "./ColorPicker.css";
11
10
  import { useEditorContext } from "../../hooks/useMouseMove";
11
+ import CustomColorPicker from "../../common/CustomColorPicker";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -43,19 +43,21 @@ const ColorPicker = props => {
43
43
  };
44
44
  const handleFormSubmit = color => {
45
45
  if (!color) return;
46
- selection && Transforms.select(editor, selection);
46
+ // selection && Transforms.select(editor, selection);
47
47
  addMarkData(editor, {
48
48
  format,
49
49
  value: color
50
50
  });
51
- selection && ReactEditor.focus(editor);
52
- handleClose();
51
+ // selection && ReactEditor.focus(editor);
52
+ // handleClose();
53
53
  };
54
+
54
55
  const onSelect = color => {
55
56
  handleFormSubmit(color);
56
57
  };
57
58
  const handleClose = () => {
58
59
  setAnchorEl(null);
60
+ setSelection(null);
59
61
  };
60
62
  const activeColor = activeMark(editor, format) || DEFAULT_COLOR[format];
61
63
  return /*#__PURE__*/_jsxs(_Fragment, {
@@ -95,10 +97,10 @@ const ColorPicker = props => {
95
97
  horizontal: "top"
96
98
  },
97
99
  sx: classes.colorPickerPopup,
98
- children: /*#__PURE__*/_jsx(ColorPickerTool, {
100
+ children: /*#__PURE__*/_jsx(CustomColorPicker, {
99
101
  gradient: true,
100
- value: activeColor,
101
- onChange: handleFormSubmit
102
+ onChange: handleFormSubmit,
103
+ color: activeColor
102
104
  })
103
105
  })]
104
106
  });
@@ -21,7 +21,7 @@ const ColorPickerStyles = theme => ({
21
21
  border: `1px solid ${theme?.palette?.editor?.miniToolBarBorder} !important`,
22
22
  borderRadius: "7px !important",
23
23
  padding: "0px 5px",
24
- '@media only screen and (max-width: 600px)': {
24
+ "@media only screen and (max-width: 600px)": {
25
25
  marginTop: "-40px"
26
26
  }
27
27
  }
@@ -16,7 +16,10 @@ const ColumnView = props => {
16
16
  selected,
17
17
  readOnly
18
18
  } = props;
19
- const DataType = DataTypes[property?.type] || DataTypes["text"];
19
+ const {
20
+ type
21
+ } = property;
22
+ const DataType = DataTypes[type] || DataTypes["text"];
20
23
  const anchorRef = useRef(null);
21
24
  const [anchorEl, setAnchorEl] = useState(null);
22
25
  const [popperRefresh, setPopperRefresh] = useState(new Date().getTime());
@@ -153,11 +153,9 @@ export default function Select(props) {
153
153
  ...optionProps,
154
154
  children: /*#__PURE__*/_jsx(Chip, {
155
155
  label: option.label || option.value || "",
156
+ classes: classes.chipText,
156
157
  sx: {
157
- background: option.color || appTheme?.palette?.editor?.tv_border1,
158
- "& .MuiChip-label": {
159
- paddingLeft: "12px !important"
160
- }
158
+ background: option.color || appTheme?.palette?.editor?.tv_border1
161
159
  },
162
160
  avatar: /*#__PURE__*/_jsx(AvatarIcon, {
163
161
  option: option,
@@ -172,6 +170,7 @@ export default function Select(props) {
172
170
  fullWidth: true,
173
171
  renderInput: params => {
174
172
  return /*#__PURE__*/_jsx(TextField, {
173
+ fullWidth: true,
175
174
  size: "small",
176
175
  ...params,
177
176
  placeholder: placeholder
@@ -3,7 +3,7 @@ const useCompStyles = (theme, appTheme) => ({
3
3
  border: `1px solid ${appTheme?.palette?.editor?.tv_border}`,
4
4
  background: appTheme?.palette?.editor?.tv_pop_bg,
5
5
  color: appTheme?.palette?.editor?.tv_text,
6
- fontSize: '14px',
6
+ fontSize: "14px",
7
7
  borderRadius: "8px",
8
8
  [theme?.breakpoints?.between("xs", "md")]: {},
9
9
  "& ul": {
@@ -63,6 +63,11 @@ const useCompStyles = (theme, appTheme) => ({
63
63
  }
64
64
  }
65
65
  }
66
+ },
67
+ chipText: {
68
+ "& .MuiChip-label": {
69
+ paddingLeft: "12px !important"
70
+ }
66
71
  }
67
72
  });
68
73
  export default useCompStyles;
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
2
  import DatePicker from "react-datepicker";
3
+ import { Grid } from "@mui/material";
3
4
  import { useDataView } from "../../Providers/DataViewProvider";
5
+ import useCommonStyle from "../../../../commonStyle";
6
+ import { useEditorContext } from "../../../../hooks/useMouseMove";
4
7
  import { jsx as _jsx } from "react/jsx-runtime";
5
8
  function isValidDate(dateString) {
6
9
  const date = new Date(dateString);
@@ -16,20 +19,27 @@ const DateType = props => {
16
19
  const {
17
20
  onChange
18
21
  } = useDataView();
22
+ const {
23
+ theme
24
+ } = useEditorContext();
25
+ const classes = useCommonStyle(theme);
19
26
  const handleChange = date => {
20
27
  onChange(rowIndex, {
21
28
  [property]: date
22
29
  });
23
30
  };
24
- return /*#__PURE__*/_jsx(DatePicker, {
25
- disabled: readOnly,
26
- selected: isValidDate(value) ? new Date(value) : "",
27
- onChange: handleChange,
28
- onKeyDown: e => {
29
- e.preventDefault();
30
- console.log(e?.target.value);
31
- },
32
- placeholderText: "MM/DD/YYYY"
31
+ return /*#__PURE__*/_jsx(Grid, {
32
+ sx: classes.datePicker,
33
+ children: /*#__PURE__*/_jsx(DatePicker, {
34
+ disabled: readOnly,
35
+ selected: isValidDate(value) ? new Date(value) : "",
36
+ onChange: handleChange,
37
+ onKeyDown: e => {
38
+ e.preventDefault();
39
+ console.log(e?.target.value);
40
+ },
41
+ placeholderText: "MM/DD/YYYY"
42
+ })
33
43
  });
34
44
  };
35
45
  export default DateType;
@@ -153,7 +153,7 @@ const useOptionsStyles = (theme, appTheme) => ({
153
153
  },
154
154
  addProperty: {
155
155
  padding: "12px",
156
- width: "253px",
156
+ minWidth: "253px",
157
157
  "& .divider_sty": {
158
158
  borderBottom: `1px solid ${appTheme?.palette?.editor?.tv_border}`
159
159
  },
@@ -10,12 +10,16 @@ const useTableStyles = (theme, appTheme) => ({
10
10
  borderSpacing: 0,
11
11
  borderRadius: "7px 7px 0px 0px",
12
12
  overflow: "hidden",
13
+ width: "auto !important",
14
+ minWidth: "100%",
13
15
  border: `1px solid ${appTheme?.palette?.editor?.tv_border}`,
16
+ tableLayout: "fixed",
14
17
  "& thead": {
15
18
  background: appTheme?.palette?.editor?.tv_header,
16
19
  height: "40px"
17
20
  },
18
21
  "& th": {
22
+ position: "relative",
19
23
  "& svg": {
20
24
  "& .fillStroke": {
21
25
  stroke: appTheme?.palette?.editor?.tv_stroke
@@ -27,6 +31,8 @@ const useTableStyles = (theme, appTheme) => ({
27
31
  },
28
32
  "& td": {
29
33
  height: "40px",
34
+ maxWidth: "0px !important",
35
+ minWidth: "0px !important",
30
36
  "& input": {
31
37
  color: appTheme?.palette?.editor?.tv_text_primary,
32
38
  background: "transparent",
@@ -39,6 +45,11 @@ const useTableStyles = (theme, appTheme) => ({
39
45
  "& th, tr, td": {
40
46
  border: `1px solid ${appTheme?.palette?.editor?.tv_border}`
41
47
  },
48
+ "& th, & td": {
49
+ overflowX: "clip",
50
+ textOverflow: "ellipsis",
51
+ whiteSpace: "nowrap"
52
+ },
42
53
  "& .tv-act-btn": {
43
54
  color: appTheme?.palette?.editor?.tv_text,
44
55
  textTransform: "none",
@@ -85,13 +96,18 @@ const useTableStyles = (theme, appTheme) => ({
85
96
  paddingTop: "3px",
86
97
  paddingBottom: "3px",
87
98
  paddingLeft: "3px",
88
- maxWidth: "250px",
99
+ // maxWidth: "250px",
89
100
  overflow: "hidden",
90
101
  position: "relative",
91
102
  "& .tv-ms-tag-wrpr": {
92
103
  display: "flex",
93
104
  flexWrap: "nowrap",
94
- overflow: "auto"
105
+ overflow: "auto",
106
+ minWidth: "58px",
107
+ "& .MuiChip-deleteIcon": {
108
+ minWidth: "22px",
109
+ minHeight: "22px"
110
+ }
95
111
  },
96
112
  "&.Mui-disabled": {
97
113
  "& input": {
@@ -129,6 +145,20 @@ const useTableStyles = (theme, appTheme) => ({
129
145
  opacity: 1
130
146
  }
131
147
  }
148
+ },
149
+ cellResizer: {
150
+ position: "absolute",
151
+ cursor: "col-resize",
152
+ right: "0px",
153
+ top: 0,
154
+ width: "3px",
155
+ borderRadius: "0px",
156
+ zIndex: 1,
157
+ background: "transparent",
158
+ height: "100%",
159
+ "&:hover, &.active": {
160
+ background: "#2563EB"
161
+ }
132
162
  }
133
163
  });
134
164
  export default useTableStyles;
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useEffect, useRef, useState } from "react";
2
2
  import { Box, Button, useTheme } from "@mui/material";
3
3
  import { useDataView } from "../Providers/DataViewProvider";
4
4
  import PropertySettings from "./Options";
@@ -7,37 +7,127 @@ import useTableStyles from "./TableStyles";
7
7
  import { GridSettingsIcon, GridAddSectionIcon } from "../../../common/iconslist";
8
8
  import { useEditorContext } from "../../../hooks/useMouseMove";
9
9
  import Icon from "../../../common/Icon";
10
+ import useTableResize from "../../../utils/customHooks/useTableResize";
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  import { Fragment as _Fragment } from "react/jsx-runtime";
12
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ const Resizer = ({
15
+ classes,
16
+ onMouseDown,
17
+ height,
18
+ resizing
19
+ }) => {
20
+ return /*#__PURE__*/_jsx(_Fragment, {
21
+ children: /*#__PURE__*/_jsx(Box, {
22
+ component: "div",
23
+ className: `cell-resizer ${resizing ? "active" : ""}`,
24
+ contentEditable: false,
25
+ onPointerDown: onMouseDown,
26
+ sx: classes.cellResizer,
27
+ style: {
28
+ height: `${height}px`
29
+ }
30
+ })
31
+ });
32
+ };
13
33
  const SortIcon = props => {
14
34
  const {
15
35
  sortBy
16
36
  } = props;
17
37
  return sortBy ? sortBy === "asc" ? /*#__PURE__*/_jsx(Box, {
18
38
  sx: {
19
- '& svg': {
20
- '& path': {
39
+ "& svg": {
40
+ "& path": {
21
41
  stroke: "rgba(37, 99, 235, 1) !important"
22
42
  }
23
43
  }
24
44
  },
25
45
  children: /*#__PURE__*/_jsx(Icon, {
26
- icon: 'chervUp'
46
+ icon: "chervUp"
27
47
  })
28
48
  }) : /*#__PURE__*/_jsx(Box, {
29
49
  sx: {
30
- '& svg': {
31
- '& path': {
50
+ "& svg": {
51
+ "& path": {
32
52
  stroke: "rgba(37, 99, 235, 1) !important"
33
53
  }
34
54
  }
35
55
  },
36
56
  children: /*#__PURE__*/_jsx(Icon, {
37
- icon: 'chervDown'
57
+ icon: "chervDown"
38
58
  })
39
59
  }) : null;
40
60
  };
61
+ const THead = props => {
62
+ const thRef = useRef(null);
63
+ const [headerTextWidth, setHeaderTextWidth] = useState(200);
64
+ const {
65
+ iconType,
66
+ isSort,
67
+ classes,
68
+ onEditProperty,
69
+ m,
70
+ tableRef,
71
+ handleResize
72
+ } = props;
73
+ // do not remove extra coma it will lead to swap of variable
74
+ const [size, onMouseDown, resizing,, isDone] = useTableResize({
75
+ parentDOM: thRef?.current,
76
+ size: m?.size,
77
+ minMaxProps: {
78
+ minWidth: 30
79
+ }
80
+ });
81
+ const finalWidth = size?.width < headerTextWidth ? headerTextWidth : size?.width || 200;
82
+ useEffect(() => {
83
+ if (thRef?.current) {
84
+ const tw = (thRef?.current?.querySelectorAll(".dht-text")[0]?.getBoundingClientRect()?.width || 0) + 16 + 30;
85
+ setHeaderTextWidth(tw);
86
+ }
87
+ }, [thRef?.current, m?.label]);
88
+ useEffect(() => {
89
+ if (isDone) {
90
+ handleResize({
91
+ ...m,
92
+ size: size
93
+ });
94
+ }
95
+ }, [isDone]);
96
+ return /*#__PURE__*/_jsxs("th", {
97
+ style: {
98
+ minWidth: finalWidth,
99
+ maxWidth: finalWidth,
100
+ width: finalWidth
101
+ },
102
+ ref: thRef,
103
+ children: [/*#__PURE__*/_jsx(Box, {
104
+ sx: {
105
+ maxWidth: "100%",
106
+ overflow: "hidden"
107
+ },
108
+ children: /*#__PURE__*/_jsx(Button, {
109
+ className: "tv-act-btn la",
110
+ startIcon: /*#__PURE__*/_jsx(Icon, {
111
+ icon: iconType
112
+ }),
113
+ endIcon: /*#__PURE__*/_jsx(SortIcon, {
114
+ sortBy: isSort
115
+ }),
116
+ fullWidth: true,
117
+ onClick: onEditProperty(m),
118
+ children: /*#__PURE__*/_jsx("span", {
119
+ className: "dht-text",
120
+ children: m.label
121
+ })
122
+ })
123
+ }), /*#__PURE__*/_jsx(Resizer, {
124
+ classes: classes,
125
+ onMouseDown: onMouseDown,
126
+ height: tableRef?.current?.getBoundingClientRect()?.height,
127
+ resizing: resizing
128
+ })]
129
+ });
130
+ };
41
131
  const TableView = props => {
42
132
  const {
43
133
  theme: appTheme
@@ -48,6 +138,7 @@ const TableView = props => {
48
138
  } = props;
49
139
  const theme = useTheme();
50
140
  const classes = useTableStyles(theme, appTheme);
141
+ const tableRef = useRef(null);
51
142
  const {
52
143
  properties,
53
144
  onAddProperty,
@@ -164,6 +255,9 @@ const TableView = props => {
164
255
  setMode({});
165
256
  setAnchorEl(null);
166
257
  };
258
+ const handleResize = data => {
259
+ onUpdateProperty(data);
260
+ };
167
261
  return /*#__PURE__*/_jsxs(_Fragment, {
168
262
  children: [/*#__PURE__*/_jsx(Box, {
169
263
  component: "div",
@@ -173,6 +267,7 @@ const TableView = props => {
173
267
  children: /*#__PURE__*/_jsxs(Box, {
174
268
  component: "table",
175
269
  sx: classes.table,
270
+ ref: tableRef,
176
271
  children: [/*#__PURE__*/_jsx("thead", {
177
272
  children: /*#__PURE__*/_jsxs("tr", {
178
273
  children: [shownProperties?.map((m, i) => {
@@ -180,26 +275,23 @@ const TableView = props => {
180
275
  Icon: iconType
181
276
  } = PROPERTY_TYPES?.find(f => f.type === m.type) || {};
182
277
  const isSort = sortBy?.key === m.key ? sortBy?.operator : null;
183
- return /*#__PURE__*/_jsx("th", {
184
- style: {
185
- minWidth: "200px"
186
- },
187
- children: /*#__PURE__*/_jsx(Button, {
188
- className: "tv-act-btn la",
189
- startIcon: /*#__PURE__*/_jsx(Icon, {
190
- icon: iconType
191
- }),
192
- endIcon: /*#__PURE__*/_jsx(SortIcon, {
193
- sortBy: isSort
194
- }),
195
- fullWidth: true,
196
- onClick: onEditProperty(m),
197
- children: m.label
198
- })
278
+ return /*#__PURE__*/_jsx(THead, {
279
+ iconType: iconType,
280
+ isSort: isSort,
281
+ onEditProperty: onEditProperty,
282
+ m: m,
283
+ classes: classes,
284
+ tableRef: tableRef,
285
+ handleResize: handleResize
199
286
  }, i);
200
287
  }), !readOnly ? /*#__PURE__*/_jsxs(_Fragment, {
201
288
  children: [/*#__PURE__*/_jsx("th", {
202
289
  className: "tv-act-btn ico",
290
+ style: {
291
+ maxWidth: "80px",
292
+ minWidth: "80px",
293
+ width: "auto"
294
+ },
203
295
  children: /*#__PURE__*/_jsx(Button, {
204
296
  onClick: onAddClick,
205
297
  fullWidth: true,
@@ -207,6 +299,11 @@ const TableView = props => {
207
299
  })
208
300
  }), /*#__PURE__*/_jsx("th", {
209
301
  className: "tv-act-btn ico",
302
+ style: {
303
+ maxWidth: "80px",
304
+ minWidth: "80px",
305
+ width: "auto"
306
+ },
210
307
  children: /*#__PURE__*/_jsx(Button, {
211
308
  onClick: onSettings,
212
309
  fullWidth: true,
@@ -226,18 +323,18 @@ const TableView = props => {
226
323
  textTransform: "none",
227
324
  justifyContent: "start",
228
325
  color: appTheme?.palette?.editor?.activeColor,
229
- '& svg': {
230
- width: '18px',
231
- height: '18px',
326
+ "& svg": {
327
+ width: "18px",
328
+ height: "18px",
232
329
  strokeWidth: 1.2,
233
- '& path': {
330
+ "& path": {
234
331
  stroke: appTheme?.palette?.editor?.activeColor
235
332
  }
236
333
  },
237
- fontFamily: 'inter'
334
+ fontFamily: "inter"
238
335
  },
239
336
  startIcon: /*#__PURE__*/_jsx(Icon, {
240
- icon: 'addRounded'
337
+ icon: "addRounded"
241
338
  }),
242
339
  children: "Add new row"
243
340
  }) : null, open && !readOnly ? /*#__PURE__*/_jsx(PropertySettings, {
@@ -58,17 +58,17 @@ const ViewData = props => {
58
58
  }
59
59
  },
60
60
  children: [rows?.map((row, i) => {
61
- return /*#__PURE__*/_jsx(Box, {
61
+ return /*#__PURE__*/_jsxs(Box, {
62
62
  component: "tr",
63
63
  className: "tv-act-row",
64
- children: /*#__PURE__*/_jsx(RenderRow, {
64
+ children: [/*#__PURE__*/_jsx(RenderRow, {
65
65
  rowIndex: row?.id,
66
66
  row: row,
67
67
  properties: properties,
68
68
  onSelect: onSelect,
69
69
  selected: selectedRows?.includes(row?.id),
70
70
  readOnly: readOnly
71
- })
71
+ }), /*#__PURE__*/_jsx("td", {}), /*#__PURE__*/_jsx("td", {})]
72
72
  }, i);
73
73
  }), /*#__PURE__*/_jsx("tr", {
74
74
  style: {
@@ -1,5 +1,5 @@
1
1
  import React, { createContext, useContext, useEffect, useState } from "react";
2
- import { Editor, Transforms, Node } from "slate";
2
+ import { Transforms, Node } from "slate";
3
3
  import { PROPERTY_DEFAULTS } from "../Layouts/Options/Constants";
4
4
  import multiSortRows from "../Utils/multiSortRows";
5
5
  import globalSearch from "../Utils/globalSearch";