@flozy/editor 5.3.4 → 5.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. package/dist/Editor/CommonEditor.js +8 -14
  2. package/dist/Editor/Editor.css +22 -50
  3. package/dist/Editor/Elements/Accordion/Accordion.js +1 -8
  4. package/dist/Editor/Elements/AppHeader/AppHeader.js +6 -6
  5. package/dist/Editor/Elements/Button/EditorButton.js +2 -9
  6. package/dist/Editor/Elements/Color Picker/ColorButtons.js +2 -4
  7. package/dist/Editor/Elements/Divider/Divider.js +9 -24
  8. package/dist/Editor/Elements/Embed/Image.js +12 -31
  9. package/dist/Editor/Elements/Embed/Video.js +2 -13
  10. package/dist/Editor/Elements/Form/Form.js +0 -1
  11. package/dist/Editor/Elements/FreeGrid/breakpointConstants.js +4 -4
  12. package/dist/Editor/Elements/FreeGrid/styles.js +1 -2
  13. package/dist/Editor/Elements/Grid/GridItem.js +0 -2
  14. package/dist/Editor/Elements/Grid/Styles.js +0 -44
  15. package/dist/Editor/Elements/List/CheckList.js +1 -2
  16. package/dist/Editor/Elements/PageSettings/PageSettingsButton.js +0 -1
  17. package/dist/Editor/Elements/Search/SearchAttachment.js +0 -1
  18. package/dist/Editor/Elements/Signature/SignaturePopup.js +4 -4
  19. package/dist/Editor/Elements/SimpleText/index.js +1 -8
  20. package/dist/Editor/Elements/SimpleText/style.js +1 -10
  21. package/dist/Editor/Elements/TopBanner/TopBanner.js +1 -2
  22. package/dist/Editor/Styles/EditorStyles.js +3 -5
  23. package/dist/Editor/Toolbar/FormatTools/FontFamilyAutocomplete.js +1 -17
  24. package/dist/Editor/Toolbar/FormatTools/TextSize.js +3 -5
  25. package/dist/Editor/Toolbar/PopupTool/PopupToolStyle.js +72 -210
  26. package/dist/Editor/Toolbar/PopupTool/TextFormat.js +8 -55
  27. package/dist/Editor/Toolbar/Toolbar.js +0 -6
  28. package/dist/Editor/Toolbar/toolbarGroups.js +0 -4
  29. package/dist/Editor/assets/svg/SettingsIcon.js +4 -4
  30. package/dist/Editor/common/ColorPickerButton.js +3 -5
  31. package/dist/Editor/common/DnD/Draggable.js +1 -2
  32. package/dist/Editor/common/FontLoader/FontLoader.js +4 -4
  33. package/dist/Editor/common/Icon.js +0 -6
  34. package/dist/Editor/common/ImageSelector/Options/Upload.js +1 -2
  35. package/dist/Editor/common/ImageSelector/Styles.js +6 -47
  36. package/dist/Editor/common/ImageSelector/UploadStyles.js +6 -18
  37. package/dist/Editor/common/MentionsPopup/Styles.js +122 -109
  38. package/dist/Editor/common/RnD/ElementSettings/Settings/FormSettings.js +0 -1
  39. package/dist/Editor/common/RnD/GuideLines/styles.js +3 -3
  40. package/dist/Editor/common/RnD/ShadowElement.js +1 -1
  41. package/dist/Editor/common/RnD/SwitchViewport/SwitchViewport.js +2 -14
  42. package/dist/Editor/common/RnD/Utils/gridDropItem.js +6 -9
  43. package/dist/Editor/common/RnD/index.js +1 -2
  44. package/dist/Editor/common/Section/index.js +3 -3
  45. package/dist/Editor/common/Section/styles.js +1 -5
  46. package/dist/Editor/common/Shorthands/elements.js +1 -13
  47. package/dist/Editor/common/StyleBuilder/fieldTypes/backgroundImage.js +3 -9
  48. package/dist/Editor/common/StyleBuilder/fieldTypes/bannerSpacing.js +3 -27
  49. package/dist/Editor/common/StyleBuilder/fieldTypes/borderRadius.js +2 -15
  50. package/dist/Editor/common/StyleBuilder/fieldTypes/card.js +2 -10
  51. package/dist/Editor/common/StyleBuilder/fieldTypes/color.js +1 -2
  52. package/dist/Editor/common/StyleBuilder/fieldTypes/fontSize.js +1 -1
  53. package/dist/Editor/common/StyleBuilder/fieldTypes/icons.js +0 -2
  54. package/dist/Editor/common/StyleBuilder/fieldTypes/index.js +1 -3
  55. package/dist/Editor/common/StyleBuilder/fieldTypes/radiusStyle.js +4 -4
  56. package/dist/Editor/common/StyleBuilder/fieldTypes/saveAsTemplate.js +6 -22
  57. package/dist/Editor/common/StyleBuilder/fieldTypes/selectBox.js +2 -21
  58. package/dist/Editor/common/StyleBuilder/fieldTypes/textOptions.js +0 -7
  59. package/dist/Editor/common/StyleBuilder/index.js +3 -4
  60. package/dist/Editor/common/StyleBuilder/pageSettingsStyle.js +0 -4
  61. package/dist/Editor/common/ToolbarIcon.js +1 -2
  62. package/dist/Editor/common/Uploader.js +36 -46
  63. package/dist/Editor/common/iconListV2.js +130 -348
  64. package/dist/Editor/common/iconslist.js +3 -6
  65. package/dist/Editor/commonStyle.js +4 -290
  66. package/dist/Editor/helper/index.js +3 -16
  67. package/dist/Editor/helper/theme.js +1 -24
  68. package/dist/Editor/hooks/useMouseMove.js +2 -5
  69. package/dist/Editor/plugins/withCustomDeleteBackward.js +2 -33
  70. package/dist/Editor/plugins/withEmbeds.js +26 -30
  71. package/dist/Editor/utils/SlateUtilityFunctions.js +4 -27
  72. package/dist/Editor/utils/button.js +4 -4
  73. package/dist/Editor/utils/helper.js +13 -40
  74. package/dist/Editor/utils/pageSettings.js +2 -14
  75. package/package.json +2 -2
  76. package/dist/Editor/Elements/DataView/DataView.js +0 -124
  77. package/dist/Editor/Elements/DataView/DataViewButton.js +0 -23
  78. package/dist/Editor/Elements/DataView/Layouts/ColumnView.js +0 -67
  79. package/dist/Editor/Elements/DataView/Layouts/DataTypes/CheckType.js +0 -33
  80. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/Select.js +0 -162
  81. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/SimpleSelect.js +0 -40
  82. package/dist/Editor/Elements/DataView/Layouts/DataTypes/Components/styles.js +0 -67
  83. package/dist/Editor/Elements/DataView/Layouts/DataTypes/DateType.js +0 -35
  84. package/dist/Editor/Elements/DataView/Layouts/DataTypes/MultiSelectType.js +0 -39
  85. package/dist/Editor/Elements/DataView/Layouts/DataTypes/NumberType.js +0 -30
  86. package/dist/Editor/Elements/DataView/Layouts/DataTypes/PersonType.js +0 -30
  87. package/dist/Editor/Elements/DataView/Layouts/DataTypes/SelectType.js +0 -35
  88. package/dist/Editor/Elements/DataView/Layouts/DataTypes/TextType.js +0 -36
  89. package/dist/Editor/Elements/DataView/Layouts/DataTypes/index.js +0 -17
  90. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseField.js +0 -29
  91. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/ChooseSort.js +0 -38
  92. package/dist/Editor/Elements/DataView/Layouts/FilterSort/SortOptions/index.js +0 -74
  93. package/dist/Editor/Elements/DataView/Layouts/FilterSort/index.js +0 -64
  94. package/dist/Editor/Elements/DataView/Layouts/FilterSort/styles.js +0 -106
  95. package/dist/Editor/Elements/DataView/Layouts/FilterView.js +0 -174
  96. package/dist/Editor/Elements/DataView/Layouts/Formula.js +0 -29
  97. package/dist/Editor/Elements/DataView/Layouts/Options/AddOptions.js +0 -113
  98. package/dist/Editor/Elements/DataView/Layouts/Options/AddProperty.js +0 -37
  99. package/dist/Editor/Elements/DataView/Layouts/Options/AllProperties.js +0 -111
  100. package/dist/Editor/Elements/DataView/Layouts/Options/ChangeProperty.js +0 -60
  101. package/dist/Editor/Elements/DataView/Layouts/Options/ColumnsList.js +0 -36
  102. package/dist/Editor/Elements/DataView/Layouts/Options/Constants.js +0 -101
  103. package/dist/Editor/Elements/DataView/Layouts/Options/EditOption.js +0 -160
  104. package/dist/Editor/Elements/DataView/Layouts/Options/EditProperty.js +0 -190
  105. package/dist/Editor/Elements/DataView/Layouts/Options/FilterProperty.js +0 -42
  106. package/dist/Editor/Elements/DataView/Layouts/Options/PropertyList.js +0 -30
  107. package/dist/Editor/Elements/DataView/Layouts/Options/index.js +0 -110
  108. package/dist/Editor/Elements/DataView/Layouts/Options/styles.js +0 -179
  109. package/dist/Editor/Elements/DataView/Layouts/TableStyles.js +0 -112
  110. package/dist/Editor/Elements/DataView/Layouts/TableView.js +0 -227
  111. package/dist/Editor/Elements/DataView/Layouts/ViewData.js +0 -80
  112. package/dist/Editor/Elements/DataView/Layouts/colStyles.js +0 -10
  113. package/dist/Editor/Elements/DataView/Layouts/index.js +0 -25
  114. package/dist/Editor/Elements/DataView/Providers/DataViewProvider.js +0 -281
  115. package/dist/Editor/Elements/DataView/Utils/globalSearch.js +0 -15
  116. package/dist/Editor/Elements/DataView/Utils/multiSortRows.js +0 -74
  117. package/dist/Editor/Elements/DataView/styles.js +0 -154
  118. package/dist/Editor/common/StyleBuilder/fieldTypes/lineSpacing.js +0 -79
  119. package/dist/Editor/helper/enforceDateFormat.js +0 -41
  120. package/dist/Editor/utils/dataView.js +0 -43
