tinybase 4.0.0 → 4.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/lib/cjs/tools.cjs +1 -1
  2. package/lib/cjs/tools.cjs.gz +0 -0
  3. package/lib/cjs/ui-react-dom.cjs +1 -0
  4. package/lib/cjs/ui-react-dom.cjs.gz +0 -0
  5. package/lib/cjs/ui-react.cjs +1 -1
  6. package/lib/cjs/ui-react.cjs.gz +0 -0
  7. package/lib/cjs-es6/tools.cjs +1 -1
  8. package/lib/cjs-es6/tools.cjs.gz +0 -0
  9. package/lib/cjs-es6/ui-react-dom.cjs +1 -0
  10. package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
  11. package/lib/cjs-es6/ui-react.cjs +1 -1
  12. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  13. package/lib/debug/tools.js +25 -4
  14. package/lib/debug/ui-react-dom.js +205 -0
  15. package/lib/debug/ui-react.js +21 -13
  16. package/lib/es6/tools.js +1 -1
  17. package/lib/es6/tools.js.gz +0 -0
  18. package/lib/es6/ui-react-dom.js +1 -0
  19. package/lib/es6/ui-react-dom.js.gz +0 -0
  20. package/lib/es6/ui-react.js +1 -1
  21. package/lib/es6/ui-react.js.gz +0 -0
  22. package/lib/tools.js +1 -1
  23. package/lib/tools.js.gz +0 -0
  24. package/lib/types/ui-react-dom.d.ts +544 -0
  25. package/lib/types/ui-react.d.ts +59 -18
  26. package/lib/types/with-schemas/internal/ui-react.d.ts +15 -0
  27. package/lib/types/with-schemas/ui-react-dom.d.ts +590 -0
  28. package/lib/types/with-schemas/ui-react.d.ts +44 -18
  29. package/lib/ui-react-dom.js +1 -0
  30. package/lib/ui-react-dom.js.gz +0 -0
  31. package/lib/ui-react.js +1 -1
  32. package/lib/ui-react.js.gz +0 -0
  33. package/lib/umd/tools.js +1 -1
  34. package/lib/umd/tools.js.gz +0 -0
  35. package/lib/umd/ui-react-dom.js +1 -0
  36. package/lib/umd/ui-react-dom.js.gz +0 -0
  37. package/lib/umd/ui-react.js +1 -1
  38. package/lib/umd/ui-react.js.gz +0 -0
  39. package/lib/umd-es6/tools.js +1 -1
  40. package/lib/umd-es6/tools.js.gz +0 -0
  41. package/lib/umd-es6/ui-react-dom.js +1 -0
  42. package/lib/umd-es6/ui-react-dom.js.gz +0 -0
  43. package/lib/umd-es6/ui-react.js +1 -1
  44. package/lib/umd-es6/ui-react.js.gz +0 -0
  45. package/package.json +32 -28
  46. package/readme.md +50 -33
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="tinybase",a="",n=",",o=t(a),d=t(!0),r=t(0),s="type",I="default",c="Listener",i="get",$="add",u="Ids",p="Table",b=p+"s",C=p+u,h="Row",g=h+u,f="Sorted"+h+u,m="Cell",w=m+u,y="Value",v=y+"s",T=y+u,V=(e,t)=>e.every(t),x=(e,t)=>e.sort(t),R=(e,t)=>e.forEach(t),k=(e,t=a)=>e.join(t),P=(e,t)=>e.map(t),S=e=>e.length,A=(e,t)=>e.filter(t),O=(e,...t)=>e.push(...t),E=e=>e.pop(),D=(e,...t)=>e.unshift(...t),j=e=>e.shift(),N=JSON.parse,L=isFinite,G=(e,t)=>e instanceof t,M=e=>null==e,J=e=>e==o||e==d,z=e=>t(e)==o,W=e=>Array.isArray(e),B=e=>{const l=t(e);return J(l)||l==r&&L(e)?l:void 0},F=Object,U=F.keys,_=F.freeze,Z=e=>G(e,F)&&e.constructor==F,H=(e,t)=>P(F.entries(e),(([e,l])=>t(l,e))),Q=e=>S(U(e)),q=e=>Z(e)&&0==Q(e),K=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},X=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},Y=(e,t)=>null==e?void 0:e.forEach(t),ee=(e,t)=>null==e?void 0:e.delete(t),te=e=>new Map(e),le=(e,t)=>null==e?void 0:e.get(t),ae=(e,t)=>Y(e,((e,l)=>t(l,e))),ne=(e,t)=>{var l;return P([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},oe=(e,t,l)=>M(l)?(ee(e,t),e):null==e?void 0:e.set(t,l),de=(e,t,l)=>(K(e,t)||oe(e,t,l()),le(e,t)),re=e=>e.toUpperCase(),se=e=>e.toLowerCase(),Ie="a ",ce="A function for",ie=", and registers a listener so that any changes to that result will cause a re-render",$e="Callback",ue="Del",pe="Deps",be=pe+"?: React.DependencyList",Ce="doRollback?: DoRollback",he="actions: () => Return, "+Ce,ge="export",fe="Id",me="Invalid",we="Json",ye=se(c),ve="?: ",Te=" | undefined",Ve="NonNullable",xe="Partial",Re="Props",ke="Provider",Pe=`Registers a ${ye} that will be called`,Se="Represents",Ae="rowId: "+fe,Oe="Schema",Ee="Set",De=", descending?: boolean, offset?: number, limit?: number",je="[]",Ne="the Store",Le="Transaction",Ge=Le+"Changes",Me=se(Le),Je="Execute a "+Me+" to make multiple mutations",ze="Explicitly starts a "+Me,We="Explicitly finishes a "+Me,Be="the end of the "+Me,Fe="void",Ue=" => "+Fe,_e="WhenSet",Ze=" when setting it",He=Ie+"string serialization of",Qe=" ",qe="Gets a callback that can ",Ke="the ",Xe=" the schema for",Ye=(e=0,t=0)=>`the ${ht[e]}content of`+(t?Qe+Ne:a),et=(e=0,t,l=0)=>pt[t]+Qe+Ye(e,1)+(l?" when setting it":a),tt=(e,t=0)=>Se+` a Row when ${t?"s":"g"}etting ${Ye()} the '${e}' `+p,lt=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,at=(e,t)=>`Calls a function for each ${e} in `+t,nt=e=>"The props passed to a component that renders "+e,ot=e=>"A function that takes "+e,dt=(e,t=0)=>ce+" listening to changes to "+Ct[e]+" in "+Ct[t],rt=(e,t,l=0)=>Pe+" whenever "+Ct[e]+" in "+Ct[t]+" change"+(l?a:"s"),st=e=>`the '${e}' `+p,It=e=>"the specified Row in "+st(e),ct=(e,t=0)=>pt[t]+` ${Ye()} `+st(e),it=(e,t=0)=>pt[t]+` ${Ye()} `+It(e),$t=(e,t,l=0)=>pt[l]+` the '${t}' Cell for `+It(e),ut=(e,t=0)=>pt[t]+` the '${e}' Value`,pt=["Gets","Checks existence of","Sets","Deletes","Sets part of",Se,"Gets "+He,"Sets "+He,Pe+" whenever",qe+"set",qe+"add",qe+"set part of",qe+"delete","Renders","Gets "+He+Xe,"Sets"+Xe,"Deletes"+Xe],bt=[i,"has","set","del","set","forEach",$,a],Ct=[Ne,b,Ke+p+Qe+u,Ie+p,Ke+h+Qe+u,Ie+h,Ke+m+Qe+u,Ie+m,"invalid Cell changes",v,Ke+y+Qe+u,Ie+y,"invalid Value changes",Ke+"sorted "+h+Qe+u,Ke+m+Qe+u+" anywhere"],ht=[a,"tabular ","keyed value "],gt=e=>new Set(W(e)||M(e)?e:[e]),ft=(e,t)=>null==e?void 0:e.add(t),mt=/[^A-Za-z]+/,wt=/[^A-Za-z0-9]+/,yt=/^( *)\/\*\* *(.*?) *\*\/$/gm,vt=(e,t,l)=>e.substring(t,l),Tt=e=>e.includes(n),Vt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return K(e,n)?Vt(e,t,l,a+1):(oe(e,n,l),n)},xt=e=>e.replace(yt,((e,t,l)=>{const a=77-Rt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),Rt=e=>e.length,kt=e=>e.flat(1e3),Pt=(e,t=0)=>k(P(e.split(wt),((e,l)=>(l>0||t?re:se)(vt(e,0,1))+vt(e,1)))),St=e=>re(k((e&&!mt.test(e[0])?e:" "+e).split(wt),"_")),At=e=>`/** ${e}. */`,Ot=(...e)=>k(A(e,(e=>e)),", "),Et=(...e)=>"{"+k(e,"; ")+"}",Dt=(...e)=>Et(...P(e,(e=>"readonly "+e))),jt=()=>{const e=[te(),te(),te(),te()],t=te(),l=te(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>k(kt(e),"\n"),(t,l,...a)=>R(a,(a=>R([0,1],(n=>(null!=t?t:n)==n?ft(de(e[n],l,gt),a):0)))),(e,l,n,o=a,d=1)=>Vt(t,e,[l,n,o,d]),(e,t,a)=>Vt(l,e,W(a)?[`(${t}) => {`,a,"}"]:[`(${t}) => ${a}`]),(e,t)=>le(l,e)===t?e:Vt(l,e,t),(t=0)=>P([...x(ne(e[t],((e,t)=>`import {${k(x(X(e),((e,t)=>n(e)>n(t)?1:-1)),", ")}} from '${t}';`)),((e,t)=>Tt(e)!=Tt(t)?Tt(e)?-1:1:e>t?1:-1)),a],(e=>e.replace("{React}","React"))),()=>ne(t,(([e,t,l,n],o)=>[At(t),`${n?ge+" ":a}type ${o}${l} = ${e};`,a])),()=>ne(l,((e,t)=>(e=W(e)?e:[e],O(e,E(e)+";"),[`const ${t} = ${j(e)}`,e,a])))]},Nt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Lt=(e,t,l)=>[t=>H(e,((e,a)=>t(a,Pt(a,1),l(St(a),`'${a}'`)))),(t,a)=>H(e[t],((e,t)=>a(t,e[s],e[I],l(St(t),`'${t}'`),Pt(t,1)))),e=>H(t,((t,a)=>e(a,t[s],t[I],l(St(a),`'${a}'`),Pt(a,1))))],Gt=(e,t,l,n)=>[(n,o)=>{const d=n+": "+o,r=e(b,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...l(e,((e,t,l)=>`'${e}'${M(l)?"?":a}: ${t}`)))+"}"))),et(1,5)),s=e(b+_e,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...l(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),et(1,5,1)),I=e(p+fe,"keyof "+r,"A "+p+" Id in "+Ne),i=`<TId extends ${I}>`,$=e(p,Ve+`<${r}[TId]>`,"A "+p+" in "+Ne,i),u=e(p+_e,Ve+`<${s}[TId]>`,"A "+p+" in "+Ne+Ze,i),y=e(h,$+"<TId>[Id]","A "+h+" in a "+p,i),v=e(h+_e,u+"<TId>[Id]","A "+h+" in a "+p+Ze,i),T=e(m+fe,`Extract<keyof ${y}<TId>, Id>`,"A "+m+" Id in a "+h,i),V=e(m,Ve+`<${r}[TId]>[Id][CId]`,"A "+m+" in a "+h,`<TId extends ${I}, CId extends ${T}<TId>>`),x=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,m+" Ids and types in a "+h,`<TId extends ${I}, CId = ${T}<TId>>`,0),R=e(m+$e,`(...[cellId, cell]: ${x}<TId>)`+Ue,ot(Ie+m+" Id, and "+m),i),k=e(h+$e,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Ue+") "+Ue,ot(Ie+h+" Id, and a "+m+" iterator"),i),P=e(p+m+$e,`(cellId: ${T}<TId>, count: number) `+Ue,ot(Ie+m+" Id, and count of how many times it appears"),i),S=e("TableIdForEachRowArray",`TId extends ${I} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Ue}] : never`,p+" Ids and callback types",`<TId = ${I}>`,0),A=e(p+$e,`(...[tableId, forEachRow]: ${S})`+Ue,ot(Ie+p+" Id, and a "+h+" iterator"),a),O=e("TableIdRowIdCellIdArray",`TId extends ${I} ? [tableId: TId, rowId: Id, cellId: ${T}<TId>] : never`,"Ids for GetCellChange",`<TId = ${I}>`,0),E=e("GetCellChange",`(...[tableId, rowId, cellId]: ${O}) => CellChange`,ce+" returning information about any Cell's changes during a "+Me),D=e(b+c,`(${d}, getCellChange: ${E}${Te})`+Ue,dt(1)),j=e(C+c,`(${d})`+Ue,dt(2)),N=e(p+c,`(${d}, tableId: ${I}, getCellChange: ${E}${Te})`+Ue,dt(3)),L=e(p+w+c,`(${d}, tableId: ${I})`+Ue,dt(14,3)),G=e(g+c,`(${d}, tableId: ${I})`+Ue,dt(4,3)),J=e(f+c,"("+Ot(d,"tableId: "+I,"cellId: Id"+Te,"descending: boolean","offset: number","limit: number"+Te,"sortedRowIds: Ids")+")"+Ue,dt(13,3)),z=e(h+c,"("+Ot(""+d,"tableId: "+I,Ae,`getCellChange: ${E}${Te}`)+")"+Ue,dt(5,3)),W=e(w+c,"("+Ot(""+d,"tableId: "+I,Ae)+")"+Ue,dt(6,5)),B=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${d}, tableId: TId, ${Ae}, cellId: CId, newCell: ${V}<TId, CId> ${Te}, oldCell: ${V}<TId, CId> ${Te}, getCellChange: ${E} ${Te}] : never`,"Cell args for CellListener",`<TId extends ${I}, CId = ${T}<TId>>`,0),F=e("CellListenerArgsArrayOuter",`TId extends ${I} ? `+B+"<TId> : never","Table args for CellListener",`<TId = ${I}>`,0);return[r,s,I,$,u,y,v,T,V,R,k,P,A,D,j,N,L,G,J,z,W,e(m+c,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${F})`+Ue,dt(7,5)),e(me+m+c,`(${d}, tableId: Id, ${Ae}, cellId: Id, invalidCells: any[])`+Ue,dt(8))]},(t,l)=>{const o=t+": "+l,d=e(v,Et(...n(((e,t,l)=>`'${e}'${M(l)?"?":a}: ${t}`))),et(2,5)),r=e(v+_e,Et(...n(((e,t)=>`'${e}'?: ${t}`))),et(2,5,1)),s=e(y+fe,"keyof "+d,"A "+y+" Id in "+Ne),I=e(y,Ve+`<${d}[VId]>`,"A "+y+" Id in "+Ne,`<VId extends ${s}>`),i=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${I}<VId>] : never`,y+" Ids and types in "+Ne,`<VId = ${s}>`,0),$=e(y+$e,`(...[valueId, value]: ${i})`+Ue,ot(Ie+y+" Id, and "+y)),u=e("GetValueChange",`(valueId: ${s}) => ValueChange`,ce+" returning information about any Value's changes during a "+Me),p=e(v+c,`(${o}, getValueChange: ${u}${Te})`+Ue,dt(9)),b=e(T+c,`(${o})`+Ue,dt(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${I}<VId> ${Te}, oldValue: ${I}<VId> ${Te}, getValueChange: ${u} ${Te}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,I,$,p,b,e(y+c,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Ue,dt(11)),e(me+y+c,`(${o}, valueId: Id, invalidValues: any[])`+Ue,dt(12))]},(t,l)=>e(Le+c,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Ue,ce+" listening to the completion of a "+Me)],Mt=(e,t=a,l=a)=>`store.${e}(${t})`+(l?" as "+l:a),Jt=(e,t=a)=>`fluent(() => ${Mt(e,t)})`,zt=(e,t=a,l=a)=>`store.${e}(${t?t+", ":a}proxy(listener)${l?", "+l:a})`,Wt=(e,t,n)=>{const[o,r,i,V,x,P,S,A]=jt(),[E,j,N]=Lt(e,t,x),[L,G,J]=Gt(i,E,j,N),W=te(),B=(e=0)=>ne(W,(([t,l,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${l} => ${n},`]:[r+d+`(${t}): ${l};`];return e||D(s,At(o)),O(s,a),s})),F=(e,t,l,n,o,d=a)=>Vt(W,e,[t,l,n,o,d]),U=(e,t,l,n,o,d=a,r=a,s=a)=>F(bt[e]+t+(4==e?xe:a)+l,d,n,(n==H?Jt:Mt)(bt[e]+(4==e?xe:a)+l,r,e?void 0:n),o,s),_=(e,t,l,n=a,o=a,d=1,r=a)=>F($+e+c,(n?n+", ":a)+ye+": "+t+(d?", mutator?: boolean":a),fe,zt($+e+c,o,d?"mutator":a),l,r),Z=`./${Pt(n)}.d`,H=Pt(n,1),Q=Pt(H),K=[],Y=te();let ee=[],de=[];if(r(1,Z,H,`create${H} as create${H}Decl`),q(e))r(null,l,b);else{r(0,l,"CellChange"),r(null,l,u);const[e,t,n,o,c,$,y,v,T,V,P,S,A,D,N,G,J,W,B,F,q,ae,ne]=L(Q,H),de=te();E(((e,t)=>{const l=`<'${e}'>`,a=[i(t+p,o+l,Se+` the '${e}' `+p),i(t+p+_e,c+l,Se+` the '${e}' `+p+Ze),i(t+h,$+l,tt(e)),i(t+h+_e,y+l,tt(e,1)),i(t+m+fe,v+l,`A Cell Id for the '${e}' `+p),i(t+m+$e,V+l,ot(`a Cell Id and value from a Row in the '${e}' `+p)),i(t+h+$e,P+l,ot(`a Row Id from the '${e}' Table, and a Cell iterator`)),i(t+p+m+$e,S+l,ot(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];oe(de,e,a),r(1,Z,...a)})),r(1,Z,e,t,n,v,A,D,N,G,J,W,B,F,q,ae,ne),ee=[e,t,n,v,D,N,G,J,W,B,F,q,ae,de],R([[e],[d],[H,"tables: "+t,"tables"],[H]],(([e,t,l],n)=>U(n,a,b,e,et(1,n),t,l))),U(0,a,C,n+je,lt(p,Ne)),U(5,a,p,Fe,at(p,Ne),"tableCallback: "+A,"tableCallback as any"),E(((e,t,l)=>{const[n,o,r,s,I,c,i,$]=le(de,e);R([[n],[d],[H,"table: "+o,", table"],[H]],(([n,o,d=a],r)=>U(r,t,p,n,ct(e,r),o,l+d))),U(0,t,p+w,u,lt(m,"the whole of "+st(e)),a,l),U(5,t,p+m,Fe,at(p+m,"the whole of "+st(e)),"tableCellCallback: "+$,l+", tableCellCallback as any"),U(0,t,g,u,lt(h,st(e)),a,l),U(0,t,f,u,lt(h,st(e),1),"cellId?: "+I+De,l+", cellId, descending, offset, limit"),U(5,t,h,Fe,at(h,st(e)),"rowCallback: "+i,l+", rowCallback as any"),R([[r],[d],[H,", row: "+s,", row"],[H],[H,", partialRow: "+s,", partialRow"]],(([n,o=a,d=a],r)=>U(r,t,h,n,it(e,r),Ae+o,l+", rowId"+d))),U(6,t,h,fe+Te,"Add a new Row to "+st(e),"row: "+s+", reuseIds?: boolean",l+", row, reuseIds"),U(0,t,w,I+je,lt(m,It(e)),Ae,l+", rowId"),U(5,t,m,Fe,at(m,It(e)),Ae+", cellCallback: "+c,l+", rowId, cellCallback as any"),j(e,((n,o,r,s,I)=>{const c="Map"+Pt(o,1);oe(Y,o,c);const i=o+(M(r)?Te:a);R([[i],[d],[H,`, cell: ${o} | `+c,", cell as any"],[H]],(([o,d=a,r=a],c)=>U(c,t+I,m,o,$t(e,n,c),Ae+d,l+", rowId, "+s+r))),U(1,t+I,p+m,d,pt[1]+` the '${n}' Cell anywhere in `+st(e),a,l+", "+s)}))})),U(0,a,b+we,we,et(1,6)),U(2,a,b+we,H,et(1,7),"tablesJson: "+we,"tables"+we),_(b,D,et(1,8)+" changes"),_(C,N,rt(2,0,1)),_(p,G,rt(3,0),`tableId: ${n} | null`,"tableId"),_(p+w,J,rt(14,3,1),`tableId: ${n} | null`,"tableId"),_(g,W,rt(4,3,1),`tableId: ${n} | null`,"tableId"),_(f,B,rt(13,3,1),Ot("tableId: TId",`cellId: ${v}<TId>`+Te,"descending: boolean","offset: number","limit: number"+Te),Ot("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(h,F,rt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(w,q,rt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(m,ae,rt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${k(E((e=>{var t,l;return null!=(l=null==(t=le(de,e))?void 0:t[4])?l:a}))," | ")} | null`,"tableId, rowId, cellId"),_(me+m,ne,Pe+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),r(1,Z,...X(Y)),O(K,".set"+b+Oe+"({",kt(E(((e,t,l)=>[`[${l}]: {`,...j(e,((e,t,l,n)=>`[${n}]: {[${x(St(s),`'${s}'`)}]: ${x(St(t),`'${t}'`)}${M(l)?a:`, [${x(St(I),`'${I}'`)}]: `+(z(l)?x(St(l),`'${l}'`):l)}},`)),"},"]))),"})")}if(q(t))r(null,l,v);else{const[e,t,n,o,c,i,$,u,p]=G(Q,H);r(1,Z,e,t,n,c,i,$,u,p),de=[e,t,n,i,$,u],R([[e],[d],[H,"values: "+t,"values"],[H],[H,"partialValues: "+t,"partialValues"]],(([e,t,l],n)=>U(n,a,v,e,et(2,n),t,l))),U(0,a,T,n+je,lt(y,Ne)),U(5,a,y,"void",at(y,Ne),"valueCallback: "+c,"valueCallback as any"),N(((e,t,l,n,o)=>{const r="Map"+Pt(t,1);oe(Y,t,r),R([[t],[d],[H,`value: ${t} | `+r,", value as any"],[H]],(([t,l,d=a],r)=>U(r,o,y,t,ut(e,r),l,n+d)))})),U(0,a,v+we,we,et(2,6)),U(2,a,v+we,H,et(2,7),"valuesJson: "+we,"values"+we),_(v,i,et(2,8)+" changes"),_(T,$,rt(10,0,1)),_(y,u,rt(11,0),`valueId: ${n} | null`,"valueId"),_(me+y,p,Pe+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),r(1,Z,...X(Y)),r(0,l,"ValueChange"),O(K,".set"+v+Oe+"({",N(((e,t,l,n)=>[`[${n}]: {[${x(St(s),`'${s}'`)}]: ${x(St(t),`'${t}'`)}${M(l)?a:`, [${x(St(I),`'${I}'`)}]: `+(z(l)?x(St(l),`'${l}'`):l)}},`])),"})")}U(0,a,"Content",`[${b}, ${v}]`,et(0,0)),U(2,a,"Content",H,et(0,2),`[tables, values]: [${b}, ${v}]`,"[tables, values]"),U(2,a,Ge,H,`Applies a set of ${Ge} to the Store`,"transactionChanges: "+Ge,"transactionChanges"),ae(Y,((e,t)=>i(t,`(cell: ${e}${Te}) => `+e,`Takes a ${e} Cell value and returns another`))),r(null,l,"DoRollback",fe,"IdOrNull",we,"Store",Ge),r(0,l,"Get"+Ge,"GetTransactionLog"),U(0,a,we,we,et(0,6)),U(2,a,we,H,et(0,7),"tablesAndValuesJson: "+we,"tablesAndValuesJson"),U(7,a,Me,"Return",Je,he,"actions, doRollback","<Return>"),U(7,a,"start"+Le,H,ze),U(7,a,"finish"+Le,H,We,Ce,"doRollback");const re=J(Q,H);return _("Start"+Le,re,Pe+" just before the start of the "+Me,a,a,0),_("WillFinish"+Le,re,Pe+" just before "+Be,a,a,0),_("DidFinish"+Le,re,Pe+" just after "+Be,a,a,0),U(7,a,"call"+c,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,a,c,H,"Remove a listener that was previously added to "+Ne,"listenerId: Id","listenerId"),F("getStore",a,"Store","store",pt[0]+" the underlying Store object"),r(1,l,"createStore"),r(1,Z,H,`create${H} as create${H}Decl`,re),x("store",["createStore()",...K]),V("fluent","actions: () => Store",["actions();",`return ${Q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${Q}, ...params)`),x(Q,["{",...B(1),"}"]),[o(...P(0),...S(),ge+" interface "+H+" {",...B(0),"}",a,At(`Creates a ${H} object`),ge+" function create"+H+"(): "+H+";"),o(...P(1),ge+" const create"+H+": typeof create"+H+"Decl = () => {",...A(),`return Object.freeze(${Q});`,"};"),ee,de]},Bt=e=>i+e,Ft=e=>Ot(Bt(e),Bt(e)+pe),Ut="debugIds?: boolean",_t="debugIds={debugIds}",Zt="then"+be,Ht="Parameter",Qt=": (parameter: "+Ht+", store: Store) => ",qt="const contextValue = useContext(Context);",Kt=", based on a parameter",Xt=": ",Yt="<"+Ht+",>",el=Ht+"ized"+$e+"<"+Ht+">",tl="rowId",ll="rowId={rowId}",al=", separator, debugIds",nl="separator?: ReactElement | string",ol="then?: (store: Store",dl=Ot(ol+")"+Ue,Zt),rl="then, then"+pe,sl=tl+Xt+fe,Il="View",cl=(e,...t)=>Ot(...t,ye+": "+e,ye+be,"mutator?: boolean"),il=(...e)=>Ot(...e,ye,ye+pe,"mutator"),$l=(e,t,n,o,d)=>{const[r,s,I,i,$,V,x,R]=jt(),[P,S,A]=Lt(e,t,$),E=`./${Pt(n)}.d`,j=`./${Pt(n)}-ui-react.d`,N="tinybase/ui-react",L=Pt(n,1),G=Pt(L),J=L+"Or"+L+fe,z=G+"Or"+L+fe,W=G+`={${G}}`,B=te(),F=(e,t,l,n,o,d=a)=>(s(1,j,e+" as "+e+"Decl"),Vt(B,e,[t,l,n,o,d])),U=(e,t,l,n,o,d=a)=>F("use"+e,t,l,n,o,d),_=(e,t,l,n,o=a,d=a,r=a,I=a,c=a)=>(s(1,N,`use${t} as use${t}Core`),U(e,Ot(o,X,I),l,ee+`(${z}, use${t}Core, [`+(d||a)+(c?"], ["+c:a)+"]);",n,r)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ne(B,(([t,l,n,o,d],r)=>{const s=e?[ge+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==l?"any":l} =>`,n]:[ge+` function ${r}${d}(${t}): ${1==l?"ComponentReturnType":l};`];return e||D(s,At(o)),O(s,a),s}));s(null,l,fe,"Store",$e,Ht+"ized"+$e),s(0,N,"ComponentReturnType"),s(null,N,"ExtraProps"),s(0,E,L);const Q=I(J,L+" | "+fe,`Used when you need to refer to a ${L} in a React hook or component`),K=I(ke+Re,Dt(G+ve+L,G+`ById?: {[${G}Id: Id]: ${L}}`),`Used with the ${ke} component, so that a `+L+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,j,Q,K);const X=z+ve+Q;$("{createContext, useContext, useMemo}","React"),$("Context",`createContext<[${L}?, {[${G}Id: Id]: ${L}}?]>([])`),U("Create"+L,`create: () => ${L}, create`+be,L,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${L} within a React application with convenient memoization`);const Y=U(L,"id?: Id",L+Te,["{",qt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${L} from within a ${ke} component context`),ee=i("useHook",z+`: ${Q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${G} = ${Y}(${z} as Id);`,`return hook(...preParams, ((${z} == null || typeof ${z} == 'string')`,`? ${G} : ${z})?.getStore(), ...postParams)`]),ae=i("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=i("wrap",Ot("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),de=$("NullComponent","() => null");if(!q(e)){const[e,t,n,d,r,$,y,v,T,V,x,R,A,O]=o;s(null,E,e,t,n,r,$,y,v,T,V,x,R,A),s(0,E,d),s(1,E,L),s(null,l,u,"IdOrNull");const D=i("tableView",`{${G}, rowComponent, getRowComponentProps`+al+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${oe}(rowIds.map((rowId) => (`,"<Row","{..."+ae+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",ll,W,_t,"/>","))",al,", tableId,",");"]),N=i("getDefaultTableComponent","tableId: Id",k(P(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+de),J=i("getDefaultCellComponent","tableId: Id, cellId: Id",k(P(((e,t,l)=>`tableId == ${l} ? ${k(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+de} : `)))+de);_(b,b,e,et(1,0)+ie);const z=_(C,C,n+je,lt(p,Ne)+ie);_(Ee+b+$e,Ee+b+$e,el,et(1,9)+Kt,Ot(Bt(b)+Qt+t,Bt(b)+be),Ft(b),Yt,Ot(ol,`tables: ${t})`+Ue,Zt),rl),_(ue+b+$e,ue+b+$e,$e,et(1,12),a,a,a,dl,rl);const B=I(m+Re,Dt("tableId?: TId","rowId: Id","cellId?: CId",G+ve+L,Ut),nt(Ie+m),`<TId extends ${n}, CId extends ${d}<TId>>`),F=I(h+Re,Dt("tableId?: TId","rowId: Id",G+ve+L,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${B}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,nl,Ut),nt(Ie+h),`<TId extends ${n}>`),U=I(p+Re,Dt("tableId?: TId",G+ve+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",nl,Ut),nt(Ie+p),`<TId extends ${n}>`),H=I("Sorted"+p+Re,Dt("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",G+ve+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",nl,Ut),nt(Ie+"sorted "+p),`<TId extends ${n}>`),Q=I(b+Re,Dt(G+ve+L,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${U}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,nl,Ut),nt(Ye(1,1)));s(1,j,Q,U,H,F,B),Z(b+Il,"{"+G+", tableComponents, getTableComponentProps"+al+"}: "+Q,[oe+`(${z}(${G}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+N+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ae}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,_t,"/>;","}), separator)"],et(1,13)+ie),P(((e,t,l)=>{const[n,o,d,r,I]=le(O,e);s(null,E,n,o,d,r,I),_(t+p,p,n,ct(e)+ie,a,l),_(t+p+w,p+w,u,lt(m,"the whole of "+st(e))+ie,a,l);const c=_(t+g,g,u,lt(h,st(e))+ie,a,l),i=_(t+f,f,u,lt(h,st(e),1)+ie,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",l+", cellId, descending, offset, limit");_(t+h,h,d,it(e)+ie,sl,Ot(l,tl));const $=_(t+w,w,I+je,lt(m,It(e))+ie,sl,Ot(l,tl));_(Ee+t+p+$e,Ee+p+$e,el,ct(e,9)+Kt,Ot(Bt(p)+Qt+o,Bt(p)+be),Ot(l,Ft(p)),Yt,Ot(ol,`table: ${o})`+Ue,Zt),rl),_(ue+t+p+$e,ue+p+$e,$e,ct(e,12),a,l,a,dl,rl),_(Ee+t+h+$e,Ee+h+$e,el,it(e,9)+Kt,Ot(sl,Bt(h)+Qt+r,Bt(h)+be),Ot(l,tl,Ft(h)),Yt,Ot(ol,`row: ${r})`+Ue,Zt),rl),_("Add"+t+h+$e,"Add"+h+$e,el,it(e,10)+Kt,Ot(Bt(h)+Qt+r,Bt(h)+be),Ot(l,Ft(h)),Yt,"then?: ("+Ot(sl+Te,"store: Store","row: "+r+")"+Ue,"then"+be)+", reuseRowIds?: boolean",rl+", reuseRowIds"),_(Ee+t+xe+h+$e,Ee+xe+h+$e,el,it(e,11)+Kt,Ot(sl,Bt(xe+h)+Qt+r,Bt(xe+h)+be),Ot(l,tl,Ft(xe+h)),Yt,Ot(ol,`partialRow: ${r})`+Ue,Zt),rl),_(ue+t+h+$e,ue+h+$e,$e,it(e,12),sl,Ot(l,tl),a,dl,rl);const b=Z(t+h+Il,"{rowId, "+G+", cellComponents, getCellComponentProps"+al+`}: ${F}<'${e}'>`,[oe+`(${$}(rowId, ${G}).map((cellId) => {`,"const Cell = (cellComponents?.[cellId] ?? "+J+`(${l}, cellId)) as React.ComponentType<CellProps<typeof `+l+", typeof cellId>>;","return <Cell",`{...${ae}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${l}}`,ll,"cellId={cellId}",W,_t,"/>;","})"+al+", rowId)"],it(e,13)+ie);Z(t+"Sorted"+p+Il,"{cellId, descending, offset, limit, ...props}: "+H+`<'${e}'>`,D+"(props, "+i+`(cellId, descending, offset, limit, props.${G}), ${l}, ${b});`,ct(e,13)+", sorted"+ie),Z(t+p+Il,`props: ${U}<'${e}'>`,D+"(props, "+c+`(props.${G}), ${l}, ${b});`,ct(e,13)+ie),S(e,((n,o,d,r,I)=>{const c="Map"+Pt(o,1);s(0,E,c),s(1,E,c);const i=_(t+I+m,m,o+(M(d)?Te:a),$t(e,n)+ie,sl,Ot(l,tl,r));_(Ee+t+I+m+$e,Ee+m+$e,el,$t(e,n,9)+Kt,Ot(sl,Bt(m)+Qt+o+" | "+c,Bt(m)+be),Ot(l,tl,r,Ft(m)),Yt,Ot(ol,`cell: ${o} | ${c})`+Ue,Zt),rl),_(ue+t+I+m+$e,ue+m+$e,$e,$t(e,n,12),Ot(sl,"forceDel?: boolean"),Ot(l,tl,r,"forceDel"),a,dl,rl),Z(t+I+m+Il,`{rowId, ${G}, debugIds}: `+B+`<'${e}', '${n}'>`,[oe+`('' + ${i}(rowId, `+G+`) ?? '', undefined, debugIds, ${r})`],$t(e,n,13)+ie)}))}));const q=k(P((e=>{var t,l;return null!=(l=null==(t=le(O,e))?void 0:t[4])?l:a}))," | ");_(b+c,b+c,Fe,et(1,8)+" changes",cl(r),il()),_(C+c,C+c,Fe,rt(2,0,1),cl($),il()),_(p+c,p+c,Fe,rt(3,0),cl(y,`tableId: ${n} | null`),il("tableId")),_(p+w+c,p+w+c,Fe,rt(14,3,1),cl(v,`tableId: ${n} | null`),il("tableId")),_(g+c,g+c,Fe,rt(4,3,1),cl(T,`tableId: ${n} | null`),il("tableId")),_(f+c,f+c,Fe,rt(13,3,1),cl(V,`tableId: ${n} | null`,"cellId: "+q+Te,"descending: boolean","offset: number","limit: number"+Te),il("tableId","cellId","descending","offset","limit")),_(h+c,h+c,Fe,rt(5,3),cl(x,`tableId: ${n} | null`,tl+": IdOrNull"),il("tableId",tl)),_(w+c,w+c,Fe,rt(6,5,1),cl(R,`tableId: ${n} | null`,tl+": IdOrNull"),il("tableId",tl)),_(m+c,m+c,Fe,rt(7,5),cl(A,`tableId: ${n} | null`,tl+": IdOrNull",`cellId: ${q} | null`),il("tableId",tl,"cellId"))}if(!q(t)){const[e,t,l,n,o,r]=d;s(null,E,...d),s(1,E,L);const $=i("getDefaultValueComponent","valueId: Id",k(A(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+de);_(v,v,e,et(2,0)+ie);const u=_(T,T,l+je,lt(y,Ne)+ie);_(Ee+v+$e,Ee+v+$e,el,et(2,9)+Kt,Ot(Bt(v)+Qt+t,Bt(v)+be),Ft(v),Yt,Ot(ol,`values: ${t})`+Ue,Zt),rl),_(Ee+xe+v+$e,Ee+xe+v+$e,el,et(2,11)+Kt,Ot(Bt(xe+v)+Qt+t,Bt(xe+v)+be),Ft(xe+v),Yt,Ot(ol,`partialValues: ${t})`+Ue,Zt),rl),_(ue+v+$e,ue+v+$e,$e,et(2,12),a,a,a,dl,rl);const p=I(y+Re,Dt("valueId?: VId",G+ve+L,Ut),nt("a Value"),`<VId extends ${l}>`),b=I(v+Re,Dt(G+ve+L,"valueComponents?: {readonly [VId in "+l+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${l}) => ExtraProps`,nl,Ut),nt(Ye(2,1)));s(1,j,b,p),Z(v+Il,"{"+G+", valueComponents, getValueComponentProps"+al+"}: "+b,[oe+`(${u}(${G}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+$+"(valueId);","return <Value",`{...${ae}(getValueComponentProps, valueId)}`,"key={valueId}",W,_t,"/>;","}), separator)"],et(2,13)+ie),A(((e,t,l,n,o)=>{const d="Map"+Pt(t,1);s(0,E,d),s(1,E,d);const r=_(o+y,y,t,ut(e)+ie,a,n);_(Ee+o+y+$e,Ee+y+$e,el,ut(e,9)+Kt,Ot(Bt(y)+Qt+t+" | "+d,Bt(y)+be),Ot(n,Ft(y)),Yt,Ot(ol,`value: ${t} | ${d})`+Ue,Zt),rl),_(ue+o+y+$e,ue+y+$e,$e,ut(e,12),a,n,a,dl,rl),Z(o+y+Il,`{${G}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${r}(`+G+`) ?? '', undefined, debugIds, ${n})`],ut(e,13)+ie)})),_(v+c,v+c,Fe,et(2,8)+" changes",cl(n),il()),_(T+c,T+c,Fe,rt(10,0,1),cl(o),il()),_(y+c,y+c,Fe,rt(11,0),cl(r,`valueId: ${l} | null`),il("valueId"))}return Z(ke,`{${G}, ${G}ById, children}: `+K+" & {children: React.ReactNode}",["{",qt,"return (","<Context."+ke,"value={useMemo(",`() => [${G} ?? contextValue[0], {...contextValue[1], ...${G}ById}],`,`[${G}, ${G}ById, contextValue],`,")}>","{children}",`</Context.${ke}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[r(...V(0),...x(),...H(0)),r(...V(1),...R(),...H(1))]},ul=(e,t,l)=>{if(q(e)&&q(t))return[a,a,a,a];const[n,o,d,r]=Wt(e,t,l);return[n,o,...$l(e,t,l,d,r)]};var pl=Object.defineProperty,bl=Object.defineProperties,Cl=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,gl=Object.prototype.hasOwnProperty,fl=Object.prototype.propertyIsEnumerable,ml=(e,t,l)=>t in e?pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,wl=(e,t)=>{for(var l in t||(t={}))gl.call(t,l)&&ml(e,l,t[l]);if(hl)for(var l of hl(t))fl.call(t,l)&&ml(e,l,t[l]);return e},yl=(e,t)=>bl(e,Cl(t)),vl=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{r(l.next(e))}catch(e){n(e)}},d=e=>{try{r(l.throw(e))}catch(e){n(e)}},r=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const Tl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},Vl=Nt((e=>{const t=()=>{const t=N(e.getTablesSchemaJson());return!q(t)||V(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=te();if(V(a,(t=>V(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=de(n,a,(()=>[B(o),te(),[0],0])),[r,s,[I]]=d,c=de(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),oe(s,o,c),d[3]++,r==B(o)})))))return t[l]={},Y(n,(([e,,[,n],o],d)=>{t[l][d]=wl({[s]:e},o==S(a)?{[I]:n}:{})})),1}))?t:{}},l=()=>{const t=N(e.getValuesSchemaJson());return q(t)&&e.forEachValue(((e,l)=>{t[e]={[s]:B(l)}})),t},a=e=>ul(t(),l(),e),n=e=>vl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(yield import("prettier")).format}catch(e){l=e=>e}return P(a(e),((e,a)=>xt(l(e,yl(wl({},Tl),{filepath:"_."+t[a]})))))}));return _({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let r=0,s=0;const I={};d(((e,l)=>{r++;let a=0;l((()=>a++)),s+=a,t&&(I[e]={rowCells:a})})),a+=r,n+=s,t&&(o[e]={tableRows:r,tableCells:s,rows:I})})),wl({totalTables:l,totalRows:a,totalCells:n,totalValues:S(e.getValueIds()),jsonLength:Rt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));e.createTools=Vl},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseTools={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,l="tinybase",a="",n=",",o=t(a),d=t(!0),r=t(0),s="type",I="default",c="Listener",u="get",i="add",$="Ids",p="Table",b=p+"s",C=p+$,h="Row",m=h+$,f="Sorted"+h+$,g="Cell",w=g+$,y="Value",T=y+"s",v=y+$,V=(e,t)=>e.every(t),x=(e,t)=>e.sort(t),R=(e,t)=>e.forEach(t),k=(e,t=a)=>e.join(t),P=(e,t)=>e.map(t),S=e=>e.length,A=(e,t)=>e.filter(t),O=(e,...t)=>e.push(...t),E=e=>e.pop(),D=(e,...t)=>e.unshift(...t),j=e=>e.shift(),N=JSON.parse,L=isFinite,G=(e,t)=>e instanceof t,M=e=>null==e,J=e=>e==o||e==d,z=e=>t(e)==o,W=e=>Array.isArray(e),B=e=>{const l=t(e);return J(l)||l==r&&L(e)?l:void 0},F=Object,U=F.keys,_=F.freeze,Z=e=>G(e,F)&&e.constructor==F,H=(e,t)=>P(F.entries(e),(([e,l])=>t(l,e))),Q=e=>S(U(e)),q=e=>Z(e)&&0==Q(e),K=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},X=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},Y=(e,t)=>null==e?void 0:e.forEach(t),ee=(e,t)=>null==e?void 0:e.delete(t),te=e=>new Map(e),le=(e,t)=>null==e?void 0:e.get(t),ae=(e,t)=>Y(e,((e,l)=>t(l,e))),ne=(e,t)=>{var l;return P([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},oe=(e,t,l)=>M(l)?(ee(e,t),e):null==e?void 0:e.set(t,l),de=(e,t,l)=>(K(e,t)||oe(e,t,l()),le(e,t)),re=e=>e.toUpperCase(),se=e=>e.toLowerCase(),Ie="a ",ce="A function for",ue=", and registers a listener so that any changes to that result will cause a re-render",ie="Callback",$e="Del",pe="Deps",be=pe+"?: React.DependencyList",Ce="doRollback?: DoRollback",he="actions: () => Return, "+Ce,me="export",fe="Id",ge="Invalid",we="Json",ye=se(c),Te="?: ",ve=" | undefined",Ve="NonNullable",xe="Partial",Re="Props",ke="Provider",Pe=`Registers a ${ye} that will be called`,Se="Represents",Ae="rowId: "+fe,Oe="Schema",Ee="Set",De=", descending?: boolean, offset?: number, limit?: number",je="[]",Ne="the Store",Le="Transaction",Ge=Le+"Changes",Me=se(Le),Je="Execute a "+Me+" to make multiple mutations",ze="Explicitly starts a "+Me,We="Explicitly finishes a "+Me,Be="the end of the "+Me,Fe="void",Ue=" => "+Fe,_e="WhenSet",Ze=" when setting it",He=Ie+"string serialization of",Qe=" ",qe="Gets a callback that can ",Ke="the ",Xe=" the schema for",Ye=(e=0,t=0)=>`the ${ht[e]}content of`+(t?Qe+Ne:a),et=(e=0,t,l=0)=>pt[t]+Qe+Ye(e,1)+(l?" when setting it":a),tt=(e,t=0)=>Se+` a Row when ${t?"s":"g"}etting ${Ye()} the '${e}' `+p,lt=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,at=(e,t)=>`Calls a function for each ${e} in `+t,nt=e=>"The props passed to a component that renders "+e,ot=e=>"A function that takes "+e,dt=(e,t=0)=>ce+" listening to changes to "+Ct[e]+" in "+Ct[t],rt=(e,t,l=0)=>Pe+" whenever "+Ct[e]+" in "+Ct[t]+" change"+(l?a:"s"),st=e=>`the '${e}' `+p,It=e=>"the specified Row in "+st(e),ct=(e,t=0)=>pt[t]+` ${Ye()} `+st(e),ut=(e,t=0)=>pt[t]+` ${Ye()} `+It(e),it=(e,t,l=0)=>pt[l]+` the '${t}' Cell for `+It(e),$t=(e,t=0)=>pt[t]+` the '${e}' Value`,pt=["Gets","Checks existence of","Sets","Deletes","Sets part of",Se,"Gets "+He,"Sets "+He,Pe+" whenever",qe+"set",qe+"add",qe+"set part of",qe+"delete","Renders","Gets "+He+Xe,"Sets"+Xe,"Deletes"+Xe],bt=[u,"has","set","del","set","forEach",i,a],Ct=[Ne,b,Ke+p+Qe+$,Ie+p,Ke+h+Qe+$,Ie+h,Ke+g+Qe+$,Ie+g,"invalid Cell changes",T,Ke+y+Qe+$,Ie+y,"invalid Value changes",Ke+"sorted "+h+Qe+$,Ke+g+Qe+$+" anywhere"],ht=[a,"tabular ","keyed value "],mt=e=>new Set(W(e)||M(e)?e:[e]),ft=(e,t)=>null==e?void 0:e.add(t),gt=/[^A-Za-z]+/,wt=/[^A-Za-z0-9]+/,yt=/^( *)\/\*\* *(.*?) *\*\/$/gm,Tt=(e,t,l)=>e.substring(t,l),vt=e=>e.includes(n),Vt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return K(e,n)?Vt(e,t,l,a+1):(oe(e,n,l),n)},xt=e=>e.replace(yt,((e,t,l)=>{const a=77-Rt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),Rt=e=>e.length,kt=e=>e.flat(1e3),Pt=(e,t=0)=>k(P(e.split(wt),((e,l)=>(l>0||t?re:se)(Tt(e,0,1))+Tt(e,1)))),St=e=>re(k((e&&!gt.test(e[0])?e:" "+e).split(wt),"_")),At=e=>`/** ${e}. */`,Ot=(...e)=>k(A(e,(e=>e)),", "),Et=(...e)=>"{"+k(e,"; ")+"}",Dt=(...e)=>Et(...P(e,(e=>"readonly "+e))),jt=()=>{const e=[te(),te(),te(),te()],t=te(),l=te(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>k(kt(e),"\n"),(t,l,...a)=>R(a,(a=>R([0,1],(n=>(null!=t?t:n)==n?ft(de(e[n],l,mt),a):0)))),(e,l,n,o=a,d=1)=>Vt(t,e,[l,n,o,d]),(e,t,a)=>Vt(l,e,W(a)?[`(${t}) => {`,a,"}"]:[`(${t}) => ${a}`]),(e,t)=>le(l,e)===t?e:Vt(l,e,t),(t=0)=>P([...x(ne(e[t],((e,t)=>`import {${k(x(X(e),((e,t)=>n(e)>n(t)?1:-1)),", ")}} from '${t}';`)),((e,t)=>vt(e)!=vt(t)?vt(e)?-1:1:e>t?1:-1)),a],(e=>e.replace("{React}","React"))),()=>ne(t,(([e,t,l,n],o)=>[At(t),`${n?me+" ":a}type ${o}${l} = ${e};`,a])),()=>ne(l,((e,t)=>(e=W(e)?e:[e],O(e,E(e)+";"),[`const ${t} = ${j(e)}`,e,a])))]},Nt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Lt=(e,t,l)=>[t=>H(e,((e,a)=>t(a,Pt(a,1),l(St(a),`'${a}'`)))),(t,a)=>H(e[t],((e,t)=>a(t,e[s],e[I],l(St(t),`'${t}'`),Pt(t,1)))),e=>H(t,((t,a)=>e(a,t[s],t[I],l(St(a),`'${a}'`),Pt(a,1))))],Gt=(e,t,l,n)=>[(n,o)=>{const d=n+": "+o,r=e(b,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...l(e,((e,t,l)=>`'${e}'${M(l)?"?":a}: ${t}`)))+"}"))),et(1,5)),s=e(b+_e,Et(...t((e=>`'${e}'?: {[rowId: Id]: `+Et(...l(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),et(1,5,1)),I=e(p+fe,"keyof "+r,"A "+p+" Id in "+Ne),u=`<TId extends ${I}>`,i=e(p,Ve+`<${r}[TId]>`,"A "+p+" in "+Ne,u),$=e(p+_e,Ve+`<${s}[TId]>`,"A "+p+" in "+Ne+Ze,u),y=e(h,i+"<TId>[Id]","A "+h+" in a "+p,u),T=e(h+_e,$+"<TId>[Id]","A "+h+" in a "+p+Ze,u),v=e(g+fe,`Extract<keyof ${y}<TId>, Id>`,"A "+g+" Id in a "+h,u),V=e(g,Ve+`<${r}[TId]>[Id][CId]`,"A "+g+" in a "+h,`<TId extends ${I}, CId extends ${v}<TId>>`),x=e("CellIdCellArray",`CId extends ${v}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,g+" Ids and types in a "+h,`<TId extends ${I}, CId = ${v}<TId>>`,0),R=e(g+ie,`(...[cellId, cell]: ${x}<TId>)`+Ue,ot(Ie+g+" Id, and "+g),u),k=e(h+ie,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Ue+") "+Ue,ot(Ie+h+" Id, and a "+g+" iterator"),u),P=e(p+g+ie,`(cellId: ${v}<TId>, count: number) `+Ue,ot(Ie+g+" Id, and count of how many times it appears"),u),S=e("TableIdForEachRowArray",`TId extends ${I} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Ue}] : never`,p+" Ids and callback types",`<TId = ${I}>`,0),A=e(p+ie,`(...[tableId, forEachRow]: ${S})`+Ue,ot(Ie+p+" Id, and a "+h+" iterator"),a),O=e("TableIdRowIdCellIdArray",`TId extends ${I} ? [tableId: TId, rowId: Id, cellId: ${v}<TId>] : never`,"Ids for GetCellChange",`<TId = ${I}>`,0),E=e("GetCellChange",`(...[tableId, rowId, cellId]: ${O}) => CellChange`,ce+" returning information about any Cell's changes during a "+Me),D=e(b+c,`(${d}, getCellChange: ${E}${ve})`+Ue,dt(1)),j=e(C+c,`(${d})`+Ue,dt(2)),N=e(p+c,`(${d}, tableId: ${I}, getCellChange: ${E}${ve})`+Ue,dt(3)),L=e(p+w+c,`(${d}, tableId: ${I})`+Ue,dt(14,3)),G=e(m+c,`(${d}, tableId: ${I})`+Ue,dt(4,3)),J=e(f+c,"("+Ot(d,"tableId: "+I,"cellId: Id"+ve,"descending: boolean","offset: number","limit: number"+ve,"sortedRowIds: Ids")+")"+Ue,dt(13,3)),z=e(h+c,"("+Ot(""+d,"tableId: "+I,Ae,`getCellChange: ${E}${ve}`)+")"+Ue,dt(5,3)),W=e(w+c,"("+Ot(""+d,"tableId: "+I,Ae)+")"+Ue,dt(6,5)),B=e("CellListenerArgsArrayInner",`CId extends ${v}<TId> ? [${d}, tableId: TId, ${Ae}, cellId: CId, newCell: ${V}<TId, CId> ${ve}, oldCell: ${V}<TId, CId> ${ve}, getCellChange: ${E} ${ve}] : never`,"Cell args for CellListener",`<TId extends ${I}, CId = ${v}<TId>>`,0),F=e("CellListenerArgsArrayOuter",`TId extends ${I} ? `+B+"<TId> : never","Table args for CellListener",`<TId = ${I}>`,0);return[r,s,I,i,$,y,T,v,V,R,k,P,A,D,j,N,L,G,J,z,W,e(g+c,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${F})`+Ue,dt(7,5)),e(ge+g+c,`(${d}, tableId: Id, ${Ae}, cellId: Id, invalidCells: any[])`+Ue,dt(8))]},(t,l)=>{const o=t+": "+l,d=e(T,Et(...n(((e,t,l)=>`'${e}'${M(l)?"?":a}: ${t}`))),et(2,5)),r=e(T+_e,Et(...n(((e,t)=>`'${e}'?: ${t}`))),et(2,5,1)),s=e(y+fe,"keyof "+d,"A "+y+" Id in "+Ne),I=e(y,Ve+`<${d}[VId]>`,"A "+y+" Id in "+Ne,`<VId extends ${s}>`),u=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${I}<VId>] : never`,y+" Ids and types in "+Ne,`<VId = ${s}>`,0),i=e(y+ie,`(...[valueId, value]: ${u})`+Ue,ot(Ie+y+" Id, and "+y)),$=e("GetValueChange",`(valueId: ${s}) => ValueChange`,ce+" returning information about any Value's changes during a "+Me),p=e(T+c,`(${o}, getValueChange: ${$}${ve})`+Ue,dt(9)),b=e(v+c,`(${o})`+Ue,dt(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${I}<VId> ${ve}, oldValue: ${I}<VId> ${ve}, getValueChange: ${$} ${ve}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,I,i,p,b,e(y+c,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Ue,dt(11)),e(ge+y+c,`(${o}, valueId: Id, invalidValues: any[])`+Ue,dt(12))]},(t,l)=>e(Le+c,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Ue,ce+" listening to the completion of a "+Me)],Mt=(e,t=a,l=a)=>`store.${e}(${t})`+(l?" as "+l:a),Jt=(e,t=a)=>`fluent(() => ${Mt(e,t)})`,zt=(e,t=a,l=a)=>`store.${e}(${t?t+", ":a}proxy(listener)${l?", "+l:a})`,Wt=(e,t,n)=>{const[o,r,u,V,x,P,S,A]=jt(),[E,j,N]=Lt(e,t,x),[L,G,J]=Gt(u,E,j,N),W=te(),B=(e=0)=>ne(W,(([t,l,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${l} => ${n},`]:[r+d+`(${t}): ${l};`];return e||D(s,At(o)),O(s,a),s})),F=(e,t,l,n,o,d=a)=>Vt(W,e,[t,l,n,o,d]),U=(e,t,l,n,o,d=a,r=a,s=a)=>F(bt[e]+t+(4==e?xe:a)+l,d,n,(n==H?Jt:Mt)(bt[e]+(4==e?xe:a)+l,r,e?void 0:n),o,s),_=(e,t,l,n=a,o=a,d=1,r=a)=>F(i+e+c,(n?n+", ":a)+ye+": "+t+(d?", mutator?: boolean":a),fe,zt(i+e+c,o,d?"mutator":a),l,r),Z=`./${Pt(n)}.d`,H=Pt(n,1),Q=Pt(H),K=[],Y=te();let ee=[],de=[];if(r(1,Z,H,`create${H} as create${H}Decl`),q(e))r(null,l,b);else{r(0,l,"CellChange"),r(null,l,$);const[e,t,n,o,c,i,y,T,v,V,P,S,A,D,N,G,J,W,B,F,q,ae,ne]=L(Q,H),de=te();E(((e,t)=>{const l=`<'${e}'>`,a=[u(t+p,o+l,Se+` the '${e}' `+p),u(t+p+_e,c+l,Se+` the '${e}' `+p+Ze),u(t+h,i+l,tt(e)),u(t+h+_e,y+l,tt(e,1)),u(t+g+fe,T+l,`A Cell Id for the '${e}' `+p),u(t+g+ie,V+l,ot(`a Cell Id and value from a Row in the '${e}' `+p)),u(t+h+ie,P+l,ot(`a Row Id from the '${e}' Table, and a Cell iterator`)),u(t+p+g+ie,S+l,ot(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];oe(de,e,a),r(1,Z,...a)})),r(1,Z,e,t,n,T,A,D,N,G,J,W,B,F,q,ae,ne),ee=[e,t,n,T,D,N,G,J,W,B,F,q,ae,de],R([[e],[d],[H,"tables: "+t,"tables"],[H]],(([e,t,l],n)=>U(n,a,b,e,et(1,n),t,l))),U(0,a,C,n+je,lt(p,Ne)),U(5,a,p,Fe,at(p,Ne),"tableCallback: "+A,"tableCallback as any"),E(((e,t,l)=>{const[n,o,r,s,I,c,u,i]=le(de,e);R([[n],[d],[H,"table: "+o,", table"],[H]],(([n,o,d=a],r)=>U(r,t,p,n,ct(e,r),o,l+d))),U(0,t,p+w,$,lt(g,"the whole of "+st(e)),a,l),U(5,t,p+g,Fe,at(p+g,"the whole of "+st(e)),"tableCellCallback: "+i,l+", tableCellCallback as any"),U(0,t,m,$,lt(h,st(e)),a,l),U(0,t,f,$,lt(h,st(e),1),"cellId?: "+I+De,l+", cellId, descending, offset, limit"),U(5,t,h,Fe,at(h,st(e)),"rowCallback: "+u,l+", rowCallback as any"),R([[r],[d],[H,", row: "+s,", row"],[H],[H,", partialRow: "+s,", partialRow"]],(([n,o=a,d=a],r)=>U(r,t,h,n,ut(e,r),Ae+o,l+", rowId"+d))),U(6,t,h,fe+ve,"Add a new Row to "+st(e),"row: "+s+", reuseIds?: boolean",l+", row, reuseIds"),U(0,t,w,I+je,lt(g,It(e)),Ae,l+", rowId"),U(5,t,g,Fe,at(g,It(e)),Ae+", cellCallback: "+c,l+", rowId, cellCallback as any"),j(e,((n,o,r,s,I)=>{const c="Map"+Pt(o,1);oe(Y,o,c);const u=o+(M(r)?ve:a);R([[u],[d],[H,`, cell: ${o} | `+c,", cell as any"],[H]],(([o,d=a,r=a],c)=>U(c,t+I,g,o,it(e,n,c),Ae+d,l+", rowId, "+s+r))),U(1,t+I,p+g,d,pt[1]+` the '${n}' Cell anywhere in `+st(e),a,l+", "+s)}))})),U(0,a,b+we,we,et(1,6)),U(2,a,b+we,H,et(1,7),"tablesJson: "+we,"tables"+we),_(b,D,et(1,8)+" changes"),_(C,N,rt(2,0,1)),_(p,G,rt(3,0),`tableId: ${n} | null`,"tableId"),_(p+w,J,rt(14,3,1),`tableId: ${n} | null`,"tableId"),_(m,W,rt(4,3,1),`tableId: ${n} | null`,"tableId"),_(f,B,rt(13,3,1),Ot("tableId: TId",`cellId: ${T}<TId>`+ve,"descending: boolean","offset: number","limit: number"+ve),Ot("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(h,F,rt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(w,q,rt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(g,ae,rt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${k(E((e=>{var t,l;return null!=(l=null==(t=le(de,e))?void 0:t[4])?l:a}))," | ")} | null`,"tableId, rowId, cellId"),_(ge+g,ne,Pe+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),r(1,Z,...X(Y)),O(K,".set"+b+Oe+"({",kt(E(((e,t,l)=>[`[${l}]: {`,...j(e,((e,t,l,n)=>`[${n}]: {[${x(St(s),`'${s}'`)}]: ${x(St(t),`'${t}'`)}${M(l)?a:`, [${x(St(I),`'${I}'`)}]: `+(z(l)?x(St(l),`'${l}'`):l)}},`)),"},"]))),"})")}if(q(t))r(null,l,T);else{const[e,t,n,o,c,u,i,$,p]=G(Q,H);r(1,Z,e,t,n,c,u,i,$,p),de=[e,t,n,u,i,$],R([[e],[d],[H,"values: "+t,"values"],[H],[H,"partialValues: "+t,"partialValues"]],(([e,t,l],n)=>U(n,a,T,e,et(2,n),t,l))),U(0,a,v,n+je,lt(y,Ne)),U(5,a,y,"void",at(y,Ne),"valueCallback: "+c,"valueCallback as any"),N(((e,t,l,n,o)=>{const r="Map"+Pt(t,1);oe(Y,t,r),R([[t],[d],[H,`value: ${t} | `+r,", value as any"],[H]],(([t,l,d=a],r)=>U(r,o,y,t,$t(e,r),l,n+d)))})),U(0,a,T+we,we,et(2,6)),U(2,a,T+we,H,et(2,7),"valuesJson: "+we,"values"+we),_(T,u,et(2,8)+" changes"),_(v,i,rt(10,0,1)),_(y,$,rt(11,0),`valueId: ${n} | null`,"valueId"),_(ge+y,p,Pe+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),r(1,Z,...X(Y)),r(0,l,"ValueChange"),O(K,".set"+T+Oe+"({",N(((e,t,l,n)=>[`[${n}]: {[${x(St(s),`'${s}'`)}]: ${x(St(t),`'${t}'`)}${M(l)?a:`, [${x(St(I),`'${I}'`)}]: `+(z(l)?x(St(l),`'${l}'`):l)}},`])),"})")}U(0,a,"Content",`[${b}, ${T}]`,et(0,0)),U(2,a,"Content",H,et(0,2),`[tables, values]: [${b}, ${T}]`,"[tables, values]"),U(2,a,Ge,H,`Applies a set of ${Ge} to the Store`,"transactionChanges: "+Ge,"transactionChanges"),ae(Y,((e,t)=>u(t,`(cell: ${e}${ve}) => `+e,`Takes a ${e} Cell value and returns another`))),r(null,l,"DoRollback",fe,"IdOrNull",we,"Store",Ge),r(0,l,"Get"+Ge,"GetTransactionLog"),U(0,a,we,we,et(0,6)),U(2,a,we,H,et(0,7),"tablesAndValuesJson: "+we,"tablesAndValuesJson"),U(7,a,Me,"Return",Je,he,"actions, doRollback","<Return>"),U(7,a,"start"+Le,H,ze),U(7,a,"finish"+Le,H,We,Ce,"doRollback");const re=J(Q,H);return _("Start"+Le,re,Pe+" just before the start of the "+Me,a,a,0),_("WillFinish"+Le,re,Pe+" just before "+Be,a,a,0),_("DidFinish"+Le,re,Pe+" just after "+Be,a,a,0),U(7,a,"call"+c,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,a,c,H,"Remove a listener that was previously added to "+Ne,"listenerId: Id","listenerId"),F("getStore",a,"Store","store",pt[0]+" the underlying Store object"),r(1,l,"createStore"),r(1,Z,H,`create${H} as create${H}Decl`,re),x("store",["createStore()",...K]),V("fluent","actions: () => Store",["actions();",`return ${Q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${Q}, ...params)`),x(Q,["{",...B(1),"}"]),[o(...P(0),...S(),me+" interface "+H+" {",...B(0),"}",a,At(`Creates a ${H} object`),me+" function create"+H+"(): "+H+";"),o(...P(1),me+" const create"+H+": typeof create"+H+"Decl = () => {",...A(),`return Object.freeze(${Q});`,"};"),ee,de]},Bt=e=>u+e,Ft=e=>Ot(Bt(e),Bt(e)+pe),Ut="debugIds?: boolean",_t="debugIds={debugIds}",Zt="then"+be,Ht="Parameter",Qt=": (parameter: "+Ht+", store: Store) => ",qt="const contextValue = useContext(Context);",Kt=", based on a parameter",Xt=": ",Yt="<"+Ht+",>",el=Ht+"ized"+ie+"<"+Ht+">",tl="rowId",ll="rowId={rowId}",al=", separator, debugIds",nl="separator?: ReactElement | string",ol="then?: (store: Store",dl=Ot(ol+")"+Ue,Zt),rl="then, then"+pe,sl=tl+Xt+fe,Il="View",cl=(e,...t)=>Ot(...t,ye+": "+e,ye+be,"mutator?: boolean"),ul=(...e)=>Ot(...e,ye,ye+pe,"mutator"),il=(e,t,n,o,d)=>{const[r,s,I,u,i,V,x,R]=jt(),[P,S,A]=Lt(e,t,i),E=`./${Pt(n)}.d`,j=`./${Pt(n)}-ui-react.d`,N="tinybase/ui-react",L=Pt(n,1),G=Pt(L),J=L+"Or"+L+fe,z=G+"Or"+L+fe,W=G+`={${G}}`,B=te(),F=(e,t,l,n,o,d=a)=>(s(1,j,e+" as "+e+"Decl"),Vt(B,e,[t,l,n,o,d])),U=(e,t,l,n,o,d=a)=>F("use"+e,t,l,n,o,d),_=(e,t,l,n,o=a,d=a,r=a,I=a,c=a)=>(s(1,N,`use${t} as use${t}Core`),U(e,Ot(o,X,I),l,ee+`(${z}, use${t}Core, [`+(d||a)+(c?"], ["+c:a)+"]);",n,r)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ne(B,(([t,l,n,o,d],r)=>{const s=e?[me+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==l?"any":l} =>`,n]:[me+` function ${r}${d}(${t}): ${1==l?"ComponentReturnType":l};`];return e||D(s,At(o)),O(s,a),s}));s(null,l,fe,"Store",ie,Ht+"ized"+ie),s(0,N,"ComponentReturnType"),s(1,N,"useCellIds"),s(null,N,"ExtraProps"),s(0,E,L);const Q=I(J,L+" | "+fe,`Used when you need to refer to a ${L} in a React hook or component`),K=I(ke+Re,Dt(G+Te+L,G+`ById?: {[${G}Id: Id]: ${L}}`),`Used with the ${ke} component, so that a `+L+" can be passed into the context of an application");s(0,"react","ReactElement","ComponentType"),s(1,"react","React"),s(1,j,Q,K);const X=z+Te+Q;i("{createContext, useContext, useMemo}","React"),i("Context",`createContext<[${L}?, {[${G}Id: Id]: ${L}}?]>([])`),U("Create"+L,`create: () => ${L}, create`+be,L,"\n// eslint-disable-next-line react-hooks/exhaustive-deps\nuseMemo(create, createDeps)",`Create a ${L} within a React application with convenient memoization`);const Y=U(L,"id?: Id",L+ve,["{",qt,"return id == null ? contextValue[0] : contextValue[1]?.[id];","}"],`Get a reference to a ${L} from within a ${ke} component context`),ee=u("useHook",z+`: ${Q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${G} = ${Y}(${z} as Id);`,`return hook(...preParams, ((${z} == null || typeof ${z} == 'string')`,`? ${G} : ${z})?.getStore(), ...postParams)`]),ae=u("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=u("wrap",Ot("children: any","separator?: any","encloseWithId?: boolean","id?: Id"),["const separated = separator==null || !Array.isArray(children)"," ? children"," : children.map((child, c) => (c > 0 ? [separator, child] : child));","return encloseWithId ? [id, ':{', separated, '}'] : separated;"]),de=u("useCustomOrDefaultCellIds",Ot("customCellIds: Ids | undefined","tableId: Id","rowId: Id",`${z}?: ${Q} | undefined`),[`const defaultCellIds = ${ee}(${z}, useCellIds, [tableId, rowId]);`,"return customCellIds ?? defaultCellIds;"]),re=i("NullComponent","() => null");if(!q(e)){const[e,t,n,d,r,i,y,T,v,V,x,R,A,O]=o;s(null,E,e,t,n,r,i,y,T,v,V,x,R,A),s(0,E,d),s(1,E,L),s(null,l,$,"IdOrNull");const D=u("tableView",`{${G}, rowComponent, getRowComponentProps, customCellIds`+al+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${oe}(rowIds.map((rowId) => (`,"<Row","{..."+ae+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",ll,"customCellIds={customCellIds}",W,_t,"/>","))",al,", tableId,",");"]),N=u("getDefaultTableComponent","tableId: Id",k(P(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+re),J=u("getDefaultCellComponent","tableId: Id, cellId: Id",k(P(((e,t,l)=>`tableId == ${l} ? ${k(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+re} : `)))+re);_(b,b,e,et(1,0)+ue);const z=_(C,C,n+je,lt(p,Ne)+ue);_(Ee+b+ie,Ee+b+ie,el,et(1,9)+Kt,Ot(Bt(b)+Qt+t,Bt(b)+be),Ft(b),Yt,Ot(ol,`tables: ${t})`+Ue,Zt),rl),_($e+b+ie,$e+b+ie,ie,et(1,12),a,a,a,dl,rl);const B=I(g+Re,Dt("tableId?: TId","rowId: Id","cellId?: CId",G+Te+L,Ut),nt(Ie+g),`<TId extends ${n}, CId extends ${d}<TId>>`),F=I(h+Re,Dt("tableId?: TId","rowId: Id",G+Te+L,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${B}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,`customCellIds?: ${d}<TId>[]`,nl,Ut),nt(Ie+h),`<TId extends ${n}>`),U=I(p+Re,Dt("tableId?: TId",G+Te+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",nl,Ut),nt(Ie+p),`<TId extends ${n}>`),H=I("Sorted"+p+Re,Dt("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",G+Te+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",nl,Ut),nt(Ie+"sorted "+p),`<TId extends ${n}>`),Q=I(b+Re,Dt(G+Te+L,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${U}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,nl,Ut),nt(Ye(1,1)));s(1,j,Q,U,H,F,B),Z(b+Il,"{"+G+", tableComponents, getTableComponentProps"+al+"}: "+Q,[oe+`(${z}(${G}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+N+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ae}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,_t,"/>;","}), separator)"],et(1,13)+ue),P(((e,t,l)=>{const[n,o,d,r,I]=le(O,e);s(null,E,n,o,d,r,I),_(t+p,p,n,ct(e)+ue,a,l),_(t+p+w,p+w,$,lt(g,"the whole of "+st(e))+ue,a,l);const c=_(t+m,m,$,lt(h,st(e))+ue,a,l),u=_(t+f,f,$,lt(h,st(e),1)+ue,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",l+", cellId, descending, offset, limit");_(t+h,h,d,ut(e)+ue,sl,Ot(l,tl)),_(t+w,w,I+je,lt(g,It(e))+ue,sl,Ot(l,tl)),_(Ee+t+p+ie,Ee+p+ie,el,ct(e,9)+Kt,Ot(Bt(p)+Qt+o,Bt(p)+be),Ot(l,Ft(p)),Yt,Ot(ol,`table: ${o})`+Ue,Zt),rl),_($e+t+p+ie,$e+p+ie,ie,ct(e,12),a,l,a,dl,rl),_(Ee+t+h+ie,Ee+h+ie,el,ut(e,9)+Kt,Ot(sl,Bt(h)+Qt+r,Bt(h)+be),Ot(l,tl,Ft(h)),Yt,Ot(ol,`row: ${r})`+Ue,Zt),rl),_("Add"+t+h+ie,"Add"+h+ie,el,ut(e,10)+Kt,Ot(Bt(h)+Qt+r,Bt(h)+be),Ot(l,Ft(h)),Yt,"then?: ("+Ot(sl+ve,"store: Store","row: "+r+")"+Ue,"then"+be)+", reuseRowIds?: boolean",rl+", reuseRowIds"),_(Ee+t+xe+h+ie,Ee+xe+h+ie,el,ut(e,11)+Kt,Ot(sl,Bt(xe+h)+Qt+r,Bt(xe+h)+be),Ot(l,tl,Ft(xe+h)),Yt,Ot(ol,`partialRow: ${r})`+Ue,Zt),rl),_($e+t+h+ie,$e+h+ie,ie,ut(e,12),sl,Ot(l,tl),a,dl,rl);const i=Z(t+h+Il,"{rowId, "+G+", cellComponents, getCellComponentProps, customCellIds"+al+`}: ${F}<'${e}'>`,[oe+`(${de}(customCellIds, `+l+`, rowId, ${G}).map((cellId: ${I}) => {`,"const Cell = (cellComponents?.[cellId] ?? "+J+`(${l}, cellId)) as React.ComponentType<CellProps<typeof `+l+", typeof cellId>>;","return <Cell",`{...${ae}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${l}}`,ll,"cellId={cellId}",W,_t,"/>;","})"+al+", rowId)"],ut(e,13)+ue);Z(t+"Sorted"+p+Il,"{cellId, descending, offset, limit, ...props}: "+H+`<'${e}'>`,D+"(props, "+u+`(cellId, descending, offset, limit, props.${G}), ${l}, ${i});`,ct(e,13)+", sorted"+ue),Z(t+p+Il,`props: ${U}<'${e}'>`,D+"(props, "+c+`(props.${G}), ${l}, ${i});`,ct(e,13)+ue),S(e,((n,o,d,r,I)=>{const c="Map"+Pt(o,1);s(0,E,c),s(1,E,c);const u=_(t+I+g,g,o+(M(d)?ve:a),it(e,n)+ue,sl,Ot(l,tl,r));_(Ee+t+I+g+ie,Ee+g+ie,el,it(e,n,9)+Kt,Ot(sl,Bt(g)+Qt+o+" | "+c,Bt(g)+be),Ot(l,tl,r,Ft(g)),Yt,Ot(ol,`cell: ${o} | ${c})`+Ue,Zt),rl),_($e+t+I+g+ie,$e+g+ie,ie,it(e,n,12),Ot(sl,"forceDel?: boolean"),Ot(l,tl,r,"forceDel"),a,dl,rl),Z(t+I+g+Il,`{rowId, ${G}, debugIds}: `+B+`<'${e}', '${n}'>`,[oe+`('' + ${u}(rowId, `+G+`) ?? '', undefined, debugIds, ${r})`],it(e,n,13)+ue)}))}));const q=k(P((e=>{var t,l;return null!=(l=null==(t=le(O,e))?void 0:t[4])?l:a}))," | ");_(b+c,b+c,Fe,et(1,8)+" changes",cl(r),ul()),_(C+c,C+c,Fe,rt(2,0,1),cl(i),ul()),_(p+c,p+c,Fe,rt(3,0),cl(y,`tableId: ${n} | null`),ul("tableId")),_(p+w+c,p+w+c,Fe,rt(14,3,1),cl(T,`tableId: ${n} | null`),ul("tableId")),_(m+c,m+c,Fe,rt(4,3,1),cl(v,`tableId: ${n} | null`),ul("tableId")),_(f+c,f+c,Fe,rt(13,3,1),cl(V,`tableId: ${n} | null`,"cellId: "+q+ve,"descending: boolean","offset: number","limit: number"+ve),ul("tableId","cellId","descending","offset","limit")),_(h+c,h+c,Fe,rt(5,3),cl(x,`tableId: ${n} | null`,tl+": IdOrNull"),ul("tableId",tl)),_(w+c,w+c,Fe,rt(6,5,1),cl(R,`tableId: ${n} | null`,tl+": IdOrNull"),ul("tableId",tl)),_(g+c,g+c,Fe,rt(7,5),cl(A,`tableId: ${n} | null`,tl+": IdOrNull",`cellId: ${q} | null`),ul("tableId",tl,"cellId"))}if(!q(t)){const[e,t,l,n,o,r]=d;s(null,E,...d),s(1,E,L);const i=u("getDefaultValueComponent","valueId: Id",k(A(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+re);_(T,T,e,et(2,0)+ue);const $=_(v,v,l+je,lt(y,Ne)+ue);_(Ee+T+ie,Ee+T+ie,el,et(2,9)+Kt,Ot(Bt(T)+Qt+t,Bt(T)+be),Ft(T),Yt,Ot(ol,`values: ${t})`+Ue,Zt),rl),_(Ee+xe+T+ie,Ee+xe+T+ie,el,et(2,11)+Kt,Ot(Bt(xe+T)+Qt+t,Bt(xe+T)+be),Ft(xe+T),Yt,Ot(ol,`partialValues: ${t})`+Ue,Zt),rl),_($e+T+ie,$e+T+ie,ie,et(2,12),a,a,a,dl,rl);const p=I(y+Re,Dt("valueId?: VId",G+Te+L,Ut),nt("a Value"),`<VId extends ${l}>`),b=I(T+Re,Dt(G+Te+L,"valueComponents?: {readonly [VId in "+l+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${l}) => ExtraProps`,nl,Ut),nt(Ye(2,1)));s(1,j,b,p),Z(T+Il,"{"+G+", valueComponents, getValueComponentProps"+al+"}: "+b,[oe+`(${$}(${G}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+i+"(valueId);","return <Value",`{...${ae}(getValueComponentProps, valueId)}`,"key={valueId}",W,_t,"/>;","}), separator)"],et(2,13)+ue),A(((e,t,l,n,o)=>{const d="Map"+Pt(t,1);s(0,E,d),s(1,E,d);const r=_(o+y,y,t,$t(e)+ue,a,n);_(Ee+o+y+ie,Ee+y+ie,el,$t(e,9)+Kt,Ot(Bt(y)+Qt+t+" | "+d,Bt(y)+be),Ot(n,Ft(y)),Yt,Ot(ol,`value: ${t} | ${d})`+Ue,Zt),rl),_($e+o+y+ie,$e+y+ie,ie,$t(e,12),a,n,a,dl,rl),Z(o+y+Il,`{${G}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${r}(`+G+`) ?? '', undefined, debugIds, ${n})`],$t(e,13)+ue)})),_(T+c,T+c,Fe,et(2,8)+" changes",cl(n),ul()),_(v+c,v+c,Fe,rt(10,0,1),cl(o),ul()),_(y+c,y+c,Fe,rt(11,0),cl(r,`valueId: ${l} | null`),ul("valueId"))}return Z(ke,`{${G}, ${G}ById, children}: `+K+" & {children: React.ReactNode}",["{",qt,"return (","<Context."+ke,"value={useMemo(",`() => [${G} ?? contextValue[0], {...contextValue[1], ...${G}ById}],`,`[${G}, ${G}ById, contextValue],`,")}>","{children}",`</Context.${ke}>`,");","}"],"Wraps part of an application in a context that provides default objects to be used by hooks and components within"),[r(...V(0),...x(),...H(0)),r(...V(1),...R(),...H(1))]},$l=(e,t,l)=>{if(q(e)&&q(t))return[a,a,a,a];const[n,o,d,r]=Wt(e,t,l);return[n,o,...il(e,t,l,d,r)]};var pl=Object.defineProperty,bl=Object.defineProperties,Cl=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,ml=Object.prototype.hasOwnProperty,fl=Object.prototype.propertyIsEnumerable,gl=(e,t,l)=>t in e?pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,wl=(e,t)=>{for(var l in t||(t={}))ml.call(t,l)&&gl(e,l,t[l]);if(hl)for(var l of hl(t))fl.call(t,l)&&gl(e,l,t[l]);return e},yl=(e,t)=>bl(e,Cl(t)),Tl=(e,t,l)=>new Promise(((a,n)=>{var o=e=>{try{r(l.next(e))}catch(e){n(e)}},d=e=>{try{r(l.throw(e))}catch(e){n(e)}},r=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,d);r((l=l.apply(e,t)).next())}));const vl={parser:"typescript",singleQuote:!0,trailingComma:"all",bracketSpacing:!1,jsdocSingleLineComment:!1},Vl=Nt((e=>{const t=()=>{const t=N(e.getTablesSchemaJson());return!q(t)||V(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=te();if(V(a,(t=>V(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=de(n,a,(()=>[B(o),te(),[0],0])),[r,s,[I]]=d,c=de(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),oe(s,o,c),d[3]++,r==B(o)})))))return t[l]={},Y(n,(([e,,[,n],o],d)=>{t[l][d]=wl({[s]:e},o==S(a)?{[I]:n}:{})})),1}))?t:{}},l=()=>{const t=N(e.getValuesSchemaJson());return q(t)&&e.forEachValue(((e,l)=>{t[e]={[s]:B(l)}})),t},a=e=>$l(t(),l(),e),n=e=>Tl(void 0,null,(function*(){const t=["d.ts","ts","d.ts","tsx"];let l;try{l=(yield import("prettier")).format}catch(e){l=e=>e}return P(a(e),((e,a)=>xt(l(e,yl(wl({},vl),{filepath:"_."+t[a]})))))}));return _({getStoreStats:t=>{let l=0,a=0,n=0;const o={};return e.forEachTable(((e,d)=>{l++;let r=0,s=0;const I={};d(((e,l)=>{r++;let a=0;l((()=>a++)),s+=a,t&&(I[e]={rowCells:a})})),a+=r,n+=s,t&&(o[e]={tableRows:r,tableCells:s,rows:I})})),wl({totalTables:l,totalRows:a,totalCells:n,totalValues:S(e.getValueIds()),jsonLength:Rt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));e.createTools=Vl},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseTools={});
Binary file
@@ -0,0 +1 @@
1
+ var e,l;e=this,l=function(e,l,t){"use strict";const n=(e,l)=>e.map(l),o=e=>null==e,{createContext:r,useContext:a}=t;r([]);const s=(e,...l)=>o(e)?{}:e(...l);var d=Object.defineProperty,i=Object.defineProperties,u=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,I=(e,l,t)=>l in e?d(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,p=(e,l)=>{for(var t in l||(l={}))b.call(l,t)&&I(e,t,l[t]);if(c)for(var t of c(l))f.call(l,t)&&I(e,t,l[t]);return e},m=(e,l)=>i(e,u(l)),C=(e,l)=>{var t={};for(var n in e)b.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&c)for(var n of c(e))l.indexOf(n)<0&&f.call(e,n)&&(t[n]=e[n]);return t};const{createElement:y,useCallback:g,useState:h}=t,v=(e,l,t)=>{const n=g(e,l);return t?n:void 0},w=(e,l)=>o(e)||e[0]!=l?void 0:`sorted ${e[1]?"de":"a"}scending`,k=({cellId:e,sorting:l,label:t=(null!=e?e:""),onClick:n})=>y("th",{onClick:v((()=>null==n?void 0:n(e)),[n,e],!o(n)),className:w(l,e)},t),O=({tableId:e,rowIds:t,store:o,cellComponent:r=l.CellView,getCellComponentProps:a,className:d,headerRow:i,idColumn:u,customCellIds:c,sorting:b,onHeaderThClick:f})=>{const I=l.useTableCellIds(e,o),C=null!=c?c:I;return y("table",{className:d},!1===i?null:y("thead",null,y("tr",null,!1===u?null:y(k,{sorting:b,label:"Id",onClick:f}),n(C,(e=>y(k,{key:e,cellId:e,sorting:b,onClick:f}))))),y("tbody",null,n(t,(l=>y("tr",{key:l},!1===u?null:y("th",null,l),n(C,(t=>y("td",{key:t},y(r,m(p({},s(a,l,t)),{tableId:e,rowId:l,cellId:t,store:o}))))))))))};e.SortedTableInHtmlTable=e=>{var t=e,{tableId:n,cellId:o,descending:r,offset:a,limit:s,store:d,sortOnClick:i}=t,u=C(t,["tableId","cellId","descending","offset","limit","store","sortOnClick"]);const[c,b]=h([o,!!r]),f=v((e=>b([e,e==c[0]&&!c[1]])),[c],i);return y(O,m(p({},u),{tableId:n,store:d,rowIds:l.useSortedRowIds(n,...c,a,s,d),sorting:c,onHeaderThClick:f}))},e.TableInHtmlTable=e=>{var t=e,{tableId:n,store:o}=t,r=C(t,["tableId","store"]);return y(O,m(p({},r),{tableId:n,store:o,rowIds:l.useRowIds(n,o)}))},e.ValuesInHtmlTable=({store:e,valueComponent:t=l.ValueView,getValueComponentProps:o,className:r,headerRow:a,idColumn:d})=>y("table",{className:r},!1===a?null:y("thead",null,y("tr",null,!1===d?null:y("th",null,"Id"),y("th",null,"Value"))),y("tbody",null,n(l.useValueIds(e),(l=>y("tr",{key:l},!1===d?null:y("th",null,l),y("td",null,y(t,m(p({},s(o,l)),{valueId:l,store:e}))))))))},"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("./ui-react"),require("react")):"function"==typeof define&&define.amd?define(["exports","./ui-react","react"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.TinyBaseUiReact,e.React);
Binary file
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r="Ids",u="Table",n=u+"s",d=u+r,i="Row",a=i+r,c="Sorted"+i+r,I="Cell",w=I+r,p="Value",b=p+"s",R=p+r,C=(e,s)=>e.map(s),k=e=>null==e,v=(e,s,t)=>k(e)?null==t?void 0:t():s(e),g=e=>t(e)==o,m=()=>{},{createContext:y,useContext:h}=s,f=y([]),L=(e,s)=>{const t=h(f);return k(e)?t[s]:g(e)?((e,s)=>v(e,(e=>e[s])))(t[s+1],e):e},V=(e,s)=>{const t=L(e,s);return k(e)||g(e)?t:e},S=e=>V(e,0),T=e=>V(e,2),P=e=>V(e,4),x=e=>V(e,6),q=e=>V(e,8),O=e=>V(e,10),{useCallback:B,useEffect:M,useMemo:j,useRef:D,useState:A}=s,E=(e,s,t=[])=>{const l=j((()=>s(e)),[e,...t]);return M((()=>()=>l.destroy()),[l]),l},F=(e,s,t,l=[],o)=>{const[,r]=A(),u=B((()=>{var o,r;return null!=(r=null==(o=null==s?void 0:s["get"+e])?void 0:o.call(s,...l))?r:t}),[s,...l]),[n]=A(u),d=D(n);return j((()=>d.current=u()),[u]),G(e,s,((...e)=>{d.current=k(o)?u():e[o],r([])}),[],l),d.current},G=(e,s,t,l=[],o=[],...r)=>M((()=>{var l;const u=null==(l=null==s?void 0:s["add"+e+"Listener"])?void 0:l.call(s,...o,t,...r);return()=>null==s?void 0:s.delListener(u)}),[s,...o,...l,...r]),Q=(e,s,t,l=[],o=m,r=[],...u)=>{const n=S(e);return B((e=>v(n,(l=>v(t(e,l),(e=>o(l["set"+s](...u,e),e)))))),[n,s,...l,...r,...u])},U=(e,s,t=m,l=[],...o)=>{const r=S(e);return B((()=>t(null==r?void 0:r["del"+s](...o))),[r,s,...l,...o])},z=(e,s,t)=>{const l=O(e);return B((()=>null==l?void 0:l[s](t)),[l,s,t])},H=e=>F(d,S(e),[],[]),J=(e,s)=>F(a,S(s),[],[e]),K=(e,s,t,l=0,o,r)=>F(c,S(r),[],[e,s,t,l,o],6),N=(e,s,t)=>F(w,S(t),[],[e,s]),W=(e,s,t,l)=>F(I,S(l),void 0,[e,s,t],4),X=e=>F(R,S(e),[],[]),Y=(e,s)=>F(p,S(s),void 0,[e]),Z=(e,s)=>F("Metric",T(s),void 0,[e]),$=(e,s)=>F("SliceIds",P(s),[],[e]),_=(e,s,t)=>F("SliceRowIds",P(t),[],[e,s]),ee=(e,s,t)=>F("RemoteRowId",x(t),void 0,[e,s]),se=(e,s,t)=>F("LocalRowIds",x(t),[],[e,s]),te=(e,s,t)=>F("LinkedRowIds",x(t),[],[e,s]),le=(e,s)=>F("ResultRowIds",q(s),[],[e]),oe=(e,s,t,l=0,o,r)=>F("ResultSortedRowIds",q(r),[],[e,s,t,l,o],6),re=(e,s,t)=>F("ResultCellIds",q(t),[],[e,s]),ue=(e,s,t,l)=>F("ResultCell",q(l),void 0,[e,s,t]),ne=e=>F("CheckpointIds",O(e),[[],void 0,[]]),de=(e,s)=>F("Checkpoint",O(s),void 0,[e]),ie=e=>z(e,"goBackward"),ae=e=>z(e,"goForward");var ce=Object.defineProperty,Ie=Object.defineProperties,we=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,Ce=(e,s,t)=>s in e?ce(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ke=(e,s)=>{for(var t in s||(s={}))be.call(s,t)&&Ce(e,t,s[t]);if(pe)for(var t of pe(s))Re.call(s,t)&&Ce(e,t,s[t]);return e},ve=(e,s)=>Ie(e,we(s)),ge=(e,s)=>{var t={};for(var l in e)be.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&pe)for(var l of pe(e))s.indexOf(l)<0&&Re.call(e,l)&&(t[l]=e[l]);return t};const{createElement:me,useMemo:ye}=s,he=({tableId:e,store:s,rowComponent:t=qe,getRowComponentProps:l,separator:o,debugIds:r},u)=>Pe(C(u,(o=>me(t,ve(ke({},Te(l,o)),{key:o,tableId:e,rowId:o,store:s,debugIds:r})))),o,r,e),fe=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>Pe(C(u,(o=>me(t,ve(ke({},Te(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),Le=e=>{const s=x(e);return[s,null==s?void 0:s.getStore()]},Ve=({relationshipId:e,relationships:s,rowComponent:t=qe,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i]=Le(s),a=null==d?void 0:d.getLocalTableId(e),c=u(e,n,d);return Pe(C(c,(e=>me(t,ve(ke({},Te(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},Se=e=>({checkpoints:s,checkpointComponent:t=Ae,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=O(s);return Pe(C(e(ne(u)),(e=>me(t,ve(ke({},Te(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},Te=(e,s)=>k(e)?{}:e(s),Pe=(e,s,t,l)=>{const o=k(s)||!Array.isArray(e)?e:C(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},xe=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return Pe(l+(null!=(u=W(e,s,t,o))?u:l),void 0,r,t)},qe=({tableId:e,rowId:s,store:t,cellComponent:l=xe,getCellComponentProps:o,separator:r,debugIds:u})=>Pe(C(N(e,s,t),(r=>me(l,ve(ke({},Te(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:u})))),r,u,s),Oe=e=>he(e,J(e.tableId,e.store)),Be=({valueId:e,store:s,debugIds:t})=>{var o;return Pe(l+(null!=(o=Y(e,s))?o:l),void 0,t,e)},Me=({indexId:e,sliceId:s,indexes:t,rowComponent:l=qe,getRowComponentProps:o,separator:r,debugIds:u})=>{const n=P(t),d=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),a=_(e,s,n);return Pe(C(a,(e=>me(l,ve(ke({},Te(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},je=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return Pe(l+(null!=(u=ue(e,s,t,o))?u:l),void 0,r,t)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:l=je,getResultCellComponentProps:o,separator:r,debugIds:u})=>Pe(C(re(e,s,t),(r=>me(l,ve(ke({},Te(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),Ae=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return Pe(null!=(o=de(s,e))?o:l,void 0,t,s)},Ee=Se((e=>e[0])),Fe=Se((e=>k(e[1])?[]:[e[1]])),Ge=Se((e=>e[2]));e.BackwardCheckpointsView=Ee,e.CellView=xe,e.CheckpointView=Ae,e.CurrentCheckpointView=Fe,e.ForwardCheckpointsView=Ge,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Me,getSliceComponentProps:l,separator:o,debugIds:r})=>Pe(C($(e,s),(o=>me(t,ve(ke({},Te(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>Ve(e,te,e.firstRowId),e.LocalRowsView=e=>Ve(e,se,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return Pe(null!=(o=Z(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:l,metricsById:o,indexes:r,indexesById:u,relationships:n,relationshipsById:d,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:w})=>{const p=s.useContext(f);return me(f.Provider,{value:ye((()=>[null!=e?e:p[0],ke(ke({},p[1]),t),null!=l?l:p[2],ke(ke({},p[3]),o),null!=r?r:p[4],ke(ke({},p[5]),u),null!=n?n:p[6],ke(ke({},p[7]),d),null!=i?i:p[8],ke(ke({},p[9]),a),null!=c?c:p[10],ke(ke({},p[11]),I)]),[e,t,l,o,r,u,n,d,i,a,c,I,p])},w)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=qe,getRowComponentProps:o,debugIds:r})=>{const[u,n]=Le(t),d=null==u?void 0:u.getRemoteTableId(e),i=ee(e,s,u);return Pe(k(d)||k(i)?null:me(l,ve(ke({},Te(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=je,e.ResultRowView=De,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return fe(u,oe(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>fe(e,le(e.queryId,e.queries)),e.RowView=qe,e.SliceView=Me,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=ge(s,["cellId","descending","offset","limit"]);return he(u,K(u.tableId,t,l,o,r,u.store))},e.TableView=Oe,e.TablesView=({store:e,tableComponent:s=Oe,getTableComponentProps:t,separator:l,debugIds:o})=>Pe(C(H(e),(l=>me(s,ve(ke({},Te(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=Be,e.ValuesView=({store:e,valueComponent:s=Be,getValueComponentProps:t,separator:l,debugIds:o})=>Pe(C(X(e),(l=>me(s,ve(ke({},Te(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.tableView=he,e.useAddRowCallback=(e,s,t=[],l,o=m,r=[],u=!0)=>{const n=S(l);return B((t=>v(n,(l=>v(s(t,l),(s=>o(l.addRow(e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=W,e.useCellIds=N,e.useCellIdsListener=(e,s,t,l,o,r)=>G(w,S(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>G(I,S(u),l,o,[e,s,t],r),e.useCheckpoint=de,e.useCheckpointIds=ne,e.useCheckpointIdsListener=(e,s,t)=>G("CheckpointIds",O(t),e,s),e.useCheckpointListener=(e,s,t,l)=>G("Checkpoint",O(l),s,t,[e]),e.useCheckpoints=e=>L(e,10),e.useCreateCheckpoints=(e,s,t)=>E(e,s,t),e.useCreateIndexes=(e,s,t)=>E(e,s,t),e.useCreateMetrics=(e,s,t)=>E(e,s,t),e.useCreatePersister=(e,s,t=[],l,o=[])=>{const[,r]=A(),u=j((()=>s(e)),[e,...t]);return M((()=>{var e;return e=function*(){yield null==l?void 0:l(u),r(1)},new Promise(((s,t)=>{var l=s=>{try{r(e.next(s))}catch(e){t(e)}},o=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);r((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...o]),u},e.useCreateQueries=(e,s,t)=>E(e,s,t),e.useCreateRelationships=(e,s,t)=>E(e,s,t),e.useCreateStore=(e,s=[])=>j(e,s),e.useDelCellCallback=(e,s,t,l,o,r,u)=>U(o,I,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>U(t,i,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>U(s,u,t,l,e),e.useDelTablesCallback=(e,s,t)=>U(e,n,s,t),e.useDelValueCallback=(e,s,t,l)=>U(s,p,t,l,e),e.useDelValuesCallback=(e,s,t)=>U(e,b,s,t),e.useGoBackwardCallback=ie,e.useGoForwardCallback=ae,e.useGoToCallback=(e,s=[],t,l=m,o=[])=>{const r=O(t);return B((s=>v(r,(t=>v(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useIndexes=e=>L(e,4),e.useLinkedRowIds=te,e.useLinkedRowIdsListener=(e,s,t,l,o)=>G("LinkedRowIds",x(o),t,l,[e,s]),e.useLocalRowIds=se,e.useLocalRowIdsListener=(e,s,t,l,o)=>G("LocalRowIds",x(o),t,l,[e,s]),e.useMetric=Z,e.useMetricListener=(e,s,t,l)=>G("Metric",T(l),s,t,[e]),e.useMetrics=e=>L(e,2),e.useQueries=e=>L(e,8),e.useRedoInformation=e=>{var s;const t=O(e),[,,[o]]=ne(t);return[!k(o),ae(t),o,null!=(s=v(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationships=e=>L(e,6),e.useRemoteRowId=ee,e.useRemoteRowIdListener=(e,s,t,l,o)=>G("RemoteRowId",x(o),t,l,[e,s]),e.useResultCell=ue,e.useResultCellIds=re,e.useResultCellIdsListener=(e,s,t,l,o)=>G("ResultCellIds",q(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>G("ResultCell",q(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>F("ResultRow",q(t),{},[e,s]),e.useResultRowIds=le,e.useResultRowIdsListener=(e,s,t,l)=>G("ResultRowIds",q(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>G("ResultRow",q(o),t,l,[e,s]),e.useResultSortedRowIds=oe,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,u,n)=>G("ResultSortedRowIds",q(n),r,u,[e,s,t,l,o]),e.useResultTable=(e,s)=>F("ResultTable",q(s),{},[e]),e.useResultTableListener=(e,s,t,l)=>G("ResultTable",q(l),s,t,[e]),e.useRow=(e,s,t)=>F(i,S(t),{},[e,s]),e.useRowIds=J,e.useRowIdsListener=(e,s,t,l,o)=>G(a,S(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>G(i,S(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>Q(r,I,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=m,s=[],t,l=m,o=[])=>{const r=O(t);return B((s=>v(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>Q(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>Q(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>Q(o,i,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>Q(l,u,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>Q(t,n,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>Q(l,p,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>Q(t,b,e,s,l,o),e.useSliceIds=$,e.useSliceIdsListener=(e,s,t,l)=>G("SliceIds",P(l),s,t,[e]),e.useSliceRowIds=_,e.useSliceRowIdsListener=(e,s,t,l,o)=>G("SliceRowIds",P(o),t,l,[e,s]),e.useSortedRowIds=K,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>G(c,S(d),r,u,[e,s,t,l,o],n),e.useStore=e=>L(e,0),e.useTable=(e,s)=>F(u,S(s),{},[e]),e.useTableCellIds=(e,s)=>F(u+w,S(s),[],[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>G(u+w,S(o),s,t,[e],l),e.useTableIds=H,e.useTableIdsListener=(e,s,t,l)=>G(d,S(l),e,s,[],t),e.useTableListener=(e,s,t,l,o)=>G(u,S(o),s,t,[e],l),e.useTables=e=>F(n,S(e),{}),e.useTablesListener=(e,s,t,l)=>G(n,S(l),e,s,[],t),e.useUndoInformation=e=>{var s;const t=O(e),[o,r]=ne(t);return[(u=o,!(0==(e=>e.length)(u))),ie(t),r,null!=(s=v(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=Y,e.useValueIds=X,e.useValueIdsListener=(e,s,t,l)=>G(R,S(l),e,s,[],t),e.useValueListener=(e,s,t,l,o)=>G(p,S(o),s,t,[e],l),e.useValues=e=>F(b,S(e),{}),e.useValuesListener=(e,s,t,l)=>G(b,S(l),e,s,[],t)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r="Ids",u="Table",n=u+"s",d=u+r,i="Row",a=i+r,c="Sorted"+i+r,I="Cell",w=I+r,p="Value",b=p+"s",C=p+r,R=(e,s)=>e.map(s),k=e=>null==e,v=(e,s,t)=>k(e)?null==t?void 0:t():s(e),g=e=>t(e)==o,m=()=>{},{createContext:y,useContext:h}=s,f=y([]),L=(e,s)=>{const t=h(f);return k(e)?t[s]:g(e)?((e,s)=>v(e,(e=>e[s])))(t[s+1],e):e},V=(e,s)=>{const t=L(e,s);return k(e)||g(e)?t:e},S=(e,...s)=>k(e)?{}:e(...s),T=e=>V(e,0),P=e=>V(e,2),x=e=>V(e,4),q=e=>V(e,6),O=e=>V(e,8),B=e=>V(e,10),{useCallback:M,useEffect:j,useMemo:D,useRef:A,useState:E}=s,F=(e,s,t=[])=>{const l=D((()=>s(e)),[e,...t]);return j((()=>()=>l.destroy()),[l]),l},G=(e,s,t,l=[],o)=>{const[,r]=E(),u=M((()=>{var o,r;return null!=(r=null==(o=null==s?void 0:s["get"+e])?void 0:o.call(s,...l))?r:t}),[s,...l]),[n]=E(u),d=A(n);return D((()=>d.current=u()),[u]),Q(e,s,((...e)=>{d.current=k(o)?u():e[o],r([])}),[],l),d.current},Q=(e,s,t,l=[],o=[],...r)=>j((()=>{var l;const u=null==(l=null==s?void 0:s["add"+e+"Listener"])?void 0:l.call(s,...o,t,...r);return()=>null==s?void 0:s.delListener(u)}),[s,...o,...l,...r]),U=(e,s,t,l=[],o=m,r=[],...u)=>{const n=T(e);return M((e=>v(n,(l=>v(t(e,l),(e=>o(l["set"+s](...u,e),e)))))),[n,s,...l,...r,...u])},z=(e,s,t=m,l=[],...o)=>{const r=T(e);return M((()=>t(null==r?void 0:r["del"+s](...o))),[r,s,...l,...o])},H=(e,s,t)=>{const l=B(e);return M((()=>null==l?void 0:l[s](t)),[l,s,t])},J=e=>G(d,T(e),[],[]),K=(e,s)=>G(a,T(s),[],[e]),N=(e,s,t,l=0,o,r)=>G(c,T(r),[],[e,s,t,l,o],6),W=(e,s,t)=>G(w,T(t),[],[e,s]),X=(e,s,t,l)=>G(I,T(l),void 0,[e,s,t],4),Y=e=>G(C,T(e),[],[]),Z=(e,s)=>G(p,T(s),void 0,[e]),$=(e,s)=>G("Metric",P(s),void 0,[e]),_=(e,s)=>G("SliceIds",x(s),[],[e]),ee=(e,s,t)=>G("SliceRowIds",x(t),[],[e,s]),se=(e,s,t)=>G("RemoteRowId",q(t),void 0,[e,s]),te=(e,s,t)=>G("LocalRowIds",q(t),[],[e,s]),le=(e,s,t)=>G("LinkedRowIds",q(t),[],[e,s]),oe=(e,s)=>G("ResultRowIds",O(s),[],[e]),re=(e,s,t,l=0,o,r)=>G("ResultSortedRowIds",O(r),[],[e,s,t,l,o],6),ue=(e,s,t)=>G("ResultCellIds",O(t),[],[e,s]),ne=(e,s,t,l)=>G("ResultCell",O(l),void 0,[e,s,t]),de=e=>G("CheckpointIds",B(e),[[],void 0,[]]),ie=(e,s)=>G("Checkpoint",B(s),void 0,[e]),ae=e=>H(e,"goBackward"),ce=e=>H(e,"goForward");var Ie=Object.defineProperty,we=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,ke=(e,s,t)=>s in e?Ie(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ve=(e,s)=>{for(var t in s||(s={}))Ce.call(s,t)&&ke(e,t,s[t]);if(be)for(var t of be(s))Re.call(s,t)&&ke(e,t,s[t]);return e},ge=(e,s)=>we(e,pe(s)),me=(e,s)=>{var t={};for(var l in e)Ce.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&be)for(var l of be(e))s.indexOf(l)<0&&Re.call(e,l)&&(t[l]=e[l]);return t};const{createElement:ye,useMemo:he}=s,fe=({tableId:e,store:s,rowComponent:t=qe,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>Pe(R(n,(r=>ye(t,ge(ve({},S(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),Le=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>Pe(R(u,(o=>ye(t,ge(ve({},S(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),Ve=e=>{const s=q(e);return[s,null==s?void 0:s.getStore()]},Se=({relationshipId:e,relationships:s,rowComponent:t=qe,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i]=Ve(s),a=null==d?void 0:d.getLocalTableId(e),c=u(e,n,d);return Pe(R(c,(e=>ye(t,ge(ve({},S(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},Te=e=>({checkpoints:s,checkpointComponent:t=Ae,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=B(s);return Pe(R(e(de(u)),(e=>ye(t,ge(ve({},S(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},Pe=(e,s,t,l)=>{const o=k(s)||!Array.isArray(e)?e:R(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},xe=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return Pe(l+(null!=(u=X(e,s,t,o))?u:l),void 0,r,t)},qe=({tableId:e,rowId:s,store:t,cellComponent:l=xe,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>Pe(R(((e,s,t,l)=>{const o=W(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>ye(l,ge(ve({},S(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),Oe=e=>fe(e,K(e.tableId,e.store)),Be=({valueId:e,store:s,debugIds:t})=>{var o;return Pe(l+(null!=(o=Z(e,s))?o:l),void 0,t,e)},Me=({indexId:e,sliceId:s,indexes:t,rowComponent:l=qe,getRowComponentProps:o,separator:r,debugIds:u})=>{const n=x(t),d=null==n?void 0:n.getStore(),i=null==n?void 0:n.getTableId(e),a=ee(e,s,n);return Pe(R(a,(e=>ye(l,ge(ve({},S(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},je=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return Pe(l+(null!=(u=ne(e,s,t,o))?u:l),void 0,r,t)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:l=je,getResultCellComponentProps:o,separator:r,debugIds:u})=>Pe(R(ue(e,s,t),(r=>ye(l,ge(ve({},S(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),Ae=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return Pe(null!=(o=ie(s,e))?o:l,void 0,t,s)},Ee=Te((e=>e[0])),Fe=Te((e=>k(e[1])?[]:[e[1]])),Ge=Te((e=>e[2]));e.BackwardCheckpointsView=Ee,e.CellView=xe,e.CheckpointView=Ae,e.CurrentCheckpointView=Fe,e.ForwardCheckpointsView=Ge,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Me,getSliceComponentProps:l,separator:o,debugIds:r})=>Pe(R(_(e,s),(o=>ye(t,ge(ve({},S(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>Se(e,le,e.firstRowId),e.LocalRowsView=e=>Se(e,te,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return Pe(null!=(o=$(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:t,metrics:l,metricsById:o,indexes:r,indexesById:u,relationships:n,relationshipsById:d,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:w})=>{const p=s.useContext(f);return ye(f.Provider,{value:he((()=>[null!=e?e:p[0],ve(ve({},p[1]),t),null!=l?l:p[2],ve(ve({},p[3]),o),null!=r?r:p[4],ve(ve({},p[5]),u),null!=n?n:p[6],ve(ve({},p[7]),d),null!=i?i:p[8],ve(ve({},p[9]),a),null!=c?c:p[10],ve(ve({},p[11]),I)]),[e,t,l,o,r,u,n,d,i,a,c,I,p])},w)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=qe,getRowComponentProps:o,debugIds:r})=>{const[u,n]=Ve(t),d=null==u?void 0:u.getRemoteTableId(e),i=se(e,s,u);return Pe(k(d)||k(i)?null:ye(l,ge(ve({},S(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=je,e.ResultRowView=De,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=me(s,["cellId","descending","offset","limit"]);return Le(u,re(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>Le(e,oe(e.queryId,e.queries)),e.RowView=qe,e.SliceView=Me,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=me(s,["cellId","descending","offset","limit"]);return fe(u,N(u.tableId,t,l,o,r,u.store))},e.TableView=Oe,e.TablesView=({store:e,tableComponent:s=Oe,getTableComponentProps:t,separator:l,debugIds:o})=>Pe(R(J(e),(l=>ye(s,ge(ve({},S(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=Be,e.ValuesView=({store:e,valueComponent:s=Be,getValueComponentProps:t,separator:l,debugIds:o})=>Pe(R(Y(e),(l=>ye(s,ge(ve({},S(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=[],l,o=m,r=[],u=!0)=>{const n=T(l);return M((t=>v(n,(l=>v(s(t,l),(s=>o(l.addRow(e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=X,e.useCellIds=W,e.useCellIdsListener=(e,s,t,l,o,r)=>Q(w,T(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>Q(I,T(u),l,o,[e,s,t],r),e.useCheckpoint=ie,e.useCheckpointIds=de,e.useCheckpointIdsListener=(e,s,t)=>Q("CheckpointIds",B(t),e,s),e.useCheckpointListener=(e,s,t,l)=>Q("Checkpoint",B(l),s,t,[e]),e.useCheckpoints=e=>L(e,10),e.useCreateCheckpoints=(e,s,t)=>F(e,s,t),e.useCreateIndexes=(e,s,t)=>F(e,s,t),e.useCreateMetrics=(e,s,t)=>F(e,s,t),e.useCreatePersister=(e,s,t=[],l,o=[])=>{const[,r]=E(),u=D((()=>s(e)),[e,...t]);return j((()=>{var e;return e=function*(){yield null==l?void 0:l(u),r(1)},new Promise(((s,t)=>{var l=s=>{try{r(e.next(s))}catch(e){t(e)}},o=s=>{try{r(e.throw(s))}catch(e){t(e)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,o);r((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...o]),u},e.useCreateQueries=(e,s,t)=>F(e,s,t),e.useCreateRelationships=(e,s,t)=>F(e,s,t),e.useCreateStore=(e,s=[])=>D(e,s),e.useDelCellCallback=(e,s,t,l,o,r,u)=>z(o,I,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>z(t,i,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>z(s,u,t,l,e),e.useDelTablesCallback=(e,s,t)=>z(e,n,s,t),e.useDelValueCallback=(e,s,t,l)=>z(s,p,t,l,e),e.useDelValuesCallback=(e,s,t)=>z(e,b,s,t),e.useGoBackwardCallback=ae,e.useGoForwardCallback=ce,e.useGoToCallback=(e,s=[],t,l=m,o=[])=>{const r=B(t);return M((s=>v(r,(t=>v(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useIndexes=e=>L(e,4),e.useLinkedRowIds=le,e.useLinkedRowIdsListener=(e,s,t,l,o)=>Q("LinkedRowIds",q(o),t,l,[e,s]),e.useLocalRowIds=te,e.useLocalRowIdsListener=(e,s,t,l,o)=>Q("LocalRowIds",q(o),t,l,[e,s]),e.useMetric=$,e.useMetricListener=(e,s,t,l)=>Q("Metric",P(l),s,t,[e]),e.useMetrics=e=>L(e,2),e.useQueries=e=>L(e,8),e.useRedoInformation=e=>{var s;const t=B(e),[,,[o]]=de(t);return[!k(o),ce(t),o,null!=(s=v(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationships=e=>L(e,6),e.useRemoteRowId=se,e.useRemoteRowIdListener=(e,s,t,l,o)=>Q("RemoteRowId",q(o),t,l,[e,s]),e.useResultCell=ne,e.useResultCellIds=ue,e.useResultCellIdsListener=(e,s,t,l,o)=>Q("ResultCellIds",O(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>Q("ResultCell",O(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>G("ResultRow",O(t),{},[e,s]),e.useResultRowIds=oe,e.useResultRowIdsListener=(e,s,t,l)=>Q("ResultRowIds",O(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>Q("ResultRow",O(o),t,l,[e,s]),e.useResultSortedRowIds=re,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,u,n)=>Q("ResultSortedRowIds",O(n),r,u,[e,s,t,l,o]),e.useResultTable=(e,s)=>G("ResultTable",O(s),{},[e]),e.useResultTableListener=(e,s,t,l)=>Q("ResultTable",O(l),s,t,[e]),e.useRow=(e,s,t)=>G(i,T(t),{},[e,s]),e.useRowIds=K,e.useRowIdsListener=(e,s,t,l,o)=>Q(a,T(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>Q(i,T(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>U(r,I,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=m,s=[],t,l=m,o=[])=>{const r=B(t);return M((s=>v(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>U(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>U(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>U(o,i,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>U(l,u,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>U(t,n,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>U(l,p,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>U(t,b,e,s,l,o),e.useSliceIds=_,e.useSliceIdsListener=(e,s,t,l)=>Q("SliceIds",x(l),s,t,[e]),e.useSliceRowIds=ee,e.useSliceRowIdsListener=(e,s,t,l,o)=>Q("SliceRowIds",x(o),t,l,[e,s]),e.useSortedRowIds=N,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>Q(c,T(d),r,u,[e,s,t,l,o],n),e.useStore=e=>L(e,0),e.useTable=(e,s)=>G(u,T(s),{},[e]),e.useTableCellIds=(e,s)=>G(u+w,T(s),[],[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>Q(u+w,T(o),s,t,[e],l),e.useTableIds=J,e.useTableIdsListener=(e,s,t,l)=>Q(d,T(l),e,s,[],t),e.useTableListener=(e,s,t,l,o)=>Q(u,T(o),s,t,[e],l),e.useTables=e=>G(n,T(e),{}),e.useTablesListener=(e,s,t,l)=>Q(n,T(l),e,s,[],t),e.useUndoInformation=e=>{var s;const t=B(e),[o,r]=de(t);return[(u=o,!(0==(e=>e.length)(u))),ae(t),r,null!=(s=v(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=Z,e.useValueIds=Y,e.useValueIdsListener=(e,s,t,l)=>Q(C,T(l),e,s,[],t),e.useValueListener=(e,s,t,l,o)=>Q(p,T(o),s,t,[e],l),e.useValues=e=>G(b,T(e),{}),e.useValuesListener=(e,s,t,l)=>Q(b,T(l),e,s,[],t)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.0.0",
3
+ "version": "4.1.0-beta.1",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -211,80 +211,81 @@
211
211
  },
212
212
  "devDependencies": {
213
213
  "@automerge/automerge": "^2.1.0-alpha.6",
214
- "@babel/cli": "^7.22.5",
215
- "@babel/core": "^7.22.5",
216
- "@babel/preset-env": "^7.22.5",
214
+ "@babel/cli": "^7.22.9",
215
+ "@babel/core": "^7.22.9",
216
+ "@babel/preset-env": "^7.22.9",
217
217
  "@babel/preset-react": "^7.22.5",
218
218
  "@babel/preset-typescript": "^7.22.5",
219
219
  "@rollup/plugin-replace": "^5.0.2",
220
220
  "@rollup/plugin-terser": "^0.4.3",
221
- "@sqlite.org/sqlite-wasm": "^3.42.0-build2",
221
+ "@sqlite.org/sqlite-wasm": "3.42.0-build2",
222
222
  "@types/asciichart": "^1.5.6",
223
223
  "@types/expect-puppeteer": "^5.0.3",
224
224
  "@types/http-server": "^0.12.1",
225
- "@types/jest": "^29.5.2",
225
+ "@types/jest": "^29.5.3",
226
226
  "@types/jest-environment-puppeteer": "^5.0.3",
227
227
  "@types/less": "^3.0.3",
228
- "@types/node": "^20.3.2",
228
+ "@types/node": "^20.4.2",
229
229
  "@types/puppeteer": "^5.4.7",
230
- "@types/react": "^18.2.14",
231
- "@types/react-dom": "^18.2.6",
230
+ "@types/react": "^18.2.15",
231
+ "@types/react-dom": "^18.2.7",
232
232
  "@types/react-test-renderer": "^18.0.0",
233
233
  "@types/tmp": "^0.2.3",
234
- "@typescript-eslint/eslint-plugin": "^5.60.1",
235
- "@typescript-eslint/parser": "^5.60.1",
236
- "@vlcn.io/crsqlite-wasm": "^0.13.0",
234
+ "@typescript-eslint/eslint-plugin": "^6.1.0",
235
+ "@typescript-eslint/parser": "^6.1.0",
236
+ "@vlcn.io/crsqlite-wasm": "^0.14.0",
237
237
  "asciichart": "^1.5.25",
238
238
  "automerge-repo": "^0.1.0",
239
239
  "babel-eslint": "^10.1.0",
240
- "babel-jest": "^29.5.0",
240
+ "babel-jest": "^29.6.1",
241
241
  "babel-plugin-transform-import-meta": "^2.2.0",
242
242
  "babel-preset-minify": "^0.5.2",
243
243
  "buffer-replace": "^1.0.0",
244
244
  "country-flag-emoji-json": "^2.0.0",
245
- "cspell": "^6.31.1",
246
- "esbuild": "^0.18.10",
247
- "eslint": "^8.43.0",
245
+ "cspell": "^6.31.2",
246
+ "esbuild": "^0.18.14",
247
+ "eslint": "^8.45.0",
248
248
  "eslint-config-prettier": "^8.8.0",
249
- "eslint-plugin-jest": "^27.2.2",
250
- "eslint-plugin-jsdoc": "^46.4.2",
249
+ "eslint-plugin-jest": "^27.2.3",
250
+ "eslint-plugin-jsdoc": "^46.4.4",
251
251
  "eslint-plugin-react": "^7.32.2",
252
252
  "eslint-plugin-react-hooks": "^4.6.0",
253
- "fake-indexeddb": "^4.0.1",
253
+ "fake-indexeddb": "^4.0.2",
254
254
  "gulp": "^4.0.2",
255
255
  "gulp-gzip": "^1.4.2",
256
256
  "http-server": "^14.1.1",
257
- "jest": "^29.5.0",
258
- "jest-environment-jsdom": "^29.5.0",
257
+ "jest": "^29.6.1",
258
+ "jest-environment-jsdom": "^29.6.1",
259
259
  "jest-fetch-mock": "^3.0.3",
260
260
  "jest-puppeteer": "^9.0.0",
261
261
  "less": "^4.1.3",
262
262
  "prettier": "^2.8.8",
263
- "puppeteer": "^20.7.4",
263
+ "puppeteer": "^20.8.3",
264
264
  "react": "^18.2.0",
265
265
  "react-dom": "^18.2.0",
266
266
  "react-test-renderer": "^18.2.0",
267
- "rollup": "^3.26.0",
267
+ "rollup": "^3.26.3",
268
268
  "rollup-plugin-esbuild": "^5.0.0",
269
269
  "rollup-plugin-gzip": "^3.1.0",
270
270
  "rollup-plugin-preserve-shebang": "^1.0.1",
271
271
  "rollup-plugin-prettier": "^3.0.0",
272
272
  "sqlite3": "^5.1.6",
273
273
  "tinybase": "file:./",
274
- "tinydocs": "^0.1.27",
274
+ "tinydocs": "^0.1.29",
275
275
  "tmp": "^0.2.1",
276
276
  "ts-unused-exports": "^9.0.5",
277
277
  "typescript": "5.1.6",
278
- "yjs": "^13.6.6"
278
+ "yjs": "^13.6.7"
279
279
  },
280
280
  "peerDependencies": {
281
- "@sqlite.org/sqlite-wasm": "^3.42.0-build2",
282
- "@vlcn.io/crsqlite-wasm": "^0.13.0",
281
+ "@sqlite.org/sqlite-wasm": "3.42.0-build2",
282
+ "@vlcn.io/crsqlite-wasm": "^0.14.0",
283
283
  "automerge-repo": "^0.1.0",
284
284
  "prettier": "^2.8.8",
285
285
  "react": "^18.2.0",
286
+ "react-dom": "^18.2.0",
286
287
  "sqlite3": "^5.1.6",
287
- "yjs": "^13.6.6"
288
+ "yjs": "^13.6.7"
288
289
  },
289
290
  "peerDependenciesMeta": {
290
291
  "@sqlite.org/sqlite-wasm": {
@@ -302,6 +303,9 @@
302
303
  "react": {
303
304
  "optional": true
304
305
  },
306
+ "react-dom": {
307
+ "optional": true
308
+ },
305
309
  "sqlite3": {
306
310
  "optional": true
307
311
  },