dynamic-modal 1.0.11 → 1.0.13

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,130 +1,130 @@
1
-
2
- import { IModalConfigLoader } from '../src/interfaces/modal'
3
-
4
- export type IncomingProps = object
5
-
6
- type ResultProps = Record<'optionId', string> & Partial<Record<'input1ReadOnly' | 'input1WriteValue' | 'input2ReadOnly' | 'input2WriteValue', string>>
7
-
8
- export interface IEnableIfModal {
9
- default: IModalConfigLoader<IncomingProps, ResultProps>
10
- }
11
-
12
- const enableIfModal: IEnableIfModal = {
13
- default: (props, action) => {
14
- return {
15
- reservedData: {}, //Put here any data that you want store and receive into modal output
16
- fields: [ //Put here any elements for render into modal
17
- {
18
- elementType: 'select',
19
- label: 'option',
20
- defaultValue: '0',
21
- options: [
22
- {
23
- id: '0',
24
- name:'Select...'
25
- },
26
- {
27
- id: '1',
28
- name:'Option 1'
29
- },
30
- {
31
- id: '2',
32
- name:'Option 2'
33
- }
34
- ],
35
- name: 'optionId', //Element to be observed
36
- validation: {
37
- required: true,
38
- message: 'Please select a valid option'
39
- }
40
- },
41
- {
42
- elementType: 'group', //Put here groups of element into same line and customize using styles
43
- groups: [
44
- {
45
- elementType: 'input',
46
- label: 'Input 1 (Read)',
47
- name: 'input1ReadOnly',
48
- styles: {
49
- width: '50%'
50
- },
51
- validation: {
52
- required: false
53
- },
54
- //Define enable condition (element will be enabled when value of element observed match with array condition)
55
- enableIf: {
56
- optionId: ['1']
57
- }
58
- },
59
- {
60
- elementType: 'input',
61
- label: 'Input 1',
62
- name: 'input1WriteValue',
63
- styles: {
64
- width: '50%'
65
- },
66
- validation: {
67
- required: true,
68
- message: `Write a valid input value`
69
- },
70
- //Define enable condition (element will be enabled when value of element observed match with array condition)
71
- enableIf: {
72
- optionId: ['1']
73
- }
74
- },
75
- ]
76
- },
77
- {
78
- elementType: 'group', //Put here groups of element into same line and customize using styles
79
- groups: [
80
- {
81
- elementType: 'input',
82
- label: 'Input 2 (Read)',
83
- name: 'input2ReadOnly',
84
- disabled: true,
85
- styles: {
86
- width: '50%'
87
- },
88
- validation: {
89
- required: false
90
- },
91
- //Define enable condition (element will be enabled when value of element observed match with array condition)
92
- enableIf: {
93
- optionId: ['2']
94
- }
95
- },
96
- {
97
- elementType: 'input',
98
- label: 'Input 2',
99
- name: 'input2WriteValue',
100
- styles: {
101
- width: '50%'
102
- },
103
- validation: {
104
- required: true,
105
- message: `Write a valid input value`
106
- },
107
- //Define enable condition (element will be enabled when value of element observed match with array condition)
108
- enableIf: {
109
- optionId: ['2']
110
- }
111
- },
112
- ]
113
- },
114
- ],
115
- styles: { // Put here styles for modal like height or width
116
- width: '500px'
117
- },
118
- title: `Title of enable if modal`, //Title of modal
119
- action: {
120
- name: 'Save', //Name of action button
121
- action //Function to receive data from modal
122
- },
123
- cancel: {
124
- name: 'Cancel' //Name of cancel button
125
- }
126
- }
127
- }
128
- }
129
-
1
+
2
+ import { IModalConfigLoader } from '../src/interfaces/modal'
3
+
4
+ export type IncomingProps = object
5
+
6
+ type ResultProps = Record<'optionId', string> & Partial<Record<'input1ReadOnly' | 'input1WriteValue' | 'input2ReadOnly' | 'input2WriteValue', string>>
7
+
8
+ export interface IEnableIfModal {
9
+ default: IModalConfigLoader<IncomingProps, ResultProps>
10
+ }
11
+
12
+ const enableIfModal: IEnableIfModal = {
13
+ default: (props, action) => {
14
+ return {
15
+ reservedData: {}, //Put here any data that you want store and receive into modal output
16
+ fields: [ //Put here any elements for render into modal
17
+ {
18
+ elementType: 'select',
19
+ label: 'option',
20
+ defaultValue: '0',
21
+ options: [
22
+ {
23
+ id: '0',
24
+ name:'Select...'
25
+ },
26
+ {
27
+ id: '1',
28
+ name:'Option 1'
29
+ },
30
+ {
31
+ id: '2',
32
+ name:'Option 2'
33
+ }
34
+ ],
35
+ name: 'optionId', //Element to be observed
36
+ validation: {
37
+ required: true,
38
+ message: 'Please select a valid option'
39
+ }
40
+ },
41
+ {
42
+ elementType: 'group', //Put here groups of element into same line and customize using styles
43
+ groups: [
44
+ {
45
+ elementType: 'input',
46
+ label: 'Input 1 (Read)',
47
+ name: 'input1ReadOnly',
48
+ styles: {
49
+ width: '50%'
50
+ },
51
+ validation: {
52
+ required: false
53
+ },
54
+ //Define enable condition (element will be enabled when value of element observed match with array condition)
55
+ enableIf: {
56
+ optionId: ['1']
57
+ }
58
+ },
59
+ {
60
+ elementType: 'input',
61
+ label: 'Input 1',
62
+ name: 'input1WriteValue',
63
+ styles: {
64
+ width: '50%'
65
+ },
66
+ validation: {
67
+ required: true,
68
+ message: `Write a valid input value`
69
+ },
70
+ //Define enable condition (element will be enabled when value of element observed match with array condition)
71
+ enableIf: {
72
+ optionId: ['1']
73
+ }
74
+ },
75
+ ]
76
+ },
77
+ {
78
+ elementType: 'group', //Put here groups of element into same line and customize using styles
79
+ groups: [
80
+ {
81
+ elementType: 'input',
82
+ label: 'Input 2 (Read)',
83
+ name: 'input2ReadOnly',
84
+ disabled: true,
85
+ styles: {
86
+ width: '50%'
87
+ },
88
+ validation: {
89
+ required: false
90
+ },
91
+ //Define enable condition (element will be enabled when value of element observed match with array condition)
92
+ enableIf: {
93
+ optionId: ['2']
94
+ }
95
+ },
96
+ {
97
+ elementType: 'input',
98
+ label: 'Input 2',
99
+ name: 'input2WriteValue',
100
+ styles: {
101
+ width: '50%'
102
+ },
103
+ validation: {
104
+ required: true,
105
+ message: `Write a valid input value`
106
+ },
107
+ //Define enable condition (element will be enabled when value of element observed match with array condition)
108
+ enableIf: {
109
+ optionId: ['2']
110
+ }
111
+ },
112
+ ]
113
+ },
114
+ ],
115
+ styles: { // Put here styles for modal like height or width
116
+ width: '500px'
117
+ },
118
+ title: `Title of enable if modal`, //Title of modal
119
+ action: {
120
+ name: 'Save', //Name of action button
121
+ action //Function to receive data from modal
122
+ },
123
+ cancel: {
124
+ name: 'Cancel' //Name of cancel button
125
+ }
126
+ }
127
+ }
128
+ }
129
+
130
130
  export default enableIfModal
