sera-components 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/src/basic/CountryFlag.d.ts +75 -0
- package/dist/components/src/basic/Language.d.ts +48 -0
- package/dist/components/src/basic/Menu.d.ts +62 -0
- package/dist/components/src/basic/Transition.d.ts +18 -0
- package/dist/components/src/basic/index.d.ts +4 -0
- package/dist/components/src/data/display/ForeignKeyDisplay.d.ts +7 -0
- package/dist/components/src/data/display/TextDisplay.d.ts +2 -0
- package/dist/components/src/data/display/index.d.ts +13 -0
- package/dist/components/src/data/index.d.ts +2 -0
- package/dist/components/src/data/inputs/BooleanInput.d.ts +2 -0
- package/dist/components/src/data/inputs/ForeignKeyInput.d.ts +22 -0
- package/dist/components/src/data/inputs/NumberInput.d.ts +2 -0
- package/dist/components/src/data/inputs/PhoneNumberInput.d.ts +13 -0
- package/dist/components/src/data/inputs/TextInput.d.ts +2 -0
- package/dist/components/src/data/inputs/index.d.ts +21 -0
- package/dist/components/src/form/Form.d.ts +61 -0
- package/dist/components/src/form/FormItem.d.ts +31 -0
- package/dist/components/src/form/FormItemLabel.d.ts +9 -0
- package/dist/components/src/form/index.d.ts +3 -0
- package/dist/components/src/index.d.ts +5 -0
- package/dist/components/src/misc/index.d.ts +2 -0
- package/dist/components/src/misc/trie.d.ts +36 -0
- package/dist/components/src/misc/utils.d.ts +9 -0
- package/dist/components/src/table/EmbeddedTable.d.ts +13 -0
- package/dist/components/src/table/Table.d.ts +16 -0
- package/dist/components/src/table/TableAction.d.ts +16 -0
- package/dist/components/src/table/TableContent.d.ts +9 -0
- package/dist/components/src/table/TablePagination.d.ts +14 -0
- package/dist/components/src/table/index.d.ts +4 -0
- package/dist/components/src/table/makeColumns.d.ts +28 -0
- package/dist/components/src/view/MultiTabView.d.ts +1 -0
- package/dist/components/src/view/View.d.ts +25 -0
- package/dist/components/src/view/ViewItem.d.ts +15 -0
- package/dist/components/src/view/ViewNestedPropertyItem.d.ts +46 -0
- package/dist/components/src/view/ViewTab.d.ts +18 -0
- package/dist/components/src/view/index.d.ts +2 -0
- package/dist/index.css +1 -0
- package/dist/index.js +3344 -0
- package/dist/index.umd.cjs +33 -0
- package/package.json +45 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
(function(C,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("react"),require("@mantine/core"),require("@tabler/icons-react"),require("mobx-react-lite"),require("sera-route"),require("react-imask"),require("sera-db"),require("@tanstack/react-table")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@tabler/icons-react","mobx-react-lite","sera-route","react-imask","sera-db","@tanstack/react-table"],j):(C=typeof globalThis<"u"?globalThis:C||self,j(C["sera-components"]={},C.React,C["@mantine/core"],C["@tabler/icons-react"],C["mobx-react-lite"],C["sera-route"],C.ReactIMask,C["sera-db"],C["@tanstack/react-table"]))})(this,function(C,j,u,M,Y,Be,Bt,J,X){"use strict";var ea=Object.defineProperty;var ta=(C,j,u)=>j in C?ea(C,j,{enumerable:!0,configurable:!0,writable:!0,value:u}):C[j]=u;var ae=(C,j,u)=>ta(C,typeof j!="symbol"?j+"":j,u);function qt(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const f=qt(j);var de={exports:{}},oe={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var qe;function Kt(){if(qe)return oe;qe=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function t(a,r,o){var l=null;if(o!==void 0&&(l=""+o),r.key!==void 0&&(l=""+r.key),"key"in r){o={};for(var s in r)s!=="key"&&(o[s]=r[s])}else o=r;return r=o.ref,{$$typeof:e,type:a,key:l,ref:r!==void 0?r:null,props:o}}return oe.Fragment=n,oe.jsx=t,oe.jsxs=t,oe}var ie={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Ke;function Ut(){return Ke||(Ke=1,process.env.NODE_ENV!=="production"&&function(){function e(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===V?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case m:return"Fragment";case b:return"Profiler";case E:return"StrictMode";case R:return"Suspense";case U:return"SuspenseList";case A:return"Activity"}if(typeof g=="object")switch(typeof g.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case y:return"Portal";case w:return(g.displayName||"Context")+".Provider";case T:return(g._context.displayName||"Context")+".Consumer";case S:var k=g.render;return g=g.displayName,g||(g=k.displayName||k.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case _:return k=g.displayName||null,k!==null?k:e(g.type)||"Memo";case Z:k=g._payload,g=g._init;try{return e(g(k))}catch{}}return null}function n(g){return""+g}function t(g){try{n(g);var k=!1}catch{k=!0}if(k){k=console;var P=k.error,F=typeof Symbol=="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return P.call(k,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",F),n(g)}}function a(g){if(g===m)return"<>";if(typeof g=="object"&&g!==null&&g.$$typeof===Z)return"<...>";try{var k=e(g);return k?"<"+k+">":"<...>"}catch{return"<...>"}}function r(){var g=ne.A;return g===null?null:g.getOwner()}function o(){return Error("react-stack-top-frame")}function l(g){if(At.call(g,"key")){var k=Object.getOwnPropertyDescriptor(g,"key").get;if(k&&k.isReactWarning)return!1}return g.key!==void 0}function s(g,k){function P(){Ot||(Ot=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",k))}P.isReactWarning=!0,Object.defineProperty(g,"key",{get:P,configurable:!0})}function c(){var g=e(this.type);return _t[g]||(_t[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function d(g,k,P,F,H,D,De,$e){return P=D.ref,g={$$typeof:v,type:g,key:k,props:D,_owner:H},(P!==void 0?P:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:c}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:De}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:$e}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function h(g,k,P,F,H,D,De,$e){var L=k.children;if(L!==void 0)if(F)if(Zr(L)){for(F=0;F<L.length;F++)x(L[F]);Object.freeze&&Object.freeze(L)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(L);if(At.call(k,"key")){L=e(g);var re=Object.keys(k).filter(function(Qr){return Qr!=="key"});F=0<re.length?"{key: someKey, "+re.join(": ..., ")+": ...}":"{key: someKey}",zt[L+F]||(re=0<re.length?"{"+re.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,F,L,re,L),zt[L+F]=!0)}if(L=null,P!==void 0&&(t(P),L=""+P),l(k)&&(t(k.key),L=""+k.key),"key"in k){P={};for(var ze in k)ze!=="key"&&(P[ze]=k[ze])}else P=k;return L&&s(P,typeof g=="function"?g.displayName||g.name||"Unknown":g),d(g,L,D,H,r(),P,De,$e)}function x(g){typeof g=="object"&&g!==null&&g.$$typeof===v&&g._store&&(g._store.validated=1)}var p=j,v=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),w=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),V=Symbol.for("react.client.reference"),ne=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,At=Object.prototype.hasOwnProperty,Zr=Array.isArray,_e=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(g){return g()}};var Ot,_t={},Dt=p.react_stack_bottom_frame.bind(p,o)(),$t=_e(a(o)),zt={};ie.Fragment=m,ie.jsx=function(g,k,P,F,H){var D=1e4>ne.recentlyCreatedOwnerStacks++;return h(g,k,P,!1,F,H,D?Error("react-stack-top-frame"):Dt,D?_e(a(g)):$t)},ie.jsxs=function(g,k,P,F,H){var D=1e4>ne.recentlyCreatedOwnerStacks++;return h(g,k,P,!0,F,H,D?Error("react-stack-top-frame"):Dt,D?_e(a(g)):$t)}}()),ie}var Ue;function Gt(){return Ue||(Ue=1,process.env.NODE_ENV==="production"?de.exports=Kt():de.exports=Ut()),de.exports}var i=Gt();const N={UK:{svgFlag:"https://flagcdn.com/gb.svg",emojiFlag:"🇬🇧"},VN:{svgFlag:"https://flagcdn.com/vn.svg",emojiFlag:"🇻🇳"},US:{svgFlag:"https://flagcdn.com/us.svg",emojiFlag:"🇺🇸"},CA:{svgFlag:"https://flagcdn.com/ca.svg",emojiFlag:"🇨🇦"},BR:{svgFlag:"https://flagcdn.com/br.svg",emojiFlag:"🇧🇷"},ES:{svgFlag:"https://flagcdn.com/es.svg",emojiFlag:"🇪🇸"},IT:{svgFlag:"https://flagcdn.com/it.svg",emojiFlag:"🇮🇹"},NZ:{svgFlag:"https://flagcdn.com/nz.svg",emojiFlag:"🇳🇿"},MX:{svgFlag:"https://flagcdn.com/mx.svg",emojiFlag:"🇲🇽"},CN:{svgFlag:"https://flagcdn.com/cn.svg",emojiFlag:"🇨🇳"},AU:{svgFlag:"https://flagcdn.com/au.svg",emojiFlag:"🇦🇺"},JP:{svgFlag:"https://flagcdn.com/jp.svg",emojiFlag:"🇯🇵"},FR:{svgFlag:"https://flagcdn.com/fr.svg",emojiFlag:"🇫🇷"},DE:{svgFlag:"https://flagcdn.com/de.svg",emojiFlag:"🇩🇪"},IN:{svgFlag:"https://flagcdn.com/in.svg",emojiFlag:"🇮🇳"}},Ge=({flag:e})=>i.jsx(u.Paper,{shadow:"xs",w:20,h:14,children:i.jsx(u.Image,{src:e.svgFlag,w:20,h:14,fit:"cover"})}),We=({flag:e})=>i.jsx(u.Text,{component:"span",style:n=>({textShadow:n.shadows.xs}),children:e.emojiFlag}),fe=navigator.userAgent.includes("Windows")?Ge:We,Wt={lang2value:{en:"Choose Language",vi:"Chọn ngôn ngữ"}},he={en:{name:"English",flag:N.US,locale:new Intl.Locale("en-US")},vi:{name:"Tiếng Việt",flag:N.VN,locale:new Intl.Locale("vi-VN")}},Vt=({locale:e,setLocale:n})=>{const t=j.useMemo(()=>Object.entries(he).map(([a,{flag:r,name:o,locale:l}])=>i.jsx(u.Menu.Item,{onClick:()=>n(l),leftSection:i.jsx(fe,{flag:r}),rightSection:e.language===a&&i.jsx(M.IconCheck,{size:"15",color:"#2986cc",stroke:2}),children:i.jsx(u.Text,{size:"sm",children:o})},a)),[he,e]);return i.jsxs(u.Menu,{width:170,children:[i.jsx(u.Menu.Target,{children:i.jsx(u.Button,{variant:"subtle",size:"sm",leftSection:i.jsx(fe,{flag:he[e.language].flag}),children:i.jsx(u.Text,{size:"sm",children:he[e.language].name})})}),i.jsxs(u.Menu.Dropdown,{children:[i.jsx(u.Menu.Label,{children:i.jsx(u.Text,{size:"sm",children:Wt.lang2value[e.language]})}),t]})]})},Ve=j.createContext(new Intl.Locale("en-US")),O=({value:e})=>{const n=j.useContext(Ve);return e.lang2value[n.language]||e.lang2value[e.lang]};/**
|
|
23
|
+
* react-router v7.7.1
|
|
24
|
+
*
|
|
25
|
+
* Copyright (c) Remix Software Inc.
|
|
26
|
+
*
|
|
27
|
+
* This source code is licensed under the MIT license found in the
|
|
28
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
29
|
+
*
|
|
30
|
+
* @license MIT
|
|
31
|
+
*/function I(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function $(e,n){if(!e){typeof console<"u"&&console.warn(n);try{throw new Error(n)}catch{}}}function we({pathname:e="/",search:n="",hash:t=""}){return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),t&&t!=="#"&&(e+=t.charAt(0)==="#"?t:"#"+t),e}function je(e){let n={};if(e){let t=e.indexOf("#");t>=0&&(n.hash=e.substring(t),e=e.substring(0,t));let a=e.indexOf("?");a>=0&&(n.search=e.substring(a),e=e.substring(0,a)),e&&(n.pathname=e)}return n}function He(e,n,t="/"){return Ht(e,n,t,!1)}function Ht(e,n,t,a){let r=typeof n=="string"?je(n):n,o=G(r.pathname||"/",t);if(o==null)return null;let l=Ye(e);Yt(l);let s=null;for(let c=0;s==null&&c<l.length;++c){let d=ln(o);s=an(l[c],d,a)}return s}function Ye(e,n=[],t=[],a=""){let r=(o,l,s)=>{let c={relativePath:s===void 0?o.path||"":s,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};c.relativePath.startsWith("/")&&(I(c.relativePath.startsWith(a),`Absolute route path "${c.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(a.length));let d=z([a,c.relativePath]),h=t.concat(c);o.children&&o.children.length>0&&(I(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),Ye(o.children,n,h,d)),!(o.path==null&&!o.index)&&n.push({path:d,score:nn(d,o.index),routesMeta:h})};return e.forEach((o,l)=>{var s;if(o.path===""||!((s=o.path)!=null&&s.includes("?")))r(o,l);else for(let c of Je(o.path))r(o,l,c)}),n}function Je(e){let n=e.split("/");if(n.length===0)return[];let[t,...a]=n,r=t.endsWith("?"),o=t.replace(/\?$/,"");if(a.length===0)return r?[o,""]:[o];let l=Je(a.join("/")),s=[];return s.push(...l.map(c=>c===""?o:[o,c].join("/"))),r&&s.push(...l),s.map(c=>e.startsWith("/")&&c===""?"/":c)}function Yt(e){e.sort((n,t)=>n.score!==t.score?t.score-n.score:rn(n.routesMeta.map(a=>a.childrenIndex),t.routesMeta.map(a=>a.childrenIndex)))}var Jt=/^:[\w-]+$/,Xt=3,Zt=2,Qt=1,en=10,tn=-2,Xe=e=>e==="*";function nn(e,n){let t=e.split("/"),a=t.length;return t.some(Xe)&&(a+=tn),n&&(a+=Zt),t.filter(r=>!Xe(r)).reduce((r,o)=>r+(Jt.test(o)?Xt:o===""?Qt:en),a)}function rn(e,n){return e.length===n.length&&e.slice(0,-1).every((a,r)=>a===n[r])?e[e.length-1]-n[n.length-1]:0}function an(e,n,t=!1){let{routesMeta:a}=e,r={},o="/",l=[];for(let s=0;s<a.length;++s){let c=a[s],d=s===a.length-1,h=o==="/"?n:n.slice(o.length)||"/",x=me({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},h),p=c.route;if(!x&&d&&t&&!a[a.length-1].route.index&&(x=me({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},h)),!x)return null;Object.assign(r,x.params),l.push({params:r,pathname:z([o,x.pathname]),pathnameBase:dn(z([o,x.pathnameBase])),route:p}),x.pathnameBase!=="/"&&(o=z([o,x.pathnameBase]))}return l}function me(e,n){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[t,a]=on(e.path,e.caseSensitive,e.end),r=n.match(t);if(!r)return null;let o=r[0],l=o.replace(/(.)\/+$/,"$1"),s=r.slice(1);return{params:a.reduce((d,{paramName:h,isOptional:x},p)=>{if(h==="*"){let y=s[p]||"";l=o.slice(0,o.length-y.length).replace(/(.)\/+$/,"$1")}const v=s[p];return x&&!v?d[h]=void 0:d[h]=(v||"").replace(/%2F/g,"/"),d},{}),pathname:o,pathnameBase:l,pattern:e}}function on(e,n=!1,t=!0){$(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,s,c)=>(a.push({paramName:s,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(a.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,n?void 0:"i"),a]}function ln(e){try{return e.split("/").map(n=>decodeURIComponent(n).replace(/\//g,"%2F")).join("/")}catch(n){return $(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${n}).`),e}}function G(e,n){if(n==="/")return e;if(!e.toLowerCase().startsWith(n.toLowerCase()))return null;let t=n.endsWith("/")?n.length-1:n.length,a=e.charAt(t);return a&&a!=="/"?null:e.slice(t)||"/"}function sn(e,n="/"){let{pathname:t,search:a="",hash:r=""}=typeof e=="string"?je(e):e;return{pathname:t?t.startsWith("/")?t:un(t,n):n,search:fn(a),hash:hn(r)}}function un(e,n){let t=n.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?t.length>1&&t.pop():r!=="."&&t.push(r)}),t.length>1?t.join("/"):"/"}function Ce(e,n,t,a){return`Cannot include a '${e}' character in a manually specified \`to.${n}\` field [${JSON.stringify(a)}]. Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function cn(e){return e.filter((n,t)=>t===0||n.route.path&&n.route.path.length>0)}function Ze(e){let n=cn(e);return n.map((t,a)=>a===n.length-1?t.pathname:t.pathnameBase)}function Qe(e,n,t,a=!1){let r;typeof e=="string"?r=je(e):(r={...e},I(!r.pathname||!r.pathname.includes("?"),Ce("?","pathname","search",r)),I(!r.pathname||!r.pathname.includes("#"),Ce("#","pathname","hash",r)),I(!r.search||!r.search.includes("#"),Ce("#","search","hash",r)));let o=e===""||r.pathname==="",l=o?"/":r.pathname,s;if(l==null)s=t;else{let x=n.length-1;if(!a&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),x-=1;r.pathname=p.join("/")}s=x>=0?n[x]:"/"}let c=sn(r,s),d=l&&l!=="/"&&l.endsWith("/"),h=(o||l===".")&&t.endsWith("/");return!c.pathname.endsWith("/")&&(d||h)&&(c.pathname+="/"),c}var z=e=>e.join("/").replace(/\/\/+/g,"/"),dn=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),fn=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,hn=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function mn(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var et=["POST","PUT","PATCH","DELETE"];new Set(et);var gn=["GET",...et];new Set(gn);var Q=f.createContext(null);Q.displayName="DataRouter";var ge=f.createContext(null);ge.displayName="DataRouterState",f.createContext(!1);var tt=f.createContext({isTransitioning:!1});tt.displayName="ViewTransition";var pn=f.createContext(new Map);pn.displayName="Fetchers";var vn=f.createContext(null);vn.displayName="Await";var B=f.createContext(null);B.displayName="Navigation";var Se=f.createContext(null);Se.displayName="Location";var q=f.createContext({outlet:null,matches:[],isDataRoute:!1});q.displayName="Route";var Ee=f.createContext(null);Ee.displayName="RouteError";function xn(e,{relative:n}={}){I(pe(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:a}=f.useContext(B),{hash:r,pathname:o,search:l}=le(e,{relative:n}),s=o;return t!=="/"&&(s=o==="/"?t:z([t,o])),a.createHref({pathname:s,search:l,hash:r})}function pe(){return f.useContext(Se)!=null}function W(){return I(pe(),"useLocation() may be used only in the context of a <Router> component."),f.useContext(Se).location}var nt="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function rt(e){f.useContext(B).static||f.useLayoutEffect(e)}function ke(){let{isDataRoute:e}=f.useContext(q);return e?In():yn()}function yn(){I(pe(),"useNavigate() may be used only in the context of a <Router> component.");let e=f.useContext(Q),{basename:n,navigator:t}=f.useContext(B),{matches:a}=f.useContext(q),{pathname:r}=W(),o=JSON.stringify(Ze(a)),l=f.useRef(!1);return rt(()=>{l.current=!0}),f.useCallback((c,d={})=>{if($(l.current,nt),!l.current)return;if(typeof c=="number"){t.go(c);return}let h=Qe(c,JSON.parse(o),r,d.relative==="path");e==null&&n!=="/"&&(h.pathname=h.pathname==="/"?n:z([n,h.pathname])),(d.replace?t.replace:t.push)(h,d.state,d)},[n,t,o,r,e])}f.createContext(null);function le(e,{relative:n}={}){let{matches:t}=f.useContext(q),{pathname:a}=W(),r=JSON.stringify(Ze(t));return f.useMemo(()=>Qe(e,JSON.parse(r),a,n==="path"),[e,r,a,n])}function bn(e,n,t,a){I(pe(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=f.useContext(B),{matches:o}=f.useContext(q),l=o[o.length-1],s=l?l.params:{},c=l?l.pathname:"/",d=l?l.pathnameBase:"/",h=l&&l.route;{let b=h&&h.path||"";ot(c,!h||b.endsWith("*")||b.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${b}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
32
|
+
|
|
33
|
+
Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}/*`}">.`)}let x=W(),p;p=x;let v=p.pathname||"/",y=v;if(d!=="/"){let b=d.replace(/^\//,"").split("/");y="/"+v.replace(/^\//,"").split("/").slice(b.length).join("/")}let m=He(e,{pathname:y});return $(h||m!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),$(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),En(m&&m.map(b=>Object.assign({},b,{params:Object.assign({},s,b.params),pathname:z([d,r.encodeLocation?r.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?d:z([d,r.encodeLocation?r.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),o,t,a)}function wn(){let e=Nn(),n=mn(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),t=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:a},o={padding:"2px 4px",backgroundColor:a},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:o},"ErrorBoundary")," or"," ",f.createElement("code",{style:o},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},n),t?f.createElement("pre",{style:r},t):null,l)}var jn=f.createElement(wn,null),Cn=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?f.createElement(q.Provider,{value:this.props.routeContext},f.createElement(Ee.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Sn({routeContext:e,match:n,children:t}){let a=f.useContext(Q);return a&&a.static&&a.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=n.route.id),f.createElement(q.Provider,{value:e},t)}function En(e,n=[],t=null,a=null){if(e==null){if(!t)return null;if(t.errors)e=t.matches;else if(n.length===0&&!t.initialized&&t.matches.length>0)e=t.matches;else return null}let r=e,o=t==null?void 0:t.errors;if(o!=null){let c=r.findIndex(d=>d.route.id&&(o==null?void 0:o[d.route.id])!==void 0);I(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),r=r.slice(0,Math.min(r.length,c+1))}let l=!1,s=-1;if(t)for(let c=0;c<r.length;c++){let d=r[c];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(s=c),d.route.id){let{loaderData:h,errors:x}=t,p=d.route.loader&&!h.hasOwnProperty(d.route.id)&&(!x||x[d.route.id]===void 0);if(d.route.lazy||p){l=!0,s>=0?r=r.slice(0,s+1):r=[r[0]];break}}}return r.reduceRight((c,d,h)=>{let x,p=!1,v=null,y=null;t&&(x=o&&d.route.id?o[d.route.id]:void 0,v=d.route.errorElement||jn,l&&(s<0&&h===0?(ot("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,y=null):s===h&&(p=!0,y=d.route.hydrateFallbackElement||null)));let m=n.concat(r.slice(0,h+1)),E=()=>{let b;return x?b=v:p?b=y:d.route.Component?b=f.createElement(d.route.Component,null):d.route.element?b=d.route.element:b=c,f.createElement(Sn,{match:d,routeContext:{outlet:c,matches:m,isDataRoute:t!=null},children:b})};return t&&(d.route.ErrorBoundary||d.route.errorElement||h===0)?f.createElement(Cn,{location:t.location,revalidation:t.revalidation,component:v,error:x,children:E(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):E()},null)}function Te(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kn(e){let n=f.useContext(Q);return I(n,Te(e)),n}function Tn(e){let n=f.useContext(ge);return I(n,Te(e)),n}function Rn(e){let n=f.useContext(q);return I(n,Te(e)),n}function Re(e){let n=Rn(e),t=n.matches[n.matches.length-1];return I(t.route.id,`${e} can only be used on routes that contain a unique "id"`),t.route.id}function Pn(){return Re("useRouteId")}function Nn(){var a;let e=f.useContext(Ee),n=Tn("useRouteError"),t=Re("useRouteError");return e!==void 0?e:(a=n.errors)==null?void 0:a[t]}function In(){let{router:e}=kn("useNavigate"),n=Re("useNavigate"),t=f.useRef(!1);return rt(()=>{t.current=!0}),f.useCallback(async(r,o={})=>{$(t.current,nt),t.current&&(typeof r=="number"?e.navigate(r):await e.navigate(r,{fromRouteId:n,...o}))},[e,n])}var at={};function ot(e,n,t){!n&&!at[e]&&(at[e]=!0,$(!1,t))}f.memo(Fn);function Fn({routes:e,future:n,state:t}){return bn(e,void 0,t,n)}var ve="get",xe="application/x-www-form-urlencoded";function ye(e){return e!=null&&typeof e.tagName=="string"}function Ln(e){return ye(e)&&e.tagName.toLowerCase()==="button"}function Mn(e){return ye(e)&&e.tagName.toLowerCase()==="form"}function An(e){return ye(e)&&e.tagName.toLowerCase()==="input"}function On(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function _n(e,n){return e.button===0&&(!n||n==="_self")&&!On(e)}var be=null;function Dn(){if(be===null)try{new FormData(document.createElement("form"),0),be=!1}catch{be=!0}return be}var $n=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Pe(e){return e!=null&&!$n.has(e)?($(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${xe}"`),null):e}function zn(e,n){let t,a,r,o,l;if(Mn(e)){let s=e.getAttribute("action");a=s?G(s,n):null,t=e.getAttribute("method")||ve,r=Pe(e.getAttribute("enctype"))||xe,o=new FormData(e)}else if(Ln(e)||An(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||s.getAttribute("action");if(a=c?G(c,n):null,t=e.getAttribute("formmethod")||s.getAttribute("method")||ve,r=Pe(e.getAttribute("formenctype"))||Pe(s.getAttribute("enctype"))||xe,o=new FormData(s,e),!Dn()){let{name:d,type:h,value:x}=e;if(h==="image"){let p=d?`${d}.`:"";o.append(`${p}x`,"0"),o.append(`${p}y`,"0")}else d&&o.append(d,x)}}else{if(ye(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=ve,a=null,r=xe,l=e}return o&&r==="text/plain"&&(l=o,o=void 0),{action:a,method:t.toLowerCase(),encType:r,formData:o,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Ne(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function Bn(e,n,t){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a.pathname==="/"?a.pathname=`_root.${t}`:n&&G(a.pathname,n)==="/"?a.pathname=`${n.replace(/\/$/,"")}/_root.${t}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${t}`,a}async function qn(e,n){if(e.id in n)return n[e.id];try{let t=await import(e.module);return n[e.id]=t,t}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Kn(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Un(e,n,t){let a=await Promise.all(e.map(async r=>{let o=n.routes[r.route.id];if(o){let l=await qn(o,t);return l.links?l.links():[]}return[]}));return Hn(a.flat(1).filter(Kn).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function it(e,n,t,a,r,o){let l=(c,d)=>t[d]?c.route.id!==t[d].route.id:!0,s=(c,d)=>{var h;return t[d].pathname!==c.pathname||((h=t[d].route.path)==null?void 0:h.endsWith("*"))&&t[d].params["*"]!==c.params["*"]};return o==="assets"?n.filter((c,d)=>l(c,d)||s(c,d)):o==="data"?n.filter((c,d)=>{var x;let h=a.routes[c.route.id];if(!h||!h.hasLoader)return!1;if(l(c,d)||s(c,d))return!0;if(c.route.shouldRevalidate){let p=c.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((x=t[0])==null?void 0:x.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}return!0}):[]}function Gn(e,n,{includeHydrateFallback:t}={}){return Wn(e.map(a=>{let r=n.routes[a.route.id];if(!r)return[];let o=[r.module];return r.clientActionModule&&(o=o.concat(r.clientActionModule)),r.clientLoaderModule&&(o=o.concat(r.clientLoaderModule)),t&&r.hydrateFallbackModule&&(o=o.concat(r.hydrateFallbackModule)),r.imports&&(o=o.concat(r.imports)),o}).flat(1))}function Wn(e){return[...new Set(e)]}function Vn(e){let n={},t=Object.keys(e).sort();for(let a of t)n[a]=e[a];return n}function Hn(e,n){let t=new Set;return new Set(n),e.reduce((a,r)=>{let o=JSON.stringify(Vn(r));return t.has(o)||(t.add(o),a.push({key:o,link:r})),a},[])}function lt(){let e=f.useContext(Q);return Ne(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Yn(){let e=f.useContext(ge);return Ne(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Ie=f.createContext(void 0);Ie.displayName="FrameworkContext";function st(){let e=f.useContext(Ie);return Ne(e,"You must render this element inside a <HydratedRouter> element"),e}function Jn(e,n){let t=f.useContext(Ie),[a,r]=f.useState(!1),[o,l]=f.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:d,onMouseLeave:h,onTouchStart:x}=n,p=f.useRef(null);f.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let m=b=>{b.forEach(T=>{l(T.isIntersecting)})},E=new IntersectionObserver(m,{threshold:.5});return p.current&&E.observe(p.current),()=>{E.disconnect()}}},[e]),f.useEffect(()=>{if(a){let m=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(m)}}},[a]);let v=()=>{r(!0)},y=()=>{r(!1),l(!1)};return t?e!=="intent"?[o,p,{}]:[o,p,{onFocus:se(s,v),onBlur:se(c,y),onMouseEnter:se(d,v),onMouseLeave:se(h,y),onTouchStart:se(x,v)}]:[!1,p,{}]}function se(e,n){return t=>{e&&e(t),t.defaultPrevented||n(t)}}function Xn({page:e,...n}){let{router:t}=lt(),a=f.useMemo(()=>He(t.routes,e,t.basename),[t.routes,e,t.basename]);return a?f.createElement(Qn,{page:e,matches:a,...n}):null}function Zn(e){let{manifest:n,routeModules:t}=st(),[a,r]=f.useState([]);return f.useEffect(()=>{let o=!1;return Un(e,n,t).then(l=>{o||r(l)}),()=>{o=!0}},[e,n,t]),a}function Qn({page:e,matches:n,...t}){let a=W(),{manifest:r,routeModules:o}=st(),{basename:l}=lt(),{loaderData:s,matches:c}=Yn(),d=f.useMemo(()=>it(e,n,c,r,a,"data"),[e,n,c,r,a]),h=f.useMemo(()=>it(e,n,c,r,a,"assets"),[e,n,c,r,a]),x=f.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let y=new Set,m=!1;if(n.forEach(b=>{var w;let T=r.routes[b.route.id];!T||!T.hasLoader||(!d.some(S=>S.route.id===b.route.id)&&b.route.id in s&&((w=o[b.route.id])!=null&&w.shouldRevalidate)||T.hasClientLoader?m=!0:y.add(b.route.id))}),y.size===0)return[];let E=Bn(e,l,"data");return m&&y.size>0&&E.searchParams.set("_routes",n.filter(b=>y.has(b.route.id)).map(b=>b.route.id).join(",")),[E.pathname+E.search]},[l,s,a,r,d,n,e,o]),p=f.useMemo(()=>Gn(h,r),[h,r]),v=Zn(h);return f.createElement(f.Fragment,null,x.map(y=>f.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...t})),p.map(y=>f.createElement("link",{key:y,rel:"modulepreload",href:y,...t})),v.map(({key:y,link:m})=>f.createElement("link",{key:y,...m})))}function er(...e){return n=>{e.forEach(t=>{typeof t=="function"?t(n):t!=null&&(t.current=n)})}}var ut=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ut&&(window.__reactRouterVersion="7.7.1")}catch{}var ct=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,dt=f.forwardRef(function({onClick:n,discover:t="render",prefetch:a="none",relative:r,reloadDocument:o,replace:l,state:s,target:c,to:d,preventScrollReset:h,viewTransition:x,...p},v){let{basename:y}=f.useContext(B),m=typeof d=="string"&&ct.test(d),E,b=!1;if(typeof d=="string"&&m&&(E=d,ut))try{let A=new URL(window.location.href),V=d.startsWith("//")?new URL(A.protocol+d):new URL(d),ne=G(V.pathname,y);V.origin===A.origin&&ne!=null?d=ne+V.search+V.hash:b=!0}catch{$(!1,`<Link to="${d}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=xn(d,{relative:r}),[w,S,R]=Jn(a,p),U=ar(d,{replace:l,state:s,target:c,preventScrollReset:h,relative:r,viewTransition:x});function _(A){n&&n(A),A.defaultPrevented||U(A)}let Z=f.createElement("a",{...p,...R,href:E||T,onClick:b||o?n:_,ref:er(v,S),target:c,"data-discover":!m&&t==="render"?"true":void 0});return w&&!m?f.createElement(f.Fragment,null,Z,f.createElement(Xn,{page:T})):Z});dt.displayName="Link";var tr=f.forwardRef(function({"aria-current":n="page",caseSensitive:t=!1,className:a="",end:r=!1,style:o,to:l,viewTransition:s,children:c,...d},h){let x=le(l,{relative:d.relative}),p=W(),v=f.useContext(ge),{navigator:y,basename:m}=f.useContext(B),E=v!=null&&ur(x)&&s===!0,b=y.encodeLocation?y.encodeLocation(x).pathname:x.pathname,T=p.pathname,w=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;t||(T=T.toLowerCase(),w=w?w.toLowerCase():null,b=b.toLowerCase()),w&&m&&(w=G(w,m)||w);const S=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let R=T===b||!r&&T.startsWith(b)&&T.charAt(S)==="/",U=w!=null&&(w===b||!r&&w.startsWith(b)&&w.charAt(b.length)==="/"),_={isActive:R,isPending:U,isTransitioning:E},Z=R?n:void 0,A;typeof a=="function"?A=a(_):A=[a,R?"active":null,U?"pending":null,E?"transitioning":null].filter(Boolean).join(" ");let V=typeof o=="function"?o(_):o;return f.createElement(dt,{...d,"aria-current":Z,className:A,ref:h,style:V,to:l,viewTransition:s},typeof c=="function"?c(_):c)});tr.displayName="NavLink";var nr=f.forwardRef(({discover:e="render",fetcherKey:n,navigate:t,reloadDocument:a,replace:r,state:o,method:l=ve,action:s,onSubmit:c,relative:d,preventScrollReset:h,viewTransition:x,...p},v)=>{let y=lr(),m=sr(s,{relative:d}),E=l.toLowerCase()==="get"?"get":"post",b=typeof s=="string"&&ct.test(s),T=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let S=w.nativeEvent.submitter,R=(S==null?void 0:S.getAttribute("formmethod"))||l;y(S||w.currentTarget,{fetcherKey:n,method:R,navigate:t,replace:r,state:o,relative:d,preventScrollReset:h,viewTransition:x})};return f.createElement("form",{ref:v,method:E,action:m,onSubmit:a?c:T,...p,"data-discover":!b&&e==="render"?"true":void 0})});nr.displayName="Form";function rr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ft(e){let n=f.useContext(Q);return I(n,rr(e)),n}function ar(e,{target:n,replace:t,state:a,preventScrollReset:r,relative:o,viewTransition:l}={}){let s=ke(),c=W(),d=le(e,{relative:o});return f.useCallback(h=>{if(_n(h,n)){h.preventDefault();let x=t!==void 0?t:we(c)===we(d);s(e,{replace:x,state:a,preventScrollReset:r,relative:o,viewTransition:l})}},[c,s,d,t,a,n,e,r,o,l])}var or=0,ir=()=>`__${String(++or)}__`;function lr(){let{router:e}=ft("useSubmit"),{basename:n}=f.useContext(B),t=Pn();return f.useCallback(async(a,r={})=>{let{action:o,method:l,encType:s,formData:c,body:d}=zn(a,n);if(r.navigate===!1){let h=r.fetcherKey||ir();await e.fetch(h,t,r.action||o,{preventScrollReset:r.preventScrollReset,formData:c,body:d,formMethod:r.method||l,formEncType:r.encType||s,flushSync:r.flushSync})}else await e.navigate(r.action||o,{preventScrollReset:r.preventScrollReset,formData:c,body:d,formMethod:r.method||l,formEncType:r.encType||s,replace:r.replace,state:r.state,fromRouteId:t,flushSync:r.flushSync,viewTransition:r.viewTransition})},[e,n,t])}function sr(e,{relative:n}={}){let{basename:t}=f.useContext(B),a=f.useContext(q);I(a,"useFormAction must be used inside a RouteContext");let[r]=a.matches.slice(-1),o={...le(e||".",{relative:n})},l=W();if(e==null){o.search=l.search;let s=new URLSearchParams(o.search),c=s.getAll("index");if(c.some(h=>h==="")){s.delete("index"),c.filter(x=>x).forEach(x=>s.append("index",x));let h=s.toString();o.search=h?`?${h}`:""}}return(!e||e===".")&&r.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(o.pathname=o.pathname==="/"?t:z([t,o.pathname])),we(o)}function ur(e,{relative:n}={}){let t=f.useContext(tt);I(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=ft("useViewTransitionState"),r=le(e,{relative:n});if(!t.isTransitioning)return!1;let o=G(t.currentLocation.pathname,a)||t.currentLocation.pathname,l=G(t.nextLocation.pathname,a)||t.nextLocation.pathname;return me(r.pathname,l)!=null||me(r.pathname,o)!=null}const cr=({message:e})=>{const n=ke();return i.jsxs(u.Alert,{color:"red",title:"Not Found",variant:"404 - Not Found",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:[e||"Sorry, the page you are looking for does not exist.",i.jsx(u.Button,{variant:"filled",onClick:()=>n("/"),children:"Back Home"})]})},dr=({message:e})=>i.jsx(u.Alert,{color:"red",title:"Not Found",variant:"404 - Not Found",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:e||"Sorry, the page you are looking for does not exist."}),Fe=({message:e})=>i.jsx(u.Text,{c:"red",size:"sm",children:e||"Not Found"}),fr=({tip:e})=>e===void 0?i.jsx(u.Flex,{justify:"center",align:"center",children:i.jsx(u.Loader,{color:"blue",size:"md"})}):i.jsxs(u.Flex,{gap:"md",direction:"column",justify:"center",align:"center",style:{height:"100%"},children:[i.jsx(u.Loader,{color:"blue",size:"md"}),e]}),hr=({tip:e})=>e===void 0?i.jsx(u.Loader,{color:"blue",size:"xs"}):i.jsxs(u.Flex,{gap:"md",direction:"column",justify:"center",align:"center",children:[i.jsx(u.Loader,{color:"blue",size:"xs"}),e]}),mr=({message:e})=>i.jsx(u.Alert,{color:"red",title:"Not Found",variant:"403 - Not Authorized",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:e||"Sorry, you are not authorized to access this page."});class ht{constructor(){ae(this,"children",new Map);ae(this,"isEndOfWord",!1);ae(this,"value","")}}class mt{constructor(){ae(this,"root",new ht)}insert(n){let t=this.root;for(const a of n){let r=t.children.get(a);r===void 0&&(r=new ht,t.children.set(a,r)),t=r}t.isEndOfWord=!0,t.value=n}findLongestPrefix(n){let t=this.root,a={match:"",remaining:n};for(let r=0;r<n.length;r++){const o=n[r];if(!t.children.has(o))break;t=t.children.get(o),t.isEndOfWord&&(a={match:t.value,remaining:n.slice(r+1)})}return a}}var gt=(e=>(e[e.Allow=0]="Allow",e[e.Denied=1]="Denied",e[e.Pending=2]="Pending",e))(gt||{});class pt extends mt{constructor(){super(...arguments);ae(this,"pathToKey",new Map)}normalizePath(t){return t==="/"?"/":t.replace(/\/$/,"")}insertRoute(t,a){const r=this.normalizePath(t);this.insert(r),this.pathToKey.set(r,a)}findMatchingKey(t){const a=this.normalizePath(t),r=this.findLongestPrefix(a);if(r.match&&this.pathToKey.has(r.match)&&(a===r.match||r.remaining.startsWith("/")||r.remaining===""))return this.pathToKey.get(r.match)}}function vt(e){const n={},t={},a={},r=(o,l=[])=>{o.forEach(s=>{const c=[...l,s.key];n[s.key]=s,t[s.key]=c,s.route!==void 0&&(a[s.key]=s.route),s.children!==void 0&&s.children.length>0&&r(s.children,c)})};return r(e),{key2item:n,key2fullpath:t,key2route:a}}function gr(e){const n=new pt,t=a=>{a.forEach(r=>{if(r.route!==void 0){const o=r.route.path.getURL();n.insertRoute(o,r.key)}r.children!==void 0&&r.children.length>0&&t(r.children)})};return t(e),n}function xt(e,n){return e.map(t=>{if(t.route!==void 0)return n(t.route.role)===0?t:null;if(t.children!==void 0){const a=t.children.filter(r=>r.route!==void 0?n(r.route.role)===0:!0);return a.length>0?{...t,children:a}:null}return t}).filter(t=>t!==null)}const pr=e=>{const n=ke(),t=W(),[a,r]=j.useState(new Set),[o,l]=j.useState(new Set),[s,c]=j.useState(),d=j.useMemo(()=>xt(e.items,e.checkPermission),[e.items,e.checkPermission]),h=j.useMemo(()=>gr(e.items),[e.items]),{key2fullpath:x,key2route:p}=j.useMemo(()=>vt(d),[d]);j.useEffect(()=>{const y=t.pathname,m=h.findMatchingKey(y);m!==void 0&&(l(new Set(x[m])),c(m))},[t,p]);const v=j.useMemo(()=>{function y(m,E){var T,w;const b=m.children!==void 0&&m.children.length>0;return b?i.jsxs("div",{onMouseEnter:()=>{o.has(m.key)||r(S=>{const R=new Set(S);return R.add(m.key),R})},onMouseLeave:()=>{o.has(m.key)||r(S=>{const R=new Set(S);return R.delete(m.key),R})},children:[i.jsx(u.NavLink,{active:s===m.key,href:(T=m.route)==null?void 0:T.path.getURL(),label:m.label,leftSection:m.icon,styles:{label:{fontSize:"md"},root:{borderRadius:"var(--mantine-radius-sm)"}},ml:E===0?void 0:E===1?"md":`calc(var(--mantine-spacing-md) * ${E})`,w:"unset",rightSection:b?i.jsx(M.IconChevronRight,{size:12,stroke:1.5,className:"mantine-rotate-rtl"}):void 0,opened:a.has(m.key)||o.has(m.key),onClick:S=>{S.ctrlKey||S.metaKey||(S.preventDefault(),l(U=>{const _=new Set(U);return U.has(m.key)?_.delete(m.key):_.add(m.key),_}))}},m.key),(o.has(m.key)||a.has(m.key))&&m.children.map(S=>y(S,E+1))]},`container-${m.key}`):i.jsx(u.NavLink,{active:s===m.key,href:(w=m.route)==null?void 0:w.path.getURL(),label:m.label,leftSection:m.icon,styles:{label:{fontSize:"md"},root:{borderRadius:"var(--mantine-radius-sm)"}},ml:E===0?void 0:E===1?"md":`calc(var(--mantine-spacing-md) * ${E})`,w:"unset",onClick:S=>{S.ctrlKey||S.metaKey||(S.preventDefault(),m.route!=null&&m.route.path.path().open(n))}},m.key)}return d.map(m=>y(m,0))},[d,s,o,a,n]);return i.jsx(i.Fragment,{children:v})},ee=({value:e})=>i.jsx(u.Text,{size:"sm",children:e});function yt(e,n,t,a){const r=e.getByName(n.targetClass),o=a[n.targetClass];j.useEffect(()=>{r.fetchByIds(t)},[t]);const l={};for(const s of t)l[s]=r.get(s);return[l,o]}const ue=Y.observer(({db:e,property:n,value:t,entityRoutes:a})=>{const r=j.useMemo(()=>[t],[t]),[o,l]=yt(e,n,r,a),s=o[t];return s===void 0?i.jsx(u.Text,{size:"sm",children:t}):s===null?i.jsx(Fe,{}):l===void 0?i.jsx(u.Text,{size:"sm",children:s.name}):i.jsx(Be.InternalLink,{path:l,openInNewPage:!1,urlArgs:{id:s.id},queryArgs:{},children:s.name})}),ce=Y.observer(({db:e,property:n,value:t,entityRoutes:a})=>{const[r,o]=yt(e,n,t,a);return i.jsx(u.Group,{gap:"xs",children:t.map((l,s)=>{const c=r[l];return c===void 0?i.jsx(u.Text,{size:"sm",children:t},l):c===null?i.jsx(Fe,{},l):o===void 0?i.jsx(u.Text,{size:"sm",children:c.name},s):i.jsx(Be.InternalLink,{path:o,openInNewPage:!1,urlArgs:{id:c.id},queryArgs:{},children:c.name},s)})})}),K={string:ee,integer:ee,float:ee,boolean:ee,"string[]":ee,enum:ee},vr=({property:e,value:n,onChange:t})=>i.jsx(u.Input,{id:e.name,type:"checkbox",checked:n,onChange:a=>{const r=a.target.checked;t(r)}}),bt=({property:e,value:n,onChange:t})=>i.jsx(u.Input,{id:e.name,type:"number",value:n,onChange:a=>{const r=a.target.value;t(r===""?void 0:Number(r))}}),xr={lang2value:{en:"The leading zero is not necessary in international phone number format. For example, if your phone number is 0123456789, you should enter it as 123-456-789.",vi:"Số 0 đầu tiên không cần thiết trong định dạng điện thoại quốc tế. Ví dụ, nếu số điện thoại của bạn là 0123456789, bạn nên nhập nó là 123-456-789."},lang:"en"},yr={lang2value:{en:"No valid country code found.",vi:"Không tìm thấy mã quốc gia hợp lệ. "},lang:"en"},te={84:{name:"Vietnam",flags:[N.VN]},1:{name:"US, Canada",flags:[N.US,N.CA]},61:{name:"Australia",flags:[N.AU]},81:{name:"Japan",flags:[N.JP]},44:{name:"UK",flags:[N.UK]},33:{name:"France",flags:[N.FR]},49:{name:"Germany",flags:[N.DE]},91:{name:"India",flags:[N.IN]},55:{name:"Brazil",flags:[N.BR]},34:{name:"Spain",flags:[N.ES]},39:{name:"Italy",flags:[N.IT]},64:{name:"New Zealand",flags:[N.NZ]},52:{name:"Mexico",flags:[N.MX]},86:{name:"China",flags:[N.CN]}},br=(e,n)=>{if(e==="")return{match:"84",remaining:""};const t=e.replace(/[^\d]/g,""),a=n.findLongestPrefix(t);if(a.match==="")throw new Error(`No valid country code found for phone number: ${e}`);return a},wt=({value:e})=>{const n=te[e];if(n!==void 0)return i.jsxs(u.Group,{gap:"sm",wrap:"nowrap",align:"center",children:[i.jsxs(u.Text,{size:"sm",children:["+",e]}),i.jsx(u.Group,{gap:4,wrap:"nowrap",children:n.flags.map((t,a)=>i.jsx(fe,{flag:t},a))})]})},wr=({value:e,onChange:n,error:t,id:a})=>{const[r,o]=j.useState(""),[l,s]=j.useState(!1),[c,d]=j.useState(""),[h,x]=j.useState(!1),p=j.useMemo(()=>{const w=new mt;return Object.keys(te).forEach(S=>{w.insert(S)}),w},[te]),{rawInput:v}=j.useMemo(()=>{try{const{match:w,remaining:S}=br(e,p);return d(w),x(!1),{rawInput:S}}catch{return x(!0),d(""),{rawInput:e}}},[e]),y=u.useCombobox({onDropdownClose:()=>{y.resetSelectedOption(),o("")},onDropdownOpen:()=>{y.updateSelectedOptionIndex("active")}}),m=j.useMemo(()=>Object.keys(te),[te]),E=(w,S)=>{const R=w.replace(/[^\d]/g,"");return R.length===0?`+${S}`:R.startsWith("0")?(s(!0),`+${S}${R}`):(s(!1),`+${S}${R}`)},b=j.useMemo(()=>m.filter(w=>te[w].name.toLowerCase().includes(r.toLowerCase())||w.includes(r)),[r,m]),T=j.useMemo(()=>b.map((w,S)=>i.jsx(u.Combobox.Option,{value:w,children:i.jsx(wt,{value:w})},S)),[b]);return i.jsxs("div",{children:[i.jsx(u.Grid,{gutter:"xs",children:i.jsx(u.Grid.Col,{children:i.jsxs(u.Group,{gap:5,children:[i.jsxs(u.Combobox,{store:y,position:"top-start",onOptionSubmit:w=>{o(""),y.closeDropdown(),n({target:{value:E(v,w)}})},children:[i.jsx(u.Combobox.Target,{children:i.jsx(u.InputBase,{component:"button",type:"button",pointer:!0,rightSection:i.jsx(u.Combobox.Chevron,{}),onClick:()=>y.toggleDropdown(),rightSectionPointerEvents:"none",w:110,children:i.jsx(wt,{value:c})})}),i.jsxs(u.Combobox.Dropdown,{children:[i.jsx(u.Combobox.Search,{leftSection:i.jsx(M.IconSearch,{size:14,stroke:1.5}),placeholder:".....",value:r,onChange:w=>o(w.currentTarget.value)}),i.jsx(u.Combobox.Options,{children:T.length>0?T:i.jsx(u.Combobox.Empty,{children:i.jsx(u.Text,{size:"sm",children:"Nothing found"})})})]})]}),c===""?i.jsx(u.Input,{id:a,value:v,type:"phone_number",onChange:w=>{n({target:{value:w.target.value}})},error:t,flex:1}):i.jsx(u.Input,{id:a,value:v,type:"phone_number",onAccept:w=>{const S=w.replace(/[^\d]/g,"");n({target:{value:E(S,c)}})},component:Bt.IMaskInput,mask:"000-000-0000",error:t,flex:1})]})})}),(l||h||t&&typeof t=="string")&&i.jsx(u.Grid,{gutter:"xs",children:i.jsx(u.Grid.Col,{children:i.jsx(u.Input.Error,{children:l?i.jsx(O,{value:xr}):h?i.jsx(O,{value:yr}):t})})})]})},Le=({property:e,error:n,value:t,onChange:a})=>{const[r,o]=j.useMemo(()=>e.constraints.includes("password")?["password",u.PasswordInput]:e.constraints.includes("phone_number")?["phone_number",wr]:[e.constraints.includes("email")?"email":e.constraints.includes("url")?"url":"text",u.Input],[e.constraints]);return i.jsx(o,{id:e.name,value:t,type:r,onChange:l=>a(l.target.value),error:n})},Me={integer:bt,float:bt,string:Le,boolean:vr,"string[]":Le,enum:Le};function jr(e,n){const[t,a]=j.useState(""),[r,o]=j.useState([]);return j.useEffect(()=>{e.getByName(n.targetClass).fetch({limit:100,offset:0}).then(s=>o(s.records))},[n.name]),{data:r,query:t,setQuery:s=>{a(s);const c=e.getByName(n.targetClass);o(c.filter(d=>d.name.toLowerCase().includes(s.toLowerCase())))},table:e.getByName(n.targetClass)}}const Cr=e=>e.name,Sr=e=>i.jsx(u.Text,{size:"sm",children:e.name}),Er=Y.observer(e=>i.jsx("h1",{children:"SingleForeignKey"})),kr=Y.observer(({db:e,property:n,value:t,onChange:a})=>{const{table:r,data:o,query:l,setQuery:s}=jr(e,n);return i.jsxs(u.Stack,{gap:"sm",children:[i.jsx(Tr,{name:n.name,query:l,setQuery:s,data:o,onSelect:c=>{t.includes(c)||a([...t,c])},renderOption:Cr,isIdInteger:n.datatype==="integer"}),i.jsx(Rr,{items:t.map(c=>r.get(c)),onDelete:c=>{a(t.filter(d=>d!==c.id))},render:Sr})]})}),Tr=({name:e,data:n,onSelect:t,renderOption:a,isIdInteger:r,query:o,setQuery:l})=>{const s=u.useCombobox({onDropdownClose:()=>s.resetSelectedOption()}),c=j.useMemo(()=>n.map(d=>i.jsx(u.Combobox.Option,{value:d.id.toString(),children:a(d)},d.id)),[n]);return i.jsxs(u.Combobox,{store:s,onOptionSubmit:d=>{t(r?parseInt(d):d),l(""),s.closeDropdown()},offset:0,shadow:"sm",children:[i.jsx(u.Combobox.Target,{children:i.jsx(u.Input,{id:e,pointer:!0,rightSection:i.jsx(M.IconSearch,{size:16,stroke:1.5}),rightSectionPointerEvents:"none",onClick:()=>s.toggleDropdown(),placeholder:"Type to search...",value:o,onChange:d=>{l(d.currentTarget.value)}})}),i.jsx(u.Combobox.Dropdown,{children:i.jsx(u.Combobox.Options,{children:c.length===0?i.jsx(u.Combobox.Empty,{children:"Nothing found"}):c})})]})},Rr=({items:e,onDelete:n,render:t})=>{const a=j.useMemo(()=>{const r=[];for(let o=0;o<e.length;o++){const l=e[o];r.push(i.jsxs(u.Group,{justify:"space-between",p:"sm",children:[t(l),i.jsx(u.CloseButton,{size:"sm",onClick:()=>n(l)})]},o)),o<e.length-1&&r.push(i.jsx(u.Divider,{},`divider-${o}`))}return r},[e]);if(a.length!==0)return i.jsx(u.Paper,{bd:"1px solid #ddd",children:a})},jt={requiredLabelLeft:"_requiredLabelLeft_l5p83_1",requiredLabelRight:"_requiredLabelRight_l5p83_11"},Ct=({label:e,name:n,required:t=!1,tooltip:a,style:r,align:o="left"})=>{const l=t?o==="left"?jt.requiredLabelRight:jt.requiredLabelLeft:"";return i.jsx(u.Flex,{align:"center",h:36,children:i.jsx("label",{htmlFor:n,style:r,children:i.jsxs(u.Group,{gap:4,children:[i.jsx(u.Text,{size:"sm",className:l,children:e}),a!==void 0&&i.jsx(u.Tooltip,{label:a,withArrow:!0,children:i.jsx(M.IconHelpOctagonFilled,{size:16,stroke:1.5,style:{color:"var(--mantine-color-dimmed)"}})})]})})})},Pr={type:"vertical",helpAlwaysVisible:!1},St=Y.observer(({store:e,record:n,property:t,layout:a=Pr,InputComponent:r,validator:o})=>{const[l,s]=j.useState(void 0),c=n[t.tsName],d=x=>{var v;if(J.isDraftRecord(n))n[t.updateFuncName](x);else{const y=n.toDraft();y[t.updateFuncName](x),e.setDraft(y)}const p=o(x);p.isValid?s(void 0):s((v=p.errorMessage)==null?void 0:v.t({args:{name:t.label}}))};if(Nr(a))return i.jsxs(u.Stack,{gap:5,children:[i.jsxs(u.Grid,{gutter:"sm",children:[i.jsx(u.Grid.Col,{span:a.labelCol,style:{display:"flex",justifyContent:a.align||"left"},children:i.jsx(Ct,{label:i.jsx(O,{value:t.label}),name:t.name,required:t.isRequired,tooltip:t.description!==void 0?i.jsx(O,{value:t.description}):void 0,align:a.align})}),i.jsx(u.Grid.Col,{span:a.itemCol,children:i.jsx(r,{db:e.db,property:t,value:c,error:l!==void 0,onChange:d})})]}),l!==void 0&&i.jsxs(u.Grid,{gutter:"sm",children:[i.jsx(u.Grid.Col,{span:a.labelCol}),i.jsx(u.Grid.Col,{span:a.itemCol,children:i.jsx(u.Input.Error,{children:l})})]})]});let h=i.jsx(O,{value:t.label});return!a.helpAlwaysVisible&&t.description!==void 0&&(h=i.jsxs(u.Group,{gap:4,style:{display:"inline-flex"},children:[h,i.jsx(u.Tooltip,{label:i.jsx(O,{value:t.description}),withArrow:!0,children:i.jsx(M.IconHelpOctagonFilled,{size:16,stroke:1.5,style:{color:"var(--mantine-color-dimmed)"}})})]})),i.jsx(u.Input.Wrapper,{label:h,description:a.helpAlwaysVisible&&t.description!==void 0?i.jsx(O,{value:t.description}):void 0,required:t.isRequired,children:i.jsx(r,{db:e.db,property:t,value:c,error:l,onChange:d})})});function Nr(e){return e.type==="horizontal"}const Et=12,Ir=e=>{const n=e.schema,t=j.useMemo(()=>{const a=Math.max(...e.fieldGroups.map(r=>Math.max(...r.fields.map(o=>o.length))));return e.fieldGroups.map((r,o)=>Fr(n,e.store,e.record,o,r,a,e.layout))},[n,e.store,e.record,e.fieldGroups,e.layout]);return i.jsx("form",{onSubmit:e.onSubmit===void 0?void 0:a=>{a.preventDefault(),e.onSubmit!==void 0&&J.isDraftRecord(e.record)&&e.onSubmit(e.record)},children:i.jsxs(u.Stack,{gap:"sm",className:e.className,style:e.styles,children:[t,i.jsx(u.Group,{gap:"sm",children:e.actions.map((a,r)=>i.jsx(u.Button,{variant:a.variant,onClick:()=>{a.onClick!==void 0&&a.onClick()},disabled:a.disabled,children:a.label},r))})]})})};function Fr(e,n,t,a,r,o,l){const s=r.fields,c=[];for(let h=0;h<s.length;h++){const x=Et/s[h].length;if(!Number.isInteger(x))throw new Error(`Span must be an integer, but got ${x} for row ${h}`);let p;l!==void 0&&typeof l=="object"&&l.type==="horizontal"?p={...l,labelCol:Math.floor(l.labelCol*s[h].length/o),itemCol:Et-Math.floor(l.labelCol*s[h].length/o)}:p=l;for(let v=0;v<s[h].length;v++){const y=s[h][v],m=e.allProperties[y];let E;if(J.isObjectProperty(m))E=m.cardinality==="N:N"||m.cardinality==="1:N"?kr:Er;else{if(Me[m.datatype]===void 0)throw new Error(`No input component found for datatype ${m.datatype}`);E=Me[m.datatype]}c.push(i.jsx(u.Grid.Col,{span:x,children:i.jsx(St,{store:n,record:t,property:m,layout:p,InputComponent:E,validator:e.validators[y]})},`${h}-${v}`))}}const d=i.jsx(u.Grid,{gutter:"sm",children:c},a);return r.name!==void 0?i.jsx(u.Fieldset,{legend:r.name,children:d},a):d}const kt=({actions:e,reloadData:n,selectedRowKeys:t,size:a="xs"})=>i.jsxs(u.Group,{gap:a,children:[(e==null?void 0:e.add)&&i.jsx(u.Button,{variant:"light",leftSection:i.jsx(M.IconPlus,{size:16,stroke:1.5}),size:a,onClick:e.add,children:"Add"}),(e==null?void 0:e.edit)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconPencil,{size:16,stroke:1.5}),size:a,variant:"light",onClick:()=>e.edit!==void 0&&e.edit(t[0]),disabled:t.length!==1,children:"Edit"}),(e==null?void 0:e.reload)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconReload,{size:16,stroke:1.5}),size:a,onClick:n,variant:"light",children:"Reload"}),(e==null?void 0:e.import)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconDatabaseImport,{size:16,stroke:1.5}),size:a,variant:"light",onClick:e.import,children:"Import"}),(e==null?void 0:e.export)&&i.jsx(u.Button,{leftSection:i.jsx(M.IconDownload,{size:16,stroke:1.5}),size:a,variant:"light",onClick:e.export,children:"Export"})]}),Tt=e=>e!==void 0&&(e.add!==void 0||e.edit!==void 0||e.delete!==void 0||e.export!==void 0||e.reload===!0||e.import!==void 0),Lr="__selectcol__",{Thead:Mr,Tr:Rt,Th:Ar,Tbody:Or,Td:_r}=u.Table,Pt=e=>{const n=i.jsxs(u.Table,{striped:!0,highlightOnHover:!0,verticalSpacing:"xs",children:[i.jsx(Mr,{children:e.table.getHeaderGroups().map(a=>i.jsx(Rt,{children:a.headers.map(r=>i.jsx(Ar,{w:r.id===Lr?"1%":void 0,children:r.isPlaceholder?null:X.flexRender(r.column.columnDef.header,r.getContext())},r.id))},a.id))}),i.jsx(Or,{pos:"relative",children:e.table.getRowModel().rows.map(a=>i.jsx(Rt,{bg:e.selectedRowKeys[a.id]?"var(--mantine-color-blue-light)":void 0,children:a.getVisibleCells().map(r=>i.jsx(_r,{children:X.flexRender(r.column.columnDef.cell,r.getContext())},r.id))},a.id))})]});if(!e.bordered)return n;const t={};return e.hasTopSection&&(t.borderTopLeftRadius=0,t.borderTopRightRadius=0),e.hasBottomSection&&(t.borderBottomLeftRadius=0,t.borderBottomRightRadius=0),i.jsx(u.Paper,{withBorder:!0,p:0,style:t,children:n})},Dr={pageSizeSelectorActive:"_pageSizeSelectorActive_1wv6j_1"},Nt=({total:e,pageIndex:n,pageSize:t,allowPageSizeChange:a=!0,onUpdatePagination:r})=>{const o=i.jsx(u.Pagination,{size:"sm",total:e,value:n+1,onChange:l=>r(l-1,t)});return a?i.jsxs(u.Group,{gap:"sm",children:[i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",component:"span",pr:"xs",c:"dimmed",children:"Records per page"}),i.jsx($r,{size:"sm",values:["10","20","50","100"],value:t.toString(),onChange:l=>{r(0,parseInt(l,10))}})]}),o]}):o},It={xs:u.rem(22),sm:u.rem(26),md:u.rem(32),lg:u.rem(38),xl:u.rem(44)};function $r({size:e,values:n,value:t,onChange:a}){return i.jsxs(u.Menu,{withinPortal:!0,withArrow:!0,offset:2,children:[i.jsx(u.MenuTarget,{children:i.jsx(u.Button,{size:e,variant:"default",rightSection:i.jsx(M.IconSelector,{size:16,stroke:1.5}),style:[{fontWeight:"normal"},r=>({height:It[e],paddingLeft:r.spacing[e],paddingRight:r.spacing[e]})],styles:{section:{marginInlineStart:2}},children:t})}),i.jsx(u.MenuDropdown,{children:n.map(r=>{const o=r===t;return i.jsx(u.MenuItem,{className:o?Dr.pageSizeSelectorActive:void 0,style:[{height:It[e]}],disabled:o,onClick:()=>a(r),children:i.jsx(u.Text,{component:"div",size:e,children:r})},r)})})]})}const Ft=new Set(["topRight","bottomRight"]),zr=e=>{var b,T;const[n,t]=j.useState({records:[],total:0}),[a,r]=j.useState(!1),[o,l]=j.useState({}),s=w=>{r(!0),e.getData(w).then(S=>{t(S),r(!1)})},c=(w,S)=>{const R={...e.query.query,limit:S,offset:w*S};e.query.update(R)},[d,h,x]=j.useMemo(()=>{const w=e.query.query.limit,S=Math.floor((e.query.query.offset||0)/e.query.query.limit),R=Math.ceil(n.total/e.query.query.limit);return[w,S,R]},[e.query.query.limit,e.query.query.offset,n.total]);j.useEffect(()=>(n.total==0&&s(e.query.query),e.query.subscribe(s)),[e.query]);const p=j.useMemo(()=>{const w=e.schema.normalizers[e.schema.primaryKey];return Object.keys(o).filter(S=>o[S]).map(S=>w(S))},[o]);let v,y;Tt(e.actions)&&(v=i.jsx(kt,{actions:e.actions,reloadData:()=>s(e.query.query),selectedRowKeys:p}));const m=((b=e.pagination)==null?void 0:b.positions)||Ft;if(m.size>0){const w=i.jsx(Nt,{total:x,pageIndex:h,pageSize:d,onUpdatePagination:c,allowPageSizeChange:(T=e.pagination)==null?void 0:T.showSizeChanger});m.has("topRight")&&(v!==void 0?v=i.jsxs(u.Group,{justify:"space-between",gap:"sm",children:[v,w]}):v=i.jsx(u.Flex,{justify:"flex-end",children:w})),(m.has("bottomRight")||m.has("bottomLeft")||m.has("bottomCenter"))&&(m.has("bottomLeft")?y=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[w,i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",h*d+1," to"," ",Math.min((h+1)*d,n.total)," of ",n.total," ","records"]})]}):y=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",h*d+1," to"," ",Math.min((h+1)*d,n.total)," of ",n.total," ","records"]}),w]}))}const E=j.useMemo(()=>i.jsx(Br,{data:n,loading:a,columns:e.columns,primaryKey:e.schema.primaryKey,selectedRowKeys:o,setSelectedRowKeys:l,hasTopSection:v!==void 0,hasBottomSection:y!==void 0}),[n,a,e.columns,e.schema.primaryKey,o,l,v!==void 0,y!==void 0]);return v===void 0||y===void 0?E:i.jsxs("div",{children:[v!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:"none"},children:v}),E,y!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderTop:"none"},children:y})]})},Br=e=>{const n=j.useMemo(()=>{const a=[{id:"selection",header:({table:r})=>i.jsx(u.Checkbox,{checked:r.getIsAllRowsSelected(),indeterminate:r.getIsSomeRowsSelected(),onChange:r.getToggleAllRowsSelectedHandler()}),cell:({row:r})=>i.jsx(u.Checkbox,{checked:r.getIsSelected(),disabled:!r.getCanSelect(),onChange:r.getToggleSelectedHandler()})}];return e.columns.forEach(r=>{a.push({id:r.key,header:r.title,accessorFn:r.render,cell:({row:o})=>r.render(o.original)})}),a},[e.columns]),t=X.useReactTable({data:e.data.records,columns:n,getCoreRowModel:X.getCoreRowModel(),getRowId:a=>a[e.primaryKey].toString(),state:{rowSelection:e.selectedRowKeys},onRowSelectionChange:e.setSelectedRowKeys,manualPagination:!0});return i.jsx(Pt,{table:t,selectedRowKeys:e.selectedRowKeys,bordered:!0,hasTopSection:e.hasTopSection,hasBottomSection:e.hasBottomSection})};function Ae(e,n,t){let a;if(J.isObjectProperty(n))n.cardinality==="1:N"||n.cardinality==="N:N"?a=ce:a=ue;else{if(K[n.datatype]===void 0)throw new Error(`No display component found for datatype ${n.datatype}`);a=K[n.datatype]}return{key:n.name,title:i.jsx(O,{value:n.label}),accessorFn:r=>r[n.tsName],render:r=>{const o=r[n.tsName];return i.jsx(a,{db:e,property:n,value:o,entityRoutes:t})}}}function qr(e,n,t,a,{title:r}={}){let o;if(J.isObjectProperty(t))t.cardinality==="1:N"||t.cardinality==="N:N"?o=ce:o=ue;else{if(K[t.datatype]===void 0)throw new Error(`No display component found for datatype ${t.datatype}`);o=K[t.datatype]}return{key:n+"."+t.name,title:r||i.jsx(O,{value:t.label}),accessorFn:l=>l[n.tsName][t.tsName],render:l=>{const s=l[n.tsName][t.tsName];return i.jsx(o,{db:e,property:t,value:s,entityRoutes:a})}}}function Kr(e,n,t,a){return t.map(r=>Oe(r)?r:Ae(e,n.publicProperties[r],a))}function Ur(e,n,t,a){return t.map(r=>Oe(r)?r:Ae(e,n.publicProperties[r],a))}function Oe(e){return typeof e=="object"&&"key"in e&&"title"in e}const Gr=new Set(["topRight","bottomRight"]),Wr=e=>{var h,x;const[n,t]=j.useState({}),a=j.useMemo(()=>{const p=[{id:"selection",header:({table:v})=>i.jsx(u.Checkbox,{checked:v.getIsAllRowsSelected(),indeterminate:v.getIsSomeRowsSelected(),onChange:v.getToggleAllRowsSelectedHandler()}),cell:({row:v})=>i.jsx(u.Checkbox,{checked:v.getIsSelected(),disabled:!v.getCanSelect(),onChange:v.getToggleSelectedHandler()})}];return e.columns.forEach(v=>{p.push({id:v.key,header:v.title,accessorFn:v.render,cell:({row:y})=>v.render(y.original)})}),p},[e.columns]),r=X.useReactTable({data:e.data,columns:a,getCoreRowModel:X.getCoreRowModel(),getPaginationRowModel:X.getPaginationRowModel(),state:{rowSelection:n},onRowSelectionChange:t}),o=j.useMemo(()=>Object.keys(n).filter(p=>n[p]).map(Number),[n]);let l,s;Tt(e.actions)&&(l=i.jsx(kt,{actions:e.actions,selectedRowKeys:o}));const c=((h=e.pagination)==null?void 0:h.positions)||Gr;if(c.size>0){const p=r.getState().pagination,v=i.jsx(Nt,{total:r.getPageCount(),pageIndex:p.pageIndex,pageSize:p.pageSize,onUpdatePagination:(y,m)=>r.setPagination({pageIndex:y,pageSize:m}),allowPageSizeChange:(x=e.pagination)==null?void 0:x.showSizeChanger});c.has("topRight")&&(l!==void 0?l=i.jsxs(u.Group,{justify:"space-between",gap:"sm",children:[l,v]}):l=i.jsx(u.Flex,{justify:"flex-end",children:v})),(c.has("bottomRight")||c.has("bottomLeft")||c.has("bottomCenter"))&&(c.has("bottomLeft")?s=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[v,i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",p.pageIndex*p.pageSize+1," to"," ",Math.min((p.pageIndex+1)*p.pageSize,e.data.length)," of"," ",e.data.length," records"]})]}):s=i.jsxs(u.Flex,{justify:"space-between",align:"center",children:[i.jsxs(u.Text,{size:"sm",c:"dimmed",children:["Showing ",p.pageIndex*p.pageSize+1," to"," ",Math.min((p.pageIndex+1)*p.pageSize,e.data.length)," of"," ",e.data.length," records"]}),v]}))}const d=i.jsx(Pt,{selectedRowKeys:n,table:r,bordered:!0,hasTopSection:l!==void 0,hasBottomSection:s!==void 0});return l===void 0&&s===void 0?d:i.jsxs("div",{children:[l!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:"none"},children:l}),d,s!==void 0&&i.jsx(u.Paper,{withBorder:!0,p:"xs",style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderTop:"none"},children:s})]})},Lt=Y.observer(({store:e,record:n,property:t,DisplayComponent:a,entityRoutes:r})=>{const o=n[t.tsName];return i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",fw:500,children:i.jsx(O,{value:t.label})}),i.jsx(a,{db:e.db,entityRoutes:r,property:t,value:o})]})}),Vr=Y.observer(({store:e,record:n,properties:t,DisplayComponent:a,entityRoutes:r})=>{const o=t[t.length-1],l=t.reduce((s,c)=>{if(s!=null)return s[c.tsName]},n);return i.jsxs("div",{children:[i.jsx(u.Text,{size:"sm",fw:500,children:i.jsx(O,{value:o.label})}),l!==void 0&&i.jsx(a,{db:e.db,property:o,value:l,entityRoutes:r})]})}),Hr=12,Mt=e=>{const n=e.schema,t=j.useMemo(()=>e.fieldGroups.map((a,r)=>Yr(n,e.store,e.record,r,a,e.entityRoutes)),[n,e.store,e.record,e.fieldGroups]);return i.jsx(u.Stack,{gap:"sm",className:e.className,style:e.styles,children:t})};function Yr(e,n,t,a,r,o){const l=r.fields,s=[];for(let c=0;c<l.length;c++){const d=Hr/l[c].length;if(!Number.isInteger(d))throw new Error(`Span must be an integer, but got ${d} for row ${c}`);for(let h=0;h<l[c].length;h++){const x=l[c][h];let p;if(typeof x=="function")p=x(n,t);else if(typeof x=="object"&&"prop"in x){const v=e.allProperties[x.prop],y=x.display;p=i.jsx(Lt,{store:n,record:t,property:v,DisplayComponent:y,entityRoutes:o})}else{const v=e.allProperties[x];let y;if(J.isObjectProperty(v))y=v.cardinality==="N:N"||v.cardinality==="1:N"?ce:ue;else{if(K[v.datatype]===void 0)throw new Error(`No display component found for datatype ${v.datatype}`);y=K[v.datatype]}p=i.jsx(Lt,{store:n,record:t,property:v,DisplayComponent:y,entityRoutes:o})}s.push(i.jsx(u.Grid.Col,{span:d,children:p},`${c}-${h}`))}}return i.jsx(u.Grid,{gutter:"sm",children:s},a)}function Jr(e,n,t){const a=e[e.length-1];let r;if(t!==void 0)r=t;else if(J.isObjectProperty(a))r=a.cardinality==="N:N"||a.cardinality==="1:N"?ce:ue;else{if(K[a.datatype]===void 0)throw new Error(`No display component found for datatype ${a.datatype}`);r=K[a.datatype]}return(o,l)=>i.jsx(Vr,{store:o,record:l,properties:e,DisplayComponent:r,entityRoutes:n})}const Xr=e=>i.jsxs(u.Tabs,{defaultValue:e.fieldTabs[0].tabName,children:[i.jsx(u.Tabs.List,{children:e.fieldTabs.map((n,t)=>i.jsx(u.Tabs.Tab,{value:n.tabName,children:n.tabName},t))}),e.fieldTabs.map((n,t)=>i.jsx(u.Tabs.Panel,{value:n.tabName,pt:"sm",children:i.jsx(Mt,{schema:e.schema,store:e.store,record:e.record,fieldGroups:n.fieldGroups,styles:e.tabStyles,className:e.tabClassName,entityRoutes:e.entityRoutes})},t))]});C.CountryFlagComponent=fe,C.DEFAULT_PAGINATION_POSITIONS=Ft,C.DataType2Component=Me,C.DataType2DisplayComponent=K,C.EmojiCountryFlag=We,C.FormItem=St,C.FormItemLabel=Ct,C.LanguageSelector=Vt,C.Loading=fr,C.LoadingInline=hr,C.LocaleContext=Ve,C.MenuTrie=pt,C.MultiForeignKeyDisplay=ce,C.MultiLingualString=O,C.NotAuthorized=mr,C.NotFound=cr,C.NotFoundInline=Fe,C.NotFoundSubPage=dr,C.Permission=gt,C.SVGCountryFlag=Ge,C.SeraEmbeddedTable=Wr,C.SeraForm=Ir,C.SeraTable=zr,C.SeraVerticalMenu=pr,C.SeraView=Mt,C.SeraViewTab=Xr,C.SingleForeignKeyDisplay=ue,C.buildMenuItemIndex=vt,C.countryFlags=N,C.filterAllowedItems=xt,C.isSeraColumn=Oe,C.makeEmbeddedTableColumns=Ur,C.makeFieldDisplay=Jr,C.makeTableColumn=Ae,C.makeTableColumnFromNestedProperty=qr,C.makeTableColumns=Kr,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sera-components",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.umd.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.umd.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite",
|
|
20
|
+
"build": "tsc -b tsconfig.build.json && vite build",
|
|
21
|
+
"preview": "vite preview",
|
|
22
|
+
"test": "vitest"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"typescript": "~5.7.2",
|
|
26
|
+
"vite": "^6.2.0",
|
|
27
|
+
"vite-plugin-dts": "^4.5.3",
|
|
28
|
+
"vitest": "^3.2.4",
|
|
29
|
+
"@types/react": "^19.0.12",
|
|
30
|
+
"@types/react-dom": "^19.0.4"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@mantine/core": "^8.1.0",
|
|
34
|
+
"@mantine/form": "^8.1.0",
|
|
35
|
+
"react": "^19.0.0",
|
|
36
|
+
"react-dom": "^19.0.0",
|
|
37
|
+
"react-router": "^7.7.1",
|
|
38
|
+
"react-imask": "^7.6.1",
|
|
39
|
+
"@tabler/icons-react": "^3.31.0",
|
|
40
|
+
"@tanstack/react-table": "^8.21.3",
|
|
41
|
+
"mobx-react-lite": "^4.1.0",
|
|
42
|
+
"sera-db": "^1.11.6",
|
|
43
|
+
"sera-route": "^1.3.2"
|
|
44
|
+
}
|
|
45
|
+
}
|