@monolith-forensics/monolith-ui 1.2.91 → 1.2.92

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.
Files changed (122) hide show
  1. package/dist/Button/Button.d.ts +1 -0
  2. package/dist/Button/Button.js +3 -2
  3. package/dist/Calendar/CalendarStyles.d.ts +5 -15
  4. package/dist/Calendar/calendarHelpers.d.ts +1 -1
  5. package/dist/CheckBox/CheckBox.js +6 -4
  6. package/dist/DateInput/DateInput.d.ts +5 -3
  7. package/dist/DateInput/DateInput.js +41 -25
  8. package/dist/DropDownMenu/DropDownMenu.d.ts +2 -45
  9. package/dist/DropDownMenu/DropDownMenu.js +9 -315
  10. package/dist/DropDownMenu/components/Menu.d.ts +2 -0
  11. package/dist/DropDownMenu/components/Menu.js +11 -0
  12. package/dist/DropDownMenu/components/MenuComponent.d.ts +2 -0
  13. package/dist/DropDownMenu/components/MenuComponent.js +117 -0
  14. package/dist/DropDownMenu/components/MenuContext.d.ts +7 -0
  15. package/dist/DropDownMenu/components/MenuContext.js +8 -0
  16. package/dist/DropDownMenu/components/MenuItem.d.ts +7 -0
  17. package/dist/DropDownMenu/components/MenuItem.js +99 -0
  18. package/dist/DropDownMenu/components/MenuItemList.d.ts +18 -0
  19. package/dist/DropDownMenu/components/MenuItemList.js +92 -0
  20. package/dist/DropDownMenu/components/SearchInput.d.ts +1 -0
  21. package/dist/DropDownMenu/components/SearchInput.js +4 -0
  22. package/dist/DropDownMenu/components/StyledContent.d.ts +2 -0
  23. package/dist/DropDownMenu/components/StyledContent.js +42 -0
  24. package/dist/DropDownMenu/components/StyledFloatContainer.d.ts +1 -0
  25. package/dist/DropDownMenu/components/StyledFloatContainer.js +5 -0
  26. package/dist/DropDownMenu/components/StyledInnerItemContainer.d.ts +1 -0
  27. package/dist/DropDownMenu/components/StyledInnerItemContainer.js +9 -0
  28. package/dist/DropDownMenu/components/index.d.ts +9 -0
  29. package/dist/DropDownMenu/components/index.js +9 -0
  30. package/dist/DropDownMenu/index.d.ts +1 -1
  31. package/dist/DropDownMenu/index.js +1 -0
  32. package/dist/DropDownMenu/types.d.ts +52 -0
  33. package/dist/FieldLabel/FieldLabel.d.ts +1 -1
  34. package/dist/FileViewer/FileViewer.d.ts +13 -0
  35. package/dist/FileViewer/FileViewer.js +180 -0
  36. package/dist/FileViewer/index.d.ts +1 -0
  37. package/dist/FileViewer/index.js +1 -0
  38. package/dist/FileViewer/viewers/CodeViewer.d.ts +6 -0
  39. package/dist/FileViewer/viewers/CodeViewer.js +106 -0
  40. package/dist/FileViewer/viewers/ImageViewer.d.ts +6 -0
  41. package/dist/FileViewer/viewers/ImageViewer.js +58 -0
  42. package/dist/FileViewer/viewers/OfficeViewer.d.ts +5 -0
  43. package/dist/FileViewer/viewers/OfficeViewer.js +70 -0
  44. package/dist/FileViewer/viewers/PdfViewer.d.ts +8 -0
  45. package/dist/FileViewer/viewers/PdfViewer.js +63 -0
  46. package/dist/FileViewer/viewers/PlainTextViewer.d.ts +4 -0
  47. package/dist/FileViewer/viewers/PlainTextViewer.js +62 -0
  48. package/dist/FileViewer/viewers/VideoViewer.d.ts +6 -0
  49. package/dist/FileViewer/viewers/VideoViewer.js +30 -0
  50. package/dist/FileViewer/viewers/index.d.ts +6 -0
  51. package/dist/FileViewer/viewers/index.js +6 -0
  52. package/dist/FormSection/FormSection.d.ts +10 -2
  53. package/dist/FormSection/FormSection.js +43 -8
  54. package/dist/IconButton/IconButton.d.ts +1 -3
  55. package/dist/Input/Input.js +5 -0
  56. package/dist/MonolithUIProvider/GlobalStyle.d.ts +1 -1
  57. package/dist/MonolithUIProvider/GlobalStyle.js +1 -1
  58. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +2 -2
  59. package/dist/MonolithUIProvider/MonolithUIProvider.js +8 -3
  60. package/dist/MonolithUIProvider/index.d.ts +2 -2
  61. package/dist/MonolithUIProvider/index.js +2 -2
  62. package/dist/MonolithUIProvider/useMonolithUITheme.d.ts +1 -2
  63. package/dist/MonolithUIProvider/useMonolithUITheme.js +1 -2
  64. package/dist/Pill/Pill.d.ts +2 -1
  65. package/dist/Pill/Pill.js +2 -2
  66. package/dist/QueryFilter/DefaultOperators.d.ts +2 -3
  67. package/dist/QueryFilter/DefaultOperators.js +2 -3
  68. package/dist/QueryFilter/QueryFilter.d.ts +2 -3
  69. package/dist/QueryFilter/QueryFilter.js +126 -49
  70. package/dist/QueryFilter/index.d.ts +4 -2
  71. package/dist/QueryFilter/index.js +4 -2
  72. package/dist/QueryFilter/types.d.ts +12 -8
  73. package/dist/QueryFilter/useFilterHelper.d.ts +20 -0
  74. package/dist/QueryFilter/useFilterHelper.js +61 -0
  75. package/dist/QueryFilter/useQueryFilter.d.ts +1 -2
  76. package/dist/QueryFilter/useQueryFilter.js +5 -2
  77. package/dist/RichTextEditor/Components/BubbleMenu.d.ts +3 -4
  78. package/dist/RichTextEditor/Components/BubbleMenu.js +29 -26
  79. package/dist/RichTextEditor/Components/ColorPicker.d.ts +4 -0
  80. package/dist/RichTextEditor/Components/ColorPicker.js +37 -0
  81. package/dist/RichTextEditor/Components/index.d.ts +1 -0
  82. package/dist/RichTextEditor/Components/index.js +1 -0
  83. package/dist/RichTextEditor/RichTextEditor.d.ts +2 -3
  84. package/dist/RichTextEditor/RichTextEditor.js +83 -86
  85. package/dist/RichTextEditor/Toolbar/ControlsGroup.d.ts +1 -3
  86. package/dist/RichTextEditor/Toolbar/Toolbar.d.ts +1 -1
  87. package/dist/RichTextEditor/Toolbar/Toolbar.js +10 -14
  88. package/dist/SelectBox/SelectBox.d.ts +1 -1
  89. package/dist/SelectBox/SelectBox.js +133 -92
  90. package/dist/SelectBox/types.d.ts +8 -5
  91. package/dist/Switch/Switch.js +4 -4
  92. package/dist/Table/ActionButton.d.ts +1 -3
  93. package/dist/Table/ActionCell.d.ts +1 -3
  94. package/dist/Table/SelectionCell.d.ts +1 -3
  95. package/dist/Table/StaticRows.d.ts +2 -2
  96. package/dist/Table/Table.d.ts +1 -2
  97. package/dist/Table/Table.js +9 -13
  98. package/dist/Table/TableComponents.d.ts +2 -6
  99. package/dist/Table/TableComponents.js +0 -5
  100. package/dist/Table/TableHeader.js +8 -2
  101. package/dist/Table/TableMenu/TableMenu.js +11 -9
  102. package/dist/Table/TableProvider.js +36 -30
  103. package/dist/Table/TableRow.js +5 -2
  104. package/dist/Table/VirtualIzedRows.d.ts +2 -2
  105. package/dist/Table/VirtualIzedRows.js +12 -10
  106. package/dist/Table/index.d.ts +1 -2
  107. package/dist/Table/index.js +1 -2
  108. package/dist/Table/types.d.ts +23 -3
  109. package/dist/TagBox/TagBox.d.ts +1 -1
  110. package/dist/TagBox/TagBox.js +180 -92
  111. package/dist/TagBox/TagBoxStyles.d.ts +1 -3
  112. package/dist/TagBox/types.d.ts +4 -2
  113. package/dist/TextArea/TextArea.d.ts +1 -3
  114. package/dist/Tooltip/Tooltip.d.ts +1 -1
  115. package/dist/index.d.ts +4 -4
  116. package/dist/index.js +4 -4
  117. package/dist/theme/getTheme.d.ts +1 -1
  118. package/package.json +11 -5
  119. package/dist/RichTextEditor/Components/DefaultColorIcon.d.ts +0 -4
  120. package/dist/RichTextEditor/Components/DefaultColorIcon.js +0 -7
  121. package/dist/Table/Column.d.ts +0 -3
  122. package/dist/Table/Column.js +0 -5
