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.
Files changed (92) hide show
  1. package/README-ES.md +109 -11
  2. package/README.md +111 -13
  3. package/dist/components/input-upload/input-upload.js +8 -42
  4. package/dist/components/make-button/make-button.js +41 -18
  5. package/dist/components/make-description/make-description.d.ts +4 -0
  6. package/dist/components/make-description/make-description.js +13 -0
  7. package/dist/components/make-input/make-input.d.ts +1 -1
  8. package/dist/components/make-input/make-input.js +14 -8
  9. package/dist/components/make-select/make-select.js +14 -8
  10. package/dist/components/make-textarea/make-textarea.js +14 -8
  11. package/dist/components/make-toggle/make-toggle.js +14 -11
  12. package/dist/components/make-upload/make-upload.js +10 -9
  13. package/dist/context/component/component-state.d.ts +4 -0
  14. package/dist/context/component/component-state.js +45 -0
  15. package/dist/hooks/field-render.js +1 -1
  16. package/dist/interfaces/component-state.d.ts +27 -0
  17. package/dist/interfaces/field.d.ts +6 -4
  18. package/dist/interfaces/input-upload.d.ts +1 -1
  19. package/dist/interfaces/make-button.d.ts +5 -6
  20. package/dist/interfaces/make-description.d.ts +12 -0
  21. package/dist/interfaces/make-field-group.d.ts +1 -0
  22. package/dist/interfaces/{make-field.d.ts → make-input.d.ts} +2 -2
  23. package/dist/interfaces/make-select.d.ts +5 -2
  24. package/dist/interfaces/make-textarea.d.ts +1 -1
  25. package/dist/interfaces/make-toggle.d.ts +1 -1
  26. package/dist/interfaces/make-upload.d.ts +1 -1
  27. package/dist/interfaces/modal.d.ts +15 -20
  28. package/dist/modal.js +42 -35
  29. package/dist/tools/general.js +1 -0
  30. package/examples/enable-if.ts +5 -7
  31. package/examples/live-data.ts +7 -9
  32. package/examples/render-if.ts +6 -8
  33. package/examples/simple.ts +6 -8
  34. package/index.ts +4 -2
  35. package/package.json +15 -16
  36. package/src/components/input-upload/input-upload.tsx +7 -12
  37. package/src/components/make-button/make-button.tsx +11 -10
  38. package/src/components/make-description/make-description.tsx +15 -0
  39. package/src/components/make-input/make-input.tsx +27 -21
  40. package/src/components/make-select/make-select.tsx +25 -24
  41. package/src/components/make-textarea/make-textarea.tsx +21 -16
  42. package/src/components/make-toggle/make-toggle.tsx +26 -17
  43. package/src/components/make-upload/make-upload.tsx +14 -8
  44. package/src/components/portal/portal.tsx +1 -0
  45. package/src/context/component/component-state.tsx +18 -0
  46. package/src/hooks/field-render.ts +6 -5
  47. package/src/hooks/modal-handler.ts +1 -0
  48. package/src/interfaces/component-state.ts +33 -0
  49. package/src/interfaces/field.ts +11 -9
  50. package/src/interfaces/input-upload.ts +11 -11
  51. package/src/interfaces/make-button.ts +10 -11
  52. package/src/interfaces/make-description.ts +14 -0
  53. package/src/interfaces/make-field-group.ts +5 -4
  54. package/src/interfaces/{make-field.ts → make-input.ts} +2 -2
  55. package/src/interfaces/make-select.ts +5 -2
  56. package/src/interfaces/make-textarea.ts +1 -1
  57. package/src/interfaces/make-toggle.ts +2 -2
  58. package/src/interfaces/make-upload.ts +7 -7
  59. package/src/interfaces/modal.ts +16 -21
  60. package/src/interfaces/option.ts +2 -2
  61. package/src/interfaces/portal.ts +4 -4
  62. package/src/modal.tsx +43 -53
  63. package/src/tools/general.ts +2 -0
  64. package/.idea/dynamic-modal.iml +0 -12
  65. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  66. package/.idea/modules.xml +0 -8
  67. package/.idea/vcs.xml +0 -6
  68. package/dist/components/make-autocomplete/make-autocomplete.d.ts +0 -4
  69. package/dist/components/make-autocomplete/make-autocomplete.js +0 -70
  70. package/dist/components/make-multi-select/make-multi-select.d.ts +0 -4
  71. package/dist/components/make-multi-select/make-multi-select.js +0 -70
  72. package/dist/components/make-text/make-text.d.ts +0 -4
  73. package/dist/components/make-text/make-text.js +0 -11
  74. package/dist/components/make-title/make-title.d.ts +0 -4
  75. package/dist/components/make-title/make-title.js +0 -10
  76. package/dist/interfaces/make-autocomplete.d.ts +0 -11
  77. package/dist/interfaces/make-multi-select.d.ts +0 -12
  78. package/dist/interfaces/make-text.d.ts +0 -10
  79. package/dist/interfaces/make-text.js +0 -2
  80. package/dist/interfaces/make-title.d.ts +0 -3
  81. package/dist/interfaces/make-title.js +0 -2
  82. package/src/components/make-autocomplete/make-autocomplete.tsx +0 -54
  83. package/src/components/make-multi-select/make-multi-select.tsx +0 -56
  84. package/src/components/make-text/make-text.tsx +0 -16
  85. package/src/components/make-title/make-title.tsx +0 -12
  86. package/src/interfaces/make-autocomplete.ts +0 -13
  87. package/src/interfaces/make-multi-select.ts +0 -14
  88. package/src/interfaces/make-text.ts +0 -12
  89. package/src/interfaces/make-title.ts +0 -3
  90. /package/dist/interfaces/{make-autocomplete.js → component-state.js} +0 -0
  91. /package/dist/interfaces/{make-field.js → make-description.js} +0 -0
  92. /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 18
