@wavv/ui 2.2.2-alpha.5 → 2.2.2-alpha.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.
Files changed (229) hide show
  1. package/build/assets/icons/CaretDown.js +18 -0
  2. package/build/assets/icons/CaretUp.js +18 -0
  3. package/build/assets/icons/Checkbox.js +15 -0
  4. package/build/assets/icons/CheckboxOff.js +15 -0
  5. package/build/assets/icons/CheckboxPartial.js +15 -0
  6. package/build/assets/icons/Dialpad.js +18 -0
  7. package/build/assets/icons/Exclamation.js +25 -0
  8. package/build/assets/icons/Phone.js +13 -0
  9. package/build/assets/icons/PhoneAdd.js +21 -0
  10. package/build/assets/icons/PhoneBlocked.js +22 -0
  11. package/build/assets/icons/PhoneCallback.js +21 -0
  12. package/build/assets/icons/PhoneEnd.js +28 -0
  13. package/build/assets/icons/PhoneForward.js +22 -0
  14. package/build/assets/icons/PhoneHistory.js +21 -0
  15. package/build/assets/icons/PhoneHold.js +22 -0
  16. package/build/assets/icons/PhoneIncoming.js +22 -0
  17. package/build/assets/icons/PhoneMissed.js +22 -0
  18. package/build/assets/icons/PhoneTalk.js +22 -0
  19. package/build/assets/icons/PhoneTransfer.js +21 -0
  20. package/build/assets/icons/RadioButton.js +22 -0
  21. package/build/assets/icons/RadioButtonOff.js +15 -0
  22. package/build/assets/icons/Record.js +18 -0
  23. package/build/assets/icons/Screenshot.js +39 -0
  24. package/build/assets/icons/ShieldWavv.js +30 -0
  25. package/build/assets/icons/Spotify.js +15 -0
  26. package/build/assets/icons/SubArrow.js +16 -0
  27. package/build/assets/icons/ToggleOff.js +15 -0
  28. package/build/assets/icons/ToggleOn.js +15 -0
  29. package/build/assets/icons/TransferCancel.js +60 -0
  30. package/build/components/Accordion/Accordion.js +26 -0
  31. package/build/components/Accordion/Header.js +86 -0
  32. package/build/components/Accordion/Item.js +25 -0
  33. package/build/components/Accordion/Panel.js +64 -0
  34. package/build/components/Accordion/index.js +2 -0
  35. package/build/components/Audio.js +248 -0
  36. package/build/components/BarChart.js +123 -0
  37. package/build/components/Button/Button.js +258 -0
  38. package/build/components/Button/ButtonLoader.js +20 -0
  39. package/build/components/Button/ButtonTypes.js +0 -0
  40. package/build/components/Button/Group.js +58 -0
  41. package/build/components/Button/index.js +2 -0
  42. package/build/components/Calendar.js +49 -0
  43. package/build/components/CalendarParts/CalendarContainerStyles.js +15 -0
  44. package/build/components/CalendarParts/CalendarContent.js +138 -0
  45. package/build/components/CalendarParts/CalendarHeader.js +146 -0
  46. package/build/components/CalendarParts/useMinMax.js +23 -0
  47. package/build/components/CalendarParts/utils.js +6 -0
  48. package/build/components/ChartHelpers.js +121 -0
  49. package/build/components/Checkbox.js +85 -0
  50. package/build/components/Code/Code.js +117 -0
  51. package/build/components/Code/Copy.js +50 -0
  52. package/build/components/Code/Endpoint.js +82 -0
  53. package/build/components/Code/index.js +3 -0
  54. package/build/components/ComboBox.js +190 -0
  55. package/build/components/CommandMenu/CommandItem.js +32 -0
  56. package/build/components/CommandMenu/CommandMenu.js +136 -0
  57. package/build/components/CommandMenu/CommandOptions.js +24 -0
  58. package/build/components/CommandMenu/CommandSection.js +19 -0
  59. package/build/components/CommandMenu/index.js +2 -0
  60. package/build/components/DateRangeSelect.js +359 -0
  61. package/build/components/DocTable.js +32 -0
  62. package/build/components/Dot.js +60 -0
  63. package/build/components/DraftEditor.js +188 -0
  64. package/build/components/Dropdown.js +130 -0
  65. package/build/components/DropdownMenu.js +131 -0
  66. package/build/components/DropdownMenuParts/Menu.js +6 -0
  67. package/build/components/DropdownMenuParts/MenuItem.js +54 -0
  68. package/build/components/DropdownMenuParts/MenuOptions.js +47 -0
  69. package/build/components/DropdownMenuParts/MenuSection.js +14 -0
  70. package/build/components/DropdownSelect.js +171 -0
  71. package/build/components/DynamicIcon.js +49 -0
  72. package/build/components/Editor/Editor.js +356 -0
  73. package/build/components/Editor/EditorStyles.js +259 -0
  74. package/build/components/Editor/MergeFieldExtension.js +110 -0
  75. package/build/components/Editor/RichTextToolbar.js +515 -0
  76. package/build/components/Editor/editorUtils.js +213 -0
  77. package/build/components/Editor/index.js +3 -0
  78. package/build/components/Ellipsis.js +22 -0
  79. package/build/components/Focusable.js +20 -0
  80. package/build/components/Form.js +68 -0
  81. package/build/components/FormControl.js +72 -0
  82. package/build/components/Grid.js +53 -0
  83. package/build/components/Icon/Icon.js +89 -0
  84. package/build/components/Icon/customIcons.js +48 -0
  85. package/build/components/Icon/icons.js +145 -0
  86. package/build/components/Icon/index.js +3 -0
  87. package/build/components/ImageViewer.js +142 -0
  88. package/build/components/InlineCode.js +10 -0
  89. package/build/components/InputHelpers.js +106 -0
  90. package/build/components/Inputs/DatePicker.js +111 -0
  91. package/build/components/Inputs/DateRangePicker.js +166 -0
  92. package/build/components/Inputs/InlineInput.js +71 -0
  93. package/build/components/Inputs/NumberInput.js +117 -0
  94. package/build/components/Inputs/PhoneInput.js +96 -0
  95. package/build/components/Inputs/SearchInput.js +84 -0
  96. package/build/components/Inputs/TextArea.js +164 -0
  97. package/build/components/Inputs/TextInput.js +74 -0
  98. package/build/components/Inputs/TimeInput.js +74 -0
  99. package/build/components/Inputs/helpers/AriaButton.js +19 -0
  100. package/build/components/Inputs/helpers/DateSegment.js +22 -0
  101. package/build/components/Inputs/helpers/Description.js +11 -0
  102. package/build/components/Inputs/helpers/ErrorMessage.js +11 -0
  103. package/build/components/Inputs/helpers/Input.js +6 -0
  104. package/build/components/Inputs/helpers/InputContainerStyles.js +78 -0
  105. package/build/components/Inputs/helpers/InputMessage.js +30 -0
  106. package/build/components/Inputs/helpers/InputStyles.js +43 -0
  107. package/build/components/Inputs/helpers/Label.js +42 -0
  108. package/build/components/Inputs/helpers/LabelWrapper.js +14 -0
  109. package/build/components/Inputs/helpers/PickerToggle.js +7 -0
  110. package/build/components/Inputs/helpers/TextArea.js +8 -0
  111. package/build/components/Inputs/helpers/filterPastedText.js +9 -0
  112. package/build/components/Inputs/helpers/handlePaste.js +12 -0
  113. package/build/components/Inputs/helpers/isAcceptable.js +7 -0
  114. package/build/components/Inputs/helpers/useDynamicWidth.js +39 -0
  115. package/build/components/Inputs/helpers/useInputFocus.js +19 -0
  116. package/build/components/Label.js +42 -0
  117. package/build/components/LineChart.js +80 -0
  118. package/build/components/ListBoxParts/GridListItem.js +34 -0
  119. package/build/components/ListBoxParts/ListBoxItem.js +32 -0
  120. package/build/components/ListBoxParts/ListOptions.js +45 -0
  121. package/build/components/ListHelpers/GridListHeader.js +14 -0
  122. package/build/components/ListHelpers/GridListSection.js +14 -0
  123. package/build/components/ListHelpers/ItemHeaderBody.js +36 -0
  124. package/build/components/ListHelpers/ListHeader.js +14 -0
  125. package/build/components/ListHelpers/ListItemStyles.js +52 -0
  126. package/build/components/ListHelpers/ListRootStyles.js +14 -0
  127. package/build/components/ListHelpers/ListSection.js +14 -0
  128. package/build/components/ListHelpers/ListStyles.js +29 -0
  129. package/build/components/Menu.js +159 -0
  130. package/build/components/Message.js +107 -0
  131. package/build/components/MessageHr.js +32 -0
  132. package/build/components/Modal.js +212 -0
  133. package/build/components/MotionPopover.js +39 -0
  134. package/build/components/MultiSelect/MultiSelect.js +263 -0
  135. package/build/components/MultiSelect/SearchDropdown.js +155 -0
  136. package/build/components/MultiSelect/index.js +2 -0
  137. package/build/components/OptionHelpers/Container.js +34 -0
  138. package/build/components/OptionHelpers/Item.js +59 -0
  139. package/build/components/OptionHelpers/types.js +0 -0
  140. package/build/components/Pagination.js +121 -0
  141. package/build/components/PieChart.js +40 -0
  142. package/build/components/Popover.js +40 -0
  143. package/build/components/PortalScope.js +8 -0
  144. package/build/components/Progress/CirclePercent.js +56 -0
  145. package/build/components/Progress/Progress.js +59 -0
  146. package/build/components/Progress/index.js +3 -0
  147. package/build/components/Radio.js +45 -0
  148. package/build/components/RangeCalendar.js +60 -0
  149. package/build/components/Select.js +162 -0
  150. package/build/components/Slider.js +50 -0
  151. package/build/components/Spinner.js +70 -0
  152. package/build/components/Table/Body.js +49 -0
  153. package/build/components/Table/Cell.js +63 -0
  154. package/build/components/Table/Check.js +35 -0
  155. package/build/components/Table/Column.js +129 -0
  156. package/build/components/Table/ColumnSort.js +26 -0
  157. package/build/components/Table/Header.js +64 -0
  158. package/build/components/Table/Resizer.js +25 -0
  159. package/build/components/Table/Row.js +84 -0
  160. package/build/components/Table/SortCaret.js +24 -0
  161. package/build/components/Table/Table.js +88 -0
  162. package/build/components/Table/contentStyles.js +20 -0
  163. package/build/components/Table/context.js +4 -0
  164. package/build/components/Table/index.js +2 -0
  165. package/build/components/Table/types.js +0 -0
  166. package/build/components/Tabs.js +151 -0
  167. package/build/components/Tag.js +71 -0
  168. package/build/components/Toggle.js +59 -0
  169. package/build/components/ToggleButton/ToggleButton.js +104 -0
  170. package/build/components/ToggleButton/ToggleButtonGroup.js +36 -0
  171. package/build/components/ToggleButton/context.js +8 -0
  172. package/build/components/ToggleButton/index.js +3 -0
  173. package/build/components/Tooltip.js +136 -0
  174. package/build/components/TransferList.js +234 -0
  175. package/build/components/Tree/Tree.js +69 -0
  176. package/build/components/Tree/TreeContext.js +3 -0
  177. package/build/components/Tree/TreeItem.js +93 -0
  178. package/build/components/Tree/index.js +2 -0
  179. package/build/components/UnstyledButton.js +8 -0
  180. package/build/components/Waveform.js +243 -0
  181. package/build/components/draftUtils.js +193 -0
  182. package/build/components/helpers/getIcon.js +28 -0
  183. package/build/components/helpers/getPopPosition.js +20 -0
  184. package/build/components/helpers/isPropAllowed.js +3 -0
  185. package/build/components/helpers/mergePadding.js +47 -0
  186. package/build/components/helpers/styledProps.js +34 -0
  187. package/build/components/typeDefs/elementTypes.js +0 -0
  188. package/build/components/typeDefs/inputTypes.js +0 -0
  189. package/build/components/typeDefs/selectionTypes.js +0 -0
  190. package/build/components/typeDefs/tagTypes.js +0 -0
  191. package/build/components/types.js +0 -0
  192. package/build/global-styles/GlobalStorybookStyles.js +108 -0
  193. package/build/global-styles/ResetStyles.js +33 -0
  194. package/build/global-styles/ScrollbarStyles.js +26 -0
  195. package/build/global-styles/ToastStyles.js +66 -0
  196. package/build/global-styles/index.js +4 -0
  197. package/build/hooks/index.js +9 -0
  198. package/build/hooks/useConfirm.js +91 -0
  199. package/build/hooks/useControlledOpenState.js +22 -0
  200. package/build/hooks/useCopy.js +28 -0
  201. package/build/hooks/useElementObserver.js +6 -0
  202. package/build/hooks/useEventListener.js +19 -0
  203. package/build/hooks/useOnClickOutside.js +21 -0
  204. package/build/hooks/usePrevious.js +12 -0
  205. package/build/hooks/useSelectAll.js +60 -0
  206. package/build/hooks/useWindowSize.js +25 -0
  207. package/build/theme/ThemeTypes.js +0 -0
  208. package/build/theme/common/button.js +33 -0
  209. package/build/theme/common/common.js +38 -0
  210. package/build/theme/common/index.js +4 -0
  211. package/build/theme/core/colors.js +77 -0
  212. package/build/theme/core/dark/dark.js +457 -0
  213. package/build/theme/core/dark/darkScale.js +36 -0
  214. package/build/theme/core/light/light.js +456 -0
  215. package/build/theme/core/light/lightScale.js +35 -0
  216. package/build/theme/eighties/colors.js +78 -0
  217. package/build/theme/eighties/dark/dark.js +457 -0
  218. package/build/theme/eighties/dark/darkScale.js +36 -0
  219. package/build/theme/eighties/light/light.js +456 -0
  220. package/build/theme/eighties/light/lightScale.js +35 -0
  221. package/build/theme/index.js +28 -0
  222. package/build/utils/chunk.js +13 -0
  223. package/build/utils/copyToClipboard.js +29 -0
  224. package/build/utils/flattenListOptions.js +4 -0
  225. package/build/utils/formatDate.js +55 -0
  226. package/build/utils/index.js +6 -0
  227. package/build/utils/numberWithCommas.js +3 -0
  228. package/build/utils/range.js +11 -0
  229. package/package.json +1 -1
