@flozy/editor 5.1.2 → 5.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Editor/ChatEditor.js +34 -25
- package/dist/Editor/CommonEditor.js +7 -13
- package/dist/Editor/Editor.css +10 -52
- package/dist/Editor/Elements/AI/AIInput.js +1 -0
- package/dist/Editor/Elements/AI/CustomSelect.js +10 -17
- package/dist/Editor/Elements/AI/Styles.js +1 -7
- package/dist/Editor/Elements/Button/EditorButton.js +1 -0
- package/dist/Editor/Elements/Color Picker/ColorButtons.js +5 -7
- package/dist/Editor/Elements/Color Picker/Styles.js +3 -7
- package/dist/Editor/Elements/Color Picker/defaultColors.js +2 -2
- package/dist/Editor/Elements/Form/Form.js +2 -38
- package/dist/Editor/Elements/Form/FormElements/FormCheckbox.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormDate.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormEmail.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormNumbers.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormRadioButton.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormText.js +1 -7
- package/dist/Editor/Elements/Form/FormElements/FormTextArea.js +1 -6
- package/dist/Editor/Elements/Form/FormPopup.js +9 -12
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +1 -1
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +1 -20
- package/dist/Editor/Elements/Grid/GridButton.js +1 -2
- package/dist/Editor/Elements/Grid/GridItem.js +2 -3
- package/dist/Editor/Elements/Grid/Styles.js +3 -0
- package/dist/Editor/Elements/Link/LinkButton.js +1 -1
- package/dist/Editor/Elements/Signature/Signature.css +1 -1
- package/dist/Editor/Elements/Signature/SignatureOptions/TypeSignature.js +2 -2
- package/dist/Editor/Elements/Signature/SignaturePopup.js +48 -13
- package/dist/Editor/Elements/SimpleText/index.js +1 -8
- package/dist/Editor/Elements/SimpleText/style.js +1 -8
- package/dist/Editor/Elements/Table/Styles.js +43 -25
- package/dist/Editor/Elements/Table/Table.js +138 -206
- package/dist/Editor/Elements/Table/TableCell.js +102 -355
- package/dist/Editor/Elements/Table/TablePopup.js +3 -9
- package/dist/Editor/Elements/Table/TableRow.js +2 -10
- package/dist/Editor/Styles/EditorStyles.js +1 -3
- package/dist/Editor/Toolbar/FormatTools/BlockButton.js +0 -10
- package/dist/Editor/Toolbar/FormatTools/Dropdown.js +11 -7
- package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +4 -10
- package/dist/Editor/Toolbar/FormatTools/MarkButton.js +0 -3
- package/dist/Editor/Toolbar/FormatTools/TextSize.js +2 -0
- package/dist/Editor/Toolbar/Mini/MiniToolbar.js +6 -3
- package/dist/Editor/Toolbar/Mini/Styles.js +1 -4
- package/dist/Editor/Toolbar/PopupTool/MiniTextFormat/index.js +3 -3
- package/dist/Editor/Toolbar/PopupTool/PopperHeader.js +11 -16
- package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +49 -416
- package/dist/Editor/Toolbar/PopupTool/TextFormat.js +8 -62
- package/dist/Editor/Toolbar/PopupTool/index.js +6 -5
- package/dist/Editor/Toolbar/Toolbar.js +0 -6
- package/dist/Editor/Toolbar/toolbarGroups.js +0 -4
- package/dist/Editor/assets/svg/BrainIcon.js +2 -2
- package/dist/Editor/common/ColorPickerButton.js +2 -3
- package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
- package/dist/Editor/common/Icon.js +23 -24
- package/dist/Editor/common/LinkSettings/NavComponents.js +1 -2
- package/dist/Editor/common/LinkSettings/index.js +1 -2
- package/dist/Editor/common/MentionsPopup/Styles.js +3 -151
- package/dist/Editor/common/MentionsPopup/index.js +1 -1
- package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +12 -108
- package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -14
- package/dist/Editor/common/Shorthands/elements.js +1 -13
- package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +0 -5
- package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +2 -10
- package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
- package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +2 -5
- package/dist/Editor/common/StyleBuilder/formStyle.js +149 -268
- package/dist/Editor/common/StyleBuilder/index.js +11 -84
- package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +0 -4
- package/dist/Editor/common/StyleBuilder/tableStyle.js +25 -69
- package/dist/Editor/common/Uploader.js +0 -8
- package/dist/Editor/common/iconListV2.js +40 -378
- package/dist/Editor/common/iconslist.js +5 -8
- package/dist/Editor/commonStyle.js +9 -117
- package/dist/Editor/helper/deserialize/index.js +1 -4
- package/dist/Editor/helper/index.js +2 -2
- package/dist/Editor/helper/theme.js +1 -24
- package/dist/Editor/hooks/useMouseMove.js +2 -5
- package/dist/Editor/plugins/withCustomDeleteBackward.js +2 -3
- package/dist/Editor/plugins/withHTML.js +1 -17
- package/dist/Editor/plugins/withLayout.js +1 -48
- package/dist/Editor/utils/SlateUtilityFunctions.js +0 -18
- package/dist/Editor/utils/chatEditor/SlateUtilityFunctions.js +0 -21
- package/dist/Editor/utils/embed.js +1 -2
- package/dist/Editor/utils/events.js +1 -0
- package/dist/Editor/utils/font.js +4 -11
- package/dist/Editor/utils/formfield.js +4 -8
- package/dist/Editor/utils/helper.js +1 -34
- package/dist/Editor/utils/insertNewLine.js +1 -19
- package/dist/Editor/utils/pageSettings.js +2 -14
- package/dist/Editor/utils/serializeToText.js +0 -2
- package/dist/Editor/utils/table.js +24 -228
- package/package.json +1 -1
- package/dist/Editor/Elements/DataView/DataView.js +0 -101
- package/dist/Editor/Elements/DataView/DataViewButton.js +0 -23
- package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +0 -59
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +0 -140
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +0 -40
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +0 -59
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +0 -26
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +0 -38
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +0 -35
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +0 -36
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +0 -17
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +0 -29
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +0 -38
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +0 -74
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +0 -64
- package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +0 -106
- package/dist/Editor/Elements/DataView/Layouts/FilterView.js +0 -174
- package/dist/Editor/Elements/DataView/Layouts/Formula.js +0 -29
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +0 -113
- package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +0 -37
- package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +0 -111
- package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +0 -62
- package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +0 -36
- package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +0 -101
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +0 -160
- package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +0 -190
- package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +0 -42
- package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +0 -30
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +0 -110
- package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +0 -179
- package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +0 -100
- package/dist/Editor/Elements/DataView/Layouts/TableView.js +0 -227
- package/dist/Editor/Elements/DataView/Layouts/ViewData.js +0 -70
- package/dist/Editor/Elements/DataView/Layouts/index.js +0 -25
- package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +0 -288
- package/dist/Editor/Elements/DataView/Utils/globalSearch.js +0 -15
- package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +0 -72
- package/dist/Editor/Elements/DataView/styles.js +0 -143
- package/dist/Editor/Elements/Table/AddRowCol.js +0 -77
- package/dist/Editor/Elements/Table/DragButton.js +0 -141
- package/dist/Editor/Elements/Table/DragStyles.js +0 -69
- package/dist/Editor/Elements/Table/Draggable.js +0 -25
- package/dist/Editor/Elements/Table/Droppable.js +0 -53
- package/dist/Editor/Elements/Table/TableTool.js +0 -101
- package/dist/Editor/Elements/Table/tableHelper.js +0 -71
- package/dist/Editor/assets/svg/TableIcons.js +0 -220
- package/dist/Editor/common/Select/index.js +0 -20
- package/dist/Editor/common/Select/styles.js +0 -17
- package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +0 -79
- package/dist/Editor/hooks/useTable.js +0 -175
- package/dist/Editor/utils/dataView.js +0 -43
@@ -1,288 +0,0 @@
|
|
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
|
-
};
|
@@ -1,15 +0,0 @@
|
|
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;
|
@@ -1,72 +0,0 @@
|
|
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;
|
@@ -1,143 +0,0 @@
|
|
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;
|
@@ -1,77 +0,0 @@
|
|
1
|
-
import { Button } from "@mui/material";
|
2
|
-
import { useMemo, useState } from "react";
|
3
|
-
import useTable from "../../hooks/useTable";
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
5
|
-
const showAddButton = (addType, tableNode, hoverPath) => {
|
6
|
-
const [row, col] = hoverPath && hoverPath?.length ? hoverPath.slice(-2) : [];
|
7
|
-
if (addType === "row") {
|
8
|
-
return tableNode?.rows - 1 === row;
|
9
|
-
} else {
|
10
|
-
return tableNode?.columns - 1 === col;
|
11
|
-
}
|
12
|
-
};
|
13
|
-
const ADD_COL_BTN_WIDTH = 20;
|
14
|
-
function AddRowCol(props) {
|
15
|
-
const {
|
16
|
-
tableRef,
|
17
|
-
containerRef,
|
18
|
-
addType,
|
19
|
-
tableNode,
|
20
|
-
onAdd,
|
21
|
-
readOnly
|
22
|
-
} = props;
|
23
|
-
const {
|
24
|
-
hoverPath
|
25
|
-
} = useTable();
|
26
|
-
const [hoveringAddBtn, setHoveringAddBtn] = useState(false);
|
27
|
-
const {
|
28
|
-
tableResizing
|
29
|
-
} = useTable();
|
30
|
-
const {
|
31
|
-
clientHeight,
|
32
|
-
scrollWidth
|
33
|
-
} = tableRef?.current || {};
|
34
|
-
const {
|
35
|
-
clientWidth: containerWidth
|
36
|
-
} = containerRef?.current || {};
|
37
|
-
const buttonStyle = useMemo(() => {
|
38
|
-
if (addType === "row") {
|
39
|
-
const isScrollEnabled = scrollWidth > containerWidth;
|
40
|
-
const width = isScrollEnabled ? containerWidth - ADD_COL_BTN_WIDTH : scrollWidth;
|
41
|
-
return {
|
42
|
-
width
|
43
|
-
};
|
44
|
-
} else {
|
45
|
-
return {
|
46
|
-
height: "100%",
|
47
|
-
marginLeft: "3px"
|
48
|
-
};
|
49
|
-
}
|
50
|
-
}, [scrollWidth, clientHeight, containerWidth, tableResizing]);
|
51
|
-
const showAdd = showAddButton(addType, tableNode, hoverPath);
|
52
|
-
const onMouseEnter = () => setHoveringAddBtn(true);
|
53
|
-
const onMouseLeave = () => setHoveringAddBtn(false);
|
54
|
-
const showBtn = (showAdd || hoveringAddBtn) && !tableResizing && !readOnly;
|
55
|
-
return /*#__PURE__*/_jsx("div", {
|
56
|
-
onMouseEnter: onMouseEnter,
|
57
|
-
onMouseLeave: onMouseLeave,
|
58
|
-
contentEditable: false,
|
59
|
-
children: /*#__PURE__*/_jsx(Button, {
|
60
|
-
sx: {
|
61
|
-
fontSize: "14px",
|
62
|
-
border: "1px dashed #8DA8E3",
|
63
|
-
color: "#2563EB !important",
|
64
|
-
padding: "0px 4px",
|
65
|
-
minWidth: "unset",
|
66
|
-
lineHeight: "18px",
|
67
|
-
fontWeight: "normal !important",
|
68
|
-
...buttonStyle,
|
69
|
-
opacity: showBtn ? 1 : 0
|
70
|
-
},
|
71
|
-
disabled: !showBtn,
|
72
|
-
onClick: onAdd,
|
73
|
-
children: "+"
|
74
|
-
})
|
75
|
-
});
|
76
|
-
}
|
77
|
-
export default AddRowCol;
|