@pautena/react-design-system 0.5.0 → 0.5.1
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/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/inputs/search-input/index.d.ts +1 -0
- package/dist/cjs/types/components/inputs/search-input/search-input.d.ts +19 -0
- package/dist/cjs/types/utils/forms.d.ts +2 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/inputs/search-input/index.d.ts +1 -0
- package/dist/esm/types/components/inputs/search-input/search-input.d.ts +19 -0
- package/dist/esm/types/utils/forms.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/dialogs/form-dialog/form-dialog.tsx +2 -8
- package/src/components/inputs/inputs.stories.mdx +1 -0
- package/src/components/inputs/search-input/index.ts +1 -0
- package/src/components/inputs/search-input/search-input.stories.tsx +57 -0
- package/src/components/inputs/search-input/search-input.test.tsx +165 -0
- package/src/components/inputs/search-input/search-input.tsx +218 -0
- package/src/storybook.tsx +18 -3
- package/src/tests/assertions.ts +33 -0
- package/src/utils/forms.ts +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./search-input";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SxProps, Theme } from "@mui/material";
|
|
2
|
+
export type SearchInputSize = "small" | "medium";
|
|
3
|
+
export interface SearchFilter {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
type: "text" | "number" | "boolean" | "datetime";
|
|
7
|
+
}
|
|
8
|
+
export interface SearchInputProps<T> {
|
|
9
|
+
label?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
helperText?: string;
|
|
13
|
+
size?: SearchInputSize;
|
|
14
|
+
filters?: SearchFilter[];
|
|
15
|
+
sx?: SxProps<Theme>;
|
|
16
|
+
dateFormat?: string;
|
|
17
|
+
onSearch: (data: T) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const SearchInput: <T>({ label, placeholder, helperText, size, fullWidth, dateFormat, filters, onSearch, sx, }: SearchInputProps<T>) => JSX.Element;
|
package/dist/esm/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
|
-
*/Hn={exports:{}},"production"===process.env.NODE_ENV?Hn.exports=function(){if(Ln)return qn;Ln=1;var e,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen");function v(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:switch(e=e.type){case r:case a:case o:case s:case d:return e;default:switch(e=e&&e.$$typeof){case c:case l:case u:case f:case m:case i:return e;default:return p}}case n:return p}}}return e=Symbol.for("react.module.reference"),qn.ContextConsumer=l,qn.ContextProvider=i,qn.Element=t,qn.ForwardRef=u,qn.Fragment=r,qn.Lazy=f,qn.Memo=m,qn.Portal=n,qn.Profiler=a,qn.StrictMode=o,qn.Suspense=s,qn.SuspenseList=d,qn.isAsyncMode=function(){return!1},qn.isConcurrentMode=function(){return!1},qn.isContextConsumer=function(e){return v(e)===l},qn.isContextProvider=function(e){return v(e)===i},qn.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},qn.isForwardRef=function(e){return v(e)===u},qn.isFragment=function(e){return v(e)===r},qn.isLazy=function(e){return v(e)===f},qn.isMemo=function(e){return v(e)===m},qn.isPortal=function(e){return v(e)===n},qn.isProfiler=function(e){return v(e)===a},qn.isStrictMode=function(e){return v(e)===o},qn.isSuspense=function(e){return v(e)===s},qn.isSuspenseList=function(e){return v(e)===d},qn.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===r||t===a||t===o||t===s||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===f||t.$$typeof===m||t.$$typeof===i||t.$$typeof===l||t.$$typeof===u||t.$$typeof===e||void 0!==t.getModuleId)},qn.typeOf=v,qn}():Hn.exports=(Un||(Un=1,"production"!==process.env.NODE_ENV&&function(){var e,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen");function v(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var v=e.type;switch(v){case r:case a:case o:case s:case d:return v;default:var y=v&&v.$$typeof;switch(y){case c:case l:case u:case f:case m:case i:return y;default:return p}}case n:return p}}}e=Symbol.for("react.module.reference");var y=l,h=i,E=t,b=u,g=r,x=f,C=m,w=n,S=a,k=o,O=s,I=d,$=!1,T=!1;Yn.ContextConsumer=y,Yn.ContextProvider=h,Yn.Element=E,Yn.ForwardRef=b,Yn.Fragment=g,Yn.Lazy=x,Yn.Memo=C,Yn.Portal=w,Yn.Profiler=S,Yn.StrictMode=k,Yn.Suspense=O,Yn.SuspenseList=I,Yn.isAsyncMode=function(e){return $||($=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1},Yn.isConcurrentMode=function(e){return T||(T=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1},Yn.isContextConsumer=function(e){return v(e)===l},Yn.isContextProvider=function(e){return v(e)===i},Yn.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},Yn.isForwardRef=function(e){return v(e)===u},Yn.isFragment=function(e){return v(e)===r},Yn.isLazy=function(e){return v(e)===f},Yn.isMemo=function(e){return v(e)===m},Yn.isPortal=function(e){return v(e)===n},Yn.isProfiler=function(e){return v(e)===a},Yn.isStrictMode=function(e){return v(e)===o},Yn.isSuspense=function(e){return v(e)===s},Yn.isSuspenseList=function(e){return v(e)===d},Yn.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===r||t===a||t===o||t===s||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===f||t.$$typeof===m||t.$$typeof===i||t.$$typeof===l||t.$$typeof===u||t.$$typeof===e||void 0!==t.getModuleId)},Yn.typeOf=v}()),Yn),"undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),gn.exports.oneOfType([gn.exports.func,gn.exports.object]);let Gn=0;const Jn=ye.useId;function Xn(e){if(void 0!==Jn){const t=Jn();return null!=e?e:t}return function(e){const[t,n]=ye.useState(e),r=e||t;return ye.useEffect((()=>{null==t&&(Gn+=1,n(`mui-${Gn}`))}),[t]),r}(e)}const Kn={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px"};const Qn=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function Zn(e,t,n,r){const o=e[t];if(null==o||!Qn(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 ${r} \`${t}\` of type \`${e}\` supplied to \`${n}\`, expected \`integer\`.`)}return null}function er(e,t,...n){return void 0===e[t]?null:Zn(e,t,...n)}function tr(){return null}er.isRequired=Zn,tr.isRequired=tr,process.env.NODE_ENV;var nr=function(t){var n,r=t.id,o=t.label,a=t.InputLabelProps,i=t.InputProps,l=t.fetching,c=t.loading,u=t.helperText,s=t.hexColor,d=t.size,f=t.fullWidth,p=t.sx,v=ht(t,["id","label","InputLabelProps","InputProps","fetching","loading","helperText","hexColor","size","fullWidth","sx"]),y=Xn(r),h=u&&y?"".concat(y,"-helper-text"):void 0,E=o&&y?"".concat(y,"-label"):void 0,b=s?((n={})["& .".concat(L.notchedOutline)]={borderColor:"".concat(s," !important")},n["& .".concat(q.root)]={color:s},n["& .".concat(L.input)]={color:s},n["& .".concat(U.root)]={color:s},n["& .".concat(H.bar)]={backgroundColor:s},n["& .".concat(Y.endAdornment," .").concat(G.root)]={color:s},n):{};return he.createElement(V,{sx:b,fullWidth:f},he.createElement(F,yt({size:"small"===d?"small":"normal",id:E,htmlFor:y},a),o),he.createElement(J,yt({},i,{id:y,label:o,size:d,fullWidth:f,endAdornment:he.createElement(e,{position:"end"},null==i?void 0:i.endAdornment,l?he.createElement(m,{color:"inherit",size:20,sx:{ml:1}}):null),sx:p},v)),c&&he.createElement(_,{color:"inherit",sx:{position:"absolute",left:0,right:0,bottom:0}}),u&&he.createElement(X,{id:h},u))},rr=function(e){var t=e.label,n=e.loading,r=e.fetching,o=e.options,a=e.helperText,i=e.color,l=e.onChangeValue,c=void 0===l?function(){return null}:l,u=e.sx,s=ht(e,["label","loading","fetching","options","helperText","color","onChangeValue","sx"]),d=n||r;return he.createElement(K,yt({loading:d,options:r?[]:o,onChange:function(e,t){return c(t)}},s,{renderInput:function(e){return he.createElement(nr,yt({},e,{label:t,fullWidth:!0,fetching:r,loading:n,hexColor:i,helperText:a}))},sx:u}))};function or(e){var t=e.children,r=e.index,o=Kt()[0],a=o===r;return Array.isArray(r)&&(a=r.includes(o)),he.createElement("div",{role:"tabpanel",hidden:!a,id:"simple-tabpanel-".concat(r),"aria-labelledby":"simple-tab-".concat(r)},a&&he.createElement(n,{sx:{p:3}},t))}var ar=$(g)((function(e){var t,n=e.theme;return(t={})["&.".concat(Q.root)]={backgroundColor:n.palette.grey[100]},t})),ir=function(e){var t=e.children,n=e.tabs,r=Kt(),o=r[0],a=r[1];return he.createElement(l,null,he.createElement(ar,{value:o,onChange:function(e,t){return a(t)}},n.map((function(e){return he.createElement(x,{key:e,label:e})}))),t)},lr=function(e){var t=e.order,r=e.orderBy,o=e.headCells,a=e.onRequestSort;return he.createElement(Z,null,he.createElement(ee,null,o.map((function(e){return he.createElement(te,{variant:"head",key:String(e.id),padding:e.disablePadding?"none":"normal",sortDirection:r===e.id&&t,sx:{fontWeight:"bold"}},e.sort?he.createElement(ne,{active:r===e.id,direction:r===e.id?t:"asc",onClick:(o=e.id,function(){a(o)})},e.label,r===e.id?he.createElement(n,{component:"span",sx:Kn},"desc"===t?"sorted descending":"sorted ascending"):null):e.label);var o}))))};function cr(e,t,n){return t[n]<e[n]?-1:t[n]>e[n]?1:0}var ur=function(t){var r=t.children,o=t.data,i=t.search,l=t.columns,c=t.defaultSort,u=t.defaultOrder,s=void 0===u?"asc":u,d=t.loading,f=void 0!==d&&d,p=Ee(""),v=p[0],y=p[1],h=Ee(s),E=h[0],b=h[1],g=Ee(c),x=g[0],C=g[1],w=o.slice().filter(function(e,t){return function(n){return!t||e.some((function(e){var r=n[e.id];return(null==r?void 0:r.toLowerCase)&&(r=r.toLowerCase()),null==r?void 0:r.toString().includes(t.toLowerCase())}))}}(l,v)).sort(function(e,t){return"desc"===e?function(e,n){return cr(e,n,t)}:function(e,n){return-cr(e,n,t)}}(E,x));return he.createElement(he.Fragment,null,he.createElement(n,{sx:{paddingX:1,paddingBottom:2}},i&&he.createElement(n,{paddingY:2},he.createElement(a,{fullWidth:!0,placeholder:"Search",InputProps:{role:"search",startAdornment:he.createElement(e,{position:"start"},he.createElement(He,null))},onChange:function(e){return y(e.target.value)}})),he.createElement(re,null,he.createElement(oe,null,he.createElement(lr,{order:E,orderBy:x,headCells:l,onRequestSort:function(e){b(x===e&&"asc"===E?"desc":"asc"),C(e)}}),he.createElement(ae,null,f?he.createElement(ee,null,he.createElement(te,{colSpan:l.length,sx:{textAlign:"center"}},he.createElement(m,null))):0===w.length?he.createElement(ee,null,he.createElement(te,{colSpan:l.length,sx:{textAlign:"center"}},"No data")):r(w))))))};ur.defaultProps={defaultOrder:"asc"};var sr,dr=function(e){var t=e.children,n=e.data,r=e.loading,o=e.columns,a=e.defaultSort,i=e.defaultOrder,l=e.onRequestSort,c=Ee({orderBy:a,order:i||"asc"}),u=c[0],s=c[1];return he.createElement(he.Fragment,null,he.createElement(re,null,he.createElement(oe,null,he.createElement(lr,{order:u.order,orderBy:u.orderBy,headCells:o,onRequestSort:function(e){s((function(t){var n=t.orderBy,r=t.order,o=n===e&&"asc"===r?"desc":"asc";return l(e,o),{orderBy:e,order:o}}))}}),he.createElement(ae,null,r?he.createElement(ee,null,he.createElement(te,{colSpan:o.length,sx:{textAlign:"center"}},he.createElement(m,null))):n.map((function(e,n){return t(e,n)}))))))},mr=function(e){var o=e.title,a=e.subtitle,i=e.icon,l=e.iconSize,c=void 0===l?200:l,u=e.actions;return he.createElement(n,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",textAlign:"center"},i&&i({size:c,color:"primary"}),he.createElement(r,{variant:"h4",role:"heading","aria-level":1},o),he.createElement(r,{variant:"subtitle1",role:"heading","aria-level":2,sx:{mt:2}},a),u&&he.createElement(n,{sx:{pt:2}},u.map((function(e,n){var r=e.id,o=e.text,a=e.href,i=e.onClick;return he.createElement(t,{key:r,role:"button",variant:"contained",href:a,onClick:i,sx:{mr:n<u.length-1?2:0}},o)}))))},fr=function(e){var t=e.width,r=void 0===t?"100%":t,o=e.animation,a=void 0!==o&&o;return he.createElement(n,{width:r},he.createElement(ie,{animation:a,variant:"rectangular",height:118}),he.createElement(ie,{animation:a,variant:"rectangular",height:16,sx:{my:1}}),he.createElement(ie,{animation:a,variant:"rectangular",width:"80%",height:16}))},pr=function(e){var t=e.size,n=void 0===t?20:t;return he.createElement(s,{container:!0,spacing:2},Bt(n,0).map((function(e,t){return he.createElement(s,{item:!0,key:t,xs:4},he.createElement(fr,{width:1}))})))},vr=function(e){var t=e.size,n=void 0===t?20:t,r=e.children,o=e.p;return he.createElement(E,{component:"main",sx:{p:o},"data-testid":"content-placeholder-test"},r,he.createElement(pr,{size:n}))},yr=function(e){var t=e.count,n=void 0===t?3:t,o=e.units,a=void 0===o?"paragraph":o,i=e.variant,l=void 0===i?"body1":i;return he.createElement(r,{variant:l},it({count:n,units:a}))},hr=((sr={})["& .".concat(le.message)]={width:1},sr),Er=function(e){var t=e.severity,r=e.iconMapping,o=e.title,a=e.message,l=e.metadata,c=e.onClose,u=Ee(!1),s=u[0],d=u[1];return he.createElement(f,{severity:t,iconMapping:r,onClose:c,action:he.createElement(n,{display:"flex",flexDirection:"column"},he.createElement(i,{color:"inherit",onClick:c},he.createElement(Te,{fontSize:"small"})),l&&he.createElement(i,{color:"inherit",onClick:function(){return d((function(e){return!e}))}},s?he.createElement(rt,{fontSize:"small"}):he.createElement(ot,{fontSize:"small"}))),sx:hr},he.createElement(n,{sx:{w:1}},o&&he.createElement(p,null,o),a,l&&he.createElement(N,{in:s,sx:{mt:2}},he.createElement(nn,{content:l}))))},br=function(e){var r=e.open,o=e.title,a=e.component,l=e.componentProps,c=void 0===l?{}:l,u=e.disabled,s=e.actions,d=void 0===s?[]:s,f=e.children,p=e.loading,v=e.cancelable,y=e.callCloseWhenCancel,h=void 0===y||y,E=e.acceptable,b=e.acceptText,g=void 0===b?"Accept":b,x=e.cancelText,C=void 0===x?"Cancel":x,w=e.onAccept,S=e.onCancel,k=void 0===S?function(){return null}:S,O=e.onClose,I=e.acceptType,$=void 0===I?"button":I,T=d.length>0||E||v;return he.createElement(ce,{open:r,onClose:O},he.createElement(ue,{sx:{display:"flex",alignItems:"center"}},o,p&&!E&&he.createElement(m,{size:20,sx:{ml:2,color:function(e){return e.palette.grey[500]}}}),he.createElement(i,{disabled:u,"aria-label":"close",onClick:O,sx:{position:"absolute",right:8,top:8,color:function(e){return e.palette.grey[500]}}},he.createElement(Te,null))),he.createElement(n,yt({component:a},c),he.createElement(se,{dividers:!0},f),T&&he.createElement(de,null,d.map((function(e){var n=e.id,r=e.text,o=e.type,a=void 0===o?"button":o,i=e.onClick,l=e.color,c=void 0===l?"primary":l;return he.createElement(t,{key:n,type:a,disabled:u,onClick:i,color:c},r)})),v&&he.createElement(t,{color:"error",disabled:u,onClick:function(){k(),h&&O()}},C),E&&he.createElement(at,{type:$,loading:p,disabled:u,onClick:w},g))))},gr=function(e){var t=e.open,n=e.title,r=e.loading,o=e.disabled,a=e.confirmText,i=void 0===a?"Confirm":a,l=e.cancelText,c=void 0===l?"Cancel":l,u=e.children,s=e.onConfirm,d=e.onCancel;return he.createElement(br,{title:n,loading:r,disabled:r||o,open:t,onClose:d,acceptable:!0,cancelable:!0,callCloseWhenCancel:!1,acceptText:i,cancelText:c,onCancel:d,onAccept:s},u)},xr=function(e){var t=e.open,n=e.title,r=e.loading,o=e.disabled,a=e.submitText,i=void 0===a?"Submit":a,l=e.cancelText,c=void 0===l?"Cancel":l,u=e.children,s=e.onSubmit,d=e.onCancel;return he.createElement(br,{component:"form",componentProps:{onSubmit:function(e){e.preventDefault();var t=new FormData(e.currentTarget),n={};t.forEach((function(e,t){n[t]=e})),s(n)}},title:n,loading:r,disabled:r||o,open:t,onClose:d,callCloseWhenCancel:!1,cancelable:!0,acceptable:!0,cancelText:c,onCancel:d,acceptText:i,acceptType:"submit"},u)},Cr=function(e){void 0===e&&(e=!1);var t=Ee(e),n=t[0],r=t[1];return{isOpen:n,open:function(){return r(!0)},close:function(){return r(!1)},setIsOpen:r}},wr=Ne("div")((function(e){var t=e.theme;return yt({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:t.spacing(0,1)},t.mixins.toolbar)})),Sr=function(e){var t=e.children,r=t[0],o=t[1],a=t[2];return he.createElement(n,{sx:{display:"flex"}},he.createElement(un,null,r,o,he.createElement(n,{sx:{flexGrow:1}},he.createElement(wr,null),a)))},kr=function(e){var t=e.loading,r=e.children,o=r[0],a=r[1];return he.createElement(Qt,null,he.createElement(n,{display:"flex",flexDirection:"column",height:1},o,t?he.createElement(kt,null):a))},Or=function(e,t){var n=e.id,r=e.name,o=e.type,a=t[n];return"boolean"===o?he.createElement(vt,{label:r,value:a}):"date"===o||"time"===o||"datetime"===o?he.createElement(bt,{label:r,value:a,format:e.format}):he.createElement(ft,{label:r,value:null==a?void 0:a.toString()})},Ir=function(e){var t=e.field,n=t.name,r=t.description,o=t.value,a=e.instance;return he.createElement(wt,{title:n,subtitle:r},o.map((function(e){var t=e.id,n=e.xs,r=e.sm,o=e.md,i=e.lg,l=e.xl;return he.createElement(Ct,{key:t,xs:n,sm:r,md:o,lg:i,xl:l},Or(e,a))})))},$r=function(e){var t=e.model,n=e.instance;return he.createElement(s,{container:!0,spacing:2},t.fields.map((function(e){var t=e.id,r=e.type,o=e.xs,a=void 0===o?3:o,i=e.sm,l=e.md,c=e.lg,u=e.xl;return"group"===r?he.createElement(s,{item:!0,key:t,xs:12},he.createElement(Ir,{field:e,instance:n[t]})):he.createElement(s,{item:!0,key:t,xs:a,sm:i,md:l,lg:c,xl:u},he.createElement(pt,null,Or(e,n)))})))},Tr={string:"",number:0,boolean:!1,enum:"",multienum:[],date:new Date(1970,0,1,0,0),time:new Date(1970,0,1,0,0),datetime:new Date(1970,0,1,0,0),group:{}},Pr=function(e,t){return t&&t[e.id]||"default"in e&&e.default||Tr[e.type]},jr=function(e,t){void 0===t&&(t=void 0);var n={};return e.fields.forEach((function(e){if("group"===e.type){var r={};e.value.forEach((function(n){r[n.id]=Pr(n,t&&t[e.id])})),n[e.id]=r}else n[e.id]=Pr(e,t)})),n},Rr=function(e){var o=e.model,i=e.saveButtonText,c=e.onSubmit,u=e.initialValues,d=ke((function(){return jr(o,u)}),[o,u]),m=Ee(d),f=m[0],p=m[1],v=function(e,t,n){p((function(r){var o,a={};return t?a[t]=yt(yt({},r[t]),((o={})[e]=n,o)):a[e]=n,yt(yt({},r),a)}))},y=function(e,t,n){v(n,t,e)},h=function(e,t){void 0===t&&(t=void 0);var o,i=gt({lightWeight:200,darkWeight:800}),c=e.id,u=e.type,d=e.name,m=e.description,p=e.xs,E=e.sm,b=e.md,g=e.lg,x=e.xl,C=t?f[t][c]:f[c];return o="group"===u?he.createElement(l,null,he.createElement(n,{bgcolor:i,px:2,py:1,mb:2},he.createElement(r,{variant:"h6",role:"heading","aria-level":1},d),he.createElement(r,{variant:"body2",role:"heading","aria-level":2},m)),he.createElement(s,{container:!0,spacing:2,sx:{p:2}},e.value.map((function(e){return h(e,c)})))):"boolean"===u?he.createElement(n,{sx:{height:1,display:"flex",alignItems:"center"}},he.createElement(me,{control:he.createElement(fe,{name:c,onChange:function(e){return function(e,t){e.preventDefault(),v(e.target.name,t,e.target.checked)}(e,t)},checked:C}),label:d})):"enum"===u?he.createElement(V,{fullWidth:!0},he.createElement(F,{id:"".concat(c,"-select-label")},d),he.createElement(W,{labelId:"".concat(c,"-select-label"),id:"".concat(c,"-select"),value:C,label:d,name:c,onChange:function(e){return function(e,t){e.preventDefault(),v(e.target.name,t,e.target.value)}(e,t)},required:!0},e.value.map((function(e){return he.createElement(pe,{key:e,value:e},e)})))):"multienum"===u?he.createElement(V,{fullWidth:!0},he.createElement(F,{id:"".concat(c,"-select-label")},d),he.createElement(W,{labelId:"".concat(c,"-select-label"),id:"".concat(c,"-select"),value:C||[],renderValue:function(e){return e.join(", ")},label:d,name:c,onChange:function(e){return function(e,t){e.preventDefault();var n=e.target.value,r="string"==typeof n?n.split(","):n;v(e.target.name,t,r)}(e,t)},required:!0,multiple:!0},e.value.map((function(e){return he.createElement(pe,{key:e,value:e},he.createElement(fe,{checked:(C||[]).includes(e)}),he.createElement(z,{primary:e}))})))):"date"===u?he.createElement(ze,{label:d,format:e.format,value:C,onChange:function(e){return y(e,t,c)}}):"time"===u?he.createElement(Re,{label:d,format:e.format,value:C,onChange:function(e){return y(e,t,c)}}):"datetime"===u?he.createElement(je,{label:d,format:e.format,value:C,onChange:function(e){return y(e,t,c)}}):he.createElement(a,{required:!0,type:u,label:d,name:c,variant:"outlined",fullWidth:!0,value:C,onChange:function(e){return function(e,t,n){e.preventDefault();var r=e.target.value;"number"===n&&"string"==typeof r&&(r=parseInt(e.target.value)),v(e.target.name,t,r)}(e,t,u)}}),he.createElement(s,{item:!0,key:c,xs:p,sm:E,md:b,lg:g,xl:x},o)};return he.createElement(s,{container:!0,component:"form",spacing:2,onSubmit:function(e){e.preventDefault(),c(f)}},o.fields.map((function(e){return h(e)})),he.createElement(s,{item:!0,xs:12},he.createElement(t,{type:"submit",variant:"contained"},i)))},Mr=function(e,t,n){var r=n.from,o=n.to,a=Ce(),i=Xe();we((function(){a.current===r&&t===o&&i(e),a.current=t}),[t])},zr=function(e){var t=e.model,n=e.modelName,r=e.basePath,o=void 0===r?"":r,a=e.submitUpdateItemRequest,i=e.updateItemRequest,l=e.updateItem,c=e.onSubmitUpdateItem,u=e.onRequestUpdateItem,s=Ke().id,d=void 0===s?"":s,m=i.loading||a.loading;return we((function(){u(d)}),[d]),Gt({title:"Item updated",message:"The item ".concat(d," has been updated successfully"),severity:"success"},!!a.success,{from:!1,to:!0}),Mr("".concat(o,"/"),!!a.success,{from:!1,to:!0}),Gt({title:"We had an error",message:a.error||"",severity:"error"},!!a.error,{from:!1,to:!0}),he.createElement(kr,{loading:m},he.createElement(Zt,{title:"Edit ".concat(d),preset:"default",breadcrumbs:[{id:"list",text:n,link:"".concat(o,"/")},{id:"update",text:"Edit ".concat(d),link:"".concat(o,"/").concat(d,"/update")}]}),he.createElement(rn,null,he.createElement(Rr,{model:t,initialValues:l,saveButtonText:"Save",onSubmit:c})))},Nr=function(e){var t=e.columns,n=e.options,r=e.data,o=e.onClick,a=e.search,l=e.defaultSort,c=e.defaultOrder,u=e.loading,s=Et(Et([],t,!0),[{id:"__options",label:"",disablePadding:!1,numeric:!1,sort:!1}],!1),d=he.useState(null),m=d[0],f=d[1];return he.createElement(he.Fragment,null,he.createElement(ur,{columns:s,data:r,search:a,defaultSort:l,defaultOrder:c,loading:u},(function(e){return e.map((function(e,t){return he.createElement(ee,{key:e.id,onClick:function(){return o&&o(e)},role:"row","aria-rowindex":t,sx:{cursor:o&&"pointer"}},s.map((function(n,r){var o=n.id;return he.createElement(te,{role:"cell",scope:"row",key:o.toString(),"aria-rowindex":t,"aria-colindex":r},e[o])})),n&&he.createElement(te,null,he.createElement(i,{"data-testid":"options-".concat(e.id),onClick:function(t){t.stopPropagation(),f({item:e,anchor:t.currentTarget})}},he.createElement(lt,null))))}))})),n&&he.createElement(ve,{anchorEl:null==m?void 0:m.anchor,open:!!m,onClose:function(){return f(null)},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"}},n.map((function(e){var t=e.id,n=e.label,r=e.onClick;return he.createElement(pe,{key:t,onClick:function(){m&&r(null==m?void 0:m.item),f(null)}},n)}))))},Dr=function(e){var t=e.model,n=e.modelName,r=e.listData,o=e.listRequest,a=e.deleteRequest,i=e.basePath,l=void 0===i?"":i,c=e.deleteFeature,u=void 0===c||c,s=e.updateFeature,d=void 0===s||s,m=e.addFeature,f=void 0===m||m,p=e.detailsFeature,v=void 0===p||p,y=e.onRequestList,h=e.onClickDeleteItem,E=Xe();we((function(){y()}),[]),Gt({title:"Item deleted",message:"The item has been deleted successfully",severity:"success"},!!a.success,{from:!1,to:!0}),Gt({title:"We had an error",message:a.error||"",severity:"error"},!!a.error,{from:!1,to:!0});var b=v?function(e){E("".concat(l,"/").concat(e.id))}:void 0,g=function(e,t){"edit"===e?E("".concat(l,"/").concat(t.id,"/update")):h(t)},x=[];d&&x.push({id:"edit",label:"Edit",onClick:function(e){return g("edit",e)}}),u&&x.push({id:"remove",label:"Remove",onClick:function(e){return g("remove",e)}});var C=[];return f&&C.push({id:"add",text:"Add",href:"".concat(l,"/add")}),he.createElement(kr,{loading:o.loading||a.loading},he.createElement(Zt,{title:n,preset:"default",actions:C.length>0?C:void 0}),he.createElement(rn,null,he.createElement(Nr,{columns:t.fields.filter((function(e){return e.listable})).map((function(e){return{disablePadding:!1,id:e.id,label:e.name,numeric:"number"===e.type,sort:!1}})),data:r,defaultSort:t.fields[0].id,onClick:b,options:x.length>0?x:void 0})))},Ar=function(e){var t=e.model,n=e.modelName,r=e.basePath,o=void 0===r?"":r,a=e.onSubmitNewItem,i=e.newItemRequest;return Gt({message:"Item added successfully",severity:"success"},!!i.success,{from:!1,to:!0}),Mr("".concat(o,"/"),!!i.success,{from:!1,to:!0}),Gt({title:"We had an error",message:i.error||"",severity:"error"},!!i.error,{from:!1,to:!0}),he.createElement(kr,{loading:i.loading},he.createElement(Zt,{title:"Add ".concat(n),preset:"default",breadcrumbs:[{id:"list",text:n,link:"".concat(o,"/")},{id:"add",text:"Add new ".concat(n),link:"".concat(o,"/add")}]}),he.createElement(rn,null,he.createElement(Rr,{model:t,saveButtonText:"Save",onSubmit:a})))},Vr=function(e){var t=e.model,n=e.modelName,r=e.basePath,o=void 0===r?"":r,a=e.onRequestItem,i=e.itemRequest,l=e.detailsItem,c=Ke().id,u=void 0===c?"":c;return we((function(){a(u)}),[u]),he.createElement(kr,{loading:i.loading},he.createElement(Zt,{title:u,preset:"default",breadcrumbs:[{id:"list",text:n,link:"".concat(o,"/")},{id:"detail",text:u,link:"".concat(o,"/").concat(u)}]}),he.createElement(rn,null,l&&he.createElement($r,{model:t,instance:l})))},Fr=function(e){var t=e.updateFeature,n=void 0===t||t,r=e.addFeature,o=void 0===r||r,a=e.detailsFeature,i=void 0===a||a;return he.createElement(Qe,null,he.createElement(Ze,{path:"",element:he.createElement(Dr,yt({},e))}),i&&he.createElement(Ze,{path:":id",element:he.createElement(Vr,yt({},e))}),o&&he.createElement(Ze,{path:"add",element:he.createElement(Ar,yt({},e))}),n&&he.createElement(Ze,{path:":id/update",element:he.createElement(zr,yt({},e))}))},Wr={idle:!0},_r={loading:!0},Br={success:!0};export{Sr as AppBarWithDrawerLayout,nn as Board,br as BootstrapDialog,At as Bullet,on as CenterContainer,gr as ConfirmDialog,rn as Content,vr as ContentPlaceholder,st as DefaultPlaceholder,ln as Drawer,pn as DrawerContent,It as DrawerContext,dn as DrawerItem,un as DrawerProvider,fn as DrawerSection,rr as EnhancedAutocomplete,dr as EnhancedRemoteTable,yn as EnhancedSelect,ur as EnhancedTable,lr as EnhancedTableHead,Er as ExpandableAlert,xr as FormDialog,wt as GroupValueCard,Ct as GroupValueItem,Zt as Header,kr as HeaderLayout,Wr as IdleRequest,Ft as Label,kt as LoadingArea,_r as LoadingRequest,yr as LoremIpsumPlaceholder,tn as Markdown,Nt as MiniAppBar,cn as MiniDrawer,Rr as ModelForm,Fr as ModelRouter,Ut as NotificationCenterContext,Yt as NotificationCenterProvider,qt as NotificationCenterProviderUndefinedError,$r as ObjectDetails,mr as Placeholder,Ot as QueryContainer,hn as SignIn,fr as SkeletonCard,pr as SkeletonGrid,Br as SuccessRequest,ir as TabCard,Jt as TabContext,Xt as TabContextProvider,or as TabPanel,Qt as TabProvider,Nr as TableList,$t as UndefinedProvider,vt as ValueBoolean,pt as ValueCard,bt as ValueDatetime,ct as ValueEditButtons,St as ValueRating,ft as ValueText,Dt as bulletClasses,Lt as getRandomItem,xt as groupValueItemClasses,Vt as labelClasses,en as markdownDefaultOptions,Bt as newArrayWithSize,jr as newInstanceFromValuesOrZeroValue,Cr as useDialog,Tt as useDrawer,ut as useEditableValueDisplay,gt as useGetDefaultThemeColor,Ht as useNotificationCenter,Gt as useNotifyWhenValueChanges,Kt as useTab};
|
|
23
|
+
*/Hn={exports:{}},"production"===process.env.NODE_ENV?Hn.exports=function(){if(Ln)return qn;Ln=1;var e,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen");function v(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:switch(e=e.type){case r:case a:case o:case s:case d:return e;default:switch(e=e&&e.$$typeof){case c:case l:case u:case f:case m:case i:return e;default:return p}}case n:return p}}}return e=Symbol.for("react.module.reference"),qn.ContextConsumer=l,qn.ContextProvider=i,qn.Element=t,qn.ForwardRef=u,qn.Fragment=r,qn.Lazy=f,qn.Memo=m,qn.Portal=n,qn.Profiler=a,qn.StrictMode=o,qn.Suspense=s,qn.SuspenseList=d,qn.isAsyncMode=function(){return!1},qn.isConcurrentMode=function(){return!1},qn.isContextConsumer=function(e){return v(e)===l},qn.isContextProvider=function(e){return v(e)===i},qn.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},qn.isForwardRef=function(e){return v(e)===u},qn.isFragment=function(e){return v(e)===r},qn.isLazy=function(e){return v(e)===f},qn.isMemo=function(e){return v(e)===m},qn.isPortal=function(e){return v(e)===n},qn.isProfiler=function(e){return v(e)===a},qn.isStrictMode=function(e){return v(e)===o},qn.isSuspense=function(e){return v(e)===s},qn.isSuspenseList=function(e){return v(e)===d},qn.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===r||t===a||t===o||t===s||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===f||t.$$typeof===m||t.$$typeof===i||t.$$typeof===l||t.$$typeof===u||t.$$typeof===e||void 0!==t.getModuleId)},qn.typeOf=v,qn}():Hn.exports=(Un||(Un=1,"production"!==process.env.NODE_ENV&&function(){var e,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen");function v(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var v=e.type;switch(v){case r:case a:case o:case s:case d:return v;default:var y=v&&v.$$typeof;switch(y){case c:case l:case u:case f:case m:case i:return y;default:return p}}case n:return p}}}e=Symbol.for("react.module.reference");var y=l,h=i,E=t,b=u,g=r,x=f,C=m,w=n,S=a,k=o,O=s,I=d,$=!1,T=!1;Yn.ContextConsumer=y,Yn.ContextProvider=h,Yn.Element=E,Yn.ForwardRef=b,Yn.Fragment=g,Yn.Lazy=x,Yn.Memo=C,Yn.Portal=w,Yn.Profiler=S,Yn.StrictMode=k,Yn.Suspense=O,Yn.SuspenseList=I,Yn.isAsyncMode=function(e){return $||($=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1},Yn.isConcurrentMode=function(e){return T||(T=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1},Yn.isContextConsumer=function(e){return v(e)===l},Yn.isContextProvider=function(e){return v(e)===i},Yn.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},Yn.isForwardRef=function(e){return v(e)===u},Yn.isFragment=function(e){return v(e)===r},Yn.isLazy=function(e){return v(e)===f},Yn.isMemo=function(e){return v(e)===m},Yn.isPortal=function(e){return v(e)===n},Yn.isProfiler=function(e){return v(e)===a},Yn.isStrictMode=function(e){return v(e)===o},Yn.isSuspense=function(e){return v(e)===s},Yn.isSuspenseList=function(e){return v(e)===d},Yn.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===r||t===a||t===o||t===s||t===d||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===f||t.$$typeof===m||t.$$typeof===i||t.$$typeof===l||t.$$typeof===u||t.$$typeof===e||void 0!==t.getModuleId)},Yn.typeOf=v}()),Yn),"undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),gn.exports.oneOfType([gn.exports.func,gn.exports.object]);let Gn=0;const Jn=ye.useId;function Xn(e){if(void 0!==Jn){const t=Jn();return null!=e?e:t}return function(e){const[t,n]=ye.useState(e),r=e||t;return ye.useEffect((()=>{null==t&&(Gn+=1,n(`mui-${Gn}`))}),[t]),r}(e)}const Kn={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px"};const Qn=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function Zn(e,t,n,r){const o=e[t];if(null==o||!Qn(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 ${r} \`${t}\` of type \`${e}\` supplied to \`${n}\`, expected \`integer\`.`)}return null}function er(e,t,...n){return void 0===e[t]?null:Zn(e,t,...n)}function tr(){return null}er.isRequired=Zn,tr.isRequired=tr,process.env.NODE_ENV;var nr=function(t){var n,r=t.id,o=t.label,a=t.InputLabelProps,i=t.InputProps,l=t.fetching,c=t.loading,u=t.helperText,s=t.hexColor,d=t.size,f=t.fullWidth,p=t.sx,v=ht(t,["id","label","InputLabelProps","InputProps","fetching","loading","helperText","hexColor","size","fullWidth","sx"]),y=Xn(r),h=u&&y?"".concat(y,"-helper-text"):void 0,E=o&&y?"".concat(y,"-label"):void 0,b=s?((n={})["& .".concat(L.notchedOutline)]={borderColor:"".concat(s," !important")},n["& .".concat(q.root)]={color:s},n["& .".concat(L.input)]={color:s},n["& .".concat(U.root)]={color:s},n["& .".concat(H.bar)]={backgroundColor:s},n["& .".concat(Y.endAdornment," .").concat(G.root)]={color:s},n):{};return he.createElement(V,{sx:b,fullWidth:f},he.createElement(F,yt({size:"small"===d?"small":"normal",id:E,htmlFor:y},a),o),he.createElement(J,yt({},i,{id:y,label:o,size:d,fullWidth:f,endAdornment:he.createElement(e,{position:"end"},null==i?void 0:i.endAdornment,l?he.createElement(m,{color:"inherit",size:20,sx:{ml:1}}):null),sx:p},v)),c&&he.createElement(_,{color:"inherit",sx:{position:"absolute",left:0,right:0,bottom:0}}),u&&he.createElement(X,{id:h},u))},rr=function(e){var t=e.label,n=e.loading,r=e.fetching,o=e.options,a=e.helperText,i=e.color,l=e.onChangeValue,c=void 0===l?function(){return null}:l,u=e.sx,s=ht(e,["label","loading","fetching","options","helperText","color","onChangeValue","sx"]),d=n||r;return he.createElement(K,yt({loading:d,options:r?[]:o,onChange:function(e,t){return c(t)}},s,{renderInput:function(e){return he.createElement(nr,yt({},e,{label:t,fullWidth:!0,fetching:r,loading:n,hexColor:i,helperText:a}))},sx:u}))};function or(e){var t=e.children,r=e.index,o=Kt()[0],a=o===r;return Array.isArray(r)&&(a=r.includes(o)),he.createElement("div",{role:"tabpanel",hidden:!a,id:"simple-tabpanel-".concat(r),"aria-labelledby":"simple-tab-".concat(r)},a&&he.createElement(n,{sx:{p:3}},t))}var ar=$(g)((function(e){var t,n=e.theme;return(t={})["&.".concat(Q.root)]={backgroundColor:n.palette.grey[100]},t})),ir=function(e){var t=e.children,n=e.tabs,r=Kt(),o=r[0],a=r[1];return he.createElement(l,null,he.createElement(ar,{value:o,onChange:function(e,t){return a(t)}},n.map((function(e){return he.createElement(x,{key:e,label:e})}))),t)},lr=function(e){var t=e.order,r=e.orderBy,o=e.headCells,a=e.onRequestSort;return he.createElement(Z,null,he.createElement(ee,null,o.map((function(e){return he.createElement(te,{variant:"head",key:String(e.id),padding:e.disablePadding?"none":"normal",sortDirection:r===e.id&&t,sx:{fontWeight:"bold"}},e.sort?he.createElement(ne,{active:r===e.id,direction:r===e.id?t:"asc",onClick:(o=e.id,function(){a(o)})},e.label,r===e.id?he.createElement(n,{component:"span",sx:Kn},"desc"===t?"sorted descending":"sorted ascending"):null):e.label);var o}))))};function cr(e,t,n){return t[n]<e[n]?-1:t[n]>e[n]?1:0}var ur=function(t){var r=t.children,o=t.data,i=t.search,l=t.columns,c=t.defaultSort,u=t.defaultOrder,s=void 0===u?"asc":u,d=t.loading,f=void 0!==d&&d,p=Ee(""),v=p[0],y=p[1],h=Ee(s),E=h[0],b=h[1],g=Ee(c),x=g[0],C=g[1],w=o.slice().filter(function(e,t){return function(n){return!t||e.some((function(e){var r=n[e.id];return(null==r?void 0:r.toLowerCase)&&(r=r.toLowerCase()),null==r?void 0:r.toString().includes(t.toLowerCase())}))}}(l,v)).sort(function(e,t){return"desc"===e?function(e,n){return cr(e,n,t)}:function(e,n){return-cr(e,n,t)}}(E,x));return he.createElement(he.Fragment,null,he.createElement(n,{sx:{paddingX:1,paddingBottom:2}},i&&he.createElement(n,{paddingY:2},he.createElement(a,{fullWidth:!0,placeholder:"Search",InputProps:{role:"search",startAdornment:he.createElement(e,{position:"start"},he.createElement(He,null))},onChange:function(e){return y(e.target.value)}})),he.createElement(re,null,he.createElement(oe,null,he.createElement(lr,{order:E,orderBy:x,headCells:l,onRequestSort:function(e){b(x===e&&"asc"===E?"desc":"asc"),C(e)}}),he.createElement(ae,null,f?he.createElement(ee,null,he.createElement(te,{colSpan:l.length,sx:{textAlign:"center"}},he.createElement(m,null))):0===w.length?he.createElement(ee,null,he.createElement(te,{colSpan:l.length,sx:{textAlign:"center"}},"No data")):r(w))))))};ur.defaultProps={defaultOrder:"asc"};var sr,dr=function(e){var t=e.children,n=e.data,r=e.loading,o=e.columns,a=e.defaultSort,i=e.defaultOrder,l=e.onRequestSort,c=Ee({orderBy:a,order:i||"asc"}),u=c[0],s=c[1];return he.createElement(he.Fragment,null,he.createElement(re,null,he.createElement(oe,null,he.createElement(lr,{order:u.order,orderBy:u.orderBy,headCells:o,onRequestSort:function(e){s((function(t){var n=t.orderBy,r=t.order,o=n===e&&"asc"===r?"desc":"asc";return l(e,o),{orderBy:e,order:o}}))}}),he.createElement(ae,null,r?he.createElement(ee,null,he.createElement(te,{colSpan:o.length,sx:{textAlign:"center"}},he.createElement(m,null))):n.map((function(e,n){return t(e,n)}))))))},mr=function(e){var o=e.title,a=e.subtitle,i=e.icon,l=e.iconSize,c=void 0===l?200:l,u=e.actions;return he.createElement(n,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",textAlign:"center"},i&&i({size:c,color:"primary"}),he.createElement(r,{variant:"h4",role:"heading","aria-level":1},o),he.createElement(r,{variant:"subtitle1",role:"heading","aria-level":2,sx:{mt:2}},a),u&&he.createElement(n,{sx:{pt:2}},u.map((function(e,n){var r=e.id,o=e.text,a=e.href,i=e.onClick;return he.createElement(t,{key:r,role:"button",variant:"contained",href:a,onClick:i,sx:{mr:n<u.length-1?2:0}},o)}))))},fr=function(e){var t=e.width,r=void 0===t?"100%":t,o=e.animation,a=void 0!==o&&o;return he.createElement(n,{width:r},he.createElement(ie,{animation:a,variant:"rectangular",height:118}),he.createElement(ie,{animation:a,variant:"rectangular",height:16,sx:{my:1}}),he.createElement(ie,{animation:a,variant:"rectangular",width:"80%",height:16}))},pr=function(e){var t=e.size,n=void 0===t?20:t;return he.createElement(s,{container:!0,spacing:2},Bt(n,0).map((function(e,t){return he.createElement(s,{item:!0,key:t,xs:4},he.createElement(fr,{width:1}))})))},vr=function(e){var t=e.size,n=void 0===t?20:t,r=e.children,o=e.p;return he.createElement(E,{component:"main",sx:{p:o},"data-testid":"content-placeholder-test"},r,he.createElement(pr,{size:n}))},yr=function(e){var t=e.count,n=void 0===t?3:t,o=e.units,a=void 0===o?"paragraph":o,i=e.variant,l=void 0===i?"body1":i;return he.createElement(r,{variant:l},it({count:n,units:a}))},hr=((sr={})["& .".concat(le.message)]={width:1},sr),Er=function(e){var t=e.severity,r=e.iconMapping,o=e.title,a=e.message,l=e.metadata,c=e.onClose,u=Ee(!1),s=u[0],d=u[1];return he.createElement(f,{severity:t,iconMapping:r,onClose:c,action:he.createElement(n,{display:"flex",flexDirection:"column"},he.createElement(i,{color:"inherit",onClick:c},he.createElement(Te,{fontSize:"small"})),l&&he.createElement(i,{color:"inherit",onClick:function(){return d((function(e){return!e}))}},s?he.createElement(rt,{fontSize:"small"}):he.createElement(ot,{fontSize:"small"}))),sx:hr},he.createElement(n,{sx:{w:1}},o&&he.createElement(p,null,o),a,l&&he.createElement(N,{in:s,sx:{mt:2}},he.createElement(nn,{content:l}))))},br=function(e){var r=e.open,o=e.title,a=e.component,l=e.componentProps,c=void 0===l?{}:l,u=e.disabled,s=e.actions,d=void 0===s?[]:s,f=e.children,p=e.loading,v=e.cancelable,y=e.callCloseWhenCancel,h=void 0===y||y,E=e.acceptable,b=e.acceptText,g=void 0===b?"Accept":b,x=e.cancelText,C=void 0===x?"Cancel":x,w=e.onAccept,S=e.onCancel,k=void 0===S?function(){return null}:S,O=e.onClose,I=e.acceptType,$=void 0===I?"button":I,T=d.length>0||E||v;return he.createElement(ce,{open:r,onClose:O},he.createElement(ue,{sx:{display:"flex",alignItems:"center"}},o,p&&!E&&he.createElement(m,{size:20,sx:{ml:2,color:function(e){return e.palette.grey[500]}}}),he.createElement(i,{disabled:u,"aria-label":"close",onClick:O,sx:{position:"absolute",right:8,top:8,color:function(e){return e.palette.grey[500]}}},he.createElement(Te,null))),he.createElement(n,yt({component:a},c),he.createElement(se,{dividers:!0},f),T&&he.createElement(de,null,d.map((function(e){var n=e.id,r=e.text,o=e.type,a=void 0===o?"button":o,i=e.onClick,l=e.color,c=void 0===l?"primary":l;return he.createElement(t,{key:n,type:a,disabled:u,onClick:i,color:c},r)})),v&&he.createElement(t,{color:"error",disabled:u,onClick:function(){k(),h&&O()}},C),E&&he.createElement(at,{type:$,loading:p,disabled:u,onClick:w},g))))},gr=function(e){var t=e.open,n=e.title,r=e.loading,o=e.disabled,a=e.confirmText,i=void 0===a?"Confirm":a,l=e.cancelText,c=void 0===l?"Cancel":l,u=e.children,s=e.onConfirm,d=e.onCancel;return he.createElement(br,{title:n,loading:r,disabled:r||o,open:t,onClose:d,acceptable:!0,cancelable:!0,callCloseWhenCancel:!1,acceptText:i,cancelText:c,onCancel:d,onAccept:s},u)},xr=function(e){var t=e.open,n=e.title,r=e.loading,o=e.disabled,a=e.submitText,i=void 0===a?"Submit":a,l=e.cancelText,c=void 0===l?"Cancel":l,u=e.children,s=e.onSubmit,d=e.onCancel;return he.createElement(br,{component:"form",componentProps:{onSubmit:function(e){e.preventDefault(),s(function(e){var t=new FormData(e.currentTarget),n={};return t.forEach((function(e,t){n[t]=e})),n}(e))}},title:n,loading:r,disabled:r||o,open:t,onClose:d,callCloseWhenCancel:!1,cancelable:!0,acceptable:!0,cancelText:c,onCancel:d,acceptText:i,acceptType:"submit"},u)},Cr=function(e){void 0===e&&(e=!1);var t=Ee(e),n=t[0],r=t[1];return{isOpen:n,open:function(){return r(!0)},close:function(){return r(!1)},setIsOpen:r}},wr=Ne("div")((function(e){var t=e.theme;return yt({display:"flex",alignItems:"center",justifyContent:"flex-end",padding:t.spacing(0,1)},t.mixins.toolbar)})),Sr=function(e){var t=e.children,r=t[0],o=t[1],a=t[2];return he.createElement(n,{sx:{display:"flex"}},he.createElement(un,null,r,o,he.createElement(n,{sx:{flexGrow:1}},he.createElement(wr,null),a)))},kr=function(e){var t=e.loading,r=e.children,o=r[0],a=r[1];return he.createElement(Qt,null,he.createElement(n,{display:"flex",flexDirection:"column",height:1},o,t?he.createElement(kt,null):a))},Or=function(e,t){var n=e.id,r=e.name,o=e.type,a=t[n];return"boolean"===o?he.createElement(vt,{label:r,value:a}):"date"===o||"time"===o||"datetime"===o?he.createElement(bt,{label:r,value:a,format:e.format}):he.createElement(ft,{label:r,value:null==a?void 0:a.toString()})},Ir=function(e){var t=e.field,n=t.name,r=t.description,o=t.value,a=e.instance;return he.createElement(wt,{title:n,subtitle:r},o.map((function(e){var t=e.id,n=e.xs,r=e.sm,o=e.md,i=e.lg,l=e.xl;return he.createElement(Ct,{key:t,xs:n,sm:r,md:o,lg:i,xl:l},Or(e,a))})))},$r=function(e){var t=e.model,n=e.instance;return he.createElement(s,{container:!0,spacing:2},t.fields.map((function(e){var t=e.id,r=e.type,o=e.xs,a=void 0===o?3:o,i=e.sm,l=e.md,c=e.lg,u=e.xl;return"group"===r?he.createElement(s,{item:!0,key:t,xs:12},he.createElement(Ir,{field:e,instance:n[t]})):he.createElement(s,{item:!0,key:t,xs:a,sm:i,md:l,lg:c,xl:u},he.createElement(pt,null,Or(e,n)))})))},Tr={string:"",number:0,boolean:!1,enum:"",multienum:[],date:new Date(1970,0,1,0,0),time:new Date(1970,0,1,0,0),datetime:new Date(1970,0,1,0,0),group:{}},Pr=function(e,t){return t&&t[e.id]||"default"in e&&e.default||Tr[e.type]},jr=function(e,t){void 0===t&&(t=void 0);var n={};return e.fields.forEach((function(e){if("group"===e.type){var r={};e.value.forEach((function(n){r[n.id]=Pr(n,t&&t[e.id])})),n[e.id]=r}else n[e.id]=Pr(e,t)})),n},Rr=function(e){var o=e.model,i=e.saveButtonText,c=e.onSubmit,u=e.initialValues,d=ke((function(){return jr(o,u)}),[o,u]),m=Ee(d),f=m[0],p=m[1],v=function(e,t,n){p((function(r){var o,a={};return t?a[t]=yt(yt({},r[t]),((o={})[e]=n,o)):a[e]=n,yt(yt({},r),a)}))},y=function(e,t,n){v(n,t,e)},h=function(e,t){void 0===t&&(t=void 0);var o,i=gt({lightWeight:200,darkWeight:800}),c=e.id,u=e.type,d=e.name,m=e.description,p=e.xs,E=e.sm,b=e.md,g=e.lg,x=e.xl,C=t?f[t][c]:f[c];return o="group"===u?he.createElement(l,null,he.createElement(n,{bgcolor:i,px:2,py:1,mb:2},he.createElement(r,{variant:"h6",role:"heading","aria-level":1},d),he.createElement(r,{variant:"body2",role:"heading","aria-level":2},m)),he.createElement(s,{container:!0,spacing:2,sx:{p:2}},e.value.map((function(e){return h(e,c)})))):"boolean"===u?he.createElement(n,{sx:{height:1,display:"flex",alignItems:"center"}},he.createElement(me,{control:he.createElement(fe,{name:c,onChange:function(e){return function(e,t){e.preventDefault(),v(e.target.name,t,e.target.checked)}(e,t)},checked:C}),label:d})):"enum"===u?he.createElement(V,{fullWidth:!0},he.createElement(F,{id:"".concat(c,"-select-label")},d),he.createElement(W,{labelId:"".concat(c,"-select-label"),id:"".concat(c,"-select"),value:C,label:d,name:c,onChange:function(e){return function(e,t){e.preventDefault(),v(e.target.name,t,e.target.value)}(e,t)},required:!0},e.value.map((function(e){return he.createElement(pe,{key:e,value:e},e)})))):"multienum"===u?he.createElement(V,{fullWidth:!0},he.createElement(F,{id:"".concat(c,"-select-label")},d),he.createElement(W,{labelId:"".concat(c,"-select-label"),id:"".concat(c,"-select"),value:C||[],renderValue:function(e){return e.join(", ")},label:d,name:c,onChange:function(e){return function(e,t){e.preventDefault();var n=e.target.value,r="string"==typeof n?n.split(","):n;v(e.target.name,t,r)}(e,t)},required:!0,multiple:!0},e.value.map((function(e){return he.createElement(pe,{key:e,value:e},he.createElement(fe,{checked:(C||[]).includes(e)}),he.createElement(z,{primary:e}))})))):"date"===u?he.createElement(ze,{label:d,format:e.format,value:C,onChange:function(e){return y(e,t,c)}}):"time"===u?he.createElement(Re,{label:d,format:e.format,value:C,onChange:function(e){return y(e,t,c)}}):"datetime"===u?he.createElement(je,{label:d,format:e.format,value:C,onChange:function(e){return y(e,t,c)}}):he.createElement(a,{required:!0,type:u,label:d,name:c,variant:"outlined",fullWidth:!0,value:C,onChange:function(e){return function(e,t,n){e.preventDefault();var r=e.target.value;"number"===n&&"string"==typeof r&&(r=parseInt(e.target.value)),v(e.target.name,t,r)}(e,t,u)}}),he.createElement(s,{item:!0,key:c,xs:p,sm:E,md:b,lg:g,xl:x},o)};return he.createElement(s,{container:!0,component:"form",spacing:2,onSubmit:function(e){e.preventDefault(),c(f)}},o.fields.map((function(e){return h(e)})),he.createElement(s,{item:!0,xs:12},he.createElement(t,{type:"submit",variant:"contained"},i)))},Mr=function(e,t,n){var r=n.from,o=n.to,a=Ce(),i=Xe();we((function(){a.current===r&&t===o&&i(e),a.current=t}),[t])},zr=function(e){var t=e.model,n=e.modelName,r=e.basePath,o=void 0===r?"":r,a=e.submitUpdateItemRequest,i=e.updateItemRequest,l=e.updateItem,c=e.onSubmitUpdateItem,u=e.onRequestUpdateItem,s=Ke().id,d=void 0===s?"":s,m=i.loading||a.loading;return we((function(){u(d)}),[d]),Gt({title:"Item updated",message:"The item ".concat(d," has been updated successfully"),severity:"success"},!!a.success,{from:!1,to:!0}),Mr("".concat(o,"/"),!!a.success,{from:!1,to:!0}),Gt({title:"We had an error",message:a.error||"",severity:"error"},!!a.error,{from:!1,to:!0}),he.createElement(kr,{loading:m},he.createElement(Zt,{title:"Edit ".concat(d),preset:"default",breadcrumbs:[{id:"list",text:n,link:"".concat(o,"/")},{id:"update",text:"Edit ".concat(d),link:"".concat(o,"/").concat(d,"/update")}]}),he.createElement(rn,null,he.createElement(Rr,{model:t,initialValues:l,saveButtonText:"Save",onSubmit:c})))},Nr=function(e){var t=e.columns,n=e.options,r=e.data,o=e.onClick,a=e.search,l=e.defaultSort,c=e.defaultOrder,u=e.loading,s=Et(Et([],t,!0),[{id:"__options",label:"",disablePadding:!1,numeric:!1,sort:!1}],!1),d=he.useState(null),m=d[0],f=d[1];return he.createElement(he.Fragment,null,he.createElement(ur,{columns:s,data:r,search:a,defaultSort:l,defaultOrder:c,loading:u},(function(e){return e.map((function(e,t){return he.createElement(ee,{key:e.id,onClick:function(){return o&&o(e)},role:"row","aria-rowindex":t,sx:{cursor:o&&"pointer"}},s.map((function(n,r){var o=n.id;return he.createElement(te,{role:"cell",scope:"row",key:o.toString(),"aria-rowindex":t,"aria-colindex":r},e[o])})),n&&he.createElement(te,null,he.createElement(i,{"data-testid":"options-".concat(e.id),onClick:function(t){t.stopPropagation(),f({item:e,anchor:t.currentTarget})}},he.createElement(lt,null))))}))})),n&&he.createElement(ve,{anchorEl:null==m?void 0:m.anchor,open:!!m,onClose:function(){return f(null)},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"}},n.map((function(e){var t=e.id,n=e.label,r=e.onClick;return he.createElement(pe,{key:t,onClick:function(){m&&r(null==m?void 0:m.item),f(null)}},n)}))))},Dr=function(e){var t=e.model,n=e.modelName,r=e.listData,o=e.listRequest,a=e.deleteRequest,i=e.basePath,l=void 0===i?"":i,c=e.deleteFeature,u=void 0===c||c,s=e.updateFeature,d=void 0===s||s,m=e.addFeature,f=void 0===m||m,p=e.detailsFeature,v=void 0===p||p,y=e.onRequestList,h=e.onClickDeleteItem,E=Xe();we((function(){y()}),[]),Gt({title:"Item deleted",message:"The item has been deleted successfully",severity:"success"},!!a.success,{from:!1,to:!0}),Gt({title:"We had an error",message:a.error||"",severity:"error"},!!a.error,{from:!1,to:!0});var b=v?function(e){E("".concat(l,"/").concat(e.id))}:void 0,g=function(e,t){"edit"===e?E("".concat(l,"/").concat(t.id,"/update")):h(t)},x=[];d&&x.push({id:"edit",label:"Edit",onClick:function(e){return g("edit",e)}}),u&&x.push({id:"remove",label:"Remove",onClick:function(e){return g("remove",e)}});var C=[];return f&&C.push({id:"add",text:"Add",href:"".concat(l,"/add")}),he.createElement(kr,{loading:o.loading||a.loading},he.createElement(Zt,{title:n,preset:"default",actions:C.length>0?C:void 0}),he.createElement(rn,null,he.createElement(Nr,{columns:t.fields.filter((function(e){return e.listable})).map((function(e){return{disablePadding:!1,id:e.id,label:e.name,numeric:"number"===e.type,sort:!1}})),data:r,defaultSort:t.fields[0].id,onClick:b,options:x.length>0?x:void 0})))},Ar=function(e){var t=e.model,n=e.modelName,r=e.basePath,o=void 0===r?"":r,a=e.onSubmitNewItem,i=e.newItemRequest;return Gt({message:"Item added successfully",severity:"success"},!!i.success,{from:!1,to:!0}),Mr("".concat(o,"/"),!!i.success,{from:!1,to:!0}),Gt({title:"We had an error",message:i.error||"",severity:"error"},!!i.error,{from:!1,to:!0}),he.createElement(kr,{loading:i.loading},he.createElement(Zt,{title:"Add ".concat(n),preset:"default",breadcrumbs:[{id:"list",text:n,link:"".concat(o,"/")},{id:"add",text:"Add new ".concat(n),link:"".concat(o,"/add")}]}),he.createElement(rn,null,he.createElement(Rr,{model:t,saveButtonText:"Save",onSubmit:a})))},Vr=function(e){var t=e.model,n=e.modelName,r=e.basePath,o=void 0===r?"":r,a=e.onRequestItem,i=e.itemRequest,l=e.detailsItem,c=Ke().id,u=void 0===c?"":c;return we((function(){a(u)}),[u]),he.createElement(kr,{loading:i.loading},he.createElement(Zt,{title:u,preset:"default",breadcrumbs:[{id:"list",text:n,link:"".concat(o,"/")},{id:"detail",text:u,link:"".concat(o,"/").concat(u)}]}),he.createElement(rn,null,l&&he.createElement($r,{model:t,instance:l})))},Fr=function(e){var t=e.updateFeature,n=void 0===t||t,r=e.addFeature,o=void 0===r||r,a=e.detailsFeature,i=void 0===a||a;return he.createElement(Qe,null,he.createElement(Ze,{path:"",element:he.createElement(Dr,yt({},e))}),i&&he.createElement(Ze,{path:":id",element:he.createElement(Vr,yt({},e))}),o&&he.createElement(Ze,{path:"add",element:he.createElement(Ar,yt({},e))}),n&&he.createElement(Ze,{path:":id/update",element:he.createElement(zr,yt({},e))}))},Wr={idle:!0},_r={loading:!0},Br={success:!0};export{Sr as AppBarWithDrawerLayout,nn as Board,br as BootstrapDialog,At as Bullet,on as CenterContainer,gr as ConfirmDialog,rn as Content,vr as ContentPlaceholder,st as DefaultPlaceholder,ln as Drawer,pn as DrawerContent,It as DrawerContext,dn as DrawerItem,un as DrawerProvider,fn as DrawerSection,rr as EnhancedAutocomplete,dr as EnhancedRemoteTable,yn as EnhancedSelect,ur as EnhancedTable,lr as EnhancedTableHead,Er as ExpandableAlert,xr as FormDialog,wt as GroupValueCard,Ct as GroupValueItem,Zt as Header,kr as HeaderLayout,Wr as IdleRequest,Ft as Label,kt as LoadingArea,_r as LoadingRequest,yr as LoremIpsumPlaceholder,tn as Markdown,Nt as MiniAppBar,cn as MiniDrawer,Rr as ModelForm,Fr as ModelRouter,Ut as NotificationCenterContext,Yt as NotificationCenterProvider,qt as NotificationCenterProviderUndefinedError,$r as ObjectDetails,mr as Placeholder,Ot as QueryContainer,hn as SignIn,fr as SkeletonCard,pr as SkeletonGrid,Br as SuccessRequest,ir as TabCard,Jt as TabContext,Xt as TabContextProvider,or as TabPanel,Qt as TabProvider,Nr as TableList,$t as UndefinedProvider,vt as ValueBoolean,pt as ValueCard,bt as ValueDatetime,ct as ValueEditButtons,St as ValueRating,ft as ValueText,Dt as bulletClasses,Lt as getRandomItem,xt as groupValueItemClasses,Vt as labelClasses,en as markdownDefaultOptions,Bt as newArrayWithSize,jr as newInstanceFromValuesOrZeroValue,Cr as useDialog,Tt as useDrawer,ut as useEditableValueDisplay,gt as useGetDefaultThemeColor,Ht as useNotificationCenter,Gt as useNotifyWhenValueChanges,Kt as useTab};
|
|
24
24
|
//# sourceMappingURL=index.js.map
|