@@ -4,7 +4,6 @@ import insertNewLine from "./insertNewLine";
4
4
  import { getDevice } from "../helper/theme";
5
5
  export const windowVar = {};
6
6
  let ST_TIMEOUT = null;
7
- const BLOCKS = ["grid", "dataView"];
8
7
  export const formatDate = (date, format = "MM/DD/YYYY") => {
9
8
  if (!date) return "";
10
9
  var d = new Date(date),
@@ -164,7 +163,7 @@ export const handleInsertLastElement = (event, editor) => {
164
163
  if (isFreeGrid) {
165
164
  return;
166
165
  }
167
- const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => BLOCKS.includes(c.type));
166
+ const isLastElementEmpty = lastElement.type === "paragraph" && !lastElement.children[0]?.text && !lastElement.children?.some(c => c.type === "grid");
168
167
  if (!ReactEditor.isFocused(editor)) {
169
168
  if (isLastElementEmpty) {
170
169
  if (hasPath) {
@@ -624,35 +623,6 @@ export const isPageSettings = (event, editor) => {
624
623
  return isPageSettingsNode;
625
624
  }
626
625
  };
627
- export function capitalizeFirstLetter(str) {
628
- if (!str) return str;
629
- return str.charAt(0).toUpperCase() + str.slice(1);
630
- }
631
- export const insertLineBreakAtEndOfPath = (editor, path) => {
632
- try {
633
- const [node, nodePath] = Editor.node(editor, path); // Get the node at the specified path
634
- if (node) {
635
- // Insert the line break
636
- Transforms.insertNodes(editor, {
637
- type: "paragraph",
638
- children: [{
639
- text: ""
640
- }]
641
- }, {
642
- at: nodePath
643
- });
644
- }
645
- } catch (err) {
646
- console.log(err);
647
- }
648
- };
649
- export function isHavingSelection(editor) {
650
- try {
651
- return editor?.selection && !Range.isCollapsed(editor.selection);
652
- } catch (err) {
653
- console.log(err);
654
- }
655
- }
656
626
  const omitNodes = ["site-settings", "page-settings"];
657
627
  export function getInitialValue(value = [], readOnly) {
658
628
  if (readOnly === "readonly" && value?.length) {
@@ -681,14 +651,17 @@ export function getInitialValue(value = [], readOnly) {
681
651
  }
682
652
  return value;
683
653
  }
684
- export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
685
- return `${defaultCls} ${selected ? selectedClsName : ""}`;
654
+ export function capitalizeFirstLetter(str) {
655
+ if (!str) return str;
656
+ return str.charAt(0).toUpperCase() + str.slice(1);
686
657
  }
687
- export function handleNegativeInteger(val) {
688
- return val < 0 ? 0 : val;
658
+ export function isHavingSelection(editor) {
659
+ try {
660
+ return editor?.selection && !Range.isCollapsed(editor.selection);
661
+ } catch (err) {
662
+ console.log(err);
663
+ }
689
664
  }
690
- export const containsSurrogatePair = text => {
691
- // Match surrogate pairs (high and low surrogate)
692
- const surrogatePairRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
693
- return surrogatePairRegex.test(text);
694
- };
665
+ export function getSelectedCls(defaultCls = "", selected, selectedClsName = "selected") {
666
+ return `${defaultCls} ${selected ? selectedClsName : ""}`;
667
+ }
@@ -9,13 +9,7 @@ export const findPageSettings = editor => {
9
9
  path: null,
10
10
  element: {
11
11
  pageProps: {
12
- pageWidth: "fixed",
13
- "lineHeight": {
14
- "xs": 1.43,
15
- "sm": 1.43,
16
- "md": 1.43,
17
- "lg": 1.43
18
- }
12
+ pageWidth: "fixed"
19
13
  }
20
14
  }
21
15
  };
@@ -40,13 +34,7 @@ export const getPageSettings = editor => {
40
34
  path: null,
41
35
  element: {
42
36
  pageProps: {
43
- pageWidth: "fixed",
44
- "lineHeight": {
45
- "xs": 1.43,
46
- "sm": 1.43,
47
- "md": 1.43,
48
- "lg": 1.43
49
- }
37
+ pageWidth: "fixed"
50
38
  }
51
39
  }
52
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "5.3.4",
3
+ "version": "5.3.6",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "files": [
6
6
  "dist"
@@ -68,7 +68,7 @@
68
68
  "storybook": "storybook dev -p 6006",
69
69
  "build-storybook": "NODE_OPTIONS='--max_old_space_size=4096' storybook build",
70
70
  "publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
71
- "publish:local": "rm -rf /Users/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac30/Documents/CODE_BASE/flozy/client/node_modules/@flozy/editor/dist --copy-files"
71
+ "publish:local": "rm -rf /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist && babel src/components -d /Users/agmac03/flozy/client/node_modules/@flozy/editor/dist --copy-files"
72
72
  },
73
73
  "eslintConfig": {
74
74
  "extends": [
@@ -1,124 +0,0 @@
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
- } = props;
25
- const {
26
- CHARACTERS,
27
- readOnly
28
- } = customProps || {};
29
- const {
30
- properties,
31
- layouts,
32
- rows,
33
- title
34
- } = element;
35
- const classes = useDataViewStyles(theme, appTheme);
36
- const path = ReactEditor.findPath(editor, element);
37
- const users = CHARACTERS?.map(m => {
38
- const name = [m?.first_name || "", m?.last_name || ""]?.join(" ").trim();
39
- return {
40
- value: m?.email,
41
- name: name || m?.username || m?.email,
42
- avatar: m?.avatar || null
43
- };
44
- });
45
- const onDuplicate = () => {
46
- try {
47
- const newPath = ReactEditor.findPath(editor, element);
48
- const dataViewNode = Node.get(editor, newPath);
49
- const cloneNode = JSON.parse(JSON.stringify(dataViewNode));
50
- const toPath = Path.next(Path.parent(newPath));
51
- Transforms.insertNodes(editor, [{
52
- type: "paragraph",
53
- children: [{
54
- ...cloneNode
55
- }]
56
- }], {
57
- at: toPath
58
- });
59
- } catch (err) {
60
- console.log(err);
61
- }
62
- };
63
- const onDelete = () => {
64
- try {
65
- const newPath = ReactEditor.findPath(editor, element);
66
- Transforms.removeNodes(editor, {
67
- at: newPath
68
- });
69
- } catch (err) {
70
- console.log(err);
71
- }
72
- };
73
- const onEnter = () => {
74
- try {
75
- const newPath = ReactEditor.findPath(editor, element);
76
- const toPath = Path.previous(Path.parent(newPath));
77
- insertLineBreakAtEndOfPath(editor, toPath);
78
- } catch (err) {
79
- console.log(err);
80
- }
81
- };
82
- const onTitleChange = value => {
83
- try {
84
- Transforms.setNodes(editor, {
85
- title: value
86
- }, {
87
- at: path
88
- });
89
- } catch (err) {
90
- console.log(err);
91
- }
92
- };
93
- return /*#__PURE__*/_jsx(Box, {
94
- ...attributes,
95
- className: "fe-dataview",
96
- sx: classes.root,
97
- contentEditable: false,
98
- "data-title": title,
99
- children: /*#__PURE__*/_jsxs(DataViewProvider, {
100
- data: {
101
- properties,
102
- layouts,
103
- rows
104
- },
105
- path: path,
106
- editor: editor,
107
- title: title,
108
- users: users,
109
- children: [/*#__PURE__*/_jsx(FilterView, {
110
- classes: classes,
111
- onEnter: onEnter,
112
- onDelete: onDelete,
113
- onDuplicate: onDuplicate,
114
- readOnly: readOnly,
115
- title: title,
116
- onTitleChange: onTitleChange
117
- }), /*#__PURE__*/_jsx(LayoutView, {
118
- readOnly: readOnly,
119
- children: children
120
- })]
121
- })
122
- });
123
- };
124
- export default DataView;
@@ -1,23 +0,0 @@
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;
@@ -1,67 +0,0 @@
1
- import React, { useEffect, useRef, useState } from "react";
2
- import { Box, Checkbox, Popper, useTheme } from "@mui/material";
3
- import CheckBoxTwoToneIcon from "@mui/icons-material/CheckBoxTwoTone";
4
- import DataTypes from "./DataTypes";
5
- import useColumnStyles from "./colStyles";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
- const ColumnView = props => {
9
- const theme = useTheme();
10
- const {
11
- needAnchor,
12
- rowIndex,
13
- row,
14
- property,
15
- onSelect,
16
- selected,
17
- readOnly
18
- } = props;
19
- const DataType = DataTypes[property?.type] || DataTypes["text"];
20
- const anchorRef = useRef(null);
21
- const [anchorEl, setAnchorEl] = useState(null);
22
- const open = Boolean(anchorEl);
23
- const classes = useColumnStyles(theme);
24
- useEffect(() => {
25
- if (anchorRef?.current) {
26
- setAnchorEl(anchorRef?.current);
27
- }
28
- }, [anchorRef?.current]);
29
- const handleSelect = id => e => {
30
- onSelect(id, e.target.checked);
31
- };
32
- return /*#__PURE__*/_jsxs(Box, {
33
- component: "td",
34
- children: [needAnchor ? /*#__PURE__*/_jsx("span", {
35
- ref: anchorRef,
36
- style: {
37
- position: "absolute",
38
- width: "1px"
39
- }
40
- }) : null, /*#__PURE__*/_jsx(DataType, {
41
- options: property?.options,
42
- property: property?.key,
43
- value: row[property?.key] || "",
44
- rowIndex: rowIndex,
45
- label: property?.label,
46
- readOnly: readOnly
47
- }), needAnchor && !readOnly ? /*#__PURE__*/_jsx(Popper, {
48
- sx: classes.root,
49
- open: open,
50
- anchorEl: anchorEl,
51
- placement: "left",
52
- className: `tv-tr-pop ${selected ? "active" : ""}`,
53
- disablePortal: true,
54
- children: /*#__PURE__*/_jsx(Checkbox, {
55
- onClick: handleSelect(row?.id),
56
- size: "small",
57
- className: "tv-ck-box",
58
- sx: {
59
- mr: 0
60
- },
61
- checked: selected,
62
- checkedIcon: /*#__PURE__*/_jsx(CheckBoxTwoToneIcon, {})
63
- })
64
- }) : null]
65
- });
66
- };
67
- export default ColumnView;
@@ -1,33 +0,0 @@
1
- import React from "react";
2
- import { useDataView } from "../../Providers/DataViewProvider";
3
- import Checkbox from "@mui/material/Checkbox";
4
- import Icon from "../../../../common/Icon";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- const CheckType = props => {
7
- const {
8
- rowIndex,
9
- property,
10
- value,
11
- readOnly
12
- } = props;
13
- const {
14
- onChange
15
- } = useDataView();
16
- const handleChange = e => {
17
- onChange(rowIndex, {
18
- [property]: e?.target?.checked
19
- });
20
- };
21
- return /*#__PURE__*/_jsx(Checkbox, {
22
- checked: value || false,
23
- icon: /*#__PURE__*/_jsx(Icon, {
24
- icon: "checkListButton"
25
- }),
26
- checkedIcon: /*#__PURE__*/_jsx(Icon, {
27
- icon: "checkListButtonActive"
28
- }),
29
- onChange: handleChange,
30
- disabled: readOnly
31
- }, rowIndex);
32
- };
33
- export default CheckType;
@@ -1,162 +0,0 @@
1
- import React from "react";
2
- import TextField from "@mui/material/TextField";
3
- import Autocomplete from "@mui/material/Autocomplete";
4
- import { Avatar, Box, Chip, useTheme } from "@mui/material";
5
- import { useEditorContext } from "../../../../../hooks/useMouseMove";
6
- import useCompStyles from "./styles";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- const AvatarIcon = props => {
9
- const {
10
- option,
11
- avatar
12
- } = props;
13
- const nameIndex = option.label || option.value;
14
- return avatar && nameIndex ? /*#__PURE__*/_jsx(Avatar, {
15
- alt: option.label || option.value,
16
- src: option.avatar || null,
17
- children: nameIndex[0] || ""
18
- }) : null;
19
- };
20
- const filter = (opt, params, selectedOpt) => {
21
- const selectedVals = selectedOpt?.map(m => m?.value);
22
- const fv = opt?.filter(f => !selectedVals.includes(f.value));
23
- if (params?.inputValue) {
24
- return fv.filter(f => f?.value?.toLowerCase().indexOf(params?.inputValue?.toLowerCase()) >= 0);
25
- }
26
- return fv;
27
- };
28
- export default function Select(props) {
29
- const theme = useTheme();
30
- const {
31
- theme: appTheme
32
- } = useEditorContext();
33
- const classes = useCompStyles(theme, appTheme);
34
- const {
35
- value: pValue,
36
- onChange,
37
- options,
38
- multiple = false,
39
- limitTags = 2,
40
- placeholder = "",
41
- disabled = false,
42
- optionAvatar = false
43
- } = props;
44
- const value = Array.isArray(pValue) ? pValue : [];
45
- return /*#__PURE__*/_jsx(Autocomplete, {
46
- disabled: disabled,
47
- className: "tv-ac-field",
48
- multiple: true,
49
- limitTags: limitTags,
50
- placeholder: placeholder,
51
- value: value || "",
52
- onChange: (event, newValue) => {
53
- const fv = [];
54
- newValue?.forEach(m => {
55
- if (multiple) {
56
- fv.push({
57
- value: m.inputValue || m.value
58
- });
59
- } else {
60
- fv[0] = {
61
- value: m.inputValue || m.value
62
- };
63
- }
64
- });
65
- onChange(fv);
66
- },
67
- filterOptions: (options, params) => {
68
- const filtered = filter(options, params, value);
69
-
70
- // const { inputValue } = params;
71
- // Suggest the creation of a new value
72
- // const isExisting = options.some(
73
- // (option) => inputValue?.toLowerCase() === option.value?.toLowerCase()
74
- // );
75
- // no need of new val now
76
- // if (inputValue !== "" && !isExisting) {
77
- // filtered.push({
78
- // inputValue,
79
- // value: `Add "${inputValue}"`,
80
- // });
81
- // }
82
-
83
- return filtered;
84
- },
85
- selectOnFocus: true,
86
- clearOnBlur: true,
87
- handleHomeEndKeys: true,
88
- options: options || [],
89
- getOptionLabel: option => {
90
- // Value selected with enter, right from the input
91
- if (typeof option === "string") {
92
- return option;
93
- }
94
- // Add "xxx" option created dynamically
95
- if (option.inputValue) {
96
- return option.inputValue;
97
- }
98
- // Regular option
99
- return option.value || "";
100
- },
101
- renderTags: (value, getTagProps) => {
102
- return /*#__PURE__*/_jsx(Box, {
103
- className: "tv-ms-tag-wrpr",
104
- children: value?.map((option, index) => {
105
- const {
106
- key,
107
- ...tagProps
108
- } = getTagProps({
109
- index
110
- }) || {};
111
- return option?.value ? /*#__PURE__*/_jsx(Chip, {
112
- variant: "outlined",
113
- label: option?.label || option?.value,
114
- ...tagProps,
115
- sx: {
116
- background: option?.color || "#CCC",
117
- border: "none"
118
- },
119
- avatar: /*#__PURE__*/_jsx(AvatarIcon, {
120
- option: option,
121
- avatar: optionAvatar
122
- })
123
- }, key) : null;
124
- })
125
- });
126
- },
127
- renderOption: (props, option) => {
128
- const {
129
- key,
130
- ...optionProps
131
- } = props;
132
- return /*#__PURE__*/_jsx("li", {
133
- ...optionProps,
134
- children: /*#__PURE__*/_jsx(Chip, {
135
- label: option.label || option.value || "",
136
- sx: {
137
- background: option.color || "#CCC"
138
- },
139
- avatar: /*#__PURE__*/_jsx(AvatarIcon, {
140
- option: option,
141
- avatar: optionAvatar
142
- })
143
- })
144
- }, key);
145
- },
146
- freeSolo: true,
147
- size: "small",
148
- fullWidth: true,
149
- renderInput: params => {
150
- return /*#__PURE__*/_jsx(TextField, {
151
- size: "small",
152
- ...params,
153
- placeholder: placeholder
154
- });
155
- },
156
- slotProps: {
157
- paper: {
158
- sx: classes.autocomplete
159
- }
160
- }
161
- });
162
- }
@@ -1,40 +0,0 @@
1
- import React from "react";
2
- import { MenuItem, Select, useTheme } from "@mui/material";
3
- import { useEditorContext } from "../../../../../hooks/useMouseMove";
4
- import useCompStyles from "./styles";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- const SimpleSelect = props => {
7
- const theme = useTheme();
8
- const {
9
- theme: appTheme
10
- } = useEditorContext();
11
- const classes = useCompStyles(theme, appTheme);
12
- const {
13
- value,
14
- options,
15
- handleChange,
16
- disabled = false
17
- } = props;
18
- console.log(classes);
19
- return /*#__PURE__*/_jsx(Select, {
20
- disabled: disabled,
21
- value: value,
22
- onChange: handleChange,
23
- fullWidth: true,
24
- size: "small",
25
- MenuProps: {
26
- PaperProps: {
27
- sx: classes.simpleselect,
28
- className: "tv-cf-opt-wrpr"
29
- }
30
- },
31
- children: options?.map((m, i) => {
32
- return /*#__PURE__*/_jsx(MenuItem, {
33
- value: m.key,
34
- className: "tv-cf-opt-wrpr",
35
- children: m.label
36
- }, i);
37
- })
38
- });
39
- };
40
- export default SimpleSelect;
@@ -1,67 +0,0 @@
1
- const useCompStyles = (theme, appTheme) => ({
2
- simpleselect: {
3
- border: `1px solid ${appTheme?.palette?.editor?.tv_border}`,
4
- background: appTheme?.palette?.editor?.tv_pop_bg,
5
- color: appTheme?.palette?.editor?.tv_text_primary,
6
- borderRadius: "8px",
7
- [theme?.breakpoints?.between("xs", "md")]: {},
8
- "& ul": {
9
- padding: "4px",
10
- "& li": {
11
- padding: "4px 6px",
12
- borderRadius: "8px",
13
- color: appTheme?.palette?.editor?.tv_text_primary,
14
- fontSize: "14px",
15
- marginTop: "4px",
16
- "&.Mui-selected": {
17
- background: appTheme?.palette?.editor?.tv_hover_bg,
18
- color: appTheme?.palette?.editor?.tv_hover_text,
19
- "&:hover": {
20
- background: appTheme?.palette?.editor?.tv_hover_bg,
21
- color: appTheme?.palette?.editor?.tv_hover_text
22
- }
23
- },
24
- "&:hover": {
25
- background: appTheme?.palette?.editor?.tv_hover_bg,
26
- color: appTheme?.palette?.editor?.tv_hover_text
27
- }
28
- }
29
- }
30
- },
31
- autocomplete: {
32
- border: `1px solid ${appTheme?.palette?.editor?.tv_border}`,
33
- background: appTheme?.palette?.editor?.tv_pop_bg,
34
- color: appTheme?.palette?.editor?.tv_text_primary,
35
- borderRadius: "8px",
36
- "& ul": {
37
- padding: "4px",
38
- "& .MuiAutocomplete-option": {
39
- padding: "4px 6px",
40
- borderRadius: "8px",
41
- color: appTheme?.palette?.editor?.tv_text_primary,
42
- fontSize: "14px",
43
- "& .MuiAvatar-root": {
44
- width: "20px",
45
- height: "20px",
46
- marginLeft: "8px",
47
- fontSize: "16px",
48
- padding: "2px",
49
- textTransform: "capitalize"
50
- },
51
- "&.Mui-selected": {
52
- background: appTheme?.palette?.editor?.tv_hover_bg,
53
- color: appTheme?.palette?.editor?.tv_hover_text,
54
- "&:hover": {
55
- background: appTheme?.palette?.editor?.tv_hover_bg,
56
- color: appTheme?.palette?.editor?.tv_hover_text
57
- }
58
- },
59
- "&:hover": {
60
- background: appTheme?.palette?.editor?.tv_hover_bg,
61
- color: appTheme?.palette?.editor?.tv_hover_text
62
- }
63
- }
64
- }
65
- }
66
- });
67
- export default useCompStyles;
@@ -1,35 +0,0 @@
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
- function isValidDate(dateString) {
6
- const date = new Date(dateString);
7
- return !isNaN(date.getTime());
8
- }
9
- const DateType = props => {
10
- const {
11
- rowIndex,
12
- property,
13
- value,
14
- readOnly
15
- } = props;
16
- const {
17
- onChange
18
- } = useDataView();
19
- const handleChange = date => {
20
- onChange(rowIndex, {
21
- [property]: date
22
- });
23
- };
24
- return /*#__PURE__*/_jsx(DatePicker, {
25
- disabled: readOnly,
26
- selected: isValidDate(value) ? new Date(value) : "",
27
- onChange: handleChange,
28
- onKeyDown: e => {
29
- e.preventDefault();
30
- console.log(e?.target.value);
31
- },
32
- placeholderText: "MM/DD/YYYY"
33
- });
34
- };
35
- export default DateType;