sera-components 1.1.10 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/basic/ExternalComponents.d.ts +16 -0
- package/dist/basic/Menu.d.ts +29 -28
- package/dist/data/display/index.d.ts +3 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2475 -1222
- 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(S,b){typeof exports=="object"&&typeof module<"u"?b(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"],b):(S=typeof globalThis<"u"?globalThis:S||self,b(S["sera-components"]={},S.React,S["@mantine/core"],S["@tabler/icons-react"],S["mobx-react-lite"],S["sera-db"],S.ReactIMask,S["@tanstack/react-table"]))})(this,function(S,b,d,M,U,G,Gt,Y){"use strict";var fa=Object.defineProperty;var ha=(S,b,d)=>b in S?fa(S,b,{enumerable:!0,configurable:!0,writable:!0,value:d}):S[b]=d;var H=(S,b,d)=>ha(S,typeof b!="symbol"?b+"":b,d);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(b);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 We;function Kt(){if(We)return oe;We=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 u in r)u!=="key"&&(o[u]=r[u])}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 Ke;function Vt(){return Ke||(Ke=1,process.env.NODE_ENV!=="production"&&function(){function e(g){if(g==null)return null;if(typeof g=="function")return g.$$typeof===K?null:g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case j:return"Fragment";case v: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 y:return"Portal";case w:return(g.displayName||"Context")+".Provider";case k:return(g._context.displayName||"Context")+".Consumer";case T:var C=g.render;return g=g.displayName,g||(g=C.displayName||C.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case X:return C=g.displayName||null,C!==null?C:e(g.type)||"Memo";case Z:C=g._payload,g=g._init;try{return e(g(C))}catch{}}return null}function n(g){return""+g}function t(g){try{n(g);var C=!1}catch{C=!0}if(C){C=console;var N=C.error,F=typeof Symbol=="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return N.call(C,"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===j)return"<>";if(typeof g=="object"&&g!==null&&g.$$typeof===Z)return"<...>";try{var C=e(g);return C?"<"+C+">":"<...>"}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 C=Object.getOwnPropertyDescriptor(g,"key").get;if(C&&C.isReactWarning)return!1}return g.key!==void 0}function u(g,C){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)",C))}N.isReactWarning=!0,Object.defineProperty(g,"key",{get:N,configurable:!0})}function s(){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,C,N,F,V,D,qe,Ue){return N=D.ref,g={$$typeof:f,type:g,key:C,props:D,_owner:V},(N!==void 0?N:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:s}):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:qe}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ue}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function h(g,C,N,F,V,D,qe,Ue){var L=C.children;if(L!==void 0)if(F)if(da(L)){for(F=0;F<L.length;F++)x(L[F]);Object.freeze&&Object.freeze(L)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(L);if(_t.call(C,"key")){L=e(g);var ae=Object.keys(C).filter(function(ca){return ca!=="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(C)&&(t(C.key),L=""+C.key),"key"in C){N={};for(var Ge in C)Ge!=="key"&&(N[Ge]=C[Ge])}else N=C;return L&&u(N,typeof g=="function"?g.displayName||g.name||"Unknown":g),c(g,L,D,V,r(),N,qe,Ue)}function x(g){typeof g=="object"&&g!==null&&g.$$typeof===f&&g._store&&(g._store.validated=1)}var p=b,f=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),w=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=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_t=Object.prototype.hasOwnProperty,da=Array.isArray,Be=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(g){return g()}};var $t,zt={},Bt=p.react_stack_bottom_frame.bind(p,o)(),qt=Be(a(o)),Ut={};ie.Fragment=j,ie.jsx=function(g,C,N,F,V){var D=1e4>re.recentlyCreatedOwnerStacks++;return h(g,C,N,!1,F,V,D?Error("react-stack-top-frame"):Bt,D?Be(a(g)):qt)},ie.jsxs=function(g,C,N,F,V){var D=1e4>re.recentlyCreatedOwnerStacks++;return h(g,C,N,!0,F,V,D?Error("react-stack-top-frame"):Bt,D?Be(a(g)):qt)}}()),ie}var Ve;function Ht(){return Ve||(Ve=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:"🇮🇳"}},He=({flag:e})=>i.jsx(d.Paper,{shadow:"xs",w:20,h:14,children:i.jsx(d.Image,{src:e.svgFlag,w:20,h:14,fit:"cover"})}),Ye=({flag:e})=>i.jsx(d.Text,{component:"span",style:n=>({textShadow:n.shadows.xs}),children:e.emojiFlag}),fe=navigator.userAgent.includes("Windows")?He:Ye,Q=b.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=b.useMemo(()=>Object.entries(he).map(([a,{flag:r,name:o,locale:l}])=>i.jsx(d.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(d.Text,{size:"sm",children:o})},a)),[he,e]);return i.jsxs(d.Menu,{width:170,children:[i.jsx(d.Menu.Target,{children:i.jsx(d.Button,{variant:"subtle",size:"sm",leftSection:i.jsx(fe,{flag:he[e.language].flag}),children:i.jsx(d.Text,{size:"sm",children:he[e.language].name})})}),i.jsxs(d.Menu.Dropdown,{children:[i.jsx(d.Menu.Label,{children:i.jsx(d.Text,{size:"sm",children:Jt.lang2value[e.language]})}),t]})]})},O=({value:e})=>{const n=b.useContext(Q);return e.lang2value[n.language]||e.lang2value[e.lang]};/**
|
|
23
|
+
* react-router v7.7.1
|
|
24
|
+
*
|
|
25
|
+
* Copyright (c) Remix Software Inc.
|
|
26
|
+
*
|
|
27
|
+
* This source code is licensed under the MIT license found in the
|
|
28
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
29
|
+
*
|
|
30
|
+
* @license MIT
|
|
31
|
+
*/function I(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function _(e,n){if(!e){typeof console<"u"&&console.warn(n);try{throw new Error(n)}catch{}}}function je({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 Ce(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 Je(e,n,t="/"){return Zt(e,n,t,!1)}function Zt(e,n,t,a){let r=typeof n=="string"?Ce(n):n,o=W(r.pathname||"/",t);if(o==null)return null;let l=Xe(e);Qt(l);let u=null;for(let s=0;u==null&&s<l.length;++s){let c=cn(o);u=un(l[s],c,a)}return u}function Xe(e,n=[],t=[],a=""){let r=(o,l,u)=>{let s={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};s.relativePath.startsWith("/")&&(I(s.relativePath.startsWith(a),`Absolute route path "${s.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),s.relativePath=s.relativePath.slice(a.length));let c=$([a,s.relativePath]),h=t.concat(s);o.children&&o.children.length>0&&(I(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),Xe(o.children,n,h,c)),!(o.path==null&&!o.index)&&n.push({path:c,score:ln(c,o.index),routesMeta:h})};return e.forEach((o,l)=>{var u;if(o.path===""||!((u=o.path)!=null&&u.includes("?")))r(o,l);else for(let s of Ze(o.path))r(o,l,s)}),n}function Ze(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=Ze(a.join("/")),u=[];return u.push(...l.map(s=>s===""?o:[o,s].join("/"))),r&&u.push(...l),u.map(s=>e.startsWith("/")&&s===""?"/":s)}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,Qe=e=>e==="*";function ln(e,n){let t=e.split("/"),a=t.length;return t.some(Qe)&&(a+=on),n&&(a+=nn),t.filter(r=>!Qe(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 u=0;u<a.length;++u){let s=a[u],c=u===a.length-1,h=o==="/"?n:n.slice(o.length)||"/",x=me({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},h),p=s.route;if(!x&&c&&t&&!a[a.length-1].route.index&&(x=me({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},h)),!x)return null;Object.assign(r,x.params),l.push({params:r,pathname:$([o,x.pathname]),pathnameBase:gn($([o,x.pathnameBase])),route:p}),x.pathnameBase!=="/"&&(o=$([o,x.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"),u=r.slice(1);return{params:a.reduce((c,{paramName:h,isOptional:x},p)=>{if(h==="*"){let y=u[p]||"";l=o.slice(0,o.length-y.length).replace(/(.)\/+$/,"$1")}const f=u[p];return x&&!f?c[h]=void 0:c[h]=(f||"").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,u,s)=>(a.push({paramName:u,isOptional:s!=null}),s?"/?([^\\/]+)?":"/([^\\/]+)"));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"?Ce(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 et(e){let n=mn(e);return n.map((t,a)=>a===n.length-1?t.pathname:t.pathnameBase)}function tt(e,n,t,a=!1){let r;typeof e=="string"?r=Ce(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,u;if(l==null)u=t;else{let x=n.length-1;if(!a&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),x-=1;r.pathname=p.join("/")}u=x>=0?n[x]:"/"}let s=fn(r,u),c=l&&l!=="/"&&l.endsWith("/"),h=(o||l===".")&&t.endsWith("/");return!s.pathname.endsWith("/")&&(c||h)&&(s.pathname+="/"),s}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 nt=["POST","PUT","PATCH","DELETE"];new Set(nt);var yn=["GET",...nt];new Set(yn);var ee=m.createContext(null);ee.displayName="DataRouter";var ge=m.createContext(null);ge.displayName="DataRouterState",m.createContext(!1);var rt=m.createContext({isTransitioning:!1});rt.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 Ee=m.createContext(null);Ee.displayName="Location";var B=m.createContext({outlet:null,matches:[],isDataRoute:!1});B.displayName="Route";var Te=m.createContext(null);Te.displayName="RouteError";function Sn(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}),u=o;return t!=="/"&&(u=o==="/"?t:$([t,o])),a.createHref({pathname:u,search:l,hash:r})}function pe(){return m.useContext(Ee)!=null}function J(){return I(pe(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Ee).location}var at="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ot(e){m.useContext(z).static||m.useLayoutEffect(e)}function it(){let{isDataRoute:e}=m.useContext(B);return e?On():jn()}function jn(){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(et(a)),l=m.useRef(!1);return ot(()=>{l.current=!0}),m.useCallback((s,c={})=>{if(_(l.current,at),!l.current)return;if(typeof s=="number"){t.go(s);return}let h=tt(s,JSON.parse(o),r,c.relative==="path");e==null&&n!=="/"&&(h.pathname=h.pathname==="/"?n:$([n,h.pathname])),(c.replace?t.replace:t.push)(h,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(et(t));return m.useMemo(()=>tt(e,JSON.parse(r),a,n==="path"),[e,r,a,n])}function Cn(e,n,t,a){I(pe(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=m.useContext(z),{matches:o}=m.useContext(B),l=o[o.length-1],u=l?l.params:{},s=l?l.pathname:"/",c=l?l.pathnameBase:"/",h=l&&l.route;{let v=h&&h.path||"";st(s,!h||v.endsWith("*")||v.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${v}">) 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="${v}"> to <Route path="${v==="/"?"*":`${v}/*`}">.`)}let x=J(),p;p=x;let f=p.pathname||"/",y=f;if(c!=="/"){let v=c.replace(/^\//,"").split("/");y="/"+f.replace(/^\//,"").split("/").slice(v.length).join("/")}let j=Je(e,{pathname:y});return _(h||j!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),_(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),Rn(j&&j.map(v=>Object.assign({},v,{params:Object.assign({},u,v.params),pathname:$([c,r.encodeLocation?r.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?c:$([c,r.encodeLocation?r.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),o,t,a)}function kn(){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 En=m.createElement(kn,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){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?m.createElement(B.Provider,{value:this.props.routeContext},m.createElement(Te.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){if(e==null){if(!t)return null;if(t.errors)e=t.matches;else if(n.length===0&&!t.initialized&&t.matches.length>0)e=t.matches;else return null}let r=e,o=t==null?void 0:t.errors;if(o!=null){let s=r.findIndex(c=>c.route.id&&(o==null?void 0:o[c.route.id])!==void 0);I(s>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),r=r.slice(0,Math.min(r.length,s+1))}let l=!1,u=-1;if(t)for(let s=0;s<r.length;s++){let c=r[s];if((c.route.HydrateFallback||c.route.hydrateFallbackElement)&&(u=s),c.route.id){let{loaderData:h,errors:x}=t,p=c.route.loader&&!h.hasOwnProperty(c.route.id)&&(!x||x[c.route.id]===void 0);if(c.route.lazy||p){l=!0,u>=0?r=r.slice(0,u+1):r=[r[0]];break}}}return r.reduceRight((s,c,h)=>{let x,p=!1,f=null,y=null;t&&(x=o&&c.route.id?o[c.route.id]:void 0,f=c.route.errorElement||En,l&&(u<0&&h===0?(st("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,y=null):u===h&&(p=!0,y=c.route.hydrateFallbackElement||null)));let j=n.concat(r.slice(0,h+1)),E=()=>{let v;return x?v=f:p?v=y:c.route.Component?v=m.createElement(c.route.Component,null):c.route.element?v=c.route.element:v=s,m.createElement(Nn,{match:c,routeContext:{outlet:s,matches:j,isDataRoute:t!=null},children:v})};return t&&(c.route.ErrorBoundary||c.route.errorElement||h===0)?m.createElement(Tn,{location:t.location,revalidation:t.revalidation,component:f,error:x,children:E(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):E()},null)}function Ne(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,Ne(e)),n}function In(e){let n=m.useContext(ge);return I(n,Ne(e)),n}function Fn(e){let n=m.useContext(B);return I(n,Ne(e)),n}function Re(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 Re("useRouteId")}function Mn(){var a;let e=m.useContext(Te),n=In("useRouteError"),t=Re("useRouteError");return e!==void 0?e:(a=n.errors)==null?void 0:a[t]}function On(){let{router:e}=Pn("useNavigate"),n=Re("useNavigate"),t=m.useRef(!1);return ot(()=>{t.current=!0}),m.useCallback(async(r,o={})=>{_(t.current,at),t.current&&(typeof r=="number"?e.navigate(r):await e.navigate(r,{fromRouteId:n,...o}))},[e,n])}var lt={};function st(e,n,t){!n&&!lt[e]&&(lt[e]=!0,_(!1,t))}m.memo(An);function An({routes:e,future:n,state:t}){return Cn(e,void 0,t,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 Pe(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 u=e.getAttribute("action");a=u?W(u,n):null,t=e.getAttribute("method")||xe,r=Pe(e.getAttribute("enctype"))||ve,o=new FormData(e)}else if(Dn(e)||$n(e)&&(e.type==="submit"||e.type==="image")){let u=e.form;if(u==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let s=e.getAttribute("formaction")||u.getAttribute("action");if(a=s?W(s,n):null,t=e.getAttribute("formmethod")||u.getAttribute("method")||xe,r=Pe(e.getAttribute("formenctype"))||Pe(u.getAttribute("enctype"))||ve,o=new FormData(u,e),!qn()){let{name:c,type:h,value:x}=e;if(h==="image"){let p=c?`${c}.`:"";o.append(`${p}x`,"0"),o.append(`${p}y`,"0")}else c&&o.append(c,x)}}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 Ie(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 ut(e,n,t,a,r,o){let l=(s,c)=>t[c]?s.route.id!==t[c].route.id:!0,u=(s,c)=>{var h;return t[c].pathname!==s.pathname||((h=t[c].route.path)==null?void 0:h.endsWith("*"))&&t[c].params["*"]!==s.params["*"]};return o==="assets"?n.filter((s,c)=>l(s,c)||u(s,c)):o==="data"?n.filter((s,c)=>{var x;let h=a.routes[s.route.id];if(!h||!h.hasLoader)return!1;if(l(s,c)||u(s,c))return!0;if(s.route.shouldRevalidate){let p=s.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:((x=t[0])==null?void 0:x.params)||{},nextUrl:new URL(e,window.origin),nextParams:s.params,defaultShouldRevalidate:!0});if(typeof p=="boolean")return p}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 dt(){let e=m.useContext(ee);return Ie(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Qn(){let e=m.useContext(ge);return Ie(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Fe=m.createContext(void 0);Fe.displayName="FrameworkContext";function ct(){let e=m.useContext(Fe);return Ie(e,"You must render this element inside a <HydratedRouter> element"),e}function er(e,n){let t=m.useContext(Fe),[a,r]=m.useState(!1),[o,l]=m.useState(!1),{onFocus:u,onBlur:s,onMouseEnter:c,onMouseLeave:h,onTouchStart:x}=n,p=m.useRef(null);m.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let j=v=>{v.forEach(k=>{l(k.isIntersecting)})},E=new IntersectionObserver(j,{threshold:.5});return p.current&&E.observe(p.current),()=>{E.disconnect()}}},[e]),m.useEffect(()=>{if(a){let j=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(j)}}},[a]);let f=()=>{r(!0)},y=()=>{r(!1),l(!1)};return t?e!=="intent"?[o,p,{}]:[o,p,{onFocus:se(u,f),onBlur:se(s,y),onMouseEnter:se(c,f),onMouseLeave:se(h,y),onTouchStart:se(x,f)}]:[!1,p,{}]}function se(e,n){return t=>{e&&e(t),t.defaultPrevented||n(t)}}function tr({page:e,...n}){let{router:t}=dt(),a=m.useMemo(()=>Je(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}=ct(),[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}=ct(),{basename:l}=dt(),{loaderData:u,matches:s}=Qn(),c=m.useMemo(()=>ut(e,n,s,r,a,"data"),[e,n,s,r,a]),h=m.useMemo(()=>ut(e,n,s,r,a,"assets"),[e,n,s,r,a]),x=m.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let y=new Set,j=!1;if(n.forEach(v=>{var w;let k=r.routes[v.route.id];!k||!k.hasLoader||(!c.some(T=>T.route.id===v.route.id)&&v.route.id in u&&((w=o[v.route.id])!=null&&w.shouldRevalidate)||k.hasClientLoader?j=!0:y.add(v.route.id))}),y.size===0)return[];let E=Wn(e,l,"data");return j&&y.size>0&&E.searchParams.set("_routes",n.filter(v=>y.has(v.route.id)).map(v=>v.route.id).join(",")),[E.pathname+E.search]},[l,u,a,r,c,n,e,o]),p=m.useMemo(()=>Yn(h,r),[h,r]),f=nr(h);return m.createElement(m.Fragment,null,x.map(y=>m.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...t})),p.map(y=>m.createElement("link",{key:y,rel:"modulepreload",href:y,...t})),f.map(({key:y,link:j})=>m.createElement("link",{key:y,...j})))}function ar(...e){return n=>{e.forEach(t=>{typeof t=="function"?t(n):t!=null&&(t.current=n)})}}var ft=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ft&&(window.__reactRouterVersion="7.7.1")}catch{}var ht=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,mt=m.forwardRef(function({onClick:n,discover:t="render",prefetch:a="none",relative:r,reloadDocument:o,replace:l,state:u,target:s,to:c,preventScrollReset:h,viewTransition:x,...p},f){let{basename:y}=m.useContext(z),j=typeof c=="string"&&ht.test(c),E,v=!1;if(typeof c=="string"&&j&&(E=c,ft))try{let A=new URL(window.location.href),K=c.startsWith("//")?new URL(A.protocol+c):new URL(c),re=W(K.pathname,y);K.origin===A.origin&&re!=null?c=re+K.search+K.hash:v=!0}catch{_(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let k=Sn(c,{relative:r}),[w,T,P]=er(a,p),ne=sr(c,{replace:l,state:u,target:s,preventScrollReset:h,relative:r,viewTransition:x});function X(A){n&&n(A),A.defaultPrevented||ne(A)}let Z=m.createElement("a",{...p,...P,href:E||k,onClick:v||o?n:X,ref:ar(f,T),target:s,"data-discover":!j&&t==="render"?"true":void 0});return w&&!j?m.createElement(m.Fragment,null,Z,m.createElement(tr,{page:k})):Z});mt.displayName="Link";var or=m.forwardRef(function({"aria-current":n="page",caseSensitive:t=!1,className:a="",end:r=!1,style:o,to:l,viewTransition:u,children:s,...c},h){let x=le(l,{relative:c.relative}),p=J(),f=m.useContext(ge),{navigator:y,basename:j}=m.useContext(z),E=f!=null&&hr(x)&&u===!0,v=y.encodeLocation?y.encodeLocation(x).pathname:x.pathname,k=p.pathname,w=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(k=k.toLowerCase(),w=w?w.toLowerCase():null,v=v.toLowerCase()),w&&j&&(w=W(w,j)||w);const T=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let P=k===v||!r&&k.startsWith(v)&&k.charAt(T)==="/",ne=w!=null&&(w===v||!r&&w.startsWith(v)&&w.charAt(v.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(mt,{...c,"aria-current":Z,className:A,ref:h,style:K,to:l,viewTransition:u},typeof s=="function"?s(X):s)});or.displayName="NavLink";var ir=m.forwardRef(({discover:e="render",fetcherKey:n,navigate:t,reloadDocument:a,replace:r,state:o,method:l=xe,action:u,onSubmit:s,relative:c,preventScrollReset:h,viewTransition:x,...p},f)=>{let y=cr(),j=fr(u,{relative:c}),E=l.toLowerCase()==="get"?"get":"post",v=typeof u=="string"&&ht.test(u),k=w=>{if(s&&s(w),w.defaultPrevented)return;w.preventDefault();let T=w.nativeEvent.submitter,P=(T==null?void 0:T.getAttribute("formmethod"))||l;y(T||w.currentTarget,{fetcherKey:n,method:P,navigate:t,replace:r,state:o,relative:c,preventScrollReset:h,viewTransition:x})};return m.createElement("form",{ref:f,method:E,action:j,onSubmit:a?s:k,...p,"data-discover":!v&&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 gt(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 u=it(),s=J(),c=le(e,{relative:o});return m.useCallback(h=>{if(Bn(h,n)){h.preventDefault();let x=t!==void 0?t:je(s)===je(c);u(e,{replace:x,state:a,preventScrollReset:r,relative:o,viewTransition:l})}},[s,u,c,t,a,n,e,r,o,l])}var ur=0,dr=()=>`__${String(++ur)}__`;function cr(){let{router:e}=gt("useSubmit"),{basename:n}=m.useContext(z),t=Ln();return m.useCallback(async(a,r={})=>{let{action:o,method:l,encType:u,formData:s,body:c}=Gn(a,n);if(r.navigate===!1){let h=r.fetcherKey||dr();await e.fetch(h,t,r.action||o,{preventScrollReset:r.preventScrollReset,formData:s,body:c,formMethod:r.method||l,formEncType:r.encType||u,flushSync:r.flushSync})}else await e.navigate(r.action||o,{preventScrollReset:r.preventScrollReset,formData:s,body:c,formMethod:r.method||l,formEncType:r.encType||u,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 u=new URLSearchParams(o.search),s=u.getAll("index");if(s.some(h=>h==="")){u.delete("index"),s.filter(x=>x).forEach(x=>u.append("index",x));let h=u.toString();o.search=h?`?${h}`:""}}return(!e||e===".")&&r.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(o.pathname=o.pathname==="/"?t:$([t,o.pathname])),je(o)}function hr(e,{relative:n}={}){let t=m.useContext(rt);I(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=gt("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=it();return i.jsx(d.Container,{size:"xs",style:{height:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsx(d.Alert,{color:"red",title:"Not Found",variant:"404 - Not Found",icon:i.jsx(M.IconInfoCircle,{size:12,stroke:1.5}),children:i.jsxs(d.Stack,{align:"flex-start",children:[e||"Sorry, the page you are looking for does not exist.",i.jsx(d.Button,{variant:"filled",onClick:()=>n("/"),size:"xs",children:"Back Home"})]})})})},gr=({message:e})=>i.jsx(d.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."}),Le=({message:e})=>i.jsx(d.Text,{c:"red",size:"sm",children:e||"Not Found"}),pr=({tip:e})=>e===void 0?i.jsx(d.Flex,{justify:"center",align:"center",children:i.jsx(d.Loader,{color:"blue",size:"md"})}):i.jsxs(d.Flex,{gap:"md",direction:"column",justify:"center",align:"center",style:{height:"100%"},children:[i.jsx(d.Loader,{color:"blue",size:"md"}),e]}),xr=({tip:e})=>e===void 0?i.jsx(d.Loader,{color:"blue",size:"xs"}):i.jsxs(d.Flex,{gap:"md",direction:"column",justify:"center",align:"center",children:[i.jsx(d.Loader,{color:"blue",size:"xs"}),e]}),vr=({message:e})=>i.jsx(d.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 Sr{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 Me{constructor(){H(this,"children",new Map);H(this,"isEndOfWord",!1);H(this,"value","")}}class Oe{constructor(){H(this,"root",new Me)}insert(n){let t=this.root;for(const a of n){let r=t.children.get(a);r===void 0&&(r=new Me,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 pt(e){const n={},t={},a={},r=(o,l=[])=>{o.forEach(u=>{const s=[...l,u.key];n[u.key]=u,t[u.key]=s,u.route!==void 0&&(a[u.key]=u.route),u.children!==void 0&&u.children.length>0&&r(u.children,s)})};return r(e),{key2item:n,key2fullpath:t,key2route:a}}function jr(e){const n=new vt,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 xt(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]=b.useState(new Set),[a,r]=b.useState(new Set),[o,l]=b.useState(),u=b.useMemo(()=>xt(e.items,e.checkPermission),[e.items,e.checkPermission]),s=b.useMemo(()=>jr(e.items),[e.items]),{key2fullpath:c,key2route:h}=b.useMemo(()=>pt(u),[u]);b.useEffect(()=>{const p=window.location.pathname,f=s.findMatchingKey(p);f!==void 0&&(r(new Set(c[f])),l(f))},[location,h]);const x=b.useMemo(()=>{function p(f,y){var E;const j=f.children!==void 0&&f.children.length>0;return j?i.jsxs("div",{onMouseEnter:()=>{a.has(f.key)||t(v=>{const k=new Set(v);return k.add(f.key),k})},onMouseLeave:()=>{a.has(f.key)||t(v=>{const k=new Set(v);return k.delete(f.key),k})},children:[i.jsx(d.NavLink,{active:o===f.key,label:f.label,leftSection:f.icon,styles:{label:{fontSize:"md"},root:{borderRadius:"var(--mantine-radius-sm)"}},ml:y===0?void 0:y===1?"md":`calc(var(--mantine-spacing-md) * ${y})`,w:"unset",rightSection:j?i.jsx(M.IconChevronRight,{size:12,stroke:1.5,className:"mantine-rotate-rtl"}):void 0,opened:n.has(f.key)||a.has(f.key),onClick:v=>{v.preventDefault(),r(k=>{const w=new Set(k);return k.has(f.key)?w.delete(f.key):w.add(f.key),w})}},f.key),(a.has(f.key)||n.has(f.key))&&f.children.map(v=>p(v,y+1))]},`container-${f.key}`):i.jsx(d.NavLink,{active:o===f.key,href:(E=f.route)==null?void 0:E.route.fullPath,label:f.label,leftSection:f.icon,styles:{label:{fontSize:"md"},root:{borderRadius:"var(--mantine-radius-sm)"}},ml:y===0?void 0:y===1?"md":`calc(var(--mantine-spacing-md) * ${y})`,w:"unset",onClick:v=>{v.ctrlKey||v.metaKey||(v.preventDefault(),f.route!=null&&e.navigate({to:f.route.route.to}))}},f.key)}return u.map(f=>p(f,0))},[u,o,a,n]);return i.jsx(i.Fragment,{children:x})};class vt extends Oe{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 Se=({value:e})=>i.jsx(d.Text,{size:"sm",children:e});function Ae(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 yt=({value:e})=>{const n=b.useContext(Q),t=b.useMemo(()=>{const a=e.getHours().toString().padStart(2,"0"),r=e.getMinutes().toString().padStart(2,"0"),o=e.getSeconds().toString().padStart(2,"0");return Ae(n,e)+`${a}:${r}:${o}`},[n,e]);return i.jsx(d.Text,{size:"sm",children:t})},bt=({value:e})=>{const n=b.useContext(Q),t=b.useMemo(()=>Ae(n,e),[n,e]);return i.jsx(d.Text,{size:"sm",children:t})},kr=({value:e})=>{const n=b.useContext(Q),[t,a]=b.useMemo(()=>{const r=Ae(n,e),o=e.getHours().toString().padStart(2,"0"),l=e.getMinutes().toString().padStart(2,"0"),u=e.getSeconds().toString().padStart(2,"0");return[r,`${o}:${l}:${u}`]},[n,e]);return i.jsx(d.Text,{size:"sm",title:a,children:t})},Er={yes:{lang2value:{en:"Yes",vi:"Có"},lang:"en"},no:{lang2value:{en:"No",vi:"Không"},lang:"en"}},Tr=({value:e})=>i.jsx(d.Checkbox,{checked:e,label:i.jsx(O,{value:Er[e?"yes":"no"]}),readOnly:!0}),Nr=({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(d.Text,{size:"sm",children:i.jsx(O,{value:a.enumType.label[t]})})},wt=b.createContext({link:()=>null});function St(e,n,t,a){const r=e.getByName(n.targetClass),o=a[n.targetClass];b.useEffect(()=>{r.fetchByIds(t)},[t]);const l={};for(const u of t)l[u]=r.get(u);return[l,o]}const ue=U.observer(({db:e,property:n,value:t,entityRoutes:a})=>{const{link:r}=b.useContext(wt),o=b.useMemo(()=>[t],[t]),[l,u]=St(e,n,o,a),s=l[t];return s===void 0?i.jsx(d.Text,{size:"sm",children:t}):s===null?i.jsx(Le,{}):u===void 0?i.jsx(d.Text,{size:"sm",children:s.name}):i.jsx(r,{to:u.to,openInNewPage:!1,params:{id:s.id},children:s.name})}),de=U.observer(({db:e,property:n,value:t,entityRoutes:a})=>{const{link:r}=b.useContext(wt),[o,l]=St(e,n,t,a);return i.jsx(d.Group,{gap:"xs",children:t.map((u,s)=>{const c=o[u];return c===void 0?i.jsx(d.Text,{size:"sm",children:t},u):c===null?i.jsx(Le,{},u):l===void 0?i.jsx(d.Text,{size:"sm",children:c.name},s):i.jsx(r,{to:l.to,openInNewPage:!1,params:{id:c.id},children:c.name},s)})})}),q={string:Se,integer:Se,float:Se,boolean:Tr,"string[]":Se,enum:Nr,datetime:yt,date:bt},Rr=({property:e,value:n,onChange:t})=>i.jsx(d.Input,{id:e.name,type:"checkbox",checked:n,onChange:a=>{const r=a.target.checked;t(r)}}),jt=({property:e,value:n,onChange:t})=>i.jsx(d.Input,{id:e.name,type:"number",value:n,onChange:a=>{const r=a.target.value;t(r===""?void 0:Number(r))}}),Pr={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"},Ir={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]}},Fr=(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(d.Group,{gap:"sm",wrap:"nowrap",align:"center",children:[i.jsxs(d.Text,{size:"sm",children:["+",e]}),i.jsx(d.Group,{gap:4,wrap:"nowrap",children:n.flags.map((t,a)=>i.jsx(fe,{flag:t},a))})]})},Lr=({value:e,onChange:n,error:t,id:a})=>{const[r,o]=b.useState(""),[l,u]=b.useState(!1),[s,c]=b.useState(""),[h,x]=b.useState(!1),p=b.useMemo(()=>{const w=new Oe;return Object.keys(te).forEach(T=>{w.insert(T)}),w},[te]),{rawInput:f}=b.useMemo(()=>{try{const{match:w,remaining:T}=Fr(e,p);return c(w),x(!1),{rawInput:T}}catch{return x(!0),c(""),{rawInput:e}}},[e]),y=d.useCombobox({onDropdownClose:()=>{y.resetSelectedOption(),o("")},onDropdownOpen:()=>{y.updateSelectedOptionIndex("active")}}),j=b.useMemo(()=>Object.keys(te),[te]),E=(w,T)=>{const P=w.replace(/[^\d]/g,"");return P.length===0?`+${T}`:P.startsWith("0")?(u(!0),`+${T}${P}`):(u(!1),`+${T}${P}`)},v=b.useMemo(()=>j.filter(w=>te[w].name.toLowerCase().includes(r.toLowerCase())||w.includes(r)),[r,j]),k=b.useMemo(()=>v.map((w,T)=>i.jsx(d.Combobox.Option,{value:w,children:i.jsx(Ct,{value:w})},T)),[v]);return i.jsxs("div",{children:[i.jsx(d.Grid,{gutter:"xs",children:i.jsx(d.Grid.Col,{children:i.jsxs(d.Group,{gap:5,children:[i.jsxs(d.Combobox,{store:y,position:"top-start",onOptionSubmit:w=>{o(""),y.closeDropdown(),n({target:{value:E(f,w)}})},children:[i.jsx(d.Combobox.Target,{children:i.jsx(d.InputBase,{component:"button",type:"button",pointer:!0,rightSection:i.jsx(d.Combobox.Chevron,{}),onClick:()=>y.toggleDropdown(),rightSectionPointerEvents:"none",w:110,children:i.jsx(Ct,{value:s})})}),i.jsxs(d.Combobox.Dropdown,{children:[i.jsx(d.Combobox.Search,{leftSection:i.jsx(M.IconSearch,{size:14,stroke:1.5}),placeholder:".....",value:r,onChange:w=>o(w.currentTarget.value)}),i.jsx(d.Combobox.Options,{children:k.length>0?k:i.jsx(d.Combobox.Empty,{children:i.jsx(d.Text,{size:"sm",children:"Nothing found"})})})]})]}),s===""?i.jsx(d.Input,{id:a,value:f,type:"phone_number",onChange:w=>{n({target:{value:w.target.value}})},error:t,flex:1}):i.jsx(d.Input,{id:a,value:f,type:"phone_number",onAccept:w=>{const T=w.replace(/[^\d]/g,"");n({target:{value:E(T,s)}})},component:Gt.IMaskInput,mask:"000-000-0000",error:t,flex:1})]})})}),(l||h||t&&typeof t=="string")&&i.jsx(d.Grid,{gutter:"xs",children:i.jsx(d.Grid.Col,{children:i.jsx(d.Input.Error,{children:l?i.jsx(O,{value:Pr}):h?i.jsx(O,{value:Ir}):t})})})]})},De=({property:e,error:n,value:t,onChange:a})=>{const[r,o]=b.useMemo(()=>e.constraints.includes("password")?["password",d.PasswordInput]:e.constraints.includes("phone_number")?["phone_number",Lr]:[e.constraints.includes("email")?"email":e.constraints.includes("url")?"url":"text",d.Input],[e.constraints]);return i.jsx(o,{id:e.name,value:t,type:r,onChange:l=>a(l.target.value),error:n})},_e={integer:jt,float:jt,string:De,boolean:Rr,"string[]":De,enum:De};function Mr(e,n){const[t,a]=b.useState(""),[r,o]=b.useState([]);return b.useEffect(()=>{e.getByName(n.targetClass).fetch({limit:100,offset:0}).then(u=>o(u.records))},[n.name]),{data:r,query:t,setQuery:u=>{a(u);const s=e.getByName(n.targetClass);o(s.filter(c=>c.name.toLowerCase().includes(u.toLowerCase())))},table:e.getByName(n.targetClass)}}const Or=e=>e.name,Ar=e=>i.jsx(d.Text,{size:"sm",children:e.name}),Dr=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:u}=Mr(e,n);return i.jsxs(d.Stack,{gap:"sm",children:[i.jsx($r,{name:n.name,query:l,setQuery:u,data:o,onSelect:s=>{t.includes(s)||a([...t,s])},renderOption:Or,isIdInteger:n.datatype==="integer"}),i.jsx(zr,{items:t.map(s=>r.get(s)),onDelete:s=>{a(t.filter(c=>c!==s.id))},render:Ar})]})}),$r=({name:e,data:n,onSelect:t,renderOption:a,isIdInteger:r,query:o,setQuery:l})=>{const u=d.useCombobox({onDropdownClose:()=>u.resetSelectedOption()}),s=b.useMemo(()=>n.map(c=>i.jsx(d.Combobox.Option,{value:c.id.toString(),children:a(c)},c.id)),[n]);return i.jsxs(d.Combobox,{store:u,onOptionSubmit:c=>{t(r?parseInt(c):c),l(""),u.closeDropdown()},offset:0,shadow:"sm",children:[i.jsx(d.Combobox.Target,{children:i.jsx(d.Input,{id:e,pointer:!0,rightSection:i.jsx(M.IconSearch,{size:16,stroke:1.5}),rightSectionPointerEvents:"none",onClick:()=>u.toggleDropdown(),placeholder:"Type to search...",value:o,onChange:c=>{l(c.currentTarget.value)}})}),i.jsx(d.Combobox.Dropdown,{children:i.jsx(d.Combobox.Options,{children:s.length===0?i.jsx(d.Combobox.Empty,{children:"Nothing found"}):s})})]})},zr=({items:e,onDelete:n,render:t})=>{const a=b.useMemo(()=>{const r=[];for(let o=0;o<e.length;o++){const l=e[o];r.push(i.jsxs(d.Group,{justify:"space-between",p:"sm",children:[t(l),i.jsx(d.CloseButton,{size:"sm",onClick:()=>n(l)})]},o)),o<e.length-1&&r.push(i.jsx(d.Divider,{},`divider-${o}`))}return r},[e]);if(a.length!==0)return i.jsx(d.Paper,{bd:"1px solid #ddd",children:a})},kt={requiredLabelLeft:"_requiredLabelLeft_l5p83_1",requiredLabelRight:"_requiredLabelRight_l5p83_11"},Et=({label:e,name:n,required:t=!1,tooltip:a,style:r,align:o="left"})=>{const l=t?o==="left"?kt.requiredLabelRight:kt.requiredLabelLeft:"";return i.jsx(d.Flex,{align:"center",h:36,children:i.jsx("label",{htmlFor:n,style:r,children:i.jsxs(d.Group,{gap:4,children:[i.jsx(d.Text,{size:"sm",className:l,children:e}),a!==void 0&&i.jsx(d.Tooltip,{label:a,withArrow:!0,children:i.jsx(M.IconHelpOctagonFilled,{size:16,stroke:1.5,style:{color:"var(--mantine-color-dimmed)"}})})]})})})},Br={type:"vertical",helpAlwaysVisible:!1},Tt=U.observer(({store:e,record:n,property:t,layout:a=Br,InputComponent:r,validator:o})=>{const[l,u]=b.useState(void 0),s=n[t.tsName],c=x=>{var f;if(G.isDraftRecord(n))n[t.updateFuncName](x);else{const y=n.toDraft();y[t.updateFuncName](x),e.setDraft(y)}const p=o(x);p.isValid?u(void 0):u((f=p.errorMessage)==null?void 0:f.t({args:{name:t.label}}))};if(qr(a))return i.jsxs(d.Stack,{gap:5,children:[i.jsxs(d.Grid,{gutter:"sm",children:[i.jsx(d.Grid.Col,{span:a.labelCol,style:{display:"flex",justifyContent:a.align||"left"},children:i.jsx(Et,{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(d.Grid.Col,{span:a.itemCol,children:i.jsx(r,{db:e.db,property:t,value:s,error:l!==void 0,onChange:c})})]}),l!==void 0&&i.jsxs(d.Grid,{gutter:"sm",children:[i.jsx(d.Grid.Col,{span:a.labelCol}),i.jsx(d.Grid.Col,{span:a.itemCol,children:i.jsx(d.Input.Error,{children:l})})]})]});let h=i.jsx(O,{value:t.label});return!a.helpAlwaysVisible&&t.description!==void 0&&(h=i.jsxs(d.Group,{gap:4,style:{display:"inline-flex"},children:[h,i.jsx(d.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(d.Input.Wrapper,{label:h,description:a.helpAlwaysVisible&&t.description!==void 0?i.jsx(O,{value:t.description}):void 0,required:t.isRequired,children:i.jsx(r,{db:e.db,property:t,value:s,error:l,onChange:c})})});function qr(e){return e.type==="horizontal"}const Nt=12,Ur=e=>{const n=e.schema,t=b.useMemo(()=>{const a=Math.max(...e.fieldGroups.map(r=>Math.max(...r.fields.map(o=>o.length))));return e.fieldGroups.map((r,o)=>Gr(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(d.Stack,{gap:"sm",className:e.className,style:e.styles,children:[t,i.jsx(d.Group,{gap:"sm",children:e.actions.map((a,r)=>i.jsx(d.Button,{variant:a.variant,onClick:()=>{a.onClick!==void 0&&a.onClick()},disabled:a.disabled,children:a.label},r))})]})})};function Gr(e,n,t,a,r,o,l){const u=r.fields,s=[];for(let h=0;h<u.length;h++){const x=Nt/u[h].length;if(!Number.isInteger(x))throw new Error(`Span must be an integer, but got ${x} for row ${h}`);let p;l!==void 0&&typeof l=="object"&&l.type==="horizontal"?p={...l,labelCol:Math.floor(l.labelCol*u[h].length/o),itemCol:Nt-Math.floor(l.labelCol*u[h].length/o)}:p=l;for(let f=0;f<u[h].length;f++){const y=u[h][f],j=e.allProperties[y];let E;if(G.isObjectProperty(j))E=j.cardinality==="N:N"||j.cardinality==="1:N"?_r:Dr;else{if(_e[j.datatype]===void 0)throw new Error(`No input component found for datatype ${j.datatype}`);E=_e[j.datatype]}s.push(i.jsx(d.Grid.Col,{span:x,children:i.jsx(Tt,{store:n,record:t,property:j,layout:p,InputComponent:E,validator:e.validators[y]})},`${h}-${f}`))}}const c=i.jsx(d.Grid,{gutter:"sm",children:s},a);return r.name!==void 0?i.jsx(d.Fieldset,{legend:r.name,children:c},a):c}const Rt=({actions:e,reloadData:n,selectedRowKeys:t,size:a="xs"})=>i.jsxs(d.Group,{gap:a,children:[(e==null?void 0:e.add)&&i.jsx(d.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(d.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(d.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(d.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(d.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),Wr="__selectcol__",{Thead:Kr,Tr:It,Th:Vr,Tbody:Hr,Td:Yr}=d.Table,Ft=e=>{const n=i.jsxs(d.Table,{striped:!0,highlightOnHover:!0,verticalSpacing:"xs",tabularNums:!0,children:[i.jsx(Kr,{children:e.table.getHeaderGroups().map(a=>i.jsx(It,{children:a.headers.map(r=>i.jsx(Vr,{w:r.id===Wr?"1%":void 0,children:r.isPlaceholder?null:Y.flexRender(r.column.columnDef.header,r.getContext())},r.id))},a.id))}),i.jsx(Hr,{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(Yr,{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(d.Paper,{withBorder:!0,p:0,style:t,children:n})},Jr={pageSizeSelectorActive:"_pageSizeSelectorActive_1wv6j_1"},Lt=({total:e,pageIndex:n,pageSize:t,allowPageSizeChange:a=!0,onUpdatePagination:r})=>{const o=i.jsx(d.Pagination,{size:"sm",total:e,value:n+1,onChange:l=>r(l-1,t)});return a?i.jsxs(d.Group,{gap:"sm",children:[i.jsxs("div",{children:[i.jsx(d.Text,{size:"sm",component:"span",pr:"xs",c:"dimmed",children:"Records per page"}),i.jsx(Xr,{size:"sm",values:["10","20","50","100"],value:t.toString(),onChange:l=>{r(0,parseInt(l,10))}})]}),o]}):o},Mt={xs:d.rem(22),sm:d.rem(26),md:d.rem(32),lg:d.rem(38),xl:d.rem(44)};function Xr({size:e,values:n,value:t,onChange:a}){return i.jsxs(d.Menu,{withinPortal:!0,withArrow:!0,offset:2,children:[i.jsx(d.MenuTarget,{children:i.jsx(d.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(d.MenuDropdown,{children:n.map(r=>{const o=r===t;return i.jsx(d.MenuItem,{className:o?Jr.pageSizeSelectorActive:void 0,style:[{height:Mt[e]}],disabled:o,onClick:()=>a(r),children:i.jsx(d.Text,{component:"div",size:e,children:r})},r)})})]})}const Ot=new Set(["topRight","bottomRight"]),Zr=e=>{var v,k;const[n,t]=b.useState({records:[],total:0}),[a,r]=b.useState(!1),[o,l]=b.useState({}),u=w=>{r(!0),e.getData(w).then(T=>{t(T),r(!1)})},s=(w,T)=>{const P={...e.query.query,limit:T,offset:w*T};e.query.update(P)},[c,h,x]=b.useMemo(()=>{const w=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[w,T,P]},[e.query.query.limit,e.query.query.offset,n.total]);b.useEffect(()=>(n.total==0&&u(e.query.query),e.query.subscribe(u)),[e.query]);const p=b.useMemo(()=>Object.keys(o).filter(w=>o[w]).map(w=>e.normalizeRowId(w)),[o]);let f,y;Pt(e.actions)&&(f=i.jsx(Rt,{actions:e.actions,reloadData:()=>u(e.query.query),selectedRowKeys:p}));const j=((v=e.pagination)==null?void 0:v.positions)||Ot;if(j.size>0){const w=i.jsx(Lt,{total:x,pageIndex:h,pageSize:c,onUpdatePagination:s,allowPageSizeChange:(k=e.pagination)==null?void 0:k.showSizeChanger});j.has("topRight")&&(f!==void 0?f=i.jsxs(d.Group,{justify:"space-between",gap:"sm",children:[f,w]}):f=i.jsx(d.Flex,{justify:"flex-end",children:w})),(j.has("bottomRight")||j.has("bottomLeft")||j.has("bottomCenter"))&&(j.has("bottomLeft")?y=i.jsxs(d.Flex,{justify:"space-between",align:"center",children:[w,i.jsxs(d.Text,{size:"sm",c:"dimmed",children:["Showing ",h*c+1," to"," ",Math.min((h+1)*c,n.total)," of ",n.total," ","records"]})]}):y=i.jsxs(d.Flex,{justify:"space-between",align:"center",children:[i.jsxs(d.Text,{size:"sm",c:"dimmed",children:["Showing ",h*c+1," to"," ",Math.min((h+1)*c,n.total)," of ",n.total," ","records"]}),w]}))}const E=b.useMemo(()=>i.jsx(Qr,{data:n,loading:a,columns:e.columns,getRowId:e.getRowId,selectedRowKeys:o,setSelectedRowKeys:l,hasTopSection:f!==void 0,hasBottomSection:y!==void 0}),[n,a,e.columns,e.getRowId,o,l,f!==void 0,y!==void 0]);return f===void 0||y===void 0?E:i.jsxs("div",{children:[f!==void 0&&i.jsx(d.Paper,{withBorder:!0,p:"xs",style:{borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:"none"},children:f}),E,y!==void 0&&i.jsx(d.Paper,{withBorder:!0,p:"xs",style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderTop:"none"},children:y})]})},Qr=e=>{const n=b.useMemo(()=>{const a=[{id:"selection",header:({table:r})=>i.jsx(d.Checkbox,{checked:r.getIsAllRowsSelected(),indeterminate:r.getIsSomeRowsSelected(),onChange:r.getToggleAllRowsSelectedHandler()}),cell:({row:r})=>i.jsx(d.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 $e(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 u={key:t.name,title:a||i.jsx(O,{value:t.label}),accessorFn:s=>s[t.tsName],render:s=>{const c=s[t.tsName];return i.jsx(l,{db:e,property:t,value:c,entityRoutes:n})}};return r!==void 0&&(u.accessorFn=s=>s[r][t.tsName],u.render=s=>{const c=s[r][t.tsName];return i.jsx(l,{db:e,property:t,value:c,entityRoutes:n})}),u}function ea(e,n,t,a,{title:r,nestedKey:o,component:l}={}){let u;if(l!==void 0)u=l;else if(G.isObjectProperty(a))a.cardinality==="1:N"||a.cardinality==="N:N"?u=de:u=ue;else{if(q[a.datatype]===void 0)throw new Error(`No display component found for datatype ${a.datatype}`);u=q[a.datatype]}const s={key:t+"."+a.name,title:r||i.jsx(O,{value:a.label}),accessorFn:c=>c[t.tsName][a.tsName],render:c=>{const h=c[t.tsName][a.tsName];return i.jsx(u,{db:e,property:a,value:h,entityRoutes:n})}};return o!==void 0&&(s.accessorFn=c=>c[o][t.tsName][a.tsName],s.render=c=>{const h=c[o][t.tsName][a.tsName];return i.jsx(u,{db:e,property:a,value:h,entityRoutes:n})}),s}function ta(e,n,t,a,r={}){return a.map(o=>ze(o)?o:$e(e,t,n.publicProperties[o],r))}function na(e,n,t,a=[],r={}){return a.map(o=>ze(o)?o:$e(e,t,n.publicProperties[o],r))}function ze(e){return typeof e=="object"&&"key"in e&&"title"in e}const ra=new Set(["topRight","bottomRight"]),aa=e=>{var h,x;const[n,t]=b.useState({}),a=b.useMemo(()=>{const p=[{id:"selection",header:({table:f})=>i.jsx(d.Checkbox,{checked:f.getIsAllRowsSelected(),indeterminate:f.getIsSomeRowsSelected(),onChange:f.getToggleAllRowsSelectedHandler()}),cell:({row:f})=>i.jsx(d.Checkbox,{checked:f.getIsSelected(),disabled:!f.getCanSelect(),onChange:f.getToggleSelectedHandler()})}];return e.columns.forEach(f=>{p.push({id:f.key,header:f.title,accessorFn:f.render,cell:({row:y})=>f.render(y.original)})}),p},[e.columns]),r=Y.useReactTable({data:e.data,columns:a,getCoreRowModel:Y.getCoreRowModel(),getPaginationRowModel:Y.getPaginationRowModel(),state:{rowSelection:n},onRowSelectionChange:t}),o=b.useMemo(()=>Object.keys(n).filter(p=>n[p]).map(Number),[n]);let l,u;Pt(e.actions)&&(l=i.jsx(Rt,{actions:e.actions,selectedRowKeys:o}));const s=((h=e.pagination)==null?void 0:h.positions)||ra;if(s.size>0){const p=r.getState().pagination,f=i.jsx(Lt,{total:r.getPageCount(),pageIndex:p.pageIndex,pageSize:p.pageSize,onUpdatePagination:(y,j)=>r.setPagination({pageIndex:y,pageSize:j}),allowPageSizeChange:(x=e.pagination)==null?void 0:x.showSizeChanger});s.has("topRight")&&(l!==void 0?l=i.jsxs(d.Group,{justify:"space-between",gap:"sm",children:[l,f]}):l=i.jsx(d.Flex,{justify:"flex-end",children:f})),(s.has("bottomRight")||s.has("bottomLeft")||s.has("bottomCenter"))&&(s.has("bottomLeft")?u=i.jsxs(d.Flex,{justify:"space-between",align:"center",children:[f,i.jsxs(d.Text,{size:"sm",c:"dimmed",children:["Showing ",p.pageIndex*p.pageSize+1," to"," ",Math.min((p.pageIndex+1)*p.pageSize,e.data.length)," ","of ",e.data.length," records"]})]}):u=i.jsxs(d.Flex,{justify:"space-between",align:"center",children:[i.jsxs(d.Text,{size:"sm",c:"dimmed",children:["Showing ",p.pageIndex*p.pageSize+1," to"," ",Math.min((p.pageIndex+1)*p.pageSize,e.data.length)," ","of ",e.data.length," records"]}),f]}))}const c=i.jsx(Ft,{selectedRowKeys:n,table:r,bordered:!0,hasTopSection:l!==void 0,hasBottomSection:u!==void 0});return l===void 0&&u===void 0?c:i.jsxs("div",{children:[l!==void 0&&i.jsx(d.Paper,{withBorder:!0,p:"xs",style:{borderBottomLeftRadius:0,borderBottomRightRadius:0,borderBottom:"none"},children:l}),c,u!==void 0&&i.jsx(d.Paper,{withBorder:!0,p:"xs",style:{borderTopLeftRadius:0,borderTopRightRadius:0,borderTop:"none"},children:u})]})},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(d.Text,{size:"sm",fw:550,children:i.jsx(O,{value:t.label})}),i.jsx(a,{db:e.db,entityRoutes:r,property:t,value:o})]})}),oa=U.observer(({store:e,record:n,properties:t,DisplayComponent:a,entityRoutes:r})=>{const o=t[t.length-1],l=t.reduce((u,s)=>{if(u!=null)return u[s.tsName]},n);return i.jsxs("div",{children:[i.jsx(d.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})]})}),ia=12,Dt=e=>{const n=e.schema,t=b.useMemo(()=>e.fieldGroups.map((a,r)=>la(n,e.store,e.record,r,a,e.entityRoutes)),[n,e.store,e.record,e.fieldGroups]);return i.jsx(d.Stack,{gap:"sm",className:e.className,style:e.styles,children:t})};function la(e,n,t,a,r,o){const l=r.fields,u=[];for(let s=0;s<l.length;s++){const c=ia/l[s].length;if(!Number.isInteger(c))throw new Error(`Span must be an integer, but got ${c} for row ${s}`);for(let h=0;h<l[s].length;h++){const x=l[s][h];let p;if(typeof x=="function")p=x(n,t);else if(typeof x=="object"&&"prop"in x){const f=e.allProperties[x.prop],y=x.display;p=i.jsx(At,{store:n,record:t,property:f,DisplayComponent:y,entityRoutes:o})}else{const f=e.allProperties[x];let y;if(G.isObjectProperty(f))y=f.cardinality==="N:N"||f.cardinality==="1:N"?de:ue;else{if(q[f.datatype]===void 0)throw new Error(`No display component found for datatype ${f.datatype}`);y=q[f.datatype]}p=i.jsx(At,{store:n,record:t,property:f,DisplayComponent:y,entityRoutes:o})}u.push(i.jsx(d.Grid.Col,{span:c,children:p},`${s}-${h}`))}}return i.jsx(d.Grid,{gutter:"sm",children:u},a)}function sa(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(oa,{store:o,record:l,properties:e,DisplayComponent:r,entityRoutes:n})}const ua=e=>i.jsxs(d.Tabs,{defaultValue:e.fieldTabs[0].tabName,children:[i.jsx(d.Tabs.List,{children:e.fieldTabs.map((n,t)=>i.jsx(d.Tabs.Tab,{value:n.tabName,children:n.tabName},t))}),e.fieldTabs.map((n,t)=>i.jsx(d.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))]});S.CountryFlagComponent=fe,S.DEFAULT_PAGINATION_POSITIONS=Ot,S.DataType2Component=_e,S.DataType2DisplayComponent=q,S.DateDisplay=bt,S.DateTimeDisplay=yt,S.DateTimeHideTimeDisplay=kr,S.EmojiCountryFlag=Ye,S.FormItem=Tt,S.FormItemLabel=Et,S.LanguageSelector=Xt,S.Loading=pr,S.LoadingInline=xr,S.LocaleContext=Q,S.LocaleProvider=Yt,S.MenuTrie=vt,S.MultiForeignKeyDisplay=de,S.MultiLingualString=O,S.NotAuthorized=vr,S.NotFound=mr,S.NotFoundInline=Le,S.NotFoundSubPage=gr,S.OrderedUniqueList=Sr,S.Permission=we,S.SVGCountryFlag=He,S.SeraEmbeddedTable=aa,S.SeraForm=Ur,S.SeraTable=Zr,S.SeraVerticalMenu=Cr,S.SeraView=Dt,S.SeraViewTab=ua,S.SingleForeignKeyDisplay=ue,S.Trie=Oe,S.TrieNode=Me,S.buildMenuItemIndex=pt,S.countryFlags=R,S.filterAllowedItems=xt,S.groupBy=yr,S.groupByAsList=br,S.isSeraColumn=ze,S.makeEmbeddedTableColumns=na,S.makeFieldDisplay=sa,S.makeTableColumn=$e,S.makeTableColumnFromNestedProperty=ea,S.makeTableColumns=ta,S.uniqueList=wr,Object.defineProperty(S,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.
|
|
4
|
+
"version": "1.2.0",
|
|
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
|
}
|