10
- - React-DOM 18
11
- - react-hook-form
12
- - NextUI
9
+ - React
13
10
 
14
- Además, es compatible con **Next.js 14**.
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
- En el provider principal de tu aplicación Next.js, debes envolver tu aplicación con el componente `NextUIProvider` para que `dynamic-modal` funcione adecuadamente. Aquí un ejemplo:
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
- import { NextUIProvider } from '@nextui-org/react';
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
- <NextUIProvider>
130
+ <ComponentState components={ModalComponents}>
33
131
  <Component {...pageProps} />
34
- </NextUIProvider>
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 18
10
- - React-DOM 18
11
- - react-hook-form
12
- - NextUI
10
+ - React
13
11
 
14
- Additionally, `dynamic-modal` is compatible with **Next.js 14**.
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
- In the main provider of your Next.js application, wrap your app with the `NextUIProvider` component to ensure `dynamic-modal` functions properly. Heres an example:
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
- import { NextUIProvider } from '@nextui-org/react';
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
- <NextUIProvider>
131
+ <ComponentState components={ModalComponents}>
33
132
  <Component {...pageProps} />
34
- </NextUIProvider>
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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
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 = __importStar(require("react"));
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-${elementId}` }, props.label),
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-${elementId}-help`, id: `file-input-${elementId}`, type: "file", onChange: onChangeHandler }, props)),
94
- react_1.default.createElement("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-300 text-start", id: `file-input-${elementId}-help` }, (_b = props.helpText) === null || _b === void 0 ? void 0 : _b.toUpperCase())));
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
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 = __importDefault(require("react"));
18
- const MakeButton = (_a) => {
19
- var _b = _a.element, { text } = _b, element = __rest(_b, ["text"]);
20
- return (react_1.default.createElement("button", Object.assign({ className: 'transition-all delay-100 hover:translate-y-1 bg-blue-500 text-white hover:bg-blue-700 rounded w-11/12 h-[40px] p-2' }, element), text));
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,4 @@
1
+ import { FC } from 'react';
2
+ import { IMakeDescriptionProps } from '../../interfaces/make-description';
3
+ declare const MakeDescription: FC<IMakeDescriptionProps>;
4
+ export default MakeDescription;
@@ -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,4 @@
1
1
  import { FC } from 'react';
2
- import { IMakeInputProps } from '../../interfaces/make-field';
2
+ import { IMakeInputProps } from '../../interfaces/make-input';
3
3
  declare const MakeInput: FC<IMakeInputProps>;
4
4
  export default MakeInput;
@@ -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 react_2 = require("@nextui-org/react");
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 { render, enable, checkField } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element }));
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, pattern: {
62
- value: (_b = validation.regex) !== null && _b !== void 0 ? _b : /(.*)/,
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, _c;
66
- return (react_1.default.createElement(react_2.Input, Object.assign({ size: 'sm' }, element, { id: (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(), onChange: onChange, value: value !== null && value !== void 0 ? value : '', color: invalid ? 'danger' : undefined, isInvalid: invalid, errorMessage: invalid ? ((_b = validation.message) !== null && _b !== void 0 ? _b : '') : undefined, isDisabled: (_c = element.disabled) !== null && _c !== void 0 ? _c : !enable })));
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 react_2 = require("@nextui-org/react");
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 { render, enable, checkField, liveData, liveSearching } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element }));
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, pattern: {
62
- value: (_b = validation.regex) !== null && _b !== void 0 ? _b : /(.*)/,
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, _c, _d;
66
- return (react_1.default.createElement(react_2.Select, Object.assign({ size: 'sm' }, element, { id: (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(), onChange: onChange, label: liveSearching ? 'Loading...' : element.label, selectedKeys: [value], color: invalid ? 'danger' : undefined, isInvalid: invalid, errorMessage: invalid ? ((_b = validation.message) !== null && _b !== void 0 ? _b : '') : undefined, isDisabled: (_c = element.disabled) !== null && _c !== void 0 ? _c : !enable }), (liveData || ((_d = element.options) !== null && _d !== void 0 ? _d : [])).map((opt) => (react_1.default.createElement(react_2.SelectItem, { key: opt.id, value: opt.id }, opt.name)))));
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 react_2 = require("@nextui-org/react");
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 { render, enable, checkField } = (0, field_render_1.useFieldRender)(Object.assign(Object.assign({}, props), { element }));
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, pattern: {
62
- value: (_b = validation.regex) !== null && _b !== void 0 ? _b : /(.*)/,
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, _b, _c;
66
- return (react_1.default.createElement(react_2.Textarea, Object.assign({}, element, { disableAutosize: true, id: (_a = element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(), onChange: onChange, label: element.label, value: value !== null && value !== void 0 ? value : '', color: invalid ? 'danger' : undefined, isInvalid: invalid, errorMessage: invalid ? ((_b = validation.message) !== null && _b !== void 0 ? _b : '') : undefined, isDisabled: (_c = element.disabled) !== null && _c !== void 0 ? _c : !enable })));
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
  };