@lets-events/react 12.1.2 → 12.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "12.1.2",
3
+ "version": "12.1.4",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -41,6 +41,7 @@
41
41
  "dotenv": "^17.2.1",
42
42
  "i18n-iso-countries": "^7.14.0",
43
43
  "npm": "^11.4.2",
44
+ "quill": "^2.0.3",
44
45
  "radix-ui": "^1.4.2",
45
46
  "react-day-picker": "^9.6.7",
46
47
  "react-hook-form": "^7.57.0",
@@ -1,5 +1,7 @@
1
+ import { lazy, useEffect, useState, Suspense } from "react";
1
2
  import { ToastProvider } from "../Toast";
2
- import QuillComponent from "./QuillComponent";
3
+
4
+ const QuillComponent = lazy(() => import("./QuillComponent"));
3
5
 
4
6
  export interface UploadConfig {
5
7
  apiUrl: string;
@@ -19,20 +21,29 @@ export interface RichEditorProps {
19
21
  onChange?: (value: string) => void;
20
22
  placeholder?: string;
21
23
  label?: string;
22
- required?: boolean;
23
24
  disabled?: boolean;
24
25
  className?: string;
25
26
  uploadConfig: UploadConfig;
26
27
  }
27
28
 
28
29
  const RichEditor = (props: RichEditorProps) => {
30
+ const [isClient, setIsClient] = useState(false);
31
+
32
+ useEffect(() => {
33
+ setIsClient(typeof window !== "undefined");
34
+ }, []);
35
+
36
+ if (!isClient) return null;
37
+
29
38
  return (
30
39
  <div>
31
40
  <ToastProvider>
32
- <QuillComponent {...props} />
41
+ <Suspense fallback={null}>
42
+ <QuillComponent {...props} />
43
+ </Suspense>
33
44
  </ToastProvider>
34
45
  </div>
35
46
  );
36
47
  };
37
48
 
38
- export default RichEditor;
49
+ export default RichEditor;
@@ -1,7 +1,6 @@
1
- import { TextArea as TextAreaRadix, Flex, Box } from "@radix-ui/themes";
1
+ import { TextArea as TextAreaRadix } from "@radix-ui/themes";
2
2
  import { styled } from "../styles";
3
- import React, { ComponentProps, useRef } from "react";
4
-
3
+ import React, { ComponentProps, useRef, useState, useEffect } from "react";
5
4
  import { typographyValues } from "../types/typographyValues";
6
5
  import { Text } from "./Text";
7
6
 
@@ -59,12 +58,6 @@ const TextareaContainer = styled("div", {
59
58
  },
60
59
  });
61
60
 
62
- export type TextareaFieldProps = Omit<
63
- ComponentProps<typeof TextareaFieldStyle>,
64
- "color"
65
- > &
66
- ComponentProps<typeof TextareaContainer>;
67
-
68
61
  const TextareaLimitIndicator = styled("div", {
69
62
  padding: "$12 $16",
70
63
  borderTop: "1px solid $neutral300",
@@ -80,21 +73,29 @@ const TextareaLimitIndicator = styled("div", {
80
73
  },
81
74
  });
82
75
 
76
+ export type TextareaFieldProps = Omit<
77
+ ComponentProps<typeof TextareaFieldStyle>,
78
+ "color"
79
+ > &
80
+ ComponentProps<typeof TextareaContainer>;
81
+
83
82
  export const TextareaField = React.forwardRef<
84
83
  HTMLTextAreaElement,
85
84
  TextareaFieldProps
86
- >(({ maxLength, color, ...props }, fowardedRef) => {
85
+ >(({ maxLength, color, ...props }, forwardedRef) => {
87
86
  const inputRef = useRef<HTMLTextAreaElement>(null);
88
- const badgeRef = useRef<HTMLSpanElement>(null);
87
+ const [remaining, setRemaining] = useState(maxLength);
89
88
 
90
- const updateCharCountBadge = () => {
91
- if (!maxLength || !badgeRef.current) return;
92
- const remainingChars = maxLength - (inputRef?.current?.value.length ?? 0);
93
- badgeRef.current.textContent = String(remainingChars);
94
- };
89
+ useEffect(() => {
90
+ if (maxLength && inputRef.current) {
91
+ setRemaining(maxLength - (inputRef.current.value.length ?? 0));
92
+ }
93
+ }, [maxLength]);
95
94
 
96
95
  const handleInput = (e: React.FormEvent<HTMLTextAreaElement>) => {
97
- updateCharCountBadge();
96
+ if (maxLength) {
97
+ setRemaining(maxLength - e.currentTarget.value.length);
98
+ }
98
99
  props.onInput?.(e);
99
100
  };
100
101
 
@@ -105,11 +106,9 @@ export const TextareaField = React.forwardRef<
105
106
  ref={(r) => {
106
107
  if (!r) return;
107
108
  inputRef.current = r;
108
- if (fowardedRef) {
109
- if (typeof fowardedRef === "function") fowardedRef(r);
110
- else {
111
- fowardedRef.current = r;
112
- }
109
+ if (forwardedRef) {
110
+ if (typeof forwardedRef === "function") forwardedRef(r);
111
+ else forwardedRef.current = r;
113
112
  }
114
113
  }}
115
114
  onInput={handleInput}
@@ -118,8 +117,8 @@ export const TextareaField = React.forwardRef<
118
117
  />
119
118
  {maxLength && (
120
119
  <TextareaLimitIndicator>
121
- <Text typography={"badgeMedium"} ref={badgeRef}>
122
- {maxLength}
120
+ <Text typography="badgeMedium">
121
+ {remaining}
123
122
  </Text>
124
123
  </TextareaLimitIndicator>
125
124
  )}