@alepha/devtools 0.14.1 → 0.14.2
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/assets/devtools/{asset.Bhpm0ujk.css → asset.DbJSgVPr.css} +1 -1
- package/assets/devtools/chunk.3mUAkkKN.js +1 -0
- package/assets/devtools/chunk.AVmV_XG3.js +1 -0
- package/assets/devtools/{chunk.BChtaeaz.js → chunk.B9Nj9arT.js} +1 -1
- package/assets/devtools/chunk.BA8URMP8.js +1 -0
- package/assets/devtools/{chunk.BVciOoK-.js → chunk.BXj_XO3l.js} +1 -1
- package/assets/devtools/{chunk.CioNo4ZJ.js → chunk.BZoA8zmc.js} +1 -1
- package/assets/devtools/{chunk.CaVuq3Op.js → chunk.B_-9nxHc.js} +1 -1
- package/assets/devtools/{chunk.aHk99chr.js → chunk.BkQQhCPw.js} +1 -1
- package/assets/devtools/chunk.Bk_AzNdP.js +7 -0
- package/assets/devtools/{chunk.BRzkf5AB.js → chunk.BlCuAV4r.js} +1 -1
- package/assets/devtools/chunk.BoKPUi4h.js +2 -0
- package/assets/devtools/{chunk.Duwrcaca.js → chunk.C2Epljet.js} +1 -1
- package/assets/devtools/chunk.C2XzHl1-.js +1 -0
- package/assets/devtools/{chunk.DPzX4t8Q.js → chunk.CD3lZA1D.js} +1 -1
- package/assets/devtools/{chunk.BiYuhEvJ.js → chunk.CMPoj2S1.js} +1 -1
- package/assets/devtools/{chunk.uTsm7un3.js → chunk.CMrSghiM.js} +1 -1
- package/assets/devtools/{chunk.BLm9NSIJ.js → chunk.CNyKXw81.js} +2 -2
- package/assets/devtools/chunk.CSlinMdh.js +1 -0
- package/assets/devtools/chunk.CUdeQBl0.js +6 -0
- package/assets/devtools/chunk.CcRPc1V0.js +1 -0
- package/assets/devtools/{chunk.0pKzkQ-k.js → chunk.CqWgHz10.js} +1 -1
- package/assets/devtools/{chunk.BkBlh2Dt.js → chunk.D6vpaxPE.js} +1 -1
- package/assets/devtools/{chunk.B9h7IAR1.js → chunk.DCS6fHH1.js} +1 -1
- package/assets/devtools/chunk.DIbRzrh1.js +1 -0
- package/assets/devtools/chunk.DJdym_tE.js +1 -0
- package/assets/devtools/{chunk.XGXwPH1e.js → chunk.DRx03mgu.js} +1 -1
- package/assets/devtools/{chunk.Djkuv-DD.js → chunk.DUP1E40B.js} +1 -1
- package/assets/devtools/{chunk.Ct5753mG.js → chunk.DhCpNWJE.js} +1 -1
- package/assets/devtools/chunk.DojDQgy5.js +1 -0
- package/assets/devtools/{chunk.e1Pq7Nwk.js → chunk.DqX1betX.js} +1 -1
- package/assets/devtools/chunk.Dwb-lFg8.js +1 -0
- package/assets/devtools/{chunk.bYKDU_ru.js → chunk.OgXBCMJY.js} +1 -1
- package/assets/devtools/chunk.QuY3UyEF.js +1 -0
- package/assets/devtools/chunk.VmKlHUok.js +1 -0
- package/assets/devtools/{chunk.C8MW3asi.js → chunk.VyCl7mMj.js} +1 -1
- package/assets/devtools/chunk.e9ZcH1yi.js +1 -0
- package/assets/devtools/entry.r_sixgJG.js +75 -0
- package/assets/devtools/index.html +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/ui/AppRouter.tsx +1 -1
- package/src/ui/components/DevAtomsViewer.tsx +2 -1
- package/src/ui/components/DevLayout.tsx +4 -34
- package/src/ui/components/DevTopicsViewer.tsx +3 -7
- package/src/ui/main.ts +8 -2
- package/assets/devtools/chunk.B5eTVHku.js +0 -1
- package/assets/devtools/chunk.BmVQcEyT.js +0 -1
- package/assets/devtools/chunk.ByjndBdY.js +0 -6
- package/assets/devtools/chunk.CLYiSTOf.js +0 -1
- package/assets/devtools/chunk.CjoaeVq1.js +0 -7
- package/assets/devtools/chunk.D4sT5zWZ.js +0 -1
- package/assets/devtools/chunk.Ddpv5E_O.js +0 -1
- package/assets/devtools/chunk.DtstekP0.js +0 -1
- package/assets/devtools/chunk.R7-m7OZO.js +0 -1
- package/assets/devtools/chunk.VgeujX8m.js +0 -2
- package/assets/devtools/chunk.VjygskIP.js +0 -1
- package/assets/devtools/chunk.W1p_0xSo.js +0 -1
- package/assets/devtools/chunk.arBxf8N4.js +0 -1
- package/assets/devtools/chunk.cMS5bixD.js +0 -1
- package/assets/devtools/entry.Cjxjbqvs.js +0 -75
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{w as B,j as e,ad as v,Y as D,Z as P,r as j,F as d,T as n,B as a,H as m,Q as C,ae as k,z as I,ac as w}from"./entry.Cjxjbqvs.js";import{d as $}from"./chunk.XGXwPH1e.js";import{B as x,S as g}from"./chunk.uTsm7un3.js";import{T as f}from"./chunk.Ct5753mG.js";import{T as s}from"./chunk.aHk99chr.js";import"./chunk.BlqFPyLh.js";const A=[["path",{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z",key:"svg-0"}],["path",{d:"M3 10h18",key:"svg-1"}],["path",{d:"M10 3v18",key:"svg-2"}]],y=B("outline","table","Table",A),K=({column:i,size:r="xs"})=>{const t=[];return i.primaryKey&&t.push({label:"PK",tooltip:"Primary Key"}),i.identity&&t.push({label:"ID",tooltip:"Auto-increment Identity"}),i.ref&&t.push({label:"FK",tooltip:`Foreign Key → ${i.ref.entity}.${i.ref.column}`}),i.createdAt&&t.push({label:"C",tooltip:"Created At (auto-set on insert)"}),i.updatedAt&&t.push({label:"U",tooltip:"Updated At (auto-set on update)"}),i.deletedAt&&t.push({label:"D",tooltip:"Deleted At (soft delete)"}),i.version&&t.push({label:"V",tooltip:"Version (optimistic locking)"}),e.jsxs(e.Fragment,{children:[t.map(o=>e.jsx(v,{label:o.tooltip,children:e.jsx(x,{size:r,variant:"light",color:"blue",children:o.label})},o.label)),i.nullable&&e.jsx(v,{label:"Nullable",children:e.jsx(x,{size:r,variant:"outline",color:"gray",children:"?"})})]})},z={PostgresProvider:"#336791",SqliteProvider:"#003B57",DatabaseProvider:"#495057",default:"#495057"},S=i=>z[i]??z.default,N=({entities:i,selectedEntity:r,onSelectEntity:t,search:o,onSearchChange:T})=>{const u=j.useMemo(()=>{const l={};for(const c of i){const h=c.provider.replace("Provider","");l[h]||(l[h]=[]),l[h].push(c)}return l},[i]),b=Object.keys(u).sort();return e.jsxs(g,{gap:0,h:"100%",children:[e.jsx(a,{p:"sm",style:{borderBottom:`1px solid ${m.colors.border}`},children:e.jsx(k,{placeholder:"Search tables...",leftSection:e.jsx(I,{size:14}),size:"xs",value:o,onChange:l=>T(l.target.value)})}),e.jsx(w,{style:{flex:1},children:b.map(l=>e.jsxs(a,{children:[e.jsx(n,{size:"xs",fw:600,c:"dimmed",px:"sm",py:"xs",style:{backgroundColor:m.colors.background,borderBottom:`1px solid ${m.colors.border}`,textTransform:"uppercase",letterSpacing:"0.05em"},children:l}),u[l].map(c=>{const h=r?.name===c.name,p=S(c.provider);return e.jsxs(d,{align:"center",gap:"xs",px:"sm",py:6,onClick:()=>t(c),style:{cursor:"pointer",backgroundColor:h?`${p}15`:void 0,borderLeft:h?`2px solid ${p}`:"2px solid transparent",borderBottom:`1px solid ${m.colors.border}`},children:[e.jsx(y,{size:14,opacity:.5}),e.jsx(n,{size:"sm",style:{flex:1},truncate:!0,children:c.name}),e.jsx(n,{size:"xs",c:"dimmed",children:c.columns.length})]},c.name)})]},l))})]})},O=({entity:i})=>e.jsx(w,{h:"100%",p:"md",children:e.jsxs(g,{gap:"lg",children:[e.jsxs(a,{children:[e.jsx(n,{size:"sm",fw:600,mb:"xs",children:"Columns"}),e.jsxs(s,{striped:!0,highlightOnHover:!0,withTableBorder:!0,children:[e.jsx(s.Thead,{children:e.jsxs(s.Tr,{children:[e.jsx(s.Th,{children:"Name"}),e.jsx(s.Th,{children:"Type"}),e.jsx(s.Th,{children:"Attributes"})]})}),e.jsx(s.Tbody,{children:i.columns.map(r=>e.jsxs(s.Tr,{children:[e.jsx(s.Td,{children:e.jsx(n,{size:"sm",ff:"monospace",fw:r.primaryKey?600:400,children:r.name})}),e.jsx(s.Td,{children:e.jsx(n,{size:"sm",ff:"monospace",c:"dimmed",children:r.type})}),e.jsx(s.Td,{children:e.jsx(d,{gap:4,wrap:"wrap",children:e.jsx(K,{column:r})})})]},r.name))})]})]}),i.indexes.length>0&&e.jsxs(a,{children:[e.jsx(n,{size:"sm",fw:600,mb:"xs",children:"Indexes"}),e.jsxs(s,{striped:!0,highlightOnHover:!0,withTableBorder:!0,children:[e.jsx(s.Thead,{children:e.jsxs(s.Tr,{children:[e.jsx(s.Th,{children:"Name"}),e.jsx(s.Th,{children:"Columns"}),e.jsx(s.Th,{children:"Unique"})]})}),e.jsx(s.Tbody,{children:i.indexes.map((r,t)=>e.jsxs(s.Tr,{children:[e.jsx(s.Td,{children:e.jsx(n,{size:"sm",ff:"monospace",children:r.name||"-"})}),e.jsx(s.Td,{children:e.jsx(d,{gap:4,children:r.columns.map(o=>e.jsx(x,{size:"xs",variant:"light",children:o},o))})}),e.jsx(s.Td,{children:r.unique&&e.jsx(x,{size:"xs",color:"yellow",children:"UNIQUE"})})]},r.name||t))})]})]}),i.foreignKeys.length>0&&e.jsxs(a,{children:[e.jsx(n,{size:"sm",fw:600,mb:"xs",children:"Foreign Keys"}),e.jsxs(s,{striped:!0,highlightOnHover:!0,withTableBorder:!0,children:[e.jsx(s.Thead,{children:e.jsxs(s.Tr,{children:[e.jsx(s.Th,{children:"Name"}),e.jsx(s.Th,{children:"Column"}),e.jsx(s.Th,{children:"References"})]})}),e.jsx(s.Tbody,{children:i.foreignKeys.map((r,t)=>e.jsxs(s.Tr,{children:[e.jsx(s.Td,{children:e.jsx(n,{size:"sm",ff:"monospace",children:r.name||"-"})}),e.jsx(s.Td,{children:e.jsx(n,{size:"sm",ff:"monospace",children:r.columns.join(", ")})}),e.jsx(s.Td,{children:e.jsxs(n,{size:"sm",ff:"monospace",c:"pink",children:[r.foreignEntity,".",r.foreignColumns.join(", ")]})})]},r.name||t))})]})]}),i.columns.some(r=>r.ref)&&e.jsxs(a,{children:[e.jsx(n,{size:"sm",fw:600,mb:"xs",children:"Column References"}),e.jsxs(s,{striped:!0,highlightOnHover:!0,withTableBorder:!0,children:[e.jsx(s.Thead,{children:e.jsxs(s.Tr,{children:[e.jsx(s.Th,{children:"Column"}),e.jsx(s.Th,{children:"References"})]})}),e.jsx(s.Tbody,{children:i.columns.filter(r=>r.ref).map(r=>e.jsxs(s.Tr,{children:[e.jsx(s.Td,{children:e.jsx(n,{size:"sm",ff:"monospace",children:r.name})}),e.jsx(s.Td,{children:e.jsxs(n,{size:"sm",ff:"monospace",c:"pink",children:[r.ref?.entity,".",r.ref?.column]})})]},r.name))})]})]}),i.constraints.length>0&&e.jsxs(a,{children:[e.jsx(n,{size:"sm",fw:600,mb:"xs",children:"Constraints"}),e.jsxs(s,{striped:!0,highlightOnHover:!0,withTableBorder:!0,children:[e.jsx(s.Thead,{children:e.jsxs(s.Tr,{children:[e.jsx(s.Th,{children:"Name"}),e.jsx(s.Th,{children:"Columns"}),e.jsx(s.Th,{children:"Type"})]})}),e.jsx(s.Tbody,{children:i.constraints.map((r,t)=>e.jsxs(s.Tr,{children:[e.jsx(s.Td,{children:e.jsx(n,{size:"sm",ff:"monospace",children:r.name||"-"})}),e.jsx(s.Td,{children:e.jsx(d,{gap:4,children:r.columns.map(o=>e.jsx(x,{size:"xs",variant:"outline",children:o},o))})}),e.jsx(s.Td,{children:e.jsxs(d,{gap:4,children:[r.unique&&e.jsx(x,{size:"xs",color:"yellow",children:"UNIQUE"}),r.hasCheck&&e.jsx(x,{size:"xs",color:"blue",children:"CHECK"})]})})]},r.name||t))})]})]})]})}),R=()=>e.jsx(d,{align:"center",justify:"center",h:"100%",c:"dimmed",children:e.jsxs(g,{align:"center",gap:"xs",children:[e.jsx(C,{size:48,opacity:.3}),e.jsx(n,{size:"sm",children:"Data browser coming soon"})]})}),H=({entity:i})=>{const r=S(i.provider);return e.jsxs(d,{direction:"column",h:"100%",children:[e.jsx(a,{px:"md",py:"sm",style:{borderBottom:`1px solid ${m.colors.border}`,backgroundColor:`${r}08`},children:e.jsxs(d,{align:"center",gap:"sm",children:[e.jsx(y,{size:18,opacity:.7}),e.jsx(n,{size:"md",fw:600,children:i.name}),e.jsxs(x,{size:"xs",variant:"light",color:"gray",children:[i.columns.length," columns"]})]})}),e.jsxs(f,{defaultValue:"structure",style:{flex:1,display:"flex",flexDirection:"column"},children:[e.jsxs(f.List,{px:"md",children:[e.jsx(f.Tab,{value:"structure",children:"Structure"}),e.jsx(f.Tab,{value:"data",children:"Data"})]}),e.jsx(f.Panel,{value:"structure",style:{flex:1,overflow:"hidden"},children:e.jsx(O,{entity:i})}),e.jsx(f.Panel,{value:"data",style:{flex:1,overflow:"hidden"},children:e.jsx(R,{})})]})]})},L=()=>e.jsx(d,{align:"center",justify:"center",h:"100%",c:"dimmed",children:e.jsxs(g,{align:"center",gap:"xs",children:[e.jsx(y,{size:48,opacity:.3}),e.jsx(n,{size:"sm",children:"Select a table to view its structure"})]})}),U=()=>e.jsx(d,{align:"center",justify:"center",h:"100%",c:"dimmed",children:e.jsxs(g,{align:"center",gap:"xs",children:[e.jsx(C,{size:48,opacity:.3}),e.jsx(n,{children:"No entities found"}),e.jsx(n,{size:"sm",c:"dimmed",children:"Add entities using $entity primitive to see them here"})]})}),Y=()=>{const i=D(P),[r,t]=j.useState([]),[o,T]=j.useState(!0),[u,b]=j.useState(null),[l,c]=j.useState("");j.useEffect(()=>{i.fetch("/devtools/api/metadata",{schema:{response:$}}).then(p=>{t(p.data.entities),T(!1)})},[]);const h=j.useMemo(()=>{if(!l)return r;const p=l.toLowerCase();return r.filter(E=>E.name.toLowerCase().includes(p))},[r,l]);return o?e.jsx(d,{align:"center",justify:"center",h:"100%",children:e.jsx(n,{c:"dimmed",children:"Loading..."})}):r.length===0?e.jsx(U,{}):e.jsxs(d,{h:"100%",style:{overflow:"hidden"},children:[e.jsx(a,{w:240,style:{borderRight:`1px solid ${m.colors.border}`,backgroundColor:m.colors.surface},children:e.jsx(N,{entities:h,selectedEntity:u,onSelectEntity:b,search:l,onSearchChange:c})}),e.jsx(a,{style:{flex:1,overflow:"hidden"},children:u?e.jsx(H,{entity:u}):e.jsx(L,{})})]})};export{Y as DevDbStudio,Y as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{at as oe,Y as re,a$ as De,r as f,A as z,b4 as je,aK as ke,x as Ie,b5 as Te,p as H,b as M,j as s,T as Ae,d as Pe,c as Ee,f as B,B as se,ay as K,aw as Ne,i as q,ah as ie,b6 as ae,U as ce,b7 as Re,$ as Le,b8 as Fe,q as Oe,a0 as _e,av as Be,a2 as Ke,aZ as $e,H as Ve,F as te,ad as ze,a5 as R,G as He,aa as qe}from"./entry.Cjxjbqvs.js";import{T as le}from"./chunk.Djkuv-DD.js";import{f as Ue,c as ue}from"./chunk.BlqFPyLh.js";import{P as L}from"./chunk.DtstekP0.js";import{A as Ge}from"./chunk.Duwrcaca.js";function de(t,o){const n=oe(),r=re(De),[a,i]=f.useState(!1),[e,c]=f.useState(),l=f.useRef(!1),u=f.useRef(void 0),d=f.useRef(void 0),y=f.useRef(!0),m=f.useRef(void 0);f.useEffect(()=>()=>{y.current=!1,u.current&&(r.clearTimeout(u.current),u.current=void 0),m.current&&(r.clearInterval(m.current),m.current=void 0),d.current&&(d.current.abort(),d.current=void 0)},[]);const v=f.useCallback(async(...g)=>{if(l.current)return;d.current&&d.current.abort();const b=new AbortController;d.current=b,l.current=!0,i(!0),c(void 0),await n.events.emit("react:action:begin",{type:"custom",id:t.id});try{const x=await t.handler(...g,{signal:b.signal});return!y.current||b.signal.aborted?void 0:(await n.events.emit("react:action:success",{type:"custom",id:t.id}),t.onSuccess&&await t.onSuccess(x),x)}catch(x){if(x instanceof Error&&x.name==="AbortError"||!y.current)return;const p=x;if(c(p),await n.events.emit("react:action:error",{type:"custom",id:t.id,error:p}),t.onError)await t.onError(p);else throw p}finally{l.current=!1,i(!1),await n.events.emit("react:action:end",{type:"custom",id:t.id}),d.current===b&&(d.current=void 0)}},[...o,t.id,t.onError,t.onSuccess]),w=f.useCallback(async(...g)=>t.debounce?(u.current&&r.clearTimeout(u.current),new Promise(b=>{u.current=r.createTimeout(async()=>{const x=await v(...g);b(x)},t.debounce??0)})):v(...g),[v,t.debounce]),h=f.useCallback(()=>{u.current&&(r.clearTimeout(u.current),u.current=void 0),d.current&&(d.current.abort(),d.current=void 0),y.current&&(l.current=!1,i(!1))},[]);return f.useEffect(()=>{t.runOnInit&&w()},o),f.useEffect(()=>{if(t.runEvery)return m.current=r.createInterval(()=>w(),t.runEvery,!0),()=>{m.current&&(r.clearInterval(m.current),m.current=void 0)}},[w,t.runEvery]),{run:w,loading:a,error:e,cancel:h}}const We=t=>{const o=z(),[n,r]=f.useState(!1);je().url.pathname;const i=typeof t=="string"?{href:t}:{...t,href:t.href},e=i.href,c=o.isActive(e,i);return{isPending:n,isActive:c,anchorProps:{href:o.base(e),onClick:async l=>{if(l?.stopPropagation(),l?.preventDefault(),!c&&!n){r(!0);try{await o.go(e)}finally{r(!1)}}}}}},me=(t,o=["loading","dirty","error"])=>{const n=oe(),r=o,[a,i]=f.useState(!1),[e,c]=f.useState(!1),[l,u]=f.useState(void 0),[d,y]=f.useState(void 0),m="form"in t?t.form:t,v="path"in t?t.path:void 0,w=r.includes("values"),h=r.includes("error"),g=r.includes("dirty"),b=r.includes("loading");return f.useEffect(()=>{const x=[];return(h||w||g)&&x.push(n.events.on("form:change",p=>{p.id===m.id&&((!v||p.path===v)&&(g&&i(!0),h&&u(void 0)),w&&y(m.currentValues))})),w&&x.push(n.events.on("form:reset",p=>{p.id===m.id&&y(p.values)})),b&&x.push(n.events.on("form:submit:begin",p=>{p.id===m.id&&c(!0)}),n.events.on("form:submit:end",p=>{p.id===m.id&&c(!1)})),(w||g)&&x.push(n.events.on("form:submit:success",p=>{p.id===m.id&&(w&&y(p.values),g&&i(!1))})),h&&x.push(n.events.on("form:submit:error",p=>{p.id===m.id&&(!v||p.error instanceof ke&&p.error.value.path===v)&&u(p.error)})),()=>{for(const p of x)p()}},[]),{dirty:a,loading:e,error:l,values:d}},ht=()=>(Ie("alepha.react.i18n.lang"),re(Te));function C(t,o){return n=>{t?.(n),o?.(n)}}function Ye(t,o,n){return n?Array.from(Ue(n,o)?.querySelectorAll(t)||[]).findIndex(r=>r===n):null}function Ze(t=!1,o={}){const[n,r]=f.useState(t),a=f.useCallback(()=>{r(c=>c||(o.onOpen?.(),!0))},[o.onOpen]),i=f.useCallback(()=>{r(c=>c&&(o.onClose?.(),!1))},[o.onClose]),e=f.useCallback(()=>{n?i():a()},[i,a,n]);return[n,{open:a,close:i,toggle:e}]}function fe({open:t,close:o,openDelay:n,closeDelay:r}){const a=f.useRef(-1),i=f.useRef(-1),e=()=>{window.clearTimeout(a.current),window.clearTimeout(i.current)},c=()=>{e(),n===0||n===void 0?t():a.current=window.setTimeout(t,n)},l=()=>{e(),r===0||r===void 0?o():i.current=window.setTimeout(o,r)};return f.useEffect(()=>e,[]),{openDropdown:c,closeDropdown:l}}var he={root:"m_849cf0da"};const Je={underline:"hover"},U=H((t,o)=>{const{underline:n,className:r,unstyled:a,mod:i,...e}=M("Anchor",Je,t);return s.jsx(Ae,{component:"a",ref:o,className:Pe({[he.root]:!a},r),...e,mod:[{underline:n},i],__staticSelector:"Anchor",unstyled:a})});U.classes=he;U.displayName="@mantine/core/Anchor";const[Qe,k]=Ee("Menu component was not found in the tree");var I={dropdown:"m_dc9b7c9f",label:"m_9bfac126",divider:"m_efdf90cb",item:"m_99ac2aa1",itemLabel:"m_5476e0d3",itemSection:"m_8b75e504",chevron:"m_b85b0bed"};const G=B((t,o)=>{const{classNames:n,className:r,style:a,styles:i,vars:e,...c}=M("MenuDivider",null,t),l=k();return s.jsx(se,{ref:o,...l.getStyles("divider",{className:r,style:a,styles:i,classNames:n}),...c})});G.classes=I;G.displayName="@mantine/core/MenuDivider";const W=B((t,o)=>{const{classNames:n,className:r,style:a,styles:i,vars:e,onMouseEnter:c,onMouseLeave:l,onKeyDown:u,children:d,...y}=M("MenuDropdown",null,t),m=f.useRef(null),v=k(),w=C(u,b=>{(b.key==="ArrowUp"||b.key==="ArrowDown")&&(b.preventDefault(),m.current?.querySelectorAll("[data-menu-item]:not(:disabled)")[0]?.focus())}),h=C(c,()=>(v.trigger==="hover"||v.trigger==="click-hover")&&v.openDropdown()),g=C(l,()=>(v.trigger==="hover"||v.trigger==="click-hover")&&v.closeDropdown());return s.jsxs(L.Dropdown,{...y,onMouseEnter:h,onMouseLeave:g,role:"menu","aria-orientation":"vertical",ref:K(o,m),...v.getStyles("dropdown",{className:r,style:a,styles:i,classNames:n,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:w,children:[v.withInitialFocusPlaceholder&&s.jsx("div",{tabIndex:-1,"data-autofocus":!0,"data-mantine-stop-propagation":!0,style:{outline:0}}),d]})});W.classes=I;W.displayName="@mantine/core/MenuDropdown";const[Xe,$]=Ne(),Y=H((t,o)=>{const{classNames:n,className:r,style:a,styles:i,vars:e,color:c,closeMenuOnClick:l,leftSection:u,rightSection:d,children:y,disabled:m,"data-disabled":v,...w}=M("MenuItem",null,t),h=k(),g=$(),b=q(),{dir:x}=ie(),p=f.useRef(null),D=w,T=C(D.onClick,()=>{v||(typeof l=="boolean"?l&&h.closeDropdownImmediately():h.closeOnItemClick&&h.closeDropdownImmediately())}),j=c?b.variantColorResolver({color:c,theme:b,variant:"light"}):void 0,A=c?ae({color:c,theme:b}):null,O=C(D.onKeyDown,P=>{P.key==="ArrowLeft"&&g&&(g.close(),g.focusParentItem())});return s.jsxs(ce,{onMouseDown:P=>P.preventDefault(),...w,unstyled:h.unstyled,tabIndex:h.menuItemTabIndex,...h.getStyles("item",{className:r,style:a,styles:i,classNames:n}),ref:K(p,o),role:"menuitem",disabled:m,"data-menu-item":!0,"data-disabled":m||v||void 0,"data-mantine-stop-propagation":!0,onClick:T,onKeyDown:ue({siblingSelector:"[data-menu-item]:not([data-disabled])",parentSelector:"[data-menu-dropdown]",activateOnFocus:!1,loop:h.loop,dir:x,orientation:"vertical",onKeyDown:O}),__vars:{"--menu-item-color":A?.isThemeColor&&A?.shade===void 0?`var(--mantine-color-${A.color}-6)`:j?.color,"--menu-item-hover":j?.hover},children:[u&&s.jsx("div",{...h.getStyles("itemSection",{styles:i,classNames:n}),"data-position":"left",children:u}),y&&s.jsx("div",{...h.getStyles("itemLabel",{styles:i,classNames:n}),children:y}),d&&s.jsx("div",{...h.getStyles("itemSection",{styles:i,classNames:n}),"data-position":"right",children:d})]})});Y.classes=I;Y.displayName="@mantine/core/MenuItem";const Z=B((t,o)=>{const{classNames:n,className:r,style:a,styles:i,vars:e,...c}=M("MenuLabel",null,t),l=k();return s.jsx(se,{ref:o,...l.getStyles("label",{className:r,style:a,styles:i,classNames:n}),...c})});Z.classes=I;Z.displayName="@mantine/core/MenuLabel";const J=B((t,o)=>{const{classNames:n,className:r,style:a,styles:i,vars:e,onMouseEnter:c,onMouseLeave:l,onKeyDown:u,children:d,...y}=M("MenuSubDropdown",null,t),m=f.useRef(null),v=k(),w=$(),h=C(c,w?.open),g=C(l,w?.close);return s.jsx(L.Dropdown,{...y,onMouseEnter:h,onMouseLeave:g,role:"menu","aria-orientation":"vertical",ref:K(o,m),...v.getStyles("dropdown",{className:r,style:a,styles:i,classNames:n,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,children:d})});J.classes=I;J.displayName="@mantine/core/MenuSubDropdown";const Q=H((t,o)=>{const{classNames:n,className:r,style:a,styles:i,vars:e,color:c,leftSection:l,rightSection:u,children:d,disabled:y,"data-disabled":m,closeMenuOnClick:v,...w}=M("MenuSubItem",null,t),h=k(),g=$(),b=q(),{dir:x}=ie(),p=f.useRef(null),D=w,T=c?b.variantColorResolver({color:c,theme:b,variant:"light"}):void 0,j=c?ae({color:c,theme:b}):null,A=C(D.onKeyDown,N=>{N.key==="ArrowRight"&&(g?.open(),g?.focusFirstItem()),N.key==="ArrowLeft"&&g?.parentContext&&(g.parentContext.close(),g.parentContext.focusParentItem())}),O=C(D.onClick,()=>{!m&&v&&h.closeDropdownImmediately()}),P=C(D.onMouseEnter,g?.open),E=C(D.onMouseLeave,g?.close);return s.jsxs(ce,{onMouseDown:N=>N.preventDefault(),...w,unstyled:h.unstyled,tabIndex:h.menuItemTabIndex,...h.getStyles("item",{className:r,style:a,styles:i,classNames:n}),ref:K(p,o),role:"menuitem",disabled:y,"data-menu-item":!0,"data-sub-menu-item":!0,"data-disabled":y||m||void 0,"data-mantine-stop-propagation":!0,onMouseEnter:P,onMouseLeave:E,onClick:O,onKeyDown:ue({siblingSelector:"[data-menu-item]:not([data-disabled])",parentSelector:"[data-menu-dropdown]",activateOnFocus:!1,loop:h.loop,dir:x,orientation:"vertical",onKeyDown:A}),__vars:{"--menu-item-color":j?.isThemeColor&&j?.shade===void 0?`var(--mantine-color-${j.color}-6)`:T?.color,"--menu-item-hover":T?.hover},children:[l&&s.jsx("div",{...h.getStyles("itemSection",{styles:i,classNames:n}),"data-position":"left",children:l}),d&&s.jsx("div",{...h.getStyles("itemLabel",{styles:i,classNames:n}),children:d}),s.jsx("div",{...h.getStyles("itemSection",{styles:i,classNames:n}),"data-position":"right",children:u||s.jsx(Ge,{...h.getStyles("chevron"),size:14})})]})});Q.classes=I;Q.displayName="@mantine/core/MenuSubItem";function pe({children:t,refProp:o}){if(!Re(t))throw new Error("Menu.Sub.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");return k(),s.jsx(L.Target,{refProp:o,popupType:"menu",children:t})}pe.displayName="@mantine/core/MenuSubTarget";const et={offset:0,position:"right-start",transitionProps:{duration:0},openDelay:0,middlewares:{shift:{crossAxis:!0}}};function F(t){const{children:o,closeDelay:n,openDelay:r,...a}=M("MenuSub",et,t),i=Le(),[e,{open:c,close:l}]=Ze(!1),u=$(),{openDropdown:d,closeDropdown:y}=fe({open:c,close:l,closeDelay:n,openDelay:r}),m=()=>window.setTimeout(()=>{document.getElementById(`${i}-dropdown`)?.querySelectorAll("[data-menu-item]:not([data-disabled])")[0]?.focus()},16),v=()=>window.setTimeout(()=>{document.getElementById(`${i}-target`)?.focus()},16);return s.jsx(Xe,{value:{opened:e,close:y,open:d,focusFirstItem:m,focusParentItem:v,parentContext:u},children:s.jsx(L,{opened:e,withinPortal:!1,withArrow:!1,id:i,...a,children:o})})}F.extend=t=>t;F.displayName="@mantine/core/MenuSub";F.Target=pe;F.Dropdown=J;F.Item=Q;const tt={refProp:"ref"},ve=f.forwardRef((t,o)=>{const{children:n,refProp:r,...a}=M("MenuTarget",tt,t),i=Fe(n);if(!i)throw new Error("Menu.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const e=k(),c=i.props,l=C(c.onClick,()=>{e.trigger==="click"?e.toggleDropdown():e.trigger==="click-hover"&&(e.setOpenedViaClick(!0),e.opened||e.openDropdown())}),u=C(c.onMouseEnter,()=>(e.trigger==="hover"||e.trigger==="click-hover")&&e.openDropdown()),d=C(c.onMouseLeave,()=>{(e.trigger==="hover"||e.trigger==="click-hover"&&!e.openedViaClick)&&e.closeDropdown()});return s.jsx(L.Target,{refProp:r,popupType:"menu",ref:o,...a,children:f.cloneElement(i,{onClick:l,onMouseEnter:u,onMouseLeave:d,"data-expanded":e.opened?!0:void 0})})});ve.displayName="@mantine/core/MenuTarget";const nt={trapFocus:!0,closeOnItemClick:!0,withInitialFocusPlaceholder:!0,clickOutsideEvents:["mousedown","touchstart","keydown"],loop:!0,trigger:"click",openDelay:0,closeDelay:100,menuItemTabIndex:-1};function S(t){const o=M("Menu",nt,t),{children:n,onOpen:r,onClose:a,opened:i,defaultOpened:e,trapFocus:c,onChange:l,closeOnItemClick:u,loop:d,closeOnEscape:y,trigger:m,openDelay:v,closeDelay:w,classNames:h,styles:g,unstyled:b,variant:x,vars:p,menuItemTabIndex:D,keepMounted:T,withInitialFocusPlaceholder:j,attributes:A,...O}=o,P=Oe({name:"Menu",classes:I,props:o,classNames:h,styles:g,unstyled:b,attributes:A}),[E,N]=_e({value:i,defaultValue:e,finalValue:!1,onChange:l}),[ye,X]=f.useState(!1),_=()=>{N(!1),X(!1),E&&a?.()},V=()=>{N(!0),!E&&r?.()},ee=()=>{E?_():V()},{openDropdown:be,closeDropdown:we}=fe({open:V,close:_,closeDelay:w,openDelay:v}),xe=Me=>Ye("[data-menu-item]","[data-menu-dropdown]",Me),{resolvedClassNames:Se,resolvedStyles:Ce}=Be({classNames:h,styles:g,props:o});return s.jsx(Qe,{value:{getStyles:P,opened:E,toggleDropdown:ee,getItemIndex:xe,openedViaClick:ye,setOpenedViaClick:X,closeOnItemClick:u,closeDropdown:m==="click"?_:we,openDropdown:m==="click"?V:be,closeDropdownImmediately:_,loop:d,trigger:m,unstyled:b,menuItemTabIndex:D,withInitialFocusPlaceholder:j},children:s.jsx(L,{returnFocus:!0,...O,opened:E,onChange:ee,defaultOpened:e,trapFocus:T?!1:c,closeOnEscape:y,__staticSelector:"Menu",classNames:Se,styles:Ce,unstyled:b,variant:x,keepMounted:T,children:n})})}S.extend=t=>t;S.withProps=Ke(S);S.classes=I;S.displayName="@mantine/core/Menu";S.Item=Y;S.Label=Z;S.Dropdown=W;S.Target=ve;S.Divider=G;S.Sub=F;const ge=t=>{const{item:o,index:n}=t,r=z(),a=de({handler:async e=>{await o.onClick?.()}},[o.onClick]);if(o.type==="divider")return s.jsx(S.Divider,{},n);if(o.type==="label")return s.jsx(S.Label,{children:o.label},n);if(o.children&&o.children.length>0)return s.jsxs(S,{trigger:"hover",position:"right-start",offset:2,children:[s.jsx(S.Target,{children:s.jsx(S.Item,{leftSection:o.icon,rightSection:s.jsx(He,{size:14}),children:o.label})}),s.jsx(S.Dropdown,{children:o.children.map((e,c)=>s.jsx(ge,{item:e,index:c},c))})]},n);const i={};return t.item.onClick?i.onClick=a.run:t.item.href&&Object.assign(i,r.anchor(t.item.href)),s.jsx(S.Item,{leftSection:o.icon,onClick:o.onClick,color:o.color,rightSection:o.active?s.jsx(le,{size:"xs",variant:"transparent",children:s.jsx(qe,{})}):void 0,...i,children:o.label},n)},ne=t=>{const o=q(),n={...t},{tooltip:r,menu:a,icon:i,...e}=n;if(n.variant==="subtle"&&(e.c??="var(--mantine-color-text)",e.color??="gray"),n.intent&&(n.intent==="none"?(e.c??="var(--mantine-color-text)",e.color??="gray"):n.intent==="primary"?(e.c??="white",e.color??=o.primaryColor):n.intent==="success"?(e.c??="white",e.color??="green"):n.intent==="danger"?(e.c??="white",e.color??="red"):n.intent==="warning"?(e.c??="var(--mantine-color-text)",e.color??="yellow"):n.intent==="info"&&(e.c??="white",e.color??="blue")),n.icon){const u=$e(n.icon)?s.jsx(n.icon,{size:Ve.sizes.icon.md}):s.jsx(le,{w:24,variant:"transparent",size:"sm",c:"var(--mantine-color-text)",...n.themeIconProps,children:n.icon});n.children?e.leftSection=u:(e.children=f.Children.only(u),e.px??="xs")}if(n.leftSection&&!n.children&&(e.px??="xs"),n.textVisibleFrom){const{children:u,textVisibleFrom:d,leftSection:y,...m}=e;return s.jsxs(s.Fragment,{children:[s.jsx(te,{w:"100%",visibleFrom:d,children:s.jsx(ne,{flex:1,...m,leftSection:y,tooltip:r,menu:a,children:u})}),s.jsx(te,{w:"100%",hiddenFrom:d,children:s.jsx(ne,{px:"xs",...m,tooltip:r,menu:a,children:y})})]})}let l="href"in e&&e.href?e.href.startsWith("http")||e.target?s.jsx(ct,{...e,href:e.href,children:e.children}):s.jsx(at,{...e,href:e.href,children:e.children}):(delete e.classNameActive,delete e.variantActive,"action"in e&&e.action?s.jsx(st,{...e,action:e.action,children:e.children}):"onClick"in e&&e.onClick?s.jsx(it,{...e,onClick:e.onClick,children:e.children}):"form"in e&&e.form?e.type==="reset"?s.jsx(rt,{...e,form:e.form,children:e.children}):s.jsx(ot,{...e,form:e.form,children:e.children}):s.jsx(R,{...e,children:e.children}));if(a&&(l=s.jsxs(S,{position:a.position||"bottom-start",width:a.width||200,shadow:a.shadow||"md",trigger:a.on==="hover"?"hover":"click",...a.menuProps,children:[s.jsx(S.Target,{...a.targetProps,children:l}),s.jsx(S.Dropdown,{children:a.items.map((u,d)=>s.jsx(ge,{item:u,index:d},d))})]})),r){const u={openDelay:1e3},d=typeof r=="string"||typeof r=="number"?{...u,label:r,children:l}:{...u,...r,children:l};return s.jsx(ze,{...d})}return l},ot=t=>{const{form:o,...n}=t,r=me(o);return s.jsx(R,{...n,loading:r.loading,disabled:r.loading,type:"submit",children:t.children})},rt=t=>{const{form:o,...n}=t,r=me(o);return s.jsx(R,{...n,disabled:r.loading,type:"reset",children:t.children})},st=t=>{const{action:o,...n}=t;return s.jsx(R,{...n,disabled:o.loading||t.disabled,loading:o.loading,onClick:()=>o.run(),children:t.children})},it=t=>{const o=de({handler:async n=>{await t.onClick(n)}},[t.onClick]);return s.jsx(R,{...t,disabled:o.loading||t.disabled,loading:o.loading,onClick:o.run,children:t.children})},at=t=>{const{active:o,classNameActive:n,variantActive:r,routerGoOptions:a,...i}=t,e=z(),{isPending:c,isActive:l}=We(o?{href:t.href,...o}:{href:t.href}),u=e.anchor(t.href,a),d=i.className||"";return l&&o!==!1&&n&&(i.className=`${d} ${n}`.trim()),t.anchorProps?s.jsx(U,{component:"a",...u,...t.anchorProps,children:t.children}):s.jsx(R,{component:"a",loading:c,...i,...u,variant:l&&o!==!1?r??"filled":i.variant??"subtle",children:t.children})},ct=t=>{const{active:o,classNameActive:n,variantActive:r,routerGoOptions:a,target:i,...e}=t;return s.jsx(R,{component:"a",target:i,...e,children:t.children})};export{ne as A,Ze as a,me as b,C as c,ht as u};
|