dynamic-modal 1.0.12 → 1.1.1

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 (91) hide show
  1. package/README-ES.md +109 -11
  2. package/README.md +110 -13
  3. package/dist/components/input-upload/input-upload.js +8 -42
  4. package/dist/components/make-button/make-button.js +41 -18
  5. package/dist/components/make-description/make-description.d.ts +4 -0
  6. package/dist/components/make-description/make-description.js +13 -0
  7. package/dist/components/make-input/make-input.d.ts +1 -1
  8. package/dist/components/make-input/make-input.js +12 -6
  9. package/dist/components/make-select/make-select.js +12 -6
  10. package/dist/components/make-textarea/make-textarea.js +12 -6
  11. package/dist/components/make-toggle/make-toggle.js +12 -9
  12. package/dist/components/make-upload/make-upload.js +8 -7
  13. package/dist/context/component/component-state.d.ts +4 -0
  14. package/dist/context/component/component-state.js +45 -0
  15. package/dist/interfaces/component-state.d.ts +27 -0
  16. package/dist/interfaces/field.d.ts +3 -2
  17. package/dist/interfaces/input-upload.d.ts +1 -1
  18. package/dist/interfaces/make-button.d.ts +5 -6
  19. package/dist/interfaces/make-description.d.ts +12 -0
  20. package/dist/interfaces/make-field-group.d.ts +1 -0
  21. package/dist/interfaces/{make-field.d.ts → make-input.d.ts} +2 -2
  22. package/dist/interfaces/make-select.d.ts +3 -1
  23. package/dist/interfaces/make-textarea.d.ts +1 -1
  24. package/dist/interfaces/make-toggle.d.ts +1 -1
  25. package/dist/interfaces/make-upload.d.ts +1 -1
  26. package/dist/interfaces/modal.d.ts +14 -19
  27. package/dist/modal.js +42 -35
  28. package/dist/tools/general.js +1 -0
  29. package/examples/enable-if.ts +5 -7
  30. package/examples/live-data.ts +7 -9
  31. package/examples/render-if.ts +6 -8
  32. package/examples/simple.ts +6 -8
  33. package/index.ts +4 -2
  34. package/package.json +16 -17
  35. package/src/components/input-upload/input-upload.tsx +7 -12
  36. package/src/components/make-button/make-button.tsx +11 -10
  37. package/src/components/make-description/make-description.tsx +15 -0
  38. package/src/components/make-input/make-input.tsx +25 -19
  39. package/src/components/make-select/make-select.tsx +23 -22
  40. package/src/components/make-textarea/make-textarea.tsx +18 -13
  41. package/src/components/make-toggle/make-toggle.tsx +24 -15
  42. package/src/components/make-upload/make-upload.tsx +12 -6
  43. package/src/components/portal/portal.tsx +1 -0
  44. package/src/context/component/component-state.tsx +18 -0
  45. package/src/hooks/field-render.ts +1 -0
  46. package/src/hooks/modal-handler.ts +1 -0
  47. package/src/interfaces/component-state.ts +33 -0
  48. package/src/interfaces/field.ts +8 -7
  49. package/src/interfaces/input-upload.ts +11 -11
  50. package/src/interfaces/make-button.ts +10 -11
  51. package/src/interfaces/make-description.ts +14 -0
  52. package/src/interfaces/make-field-group.ts +5 -4
  53. package/src/interfaces/{make-field.ts → make-input.ts} +2 -2
  54. package/src/interfaces/make-select.ts +3 -1
  55. package/src/interfaces/make-textarea.ts +1 -1
  56. package/src/interfaces/make-toggle.ts +2 -2
  57. package/src/interfaces/make-upload.ts +7 -7
  58. package/src/interfaces/modal.ts +15 -21
  59. package/src/interfaces/option.ts +2 -2
  60. package/src/interfaces/portal.ts +4 -4
  61. package/src/modal.tsx +43 -53
  62. package/src/tools/general.ts +2 -0
  63. package/.idea/dynamic-modal.iml +0 -12
  64. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  65. package/.idea/modules.xml +0 -8
  66. package/.idea/vcs.xml +0 -6
  67. package/dist/components/make-autocomplete/make-autocomplete.d.ts +0 -4
  68. package/dist/components/make-autocomplete/make-autocomplete.js +0 -70
  69. package/dist/components/make-multi-select/make-multi-select.d.ts +0 -4
  70. package/dist/components/make-multi-select/make-multi-select.js +0 -70
  71. package/dist/components/make-text/make-text.d.ts +0 -4
  72. package/dist/components/make-text/make-text.js +0 -11
  73. package/dist/components/make-title/make-title.d.ts +0 -4
  74. package/dist/components/make-title/make-title.js +0 -10
  75. package/dist/interfaces/make-autocomplete.d.ts +0 -11
  76. package/dist/interfaces/make-multi-select.d.ts +0 -12
  77. package/dist/interfaces/make-text.d.ts +0 -10
  78. package/dist/interfaces/make-text.js +0 -2
  79. package/dist/interfaces/make-title.d.ts +0 -3
  80. package/dist/interfaces/make-title.js +0 -2
  81. package/src/components/make-autocomplete/make-autocomplete.tsx +0 -54
  82. package/src/components/make-multi-select/make-multi-select.tsx +0 -56
  83. package/src/components/make-text/make-text.tsx +0 -16
  84. package/src/components/make-title/make-title.tsx +0 -12
  85. package/src/interfaces/make-autocomplete.ts +0 -13
  86. package/src/interfaces/make-multi-select.ts +0 -14
  87. package/src/interfaces/make-text.ts +0 -12
  88. package/src/interfaces/make-title.ts +0 -3
  89. /package/dist/interfaces/{make-autocomplete.js → component-state.js} +0 -0
  90. /package/dist/interfaces/{make-field.js → make-description.js} +0 -0
  91. /package/dist/interfaces/{make-multi-select.js → make-input.js} +0 -0
