@dashadmin/dash-components 1.3.17 → 1.3.20
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/components/AuditLog/AuditLog.js +1 -0
- package/dist/components/AuditLog/index.js +1 -0
- package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +3 -0
- package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +1 -0
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +3 -0
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +42 -0
- package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +1 -0
- package/dist/components/Json/Json.js +1 -0
- package/dist/components/JsonColorSelector/JsonColorSelector.js +1 -0
- package/dist/components/JsonColorSelector/JsonColorSelector.tsx.bkup +746 -0
- package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +2 -0
- package/dist/components/JsonColorSelector/JsonCssVarValues.js +1 -0
- package/dist/components/JsonColorSelector/components/ColorEditDialog.js +1 -0
- package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +1 -0
- package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +1 -0
- package/dist/components/JsonColorSelector/helpers/functions.js +1 -0
- package/dist/components/JsonColorSelector/interfaces/interfaces.js +0 -0
- package/dist/components/JsonColorSelector/useAsyncColorThief.js +1 -0
- package/dist/components/ListActive/ListActive.js +1 -0
- package/dist/components/ListActive/ListBoolean.js +1 -0
- package/dist/components/NotificationPreferences/NotificationPreferences.js +1 -0
- package/dist/components/NotificationPreferences/index.js +1 -0
- package/dist/components/SearchableSelects/RASearchableSelect.js +1 -0
- package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +1 -0
- package/dist/components/SearchableSelects/RASearchableSelectChips.js +1 -0
- package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +1 -0
- package/dist/components/SearchableSelects/SearchableSelect.js +1 -0
- package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +1 -0
- package/dist/components/SortableDataGrid/README.md +1 -0
- package/dist/components/SortableDataGrid/SortableDataGrid.js +1 -0
- package/dist/components/SortableDataGrid/SortableDataGridBody.js +1 -0
- package/dist/components/SortableDataGrid/SortableDataGridHeader.js +1 -0
- package/dist/components/SortableDataGrid/SortableDataGridRow.js +1 -0
- package/dist/components/Upload/SingleImageUploader.js +1 -0
- package/dist/components/custom/PackageCopyMethod.js +1 -0
- package/dist/components/custom/PackageRadioButtonGroup.js +1 -0
- package/dist/components/dialog/Basic.js +1 -0
- package/dist/components/dialog/Correct.js +1 -0
- package/dist/components/dialog/Error.js +1 -0
- package/dist/components/dialog/Info.js +1 -0
- package/dist/components/dialog/InfoV2.js +1 -0
- package/dist/components/dialog/NotFound.js +1 -0
- package/dist/components/dialog/QuickSearch.js +1 -0
- package/dist/components/notifications/NotificationsCenter.js +1 -0
- package/dist/components/notifications/index.js +1 -0
- package/dist/components/tables/PaginationComponent.js +1 -0
- package/dist/components/theme/AppLoadingFallback.js +6 -0
- package/dist/components/theme/ErrorBoundary.js +1 -0
- package/dist/components/theme/InitialLoader.js +1 -0
- package/dist/components/theme/NotFound.js +1 -0
- package/dist/components/theme/NotResults.js +1 -0
- package/dist/hooks/useDraggable.js +1 -0
- package/dist/hooks/useNotifications.js +1 -0
- package/dist/hooks/useQuickSearch.js +1 -0
- package/dist/styles/index.less +0 -0
- package/dist/utils/setNativeValue.js +1 -0
- package/package.json +14 -3
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Fragment as xe,jsx as t,jsxs as c}from"react/jsx-runtime";import{useRecordContext as Oe}from"react-admin";import{useFormContext as $e}from"react-hook-form";import{Box as a,Button as T,IconButton as ue,TextField as Ne,Typography as C,Chip as R,InputAdornment as K,FormControl as je,InputLabel as We,Select as _e,MenuItem as me,Pagination as Ue,Card as Ge,Link as U}from"@mui/material";import pe from"@mui/icons-material/Add";import He from"@mui/icons-material/Edit";import Je from"@mui/icons-material/Preview";import qe from"@mui/icons-material/Search";import ge from"@mui/icons-material/Clear";import Ye from"@mui/icons-material/FilterList";import Qe from"@mui/icons-material/Download";import Xe from"@mui/icons-material/Upload";import{useState as u,useEffect as M,useRef as G,useCallback as b,useMemo as fe}from"react";import{extractAvailableModes as Ze,getContrastColor as et,getModeIcon as H,parseColorKey as J}from"./helpers/functions";import tt from"./components/ImageColorExtractor";import ot from"./components/ColorEditDialog";import{updateDomCssVariables as he}from"@dashadmin/dash-utils";import{AuthPersistenceService as nt}from"@dashadmin/dash-auth";const q=!1,rt=!1,Rt={"primary-color":"Primary Color","secondary-color":"Secondary Color","highlight-color":"Highlight Color","contrast-color":"Contrast Color"},st=({pair:m,onEdit:P,onDelete:v})=>{const O=et(m.value),{baseChips:f,mode:y}=J(m.key),E=H(y);return c(Ge,{onClick:()=>P(m),elevation:1,sx:{width:"100%",display:"flex",alignItems:"stretch",cursor:"pointer",transition:"all 0.2s ease-in-out","&:hover":{transform:"translateY(-2px)",boxShadow:3},borderRadius:2,overflow:"hidden",position:"relative",height:80,backgroundColor:"background.paper"},children:[t(a,{sx:{width:80,backgroundColor:m.value,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:t(a,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.3)",opacity:0,transition:"opacity 0.2s","&:hover":{opacity:1},display:"flex",alignItems:"center",justifyContent:"center"},children:t(He,{sx:{color:"#fff"}})})}),c(a,{sx:{flexGrow:1,p:1.5,display:"flex",flexDirection:"column",justifyContent:"space-between",overflow:"hidden"},children:[c(a,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:.5},children:[t(C,{variant:"caption",sx:{fontFamily:"monospace",fontWeight:"bold",color:"text.secondary"},children:m.value}),y&&t(R,{label:y,size:"small",icon:t("span",{style:{marginLeft:6,fontSize:"0.8rem"},children:E}),sx:{height:18,fontSize:"0.65rem","& .MuiChip-label":{padding:"0 6px"}}})]}),t(a,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:f.map((p,S)=>t(R,{label:p,size:"small",variant:"outlined",sx:{height:20,fontSize:"0.7rem",maxWidth:"100%","& .MuiChip-label":{padding:"0 6px",overflow:"hidden",textOverflow:"ellipsis"}}},S))})]})]})},ye=m=>{const{method:P,attribute:v,resourceConfig:O}=m,f=Oe(),{setValue:y,getValues:E}=$e(),p=v.attribute,S=p.startsWith("settings."),V=S?p.split(".").slice(1).join("."):p,[i,k]=u([]),[x,$]=u(""),[h,N]=u(""),[D,Y]=u(!0),[Q,X]=u(!0),[Ce,j]=u(!1),[be,W]=u(null),[ve,Se]=u([]),[A,I]=u(1),[w]=u(50),[F,Z]=u(!q),ee=G(null),te=G(null),it=G(new Map),L=b(e=>{window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:e}))},[]),Ie=b(e=>{Se(e)},[]),we=fe(()=>Ze(i),[i]),g=fe(()=>{let e=i;return x.trim()&&(e=e.filter(o=>o.key.toLowerCase().includes(x.toLowerCase()))),h&&(e=e.filter(o=>{const{mode:r}=J(o.key);return r===h})),e},[i,x,h]),Ee=b(()=>{try{const e=Ae(i),o=new Blob([e],{type:"text/css"}),r=URL.createObjectURL(o),n=document.createElement("a");n.href=r,n.download="color-variables.css",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r),console.log("CSS variables exported successfully")}catch(e){console.error("Error exporting CSS variables:",e)}},[i]),Pe=b(()=>{ee.current?.click()},[]),ke=b(e=>{const o=e.target.files?.[0];if(!o)return;const r=new FileReader;r.onload=n=>{try{const s=n.target?.result,l=Le(s);if(l.length>0){const d=Te(i,l);k(d),z(d),console.log(`Imported ${l.length} color variables from CSS`)}else console.warn("No valid CSS variables found in the imported file")}catch(s){console.error("Error importing CSS file:",s)}},r.readAsText(o),e.target.value=""},[i]),Ae=e=>{const o=["/* Color Variables - Generated by JsonColorSelector */","/* Import this file or copy these variables to your CSS */","",":root {"],r=e.reduce((n,s)=>{if(!s.key.trim())return n;const{mode:l}=J(s.key),d=l||"default";return n[d]||(n[d]=[]),n[d].push(s),n},{});return Object.entries(r).forEach(([n,s])=>{s.length>0&&(o.push(` /* ${n} mode colors */`),s.forEach(l=>{const d=l.key.startsWith("--")?l.key:`--${l.key}`;o.push(` ${d}: ${l.value};`)}),o.push(""))}),o.push("}"),o.push(""),o.push("/* Usage example: */"),o.push("/* .my-element { background-color: var(--primary-color); } */"),o.join(`
|
|
2
|
+
`)},Le=e=>{const o=[],r=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").trim(),n=/--([^:]+):\s*([^;]+);/g;let s;for(;(s=n.exec(r))!==null;){const[,l,d]=s,B=l.trim(),de=d.trim();Be(de)&&o.push({key:B,value:de,id:_()})}return o},Be=e=>[/^#[0-9a-fA-F]{3,8}$/,/^rgb\(/i,/^rgba\(/i,/^hsl\(/i,/^hsla\(/i,/^(red|blue|green|yellow|purple|orange|pink|brown|black|white|gray|grey)$/i].some(r=>r.test(e.trim())),Te=(e,o)=>{const r=[...e];return o.forEach(n=>{const s=r.findIndex(l=>l.key===n.key);s>=0?r[s]={...r[s],value:n.value}:r.push(n)}),r},Re=e=>{$(e.target.value),I(1)},oe=()=>{$(""),I(1)},Me=e=>{N(e.target.value),I(1)},ne=()=>{N(""),I(1)};M(()=>{(async()=>{Y(!0),L(!0);try{let o={},r={};try{r=v?.default_value||{}}catch{r={}}if(S&&f?.settings){const s=f.settings||{};o={...r,...re(s,V)}}else f?.[p]?o={...r,...f[p]}:o=r;const n=Object.entries(o).map(([s,l])=>({key:s,value:String(l),id:_()}));k(n),n.length>50&&await new Promise(s=>setTimeout(s,100))}catch(o){console.error("Error loading initial data:",o)}finally{Y(!1)}})()},[f,p]),M(()=>{!D&&i.length>=0&&(X(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{X(!1),L(!1)})}))},[D,i.length,L]),M(()=>()=>{te.current&&clearTimeout(te.current),L(!1)},[L]);const re=(e,o)=>o?o.split(".").reduce((n,s)=>n&&n[s]!==void 0?n[s]:{},e):e,Ve=(e,o,r)=>{if(!o)return r;const n=o.split("."),s=n.pop(),l=n.reduce((d,B)=>(d[B]===void 0&&(d[B]={}),d[B]),e);return s&&(l[s]=r),e},_=()=>Math.random().toString(36).substring(2,11),se=()=>{const e={key:"",value:"#000000",id:_()};W(e),j(!0)},De=e=>{W(e),j(!0)},Fe=e=>{const o=i.findIndex(n=>n.id===e.id);let r;o>=0?r=i.map(n=>n.id===e.id?e:n):r=[...i,e],k(r),z(r),ie(e.key,e.value)},ae=e=>{const o=i.filter(r=>r.id!==e);k(o),z(o)},ze=e=>{k(e),z(e)},ie=b((e,o)=>{e.trim()&&requestAnimationFrame(()=>{const r=document.documentElement.getAttribute("data-theme")||"",n=r?`--${r}`:"";if(n&&e.endsWith(n)){const s=e.slice(0,-n.length);document.documentElement.style.setProperty(`--${s}`,o),document.documentElement.style.setProperty(`--${s}${n}`,o)}else{const s=e.startsWith("--")?e:`--${e}`;document.documentElement.style.setProperty(s,o)}})},[]),lt=e=>{const r=`--${document.documentElement.getAttribute("data-theme")}`;requestAnimationFrame(()=>{Object.entries(e).forEach(([n,s])=>{if(n.endsWith(r)){const l=n.slice(0,-r.length);document.documentElement.style.setProperty(`--${l}`,String(s))}})})},Ke=b(e=>{const o=i.reduce((r,n)=>(n.key.trim()&&(r[n.key]=n.value),r),{});he(e,o,ce())},[i]),le=b(()=>{try{let e={};if(S){const o=E("settings")||{};e=re(o,V)||{}}else e=E(p)||{};return e}catch(e){return console.error("Error syncing pairs from form values:",e),{}}},[E,S,V,p]),ce=()=>{const e=nt.getTenantSettings();return e?e?.values||{}:{}};M(()=>{const e=o=>{console.log("Theme switch event received:",o.detail.mode);const r=le();console.log("Current colors from form:",r),he(o.detail.mode,r,ce())};return window.addEventListener("dash-theme-mode-switched",e),()=>{window.removeEventListener("dash-theme-mode-switched",e)}},[le]);const z=e=>{const o=e.reduce((r,n)=>(n.key.trim()&&(r[n.key]=n.value),r),{});if(S){const r=E("settings")||{},n=Ve({...r},V,o);y("settings",n,{shouldDirty:!0})}else y(p,o,{shouldDirty:!0})};return D||Q?t(a,{sx:{mt:1,mb:2,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:t(C,{variant:"body2",color:"textSecondary",children:D?"Loading color settings...":"Rendering colors..."})}):c(a,{sx:{mt:1,mb:2},children:[t(C,{variant:"subtitle1",gutterBottom:!0,children:v.label||"Color Palette"}),t("input",{type:"file",ref:ee,accept:".css",style:{display:"none"},onChange:ke}),t(tt,{onColorsExtracted:Ie,onColorsUpdate:ze,existingPairs:i}),c(a,{sx:{mb:3,display:"flex",gap:2,alignItems:"flex-end"},children:[t(Ne,{fullWidth:!0,size:"small",placeholder:"Search colors by name...",value:x,onChange:Re,InputProps:{startAdornment:t(K,{position:"start",children:t(qe,{})}),endAdornment:x&&t(K,{position:"end",children:t(ue,{size:"small",onClick:oe,edge:"end",children:t(ge,{})})})}}),c(je,{size:"small",sx:{minWidth:150},children:[t(We,{children:"Mode"}),c(_e,{value:h,label:"Mode",onChange:Me,startAdornment:t(K,{position:"start",children:t(Ye,{fontSize:"small"})}),endAdornment:h&&t(K,{position:"end",children:t(ue,{size:"small",onClick:ne,edge:"end",sx:{mr:1},children:t(ge,{fontSize:"small"})})}),children:[t(me,{value:"",children:t("em",{children:"All Modes"})}),we.map(e=>t(me,{value:e,children:c(a,{sx:{display:"flex",alignItems:"center",gap:1},children:[t("span",{children:H(e)}),t("span",{children:e})]})},e))]})]})]}),c(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:3,flexWrap:"wrap",gap:1},children:[c(a,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:[t(T,{startIcon:t(Je,{}),variant:"contained",size:"small",onClick:()=>Ke(document.documentElement.getAttribute("data-theme")),color:"primary",children:"Preview Colors"}),t(T,{startIcon:t(Qe,{}),variant:"outlined",size:"small",onClick:Ee,color:"secondary",disabled:i.length===0,children:"Export CSS"}),t(T,{startIcon:t(Xe,{}),variant:"outlined",size:"small",onClick:Pe,color:"secondary",children:"Import CSS"})]}),t(T,{startIcon:t(pe,{}),variant:"outlined",size:"small",onClick:se,children:"Add Color"})]}),(x||h)&&c(a,{sx:{mb:2,display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[t(R,{label:`${g.length} of ${i.length} colors`,size:"small",variant:"outlined"}),h&&t(R,{label:`Mode: ${h}`,size:"small",variant:"filled",color:"primary",onDelete:ne,avatar:t("span",{style:{paddingLeft:6},children:H(h)})}),x&&t(R,{label:`Search: "${x}"`,size:"small",variant:"filled",color:"secondary",onDelete:oe})]}),t(a,{sx:{flexGrow:1,my:2},children:Q?t(a,{sx:{display:"flex",justifyContent:"center",p:4,alignItems:"center",flexDirection:"column",gap:2},children:t(C,{children:"Rendering Grid..."})}):g.length>0?c(xe,{children:[t(a,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:2,width:"100%"},children:(F?g:g.slice((A-1)*w,A*w)).map(e=>t(a,{sx:{minWidth:0},children:t(st,{pair:e,onEdit:De,onDelete:ae})},e.id))}),q&&!F&&g.length>w&&c(a,{sx:{mt:4,display:"flex",flexDirection:"column",alignItems:"center",gap:1},children:[t(Ue,{count:Math.ceil(g.length/w),page:A,onChange:(e,o)=>I(o),color:"primary",size:"large",showFirstButton:!0,showLastButton:!0}),rt&&t(U,{component:"button",variant:"body2",underline:"always",onClick:()=>Z(!0),sx:{mt:.5,fontSize:"0.8rem",cursor:"pointer"},children:"Show all"})]}),t(C,{variant:"caption",sx:{display:"block",textAlign:"center",mt:2,color:"text.secondary"},children:F?`Showing all ${g.length} colors`:`Showing ${Math.min((A-1)*w+1,g.length)} - ${Math.min(A*w,g.length)} of ${g.length} colors`}),q&&F&&g.length>w&&t(a,{sx:{display:"flex",justifyContent:"center",mt:1},children:t(U,{component:"button",variant:"body2",underline:"always",onClick:()=>{Z(!1),I(1)},sx:{fontSize:"0.8rem",cursor:"pointer"},children:"Show paginated"})})]}):c(a,{sx:{p:4,textAlign:"center",bgcolor:"background.paper",borderRadius:1,border:"1px dashed #ccc"},children:[t(C,{color:"textSecondary",children:"No colors found using current filters."}),t(a,{sx:{mt:1},children:t(U,{component:"button",variant:"body2",onClick:()=>{$(""),N(""),I(1)},children:"Clear filters"})})]})}),i.length===0&&c(a,{sx:{textAlign:"center",py:4},children:[t(C,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:"No colors in your palette yet"}),t(T,{startIcon:t(pe,{}),variant:"contained",onClick:se,children:"Add Your First Color"})]}),t(ot,{open:Ce,pair:be,onClose:()=>{j(!1),W(null)},onSave:Fe,onDelete:ae,existingKeys:i.map(e=>e.key),updateSingleDomColor:ie,extractedColors:ve})]})},at=({method:m,attribute:P,resourceConfig:v})=>{const[O,f]=u(!0);if(M(()=>{window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:!0}));const y=setTimeout(()=>{f(!1)},50);return()=>{clearTimeout(y),window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:!1}))}},[]),O)return t(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:100},children:t(C,{variant:"body2",color:"textSecondary",children:"Initializing color palette..."})});switch(m){case"edit":return t(ye,{attribute:P,method:m,resourceConfig:v});case"create":return t(ye,{attribute:P,method:m,resourceConfig:v});default:return t(xe,{children:"Not implemented"})}};var Mt=at;export{ye as JsonEdit,Mt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as ae,jsx as e,jsxs as f}from"react/jsx-runtime";import{useRecordContext as $}from"react-admin";import{useFormContext as Z}from"react-hook-form";import{Box as a,Button as F,IconButton as H,TextField as N,Typography as m,Card as U,CardContent as _,Chip as R,InputAdornment as W}from"@mui/material";import ee from"@mui/icons-material/Delete";import Y from"@mui/icons-material/Add";import q from"@mui/icons-material/Search";import G from"@mui/icons-material/Clear";import{useState as b,useEffect as J,useMemo as M}from"react";const L=r=>r==="true"||r==="false"?"boolean":!isNaN(Number(r))&&r.trim()!==""?"number":r.startsWith("{")&&r.endsWith("}")||r.startsWith("[")&&r.endsWith("]")?"json":"string",Q=(r,u=30)=>r.length<=u?r:r.substring(0,u)+"...",te=({pair:r,onUpdate:u,onDelete:d,existingKeys:h})=>{const[I,y]=b(!1),[x,V]=b(!1),[p,B]=b(r.key),[i,A]=b(r.value),[D,S]=b(""),[w,P]=b(""),s=L(r.value),l=t=>{switch(t){case"string":return"#2196f3";case"number":return"#4caf50";case"boolean":return"#ff9800";case"json":return"#9c27b0";default:return"#757575"}},g=t=>{const n=h.some(o=>o===t&&t!==r.key);return S(n?"Key already exists":""),!n&&t.trim()!==""},C=(t,n)=>{let o="";if(n==="number"&&isNaN(Number(t))&&t.trim()!=="")o="Invalid number format";else if(n==="boolean"&&!["true","false"].includes(t.toLowerCase()))o='Boolean must be "true" or "false"';else if(n==="json")try{JSON.parse(t)}catch{o="Invalid JSON format"}return P(o),!o},T=()=>{g(p)&&(u({...r,key:p}),y(!1))},K=()=>{const t=L(i);C(i,t)&&(u({...r,value:i}),V(!1))},j=()=>{B(r.key),S(""),y(!1)},E=()=>{A(r.value),P(""),V(!1)};return e(U,{variant:"outlined",sx:{mb:1,"&:hover":{boxShadow:2}},children:e(_,{sx:{p:2,"&:last-child":{pb:2}},children:f(a,{sx:{display:"flex",alignItems:"flex-start",gap:2},children:[f(a,{sx:{flex:1,minWidth:0},children:[e(m,{variant:"caption",color:"textSecondary",sx:{display:"block",mb:.5},children:"Key"}),I?e(N,{fullWidth:!0,size:"small",value:p,onChange:t=>{B(t.target.value),g(t.target.value)},error:!!D,helperText:D,onKeyDown:t=>{t.key==="Enter"&&T(),t.key==="Escape"&&j()},onBlur:T,autoFocus:!0}):e(a,{onClick:()=>y(!0),sx:{cursor:"pointer",p:1,borderRadius:1,backgroundColor:"rgba(0,0,0,0.04)","&:hover":{backgroundColor:"rgba(0,0,0,0.08)"},minHeight:24,display:"flex",alignItems:"center"},children:e(m,{variant:"body2",sx:{fontFamily:"monospace",wordBreak:"break-all"},children:r.key||"Click to add key"})})]}),f(a,{sx:{flex:1,minWidth:0},children:[f(a,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e(m,{variant:"caption",color:"textSecondary",children:"Value"}),e(R,{label:s.toUpperCase(),size:"small",sx:{height:16,fontSize:"0.6rem",backgroundColor:l(s),color:"#fff","& .MuiChip-label":{padding:"0 4px"}}})]}),x?e(N,{fullWidth:!0,size:"small",value:i,onChange:t=>{A(t.target.value);const n=L(t.target.value);C(t.target.value,n)},error:!!w,helperText:w,multiline:s==="json",rows:s==="json"?3:1,onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&s!=="json"&&(t.preventDefault(),K()),t.key==="Escape"&&E()},onBlur:K,autoFocus:!0}):e(a,{onClick:()=>V(!0),sx:{cursor:"pointer",p:1,borderRadius:1,backgroundColor:"rgba(0,0,0,0.04)","&:hover":{backgroundColor:"rgba(0,0,0,0.08)"},minHeight:24,display:"flex",alignItems:"center"},children:e(m,{variant:"body2",sx:{fontFamily:"monospace",wordBreak:"break-all"},title:r.value,children:Q(r.value)||"Click to add value"})})]}),e(a,{sx:{display:"flex",alignItems:"center"},children:e(H,{size:"small",onClick:()=>d(r.id),color:"error",children:e(ee,{fontSize:"small"})})})]})})})},X=r=>{const{attribute:u}=r,d=$(),{setValue:h,getValues:I}=Z(),y=u.attribute,x=y.startsWith("settings."),V=x?y.split(".").slice(1).join("."):y,[p,B]=b([]),[i,A]=b(""),[D,S]=b(!0),w=M(()=>i.trim()?p.filter(t=>t.key.toLowerCase().includes(i.toLowerCase())||t.value.toLowerCase().includes(i.toLowerCase())):p,[p,i]),P=t=>{A(t.target.value)},s=()=>{A("")};J(()=>{(async()=>{S(!0);try{let n={},o={};try{o=u?.default_value||{}}catch{o={}}if(x&&d?.settings){const v=d.settings||{};n={...o,...l(v,V)}}else d?.[y]?n={...o,...d[y]}:n=o;const c=Object.entries(n).map(([v,k])=>({key:v,value:String(k),id:C()}));B(c)}catch(n){console.error("Error loading initial data:",n)}finally{S(!1)}})()},[d,y]);const l=(t,n)=>n?n.split(".").reduce((c,v)=>c&&c[v]!==void 0?c[v]:{},t):t,g=(t,n,o)=>{if(!n)return o;const c=n.split("."),v=c.pop(),k=c.reduce((z,O)=>(z[O]===void 0&&(z[O]={}),z[O]),t);return v&&(k[v]=o),t},C=()=>Math.random().toString(36).substring(2,11),T=()=>{const t={key:"",value:"",id:C()},n=[...p,t];B(n),E(n)},K=t=>{const n=p.map(o=>o.id===t.id?t:o);B(n),E(n)},j=t=>{const n=p.filter(o=>o.id!==t);B(n),E(n)},E=t=>{const n=t.reduce((o,c)=>{if(c.key.trim()){const v=L(c.value);let k=c.value;try{switch(v){case"number":k=Number(c.value);break;case"boolean":k=c.value.toLowerCase()==="true";break;case"json":k=JSON.parse(c.value);break;default:k=c.value;break}}catch{k=c.value}o[c.key]=k}return o},{});if(x){const o=I("settings")||{},c=g({...o},V,n);h("settings",c,{shouldDirty:!0})}else h(y,n,{shouldDirty:!0})};return D?e(a,{sx:{mt:1,mb:2,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e(m,{variant:"body2",color:"textSecondary",children:"Loading values..."})}):f(a,{sx:{mt:1,mb:2},children:[e(m,{variant:"subtitle1",gutterBottom:!0,children:u.label||"Key-Value Pairs"}),e(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:3},children:e(F,{startIcon:e(Y,{}),variant:"outlined",size:"small",onClick:T,children:"Add Pair"})}),p.length>0&&e(a,{sx:{mb:3},children:e(N,{fullWidth:!0,size:"small",placeholder:"Search by key or value...",value:i,onChange:P,InputProps:{startAdornment:e(W,{position:"start",children:e(q,{})}),endAdornment:i&&e(W,{position:"end",children:e(H,{size:"small",onClick:s,edge:"end",children:e(G,{})})})}})}),i&&e(a,{sx:{mb:2},children:e(R,{label:`${w.length} of ${p.length} pairs`,size:"small",variant:"outlined",onDelete:s})}),e(a,{sx:{mb:2},children:w.map(t=>e(te,{pair:t,onUpdate:K,onDelete:j,existingKeys:p.map(n=>n.key)},t.id))}),i&&w.length===0&&f(a,{sx:{textAlign:"center",py:4},children:[e(m,{variant:"body2",color:"textSecondary",children:"No pairs found matching your search"}),e(F,{size:"small",onClick:s,sx:{mt:1},children:"Clear search"})]}),p.length===0&&f(a,{sx:{textAlign:"center",py:4},children:[e(m,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:"No key-value pairs configured yet"}),e(F,{startIcon:e(Y,{}),variant:"contained",onClick:T,children:"Add Your First Pair"})]})]})},ne=r=>{const{attribute:u}=r,d=$(),h=u.attribute,I=h.startsWith("settings."),y=I?h.split(".").slice(1).join("."):h,[x,V]=b(""),[p,B]=b(!0),[i,A]=b({}),D=M(()=>Object.entries(i).map(([s,l])=>({key:s,value:String(l),id:s})),[i]);J(()=>{(async()=>{B(!0);try{let l={},g={};try{g=u?.default_value||{}}catch{g={}}if(I&&d?.settings){const C=d.settings||{};if(y){const T=y.split(".");l={...g,...T.reduce((K,j)=>K&&K[j]!==void 0?K[j]:{},C)}}else l={...g,...C}}else d?.[h]?l={...g,...d[h]}:l=g;A(l)}catch(l){console.error("Error loading view data:",l)}finally{B(!1)}})()},[d,h,u,I,y]);const S=M(()=>x.trim()?Object.entries(i).filter(([s,l])=>s.toLowerCase().includes(x.toLowerCase())||String(l).toLowerCase().includes(x.toLowerCase())).reduce((s,[l,g])=>(s[l]=g,s),{}):i,[i,x]),w=s=>{V(s.target.value)},P=()=>{V("")};return p?e(a,{sx:{mt:1,mb:2,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e(m,{variant:"body2",color:"textSecondary",children:"Loading values..."})}):f(a,{sx:{mt:1,mb:2},children:[e(m,{variant:"subtitle1",gutterBottom:!0,children:u.label||"Key-Value Pairs"}),Object.keys(i).length>0&&f(ae,{children:[e(a,{sx:{mb:3},children:e(N,{fullWidth:!0,size:"small",placeholder:"Search by key or value...",value:x,onChange:w,InputProps:{startAdornment:e(W,{position:"start",children:e(q,{})}),endAdornment:x&&e(W,{position:"end",children:e(H,{size:"small",onClick:P,edge:"end",children:e(G,{})})})}})}),x&&e(a,{sx:{mb:2},children:e(R,{label:`${Object.keys(S).length} of ${Object.keys(i).length} pairs`,size:"small",variant:"outlined",onDelete:P})}),Object.keys(S).length>0?e(a,{sx:{mb:2},children:Object.entries(S).map(([s,l])=>{const g=L(String(l)),C=T=>{switch(T){case"string":return"#2196f3";case"number":return"#4caf50";case"boolean":return"#ff9800";case"json":return"#9c27b0";default:return"#757575"}};return e(U,{variant:"outlined",sx:{mb:1,border:`2px solid ${C(g)}`},children:e(_,{sx:{p:2,"&:last-child":{pb:2}},children:f(a,{sx:{display:"flex",alignItems:"flex-start",gap:2},children:[f(a,{sx:{flex:1,minWidth:0},children:[e(m,{variant:"caption",color:"textSecondary",sx:{display:"block",mb:.5},children:"Key"}),e(a,{sx:{p:1,borderRadius:1,backgroundColor:"rgba(0,0,0,0.04)",minHeight:24,display:"flex",alignItems:"center"},children:e(m,{variant:"body2",sx:{fontFamily:"monospace",wordBreak:"break-all"},children:s})})]}),f(a,{sx:{flex:1,minWidth:0},children:[f(a,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e(m,{variant:"caption",color:"textSecondary",children:"Value"}),e(R,{label:g.toUpperCase(),size:"small",sx:{height:16,fontSize:"0.6rem",backgroundColor:C(g),color:"#fff","& .MuiChip-label":{padding:"0 4px"}}})]}),e(a,{sx:{p:1,borderRadius:1,backgroundColor:"rgba(0,0,0,0.04)",minHeight:24,display:"flex",alignItems:"center"},children:e(m,{variant:"body2",sx:{fontFamily:"monospace",wordBreak:"break-all"},title:String(l),children:Q(String(l))})})]})]})})},s)})}):f(a,{sx:{textAlign:"center",py:4},children:[e(m,{variant:"body2",color:"textSecondary",children:"No pairs found matching your search"}),e(F,{size:"small",onClick:P,sx:{mt:1},children:"Clear search"})]})]}),Object.keys(i).length===0&&e(a,{sx:{textAlign:"center",py:4},children:e(m,{variant:"body2",color:"textSecondary",children:"No key-value pairs configured"})})]})},re=({method:r,attribute:u,resourceConfig:d})=>{const[h,I]=b(!0);if(J(()=>{const y=setTimeout(()=>{I(!1)},50);return()=>{clearTimeout(y)}},[]),h)return e(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:100},children:e(m,{variant:"body2",color:"textSecondary",children:"Initializing key-value editor..."})});switch(r){case"edit":return e(X,{attribute:u,method:r,resourceConfig:d});case"create":return e(X,{attribute:u,method:r,resourceConfig:d});case"view":return e(ne,{attribute:u,method:r,resourceConfig:d});default:return null}};var fe=re;export{X as JsonEdit,ne as JsonView,fe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t,jsxs as i}from"react/jsx-runtime";import{Box as n,Button as I,TextField as W,Typography as p,Drawer as U,InputAdornment as $,FormControl as N,InputLabel as O,Select as X,MenuItem as f,Tabs as Y,Tab as M,Avatar as _,IconButton as q}from"@mui/material";import J from"@mui/icons-material/Delete";import Q from"@mui/icons-material/Close";import{ChromePicker as Z}from"react-color";import{useState as y,useEffect as ee,useRef as te,useMemo as re}from"react";import{convertColor as ae,getContrastColor as P,rgbArrayToHex as F}from"../helpers/functions";const oe=({open:S,pair:d,onClose:g,onSave:A,onDelete:z,existingKeys:D,updateSingleDomColor:v,extractedColors:w=[]})=>{const[r,b]=y(null),[s,u]=y("hex"),[m,B]=y(""),[C,R]=y(0),T=te(0),E=re(()=>({default:{picker:{width:"100%",boxShadow:"none"}}}),[]);ee(()=>{if(d){b({...d});const e=d.value.toLowerCase().trim();e.startsWith("rgba(")?u("rgba"):e.startsWith("rgb(")?u("rgb"):e.startsWith("hsla(")?u("hsla"):e.startsWith("hsl(")?u("hsl"):e.startsWith("#")&&e.length===9?u("rgba"):u("hex")}B("")},[d]);const V=e=>{if(!r)return;const o=D.some(a=>a===e&&e!==d?.key);B(o?"Key already exists":""),b({...r,key:e})},ne=e=>{const o=e.toLowerCase().trim();if(o.startsWith("rgba(")){const a=o.match(/rgba?\(([^)]+)\)/);if(a){const l=a[1].split(",").map(G=>parseFloat(G.trim())),[c,h,x,k=1]=l;return{r:Math.round(c),g:Math.round(h),b:Math.round(x),a:k}}}else if(o.startsWith("rgb(")){const a=o.match(/rgb\(([^)]+)\)/);if(a){const l=a[1].split(",").map(k=>parseFloat(k.trim())),[c,h,x]=l;return{r:Math.round(c),g:Math.round(h),b:Math.round(x),a:1}}}else{if(o.startsWith("hsla("))return e;if(o.startsWith("hsl("))return e;if(o.startsWith("#")){const a=o.replace("#","");if(a.length===8){const l=parseInt(a.substr(0,2),16),c=parseInt(a.substr(2,2),16),h=parseInt(a.substr(4,2),16),x=parseInt(a.substr(6,2),16)/255;return{r:l,g:c,b:h,a:x}}else if(a.length===6){const l=parseInt(a.substr(0,2),16),c=parseInt(a.substr(2,2),16),h=parseInt(a.substr(4,2),16);return{r:l,g:c,b:h,a:1}}}}return e},K=e=>{if(!r)return;const o={hex:e.hex,rgb:{r:Math.round(e.rgb.r),g:Math.round(e.rgb.g),b:Math.round(e.rgb.b),a:e.rgb.a!==void 0?e.rgb.a:1},hsl:{h:Math.round(e.hsl.h||0),s:e.hsl.s||0,l:e.hsl.l||0,a:e.hsl.a!==void 0?e.hsl.a:e.rgb.a!==void 0?e.rgb.a:1}},a=ae(o,s);b({...r,value:a});const l=Date.now();l-T.current>=16&&(v(r.key,a),T.current=l)},L=e=>{if(!r)return;const o=F(e);b({...r,value:o}),v(r.key,o)},j=()=>{!r||m||!r.key.trim()||(A(r),g())},H=()=>{r&&(z(r.id),g())};return r?i(U,{anchor:"right",open:S,onClose:g,BackdropProps:{invisible:!0},PaperProps:{sx:{width:{xs:"100%",sm:460},maxWidth:"100vw",display:"flex",flexDirection:"column"}},children:[i(n,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1.5,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t(p,{variant:"h6",sx:{fontWeight:600},children:d?.key?`Edit: ${d.key}`:"Add New Color"}),t(q,{onClick:g,size:"small",children:t(Q,{})})]}),i(n,{sx:{flex:1,overflowY:"auto",px:2,py:2,display:"flex",flexDirection:"column",gap:3},children:[t(W,{fullWidth:!0,label:"Color Name",value:r.key,onChange:e=>V(e.target.value),error:!!m,helperText:m,placeholder:"e.g., primary-color--light, background-dark--dark",size:"small"}),i(N,{fullWidth:!0,size:"small",children:[t(O,{children:"Color Format"}),i(X,{value:s,label:"Color Format",onChange:e=>u(e.target.value),children:[t(f,{value:"hex",children:"HEX"}),t(f,{value:"rgb",children:"RGB"}),t(f,{value:"rgba",children:"RGBA (with alpha)"}),t(f,{value:"hsl",children:"HSL"}),t(f,{value:"hsla",children:"HSLA (with alpha)"})]})]}),i(n,{children:[t(p,{variant:"subtitle2",gutterBottom:!0,children:"Color Picker"}),i(n,{children:[i(Y,{value:C,onChange:(e,o)=>R(o),variant:"fullWidth",children:[t(M,{label:"Picker"}),t(M,{label:"Manual"})]}),C===0&&t(n,{sx:{mt:2,display:"flex",justifyContent:"center"},children:t(Z,{color:r.value,onChange:K,disableAlpha:!1,styles:E})}),C===1&&t(n,{sx:{mt:2},children:t(W,{fullWidth:!0,size:"small",label:`Color Value (${s.toUpperCase()})`,value:r.value,onChange:e=>{const o=e.target.value;b({...r,value:o}),v(r.key,o)},placeholder:s==="hex"?"#ff0000":s==="rgb"?"rgb(255, 0, 0)":s==="rgba"?"rgba(255, 0, 0, 0.5)":s==="hsl"?"hsl(0, 100%, 50%)":"hsla(0, 100%, 50%, 0.5)",helperText:s==="rgba"||s==="hsla"?"Alpha value should be between 0 and 1 (e.g., 0.1, 0.5, 1)":void 0,InputProps:{startAdornment:t($,{position:"start",children:t(n,{sx:{width:20,height:20,backgroundColor:r.value,border:"1px solid #ccc",borderRadius:1,backgroundImage:s==="rgba"||s==="hsla"?"linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)":"none",backgroundSize:"4px 4px",backgroundPosition:"0 0, 0 2px, 2px -2px, -2px 0px"}})})}})})]})]}),w.length>0&&i(n,{children:[t(p,{variant:"subtitle2",gutterBottom:!0,children:"Extracted Colors"}),t(n,{sx:{display:"flex",flexWrap:"wrap",gap:1,p:2,border:"1px solid",borderColor:"divider",borderRadius:1,backgroundColor:"action.hover"},children:w.map((e,o)=>{const a=F(e),l=r.value===a;return t(_,{sx:{width:36,height:36,backgroundColor:a,border:l?"3px solid #1976d2":"2px solid #ccc",cursor:"pointer",transition:"all 0.2s","&:hover":{transform:"scale(1.1)",boxShadow:2},color:P(a),fontWeight:"bold",fontSize:"0.7rem"},onClick:()=>L(e),title:`Use extracted color: ${a}`,children:o+1},o)})}),t(p,{variant:"caption",color:"textSecondary",sx:{mt:1,display:"block"},children:"Click any color to use it"})]}),i(n,{children:[t(p,{variant:"subtitle2",gutterBottom:!0,children:"Preview"}),t(n,{sx:{width:"100%",height:80,backgroundColor:r.value,border:"1px solid #ccc",borderRadius:1,display:"flex",alignItems:"center",justifyContent:"center",position:"relative",backgroundImage:r.value.includes("rgba")||r.value.includes("hsla")?"linear-gradient(45deg, #f0f0f0 25%, transparent 25%), linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f0f0 75%), linear-gradient(-45deg, transparent 75%, #f0f0f0 75%)":"none",backgroundSize:"10px 10px",backgroundPosition:"0 0, 0 5px, 5px -5px, -5px 0px"},children:t(n,{sx:{width:"100%",height:"100%",backgroundColor:r.value,borderRadius:1,display:"flex",alignItems:"center",justifyContent:"center"},children:t(p,{variant:"body2",sx:{color:P(r.value),fontWeight:"bold",backgroundColor:"rgba(0,0,0,0.1)",padding:"4px 8px",borderRadius:1},children:r.key||"Color Preview"})})})]})]}),i(n,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1.5,borderTop:"1px solid",borderColor:"divider",flexShrink:0,backgroundColor:"background.paper"},children:[d?.key&&t(I,{onClick:H,color:"error",startIcon:t(J,{}),size:"small",children:"Delete"}),t(n,{sx:{flexGrow:1}}),t(I,{onClick:g,size:"small",children:"Cancel"}),t(I,{onClick:j,variant:"contained",disabled:!!m||!r.key.trim(),size:"small",children:"Save"})]})]}):null};var xe=oe;export{xe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o,jsxs as g}from"react/jsx-runtime";import{Box as a,Chip as r}from"@mui/material";import{getContrastColor as d,getModeIcon as x,parseColorKey as f}from"../helpers/functions";const c=({pair:e,onEdit:l,onDelete:u})=>{const C=d(e.value),{baseChips:i,mode:t}=f(e.key),n=x(t);return g(a,{sx:{aspectRatio:"unset",height:"30px",cursor:"pointer",transition:"all 0.2s ease-in-out","&:hover":{transform:"translateY(-2px)",boxShadow:3},position:"relative",overflow:"hidden",backgroundColor:e.value,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",padding:"0 8px",gap:.5},onClick:()=>l(e),children:[o(a,{sx:{display:"flex",flexWrap:"wrap",gap:.25,justifyContent:"center"},children:i.map((s,p)=>o(r,{label:s,size:"small",sx:{height:16,fontSize:"0.6rem",backgroundColor:"rgba(255,255,255,0.9)",color:"#333","& .MuiChip-label":{padding:"0 4px"}}},p))}),t&&o(r,{label:n,size:"small",sx:{height:16,fontSize:"0.6rem",backgroundColor:"rgba(0,0,0,0.7)",color:"#fff","& .MuiChip-label":{padding:"0 4px"}}})]})};var v=c;export{v as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Box as r,Button as A,IconButton as D,Typography as i,Card as j,CardMedia as L,CircularProgress as U,Input as O,Alert as F,TextField as H,Divider as K}from"@mui/material";import M from"@mui/icons-material/Delete";import V from"@mui/icons-material/CloudUpload";import $ from"@mui/icons-material/Palette";import q from"@mui/icons-material/AutoFixHigh";import{useState as m,useEffect as _,memo as J,useCallback as N}from"react";import{useAsyncColorThief as Q}from"../useAsyncColorThief";import{getContrastColor as X,rgbArrayToHex as Y}from"../helpers/functions";import{useAxios as Z}from"@dashadmin/dash-axios-hook";const ee=J(({onColorsExtracted:x,onColorsUpdate:h,existingPairs:I=[]})=>{const[c,C]=m(null),[te,v]=m(null),[f,R]=m(""),[y,T]=m(!1),[B,b]=m(null),[n,P]=m([]),w=Z(),{dominantColor:g,palette:p,loading:E,error:k}=Q(c,{colorCount:8,quality:10});_(()=>{p&&p.length>0&&(P(p),x(p))},[p,x]);const S=t=>{const o=t.target.files?.[0];if(o){if(!o.type.startsWith("image/")){alert("Please select a valid image file");return}if(o.size>5*1024*1024){alert("File size must be less than 5MB");return}v(o);const s=URL.createObjectURL(o);C(s)}},z=()=>{c&&c.startsWith("blob:")&&URL.revokeObjectURL(c),C(null),v(null),P([]),x([])},G=N(async()=>{if(!n||n.length===0){b("Please extract colors from an image first");return}T(!0),b(null);try{const t=await w.post("/tenant/tenant/settings/theme-generator",{colors:n,prompt:f,output_format:"json"});if(t.status!==200)throw new Error(`HTTP error! status: ${t.status}`);const o=t.data;if(o.success&&o.data){const s=Object.entries(o.data).map(([d,u])=>({key:d,value:String(u),id:Math.random().toString(36).substring(2,11)})),l=[...I];s.forEach(d=>{const u=l.findIndex(W=>W.key===d.key);u>=0?l[u]=d:l.push(d)}),h&&h(l)}else throw new Error(o.message||"Failed to generate theme")}catch(t){console.error("Theme generation error:",t),b(t instanceof Error?t.message:"Failed to generate theme")}finally{T(!1)}},[n,f,I,h,w]);return a(r,{sx:{mt:3,p:3,borderRadius:2},children:[a(i,{variant:"h6",gutterBottom:!0,sx:{display:"flex",alignItems:"center",gap:1},children:[e($,{}),"AI Theme Generator"]}),e(K,{sx:{mb:3}}),e(r,{sx:{mb:3},children:c?e(j,{sx:{maxWidth:400,mb:3},children:a(r,{sx:{position:"relative"},children:[e(L,{component:"img",height:"200",image:c,alt:"Uploaded image",sx:{objectFit:"contain"}}),e(D,{sx:{position:"absolute",top:8,right:8,backgroundColor:"rgba(255, 255, 255, 0.9)","&:hover":{backgroundColor:"rgba(255, 255, 255, 1)"}},onClick:z,size:"small",children:e(M,{})})]})}):a(r,{sx:{textAlign:"center",py:4,backgroundColor:"rgba(0,0,0,0.02)",borderRadius:1,border:"2px dashed #e0e0e0"},children:[e(O,{type:"file",inputProps:{accept:"image/*"},onChange:S,sx:{display:"none"},id:"color-extractor-upload"}),e(i,{variant:"body1",color:"textSecondary",gutterBottom:!0,children:"Upload an Image to Extract Colors"}),e(i,{variant:"body2",color:"textSecondary",sx:{mb:2},children:"Select an image file and we'll automatically extract a color palette"}),e("label",{htmlFor:"color-extractor-upload",children:e(A,{variant:"contained",component:"span",startIcon:e(V,{}),size:"large",children:"Choose Image"})})]})}),E&&a(r,{display:"flex",alignItems:"center",gap:2,sx:{mb:3,p:2,backgroundColor:"rgba(25, 118, 210, 0.04)",borderRadius:1},children:[e(U,{size:20}),e(i,{children:"Extracting colors from image..."})]}),k&&e(F,{severity:"error",sx:{mb:3},children:k}),B&&e(F,{severity:"error",sx:{mb:3},children:B}),n&&n.length>0&&!E&&a(r,{sx:{mb:3},children:[a(i,{variant:"subtitle1",gutterBottom:!0,children:["Extracted Colors (",n.length," colors found)"]}),e(r,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:2,mb:3},children:n.map((t,o)=>{const s=Y(t),l=g&&t[0]===g[0]&&t[1]===g[1]&&t[2]===g[2];return e(r,{sx:{width:50,height:50,backgroundColor:s,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",border:l?"3px solid #4caf50":"2px solid #ccc",cursor:"pointer",transition:"transform 0.2s","&:hover":{transform:"scale(1.1)"}},title:`${s} ${l?"(Dominant)":""}`,children:e(i,{variant:"caption",sx:{color:X(s),fontWeight:"bold",fontSize:"0.8rem"},children:o+1})},o)})}),a(r,{sx:{mb:3},children:[e(H,{fullWidth:!0,multiline:!0,rows:2,placeholder:"Optional: Describe the theme style you want (e.g., 'modern and minimalist', 'warm and cozy', 'professional corporate')",value:f,onChange:t=>R(t.target.value),sx:{mb:2},label:"Theme Description (Optional)"}),e(r,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:e(A,{variant:"contained",startIcon:y?e(U,{size:16}):e(q,{}),onClick:G,disabled:y,color:"primary",children:y?"Generating...":"Generate AI Theme"})})]}),a(i,{variant:"body2",color:"textSecondary",sx:{fontStyle:"italic"},children:["\u2022 ",e("strong",{children:"Generate AI Theme:"})," Uses AI to create a complete color scheme based on extracted colors and your description"]})]})]})});var xe=ee;export{xe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l=t=>{let r,s,e,a=1;if(t.startsWith("#")){const n=t.replace("#","");n.length===8?(r=parseInt(n.substr(0,2),16),s=parseInt(n.substr(2,2),16),e=parseInt(n.substr(4,2),16),a=parseInt(n.substr(6,2),16)/255):(r=parseInt(n.substr(0,2),16),s=parseInt(n.substr(2,2),16),e=parseInt(n.substr(4,2),16))}else if(t.startsWith("rgb")){const n=t.match(/rgba?\(([^)]+)\)/);if(n){const h=n[1].split(",").map(i=>parseFloat(i.trim()));[r,s,e,a=1]=h}else return"#000000"}else return t.startsWith("hsl"),"#000000";return(.299*r+.587*s+.114*e)/255*a+(1-a)>.5?"#000000":"#ffffff"},m=(t,r)=>{switch(r){case"hex":if(t.rgb.a!==void 0&&t.rgb.a<1){const u=Math.round(t.rgb.a*255).toString(16).padStart(2,"0");return`${t.hex}${u}`}return t.hex;case"rgb":return`rgb(${Math.round(t.rgb.r)}, ${Math.round(t.rgb.g)}, ${Math.round(t.rgb.b)})`;case"rgba":const s=t.rgb.a!==void 0?Number(t.rgb.a.toFixed(2)):1;return`rgba(${Math.round(t.rgb.r)}, ${Math.round(t.rgb.g)}, ${Math.round(t.rgb.b)}, ${s})`;case"hsl":return`hsl(${Math.round(t.hsl.h)}, ${Math.round(t.hsl.s*100)}%, ${Math.round(t.hsl.l*100)}%)`;case"hsla":const e=t.hsl.a!==void 0?Number(t.hsl.a.toFixed(2)):1;return`hsla(${Math.round(t.hsl.h)}, ${Math.round(t.hsl.s*100)}%, ${Math.round(t.hsl.l*100)}%, ${e})`;default:return t.hex}},b=t=>{const r=t.split("--"),s=r[0],e=r[1];return{baseChips:s.split("-").filter(u=>u.length>0),mode:e}},c=t=>{const r=new Set;return t.forEach(s=>{const{mode:e}=b(s.key);e&&r.add(e)}),Array.from(r).sort()},$=t=>{if(!t)return"";switch(t.toLowerCase()){case"light":return"\u2600\uFE0F";case"dark":return"\u{1F319}";default:return t}},x=t=>{const[r,s,e]=t;return`#${((1<<24)+(r<<16)+(s<<8)+e).toString(16).slice(1)}`},M=t=>{const[r,s,e]=t;return`rgb(${r}, ${s}, ${e})`};export{m as convertColor,c as extractAvailableModes,l as getContrastColor,$ as getModeIcon,b as parseColorKey,x as rgbArrayToHex,M as rgbArrayToRgbString};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as f,useEffect as d,useCallback as C}from"react";const m=(t,n={})=>{const[u,l]=f({dominantColor:null,palette:null,loading:!1,error:null}),s=C(async i=>{if(i){l(e=>({...e,loading:!0,error:null}));try{const e=(await import("colorthief")).default,r=new Image;r.crossOrigin="anonymous",r.onload=()=>{try{const o=new e,a=o.getColor(r),c=o.getPalette(r,n.colorCount||5,n.quality||10);l({dominantColor:a,palette:c,loading:!1,error:null})}catch(o){console.error("Color extraction error:",o),l(a=>({...a,loading:!1,error:`Failed to extract colors: ${o instanceof Error?o.message:"Unknown error"}`}))}},r.onerror=()=>{l(o=>({...o,loading:!1,error:"Failed to load image"}))},r.src=i}catch(e){console.error("ColorThief import error:",e),l(r=>({...r,loading:!1,error:`Failed to load Color Thief: ${e instanceof Error?e.message:"Unknown error"}`}))}}},[n.colorCount,n.quality]);return d(()=>{t?s(t):l({dominantColor:null,palette:null,loading:!1,error:null})},[t,s]),u};export{m as useAsyncColorThief};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as b,jsx as r,jsxs as v}from"react/jsx-runtime";import{useCallback as h,useEffect as C,useState as u}from"react";import{useRecordContext as I,useUpdate as y}from"react-admin";import{Switch as x,Box as S}from"@mui/material";import{AttributeToField as w}from"@dashadmin/dash-auto-admin/src/mui/AttributeToField";import B from"@dashadmin/dash-auto-admin/src/mui/AttributeToInput";const D=({method:s,attribute:e,resourceConfig:i,activeLabel:c="Activo",inactiveLabel:l="Inactivo",enableLabel:F="Activar",disableLabel:T="Desactivar",showLabel:A=!1})=>{const[,L]=u(!0),[d,{isLoading:k}]=y(),t=I(),[n,m]=u(!1),p=o=>{console.error(o)},g=h(async o=>{try{await d(i.model+"/partial/"+t.id,{id:t.id,data:{[e.attribute]:o},previousData:t,meta:{method:"POST"}},{onSuccess:()=>{m(o)},onSettled:(a,f)=>{f&&p(f)}})}catch(a){p(a)}},[d,t]);switch(C(()=>{L(!1),t&&e&&e.attribute in t&&m(!!t[e.attribute])},[t,e]),s){case"create":case"edit":return B(s,i,{...e,custom:!1,type:Boolean});case"view":return w(s,i,{...e,custom:!1,type:Boolean});case"list":return r("div",{children:v(S,{children:[r(x,{size:"small",onChange:(o,a)=>g(a),checked:n}),A?n?c:l:r(b,{})]})});default:return v(b,{children:[e.label,": ",n?c:l]})}};var K=D;export{K as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as _,jsx as m,jsxs as p}from"react/jsx-runtime";import{useCallback as b,useEffect as w,useState as A}from"react";import{useRecordContext as L,useUpdate as C}from"react-admin";import{Switch as x,Box as y}from"@mui/material";import{AttributeToField as E}from"@dashadmin/dash-auto-admin/src/mui/AttributeToField";import I from"@dashadmin/dash-auto-admin/src/mui/AttributeToInput";const S=({method:o,attribute:s,resourceConfig:i,activeLabel:r="Activo",inactiveLabel:c="Inactivo",enableLabel:v="Activar",disableLabel:f="Desactivar"})=>{const[,g]=A(!0),[d,{isLoading:B}]=C(),t=L(),l=e=>{console.error(e)},h=b(async e=>{window.dispatchEvent(new MessageEvent("dash-global-loader",{data:!0}));try{await d(i.model+"/change-status/"+t.id,{id:t.id,data:{is_active:e},previousData:t},{onSuccess:()=>{t.is_active=e},onSettled:(a,u)=>{u&&l(u),window.dispatchEvent(new MessageEvent("dash-global-loader",{data:!1}))}})}catch(a){l(a)}},[d,t]);w(()=>{g(!1)},[t]);const n=!!t?.is_active,D=t?.is_active?f:v;switch(o){case"create":case"edit":return I(o,i,{...s,custom:!1,type:Boolean});case"view":return E(o,i,{...s,custom:!1,type:Boolean});case"list":return m("div",{children:p(y,{children:[m(x,{onChange:(e,a)=>h(a),...n===!0&&{defaultChecked:!0}}),n?r:c]})});default:return p(_,{children:[s.label,": ",n?r:c]})}};var K=S;export{K as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as q,jsx as e,jsxs as l}from"react/jsx-runtime";import B,{useMemo as P}from"react";import{Box as c,Card as w,CardContent as E,Typography as b,Switch as F,FormControlLabel as D,Alert as I,TextField as z,InputAdornment as S,IconButton as R,Chip as v}from"@mui/material";import{Search as L,Clear as W,Email as _,Notifications as j}from"@mui/icons-material";import{useRecordContext as K}from"react-admin";import{useFormContext as J}from"react-hook-form";import{AuthPersistenceService as M}from"@dashadmin/dash-auth";const V=(m,r)=>!r||!m?[]:r.split(".").reduce((i,a)=>i&&i[a]!==void 0?i[a]:[],m),O=(m,r,s)=>{if(!r)return s;const i=r.split("."),a=i.pop(),u={...m};let f=u;for(const y of i)f[y]||(f[y]={}),f=f[y];return a&&(f[a]=s),u},Q=m=>{const{attribute:r}=m,s=K(),i=J(),[a,u]=B.useState(""),[f,y]=B.useState(null),x=i?.setValue,h=i?.getValues,p=r?.attribute||"",n=p.startsWith("preferences."),d=n?p.split(".").slice(1).join("."):p,C=P(()=>{const t=M.getSystemValues();console.log("\u{1F514} NotificationPreferencesEdit - systemValues:",t);const o=t?.user_notifications||[];return console.log("\u{1F514} NotificationPreferencesEdit - user_notifications:",o),o},[]),G=P(()=>{let t=[];if(s){const o=n?V(s,d):s[p];t=Array.isArray(o)?o:[],console.log("\u{1F514} NotificationPreferencesEdit - preferences from record:",t)}else if(h){const o=h(),g=n?V(o,d):o[p];t=Array.isArray(g)?g:[],console.log("\u{1F514} NotificationPreferencesEdit - preferences from form:",t)}return C.map(o=>t.find(N=>N.id===o.className)||{id:o.className,name:o.name,email:o.hasEmail,push:o.hasPush})},[C,s,p,n,d,h]),A=f??G,T=P(()=>a.trim()?A.filter(t=>t.name.toLowerCase().includes(a.toLowerCase())):A,[A,a]),H=t=>{if(x)if(n){const o=h?.()||{},g=O({...o},d,t);x(p,V(g,d),{shouldDirty:!0})}else x(p,t,{shouldDirty:!0})},k=(t,o)=>{const g=A.map(N=>N.id===t?{...N,[o]:!N[o]}:N);y(g),H(g)};return i?C.length===0?l(I,{severity:"info",children:["No notifications available to configure.",e(b,{variant:"caption",display:"block",sx:{mt:1},children:"Debug: No user_notifications found in systemValues. Try logging out and logging back in to refresh auth data."})]}):l(c,{sx:{mt:1,mb:2},children:[e(b,{variant:"h6",gutterBottom:!0,children:"Notification Preferences"}),e(b,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Configure which notifications you want to receive via email and push notifications"}),A.length>5&&e(z,{fullWidth:!0,variant:"outlined",placeholder:"Search notifications...",value:a,onChange:t=>u(t.target.value),sx:{mb:2},InputProps:{startAdornment:e(S,{position:"start",children:e(L,{})}),endAdornment:a&&e(S,{position:"end",children:e(R,{onClick:()=>u(""),edge:"end",size:"small",children:e(W,{})})})}}),a&&T.length===0&&l(I,{severity:"info",sx:{mb:2},children:['No notifications found matching "',a,'"']}),T.map(t=>{const o=C.find(g=>g.className===t.id);return o?e(w,{variant:"outlined",sx:{mb:1,"&:hover":{boxShadow:2}},children:e(E,{sx:{p:2,"&:last-child":{pb:2}},children:l(c,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l(c,{sx:{flex:1},children:[e(b,{variant:"subtitle1",fontWeight:"bold",children:t.name}),l(c,{sx:{display:"flex",gap:1,mt:.5},children:[o.hasSocket&&e(v,{label:"Real-time",size:"small",color:"info"}),o.hasDatabase&&e(v,{label:"Stored",size:"small",color:"default"})]})]}),l(c,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.hasEmail&&e(D,{control:e(F,{checked:t.email,onChange:()=>k(t.id,"email"),color:"primary"}),label:l(c,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e(_,{fontSize:"small"}),e(b,{variant:"body2",children:"Email"})]})}),o.hasPush&&e(D,{control:e(F,{checked:t.push,onChange:()=>k(t.id,"push"),color:"secondary"}),label:l(c,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e(j,{fontSize:"small"}),e(b,{variant:"body2",children:"Push"})]})})]})]})})},t.id):null})]}):e(I,{severity:"warning",children:"Form context not available. This component must be used within a form."})},U=m=>{const{attribute:r}=m,s=K(),[i,a]=B.useState(""),u=r?.attribute||"",f=u.startsWith("preferences."),y=f?u.split(".").slice(1).join("."):u,x=P(()=>M.getSystemValues()?.user_notifications||[],[]),h=P(()=>{if(!s)return[];const n=f?V(s,y):s[u];return Array.isArray(n)?n:[]},[s,u,f,y]),p=P(()=>i.trim()?h.filter(n=>n.name.toLowerCase().includes(i.toLowerCase())):h,[h,i]);return x.length===0?e(I,{severity:"info",children:"No notification preferences configured."}):l(c,{sx:{mt:1,mb:2},children:[e(b,{variant:"h6",gutterBottom:!0,children:"Notification Preferences"}),h.length>5&&e(z,{fullWidth:!0,variant:"outlined",placeholder:"Search notifications...",value:i,onChange:n=>a(n.target.value),sx:{mb:2},InputProps:{startAdornment:e(S,{position:"start",children:e(L,{})}),endAdornment:i&&e(S,{position:"end",children:e(R,{onClick:()=>a(""),edge:"end",size:"small",children:e(W,{})})})}}),p.map(n=>{const d=x.find(C=>C.className===n.id);return d?e(w,{variant:"outlined",sx:{mb:1},children:e(E,{sx:{p:2,"&:last-child":{pb:2}},children:l(c,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l(c,{sx:{flex:1},children:[e(b,{variant:"subtitle1",fontWeight:"bold",children:n.name}),l(c,{sx:{display:"flex",gap:1,mt:.5},children:[d.hasSocket&&e(v,{label:"Real-time",size:"small",color:"info"}),d.hasDatabase&&e(v,{label:"Stored",size:"small",color:"default"})]})]}),l(c,{sx:{display:"flex",gap:2},children:[d.hasEmail&&e(v,{icon:e(_,{}),label:"Email",color:n.email?"primary":"default",variant:n.email?"filled":"outlined"}),d.hasPush&&e(v,{icon:e(j,{}),label:"Push",color:n.push?"secondary":"default",variant:n.push?"filled":"outlined"})]})]})})},n.id):null}),h.length===0&&e(I,{severity:"info",children:"No notification preferences configured"})]})},X=m=>{const{method:r="edit",attribute:s=null,resourceConfig:i=null}=m;switch(console.log("\u{1F514} NotificationPreferences - method:",r),console.log("\u{1F514} NotificationPreferences - attribute:",s),r){case"edit":case"create":return e(q,{children:e(Q,{method:r,attribute:s,resourceConfig:i})});case"view":return e(q,{children:e(U,{method:r,attribute:s,resourceConfig:i})});default:return console.log("\u{1F514} NotificationPreferences - unsupported method:",r),null}};var se=X;export{Q as NotificationPreferencesEdit,U as NotificationPreferencesView,se as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as o}from"./NotificationPreferences";import{NotificationPreferencesEdit as t,NotificationPreferencesView as f}from"./NotificationPreferences";export{o as NotificationPreferences,t as NotificationPreferencesEdit,f as NotificationPreferencesView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as I,jsx as i,jsxs as K}from"react/jsx-runtime";import{Autocomplete as B,Box as M,CircularProgress as Q,TextField as W}from"@mui/material";import{useEffect as z,useState as g}from"react";import{useController as G}from"react-hook-form";import{useGetList as H}from"react-admin";import{useRecordContext as _}from"react-admin";import{isArray as j}from"lodash";const A=({method:u,attribute:o,isMultiple:d=!1,searchResults:N=50,minSearch:k=3,timerSearch:D=500,resource:L,selectLabel:P,renderText:c,transformData:v,queryFilter:x="q",defaultValues:U=void 0,isEmpty:F=!1,filter:V,isOptionEqualToValue:h=void 0,viewAttribute:f=null,elementKeyId:O="id"})=>{const[S,C]=g(!0),[l,y]=g(null),[b,w]=g(""),a=_(),s=G({name:o.attribute,defaultValue:a?a[o.attribute]:null}),E=a&&a[o.attribute]&&j(a[o.attribute])?a[o.attribute].map(e=>e.hasOwnProperty(O)?e[O]:e):a[o.attribute],{data:p,total:X,isLoading:m,error:Y}=H(L,{filter:{[x]:b,...V,includes:E}},{refetchOnWindowFocus:!1});z(()=>(p&&!m&&(l&&y([...l,...p.map(e=>({...e,key:"option"+e.id}))]),y(p.map(e=>({...e,key:"option"+e.id})))),()=>y([])),[p,m]);const[R,T]=g(void 0),q=(e,t=500)=>{clearTimeout(R),T(setTimeout(()=>{e()},t))};return i(I,{children:l&&i(B,{multiple:d,loading:m&&S,fullWidth:!0,freeSolo:!0,options:l,open:S,onOpen:()=>C(!0),onClose:()=>C(!1),defaultValue:s.field?.value,isOptionEqualToValue:h,autoHighlight:!0,getOptionLabel:e=>{const t=Array.isArray(e)?e:l&&l.find(r=>h(r,s.field.value));if(!t)return b;const n=f&&!c?t[f]:c(t);return console.log("getOptionLabel",l.find(r=>h(r,s.field.value)),n),n||b},renderOption:(e,t)=>{const{key:n,...r}=e;return i(M,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...r,children:f&&!c?t[f]:c(t)},t.key)},onChange:(e,t)=>{console.log("onChange",e,t);let n=t;Array.isArray(t)&&(n=F?[...t,...s.field.value]:[...new Map(n.map(r=>[r.id,r])).values()]),v?s.field.onChange(v(n)):s.field.onChange(n)},renderInput:e=>(console.log("renderInput",e.id),i(W,{...e,label:P,variant:"outlined",onChange:t=>{let n=t.target.value;n&&n!==""&&n.length>=k&&q(()=>w(n),D)},InputProps:{...e.InputProps,autoComplete:"new-password",endAdornment:K(I,{children:[m?i(Q,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}},e.id))},"autocomplete-"+o.attribute)})},J=({method:u,attribute:o,...d})=>{switch(u){case"edit":case"create":return i(A,{attribute:o,method:u,...d});case"view":return i(A,{attribute:o,method:u,...d})}};var de=J;export{de as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as n,jsxs as p}from"react/jsx-runtime";import{Box as u,Checkbox as G,CircularProgress as ge,TextField as J,Typography as b,Chip as U,List as be,ListItem as z,ListItemButton as X,ListItemIcon as Y,ListItemText as E,Paper as xe,Popper as Se,ClickAwayListener as Ie,InputAdornment as P,IconButton as Z}from"@mui/material";import{useEffect as M,useState as m,useRef as Le}from"react";import{useGetList as Ce}from"react-admin";import{LoadingIndicator as ke}from"react-admin";import Be from"@mui/icons-material/Search";import Te from"@mui/icons-material/Clear";import Ae from"@mui/icons-material/ExpandMore";import Oe from"@mui/icons-material/ExpandLess";const je=({isMultiple:we=!0,searchResults:x=50,minSearch:S=1,minOptions:F=10,timerSearch:K=300,resource:ee,selectLabel:te,renderText:C,transformData:ze=y=>y,queryFilter:ne="q",defaultValues:k=void 0,value:L,onChange:f,isEmpty:Ee=!1,filter:oe,isOptionEqualToValue:Pe,viewAttribute:d=null,valueKeyId:a="id",transformOption:v,disabled:V=!1,placeholder:re="",emptyText:Me="",fullWidth:D=!0,maxHeight:W=300,showSelectAll:se=!0,showSelectedCount:$=!0})=>{const[y,B]=m(!1),[ie,R]=m(!1),[l,ae]=m([]),[c,T]=m(""),[s,h]=m([]),[le,ce]=m(void 0),A=Le(null),[q,H]=m(""),O=(e,t)=>typeof v=="function"?v(e,l,t):e,_=(()=>{const e=L||k;if(!e)return[];if(Array.isArray(e))return e.map(r=>typeof r=="object"?r[a]:r).filter(Boolean);const t=typeof e=="object"?e[a]:e;return t?[t]:[]})(),pe=()=>{const e={...oe};return _.length>0&&(e.includes=_),c&&c.length>=S?(e[ne]=c,e.mixed_results=!0,e.min_options=F,e.limit=x):e.limit=Math.max(F,x),e},{data:I,isLoading:N,error:ve}=Ce(ee,{meta:{removeSortFilters:!0},filter:pe()});M(()=>{if(I){let t=(Array.isArray(I)?I:Object.values(I)).map((r,o)=>{const i=c&&c.length>=S?r[d]&&r[d].toLowerCase().includes(c.toLowerCase()):!0;return{...r,key:`option-${r[a]||o}`,isSearchMatch:i,priority:i?1:2}});t.sort((r,o)=>{if(r.priority!==o.priority)return r.priority-o.priority;const i=r[d]||r.name||"",w=o[d]||o.name||"";return i.localeCompare(w)}),t.length>x&&(t=t.slice(0,x)),ae(t)}},[I,a,c,S,d,x]),M(()=>{const e=L!==void 0?L:k;if(e==null){h([]),R(!0);return}let t=[];Array.isArray(e)?t=e:e&&(t=[e]),h(t),R(!0)},[L,k]),M(()=>{if(l.length>0&&s.length>0){const e=s.map(t=>{if(typeof t=="object"&&t[d])return t;const r=typeof t=="object"?t[a]:t;return l.find(o=>o[a]===r)||t});h(e)}},[l,d,a]);const de=(e,t=300)=>{clearTimeout(le),ce(setTimeout(()=>{e()},t))},ue=e=>{const t=e.target.value;H(t),t&&t!==""&&t.length>=S?de(()=>T(t),K):t===""&&T("")},me=()=>{H(""),T("")},g=e=>s.some(t=>{const r=typeof t=="object"?t[a]:t,o=typeof e=="object"?e[a]:e;return r===o}),Q=e=>{const t=g(e);let r;t?r=s.filter(o=>{const i=typeof o=="object"?o[a]:o,w=typeof e=="object"?e[a]:e;return i!==w}):r=[...s,e],h(r),f&&f(r)},fe=()=>{if(l.every(t=>g(t))){const t=l.map(o=>typeof o=="object"?o[a]:o),r=s.filter(o=>{const i=typeof o=="object"?o[a]:o;return!t.includes(i)});h(r),f&&f(r)}else{const t=l.filter(o=>!g(o)),r=[...s,...t];h(r),f&&f(r)}},ye=()=>s.length===0?re||"Seleccionar opciones...":$&&s.length>2?`${s.length} elementos seleccionados`:s.slice(0,2).map(e=>C(O(e,"display"),"display")).join(", ")+(s.length>2?`, +${s.length-2} m\xE1s`:""),j=l.length>0&&l.every(e=>g(e)),he=l.some(e=>g(e));return ie?p(u,{ref:A,sx:{position:"relative",width:D?"100%":"auto"},children:[n(J,{fullWidth:D,label:te,value:ye(),onClick:()=>B(!y),disabled:V,variant:"outlined",InputProps:{readOnly:!0,endAdornment:n(P,{position:"end",children:n(Z,{onClick:e=>{e.stopPropagation(),B(!y)},edge:"end",size:"small",children:y?n(Oe,{}):n(Ae,{})})})},sx:{cursor:"pointer","& .MuiInputBase-input":{cursor:"pointer"}}}),s.length>0&&p(u,{sx:{mt:1,display:"flex",flexWrap:"wrap",gap:.5},children:[s.slice(0,5).map((e,t)=>n(U,{label:C(O(e,"chip"),"chip"),size:"small",onDelete:()=>Q(e),disabled:V},`chip-${e[a]||t}`)),s.length>5&&n(U,{label:`+${s.length-5} m\xE1s`,size:"small",variant:"outlined"})]}),n(Se,{open:y,anchorEl:A.current,placement:"bottom-start",style:{zIndex:1300,width:A.current?.offsetWidth},children:n(Ie,{onClickAway:()=>B(!1),children:p(xe,{elevation:8,sx:{maxHeight:W+100,width:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[n(u,{sx:{p:2,borderBottom:"1px solid #e0e0e0"},children:n(J,{fullWidth:!0,size:"small",placeholder:"Buscar...",value:q,onChange:ue,InputProps:{startAdornment:n(P,{position:"start",children:n(Be,{fontSize:"small"})}),endAdornment:q&&n(P,{position:"end",children:n(Z,{size:"small",onClick:me,children:n(Te,{fontSize:"small"})})})}})}),se&&l.length>0&&n(u,{sx:{borderBottom:"1px solid #e0e0e0"},children:n(z,{disablePadding:!0,children:p(X,{onClick:fe,dense:!0,children:[n(Y,{children:n(G,{checked:j,indeterminate:he&&!j,size:"small"})}),n(E,{primary:p(b,{variant:"body2",fontWeight:"bold",children:[j?"Deseleccionar todo":"Seleccionar todo",c&&` (${l.length} resultados)`]})})]})})}),N&&p(u,{sx:{p:2,display:"flex",justifyContent:"center",alignItems:"center"},children:[n(ge,{size:20}),n(b,{variant:"body2",sx:{ml:1},children:"Cargando opciones..."})]}),!N&&n(be,{sx:{maxHeight:W,overflow:"auto",py:0},children:l.length===0?n(z,{children:n(E,{primary:n(b,{variant:"body2",color:"text.secondary",textAlign:"center",children:c?"No se encontraron resultados":"No hay opciones disponibles"})})}):l.map((e,t)=>{const r=g(e),o=e.isSearchMatch,i=c&&c.length>=S;return n(z,{disablePadding:!0,children:p(X,{onClick:()=>Q(e),dense:!0,sx:{backgroundColor:i&&o?"rgba(25, 118, 210, 0.04)":"transparent",borderLeft:i&&o?"3px solid #1976d2":"none",paddingLeft:i&&o?1:2,"&:hover":{backgroundColor:i&&o?"rgba(25, 118, 210, 0.08)":"rgba(0, 0, 0, 0.04)"}},children:[n(Y,{children:n(G,{checked:r,size:"small",tabIndex:-1,disableRipple:!0})}),n(E,{primary:p(u,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n(b,{variant:"body2",sx:{fontWeight:i&&o?"bold":"normal",opacity:i&&!o?.7:1},children:C(O(e,"option"),"option")}),i&&o&&n(b,{variant:"caption",sx:{color:"#1976d2",fontWeight:"bold",fontSize:"0.75rem"},children:"\u2713"})]})})]})},e.key||`option-${t}`)})}),$&&s.length>0&&n(u,{sx:{p:1,borderTop:"1px solid #e0e0e0",backgroundColor:"#f5f5f5"},children:p(b,{variant:"caption",color:"text.secondary",children:[s.length," elemento",s.length!==1?"s":""," seleccionado",s.length!==1?"s":""]})})]})})})]}):n(ke,{})};var Je=je;export{je as SearchableSelectCheckboxes,Je as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as ie,jsx as u,jsxs as G}from"react/jsx-runtime";import{Autocomplete as K,Box as E,Chip as ee,CircularProgress as te,TextField as re}from"@mui/material";import{useEffect as B,useState as y}from"react";import{useGetList as oe}from"react-admin";import{LoadingIndicator as ne}from"react-admin";const ae=({isMultiple:l=!1,searchResults:c=50,minSearch:s=2,minOptions:p=10,timerSearch:j=500,resource:i,selectLabel:L,renderText:I,transformData:se=U=>U,queryFilter:T="q",defaultValues:P=void 0,value:C,onChange:O,isEmpty:le=!1,filter:z,isOptionEqualToValue:_,viewAttribute:d=null,valueKeyId:h="id",transformOption:F,disabled:X=!1,placeholder:$="",emptyText:ce="",fullWidth:H=!0,enableMixedResults:m=!1})=>{const[U,k]=y(!1),[N,w]=y(!1),[f,J]=y([]),[r,Q]=y(""),[x,D]=y([]),[M,Y]=y(void 0),A=(e,t)=>typeof F=="function"?F(e,f,t):e,W=(()=>{const e=C||P;if(!e)return[];if(Array.isArray(e))return e.map(n=>typeof n=="object"?n[h]:n).filter(Boolean);const t=typeof e=="object"?e[h]:e;return t?[t]:[]})(),Z=(()=>{const e={...z};if(W.length>0&&(e.includes=W),console.log("\u{1F527} SearchableSelectChips DEBUG - buildFilterParams called:",{resource:i,enableMixedResults:m,searchQuery:r,hasSearch:r&&r.length>=s,timestamp:new Date().toISOString()}),m){const t=p;e.mixedResults=t,console.log("\u{1F525} SearchableSelectChips DEBUG - Mixed results enabled via query param:",{resource:i,mixedResults:t,searchQuery:r,hasSearch:r&&r.length>=s,baseFilter:e,timestamp:new Date().toISOString()}),r&&r.length>=s&&(e[T]=r),e.limit=c}else r&&r.length>=s?(e[T]=r,e.mixed_results=!0,e.min_options=p,e.limit=c,console.log("\u{1F50D} SearchableSelectChips DEBUG - Legacy mixed results enabled:",{resource:i,searchQuery:r,minOptions:p,searchResults:c,mixed_results:!0,baseFilter:e,timestamp:new Date().toISOString()})):e.limit=Math.max(p,c);return console.log("\u{1F680} SearchableSelectChips DEBUG - Final filter params:",{resource:i,filterParams:e,enableMixedResults:m,timestamp:new Date().toISOString()}),e})(),{data:b,isLoading:q,error:ge}=oe(i,{meta:{removeSortFilters:!0},filter:Z});B(()=>{if(b){const e=Array.isArray(b)?b:Object.values(b);console.log("\u{1F4CA} SearchableSelectChips DEBUG - Processing results:",{resource:i,totalResults:e.length,searchQuery:r,hasSearch:r&&r.length>=s,enableMixedResults:m,timestamp:new Date().toISOString()});let t=e.map((o,a)=>{const S=r&&r.length>=s?o[d]&&o[d].toLowerCase().includes(r.toLowerCase()):!0;return{...o,key:`option-${o[h]||a}`,isSearchMatch:S,priority:S?1:2}});t.sort((o,a)=>{if(o.priority!==a.priority)return o.priority-a.priority;const S=o[d]||o.name||"",R=a[d]||a.name||"";return S.localeCompare(R)});const n=t.filter(o=>o.isSearchMatch),g=t.filter(o=>!o.isSearchMatch);console.log("\u{1F3AF} SearchableSelectChips DEBUG - Results breakdown:",{resource:i,searchQuery:r,totalProcessed:t.length,searchMatches:n.length,nonMatches:g.length,enableMixedResults:m,mixedResultsParam:m?p:"disabled",timestamp:new Date().toISOString()}),t.length>c&&(t=t.slice(0,c)),J(t)}},[b,h,r,s,d,c,p,m]),B(()=>{console.log("\u{1F50D} SearchableSelectChips DEBUG - Component initialized with resource:",{resource:i,resourceType:typeof i,selectLabel:L,isMultiple:l,minOptions:p,searchResults:c,minSearch:s,timestamp:new Date().toISOString()})},[]),B(()=>{const e=C!==void 0?C:P;if(console.log("\u{1F3AF} SearchableSelectChips DEBUG - Value changed:",{resource:i,currentValue:e,valueType:typeof e,isArray:Array.isArray(e),isMultiple:l,timestamp:new Date().toISOString()}),e==null){D([]),w(!0);return}let t=[];l?Array.isArray(e)?t=e:e&&(t=[e]):e&&(t=[e]),console.log("\u{1F3AF} SearchableSelectChips DEBUG - Selected options set:",{resource:i,currentValue:e,initialSelectedOptions:t,isMultiple:l,timestamp:new Date().toISOString()}),D(t),w(!0)},[C,P,l]),B(()=>{if(f.length>0&&x.length>0){const e=x.map(t=>{if(typeof t=="object"&&t[d])return t;const n=typeof t=="object"?t[h]:t;return f.find(g=>g[h]===n)||t});D(e)}},[f,d,h]);const v=(e,t=500)=>{clearTimeout(M),Y(setTimeout(()=>{e()},t))},V=e=>{D(e||[]),O&&O(l?e||[]:e&&e.length>0?e[0]:null)};return N?u(K,{multiple:l,loading:q,fullWidth:H,freeSolo:!1,options:f,open:U,onOpen:()=>k(!0),onClose:()=>k(!1),value:l?x:x[0]||null,isOptionEqualToValue:_,autoHighlight:!0,disabled:X,getOptionLabel:e=>e&&I(A(e,"optionlabel"),"optionlabel")||"",renderOption:(e,t)=>{const{key:n,...g}=e,o=t.isSearchMatch,a=r&&r.length>=s;return G(E,{component:"li",sx:{"& > img":{mr:2,flexShrink:0},fontWeight:a&&o?"bold":"normal",opacity:a&&!o?.7:1,borderLeft:a&&o?"3px solid #1976d2":"none",paddingLeft:a&&o?1:2,backgroundColor:a&&o?"rgba(25, 118, 210, 0.04)":"transparent",borderTop:a&&!o&&t.priority===2?"1px solid rgba(0,0,0,0.1)":"none",marginTop:a&&!o&&t.priority===2?.5:0},...g,children:[a&&t.priority===2&&f.indexOf(t)===f.findIndex(S=>S.priority===2)&&u(E,{sx:{position:"absolute",top:-20,left:0,right:0,fontSize:"0.7rem",color:"text.secondary",backgroundColor:"background.paper",padding:"2px 8px",borderBottom:"1px solid rgba(0,0,0,0.1)",fontWeight:"bold"},children:"Otras opciones"}),I(A(t,"option"),"option"),a&&o&&G(E,{component:"span",sx:{ml:"auto",fontSize:"0.75rem",color:"#1976d2",fontWeight:"bold",display:"flex",alignItems:"center",gap:.5},children:[u(E,{component:"span",sx:{width:6,height:6,borderRadius:"50%",backgroundColor:"#1976d2"}}),"Coincidencia"]})]},t.key||`option-${t[h]}`)},renderValue:(e,t)=>e.map((n,g)=>{const o=t({index:g});return u(ee,{label:I(A(n,"chip"),"chip"),...o},`chip-${n[h]||g}`)}),onChange:(e,t)=>{console.log("\u{1F504} SearchableSelectChips DEBUG - Autocomplete onChange:",{resource:i,rawValue:t,isMultiple:l,timestamp:new Date().toISOString()}),V(l?Array.isArray(t)?t:[]:t?[t]:[])},renderInput:e=>u(re,{...e,label:L,variant:"outlined",placeholder:$,onChange:t=>{const n=t.target.value;console.log("\u{1F50D} SearchableSelectChips DEBUG - Search input changed:",{resource:i,searchValue:n,searchLength:n.length,minSearch:s,willTriggerSearch:n.length>=s,timestamp:new Date().toISOString()}),n&&n!==""&&n.length>=s?v(()=>{console.log("\u{1F680} SearchableSelectChips DEBUG - Triggering search:",{resource:i,searchValue:n,minOptions:p,searchResults:c,timestamp:new Date().toISOString()}),Q(n)},j):n===""&&(console.log("\u{1F504} SearchableSelectChips DEBUG - Clearing search:",{resource:i,timestamp:new Date().toISOString()}),Q(""))},slotProps:{input:{...e.InputProps,autoComplete:"new-password",endAdornment:G(ie,{children:[q&&u(te,{color:"inherit",size:20}),e.InputProps.endAdornment]})}}}),ListboxProps:{sx:{maxHeight:400,"& .MuiAutocomplete-option":{position:"relative"}}}}):u(ne,{})};var Ce=ae;export{ae as SearchableSelectChips,Ce as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as v,jsx as i,jsxs as se}from"react/jsx-runtime";import{Autocomplete as Y,Box as T,Chip as B,CircularProgress as Z,TextField as M}from"@mui/material";import{useEffect as O,useState as d}from"react";import{useFormContext as K}from"react-hook-form";import{useGetList as ee}from"react-admin";import{useRecordContext as E}from"react-admin";import{LoadingIndicator as te}from"react-admin";const oe=({method:a,attribute:m,isMultiple:n=!1,searchResults:f=50,minSearch:A=3,timerSearch:I=500,resource:D,selectLabel:P,renderText:S,transformData:ie=C=>C,queryFilter:q="q",defaultValues:l=void 0,isEmpty:ae=!1,filter:N,isOptionEqualToValue:$=void 0,viewAttribute:le=null,valueKeyId:c="id",useBaseAttributeName:ce=!1,useListAttributeForController:ue=!1,transformOption:L})=>{const{setValue:C,watch:j}=K(),r=E(),s=m.attribute,p=m.listAttribute||m.attribute;console.log("Attribute config:",{saveAttributeName:s,displayAttributeName:p,record:r?{[s]:r[s],[p]:r[p]}:null});const[z,k]=d(!1),[F,V]=d(!1),[y,_]=d([]),[G,H]=d(""),[b,x]=d([]),[Q,U]=d(void 0),h=j(s),R=(e,t)=>typeof L=="function"?L(e,y,t):e,W=(()=>{let e=r?.[s];return e?(Array.isArray(e)||(e=[e]),e.filter(Boolean)):[]})(),{data:g,total:me,isLoading:w,error:de}=ee(D,{meta:{removeSortFilters:!0},filter:{[q]:G,...N,includes:W}});O(()=>{if(g){const t=(Array.isArray(g)?g:Object.values(g)).map((o,u)=>({...o,key:`option-${o[c]||u}`}));_(t)}},[g,c]),O(()=>{if(F)return;console.log("Initializing default values...");let e=[],t=n?[]:null;if(l===null&&r){if(r[p]&&Array.isArray(r[p]))e=r[p],t=r[p].map(o=>o[c]);else if(r[s]){const o=Array.isArray(r[s])?r[s]:[r[s]];t=n?o:o[0]}}else l!=null&&(Array.isArray(l)?(e=l,t=l.map(o=>typeof o=="object"?o[c]:o)):(e=[l],t=typeof l=="object"?l[c]:l));console.log("Initial values:",{initialSelectedOptions:e,initialFormValue:t}),x(e),C(s,t),V(!0)},[r,l,F,s,p,c,n]),O(()=>{if(y.length>0&&b.length===0&&h){const t=(Array.isArray(h)?h:[h]).map(o=>y.find(u=>u[c]===o)).filter(Boolean);t.length>0&&(console.log("Setting selected options from parsed options:",t),x(t))}},[y,b,h,c]);const J=(e,t=500)=>{clearTimeout(Q),U(setTimeout(()=>{e()},t))},X=e=>{console.log("Updating field value:",e),x(e||[]);const t=(e||[]).map(u=>u[c]),o=n?t:t[0]||null;console.log("Saving to form:",{attribute:s,value:o}),C(s,o)};return F?i(v,{children:i(Y,{multiple:n,loading:w,fullWidth:!0,freeSolo:!1,options:y,open:z,onOpen:()=>k(!0),onClose:()=>k(!1),value:n?b:b[0]||null,isOptionEqualToValue:$,autoHighlight:!0,getOptionLabel:e=>e&&S(R(e,"optionlabel"),"optionlabel")||"",renderOption:(e,t)=>{const{key:o,...u}=e;return i(T,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...u,children:S(R(t,"option"),"option")},t.key||`option-${t[c]}`)},renderTags:(e,t)=>e.map((o,u)=>i(B,{label:S(R(o,"chip"),"chip"),...t({index:u})},`chip-${o[c]||u}`)),onChange:(e,t)=>{X(n?t:t?[t]:[])},renderInput:e=>i(M,{...e,label:P,variant:"outlined",onChange:t=>{const o=t.target.value;o&&o!==""&&o.length>=A&&J(()=>H(o),I)},InputProps:{...e.InputProps,autoComplete:"new-password",endAdornment:se(v,{children:[w&&i(Z,{color:"inherit",size:20}),e.InputProps.endAdornment]})}})},`autocomplete-${s}`)}):i(te,{})},ne=({attribute:a,resourceConfig:m})=>{const n=E(),f=Array.isArray(n[a.listAttribute||a.attribute])?n[a.listAttribute||a.attribute]:[n[a.listAttribute||a.attribute]];return i(v,{children:n&&i(T,{sx:{width:"100%"},children:f.map(A=>i(B,{label:A.name,sx:{margin:.5}},A.id))})})},re=({method:a,attribute:m,resourceConfig:n,...f})=>{switch(a){case"edit":case"create":return i(oe,{resourceConfig:n,attribute:m,method:a,...f});case"view":case"list":return i(ne,{resourceConfig:n,attribute:m,method:a,...f});default:return null}};var Oe=re;export{oe as SearchableSelectChipsControlRecordContextEdit,ne as SearchableSelectChipsControlRecordContextView,Oe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as b,jsx as o,jsxs as C}from"react/jsx-runtime";import{Autocomplete as K,Box as Q,CircularProgress as A,TextField as X}from"@mui/material";import{useEffect as G,useState as c}from"react";import{useController as H}from"react-hook-form";import{useGetList as R}from"react-admin";import{isArray as _}from"lodash";const j=function({...D}){const{isMultiple:u=!1,minSearch:V=3,timerSearch:E=500,resource:F,selectLabel:I,renderText:d,transformData:g,queryFilter:P="q",defaultValues:r=void 0,elementKeyId:v="id",isEmpty:k=!1,filter:q,isOptionEqualToValue:h=(e,t)=>t===e,renderAttribute:f=null,name:S,onChange:x,renderInputTextFieldProps:M}=D,[O,T]=c(!1),[a,m]=c(null),[y,L]=c(""),l=H({name:S,defaultValue:r||null}),w=r&&_(r)?r.map(e=>e[v]?e[v]:e):r,{data:p,isLoading:s}=R(F,{filter:{[P]:y,...q,includes:w}},{refetchOnWindowFocus:!1});G(()=>(p&&!s&&(a&&m([...a,...p.map(e=>({...e,key:"option"+e.id}))]),m(p.map(e=>({...e,key:"option"+e.id})))),()=>m([])),[p,s]);const[B,W]=c(void 0),z=(e,t=500)=>{clearTimeout(B),W(setTimeout(()=>{e()},t))},J=(()=>{let e=null;return u&&(e=[]),u&&l.field.value&&Array.isArray(l.field.value)&&(e=l.field.value),u&&l.field.value&&!Array.isArray(l.field.value)&&(e=[l.field.value]),!u&&l.field.value&&(e=l.field.value),e})();return C(b,{children:[s&&!a?o(A,{color:"inherit",size:20}):o(b,{}),a&&o(K,{multiple:u,loading:s&&O,fullWidth:!0,freeSolo:!0,options:a,open:O,onOpen:()=>T(!0),onClose:()=>T(!1),defaultValue:J,isOptionEqualToValue:h,autoHighlight:!0,getOptionLabel:e=>{const t=Array.isArray(e)?e:a&&a.find(i=>h(i,l.field.value));if(!t)return y;const n=f&&!d?t[f]:d(t);return n||y},renderOption:(e,t)=>{const{key:n,...i}=e;return o(Q,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...i,children:f&&!d?t[f]:d(t)},t.key)},onChange:(e,t)=>{let n=t;Array.isArray(t)&&(n=k?[...t,...l.field.value]:[...new Map(n.map(i=>[i.id,i])).values()]),g?l.field.onChange(g(n)):l.field.onChange(n),x&&x(n)},renderInput:e=>o(X,{...e,label:I,variant:"outlined",onChange:t=>{const n=t.target.value;n&&n!==""&&n.length>=V&&z(()=>L(n),E)},InputProps:{...e.InputProps,autoComplete:"new-password",endAdornment:C(b,{children:[s?o(A,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})},...M},e.id)},"autocomplete-"+S)]})};var re=j;export{re as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as T,jsx as r,jsxs as g}from"react/jsx-runtime";import{Autocomplete as oe,Box as re,Checkbox as se,CircularProgress as R,TextField as ae}from"@mui/material";import le,{useEffect as i,useState as o}from"react";import ie from"@mui/icons-material/CheckBoxOutlineBlank";import ce from"@mui/icons-material/CheckBox";import{useAxios as ue}from"@dashadmin/dash-axios-hook";const de=r(ie,{fontSize:"small"}),pe=r(ce,{fontSize:"small"}),F=function({...L}){const{multiple:c,freeSolo:z,minSearch:B=3,timerSearch:D=500,checkboxes:S=!1,resource:w,selectLabel:v,renderText:a,queryFilter:J="q",defaultValues:f=null,elementKeyId:u="id",isEmpty:fe=!1,filter:K,isOptionEqualToValue:X=(e,n)=>n===e,renderAttribute:l=null,name:_,onChange:x,renderInputTextFieldProps:H,selectedIds:M,useDefaultSearch:k=!1,...Q}=L,[I,O]=o(!1),[s,b]=o(null),[h,W]=o(null),[y,j]=o(null),[d,C]=o(!1),[p,G]=o(null),N=f&&Array.isArray(f)?f.map(e=>e[u]?e[u]:e):c&&p?p:f,[U,A]=o(N),[m,P]=o(null),Y=ue();i(()=>{G(M)},[]);const V=(e,n)=>{Array.isArray(e)?(P(e),n==="onChange"&&A(e.map(t=>t[u]))):(P(e),n==="onChange"&&A(e[u]))},q=async()=>{C(!0);try{const e={[J]:h,...K,includes:U},{data:n}=await Y.get(w,{params:e});j(n.data)}catch(e){console.error(e)}finally{C(!1)}};i(()=>{q()},[]),i(()=>{h&&h!==""&&!k&&q()},[h]),i(()=>(y&&!d&&(s&&b([...s,...y.map(e=>({...e,key:"option"+e.id}))]),b(y.map(e=>({...e,key:"option"+e.id})))),()=>b([])),[y,d]);const[Z,$]=o(void 0),ee=(e,n=500)=>{clearTimeout(Z),$(setTimeout(()=>{e()},n))},ne=S?(e,n,{selected:t})=>{const{key:E,...te}=e;return g("li",{...te,children:[r(se,{icon:de,checkedIcon:pe,style:{marginRight:8},checked:t}),l&&!a?n[l]:a(n)]},n.key)}:(e,n)=>{const{key:t,...E}=e;return r(re,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...E,children:l&&!a?n[l]:a(n)},n.key)};return i(()=>{if(c&&s&&p){const e=s.filter(n=>p.includes(n[u]));V(e,"selectedIds")}},[s,p,c]),i(()=>{x&&m&&x(null,m,null)},[m]),g(T,{children:[d&&!s?r(R,{color:"inherit",size:20}):r(T,{}),s&&r(oe,{multiple:c,freeSolo:z,loading:d&&I,...S&&{disableCloseOnSelect:!0},options:s,open:I,onOpen:()=>O(!0),onClose:()=>O(!1),value:m||(c?[]:null),isOptionEqualToValue:X,autoHighlight:!0,getOptionLabel:e=>l&&!a?e[l]:a?a(e):e,renderOption:ne,onChange:(e,n,t)=>{V(n,"onChange")},renderInput:e=>r(ae,{...e,label:v,variant:"outlined",onChange:n=>{if(k!==!0){const t=n.target.value;t&&t!==""&&t.length>=B&&ee(()=>W(t),D)}},InputProps:{...e.InputProps,autoComplete:"new-password",endAdornment:g(T,{children:[d?r(R,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})},...H},e.id),...Q},"autocomplete-"+_)]})},Ae=le.memo(F,()=>!0);var Pe=F;export{Ae as MemoizedSearchableSelectCheckboxes,Pe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This code was borrowed from react-admin for testing and to develop an extension, is deprecated, not being used in the app, should be deleted. probably outdated.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{memo as l}from"react";import{Datagrid as s}from"react-admin";import m from"./SortableDataGridBody";import{SortableDatagridHeader as f}from"./SortableDataGridHeader";import g from"./SortableDataGridRow";import b from"react";const D=a=>{const{children:e,onOrderUpdate:t,...d}=a,i=b.useRef(null),n=o=>{t&&t(o)},p=l(o=>r(s,{...o,header:r(f,{}),body:r(m,{onOrderUpdate:n,ref:i,row:r(g,{})})}),()=>!0);return r("div",{id:"sortable-list",children:r(p,{...d,children:e})})};var x=D;export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import*as D from"react";import{cloneElement as T,memo as k,forwardRef as v}from"react";import{TableBody as A}from"@mui/material";import{DatagridRow as F,PureDatagridRow as I}from"react-admin";import{DragDropContext as $,Droppable as q,Draggable as w}from"@hello-pangea/dnd";const H=r(F,{}),O=[],f=v(({children:d,className:_,data:s=O,expand:c,hasBulkActions:y=!1,hover:u,onToggleItem:B,resource:P,row:x=H,rowClick:C,rowStyle:i,selectedIds:l,isRowSelectable:g,onOrderUpdate:p,...E},z)=>{D.useEffect(()=>{console.log("data has been updated")},[s]);const[m,R]=D.useState(s),S=(a,e,t)=>{const o=Array.from(a),[n]=o.splice(e,1);return o.splice(t,0,n),o},h=(a,e)=>({border:a?"1px dashed #ccc":"none",...e});return r($,{onDragEnd:a=>{if(!a.destination)return;const e=S(m,a.source.index,a.destination.index);R(e),p&&p(e)},children:r(q,{droppableId:"droppable",children:a=>r(A,{ref:a.innerRef,className:"datagrid-body",...E,children:m.map((e,t)=>r(w,{draggableId:"q-"+e.id,index:t,children:(o,n)=>{const N=i?i(e,t):{};return T(x,{ref:o.innerRef,...o.draggableProps,...o.dragHandleProps,expand:c,hasBulkActions:y&&!!l,hover:u,id:e.id??`row${t}`,key:e.id??`row${t}`,onToggleItem:B,record:e,resource:P,rowClick:C,selectable:!g||g(e),selected:l?.includes(e.id),style:{...N,...h(n.isDragging,o.draggableProps.style)}},d)}},e.id))})})})});f.muiName="TableBody";const b=k(d=>r(f,{row:r(I,{}),...d}),()=>!0);b.muiName="TableBody";var W=b;export{b as PureSortableDatagridBody,W as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as s,jsxs as M}from"react/jsx-runtime";import{Children as N,isValidElement as k,useCallback as u}from"react";import{useListContext as w,useResourceContext as R}from"react-admin";import{Checkbox as A,TableCell as g,TableHead as P,TableRow as E}from"@mui/material";import c from"clsx";import{DatagridClasses as t,DatagridHeader as I,DatagridHeaderCell as L,useDatagridContext as B,useTranslate as _}from"react-admin";import F from"@mui/icons-material/Menu";const W=n=>{const{children:h,className:C,hasExpand:O=!1,hasSort:b=!0,hasBulkActions:S=!1,isRowSelectable:l}=n,f=R(n),x=_(),{sort:r,data:d,onSelect:p,selectedIds:o,setSort:i}=w(n),{expandSingle:V}=B(),y=u(e=>{e.stopPropagation();const a=e.currentTarget.dataset.field,T=r.field===a?r.order&&r.order.toLocaleLowerCase()==="asc"?"ASC":"DESC":e.currentTarget.dataset.order;i({field:a,order:T})},[r.field,r.order,i]),D=i?y:null,H=u(e=>p(e.target.checked?o.concat(d.filter(a=>!o.includes(a.id)).filter(a=>l?l(a):!0).map(a=>a.id)):[]),[d,p,l,o]),m=Array.isArray(d)?l?d.filter(e=>l(e)).map(e=>e.id):d.map(e=>e.id):[];return s(P,{className:c(C,t.thead),children:M(E,{className:c(t.row,t.headerRow),children:[b&&s(g,{padding:"none",className:c(t.headerCell,t.expandHeader),children:s(F,{sx:{cursor:"pointer"},className:"handle"})}),S&&o&&s(g,{padding:"checkbox",className:t.headerCell,children:s(A,{"aria-label":x("ra.action.select_all",{_:"Select all"}),className:"select-all",color:"primary",checked:o.length>0&&m.length>0&&m.every(e=>o.includes(e)),onChange:H})}),N.map(h,(e,a)=>k(e)?s(L,{className:c(t.headerCell,`column-${e.props.source}`),sort:r,field:e,isSorting:r.field===(e.props.sortBy||e.props.source),resource:f,updateSort:D},e.props.source||a):null)]})})};I.displayName="DatagridHeader";export{W as SortableDatagridHeader};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as n,jsxs as _}from"react/jsx-runtime";import y,{isValidElement as M,cloneElement as O,createElement as V,useState as z,useEffect as G,useCallback as E,memo as H}from"react";import{isElement as J}from"react-is";import N from"clsx";import{TableCell as b,TableRow as $,Checkbox as K}from"@mui/material";import{RecordContextProvider as L,shallowEqual as Q,useExpanded as U,useResourceContext as X,useTranslate as Y,useCreatePath as Z,useRecordContext as j}from"react-admin";import{useNavigate as ee}from"react-router-dom";import{DatagridCell as ae,DatagridClasses as t,DatagridRow as oe,ExpandRowButton as te,useDatagridContext as ne}from"react-admin";import re from"@mui/icons-material/Menu";const v=(r,u,l)=>r?1+(l?1:0)+y.Children.toArray(u).filter(g=>!!g).length:0,le=y.forwardRef((r,u)=>{const{children:l,className:g,expand:s,hasBulkActions:m=!1,hover:P=!0,id:a,onToggleItem:T,record:de,rowClick:i,selected:I=!1,style:q,selectable:x=!0,...A}=r,C=ne(),B=Y(),c=j(r),p=(!C||!C.isRowExpandable||C.isRowExpandable(c))&&s,d=X(r),D=Z(),[h,S]=U(d,a,C&&C.expandSingle),[f,F]=z(()=>v(p,l,m));G(()=>{const e=v(p,l,m);e!==f&&F(e)},[p,f,l,m]);const w=ee(),R=E(e=>{S(),e.stopPropagation()},[S]),k=E(e=>{x&&(T(a,e),e.stopPropagation())},[a,T,x]),W=E(async e=>{e.persist();const o=typeof i=="function"?await i(a,d,c):i;if(!(o===!1||o===null)){if(["edit","show"].includes(o)){w(D({resource:d,id:a,type:o}));return}if(o==="expand"){R(e);return}if(o==="toggleSelection"){k(e);return}w(o)}},[i,a,d,c,w,D,R,k]);return _(L,{value:c,children:[_($,{ref:u,className:N(g,{[t.expandable]:p,[t.selectable]:x,[t.clickableRow]:typeof i=="function"?!0:i}),style:q,hover:P,onClick:W,...A,children:[n(b,{children:n(re,{sx:{cursor:"pointer"},className:"handle"})},"drag"),s&&n(b,{padding:"none",className:t.expandIconCell,children:p&&n(te,{className:N(t.expandIcon,{[t.expanded]:h}),expanded:h,onClick:R,expandContentId:`${a}-expand`})}),m&&n(b,{padding:"checkbox",children:n(K,{"aria-label":B("ra.action.select_row",{_:"Select this row"}),color:"primary",className:`select-item ${t.checkbox}`,checked:x&&I,onClick:k,disabled:!x})}),y.Children.map(l,(e,o)=>M(e)?n(ae,{className:N(`column-${e.props.source}`,t.rowCell),record:c,field:e,resource:d},`${a}-${e.props.source||o}`):null)]},a),p&&h&&n($,{id:`${a}-expand`,className:t.expandedPanel,children:n(b,{colSpan:f,children:J(s)?O(s,{record:c,resource:d,id:String(a)}):V(s,{record:c,resource:d,id:String(a)})})},`${a}-expand`)]})}),se=(r,u)=>{const{children:l,expand:g,...s}=r,{children:m,expand:P,...a}=u;return Q(s,a)},ce=H(oe,se);ce.displayName="PureDatagridRow";var we=le;export{ce as PureDatagridRow,we as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{IconButton as m}from"@mui/material";import{useState as s}from"react";import{Upload as g}from"@mui/icons-material";const p=n=>{const{classNamePrefix:a="default",currentUrl:l="single-image-uploader",onChange:i}=n,[t,c]=s(null);return r("div",{className:`single-image-uploader ${a}-img`,children:[t||l?e("img",{src:t||l,alt:""}):e("div",{className:`${a}-icon`}),r(m,{"aria-label":"upload image",component:"label",className:`${a}-edit`,children:[e(g,{style:{opacity:"0.6"}}),e("input",{hidden:!0,accept:"image/*",type:"file",onChange:o=>{c(URL.createObjectURL(o.target.files[0])),i&&i(o.target.files[0])}})]})]})};var C=p;export{C as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as I}from"react/jsx-runtime";import{RadioGroup as f,ListItem as m,ListItemText as p,Button as n,List as h}from"@mui/material";import{useState as C,useEffect as P}from"react";const k=u=>{const{onChange:o,defaultCopyMethod:c,dialog:t,sendPackage:a,resetExtraPayloadFlagsAfterSubmit:l,getValues:d,setValue:y}=u,[r,g]=C();P(()=>{o&&o(r)},[r]);const s=i=>{y("copy_method",i),g(i)};return e(f,{"aria-labelledby":"copy-method-selection-label",defaultValue:c,name:"copy-method-selection",children:I(h,{children:[e(m,{children:e(p,{primary:e(n,{onClick:()=>{s(1),a(d()),l(),t(null)},children:"Ingresar Nuevamente"})})},"copy_method_1"),e(m,{children:e(p,{primary:e(n,{onClick:()=>{s(2),a(d()),l(),t(null)},children:"Duplicado"})})},"copy_method_2")]})})};var G=k;export{G as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as I}from"react/jsx-runtime";import{RadioGroup as c,ListItem as d,ListItemText as g,Radio as u,List as p}from"@mui/material";import{useState as k}from"react";const m=o=>{const{packages:i,onChange:t}=o,[n,r]=k(null),s=a=>{r(a.target.value),t&&t(a.target.value)};return e(c,{"aria-labelledby":"package-selection-label",name:"package-selection",children:e(p,{children:i.map((a,l)=>I(d,{children:[e(u,{checked:n===a.id.toString(),onChange:s,value:a.id,name:"package-selection",inputProps:{"aria-label":a.id.toString()}}),e(g,{primary:a.id,secondary:`Internal Id: ${a.internal_id}, Direcci\xF3n: ${a.delivery_address}`})]},l))})})};var P=m;export{P as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";const e=()=>i("span",{children:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam ante est, hendrerit quis bibendum eget, sodales vitae libero. Mauris a dolor vel neque euismod tempor."});var o=e;export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as o,jsx as e,jsxs as r}from"react/jsx-runtime";const t=()=>r(o,{children:[e("p",{children:e("strong",{children:"Paquete ingresado correctamente"})}),r("p",{children:["Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pharetra libero vitae cursus gravida,"," "]})]});var a=t;export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as t,jsx as r,jsxs as e}from"react/jsx-runtime";const o=()=>e(t,{children:[r("p",{children:r("strong",{children:"El paquete no pudo ser ingresado"})}),e("p",{children:["Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pharetra libero vitae cursus gravida,"," "]})]});var a=o;export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as r,jsx as e,jsxs as o}from"react/jsx-runtime";const a=()=>o(r,{children:[e("p",{children:e("strong",{children:"Despachos realizados"})}),o("p",{children:["Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean pharetra libero vitae cursus gravida,"," "]})]});var s=a;export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as n,jsx as t,jsxs as s}from"react/jsx-runtime";import o from"@mui/material/Button";const r=()=>s(n,{children:[t("p",{children:t("strong",{children:"Paquete egresado"})}),t("p",{children:t("strong",{style:{color:"#9A65E0"},children:"Fecha y hora: 12/02/2023 12:23:43"})}),t("p",{children:t("strong",{style:{color:"#9A65E0"},children:"Estado: En dep\xF3sito"})}),t("br",{}),t(o,{className:"btn-width-lg",children:"Egresar nuevamente"}),t("br",{}),t("br",{}),t(o,{className:"btn-width-lg",children:"Duplicado"}),t("br",{}),t("br",{}),t(o,{className:"btn-width-lg",children:"Cerrar"})]});var a=r;export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as r,jsx as o,jsxs as s}from"react/jsx-runtime";import{Button as t}from"@mui/material";const n=()=>s(r,{children:[o("p",{children:o("strong",{children:"Lo sentimos"})}),o("p",{children:"No se ha encontrado lo solicitado"}),o("br",{}),o(t,{className:"btn-width-md",children:"Aceptar"})]});var p=n;export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as T,jsx as o,jsxs as b}from"react/jsx-runtime";import{useEffect as h,useState as g}from"react";import S from"@mui/material/Button";import{useNavigate as k}from"react-router-dom";import*as c from"react";import q from"@dashadmin/dash-modal";import{TextField as v}from"@mui/material";import x from"../../hooks/useQuickSearch";import B from"../../utils/setNativeValue";const y=u=>{const{searchUrl:l="/admin/package"}=u,f=k(),[a,m]=g({q:""}),[t,r]=c.useState(!1),{sendQuickSearchEvent:p}=x(),i=c.useRef(null),n=e=>{if(e==null){r(!0);return}r(!t)},s=()=>{n(!1),f({pathname:l}),setTimeout(()=>{p(a.q),B(document.getElementById("quickSearch"),a.q)},2e3)};return h(()=>{t===!0&&setTimeout(()=>{i.current?.focus()},10)},[t]),b(T,{children:[o(S,{className:"dash-header-actions-btn",onClick:()=>n(!0),children:"B\xFAsqueda r\xE1pida"}),o(q,{onCancel:()=>{n(!1)},onConfirm:()=>s(),title:"B\xFAsqueda r\xE1pida",variant:"info",open:t,confirmText:"Buscar",children:o("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch",textAlign:"left"},children:o(v,{inputRef:i,autoFocus:!0,variant:"outlined",placeholder:"Buscar por nombre, apellido, ID dash",label:"Buscar",onChange:({target:{value:e}})=>m(d=>({...d,q:e})),onKeyDown:e=>{e.key==="Enter"&&s()}})})})]})};var A=y;export{A as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as ut,jsx as o,jsxs as d}from"react/jsx-runtime";import{useState as w,useCallback as x,useEffect as X}from"react";import{Button as z,Badge as j,Menu as G,MenuItem as E,Typography as b,Divider as q,Box as y,IconButton as M,Chip as B,Snackbar as J,Alert as K,Stack as Q,Paper as V,Portal as _}from"@mui/material";import{NotificationsNone as tt,NotificationsActive as H,Close as L,Clear as ot,Person as et,Store as it,DragIndicator as nt}from"@mui/icons-material";const R={maxNotifications:50,toastAutoHideDuration:8e3,baseZIndex:1e5,menuMaxHeight:480,menuWidth:360,labels:{title:"Notifications",markAll:"Mark all",noNotifications:"No notifications",close:"Close",acknowledge:"Got it",customer:"Customer:",store:"Store:",received:"Received:",now:"Now",minutesAgo:"m",hoursAgo:"h",daysAgo:"d"},icons:{}},$=(t,i)=>{const l=new Date,e=new Date(t),n=Math.floor((l.getTime()-e.getTime())/(1e3*60)),m={...R.labels,...i};return n<1?m.now||"Now":n<60?`${n}${m.minutesAgo}`:n<1440?`${Math.floor(n/60)}${m.hoursAgo}`:`${Math.floor(n/1440)}${m.daysAgo}`},at=()=>`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,st=(t={})=>{const i={...R,...t},[l,e]=w([]),[n,m]=w([]),[v,f]=w([]),u=l.filter(a=>!a.isRead).length,s=x((a,r={})=>{const{showDialog:c=!0,showToast:N=!0,toastSeverity:Z="warning"}=r,D={...a,id:at(),timestamp:new Date().toISOString(),isRead:!1};if(e(I=>[D,...I.slice(0,i.maxNotifications-1)]),c&&f(I=>{const T=I.length,O=20,W=typeof window<"u"?window.innerHeight-250:600,Y=T*-220,U={...D,position:{x:O,y:W+Y},zIndex:i.baseZIndex+T+1};return[...I,U]}),N){const I=`toast-${D.id}`;m(T=>[...T,{id:I,title:D.title,message:`${D.customer||""} ${D.store?`- ${D.store}`:""}`.trim(),severity:Z}])}},[i.maxNotifications,i.baseZIndex]),p=x(a=>{e(r=>r.map(c=>c.id===a?{...c,isRead:!0}:c))},[]),k=x(()=>{e(a=>a.map(r=>({...r,isRead:!0})))},[]),h=x(a=>{e(r=>r.filter(c=>c.id!==a))},[]),C=x(()=>{e([])},[]),A=x(a=>{m(r=>r.filter(c=>c.id!==a))},[]),g=x(a=>{f(r=>r.filter(c=>c.id!==a)),p(a)},[p]),P=x(a=>{p(a),f(r=>r.filter(c=>c.id!==a))},[p]),S=x(a=>{f(r=>{const c=Math.max(...r.map(N=>N.zIndex),i.baseZIndex);return r.map(N=>N.id===a?{...N,zIndex:c+1}:N)})},[i.baseZIndex]),F=x((a,r)=>{f(c=>c.map(N=>N.id===a?{...N,position:r}:N))},[]);return{notifications:l,toastNotifications:n,dialogNotifications:v,unreadCount:u,addNotification:s,markAsRead:p,markAllAsRead:k,removeNotification:h,clearAllNotifications:C,closeToast:A,closeDialog:g,acknowledgeDialog:P,bringDialogToFront:S,updateDialogPosition:F}},rt=({unreadCount:t,onClick:i,icons:l})=>o(M,{onClick:i,"aria-label":"notifications",color:"inherit",children:o(j,{badgeContent:t,color:"error",max:99,children:t>0?l?.active||o(H,{}):l?.empty||o(tt,{})})}),lt=({notification:t,onMarkAsRead:i,onRemove:l,formatTimeAgo:e})=>o(E,{onClick:()=>i(t.id),sx:{backgroundColor:t.isRead?"transparent":"action.hover",borderLeft:t.isRead?"none":"4px solid #ff9800",whiteSpace:"normal",alignItems:"flex-start",py:1.5},children:d(y,{sx:{width:"100%"},children:[d(y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:.5},children:[o(b,{variant:"subtitle2",sx:{fontWeight:t.isRead?"normal":"bold"},children:t.title}),d(y,{sx:{display:"flex",alignItems:"center",gap:.5},children:[o(b,{variant:"caption",color:"text.secondary",children:e(t.timestamp)}),o(M,{size:"small",onClick:n=>{n.stopPropagation(),l(t.id)},children:o(L,{fontSize:"small"})})]})]}),o(b,{variant:"body2",color:"text.secondary",sx:{mb:1},children:t.message}),d(y,{sx:{display:"flex",gap:.5,flexWrap:"wrap"},children:[t.customer&&o(B,{label:t.customer,size:"small",variant:"outlined",color:"primary"}),t.store&&o(B,{label:t.store,size:"small",variant:"outlined",color:"secondary"})]})]})}),ct=({anchorEl:t,notifications:i,onClose:l,onMarkAsRead:e,onMarkAllAsRead:n,onRemove:m,onClearAll:v,config:f={}})=>{const u={...R,...f},s={...R.labels,...f.labels},p=!!t,k=i.filter(h=>!h.isRead).length;return d(G,{anchorEl:t,open:p,onClose:l,PaperProps:{style:{maxHeight:u.menuMaxHeight,width:u.menuWidth}},transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[d(y,{sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o(b,{variant:"h6",children:s.title}),i.length>0&&d(y,{children:[k>0&&o(z,{size:"small",onClick:n,sx:{mr:1},children:s.markAll}),o(M,{size:"small",onClick:v,children:o(ot,{fontSize:"small"})})]})]}),o(q,{}),i.length===0?o(E,{disabled:!0,children:o(b,{color:"text.secondary",children:s.noNotifications})}):i.map(h=>o(lt,{notification:h,onMarkAsRead:e,onRemove:m,formatTimeAgo:C=>$(C,s)},h.id))]})},dt=({toasts:t,onClose:i,autoHideDuration:l=8e3,baseZIndex:e=1e5})=>o(Q,{spacing:1,sx:{position:"fixed",top:16,right:16,zIndex:e,maxWidth:400},children:t.map(n=>o(J,{open:!0,autoHideDuration:l,onClose:()=>i(n.id),anchorOrigin:{vertical:"top",horizontal:"right"},sx:{position:"relative",zIndex:e},children:d(K,{onClose:()=>i(n.id),severity:n.severity,variant:"filled",sx:{width:"100%"},children:[o(b,{variant:"subtitle2",children:n.title}),o(b,{variant:"body2",children:n.message})]})},n.id))}),gt=({notification:t,onClose:i,onAcknowledge:l,onFocus:e,onPositionChange:n,config:m={}})=>{const v={...R.labels,...m.labels},f={...R.icons,...m.icons},[u,s]=w(!1),[p,k]=w({x:0,y:0}),h=x(g=>{g.target.closest(".drag-handle")&&(g.preventDefault(),e(),s(!0),k({x:g.clientX-t.position.x,y:g.clientY-t.position.y}))},[e,t.position]),C=x(g=>{if(u){g.preventDefault();const P=Math.max(0,Math.min(window.innerWidth-400,g.clientX-p.x)),S=Math.max(0,Math.min(window.innerHeight-200,g.clientY-p.y));n({x:P,y:S})}},[u,p,n]),A=x(()=>{u&&s(!1)},[u]);return X(()=>{if(u)return document.addEventListener("mousemove",C),document.addEventListener("mouseup",A),document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",A),document.body.style.userSelect=""}},[u,C,A]),o(_,{children:o("div",{style:{position:"fixed",left:t.position.x,top:t.position.y,zIndex:t.zIndex,pointerEvents:"auto"},onMouseDown:h,children:d(V,{elevation:8,sx:{width:400,borderRadius:2,overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.24)",cursor:u?"grabbing":"default","&:hover":{boxShadow:"0 12px 40px rgba(0,0,0,0.3)"}},children:[d(y,{className:"drag-handle",sx:{backgroundColor:"warning.main",color:"warning.contrastText",p:2,display:"flex",alignItems:"center",gap:1,cursor:u?"grabbing":"grab",userSelect:"none"},children:[o(nt,{sx:{mr:1}}),o(H,{}),o(b,{variant:"h6",sx:{flexGrow:1,fontSize:"1rem"},children:t.title}),o(M,{size:"small",onClick:g=>{g.stopPropagation(),i()},sx:{color:"warning.contrastText"},children:o(L,{fontSize:"small"})})]}),d(y,{sx:{p:2},children:[o(b,{variant:"body1",sx:{mb:2},children:t.message}),d(y,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:[t.customer&&d(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[f.customer||o(et,{color:"primary"}),o(b,{variant:"body2",color:"text.secondary",children:v.customer}),o(B,{label:t.customer,size:"small",color:"primary",variant:"outlined"})]}),t.store&&d(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[f.store||o(it,{color:"secondary"}),o(b,{variant:"body2",color:"text.secondary",children:v.store}),o(B,{label:t.store,size:"small",color:"secondary",variant:"outlined"})]}),o(y,{sx:{display:"flex",alignItems:"center",gap:1,mt:1},children:d(b,{variant:"caption",color:"text.secondary",children:[v.received," ",$(t.timestamp,v)]})})]})]}),d(y,{sx:{p:2,pt:0,display:"flex",gap:1,justifyContent:"flex-end"},children:[o(z,{onClick:g=>{g.stopPropagation(),i()},color:"inherit",variant:"outlined",size:"small",children:v.close}),o(z,{onClick:g=>{g.stopPropagation(),l()},color:"primary",variant:"contained",size:"small",children:v.acknowledge})]})]})})})},mt=({config:t={},notificationsHook:i})=>{const l=st(t),e=i||l,[n,m]=w(null),v=s=>{m(s.currentTarget)},f=()=>{m(null)},u=()=>{e.clearAllNotifications(),f()};return d(ut,{children:[o(rt,{unreadCount:e.unreadCount,onClick:v,icons:t.icons}),o(ct,{anchorEl:n,notifications:e.notifications,onClose:f,onMarkAsRead:e.markAsRead,onMarkAllAsRead:e.markAllAsRead,onRemove:e.removeNotification,onClearAll:u,config:t}),e.dialogNotifications.map(s=>o(gt,{notification:s,onClose:()=>e.closeDialog(s.id),onAcknowledge:()=>e.acknowledgeDialog(s.id),onFocus:()=>e.bringDialogToFront(s.id),onPositionChange:p=>e.updateDialogPosition(s.id,p),config:t},s.id)),o(dt,{toasts:e.toastNotifications,onClose:e.closeToast,autoHideDuration:t.toastAutoHideDuration,baseZIndex:t.baseZIndex})]})};var vt=mt;export{gt as DraggableNotificationDialog,rt as NotificationButton,lt as NotificationMenuItem,mt as NotificationsCenter,ct as NotificationsMenu,dt as ToastNotificationsStack,vt as default,$ as formatTimeAgo,at as generateNotificationId,st as useNotificationsCenter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{NotificationsCenter as o,NotificationButton as e,NotificationsMenu as a,NotificationMenuItem as n,ToastNotificationsStack as f,DraggableNotificationDialog as c,useNotificationsCenter as s,formatTimeAgo as r,generateNotificationId as p}from"./NotificationsCenter";import{default as y}from"./NotificationsCenter";export{c as DraggableNotificationDialog,e as NotificationButton,n as NotificationMenuItem,o as NotificationsCenter,a as NotificationsMenu,f as ToastNotificationsStack,y as default,r as formatTimeAgo,p as generateNotificationId,s as useNotificationsCenter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{Pagination as i}from"react-admin";const n=a=>o("div",{className:"dash-pagination-component",children:o(i,{rowsPerPageOptions:[10,25,50,100,250,500,1e3],...a})});var f=n;export{f as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";const o=({message:t="Loading..."})=>r("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",minHeight:"100vh",gap:"16px",background:"linear-gradient(to bottom, var(--bodybg-primary), var(--bodybg-secondary))",color:"var(--text-color, @text-color--dark)"},children:[e("div",{style:{width:"60px",height:"60px",border:"4px solid rgba(255, 255, 255, 0.3)",borderTop:"4px solid #ffffff",borderRadius:"50%",animation:"spin 1s linear infinite"}}),e("h6",{style:{margin:0,fontSize:"1.25rem",fontWeight:500},children:t}),e("style",{children:`
|
|
2
|
+
@keyframes spin {
|
|
3
|
+
0% { transform: rotate(0deg); }
|
|
4
|
+
100% { transform: rotate(360deg); }
|
|
5
|
+
}
|
|
6
|
+
`})]});var n=o;export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o,jsxs as n}from"react/jsx-runtime";import t from"react";class a extends t.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,e){console.error("Error:",r,e)}render(){return this.state.hasError?n("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"#121212",color:"#ffffff",flexDirection:"column",gap:"20px"},children:[o("h2",{children:"Error"}),o("p",{children:this.state.error?.message}),o("button",{onClick:()=>window.location.reload(),style:{padding:"10px 20px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Reload Page"})]}):this.props.children}}var i=a;export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";const o=()=>t("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",background:"linear-gradient(to bottom, var(--bodybg-primary), var(--bodybg-secondary))",color:"var(--text-color, @text-color--dark)"},children:t("div",{children:"Loading..."})});var a=o;export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o,jsxs as i}from"react/jsx-runtime";import*as a from"react";import{Button as w}from"@mui/material";import B from"@mui/icons-material/ErrorOutline";import{useNavigate as N}from"react-router";function x(){window.history.go(-1)}const y=({staticContext:r,history:d,location:t,match:e,...n})=>n,S=r=>{const{title:d,time:t=!1,redirect:e=null,disableCountdown:n=!1,disableGoBack:l=!1,customMessage:m,customButtonText:f,...p}=r,[g,h]=a.useState(t||0),c=N();a.useEffect(()=>{if(!n&&typeof t=="number"&&t>0){const v=setInterval(()=>{h(u=>{if(u<=1){const b=window.location.pathname;return c(`${e||"/"}?redirect=${encodeURIComponent(b)}`),0}return u-1})},1e3);return()=>clearInterval(v)}},[t,c,e,n]),a.useEffect(()=>{});const C=!n&&t&&t>0,s=l?null:{text:f||"Aceptar",action:x};return o("div",{className:"dash-app-module not-found",...y(p),children:i("div",{className:"dash-app-notfound",children:[o("div",{className:"dash-app-notfound-img",children:o(B,{sx:{fontSize:300}})}),i("div",{className:"dash-app-notfound-content",children:[o("h1",{children:"Oops!"}),o("span",{children:m||"No encontramos este enlace."}),C&&i("p",{style:{fontSize:"0.9em",color:"#666"},children:["Ser\xE1s redirigido en ",g," segundos..."]}),s&&o(w,{color:"primary",onClick:s.action,children:s.text})]})]})})};var I=S;export{I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t,jsxs as i}from"react/jsx-runtime";import*as o from"react";import{Card as c,CardContent as p,Typography as a}from"@mui/material";import f from"@mui/icons-material/Info";const s=o.memo(d=>{const{title:r,description:n,children:l}=d,e=o.useMemo(()=>({card:{p:0},cardContent:{display:"flex",flexDirection:"column",alignItems:"left",gap:2},header:{display:"flex",alignItems:"center",gap:2},icon:{fontSize:32}}),[]);return o.useEffect(()=>{console.log("Reloaded")},[]),t(c,{sx:e.card,children:i(p,{sx:e.cardContent,children:[i("div",{style:e.header,children:[t(f,{sx:e.icon}),r&&t(a,{variant:"h5",children:r})]}),n&&t(a,{variant:"body1",color:"text.secondary",children:n}),l]})})});s.displayName="NoResults";var g=s;export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useDraggable as g}from"@dashadmin/dash-utils";export{g as useDraggable};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useNotifications as o}from"@dashadmin/dash-utils";import{useNotifications as s}from"@dashadmin/dash-utils";export{s as default,o as useNotifications};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useQuickSearch as u}from"@dashadmin/dash-utils";import{useQuickSearch as a}from"@dashadmin/dash-utils";export{a as default,u as useQuickSearch};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l=(t,u)=>{if(!t)return;let e=t.value;t.value=u;let r=new Event("input",{target:t,bubbles:!0}),a=t._valueTracker;a&&a.setValue(e),t.dispatchEvent(r)};var v=l;export{v as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashadmin/dash-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"lint:fix": "pnpm prettier --write .",
|
|
12
12
|
"check-updates": "pnpm npm-check-updates",
|
|
13
13
|
"updates-packages": "pnpm npm-check-updates -u",
|
|
14
|
-
"build": "vite build"
|
|
14
|
+
"build": "rm -rf dist && node ../dash-build/compile.mjs && vite build"
|
|
15
15
|
},
|
|
16
16
|
"browserslist": {
|
|
17
17
|
"production": [
|
|
@@ -122,10 +122,21 @@
|
|
|
122
122
|
"exports": {
|
|
123
123
|
".": {
|
|
124
124
|
"import": "./dist/index.js"
|
|
125
|
+
},
|
|
126
|
+
"./src/*": {
|
|
127
|
+
"import": "./dist/*.js"
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
},
|
|
128
131
|
"files": [
|
|
129
132
|
"dist"
|
|
130
|
-
]
|
|
133
|
+
],
|
|
134
|
+
"exports": {
|
|
135
|
+
".": {
|
|
136
|
+
"import": "./src/index.tsx"
|
|
137
|
+
},
|
|
138
|
+
"./src/*": {
|
|
139
|
+
"import": "./src/*"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
131
142
|
}
|