@flozy/editor 5.0.5 → 5.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/dist/Editor/CommonEditor.js +6 -4
  2. package/dist/Editor/Editor.css +19 -1
  3. package/dist/Editor/Elements/Button/EditorButton.js +71 -53
  4. package/dist/Editor/Elements/Color Picker/ColorButtons.js +4 -2
  5. package/dist/Editor/Elements/DataView/DataView.js +101 -0
  6. package/dist/Editor/Elements/DataView/DataViewButton.js +23 -0
  7. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +59 -0
  8. package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +30 -0
  9. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +128 -0
  10. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +25 -0
  11. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +26 -0
  12. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +38 -0
  13. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +30 -0
  14. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +30 -0
  15. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +35 -0
  16. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +36 -0
  17. package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +17 -0
  18. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +28 -0
  19. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +37 -0
  20. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +74 -0
  21. package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +59 -0
  22. package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +66 -0
  23. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +174 -0
  24. package/dist/Editor/Elements/DataView/Layouts/Formula.js +29 -0
  25. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +113 -0
  26. package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +37 -0
  27. package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +111 -0
  28. package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +62 -0
  29. package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +36 -0
  30. package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +101 -0
  31. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +158 -0
  32. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +190 -0
  33. package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +42 -0
  34. package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +30 -0
  35. package/dist/Editor/Elements/DataView/Layouts/Options/index.js +110 -0
  36. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +176 -0
  37. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +94 -0
  38. package/dist/Editor/Elements/DataView/Layouts/TableView.js +214 -0
  39. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +83 -0
  40. package/dist/Editor/Elements/DataView/Layouts/index.js +25 -0
  41. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +288 -0
  42. package/dist/Editor/Elements/DataView/Utils/globalSearch.js +15 -0
  43. package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +72 -0
  44. package/dist/Editor/Elements/DataView/styles.js +133 -0
  45. package/dist/Editor/Elements/FreeGrid/styles.js +2 -1
  46. package/dist/Editor/Elements/Signature/Signature.css +1 -1
  47. package/dist/Editor/Elements/Table/AddRowCol.js +1 -1
  48. package/dist/Editor/Elements/Table/DragButton.js +71 -68
  49. package/dist/Editor/Elements/Table/Styles.js +2 -2
  50. package/dist/Editor/Elements/Table/Table.js +10 -7
  51. package/dist/Editor/Elements/Table/TableCell.js +21 -21
  52. package/dist/Editor/Elements/Table/tableHelper.js +4 -16
  53. package/dist/Editor/Toolbar/PopupTool/index.js +1 -1
  54. package/dist/Editor/Toolbar/Toolbar.js +6 -0
  55. package/dist/Editor/Toolbar/toolbarGroups.js +4 -0
  56. package/dist/Editor/assets/svg/OpenLinkIcon.js +3 -3
  57. package/dist/Editor/common/Icon.js +7 -1
  58. package/dist/Editor/common/MentionsPopup/index.js +1 -1
  59. package/dist/Editor/common/Shorthands/elements.js +13 -1
  60. package/dist/Editor/common/StyleBuilder/tableStyle.js +1 -1
  61. package/dist/Editor/common/iconslist.js +6 -3
  62. package/dist/Editor/hooks/useTable.js +4 -5
  63. package/dist/Editor/plugins/withHTML.js +18 -2
  64. package/dist/Editor/utils/SlateUtilityFunctions.js +16 -0
  65. package/dist/Editor/utils/dataView.js +43 -0
  66. package/dist/Editor/utils/embed.js +2 -1
  67. package/dist/Editor/utils/helper.js +19 -1
  68. package/dist/Editor/utils/insertNewLine.js +19 -1
  69. package/package.json +1 -1
@@ -298,10 +298,12 @@ const CommonEditor = /*#__PURE__*/forwardRef((props, ref) => {
298
298
  hideTools: updatedHideTools || []
299
299
  }) : [];
