@lets-events/react 12.1.3 → 12.1.5

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.3",
3
+ "version": "12.1.5",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -0,0 +1,46 @@
1
+ import { useFormContext, Controller } from "react-hook-form";
2
+ import { Flex } from "../Flex";
3
+ import { Switch } from "../Switch";
4
+ import { Text } from "../Text";
5
+
6
+
7
+ export type SwitchFormFieldProps = {
8
+ name: string;
9
+ label: string;
10
+ defaultValue?: boolean;
11
+ watch?: boolean;
12
+ };
13
+
14
+ export const SwitchFormField = ({
15
+ name,
16
+ label,
17
+ defaultValue = false,
18
+ watch = false,
19
+ }: SwitchFormFieldProps) => {
20
+ const {
21
+ control,
22
+ watch: watchForm,
23
+ } = useFormContext();
24
+
25
+ if (watch) {
26
+ watchForm(name);
27
+ }
28
+ return (
29
+ <Flex justify="between" style={{ margin: '1rem 0' }}>
30
+ <Text typography="labelMedium" fontWeight="regular">
31
+ {label}
32
+ </Text>
33
+ <Controller
34
+ control={control}
35
+ name={name}
36
+ defaultValue={defaultValue}
37
+ render={({ field }) => (
38
+ <Switch
39
+ checked={field.value}
40
+ onCheckedChange={field.onChange}
41
+ />
42
+ )}
43
+ />
44
+ </Flex>
45
+ );
46
+ };
@@ -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;
@@ -25,13 +27,23 @@ export interface RichEditorProps {
25
27
  }
26
28
 
27
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
+
28
38
  return (
29
39
  <div>
30
40
  <ToastProvider>
31
- <QuillComponent {...props} />
41
+ <Suspense fallback={null}>
42
+ <QuillComponent {...props} />
43
+ </Suspense>
32
44
  </ToastProvider>
33
45
  </div>
34
46
  );
35
47
  };
36
48
 
37
- export default RichEditor;
49
+ export default RichEditor;
package/src/index.tsx CHANGED
@@ -52,6 +52,7 @@ export * from "./components/FormFields/RadioGroupFormField";
52
52
  export * from "./components/FormFields/CheckboxGroupFormField";
53
53
  export * from "./components/FormFields/AddressFormFields/CountryFormField";
54
54
  export * from "./components/FormFields/SelectFormField";
55
+ export * from "./components/FormFields/SwitchFormField";
55
56
  export * from "./components/FormFields/EmailFormField";
56
57
  export * from "./components/FormFields/RichEditorFormField";
57
58
  export * from "./components/FormFields/CalendarFormField";