dynamic-modal 1.0.11 → 1.0.12

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.
Files changed (58) hide show
  1. package/.idea/dynamic-modal.iml +12 -0
  2. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  3. package/.idea/modules.xml +8 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/README-ES.md +119 -119
  6. package/README.md +119 -119
  7. package/dist/components/input-upload/input-upload.js +18 -8
  8. package/dist/components/make-autocomplete/make-autocomplete.js +24 -17
  9. package/dist/components/make-input/make-input.js +24 -17
  10. package/dist/components/make-multi-select/make-multi-select.js +24 -17
  11. package/dist/components/make-select/make-select.js +24 -17
  12. package/dist/components/make-textarea/make-textarea.js +23 -16
  13. package/dist/components/make-toggle/make-toggle.js +36 -14
  14. package/dist/components/make-upload/make-upload.js +20 -8
  15. package/dist/components/portal/portal.js +17 -7
  16. package/dist/interfaces/field.d.ts +7 -4
  17. package/dist/interfaces/input-upload.d.ts +1 -15
  18. package/dist/modal.js +17 -7
  19. package/eslint.config.mjs +13 -13
  20. package/examples/enable-if.ts +129 -129
  21. package/examples/live-data.ts +63 -63
  22. package/examples/render-if.ts +130 -130
  23. package/examples/simple.ts +76 -76
  24. package/index.ts +2 -2
  25. package/package.json +48 -48
  26. package/src/components/input-upload/input-upload.tsx +72 -72
  27. package/src/components/make-autocomplete/make-autocomplete.tsx +54 -53
  28. package/src/components/make-button/make-button.tsx +17 -17
  29. package/src/components/make-input/make-input.tsx +47 -46
  30. package/src/components/make-multi-select/make-multi-select.tsx +56 -55
  31. package/src/components/make-select/make-select.tsx +54 -53
  32. package/src/components/make-text/make-text.tsx +16 -16
  33. package/src/components/make-textarea/make-textarea.tsx +48 -47
  34. package/src/components/make-title/make-title.tsx +12 -12
  35. package/src/components/make-toggle/make-toggle.tsx +44 -44
  36. package/src/components/make-upload/make-upload.tsx +34 -41
  37. package/src/components/portal/portal.tsx +36 -36
  38. package/src/hooks/field-render.ts +108 -108
  39. package/src/hooks/modal-handler.ts +37 -37
  40. package/src/interfaces/field.ts +35 -31
  41. package/src/interfaces/input-upload.ts +21 -37
  42. package/src/interfaces/make-autocomplete.ts +13 -13
  43. package/src/interfaces/make-button.ts +20 -20
  44. package/src/interfaces/make-field-group.ts +13 -13
  45. package/src/interfaces/make-field.ts +14 -14
  46. package/src/interfaces/make-multi-select.ts +14 -14
  47. package/src/interfaces/make-select.ts +12 -12
  48. package/src/interfaces/make-text.ts +12 -12
  49. package/src/interfaces/make-textarea.ts +11 -11
  50. package/src/interfaces/make-title.ts +3 -3
  51. package/src/interfaces/make-toggle.ts +9 -9
  52. package/src/interfaces/make-upload.ts +14 -14
  53. package/src/interfaces/modal.ts +51 -51
  54. package/src/interfaces/option.ts +3 -3
  55. package/src/interfaces/portal.ts +8 -8
  56. package/src/modal.tsx +174 -174
  57. package/src/tools/general.ts +6 -6
  58. package/tsconfig.json +13 -13
