@innovardix-com-mx/capi-ui 0.1.2 → 0.2.0
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.md +22 -75
- package/dist/capi-ui.d.ts +4 -0
- package/dist/capi-ui.js +3 -3
- package/dist/capi-ui.umd.cjs +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -49,19 +49,25 @@
|
|
|
49
49
|
### Usando npm
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
|
-
npm install capi-ui
|
|
52
|
+
npm install @innovardix-com-mx/capi-ui
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
### Usando pnpm
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
pnpm install capi-ui
|
|
58
|
+
pnpm install @innovardix-com-mx/capi-ui
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
o
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pnpm add @innovardix-com-mx/capi-ui
|
|
59
65
|
```
|
|
60
66
|
|
|
61
67
|
### Usando yarn
|
|
62
68
|
|
|
63
69
|
```bash
|
|
64
|
-
yarn add capi-ui
|
|
70
|
+
yarn add @innovardix-com-mx/capi-ui
|
|
65
71
|
```
|
|
66
72
|
|
|
67
73
|
## 📚 Peer Dependencies
|
|
@@ -89,7 +95,7 @@ npm install antd axios dayjs react react-dom
|
|
|
89
95
|
No olvides importar los estilos CSS en tu aplicación:
|
|
90
96
|
|
|
91
97
|
```tsx
|
|
92
|
-
import 'capi-ui/dist/style.css';
|
|
98
|
+
import '@innovardix-com-mx/capi-ui/dist/style.css';
|
|
93
99
|
```
|
|
94
100
|
|
|
95
101
|
## 🧩 Componentes Principales
|
|
@@ -99,7 +105,7 @@ import 'capi-ui/dist/style.css';
|
|
|
99
105
|
Componente completo CRUD con tabla, formulario modal y acciones personalizables.
|
|
100
106
|
|
|
101
107
|
```tsx
|
|
102
|
-
import { DynamicCrud } from 'capi-ui';
|
|
108
|
+
import { DynamicCrud } from '@innovardix-com-mx/capi-ui';
|
|
103
109
|
|
|
104
110
|
<DynamicCrud
|
|
105
111
|
title="Gestión de Usuarios"
|
|
@@ -124,7 +130,7 @@ import { DynamicCrud } from 'capi-ui';
|
|
|
124
130
|
Formulario dinámico generado a partir de configuración JSON.
|
|
125
131
|
|
|
126
132
|
```tsx
|
|
127
|
-
import { DynamicForm } from 'capi-ui';
|
|
133
|
+
import { DynamicForm } from '@innovardix-com-mx/capi-ui';
|
|
128
134
|
|
|
129
135
|
<DynamicForm
|
|
130
136
|
mode="create"
|
|
@@ -146,7 +152,7 @@ import { DynamicForm } from 'capi-ui';
|
|
|
146
152
|
Tabla configurable con búsqueda, filtros, paginación y exportación.
|
|
147
153
|
|
|
148
154
|
```tsx
|
|
149
|
-
import { DynamicTable } from 'capi-ui';
|
|
155
|
+
import { DynamicTable } from '@innovardix-com-mx/capi-ui';
|
|
150
156
|
|
|
151
157
|
<DynamicTable
|
|
152
158
|
title="Lista de Productos"
|
|
@@ -174,7 +180,7 @@ import { DynamicTable } from 'capi-ui';
|
|
|
174
180
|
Botón versátil con presets, variantes de color e iconos.
|
|
175
181
|
|
|
176
182
|
```tsx
|
|
177
|
-
import { Btn } from 'capi-ui';
|
|
183
|
+
import { Btn } from '@innovardix-com-mx/capi-ui';
|
|
178
184
|
|
|
179
185
|
// Botón con preset
|
|
180
186
|
<Btn preset="save" variant="success">Guardar</Btn>
|
|
@@ -199,7 +205,7 @@ import { Btn } from 'capi-ui';
|
|
|
199
205
|
Sistema de gestión de permisos basado en roles.
|
|
200
206
|
|
|
201
207
|
```tsx
|
|
202
|
-
import { PermissionsProvider, usePermissions } from 'capi-ui';
|
|
208
|
+
import { PermissionsProvider, usePermissions } from '@innovardix-com-mx/capi-ui';
|
|
203
209
|
|
|
204
210
|
// Configurar permisos
|
|
205
211
|
const permissionsConfig = {
|
|
@@ -232,7 +238,7 @@ function UserActions() {
|
|
|
232
238
|
Modal para carga masiva de datos con validación.
|
|
233
239
|
|
|
234
240
|
```tsx
|
|
235
|
-
import { BulkUploadModal } from 'capi-ui';
|
|
241
|
+
import { BulkUploadModal } from '@innovardix-com-mx/capi-ui';
|
|
236
242
|
|
|
237
243
|
<BulkUploadModal
|
|
238
244
|
title="Importar Usuarios"
|
|
@@ -256,7 +262,7 @@ import { BulkUploadModal } from 'capi-ui';
|
|
|
256
262
|
Campo de formulario compartido con validación y tipos múltiples.
|
|
257
263
|
|
|
258
264
|
```tsx
|
|
259
|
-
import { SharedField } from 'capi-ui';
|
|
265
|
+
import { SharedField } from '@innovardix-com-mx/capi-ui';
|
|
260
266
|
|
|
261
267
|
<SharedField
|
|
262
268
|
name="username"
|
|
@@ -279,7 +285,7 @@ import { SharedField } from 'capi-ui';
|
|
|
279
285
|
Hook para operaciones CRUD con React Query integrado.
|
|
280
286
|
|
|
281
287
|
```tsx
|
|
282
|
-
import { useCrudOperations } from 'capi-ui';
|
|
288
|
+
import { useCrudOperations } from '@innovardix-com-mx/capi-ui';
|
|
283
289
|
|
|
284
290
|
function UserManagement() {
|
|
285
291
|
const {
|
|
@@ -311,7 +317,7 @@ function UserManagement() {
|
|
|
311
317
|
Hook wrapper de React Query con configuración predeterminada.
|
|
312
318
|
|
|
313
319
|
```tsx
|
|
314
|
-
import { useFetchQuery } from 'capi-ui';
|
|
320
|
+
import { useFetchQuery } from '@innovardix-com-mx/capi-ui';
|
|
315
321
|
|
|
316
322
|
const { data, isLoading, error } = useFetchQuery({
|
|
317
323
|
queryKey: ['users'],
|
|
@@ -328,7 +334,7 @@ const { data, isLoading, error } = useFetchQuery({
|
|
|
328
334
|
Hook para mostrar notificaciones del sistema.
|
|
329
335
|
|
|
330
336
|
```tsx
|
|
331
|
-
import { openNotification } from 'capi-ui';
|
|
337
|
+
import { openNotification } from '@innovardix-com-mx/capi-ui';
|
|
332
338
|
|
|
333
339
|
openNotification('success', 'Operación exitosa', 'Los datos se guardaron correctamente');
|
|
334
340
|
openNotification('error', 'Error', 'No se pudo completar la operación');
|
|
@@ -341,7 +347,7 @@ openNotification('info', 'Información', 'Proceso en curso');
|
|
|
341
347
|
Hook para manejar operaciones asíncronas.
|
|
342
348
|
|
|
343
349
|
```tsx
|
|
344
|
-
import { useAsync } from 'capi-ui';
|
|
350
|
+
import { useAsync } from '@innovardix-com-mx/capi-ui';
|
|
345
351
|
|
|
346
352
|
function DataDisplay() {
|
|
347
353
|
const { data, loading, error } = useAsync(
|
|
@@ -409,44 +415,6 @@ function DataDisplay() {
|
|
|
409
415
|
}
|
|
410
416
|
```
|
|
411
417
|
|
|
412
|
-
## 🛠️ Desarrollo
|
|
413
|
-
|
|
414
|
-
### Clonar el repositorio
|
|
415
|
-
|
|
416
|
-
```bash
|
|
417
|
-
git clone https://github.com/8Wada/capi-ui.git
|
|
418
|
-
cd capi-ui
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
### Instalar dependencias
|
|
422
|
-
|
|
423
|
-
```bash
|
|
424
|
-
pnpm install
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
### Iniciar el entorno de desarrollo
|
|
428
|
-
|
|
429
|
-
```bash
|
|
430
|
-
pnpm dev
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
### Ejecutar Storybook
|
|
434
|
-
|
|
435
|
-
```bash
|
|
436
|
-
pnpm storybook
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
## 📜 Scripts Disponibles
|
|
440
|
-
|
|
441
|
-
| Script | Descripción |
|
|
442
|
-
|--------|-------------|
|
|
443
|
-
| `pnpm dev` | Inicia el servidor de desarrollo con Vite |
|
|
444
|
-
| `pnpm build` | Construye la librería para producción |
|
|
445
|
-
| `pnpm lint` | Ejecuta ESLint para revisar el código |
|
|
446
|
-
| `pnpm preview` | Previsualiza la build de producción |
|
|
447
|
-
| `pnpm storybook` | Inicia Storybook en el puerto 6006 |
|
|
448
|
-
| `pnpm build-storybook` | Construye Storybook para producción |
|
|
449
|
-
|
|
450
418
|
## 🚀 Tecnologías
|
|
451
419
|
|
|
452
420
|
- **React 19** - Librería de UI
|
|
@@ -463,36 +431,15 @@ pnpm storybook
|
|
|
463
431
|
- **XLSX** - Manejo de archivos Excel
|
|
464
432
|
- **AJV** - Validación de esquemas JSON
|
|
465
433
|
|
|
466
|
-
## 🤝 Contribuir
|
|
467
|
-
|
|
468
|
-
Las contribuciones son bienvenidas. Por favor:
|
|
469
|
-
|
|
470
|
-
1. Fork el proyecto
|
|
471
|
-
2. Crea tu rama de características (`git checkout -b feature/AmazingFeature`)
|
|
472
|
-
3. Commit tus cambios (`git commit -m 'Add some AmazingFeature'`)
|
|
473
|
-
4. Push a la rama (`git push origin feature/AmazingFeature`)
|
|
474
|
-
5. Abre un Pull Request
|
|
475
|
-
|
|
476
|
-
## 📄 Licencia
|
|
477
|
-
|
|
478
|
-
Este proyecto está bajo la licencia que especifique el repositorio.
|
|
479
|
-
|
|
480
434
|
## 👥 Autores
|
|
481
435
|
|
|
482
436
|
- **@RKamey** - *Colaborador*
|
|
483
437
|
- **@8Wada** - *Colaborador*
|
|
484
438
|
|
|
485
|
-
## 🔗 Enlaces
|
|
486
|
-
|
|
487
|
-
- [Repositorio en GitHub](https://github.com/8Wada/capi-ui)
|
|
488
|
-
- [Demo en vivo](https://capi-ui.netlify.app/)
|
|
489
|
-
- [Reportar Issues](https://github.com/8Wada/capi-ui/issues)
|
|
490
|
-
- [NPM Package](https://www.npmjs.com/package/capi-ui)
|
|
491
|
-
|
|
492
439
|
---
|
|
493
440
|
|
|
494
441
|
<div align="center">
|
|
495
442
|
|
|
496
|
-
**Hecho con ❤️ por el equipo de
|
|
443
|
+
**Hecho con ❤️ por el equipo de Innovardix**
|
|
497
444
|
|
|
498
445
|
</div>
|
package/dist/capi-ui.d.ts
CHANGED
|
@@ -414,6 +414,8 @@ export declare interface FormField {
|
|
|
414
414
|
uploadConfig?: UploadConfig;
|
|
415
415
|
radioConfig?: RadioConfig;
|
|
416
416
|
hidden?: boolean;
|
|
417
|
+
hiddenIn?: 'create' | 'edit';
|
|
418
|
+
submitKey?: string;
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
/**
|
|
@@ -574,6 +576,8 @@ export declare interface SharedFieldConfig<T = Record<string, unknown>> {
|
|
|
574
576
|
readonly?: boolean;
|
|
575
577
|
isHidden?: boolean;
|
|
576
578
|
hiddenInForm?: boolean;
|
|
579
|
+
hiddenIn?: 'create' | 'edit';
|
|
580
|
+
submitKey?: string;
|
|
577
581
|
type?: FieldType;
|
|
578
582
|
align?: "left" | "right" | "center";
|
|
579
583
|
icon?: React.ReactElement;
|
package/dist/capi-ui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import*as e from"react";import t,{useState as n,useEffect as r,useCallback as o,useMemo as a,createContext as i,useContext as l,isValidElement as s,version as u,Component as c,useInsertionEffect as d,useRef as f,useLayoutEffect as p,forwardRef as h,useImperativeHandle as m}from"react";import{Button as g,Typography as y,Form as b,Row as v,Col as w,Input as k,Upload as S,message as x,Radio as C,Checkbox as E,DatePicker as P,Select as N,Slider as T,Switch as $,InputNumber as O,Table as z,Tooltip as _,Popconfirm as L,Modal as F,Steps as R,Card as D,Alert as j,Spin as A,notification as M}from"antd";import I from"dayjs";import H from"axios";import*as V from"xlsx";import B,{createPortal as W,flushSync as U}from"react-dom";import{useQuery as q,useQueryClient as X,useMutation as Q}from"@tanstack/react-query";var G,Y={exports:{}},K={};var Z,J,ee={};function te(){return Z||(Z=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===E?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case h:return"Fragment";case g:return"Profiler";case m:return"StrictMode";case w:return"Suspense";case k:return"SuspenseList";case C:return"Activity"}if("object"==typeof t)switch(t.tag,t.$$typeof){case p:return"Portal";case b:return t.displayName||"Context";case y:return(t._context.displayName||"Context")+".Consumer";case v:var n=t.render;return(t=t.displayName)||(t=""!==(t=n.displayName||n.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case S:return null!==(n=t.displayName||null)?n:e(t.type)||"Memo";case x:n=t._payload,t=t._init;try{return e(t(n))}catch(r){}}return null}function n(e){return""+e}function r(e){try{n(e);var t=!1}catch(a){t=!0}if(t){var r=(t=console).error,o="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),n(e)}}function o(t){if(t===h)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===x)return"<...>";try{var n=e(t);return n?"<"+n+">":"<...>"}catch(r){return"<...>"}}function a(){return Error("react-stack-top-frame")}function i(){var t=e(this.type);return O[t]||(O[t]=!0),void 0!==(t=this.props.ref)?t:null}function l(t,n,o,a,l,u){var d,p=n.children;if(void 0!==p)if(a){if(T(p)){for(a=0;a<p.length;a++)s(p[a]);Object.freeze&&Object.freeze(p)}}else s(p);if(N.call(n,"key")){p=e(t);var h=Object.keys(n).filter((function(e){return"key"!==e}));a=0<h.length?"{key: someKey, "+h.join(": ..., ")+": ...}":"{key: someKey}",L[p+a]||(h=0<h.length?"{"+h.join(": ..., ")+": ...}":"{}",L[p+a]=!0)}if(p=null,void 0!==o&&(r(o),p=""+o),function(e){if(N.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(n)&&(r(n.key),p=""+n.key),"key"in n)for(var m in o={},n)"key"!==m&&(o[m]=n[m]);else o=n;return p&&function(e){function t(){c||(c=!0)}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}(o,"function"==typeof t&&(t.displayName||t.name)),function(e,t,n,r,o,a){var l=n.ref;return e={$$typeof:f,type:e,key:t,props:n,_owner:r},null!==(void 0!==l?l:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:i}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:o}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,p,o,null===(d=P.A)?null:d.getOwner(),l,u)}function s(e){u(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===x&&("fulfilled"===e._payload.status?u(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function u(e){return"object"==typeof e&&null!==e&&e.$$typeof===f}var c,d=t,f=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),b=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),E=Symbol.for("react.client.reference"),P=d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=Object.prototype.hasOwnProperty,T=Array.isArray,$=console.createTask?console.createTask:function(){return null},O={},z=(d={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(d,a)(),_=$(o(a)),L={};ee.Fragment=h,ee.jsx=function(e,t,n){var r=1e4>P.recentlyCreatedOwnerStacks++;return l(e,t,n,!1,r?Error("react-stack-top-frame"):z,r?$(o(e)):_)},ee.jsxs=function(e,t,n){var r=1e4>P.recentlyCreatedOwnerStacks++;return l(e,t,n,!0,r?Error("react-stack-top-frame"):z,r?$(o(e)):_)}}()),ee}var ne=(J||(J=1,"production"===process.env.NODE_ENV?Y.exports=function(){if(G)return K;G=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==n.key&&(o=""+n.key),"key"in n)for(var a in r={},n)"key"!==a&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:e,type:t,key:o,ref:void 0!==n?n:null,props:r}}return K.Fragment=t,K.jsx=n,K.jsxs=n,K}():Y.exports=te()),Y.exports),re={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},oe=t.createContext&&/* @__PURE__ */t.createContext(re),ae=["attr","size","title"];function ie(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function le(){return le=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},le.apply(this,arguments)}function se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?se(Object(n),!0).forEach((function(t){ce(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):se(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ce(e,t,n){var r;return(t="symbol"==typeof(r=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?r:r+"")in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function de(e){return e&&e.map(((e,n)=>/* @__PURE__ */t.createElement(e.tag,ue({key:n},e.attr),de(e.child))))}function fe(e){return n=>/* @__PURE__ */t.createElement(pe,le({attr:ue({},e.attr)},n),de(e.child))}function pe(e){var n=n=>{var r,{attr:o,size:a,title:i}=e,l=ie(e,ae),s=a||n.size||"1em";return n.className&&(r=n.className),e.className&&(r=(r?r+" ":"")+e.className),/* @__PURE__ */t.createElement("svg",le({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,o,l,{className:r,style:ue(ue({color:e.color||n.color},n.style),e.style),height:s,width:s,xmlns:"http://www.w3.org/2000/svg"}),i&&/* @__PURE__ */t.createElement("title",null,i),e.children)};return void 0!==oe?/* @__PURE__ */t.createElement(oe.Consumer,null,(e=>n(e))):n(re)}function he(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"5",y1:"12",x2:"19",y2:"12"},child:[]},{tag:"polyline",attr:{points:"12 5 19 12 12 19"},child:[]}]})(e)}function me(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"7 10 12 15 17 10"},child:[]},{tag:"line",attr:{x1:"12",y1:"15",x2:"12",y2:"3"},child:[]}]})(e)}function ge(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 20h9"},child:[]},{tag:"path",attr:{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"},child:[]}]})(e)}function ye(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"},child:[]}]})(e)}function be(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"},child:[]},{tag:"polyline",attr:{points:"9 22 9 12 15 12 15 22"},child:[]}]})(e)}function ve(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"},child:[]},{tag:"polyline",attr:{points:"22,6 12,13 2,6"},child:[]}]})(e)}function we(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"},child:[]}]})(e)}function ke(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"line",attr:{x1:"5",y1:"12",x2:"19",y2:"12"},child:[]}]})(e)}function Se(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"23 4 23 10 17 10"},child:[]},{tag:"polyline",attr:{points:"1 20 1 14 7 14"},child:[]},{tag:"path",attr:{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"},child:[]}]})(e)}function xe(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"},child:[]},{tag:"polyline",attr:{points:"17 21 17 13 7 13 7 21"},child:[]},{tag:"polyline",attr:{points:"7 3 7 8 15 8"},child:[]}]})(e)}function Ce(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]}]})(e)}function Ee(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(e)}function Pe(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"9",cy:"21",r:"1"},child:[]},{tag:"circle",attr:{cx:"20",cy:"21",r:"1"},child:[]},{tag:"path",attr:{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"},child:[]}]})(e)}function Ne(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"3 6 5 6 21 6"},child:[]},{tag:"path",attr:{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",y1:"11",x2:"10",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",y1:"11",x2:"14",y2:"17"},child:[]}]})(e)}function Te(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"17 8 12 3 7 8"},child:[]},{tag:"line",attr:{x1:"12",y1:"3",x2:"12",y2:"15"},child:[]}]})(e)}function $e(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"},child:[]},{tag:"circle",attr:{cx:"12",cy:"7",r:"4"},child:[]}]})(e)}const Oe=({children:e,type:t="primary",size:n="middle",variant:r="default",preset:o,icon:a,iconPosition:i="left",iconOnly:l=!1,loading:s=!1,disabled:u=!1,onClick:c})=>{const d=o?{save:{icon:/* @__PURE__ */ne.jsx(xe,{}),text:"Guardar",variant:"success"},delete:{icon:/* @__PURE__ */ne.jsx(Ne,{}),text:"Eliminar",variant:"danger"},edit:{icon:/* @__PURE__ */ne.jsx(ge,{}),text:"Editar",variant:"info"},add:{icon:/* @__PURE__ */ne.jsx(ke,{}),text:"Agregar",variant:"success"},download:{icon:/* @__PURE__ */ne.jsx(me,{}),text:"Descargar",variant:"info"},upload:{icon:/* @__PURE__ */ne.jsx(Te,{}),text:"Subir",variant:"warning"},refresh:{icon:/* @__PURE__ */ne.jsx(Se,{}),text:"Actualizar",variant:"default"},search:{icon:/* @__PURE__ */ne.jsx(Ce,{}),text:"Buscar",variant:"info"},settings:{icon:/* @__PURE__ */ne.jsx(Ee,{}),text:"Configurar",variant:"dark"},profile:{icon:/* @__PURE__ */ne.jsx($e,{}),text:"Perfil",variant:"default"},favorite:{icon:/* @__PURE__ */ne.jsx(ye,{}),text:"Favorito",variant:"danger"},cart:{icon:/* @__PURE__ */ne.jsx(Pe,{}),text:"Carrito",variant:"warning"},mail:{icon:/* @__PURE__ */ne.jsx(ve,{}),text:"Enviar",variant:"info"},call:{icon:/* @__PURE__ */ne.jsx(we,{}),text:"Llamar",variant:"success"},home:{icon:/* @__PURE__ */ne.jsx(be,{}),text:"Inicio",variant:"default"},next:{icon:/* @__PURE__ */ne.jsx(he,{}),text:"Siguiente",variant:"default",iconPosition:"right"}}[o]:null,f=a||d?.icon,p=d?.variant||r,h=d&&"iconPosition"in d?d.iconPosition:i,m=e||(o&&!l?d?.text:""),y=l?"!rounded-full !w-10 !h-10 !flex !items-center !justify-center !shadow-md !cursor-pointer !transition-all !duration-200":"!rounded-lg !shadow-md !cursor-pointer !transition-all !duration-200 !font-medium",b="default"!==p?(()=>{switch(r){case"success":return"!bg-green-600 hover:!bg-green-700 !border-green-600 hover:!border-green-700 !text-white";case"danger":return"!bg-red-600 hover:!bg-red-700 !border-red-600 hover:!border-red-700 !text-white";case"warning":return"!bg-yellow-600 hover:!bg-yellow-700 !border-yellow-600 hover:!border-yellow-700 !text-white";case"info":return"!bg-blue-600 hover:!bg-blue-700 !border-blue-600 hover:!border-blue-700 !text-white";case"dark":return"!bg-gray-800 hover:!bg-gray-900 !border-gray-800 hover:!border-gray-900 !text-white";default:return""}})():"";return l?/* @__PURE__ */ne.jsx(g,{className:`${y} ${b}`,type:t,size:n,loading:s,disabled:u,onClick:c,children:f}):/* @__PURE__ */ne.jsx(g,{className:`${y} ${b}`,type:t,size:n,loading:s,disabled:u,onClick:c,icon:"left"===h?f:void 0,children:/* @__PURE__ */ne.jsxs("div",{className:"!flex !items-center !gap-2 "+("right"===h?"!flex-row-reverse":""),children:["right"===h&&f,m]})})},{Title:ze}=y,_e=({level:e=1,children:t,className:n="",style:r})=>{const o={1:"text-4xl md:text-5xl mb-6",2:"text-3xl md:text-4xl mb-5",3:"text-2xl md:text-3xl mb-4",4:"text-xl md:text-2xl mb-3",5:"text-lg md:text-xl mb-2"}[e];/* @__PURE__ */
|
|
2
|
-
return ne.jsx(ze,{level:e,className:`font-bold tracking-tight text-gray-900 dark:text-white ${o} ${n}`,style:r,children:t})};function Le(e){return fe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M11 15h2V9h3l-4-5-4 5h3z"},child:[]},{tag:"path",attr:{d:"M20 18H4v-7H2v7c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2v-7h-2v7z"},child:[]}]})(e)}const Fe=({mode:e,title:a,description:i,icon:l,layout:s="vertical",cols:u=1,fields:c,submitButtonText:d="Guardar",submitEditText:f="Actualizar",onSubmit:p,initialData:h={},customCols:m=!1})=>{const[y]=b.useForm(),[z,_]=n({}),[L,F]=n({});r((()=>{if(h&&Object.keys(h).length>0){const e={...h};c.filter((e=>"object"==typeof e&&!Array.isArray(e))).forEach((t=>{"datepicker"===t.type&&e[t.name]&&(e[t.name]=I(e[t.name]))})),y.setFieldsValue(e)}}),[y,h,c]),r((()=>{c.filter((e=>"object"==typeof e&&!Array.isArray(e))).forEach((e=>{"select"===e.type&&e.selectConfig?.apiConfig&&!e.selectConfig.dependsOn?j(e):"select"===e.type&&e.dependsOn&&A(e,h[e.dependsOn.field])}))}),[]),r((()=>{const e=c.filter((e=>"object"==typeof e&&!Array.isArray(e)&&!!e.validations?.some((e=>e.isGreaterThan)))).reduce(((e,t)=>{const n=t.validations?.find((e=>e.isGreaterThan));return n?.isGreaterThan?.target&&(e[t.name]=n.isGreaterThan.target),e}),{});_(e)}),[c]);const R=o((()=>{const e=/* @__PURE__ */new Set;Object.entries(z).forEach((([t,n])=>{e.add(t),e.add(n)})),e.size>0&&y.validateFields([...e])}),[y,z]),D=o((e=>{Object.keys(e).some((e=>z[e]||Object.values(z).includes(e)))&&R()}),[z,R]),j=async e=>{if(!e.selectConfig?.apiConfig)return;const{url:t,getterMethod:n,method:r,headers:o,valueKey:a,labelKey:i,responseDataPath:l}=e.selectConfig.apiConfig;let s;s=n?await n():await H.get(t||"",{method:r||"GET",headers:o});const u=s&&l?s.data[l]:s?.data?.data,c=(Array.isArray(u)&&Array.isArray(u[0])?u[0]:u).map((e=>({value:e[a],label:e[i]})));F((t=>({...t,[e.name]:c})))},A=async(e,t)=>{if(!e.dependsOn)return;const{apiUrl:n,method:r="GET",labelKey:o,valueKey:a,idPlaceholder:i=":id"}=e.dependsOn;try{const l=n.replace(i,t.toString()),s=await H({url:l,method:r}),u=(s.data.data||s.data).map((e=>({value:e[a],label:e[o]})));F((t=>({...t,[e.name]:u}))),y.setFieldValue(e.name,void 0)}catch(l){F((t=>({...t,[e.name]:[]})))}},M=(e,t)=>e?t.selectConfig?.customOption?[t.selectConfig.customOption,...e]:e:[],V=(e,t)=>{if(!e.dependsOn?.placeholderTemplate||!t)return e.placeholder;const n=c.find((e=>"object"==typeof e&&!Array.isArray(e)&&e.name===t)),r=y.getFieldValue(t);if(!r)return`Seleccione primero un ${n?.label?.toLowerCase()}`;const o=(L[t]||[]).find((e=>e.value===r));return e.dependsOn.placeholderTemplate.replace("${"+t+"}",o?.label||r)},B=e=>e?e.map((e=>{const t={};if(e.required){const n="object"==typeof e.required?e.required:{value:e.required};t.required=n.value,n.message&&(t.message=n.message)}if(e.regex){const n="object"==typeof e.regex?e.regex:{pattern:e.regex};t.pattern=new RegExp(n.pattern),n.message&&(t.message=n.message)}if(e.min){const n=e.min;t.min=n.value,n.message&&(t.message=n.message)}if(e.max){const n=e.max;t.max=n.value,n.message&&(t.message=n.message)}if(e.email){const n=e.email;t.type="email",n.message&&(t.message=n.message)}if(e.isGreaterThan){const{target:n,message:r}=e.isGreaterThan;t.validator=async(e,t)=>{if(!t)return Promise.resolve();const o=y.getFieldValue(n);if(!o)return Promise.resolve();const a=I(t),i=I(o);return a.isAfter(i)?Promise.reject(new Error(r)):Promise.resolve()}}if(e.isLessThan){const{target:n,message:r}=e.isLessThan;t.validator=async(e,t)=>{if(!t)return Promise.resolve();const o=y.getFieldValue(n);if(!o)return Promise.resolve();const a=I(t),i=I(o);return a.isBefore(i)?Promise.reject(new Error(r)):Promise.resolve()}}return t})):[],W=
|
|
2
|
+
return ne.jsx(ze,{level:e,className:`font-bold tracking-tight text-gray-900 dark:text-white ${o} ${n}`,style:r,children:t})};function Le(e){return fe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M11 15h2V9h3l-4-5-4 5h3z"},child:[]},{tag:"path",attr:{d:"M20 18H4v-7H2v7c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2v-7h-2v7z"},child:[]}]})(e)}const Fe=({mode:e,title:a,description:i,icon:l,layout:s="vertical",cols:u=1,fields:c,submitButtonText:d="Guardar",submitEditText:f="Actualizar",onSubmit:p,initialData:h={},customCols:m=!1})=>{const[y]=b.useForm(),[z,_]=n({}),[L,F]=n({});r((()=>{if(h&&Object.keys(h).length>0){const e={...h};c.filter((e=>"object"==typeof e&&!Array.isArray(e))).forEach((t=>{"datepicker"===t.type&&e[t.name]&&(e[t.name]=I(e[t.name]))})),y.setFieldsValue(e)}}),[y,h,c]),r((()=>{c.filter((e=>"object"==typeof e&&!Array.isArray(e))).forEach((e=>{"select"===e.type&&e.selectConfig?.apiConfig&&!e.selectConfig.dependsOn?j(e):"select"===e.type&&e.dependsOn&&A(e,h[e.dependsOn.field])}))}),[]),r((()=>{const e=c.filter((e=>"object"==typeof e&&!Array.isArray(e)&&!!e.validations?.some((e=>e.isGreaterThan)))).reduce(((e,t)=>{const n=t.validations?.find((e=>e.isGreaterThan));return n?.isGreaterThan?.target&&(e[t.name]=n.isGreaterThan.target),e}),{});_(e)}),[c]);const R=o((()=>{const e=/* @__PURE__ */new Set;Object.entries(z).forEach((([t,n])=>{e.add(t),e.add(n)})),e.size>0&&y.validateFields([...e])}),[y,z]),D=o((e=>{Object.keys(e).some((e=>z[e]||Object.values(z).includes(e)))&&R()}),[z,R]),j=async e=>{if(!e.selectConfig?.apiConfig)return;const{url:t,getterMethod:n,method:r,headers:o,valueKey:a,labelKey:i,responseDataPath:l}=e.selectConfig.apiConfig;let s;s=n?await n():await H.get(t||"",{method:r||"GET",headers:o});const u=s&&l?s.data[l]:s?.data?.data,c=(Array.isArray(u)&&Array.isArray(u[0])?u[0]:u).map((e=>({value:e[a],label:e[i]})));F((t=>({...t,[e.name]:c})))},A=async(e,t)=>{if(!e.dependsOn)return;const{apiUrl:n,method:r="GET",labelKey:o,valueKey:a,idPlaceholder:i=":id"}=e.dependsOn;try{const l=n.replace(i,t.toString()),s=await H({url:l,method:r}),u=(s.data.data||s.data).map((e=>({value:e[a],label:e[o]})));F((t=>({...t,[e.name]:u}))),y.setFieldValue(e.name,void 0)}catch(l){F((t=>({...t,[e.name]:[]})))}},M=(e,t)=>e?t.selectConfig?.customOption?[t.selectConfig.customOption,...e]:e:[],V=(e,t)=>{if(!e.dependsOn?.placeholderTemplate||!t)return e.placeholder;const n=c.find((e=>"object"==typeof e&&!Array.isArray(e)&&e.name===t)),r=y.getFieldValue(t);if(!r)return`Seleccione primero un ${n?.label?.toLowerCase()}`;const o=(L[t]||[]).find((e=>e.value===r));return e.dependsOn.placeholderTemplate.replace("${"+t+"}",o?.label||r)},B=e=>e?e.map((e=>{const t={};if(e.required){const n="object"==typeof e.required?e.required:{value:e.required};t.required=n.value,n.message&&(t.message=n.message)}if(e.regex){const n="object"==typeof e.regex?e.regex:{pattern:e.regex};t.pattern=new RegExp(n.pattern),n.message&&(t.message=n.message)}if(e.min){const n=e.min;t.min=n.value,n.message&&(t.message=n.message)}if(e.max){const n=e.max;t.max=n.value,n.message&&(t.message=n.message)}if(e.email){const n=e.email;t.type="email",n.message&&(t.message=n.message)}if(e.isGreaterThan){const{target:n,message:r}=e.isGreaterThan;t.validator=async(e,t)=>{if(!t)return Promise.resolve();const o=y.getFieldValue(n);if(!o)return Promise.resolve();const a=I(t),i=I(o);return a.isAfter(i)?Promise.reject(new Error(r)):Promise.resolve()}}if(e.isLessThan){const{target:n,message:r}=e.isLessThan;t.validator=async(e,t)=>{if(!t)return Promise.resolve();const o=y.getFieldValue(n);if(!o)return Promise.resolve();const a=I(t),i=I(o);return a.isBefore(i)?Promise.reject(new Error(r)):Promise.resolve()}}return t})):[],W=t=>{const n=[];let r=[];return t.filter((t=>{if(t.hidden)return!1;if(t.hiddenIn&&e){if("create"===t.hiddenIn&&"create"===e)return!1;if("edit"===t.hiddenIn&&"update"===e)return!1}return!0})).forEach((e=>{r.length<u&&r.push(e),r.length===u&&(n.push(r),r=[])})),r.length>0&&n.push(r),n},U=n=>{const{type:r,name:o,label:a,placeholder:i,readonly:l,validations:s,options:u,min:d,max:f,step:p,datepickerConfig:m,hidden:v}=n;if(v)return null;if("view"===e){const e=h?.[o]??y.getFieldValue(o)??"-";let t=e;switch(r){case"text":case"number":case"textarea":case"email":case"password":default:t=e;break;case"select":{const r=n.dependsOn||n.selectConfig?.apiConfig?L[o]:u,a=r?.find((t=>t.value===e));t=a?.label||e;break}case"datepicker":if(e&&I.isDayjs(e)){const{format:n="YYYY-MM-DD"}=m||{};t=e.format(n)}break;case"checkbox":if(u){if(Array.isArray(e)){t=u.filter((t=>e.includes(t.value))).map((e=>e.label)).join(", ")}}else t=e?"Sí":"No";break;case"radio":{const n=u?.find((t=>t.value===e));t=n?.label||e;break}case"switch":t=e?"Sí":"No";break;case"upload":{const e=h?.[o]??y.getFieldValue(o)??"-";let t=e;return n.uploadConfig?.renderPreview&&(t=n.uploadConfig.renderPreview(e)),/* @__PURE__ */ne.jsx(b.Item,{label:a,className:"mb-4",children:/* @__PURE__ */ne.jsx("div",{className:"text-gray-700",children:t})})}}/* @__PURE__ */
|
|
3
3
|
return ne.jsx(b.Item,{label:a,className:"mb-4",children:/* @__PURE__ */ne.jsx("div",{className:"text-gray-700",children:String(t)})})}const{format:w,showTime:z,picker:_,size:F}=m||{};let R;switch(r){case"text":R=/* @__PURE__ */ne.jsx(k,{placeholder:i,readOnly:l});break;case"number":R=/* @__PURE__ */ne.jsx(O,{className:"w-full",style:{width:"100%"},placeholder:i,readOnly:l,min:d,max:f,step:p});break;case"select":R=/* @__PURE__ */ne.jsx(N,{showSearch:!0,placeholder:i||V(n,n.dependsOn?.field),options:n.dependsOn||n.selectConfig?.apiConfig?L[o]:M(u,n),optionFilterProp:"label",onChange:e=>{y.setFieldsValue({[o]:e}),n.selectConfig?.customOption&&e===n.selectConfig.customOption.value&&n.selectConfig.customOption.onClick?.(),e&&c.filter((e=>"object"==typeof e&&!Array.isArray(e)&&e.dependsOn?.field===o)).forEach((t=>{A(t,e)}))}});break;case"datepicker":R=/* @__PURE__ */ne.jsx(P,{className:"w-full",placeholder:i,size:F,format:w,showTime:z});break;case"rangepicker":R=/* @__PURE__ */ne.jsx(P.RangePicker,{className:"w-full",picker:_,format:w,showTime:z,size:F});break;case"email":R=/* @__PURE__ */ne.jsx(k,{type:"email",placeholder:i,readOnly:l});break;case"password":R=/* @__PURE__ */ne.jsx(k,{type:"password",placeholder:i,readOnly:l});break;case"textarea":R=/* @__PURE__ */ne.jsx(k.TextArea,{placeholder:i,readOnly:l});break;case"checkbox":R=u?/* @__PURE__ */ne.jsx(E.Group,{options:u,disabled:l,onChange:e=>{y.setFieldsValue({[o]:e})}}):/* @__PURE__ */ne.jsx(E,{disabled:l,onChange:e=>{y.setFieldsValue({[o]:e.target.checked})},children:i});break;case"radio":R=/* @__PURE__ */ne.jsx("div",{style:{width:n.radioConfig?.radioWidth||"40%"},children:/* @__PURE__ */ne.jsx(C.Group,{disabled:l,defaultValue:h[o],onChange:e=>{y.setFieldsValue({[o]:e.target.value})},style:{display:"grid",gridTemplateColumns:`repeat(${n?.radioConfig?.cols||1}, 1fr)`,gap:"0.5rem"},children:u?.map(((e,t)=>/* @__PURE__ */ne.jsx(C,{value:e.value,style:{display:"flex",alignItems:"center",marginRight:"0"},children:e.label},t)))})});break;case"switch":R=/* @__PURE__ */ne.jsx($,{defaultChecked:!0});break;case"slider":R=/* @__PURE__ */ne.jsx(T,{});break;case"upload":R=/* @__PURE__ */ne.jsx(S,{name:n.uploadConfig?.name||o,action:n.uploadConfig?.action,accept:n.uploadConfig?.accept,multiple:n.uploadConfig?.multiple,maxCount:n.uploadConfig?.maxCount,listType:n.uploadConfig?.listType||"text",beforeUpload:e=>{if(n.uploadConfig?.maxSize&&e.size>n.uploadConfig.maxSize){const e=Math.round(n.uploadConfig.maxSize/1048576);return x.error(`El archivo no debe exceder ${e}MB`),S.LIST_IGNORE}return!n.uploadConfig?.beforeUpload||n.uploadConfig.beforeUpload(e)},onChange:e=>{const{status:t,response:r}=e.file;if("done"===t){const t=r;t&&(y.setFieldValue(o,t),x.success(`${e.file.name} se subió correctamente`))}else"error"===t&&x.error(`${e.file.name} falló al subirse.`);n.uploadConfig?.onChange?.(e)},customRequest:n.uploadConfig?.customRequest,children:n.uploadConfig?.renderPreview&&y.getFieldValue(o)?/* @__PURE__ */ne.jsxs("div",{children:[n.uploadConfig.renderPreview(y.getFieldValue(o)),
|
|
4
4
|
/* @__PURE__ */ne.jsx(g,{icon:n.uploadConfig?.iconButton?/* @__PURE__ */ne.jsx("span",{className:n.uploadConfig.iconButton}):/* @__PURE__ */ne.jsx(Le,{}),children:"Cambiar archivo"})]}):/* @__PURE__ */ne.jsx(g,{icon:n.uploadConfig?.iconButton?/* @__PURE__ */ne.jsx("span",{className:n.uploadConfig.iconButton}):/* @__PURE__ */ne.jsx(Le,{}),children:n.uploadConfig?.textButton||"Subir archivo"})})}return R?/* @__PURE__ */ne.jsx(b.Item,{label:a,name:o,rules:B(s),children:t.cloneElement(R)}):null};/* @__PURE__ */
|
|
5
5
|
return ne.jsxs("div",{children:[
|
|
@@ -7,7 +7,7 @@ return ne.jsxs("div",{children:[
|
|
|
7
7
|
/* @__PURE__ */ne.jsxs("div",{className:"flex items-center gap-4",children:[l&&t.cloneElement(l),
|
|
8
8
|
/* @__PURE__ */ne.jsx("span",{className:"font-semibold",children:a})]}),
|
|
9
9
|
/* @__PURE__ */ne.jsx("p",{className:"text-sm text-gray-500",children:i})]}),
|
|
10
|
-
/* @__PURE__ */ne.jsxs(b,{form:y,layout:s,initialValues:h,onFinish:e=>{const t={...e};c.filter((e=>"object"==typeof e&&!Array.isArray(e))).forEach((e=>{"datepicker"===e.type&&t[e.name]&&(t[e.name]=I(t[e.name]).format(e.datepickerConfig?.format||"YYYY-MM-DD"))})),p?.(t)},onValuesChange:D,children:[(q=c,m?q.map((e=>Array.isArray(e)?e:[e])):W(q)).map(((e,t)=>/* @__PURE__ */ne.jsx(v,{gutter:16,children:e.map(((n,r)=>/* @__PURE__ */ne.jsx(w,{span:24/e.length,children:U(n)},`${t}-${r}`)))},t))),c.filter((e=>"object"==typeof e&&!Array.isArray(e)&&!0===e.hidden)).map((e=>/* @__PURE__ */ne.jsx(b.Item,{name:e.name,hidden:!0,children:/* @__PURE__ */ne.jsx(k,{type:"hidden"})},e.name))),"view"!==e&&/* @__PURE__ */ne.jsx(v,{justify:"end",children:/* @__PURE__ */ne.jsx(b.Item,{children:/* @__PURE__ */ne.jsx(g,{type:"primary",htmlType:"submit",className:"bg-primary",style:{color:"white"},children:"update"===e?f:d})})})]})]});var q};function Re(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5.82843 6.99955L8.36396 9.53509L6.94975 10.9493L2 5.99955L6.94975 1.0498L8.36396 2.46402L5.82843 4.99955H13C17.4183 4.99955 21 8.58127 21 12.9996C21 17.4178 17.4183 20.9996 13 20.9996H4V18.9996H13C16.3137 18.9996 19 16.3133 19 12.9996C19 9.68584 16.3137 6.99955 13 6.99955H5.82843Z"},child:[]}]})(e)}function De(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M6.41421 15.89L16.5563 5.74785L15.1421 4.33363L5 14.4758V15.89H6.41421ZM7.24264 17.89H3V13.6473L14.435 2.21231C14.8256 1.82179 15.4587 1.82179 15.8492 2.21231L18.6777 5.04074C19.0682 5.43126 19.0682 6.06443 18.6777 6.45495L7.24264 17.89ZM3 19.89H21V21.89H3V19.89Z"},child:[]}]})(e)}function je(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2.85858 2.87732L15.4293 1.0815C15.7027 1.04245 15.9559 1.2324 15.995 1.50577C15.9983 1.52919 16 1.55282 16 1.57648V22.4235C16 22.6996 15.7761 22.9235 15.5 22.9235C15.4763 22.9235 15.4527 22.9218 15.4293 22.9184L2.85858 21.1226C2.36593 21.0522 2 20.6303 2 20.1327V3.86727C2 3.36962 2.36593 2.9477 2.85858 2.87732ZM4 4.73457V19.2654L14 20.694V3.30599L4 4.73457ZM17 19H20V4.99997H17V2.99997H21C21.5523 2.99997 22 3.44769 22 3.99997V20C22 20.5523 21.5523 21 21 21H17V19ZM10.2 12L13 16H10.6L9 13.7143L7.39999 16H5L7.8 12L5 7.99997H7.39999L9 10.2857L10.6 7.99997H13L10.2 12Z"},child:[]}]})(e)}function Ae(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M11 11V7H13V11H17V13H13V17H11V13H7V11H11ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20Z"},child:[]}]})(e)}function Me(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 11H11V17H9V11ZM13 11H15V17H13V11ZM9 4V6H15V4H9Z"},child:[]}]})(e)}function Ie(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12.0003 3C17.3924 3 21.8784 6.87976 22.8189 12C21.8784 17.1202 17.3924 21 12.0003 21C6.60812 21 2.12215 17.1202 1.18164 12C2.12215 6.87976 6.60812 3 12.0003 3ZM12.0003 19C16.2359 19 19.8603 16.052 20.7777 12C19.8603 7.94803 16.2359 5 12.0003 5C7.7646 5 4.14022 7.94803 3.22278 12C4.14022 16.052 7.7646 19 12.0003 19ZM12.0003 16.5C9.51498 16.5 7.50026 14.4853 7.50026 12C7.50026 9.51472 9.51498 7.5 12.0003 7.5C14.4855 7.5 16.5003 9.51472 16.5003 12C16.5003 14.4853 14.4855 16.5 12.0003 16.5ZM12.0003 14.5C13.381 14.5 14.5003 13.3807 14.5003 12C14.5003 10.6193 13.381 9.5 12.0003 9.5C10.6196 9.5 9.50026 10.6193 9.50026 12C9.50026 13.3807 10.6196 14.5 12.0003 14.5Z"},child:[]}]})(e)}function He(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5.46257 4.43262C7.21556 2.91688 9.5007 2 12 2C17.5228 2 22 6.47715 22 12C22 14.1361 21.3302 16.1158 20.1892 17.7406L17 12H20C20 7.58172 16.4183 4 12 4C9.84982 4 7.89777 4.84827 6.46023 6.22842L5.46257 4.43262ZM18.5374 19.5674C16.7844 21.0831 14.4993 22 12 22C6.47715 22 2 17.5228 2 12C2 9.86386 2.66979 7.88416 3.8108 6.25944L7 12H4C4 16.4183 7.58172 20 12 20C14.1502 20 16.1022 19.1517 17.5398 17.7716L18.5374 19.5674Z"},child:[]}]})(e)}function Ve(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 19H21V21H3V19ZM13 5.82843V17H11V5.82843L4.92893 11.8995L3.51472 10.4853L12 2L20.4853 10.4853L19.0711 11.8995L13 5.82843Z"},child:[]}]})(e)}function Be(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Be(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function We(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Be(e))&&(r&&(r+=" "),r+=t);return r}const Ue=(e,t)=>{const n=t.split(".");let r=e;for(const o of n){if(!r||"object"!=typeof r||!(o in r))return;r=r[o]}return r},qe=e=>(t,n)=>{const r=String(e),o=r.includes(".")?Ue(t,r):t[e],a=r.includes(".")?Ue(n,r):n[e];if(null==o)return-1;if(null==a)return 1;if(o instanceof Date&&a instanceof Date)return o.getTime()-a.getTime();if("number"==typeof o&&"number"==typeof a)return o-a;if("string"==typeof o&&"string"==typeof a){const e=Number(o),t=Number(a);return isNaN(e)||isNaN(t)?o.localeCompare(a):e-t}return"boolean"==typeof o&&"boolean"==typeof a?o===a?0:o?-1:1:"object"==typeof o&&"object"==typeof a?JSON.stringify(o).localeCompare(JSON.stringify(a)):String(o).localeCompare(String(a))},{Search:Xe}=k,Qe=({title:e,icon:r,description:o,showSearchBar:i=!0,showCreateButton:l,onCreate:s,onEdit:u,onDelete:c,onView:d,onRefresh:f,exportToExcel:p,createButtonText:h="Crear",createButtonIcon:m=/* @__PURE__ */ne.jsx(Ae,{}),columns:y,data:b,loading:v,moreActions:w,customFilters:k,disableWrapper:S=!1,actionConfig:x={showDefaultActions:!0,showEdit:!0,showDelete:!0,showView:!1,refreshButtonText:"Refrescar",customIcons:{create:/* @__PURE__ */ne.jsx(Ae,{}),edit:/* @__PURE__ */ne.jsx(De,{}),delete:/* @__PURE__ */ne.jsx(Me,{}),refresh:/* @__PURE__ */ne.jsx(He,{}),view:/* @__PURE__ */ne.jsx(Ie,{})},customActionsColor:{edit:"!bg-yellow-500 hover:!bg-yellow-700",delete:"!bg-red-500 hover:!bg-red-700",view:"!bg-sky-500 hover:!bg-sky-700"}},showRefreshButton:C,hiddenActions:E=!1,searchConfig:P={searchableFields:[],customSearch:void 0},backButton:N,widthActionsCol:T,bulkUpload:$,onBulkUpload:O})=>{const[F,R]=n(""),D=a((()=>b.map(((e,t)=>({...e,key:t})))),[b]),j=(e,t)=>Object.values(e).some((e=>null!=e&&("object"==typeof e?"object"==typeof e&&null!==e&&!Array.isArray(e)&&j(e,t):e.toString().toLowerCase().includes(t.toLowerCase())))),A=a((()=>F?D.filter((e=>{const t=e;return P.customSearch?P.customSearch(t,F):P.searchableFields&&P.searchableFields.length>0?((e,t,n)=>n.some((n=>{const r=n.includes(".")?Ue(e,n):e[n];return null!=r&&r.toString().toLowerCase().includes(t.toLowerCase())})))(t,F,P.searchableFields):j(e,F)})):D),[D,F,P]),M=e=>{R(e)},I={defaultPageSize:10,showSizeChanger:!0,showTotal:e=>`Total ${e} registros${F?" filtrados":""}`,pageSizeOptions:["10","20","50","100"]},H=e=>{u?.(e)},B=e=>{c?.(e)},W=e=>{d?.(e)},U=()=>N?"boolean"==typeof N?/* @__PURE__ */ne.jsx(g,{icon:/* @__PURE__ */ne.jsx(Re,{}),className:"bg-white hover:bg-gray-50 border border-gray-200 shadow-xs hover:shadow-sm transition-all duration-300 px-4 h-8 dark:!bg-gray-700 dark:!border-gray-600 dark:hover:!bg-gray-600 dark:text-white",onClick:()=>window.history.back(),children:"Volver"}):N:null;/* @__PURE__ */
|
|
10
|
+
/* @__PURE__ */ne.jsxs(b,{form:y,layout:s,initialValues:h,onFinish:e=>{const t={...e};c.filter((e=>"object"==typeof e&&!Array.isArray(e))).forEach((e=>{"datepicker"===e.type&&t[e.name]&&(t[e.name]=I(t[e.name]).format(e.datepickerConfig?.format||"YYYY-MM-DD")),e.submitKey&&void 0!==t[e.name]&&(t[e.submitKey]=t[e.name],e.submitKey!==e.name&&delete t[e.name])})),p?.(t)},onValuesChange:D,children:[(q=c,m?q.map((e=>Array.isArray(e)?e:[e])):W(q)).map(((e,t)=>/* @__PURE__ */ne.jsx(v,{gutter:16,children:e.map(((n,r)=>/* @__PURE__ */ne.jsx(w,{span:24/e.length,children:U(n)},`${t}-${r}`)))},t))),c.filter((e=>"object"==typeof e&&!Array.isArray(e)&&!0===e.hidden)).map((e=>/* @__PURE__ */ne.jsx(b.Item,{name:e.name,hidden:!0,children:/* @__PURE__ */ne.jsx(k,{type:"hidden"})},e.name))),"view"!==e&&/* @__PURE__ */ne.jsx(v,{justify:"end",children:/* @__PURE__ */ne.jsx(b.Item,{children:/* @__PURE__ */ne.jsx(g,{type:"primary",htmlType:"submit",className:"bg-primary",style:{color:"white"},children:"update"===e?f:d})})})]})]});var q};function Re(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5.82843 6.99955L8.36396 9.53509L6.94975 10.9493L2 5.99955L6.94975 1.0498L8.36396 2.46402L5.82843 4.99955H13C17.4183 4.99955 21 8.58127 21 12.9996C21 17.4178 17.4183 20.9996 13 20.9996H4V18.9996H13C16.3137 18.9996 19 16.3133 19 12.9996C19 9.68584 16.3137 6.99955 13 6.99955H5.82843Z"},child:[]}]})(e)}function De(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M6.41421 15.89L16.5563 5.74785L15.1421 4.33363L5 14.4758V15.89H6.41421ZM7.24264 17.89H3V13.6473L14.435 2.21231C14.8256 1.82179 15.4587 1.82179 15.8492 2.21231L18.6777 5.04074C19.0682 5.43126 19.0682 6.06443 18.6777 6.45495L7.24264 17.89ZM3 19.89H21V21.89H3V19.89Z"},child:[]}]})(e)}function je(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2.85858 2.87732L15.4293 1.0815C15.7027 1.04245 15.9559 1.2324 15.995 1.50577C15.9983 1.52919 16 1.55282 16 1.57648V22.4235C16 22.6996 15.7761 22.9235 15.5 22.9235C15.4763 22.9235 15.4527 22.9218 15.4293 22.9184L2.85858 21.1226C2.36593 21.0522 2 20.6303 2 20.1327V3.86727C2 3.36962 2.36593 2.9477 2.85858 2.87732ZM4 4.73457V19.2654L14 20.694V3.30599L4 4.73457ZM17 19H20V4.99997H17V2.99997H21C21.5523 2.99997 22 3.44769 22 3.99997V20C22 20.5523 21.5523 21 21 21H17V19ZM10.2 12L13 16H10.6L9 13.7143L7.39999 16H5L7.8 12L5 7.99997H7.39999L9 10.2857L10.6 7.99997H13L10.2 12Z"},child:[]}]})(e)}function Ae(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M11 11V7H13V11H17V13H13V17H11V13H7V11H11ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20Z"},child:[]}]})(e)}function Me(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 11H11V17H9V11ZM13 11H15V17H13V11ZM9 4V6H15V4H9Z"},child:[]}]})(e)}function Ie(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12.0003 3C17.3924 3 21.8784 6.87976 22.8189 12C21.8784 17.1202 17.3924 21 12.0003 21C6.60812 21 2.12215 17.1202 1.18164 12C2.12215 6.87976 6.60812 3 12.0003 3ZM12.0003 19C16.2359 19 19.8603 16.052 20.7777 12C19.8603 7.94803 16.2359 5 12.0003 5C7.7646 5 4.14022 7.94803 3.22278 12C4.14022 16.052 7.7646 19 12.0003 19ZM12.0003 16.5C9.51498 16.5 7.50026 14.4853 7.50026 12C7.50026 9.51472 9.51498 7.5 12.0003 7.5C14.4855 7.5 16.5003 9.51472 16.5003 12C16.5003 14.4853 14.4855 16.5 12.0003 16.5ZM12.0003 14.5C13.381 14.5 14.5003 13.3807 14.5003 12C14.5003 10.6193 13.381 9.5 12.0003 9.5C10.6196 9.5 9.50026 10.6193 9.50026 12C9.50026 13.3807 10.6196 14.5 12.0003 14.5Z"},child:[]}]})(e)}function He(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5.46257 4.43262C7.21556 2.91688 9.5007 2 12 2C17.5228 2 22 6.47715 22 12C22 14.1361 21.3302 16.1158 20.1892 17.7406L17 12H20C20 7.58172 16.4183 4 12 4C9.84982 4 7.89777 4.84827 6.46023 6.22842L5.46257 4.43262ZM18.5374 19.5674C16.7844 21.0831 14.4993 22 12 22C6.47715 22 2 17.5228 2 12C2 9.86386 2.66979 7.88416 3.8108 6.25944L7 12H4C4 16.4183 7.58172 20 12 20C14.1502 20 16.1022 19.1517 17.5398 17.7716L18.5374 19.5674Z"},child:[]}]})(e)}function Ve(e){return fe({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 19H21V21H3V19ZM13 5.82843V17H11V5.82843L4.92893 11.8995L3.51472 10.4853L12 2L20.4853 10.4853L19.0711 11.8995L13 5.82843Z"},child:[]}]})(e)}function Be(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Be(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function We(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Be(e))&&(r&&(r+=" "),r+=t);return r}const Ue=(e,t)=>{const n=t.split(".");let r=e;for(const o of n){if(!r||"object"!=typeof r||!(o in r))return;r=r[o]}return r},qe=e=>(t,n)=>{const r=String(e),o=r.includes(".")?Ue(t,r):t[e],a=r.includes(".")?Ue(n,r):n[e];if(null==o)return-1;if(null==a)return 1;if(o instanceof Date&&a instanceof Date)return o.getTime()-a.getTime();if("number"==typeof o&&"number"==typeof a)return o-a;if("string"==typeof o&&"string"==typeof a){const e=Number(o),t=Number(a);return isNaN(e)||isNaN(t)?o.localeCompare(a):e-t}return"boolean"==typeof o&&"boolean"==typeof a?o===a?0:o?-1:1:"object"==typeof o&&"object"==typeof a?JSON.stringify(o).localeCompare(JSON.stringify(a)):String(o).localeCompare(String(a))},{Search:Xe}=k,Qe=({title:e,icon:r,description:o,showSearchBar:i=!0,showCreateButton:l,onCreate:s,onEdit:u,onDelete:c,onView:d,onRefresh:f,exportToExcel:p,createButtonText:h="Crear",createButtonIcon:m=/* @__PURE__ */ne.jsx(Ae,{}),columns:y,data:b,loading:v,moreActions:w,customFilters:k,disableWrapper:S=!1,actionConfig:x={showDefaultActions:!0,showEdit:!0,showDelete:!0,showView:!1,refreshButtonText:"Refrescar",customIcons:{create:/* @__PURE__ */ne.jsx(Ae,{}),edit:/* @__PURE__ */ne.jsx(De,{}),delete:/* @__PURE__ */ne.jsx(Me,{}),refresh:/* @__PURE__ */ne.jsx(He,{}),view:/* @__PURE__ */ne.jsx(Ie,{})},customActionsColor:{edit:"!bg-yellow-500 hover:!bg-yellow-700",delete:"!bg-red-500 hover:!bg-red-700",view:"!bg-sky-500 hover:!bg-sky-700"}},showRefreshButton:C,hiddenActions:E=!1,searchConfig:P={searchableFields:[],customSearch:void 0},backButton:N,widthActionsCol:T,bulkUpload:$,onBulkUpload:O})=>{const[F,R]=n(""),D=a((()=>b.map(((e,t)=>({...e,key:t})))),[b]),j=(e,t)=>Object.values(e).some((e=>null!=e&&("object"==typeof e?"object"==typeof e&&null!==e&&!Array.isArray(e)&&j(e,t):e.toString().toLowerCase().includes(t.toLowerCase())))),A=a((()=>F?D.filter((e=>{const t=e;return P.customSearch?P.customSearch(t,F):P.searchableFields&&P.searchableFields.length>0?((e,t,n)=>n.some((n=>{const r=n.includes(".")?Ue(e,n):e[n];return null!=r&&r.toString().toLowerCase().includes(t.toLowerCase())})))(t,F,P.searchableFields):j(e,F)})):D),[D,F,P]),M=e=>{R(e)},I={defaultPageSize:10,showSizeChanger:!0,showTotal:e=>`Total ${e} registros${F?" filtrados":""}`,pageSizeOptions:["10","20","50","100"]},H=e=>{u?.(e)},B=e=>{c?.(e)},W=e=>{d?.(e)},U=()=>N?"boolean"==typeof N?/* @__PURE__ */ne.jsx(g,{icon:/* @__PURE__ */ne.jsx(Re,{}),className:"bg-white hover:bg-gray-50 border border-gray-200 shadow-xs hover:shadow-sm transition-all duration-300 px-4 h-8 dark:!bg-gray-700 dark:!border-gray-600 dark:hover:!bg-gray-600 dark:text-white",onClick:()=>window.history.back(),children:"Volver"}):N:null;/* @__PURE__ */
|
|
11
11
|
return ne.jsxs("div",{className:We("my-1",{"bg-white rounded-xl shadow-lg p-1 dark:bg-gray-800":!S}),children:[
|
|
12
12
|
/* @__PURE__ */ne.jsxs("div",{className:"mb-2 space-y-3 sm:space-y-3",children:[e&&/* @__PURE__ */ne.jsxs("div",{className:"mb-3 sm:mb-4 space-y-2",children:[
|
|
13
13
|
/* @__PURE__ */ne.jsxs("div",{className:"flex items-center gap-3",children:[U&&/* @__PURE__ */ne.jsx("div",{children:U()}),r&&/* @__PURE__ */ne.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-primary-lightest hover:bg-primary-lightest/70 transition-colors dark:bg-primary-dark dark:hover:bg-primary-dark/70",children:t.isValidElement(r)?t.cloneElement(r):r}),
|
|
@@ -144,4 +144,4 @@ return ne.jsxs(D,{children:[
|
|
|
144
144
|
/* @__PURE__ */ne.jsx(w,{span:12,children:/* @__PURE__ */ne.jsx(g,{block:!0,onClick:()=>u(3),children:"Volver a validación"})}),
|
|
145
145
|
/* @__PURE__ */ne.jsx(w,{span:12,children:/* @__PURE__ */ne.jsx(g,{type:"primary",block:!0,onClick:()=>{x.success(`${P.length} registros cargados exitosamente`),a&&P.length>0&&a(P),q(),o()},children:"Cargar datos"})})]})]});default:return null}})()]})},Yp=({columns:e,data:t,title:r,formTitle:i,formTitles:l,description:s,formDescription:u,fields:c,showCreateButton:d,createButtonText:f="Crear",createButtonIcon:p,icon:h,layout:m,actionConfig:g,searchConfig:y,headerDirection:b,showRefreshButton:v,onRefresh:w,loading:k,onCreate:S,createRedirect:x=!1,onEdit:C,onDelete:E,onView:P,submitButtonText:N="Guardar",apiConfig:T,initialData:$,themeConfig:O,moreActions:z,formCols:_=1,formCustomCols:L=!1,exportToExcel:R,backButton:D,showSearchBar:j,customFilters:A,disableWrapper:M=!1,hiddenActions:H=!1,widthActionsCol:V,crudName:B,permissions:W,bulkUpload:U={enabled:!1}})=>{const[q,X]=n(!1),[Q,G]=n(null),[Y,K]=n($?"update":"create"),[Z,J]=n(!1),{canCreate:ee,canUpdate:te,canDelete:re,canView:oe}=kr(B,W),ae=Boolean(B||W),ie=o(((e,t,n)=>n?!!t&&("function"==typeof e?e:void 0===e||e):e),[]),le=a((()=>ae?{...g,showEdit:ie(g?.showEdit,te,ae),showDelete:ie(g?.showDelete,re,ae),showView:ie(g?.showView,oe,ae)}:g),[g,te,re,oe,ae,ie]),se=ae?d&&ee:d,ue=e.find((e=>e.isPrimaryKey))?.dataIndex||"id",ce=e=>{const t={...e};return c?.forEach((e=>{"datepicker"===e.type&&t[e.name]&&(t[e.name]=I(t[e.name]))})),t},de=i||("create"===Y?l?.[0]||"Crear nuevo registro":"update"===Y?l?.[1]||"Editar registro":l?.[2]||"Ver registro"),fe=h||("create"===Y?p||/* @__PURE__ */ne.jsx(Jn,{}):"update"===Y?/* @__PURE__ */ne.jsx(En,{}):/* @__PURE__ */ne.jsx(jn,{}));/* @__PURE__ */
|
|
146
146
|
return ne.jsxs("div",{children:[
|
|
147
|
-
/* @__PURE__ */ne.jsx(Qe,{title:r,description:s,icon:h,columns:e,data:t||[],showCreateButton:se,createButtonText:f,createButtonIcon:p,searchConfig:y,actionConfig:le,hiddenActions:H,headerDirection:b,showSearchBar:j,showRefreshButton:v,loading:k,onCreate:()=>{x?"function"==typeof S&&S({}):(X(!0),K("create"))},onEdit:e=>{const t=ce(e);G(t),X(!0),K("update")},onRefresh:w,onDelete:e=>{E?.(e)},onView:e=>{if(P)P(e);else{const t=ce(e);G(t),X(!0),K("view")}},themeConfig:O,moreActions:z,customFilters:A,exportToExcel:R,bulkUpload:U,backButton:D,disableWrapper:M,widthActionsCol:V,onBulkUpload:()=>{J(!0)}}),q&&/* @__PURE__ */ne.jsx(F,{open:q,onCancel:()=>{X(!1),G(null),K($?"update":"create")},footer:null,children:/* @__PURE__ */ne.jsx(Fe,{title:de,description:u||s,fields:c||[],icon:fe,layout:m,initialData:Q||void 0,onSubmit:e=>{try{if("update"===Y){const t={..."object"==typeof e&&null!==e?e:{},[ue]:Q?.[ue]};C?.(t),G(null)}else S?.(e);X(!1)}catch(t){}},mode:Y,submitButtonText:N,apiConfig:T,cols:_,customCols:L})}),Z&&U?.enabled&&/* @__PURE__ */ne.jsx(Gp,{title:U?.title||"Carga masiva",visible:Z,onCancel:()=>J(!1),onFinish:U.onFinish,config:U.config})]})};class Kp{baseUrl;config;instances;constructor(e,t){this.baseUrl=e,this.config=t,this.instances={};const n=H.create({baseURL:this.baseUrl,...this.config});Object.assign(n,{getInstance:this.getInstance.bind(this)}),this.instances.default=n}createApiInstance(e){return H.create({baseURL:`${this.baseUrl}/${e}`,...this.config})}version(e){return this.instances[e]||(this.instances[e]=this.createApiInstance(e)),this.instances[e]}getInstance(e){return this.instances[e]||(this.instances[e]=this.createApiInstance(e)),this.instances[e]}}const Zp=e=>Object.values(e).map((e=>({key:e.key,title:e.title,dataIndex:e.key,sorter:e.sorter?(t,n)=>qe(e.key)(t,n):void 0,width:e.width,align:e.align,icon:e.icon,isHidden:e.isHidden,render:e.render,filters:e.filtrers,onFilter:e.onFilter,isPrimaryKey:"id"===e.key?.toLowerCase()||"uuid"===e.key?.toLowerCase()}))),Jp=e=>Object.entries(e).map((([e,t])=>({type:t.type||"text",name:e,label:t.label,placeholder:t.placeholder,validations:t.validations,datepickerConfig:t.datepickerConfig,min:t.min,max:t.max,step:t.step,width:t.width,readonly:t.readonly,hidden:t.hiddenInForm,checkboxConfig:t.checkboxConfig,selectConfig:t.selectConfig,dependsOn:t.dependsOn,options:t.options,onChange:t.onChange,uploadConfig:t.uploadConfig,radioConfig:t.radioConfig}))),eh=(e,t,n,r="bottomRight")=>{M[e]({message:t,description:n,placement:r})},th=({queryKey:e,queryFn:t,config:n={}})=>q({queryKey:e,queryFn:t,...n}),nh=({queryKey:e,mutationFn:t,config:n={}})=>{const r=X();return Q({mutationFn:t,onSettled:()=>{r.invalidateQueries({queryKey:e})},...n})};function rh({getAll:e,create:t,update:n,delete:r,idField:o="id",entityName:a="item"}){const i=[`crud-${o}`],{data:l=[],isLoading:s,refetch:u}=th({queryKey:i,queryFn:async()=>(await e()).data??[],config:{onError:e=>eh("error","Error al cargar los datos",e.message)}}),c={creado:"crear",actualizado:"actualizar",eliminado:"eliminar"},d=e=>({queryKey:i,config:{onSuccess:()=>{eh("success",`${a.charAt(0).toUpperCase()+a.slice(1)} ${e} exitosamente`,""),u()},onError:t=>eh("error",`Error al ${c[e]} el ${a}`,t.message)}}),{mutateAsync:f}=nh({...d("creado"),mutationFn:async e=>{if(!t)throw new Error("Create function is not defined");const n=await t(e);if(n.error)throw new Error(n.message);return n.data}}),{mutateAsync:p}=nh({...d("actualizado"),mutationFn:async e=>{if(!n)throw new Error("Update function is not defined");const t=await n(e);if(t.error)throw new Error(t.message);return t.data}}),{mutateAsync:h}=nh({...d("eliminado"),mutationFn:async e=>{if(!r)throw new Error("Delete function is not defined");return(await r(e)).data}});return{data:l,isLoading:s,refetch:u,handleCreate:async e=>{const t=e;return await f(t)},handleUpdate:async e=>{const t=e;return await p(t)},handleDelete:async e=>{const t=e;return await h(t)},createItemAsync:f,updateItemAsync:p,deleteItemAsync:h}}const oh=(e,t)=>{const[o,a]=n(),[i,l]=n(null),[s,u]=n(!0);return r((()=>{(async()=>{try{u(!0);const t=await e();a(t&&"object"==typeof t&&"data"in t?t.data:t)}catch(t){l(t instanceof Error?t:new Error("An error occurred"))}finally{u(!1)}})()}),t||[]),{data:o,error:i,loading:s}},ah=()=>function(e,t,n,r,o,a,i="",l={}){return{key:e,icon:t,label:i,style:l,tooltip:n,className:r,onClick:o,hidden:a}},ih=e=>e,lh={FULL_ACCESS:["create","read","update","delete","view","refresh","export"],READ_WRITE:["create","read","update","view","refresh"],READ_ONLY:["read","view"],VIEW_ONLY:["view"],NO_ACCESS:[]},sh=(...e)=>e;export{Kp as ApiVersioning,Oe as Btn,Yp as DynamicCrud,Fe as DynamicForm,Qe as DynamicTable,lh as PERMISSIONS,wr as PermissionsProvider,_e as Title,ah as createActionFactory,sh as createPermissions,ih as createPermissionsConfig,Zp as generateColumns,Jp as generateFields,eh as openNotification,qe as sortOrder,oh as useAsync,rh as useCrudOperations,nh as useMutationFetch,kr as usePermissions,th as useQueryFetch};
|
|
147
|
+
/* @__PURE__ */ne.jsx(Qe,{title:r,description:s,icon:h,columns:e,data:t||[],showCreateButton:se,createButtonText:f,createButtonIcon:p,searchConfig:y,actionConfig:le,hiddenActions:H,headerDirection:b,showSearchBar:j,showRefreshButton:v,loading:k,onCreate:()=>{x?"function"==typeof S&&S({}):(X(!0),K("create"))},onEdit:e=>{const t=ce(e);G(t),X(!0),K("update")},onRefresh:w,onDelete:e=>{E?.(e)},onView:e=>{if(P)P(e);else{const t=ce(e);G(t),X(!0),K("view")}},themeConfig:O,moreActions:z,customFilters:A,exportToExcel:R,bulkUpload:U,backButton:D,disableWrapper:M,widthActionsCol:V,onBulkUpload:()=>{J(!0)}}),q&&/* @__PURE__ */ne.jsx(F,{open:q,onCancel:()=>{X(!1),G(null),K($?"update":"create")},footer:null,children:/* @__PURE__ */ne.jsx(Fe,{title:de,description:u||s,fields:c||[],icon:fe,layout:m,initialData:Q||void 0,onSubmit:e=>{try{if("update"===Y){const t={..."object"==typeof e&&null!==e?e:{},[ue]:Q?.[ue]};C?.(t),G(null)}else S?.(e);X(!1)}catch(t){}},mode:Y,submitButtonText:N,apiConfig:T,cols:_,customCols:L})}),Z&&U?.enabled&&/* @__PURE__ */ne.jsx(Gp,{title:U?.title||"Carga masiva",visible:Z,onCancel:()=>J(!1),onFinish:U.onFinish,config:U.config})]})};class Kp{baseUrl;config;instances;constructor(e,t){this.baseUrl=e,this.config=t,this.instances={};const n=H.create({baseURL:this.baseUrl,...this.config});Object.assign(n,{getInstance:this.getInstance.bind(this)}),this.instances.default=n}createApiInstance(e){return H.create({baseURL:`${this.baseUrl}/${e}`,...this.config})}version(e){return this.instances[e]||(this.instances[e]=this.createApiInstance(e)),this.instances[e]}getInstance(e){return this.instances[e]||(this.instances[e]=this.createApiInstance(e)),this.instances[e]}}const Zp=e=>Object.values(e).map((e=>({key:e.key,title:e.title,dataIndex:e.key,sorter:e.sorter?(t,n)=>qe(e.key)(t,n):void 0,width:e.width,align:e.align,icon:e.icon,isHidden:e.isHidden,render:e.render,filters:e.filtrers,onFilter:e.onFilter,isPrimaryKey:"id"===e.key?.toLowerCase()||"uuid"===e.key?.toLowerCase()}))),Jp=e=>Object.entries(e).map((([e,t])=>({type:t.type||"text",name:e,label:t.label,placeholder:t.placeholder,validations:t.validations,datepickerConfig:t.datepickerConfig,min:t.min,max:t.max,step:t.step,width:t.width,readonly:t.readonly,hidden:t.hiddenInForm,hiddenIn:t.hiddenIn,submitKey:t.submitKey,checkboxConfig:t.checkboxConfig,selectConfig:t.selectConfig,dependsOn:t.dependsOn,options:t.options,onChange:t.onChange,uploadConfig:t.uploadConfig,radioConfig:t.radioConfig}))),eh=(e,t,n,r="bottomRight")=>{M[e]({message:t,description:n,placement:r})},th=({queryKey:e,queryFn:t,config:n={}})=>q({queryKey:e,queryFn:t,...n}),nh=({queryKey:e,mutationFn:t,config:n={}})=>{const r=X();return Q({mutationFn:t,onSettled:()=>{r.invalidateQueries({queryKey:e})},...n})};function rh({getAll:e,create:t,update:n,delete:r,idField:o="id",entityName:a="item"}){const i=[`crud-${o}`],{data:l=[],isLoading:s,refetch:u}=th({queryKey:i,queryFn:async()=>(await e()).data??[],config:{onError:e=>eh("error","Error al cargar los datos",e.message)}}),c={creado:"crear",actualizado:"actualizar",eliminado:"eliminar"},d=e=>({queryKey:i,config:{onSuccess:()=>{eh("success",`${a.charAt(0).toUpperCase()+a.slice(1)} ${e} exitosamente`,""),u()},onError:t=>eh("error",`Error al ${c[e]} el ${a}`,t.message)}}),{mutateAsync:f}=nh({...d("creado"),mutationFn:async e=>{if(!t)throw new Error("Create function is not defined");const n=await t(e);if(n.error)throw new Error(n.message);return n.data}}),{mutateAsync:p}=nh({...d("actualizado"),mutationFn:async e=>{if(!n)throw new Error("Update function is not defined");const t=await n(e);if(t.error)throw new Error(t.message);return t.data}}),{mutateAsync:h}=nh({...d("eliminado"),mutationFn:async e=>{if(!r)throw new Error("Delete function is not defined");return(await r(e)).data}});return{data:l,isLoading:s,refetch:u,handleCreate:async e=>{const t=e;return await f(t)},handleUpdate:async e=>{const t=e;return await p(t)},handleDelete:async e=>{const t=e;return await h(t)},createItemAsync:f,updateItemAsync:p,deleteItemAsync:h}}const oh=(e,t)=>{const[o,a]=n(),[i,l]=n(null),[s,u]=n(!0);return r((()=>{(async()=>{try{u(!0);const t=await e();a(t&&"object"==typeof t&&"data"in t?t.data:t)}catch(t){l(t instanceof Error?t:new Error("An error occurred"))}finally{u(!1)}})()}),t||[]),{data:o,error:i,loading:s}},ah=()=>function(e,t,n,r,o,a,i="",l={}){return{key:e,icon:t,label:i,style:l,tooltip:n,className:r,onClick:o,hidden:a}},ih=e=>e,lh={FULL_ACCESS:["create","read","update","delete","view","refresh","export"],READ_WRITE:["create","read","update","view","refresh"],READ_ONLY:["read","view"],VIEW_ONLY:["view"],NO_ACCESS:[]},sh=(...e)=>e;export{Kp as ApiVersioning,Oe as Btn,Yp as DynamicCrud,Fe as DynamicForm,Qe as DynamicTable,lh as PERMISSIONS,wr as PermissionsProvider,_e as Title,ah as createActionFactory,sh as createPermissions,ih as createPermissionsConfig,Zp as generateColumns,Jp as generateFields,eh as openNotification,qe as sortOrder,oh as useAsync,rh as useCrudOperations,nh as useMutationFetch,kr as usePermissions,th as useQueryFetch};
|