@lets-events/react 12.1.6 → 12.1.8
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/.turbo/turbo-build.log +9 -10
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +65 -36
- package/dist/index.mjs +34 -23
- package/package.json +1 -1
- package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +0 -11
- package/src/components/FormFields/RichEditorFormField.tsx +38 -9
- package/src/components/RichEditor/QuillComponent.tsx +55 -37
- package/src/components/RichEditor/RichEditor.tsx +4 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
[1mnpm[22m [33mwarn[39m [94mcli[39m npm v11.5.1 does not support Node.js v20.10.0. This version of npm supports the following node versions: `^20.17.0 || >=22.9.0`. You can find the latest version at https://nodejs.org/.
|
|
3
2
|
|
|
4
|
-
> @lets-events/react@12.1.
|
|
3
|
+
> @lets-events/react@12.1.8 build
|
|
5
4
|
> tsup src/index.tsx --format esm,cjs --dts --external react
|
|
6
5
|
|
|
7
6
|
[1G[0K[34mCLI[39m Building entry: src/index.tsx
|
|
@@ -11,14 +10,14 @@
|
|
|
11
10
|
[34mCLI[39m Target: es6
|
|
12
11
|
[34mESM[39m Build start
|
|
13
12
|
[34mCJS[39m Build start
|
|
14
|
-
[
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m375.90 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 258ms
|
|
15
|
+
[32mESM[39m [1mdist/QuillComponent-EIWPUIIH.mjs [22m[32m13.81 KB[39m
|
|
15
16
|
[32mESM[39m [1mdist/chunk-TU7LKUXZ.mjs [22m[32m61.98 KB[39m
|
|
16
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m277.
|
|
17
|
-
[32mESM[39m ⚡️ Build success in
|
|
18
|
-
[32mCJS[39m [1mdist/index.js [22m[32m374.66 KB[39m
|
|
19
|
-
[32mCJS[39m ⚡️ Build success in 397ms
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m277.60 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 274ms
|
|
20
19
|
DTS Build start
|
|
21
|
-
DTS ⚡️ Build success in
|
|
22
|
-
DTS dist/index.d.mts 388.
|
|
23
|
-
DTS dist/index.d.ts 388.
|
|
20
|
+
DTS ⚡️ Build success in 5155ms
|
|
21
|
+
DTS dist/index.d.mts 388.87 KB
|
|
22
|
+
DTS dist/index.d.ts 388.87 KB
|
|
24
23
|
[1G[0K⠙[1G[0K
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -14724,7 +14724,10 @@ interface RichEditorProps {
|
|
|
14724
14724
|
label?: string;
|
|
14725
14725
|
disabled?: boolean;
|
|
14726
14726
|
className?: string;
|
|
14727
|
-
uploadConfig
|
|
14727
|
+
uploadConfig?: UploadConfig$1;
|
|
14728
|
+
simpleVersion?: boolean;
|
|
14729
|
+
onCharacterCountChange?: (count: number) => void;
|
|
14730
|
+
maxLength?: number;
|
|
14728
14731
|
}
|
|
14729
14732
|
declare const RichEditor: (props: RichEditorProps) => react_jsx_runtime.JSX.Element | null;
|
|
14730
14733
|
|
|
@@ -14733,10 +14736,11 @@ type RichEditorFormFieldProps = Omit<RichEditorProps, "value" | "onChange"> & {
|
|
|
14733
14736
|
label?: string;
|
|
14734
14737
|
required?: boolean;
|
|
14735
14738
|
validate?: (value: string) => boolean | string;
|
|
14739
|
+
maxLength?: number;
|
|
14736
14740
|
validationErrorMessage?: string;
|
|
14737
14741
|
uploadConfig: RichEditorProps["uploadConfig"];
|
|
14738
14742
|
};
|
|
14739
|
-
declare const RichEditorFormField: ({ name, label, required, validate, validationErrorMessage, ...props }: RichEditorFormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
14743
|
+
declare const RichEditorFormField: ({ name, label, required, validate, validationErrorMessage, maxLength, ...props }: RichEditorFormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
14740
14744
|
|
|
14741
14745
|
type CalendarFormFieldProps = Omit<CalendarProps, "selected" | "setSelected"> & {
|
|
14742
14746
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -14724,7 +14724,10 @@ interface RichEditorProps {
|
|
|
14724
14724
|
label?: string;
|
|
14725
14725
|
disabled?: boolean;
|
|
14726
14726
|
className?: string;
|
|
14727
|
-
uploadConfig
|
|
14727
|
+
uploadConfig?: UploadConfig$1;
|
|
14728
|
+
simpleVersion?: boolean;
|
|
14729
|
+
onCharacterCountChange?: (count: number) => void;
|
|
14730
|
+
maxLength?: number;
|
|
14728
14731
|
}
|
|
14729
14732
|
declare const RichEditor: (props: RichEditorProps) => react_jsx_runtime.JSX.Element | null;
|
|
14730
14733
|
|
|
@@ -14733,10 +14736,11 @@ type RichEditorFormFieldProps = Omit<RichEditorProps, "value" | "onChange"> & {
|
|
|
14733
14736
|
label?: string;
|
|
14734
14737
|
required?: boolean;
|
|
14735
14738
|
validate?: (value: string) => boolean | string;
|
|
14739
|
+
maxLength?: number;
|
|
14736
14740
|
validationErrorMessage?: string;
|
|
14737
14741
|
uploadConfig: RichEditorProps["uploadConfig"];
|
|
14738
14742
|
};
|
|
14739
|
-
declare const RichEditorFormField: ({ name, label, required, validate, validationErrorMessage, ...props }: RichEditorFormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
14743
|
+
declare const RichEditorFormField: ({ name, label, required, validate, validationErrorMessage, maxLength, ...props }: RichEditorFormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
14740
14744
|
|
|
14741
14745
|
type CalendarFormFieldProps = Omit<CalendarProps, "selected" | "setSelected"> & {
|
|
14742
14746
|
name: string;
|
package/dist/index.js
CHANGED
|
@@ -152,7 +152,7 @@ var require_react_is_development = __commonJS({
|
|
|
152
152
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
153
153
|
var Element = REACT_ELEMENT_TYPE;
|
|
154
154
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
155
|
-
var
|
|
155
|
+
var Fragment6 = REACT_FRAGMENT_TYPE;
|
|
156
156
|
var Lazy = REACT_LAZY_TYPE;
|
|
157
157
|
var Memo = REACT_MEMO_TYPE;
|
|
158
158
|
var Portal = REACT_PORTAL_TYPE;
|
|
@@ -211,7 +211,7 @@ var require_react_is_development = __commonJS({
|
|
|
211
211
|
exports2.ContextProvider = ContextProvider;
|
|
212
212
|
exports2.Element = Element;
|
|
213
213
|
exports2.ForwardRef = ForwardRef;
|
|
214
|
-
exports2.Fragment =
|
|
214
|
+
exports2.Fragment = Fragment6;
|
|
215
215
|
exports2.Lazy = Lazy;
|
|
216
216
|
exports2.Memo = Memo;
|
|
217
217
|
exports2.Portal = Portal;
|
|
@@ -2053,7 +2053,10 @@ var init_QuillComponent = __esm({
|
|
|
2053
2053
|
placeholder = "Digite seu texto aqui...",
|
|
2054
2054
|
disabled = false,
|
|
2055
2055
|
className,
|
|
2056
|
-
uploadConfig
|
|
2056
|
+
uploadConfig,
|
|
2057
|
+
simpleVersion = false,
|
|
2058
|
+
onCharacterCountChange,
|
|
2059
|
+
maxLength
|
|
2057
2060
|
}) => {
|
|
2058
2061
|
const [showVideoModal, setShowVideoModal] = (0, import_react20.useState)(false);
|
|
2059
2062
|
const [videoUrl, setVideoUrl] = (0, import_react20.useState)("");
|
|
@@ -2062,7 +2065,16 @@ var init_QuillComponent = __esm({
|
|
|
2062
2065
|
const videoModalRef = (0, import_react20.useRef)(null);
|
|
2063
2066
|
const linkModalRef = (0, import_react20.useRef)(null);
|
|
2064
2067
|
const { addToast, removeToast } = useToast();
|
|
2065
|
-
const modules = {
|
|
2068
|
+
const modules = simpleVersion ? {
|
|
2069
|
+
toolbar: [
|
|
2070
|
+
["bold", "italic", "underline"],
|
|
2071
|
+
[{ list: "ordered" }, { list: "bullet" }],
|
|
2072
|
+
["link"]
|
|
2073
|
+
],
|
|
2074
|
+
clipboard: {
|
|
2075
|
+
matchVisual: false
|
|
2076
|
+
}
|
|
2077
|
+
} : {
|
|
2066
2078
|
toolbar: [
|
|
2067
2079
|
[{ header: [1, 2, false] }],
|
|
2068
2080
|
["bold", "italic", "underline", "strike"],
|
|
@@ -2075,7 +2087,7 @@ var init_QuillComponent = __esm({
|
|
|
2075
2087
|
matchVisual: false
|
|
2076
2088
|
}
|
|
2077
2089
|
};
|
|
2078
|
-
const formats = [
|
|
2090
|
+
const formats = simpleVersion ? ["bold", "italic", "underline", "list", "link"] : [
|
|
2079
2091
|
"header",
|
|
2080
2092
|
"bold",
|
|
2081
2093
|
"italic",
|
|
@@ -2143,8 +2155,14 @@ var init_QuillComponent = __esm({
|
|
|
2143
2155
|
if (quill) {
|
|
2144
2156
|
quill.on("text-change", (delta, oldDelta, source) => {
|
|
2145
2157
|
if (source === "user") {
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2158
|
+
const text = quill.getText().trim();
|
|
2159
|
+
const count = text.length;
|
|
2160
|
+
if (maxLength !== void 0 && count > maxLength) {
|
|
2161
|
+
quill.deleteText(maxLength, count - maxLength);
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
onChange == null ? void 0 : onChange(quill.root.innerHTML);
|
|
2165
|
+
onCharacterCountChange == null ? void 0 : onCharacterCountChange(count);
|
|
2148
2166
|
}
|
|
2149
2167
|
});
|
|
2150
2168
|
const toolbar = quill.getModule("toolbar");
|
|
@@ -2187,7 +2205,7 @@ var init_QuillComponent = __esm({
|
|
|
2187
2205
|
}
|
|
2188
2206
|
}, 2e3);
|
|
2189
2207
|
}
|
|
2190
|
-
}, [quill, onChange, handleImageUpload]);
|
|
2208
|
+
}, [quill, onChange, handleImageUpload, onCharacterCountChange]);
|
|
2191
2209
|
(0, import_react20.useEffect)(() => {
|
|
2192
2210
|
if (quill) {
|
|
2193
2211
|
quill.enable(!disabled);
|
|
@@ -11093,18 +11111,7 @@ var IdentityDocumentNumberFormField = ({
|
|
|
11093
11111
|
name,
|
|
11094
11112
|
label,
|
|
11095
11113
|
required,
|
|
11096
|
-
placeholder: placeholder || "__.___.___-_"
|
|
11097
|
-
mask: {
|
|
11098
|
-
mask: "__.___.___-_",
|
|
11099
|
-
replacement: { _: /[0-9]/ }
|
|
11100
|
-
},
|
|
11101
|
-
validate: (value) => {
|
|
11102
|
-
const cleaned = value.replace(/[^\d]/g, "");
|
|
11103
|
-
const isEmpty = cleaned.length === 0;
|
|
11104
|
-
if (!required && isEmpty) return true;
|
|
11105
|
-
if (cleaned.length >= 3) return true;
|
|
11106
|
-
return validationErrorMessage;
|
|
11107
|
-
}
|
|
11114
|
+
placeholder: placeholder || "__.___.___-_"
|
|
11108
11115
|
}
|
|
11109
11116
|
);
|
|
11110
11117
|
};
|
|
@@ -11746,6 +11753,7 @@ var RichEditor = (props) => {
|
|
|
11746
11753
|
var RichEditor_default = RichEditor;
|
|
11747
11754
|
|
|
11748
11755
|
// src/components/FormFields/RichEditorFormField.tsx
|
|
11756
|
+
var import_react22 = require("react");
|
|
11749
11757
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
11750
11758
|
var RichEditorFormField = (_a) => {
|
|
11751
11759
|
var _b = _a, {
|
|
@@ -11753,13 +11761,15 @@ var RichEditorFormField = (_a) => {
|
|
|
11753
11761
|
label,
|
|
11754
11762
|
required,
|
|
11755
11763
|
validate,
|
|
11756
|
-
validationErrorMessage = "Este campo \xE9 obrigat\xF3rio."
|
|
11764
|
+
validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
|
|
11765
|
+
maxLength
|
|
11757
11766
|
} = _b, props = __objRest(_b, [
|
|
11758
11767
|
"name",
|
|
11759
11768
|
"label",
|
|
11760
11769
|
"required",
|
|
11761
11770
|
"validate",
|
|
11762
|
-
"validationErrorMessage"
|
|
11771
|
+
"validationErrorMessage",
|
|
11772
|
+
"maxLength"
|
|
11763
11773
|
]);
|
|
11764
11774
|
const { field, fieldState } = (0, import_react_hook_form12.useController)({
|
|
11765
11775
|
name,
|
|
@@ -11774,11 +11784,28 @@ var RichEditorFormField = (_a) => {
|
|
|
11774
11784
|
},
|
|
11775
11785
|
defaultValue: ""
|
|
11776
11786
|
});
|
|
11787
|
+
const [caracterQuantity, setCaracterQuantity] = (0, import_react22.useState)(maxLength);
|
|
11788
|
+
const handleCharacterCountChange = (count) => {
|
|
11789
|
+
if (maxLength !== void 0) {
|
|
11790
|
+
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
11791
|
+
}
|
|
11792
|
+
};
|
|
11777
11793
|
const fieldError = fieldState.error;
|
|
11778
11794
|
const haveError = !!fieldError;
|
|
11779
11795
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
11780
11796
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Flex2, { direction: "column", children: [
|
|
11781
|
-
|
|
11797
|
+
maxLength ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Flex2, { direction: "row", justify: "between", children: [
|
|
11798
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11799
|
+
FormLabel,
|
|
11800
|
+
{
|
|
11801
|
+
name,
|
|
11802
|
+
label,
|
|
11803
|
+
required,
|
|
11804
|
+
haveError
|
|
11805
|
+
}
|
|
11806
|
+
),
|
|
11807
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Badge, { color: "grey", size: "xs", children: caracterQuantity })
|
|
11808
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: label && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11782
11809
|
FormLabel,
|
|
11783
11810
|
{
|
|
11784
11811
|
name,
|
|
@@ -11786,13 +11813,15 @@ var RichEditorFormField = (_a) => {
|
|
|
11786
11813
|
required,
|
|
11787
11814
|
haveError
|
|
11788
11815
|
}
|
|
11789
|
-
),
|
|
11816
|
+
) }),
|
|
11790
11817
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
11791
11818
|
RichEditor_default,
|
|
11792
11819
|
__spreadProps(__spreadValues({}, props), {
|
|
11793
11820
|
value: field.value,
|
|
11794
11821
|
onChange: field.onChange,
|
|
11795
|
-
"aria-labelledby": `${name}-label
|
|
11822
|
+
"aria-labelledby": `${name}-label`,
|
|
11823
|
+
onCharacterCountChange: handleCharacterCountChange,
|
|
11824
|
+
maxLength
|
|
11796
11825
|
})
|
|
11797
11826
|
),
|
|
11798
11827
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ErrorFormMessage, { message: errorMsg })
|
|
@@ -11802,7 +11831,7 @@ var RichEditorFormField = (_a) => {
|
|
|
11802
11831
|
// src/components/FormFields/CalendarFormField.tsx
|
|
11803
11832
|
var import_react_hook_form13 = require("react-hook-form");
|
|
11804
11833
|
init_Flex();
|
|
11805
|
-
var
|
|
11834
|
+
var import_react23 = require("react");
|
|
11806
11835
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
11807
11836
|
var CalendarFormField = (_a) => {
|
|
11808
11837
|
var _b = _a, {
|
|
@@ -11824,7 +11853,7 @@ var CalendarFormField = (_a) => {
|
|
|
11824
11853
|
"onChange",
|
|
11825
11854
|
"allowPastDates"
|
|
11826
11855
|
]);
|
|
11827
|
-
const handleValidate = (0,
|
|
11856
|
+
const handleValidate = (0, import_react23.useCallback)(
|
|
11828
11857
|
(value) => {
|
|
11829
11858
|
var _a2;
|
|
11830
11859
|
if (value === void 0 || value === null) {
|
|
@@ -11879,7 +11908,7 @@ var CalendarFormField = (_a) => {
|
|
|
11879
11908
|
// src/components/FormFields/TimePickerFormField.tsx
|
|
11880
11909
|
var import_react_hook_form14 = require("react-hook-form");
|
|
11881
11910
|
init_Flex();
|
|
11882
|
-
var
|
|
11911
|
+
var import_react24 = require("react");
|
|
11883
11912
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
11884
11913
|
var TimePickerFormField = (_a) => {
|
|
11885
11914
|
var _b = _a, {
|
|
@@ -11897,7 +11926,7 @@ var TimePickerFormField = (_a) => {
|
|
|
11897
11926
|
"validationErrorMessage",
|
|
11898
11927
|
"rules"
|
|
11899
11928
|
]);
|
|
11900
|
-
const handleValidate = (0,
|
|
11929
|
+
const handleValidate = (0, import_react24.useCallback)(
|
|
11901
11930
|
(value) => {
|
|
11902
11931
|
var _a2;
|
|
11903
11932
|
if (value === void 0 || value === null || value === "") {
|
|
@@ -11949,12 +11978,12 @@ var TimePickerFormField = (_a) => {
|
|
|
11949
11978
|
};
|
|
11950
11979
|
|
|
11951
11980
|
// src/hooks/useImageUpload.ts
|
|
11952
|
-
var
|
|
11981
|
+
var import_react25 = require("react");
|
|
11953
11982
|
init_uploadService();
|
|
11954
11983
|
var useImageUpload = (options) => {
|
|
11955
|
-
const [isUploading, setIsUploading] = (0,
|
|
11956
|
-
const [progress, setProgress] = (0,
|
|
11957
|
-
const [error, setError] = (0,
|
|
11984
|
+
const [isUploading, setIsUploading] = (0, import_react25.useState)(false);
|
|
11985
|
+
const [progress, setProgress] = (0, import_react25.useState)(null);
|
|
11986
|
+
const [error, setError] = (0, import_react25.useState)(null);
|
|
11958
11987
|
const {
|
|
11959
11988
|
onSuccess,
|
|
11960
11989
|
onError,
|
|
@@ -11964,7 +11993,7 @@ var useImageUpload = (options) => {
|
|
|
11964
11993
|
allowedTypes = ["image/jpeg", "image/png", "image/gif", "image/webp"],
|
|
11965
11994
|
uploadConfig
|
|
11966
11995
|
} = options;
|
|
11967
|
-
const validateFile = (0,
|
|
11996
|
+
const validateFile = (0, import_react25.useCallback)(
|
|
11968
11997
|
(file) => {
|
|
11969
11998
|
if (!allowedTypes.includes(file.type)) {
|
|
11970
11999
|
const errorMsg = "Tipo de arquivo n\xE3o suportado";
|
|
@@ -11982,7 +12011,7 @@ var useImageUpload = (options) => {
|
|
|
11982
12011
|
},
|
|
11983
12012
|
[allowedTypes, maxFileSize, onError]
|
|
11984
12013
|
);
|
|
11985
|
-
const uploadFile = (0,
|
|
12014
|
+
const uploadFile = (0, import_react25.useCallback)(
|
|
11986
12015
|
(file) => __async(null, null, function* () {
|
|
11987
12016
|
if (!validateFile(file)) {
|
|
11988
12017
|
return null;
|
|
@@ -12035,7 +12064,7 @@ var useImageUpload = (options) => {
|
|
|
12035
12064
|
}),
|
|
12036
12065
|
[validateFile, onSuccess, onError, onProgress]
|
|
12037
12066
|
);
|
|
12038
|
-
const reset = (0,
|
|
12067
|
+
const reset = (0, import_react25.useCallback)(() => {
|
|
12039
12068
|
setIsUploading(false);
|
|
12040
12069
|
setProgress(null);
|
|
12041
12070
|
setError(null);
|
package/dist/index.mjs
CHANGED
|
@@ -8530,18 +8530,7 @@ var IdentityDocumentNumberFormField = ({
|
|
|
8530
8530
|
name,
|
|
8531
8531
|
label,
|
|
8532
8532
|
required,
|
|
8533
|
-
placeholder: placeholder || "__.___.___-_"
|
|
8534
|
-
mask: {
|
|
8535
|
-
mask: "__.___.___-_",
|
|
8536
|
-
replacement: { _: /[0-9]/ }
|
|
8537
|
-
},
|
|
8538
|
-
validate: (value) => {
|
|
8539
|
-
const cleaned = value.replace(/[^\d]/g, "");
|
|
8540
|
-
const isEmpty = cleaned.length === 0;
|
|
8541
|
-
if (!required && isEmpty) return true;
|
|
8542
|
-
if (cleaned.length >= 3) return true;
|
|
8543
|
-
return validationErrorMessage;
|
|
8544
|
-
}
|
|
8533
|
+
placeholder: placeholder || "__.___.___-_"
|
|
8545
8534
|
}
|
|
8546
8535
|
);
|
|
8547
8536
|
};
|
|
@@ -9161,7 +9150,7 @@ import { useController as useController3 } from "react-hook-form";
|
|
|
9161
9150
|
// src/components/RichEditor/RichEditor.tsx
|
|
9162
9151
|
import { lazy, useEffect as useEffect6, useState as useState7, Suspense } from "react";
|
|
9163
9152
|
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
9164
|
-
var QuillComponent = lazy(() => import("./QuillComponent-
|
|
9153
|
+
var QuillComponent = lazy(() => import("./QuillComponent-EIWPUIIH.mjs"));
|
|
9165
9154
|
var RichEditor = (props) => {
|
|
9166
9155
|
const [isClient, setIsClient] = useState7(false);
|
|
9167
9156
|
useEffect6(() => {
|
|
@@ -9173,20 +9162,23 @@ var RichEditor = (props) => {
|
|
|
9173
9162
|
var RichEditor_default = RichEditor;
|
|
9174
9163
|
|
|
9175
9164
|
// src/components/FormFields/RichEditorFormField.tsx
|
|
9176
|
-
import {
|
|
9165
|
+
import { useState as useState8 } from "react";
|
|
9166
|
+
import { Fragment as Fragment5, jsx as jsx47, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
9177
9167
|
var RichEditorFormField = (_a) => {
|
|
9178
9168
|
var _b = _a, {
|
|
9179
9169
|
name,
|
|
9180
9170
|
label,
|
|
9181
9171
|
required,
|
|
9182
9172
|
validate,
|
|
9183
|
-
validationErrorMessage = "Este campo \xE9 obrigat\xF3rio."
|
|
9173
|
+
validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
|
|
9174
|
+
maxLength
|
|
9184
9175
|
} = _b, props = __objRest(_b, [
|
|
9185
9176
|
"name",
|
|
9186
9177
|
"label",
|
|
9187
9178
|
"required",
|
|
9188
9179
|
"validate",
|
|
9189
|
-
"validationErrorMessage"
|
|
9180
|
+
"validationErrorMessage",
|
|
9181
|
+
"maxLength"
|
|
9190
9182
|
]);
|
|
9191
9183
|
const { field, fieldState } = useController3({
|
|
9192
9184
|
name,
|
|
@@ -9201,11 +9193,28 @@ var RichEditorFormField = (_a) => {
|
|
|
9201
9193
|
},
|
|
9202
9194
|
defaultValue: ""
|
|
9203
9195
|
});
|
|
9196
|
+
const [caracterQuantity, setCaracterQuantity] = useState8(maxLength);
|
|
9197
|
+
const handleCharacterCountChange = (count) => {
|
|
9198
|
+
if (maxLength !== void 0) {
|
|
9199
|
+
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
9200
|
+
}
|
|
9201
|
+
};
|
|
9204
9202
|
const fieldError = fieldState.error;
|
|
9205
9203
|
const haveError = !!fieldError;
|
|
9206
9204
|
const errorMsg = fieldError == null ? void 0 : fieldError.message;
|
|
9207
9205
|
return /* @__PURE__ */ jsxs24(Flex, { direction: "column", children: [
|
|
9208
|
-
|
|
9206
|
+
maxLength ? /* @__PURE__ */ jsxs24(Flex, { direction: "row", justify: "between", children: [
|
|
9207
|
+
label && /* @__PURE__ */ jsx47(
|
|
9208
|
+
FormLabel,
|
|
9209
|
+
{
|
|
9210
|
+
name,
|
|
9211
|
+
label,
|
|
9212
|
+
required,
|
|
9213
|
+
haveError
|
|
9214
|
+
}
|
|
9215
|
+
),
|
|
9216
|
+
/* @__PURE__ */ jsx47(Badge, { color: "grey", size: "xs", children: caracterQuantity })
|
|
9217
|
+
] }) : /* @__PURE__ */ jsx47(Fragment5, { children: label && /* @__PURE__ */ jsx47(
|
|
9209
9218
|
FormLabel,
|
|
9210
9219
|
{
|
|
9211
9220
|
name,
|
|
@@ -9213,13 +9222,15 @@ var RichEditorFormField = (_a) => {
|
|
|
9213
9222
|
required,
|
|
9214
9223
|
haveError
|
|
9215
9224
|
}
|
|
9216
|
-
),
|
|
9225
|
+
) }),
|
|
9217
9226
|
/* @__PURE__ */ jsx47(
|
|
9218
9227
|
RichEditor_default,
|
|
9219
9228
|
__spreadProps(__spreadValues({}, props), {
|
|
9220
9229
|
value: field.value,
|
|
9221
9230
|
onChange: field.onChange,
|
|
9222
|
-
"aria-labelledby": `${name}-label
|
|
9231
|
+
"aria-labelledby": `${name}-label`,
|
|
9232
|
+
onCharacterCountChange: handleCharacterCountChange,
|
|
9233
|
+
maxLength
|
|
9223
9234
|
})
|
|
9224
9235
|
),
|
|
9225
9236
|
/* @__PURE__ */ jsx47(ErrorFormMessage, { message: errorMsg })
|
|
@@ -9374,11 +9385,11 @@ var TimePickerFormField = (_a) => {
|
|
|
9374
9385
|
};
|
|
9375
9386
|
|
|
9376
9387
|
// src/hooks/useImageUpload.ts
|
|
9377
|
-
import { useState as
|
|
9388
|
+
import { useState as useState9, useCallback as useCallback6 } from "react";
|
|
9378
9389
|
var useImageUpload = (options) => {
|
|
9379
|
-
const [isUploading, setIsUploading] =
|
|
9380
|
-
const [progress, setProgress] =
|
|
9381
|
-
const [error, setError] =
|
|
9390
|
+
const [isUploading, setIsUploading] = useState9(false);
|
|
9391
|
+
const [progress, setProgress] = useState9(null);
|
|
9392
|
+
const [error, setError] = useState9(null);
|
|
9382
9393
|
const {
|
|
9383
9394
|
onSuccess,
|
|
9384
9395
|
onError,
|
package/package.json
CHANGED
|
@@ -21,17 +21,6 @@ export const IdentityDocumentNumberFormField = ({
|
|
|
21
21
|
label={label}
|
|
22
22
|
required={required}
|
|
23
23
|
placeholder={placeholder || "__.___.___-_"}
|
|
24
|
-
mask={{
|
|
25
|
-
mask: "__.___.___-_",
|
|
26
|
-
replacement: { _: /[0-9]/ },
|
|
27
|
-
}}
|
|
28
|
-
validate={(value: string) => {
|
|
29
|
-
const cleaned = value.replace(/[^\d]/g, "");
|
|
30
|
-
const isEmpty = cleaned.length === 0;
|
|
31
|
-
if (!required && isEmpty) return true;
|
|
32
|
-
if (cleaned.length >= 3) return true;
|
|
33
|
-
return false || validationErrorMessage;
|
|
34
|
-
}}
|
|
35
24
|
/>
|
|
36
25
|
);
|
|
37
26
|
};
|
|
@@ -3,6 +3,8 @@ import { Flex } from "../Flex";
|
|
|
3
3
|
import { FormLabel } from "./subComponents/FormLabel";
|
|
4
4
|
import { ErrorFormMessage } from "./subComponents/ErrorFormMessage";
|
|
5
5
|
import { RichEditor, RichEditorProps } from "../RichEditor";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { Badge } from "../Badge";
|
|
6
8
|
|
|
7
9
|
export type RichEditorFormFieldProps = Omit<
|
|
8
10
|
RichEditorProps,
|
|
@@ -12,6 +14,7 @@ export type RichEditorFormFieldProps = Omit<
|
|
|
12
14
|
label?: string;
|
|
13
15
|
required?: boolean;
|
|
14
16
|
validate?: (value: string) => boolean | string;
|
|
17
|
+
maxLength?: number;
|
|
15
18
|
validationErrorMessage?: string;
|
|
16
19
|
uploadConfig: RichEditorProps["uploadConfig"];
|
|
17
20
|
};
|
|
@@ -22,6 +25,7 @@ export const RichEditorFormField = ({
|
|
|
22
25
|
required,
|
|
23
26
|
validate,
|
|
24
27
|
validationErrorMessage = "Este campo é obrigatório.",
|
|
28
|
+
maxLength,
|
|
25
29
|
...props
|
|
26
30
|
}: RichEditorFormFieldProps) => {
|
|
27
31
|
const { field, fieldState } = useController({
|
|
@@ -40,27 +44,52 @@ export const RichEditorFormField = ({
|
|
|
40
44
|
},
|
|
41
45
|
defaultValue: "",
|
|
42
46
|
});
|
|
43
|
-
|
|
47
|
+
const [caracterQuantity, setCaracterQuantity] = useState(maxLength)
|
|
48
|
+
const handleCharacterCountChange = (count: number) => {
|
|
49
|
+
if (maxLength !== undefined) {
|
|
50
|
+
setCaracterQuantity(Math.max(0, maxLength - count));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
44
53
|
const fieldError = fieldState.error;
|
|
45
54
|
const haveError = !!fieldError;
|
|
46
55
|
const errorMsg = fieldError?.message;
|
|
47
56
|
|
|
57
|
+
|
|
48
58
|
return (
|
|
49
59
|
<Flex direction="column">
|
|
50
|
-
{
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
{maxLength ? (
|
|
61
|
+
<Flex direction="row" justify="between">
|
|
62
|
+
{label && (
|
|
63
|
+
<FormLabel
|
|
64
|
+
name={name}
|
|
65
|
+
label={label}
|
|
66
|
+
required={required}
|
|
67
|
+
haveError={haveError}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
<Badge color="grey" size="xs">
|
|
71
|
+
{caracterQuantity}
|
|
72
|
+
</Badge>
|
|
73
|
+
</Flex>
|
|
74
|
+
) : (
|
|
75
|
+
<>
|
|
76
|
+
{label && (
|
|
77
|
+
<FormLabel
|
|
78
|
+
name={name}
|
|
79
|
+
label={label}
|
|
80
|
+
required={required}
|
|
81
|
+
haveError={haveError}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
</>
|
|
57
85
|
)}
|
|
58
|
-
|
|
59
86
|
<RichEditor
|
|
60
87
|
{...props}
|
|
61
88
|
value={field.value}
|
|
62
89
|
onChange={field.onChange}
|
|
63
90
|
aria-labelledby={`${name}-label`}
|
|
91
|
+
onCharacterCountChange={handleCharacterCountChange}
|
|
92
|
+
maxLength={maxLength}
|
|
64
93
|
/>
|
|
65
94
|
|
|
66
95
|
<ErrorFormMessage message={errorMsg} />
|
|
@@ -6,20 +6,18 @@ import { Text } from "../Text";
|
|
|
6
6
|
import { RichEditorProps } from "./RichEditor";
|
|
7
7
|
import { useToast } from "../Toast/hooks/useToast";
|
|
8
8
|
import { UploadService } from "../../utils/uploadService";
|
|
9
|
-
import { UploadConfig } from "./RichEditor";
|
|
10
9
|
import { QuillContainer, QuillEditor } from "./styledComponents";
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
uploadConfig: UploadConfig;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const QuillComponent: React.FC<QuillComponentProps> = ({
|
|
11
|
+
const QuillComponent: React.FC<RichEditorProps> = ({
|
|
17
12
|
value = "",
|
|
18
13
|
onChange,
|
|
19
14
|
placeholder = "Digite seu texto aqui...",
|
|
20
15
|
disabled = false,
|
|
21
16
|
className,
|
|
22
17
|
uploadConfig,
|
|
18
|
+
simpleVersion = false,
|
|
19
|
+
onCharacterCountChange,
|
|
20
|
+
maxLength,
|
|
23
21
|
}) => {
|
|
24
22
|
const [showVideoModal, setShowVideoModal] = useState(false);
|
|
25
23
|
const [videoUrl, setVideoUrl] = useState("");
|
|
@@ -30,34 +28,47 @@ const QuillComponent: React.FC<QuillComponentProps> = ({
|
|
|
30
28
|
const linkModalRef = useRef<HTMLDivElement>(null);
|
|
31
29
|
const { addToast, removeToast } = useToast();
|
|
32
30
|
|
|
33
|
-
const modules =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
31
|
+
const modules = simpleVersion
|
|
32
|
+
? {
|
|
33
|
+
toolbar: [
|
|
34
|
+
["bold", "italic", "underline"],
|
|
35
|
+
[{ list: "ordered" }, { list: "bullet" }],
|
|
36
|
+
["link"],
|
|
37
|
+
],
|
|
38
|
+
clipboard: {
|
|
39
|
+
matchVisual: false,
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
: {
|
|
43
|
+
toolbar: [
|
|
44
|
+
[{ header: [1, 2, false] }],
|
|
45
|
+
["bold", "italic", "underline", "strike"],
|
|
46
|
+
[{ color: [] }, { background: [] }],
|
|
47
|
+
[{ align: [] }],
|
|
48
|
+
[{ list: "ordered" }, { list: "bullet" }],
|
|
49
|
+
["link", "image", "video"],
|
|
50
|
+
],
|
|
51
|
+
clipboard: {
|
|
52
|
+
matchVisual: false,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const formats = simpleVersion
|
|
57
|
+
? ["bold", "italic", "underline", "list", "link"]
|
|
58
|
+
: [
|
|
59
|
+
"header",
|
|
60
|
+
"bold",
|
|
61
|
+
"italic",
|
|
62
|
+
"underline",
|
|
63
|
+
"strike",
|
|
64
|
+
"color",
|
|
65
|
+
"background",
|
|
66
|
+
"align",
|
|
67
|
+
"list",
|
|
68
|
+
"link",
|
|
69
|
+
"image",
|
|
70
|
+
"video",
|
|
71
|
+
];
|
|
61
72
|
|
|
62
73
|
const { quill, quillRef } = useQuill({
|
|
63
74
|
theme: "snow",
|
|
@@ -121,8 +132,15 @@ const QuillComponent: React.FC<QuillComponentProps> = ({
|
|
|
121
132
|
if (quill) {
|
|
122
133
|
quill.on("text-change", (delta: any, oldDelta: any, source: string) => {
|
|
123
134
|
if (source === "user") {
|
|
124
|
-
const
|
|
125
|
-
|
|
135
|
+
const text = quill.getText().trim();
|
|
136
|
+
const count = text.length;
|
|
137
|
+
|
|
138
|
+
if (maxLength !== undefined && count > maxLength) {
|
|
139
|
+
quill.deleteText(maxLength, count - maxLength);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
onChange?.(quill.root.innerHTML);
|
|
143
|
+
onCharacterCountChange?.(count);
|
|
126
144
|
}
|
|
127
145
|
});
|
|
128
146
|
|
|
@@ -167,7 +185,7 @@ const QuillComponent: React.FC<QuillComponentProps> = ({
|
|
|
167
185
|
}
|
|
168
186
|
}, 2000);
|
|
169
187
|
}
|
|
170
|
-
}, [quill, onChange, handleImageUpload]);
|
|
188
|
+
}, [quill, onChange, handleImageUpload, onCharacterCountChange]);
|
|
171
189
|
|
|
172
190
|
useEffect(() => {
|
|
173
191
|
if (quill) {
|
|
@@ -23,7 +23,10 @@ export interface RichEditorProps {
|
|
|
23
23
|
label?: string;
|
|
24
24
|
disabled?: boolean;
|
|
25
25
|
className?: string;
|
|
26
|
-
uploadConfig
|
|
26
|
+
uploadConfig?: UploadConfig;
|
|
27
|
+
simpleVersion?: boolean;
|
|
28
|
+
onCharacterCountChange?: (count: number) => void;
|
|
29
|
+
maxLength?: number;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
const RichEditor = (props: RichEditorProps) => {
|