@lets-events/react 11.8.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +2 -2
- package/.turbo/turbo-build.log +21 -18
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +122 -6
- package/dist/index.d.ts +122 -6
- package/dist/index.js +976 -237
- package/dist/index.mjs +970 -237
- package/package.json +7 -2
- package/src/components/Alert.tsx +303 -303
- package/src/components/Avatar.tsx +55 -55
- package/src/components/Badge.tsx +125 -125
- package/src/components/Box.tsx +3 -3
- package/src/components/Button/index.tsx +16 -16
- package/src/components/Button/styledComponents.ts +287 -287
- package/src/components/ButtonGroup.tsx +484 -484
- package/src/components/Calendar/index.tsx +139 -136
- package/src/components/Calendar/styledComponents.ts +209 -209
- package/src/components/Card.tsx +48 -48
- package/src/components/CheckboxGroup.tsx +176 -176
- package/src/components/Container.tsx +39 -39
- package/src/components/Drawer/index.tsx +55 -55
- package/src/components/Drawer/styledComponents.ts +46 -46
- package/src/components/Dropdown.tsx +302 -302
- package/src/components/Filter.tsx +164 -164
- package/src/components/Flex.tsx +118 -118
- package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
- package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
- package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
- package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
- package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
- package/src/components/FormFields/BirthDateFormField.tsx +84 -84
- package/src/components/FormFields/CNPJFormField.tsx +87 -87
- package/src/components/FormFields/CPFFormField.tsx +78 -78
- package/src/components/FormFields/CalendarFormField.tsx +89 -0
- package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
- package/src/components/FormFields/EmailFormField.tsx +27 -27
- package/src/components/FormFields/Form.tsx +39 -39
- package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +40 -40
- package/src/components/FormFields/MultiSelectFormField.tsx +61 -55
- package/src/components/FormFields/PhoneFormField.tsx +40 -40
- package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
- package/src/components/FormFields/RichEditorFormField.tsx +69 -0
- package/src/components/FormFields/SelectFormField.tsx +93 -93
- package/src/components/FormFields/TextAreaFormField.tsx +57 -48
- package/src/components/FormFields/TextFormField.tsx +112 -112
- package/src/components/FormFields/TimePickerFormField.tsx +88 -0
- package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
- package/src/components/FormFields/subComponents/FormLabel.tsx +29 -29
- package/src/components/FormFields/utils/validation.ts +23 -23
- package/src/components/Grid.tsx +137 -137
- package/src/components/Icon.tsx +47 -47
- package/src/components/MenuDropdown/index.tsx +38 -38
- package/src/components/MenuDropdown/styledComponents.ts +31 -31
- package/src/components/Modal.tsx +90 -90
- package/src/components/MultiSelect.tsx +266 -267
- package/src/components/RadioGroup.tsx +210 -210
- package/src/components/RichEditor/QuillComponent.tsx +415 -0
- package/src/components/RichEditor/RichEditor.tsx +38 -0
- package/src/components/RichEditor/index.ts +2 -0
- package/src/components/RichEditor/styledComponents.ts +62 -0
- package/src/components/Section.tsx +33 -33
- package/src/components/Step.tsx +164 -164
- package/src/components/Switch.tsx +108 -108
- package/src/components/Text.tsx +38 -38
- package/src/components/TextField.tsx +372 -365
- package/src/components/TextareaField.tsx +128 -128
- package/src/components/TimePicker.tsx +301 -298
- package/src/components/Toast/components/ToastItem.tsx +41 -41
- package/src/components/Toast/components/ToastProvider.tsx +63 -63
- package/src/components/Toast/hooks/useToast.ts +12 -12
- package/src/components/Toast/index.tsx +5 -5
- package/src/components/Toast/styles/index.ts +135 -135
- package/src/components/Toast/types/index.ts +46 -46
- package/src/components/Tooltip/index.tsx +66 -66
- package/src/components/Tooltip/styles.ts +77 -77
- package/src/hooks/useCountries.ts +41 -41
- package/src/hooks/useImageUpload.ts +139 -0
- package/src/hooks/useOnClickOutside.tsx +20 -20
- package/src/index.tsx +67 -55
- package/src/styles/index.ts +38 -38
- package/src/types/typographyValues.ts +178 -178
- package/src/utils/getNestedValue.ts +3 -3
- package/src/utils/states.ts +29 -29
- package/src/utils/uploadService.ts +180 -0
- package/tsconfig.json +3 -3
- package/tsup.config.ts +38 -0
- package/dist/index.css +0 -171
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import { useQuill } from "react-quilljs";
|
|
3
|
+
import "quill/dist/quill.snow.css";
|
|
4
|
+
import { Flex } from "../Flex";
|
|
5
|
+
import { Text } from "../Text";
|
|
6
|
+
import { RichEditorProps } from "./RichEditor";
|
|
7
|
+
import { useToast } from "../Toast/hooks/useToast";
|
|
8
|
+
import { UploadService } from "../../utils/uploadService";
|
|
9
|
+
import { UploadConfig } from "./RichEditor";
|
|
10
|
+
import { QuillContainer, QuillEditor } from "./styledComponents";
|
|
11
|
+
|
|
12
|
+
interface QuillComponentProps extends RichEditorProps {
|
|
13
|
+
uploadConfig: UploadConfig;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const QuillComponent: React.FC<QuillComponentProps> = ({
|
|
17
|
+
value = "",
|
|
18
|
+
onChange,
|
|
19
|
+
placeholder = "Digite seu texto aqui...",
|
|
20
|
+
disabled = false,
|
|
21
|
+
className,
|
|
22
|
+
uploadConfig,
|
|
23
|
+
}) => {
|
|
24
|
+
const [showVideoModal, setShowVideoModal] = useState(false);
|
|
25
|
+
const [videoUrl, setVideoUrl] = useState("");
|
|
26
|
+
const [showLinkModal, setShowLinkModal] = useState(false);
|
|
27
|
+
const [linkUrl, setLinkUrl] = useState("");
|
|
28
|
+
|
|
29
|
+
const videoModalRef = useRef<HTMLDivElement>(null);
|
|
30
|
+
const linkModalRef = useRef<HTMLDivElement>(null);
|
|
31
|
+
const { addToast, removeToast } = useToast();
|
|
32
|
+
|
|
33
|
+
const modules = {
|
|
34
|
+
toolbar: [
|
|
35
|
+
[{ header: [1, 2, false] }],
|
|
36
|
+
["bold", "italic", "underline", "strike"],
|
|
37
|
+
[{ color: [] }, { background: [] }],
|
|
38
|
+
[{ align: [] }],
|
|
39
|
+
[{ list: "ordered" }, { list: "bullet" }],
|
|
40
|
+
["link", "image", "video"],
|
|
41
|
+
],
|
|
42
|
+
clipboard: {
|
|
43
|
+
matchVisual: false,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const formats = [
|
|
48
|
+
"header",
|
|
49
|
+
"bold",
|
|
50
|
+
"italic",
|
|
51
|
+
"underline",
|
|
52
|
+
"strike",
|
|
53
|
+
"color",
|
|
54
|
+
"background",
|
|
55
|
+
"align",
|
|
56
|
+
"list",
|
|
57
|
+
"link",
|
|
58
|
+
"image",
|
|
59
|
+
"video",
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
const { quill, quillRef } = useQuill({
|
|
63
|
+
theme: "snow",
|
|
64
|
+
modules,
|
|
65
|
+
formats,
|
|
66
|
+
placeholder,
|
|
67
|
+
readOnly: disabled,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const handleImageUpload = useCallback(
|
|
71
|
+
async (file: File) => {
|
|
72
|
+
if (disabled || !quill || !uploadConfig) return;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
addToast({
|
|
76
|
+
type: "info",
|
|
77
|
+
message: "Carregando imagem...",
|
|
78
|
+
duration: 2000,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const uploadedFile = await UploadService.uploadToS3(file, uploadConfig);
|
|
82
|
+
removeToast("info");
|
|
83
|
+
addToast({
|
|
84
|
+
type: "success",
|
|
85
|
+
message: "Imagem adicionada com sucesso!",
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const selection = quill.getSelection();
|
|
89
|
+
const index = selection ? selection.index : quill.getLength();
|
|
90
|
+
quill.insertEmbed(index, "image", uploadedFile.url);
|
|
91
|
+
quill.setSelection(index + 1, 0);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error("Erro no upload:", error);
|
|
94
|
+
addToast({
|
|
95
|
+
type: "error",
|
|
96
|
+
message:
|
|
97
|
+
"Erro no upload: Não foi possível enviar a imagem. Tente novamente.",
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
[disabled, quill, addToast, removeToast, uploadConfig]
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (quill && value) {
|
|
106
|
+
const currentContent = quill.root.innerHTML;
|
|
107
|
+
if (currentContent !== value) {
|
|
108
|
+
const selection = quill.getSelection();
|
|
109
|
+
quill.clipboard.dangerouslyPasteHTML(value);
|
|
110
|
+
|
|
111
|
+
if (selection) {
|
|
112
|
+
quill.setSelection(selection.index, selection.length);
|
|
113
|
+
} else {
|
|
114
|
+
quill.setSelection(quill.getLength(), 0);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, [quill, value]);
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (quill) {
|
|
122
|
+
quill.on("text-change", (delta: any, oldDelta: any, source: string) => {
|
|
123
|
+
if (source === "user") {
|
|
124
|
+
const html = quill.root.innerHTML;
|
|
125
|
+
onChange?.(html);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const toolbar = quill.getModule("toolbar") as any;
|
|
130
|
+
if (toolbar) {
|
|
131
|
+
toolbar.addHandler("link", () => setShowLinkModal(true));
|
|
132
|
+
toolbar.addHandler("video", () => setShowVideoModal(true));
|
|
133
|
+
toolbar.addHandler("image", () => {
|
|
134
|
+
const input = document.createElement("input");
|
|
135
|
+
input.setAttribute("type", "file");
|
|
136
|
+
input.setAttribute("accept", "image/*");
|
|
137
|
+
input.click();
|
|
138
|
+
|
|
139
|
+
input.onchange = async () => {
|
|
140
|
+
const file = input.files?.[0];
|
|
141
|
+
if (file) {
|
|
142
|
+
await handleImageUpload(file);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
setTimeout(() => {
|
|
149
|
+
const toolbarElement =
|
|
150
|
+
quillRef.current?.parentElement?.querySelector(".ql-toolbar");
|
|
151
|
+
if (toolbarElement) {
|
|
152
|
+
const headerSelect = toolbarElement.querySelector(
|
|
153
|
+
"select[data-value]"
|
|
154
|
+
) as HTMLSelectElement;
|
|
155
|
+
console.log(headerSelect, "headerSelect");
|
|
156
|
+
if (headerSelect) {
|
|
157
|
+
const options = headerSelect.querySelectorAll("option");
|
|
158
|
+
console.log(options, "options");
|
|
159
|
+
options.forEach((option) => {
|
|
160
|
+
if (option.value === "1") {
|
|
161
|
+
option.textContent = "Título 1";
|
|
162
|
+
} else if (option.value === "2") {
|
|
163
|
+
option.textContent = "Título 2";
|
|
164
|
+
} else if (option.value === "") {
|
|
165
|
+
option.textContent = "Normal";
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}, 100);
|
|
171
|
+
}
|
|
172
|
+
}, [quill, onChange, handleImageUpload]);
|
|
173
|
+
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (quill) {
|
|
176
|
+
quill.enable(!disabled);
|
|
177
|
+
|
|
178
|
+
if (!disabled) {
|
|
179
|
+
if (quill.getLength() <= 1) {
|
|
180
|
+
quill.focus();
|
|
181
|
+
quill.setSelection(0, 0);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}, [quill, disabled]);
|
|
186
|
+
|
|
187
|
+
const handleLinkCancel = useCallback(() => {
|
|
188
|
+
setLinkUrl("");
|
|
189
|
+
setShowLinkModal(false);
|
|
190
|
+
}, []);
|
|
191
|
+
|
|
192
|
+
const handleLinkSubmit = useCallback(() => {
|
|
193
|
+
if (!linkUrl.trim() || !quill) return;
|
|
194
|
+
|
|
195
|
+
const url = linkUrl.trim();
|
|
196
|
+
const selection = quill.getSelection();
|
|
197
|
+
|
|
198
|
+
if (selection && selection.length > 0) {
|
|
199
|
+
quill.format("link", url);
|
|
200
|
+
} else {
|
|
201
|
+
const index = quill.getLength();
|
|
202
|
+
quill.insertText(index, url, "link", url);
|
|
203
|
+
quill.setSelection(index + url.length, 0);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
setLinkUrl("");
|
|
207
|
+
setShowLinkModal(false);
|
|
208
|
+
}, [linkUrl, quill]);
|
|
209
|
+
|
|
210
|
+
const handleVideoCancel = useCallback(() => {
|
|
211
|
+
setVideoUrl("");
|
|
212
|
+
setShowVideoModal(false);
|
|
213
|
+
}, []);
|
|
214
|
+
|
|
215
|
+
const handleVideoSubmit = useCallback(() => {
|
|
216
|
+
if (!videoUrl.trim() || !quill) return;
|
|
217
|
+
|
|
218
|
+
let processedUrl = videoUrl.trim();
|
|
219
|
+
|
|
220
|
+
if (processedUrl.includes("youtube.com/watch")) {
|
|
221
|
+
const videoId = processedUrl.match(/[?&]v=([^&]+)/)?.[1];
|
|
222
|
+
if (videoId) {
|
|
223
|
+
processedUrl = `https://www.youtube.com/embed/${videoId}`;
|
|
224
|
+
}
|
|
225
|
+
} else if (processedUrl.includes("youtu.be/")) {
|
|
226
|
+
const videoId = processedUrl.split("youtu.be/")[1]?.split("?")[0];
|
|
227
|
+
if (videoId) {
|
|
228
|
+
processedUrl = `https://www.youtube.com/embed/${videoId}`;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const videoHTML = `
|
|
233
|
+
<iframe
|
|
234
|
+
src="${processedUrl}"
|
|
235
|
+
style="max-width:100%; height:315px; border:0;"
|
|
236
|
+
title="Video player"
|
|
237
|
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
|
238
|
+
allowfullscreen>
|
|
239
|
+
</iframe>
|
|
240
|
+
<br/>
|
|
241
|
+
`;
|
|
242
|
+
|
|
243
|
+
const selection = quill.getSelection();
|
|
244
|
+
const insertIndex = selection ? selection.index : quill.getLength();
|
|
245
|
+
quill.clipboard.dangerouslyPasteHTML(insertIndex, videoHTML);
|
|
246
|
+
quill.setSelection(insertIndex + 1, 0);
|
|
247
|
+
|
|
248
|
+
setVideoUrl("");
|
|
249
|
+
setShowVideoModal(false);
|
|
250
|
+
}, [videoUrl, quill]);
|
|
251
|
+
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
254
|
+
if (
|
|
255
|
+
showVideoModal &&
|
|
256
|
+
videoModalRef.current &&
|
|
257
|
+
!videoModalRef.current.contains(event.target as Node)
|
|
258
|
+
) {
|
|
259
|
+
handleVideoCancel();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (
|
|
263
|
+
showLinkModal &&
|
|
264
|
+
linkModalRef.current &&
|
|
265
|
+
!linkModalRef.current.contains(event.target as Node)
|
|
266
|
+
) {
|
|
267
|
+
handleLinkCancel();
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
272
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
273
|
+
}, [showVideoModal, showLinkModal, handleVideoCancel, handleLinkCancel]);
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<QuillContainer className={className}>
|
|
277
|
+
<QuillEditor style={{ position: "relative" }}>
|
|
278
|
+
<div ref={quillRef} />
|
|
279
|
+
|
|
280
|
+
{/* Video Modal */}
|
|
281
|
+
{showVideoModal && (
|
|
282
|
+
<div
|
|
283
|
+
ref={videoModalRef}
|
|
284
|
+
style={{
|
|
285
|
+
position: "absolute",
|
|
286
|
+
top: "20px",
|
|
287
|
+
left: "20px",
|
|
288
|
+
right: "20px",
|
|
289
|
+
backgroundColor: "white",
|
|
290
|
+
border: "1px solid #e0e0e0",
|
|
291
|
+
borderRadius: "4px",
|
|
292
|
+
padding: "12px",
|
|
293
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
294
|
+
zIndex: 1000,
|
|
295
|
+
width: "fit-content",
|
|
296
|
+
}}
|
|
297
|
+
>
|
|
298
|
+
<Flex gap={8} align="center">
|
|
299
|
+
<Text
|
|
300
|
+
style={{ fontSize: "14px", fontWeight: "500", color: "#333" }}
|
|
301
|
+
>
|
|
302
|
+
Vídeo:
|
|
303
|
+
</Text>
|
|
304
|
+
<input
|
|
305
|
+
type="text"
|
|
306
|
+
value={videoUrl}
|
|
307
|
+
onChange={(e) => setVideoUrl(e.target.value)}
|
|
308
|
+
placeholder="Embed URL"
|
|
309
|
+
style={{
|
|
310
|
+
padding: "8px 12px",
|
|
311
|
+
border: "1px solid #d0d0d0",
|
|
312
|
+
borderRadius: "4px",
|
|
313
|
+
fontSize: "14px",
|
|
314
|
+
backgroundColor: "#f8f8f8",
|
|
315
|
+
}}
|
|
316
|
+
onKeyDown={(e) => {
|
|
317
|
+
if (e.key === "Enter") {
|
|
318
|
+
handleVideoSubmit();
|
|
319
|
+
} else if (e.key === "Escape") {
|
|
320
|
+
handleVideoCancel();
|
|
321
|
+
}
|
|
322
|
+
}}
|
|
323
|
+
autoFocus
|
|
324
|
+
/>
|
|
325
|
+
<button
|
|
326
|
+
onClick={handleVideoSubmit}
|
|
327
|
+
disabled={!videoUrl.trim()}
|
|
328
|
+
style={{
|
|
329
|
+
padding: "8px 16px",
|
|
330
|
+
backgroundColor: "#007bff",
|
|
331
|
+
color: "white",
|
|
332
|
+
border: "none",
|
|
333
|
+
borderRadius: "4px",
|
|
334
|
+
fontSize: "14px",
|
|
335
|
+
cursor: videoUrl.trim() ? "pointer" : "not-allowed",
|
|
336
|
+
opacity: videoUrl.trim() ? 1 : 0.6,
|
|
337
|
+
}}
|
|
338
|
+
>
|
|
339
|
+
Ok
|
|
340
|
+
</button>
|
|
341
|
+
</Flex>
|
|
342
|
+
</div>
|
|
343
|
+
)}
|
|
344
|
+
|
|
345
|
+
{/* Link Modal */}
|
|
346
|
+
{showLinkModal && (
|
|
347
|
+
<div
|
|
348
|
+
ref={linkModalRef}
|
|
349
|
+
style={{
|
|
350
|
+
position: "absolute",
|
|
351
|
+
top: "20px",
|
|
352
|
+
left: "20px",
|
|
353
|
+
right: "20px",
|
|
354
|
+
backgroundColor: "white",
|
|
355
|
+
border: "1px solid #e0e0e0",
|
|
356
|
+
borderRadius: "4px",
|
|
357
|
+
padding: "12px",
|
|
358
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
359
|
+
zIndex: 1000,
|
|
360
|
+
width: "fit-content",
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
<Flex gap={8} align="center">
|
|
364
|
+
<Text
|
|
365
|
+
style={{ fontSize: "14px", fontWeight: "500", color: "#333" }}
|
|
366
|
+
>
|
|
367
|
+
Link:
|
|
368
|
+
</Text>
|
|
369
|
+
<input
|
|
370
|
+
type="text"
|
|
371
|
+
value={linkUrl}
|
|
372
|
+
onChange={(e) => setLinkUrl(e.target.value)}
|
|
373
|
+
placeholder="URL do link"
|
|
374
|
+
style={{
|
|
375
|
+
padding: "8px 12px",
|
|
376
|
+
border: "1px solid #d0d0d0",
|
|
377
|
+
borderRadius: "4px",
|
|
378
|
+
fontSize: "14px",
|
|
379
|
+
backgroundColor: "#f8f8f8",
|
|
380
|
+
width: "300px",
|
|
381
|
+
}}
|
|
382
|
+
onKeyDown={(e) => {
|
|
383
|
+
if (e.key === "Enter") {
|
|
384
|
+
handleLinkSubmit();
|
|
385
|
+
} else if (e.key === "Escape") {
|
|
386
|
+
handleLinkCancel();
|
|
387
|
+
}
|
|
388
|
+
}}
|
|
389
|
+
autoFocus
|
|
390
|
+
/>
|
|
391
|
+
<button
|
|
392
|
+
onClick={handleLinkSubmit}
|
|
393
|
+
disabled={!linkUrl.trim()}
|
|
394
|
+
style={{
|
|
395
|
+
padding: "8px 16px",
|
|
396
|
+
backgroundColor: "#007bff",
|
|
397
|
+
color: "white",
|
|
398
|
+
border: "none",
|
|
399
|
+
borderRadius: "4px",
|
|
400
|
+
fontSize: "14px",
|
|
401
|
+
cursor: linkUrl.trim() ? "pointer" : "not-allowed",
|
|
402
|
+
opacity: linkUrl.trim() ? 1 : 0.6,
|
|
403
|
+
}}
|
|
404
|
+
>
|
|
405
|
+
Ok
|
|
406
|
+
</button>
|
|
407
|
+
</Flex>
|
|
408
|
+
</div>
|
|
409
|
+
)}
|
|
410
|
+
</QuillEditor>
|
|
411
|
+
</QuillContainer>
|
|
412
|
+
);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
export default QuillComponent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ToastProvider } from "../Toast";
|
|
2
|
+
import QuillComponent from "./QuillComponent";
|
|
3
|
+
|
|
4
|
+
export interface UploadConfig {
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
s3Bucket: string;
|
|
7
|
+
s3Region: string;
|
|
8
|
+
s3Url: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
maxFileSize?: number;
|
|
11
|
+
endpoints?: {
|
|
12
|
+
presignedUrl: string;
|
|
13
|
+
upload: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface RichEditorProps {
|
|
18
|
+
value?: string;
|
|
19
|
+
onChange?: (value: string) => void;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
uploadConfig: UploadConfig;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const RichEditor = (props: RichEditorProps) => {
|
|
29
|
+
return (
|
|
30
|
+
<div>
|
|
31
|
+
<ToastProvider>
|
|
32
|
+
<QuillComponent {...props} />
|
|
33
|
+
</ToastProvider>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default RichEditor;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { styled } from "../../styles";
|
|
2
|
+
|
|
3
|
+
export const QuillContainer = styled("div", {
|
|
4
|
+
display: "flex",
|
|
5
|
+
flexDirection: "column",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const QuillEditor = styled("div", {
|
|
9
|
+
"& .ql-editor": {
|
|
10
|
+
minHeight: "200px",
|
|
11
|
+
padding: "$12",
|
|
12
|
+
fontSize: "$14",
|
|
13
|
+
lineHeight: "$base",
|
|
14
|
+
fontFamily: "$default",
|
|
15
|
+
color: "$neutral900",
|
|
16
|
+
backgroundColor: "$white",
|
|
17
|
+
border: "none",
|
|
18
|
+
outline: "none",
|
|
19
|
+
cursor: "text",
|
|
20
|
+
caretColor: "$primary500",
|
|
21
|
+
|
|
22
|
+
"&:focus": {
|
|
23
|
+
borderColor: "$primary500",
|
|
24
|
+
boxShadow: "0 0 0 1px $primary500",
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
"& p": {
|
|
28
|
+
margin: "0 0 $8 0",
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
"& p:last-child": {
|
|
32
|
+
marginBottom: 0,
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
"& .ql-cursor": {
|
|
36
|
+
borderLeft: "2px solid $primary500",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
"& .ql-toolbar": {
|
|
41
|
+
backgroundColor: "$grey100",
|
|
42
|
+
border: "1px solid $neutral300",
|
|
43
|
+
borderBottom: "none",
|
|
44
|
+
borderTopLeftRadius: "$sm",
|
|
45
|
+
borderTopRightRadius: "$sm",
|
|
46
|
+
padding: "$8 $12",
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
"& .ql-container": {
|
|
50
|
+
border: "1px solid $neutral300",
|
|
51
|
+
borderTop: "none",
|
|
52
|
+
borderBottomLeftRadius: "$sm",
|
|
53
|
+
borderBottomRightRadius: "$sm",
|
|
54
|
+
fontFamily: "$default",
|
|
55
|
+
},
|
|
56
|
+
"& .ql-snow .ql-picker.ql-header .ql-picker-item[data-value='1']::before": {
|
|
57
|
+
content: "Título 1",
|
|
58
|
+
},
|
|
59
|
+
"& .ql-snow .ql-picker.ql-header .ql-picker-item[data-value='2']::before": {
|
|
60
|
+
content: "Título 2",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { ComponentProps, ElementType } from 'react';
|
|
2
|
-
import { styled } from '../styles';
|
|
3
|
-
import { Section as SectionRadix } from '@radix-ui/themes';
|
|
4
|
-
|
|
5
|
-
export const SectionStyled = styled(SectionRadix, {
|
|
6
|
-
variants: {
|
|
7
|
-
size: {
|
|
8
|
-
xs: { maxWidth: '576px' },
|
|
9
|
-
sm: { minWidth: '577px', maxWidth: '767px' },
|
|
10
|
-
md: { mixWidth: '768px', maxWidth: '991px' },
|
|
11
|
-
lg: { mixWidth: '992px', maxWidth: '1199px' },
|
|
12
|
-
xl: { mixWidth: '1200px', maxWidth: '1399px' },
|
|
13
|
-
xxl: { mixWidth: '1400px' },
|
|
14
|
-
responsive: { width: '100%', maxWidth: '100%', minWidth: '100%' }
|
|
15
|
-
},
|
|
16
|
-
display: {
|
|
17
|
-
none: { display: 'none' },
|
|
18
|
-
initial: { display: 'initial' },
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
defaultVariants: {
|
|
22
|
-
size: 'md',
|
|
23
|
-
display: 'initial'
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type SectionProps = ComponentProps<typeof SectionStyled> & {
|
|
28
|
-
as?: ElementType;
|
|
29
|
-
children: React.ReactNode;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export function Section({ children, ...props }: SectionProps) {
|
|
33
|
-
return <SectionStyled {...props}>{children}</SectionStyled>;
|
|
1
|
+
import { ComponentProps, ElementType } from 'react';
|
|
2
|
+
import { styled } from '../styles';
|
|
3
|
+
import { Section as SectionRadix } from '@radix-ui/themes';
|
|
4
|
+
|
|
5
|
+
export const SectionStyled = styled(SectionRadix, {
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
xs: { maxWidth: '576px' },
|
|
9
|
+
sm: { minWidth: '577px', maxWidth: '767px' },
|
|
10
|
+
md: { mixWidth: '768px', maxWidth: '991px' },
|
|
11
|
+
lg: { mixWidth: '992px', maxWidth: '1199px' },
|
|
12
|
+
xl: { mixWidth: '1200px', maxWidth: '1399px' },
|
|
13
|
+
xxl: { mixWidth: '1400px' },
|
|
14
|
+
responsive: { width: '100%', maxWidth: '100%', minWidth: '100%' }
|
|
15
|
+
},
|
|
16
|
+
display: {
|
|
17
|
+
none: { display: 'none' },
|
|
18
|
+
initial: { display: 'initial' },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
size: 'md',
|
|
23
|
+
display: 'initial'
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type SectionProps = ComponentProps<typeof SectionStyled> & {
|
|
28
|
+
as?: ElementType;
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function Section({ children, ...props }: SectionProps) {
|
|
33
|
+
return <SectionStyled {...props}>{children}</SectionStyled>;
|
|
34
34
|
}
|