300
300
  const handleEditorChange = newValue => {
301
- if (JSON.stringify(newValue) !== JSON.stringify(debouncedValue?.current)) {
302
- debounced(newValue);
303
- if (!isInteracted) {
304
- setIsInteracted(true);
301
+ if (!readOnly) {
302
+ if (JSON.stringify(newValue) !== JSON.stringify(debouncedValue?.current)) {
303
+ debounced(newValue);
304
+ if (!isInteracted) {
305
+ setIsInteracted(true);
306
+ }
305
307
  }
306
308
  }
307
309
  };
@@ -397,7 +397,7 @@ blockquote {
397
397
  .signature-tab2 {
398
398
  /* display: flex; */
399
399
  align-items: center;
400
- border-width: 0px, 0px, 0px, 0px;
400
+ border-width: 1px;
401
401
  border-style: solid;
402
402
  border-color: #2563EB66;
403
403
  justify-content: center;
@@ -1261,3 +1261,21 @@ blockquote {
1261
1261
  .hideScroll::-webkit-scrollbar-thumb:hover {
1262
1262
  background: none !important;
1263
1263
  }
1264
+
1265
+ .custom-scroll::-webkit-scrollbar {
1266
+ height: .6rem;
1267
+ }
1268
+
1269
+ .custom-scroll::-webkit-scrollbar-thumb {
1270
+ background: #888;
1271
+ border-radius: 5px;
1272
+ cursor: pointer;
1273
+ }
1274
+
1275
+ .custom-scroll::-webkit-scrollbar-track {
1276
+ background: #f1f1f1;
1277
+ }
1278
+
1279
+ .custom-scroll:hover::-webkit-scrollbar-thumb {
1280
+ background: #A7AEC1;
1281
+ }
@@ -1,7 +1,7 @@
1
- import React, { useState } from "react";
1
+ import React, { useState, useRef } from "react";
2
2
  import { Transforms } from "slate";
3
3
  import { ReactEditor, useSlateStatic } from "slate-react";
4
- import { IconButton, Tooltip, Box, useTheme } from "@mui/material";
4
+ import { IconButton, Tooltip, Box, useTheme, Popper } from "@mui/material";
5
5
  import MUIIcon from "../../common/StyleBuilder/fieldTypes/loadIcon";
6
6
  import ButtonPopup from "./ButtonPopup";
7
7
  import { actionButtonRedirect } from "../../service/actionTrigger";
@@ -12,12 +12,14 @@ import LinkSettings from "../../common/LinkSettings";
12
12
  import Icon from "../../common/Icon";
13
13
  import { useEditorContext } from "../../hooks/useMouseMove";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
+ import { Fragment as _Fragment } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
17
  const EditorButton = props => {
17
18
  const theme = useTheme();
18
19
  const {
19
20
  theme: appTheme
20
21
  } = useEditorContext();
22
+ const buttonRef = useRef(null);
21
23
  const {
22
24
  attributes,
23
25
  element,
@@ -111,48 +113,60 @@ const EditorButton = props => {
111
113
  const Toolbar = () => {
112
114
  const btnProps = handleLinkType(refURl, linkType, true, openInNewTab, handleTrigger);
113
115
  const hideOpenLink = linkType === "page" || !linkType;
114
- return !readOnly ? /*#__PURE__*/_jsxs("div", {
115
- className: "element-toolbar hr",
116
- style: {
117
- width: "max-content",
118
- top: "-33px",
119
- alignItems: "center",
120
- cursor: "pointer"
116
+ return !readOnly && openMoreOptions ? /*#__PURE__*/_jsx(Popper, {
117
+ anchorEl: buttonRef?.current,
118
+ placement: "top-end",
119
+ open: openMoreOptions,
120
+ sx: {
121
+ zIndex: 1000
121
122
  },
122
- children: [/*#__PURE__*/_jsx(Tooltip, {
123
- title: "Settings",
124
- arrow: true,
125
- children: /*#__PURE__*/_jsx(IconButton, {
126
- onClick: onMenuClick("edit"),
127
- children: /*#__PURE__*/_jsx(Icon, {
128
- icon: "pagesSettings"
123
+ children: /*#__PURE__*/_jsxs("div", {
124
+ className: "element-toolbar hr",
125
+ style: {
126
+ width: "max-content",
127
+ top: "-35px",
128
+ alignItems: "center",
129
+ cursor: "pointer",
130
+ display: "flex",
131
+ alignContent: "center",
132
+ justifyContent: "center"
133
+ },
134
+ children: [/*#__PURE__*/_jsx(Tooltip, {
135
+ title: "Settings",
136
+ arrow: true,
137
+ children: /*#__PURE__*/_jsx(IconButton, {
138
+ onClick: onMenuClick("edit"),
139
+ children: /*#__PURE__*/_jsx(Icon, {
140
+ icon: "pagesSettings"
141
+ })
129
142
  })
130
- })
131
- }), /*#__PURE__*/_jsx(Tooltip, {
132
- title: "Nav Settings",
133
- arrow: true,
134
- children: /*#__PURE__*/_jsx(IconButton, {
135
- onClick: onMenuClick("nav"),
136
- children: /*#__PURE__*/_jsx(Icon, {
137
- icon: "link"
143
+ }), /*#__PURE__*/_jsx(Tooltip, {
144
+ title: "Nav Settings",
145
+ arrow: true,
146
+ children: /*#__PURE__*/_jsx(IconButton, {
147
+ onClick: onMenuClick("nav"),
148
+ children: /*#__PURE__*/_jsx(Icon, {
149
+ icon: "link"
150
+ })
138
151
  })
139
- })
140
- }), hideOpenLink ? null : /*#__PURE__*/_jsx(Tooltip, {
141
- title: "Open Link",
142
- arrow: true,
143
- children: /*#__PURE__*/_jsx(Box, {
144
- sx: {
145
- display: "inline-flex",
146
- color: "rgba(0, 0, 0, 0.54)",
147
- borderRadius: "50% !important",
148
- border: "none !important"
149
- },
150
- ...btnProps,
151
- children: /*#__PURE__*/_jsx(Icon, {
152
- icon: "openLinkIcon"
152
+ }), hideOpenLink ? null : /*#__PURE__*/_jsx(_Fragment, {
153
+ children: /*#__PURE__*/_jsx(Tooltip, {
154
+ title: "Open Link",
155
+ arrow: true,
156
+ children: /*#__PURE__*/_jsx(Box, {
157
+ sx: {
158
+ display: "inline-flex",
159
+ color: "rgba(0, 0, 0, 0.54)",
160
+ marginBottom: "0px !important"
161
+ },
162
+ ...btnProps,
163
+ children: /*#__PURE__*/_jsx(Icon, {
164
+ icon: "openLinkIcon"
165
+ })
166
+ })
153
167
  })
154
- })
155
- })]
168
+ })]
169
+ })
156
170
  }) : null;
157
171
  };
158
172
  const onSave = data => {
@@ -232,6 +246,7 @@ const EditorButton = props => {
232
246
  display: "inline-block"
233
247
  },
234
248
  children: [/*#__PURE__*/_jsxs(Box, {
249
+ ref: buttonRef,
235
250
  className: `btn textAlign-${tAlign}`,
236
251
  sx: {
237
252
  textDecoration: "none",
@@ -274,19 +289,22 @@ const EditorButton = props => {
274
289
  },
275
290
  props: customProps
276
291
  })]
277
- }), !readOnly && /*#__PURE__*/_jsx(IconButton, {
278
- className: `moreBtnShow ${isMobile || openMoreOptions ? "activeBtnShow" : ""}`,
279
- sx: {
280
- position: "absolute",
281
- right: "-42px",
282
- stroke: "#fff",
283
- "& path": {
284
- fill: openMoreOptions ? appTheme.palette.text.blueText : ""
285
- }
286
- },
287
- onClick: handleMoreBtn,
288
- children: /*#__PURE__*/_jsx(Icon, {
289
- icon: "moreVertical"
292
+ }), !readOnly && buttonRef?.current && /*#__PURE__*/_jsx(Popper, {
293
+ anchorEl: buttonRef?.current,
294
+ open: true,
295
+ placement: "right",
296
+ container: buttonRef?.current,
297
+ children: /*#__PURE__*/_jsx(IconButton, {
298
+ className: `moreBtnShow ${isMobile || openMoreOptions ? "activeBtnShow" : ""}`,
299
+ sx: {
300
+ "& path": {
301
+ fill: openMoreOptions ? appTheme.palette.text.blueText : ""
302
+ }
303
+ },
304
+ onClick: handleMoreBtn,
305
+ children: /*#__PURE__*/_jsx(Icon, {
306
+ icon: "moreVertical"
307
+ })
290
308
  })
291
309
  }), !readOnly && isTrigger ? /*#__PURE__*/_jsx(IconButton, {
292
310
  className: "workflow-icon-btn",
@@ -109,11 +109,13 @@ const ColorButtons = props => {
109
109
  forMiniTool,
110
110
  openColorTool,
111
111
  onClose,
112
- onColorPickerClick
112
+ onColorPickerClick,
113
+ defaultColors = []
113
114
  } = props;
114
115
  const [row1, ...restRows] = ColorChunks([]);
115
116
  const [anchorEl, setAnchorEl] = useState(null);
116
117
  const open = Boolean(anchorEl);
118
+ const firstRow = defaultColors || row1;
117
119
  const handleMore = e => {
118
120
  setAnchorEl(e.currentTarget);
119
121
  };
@@ -131,7 +133,7 @@ const ColorButtons = props => {
131
133
  sx: classes.colorButtons,
132
134
  children: [forMiniTool ? null : /*#__PURE__*/_jsx(Box, {
133
135
  className: "buttonsWrpr first",
134
- children: [row1].map((m, i) => {
136
+ children: [firstRow].map((m, i) => {
135
137
  return /*#__PURE__*/_jsx(SingleColorButton, {
136
138
  id: `p1_${id}`,
137
139
  crs: m,
@@ -0,0 +1,101 @@
1
+ import React from "react";
2
+ import { Node, Path, Transforms } from "slate";
3
+ import { ReactEditor, useSlateStatic } from "slate-react";
4
+ import { Box, useTheme } from "@mui/material";
5
+ import { DataViewProvider } from "./Providers/DataViewProvider";
6
+ import useDataViewStyles from "./styles";
7
+ import LayoutView from "./Layouts";
8
+ import FilterView from "./Layouts/FilterView";
9
+ import { insertLineBreakAtEndOfPath } from "../../utils/helper";
10
+ import { useEditorContext } from "../../hooks/useMouseMove";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ const DataView = props => {
14
+ const {
15
+ theme: appTheme
16
+ } = useEditorContext();
17
+ const theme = useTheme();
18
+ const editor = useSlateStatic();
19
+ const {
20
+ attributes,
21
+ children,
22
+ element,
23
+ customProps,
24
+ title
25
+ } = props;
26
+ const {
27
+ CHARACTERS,
28
+ readOnly
29
+ } = customProps || {};
30
+ const {
31
+ properties,
32
+ layouts,
33
+ rows
34
+ } = element;
35
+ const classes = useDataViewStyles(theme, appTheme);
36
+ const path = ReactEditor.findPath(editor, element);
37
+ const onDuplicate = () => {
38
+ try {
39
+ const newPath = ReactEditor.findPath(editor, element);
40
+ const dataViewNode = Node.get(editor, newPath);
41
+ const cloneNode = JSON.parse(JSON.stringify(dataViewNode));
42
+ const toPath = Path.next(Path.parent(newPath));
43
+ Transforms.insertNodes(editor, [{
44
+ type: "paragraph",
45
+ children: [{
46
+ ...cloneNode
47
+ }]
48
+ }], {
49
+ at: toPath
50
+ });
51
+ } catch (err) {
52
+ console.log(err);
53
+ }
54
+ };
55
+ const onDelete = () => {
56
+ try {
57
+ const newPath = ReactEditor.findPath(editor, element);
58
+ Transforms.removeNodes(editor, {
59
+ at: newPath
60
+ });
61
+ } catch (err) {
62
+ console.log(err);
63
+ }
64
+ };
65
+ const onEnter = () => {
66
+ try {
67
+ const newPath = ReactEditor.findPath(editor, element);
68
+ const toPath = Path.previous(Path.parent(newPath));
69
+ insertLineBreakAtEndOfPath(editor, toPath);
70
+ } catch (err) {
71
+ console.log(err);
72
+ }
73
+ };
74
+ return /*#__PURE__*/_jsx(Box, {
75
+ ...attributes,
76
+ className: "fe-dataview",
77
+ sx: classes.root,
78
+ children: /*#__PURE__*/_jsxs(DataViewProvider, {
79
+ initialData: {
80
+ properties,
81
+ layouts,
82
+ rows,
83
+ users: CHARACTERS,
84
+ tableTitle: title
85
+ },
86
+ path: path,
87
+ editor: editor,
88
+ children: [/*#__PURE__*/_jsx(FilterView, {
89
+ classes: classes,
90
+ onEnter: onEnter,
91
+ onDelete: onDelete,
92
+ onDuplicate: onDuplicate,
93
+ readOnly: readOnly
94
+ }), /*#__PURE__*/_jsx(LayoutView, {
95
+ readOnly: readOnly,
96
+ children: children
97
+ })]
98
+ })
99
+ });
100
+ };
101
+ export default DataView;
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ import ToolbarIcon from "../../common/ToolbarIcon";
3
+ import Icon from "../../common/Icon";
4
+ import { insertDataView } from "../../utils/dataView";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const DataViewButton = props => {
7
+ const {
8
+ editor,
9
+ icoBtnType
10
+ } = props;
11
+ const onClick = () => {
12
+ insertDataView(editor);
13
+ };
14
+ return /*#__PURE__*/_jsx(ToolbarIcon, {
15
+ title: "Dynamic Table",
16
+ onClick: onClick,
17
+ icon: /*#__PURE__*/_jsx(Icon, {
18
+ icon: "dataView"
19
+ }),
20
+ icoBtnType: icoBtnType
21
+ });
22
+ };
23
+ export default DataViewButton;
@@ -0,0 +1,59 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import { Box, Checkbox, Popper } from "@mui/material";
3
+ import DataTypes from "./DataTypes";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ const ColumnView = props => {
7
+ const {
8
+ needAnchor,
9
+ rowIndex,
10
+ row,
11
+ property,
12
+ onSelect,
13
+ selected,
14
+ readOnly
15
+ } = props;
16
+ const DataType = DataTypes[property?.type] || DataTypes["text"];
17
+ const anchorRef = useRef(null);
18
+ const [anchorEl, setAnchorEl] = useState(null);
19
+ const open = Boolean(anchorEl);
20
+ useEffect(() => {
21
+ if (anchorRef?.current) {
22
+ setAnchorEl(anchorRef?.current);
23
+ }
24
+ }, [anchorRef?.current]);
25
+ const handleSelect = id => e => {
26
+ onSelect(id, e.target.checked);
27
+ };
28
+ return /*#__PURE__*/_jsxs(Box, {
29
+ component: "td",
30
+ ref: anchorRef,
31
+ children: [/*#__PURE__*/_jsx(DataType, {
32
+ options: property?.options,
33
+ property: property?.key,
34
+ value: row[property?.key] || "",
35
+ rowIndex: rowIndex,
36
+ label: property?.label,
37
+ readOnly: readOnly
38
+ }), needAnchor && !readOnly ? /*#__PURE__*/_jsx(Popper, {
39
+ sx: {
40
+ zIndex: 1000
41
+ },
42
+ open: open,
43
+ anchorEl: anchorEl,
44
+ placement: "left",
45
+ container: anchorRef?.current,
46
+ className: `tv-tr-pop ${selected ? "active" : ""}`,
47
+ children: /*#__PURE__*/_jsx(Checkbox, {
48
+ onClick: handleSelect(row?.id),
49
+ size: "small",
50
+ className: "tv-ck-box",
51
+ sx: {
52
+ mr: 0
53
+ },
54
+ checked: selected
55
+ })
56
+ }) : null]
57
+ });
58
+ };
59
+ export default ColumnView;
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import { useDataView } from "../../Providers/DataViewProvider";
3
+ import Checkbox from "@mui/material/Checkbox";
4
+ import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
5
+ import CheckCircleIcon from "@mui/icons-material/CheckCircle";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const CheckType = props => {
8
+ const {
9
+ rowIndex,
10
+ property,
11
+ value,
12
+ readOnly
13
+ } = props;
14
+ const {
15
+ onChange
16
+ } = useDataView();
17
+ const handleChange = e => {
18
+ onChange(rowIndex, {
19
+ [property]: e?.target?.checked
20
+ });
21
+ };
22
+ return /*#__PURE__*/_jsx(Checkbox, {
23
+ checked: value,
24
+ icon: /*#__PURE__*/_jsx(CheckCircleOutlineIcon, {}),
25
+ checkedIcon: /*#__PURE__*/_jsx(CheckCircleIcon, {}),
26
+ onChange: handleChange,
27
+ disabled: readOnly
28
+ }, rowIndex);
29
+ };
30
+ export default CheckType;
@@ -0,0 +1,128 @@
1
+ import React from "react";
2
+ import TextField from "@mui/material/TextField";
3
+ import Autocomplete from "@mui/material/Autocomplete";
4
+ import { Box, Chip } from "@mui/material";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const filter = (opt, params, selectedOpt) => {
7
+ const selectedVals = selectedOpt?.map(m => m?.value);
8
+ const fv = opt?.filter(f => !selectedVals.includes(f.value));
9
+ if (params?.inputValue) {
10
+ fv.filter(f => f?.value?.toLowerCase().indexOf(params?.inputValue?.toLowerCase()) >= 0);
11
+ }
12
+ return fv;
13
+ };
14
+ export default function Select(props) {
15
+ const {
16
+ value,
17
+ onChange,
18
+ options,
19
+ multiple = false,
20
+ limitTags = 2,
21
+ placeholder = "",
22
+ disabled = false
23
+ } = props;
24
+ return /*#__PURE__*/_jsx(Autocomplete, {
25
+ disabled: disabled,
26
+ className: "tv-ac-field",
27
+ multiple: true,
28
+ limitTags: limitTags,
29
+ placeholder: placeholder,
30
+ value: value || "",
31
+ onChange: (event, newValue) => {
32
+ const fv = [];
33
+ newValue?.forEach(m => {
34
+ if (multiple) {
35
+ fv.push({
36
+ value: m.inputValue || m.value
37
+ });
38
+ } else {
39
+ fv[0] = {
40
+ value: m.inputValue || m.value
41
+ };
42
+ }
43
+ });
44
+ onChange(fv);
45
+ },
46
+ filterOptions: (options, params) => {
47
+ const filtered = filter(options, params, value);
48
+
49
+ // const { inputValue } = params;
50
+ // Suggest the creation of a new value
51
+ // const isExisting = options.some(
52
+ // (option) => inputValue?.toLowerCase() === option.value?.toLowerCase()
53
+ // );
54
+ // no need of new val now
55
+ // if (inputValue !== "" && !isExisting) {
56
+ // filtered.push({
57
+ // inputValue,
58
+ // value: `Add "${inputValue}"`,
59
+ // });
60
+ // }
61
+
62
+ return filtered;
63
+ },
64
+ selectOnFocus: true,
65
+ clearOnBlur: true,
66
+ handleHomeEndKeys: true,
67
+ options: options || [],
68
+ getOptionLabel: option => {
69
+ // Value selected with enter, right from the input
70
+ if (typeof option === "string") {
71
+ return option;
72
+ }
73
+ // Add "xxx" option created dynamically
74
+ if (option.inputValue) {
75
+ return option.inputValue;
76
+ }
77
+ // Regular option
78
+ return option.value || "";
79
+ },
80
+ renderTags: (value, getTagProps) => {
81
+ return /*#__PURE__*/_jsx(Box, {
82
+ className: "tv-ms-tag-wrpr",
83
+ children: value?.map((option, index) => {
84
+ const {
85
+ key,
86
+ ...tagProps
87
+ } = getTagProps({
88
+ index
89
+ }) || {};
90
+ return option?.value ? /*#__PURE__*/_jsx(Chip, {
91
+ variant: "outlined",
92
+ label: option?.label || option?.value,
93
+ ...tagProps,
94
+ sx: {
95
+ background: option?.color || "#CCC",
96
+ border: "none"
97
+ }
98
+ }, key) : null;
99
+ })
100
+ });
101
+ },
102
+ renderOption: (props, option) => {
103
+ const {
104
+ key,
105
+ ...optionProps
106
+ } = props;
107
+ return /*#__PURE__*/_jsx("li", {
108
+ ...optionProps,
109
+ children: /*#__PURE__*/_jsx(Chip, {
110
+ label: option.label || option.value || "",
111
+ sx: {
112
+ backgroundColor: option.color || "#CCC"
113
+ }
114
+ })
115
+ }, key);
116
+ },
117
+ freeSolo: true,
118
+ size: "small",
119
+ fullWidth: true,
120
+ renderInput: params => {
121
+ return /*#__PURE__*/_jsx(TextField, {
122
+ size: "small",
123
+ ...params,
124
+ placeholder: placeholder
125
+ });
126
+ }
127
+ });
128
+ }
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { MenuItem, Select } from "@mui/material";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const SimpleSelect = props => {
5
+ const {
6
+ value,
7
+ options,
8
+ handleChange,
9
+ disabled = false
10
+ } = props;
11
+ return /*#__PURE__*/_jsx(Select, {
12
+ disabled: disabled,
13
+ value: value,
14
+ onChange: handleChange,
15
+ fullWidth: true,
16
+ size: "small",
17
+ children: options?.map((m, i) => {
18
+ return /*#__PURE__*/_jsx(MenuItem, {
19
+ value: m.key,
20
+ children: m.label
21
+ }, i);
22
+ })
23
+ });
24
+ };
25
+ export default SimpleSelect;
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import DatePicker from "react-datepicker";
3
+ import { useDataView } from "../../Providers/DataViewProvider";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const DateType = props => {
6
+ const {
7
+ rowIndex,
8
+ property,
9
+ value,
10
+ readOnly
11
+ } = props;
12
+ const {
13
+ onChange
14
+ } = useDataView();
15
+ const handleChange = date => {
16
+ onChange(rowIndex, {
17
+ [property]: date
18
+ });
19
+ };
20
+ return /*#__PURE__*/_jsx(DatePicker, {
21
+ disabled: readOnly,
22
+ selected: value ? new Date(value) : "",
23
+ onChange: handleChange
24
+ });
25
+ };
26
+ export default DateType;
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import { useDataView } from "../../Providers/DataViewProvider";
3
+ import Select from "./Components/Select";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const MultiSelectType = props => {
6
+ const {
7
+ rowIndex,
8
+ property,
9
+ value,
10
+ options,
11
+ label = "",
12
+ readOnly
13
+ } = props;
14
+ const {
15
+ onChange
16
+ } = useDataView();
17
+ const coloredValues = [...(value || [])]?.map(m => {
18
+ return {
19
+ ...m,
20
+ color: options?.find(f => f.value === m.value)?.color || "#FFF"
21
+ };
22
+ });
23
+ const handleChange = data => {
24
+ onChange(rowIndex, {
25
+ [property]: data?.filter(f => f?.value)
26
+ });
27
+ };
28
+ return /*#__PURE__*/_jsx(Select, {
29
+ value: coloredValues,
30
+ onChange: handleChange,
31
+ options: options,
32
+ multiple: true,
33
+ limitTags: 2,
34
+ placeholder: label,
35
+ disabled: readOnly
36
+ });
37
+ };
38
+ export default MultiSelectType;