@@ -1,6 +1,7 @@
1
- import React, { ChangeEvent, FC, useMemo } from 'react'
1
+ 'use client'
2
+
3
+ import React, { ChangeEvent, FC } from 'react'
2
4
  import { IFileResult, IInputUpload } from '../../interfaces/input-upload'
3
- import { generateId } from '../../tools/general'
4
5
 
5
6
  const InputUpload: FC<IInputUpload> = ({ onChange, readAsArrayBuffer, ...props }: IInputUpload) => {
6
7
 
@@ -39,30 +40,24 @@ const InputUpload: FC<IInputUpload> = ({ onChange, readAsArrayBuffer, ...props }
39
40
  })
40
41
  }
41
42
 
42
- const elementId = useMemo<string>(
43
- () => {
44
- return props.id ?? generateId()
45
- }, [props.id]
46
- )
47
-
48
43
  return (
49
44
  <div className='flex flex-col w-full gap-1 text-center'>
50
- {props.label && <label className="block mb-2 text-sm font-medium text-gray-900 dark:text-white" htmlFor={`file-input-${elementId}`}>{props.label}</label>}
45
+ {props.label && <label className="block mb-2 text-sm font-medium text-gray-900 dark:text-white" htmlFor={`file-input-${props.id}`}>{props.label}</label>}
51
46
  <input
52
47
  className="file:transition-all file:delay-150 block w-full text-sm text-slate-500
53
48
  file:mr-4 file:py-2 file:px-4 file:rounded-md
54
49
  file:border-0 file:text-sm file:font-semibold
55
50
  file:bg-gray-100 file:text-blue-600
56
51
  hover:file:bg-blue-700 hover:file:text-white cursor-pointer disabled:cursor-not-allowed"
57
- aria-describedby={`file-input-${elementId}-help`}
58
- id={`file-input-${elementId}`}
52
+ aria-describedby={`file-input-${props.id}-help`}
53
+ id={`file-input-${props.id}`}
59
54
  type="file"
60
55
  onChange={onChangeHandler}
61
56
  {...props}
62
57
  />
63
58
  <p
64
59
  className="mt-1 text-sm text-gray-500 dark:text-gray-300 text-start"
65
- id={`file-input-${elementId}-help`}>
60
+ id={`file-input-${props.id}-help`}>
66
61
  {props.helpText?.toUpperCase()}
67
62
  </p>
68
63
  </div>
@@ -1,16 +1,17 @@
1
- import React, { FC } from 'react'
1
+ 'use client'
2
+
3
+ import React, { FC, useContext, useMemo } from 'react'
2
4
  import { IMakeButtonProps } from '../../interfaces/make-button'
5
+ import { ComponentStateContext } from '../../context/component/component-state'
6
+ import { generateId } from '../../tools/general'
7
+
8
+ const MakeButton: FC<IMakeButtonProps> = ({ element }) => {
9
+ const { Button } = useContext(ComponentStateContext)
3
10
 
4
- const MakeButton: FC<IMakeButtonProps> = ({
5
- element: { text, ...element }
6
- }) => {
11
+ const elementId = useMemo(() => element.id ?? generateId(), [])
12
+
7
13
  return (
8
- <button
9
- className='transition-all delay-100 hover:translate-y-1 bg-blue-500 text-white hover:bg-blue-700 rounded w-11/12 h-[40px] p-2'
10
- {...element}
11
- >
12
- {text}
13
- </button>
14
+ <Button {...element} id={elementId} />
14
15
  )
15
16
  }
16
17
 
@@ -0,0 +1,15 @@
1
+ 'use client'
2
+
3
+ import React, { FC } from 'react'
4
+ import { IMakeDescriptionProps } from '../../interfaces/make-description'
5
+
6
+ const MakeDescription: FC<IMakeDescriptionProps> = ({ element: { text, Icon, containerStyle, textStyle } }) => {
7
+ return (
8
+ <div className='flex gap-4 w-full h-auto text-xs text-center p-2 border-1 rounded-md' style={containerStyle}>
9
+ {Icon && <Icon />}
10
+ <p style={textStyle}>{text}</p>
11
+ </div>
12
+ )
13
+ }
14
+
15
+ export default MakeDescription
@@ -1,13 +1,18 @@
1
- import React, { FC, useEffect } from 'react'
1
+ 'use client'
2
+
3
+ import React, { FC, useContext, useEffect, useMemo } from 'react'
2
4
  import { Controller } from 'react-hook-form'
3
5
  import { useFieldRender } from '../../hooks/field-render'
4
- import { IMakeInputProps } from '../../interfaces/make-field'
5
- import { Input } from '@nextui-org/react'
6
+ import { IMakeInputProps } from '../../interfaces/make-input'
7
+ import { ComponentStateContext } from '../../context/component/component-state'
6
8
  import { generateId } from '../../tools/general'
7
9
 
8
10
  const MakeInput: FC<IMakeInputProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
11
+ const { Input } = useContext(ComponentStateContext)
9
12
  const { render, enable, checkField } = useFieldRender({ ...props, element })
10
13
 
14
+ const elementId = useMemo(() => element.id ?? generateId(), [])
15
+
11
16
  useEffect(() => {
12
17
  const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
18
  return () => subscription.unsubscribe()
@@ -19,25 +24,26 @@ const MakeInput: FC<IMakeInputProps> = ({ element: { validation: { required, ...
19
24
  control={props.control}
20
25
  name={element.name}
21
26
  rules={{
22
- required,
23
- pattern: {
24
- value: validation.regex as RegExp ?? /(.*)/,
27
+ required: {
28
+ value: required,
25
29
  message: validation.message ?? ''
26
30
  },
27
- ...validation
31
+ pattern: validation.regex ? {
32
+ value: validation.regex,
33
+ message: validation.message ?? ''
34
+ } : undefined,
35
+ ...validation
28
36
  }}
29
- render={({ field: { onChange, value }, fieldState: { invalid } }) => (
30
- <Input
31
- size='sm'
32
- {...element}
33
- id={element.id ?? generateId()}
34
- onChange={onChange}
35
- value={value ?? ''}
36
- color={invalid ? 'danger' : undefined}
37
- isInvalid={invalid}
38
- errorMessage={invalid ? (validation.message ?? '') : undefined}
39
- disabled={element.disabled ?? !enable}
40
- />
37
+ render={({ field: { onChange, value }, fieldState: { invalid, error } }) => (
38
+ <Input
39
+ {...element}
40
+ id={elementId}
41
+ onChange={onChange}
42
+ value={value ?? ''}
43
+ invalid={invalid}
44
+ error={error}
45
+ disabled={element.disabled ?? !enable}
46
+ />
41
47
  )}
42
48
  />
43
49
  : null
@@ -1,13 +1,18 @@
1
- import React, { FC, useEffect } from 'react'
1
+ 'use client'
2
+
3
+ import React, { FC, useContext, useEffect, useMemo } from 'react'
2
4
  import { Controller } from 'react-hook-form'
3
5
  import { useFieldRender } from '../../hooks/field-render'
4
6
  import { generateId } from '../../tools/general'
5
7
  import { IMakeSelectProps } from '../../interfaces/make-select'
6
- import { Select, SelectItem } from '@nextui-org/react'
8
+ import { ComponentStateContext } from '../../context/component/component-state'
7
9
 
8
10
  const MakeSelect: FC<IMakeSelectProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
11
+ const { Select } = useContext(ComponentStateContext)
9
12
  const { render, enable, checkField, liveData, liveSearching } = useFieldRender({ ...props, element })
10
13
 
14
+ const elementId = useMemo(() => element.id ?? generateId(), [])
15
+
11
16
  useEffect(() => {
12
17
  const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
18
  return () => subscription.unsubscribe()
@@ -19,32 +24,28 @@ const MakeSelect: FC<IMakeSelectProps> = ({ element: { validation: { required, .
19
24
  control={props.control}
20
25
  name={element.name}
21
26
  rules={{
22
- required,
23
- pattern: {
24
- value: validation.regex as RegExp ?? /(.*)/,
27
+ required: {
28
+ value: required,
25
29
  message: validation.message ?? ''
26
30
  },
27
- ...validation
31
+ pattern: validation.regex ? {
32
+ value: validation.regex,
33
+ message: validation.message ?? ''
34
+ } : undefined,
35
+ ...validation
28
36
  }}
29
- render={({ field: { onChange, value }, fieldState: { invalid } }) => (
37
+ render={({ field: { onChange, value }, fieldState: { invalid, error } }) => (
30
38
  <Select
31
- size='sm'
32
39
  {...element}
33
- id={element.id ?? generateId()}
40
+ id={elementId}
34
41
  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>
42
+ value={value}
43
+ invalid={invalid}
44
+ error={error}
45
+ disabled={element.disabled ?? !enable}
46
+ liveSearching={liveSearching}
47
+ options={liveData || (element.options ?? [])}
48
+ />
48
49
  )}
49
50
  />
50
51
  : <></>
@@ -1,13 +1,18 @@
1
- import React, { FC, useEffect } from 'react'
1
+ 'use client'
2
+
3
+ import React, { FC, useContext, useEffect, useMemo } from 'react'
2
4
  import { Controller } from 'react-hook-form'
3
5
  import { useFieldRender } from '../../hooks/field-render'
4
6
  import { generateId } from '../../tools/general'
5
7
  import { IMakeTextareaProps } from '../../interfaces/make-textarea'
6
- import { Textarea } from '@nextui-org/react'
8
+ import { ComponentStateContext } from '../../context/component/component-state'
7
9
 
8
10
  const MakeTextarea: FC<IMakeTextareaProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
11
+ const { Textarea } = useContext(ComponentStateContext)
9
12
  const { render, enable, checkField } = useFieldRender({ ...props, element })
10
13
 
14
+ const elementId = useMemo(() => element.id ?? generateId(), [])
15
+
11
16
  useEffect(() => {
12
17
  const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
18
  return () => subscription.unsubscribe()
@@ -19,24 +24,24 @@ const MakeTextarea: FC<IMakeTextareaProps> = ({ element: { validation: { require
19
24
  name={element.name}
20
25
  control={props.control}
21
26
  rules={{
22
- required,
23
- pattern: {
24
- value: validation.regex as RegExp ?? /(.*)/,
27
+ required: {
28
+ value: required,
25
29
  message: validation.message ?? ''
26
30
  },
27
- ...validation
31
+ pattern: validation.regex ? {
32
+ value: validation.regex,
33
+ message: validation.message ?? ''
34
+ } : undefined,
35
+ ...validation
28
36
  }}
29
- render={({ field: { onChange, value }, fieldState: { invalid } }) => (
37
+ render={({ field: { onChange, value }, fieldState: { invalid, error } }) => (
30
38
  <Textarea
31
39
  {...element}
32
- disableAutosize
33
- id={element.id ?? generateId()}
40
+ id={elementId}
34
41
  onChange={onChange}
35
- label={element.label}
36
42
  value={value ?? ''}
37
- color={invalid ? 'danger' : undefined}
38
- isInvalid={invalid}
39
- errorMessage={invalid ? (validation.message ?? '') : undefined}
43
+ invalid={invalid}
44
+ error={error}
40
45
  disabled={element.disabled ?? !enable}
41
46
  />
42
47
  )}
@@ -1,13 +1,18 @@
1
- import React, { FC, useEffect } from 'react'
1
+ 'use client'
2
+
3
+ import React, { FC, useContext, useEffect, useMemo } from 'react'
2
4
  import { Controller } from 'react-hook-form'
3
5
  import { useFieldRender } from '../../hooks/field-render'
4
6
  import { IMakeToggleProps } from '../../interfaces/make-toggle'
5
- import { Switch } from '@nextui-org/react'
6
7
  import { generateId } from '../../tools/general'
8
+ import { ComponentStateContext } from '../../context/component/component-state'
7
9
 
8
10
  const MakeToggle: FC<IMakeToggleProps> = ({ element: { validation: { required, ...validation }, ...element }, ...props }) => {
11
+ const { Toggle } = useContext(ComponentStateContext)
9
12
  const { render, enable, checkField } = useFieldRender({ ...props, element })
10
13
 
14
+ const elementId = useMemo(() => element.id ?? generateId(), [])
15
+
11
16
  useEffect(() => {
12
17
  const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }))
13
18
  return () => subscription.unsubscribe()
@@ -19,22 +24,26 @@ const MakeToggle: FC<IMakeToggleProps> = ({ element: { validation: { required, .
19
24
  control={props.control}
20
25
  name={element.name}
21
26
  rules={{
22
- required,
23
- pattern: {
24
- value: validation.regex as RegExp ?? /(.*)/,
27
+ required: {
28
+ value: required,
29
+ message: validation.message ?? ''
30
+ },
31
+ pattern: validation.regex ? {
32
+ value: validation.regex,
25
33
  message: validation.message ?? ''
26
- }
34
+ } : undefined,
35
+ ...validation
27
36
  }}
28
- render={({ field: { onChange, value } }) => (
29
- <Switch
37
+ render={({ field: { onChange, value }, fieldState: { invalid, error } }) => (
38
+ <Toggle
30
39
  {...element}
31
- id={element.id ?? generateId()}
32
- isSelected={value}
33
- onValueChange={onChange}
34
- isDisabled={element.disabled ?? !enable}
35
- >
36
- {element.label}
37
- </Switch>
40
+ id={elementId}
41
+ onChange={onChange}
42
+ value={value ?? ''}
43
+ invalid={invalid}
44
+ error={error}
45
+ disabled={element.disabled ?? !enable}
46
+ />
38
47
  )}
39
48
  />
40
49
  : null
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import React,{ FC } from 'react'
2
4
  import { Controller } from 'react-hook-form'
3
5
  import InputUpload from '../input-upload/input-upload'
@@ -13,17 +15,21 @@ const MakeUpload : FC<IMakeUploadProps> = ({ element: { validation: { required,
13
15
  control={props.control}
14
16
  name={element.name}
15
17
  rules={{
16
- required,
17
- pattern: {
18
- value: validation.regex as RegExp ?? /(.*)/,
18
+ required: {
19
+ value: required,
20
+ message: validation.message ?? ''
21
+ },
22
+ pattern: validation.regex ? {
23
+ value: validation.regex,
19
24
  message: validation.message ?? ''
20
- }
25
+ } : undefined,
26
+ ...validation
21
27
  }}
22
28
  render={({ field: { onChange } }) => (
23
29
  <InputUpload
24
- {...element}
25
- disabled={element.disabled ?? !enable}
30
+ {...element}
26
31
  onChange={onChange}
32
+ disabled={element.disabled ?? !enable}
27
33
  />
28
34
  )}
29
35
  />
@@ -1,4 +1,5 @@
1
1
  'use client'
2
+
2
3
  import React, { useRef, useEffect, useState, FC } from 'react'
3
4
  import { createPortal } from 'react-dom'
4
5
  import { IPortal } from '../../interfaces/portal'
@@ -0,0 +1,18 @@
1
+ 'use client'
2
+
3
+ import React, { useMemo } from "react"
4
+ import { createContext } from "react"
5
+ import { IComponentState, IComponentStateProps } from "../../interfaces/component-state"
6
+
7
+ export const ComponentStateContext = createContext<IComponentState>({} as IComponentState)
8
+
9
+ export const ComponentState = ({ children, components }: IComponentStateProps) => {
10
+
11
+ const value: IComponentState = useMemo(() => components, [])
12
+
13
+ return (
14
+ <ComponentStateContext.Provider value={value}>
15
+ {children}
16
+ </ComponentStateContext.Provider>
17
+ )
18
+ }
@@ -1,4 +1,5 @@
1
1
  'use client'
2
+
2
3
  import { useCallback, useMemo, useState } from 'react'
3
4
  import { IField, IFieldProps } from '../interfaces/field'
4
5
  import { IOption } from '../interfaces/option'
@@ -1,4 +1,5 @@
1
1
  'use client'
2
+
2
3
  import { useState } from 'react'
3
4
  import { IModal, IModalConfigProps } from '../interfaces/modal'
4
5
 
@@ -0,0 +1,33 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { FC, PropsWithChildren } from "react"
3
+ import { FieldError } from "react-hook-form"
4
+ import { IOption } from "./option"
5
+ import { IMakeInput } from "./make-input"
6
+ import { IMakeButton } from "./make-button"
7
+ import { IMakeSelect } from "./make-select"
8
+ import { IMakeTextarea } from "./make-textarea"
9
+ import { IMakeToggle } from "./make-toggle"
10
+
11
+ export interface IComponentAditionalProps {
12
+ onChange: (...event: any[]) => void
13
+ value: any
14
+ invalid: boolean
15
+ error?: FieldError
16
+ liveSearching?: boolean
17
+ }
18
+
19
+ export interface IComponentState {
20
+ ModalButtonCancel: FC<Omit<IMakeButton, 'elementType'>>
21
+ ModalButtonAction: FC<Omit<IMakeButton, 'elementType'>>
22
+ Button: FC<Omit<IMakeButton, 'elementType'>>
23
+ //Description: FC<Omit<IMakeDescription, 'elementType'>>
24
+ Input: FC<Omit<IMakeInput, 'elementType' | 'validation' |'renderIf' | 'enableIf'> & IComponentAditionalProps>
25
+ Select: FC<Omit<IMakeSelect, 'elementType' | 'validation' |'renderIf' | 'enableIf'> & IComponentAditionalProps & Record<'options', Array<IOption>>>
26
+ Textarea: FC<Omit<IMakeTextarea, 'elementType' | 'validation' |'renderIf' | 'enableIf'> & IComponentAditionalProps>
27
+ Toggle: FC<Omit<IMakeToggle, 'elementType' | 'validation' |'renderIf' | 'enableIf'> & IComponentAditionalProps>
28
+ }
29
+
30
+ export interface IComponentStateProps extends PropsWithChildren {
31
+ components: IComponentState
32
+ }
33
+
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import { CSSProperties } from 'react'
2
3
  import { Control, FieldValues, UseFormSetValue, UseFormUnregister, UseFormWatch } from 'react-hook-form'
3
4
 
@@ -10,8 +11,9 @@ export interface IField {
10
11
  name: string
11
12
  id?: string
12
13
  label?: string
13
- styles?: CSSProperties
14
- defaultValue?: string
14
+ style?: CSSProperties
15
+ placeholder?: string
16
+ defaultValue?: any
15
17
  renderIf?: Record<string, Array<string | number>>
16
18
  enableIf?: Record<string, Array<string | number>>
17
19
  validation: {
@@ -24,12 +26,11 @@ export interface IField {
24
26
  max?: IValidationBase<number | string>
25
27
  }
26
28
  disabled?: boolean
27
- //required?: boolean
28
29
  }
29
30
 
30
31
  export interface IFieldProps {
31
- control: Control<FieldValues, unknown>;
32
- watch: UseFormWatch<FieldValues>;
33
- setValue: UseFormSetValue<FieldValues>;
34
- unregister: UseFormUnregister<FieldValues>;
32
+ control: Control<FieldValues, unknown>
33
+ watch: UseFormWatch<FieldValues>
34
+ setValue: UseFormSetValue<FieldValues>
35
+ unregister: UseFormUnregister<FieldValues>
35
36
  }
@@ -1,21 +1,21 @@
1
1
  import { ChangeEvent, CSSProperties } from 'react'
2
2
 
3
3
  export interface IFileResult {
4
- name: string;
5
- size: number;
4
+ name: string
5
+ size: number
6
6
  data: string
7
7
  }
8
8
 
9
9
  export interface IInputUpload {
10
- id?: string;
11
- value?: string;
12
- onChange: (event: ChangeEvent<HTMLInputElement> | IFileResult | FileList | null) => void;
13
- accept?:string;
10
+ id?: string
11
+ value?: string
12
+ onChange: (event: ChangeEvent<HTMLInputElement> | IFileResult | FileList | null) => void
13
+ accept?:string
14
14
  label?: string
15
15
  helpText?: string
16
- styles?:CSSProperties;
17
- readAsArrayBuffer?: boolean;
18
- name: string;
19
- disabled?: boolean;
20
- read?: boolean;
16
+ style?:CSSProperties
17
+ readAsArrayBuffer?: boolean
18
+ name: string
19
+ disabled?: boolean
20
+ read?: boolean
21
21
  }
@@ -2,19 +2,18 @@ import { CSSProperties } from 'react'
2
2
  import { IFieldProps } from './field'
3
3
 
4
4
  export interface IMakeButton {
5
- elementType: 'button';
5
+ id?: string
6
+ elementType: 'button'
6
7
  disabled?: boolean
7
- className?: string;
8
- variant?: 'solid' | 'light' | 'flat' | 'bordered' | 'faded' | 'shadow' | 'ghost'
9
- text?: string;
10
- type?: 'button' | 'submit' | 'reset';
11
- onClick?: () => void;
12
- iconName?: string;
13
- iconSize?: number | string;
14
- iconClassName?: CSSProperties;
15
- color?: 'primary' | 'secondary' | 'default' | 'success' | 'warning' | 'danger'
8
+ className?: string
9
+ style?: CSSProperties
10
+ variant?: string
11
+ text?: string
12
+ type?: 'button' | 'submit' | 'reset'
13
+ onClick?: () => void
14
+ color?: string
16
15
  }
17
16
 
18
17
  export interface IMakeButtonProps extends IFieldProps {
19
- element: IMakeButton
18
+ element: Omit<IMakeButton, 'elementType'>
20
19
  }
@@ -0,0 +1,14 @@
1
+ import { CSSProperties, FC } from 'react'
2
+ import { IFieldProps } from './field'
3
+
4
+ export interface IMakeDescription {
5
+ elementType: 'text'
6
+ text: string
7
+ containerStyle?: CSSProperties
8
+ textStyle?: CSSProperties
9
+ Icon?: FC
10
+ }
11
+
12
+ export interface IMakeDescriptionProps extends IFieldProps {
13
+ element: Omit<IMakeDescription, 'elementType'>
14
+ }
@@ -3,11 +3,12 @@ import { IFieldProps } from './field'
3
3
  import { IModalField } from './modal'
4
4
 
5
5
  export interface IMakeFieldGroup {
6
- elementType: 'group';
7
- groups: Array<IModalField>;
8
- style?: CSSProperties;
6
+ elementType: 'group'
7
+ groups: Array<IModalField>
8
+ style?: CSSProperties
9
+ title?: string
9
10
  }
10
11
 
11
12
  export interface IMakeFieldGroupProps extends IFieldProps {
12
- element: IMakeFieldGroup;
13
+ element: IMakeFieldGroup
13
14
  }
@@ -3,12 +3,12 @@ import { IField, IFieldProps } from './field'
3
3
 
4
4
  export interface IMakeInput extends IField {
5
5
  elementType: 'input'
6
- placeHolder?: string
6
+ placeholder?: string
7
7
  min?: string
8
8
  max?: string
9
9
  type?: HTMLInputTypeAttribute
10
10
  }
11
11
 
12
12
  export interface IMakeInputProps extends IFieldProps {
13
- element: IMakeInput
13
+ element: Omit<IMakeInput, 'elementType'>
14
14
  }
@@ -5,8 +5,10 @@ export interface IMakeSelect extends IField {
5
5
  elementType: 'select'
6
6
  options: Array<Record<'id'|'name', string>>
7
7
  liveData?: IModalLiveDataCondition
8
+ isSearch?: boolean
9
+ isMulti?: boolean
8
10
  }
9
11
 
10
12
  export interface IMakeSelectProps extends IFieldProps {
11
- element: IMakeSelect
13
+ element: Omit<IMakeSelect, 'elementType'>
12
14
  }
@@ -7,5 +7,5 @@ export interface IMakeTextarea extends IField {
7
7
  }
8
8
 
9
9
  export interface IMakeTextareaProps extends IFieldProps {
10
- element: IMakeTextarea
10
+ element: Omit<IMakeTextarea, 'elementType'>
11
11
  }
@@ -1,9 +1,9 @@
1
1
  import { IField, IFieldProps } from './field'
2
2
 
3
- export interface IMakeToggle extends IField{
3
+ export interface IMakeToggle extends IField {
4
4
  elementType: 'toggle'
5
5
  }
6
6
 
7
7
  export interface IMakeToggleProps extends IFieldProps {
8
- element: IMakeToggle
8
+ element: Omit<IMakeToggle, 'elementType'>
9
9
  }