vicdev-ui-lib 1.0.1 → 1.0.2
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/dist/vicdev-ui-lib.cjs.js +7 -7
- package/dist/vicdev-ui-lib.es.js +292 -274
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),$=require("framer-motion"),f=require("lucide-react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),$=require("framer-motion"),f=require("lucide-react"),Y=require("react-dom"),G=require("primereact/datatable"),J=require("primereact/column"),T={primary:"#0f172a",primaryForeground:"#f8fafc",secondary:"#7ba63f",secondaryForeground:"#0f172a",accent:"#f1f5f9",accentForeground:"#0f172a",destructive:"#ef4444",destructiveForeground:"#f8fafc",background:"#ffffff",foreground:"#0f172a",card:"#ffffff",cardForeground:"#0f172a",border:"#e2e8f0",input:"#e2e8f0",ring:"#0f172a",muted:"#f1f5f9",mutedForeground:"#64748b",popover:"#ffffff",popoverForeground:"#0f172a",radio:"#e2e8f0",radioForeground:"#0f172a"},B={colors:T,name:"default",description:"Tema por defecto de vicdev-ui-lib"};function Q(t){return{colors:{...T,...t},name:"custom"}}function U(t){const{colors:r}=t;return`:root {
|
|
2
2
|
${Object.entries(r).map(([s,o])=>` --${s.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${o};`).join(`
|
|
3
3
|
`)}
|
|
4
|
-
}`}const
|
|
4
|
+
}`}const z=x.createContext(void 0);function R({theme:t=B,children:r,injectCSS:n=!0}){const[s,o]=x.useState(t);x.useEffect(()=>{if(n&&typeof document<"u"){let l=document.getElementById("vicdev-ui-theme-variables");return l||(l=document.createElement("style"),l.id="vicdev-ui-theme-variables",document.head.appendChild(l)),l.textContent=U(s),()=>{}}},[s,n]),x.useEffect(()=>{o(t)},[t]);const a={theme:s,setTheme:o};return e.jsx(z.Provider,{value:a,children:r})}function ee(){return x.useContext(z)}const O=x.createContext(void 0);function te({config:t={},children:r}){const n=x.useMemo(()=>({theme:t.theme,injectCSS:t.injectCSS??!0,modalZIndex:t.modalZIndex??0,toastZIndex:t.toastZIndex??0,animationDuration:t.animationDuration??300,enableAnimations:t.enableAnimations??!0,components:{modal:{defaultSize:t.components?.modal?.defaultSize??"lg"},button:{defaultVariant:t.components?.button?.defaultVariant??"primary"},toast:{defaultDuration:t.components?.toast?.defaultDuration??3e3,position:t.components?.toast?.position??"top-right"}}}),[t]),s=x.useMemo(()=>({config:n,updateConfig:o=>{console.warn("updateConfig: Esta funcionalidad está en desarrollo")}}),[n]);return e.jsx(O.Provider,{value:s,children:e.jsx(R,{theme:t.theme,injectCSS:t.injectCSS,children:r})})}function _(){return x.useContext(O)}function W(t){const r={...T,...t};return{primary:{DEFAULT:r.primary,foreground:r.primaryForeground},secondary:{DEFAULT:r.secondary,foreground:r.secondaryForeground},accent:{DEFAULT:r.accent,foreground:r.accentForeground},destructive:{DEFAULT:r.destructive,foreground:r.destructiveForeground},background:r.background,foreground:r.foreground,card:{DEFAULT:r.card,foreground:r.cardForeground},border:r.border,input:r.input,ring:r.ring,muted:{DEFAULT:r.muted,foreground:r.mutedForeground},popover:{DEFAULT:r.popover,foreground:r.popoverForeground},radio:{DEFAULT:r.radio,foreground:r.radioForeground}}}function re(t){return{extend:{colors:W(t),borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}}}}function Z(t){const r={...T,...t};return`@theme {
|
|
5
5
|
${Object.entries(r).map(([s,o])=>` --color-${s.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${o};`).join(`
|
|
6
6
|
`)}
|
|
7
7
|
|
|
@@ -12,16 +12,16 @@ ${Object.entries(r).map(([s])=>{const o=s.replace(/([A-Z])/g,"-$1").toLowerCase(
|
|
|
12
12
|
`)}
|
|
13
13
|
}`}function se(t){const r=Z(t),n=q(t);return`${r}
|
|
14
14
|
|
|
15
|
-
${n}`}const M={primary:"bg-primary text-primary-foreground hover:bg-primary/90 font-bold shadow-lg",secondary:"bg-white border-2 border-border/20 text-foreground hover:border-border/40 hover:bg-card shadow-sm",accent:"bg-gradient-to-r from-accent to-accent/90 text-accent-foreground hover:shadow-lg",danger:"bg-destructive text-destructive-foreground hover:bg-destructive/90 border-0 shadow-lg hover:shadow-destructive/25",outline:"border-
|
|
15
|
+
${n}`}const M={primary:"bg-primary text-primary-foreground hover:bg-primary/90 font-bold shadow-lg",secondary:"bg-white border-2 border-border/20 text-foreground hover:border-border/40 hover:bg-card shadow-sm",accent:"bg-gradient-to-r from-accent to-accent/90 text-accent-foreground hover:shadow-lg",danger:"bg-destructive text-destructive-foreground hover:bg-destructive/90 border-0 shadow-lg hover:shadow-destructive/25",outline:"border-1 border-border/30 text-foreground hover:bg-card hover:border-border/50 shadow-sm",ghost:"text-foreground hover:bg-card hover:text-primary",success:"bg-green-500 text-white hover:bg-green-600 hover:shadow-green-400/20"},P=({onClick:t,icon:r,label:n,variant:s="primary",type:o="button",className:a="",disabled:l=!1,children:c,...d})=>e.jsxs("button",{onClick:t,type:o,disabled:l,className:`
|
|
16
16
|
flex items-center justify-center px-4 py-3 rounded-xl font-semibold text-sm
|
|
17
17
|
transition-all duration-300 hover:scale-[1.02] active:scale-[0.98] group
|
|
18
|
-
disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100 cursor-pointer
|
|
18
|
+
disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100 cursor-pointer hover:shadow-lg
|
|
19
19
|
${M[s]??M.primary} ${a}
|
|
20
|
-
`,...d,children:[r&&e.jsx(r,{size:20,className:`${n?"mr-2":""} ${l?"":"group-hover:rotate-12"} transition-transform duration-300`}),n,c]}),V={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[90vw]",fullscreen:"w-[95vw] h-[95vh]"};function H({isOpen:t,onClose:r,title:n="",tamaño:s="lg",children:o,canClose:a=!0}){const l=_(),c=l?l.config.modalZIndex+99999:99999;x.useEffect(()=>{if(t){const u=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${u}px`,document.body.style.width="100%",document.body.style.overflow="hidden",()=>{const p=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",p&&window.scrollTo(0,parseInt(p||"0")*-1)}}},[t]);const d=e.jsx($.AnimatePresence,{children:t&&e.jsx(e.Fragment,{children:e.jsx($.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 backdrop-blur-
|
|
20
|
+
`,...d,children:[r&&e.jsx(r,{size:20,className:`${n?"mr-2":""} ${l?"":"group-hover:rotate-12"} transition-transform duration-300`}),n,c]}),V={sm:"max-w-sm",md:"max-w-md",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-[90vw]",fullscreen:"w-[95vw] h-[95vh]"};function H({isOpen:t,onClose:r,title:n="",tamaño:s="lg",children:o,canClose:a=!0}){const l=_(),c=l?l.config.modalZIndex+99999:99999;x.useEffect(()=>{if(t){const u=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${u}px`,document.body.style.width="100%",document.body.style.overflow="hidden",()=>{const p=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",p&&window.scrollTo(0,parseInt(p||"0")*-1)}}},[t]);const d=e.jsx($.AnimatePresence,{children:t&&e.jsx(e.Fragment,{children:e.jsx($.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4",onClick:a?r:u=>u.stopPropagation(),style:{position:"fixed",top:0,left:0,right:0,bottom:0,margin:0,padding:s==="fullscreen"?"0.5rem":"1rem",zIndex:c},children:e.jsxs($.motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{type:"spring",damping:20,stiffness:300},className:`
|
|
21
21
|
bg-background shadow-2xl w-full overflow-hidden relative border border-border/50
|
|
22
22
|
${s==="fullscreen"?"rounded-none h-[95vh]":"rounded-2xl max-h-[95vh]"}
|
|
23
23
|
${V[s]||V.md}
|
|
24
|
-
`,onClick:u=>u.stopPropagation(),style:{maxHeight:"95vh",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{className:"bg-linear-to-r from-primary to-secondary p-4 flex justify-between items-center sticky top-0 z-10 border-b border-primary-foreground/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-primary-foreground/20 rounded-lg flex items-center justify-center",children:e.jsx("div",{className:"w-4 h-4 bg-primary-foreground rounded-full"})}),e.jsx("h2",{className:"text-lg font-bold text-primary-foreground",children:n})]}),a?e.jsx("button",{onClick:r,className:"text-primary-foreground hover:text-primary-foreground/80 hover:bg-primary-foreground/10 p-2 rounded-lg transition-all duration-200",children:e.jsx(f.X,{size:24})}):e.jsx("div",{className:"w-10 h-10 flex items-center justify-center",children:e.jsx("div",{className:"w-5 h-5 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin"})})]}),e.jsx("div",{className:`overflow-y-auto bg-linear-to-b from-background to-card/30 ${s==="fullscreen"?"p-8 flex-1":"p-6 flex-1"}`,style:{maxHeight:"calc(95vh - 80px)",minHeight:0},children:o})]})})})});return typeof window<"u"?G.createPortal(d,document.body):d}const ne=({isOpen:t,onClose:r,onConfirm:n,loading:s=!1,entidad:o})=>{if(!t)return null;const{tipo:a="elemento",nombre:l="",dependencias:c=0,nombreDependencia:d=""}=o||{};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background rounded-2xl shadow-2xl max-w-md w-full p-6 transform transition-all",children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 mx-auto mb-4 bg-destructive/10 rounded-full",children:e.jsx(f.AlertTriangle,{className:"w-8 h-8 text-destructive"})}),e.jsxs("h3",{className:"text-xl font-bold text-foreground text-center mb-2",children:["¿Eliminar ",a,"?"]}),e.jsxs("p",{className:"text-muted-foreground text-center mb-6",children:["Esta acción eliminará ",a==="producto"?"el":"la"," ",e.jsxs("strong",{children:[a,' "',l,'"']}),c>0&&d?e.jsxs(e.Fragment,{children:[" y afectará a ",e.jsxs("strong",{children:[c," ",d]}),"."]}):null,e.jsx("br",{}),"Esta acción no se puede deshacer."]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>r(!1),className:"flex-1 px-4 py-3 border border-border text-foreground rounded-xl hover:bg-card transition-colors",children:"Cancelar"}),e.jsx("button",{onClick:n,disabled:s,className:`flex-1 px-4 py-3 ${s?"bg-destructive/70":"bg-destructive hover:bg-destructive/90"} text-destructive-foreground rounded-xl transition-colors`,children:s?"Cargando...":"Eliminar"})]})]})})},oe={success:{container:"bg-primary/10 border-primary/30 text-primary",icon:f.CheckCircle},error:{container:"bg-destructive/10 border-destructive/30 text-destructive",icon:f.XCircle},info:{container:"bg-blue-500/10 border-blue-500/30 text-blue-600 dark:text-blue-400",icon:f.Info},warning:{container:"bg-amber-500/10 border-amber-500/30 text-amber-700 dark:text-amber-400",icon:f.AlertTriangle}};function ae({message:t,variant:r="info",open:n,onClose:s,autoClose:o,className:a=""}){const{container:l,icon:c}=oe[r];return x.useEffect(()=>{if(!n||!o)return;const d=setTimeout(s,o);return()=>clearTimeout(d)},[n,o,s]),n?e.jsxs("div",{role:"alert",className:`fixed top-20 right-4 z-[9999] max-w-md flex items-center gap-3 px-4 py-3 rounded-xl border shadow-xl shadow-black/10 dark:shadow-black/30 animate-in slide-in-from-top-5 fade-in duration-300 ${l} ${a}`,children:[e.jsx(c,{className:"w-5 h-5 shrink-0","aria-hidden":!0}),e.jsx("p",{className:"font-medium flex-1",children:t}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 p-1 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring","aria-label":"Cerrar",children:e.jsx(f.X,{className:"w-4 h-4"})})]}):null}const ie="No hay registros para mostrar.",le=10,ce=[10,25,50];function de({value:t,columns:r,dataKey:n,emptyMessage:s=ie,loading:o=!1,paginator:a=!1,rows:l=le,rowsPerPageOptions:c=ce,size:d="normal",stripedRows:u=!1,showGridlines:p=!1,className:g,style:h}){const y=r.filter(i=>!i.hidden);return e.jsx("div",{className:`data-table-viva overflow-hidden rounded-lg border border-border bg-card ${g??""}`.trim(),style:h,children:e.jsx(Y.DataTable,{value:t,dataKey:n,loading:o,emptyMessage:s,paginator:a,rows:l,rowsPerPageOptions:c,size:d,stripedRows:u,showGridlines:p,paginatorTemplate:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown",currentPageReportTemplate:"Mostrando {first} a {last} de {totalRecords} registros",children:y.map(i=>e.jsx(J.Column,{field:i.field,header:i.header,sortable:i.sortable??!1,align:i.align,alignHeader:i.alignHeader,style:i.style,bodyClassName:i.bodyClassName,body:i.body?b=>i.body(b):void 0},String(i.field)))})})}function ue(t){return e.jsx(de,{...t})}const me="w-full px-4 py-3 border text-base border-input rounded-xl focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-all bg-background shadow-sm",fe="w-full pl-4 pr-12 py-3 border text-base border-input rounded-xl focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-all bg-background shadow-sm",xe="w-full px-4 pt-6 pb-2 border text-base border-input rounded-xl focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-all bg-background shadow-sm",pe="w-full pl-4 pr-12 pt-6 pb-2 border text-base border-input rounded-xl focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-all bg-background shadow-sm";function ge({label:t,id:r,name:n,type:s="text",value:o="",onChange:a,onBlur:l,placeholder:c,required:d=!1,options:u=[],rows:p=4,className:g="",floatingLabel:h=!1,helperText:y,disabled:i=!1,inputMode:b}){const[S,C]=x.useState(!1),[v,k]=x.useState(!1),j=x.useRef(null),E=h&&(S||o!==""&&o!==void 0&&o!==null),m=s==="password",w=m&&v?"text":s,L=()=>{C(!0)},I=N=>{C(!1),l?.(N)},F=h?m?pe:xe:m?fe:me,A=()=>{k(!v)};return e.jsxs("div",{className:g,children:[h?e.jsxs("div",{className:"relative",children:[t&&e.jsxs("label",{htmlFor:r,className:`absolute left-4 transition-all duration-200 pointer-events-none ${E?"top-2 text-xs text-muted-foreground font-medium":"top-1/2 -translate-y-1/2 text-base text-muted-foreground/70"}`,children:[t,d&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s==="textarea"?e.jsx("textarea",{ref:j,id:r,name:n,value:o,onChange:a,onFocus:L,onBlur:I,placeholder:E?c:"",rows:p,disabled:i,className:`${F} resize-none`}):s==="select"?e.jsxs("select",{ref:j,id:r,name:n,value:o,onChange:a,onFocus:L,onBlur:I,disabled:i,className:F,children:[e.jsx("option",{value:"",children:"Seleccionar opción"}),u.map(N=>e.jsx("option",{value:N.value,children:N.label},N.value))]}):e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:j,type:w,id:r,name:n,value:o,onChange:a,onFocus:L,onBlur:I,placeholder:E?c:"",disabled:i,inputMode:b,className:F}),m&&e.jsx("button",{type:"button",onClick:A,className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors focus:outline-none focus:ring-2 focus:ring-ring rounded p-1","aria-label":v?"Ocultar contraseña":"Mostrar contraseña",children:v?e.jsx(f.EyeOff,{className:"w-5 h-5"}):e.jsx(f.Eye,{className:"w-5 h-5"})})]})]}):e.jsxs(e.Fragment,{children:[t&&e.jsxs("label",{htmlFor:r,className:"block text-base font-semibold text-foreground mb-2",children:[t,d&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s==="textarea"?e.jsx("textarea",{id:r,name:n,value:o,onChange:a,placeholder:c,rows:p,disabled:i,className:`${F} resize-none`}):s==="select"?e.jsxs("select",{id:r,name:n,value:o,onChange:a,disabled:i,className:F,children:[e.jsx("option",{value:"",children:"Seleccionar opción"}),u.map(N=>e.jsx("option",{value:N.value,children:N.label},N.value))]}):e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:w,id:r,name:n,value:o,onChange:a,onFocus:L,onBlur:I,placeholder:c,disabled:i,inputMode:b,className:F}),m&&e.jsx("button",{type:"button",onClick:A,className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors focus:outline-none focus:ring-2 focus:ring-ring rounded p-1","aria-label":v?"Ocultar contraseña":"Mostrar contraseña",children:v?e.jsx(f.EyeOff,{className:"w-5 h-5"}):e.jsx(f.Eye,{className:"w-5 h-5"})})]})]}),y&&e.jsx("p",{className:`mt-2 text-sm ${g?.includes("border-red-500")?"text-destructive":"text-muted-foreground"}`,children:y})]})}function he({value:t,onChange:r,placeholder:n="Buscar...",className:s=""}){return e.jsxs("div",{className:`relative ${s}`,children:[e.jsx(f.Search,{className:"absolute left-4 top-1/2 transform -translate-y-1/2 w-5 h-5 text-gray-400"}),e.jsx("input",{type:"text",value:t,onChange:o=>r(o.target.value),placeholder:n,className:"w-full pl-12 pr-4 py-3 bg-white border-2 border-gray-200 rounded-xl focus:ring-2 focus:ring-uno focus:border-uno transition-all text-sm font-medium text-divisiones placeholder-gray-400"}),t&&e.jsx("button",{onClick:()=>r(""),className:"absolute right-4 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-divisiones transition-colors",type:"button",children:e.jsx(f.X,{className:"w-4 h-4"})})]})}function be({id:t,name:r,label:n,accept:s=".pdf,application/pdf",required:o=!1,helperText:a,onChange:l,error:c,disabled:d=!1,maxSizeMB:u=10,currentFileName:p}){const[g,h]=x.useState(null),[y,i]=x.useState(!1),b=x.useRef(null),S=m=>{if(s.includes("pdf")&&m.type!=="application/pdf")return"El archivo debe ser un PDF";const w=u*1024*1024;return m.size>w?`El archivo no debe superar ${u}MB`:null},C=m=>{if(!m){h(null),l(null);return}if(S(m)){l(null);return}h(m),l(m)},v=m=>{const w=m.target.files?.[0]||null;C(w)},k=m=>{m.preventDefault(),m.stopPropagation(),m.type==="dragenter"||m.type==="dragover"?i(!0):m.type==="dragleave"&&i(!1)},j=m=>{if(m.preventDefault(),m.stopPropagation(),i(!1),d)return;const w=m.dataTransfer.files?.[0];w&&C(w)},D=()=>{h(null),l(null),b.current&&(b.current.value="")},E=()=>{d||b.current?.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:t,className:"block text-sm font-medium text-foreground",children:[n,o&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:`
|
|
24
|
+
`,onClick:u=>u.stopPropagation(),style:{maxHeight:"95vh",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{className:"bg-linear-to-r from-primary to-secondary p-4 flex justify-between items-center sticky top-0 z-10 border-b border-primary-foreground/20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-primary-foreground/20 rounded-lg flex items-center justify-center",children:e.jsx("div",{className:"w-4 h-4 bg-primary-foreground rounded-full"})}),e.jsx("h2",{className:"text-lg font-bold text-primary-foreground",children:n})]}),a?e.jsx("button",{onClick:r,className:"text-primary-foreground hover:text-primary-foreground/80 hover:bg-primary-foreground/10 p-2 rounded-lg transition-all duration-200",children:e.jsx(f.X,{size:24})}):e.jsx("div",{className:"w-10 h-10 flex items-center justify-center",children:e.jsx("div",{className:"w-5 h-5 border-2 border-primary-foreground/30 border-t-primary-foreground rounded-full animate-spin"})})]}),e.jsx("div",{className:`overflow-y-auto bg-linear-to-b from-background to-card/30 ${s==="fullscreen"?"p-8 flex-1":"p-6 flex-1"}`,style:{maxHeight:"calc(95vh - 80px)",minHeight:0},children:o})]})})})});return typeof window<"u"?Y.createPortal(d,document.body):d}const ne=({isOpen:t,onClose:r,onConfirm:n,loading:s=!1,entidad:o})=>{if(!t)return null;const{tipo:a="elemento",nombre:l="",dependencias:c=0,nombreDependencia:d=""}=o||{};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background rounded-2xl shadow-2xl max-w-md w-full p-6 transform transition-all",children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 mx-auto mb-4 bg-destructive/10 rounded-full",children:e.jsx(f.AlertTriangle,{className:"w-8 h-8 text-destructive"})}),e.jsxs("h3",{className:"text-xl font-bold text-foreground text-center mb-2",children:["¿Eliminar ",a,"?"]}),e.jsxs("p",{className:"text-muted-foreground text-center mb-6",children:["Esta acción eliminará ",a==="producto"?"el":"la"," ",e.jsxs("strong",{children:[a,' "',l,'"']}),c>0&&d?e.jsxs(e.Fragment,{children:[" y afectará a ",e.jsxs("strong",{children:[c," ",d]}),"."]}):null,e.jsx("br",{}),"Esta acción no se puede deshacer."]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>r(!1),className:"flex-1 px-4 py-3 border border-border text-foreground rounded-xl hover:bg-card transition-colors",children:"Cancelar"}),e.jsx("button",{onClick:n,disabled:s,className:`flex-1 px-4 py-3 ${s?"bg-destructive/70":"bg-destructive hover:bg-destructive/90"} text-destructive-foreground rounded-xl transition-colors`,children:s?"Cargando...":"Eliminar"})]})]})})},oe={success:{container:"bg-primary/10 border-primary/30 text-primary",icon:f.CheckCircle},error:{container:"bg-destructive/10 border-destructive/30 text-destructive",icon:f.XCircle},info:{container:"bg-blue-500/10 border-blue-500/30 text-blue-600 dark:text-blue-400",icon:f.Info},warning:{container:"bg-amber-500/10 border-amber-500/30 text-amber-700 dark:text-amber-400",icon:f.AlertTriangle}};function ae({message:t,variant:r="info",open:n,onClose:s,autoClose:o,className:a=""}){const{container:l,icon:c}=oe[r];return x.useEffect(()=>{if(!n||!o)return;const d=setTimeout(s,o);return()=>clearTimeout(d)},[n,o,s]),n?e.jsxs("div",{role:"alert",className:`fixed top-20 right-4 z-[9999] max-w-md flex items-center gap-3 px-4 py-3 rounded-xl border shadow-xl shadow-black/10 dark:shadow-black/30 animate-in slide-in-from-top-5 fade-in duration-300 ${l} ${a}`,children:[e.jsx(c,{className:"w-5 h-5 shrink-0","aria-hidden":!0}),e.jsx("p",{className:"font-medium flex-1",children:t}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 p-1 rounded-lg hover:bg-black/5 dark:hover:bg-white/5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring","aria-label":"Cerrar",children:e.jsx(f.X,{className:"w-4 h-4"})})]}):null}const ie="No hay registros para mostrar.",le=10,ce=[10,25,50];function de({value:t,columns:r,dataKey:n,emptyMessage:s=ie,loading:o=!1,paginator:a=!1,rows:l=le,rowsPerPageOptions:c=ce,size:d="normal",stripedRows:u=!1,showGridlines:p=!1,className:g,style:h}){const y=r.filter(i=>!i.hidden);return e.jsx("div",{className:`data-table-viva overflow-hidden rounded-lg border border-border bg-card ${g??""}`.trim(),style:h,children:e.jsx(G.DataTable,{value:t,dataKey:n,loading:o,emptyMessage:s,paginator:a,rows:l,rowsPerPageOptions:c,size:d,stripedRows:u,showGridlines:p,paginatorTemplate:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown",currentPageReportTemplate:"Mostrando {first} a {last} de {totalRecords} registros",children:y.map(i=>e.jsx(J.Column,{field:i.field,header:i.header,sortable:i.sortable??!1,align:i.align,alignHeader:i.alignHeader,style:i.style,bodyClassName:i.bodyClassName,body:i.body?b=>i.body(b):void 0},String(i.field)))})})}function ue(t){return e.jsx(de,{...t})}const me="w-full px-4 py-3 border text-base border-input rounded-xl focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-all bg-background shadow-sm",fe="w-full pl-4 pr-12 py-3 border text-base border-input rounded-xl focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-all bg-background shadow-sm",xe="w-full px-4 pt-6 pb-2 border text-base border-input rounded-xl focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-all bg-background shadow-sm",pe="w-full pl-4 pr-12 pt-6 pb-2 border text-base border-input rounded-xl focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent transition-all bg-background shadow-sm";function ge({label:t,id:r,name:n,type:s="text",value:o="",onChange:a,onBlur:l,placeholder:c,required:d=!1,options:u=[],rows:p=4,className:g="",floatingLabel:h=!1,helperText:y,disabled:i=!1,inputMode:b}){const[S,C]=x.useState(!1),[v,k]=x.useState(!1),j=x.useRef(null),E=h&&(S||o!==""&&o!==void 0&&o!==null),m=s==="password",w=m&&v?"text":s,L=()=>{C(!0)},I=N=>{C(!1),l?.(N)},F=h?m?pe:xe:m?fe:me,A=()=>{k(!v)};return e.jsxs("div",{className:g,children:[h?e.jsxs("div",{className:"relative",children:[t&&e.jsxs("label",{htmlFor:r,className:`absolute left-4 transition-all duration-200 pointer-events-none ${E?"top-2 text-xs text-muted-foreground font-medium":"top-1/2 -translate-y-1/2 text-base text-muted-foreground/70"}`,children:[t,d&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s==="textarea"?e.jsx("textarea",{ref:j,id:r,name:n,value:o,onChange:a,onFocus:L,onBlur:I,placeholder:E?c:"",rows:p,disabled:i,className:`${F} resize-none`}):s==="select"?e.jsxs("select",{ref:j,id:r,name:n,value:o,onChange:a,onFocus:L,onBlur:I,disabled:i,className:F,children:[e.jsx("option",{value:"",children:"Seleccionar opción"}),u.map(N=>e.jsx("option",{value:N.value,children:N.label},N.value))]}):e.jsxs("div",{className:"relative",style:{position:"relative"},children:[e.jsx("input",{ref:j,type:w,id:r,name:n,value:o,onChange:a,onFocus:L,onBlur:I,placeholder:E?c:"",disabled:i,inputMode:b,className:F}),m&&e.jsx("button",{type:"button",onClick:A,className:"absolute text-muted-foreground hover:text-foreground transition-colors focus:outline-none focus:ring-2 focus:ring-ring rounded p-1 z-10",style:{position:"absolute",right:"0.75rem",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center"},"aria-label":v?"Ocultar contraseña":"Mostrar contraseña",children:v?e.jsx(f.EyeOff,{className:"w-5 h-5",style:{width:"1.25rem",height:"1.25rem"}}):e.jsx(f.Eye,{className:"w-5 h-5",style:{width:"1.25rem",height:"1.25rem"}})})]})]}):e.jsxs(e.Fragment,{children:[t&&e.jsxs("label",{htmlFor:r,className:"block text-base font-semibold text-foreground mb-2",children:[t,d&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s==="textarea"?e.jsx("textarea",{id:r,name:n,value:o,onChange:a,placeholder:c,rows:p,disabled:i,className:`${F} resize-none`}):s==="select"?e.jsxs("select",{id:r,name:n,value:o,onChange:a,disabled:i,className:F,children:[e.jsx("option",{value:"",children:"Seleccionar opción"}),u.map(N=>e.jsx("option",{value:N.value,children:N.label},N.value))]}):e.jsxs("div",{className:"relative",style:{position:"relative"},children:[e.jsx("input",{type:w,id:r,name:n,value:o,onChange:a,onFocus:L,onBlur:I,placeholder:c,disabled:i,inputMode:b,className:F}),m&&e.jsx("button",{type:"button",onClick:A,className:"absolute text-muted-foreground hover:text-foreground transition-colors focus:outline-none focus:ring-2 focus:ring-ring rounded p-1 z-10",style:{position:"absolute",right:"0.75rem",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",justifyContent:"center"},"aria-label":v?"Ocultar contraseña":"Mostrar contraseña",children:v?e.jsx(f.EyeOff,{className:"w-5 h-5",style:{width:"1.25rem",height:"1.25rem"}}):e.jsx(f.Eye,{className:"w-5 h-5",style:{width:"1.25rem",height:"1.25rem"}})})]})]}),y&&e.jsx("p",{className:`mt-2 text-sm ${g?.includes("border-red-500")?"text-destructive":"text-muted-foreground"}`,children:y})]})}function he({value:t,onChange:r,placeholder:n="Buscar...",className:s=""}){return e.jsxs("div",{className:`relative ${s}`,children:[e.jsx(f.Search,{className:"absolute left-4 top-1/2 transform -translate-y-1/2 w-5 h-5 text-gray-400"}),e.jsx("input",{type:"text",value:t,onChange:o=>r(o.target.value),placeholder:n,className:"w-full pl-12 pr-4 py-3 bg-white border-2 border-gray-200 rounded-xl focus:ring-2 focus:ring-uno focus:border-uno transition-all text-sm font-medium text-divisiones placeholder-gray-400"}),t&&e.jsx("button",{onClick:()=>r(""),className:"absolute right-4 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-divisiones transition-colors",type:"button",children:e.jsx(f.X,{className:"w-4 h-4"})})]})}function be({id:t,name:r,label:n,accept:s=".pdf,application/pdf",required:o=!1,helperText:a,onChange:l,error:c,disabled:d=!1,maxSizeMB:u=10,currentFileName:p}){const[g,h]=x.useState(null),[y,i]=x.useState(!1),b=x.useRef(null),S=m=>{if(s.includes("pdf")&&m.type!=="application/pdf")return"El archivo debe ser un PDF";const w=u*1024*1024;return m.size>w?`El archivo no debe superar ${u}MB`:null},C=m=>{if(!m){h(null),l(null);return}if(S(m)){l(null);return}h(m),l(m)},v=m=>{const w=m.target.files?.[0]||null;C(w)},k=m=>{m.preventDefault(),m.stopPropagation(),m.type==="dragenter"||m.type==="dragover"?i(!0):m.type==="dragleave"&&i(!1)},j=m=>{if(m.preventDefault(),m.stopPropagation(),i(!1),d)return;const w=m.dataTransfer.files?.[0];w&&C(w)},D=()=>{h(null),l(null),b.current&&(b.current.value="")},E=()=>{d||b.current?.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:t,className:"block text-sm font-medium text-foreground",children:[n,o&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs("div",{className:`
|
|
25
25
|
relative border-2 border-dashed rounded-lg p-6 transition-all
|
|
26
26
|
${y?"border-primary bg-primary/5":"border-border"}
|
|
27
27
|
${d?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-primary/50"}
|
|
@@ -31,4 +31,4 @@ ${n}`}const M={primary:"bg-primary text-primary-foreground hover:bg-primary/90 f
|
|
|
31
31
|
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary/50
|
|
32
32
|
${a?"cursor-not-allowed":"cursor-pointer"}
|
|
33
33
|
${c?"bg-gradient-to-r from-green-500 to-green-600":"bg-muted"}
|
|
34
|
-
`,whileTap:a?{}:{scale:.95},"aria-label":c?"Desactivar":"Activar","aria-checked":c,role:"switch",children:e.jsx($.motion.div,{className:"w-6 h-6 bg-white rounded-full shadow-lg flex items-center justify-center",animate:{x:c?26:0},transition:{type:"spring",stiffness:500,damping:30},children:c?e.jsx(f.Check,{className:"w-4 h-4 text-green-600"}):e.jsx(f.X,{className:"w-4 h-4 text-muted-foreground"})})})]})}const je=t=>{const r=typeof t=="string"?parseFloat(t):t;return new Intl.NumberFormat("es-CO",{style:"currency",currency:"COP",minimumFractionDigits:0,maximumFractionDigits:0}).format(r)};function we({value:t,className:r="",bold:n=!1,primary:s=!1,secondary:o=!1,success:a=!1,error:l=!1,size:c="base",emptyText:d="-"}){if(t==null)return e.jsx("span",{className:`text-muted-foreground ${r}`,children:d});const u=typeof t=="string"?parseFloat(t):t;if(isNaN(u))return e.jsx("span",{className:`text-muted-foreground ${r}`,children:d});const p=je(u),g={sm:"text-sm",base:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl"},h=s?"text-primary":o?"text-secondary":a?"text-green-600 dark:text-green-400":l?"text-destructive":"text-foreground",y=n?"font-bold":"font-normal";return e.jsx("span",{className:`${g[c]} ${h} ${y} ${r}`,children:p})}const Ne={small:{width:60,height:45},default:{width:120,height:90},large:{width:180,height:135}},Ce={default:"/logo.png",logo2:"/logo2.png",white:"/logoW.png",whiteNoBg:"/logoW_sin_bg.png"},ke=({size:t="default",variant:r="whiteNoBg",src:n,alt:s="Logo de Buenity",className:o="",fondoColor:a="transparent",animated:l=!1,animationType:c="fade",animationDuration:d=1})=>{const{width:u,height:p}=Ne[t],g=n||Ce[r],y=(()=>{if(!l)return{};const b={initial:{opacity:0},animate:{opacity:1},transition:{duration:d}};switch(c){case"fade":return{...b,initial:{opacity:0},animate:{opacity:1}};case"scale":return{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:d,ease:"easeOut"}};case"pulse":return{initial:{opacity:0,scale:1},animate:{opacity:1,scale:[1,1.05,1]},transition:{duration:d,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}};case"bounce":return{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:d,type:"spring",stiffness:200,damping:10}};case"rotate":return{initial:{opacity:0,rotate:-180},animate:{opacity:1,rotate:0},transition:{duration:d,ease:"easeOut"}};default:return b}})(),i={className:"flex items-center rounded-xl justify-center",style:{backgroundColor:a},...l?y:{}};return l?e.jsx($.motion.div,{...i,children:e.jsx("img",{src:g,width:u,height:p,alt:s,className:`object-contain ${o}`})}):e.jsx("div",{...i,children:e.jsx("img",{src:g,width:u,height:p,alt:s,className:`object-contain ${o}`})})};function K(t){const r=t.split("?")[0],n=r.match(/rp-(\d+)/i);if(n)return`rp-${n[1]}`;const s=r.split("/");return(s[s.length-1]||"").replace(/\.(pdf|jpg|jpeg|png|gif|webp)$/i,"")||"Soporte"}function Fe({url:t,isOpen:r,onClose:n,displayName:s}){const[o,a]=x.useState(!0),[l,c]=x.useState(null),[d,u]=x.useState("unknown");x.useEffect(()=>{if(!t){u("unknown"),a(!1);return}const i=t.toLowerCase();i.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp)$/)?u("image"):i.match(/\.pdf$/)||i.includes("application/pdf")?u("pdf"):u("unknown"),a(!1),c(null)},[t]);const p=()=>{c("Error al cargar la imagen"),a(!1)},g=()=>{if(!t)return;const i=document.createElement("a");i.href=t,i.download=h,i.target="_blank",document.body.appendChild(i),i.click(),document.body.removeChild(i)},h=s??(t?K(t):"Archivo"),y=()=>{switch(d){case"image":return e.jsx(f.Image,{className:"w-6 h-6 text-primary"});case"pdf":return e.jsx(f.FileText,{className:"w-6 h-6 text-primary"});default:return e.jsx(f.File,{className:"w-6 h-6 text-primary"})}};return r?e.jsx(H,{isOpen:!0,onClose:n,title:h,tamaño:"fullscreen",canClose:!0,children:e.jsx("div",{className:"flex flex-col h-full min-h-[90dvh]",children:e.jsxs("div",{className:"flex-1 overflow-auto mt-4 bg-muted/30 rounded-xl p-4 min-h-[60vh]",children:[!t&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-muted-foreground",children:[e.jsx(f.File,{className:"w-12 h-12 mb-4 opacity-50"}),e.jsx("p",{children:"No hay archivo para visualizar."})]}),t&&o&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-muted-foreground",children:[e.jsx(f.Loader2,{className:"w-12 h-12 text-primary animate-spin mb-4"}),e.jsx("p",{children:"Cargando archivo..."})]}),t&&l&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(f.AlertCircle,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:"Error al cargar el archivo"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:l}),e.jsx(P,{type:"button",variant:"primary",icon:f.Download,label:"Intentar descargar",onClick:g})]}),t&&!o&&!l&&e.jsxs(e.Fragment,{children:[d==="image"&&e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("img",{src:t,alt:h,onError:p,onLoad:()=>a(!1),className:"max-w-full max-h-[75vh] object-contain rounded-lg shadow-lg border border-border"})}),d==="pdf"&&e.jsx("div",{className:"flex items-center justify-center min-h-[82dvh] w-full",children:e.jsx("iframe",{src:t,onLoad:()=>a(!1),className:"w-full h-[75vh] rounded-lg shadow-lg bg-background border border-border",title:h})}),d==="unknown"&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-muted rounded-full flex items-center justify-center mx-auto mb-4",children:y()}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:"Tipo de archivo no soportado para vista previa"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Puede descargar el archivo para abrirlo en su dispositivo."}),e.jsx(P,{type:"button",variant:"primary",icon:f.Download,label:"Descargar archivo",onClick:g})]})]})]})})}):null}function $e({url:t,displayName:r,icon:n,className:s="inline-flex items-center gap-2 text-primary hover:text-primary/80 hover:underline font-medium"}){const o=t.startsWith("http")||t.startsWith("//")?t:`${typeof window<"u"?window.location.origin:""}${t.startsWith("/")?t:`/${t}`}`;return e.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:s,children:[n??e.jsx(f.FileText,{className:"w-4 h-4 shrink-0"}),r]})}const Te={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-10 w-10",xl:"h-16 w-16"},Se={primary:"text-primary",secondary:"text-secondary",muted:"text-muted-foreground",destructive:"text-destructive"};function X({size:t="md",variant:r="muted",className:n=""}){return e.jsxs("svg",{className:`${Te[t]} ${Se[r]} animate-spin ${n}`,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",role:"status","aria-label":"Cargando",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]})}function Ee({text:t="Cargando datos...",size:r="lg",variant:n="muted",className:s="",textClassName:o=""}){return e.jsx("div",{className:`w-full h-screen flex items-center justify-center p-6 ${s}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(X,{size:r,variant:n}),t&&e.jsx("span",{className:`text-lg font-semibold text-muted-foreground ${o}`,children:t})]})})}exports.ActionButton=P;exports.CurrencyDisplay=we;exports.DataTable=ue;exports.DeleteConfirmModal=ne;exports.FileLink=$e;exports.FileUpload=be;exports.FileViewerModal=Fe;exports.FormField=ge;exports.Loader=X;exports.LoaderScreen=Ee;exports.Logo=ke;exports.Modal=H;exports.MultiSelectCheckbox=ye;exports.SearchBar=he;exports.ThemeProvider=
|
|
34
|
+
`,whileTap:a?{}:{scale:.95},"aria-label":c?"Desactivar":"Activar","aria-checked":c,role:"switch",children:e.jsx($.motion.div,{className:"w-6 h-6 bg-white rounded-full shadow-lg flex items-center justify-center",animate:{x:c?26:0},transition:{type:"spring",stiffness:500,damping:30},children:c?e.jsx(f.Check,{className:"w-4 h-4 text-green-600"}):e.jsx(f.X,{className:"w-4 h-4 text-muted-foreground"})})})]})}const je=t=>{const r=typeof t=="string"?parseFloat(t):t;return new Intl.NumberFormat("es-CO",{style:"currency",currency:"COP",minimumFractionDigits:0,maximumFractionDigits:0}).format(r)};function we({value:t,className:r="",bold:n=!1,primary:s=!1,secondary:o=!1,success:a=!1,error:l=!1,size:c="base",emptyText:d="-"}){if(t==null)return e.jsx("span",{className:`text-muted-foreground ${r}`,children:d});const u=typeof t=="string"?parseFloat(t):t;if(isNaN(u))return e.jsx("span",{className:`text-muted-foreground ${r}`,children:d});const p=je(u),g={sm:"text-sm",base:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl"},h=s?"text-primary":o?"text-secondary":a?"text-green-600 dark:text-green-400":l?"text-destructive":"text-foreground",y=n?"font-bold":"font-normal";return e.jsx("span",{className:`${g[c]} ${h} ${y} ${r}`,children:p})}const Ne={small:{width:60,height:45},default:{width:120,height:90},large:{width:180,height:135}},Ce={default:"/logo.png",logo2:"/logo2.png",white:"/logoW.png",whiteNoBg:"/logoW_sin_bg.png"},ke=({size:t="default",variant:r="whiteNoBg",src:n,alt:s="Logo de Buenity",className:o="",fondoColor:a="transparent",animated:l=!1,animationType:c="fade",animationDuration:d=1})=>{const{width:u,height:p}=Ne[t],g=n||Ce[r],y=(()=>{if(!l)return{};const b={initial:{opacity:0},animate:{opacity:1},transition:{duration:d}};switch(c){case"fade":return{...b,initial:{opacity:0},animate:{opacity:1}};case"scale":return{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:d,ease:"easeOut"}};case"pulse":return{initial:{opacity:0,scale:1},animate:{opacity:1,scale:[1,1.05,1]},transition:{duration:d,repeat:1/0,repeatType:"reverse",ease:"easeInOut"}};case"bounce":return{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:d,type:"spring",stiffness:200,damping:10}};case"rotate":return{initial:{opacity:0,rotate:-180},animate:{opacity:1,rotate:0},transition:{duration:d,ease:"easeOut"}};default:return b}})(),i={className:"flex items-center rounded-xl justify-center",style:{backgroundColor:a},...l?y:{}};return l?e.jsx($.motion.div,{...i,children:e.jsx("img",{src:g,width:u,height:p,alt:s,className:`object-contain ${o}`})}):e.jsx("div",{...i,children:e.jsx("img",{src:g,width:u,height:p,alt:s,className:`object-contain ${o}`})})};function K(t){const r=t.split("?")[0],n=r.match(/rp-(\d+)/i);if(n)return`rp-${n[1]}`;const s=r.split("/");return(s[s.length-1]||"").replace(/\.(pdf|jpg|jpeg|png|gif|webp)$/i,"")||"Soporte"}function Fe({url:t,isOpen:r,onClose:n,displayName:s}){const[o,a]=x.useState(!0),[l,c]=x.useState(null),[d,u]=x.useState("unknown");x.useEffect(()=>{if(!t){u("unknown"),a(!1);return}const i=t.toLowerCase();i.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp)$/)?u("image"):i.match(/\.pdf$/)||i.includes("application/pdf")?u("pdf"):u("unknown"),a(!1),c(null)},[t]);const p=()=>{c("Error al cargar la imagen"),a(!1)},g=()=>{if(!t)return;const i=document.createElement("a");i.href=t,i.download=h,i.target="_blank",document.body.appendChild(i),i.click(),document.body.removeChild(i)},h=s??(t?K(t):"Archivo"),y=()=>{switch(d){case"image":return e.jsx(f.Image,{className:"w-6 h-6 text-primary"});case"pdf":return e.jsx(f.FileText,{className:"w-6 h-6 text-primary"});default:return e.jsx(f.File,{className:"w-6 h-6 text-primary"})}};return r?e.jsx(H,{isOpen:!0,onClose:n,title:h,tamaño:"fullscreen",canClose:!0,children:e.jsx("div",{className:"flex flex-col h-full min-h-[90dvh]",children:e.jsxs("div",{className:"flex-1 overflow-auto mt-4 bg-muted/30 rounded-xl p-4 min-h-[60vh]",children:[!t&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-muted-foreground",children:[e.jsx(f.File,{className:"w-12 h-12 mb-4 opacity-50"}),e.jsx("p",{children:"No hay archivo para visualizar."})]}),t&&o&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-muted-foreground",children:[e.jsx(f.Loader2,{className:"w-12 h-12 text-primary animate-spin mb-4"}),e.jsx("p",{children:"Cargando archivo..."})]}),t&&l&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(f.AlertCircle,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:"Error al cargar el archivo"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:l}),e.jsx(P,{type:"button",variant:"primary",icon:f.Download,label:"Intentar descargar",onClick:g})]}),t&&!o&&!l&&e.jsxs(e.Fragment,{children:[d==="image"&&e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("img",{src:t,alt:h,onError:p,onLoad:()=>a(!1),className:"max-w-full max-h-[75vh] object-contain rounded-lg shadow-lg border border-border"})}),d==="pdf"&&e.jsx("div",{className:"flex items-center justify-center min-h-[82dvh] w-full",children:e.jsx("iframe",{src:t,onLoad:()=>a(!1),className:"w-full h-[75vh] rounded-lg shadow-lg bg-background border border-border",title:h})}),d==="unknown"&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-muted rounded-full flex items-center justify-center mx-auto mb-4",children:y()}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:"Tipo de archivo no soportado para vista previa"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Puede descargar el archivo para abrirlo en su dispositivo."}),e.jsx(P,{type:"button",variant:"primary",icon:f.Download,label:"Descargar archivo",onClick:g})]})]})]})})}):null}function $e({url:t,displayName:r,icon:n,className:s="inline-flex items-center gap-2 text-primary hover:text-primary/80 hover:underline font-medium"}){const o=t.startsWith("http")||t.startsWith("//")?t:`${typeof window<"u"?window.location.origin:""}${t.startsWith("/")?t:`/${t}`}`;return e.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:s,children:[n??e.jsx(f.FileText,{className:"w-4 h-4 shrink-0"}),r]})}const Te={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-10 w-10",xl:"h-16 w-16"},Se={primary:"text-primary",secondary:"text-secondary",muted:"text-muted-foreground",destructive:"text-destructive"};function X({size:t="md",variant:r="muted",className:n=""}){return e.jsxs("svg",{className:`${Te[t]} ${Se[r]} animate-spin ${n}`,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",role:"status","aria-label":"Cargando",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]})}function Ee({text:t="Cargando datos...",size:r="lg",variant:n="muted",className:s="",textClassName:o=""}){return e.jsx("div",{className:`w-full h-screen flex items-center justify-center p-6 ${s}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(X,{size:r,variant:n}),t&&e.jsx("span",{className:`text-lg font-semibold text-muted-foreground ${o}`,children:t})]})})}exports.ActionButton=P;exports.CurrencyDisplay=we;exports.DataTable=ue;exports.DeleteConfirmModal=ne;exports.FileLink=$e;exports.FileUpload=be;exports.FileViewerModal=Fe;exports.FormField=ge;exports.Loader=X;exports.LoaderScreen=Ee;exports.Logo=ke;exports.Modal=H;exports.MultiSelectCheckbox=ye;exports.SearchBar=he;exports.ThemeProvider=R;exports.Toast=ae;exports.ToggleSwitch=ve;exports.VicdevUIProvider=te;exports.createTheme=Q;exports.defaultColors=T;exports.defaultTheme=B;exports.generateCSSVariables=U;exports.generateCompatibilityVariables=q;exports.generateTailwindV4CSS=se;exports.generateTailwindV4Theme=Z;exports.getRpSoporteDisplayName=K;exports.getTailwindColors=W;exports.getTailwindConfig=re;exports.useTheme=ee;exports.useVicdevUIConfig=_;
|