@flozy/editor 9.3.5 → 9.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Editor/ChatEditor.js +1 -1
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/MultiSelect.js +422 -0
- package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +18 -5
- package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +5 -1
- package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +3 -2
- package/dist/Editor/Elements/DataView/Layouts/Options/index.js +11 -0
- package/dist/Editor/Elements/Embed/Image.js +2 -1
- package/dist/Editor/Elements/FreeGrid/FreeGrid.js +44 -9
- package/dist/Editor/Elements/FreeGrid/FreeGridBox.js +16 -2
- package/dist/Editor/Elements/FreeGrid/FreeGridItem.js +26 -2
- package/dist/Editor/Elements/FreeGrid/Options/More.js +7 -2
- package/dist/Editor/Elements/Table/TableCell.js +4 -0
- package/dist/Editor/assets/svg/ClearAllRounded.js +31 -0
- package/dist/Editor/common/RnD/Utils/gridDropItem.js +58 -7
- package/dist/Editor/common/RnD/Utils/index.js +3 -0
- package/dist/Editor/common/RnD/VirtualElement/ForceAutoAlignment.js +110 -0
- package/dist/Editor/common/RnD/VirtualElement/VirtualTextElement.js +112 -0
- package/dist/Editor/common/RnD/VirtualElement/helper.js +267 -0
- package/dist/Editor/common/RnD/VirtualElement/index.js +185 -102
- package/dist/Editor/common/RnD/VirtualElement/styles.js +95 -8
- package/dist/Editor/common/RnD/VirtualElement/updateAutoProps.js +5 -3
- package/dist/Editor/common/RnD/index.js +50 -5
- package/dist/Editor/common/SnackBar/index.js +43 -0
- package/dist/Editor/hooks/useAutoScroll.js +38 -0
- package/dist/Editor/hooks/useMouseMove.js +5 -2
- package/dist/Editor/hooks/useTable.js +4 -1
- package/dist/Editor/utils/divider.js +11 -3
- package/dist/Editor/utils/freegrid.js +2 -2
- package/dist/Editor/utils/helper.js +62 -9
- package/dist/Editor/utils/table.js +45 -37
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useCallback, useMemo, useRef,
|
1
|
+
import React, { useCallback, useMemo, useRef, useImperativeHandle, forwardRef } from "react";
|
2
2
|
import { Editable, Slate, ReactEditor } from "slate-react";
|
3
3
|
import { createEditor, Transforms, Editor } from "slate";
|
4
4
|
import withCommon from "./hooks/withCommon";
|
@@ -0,0 +1,422 @@
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
import { Autocomplete, Box, Chip, Divider, Popover, TextField, Typography, List, ListItem, ListItemButton, IconButton, SwipeableDrawer, Tooltip } from "@mui/material";
|
3
|
+
import { CloseIcon } from "../../../../../common/iconslist";
|
4
|
+
import { useEditorContext } from "../../../../../hooks/useMouseMove";
|
5
|
+
import Icon from "../../../../../common/Icon";
|
6
|
+
import { colors } from "../../../../Color Picker/defaultColors";
|
7
|
+
import PropertySettings from "../../Options";
|
8
|
+
import SnackbarAlert from "../../../../../common/SnackBar";
|
9
|
+
import ClearAllRounded from "../../../../../assets/svg/ClearAllRounded";
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
12
|
+
const EXCLUDED_COLORS = new Set(["#000000", "#0F172A", "#2563EB", "#FFFFFF", "#64748B"]);
|
13
|
+
const DEFAULT_COLORS = colors?.filter(f => !f?.includes("linear") && !EXCLUDED_COLORS?.has(f));
|
14
|
+
const generateRandomColor = () => {
|
15
|
+
const randomIndex = Math.floor(Math.random() * DEFAULT_COLORS?.length);
|
16
|
+
return DEFAULT_COLORS[randomIndex];
|
17
|
+
};
|
18
|
+
const MultiSelectWithPopover = props => {
|
19
|
+
const {
|
20
|
+
options = [],
|
21
|
+
value,
|
22
|
+
onChange,
|
23
|
+
onUpdate,
|
24
|
+
property,
|
25
|
+
wrapColumn = false
|
26
|
+
} = props;
|
27
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
28
|
+
const [anchorElOption, setAnchorElOption] = useState(null);
|
29
|
+
const [currentIndex, setCurrentIndex] = useState(null);
|
30
|
+
const [selectedOptions, setSelectedOptions] = useState(value);
|
31
|
+
const [availableOptions, setAvailableOptions] = useState(options);
|
32
|
+
const [showSnackBar, setShowSnackBar] = useState(false);
|
33
|
+
const [chipColor, setChipColor] = useState(generateRandomColor());
|
34
|
+
const [inputValue, setInputValue] = useState("");
|
35
|
+
const {
|
36
|
+
theme
|
37
|
+
} = useEditorContext();
|
38
|
+
const isMobile = window.matchMedia("(max-width: 899px)")?.matches || false;
|
39
|
+
const PopoverComponent = isMobile ? SwipeableDrawer : Popover;
|
40
|
+
const mode = {
|
41
|
+
type: "editOptionMulti",
|
42
|
+
edit: {
|
43
|
+
label: "Multi Select",
|
44
|
+
visible: true,
|
45
|
+
key: property,
|
46
|
+
type: "multi-select",
|
47
|
+
options: options || [],
|
48
|
+
optionIndex: currentIndex,
|
49
|
+
hideBackButton: true
|
50
|
+
}
|
51
|
+
};
|
52
|
+
const customScrollStyles = {
|
53
|
+
scrollbarWidth: "thin",
|
54
|
+
scrollbarColor: `${theme?.palette?.editor?.brainPopupScroll} transparent`,
|
55
|
+
"&::-webkit-scrollbar": {
|
56
|
+
width: "6px"
|
57
|
+
},
|
58
|
+
"&::-webkit-scrollbar-thumb": {
|
59
|
+
backgroundColor: theme?.palette?.editor?.brainPopupScroll,
|
60
|
+
borderRadius: "3px"
|
61
|
+
},
|
62
|
+
"&::-webkit-scrollbar-track": {
|
63
|
+
display: "none"
|
64
|
+
}
|
65
|
+
};
|
66
|
+
useEffect(() => {
|
67
|
+
if (inputValue?.trim()) {
|
68
|
+
setChipColor(prevColor => prevColor || generateRandomColor());
|
69
|
+
} else {
|
70
|
+
setChipColor(generateRandomColor());
|
71
|
+
}
|
72
|
+
}, [inputValue]);
|
73
|
+
useEffect(() => {
|
74
|
+
setAvailableOptions(options);
|
75
|
+
}, [options]);
|
76
|
+
const handleOpenPopover = event => {
|
77
|
+
setAnchorEl(event.currentTarget);
|
78
|
+
};
|
79
|
+
const handleClosePopover = () => {
|
80
|
+
setAnchorEl(null);
|
81
|
+
};
|
82
|
+
const handleAddOption = newValue => {
|
83
|
+
const trimmedValue = newValue?.trim();
|
84
|
+
if (!trimmedValue) return;
|
85
|
+
const newOption = {
|
86
|
+
value: trimmedValue,
|
87
|
+
color: chipColor
|
88
|
+
};
|
89
|
+
if (!availableOptions?.some(opt => opt?.value === trimmedValue)) {
|
90
|
+
setAvailableOptions(prev => [...prev, newOption]);
|
91
|
+
setSelectedOptions(prev => [...prev, newOption]);
|
92
|
+
onUpdate([newOption, ...availableOptions]);
|
93
|
+
}
|
94
|
+
setInputValue("");
|
95
|
+
};
|
96
|
+
const onClose = () => {
|
97
|
+
setAnchorEl(anchorElOption);
|
98
|
+
setAnchorElOption(null);
|
99
|
+
};
|
100
|
+
const onEditOption = (type, data) => {
|
101
|
+
const updateData = data?.edit ? data?.edit?.options : data?.options;
|
102
|
+
onUpdate(updateData);
|
103
|
+
if (data?.edit?.options) {
|
104
|
+
const updatedSelectedOptions = selectedOptions?.filter(selOption => updateData?.some(availOption => availOption?.value === selOption?.value && availOption?.color === selOption?.color));
|
105
|
+
setSelectedOptions(updatedSelectedOptions);
|
106
|
+
onClose();
|
107
|
+
}
|
108
|
+
};
|
109
|
+
const handleEditOption = (e, index) => {
|
110
|
+
e.stopPropagation();
|
111
|
+
setCurrentIndex(index);
|
112
|
+
setAnchorElOption(anchorEl);
|
113
|
+
setAnchorEl(null);
|
114
|
+
};
|
115
|
+
const handleSelectOption = option => {
|
116
|
+
if (!selectedOptions?.some(opt => opt?.value === option?.value)) {
|
117
|
+
setSelectedOptions(prev => [...prev, option]);
|
118
|
+
onChange(selectedOptions);
|
119
|
+
} else {
|
120
|
+
setShowSnackBar(true);
|
121
|
+
}
|
122
|
+
};
|
123
|
+
const handleClearSelection = () => {
|
124
|
+
setSelectedOptions([]);
|
125
|
+
};
|
126
|
+
const filteredOptions = availableOptions?.filter(option => option?.value?.toLowerCase()?.includes(inputValue?.toLowerCase()));
|
127
|
+
const isExactMatch = availableOptions?.some(opt => opt?.value?.toLowerCase() === inputValue?.toLowerCase());
|
128
|
+
const open = Boolean(anchorEl);
|
129
|
+
const openEditOption = Boolean(anchorElOption);
|
130
|
+
const id = open ? "autocomplete-popover" : undefined;
|
131
|
+
return /*#__PURE__*/_jsxs("div", {
|
132
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
133
|
+
sx: {
|
134
|
+
display: "flex",
|
135
|
+
flexWrap: wrapColumn ? "wrap" : "nowrap",
|
136
|
+
overflowX: wrapColumn ? "hidden" : "auto",
|
137
|
+
gap: 0.5,
|
138
|
+
padding: "8px",
|
139
|
+
cursor: "pointer"
|
140
|
+
},
|
141
|
+
onClick: handleOpenPopover,
|
142
|
+
children: selectedOptions?.map((option, index) => /*#__PURE__*/_jsx(Chip, {
|
143
|
+
label: option?.value,
|
144
|
+
onDelete: () => setSelectedOptions(prev => prev.filter(selected => selected?.value !== option?.value)),
|
145
|
+
deleteIcon: /*#__PURE__*/_jsx(CloseIcon, {}),
|
146
|
+
variant: "filled",
|
147
|
+
sx: {
|
148
|
+
backgroundColor: option?.color,
|
149
|
+
color: '#0F172A',
|
150
|
+
"& .MuiChip-deleteIcon": {
|
151
|
+
flexShrink: 0,
|
152
|
+
"& path": {
|
153
|
+
stroke: '#0F172A'
|
154
|
+
}
|
155
|
+
},
|
156
|
+
"&:hover": {
|
157
|
+
opacity: 0.8
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}, index))
|
161
|
+
}), /*#__PURE__*/_jsx(PopoverComponent, {
|
162
|
+
id: id,
|
163
|
+
open: open,
|
164
|
+
anchorEl: anchorEl,
|
165
|
+
onClose: handleClosePopover,
|
166
|
+
anchorOrigin: {
|
167
|
+
vertical: "top",
|
168
|
+
horizontal: "left"
|
169
|
+
},
|
170
|
+
transformOrigin: {
|
171
|
+
vertical: "top",
|
172
|
+
horizontal: "left"
|
173
|
+
},
|
174
|
+
sx: {
|
175
|
+
"& .MuiPaper-root": {
|
176
|
+
borderRadius: "20px",
|
177
|
+
background: theme?.palette?.editor?.background,
|
178
|
+
border: `1px solid ${theme?.palette?.editor?.popUpBorderColor}`,
|
179
|
+
boxShadow: "0px 4px 10px 0px #00000029"
|
180
|
+
}
|
181
|
+
},
|
182
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
183
|
+
sx: {
|
184
|
+
width: 300
|
185
|
+
},
|
186
|
+
children: [/*#__PURE__*/_jsx(Autocomplete, {
|
187
|
+
multiple: true,
|
188
|
+
freeSolo: true,
|
189
|
+
disablePortal: true,
|
190
|
+
PopperComponent: () => null,
|
191
|
+
sx: {
|
192
|
+
"& .MuiFormControl-root": {
|
193
|
+
maxHeight: "250px",
|
194
|
+
overflowY: "auto",
|
195
|
+
overflowX: "hidden",
|
196
|
+
pr: '12px',
|
197
|
+
pl: '12px',
|
198
|
+
maxWidth: "275px",
|
199
|
+
marginTop: '12px',
|
200
|
+
...customScrollStyles
|
201
|
+
}
|
202
|
+
},
|
203
|
+
disableClearable: true,
|
204
|
+
options: [],
|
205
|
+
getOptionLabel: option => options?.value || "",
|
206
|
+
value: selectedOptions,
|
207
|
+
onChange: (event, newValues) => {
|
208
|
+
// Filter and map the new values properly
|
209
|
+
const addedOptions = newValues?.filter(value => typeof value === "object" || typeof value === "string" && value?.trim() !== "")?.map(value => typeof value === "string" ? {
|
210
|
+
value,
|
211
|
+
color: chipColor
|
212
|
+
} : value);
|
213
|
+
|
214
|
+
// Check if any new value already exists in selectedOptions
|
215
|
+
const isDuplicate = addedOptions?.some(newOpt => (selectedOptions || [])?.some(opt => opt.value === newOpt.value));
|
216
|
+
if (!isDuplicate) {
|
217
|
+
setSelectedOptions([...selectedOptions, ...addedOptions]);
|
218
|
+
}
|
219
|
+
},
|
220
|
+
inputValue: inputValue,
|
221
|
+
onInputChange: (event, newInputValue) => setInputValue(newInputValue),
|
222
|
+
onKeyDown: event => {
|
223
|
+
if (event.key === "Enter" && inputValue.trim()) {
|
224
|
+
event.preventDefault();
|
225
|
+
handleAddOption(inputValue);
|
226
|
+
}
|
227
|
+
},
|
228
|
+
filterOptions: (options, params) => options?.filter(option => option?.value?.toLowerCase()?.includes(params?.inputValue?.toLowerCase())),
|
229
|
+
renderInput: params => /*#__PURE__*/_jsx(TextField, {
|
230
|
+
...params,
|
231
|
+
variant: "standard",
|
232
|
+
InputProps: {
|
233
|
+
...params.InputProps,
|
234
|
+
disableUnderline: true,
|
235
|
+
sx: {
|
236
|
+
display: "flex",
|
237
|
+
flexWrap: "wrap",
|
238
|
+
fontFamily: "Inter",
|
239
|
+
fontWeight: 400,
|
240
|
+
fontSize: "12px",
|
241
|
+
color: theme?.palette?.editor?.secondaryTextColor,
|
242
|
+
"&::placeholder": {
|
243
|
+
color: theme?.palette?.editor?.secondaryTextColor
|
244
|
+
},
|
245
|
+
"& .MuiAutocomplete-input": {
|
246
|
+
minWidth: "100px !important"
|
247
|
+
}
|
248
|
+
},
|
249
|
+
endAdornment: /*#__PURE__*/_jsx(Tooltip, {
|
250
|
+
arrow: true,
|
251
|
+
title: "Clear Selected",
|
252
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
253
|
+
onClick: handleClearSelection,
|
254
|
+
sx: {
|
255
|
+
padding: 0,
|
256
|
+
minWidth: "unset",
|
257
|
+
"& .MuiSvgIcon-root": {
|
258
|
+
fontSize: 20
|
259
|
+
},
|
260
|
+
'& rect': {
|
261
|
+
fill: theme?.palette?.editor?.closeButtonSvgStroke
|
262
|
+
},
|
263
|
+
'&:hover': {
|
264
|
+
backgroundColor: 'transparent'
|
265
|
+
}
|
266
|
+
},
|
267
|
+
children: /*#__PURE__*/_jsx(ClearAllRounded, {})
|
268
|
+
})
|
269
|
+
})
|
270
|
+
},
|
271
|
+
sx: {
|
272
|
+
backgroundColor: "transparent",
|
273
|
+
fontFamily: 'Inter',
|
274
|
+
fontWeight: 400,
|
275
|
+
fontSize: '12px'
|
276
|
+
},
|
277
|
+
placeholder: "Create new one..."
|
278
|
+
}),
|
279
|
+
renderTags: (tagValues, getTagProps) => tagValues.map((option, index) => /*#__PURE__*/_jsx(Chip, {
|
280
|
+
variant: "filled",
|
281
|
+
label: option?.value,
|
282
|
+
...getTagProps({
|
283
|
+
index
|
284
|
+
}),
|
285
|
+
deleteIcon: /*#__PURE__*/_jsx(CloseIcon, {}),
|
286
|
+
sx: {
|
287
|
+
backgroundColor: option?.color,
|
288
|
+
color: '#0F172A',
|
289
|
+
// maxWidth: 200,
|
290
|
+
// overflow: "hidden",
|
291
|
+
// textOverflow: "ellipsis",
|
292
|
+
// whiteSpace: "nowrap",
|
293
|
+
"& .MuiChip-deleteIcon": {
|
294
|
+
flexShrink: 0,
|
295
|
+
"& path": {
|
296
|
+
stroke: '#0F172A'
|
297
|
+
}
|
298
|
+
},
|
299
|
+
"&:hover": {
|
300
|
+
opacity: 0.8
|
301
|
+
}
|
302
|
+
}
|
303
|
+
}, index))
|
304
|
+
}), /*#__PURE__*/_jsx(Divider, {
|
305
|
+
sx: {
|
306
|
+
mt: '12px',
|
307
|
+
borderBottom: `1px solid ${theme?.palette?.editor?.popUpBorderColor}`,
|
308
|
+
boxShadow: theme?.palette?.editor?.dividerDropShadow
|
309
|
+
}
|
310
|
+
}), /*#__PURE__*/_jsx(Box, {
|
311
|
+
sx: {
|
312
|
+
pl: '4px'
|
313
|
+
},
|
314
|
+
children: /*#__PURE__*/_jsxs(List, {
|
315
|
+
sx: {
|
316
|
+
maxHeight: "250px",
|
317
|
+
overflowY: "auto",
|
318
|
+
...customScrollStyles
|
319
|
+
},
|
320
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
321
|
+
sx: {
|
322
|
+
mb: 1,
|
323
|
+
pl: '8px',
|
324
|
+
color: theme?.palette?.editor?.secondaryTextColor,
|
325
|
+
fontFamily: 'Inter',
|
326
|
+
fontWeight: 400,
|
327
|
+
fontSize: '12px'
|
328
|
+
},
|
329
|
+
children: "Choose an option or create one"
|
330
|
+
}), filteredOptions?.map((option, index) => /*#__PURE__*/_jsx(ListItem, {
|
331
|
+
disablePadding: true,
|
332
|
+
children: /*#__PURE__*/_jsxs(ListItemButton, {
|
333
|
+
onClick: () => handleSelectOption(option),
|
334
|
+
sx: {
|
335
|
+
justifyContent: 'space-between',
|
336
|
+
'&:hover': {
|
337
|
+
'& path': {
|
338
|
+
stroke: theme?.palette?.editor?.activeColor
|
339
|
+
},
|
340
|
+
borderRadius: '12px'
|
341
|
+
}
|
342
|
+
},
|
343
|
+
children: [/*#__PURE__*/_jsx(Chip, {
|
344
|
+
label: option?.value,
|
345
|
+
sx: {
|
346
|
+
backgroundColor: option?.color,
|
347
|
+
color: '#0F172A',
|
348
|
+
fontWeight: 500,
|
349
|
+
fontSize: "12px",
|
350
|
+
fontFamily: "Inter",
|
351
|
+
padding: "4px 12px",
|
352
|
+
borderRadius: "16px",
|
353
|
+
maxWidth: "180px",
|
354
|
+
whiteSpace: "nowrap",
|
355
|
+
overflow: "hidden",
|
356
|
+
textOverflow: "ellipsis"
|
357
|
+
}
|
358
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
359
|
+
size: "small",
|
360
|
+
sx: {
|
361
|
+
'& path': {
|
362
|
+
stroke: theme?.palette?.editor?.closeButtonSvgStroke
|
363
|
+
},
|
364
|
+
'&:hover': {
|
365
|
+
backgroundColor: 'transparent'
|
366
|
+
}
|
367
|
+
},
|
368
|
+
onClick: e => handleEditOption(e, index),
|
369
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
370
|
+
icon: "rightArrow"
|
371
|
+
})
|
372
|
+
})]
|
373
|
+
})
|
374
|
+
}, index)), inputValue?.trim() && !isExactMatch && /*#__PURE__*/_jsx(ListItem, {
|
375
|
+
disablePadding: true,
|
376
|
+
children: /*#__PURE__*/_jsxs(ListItemButton, {
|
377
|
+
onClick: () => handleAddOption(inputValue),
|
378
|
+
sx: {
|
379
|
+
display: "flex",
|
380
|
+
alignItems: "center"
|
381
|
+
},
|
382
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
383
|
+
sx: {
|
384
|
+
color: theme?.palette?.editor?.secondaryTextColor,
|
385
|
+
marginRight: "6px",
|
386
|
+
fontSize: "14px",
|
387
|
+
fontFamily: "Inter"
|
388
|
+
},
|
389
|
+
children: "Create"
|
390
|
+
}), /*#__PURE__*/_jsx(Chip, {
|
391
|
+
label: `${inputValue}`,
|
392
|
+
sx: {
|
393
|
+
backgroundColor: chipColor,
|
394
|
+
color: '#0F172A',
|
395
|
+
fontWeight: 500,
|
396
|
+
fontSize: "12px",
|
397
|
+
fontFamily: "Inter",
|
398
|
+
borderRadius: "16px",
|
399
|
+
maxWidth: "180px",
|
400
|
+
whiteSpace: "nowrap",
|
401
|
+
overflow: "hidden",
|
402
|
+
textOverflow: "ellipsis"
|
403
|
+
}
|
404
|
+
})]
|
405
|
+
})
|
406
|
+
})]
|
407
|
+
})
|
408
|
+
})]
|
409
|
+
})
|
410
|
+
}), openEditOption ? /*#__PURE__*/_jsx(PropertySettings, {
|
411
|
+
open: openEditOption,
|
412
|
+
anchorEl: anchorElOption,
|
413
|
+
mode: mode,
|
414
|
+
onClose: onClose,
|
415
|
+
onEvent: onEditOption
|
416
|
+
}) : null, showSnackBar ? /*#__PURE__*/_jsx(SnackbarAlert, {
|
417
|
+
message: "Option already selected!",
|
418
|
+
setShowSnackBar: setShowSnackBar
|
419
|
+
}) : null]
|
420
|
+
});
|
421
|
+
};
|
422
|
+
export default MultiSelectWithPopover;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { useDataView } from "../../Providers/DataViewProvider";
|
3
|
-
import
|
3
|
+
import MultiSelectWithPopover from "./Components/MultiSelect";
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
5
5
|
const MultiSelectType = props => {
|
6
6
|
const {
|
@@ -16,7 +16,8 @@ const MultiSelectType = props => {
|
|
16
16
|
wrapColumn
|
17
17
|
} = settings;
|
18
18
|
const {
|
19
|
-
onChange
|
19
|
+
onChange,
|
20
|
+
onUpdateProperty
|
20
21
|
} = useDataView();
|
21
22
|
const value = Array.isArray(pValue) ? pValue : [];
|
22
23
|
const coloredValues = [...(value || [])]?.map(m => {
|
@@ -30,15 +31,27 @@ const MultiSelectType = props => {
|
|
30
31
|
[property]: data?.filter(f => f?.value)
|
31
32
|
});
|
32
33
|
};
|
33
|
-
|
34
|
-
|
34
|
+
const handleUpdate = data => {
|
35
|
+
const updateData = {
|
36
|
+
"label": "Multi Select",
|
37
|
+
"visible": true,
|
38
|
+
"key": property,
|
39
|
+
"type": "multi-select",
|
40
|
+
"options": data
|
41
|
+
};
|
42
|
+
onUpdateProperty(updateData);
|
43
|
+
};
|
44
|
+
return /*#__PURE__*/_jsx(MultiSelectWithPopover, {
|
35
45
|
value: coloredValues,
|
36
46
|
onChange: handleChange,
|
47
|
+
onUpdate: handleUpdate,
|
37
48
|
options: options,
|
38
49
|
multiple: true,
|
39
50
|
limitTags: 2,
|
40
51
|
placeholder: label,
|
41
|
-
disabled: readOnly
|
52
|
+
disabled: readOnly,
|
53
|
+
property: property,
|
54
|
+
wrapColumn: wrapColumn
|
42
55
|
});
|
43
56
|
};
|
44
57
|
export default MultiSelectType;
|
@@ -4,7 +4,11 @@ import { colors } from "../../../Color Picker/defaultColors";
|
|
4
4
|
import Icon from "../../../../common/Icon";
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
6
6
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
7
|
-
const
|
7
|
+
const EXCLUDED_COLORS = new Set(["#000000", "#0F172A", "#2563EB", "#FFFFFF", "#64748B"]);
|
8
|
+
const DEFAULT_COLORS = colors?.filter(f => !f?.includes("linear") && !EXCLUDED_COLORS?.has(f));
|
9
|
+
|
10
|
+
// const DEFAULT_COLORS = colors?.filter((f) => !(f.includes("linear") || f === "#000000"));
|
11
|
+
|
8
12
|
const AddOptions = props => {
|
9
13
|
const {
|
10
14
|
edit,
|
@@ -30,6 +30,7 @@ const EditOption = props => {
|
|
30
30
|
} = edit;
|
31
31
|
const selectedOption = edit?.options[optionIndex] || {};
|
32
32
|
const pickerStyles = ColorPickerStyles(theme);
|
33
|
+
const hideBackButton = edit?.hideBackButton || false;
|
33
34
|
useEffect(() => {
|
34
35
|
return () => {
|
35
36
|
// on un-mount update the option change
|
@@ -104,14 +105,14 @@ const EditOption = props => {
|
|
104
105
|
children: [/*#__PURE__*/_jsxs(Box, {
|
105
106
|
className: "fe-dv-ap-title",
|
106
107
|
children: [/*#__PURE__*/_jsxs("span", {
|
107
|
-
children: [/*#__PURE__*/_jsx(IconButton, {
|
108
|
+
children: [!hideBackButton ? /*#__PURE__*/_jsx(IconButton, {
|
108
109
|
className: "tv-act-ico",
|
109
110
|
size: "small",
|
110
111
|
onClick: onBack,
|
111
112
|
children: /*#__PURE__*/_jsx(Icon, {
|
112
113
|
icon: 'leftArrow'
|
113
114
|
})
|
114
|
-
}), translation("Edit Option")]
|
115
|
+
}) : null, translation("Edit Option")]
|
115
116
|
}), /*#__PURE__*/_jsx(IconButton, {
|
116
117
|
className: "tv-act-ico bg br1",
|
117
118
|
size: "small",
|
@@ -29,6 +29,16 @@ const POSITIONS = {
|
|
29
29
|
vertical: "top",
|
30
30
|
horizontal: "right"
|
31
31
|
}
|
32
|
+
},
|
33
|
+
editOptionMulti: {
|
34
|
+
anchorOrigin: {
|
35
|
+
vertical: "top",
|
36
|
+
horizontal: "left"
|
37
|
+
},
|
38
|
+
transformOrigin: {
|
39
|
+
vertical: "top",
|
40
|
+
horizontal: "left"
|
41
|
+
}
|
32
42
|
}
|
33
43
|
};
|
34
44
|
const PropertySettings = props => {
|
@@ -82,6 +92,7 @@ const PropertySettings = props => {
|
|
82
92
|
translation: translation
|
83
93
|
});
|
84
94
|
case "editOption":
|
95
|
+
case "editOptionMulti":
|
85
96
|
return /*#__PURE__*/_jsx(EditOption, {
|
86
97
|
classes: classes,
|
87
98
|
onClose: onClose,
|
@@ -272,6 +272,7 @@ const Image = props => {
|
|
272
272
|
};
|
273
273
|
}
|
274
274
|
};
|
275
|
+
const showToolBar = !readOnly && !openSetttings && !openNav;
|
275
276
|
return /*#__PURE__*/_jsxs(Box, {
|
276
277
|
...attributes,
|
277
278
|
component: "div",
|
@@ -306,7 +307,7 @@ const Image = props => {
|
|
306
307
|
position: "relative",
|
307
308
|
...getWidth()
|
308
309
|
},
|
309
|
-
children: [
|
310
|
+
children: [showToolBar && /*#__PURE__*/_jsx(ToolBar, {
|
310
311
|
isEmpty: isEmpty,
|
311
312
|
onSettings: onSettings,
|
312
313
|
setOpenNav: setOpenNav,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React from "react";
|
1
|
+
import React, { useEffect, useMemo, useRef } from "react";
|
2
2
|
import { Path, Transforms, Node } from "slate";
|
3
3
|
import { ReactEditor, useSlateStatic } from "slate-react";
|
4
4
|
import { Box, useTheme } from "@mui/material";
|
@@ -43,7 +43,8 @@ const FreeGrid = props => {
|
|
43
43
|
} = props;
|
44
44
|
const {
|
45
45
|
sectionName,
|
46
|
-
sectionBorderRadius
|
46
|
+
sectionBorderRadius,
|
47
|
+
height_xs
|
47
48
|
} = element;
|
48
49
|
const {
|
49
50
|
readOnly,
|
@@ -62,13 +63,17 @@ const FreeGrid = props => {
|
|
62
63
|
height
|
63
64
|
} = breakpointValues(element.type, breakpoint, element);
|
64
65
|
const {
|
65
|
-
setSelectedElement
|
66
|
+
setSelectedElement,
|
67
|
+
setAutoAlign,
|
68
|
+
autoAlign
|
66
69
|
} = useEditorContext();
|
70
|
+
const count = useRef(2);
|
71
|
+
const childrenCountRef = useRef(element?.children?.length);
|
67
72
|
const onChange = data => {
|
68
73
|
const append = breakpoint === "lg" ? "" : `_${breakpoint}`;
|
69
74
|
const updateData = {
|
70
75
|
...data,
|
71
|
-
[`height${append}`]:
|
76
|
+
[`height${append}`]: data.height
|
72
77
|
};
|
73
78
|
if (append !== "") {
|
74
79
|
delete updateData.height;
|
@@ -130,6 +135,10 @@ const FreeGrid = props => {
|
|
130
135
|
setSelectedElement
|
131
136
|
});
|
132
137
|
break;
|
138
|
+
case "forceAutoAlignment":
|
139
|
+
setAutoAlign(true);
|
140
|
+
setSelectedElement({});
|
141
|
+
break;
|
133
142
|
default:
|
134
143
|
}
|
135
144
|
} catch (err) {
|
@@ -144,9 +153,12 @@ const FreeGrid = props => {
|
|
144
153
|
console.log(err);
|
145
154
|
}
|
146
155
|
};
|
156
|
+
useEffect(() => {
|
157
|
+
childrenCountRef.current = element?.children?.length;
|
158
|
+
}, [element?.children?.length]);
|
147
159
|
const handleAddElementClick = type => () => {
|
148
160
|
const isEmpty = isEmptySection();
|
149
|
-
const insertAt = isEmpty ? [...path, 0] : [...path,
|
161
|
+
const insertAt = isEmpty ? [...path, 0] : [...path, childrenCountRef.current];
|
150
162
|
switch (type) {
|
151
163
|
case "addText":
|
152
164
|
Transforms.insertNodes(editor, [{
|
@@ -353,6 +365,17 @@ const FreeGrid = props => {
|
|
353
365
|
break;
|
354
366
|
default:
|
355
367
|
}
|
368
|
+
if (breakpoint === "lg") {
|
369
|
+
// auto align in mobile
|
370
|
+
Transforms.setNodes(editor, {
|
371
|
+
xs_updatedOn: null,
|
372
|
+
updated_at: new Date().getTime()
|
373
|
+
}, {
|
374
|
+
at: path
|
375
|
+
});
|
376
|
+
}
|
377
|
+
count.current = count.current + 1;
|
378
|
+
|
356
379
|
// focus on newly added element
|
357
380
|
focusOnNewItem(editor, insertAt, {
|
358
381
|
setSelectedElement
|
@@ -424,8 +447,16 @@ const FreeGrid = props => {
|
|
424
447
|
}
|
425
448
|
}, theme);
|
426
449
|
const sectionTypeOptions = (itemOptions?.section || []).filter(f => (hideTools || []).indexOf(f) === -1);
|
450
|
+
const id = useMemo(() => {
|
451
|
+
let eleId = `freegrid_container_${path.join("|")}_${breakpoint}`;
|
452
|
+
if (autoAlign) {
|
453
|
+
eleId += `_${updated_at}`; // re-render component on force auto align
|
454
|
+
}
|
455
|
+
|
456
|
+
return eleId;
|
457
|
+
}, [autoAlign, updated_at, breakpoint, path]);
|
427
458
|
return /*#__PURE__*/_jsx(RnD, {
|
428
|
-
id:
|
459
|
+
id: id,
|
429
460
|
className: `
|
430
461
|
freegrid-section breakpoint-${breakpoint}
|
431
462
|
freegrid-section_${path.join("_")}
|
@@ -437,6 +468,9 @@ const FreeGrid = props => {
|
|
437
468
|
position: "relative",
|
438
469
|
"--height": `${height}px`
|
439
470
|
},
|
471
|
+
dataSets: {
|
472
|
+
"data-height-xs": height_xs
|
473
|
+
},
|
440
474
|
defaultStyle: {
|
441
475
|
width: "100%",
|
442
476
|
height: height ? `${height}px` : "auto"
|
@@ -493,7 +527,8 @@ const FreeGrid = props => {
|
|
493
527
|
},
|
494
528
|
customProps: {
|
495
529
|
customProps
|
496
|
-
}
|
530
|
+
},
|
531
|
+
breakpoint
|
497
532
|
}
|
498
533
|
},
|
499
534
|
settings: {
|
@@ -505,8 +540,7 @@ const FreeGrid = props => {
|
|
505
540
|
path,
|
506
541
|
classes,
|
507
542
|
customProps,
|
508
|
-
translation
|
509
|
-
customProps
|
543
|
+
translation
|
510
544
|
}
|
511
545
|
}
|
512
546
|
},
|
@@ -516,6 +550,7 @@ const FreeGrid = props => {
|
|
516
550
|
handleContextMenuClick: handleContextMenuClick,
|
517
551
|
translation: translation,
|
518
552
|
customProps: customProps,
|
553
|
+
sectionElement: element,
|
519
554
|
children: /*#__PURE__*/_jsxs(Box, {
|
520
555
|
...attributes,
|
521
556
|
id: sectionName,
|