@@ -1,5 +1,5 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import styled from "styled-components";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import styled, { useTheme } from "styled-components";
3
3
  import Extensions from "../Enums/Extensions";
4
4
  import { BoldIcon, ItalicIcon, UnderlineIcon, CaseSensitiveIcon, ListIcon, ListOrderedIcon, StrikethroughIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, RemoveFormattingIcon, SquircleIcon, } from "lucide-react";
5
5
  import DropDownMenu from "../../DropDownMenu";
@@ -7,8 +7,7 @@ import { FloatingPortal, useFloating } from "@floating-ui/react";
7
7
  import { useEffect, useRef } from "react";
8
8
  import Button from "../../Button";
9
9
  import TextColors from "../Enums/TextColors";
10
- import DefaultColorIcon from "./DefaultColorIcon";
11
- const getMenuItems = (editor, customMenuItems) => {
10
+ const getMenuItems = (editor, customMenuItems, theme) => {
12
11
  var _a, _b, _c, _d, _e, _f, _g;
13
12
  const node = (_c = (_b = (_a = editor === null || editor === void 0 ? void 0 : editor.state) === null || _a === void 0 ? void 0 : _a.selection) === null || _b === void 0 ? void 0 : _b.$from) === null || _c === void 0 ? void 0 : _c.parent;
14
13
  const pos = (_e = (_d = editor === null || editor === void 0 ? void 0 : editor.state) === null || _d === void 0 ? void 0 : _d.selection) === null || _e === void 0 ? void 0 : _e.$from;
@@ -60,8 +59,8 @@ const getMenuItems = (editor, customMenuItems) => {
60
59
  {
61
60
  label: "Text",
62
61
  value: "text",
63
- leftSection: _jsx(CaseSensitiveIcon, { size: 16 }),
64
62
  data: {
63
+ Icon: CaseSensitiveIcon,
65
64
  command: (editor) => {
66
65
  // remove ordered list
67
66
  editor
@@ -76,8 +75,8 @@ const getMenuItems = (editor, customMenuItems) => {
76
75
  {
77
76
  label: "Heading 1",
78
77
  value: "heading_1",
79
- leftSection: _jsx(Heading1Icon, { size: 16 }),
80
78
  data: {
79
+ Icon: Heading1Icon,
81
80
  command: (editor) => {
82
81
  editor.chain().focus().setHeading({ level: 1 }).run();
83
82
  },
@@ -86,8 +85,8 @@ const getMenuItems = (editor, customMenuItems) => {
86
85
  {
87
86
  label: "Heading 2",
88
87
  value: "heading_2",
89
- leftSection: _jsx(Heading2Icon, { size: 16 }),
90
88
  data: {
89
+ Icon: Heading2Icon,
91
90
  command: (editor) => {
92
91
  editor.chain().focus().setHeading({ level: 2 }).run();
93
92
  },
@@ -96,8 +95,8 @@ const getMenuItems = (editor, customMenuItems) => {
96
95
  {
97
96
  label: "Heading 3",
98
97
  value: "heading_3",
99
- leftSection: _jsx(Heading3Icon, { size: 16 }),
100
98
  data: {
99
+ Icon: Heading3Icon,
101
100
  command: (editor) => {
102
101
  editor.chain().focus().setHeading({ level: 3 }).run();
103
102
  },
@@ -106,8 +105,8 @@ const getMenuItems = (editor, customMenuItems) => {
106
105
  {
107
106
  label: "Heading 4",
108
107
  value: "heading_4",
109
- leftSection: _jsx(Heading4Icon, { size: 16 }),
110
108
  data: {
109
+ Icon: Heading4Icon,
111
110
  command: (editor) => {
112
111
  editor.chain().focus().setHeading({ level: 4 }).run();
113
112
  },
@@ -116,8 +115,8 @@ const getMenuItems = (editor, customMenuItems) => {
116
115
  {
117
116
  label: "Bullet List",
118
117
  value: "bullet_list",
119
- leftSection: _jsx(ListIcon, { size: 16 }),
120
118
  data: {
119
+ Icon: ListIcon,
121
120
  command: (editor) => {
122
121
  editor.chain().focus().toggleBulletList().run();
123
122
  },
@@ -126,14 +125,17 @@ const getMenuItems = (editor, customMenuItems) => {
126
125
  {
127
126
  label: "Ordered List",
128
127
  value: "ordered_list",
129
- leftSection: _jsx(ListOrderedIcon, { size: 16 }),
130
128
  data: {
129
+ Icon: ListOrderedIcon,
131
130
  command: (editor) => {
132
131
  editor.chain().focus().toggleOrderedList().run();
133
132
  },
134
133
  },
135
134
  },
136
135
  ],
136
+ dropDownProps: {
137
+ renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(item.data.Icon, { size: 16 }), item.label] })),
138
+ },
137
139
  },
138
140
  {
139
141
  name: "color",
@@ -145,15 +147,11 @@ const getMenuItems = (editor, customMenuItems) => {
145
147
  style: { fontSize: 11, padding: "4px" },
146
148
  },
147
149
  items: [
148
- // remove Color Style
149
150
  {
150
151
  label: "Default",
151
152
  value: "default",
152
- leftSection: _jsx(DefaultColorIcon, { size: 12 }),
153
- data: {
154
- command: (editor) => {
155
- editor.chain().focus().unsetColor().run();
156
- },
153
+ onClick: () => {
154
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetColor().run();
157
155
  },
158
156
  },
159
157
  ...Object.keys(TextColors).map((color) => {
@@ -161,18 +159,22 @@ const getMenuItems = (editor, customMenuItems) => {
161
159
  return {
162
160
  label: color,
163
161
  value: TextColors[colorKey],
164
- leftSection: (_jsx(SquircleIcon, { size: 12, color: TextColors[colorKey], style: {
165
- backgroundColor: TextColors[colorKey],
166
- borderRadius: "3px",
167
- } })),
168
- data: {
169
- command: (editor) => {
170
- editor.chain().focus().setColor(TextColors[colorKey]).run();
171
- },
162
+ onClick: () => {
163
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().setColor(TextColors[colorKey]).run();
172
164
  },
173
165
  };
174
166
  }),
175
167
  ],
168
+ dropDownProps: {
169
+ renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default"
170
+ ? theme.palette.text.primary
171
+ : item.value, style: {
172
+ backgroundColor: item.value === "default"
173
+ ? theme.palette.text.primary
174
+ : item.value,
175
+ borderRadius: "3px",
176
+ } }), item.label] })),
177
+ },
176
178
  },
177
179
  {
178
180
  name: Extensions.Bold,
@@ -274,6 +276,7 @@ const BubbleMenu = ({ editor, rect, open, onOpen, customMenuItems = [], }) => {
274
276
  var _a;
275
277
  const menuRef = useRef(null);
276
278
  const { refs, elements } = useFloating();
279
+ const theme = useTheme();
277
280
  useEffect(() => {
278
281
  if (open && onOpen) {
279
282
  onOpen(elements.floating);
@@ -301,7 +304,7 @@ const BubbleMenu = ({ editor, rect, open, onOpen, customMenuItems = [], }) => {
301
304
  }, style: {
302
305
  top,
303
306
  left,
304
- }, children: getMenuItems(editor, customMenuItems).map((item) => {
307
+ }, children: getMenuItems(editor, customMenuItems, theme).map((item) => {
305
308
  var _a;
306
309
  if (item.type === "button") {
307
310
  const isActive = (_a = item.isActive) === null || _a === void 0 ? void 0 : _a.call(item, editor);
@@ -0,0 +1,4 @@
1
+ import { Editor } from "@tiptap/react";
2
+ export declare const ColorPicker: React.FC<{
3
+ editor: Editor;
4
+ }>;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import DropDownMenu from "../../DropDownMenu";
3
+ import TextColors from "../Enums/TextColors";
4
+ import { SquircleIcon } from "lucide-react";
5
+ import { useTheme } from "styled-components";
6
+ export const ColorPicker = ({ editor }) => {
7
+ const theme = useTheme();
8
+ return (_jsx(DropDownMenu, { data: [
9
+ {
10
+ label: "Default",
11
+ value: "default",
12
+ onClick: () => {
13
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetColor().run();
14
+ },
15
+ },
16
+ ...Object.keys(TextColors).map((color) => {
17
+ const colorKey = color;
18
+ return {
19
+ label: color,
20
+ value: TextColors[colorKey],
21
+ onClick: () => {
22
+ editor === null || editor === void 0 ? void 0 : editor.chain().focus().setColor(TextColors[colorKey]).run();
23
+ },
24
+ };
25
+ }),
26
+ ], renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default" ? theme.palette.text.primary : item.value, style: {
27
+ backgroundColor: item.value === "default"
28
+ ? theme.palette.text.primary
29
+ : item.value,
30
+ borderRadius: "3px",
31
+ } }), item.label] })), size: "xxs", variant: "outlined", arrow: true, buttonProps: {
32
+ style: {
33
+ fontWeight: "normal",
34
+ },
35
+ title: "Select Color",
36
+ }, children: "Color" }));
37
+ };
@@ -0,0 +1 @@
1
+ export * from "./ColorPicker";
@@ -0,0 +1 @@
1
+ export * from "./ColorPicker";
@@ -9,6 +9,7 @@ interface RichTextEditorProps {
9
9
  extensions?: ExtensionType[];
10
10
  slashCommands?: any[];
11
11
  defaultValue?: string;
12
+ value?: string;
12
13
  readOnly?: boolean;
13
14
  height?: string;
14
15
  font?: string;
@@ -21,7 +22,5 @@ interface RichTextEditorProps {
21
22
  autoFocus?: boolean;
22
23
  style?: React.CSSProperties;
23
24
  }
24
- declare const RichTextEditor: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<RichTextEditorProps & import("react").RefAttributes<unknown>, "ref"> & {
25
- ref?: ((instance: unknown) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<unknown> | null | undefined;
26
- }, never>> & string & Omit<import("react").ForwardRefExoticComponent<RichTextEditorProps & import("react").RefAttributes<unknown>>, keyof import("react").Component<any, {}, any>>;
25
+ declare const RichTextEditor: import("react").ForwardRefExoticComponent<RichTextEditorProps & import("react").RefAttributes<unknown>>;
27
26
  export default RichTextEditor;
@@ -9,88 +9,7 @@ import { startImageUpload, } from "./Plugins/UploadImagesPlugin";
9
9
  import SaveBadge from "./Components/SaveBadge";
10
10
  import Fonts from "./Enums/Fonts";
11
11
  import RichTextEditorContext from "./Contexts/RichTextEditorContext";
12
- const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaultValue = "", readOnly = false, font, showToolbar = true, saving = false, extensions = [], slashCommands = [], bubbleMenuOptions, toolbarOptions, autoFocus, onChange, handleImageUpload, style, }, ref) => {
13
- const [fontState, setFontState] = useState(font || Fonts.DEFAULT);
14
- // check if image extension is included
15
- if (extensions === null || extensions === void 0 ? void 0 : extensions.includes(Extensions.Image)) {
16
- // Ensure that handleImageUpload is provided
17
- if (!handleImageUpload) {
18
- throw new Error("handleImageUpload is required when using the image extension.");
19
- }
20
- }
21
- const editor = useEditor({
22
- content: defaultValue,
23
- editable: !readOnly,
24
- extensions: getTipTapExtensions({
25
- extensions,
26
- slashCommands,
27
- bubbleMenuOptions,
28
- handleImageUpload,
29
- }),
30
- editorProps: {
31
- handlePaste: (view, event) => {
32
- if (!handleImageUpload)
33
- return false;
34
- if (!(event === null || event === void 0 ? void 0 : event.clipboardData))
35
- return false;
36
- if (event.clipboardData.types.includes("text/html") ||
37
- event.clipboardData.types.includes("text/plain") ||
38
- event.clipboardData.types.includes("text/rtf"))
39
- return false;
40
- if (event.clipboardData &&
41
- event.clipboardData.files &&
42
- event.clipboardData.files[0]) {
43
- event.preventDefault();
44
- const file = event.clipboardData.files[0];
45
- const pos = view.state.selection.from;
46
- startImageUpload(file, view, pos, handleImageUpload);
47
- return true;
48
- }
49
- return false;
50
- },
51
- handleDrop: (view, event, _slice, moved) => {
52
- if (!handleImageUpload)
53
- return false;
54
- if (!moved &&
55
- event.dataTransfer &&
56
- event.dataTransfer.files &&
57
- event.dataTransfer.files[0]) {
58
- event.preventDefault();
59
- const file = event.dataTransfer.files[0];
60
- const coordinates = view.posAtCoords({
61
- left: event.clientX,
62
- top: event.clientY,
63
- });
64
- if (!coordinates)
65
- return false;
66
- // here we deduct 1 from the pos or else the image will create an extra node
67
- startImageUpload(file, view, coordinates.pos - 1, handleImageUpload);
68
- return true;
69
- }
70
- return false;
71
- },
72
- },
73
- onUpdate: ({ editor }) => {
74
- onChange === null || onChange === void 0 ? void 0 : onChange(editor.getHTML());
75
- },
76
- });
77
- useEffect(() => {
78
- const _ref = editorInstanceRef;
79
- if (editorInstanceRef) {
80
- _ref.current = editor;
81
- }
82
- }, [editor]);
83
- // AutoFocus on the editor
84
- useEffect(() => {
85
- if (autoFocus && editor) {
86
- editor.view.focus();
87
- }
88
- }, [autoFocus, editor]);
89
- return (_jsx("div", { className: className, children: _jsxs(RichTextEditorContext.Provider, { value: {
90
- font: fontState,
91
- setFont: setFontState,
92
- }, children: [showToolbar && (_jsx(Toolbar, { editor: editor, toolbarOptions: toolbarOptions })), saving && _jsx(SaveBadge, {}), _jsx(EditorContent, { className: "editor-content", editor: editor, "data-font": fontState || null, style: style })] }) }));
93
- })) `
12
+ const StyledContent = styled.div `
94
13
  position: relative;
95
14
  display: flex;
96
15
  flex-direction: column;
@@ -99,10 +18,6 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
99
18
  justify-content: flex-start;
100
19
  align-items: center;
101
20
 
102
- ::selection {
103
- background-color: #705324;
104
- }
105
-
106
21
  .editor-content {
107
22
  height: ${({ height }) => height || "100%"};
108
23
  width: 100%;
@@ -363,4 +278,86 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
363
278
  margin: 0 0.125rem;
364
279
  }
365
280
  `;
281
+ const RichTextEditor = forwardRef(({ className, editorInstanceRef, defaultValue = "", value = "", readOnly = false, font, showToolbar = true, saving = false, extensions = [], slashCommands = [], bubbleMenuOptions, toolbarOptions, autoFocus, onChange, handleImageUpload, style, }, ref) => {
282
+ const [fontState, setFontState] = useState(font || Fonts.DEFAULT);
283
+ // check if image extension is included
284
+ if (extensions === null || extensions === void 0 ? void 0 : extensions.includes(Extensions.Image)) {
285
+ // Ensure that handleImageUpload is provided
286
+ if (!handleImageUpload) {
287
+ throw new Error("handleImageUpload is required when using the image extension.");
288
+ }
289
+ }
290
+ const editor = useEditor({
291
+ content: defaultValue,
292
+ editable: !readOnly,
293
+ extensions: getTipTapExtensions({
294
+ extensions,
295
+ slashCommands,
296
+ bubbleMenuOptions,
297
+ handleImageUpload,
298
+ }),
299
+ editorProps: {
300
+ handlePaste: (view, event) => {
301
+ if (!handleImageUpload)
302
+ return false;
303
+ if (!(event === null || event === void 0 ? void 0 : event.clipboardData))
304
+ return false;
305
+ if (event.clipboardData.types.includes("text/html") ||
306
+ event.clipboardData.types.includes("text/plain") ||
307
+ event.clipboardData.types.includes("text/rtf"))
308
+ return false;
309
+ if (event.clipboardData &&
310
+ event.clipboardData.files &&
311
+ event.clipboardData.files[0]) {
312
+ event.preventDefault();
313
+ const file = event.clipboardData.files[0];
314
+ const pos = view.state.selection.from;
315
+ startImageUpload(file, view, pos, handleImageUpload);
316
+ return true;
317
+ }
318
+ return false;
319
+ },
320
+ handleDrop: (view, event, _slice, moved) => {
321
+ if (!handleImageUpload)
322
+ return false;
323
+ if (!moved &&
324
+ event.dataTransfer &&
325
+ event.dataTransfer.files &&
326
+ event.dataTransfer.files[0]) {
327
+ event.preventDefault();
328
+ const file = event.dataTransfer.files[0];
329
+ const coordinates = view.posAtCoords({
330
+ left: event.clientX,
331
+ top: event.clientY,
332
+ });
333
+ if (!coordinates)
334
+ return false;
335
+ // here we deduct 1 from the pos or else the image will create an extra node
336
+ startImageUpload(file, view, coordinates.pos - 1, handleImageUpload);
337
+ return true;
338
+ }
339
+ return false;
340
+ },
341
+ },
342
+ onUpdate: ({ editor }) => {
343
+ onChange === null || onChange === void 0 ? void 0 : onChange(editor.getHTML());
344
+ },
345
+ });
346
+ useEffect(() => {
347
+ const _ref = editorInstanceRef;
348
+ if (editorInstanceRef) {
349
+ _ref.current = editor;
350
+ }
351
+ }, [editor]);
352
+ // AutoFocus on the editor
353
+ useEffect(() => {
354
+ if (autoFocus && editor) {
355
+ editor.view.focus();
356
+ }
357
+ }, [autoFocus, editor]);
358
+ return (_jsx(StyledContent, { className: className, children: _jsxs(RichTextEditorContext.Provider, { value: {
359
+ font: fontState,
360
+ setFont: setFontState,
361
+ }, children: [showToolbar && (_jsx(Toolbar, { editor: editor, toolbarOptions: toolbarOptions })), saving && _jsx(SaveBadge, {}), _jsx(EditorContent, { className: "editor-content", editor: editor, "data-font": fontState || null, style: style })] }) }));
362
+ });
366
363
  export default RichTextEditor;
@@ -2,7 +2,5 @@ interface ControlsGroupProps {
2
2
  className?: string;
3
3
  children?: React.ReactNode;
4
4
  }
5
- declare const ControlsGroup: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<ControlsGroupProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
6
- ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
7
- }, never>> & string & Omit<import("react").ForwardRefExoticComponent<ControlsGroupProps & import("react").RefAttributes<HTMLDivElement>>, keyof import("react").Component<any, {}, any>>;
5
+ declare const ControlsGroup: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ControlsGroupProps & import("react").RefAttributes<HTMLDivElement>, never>> & string & Omit<import("react").ForwardRefExoticComponent<ControlsGroupProps & import("react").RefAttributes<HTMLDivElement>>, keyof import("react").Component<any, {}, any>>;
8
6
  export default ControlsGroup;
@@ -1,7 +1,7 @@
1
1
  import { Editor } from "@tiptap/react";
2
2
  import Controls from "../Enums/Controls";
3
+ import { DropDownMenuProps } from "../../DropDownMenu";
3
4
  import { ReactNode } from "react";
4
- import { DropDownMenuProps } from "../../DropDownMenu/DropDownMenu";
5
5
  import { ButtonProps } from "../../Button";
6
6
  export type CustomItem = {
7
7
  type: "button";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import styled from "styled-components";
2
+ import styled, { useTheme } from "styled-components";
3
3
  import ControlsGroup from "./ControlsGroup";
4
4
  import { UndoControl, RedoControl, BoldControl, ItalicControl, UnderlineControl, StrikeThroughControl, Heading1Control, Heading2Control, Heading3Control, Heading4Control, BulletListControl, OrderedListControl, AlignLeftControl, AlignCenterControl, AlignRightControl, AlignJustifiedControl, } from "./Controls";
5
5
  import Controls from "../Enums/Controls";
@@ -9,10 +9,10 @@ import { useContext } from "react";
9
9
  import RichTextEditorContext from "../Contexts/RichTextEditorContext";
10
10
  import Button from "../../Button";
11
11
  import TextColors from "../Enums/TextColors";
12
- import DefaultColorIcon from "../Components/DefaultColorIcon";
13
12
  import { SquircleIcon } from "lucide-react";
14
13
  const Toolbar = styled(({ className, editor, toolbarOptions }) => {
15
14
  var _a;
15
+ const theme = useTheme();
16
16
  const { controls } = toolbarOptions || {};
17
17
  const customItems = controls === null || controls === void 0 ? void 0 : controls.filter((control) => typeof control !== "string" &&
18
18
  (control.type === "menu" || control.type === "button"));
@@ -32,15 +32,11 @@ const Toolbar = styled(({ className, editor, toolbarOptions }) => {
32
32
  setFont(font);
33
33
  },
34
34
  })), size: "xxs", variant: "outlined", arrow: true, buttonProps: {
35
- style: {
36
- fontWeight: "normal",
37
- },
38
35
  title: "Select Font",
39
36
  }, children: (font || Fonts.DEFAULT) })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDO)) && _jsx(UndoControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.REDO)) && _jsx(RedoControl, { editor: editor })] }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.COLOR)) && (_jsx(DropDownMenu, { data: [
40
37
  {
41
38
  label: "Default",
42
39
  value: "default",
43
- leftSection: _jsx(DefaultColorIcon, { size: 12 }),
44
40
  onClick: () => {
45
41
  editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetColor().run();
46
42
  },
@@ -50,19 +46,19 @@ const Toolbar = styled(({ className, editor, toolbarOptions }) => {
50
46
  return {
51
47
  label: color,
52
48
  value: TextColors[colorKey],
53
- leftSection: (_jsx(SquircleIcon, { size: 12, color: TextColors[colorKey], style: {
54
- backgroundColor: TextColors[colorKey],
55
- borderRadius: "3px",
56
- } })),
57
49
  onClick: () => {
58
50
  editor === null || editor === void 0 ? void 0 : editor.chain().focus().setColor(TextColors[colorKey]).run();
59
51
  },
60
52
  };
61
53
  }),
62
- ], size: "xxs", variant: "outlined", arrow: true, buttonProps: {
63
- style: {
64
- fontWeight: "normal",
65
- },
54
+ ], renderOption: (item) => (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [_jsx(SquircleIcon, { size: 12, color: item.value === "default"
55
+ ? theme.palette.text.primary
56
+ : item.value, style: {
57
+ backgroundColor: item.value === "default"
58
+ ? theme.palette.text.primary
59
+ : item.value,
60
+ borderRadius: "3px",
61
+ } }), item.label] })), size: "xxs", variant: "outlined", arrow: true, buttonProps: {
66
62
  title: "Select Color",
67
63
  }, children: "Color" })), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BOLD)) && _jsx(BoldControl, { editor: editor }), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ITALIC)) && (_jsx(ItalicControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.UNDERLINE)) && (_jsx(UnderlineControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.STRIKE)) && (_jsx(StrikeThroughControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_1)) && (_jsx(Heading1Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_2)) && (_jsx(Heading2Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_3)) && (_jsx(Heading3Control, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.HEADING_4)) && (_jsx(Heading4Control, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.BULLET_LIST)) && (_jsx(BulletListControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.ORDERED_LIST)) && (_jsx(OrderedListControl, { editor: editor }))] }), _jsxs(ControlsGroup, { children: [(controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_LEFT)) && (_jsx(AlignLeftControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_CENTER)) && (_jsx(AlignCenterControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_RIGHT)) && (_jsx(AlignRightControl, { editor: editor })), (controls === null || controls === void 0 ? void 0 : controls.includes(Controls.TEXT_ALIGN_JUSTIFIED)) && (_jsx(AlignJustifiedControl, { editor: editor }))] })] }));
68
64
  }) `
@@ -2,5 +2,5 @@ import { SelectBoxProps } from "..";
2
2
  export declare const StyledInputContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
3
3
  width?: string | number | null;
4
4
  }>> & string;
5
- declare const SelectBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<SelectBoxProps, never>> & string & Omit<({ className, data, placeholder, arrow, onChange, onSearch, searchFn, onScroll, loading, defaultValue, value, onItemAdded, size, variant, width, allowCustomValue, searchable, clearable, label, description, required, error, openOnFocus, renderOption, actionComponent, focused, grouped, OptionTooltip, DropDownProps, debounceTime, sort, }: SelectBoxProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
5
+ declare const SelectBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<SelectBoxProps, never>> & string & Omit<({ className, data, placeholder, arrow, onChange, onSearch, searchFn, onScroll, loading, defaultValue, value, onItemAdded, size, variant, width, allowCustomValue, searchable, clearable, label, description, required, error, openOnFocus, renderOption, actionComponent, focused, grouped, OptionTooltip, DropDownProps, debounceTime, sort, disabled, }: SelectBoxProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
6
6
  export default SelectBox;