tinybase 4.1.0-beta.0 → 4.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/queries.cjs +1 -1
- package/lib/cjs/queries.cjs.gz +0 -0
- package/lib/cjs/tinybase.cjs +1 -1
- package/lib/cjs/tinybase.cjs.gz +0 -0
- package/lib/cjs/tools.cjs +1 -1
- package/lib/cjs/tools.cjs.gz +0 -0
- package/lib/cjs/ui-react-dom.cjs +1 -0
- package/lib/cjs/ui-react-dom.cjs.gz +0 -0
- package/lib/cjs/ui-react.cjs +1 -1
- package/lib/cjs/ui-react.cjs.gz +0 -0
- package/lib/cjs-es6/queries.cjs +1 -1
- package/lib/cjs-es6/queries.cjs.gz +0 -0
- package/lib/cjs-es6/tinybase.cjs +1 -1
- package/lib/cjs-es6/tinybase.cjs.gz +0 -0
- package/lib/cjs-es6/tools.cjs +1 -1
- package/lib/cjs-es6/tools.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react-dom.cjs +1 -0
- package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
- package/lib/cjs-es6/ui-react.cjs +1 -1
- package/lib/cjs-es6/ui-react.cjs.gz +0 -0
- package/lib/debug/queries.js +1 -0
- package/lib/debug/tinybase.js +1 -0
- package/lib/debug/tools.js +25 -4
- package/lib/debug/ui-react-dom.js +292 -0
- package/lib/debug/ui-react.js +43 -13
- package/lib/es6/queries.js +1 -1
- package/lib/es6/queries.js.gz +0 -0
- package/lib/es6/tinybase.js +1 -1
- package/lib/es6/tinybase.js.gz +0 -0
- package/lib/es6/tools.js +1 -1
- package/lib/es6/tools.js.gz +0 -0
- package/lib/es6/ui-react-dom.js +1 -0
- package/lib/es6/ui-react-dom.js.gz +0 -0
- package/lib/es6/ui-react.js +1 -1
- package/lib/es6/ui-react.js.gz +0 -0
- package/lib/queries.js +1 -1
- package/lib/queries.js.gz +0 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/tools.js +1 -1
- package/lib/tools.js.gz +0 -0
- package/lib/types/queries.d.ts +67 -0
- package/lib/types/ui-react-dom.d.ts +916 -0
- package/lib/types/ui-react.d.ts +328 -76
- package/lib/types/with-schemas/internal/ui-react.d.ts +23 -8
- package/lib/types/with-schemas/queries.d.ts +76 -0
- package/lib/types/with-schemas/ui-react-dom.d.ts +993 -0
- package/lib/types/with-schemas/ui-react.d.ts +325 -68
- package/lib/ui-react-dom.js +1 -0
- package/lib/ui-react-dom.js.gz +0 -0
- package/lib/ui-react.js +1 -1
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/queries.js +1 -1
- package/lib/umd/queries.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/tools.js +1 -1
- package/lib/umd/tools.js.gz +0 -0
- package/lib/umd/ui-react-dom.js +1 -0
- package/lib/umd/ui-react-dom.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -1
- package/lib/umd/ui-react.js.gz +0 -0
- package/lib/umd-es6/queries.js +1 -1
- package/lib/umd-es6/queries.js.gz +0 -0
- package/lib/umd-es6/tinybase.js +1 -1
- package/lib/umd-es6/tinybase.js.gz +0 -0
- package/lib/umd-es6/tools.js +1 -1
- package/lib/umd-es6/tools.js.gz +0 -0
- package/lib/umd-es6/ui-react-dom.js +1 -0
- package/lib/umd-es6/ui-react-dom.js.gz +0 -0
- package/lib/umd-es6/ui-react.js +1 -1
- package/lib/umd-es6/ui-react.js.gz +0 -0
- package/package.json +33 -29
- package/readme.md +41 -24
package/lib/cjs-es6/tools.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=e=>typeof e,t="tinybase",l="",a=",",n=e(l),o=e(!0),d=e(0),r="type",s="default",I="Listener",c="get",$="add",i="Ids",u="Table",p=u+"s",b=u+i,C="Row",h=C+i,g="Sorted"+C+i,m="Cell",f=m+i,w="Value",y=w+"s",v=w+i,T=(e,t)=>e.every(t),V=(e,t)=>e.sort(t),x=(e,t)=>e.forEach(t),R=(e,t=l)=>e.join(t),k=(e,t)=>e.map(t),P=e=>e.length,S=(e,t)=>e.filter(t),A=(e,...t)=>e.push(...t),O=e=>e.pop(),E=(e,...t)=>e.unshift(...t),D=e=>e.shift(),j=JSON.parse,N=isFinite,L=(e,t)=>e instanceof t,G=e=>null==e,M=e=>e==n||e==o,J=t=>e(t)==n,z=e=>Array.isArray(e),W=t=>{const l=e(t);return M(l)||l==d&&N(t)?l:void 0},B=Object,F=B.keys,U=B.freeze,_=e=>L(e,B)&&e.constructor==B,Z=(e,t)=>k(B.entries(e),(([e,l])=>t(l,e))),H=e=>P(F(e)),Q=e=>_(e)&&0==H(e),q=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},K=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},X=(e,t)=>null==e?void 0:e.forEach(t),Y=(e,t)=>null==e?void 0:e.delete(t),ee=e=>new Map(e),te=(e,t)=>null==e?void 0:e.get(t),le=(e,t)=>X(e,((e,l)=>t(l,e))),ae=(e,t)=>{var l;return k([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},ne=(e,t,l)=>G(l)?(Y(e,t),e):null==e?void 0:e.set(t,l),oe=(e,t,l)=>(q(e,t)||ne(e,t,l()),te(e,t)),de=e=>e.toUpperCase(),re=e=>e.toLowerCase(),se="a ",Ie="A function for",ce=", and registers a listener so that any changes to that result will cause a re-render",$e="Callback",ie="Del",ue="Deps",pe=ue+"?: React.DependencyList",be="doRollback?: DoRollback",Ce="actions: () => Return, "+be,he="export",ge="Id",me="Invalid",fe="Json",we=re(I),ye="?: ",ve=" | undefined",Te="NonNullable",Ve="Partial",xe="Props",Re="Provider",ke=`Registers a ${we} that will be called`,Pe="Represents",Se="rowId: "+ge,Ae="Schema",Oe="Set",Ee=", descending?: boolean, offset?: number, limit?: number",De="[]",je="the Store",Ne="Transaction",Le=Ne+"Changes",Ge=re(Ne),Me="Execute a "+Ge+" to make multiple mutations",Je="Explicitly starts a "+Ge,ze="Explicitly finishes a "+Ge,We="the end of the "+Ge,Be="void",Fe=" => "+Be,Ue="WhenSet",_e=" when setting it",Ze=se+"string serialization of",He=" ",Qe="Gets a callback that can ",qe="the ",Ke=" the schema for",Xe=(e=0,t=0)=>`the ${Ct[e]}content of`+(t?He+je:l),Ye=(e=0,t,a=0)=>ut[t]+He+Xe(e,1)+(a?" when setting it":l),et=(e,t=0)=>Pe+` a Row when ${t?"s":"g"}etting ${Xe()} the '${e}' `+u,tt=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,lt=(e,t)=>`Calls a function for each ${e} in `+t,at=e=>"The props passed to a component that renders "+e,nt=e=>"A function that takes "+e,ot=(e,t=0)=>Ie+" listening to changes to "+bt[e]+" in "+bt[t],dt=(e,t,a=0)=>ke+" whenever "+bt[e]+" in "+bt[t]+" change"+(a?l:"s"),rt=e=>`the '${e}' `+u,st=e=>"the specified Row in "+rt(e),It=(e,t=0)=>ut[t]+` ${Xe()} `+rt(e),ct=(e,t=0)=>ut[t]+` ${Xe()} `+st(e),$t=(e,t,l=0)=>ut[l]+` the '${t}' Cell for `+st(e),it=(e,t=0)=>ut[t]+` the '${e}' Value`,ut=["Gets","Checks existence of","Sets","Deletes","Sets part of",Pe,"Gets "+Ze,"Sets "+Ze,ke+" whenever",Qe+"set",Qe+"add",Qe+"set part of",Qe+"delete","Renders","Gets "+Ze+Ke,"Sets"+Ke,"Deletes"+Ke],pt=[c,"has","set","del","set","forEach",$,l],bt=[je,p,qe+u+He+i,se+u,qe+C+He+i,se+C,qe+m+He+i,se+m,"invalid Cell changes",y,qe+w+He+i,se+w,"invalid Value changes",qe+"sorted "+C+He+i,qe+m+He+i+" anywhere"],Ct=[l,"tabular ","keyed value "],ht=e=>new Set(z(e)||G(e)?e:[e]),gt=(e,t)=>null==e?void 0:e.add(t),mt=/[^A-Za-z]+/,ft=/[^A-Za-z0-9]+/,wt=/^( *)\/\*\* *(.*?) *\*\/$/gm,yt=(e,t,l)=>e.substring(t,l),vt=e=>e.includes(a),Tt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return q(e,n)?Tt(e,t,l,a+1):(ne(e,n,l),n)},Vt=e=>e.replace(wt,((e,t,l)=>{const a=77-xt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),xt=e=>e.length,Rt=e=>e.flat(1e3),kt=(e,t=0)=>R(k(e.split(ft),((e,l)=>(l>0||t?de:re)(yt(e,0,1))+yt(e,1)))),Pt=e=>de(R((e&&!mt.test(e[0])?e:" "+e).split(ft),"_")),St=e=>`/** ${e}. */`,At=(...e)=>R(S(e,(e=>e)),", "),Ot=(...e)=>"{"+R(e,"; ")+"}",Et=(...e)=>Ot(...k(e,(e=>"readonly "+e))),Dt=()=>{const e=[ee(),ee(),ee(),ee()],t=ee(),a=ee(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>R(Rt(e),"\n"),(t,l,...a)=>x(a,(a=>x([0,1],(n=>(null!=t?t:n)==n?gt(oe(e[n],l,ht),a):0)))),(e,a,n,o=l,d=1)=>Tt(t,e,[a,n,o,d]),(e,t,l)=>Tt(a,e,z(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>te(a,e)===t?e:Tt(a,e,t),(t=0)=>k([...V(ae(e[t],((e,t)=>`import {${R(V(K(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)),l],(e=>e.replace("{React}","React"))),()=>ae(t,(([e,t,a,n],o)=>[St(t),`${n?he+" ":l}type ${o}${a} = ${e};`,l])),()=>ae(a,((e,t)=>(e=z(e)?e:[e],A(e,O(e)+";"),[`const ${t} = ${D(e)}`,e,l])))]},jt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Nt=(e,t,l)=>[t=>Z(e,((e,a)=>t(a,kt(a,1),l(Pt(a),`'${a}'`)))),(t,a)=>Z(e[t],((e,t)=>a(t,e[r],e[s],l(Pt(t),`'${t}'`),kt(t,1)))),e=>Z(t,((t,a)=>e(a,t[r],t[s],l(Pt(a),`'${a}'`),kt(a,1))))],Lt=(e,t,a,n)=>[(n,o)=>{const d=n+": "+o,r=e(p,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...a(e,((e,t,a)=>`'${e}'${G(a)?"?":l}: ${t}`)))+"}"))),Ye(1,5)),s=e(p+Ue,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Ye(1,5,1)),c=e(u+ge,"keyof "+r,"A "+u+" Id in "+je),$=`<TId extends ${c}>`,i=e(u,Te+`<${r}[TId]>`,"A "+u+" in "+je,$),w=e(u+Ue,Te+`<${s}[TId]>`,"A "+u+" in "+je+_e,$),y=e(C,i+"<TId>[Id]","A "+C+" in a "+u,$),v=e(C+Ue,w+"<TId>[Id]","A "+C+" in a "+u+_e,$),T=e(m+ge,`Extract<keyof ${y}<TId>, Id>`,"A "+m+" Id in a "+C,$),V=e(m,Te+`<${r}[TId]>[Id][CId]`,"A "+m+" in a "+C,`<TId extends ${c}, CId extends ${T}<TId>>`),x=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,m+" Ids and types in a "+C,`<TId extends ${c}, CId = ${T}<TId>>`,0),R=e(m+$e,`(...[cellId, cell]: ${x}<TId>)`+Fe,nt(se+m+" Id, and "+m),$),k=e(C+$e,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Fe+") "+Fe,nt(se+C+" Id, and a "+m+" iterator"),$),P=e(u+m+$e,`(cellId: ${T}<TId>, count: number) `+Fe,nt(se+m+" Id, and count of how many times it appears"),$),S=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Fe}] : never`,u+" Ids and callback types",`<TId = ${c}>`,0),A=e(u+$e,`(...[tableId, forEachRow]: ${S})`+Fe,nt(se+u+" Id, and a "+C+" iterator"),l),O=e("TableIdRowIdCellIdArray",`TId extends ${c} ? [tableId: TId, rowId: Id, cellId: ${T}<TId>] : never`,"Ids for GetCellChange",`<TId = ${c}>`,0),E=e("GetCellChange",`(...[tableId, rowId, cellId]: ${O}) => CellChange`,Ie+" returning information about any Cell's changes during a "+Ge),D=e(p+I,`(${d}, getCellChange: ${E}${ve})`+Fe,ot(1)),j=e(b+I,`(${d})`+Fe,ot(2)),N=e(u+I,`(${d}, tableId: ${c}, getCellChange: ${E}${ve})`+Fe,ot(3)),L=e(u+f+I,`(${d}, tableId: ${c})`+Fe,ot(14,3)),M=e(h+I,`(${d}, tableId: ${c})`+Fe,ot(4,3)),J=e(g+I,"("+At(d,"tableId: "+c,"cellId: Id"+ve,"descending: boolean","offset: number","limit: number"+ve,"sortedRowIds: Ids")+")"+Fe,ot(13,3)),z=e(C+I,"("+At(""+d,"tableId: "+c,Se,`getCellChange: ${E}${ve}`)+")"+Fe,ot(5,3)),W=e(f+I,"("+At(""+d,"tableId: "+c,Se)+")"+Fe,ot(6,5)),B=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${d}, tableId: TId, ${Se}, cellId: CId, newCell: ${V}<TId, CId> ${ve}, oldCell: ${V}<TId, CId> ${ve}, getCellChange: ${E} ${ve}] : never`,"Cell args for CellListener",`<TId extends ${c}, CId = ${T}<TId>>`,0),F=e("CellListenerArgsArrayOuter",`TId extends ${c} ? `+B+"<TId> : never","Table args for CellListener",`<TId = ${c}>`,0);return[r,s,c,i,w,y,v,T,V,R,k,P,A,D,j,N,L,M,J,z,W,e(m+I,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${F})`+Fe,ot(7,5)),e(me+m+I,`(${d}, tableId: Id, ${Se}, cellId: Id, invalidCells: any[])`+Fe,ot(8))]},(t,a)=>{const o=t+": "+a,d=e(y,Ot(...n(((e,t,a)=>`'${e}'${G(a)?"?":l}: ${t}`))),Ye(2,5)),r=e(y+Ue,Ot(...n(((e,t)=>`'${e}'?: ${t}`))),Ye(2,5,1)),s=e(w+ge,"keyof "+d,"A "+w+" Id in "+je),c=e(w,Te+`<${d}[VId]>`,"A "+w+" Id in "+je,`<VId extends ${s}>`),$=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${c}<VId>] : never`,w+" Ids and types in "+je,`<VId = ${s}>`,0),i=e(w+$e,`(...[valueId, value]: ${$})`+Fe,nt(se+w+" Id, and "+w)),u=e("GetValueChange",`(valueId: ${s}) => ValueChange`,Ie+" returning information about any Value's changes during a "+Ge),p=e(y+I,`(${o}, getValueChange: ${u}${ve})`+Fe,ot(9)),b=e(v+I,`(${o})`+Fe,ot(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${c}<VId> ${ve}, oldValue: ${c}<VId> ${ve}, getValueChange: ${u} ${ve}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,c,i,p,b,e(w+I,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Fe,ot(11)),e(me+w+I,`(${o}, valueId: Id, invalidValues: any[])`+Fe,ot(12))]},(t,l)=>e(Ne+I,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Fe,Ie+" listening to the completion of a "+Ge)],Gt=(e,t=l,a=l)=>`store.${e}(${t})`+(a?" as "+a:l),Mt=(e,t=l)=>`fluent(() => ${Gt(e,t)})`,Jt=(e,t=l,a=l)=>`store.${e}(${t?t+", ":l}proxy(listener)${a?", "+a:l})`,zt=(e,a,n)=>{const[d,c,T,V,k,P,S,O]=Dt(),[D,j,N]=Nt(e,a,k),[L,M,z]=Lt(T,D,j,N),W=ee(),B=(e=0)=>ae(W,(([t,a,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${a} => ${n},`]:[r+d+`(${t}): ${a};`];return e||E(s,St(o)),A(s,l),s})),F=(e,t,a,n,o,d=l)=>Tt(W,e,[t,a,n,o,d]),U=(e,t,a,n,o,d=l,r=l,s=l)=>F(pt[e]+t+(4==e?Ve:l)+a,d,n,(n==H?Mt:Gt)(pt[e]+(4==e?Ve:l)+a,r,e?void 0:n),o,s),_=(e,t,a,n=l,o=l,d=1,r=l)=>F($+e+I,(n?n+", ":l)+we+": "+t+(d?", mutator?: boolean":l),ge,Jt($+e+I,o,d?"mutator":l),a,r),Z=`./${kt(n)}.d`,H=kt(n,1),q=kt(H),X=[],Y=ee();let oe=[],de=[];if(c(1,Z,H,`create${H} as create${H}Decl`),Q(e))c(null,t,p);else{c(0,t,"CellChange"),c(null,t,i);const[e,a,n,d,I,$,w,y,v,V,P,S,O,E,N,M,z,W,B,F,Q,le,ae]=L(q,H),de=ee();D(((e,t)=>{const l=`<'${e}'>`,a=[T(t+u,d+l,Pe+` the '${e}' `+u),T(t+u+Ue,I+l,Pe+` the '${e}' `+u+_e),T(t+C,$+l,et(e)),T(t+C+Ue,w+l,et(e,1)),T(t+m+ge,y+l,`A Cell Id for the '${e}' `+u),T(t+m+$e,V+l,nt(`a Cell Id and value from a Row in the '${e}' `+u)),T(t+C+$e,P+l,nt(`a Row Id from the '${e}' Table, and a Cell iterator`)),T(t+u+m+$e,S+l,nt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];ne(de,e,a),c(1,Z,...a)})),c(1,Z,e,a,n,y,O,E,N,M,z,W,B,F,Q,le,ae),oe=[e,a,n,y,E,N,M,z,W,B,F,Q,le,de],x([[e],[o],[H,"tables: "+a,"tables"],[H]],(([e,t,a],n)=>U(n,l,p,e,Ye(1,n),t,a))),U(0,l,b,n+De,tt(u,je)),U(5,l,u,Be,lt(u,je),"tableCallback: "+O,"tableCallback as any"),D(((e,t,a)=>{const[n,d,r,s,I,c,$,p]=te(de,e);x([[n],[o],[H,"table: "+d,", table"],[H]],(([n,o,d=l],r)=>U(r,t,u,n,It(e,r),o,a+d))),U(0,t,u+f,i,tt(m,"the whole of "+rt(e)),l,a),U(5,t,u+m,Be,lt(u+m,"the whole of "+rt(e)),"tableCellCallback: "+p,a+", tableCellCallback as any"),U(0,t,h,i,tt(C,rt(e)),l,a),U(0,t,g,i,tt(C,rt(e),1),"cellId?: "+I+Ee,a+", cellId, descending, offset, limit"),U(5,t,C,Be,lt(C,rt(e)),"rowCallback: "+$,a+", rowCallback as any"),x([[r],[o],[H,", row: "+s,", row"],[H],[H,", partialRow: "+s,", partialRow"]],(([n,o=l,d=l],r)=>U(r,t,C,n,ct(e,r),Se+o,a+", rowId"+d))),U(6,t,C,ge+ve,"Add a new Row to "+rt(e),"row: "+s+", reuseIds?: boolean",a+", row, reuseIds"),U(0,t,f,I+De,tt(m,st(e)),Se,a+", rowId"),U(5,t,m,Be,lt(m,st(e)),Se+", cellCallback: "+c,a+", rowId, cellCallback as any"),j(e,((n,d,r,s,I)=>{const c="Map"+kt(d,1);ne(Y,d,c);const $=d+(G(r)?ve:l);x([[$],[o],[H,`, cell: ${d} | `+c,", cell as any"],[H]],(([o,d=l,r=l],c)=>U(c,t+I,m,o,$t(e,n,c),Se+d,a+", rowId, "+s+r))),U(1,t+I,u+m,o,ut[1]+` the '${n}' Cell anywhere in `+rt(e),l,a+", "+s)}))})),U(0,l,p+fe,fe,Ye(1,6)),U(2,l,p+fe,H,Ye(1,7),"tablesJson: "+fe,"tables"+fe),_(p,E,Ye(1,8)+" changes"),_(b,N,dt(2,0,1)),_(u,M,dt(3,0),`tableId: ${n} | null`,"tableId"),_(u+f,z,dt(14,3,1),`tableId: ${n} | null`,"tableId"),_(h,W,dt(4,3,1),`tableId: ${n} | null`,"tableId"),_(g,B,dt(13,3,1),At("tableId: TId",`cellId: ${y}<TId>`+ve,"descending: boolean","offset: number","limit: number"+ve),At("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(C,F,dt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(f,Q,dt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(m,le,dt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${R(D((e=>{var t,a;return null!=(a=null==(t=te(de,e))?void 0:t[4])?a:l}))," | ")} | null`,"tableId, rowId, cellId"),_(me+m,ae,ke+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),c(1,Z,...K(Y)),A(X,".set"+p+Ae+"({",Rt(D(((e,t,a)=>[`[${a}]: {`,...j(e,((e,t,a,n)=>`[${n}]: {[${k(Pt(r),`'${r}'`)}]: ${k(Pt(t),`'${t}'`)}${G(a)?l:`, [${k(Pt(s),`'${s}'`)}]: `+(J(a)?k(Pt(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(Q(a))c(null,t,y);else{const[e,a,n,d,I,$,i,u,p]=M(q,H);c(1,Z,e,a,n,I,$,i,u,p),de=[e,a,n,$,i,u],x([[e],[o],[H,"values: "+a,"values"],[H],[H,"partialValues: "+a,"partialValues"]],(([e,t,a],n)=>U(n,l,y,e,Ye(2,n),t,a))),U(0,l,v,n+De,tt(w,je)),U(5,l,w,"void",lt(w,je),"valueCallback: "+I,"valueCallback as any"),N(((e,t,a,n,d)=>{const r="Map"+kt(t,1);ne(Y,t,r),x([[t],[o],[H,`value: ${t} | `+r,", value as any"],[H]],(([t,a,o=l],r)=>U(r,d,w,t,it(e,r),a,n+o)))})),U(0,l,y+fe,fe,Ye(2,6)),U(2,l,y+fe,H,Ye(2,7),"valuesJson: "+fe,"values"+fe),_(y,$,Ye(2,8)+" changes"),_(v,i,dt(10,0,1)),_(w,u,dt(11,0),`valueId: ${n} | null`,"valueId"),_(me+w,p,ke+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),c(1,Z,...K(Y)),c(0,t,"ValueChange"),A(X,".set"+y+Ae+"({",N(((e,t,a,n)=>[`[${n}]: {[${k(Pt(r),`'${r}'`)}]: ${k(Pt(t),`'${t}'`)}${G(a)?l:`, [${k(Pt(s),`'${s}'`)}]: `+(J(a)?k(Pt(a),`'${a}'`):a)}},`])),"})")}U(0,l,"Content",`[${p}, ${y}]`,Ye(0,0)),U(2,l,"Content",H,Ye(0,2),`[tables, values]: [${p}, ${y}]`,"[tables, values]"),U(2,l,Le,H,`Applies a set of ${Le} to the Store`,"transactionChanges: "+Le,"transactionChanges"),le(Y,((e,t)=>T(t,`(cell: ${e}${ve}) => `+e,`Takes a ${e} Cell value and returns another`))),c(null,t,"DoRollback",ge,"IdOrNull",fe,"Store",Le),c(0,t,"Get"+Le,"GetTransactionLog"),U(0,l,fe,fe,Ye(0,6)),U(2,l,fe,H,Ye(0,7),"tablesAndValuesJson: "+fe,"tablesAndValuesJson"),U(7,l,Ge,"Return",Me,Ce,"actions, doRollback","<Return>"),U(7,l,"start"+Ne,H,Je),U(7,l,"finish"+Ne,H,ze,be,"doRollback");const re=z(q,H);return _("Start"+Ne,re,ke+" just before the start of the "+Ge,l,l,0),_("WillFinish"+Ne,re,ke+" just before "+We,l,l,0),_("DidFinish"+Ne,re,ke+" just after "+We,l,l,0),U(7,l,"call"+I,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,l,I,H,"Remove a listener that was previously added to "+je,"listenerId: Id","listenerId"),F("getStore",l,"Store","store",ut[0]+" the underlying Store object"),c(1,t,"createStore"),c(1,Z,H,`create${H} as create${H}Decl`,re),k("store",["createStore()",...X]),V("fluent","actions: () => Store",["actions();",`return ${q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${q}, ...params)`),k(q,["{",...B(1),"}"]),[d(...P(0),...S(),he+" interface "+H+" {",...B(0),"}",l,St(`Creates a ${H} object`),he+" function create"+H+"(): "+H+";"),d(...P(1),he+" const create"+H+": typeof create"+H+"Decl = () => {",...O(),`return Object.freeze(${q});`,"};"),oe,de]},Wt=e=>c+e,Bt=e=>At(Wt(e),Wt(e)+ue),Ft="debugIds?: boolean",Ut="debugIds={debugIds}",_t="then"+pe,Zt="Parameter",Ht=": (parameter: "+Zt+", store: Store) => ",Qt="const contextValue = useContext(Context);",qt=", based on a parameter",Kt=": ",Xt="<"+Zt+",>",Yt=Zt+"ized"+$e+"<"+Zt+">",el="rowId",tl="rowId={rowId}",ll=", separator, debugIds",al="separator?: ReactElement | string",nl="then?: (store: Store",ol=At(nl+")"+Fe,_t),dl="then, then"+ue,rl=el+Kt+ge,sl="View",Il=(e,...t)=>At(...t,we+": "+e,we+pe,"mutator?: boolean"),cl=(...e)=>At(...e,we,we+ue,"mutator"),$l=(e,a,n,o,d)=>{const[r,s,c,$,T,V,x,k]=Dt(),[P,S,O]=Nt(e,a,T),D=`./${kt(n)}.d`,j=`./${kt(n)}-ui-react.d`,N="tinybase/ui-react",L=kt(n,1),M=kt(L),J=L+"Or"+L+ge,z=M+"Or"+L+ge,W=M+`={${M}}`,B=ee(),F=(e,t,a,n,o,d=l)=>(s(1,j,e+" as "+e+"Decl"),Tt(B,e,[t,a,n,o,d])),U=(e,t,a,n,o,d=l)=>F("use"+e,t,a,n,o,d),_=(e,t,a,n,o=l,d=l,r=l,I=l,c=l)=>(s(1,N,`use${t} as use${t}Core`),U(e,At(o,X,I),a,le+`(${z}, use${t}Core, [`+(d||l)+(c?"], ["+c:l)+"]);",n,r)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ae(B,(([t,a,n,o,d],r)=>{const s=e?[he+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==a?"any":a} =>`,n]:[he+` function ${r}${d}(${t}): ${1==a?"ComponentReturnType":a};`];return e||E(s,St(o)),A(s,l),s}));s(null,t,ge,"Store",$e,Zt+"ized"+$e),s(0,N,"ComponentReturnType"),s(null,N,"ExtraProps"),s(0,D,L);const q=c(J,L+" | "+ge,`Used when you need to refer to a ${L} in a React hook or component`),K=c(Re+xe,Et(M+ye+L,M+`ById?: {[${M}Id: Id]: ${L}}`),`Used with the ${Re} 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+ye+q;T("{createContext, useContext, useMemo}","React"),T("Context",`createContext<[${L}?, {[${M}Id: Id]: ${L}}?]>([])`),U("Create"+L,`create: () => ${L}, create`+pe,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 ${Re} component context`),le=$("useHook",z+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${M} = ${Y}(${z} as Id);`,`return hook(...preParams, ((${z} == null || typeof ${z} == 'string')`,`? ${M} : ${z})?.getStore(), ...postParams)`]),ne=$("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=$("wrap",At("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=T("NullComponent","() => null");if(!Q(e)){const[e,a,n,d,r,w,y,v,T,V,x,k,A,O]=o;s(null,D,e,a,n,r,w,y,v,T,V,x,k,A),s(0,D,d),s(1,D,L),s(null,t,i,"IdOrNull");const E=$("tableView",`{${M}, rowComponent, getRowComponentProps`+ll+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${oe}(rowIds.map((rowId) => (`,"<Row","{..."+ne+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",tl,W,Ut,"/>","))",ll,", tableId,",");"]),N=$("getDefaultTableComponent","tableId: Id",R(P(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+de),J=$("getDefaultCellComponent","tableId: Id, cellId: Id",R(P(((e,t,l)=>`tableId == ${l} ? ${R(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+de} : `)))+de);_(p,p,e,Ye(1,0)+ce);const z=_(b,b,n+De,tt(u,je)+ce);_(Oe+p+$e,Oe+p+$e,Yt,Ye(1,9)+qt,At(Wt(p)+Ht+a,Wt(p)+pe),Bt(p),Xt,At(nl,`tables: ${a})`+Fe,_t),dl),_(ie+p+$e,ie+p+$e,$e,Ye(1,12),l,l,l,ol,dl);const B=c(m+xe,Et("tableId?: TId","rowId: Id","cellId?: CId",M+ye+L,Ft),at(se+m),`<TId extends ${n}, CId extends ${d}<TId>>`),F=c(C+xe,Et("tableId?: TId","rowId: Id",M+ye+L,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${B}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,al,Ft),at(se+C),`<TId extends ${n}>`),U=c(u+xe,Et("tableId?: TId",M+ye+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",al,Ft),at(se+u),`<TId extends ${n}>`),H=c("Sorted"+u+xe,Et("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",M+ye+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps",al,Ft),at(se+"sorted "+u),`<TId extends ${n}>`),Q=c(p+xe,Et(M+ye+L,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${U}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,al,Ft),at(Xe(1,1)));s(1,j,Q,U,H,F,B),Z(p+sl,"{"+M+", tableComponents, getTableComponentProps"+ll+"}: "+Q,[oe+`(${z}(${M}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+N+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,Ut,"/>;","}), separator)"],Ye(1,13)+ce),P(((e,t,a)=>{const[n,o,d,r,I]=te(O,e);s(null,D,n,o,d,r,I),_(t+u,u,n,It(e)+ce,l,a),_(t+u+f,u+f,i,tt(m,"the whole of "+rt(e))+ce,l,a);const c=_(t+h,h,i,tt(C,rt(e))+ce,l,a),$=_(t+g,g,i,tt(C,rt(e),1)+ce,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");_(t+C,C,d,ct(e)+ce,rl,At(a,el));const p=_(t+f,f,I+De,tt(m,st(e))+ce,rl,At(a,el));_(Oe+t+u+$e,Oe+u+$e,Yt,It(e,9)+qt,At(Wt(u)+Ht+o,Wt(u)+pe),At(a,Bt(u)),Xt,At(nl,`table: ${o})`+Fe,_t),dl),_(ie+t+u+$e,ie+u+$e,$e,It(e,12),l,a,l,ol,dl),_(Oe+t+C+$e,Oe+C+$e,Yt,ct(e,9)+qt,At(rl,Wt(C)+Ht+r,Wt(C)+pe),At(a,el,Bt(C)),Xt,At(nl,`row: ${r})`+Fe,_t),dl),_("Add"+t+C+$e,"Add"+C+$e,Yt,ct(e,10)+qt,At(Wt(C)+Ht+r,Wt(C)+pe),At(a,Bt(C)),Xt,"then?: ("+At(rl+ve,"store: Store","row: "+r+")"+Fe,"then"+pe)+", reuseRowIds?: boolean",dl+", reuseRowIds"),_(Oe+t+Ve+C+$e,Oe+Ve+C+$e,Yt,ct(e,11)+qt,At(rl,Wt(Ve+C)+Ht+r,Wt(Ve+C)+pe),At(a,el,Bt(Ve+C)),Xt,At(nl,`partialRow: ${r})`+Fe,_t),dl),_(ie+t+C+$e,ie+C+$e,$e,ct(e,12),rl,At(a,el),l,ol,dl);const b=Z(t+C+sl,"{rowId, "+M+", cellComponents, getCellComponentProps"+ll+`}: ${F}<'${e}'>`,[oe+`(${p}(rowId, ${M}).map((cellId) => {`,"const Cell = (cellComponents?.[cellId] ?? "+J+`(${a}, cellId)) as React.ComponentType<CellProps<typeof `+a+", typeof cellId>>;","return <Cell",`{...${ne}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${a}}`,tl,"cellId={cellId}",W,Ut,"/>;","})"+ll+", rowId)"],ct(e,13)+ce);Z(t+"Sorted"+u+sl,"{cellId, descending, offset, limit, ...props}: "+H+`<'${e}'>`,E+"(props, "+$+`(cellId, descending, offset, limit, props.${M}), ${a}, ${b});`,It(e,13)+", sorted"+ce),Z(t+u+sl,`props: ${U}<'${e}'>`,E+"(props, "+c+`(props.${M}), ${a}, ${b});`,It(e,13)+ce),S(e,((n,o,d,r,I)=>{const c="Map"+kt(o,1);s(0,D,c),s(1,D,c);const $=_(t+I+m,m,o+(G(d)?ve:l),$t(e,n)+ce,rl,At(a,el,r));_(Oe+t+I+m+$e,Oe+m+$e,Yt,$t(e,n,9)+qt,At(rl,Wt(m)+Ht+o+" | "+c,Wt(m)+pe),At(a,el,r,Bt(m)),Xt,At(nl,`cell: ${o} | ${c})`+Fe,_t),dl),_(ie+t+I+m+$e,ie+m+$e,$e,$t(e,n,12),At(rl,"forceDel?: boolean"),At(a,el,r,"forceDel"),l,ol,dl),Z(t+I+m+sl,`{rowId, ${M}, debugIds}: `+B+`<'${e}', '${n}'>`,[oe+`('' + ${$}(rowId, `+M+`) ?? '', undefined, debugIds, ${r})`],$t(e,n,13)+ce)}))}));const q=R(P((e=>{var t,a;return null!=(a=null==(t=te(O,e))?void 0:t[4])?a:l}))," | ");_(p+I,p+I,Be,Ye(1,8)+" changes",Il(r),cl()),_(b+I,b+I,Be,dt(2,0,1),Il(w),cl()),_(u+I,u+I,Be,dt(3,0),Il(y,`tableId: ${n} | null`),cl("tableId")),_(u+f+I,u+f+I,Be,dt(14,3,1),Il(v,`tableId: ${n} | null`),cl("tableId")),_(h+I,h+I,Be,dt(4,3,1),Il(T,`tableId: ${n} | null`),cl("tableId")),_(g+I,g+I,Be,dt(13,3,1),Il(V,`tableId: ${n} | null`,"cellId: "+q+ve,"descending: boolean","offset: number","limit: number"+ve),cl("tableId","cellId","descending","offset","limit")),_(C+I,C+I,Be,dt(5,3),Il(x,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(f+I,f+I,Be,dt(6,5,1),Il(k,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(m+I,m+I,Be,dt(7,5),Il(A,`tableId: ${n} | null`,el+": IdOrNull",`cellId: ${q} | null`),cl("tableId",el,"cellId"))}if(!Q(a)){const[e,t,a,n,o,r]=d;s(null,D,...d),s(1,D,L);const i=$("getDefaultValueComponent","valueId: Id",R(O(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+de);_(y,y,e,Ye(2,0)+ce);const u=_(v,v,a+De,tt(w,je)+ce);_(Oe+y+$e,Oe+y+$e,Yt,Ye(2,9)+qt,At(Wt(y)+Ht+t,Wt(y)+pe),Bt(y),Xt,At(nl,`values: ${t})`+Fe,_t),dl),_(Oe+Ve+y+$e,Oe+Ve+y+$e,Yt,Ye(2,11)+qt,At(Wt(Ve+y)+Ht+t,Wt(Ve+y)+pe),Bt(Ve+y),Xt,At(nl,`partialValues: ${t})`+Fe,_t),dl),_(ie+y+$e,ie+y+$e,$e,Ye(2,12),l,l,l,ol,dl);const p=c(w+xe,Et("valueId?: VId",M+ye+L,Ft),at("a Value"),`<VId extends ${a}>`),b=c(y+xe,Et(M+ye+L,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,al,Ft),at(Xe(2,1)));s(1,j,b,p),Z(y+sl,"{"+M+", valueComponents, getValueComponentProps"+ll+"}: "+b,[oe+`(${u}(${M}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+i+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",W,Ut,"/>;","}), separator)"],Ye(2,13)+ce),O(((e,t,a,n,o)=>{const d="Map"+kt(t,1);s(0,D,d),s(1,D,d);const r=_(o+w,w,t,it(e)+ce,l,n);_(Oe+o+w+$e,Oe+w+$e,Yt,it(e,9)+qt,At(Wt(w)+Ht+t+" | "+d,Wt(w)+pe),At(n,Bt(w)),Xt,At(nl,`value: ${t} | ${d})`+Fe,_t),dl),_(ie+o+w+$e,ie+w+$e,$e,it(e,12),l,n,l,ol,dl),Z(o+w+sl,`{${M}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${r}(`+M+`) ?? '', undefined, debugIds, ${n})`],it(e,13)+ce)})),_(y+I,y+I,Be,Ye(2,8)+" changes",Il(n),cl()),_(v+I,v+I,Be,dt(10,0,1),Il(o),cl()),_(w+I,w+I,Be,dt(11,0),Il(r,`valueId: ${a} | null`),cl("valueId"))}return Z(Re,`{${M}, ${M}ById, children}: `+K+" & {children: React.ReactNode}",["{",Qt,"return (","<Context."+Re,"value={useMemo(",`() => [${M} ?? contextValue[0], {...contextValue[1], ...${M}ById}],`,`[${M}, ${M}ById, contextValue],`,")}>","{children}",`</Context.${Re}>`,");","}"],"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),...k(),...H(1))]},il=(e,t,a)=>{if(Q(e)&&Q(t))return[l,l,l,l];const[n,o,d,r]=zt(e,t,a);return[n,o,...$l(e,t,a,d,r)]};var ul=Object.defineProperty,pl=Object.defineProperties,bl=Object.getOwnPropertyDescriptors,Cl=Object.getOwnPropertySymbols,hl=Object.prototype.hasOwnProperty,gl=Object.prototype.propertyIsEnumerable,ml=(e,t,l)=>t in e?ul(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,fl=(e,t)=>{for(var l in t||(t={}))hl.call(t,l)&&ml(e,l,t[l]);if(Cl)for(var l of Cl(t))gl.call(t,l)&&ml(e,l,t[l]);return e},wl=(e,t)=>pl(e,bl(t)),yl=(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},Tl=jt((e=>{const t=()=>{const t=j(e.getTablesSchemaJson());return!Q(t)||T(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=ee();if(T(a,(t=>T(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=oe(n,a,(()=>[W(o),ee(),[0],0])),[r,s,[I]]=d,c=oe(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),ne(s,o,c),d[3]++,r==W(o)})))))return t[l]={},X(n,(([e,,[,n],o],d)=>{t[l][d]=fl({[r]:e},o==P(a)?{[s]:n}:{})})),1}))?t:{}},l=()=>{const t=j(e.getValuesSchemaJson());return Q(t)&&e.forEachValue(((e,l)=>{t[e]={[r]:W(l)}})),t},a=e=>il(t(),l(),e),n=e=>yl(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 k(a(e),((e,a)=>Vt(l(e,wl(fl({},vl),{filepath:"_."+t[a]})))))}));return U({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})})),fl({totalTables:l,totalRows:a,totalCells:n,totalValues:P(e.getValueIds()),jsonLength:xt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));exports.createTools=Tl;
|
|
1
|
+
"use strict";const e=e=>typeof e,t="tinybase",l="",a=",",n=e(l),o=e(!0),d=e(0),r="type",s="default",I="Listener",c="get",u="add",$="Ids",i="Table",p=i+"s",b=i+$,C="Row",h=C+$,m="Sorted"+C+$,g="Cell",f=g+$,w="Value",y=w+"s",v=w+$,T=(e,t)=>e.every(t),V=(e,t)=>e.sort(t),x=(e,t)=>e.forEach(t),R=(e,t=l)=>e.join(t),k=(e,t)=>e.map(t),P=e=>e.length,S=(e,t)=>e.filter(t),A=(e,...t)=>e.push(...t),O=e=>e.pop(),E=(e,...t)=>e.unshift(...t),D=e=>e.shift(),j=JSON.parse,N=isFinite,L=(e,t)=>e instanceof t,G=e=>null==e,M=e=>e==n||e==o,J=t=>e(t)==n,z=e=>Array.isArray(e),W=t=>{const l=e(t);return M(l)||l==d&&N(t)?l:void 0},B=Object,F=B.keys,U=B.freeze,_=e=>L(e,B)&&e.constructor==B,Z=(e,t)=>k(B.entries(e),(([e,l])=>t(l,e))),H=e=>P(F(e)),Q=e=>_(e)&&0==H(e),q=(e,t)=>{var l;return null!=(l=null==e?void 0:e.has(t))&&l},K=e=>{var t;return[...null!=(t=null==e?void 0:e.values())?t:[]]},X=(e,t)=>null==e?void 0:e.forEach(t),Y=(e,t)=>null==e?void 0:e.delete(t),ee=e=>new Map(e),te=(e,t)=>null==e?void 0:e.get(t),le=(e,t)=>X(e,((e,l)=>t(l,e))),ae=(e,t)=>{var l;return k([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>t(l,e)))},ne=(e,t,l)=>G(l)?(Y(e,t),e):null==e?void 0:e.set(t,l),oe=(e,t,l)=>(q(e,t)||ne(e,t,l()),te(e,t)),de=e=>e.toUpperCase(),re=e=>e.toLowerCase(),se="a ",Ie="A function for",ce=", and registers a listener so that any changes to that result will cause a re-render",ue="Callback",$e="Del",ie="Deps",pe=ie+"?: React.DependencyList",be="doRollback?: DoRollback",Ce="actions: () => Return, "+be,he="export",me="Id",ge="Invalid",fe="Json",we=re(I),ye="?: ",ve=" | undefined",Te="NonNullable",Ve="Partial",xe="Props",Re="Provider",ke=`Registers a ${we} that will be called`,Pe="Represents",Se="rowId: "+me,Ae="Schema",Oe="Set",Ee=", descending?: boolean, offset?: number, limit?: number",De="[]",je="the Store",Ne="Transaction",Le=Ne+"Changes",Ge=re(Ne),Me="Execute a "+Ge+" to make multiple mutations",Je="Explicitly starts a "+Ge,ze="Explicitly finishes a "+Ge,We="the end of the "+Ge,Be="void",Fe=" => "+Be,Ue="WhenSet",_e=" when setting it",Ze=se+"string serialization of",He=" ",Qe="Gets a callback that can ",qe="the ",Ke=" the schema for",Xe=(e=0,t=0)=>`the ${Ct[e]}content of`+(t?He+je:l),Ye=(e=0,t,a=0)=>it[t]+He+Xe(e,1)+(a?" when setting it":l),et=(e,t=0)=>Pe+` a Row when ${t?"s":"g"}etting ${Xe()} the '${e}' `+i,tt=(e,t,l=0)=>`Gets ${l?"sorted, paginated":"the"} Ids of the ${e}s in `+t,lt=(e,t)=>`Calls a function for each ${e} in `+t,at=e=>"The props passed to a component that renders "+e,nt=e=>"A function that takes "+e,ot=(e,t=0)=>Ie+" listening to changes to "+bt[e]+" in "+bt[t],dt=(e,t,a=0)=>ke+" whenever "+bt[e]+" in "+bt[t]+" change"+(a?l:"s"),rt=e=>`the '${e}' `+i,st=e=>"the specified Row in "+rt(e),It=(e,t=0)=>it[t]+` ${Xe()} `+rt(e),ct=(e,t=0)=>it[t]+` ${Xe()} `+st(e),ut=(e,t,l=0)=>it[l]+` the '${t}' Cell for `+st(e),$t=(e,t=0)=>it[t]+` the '${e}' Value`,it=["Gets","Checks existence of","Sets","Deletes","Sets part of",Pe,"Gets "+Ze,"Sets "+Ze,ke+" whenever",Qe+"set",Qe+"add",Qe+"set part of",Qe+"delete","Renders","Gets "+Ze+Ke,"Sets"+Ke,"Deletes"+Ke],pt=[c,"has","set","del","set","forEach",u,l],bt=[je,p,qe+i+He+$,se+i,qe+C+He+$,se+C,qe+g+He+$,se+g,"invalid Cell changes",y,qe+w+He+$,se+w,"invalid Value changes",qe+"sorted "+C+He+$,qe+g+He+$+" anywhere"],Ct=[l,"tabular ","keyed value "],ht=e=>new Set(z(e)||G(e)?e:[e]),mt=(e,t)=>null==e?void 0:e.add(t),gt=/[^A-Za-z]+/,ft=/[^A-Za-z0-9]+/,wt=/^( *)\/\*\* *(.*?) *\*\/$/gm,yt=(e,t,l)=>e.substring(t,l),vt=e=>e.includes(a),Tt=(e,t,l,a=1)=>{const n=`${t}${1==a?"":a}`;return q(e,n)?Tt(e,t,l,a+1):(ne(e,n,l),n)},Vt=e=>e.replace(wt,((e,t,l)=>{const a=77-xt(t);return`${t}/**\n${l.replace(RegExp(`([^\\n]{1,${a}})(\\s|$)`,"g"),t+" * $1\n")}${t} */`})),xt=e=>e.length,Rt=e=>e.flat(1e3),kt=(e,t=0)=>R(k(e.split(ft),((e,l)=>(l>0||t?de:re)(yt(e,0,1))+yt(e,1)))),Pt=e=>de(R((e&&!gt.test(e[0])?e:" "+e).split(ft),"_")),St=e=>`/** ${e}. */`,At=(...e)=>R(S(e,(e=>e)),", "),Ot=(...e)=>"{"+R(e,"; ")+"}",Et=(...e)=>Ot(...k(e,(e=>"readonly "+e))),Dt=()=>{const e=[ee(),ee(),ee(),ee()],t=ee(),a=ee(),n=e=>{const t=e.indexOf(" as ");return-1!=t?e.substring(t+4):e};return[(...e)=>R(Rt(e),"\n"),(t,l,...a)=>x(a,(a=>x([0,1],(n=>(null!=t?t:n)==n?mt(oe(e[n],l,ht),a):0)))),(e,a,n,o=l,d=1)=>Tt(t,e,[a,n,o,d]),(e,t,l)=>Tt(a,e,z(l)?[`(${t}) => {`,l,"}"]:[`(${t}) => ${l}`]),(e,t)=>te(a,e)===t?e:Tt(a,e,t),(t=0)=>k([...V(ae(e[t],((e,t)=>`import {${R(V(K(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)),l],(e=>e.replace("{React}","React"))),()=>ae(t,(([e,t,a,n],o)=>[St(t),`${n?he+" ":l}type ${o}${a} = ${e};`,l])),()=>ae(a,((e,t)=>(e=z(e)?e:[e],A(e,O(e)+";"),[`const ${t} = ${D(e)}`,e,l])))]},jt=e=>{const t=new WeakMap;return l=>(t.has(l)||t.set(l,e(l)),t.get(l))},Nt=(e,t,l)=>[t=>Z(e,((e,a)=>t(a,kt(a,1),l(Pt(a),`'${a}'`)))),(t,a)=>Z(e[t],((e,t)=>a(t,e[r],e[s],l(Pt(t),`'${t}'`),kt(t,1)))),e=>Z(t,((t,a)=>e(a,t[r],t[s],l(Pt(a),`'${a}'`),kt(a,1))))],Lt=(e,t,a,n)=>[(n,o)=>{const d=n+": "+o,r=e(p,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...a(e,((e,t,a)=>`'${e}'${G(a)?"?":l}: ${t}`)))+"}"))),Ye(1,5)),s=e(p+Ue,Ot(...t((e=>`'${e}'?: {[rowId: Id]: `+Ot(...a(e,((e,t)=>`'${e}'?: ${t}`)))+"}"))),Ye(1,5,1)),c=e(i+me,"keyof "+r,"A "+i+" Id in "+je),u=`<TId extends ${c}>`,$=e(i,Te+`<${r}[TId]>`,"A "+i+" in "+je,u),w=e(i+Ue,Te+`<${s}[TId]>`,"A "+i+" in "+je+_e,u),y=e(C,$+"<TId>[Id]","A "+C+" in a "+i,u),v=e(C+Ue,w+"<TId>[Id]","A "+C+" in a "+i+_e,u),T=e(g+me,`Extract<keyof ${y}<TId>, Id>`,"A "+g+" Id in a "+C,u),V=e(g,Te+`<${r}[TId]>[Id][CId]`,"A "+g+" in a "+C,`<TId extends ${c}, CId extends ${T}<TId>>`),x=e("CellIdCellArray",`CId extends ${T}<TId> ? [cellId: CId, cell: ${V}<TId, CId>] : never`,g+" Ids and types in a "+C,`<TId extends ${c}, CId = ${T}<TId>>`,0),R=e(g+ue,`(...[cellId, cell]: ${x}<TId>)`+Fe,nt(se+g+" Id, and "+g),u),k=e(C+ue,"(rowId: Id, forEachCell: (cellCallback: CellCallback<TId>) "+Fe+") "+Fe,nt(se+C+" Id, and a "+g+" iterator"),u),P=e(i+g+ue,`(cellId: ${T}<TId>, count: number) `+Fe,nt(se+g+" Id, and count of how many times it appears"),u),S=e("TableIdForEachRowArray",`TId extends ${c} ? [tableId: TId, forEachRow: (rowCallback: ${k}<TId>)${Fe}] : never`,i+" Ids and callback types",`<TId = ${c}>`,0),A=e(i+ue,`(...[tableId, forEachRow]: ${S})`+Fe,nt(se+i+" Id, and a "+C+" iterator"),l),O=e("TableIdRowIdCellIdArray",`TId extends ${c} ? [tableId: TId, rowId: Id, cellId: ${T}<TId>] : never`,"Ids for GetCellChange",`<TId = ${c}>`,0),E=e("GetCellChange",`(...[tableId, rowId, cellId]: ${O}) => CellChange`,Ie+" returning information about any Cell's changes during a "+Ge),D=e(p+I,`(${d}, getCellChange: ${E}${ve})`+Fe,ot(1)),j=e(b+I,`(${d})`+Fe,ot(2)),N=e(i+I,`(${d}, tableId: ${c}, getCellChange: ${E}${ve})`+Fe,ot(3)),L=e(i+f+I,`(${d}, tableId: ${c})`+Fe,ot(14,3)),M=e(h+I,`(${d}, tableId: ${c})`+Fe,ot(4,3)),J=e(m+I,"("+At(d,"tableId: "+c,"cellId: Id"+ve,"descending: boolean","offset: number","limit: number"+ve,"sortedRowIds: Ids")+")"+Fe,ot(13,3)),z=e(C+I,"("+At(""+d,"tableId: "+c,Se,`getCellChange: ${E}${ve}`)+")"+Fe,ot(5,3)),W=e(f+I,"("+At(""+d,"tableId: "+c,Se)+")"+Fe,ot(6,5)),B=e("CellListenerArgsArrayInner",`CId extends ${T}<TId> ? [${d}, tableId: TId, ${Se}, cellId: CId, newCell: ${V}<TId, CId> ${ve}, oldCell: ${V}<TId, CId> ${ve}, getCellChange: ${E} ${ve}] : never`,"Cell args for CellListener",`<TId extends ${c}, CId = ${T}<TId>>`,0),F=e("CellListenerArgsArrayOuter",`TId extends ${c} ? `+B+"<TId> : never","Table args for CellListener",`<TId = ${c}>`,0);return[r,s,c,$,w,y,v,T,V,R,k,P,A,D,j,N,L,M,J,z,W,e(g+I,`(...[${n}, tableId, rowId, cellId, newCell, oldCell, getCellChange]: ${F})`+Fe,ot(7,5)),e(ge+g+I,`(${d}, tableId: Id, ${Se}, cellId: Id, invalidCells: any[])`+Fe,ot(8))]},(t,a)=>{const o=t+": "+a,d=e(y,Ot(...n(((e,t,a)=>`'${e}'${G(a)?"?":l}: ${t}`))),Ye(2,5)),r=e(y+Ue,Ot(...n(((e,t)=>`'${e}'?: ${t}`))),Ye(2,5,1)),s=e(w+me,"keyof "+d,"A "+w+" Id in "+je),c=e(w,Te+`<${d}[VId]>`,"A "+w+" Id in "+je,`<VId extends ${s}>`),u=e("ValueIdValueArray",`VId extends ${s} ? [valueId: VId, value: ${c}<VId>] : never`,w+" Ids and types in "+je,`<VId = ${s}>`,0),$=e(w+ue,`(...[valueId, value]: ${u})`+Fe,nt(se+w+" Id, and "+w)),i=e("GetValueChange",`(valueId: ${s}) => ValueChange`,Ie+" returning information about any Value's changes during a "+Ge),p=e(y+I,`(${o}, getValueChange: ${i}${ve})`+Fe,ot(9)),b=e(v+I,`(${o})`+Fe,ot(10)),C=e("ValueListenerArgsArray",`VId extends ${s} ? [${o}, valueId: VId, newValue: ${c}<VId> ${ve}, oldValue: ${c}<VId> ${ve}, getValueChange: ${i} ${ve}] : never`,"Value args for ValueListener",`<VId = ${s}>`,0);return[d,r,s,c,$,p,b,e(w+I,`(...[${t}, valueId, newValue, oldValue, getValueChange]: `+C+")"+Fe,ot(11)),e(ge+w+I,`(${o}, valueId: Id, invalidValues: any[])`+Fe,ot(12))]},(t,l)=>e(Ne+I,`(${t}: ${l}, getTransactionChanges: GetTransactionChanges, getTransactionLog: GetTransactionLog)`+Fe,Ie+" listening to the completion of a "+Ge)],Gt=(e,t=l,a=l)=>`store.${e}(${t})`+(a?" as "+a:l),Mt=(e,t=l)=>`fluent(() => ${Gt(e,t)})`,Jt=(e,t=l,a=l)=>`store.${e}(${t?t+", ":l}proxy(listener)${a?", "+a:l})`,zt=(e,a,n)=>{const[d,c,T,V,k,P,S,O]=Dt(),[D,j,N]=Nt(e,a,k),[L,M,z]=Lt(T,D,j,N),W=ee(),B=(e=0)=>ae(W,(([t,a,n,o,d],r)=>{const s=e?[r+`: ${d}(${t}): ${a} => ${n},`]:[r+d+`(${t}): ${a};`];return e||E(s,St(o)),A(s,l),s})),F=(e,t,a,n,o,d=l)=>Tt(W,e,[t,a,n,o,d]),U=(e,t,a,n,o,d=l,r=l,s=l)=>F(pt[e]+t+(4==e?Ve:l)+a,d,n,(n==H?Mt:Gt)(pt[e]+(4==e?Ve:l)+a,r,e?void 0:n),o,s),_=(e,t,a,n=l,o=l,d=1,r=l)=>F(u+e+I,(n?n+", ":l)+we+": "+t+(d?", mutator?: boolean":l),me,Jt(u+e+I,o,d?"mutator":l),a,r),Z=`./${kt(n)}.d`,H=kt(n,1),q=kt(H),X=[],Y=ee();let oe=[],de=[];if(c(1,Z,H,`create${H} as create${H}Decl`),Q(e))c(null,t,p);else{c(0,t,"CellChange"),c(null,t,$);const[e,a,n,d,I,u,w,y,v,V,P,S,O,E,N,M,z,W,B,F,Q,le,ae]=L(q,H),de=ee();D(((e,t)=>{const l=`<'${e}'>`,a=[T(t+i,d+l,Pe+` the '${e}' `+i),T(t+i+Ue,I+l,Pe+` the '${e}' `+i+_e),T(t+C,u+l,et(e)),T(t+C+Ue,w+l,et(e,1)),T(t+g+me,y+l,`A Cell Id for the '${e}' `+i),T(t+g+ue,V+l,nt(`a Cell Id and value from a Row in the '${e}' `+i)),T(t+C+ue,P+l,nt(`a Row Id from the '${e}' Table, and a Cell iterator`)),T(t+i+g+ue,S+l,nt(`a Cell Id from anywhere in the '${e}' Table, and a count of how many times it appears`))];ne(de,e,a),c(1,Z,...a)})),c(1,Z,e,a,n,y,O,E,N,M,z,W,B,F,Q,le,ae),oe=[e,a,n,y,E,N,M,z,W,B,F,Q,le,de],x([[e],[o],[H,"tables: "+a,"tables"],[H]],(([e,t,a],n)=>U(n,l,p,e,Ye(1,n),t,a))),U(0,l,b,n+De,tt(i,je)),U(5,l,i,Be,lt(i,je),"tableCallback: "+O,"tableCallback as any"),D(((e,t,a)=>{const[n,d,r,s,I,c,u,p]=te(de,e);x([[n],[o],[H,"table: "+d,", table"],[H]],(([n,o,d=l],r)=>U(r,t,i,n,It(e,r),o,a+d))),U(0,t,i+f,$,tt(g,"the whole of "+rt(e)),l,a),U(5,t,i+g,Be,lt(i+g,"the whole of "+rt(e)),"tableCellCallback: "+p,a+", tableCellCallback as any"),U(0,t,h,$,tt(C,rt(e)),l,a),U(0,t,m,$,tt(C,rt(e),1),"cellId?: "+I+Ee,a+", cellId, descending, offset, limit"),U(5,t,C,Be,lt(C,rt(e)),"rowCallback: "+u,a+", rowCallback as any"),x([[r],[o],[H,", row: "+s,", row"],[H],[H,", partialRow: "+s,", partialRow"]],(([n,o=l,d=l],r)=>U(r,t,C,n,ct(e,r),Se+o,a+", rowId"+d))),U(6,t,C,me+ve,"Add a new Row to "+rt(e),"row: "+s+", reuseIds?: boolean",a+", row, reuseIds"),U(0,t,f,I+De,tt(g,st(e)),Se,a+", rowId"),U(5,t,g,Be,lt(g,st(e)),Se+", cellCallback: "+c,a+", rowId, cellCallback as any"),j(e,((n,d,r,s,I)=>{const c="Map"+kt(d,1);ne(Y,d,c);const u=d+(G(r)?ve:l);x([[u],[o],[H,`, cell: ${d} | `+c,", cell as any"],[H]],(([o,d=l,r=l],c)=>U(c,t+I,g,o,ut(e,n,c),Se+d,a+", rowId, "+s+r))),U(1,t+I,i+g,o,it[1]+` the '${n}' Cell anywhere in `+rt(e),l,a+", "+s)}))})),U(0,l,p+fe,fe,Ye(1,6)),U(2,l,p+fe,H,Ye(1,7),"tablesJson: "+fe,"tables"+fe),_(p,E,Ye(1,8)+" changes"),_(b,N,dt(2,0,1)),_(i,M,dt(3,0),`tableId: ${n} | null`,"tableId"),_(i+f,z,dt(14,3,1),`tableId: ${n} | null`,"tableId"),_(h,W,dt(4,3,1),`tableId: ${n} | null`,"tableId"),_(m,B,dt(13,3,1),At("tableId: TId",`cellId: ${y}<TId>`+ve,"descending: boolean","offset: number","limit: number"+ve),At("tableId","cellId","descending","offset","limit"),1,"<TId extends TableId>"),_(C,F,dt(5,3),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(f,Q,dt(6,5,1),`tableId: ${n} | null, rowId: IdOrNull`,"tableId, rowId"),_(g,le,dt(7,5),`tableId: ${n} | null, rowId: IdOrNull, cellId: ${R(D((e=>{var t,a;return null!=(a=null==(t=te(de,e))?void 0:t[4])?a:l}))," | ")} | null`,"tableId, rowId, cellId"),_(ge+g,ae,ke+" whenever an invalid Cell change was attempted","tableId: IdOrNull, rowId: IdOrNull, cellId: IdOrNull","tableId, rowId, cellId"),c(1,Z,...K(Y)),A(X,".set"+p+Ae+"({",Rt(D(((e,t,a)=>[`[${a}]: {`,...j(e,((e,t,a,n)=>`[${n}]: {[${k(Pt(r),`'${r}'`)}]: ${k(Pt(t),`'${t}'`)}${G(a)?l:`, [${k(Pt(s),`'${s}'`)}]: `+(J(a)?k(Pt(a),`'${a}'`):a)}},`)),"},"]))),"})")}if(Q(a))c(null,t,y);else{const[e,a,n,d,I,u,$,i,p]=M(q,H);c(1,Z,e,a,n,I,u,$,i,p),de=[e,a,n,u,$,i],x([[e],[o],[H,"values: "+a,"values"],[H],[H,"partialValues: "+a,"partialValues"]],(([e,t,a],n)=>U(n,l,y,e,Ye(2,n),t,a))),U(0,l,v,n+De,tt(w,je)),U(5,l,w,"void",lt(w,je),"valueCallback: "+I,"valueCallback as any"),N(((e,t,a,n,d)=>{const r="Map"+kt(t,1);ne(Y,t,r),x([[t],[o],[H,`value: ${t} | `+r,", value as any"],[H]],(([t,a,o=l],r)=>U(r,d,w,t,$t(e,r),a,n+o)))})),U(0,l,y+fe,fe,Ye(2,6)),U(2,l,y+fe,H,Ye(2,7),"valuesJson: "+fe,"values"+fe),_(y,u,Ye(2,8)+" changes"),_(v,$,dt(10,0,1)),_(w,i,dt(11,0),`valueId: ${n} | null`,"valueId"),_(ge+w,p,ke+" whenever an invalid Value change was attempted","valueId: IdOrNull","valueId"),c(1,Z,...K(Y)),c(0,t,"ValueChange"),A(X,".set"+y+Ae+"({",N(((e,t,a,n)=>[`[${n}]: {[${k(Pt(r),`'${r}'`)}]: ${k(Pt(t),`'${t}'`)}${G(a)?l:`, [${k(Pt(s),`'${s}'`)}]: `+(J(a)?k(Pt(a),`'${a}'`):a)}},`])),"})")}U(0,l,"Content",`[${p}, ${y}]`,Ye(0,0)),U(2,l,"Content",H,Ye(0,2),`[tables, values]: [${p}, ${y}]`,"[tables, values]"),U(2,l,Le,H,`Applies a set of ${Le} to the Store`,"transactionChanges: "+Le,"transactionChanges"),le(Y,((e,t)=>T(t,`(cell: ${e}${ve}) => `+e,`Takes a ${e} Cell value and returns another`))),c(null,t,"DoRollback",me,"IdOrNull",fe,"Store",Le),c(0,t,"Get"+Le,"GetTransactionLog"),U(0,l,fe,fe,Ye(0,6)),U(2,l,fe,H,Ye(0,7),"tablesAndValuesJson: "+fe,"tablesAndValuesJson"),U(7,l,Ge,"Return",Me,Ce,"actions, doRollback","<Return>"),U(7,l,"start"+Ne,H,Je),U(7,l,"finish"+Ne,H,ze,be,"doRollback");const re=z(q,H);return _("Start"+Ne,re,ke+" just before the start of the "+Ge,l,l,0),_("WillFinish"+Ne,re,ke+" just before "+We,l,l,0),_("DidFinish"+Ne,re,ke+" just after "+We,l,l,0),U(7,l,"call"+I,H,"Manually provoke a listener to be called","listenerId: Id","listenerId"),U(3,l,I,H,"Remove a listener that was previously added to "+je,"listenerId: Id","listenerId"),F("getStore",l,"Store","store",it[0]+" the underlying Store object"),c(1,t,"createStore"),c(1,Z,H,`create${H} as create${H}Decl`,re),k("store",["createStore()",...X]),V("fluent","actions: () => Store",["actions();",`return ${q};`]),V("proxy","listener: any",`(_: Store, ...params: any[]) => listener(${q}, ...params)`),k(q,["{",...B(1),"}"]),[d(...P(0),...S(),he+" interface "+H+" {",...B(0),"}",l,St(`Creates a ${H} object`),he+" function create"+H+"(): "+H+";"),d(...P(1),he+" const create"+H+": typeof create"+H+"Decl = () => {",...O(),`return Object.freeze(${q});`,"};"),oe,de]},Wt=e=>c+e,Bt=e=>At(Wt(e),Wt(e)+ie),Ft="debugIds?: boolean",Ut="debugIds={debugIds}",_t="then"+pe,Zt="Parameter",Ht=": (parameter: "+Zt+", store: Store) => ",Qt="const contextValue = useContext(Context);",qt=", based on a parameter",Kt=": ",Xt="<"+Zt+",>",Yt=Zt+"ized"+ue+"<"+Zt+">",el="rowId",tl="rowId={rowId}",ll=", separator, debugIds",al="separator?: ReactElement | string",nl="then?: (store: Store",ol=At(nl+")"+Fe,_t),dl="then, then"+ie,rl=el+Kt+me,sl="View",Il=(e,...t)=>At(...t,we+": "+e,we+pe,"mutator?: boolean"),cl=(...e)=>At(...e,we,we+ie,"mutator"),ul=(e,a,n,o,d)=>{const[r,s,c,u,T,V,x,k]=Dt(),[P,S,O]=Nt(e,a,T),D=`./${kt(n)}.d`,j=`./${kt(n)}-ui-react.d`,N="tinybase/ui-react",L=kt(n,1),M=kt(L),J=L+"Or"+L+me,z=M+"Or"+L+me,W=M+`={${M}}`,B=ee(),F=(e,t,a,n,o,d=l)=>(s(1,j,e+" as "+e+"Decl"),Tt(B,e,[t,a,n,o,d])),U=(e,t,a,n,o,d=l)=>F("use"+e,t,a,n,o,d),_=(e,t,a,n,o=l,d=l,r=l,I=l,c=l)=>(s(1,N,`use${t} as use${t}Core`),U(e,At(o,X,I),a,le+`(${z}, use${t}Core, [`+(d||l)+(c?"], ["+c:l)+"]);",n,r)),Z=(e,t,l,a)=>F(e,t,1,l,a),H=(e=0)=>ae(B,(([t,a,n,o,d],r)=>{const s=e?[he+` const ${r}: typeof ${r}Decl = ${d}(${t}): ${1==a?"any":a} =>`,n]:[he+` function ${r}${d}(${t}): ${1==a?"ComponentReturnType":a};`];return e||E(s,St(o)),A(s,l),s}));s(null,t,me,"Store",ue,Zt+"ized"+ue),s(0,N,"ComponentReturnType"),s(1,N,"useCellIds"),s(null,N,"ExtraProps"),s(0,D,L);const q=c(J,L+" | "+me,`Used when you need to refer to a ${L} in a React hook or component`),K=c(Re+xe,Et(M+ye+L,M+`ById?: {[${M}Id: Id]: ${L}}`),`Used with the ${Re} 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+ye+q;T("{createContext, useContext, useMemo}","React"),T("Context",`createContext<[${L}?, {[${M}Id: Id]: ${L}}?]>([])`),U("Create"+L,`create: () => ${L}, create`+pe,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 ${Re} component context`),le=u("useHook",z+`: ${q} | undefined, hook: (...params: any[]) => any, preParams: any[], postParams: any[] = []`,[`const ${M} = ${Y}(${z} as Id);`,`return hook(...preParams, ((${z} == null || typeof ${z} == 'string')`,`? ${M} : ${z})?.getStore(), ...postParams)`]),ne=u("getProps","getProps: ((id: any) => ExtraProps) | undefined, id: Id","(getProps == null) ? ({} as ExtraProps) : getProps(id)"),oe=u("wrap",At("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",At("customCellIds: Ids | undefined","tableId: Id","rowId: Id",`${z}?: ${q} | undefined`),[`const defaultCellIds = ${le}(${z}, useCellIds, [tableId, rowId]);`,"return customCellIds ?? defaultCellIds;"]),re=T("NullComponent","() => null");if(!Q(e)){const[e,a,n,d,r,w,y,v,T,V,x,k,A,O]=o;s(null,D,e,a,n,r,w,y,v,T,V,x,k,A),s(0,D,d),s(1,D,L),s(null,t,$,"IdOrNull");const E=u("tableView",`{${M}, rowComponent, getRowComponentProps, customCellIds`+ll+"}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>",["const Row = rowComponent ?? defaultRowComponent;",`return ${oe}(rowIds.map((rowId) => (`,"<Row","{..."+ne+"(getRowComponentProps, rowId)}","key={rowId}","tableId={tableId}",tl,"customCellIds={customCellIds}",W,Ut,"/>","))",ll,", tableId,",");"]),N=u("getDefaultTableComponent","tableId: Id",R(P(((e,t,l)=>`tableId == ${l} ? ${t}TableView : `)))+re),J=u("getDefaultCellComponent","tableId: Id, cellId: Id",R(P(((e,t,l)=>`tableId == ${l} ? ${R(S(e,((e,l,a,n,o)=>`cellId == ${n} ? `+t+o+"CellView : ")))+re} : `)))+re);_(p,p,e,Ye(1,0)+ce);const z=_(b,b,n+De,tt(i,je)+ce);_(Oe+p+ue,Oe+p+ue,Yt,Ye(1,9)+qt,At(Wt(p)+Ht+a,Wt(p)+pe),Bt(p),Xt,At(nl,`tables: ${a})`+Fe,_t),dl),_($e+p+ue,$e+p+ue,ue,Ye(1,12),l,l,l,ol,dl);const B=c(g+xe,Et("tableId?: TId","rowId: Id","cellId?: CId",M+ye+L,Ft),at(se+g),`<TId extends ${n}, CId extends ${d}<TId>>`),F=c(C+xe,Et("tableId?: TId","rowId: Id",M+ye+L,"cellComponents?: {readonly [CId in "+d+`<TId>]?: ComponentType<${B}<TId, CId>>;}`,`getCellComponentProps?: (cellId: ${d}<TId>) => ExtraProps`,`customCellIds?: ${d}<TId>[]`,al,Ft),at(se+C),`<TId extends ${n}>`),U=c(i+xe,Et("tableId?: TId",M+ye+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(se+i),`<TId extends ${n}>`),H=c("Sorted"+i+xe,Et("tableId?: TId","cellId?: "+d+"<TId>","descending?: boolean","offset?: number","limit?: number",M+ye+L,`rowComponent?: ComponentType<${F}<TId>>`,"getRowComponentProps?: (rowId: Id) => ExtraProps","customCellIds?: CellId<TId>[]",al,Ft),at(se+"sorted "+i),`<TId extends ${n}>`),Q=c(p+xe,Et(M+ye+L,"tableComponents?: {readonly [TId in "+n+`]?: ComponentType<${U}<TId>>;}`,`getTableComponentProps?: (tableId: ${n}) => ExtraProps`,al,Ft),at(Xe(1,1)));s(1,j,Q,U,H,F,B),Z(p+sl,"{"+M+", tableComponents, getTableComponentProps"+ll+"}: "+Q,[oe+`(${z}(${M}).map((tableId) => {`,"const Table = (tableComponents?.[tableId] ?? "+N+"(tableId)) as React.ComponentType<TableProps<typeof tableId>>;","return <Table",`{...${ne}(getTableComponentProps, tableId)}`,"tableId={tableId}","key={tableId}",W,Ut,"/>;","}), separator)"],Ye(1,13)+ce),P(((e,t,a)=>{const[n,o,d,r,I]=te(O,e);s(null,D,n,o,d,r,I),_(t+i,i,n,It(e)+ce,l,a),_(t+i+f,i+f,$,tt(g,"the whole of "+rt(e))+ce,l,a);const c=_(t+h,h,$,tt(C,rt(e))+ce,l,a),u=_(t+m,m,$,tt(C,rt(e),1)+ce,"cellId?: "+I+", descending?: boolean, offset?: number, limit?: number",a+", cellId, descending, offset, limit");_(t+C,C,d,ct(e)+ce,rl,At(a,el)),_(t+f,f,I+De,tt(g,st(e))+ce,rl,At(a,el)),_(Oe+t+i+ue,Oe+i+ue,Yt,It(e,9)+qt,At(Wt(i)+Ht+o,Wt(i)+pe),At(a,Bt(i)),Xt,At(nl,`table: ${o})`+Fe,_t),dl),_($e+t+i+ue,$e+i+ue,ue,It(e,12),l,a,l,ol,dl),_(Oe+t+C+ue,Oe+C+ue,Yt,ct(e,9)+qt,At(rl,Wt(C)+Ht+r,Wt(C)+pe),At(a,el,Bt(C)),Xt,At(nl,`row: ${r})`+Fe,_t),dl),_("Add"+t+C+ue,"Add"+C+ue,Yt,ct(e,10)+qt,At(Wt(C)+Ht+r,Wt(C)+pe),At(a,Bt(C)),Xt,"then?: ("+At(rl+ve,"store: Store","row: "+r+")"+Fe,"then"+pe)+", reuseRowIds?: boolean",dl+", reuseRowIds"),_(Oe+t+Ve+C+ue,Oe+Ve+C+ue,Yt,ct(e,11)+qt,At(rl,Wt(Ve+C)+Ht+r,Wt(Ve+C)+pe),At(a,el,Bt(Ve+C)),Xt,At(nl,`partialRow: ${r})`+Fe,_t),dl),_($e+t+C+ue,$e+C+ue,ue,ct(e,12),rl,At(a,el),l,ol,dl);const p=Z(t+C+sl,"{rowId, "+M+", cellComponents, getCellComponentProps, customCellIds"+ll+`}: ${F}<'${e}'>`,[oe+`(${de}(customCellIds, `+a+`, rowId, ${M}).map((cellId: ${I}) => {`,"const Cell = (cellComponents?.[cellId] ?? "+J+`(${a}, cellId)) as React.ComponentType<CellProps<typeof `+a+", typeof cellId>>;","return <Cell",`{...${ne}(getCellComponentProps, cellId)} `,"key={cellId}",`tableId={${a}}`,tl,"cellId={cellId}",W,Ut,"/>;","})"+ll+", rowId)"],ct(e,13)+ce);Z(t+"Sorted"+i+sl,"{cellId, descending, offset, limit, ...props}: "+H+`<'${e}'>`,E+"(props, "+u+`(cellId, descending, offset, limit, props.${M}), ${a}, ${p});`,It(e,13)+", sorted"+ce),Z(t+i+sl,`props: ${U}<'${e}'>`,E+"(props, "+c+`(props.${M}), ${a}, ${p});`,It(e,13)+ce),S(e,((n,o,d,r,I)=>{const c="Map"+kt(o,1);s(0,D,c),s(1,D,c);const u=_(t+I+g,g,o+(G(d)?ve:l),ut(e,n)+ce,rl,At(a,el,r));_(Oe+t+I+g+ue,Oe+g+ue,Yt,ut(e,n,9)+qt,At(rl,Wt(g)+Ht+o+" | "+c,Wt(g)+pe),At(a,el,r,Bt(g)),Xt,At(nl,`cell: ${o} | ${c})`+Fe,_t),dl),_($e+t+I+g+ue,$e+g+ue,ue,ut(e,n,12),At(rl,"forceDel?: boolean"),At(a,el,r,"forceDel"),l,ol,dl),Z(t+I+g+sl,`{rowId, ${M}, debugIds}: `+B+`<'${e}', '${n}'>`,[oe+`('' + ${u}(rowId, `+M+`) ?? '', undefined, debugIds, ${r})`],ut(e,n,13)+ce)}))}));const q=R(P((e=>{var t,a;return null!=(a=null==(t=te(O,e))?void 0:t[4])?a:l}))," | ");_(p+I,p+I,Be,Ye(1,8)+" changes",Il(r),cl()),_(b+I,b+I,Be,dt(2,0,1),Il(w),cl()),_(i+I,i+I,Be,dt(3,0),Il(y,`tableId: ${n} | null`),cl("tableId")),_(i+f+I,i+f+I,Be,dt(14,3,1),Il(v,`tableId: ${n} | null`),cl("tableId")),_(h+I,h+I,Be,dt(4,3,1),Il(T,`tableId: ${n} | null`),cl("tableId")),_(m+I,m+I,Be,dt(13,3,1),Il(V,`tableId: ${n} | null`,"cellId: "+q+ve,"descending: boolean","offset: number","limit: number"+ve),cl("tableId","cellId","descending","offset","limit")),_(C+I,C+I,Be,dt(5,3),Il(x,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(f+I,f+I,Be,dt(6,5,1),Il(k,`tableId: ${n} | null`,el+": IdOrNull"),cl("tableId",el)),_(g+I,g+I,Be,dt(7,5),Il(A,`tableId: ${n} | null`,el+": IdOrNull",`cellId: ${q} | null`),cl("tableId",el,"cellId"))}if(!Q(a)){const[e,t,a,n,o,r]=d;s(null,D,...d),s(1,D,L);const $=u("getDefaultValueComponent","valueId: Id",R(O(((e,t,l,a,n)=>`valueId == ${a} ? `+n+"ValueView : ")))+re);_(y,y,e,Ye(2,0)+ce);const i=_(v,v,a+De,tt(w,je)+ce);_(Oe+y+ue,Oe+y+ue,Yt,Ye(2,9)+qt,At(Wt(y)+Ht+t,Wt(y)+pe),Bt(y),Xt,At(nl,`values: ${t})`+Fe,_t),dl),_(Oe+Ve+y+ue,Oe+Ve+y+ue,Yt,Ye(2,11)+qt,At(Wt(Ve+y)+Ht+t,Wt(Ve+y)+pe),Bt(Ve+y),Xt,At(nl,`partialValues: ${t})`+Fe,_t),dl),_($e+y+ue,$e+y+ue,ue,Ye(2,12),l,l,l,ol,dl);const p=c(w+xe,Et("valueId?: VId",M+ye+L,Ft),at("a Value"),`<VId extends ${a}>`),b=c(y+xe,Et(M+ye+L,"valueComponents?: {readonly [VId in "+a+`]?: ComponentType<${p}<VId>>;}`,`getValueComponentProps?: (valueId: ${a}) => ExtraProps`,al,Ft),at(Xe(2,1)));s(1,j,b,p),Z(y+sl,"{"+M+", valueComponents, getValueComponentProps"+ll+"}: "+b,[oe+`(${i}(${M}).map((valueId) => {`,"const Value = valueComponents?.[valueId] ?? "+$+"(valueId);","return <Value",`{...${ne}(getValueComponentProps, valueId)}`,"key={valueId}",W,Ut,"/>;","}), separator)"],Ye(2,13)+ce),O(((e,t,a,n,o)=>{const d="Map"+kt(t,1);s(0,D,d),s(1,D,d);const r=_(o+w,w,t,$t(e)+ce,l,n);_(Oe+o+w+ue,Oe+w+ue,Yt,$t(e,9)+qt,At(Wt(w)+Ht+t+" | "+d,Wt(w)+pe),At(n,Bt(w)),Xt,At(nl,`value: ${t} | ${d})`+Fe,_t),dl),_($e+o+w+ue,$e+w+ue,ue,$t(e,12),l,n,l,ol,dl),Z(o+w+sl,`{${M}, debugIds}: ${p}<'${e}'>`,[oe+`('' + ${r}(`+M+`) ?? '', undefined, debugIds, ${n})`],$t(e,13)+ce)})),_(y+I,y+I,Be,Ye(2,8)+" changes",Il(n),cl()),_(v+I,v+I,Be,dt(10,0,1),Il(o),cl()),_(w+I,w+I,Be,dt(11,0),Il(r,`valueId: ${a} | null`),cl("valueId"))}return Z(Re,`{${M}, ${M}ById, children}: `+K+" & {children: React.ReactNode}",["{",Qt,"return (","<Context."+Re,"value={useMemo(",`() => [${M} ?? contextValue[0], {...contextValue[1], ...${M}ById}],`,`[${M}, ${M}ById, contextValue],`,")}>","{children}",`</Context.${Re}>`,");","}"],"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),...k(),...H(1))]},$l=(e,t,a)=>{if(Q(e)&&Q(t))return[l,l,l,l];const[n,o,d,r]=zt(e,t,a);return[n,o,...ul(e,t,a,d,r)]};var il=Object.defineProperty,pl=Object.defineProperties,bl=Object.getOwnPropertyDescriptors,Cl=Object.getOwnPropertySymbols,hl=Object.prototype.hasOwnProperty,ml=Object.prototype.propertyIsEnumerable,gl=(e,t,l)=>t in e?il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,fl=(e,t)=>{for(var l in t||(t={}))hl.call(t,l)&&gl(e,l,t[l]);if(Cl)for(var l of Cl(t))ml.call(t,l)&&gl(e,l,t[l]);return e},wl=(e,t)=>pl(e,bl(t)),yl=(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},Tl=jt((e=>{const t=()=>{const t=j(e.getTablesSchemaJson());return!Q(t)||T(e.getTableIds(),(l=>{const a=e.getRowIds(l),n=ee();if(T(a,(t=>T(e.getCellIds(l,t),(a=>{const o=e.getCell(l,t,a),d=oe(n,a,(()=>[W(o),ee(),[0],0])),[r,s,[I]]=d,c=oe(s,o,(()=>0))+1;return c>I&&(d[2]=[c,o]),ne(s,o,c),d[3]++,r==W(o)})))))return t[l]={},X(n,(([e,,[,n],o],d)=>{t[l][d]=fl({[r]:e},o==P(a)?{[s]:n}:{})})),1}))?t:{}},l=()=>{const t=j(e.getValuesSchemaJson());return Q(t)&&e.forEachValue(((e,l)=>{t[e]={[r]:W(l)}})),t},a=e=>$l(t(),l(),e),n=e=>yl(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 k(a(e),((e,a)=>Vt(l(e,wl(fl({},vl),{filepath:"_."+t[a]})))))}));return U({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})})),fl({totalTables:l,totalRows:a,totalCells:n,totalValues:P(e.getValueIds()),jsonLength:xt(e.getJson())},t?{detail:{tables:o}}:{})},getStoreTablesSchema:t,getStoreValuesSchema:l,getStoreApi:a,getPrettyStoreApi:n,getStore:()=>e})}));exports.createTools=Tl;
|
package/lib/cjs-es6/tools.cjs.gz
CHANGED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./ui-react"),l=require("react");const r=e=>typeof e,t=r(""),s=(e,l)=>e.map(l),o=e=>null==e,u=Object,n=(e=[])=>u.fromEntries(e),a=(e,l)=>s(u.entries(e),(([e,r])=>l(r,e))),{createContext:d,useContext:i}=l;d([]);const I=(e,...l)=>o(e)?{}:e(...l);var c=Object.defineProperty,b=Object.defineProperties,C=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,p=(e,l,r)=>l in e?c(e,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[l]=r,w=(e,l)=>{for(var r in l||(l={}))m.call(l,r)&&p(e,r,l[r]);if(f)for(var r of f(l))y.call(l,r)&&p(e,r,l[r]);return e},O=(e,l)=>b(e,C(l)),T=(e,l)=>{var r={};for(var t in e)m.call(e,t)&&l.indexOf(t)<0&&(r[t]=e[t]);if(null!=e&&f)for(var t of f(e))l.indexOf(t)<0&&y.call(e,t)&&(r[t]=e[t]);return r};const{createElement:v,useCallback:g,useMemo:k,useState:q}=l,R=(e,l,r)=>{const t=g(e,l);return r?t:void 0},h=(e,l)=>o(e)||e[0]!=l?void 0:`sorted ${e[1]?"de":"a"}scending`,V=({cellId:e,sorting:l,label:r=(null!=e?e:""),onClick:t})=>v("th",{onClick:R((()=>null==t?void 0:t(e)),[t,e],!o(t)),className:h(l,e)},r),Q=({className:l,headerRow:o,idColumn:u,customCells:d,storeTableIdOrQueriesQueryId:i,defaultCellView:c=e.CellView,rowIds:b,defaultCellIds:C,sorting:f,onHeaderThClick:m})=>{const y=k((()=>{const e=null!=d?d:C;return n(a(Array.isArray(e)?n(s(e,(e=>[e,e]))):e,((e,l)=>{return[l,w(w({},{label:l}),(s=e,r(s)==t?{label:e}:e))];var s})))}),[d,C]);return v("table",{className:l},!1===o?null:v("thead",null,v("tr",null,!1===u?null:v(V,{sorting:f,label:"Id",onClick:m}),a(y,(({label:e},l)=>v(V,{key:l,cellId:l,label:e,sorting:f,onClick:m}))))),v("tbody",null,s(b,(e=>v("tr",{key:e},!1===u?null:v("th",null,e),a(y,(({component:l=c,getComponentProps:r},t)=>v("td",{key:t},v(l,O(w(w({},I(r,e,t)),i),{rowId:e,cellId:t}))))))))))};exports.ResultSortedTableInHtmlTable=l=>{var r=l,{queryId:t,cellId:s,descending:o,offset:u,limit:n,queries:a,sortOnClick:d}=r,i=T(r,["queryId","cellId","descending","offset","limit","queries","sortOnClick"]);const[I,c]=q([s,!!o]),b=R((e=>c([e,e==I[0]&&!I[1]])),[I],d);return v(Q,O(w({},i),{storeTableIdOrQueriesQueryId:k((()=>({queries:a,queryId:t})),[a,t]),defaultCellView:e.ResultCellView,rowIds:e.useResultSortedRowIds(t,...I,u,n,a),defaultCellIds:e.useResultTableCellIds(t,a),sorting:I,onHeaderThClick:b}))},exports.ResultTableInHtmlTable=l=>{var r=l,{queryId:t,queries:s}=r,o=T(r,["queryId","queries"]);return v(Q,O(w({},o),{storeTableIdOrQueriesQueryId:k((()=>({queries:s,queryId:t})),[s,t]),defaultCellView:e.ResultCellView,rowIds:e.useResultRowIds(t,s),defaultCellIds:e.useResultTableCellIds(t,s)}))},exports.SortedTableInHtmlTable=l=>{var r=l,{tableId:t,cellId:s,descending:o,offset:u,limit:n,store:a,sortOnClick:d}=r,i=T(r,["tableId","cellId","descending","offset","limit","store","sortOnClick"]);const[I,c]=q([s,!!o]),b=R((e=>c([e,e==I[0]&&!I[1]])),[I],d);return v(Q,O(w({},i),{storeTableIdOrQueriesQueryId:k((()=>({store:a,tableId:t})),[a,t]),rowIds:e.useSortedRowIds(t,...I,u,n,a),defaultCellIds:e.useTableCellIds(t,a),sorting:I,onHeaderThClick:b}))},exports.TableInHtmlTable=l=>{var r=l,{tableId:t,store:s}=r,o=T(r,["tableId","store"]);return v(Q,O(w({},o),{storeTableIdOrQueriesQueryId:k((()=>({store:s,tableId:t})),[s,t]),rowIds:e.useRowIds(t,s),defaultCellIds:e.useTableCellIds(t,s)}))},exports.ValuesInHtmlTable=({store:l,valueComponent:r=e.ValueView,getValueComponentProps:t,className:o,headerRow:u,idColumn:n})=>v("table",{className:o},!1===u?null:v("thead",null,v("tr",null,!1===n?null:v("th",null,"Id"),v("th",null,"Value"))),v("tbody",null,s(e.useValueIds(l),(e=>v("tr",{key:e},!1===n?null:v("th",null,e),v("td",null,v(r,O(w({},I(t,e)),{valueId:e,store:l}))))))));
|
|
Binary file
|
package/lib/cjs-es6/ui-react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r="Ids",l="Table",u=l+"s",d=l+r,n="Row",i=n+r,a="Sorted"+n+r,p="Cell",c=p+r,I="Value",x=I+"s",w=I+r,b=(e,s)=>e.map(s),R=e=>null==e,C=(e,s,t)=>R(e)?null==t?void 0:t():s(e),k=e=>s(e)==o,v=()=>{},{createContext:g,useContext:m}=e,h=g([]),y=(e,s)=>{const t=m(h);return R(e)?t[s]:k(e)?((e,s)=>C(e,(e=>e[s])))(t[s+1],e):e},L=(e,s)=>{const t=y(e,s);return R(e)||k(e)?t:e},V=e=>L(e,0),S=e=>L(e,2),f=e=>L(e,4),T=e=>L(e,6),P=e=>L(e,8),q=e=>L(e,10),{useCallback:O,useEffect:B,useMemo:M,useRef:D,useState:j}=e,A=(e,s,t=[])=>{const o=M((()=>s(e)),[e,...t]);return B((()=>()=>o.destroy()),[o]),o},E=(e,s,t,o=[],r)=>{const[,l]=j(),u=O((()=>{var r,l;return null!=(l=null==(r=null==s?void 0:s["get"+e])?void 0:r.call(s,...o))?l:t}),[s,...o]),[d]=j(u),n=D(d);return M((()=>n.current=u()),[u]),F(e,s,((...e)=>{n.current=R(r)?u():e[r],l([])}),[],o),n.current},F=(e,s,t,o=[],r=[],...l)=>B((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...r,t,...l);return()=>null==s?void 0:s.delListener(u)}),[s,...r,...o,...l]),G=(e,s,t,o=[],r=v,l=[],...u)=>{const d=V(e);return O((e=>C(d,(o=>C(t(e,o),(e=>r(o["set"+s](...u,e),e)))))),[d,s,...o,...l,...u])},Q=(e,s,t=v,o=[],...r)=>{const l=V(e);return O((()=>t(null==l?void 0:l["del"+s](...r))),[l,s,...o,...r])},U=(e,s,t)=>{const o=q(e);return O((()=>null==o?void 0:o[s](t)),[o,s,t])},z=e=>E(d,V(e),[],[]),H=(e,s)=>E(i,V(s),[],[e]),J=(e,s,t,o=0,r,l)=>E(a,V(l),[],[e,s,t,o,r],6),K=(e,s,t)=>E(c,V(t),[],[e,s]),N=(e,s,t,o)=>E(p,V(o),void 0,[e,s,t],4),W=e=>E(w,V(e),[],[]),X=(e,s)=>E(I,V(s),void 0,[e]),Y=(e,s)=>E("Metric",S(s),void 0,[e]),Z=(e,s)=>E("SliceIds",f(s),[],[e]),$=(e,s,t)=>E("SliceRowIds",f(t),[],[e,s]),_=(e,s,t)=>E("RemoteRowId",T(t),void 0,[e,s]),ee=(e,s,t)=>E("LocalRowIds",T(t),[],[e,s]),se=(e,s,t)=>E("LinkedRowIds",T(t),[],[e,s]),te=(e,s)=>E("ResultRowIds",P(s),[],[e]),oe=(e,s,t,o=0,r,l)=>E("ResultSortedRowIds",P(l),[],[e,s,t,o,r],6),re=(e,s,t)=>E("ResultCellIds",P(t),[],[e,s]),le=(e,s,t,o)=>E("ResultCell",P(o),void 0,[e,s,t]),ue=e=>E("CheckpointIds",q(e),[[],void 0,[]]),de=(e,s)=>E("Checkpoint",q(s),void 0,[e]),ne=e=>U(e,"goBackward"),ie=e=>U(e,"goForward");var ae=Object.defineProperty,pe=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertySymbols,xe=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable,be=(e,s,t)=>s in e?ae(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,Re=(e,s)=>{for(var t in s||(s={}))xe.call(s,t)&&be(e,t,s[t]);if(Ie)for(var t of Ie(s))we.call(s,t)&&be(e,t,s[t]);return e},Ce=(e,s)=>pe(e,ce(s)),ke=(e,s)=>{var t={};for(var o in e)xe.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&Ie)for(var o of Ie(e))s.indexOf(o)<0&&we.call(e,o)&&(t[o]=e[o]);return t};const{createElement:ve,useMemo:ge}=e,me=({tableId:e,store:s,rowComponent:t=Pe,getRowComponentProps:o,separator:r,debugIds:l},u)=>fe(b(u,(r=>ve(t,Ce(Re({},Se(o,r)),{key:r,tableId:e,rowId:r,store:s,debugIds:l})))),r,l,e),he=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:r,debugIds:l},u)=>fe(b(u,(r=>ve(t,Ce(Re({},Se(o,r)),{key:r,queryId:e,rowId:r,queries:s,debugIds:l})))),r,l,e),ye=e=>{const s=T(e);return[s,null==s?void 0:s.getStore()]},Le=({relationshipId:e,relationships:s,rowComponent:t=Pe,getRowComponentProps:o,separator:r,debugIds:l},u,d)=>{const[n,i]=ye(s),a=null==n?void 0:n.getLocalTableId(e),p=u(e,d,n);return fe(b(p,(e=>ve(t,Ce(Re({},Se(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:l})))),r,l,d)},Ve=e=>({checkpoints:s,checkpointComponent:t=je,getCheckpointComponentProps:o,separator:r,debugIds:l})=>{const u=q(s);return fe(b(e(ue(u)),(e=>ve(t,Ce(Re({},Se(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:l})))),r)},Se=(e,s)=>R(e)?{}:e(s),fe=(e,s,t,o)=>{const r=R(s)||!Array.isArray(e)?e:b(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},Te=({tableId:e,rowId:s,cellId:o,store:r,debugIds:l})=>{var u;return fe(t+(null!=(u=N(e,s,o,r))?u:t),void 0,l,o)},Pe=({tableId:e,rowId:s,store:t,cellComponent:o=Te,getCellComponentProps:r,separator:l,debugIds:u})=>fe(b(K(e,s,t),(l=>ve(o,Ce(Re({},Se(r,l)),{key:l,tableId:e,rowId:s,cellId:l,store:t,debugIds:u})))),l,u,s),qe=e=>me(e,H(e.tableId,e.store)),Oe=({valueId:e,store:s,debugIds:o})=>{var r;return fe(t+(null!=(r=X(e,s))?r:t),void 0,o,e)},Be=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Pe,getRowComponentProps:r,separator:l,debugIds:u})=>{const d=f(t),n=null==d?void 0:d.getStore(),i=null==d?void 0:d.getTableId(e),a=$(e,s,d);return fe(b(a,(e=>ve(o,Ce(Re({},Se(r,e)),{key:e,tableId:i,rowId:e,store:n,debugIds:u})))),l,u,s)},Me=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:l})=>{var u;return fe(t+(null!=(u=le(e,s,o,r))?u:t),void 0,l,o)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Me,getResultCellComponentProps:r,separator:l,debugIds:u})=>fe(b(re(e,s,t),(l=>ve(o,Ce(Re({},Se(r,l)),{key:l,queryId:e,rowId:s,cellId:l,queries:t,debugIds:u})))),l,u,s),je=({checkpoints:e,checkpointId:s,debugIds:o})=>{var r;return fe(null!=(r=de(s,e))?r:t,void 0,o,s)},Ae=Ve((e=>e[0])),Ee=Ve((e=>R(e[1])?[]:[e[1]])),Fe=Ve((e=>e[2]));exports.BackwardCheckpointsView=Ae,exports.CellView=Te,exports.CheckpointView=je,exports.CurrentCheckpointView=Ee,exports.ForwardCheckpointsView=Fe,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=Be,getSliceComponentProps:o,separator:r,debugIds:l})=>fe(b(Z(e,s),(r=>ve(t,Ce(Re({},Se(o,r)),{key:r,indexId:e,sliceId:r,indexes:s,debugIds:l})))),r,l,e),exports.LinkedRowsView=e=>Le(e,se,e.firstRowId),exports.LocalRowsView=e=>Le(e,ee,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>{var r;return fe(null!=(r=Y(e,s))?r:t,void 0,o,e)},exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:u,relationships:d,relationshipsById:n,queries:i,queriesById:a,checkpoints:p,checkpointsById:c,children:I})=>{const x=e.useContext(h);return ve(h.Provider,{value:ge((()=>[null!=s?s:x[0],Re(Re({},x[1]),t),null!=o?o:x[2],Re(Re({},x[3]),r),null!=l?l:x[4],Re(Re({},x[5]),u),null!=d?d:x[6],Re(Re({},x[7]),n),null!=i?i:x[8],Re(Re({},x[9]),a),null!=p?p:x[10],Re(Re({},x[11]),c)]),[s,t,o,r,l,u,d,n,i,a,p,c,x])},I)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Pe,getRowComponentProps:r,debugIds:l})=>{const[u,d]=ye(t),n=null==u?void 0:u.getRemoteTableId(e),i=_(e,s,u);return fe(R(n)||R(i)?null:ve(o,Ce(Re({},Se(r,i)),{key:i,tableId:n,rowId:i,store:d,debugIds:l})),void 0,l,s)},exports.ResultCellView=Me,exports.ResultRowView=De,exports.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ke(s,["cellId","descending","offset","limit"]);return he(u,oe(u.queryId,t,o,r,l,u.queries))},exports.ResultTableView=e=>he(e,te(e.queryId,e.queries)),exports.RowView=Pe,exports.SliceView=Be,exports.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ke(s,["cellId","descending","offset","limit"]);return me(u,J(u.tableId,t,o,r,l,u.store))},exports.TableView=qe,exports.TablesView=({store:e,tableComponent:s=qe,getTableComponentProps:t,separator:o,debugIds:r})=>fe(b(z(e),(o=>ve(s,Ce(Re({},Se(t,o)),{key:o,tableId:o,store:e,debugIds:r})))),o),exports.ValueView=Oe,exports.ValuesView=({store:e,valueComponent:s=Oe,getValueComponentProps:t,separator:o,debugIds:r})=>fe(b(W(e),(o=>ve(s,Ce(Re({},Se(t,o)),{key:o,valueId:o,store:e,debugIds:r})))),o),exports.tableView=me,exports.useAddRowCallback=(e,s,t=[],o,r=v,l=[],u=!0)=>{const d=V(o);return O((t=>C(d,(o=>C(s(t,o),(s=>r(o.addRow(e,s,u),o,s)))))),[d,e,...t,...l,u])},exports.useCell=N,exports.useCellIds=K,exports.useCellIdsListener=(e,s,t,o,r,l)=>F(c,V(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,u)=>F(p,V(u),o,r,[e,s,t],l),exports.useCheckpoint=de,exports.useCheckpointIds=ue,exports.useCheckpointIdsListener=(e,s,t)=>F("CheckpointIds",q(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>F("Checkpoint",q(o),s,t,[e]),exports.useCheckpoints=e=>y(e,10),exports.useCreateCheckpoints=(e,s,t)=>A(e,s,t),exports.useCreateIndexes=(e,s,t)=>A(e,s,t),exports.useCreateMetrics=(e,s,t)=>A(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=j(),u=M((()=>s(e)),[e,...t]);return B((()=>{var e;return e=function*(){yield null==o?void 0:o(u),l(1)},new Promise(((s,t)=>{var o=s=>{try{l(e.next(s))}catch(e){t(e)}},r=s=>{try{l(e.throw(s))}catch(e){t(e)}},l=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,r);l((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...r]),u},exports.useCreateQueries=(e,s,t)=>A(e,s,t),exports.useCreateRelationships=(e,s,t)=>A(e,s,t),exports.useCreateStore=(e,s=[])=>M(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,u)=>Q(r,p,l,u,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>Q(t,n,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>Q(s,l,t,o,e),exports.useDelTablesCallback=(e,s,t)=>Q(e,u,s,t),exports.useDelValueCallback=(e,s,t,o)=>Q(s,I,t,o,e),exports.useDelValuesCallback=(e,s,t)=>Q(e,x,s,t),exports.useGoBackwardCallback=ne,exports.useGoForwardCallback=ie,exports.useGoToCallback=(e,s=[],t,o=v,r=[])=>{const l=q(t);return O((s=>C(l,(t=>C(e(s),(e=>o(t.goTo(e),e)))))),[l,...s,...r])},exports.useIndexes=e=>y(e,4),exports.useLinkedRowIds=se,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>F("LinkedRowIds",T(r),t,o,[e,s]),exports.useLocalRowIds=ee,exports.useLocalRowIdsListener=(e,s,t,o,r)=>F("LocalRowIds",T(r),t,o,[e,s]),exports.useMetric=Y,exports.useMetricListener=(e,s,t,o)=>F("Metric",S(o),s,t,[e]),exports.useMetrics=e=>y(e,2),exports.useQueries=e=>y(e,8),exports.useRedoInformation=e=>{var s;const o=q(e),[,,[r]]=ue(o);return[!R(r),ie(o),r,null!=(s=C(r,(e=>null==o?void 0:o.getCheckpoint(e))))?s:t]},exports.useRelationships=e=>y(e,6),exports.useRemoteRowId=_,exports.useRemoteRowIdListener=(e,s,t,o,r)=>F("RemoteRowId",T(r),t,o,[e,s]),exports.useResultCell=le,exports.useResultCellIds=re,exports.useResultCellIdsListener=(e,s,t,o,r)=>F("ResultCellIds",P(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>F("ResultCell",P(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>E("ResultRow",P(t),{},[e,s]),exports.useResultRowIds=te,exports.useResultRowIdsListener=(e,s,t,o)=>F("ResultRowIds",P(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>F("ResultRow",P(r),t,o,[e,s]),exports.useResultSortedRowIds=oe,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,u,d)=>F("ResultSortedRowIds",P(d),l,u,[e,s,t,o,r]),exports.useResultTable=(e,s)=>E("ResultTable",P(s),{},[e]),exports.useResultTableListener=(e,s,t,o)=>F("ResultTable",P(o),s,t,[e]),exports.useRow=(e,s,t)=>E(n,V(t),{},[e,s]),exports.useRowIds=H,exports.useRowIdsListener=(e,s,t,o,r)=>F(i,V(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>F(n,V(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,u,d)=>G(l,p,o,r,u,d,e,s,t),exports.useSetCheckpointCallback=(e=v,s=[],t,o=v,r=[])=>{const l=q(t);return O((s=>C(l,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[l,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,u)=>G(r,"PartialRow",t,o,l,u,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>G(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,u)=>G(r,n,t,o,l,u,e,s),exports.useSetTableCallback=(e,s,t,o,r,u)=>G(o,l,s,t,r,u,e),exports.useSetTablesCallback=(e,s,t,o,r)=>G(t,u,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>G(o,I,s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>G(t,x,e,s,o,r),exports.useSliceIds=Z,exports.useSliceIdsListener=(e,s,t,o)=>F("SliceIds",f(o),s,t,[e]),exports.useSliceRowIds=$,exports.useSliceRowIdsListener=(e,s,t,o,r)=>F("SliceRowIds",f(r),t,o,[e,s]),exports.useSortedRowIds=J,exports.useSortedRowIdsListener=(e,s,t,o,r,l,u,d,n)=>F(a,V(n),l,u,[e,s,t,o,r],d),exports.useStore=e=>y(e,0),exports.useTable=(e,s)=>E(l,V(s),{},[e]),exports.useTableCellIds=(e,s)=>E(l+c,V(s),[],[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>F(l+c,V(r),s,t,[e],o),exports.useTableIds=z,exports.useTableIdsListener=(e,s,t,o)=>F(d,V(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>F(l,V(r),s,t,[e],o),exports.useTables=e=>E(u,V(e),{}),exports.useTablesListener=(e,s,t,o)=>F(u,V(o),e,s,[],t),exports.useUndoInformation=e=>{var s;const o=q(e),[r,l]=ue(o);return[(u=r,!(0==(e=>e.length)(u))),ne(o),l,null!=(s=C(l,(e=>null==o?void 0:o.getCheckpoint(e))))?s:t];var u},exports.useValue=X,exports.useValueIds=W,exports.useValueIdsListener=(e,s,t,o)=>F(w,V(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>F(I,V(r),s,t,[e],o),exports.useValues=e=>E(x,V(e),{}),exports.useValuesListener=(e,s,t,o)=>F(x,V(o),e,s,[],t);
|
|
1
|
+
"use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r="Ids",l="Table",u=l+"s",d=l+r,n="Row",i=n+r,a="Sorted"+n+r,p="Cell",c=p+r,I="Value",x=I+"s",w=I+r,C=(e,s)=>e.map(s),b=e=>null==e,R=(e,s,t)=>b(e)?null==t?void 0:t():s(e),k=e=>s(e)==o,v=()=>{},{createContext:g,useContext:m}=e,h=g([]),y=(e,s)=>{const t=m(h);return b(e)?t[s]:k(e)?((e,s)=>R(e,(e=>e[s])))(t[s+1],e):e},L=(e,s)=>{const t=y(e,s);return b(e)||k(e)?t:e},V=(e,...s)=>b(e)?{}:e(...s),S=e=>L(e,0),T=e=>L(e,2),f=e=>L(e,4),P=e=>L(e,6),q=e=>L(e,8),O=e=>L(e,10),{useCallback:B,useEffect:M,useMemo:D,useRef:j,useState:A}=e,E=(e,s,t=[])=>{const o=D((()=>s(e)),[e,...t]);return M((()=>()=>o.destroy()),[o]),o},F=(e,s,t,o=[],r)=>{const[,l]=A(),u=B((()=>{var r,l;return null!=(l=null==(r=null==s?void 0:s["get"+e])?void 0:r.call(s,...o))?l:t}),[s,...o]),[d]=A(u),n=j(d);return D((()=>n.current=u()),[u]),G(e,s,((...e)=>{n.current=b(r)?u():e[r],l([])}),[],o),n.current},G=(e,s,t,o=[],r=[],...l)=>M((()=>{var o;const u=null==(o=null==s?void 0:s["add"+e+"Listener"])?void 0:o.call(s,...r,t,...l);return()=>null==s?void 0:s.delListener(u)}),[s,...r,...o,...l]),Q=(e,s,t,o=[],r=v,l=[],...u)=>{const d=S(e);return B((e=>R(d,(o=>R(t(e,o),(e=>r(o["set"+s](...u,e),e)))))),[d,s,...o,...l,...u])},U=(e,s,t=v,o=[],...r)=>{const l=S(e);return B((()=>t(null==l?void 0:l["del"+s](...r))),[l,s,...o,...r])},z=(e,s,t)=>{const o=O(e);return B((()=>null==o?void 0:o[s](t)),[o,s,t])},H=e=>F(d,S(e),[],[]),J=(e,s)=>F(i,S(s),[],[e]),K=(e,s,t,o=0,r,l)=>F(a,S(l),[],[e,s,t,o,r],6),N=(e,s,t)=>F(c,S(t),[],[e,s]),W=(e,s,t,o)=>F(p,S(o),void 0,[e,s,t],4),X=e=>F(w,S(e),[],[]),Y=(e,s)=>F(I,S(s),void 0,[e]),Z=(e,s)=>F("Metric",T(s),void 0,[e]),$=(e,s)=>F("SliceIds",f(s),[],[e]),_=(e,s,t)=>F("SliceRowIds",f(t),[],[e,s]),ee=(e,s,t)=>F("RemoteRowId",P(t),void 0,[e,s]),se=(e,s,t)=>F("LocalRowIds",P(t),[],[e,s]),te=(e,s,t)=>F("LinkedRowIds",P(t),[],[e,s]),oe=(e,s)=>F("ResultRowIds",q(s),[],[e]),re=(e,s,t,o=0,r,l)=>F("ResultSortedRowIds",q(l),[],[e,s,t,o,r],6),le=(e,s,t)=>F("ResultCellIds",q(t),[],[e,s]),ue=(e,s,t,o)=>F("ResultCell",q(o),void 0,[e,s,t]),de=e=>F("CheckpointIds",O(e),[[],void 0,[]]),ne=(e,s)=>F("Checkpoint",O(s),void 0,[e]),ie=e=>z(e,"goBackward"),ae=e=>z(e,"goForward");var pe=Object.defineProperty,ce=Object.defineProperties,Ie=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,we=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,be=(e,s,t)=>s in e?pe(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,Re=(e,s)=>{for(var t in s||(s={}))we.call(s,t)&&be(e,t,s[t]);if(xe)for(var t of xe(s))Ce.call(s,t)&&be(e,t,s[t]);return e},ke=(e,s)=>ce(e,Ie(s)),ve=(e,s)=>{var t={};for(var o in e)we.call(e,o)&&s.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&xe)for(var o of xe(e))s.indexOf(o)<0&&Ce.call(e,o)&&(t[o]=e[o]);return t};const{createElement:ge,useMemo:me}=e,he=({tableId:e,store:s,rowComponent:t=Pe,getRowComponentProps:o,customCellIds:r,separator:l,debugIds:u},d)=>Te(C(d,(l=>ge(t,ke(Re({},V(o,l)),{key:l,tableId:e,rowId:l,customCellIds:r,store:s,debugIds:u})))),l,u,e),ye=({queryId:e,queries:s,resultRowComponent:t=De,getResultRowComponentProps:o,separator:r,debugIds:l},u)=>Te(C(u,(r=>ge(t,ke(Re({},V(o,r)),{key:r,queryId:e,rowId:r,queries:s,debugIds:l})))),r,l,e),Le=e=>{const s=P(e);return[s,null==s?void 0:s.getStore()]},Ve=({relationshipId:e,relationships:s,rowComponent:t=Pe,getRowComponentProps:o,separator:r,debugIds:l},u,d)=>{const[n,i]=Le(s),a=null==n?void 0:n.getLocalTableId(e),p=u(e,d,n);return Te(C(p,(e=>ge(t,ke(Re({},V(o,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:l})))),r,l,d)},Se=e=>({checkpoints:s,checkpointComponent:t=je,getCheckpointComponentProps:o,separator:r,debugIds:l})=>{const u=O(s);return Te(C(e(de(u)),(e=>ge(t,ke(Re({},V(o,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:l})))),r)},Te=(e,s,t,o)=>{const r=b(s)||!Array.isArray(e)?e:C(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},fe=({tableId:e,rowId:s,cellId:o,store:r,debugIds:l})=>{var u;return Te(t+(null!=(u=W(e,s,o,r))?u:t),void 0,l,o)},Pe=({tableId:e,rowId:s,store:t,cellComponent:o=fe,getCellComponentProps:r,customCellIds:l,separator:u,debugIds:d})=>Te(C(((e,s,t,o)=>{const r=N(s,t,o);return null!=e?e:r})(l,e,s,t),(l=>ge(o,ke(Re({},V(r,l)),{key:l,tableId:e,rowId:s,cellId:l,store:t,debugIds:d})))),u,d,s),qe=e=>he(e,J(e.tableId,e.store)),Oe=({valueId:e,store:s,debugIds:o})=>{var r;return Te(t+(null!=(r=Y(e,s))?r:t),void 0,o,e)},Be=({indexId:e,sliceId:s,indexes:t,rowComponent:o=Pe,getRowComponentProps:r,separator:l,debugIds:u})=>{const d=f(t),n=null==d?void 0:d.getStore(),i=null==d?void 0:d.getTableId(e),a=_(e,s,d);return Te(C(a,(e=>ge(o,ke(Re({},V(r,e)),{key:e,tableId:i,rowId:e,store:n,debugIds:u})))),l,u,s)},Me=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:l})=>{var u;return Te(t+(null!=(u=ue(e,s,o,r))?u:t),void 0,l,o)},De=({queryId:e,rowId:s,queries:t,resultCellComponent:o=Me,getResultCellComponentProps:r,separator:l,debugIds:u})=>Te(C(le(e,s,t),(l=>ge(o,ke(Re({},V(r,l)),{key:l,queryId:e,rowId:s,cellId:l,queries:t,debugIds:u})))),l,u,s),je=({checkpoints:e,checkpointId:s,debugIds:o})=>{var r;return Te(null!=(r=ne(s,e))?r:t,void 0,o,s)},Ae=Se((e=>e[0])),Ee=Se((e=>b(e[1])?[]:[e[1]])),Fe=Se((e=>e[2]));exports.BackwardCheckpointsView=Ae,exports.CellView=fe,exports.CheckpointView=je,exports.CurrentCheckpointView=Ee,exports.ForwardCheckpointsView=Fe,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=Be,getSliceComponentProps:o,separator:r,debugIds:l})=>Te(C($(e,s),(r=>ge(t,ke(Re({},V(o,r)),{key:r,indexId:e,sliceId:r,indexes:s,debugIds:l})))),r,l,e),exports.LinkedRowsView=e=>Ve(e,te,e.firstRowId),exports.LocalRowsView=e=>Ve(e,se,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>{var r;return Te(null!=(r=Z(e,s))?r:t,void 0,o,e)},exports.Provider=({store:s,storesById:t,metrics:o,metricsById:r,indexes:l,indexesById:u,relationships:d,relationshipsById:n,queries:i,queriesById:a,checkpoints:p,checkpointsById:c,children:I})=>{const x=e.useContext(h);return ge(h.Provider,{value:me((()=>[null!=s?s:x[0],Re(Re({},x[1]),t),null!=o?o:x[2],Re(Re({},x[3]),r),null!=l?l:x[4],Re(Re({},x[5]),u),null!=d?d:x[6],Re(Re({},x[7]),n),null!=i?i:x[8],Re(Re({},x[9]),a),null!=p?p:x[10],Re(Re({},x[11]),c)]),[s,t,o,r,l,u,d,n,i,a,p,c,x])},I)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=Pe,getRowComponentProps:r,debugIds:l})=>{const[u,d]=Le(t),n=null==u?void 0:u.getRemoteTableId(e),i=ee(e,s,u);return Te(b(n)||b(i)?null:ge(o,ke(Re({},V(r,i)),{key:i,tableId:n,rowId:i,store:d,debugIds:l})),void 0,l,s)},exports.ResultCellView=Me,exports.ResultRowView=De,exports.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ve(s,["cellId","descending","offset","limit"]);return ye(u,re(u.queryId,t,o,r,l,u.queries))},exports.ResultTableView=e=>ye(e,oe(e.queryId,e.queries)),exports.RowView=Pe,exports.SliceView=Be,exports.SortedTableView=e=>{var s=e,{cellId:t,descending:o,offset:r,limit:l}=s,u=ve(s,["cellId","descending","offset","limit"]);return he(u,K(u.tableId,t,o,r,l,u.store))},exports.TableView=qe,exports.TablesView=({store:e,tableComponent:s=qe,getTableComponentProps:t,separator:o,debugIds:r})=>Te(C(H(e),(o=>ge(s,ke(Re({},V(t,o)),{key:o,tableId:o,store:e,debugIds:r})))),o),exports.ValueView=Oe,exports.ValuesView=({store:e,valueComponent:s=Oe,getValueComponentProps:t,separator:o,debugIds:r})=>Te(C(X(e),(o=>ge(s,ke(Re({},V(t,o)),{key:o,valueId:o,store:e,debugIds:r})))),o),exports.useAddRowCallback=(e,s,t=[],o,r=v,l=[],u=!0)=>{const d=S(o);return B((t=>R(d,(o=>R(s(t,o),(s=>r(o.addRow(e,s,u),o,s)))))),[d,e,...t,...l,u])},exports.useCell=W,exports.useCellIds=N,exports.useCellIdsListener=(e,s,t,o,r,l)=>G(c,S(l),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,l,u)=>G(p,S(u),o,r,[e,s,t],l),exports.useCheckpoint=ne,exports.useCheckpointIds=de,exports.useCheckpointIdsListener=(e,s,t)=>G("CheckpointIds",O(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>G("Checkpoint",O(o),s,t,[e]),exports.useCheckpoints=e=>y(e,10),exports.useCreateCheckpoints=(e,s,t)=>E(e,s,t),exports.useCreateIndexes=(e,s,t)=>E(e,s,t),exports.useCreateMetrics=(e,s,t)=>E(e,s,t),exports.useCreatePersister=(e,s,t=[],o,r=[])=>{const[,l]=A(),u=D((()=>s(e)),[e,...t]);return M((()=>{var e;return e=function*(){yield null==o?void 0:o(u),l(1)},new Promise(((s,t)=>{var o=s=>{try{l(e.next(s))}catch(e){t(e)}},r=s=>{try{l(e.throw(s))}catch(e){t(e)}},l=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,r);l((e=e.apply(void 0,null)).next())})),()=>{u.destroy()}}),[u,...r]),u},exports.useCreateQueries=(e,s,t)=>E(e,s,t),exports.useCreateRelationships=(e,s,t)=>E(e,s,t),exports.useCreateStore=(e,s=[])=>D(e,s),exports.useDelCellCallback=(e,s,t,o,r,l,u)=>U(r,p,l,u,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>U(t,n,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>U(s,l,t,o,e),exports.useDelTablesCallback=(e,s,t)=>U(e,u,s,t),exports.useDelValueCallback=(e,s,t,o)=>U(s,I,t,o,e),exports.useDelValuesCallback=(e,s,t)=>U(e,x,s,t),exports.useGoBackwardCallback=ie,exports.useGoForwardCallback=ae,exports.useGoToCallback=(e,s=[],t,o=v,r=[])=>{const l=O(t);return B((s=>R(l,(t=>R(e(s),(e=>o(t.goTo(e),e)))))),[l,...s,...r])},exports.useIndexes=e=>y(e,4),exports.useLinkedRowIds=te,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>G("LinkedRowIds",P(r),t,o,[e,s]),exports.useLocalRowIds=se,exports.useLocalRowIdsListener=(e,s,t,o,r)=>G("LocalRowIds",P(r),t,o,[e,s]),exports.useMetric=Z,exports.useMetricListener=(e,s,t,o)=>G("Metric",T(o),s,t,[e]),exports.useMetrics=e=>y(e,2),exports.useQueries=e=>y(e,8),exports.useRedoInformation=e=>{var s;const o=O(e),[,,[r]]=de(o);return[!b(r),ae(o),r,null!=(s=R(r,(e=>null==o?void 0:o.getCheckpoint(e))))?s:t]},exports.useRelationships=e=>y(e,6),exports.useRemoteRowId=ee,exports.useRemoteRowIdListener=(e,s,t,o,r)=>G("RemoteRowId",P(r),t,o,[e,s]),exports.useResultCell=ue,exports.useResultCellIds=le,exports.useResultCellIdsListener=(e,s,t,o,r)=>G("ResultCellIds",q(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,l)=>G("ResultCell",q(l),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>F("ResultRow",q(t),{},[e,s]),exports.useResultRowIds=oe,exports.useResultRowIdsListener=(e,s,t,o)=>G("ResultRowIds",q(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>G("ResultRow",q(r),t,o,[e,s]),exports.useResultSortedRowIds=re,exports.useResultSortedRowIdsListener=(e,s,t,o,r,l,u,d)=>G("ResultSortedRowIds",q(d),l,u,[e,s,t,o,r]),exports.useResultTable=(e,s)=>F("ResultTable",q(s),{},[e]),exports.useResultTableCellIds=(e,s)=>F("ResultTableCellIds",q(s),[],[e]),exports.useResultTableCellIdsListener=(e,s,t,o)=>G("ResultTableCellIds",q(o),s,t,[e]),exports.useResultTableListener=(e,s,t,o)=>G("ResultTable",q(o),s,t,[e]),exports.useRow=(e,s,t)=>F(n,S(t),{},[e,s]),exports.useRowIds=J,exports.useRowIdsListener=(e,s,t,o,r)=>G(i,S(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,l)=>G(n,S(l),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,l,u,d)=>Q(l,p,o,r,u,d,e,s,t),exports.useSetCheckpointCallback=(e=v,s=[],t,o=v,r=[])=>{const l=O(t);return B((s=>R(l,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[l,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,l,u)=>Q(r,"PartialRow",t,o,l,u,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>Q(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,l,u)=>Q(r,n,t,o,l,u,e,s),exports.useSetTableCallback=(e,s,t,o,r,u)=>Q(o,l,s,t,r,u,e),exports.useSetTablesCallback=(e,s,t,o,r)=>Q(t,u,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,l)=>Q(o,I,s,t,r,l,e),exports.useSetValuesCallback=(e,s,t,o,r)=>Q(t,x,e,s,o,r),exports.useSliceIds=$,exports.useSliceIdsListener=(e,s,t,o)=>G("SliceIds",f(o),s,t,[e]),exports.useSliceRowIds=_,exports.useSliceRowIdsListener=(e,s,t,o,r)=>G("SliceRowIds",f(r),t,o,[e,s]),exports.useSortedRowIds=K,exports.useSortedRowIdsListener=(e,s,t,o,r,l,u,d,n)=>G(a,S(n),l,u,[e,s,t,o,r],d),exports.useStore=e=>y(e,0),exports.useTable=(e,s)=>F(l,S(s),{},[e]),exports.useTableCellIds=(e,s)=>F(l+c,S(s),[],[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>G(l+c,S(r),s,t,[e],o),exports.useTableIds=H,exports.useTableIdsListener=(e,s,t,o)=>G(d,S(o),e,s,[],t),exports.useTableListener=(e,s,t,o,r)=>G(l,S(r),s,t,[e],o),exports.useTables=e=>F(u,S(e),{}),exports.useTablesListener=(e,s,t,o)=>G(u,S(o),e,s,[],t),exports.useUndoInformation=e=>{var s;const o=O(e),[r,l]=de(o);return[(u=r,!(0==(e=>e.length)(u))),ie(o),l,null!=(s=R(l,(e=>null==o?void 0:o.getCheckpoint(e))))?s:t];var u},exports.useValue=Y,exports.useValueIds=X,exports.useValueIdsListener=(e,s,t,o)=>G(w,S(o),e,s,[],t),exports.useValueListener=(e,s,t,o,r)=>G(I,S(r),s,t,[e],o),exports.useValues=e=>F(x,S(e),{}),exports.useValuesListener=(e,s,t,o)=>G(x,S(o),e,s,[],t);
|
|
Binary file
|
package/lib/debug/queries.js
CHANGED
package/lib/debug/tinybase.js
CHANGED
package/lib/debug/tools.js
CHANGED
|
@@ -1827,6 +1827,7 @@ const getStoreUiReactApi = (
|
|
|
1827
1827
|
PARAMETER + 'ized' + CALLBACK,
|
|
1828
1828
|
);
|
|
1829
1829
|
addImport(0, tinyBaseUiReact, 'ComponentReturnType');
|
|
1830
|
+
addImport(1, tinyBaseUiReact, 'useCellIds');
|
|
1830
1831
|
addImport(null, tinyBaseUiReact, 'ExtraProps');
|
|
1831
1832
|
addImport(0, moduleDefinition, storeType);
|
|
1832
1833
|
const storeOrStoreIdType = addType(
|
|
@@ -1903,6 +1904,19 @@ const getStoreUiReactApi = (
|
|
|
1903
1904
|
`return encloseWithId ? [id, ':{', separated, '}'] : separated;`,
|
|
1904
1905
|
],
|
|
1905
1906
|
);
|
|
1907
|
+
const useCustomOrDefaultCellIds = addInternalFunction(
|
|
1908
|
+
'useCustomOrDefaultCellIds',
|
|
1909
|
+
getParameterList(
|
|
1910
|
+
'customCellIds: Ids | undefined',
|
|
1911
|
+
'tableId: Id',
|
|
1912
|
+
'rowId: Id',
|
|
1913
|
+
`${storeOrStoreId}?: ${storeOrStoreIdType} | undefined`,
|
|
1914
|
+
),
|
|
1915
|
+
[
|
|
1916
|
+
`const defaultCellIds = ${useHook}(${storeOrStoreId}, useCellIds, [tableId, rowId]);`,
|
|
1917
|
+
'return customCellIds ?? defaultCellIds;',
|
|
1918
|
+
],
|
|
1919
|
+
);
|
|
1906
1920
|
const NullComponent = addConstant('NullComponent', `() => null`);
|
|
1907
1921
|
if (!objIsEmpty(tablesSchema)) {
|
|
1908
1922
|
const [
|
|
@@ -1942,7 +1956,7 @@ const getStoreUiReactApi = (
|
|
|
1942
1956
|
addImport(null, TINYBASE, IDS, 'IdOrNull');
|
|
1943
1957
|
const tableView = addInternalFunction(
|
|
1944
1958
|
'tableView',
|
|
1945
|
-
`{${storeInstance}, rowComponent, getRowComponentProps` +
|
|
1959
|
+
`{${storeInstance}, rowComponent, getRowComponentProps, customCellIds` +
|
|
1946
1960
|
SEPARATOR_AND_DEBUG_IDS +
|
|
1947
1961
|
'}: any, rowIds: Ids, tableId: Id, defaultRowComponent: React.ComponentType<any>',
|
|
1948
1962
|
[
|
|
@@ -1953,6 +1967,7 @@ const getStoreUiReactApi = (
|
|
|
1953
1967
|
'key={rowId}',
|
|
1954
1968
|
'tableId={tableId}',
|
|
1955
1969
|
ROW_ID_PROP,
|
|
1970
|
+
'customCellIds={customCellIds}',
|
|
1956
1971
|
storeProp,
|
|
1957
1972
|
DEBUG_IDS_PROP,
|
|
1958
1973
|
'/>',
|
|
@@ -2056,6 +2071,7 @@ const getStoreUiReactApi = (
|
|
|
2056
2071
|
cellIdType +
|
|
2057
2072
|
`<TId>]?: ComponentType<${cellPropsType}<TId, CId>>;}`,
|
|
2058
2073
|
`getCellComponentProps?: (cellId: ${cellIdType}<TId>) => ExtraProps`,
|
|
2074
|
+
`customCellIds?: ${cellIdType}<TId>[]`,
|
|
2059
2075
|
SEPARATOR_PROP_TYPE,
|
|
2060
2076
|
DEBUG_IDS_PROP_TYPE,
|
|
2061
2077
|
),
|
|
@@ -2069,6 +2085,7 @@ const getStoreUiReactApi = (
|
|
|
2069
2085
|
storeInstance + OPTIONAL_COLON + storeType,
|
|
2070
2086
|
`rowComponent?: ComponentType<${rowPropsType}<TId>>`,
|
|
2071
2087
|
`getRowComponentProps?: (rowId: Id) => ExtraProps`,
|
|
2088
|
+
`customCellIds?: CellId<TId>[]`,
|
|
2072
2089
|
SEPARATOR_PROP_TYPE,
|
|
2073
2090
|
DEBUG_IDS_PROP_TYPE,
|
|
2074
2091
|
),
|
|
@@ -2086,6 +2103,7 @@ const getStoreUiReactApi = (
|
|
|
2086
2103
|
storeInstance + OPTIONAL_COLON + storeType,
|
|
2087
2104
|
`rowComponent?: ComponentType<${rowPropsType}<TId>>`,
|
|
2088
2105
|
`getRowComponentProps?: (rowId: Id) => ExtraProps`,
|
|
2106
|
+
`customCellIds?: CellId<TId>[]`,
|
|
2089
2107
|
SEPARATOR_PROP_TYPE,
|
|
2090
2108
|
DEBUG_IDS_PROP_TYPE,
|
|
2091
2109
|
),
|
|
@@ -2197,7 +2215,7 @@ const getStoreUiReactApi = (
|
|
|
2197
2215
|
TYPED_ROW_ID,
|
|
2198
2216
|
getParameterList(TABLE_ID, ROW_ID),
|
|
2199
2217
|
);
|
|
2200
|
-
|
|
2218
|
+
addProxyHook(
|
|
2201
2219
|
tableName + CELL_IDS,
|
|
2202
2220
|
CELL_IDS,
|
|
2203
2221
|
cellIdType2 + SQUARE_BRACKETS,
|
|
@@ -2308,11 +2326,14 @@ const getStoreUiReactApi = (
|
|
|
2308
2326
|
tableName + ROW + VIEW,
|
|
2309
2327
|
'{rowId, ' +
|
|
2310
2328
|
storeInstance +
|
|
2311
|
-
', cellComponents, getCellComponentProps' +
|
|
2329
|
+
', cellComponents, getCellComponentProps, customCellIds' +
|
|
2312
2330
|
SEPARATOR_AND_DEBUG_IDS +
|
|
2313
2331
|
`}: ${rowPropsType}<'${tableId}'>`,
|
|
2314
2332
|
[
|
|
2315
|
-
wrap +
|
|
2333
|
+
wrap +
|
|
2334
|
+
`(${useCustomOrDefaultCellIds}(customCellIds, ` +
|
|
2335
|
+
TABLE_ID +
|
|
2336
|
+
`, rowId, ${storeInstance}).map((cellId: ${cellIdType2}) => {`,
|
|
2316
2337
|
'const Cell = (cellComponents?.[cellId] ?? ' +
|
|
2317
2338
|
getDefaultCellComponent +
|
|
2318
2339
|
`(${TABLE_ID}, cellId)) as React.ComponentType<CellProps<typeof ` +
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useRowIds,
|
|
3
|
+
useTableCellIds,
|
|
4
|
+
useSortedRowIds,
|
|
5
|
+
useValueIds,
|
|
6
|
+
ValueView,
|
|
7
|
+
ResultCellView,
|
|
8
|
+
useResultRowIds,
|
|
9
|
+
useResultTableCellIds,
|
|
10
|
+
useResultSortedRowIds,
|
|
11
|
+
CellView,
|
|
12
|
+
} from './ui-react';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
|
|
15
|
+
const getTypeOf = (thing) => typeof thing;
|
|
16
|
+
const EMPTY_STRING = '';
|
|
17
|
+
const STRING = getTypeOf(EMPTY_STRING);
|
|
18
|
+
const VALUE = 'Value';
|
|
19
|
+
|
|
20
|
+
const arrayMap = (array, cb) => array.map(cb);
|
|
21
|
+
|
|
22
|
+
const isUndefined = (thing) => thing == void 0;
|
|
23
|
+
const isString = (thing) => getTypeOf(thing) == STRING;
|
|
24
|
+
const isArray = (thing) => Array.isArray(thing);
|
|
25
|
+
|
|
26
|
+
const object = Object;
|
|
27
|
+
const objNew = (entries = []) => object.fromEntries(entries);
|
|
28
|
+
const objMap = (obj, cb) =>
|
|
29
|
+
arrayMap(object.entries(obj), ([id, value]) => cb(value, id));
|
|
30
|
+
|
|
31
|
+
const {createContext, useContext} = React;
|
|
32
|
+
createContext([]);
|
|
33
|
+
const getProps = (getProps2, ...ids) =>
|
|
34
|
+
isUndefined(getProps2) ? {} : getProps2(...ids);
|
|
35
|
+
|
|
36
|
+
const {createElement, useCallback, useMemo, useState} = React;
|
|
37
|
+
const useCallbackOrUndefined = (callback, deps, test) => {
|
|
38
|
+
const returnCallback = useCallback(callback, deps);
|
|
39
|
+
return test ? returnCallback : void 0;
|
|
40
|
+
};
|
|
41
|
+
const sortedClassName = (sorting, cellId) =>
|
|
42
|
+
isUndefined(sorting)
|
|
43
|
+
? void 0
|
|
44
|
+
: sorting[0] != cellId
|
|
45
|
+
? void 0
|
|
46
|
+
: `sorted ${sorting[1] ? 'de' : 'a'}scending`;
|
|
47
|
+
const HtmlHeaderTh = ({
|
|
48
|
+
cellId,
|
|
49
|
+
sorting,
|
|
50
|
+
label = cellId ?? EMPTY_STRING,
|
|
51
|
+
onClick,
|
|
52
|
+
}) =>
|
|
53
|
+
/* @__PURE__ */ createElement(
|
|
54
|
+
'th',
|
|
55
|
+
{
|
|
56
|
+
onClick: useCallbackOrUndefined(
|
|
57
|
+
() => onClick?.(cellId),
|
|
58
|
+
[onClick, cellId],
|
|
59
|
+
!isUndefined(onClick),
|
|
60
|
+
),
|
|
61
|
+
className: sortedClassName(sorting, cellId),
|
|
62
|
+
},
|
|
63
|
+
label,
|
|
64
|
+
);
|
|
65
|
+
const HtmlTable = ({
|
|
66
|
+
className,
|
|
67
|
+
headerRow,
|
|
68
|
+
idColumn,
|
|
69
|
+
customCells,
|
|
70
|
+
storeTableIdOrQueriesQueryId,
|
|
71
|
+
defaultCellView = CellView,
|
|
72
|
+
rowIds,
|
|
73
|
+
defaultCellIds,
|
|
74
|
+
sorting,
|
|
75
|
+
onHeaderThClick,
|
|
76
|
+
}) => {
|
|
77
|
+
const customCellConfigurations = useMemo(() => {
|
|
78
|
+
const cellIds = customCells ?? defaultCellIds;
|
|
79
|
+
return objNew(
|
|
80
|
+
objMap(
|
|
81
|
+
isArray(cellIds)
|
|
82
|
+
? objNew(arrayMap(cellIds, (cellId) => [cellId, cellId]))
|
|
83
|
+
: cellIds,
|
|
84
|
+
(labelOrCustomCell, cellId) => [
|
|
85
|
+
cellId,
|
|
86
|
+
{
|
|
87
|
+
...{label: cellId},
|
|
88
|
+
...(isString(labelOrCustomCell)
|
|
89
|
+
? {label: labelOrCustomCell}
|
|
90
|
+
: labelOrCustomCell),
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
),
|
|
94
|
+
);
|
|
95
|
+
}, [customCells, defaultCellIds]);
|
|
96
|
+
return /* @__PURE__ */ createElement(
|
|
97
|
+
'table',
|
|
98
|
+
{className},
|
|
99
|
+
headerRow === false
|
|
100
|
+
? null
|
|
101
|
+
: /* @__PURE__ */ createElement(
|
|
102
|
+
'thead',
|
|
103
|
+
null,
|
|
104
|
+
/* @__PURE__ */ createElement(
|
|
105
|
+
'tr',
|
|
106
|
+
null,
|
|
107
|
+
idColumn === false
|
|
108
|
+
? null
|
|
109
|
+
: /* @__PURE__ */ createElement(HtmlHeaderTh, {
|
|
110
|
+
sorting,
|
|
111
|
+
label: 'Id',
|
|
112
|
+
onClick: onHeaderThClick,
|
|
113
|
+
}),
|
|
114
|
+
objMap(customCellConfigurations, ({label}, cellId) =>
|
|
115
|
+
/* @__PURE__ */ createElement(HtmlHeaderTh, {
|
|
116
|
+
key: cellId,
|
|
117
|
+
cellId,
|
|
118
|
+
label,
|
|
119
|
+
sorting,
|
|
120
|
+
onClick: onHeaderThClick,
|
|
121
|
+
}),
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ createElement(
|
|
126
|
+
'tbody',
|
|
127
|
+
null,
|
|
128
|
+
arrayMap(rowIds, (rowId) =>
|
|
129
|
+
/* @__PURE__ */ createElement(
|
|
130
|
+
'tr',
|
|
131
|
+
{key: rowId},
|
|
132
|
+
idColumn === false
|
|
133
|
+
? null
|
|
134
|
+
: /* @__PURE__ */ createElement('th', null, rowId),
|
|
135
|
+
objMap(
|
|
136
|
+
customCellConfigurations,
|
|
137
|
+
(
|
|
138
|
+
{component: CellView2 = defaultCellView, getComponentProps},
|
|
139
|
+
cellId,
|
|
140
|
+
) =>
|
|
141
|
+
/* @__PURE__ */ createElement(
|
|
142
|
+
'td',
|
|
143
|
+
{key: cellId},
|
|
144
|
+
/* @__PURE__ */ createElement(CellView2, {
|
|
145
|
+
...getProps(getComponentProps, rowId, cellId),
|
|
146
|
+
...storeTableIdOrQueriesQueryId,
|
|
147
|
+
rowId,
|
|
148
|
+
cellId,
|
|
149
|
+
}),
|
|
150
|
+
),
|
|
151
|
+
),
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
),
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
const TableInHtmlTable = ({tableId, store, ...props}) =>
|
|
158
|
+
/* @__PURE__ */ createElement(HtmlTable, {
|
|
159
|
+
...props,
|
|
160
|
+
storeTableIdOrQueriesQueryId: useMemo(
|
|
161
|
+
() => ({store, tableId}),
|
|
162
|
+
[store, tableId],
|
|
163
|
+
),
|
|
164
|
+
rowIds: useRowIds(tableId, store),
|
|
165
|
+
defaultCellIds: useTableCellIds(tableId, store),
|
|
166
|
+
});
|
|
167
|
+
const SortedTableInHtmlTable = ({
|
|
168
|
+
tableId,
|
|
169
|
+
cellId,
|
|
170
|
+
descending,
|
|
171
|
+
offset,
|
|
172
|
+
limit,
|
|
173
|
+
store,
|
|
174
|
+
sortOnClick,
|
|
175
|
+
...props
|
|
176
|
+
}) => {
|
|
177
|
+
const [sorting, setSorting] = useState([cellId, descending ? true : false]);
|
|
178
|
+
const handleHeaderThClick = useCallbackOrUndefined(
|
|
179
|
+
(cellId2) =>
|
|
180
|
+
setSorting([cellId2, cellId2 == sorting[0] ? !sorting[1] : false]),
|
|
181
|
+
[sorting],
|
|
182
|
+
sortOnClick,
|
|
183
|
+
);
|
|
184
|
+
return /* @__PURE__ */ createElement(HtmlTable, {
|
|
185
|
+
...props,
|
|
186
|
+
storeTableIdOrQueriesQueryId: useMemo(
|
|
187
|
+
() => ({store, tableId}),
|
|
188
|
+
[store, tableId],
|
|
189
|
+
),
|
|
190
|
+
rowIds: useSortedRowIds(tableId, ...sorting, offset, limit, store),
|
|
191
|
+
defaultCellIds: useTableCellIds(tableId, store),
|
|
192
|
+
sorting,
|
|
193
|
+
onHeaderThClick: handleHeaderThClick,
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
const ValuesInHtmlTable = ({
|
|
197
|
+
store,
|
|
198
|
+
valueComponent: Value = ValueView,
|
|
199
|
+
getValueComponentProps,
|
|
200
|
+
className,
|
|
201
|
+
headerRow,
|
|
202
|
+
idColumn,
|
|
203
|
+
}) =>
|
|
204
|
+
/* @__PURE__ */ createElement(
|
|
205
|
+
'table',
|
|
206
|
+
{className},
|
|
207
|
+
headerRow === false
|
|
208
|
+
? null
|
|
209
|
+
: /* @__PURE__ */ createElement(
|
|
210
|
+
'thead',
|
|
211
|
+
null,
|
|
212
|
+
/* @__PURE__ */ createElement(
|
|
213
|
+
'tr',
|
|
214
|
+
null,
|
|
215
|
+
idColumn === false
|
|
216
|
+
? null
|
|
217
|
+
: /* @__PURE__ */ createElement('th', null, 'Id'),
|
|
218
|
+
/* @__PURE__ */ createElement('th', null, VALUE),
|
|
219
|
+
),
|
|
220
|
+
),
|
|
221
|
+
/* @__PURE__ */ createElement(
|
|
222
|
+
'tbody',
|
|
223
|
+
null,
|
|
224
|
+
arrayMap(useValueIds(store), (valueId) =>
|
|
225
|
+
/* @__PURE__ */ createElement(
|
|
226
|
+
'tr',
|
|
227
|
+
{key: valueId},
|
|
228
|
+
idColumn === false
|
|
229
|
+
? null
|
|
230
|
+
: /* @__PURE__ */ createElement('th', null, valueId),
|
|
231
|
+
/* @__PURE__ */ createElement(
|
|
232
|
+
'td',
|
|
233
|
+
null,
|
|
234
|
+
/* @__PURE__ */ createElement(Value, {
|
|
235
|
+
...getProps(getValueComponentProps, valueId),
|
|
236
|
+
valueId,
|
|
237
|
+
store,
|
|
238
|
+
}),
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
),
|
|
242
|
+
),
|
|
243
|
+
);
|
|
244
|
+
const ResultTableInHtmlTable = ({queryId, queries, ...props}) =>
|
|
245
|
+
/* @__PURE__ */ createElement(HtmlTable, {
|
|
246
|
+
...props,
|
|
247
|
+
storeTableIdOrQueriesQueryId: useMemo(
|
|
248
|
+
() => ({queries, queryId}),
|
|
249
|
+
[queries, queryId],
|
|
250
|
+
),
|
|
251
|
+
defaultCellView: ResultCellView,
|
|
252
|
+
rowIds: useResultRowIds(queryId, queries),
|
|
253
|
+
defaultCellIds: useResultTableCellIds(queryId, queries),
|
|
254
|
+
});
|
|
255
|
+
const ResultSortedTableInHtmlTable = ({
|
|
256
|
+
queryId,
|
|
257
|
+
cellId,
|
|
258
|
+
descending,
|
|
259
|
+
offset,
|
|
260
|
+
limit,
|
|
261
|
+
queries,
|
|
262
|
+
sortOnClick,
|
|
263
|
+
...props
|
|
264
|
+
}) => {
|
|
265
|
+
const [sorting, setSorting] = useState([cellId, descending ? true : false]);
|
|
266
|
+
const handleHeaderThClick = useCallbackOrUndefined(
|
|
267
|
+
(cellId2) =>
|
|
268
|
+
setSorting([cellId2, cellId2 == sorting[0] ? !sorting[1] : false]),
|
|
269
|
+
[sorting],
|
|
270
|
+
sortOnClick,
|
|
271
|
+
);
|
|
272
|
+
return /* @__PURE__ */ createElement(HtmlTable, {
|
|
273
|
+
...props,
|
|
274
|
+
storeTableIdOrQueriesQueryId: useMemo(
|
|
275
|
+
() => ({queries, queryId}),
|
|
276
|
+
[queries, queryId],
|
|
277
|
+
),
|
|
278
|
+
defaultCellView: ResultCellView,
|
|
279
|
+
rowIds: useResultSortedRowIds(queryId, ...sorting, offset, limit, queries),
|
|
280
|
+
defaultCellIds: useResultTableCellIds(queryId, queries),
|
|
281
|
+
sorting,
|
|
282
|
+
onHeaderThClick: handleHeaderThClick,
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export {
|
|
287
|
+
ResultSortedTableInHtmlTable,
|
|
288
|
+
ResultTableInHtmlTable,
|
|
289
|
+
SortedTableInHtmlTable,
|
|
290
|
+
TableInHtmlTable,
|
|
291
|
+
ValuesInHtmlTable,
|
|
292
|
+
};
|