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.
Files changed (52) hide show
  1. package/README-ES.md +217 -217
  2. package/README.md +216 -215
  3. package/dist/components/input-upload/input-upload.js +1 -1
  4. package/dist/components/make-button/make-button.js +7 -17
  5. package/dist/components/make-input/make-input.js +9 -19
  6. package/dist/components/make-select/make-select.js +9 -19
  7. package/dist/components/make-textarea/make-textarea.js +9 -19
  8. package/dist/components/make-toggle/make-toggle.js +9 -19
  9. package/dist/components/make-upload/make-upload.js +2 -2
  10. package/dist/components/portal/portal.js +7 -17
  11. package/dist/context/component/component-state.js +7 -17
  12. package/dist/hooks/field-render.js +1 -1
  13. package/dist/interfaces/field.d.ts +3 -2
  14. package/dist/interfaces/make-select.d.ts +2 -1
  15. package/dist/interfaces/modal.d.ts +2 -1
  16. package/dist/modal.js +38 -19
  17. package/eslint.config.mjs +14 -14
  18. package/examples/enable-if.ts +127 -127
  19. package/examples/live-data.ts +61 -61
  20. package/examples/render-if.ts +128 -128
  21. package/examples/simple.ts +74 -74
  22. package/index.ts +5 -5
  23. package/package.json +46 -47
  24. package/src/components/input-upload/input-upload.tsx +67 -67
  25. package/src/components/make-button/make-button.tsx +18 -18
  26. package/src/components/make-description/make-description.tsx +15 -15
  27. package/src/components/make-input/make-input.tsx +53 -53
  28. package/src/components/make-select/make-select.tsx +55 -55
  29. package/src/components/make-textarea/make-textarea.tsx +53 -53
  30. package/src/components/make-toggle/make-toggle.tsx +53 -53
  31. package/src/components/make-upload/make-upload.tsx +40 -40
  32. package/src/components/portal/portal.tsx +37 -37
  33. package/src/context/component/component-state.tsx +17 -17
  34. package/src/hooks/field-render.ts +109 -109
  35. package/src/hooks/modal-handler.ts +38 -38
  36. package/src/interfaces/component-state.ts +33 -33
  37. package/src/interfaces/field.ts +37 -36
  38. package/src/interfaces/input-upload.ts +21 -21
  39. package/src/interfaces/make-button.ts +19 -19
  40. package/src/interfaces/make-description.ts +14 -14
  41. package/src/interfaces/make-field-group.ts +14 -14
  42. package/src/interfaces/make-input.ts +14 -14
  43. package/src/interfaces/make-select.ts +15 -14
  44. package/src/interfaces/make-textarea.ts +11 -11
  45. package/src/interfaces/make-toggle.ts +9 -9
  46. package/src/interfaces/make-upload.ts +14 -14
  47. package/src/interfaces/modal.ts +47 -45
  48. package/src/interfaces/option.ts +3 -3
  49. package/src/interfaces/portal.ts +8 -8
  50. package/src/modal.tsx +196 -164
  51. package/src/tools/general.ts +8 -8
  52. package/tsconfig.json +13 -13