@@ -1,64 +1,64 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { IModalConfigLoader } from '../src/interfaces/modal'
3
- import { IOption } from '../src/interfaces/option'
4
-
5
- type IncomingProps = {
6
- typeList: Array<IOption>
7
-
8
- //Define function to receive selected element and formData (if you need to use) make read or select operations and build
9
- //next select array of elements
10
- optionReadAction : (typeId: string, formData: any) => Promise<Array<IOption>>
11
- }
12
-
13
- type ResultProps = Omit<IncomingProps,'optionReadAction'|'typeList'> & Record<'typeId'|'optionId', string>
14
-
15
- export interface ILiveDataModal {
16
- default: IModalConfigLoader<IncomingProps, ResultProps>
17
- }
18
-
19
- const liveDataModal: ILiveDataModal = {
20
- default: (props, action) => {
21
- return {
22
- reservedData: {}, //Put here any data that you want store and receive into modal output
23
- fields: [ //Put here any elements for render into modal
24
- {
25
- elementType: 'select',
26
- label: 'Type',
27
- options: props.typeList,
28
- name: 'typeId', //Element to be observed
29
- validation: {
30
- required: true,
31
- message: 'Please select a valid type'
32
- }
33
- },
34
- {
35
- elementType: 'select',
36
- label: 'Options',
37
- options: [],
38
- name: 'optionId',
39
- validation: {
40
- required: true,
41
- message: 'Please select a valid option'
42
- },
43
- liveData: {
44
- action: props.optionReadAction, //Define live data action (function that receive data selected from other field for execute and build other options)
45
- condition: 'typeId' //Define element into modal was to observed
46
- }
47
- }
48
- ],
49
- styles: { // Put here styles for modal like height or width
50
- width: '500px'
51
- },
52
- title: `Title of live data modal`, //Title of modal
53
- action: {
54
- name: 'Save', //Name of action button
55
- action //Function to receive data from modal
56
- },
57
- cancel: {
58
- name: 'Cancel' //Name of cancel button
59
- }
60
- }
61
- }
62
- }
63
-
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { IModalConfigLoader } from '../src/interfaces/modal'
3
+ import { IOption } from '../src/interfaces/option'
4
+
5
+ type IncomingProps = {
6
+ typeList: Array<IOption>
7
+
8
+ //Define function to receive selected element and formData (if you need to use) make read or select operations and build
9
+ //next select array of elements
10
+ optionReadAction : (typeId: string, formData: any) => Promise<Array<IOption>>
11
+ }
12
+
13
+ type ResultProps = Omit<IncomingProps,'optionReadAction'|'typeList'> & Record<'typeId'|'optionId', string>
14
+
15
+ export interface ILiveDataModal {
16
+ default: IModalConfigLoader<IncomingProps, ResultProps>
17
+ }
18
+
19
+ const liveDataModal: ILiveDataModal = {
20
+ default: (props, action) => {
21
+ return {
22
+ reservedData: {}, //Put here any data that you want store and receive into modal output
23
+ fields: [ //Put here any elements for render into modal
24
+ {
25
+ elementType: 'select',
26
+ label: 'Type',
27
+ options: props.typeList,
28
+ name: 'typeId', //Element to be observed
29
+ validation: {
30
+ required: true,
31
+ message: 'Please select a valid type'
32
+ }
33
+ },
34
+ {
35
+ elementType: 'select',
36
+ label: 'Options',
37
+ options: [],
38
+ name: 'optionId',
39
+ validation: {
40
+ required: true,
41
+ message: 'Please select a valid option'
42
+ },
43
+ liveData: {
44
+ action: props.optionReadAction, //Define live data action (function that receive data selected from other field for execute and build other options)
45
+ condition: 'typeId' //Define element into modal was to observed
46
+ }
47
+ }
48
+ ],
49
+ styles: { // Put here styles for modal like height or width
50
+ width: '500px'
51
+ },
52
+ title: `Title of live data modal`, //Title of modal
53
+ action: {
54
+ name: 'Save', //Name of action button
55
+ action //Function to receive data from modal
56
+ },
57
+ cancel: {
58
+ name: 'Cancel' //Name of cancel button
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
64
  export default liveDataModal
@@ -1,131 +1,131 @@
1
-
2
- import { IModalConfigLoader } from '../src/interfaces/modal'
3
-
4
- export type IncomingProps = object
5
-
6
- type ResultProps = Record<'optionId', string> & Partial<Record<'input1ReadOnly' | 'input1WriteValue' | 'input2ReadOnly' | 'input2WriteValue', string>>
7
-
8
- export interface IRenderIfModal {
9
- default: IModalConfigLoader<IncomingProps, ResultProps>
10
- }
11
-
12
- const renderIfModal: IRenderIfModal = {
13
- default: (props, action) => {
14
- return {
15
- reservedData: {}, //Put here any data that you want store and receive into modal output
16
- fields: [ //Put here any elements for render into modal
17
- {
18
- elementType: 'select',
19
- label: 'option',
20
- defaultValue: '0',
21
- options: [
22
- {
23
- id: '0',
24
- name:'Select...'
25
- },
26
- {
27
- id: '1',
28
- name:'Option 1'
29
- },
30
- {
31
- id: '2',
32
- name:'Option 2'
33
- }
34
- ],
35
- name: 'optionId', //Element to be observed
36
- validation: {
37
- required: true,
38
- message: 'Please select a valid option'
39
- }
40
- },
41
- {
42
- elementType: 'group', //Put here groups of element into same line and customize using styles
43
- groups: [
44
- {
45
- elementType: 'input',
46
- label: 'Input 1 (Read)',
47
- name: 'input1ReadOnly',
48
- disabled: true,
49
- styles: {
50
- width: '50%'
51
- },
52
- validation: {
53
- required: false
54
- },
55
- //Define render condition (element will be show when value of element observed match with array condition)
56
- renderIf: {
57
- optionId: ['1']
58
- }
59
- },
60
- {
61
- elementType: 'input',
62
- label: 'Input 1',
63
- name: 'input1WriteValue',
64
- styles: {
65
- width: '50%'
66
- },
67
- validation: {
68
- required: true,
69
- message: `Write a valid input value`
70
- },
71
- //Define render condition (element will be show when value of element observed match with array condition)
72
- renderIf: {
73
- optionId: ['1']
74
- }
75
- },
76
- ]
77
- },
78
- {
79
- elementType: 'group', //Put here groups of element into same line and customize using styles
80
- groups: [
81
- {
82
- elementType: 'input',
83
- label: 'Input 2 (Read)',
84
- name: 'input2ReadOnly',
85
- disabled: true,
86
- styles: {
87
- width: '50%'
88
- },
89
- validation: {
90
- required: false
91
- },
92
- //Define render condition (element will be show when value of element observed match with array condition)
93
- renderIf: {
94
- optionId: ['2']
95
- }
96
- },
97
- {
98
- elementType: 'input',
99
- label: 'Input 2',
100
- name: 'input2WriteValue',
101
- styles: {
102
- width: '50%'
103
- },
104
- validation: {
105
- required: true,
106
- message: `Write a valid input value`
107
- },
108
- //Define render condition (element will be show when value of element observed match with array condition)
109
- renderIf: {
110
- optionId: ['2']
111
- }
112
- },
113
- ]
114
- },
115
- ],
116
- styles: { // Put here styles for modal like height or width
117
- width: '500px'
118
- },
119
- title: `Title of render if modal`, //Title of modal
120
- action: {
121
- name: 'Save', //Name of action button
122
- action //Function to receive data from modal
123
- },
124
- cancel: {
125
- name: 'Cancel' //Name of cancel button
126
- }
127
- }
128
- }
129
- }
130
-
1
+
2
+ import { IModalConfigLoader } from '../src/interfaces/modal'
3
+
4
+ export type IncomingProps = object
5
+
6
+ type ResultProps = Record<'optionId', string> & Partial<Record<'input1ReadOnly' | 'input1WriteValue' | 'input2ReadOnly' | 'input2WriteValue', string>>
7
+
8
+ export interface IRenderIfModal {
9
+ default: IModalConfigLoader<IncomingProps, ResultProps>
10
+ }
11
+
12
+ const renderIfModal: IRenderIfModal = {
13
+ default: (props, action) => {
14
+ return {
15
+ reservedData: {}, //Put here any data that you want store and receive into modal output
16
+ fields: [ //Put here any elements for render into modal
17
+ {
18
+ elementType: 'select',
19
+ label: 'option',
20
+ defaultValue: '0',
21
+ options: [
22
+ {
23
+ id: '0',
24
+ name:'Select...'
25
+ },
26
+ {
27
+ id: '1',
28
+ name:'Option 1'
29
+ },
30
+ {
31
+ id: '2',
32
+ name:'Option 2'
33
+ }
34
+ ],
35
+ name: 'optionId', //Element to be observed
36
+ validation: {
37
+ required: true,
38
+ message: 'Please select a valid option'
39
+ }
40
+ },
41
+ {
42
+ elementType: 'group', //Put here groups of element into same line and customize using styles
43
+ groups: [
44
+ {
45
+ elementType: 'input',
46
+ label: 'Input 1 (Read)',
47
+ name: 'input1ReadOnly',
48
+ disabled: true,
49
+ styles: {
50
+ width: '50%'
51
+ },
52
+ validation: {
53
+ required: false
54
+ },
55
+ //Define render condition (element will be show when value of element observed match with array condition)
56
+ renderIf: {
57
+ optionId: ['1']
58
+ }
59
+ },
60
+ {
61
+ elementType: 'input',
62
+ label: 'Input 1',
63
+ name: 'input1WriteValue',
64
+ styles: {
65
+ width: '50%'
66
+ },
67
+ validation: {
68
+ required: true,
69
+ message: `Write a valid input value`
70
+ },
71
+ //Define render condition (element will be show when value of element observed match with array condition)
72
+ renderIf: {
73
+ optionId: ['1']
74
+ }
75
+ },
76
+ ]
77
+ },
78
+ {
79
+ elementType: 'group', //Put here groups of element into same line and customize using styles
80
+ groups: [
81
+ {
82
+ elementType: 'input',
83
+ label: 'Input 2 (Read)',
84
+ name: 'input2ReadOnly',
85
+ disabled: true,
86
+ styles: {
87
+ width: '50%'
88
+ },
89
+ validation: {
90
+ required: false
91
+ },
92
+ //Define render condition (element will be show when value of element observed match with array condition)
93
+ renderIf: {
94
+ optionId: ['2']
95
+ }
96
+ },
97
+ {
98
+ elementType: 'input',
99
+ label: 'Input 2',
100
+ name: 'input2WriteValue',
101
+ styles: {
102
+ width: '50%'
103
+ },
104
+ validation: {
105
+ required: true,
106
+ message: `Write a valid input value`
107
+ },
108
+ //Define render condition (element will be show when value of element observed match with array condition)
109
+ renderIf: {
110
+ optionId: ['2']
111
+ }
112
+ },
113
+ ]
114
+ },
115
+ ],
116
+ styles: { // Put here styles for modal like height or width
117
+ width: '500px'
118
+ },
119
+ title: `Title of render if modal`, //Title of modal
120
+ action: {
121
+ name: 'Save', //Name of action button
122
+ action //Function to receive data from modal
123
+ },
124
+ cancel: {
125
+ name: 'Cancel' //Name of cancel button
126
+ }
127
+ }
128
+ }
129
+ }
130
+
131
131
  export default renderIfModal