@dashadmin/dash-components 1.3.17 → 1.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/components/AuditLog/AuditLog.js +1 -0
  2. package/dist/components/AuditLog/index.js +1 -0
  3. package/dist/components/AutoCompleteArrayInput/AutoCompleteCheckBoxInput.js +3 -0
  4. package/dist/components/AutoCompleteArrayInput/AutocompleteCheckBoxArrayInput.js +1 -0
  5. package/dist/components/AutoCompleteArrayInputAutoSearch/AutoCompleteCheckBoxInput.js +3 -0
  6. package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayAutoSearch.tsx.wip +42 -0
  7. package/dist/components/AutoCompleteArrayInputAutoSearch/AutocompleteCheckBoxArrayInput.js +1 -0
  8. package/dist/components/Json/Json.js +1 -0
  9. package/dist/components/JsonColorSelector/JsonColorSelector.js +1 -0
  10. package/dist/components/JsonColorSelector/JsonColorSelector.tsx.bkup +746 -0
  11. package/dist/components/JsonColorSelector/JsonColorSelectorEnhanced.js +2 -0
  12. package/dist/components/JsonColorSelector/JsonCssVarValues.js +1 -0
  13. package/dist/components/JsonColorSelector/components/ColorEditDialog.js +1 -0
  14. package/dist/components/JsonColorSelector/components/ColorPaletteItem.js +1 -0
  15. package/dist/components/JsonColorSelector/components/ImageColorExtractor.js +1 -0
  16. package/dist/components/JsonColorSelector/helpers/functions.js +1 -0
  17. package/dist/components/JsonColorSelector/interfaces/interfaces.js +0 -0
  18. package/dist/components/JsonColorSelector/useAsyncColorThief.js +1 -0
  19. package/dist/components/ListActive/ListActive.js +1 -0
  20. package/dist/components/ListActive/ListBoolean.js +1 -0
  21. package/dist/components/NotificationPreferences/NotificationPreferences.js +1 -0
  22. package/dist/components/NotificationPreferences/index.js +1 -0
  23. package/dist/components/SearchableSelects/RASearchableSelect.js +1 -0
  24. package/dist/components/SearchableSelects/RASearchableSelectCheckboxes.js +1 -0
  25. package/dist/components/SearchableSelects/RASearchableSelectChips.js +1 -0
  26. package/dist/components/SearchableSelects/RASearchableSelectChipsRecordContext.js +1 -0
  27. package/dist/components/SearchableSelects/SearchableSelect.js +1 -0
  28. package/dist/components/SearchableSelects/SearchableSelectCheckboxes.js +1 -0
  29. package/dist/components/SortableDataGrid/README.md +1 -0
  30. package/dist/components/SortableDataGrid/SortableDataGrid.js +1 -0
  31. package/dist/components/SortableDataGrid/SortableDataGridBody.js +1 -0
  32. package/dist/components/SortableDataGrid/SortableDataGridHeader.js +1 -0
  33. package/dist/components/SortableDataGrid/SortableDataGridRow.js +1 -0
  34. package/dist/components/Upload/SingleImageUploader.js +1 -0
  35. package/dist/components/custom/PackageCopyMethod.js +1 -0
  36. package/dist/components/custom/PackageRadioButtonGroup.js +1 -0
  37. package/dist/components/dialog/Basic.js +1 -0
  38. package/dist/components/dialog/Correct.js +1 -0
  39. package/dist/components/dialog/Error.js +1 -0
  40. package/dist/components/dialog/Info.js +1 -0
  41. package/dist/components/dialog/InfoV2.js +1 -0
  42. package/dist/components/dialog/NotFound.js +1 -0
  43. package/dist/components/dialog/QuickSearch.js +1 -0
  44. package/dist/components/notifications/NotificationsCenter.js +1 -0
  45. package/dist/components/notifications/index.js +1 -0
  46. package/dist/components/tables/PaginationComponent.js +1 -0
  47. package/dist/components/theme/AppLoadingFallback.js +6 -0
  48. package/dist/components/theme/ErrorBoundary.js +1 -0
  49. package/dist/components/theme/InitialLoader.js +1 -0
  50. package/dist/components/theme/NotFound.js +1 -0
  51. package/dist/components/theme/NotResults.js +1 -0
  52. package/dist/hooks/useDraggable.js +1 -0
  53. package/dist/hooks/useNotifications.js +1 -0
  54. package/dist/hooks/useQuickSearch.js +1 -0
  55. package/dist/styles/index.less +0 -0
  56. package/dist/utils/setNativeValue.js +1 -0
  57. package/package.json +14 -3
