@flozy/editor 5.1.5 → 5.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. package/dist/Editor/ChatEditor.js +25 -34
  2. package/dist/Editor/CommonEditor.js +15 -9
  3. package/dist/Editor/Editor.css +56 -12
  4. package/dist/Editor/Elements/AI/AIInput.js +0 -1
  5. package/dist/Editor/Elements/AI/CustomSelect.js +17 -10
  6. package/dist/Editor/Elements/AI/Styles.js +7 -1
  7. package/dist/Editor/Elements/Button/EditorButton.js +1 -1
  8. package/dist/Editor/Elements/Carousel/CarouselItem.js +1 -1
  9. package/dist/Editor/Elements/Color Picker/ColorButtons.js +7 -5
  10. package/dist/Editor/Elements/Color Picker/Styles.js +7 -3
  11. package/dist/Editor/Elements/Color Picker/defaultColors.js +2 -2
  12. package/dist/Editor/Elements/DataView/DataView.js +101 -0
  13. package/dist/Editor/Elements/DataView/DataViewButton.js +23 -0
  14. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +59 -0
  15. package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +30 -0
  16. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +140 -0
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +40 -0
  18. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +59 -0
  19. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +26 -0
  20. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +38 -0
  21. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +30 -0
  22. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +30 -0
  23. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +35 -0
  24. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +36 -0
  25. package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +17 -0
  26. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +29 -0
  27. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +38 -0
  28. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +74 -0
  29. package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +64 -0
  30. package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +106 -0
  31. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +174 -0
  32. package/dist/Editor/Elements/DataView/Layouts/Formula.js +29 -0
  33. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +113 -0
  34. package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +37 -0
  35. package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +111 -0
  36. package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +62 -0
  37. package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +36 -0
  38. package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +101 -0
  39. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +160 -0
  40. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +190 -0
  41. package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +42 -0
  42. package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +30 -0
  43. package/dist/Editor/Elements/DataView/Layouts/Options/index.js +110 -0
  44. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +179 -0
  45. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +100 -0
  46. package/dist/Editor/Elements/DataView/Layouts/TableView.js +227 -0
  47. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +70 -0
  48. package/dist/Editor/Elements/DataView/Layouts/index.js +25 -0
  49. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +288 -0
  50. package/dist/Editor/Elements/DataView/Utils/globalSearch.js +15 -0
  51. package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +72 -0
  52. package/dist/Editor/Elements/DataView/styles.js +143 -0
  53. package/dist/Editor/Elements/Divider/Divider.js +15 -14
  54. package/dist/Editor/Elements/Form/Form.js +38 -2
  55. package/dist/Editor/Elements/Form/FormElements/FormCheckbox.js +7 -1
  56. package/dist/Editor/Elements/Form/FormElements/FormDate.js +7 -1
  57. package/dist/Editor/Elements/Form/FormElements/FormEmail.js +7 -1
  58. package/dist/Editor/Elements/Form/FormElements/FormNumbers.js +7 -1
  59. package/dist/Editor/Elements/Form/FormElements/FormRadioButton.js +7 -1
  60. package/dist/Editor/Elements/Form/FormElements/FormText.js +7 -1
  61. package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +6 -1
  62. package/dist/Editor/Elements/Form/FormPopup.js +12 -9
  63. package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
  64. package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +20 -1
  65. package/dist/Editor/Elements/Grid/GridButton.js +2 -1
  66. package/dist/Editor/Elements/Grid/GridItem.js +12 -0
  67. package/dist/Editor/Elements/Link/LinkButton.js +1 -1
  68. package/dist/Editor/Elements/Signature/Signature.css +1 -1
  69. package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -2
  70. package/dist/Editor/Elements/Signature/SignaturePopup.js +13 -48
  71. package/dist/Editor/Elements/SimpleText/index.js +8 -1
  72. package/dist/Editor/Elements/SimpleText/style.js +8 -1
  73. package/dist/Editor/Elements/Table/AddRowCol.js +77 -0
  74. package/dist/Editor/Elements/Table/DragButton.js +141 -0
  75. package/dist/Editor/Elements/Table/DragStyles.js +70 -0
  76. package/dist/Editor/Elements/Table/Draggable.js +25 -0
  77. package/dist/Editor/Elements/Table/Droppable.js +53 -0
  78. package/dist/Editor/Elements/Table/Styles.js +25 -43
  79. package/dist/Editor/Elements/Table/Table.js +205 -138
  80. package/dist/Editor/Elements/Table/TableCell.js +355 -102
  81. package/dist/Editor/Elements/Table/TablePopup.js +9 -3
  82. package/dist/Editor/Elements/Table/TableRow.js +10 -2
  83. package/dist/Editor/Elements/Table/TableTool.js +101 -0
  84. package/dist/Editor/Elements/Table/tableHelper.js +71 -0
  85. package/dist/Editor/Styles/EditorStyles.js +3 -1
  86. package/dist/Editor/Toolbar/FormatTools/BlockButton.js +10 -0
  87. package/dist/Editor/Toolbar/FormatTools/Dropdown.js +7 -11
  88. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +10 -4
  89. package/dist/Editor/Toolbar/FormatTools/MarkButton.js +3 -0
  90. package/dist/Editor/Toolbar/FormatTools/TextSize.js +0 -2
  91. package/dist/Editor/Toolbar/Mini/MiniToolbar.js +3 -6
  92. package/dist/Editor/Toolbar/Mini/Styles.js +4 -1
  93. package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -3
  94. package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +16 -11
  95. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +416 -49
  96. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +62 -8
  97. package/dist/Editor/Toolbar/PopupTool/index.js +5 -6
  98. package/dist/Editor/Toolbar/Toolbar.js +6 -0
  99. package/dist/Editor/Toolbar/toolbarGroups.js +4 -0
  100. package/dist/Editor/assets/svg/BrainIcon.js +2 -2
  101. package/dist/Editor/assets/svg/TableIcons.js +220 -0
  102. package/dist/Editor/common/ColorPickerButton.js +3 -2
  103. package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
  104. package/dist/Editor/common/Icon.js +24 -23
  105. package/dist/Editor/common/LinkSettings/NavComponents.js +2 -1
  106. package/dist/Editor/common/LinkSettings/index.js +2 -1
  107. package/dist/Editor/common/MentionsPopup/Styles.js +152 -7
  108. package/dist/Editor/common/MentionsPopup/index.js +1 -1
  109. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +108 -12
  110. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +14 -2
  111. package/dist/Editor/common/Select/index.js +20 -0
  112. package/dist/Editor/common/Select/styles.js +17 -0
  113. package/dist/Editor/common/Shorthands/elements.js +13 -1
  114. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +5 -0
  115. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +8 -4
  116. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +10 -2
  117. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +3 -1
  118. package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +79 -0
  119. package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +7 -7
  120. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +5 -2
  121. package/dist/Editor/common/StyleBuilder/formStyle.js +268 -149
  122. package/dist/Editor/common/StyleBuilder/index.js +84 -11
  123. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +4 -0
  124. package/dist/Editor/common/StyleBuilder/tableStyle.js +69 -25
  125. package/dist/Editor/common/SwipeableDrawer/style.js +15 -4
  126. package/dist/Editor/common/Uploader.js +8 -0
  127. package/dist/Editor/common/iconListV2.js +378 -40
  128. package/dist/Editor/common/iconslist.js +23 -17
  129. package/dist/Editor/commonStyle.js +126 -9
  130. package/dist/Editor/helper/deserialize/index.js +4 -1
  131. package/dist/Editor/helper/index.js +2 -2
  132. package/dist/Editor/helper/theme.js +24 -1
  133. package/dist/Editor/hooks/useMouseMove.js +5 -2
  134. package/dist/Editor/hooks/useTable.js +195 -0
  135. package/dist/Editor/plugins/withCustomDeleteBackward.js +3 -2
  136. package/dist/Editor/plugins/withHTML.js +17 -1
  137. package/dist/Editor/plugins/withLayout.js +48 -1
  138. package/dist/Editor/utils/SlateUtilityFunctions.js +18 -0
  139. package/dist/Editor/utils/button.js +4 -4
  140. package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +21 -0
  141. package/dist/Editor/utils/dataView.js +43 -0
  142. package/dist/Editor/utils/embed.js +2 -1
  143. package/dist/Editor/utils/events.js +0 -1
  144. package/dist/Editor/utils/font.js +11 -4
  145. package/dist/Editor/utils/formfield.js +8 -4
  146. package/dist/Editor/utils/helper.js +67 -2
  147. package/dist/Editor/utils/insertNewLine.js +19 -1
  148. package/dist/Editor/utils/pageSettings.js +14 -2
  149. package/dist/Editor/utils/serializeToText.js +2 -0
  150. package/dist/Editor/utils/table.js +228 -24
  151. package/package.json +1 -1