package/README.md CHANGED
@@ -1,216 +1,217 @@
1
- # dynamic-modal
2
-
3
- `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
- ## Requirements
6
-
7
- To use `dynamic-modal` properly, ensure you have the following dependencies installed:
8
-
9
- - React
10
-
11
- Additionally, `dynamic-modal` is compatible with **Next.js**.
12
-
13
- ## Installation
14
-
15
- Install the library via npm:
16
-
17
- ```bash
18
- npm install dynamic-modal
19
- ```
20
-
21
- ## Setup for Next.js (14 or 15)
22
- Define your components for use inside modal, create file and configure all modal components. Here´s an example using HeroUI (previously NextUI):
23
-
24
- ```jsx
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
- 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:
123
-
124
- ```jsx
125
- import { ComponentState } from 'dynamic-modal'
126
- import { ModalComponents } from "@data/modal-component/modal-component";
127
-
128
- function Provider({ children }: Readonly<{ children: ReactNode }>) {
129
- return (
130
- <ComponentState components={ModalComponents}>
131
- <Component {...pageProps} />
132
- </ComponentState>
133
- );
134
- }
135
-
136
- export default Provider;
137
-
138
- ```
139
- In the root layout define `portal` for modal (this component use react portal)
140
-
141
- ```jsx
142
- //imports...
143
-
144
- export default function RootLayout ({
145
- children
146
- }: Readonly<{
147
- children: ReactNode;
148
- }>) {
149
- return (
150
- <html lang="en">
151
- <body className={inter.className}>
152
- <Provider>
153
- {children}
154
- </Provider>
155
- <div id='modal-portal'/>
156
- </body>
157
- </html>
158
- )
159
- }
160
- ```
161
-
162
- ## Setup for Next.js 13 and old
163
- Edit file named `_document.tsx` and define `portal` for modal (this component use react portal)
164
-
165
- ```jsx
166
- import { Html, Head, Main, NextScript } from 'next/document'
167
-
168
- export default function Document () {
169
- return (
170
- <Html>
171
- <Head />
172
- <body>
173
- <Main />
174
- <div id='modal-portal'/>
175
- <NextScript />
176
- </body>
177
- </Html>
178
- )
179
- }
180
- ```
181
-
182
- ## Usage
183
- To control the modal’s open and close states, use the `useModalHandler` custom hook and call `openModal` whenever you need to display the modal.
184
-
185
- ```jsx
186
- import { useModalHandler, DynamicModal } from 'dynamic-modal';
187
- import { Button } from '@nextui-org/react';
188
- //Create your modal, import and use
189
- import testModal from '@modal-config/test';
190
-
191
- function ExampleComponent() {
192
- const { openModal, modalProps } = useModalHandler();
193
-
194
- return (
195
- <>
196
- <Button
197
- onClick={() => {
198
- openModal(testModal.default({}, (data) => {
199
- console.log('modal data', data);
200
- }));
201
- }}
202
- >
203
- Open modal
204
- </Button>
205
-
206
- <DynamicModal {...modalProps} />
207
- </>
208
- );
209
- }
210
-
211
- export default ExampleComponent;
212
-
213
- ```
214
-
215
- ## Examples
1
+ # dynamic-modal
2
+
3
+ <<<<<<< README.md
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.
5
+
6
+ ## Requirements
7
+
8
+ To use `dynamic-modal` properly, ensure you have the following dependencies installed:
9
+
10
+ - React
11
+
12
+ Additionally, `dynamic-modal` is compatible with **Next.js**.
13
+
14
+ ## Installation
15
+
16
+ Install the library via npm:
17
+
18
+ ```bash
19
+ npm install dynamic-modal
20
+ ```
21
+
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):
24
+
25
+ ```jsx
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"
128
+
129
+ function Provider({ children }: Readonly<{ children: ReactNode }>) {
130
+ return (
131
+ <ComponentState components={ModalComponents}>
132
+ <Component {...pageProps} />
133
+ </ComponentState>
134
+ )
135
+ }
136
+
137
+ export default Provider
138
+
139
+ ```
140
+ In the root layout define `portal` for modal (this component use react portal)
141
+
142
+ ```jsx
143
+ //imports...
144
+
145
+ export default function RootLayout ({
146
+ children
147
+ }: Readonly<{
148
+ children: ReactNode
149
+ }>) {
150
+ return (
151
+ <html lang="en">
152
+ <body className={inter.className}>
153
+ <Provider>
154
+ {children}
155
+ </Provider>
156
+ <div id='modal-portal'/>
157
+ </body>
158
+ </html>
159
+ )
160
+ }
161
+ ```
162
+
163
+ ## Setup for Next.js 13 and old
164
+ Edit file named `_document.tsx` and define `portal` for modal (this component use react portal)
165
+
166
+ ```jsx
167
+ import { Html, Head, Main, NextScript } from 'next/document'
168
+
169
+ export default function Document () {
170
+ return (
171
+ <Html>
172
+ <Head />
173
+ <body>
174
+ <Main />
175
+ <div id='modal-portal'/>
176
+ <NextScript />
177
+ </body>
178
+ </Html>
179
+ )
180
+ }
181
+ ```
182
+
183
+ ## Usage
184
+ To control the modal’s open and close states, use the `useModalHandler` custom hook and call `openModal` whenever you need to display the modal.
185
+
186
+ ```jsx
187
+ import { useModalHandler, DynamicModal } from 'dynamic-modal'
188
+ import { Button } from '@nextui-org/react'
189
+ //Create your modal, import and use
190
+ import testModal from '@modal-config/test'
191
+
192
+ function ExampleComponent() {
193
+ const { openModal, modalProps } = useModalHandler()
194
+
195
+ return (
196
+ <>
197
+ <Button
198
+ onClick={() => {
199
+ openModal(testModal.default({}, (data) => {
200
+ console.log('modal data', data)
201
+ }))
202
+ }}
203
+ >
204
+ Open modal
205
+ </Button>
206
+
207
+ <DynamicModal {...modalProps} />
208
+ </>
209
+ )
210
+ }
211
+
212
+ export default ExampleComponent
213
+
214
+ ```
215
+
216
+ ## Examples
216
217
  The examples folder in the repository contains different configuration modes to help you customize your modal.
