tinybase 4.1.0 → 4.1.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/lib/cjs/ui-react-dom-debug.cjs +1 -1
- package/lib/cjs/ui-react-dom-debug.cjs.gz +0 -0
- package/lib/cjs/ui-react-dom.cjs +1 -1
- package/lib/cjs/ui-react-dom.cjs.gz +0 -0
- package/lib/cjs/ui-react.cjs +1 -1
- package/lib/cjs/ui-react.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react-dom-debug.cjs +1 -1
- package/lib/cjs-es6/ui-react-dom-debug.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react-dom.cjs +1 -1
- package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react.cjs +1 -1
- package/lib/cjs-es6/ui-react.cjs.gz +0 -0
- package/lib/debug/ui-react-dom.js +94 -42
- package/lib/debug/ui-react.js +4 -3
- package/lib/es6/ui-react-dom-debug.js +1 -1
- package/lib/es6/ui-react-dom-debug.js.gz +0 -0
- package/lib/es6/ui-react-dom.js +1 -1
- package/lib/es6/ui-react-dom.js.gz +0 -0
- package/lib/es6/ui-react.js +1 -1
- package/lib/es6/ui-react.js.gz +0 -0
- package/lib/ui-react-dom.js +1 -1
- package/lib/ui-react-dom.js.gz +0 -0
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/ui-react-dom-debug.js +1 -1
- package/lib/umd/ui-react-dom-debug.js.gz +0 -0
- package/lib/umd/ui-react-dom.js +1 -1
- package/lib/umd/ui-react-dom.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/lib/umd-es6/ui-react-dom-debug.js +1 -1
- package/lib/umd-es6/ui-react-dom-debug.js.gz +0 -0
- package/lib/umd-es6/ui-react-dom.js +1 -1
- package/lib/umd-es6/ui-react-dom.js.gz +0 -0
- package/lib/umd-es6/ui-react.js +1 -1
- package/lib/umd-es6/ui-react.js.gz +0 -0
- package/package.json +18 -18
- package/readme.md +2 -2
package/lib/ui-react-dom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";import{useRowIds as t,useTableCellIds as l,useRowCount as a,useSortedRowIds as n,useValueIds as o,ValueView as r,useIndexesOrIndexesById as i,useSliceRowIds as s,useRelationshipsOrRelationshipsById as d,useResultRowIds as m,useResultTableCellIds as u,useResultRowCount as h,useResultSortedRowIds as c,useCell as g,useSetCellCallback as
|
|
1
|
+
import e from"react";import{useRowIds as t,useTableCellIds as l,useRowCount as a,useSortedRowIds as n,useValueIds as o,ValueView as r,useIndexesOrIndexesById as i,useSliceRowIds as s,useRelationshipsOrRelationshipsById as d,useResultRowIds as m,useResultTableCellIds as u,useResultRowCount as h,useResultSortedRowIds as c,useCell as g,useSetCellCallback as p,useStoreOrStoreById as b,useValue as f,useSetValueCallback as w,useRemoteRowId as k,CellView as v,ResultCellView as y}from"./ui-react";const C=e=>typeof e,x=C(""),I=C(!0),N=C(0),z="Value",$="currentTarget",M="value",S=isFinite,T=e=>null==e,{PureComponent:R,Fragment:q,createElement:F,useCallback:P,useLayoutEffect:E,useRef:O,useState:V}=e,j=(e,...t)=>T(e)?{}:e(...t),A=(e,t)=>e.map(t),B=Object,L=(e=[])=>B.fromEntries(e),D=(e,t)=>A(B.entries(e),(([e,l])=>t(l,e))),G="tinybaseStoreInspector",H="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",J='content:url("',K=J+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Q='</svg>")',U=J+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",W=A([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>K+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+Q)),X=K+"<path d='M20 20l60 60M20 80l60-60' />"+Q,Y=K+`<path d='${H}' />`+Q,Z=K+`<path d='${H}M20 20l60 60' />`+Q,_="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(D({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[_]:"width:0.5rem;height:0.5rem;",[_+"-track"]:"background:#111",[_+"-thumb"]:"background:#999;border:1px solid #111",[_+"-thumb:hover"]:"background:#fff",[_+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+U,...L(A(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...L(A(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":U,"header>img:nth-of-type(6)":X,...L(A(W,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Y,"details[open]>summary img.done":Z,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${G} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${G} ${t}{${e}}`:"")));const ee=(e,t,l,a)=>e==x?t:e==N?l:a,{useCallback:te,useMemo:le,useState:ae}=e,ne="editable",oe=(e,t)=>A(l(e,t),(t=>e+"."+t)),re=(e,t,l)=>{const a=te(e,t);return l?a:void 0},ie=(...e)=>le((()=>e),e),se=(e,t)=>le((()=>({store:e,tableId:t})),[e,t]),de=(e,t)=>le((()=>({queries:e,queryId:t})),[e,t]),me=(e,t=!1,l,a=0,n,o,r,i)=>{const[[s,d,m],u]=ae([e,t,a]),h=te((e=>{u(e),i?.(e)}),[i]),c=re((e=>h([e,e==s&&!d,m])),[h,s,d,m],l),g=te((e=>h([s,d,e])),[h,s,d]),p=!0===r?Ne:r;return[[s,d,m],c,le((()=>!1===r?null:F(p,{offset:m,limit:n,total:o,onChange:g})),[r,p,m,n,o,g])]},ue=(e,t,l)=>le((()=>{const a=t??e;return L(D(Array.isArray(a)?L(A(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:l,...(a=e,C(a)==x?{label:e}:e)}];var a})))}),[t,l,e]),he=({className:e,headerRow:t,idColumn:l,params:[a,n,o,r,i,s]})=>F("table",{className:e},s?F("caption",null,s):null,!1===t?null:F("thead",null,F("tr",null,!1===l?null:F(ce,{sort:r??[],label:"Id",onClick:i}),D(a,(({label:e},t)=>F(ce,{key:t,cellId:t,label:e,sort:r??[],onClick:i}))))),F("tbody",null,A(o,(e=>F("tr",{key:e},!1===l?null:F("th",null,e),D(a,(({component:t,getComponentProps:l},a)=>F("td",{key:a},F(t,{...j(l,e,a),...n,rowId:e,cellId:a}))))))))),ce=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>F("th",{onClick:re((()=>n?.(e)),[n,e],n),className:T(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},T(l)||t!=e?null:(l?"↓":"↑")+" ",a),ge=({localRowId:t,params:[l,a,n,o,r,i,s]})=>{const d=k(r,t,i);return F("tr",null,!1===l?null:F(e.Fragment,null,F("th",null,t),F("th",null,d)),D(a,(({component:e,getComponentProps:l},a)=>{const[r,i]=a.split(".",2),m=r===n?t:r===o?d:null;return T(m)?null:F("td",{key:a},F(e,{...j(l,m,i),store:s,tableId:r,rowId:m,cellId:i}))})))},pe=({thing:e,onThingChange:t,className:l,hasSchema:a})=>{const[n,o]=ae(),[r,i]=ae(),[s,d]=ae(),[m,u]=ae(),[h,c]=ae();r!==e&&(o((e=>{const t=C(e);return(e=>e==x||e==I)(t)||t==N&&S(e)?t:void 0})(e)),i(e),d(e+""),u(Number(e)||0),c(!!e));const g=te(((e,l)=>{l(e),i(e),t(e)}),[t]);return F("div",{className:l},F("button",{className:n,onClick:te((()=>{if(!a?.()){const e=ee(n,N,I,x),l=ee(e,s,m,h);o(e),i(l),t(l)}}),[a,t,s,m,h,n])},n),ee(n,F("input",{key:n,value:s,onChange:te((e=>g(e[$][M]+"",d)),[g])}),F("input",{key:n,type:"number",value:m,onChange:te((e=>g(Number(e[$][M]||0),u)),[g])}),F("input",{key:n,type:"checkbox",checked:h,onChange:te((e=>g(!!e[$].checked,c)),[g])})))},be=({tableId:e,store:a,editable:n,customCells:o,...r})=>F(he,{...r,params:ie(ue(l(e,a),o,n?xe:v),se(a,e),t(e,a))}),fe=({tableId:e,cellId:t,descending:o,offset:r,limit:i,store:s,editable:d,sortOnClick:m,paginator:u=!1,onChange:h,customCells:c,...g})=>{const[p,b,f]=me(t,o,m,r,i,a(e,s),u,h);return F(he,{...g,params:ie(ue(l(e,s),c,d?xe:v),se(s,e),n(e,...p,i,s),p,b,f)})},we=({store:e,editable:t=!1,valueComponent:l=(t?Ie:r),getValueComponentProps:a,className:n,headerRow:i,idColumn:s})=>F("table",{className:n},!1===i?null:F("thead",null,F("tr",null,!1===s?null:F("th",null,"Id"),F("th",null,z))),F("tbody",null,A(o(e),(t=>F("tr",{key:t},!1===s?null:F("th",null,t),F("td",null,F(l,{...j(a,t),valueId:t,store:e}))))))),ke=({indexId:e,sliceId:t,indexes:a,editable:n,customCells:o,...r})=>{const[d,m,u]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(i(a),e);return F(he,{...r,params:ie(ue(l(u,m),o,n?xe:v),se(m,u),s(e,t,d))})},ve=({relationshipId:l,relationships:a,editable:n,customCells:o,className:r,headerRow:i,idColumn:s=!0})=>{const[m,u,h,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(d(a),l),g=ue([...oe(h,u),...oe(c,u)],o,n?xe:v),p=ie(s,g,h,c,l,m,u);return F("table",{className:r},!1===i?null:F("thead",null,F("tr",null,!1===s?null:F(e.Fragment,null,F("th",null,h,".Id"),F("th",null,c,".Id")),D(g,(({label:e},t)=>F("th",{key:t},e))))),F("tbody",null,A(t(h,u),(e=>F(ge,{key:e,localRowId:e,params:p})))))},ye=({queryId:e,queries:t,customCells:l,...a})=>F(he,{...a,params:ie(ue(u(e,t),l,y),de(t,e),m(e,t))}),Ce=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:o,sortOnClick:r,paginator:i=!1,customCells:s,onChange:d,...m})=>{const[g,p,b]=me(t,l,r,a,n,h(e,o),i,d);return F(he,{...m,params:ie(ue(u(e,o),s,y),de(o,e),c(e,...g,n,o),g,p,b)})},xe=({tableId:e,rowId:t,cellId:l,store:a,className:n})=>F(pe,{thing:g(e,t,l,a),onThingChange:p(e,t,l,(e=>e),[],a),className:n??ne+"Cell",hasSchema:b(a)?.hasTablesSchema}),Ie=({valueId:e,store:t,className:l})=>F(pe,{thing:f(e,t),onThingChange:w(e,(e=>e),[],t),className:l??ne+z,hasSchema:b(t)?.hasValuesSchema}),Ne=({onChange:t,total:l,offset:a=0,limit:n=l,singular:o="row",plural:r=o+"s"})=>{(a>l||a<0)&&(a=0,t(0));const i=re((()=>t(a-n)),[t,a,n],a>0),s=re((()=>t(a+n)),[t,a,n],a+n<l);return F(e.Fragment,null,l>n&&F(e.Fragment,null,F("button",{className:"previous",disabled:0==a,onClick:i},"←"),F("button",{className:"next",disabled:a+n>=l,onClick:s},"→"),a+1," to ",Math.min(l,a+n)," of "),l," ",1!=l?r:o)},ze=e=>new Map(e);ze(),ze();const $e=e=>null;export{xe as EditableCellView,Ie as EditableValueView,ve as RelationshipInHtmlTable,Ce as ResultSortedTableInHtmlTable,ye as ResultTableInHtmlTable,ke as SliceInHtmlTable,fe as SortedTableInHtmlTable,Ne as SortedTablePaginator,$e as StoreInspector,be as TableInHtmlTable,we as ValuesInHtmlTable};
|
package/lib/ui-react-dom.js.gz
CHANGED
|
Binary file
|
package/lib/ui-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Result",n="Ids",I="Table",u=I+"s",l=I+n,i="Row",c=i+"Count",a=i+n,p="Sorted"+i+n,g="Cell",b=g+n,C="Value",m=C+"s",k=C+n,y=e=>null==e,w=(e,t,o)=>y(e)?o?.():t(e),h=e=>o(e)==r,R=()=>{},v=(e,t)=>e.map(t),q=Object.keys,{createContext:P,useContext:f}=e,x=P([]),S=(e,t)=>{const o=f(x);return y(e)?o[t]:h(e)?((e,t)=>w(e,(e=>e[t])))(o[t+1],e):e},L=(e,t)=>{const o=S(e,t);return y(e)||h(e)?o:e},B=e=>q(f(x)[e]),T=e=>S(e,0),M=e=>L(e,0),E=e=>S(e,2),V=e=>L(e,2),A=e=>S(e,4),F=e=>L(e,4),j=e=>S(e,6),O=e=>L(e,6),Q=e=>S(e,8),z=e=>L(e,8),D=e=>S(e,10),G=e=>L(e,10),{useCallback:H,useEffect:J,useMemo:K,useRef:N,useState:U}=e,W=(e,t,o=[])=>{const s=K((()=>t(e)),[e,...o]);return J((()=>()=>s.destroy()),[s]),s},X=(e,t,o,s=[],r)=>{const[,d]=U(),n=H((()=>t?.["get"+e]?.(...s)??o),[t,...s]),[I]=U(n),u=N(I);return K((()=>u.current=n()),[n]),Y(e,t,((...e)=>{u.current=y(r)?n():e[r],d([])}),[],s),u.current},Y=(e,t,o,s=[],r=[],...d)=>J((()=>{const s=t?.["add"+e+"Listener"]?.(...r,o,...d);return()=>t?.delListener(s)}),[t,...r,...s,...d]),Z=(e,t,o,s=[],r=R,d=[],...n)=>{const I=M(e);return H((e=>w(I,(s=>w(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[I,t,...s,...d,...n])},$=(e,t,o=R,s=[],...r)=>{const d=M(e);return H((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},_=(e,t,o)=>{const s=G(e);return H((()=>s?.[t](o)),[s,t,o])},ee=(e,t=[])=>K(e,t),te=()=>B(1),oe=e=>X(u,M(e),{}),se=e=>X(l,M(e),[],[]),re=(e,t)=>X(I,M(t),{},[e]),de=(e,t)=>X(I+b,M(t),[],[e]),ne=(e,t)=>X(c,M(t),[],[e]),Ie=(e,t)=>X(a,M(t),[],[e]),ue=(e,t,o,s=0,r,d)=>X(p,M(d),[],[e,t,o,s,r],6),le=(e,t,o)=>X(i,M(o),{},[e,t]),ie=(e,t,o)=>X(b,M(o),[],[e,t]),ce=(e,t,o,s)=>X(g,M(s),void 0,[e,t,o],4),ae=e=>X(m,M(e),{}),pe=e=>X(k,M(e),[],[]),ge=(e,t)=>X(C,M(t),void 0,[e]),be=(e,t,o,s,r)=>Z(o,u,e,t,s,r),Ce=(e,t,o,s,r,d)=>Z(s,I,t,o,r,d,e),me=(e,t,o,s,r,d,n)=>Z(r,i,o,s,d,n,e,t),ke=(e,t,o=[],s,r=R,d=[],n=!0)=>{const I=M(s);return H((o=>w(I,(s=>w(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[I,e,...o,...d,n])},ye=(e,t,o,s,r,d,n)=>Z(r,"PartialRow",o,s,d,n,e,t),we=(e,t,o,s,r,d,n,I)=>Z(d,g,s,r,n,I,e,t,o),he=(e,t,o,s,r)=>Z(o,m,e,t,s,r),Re=(e,t,o,s,r)=>Z(o,"PartialValues",e,t,s,r),ve=(e,t,o,s,r,d)=>Z(s,C,t,o,r,d,e),qe=(e,t,o)=>$(e,u,t,o),Pe=(e,t,o,s)=>$(t,I,o,s,e),fe=(e,t,o,s,r)=>$(o,i,s,r,e,t),xe=(e,t,o,s,r,d,n)=>$(r,g,d,n,e,t,o,s),Se=(e,t,o)=>$(e,m,t,o),Le=(e,t,o,s)=>$(t,C,o,s,e),Be=(e,t,o,s)=>Y(u,M(s),e,t,[],o),Te=(e,t,o,s)=>Y(l,M(s),e,t,[],o),Me=(e,t,o,s,r)=>Y(I,M(r),t,o,[e],s),Ee=(e,t,o,s,r)=>Y(I+b,M(r),t,o,[e],s),Ve=(e,t,o,s,r)=>Y(c,M(r),t,o,[e],s),Ae=(e,t,o,s,r)=>Y(a,M(r),t,o,[e],s),Fe=(e,t,o,s,r,d,n,I,u)=>Y(p,M(u),d,n,[e,t,o,s,r],I),je=(e,t,o,s,r,d)=>Y(i,M(d),o,s,[e,t],r),Oe=(e,t,o,s,r,d)=>Y(b,M(d),o,s,[e,t],r),Qe=(e,t,o,s,r,d,n)=>Y(g,M(n),s,r,[e,t,o],d),ze=(e,t,o,s)=>Y(m,M(s),e,t,[],o),De=(e,t,o,s)=>Y(k,M(s),e,t,[],o),Ge=(e,t,o,s,r)=>Y(C,M(r),t,o,[e],s),He=(e,t,o)=>W(e,t,o),Je=()=>B(3),Ke=e=>X("MetricIds",V(e),[]),Ne=(e,t)=>X("Metric",V(t),void 0,[e]),Ue=(e,t,o,s)=>Y("Metric",V(s),t,o,[e]),We=(e,t,o)=>W(e,t,o),Xe=()=>B(5),Ye=(e,t)=>X("SliceIds",F(t),[],[e]),Ze=e=>X("IndexIds",F(e),[]),$e=(e,t,o)=>X("Slice"+a,F(o),[],[e,t]),_e=(e,t,o,s)=>Y("SliceIds",F(s),t,o,[e]),et=(e,t,o,s,r)=>Y("Slice"+a,F(r),o,s,[e,t]),tt=(e,t,o)=>W(e,t,o),ot=()=>B(7),st=e=>X("RelationshipIds",O(e),[]),rt=(e,t,o)=>X("RemoteRowId",O(o),void 0,[e,t]),dt=(e,t,o)=>X("Local"+a,O(o),[],[e,t]),nt=(e,t,o)=>X("Linked"+a,O(o),[],[e,t]),It=(e,t,o,s,r)=>Y("RemoteRowId",O(r),o,s,[e,t]),ut=(e,t,o,s,r)=>Y("Local"+a,O(r),o,s,[e,t]),lt=(e,t,o,s,r)=>Y("Linked"+a,O(r),o,s,[e,t]),it=(e,t,o)=>W(e,t,o),ct=()=>B(9),at=e=>X("QueryIds",z(e),[]),pt=(e,t)=>X(d+I,z(t),{},[e]),gt=(e,t)=>X(d+I+b,z(t),[],[e]),bt=(e,t)=>X(d+c,z(t),[],[e]),Ct=(e,t)=>X(d+a,z(t),[],[e]),mt=(e,t,o,s=0,r,n)=>X(d+p,z(n),[],[e,t,o,s,r],6),kt=(e,t,o)=>X(d+i,z(o),{},[e,t]),yt=(e,t,o)=>X(d+b,z(o),[],[e,t]),wt=(e,t,o,s)=>X(d+g,z(s),void 0,[e,t,o]),ht=(e,t,o,s)=>Y(d+I,z(s),t,o,[e]),Rt=(e,t,o,s)=>Y(d+I+b,z(s),t,o,[e]),vt=(e,t,o,s)=>Y(d+c,z(s),t,o,[e]),qt=(e,t,o,s)=>Y(d+a,z(s),t,o,[e]),Pt=(e,t,o,s,r,n,I,u)=>Y(d+p,z(u),n,I,[e,t,o,s,r]),ft=(e,t,o,s,r)=>Y(d+i,z(r),o,s,[e,t]),xt=(e,t,o,s,r)=>Y(d+b,z(r),o,s,[e,t]),St=(e,t,o,s,r,n)=>Y(d+g,z(n),s,r,[e,t,o]),Lt=(e,t,o)=>W(e,t,o),Bt=()=>B(11),Tt=e=>X("CheckpointIds",G(e),[[],void 0,[]]),Mt=(e,t)=>X("Checkpoint",G(t),void 0,[e]),Et=(e=R,t=[],o,s=R,r=[])=>{const d=G(o);return H((t=>w(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Vt=e=>_(e,"goBackward"),At=e=>_(e,"goForward"),Ft=(e,t=[],o,s=R,r=[])=>{const d=G(o);return H((t=>w(d,(o=>w(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},jt=e=>{const t=G(e),[o,r]=Tt(t);return[(d=o,!(0==(e=>e.length)(d))),Vt(t),r,w(r,(e=>t?.getCheckpoint(e)))??s];var d},Ot=e=>{const t=G(e),[,,[o]]=Tt(t);return[!y(o),At(t),o,w(o,(e=>t?.getCheckpoint(e)))??s]},Qt=(e,t,o)=>Y("CheckpointIds",G(o),e,t),zt=(e,t,o,s)=>Y("Checkpoint",G(s),t,o,[e]),Dt=(e,t,o=[],s,r=[])=>{const[,d]=U(),n=K((()=>t(e)),[e,...o]);return J((()=>((async()=>{await(s?.(n)),d(1)})(),()=>{n.destroy()})),[n,...r]),n},{createElement:Gt,Fragment:Ht,useCallback:Jt,useLayoutEffect:Kt,useRef:Nt,useState:Ut}=e,Wt=(e,...t)=>y(e)?{}:e(...t),Xt=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:Yt}=e,Zt=({tableId:e,store:t,rowComponent:o=ro,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},I)=>oo(v(I,(d=>Gt(o,{...Wt(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),$t=({queryId:e,queries:t,resultRowComponent:o=ko,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>oo(v(n,(r=>Gt(o,{...Wt(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),_t=({relationshipId:e,relationships:t,rowComponent:o=ro,getRowComponentProps:s,separator:r,debugIds:d},n,I)=>{const[u,l,i]=Xt(O(t),e),c=n(e,I,u);return oo(v(c,(e=>Gt(o,{...Wt(s,e),key:e,tableId:i,rowId:e,store:l,debugIds:d}))),r,d,I)},eo=e=>({checkpoints:t,checkpointComponent:o=ho,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=G(t);return oo(v(e(Tt(n)),(e=>Gt(o,{...Wt(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},to=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:I,relationshipsById:u,queries:l,queriesById:i,checkpoints:c,checkpointsById:a,children:p})=>{const g=t(x);return Gt(x.Provider,{value:Yt((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},I??g[6],{...g[7],...u},l??g[8],{...g[9],...i},c??g[10],{...g[11],...a}]),[e,o,s,r,d,n,I,u,l,i,c,a,g])},p)},oo=(e,t,o,s)=>{const r=y(t)||!Array.isArray(e)?e:v(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},so=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>oo(s+(ce(e,t,o,r)??s),void 0,d,o),ro=({tableId:e,rowId:t,store:o,cellComponent:s=so,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:I})=>oo(v(((e,t,o,s)=>{const r=ie(t,o,s);return e??r})(d,e,t,o),(d=>Gt(s,{...Wt(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:I}))),n,I,t),no=e=>Zt(e,Ie(e.tableId,e.store)),Io=({cellId:e,descending:t,offset:o,limit:s,...r})=>Zt(r,ue(r.tableId,e,t,o,s,r.store)),uo=({store:e,tableComponent:t=no,getTableComponentProps:o,separator:s,debugIds:r})=>oo(v(se(e),(s=>Gt(t,{...Wt(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),lo=({valueId:e,store:t,debugIds:o})=>oo(s+(ge(e,t)??s),void 0,o,e),io=({store:e,valueComponent:t=lo,getValueComponentProps:o,separator:s,debugIds:r})=>oo(v(pe(e),(s=>Gt(t,{...Wt(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),co=({metricId:e,metrics:t,debugIds:o})=>oo(Ne(e,t)??s,void 0,o,e),ao=({indexId:e,sliceId:t,indexes:o,rowComponent:s=ro,getRowComponentProps:r,separator:d,debugIds:n})=>{const[I,u,l]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(F(o),e),i=$e(e,t,I);return oo(v(i,(e=>Gt(s,{...Wt(r,e),key:e,tableId:l,rowId:e,store:u,debugIds:n}))),d,n,t)},po=({indexId:e,indexes:t,sliceComponent:o=ao,getSliceComponentProps:s,separator:r,debugIds:d})=>oo(v(Ye(e,t),(r=>Gt(o,{...Wt(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),go=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=ro,getRowComponentProps:r,debugIds:d})=>{const[n,I,,u]=Xt(O(o),e),l=rt(e,t,n);return oo(y(u)||y(l)?null:Gt(s,{...Wt(r,l),key:l,tableId:u,rowId:l,store:I,debugIds:d}),void 0,d,t)},bo=e=>_t(e,dt,e.remoteRowId),Co=e=>_t(e,nt,e.firstRowId),mo=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>oo(s+(wt(e,t,o,r)??s),void 0,d,o),ko=({queryId:e,rowId:t,queries:o,resultCellComponent:s=mo,getResultCellComponentProps:r,separator:d,debugIds:n})=>oo(v(yt(e,t,o),(d=>Gt(s,{...Wt(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),yo=e=>$t(e,Ct(e.queryId,e.queries)),wo=({cellId:e,descending:t,offset:o,limit:s,...r})=>$t(r,mt(r.queryId,e,t,o,s,r.queries)),ho=({checkpoints:e,checkpointId:t,debugIds:o})=>oo(Mt(t,e)??s,void 0,o,t),Ro=eo((e=>e[0])),vo=eo((e=>y(e[1])?[]:[e[1]])),qo=eo((e=>e[2]));export{Ro as BackwardCheckpointsView,so as CellView,ho as CheckpointView,vo as CurrentCheckpointView,qo as ForwardCheckpointsView,po as IndexView,Co as LinkedRowsView,bo as LocalRowsView,co as MetricView,to as Provider,go as RemoteRowView,mo as ResultCellView,ko as ResultRowView,wo as ResultSortedTableView,yo as ResultTableView,ro as RowView,ao as SliceView,Io as SortedTableView,no as TableView,uo as TablesView,lo as ValueView,io as ValuesView,ke as useAddRowCallback,ce as useCell,ie as useCellIds,Oe as useCellIdsListener,Qe as useCellListener,Mt as useCheckpoint,Tt as useCheckpointIds,Qt as useCheckpointIdsListener,zt as useCheckpointListener,D as useCheckpoints,Bt as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Lt as useCreateCheckpoints,We as useCreateIndexes,He as useCreateMetrics,Dt as useCreatePersister,it as useCreateQueries,tt as useCreateRelationships,ee as useCreateStore,xe as useDelCellCallback,fe as useDelRowCallback,Pe as useDelTableCallback,qe as useDelTablesCallback,Le as useDelValueCallback,Se as useDelValuesCallback,Vt as useGoBackwardCallback,At as useGoForwardCallback,Ft as useGoToCallback,Ze as useIndexIds,A as useIndexes,Xe as useIndexesIds,F as useIndexesOrIndexesById,nt as useLinkedRowIds,lt as useLinkedRowIdsListener,dt as useLocalRowIds,ut as useLocalRowIdsListener,Ne as useMetric,Ke as useMetricIds,Ue as useMetricListener,E as useMetrics,Je as useMetricsIds,V as useMetricsOrMetricsById,Q as useQueries,ct as useQueriesIds,z as useQueriesOrQueriesById,at as useQueryIds,Ot as useRedoInformation,st as useRelationshipIds,j as useRelationships,ot as useRelationshipsIds,O as useRelationshipsOrRelationshipsById,rt as useRemoteRowId,It as useRemoteRowIdListener,wt as useResultCell,yt as useResultCellIds,xt as useResultCellIdsListener,St as useResultCellListener,kt as useResultRow,bt as useResultRowCount,vt as useResultRowCountListener,Ct as useResultRowIds,qt as useResultRowIdsListener,ft as useResultRowListener,mt as useResultSortedRowIds,Pt as useResultSortedRowIdsListener,pt as useResultTable,gt as useResultTableCellIds,Rt as useResultTableCellIdsListener,ht as useResultTableListener,le as useRow,ne as useRowCount,Ve as useRowCountListener,Ie as useRowIds,Ae as useRowIdsListener,je as useRowListener,we as useSetCellCallback,Et as useSetCheckpointCallback,ye as useSetPartialRowCallback,Re as useSetPartialValuesCallback,me as useSetRowCallback,Ce as useSetTableCallback,be as useSetTablesCallback,ve as useSetValueCallback,he as useSetValuesCallback,Ye as useSliceIds,_e as useSliceIdsListener,$e as useSliceRowIds,et as useSliceRowIdsListener,ue as useSortedRowIds,Fe as useSortedRowIdsListener,T as useStore,te as useStoreIds,M as useStoreOrStoreById,re as useTable,de as useTableCellIds,Ee as useTableCellIdsListener,se as useTableIds,Te as useTableIdsListener,Me as useTableListener,oe as useTables,Be as useTablesListener,jt as useUndoInformation,ge as useValue,pe as useValueIds,De as useValueIdsListener,Ge as useValueListener,ae as useValues,ze as useValuesListener};
|
|
1
|
+
import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Result",n="Ids",I="Table",u=I+"s",l=I+n,i="Row",c=i+"Count",a=i+n,p="Sorted"+i+n,g="Cell",b=g+n,C="Value",m=C+"s",k=C+n,y=e=>null==e,w=(e,t,o)=>y(e)?o?.():t(e),h=e=>o(e)==r,R=()=>{},v=(e,t)=>e.map(t),q=Object.keys,{createContext:P,useContext:f}=e,x=P([]),S=(e,t)=>{const o=f(x);return y(e)?o[t]:h(e)?((e,t)=>w(e,(e=>e[t])))(o[t+1]??{},e):e},L=(e,t)=>{const o=S(e,t);return y(e)||h(e)?o:e},B=e=>q(f(x)[e]??{}),T=e=>S(e,0),M=e=>L(e,0),E=e=>S(e,2),V=e=>L(e,2),A=e=>S(e,4),F=e=>L(e,4),j=e=>S(e,6),O=e=>L(e,6),Q=e=>S(e,8),z=e=>L(e,8),D=e=>S(e,10),G=e=>L(e,10),{useCallback:H,useEffect:J,useMemo:K,useRef:N,useState:U}=e,W=(e,t,o=[])=>{const s=K((()=>t(e)),[e,...o]);return J((()=>()=>s.destroy()),[s]),s},X=(e,t,o,s=[],r)=>{const[,d]=U(),n=H((()=>t?.["get"+e]?.(...s)??o),[t,...s]),[I]=U(n),u=N(I);return K((()=>u.current=n()),[n]),Y(e,t,((...e)=>{u.current=y(r)?n():e[r],d([])}),[],s),u.current},Y=(e,t,o,s=[],r=[],...d)=>J((()=>{const s=t?.["add"+e+"Listener"]?.(...r,o,...d);return()=>t?.delListener(s)}),[t,...r,...s,...d]),Z=(e,t,o,s=[],r=R,d=[],...n)=>{const I=M(e);return H((e=>w(I,(s=>w(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[I,t,...s,...d,...n])},$=(e,t,o=R,s=[],...r)=>{const d=M(e);return H((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},_=(e,t,o)=>{const s=G(e);return H((()=>s?.[t](o)),[s,t,o])},ee=(e,t=[])=>K(e,t),te=()=>B(1),oe=e=>X(u,M(e),{}),se=e=>X(l,M(e),[],[]),re=(e,t)=>X(I,M(t),{},[e]),de=(e,t)=>X(I+b,M(t),[],[e]),ne=(e,t)=>X(c,M(t),[],[e]),Ie=(e,t)=>X(a,M(t),[],[e]),ue=(e,t,o,s=0,r,d)=>X(p,M(d),[],[e,t,o,s,r],6),le=(e,t,o)=>X(i,M(o),{},[e,t]),ie=(e,t,o)=>X(b,M(o),[],[e,t]),ce=(e,t,o,s)=>X(g,M(s),void 0,[e,t,o],4),ae=e=>X(m,M(e),{}),pe=e=>X(k,M(e),[],[]),ge=(e,t)=>X(C,M(t),void 0,[e]),be=(e,t,o,s,r)=>Z(o,u,e,t,s,r),Ce=(e,t,o,s,r,d)=>Z(s,I,t,o,r,d,e),me=(e,t,o,s,r,d,n)=>Z(r,i,o,s,d,n,e,t),ke=(e,t,o=[],s,r=R,d=[],n=!0)=>{const I=M(s);return H((o=>w(I,(s=>w(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[I,e,...o,...d,n])},ye=(e,t,o,s,r,d,n)=>Z(r,"PartialRow",o,s,d,n,e,t),we=(e,t,o,s,r,d,n,I)=>Z(d,g,s,r,n,I,e,t,o),he=(e,t,o,s,r)=>Z(o,m,e,t,s,r),Re=(e,t,o,s,r)=>Z(o,"PartialValues",e,t,s,r),ve=(e,t,o,s,r,d)=>Z(s,C,t,o,r,d,e),qe=(e,t,o)=>$(e,u,t,o),Pe=(e,t,o,s)=>$(t,I,o,s,e),fe=(e,t,o,s,r)=>$(o,i,s,r,e,t),xe=(e,t,o,s,r,d,n)=>$(r,g,d,n,e,t,o,s),Se=(e,t,o)=>$(e,m,t,o),Le=(e,t,o,s)=>$(t,C,o,s,e),Be=(e,t,o,s)=>Y(u,M(s),e,t,[],o),Te=(e,t,o,s)=>Y(l,M(s),e,t,[],o),Me=(e,t,o,s,r)=>Y(I,M(r),t,o,[e],s),Ee=(e,t,o,s,r)=>Y(I+b,M(r),t,o,[e],s),Ve=(e,t,o,s,r)=>Y(c,M(r),t,o,[e],s),Ae=(e,t,o,s,r)=>Y(a,M(r),t,o,[e],s),Fe=(e,t,o,s,r,d,n,I,u)=>Y(p,M(u),d,n,[e,t,o,s,r],I),je=(e,t,o,s,r,d)=>Y(i,M(d),o,s,[e,t],r),Oe=(e,t,o,s,r,d)=>Y(b,M(d),o,s,[e,t],r),Qe=(e,t,o,s,r,d,n)=>Y(g,M(n),s,r,[e,t,o],d),ze=(e,t,o,s)=>Y(m,M(s),e,t,[],o),De=(e,t,o,s)=>Y(k,M(s),e,t,[],o),Ge=(e,t,o,s,r)=>Y(C,M(r),t,o,[e],s),He=(e,t,o)=>W(e,t,o),Je=()=>B(3),Ke=e=>X("MetricIds",V(e),[]),Ne=(e,t)=>X("Metric",V(t),void 0,[e]),Ue=(e,t,o,s)=>Y("Metric",V(s),t,o,[e]),We=(e,t,o)=>W(e,t,o),Xe=()=>B(5),Ye=(e,t)=>X("SliceIds",F(t),[],[e]),Ze=e=>X("IndexIds",F(e),[]),$e=(e,t,o)=>X("Slice"+a,F(o),[],[e,t]),_e=(e,t,o,s)=>Y("SliceIds",F(s),t,o,[e]),et=(e,t,o,s,r)=>Y("Slice"+a,F(r),o,s,[e,t]),tt=(e,t,o)=>W(e,t,o),ot=()=>B(7),st=e=>X("RelationshipIds",O(e),[]),rt=(e,t,o)=>X("RemoteRowId",O(o),void 0,[e,t]),dt=(e,t,o)=>X("Local"+a,O(o),[],[e,t]),nt=(e,t,o)=>X("Linked"+a,O(o),[],[e,t]),It=(e,t,o,s,r)=>Y("RemoteRowId",O(r),o,s,[e,t]),ut=(e,t,o,s,r)=>Y("Local"+a,O(r),o,s,[e,t]),lt=(e,t,o,s,r)=>Y("Linked"+a,O(r),o,s,[e,t]),it=(e,t,o)=>W(e,t,o),ct=()=>B(9),at=e=>X("QueryIds",z(e),[]),pt=(e,t)=>X(d+I,z(t),{},[e]),gt=(e,t)=>X(d+I+b,z(t),[],[e]),bt=(e,t)=>X(d+c,z(t),[],[e]),Ct=(e,t)=>X(d+a,z(t),[],[e]),mt=(e,t,o,s=0,r,n)=>X(d+p,z(n),[],[e,t,o,s,r],6),kt=(e,t,o)=>X(d+i,z(o),{},[e,t]),yt=(e,t,o)=>X(d+b,z(o),[],[e,t]),wt=(e,t,o,s)=>X(d+g,z(s),void 0,[e,t,o]),ht=(e,t,o,s)=>Y(d+I,z(s),t,o,[e]),Rt=(e,t,o,s)=>Y(d+I+b,z(s),t,o,[e]),vt=(e,t,o,s)=>Y(d+c,z(s),t,o,[e]),qt=(e,t,o,s)=>Y(d+a,z(s),t,o,[e]),Pt=(e,t,o,s,r,n,I,u)=>Y(d+p,z(u),n,I,[e,t,o,s,r]),ft=(e,t,o,s,r)=>Y(d+i,z(r),o,s,[e,t]),xt=(e,t,o,s,r)=>Y(d+b,z(r),o,s,[e,t]),St=(e,t,o,s,r,n)=>Y(d+g,z(n),s,r,[e,t,o]),Lt=(e,t,o)=>W(e,t,o),Bt=()=>B(11),Tt=e=>X("CheckpointIds",G(e),[[],void 0,[]]),Mt=(e,t)=>X("Checkpoint",G(t),void 0,[e]),Et=(e=R,t=[],o,s=R,r=[])=>{const d=G(o);return H((t=>w(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Vt=e=>_(e,"goBackward"),At=e=>_(e,"goForward"),Ft=(e,t=[],o,s=R,r=[])=>{const d=G(o);return H((t=>w(d,(o=>w(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},jt=e=>{const t=G(e),[o,r]=Tt(t);return[(d=o,!(0==(e=>e.length)(d))),Vt(t),r,w(r,(e=>t?.getCheckpoint(e)))??s];var d},Ot=e=>{const t=G(e),[,,[o]]=Tt(t);return[!y(o),At(t),o,w(o,(e=>t?.getCheckpoint(e)))??s]},Qt=(e,t,o)=>Y("CheckpointIds",G(o),e,t),zt=(e,t,o,s)=>Y("Checkpoint",G(s),t,o,[e]),Dt=(e,t,o=[],s,r=[])=>{const[,d]=U(),n=K((()=>t(e)),[e,...o]);return J((()=>((async()=>{await(s?.(n)),d(1)})(),()=>{n.destroy()})),[n,...r]),n},{PureComponent:Gt,Fragment:Ht,createElement:Jt,useCallback:Kt,useLayoutEffect:Nt,useRef:Ut,useState:Wt}=e,Xt=(e,...t)=>y(e)?{}:e(...t),Yt=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:Zt}=e,$t=({tableId:e,store:t,rowComponent:o=no,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},I)=>so(v(I,(d=>Jt(o,{...Xt(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),_t=({queryId:e,queries:t,resultRowComponent:o=yo,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>so(v(n,(r=>Jt(o,{...Xt(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),eo=({relationshipId:e,relationships:t,rowComponent:o=no,getRowComponentProps:s,separator:r,debugIds:d},n,I)=>{const[u,l,i]=Yt(O(t),e),c=n(e,I,u);return so(v(c,(e=>Jt(o,{...Xt(s,e),key:e,tableId:i,rowId:e,store:l,debugIds:d}))),r,d,I)},to=e=>({checkpoints:t,checkpointComponent:o=Ro,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=G(t);return so(v(e(Tt(n)),(e=>Jt(o,{...Xt(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},oo=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:I,relationshipsById:u,queries:l,queriesById:i,checkpoints:c,checkpointsById:a,children:p})=>{const g=t(x);return Jt(x.Provider,{value:Zt((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},I??g[6],{...g[7],...u},l??g[8],{...g[9],...i},c??g[10],{...g[11],...a}]),[e,o,s,r,d,n,I,u,l,i,c,a,g])},p)},so=(e,t,o,s)=>{const r=y(t)||!Array.isArray(e)?e:v(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},ro=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>so(s+(ce(e,t,o,r)??s),void 0,d,o),no=({tableId:e,rowId:t,store:o,cellComponent:s=ro,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:I})=>so(v(((e,t,o,s)=>{const r=ie(t,o,s);return e??r})(d,e,t,o),(d=>Jt(s,{...Xt(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:I}))),n,I,t),Io=e=>$t(e,Ie(e.tableId,e.store)),uo=({cellId:e,descending:t,offset:o,limit:s,...r})=>$t(r,ue(r.tableId,e,t,o,s,r.store)),lo=({store:e,tableComponent:t=Io,getTableComponentProps:o,separator:s,debugIds:r})=>so(v(se(e),(s=>Jt(t,{...Xt(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),io=({valueId:e,store:t,debugIds:o})=>so(s+(ge(e,t)??s),void 0,o,e),co=({store:e,valueComponent:t=io,getValueComponentProps:o,separator:s,debugIds:r})=>so(v(pe(e),(s=>Jt(t,{...Xt(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ao=({metricId:e,metrics:t,debugIds:o})=>so(Ne(e,t)??s,void 0,o,e),po=({indexId:e,sliceId:t,indexes:o,rowComponent:s=no,getRowComponentProps:r,separator:d,debugIds:n})=>{const[I,u,l]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(F(o),e),i=$e(e,t,I);return so(v(i,(e=>Jt(s,{...Xt(r,e),key:e,tableId:l,rowId:e,store:u,debugIds:n}))),d,n,t)},go=({indexId:e,indexes:t,sliceComponent:o=po,getSliceComponentProps:s,separator:r,debugIds:d})=>so(v(Ye(e,t),(r=>Jt(o,{...Xt(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),bo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=no,getRowComponentProps:r,debugIds:d})=>{const[n,I,,u]=Yt(O(o),e),l=rt(e,t,n);return so(y(u)||y(l)?null:Jt(s,{...Xt(r,l),key:l,tableId:u,rowId:l,store:I,debugIds:d}),void 0,d,t)},Co=e=>eo(e,dt,e.remoteRowId),mo=e=>eo(e,nt,e.firstRowId),ko=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>so(s+(wt(e,t,o,r)??s),void 0,d,o),yo=({queryId:e,rowId:t,queries:o,resultCellComponent:s=ko,getResultCellComponentProps:r,separator:d,debugIds:n})=>so(v(yt(e,t,o),(d=>Jt(s,{...Xt(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),wo=e=>_t(e,Ct(e.queryId,e.queries)),ho=({cellId:e,descending:t,offset:o,limit:s,...r})=>_t(r,mt(r.queryId,e,t,o,s,r.queries)),Ro=({checkpoints:e,checkpointId:t,debugIds:o})=>so(Mt(t,e)??s,void 0,o,t),vo=to((e=>e[0])),qo=to((e=>y(e[1])?[]:[e[1]])),Po=to((e=>e[2]));export{vo as BackwardCheckpointsView,ro as CellView,Ro as CheckpointView,qo as CurrentCheckpointView,Po as ForwardCheckpointsView,go as IndexView,mo as LinkedRowsView,Co as LocalRowsView,ao as MetricView,oo as Provider,bo as RemoteRowView,ko as ResultCellView,yo as ResultRowView,ho as ResultSortedTableView,wo as ResultTableView,no as RowView,po as SliceView,uo as SortedTableView,Io as TableView,lo as TablesView,io as ValueView,co as ValuesView,ke as useAddRowCallback,ce as useCell,ie as useCellIds,Oe as useCellIdsListener,Qe as useCellListener,Mt as useCheckpoint,Tt as useCheckpointIds,Qt as useCheckpointIdsListener,zt as useCheckpointListener,D as useCheckpoints,Bt as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Lt as useCreateCheckpoints,We as useCreateIndexes,He as useCreateMetrics,Dt as useCreatePersister,it as useCreateQueries,tt as useCreateRelationships,ee as useCreateStore,xe as useDelCellCallback,fe as useDelRowCallback,Pe as useDelTableCallback,qe as useDelTablesCallback,Le as useDelValueCallback,Se as useDelValuesCallback,Vt as useGoBackwardCallback,At as useGoForwardCallback,Ft as useGoToCallback,Ze as useIndexIds,A as useIndexes,Xe as useIndexesIds,F as useIndexesOrIndexesById,nt as useLinkedRowIds,lt as useLinkedRowIdsListener,dt as useLocalRowIds,ut as useLocalRowIdsListener,Ne as useMetric,Ke as useMetricIds,Ue as useMetricListener,E as useMetrics,Je as useMetricsIds,V as useMetricsOrMetricsById,Q as useQueries,ct as useQueriesIds,z as useQueriesOrQueriesById,at as useQueryIds,Ot as useRedoInformation,st as useRelationshipIds,j as useRelationships,ot as useRelationshipsIds,O as useRelationshipsOrRelationshipsById,rt as useRemoteRowId,It as useRemoteRowIdListener,wt as useResultCell,yt as useResultCellIds,xt as useResultCellIdsListener,St as useResultCellListener,kt as useResultRow,bt as useResultRowCount,vt as useResultRowCountListener,Ct as useResultRowIds,qt as useResultRowIdsListener,ft as useResultRowListener,mt as useResultSortedRowIds,Pt as useResultSortedRowIdsListener,pt as useResultTable,gt as useResultTableCellIds,Rt as useResultTableCellIdsListener,ht as useResultTableListener,le as useRow,ne as useRowCount,Ve as useRowCountListener,Ie as useRowIds,Ae as useRowIdsListener,je as useRowListener,we as useSetCellCallback,Et as useSetCheckpointCallback,ye as useSetPartialRowCallback,Re as useSetPartialValuesCallback,me as useSetRowCallback,Ce as useSetTableCallback,be as useSetTablesCallback,ve as useSetValueCallback,he as useSetValuesCallback,Ye as useSliceIds,_e as useSliceIdsListener,$e as useSliceRowIds,et as useSliceRowIdsListener,ue as useSortedRowIds,Fe as useSortedRowIdsListener,T as useStore,te as useStoreIds,M as useStoreOrStoreById,re as useTable,de as useTableCellIds,Ee as useTableCellIdsListener,se as useTableIds,Te as useTableIdsListener,Me as useTableListener,oe as useTables,Be as useTablesListener,jt as useUndoInformation,ge as useValue,pe as useValueIds,De as useValueIdsListener,Ge as useValueListener,ae as useValues,ze as useValuesListener};
|
package/lib/ui-react.js.gz
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=function(e,t,l){"use strict";const s=e=>typeof e,a="",n=s(a),o=s(!0),r=s(0),i=s(s),d="type",u="default",c="Ids",h="Table",m=h+"s",b=h+c,g="Row",I=g+"Count",p=g+c,f="Cell",w=f+c,y="Value",C=y+"s",v=y+c,T="currentTarget",k="value",S=e=>a+e,x=Math.floor,V=isFinite,R=(e,t)=>e instanceof t,q=e=>null==e,N=(e,t,l)=>q(e)?l?.():t(e),L=e=>e==n||e==o,M=e=>s(e)==i,E=e=>Array.isArray(e),{createElement:z,Fragment:$,useCallback:O,useLayoutEffect:A,useRef:J,useState:F}=t,B=(e,...t)=>q(e)?{}:e(...t),H=(e,t)=>e.forEach(t),P=(e,t)=>e.map(t),D=e=>e.length,Q=e=>0==D(e),j=(e,t,l)=>e.slice(t,l),W=(e,...t)=>e.push(...t),U=e=>e.shift(),G=Object,K=G.keys,X=G.isFrozen,Y=G.freeze,Z=e=>R(e,G)&&e.constructor==G,_=(e=[])=>G.fromEntries(e),ee=(e,t)=>!q(((e,t)=>N(e,(e=>e[t])))(e,t)),te=(e,t)=>(delete e[t],e),le=(e,t)=>P(G.entries(e),(([e,l])=>t(l,e))),se=e=>Z(e)&&0==(e=>D(K(e)))(e),ae=e=>JSON.stringify(e,((e,t)=>R(t,Map)?G.fromEntries([...t]):t)),ne=JSON.parse,oe="tinybaseStoreInspector",re="TinyBase Store Inspector",ie=["left","top","bottom","right","full"],de="state",ue="sort",ce="open",he="position",me=ce,be="editable",ge=(...e)=>ae(e),Ie=(e,t)=>P(e.sort(),t),pe=(e,t)=>[!!l.useCell(de,e,be,t),O((l=>{t.setCell(de,e,be,(e=>!e)),l.preventDefault()}),[t,e])],fe="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",we='content:url("',ye=we+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Ce='</svg>")',ve=we+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Te=P([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,s])=>ye+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${s}' fill='white'/>`+Ce)),ke=ye+"<path d='M20 20l60 60M20 80l60-60' />"+Ce,Se=ye+`<path d='${fe}' />`+Ce,xe=ye+`<path d='${fe}M20 20l60 60' />`+Ce,Ve="*::-webkit-scrollbar",Re=((e,t="")=>e.join(t))(le({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ve]:"width:0.5rem;height:0.5rem;",[Ve+"-track"]:"background:#111",[Ve+"-thumb"]:"background:#999;border:1px solid #111",[Ve+"-thumb:hover"]:"background:#fff",[Ve+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+ve,..._(P(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",..._(P(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ve,"header>img:nth-of-type(6)":ke,..._(P(Te,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Se,"details[open]>summary img.done":xe,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${oe} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left"},((e,t)=>e?`#${oe} ${t}{${e}}`:""))),qe=({s:e})=>{const t=l.useValue(he,e)??1,s=l.useSetValueCallback(me,(()=>!0),[],e);return l.useValue(me,e)?null:z("img",{onClick:s,title:re,"data-position":t})},Ne=({uniqueId:e,summary:t,editable:s,handleEditable:a,children:n,s:o})=>{const r=!!l.useCell(de,e,ce,o),i=l.useSetCellCallback(de,e,ce,(e=>e[T].open),[],o);return z("details",{open:r,onToggle:i},z("summary",null,t,a?z("img",{onClick:a,className:s?"done":"edit"}):null),n)},Le=e=>{const t=s(e);return L(t)||t==r&&V(e)?t:void 0},Me=(e,t,l,s,a)=>q(a)?e.delCell(t,l,s,!0):e.setCell(t,l,s,a),Ee=(e,t,l)=>q(l)?e.delValue(t):e.setValue(t,l),ze=(e,t,l,s)=>e==n?t:e==r?l:s,{useCallback:$e,useMemo:Oe,useState:Ae}=t,Je="editable",Fe=(e,t)=>P(l.useTableCellIds(e,t),(t=>e+"."+t)),Be=(e,t,l)=>{const s=$e(e,t);return l?s:void 0},He=(...e)=>Oe((()=>e),e),Pe=(e,t)=>Oe((()=>({store:e,tableId:t})),[e,t]),De=(e,t)=>Oe((()=>({queries:e,queryId:t})),[e,t]),Qe=(e,t=!1,l,s=0,a,n,o,r)=>{const[[i,d,u],c]=Ae([e,t,s]),h=$e((e=>{c(e),r?.(e)}),[r]),m=Be((e=>h([e,e==i&&!d,u])),[h,i,d,u],l),b=$e((e=>h([i,d,e])),[h,i,d]),g=!0===o?st:o;return[[i,d,u],m,Oe((()=>!1===o?null:z(g,{offset:u,limit:a,total:n,onChange:b})),[o,g,u,a,n,b])]},je=(e,t,l)=>Oe((()=>{const a=t??e;return _(le(E(a)?_(P(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:l,...(a=e,s(a)==n?{label:e}:e)}];var a})))}),[t,l,e]),We=({className:e,headerRow:t,idColumn:l,params:[s,a,n,o,r,i]})=>z("table",{className:e},i?z("caption",null,i):null,!1===t?null:z("thead",null,z("tr",null,!1===l?null:z(Ue,{sort:o??[],label:"Id",onClick:r}),le(s,(({label:e},t)=>z(Ue,{key:t,cellId:t,label:e,sort:o??[],onClick:r}))))),z("tbody",null,P(n,(e=>z("tr",{key:e},!1===l?null:z("th",null,e),le(s,(({component:t,getComponentProps:l},s)=>z("td",{key:s},z(t,{...B(l,e,s),...a,rowId:e,cellId:s}))))))))),Ue=({cellId:e,sort:[t,l],label:s=e??a,onClick:n})=>z("th",{onClick:Be((()=>n?.(e)),[n,e],n),className:q(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},q(l)||t!=e?null:(l?"↓":"↑")+" ",s),Ge=({localRowId:e,params:[s,a,n,o,r,i,d]})=>{const u=l.useRemoteRowId(r,e,i);return z("tr",null,!1===s?null:z(t.Fragment,null,z("th",null,e),z("th",null,u)),le(a,(({component:t,getComponentProps:l},s)=>{const[a,r]=s.split(".",2),i=a===n?e:a===o?u:null;return q(i)?null:z("td",{key:s},z(t,{...B(l,i,r),store:d,tableId:a,rowId:i,cellId:r}))})))},Ke=({thing:e,onThingChange:t,className:l,hasSchema:s})=>{const[a,i]=Ae(),[d,u]=Ae(),[c,h]=Ae(),[m,b]=Ae(),[g,I]=Ae();d!==e&&(i(Le(e)),u(e),h(e+""),b(Number(e)||0),I(!!e));const p=$e(((e,l)=>{l(e),u(e),t(e)}),[t]);return z("div",{className:l},z("button",{className:a,onClick:$e((()=>{if(!s?.()){const e=ze(a,r,o,n),l=ze(e,c,m,g);i(e),u(l),t(l)}}),[s,t,c,m,g,a])},a),ze(a,z("input",{key:a,value:c,onChange:$e((e=>p(e[T][k]+"",h)),[p])}),z("input",{key:a,type:"number",value:m,onChange:$e((e=>p(Number(e[T][k]||0),b)),[p])}),z("input",{key:a,type:"checkbox",checked:g,onChange:$e((e=>p(!!e[T].checked,I)),[p])})))},Xe=({tableId:e,cellId:t,descending:s,offset:a,limit:n,store:o,editable:r,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=Qe(t,s,i,a,n,l.useRowCount(e,o),d,u);return z(We,{...h,params:He(je(l.useTableCellIds(e,o),c,r?tt:l.CellView),Pe(o,e),l.useSortedRowIds(e,...m,n,o),m,b,g)})},Ye=({store:e,editable:t=!1,valueComponent:s=(t?lt:l.ValueView),getValueComponentProps:a,className:n,headerRow:o,idColumn:r})=>z("table",{className:n},!1===o?null:z("thead",null,z("tr",null,!1===r?null:z("th",null,"Id"),z("th",null,y))),z("tbody",null,P(l.useValueIds(e),(t=>z("tr",{key:t},!1===r?null:z("th",null,t),z("td",null,z(s,{...B(a,t),valueId:t,store:e}))))))),Ze=({indexId:e,sliceId:t,indexes:s,editable:a,customCells:n,...o})=>{const[r,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(l.useIndexesOrIndexesById(s),e);return z(We,{...o,params:He(je(l.useTableCellIds(d,i),n,a?tt:l.CellView),Pe(i,d),l.useSliceRowIds(e,t,r))})},_e=({relationshipId:e,relationships:s,editable:a,customCells:n,className:o,headerRow:r,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(s),e),m=je([...Fe(c,u),...Fe(h,u)],n,a?tt:l.CellView),b=He(i,m,c,h,e,d,u);return z("table",{className:o},!1===r?null:z("thead",null,z("tr",null,!1===i?null:z(t.Fragment,null,z("th",null,c,".Id"),z("th",null,h,".Id")),le(m,(({label:e},t)=>z("th",{key:t},e))))),z("tbody",null,P(l.useRowIds(c,u),(e=>z(Ge,{key:e,localRowId:e,params:b})))))},et=({queryId:e,cellId:t,descending:s,offset:a,limit:n,queries:o,sortOnClick:r,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=Qe(t,s,r,a,n,l.useResultRowCount(e,o),i,u);return z(We,{...c,params:He(je(l.useResultTableCellIds(e,o),d,l.ResultCellView),De(o,e),l.useResultSortedRowIds(e,...h,n,o),h,m,b)})},tt=({tableId:e,rowId:t,cellId:s,store:a,className:n})=>z(Ke,{thing:l.useCell(e,t,s,a),onThingChange:l.useSetCellCallback(e,t,s,(e=>e),[],a),className:n??Je+f,hasSchema:l.useStoreOrStoreById(a)?.hasTablesSchema}),lt=({valueId:e,store:t,className:s})=>z(Ke,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:s??Je+y,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),st=({onChange:e,total:l,offset:s=0,limit:a=l,singular:n="row",plural:o=n+"s"})=>{(s>l||s<0)&&(s=0,e(0));const r=Be((()=>e(s-a)),[e,s,a],s>0),i=Be((()=>e(s+a)),[e,s,a],s+a<l);return z(t.Fragment,null,l>a&&z(t.Fragment,null,z("button",{className:"previous",disabled:0==s,onClick:r},"←"),z("button",{className:"next",disabled:s+a>=l,onClick:i},"→"),s+1," to ",Math.min(l,s+a)," of "),l," ",1!=l?o:n)},at=({indexes:e,indexesId:t,indexId:s,s:a})=>z(Ne,{uniqueId:ge("i",t,s),summary:"Index: "+s,s:a},P(l.useSliceIds(s,e),(l=>z(nt,{indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})))),nt=({indexes:e,indexesId:t,indexId:l,sliceId:s,s:a})=>{const n=ge("i",t,l,s),[o,r]=pe(n,a);return z(Ne,{uniqueId:n,summary:"Slice: "+s,editable:o,handleEditable:r,s:a},z(Ze,{sliceId:s,indexId:l,indexes:e,editable:o}))},ot=({indexesId:e,s:t})=>{const s=l.useIndexes(e),a=l.useIndexIds(s);return q(s)?null:z(Ne,{uniqueId:ge("i",e),summary:"Indexes: "+(e??u),s:t},Q(a)?"No indexes defined":Ie(a,(l=>z(at,{indexes:s,indexesId:e,indexId:l,s:t}))))},rt=({metrics:e,metricId:t})=>z("tr",null,z("th",null,t),z("td",null,e?.getTableId(t)),z("td",null,l.useMetric(t,e))),it=({metricsId:e,s:t})=>{const s=l.useMetrics(e),a=l.useMetricIds(s);return q(s)?null:z(Ne,{uniqueId:ge("m",e),summary:"Metrics: "+(e??u),s:t},Q(a)?"No metrics defined":z("table",null,z("thead",null,z("th",null,"Metric Id"),z("th",null,"Table Id"),z("th",null,"Metric")),z("tbody",null,P(a,(e=>z(rt,{metrics:s,metricId:e}))))))},dt=({queries:e,queriesId:t,queryId:s,s:a})=>{const n=ge("q",t,s),[o,r,i]=ne(l.useCell(de,n,ue,a)??"[]"),d=l.useSetCellCallback(de,n,ue,ae,[],a);return z(Ne,{uniqueId:n,summary:"Query: "+s,s:a},z(et,{queryId:s,queries:e,cellId:o,descending:r,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ut=({queriesId:e,s:t})=>{const s=l.useQueries(e),a=l.useQueryIds(s);return q(s)?null:z(Ne,{uniqueId:ge("q",e),summary:"Queries: "+(e??u),s:t},Q(a)?"No queries defined":Ie(a,(l=>z(dt,{queries:s,queriesId:e,queryId:l,s:t}))))},ct=({relationships:e,relationshipsId:t,relationshipId:l,s:s})=>{const a=ge("r",t,l),[n,o]=pe(a,s);return z(Ne,{uniqueId:a,summary:"Relationship: "+l,editable:n,handleEditable:o,s:s},z(_e,{relationshipId:l,relationships:e,editable:n}))},ht=({relationshipsId:e,s:t})=>{const s=l.useRelationships(e),a=l.useRelationshipIds(s);return q(s)?null:z(Ne,{uniqueId:ge("r",e),summary:"Relationships: "+(e??u),s:t},Q(a)?"No relationships defined":Ie(a,(l=>z(ct,{relationships:s,relationshipsId:e,relationshipId:l,s:t}))))},mt=({tableId:e,store:t,storeId:s,s:a})=>{const n=ge("t",s,e),[o,r,i]=ne(l.useCell(de,n,ue,a)??"[]"),d=l.useSetCellCallback(de,n,ue,ae,[],a),[u,c]=pe(n,a);return z(Ne,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},z(Xe,{tableId:e,store:t,cellId:o,descending:r,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},bt=({store:e,storeId:t,s:s})=>{const a=ge("v",t),[n,o]=pe(a,s);return Q(l.useValueIds(e))?null:z(Ne,{uniqueId:a,summary:C,editable:n,handleEditable:o,s:s},z(Ye,{store:e,editable:n}))},gt=({storeId:e,s:t})=>{const s=l.useStore(e),a=l.useTableIds(s);return q(s)?null:z(Ne,{uniqueId:ge("s",e),summary:"Store: "+(e??u),s:t},z(bt,{storeId:e,store:s,s:t}),Ie(a,(l=>z(mt,{store:s,storeId:e,tableId:l,s:t}))))},It=({s:e})=>{const t=J(null),s=J(0),[a,n]=F(!1),{scrollLeft:o,scrollTop:r}=l.useValues(e);A((()=>{const e=t.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=x(o)+e.clientWidth&&e.scrollHeight>=x(r)+e.clientHeight&&e.scrollTo(o,r)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,o,r]);const i=O((t=>{const{scrollLeft:l,scrollTop:a}=t[T];cancelIdleCallback(s.current),s.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:l,scrollTop:a})}))}),[e]);return z("article",{ref:t,onScroll:i},z(gt,{s:e}),P(l.useStoreIds(),(t=>z(gt,{storeId:t,key:t,s:e}))),z(it,{s:e}),P(l.useMetricsIds(),(t=>z(it,{metricsId:t,key:t,s:e}))),z(ot,{s:e}),P(l.useIndexesIds(),(t=>z(ot,{indexesId:t,key:t,s:e}))),z(ht,{s:e}),P(l.useRelationshipsIds(),(t=>z(ht,{relationshipsId:t,key:t,s:e}))),z(ut,{s:e}),P(l.useQueriesIds(),(t=>z(ut,{queriesId:t,key:t,s:e}))))},pt=({s:e})=>{const t=l.useValue(he,e)??1,s=l.useSetValueCallback(me,(()=>!1),[],e),a=l.useSetValueCallback(he,(e=>Number(e[T].dataset.id)),[],e);return z("header",null,z("img",{title:re}),z("span",null,re),P(ie,((e,l)=>l==t?null:z("img",{onClick:a,"data-id":l,title:"Dock to "+e,key:l}))),z("img",{onClick:s,title:"Close"}))},ft=({s:e})=>{const t=l.useValue(he,e)??1;return l.useValue(me,e)?z("main",{"data-position":t},z(pt,{s:e}),z(It,{s:e})):null},wt=e=>t=>{return l=(t,l)=>t+e(l),xt(t).reduce(l,0);var l},yt=e=>e?.size??0,Ct=wt(yt),vt=wt(Ct),Tt=wt(vt),kt=(e,t)=>e?.has(t)??!1,St=e=>q(e)||0==yt(e),xt=e=>[...e?.values()??[]],Vt=e=>e.clear(),Rt=(e,t)=>e?.forEach(t),qt=(e,t)=>e?.delete(t),Nt=e=>new Map(e),Lt=e=>[...e?.keys()??[]],Mt=(e,t)=>e?.get(t),Et=(e,t)=>Rt(e,((e,l)=>t(l,e))),zt=(e,t,l)=>q(l)?(qt(e,t),e):e?.set(t,l),$t=(e,t,l)=>(kt(e,t)||zt(e,t,l()),Mt(e,t)),Ot=(e,t,l,s=zt)=>(le(t,((t,s)=>l(e,s,t))),Et(e,(l=>ee(t,l)?0:s(e,l))),e),At=(e,t,l)=>{const s={};return Rt(e,((e,a)=>{const n=t?t(e,a):e;!l?.(n,e)&&(s[a]=n)})),s},Jt=(e,t,l)=>At(e,(e=>At(e,t,l)),se),Ft=(e,t,l)=>At(e,(e=>Jt(e,t,l)),se),Bt=(e,t)=>{const l=Nt();return Rt(e,((e,s)=>l.set(s,t?.(e)??e))),l},Ht=e=>Bt(e,Bt),Pt=e=>Bt(e,Ht),Dt=(e,t,l,s,a=0)=>N((l?$t:Mt)(e,t[a],a>D(t)-2?l:Nt),(n=>{if(a>D(t)-2)return s?.(n)&&zt(e,t[a]),n;const o=Dt(n,t,l,s,a+1);return St(n)&&zt(e,t[a]),o})),Qt=Nt(),jt=Nt(),Wt="storage",Ut=globalThis.window,Gt=e=>new Set(E(e)||q(e)?e:[e]),Kt=(e,t)=>e?.add(t),Xt=/^\d+$/,Yt=()=>{const e=[];let t=0;return[l=>(l?U(e):null)??a+t++,t=>{Xt.test(t)&&D(e)<1e3&&W(e,t)}]},Zt=e=>[e,e],_t=(e,t=Ct)=>t(e[0])+t(e[1]),el=()=>[Nt(),Nt()],tl=e=>[...e],ll=([e,t])=>e===t,sl=(e,t,l)=>q(e)||!Z(e)||se(e)||X(e)?(l?.(),!1):(le(e,((l,s)=>{t(l,s)||te(e,s)})),!se(e)),al=(e,t,l)=>zt(e,t,Mt(e,t)==-l?void 0:l),nl=()=>{let e,t,l=!1,s=!1,n=0;const o=Nt(),i=Nt(),c=Nt(),T=Nt(),k=Nt(),x=Nt(),V=Nt(),R=Nt(),E=Nt(),z=Nt(),$=Nt(),O=Nt(),A=Nt(),J=Nt(),F=Gt(),B=Nt(),Q=Nt(),U=Nt(),G=Nt(),K=el(),X=el(),Z=el(),_=el(),oe=el(),re=el(),ie=el(),de=el(),ue=el(),ce=el(),he=el(),me=el(),be=el(),ge=el(),Ie=el(),pe=Nt(),fe=el(),[we,ye,Ce,ve]=(e=>{let t;const[l,s]=Yt(),n=Nt();return[(e,s,o,r=[],i=(()=>[]))=>{t??=wl;const d=l(1);return zt(n,d,[e,s,o,r,i]),Kt(Dt(s,o??[a],Gt),d),d},(e,l,...s)=>H(((e,t=[a])=>{const l=[],s=(e,a)=>a==D(t)?W(l,e):null===t[a]?Rt(e,(e=>s(e,a+1))):H([t[a],null],(t=>s(Mt(e,t),a+1)));return s(e,0),l})(e,l),(e=>Rt(e,(e=>Mt(n,e)[0](t,...l??[],...s))))),e=>N(Mt(n,e),(([,t,l])=>(Dt(t,l??[a],void 0,(t=>(qt(t,e),St(t)?1:0))),zt(n,e),s(e),l))),e=>N(Mt(n,e),(([e,,l=[],s,a])=>{const n=(...o)=>{const r=D(o);r==D(l)?e(t,...o,...a(o)):q(l[r])?H(s[r]?.(...o)??[],(e=>n(...o,e))):n(...o,l[r])};n()}))]})(),Te=e=>{if(!sl(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!L(t)&&t!=r||(Le(e[u])!=t&&te(e,u),0))},ke=(t,l)=>(!e||kt($,l)||st(l))&&sl(t,((e,t)=>Se(l,t,e)),(()=>st(l))),Se=(e,t,l,s)=>sl(s?l:qe(l,e,t),((s,a)=>N(xe(e,t,a,s),(e=>(l[a]=e,!0)),(()=>!1))),(()=>st(e,t))),xe=(t,l,s,a)=>e?N(Mt(Mt($,t),s),(e=>Le(a)!=e[d]?st(t,l,s,a,e[u]):a),(()=>st(t,l,s,a))):q(Le(a))?st(t,l,s,a):a,Ve=(e,t)=>sl(t?e:Ne(e),((t,l)=>N(Re(l,t),(t=>(e[l]=t,!0)),(()=>!1))),(()=>at())),Re=(e,l)=>t?N(Mt(A,e),(t=>Le(l)!=t[d]?at(e,l,t[u]):l),(()=>at(e,l))):q(Le(l))?at(e,l):l,qe=(e,t,l)=>(N(Mt(O,t),(([s,a])=>{Rt(s,((t,l)=>{ee(e,l)||(e[l]=t)})),Rt(a,(s=>{ee(e,s)||st(t,l,s)}))})),e),Ne=e=>(t&&(Rt(J,((t,l)=>{ee(e,l)||(e[l]=t)})),Rt(F,(t=>{ee(e,t)||at(t)}))),e),ze=e=>Ot($,e,((e,t,l)=>{const s=Nt(),a=Gt();Ot($t($,t,Nt),l,((e,t,l)=>{zt(e,t,l),N(l[u],(e=>zt(s,t,e)),(()=>Kt(a,t)))})),zt(O,t,[s,a])}),((e,t)=>{zt($,t),zt(O,t)})),$e=e=>Ot(A,e,((e,t,l)=>{zt(A,t,l),N(l[u],(e=>zt(J,t,e)),(()=>Kt(F,t)))}),((e,t)=>{zt(A,t),zt(J,t),qt(F,t)})),Oe=e=>se(e)?ul():Xt(e),Ae=e=>Ot(U,e,((e,t,l)=>Je(t,l)),((e,t)=>Ue(t))),Je=(e,t)=>Ot($t(U,e,(()=>(Ye(e,1),zt(B,e,Yt()),zt(Q,e,Nt()),Nt()))),t,((t,l,s)=>Fe(e,t,l,s)),((t,l)=>Ge(e,t,l))),Fe=(e,t,l,s,a)=>Ot($t(t,l,(()=>(Ze(e,l,1),Nt()))),s,((t,s,a)=>Be(e,l,t,s,a)),((s,n)=>Ke(e,t,l,s,n,a))),Be=(e,t,l,s,a)=>{kt(l,s)||_e(e,t,s,1);const n=Mt(l,s);a!==n&&(et(e,t,s,n,a),zt(l,s,a))},He=(e,t,l,s,a)=>N(Mt(t,l),(t=>Be(e,l,t,s,a)),(()=>Fe(e,t,l,qe({[s]:a},e,l)))),Pe=e=>se(e)?ml():ol(e),De=e=>Ot(G,e,((e,t,l)=>Qe(t,l)),((e,t)=>Xe(t))),Qe=(e,t)=>{kt(G,e)||tt(e,1);const l=Mt(G,e);t!==l&&(lt(e,l,t),zt(G,e,t))},je=(e,t)=>{const[l]=Mt(B,e),s=l(t);return kt(Mt(U,e),s)?je(e,t):s},We=e=>Mt(U,e)??Je(e,{}),Ue=e=>Je(e,{}),Ge=(e,t,l)=>{const[,s]=Mt(B,e);s(l),Fe(e,t,l,{},!0)},Ke=(e,t,l,s,a,n)=>{const o=Mt(Mt(O,e)?.[0],a);if(!q(o)&&!n)return Be(e,l,s,a,o);const r=t=>{et(e,l,t,Mt(s,t)),_e(e,l,t,-1),zt(s,t)};q(o)?r(a):Et(s,r),St(s)&&(Ze(e,l,-1),St(zt(t,l))&&(Ye(e,-1),zt(U,e),zt(B,e),zt(Q,e)))},Xe=e=>{const t=Mt(J,e);if(!q(t))return Qe(e,t);lt(e,Mt(G,e)),tt(e,-1),zt(G,e)},Ye=(e,t)=>al(o,e,t),Ze=(e,t,l)=>al($t(T,e,Nt),t,l)&&zt(c,e,$t(c,e,(()=>0))+l),_e=(e,t,l,s)=>{const a=Mt(Q,e),n=Mt(a,l)??0;(0==n&&1==s||1==n&&-1==s)&&al($t(i,e,Nt),l,s),zt(a,l,n!=-s?n+s:null),al($t($t(k,e,Nt),t,Nt),l,s)},et=(e,t,l,s,a)=>$t($t($t(x,e,Nt),t,Nt),l,(()=>[s,0]))[1]=a,tt=(e,t)=>al(V,e,t),lt=(e,t,l)=>$t(R,e,(()=>[t,0]))[1]=l,st=(e,t,l,s,a)=>(W($t($t($t(E,e,Nt),t,Nt),l,(()=>[])),s),a),at=(e,t,l)=>(W($t(z,e,(()=>[])),t),l),nt=(e,t,l)=>N(Mt(Mt(Mt(x,e),t),l),(([e,t])=>[!0,e,t]),(()=>[!1,...Zt(Qt(e,t,l))])),ot=e=>N(Mt(R,e),(([e,t])=>[!0,e,t]),(()=>[!1,...Zt(Ut(e))])),rt=e=>St(E)||St(he[e])?0:Rt(e?Pt(E):E,((t,l)=>Rt(t,((t,s)=>Rt(t,((t,a)=>ye(he[e],[l,s,a],t))))))),it=e=>St(z)||St(me[e])?0:Rt(e?Bt(z):z,((t,l)=>ye(me[e],[l],t))),dt=(e,t,l)=>{if(!St(t))return ye(e,l,(()=>At(t))),1},ut=e=>{const t=St(ie[e]),l=St(ue[e])&&St(_[e])&&St(oe[e])&&St(re[e])&&t&&St(X[e]),s=St(ce[e])&&St(de[e])&&St(Z[e])&&St(K[e]);if(!l||!s){const a=e?[Bt(o),Ht(i),Bt(c),Ht(T),Pt(k),Pt(x)]:[o,i,c,T,k,x];if(!l){dt(X[e],a[0]),Rt(a[1],((t,l)=>dt(_[e],t,[l]))),Rt(a[2],((t,l)=>{0!=t&&ye(oe[e],[l],pt(l))}));const l=Gt();Rt(a[3],((s,a)=>{dt(re[e],s,[a])&&!t&&(ye(ie[e],[a,null]),Kt(l,a))})),t||Rt(a[5],((t,s)=>{if(!kt(l,s)){const l=Gt();Rt(t,(e=>Rt(e,(([t,s],a)=>s!==t?Kt(l,a):qt(e,a))))),Rt(l,(t=>ye(ie[e],[s,t])))}})),Rt(a[4],((t,l)=>Rt(t,((t,s)=>dt(ue[e],t,[l,s])))))}if(!s){let t;Rt(a[5],((l,s)=>{let a;Rt(l,((l,n)=>{let o;Rt(l,(([l,r],i)=>{r!==l&&(ye(ce[e],[s,n,i],r,l,nt),t=a=o=1)})),o&&ye(de[e],[s,n],nt)})),a&&ye(Z[e],[s],nt)})),t&&ye(K[e],void 0,nt)}}},ct=e=>{const t=St(ge[e]),l=St(Ie[e])&&St(be[e]);if(!t||!l){const s=e?[Bt(V),Bt(R)]:[V,R];if(t||dt(ge[e],s[0]),!l){let t;Rt(s[1],(([l,s],a)=>{s!==l&&(ye(Ie[e],[a],s,l,ot),t=1)})),t&&ye(be[e],void 0,ot)}}},ht=(e,...t)=>(Il((()=>e(...P(t,S)))),wl),mt=()=>[At(x,((e,t)=>-1===Mt(o,t)?null:At(e,((e,l)=>-1===Mt(Mt(T,t),l)?null:At(e,(([,e])=>e??null),((e,t)=>ll(t)))),se)),se),At(R,(([,e])=>e??null),((e,t)=>ll(t)))],bt=()=>({cellsTouched:l,valuesTouched:s,changedCells:Ft(x,tl,ll),invalidCells:Ft(E),changedValues:At(R,tl,ll),invalidValues:At(z),changedTableIds:At(o),changedRowIds:Jt(T),changedCellIds:Ft(k),changedValueIds:At(V)}),gt=()=>Ft(U),It=()=>Lt(U),pt=e=>yt(Mt(U,S(e))),ft=e=>Lt(Mt(U,S(e))),wt=(e,t,l,s=0,a)=>{return P(j((o=Mt(U,S(e)),r=(e,l)=>[q(t)?l:Mt(e,S(t)),l],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(l?-1:1),P([...o?.entries()??[]],(([e,t])=>r(t,e))).sort(n)),s,q(a)?a:s+a),(([,e])=>e));var n,o,r},xt=(e,t)=>Lt(Mt(Mt(U,S(e)),S(t))),Qt=(e,t,l)=>Mt(Mt(Mt(U,S(e)),S(t)),S(l)),jt=()=>At(G),Wt=()=>Lt(G),Ut=e=>Mt(G,S(e)),Xt=e=>ht((()=>(e=>sl(e,ke,st))(e)?Ae(e):0)),ol=e=>ht((()=>Ve(e)?De(e):0)),rl=e=>{try{Oe(ne(e))}catch{}return wl},il=t=>ht((()=>{if((e=sl(t,(e=>sl(e,Te))))&&(ze(t),!St(U))){const e=gt();ul(),Xt(e)}})),dl=e=>ht((()=>{if(t=(e=>sl(e,Te))(e)){const l=jt();gl(),ml(),t=!0,$e(e),ol(l)}})),ul=()=>ht((()=>Ae({}))),cl=e=>ht((e=>kt(U,e)?Ue(e):0),e),hl=(e,t)=>ht(((e,t)=>N(Mt(U,e),(l=>kt(l,t)?Ge(e,l,t):0))),e,t),ml=()=>ht((()=>De({}))),bl=()=>ht((()=>{ze({}),e=!1})),gl=()=>ht((()=>{$e({}),t=!1})),Il=(e,t)=>{if(-1!=n){pl();const l=e();return fl(t),l}},pl=()=>(-1!=n&&n++,1==n&&ye(pe,void 0,mt,bt),wl),fl=e=>(n>0&&(n--,0==n&&(l=!St(x),s=!St(R),n=1,rt(1),l&&ut(1),it(1),s&&ct(1),e?.(mt,bt)&&(Rt(x,((e,t)=>Rt(e,((e,l)=>Rt(e,(([e],s)=>Me(wl,t,l,s,e))))))),Rt(R,(([e],t)=>Ee(wl,t,e))),l=s=!1),ye(fe[0],void 0,mt,bt),n=-1,rt(0),l&&ut(0),it(0),s&&ct(0),ye(fe[1],void 0,mt,bt),n=0,l=s=!1,H([o,i,c,T,k,x,E,V,R,z],Vt))),wl),wl={getContent:()=>[gt(),jt()],getTables:gt,getTableIds:It,getTable:e=>Jt(Mt(U,S(e))),getTableCellIds:e=>Lt(Mt(Q,S(e))),getRowCount:pt,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>At(Mt(Mt(U,S(e)),S(t))),getCellIds:xt,getCell:Qt,getValues:jt,getValueIds:Wt,getValue:Ut,hasTables:()=>!St(U),hasTable:e=>kt(U,S(e)),hasTableCell:(e,t)=>kt(Mt(Q,S(e)),S(t)),hasRow:(e,t)=>kt(Mt(U,S(e)),S(t)),hasCell:(e,t,l)=>kt(Mt(Mt(U,S(e)),S(t)),S(l)),hasValues:()=>!St(G),hasValue:e=>kt(G,S(e)),getTablesJson:()=>ae(U),getValuesJson:()=>ae(G),getJson:()=>ae([U,G]),getTablesSchemaJson:()=>ae($),getValuesSchemaJson:()=>ae(A),getSchemaJson:()=>ae([$,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(se(e)?ul:Xt)(e),(se(t)?ml:ol)(t)})),setTables:Xt,setTable:(e,t)=>ht((e=>ke(t,e)?Je(e,t):0),e),setRow:(e,t,l)=>ht(((e,t)=>Se(e,t,l)?Fe(e,We(e),t,l):0),e,t),addRow:(e,t,l=!0)=>Il((()=>{let s;return Se(e,s,t)&&(e=S(e),Fe(e,We(e),s=je(e,l?1:0),t)),s})),setPartialRow:(e,t,l)=>ht(((e,t)=>{if(Se(e,t,l,1)){const s=We(e);le(l,((l,a)=>He(e,s,t,a,l)))}}),e,t),setCell:(e,t,l,s)=>ht(((e,t,l)=>N(xe(e,t,l,M(s)?s(Qt(e,t,l)):s),(s=>He(e,We(e),t,l,s)))),e,t,l),setValues:ol,setPartialValues:e=>ht((()=>Ve(e,1)?le(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>N(Re(e,M(t)?t(Ut(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{le(e[0],((e,t)=>q(e)?cl(t):le(e,((e,l)=>q(e)?hl(t,l):le(e,((e,s)=>Me(wl,t,l,s,e))))))),le(e[1],((e,t)=>Ee(wl,t,e)))})),setTablesJson:rl,setValuesJson:e=>{try{Pe(ne(e))}catch{}return wl},setJson:e=>{try{const[t,l]=ne(e);Oe(t),Pe(l)}catch{rl(e)}return wl},setTablesSchema:il,setValuesSchema:dl,setSchema:(e,t)=>ht((()=>{il(e),dl(t)})),delTables:ul,delTable:cl,delRow:hl,delCell:(e,t,l,s)=>ht(((e,t,l)=>N(Mt(U,e),(a=>N(Mt(a,t),(n=>kt(n,l)?Ke(e,a,t,n,l,s):0))))),e,t,l),delValues:ml,delValue:e=>ht((e=>kt(G,e)?Xe(e):0),e),delTablesSchema:bl,delValuesSchema:gl,delSchema:()=>ht((()=>{bl(),gl()})),transaction:Il,startTransaction:pl,finishTransaction:fl,forEachTable:e=>Rt(U,((t,l)=>e(l,(e=>Rt(t,((t,l)=>e(l,(e=>Et(t,e))))))))),forEachTableCell:(e,t)=>Et(Mt(Q,S(e)),t),forEachRow:(e,t)=>Rt(Mt(U,S(e)),((e,l)=>t(l,(t=>Et(e,t))))),forEachCell:(e,t,l)=>Et(Mt(Mt(U,S(e)),S(t)),l),forEachValue:e=>Et(G,e),addSortedRowIdsListener:(e,t,l,s,a,n,o)=>{let r=wt(e,t,l,s,a);return we((()=>{const o=wt(e,t,l,s,a);var i,d,u;d=r,D(i=o)===D(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(r=o,n(wl,e,t,l,s,a,r))}),ie[o?1:0],[e,t],[It])},addStartTransactionListener:e=>we(e,pe),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),wl),delListener:e=>(Ce(e),wl),getListenerStats:()=>({tables:_t(K),tableIds:_t(X),tableCellIds:_t(_),table:_t(Z),rowCount:_t(oe),rowIds:_t(re),sortedRowIds:_t(ie),row:_t(de,vt),cellIds:_t(ue,vt),cell:_t(ce,Tt),invalidCell:_t(he,Tt),values:_t(be),valueIds:_t(ge),value:_t(Ie),invalidValue:_t(me),transaction:Ct(pe)+_t(fe)}),createStore:nl,addListener:we,callListeners:ye};return le({[m]:[0,K],[b]:[0,X],[h]:[1,Z,[It]],[h+w]:[1,_,[It]],[I]:[1,oe,[It]],[p]:[1,re,[It]],[g]:[2,de,[It,ft]],[w]:[2,ue,[It,ft]],[f]:[3,ce,[It,ft,xt],e=>Zt(Qt(...e))],InvalidCell:[3,he],[C]:[0,be],[v]:[0,ge],[y]:[1,Ie,[Wt],e=>Zt(Ut(e[0]))],InvalidValue:[1,me]},(([e,t,l,s],a)=>{wl["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?j(a,0,e):void 0,l,s)})),Y(wl)},ol=({position:e="right",open:t=!1})=>{const s=l.useCreateStore(nl),a=ie.indexOf(e);return l.useCreatePersister(s,(e=>{return((e,t,l,s)=>((e,t,l,s,a,n,o=[])=>{let r,i,d,u=0,c=0,h=0,m=0;$t(Qt,o,(()=>0)),$t(jt,o,(()=>[]));const b=async e=>(2!=u&&(u=1,c++,await g.schedule((async()=>{await e(),u=0}))),g),g={load:async(l,s)=>await b((async()=>{try{e.setContent(await t())}catch{e.setContent([l,s])}})),startAutoLoad:async(l={},a={})=>(g.stopAutoLoad(),await g.load(l,a),m=1,d=s((async(l,s)=>{if(s){const t=s();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(l?.()??await t())}catch(e){n?.(e)}}))})),g),stopAutoLoad:()=>(m&&(a(d),d=void 0,m=0),g),save:async t=>(1!=u&&(u=2,h++,await g.schedule((async()=>{try{await l(e.getContent,t)}catch(e){n?.(e)}u=0}))),g),startAutoSave:async()=>(await g.stopAutoSave().save(),r=e.addDidFinishTransactionListener(((e,t)=>{const[l,s]=t();se(l)&&se(s)||g.save((()=>[l,s]))})),g),stopAutoSave:()=>(N(r,e.delListener),g),schedule:async(...e)=>(W(Mt(jt,o),...e),await(async()=>{if(!Mt(Qt,o)){for(zt(Qt,o,1);!q(i=U(Mt(jt,o)));)try{await i()}catch(e){n?.(e)}zt(Qt,o,0)}})(),g),getStore:()=>e,destroy:()=>g.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Y(g)})(e,(async()=>ne(l.getItem(t))),(async e=>l.setItem(t,ae(e()))),(e=>{const s=s=>{s.storageArea===l&&s.key===t&&e((()=>ne(s.newValue)))};return Ut.addEventListener(Wt,s),s}),(e=>Ut.removeEventListener(Wt,e)),s))(e,oe,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!t}),await e.startAutoSave()})),z($,null,z("aside",{id:oe},z(qe,{s:s}),z(ft,{s:s})),z("style",null,Re))};e.EditableCellView=tt,e.EditableValueView=lt,e.RelationshipInHtmlTable=_e,e.ResultSortedTableInHtmlTable=et,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:s,...a})=>z(We,{...a,params:He(je(l.useResultTableCellIds(e,t),s,l.ResultCellView),De(t,e),l.useResultRowIds(e,t))}),e.SliceInHtmlTable=Ze,e.SortedTableInHtmlTable=Xe,e.SortedTablePaginator=st,e.StoreInspector=e=>z(ol,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:s,customCells:a,...n})=>z(We,{...n,params:He(je(l.useTableCellIds(e,t),a,s?tt:l.CellView),Pe(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=Ye},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
|
|
1
|
+
var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,a="",n=l(a),r=l(!0),o=l(0),i=l(l),d="type",u="default",c="Ids",h="Table",m=h+"s",b=h+c,g="Row",I=g+"Count",p=g+c,f="Cell",w=f+c,y="Value",C=y+"s",v=y+c,T="currentTarget",k="value",S=e=>a+e,x=Math.floor,V=isFinite,R=(e,t)=>e instanceof t,q=e=>null==e,N=(e,t,s)=>q(e)?s?.():t(e),L=e=>e==n||e==r,M=e=>l(e)==i,E=e=>Array.isArray(e),{PureComponent:z,Fragment:$,createElement:O,useCallback:A,useLayoutEffect:F,useRef:J,useState:P}=t,B=(e,...t)=>q(e)?{}:e(...t),H=(e,t)=>e.forEach(t),D=(e,t)=>e.map(t),Q=e=>e.length,j=e=>0==Q(e),W=(e,t,s)=>e.slice(t,s),U=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),te=(e,t)=>!q(((e,t)=>N(e,(e=>e[t])))(e,t)),se=(e,t)=>(delete e[t],e),le=(e,t)=>D(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>Q(X(e)))(e),ne=e=>JSON.stringify(e,((e,t)=>R(t,Map)?K.fromEntries([...t]):t)),re=JSON.parse,oe="tinybaseStoreInspector",ie="TinyBase Store Inspector",de=["left","top","bottom","right","full"],ue="state",ce="sort",he="open",me="position",be=he,ge="editable",Ie=(...e)=>ne(e),pe=(e,t)=>D(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),A((s=>{t.setCell(ue,e,ge,(e=>!e)),s.preventDefault()}),[t,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',Ce=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ve='</svg>")',Te=ye+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",ke=D([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ve)),Se=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ve,xe=Ce+`<path d='${we}' />`+ve,Ve=Ce+`<path d='${we}M20 20l60 60' />`+ve,Re="*::-webkit-scrollbar",qe=((e,t="")=>e.join(t))(le({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Re]:"width:0.5rem;height:0.5rem;",[Re+"-track"]:"background:#111",[Re+"-thumb"]:"background:#999;border:1px solid #111",[Re+"-thumb:hover"]:"background:#fff",[Re+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Te,...ee(D(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...ee(D(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Te,"header>img:nth-of-type(6)":Se,...ee(D(ke,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":xe,"details[open]>summary img.done":Ve,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${oe} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${oe} ${t}{${e}}`:""))),Ne=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!0),[],e);return s.useValue(be,e)?null:O("img",{onClick:l,title:ie,"data-position":t})},Le=({uniqueId:e,summary:t,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!s.useCell(ue,e,he,r),i=s.useSetCellCallback(ue,e,he,(e=>e[T].open),[],r);return O("details",{open:o,onToggle:i},O("summary",null,t,a?O("img",{onClick:a,className:l?"done":"edit"}):null),n)},Me=e=>{const t=l(e);return L(t)||t==o&&V(e)?t:void 0},Ee=(e,t,s,l,a)=>q(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),ze=(e,t,s)=>q(s)?e.delValue(t):e.setValue(t,s),$e=(e,t,s,l)=>e==n?t:e==o?s:l,{useCallback:Oe,useMemo:Ae,useState:Fe}=t,Je="editable",Pe=(e,t)=>D(s.useTableCellIds(e,t),(t=>e+"."+t)),Be=(e,t,s)=>{const l=Oe(e,t);return s?l:void 0},He=(...e)=>Ae((()=>e),e),De=(e,t)=>Ae((()=>({store:e,tableId:t})),[e,t]),Qe=(e,t)=>Ae((()=>({queries:e,queryId:t})),[e,t]),je=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=Fe([e,t,l]),h=Oe((e=>{c(e),o?.(e)}),[o]),m=Be((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=Oe((e=>h([i,d,e])),[h,i,d]),g=!0===r?at:r;return[[i,d,u],m,Ae((()=>!1===r?null:O(g,{offset:u,limit:a,total:n,onChange:b})),[r,g,u,a,n,b])]},We=(e,t,s)=>Ae((()=>{const a=t??e;return ee(le(E(a)?ee(D(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:s,...(a=e,l(a)==n?{label:e}:e)}];var a})))}),[t,s,e]),Ue=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>O("table",{className:e},i?O("caption",null,i):null,!1===t?null:O("thead",null,O("tr",null,!1===s?null:O(Ge,{sort:r??[],label:"Id",onClick:o}),le(l,(({label:e},t)=>O(Ge,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),O("tbody",null,D(n,(e=>O("tr",{key:e},!1===s?null:O("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>O("td",{key:l},O(t,{...B(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>O("th",{onClick:Be((()=>n?.(e)),[n,e],n),className:q(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},q(s)||t!=e?null:(s?"↓":"↑")+" ",l),Ke=({localRowId:e,params:[l,a,n,r,o,i,d]})=>{const u=s.useRemoteRowId(o,e,i);return O("tr",null,!1===l?null:O(t.Fragment,null,O("th",null,e),O("th",null,u)),le(a,(({component:t,getComponentProps:s},l)=>{const[a,o]=l.split(".",2),i=a===n?e:a===r?u:null;return q(i)?null:O("td",{key:l},O(t,{...B(s,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},Xe=({thing:e,onThingChange:t,className:s,hasSchema:l})=>{const[a,i]=Fe(),[d,u]=Fe(),[c,h]=Fe(),[m,b]=Fe(),[g,I]=Fe();d!==e&&(i(Me(e)),u(e),h(e+""),b(Number(e)||0),I(!!e));const p=Oe(((e,s)=>{s(e),u(e),t(e)}),[t]);return O("div",{className:s},O("button",{className:a,onClick:Oe((()=>{if(!l?.()){const e=$e(a,o,r,n),s=$e(e,c,m,g);i(e),u(s),t(s)}}),[l,t,c,m,g,a])},a),$e(a,O("input",{key:a,value:c,onChange:Oe((e=>p(e[T][k]+"",h)),[p])}),O("input",{key:a,type:"number",value:m,onChange:Oe((e=>p(Number(e[T][k]||0),b)),[p])}),O("input",{key:a,type:"checkbox",checked:g,onChange:Oe((e=>p(!!e[T].checked,I)),[p])})))},Ye=({tableId:e,cellId:t,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=je(t,l,i,a,n,s.useRowCount(e,r),d,u);return O(Ue,{...h,params:He(We(s.useTableCellIds(e,r),c,o?st:s.CellView),De(r,e),s.useSortedRowIds(e,...m,n,r),m,b,g)})},Ze=({store:e,editable:t=!1,valueComponent:l=(t?lt:s.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>O("table",{className:n},!1===r?null:O("thead",null,O("tr",null,!1===o?null:O("th",null,"Id"),O("th",null,y))),O("tbody",null,D(s.useValueIds(e),(t=>O("tr",{key:t},!1===o?null:O("th",null,t),O("td",null,O(l,{...B(a,t),valueId:t,store:e}))))))),_e=({indexId:e,sliceId:t,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return O(Ue,{...r,params:He(We(s.useTableCellIds(d,i),n,a?st:s.CellView),De(i,d),s.useSliceRowIds(e,t,o))})},et=({relationshipId:e,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=We([...Pe(c,u),...Pe(h,u)],n,a?st:s.CellView),b=He(i,m,c,h,e,d,u);return O("table",{className:r},!1===o?null:O("thead",null,O("tr",null,!1===i?null:O(t.Fragment,null,O("th",null,c,".Id"),O("th",null,h,".Id")),le(m,(({label:e},t)=>O("th",{key:t},e))))),O("tbody",null,D(s.useRowIds(c,u),(e=>O(Ke,{key:e,localRowId:e,params:b})))))},tt=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=je(t,l,o,a,n,s.useResultRowCount(e,r),i,u);return O(Ue,{...c,params:He(We(s.useResultTableCellIds(e,r),d,s.ResultCellView),Qe(r,e),s.useResultSortedRowIds(e,...h,n,r),h,m,b)})},st=({tableId:e,rowId:t,cellId:l,store:a,className:n})=>O(Xe,{thing:s.useCell(e,t,l,a),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],a),className:n??Je+f,hasSchema:s.useStoreOrStoreById(a)?.hasTablesSchema}),lt=({valueId:e,store:t,className:l})=>O(Xe,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Je+y,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),at=({onChange:e,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,e(0));const o=Be((()=>e(l-a)),[e,l,a],l>0),i=Be((()=>e(l+a)),[e,l,a],l+a<s);return O(t.Fragment,null,s>a&&O(t.Fragment,null,O("button",{className:"previous",disabled:0==l,onClick:o},"←"),O("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?r:n)},nt=({indexes:e,indexesId:t,indexId:l,s:a})=>O(Le,{uniqueId:Ie("i",t,l),summary:"Index: "+l,s:a},D(s.useSliceIds(l,e),(s=>O(rt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a})))),rt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Ie("i",t,s,l),[r,o]=fe(n,a);return O(Le,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},O(_e,{sliceId:l,indexId:s,indexes:e,editable:r}))},ot=({indexesId:e,s:t})=>{const l=s.useIndexes(e),a=s.useIndexIds(l);return q(l)?null:O(Le,{uniqueId:Ie("i",e),summary:"Indexes: "+(e??u),s:t},j(a)?"No indexes defined":pe(a,(s=>O(nt,{indexes:l,indexesId:e,indexId:s,s:t}))))},it=({metrics:e,metricId:t})=>O("tr",null,O("th",null,t),O("td",null,e?.getTableId(t)),O("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:O(Le,{uniqueId:Ie("m",e),summary:"Metrics: "+(e??u),s:t},j(a)?"No metrics defined":O("table",null,O("thead",null,O("th",null,"Metric Id"),O("th",null,"Table Id"),O("th",null,"Metric")),O("tbody",null,D(a,(e=>O(it,{metrics:l,metricId:e}))))))},ut=({queries:e,queriesId:t,queryId:l,s:a})=>{const n=Ie("q",t,l),[r,o,i]=re(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a);return O(Le,{uniqueId:n,summary:"Query: "+l,s:a},O(tt,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ct=({queriesId:e,s:t})=>{const l=s.useQueries(e),a=s.useQueryIds(l);return q(l)?null:O(Le,{uniqueId:Ie("q",e),summary:"Queries: "+(e??u),s:t},j(a)?"No queries defined":pe(a,(s=>O(ut,{queries:l,queriesId:e,queryId:s,s:t}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Ie("r",t,s),[n,r]=fe(a,l);return O(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},O(et,{relationshipId:s,relationships:e,editable:n}))},mt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),a=s.useRelationshipIds(l);return q(l)?null:O(Le,{uniqueId:Ie("r",e),summary:"Relationships: "+(e??u),s:t},j(a)?"No relationships defined":pe(a,(s=>O(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t}))))},bt=({tableId:e,store:t,storeId:l,s:a})=>{const n=Ie("t",l,e),[r,o,i]=re(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a),[u,c]=fe(n,a);return O(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},O(Ye,{tableId:e,store:t,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},gt=({store:e,storeId:t,s:l})=>{const a=Ie("v",t),[n,r]=fe(a,l);return j(s.useValueIds(e))?null:O(Le,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},O(Ze,{store:e,editable:n}))},It=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:O(Le,{uniqueId:Ie("s",e),summary:"Store: "+(e??u),s:t},O(gt,{storeId:e,store:l,s:t}),pe(a,(s=>O(bt,{store:l,storeId:e,tableId:s,s:t}))))},pt=({s:e})=>{const t=J(null),l=J(0),[a,n]=P(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);F((()=>{const e=t.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=x(r)+e.clientWidth&&e.scrollHeight>=x(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=A((t=>{const{scrollLeft:s,scrollTop:a}=t[T];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),b=s.useIndexesIds(),g=s.useRelationships(),I=s.useRelationshipsIds(),p=s.useQueries(),f=s.useQueriesIds();return q(d)&&j(u)&&q(c)&&j(h)&&q(m)&&j(b)&&q(g)&&j(I)&&q(p)&&j(f)?O("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):O("article",{ref:t,onScroll:i},O(It,{s:e}),D(u,(t=>O(It,{storeId:t,key:t,s:e}))),O(dt,{s:e}),D(h,(t=>O(dt,{metricsId:t,key:t,s:e}))),O(ot,{s:e}),D(b,(t=>O(ot,{indexesId:t,key:t,s:e}))),O(mt,{s:e}),D(I,(t=>O(mt,{relationshipsId:t,key:t,s:e}))),O(ct,{s:e}),D(f,(t=>O(ct,{queriesId:t,key:t,s:e}))))};class ft extends z{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError=()=>({e:1});componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?O("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const wt=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!1),[],e),a=s.useSetValueCallback(me,(e=>Number(e[T].dataset.id)),[],e);return O("header",null,O("img",{title:ie}),O("span",null,ie),D(de,((e,s)=>s==t?null:O("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),O("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?O("main",{"data-position":t},O(wt,{s:e}),O(ft,null,O(pt,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Rt(t).reduce(s,0);var s},vt=e=>e?.size??0,Tt=Ct(vt),kt=Ct(Tt),St=Ct(kt),xt=(e,t)=>e?.has(t)??!1,Vt=e=>q(e)||0==vt(e),Rt=e=>[...e?.values()??[]],qt=e=>e.clear(),Nt=(e,t)=>e?.forEach(t),Lt=(e,t)=>e?.delete(t),Mt=e=>new Map(e),Et=e=>[...e?.keys()??[]],zt=(e,t)=>e?.get(t),$t=(e,t)=>Nt(e,((e,s)=>t(s,e))),Ot=(e,t,s)=>q(s)?(Lt(e,t),e):e?.set(t,s),At=(e,t,s)=>(xt(e,t)||Ot(e,t,s()),zt(e,t)),Ft=(e,t,s,l=Ot)=>(le(t,((t,l)=>s(e,l,t))),$t(e,(s=>te(t,s)?0:l(e,s))),e),Jt=(e,t,s)=>{const l={};return Nt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Pt=(e,t,s)=>Jt(e,(e=>Jt(e,t,s)),ae),Bt=(e,t,s)=>Jt(e,(e=>Pt(e,t,s)),ae),Ht=(e,t)=>{const s=Mt();return Nt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Dt=e=>Ht(e,Ht),Qt=e=>Ht(e,Dt),jt=(e,t,s,l,a=0)=>N((s?At:zt)(e,t[a],a>Q(t)-2?s:Mt),(n=>{if(a>Q(t)-2)return l?.(n)&&Ot(e,t[a]),n;const r=jt(n,t,s,l,a+1);return Vt(n)&&Ot(e,t[a]),r})),Wt=Mt(),Ut=Mt(),Gt="storage",Kt=globalThis.window,Xt=e=>new Set(E(e)||q(e)?e:[e]),Yt=(e,t)=>e?.add(t),Zt=/^\d+$/,_t=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??a+t++,t=>{Zt.test(t)&&Q(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=Tt)=>t(e[0])+t(e[1]),ss=()=>[Mt(),Mt()],ls=e=>[...e],as=([e,t])=>e===t,ns=(e,t,s)=>q(e)||!_(e)||ae(e)||Y(e)?(s?.(),!1):(le(e,((s,l)=>{t(s,l)||se(e,l)})),!ae(e)),rs=(e,t,s)=>Ot(e,t,zt(e,t)==-s?void 0:s),os=()=>{let e,t,s=!1,l=!1,n=0;const r=Mt(),i=Mt(),c=Mt(),T=Mt(),k=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),z=Mt(),$=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Xt(),P=Mt(),B=Mt(),j=Mt(),G=Mt(),K=ss(),X=ss(),Y=ss(),_=ss(),ee=ss(),oe=ss(),ie=ss(),de=ss(),ue=ss(),ce=ss(),he=ss(),me=ss(),be=ss(),ge=ss(),Ie=ss(),pe=Mt(),fe=ss(),[we,ye,Ce,ve]=(e=>{let t;const[s,l]=_t(),n=Mt();return[(e,l,r,o=[],i=(()=>[]))=>{t??=ws;const d=s(1);return Ot(n,d,[e,l,r,o,i]),Yt(jt(l,r??[a],Xt),d),d},(e,s,...l)=>H(((e,t=[a])=>{const s=[],l=(e,a)=>a==Q(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):H([t[a],null],(t=>l(zt(e,t),a+1)));return l(e,0),s})(e,s),(e=>Nt(e,(e=>zt(n,e)[0](t,...s??[],...l))))),e=>N(zt(n,e),(([,t,s])=>(jt(t,s??[a],void 0,(t=>(Lt(t,e),Vt(t)?1:0))),Ot(n,e),l(e),s))),e=>N(zt(n,e),(([e,,s=[],l,a])=>{const n=(...r)=>{const o=Q(r);o==Q(s)?e(t,...r,...a(r)):q(s[o])?H(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),Te=e=>{if(!ns(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!L(t)&&t!=o||(Me(e[u])!=t&&se(e,u),0))},ke=(t,s)=>(!e||xt($,s)||lt(s))&&ns(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>ns(l?s:qe(s,e,t),((l,a)=>N(xe(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),xe=(t,s,l,a)=>e?N(zt(zt($,t),l),(e=>Me(a)!=e[d]?lt(t,s,l,a,e[u]):a),(()=>lt(t,s,l,a))):q(Me(a))?lt(t,s,l,a):a,Ve=(e,t)=>ns(t?e:Ne(e),((t,s)=>N(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?N(zt(A,e),(t=>Me(s)!=t[d]?at(e,s,t[u]):s),(()=>at(e,s))):q(Me(s))?at(e,s):s,qe=(e,t,s)=>(N(zt(O,t),(([l,a])=>{Nt(l,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(a,(l=>{te(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(Nt(F,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(J,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft($,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At($,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(O,t,[l,a])}),((e,t)=>{Ot($,t),Ot(O,t)})),$e=e=>Ft(A,e,((e,t,s)=>{Ot(A,t,s),N(s[u],(e=>Ot(F,t,e)),(()=>Yt(J,t)))}),((e,t)=>{Ot(A,t),Ot(F,t),Lt(J,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(j,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(j,e,(()=>(Ye(e,1),Ot(P,e,_t()),Ot(B,e,Mt()),Mt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ge(e,t,s))),Je=(e,t,s,l,a)=>Ft(At(t,s,(()=>(Ze(e,s,1),Mt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ke(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{xt(s,l)||_e(e,t,l,1);const n=zt(s,l);a!==n&&(et(e,t,l,n,a),Ot(s,l,a))},Be=(e,t,s,l,a)=>N(zt(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),He=e=>ae(e)?ms():Kt(e),De=e=>Ft(G,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{xt(G,e)||tt(e,1);const s=zt(G,e);t!==s&&(st(e,s,t),Ot(G,e,t))},je=(e,t)=>{const[s]=zt(P,e),l=s(t);return xt(zt(j,e),l)?je(e,t):l},We=e=>zt(j,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(P,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const r=zt(zt(O,e)?.[0],a);if(!q(r)&&!n)return Pe(e,s,l,a,r);const o=t=>{et(e,s,t,zt(l,t)),_e(e,s,t,-1),Ot(l,t)};q(r)?o(a):$t(l,o),Vt(l)&&(Ze(e,s,-1),Vt(Ot(t,s))&&(Ye(e,-1),Ot(j,e),Ot(P,e),Ot(B,e)))},Xe=e=>{const t=zt(F,e);if(!q(t))return Qe(e,t);st(e,zt(G,e)),tt(e,-1),Ot(G,e)},Ye=(e,t)=>rs(r,e,t),Ze=(e,t,s)=>rs(At(T,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(B,e),n=zt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&rs(At(i,e,Mt),s,l),Ot(a,s,n!=-l?n+l:null),rs(At(At(k,e,Mt),t,Mt),s,l)},et=(e,t,s,l,a)=>At(At(At(x,e,Mt),t,Mt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>rs(V,e,t),st=(e,t,s)=>At(R,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(U(At(At(At(E,e,Mt),t,Mt),s,(()=>[])),l),a),at=(e,t,s)=>(U(At(z,e,(()=>[])),t),s),nt=(e,t,s)=>N(zt(zt(zt(x,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ct(e,t,s))])),rt=e=>N(zt(R,e),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ut(e))])),ot=e=>Vt(E)||Vt(he[e])?0:Nt(e?Qt(E):E,((t,s)=>Nt(t,((t,l)=>Nt(t,((t,a)=>ye(he[e],[s,l,a],t))))))),it=e=>Vt(z)||Vt(me[e])?0:Nt(e?Ht(z):z,((t,s)=>ye(me[e],[s],t))),dt=(e,t,s)=>{if(!Vt(t))return ye(e,s,(()=>Jt(t))),1},ut=e=>{const t=Vt(ie[e]),s=Vt(ue[e])&&Vt(_[e])&&Vt(ee[e])&&Vt(oe[e])&&t&&Vt(X[e]),l=Vt(ce[e])&&Vt(de[e])&&Vt(Y[e])&&Vt(K[e]);if(!s||!l){const a=e?[Ht(r),Dt(i),Ht(c),Dt(T),Qt(k),Qt(x)]:[r,i,c,T,k,x];if(!s){dt(X[e],a[0]),Nt(a[1],((t,s)=>dt(_[e],t,[s]))),Nt(a[2],((t,s)=>{0!=t&&ye(ee[e],[s],pt(s))}));const s=Xt();Nt(a[3],((l,a)=>{dt(oe[e],l,[a])&&!t&&(ye(ie[e],[a,null]),Yt(s,a))})),t||Nt(a[5],((t,l)=>{if(!xt(s,l)){const s=Xt();Nt(t,(e=>Nt(e,(([t,l],a)=>l!==t?Yt(s,a):Lt(e,a))))),Nt(s,(t=>ye(ie[e],[l,t])))}})),Nt(a[4],((t,s)=>Nt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;Nt(a[5],((s,l)=>{let a;Nt(s,((s,n)=>{let r;Nt(s,(([s,o],i)=>{o!==s&&(ye(ce[e],[l,n,i],o,s,nt),t=a=r=1)})),r&&ye(de[e],[l,n],nt)})),a&&ye(Y[e],[l],nt)})),t&&ye(K[e],void 0,nt)}}},ct=e=>{const t=Vt(ge[e]),s=Vt(Ie[e])&&Vt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(R)]:[V,R];if(t||dt(ge[e],l[0]),!s){let t;Nt(l[1],(([s,l],a)=>{l!==s&&(ye(Ie[e],[a],l,s,rt),t=1)})),t&&ye(be[e],void 0,rt)}}},ht=(e,...t)=>(Is((()=>e(...D(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(r,t)?null:Jt(e,((e,s)=>-1===zt(zt(T,t),s)?null:Jt(e,(([,e])=>e??null),((e,t)=>as(t)))),ae)),ae),Jt(R,(([,e])=>e??null),((e,t)=>as(t)))],bt=()=>({cellsTouched:s,valuesTouched:l,changedCells:Bt(x,ls,as),invalidCells:Bt(E),changedValues:Jt(R,ls,as),invalidValues:Jt(z),changedTableIds:Jt(r),changedRowIds:Pt(T),changedCellIds:Bt(k),changedValueIds:Jt(V)}),gt=()=>Bt(j),It=()=>Et(j),pt=e=>vt(zt(j,S(e))),ft=e=>Et(zt(j,S(e))),wt=(e,t,s,l=0,a)=>{return D(W((r=zt(j,S(e)),o=(e,s)=>[q(t)?s:zt(e,S(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),D([...r?.entries()??[]],(([e,t])=>o(t,e))).sort(n)),l,q(a)?a:l+a),(([,e])=>e));var n,r,o},yt=(e,t)=>Et(zt(zt(j,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(j,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,ke,lt))(e)?Ae(e):0)),Kt=e=>ht((()=>Ve(e)?De(e):0)),Zt=e=>{try{Oe(re(e))}catch{}return ws},is=t=>ht((()=>{if((e=ns(t,(e=>ns(e,Te))))&&(Le(t),!Vt(j))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,Te))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(j,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(j,e),(s=>xt(s,t)?Ge(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{Le({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),Is=(e,t)=>{if(-1!=n){ps();const s=e();return fs(t),s}},ps=()=>(-1!=n&&n++,1==n&&ye(pe,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Vt(x),l=!Vt(R),n=1,ot(1),s&&ut(1),it(1),l&&ct(1),e?.(mt,bt)&&(Nt(x,((e,t)=>Nt(e,((e,s)=>Nt(e,(([e],l)=>Ee(ws,t,s,l,e))))))),Nt(R,(([e],t)=>ze(ws,t,e))),s=l=!1),ye(fe[0],void 0,mt,bt),n=-1,ot(0),s&&ut(0),it(0),l&&ct(0),ye(fe[1],void 0,mt,bt),n=0,s=l=!1,H([r,i,c,T,k,x,E,V,R,z],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:It,getTable:e=>Pt(zt(j,S(e))),getTableCellIds:e=>Et(zt(B,S(e))),getRowCount:pt,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(j,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(j),hasTable:e=>xt(j,S(e)),hasTableCell:(e,t)=>xt(zt(B,S(e)),S(t)),hasRow:(e,t)=>xt(zt(j,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(j,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(j),getValuesJson:()=>ne(G),getJson:()=>ne([j,G]),getTablesSchemaJson:()=>ne($),getValuesSchemaJson:()=>ne(A),getSchemaJson:()=>ne([$,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(ae(e)?us:Gt)(e),(ae(t)?ms:Kt)(t)})),setTables:Gt,setTable:(e,t)=>ht((e=>ke(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>Is((()=>{let l;return Se(e,l,t)&&(e=S(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);le(s,((s,a)=>Be(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>N(xe(e,t,s,M(l)?l(Ct(e,t,s)):l),(l=>Be(e,We(e),t,s,l)))),e,t,s),setValues:Kt,setPartialValues:e=>ht((()=>Ve(e,1)?le(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>N(Re(e,M(t)?t(Ut(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{le(e[0],((e,t)=>q(e)?cs(t):le(e,((e,s)=>q(e)?hs(t,s):le(e,((e,l)=>Ee(ws,t,s,l,e))))))),le(e[1],((e,t)=>ze(ws,t,e)))})),setTablesJson:Zt,setValuesJson:e=>{try{He(re(e))}catch{}return ws},setJson:e=>{try{const[t,s]=re(e);Oe(t),He(s)}catch{Zt(e)}return ws},setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>N(zt(j,e),(a=>N(zt(a,t),(n=>xt(n,s)?Ke(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>xt(G,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:Is,startTransaction:ps,finishTransaction:fs,forEachTable:e=>Nt(j,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(B,S(e)),t),forEachRow:(e,t)=>Nt(zt(j,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(j,S(e)),S(t)),s),forEachValue:e=>$t(G,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=wt(e,t,s,l,a);return we((()=>{const r=wt(e,t,s,l,a);var i,d,u;d=o,Q(i=r)===Q(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(ws,e,t,s,l,a,o))}),ie[r?1:0],[e,t],[It])},addStartTransactionListener:e=>we(e,pe),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(Ce(e),ws),getListenerStats:()=>({tables:ts(K),tableIds:ts(X),tableCellIds:ts(_),table:ts(Y),rowCount:ts(ee),rowIds:ts(oe),sortedRowIds:ts(ie),row:ts(de,kt),cellIds:ts(ue,kt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(Ie),invalidValue:ts(me),transaction:Tt(pe)+ts(fe)}),createStore:os,addListener:we,callListeners:ye};return le({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[It]],[h+w]:[1,_,[It]],[I]:[1,ee,[It]],[p]:[1,oe,[It]],[g]:[2,de,[It,ft]],[w]:[2,ue,[It,ft]],[f]:[3,ce,[It,ft,yt],e=>es(Ct(...e))],InvalidCell:[3,he],[C]:[0,be],[v]:[0,ge],[y]:[1,Ie,[Wt],e=>es(Ut(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?W(a,0,e):void 0,s,l)})),Z(ws)},is=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(os),a=de.indexOf(e);return s.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,r=[])=>{let o,i,d,u=0,c=0,h=0,m=0;At(Wt,r,(()=>0)),At(Ut,r,(()=>[]));const b=async e=>(2!=u&&(u=1,c++,await g.schedule((async()=>{await e(),u=0}))),g),g={load:async(s,l)=>await b((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(g.stopAutoLoad(),await g.load(s,a),m=1,d=l((async(s,l)=>{if(l){const t=l();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),g),stopAutoLoad:()=>(m&&(a(d),d=void 0,m=0),g),save:async t=>(1!=u&&(u=2,h++,await g.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}u=0}))),g),startAutoSave:async()=>(await g.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();ae(s)&&ae(l)||g.save((()=>[s,l]))})),g),stopAutoSave:()=>(N(o,e.delListener),g),schedule:async(...e)=>(U(zt(Ut,r),...e),await(async()=>{if(!zt(Wt,r)){for(Ot(Wt,r,1);!q(i=G(zt(Ut,r)));)try{await i()}catch(e){n?.(e)}Ot(Wt,r,0)}})(),g),getStore:()=>e,destroy:()=>g.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(g)})(e,(async()=>re(s.getItem(t))),(async e=>s.setItem(t,ne(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>re(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l))(e,oe,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!t}),await e.startAutoSave()})),O($,null,O("aside",{id:oe},O(Ne,{s:l}),O(yt,{s:l})),O("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>O(Ue,{...a,params:He(We(s.useResultTableCellIds(e,t),l,s.ResultCellView),Qe(t,e),s.useResultRowIds(e,t))}),e.SliceInHtmlTable=_e,e.SortedTableInHtmlTable=Ye,e.SortedTablePaginator=at,e.StoreInspector=e=>O(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>O(Ue,{...n,params:He(We(s.useTableCellIds(e,t),a,l?st:s.CellView),De(t,e),s.useRowIds(e,t))}),e.ValuesInHtmlTable=Ze},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
|
|
Binary file
|
package/lib/umd/ui-react-dom.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=function(e,t,l){"use strict";const a=e=>typeof e,n=a(""),o=a(!0),r=a(0),s="Value",i="currentTarget",d="value",u=isFinite,m=e=>null==e,{createElement:c,Fragment:h,useCallback:b,useLayoutEffect:g,useRef:p,useState:f}=t,w=(e,...t)=>m(e)?{}:e(...t),I=(e,t)=>e.map(t),C=Object,y=(e=[])=>C.fromEntries(e),k=(e,t)=>I(C.entries(e),(([e,l])=>t(l,e))),v="tinybaseStoreInspector",x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",R='content:url("',T=R+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",S='</svg>")',N=R+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",V=I([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>T+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+S)),z=T+"<path d='M20 20l60 60M20 80l60-60' />"+S,$=T+`<path d='${x}' />`+S,M=T+`<path d='${x}M20 20l60 60' />`+S,q="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(k({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[q]:"width:0.5rem;height:0.5rem;",[q+"-track"]:"background:#111",[q+"-thumb"]:"background:#999;border:1px solid #111",[q+"-thumb:hover"]:"background:#fff",[q+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+N,...y(I(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...y(I(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":N,"header>img:nth-of-type(6)":z,...y(I(V,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":$,"details[open]>summary img.done":M,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${v} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left"},((e,t)=>e?`#${v} ${t}{${e}}`:"")));const B=(e,t,l,a)=>e==n?t:e==r?l:a,{useCallback:H,useMemo:O,useState:F}=t,E="editable",P=(e,t)=>I(l.useTableCellIds(e,t),(t=>e+"."+t)),j=(e,t,l)=>{const a=H(e,t);return l?a:void 0},A=(...e)=>O((()=>e),e),L=(e,t)=>O((()=>({store:e,tableId:t})),[e,t]),U=(e,t)=>O((()=>({queries:e,queryId:t})),[e,t]),D=(e,t=!1,l,a=0,n,o,r,s)=>{const[[i,d,u],m]=F([e,t,a]),h=H((e=>{m(e),s?.(e)}),[s]),b=j((e=>h([e,e==i&&!d,u])),[h,i,d,u],l),g=H((e=>h([i,d,e])),[h,i,d]),p=!0===r?Z:r;return[[i,d,u],b,O((()=>!1===r?null:c(p,{offset:u,limit:n,total:o,onChange:g})),[r,p,u,n,o,g])]},G=(e,t,l)=>O((()=>{const o=t??e;return y(k(Array.isArray(o)?y(I(o,(e=>[e,e]))):o,((e,t)=>{return[t,{label:t,component:l,...(o=e,a(o)==n?{label:e}:e)}];var o})))}),[t,l,e]),J=({className:e,headerRow:t,idColumn:l,params:[a,n,o,r,s,i]})=>c("table",{className:e},i?c("caption",null,i):null,!1===t?null:c("thead",null,c("tr",null,!1===l?null:c(K,{sort:r??[],label:"Id",onClick:s}),k(a,(({label:e},t)=>c(K,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),c("tbody",null,I(o,(e=>c("tr",{key:e},!1===l?null:c("th",null,e),k(a,(({component:t,getComponentProps:l},a)=>c("td",{key:a},c(t,{...w(l,e,a),...n,rowId:e,cellId:a}))))))))),K=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>c("th",{onClick:j((()=>n?.(e)),[n,e],n),className:m(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},m(l)||t!=e?null:(l?"↓":"↑")+" ",a),Q=({localRowId:e,params:[a,n,o,r,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return c("tr",null,!1===a?null:c(t.Fragment,null,c("th",null,e),c("th",null,u)),k(n,(({component:t,getComponentProps:l},a)=>{const[n,s]=a.split(".",2),i=n===o?e:n===r?u:null;return m(i)?null:c("td",{key:a},c(t,{...w(l,i,s),store:d,tableId:n,rowId:i,cellId:s}))})))},W=({thing:e,onThingChange:t,className:l,hasSchema:s})=>{const[m,h]=F(),[b,g]=F(),[p,f]=F(),[w,I]=F(),[C,y]=F();b!==e&&(h((e=>{const t=a(e);return(e=>e==n||e==o)(t)||t==r&&u(e)?t:void 0})(e)),g(e),f(e+""),I(Number(e)||0),y(!!e));const k=H(((e,l)=>{l(e),g(e),t(e)}),[t]);return c("div",{className:l},c("button",{className:m,onClick:H((()=>{if(!s?.()){const e=B(m,r,o,n),l=B(e,p,w,C);h(e),g(l),t(l)}}),[s,t,p,w,C,m])},m),B(m,c("input",{key:m,value:p,onChange:H((e=>k(e[i][d]+"",f)),[k])}),c("input",{key:m,type:"number",value:w,onChange:H((e=>k(Number(e[i][d]||0),I)),[k])}),c("input",{key:m,type:"checkbox",checked:C,onChange:H((e=>k(!!e[i].checked,y)),[k])})))},X=({tableId:e,rowId:t,cellId:a,store:n,className:o})=>c(W,{thing:l.useCell(e,t,a,n),onThingChange:l.useSetCellCallback(e,t,a,(e=>e),[],n),className:o??E+"Cell",hasSchema:l.useStoreOrStoreById(n)?.hasTablesSchema}),Y=({valueId:e,store:t,className:a})=>c(W,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:a??E+s,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),Z=({onChange:e,total:l,offset:a=0,limit:n=l,singular:o="row",plural:r=o+"s"})=>{(a>l||a<0)&&(a=0,e(0));const s=j((()=>e(a-n)),[e,a,n],a>0),i=j((()=>e(a+n)),[e,a,n],a+n<l);return c(t.Fragment,null,l>n&&c(t.Fragment,null,c("button",{className:"previous",disabled:0==a,onClick:s},"←"),c("button",{className:"next",disabled:a+n>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+n)," of "),l," ",1!=l?r:o)},_=e=>new Map(e);_(),_(),e.EditableCellView=X,e.EditableValueView=Y,e.RelationshipInHtmlTable=({relationshipId:e,relationships:a,editable:n,customCells:o,className:r,headerRow:s,idColumn:i=!0})=>{const[d,u,m,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(a),e),b=G([...P(m,u),...P(h,u)],o,n?X:l.CellView),g=A(i,b,m,h,e,d,u);return c("table",{className:r},!1===s?null:c("thead",null,c("tr",null,!1===i?null:c(t.Fragment,null,c("th",null,m,".Id"),c("th",null,h,".Id")),k(b,(({label:e},t)=>c("th",{key:t},e))))),c("tbody",null,I(l.useRowIds(m,u),(e=>c(Q,{key:e,localRowId:e,params:g})))))},e.ResultSortedTableInHtmlTable=({queryId:e,cellId:t,descending:a,offset:n,limit:o,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[h,b,g]=D(t,a,s,n,o,l.useResultRowCount(e,r),i,u);return c(J,{...m,params:A(G(l.useResultTableCellIds(e,r),d,l.ResultCellView),U(r,e),l.useResultSortedRowIds(e,...h,o,r),h,b,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...n})=>c(J,{...n,params:A(G(l.useResultTableCellIds(e,t),a,l.ResultCellView),U(t,e),l.useResultRowIds(e,t))}),e.SliceInHtmlTable=({indexId:e,sliceId:t,indexes:a,editable:n,customCells:o,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(l.useIndexesOrIndexesById(a),e);return c(J,{...r,params:A(G(l.useTableCellIds(d,i),o,n?X:l.CellView),L(i,d),l.useSliceRowIds(e,t,s))})},e.SortedTableInHtmlTable=({tableId:e,cellId:t,descending:a,offset:n,limit:o,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...h})=>{const[b,g,p]=D(t,a,i,n,o,l.useRowCount(e,r),d,u);return c(J,{...h,params:A(G(l.useTableCellIds(e,r),m,s?X:l.CellView),L(r,e),l.useSortedRowIds(e,...b,o,r),b,g,p)})},e.SortedTablePaginator=Z,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:n,...o})=>c(J,{...o,params:A(G(l.useTableCellIds(e,t),n,a?X:l.CellView),L(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:a=(t?Y:l.ValueView),getValueComponentProps:n,className:o,headerRow:r,idColumn:i})=>c("table",{className:o},!1===r?null:c("thead",null,c("tr",null,!1===i?null:c("th",null,"Id"),c("th",null,s))),c("tbody",null,I(l.useValueIds(e),(t=>c("tr",{key:t},!1===i?null:c("th",null,t),c("td",null,c(a,{...w(n,t),valueId:t,store:e})))))))},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.React,e.TinyBaseUiReact);
|
|
1
|
+
var e,t;e=this,t=function(e,t,l){"use strict";const a=e=>typeof e,n=a(""),o=a(!0),r=a(0),s="Value",i="currentTarget",d="value",u=isFinite,m=e=>null==e,{PureComponent:c,Fragment:h,createElement:b,useCallback:g,useLayoutEffect:p,useRef:f,useState:w}=t,I=(e,...t)=>m(e)?{}:e(...t),C=(e,t)=>e.map(t),y=Object,k=(e=[])=>y.fromEntries(e),v=(e,t)=>C(y.entries(e),(([e,l])=>t(l,e))),x="tinybaseStoreInspector",R="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",T='content:url("',S=T+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",N='</svg>")',V=T+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",z=C([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>S+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+N)),$=S+"<path d='M20 20l60 60M20 80l60-60' />"+N,M=S+`<path d='${R}' />`+N,q=S+`<path d='${R}M20 20l60 60' />`+N,B="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(v({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[B]:"width:0.5rem;height:0.5rem;",[B+"-track"]:"background:#111",[B+"-thumb"]:"background:#999;border:1px solid #111",[B+"-thumb:hover"]:"background:#fff",[B+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+V,...k(C(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...k(C(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":V,"header>img:nth-of-type(6)":$,...k(C(z,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":M,"details[open]>summary img.done":q,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${x} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${x} ${t}{${e}}`:"")));const H=(e,t,l,a)=>e==n?t:e==r?l:a,{useCallback:O,useMemo:F,useState:E}=t,P="editable",j=(e,t)=>C(l.useTableCellIds(e,t),(t=>e+"."+t)),A=(e,t,l)=>{const a=O(e,t);return l?a:void 0},L=(...e)=>F((()=>e),e),U=(e,t)=>F((()=>({store:e,tableId:t})),[e,t]),D=(e,t)=>F((()=>({queries:e,queryId:t})),[e,t]),G=(e,t=!1,l,a=0,n,o,r,s)=>{const[[i,d,u],m]=E([e,t,a]),c=O((e=>{m(e),s?.(e)}),[s]),h=A((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=O((e=>c([i,d,e])),[c,i,d]),p=!0===r?_:r;return[[i,d,u],h,F((()=>!1===r?null:b(p,{offset:u,limit:n,total:o,onChange:g})),[r,p,u,n,o,g])]},J=(e,t,l)=>F((()=>{const o=t??e;return k(v(Array.isArray(o)?k(C(o,(e=>[e,e]))):o,((e,t)=>{return[t,{label:t,component:l,...(o=e,a(o)==n?{label:e}:e)}];var o})))}),[t,l,e]),K=({className:e,headerRow:t,idColumn:l,params:[a,n,o,r,s,i]})=>b("table",{className:e},i?b("caption",null,i):null,!1===t?null:b("thead",null,b("tr",null,!1===l?null:b(Q,{sort:r??[],label:"Id",onClick:s}),v(a,(({label:e},t)=>b(Q,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),b("tbody",null,C(o,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),v(a,(({component:t,getComponentProps:l},a)=>b("td",{key:a},b(t,{...I(l,e,a),...n,rowId:e,cellId:a}))))))))),Q=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>b("th",{onClick:A((()=>n?.(e)),[n,e],n),className:m(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},m(l)||t!=e?null:(l?"↓":"↑")+" ",a),W=({localRowId:e,params:[a,n,o,r,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===a?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),v(n,(({component:t,getComponentProps:l},a)=>{const[n,s]=a.split(".",2),i=n===o?e:n===r?u:null;return m(i)?null:b("td",{key:a},b(t,{...I(l,i,s),store:d,tableId:n,rowId:i,cellId:s}))})))},X=({thing:e,onThingChange:t,className:l,hasSchema:s})=>{const[m,c]=E(),[h,g]=E(),[p,f]=E(),[w,I]=E(),[C,y]=E();h!==e&&(c((e=>{const t=a(e);return(e=>e==n||e==o)(t)||t==r&&u(e)?t:void 0})(e)),g(e),f(e+""),I(Number(e)||0),y(!!e));const k=O(((e,l)=>{l(e),g(e),t(e)}),[t]);return b("div",{className:l},b("button",{className:m,onClick:O((()=>{if(!s?.()){const e=H(m,r,o,n),l=H(e,p,w,C);c(e),g(l),t(l)}}),[s,t,p,w,C,m])},m),H(m,b("input",{key:m,value:p,onChange:O((e=>k(e[i][d]+"",f)),[k])}),b("input",{key:m,type:"number",value:w,onChange:O((e=>k(Number(e[i][d]||0),I)),[k])}),b("input",{key:m,type:"checkbox",checked:C,onChange:O((e=>k(!!e[i].checked,y)),[k])})))},Y=({tableId:e,rowId:t,cellId:a,store:n,className:o})=>b(X,{thing:l.useCell(e,t,a,n),onThingChange:l.useSetCellCallback(e,t,a,(e=>e),[],n),className:o??P+"Cell",hasSchema:l.useStoreOrStoreById(n)?.hasTablesSchema}),Z=({valueId:e,store:t,className:a})=>b(X,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:a??P+s,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),_=({onChange:e,total:l,offset:a=0,limit:n=l,singular:o="row",plural:r=o+"s"})=>{(a>l||a<0)&&(a=0,e(0));const s=A((()=>e(a-n)),[e,a,n],a>0),i=A((()=>e(a+n)),[e,a,n],a+n<l);return b(t.Fragment,null,l>n&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==a,onClick:s},"←"),b("button",{className:"next",disabled:a+n>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+n)," of "),l," ",1!=l?r:o)},ee=e=>new Map(e);ee(),ee(),e.EditableCellView=Y,e.EditableValueView=Z,e.RelationshipInHtmlTable=({relationshipId:e,relationships:a,editable:n,customCells:o,className:r,headerRow:s,idColumn:i=!0})=>{const[d,u,m,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(a),e),h=J([...j(m,u),...j(c,u)],o,n?Y:l.CellView),g=L(i,h,m,c,e,d,u);return b("table",{className:r},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,m,".Id"),b("th",null,c,".Id")),v(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,C(l.useRowIds(m,u),(e=>b(W,{key:e,localRowId:e,params:g})))))},e.ResultSortedTableInHtmlTable=({queryId:e,cellId:t,descending:a,offset:n,limit:o,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[c,h,g]=G(t,a,s,n,o,l.useResultRowCount(e,r),i,u);return b(K,{...m,params:L(J(l.useResultTableCellIds(e,r),d,l.ResultCellView),D(r,e),l.useResultSortedRowIds(e,...c,o,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...n})=>b(K,{...n,params:L(J(l.useResultTableCellIds(e,t),a,l.ResultCellView),D(t,e),l.useResultRowIds(e,t))}),e.SliceInHtmlTable=({indexId:e,sliceId:t,indexes:a,editable:n,customCells:o,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(l.useIndexesOrIndexesById(a),e);return b(K,{...r,params:L(J(l.useTableCellIds(d,i),o,n?Y:l.CellView),U(i,d),l.useSliceRowIds(e,t,s))})},e.SortedTableInHtmlTable=({tableId:e,cellId:t,descending:a,offset:n,limit:o,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...c})=>{const[h,g,p]=G(t,a,i,n,o,l.useRowCount(e,r),d,u);return b(K,{...c,params:L(J(l.useTableCellIds(e,r),m,s?Y:l.CellView),U(r,e),l.useSortedRowIds(e,...h,o,r),h,g,p)})},e.SortedTablePaginator=_,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:n,...o})=>b(K,{...o,params:L(J(l.useTableCellIds(e,t),n,a?Y:l.CellView),U(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:a=(t?Z:l.ValueView),getValueComponentProps:n,className:o,headerRow:r,idColumn:i})=>b("table",{className:o},!1===r?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,C(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(a,{...I(n,t),valueId:t,store:e})))))))},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.React,e.TinyBaseUiReact);
|
|
Binary file
|
package/lib/umd/ui-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u="Result",d="Ids",l="Table",n=l+"s",i=l+d,a="Row",I=a+"Count",c=a+d,C="Sorted"+a+d,p="Cell",b=p+d,w="Value",R=w+"s",k=w+d,g=e=>null==e,h=(e,s,t)=>g(e)?t?.():s(e),m=e=>t(e)==r,y=()=>{},L=(e,s)=>e.map(s),V=Object.keys,{createContext:S,useContext:T}=s,f=S([]),x=(e,s)=>{const t=T(f);return g(e)?t[s]:m(e)?((e,s)=>h(e,(e=>e[s])))(t[s+1],e):e},v=(e,s)=>{const t=x(e,s);return g(e)||m(e)?t:e},P=e=>V(T(f)[e]),q=e=>v(e,0),B=e=>v(e,2),M=e=>v(e,4),O=e=>v(e,6),Q=e=>v(e,8),D=e=>v(e,10),{useCallback:F,useEffect:A,useMemo:E,useRef:G,useState:j}=s,U=(e,s,t=[])=>{const o=E((()=>s(e)),[e,...t]);return A((()=>()=>o.destroy()),[o]),o},z=(e,s,t,o=[],r)=>{const[,u]=j(),d=F((()=>s?.["get"+e]?.(...o)??t),[s,...o]),[l]=j(d),n=G(l);return E((()=>n.current=d()),[d]),H(e,s,((...e)=>{n.current=g(r)?d():e[r],u([])}),[],o),n.current},H=(e,s,t,o=[],r=[],...u)=>A((()=>{const o=s?.["add"+e+"Listener"]?.(...r,t,...u);return()=>s?.delListener(o)}),[s,...r,...o,...u]),J=(e,s,t,o=[],r=y,u=[],...d)=>{const l=q(e);return F((e=>h(l,(o=>h(t(e,o),(e=>r(o["set"+s](...d,e),e)))))),[l,s,...o,...u,...d])},K=(e,s,t=y,o=[],...r)=>{const u=q(e);return F((()=>t(u?.["del"+s](...r))),[u,s,...o,...r])},N=(e,s,t)=>{const o=D(e);return F((()=>o?.[s](t)),[o,s,t])},W=e=>z(i,q(e),[],[]),X=(e,s)=>z(c,q(s),[],[e]),Y=(e,s,t,o=0,r,u)=>z(C,q(u),[],[e,s,t,o,r],6),Z=(e,s,t)=>z(b,q(t),[],[e,s]),$=(e,s,t,o)=>z(p,q(o),void 0,[e,s,t],4),_=e=>z(k,q(e),[],[]),ee=(e,s)=>z(w,q(s),void 0,[e]),se=(e,s)=>z("Metric",B(s),void 0,[e]),te=(e,s)=>z("SliceIds",M(s),[],[e]),oe=(e,s,t)=>z("Slice"+c,M(t),[],[e,s]),re=(e,s,t)=>z("RemoteRowId",O(t),void 0,[e,s]),ue=(e,s,t)=>z("Local"+c,O(t),[],[e,s]),de=(e,s,t)=>z("Linked"+c,O(t),[],[e,s]),le=(e,s)=>z(u+c,Q(s),[],[e]),ne=(e,s,t,o=0,r,d)=>z(u+C,Q(d),[],[e,s,t,o,r],6),ie=(e,s,t)=>z(u+b,Q(t),[],[e,s]),ae=(e,s,t,o)=>z(u+p,Q(o),void 0,[e,s,t]),Ie=e=>z("CheckpointIds",D(e),[[],void 0,[]]),ce=(e,s)=>z("Checkpoint",D(s),void 0,[e]),Ce=e=>N(e,"goBackward"),pe=e=>N(e,"goForward"),{createElement:be,Fragment:we,useCallback:Re,useLayoutEffect:ke,useRef:ge,useState:he}=s,me=(e,...s)=>g(e)?{}:e(...s),ye=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useMemo:Le}=s,Ve=({tableId:e,store:s,rowComponent:t=Pe,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:d},l)=>xe(L(l,(u=>be(t,{...me(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:d}))),u,d,e),Se=({queryId:e,queries:s,resultRowComponent:t=Qe,getResultRowComponentProps:o,separator:r,debugIds:u},d)=>xe(L(d,(r=>be(t,{...me(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),Te=({relationshipId:e,relationships:s,rowComponent:t=Pe,getRowComponentProps:o,separator:r,debugIds:u},d,l)=>{const[n,i,a]=ye(O(s),e),I=d(e,l,n);return xe(L(I,(e=>be(t,{...me(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:u}))),r,u,l)},fe=e=>({checkpoints:s,checkpointComponent:t=De,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const d=D(s);return xe(L(e(Ie(d)),(e=>be(t,{...me(o,e),key:e,checkpoints:d,checkpointId:e,debugIds:u}))),r)},xe=(e,s,t,o)=>{const r=g(s)||!Array.isArray(e)?e:L(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},ve=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>xe(o+($(e,s,t,r)??o),void 0,u,t),Pe=({tableId:e,rowId:s,store:t,cellComponent:o=ve,getCellComponentProps:r,customCellIds:u,separator:d,debugIds:l})=>xe(L(((e,s,t,o)=>{const r=Z(s,t,o);return e??r})(u,e,s,t),(u=>be(o,{...me(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:l}))),d,l,s),qe=e=>Ve(e,X(e.tableId,e.store)),Be=({valueId:e,store:s,debugIds:t})=>xe(o+(ee(e,s)??o),void 0,t,e),Me=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Pe,getRowComponentProps:r,separator:u,debugIds:d})=>{const[l,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(M(t),e),a=oe(e,s,l);return xe(L(a,(e=>be(o,{...me(r,e),key:e,tableId:i,rowId:e,store:n,debugIds:d}))),u,d,s)},Oe=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>xe(o+(ae(e,s,t,r)??o),void 0,u,t),Qe=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Oe,getResultCellComponentProps:r,separator:u,debugIds:d})=>xe(L(ie(e,s,t),(u=>be(o,{...me(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:d}))),u,d,s),De=({checkpoints:e,checkpointId:s,debugIds:t})=>xe(ce(s,e)??o,void 0,t,s),Fe=fe((e=>e[0])),Ae=fe((e=>g(e[1])?[]:[e[1]])),Ee=fe((e=>e[2]));e.BackwardCheckpointsView=Fe,e.CellView=ve,e.CheckpointView=De,e.CurrentCheckpointView=Ae,e.ForwardCheckpointsView=Ee,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Me,getSliceComponentProps:o,separator:r,debugIds:u})=>xe(L(te(e,s),(r=>be(t,{...me(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>Te(e,de,e.firstRowId),e.LocalRowsView=e=>Te(e,ue,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>xe(se(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:t,metrics:o,metricsById:r,indexes:u,indexesById:d,relationships:l,relationshipsById:n,queries:i,queriesById:a,checkpoints:I,checkpointsById:c,children:C})=>{const p=s.useContext(f);return be(f.Provider,{value:Le((()=>[e??p[0],{...p[1],...t},o??p[2],{...p[3],...r},u??p[4],{...p[5],...d},l??p[6],{...p[7],...n},i??p[8],{...p[9],...a},I??p[10],{...p[11],...c}]),[e,t,o,r,u,d,l,n,i,a,I,c,p])},C)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Pe,getRowComponentProps:r,debugIds:u})=>{const[d,l,,n]=ye(O(t),e),i=re(e,s,d);return xe(g(n)||g(i)?null:be(o,{...me(r,i),key:i,tableId:n,rowId:i,store:l,debugIds:u}),void 0,u,s)},e.ResultCellView=Oe,e.ResultRowView=Qe,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>Se(r,ne(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>Se(e,le(e.queryId,e.queries)),e.RowView=Pe,e.SliceView=Me,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>Ve(r,Y(r.tableId,e,s,t,o,r.store)),e.TableView=qe,e.TablesView=({store:e,tableComponent:s=qe,getTableComponentProps:t,separator:o,debugIds:r})=>xe(L(W(e),(o=>be(s,{...me(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=Be,e.ValuesView=({store:e,valueComponent:s=Be,getValueComponentProps:t,separator:o,debugIds:r})=>xe(L(_(e),(o=>be(s,{...me(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=[],o,r=y,u=[],d=!0)=>{const l=q(o);return F((t=>h(l,(o=>h(s(t,o),(s=>r(o.addRow(e,s,d),o,s)))))),[l,e,...t,...u,d])},e.useCell=$,e.useCellIds=Z,e.useCellIdsListener=(e,s,t,o,r,u)=>H(b,q(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,d)=>H(p,q(d),o,r,[e,s,t],u),e.useCheckpoint=ce,e.useCheckpointIds=Ie,e.useCheckpointIdsListener=(e,s,t)=>H("CheckpointIds",D(t),e,s),e.useCheckpointListener=(e,s,t,o)=>H("Checkpoint",D(o),s,t,[e]),e.useCheckpoints=e=>x(e,10),e.useCheckpointsIds=()=>P(11),e.useCheckpointsOrCheckpointsById=D,e.useCreateCheckpoints=(e,s,t)=>U(e,s,t),e.useCreateIndexes=(e,s,t)=>U(e,s,t),e.useCreateMetrics=(e,s,t)=>U(e,s,t),e.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,u]=j(),d=E((()=>s(e)),[e,...t]);return A((()=>((async()=>{await(o?.(d)),u(1)})(),()=>{d.destroy()})),[d,...r]),d},e.useCreateQueries=(e,s,t)=>U(e,s,t),e.useCreateRelationships=(e,s,t)=>U(e,s,t),e.useCreateStore=(e,s=[])=>E(e,s),e.useDelCellCallback=(e,s,t,o,r,u,d)=>K(r,p,u,d,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>K(t,a,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>K(s,l,t,o,e),e.useDelTablesCallback=(e,s,t)=>K(e,n,s,t),e.useDelValueCallback=(e,s,t,o)=>K(s,w,t,o,e),e.useDelValuesCallback=(e,s,t)=>K(e,R,s,t),e.useGoBackwardCallback=Ce,e.useGoForwardCallback=pe,e.useGoToCallback=(e,s=[],t,o=y,r=[])=>{const u=D(t);return F((s=>h(u,(t=>h(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useIndexIds=e=>z("IndexIds",M(e),[]),e.useIndexes=e=>x(e,4),e.useIndexesIds=()=>P(5),e.useIndexesOrIndexesById=M,e.useLinkedRowIds=de,e.useLinkedRowIdsListener=(e,s,t,o,r)=>H("Linked"+c,O(r),t,o,[e,s]),e.useLocalRowIds=ue,e.useLocalRowIdsListener=(e,s,t,o,r)=>H("Local"+c,O(r),t,o,[e,s]),e.useMetric=se,e.useMetricIds=e=>z("MetricIds",B(e),[]),e.useMetricListener=(e,s,t,o)=>H("Metric",B(o),s,t,[e]),e.useMetrics=e=>x(e,2),e.useMetricsIds=()=>P(3),e.useMetricsOrMetricsById=B,e.useQueries=e=>x(e,8),e.useQueriesIds=()=>P(9),e.useQueriesOrQueriesById=Q,e.useQueryIds=e=>z("QueryIds",Q(e),[]),e.useRedoInformation=e=>{const s=D(e),[,,[t]]=Ie(s);return[!g(t),pe(s),t,h(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>z("RelationshipIds",O(e),[]),e.useRelationships=e=>x(e,6),e.useRelationshipsIds=()=>P(7),e.useRelationshipsOrRelationshipsById=O,e.useRemoteRowId=re,e.useRemoteRowIdListener=(e,s,t,o,r)=>H("RemoteRowId",O(r),t,o,[e,s]),e.useResultCell=ae,e.useResultCellIds=ie,e.useResultCellIdsListener=(e,s,t,o,r)=>H(u+b,Q(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,d)=>H(u+p,Q(d),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>z(u+a,Q(t),{},[e,s]),e.useResultRowCount=(e,s)=>z(u+I,Q(s),[],[e]),e.useResultRowCountListener=(e,s,t,o)=>H(u+I,Q(o),s,t,[e]),e.useResultRowIds=le,e.useResultRowIdsListener=(e,s,t,o)=>H(u+c,Q(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>H(u+a,Q(r),t,o,[e,s]),e.useResultSortedRowIds=ne,e.useResultSortedRowIdsListener=(e,s,t,o,r,d,l,n)=>H(u+C,Q(n),d,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>z(u+l,Q(s),{},[e]),e.useResultTableCellIds=(e,s)=>z(u+l+b,Q(s),[],[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>H(u+l+b,Q(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>H(u+l,Q(o),s,t,[e]),e.useRow=(e,s,t)=>z(a,q(t),{},[e,s]),e.useRowCount=(e,s)=>z(I,q(s),[],[e]),e.useRowCountListener=(e,s,t,o,r)=>H(I,q(r),s,t,[e],o),e.useRowIds=X,e.useRowIdsListener=(e,s,t,o,r)=>H(c,q(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>H(a,q(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,d,l)=>J(u,p,o,r,d,l,e,s,t),e.useSetCheckpointCallback=(e=y,s=[],t,o=y,r=[])=>{const u=D(t);return F((s=>h(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,d)=>J(r,"PartialRow",t,o,u,d,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>J(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,d)=>J(r,a,t,o,u,d,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>J(o,l,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>J(t,n,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>J(o,w,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>J(t,R,e,s,o,r),e.useSliceIds=te,e.useSliceIdsListener=(e,s,t,o)=>H("SliceIds",M(o),s,t,[e]),e.useSliceRowIds=oe,e.useSliceRowIdsListener=(e,s,t,o,r)=>H("Slice"+c,M(r),t,o,[e,s]),e.useSortedRowIds=Y,e.useSortedRowIdsListener=(e,s,t,o,r,u,d,l,n)=>H(C,q(n),u,d,[e,s,t,o,r],l),e.useStore=e=>x(e,0),e.useStoreIds=()=>P(1),e.useStoreOrStoreById=q,e.useTable=(e,s)=>z(l,q(s),{},[e]),e.useTableCellIds=(e,s)=>z(l+b,q(s),[],[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>H(l+b,q(r),s,t,[e],o),e.useTableIds=W,e.useTableIdsListener=(e,s,t,o)=>H(i,q(o),e,s,[],t),e.useTableListener=(e,s,t,o,r)=>H(l,q(r),s,t,[e],o),e.useTables=e=>z(n,q(e),{}),e.useTablesListener=(e,s,t,o)=>H(n,q(o),e,s,[],t),e.useUndoInformation=e=>{const s=D(e),[t,r]=Ie(s);return[(u=t,!(0==(e=>e.length)(u))),Ce(s),r,h(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=ee,e.useValueIds=_,e.useValueIdsListener=(e,s,t,o)=>H(k,q(o),e,s,[],t),e.useValueListener=(e,s,t,o,r)=>H(w,q(r),s,t,[e],o),e.useValues=e=>z(R,q(e),{}),e.useValuesListener=(e,s,t,o)=>H(R,q(o),e,s,[],t)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
|
|
1
|
+
var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u="Result",d="Ids",l="Table",n=l+"s",i=l+d,a="Row",I=a+"Count",c=a+d,C="Sorted"+a+d,p="Cell",b=p+d,w="Value",R=w+"s",k=w+d,g=e=>null==e,h=(e,s,t)=>g(e)?t?.():s(e),m=e=>t(e)==r,y=()=>{},L=(e,s)=>e.map(s),V=Object.keys,{createContext:S,useContext:T}=s,f=S([]),x=(e,s)=>{const t=T(f);return g(e)?t[s]:m(e)?((e,s)=>h(e,(e=>e[s])))(t[s+1]??{},e):e},v=(e,s)=>{const t=x(e,s);return g(e)||m(e)?t:e},P=e=>V(T(f)[e]??{}),q=e=>v(e,0),B=e=>v(e,2),M=e=>v(e,4),O=e=>v(e,6),Q=e=>v(e,8),D=e=>v(e,10),{useCallback:F,useEffect:A,useMemo:E,useRef:G,useState:j}=s,U=(e,s,t=[])=>{const o=E((()=>s(e)),[e,...t]);return A((()=>()=>o.destroy()),[o]),o},z=(e,s,t,o=[],r)=>{const[,u]=j(),d=F((()=>s?.["get"+e]?.(...o)??t),[s,...o]),[l]=j(d),n=G(l);return E((()=>n.current=d()),[d]),H(e,s,((...e)=>{n.current=g(r)?d():e[r],u([])}),[],o),n.current},H=(e,s,t,o=[],r=[],...u)=>A((()=>{const o=s?.["add"+e+"Listener"]?.(...r,t,...u);return()=>s?.delListener(o)}),[s,...r,...o,...u]),J=(e,s,t,o=[],r=y,u=[],...d)=>{const l=q(e);return F((e=>h(l,(o=>h(t(e,o),(e=>r(o["set"+s](...d,e),e)))))),[l,s,...o,...u,...d])},K=(e,s,t=y,o=[],...r)=>{const u=q(e);return F((()=>t(u?.["del"+s](...r))),[u,s,...o,...r])},N=(e,s,t)=>{const o=D(e);return F((()=>o?.[s](t)),[o,s,t])},W=e=>z(i,q(e),[],[]),X=(e,s)=>z(c,q(s),[],[e]),Y=(e,s,t,o=0,r,u)=>z(C,q(u),[],[e,s,t,o,r],6),Z=(e,s,t)=>z(b,q(t),[],[e,s]),$=(e,s,t,o)=>z(p,q(o),void 0,[e,s,t],4),_=e=>z(k,q(e),[],[]),ee=(e,s)=>z(w,q(s),void 0,[e]),se=(e,s)=>z("Metric",B(s),void 0,[e]),te=(e,s)=>z("SliceIds",M(s),[],[e]),oe=(e,s,t)=>z("Slice"+c,M(t),[],[e,s]),re=(e,s,t)=>z("RemoteRowId",O(t),void 0,[e,s]),ue=(e,s,t)=>z("Local"+c,O(t),[],[e,s]),de=(e,s,t)=>z("Linked"+c,O(t),[],[e,s]),le=(e,s)=>z(u+c,Q(s),[],[e]),ne=(e,s,t,o=0,r,d)=>z(u+C,Q(d),[],[e,s,t,o,r],6),ie=(e,s,t)=>z(u+b,Q(t),[],[e,s]),ae=(e,s,t,o)=>z(u+p,Q(o),void 0,[e,s,t]),Ie=e=>z("CheckpointIds",D(e),[[],void 0,[]]),ce=(e,s)=>z("Checkpoint",D(s),void 0,[e]),Ce=e=>N(e,"goBackward"),pe=e=>N(e,"goForward"),{PureComponent:be,Fragment:we,createElement:Re,useCallback:ke,useLayoutEffect:ge,useRef:he,useState:me}=s,ye=(e,...s)=>g(e)?{}:e(...s),Le=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useMemo:Ve}=s,Se=({tableId:e,store:s,rowComponent:t=qe,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:d},l)=>ve(L(l,(u=>Re(t,{...ye(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:d}))),u,d,e),Te=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:r,debugIds:u},d)=>ve(L(d,(r=>Re(t,{...ye(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),fe=({relationshipId:e,relationships:s,rowComponent:t=qe,getRowComponentProps:o,separator:r,debugIds:u},d,l)=>{const[n,i,a]=Le(O(s),e),I=d(e,l,n);return ve(L(I,(e=>Re(t,{...ye(o,e),key:e,tableId:a,rowId:e,store:i,debugIds:u}))),r,u,l)},xe=e=>({checkpoints:s,checkpointComponent:t=Fe,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const d=D(s);return ve(L(e(Ie(d)),(e=>Re(t,{...ye(o,e),key:e,checkpoints:d,checkpointId:e,debugIds:u}))),r)},ve=(e,s,t,o)=>{const r=g(s)||!Array.isArray(e)?e:L(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},Pe=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ve(o+($(e,s,t,r)??o),void 0,u,t),qe=({tableId:e,rowId:s,store:t,cellComponent:o=Pe,getCellComponentProps:r,customCellIds:u,separator:d,debugIds:l})=>ve(L(((e,s,t,o)=>{const r=Z(s,t,o);return e??r})(u,e,s,t),(u=>Re(o,{...ye(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:l}))),d,l,s),Be=e=>Se(e,X(e.tableId,e.store)),Me=({valueId:e,store:s,debugIds:t})=>ve(o+(ee(e,s)??o),void 0,t,e),Oe=({indexId:e,sliceId:s,indexes:t,rowComponent:o=qe,getRowComponentProps:r,separator:u,debugIds:d})=>{const[l,n,i]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(M(t),e),a=oe(e,s,l);return ve(L(a,(e=>Re(o,{...ye(r,e),key:e,tableId:i,rowId:e,store:n,debugIds:d}))),u,d,s)},Qe=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ve(o+(ae(e,s,t,r)??o),void 0,u,t),De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Qe,getResultCellComponentProps:r,separator:u,debugIds:d})=>ve(L(ie(e,s,t),(u=>Re(o,{...ye(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:d}))),u,d,s),Fe=({checkpoints:e,checkpointId:s,debugIds:t})=>ve(ce(s,e)??o,void 0,t,s),Ae=xe((e=>e[0])),Ee=xe((e=>g(e[1])?[]:[e[1]])),Ge=xe((e=>e[2]));e.BackwardCheckpointsView=Ae,e.CellView=Pe,e.CheckpointView=Fe,e.CurrentCheckpointView=Ee,e.ForwardCheckpointsView=Ge,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Oe,getSliceComponentProps:o,separator:r,debugIds:u})=>ve(L(te(e,s),(r=>Re(t,{...ye(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>fe(e,de,e.firstRowId),e.LocalRowsView=e=>fe(e,ue,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ve(se(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:t,metrics:o,metricsById:r,indexes:u,indexesById:d,relationships:l,relationshipsById:n,queries:i,queriesById:a,checkpoints:I,checkpointsById:c,children:C})=>{const p=s.useContext(f);return Re(f.Provider,{value:Ve((()=>[e??p[0],{...p[1],...t},o??p[2],{...p[3],...r},u??p[4],{...p[5],...d},l??p[6],{...p[7],...n},i??p[8],{...p[9],...a},I??p[10],{...p[11],...c}]),[e,t,o,r,u,d,l,n,i,a,I,c,p])},C)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=qe,getRowComponentProps:r,debugIds:u})=>{const[d,l,,n]=Le(O(t),e),i=re(e,s,d);return ve(g(n)||g(i)?null:Re(o,{...ye(r,i),key:i,tableId:n,rowId:i,store:l,debugIds:u}),void 0,u,s)},e.ResultCellView=Qe,e.ResultRowView=De,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>Te(r,ne(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>Te(e,le(e.queryId,e.queries)),e.RowView=qe,e.SliceView=Oe,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>Se(r,Y(r.tableId,e,s,t,o,r.store)),e.TableView=Be,e.TablesView=({store:e,tableComponent:s=Be,getTableComponentProps:t,separator:o,debugIds:r})=>ve(L(W(e),(o=>Re(s,{...ye(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=Me,e.ValuesView=({store:e,valueComponent:s=Me,getValueComponentProps:t,separator:o,debugIds:r})=>ve(L(_(e),(o=>Re(s,{...ye(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=[],o,r=y,u=[],d=!0)=>{const l=q(o);return F((t=>h(l,(o=>h(s(t,o),(s=>r(o.addRow(e,s,d),o,s)))))),[l,e,...t,...u,d])},e.useCell=$,e.useCellIds=Z,e.useCellIdsListener=(e,s,t,o,r,u)=>H(b,q(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,d)=>H(p,q(d),o,r,[e,s,t],u),e.useCheckpoint=ce,e.useCheckpointIds=Ie,e.useCheckpointIdsListener=(e,s,t)=>H("CheckpointIds",D(t),e,s),e.useCheckpointListener=(e,s,t,o)=>H("Checkpoint",D(o),s,t,[e]),e.useCheckpoints=e=>x(e,10),e.useCheckpointsIds=()=>P(11),e.useCheckpointsOrCheckpointsById=D,e.useCreateCheckpoints=(e,s,t)=>U(e,s,t),e.useCreateIndexes=(e,s,t)=>U(e,s,t),e.useCreateMetrics=(e,s,t)=>U(e,s,t),e.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,u]=j(),d=E((()=>s(e)),[e,...t]);return A((()=>((async()=>{await(o?.(d)),u(1)})(),()=>{d.destroy()})),[d,...r]),d},e.useCreateQueries=(e,s,t)=>U(e,s,t),e.useCreateRelationships=(e,s,t)=>U(e,s,t),e.useCreateStore=(e,s=[])=>E(e,s),e.useDelCellCallback=(e,s,t,o,r,u,d)=>K(r,p,u,d,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>K(t,a,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>K(s,l,t,o,e),e.useDelTablesCallback=(e,s,t)=>K(e,n,s,t),e.useDelValueCallback=(e,s,t,o)=>K(s,w,t,o,e),e.useDelValuesCallback=(e,s,t)=>K(e,R,s,t),e.useGoBackwardCallback=Ce,e.useGoForwardCallback=pe,e.useGoToCallback=(e,s=[],t,o=y,r=[])=>{const u=D(t);return F((s=>h(u,(t=>h(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useIndexIds=e=>z("IndexIds",M(e),[]),e.useIndexes=e=>x(e,4),e.useIndexesIds=()=>P(5),e.useIndexesOrIndexesById=M,e.useLinkedRowIds=de,e.useLinkedRowIdsListener=(e,s,t,o,r)=>H("Linked"+c,O(r),t,o,[e,s]),e.useLocalRowIds=ue,e.useLocalRowIdsListener=(e,s,t,o,r)=>H("Local"+c,O(r),t,o,[e,s]),e.useMetric=se,e.useMetricIds=e=>z("MetricIds",B(e),[]),e.useMetricListener=(e,s,t,o)=>H("Metric",B(o),s,t,[e]),e.useMetrics=e=>x(e,2),e.useMetricsIds=()=>P(3),e.useMetricsOrMetricsById=B,e.useQueries=e=>x(e,8),e.useQueriesIds=()=>P(9),e.useQueriesOrQueriesById=Q,e.useQueryIds=e=>z("QueryIds",Q(e),[]),e.useRedoInformation=e=>{const s=D(e),[,,[t]]=Ie(s);return[!g(t),pe(s),t,h(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>z("RelationshipIds",O(e),[]),e.useRelationships=e=>x(e,6),e.useRelationshipsIds=()=>P(7),e.useRelationshipsOrRelationshipsById=O,e.useRemoteRowId=re,e.useRemoteRowIdListener=(e,s,t,o,r)=>H("RemoteRowId",O(r),t,o,[e,s]),e.useResultCell=ae,e.useResultCellIds=ie,e.useResultCellIdsListener=(e,s,t,o,r)=>H(u+b,Q(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,d)=>H(u+p,Q(d),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>z(u+a,Q(t),{},[e,s]),e.useResultRowCount=(e,s)=>z(u+I,Q(s),[],[e]),e.useResultRowCountListener=(e,s,t,o)=>H(u+I,Q(o),s,t,[e]),e.useResultRowIds=le,e.useResultRowIdsListener=(e,s,t,o)=>H(u+c,Q(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>H(u+a,Q(r),t,o,[e,s]),e.useResultSortedRowIds=ne,e.useResultSortedRowIdsListener=(e,s,t,o,r,d,l,n)=>H(u+C,Q(n),d,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>z(u+l,Q(s),{},[e]),e.useResultTableCellIds=(e,s)=>z(u+l+b,Q(s),[],[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>H(u+l+b,Q(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>H(u+l,Q(o),s,t,[e]),e.useRow=(e,s,t)=>z(a,q(t),{},[e,s]),e.useRowCount=(e,s)=>z(I,q(s),[],[e]),e.useRowCountListener=(e,s,t,o,r)=>H(I,q(r),s,t,[e],o),e.useRowIds=X,e.useRowIdsListener=(e,s,t,o,r)=>H(c,q(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>H(a,q(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,d,l)=>J(u,p,o,r,d,l,e,s,t),e.useSetCheckpointCallback=(e=y,s=[],t,o=y,r=[])=>{const u=D(t);return F((s=>h(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,d)=>J(r,"PartialRow",t,o,u,d,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>J(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,d)=>J(r,a,t,o,u,d,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>J(o,l,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>J(t,n,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>J(o,w,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>J(t,R,e,s,o,r),e.useSliceIds=te,e.useSliceIdsListener=(e,s,t,o)=>H("SliceIds",M(o),s,t,[e]),e.useSliceRowIds=oe,e.useSliceRowIdsListener=(e,s,t,o,r)=>H("Slice"+c,M(r),t,o,[e,s]),e.useSortedRowIds=Y,e.useSortedRowIdsListener=(e,s,t,o,r,u,d,l,n)=>H(C,q(n),u,d,[e,s,t,o,r],l),e.useStore=e=>x(e,0),e.useStoreIds=()=>P(1),e.useStoreOrStoreById=q,e.useTable=(e,s)=>z(l,q(s),{},[e]),e.useTableCellIds=(e,s)=>z(l+b,q(s),[],[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>H(l+b,q(r),s,t,[e],o),e.useTableIds=W,e.useTableIdsListener=(e,s,t,o)=>H(i,q(o),e,s,[],t),e.useTableListener=(e,s,t,o,r)=>H(l,q(r),s,t,[e],o),e.useTables=e=>z(n,q(e),{}),e.useTablesListener=(e,s,t,o)=>H(n,q(o),e,s,[],t),e.useUndoInformation=e=>{const s=D(e),[t,r]=Ie(s);return[(u=t,!(0==(e=>e.length)(u))),Ce(s),r,h(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=ee,e.useValueIds=_,e.useValueIdsListener=(e,s,t,o)=>H(k,q(o),e,s,[],t),e.useValueListener=(e,s,t,o,r)=>H(w,q(r),s,t,[e],o),e.useValues=e=>z(R,q(e),{}),e.useValuesListener=(e,s,t,o)=>H(R,q(o),e,s,[],t)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
|
package/lib/umd/ui-react.js.gz
CHANGED
|
Binary file
|