@pautena/react-design-system 0.14.4 → 0.14.5
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/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/model-router/cjs/index.js +1 -1
- package/model-router/cjs/index.js.map +1 -1
- package/model-router/index.js +1 -1
- package/model-router/index.js.map +1 -1
- package/object-details/cjs/index.js +1 -1
- package/object-details/cjs/index.js.map +1 -1
- package/object-details/index.js +1 -1
- package/object-details/index.js.map +1 -1
- package/package.json +1 -1
- package/value-datetime/cjs/index.js +1 -1
- package/value-datetime/cjs/index.js.map +1 -1
- package/value-datetime/index.js +1 -1
- package/value-datetime/index.js.map +1 -1
- package/value-rating/cjs/index.js +1 -1
- package/value-rating/cjs/index.js.map +1 -1
- package/value-rating/index.js +1 -1
- package/value-rating/index.js.map +1 -1
- package/value-text/cjs/index.js +1 -1
- package/value-text/cjs/index.js.map +1 -1
- package/value-text/index.js +1 -1
- package/value-text/index.js.map +1 -1
package/model-router/index.js
CHANGED
|
@@ -20,5 +20,5 @@ object-assign
|
|
|
20
20
|
*
|
|
21
21
|
* This source code is licensed under the MIT license found in the
|
|
22
22
|
* LICENSE file in the root directory of this source tree.
|
|
23
|
-
*/vt={exports:{}},"production"===process.env.NODE_ENV?vt.exports=function(){if(ht)return bt;ht=1;var e,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.server_context"),s=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen");function y(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:switch(e=e.type){case n:case i:case o:case u:case d:return e;default:switch(e=e&&e.$$typeof){case c:case l:case s:case m:case f:case a:return e;default:return p}}case r:return p}}}return e=Symbol.for("react.module.reference"),bt.ContextConsumer=l,bt.ContextProvider=a,bt.Element=t,bt.ForwardRef=s,bt.Fragment=n,bt.Lazy=m,bt.Memo=f,bt.Portal=r,bt.Profiler=i,bt.StrictMode=o,bt.Suspense=u,bt.SuspenseList=d,bt.isAsyncMode=function(){return!1},bt.isConcurrentMode=function(){return!1},bt.isContextConsumer=function(e){return y(e)===l},bt.isContextProvider=function(e){return y(e)===a},bt.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},bt.isForwardRef=function(e){return y(e)===s},bt.isFragment=function(e){return y(e)===n},bt.isLazy=function(e){return y(e)===m},bt.isMemo=function(e){return y(e)===f},bt.isPortal=function(e){return y(e)===r},bt.isProfiler=function(e){return y(e)===i},bt.isStrictMode=function(e){return y(e)===o},bt.isSuspense=function(e){return y(e)===u},bt.isSuspenseList=function(e){return y(e)===d},bt.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===i||t===o||t===u||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===m||t.$$typeof===f||t.$$typeof===a||t.$$typeof===l||t.$$typeof===s||t.$$typeof===e||void 0!==t.getModuleId)},bt.typeOf=y,bt}():vt.exports=(gt||(gt=1,"production"!==process.env.NODE_ENV&&function(){var e,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.server_context"),s=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen");function y(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var y=e.type;switch(y){case n:case i:case o:case u:case d:return y;default:var h=y&&y.$$typeof;switch(h){case c:case l:case s:case m:case f:case a:return h;default:return p}}case r:return p}}}e=Symbol.for("react.module.reference");var h=l,b=a,g=t,v=s,x=n,S=m,w=f,$=r,C=i,E=o,k=u,O=d,T=!1,P=!1;xt.ContextConsumer=h,xt.ContextProvider=b,xt.Element=g,xt.ForwardRef=v,xt.Fragment=x,xt.Lazy=S,xt.Memo=w,xt.Portal=$,xt.Profiler=C,xt.StrictMode=E,xt.Suspense=k,xt.SuspenseList=O,xt.isAsyncMode=function(e){return T||(T=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1},xt.isConcurrentMode=function(e){return P||(P=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1},xt.isContextConsumer=function(e){return y(e)===l},xt.isContextProvider=function(e){return y(e)===a},xt.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},xt.isForwardRef=function(e){return y(e)===s},xt.isFragment=function(e){return y(e)===n},xt.isLazy=function(e){return y(e)===m},xt.isMemo=function(e){return y(e)===f},xt.isPortal=function(e){return y(e)===r},xt.isProfiler=function(e){return y(e)===i},xt.isStrictMode=function(e){return y(e)===o},xt.isSuspense=function(e){return y(e)===u},xt.isSuspenseList=function(e){return y(e)===d},xt.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===i||t===o||t===u||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===m||t.$$typeof===f||t.$$typeof===a||t.$$typeof===l||t.$$typeof===s||t.$$typeof===e||void 0!==t.getModuleId)},xt.typeOf=y}()),xt),"undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),Ye.exports.oneOfType([Ye.exports.func,Ye.exports.object]);const St={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px"};const wt=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function $t(e,t,r,n){const o=e[t];if(null==o||!wt(o)){const e=function(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":Number.isFinite(e)?e!==Math.floor(e)?"float":"number":"Infinity";case"object":return null===e?"null":e.constructor.name;default:return t}}(o);return new RangeError(`Invalid ${n} \`${t}\` of type \`${e}\` supplied to \`${r}\`, expected \`integer\`.`)}return null}function Ct(e,t,...r){return void 0===e[t]?null:$t(e,t,...r)}function Et(){return null}Ct.isRequired=$t,Et.isRequired=Et,process.env.NODE_ENV;const kt=({order:r,orderBy:n,headCells:o,onRequestSort:i})=>t(Q,{children:t(W,{children:o.map((o=>{return t(q,{variant:"head",padding:o.disablePadding?"none":"normal",sortDirection:n===o.id&&r,sx:{fontWeight:"bold"},children:o.sort?e(K,{active:n===o.id,direction:n===o.id?r:"asc",onClick:(a=o.id,()=>{i(a)}),children:[o.label,n===o.id?t(g,{component:"span",sx:St,children:"desc"===r?"sorted descending":"sorted ascending"}):null]}):o.label},String(o.id));var a}))})});function Ot(e,t,r){return t[r]<e[r]?-1:t[r]>e[r]?1:0}const Tt=({children:n,data:o,search:i,columns:a,defaultSort:l,defaultOrder:c="asc",loading:s=!1})=>{const[d,f]=u(""),[m,p]=u(c),[y,h]=u(l),b=o.slice().filter(function(e,t){return r=>!t||e.some((e=>{let n=r[e.id];return n?.toLowerCase&&(n=n.toLowerCase()),n?.toString().includes(t.toLowerCase())}))}(a,d)).sort(function(e,t){return"desc"===e?(e,r)=>Ot(e,r,t):(e,r)=>-Ot(e,r,t)}(m,y));return t(r,{children:e(g,{sx:{paddingX:1,paddingBottom:2},children:[i&&t(g,{paddingY:2,children:t(k,{fullWidth:!0,placeholder:"Search",InputProps:{role:"search",startAdornment:t(J,{position:"start",children:t(X,{})})},onChange:e=>f(e.target.value)})}),t(Y,{children:e(G,{children:[t(kt,{order:m,orderBy:y,headCells:a,onRequestSort:e=>{p(y===e&&"asc"===m?"desc":"asc"),h(e)}}),t(H,{children:s?t(W,{children:t(q,{colSpan:a.length,sx:{textAlign:"center"},children:t(M,{})})}):0===b.length?t(W,{children:t(q,{colSpan:a.length,sx:{textAlign:"center"},children:"No data"})}):n(b)})]})})]})})};Tt.defaultProps={defaultOrder:"asc"};const Pt=({columns:n,options:o,data:i,onClick:a,search:l,defaultSort:c,defaultOrder:s,loading:d})=>{const f=[...n,{id:"__options",label:"",disablePadding:!1,numeric:!1,sort:!1}],[m,p]=u(null);return e(r,{children:[t(Tt,{columns:f,data:i,search:l,defaultSort:c,defaultOrder:s,loading:d,children:r=>r.map(((r,n)=>e(W,{onClick:()=>a&&a(r),role:"row","aria-rowindex":n,sx:{cursor:a&&"pointer"},children:[f.map((({id:e},o)=>t(q,{role:"cell",scope:"row","aria-rowindex":n,"aria-colindex":o,children:r[e]},e.toString()))),o&&t(q,{children:t(B,{"data-testid":`options-${r.id}`,onClick:e=>{e.stopPropagation(),p({item:r,anchor:e.currentTarget})},children:t(Z,{})})})]},r.id)))}),o&&t(U,{anchorEl:m?.anchor,open:!!m,onClose:()=>p(null),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:o.map((({id:e,label:r,onClick:n})=>t(C,{onClick:()=>{m&&n(m?.item),p(null)},children:r},e)))})]})},It=({model:r,modelName:o,listData:i,listRequest:a,deleteRequest:l,basePath:c="",deleteFeature:s=!0,updateFeature:u=!0,addFeature:d=!0,detailsFeature:m=!0,onRequestList:p,onClickDeleteItem:y})=>{const h=n();f((()=>{p()}),[]),_e({title:"Item deleted",message:"The item has been deleted successfully",severity:"success"},!!l.success,{from:!1,to:!0}),_e({title:"We had an error",message:l.error||"",severity:"error"},!!l.error,{from:!1,to:!0});const b=m?e=>{h(`${c}/${e.id}`)}:void 0,g=(e,t)=>{"edit"===e?h(`${c}/${t.id}/update`):y(t)},v=[];u&&v.push({id:"edit",label:"Edit",onClick:e=>g("edit",e)}),s&&v.push({id:"remove",label:"Remove",onClick:e=>g("remove",e)});const x=[];return d&&x.push({id:"add",text:"Add",href:`${c}/add`}),e(Ne,{loading:a.loading||l.loading,children:[t(Le,{title:o,preset:"default",actions:x.length>0?x:void 0}),t(We,{children:t(Pt,{columns:r.fields.filter((({listable:e})=>e)).map((({id:e,name:t,type:r})=>({disablePadding:!1,id:e,label:t,numeric:"number"===r,sort:!1}))),data:i,defaultSort:r.fields[0].id,onClick:b,options:v.length>0?v:void 0})})]})},jt=({model:r,modelName:n,basePath:o="",onSubmitNewItem:i,newItemRequest:a})=>(_e({message:"Item added successfully",severity:"success"},!!a.success,{from:!1,to:!0}),ke(`${o}/`,!!a.success,{from:!1,to:!0}),_e({title:"We had an error",message:a.error||"",severity:"error"},!!a.error,{from:!1,to:!0}),e(Ne,{loading:a.loading,children:[t(Le,{title:`Add ${n}`,preset:"default",breadcrumbs:[{id:"list",text:n,link:`${o}/`},{id:"add",text:`Add new ${n}`,link:`${o}/add`}]}),t(We,{children:t(Ee,{model:r,saveButtonText:"Save",onSubmit:i})})]})),Rt=({onClickCancel:r,onClickSubmit:n,sx:o})=>e(J,{position:"end",sx:o,children:[t(h,{variant:"contained",size:"small",color:"error","aria-label":"cancel button",startIcon:t(ne,{sx:{fontSize:12}}),onClick:r,sx:{paddingRight:0,minWidth:0,marginRight:1}}),t(h,{variant:"contained",size:"small",color:"primary","aria-label":"submit button",startIcon:t(te,{sx:{fontSize:12}}),onClick:n,sx:{paddingRight:0,minWidth:0}})]}),Nt=(e,t)=>{const[r,n]=u(!1),[o,i]=u(e),a=()=>{n(!1),i(e)};return{isEditing:r,cancelEdit:a,editValue:o,setEditValue:i,startEdit:()=>{n(!0)},submitEdit:()=>{t(o),a()}}},zt=({dense:e,onClick:r})=>{const{typography:n}=N();return t(B,{size:"small",onClick:r,sx:{ml:e?.5:1},"aria-label":"edit button",children:t(oe,{sx:{fontSize:n.pxToRem(e?18:24)}})})},Mt=e=>`label-${e.replace(/ /g,"-")}`,_t=({label:r,hideLabel:n,tooltip:o,tooltipEnterDelay:i=2e3,children:a,dense:l,sx:c})=>{const{typography:s}=N(),u=Mt(r);return e(g,{width:1,lineHeight:l?0:void 0,sx:c,children:[!n&&t(R,{variant:l?"caption":"subtitle2",role:"label",id:u,lineHeight:l?s.pxToRem(15):void 0,children:r}),o?t(ie,{title:o,placement:"top",enterDelay:i,children:a}):a]})},Vt=({label:r,value:n,placeholder:o="-",editable:i,dense:a,onEdit:l=(()=>null)})=>{const c=Mt(r),{typography:s}=N(),{isEditing:u,editValue:d,startEdit:f,cancelEdit:m,setEditValue:p,submitEdit:y}=Nt(n,l),h={fontSize:a?s.h6.fontSize:s.h5.fontSize};return t(_t,{label:r,dense:a,children:e(g,u?{display:"flex",alignItems:"center",children:[t(ee,{size:a?"small":"medium",checked:d,onChange:e=>p(e.target.checked)}),t(Rt,{onClickCancel:m,onClickSubmit:y})]}:{display:"flex",alignItems:"center","aria-labelledby":c,role:"checkbox","aria-checked":n,children:[void 0===n?t(R,{variant:"h5",children:o}):n?t(te,{color:"success",sx:h}):t(re,{color:"error",sx:h}),i&&t(zt,{dense:a,onClick:f})]})})},At=({label:n,value:o,format:i,placeholder:a="-",editable:l,editInputType:c="datetime",dense:s,onEdit:u=(()=>null)})=>{const{isEditing:d,editValue:f,startEdit:m,cancelEdit:p,setEditValue:y,submitEdit:h}=Nt(o,u),b=Mt(n),v=o&&ae(o,i)||a;return t(_t,{label:n,hideLabel:d,tooltip:v,dense:s,sx:{display:"flex",flexDirection:"column"},children:d?t("datetime"===c?ce:"time"===c?se:le,{value:f,format:i,label:n,onChange:e=>y(e||void 0),slots:{textField:n=>t(k,{...n,size:"small",InputProps:{...n.InputProps,endAdornment:e(r,{children:[n.InputProps?.endAdornment,t(Rt,{onClickCancel:p,onClickSubmit:h,sx:{ml:2}})]}),sx:{marginY:s?.2:1}}})}}):e(g,{display:"flex",alignItems:"center",children:[t(R,{variant:s?"body1":"h5",noWrap:!0,"aria-labelledby":b,children:v}),l&&t(zt,{dense:s,onClick:m})]})})},Dt=({label:r,value:n,placeholder:o="-",editable:i,dense:a,onEdit:l=(()=>null)})=>{const c=d(null),{isEditing:s,editValue:u,startEdit:m,cancelEdit:p,setEditValue:y,submitEdit:h}=Nt(n?.toString(),l),b=Mt(r),v=n?.toString()||o,x=e=>{"Enter"===e.key&&l(e.target.value)};return f((()=>(c.current?.addEventListener("keypress",x),()=>c.current?.removeEventListener("keypress",x))),[c.current]),t(_t,{hideLabel:s,label:r,tooltip:v,dense:a,children:s?t(k,{inputRef:c,value:u,label:r,size:"small",onChange:e=>y(e.target.value),InputProps:{endAdornment:t(Rt,{onClickCancel:p,onClickSubmit:h})},sx:{marginY:a?0:1}}):e(g,{display:"flex",children:[t(R,{variant:a?"body1":"h5",noWrap:!0,"aria-labelledby":b,children:v}),i&&t(zt,{dense:a,onClick:m})]})})},Ft="RdsValueItem-root",Lt="RdsValueItem-content",Wt=({children:e,bordered:r=!0,...n})=>{const o=((e,t)=>{const r=`solid ${t} 1px`,n="none";if(e){if(Array.isArray(e))return e.map((e=>e?r:n));if("object"==typeof e){const t={};return Object.entries(e).forEach((([e,o])=>{t[e]=o?r:n})),t}return r}})(r,me({lightWeight:200,darkWeight:800}));return t(b,{item:!0,className:Ft,...n,children:t(g,{className:Lt,px:1,borderLeft:o,children:e})})},qt=(e,r,{dense:n}={})=>{const{id:o,name:i,type:a}=e,l=r[o];return"boolean"===a?t(Vt,{dense:n,label:i,value:l}):"date"===a||"time"===a||"datetime"===a?t(At,{dense:n,label:i,value:l,format:e.format}):"object"!=typeof l||Array.isArray(l)?t(Dt,{dense:n,label:i,value:l?.toString()}):t(Dt,{dense:n,label:i,value:JSON.stringify(l)})},Bt=({field:{name:e,description:r,value:n},instance:o,dense:i})=>{const a=[{field:"id",headerName:"ID",width:70}];n.forEach((e=>{a.push({field:e.id,headerName:e.name})}));const l=o.map(((e,t)=>({id:t,...e})));return t(ye,{title:e,subtitle:r,dense:i,children:t(b,{item:!0,xs:12,children:t(ue,{rows:l,columns:a,density:i?"compact":"standard",disableRowSelectionOnClick:!0,pageSizeOptions:[5],initialState:{pagination:{paginationModel:{pageSize:5}}},sx:{height:400}})})})},Ut=({field:{name:e,description:r,value:n},instance:o,dense:i})=>{const a=pe();return t(ye,{title:e,subtitle:r,dense:i,children:n.map((e=>{const{id:r,xs:n,sm:l,md:c,lg:s,xl:u}=e,d=a.increment(e);return t(Wt,{xs:n,sm:l,md:c,lg:s,xl:u,bordered:d,children:qt(e,o,{dense:i})},r)}))})},Yt=({model:e,instance:r,dense:n})=>{const o=pe();return t(b,{container:!0,spacing:n?1:2,children:e.fields.map((e=>{const{id:i,type:a,xs:l=3,sm:c=0,md:s=0,lg:u=0,xl:d=0}=e;if("group"===a)return o.increment({xs:12}),t(b,{item:!0,xs:12,children:t(Ut,{field:e,instance:r[i],dense:n})},i);if("group[]"===a)return o.increment({xs:12}),t(b,{item:!0,xs:12,children:t(Bt,{field:e,instance:r[i],dense:n})},i);const f=o.increment(e);return t(Wt,{xs:l,sm:c,md:s,lg:u,xl:d,bordered:f,children:qt(e,r,{dense:n})},i)}))})},Ht=({model:r,modelName:n,basePath:o="",onRequestItem:i,itemRequest:l,detailsItem:c})=>{const{id:s=""}=a();return f((()=>{i(s)}),[s]),e(Ne,{loading:l.loading,children:[t(Le,{title:s,preset:"default",breadcrumbs:[{id:"list",text:n,link:`${o}/`},{id:"detail",text:s,link:`${o}/${s}`}]}),t(We,{children:c&&t(Yt,{model:r,instance:c})})]})},Jt=r=>{const{updateFeature:n=!0,addFeature:o=!0,detailsFeature:i=!0}=r;return e(l,{children:[t(c,{path:"",element:t(It,{...r})}),i&&t(c,{path:":id",element:t(Ht,{...r})}),o&&t(c,{path:"add",element:t(jt,{...r})}),n&&t(c,{path:":id/update",element:t(qe,{...r})})]})},Gt={idle:!0},Xt={loading:!0},Kt={success:!0};export{Gt as IdleRequest,Xt as LoadingRequest,Jt as ModelRouter,Kt as SuccessRequest};
|
|
23
|
+
*/vt={exports:{}},"production"===process.env.NODE_ENV?vt.exports=function(){if(ht)return bt;ht=1;var e,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.server_context"),s=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen");function y(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:switch(e=e.type){case n:case i:case o:case u:case d:return e;default:switch(e=e&&e.$$typeof){case c:case l:case s:case m:case f:case a:return e;default:return p}}case r:return p}}}return e=Symbol.for("react.module.reference"),bt.ContextConsumer=l,bt.ContextProvider=a,bt.Element=t,bt.ForwardRef=s,bt.Fragment=n,bt.Lazy=m,bt.Memo=f,bt.Portal=r,bt.Profiler=i,bt.StrictMode=o,bt.Suspense=u,bt.SuspenseList=d,bt.isAsyncMode=function(){return!1},bt.isConcurrentMode=function(){return!1},bt.isContextConsumer=function(e){return y(e)===l},bt.isContextProvider=function(e){return y(e)===a},bt.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},bt.isForwardRef=function(e){return y(e)===s},bt.isFragment=function(e){return y(e)===n},bt.isLazy=function(e){return y(e)===m},bt.isMemo=function(e){return y(e)===f},bt.isPortal=function(e){return y(e)===r},bt.isProfiler=function(e){return y(e)===i},bt.isStrictMode=function(e){return y(e)===o},bt.isSuspense=function(e){return y(e)===u},bt.isSuspenseList=function(e){return y(e)===d},bt.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===i||t===o||t===u||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===m||t.$$typeof===f||t.$$typeof===a||t.$$typeof===l||t.$$typeof===s||t.$$typeof===e||void 0!==t.getModuleId)},bt.typeOf=y,bt}():vt.exports=(gt||(gt=1,"production"!==process.env.NODE_ENV&&function(){var e,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.server_context"),s=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen");function y(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var y=e.type;switch(y){case n:case i:case o:case u:case d:return y;default:var h=y&&y.$$typeof;switch(h){case c:case l:case s:case m:case f:case a:return h;default:return p}}case r:return p}}}e=Symbol.for("react.module.reference");var h=l,b=a,g=t,v=s,x=n,S=m,w=f,$=r,C=i,E=o,k=u,O=d,T=!1,P=!1;xt.ContextConsumer=h,xt.ContextProvider=b,xt.Element=g,xt.ForwardRef=v,xt.Fragment=x,xt.Lazy=S,xt.Memo=w,xt.Portal=$,xt.Profiler=C,xt.StrictMode=E,xt.Suspense=k,xt.SuspenseList=O,xt.isAsyncMode=function(e){return T||(T=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1},xt.isConcurrentMode=function(e){return P||(P=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1},xt.isContextConsumer=function(e){return y(e)===l},xt.isContextProvider=function(e){return y(e)===a},xt.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},xt.isForwardRef=function(e){return y(e)===s},xt.isFragment=function(e){return y(e)===n},xt.isLazy=function(e){return y(e)===m},xt.isMemo=function(e){return y(e)===f},xt.isPortal=function(e){return y(e)===r},xt.isProfiler=function(e){return y(e)===i},xt.isStrictMode=function(e){return y(e)===o},xt.isSuspense=function(e){return y(e)===u},xt.isSuspenseList=function(e){return y(e)===d},xt.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===i||t===o||t===u||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===m||t.$$typeof===f||t.$$typeof===a||t.$$typeof===l||t.$$typeof===s||t.$$typeof===e||void 0!==t.getModuleId)},xt.typeOf=y}()),xt),"undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),Ye.exports.oneOfType([Ye.exports.func,Ye.exports.object]);const St={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px"};const wt=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function $t(e,t,r,n){const o=e[t];if(null==o||!wt(o)){const e=function(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":Number.isFinite(e)?e!==Math.floor(e)?"float":"number":"Infinity";case"object":return null===e?"null":e.constructor.name;default:return t}}(o);return new RangeError(`Invalid ${n} \`${t}\` of type \`${e}\` supplied to \`${r}\`, expected \`integer\`.`)}return null}function Ct(e,t,...r){return void 0===e[t]?null:$t(e,t,...r)}function Et(){return null}Ct.isRequired=$t,Et.isRequired=Et,process.env.NODE_ENV;const kt=({order:r,orderBy:n,headCells:o,onRequestSort:i})=>t(Q,{children:t(W,{children:o.map((o=>{return t(q,{variant:"head",padding:o.disablePadding?"none":"normal",sortDirection:n===o.id&&r,sx:{fontWeight:"bold"},children:o.sort?e(K,{active:n===o.id,direction:n===o.id?r:"asc",onClick:(a=o.id,()=>{i(a)}),children:[o.label,n===o.id?t(g,{component:"span",sx:St,children:"desc"===r?"sorted descending":"sorted ascending"}):null]}):o.label},String(o.id));var a}))})});function Ot(e,t,r){return t[r]<e[r]?-1:t[r]>e[r]?1:0}const Tt=({children:n,data:o,search:i,columns:a,defaultSort:l,defaultOrder:c="asc",loading:s=!1})=>{const[d,f]=u(""),[m,p]=u(c),[y,h]=u(l),b=o.slice().filter(function(e,t){return r=>!t||e.some((e=>{let n=r[e.id];return n?.toLowerCase&&(n=n.toLowerCase()),n?.toString().includes(t.toLowerCase())}))}(a,d)).sort(function(e,t){return"desc"===e?(e,r)=>Ot(e,r,t):(e,r)=>-Ot(e,r,t)}(m,y));return t(r,{children:e(g,{sx:{paddingX:1,paddingBottom:2},children:[i&&t(g,{paddingY:2,children:t(k,{fullWidth:!0,placeholder:"Search",InputProps:{role:"search",startAdornment:t(J,{position:"start",children:t(X,{})})},onChange:e=>f(e.target.value)})}),t(Y,{children:e(G,{children:[t(kt,{order:m,orderBy:y,headCells:a,onRequestSort:e=>{p(y===e&&"asc"===m?"desc":"asc"),h(e)}}),t(H,{children:s?t(W,{children:t(q,{colSpan:a.length,sx:{textAlign:"center"},children:t(M,{})})}):0===b.length?t(W,{children:t(q,{colSpan:a.length,sx:{textAlign:"center"},children:"No data"})}):n(b)})]})})]})})};Tt.defaultProps={defaultOrder:"asc"};const Pt=({columns:n,options:o,data:i,onClick:a,search:l,defaultSort:c,defaultOrder:s,loading:d})=>{const f=[...n,{id:"__options",label:"",disablePadding:!1,numeric:!1,sort:!1}],[m,p]=u(null);return e(r,{children:[t(Tt,{columns:f,data:i,search:l,defaultSort:c,defaultOrder:s,loading:d,children:r=>r.map(((r,n)=>e(W,{onClick:()=>a&&a(r),role:"row","aria-rowindex":n,sx:{cursor:a&&"pointer"},children:[f.map((({id:e},o)=>t(q,{role:"cell",scope:"row","aria-rowindex":n,"aria-colindex":o,children:r[e]},e.toString()))),o&&t(q,{children:t(B,{"data-testid":`options-${r.id}`,onClick:e=>{e.stopPropagation(),p({item:r,anchor:e.currentTarget})},children:t(Z,{})})})]},r.id)))}),o&&t(U,{anchorEl:m?.anchor,open:!!m,onClose:()=>p(null),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:o.map((({id:e,label:r,onClick:n})=>t(C,{onClick:()=>{m&&n(m?.item),p(null)},children:r},e)))})]})},It=({model:r,modelName:o,listData:i,listRequest:a,deleteRequest:l,basePath:c="",deleteFeature:s=!0,updateFeature:u=!0,addFeature:d=!0,detailsFeature:m=!0,onRequestList:p,onClickDeleteItem:y})=>{const h=n();f((()=>{p()}),[]),_e({title:"Item deleted",message:"The item has been deleted successfully",severity:"success"},!!l.success,{from:!1,to:!0}),_e({title:"We had an error",message:l.error||"",severity:"error"},!!l.error,{from:!1,to:!0});const b=m?e=>{h(`${c}/${e.id}`)}:void 0,g=(e,t)=>{"edit"===e?h(`${c}/${t.id}/update`):y(t)},v=[];u&&v.push({id:"edit",label:"Edit",onClick:e=>g("edit",e)}),s&&v.push({id:"remove",label:"Remove",onClick:e=>g("remove",e)});const x=[];return d&&x.push({id:"add",text:"Add",href:`${c}/add`}),e(Ne,{loading:a.loading||l.loading,children:[t(Le,{title:o,preset:"default",actions:x.length>0?x:void 0}),t(We,{children:t(Pt,{columns:r.fields.filter((({listable:e})=>e)).map((({id:e,name:t,type:r})=>({disablePadding:!1,id:e,label:t,numeric:"number"===r,sort:!1}))),data:i,defaultSort:r.fields[0].id,onClick:b,options:v.length>0?v:void 0})})]})},jt=({model:r,modelName:n,basePath:o="",onSubmitNewItem:i,newItemRequest:a})=>(_e({message:"Item added successfully",severity:"success"},!!a.success,{from:!1,to:!0}),ke(`${o}/`,!!a.success,{from:!1,to:!0}),_e({title:"We had an error",message:a.error||"",severity:"error"},!!a.error,{from:!1,to:!0}),e(Ne,{loading:a.loading,children:[t(Le,{title:`Add ${n}`,preset:"default",breadcrumbs:[{id:"list",text:n,link:`${o}/`},{id:"add",text:`Add new ${n}`,link:`${o}/add`}]}),t(We,{children:t(Ee,{model:r,saveButtonText:"Save",onSubmit:i})})]})),Rt=({onClickCancel:r,onClickSubmit:n,sx:o})=>e(J,{position:"end",sx:o,children:[t(h,{variant:"contained",size:"small",color:"error","aria-label":"cancel button",startIcon:t(ne,{sx:{fontSize:12}}),onClick:r,sx:{paddingRight:0,minWidth:0,marginRight:1}}),t(h,{variant:"contained",size:"small",color:"primary","aria-label":"submit button",startIcon:t(te,{sx:{fontSize:12}}),onClick:n,sx:{paddingRight:0,minWidth:0}})]}),Nt=(e,t)=>{const[r,n]=u(!1),[o,i]=u(e),a=()=>{n(!1),i(e)};return{isEditing:r,cancelEdit:a,editValue:o,setEditValue:i,startEdit:()=>{n(!0)},submitEdit:()=>{t(o),a()}}},zt=({dense:e,onClick:r})=>{const{typography:n}=N();return t(B,{size:"small",onClick:r,sx:{ml:e?.5:1},"aria-label":"edit button",children:t(oe,{sx:{fontSize:n.pxToRem(e?18:24)}})})},Mt=e=>`label-${e.replace(/ /g,"-")}`,_t=({label:r,hideLabel:n,tooltip:o,tooltipEnterDelay:i=2e3,children:a,dense:l,sx:c})=>{const{typography:s}=N(),u=Mt(r);return e(g,{width:1,lineHeight:l?0:void 0,sx:c,children:[!n&&t(R,{variant:l?"caption":"subtitle2",role:"label",id:u,lineHeight:l?s.pxToRem(15):void 0,children:r}),o?t(ie,{title:o,placement:"top",enterDelay:i,children:a}):a]})},Vt=({label:r,value:n,placeholder:o="-",editable:i,dense:a,onEdit:l=(()=>null)})=>{const c=Mt(r),{typography:s}=N(),{isEditing:u,editValue:d,startEdit:f,cancelEdit:m,setEditValue:p,submitEdit:y}=Nt(n,l),h={fontSize:a?s.h6.fontSize:s.h5.fontSize};return t(_t,{label:r,dense:a,children:e(g,u?{display:"flex",alignItems:"center",children:[t(ee,{size:a?"small":"medium",checked:d,onChange:e=>p(e.target.checked)}),t(Rt,{onClickCancel:m,onClickSubmit:y})]}:{display:"flex",alignItems:"center","aria-labelledby":c,role:"checkbox","aria-checked":n,children:[void 0===n?t(R,{variant:"h5",children:o}):n?t(te,{color:"success",sx:h}):t(re,{color:"error",sx:h}),i&&t(zt,{dense:a,onClick:f})]})})},At=({label:n,value:o,format:i,placeholder:a="-",editable:l,editInputType:c="datetime",dense:s,onEdit:u=(()=>null)})=>{const{isEditing:d,editValue:f,startEdit:m,cancelEdit:p,setEditValue:y,submitEdit:h}=Nt(o,u),b=Mt(n),v=o&&ae(o,i)||a;return t(_t,{label:n,hideLabel:d,tooltip:v,dense:s,sx:{display:"flex",flexDirection:"column"},children:d?t("datetime"===c?ce:"time"===c?se:le,{value:f,format:i,label:n,onChange:e=>y(e||void 0),slots:{textField:n=>t(k,{...n,size:"small",InputProps:{...n.InputProps,endAdornment:e(r,{children:[n.InputProps?.endAdornment,t(Rt,{onClickCancel:p,onClickSubmit:h,sx:{ml:2}})]}),sx:{marginY:s?.2:1}}})}}):e(g,{display:"flex",alignItems:"center","aria-labelledby":b,children:[t(R,{variant:s?"body1":"h5",noWrap:!0,children:v}),l&&t(zt,{dense:s,onClick:m})]})})},Dt=({label:r,value:n,placeholder:o="-",editable:i,dense:a,onEdit:l=(()=>null)})=>{const c=d(null),{isEditing:s,editValue:u,startEdit:m,cancelEdit:p,setEditValue:y,submitEdit:h}=Nt(n?.toString(),l),b=Mt(r),v=n?.toString()||o,x=e=>{"Enter"===e.key&&l(e.target.value)};return f((()=>(c.current?.addEventListener("keypress",x),()=>c.current?.removeEventListener("keypress",x))),[c.current]),t(_t,{hideLabel:s,label:r,tooltip:v,dense:a,children:s?t(k,{inputRef:c,value:u,label:r,size:"small",onChange:e=>y(e.target.value),InputProps:{endAdornment:t(Rt,{onClickCancel:p,onClickSubmit:h})},sx:{marginY:a?0:1}}):e(g,{display:"flex","aria-labelledby":b,children:[t(R,{variant:a?"body1":"h5",noWrap:!0,children:v}),i&&t(zt,{dense:a,onClick:m})]})})},Ft="RdsValueItem-root",Lt="RdsValueItem-content",Wt=({children:e,bordered:r=!0,...n})=>{const o=((e,t)=>{const r=`solid ${t} 1px`,n="none";if(e){if(Array.isArray(e))return e.map((e=>e?r:n));if("object"==typeof e){const t={};return Object.entries(e).forEach((([e,o])=>{t[e]=o?r:n})),t}return r}})(r,me({lightWeight:200,darkWeight:800}));return t(b,{item:!0,className:Ft,...n,children:t(g,{className:Lt,px:1,borderLeft:o,children:e})})},qt=(e,r,{dense:n}={})=>{const{id:o,name:i,type:a}=e,l=r[o];return"boolean"===a?t(Vt,{dense:n,label:i,value:l}):"date"===a||"time"===a||"datetime"===a?t(At,{dense:n,label:i,value:l,format:e.format}):"object"!=typeof l||Array.isArray(l)?t(Dt,{dense:n,label:i,value:l?.toString()}):t(Dt,{dense:n,label:i,value:JSON.stringify(l)})},Bt=({field:{name:e,description:r,value:n},instance:o,dense:i})=>{const a=[{field:"id",headerName:"ID",width:70}];n.forEach((e=>{a.push({field:e.id,headerName:e.name})}));const l=o.map(((e,t)=>({id:t,...e})));return t(ye,{title:e,subtitle:r,dense:i,children:t(b,{item:!0,xs:12,children:t(ue,{rows:l,columns:a,density:i?"compact":"standard",disableRowSelectionOnClick:!0,pageSizeOptions:[5],initialState:{pagination:{paginationModel:{pageSize:5}}},sx:{height:400}})})})},Ut=({field:{name:e,description:r,value:n},instance:o,dense:i})=>{const a=pe();return t(ye,{title:e,subtitle:r,dense:i,children:n.map((e=>{const{id:r,xs:n,sm:l,md:c,lg:s,xl:u}=e,d=a.increment(e);return t(Wt,{xs:n,sm:l,md:c,lg:s,xl:u,bordered:d,children:qt(e,o,{dense:i})},r)}))})},Yt=({model:e,instance:r,dense:n})=>{const o=pe();return t(b,{container:!0,spacing:n?1:2,children:e.fields.map((e=>{const{id:i,type:a,xs:l=3,sm:c=0,md:s=0,lg:u=0,xl:d=0}=e;if("group"===a)return o.increment({xs:12}),t(b,{item:!0,xs:12,children:t(Ut,{field:e,instance:r[i],dense:n})},i);if("group[]"===a)return o.increment({xs:12}),t(b,{item:!0,xs:12,children:t(Bt,{field:e,instance:r[i],dense:n})},i);const f=o.increment(e);return t(Wt,{xs:l,sm:c,md:s,lg:u,xl:d,bordered:f,children:qt(e,r,{dense:n})},i)}))})},Ht=({model:r,modelName:n,basePath:o="",onRequestItem:i,itemRequest:l,detailsItem:c})=>{const{id:s=""}=a();return f((()=>{i(s)}),[s]),e(Ne,{loading:l.loading,children:[t(Le,{title:s,preset:"default",breadcrumbs:[{id:"list",text:n,link:`${o}/`},{id:"detail",text:s,link:`${o}/${s}`}]}),t(We,{children:c&&t(Yt,{model:r,instance:c})})]})},Jt=r=>{const{updateFeature:n=!0,addFeature:o=!0,detailsFeature:i=!0}=r;return e(l,{children:[t(c,{path:"",element:t(It,{...r})}),i&&t(c,{path:":id",element:t(Ht,{...r})}),o&&t(c,{path:"add",element:t(jt,{...r})}),n&&t(c,{path:":id/update",element:t(qe,{...r})})]})},Gt={idle:!0},Xt={loading:!0},Kt={success:!0};export{Gt as IdleRequest,Xt as LoadingRequest,Jt as ModelRouter,Kt as SuccessRequest};
|
|
24
24
|
//# sourceMappingURL=index.js.map
|