dynamic-modal 1.1.1 → 1.1.7
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 +217 -217
- package/README.md +216 -215
- package/dist/components/input-upload/input-upload.js +1 -1
- package/dist/components/make-button/make-button.js +7 -17
- package/dist/components/make-input/make-input.js +9 -19
- package/dist/components/make-select/make-select.js +9 -19
- package/dist/components/make-textarea/make-textarea.js +9 -19
- package/dist/components/make-toggle/make-toggle.js +9 -19
- package/dist/components/make-upload/make-upload.js +2 -2
- package/dist/components/portal/portal.js +7 -17
- package/dist/context/component/component-state.js +7 -17
- package/dist/hooks/field-render.js +1 -1
- package/dist/interfaces/field.d.ts +3 -2
- package/dist/interfaces/make-select.d.ts +2 -1
- package/dist/interfaces/modal.d.ts +2 -1
- package/dist/modal.js +38 -19
- package/eslint.config.mjs +14 -14
- package/examples/enable-if.ts +127 -127
- package/examples/live-data.ts +61 -61
- package/examples/render-if.ts +128 -128
- package/examples/simple.ts +74 -74
- package/index.ts +5 -5
- package/package.json +46 -47
- package/src/components/input-upload/input-upload.tsx +67 -67
- package/src/components/make-button/make-button.tsx +18 -18
- package/src/components/make-description/make-description.tsx +15 -15
- package/src/components/make-input/make-input.tsx +53 -53
- package/src/components/make-select/make-select.tsx +55 -55
- package/src/components/make-textarea/make-textarea.tsx +53 -53
- package/src/components/make-toggle/make-toggle.tsx +53 -53
- package/src/components/make-upload/make-upload.tsx +40 -40
- package/src/components/portal/portal.tsx +37 -37
- package/src/context/component/component-state.tsx +17 -17
- package/src/hooks/field-render.ts +109 -109
- package/src/hooks/modal-handler.ts +38 -38
- package/src/interfaces/component-state.ts +33 -33
- package/src/interfaces/field.ts +37 -36
- package/src/interfaces/input-upload.ts +21 -21
- package/src/interfaces/make-button.ts +19 -19
- package/src/interfaces/make-description.ts +14 -14
- package/src/interfaces/make-field-group.ts +14 -14
- package/src/interfaces/make-input.ts +14 -14
- package/src/interfaces/make-select.ts +15 -14
- package/src/interfaces/make-textarea.ts +11 -11
- package/src/interfaces/make-toggle.ts +9 -9
- package/src/interfaces/make-upload.ts +14 -14
- package/src/interfaces/modal.ts +47 -45
- package/src/interfaces/option.ts +3 -3
- package/src/interfaces/portal.ts +8 -8
- package/src/modal.tsx +196 -164
- package/src/tools/general.ts +8 -8
- package/tsconfig.json +13 -13
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ChangeEvent, CSSProperties } from 'react'
|
|
2
|
-
|
|
3
|
-
export interface IFileResult {
|
|
4
|
-
name: string
|
|
5
|
-
size: number
|
|
6
|
-
data: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface IInputUpload {
|
|
10
|
-
id?: string
|
|
11
|
-
value?: string
|
|
12
|
-
onChange: (event: ChangeEvent<HTMLInputElement> | IFileResult | FileList | null) => void
|
|
13
|
-
accept?:string
|
|
14
|
-
label?: string
|
|
15
|
-
helpText?: string
|
|
16
|
-
style?:CSSProperties
|
|
17
|
-
readAsArrayBuffer?: boolean
|
|
18
|
-
name: string
|
|
19
|
-
disabled?: boolean
|
|
20
|
-
read?: boolean
|
|
21
|
-
}
|
|
1
|
+
import { ChangeEvent, CSSProperties } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface IFileResult {
|
|
4
|
+
name: string
|
|
5
|
+
size: number
|
|
6
|
+
data: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IInputUpload {
|
|
10
|
+
id?: string
|
|
11
|
+
value?: string
|
|
12
|
+
onChange: (event: ChangeEvent<HTMLInputElement> | IFileResult | FileList | null) => void
|
|
13
|
+
accept?:string
|
|
14
|
+
label?: string
|
|
15
|
+
helpText?: string
|
|
16
|
+
style?:CSSProperties
|
|
17
|
+
readAsArrayBuffer?: boolean
|
|
18
|
+
name: string
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
read?: boolean
|
|
21
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { CSSProperties } from 'react'
|
|
2
|
-
import { IFieldProps } from './field'
|
|
3
|
-
|
|
4
|
-
export interface IMakeButton {
|
|
5
|
-
id?: string
|
|
6
|
-
elementType: 'button'
|
|
7
|
-
disabled?: boolean
|
|
8
|
-
className?: string
|
|
9
|
-
style?: CSSProperties
|
|
10
|
-
variant?: string
|
|
11
|
-
text?: string
|
|
12
|
-
type?: 'button' | 'submit' | 'reset'
|
|
13
|
-
onClick?: () => void
|
|
14
|
-
color?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface IMakeButtonProps extends IFieldProps {
|
|
18
|
-
element: Omit<IMakeButton, 'elementType'>
|
|
19
|
-
}
|
|
1
|
+
import { CSSProperties } from 'react'
|
|
2
|
+
import { IFieldProps } from './field'
|
|
3
|
+
|
|
4
|
+
export interface IMakeButton {
|
|
5
|
+
id?: string
|
|
6
|
+
elementType: 'button'
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
className?: string
|
|
9
|
+
style?: CSSProperties
|
|
10
|
+
variant?: string
|
|
11
|
+
text?: string
|
|
12
|
+
type?: 'button' | 'submit' | 'reset'
|
|
13
|
+
onClick?: () => void
|
|
14
|
+
color?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface IMakeButtonProps extends IFieldProps {
|
|
18
|
+
element: Omit<IMakeButton, 'elementType'>
|
|
19
|
+
}
|
|
@@ -1,14 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { CSSProperties } from 'react'
|
|
2
|
-
import { IFieldProps } from './field'
|
|
3
|
-
import { IModalField } from './modal'
|
|
4
|
-
|
|
5
|
-
export interface IMakeFieldGroup {
|
|
6
|
-
elementType: 'group'
|
|
7
|
-
groups: Array<IModalField>
|
|
8
|
-
style?: CSSProperties
|
|
9
|
-
title?: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IMakeFieldGroupProps extends IFieldProps {
|
|
13
|
-
element: IMakeFieldGroup
|
|
14
|
-
}
|
|
1
|
+
import { CSSProperties } from 'react'
|
|
2
|
+
import { IFieldProps } from './field'
|
|
3
|
+
import { IModalField } from './modal'
|
|
4
|
+
|
|
5
|
+
export interface IMakeFieldGroup {
|
|
6
|
+
elementType: 'group'
|
|
7
|
+
groups: Array<IModalField>
|
|
8
|
+
style?: CSSProperties
|
|
9
|
+
title?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IMakeFieldGroupProps extends IFieldProps {
|
|
13
|
+
element: IMakeFieldGroup
|
|
14
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { HTMLInputTypeAttribute } from 'react'
|
|
2
|
-
import { IField, IFieldProps } from './field'
|
|
3
|
-
|
|
4
|
-
export interface IMakeInput extends IField {
|
|
5
|
-
elementType: 'input'
|
|
6
|
-
placeholder?: string
|
|
7
|
-
min?: string
|
|
8
|
-
max?: string
|
|
9
|
-
type?: HTMLInputTypeAttribute
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IMakeInputProps extends IFieldProps {
|
|
13
|
-
element: Omit<IMakeInput, 'elementType'>
|
|
14
|
-
}
|
|
1
|
+
import { HTMLInputTypeAttribute } from 'react'
|
|
2
|
+
import { IField, IFieldProps } from './field'
|
|
3
|
+
|
|
4
|
+
export interface IMakeInput extends IField {
|
|
5
|
+
elementType: 'input'
|
|
6
|
+
placeholder?: string
|
|
7
|
+
min?: string
|
|
8
|
+
max?: string
|
|
9
|
+
type?: HTMLInputTypeAttribute
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IMakeInputProps extends IFieldProps {
|
|
13
|
+
element: Omit<IMakeInput, 'elementType'>
|
|
14
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { IField, IFieldProps } from './field'
|
|
2
|
-
import { IModalLiveDataCondition } from './modal'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { IField, IFieldProps } from './field'
|
|
2
|
+
import { IModalLiveDataCondition } from './modal'
|
|
3
|
+
import { IOption } from './option'
|
|
4
|
+
|
|
5
|
+
export interface IMakeSelect extends IField {
|
|
6
|
+
elementType: 'select'
|
|
7
|
+
options: Array<IOption>
|
|
8
|
+
liveData?: IModalLiveDataCondition
|
|
9
|
+
isSearch?: boolean
|
|
10
|
+
isMulti?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IMakeSelectProps extends IFieldProps {
|
|
14
|
+
element: Omit<IMakeSelect, 'elementType'>
|
|
15
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IField, IFieldProps } from './field'
|
|
2
|
-
|
|
3
|
-
export interface IMakeTextarea extends IField {
|
|
4
|
-
elementType: 'textarea'
|
|
5
|
-
cols?: number
|
|
6
|
-
rows?: number
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface IMakeTextareaProps extends IFieldProps {
|
|
10
|
-
element: Omit<IMakeTextarea, 'elementType'>
|
|
11
|
-
}
|
|
1
|
+
import { IField, IFieldProps } from './field'
|
|
2
|
+
|
|
3
|
+
export interface IMakeTextarea extends IField {
|
|
4
|
+
elementType: 'textarea'
|
|
5
|
+
cols?: number
|
|
6
|
+
rows?: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IMakeTextareaProps extends IFieldProps {
|
|
10
|
+
element: Omit<IMakeTextarea, 'elementType'>
|
|
11
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IField, IFieldProps } from './field'
|
|
2
|
-
|
|
3
|
-
export interface IMakeToggle extends IField {
|
|
4
|
-
elementType: 'toggle'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface IMakeToggleProps extends IFieldProps {
|
|
8
|
-
element: Omit<IMakeToggle, 'elementType'>
|
|
9
|
-
}
|
|
1
|
+
import { IField, IFieldProps } from './field'
|
|
2
|
+
|
|
3
|
+
export interface IMakeToggle extends IField {
|
|
4
|
+
elementType: 'toggle'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface IMakeToggleProps extends IFieldProps {
|
|
8
|
+
element: Omit<IMakeToggle, 'elementType'>
|
|
9
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IField, IFieldProps } from './field'
|
|
2
|
-
|
|
3
|
-
export interface IMakeUpload extends Omit<IField, 'defaultValue'> {
|
|
4
|
-
elementType: 'upload'
|
|
5
|
-
helpText?: string
|
|
6
|
-
read: boolean
|
|
7
|
-
image?: boolean
|
|
8
|
-
accept?:string
|
|
9
|
-
readAsArrayBuffer?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IMakeUploadProps extends IFieldProps {
|
|
13
|
-
element: Omit<IMakeUpload, 'elementType'>
|
|
14
|
-
}
|
|
1
|
+
import { IField, IFieldProps } from './field'
|
|
2
|
+
|
|
3
|
+
export interface IMakeUpload extends Omit<IField, 'defaultValue'> {
|
|
4
|
+
elementType: 'upload'
|
|
5
|
+
helpText?: string
|
|
6
|
+
read: boolean
|
|
7
|
+
image?: boolean
|
|
8
|
+
accept?:string
|
|
9
|
+
readAsArrayBuffer?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IMakeUploadProps extends IFieldProps {
|
|
13
|
+
element: Omit<IMakeUpload, 'elementType'>
|
|
14
|
+
}
|
package/src/interfaces/modal.ts
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { CSSProperties } from 'react'
|
|
3
|
-
import { IMakeSelect } from './make-select'
|
|
4
|
-
import { IMakeInput } from './make-input'
|
|
5
|
-
import { IMakeTextarea } from './make-textarea'
|
|
6
|
-
import { IMakeToggle } from './make-toggle'
|
|
7
|
-
import { IMakeDescription } from './make-description'
|
|
8
|
-
import { IMakeFieldGroup } from './make-field-group'
|
|
9
|
-
import { IMakeUpload } from './make-upload'
|
|
10
|
-
import { IOption } from './option'
|
|
11
|
-
import { IMakeButton } from './make-button'
|
|
12
|
-
|
|
13
|
-
export type IModalField = IMakeSelect | IMakeInput | IMakeFieldGroup | IMakeTextarea | IMakeToggle | IMakeDescription | IMakeUpload | IMakeButton
|
|
14
|
-
|
|
15
|
-
export type IFormField = IMakeSelect | IMakeInput | IMakeTextarea | IMakeToggle
|
|
16
|
-
|
|
17
|
-
export type IModalRenderCondition =
|
|
18
|
-
|
|
19
|
-
export type IModalLiveDataCondition = {
|
|
20
|
-
action: (data: string, ...args: any[]) => Promise<Array<IOption>>
|
|
21
|
-
condition: Array<string>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { CSSProperties } from 'react'
|
|
3
|
+
import { IMakeSelect } from './make-select'
|
|
4
|
+
import { IMakeInput } from './make-input'
|
|
5
|
+
import { IMakeTextarea } from './make-textarea'
|
|
6
|
+
import { IMakeToggle } from './make-toggle'
|
|
7
|
+
import { IMakeDescription } from './make-description'
|
|
8
|
+
import { IMakeFieldGroup } from './make-field-group'
|
|
9
|
+
import { IMakeUpload } from './make-upload'
|
|
10
|
+
import { IOption } from './option'
|
|
11
|
+
import { IMakeButton } from './make-button'
|
|
12
|
+
|
|
13
|
+
export type IModalField = IMakeSelect | IMakeInput | IMakeFieldGroup | IMakeTextarea | IMakeToggle | IMakeDescription | IMakeUpload | IMakeButton
|
|
14
|
+
|
|
15
|
+
export type IFormField = IMakeSelect | IMakeInput | IMakeTextarea | IMakeToggle
|
|
16
|
+
|
|
17
|
+
export type IModalRenderCondition = Record<string, Array<string | number | boolean> | undefined>
|
|
18
|
+
|
|
19
|
+
export type IModalLiveDataCondition = {
|
|
20
|
+
action: (data: string, ...args: any[]) => Promise<Array<IOption>>
|
|
21
|
+
condition: Array<string>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IModalConfigProps {
|
|
25
|
+
reservedData?: Record<string, any>
|
|
26
|
+
title: string
|
|
27
|
+
fields: Array<IModalField>
|
|
28
|
+
out: (data: any) => void
|
|
29
|
+
onClose?: () => void
|
|
30
|
+
style?: CSSProperties
|
|
31
|
+
overFlowBody?: string | number
|
|
32
|
+
minHeightBody?: string | number
|
|
33
|
+
useSubmit?: boolean
|
|
34
|
+
actions: {
|
|
35
|
+
containerStyle?: CSSProperties
|
|
36
|
+
cancel?: Omit<IMakeButton, 'elementType'>
|
|
37
|
+
action: Omit<IMakeButton, 'elementType'>
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type IModalConfigLoader<T = any, D = any> = (props: T, action: (modalResult: D) => void) => IModalConfigProps
|
|
42
|
+
|
|
43
|
+
export interface IModal {
|
|
44
|
+
open: boolean
|
|
45
|
+
close: () => void
|
|
46
|
+
config: IModalConfigProps
|
|
47
|
+
}
|
package/src/interfaces/option.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface IOption {
|
|
2
|
-
id: string
|
|
3
|
-
name: string
|
|
1
|
+
export interface IOption {
|
|
2
|
+
id: string
|
|
3
|
+
name: string
|
|
4
4
|
}
|
package/src/interfaces/portal.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
export interface IPortal {
|
|
4
|
-
children: ReactNode
|
|
5
|
-
closeTime: number
|
|
6
|
-
portalOpen: boolean
|
|
7
|
-
portalTag?: string
|
|
8
|
-
}
|
|
1
|
+
import { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface IPortal {
|
|
4
|
+
children: ReactNode
|
|
5
|
+
closeTime: number
|
|
6
|
+
portalOpen: boolean
|
|
7
|
+
portalTag?: string
|
|
8
|
+
}
|