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