@lets-events/react 12.1.5 → 12.1.7

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/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 Fragment5 = REACT_FRAGMENT_TYPE;
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 = Fragment5;
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",
@@ -2127,6 +2139,7 @@ var init_QuillComponent = __esm({
2127
2139
  );
2128
2140
  (0, import_react20.useEffect)(() => {
2129
2141
  if (quill && value) {
2142
+ console.log("entrou no quill && value");
2130
2143
  const currentContent = quill.root.innerHTML;
2131
2144
  if (currentContent !== value) {
2132
2145
  const selection = quill.getSelection();
@@ -2143,8 +2156,15 @@ var init_QuillComponent = __esm({
2143
2156
  if (quill) {
2144
2157
  quill.on("text-change", (delta, oldDelta, source) => {
2145
2158
  if (source === "user") {
2146
- const html = quill.root.innerHTML;
2147
- onChange == null ? void 0 : onChange(html);
2159
+ const text = quill.getText().trim();
2160
+ const count = text.length;
2161
+ console.log("entrou no quill && user", maxLength !== void 0, count, maxLength, "count > maxLength");
2162
+ if (maxLength !== void 0 && count > maxLength) {
2163
+ quill.deleteText(maxLength, count - maxLength);
2164
+ return;
2165
+ }
2166
+ onChange == null ? void 0 : onChange(quill.root.innerHTML);
2167
+ onCharacterCountChange == null ? void 0 : onCharacterCountChange(count);
2148
2168
  }
2149
2169
  });
2150
2170
  const toolbar = quill.getModule("toolbar");
@@ -2187,7 +2207,7 @@ var init_QuillComponent = __esm({
2187
2207
  }
2188
2208
  }, 2e3);
2189
2209
  }
2190
- }, [quill, onChange, handleImageUpload]);
2210
+ }, [quill, onChange, handleImageUpload, onCharacterCountChange]);
2191
2211
  (0, import_react20.useEffect)(() => {
2192
2212
  if (quill) {
2193
2213
  quill.enable(!disabled);
@@ -2504,6 +2524,7 @@ __export(index_exports, {
2504
2524
  TimePickerDropdownStyled: () => TimePickerDropdownStyled,
2505
2525
  TimePickerFooterStyled: () => TimePickerFooterStyled,
2506
2526
  TimePickerFormField: () => TimePickerFormField,
2527
+ TimePickerIconButton: () => TimePickerIconButton,
2507
2528
  TimePickerStyled: () => TimePickerStyled,
2508
2529
  TimerPickerContentStyled: () => TimerPickerContentStyled,
2509
2530
  ToastItem: () => ToastItem,
@@ -9093,6 +9114,7 @@ init_styles();
9093
9114
  var import_jsx_runtime17 = require("react/jsx-runtime");
9094
9115
  var TimePickerStyled = styled("div", {
9095
9116
  position: "relative",
9117
+ width: "fit-content",
9096
9118
  fontFamily: "$default",
9097
9119
  lineHeight: "$base",
9098
9120
  fontSize: "$14",
@@ -9116,7 +9138,7 @@ var TimePickerDropdownStyled = styled("div", {
9116
9138
  position: "absolute",
9117
9139
  zIndex: 10,
9118
9140
  width: "100%",
9119
- maxWidth: "8.875rem",
9141
+ maxWidth: "min-content",
9120
9142
  backgroundColor: "$neutral50",
9121
9143
  border: "1px solid $neutral300",
9122
9144
  borderRadius: "$sm",
@@ -9200,6 +9222,9 @@ var TimePickerButtonStyled = styled("button", {
9200
9222
  }
9201
9223
  }
9202
9224
  });
9225
+ var TimePickerIconButton = styled(Button, {
9226
+ padding: "0 !important"
9227
+ });
9203
9228
  var pad = (num) => String(num).padStart(2, "0");
9204
9229
  function TimePicker({
9205
9230
  selected,
@@ -9281,7 +9306,7 @@ function TimePicker({
9281
9306
  },
9282
9307
  children: [
9283
9308
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9284
- Button,
9309
+ TimePickerIconButton,
9285
9310
  {
9286
9311
  type: "button",
9287
9312
  variant: "text",
@@ -9353,7 +9378,7 @@ function TimePicker({
9353
9378
  }
9354
9379
  ),
9355
9380
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9356
- Button,
9381
+ TimePickerIconButton,
9357
9382
  {
9358
9383
  type: "button",
9359
9384
  variant: "text",
@@ -11741,6 +11766,7 @@ var RichEditor = (props) => {
11741
11766
  var RichEditor_default = RichEditor;
11742
11767
 
11743
11768
  // src/components/FormFields/RichEditorFormField.tsx
11769
+ var import_react22 = require("react");
11744
11770
  var import_jsx_runtime53 = require("react/jsx-runtime");
11745
11771
  var RichEditorFormField = (_a) => {
11746
11772
  var _b = _a, {
@@ -11748,13 +11774,15 @@ var RichEditorFormField = (_a) => {
11748
11774
  label,
11749
11775
  required,
11750
11776
  validate,
11751
- validationErrorMessage = "Este campo \xE9 obrigat\xF3rio."
11777
+ validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
11778
+ maxLength
11752
11779
  } = _b, props = __objRest(_b, [
11753
11780
  "name",
11754
11781
  "label",
11755
11782
  "required",
11756
11783
  "validate",
11757
- "validationErrorMessage"
11784
+ "validationErrorMessage",
11785
+ "maxLength"
11758
11786
  ]);
11759
11787
  const { field, fieldState } = (0, import_react_hook_form12.useController)({
11760
11788
  name,
@@ -11769,11 +11797,28 @@ var RichEditorFormField = (_a) => {
11769
11797
  },
11770
11798
  defaultValue: ""
11771
11799
  });
11800
+ const [caracterQuantity, setCaracterQuantity] = (0, import_react22.useState)(maxLength);
11801
+ const handleCharacterCountChange = (count) => {
11802
+ if (maxLength !== void 0) {
11803
+ setCaracterQuantity(Math.max(0, maxLength - count));
11804
+ }
11805
+ };
11772
11806
  const fieldError = fieldState.error;
11773
11807
  const haveError = !!fieldError;
11774
11808
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
11775
11809
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Flex2, { direction: "column", children: [
11776
- label && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11810
+ maxLength ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Flex2, { direction: "row", justify: "between", children: [
11811
+ label && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11812
+ FormLabel,
11813
+ {
11814
+ name,
11815
+ label,
11816
+ required,
11817
+ haveError
11818
+ }
11819
+ ),
11820
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Badge, { color: "grey", size: "xs", children: caracterQuantity })
11821
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: label && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11777
11822
  FormLabel,
11778
11823
  {
11779
11824
  name,
@@ -11781,13 +11826,15 @@ var RichEditorFormField = (_a) => {
11781
11826
  required,
11782
11827
  haveError
11783
11828
  }
11784
- ),
11829
+ ) }),
11785
11830
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11786
11831
  RichEditor_default,
11787
11832
  __spreadProps(__spreadValues({}, props), {
11788
11833
  value: field.value,
11789
11834
  onChange: field.onChange,
11790
- "aria-labelledby": `${name}-label`
11835
+ "aria-labelledby": `${name}-label`,
11836
+ onCharacterCountChange: handleCharacterCountChange,
11837
+ maxLength
11791
11838
  })
11792
11839
  ),
11793
11840
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ErrorFormMessage, { message: errorMsg })
@@ -11797,7 +11844,7 @@ var RichEditorFormField = (_a) => {
11797
11844
  // src/components/FormFields/CalendarFormField.tsx
11798
11845
  var import_react_hook_form13 = require("react-hook-form");
11799
11846
  init_Flex();
11800
- var import_react22 = require("react");
11847
+ var import_react23 = require("react");
11801
11848
  var import_jsx_runtime54 = require("react/jsx-runtime");
11802
11849
  var CalendarFormField = (_a) => {
11803
11850
  var _b = _a, {
@@ -11819,7 +11866,7 @@ var CalendarFormField = (_a) => {
11819
11866
  "onChange",
11820
11867
  "allowPastDates"
11821
11868
  ]);
11822
- const handleValidate = (0, import_react22.useCallback)(
11869
+ const handleValidate = (0, import_react23.useCallback)(
11823
11870
  (value) => {
11824
11871
  var _a2;
11825
11872
  if (value === void 0 || value === null) {
@@ -11874,7 +11921,7 @@ var CalendarFormField = (_a) => {
11874
11921
  // src/components/FormFields/TimePickerFormField.tsx
11875
11922
  var import_react_hook_form14 = require("react-hook-form");
11876
11923
  init_Flex();
11877
- var import_react23 = require("react");
11924
+ var import_react24 = require("react");
11878
11925
  var import_jsx_runtime55 = require("react/jsx-runtime");
11879
11926
  var TimePickerFormField = (_a) => {
11880
11927
  var _b = _a, {
@@ -11892,7 +11939,7 @@ var TimePickerFormField = (_a) => {
11892
11939
  "validationErrorMessage",
11893
11940
  "rules"
11894
11941
  ]);
11895
- const handleValidate = (0, import_react23.useCallback)(
11942
+ const handleValidate = (0, import_react24.useCallback)(
11896
11943
  (value) => {
11897
11944
  var _a2;
11898
11945
  if (value === void 0 || value === null || value === "") {
@@ -11944,12 +11991,12 @@ var TimePickerFormField = (_a) => {
11944
11991
  };
11945
11992
 
11946
11993
  // src/hooks/useImageUpload.ts
11947
- var import_react24 = require("react");
11994
+ var import_react25 = require("react");
11948
11995
  init_uploadService();
11949
11996
  var useImageUpload = (options) => {
11950
- const [isUploading, setIsUploading] = (0, import_react24.useState)(false);
11951
- const [progress, setProgress] = (0, import_react24.useState)(null);
11952
- const [error, setError] = (0, import_react24.useState)(null);
11997
+ const [isUploading, setIsUploading] = (0, import_react25.useState)(false);
11998
+ const [progress, setProgress] = (0, import_react25.useState)(null);
11999
+ const [error, setError] = (0, import_react25.useState)(null);
11953
12000
  const {
11954
12001
  onSuccess,
11955
12002
  onError,
@@ -11959,7 +12006,7 @@ var useImageUpload = (options) => {
11959
12006
  allowedTypes = ["image/jpeg", "image/png", "image/gif", "image/webp"],
11960
12007
  uploadConfig
11961
12008
  } = options;
11962
- const validateFile = (0, import_react24.useCallback)(
12009
+ const validateFile = (0, import_react25.useCallback)(
11963
12010
  (file) => {
11964
12011
  if (!allowedTypes.includes(file.type)) {
11965
12012
  const errorMsg = "Tipo de arquivo n\xE3o suportado";
@@ -11977,7 +12024,7 @@ var useImageUpload = (options) => {
11977
12024
  },
11978
12025
  [allowedTypes, maxFileSize, onError]
11979
12026
  );
11980
- const uploadFile = (0, import_react24.useCallback)(
12027
+ const uploadFile = (0, import_react25.useCallback)(
11981
12028
  (file) => __async(null, null, function* () {
11982
12029
  if (!validateFile(file)) {
11983
12030
  return null;
@@ -12030,7 +12077,7 @@ var useImageUpload = (options) => {
12030
12077
  }),
12031
12078
  [validateFile, onSuccess, onError, onProgress]
12032
12079
  );
12033
- const reset = (0, import_react24.useCallback)(() => {
12080
+ const reset = (0, import_react25.useCallback)(() => {
12034
12081
  setIsUploading(false);
12035
12082
  setProgress(null);
12036
12083
  setError(null);
@@ -12135,6 +12182,7 @@ init_uploadService();
12135
12182
  TimePickerDropdownStyled,
12136
12183
  TimePickerFooterStyled,
12137
12184
  TimePickerFormField,
12185
+ TimePickerIconButton,
12138
12186
  TimePickerStyled,
12139
12187
  TimerPickerContentStyled,
12140
12188
  ToastItem,
package/dist/index.mjs CHANGED
@@ -6557,6 +6557,7 @@ import { useCallback, useRef as useRef5, useState as useState3 } from "react";
6557
6557
  import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
6558
6558
  var TimePickerStyled = styled("div", {
6559
6559
  position: "relative",
6560
+ width: "fit-content",
6560
6561
  fontFamily: "$default",
6561
6562
  lineHeight: "$base",
6562
6563
  fontSize: "$14",
@@ -6580,7 +6581,7 @@ var TimePickerDropdownStyled = styled("div", {
6580
6581
  position: "absolute",
6581
6582
  zIndex: 10,
6582
6583
  width: "100%",
6583
- maxWidth: "8.875rem",
6584
+ maxWidth: "min-content",
6584
6585
  backgroundColor: "$neutral50",
6585
6586
  border: "1px solid $neutral300",
6586
6587
  borderRadius: "$sm",
@@ -6664,6 +6665,9 @@ var TimePickerButtonStyled = styled("button", {
6664
6665
  }
6665
6666
  }
6666
6667
  });
6668
+ var TimePickerIconButton = styled(Button, {
6669
+ padding: "0 !important"
6670
+ });
6667
6671
  var pad = (num) => String(num).padStart(2, "0");
6668
6672
  function TimePicker({
6669
6673
  selected,
@@ -6745,7 +6749,7 @@ function TimePicker({
6745
6749
  },
6746
6750
  children: [
6747
6751
  /* @__PURE__ */ jsx14(
6748
- Button,
6752
+ TimePickerIconButton,
6749
6753
  {
6750
6754
  type: "button",
6751
6755
  variant: "text",
@@ -6817,7 +6821,7 @@ function TimePicker({
6817
6821
  }
6818
6822
  ),
6819
6823
  /* @__PURE__ */ jsx14(
6820
- Button,
6824
+ TimePickerIconButton,
6821
6825
  {
6822
6826
  type: "button",
6823
6827
  variant: "text",
@@ -9157,7 +9161,7 @@ import { useController as useController3 } from "react-hook-form";
9157
9161
  // src/components/RichEditor/RichEditor.tsx
9158
9162
  import { lazy, useEffect as useEffect6, useState as useState7, Suspense } from "react";
9159
9163
  import { jsx as jsx46 } from "react/jsx-runtime";
9160
- var QuillComponent = lazy(() => import("./QuillComponent-A5KIFPCL.mjs"));
9164
+ var QuillComponent = lazy(() => import("./QuillComponent-TLIZCM6V.mjs"));
9161
9165
  var RichEditor = (props) => {
9162
9166
  const [isClient, setIsClient] = useState7(false);
9163
9167
  useEffect6(() => {
@@ -9169,20 +9173,23 @@ var RichEditor = (props) => {
9169
9173
  var RichEditor_default = RichEditor;
9170
9174
 
9171
9175
  // src/components/FormFields/RichEditorFormField.tsx
9172
- import { jsx as jsx47, jsxs as jsxs24 } from "react/jsx-runtime";
9176
+ import { useState as useState8 } from "react";
9177
+ import { Fragment as Fragment5, jsx as jsx47, jsxs as jsxs24 } from "react/jsx-runtime";
9173
9178
  var RichEditorFormField = (_a) => {
9174
9179
  var _b = _a, {
9175
9180
  name,
9176
9181
  label,
9177
9182
  required,
9178
9183
  validate,
9179
- validationErrorMessage = "Este campo \xE9 obrigat\xF3rio."
9184
+ validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
9185
+ maxLength
9180
9186
  } = _b, props = __objRest(_b, [
9181
9187
  "name",
9182
9188
  "label",
9183
9189
  "required",
9184
9190
  "validate",
9185
- "validationErrorMessage"
9191
+ "validationErrorMessage",
9192
+ "maxLength"
9186
9193
  ]);
9187
9194
  const { field, fieldState } = useController3({
9188
9195
  name,
@@ -9197,11 +9204,28 @@ var RichEditorFormField = (_a) => {
9197
9204
  },
9198
9205
  defaultValue: ""
9199
9206
  });
9207
+ const [caracterQuantity, setCaracterQuantity] = useState8(maxLength);
9208
+ const handleCharacterCountChange = (count) => {
9209
+ if (maxLength !== void 0) {
9210
+ setCaracterQuantity(Math.max(0, maxLength - count));
9211
+ }
9212
+ };
9200
9213
  const fieldError = fieldState.error;
9201
9214
  const haveError = !!fieldError;
9202
9215
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
9203
9216
  return /* @__PURE__ */ jsxs24(Flex, { direction: "column", children: [
9204
- label && /* @__PURE__ */ jsx47(
9217
+ maxLength ? /* @__PURE__ */ jsxs24(Flex, { direction: "row", justify: "between", children: [
9218
+ label && /* @__PURE__ */ jsx47(
9219
+ FormLabel,
9220
+ {
9221
+ name,
9222
+ label,
9223
+ required,
9224
+ haveError
9225
+ }
9226
+ ),
9227
+ /* @__PURE__ */ jsx47(Badge, { color: "grey", size: "xs", children: caracterQuantity })
9228
+ ] }) : /* @__PURE__ */ jsx47(Fragment5, { children: label && /* @__PURE__ */ jsx47(
9205
9229
  FormLabel,
9206
9230
  {
9207
9231
  name,
@@ -9209,13 +9233,15 @@ var RichEditorFormField = (_a) => {
9209
9233
  required,
9210
9234
  haveError
9211
9235
  }
9212
- ),
9236
+ ) }),
9213
9237
  /* @__PURE__ */ jsx47(
9214
9238
  RichEditor_default,
9215
9239
  __spreadProps(__spreadValues({}, props), {
9216
9240
  value: field.value,
9217
9241
  onChange: field.onChange,
9218
- "aria-labelledby": `${name}-label`
9242
+ "aria-labelledby": `${name}-label`,
9243
+ onCharacterCountChange: handleCharacterCountChange,
9244
+ maxLength
9219
9245
  })
9220
9246
  ),
9221
9247
  /* @__PURE__ */ jsx47(ErrorFormMessage, { message: errorMsg })
@@ -9370,11 +9396,11 @@ var TimePickerFormField = (_a) => {
9370
9396
  };
9371
9397
 
9372
9398
  // src/hooks/useImageUpload.ts
9373
- import { useState as useState8, useCallback as useCallback6 } from "react";
9399
+ import { useState as useState9, useCallback as useCallback6 } from "react";
9374
9400
  var useImageUpload = (options) => {
9375
- const [isUploading, setIsUploading] = useState8(false);
9376
- const [progress, setProgress] = useState8(null);
9377
- const [error, setError] = useState8(null);
9401
+ const [isUploading, setIsUploading] = useState9(false);
9402
+ const [progress, setProgress] = useState9(null);
9403
+ const [error, setError] = useState9(null);
9378
9404
  const {
9379
9405
  onSuccess,
9380
9406
  onError,
@@ -9556,6 +9582,7 @@ export {
9556
9582
  TimePickerDropdownStyled,
9557
9583
  TimePickerFooterStyled,
9558
9584
  TimePickerFormField,
9585
+ TimePickerIconButton,
9559
9586
  TimePickerStyled,
9560
9587
  TimerPickerContentStyled,
9561
9588
  ToastItem,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "12.1.5",
3
+ "version": "12.1.7",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -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
- {label && (
51
- <FormLabel
52
- name={name}
53
- label={label}
54
- required={required}
55
- haveError={haveError}
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
- interface QuillComponentProps extends RichEditorProps {
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
- 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
- ];
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",
@@ -103,6 +114,7 @@ const QuillComponent: React.FC<QuillComponentProps> = ({
103
114
 
104
115
  useEffect(() => {
105
116
  if (quill && value) {
117
+ console.log('entrou no quill && value')
106
118
  const currentContent = quill.root.innerHTML;
107
119
  if (currentContent !== value) {
108
120
  const selection = quill.getSelection();
@@ -121,8 +133,16 @@ const QuillComponent: React.FC<QuillComponentProps> = ({
121
133
  if (quill) {
122
134
  quill.on("text-change", (delta: any, oldDelta: any, source: string) => {
123
135
  if (source === "user") {
124
- const html = quill.root.innerHTML;
125
- onChange?.(html);
136
+ const text = quill.getText().trim();
137
+ const count = text.length;
138
+ console.log('entrou no quill && user', maxLength !== undefined, count, maxLength, 'count > maxLength')
139
+
140
+ if (maxLength !== undefined && count > maxLength) {
141
+ quill.deleteText(maxLength, count - maxLength);
142
+ return;
143
+ }
144
+ onChange?.(quill.root.innerHTML);
145
+ onCharacterCountChange?.(count);
126
146
  }
127
147
  });
128
148
 
@@ -167,7 +187,7 @@ const QuillComponent: React.FC<QuillComponentProps> = ({
167
187
  }
168
188
  }, 2000);
169
189
  }
170
- }, [quill, onChange, handleImageUpload]);
190
+ }, [quill, onChange, handleImageUpload, onCharacterCountChange]);
171
191
 
172
192
  useEffect(() => {
173
193
  if (quill) {