@@ -0,0 +1,356 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import extension_character_count from "@tiptap/extension-character-count";
4
+ import extension_highlight from "@tiptap/extension-highlight";
5
+ import extension_placeholder from "@tiptap/extension-placeholder";
6
+ import extension_task_item from "@tiptap/extension-task-item";
7
+ import extension_task_list from "@tiptap/extension-task-list";
8
+ import { Markdown } from "@tiptap/markdown";
9
+ import { EditorContent, useEditor } from "@tiptap/react";
10
+ import starter_kit from "@tiptap/starter-kit";
11
+ import { isEqual } from "es-toolkit/predicate";
12
+ import { startTransition, useEffect, useImperativeHandle, useRef, useState } from "react";
13
+ import { Description, InputContainer, InputWrapper, Label, isInputFilled, useInputFocus } from "../InputHelpers.js";
14
+ import EditorStyles from "./EditorStyles.js";
15
+ import { documentToText, editorContentToText, getEditorCharacterCount, hasMissingFields, insertMergeField, parseJSONToDocument, parseTextToDocument, updateMergeFieldValidation } from "./editorUtils.js";
16
+ import { MergeField } from "./MergeFieldExtension.js";
17
+ import RichTextToolbar from "./RichTextToolbar.js";
18
+ const createEditorContent = (value, fields, displayValue = false)=>{
19
+ if (!value) return {
20
+ type: 'doc',
21
+ content: []
22
+ };
23
+ if ('object' == typeof value && value.type) {
24
+ if (fields && fields.length > 0) return parseJSONToDocument(value, fields, displayValue);
25
+ return value;
26
+ }
27
+ if ('string' == typeof value) {
28
+ if (!value.includes('<<')) return {
29
+ type: 'doc',
30
+ content: [
31
+ {
32
+ type: 'paragraph',
33
+ content: [
34
+ {
35
+ type: 'text',
36
+ text: value
37
+ }
38
+ ]
39
+ }
40
+ ]
41
+ };
42
+ return parseTextToDocument(value, fields || [], displayValue);
43
+ }
44
+ return {
45
+ type: 'doc',
46
+ content: []
47
+ };
48
+ };
49
+ const Editor = ({ value, textValue, onChange, onTextChange, onDirtyChange, onEnterKey, onFocus, onBlur, mergeFields = [], placeholder = 'Text...', description, invalid, width, height, maxHeight, noPadding = false, readOnly = false, interactiveTaskItems = false, displayMergedValues = false, color, overflow, clampLines, label, disabled, borderRadius, backgroundColor, fontSize, textOnly, showToolbarOptions = false, maxLength, margin, marginLeft, marginRight, marginTop, marginBottom, padding, paddingLeft, paddingRight, paddingTop, paddingBottom, ref, className, ...rest })=>{
50
+ const { focused, handleFocus, handleBlur } = useInputFocus(onFocus, onBlur);
51
+ const [missingField, setMissingField] = useState(false);
52
+ const fieldsRef = useRef(mergeFields);
53
+ const [isUpdatingContent, setIsUpdatingContent] = useState(false);
54
+ const [scale, setScale] = useState(1);
55
+ const onEnterKeyRef = useRef(onEnterKey);
56
+ const margins = {
57
+ margin,
58
+ marginLeft,
59
+ marginRight,
60
+ marginTop,
61
+ marginBottom
62
+ };
63
+ const paddings = {
64
+ padding,
65
+ paddingLeft,
66
+ paddingRight,
67
+ paddingTop,
68
+ paddingBottom
69
+ };
70
+ useEffect(()=>{
71
+ onEnterKeyRef.current = onEnterKey;
72
+ }, [
73
+ onEnterKey
74
+ ]);
75
+ const heightVar = maxHeight ?? height;
76
+ const editorMaxHeight = heightVar;
77
+ const editorContent = value ?? (void 0 !== textValue ? createEditorContent(textValue, mergeFields, displayMergedValues) : createEditorContent());
78
+ const editor = useEditor({
79
+ extensions: [
80
+ starter_kit.configure({
81
+ bold: {},
82
+ italic: {},
83
+ strike: {},
84
+ code: {},
85
+ paragraph: {
86
+ HTMLAttributes: {
87
+ class: 'editor-paragraph'
88
+ }
89
+ }
90
+ }),
91
+ extension_highlight.configure({
92
+ multicolor: true
93
+ }),
94
+ extension_placeholder.configure({
95
+ placeholder
96
+ }),
97
+ extension_task_list,
98
+ extension_task_item.configure({
99
+ nested: true,
100
+ onReadOnlyChecked: ()=>interactiveTaskItems
101
+ }),
102
+ MergeField,
103
+ Markdown,
104
+ ...maxLength ? [
105
+ extension_character_count.configure({
106
+ limit: maxLength
107
+ })
108
+ ] : []
109
+ ],
110
+ content: editorContent,
111
+ editable: !readOnly && !disabled,
112
+ immediatelyRender: true,
113
+ editorProps: {
114
+ handleKeyDown: (_view, event)=>{
115
+ if ('Enter' === event.key && !event.shiftKey && onEnterKeyRef.current) {
116
+ event.preventDefault();
117
+ onEnterKeyRef.current(event);
118
+ return true;
119
+ }
120
+ return false;
121
+ },
122
+ handlePaste: (_view, event)=>{
123
+ const clipboardData = event.clipboardData || window.clipboardData;
124
+ const pastedText = clipboardData?.getData('text/plain') || '';
125
+ if (!pastedText) return false;
126
+ if (maxLength && editor) {
127
+ const currentLength = getEditorCharacterCount(editor);
128
+ const remainingSpace = maxLength - currentLength;
129
+ if (remainingSpace <= 0) {
130
+ event.preventDefault();
131
+ return true;
132
+ }
133
+ if (pastedText.length > remainingSpace) {
134
+ const truncatedText = pastedText.substring(0, remainingSpace);
135
+ event.preventDefault();
136
+ editor.commands.insertContent(truncatedText, {
137
+ contentType: 'markdown'
138
+ });
139
+ return true;
140
+ }
141
+ }
142
+ if (editor) {
143
+ event.preventDefault();
144
+ editor.commands.insertContent(pastedText, {
145
+ contentType: 'markdown'
146
+ });
147
+ return true;
148
+ }
149
+ return false;
150
+ }
151
+ },
152
+ onUpdate: ({ editor })=>{
153
+ if (isUpdatingContent) return;
154
+ if (maxLength) {
155
+ const currentLength = getEditorCharacterCount(editor);
156
+ if (currentLength > maxLength) {
157
+ setIsUpdatingContent(true);
158
+ editor.commands.undo();
159
+ setIsUpdatingContent(false);
160
+ return;
161
+ }
162
+ }
163
+ const json = editor.getJSON();
164
+ const hasMissing = hasMissingFields(editor, mergeFields);
165
+ const newIsDirty = editor.can().undo();
166
+ startTransition(()=>{
167
+ setMissingField(hasMissing);
168
+ if (onDirtyChange) onDirtyChange(newIsDirty);
169
+ if (onChange) onChange(json, hasMissing, 'insert-characters');
170
+ if (onTextChange) {
171
+ const text = editorContentToText(json);
172
+ onTextChange(text, hasMissing, 'insert-characters');
173
+ }
174
+ });
175
+ },
176
+ onFocus: ()=>{
177
+ handleFocus();
178
+ },
179
+ onBlur: ()=>{
180
+ handleBlur();
181
+ }
182
+ });
183
+ useEffect(()=>{
184
+ if (editor) editor.setEditable(!readOnly && !disabled);
185
+ }, [
186
+ editor,
187
+ readOnly,
188
+ disabled
189
+ ]);
190
+ useEffect(()=>{
191
+ if (editor) {
192
+ const placeholderExt = editor.extensionManager.extensions.find((ext)=>'placeholder' === ext.name);
193
+ if (placeholderExt) placeholderExt.options.placeholder = placeholder;
194
+ }
195
+ }, [
196
+ editor,
197
+ placeholder
198
+ ]);
199
+ useEffect(()=>{
200
+ if (!editor || isUpdatingContent) return;
201
+ const newContent = value ?? (void 0 !== textValue ? createEditorContent(textValue, mergeFields, displayMergedValues) : null);
202
+ if (!newContent) return;
203
+ const currentContent = editor.getJSON();
204
+ if (!isEqual(currentContent, newContent)) {
205
+ setIsUpdatingContent(true);
206
+ requestAnimationFrame(()=>{
207
+ const { selection } = editor.state;
208
+ const { from, to } = selection;
209
+ editor.commands.setContent(newContent);
210
+ requestAnimationFrame(()=>{
211
+ try {
212
+ const newDocSize = editor.state.doc.content.size;
213
+ const safeFrom = Math.min(from, newDocSize);
214
+ const safeTo = Math.min(to, newDocSize);
215
+ if (safeFrom >= 0 && safeTo >= 0 && safeFrom <= newDocSize && safeTo <= newDocSize) editor.commands.setTextSelection({
216
+ from: safeFrom,
217
+ to: safeTo
218
+ });
219
+ } catch {}
220
+ setIsUpdatingContent(false);
221
+ });
222
+ });
223
+ }
224
+ }, [
225
+ value,
226
+ textValue,
227
+ mergeFields,
228
+ displayMergedValues,
229
+ editor
230
+ ]);
231
+ useEffect(()=>{
232
+ if (!editor) return;
233
+ const { current: prevFields } = fieldsRef;
234
+ const areEqual = isEqual(prevFields, mergeFields);
235
+ if (!areEqual) {
236
+ fieldsRef.current = mergeFields;
237
+ updateMergeFieldValidation(editor, mergeFields, displayMergedValues);
238
+ const hasMissing = hasMissingFields(editor, mergeFields);
239
+ startTransition(()=>{
240
+ setMissingField(hasMissing);
241
+ });
242
+ }
243
+ }, [
244
+ mergeFields,
245
+ displayMergedValues,
246
+ editor
247
+ ]);
248
+ useImperativeHandle(ref, ()=>({
249
+ insertField: (field)=>{
250
+ if (editor) insertMergeField(editor, field, mergeFields, displayMergedValues);
251
+ },
252
+ insertText: (text)=>{
253
+ if (editor) editor.chain().focus().insertContent(text).run();
254
+ },
255
+ focusAtEnd: ()=>{
256
+ if (editor) editor.commands.focus('end');
257
+ },
258
+ zoomIn: ()=>{
259
+ setScale((prevScale)=>Math.min(2.0, prevScale + 0.1));
260
+ },
261
+ zoomOut: ()=>{
262
+ setScale((prevScale)=>Math.max(0.5, prevScale - 0.1));
263
+ },
264
+ resetZoom: ()=>{
265
+ setScale(1);
266
+ },
267
+ getMarkdown: ()=>{
268
+ if (editor) return editor.getMarkdown();
269
+ return '';
270
+ },
271
+ getText: ()=>{
272
+ if (editor) return editorContentToText(editor.getJSON());
273
+ return '';
274
+ },
275
+ setText: (text)=>{
276
+ if (editor) {
277
+ const content = createEditorContent(text, mergeFields, displayMergedValues);
278
+ editor.commands.setContent(content);
279
+ }
280
+ }
281
+ }));
282
+ const handleContainerClick = (event)=>{
283
+ if (!readOnly && !disabled) {
284
+ event.stopPropagation();
285
+ if (editor && !editor.isFocused) editor.commands.focus('end');
286
+ }
287
+ };
288
+ if (!editor) return null;
289
+ return /*#__PURE__*/ jsxs(EditorContainer, {
290
+ onClick: handleContainerClick,
291
+ width: width,
292
+ height: height,
293
+ editorMaxHeight: editorMaxHeight,
294
+ noPadding: noPadding || textOnly,
295
+ readOnly: readOnly,
296
+ color: color,
297
+ overflow: overflow,
298
+ clampLines: clampLines,
299
+ filled: isInputFilled(documentToText(editor || {
300
+ getJSON: ()=>({})
301
+ })),
302
+ invalid: invalid || missingField,
303
+ textOnly: textOnly,
304
+ borderRadius: borderRadius,
305
+ backgroundColor: backgroundColor,
306
+ fontSize: fontSize,
307
+ focused: focused,
308
+ disabled: disabled,
309
+ hasLabel: !!label,
310
+ hideEditor: !isInputFilled(documentToText(editor || {
311
+ getJSON: ()=>({})
312
+ })) && !!label && !focused && !showToolbarOptions,
313
+ scale: scale,
314
+ className: className,
315
+ ...margins,
316
+ ...paddings,
317
+ children: [
318
+ /*#__PURE__*/ jsxs(InputWrapper, {
319
+ readOnly: readOnly,
320
+ style: {
321
+ height: '100%'
322
+ },
323
+ children: [
324
+ label && !showToolbarOptions && /*#__PURE__*/ jsx(Label, {
325
+ filled: isInputFilled(documentToText(editor || {
326
+ getJSON: ()=>({})
327
+ })),
328
+ focused: focused,
329
+ disabled: disabled,
330
+ children: label
331
+ }),
332
+ showToolbarOptions && !readOnly && !disabled && /*#__PURE__*/ jsx(RichTextToolbar, {
333
+ editor: editor,
334
+ insertField: (field)=>{
335
+ insertMergeField(editor, field, mergeFields, displayMergedValues);
336
+ },
337
+ mergeFields: mergeFields,
338
+ maxLength: maxLength
339
+ }),
340
+ /*#__PURE__*/ jsx(EditorContent, {
341
+ editor: editor,
342
+ className: "editor-content",
343
+ ...rest
344
+ })
345
+ ]
346
+ }),
347
+ description && /*#__PURE__*/ jsx(Description, {
348
+ invalid: invalid,
349
+ children: description
350
+ })
351
+ ]
352
+ });
353
+ };
354
+ const EditorContainer = styled(InputContainer)(...EditorStyles);
355
+ const Editor_Editor = Editor;
356
+ export { createEditorContent, Editor_Editor as default };
@@ -0,0 +1,259 @@
1
+ import { marginProps, paddingProps } from "../helpers/styledProps.js";
2
+ const baseContainerStyles = ({ theme, height, noPadding, disabled, readOnly, color })=>({
3
+ alignItems: height ? 'flex-start' : void 0,
4
+ minHeight: height,
5
+ height: height ?? 'max-content',
6
+ padding: noPadding ? 0 : void 0,
7
+ color: disabled ? theme.input.color.disabled : color || theme.input.color.default,
8
+ cursor: readOnly ? 'inherit' : 'text',
9
+ pointerEvents: readOnly ? 'auto' : void 0,
10
+ '&:hover': {
11
+ backgroundColor: readOnly ? theme.input.background.default : void 0,
12
+ Label: {
13
+ color: readOnly ? theme.input.labelColor.filled : void 0
14
+ }
15
+ }
16
+ });
17
+ const editorContentStyles = ()=>({
18
+ '& .editor-content': {
19
+ width: '100%',
20
+ height: '100%',
21
+ overflow: 'auto'
22
+ }
23
+ });
24
+ const proseMirrorBaseStyles = ({ theme, height, hasLabel, editorMaxHeight, overflow, hideEditor, fontSize, filled, noPadding, scale = 1 })=>({
25
+ '& .ProseMirror': {
26
+ outline: 'none',
27
+ ...1 !== scale ? {
28
+ overflow: 'visible',
29
+ height: editorMaxHeight || height ? 'max-content' : 'auto'
30
+ } : editorMaxHeight || height ? {
31
+ maxHeight: editorMaxHeight || height,
32
+ overflow: 'visible'
33
+ } : {
34
+ overflow: overflow || 'auto'
35
+ },
36
+ lineHeight: hasLabel ? '19px' : '21px',
37
+ position: hideEditor ? 'absolute' : 'relative',
38
+ fontSize: fontSize || theme.font.size.lg,
39
+ top: !filled || hasLabel || noPadding ? void 0 : 1,
40
+ caretColor: theme.accent,
41
+ width: scale > 1 ? `${100 / scale}%` : '100%',
42
+ transformOrigin: 'top left',
43
+ transform: 1 !== scale ? `scale(${scale})` : void 0,
44
+ fontWeight: 'normal',
45
+ textDecoration: 'none',
46
+ textTransform: 'none',
47
+ letterSpacing: 'normal'
48
+ }
49
+ });
50
+ const textFormattingStyles = ({ theme })=>({
51
+ '& .ProseMirror strong, & .ProseMirror b': {
52
+ fontWeight: 'bold'
53
+ },
54
+ '& .ProseMirror em, & .ProseMirror i': {
55
+ fontStyle: 'italic'
56
+ },
57
+ '& .ProseMirror code': {
58
+ fontFamily: 'monospace',
59
+ backgroundColor: theme.scale1,
60
+ padding: '2px 4px',
61
+ borderRadius: 3,
62
+ fontSize: '0.875em'
63
+ },
64
+ '& .ProseMirror mark': {
65
+ backgroundColor: 'yellow',
66
+ color: 'inherit'
67
+ }
68
+ });
69
+ const headingStyles = ()=>({
70
+ '& .ProseMirror h1': {
71
+ fontSize: '2rem',
72
+ fontWeight: 'bold',
73
+ lineHeight: 1.2,
74
+ margin: '24px 0 16px 0'
75
+ },
76
+ '& .ProseMirror h2': {
77
+ fontSize: '1.5rem',
78
+ fontWeight: 'bold',
79
+ lineHeight: 1.3,
80
+ margin: '20px 0 12px 0'
81
+ },
82
+ '& .ProseMirror h3': {
83
+ fontSize: '1.25rem',
84
+ fontWeight: 'bold',
85
+ lineHeight: 1.4,
86
+ margin: '16px 0 8px 0'
87
+ },
88
+ '& .ProseMirror h4': {
89
+ fontSize: '1.125rem',
90
+ fontWeight: 'bold',
91
+ lineHeight: 1.4,
92
+ margin: '16px 0 8px 0'
93
+ },
94
+ '& .ProseMirror h5': {
95
+ fontSize: '1rem',
96
+ fontWeight: 'bold',
97
+ lineHeight: 1.5,
98
+ margin: '12px 0 6px 0'
99
+ },
100
+ '& .ProseMirror h6': {
101
+ fontSize: '0.875rem',
102
+ fontWeight: 'bold',
103
+ lineHeight: 1.5,
104
+ margin: '12px 0 6px 0',
105
+ textTransform: 'uppercase',
106
+ letterSpacing: '0.05em'
107
+ }
108
+ });
109
+ const blockquoteStyles = ({ theme })=>({
110
+ '& .ProseMirror blockquote': {
111
+ margin: '16px 0',
112
+ paddingLeft: '16px',
113
+ borderLeft: `4px solid ${theme.accent}`,
114
+ fontStyle: 'italic',
115
+ color: theme.scale10
116
+ },
117
+ '& .ProseMirror blockquote p': {
118
+ margin: '8px 0'
119
+ },
120
+ '& .ProseMirror blockquote p:first-of-type': {
121
+ marginTop: 0
122
+ },
123
+ '& .ProseMirror blockquote p:last-of-type': {
124
+ marginBottom: 0
125
+ }
126
+ });
127
+ const paragraphStyles = ({ clampLines, overflow })=>({
128
+ '& .ProseMirror p': {
129
+ margin: 0,
130
+ WebkitLineClamp: clampLines,
131
+ overflow: clampLines ? 'hidden' : overflow || 'auto',
132
+ display: clampLines ? '-webkit-box' : void 0,
133
+ WebkitBoxOrient: clampLines ? 'vertical' : void 0,
134
+ wordBreak: clampLines ? 'break-word' : void 0
135
+ }
136
+ });
137
+ const placeholderStyles = ({ theme, fontSize, hideEditor })=>({
138
+ '& .ProseMirror p.is-editor-empty:first-of-type::before': {
139
+ color: theme.input.color.placeholder,
140
+ content: 'attr(data-placeholder)',
141
+ float: 'left',
142
+ pointerEvents: 'none',
143
+ height: 0,
144
+ fontSize: fontSize || theme.font.size.lg,
145
+ visibility: hideEditor ? 'hidden' : void 0
146
+ }
147
+ });
148
+ const listStyles = ()=>({
149
+ '& .ProseMirror ul:not([data-type="taskList"])': {
150
+ listStyle: 'disc',
151
+ listStylePosition: 'inside',
152
+ margin: '16px 0',
153
+ paddingLeft: 20
154
+ },
155
+ '& .ProseMirror ol': {
156
+ listStyle: 'decimal',
157
+ listStylePosition: 'inside',
158
+ margin: '16px 0',
159
+ paddingLeft: 20
160
+ },
161
+ '& .ProseMirror ul:not([data-type="taskList"]) li, & .ProseMirror ol li': {
162
+ display: 'list-item',
163
+ margin: '4px 0',
164
+ padding: 0,
165
+ listStyleType: 'inherit'
166
+ },
167
+ '& .ProseMirror ul:not([data-type="taskList"]) li p, & .ProseMirror ol li p': {
168
+ display: 'inline',
169
+ margin: 0
170
+ },
171
+ '& .ProseMirror ul:not([data-type="taskList"]) ul, & .ProseMirror ol ol, & .ProseMirror ul:not([data-type="taskList"]) ol, & .ProseMirror ol ul:not([data-type="taskList"])': {
172
+ margin: 0,
173
+ paddingLeft: 20
174
+ }
175
+ });
176
+ const taskListStyles = ()=>({
177
+ '& .ProseMirror ul[data-type="taskList"]': {
178
+ listStyle: 'none',
179
+ listStylePosition: 'initial',
180
+ padding: 0,
181
+ margin: '16px 0'
182
+ },
183
+ '& .ProseMirror ul[data-type="taskList"] ul': {
184
+ margin: 0
185
+ },
186
+ '& .ProseMirror ul[data-type="taskList"] li': {
187
+ display: 'flex',
188
+ alignItems: 'flex-start',
189
+ gap: 8,
190
+ margin: 0,
191
+ padding: 0,
192
+ listStyle: 'none'
193
+ },
194
+ '& .ProseMirror ul[data-type="taskList"] li > label': {
195
+ flexShrink: 0,
196
+ cursor: 'pointer',
197
+ display: 'flex',
198
+ alignItems: 'flex-start',
199
+ paddingTop: 2
200
+ },
201
+ '& .ProseMirror ul[data-type="taskList"] li > label input[type="checkbox"]': {
202
+ margin: 0,
203
+ padding: 0,
204
+ width: 16,
205
+ height: 16
206
+ },
207
+ '& .ProseMirror ul[data-type="taskList"] li > label span': {
208
+ display: 'none'
209
+ },
210
+ '& .ProseMirror ul[data-type="taskList"] li > div': {
211
+ flex: 1,
212
+ minWidth: 0,
213
+ display: 'flex',
214
+ flexDirection: 'column'
215
+ },
216
+ '& .ProseMirror ul[data-type="taskList"] li > div > p:first-of-type': {
217
+ margin: 0,
218
+ minHeight: 24
219
+ },
220
+ '& .ProseMirror ul[data-type="taskList"] li > div > p:not(:first-of-type)': {
221
+ margin: 0,
222
+ lineHeight: '1.5'
223
+ }
224
+ });
225
+ const placeholderPositionStyles = ({ noPadding, hasLabel })=>{
226
+ let top;
227
+ if (noPadding) top = -1;
228
+ if (hasLabel) top = -2;
229
+ return {
230
+ '& .ProseMirror p.is-editor-empty:first-of-type::before': {
231
+ position: 'relative',
232
+ top
233
+ }
234
+ };
235
+ };
236
+ const textOnlyStyles = ({ textOnly })=>({
237
+ backgroundColor: textOnly ? 'transparent' : void 0,
238
+ '&:hover': {
239
+ backgroundColor: textOnly ? 'transparent' : void 0
240
+ }
241
+ });
242
+ const styles = [
243
+ baseContainerStyles,
244
+ editorContentStyles,
245
+ proseMirrorBaseStyles,
246
+ textFormattingStyles,
247
+ headingStyles,
248
+ blockquoteStyles,
249
+ paragraphStyles,
250
+ placeholderStyles,
251
+ listStyles,
252
+ taskListStyles,
253
+ placeholderPositionStyles,
254
+ textOnlyStyles,
255
+ marginProps,
256
+ paddingProps
257
+ ];
258
+ const EditorStyles = styles;
259
+ export { EditorStyles as default };