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.
- package/README-ES.md +109 -11
- package/README.md +110 -13
- package/dist/components/input-upload/input-upload.js +8 -42
- package/dist/components/make-button/make-button.js +41 -18
- package/dist/components/make-description/make-description.d.ts +4 -0
- package/dist/components/make-description/make-description.js +13 -0
- package/dist/components/make-input/make-input.d.ts +1 -1
- package/dist/components/make-input/make-input.js +12 -6
- package/dist/components/make-select/make-select.js +12 -6
- package/dist/components/make-textarea/make-textarea.js +12 -6
- package/dist/components/make-toggle/make-toggle.js +12 -9
- package/dist/components/make-upload/make-upload.js +8 -7
- package/dist/context/component/component-state.d.ts +4 -0
- package/dist/context/component/component-state.js +45 -0
- package/dist/interfaces/component-state.d.ts +27 -0
- package/dist/interfaces/field.d.ts +3 -2
- package/dist/interfaces/input-upload.d.ts +1 -1
- package/dist/interfaces/make-button.d.ts +5 -6
- package/dist/interfaces/make-description.d.ts +12 -0
- package/dist/interfaces/make-field-group.d.ts +1 -0
- package/dist/interfaces/{make-field.d.ts → make-input.d.ts} +2 -2
- package/dist/interfaces/make-select.d.ts +3 -1
- package/dist/interfaces/make-textarea.d.ts +1 -1
- package/dist/interfaces/make-toggle.d.ts +1 -1
- package/dist/interfaces/make-upload.d.ts +1 -1
- package/dist/interfaces/modal.d.ts +14 -19
- package/dist/modal.js +42 -35
- package/dist/tools/general.js +1 -0
- package/examples/enable-if.ts +5 -7
- package/examples/live-data.ts +7 -9
- package/examples/render-if.ts +6 -8
- package/examples/simple.ts +6 -8
- package/index.ts +4 -2
- package/package.json +16 -17
- package/src/components/input-upload/input-upload.tsx +7 -12
- package/src/components/make-button/make-button.tsx +11 -10
- package/src/components/make-description/make-description.tsx +15 -0
- package/src/components/make-input/make-input.tsx +25 -19
- package/src/components/make-select/make-select.tsx +23 -22
- package/src/components/make-textarea/make-textarea.tsx +18 -13
- package/src/components/make-toggle/make-toggle.tsx +24 -15
- package/src/components/make-upload/make-upload.tsx +12 -6
- package/src/components/portal/portal.tsx +1 -0
- package/src/context/component/component-state.tsx +18 -0
- package/src/hooks/field-render.ts +1 -0
- package/src/hooks/modal-handler.ts +1 -0
- package/src/interfaces/component-state.ts +33 -0
- package/src/interfaces/field.ts +8 -7
- package/src/interfaces/input-upload.ts +11 -11
- package/src/interfaces/make-button.ts +10 -11
- package/src/interfaces/make-description.ts +14 -0
- package/src/interfaces/make-field-group.ts +5 -4
- package/src/interfaces/{make-field.ts → make-input.ts} +2 -2
- package/src/interfaces/make-select.ts +3 -1
- package/src/interfaces/make-textarea.ts +1 -1
- package/src/interfaces/make-toggle.ts +2 -2
- package/src/interfaces/make-upload.ts +7 -7
- package/src/interfaces/modal.ts +15 -21
- package/src/interfaces/option.ts +2 -2
- package/src/interfaces/portal.ts +4 -4
- package/src/modal.tsx +43 -53
- package/src/tools/general.ts +2 -0
- package/.idea/dynamic-modal.iml +0 -12
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/dist/components/make-autocomplete/make-autocomplete.d.ts +0 -4
- package/dist/components/make-autocomplete/make-autocomplete.js +0 -70
- package/dist/components/make-multi-select/make-multi-select.d.ts +0 -4
- package/dist/components/make-multi-select/make-multi-select.js +0 -70
- package/dist/components/make-text/make-text.d.ts +0 -4
- package/dist/components/make-text/make-text.js +0 -11
- package/dist/components/make-title/make-title.d.ts +0 -4
- package/dist/components/make-title/make-title.js +0 -10
- package/dist/interfaces/make-autocomplete.d.ts +0 -11
- package/dist/interfaces/make-multi-select.d.ts +0 -12
- package/dist/interfaces/make-text.d.ts +0 -10
- package/dist/interfaces/make-text.js +0 -2
- package/dist/interfaces/make-title.d.ts +0 -3
- package/dist/interfaces/make-title.js +0 -2
- package/src/components/make-autocomplete/make-autocomplete.tsx +0 -54
- package/src/components/make-multi-select/make-multi-select.tsx +0 -56
- package/src/components/make-text/make-text.tsx +0 -16
- package/src/components/make-title/make-title.tsx +0 -12
- package/src/interfaces/make-autocomplete.ts +0 -13
- package/src/interfaces/make-multi-select.ts +0 -14
- package/src/interfaces/make-text.ts +0 -12
- package/src/interfaces/make-title.ts +0 -3
- /package/dist/interfaces/{make-autocomplete.js → component-state.js} +0 -0
- /package/dist/interfaces/{make-field.js → make-description.js} +0 -0
- /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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|