@@ -1,55 +1,56 @@
1
- import React, { FC, useEffect } from 'react'
2
- import { Controller } from 'react-hook-form'
3
- import { useFieldRender } from '../../hooks/field-render'
4
- import { generateId } from '../../tools/general'
5
- import { IMakeMultiSelectProps } from '../../interfaces/make-multi-select'
6
- import { Select, SelectItem } from '@nextui-org/react'
7
-
8
- const MakeMultiSelect: FC<IMakeMultiSelectProps> = ({ element, ...props }) => {
9
- const { render, enable, checkField, liveData, liveSearching } = useFieldRender({ element, ...props })
10
-
11
- useEffect(() => {
12
- const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
- return () => subscription.unsubscribe()
14
- }, [checkField, props, props.watch])
15
-
16
- return (
17
- render
18
- ? <Controller
19
- control={props.control}
20
- name={element.name}
21
- rules={{
22
- required: element.validation.required,
23
- pattern: {
24
- value: element.validation.regex as RegExp ?? /(.*)/,
25
- message: element.validation.message ?? ''
26
- }
27
- }}
28
- render={({ field: { onChange, value }, fieldState: { invalid } }) => (
29
- <Select
30
- size='sm'
31
- {...element}
32
- id={element.id ?? generateId()}
33
- onSelectionChange={onChange}
34
- label={liveSearching ? 'Loading...' : element.label}
35
- selectionMode="multiple"
36
- selectedKeys={value}
37
- color={invalid ? 'danger' : undefined}
38
- isInvalid={invalid}
39
- errorMessage={invalid ? (element.validation.message ?? '') : undefined}
40
- disabled={element.disabled ?? !enable}
41
- className='max-w-lg'
42
- >
43
- {
44
- (liveData || (element.options ?? [])).map((opt) => (
45
- <SelectItem key={opt.id} value={opt.id}>{opt.name}</SelectItem>
46
- ))
47
- }
48
- </Select>
49
- )}
50
- />
51
- : null
52
- )
53
- }
54
-
55
- export default MakeMultiSelect
1
+ import React, { FC, useEffect } from 'react'
2
+ import { Controller } from 'react-hook-form'
3
+ import { useFieldRender } from '../../hooks/field-render'
4
+ import { generateId } from '../../tools/general'
5
+ import { IMakeMultiSelectProps } from '../../interfaces/make-multi-select'
6
+ import { Select, SelectItem } from '@nextui-org/react'
7
+
8
+ const MakeMultiSelect: FC<IMakeMultiSelectProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
9
+ const { render, enable, checkField, liveData, liveSearching } = useFieldRender({ ...props, element })
10
+
11
+ useEffect(() => {
12
+ const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
+ return () => subscription.unsubscribe()
14
+ }, [checkField, props, props.watch])
15
+
16
+ return (
17
+ render
18
+ ? <Controller
19
+ control={props.control}
20
+ name={element.name}
21
+ rules={{
22
+ required,
23
+ pattern: {
24
+ value: validation.regex as RegExp ?? /(.*)/,
25
+ message: validation.message ?? ''
26
+ },
27
+ ...validation
28
+ }}
29
+ render={({ field: { onChange, value }, fieldState: { invalid } }) => (
30
+ <Select
31
+ size='sm'
32
+ {...element}
33
+ id={element.id ?? generateId()}
34
+ onSelectionChange={onChange}
35
+ label={liveSearching ? 'Loading...' : element.label}
36
+ selectionMode="multiple"
37
+ selectedKeys={value}
38
+ color={invalid ? 'danger' : undefined}
39
+ isInvalid={invalid}
40
+ errorMessage={invalid ? (validation.message ?? '') : undefined}
41
+ disabled={element.disabled ?? !enable}
42
+ className='max-w-lg'
43
+ >
44
+ {
45
+ (liveData || (element.options ?? [])).map((opt) => (
46
+ <SelectItem key={opt.id} value={opt.id}>{opt.name}</SelectItem>
47
+ ))
48
+ }
49
+ </Select>
50
+ )}
51
+ />
52
+ : null
53
+ )
54
+ }
55
+
56
+ export default MakeMultiSelect
@@ -1,53 +1,54 @@
1
- import React, { FC, useEffect } from 'react'
2
- import { Controller } from 'react-hook-form'
3
- import { useFieldRender } from '../../hooks/field-render'
4
- import { generateId } from '../../tools/general'
5
- import { IMakeSelectProps } from '../../interfaces/make-select'
6
- import { Select, SelectItem } from '@nextui-org/react'
7
-
8
- const MakeSelect: FC<IMakeSelectProps> = ({ element, ...props }) => {
9
- const { render, enable, checkField, liveData, liveSearching } = useFieldRender({ element, ...props })
10
-
11
- useEffect(() => {
12
- const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
- return () => subscription.unsubscribe()
14
- }, [checkField, props, props.watch])
15
-
16
- return (
17
- render
18
- ? <Controller
19
- control={props.control}
20
- name={element.name}
21
- rules={{
22
- required: element.validation.required,
23
- pattern: {
24
- value: element.validation.regex as RegExp ?? /(.*)/,
25
- message: element.validation.message ?? ''
26
- }
27
- }}
28
- render={({ field: { onChange, value }, fieldState: { invalid } }) => (
29
- <Select
30
- size='sm'
31
- {...element}
32
- id={element.id ?? generateId()}
33
- onChange={onChange}
34
- label={liveSearching ? 'Loading...' : element.label}
35
- selectedKeys={[value]}
36
- color={invalid ? 'danger' : undefined}
37
- isInvalid={invalid}
38
- errorMessage={invalid ? (element.validation.message ?? '') : undefined}
39
- disabled={element.disabled ?? !enable}
40
- >
41
- {
42
- (liveData || (element.options ?? [])).map((opt) => (
43
- <SelectItem key={opt.id} value={opt.id}>{opt.name}</SelectItem>
44
- ))
45
- }
46
- </Select>
47
- )}
48
- />
49
- : <></>
50
- )
51
- }
52
-
53
- export default MakeSelect
1
+ import React, { FC, useEffect } from 'react'
2
+ import { Controller } from 'react-hook-form'
3
+ import { useFieldRender } from '../../hooks/field-render'
4
+ import { generateId } from '../../tools/general'
5
+ import { IMakeSelectProps } from '../../interfaces/make-select'
6
+ import { Select, SelectItem } from '@nextui-org/react'
7
+
8
+ const MakeSelect: FC<IMakeSelectProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
9
+ const { render, enable, checkField, liveData, liveSearching } = useFieldRender({ ...props, element })
10
+
11
+ useEffect(() => {
12
+ const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
+ return () => subscription.unsubscribe()
14
+ }, [checkField, props, props.watch])
15
+
16
+ return (
17
+ render
18
+ ? <Controller
19
+ control={props.control}
20
+ name={element.name}
21
+ rules={{
22
+ required,
23
+ pattern: {
24
+ value: validation.regex as RegExp ?? /(.*)/,
25
+ message: validation.message ?? ''
26
+ },
27
+ ...validation
28
+ }}
29
+ render={({ field: { onChange, value }, fieldState: { invalid } }) => (
30
+ <Select
31
+ size='sm'
32
+ {...element}
33
+ id={element.id ?? generateId()}
34
+ onChange={onChange}
35
+ label={liveSearching ? 'Loading...' : element.label}
36
+ selectedKeys={[value]}
37
+ color={invalid ? 'danger' : undefined}
38
+ isInvalid={invalid}
39
+ errorMessage={invalid ? (validation.message ?? '') : undefined}
40
+ disabled={element.disabled ?? !enable}
41
+ >
42
+ {
43
+ (liveData || (element.options ?? [])).map((opt) => (
44
+ <SelectItem key={opt.id} value={opt.id}>{opt.name}</SelectItem>
45
+ ))
46
+ }
47
+ </Select>
48
+ )}
49
+ />
50
+ : <></>
51
+ )
52
+ }
53
+
54
+ export default MakeSelect
@@ -1,16 +1,16 @@
1
- import React, { FC } from 'react'
2
- import { IMakeTextProps } from '../../interfaces/make-text'
3
-
4
- const MakeText: FC<IMakeTextProps> = ({
5
- element
6
- }) => {
7
- return (
8
- <div className='text-xs text-center'>
9
- <p style={element.styles}>
10
- {element.text}
11
- </p>
12
- </div>
13
- )
14
- }
15
-
16
- export default MakeText
1
+ import React, { FC } from 'react'
2
+ import { IMakeTextProps } from '../../interfaces/make-text'
3
+
4
+ const MakeText: FC<IMakeTextProps> = ({
5
+ element
6
+ }) => {
7
+ return (
8
+ <div className='text-xs text-center'>
9
+ <p style={element.styles}>
10
+ {element.text}
11
+ </p>
12
+ </div>
13
+ )
14
+ }
15
+
16
+ export default MakeText
@@ -1,47 +1,48 @@
1
- import React, { FC, useEffect } from 'react'
2
- import { Controller } from 'react-hook-form'
3
- import { useFieldRender } from '../../hooks/field-render'
4
- import { generateId } from '../../tools/general'
5
- import { IMakeTextareaProps } from '../../interfaces/make-textarea'
6
- import { Textarea } from '@nextui-org/react'
7
-
8
- const MakeTextarea: FC<IMakeTextareaProps> = ({ element, ...props }) => {
9
- const { render, enable, checkField } = useFieldRender({ ...props, element })
10
-
11
- useEffect(() => {
12
- const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
- return () => subscription.unsubscribe()
14
- }, [checkField, props, props.watch])
15
-
16
- return (
17
- render
18
- ? <Controller
19
- name={element.name}
20
- control={props.control}
21
- rules={{
22
- required: element.validation.required,
23
- pattern: {
24
- value: element.validation.regex as RegExp ?? /(.*)/,
25
- message: element.validation.message ?? ''
26
- }
27
- }}
28
- render={({ field: { onChange, value }, fieldState: { invalid } }) => (
29
- <Textarea
30
- {...element}
31
- disableAutosize
32
- id={element.id ?? generateId()}
33
- onChange={onChange}
34
- label={element.label}
35
- value={value ?? ''}
36
- color={invalid ? 'danger' : undefined}
37
- isInvalid={invalid}
38
- errorMessage={invalid ? (element.validation.message ?? '') : undefined}
39
- disabled={element.disabled ?? !enable}
40
- />
41
- )}
42
- />
43
- : null
44
- )
45
- }
46
-
47
- export default MakeTextarea
1
+ import React, { FC, useEffect } from 'react'
2
+ import { Controller } from 'react-hook-form'
3
+ import { useFieldRender } from '../../hooks/field-render'
4
+ import { generateId } from '../../tools/general'
5
+ import { IMakeTextareaProps } from '../../interfaces/make-textarea'
6
+ import { Textarea } from '@nextui-org/react'
7
+
8
+ const MakeTextarea: FC<IMakeTextareaProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
9
+ const { render, enable, checkField } = useFieldRender({ ...props, element })
10
+
11
+ useEffect(() => {
12
+ const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
+ return () => subscription.unsubscribe()
14
+ }, [checkField, props, props.watch])
15
+
16
+ return (
17
+ render
18
+ ? <Controller
19
+ name={element.name}
20
+ control={props.control}
21
+ rules={{
22
+ required,
23
+ pattern: {
24
+ value: validation.regex as RegExp ?? /(.*)/,
25
+ message: validation.message ?? ''
26
+ },
27
+ ...validation
28
+ }}
29
+ render={({ field: { onChange, value }, fieldState: { invalid } }) => (
30
+ <Textarea
31
+ {...element}
32
+ disableAutosize
33
+ id={element.id ?? generateId()}
34
+ onChange={onChange}
35
+ label={element.label}
36
+ value={value ?? ''}
37
+ color={invalid ? 'danger' : undefined}
38
+ isInvalid={invalid}
39
+ errorMessage={invalid ? (validation.message ?? '') : undefined}
40
+ disabled={element.disabled ?? !enable}
41
+ />
42
+ )}
43
+ />
44
+ : null
45
+ )
46
+ }
47
+
48
+ export default MakeTextarea
@@ -1,12 +1,12 @@
1
- import React, { FC } from 'react'
2
- import { IMakeTitle } from '../../interfaces/make-title'
3
-
4
- const MakeTitle: FC<IMakeTitle> = ({ title }) => {
5
- return (
6
- <div className='flex text-center items-center justify-center text-xl'>
7
- {title}
8
- </div>
9
- )
10
- }
11
-
12
- export default MakeTitle
1
+ import React, { FC } from 'react'
2
+ import { IMakeTitle } from '../../interfaces/make-title'
3
+
4
+ const MakeTitle: FC<IMakeTitle> = ({ title }) => {
5
+ return (
6
+ <div className='flex text-center items-center justify-center text-xl'>
7
+ {title}
8
+ </div>
9
+ )
10
+ }
11
+
12
+ export default MakeTitle
@@ -1,44 +1,44 @@
1
- import React, { FC, useEffect } from 'react'
2
- import { Controller } from 'react-hook-form'
3
- import { useFieldRender } from '../../hooks/field-render'
4
- import { IMakeToggleProps } from '../../interfaces/make-toggle'
5
- import { Switch } from '@nextui-org/react'
6
- import { generateId } from '../../tools/general'
7
-
8
- const MakeToggle: FC<IMakeToggleProps> = (props) => {
9
- const { render, enable, checkField } = useFieldRender(props)
10
-
11
- useEffect(() => {
12
- const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
- return () => subscription.unsubscribe()
14
- }, [checkField, props, props.watch])
15
-
16
- return (
17
- render
18
- ? <Controller
19
- control={props.control}
20
- name={props.element.name}
21
- rules={{
22
- required: props.element.validation.required,
23
- pattern: {
24
- value: props.element.validation.regex as RegExp ?? /(.*)/,
25
- message: props.element.validation.message ?? ''
26
- }
27
- }}
28
- render={({ field: { onChange, value } }) => (
29
- <Switch
30
- {...props.element}
31
- id={props.element.id ?? generateId()}
32
- isSelected={value}
33
- onValueChange={onChange}
34
- isDisabled={props.element.disabled ?? !enable}
35
- >
36
- {props.element.label}
37
- </Switch>
38
- )}
39
- />
40
- : null
41
- )
42
- }
43
-
44
- export default MakeToggle
1
+ import React, { FC, useEffect } from 'react'
2
+ import { Controller } from 'react-hook-form'
3
+ import { useFieldRender } from '../../hooks/field-render'
4
+ import { IMakeToggleProps } from '../../interfaces/make-toggle'
5
+ import { Switch } from '@nextui-org/react'
6
+ import { generateId } from '../../tools/general'
7
+
8
+ const MakeToggle: FC<IMakeToggleProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
9
+ const { render, enable, checkField } = useFieldRender({ ...props, element })
10
+
11
+ useEffect(() => {
12
+ const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
+ return () => subscription.unsubscribe()
14
+ }, [checkField, props, props.watch])
15
+
16
+ return (
17
+ render
18
+ ? <Controller
19
+ control={props.control}
20
+ name={element.name}
21
+ rules={{
22
+ required,
23
+ pattern: {
24
+ value: validation.regex as RegExp ?? /(.*)/,
25
+ message: validation.message ?? ''
26
+ }
27
+ }}
28
+ render={({ field: { onChange, value } }) => (
29
+ <Switch
30
+ {...element}
31
+ id={element.id ?? generateId()}
32
+ isSelected={value}
33
+ onValueChange={onChange}
34
+ isDisabled={element.disabled ?? !enable}
35
+ >
36
+ {element.label}
37
+ </Switch>
38
+ )}
39
+ />
40
+ : null
41
+ )
42
+ }
43
+
44
+ export default MakeToggle
@@ -1,41 +1,34 @@
1
- import React,{ FC } from 'react'
2
- import { Controller } from 'react-hook-form'
3
- import InputUpload from '../input-upload/input-upload'
4
- import { useFieldRender } from '../../hooks/field-render'
5
- import { IMakeUploadProps } from '../../interfaces/make-upload'
6
-
7
- const MakeUpload : FC<IMakeUploadProps> = (props) => {
8
- const { render, enable } = useFieldRender(props)
9
-
10
- return (
11
- render
12
- ? <Controller
13
- control={props.control}
14
- name={props.element.name}
15
- rules={{
16
- required: props.element.validation.required,
17
- pattern: {
18
- value: props.element.validation.regex as RegExp ?? /(.*)/,
19
- message: props.element.validation.message ?? ''
20
- }
21
- }}
22
- render={({ field: { onChange } }) => (
23
- <InputUpload
24
- id={props.element.id}
25
- name={props.element.name}
26
- disabled={props.element.disabled ?? !enable}
27
- onChange={onChange}
28
- label={props.element.label}
29
- helpText={props.element.helpText}
30
- style={props.element.styles}
31
- accept={props.element.accept}
32
- read={props.element.read}
33
- readAsArrayBuffer={props.element.readAsArrayBuffer}
34
- />
35
- )}
36
- />
37
- : null
38
- )
39
- }
40
-
41
- export default MakeUpload
1
+ import React,{ FC } from 'react'
2
+ import { Controller } from 'react-hook-form'
3
+ import InputUpload from '../input-upload/input-upload'
4
+ import { useFieldRender } from '../../hooks/field-render'
5
+ import { IMakeUploadProps } from '../../interfaces/make-upload'
6
+
7
+ const MakeUpload : FC<IMakeUploadProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
8
+ const { render, enable } = useFieldRender({ ...props, element })
9
+
10
+ return (
11
+ render
12
+ ? <Controller
13
+ control={props.control}
14
+ name={element.name}
15
+ rules={{
16
+ required,
17
+ pattern: {
18
+ value: validation.regex as RegExp ?? /(.*)/,
19
+ message: validation.message ?? ''
20
+ }
21
+ }}
22
+ render={({ field: { onChange } }) => (
23
+ <InputUpload
24
+ {...element}
25
+ disabled={element.disabled ?? !enable}
26
+ onChange={onChange}
27
+ />
28
+ )}
29
+ />
30
+ : null
31
+ )
32
+ }
33
+
34
+ export default MakeUpload
@@ -1,36 +1,36 @@
1
- 'use client'
2
- import React, { useRef, useEffect, useState, FC } from 'react'
3
- import { createPortal } from 'react-dom'
4
- import { IPortal } from '../../interfaces/portal'
5
-
6
- export const Portal: FC<IPortal> = (props) => {
7
- const ref = useRef<Element | null>(null)
8
- const [mounted, setMounted] = useState(false)
9
-
10
- useEffect(() => {
11
- if (mounted && !props.portalOpen && props.closeTime > 0) {
12
- const timeoutId = setTimeout(() => {
13
- setMounted(false)
14
- ref.current = null
15
- }, props.closeTime)
16
-
17
- return () => clearTimeout(timeoutId)
18
- } else if (mounted && !props.portalOpen) {
19
- setMounted(false)
20
- ref.current = null
21
- } else if (!mounted && props.portalOpen) {
22
- ref.current = document.querySelector<HTMLElement>(props.portalTag ?? '#portal')
23
- setMounted(true)
24
- }
25
- }, [mounted, props.closeTime, props.portalOpen, props.portalTag])
26
-
27
- return (
28
- mounted && ref.current
29
- ? createPortal(
30
- <div className='transition-all delay-100 fixed top-0 left-0 w-full h-full grid place-items-center bg-black bg-opacity-40 z-20'>
31
- {props.children}
32
- </div>
33
- , ref.current)
34
- : null
35
- )
36
- }
1
+ 'use client'
2
+ import React, { useRef, useEffect, useState, FC } from 'react'
3
+ import { createPortal } from 'react-dom'
4
+ import { IPortal } from '../../interfaces/portal'
5
+
6
+ export const Portal: FC<IPortal> = (props) => {
7
+ const ref = useRef<Element | null>(null)
8
+ const [mounted, setMounted] = useState(false)
9
+
10
+ useEffect(() => {
11
+ if (mounted && !props.portalOpen && props.closeTime > 0) {
12
+ const timeoutId = setTimeout(() => {
13
+ setMounted(false)
14
+ ref.current = null
15
+ }, props.closeTime)
16
+
17
+ return () => clearTimeout(timeoutId)
18
+ } else if (mounted && !props.portalOpen) {
19
+ setMounted(false)
20
+ ref.current = null
21
+ } else if (!mounted && props.portalOpen) {
22
+ ref.current = document.querySelector<HTMLElement>(props.portalTag ?? '#portal')
23
+ setMounted(true)
24
+ }
25
+ }, [mounted, props.closeTime, props.portalOpen, props.portalTag])
26
+
27
+ return (
28
+ mounted && ref.current
29
+ ? createPortal(
30
+ <div className='transition-all delay-100 fixed top-0 left-0 w-full h-full grid place-items-center bg-black bg-opacity-40 z-20'>
31
+ {props.children}
32
+ </div>
33
+ , ref.current)
34
+ : null
35
+ )
36
+ }