@@ -56,7 +56,7 @@ const InputUpload = (_a) => {
56
56
  };
57
57
  return (react_1.default.createElement("div", { className: 'flex flex-col w-full gap-1 text-center' },
58
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)),
59
+ react_1.default.createElement("input", Object.assign({ className: "file:transition-all file:delay-150 block w-full text-sm text-slate-500\r\n file:mr-4 file:py-2 file:px-4 file:rounded-md\r\n file:border-0 file:text-sm file:font-semibold\r\n file:bg-gray-100 file:text-blue-600\r\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
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())));
61
61
  };
62
62
  exports.default = InputUpload;
@@ -16,23 +16,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
16
16
  }) : function(o, v) {
17
17
  o["default"] = v;
18
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
- })();
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
36
26
  Object.defineProperty(exports, "__esModule", { value: true });
37
27
  const react_1 = __importStar(require("react"));
38
28
  const component_state_1 = require("../../context/component/component-state");
@@ -16,23 +16,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
16
16
  }) : function(o, v) {
17
17
  o["default"] = v;
18
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
- })();
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
36
26
  var __rest = (this && this.__rest) || function (s, e) {
37
27
  var t = {};
38
28
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -52,9 +42,9 @@ const component_state_1 = require("../../context/component/component-state");
52
42
  const general_1 = require("../../tools/general");
53
43
  const MakeInput = (_a) => {
54
44
  var _b, _c;
55
- var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), element = __rest(_d, ["validation"]), props = __rest(_a, ["element"]);
45
+ 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
46
  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 }));
47
+ const { render, enable, checkField } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element: Object.assign({ enableIf, renderIf }, element) }));
58
48
  const elementId = (0, react_1.useMemo)(() => { var _a; return (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(); }, []);
59
49
  (0, react_1.useEffect)(() => {
60
50
  const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }));
@@ -16,23 +16,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
16
16
  }) : function(o, v) {
17
17
  o["default"] = v;
18
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
- })();
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
36
26
  var __rest = (this && this.__rest) || function (s, e) {
37
27
  var t = {};
38
28
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -52,9 +42,9 @@ const general_1 = require("../../tools/general");
52
42
  const component_state_1 = require("../../context/component/component-state");
53
43
  const MakeSelect = (_a) => {
54
44
  var _b, _c;
55
- var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), element = __rest(_d, ["validation"]), props = __rest(_a, ["element"]);
45
+ 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
46
  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 }));
47
+ const { render, enable, checkField, liveData, liveSearching } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element: Object.assign({ renderIf, enableIf }, element) }));
58
48
  const elementId = (0, react_1.useMemo)(() => { var _a; return (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(); }, []);
59
49
  (0, react_1.useEffect)(() => {
60
50
  const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }));
@@ -16,23 +16,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
16
16
  }) : function(o, v) {
17
17
  o["default"] = v;
18
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
- })();
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
36
26
  var __rest = (this && this.__rest) || function (s, e) {
37
27
  var t = {};
38
28
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -52,9 +42,9 @@ const general_1 = require("../../tools/general");
52
42
  const component_state_1 = require("../../context/component/component-state");
53
43
  const MakeTextarea = (_a) => {
54
44
  var _b, _c;
55
- var _d = _a.element, _e = _d.validation, { required } = _e, validation = __rest(_e, ["required"]), element = __rest(_d, ["validation"]), props = __rest(_a, ["element"]);
45
+ 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
46
  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 }));
47
+ const { render, enable, checkField } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element: Object.assign({ enableIf, renderIf }, element) }));
58
48
  const elementId = (0, react_1.useMemo)(() => { var _a; return (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(); }, []);
59
49
  (0, react_1.useEffect)(() => {
60
50
  const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }));