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,56 +0,0 @@
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,16 +0,0 @@
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,12 +0,0 @@
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,13 +0,0 @@
1
- import { IField, IFieldProps } from './field'
2
- import { IModalLiveDataCondition } from './modal'
3
- import { IOption } from './option'
4
-
5
- export interface IMakeAutoComplete extends IField {
6
- elementType: 'autocomplete'
7
- options: Array<IOption>
8
- liveData?: IModalLiveDataCondition
9
- }
10
-
11
- export interface IMakeAutoCompleteProps extends IFieldProps {
12
- element: IMakeAutoComplete
13
- }
@@ -1,14 +0,0 @@
1
- import { IOption } from './option'
2
- import { IField, IFieldProps } from './field'
3
- import { IModalLiveDataCondition } from './modal'
4
-
5
- export interface IMakeMultiSelect extends Omit<IField, 'defaultValue'> {
6
- elementType: 'multiselect';
7
- options: Array<IOption>;
8
- liveData?: IModalLiveDataCondition;
9
- defaultValue?: Array<string>
10
- }
11
-
12
- export interface IMakeMultiSelectProps extends IFieldProps {
13
- element: IMakeMultiSelect
14
- }
@@ -1,12 +0,0 @@
1
- import { CSSProperties } from 'react'
2
- import { IFieldProps } from './field'
3
-
4
- export interface IMakeText {
5
- elementType: 'text'
6
- text: string
7
- styles?: CSSProperties
8
- }
9
-
10
- export interface IMakeTextProps extends IFieldProps {
11
- element: IMakeText
12
- }
@@ -1,3 +0,0 @@
1
- export interface IMakeTitle {
2
- title: string
3
- }