tinybase 4.3.9 → 4.3.11

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.
@@ -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,{PureComponent:c,Fragment:h,createElement:b,useCallback:g,useLayoutEffect:p,useRef:w,useState:f}=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="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=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])=>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,M=T+`<path d='${x}' />`+S,$=T+`<path d='${x}M20 20l60 60' />`+S,q="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(v({"*":"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,...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)":N,"header>img:nth-of-type(6)":z,...k(C(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":M,"details[open]>summary img.done":$,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,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?`& ${t}{${e}}`:"")));const B=(e,t,l,a)=>e==n?t:e==r?l:a,{useCallback:F,useMemo:H,useState:O}=t,E="editable",P=(e,t)=>C(l.useTableCellIds(e,t),(t=>e+"."+t)),j=(e,t,l)=>{const a=F(e,t);return l?a:void 0},D=(...e)=>H((()=>e),e),A=(e,t)=>H((()=>({store:e,tableId:t})),[e,t]),L=(e,t)=>H((()=>({queries:e,queryId:t})),[e,t]),U=(e,t=!1,l,a=0,n,o,r,s)=>{const[[i,d,u],m]=O([e,t,a]),c=F((e=>{m(e),s?.(e)}),[s]),h=j((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=F((e=>c([i,d,e])),[c,i,d]),p=!0===r?Z:r;return[[i,d,u],h,H((()=>!1===r?null:b(p,{offset:u,limit:n,total:o,onChange:g})),[r,p,u,n,o,g])]},G=(e,t,l)=>H((()=>{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]),J=({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(K,{sort:r??[],label:"Id",onClick:s}),v(a,(({label:e},t)=>b(K,{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}))))))))),K=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>b("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 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}))})))},W=({thing:e,onThingChange:t,className:l,hasSchema:s})=>{const[m,c]=O(),[h,g]=O(),[p,w]=O(),[f,I]=O(),[C,y]=O();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),w(e+""),I(Number(e)||0),y(!!e));const k=F(((e,l)=>{l(e),g(e),t(e)}),[t]);return b("div",{className:l},b("button",{className:m,onClick:F((()=>{if(!s?.()){const e=B(m,r,o,n),l=B(e,p,f,C);c(e),g(l),t(l)}}),[s,t,p,f,C,m])},m),B(m,b("input",{key:m,value:p,onChange:F((e=>k(e[i][d]+"",w)),[k])}),b("input",{key:m,type:"number",value:f,onChange:F((e=>k(Number(e[i][d]||0),I)),[k])}),b("input",{key:m,type:"checkbox",checked:C,onChange:F((e=>k(!!e[i].checked,y)),[k])})))},X=({tableId:e,rowId:t,cellId:a,store:n,className:o})=>b(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})=>b(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 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)};class _ extends c{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const ee=e=>new Map(e);ee(),ee(),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,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(a),e),h=G([...P(m,u),...P(c,u)],o,n?X:l.CellView),g=D(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(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[c,h,g]=U(t,a,s,n,o,l.useResultRowCount(e,r),i,u);return b(J,{...m,params:D(G(l.useResultTableCellIds(e,r),d,l.ResultCellView),L(r,e),l.useResultSortedRowIds(e,...c,o,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...n})=>b(J,{...n,params:D(G(l.useResultTableCellIds(e,t),a,l.ResultCellView),L(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(J,{...r,params:D(G(l.useTableCellIds(d,i),o,n?X:l.CellView),A(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]=U(t,a,i,n,o,l.useRowCount(e,r),d,u);return b(J,{...c,params:D(G(l.useTableCellIds(e,r),m,s?X:l.CellView),A(r,e),l.useSortedRowIds(e,...h,o,r),h,g,p)})},e.SortedTablePaginator=Z,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:n,...o})=>b(J,{...o,params:D(G(l.useTableCellIds(e,t),n,a?X:l.CellView),A(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})=>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);
1
+ var e,t;e=this,t=function(e,t,l){"use strict";const a=e=>typeof e,o=a(""),n=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:w,useState:f}=t,I=(e,...t)=>m(e)?{}:e(...t),y=(e,t)=>e.map(t),C=Object,k=(e=[])=>C.fromEntries(e),v=(e,t)=>y(C.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",T='content:url("',R=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'>",S='</svg>")',N=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\")",V=y([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>R+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+S)),z=R+"<path d='M20 20l60 60M20 80l60-60' />"+S,M=R+`<path d='${x}' />`+S,$=R+`<path d='${x}M20 20l60 60' />`+S,q="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(v({"*":"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,...k(y(["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(y(["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,...k(y(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":M,"details[open]>summary img.done":$,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,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?`& ${t}{${e}}`:"")));const B=(e,t,l,a)=>e==o?t:e==r?l:a,{useCallback:F,useMemo:H,useState:O}=t,E="editable",P=(e,t)=>y(l.useTableCellIds(e,t),(t=>e+"."+t)),j=(e,t,l)=>{const a=F(e,t);return l?a:void 0},D=(...e)=>H((()=>e),e),A=(e,t)=>H((()=>({store:e,tableId:t})),[e,t]),L=(e,t)=>H((()=>({queries:e,queryId:t})),[e,t]),U=(e,t=!1,l,a=0,o,n,r,s)=>{const[[i,d,u],m]=O([e,t,a]),c=F((e=>{m(e),s?.(e)}),[s]),h=j((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=F((e=>c([i,d,e])),[c,i,d]),p=!0===r?Z:r;return[[i,d,u],h,H((()=>!1===r?null:b(p,{offset:u,limit:o,total:n,onChange:g})),[r,p,u,o,n,g])]},G=(e,t,l)=>H((()=>{const n=t??e;return k(v(Array.isArray(n)?k(y(n,(e=>[e,e]))):n,((e,t)=>{return[t,{label:t,component:l,...(n=e,a(n)==o?{label:e}:e)}];var n})))}),[t,l,e]),J=({className:e,headerRow:t,idColumn:l,params:[a,o,n,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(K,{sort:r??[],label:"Id",onClick:s}),v(a,(({label:e},t)=>b(K,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),b("tbody",null,y(n,(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),...o,rowId:e,cellId:a}))))))))),K=({cellId:e,sort:[t,l],label:a=e??"",onClick:o})=>b("th",{onClick:j((()=>o?.(e)),[o,e],o),className:m(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},m(l)||t!=e?null:(l?"↓":"↑")+" ",a),Q=({localRowId:e,params:[a,o,n,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(o,(({component:t,getComponentProps:l},a)=>{const[o,s]=a.split(".",2),i=o===n?e:o===r?u:null;return m(i)?null:b("td",{key:a},b(t,{...I(l,i,s),store:d,tableId:o,rowId:i,cellId:s}))})))},W=({thing:e,onThingChange:t,className:l,hasSchema:s,showType:m=!0})=>{const[c,h]=O(),[g,p]=O(),[w,f]=O(),[I,y]=O(),[C,k]=O();g!==e&&(h((e=>{const t=a(e);return(e=>e==o||e==n)(t)||t==r&&u(e)?t:void 0})(e)),p(e),f(e+""),y(Number(e)||0),k(!!e));const v=F(((e,l)=>{l(e),p(e),t(e)}),[t]),x=F((()=>{if(!s?.()){const e=B(c,r,n,o),l=B(e,w,I,C);h(e),p(l),t(l)}}),[s,t,w,I,C,c]);return b("div",{className:l},m?b("button",{className:c,onClick:x},c):null,B(c,b("input",{key:c,value:w,onChange:F((e=>v(e[i][d]+"",f)),[v])}),b("input",{key:c,type:"number",value:I,onChange:F((e=>v(Number(e[i][d]||0),y)),[v])}),b("input",{key:c,type:"checkbox",checked:C,onChange:F((e=>v(!!e[i].checked,k)),[v])})))},X=({tableId:e,rowId:t,cellId:a,store:o,className:n,showType:r})=>b(W,{thing:l.useCell(e,t,a,o),onThingChange:l.useSetCellCallback(e,t,a,(e=>e),[],o),className:n??E+"Cell",showType:r,hasSchema:l.useStoreOrStoreById(o)?.hasTablesSchema}),Y=({valueId:e,store:t,className:a,showType:o})=>b(W,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:a??E+s,showType:o,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),Z=({onChange:e,total:l,offset:a=0,limit:o=l,singular:n="row",plural:r=n+"s"})=>{(a>l||a<0)&&(a=0,e(0));const s=j((()=>e(a-o)),[e,a,o],a>0),i=j((()=>e(a+o)),[e,a,o],a+o<l);return b(t.Fragment,null,l>o&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==a,onClick:s},"←"),b("button",{className:"next",disabled:a+o>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+o)," of "),l," ",1!=l?r:n)};class _ extends c{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const ee=e=>new Map(e);ee(),ee(),e.EditableCellView=X,e.EditableValueView=Y,e.RelationshipInHtmlTable=({relationshipId:e,relationships:a,editable:o,customCells:n,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=G([...P(m,u),...P(c,u)],n,o?X:l.CellView),g=D(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,y(l.useRowIds(m,u),(e=>b(Q,{key:e,localRowId:e,params:g})))))},e.ResultSortedTableInHtmlTable=({queryId:e,cellId:t,descending:a,offset:o,limit:n,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[c,h,g]=U(t,a,s,o,n,l.useResultRowCount(e,r),i,u);return b(J,{...m,params:D(G(l.useResultTableCellIds(e,r),d,l.ResultCellView),L(r,e),l.useResultSortedRowIds(e,...c,n,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...o})=>b(J,{...o,params:D(G(l.useResultTableCellIds(e,t),a,l.ResultCellView),L(t,e),l.useResultRowIds(e,t))}),e.SliceInHtmlTable=({indexId:e,sliceId:t,indexes:a,editable:o,customCells:n,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(l.useIndexesOrIndexesById(a),e);return b(J,{...r,params:D(G(l.useTableCellIds(d,i),n,o?X:l.CellView),A(i,d),l.useSliceRowIds(e,t,s))})},e.SortedTableInHtmlTable=({tableId:e,cellId:t,descending:a,offset:o,limit:n,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...c})=>{const[h,g,p]=U(t,a,i,o,n,l.useRowCount(e,r),d,u);return b(J,{...c,params:D(G(l.useTableCellIds(e,r),m,s?X:l.CellView),A(r,e),l.useSortedRowIds(e,...h,n,r),h,g,p)})},e.SortedTablePaginator=Z,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:o,...n})=>b(J,{...n,params:D(G(l.useTableCellIds(e,t),o,a?X:l.CellView),A(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:a=(t?Y:l.ValueView),getValueComponentProps:o,className:n,headerRow:r,idColumn:i})=>b("table",{className:n},!1===r?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,y(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(a,{...I(o,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
@@ -1 +1 @@
1
- var e,l;e=this,l=function(e,l,t){"use strict";const n=e=>typeof e,s="",r=n(s),a=n(!0),o=n(0),i=n(n),u="type",d="default",c="Ids",h="Table",m=h+"s",b=h+c,p="Row",g=p+"Count",v=p+c,f="Cell",I=f+c,y="Value",w=y+"s",C=y+c,k="currentTarget",x="value",S=e=>s+e,T=Math.floor,V=isFinite,R=(e,l)=>e instanceof l,O=e=>null==e,q=(e,l,t)=>O(e)?null==t?void 0:t():l(e),P=e=>e==r||e==a,N=e=>n(e)==i,E=e=>Array.isArray(e),L=(e,l,t)=>e.slice(l,t),M=e=>e.length,{PureComponent:j,Fragment:z,createElement:$,useCallback:A,useLayoutEffect:F,useRef:J,useState:D}=l,B=(e,...l)=>O(e)?{}:e(...l),H=(e,l)=>e.forEach(l),Q=(e,l)=>e.map(l),W=e=>0==M(e),U=(e,...l)=>e.push(...l),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),le=(e,l)=>!O(((e,l)=>q(e,(e=>e[l])))(e,l)),te=(e,l)=>(delete e[l],e),ne=(e,l)=>Q(K.entries(e),(([e,t])=>l(t,e))),se=e=>_(e)&&0==(e=>M(X(e)))(e),re=e=>JSON.stringify(e,((e,l)=>R(l,Map)?K.fromEntries([...l]):l)),ae=JSON.parse,oe="tinybaseStoreInspector",ie="TinyBase Store Inspector",ue=["left","top","bottom","right","full"],de="state",ce="sort",he="open",me="position",be=he,pe="editable",ge=(...e)=>re(e),ve=(e,l)=>Q(e.sort(),l),fe=(e,l)=>[!!t.useCell(de,e,pe,l),A((t=>{l.setCell(de,e,pe,(e=>!e)),t.preventDefault()}),[l,e])],Ie="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',we=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'>",Ce='</svg>")',ke=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\")",xe=Q([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,l,t,n])=>we+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${l}' width='${t}' height='${n}' fill='white'/>`+Ce)),Se=we+"<path d='M20 20l60 60M20 80l60-60' />"+Ce,Te=we+`<path d='${Ie}' />`+Ce,Ve=we+`<path d='${Ie}M20 20l60 60' />`+Ce;var Re=Object.defineProperty,Oe=Object.defineProperties,qe=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Ne=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Le=(e,l,t)=>l in e?Re(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Me=(e,l)=>{for(var t in l||(l={}))Ne.call(l,t)&&Le(e,t,l[t]);if(Pe)for(var t of Pe(l))Ee.call(l,t)&&Le(e,t,l[t]);return e},je=(e,l)=>Oe(e,qe(l));const ze="*::-webkit-scrollbar",$e=`#${oe}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,l="")=>e.join(l))(ne(je(Me(je(Me(je(Me({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[ze]:"width:0.5rem;height:0.5rem;",[ze+"-track"]:"background:#111",[ze+"-thumb"]:"background:#999;border:1px solid #111",[ze+"-thumb:hover"]:"background:#fff",[ze+"-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;"+ke},ee(Q(["bottom:0;left:0","top:0;right:0"],((e,l)=>[`>img[data-position='${l}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),ee(Q(["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,l)=>[`main[data-position='${l}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ke,"header>img:nth-of-type(6)":Se}),ee(Q(xe,((e,l)=>[`header>img[data-id='${l}']`,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":Te,"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,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,l)=>e?`& ${l}{${e}}`:"")))}`,Ae=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1,s=t.useSetValueCallback(be,(()=>!0),[],e);return t.useValue(be,e)?null:$("img",{onClick:s,title:ie,"data-position":n})},Fe=({uniqueId:e,summary:l,editable:n,handleEditable:s,children:r,s:a})=>{const o=!!t.useCell(de,e,he,a),i=t.useSetCellCallback(de,e,he,(e=>e[k].open),[],a);return $("details",{open:o,onToggle:i},$("summary",null,l,s?$("img",{onClick:s,className:n?"done":"edit"}):null),r)},Je=e=>{const l=n(e);return P(l)||l==o&&V(e)?l:void 0},De=(e,l,t,n,s)=>O(s)?e.delCell(l,t,n,!0):e.setCell(l,t,n,s),Be=(e,l,t)=>O(t)?e.delValue(l):e.setValue(l,t),He=(e,l,t,n)=>e==r?l:e==o?t:n;var Qe=Object.defineProperty,We=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,Ye=(e,l,t)=>l in e?Qe(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Ze=(e,l)=>{for(var t in l||(l={}))Ke.call(l,t)&&Ye(e,t,l[t]);if(Ge)for(var t of Ge(l))Xe.call(l,t)&&Ye(e,t,l[t]);return e},_e=(e,l)=>We(e,Ue(l)),el=(e,l)=>{var t={};for(var n in e)Ke.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&Ge)for(var n of Ge(e))l.indexOf(n)<0&&Xe.call(e,n)&&(t[n]=e[n]);return t};const{useCallback:ll,useMemo:tl,useState:nl}=l,sl="editable",rl=(e,l)=>Q(t.useTableCellIds(e,l),(l=>e+"."+l)),al=(e,l,t)=>{const n=ll(e,l);return t?n:void 0},ol=(...e)=>tl((()=>e),e),il=(e,l)=>tl((()=>({store:e,tableId:l})),[e,l]),ul=(e,l)=>tl((()=>({queries:e,queryId:l})),[e,l]),dl=(e,l=!1,t,n=0,s,r,a,o)=>{const[[i,u,d],c]=nl([e,l,n]),h=ll((e=>{c(e),null==o||o(e)}),[o]),m=al((e=>h([e,e==i&&!u,d])),[h,i,u,d],t),b=ll((e=>h([i,u,e])),[h,i,u]),p=!0===a?kl:a;return[[i,u,d],m,tl((()=>!1===a?null:$(p,{offset:d,limit:s,total:r,onChange:b})),[a,p,d,s,r,b])]},cl=(e,l,t)=>tl((()=>{const s=null!=l?l:e;return ee(ne(E(s)?ee(Q(s,(e=>[e,e]))):s,((e,l)=>{return[l,Ze(Ze({},{label:l,component:t}),(s=e,n(s)==r?{label:e}:e))];var s})))}),[l,t,e]),hl=({className:e,headerRow:l,idColumn:t,params:[n,s,r,a,o,i]})=>$("table",{className:e},i?$("caption",null,i):null,!1===l?null:$("thead",null,$("tr",null,!1===t?null:$(ml,{sort:null!=a?a:[],label:"Id",onClick:o}),ne(n,(({label:e},l)=>$(ml,{key:l,cellId:l,label:e,sort:null!=a?a:[],onClick:o}))))),$("tbody",null,Q(r,(e=>$("tr",{key:e},!1===t?null:$("th",null,e),ne(n,(({component:l,getComponentProps:t},n)=>$("td",{key:n},$(l,_e(Ze(Ze({},B(t,e,n)),s),{rowId:e,cellId:n})))))))))),ml=({cellId:e,sort:[l,t],label:n=(null!=e?e:s),onClick:r})=>$("th",{onClick:al((()=>null==r?void 0:r(e)),[r,e],r),className:O(t)||l!=e?void 0:`sorted ${t?"de":"a"}scending`},O(t)||l!=e?null:(t?"↓":"↑")+" ",n),bl=({localRowId:e,params:[n,s,r,a,o,i,u]})=>{const d=t.useRemoteRowId(o,e,i);return $("tr",null,!1===n?null:$(l.Fragment,null,$("th",null,e),$("th",null,d)),ne(s,(({component:l,getComponentProps:t},n)=>{const[s,o]=n.split(".",2),i=s===r?e:s===a?d:null;return O(i)?null:$("td",{key:n},$(l,_e(Ze({},B(t,i,o)),{store:u,tableId:s,rowId:i,cellId:o})))})))},pl=({thing:e,onThingChange:l,className:t,hasSchema:n})=>{const[s,i]=nl(),[u,d]=nl(),[c,h]=nl(),[m,b]=nl(),[p,g]=nl();u!==e&&(i(Je(e)),d(e),h(e+""),b(Number(e)||0),g(!!e));const v=ll(((e,t)=>{t(e),d(e),l(e)}),[l]);return $("div",{className:t},$("button",{className:s,onClick:ll((()=>{if(!(null==n?void 0:n())){const e=He(s,o,a,r),t=He(e,c,m,p);i(e),d(t),l(t)}}),[n,l,c,m,p,s])},s),He(s,$("input",{key:s,value:c,onChange:ll((e=>v(e[k][x]+"",h)),[v])}),$("input",{key:s,type:"number",value:m,onChange:ll((e=>v(Number(e[k][x]||0),b)),[v])}),$("input",{key:s,type:"checkbox",checked:p,onChange:ll((e=>v(!!e[k].checked,g)),[v])})))},gl=e=>{var l=e,{tableId:n,cellId:s,descending:r,offset:a,limit:o,store:i,editable:u,sortOnClick:d,paginator:c=!1,onChange:h,customCells:m}=l,b=el(l,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[p,g,v]=dl(s,r,d,a,o,t.useRowCount(n,i),c,h);return $(hl,_e(Ze({},b),{params:ol(cl(t.useTableCellIds(n,i),m,u?wl:t.CellView),il(i,n),t.useSortedRowIds(n,...p,o,i),p,g,v)}))},vl=({store:e,editable:l=!1,valueComponent:n=(l?Cl:t.ValueView),getValueComponentProps:s,className:r,headerRow:a,idColumn:o})=>$("table",{className:r},!1===a?null:$("thead",null,$("tr",null,!1===o?null:$("th",null,"Id"),$("th",null,y))),$("tbody",null,Q(t.useValueIds(e),(l=>$("tr",{key:l},!1===o?null:$("th",null,l),$("td",null,$(n,_e(Ze({},B(s,l)),{valueId:l,store:e})))))))),fl=e=>{var l=e,{indexId:n,sliceId:s,indexes:r,editable:a,customCells:o}=l,i=el(l,["indexId","sliceId","indexes","editable","customCells"]);const[u,d,c]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(l)])(t.useIndexesOrIndexesById(r),n);return $(hl,_e(Ze({},i),{params:ol(cl(t.useTableCellIds(c,d),o,a?wl:t.CellView),il(d,c),t.useSliceRowIds(n,s,u))}))},Il=({relationshipId:e,relationships:n,editable:s,customCells:r,className:a,headerRow:o,idColumn:i=!0})=>{const[u,d,c,h]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(l),null==e?void 0:e.getRemoteTableId(l)])(t.useRelationshipsOrRelationshipsById(n),e),m=cl([...rl(c,d),...rl(h,d)],r,s?wl:t.CellView),b=ol(i,m,c,h,e,u,d);return $("table",{className:a},!1===o?null:$("thead",null,$("tr",null,!1===i?null:$(l.Fragment,null,$("th",null,c,".Id"),$("th",null,h,".Id")),ne(m,(({label:e},l)=>$("th",{key:l},e))))),$("tbody",null,Q(t.useRowIds(c,d),(e=>$(bl,{key:e,localRowId:e,params:b})))))},yl=e=>{var l=e,{queryId:n,cellId:s,descending:r,offset:a,limit:o,queries:i,sortOnClick:u,paginator:d=!1,customCells:c,onChange:h}=l,m=el(l,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[b,p,g]=dl(s,r,u,a,o,t.useResultRowCount(n,i),d,h);return $(hl,_e(Ze({},m),{params:ol(cl(t.useResultTableCellIds(n,i),c,t.ResultCellView),ul(i,n),t.useResultSortedRowIds(n,...b,o,i),b,p,g)}))},wl=({tableId:e,rowId:l,cellId:n,store:s,className:r})=>{var a;return $(pl,{thing:t.useCell(e,l,n,s),onThingChange:t.useSetCellCallback(e,l,n,(e=>e),[],s),className:null!=r?r:sl+f,hasSchema:null==(a=t.useStoreOrStoreById(s))?void 0:a.hasTablesSchema})},Cl=({valueId:e,store:l,className:n})=>{var s;return $(pl,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:null!=n?n:sl+y,hasSchema:null==(s=t.useStoreOrStoreById(l))?void 0:s.hasValuesSchema})},kl=({onChange:e,total:t,offset:n=0,limit:s=t,singular:r="row",plural:a=r+"s"})=>{(n>t||n<0)&&(n=0,e(0));const o=al((()=>e(n-s)),[e,n,s],n>0),i=al((()=>e(n+s)),[e,n,s],n+s<t);return $(l.Fragment,null,t>s&&$(l.Fragment,null,$("button",{className:"previous",disabled:0==n,onClick:o},"←"),$("button",{className:"next",disabled:n+s>=t,onClick:i},"→"),n+1," to ",Math.min(t,n+s)," of "),t," ",1!=t?a:r)},xl=({indexes:e,indexesId:l,indexId:n,s:s})=>$(Fe,{uniqueId:ge("i",l,n),summary:"Index: "+n,s:s},Q(t.useSliceIds(n,e),(t=>$(Sl,{indexes:e,indexesId:l,indexId:n,sliceId:t,s:s,key:t})))),Sl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=ge("i",l,t,n),[a,o]=fe(r,s);return $(Fe,{uniqueId:r,summary:"Slice: "+n,editable:a,handleEditable:o,s:s},$(fl,{sliceId:n,indexId:t,indexes:e,editable:a}))},Tl=({indexesId:e,s:l})=>{const n=t.useIndexes(e),s=t.useIndexIds(n);return O(n)?null:$(Fe,{uniqueId:ge("i",e),summary:"Indexes: "+(null!=e?e:d),s:l},W(s)?"No indexes defined":ve(s,(t=>$(xl,{indexes:n,indexesId:e,indexId:t,s:l,key:t}))))},Vl=({metrics:e,metricId:l})=>$("tr",null,$("th",null,l),$("td",null,null==e?void 0:e.getTableId(l)),$("td",null,t.useMetric(l,e))),Rl=({metricsId:e,s:l})=>{const n=t.useMetrics(e),s=t.useMetricIds(n);return O(n)?null:$(Fe,{uniqueId:ge("m",e),summary:"Metrics: "+(null!=e?e:d),s:l},W(s)?"No metrics defined":$("table",null,$("thead",null,$("th",null,"Metric Id"),$("th",null,"Table Id"),$("th",null,"Metric")),$("tbody",null,Q(s,(e=>$(Vl,{metrics:n,metricId:e,key:e}))))))},Ol=({queries:e,queriesId:l,queryId:n,s:s})=>{var r;const a=ge("q",l,n),[o,i,u]=ae(null!=(r=t.useCell(de,a,ce,s))?r:"[]"),d=t.useSetCellCallback(de,a,ce,re,[],s);return $(Fe,{uniqueId:a,summary:"Query: "+n,s:s},$(yl,{queryId:n,queries:e,cellId:o,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ql=({queriesId:e,s:l})=>{const n=t.useQueries(e),s=t.useQueryIds(n);return O(n)?null:$(Fe,{uniqueId:ge("q",e),summary:"Queries: "+(null!=e?e:d),s:l},W(s)?"No queries defined":ve(s,(t=>$(Ol,{queries:n,queriesId:e,queryId:t,s:l,key:t}))))},Pl=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=ge("r",l,t),[r,a]=fe(s,n);return $(Fe,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:a,s:n},$(Il,{relationshipId:t,relationships:e,editable:r}))},Nl=({relationshipsId:e,s:l})=>{const n=t.useRelationships(e),s=t.useRelationshipIds(n);return O(n)?null:$(Fe,{uniqueId:ge("r",e),summary:"Relationships: "+(null!=e?e:d),s:l},W(s)?"No relationships defined":ve(s,(t=>$(Pl,{relationships:n,relationshipsId:e,relationshipId:t,s:l,key:t}))))},El=({tableId:e,store:l,storeId:n,s:s})=>{var r;const a=ge("t",n,e),[o,i,u]=ae(null!=(r=t.useCell(de,a,ce,s))?r:"[]"),d=t.useSetCellCallback(de,a,ce,re,[],s),[c,m]=fe(a,s);return $(Fe,{uniqueId:a,summary:h+": "+e,editable:c,handleEditable:m,s:s},$(gl,{tableId:e,store:l,cellId:o,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:c}))},Ll=({store:e,storeId:l,s:n})=>{const s=ge("v",l),[r,a]=fe(s,n);return W(t.useValueIds(e))?null:$(Fe,{uniqueId:s,summary:w,editable:r,handleEditable:a,s:n},$(vl,{store:e,editable:r}))},Ml=({storeId:e,s:l})=>{const n=t.useStore(e),s=t.useTableIds(n);return O(n)?null:$(Fe,{uniqueId:ge("s",e),summary:"Store: "+(null!=e?e:d),s:l},$(Ll,{storeId:e,store:n,s:l}),ve(s,(t=>$(El,{store:n,storeId:e,tableId:t,s:l,key:t}))))},jl=({s:e})=>{const l=J(null),n=J(0),[s,r]=D(!1),{scrollLeft:a,scrollTop:o}=t.useValues(e);F((()=>{const e=l.current;if(e&&!s){const l=new MutationObserver((()=>{e.scrollWidth>=T(a)+e.clientWidth&&e.scrollHeight>=T(o)+e.clientHeight&&e.scrollTo(a,o)}));return l.observe(e,{childList:!0,subtree:!0}),()=>l.disconnect()}}),[s,a,o]);const i=A((l=>{const{scrollLeft:t,scrollTop:s}=l[k];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{r(!0),e.setPartialValues({scrollLeft:t,scrollTop:s})}))}),[e]),u=t.useStore(),d=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),b=t.useIndexesIds(),p=t.useRelationships(),g=t.useRelationshipsIds(),v=t.useQueries(),f=t.useQueriesIds();return O(u)&&W(d)&&O(c)&&W(h)&&O(m)&&W(b)&&O(p)&&W(g)&&O(v)&&W(f)?$("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):$("article",{ref:l,onScroll:i},$(Ml,{s:e}),Q(d,(l=>$(Ml,{storeId:l,s:e,key:l}))),$(Rl,{s:e}),Q(h,(l=>$(Rl,{metricsId:l,s:e,key:l}))),$(Tl,{s:e}),Q(b,(l=>$(Tl,{indexesId:l,s:e,key:l}))),$(Nl,{s:e}),Q(g,(l=>$(Nl,{relationshipsId:l,s:e,key:l}))),$(ql,{s:e}),Q(f,(l=>$(ql,{queriesId:l,s:e,key:l}))))};class zl extends j{constructor(e){super(e),this.componentDidCatch=(e,l)=>console.error(e,l.componentStack),this.state={e:0}}render(){return this.state.e?$("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}zl.getDerivedStateFromError=()=>({e:1});const $l=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1,s=t.useSetValueCallback(be,(()=>!1),[],e),r=t.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return $("header",null,$("img",{title:ie}),$("span",null,ie),Q(ue,((e,l)=>l==n?null:$("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),$("img",{onClick:s,title:"Close"}))},Al=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1;return t.useValue(be,e)?$("main",{"data-position":n},$($l,{s:e}),$(zl,null,$(jl,{s:e}))):null},Fl=e=>l=>{return t=(l,t)=>l+e(t),Ul(l).reduce(t,0);var t},Jl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Dl=Fl(Jl),Bl=Fl(Dl),Hl=Fl(Bl),Ql=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Wl=e=>O(e)||0==Jl(e),Ul=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Gl=e=>e.clear(),Kl=(e,l)=>null==e?void 0:e.forEach(l),Xl=(e,l)=>null==e?void 0:e.delete(l),Yl=e=>new Map(e),Zl=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},_l=(e,l)=>null==e?void 0:e.get(l),et=(e,l)=>Kl(e,((e,t)=>l(t,e))),lt=(e,l,t)=>O(t)?(Xl(e,l),e):null==e?void 0:e.set(l,t),tt=(e,l,t)=>(Ql(e,l)||lt(e,l,t()),_l(e,l)),nt=(e,l,t,n=lt)=>(ne(l,((l,n)=>t(e,n,l))),et(e,(t=>le(l,t)?0:n(e,t))),e),st=(e,l,t)=>{const n={};return Kl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},rt=(e,l,t)=>st(e,(e=>st(e,l,t)),se),at=(e,l,t)=>st(e,(e=>rt(e,l,t)),se),ot=(e,l)=>{const t=Yl();return Kl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},it=e=>ot(e,ot),ut=e=>ot(e,it),dt=(e,l,t,n,s=0)=>q((t?tt:_l)(e,l[s],s>M(l)-2?t:Yl),(r=>{if(s>M(l)-2)return(null==n?void 0:n(r))&&lt(e,l[s]),r;const a=dt(r,l,t,n,s+1);return Wl(r)&&lt(e,l[s]),a}));var ct=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{o(t.next(e))}catch(e){s(e)}},a=e=>{try{o(t.throw(e))}catch(e){s(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);o((t=t.apply(e,l)).next())}));const ht=Yl(),mt=Yl();var bt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{o(t.next(e))}catch(e){s(e)}},a=e=>{try{o(t.throw(e))}catch(e){s(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);o((t=t.apply(e,l)).next())}));const pt="storage",gt=globalThis.window,vt=e=>new Set(E(e)||O(e)?e:[e]),ft=(e,l)=>null==e?void 0:e.add(l),It=/^\d+$/,yt=()=>{const e=[];let l=0;return[t=>{var n;return null!=(n=t?G(e):null)?n:s+l++},l=>{It.test(l)&&M(e)<1e3&&U(e,l)}]},wt=e=>[e,e],Ct=(e,l=Dl)=>l(e[0])+l(e[1]),kt=()=>[Yl(),Yl()],xt=e=>[...e],St=([e,l])=>e===l,Tt=(e,l,t)=>O(e)||!_(e)||se(e)||Y(e)?(null==t||t(),!1):(ne(e,((t,n)=>{l(t,n)||te(e,n)})),!se(e)),Vt=(e,l,t)=>lt(e,l,_l(e,l)==-t?void 0:t),Rt=()=>{let e,l,t=!1,n=!1,r=0;const a=Yl(),i=Yl(),c=Yl(),k=Yl(),x=Yl(),T=Yl(),V=Yl(),R=Yl(),E=Yl(),j=Yl(),z=Yl(),$=Yl(),A=Yl(),F=Yl(),J=vt(),D=Yl(),B=Yl(),W=Yl(),G=Yl(),K=kt(),X=kt(),Y=kt(),_=kt(),ee=kt(),oe=kt(),ie=kt(),ue=kt(),de=kt(),ce=kt(),he=kt(),me=kt(),be=kt(),pe=kt(),ge=kt(),ve=Yl(),fe=kt(),[Ie,ye,we,Ce]=(e=>{let l;const[t,n]=yt(),r=Yl();return[(e,n,a,o=[],i=(()=>[]))=>{null!=l||(l=Al);const u=t(1);return lt(r,u,[e,n,a,o,i]),ft(dt(n,null!=a?a:[s],vt),u),u},(e,t,...n)=>H(((e,l=[s])=>{const t=[],n=(e,s)=>s==M(l)?U(t,e):null===l[s]?Kl(e,(e=>n(e,s+1))):H([l[s],null],(l=>n(_l(e,l),s+1)));return n(e,0),t})(e,t),(e=>Kl(e,(e=>_l(r,e)[0](l,...null!=t?t:[],...n))))),e=>q(_l(r,e),(([,l,t])=>(dt(l,null!=t?t:[s],void 0,(l=>(Xl(l,e),Wl(l)?1:0))),lt(r,e),n(e),t))),e=>q(_l(r,e),(([e,,t=[],n,s])=>{const r=(...a)=>{var o,i;const u=M(a);u==M(t)?e(l,...a,...s(a)):O(t[u])?H(null!=(i=null==(o=n[u])?void 0:o.call(n,...a))?i:[],(e=>r(...a,e))):r(...a,t[u])};r()}))]})(),ke=e=>{if(!Tt(e,((e,l)=>[u,d].includes(l))))return!1;const l=e[u];return!(!P(l)&&l!=o||(Je(e[d])!=l&&te(e,d),0))},xe=(l,t)=>(!e||Ql(z,t)||nl(t))&&Tt(l,((e,l)=>Se(t,l,e)),(()=>nl(t))),Se=(e,l,t,n)=>Tt(n?t:Oe(t,e,l),((n,s)=>q(Te(e,l,s,n),(e=>(t[s]=e,!0)),(()=>!1))),(()=>nl(e,l))),Te=(l,t,n,s)=>e?q(_l(_l(z,l),n),(e=>Je(s)!=e[u]?nl(l,t,n,s,e[d]):s),(()=>nl(l,t,n,s))):O(Je(s))?nl(l,t,n,s):s,Ve=(e,l)=>Tt(l?e:qe(e),((l,t)=>q(Re(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>sl())),Re=(e,t)=>l?q(_l(A,e),(l=>Je(t)!=l[u]?sl(e,t,l[d]):t),(()=>sl(e,t))):O(Je(t))?sl(e,t):t,Oe=(e,l,t)=>(q(_l($,l),(([n,s])=>{Kl(n,((l,t)=>{le(e,t)||(e[t]=l)})),Kl(s,(n=>{le(e,n)||nl(l,t,n)}))})),e),qe=e=>(l&&(Kl(F,((l,t)=>{le(e,t)||(e[t]=l)})),Kl(J,(l=>{le(e,l)||sl(l)}))),e),Pe=e=>nt(z,e,((e,l,t)=>{const n=Yl(),s=vt();nt(tt(z,l,Yl),t,((e,l,t)=>{lt(e,l,t),q(t[d],(e=>lt(n,l,e)),(()=>ft(s,l)))})),lt($,l,[n,s])}),((e,l)=>{lt(z,l),lt($,l)})),Ne=e=>nt(A,e,((e,l,t)=>{lt(A,l,t),q(t[d],(e=>lt(F,l,e)),(()=>ft(J,l)))}),((e,l)=>{lt(A,l),lt(F,l),Xl(J,l)})),Ee=e=>se(e)?ql():Sl(e),Le=e=>nt(W,e,((e,l,t)=>Me(l,t)),((e,l)=>Ue(l))),Me=(e,l)=>nt(tt(W,e,(()=>(Ye(e,1),lt(D,e,yt()),lt(B,e,Yl()),Yl()))),l,((l,t,n)=>je(e,l,t,n)),((l,t)=>Ge(e,l,t))),je=(e,l,t,n,s)=>nt(tt(l,t,(()=>(Ze(e,t,1),Yl()))),n,((l,n,s)=>ze(e,t,l,n,s)),((n,r)=>Ke(e,l,t,n,r,s))),ze=(e,l,t,n,s)=>{Ql(t,n)||_e(e,l,n,1);const r=_l(t,n);s!==r&&(el(e,l,n,r,s),lt(t,n,s))},$e=(e,l,t,n,s)=>q(_l(l,t),(l=>ze(e,t,l,n,s)),(()=>je(e,l,t,Oe({[n]:s},e,t)))),Ae=e=>se(e)?El():Tl(e),Fe=e=>nt(G,e,((e,l,t)=>He(l,t)),((e,l)=>Xe(l))),He=(e,l)=>{Ql(G,e)||ll(e,1);const t=_l(G,e);l!==t&&(tl(e,t,l),lt(G,e,l))},Qe=(e,l)=>{const[t]=_l(D,e),n=t(l);return Ql(_l(W,e),n)?Qe(e,l):n},We=e=>{var l;return null!=(l=_l(W,e))?l:Me(e,{})},Ue=e=>Me(e,{}),Ge=(e,l,t)=>{const[,n]=_l(D,e);n(t),je(e,l,t,{},!0)},Ke=(e,l,t,n,s,r)=>{var a;const o=_l(null==(a=_l($,e))?void 0:a[0],s);if(!O(o)&&!r)return ze(e,t,n,s,o);const i=l=>{el(e,t,l,_l(n,l)),_e(e,t,l,-1),lt(n,l)};O(o)?i(s):et(n,i),Wl(n)&&(Ze(e,t,-1),Wl(lt(l,t))&&(Ye(e,-1),lt(W,e),lt(D,e),lt(B,e)))},Xe=e=>{const l=_l(F,e);if(!O(l))return He(e,l);tl(e,_l(G,e)),ll(e,-1),lt(G,e)},Ye=(e,l)=>Vt(a,e,l),Ze=(e,l,t)=>Vt(tt(k,e,Yl),l,t)&&lt(c,e,tt(c,e,(()=>0))+t),_e=(e,l,t,n)=>{var s;const r=_l(B,e),a=null!=(s=_l(r,t))?s:0;(0==a&&1==n||1==a&&-1==n)&&Vt(tt(i,e,Yl),t,n),lt(r,t,a!=-n?a+n:null),Vt(tt(tt(x,e,Yl),l,Yl),t,n)},el=(e,l,t,n,s)=>tt(tt(tt(T,e,Yl),l,Yl),t,(()=>[n,0]))[1]=s,ll=(e,l)=>Vt(V,e,l),tl=(e,l,t)=>tt(R,e,(()=>[l,0]))[1]=t,nl=(e,l,t,n,s)=>(U(tt(tt(tt(E,e,Yl),l,Yl),t,(()=>[])),n),s),sl=(e,l,t)=>(U(tt(j,e,(()=>[])),l),t),rl=(e,l,t)=>q(_l(_l(_l(T,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...wt(wl(e,l,t))])),al=e=>q(_l(R,e),(([e,l])=>[!0,e,l]),(()=>[!1,...wt(xl(e))])),ol=e=>Wl(E)||Wl(he[e])?0:Kl(e?ut(E):E,((l,t)=>Kl(l,((l,n)=>Kl(l,((l,s)=>ye(he[e],[t,n,s],l))))))),il=e=>Wl(j)||Wl(me[e])?0:Kl(e?ot(j):j,((l,t)=>ye(me[e],[t],l))),ul=(e,l,t)=>{if(!Wl(l))return ye(e,t,(()=>st(l))),1},dl=e=>{const l=Wl(ie[e]),t=Wl(de[e])&&Wl(_[e])&&Wl(ee[e])&&Wl(oe[e])&&l&&Wl(X[e]),n=Wl(ce[e])&&Wl(ue[e])&&Wl(Y[e])&&Wl(K[e]);if(!t||!n){const s=e?[ot(a),it(i),ot(c),it(k),ut(x),ut(T)]:[a,i,c,k,x,T];if(!t){ul(X[e],s[0]),Kl(s[1],((l,t)=>ul(_[e],l,[t]))),Kl(s[2],((l,t)=>{0!=l&&ye(ee[e],[t],vl(t))}));const t=vt();Kl(s[3],((n,s)=>{ul(oe[e],n,[s])&&!l&&(ye(ie[e],[s,null]),ft(t,s))})),l||Kl(s[5],((l,n)=>{if(!Ql(t,n)){const t=vt();Kl(l,(e=>Kl(e,(([l,n],s)=>n!==l?ft(t,s):Xl(e,s))))),Kl(t,(l=>ye(ie[e],[n,l])))}})),Kl(s[4],((l,t)=>Kl(l,((l,n)=>ul(de[e],l,[t,n])))))}if(!n){let l;Kl(s[5],((t,n)=>{let s;Kl(t,((t,r)=>{let a;Kl(t,(([t,o],i)=>{o!==t&&(ye(ce[e],[n,r,i],o,t,rl),l=s=a=1)})),a&&ye(ue[e],[n,r],rl)})),s&&ye(Y[e],[n],rl)})),l&&ye(K[e],void 0,rl)}}},cl=e=>{const l=Wl(pe[e]),t=Wl(ge[e])&&Wl(be[e]);if(!l||!t){const n=e?[ot(V),ot(R)]:[V,R];if(l||ul(pe[e],n[0]),!t){let l;Kl(n[1],(([t,n],s)=>{n!==t&&(ye(ge[e],[s],n,t,al),l=1)})),l&&ye(be[e],void 0,al)}}},hl=(e,...l)=>(jl((()=>e(...Q(l,S)))),Al),ml=()=>[st(T,((e,l)=>-1===_l(a,l)?null:st(e,((e,t)=>-1===_l(_l(k,l),t)?null:st(e,(([,e])=>null!=e?e:null),((e,l)=>St(l)))),se)),se),st(R,(([,e])=>null!=e?e:null),((e,l)=>St(l)))],bl=()=>({cellsTouched:t,valuesTouched:n,changedCells:at(T,xt,St),invalidCells:at(E),changedValues:st(R,xt,St),invalidValues:st(j),changedTableIds:st(a),changedRowIds:rt(k),changedCellIds:at(x),changedValueIds:st(V)}),pl=()=>at(W),gl=()=>Zl(W),vl=e=>Jl(_l(W,S(e))),fl=e=>Zl(_l(W,S(e))),Il=(e,l,t,n=0,s)=>{return Q(L((a=_l(W,S(e)),o=(e,t)=>[O(l)?t:_l(e,S(l)),t],r=([e],[l])=>{return((null!=(n=e)?n:0)<(null!=(s=l)?s:0)?-1:1)*(t?-1:1);var n,s},Q([...null!=(i=null==a?void 0:a.entries())?i:[]],(([e,l])=>o(l,e))).sort(r)),n,O(s)?s:n+s),(([,e])=>e));var r,a,o,i},yl=(e,l)=>Zl(_l(_l(W,S(e)),S(l))),wl=(e,l,t)=>_l(_l(_l(W,S(e)),S(l)),S(t)),Cl=()=>st(G),kl=()=>Zl(G),xl=e=>_l(G,S(e)),Sl=e=>hl((()=>(e=>Tt(e,xe,nl))(e)?Le(e):0)),Tl=e=>hl((()=>Ve(e)?Fe(e):0)),Vl=e=>{try{Ee(ae(e))}catch(e){}return Al},Rl=l=>hl((()=>{if((e=Tt(l,(e=>Tt(e,ke))))&&(Pe(l),!Wl(W))){const e=pl();ql(),Sl(e)}})),Ol=e=>hl((()=>{if(l=(e=>Tt(e,ke))(e)){const t=Cl();Ml(),El(),l=!0,Ne(e),Tl(t)}})),ql=()=>hl((()=>Le({}))),Pl=e=>hl((e=>Ql(W,e)?Ue(e):0),e),Nl=(e,l)=>hl(((e,l)=>q(_l(W,e),(t=>Ql(t,l)?Ge(e,t,l):0))),e,l),El=()=>hl((()=>Fe({}))),Ll=()=>hl((()=>{Pe({}),e=!1})),Ml=()=>hl((()=>{Ne({}),l=!1})),jl=(e,l)=>{if(-1!=r){zl();const t=e();return $l(l),t}},zl=()=>(-1!=r&&r++,1==r&&ye(ve,void 0,ml,bl),Al),$l=e=>(r>0&&(r--,0==r&&(t=!Wl(T),n=!Wl(R),r=1,ol(1),t&&dl(1),il(1),n&&cl(1),(null==e?void 0:e(ml,bl))&&(Kl(T,((e,l)=>Kl(e,((e,t)=>Kl(e,(([e],n)=>De(Al,l,t,n,e))))))),Kl(R,(([e],l)=>Be(Al,l,e))),t=n=!1),ye(fe[0],void 0,ml,bl),r=-1,ol(0),t&&dl(0),il(0),n&&cl(0),ye(fe[1],void 0,ml,bl),r=0,t=n=!1,H([a,i,c,k,x,T,E,V,R,j],Gl))),Al),Al={getContent:()=>[pl(),Cl()],getTables:pl,getTableIds:gl,getTable:e=>rt(_l(W,S(e))),getTableCellIds:e=>Zl(_l(B,S(e))),getRowCount:vl,getRowIds:fl,getSortedRowIds:Il,getRow:(e,l)=>st(_l(_l(W,S(e)),S(l))),getCellIds:yl,getCell:wl,getValues:Cl,getValueIds:kl,getValue:xl,hasTables:()=>!Wl(W),hasTable:e=>Ql(W,S(e)),hasTableCell:(e,l)=>Ql(_l(B,S(e)),S(l)),hasRow:(e,l)=>Ql(_l(W,S(e)),S(l)),hasCell:(e,l,t)=>Ql(_l(_l(W,S(e)),S(l)),S(t)),hasValues:()=>!Wl(G),hasValue:e=>Ql(G,S(e)),getTablesJson:()=>re(W),getValuesJson:()=>re(G),getJson:()=>re([W,G]),getTablesSchemaJson:()=>re(z),getValuesSchemaJson:()=>re(A),getSchemaJson:()=>re([z,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>l,setContent:([e,l])=>hl((()=>{(se(e)?ql:Sl)(e),(se(l)?El:Tl)(l)})),setTables:Sl,setTable:(e,l)=>hl((e=>xe(l,e)?Me(e,l):0),e),setRow:(e,l,t)=>hl(((e,l)=>Se(e,l,t)?je(e,We(e),l,t):0),e,l),addRow:(e,l,t=!0)=>jl((()=>{let n;return Se(e,n,l)&&(e=S(e),je(e,We(e),n=Qe(e,t?1:0),l)),n})),setPartialRow:(e,l,t)=>hl(((e,l)=>{if(Se(e,l,t,1)){const n=We(e);ne(t,((t,s)=>$e(e,n,l,s,t)))}}),e,l),setCell:(e,l,t,n)=>hl(((e,l,t)=>q(Te(e,l,t,N(n)?n(wl(e,l,t)):n),(n=>$e(e,We(e),l,t,n)))),e,l,t),setValues:Tl,setPartialValues:e=>hl((()=>Ve(e,1)?ne(e,((e,l)=>He(l,e))):0)),setValue:(e,l)=>hl((e=>q(Re(e,N(l)?l(xl(e)):l),(l=>He(e,l)))),e),setTransactionChanges:e=>hl((()=>{ne(e[0],((e,l)=>O(e)?Pl(l):ne(e,((e,t)=>O(e)?Nl(l,t):ne(e,((e,n)=>De(Al,l,t,n,e))))))),ne(e[1],((e,l)=>Be(Al,l,e)))})),setTablesJson:Vl,setValuesJson:e=>{try{Ae(ae(e))}catch(e){}return Al},setJson:e=>hl((()=>{try{const[l,t]=ae(e);Ee(l),Ae(t)}catch(l){Vl(e)}})),setTablesSchema:Rl,setValuesSchema:Ol,setSchema:(e,l)=>hl((()=>{Rl(e),Ol(l)})),delTables:ql,delTable:Pl,delRow:Nl,delCell:(e,l,t,n)=>hl(((e,l,t)=>q(_l(W,e),(s=>q(_l(s,l),(r=>Ql(r,t)?Ke(e,s,l,r,t,n):0))))),e,l,t),delValues:El,delValue:e=>hl((e=>Ql(G,e)?Xe(e):0),e),delTablesSchema:Ll,delValuesSchema:Ml,delSchema:()=>hl((()=>{Ll(),Ml()})),transaction:jl,startTransaction:zl,finishTransaction:$l,forEachTable:e=>Kl(W,((l,t)=>e(t,(e=>Kl(l,((l,t)=>e(t,(e=>et(l,e))))))))),forEachTableCell:(e,l)=>et(_l(B,S(e)),l),forEachRow:(e,l)=>Kl(_l(W,S(e)),((e,t)=>l(t,(l=>et(e,l))))),forEachCell:(e,l,t)=>et(_l(_l(W,S(e)),S(l)),t),forEachValue:e=>et(G,e),addSortedRowIdsListener:(e,l,t,n,s,r,a)=>{let o=Il(e,l,t,n,s);return Ie((()=>{const a=Il(e,l,t,n,s);var i,u,d;u=o,M(i=a)===M(u)&&(d=(e,l)=>u[l]===e,i.every(d))||(o=a,r(Al,e,l,t,n,s,o))}),ie[a?1:0],[e,l],[gl])},addStartTransactionListener:e=>Ie(e,ve),addWillFinishTransactionListener:e=>Ie(e,fe[0]),addDidFinishTransactionListener:e=>Ie(e,fe[1]),callListener:e=>(Ce(e),Al),delListener:e=>(we(e),Al),getListenerStats:()=>({tables:Ct(K),tableIds:Ct(X),tableCellIds:Ct(_),table:Ct(Y),rowCount:Ct(ee),rowIds:Ct(oe),sortedRowIds:Ct(ie),row:Ct(ue,Bl),cellIds:Ct(de,Bl),cell:Ct(ce,Hl),invalidCell:Ct(he,Hl),values:Ct(be),valueIds:Ct(pe),value:Ct(ge),invalidValue:Ct(me),transaction:Dl(ve)+Ct(fe)}),createStore:Rt,addListener:Ie,callListeners:ye};return ne({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[gl]],[h+I]:[1,_,[gl]],[g]:[1,ee,[gl]],[v]:[1,oe,[gl]],[p]:[2,ue,[gl,fl]],[I]:[2,de,[gl,fl]],[f]:[3,ce,[gl,fl,yl],e=>wt(wl(...e))],InvalidCell:[3,he],[w]:[0,be],[C]:[0,pe],[y]:[1,ge,[kl],e=>wt(xl(e[0]))],InvalidValue:[1,me]},(([e,l,t,n],s)=>{Al["add"+s+"Listener"]=(...s)=>Ie(s[e],l[s[e+1]?1:0],e>0?L(s,0,e):void 0,t,n)})),Z(Al)},Ot=({position:e="right",open:l=!1})=>{const n=t.useCreateStore(Rt),s=ue.indexOf(e);return t.useCreatePersister(n,(e=>{return((e,l,t,n)=>((e,l,t,n,s,r,a=[])=>{let o,i,u,d=0,c=0,h=0,m=0;tt(ht,a,(()=>0)),tt(mt,a,(()=>[]));const b=e=>ct(void 0,null,(function*(){return 2!=d&&(d=1,c++,yield p.schedule((()=>ct(void 0,null,(function*(){yield e(),d=0}))))),p})),p={load:(t,n)=>ct(void 0,null,(function*(){return yield b((()=>ct(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>ct(void 0,[...t],(function*(t={},s={}){return p.stopAutoLoad(),yield p.load(t,s),m=1,u=n(((t,n)=>ct(void 0,null,(function*(){if(n){const l=n();yield b((()=>ct(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield b((()=>ct(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield l())}catch(e){null==r||r(e)}}))))})))),p})),stopAutoLoad:()=>(m&&(s(u),u=void 0,m=0),p),save:l=>ct(void 0,null,(function*(){return 1!=d&&(d=2,h++,yield p.schedule((()=>ct(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}d=0}))))),p})),startAutoSave:()=>ct(void 0,null,(function*(){return yield p.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,l)=>{const[t,n]=l();se(t)&&se(n)||p.save((()=>[t,n]))})),p})),stopAutoSave:()=>(q(o,e.delListener),p),schedule:(...e)=>ct(void 0,null,(function*(){return U(_l(mt,a),...e),yield ct(void 0,null,(function*(){if(!_l(ht,a)){for(lt(ht,a,1);!O(i=G(_l(mt,a)));)try{yield i()}catch(e){null==r||r(e)}lt(ht,a,0)}})),p})),getStore:()=>e,destroy:()=>p.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(p)})(e,(()=>bt(void 0,null,(function*(){return ae(t.getItem(l))}))),(e=>bt(void 0,null,(function*(){return t.setItem(l,re(e()))}))),(e=>{const n=n=>{n.storageArea===t&&n.key===l&&e((()=>ae(n.newValue)))};return gt.addEventListener(pt,n),n}),(e=>gt.removeEventListener(pt,e)),n))(e,oe,sessionStorage,l);var l}),void 0,(e=>{return t=function*(){yield e.load(void 0,{position:-1==s?1:s,open:!!l}),yield e.startAutoSave()},new Promise(((e,l)=>{var n=e=>{try{r(t.next(e))}catch(e){l(e)}},s=e=>{try{r(t.throw(e))}catch(e){l(e)}},r=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,s);r((t=t.apply(void 0,null)).next())}));var t})),$(z,null,$("aside",{id:oe},$(Ae,{s:n}),$(Al,{s:n})),$("style",null,$e))};var qt=Object.defineProperty,Pt=Object.getOwnPropertySymbols,Nt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,Lt=(e,l,t)=>l in e?qt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;e.EditableCellView=wl,e.EditableValueView=Cl,e.RelationshipInHtmlTable=Il,e.ResultSortedTableInHtmlTable=yl,e.ResultTableInHtmlTable=e=>{var l=e,{queryId:n,queries:s,customCells:r}=l,a=el(l,["queryId","queries","customCells"]);return $(hl,_e(Ze({},a),{params:ol(cl(t.useResultTableCellIds(n,s),r,t.ResultCellView),ul(s,n),t.useResultRowIds(n,s))}))},e.SliceInHtmlTable=fl,e.SortedTableInHtmlTable=gl,e.SortedTablePaginator=kl,e.StoreInspector=e=>$(Ot,((e,l)=>{for(var t in l||(l={}))Nt.call(l,t)&&Lt(e,t,l[t]);if(Pt)for(var t of Pt(l))Et.call(l,t)&&Lt(e,t,l[t]);return e})({},e)),e.TableInHtmlTable=e=>{var l=e,{tableId:n,store:s,editable:r,customCells:a}=l,o=el(l,["tableId","store","editable","customCells"]);return $(hl,_e(Ze({},o),{params:ol(cl(t.useTableCellIds(n,s),a,r?wl:t.CellView),il(s,n),t.useRowIds(n,s))}))},e.ValuesInHtmlTable=vl},"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
1
+ var e,l;e=this,l=function(e,l,t){"use strict";const n=e=>typeof e,s="",r=n(s),o=n(!0),a=n(0),i=n(n),u="type",d="default",c="Ids",h="Table",m=h+"s",b=h+c,p="Row",g=p+"Count",v=p+c,f="Cell",I=f+c,y="Value",w=y+"s",C=y+c,k="currentTarget",T="value",x=e=>s+e,S=Math.floor,V=isFinite,R=(e,l)=>e instanceof l,O=e=>null==e,q=(e,l,t)=>O(e)?null==t?void 0:t():l(e),P=e=>e==r||e==o,N=e=>n(e)==i,E=e=>Array.isArray(e),L=(e,l,t)=>e.slice(l,t),M=e=>e.length,{PureComponent:j,Fragment:z,createElement:$,useCallback:A,useLayoutEffect:F,useRef:J,useState:D}=l,B=(e,...l)=>O(e)?{}:e(...l),H=(e,l)=>e.forEach(l),Q=(e,l)=>e.map(l),W=e=>0==M(e),U=(e,...l)=>e.push(...l),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),le=(e,l)=>!O(((e,l)=>q(e,(e=>e[l])))(e,l)),te=(e,l)=>(delete e[l],e),ne=(e,l)=>Q(K.entries(e),(([e,t])=>l(t,e))),se=e=>_(e)&&0==(e=>M(X(e)))(e),re=e=>JSON.stringify(e,((e,l)=>R(l,Map)?K.fromEntries([...l]):l)),oe=JSON.parse,ae="tinybaseStoreInspector",ie="TinyBase Store Inspector",ue=["left","top","bottom","right","full"],de="state",ce="sort",he="open",me="position",be=he,pe="editable",ge=(...e)=>re(e),ve=(e,l)=>Q(e.sort(),l),fe=(e,l)=>[!!t.useCell(de,e,pe,l),A((t=>{l.setCell(de,e,pe,(e=>!e)),t.preventDefault()}),[l,e])],Ie="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',we=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'>",Ce='</svg>")',ke=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\")",Te=Q([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,l,t,n])=>we+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${l}' width='${t}' height='${n}' fill='white'/>`+Ce)),xe=we+"<path d='M20 20l60 60M20 80l60-60' />"+Ce,Se=we+`<path d='${Ie}' />`+Ce,Ve=we+`<path d='${Ie}M20 20l60 60' />`+Ce;var Re=Object.defineProperty,Oe=Object.defineProperties,qe=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Ne=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Le=(e,l,t)=>l in e?Re(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Me=(e,l)=>{for(var t in l||(l={}))Ne.call(l,t)&&Le(e,t,l[t]);if(Pe)for(var t of Pe(l))Ee.call(l,t)&&Le(e,t,l[t]);return e},je=(e,l)=>Oe(e,qe(l));const ze="*::-webkit-scrollbar",$e=`#${ae}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,l="")=>e.join(l))(ne(je(Me(je(Me(je(Me({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[ze]:"width:0.5rem;height:0.5rem;",[ze+"-track"]:"background:#111",[ze+"-thumb"]:"background:#999;border:1px solid #111",[ze+"-thumb:hover"]:"background:#fff",[ze+"-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;"+ke},ee(Q(["bottom:0;left:0","top:0;right:0"],((e,l)=>[`>img[data-position='${l}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),ee(Q(["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,l)=>[`main[data-position='${l}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ke,"header>img:nth-of-type(6)":xe}),ee(Q(Te,((e,l)=>[`header>img[data-id='${l}']`,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":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,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,l)=>e?`& ${l}{${e}}`:"")))}`,Ae=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1,s=t.useSetValueCallback(be,(()=>!0),[],e);return t.useValue(be,e)?null:$("img",{onClick:s,title:ie,"data-position":n})},Fe=({uniqueId:e,summary:l,editable:n,handleEditable:s,children:r,s:o})=>{const a=!!t.useCell(de,e,he,o),i=t.useSetCellCallback(de,e,he,(e=>e[k].open),[],o);return $("details",{open:a,onToggle:i},$("summary",null,l,s?$("img",{onClick:s,className:n?"done":"edit"}):null),r)},Je=e=>{const l=n(e);return P(l)||l==a&&V(e)?l:void 0},De=(e,l,t,n,s)=>O(s)?e.delCell(l,t,n,!0):e.setCell(l,t,n,s),Be=(e,l,t)=>O(t)?e.delValue(l):e.setValue(l,t),He=(e,l,t,n)=>e==r?l:e==a?t:n;var Qe=Object.defineProperty,We=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,Ye=(e,l,t)=>l in e?Qe(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Ze=(e,l)=>{for(var t in l||(l={}))Ke.call(l,t)&&Ye(e,t,l[t]);if(Ge)for(var t of Ge(l))Xe.call(l,t)&&Ye(e,t,l[t]);return e},_e=(e,l)=>We(e,Ue(l)),el=(e,l)=>{var t={};for(var n in e)Ke.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&Ge)for(var n of Ge(e))l.indexOf(n)<0&&Xe.call(e,n)&&(t[n]=e[n]);return t};const{useCallback:ll,useMemo:tl,useState:nl}=l,sl="editable",rl=(e,l)=>Q(t.useTableCellIds(e,l),(l=>e+"."+l)),ol=(e,l,t)=>{const n=ll(e,l);return t?n:void 0},al=(...e)=>tl((()=>e),e),il=(e,l)=>tl((()=>({store:e,tableId:l})),[e,l]),ul=(e,l)=>tl((()=>({queries:e,queryId:l})),[e,l]),dl=(e,l=!1,t,n=0,s,r,o,a)=>{const[[i,u,d],c]=nl([e,l,n]),h=ll((e=>{c(e),null==a||a(e)}),[a]),m=ol((e=>h([e,e==i&&!u,d])),[h,i,u,d],t),b=ll((e=>h([i,u,e])),[h,i,u]),p=!0===o?kl:o;return[[i,u,d],m,tl((()=>!1===o?null:$(p,{offset:d,limit:s,total:r,onChange:b})),[o,p,d,s,r,b])]},cl=(e,l,t)=>tl((()=>{const s=null!=l?l:e;return ee(ne(E(s)?ee(Q(s,(e=>[e,e]))):s,((e,l)=>{return[l,Ze(Ze({},{label:l,component:t}),(s=e,n(s)==r?{label:e}:e))];var s})))}),[l,t,e]),hl=({className:e,headerRow:l,idColumn:t,params:[n,s,r,o,a,i]})=>$("table",{className:e},i?$("caption",null,i):null,!1===l?null:$("thead",null,$("tr",null,!1===t?null:$(ml,{sort:null!=o?o:[],label:"Id",onClick:a}),ne(n,(({label:e},l)=>$(ml,{key:l,cellId:l,label:e,sort:null!=o?o:[],onClick:a}))))),$("tbody",null,Q(r,(e=>$("tr",{key:e},!1===t?null:$("th",null,e),ne(n,(({component:l,getComponentProps:t},n)=>$("td",{key:n},$(l,_e(Ze(Ze({},B(t,e,n)),s),{rowId:e,cellId:n})))))))))),ml=({cellId:e,sort:[l,t],label:n=(null!=e?e:s),onClick:r})=>$("th",{onClick:ol((()=>null==r?void 0:r(e)),[r,e],r),className:O(t)||l!=e?void 0:`sorted ${t?"de":"a"}scending`},O(t)||l!=e?null:(t?"↓":"↑")+" ",n),bl=({localRowId:e,params:[n,s,r,o,a,i,u]})=>{const d=t.useRemoteRowId(a,e,i);return $("tr",null,!1===n?null:$(l.Fragment,null,$("th",null,e),$("th",null,d)),ne(s,(({component:l,getComponentProps:t},n)=>{const[s,a]=n.split(".",2),i=s===r?e:s===o?d:null;return O(i)?null:$("td",{key:n},$(l,_e(Ze({},B(t,i,a)),{store:u,tableId:s,rowId:i,cellId:a})))})))},pl=({thing:e,onThingChange:l,className:t,hasSchema:n,showType:s=!0})=>{const[i,u]=nl(),[d,c]=nl(),[h,m]=nl(),[b,p]=nl(),[g,v]=nl();d!==e&&(u(Je(e)),c(e),m(e+""),p(Number(e)||0),v(!!e));const f=ll(((e,t)=>{t(e),c(e),l(e)}),[l]),I=ll((()=>{if(!(null==n?void 0:n())){const e=He(i,a,o,r),t=He(e,h,b,g);u(e),c(t),l(t)}}),[n,l,h,b,g,i]);return $("div",{className:t},s?$("button",{className:i,onClick:I},i):null,He(i,$("input",{key:i,value:h,onChange:ll((e=>f(e[k][T]+"",m)),[f])}),$("input",{key:i,type:"number",value:b,onChange:ll((e=>f(Number(e[k][T]||0),p)),[f])}),$("input",{key:i,type:"checkbox",checked:g,onChange:ll((e=>f(!!e[k].checked,v)),[f])})))},gl=e=>{var l=e,{tableId:n,cellId:s,descending:r,offset:o,limit:a,store:i,editable:u,sortOnClick:d,paginator:c=!1,onChange:h,customCells:m}=l,b=el(l,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[p,g,v]=dl(s,r,d,o,a,t.useRowCount(n,i),c,h);return $(hl,_e(Ze({},b),{params:al(cl(t.useTableCellIds(n,i),m,u?wl:t.CellView),il(i,n),t.useSortedRowIds(n,...p,a,i),p,g,v)}))},vl=({store:e,editable:l=!1,valueComponent:n=(l?Cl:t.ValueView),getValueComponentProps:s,className:r,headerRow:o,idColumn:a})=>$("table",{className:r},!1===o?null:$("thead",null,$("tr",null,!1===a?null:$("th",null,"Id"),$("th",null,y))),$("tbody",null,Q(t.useValueIds(e),(l=>$("tr",{key:l},!1===a?null:$("th",null,l),$("td",null,$(n,_e(Ze({},B(s,l)),{valueId:l,store:e})))))))),fl=e=>{var l=e,{indexId:n,sliceId:s,indexes:r,editable:o,customCells:a}=l,i=el(l,["indexId","sliceId","indexes","editable","customCells"]);const[u,d,c]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(l)])(t.useIndexesOrIndexesById(r),n);return $(hl,_e(Ze({},i),{params:al(cl(t.useTableCellIds(c,d),a,o?wl:t.CellView),il(d,c),t.useSliceRowIds(n,s,u))}))},Il=({relationshipId:e,relationships:n,editable:s,customCells:r,className:o,headerRow:a,idColumn:i=!0})=>{const[u,d,c,h]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(l),null==e?void 0:e.getRemoteTableId(l)])(t.useRelationshipsOrRelationshipsById(n),e),m=cl([...rl(c,d),...rl(h,d)],r,s?wl:t.CellView),b=al(i,m,c,h,e,u,d);return $("table",{className:o},!1===a?null:$("thead",null,$("tr",null,!1===i?null:$(l.Fragment,null,$("th",null,c,".Id"),$("th",null,h,".Id")),ne(m,(({label:e},l)=>$("th",{key:l},e))))),$("tbody",null,Q(t.useRowIds(c,d),(e=>$(bl,{key:e,localRowId:e,params:b})))))},yl=e=>{var l=e,{queryId:n,cellId:s,descending:r,offset:o,limit:a,queries:i,sortOnClick:u,paginator:d=!1,customCells:c,onChange:h}=l,m=el(l,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[b,p,g]=dl(s,r,u,o,a,t.useResultRowCount(n,i),d,h);return $(hl,_e(Ze({},m),{params:al(cl(t.useResultTableCellIds(n,i),c,t.ResultCellView),ul(i,n),t.useResultSortedRowIds(n,...b,a,i),b,p,g)}))},wl=({tableId:e,rowId:l,cellId:n,store:s,className:r,showType:o})=>{var a;return $(pl,{thing:t.useCell(e,l,n,s),onThingChange:t.useSetCellCallback(e,l,n,(e=>e),[],s),className:null!=r?r:sl+f,showType:o,hasSchema:null==(a=t.useStoreOrStoreById(s))?void 0:a.hasTablesSchema})},Cl=({valueId:e,store:l,className:n,showType:s})=>{var r;return $(pl,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:null!=n?n:sl+y,showType:s,hasSchema:null==(r=t.useStoreOrStoreById(l))?void 0:r.hasValuesSchema})},kl=({onChange:e,total:t,offset:n=0,limit:s=t,singular:r="row",plural:o=r+"s"})=>{(n>t||n<0)&&(n=0,e(0));const a=ol((()=>e(n-s)),[e,n,s],n>0),i=ol((()=>e(n+s)),[e,n,s],n+s<t);return $(l.Fragment,null,t>s&&$(l.Fragment,null,$("button",{className:"previous",disabled:0==n,onClick:a},"←"),$("button",{className:"next",disabled:n+s>=t,onClick:i},"→"),n+1," to ",Math.min(t,n+s)," of "),t," ",1!=t?o:r)},Tl=({indexes:e,indexesId:l,indexId:n,s:s})=>$(Fe,{uniqueId:ge("i",l,n),summary:"Index: "+n,s:s},Q(t.useSliceIds(n,e),(t=>$(xl,{indexes:e,indexesId:l,indexId:n,sliceId:t,s:s,key:t})))),xl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=ge("i",l,t,n),[o,a]=fe(r,s);return $(Fe,{uniqueId:r,summary:"Slice: "+n,editable:o,handleEditable:a,s:s},$(fl,{sliceId:n,indexId:t,indexes:e,editable:o}))},Sl=({indexesId:e,s:l})=>{const n=t.useIndexes(e),s=t.useIndexIds(n);return O(n)?null:$(Fe,{uniqueId:ge("i",e),summary:"Indexes: "+(null!=e?e:d),s:l},W(s)?"No indexes defined":ve(s,(t=>$(Tl,{indexes:n,indexesId:e,indexId:t,s:l,key:t}))))},Vl=({metrics:e,metricId:l})=>$("tr",null,$("th",null,l),$("td",null,null==e?void 0:e.getTableId(l)),$("td",null,t.useMetric(l,e))),Rl=({metricsId:e,s:l})=>{const n=t.useMetrics(e),s=t.useMetricIds(n);return O(n)?null:$(Fe,{uniqueId:ge("m",e),summary:"Metrics: "+(null!=e?e:d),s:l},W(s)?"No metrics defined":$("table",null,$("thead",null,$("th",null,"Metric Id"),$("th",null,"Table Id"),$("th",null,"Metric")),$("tbody",null,Q(s,(e=>$(Vl,{metrics:n,metricId:e,key:e}))))))},Ol=({queries:e,queriesId:l,queryId:n,s:s})=>{var r;const o=ge("q",l,n),[a,i,u]=oe(null!=(r=t.useCell(de,o,ce,s))?r:"[]"),d=t.useSetCellCallback(de,o,ce,re,[],s);return $(Fe,{uniqueId:o,summary:"Query: "+n,s:s},$(yl,{queryId:n,queries:e,cellId:a,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ql=({queriesId:e,s:l})=>{const n=t.useQueries(e),s=t.useQueryIds(n);return O(n)?null:$(Fe,{uniqueId:ge("q",e),summary:"Queries: "+(null!=e?e:d),s:l},W(s)?"No queries defined":ve(s,(t=>$(Ol,{queries:n,queriesId:e,queryId:t,s:l,key:t}))))},Pl=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=ge("r",l,t),[r,o]=fe(s,n);return $(Fe,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:o,s:n},$(Il,{relationshipId:t,relationships:e,editable:r}))},Nl=({relationshipsId:e,s:l})=>{const n=t.useRelationships(e),s=t.useRelationshipIds(n);return O(n)?null:$(Fe,{uniqueId:ge("r",e),summary:"Relationships: "+(null!=e?e:d),s:l},W(s)?"No relationships defined":ve(s,(t=>$(Pl,{relationships:n,relationshipsId:e,relationshipId:t,s:l,key:t}))))},El=({tableId:e,store:l,storeId:n,s:s})=>{var r;const o=ge("t",n,e),[a,i,u]=oe(null!=(r=t.useCell(de,o,ce,s))?r:"[]"),d=t.useSetCellCallback(de,o,ce,re,[],s),[c,m]=fe(o,s);return $(Fe,{uniqueId:o,summary:h+": "+e,editable:c,handleEditable:m,s:s},$(gl,{tableId:e,store:l,cellId:a,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:c}))},Ll=({store:e,storeId:l,s:n})=>{const s=ge("v",l),[r,o]=fe(s,n);return W(t.useValueIds(e))?null:$(Fe,{uniqueId:s,summary:w,editable:r,handleEditable:o,s:n},$(vl,{store:e,editable:r}))},Ml=({storeId:e,s:l})=>{const n=t.useStore(e),s=t.useTableIds(n);return O(n)?null:$(Fe,{uniqueId:ge("s",e),summary:"Store: "+(null!=e?e:d),s:l},$(Ll,{storeId:e,store:n,s:l}),ve(s,(t=>$(El,{store:n,storeId:e,tableId:t,s:l,key:t}))))},jl=({s:e})=>{const l=J(null),n=J(0),[s,r]=D(!1),{scrollLeft:o,scrollTop:a}=t.useValues(e);F((()=>{const e=l.current;if(e&&!s){const l=new MutationObserver((()=>{e.scrollWidth>=S(o)+e.clientWidth&&e.scrollHeight>=S(a)+e.clientHeight&&e.scrollTo(o,a)}));return l.observe(e,{childList:!0,subtree:!0}),()=>l.disconnect()}}),[s,o,a]);const i=A((l=>{const{scrollLeft:t,scrollTop:s}=l[k];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{r(!0),e.setPartialValues({scrollLeft:t,scrollTop:s})}))}),[e]),u=t.useStore(),d=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),b=t.useIndexesIds(),p=t.useRelationships(),g=t.useRelationshipsIds(),v=t.useQueries(),f=t.useQueriesIds();return O(u)&&W(d)&&O(c)&&W(h)&&O(m)&&W(b)&&O(p)&&W(g)&&O(v)&&W(f)?$("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):$("article",{ref:l,onScroll:i},$(Ml,{s:e}),Q(d,(l=>$(Ml,{storeId:l,s:e,key:l}))),$(Rl,{s:e}),Q(h,(l=>$(Rl,{metricsId:l,s:e,key:l}))),$(Sl,{s:e}),Q(b,(l=>$(Sl,{indexesId:l,s:e,key:l}))),$(Nl,{s:e}),Q(g,(l=>$(Nl,{relationshipsId:l,s:e,key:l}))),$(ql,{s:e}),Q(f,(l=>$(ql,{queriesId:l,s:e,key:l}))))};class zl extends j{constructor(e){super(e),this.componentDidCatch=(e,l)=>console.error(e,l.componentStack),this.state={e:0}}render(){return this.state.e?$("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}zl.getDerivedStateFromError=()=>({e:1});const $l=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1,s=t.useSetValueCallback(be,(()=>!1),[],e),r=t.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return $("header",null,$("img",{title:ie}),$("span",null,ie),Q(ue,((e,l)=>l==n?null:$("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),$("img",{onClick:s,title:"Close"}))},Al=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1;return t.useValue(be,e)?$("main",{"data-position":n},$($l,{s:e}),$(zl,null,$(jl,{s:e}))):null},Fl=e=>l=>{return t=(l,t)=>l+e(t),Ul(l).reduce(t,0);var t},Jl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Dl=Fl(Jl),Bl=Fl(Dl),Hl=Fl(Bl),Ql=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Wl=e=>O(e)||0==Jl(e),Ul=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Gl=e=>e.clear(),Kl=(e,l)=>null==e?void 0:e.forEach(l),Xl=(e,l)=>null==e?void 0:e.delete(l),Yl=e=>new Map(e),Zl=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},_l=(e,l)=>null==e?void 0:e.get(l),et=(e,l)=>Kl(e,((e,t)=>l(t,e))),lt=(e,l,t)=>O(t)?(Xl(e,l),e):null==e?void 0:e.set(l,t),tt=(e,l,t)=>(Ql(e,l)||lt(e,l,t()),_l(e,l)),nt=(e,l,t,n=lt)=>(ne(l,((l,n)=>t(e,n,l))),et(e,(t=>le(l,t)?0:n(e,t))),e),st=(e,l,t)=>{const n={};return Kl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},rt=(e,l,t)=>st(e,(e=>st(e,l,t)),se),ot=(e,l,t)=>st(e,(e=>rt(e,l,t)),se),at=(e,l)=>{const t=Yl();return Kl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},it=e=>at(e,at),ut=e=>at(e,it),dt=(e,l,t,n,s=0)=>q((t?tt:_l)(e,l[s],s>M(l)-2?t:Yl),(r=>{if(s>M(l)-2)return(null==n?void 0:n(r))&&lt(e,l[s]),r;const o=dt(r,l,t,n,s+1);return Wl(r)&&lt(e,l[s]),o}));var ct=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{a(t.next(e))}catch(e){s(e)}},o=e=>{try{a(t.throw(e))}catch(e){s(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,o);a((t=t.apply(e,l)).next())}));const ht=Yl(),mt=Yl();var bt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{a(t.next(e))}catch(e){s(e)}},o=e=>{try{a(t.throw(e))}catch(e){s(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,o);a((t=t.apply(e,l)).next())}));const pt="storage",gt=globalThis.window,vt=e=>new Set(E(e)||O(e)?e:[e]),ft=(e,l)=>null==e?void 0:e.add(l),It=/^\d+$/,yt=()=>{const e=[];let l=0;return[t=>{var n;return null!=(n=t?G(e):null)?n:s+l++},l=>{It.test(l)&&M(e)<1e3&&U(e,l)}]},wt=e=>[e,e],Ct=(e,l=Dl)=>l(e[0])+l(e[1]),kt=()=>[Yl(),Yl()],Tt=e=>[...e],xt=([e,l])=>e===l,St=(e,l,t)=>O(e)||!_(e)||se(e)||Y(e)?(null==t||t(),!1):(ne(e,((t,n)=>{l(t,n)||te(e,n)})),!se(e)),Vt=(e,l,t)=>lt(e,l,_l(e,l)==-t?void 0:t),Rt=()=>{let e,l,t=!1,n=!1,r=0;const o=Yl(),i=Yl(),c=Yl(),k=Yl(),T=Yl(),S=Yl(),V=Yl(),R=Yl(),E=Yl(),j=Yl(),z=Yl(),$=Yl(),A=Yl(),F=Yl(),J=vt(),D=Yl(),B=Yl(),W=Yl(),G=Yl(),K=kt(),X=kt(),Y=kt(),_=kt(),ee=kt(),ae=kt(),ie=kt(),ue=kt(),de=kt(),ce=kt(),he=kt(),me=kt(),be=kt(),pe=kt(),ge=kt(),ve=Yl(),fe=kt(),[Ie,ye,we,Ce]=(e=>{let l;const[t,n]=yt(),r=Yl();return[(e,n,o,a=[],i=(()=>[]))=>{null!=l||(l=Al);const u=t(1);return lt(r,u,[e,n,o,a,i]),ft(dt(n,null!=o?o:[s],vt),u),u},(e,t,...n)=>H(((e,l=[s])=>{const t=[],n=(e,s)=>s==M(l)?U(t,e):null===l[s]?Kl(e,(e=>n(e,s+1))):H([l[s],null],(l=>n(_l(e,l),s+1)));return n(e,0),t})(e,t),(e=>Kl(e,(e=>_l(r,e)[0](l,...null!=t?t:[],...n))))),e=>q(_l(r,e),(([,l,t])=>(dt(l,null!=t?t:[s],void 0,(l=>(Xl(l,e),Wl(l)?1:0))),lt(r,e),n(e),t))),e=>q(_l(r,e),(([e,,t=[],n,s])=>{const r=(...o)=>{var a,i;const u=M(o);u==M(t)?e(l,...o,...s(o)):O(t[u])?H(null!=(i=null==(a=n[u])?void 0:a.call(n,...o))?i:[],(e=>r(...o,e))):r(...o,t[u])};r()}))]})(),ke=e=>{if(!St(e,((e,l)=>[u,d].includes(l))))return!1;const l=e[u];return!(!P(l)&&l!=a||(Je(e[d])!=l&&te(e,d),0))},Te=(l,t)=>(!e||Ql(z,t)||nl(t))&&St(l,((e,l)=>xe(t,l,e)),(()=>nl(t))),xe=(e,l,t,n)=>St(n?t:Oe(t,e,l),((n,s)=>q(Se(e,l,s,n),(e=>(t[s]=e,!0)),(()=>!1))),(()=>nl(e,l))),Se=(l,t,n,s)=>e?q(_l(_l(z,l),n),(e=>Je(s)!=e[u]?nl(l,t,n,s,e[d]):s),(()=>nl(l,t,n,s))):O(Je(s))?nl(l,t,n,s):s,Ve=(e,l)=>St(l?e:qe(e),((l,t)=>q(Re(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>sl())),Re=(e,t)=>l?q(_l(A,e),(l=>Je(t)!=l[u]?sl(e,t,l[d]):t),(()=>sl(e,t))):O(Je(t))?sl(e,t):t,Oe=(e,l,t)=>(q(_l($,l),(([n,s])=>{Kl(n,((l,t)=>{le(e,t)||(e[t]=l)})),Kl(s,(n=>{le(e,n)||nl(l,t,n)}))})),e),qe=e=>(l&&(Kl(F,((l,t)=>{le(e,t)||(e[t]=l)})),Kl(J,(l=>{le(e,l)||sl(l)}))),e),Pe=e=>nt(z,e,((e,l,t)=>{const n=Yl(),s=vt();nt(tt(z,l,Yl),t,((e,l,t)=>{lt(e,l,t),q(t[d],(e=>lt(n,l,e)),(()=>ft(s,l)))})),lt($,l,[n,s])}),((e,l)=>{lt(z,l),lt($,l)})),Ne=e=>nt(A,e,((e,l,t)=>{lt(A,l,t),q(t[d],(e=>lt(F,l,e)),(()=>ft(J,l)))}),((e,l)=>{lt(A,l),lt(F,l),Xl(J,l)})),Ee=e=>se(e)?ql():xl(e),Le=e=>nt(W,e,((e,l,t)=>Me(l,t)),((e,l)=>Ue(l))),Me=(e,l)=>nt(tt(W,e,(()=>(Ye(e,1),lt(D,e,yt()),lt(B,e,Yl()),Yl()))),l,((l,t,n)=>je(e,l,t,n)),((l,t)=>Ge(e,l,t))),je=(e,l,t,n,s)=>nt(tt(l,t,(()=>(Ze(e,t,1),Yl()))),n,((l,n,s)=>ze(e,t,l,n,s)),((n,r)=>Ke(e,l,t,n,r,s))),ze=(e,l,t,n,s)=>{Ql(t,n)||_e(e,l,n,1);const r=_l(t,n);s!==r&&(el(e,l,n,r,s),lt(t,n,s))},$e=(e,l,t,n,s)=>q(_l(l,t),(l=>ze(e,t,l,n,s)),(()=>je(e,l,t,Oe({[n]:s},e,t)))),Ae=e=>se(e)?El():Sl(e),Fe=e=>nt(G,e,((e,l,t)=>He(l,t)),((e,l)=>Xe(l))),He=(e,l)=>{Ql(G,e)||ll(e,1);const t=_l(G,e);l!==t&&(tl(e,t,l),lt(G,e,l))},Qe=(e,l)=>{const[t]=_l(D,e),n=t(l);return Ql(_l(W,e),n)?Qe(e,l):n},We=e=>{var l;return null!=(l=_l(W,e))?l:Me(e,{})},Ue=e=>Me(e,{}),Ge=(e,l,t)=>{const[,n]=_l(D,e);n(t),je(e,l,t,{},!0)},Ke=(e,l,t,n,s,r)=>{var o;const a=_l(null==(o=_l($,e))?void 0:o[0],s);if(!O(a)&&!r)return ze(e,t,n,s,a);const i=l=>{el(e,t,l,_l(n,l)),_e(e,t,l,-1),lt(n,l)};O(a)?i(s):et(n,i),Wl(n)&&(Ze(e,t,-1),Wl(lt(l,t))&&(Ye(e,-1),lt(W,e),lt(D,e),lt(B,e)))},Xe=e=>{const l=_l(F,e);if(!O(l))return He(e,l);tl(e,_l(G,e)),ll(e,-1),lt(G,e)},Ye=(e,l)=>Vt(o,e,l),Ze=(e,l,t)=>Vt(tt(k,e,Yl),l,t)&&lt(c,e,tt(c,e,(()=>0))+t),_e=(e,l,t,n)=>{var s;const r=_l(B,e),o=null!=(s=_l(r,t))?s:0;(0==o&&1==n||1==o&&-1==n)&&Vt(tt(i,e,Yl),t,n),lt(r,t,o!=-n?o+n:null),Vt(tt(tt(T,e,Yl),l,Yl),t,n)},el=(e,l,t,n,s)=>tt(tt(tt(S,e,Yl),l,Yl),t,(()=>[n,0]))[1]=s,ll=(e,l)=>Vt(V,e,l),tl=(e,l,t)=>tt(R,e,(()=>[l,0]))[1]=t,nl=(e,l,t,n,s)=>(U(tt(tt(tt(E,e,Yl),l,Yl),t,(()=>[])),n),s),sl=(e,l,t)=>(U(tt(j,e,(()=>[])),l),t),rl=(e,l,t)=>q(_l(_l(_l(S,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...wt(wl(e,l,t))])),ol=e=>q(_l(R,e),(([e,l])=>[!0,e,l]),(()=>[!1,...wt(Tl(e))])),al=e=>Wl(E)||Wl(he[e])?0:Kl(e?ut(E):E,((l,t)=>Kl(l,((l,n)=>Kl(l,((l,s)=>ye(he[e],[t,n,s],l))))))),il=e=>Wl(j)||Wl(me[e])?0:Kl(e?at(j):j,((l,t)=>ye(me[e],[t],l))),ul=(e,l,t)=>{if(!Wl(l))return ye(e,t,(()=>st(l))),1},dl=e=>{const l=Wl(ie[e]),t=Wl(de[e])&&Wl(_[e])&&Wl(ee[e])&&Wl(ae[e])&&l&&Wl(X[e]),n=Wl(ce[e])&&Wl(ue[e])&&Wl(Y[e])&&Wl(K[e]);if(!t||!n){const s=e?[at(o),it(i),at(c),it(k),ut(T),ut(S)]:[o,i,c,k,T,S];if(!t){ul(X[e],s[0]),Kl(s[1],((l,t)=>ul(_[e],l,[t]))),Kl(s[2],((l,t)=>{0!=l&&ye(ee[e],[t],vl(t))}));const t=vt();Kl(s[3],((n,s)=>{ul(ae[e],n,[s])&&!l&&(ye(ie[e],[s,null]),ft(t,s))})),l||Kl(s[5],((l,n)=>{if(!Ql(t,n)){const t=vt();Kl(l,(e=>Kl(e,(([l,n],s)=>n!==l?ft(t,s):Xl(e,s))))),Kl(t,(l=>ye(ie[e],[n,l])))}})),Kl(s[4],((l,t)=>Kl(l,((l,n)=>ul(de[e],l,[t,n])))))}if(!n){let l;Kl(s[5],((t,n)=>{let s;Kl(t,((t,r)=>{let o;Kl(t,(([t,a],i)=>{a!==t&&(ye(ce[e],[n,r,i],a,t,rl),l=s=o=1)})),o&&ye(ue[e],[n,r],rl)})),s&&ye(Y[e],[n],rl)})),l&&ye(K[e],void 0,rl)}}},cl=e=>{const l=Wl(pe[e]),t=Wl(ge[e])&&Wl(be[e]);if(!l||!t){const n=e?[at(V),at(R)]:[V,R];if(l||ul(pe[e],n[0]),!t){let l;Kl(n[1],(([t,n],s)=>{n!==t&&(ye(ge[e],[s],n,t,ol),l=1)})),l&&ye(be[e],void 0,ol)}}},hl=(e,...l)=>(jl((()=>e(...Q(l,x)))),Al),ml=()=>[st(S,((e,l)=>-1===_l(o,l)?null:st(e,((e,t)=>-1===_l(_l(k,l),t)?null:st(e,(([,e])=>null!=e?e:null),((e,l)=>xt(l)))),se)),se),st(R,(([,e])=>null!=e?e:null),((e,l)=>xt(l)))],bl=()=>({cellsTouched:t,valuesTouched:n,changedCells:ot(S,Tt,xt),invalidCells:ot(E),changedValues:st(R,Tt,xt),invalidValues:st(j),changedTableIds:st(o),changedRowIds:rt(k),changedCellIds:ot(T),changedValueIds:st(V)}),pl=()=>ot(W),gl=()=>Zl(W),vl=e=>Jl(_l(W,x(e))),fl=e=>Zl(_l(W,x(e))),Il=(e,l,t,n=0,s)=>{return Q(L((o=_l(W,x(e)),a=(e,t)=>[O(l)?t:_l(e,x(l)),t],r=([e],[l])=>{return((null!=(n=e)?n:0)<(null!=(s=l)?s:0)?-1:1)*(t?-1:1);var n,s},Q([...null!=(i=null==o?void 0:o.entries())?i:[]],(([e,l])=>a(l,e))).sort(r)),n,O(s)?s:n+s),(([,e])=>e));var r,o,a,i},yl=(e,l)=>Zl(_l(_l(W,x(e)),x(l))),wl=(e,l,t)=>_l(_l(_l(W,x(e)),x(l)),x(t)),Cl=()=>st(G),kl=()=>Zl(G),Tl=e=>_l(G,x(e)),xl=e=>hl((()=>(e=>St(e,Te,nl))(e)?Le(e):0)),Sl=e=>hl((()=>Ve(e)?Fe(e):0)),Vl=e=>{try{Ee(oe(e))}catch(e){}return Al},Rl=l=>hl((()=>{if((e=St(l,(e=>St(e,ke))))&&(Pe(l),!Wl(W))){const e=pl();ql(),xl(e)}})),Ol=e=>hl((()=>{if(l=(e=>St(e,ke))(e)){const t=Cl();Ml(),El(),l=!0,Ne(e),Sl(t)}})),ql=()=>hl((()=>Le({}))),Pl=e=>hl((e=>Ql(W,e)?Ue(e):0),e),Nl=(e,l)=>hl(((e,l)=>q(_l(W,e),(t=>Ql(t,l)?Ge(e,t,l):0))),e,l),El=()=>hl((()=>Fe({}))),Ll=()=>hl((()=>{Pe({}),e=!1})),Ml=()=>hl((()=>{Ne({}),l=!1})),jl=(e,l)=>{if(-1!=r){zl();const t=e();return $l(l),t}},zl=()=>(-1!=r&&r++,1==r&&ye(ve,void 0,ml,bl),Al),$l=e=>(r>0&&(r--,0==r&&(t=!Wl(S),n=!Wl(R),r=1,al(1),t&&dl(1),il(1),n&&cl(1),(null==e?void 0:e(ml,bl))&&(Kl(S,((e,l)=>Kl(e,((e,t)=>Kl(e,(([e],n)=>De(Al,l,t,n,e))))))),Kl(R,(([e],l)=>Be(Al,l,e))),t=n=!1),ye(fe[0],void 0,ml,bl),r=-1,al(0),t&&dl(0),il(0),n&&cl(0),ye(fe[1],void 0,ml,bl),r=0,t=n=!1,H([o,i,c,k,T,S,E,V,R,j],Gl))),Al),Al={getContent:()=>[pl(),Cl()],getTables:pl,getTableIds:gl,getTable:e=>rt(_l(W,x(e))),getTableCellIds:e=>Zl(_l(B,x(e))),getRowCount:vl,getRowIds:fl,getSortedRowIds:Il,getRow:(e,l)=>st(_l(_l(W,x(e)),x(l))),getCellIds:yl,getCell:wl,getValues:Cl,getValueIds:kl,getValue:Tl,hasTables:()=>!Wl(W),hasTable:e=>Ql(W,x(e)),hasTableCell:(e,l)=>Ql(_l(B,x(e)),x(l)),hasRow:(e,l)=>Ql(_l(W,x(e)),x(l)),hasCell:(e,l,t)=>Ql(_l(_l(W,x(e)),x(l)),x(t)),hasValues:()=>!Wl(G),hasValue:e=>Ql(G,x(e)),getTablesJson:()=>re(W),getValuesJson:()=>re(G),getJson:()=>re([W,G]),getTablesSchemaJson:()=>re(z),getValuesSchemaJson:()=>re(A),getSchemaJson:()=>re([z,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>l,setContent:([e,l])=>hl((()=>{(se(e)?ql:xl)(e),(se(l)?El:Sl)(l)})),setTables:xl,setTable:(e,l)=>hl((e=>Te(l,e)?Me(e,l):0),e),setRow:(e,l,t)=>hl(((e,l)=>xe(e,l,t)?je(e,We(e),l,t):0),e,l),addRow:(e,l,t=!0)=>jl((()=>{let n;return xe(e,n,l)&&(e=x(e),je(e,We(e),n=Qe(e,t?1:0),l)),n})),setPartialRow:(e,l,t)=>hl(((e,l)=>{if(xe(e,l,t,1)){const n=We(e);ne(t,((t,s)=>$e(e,n,l,s,t)))}}),e,l),setCell:(e,l,t,n)=>hl(((e,l,t)=>q(Se(e,l,t,N(n)?n(wl(e,l,t)):n),(n=>$e(e,We(e),l,t,n)))),e,l,t),setValues:Sl,setPartialValues:e=>hl((()=>Ve(e,1)?ne(e,((e,l)=>He(l,e))):0)),setValue:(e,l)=>hl((e=>q(Re(e,N(l)?l(Tl(e)):l),(l=>He(e,l)))),e),setTransactionChanges:e=>hl((()=>{ne(e[0],((e,l)=>O(e)?Pl(l):ne(e,((e,t)=>O(e)?Nl(l,t):ne(e,((e,n)=>De(Al,l,t,n,e))))))),ne(e[1],((e,l)=>Be(Al,l,e)))})),setTablesJson:Vl,setValuesJson:e=>{try{Ae(oe(e))}catch(e){}return Al},setJson:e=>hl((()=>{try{const[l,t]=oe(e);Ee(l),Ae(t)}catch(l){Vl(e)}})),setTablesSchema:Rl,setValuesSchema:Ol,setSchema:(e,l)=>hl((()=>{Rl(e),Ol(l)})),delTables:ql,delTable:Pl,delRow:Nl,delCell:(e,l,t,n)=>hl(((e,l,t)=>q(_l(W,e),(s=>q(_l(s,l),(r=>Ql(r,t)?Ke(e,s,l,r,t,n):0))))),e,l,t),delValues:El,delValue:e=>hl((e=>Ql(G,e)?Xe(e):0),e),delTablesSchema:Ll,delValuesSchema:Ml,delSchema:()=>hl((()=>{Ll(),Ml()})),transaction:jl,startTransaction:zl,finishTransaction:$l,forEachTable:e=>Kl(W,((l,t)=>e(t,(e=>Kl(l,((l,t)=>e(t,(e=>et(l,e))))))))),forEachTableCell:(e,l)=>et(_l(B,x(e)),l),forEachRow:(e,l)=>Kl(_l(W,x(e)),((e,t)=>l(t,(l=>et(e,l))))),forEachCell:(e,l,t)=>et(_l(_l(W,x(e)),x(l)),t),forEachValue:e=>et(G,e),addSortedRowIdsListener:(e,l,t,n,s,r,o)=>{let a=Il(e,l,t,n,s);return Ie((()=>{const o=Il(e,l,t,n,s);var i,u,d;u=a,M(i=o)===M(u)&&(d=(e,l)=>u[l]===e,i.every(d))||(a=o,r(Al,e,l,t,n,s,a))}),ie[o?1:0],[e,l],[gl])},addStartTransactionListener:e=>Ie(e,ve),addWillFinishTransactionListener:e=>Ie(e,fe[0]),addDidFinishTransactionListener:e=>Ie(e,fe[1]),callListener:e=>(Ce(e),Al),delListener:e=>(we(e),Al),getListenerStats:()=>({tables:Ct(K),tableIds:Ct(X),tableCellIds:Ct(_),table:Ct(Y),rowCount:Ct(ee),rowIds:Ct(ae),sortedRowIds:Ct(ie),row:Ct(ue,Bl),cellIds:Ct(de,Bl),cell:Ct(ce,Hl),invalidCell:Ct(he,Hl),values:Ct(be),valueIds:Ct(pe),value:Ct(ge),invalidValue:Ct(me),transaction:Dl(ve)+Ct(fe)}),createStore:Rt,addListener:Ie,callListeners:ye};return ne({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[gl]],[h+I]:[1,_,[gl]],[g]:[1,ee,[gl]],[v]:[1,ae,[gl]],[p]:[2,ue,[gl,fl]],[I]:[2,de,[gl,fl]],[f]:[3,ce,[gl,fl,yl],e=>wt(wl(...e))],InvalidCell:[3,he],[w]:[0,be],[C]:[0,pe],[y]:[1,ge,[kl],e=>wt(Tl(e[0]))],InvalidValue:[1,me]},(([e,l,t,n],s)=>{Al["add"+s+"Listener"]=(...s)=>Ie(s[e],l[s[e+1]?1:0],e>0?L(s,0,e):void 0,t,n)})),Z(Al)},Ot=({position:e="right",open:l=!1})=>{const n=t.useCreateStore(Rt),s=ue.indexOf(e);return t.useCreatePersister(n,(e=>{return((e,l,t,n)=>((e,l,t,n,s,r,o=[])=>{let a,i,u,d=0,c=0,h=0,m=0;tt(ht,o,(()=>0)),tt(mt,o,(()=>[]));const b=e=>ct(void 0,null,(function*(){return 2!=d&&(d=1,c++,yield p.schedule((()=>ct(void 0,null,(function*(){yield e(),d=0}))))),p})),p={load:(t,n)=>ct(void 0,null,(function*(){return yield b((()=>ct(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>ct(void 0,[...t],(function*(t={},s={}){return p.stopAutoLoad(),yield p.load(t,s),m=1,u=n(((t,n)=>ct(void 0,null,(function*(){if(n){const l=n();yield b((()=>ct(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield b((()=>ct(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield l())}catch(e){null==r||r(e)}}))))})))),p})),stopAutoLoad:()=>(m&&(s(u),u=void 0,m=0),p),save:l=>ct(void 0,null,(function*(){return 1!=d&&(d=2,h++,yield p.schedule((()=>ct(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}d=0}))))),p})),startAutoSave:()=>ct(void 0,null,(function*(){return yield p.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,l)=>{const[t,n]=l();se(t)&&se(n)||p.save((()=>[t,n]))})),p})),stopAutoSave:()=>(q(a,e.delListener),p),schedule:(...e)=>ct(void 0,null,(function*(){return U(_l(mt,o),...e),yield ct(void 0,null,(function*(){if(!_l(ht,o)){for(lt(ht,o,1);!O(i=G(_l(mt,o)));)try{yield i()}catch(e){null==r||r(e)}lt(ht,o,0)}})),p})),getStore:()=>e,destroy:()=>p.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(p)})(e,(()=>bt(void 0,null,(function*(){return oe(t.getItem(l))}))),(e=>bt(void 0,null,(function*(){return t.setItem(l,re(e()))}))),(e=>{const n=n=>{n.storageArea===t&&n.key===l&&e((()=>oe(n.newValue)))};return gt.addEventListener(pt,n),n}),(e=>gt.removeEventListener(pt,e)),n))(e,ae,sessionStorage,l);var l}),void 0,(e=>{return t=function*(){yield e.load(void 0,{position:-1==s?1:s,open:!!l}),yield e.startAutoSave()},new Promise(((e,l)=>{var n=e=>{try{r(t.next(e))}catch(e){l(e)}},s=e=>{try{r(t.throw(e))}catch(e){l(e)}},r=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,s);r((t=t.apply(void 0,null)).next())}));var t})),$(z,null,$("aside",{id:ae},$(Ae,{s:n}),$(Al,{s:n})),$("style",null,$e))};var qt=Object.defineProperty,Pt=Object.getOwnPropertySymbols,Nt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,Lt=(e,l,t)=>l in e?qt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;e.EditableCellView=wl,e.EditableValueView=Cl,e.RelationshipInHtmlTable=Il,e.ResultSortedTableInHtmlTable=yl,e.ResultTableInHtmlTable=e=>{var l=e,{queryId:n,queries:s,customCells:r}=l,o=el(l,["queryId","queries","customCells"]);return $(hl,_e(Ze({},o),{params:al(cl(t.useResultTableCellIds(n,s),r,t.ResultCellView),ul(s,n),t.useResultRowIds(n,s))}))},e.SliceInHtmlTable=fl,e.SortedTableInHtmlTable=gl,e.SortedTablePaginator=kl,e.StoreInspector=e=>$(Ot,((e,l)=>{for(var t in l||(l={}))Nt.call(l,t)&&Lt(e,t,l[t]);if(Pt)for(var t of Pt(l))Et.call(l,t)&&Lt(e,t,l[t]);return e})({},e)),e.TableInHtmlTable=e=>{var l=e,{tableId:n,store:s,editable:r,customCells:o}=l,a=el(l,["tableId","store","editable","customCells"]);return $(hl,_e(Ze({},a),{params:al(cl(t.useTableCellIds(n,s),o,r?wl:t.CellView),il(s,n),t.useRowIds(n,s))}))},e.ValuesInHtmlTable=vl},"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,l){"use strict";const r=e=>typeof e,a=r(""),n=r(!0),o=r(0),s="Value",i="currentTarget",d="value",u=isFinite,c=e=>null==e,{PureComponent:m,Fragment:h,createElement:b,useCallback:p,useLayoutEffect:g,useRef:f,useState:w}=t,v=(e,...t)=>c(e)?{}:e(...t),I=(e,t)=>e.map(t),y=Object,C=(e=[])=>y.fromEntries(e),k=(e,t)=>I(y.entries(e),(([e,l])=>t(l,e))),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'>",O='</svg>")',S=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\")",N=I([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,r])=>T+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${r}' fill='white'/>`+O)),V=T+"<path d='M20 20l60 60M20 80l60-60' />"+O,j=T+`<path d='${x}' />`+O,P=T+`<path d='${x}M20 20l60 60' />`+O;var z=Object.defineProperty,q=Object.defineProperties,M=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,F=(e,t,l)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,H=(e,t)=>{for(var l in t||(t={}))B.call(t,l)&&F(e,l,t[l]);if($)for(var l of $(t))E.call(t,l)&&F(e,l,t[l]);return e},D=(e,t)=>q(e,M(t));const A="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(k(D(H(D(H(D(H({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[A]:"width:0.5rem;height:0.5rem;",[A+"-track"]:"background:#111",[A+"-thumb"]:"background:#999;border:1px solid #111",[A+"-thumb:hover"]:"background:#fff",[A+"-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;"+S},C(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;"}),C(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)":S,"header>img:nth-of-type(6)":V}),C(I(N,((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":j,"details[open]>summary img.done":P,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,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?`& ${t}{${e}}`:"")));const L=(e,t,l,r)=>e==a?t:e==o?l:r;var U=Object.defineProperty,G=Object.defineProperties,J=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,X=(e,t,l)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,Y=(e,t)=>{for(var l in t||(t={}))Q.call(t,l)&&X(e,l,t[l]);if(K)for(var l of K(t))W.call(t,l)&&X(e,l,t[l]);return e},Z=(e,t)=>G(e,J(t)),_=(e,t)=>{var l={};for(var r in e)Q.call(e,r)&&t.indexOf(r)<0&&(l[r]=e[r]);if(null!=e&&K)for(var r of K(e))t.indexOf(r)<0&&W.call(e,r)&&(l[r]=e[r]);return l};const{useCallback:ee,useMemo:te,useState:le}=t,re="editable",ae=(e,t)=>I(l.useTableCellIds(e,t),(t=>e+"."+t)),ne=(e,t,l)=>{const r=ee(e,t);return l?r:void 0},oe=(...e)=>te((()=>e),e),se=(e,t)=>te((()=>({store:e,tableId:t})),[e,t]),ie=(e,t)=>te((()=>({queries:e,queryId:t})),[e,t]),de=(e,t=!1,l,r=0,a,n,o,s)=>{const[[i,d,u],c]=le([e,t,r]),m=ee((e=>{c(e),null==s||s(e)}),[s]),h=ne((e=>m([e,e==i&&!d,u])),[m,i,d,u],l),p=ee((e=>m([i,d,e])),[m,i,d]),g=!0===o?fe:o;return[[i,d,u],h,te((()=>!1===o?null:b(g,{offset:u,limit:a,total:n,onChange:p})),[o,g,u,a,n,p])]},ue=(e,t,l)=>te((()=>{const n=null!=t?t:e;return C(k(Array.isArray(n)?C(I(n,(e=>[e,e]))):n,((e,t)=>{return[t,Y(Y({},{label:t,component:l}),(n=e,r(n)==a?{label:e}:e))];var n})))}),[t,l,e]),ce=({className:e,headerRow:t,idColumn:l,params:[r,a,n,o,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(me,{sort:null!=o?o:[],label:"Id",onClick:s}),k(r,(({label:e},t)=>b(me,{key:t,cellId:t,label:e,sort:null!=o?o:[],onClick:s}))))),b("tbody",null,I(n,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),k(r,(({component:t,getComponentProps:l},r)=>b("td",{key:r},b(t,Z(Y(Y({},v(l,e,r)),a),{rowId:e,cellId:r})))))))))),me=({cellId:e,sort:[t,l],label:r=(null!=e?e:""),onClick:a})=>b("th",{onClick:ne((()=>null==a?void 0:a(e)),[a,e],a),className:c(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},c(l)||t!=e?null:(l?"↓":"↑")+" ",r),he=({localRowId:e,params:[r,a,n,o,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===r?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),k(a,(({component:t,getComponentProps:l},r)=>{const[a,s]=r.split(".",2),i=a===n?e:a===o?u:null;return c(i)?null:b("td",{key:r},b(t,Z(Y({},v(l,i,s)),{store:d,tableId:a,rowId:i,cellId:s})))})))},be=({thing:e,onThingChange:t,className:l,hasSchema:s})=>{const[c,m]=le(),[h,p]=le(),[g,f]=le(),[w,v]=le(),[I,y]=le();h!==e&&(m((e=>{const t=r(e);return(e=>e==a||e==n)(t)||t==o&&u(e)?t:void 0})(e)),p(e),f(e+""),v(Number(e)||0),y(!!e));const C=ee(((e,l)=>{l(e),p(e),t(e)}),[t]);return b("div",{className:l},b("button",{className:c,onClick:ee((()=>{if(!(null==s?void 0:s())){const e=L(c,o,n,a),l=L(e,g,w,I);m(e),p(l),t(l)}}),[s,t,g,w,I,c])},c),L(c,b("input",{key:c,value:g,onChange:ee((e=>C(e[i][d]+"",f)),[C])}),b("input",{key:c,type:"number",value:w,onChange:ee((e=>C(Number(e[i][d]||0),v)),[C])}),b("input",{key:c,type:"checkbox",checked:I,onChange:ee((e=>C(!!e[i].checked,y)),[C])})))},pe=({tableId:e,rowId:t,cellId:r,store:a,className:n})=>{var o;return b(be,{thing:l.useCell(e,t,r,a),onThingChange:l.useSetCellCallback(e,t,r,(e=>e),[],a),className:null!=n?n:re+"Cell",hasSchema:null==(o=l.useStoreOrStoreById(a))?void 0:o.hasTablesSchema})},ge=({valueId:e,store:t,className:r})=>{var a;return b(be,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:null!=r?r:re+s,hasSchema:null==(a=l.useStoreOrStoreById(t))?void 0:a.hasValuesSchema})},fe=({onChange:e,total:l,offset:r=0,limit:a=l,singular:n="row",plural:o=n+"s"})=>{(r>l||r<0)&&(r=0,e(0));const s=ne((()=>e(r-a)),[e,r,a],r>0),i=ne((()=>e(r+a)),[e,r,a],r+a<l);return b(t.Fragment,null,l>a&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==r,onClick:s},"←"),b("button",{className:"next",disabled:r+a>=l,onClick:i},"→"),r+1," to ",Math.min(l,r+a)," of "),l," ",1!=l?o:n)};(class extends m{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}).getDerivedStateFromError=()=>({e:1});const we=e=>new Map(e);we(),we(),e.EditableCellView=pe,e.EditableValueView=ge,e.RelationshipInHtmlTable=({relationshipId:e,relationships:r,editable:a,customCells:n,className:o,headerRow:s,idColumn:i=!0})=>{const[d,u,c,m]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(r),e),h=ue([...ae(c,u),...ae(m,u)],n,a?pe:l.CellView),p=oe(i,h,c,m,e,d,u);return b("table",{className:o},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,c,".Id"),b("th",null,m,".Id")),k(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,I(l.useRowIds(c,u),(e=>b(he,{key:e,localRowId:e,params:p})))))},e.ResultSortedTableInHtmlTable=e=>{var t=e,{queryId:r,cellId:a,descending:n,offset:o,limit:s,queries:i,sortOnClick:d,paginator:u=!1,customCells:c,onChange:m}=t,h=_(t,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[p,g,f]=de(a,n,d,o,s,l.useResultRowCount(r,i),u,m);return b(ce,Z(Y({},h),{params:oe(ue(l.useResultTableCellIds(r,i),c,l.ResultCellView),ie(i,r),l.useResultSortedRowIds(r,...p,s,i),p,g,f)}))},e.ResultTableInHtmlTable=e=>{var t=e,{queryId:r,queries:a,customCells:n}=t,o=_(t,["queryId","queries","customCells"]);return b(ce,Z(Y({},o),{params:oe(ue(l.useResultTableCellIds(r,a),n,l.ResultCellView),ie(a,r),l.useResultRowIds(r,a))}))},e.SliceInHtmlTable=e=>{var t=e,{indexId:r,sliceId:a,indexes:n,editable:o,customCells:s}=t,i=_(t,["indexId","sliceId","indexes","editable","customCells"]);const[d,u,c]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(l.useIndexesOrIndexesById(n),r);return b(ce,Z(Y({},i),{params:oe(ue(l.useTableCellIds(c,u),s,o?pe:l.CellView),se(u,c),l.useSliceRowIds(r,a,d))}))},e.SortedTableInHtmlTable=e=>{var t=e,{tableId:r,cellId:a,descending:n,offset:o,limit:s,store:i,editable:d,sortOnClick:u,paginator:c=!1,onChange:m,customCells:h}=t,p=_(t,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[g,f,w]=de(a,n,u,o,s,l.useRowCount(r,i),c,m);return b(ce,Z(Y({},p),{params:oe(ue(l.useTableCellIds(r,i),h,d?pe:l.CellView),se(i,r),l.useSortedRowIds(r,...g,s,i),g,f,w)}))},e.SortedTablePaginator=fe,e.StoreInspector=e=>null,e.TableInHtmlTable=e=>{var t=e,{tableId:r,store:a,editable:n,customCells:o}=t,s=_(t,["tableId","store","editable","customCells"]);return b(ce,Z(Y({},s),{params:oe(ue(l.useTableCellIds(r,a),o,n?pe:l.CellView),se(a,r),l.useRowIds(r,a))}))},e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:r=(t?ge:l.ValueView),getValueComponentProps:a,className:n,headerRow:o,idColumn:i})=>b("table",{className:n},!1===o?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,I(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(r,Z(Y({},v(a,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 r=e=>typeof e,o=r(""),a=r(!0),n=r(0),s="Value",i="currentTarget",d="value",u=isFinite,c=e=>null==e,{PureComponent:m,Fragment:h,createElement:b,useCallback:p,useLayoutEffect:g,useRef:f,useState:w}=t,y=(e,...t)=>c(e)?{}:e(...t),v=(e,t)=>e.map(t),I=Object,C=(e=[])=>I.fromEntries(e),k=(e,t)=>v(I.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",T='content:url("',R=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'>",O='</svg>")',S=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\")",N=v([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,r])=>R+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${r}' fill='white'/>`+O)),V=R+"<path d='M20 20l60 60M20 80l60-60' />"+O,j=R+`<path d='${x}' />`+O,P=R+`<path d='${x}M20 20l60 60' />`+O;var z=Object.defineProperty,q=Object.defineProperties,M=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,F=(e,t,l)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,H=(e,t)=>{for(var l in t||(t={}))B.call(t,l)&&F(e,l,t[l]);if($)for(var l of $(t))E.call(t,l)&&F(e,l,t[l]);return e},D=(e,t)=>q(e,M(t));const A="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(k(D(H(D(H(D(H({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[A]:"width:0.5rem;height:0.5rem;",[A+"-track"]:"background:#111",[A+"-thumb"]:"background:#999;border:1px solid #111",[A+"-thumb:hover"]:"background:#fff",[A+"-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;"+S},C(v(["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;"}),C(v(["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)":S,"header>img:nth-of-type(6)":V}),C(v(N,((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":j,"details[open]>summary img.done":P,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,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?`& ${t}{${e}}`:"")));const L=(e,t,l,r)=>e==o?t:e==n?l:r;var U=Object.defineProperty,G=Object.defineProperties,J=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,X=(e,t,l)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,Y=(e,t)=>{for(var l in t||(t={}))Q.call(t,l)&&X(e,l,t[l]);if(K)for(var l of K(t))W.call(t,l)&&X(e,l,t[l]);return e},Z=(e,t)=>G(e,J(t)),_=(e,t)=>{var l={};for(var r in e)Q.call(e,r)&&t.indexOf(r)<0&&(l[r]=e[r]);if(null!=e&&K)for(var r of K(e))t.indexOf(r)<0&&W.call(e,r)&&(l[r]=e[r]);return l};const{useCallback:ee,useMemo:te,useState:le}=t,re="editable",oe=(e,t)=>v(l.useTableCellIds(e,t),(t=>e+"."+t)),ae=(e,t,l)=>{const r=ee(e,t);return l?r:void 0},ne=(...e)=>te((()=>e),e),se=(e,t)=>te((()=>({store:e,tableId:t})),[e,t]),ie=(e,t)=>te((()=>({queries:e,queryId:t})),[e,t]),de=(e,t=!1,l,r=0,o,a,n,s)=>{const[[i,d,u],c]=le([e,t,r]),m=ee((e=>{c(e),null==s||s(e)}),[s]),h=ae((e=>m([e,e==i&&!d,u])),[m,i,d,u],l),p=ee((e=>m([i,d,e])),[m,i,d]),g=!0===n?fe:n;return[[i,d,u],h,te((()=>!1===n?null:b(g,{offset:u,limit:o,total:a,onChange:p})),[n,g,u,o,a,p])]},ue=(e,t,l)=>te((()=>{const a=null!=t?t:e;return C(k(Array.isArray(a)?C(v(a,(e=>[e,e]))):a,((e,t)=>{return[t,Y(Y({},{label:t,component:l}),(a=e,r(a)==o?{label:e}:e))];var a})))}),[t,l,e]),ce=({className:e,headerRow:t,idColumn:l,params:[r,o,a,n,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(me,{sort:null!=n?n:[],label:"Id",onClick:s}),k(r,(({label:e},t)=>b(me,{key:t,cellId:t,label:e,sort:null!=n?n:[],onClick:s}))))),b("tbody",null,v(a,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),k(r,(({component:t,getComponentProps:l},r)=>b("td",{key:r},b(t,Z(Y(Y({},y(l,e,r)),o),{rowId:e,cellId:r})))))))))),me=({cellId:e,sort:[t,l],label:r=(null!=e?e:""),onClick:o})=>b("th",{onClick:ae((()=>null==o?void 0:o(e)),[o,e],o),className:c(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},c(l)||t!=e?null:(l?"↓":"↑")+" ",r),he=({localRowId:e,params:[r,o,a,n,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===r?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),k(o,(({component:t,getComponentProps:l},r)=>{const[o,s]=r.split(".",2),i=o===a?e:o===n?u:null;return c(i)?null:b("td",{key:r},b(t,Z(Y({},y(l,i,s)),{store:d,tableId:o,rowId:i,cellId:s})))})))},be=({thing:e,onThingChange:t,className:l,hasSchema:s,showType:c=!0})=>{const[m,h]=le(),[p,g]=le(),[f,w]=le(),[y,v]=le(),[I,C]=le();p!==e&&(h((e=>{const t=r(e);return(e=>e==o||e==a)(t)||t==n&&u(e)?t:void 0})(e)),g(e),w(e+""),v(Number(e)||0),C(!!e));const k=ee(((e,l)=>{l(e),g(e),t(e)}),[t]),x=ee((()=>{if(!(null==s?void 0:s())){const e=L(m,n,a,o),l=L(e,f,y,I);h(e),g(l),t(l)}}),[s,t,f,y,I,m]);return b("div",{className:l},c?b("button",{className:m,onClick:x},m):null,L(m,b("input",{key:m,value:f,onChange:ee((e=>k(e[i][d]+"",w)),[k])}),b("input",{key:m,type:"number",value:y,onChange:ee((e=>k(Number(e[i][d]||0),v)),[k])}),b("input",{key:m,type:"checkbox",checked:I,onChange:ee((e=>k(!!e[i].checked,C)),[k])})))},pe=({tableId:e,rowId:t,cellId:r,store:o,className:a,showType:n})=>{var s;return b(be,{thing:l.useCell(e,t,r,o),onThingChange:l.useSetCellCallback(e,t,r,(e=>e),[],o),className:null!=a?a:re+"Cell",showType:n,hasSchema:null==(s=l.useStoreOrStoreById(o))?void 0:s.hasTablesSchema})},ge=({valueId:e,store:t,className:r,showType:o})=>{var a;return b(be,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:null!=r?r:re+s,showType:o,hasSchema:null==(a=l.useStoreOrStoreById(t))?void 0:a.hasValuesSchema})},fe=({onChange:e,total:l,offset:r=0,limit:o=l,singular:a="row",plural:n=a+"s"})=>{(r>l||r<0)&&(r=0,e(0));const s=ae((()=>e(r-o)),[e,r,o],r>0),i=ae((()=>e(r+o)),[e,r,o],r+o<l);return b(t.Fragment,null,l>o&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==r,onClick:s},"←"),b("button",{className:"next",disabled:r+o>=l,onClick:i},"→"),r+1," to ",Math.min(l,r+o)," of "),l," ",1!=l?n:a)};(class extends m{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}).getDerivedStateFromError=()=>({e:1});const we=e=>new Map(e);we(),we(),e.EditableCellView=pe,e.EditableValueView=ge,e.RelationshipInHtmlTable=({relationshipId:e,relationships:r,editable:o,customCells:a,className:n,headerRow:s,idColumn:i=!0})=>{const[d,u,c,m]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(r),e),h=ue([...oe(c,u),...oe(m,u)],a,o?pe:l.CellView),p=ne(i,h,c,m,e,d,u);return b("table",{className:n},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,c,".Id"),b("th",null,m,".Id")),k(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,v(l.useRowIds(c,u),(e=>b(he,{key:e,localRowId:e,params:p})))))},e.ResultSortedTableInHtmlTable=e=>{var t=e,{queryId:r,cellId:o,descending:a,offset:n,limit:s,queries:i,sortOnClick:d,paginator:u=!1,customCells:c,onChange:m}=t,h=_(t,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[p,g,f]=de(o,a,d,n,s,l.useResultRowCount(r,i),u,m);return b(ce,Z(Y({},h),{params:ne(ue(l.useResultTableCellIds(r,i),c,l.ResultCellView),ie(i,r),l.useResultSortedRowIds(r,...p,s,i),p,g,f)}))},e.ResultTableInHtmlTable=e=>{var t=e,{queryId:r,queries:o,customCells:a}=t,n=_(t,["queryId","queries","customCells"]);return b(ce,Z(Y({},n),{params:ne(ue(l.useResultTableCellIds(r,o),a,l.ResultCellView),ie(o,r),l.useResultRowIds(r,o))}))},e.SliceInHtmlTable=e=>{var t=e,{indexId:r,sliceId:o,indexes:a,editable:n,customCells:s}=t,i=_(t,["indexId","sliceId","indexes","editable","customCells"]);const[d,u,c]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(l.useIndexesOrIndexesById(a),r);return b(ce,Z(Y({},i),{params:ne(ue(l.useTableCellIds(c,u),s,n?pe:l.CellView),se(u,c),l.useSliceRowIds(r,o,d))}))},e.SortedTableInHtmlTable=e=>{var t=e,{tableId:r,cellId:o,descending:a,offset:n,limit:s,store:i,editable:d,sortOnClick:u,paginator:c=!1,onChange:m,customCells:h}=t,p=_(t,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[g,f,w]=de(o,a,u,n,s,l.useRowCount(r,i),c,m);return b(ce,Z(Y({},p),{params:ne(ue(l.useTableCellIds(r,i),h,d?pe:l.CellView),se(i,r),l.useSortedRowIds(r,...g,s,i),g,f,w)}))},e.SortedTablePaginator=fe,e.StoreInspector=e=>null,e.TableInHtmlTable=e=>{var t=e,{tableId:r,store:o,editable:a,customCells:n}=t,s=_(t,["tableId","store","editable","customCells"]);return b(ce,Z(Y({},s),{params:ne(ue(l.useTableCellIds(r,o),n,a?pe:l.CellView),se(o,r),l.useRowIds(r,o))}))},e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:r=(t?ge:l.ValueView),getValueComponentProps:o,className:a,headerRow:n,idColumn:i})=>b("table",{className:a},!1===n?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,v(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(r,Z(Y({},y(o,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.3.9",
3
+ "version": "4.3.11",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -228,9 +228,9 @@
228
228
  "@types/jest": "^29.5.5",
229
229
  "@types/jest-environment-puppeteer": "^5.0.4",
230
230
  "@types/less": "^3.0.4",
231
- "@types/node": "^20.7.2",
231
+ "@types/node": "^20.8.0",
232
232
  "@types/puppeteer": "^5.4.7",
233
- "@types/react": "^18.2.23",
233
+ "@types/react": "^18.2.24",
234
234
  "@types/react-dom": "^18.2.8",
235
235
  "@types/react-test-renderer": "^18.0.3",
236
236
  "@types/tmp": "^0.2.4",
@@ -250,7 +250,7 @@
250
250
  "esbuild": "^0.19.4",
251
251
  "eslint": "^8.50.0",
252
252
  "eslint-config-prettier": "^9.0.0",
253
- "eslint-plugin-jest": "^27.4.0",
253
+ "eslint-plugin-jest": "^27.4.2",
254
254
  "eslint-plugin-jsdoc": "^46.8.2",
255
255
  "eslint-plugin-react": "7.33.2",
256
256
  "eslint-plugin-react-hooks": "^4.6.0",
@@ -263,9 +263,9 @@
263
263
  "jest": "^29.7.0",
264
264
  "jest-environment-jsdom": "^29.7.0",
265
265
  "jest-fetch-mock": "^3.0.3",
266
- "jest-puppeteer": "^9.0.0",
266
+ "jest-puppeteer": "^9.0.1",
267
267
  "less": "^4.2.0",
268
- "partykit": "^0.0.24",
268
+ "partykit": "^0.0.25",
269
269
  "partysocket": "^0.0.8",
270
270
  "prettier": "^3.0.3",
271
271
  "puppeteer": "21.1.1",
@@ -289,7 +289,7 @@
289
289
  "@sqlite.org/sqlite-wasm": "^3.43.1-build1",
290
290
  "@vlcn.io/crsqlite-wasm": "^0.15.2",
291
291
  "automerge-repo": "^0.1.0",
292
- "partykit": "^0.0.23",
292
+ "partykit": "^0.0.25",
293
293
  "partysocket": "^0.0.8",
294
294
  "prettier": "^3.0.3",
295
295
  "react": "^18.2.0",
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-3"><em>NEW!</em> v4.3 release</a> <span id="one-with">&quot;The One With PartyKit&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>, and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">4.8kB - 9.2kB</a>, zero dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">Tinybase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.3.9" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://tinybase.org/guides/releases/#v4-3"><em>NEW!</em> v4.3 release</a> <span id="one-with">&quot;The One With PartyKit&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://tinybase.org/api/persister-browser">storage</a>, <a href="https://tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>, and (<em>new!</em>) <a href="https://tinybase.org/api/persister-partykit-client/">PartyKit</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">4.8kB - 9.2kB</a>, zero dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">Tinybase works great on its own, but also plays well with friends!</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://tinybase.org/react.svg"> React</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img width="48" src="https://tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img width="48" src="https://tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/4.3.11" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  const store = createStore()
@@ -247,4 +247,4 @@ export const createShop: typeof createShopDecl = () => {
247
247
  };
248
248
  ```
249
249
 
250
- <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>4.8kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.2kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.9kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>10.5kB</em>, and everything is super fast. Life&#x27;s easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>4.8kB</td><td>11.4kB</td><td>48.6kB</td><td>220.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>15.2kB</td><td>30.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.8kB</td><td>17.0kB</td><td>35.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.9kB</td><td>3.7kB</td><td>17.1kB</td><td>44.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.8kB</td><td>5.7kB</td><td>25.6kB</td><td>127.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.4kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.7kB</td><td>1.5kB</td><td>5.1kB</td><td>43.4kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>9.2kB</td><td>22.5kB</td><td>97.4kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,880</td><td>1,880</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,034</td><td>2,034</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>811</td><td>811</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>689</td><td>689</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,367</td></tr><tr><th class="right">Assertions</th><td colspan="3">15,258</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>
250
+ <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>4.8kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>9.2kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just another <em>3.9kB</em>, the auxiliary <a href="https://tinybase.org/api/tools/"><code>tools</code></a> module is <em>10.5kB</em>, and everything is super fast. Life&#x27;s easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">store</a></th><td>4.8kB</td><td>11.4kB</td><td>48.6kB</td><td>220.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics/">metrics</a></th><td>1.8kB</td><td>3.6kB</td><td>15.2kB</td><td>30.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes/">indexes</a></th><td>1.9kB</td><td>3.8kB</td><td>17.0kB</td><td>35.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships/">relationships</a></th><td>1.9kB</td><td>3.7kB</td><td>17.1kB</td><td>44.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/queries/">queries</a></th><td>2.8kB</td><td>5.7kB</td><td>25.6kB</td><td>127.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints/">checkpoints</a></th><td>1.5kB</td><td>3.1kB</td><td>12.4kB</td><td>33.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters/">persisters</a></th><td>0.7kB</td><td>1.5kB</td><td>5.1kB</td><td>43.4kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/common/">common</a></th><td>0.1kB</td><td>0.1kB</td><td>0.1kB</td><td>3.5kB</td></tr><tr><th class="right">tinybase (all)</th><td>9.2kB</td><td>22.5kB</td><td>97.4kB</td><td>0.3kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>1,880</td><td>1,880</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,034</td><td>2,034</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>811</td><td>811</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>689</td><td>689</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">3,369</td></tr><tr><th class="right">Assertions</th><td colspan="3">15,260</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img title="cancelself" src="https://github.com/cancelself.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img title="arpitBhalla" src="https://github.com/arpitBhalla.png?size=48" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/Apocalypsor" target="_blank"><img title="Apocalypsor" src="https://github.com/Apocalypsor.png?size=48" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img title="brentvatne" src="https://github.com/brentvatne.png?size=48" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img title="circadian-risk" src="https://github.com/circadian-risk.png?size=48" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img title="cubecull" src="https://github.com/cubecull.png?size=48" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img title="erwinkn" src="https://github.com/erwinkn.png?size=48" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img title="expo" src="https://github.com/expo.png?size=48" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img title="ezra-en" src="https://github.com/ezra-en.png?size=48" width="48" height="48"></a><a href="https://github.com/fdfontes" target="_blank"><img title="fdfontes" src="https://github.com/fdfontes.png?size=48" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img title="flaming-codes" src="https://github.com/flaming-codes.png?size=48" width="48" height="48"></a><a href="https://github.com/generates" target="_blank"><img title="generates" src="https://github.com/generates.png?size=48" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img title="Giulio987" src="https://github.com/Giulio987.png?size=48" width="48" height="48"></a><a href="https://github.com/jaysc" target="_blank"><img title="jaysc" src="https://github.com/jaysc.png?size=48" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img title="Kayoo-asso" src="https://github.com/Kayoo-asso.png?size=48" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img title="kotofurumiya" src="https://github.com/kotofurumiya.png?size=48" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img title="learn-anything" src="https://github.com/learn-anything.png?size=48" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img title="marksteve" src="https://github.com/marksteve.png?size=48" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img title="miking-the-viking" src="https://github.com/miking-the-viking.png?size=48" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img title="nikitavoloboev" src="https://github.com/nikitavoloboev.png?size=48" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img title="shaneosullivan" src="https://github.com/shaneosullivan.png?size=48" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img title="SuperSonicHub1" src="https://github.com/SuperSonicHub1.png?size=48" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img title="threepointone" src="https://github.com/threepointone.png?size=48" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img title="uptonking" src="https://github.com/uptonking.png?size=48" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img title="WonderPanda" src="https://github.com/WonderPanda.png?size=48" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>