dynamic-modal 1.0.13 → 1.1.4
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 +111 -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 +14 -8
- package/dist/components/make-select/make-select.js +14 -8
- package/dist/components/make-textarea/make-textarea.js +14 -8
- package/dist/components/make-toggle/make-toggle.js +14 -11
- package/dist/components/make-upload/make-upload.js +10 -9
- package/dist/context/component/component-state.d.ts +4 -0
- package/dist/context/component/component-state.js +45 -0
- package/dist/hooks/field-render.js +1 -1
- package/dist/interfaces/component-state.d.ts +27 -0
- package/dist/interfaces/field.d.ts +6 -4
- 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 +5 -2
- 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 +15 -20
- 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 +15 -16
- 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 +27 -21
- package/src/components/make-select/make-select.tsx +25 -24
- package/src/components/make-textarea/make-textarea.tsx +21 -16
- package/src/components/make-toggle/make-toggle.tsx +26 -17
- package/src/components/make-upload/make-upload.tsx +14 -8
- package/src/components/portal/portal.tsx +1 -0
- package/src/context/component/component-state.tsx +18 -0
- package/src/hooks/field-render.ts +6 -5
- package/src/hooks/modal-handler.ts +1 -0
- package/src/interfaces/component-state.ts +33 -0
- package/src/interfaces/field.ts +11 -9
- 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 +5 -2
- 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 +16 -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
package/README-ES.md
CHANGED
|
@@ -6,12 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
Para que `dynamic-modal` funcione correctamente, debes instalar las siguientes dependencias:
|
|
8
8
|
|
|
9
|
-
- React
|
|
10
|
-
- React-DOM 18
|
|
11
|
-
- react-hook-form
|
|
12
|
-
- NextUI
|
|
9
|
+
- React
|
|
13
10
|
|
|
14
|
-
Además, es compatible con **Next.js
|
|
11
|
+
Además, es compatible con **Next.js**.
|
|
15
12
|
|
|
16
13
|
## Instalación
|
|
17
14
|
|
|
@@ -21,17 +18,118 @@ Puedes instalar la librería a través de npm:
|
|
|
21
18
|
npm install dynamic-modal
|
|
22
19
|
```
|
|
23
20
|
|
|
24
|
-
## Configuración para Next.js 14
|
|
25
|
-
|
|
21
|
+
## Configuración para Next.js (14 o 15)
|
|
22
|
+
Define los componentes que seran usados por el modal, crea el archivo y configura todos los componentes del modal. Aqui un ejemplo utilizando HeroUI (anteriormente NextUI):
|
|
26
23
|
|
|
27
24
|
```jsx
|
|
28
|
-
|
|
25
|
+
'use client'
|
|
26
|
+
import { Autocomplete, AutocompleteItem, Button, Input, Select, SelectItem, Switch, Textarea } from "@heroui/react";
|
|
27
|
+
import { IComponentState } from "dynamic-modal/src/interfaces/component-state";
|
|
28
|
+
|
|
29
|
+
export const ModalComponents: IComponentState = {
|
|
30
|
+
ModalButtonCancel: (props) => {
|
|
31
|
+
return (
|
|
32
|
+
<Button
|
|
33
|
+
{...props}
|
|
34
|
+
color={props.color as "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined}
|
|
35
|
+
variant={'bordered'}
|
|
36
|
+
>
|
|
37
|
+
{props.text}
|
|
38
|
+
</Button>
|
|
39
|
+
)
|
|
40
|
+
},
|
|
41
|
+
ModalButtonAction: (props) => {
|
|
42
|
+
return (
|
|
43
|
+
<Button
|
|
44
|
+
{...props}
|
|
45
|
+
color={props.color as "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined}
|
|
46
|
+
variant={'solid'}
|
|
47
|
+
>
|
|
48
|
+
{props.text}
|
|
49
|
+
</Button>)
|
|
50
|
+
},
|
|
51
|
+
Button: ({ text, ...props }) => {
|
|
52
|
+
return (
|
|
53
|
+
<Button
|
|
54
|
+
{...props}
|
|
55
|
+
color={props.color as "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined}
|
|
56
|
+
variant={props.variant as "flat" | "bordered" | "solid" | "light" | "faded" | "shadow" | "ghost" | undefined}
|
|
57
|
+
>
|
|
58
|
+
{text}
|
|
59
|
+
</Button>)
|
|
60
|
+
},
|
|
61
|
+
Input: ({ invalid, error, disabled, onChange, ...props }) => {
|
|
62
|
+
return (
|
|
63
|
+
<Input
|
|
64
|
+
{...props}
|
|
65
|
+
onValueChange={onChange}
|
|
66
|
+
errorMessage={error?.message}
|
|
67
|
+
isInvalid={invalid}
|
|
68
|
+
isDisabled={disabled}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
},
|
|
72
|
+
Select: ({ options, invalid, error, isMulti, isSearch, disabled, onChange, value, ...props }) => {
|
|
73
|
+
return (
|
|
74
|
+
!isSearch ?
|
|
75
|
+
<Select
|
|
76
|
+
{...props}
|
|
77
|
+
selectedKeys={isMulti ? value : [value]}
|
|
78
|
+
onSelectionChange={onChange}
|
|
79
|
+
selectionMode={isMulti ? 'multiple' : 'single'}
|
|
80
|
+
errorMessage={error?.message}
|
|
81
|
+
isInvalid={invalid}
|
|
82
|
+
isDisabled={disabled}
|
|
83
|
+
>
|
|
84
|
+
{options.map((option) => (
|
|
85
|
+
<SelectItem key={option.id}>{option.name}</SelectItem>
|
|
86
|
+
))}
|
|
87
|
+
</Select> :
|
|
88
|
+
<Autocomplete
|
|
89
|
+
{...props}
|
|
90
|
+
selectedKey={value}
|
|
91
|
+
onSelectionChange={onChange}
|
|
92
|
+
errorMessage={error?.message}
|
|
93
|
+
isInvalid={invalid}
|
|
94
|
+
isDisabled={disabled}
|
|
95
|
+
>
|
|
96
|
+
{options.map((item) => (
|
|
97
|
+
<AutocompleteItem key={item.id}>{item.name}</AutocompleteItem>
|
|
98
|
+
))}
|
|
99
|
+
</Autocomplete>
|
|
100
|
+
)
|
|
101
|
+
},
|
|
102
|
+
Textarea: ({ invalid, error, disabled, ...props }) => {
|
|
103
|
+
return (
|
|
104
|
+
<Textarea
|
|
105
|
+
{...props}
|
|
106
|
+
errorMessage={error?.message}
|
|
107
|
+
isInvalid={invalid}
|
|
108
|
+
isDisabled={disabled}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
},
|
|
112
|
+
Toggle: ({ value, onChange, label, invalid, ...props }) => {
|
|
113
|
+
return(
|
|
114
|
+
<Switch {...props} isSelected={value} onValueChange={onChange}>
|
|
115
|
+
{label}
|
|
116
|
+
</Switch>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
En el provider principal de tu aplicación Next.js, importa tus componentes del modal (definidos anteriormente) y envuelve tu aplicación con el componente `ComponentState` para que `dynamic-modal` funcione adecuadamente. Aquí un ejemplo:
|
|
123
|
+
|
|
124
|
+
```jsx
|
|
125
|
+
import { ComponentState } from 'dynamic-modal'
|
|
126
|
+
import { ModalComponents } from "@data/modal-component/modal-component";
|
|
29
127
|
|
|
30
128
|
function Provider({ children }: Readonly<{ children: ReactNode }>) {
|
|
31
129
|
return (
|
|
32
|
-
<
|
|
130
|
+
<ComponentState components={ModalComponents}>
|
|
33
131
|
<Component {...pageProps} />
|
|
34
|
-
</
|
|
132
|
+
</ComponentState>
|
|
35
133
|
);
|
|
36
134
|
}
|
|
37
135
|
|
|
@@ -61,7 +159,7 @@ export default function RootLayout ({
|
|
|
61
159
|
}
|
|
62
160
|
```
|
|
63
161
|
|
|
64
|
-
## Setup for Next.js 13
|
|
162
|
+
## Setup for Next.js 13 o mas antiguo
|
|
65
163
|
Edita el archivo llamado `_document.tsx` y crea el `portal` para el modal (este componente utiliza react portal)
|
|
66
164
|
|
|
67
165
|
```jsx
|
package/README.md
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
# dynamic-modal
|
|
2
2
|
|
|
3
|
+
<<<<<<< README.md
|
|
3
4
|
`dynamic-modal` is a TypeScript library for creating reusable modals in React and Next.js applications. It uses JSON objects to configure the modal structure, eliminating the need to write HTML. This approach simplifies modal creation and customization, allowing you to open and close modals using a custom hook.
|
|
4
5
|
|
|
5
6
|
## Requirements
|
|
6
7
|
|
|
7
8
|
To use `dynamic-modal` properly, ensure you have the following dependencies installed:
|
|
8
9
|
|
|
9
|
-
- React
|
|
10
|
-
- React-DOM 18
|
|
11
|
-
- react-hook-form
|
|
12
|
-
- NextUI
|
|
10
|
+
- React
|
|
13
11
|
|
|
14
|
-
Additionally, `dynamic-modal` is compatible with **Next.js
|
|
12
|
+
Additionally, `dynamic-modal` is compatible with **Next.js**.
|
|
15
13
|
|
|
16
14
|
## Installation
|
|
17
15
|
|
|
@@ -21,17 +19,118 @@ Install the library via npm:
|
|
|
21
19
|
npm install dynamic-modal
|
|
22
20
|
```
|
|
23
21
|
|
|
24
|
-
## Setup for Next.js 14
|
|
25
|
-
|
|
22
|
+
## Setup for Next.js (14 or 15)
|
|
23
|
+
Define your components for use inside modal, create file and configure all modal components. Here´s an example using HeroUI (previously NextUI):
|
|
26
24
|
|
|
27
25
|
```jsx
|
|
28
|
-
|
|
26
|
+
'use client'
|
|
27
|
+
import { Autocomplete, AutocompleteItem, Button, Input, Select, SelectItem, Switch, Textarea } from "@heroui/react";
|
|
28
|
+
import { IComponentState } from "dynamic-modal/src/interfaces/component-state";
|
|
29
|
+
|
|
30
|
+
export const ModalComponents: IComponentState = {
|
|
31
|
+
ModalButtonCancel: (props) => {
|
|
32
|
+
return (
|
|
33
|
+
<Button
|
|
34
|
+
{...props}
|
|
35
|
+
color={props.color as "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined}
|
|
36
|
+
variant={'bordered'}
|
|
37
|
+
>
|
|
38
|
+
{props.text}
|
|
39
|
+
</Button>
|
|
40
|
+
)
|
|
41
|
+
},
|
|
42
|
+
ModalButtonAction: (props) => {
|
|
43
|
+
return (
|
|
44
|
+
<Button
|
|
45
|
+
{...props}
|
|
46
|
+
color={props.color as "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined}
|
|
47
|
+
variant={'solid'}
|
|
48
|
+
>
|
|
49
|
+
{props.text}
|
|
50
|
+
</Button>)
|
|
51
|
+
},
|
|
52
|
+
Button: ({ text, ...props }) => {
|
|
53
|
+
return (
|
|
54
|
+
<Button
|
|
55
|
+
{...props}
|
|
56
|
+
color={props.color as "default" | "primary" | "secondary" | "success" | "warning" | "danger" | undefined}
|
|
57
|
+
variant={props.variant as "flat" | "bordered" | "solid" | "light" | "faded" | "shadow" | "ghost" | undefined}
|
|
58
|
+
>
|
|
59
|
+
{text}
|
|
60
|
+
</Button>)
|
|
61
|
+
},
|
|
62
|
+
Input: ({ invalid, error, disabled, onChange, ...props }) => {
|
|
63
|
+
return (
|
|
64
|
+
<Input
|
|
65
|
+
{...props}
|
|
66
|
+
onValueChange={onChange}
|
|
67
|
+
errorMessage={error?.message}
|
|
68
|
+
isInvalid={invalid}
|
|
69
|
+
isDisabled={disabled}
|
|
70
|
+
/>
|
|
71
|
+
)
|
|
72
|
+
},
|
|
73
|
+
Select: ({ options, invalid, error, isMulti, isSearch, disabled, onChange, value, ...props }) => {
|
|
74
|
+
return (
|
|
75
|
+
!isSearch ?
|
|
76
|
+
<Select
|
|
77
|
+
{...props}
|
|
78
|
+
selectedKeys={isMulti ? value : [value]}
|
|
79
|
+
onSelectionChange={onChange}
|
|
80
|
+
selectionMode={isMulti ? 'multiple' : 'single'}
|
|
81
|
+
errorMessage={error?.message}
|
|
82
|
+
isInvalid={invalid}
|
|
83
|
+
isDisabled={disabled}
|
|
84
|
+
>
|
|
85
|
+
{options.map((option) => (
|
|
86
|
+
<SelectItem key={option.id}>{option.name}</SelectItem>
|
|
87
|
+
))}
|
|
88
|
+
</Select> :
|
|
89
|
+
<Autocomplete
|
|
90
|
+
{...props}
|
|
91
|
+
selectedKey={value}
|
|
92
|
+
onSelectionChange={onChange}
|
|
93
|
+
errorMessage={error?.message}
|
|
94
|
+
isInvalid={invalid}
|
|
95
|
+
isDisabled={disabled}
|
|
96
|
+
>
|
|
97
|
+
{options.map((item) => (
|
|
98
|
+
<AutocompleteItem key={item.id}>{item.name}</AutocompleteItem>
|
|
99
|
+
))}
|
|
100
|
+
</Autocomplete>
|
|
101
|
+
)
|
|
102
|
+
},
|
|
103
|
+
Textarea: ({ invalid, error, disabled, ...props }) => {
|
|
104
|
+
return (
|
|
105
|
+
<Textarea
|
|
106
|
+
{...props}
|
|
107
|
+
errorMessage={error?.message}
|
|
108
|
+
isInvalid={invalid}
|
|
109
|
+
isDisabled={disabled}
|
|
110
|
+
/>
|
|
111
|
+
)
|
|
112
|
+
},
|
|
113
|
+
Toggle: ({ value, onChange, label, invalid, ...props }) => {
|
|
114
|
+
return(
|
|
115
|
+
<Switch {...props} isSelected={value} onValueChange={onChange}>
|
|
116
|
+
{label}
|
|
117
|
+
</Switch>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
In the main provider of your React application, import your modal components (defined previously) and wrap your app with the `ComponentState` component to ensure `dynamic-modal` functions properly. Here’s an example:
|
|
124
|
+
|
|
125
|
+
```jsx
|
|
126
|
+
import { ComponentState } from 'dynamic-modal'
|
|
127
|
+
import { ModalComponents } from "@data/modal-component/modal-component";
|
|
29
128
|
|
|
30
129
|
function Provider({ children }: Readonly<{ children: ReactNode }>) {
|
|
31
130
|
return (
|
|
32
|
-
<
|
|
131
|
+
<ComponentState components={ModalComponents}>
|
|
33
132
|
<Component {...pageProps} />
|
|
34
|
-
</
|
|
133
|
+
</ComponentState>
|
|
35
134
|
);
|
|
36
135
|
}
|
|
37
136
|
|
|
@@ -61,7 +160,7 @@ export default function RootLayout ({
|
|
|
61
160
|
}
|
|
62
161
|
```
|
|
63
162
|
|
|
64
|
-
## Setup for Next.js 13
|
|
163
|
+
## Setup for Next.js 13 and old
|
|
65
164
|
Edit file named `_document.tsx` and define `portal` for modal (this component use react portal)
|
|
66
165
|
|
|
67
166
|
```jsx
|
|
@@ -115,5 +214,4 @@ export default ExampleComponent;
|
|
|
115
214
|
```
|
|
116
215
|
|
|
117
216
|
## Examples
|
|
118
|
-
The examples folder in the repository contains different configuration modes to help you customize your modal.
|
|
119
|
-
|
|
217
|
+
The examples folder in the repository contains different configuration modes to help you customize your modal.
|
|
@@ -1,37 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
'use client';
|
|
35
3
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
4
|
var t = {};
|
|
37
5
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -43,9 +11,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
43
11
|
}
|
|
44
12
|
return t;
|
|
45
13
|
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
46
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
const react_1 =
|
|
48
|
-
const general_1 = require("../../tools/general");
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
49
19
|
const InputUpload = (_a) => {
|
|
50
20
|
var _b;
|
|
51
21
|
var { onChange, readAsArrayBuffer } = _a, props = __rest(_a, ["onChange", "readAsArrayBuffer"]);
|
|
@@ -84,13 +54,9 @@ const InputUpload = (_a) => {
|
|
|
84
54
|
};
|
|
85
55
|
});
|
|
86
56
|
};
|
|
87
|
-
const elementId = (0, react_1.useMemo)(() => {
|
|
88
|
-
var _a;
|
|
89
|
-
return (_a = props.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)();
|
|
90
|
-
}, [props.id]);
|
|
91
57
|
return (react_1.default.createElement("div", { className: 'flex flex-col w-full gap-1 text-center' },
|
|
92
|
-
props.label && react_1.default.createElement("label", { className: "block mb-2 text-sm font-medium text-gray-900 dark:text-white", htmlFor: `file-input-${
|
|
93
|
-
react_1.default.createElement("input", Object.assign({ className: "file:transition-all file:delay-150 block w-full text-sm text-slate-500\n file:mr-4 file:py-2 file:px-4 file:rounded-md\n file:border-0 file:text-sm file:font-semibold\n file:bg-gray-100 file:text-blue-600\n hover:file:bg-blue-700 hover:file:text-white cursor-pointer disabled:cursor-not-allowed", "aria-describedby": `file-input-${
|
|
94
|
-
react_1.default.createElement("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-300 text-start", id: `file-input-${
|
|
58
|
+
props.label && react_1.default.createElement("label", { className: "block mb-2 text-sm font-medium text-gray-900 dark:text-white", htmlFor: `file-input-${props.id}` }, props.label),
|
|
59
|
+
react_1.default.createElement("input", Object.assign({ className: "file:transition-all file:delay-150 block w-full text-sm text-slate-500\n file:mr-4 file:py-2 file:px-4 file:rounded-md\n file:border-0 file:text-sm file:font-semibold\n file:bg-gray-100 file:text-blue-600\n hover:file:bg-blue-700 hover:file:text-white cursor-pointer disabled:cursor-not-allowed", "aria-describedby": `file-input-${props.id}-help`, id: `file-input-${props.id}`, type: "file", onChange: onChangeHandler }, props)),
|
|
60
|
+
react_1.default.createElement("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-300 text-start", id: `file-input-${props.id}-help` }, (_b = props.helpText) === null || _b === void 0 ? void 0 : _b.toUpperCase())));
|
|
95
61
|
};
|
|
96
62
|
exports.default = InputUpload;
|
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
16
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
const react_1 =
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const component_state_1 = require("../../context/component/component-state");
|
|
39
|
+
const general_1 = require("../../tools/general");
|
|
40
|
+
const MakeButton = ({ element }) => {
|
|
41
|
+
const { Button } = (0, react_1.useContext)(component_state_1.ComponentStateContext);
|
|
42
|
+
const elementId = (0, react_1.useMemo)(() => { var _a; return (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(); }, []);
|
|
43
|
+
return (react_1.default.createElement(Button, Object.assign({}, element, { id: elementId })));
|
|
21
44
|
};
|
|
22
45
|
exports.default = MakeButton;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const MakeDescription = ({ element: { text, Icon, containerStyle, textStyle } }) => {
|
|
9
|
+
return (react_1.default.createElement("div", { className: 'flex gap-4 w-full h-auto text-xs text-center p-2 border-1 rounded-md', style: containerStyle },
|
|
10
|
+
Icon && react_1.default.createElement(Icon, null),
|
|
11
|
+
react_1.default.createElement("p", { style: textStyle }, text)));
|
|
12
|
+
};
|
|
13
|
+
exports.default = MakeDescription;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -47,23 +48,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
47
48
|
const react_1 = __importStar(require("react"));
|
|
48
49
|
const react_hook_form_1 = require("react-hook-form");
|
|
49
50
|
const field_render_1 = require("../../hooks/field-render");
|
|
50
|
-
const
|
|
51
|
+
const component_state_1 = require("../../context/component/component-state");
|
|
51
52
|
const general_1 = require("../../tools/general");
|
|
52
53
|
const MakeInput = (_a) => {
|
|
53
54
|
var _b, _c;
|
|
54
|
-
var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), element = __rest(_d, ["validation"]), props = __rest(_a, ["element"]);
|
|
55
|
-
const {
|
|
55
|
+
var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), { enableIf, renderIf } = _d, element = __rest(_d, ["validation", "enableIf", "renderIf"]), props = __rest(_a, ["element"]);
|
|
56
|
+
const { Input } = (0, react_1.useContext)(component_state_1.ComponentStateContext);
|
|
57
|
+
const { render, enable, checkField } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element: Object.assign({ enableIf, renderIf }, element) }));
|
|
58
|
+
const elementId = (0, react_1.useMemo)(() => { var _a; return (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(); }, []);
|
|
56
59
|
(0, react_1.useEffect)(() => {
|
|
57
60
|
const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }));
|
|
58
61
|
return () => subscription.unsubscribe();
|
|
59
62
|
}, [checkField, props]);
|
|
60
63
|
return (render
|
|
61
|
-
? react_1.default.createElement(react_hook_form_1.Controller, { control: props.control, name: element.name, rules: Object.assign({ required
|
|
62
|
-
value:
|
|
64
|
+
? react_1.default.createElement(react_hook_form_1.Controller, { control: props.control, name: element.name, rules: Object.assign({ required: {
|
|
65
|
+
value: required,
|
|
66
|
+
message: (_b = validation.message) !== null && _b !== void 0 ? _b : ''
|
|
67
|
+
}, pattern: validation.regex ? {
|
|
68
|
+
value: validation.regex,
|
|
63
69
|
message: (_c = validation.message) !== null && _c !== void 0 ? _c : ''
|
|
64
|
-
} }, validation), render: ({ field: { onChange, value }, fieldState: { invalid } }) => {
|
|
65
|
-
var _a
|
|
66
|
-
return (react_1.default.createElement(
|
|
70
|
+
} : undefined }, validation), render: ({ field: { onChange, value }, fieldState: { invalid, error } }) => {
|
|
71
|
+
var _a;
|
|
72
|
+
return (react_1.default.createElement(Input, Object.assign({}, element, { id: elementId, onChange: onChange, value: value !== null && value !== void 0 ? value : '', invalid: invalid, error: error, disabled: (_a = element.disabled) !== null && _a !== void 0 ? _a : !enable })));
|
|
67
73
|
} })
|
|
68
74
|
: null);
|
|
69
75
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,22 +49,27 @@ const react_1 = __importStar(require("react"));
|
|
|
48
49
|
const react_hook_form_1 = require("react-hook-form");
|
|
49
50
|
const field_render_1 = require("../../hooks/field-render");
|
|
50
51
|
const general_1 = require("../../tools/general");
|
|
51
|
-
const
|
|
52
|
+
const component_state_1 = require("../../context/component/component-state");
|
|
52
53
|
const MakeSelect = (_a) => {
|
|
53
54
|
var _b, _c;
|
|
54
|
-
var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), element = __rest(_d, ["validation"]), props = __rest(_a, ["element"]);
|
|
55
|
-
const {
|
|
55
|
+
var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), { enableIf, renderIf } = _d, element = __rest(_d, ["validation", "enableIf", "renderIf"]), props = __rest(_a, ["element"]);
|
|
56
|
+
const { Select } = (0, react_1.useContext)(component_state_1.ComponentStateContext);
|
|
57
|
+
const { render, enable, checkField, liveData, liveSearching } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element: Object.assign({ renderIf, enableIf }, element) }));
|
|
58
|
+
const elementId = (0, react_1.useMemo)(() => { var _a; return (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(); }, []);
|
|
56
59
|
(0, react_1.useEffect)(() => {
|
|
57
60
|
const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }));
|
|
58
61
|
return () => subscription.unsubscribe();
|
|
59
62
|
}, [checkField, props, props.watch]);
|
|
60
63
|
return (render
|
|
61
|
-
? react_1.default.createElement(react_hook_form_1.Controller, { control: props.control, name: element.name, rules: Object.assign({ required
|
|
62
|
-
value:
|
|
64
|
+
? react_1.default.createElement(react_hook_form_1.Controller, { control: props.control, name: element.name, rules: Object.assign({ required: {
|
|
65
|
+
value: required,
|
|
66
|
+
message: (_b = validation.message) !== null && _b !== void 0 ? _b : ''
|
|
67
|
+
}, pattern: validation.regex ? {
|
|
68
|
+
value: validation.regex,
|
|
63
69
|
message: (_c = validation.message) !== null && _c !== void 0 ? _c : ''
|
|
64
|
-
} }, validation), render: ({ field: { onChange, value }, fieldState: { invalid } }) => {
|
|
65
|
-
var _a, _b
|
|
66
|
-
return (react_1.default.createElement(
|
|
70
|
+
} : undefined }, validation), render: ({ field: { onChange, value }, fieldState: { invalid, error } }) => {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
return (react_1.default.createElement(Select, Object.assign({}, element, { id: elementId, onChange: onChange, value: value, invalid: invalid, error: error, disabled: (_a = element.disabled) !== null && _a !== void 0 ? _a : !enable, liveSearching: liveSearching, options: liveData || ((_b = element.options) !== null && _b !== void 0 ? _b : []) })));
|
|
67
73
|
} })
|
|
68
74
|
: react_1.default.createElement(react_1.default.Fragment, null));
|
|
69
75
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
4
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,22 +49,27 @@ const react_1 = __importStar(require("react"));
|
|
|
48
49
|
const react_hook_form_1 = require("react-hook-form");
|
|
49
50
|
const field_render_1 = require("../../hooks/field-render");
|
|
50
51
|
const general_1 = require("../../tools/general");
|
|
51
|
-
const
|
|
52
|
+
const component_state_1 = require("../../context/component/component-state");
|
|
52
53
|
const MakeTextarea = (_a) => {
|
|
53
54
|
var _b, _c;
|
|
54
|
-
var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), element = __rest(_d, ["validation"]), props = __rest(_a, ["element"]);
|
|
55
|
-
const {
|
|
55
|
+
var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), { enableIf, renderIf } = _d, element = __rest(_d, ["validation", "enableIf", "renderIf"]), props = __rest(_a, ["element"]);
|
|
56
|
+
const { Textarea } = (0, react_1.useContext)(component_state_1.ComponentStateContext);
|
|
57
|
+
const { render, enable, checkField } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element: Object.assign({ enableIf, renderIf }, element) }));
|
|
58
|
+
const elementId = (0, react_1.useMemo)(() => { var _a; return (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(); }, []);
|
|
56
59
|
(0, react_1.useEffect)(() => {
|
|
57
60
|
const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }));
|
|
58
61
|
return () => subscription.unsubscribe();
|
|
59
62
|
}, [checkField, props, props.watch]);
|
|
60
63
|
return (render
|
|
61
|
-
? react_1.default.createElement(react_hook_form_1.Controller, { name: element.name, control: props.control, rules: Object.assign({ required
|
|
62
|
-
value:
|
|
64
|
+
? react_1.default.createElement(react_hook_form_1.Controller, { name: element.name, control: props.control, rules: Object.assign({ required: {
|
|
65
|
+
value: required,
|
|
66
|
+
message: (_b = validation.message) !== null && _b !== void 0 ? _b : ''
|
|
67
|
+
}, pattern: validation.regex ? {
|
|
68
|
+
value: validation.regex,
|
|
63
69
|
message: (_c = validation.message) !== null && _c !== void 0 ? _c : ''
|
|
64
|
-
} }, validation), render: ({ field: { onChange, value }, fieldState: { invalid } }) => {
|
|
65
|
-
var _a
|
|
66
|
-
return (react_1.default.createElement(
|
|
70
|
+
} : undefined }, validation), render: ({ field: { onChange, value }, fieldState: { invalid, error } }) => {
|
|
71
|
+
var _a;
|
|
72
|
+
return (react_1.default.createElement(Textarea, Object.assign({}, element, { id: elementId, onChange: onChange, value: value !== null && value !== void 0 ? value : '', invalid: invalid, error: error, disabled: (_a = element.disabled) !== null && _a !== void 0 ? _a : !enable })));
|
|
67
73
|
} })
|
|
68
74
|
: null);
|
|
69
75
|
};
|