@@ -0,0 +1 @@
1
+ import{Fragment as K,jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as v,useMemo as T,useCallback as w}from"react";import{useRecordContext as P,useGetList as R,Loading as _}from"react-admin";import{Box as c,Typography as a,Paper as l,Button as k,Dialog as N,DialogTitle as B,DialogContent as G,DialogActions as I,IconButton as x,Chip as M,Tooltip as z}from"@mui/material";import{DataGrid as F,GridToolbarContainer as E,GridToolbarExport as O}from"@mui/x-data-grid";import J from"@mui/icons-material/Visibility";import W from"@mui/icons-material/Close";import u from"@mui/icons-material/History";const V=()=>e(E,{children:e(O,{csvOptions:{fileName:"audit-logs-export",delimiter:",",utf8WithBom:!0},printOptions:{hideFooter:!0,hideToolbar:!0}})}),H=({open:r,log:o,onClose:n})=>{if(!o)return null;const i=d=>{try{return JSON.stringify(d,null,2)}catch{return String(d)}};return t(N,{open:r,onClose:n,maxWidth:"md",fullWidth:!0,"aria-labelledby":"audit-log-dialog-title",children:[e(B,{id:"audit-log-dialog-title",children:t(c,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[t(a,{variant:"h6",children:["Audit Log Details - ",o.event||o.description]}),e(x,{edge:"end",color:"inherit",onClick:n,"aria-label":"close",children:e(W,{})})]})}),t(G,{dividers:!0,children:[t(c,{mb:2,children:[e(a,{variant:"subtitle2",color:"textSecondary",children:"Event Information"}),t(l,{variant:"outlined",sx:{p:2,mt:1},children:[t(a,{variant:"body2",children:[e("strong",{children:"ID:"})," ",o.id]}),t(a,{variant:"body2",children:[e("strong",{children:"Event:"})," ",o.event||"N/A"]}),t(a,{variant:"body2",children:[e("strong",{children:"Description:"})," ",o.description]}),t(a,{variant:"body2",children:[e("strong",{children:"Log Name:"})," ",o.log_name]}),t(a,{variant:"body2",children:[e("strong",{children:"Created At:"})," ",new Date(o.created_at).toLocaleString()]}),o.causer_name&&t(a,{variant:"body2",children:[e("strong",{children:"Changed By:"})," ",o.causer_name]})]})]}),t(c,{children:[e(a,{variant:"subtitle2",color:"textSecondary",children:"Properties (JSON)"}),e(l,{variant:"outlined",sx:{p:2,mt:1,bgcolor:"grey.900",color:"grey.100",maxHeight:400,overflow:"auto"},children:e("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:i(o.properties)})})]})]}),e(I,{children:e(k,{onClick:n,color:"primary",children:"Close"})})]})},j=(r,o)=>{const n=(r||"").toLowerCase();let i="default";switch(n){case"created":i="success";break;case"updated":i="warning";break;case"deleted":i="error";break;case"restored":i="info";break;default:i="default"}return e(M,{label:r||"N/A",color:i,size:"small",variant:"outlined"})},p=({resourceConfig:r,resource:o})=>{const n=P(),[i,d]=v({page:0,pageSize:10}),[y,m]=v({open:!1,log:null}),C=`${o||r?.model||""}/audit`,{data:g,total:A,isLoading:h,error:f}=R(C,{pagination:{page:i.page+1,perPage:i.pageSize},sort:{field:"created_at",order:"DESC"},filter:{subject_id:n?.id}},{enabled:!!n?.id,refetchOnWindowFocus:!1}),b=w(s=>{m({open:!0,log:s})},[]),D=w(()=>{m({open:!1,log:null})},[]),L=T(()=>[{field:"id",headerName:"ID",type:"number",width:80},{field:"event",headerName:"Event",width:120,renderCell:s=>j(s.value)},{field:"description",headerName:"Description",flex:1,minWidth:200},{field:"causer_name",headerName:"Changed By",width:150,valueGetter:(s,S)=>S.causer_name||"System"},{field:"created_at",headerName:"Date",width:180,valueFormatter:s=>s?new Date(s).toLocaleString():""},{field:"actions",headerName:"Actions",type:"actions",width:100,getActions:s=>[e(z,{title:"View Details",children:e(x,{size:"small",onClick:()=>b(s.row),color:"primary",children:e(J,{fontSize:"small"})})},"view")]}],[b]);return n?.id?h?e(_,{}):f?e(l,{variant:"outlined",sx:{p:2},children:t(a,{color:"error",children:["Error loading audit logs: ",f?.message||"Unknown error"]})}):!g||g.length===0?t(l,{variant:"outlined",sx:{p:3,textAlign:"center"},children:[e(u,{sx:{fontSize:48,color:"text.secondary",mb:1}}),e(a,{variant:"body1",color:"text.secondary",children:"No audit logs available for this record"})]}):t(K,{children:[e(c,{sx:{width:"100%"},children:e(l,{variant:"outlined",children:e(F,{rows:g,columns:L,rowCount:A||0,loading:h,pageSizeOptions:[5,10,25,50],paginationModel:i,paginationMode:"server",onPaginationModelChange:d,disableRowSelectionOnClick:!0,autoHeight:!0,slots:{toolbar:V},sx:{"& .MuiDataGrid-cell:focus":{outline:"none"}}})})}),e(H,{open:y.open,log:y.log,onClose:D})]}):t(l,{variant:"outlined",sx:{p:3,textAlign:"center"},children:[e(u,{sx:{fontSize:48,color:"text.secondary",mb:1}}),e(a,{variant:"body1",color:"text.secondary",children:"Save the record first to view audit logs"})]})},U=r=>e(p,{...r}),$=()=>e(a,{variant:"body2",color:"text.secondary",children:"\u2014"}),q=r=>{const{method:o}=r;switch(o){case"view":case"show":return e(p,{...r});case"edit":return e(U,{...r});case"list":return e($,{...r});case"create":return t(l,{variant:"outlined",sx:{p:3,textAlign:"center"},children:[e(u,{sx:{fontSize:48,color:"text.secondary",mb:1}}),e(a,{variant:"body1",color:"text.secondary",children:"Audit logs will be available after the record is created"})]});default:return e(p,{...r})}};var le=q;export{le as default};
@@ -0,0 +1 @@
1
+ import{default as r}from"./AuditLog";export{r as AuditLog};
@@ -0,0 +1,3 @@
1
+ import{Fragment as Lt,jsx as f,jsxs as me}from"react/jsx-runtime";import{isValidElement as V,useCallback as z,useEffect as v,useMemo as ce,useRef as de,useState as pe}from"react";import{isEqual as it,get as y,debounce as st}from"lodash";import at from"clsx";import{Autocomplete as lt,Checkbox as ut,Chip as ct,TextField as dt,Tooltip as pt,createFilterOptions as ft}from"@mui/material";import{styled as gt}from"@mui/material/styles";import{FieldTitle as mt,useChoicesContext as ht,useInput as xt,useSuggestions as yt,useTimeout as Tt,useTranslate as St,warning as Ct,useGetRecordRepresentation as bt,useEvent as Rt,sanitizeInputRestProps as Ot}from"react-admin";import{InputHelperText as It,useSupportCreateSuggestion as Ft}from"react-admin";import vt from"@mui/icons-material/CheckBoxOutlineBlank";import Pt from"@mui/icons-material/CheckBox";const Et=f(vt,{fontSize:"small"}),At=f(Pt,{fontSize:"small"}),Mt=n=>({q:n}),fe="RaAutocompleteInput",kt=ft(),ge={textField:`${fe}-textField`},qt=gt(lt,{name:fe,overridesResolver:(n,o)=>o.root})(({theme:n})=>({[`& .${ge.textField}`]:{minWidth:n.spacing(20)}}));function wt(n,o,r="..."){const a=n.lastIndexOf(" ",o);return a===-1?n:n.substring(0,a)+r}const U=(n=[],o,r="id",a)=>a?(Array.isArray(o??[])?o:[o]).map(l=>n.find(g=>String(l)===String(y(g,r)))).filter(l=>!!l):n.find(l=>String(y(l,r))===String(o))||"",zt=(n,o,r="id",a)=>{if(a){const l=n??[],g=o??[];return l.length!==g.length?!1:!l.map(u=>g.some(B=>y(B,r)===y(u,r))).some(u=>u===!1)}return y(n,r)===y(o,r)},Bt=(n,{choices:o,multiple:r,optionValue:a})=>{const l=de(U(o,n,a,r)),[g,A]=pe(()=>U(o,n,a,r));return v(()=>{const u=U(o,n,a,r);zt(l.current,u,a,r)||(l.current=u,A(u))},[o,n,r,a]),g||null},Dt=n=>{const{choices:o,className:r,blurOnSelect:a=!1,clearOnBlur:l=!1,selectOnFocus:g=!0,openOnFocus:A=!0,renderTags:u,disableCloseOnSelect:B=!0,filterSelectedOptions:he=!1,renderOption:_t=null,clearText:$="ra.action.clear_input_value",closeText:X="ra.action.close",create:M,createLabel:xe,createItemLabel:ye,createValue:Te,debounce:G=250,defaultValue:Se,emptyText:C,emptyValue:m="",field:Ce,format:be,helperText:K,id:Re,inputText:P,isFetching:Oe,isLoading:Ie,isRequired:Fe,label:ve,limitChoicesToValue:k,matchSuggestion:b,margin:Pe,fieldState:Ee,filterToQuery:Ae=Mt,formState:Me,multiple:c=!1,noOptionsText:R,onBlur:ke,onChange:qe,onCreate:q,openText:j="ra.action.open",optionText:i,optionValue:O,parse:we,resource:J,shouldRenderSuggestions:w,setFilter:D,size:ze,source:Be,suggestionLimit:L=1/0,TextFieldProps:De,translateChoice:Le,validate:_e,variant:Qe,...Y}=n,Ne=Rt(Ae),{allChoices:_,isLoading:We,error:Q,resource:Z,source:N,setFilters:ee,isFromReference:T}=ht({choices:o,isFetching:Oe,isLoading:Ie,resource:J,source:Be}),I=St(),{id:He,field:h,isRequired:W,fieldState:{error:Ve,invalid:te,isTouched:ne},formState:{isSubmitted:oe}}=xt({defaultValue:Se,id:Re,field:Ce,fieldState:Ee,formState:Me,isRequired:Fe,onBlur:ke,onChange:qe,parse:we,format:be,resource:Z,source:N,validate:_e,...Y}),d=ce(()=>C==null||W||c?_:[{[O||"id"]:m,[typeof i=="string"?i:"name"]:I(C,{_:C})}].concat(_),[_,m,C,W,c,i,O,I]),p=Bt(h.value,{choices:d,multiple:c,optionValue:O});v(()=>{if(m==null)throw new Error("emptyValue being set to null or undefined is not supported. Use parse to turn the empty string into null.")},[m]),v(()=>{if(V(i)&&C!=null)throw new Error("optionText of type React element is not supported when setting emptyText");if(V(i)&&P==null)throw new Error(`
2
+ If you provided a React element for the optionText prop, you must also provide the inputText prop (used for the text input)`);if(V(i)&&!T&&b==null)throw new Error(`
3
+ If you provided a React element for the optionText prop, you must also provide the matchSuggestion prop (used to match the user input with a choice)`)},[i,P,b,C,T]),v(()=>{Ct(w!=null&&R==null,"When providing a shouldRenderSuggestions function, we recommend you also provide the noOptionsText prop and set it to a text explaining users why no options are displayed. It supports translation keys.")},[w,R]);const Ue=bt(Z),{getChoiceText:re,getChoiceValue:E,getSuggestions:ie}=yt({choices:d,limitChoicesToValue:k,matchSuggestion:b,optionText:i??(T?Ue:void 0),optionValue:O,selectedItem:p,suggestionLimit:L,translateChoice:Le??!T}),[S,se]=pe(""),$e=e=>{let t;c?Array.isArray(e)?t=e.map(E):t=[...h.value??[],E(e)]:t=E(e)??m,h.onChange(t)},ae=z(st(e=>{if(D)return D(e);o||ee(Ne(e),[],!0)},G),[G,ee,D]),le=de(h.value);v(()=>{it(le.current,h.value)||(le.current=h.value,ae(""))},[h.value]);const{getCreateItem:Xe,handleChange:Ge,createElement:Ke,createId:ue}=Ft({create:M,createLabel:xe,createItemLabel:ye,createValue:Te,handleChange:$e,filter:S,onCreate:q,optionText:i}),x=z((e,t=!1)=>e==null?"":typeof e=="string"?e:e?.id===ue?y(e,typeof i=="string"?i:"name"):!t&&e[O||"id"]===m?y(e,typeof i=="string"?i:"name"):!t&&P!==void 0?P(e):re(e),[re,P,ue,i,O,m]);v(()=>{if(!c){const e=x(p);if(typeof e=="string")se(e);else throw new Error("When optionText returns a React element, you must also provide the inputText prop")}},[x,c,p]);const H=z(e=>{let t;return c?t=p.map(s=>x(s)):t=[x(p)],t.includes(e)},[x,c,p]),je=z(e=>{const t=d?d.some(s=>x(s)===e):!1;return H(e)||t},[d,x,H]),Je=(e,t,s)=>{(e?.type==="change"||!H(t))&&(se(t),ae(t))},Ye=(e,t)=>{let s=T||b||k?e:kt(e,t);const{inputValue:F}=t;return(q||M)&&F!==""&&!je(S)&&(s=s.concat(Xe(F))),s},Ze=(e,t,s)=>{Ge(t!==null?t:m)},et=Tt(1e3,S),tt=ce(()=>!T&&(b||k)?ie(S):d?.slice(0,L)||[],[d,S,ie,k,b,L,T]),nt=(e,t)=>String(E(e))===String(E(t)),ot=!!Q||K!==!1||(ne||oe)&&te;return me(Lt,{children:[f(qt,{className:at("ra-input",`ra-input-${N}`,r),clearText:I($,{_:$}),closeText:I(X,{_:X}),openText:I(j,{_:j}),id:He,isOptionEqualToValue:nt,blurOnSelect:a,clearOnBlur:l,selectOnFocus:g,openOnFocus:A,disableCloseOnSelect:B,filterSelectedOptions:he,renderInput:e=>f(dt,{name:h.name,label:f(mt,{label:ve,source:N,resource:J,isRequired:W}),error:!!Q||(ne||oe)&&te,helperText:ot?f(It,{error:Ve?.message||Q?.message,helperText:K}):null,margin:Pe,variant:Qe,className:ge.textField,...De,...e,size:ze}),multiple:c,renderTags:u||((e,t)=>{const s=i;return f(pt,{title:e.map(F=>F[s]).join(" , "),children:f(ct,{label:wt(e[0][s],10)+(e.length>1?" +"+(e.length-1):""),sx:{".MuiSvgIcon-root":{zIndex:100}},variant:"filled",size:"small"})})}),noOptionsText:typeof R=="string"?I(R,{_:R}):R,...Ot(Y),freeSolo:!!M||!!q,handleHomeEndKeys:!!M||!!q,filterOptions:Ye,options:w==null||w(S)?tt:[],getOptionLabel:x,inputValue:S,loading:We&&(!d||d.length===0)&&et,value:p,onChange:(e,t,s)=>{Ze(e,t,s)},onInputChange:Je,clearOnEscape:!1,renderOption:(e,t,{selected:s})=>{const F=p&&p.find(rt=>rt.id===t.id)?!0:s;return me("li",{...e,children:[f(ut,{icon:Et,checkedIcon:At,style:{marginRight:8},checked:F}),t[i]]})}}),Ke]})};var rn=Dt;export{ge as AutocompleteInputClasses,rn as default};
@@ -0,0 +1 @@
1
+ import{jsx as a}from"react/jsx-runtime";const o=({defaultValue:e,...t})=>a(AutocompleteCheckBoxInput,{...t,multiple:!0,defaultValue:e??[]});var d=o;export{d as default};
@@ -0,0 +1,3 @@
1
+ import{Fragment as Qt,jsx as g,jsxs as xe}from"react/jsx-runtime";import{isValidElement as $,useCallback as z,useEffect as F,useMemo as me,useRef as X,useState as G}from"react";import{isEqual as lt,get as C,debounce as ut}from"lodash";import ct from"clsx";import{Autocomplete as dt,Checkbox as pt,Chip as ft,TextField as gt,Tooltip as mt,createFilterOptions as ht}from"@mui/material";import{styled as yt}from"@mui/material/styles";import{FieldTitle as xt,useChoicesContext as Ct,useInput as Tt,useSuggestions as St,useTimeout as bt,useTranslate as Rt,warning as Ot,useGetRecordRepresentation as It,useEvent as vt,sanitizeInputRestProps as Ft}from"react-admin";import{InputHelperText as Pt,useSupportCreateSuggestion as At}from"react-admin";import Et from"@mui/icons-material/CheckBoxOutlineBlank";import kt from"@mui/icons-material/CheckBox";const wt=g(Et,{fontSize:"small"}),Mt=g(kt,{fontSize:"small"}),Lt=o=>({q:o}),he="RaAutocompleteInput",qt=ht(),ye={textField:`${he}-textField`},zt=yt(dt,{name:he,overridesResolver:(o,r)=>r.root})(({theme:o})=>({[`& .${ye.textField}`]:{minWidth:o.spacing(20)}})),K=(o=[],r,s="id",l)=>l?(Array.isArray(r??[])?r:[r]).map(a=>o.find(m=>String(a)===String(C(m,s)))).filter(a=>!!a):o.find(a=>String(C(a,s))===String(r))||"",Bt=(o,r,s="id",l)=>{if(l){const a=o??[],m=r??[];return a.length!==m.length?!1:!a.map(u=>m.some(B=>C(B,s)===C(u,s))).some(u=>u===!1)}return C(o,s)===C(r,s)},Dt=(o,{choices:r,multiple:s,optionValue:l})=>{const a=X(K(r,o,l,s)),[m,E]=G(()=>K(r,o,l,s));return F(()=>{const u=K(r,o,l,s);Bt(a.current,u,l,s)||(a.current=u,E(u))},[r,o,s,l]),m||null},_t=o=>{const{choices:r,className:s,blurOnSelect:l=!1,clearOnBlur:a=!1,selectOnFocus:m=!0,openOnFocus:E=!0,renderTags:u,disableCloseOnSelect:B=!0,filterSelectedOptions:Ce=!1,renderOption:Nt=null,clearText:j="ra.action.clear_input_value",closeText:J="ra.action.close",create:k,createLabel:Te,createItemLabel:Se,createValue:be,debounce:Y=250,defaultValue:Re,emptyText:b,emptyValue:h="",field:Oe,format:Ie,helperText:Z,id:ve,inputText:P,isFetching:Fe,isLoading:Pe,isRequired:Ae,label:Ee,limitChoicesToValue:w,matchSuggestion:R,margin:ke,fieldState:we,filterToQuery:Me=Lt,formState:Le,multiple:d=!1,noOptionsText:O,onBlur:qe,onChange:ze,onCreate:M,openText:ee="ra.action.open",optionText:i,optionValue:I,parse:Be,resource:te,shouldRenderSuggestions:L,setFilter:D,size:De,source:_e,suggestionLimit:_=1/0,TextFieldProps:Qe,translateChoice:Ne,validate:Ve,variant:We,...ne}=o,He=vt(Me),q=X(null),{allChoices:Q,isLoading:Ue,error:N,resource:oe,source:V,setFilters:re,isFromReference:T}=Ct({choices:r,isFetching:Fe,isLoading:Pe,resource:te,source:_e}),v=Rt(),{id:$e,field:c,isRequired:W,fieldState:{error:Xe,invalid:ie,isTouched:se},formState:{isSubmitted:ae}}=Tt({defaultValue:Re,id:ve,field:Oe,fieldState:we,formState:Le,isRequired:Ae,onBlur:qe,onChange:ze,parse:Be,format:Ie,resource:oe,source:V,validate:Ve,...ne}),p=me(()=>b==null||W||d?Q:[{[I||"id"]:h,[typeof i=="string"?i:"name"]:v(b,{_:b})}].concat(Q),[Q,h,b,W,d,i,I,v]),f=Dt(c.value,{choices:p,multiple:d,optionValue:I});F(()=>{if(h==null)throw new Error("emptyValue being set to null or undefined is not supported. Use parse to turn the empty string into null.")},[h]),F(()=>{if($(i)&&b!=null)throw new Error("optionText of type React element is not supported when setting emptyText");if($(i)&&P==null)throw new Error(`
2
+ If you provided a React element for the optionText prop, you must also provide the inputText prop (used for the text input)`);if($(i)&&!T&&R==null)throw new Error(`
3
+ If you provided a React element for the optionText prop, you must also provide the matchSuggestion prop (used to match the user input with a choice)`)},[i,P,R,b,T]),F(()=>{Ot(L!=null&&O==null,"When providing a shouldRenderSuggestions function, we recommend you also provide the noOptionsText prop and set it to a text explaining users why no options are displayed. It supports translation keys.")},[L,O]);const Ge=It(oe),{getChoiceText:le,getChoiceValue:A,getSuggestions:ue}=St({choices:p,limitChoicesToValue:w,matchSuggestion:R,optionText:i??(T?Ge:void 0),optionValue:I,selectedItem:f,suggestionLimit:_,translateChoice:Ne??!T}),[S,ce]=G(""),[H,de]=G(null),Ke=e=>{let t;if(d?Array.isArray(e)?t=e.map(A):t=[...c.value??[],A(e)]:t=A(e)??h,q.current[1]==="clear"){c.onChange(t);return}if(q.current[0].currentTarget.nodeName==="svg"){c.onChange(t);return}if(q.current[1]==="removeOption"){de(n=>t.filter(x=>!new Set(H).has(x)));return}de(n=>Array.from(n?new Set([...n,...t]):new Set([...t])))},pe=z(ut(e=>{if(D)return D(e);r||re(He(e),[],!0)},Y),[Y,re,D]),fe=X(c.value);F(()=>{lt(fe.current,c.value)||(fe.current=c.value,pe(""))},[c.value]);const{getCreateItem:je,handleChange:Je,createElement:Ye,createId:ge}=At({create:k,createLabel:Te,createItemLabel:Se,createValue:be,handleChange:Ke,filter:S,onCreate:M,optionText:i}),y=z((e,t=!1)=>e==null?"":typeof e=="string"?e:e?.id===ge?C(e,typeof i=="string"?i:"name"):!t&&e[I||"id"]===h?C(e,typeof i=="string"?i:"name"):!t&&P!==void 0?P(e):le(e),[le,P,ge,i,I,h]);F(()=>{if(!d){const e=y(f);if(typeof e=="string")ce(e);else throw new Error("When optionText returns a React element, you must also provide the inputText prop")}},[y,d,f]);const U=z(e=>{let t;return d?t=f.map(n=>y(n)):t=[y(f)],t.includes(e)},[y,d,f]),Ze=z(e=>{const t=p?p.some(n=>y(n)===e):!1;return U(e)||t},[p,y,U]),et=(e,t,n)=>{(e?.type==="change"||!U(t))&&(ce(t),pe(t))},tt=(e,t)=>{let n=T||R||w?e:qt(e,t);const{inputValue:x}=t;return(M||k)&&x!==""&&!Ze(S)&&(n=n.concat(je(x))),n},nt=(e,t,n)=>{q.current=[e,n],Je(t!==null?t:h)},ot=bt(1e3,S),rt=me(()=>!T&&(R||w)?ue(S):p?.slice(0,_)||[],[p,S,ue,w,R,_,T]),it=(e,t)=>String(A(e))===String(A(t)),st=!!N||Z!==!1||(se||ae)&&ie;return xe(Qt,{children:[g(zt,{className:ct("ra-input",`ra-input-${V}`,s),clearText:v(j,{_:j}),closeText:v(J,{_:J}),openText:v(ee,{_:ee}),id:$e,isOptionEqualToValue:it,blurOnSelect:l,clearOnBlur:a,selectOnFocus:m,openOnFocus:E,disableCloseOnSelect:B,filterSelectedOptions:Ce,renderInput:e=>g(gt,{name:c.name,label:g(xt,{label:Ee,source:V,resource:te,isRequired:W}),error:!!N||(se||ae)&&ie,helperText:st?g(Pt,{error:Xe?.message||N?.message,helperText:Z}):null,margin:ke,variant:We,className:ye.textField,...Qe,...e,size:De}),multiple:d,renderTags:u||((e,t)=>{const n=i;return g(mt,{title:e.map(x=>x[n]).join(" , "),children:g(ft,{label:e[0][n]+(e.length>1?" +"+(e.length-1):""),sx:{".MuiSvgIcon-root":{zIndex:100}},variant:"filled",size:"small"})})}),noOptionsText:typeof O=="string"?v(O,{_:O}):O,...Ft(ne),freeSolo:!!k||!!M,handleHomeEndKeys:!!k||!!M,filterOptions:tt,options:L==null||L(S)?rt:[],getOptionLabel:y,inputValue:S,loading:Ue&&(!p||p.length===0)&&ot,value:f,onChange:(e,t,n)=>{nt(e,t,n)},onInputChange:et,clearOnEscape:!1,renderOption:(e,t,{selected:n})=>{const x=f&&f.find(at=>at.id===t.id)?!0:n;return xe("li",{...e,children:[g(pt,{icon:wt,checkedIcon:Mt,style:{marginRight:8},defaultChecked:x}),t[i]]})},onClose:()=>{H&&c.onChange(H)}}),Ye]})};var ln=_t;export{ye as AutocompleteInputClasses,ln as default};
@@ -0,0 +1,42 @@
1
+ import { AutocompleteInputProps, RaRecord } from 'react-admin/src';
2
+ /* TODO: AutoCompleteCheckBoxInputAutoSearch doesn't exists! */
3
+ /* @ts-ignore */
4
+ import { AutocompleteCheckBoxInputAutoSearch } from './AutoCompleteCheckBoxInputAutoSearch';
5
+ import React from 'react';
6
+
7
+ export const AutocompleteCheckBoxArrayInputAutoSearch = <
8
+ OptionType extends RaRecord = RaRecord,
9
+ DisableClearable extends boolean | undefined = boolean | undefined,
10
+ SupportCreate extends boolean | undefined = false,
11
+ >({
12
+ defaultValue,
13
+ ...props
14
+ }: AutocompleteArrayInputProps<
15
+ OptionType,
16
+ DisableClearable,
17
+ SupportCreate
18
+ >) => {
19
+ return (
20
+ <AutocompleteCheckBoxInputAutoSearch<
21
+ OptionType,
22
+ true,
23
+ DisableClearable,
24
+ SupportCreate
25
+ >
26
+ {...props}
27
+ multiple
28
+ defaultValue={defaultValue ?? []}
29
+ />
30
+ );
31
+ };
32
+
33
+ export type AutocompleteArrayInputProps<
34
+ OptionType = RaRecord,
35
+ DisableClearable extends boolean | undefined = false,
36
+ SupportCreate extends boolean | undefined = false,
37
+ > = Omit<
38
+ AutocompleteInputProps<OptionType, true, DisableClearable, SupportCreate>,
39
+ 'defaultValue'
40
+ > & {
41
+ defaultValue?: any[];
42
+ };
@@ -0,0 +1 @@
1
+ import{jsx as a}from"react/jsx-runtime";const o=({defaultValue:e,...t})=>a(AutocompleteCheckBoxInput,{...t,multiple:!0,defaultValue:e??[]});var d=o;export{d as default};
@@ -0,0 +1 @@
1
+ import{jsx as s,jsxs as m}from"react/jsx-runtime";import{useRecordContext as N}from"react-admin";import{useFormContext as G}from"react-hook-form";import{Box as R,Button as L,IconButton as Q,TextField as A,Typography as P,Table as I,TableBody as D,TableCell as u,TableContainer as F,TableHead as z,TableRow as v,Paper as K}from"@mui/material";import U from"@mui/icons-material/Delete";import X from"@mui/icons-material/Add";import{useState as O,useEffect as Y}from"react";const j=c=>{const{method:b,attribute:r,resourceConfig:f}=c,d=N(),{setValue:C,getValues:y}=G(),l=r.attribute,g=l.startsWith("settings."),h=g?l.split(".").slice(1).join("."):l,[a,T]=O([]),[p,x]=O({});Y(()=>{let t={};if(g&&d?.settings){const i=d.settings||{};t=J(i,h)||{}}else d?.[l]&&(t=d[l]||{});const n=Object.entries(t).map(([i,e])=>({key:i,value:typeof e=="object"?JSON.stringify(e):String(e),id:w()}));T(n)},[d,l]);const J=(t,n)=>n?n.split(".").reduce((e,o)=>e&&e[o]!==void 0?e[o]:{},t):t,W=(t,n,i)=>{if(!n)return i;const e=n.split("."),o=e.pop(),B=e.reduce((S,V)=>(S[V]===void 0&&(S[V]={}),S[V]),t);return o&&(B[o]=i),t},w=()=>Math.random().toString(36).substring(2,11),E=()=>{T([...a,{key:"",value:"",id:w()}])},H=t=>{T(a.filter(n=>n.id!==t)),k(a.filter(n=>n.id!==t))},M=(t,n)=>{const i=a.some(o=>o.id!==t&&o.key===n);x(i?{...p,[t]:"Duplicate key"}:{...p,[t]:""});const e=a.map(o=>o.id===t?{...o,key:n}:o);T(e),k(e)},q=(t,n)=>{const i=a.map(e=>e.id===t?{...e,value:n}:e);T(i),k(i)},k=t=>{const n=t.reduce((i,e)=>{if(e.key.trim()){let o=e.value;try{(e.value.trim().startsWith("{")||e.value.trim().startsWith("[")||e.value.trim()==="true"||e.value.trim()==="false"||!isNaN(Number(e.value.trim())))&&(o=JSON.parse(e.value))}catch{}i[e.key]=o}return i},{});if(g){const i=y("settings")||{},e=W({...i},h,n);C("settings",e,{shouldDirty:!0})}else C(l,n,{shouldDirty:!0})};return m(R,{sx:{mt:1,mb:2},children:[s(P,{variant:"subtitle1",gutterBottom:!0,children:r.label||"Settings Editor"}),s(F,{component:K,sx:{mb:2},children:m(I,{size:"small",children:[s(z,{children:m(v,{children:[s(u,{width:"40%",children:"Key"}),s(u,{width:"50%",children:"Value"}),s(u,{width:"10%",align:"center",children:"Actions"})]})}),s(D,{children:a.map(t=>m(v,{children:[s(u,{children:s(A,{fullWidth:!0,size:"small",value:t.key,onChange:n=>M(t.id,n.target.value),error:!!p[t.id],helperText:p[t.id]})}),s(u,{children:s(A,{fullWidth:!0,size:"small",value:t.value,onChange:n=>q(t.id,n.target.value)})}),s(u,{align:"center",children:s(Q,{size:"small",onClick:()=>H(t.id),color:"error",children:s(U,{fontSize:"small"})})})]},t.id))})]})}),s(L,{startIcon:s(X,{}),variant:"outlined",size:"small",onClick:E,children:"+"})]})},Z=c=>{const{attribute:b}=c,r=N(),f=b.attribute,d=f.startsWith("settings."),C=d?f.split(".").slice(1).join("."):f;let y={};if(d&&r?.settings){const l=r.settings||{};C?y=C.split(".").reduce((h,a)=>h&&h[a]!==void 0?h[a]:{},l):y=l}else r?.[f]&&(y=r[f]);return m(R,{sx:{mt:1,mb:2},children:[s(P,{variant:"subtitle1",gutterBottom:!0,children:b.label||"Settings"}),Object.keys(y).length>0?s(F,{component:K,children:m(I,{size:"small",children:[s(z,{children:m(v,{children:[s(u,{width:"40%",children:"Key"}),s(u,{width:"60%",children:"Value"})]})}),s(D,{children:Object.entries(y).map(([l,g])=>m(v,{children:[s(u,{children:l}),s(u,{children:typeof g=="object"?JSON.stringify(g):String(g)})]},l))})]})}):s(P,{variant:"body2",color:"textSecondary",children:"No settings configured"})]})},_=({method:c,attribute:b,resourceConfig:r})=>{switch(c){case"edit":return s(j,{attribute:b,method:c,resourceConfig:r});case"create":return s(j,{attribute:b,method:c,resourceConfig:r});case"view":return s(Z,{attribute:b,method:c,resourceConfig:r});default:return null}};var rt=_;export{j as JsonEdit,Z as JsonView,rt as default};
@@ -0,0 +1 @@
1
+ import{Fragment as Ie,jsx as e,jsxs as s}from"react/jsx-runtime";import{useRecordContext as me}from"react-admin";import{useFormContext as De}from"react-hook-form";import{Box as a,Button as j,IconButton as Y,TextField as U,Typography as S,Dialog as Re,DialogTitle as ze,DialogContent as Ee,DialogActions as Fe,Card as Ve,Chip as z,InputAdornment as F,FormControl as ne,InputLabel as oe,Select as ae,MenuItem as V,Tabs as Le,Tab as pe,Pagination as je,Link as We}from"@mui/material";import $e from"@mui/icons-material/Delete";import he from"@mui/icons-material/Add";import Ke from"@mui/icons-material/Edit";import Oe from"@mui/icons-material/Preview";import fe from"@mui/icons-material/Search";import X from"@mui/icons-material/Clear";import ye from"@mui/icons-material/FilterList";import{ChromePicker as Ne}from"react-color";import{useState as C,useEffect as W,useRef as xe,useCallback as be,useMemo as q}from"react";import{updateDomCssVariables as He}from"@dashadmin/dash-utils";import{AuthPersistenceService as Ge}from"@dashadmin/dash-auth";const re=n=>{let r,d,h,f=1;if(n.startsWith("#")){const o=n.replace("#","");o.length===8?(r=parseInt(o.substr(0,2),16),d=parseInt(o.substr(2,2),16),h=parseInt(o.substr(4,2),16),f=parseInt(o.substr(6,2),16)/255):(r=parseInt(o.substr(0,2),16),d=parseInt(o.substr(2,2),16),h=parseInt(o.substr(4,2),16))}else if(n.startsWith("rgb")){const o=n.match(/rgba?\(([^)]+)\)/);if(o){const p=o[1].split(",").map(k=>parseFloat(k.trim()));[r,d,h,f=1]=p}else return"#000000"}else return n.startsWith("hsl"),"#000000";return(.299*r+.587*d+.114*h)/255*f+(1-f)>.5?"#000000":"#ffffff"},qe=(n,r)=>{switch(r){case"hex":return n.hex;case"rgb":return`rgb(${Math.round(n.rgb.r)}, ${Math.round(n.rgb.g)}, ${Math.round(n.rgb.b)})`;case"rgba":return`rgba(${Math.round(n.rgb.r)}, ${Math.round(n.rgb.g)}, ${Math.round(n.rgb.b)}, ${n.rgb.a||1})`;case"hsl":return`hsl(${Math.round(n.hsl.h)}, ${Math.round(n.hsl.s*100)}%, ${Math.round(n.hsl.l*100)}%)`;case"hsla":return`hsla(${Math.round(n.hsl.h)}, ${Math.round(n.hsl.s*100)}%, ${Math.round(n.hsl.l*100)}%, ${n.hsl.a||1})`;default:return n.hex}},_=n=>{const r=n.split("--"),d=r[0],h=r[1];return{baseChips:d.split("-").filter(v=>v.length>0),mode:h}},Ce=n=>{const r=new Set;return n.forEach(d=>{const{mode:h}=_(d.key);h&&r.add(h)}),Array.from(r).sort()},G=n=>{if(!n)return"";switch(n.toLowerCase()){case"light":return"\u2600\uFE0F";case"dark":return"\u{1F319}";default:return n}},_e=({pair:n,onEdit:r,onDelete:d})=>{const h=re(n.value),{baseChips:f,mode:v}=_(n.key),I=G(v);return s(Ve,{onClick:()=>r(n),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:[e(a,{sx:{width:80,backgroundColor:n.value,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:e(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:e(Ke,{sx:{color:"#fff"}})})}),s(a,{sx:{flexGrow:1,p:1.5,display:"flex",flexDirection:"column",justifyContent:"space-between",overflow:"hidden"},children:[s(a,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:.5},children:[e(S,{variant:"caption",sx:{fontFamily:"monospace",fontWeight:"bold",color:"text.secondary"},children:n.value}),v&&e(z,{label:v,size:"small",icon:e("span",{style:{marginLeft:6,fontSize:"0.8rem"},children:I}),sx:{height:18,fontSize:"0.65rem","& .MuiChip-label":{padding:"0 6px"}}})]}),e(a,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:f.map((o,p)=>e(z,{label:o,size:"small",variant:"outlined",sx:{height:20,fontSize:"0.7rem",maxWidth:"100%","& .MuiChip-label":{padding:"0 6px",overflow:"hidden",textOverflow:"ellipsis"}}},p))})]})]})},Je=({open:n,pair:r,onClose:d,onSave:h,onDelete:f,existingKeys:v,updateSingleDomColor:I})=>{const[o,p]=C(null),[k,g]=C("hex"),[T,B]=C(""),[D,y]=C(0);W(()=>{r&&(p({...r}),r.value.startsWith("rgba(")?g("rgba"):r.value.startsWith("rgb(")?g("rgb"):r.value.startsWith("hsla(")?g("hsla"):r.value.startsWith("hsl(")?g("hsl"):g("hex")),B("")},[r]);const $=x=>{if(!o)return;const R=v.some(E=>E===x&&x!==r?.key);B(R?"Key already exists":""),p({...o,key:x})},A=x=>{if(!o)return;const R=qe(x,k);p({...o,value:R}),I(o.key,R)},K=()=>{!o||T||!o.key.trim()||(h(o),d())},N=()=>{o&&(f(o.id),d())};return o?s(Re,{open:n,onClose:d,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{minHeight:600}},children:[e(ze,{children:r?.key?`Edit Color: ${r.key}`:"Add New Color"}),e(Ee,{children:s(a,{sx:{display:"flex",flexDirection:"column",gap:3,pt:1},children:[e(U,{fullWidth:!0,label:"Color Name",value:o.key,onChange:x=>$(x.target.value),error:!!T,helperText:T,placeholder:"e.g., primary-color--light, background-dark--dark"}),s(ne,{fullWidth:!0,children:[e(oe,{children:"Color Format"}),s(ae,{value:k,label:"Color Format",onChange:x=>g(x.target.value),children:[e(V,{value:"hex",children:"HEX"}),e(V,{value:"rgb",children:"RGB"}),e(V,{value:"rgba",children:"RGBA (with alpha)"}),e(V,{value:"hsl",children:"HSL"}),e(V,{value:"hsla",children:"HSLA (with alpha)"})]})]}),s(a,{children:[s(Le,{value:D,onChange:(x,R)=>y(R),children:[e(pe,{label:"Color Picker"}),e(pe,{label:"Manual Input"})]}),D===0&&e(a,{sx:{mt:2,display:"flex",justifyContent:"center"},children:e(Ne,{color:o.value,onChange:A,disableAlpha:!["rgba","hsla"].includes(k)})}),D===1&&e(a,{sx:{mt:2},children:e(U,{fullWidth:!0,label:`Color Value (${k.toUpperCase()})`,value:o.value,onChange:x=>p({...o,value:x.target.value}),placeholder:k==="hex"?"#ff0000":k==="rgb"?"rgb(255, 0, 0)":k==="rgba"?"rgba(255, 0, 0, 1)":k==="hsl"?"hsl(0, 100%, 50%)":"hsla(0, 100%, 50%, 1)",InputProps:{startAdornment:e(F,{position:"start",children:e(a,{sx:{width:20,height:20,backgroundColor:o.value,border:"1px solid #ccc",borderRadius:1}})})}})})]}),s(a,{children:[e(S,{variant:"subtitle2",gutterBottom:!0,children:"Preview"}),e(a,{sx:{width:"100%",height:80,backgroundColor:o.value,border:"1px solid #ccc",borderRadius:1,display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:e(S,{variant:"body2",sx:{color:re(o.value),fontWeight:"bold",backgroundColor:"rgba(0,0,0,0.1)",padding:"4px 8px",borderRadius:1},children:o.key||"Color Preview"})})]})]})}),s(Fe,{children:[r?.key&&e(j,{onClick:N,color:"error",startIcon:e($e,{}),children:"Delete"}),e(a,{sx:{flexGrow:1}}),e(j,{onClick:d,children:"Cancel"}),e(j,{onClick:K,variant:"contained",disabled:!!T||!o.key.trim(),children:"Save"})]})]}):null},ve=n=>{const{method:r,attribute:d,resourceConfig:h}=n,f=me(),{setValue:v,getValues:I}=De(),o=d.attribute,p=o.startsWith("settings."),k=p?o.split(".").slice(1).join("."):o,[g,T]=C([]),[B,D]=C(""),[y,$]=C(""),[A,K]=C(!0),[N,x]=C(!0),[R,E]=C(!1),[Q,O]=C(null),[i,m]=C(1),[b]=C(24),M=xe(null),J=xe(new Map),P=be(t=>{window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:t}))},[]),H=q(()=>Ce(g),[g]),L=q(()=>{let t=g;return B.trim()&&(t=t.filter(l=>l.key.toLowerCase().includes(B.toLowerCase()))),y&&(t=t.filter(l=>{const{mode:u}=_(l.key);return u===y})),t},[g,B,y]),ke=t=>{D(t.target.value)},se=()=>{D("")},Se=t=>{$(t.target.value)},le=()=>{$("")};W(()=>{(async()=>{K(!0),P(!0);try{let l={},u={};try{u=d?.default_value||{}}catch{u={}}if(p&&f?.settings){const w=f.settings||{};l={...u,...we(w,k)}}else f?.[o]?l={...u,...f[o]}:l=u;const c=Object.entries(l).map(([w,Z])=>({key:w,value:String(Z),id:ie()}));T(c),c.length>50&&await new Promise(w=>setTimeout(w,100))}catch(l){console.error("Error loading initial data:",l)}finally{K(!1)}})()},[f,o]),W(()=>{!A&&g.length>=0&&(x(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{x(!1),P(!1)})}))},[A,g.length,P]),W(()=>()=>{M.current&&clearTimeout(M.current),P(!1)},[P]);const we=(t,l)=>l?l.split(".").reduce((c,w)=>c&&c[w]!==void 0?c[w]:{},t):t,Be=(t,l,u)=>{if(!l)return u;const c=l.split("."),w=c.pop(),Z=c.reduce((ee,te)=>(ee[te]===void 0&&(ee[te]={}),ee[te]),t);return w&&(Z[w]=u),t},ie=()=>Math.random().toString(36).substring(2,11),de=()=>{const t={key:"",value:"#000000",id:ie()};O(t),E(!0)},Me=t=>{O(t),E(!0)},Ae=t=>{const l=g.findIndex(c=>c.id===t.id);let u;l>=0?u=g.map(c=>c.id===t.id?t:c):u=[...g,t],T(u),ge(u),ce(t.key,t.value)},ue=t=>{const l=g.filter(u=>u.id!==t);T(l),ge(l)},ce=(t,l)=>{if(!t.trim())return;const c=`--${document.documentElement.getAttribute("data-theme")}`;if(t.endsWith(c)){const w=t.slice(0,-c.length);document.documentElement.style.setProperty(`--${w}`,l)}},Te=()=>{const t=Ge.getTenantSettings();return t?t?.values||{}:{}},Pe=t=>{const l=g.reduce((u,c)=>(c.key.trim()&&(u[c.key]=c.value),u),{});He(t,l,Te())},ge=t=>{const l=t.reduce((u,c)=>(c.key.trim()&&(u[c.key]=c.value),u),{});if(p){const u=I("settings")||{},c=Be({...u},k,l);v("settings",c,{shouldDirty:!0})}else v(o,l,{shouldDirty:!0})};return A||N?e(a,{sx:{mt:1,mb:2,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e(S,{variant:"body2",color:"textSecondary",children:A?"Loading color settings...":"Rendering colors..."})}):s(a,{sx:{mt:1,mb:2},children:[e(S,{variant:"subtitle1",gutterBottom:!0,children:d.label||"Color Palette"}),s(a,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:3},children:[e(j,{startIcon:e(Oe,{}),variant:"contained",size:"small",onClick:()=>Pe(document.documentElement.getAttribute("data-theme")),color:"primary",children:"Preview Colors TEST"}),e(j,{startIcon:e(he,{}),variant:"outlined",size:"small",onClick:de,children:"Add Color"})]}),s(a,{sx:{mb:3,display:"flex",gap:2,alignItems:"flex-end"},children:[e(U,{fullWidth:!0,size:"small",placeholder:"Search colors by name...",value:B,onChange:ke,InputProps:{startAdornment:e(F,{position:"start",children:e(fe,{})}),endAdornment:B&&e(F,{position:"end",children:e(Y,{size:"small",onClick:se,edge:"end",children:e(X,{})})})}}),s(ne,{size:"small",sx:{minWidth:150},children:[e(oe,{children:"Mode"}),s(ae,{value:y,label:"Mode",onChange:Se,startAdornment:e(F,{position:"start",children:e(ye,{fontSize:"small"})}),endAdornment:y&&e(F,{position:"end",children:e(Y,{size:"small",onClick:le,edge:"end",sx:{mr:1},children:e(X,{fontSize:"small"})})}),children:[e(V,{value:"",children:e("em",{children:"All Modes"})}),H.map(t=>e(V,{value:t,children:s(a,{sx:{display:"flex",alignItems:"center",gap:1},children:[e("span",{children:G(t)}),e("span",{children:t})]})},t))]})]})]}),(B||y)&&s(a,{sx:{mb:2,display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[e(z,{label:`${L.length} of ${g.length} colors`,size:"small",variant:"outlined"}),y&&e(z,{label:`Mode: ${y}`,size:"small",variant:"filled",color:"primary",onDelete:le,avatar:e("span",{style:{paddingLeft:6},children:G(y)})}),B&&e(z,{label:`Search: "${B}"`,size:"small",variant:"filled",color:"secondary",onDelete:se})]}),N?e(a,{sx:{display:"flex",justifyContent:"center",p:4,alignItems:"center",flexDirection:"column",gap:2},children:e(S,{children:"Rendering Grid..."})}):L.length>0?s(Ie,{children:[e(a,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:2,width:"100%"},children:L.slice((i-1)*b,i*b).map(t=>e(a,{sx:{minWidth:0},children:e(_e,{pair:t,onEdit:Me,onDelete:ue})},t.id))}),L.length>b&&e(a,{sx:{mt:4,display:"flex",justifyContent:"center"},children:e(je,{count:Math.ceil(L.length/b),page:i,onChange:(t,l)=>m(l),color:"primary",size:"large",showFirstButton:!0,showLastButton:!0})}),s(S,{variant:"caption",sx:{display:"block",textAlign:"center",mt:2,color:"text.secondary"},children:["Showing ",Math.min((i-1)*b+1,L.length)," - ",Math.min(i*b,L.length)," of ",L.length," colors"]})]}):s(a,{sx:{p:4,textAlign:"center",bgcolor:"background.paper",borderRadius:1,border:"1px dashed #ccc"},children:[e(S,{color:"textSecondary",children:"No colors found using current filters."}),e(a,{sx:{mt:1},children:e(We,{component:"button",variant:"body2",onClick:()=>{D(""),$(""),m(1)},children:"Clear filters"})})]}),g.length===0&&s(a,{sx:{textAlign:"center",py:4},children:[e(S,{variant:"body2",color:"textSecondary",gutterBottom:!0,children:"No colors in your palette yet"}),e(j,{startIcon:e(he,{}),variant:"contained",onClick:de,children:"Add Your First Color"})]}),e(Je,{open:R,pair:Q,onClose:()=>{E(!1),O(null)},onSave:Ae,onDelete:ue,existingKeys:g.map(t=>t.key),updateSingleDomColor:ce})]})},Ye=n=>{const{attribute:r}=n,d=me(),h=r.attribute,f=h.startsWith("settings."),v=f?h.split(".").slice(1).join("."):h,[I,o]=C(""),[p,k]=C(""),[g,T]=C(!0),[B,D]=C(!0),[y,$]=C({}),A=be(i=>{window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:i}))},[]),K=q(()=>Object.entries(y).map(([i,m])=>({key:i,value:String(m),id:i})),[y]),N=q(()=>Ce(K),[K]);W(()=>{(async()=>{T(!0),A(!0);try{let m={},b={};try{b=r?.default_value||{}}catch{b={}}if(f&&d?.settings){const M=d.settings||{};if(v){const J=v.split(".");m={...b,...J.reduce((P,H)=>P&&P[H]!==void 0?P[H]:{},M)}}else m={...b,...M}}else d?.[h]?m={...b,...d[h]}:m=b;$(m),Object.keys(m).length>50&&await new Promise(M=>setTimeout(M,100))}catch(m){console.error("Error loading view data:",m)}finally{T(!1)}})()},[d,h,r,f,v]),W(()=>{!g&&Object.keys(y).length>=0&&(D(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{D(!1),A(!1)})}))},[g,y,A]),W(()=>()=>{A(!1)},[A]);const x=q(()=>{let i=Object.entries(y);return I.trim()&&(i=i.filter(([m])=>m.toLowerCase().includes(I.toLowerCase()))),p&&(i=i.filter(([m])=>{const{mode:b}=_(m);return b===p})),i.reduce((m,[b,M])=>(m[b]=M,m),{})},[y,I,p]),R=i=>{o(i.target.value)},E=()=>{o("")},Q=i=>{k(i.target.value)},O=()=>{k("")};return g||B?e(a,{sx:{mt:1,mb:2,display:"flex",justifyContent:"center",alignItems:"center",minHeight:200},children:e(S,{variant:"body2",color:"textSecondary",children:g?"Loading color settings...":"Rendering colors..."})}):s(a,{sx:{mt:1,mb:2},children:[e(S,{variant:"subtitle1",gutterBottom:!0,children:r.label||"Color Palette"}),Object.keys(y).length>0&&s(Ie,{children:[s(a,{sx:{mb:3,display:"flex",gap:2,alignItems:"flex-end"},children:[e(U,{fullWidth:!0,size:"small",placeholder:"Search colors by name...",value:I,onChange:R,InputProps:{startAdornment:e(F,{position:"start",children:e(fe,{})}),endAdornment:I&&e(F,{position:"end",children:e(Y,{size:"small",onClick:E,edge:"end",children:e(X,{})})})}}),s(ne,{size:"small",sx:{minWidth:150},children:[e(oe,{children:"Mode"}),s(ae,{value:p,label:"Mode",onChange:Q,startAdornment:e(F,{position:"start",children:e(ye,{fontSize:"small"})}),endAdornment:p&&e(F,{position:"end",children:e(Y,{size:"small",onClick:O,edge:"end",sx:{mr:1},children:e(X,{fontSize:"small"})})}),children:[e(V,{value:"",children:e("em",{children:"All Modes"})}),N.map(i=>e(V,{value:i,children:s(a,{sx:{display:"flex",alignItems:"center",gap:1},children:[e("span",{children:G(i)}),e("span",{children:i})]})},i))]})]})]}),(I||p)&&s(a,{sx:{mb:2,display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:[e(z,{label:`${Object.keys(x).length} of ${Object.keys(y).length} colors`,size:"small",variant:"outlined"}),p&&e(z,{label:`Mode: ${G(p)} ${p}`,size:"small",variant:"filled",color:"primary",onDelete:O}),I&&e(z,{label:`Search: "${I}"`,size:"small",variant:"filled",color:"secondary",onDelete:E})]}),Object.keys(x).length>0?e(a,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))",gap:0,border:"1px solid #e0e0e0"},children:Object.entries(x).map(([i,m])=>{const{baseChips:b,mode:M}=_(i),J=G(M);return s(a,{sx:{aspectRatio:"unset",height:"30px",transition:"all 0.2s ease-in-out","&:hover":{transform:"translateY(-2px)",boxShadow:3},position:"relative",overflow:"hidden",backgroundColor:m,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",border:"1px solid rgba(255,255,255,0.1)",padding:"0 8px",gap:.5},children:[e(a,{sx:{display:"flex",flexWrap:"wrap",gap:.25,justifyContent:"center"},children:b.map((P,H)=>e(z,{label:P,size:"small",sx:{height:16,fontSize:"0.6rem",backgroundColor:"rgba(255,255,255,0.1)",color:"#fff","& .MuiChip-label":{padding:"0 4px"}}},H))}),M&&e(z,{label:J,size:"small",sx:{height:16,fontSize:"0.6rem",backgroundColor:"rgba(0,0,0,0.7)",color:"#fff","& .MuiChip-label":{padding:"0 4px"}}}),e(S,{variant:"caption",sx:{color:re(m),backgroundColor:"rgba(0,0,0,0.1)",padding:"1px 4px",borderRadius:.5,fontSize:"0.5rem",fontFamily:"monospace",textAlign:"center",mt:"auto"},children:m})]},i)})}):s(a,{sx:{textAlign:"center",py:4},children:[e(S,{variant:"body2",color:"textSecondary",children:"No colors found matching your filters"}),s(a,{sx:{mt:1,display:"flex",justifyContent:"center",gap:1},children:[I&&e(j,{size:"small",onClick:E,children:"Clear search"}),p&&e(j,{size:"small",onClick:O,children:"Clear mode filter"})]})]})]}),Object.keys(y).length===0&&e(a,{sx:{textAlign:"center",py:4},children:e(S,{variant:"body2",color:"textSecondary",children:"No colors configured in this palette"})})]})},Ue=({method:n,attribute:r,resourceConfig:d})=>{const[h,f]=C(!0);if(W(()=>{window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:!0}));const v=setTimeout(()=>{f(!1)},50);return()=>{clearTimeout(v),window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:!1}))}},[]),h)return e(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:100},children:e(S,{variant:"body2",color:"textSecondary",children:"Initializing color palette..."})});switch(n){case"edit":return e(ve,{attribute:r,method:n,resourceConfig:d});case"create":return e(ve,{attribute:r,method:n,resourceConfig:d});case"view":return e(Ye,{attribute:r,method:n,resourceConfig:d});default:return null}};var yt=Ue;export{ve as JsonEdit,Ye as JsonView,yt as default};