@@ -0,0 +1,70 @@
1
+ import React from "react";
2
+ import { Box, Button } from "@mui/material";
3
+ import AddCircleOutlineIcon from "@mui/icons-material/AddCircleOutline";
4
+ import { useDataView } from "../Providers/DataViewProvider";
5
+ import ColumnView from "./ColumnView";
6
+ // import Formula from "./Formula";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const RenderRow = props => {
9
+ const {
10
+ rowIndex,
11
+ row,
12
+ properties,
13
+ onSelect,
14
+ selected,
15
+ readOnly
16
+ } = props;
17
+ const showProperties = properties?.filter(f => f.visible);
18
+ return showProperties?.map((property, i) => {
19
+ return /*#__PURE__*/_jsx(ColumnView, {
20
+ needAnchor: i === 0,
21
+ row: row,
22
+ rowIndex: rowIndex,
23
+ property: property,
24
+ onSelect: onSelect,
25
+ selected: selected,
26
+ readOnly: readOnly
27
+ }, `${property.key}_${i}`);
28
+ });
29
+ };
30
+ const ViewData = props => {
31
+ const {
32
+ attributes,
33
+ customProps
34
+ } = props;
35
+ const {
36
+ readOnly
37
+ } = customProps || {};
38
+ const {
39
+ properties,
40
+ rows,
41
+ selectedRows,
42
+ setSelectedRows
43
+ } = useDataView();
44
+ const onSelect = (id, checked) => {
45
+ if (checked) {
46
+ setSelectedRows([...selectedRows, id]);
47
+ } else {
48
+ setSelectedRows([...selectedRows?.filter(f => f !== id)]);
49
+ }
50
+ };
51
+ return /*#__PURE__*/_jsx(Box, {
52
+ component: "tbody",
53
+ ...attributes,
54
+ children: rows?.map((row, i) => {
55
+ return /*#__PURE__*/_jsx(Box, {
56
+ component: "tr",
57
+ className: "tv-act-row",
58
+ children: /*#__PURE__*/_jsx(RenderRow, {
59
+ rowIndex: row?.id,
60
+ row: row,
61
+ properties: properties,
62
+ onSelect: onSelect,
63
+ selected: selectedRows?.includes(row?.id),
64
+ readOnly: readOnly
65
+ })
66
+ }, i);
67
+ })
68
+ });
69
+ };
70
+ export default ViewData;
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import TableView from "./TableView";
3
+ import { useDataView } from "../Providers/DataViewProvider";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ const LAYOUT_COMPONENT = {
7
+ table: TableView
8
+ };
9
+ const LayoutView = props => {
10
+ const {
11
+ readOnly,
12
+ children
13
+ } = props;
14
+ const {
15
+ layoutType
16
+ } = useDataView();
17
+ const Layout = LAYOUT_COMPONENT[layoutType] || LAYOUT_COMPONENT["table"];
18
+ return /*#__PURE__*/_jsx(_Fragment, {
19
+ children: /*#__PURE__*/_jsx(Layout, {
20
+ readOnly: readOnly,
21
+ children: children
22
+ })
23
+ });
24
+ };
25
+ export default LayoutView;
@@ -0,0 +1,288 @@
1
+ import React, { createContext, useContext, useEffect, useState } from "react";
2
+ import { Transforms } from "slate";
3
+ import { PROPERTY_DEFAULTS } from "../Layouts/Options/Constants";
4
+ import multiSortRows from "../Utils/multiSortRows";
5
+ import globalSearch from "../Utils/globalSearch";
6
+
7
+ // Data View context
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const DataViewContext = /*#__PURE__*/createContext();
10
+ export const useDataView = () => useContext(DataViewContext);
11
+ const DEFAULT_PROPERTIES = [{
12
+ key: "column1",
13
+ label: "Name",
14
+ dataType: "text"
15
+ }, {
16
+ key: "column2",
17
+ label: "Status",
18
+ dataType: "select",
19
+ options: ["Active", "Inactive"]
20
+ }, {
21
+ key: "column3",
22
+ label: "Agree?",
23
+ dataType: "checkbox"
24
+ }];
25
+
26
+ // Combined provider
27
+ export const DataViewProvider = ({
28
+ children,
29
+ ...props
30
+ }) => {
31
+ const {
32
+ initialData,
33
+ path,
34
+ editor
35
+ } = props;
36
+ const [layouts, setLayouts] = useState(initialData?.layouts || []);
37
+ const [seletectedLayout, setSelectedLayout] = useState({
38
+ ...(layouts[0] || {})
39
+ });
40
+ const [layoutType, setLayoutType] = useState(seletectedLayout?.type || "table");
41
+ const [properties, setProperties] = useState(initialData?.properties || [...DEFAULT_PROPERTIES]);
42
+ const [sort, setSort] = useState(seletectedLayout?.sort || []);
43
+ const [filter, setFilter] = useState(seletectedLayout?.filter || []);
44
+ const [rows, setRows] = useState(initialData?.rows || []);
45
+ const [selectedRows, setSelectedRows] = useState([]);
46
+ const [search, setSearch] = useState("");
47
+ const [title, setTitle] = useState(initialData?.tableTitle || "");
48
+ let {
49
+ users
50
+ } = initialData || {};
51
+ users = users?.map(m => {
52
+ return {
53
+ value: m?.name
54
+ };
55
+ });
56
+
57
+ // re-order when sort val changes
58
+ useEffect(() => {
59
+ if ((sort?.length > 0 || search) && rows?.length > 0) {
60
+ const reOrderRows = sort?.length > 0 ? multiSortRows(rows, sort, properties) : [...rows];
61
+ setRows(globalSearch(reOrderRows, search));
62
+ } else {
63
+ // reset to default order
64
+ setRows(globalSearch(initialData?.rows || [], search));
65
+ }
66
+ }, [sort, search]);
67
+ const onAddProperty = (data, overrides = {}) => {
68
+ try {
69
+ const {
70
+ type
71
+ } = data;
72
+ const key = `col_${new Date().getTime()}`;
73
+ const newProperty = {
74
+ ...(PROPERTY_DEFAULTS[type] || {}),
75
+ ...overrides,
76
+ key: key,
77
+ type
78
+ };
79
+ const updatedProperties = [...properties, {
80
+ ...newProperty
81
+ }];
82
+ Transforms.setNodes(editor, {
83
+ properties: [...updatedProperties]
84
+ }, {
85
+ at: path
86
+ });
87
+ setProperties([...updatedProperties]);
88
+ return newProperty;
89
+ } catch (err) {
90
+ console.log(err);
91
+ }
92
+ };
93
+ const onUpdateProperty = (data, isDelete = false) => {
94
+ try {
95
+ const {
96
+ key
97
+ } = data;
98
+ let up = {
99
+ ...data
100
+ };
101
+ const updatedProperties = properties?.map(m => {
102
+ if (m.key === key) {
103
+ up = {
104
+ ...m,
105
+ ...data
106
+ };
107
+ return up;
108
+ }
109
+ return m;
110
+ });
111
+ if (isDelete) {
112
+ const deleteIndex = updatedProperties.findIndex(f => f.key === key);
113
+ updatedProperties.splice(deleteIndex, 1);
114
+ }
115
+ Transforms.setNodes(editor, {
116
+ properties: [...updatedProperties]
117
+ }, {
118
+ at: path
119
+ });
120
+ setProperties([...updatedProperties]);
121
+ return up;
122
+ } catch (err) {
123
+ console.log(err);
124
+ }
125
+ };
126
+ const onChange = (rowIndex, rowData) => {
127
+ try {
128
+ const updatedRows = rows?.map(m => {
129
+ if (m?.id === rowIndex) {
130
+ m = {
131
+ ...m,
132
+ ...rowData
133
+ };
134
+ }
135
+ return m;
136
+ });
137
+ Transforms.setNodes(editor, {
138
+ rows: [...updatedRows]
139
+ }, {
140
+ at: path
141
+ });
142
+ setRows(updatedRows);
143
+ } catch (err) {
144
+ console.log(err);
145
+ }
146
+ };
147
+ const onAddRow = () => {
148
+ try {
149
+ const newRow = properties?.reduce((a, b) => {
150
+ a[b.key] = "";
151
+ return a;
152
+ }, {
153
+ id: `row_${new Date().getTime()}`
154
+ });
155
+ const updatedRows = [...rows, newRow];
156
+ Transforms.setNodes(editor, {
157
+ rows: [...updatedRows]
158
+ }, {
159
+ at: path
160
+ });
161
+ setRows(updatedRows);
162
+ } catch (err) {
163
+ console.log(err);
164
+ }
165
+ };
166
+ const formatSort = (sorts = [], sortData, isDelete = false) => {
167
+ let upSort = [];
168
+ const isUpdate = sorts?.find(f => f.key === sortData?.key);
169
+ if (isUpdate) {
170
+ // update if any
171
+ upSort = sorts?.map(m => {
172
+ if (m.key === sortData.key) {
173
+ // if update col
174
+ if (sortData["newKey"]) {
175
+ sortData["key"] = sortData["newKey"];
176
+ delete sortData["newKey"];
177
+ }
178
+ return {
179
+ ...sortData
180
+ };
181
+ }
182
+ return m;
183
+ });
184
+ } else {
185
+ upSort = [...sorts, {
186
+ ...sortData
187
+ }];
188
+ }
189
+
190
+ // if no sort
191
+ if (sorts?.length === 0 && !isDelete) {
192
+ upSort = [{
193
+ ...sortData
194
+ }];
195
+ }
196
+
197
+ // if delete
198
+ if (isDelete) {
199
+ const deleteIndex = upSort.findIndex(f => f.key === sortData.key);
200
+ upSort.splice(deleteIndex, 1);
201
+ }
202
+ return upSort;
203
+ };
204
+ const onUpdateSort = (sortData = {}, isDelete = false, deleteAll = false) => {
205
+ try {
206
+ let upSort = {};
207
+ const updatedLayouts = layouts?.map((m, i) => {
208
+ if (seletectedLayout?.key === m.key) {
209
+ upSort = !deleteAll ? formatSort(m?.sort || [], sortData, isDelete) : [];
210
+ return {
211
+ ...m,
212
+ sort: [...upSort]
213
+ };
214
+ }
215
+ return m;
216
+ });
217
+ Transforms.setNodes(editor, {
218
+ layouts: [...updatedLayouts]
219
+ }, {
220
+ at: path
221
+ });
222
+ setLayouts(updatedLayouts);
223
+ setSort(upSort);
224
+ } catch (err) {
225
+ console.log(err);
226
+ }
227
+ };
228
+ const onDeleteRows = () => {
229
+ try {
230
+ const updatedRows = [...rows].filter(f => selectedRows.includes(f.id) === false);
231
+ Transforms.setNodes(editor, {
232
+ rows: [...updatedRows]
233
+ }, {
234
+ at: path
235
+ });
236
+ setRows(updatedRows);
237
+ setSelectedRows([]);
238
+ } catch (err) {
239
+ console.log(err);
240
+ }
241
+ };
242
+ const onSearch = e => {
243
+ setSearch(e?.target?.value);
244
+ };
245
+ const onTitleChange = value => {
246
+ try {
247
+ Transforms.setNodes(editor, {
248
+ title: value
249
+ }, {
250
+ at: path
251
+ });
252
+ setTitle(value);
253
+ } catch (err) {
254
+ console.log(err);
255
+ }
256
+ };
257
+ const value = {
258
+ layoutType,
259
+ setLayoutType,
260
+ properties,
261
+ setProperties,
262
+ rows,
263
+ setRows,
264
+ onAddProperty,
265
+ layouts,
266
+ setLayouts,
267
+ onUpdateProperty,
268
+ onChange,
269
+ onAddRow,
270
+ users: users,
271
+ onUpdateSort,
272
+ sort,
273
+ filter,
274
+ setSelectedLayout,
275
+ setFilter,
276
+ selectedRows,
277
+ setSelectedRows,
278
+ onDeleteRows,
279
+ search,
280
+ onSearch,
281
+ title,
282
+ setTitle: onTitleChange
283
+ };
284
+ return /*#__PURE__*/_jsx(DataViewContext.Provider, {
285
+ value: value,
286
+ children: children
287
+ });
288
+ };
@@ -0,0 +1,15 @@
1
+ const globalSearch = (array, searchTerm) => {
2
+ if (!searchTerm) {
3
+ return array;
4
+ }
5
+ const lowerCaseSearchTerm = searchTerm.toLowerCase();
6
+ return array.filter(item => Object.values(item).some(value => {
7
+ if (typeof value === "string" && value) {
8
+ return value?.toLowerCase().includes(lowerCaseSearchTerm);
9
+ } else if (Array.isArray(value)) {
10
+ return value?.map(m => m?.value).some(d => d.toLowerCase().includes(lowerCaseSearchTerm));
11
+ }
12
+ return false;
13
+ }));
14
+ };
15
+ export default globalSearch;
@@ -0,0 +1,72 @@
1
+ function sortByDate(a, b) {
2
+ const dateA = new Date(a);
3
+ const dateB = new Date(b);
4
+
5
+ // Check if both dates are valid
6
+ const isValidA = !isNaN(dateA.getTime());
7
+ const isValidB = !isNaN(dateB.getTime());
8
+ if (isValidA && isValidB) {
9
+ // Compare valid dates
10
+ return dateA - dateB;
11
+ } else if (isValidA) {
12
+ // Invalid date in `b` pushes `a` before `b`
13
+ return -1;
14
+ } else if (isValidB) {
15
+ // Invalid date in `a` pushes `b` before `a`
16
+ return 1;
17
+ } else {
18
+ // Both are invalid, maintain their relative order
19
+ return 0;
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Multi-sort rows based on multiple criteria.
25
+ * @param {Array} rows - Array of row objects.
26
+ * @param {Array} criteria - Array of sort criteria [{key, sortBy}].
27
+ * @param {Object} columnConfig - Column configurations with data types.
28
+ */
29
+ const multiSortRows = (rows, criteria, columnConfig) => {
30
+ return rows.slice().sort((a, b) => {
31
+ for (let {
32
+ key,
33
+ operator
34
+ } of criteria) {
35
+ const column = columnConfig.find(col => col.key === key);
36
+ if (!column) continue;
37
+ const dataType = column.type;
38
+ const valueA = a[key];
39
+ const valueB = b[key];
40
+ let comparison = 0;
41
+ switch (dataType) {
42
+ case "text":
43
+ comparison = valueA.localeCompare(valueB, undefined, {
44
+ sensitivity: "base"
45
+ });
46
+ break;
47
+ case "number":
48
+ comparison = parseInt(valueA || 0) - parseInt(valueB || 0);
49
+ break;
50
+ case "select":
51
+ case "multi-select":
52
+ comparison = valueA?.map(m => m?.value).join(", ").localeCompare(valueB?.map(m => m?.value).join(", "), undefined, {
53
+ sensitivity: "base"
54
+ });
55
+ break;
56
+ case "date":
57
+ comparison = sortByDate(valueA, valueB);
58
+ break;
59
+ case "check":
60
+ return valueA && operator === "desc" ? 1 : -1;
61
+ default:
62
+ break;
63
+ }
64
+ if (comparison !== 0) {
65
+ return operator === "asc" ? comparison : -comparison;
66
+ }
67
+ }
68
+ return 0; // Rows are equal based on all criteria
69
+ });
70
+ };
71
+
72
+ export default multiSortRows;
@@ -0,0 +1,143 @@
1
+ const useDataViewStyles = (theme, appTheme) => ({
2
+ root: {
3
+ width: "100%",
4
+ overflowX: "auto",
5
+ marginTop: "8px",
6
+ "& table": {
7
+ width: "100%",
8
+ "& th.fe-tv-ap-ico": {
9
+ width: "50px"
10
+ }
11
+ },
12
+ "& table th": {
13
+ cursor: "pointer",
14
+ width: "200px"
15
+ },
16
+ "& table, th, td": {
17
+ border: "1px solid black",
18
+ borderCollapse: "collapse"
19
+ },
20
+ "& .react-datepicker-wrapper": {
21
+ width: "100%",
22
+ "& input": {
23
+ padding: "6px 12px"
24
+ }
25
+ },
26
+ "& .MuiInputBase-root": {
27
+ "& fieldset": {
28
+ border: "none"
29
+ }
30
+ },
31
+ // filter view
32
+ "& .fe-tv-fv": {
33
+ marginBottom: "8px",
34
+ "& .mr": {
35
+ marginRight: "4px"
36
+ },
37
+ [theme.breakpoints.between("xs", "md")]: {
38
+ display: "flex",
39
+ flexDirection: "column"
40
+ }
41
+ },
42
+ "& .tv-act-row": {
43
+ "& .tv-tr-pop": {
44
+ opacity: 0,
45
+ "&.active": {
46
+ opacity: 1
47
+ },
48
+ "& .tv-ck-box": {
49
+ "& svg": {
50
+ color: appTheme?.palette?.editor?.tv_border
51
+ },
52
+ "&.Mui-checked": {
53
+ "& svg": {
54
+ color: "rgba(37, 99, 235, 1)"
55
+ }
56
+ }
57
+ }
58
+ },
59
+ "&:hover": {
60
+ "& .tv-tr-pop": {
61
+ opacity: 1
62
+ }
63
+ }
64
+ }
65
+ },
66
+ filterView: {
67
+ display: "flex",
68
+ justifyContent: "space-between",
69
+ alignItems: "center",
70
+ "& .MuiButtonBase-root": {
71
+ padding: "6px",
72
+ width: "24px",
73
+ height: "24px",
74
+ "&.active": {
75
+ color: "rgba(37, 99, 235, 1)"
76
+ }
77
+ },
78
+ "& .tv-sb": {
79
+ display: "flex",
80
+ border: "1px solid transparent",
81
+ width: "24px",
82
+ transition: "width 1s",
83
+ "&.open": {
84
+ width: "fit-content",
85
+ border: "1px solid rgba(236, 236, 236, 1)",
86
+ borderRadius: "8px"
87
+ },
88
+ "& input": {
89
+ paddingBottom: "0px",
90
+ fontSize: "14px"
91
+ }
92
+ },
93
+ "& .tv-title-wrpr, .tv-fi-wrpr": {
94
+ display: "flex",
95
+ "& button": {
96
+ color: appTheme?.palette?.editor?.tv_text
97
+ },
98
+ "& input": {
99
+ color: appTheme?.palette?.editor?.tv_text
100
+ }
101
+ },
102
+ "& .tv-title-wrpr": {
103
+ width: "80%",
104
+ marginRight: "8px",
105
+ "& .MuiInputBase-root": {
106
+ width: "100%"
107
+ },
108
+ [theme.breakpoints.between("xs", "md")]: {
109
+ width: "100%",
110
+ marginRight: "0px"
111
+ }
112
+ },
113
+ "& .tv-fi-wrpr": {
114
+ [theme.breakpoints.between("xs", "md")]: {
115
+ width: "100%",
116
+ justifyContent: "end"
117
+ }
118
+ }
119
+ },
120
+ basicMenu: {
121
+ "& .MuiPaper-root": {
122
+ padding: "0px 6px",
123
+ width: "150px",
124
+ border: `1px solid ${appTheme?.palette?.editor?.tv_border}`,
125
+ borderRadius: "8px",
126
+ background: appTheme?.palette?.editor?.tv_pop_bg,
127
+ color: appTheme?.palette?.editor?.tv_text_primary,
128
+ "& .MuiButtonBase-root": {
129
+ fontSize: "14px",
130
+ "& svg": {
131
+ width: "16px",
132
+ height: "16px"
133
+ },
134
+ "&:hover": {
135
+ background: appTheme?.palette?.editor?.tv_hover_bg,
136
+ borderRadius: "8px",
137
+ color: appTheme?.palette?.editor?.tv_hover_text
138
+ }
139
+ }
140
+ }
141
+ }
142
+ });
143
+ export default useDataViewStyles;
@@ -18,9 +18,9 @@ const Divider = props => {
18
18
  theme
19
19
  } = useEditorContext();
20
20
  const {
21
- borderColor = theme?.palette?.primary?.main || '#0F172A',
22
- borderWidth = '1px',
23
- borderStyle = 'solid'
21
+ borderColor = theme?.palette?.primary?.main || "#0F172A",
22
+ borderWidth = "1px",
23
+ borderStyle = "solid"
24
24
  } = element;
25
25
  const {
26
26
  readOnly
@@ -33,7 +33,7 @@ const Divider = props => {
33
33
  } = useEditorContext();
34
34
  const [showTool] = useEditorSelection(editor);
35
35
  const selected = hoverPath === path.join(",");
36
- const width = borderWidth?.includes('px') ? borderWidth : `${borderWidth}px`;
36
+ const width = borderWidth?.includes("px") ? borderWidth : `${borderWidth}px`;
37
37
  const onSettings = () => {
38
38
  setOpenSettings(true);
39
39
  };
@@ -44,8 +44,8 @@ const Divider = props => {
44
44
  onSettings
45
45
  }) => {
46
46
  const hoverStyles = readOnly ? {
47
- '&.MuiIconButton-root:hover': {
48
- background: theme?.palette?.type === 'dark' ? `${theme?.palette?.greyshades?.light8} !important` : `${theme?.palette?.containers?.card} !important`
47
+ "&.MuiIconButton-root:hover": {
48
+ background: theme?.palette?.type === "dark" ? `${theme?.palette?.greyshades?.light8} !important` : `${theme?.palette?.containers?.card} !important`
49
49
  }
50
50
  } : {};
51
51
  return /*#__PURE__*/_jsx("div", {
@@ -61,11 +61,11 @@ const Divider = props => {
61
61
  children: /*#__PURE__*/_jsx(IconButton, {
62
62
  size: "small",
63
63
  sx: {
64
- background: theme?.palette?.type === 'dark' ? theme?.palette?.greyshades?.light8 : theme?.palette?.containers?.card,
65
- border: theme?.palette?.type === 'dark' ? '1px solid #E4E8EB33' : 'none',
66
- boxShadow: '0px 0px 4px 0px #00000040',
67
- borderRadius: '50%',
68
- '& svg': {
64
+ background: theme?.palette?.type === "dark" ? theme?.palette?.greyshades?.light8 : theme?.palette?.containers?.card,
65
+ border: theme?.palette?.type === "dark" ? "1px solid #E4E8EB33" : "none",
66
+ boxShadow: "0px 0px 4px 0px #00000040",
67
+ borderRadius: "50%",
68
+ "& svg": {
69
69
  stroke: theme?.palette?.text?.secondary3
70
70
  },
71
71
  ...hoverStyles
@@ -103,14 +103,15 @@ const Divider = props => {
103
103
  className: `dividerComponent`,
104
104
  style: {
105
105
  userSelect: "none",
106
- position: 'relative'
106
+ position: "relative"
107
107
  },
108
108
  contentEditable: false,
109
109
  children: [!readOnly && /*#__PURE__*/_jsx("div", {
110
110
  className: `element-root element-selector`,
111
111
  contentEditable: false,
112
112
  style: {
113
- zIndex: 1000
113
+ zIndex: 1000,
114
+ left: "50%"
114
115
  },
115
116
  children: /*#__PURE__*/_jsx(DividerToolbar, {
116
117
  selected: selected,
@@ -126,7 +127,7 @@ const Divider = props => {
126
127
  borderTop: !borderColor?.includes("linear") ? `${width} ${borderStyle} ${borderColor}` : `transparent`,
127
128
  backgroundImage: borderColor?.includes("linear") ? borderColor : "none",
128
129
  height: borderColor?.includes("linear") ? borderWidth : undefined,
129
- marginTop: '15px'
130
+ marginTop: "15px"
130
131
  }
131
132
  }), /*#__PURE__*/_jsx("span", {
132
133
  style: {