tinybase 4.3.17 → 4.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/lib/cjs/ui-react-dom-debug.cjs +1 -1
  2. package/lib/cjs/ui-react-dom-debug.cjs.gz +0 -0
  3. package/lib/cjs/ui-react-dom.cjs +1 -1
  4. package/lib/cjs/ui-react-dom.cjs.gz +0 -0
  5. package/lib/cjs/ui-react.cjs +1 -1
  6. package/lib/cjs/ui-react.cjs.gz +0 -0
  7. package/lib/cjs-es6/ui-react-dom-debug.cjs +1 -1
  8. package/lib/cjs-es6/ui-react-dom-debug.cjs.gz +0 -0
  9. package/lib/cjs-es6/ui-react-dom.cjs +1 -1
  10. package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
  11. package/lib/cjs-es6/ui-react.cjs +1 -1
  12. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  13. package/lib/debug/ui-react-dom.js +80 -84
  14. package/lib/debug/ui-react.js +9 -5
  15. package/lib/es6/ui-react-dom-debug.js +1 -1
  16. package/lib/es6/ui-react-dom-debug.js.gz +0 -0
  17. package/lib/es6/ui-react-dom.js +1 -1
  18. package/lib/es6/ui-react-dom.js.gz +0 -0
  19. package/lib/es6/ui-react.js +1 -1
  20. package/lib/es6/ui-react.js.gz +0 -0
  21. package/lib/types/ui-react.d.ts +24 -2
  22. package/lib/types/with-schemas/ui-react.d.ts +26 -2
  23. package/lib/ui-react-dom.js +1 -1
  24. package/lib/ui-react-dom.js.gz +0 -0
  25. package/lib/ui-react.js +1 -1
  26. package/lib/ui-react.js.gz +0 -0
  27. package/lib/umd/ui-react-dom-debug.js +1 -1
  28. package/lib/umd/ui-react-dom-debug.js.gz +0 -0
  29. package/lib/umd/ui-react-dom.js +1 -1
  30. package/lib/umd/ui-react-dom.js.gz +0 -0
  31. package/lib/umd/ui-react.js +1 -1
  32. package/lib/umd/ui-react.js.gz +0 -0
  33. package/lib/umd-es6/ui-react-dom-debug.js +1 -1
  34. package/lib/umd-es6/ui-react-dom-debug.js.gz +0 -0
  35. package/lib/umd-es6/ui-react-dom.js +1 -1
  36. package/lib/umd-es6/ui-react-dom.js.gz +0 -0
  37. package/lib/umd-es6/ui-react.js +1 -1
  38. package/lib/umd-es6/ui-react.js.gz +0 -0
  39. package/package.json +4 -4
  40. package/readme.md +2 -2
@@ -1 +1 @@
1
- import e,{useContext as t}from"react";const o=e=>typeof e,r="",n=o(r),d="Listener",l="Result",s="Ids",u="Table",i=u+"s",a=u+s,c="Row",I=c+"Count",p=c+s,v="Sorted"+c+s,b="Cell",g=b+s,m="Value",C=m+"s",y=m+s,w=e=>null==e,k=(e,t,o)=>w(e)?null==o?void 0:o():t(e),h=e=>o(e)==n,f=()=>{},R=(e,t)=>e.map(t),P=Object.keys,{createContext:x,useContext:q}=e,O=x([]),S=(e,t)=>{var o;const r=q(O);return w(e)?r[t]:h(e)?((e,t)=>k(e,(e=>e[t])))(null!=(o=r[t+1])?o:{},e):e},L=(e,t)=>{const o=S(e,t);return w(e)||h(e)?o:e},j=e=>{var t;return P(null!=(t=q(O)[e])?t:{})},B=e=>S(e,0),T=e=>L(e,0),M=e=>S(e,2),E=e=>L(e,2),F=e=>S(e,4),V=e=>L(e,4),A=e=>S(e,6),D=e=>L(e,6),Q=e=>S(e,8),W=e=>L(e,8),z=e=>S(e,10),G=e=>L(e,10),H=e=>e.toLowerCase();H(d);const J="Transaction";H(J);const{useCallback:K,useEffect:N,useMemo:U,useRef:X,useState:Y}=e,Z=(e,t,o=[])=>{const r=U((()=>t(e)),[e,...o]);return N((()=>()=>r.destroy()),[r]),r},$=(e,t,o,r=[],n)=>{const[,d]=Y(),l=K((()=>{var n,d;return null!=(d=null==(n=null==t?void 0:t["get"+e])?void 0:n.call(t,...r))?d:o}),[t,...r]),[s]=Y(l),u=X(s);return U((()=>u.current=l()),[l]),_(e,t,((...e)=>{u.current=w(n)?l():e[n],d([])}),[],r),u.current},_=(e,t,o,r=[],n=[],...l)=>N((()=>{var r;const s=null==(r=null==t?void 0:t["add"+e+d])?void 0:r.call(t,...n,o,...l);return()=>null==t?void 0:t.delListener(s)}),[t,...n,...r,...l]),ee=(e,t,o,r=[],n=f,d=[],...l)=>{const s=T(e);return K((e=>k(s,(r=>k(o(e,r),(e=>n(r["set"+t](...l,e),e)))))),[s,t,...r,...d,...l])},te=(e,t,o=f,r=[],...n)=>{const d=T(e);return K((()=>o(null==d?void 0:d["del"+t](...n))),[d,t,...r,...n])},oe=(e,t,o)=>{const r=G(e);return K((()=>null==r?void 0:r[t](o)),[r,t,o])},re=(e,t=[])=>U(e,t),ne=()=>j(1),de=e=>$(i,T(e),{}),le=e=>$(a,T(e),[],[]),se=(e,t)=>$(u,T(t),{},[e]),ue=(e,t)=>$(u+g,T(t),[],[e]),ie=(e,t)=>$(I,T(t),[],[e]),ae=(e,t)=>$(p,T(t),[],[e]),ce=(e,t,o,r=0,n,d)=>$(v,T(d),[],[e,t,o,r,n],6),Ie=(e,t,o)=>$(c,T(o),{},[e,t]),pe=(e,t,o)=>$(g,T(o),[],[e,t]),ve=(e,t,o,r)=>$(b,T(r),void 0,[e,t,o],4),be=e=>$(C,T(e),{}),ge=e=>$(y,T(e),[],[]),me=(e,t)=>$(m,T(t),void 0,[e]),Ce=(e,t,o,r,n)=>ee(o,i,e,t,r,n),ye=(e,t,o,r,n,d)=>ee(r,u,t,o,n,d,e),we=(e,t,o,r,n,d,l)=>ee(n,c,o,r,d,l,e,t),ke=(e,t,o=[],r,n=f,d=[],l=!0)=>{const s=T(r);return K((o=>k(s,(r=>k(t(o,r),(t=>n(r.addRow(e,t,l),r,t)))))),[s,e,...o,...d,l])},he=(e,t,o,r,n,d,l)=>ee(n,"PartialRow",o,r,d,l,e,t),fe=(e,t,o,r,n,d,l,s)=>ee(d,b,r,n,l,s,e,t,o),Re=(e,t,o,r,n)=>ee(o,C,e,t,r,n),Pe=(e,t,o,r,n)=>ee(o,"PartialValues",e,t,r,n),xe=(e,t,o,r,n,d)=>ee(r,m,t,o,n,d,e),qe=(e,t,o)=>te(e,i,t,o),Oe=(e,t,o,r)=>te(t,u,o,r,e),Se=(e,t,o,r,n)=>te(o,c,r,n,e,t),Le=(e,t,o,r,n,d,l)=>te(n,b,d,l,e,t,o,r),je=(e,t,o)=>te(e,C,t,o),Be=(e,t,o,r)=>te(t,m,o,r,e),Te=(e,t,o,r)=>_(i,T(r),e,t,[],o),Me=(e,t,o,r)=>_(a,T(r),e,t,[],o),Ee=(e,t,o,r,n)=>_(u,T(n),t,o,[e],r),Fe=(e,t,o,r,n)=>_(u+g,T(n),t,o,[e],r),Ve=(e,t,o,r,n)=>_(I,T(n),t,o,[e],r),Ae=(e,t,o,r,n)=>_(p,T(n),t,o,[e],r),De=(e,t,o,r,n,d,l,s,u)=>_(v,T(u),d,l,[e,t,o,r,n],s),Qe=(e,t,o,r,n,d)=>_(c,T(d),o,r,[e,t],n),We=(e,t,o,r,n,d)=>_(g,T(d),o,r,[e,t],n),ze=(e,t,o,r,n,d,l)=>_(b,T(l),r,n,[e,t,o],d),Ge=(e,t,o,r)=>_(C,T(r),e,t,[],o),He=(e,t,o,r)=>_(y,T(r),e,t,[],o),Je=(e,t,o,r,n)=>_(m,T(n),t,o,[e],r),Ke=(e,t,o)=>_("Start"+J,T(o),e,t),Ne=(e,t,o)=>_("WillFinish"+J,T(o),e,t),Ue=(e,t,o)=>_("DidFinish"+J,T(o),e,t),Xe=(e,t,o)=>Z(e,t,o),Ye=()=>j(3),Ze=e=>$("MetricIds",E(e),[]),$e=(e,t)=>$("Metric",E(t),void 0,[e]),_e=(e,t,o,r)=>_("Metric",E(r),t,o,[e]),et=(e,t,o)=>Z(e,t,o),tt=()=>j(5),ot=(e,t)=>$("SliceIds",V(t),[],[e]),rt=e=>$("IndexIds",V(e),[]),nt=(e,t,o)=>$("Slice"+p,V(o),[],[e,t]),dt=(e,t,o,r)=>_("SliceIds",V(r),t,o,[e]),lt=(e,t,o,r,n)=>_("Slice"+p,V(n),o,r,[e,t]),st=(e,t,o)=>Z(e,t,o),ut=()=>j(7),it=e=>$("RelationshipIds",D(e),[]),at=(e,t,o)=>$("RemoteRowId",D(o),void 0,[e,t]),ct=(e,t,o)=>$("Local"+p,D(o),[],[e,t]),It=(e,t,o)=>$("Linked"+p,D(o),[],[e,t]),pt=(e,t,o,r,n)=>_("RemoteRowId",D(n),o,r,[e,t]),vt=(e,t,o,r,n)=>_("Local"+p,D(n),o,r,[e,t]),bt=(e,t,o,r,n)=>_("Linked"+p,D(n),o,r,[e,t]),gt=(e,t,o)=>Z(e,t,o),mt=()=>j(9),Ct=e=>$("QueryIds",W(e),[]),yt=(e,t)=>$(l+u,W(t),{},[e]),wt=(e,t)=>$(l+u+g,W(t),[],[e]),kt=(e,t)=>$(l+I,W(t),[],[e]),ht=(e,t)=>$(l+p,W(t),[],[e]),ft=(e,t,o,r=0,n,d)=>$(l+v,W(d),[],[e,t,o,r,n],6),Rt=(e,t,o)=>$(l+c,W(o),{},[e,t]),Pt=(e,t,o)=>$(l+g,W(o),[],[e,t]),xt=(e,t,o,r)=>$(l+b,W(r),void 0,[e,t,o]),qt=(e,t,o,r)=>_(l+u,W(r),t,o,[e]),Ot=(e,t,o,r)=>_(l+u+g,W(r),t,o,[e]),St=(e,t,o,r)=>_(l+I,W(r),t,o,[e]),Lt=(e,t,o,r)=>_(l+p,W(r),t,o,[e]),jt=(e,t,o,r,n,d,s,u)=>_(l+v,W(u),d,s,[e,t,o,r,n]),Bt=(e,t,o,r,n)=>_(l+c,W(n),o,r,[e,t]),Tt=(e,t,o,r,n)=>_(l+g,W(n),o,r,[e,t]),Mt=(e,t,o,r,n,d)=>_(l+b,W(d),r,n,[e,t,o]),Et=(e,t,o)=>Z(e,t,o),Ft=()=>j(11),Vt=e=>$("CheckpointIds",G(e),[[],void 0,[]]),At=(e,t)=>$("Checkpoint",G(t),void 0,[e]),Dt=(e=f,t=[],o,r=f,n=[])=>{const d=G(o);return K((t=>k(d,(o=>{const n=e(t);r(o.addCheckpoint(n),o,n)}))),[d,...t,...n])},Qt=e=>oe(e,"goBackward"),Wt=e=>oe(e,"goForward"),zt=(e,t=[],o,r=f,n=[])=>{const d=G(o);return K((t=>k(d,(o=>k(e(t),(e=>r(o.goTo(e),e)))))),[d,...t,...n])},Gt=e=>{var t;const o=G(e),[n,d]=Vt(o);return[(l=n,!(0==l.length)),Qt(o),d,null!=(t=k(d,(e=>null==o?void 0:o.getCheckpoint(e))))?t:r];var l},Ht=e=>{var t;const o=G(e),[,,[n]]=Vt(o);return[!w(n),Wt(o),n,null!=(t=k(n,(e=>null==o?void 0:o.getCheckpoint(e))))?t:r]},Jt=(e,t,o)=>_("CheckpointIds",G(o),e,t),Kt=(e,t,o,r)=>_("Checkpoint",G(r),t,o,[e]),Nt=(e,t,o=[],r,n=[])=>{const[,d]=Y(),l=U((()=>t(e)),[e,...o]);return N((()=>{var e;return e=function*(){yield null==r?void 0:r(l),d(1)},new Promise(((t,o)=>{var r=t=>{try{d(e.next(t))}catch(e){o(e)}},n=t=>{try{d(e.throw(t))}catch(e){o(e)}},d=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,n);d((e=e.apply(void 0,null)).next())})),()=>{null==l||l.destroy()}}),[l,...n]),l},{PureComponent:Ut,Fragment:Xt,createElement:Yt,useCallback:Zt,useLayoutEffect:$t,useRef:_t,useState:eo}=e,to=(e,...t)=>w(e)?{}:e(...t),oo=(e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)];var ro=Object.defineProperty,no=Object.defineProperties,lo=Object.getOwnPropertyDescriptors,so=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,io=Object.prototype.propertyIsEnumerable,ao=(e,t,o)=>t in e?ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,co=(e,t)=>{for(var o in t||(t={}))uo.call(t,o)&&ao(e,o,t[o]);if(so)for(var o of so(t))io.call(t,o)&&ao(e,o,t[o]);return e},Io=(e,t)=>no(e,lo(t)),po=(e,t)=>{var o={};for(var r in e)uo.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&so)for(var r of so(e))t.indexOf(r)<0&&io.call(e,r)&&(o[r]=e[r]);return o};const{useMemo:vo}=e,bo=({tableId:e,store:t,rowComponent:o=ho,getRowComponentProps:r,customCellIds:n,separator:d,debugIds:l},s)=>wo(R(s,(d=>Yt(o,Io(co({},to(r,d)),{key:d,tableId:e,rowId:d,customCellIds:n,store:t,debugIds:l})))),d,l,e),go=({queryId:e,queries:t,resultRowComponent:o=Eo,getResultRowComponentProps:r,separator:n,debugIds:d},l)=>wo(R(l,(n=>Yt(o,Io(co({},to(r,n)),{key:n,queryId:e,rowId:n,queries:t,debugIds:d})))),n,d,e),mo=({relationshipId:e,relationships:t,rowComponent:o=ho,getRowComponentProps:r,separator:n,debugIds:d},l,s)=>{const[u,i,a]=oo(D(t),e),c=l(e,s,u);return wo(R(c,(e=>Yt(o,Io(co({},to(r,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:d})))),n,d,s)},Co=e=>({checkpoints:t,checkpointComponent:o=Ao,getCheckpointComponentProps:r,separator:n,debugIds:d})=>{const l=G(t);return wo(R(e(Vt(l)),(e=>Yt(o,Io(co({},to(r,e)),{key:e,checkpoints:l,checkpointId:e,debugIds:d})))),n)},yo=({store:e,storesById:o,metrics:r,metricsById:n,indexes:d,indexesById:l,relationships:s,relationshipsById:u,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:p})=>{const v=t(O);return Yt(O.Provider,{value:vo((()=>[null!=e?e:v[0],co(co({},v[1]),o),null!=r?r:v[2],co(co({},v[3]),n),null!=d?d:v[4],co(co({},v[5]),l),null!=s?s:v[6],co(co({},v[7]),u),null!=i?i:v[8],co(co({},v[9]),a),null!=c?c:v[10],co(co({},v[11]),I)]),[e,o,r,n,d,l,s,u,i,a,c,I,v])},p)},wo=(e,t,o,r)=>{const n=w(t)||!Array.isArray(e)?e:R(e,((e,o)=>o>0?[t,e]:e));return o?[r,":{",n,"}"]:n},ko=({tableId:e,rowId:t,cellId:o,store:n,debugIds:d})=>{var l;return wo(r+(null!=(l=ve(e,t,o,n))?l:r),void 0,d,o)},ho=({tableId:e,rowId:t,store:o,cellComponent:r=ko,getCellComponentProps:n,customCellIds:d,separator:l,debugIds:s})=>wo(R(((e,t,o,r)=>{const n=pe(t,o,r);return null!=e?e:n})(d,e,t,o),(d=>Yt(r,Io(co({},to(n,d)),{key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:s})))),l,s,t),fo=e=>bo(e,ae(e.tableId,e.store)),Ro=e=>{var t=e,{cellId:o,descending:r,offset:n,limit:d}=t,l=po(t,["cellId","descending","offset","limit"]);return bo(l,ce(l.tableId,o,r,n,d,l.store))},Po=({store:e,tableComponent:t=fo,getTableComponentProps:o,separator:r,debugIds:n})=>wo(R(le(e),(r=>Yt(t,Io(co({},to(o,r)),{key:r,tableId:r,store:e,debugIds:n})))),r),xo=({valueId:e,store:t,debugIds:o})=>{var n;return wo(r+(null!=(n=me(e,t))?n:r),void 0,o,e)},qo=({store:e,valueComponent:t=xo,getValueComponentProps:o,separator:r,debugIds:n})=>wo(R(ge(e),(r=>Yt(t,Io(co({},to(o,r)),{key:r,valueId:r,store:e,debugIds:n})))),r),Oo=({metricId:e,metrics:t,debugIds:o})=>{var n;return wo(null!=(n=$e(e,t))?n:r,void 0,o,e)},So=({indexId:e,sliceId:t,indexes:o,rowComponent:r=ho,getRowComponentProps:n,separator:d,debugIds:l})=>{const[s,u,i]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(V(o),e),a=nt(e,t,s);return wo(R(a,(e=>Yt(r,Io(co({},to(n,e)),{key:e,tableId:i,rowId:e,store:u,debugIds:l})))),d,l,t)},Lo=({indexId:e,indexes:t,sliceComponent:o=So,getSliceComponentProps:r,separator:n,debugIds:d})=>wo(R(ot(e,t),(n=>Yt(o,Io(co({},to(r,n)),{key:n,indexId:e,sliceId:n,indexes:t,debugIds:d})))),n,d,e),jo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:r=ho,getRowComponentProps:n,debugIds:d})=>{const[l,s,,u]=oo(D(o),e),i=at(e,t,l);return wo(w(u)||w(i)?null:Yt(r,Io(co({},to(n,i)),{key:i,tableId:u,rowId:i,store:s,debugIds:d})),void 0,d,t)},Bo=e=>mo(e,ct,e.remoteRowId),To=e=>mo(e,It,e.firstRowId),Mo=({queryId:e,rowId:t,cellId:o,queries:n,debugIds:d})=>{var l;return wo(r+(null!=(l=xt(e,t,o,n))?l:r),void 0,d,o)},Eo=({queryId:e,rowId:t,queries:o,resultCellComponent:r=Mo,getResultCellComponentProps:n,separator:d,debugIds:l})=>wo(R(Pt(e,t,o),(d=>Yt(r,Io(co({},to(n,d)),{key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:l})))),d,l,t),Fo=e=>go(e,ht(e.queryId,e.queries)),Vo=e=>{var t=e,{cellId:o,descending:r,offset:n,limit:d}=t,l=po(t,["cellId","descending","offset","limit"]);return go(l,ft(l.queryId,o,r,n,d,l.queries))},Ao=({checkpoints:e,checkpointId:t,debugIds:o})=>{var n;return wo(null!=(n=At(t,e))?n:r,void 0,o,t)},Do=Co((e=>e[0])),Qo=Co((e=>w(e[1])?[]:[e[1]])),Wo=Co((e=>e[2]));export{Do as BackwardCheckpointsView,ko as CellView,Ao as CheckpointView,Qo as CurrentCheckpointView,Wo as ForwardCheckpointsView,Lo as IndexView,To as LinkedRowsView,Bo as LocalRowsView,Oo as MetricView,yo as Provider,jo as RemoteRowView,Mo as ResultCellView,Eo as ResultRowView,Vo as ResultSortedTableView,Fo as ResultTableView,ho as RowView,So as SliceView,Ro as SortedTableView,fo as TableView,Po as TablesView,xo as ValueView,qo as ValuesView,ke as useAddRowCallback,ve as useCell,pe as useCellIds,We as useCellIdsListener,ze as useCellListener,At as useCheckpoint,Vt as useCheckpointIds,Jt as useCheckpointIdsListener,Kt as useCheckpointListener,z as useCheckpoints,Ft as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Et as useCreateCheckpoints,et as useCreateIndexes,Xe as useCreateMetrics,Nt as useCreatePersister,gt as useCreateQueries,st as useCreateRelationships,re as useCreateStore,Le as useDelCellCallback,Se as useDelRowCallback,Oe as useDelTableCallback,qe as useDelTablesCallback,Be as useDelValueCallback,je as useDelValuesCallback,Ue as useDidFinishTransactionListener,Qt as useGoBackwardCallback,Wt as useGoForwardCallback,zt as useGoToCallback,rt as useIndexIds,F as useIndexes,tt as useIndexesIds,V as useIndexesOrIndexesById,It as useLinkedRowIds,bt as useLinkedRowIdsListener,ct as useLocalRowIds,vt as useLocalRowIdsListener,$e as useMetric,Ze as useMetricIds,_e as useMetricListener,M as useMetrics,Ye as useMetricsIds,E as useMetricsOrMetricsById,Q as useQueries,mt as useQueriesIds,W as useQueriesOrQueriesById,Ct as useQueryIds,Ht as useRedoInformation,it as useRelationshipIds,A as useRelationships,ut as useRelationshipsIds,D as useRelationshipsOrRelationshipsById,at as useRemoteRowId,pt as useRemoteRowIdListener,xt as useResultCell,Pt as useResultCellIds,Tt as useResultCellIdsListener,Mt as useResultCellListener,Rt as useResultRow,kt as useResultRowCount,St as useResultRowCountListener,ht as useResultRowIds,Lt as useResultRowIdsListener,Bt as useResultRowListener,ft as useResultSortedRowIds,jt as useResultSortedRowIdsListener,yt as useResultTable,wt as useResultTableCellIds,Ot as useResultTableCellIdsListener,qt as useResultTableListener,Ie as useRow,ie as useRowCount,Ve as useRowCountListener,ae as useRowIds,Ae as useRowIdsListener,Qe as useRowListener,fe as useSetCellCallback,Dt as useSetCheckpointCallback,he as useSetPartialRowCallback,Pe as useSetPartialValuesCallback,we as useSetRowCallback,ye as useSetTableCallback,Ce as useSetTablesCallback,xe as useSetValueCallback,Re as useSetValuesCallback,ot as useSliceIds,dt as useSliceIdsListener,nt as useSliceRowIds,lt as useSliceRowIdsListener,ce as useSortedRowIds,De as useSortedRowIdsListener,Ke as useStartTransactionListener,B as useStore,ne as useStoreIds,T as useStoreOrStoreById,se as useTable,ue as useTableCellIds,Fe as useTableCellIdsListener,le as useTableIds,Me as useTableIdsListener,Ee as useTableListener,de as useTables,Te as useTablesListener,Gt as useUndoInformation,me as useValue,ge as useValueIds,He as useValueIdsListener,Je as useValueListener,be as useValues,Ge as useValuesListener,Ne as useWillFinishTransactionListener};
1
+ import e,{useContext as t}from"react";const o=e=>typeof e,r="",n=o(r),d="Listener",l="Result",s="Ids",u="Table",i=u+"s",a=u+s,c="Row",I=c+"Count",p=c+s,v="Sorted"+c+s,b="Cell",g=b+s,m="Value",C=m+"s",y=m+s,w=e=>null==e,k=(e,t,o)=>w(e)?null==o?void 0:o():t(e),h=e=>o(e)==n,f=()=>{},R=(e,t)=>e.map(t),P=Object.keys,{createContext:x,useContext:q}=e,O=x([]),S=(e,t)=>{var o;const r=q(O);return w(e)?r[t]:h(e)?((e,t)=>k(e,(e=>e[t])))(null!=(o=r[t+1])?o:{},e):e},L=(e,t)=>{const o=S(e,t);return w(e)||h(e)?o:e},j=e=>{var t;return P(null!=(t=q(O)[e])?t:{})},B=e=>S(e,0),T=e=>L(e,0),M=e=>S(e,2),E=e=>L(e,2),F=e=>S(e,4),V=e=>L(e,4),A=e=>S(e,6),D=e=>L(e,6),Q=e=>S(e,8),W=e=>L(e,8),z=e=>S(e,10),G=e=>L(e,10),H=e=>e.toLowerCase();H(d);const J="Transaction";H(J);const{useCallback:K,useEffect:N,useMemo:U,useRef:X,useState:Y}=e,Z=(e,t,o=[])=>{const r=U((()=>t(e)),[e,...o]);return N((()=>()=>r.destroy()),[r]),r},$=(e,t,o,r=[],n)=>{const[,d]=Y(),l=K((()=>{var n,d;return null!=(d=null==(n=null==t?void 0:t["get"+e])?void 0:n.call(t,...r))?d:o}),[t,...r]),[s]=Y(l),u=X(s);return U((()=>u.current=l()),[l]),_(e,t,((...e)=>{u.current=w(n)?l():e[n],d([])}),[],r),u.current},_=(e,t,o,r=[],n=[],...l)=>N((()=>{var r;const s=null==(r=null==t?void 0:t["add"+e+d])?void 0:r.call(t,...n,o,...l);return()=>null==t?void 0:t.delListener(s)}),[t,...n,...r,...l]),ee=(e,t,o,r=[],n=f,d=[],...l)=>{const s=T(e);return K((e=>k(s,(r=>k(o(e,r),(e=>n(r["set"+t](...l,e),e)))))),[s,t,...r,...d,...l])},te=(e,t,o=f,r=[],...n)=>{const d=T(e);return K((()=>o(null==d?void 0:d["del"+t](...n))),[d,t,...r,...n])},oe=(e,t,o)=>{const r=G(e);return K((()=>null==r?void 0:r[t](o)),[r,t,o])},re=(e,t=[])=>U(e,t),ne=()=>j(1),de=e=>$(i,T(e),{}),le=e=>$(a,T(e),[],[]),se=(e,t)=>$(u,T(t),{},[e]),ue=(e,t)=>$(u+g,T(t),[],[e]),ie=(e,t)=>$(I,T(t),[],[e]),ae=(e,t)=>$(p,T(t),[],[e]),ce=(e,t,o,r=0,n,d)=>$(v,T(d),[],[e,t,o,r,n],6),Ie=(e,t,o)=>$(c,T(o),{},[e,t]),pe=(e,t,o)=>$(g,T(o),[],[e,t]),ve=(e,t,o,r)=>$(b,T(r),void 0,[e,t,o],4),be=e=>$(C,T(e),{}),ge=e=>$(y,T(e),[],[]),me=(e,t)=>$(m,T(t),void 0,[e]),Ce=(e,t,o,r,n)=>ee(o,i,e,t,r,n),ye=(e,t,o,r,n,d)=>ee(r,u,t,o,n,d,e),we=(e,t,o,r,n,d,l)=>ee(n,c,o,r,d,l,e,t),ke=(e,t,o=[],r,n=f,d=[],l=!0)=>{const s=T(r);return K((o=>k(s,(r=>k(t(o,r),(t=>n(r.addRow(e,t,l),r,t)))))),[s,e,...o,...d,l])},he=(e,t,o,r,n,d,l)=>ee(n,"PartialRow",o,r,d,l,e,t),fe=(e,t,o,r,n,d,l,s)=>ee(d,b,r,n,l,s,e,t,o),Re=(e,t,o,r,n)=>ee(o,C,e,t,r,n),Pe=(e,t,o,r,n)=>ee(o,"PartialValues",e,t,r,n),xe=(e,t,o,r,n,d)=>ee(r,m,t,o,n,d,e),qe=(e,t,o)=>te(e,i,t,o),Oe=(e,t,o,r)=>te(t,u,o,r,e),Se=(e,t,o,r,n)=>te(o,c,r,n,e,t),Le=(e,t,o,r,n,d,l)=>te(n,b,d,l,e,t,o,r),je=(e,t,o)=>te(e,C,t,o),Be=(e,t,o,r)=>te(t,m,o,r,e),Te=(e,t,o,r)=>_(i,T(r),e,t,[],o),Me=(e,t,o,r)=>_(a,T(r),e,t,[],o),Ee=(e,t,o,r,n)=>_(u,T(n),t,o,[e],r),Fe=(e,t,o,r,n)=>_(u+g,T(n),t,o,[e],r),Ve=(e,t,o,r,n)=>_(I,T(n),t,o,[e],r),Ae=(e,t,o,r,n)=>_(p,T(n),t,o,[e],r),De=(e,t,o,r,n,d,l,s,u)=>_(v,T(u),d,l,[e,t,o,r,n],s),Qe=(e,t,o,r,n,d)=>_(c,T(d),o,r,[e,t],n),We=(e,t,o,r,n,d)=>_(g,T(d),o,r,[e,t],n),ze=(e,t,o,r,n,d,l)=>_(b,T(l),r,n,[e,t,o],d),Ge=(e,t,o,r)=>_(C,T(r),e,t,[],o),He=(e,t,o,r)=>_(y,T(r),e,t,[],o),Je=(e,t,o,r,n)=>_(m,T(n),t,o,[e],r),Ke=(e,t,o)=>_("Start"+J,T(o),e,t),Ne=(e,t,o)=>_("WillFinish"+J,T(o),e,t),Ue=(e,t,o)=>_("DidFinish"+J,T(o),e,t),Xe=(e,t,o)=>Z(e,t,o),Ye=()=>j(3),Ze=e=>$("MetricIds",E(e),[]),$e=(e,t)=>$("Metric",E(t),void 0,[e]),_e=(e,t,o,r)=>_("Metric",E(r),t,o,[e]),et=(e,t,o)=>Z(e,t,o),tt=()=>j(5),ot=(e,t)=>$("SliceIds",V(t),[],[e]),rt=e=>$("IndexIds",V(e),[]),nt=(e,t,o)=>$("Slice"+p,V(o),[],[e,t]),dt=(e,t,o,r)=>_("SliceIds",V(r),t,o,[e]),lt=(e,t,o,r,n)=>_("Slice"+p,V(n),o,r,[e,t]),st=(e,t,o)=>Z(e,t,o),ut=()=>j(7),it=e=>$("RelationshipIds",D(e),[]),at=(e,t,o)=>$("RemoteRowId",D(o),void 0,[e,t]),ct=(e,t,o)=>$("Local"+p,D(o),[],[e,t]),It=(e,t,o)=>$("Linked"+p,D(o),[],[e,t]),pt=(e,t,o,r,n)=>_("RemoteRowId",D(n),o,r,[e,t]),vt=(e,t,o,r,n)=>_("Local"+p,D(n),o,r,[e,t]),bt=(e,t,o,r,n)=>_("Linked"+p,D(n),o,r,[e,t]),gt=(e,t,o)=>Z(e,t,o),mt=()=>j(9),Ct=e=>$("QueryIds",W(e),[]),yt=(e,t)=>$(l+u,W(t),{},[e]),wt=(e,t)=>$(l+u+g,W(t),[],[e]),kt=(e,t)=>$(l+I,W(t),[],[e]),ht=(e,t)=>$(l+p,W(t),[],[e]),ft=(e,t,o,r=0,n,d)=>$(l+v,W(d),[],[e,t,o,r,n],6),Rt=(e,t,o)=>$(l+c,W(o),{},[e,t]),Pt=(e,t,o)=>$(l+g,W(o),[],[e,t]),xt=(e,t,o,r)=>$(l+b,W(r),void 0,[e,t,o]),qt=(e,t,o,r)=>_(l+u,W(r),t,o,[e]),Ot=(e,t,o,r)=>_(l+u+g,W(r),t,o,[e]),St=(e,t,o,r)=>_(l+I,W(r),t,o,[e]),Lt=(e,t,o,r)=>_(l+p,W(r),t,o,[e]),jt=(e,t,o,r,n,d,s,u)=>_(l+v,W(u),d,s,[e,t,o,r,n]),Bt=(e,t,o,r,n)=>_(l+c,W(n),o,r,[e,t]),Tt=(e,t,o,r,n)=>_(l+g,W(n),o,r,[e,t]),Mt=(e,t,o,r,n,d)=>_(l+b,W(d),r,n,[e,t,o]),Et=(e,t,o)=>Z(e,t,o),Ft=()=>j(11),Vt=e=>$("CheckpointIds",G(e),[[],void 0,[]]),At=(e,t)=>$("Checkpoint",G(t),void 0,[e]),Dt=(e=f,t=[],o,r=f,n=[])=>{const d=G(o);return K((t=>k(d,(o=>{const n=e(t);r(o.addCheckpoint(n),o,n)}))),[d,...t,...n])},Qt=e=>oe(e,"goBackward"),Wt=e=>oe(e,"goForward"),zt=(e,t=[],o,r=f,n=[])=>{const d=G(o);return K((t=>k(d,(o=>k(e(t),(e=>r(o.goTo(e),e)))))),[d,...t,...n])},Gt=e=>{var t;const o=G(e),[n,d]=Vt(o);return[(l=n,!(0==l.length)),Qt(o),d,null!=(t=k(d,(e=>null==o?void 0:o.getCheckpoint(e))))?t:r];var l},Ht=e=>{var t;const o=G(e),[,,[n]]=Vt(o);return[!w(n),Wt(o),n,null!=(t=k(n,(e=>null==o?void 0:o.getCheckpoint(e))))?t:r]},Jt=(e,t,o)=>_("CheckpointIds",G(o),e,t),Kt=(e,t,o,r)=>_("Checkpoint",G(r),t,o,[e]),Nt=(e,t,o=[],r,n=[],d,l=[])=>{const[,s]=Y(),u=U((()=>t(e)),[e,...o]);return N((()=>{var e;return e=function*(){r&&(yield r(u),s([]))},new Promise(((t,o)=>{var r=t=>{try{d(e.next(t))}catch(e){o(e)}},n=t=>{try{d(e.throw(t))}catch(e){o(e)}},d=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,n);d((e=e.apply(void 0,null)).next())})),()=>{null==u||u.destroy(),null==d||d(u)}}),[u,...n,...l]),u},{PureComponent:Ut,Fragment:Xt,createElement:Yt,useCallback:Zt,useLayoutEffect:$t,useRef:_t,useState:eo}=e,to=(e,...t)=>w(e)?{}:e(...t),oo=(e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)];var ro=Object.defineProperty,no=Object.defineProperties,lo=Object.getOwnPropertyDescriptors,so=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,io=Object.prototype.propertyIsEnumerable,ao=(e,t,o)=>t in e?ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,co=(e,t)=>{for(var o in t||(t={}))uo.call(t,o)&&ao(e,o,t[o]);if(so)for(var o of so(t))io.call(t,o)&&ao(e,o,t[o]);return e},Io=(e,t)=>no(e,lo(t)),po=(e,t)=>{var o={};for(var r in e)uo.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&so)for(var r of so(e))t.indexOf(r)<0&&io.call(e,r)&&(o[r]=e[r]);return o};const{useMemo:vo}=e,bo=({tableId:e,store:t,rowComponent:o=ho,getRowComponentProps:r,customCellIds:n,separator:d,debugIds:l},s)=>wo(R(s,(d=>Yt(o,Io(co({},to(r,d)),{key:d,tableId:e,rowId:d,customCellIds:n,store:t,debugIds:l})))),d,l,e),go=({queryId:e,queries:t,resultRowComponent:o=Eo,getResultRowComponentProps:r,separator:n,debugIds:d},l)=>wo(R(l,(n=>Yt(o,Io(co({},to(r,n)),{key:n,queryId:e,rowId:n,queries:t,debugIds:d})))),n,d,e),mo=({relationshipId:e,relationships:t,rowComponent:o=ho,getRowComponentProps:r,separator:n,debugIds:d},l,s)=>{const[u,i,a]=oo(D(t),e),c=l(e,s,u);return wo(R(c,(e=>Yt(o,Io(co({},to(r,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:d})))),n,d,s)},Co=e=>({checkpoints:t,checkpointComponent:o=Ao,getCheckpointComponentProps:r,separator:n,debugIds:d})=>{const l=G(t);return wo(R(e(Vt(l)),(e=>Yt(o,Io(co({},to(r,e)),{key:e,checkpoints:l,checkpointId:e,debugIds:d})))),n)},yo=({store:e,storesById:o,metrics:r,metricsById:n,indexes:d,indexesById:l,relationships:s,relationshipsById:u,queries:i,queriesById:a,checkpoints:c,checkpointsById:I,children:p})=>{const v=t(O);return Yt(O.Provider,{value:vo((()=>[null!=e?e:v[0],co(co({},v[1]),o),null!=r?r:v[2],co(co({},v[3]),n),null!=d?d:v[4],co(co({},v[5]),l),null!=s?s:v[6],co(co({},v[7]),u),null!=i?i:v[8],co(co({},v[9]),a),null!=c?c:v[10],co(co({},v[11]),I)]),[e,o,r,n,d,l,s,u,i,a,c,I,v])},p)},wo=(e,t,o,r)=>{const n=w(t)||!Array.isArray(e)?e:R(e,((e,o)=>o>0?[t,e]:e));return o?[r,":{",n,"}"]:n},ko=({tableId:e,rowId:t,cellId:o,store:n,debugIds:d})=>{var l;return wo(r+(null!=(l=ve(e,t,o,n))?l:r),void 0,d,o)},ho=({tableId:e,rowId:t,store:o,cellComponent:r=ko,getCellComponentProps:n,customCellIds:d,separator:l,debugIds:s})=>wo(R(((e,t,o,r)=>{const n=pe(t,o,r);return null!=e?e:n})(d,e,t,o),(d=>Yt(r,Io(co({},to(n,d)),{key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:s})))),l,s,t),fo=e=>bo(e,ae(e.tableId,e.store)),Ro=e=>{var t=e,{cellId:o,descending:r,offset:n,limit:d}=t,l=po(t,["cellId","descending","offset","limit"]);return bo(l,ce(l.tableId,o,r,n,d,l.store))},Po=({store:e,tableComponent:t=fo,getTableComponentProps:o,separator:r,debugIds:n})=>wo(R(le(e),(r=>Yt(t,Io(co({},to(o,r)),{key:r,tableId:r,store:e,debugIds:n})))),r),xo=({valueId:e,store:t,debugIds:o})=>{var n;return wo(r+(null!=(n=me(e,t))?n:r),void 0,o,e)},qo=({store:e,valueComponent:t=xo,getValueComponentProps:o,separator:r,debugIds:n})=>wo(R(ge(e),(r=>Yt(t,Io(co({},to(o,r)),{key:r,valueId:r,store:e,debugIds:n})))),r),Oo=({metricId:e,metrics:t,debugIds:o})=>{var n;return wo(null!=(n=$e(e,t))?n:r,void 0,o,e)},So=({indexId:e,sliceId:t,indexes:o,rowComponent:r=ho,getRowComponentProps:n,separator:d,debugIds:l})=>{const[s,u,i]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(V(o),e),a=nt(e,t,s);return wo(R(a,(e=>Yt(r,Io(co({},to(n,e)),{key:e,tableId:i,rowId:e,store:u,debugIds:l})))),d,l,t)},Lo=({indexId:e,indexes:t,sliceComponent:o=So,getSliceComponentProps:r,separator:n,debugIds:d})=>wo(R(ot(e,t),(n=>Yt(o,Io(co({},to(r,n)),{key:n,indexId:e,sliceId:n,indexes:t,debugIds:d})))),n,d,e),jo=({relationshipId:e,localRowId:t,relationships:o,rowComponent:r=ho,getRowComponentProps:n,debugIds:d})=>{const[l,s,,u]=oo(D(o),e),i=at(e,t,l);return wo(w(u)||w(i)?null:Yt(r,Io(co({},to(n,i)),{key:i,tableId:u,rowId:i,store:s,debugIds:d})),void 0,d,t)},Bo=e=>mo(e,ct,e.remoteRowId),To=e=>mo(e,It,e.firstRowId),Mo=({queryId:e,rowId:t,cellId:o,queries:n,debugIds:d})=>{var l;return wo(r+(null!=(l=xt(e,t,o,n))?l:r),void 0,d,o)},Eo=({queryId:e,rowId:t,queries:o,resultCellComponent:r=Mo,getResultCellComponentProps:n,separator:d,debugIds:l})=>wo(R(Pt(e,t,o),(d=>Yt(r,Io(co({},to(n,d)),{key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:l})))),d,l,t),Fo=e=>go(e,ht(e.queryId,e.queries)),Vo=e=>{var t=e,{cellId:o,descending:r,offset:n,limit:d}=t,l=po(t,["cellId","descending","offset","limit"]);return go(l,ft(l.queryId,o,r,n,d,l.queries))},Ao=({checkpoints:e,checkpointId:t,debugIds:o})=>{var n;return wo(null!=(n=At(t,e))?n:r,void 0,o,t)},Do=Co((e=>e[0])),Qo=Co((e=>w(e[1])?[]:[e[1]])),Wo=Co((e=>e[2]));export{Do as BackwardCheckpointsView,ko as CellView,Ao as CheckpointView,Qo as CurrentCheckpointView,Wo as ForwardCheckpointsView,Lo as IndexView,To as LinkedRowsView,Bo as LocalRowsView,Oo as MetricView,yo as Provider,jo as RemoteRowView,Mo as ResultCellView,Eo as ResultRowView,Vo as ResultSortedTableView,Fo as ResultTableView,ho as RowView,So as SliceView,Ro as SortedTableView,fo as TableView,Po as TablesView,xo as ValueView,qo as ValuesView,ke as useAddRowCallback,ve as useCell,pe as useCellIds,We as useCellIdsListener,ze as useCellListener,At as useCheckpoint,Vt as useCheckpointIds,Jt as useCheckpointIdsListener,Kt as useCheckpointListener,z as useCheckpoints,Ft as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Et as useCreateCheckpoints,et as useCreateIndexes,Xe as useCreateMetrics,Nt as useCreatePersister,gt as useCreateQueries,st as useCreateRelationships,re as useCreateStore,Le as useDelCellCallback,Se as useDelRowCallback,Oe as useDelTableCallback,qe as useDelTablesCallback,Be as useDelValueCallback,je as useDelValuesCallback,Ue as useDidFinishTransactionListener,Qt as useGoBackwardCallback,Wt as useGoForwardCallback,zt as useGoToCallback,rt as useIndexIds,F as useIndexes,tt as useIndexesIds,V as useIndexesOrIndexesById,It as useLinkedRowIds,bt as useLinkedRowIdsListener,ct as useLocalRowIds,vt as useLocalRowIdsListener,$e as useMetric,Ze as useMetricIds,_e as useMetricListener,M as useMetrics,Ye as useMetricsIds,E as useMetricsOrMetricsById,Q as useQueries,mt as useQueriesIds,W as useQueriesOrQueriesById,Ct as useQueryIds,Ht as useRedoInformation,it as useRelationshipIds,A as useRelationships,ut as useRelationshipsIds,D as useRelationshipsOrRelationshipsById,at as useRemoteRowId,pt as useRemoteRowIdListener,xt as useResultCell,Pt as useResultCellIds,Tt as useResultCellIdsListener,Mt as useResultCellListener,Rt as useResultRow,kt as useResultRowCount,St as useResultRowCountListener,ht as useResultRowIds,Lt as useResultRowIdsListener,Bt as useResultRowListener,ft as useResultSortedRowIds,jt as useResultSortedRowIdsListener,yt as useResultTable,wt as useResultTableCellIds,Ot as useResultTableCellIdsListener,qt as useResultTableListener,Ie as useRow,ie as useRowCount,Ve as useRowCountListener,ae as useRowIds,Ae as useRowIdsListener,Qe as useRowListener,fe as useSetCellCallback,Dt as useSetCheckpointCallback,he as useSetPartialRowCallback,Pe as useSetPartialValuesCallback,we as useSetRowCallback,ye as useSetTableCallback,Ce as useSetTablesCallback,xe as useSetValueCallback,Re as useSetValuesCallback,ot as useSliceIds,dt as useSliceIdsListener,nt as useSliceRowIds,lt as useSliceRowIdsListener,ce as useSortedRowIds,De as useSortedRowIdsListener,Ke as useStartTransactionListener,B as useStore,ne as useStoreIds,T as useStoreOrStoreById,se as useTable,ue as useTableCellIds,Fe as useTableCellIdsListener,le as useTableIds,Me as useTableIdsListener,Ee as useTableListener,de as useTables,Te as useTablesListener,Gt as useUndoInformation,me as useValue,ge as useValueIds,He as useValueIdsListener,Je as useValueListener,be as useValues,Ge as useValuesListener,Ne as useWillFinishTransactionListener};
Binary file
@@ -8896,6 +8896,13 @@ export function useCheckpointListener(
8896
8896
  * collaboration features. As a result, the `then` callback may also get passed
8897
8897
  * undefined, which you should handle accordingly.
8898
8898
  *
8899
+ * Since v4.3.19, a `destroy` function can be provided which will be called
8900
+ * after an old Persister is destroyed due to a change in the `createDeps`
8901
+ * dependencies that is creating a new one. Use this to clean up any underlying
8902
+ * storage objects that you set up during the `then` function, for example. If
8903
+ * this callback itself contains additional dependencies, you can provide them
8904
+ * in an array in the seventh parameter.
8905
+ *
8899
8906
  * This hook ensures the Persister object is destroyed whenever a new one is
8900
8907
  * created or the component is unmounted.
8901
8908
  * @param store A reference to the Store for which to create a new Persister
@@ -8910,6 +8917,12 @@ export function useCheckpointListener(
8910
8917
  * @param thenDeps An optional array of dependencies for the `then` callback,
8911
8918
  * which, if any change, result in its rerun. This parameter defaults to an
8912
8919
  * empty array.
8920
+ * @param destroy An optional callback whenever the Persister is destroyed due
8921
+ * to a change in the `createDeps` dependencies. destroyDeps?:
8922
+ * React.DependencyList,
8923
+ * @param destroyDeps An optional array of dependencies for the `destroy`
8924
+ * callback, which, if any change, result in `destroy` and `then` being rerun.
8925
+ * This parameter defaults to an empty array.
8913
8926
  * @returns A reference to the Persister.
8914
8927
  * @example
8915
8928
  * This example creates a Persister at the top level of a React application.
@@ -8957,7 +8970,8 @@ export function useCheckpointListener(
8957
8970
  * This example creates a Persister at the top level of a React application. The
8958
8971
  * App component is rendered twice, each with a different top-level prop. The
8959
8972
  * useCreatePersister hook takes the `sessionKey` prop as a dependency, and so
8960
- * the Persister object is created again on the second render.
8973
+ * the Persister object is created again on the second render. The first is
8974
+ * destroyed and the `destroy` parameter is called for it.
8961
8975
  *
8962
8976
  * ```jsx
8963
8977
  * const App = ({sessionKey}) => {
@@ -8971,8 +8985,12 @@ export function useCheckpointListener(
8971
8985
  * [sessionKey],
8972
8986
  * async (persister) => {
8973
8987
  * await persister.startAutoLoad();
8974
- * await persister.startAutoSave();
8975
8988
  * },
8989
+ * [],
8990
+ * (persister) =>
8991
+ * console.log(
8992
+ * `Persister destroyed for session key ${persister.getStorageName()}`,
8993
+ * ),
8976
8994
  * );
8977
8995
  * return <span>{JSON.stringify(useTables(store))}</span>;
8978
8996
  * };
@@ -8997,12 +9015,14 @@ export function useCheckpointListener(
8997
9015
  *
8998
9016
  * root.render(<App sessionKey="cujoStore" />); // !act
8999
9017
  * // -> 'Persister created for session key cujoStore'
9018
+ * // -> 'Persister destroyed for session key fidoStore'
9000
9019
  *
9001
9020
  * // ... // !act
9002
9021
  * console.log(app.innerHTML);
9003
9022
  * // -> '<span>{\"pets\":{\"cujo\":{\"species\":\"dog\"}}}</span>'
9004
9023
  *
9005
9024
  * root.unmount(); // !act
9025
+ * // -> 'Persister destroyed for session key cujoStore'
9006
9026
  * ```
9007
9027
  * @category Persister hooks
9008
9028
  */
@@ -9014,6 +9034,8 @@ export function useCreatePersister<
9014
9034
  createDeps?: React.DependencyList,
9015
9035
  then?: (persister: PersisterOrUndefined) => Promise<void>,
9016
9036
  thenDeps?: React.DependencyList,
9037
+ destroy?: (persister: PersisterOrUndefined) => void,
9038
+ destroyDeps?: React.DependencyList,
9017
9039
  ): PersisterOrUndefined;
9018
9040
 
9019
9041
  /**
@@ -10122,6 +10122,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
10122
10122
  * createDeps?: React.DependencyList,
10123
10123
  * then?: (persister: PersisterOrUndefined) => Promise<void>,
10124
10124
  * thenDeps?: React.DependencyList,
10125
+ * destroy?: (persister: PersisterOrUndefined) => void,
10126
+ * destroyDeps?: React.DependencyList,
10125
10127
  * ): PersisterOrUndefined;
10126
10128
  * ```
10127
10129
  *
@@ -10153,6 +10155,13 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
10153
10155
  * collaboration features. As a result, the `then` callback may also get passed
10154
10156
  * undefined, which you should handle accordingly.
10155
10157
  *
10158
+ * Since v4.3.19, a `destroy` function can be provided which will be called
10159
+ * after an old Persister is destroyed due to a change in the `createDeps`
10160
+ * dependencies that is creating a new one. Use this to clean up any underlying
10161
+ * storage objects that you set up during the `then` function, for example. If
10162
+ * this callback itself contains additional dependencies, you can provide them
10163
+ * in an array in the seventh parameter.
10164
+ *
10156
10165
  * This hook ensures the Persister object is destroyed whenever a new one is
10157
10166
  * created or the component is unmounted.
10158
10167
  * @param store A reference to the Store for which to create a new Persister
@@ -10167,6 +10176,12 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
10167
10176
  * @param thenDeps An optional array of dependencies for the `then` callback,
10168
10177
  * which, if any change, result in its rerun. This parameter defaults to an
10169
10178
  * empty array.
10179
+ * @param destroy An optional callback whenever the Persister is destroyed due
10180
+ * to a change in the `createDeps` dependencies. destroyDeps?:
10181
+ * React.DependencyList,
10182
+ * @param destroyDeps An optional array of dependencies for the `destroy`
10183
+ * callback, which, if any change, result in `destroy` and `then` being rerun.
10184
+ * This parameter defaults to an empty array.
10170
10185
  * @returns A reference to the Persister.
10171
10186
  * @example
10172
10187
  * This example creates a Persister at the top level of a React application.
@@ -10214,7 +10229,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
10214
10229
  * This example creates a Persister at the top level of a React application. The
10215
10230
  * App component is rendered twice, each with a different top-level prop. The
10216
10231
  * useCreatePersister hook takes the `sessionKey` prop as a dependency, and so
10217
- * the Persister object is created again on the second render.
10232
+ * the Persister object is created again on the second render. The first is
10233
+ * destroyed and the `destroy` parameter is called for it.
10218
10234
  *
10219
10235
  * ```jsx
10220
10236
  * const App = ({sessionKey}) => {
@@ -10228,8 +10244,12 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
10228
10244
  * [sessionKey],
10229
10245
  * async (persister) => {
10230
10246
  * await persister.startAutoLoad();
10231
- * await persister.startAutoSave();
10232
10247
  * },
10248
+ * [],
10249
+ * (persister) =>
10250
+ * console.log(
10251
+ * `Persister destroyed for session key ${persister.getStorageName()}`,
10252
+ * ),
10233
10253
  * );
10234
10254
  * return <span>{JSON.stringify(useTables(store))}</span>;
10235
10255
  * };
@@ -10254,12 +10274,14 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
10254
10274
  *
10255
10275
  * root.render(<App sessionKey="cujoStore" />); // !act
10256
10276
  * // -> 'Persister created for session key cujoStore'
10277
+ * // -> 'Persister destroyed for session key fidoStore'
10257
10278
  *
10258
10279
  * // ... // !act
10259
10280
  * console.log(app.innerHTML);
10260
10281
  * // -> '<span>{\"pets\":{\"cujo\":{\"species\":\"dog\"}}}</span>'
10261
10282
  *
10262
10283
  * root.unmount(); // !act
10284
+ * // -> 'Persister destroyed for session key cujoStore'
10263
10285
  * ```
10264
10286
  * @category Persister hooks
10265
10287
  */
@@ -10271,6 +10293,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
10271
10293
  createDeps?: React.DependencyList,
10272
10294
  then?: (persister?: PersisterOrUndefined) => Promise<void>,
10273
10295
  thenDeps?: React.DependencyList,
10296
+ destroy?: (persister: PersisterOrUndefined) => void,
10297
+ destroyDeps?: React.DependencyList,
10274
10298
  ) => PersisterOrUndefined;
10275
10299
 
10276
10300
  /**
@@ -1 +1 @@
1
- import e from"react";import{useRowIds as t,useTableCellIds as l,useRowCount as a,useSortedRowIds as n,useValueIds as o,ValueView as r,useIndexesOrIndexesById as i,useSliceRowIds as s,useRelationshipsOrRelationshipsById as d,useResultRowIds as m,useResultTableCellIds as h,useResultRowCount as c,useResultSortedRowIds as u,useCell as g,useSetCellCallback as p,useStoreOrStoreById as b,useValue as f,useSetValueCallback as w,useRemoteRowId as y,CellView as k,ResultCellView as v}from"./ui-react";const C=e=>typeof e,x=C(""),I=C(!0),N=C(0),z="Value",T="currentTarget",M="value",$=isFinite,S=e=>null==e,{PureComponent:F,Fragment:R,createElement:q,useCallback:E,useLayoutEffect:P,useRef:O,useState:V}=e,j=(e,...t)=>S(e)?{}:e(...t),A=(e,t)=>e.map(t),B=Object,D=(e=[])=>B.fromEntries(e),L=(e,t)=>A(B.entries(e),(([e,l])=>t(l,e))),G="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",H='content:url("',J=H+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",K='</svg>")',Q=H+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",U=A([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>J+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+K)),W=J+"<path d='M20 20l60 60M20 80l60-60' />"+K,X=J+`<path d='${G}' />`+K,Y=J+`<path d='${G}M20 20l60 60' />`+K,Z="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(L({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Z]:"width:0.5rem;height:0.5rem;",[Z+"-track"]:"background:#111",[Z+"-thumb"]:"background:#999;border:1px solid #111",[Z+"-thumb:hover"]:"background:#fff",[Z+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Q,...D(A(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...D(A(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Q,"header>img:nth-of-type(6)":W,...D(A(U,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":X,"details[open]>summary img.done":Y,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`& ${t}{${e}}`:"")));const _=(e,t,l,a)=>e==x?t:e==N?l:a,{useCallback:ee,useMemo:te,useState:le}=e,ae="editable",ne=(e,t)=>A(l(e,t),(t=>e+"."+t)),oe=(e,t,l)=>{const a=ee(e,t);return l?a:void 0},re=(...e)=>te((()=>e),e),ie=(e,t)=>te((()=>({store:e,tableId:t})),[e,t]),se=(e,t)=>te((()=>({queries:e,queryId:t})),[e,t]),de=(e,t=!1,l,a=0,n,o,r,i)=>{const[[s,d,m],h]=le([e,t,a]),c=ee((e=>{h(e),i?.(e)}),[i]),u=oe((e=>c([e,e==s&&!d,m])),[c,s,d,m],l),g=ee((e=>c([s,d,e])),[c,s,d]),p=!0===r?Ie:r;return[[s,d,m],u,te((()=>!1===r?null:q(p,{offset:m,limit:n,total:o,onChange:g})),[r,p,m,n,o,g])]},me=(e,t,l)=>te((()=>{const a=t??e;return D(L(Array.isArray(a)?D(A(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:l,...(a=e,C(a)==x?{label:e}:e)}];var a})))}),[t,l,e]),he=({className:e,headerRow:t,idColumn:l,params:[a,n,o,r,i,s]})=>q("table",{className:e},s?q("caption",null,s):null,!1===t?null:q("thead",null,q("tr",null,!1===l?null:q(ce,{sort:r??[],label:"Id",onClick:i}),L(a,(({label:e},t)=>q(ce,{key:t,cellId:t,label:e,sort:r??[],onClick:i}))))),q("tbody",null,A(o,(e=>q("tr",{key:e},!1===l?null:q("th",null,e),L(a,(({component:t,getComponentProps:l},a)=>q("td",{key:a},q(t,{...j(l,e,a),...n,rowId:e,cellId:a}))))))))),ce=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>q("th",{onClick:oe((()=>n?.(e)),[n,e],n),className:S(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},S(l)||t!=e?null:(l?"↓":"↑")+" ",a),ue=({localRowId:t,params:[l,a,n,o,r,i,s]})=>{const d=y(r,t,i);return q("tr",null,!1===l?null:q(e.Fragment,null,q("th",null,t),q("th",null,d)),L(a,(({component:e,getComponentProps:l},a)=>{const[r,i]=a.split(".",2),m=r===n?t:r===o?d:null;return S(m)?null:q("td",{key:a},q(e,{...j(l,m,i),store:s,tableId:r,rowId:m,cellId:i}))})))},ge=({thing:e,onThingChange:t,className:l,hasSchema:a,showType:n=!0})=>{const[o,r]=le(),[i,s]=le(),[d,m]=le(),[h,c]=le(),[u,g]=le();i!==e&&(r((e=>{const t=C(e);return(e=>e==x||e==I)(t)||t==N&&$(e)?t:void 0})(e)),s(e),m(e+""),c(Number(e)||0),g(!!e));const p=ee(((e,l)=>{l(e),s(e),t(e)}),[t]),b=ee((()=>{if(!a?.()){const e=_(o,N,I,x),l=_(e,d,h,u);r(e),s(l),t(l)}}),[a,t,d,h,u,o]);return q("div",{className:l},n?q("button",{className:o,onClick:b},o):null,_(o,q("input",{key:o,value:d,onChange:ee((e=>p(e[T][M]+"",m)),[p])}),q("input",{key:o,type:"number",value:h,onChange:ee((e=>p(Number(e[T][M]||0),c)),[p])}),q("input",{key:o,type:"checkbox",checked:u,onChange:ee((e=>p(!!e[T].checked,g)),[p])})))},pe=({tableId:e,store:a,editable:n,customCells:o,...r})=>q(he,{...r,params:re(me(l(e,a),o,n?Ce:k),ie(a,e),t(e,a))}),be=({tableId:e,cellId:t,descending:o,offset:r,limit:i,store:s,editable:d,sortOnClick:m,paginator:h=!1,onChange:c,customCells:u,...g})=>{const[p,b,f]=de(t,o,m,r,i,a(e,s),h,c);return q(he,{...g,params:re(me(l(e,s),u,d?Ce:k),ie(s,e),n(e,...p,i,s),p,b,f)})},fe=({store:e,editable:t=!1,valueComponent:l=(t?xe:r),getValueComponentProps:a,className:n,headerRow:i,idColumn:s})=>q("table",{className:n},!1===i?null:q("thead",null,q("tr",null,!1===s?null:q("th",null,"Id"),q("th",null,z))),q("tbody",null,A(o(e),(t=>q("tr",{key:t},!1===s?null:q("th",null,t),q("td",null,q(l,{...j(a,t),valueId:t,store:e}))))))),we=({indexId:e,sliceId:t,indexes:a,editable:n,customCells:o,...r})=>{const[d,m,h]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(i(a),e);return q(he,{...r,params:re(me(l(h,m),o,n?Ce:k),ie(m,h),s(e,t,d))})},ye=({relationshipId:l,relationships:a,editable:n,customCells:o,className:r,headerRow:i,idColumn:s=!0})=>{const[m,h,c,u]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(d(a),l),g=me([...ne(c,h),...ne(u,h)],o,n?Ce:k),p=re(s,g,c,u,l,m,h);return q("table",{className:r},!1===i?null:q("thead",null,q("tr",null,!1===s?null:q(e.Fragment,null,q("th",null,c,".Id"),q("th",null,u,".Id")),L(g,(({label:e},t)=>q("th",{key:t},e))))),q("tbody",null,A(t(c,h),(e=>q(ue,{key:e,localRowId:e,params:p})))))},ke=({queryId:e,queries:t,customCells:l,...a})=>q(he,{...a,params:re(me(h(e,t),l,v),se(t,e),m(e,t))}),ve=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:o,sortOnClick:r,paginator:i=!1,customCells:s,onChange:d,...m})=>{const[g,p,b]=de(t,l,r,a,n,c(e,o),i,d);return q(he,{...m,params:re(me(h(e,o),s,v),se(o,e),u(e,...g,n,o),g,p,b)})},Ce=({tableId:e,rowId:t,cellId:l,store:a,className:n,showType:o})=>q(ge,{thing:g(e,t,l,a),onThingChange:p(e,t,l,(e=>e),[],a),className:n??ae+"Cell",showType:o,hasSchema:b(a)?.hasTablesSchema}),xe=({valueId:e,store:t,className:l,showType:a})=>q(ge,{thing:f(e,t),onThingChange:w(e,(e=>e),[],t),className:l??ae+z,showType:a,hasSchema:b(t)?.hasValuesSchema}),Ie=({onChange:t,total:l,offset:a=0,limit:n=l,singular:o="row",plural:r=o+"s"})=>{(a>l||a<0)&&(a=0,t(0));const i=oe((()=>t(a-n)),[t,a,n],a>0),s=oe((()=>t(a+n)),[t,a,n],a+n<l);return q(e.Fragment,null,l>n&&q(e.Fragment,null,q("button",{className:"previous",disabled:0==a,onClick:i},"←"),q("button",{className:"next",disabled:a+n>=l,onClick:s},"→"),a+1," to ",Math.min(l,a+n)," of "),l," ",1!=l?r:o)};class Ne extends F{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?q("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const ze=e=>new Map(e);ze(),ze();const Te=e=>null;export{Ce as EditableCellView,xe as EditableValueView,ye as RelationshipInHtmlTable,ve as ResultSortedTableInHtmlTable,ke as ResultTableInHtmlTable,we as SliceInHtmlTable,be as SortedTableInHtmlTable,Ie as SortedTablePaginator,Te as StoreInspector,pe as TableInHtmlTable,fe as ValuesInHtmlTable};
1
+ import e from"react";import{useRowIds as t,useTableCellIds as l,useRowCount as a,useSortedRowIds as n,useValueIds as o,ValueView as r,useIndexesOrIndexesById as i,useSliceRowIds as s,useRelationshipsOrRelationshipsById as d,useResultRowIds as m,useResultTableCellIds as h,useResultRowCount as u,useResultSortedRowIds as c,useCell as g,useSetCellCallback as p,useStoreOrStoreById as b,useValue as f,useSetValueCallback as w,useRemoteRowId as y,CellView as k,ResultCellView as v}from"./ui-react";const C=e=>typeof e,x=C(""),I=C(!0),N=C(0),z="Value",$="currentTarget",T="value",M=isFinite,S=e=>null==e,{PureComponent:R,Fragment:q,createElement:F,useCallback:P,useLayoutEffect:E,useRef:O,useState:V}=e,j=(e,...t)=>S(e)?{}:e(...t),A=(e,t)=>e.map(t),B=Object,L=(e=[])=>B.fromEntries(e),D=(e,t)=>A(B.entries(e),(([e,l])=>t(l,e))),G="tinybaseStoreInspector",H="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",J='content:url("',K=J+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Q='</svg>")',U=J+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",W=A([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>K+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+Q)),X=K+"<path d='M20 20l60 60M20 80l60-60' />"+Q,Y=K+`<path d='${H}' />`+Q,Z=K+`<path d='${H}M20 20l60 60' />`+Q,_="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(D({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[_]:"width:0.5rem;height:0.5rem;",[_+"-track"]:"background:#111",[_+"-thumb"]:"background:#999;border:1px solid #111",[_+"-thumb:hover"]:"background:#fff",[_+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+U,...L(A(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...L(A(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":U,"header>img:nth-of-type(6)":X,...L(A(W,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Y,"details[open]>summary img.done":Z,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${G} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${G} ${t}{${e}}`:"")));const ee=(e,t,l,a)=>e==x?t:e==N?l:a,{useCallback:te,useMemo:le,useState:ae}=e,ne="editable",oe=(e,t)=>A(l(e,t),(t=>e+"."+t)),re=(e,t,l)=>{const a=te(e,t);return l?a:void 0},ie=(...e)=>le((()=>e),e),se=(e,t)=>le((()=>({store:e,tableId:t})),[e,t]),de=(e,t)=>le((()=>({queries:e,queryId:t})),[e,t]),me=(e,t=!1,l,a=0,n,o,r,i)=>{const[[s,d,m],h]=ae([e,t,a]),u=te((e=>{h(e),i?.(e)}),[i]),c=re((e=>u([e,e==s&&!d,m])),[u,s,d,m],l),g=te((e=>u([s,d,e])),[u,s,d]),p=!0===r?Ne:r;return[[s,d,m],c,le((()=>!1===r?null:F(p,{offset:m,limit:n,total:o,onChange:g})),[r,p,m,n,o,g])]},he=(e,t,l)=>le((()=>{const a=t??e;return L(D(Array.isArray(a)?L(A(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:l,...(a=e,C(a)==x?{label:e}:e)}];var a})))}),[t,l,e]),ue=({className:e,headerRow:t,idColumn:l,params:[a,n,o,r,i,s]})=>F("table",{className:e},s?F("caption",null,s):null,!1===t?null:F("thead",null,F("tr",null,!1===l?null:F(ce,{sort:r??[],label:"Id",onClick:i}),D(a,(({label:e},t)=>F(ce,{key:t,cellId:t,label:e,sort:r??[],onClick:i}))))),F("tbody",null,A(o,(e=>F("tr",{key:e},!1===l?null:F("th",null,e),D(a,(({component:t,getComponentProps:l},a)=>F("td",{key:a},F(t,{...j(l,e,a),...n,rowId:e,cellId:a}))))))))),ce=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>F("th",{onClick:re((()=>n?.(e)),[n,e],n),className:S(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},S(l)||t!=e?null:(l?"↓":"↑")+" ",a),ge=({localRowId:t,params:[l,a,n,o,r,i,s]})=>{const d=y(r,t,i);return F("tr",null,!1===l?null:F(e.Fragment,null,F("th",null,t),F("th",null,d)),D(a,(({component:e,getComponentProps:l},a)=>{const[r,i]=a.split(".",2),m=r===n?t:r===o?d:null;return S(m)?null:F("td",{key:a},F(e,{...j(l,m,i),store:s,tableId:r,rowId:m,cellId:i}))})))},pe=({thing:e,onThingChange:t,className:l,hasSchema:a,showType:n=!0})=>{const[o,r]=ae(),[i,s]=ae(),[d,m]=ae(),[h,u]=ae(),[c,g]=ae();i!==e&&(r((e=>{const t=C(e);return(e=>e==x||e==I)(t)||t==N&&M(e)?t:void 0})(e)),s(e),m(e+""),u(Number(e)||0),g(!!e));const p=te(((e,l)=>{l(e),s(e),t(e)}),[t]),b=te((()=>{if(!a?.()){const e=ee(o,N,I,x),l=ee(e,d,h,c);r(e),s(l),t(l)}}),[a,t,d,h,c,o]);return F("div",{className:l},n?F("button",{className:o,onClick:b},o):null,ee(o,F("input",{key:o,value:d,onChange:te((e=>p(e[$][T]+"",m)),[p])}),F("input",{key:o,type:"number",value:h,onChange:te((e=>p(Number(e[$][T]||0),u)),[p])}),F("input",{key:o,type:"checkbox",checked:c,onChange:te((e=>p(!!e[$].checked,g)),[p])})))},be=({tableId:e,store:a,editable:n,customCells:o,...r})=>F(ue,{...r,params:ie(he(l(e,a),o,n?xe:k),se(a,e),t(e,a))}),fe=({tableId:e,cellId:t,descending:o,offset:r,limit:i,store:s,editable:d,sortOnClick:m,paginator:h=!1,onChange:u,customCells:c,...g})=>{const[p,b,f]=me(t,o,m,r,i,a(e,s),h,u);return F(ue,{...g,params:ie(he(l(e,s),c,d?xe:k),se(s,e),n(e,...p,i,s),p,b,f)})},we=({store:e,editable:t=!1,valueComponent:l=(t?Ie:r),getValueComponentProps:a,className:n,headerRow:i,idColumn:s})=>F("table",{className:n},!1===i?null:F("thead",null,F("tr",null,!1===s?null:F("th",null,"Id"),F("th",null,z))),F("tbody",null,A(o(e),(t=>F("tr",{key:t},!1===s?null:F("th",null,t),F("td",null,F(l,{...j(a,t),valueId:t,store:e}))))))),ye=({indexId:e,sliceId:t,indexes:a,editable:n,customCells:o,...r})=>{const[d,m,h]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(i(a),e);return F(ue,{...r,params:ie(he(l(h,m),o,n?xe:k),se(m,h),s(e,t,d))})},ke=({relationshipId:l,relationships:a,editable:n,customCells:o,className:r,headerRow:i,idColumn:s=!0})=>{const[m,h,u,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(d(a),l),g=he([...oe(u,h),...oe(c,h)],o,n?xe:k),p=ie(s,g,u,c,l,m,h);return F("table",{className:r},!1===i?null:F("thead",null,F("tr",null,!1===s?null:F(e.Fragment,null,F("th",null,u,".Id"),F("th",null,c,".Id")),D(g,(({label:e},t)=>F("th",{key:t},e))))),F("tbody",null,A(t(u,h),(e=>F(ge,{key:e,localRowId:e,params:p})))))},ve=({queryId:e,queries:t,customCells:l,...a})=>F(ue,{...a,params:ie(he(h(e,t),l,v),de(t,e),m(e,t))}),Ce=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:o,sortOnClick:r,paginator:i=!1,customCells:s,onChange:d,...m})=>{const[g,p,b]=me(t,l,r,a,n,u(e,o),i,d);return F(ue,{...m,params:ie(he(h(e,o),s,v),de(o,e),c(e,...g,n,o),g,p,b)})},xe=({tableId:e,rowId:t,cellId:l,store:a,className:n,showType:o})=>F(pe,{thing:g(e,t,l,a),onThingChange:p(e,t,l,(e=>e),[],a),className:n??ne+"Cell",showType:o,hasSchema:b(a)?.hasTablesSchema}),Ie=({valueId:e,store:t,className:l,showType:a})=>F(pe,{thing:f(e,t),onThingChange:w(e,(e=>e),[],t),className:l??ne+z,showType:a,hasSchema:b(t)?.hasValuesSchema}),Ne=({onChange:t,total:l,offset:a=0,limit:n=l,singular:o="row",plural:r=o+"s"})=>{(a>l||a<0)&&(a=0,t(0));const i=re((()=>t(a-n)),[t,a,n],a>0),s=re((()=>t(a+n)),[t,a,n],a+n<l);return F(e.Fragment,null,l>n&&F(e.Fragment,null,F("button",{className:"previous",disabled:0==a,onClick:i},"←"),F("button",{className:"next",disabled:a+n>=l,onClick:s},"→"),a+1," to ",Math.min(l,a+n)," of "),l," ",1!=l?r:o)},ze=e=>new Map(e);ze(),ze();const $e=e=>null;export{xe as EditableCellView,Ie as EditableValueView,ke as RelationshipInHtmlTable,Ce as ResultSortedTableInHtmlTable,ve as ResultTableInHtmlTable,ye as SliceInHtmlTable,fe as SortedTableInHtmlTable,Ne as SortedTablePaginator,$e as StoreInspector,be as TableInHtmlTable,we as ValuesInHtmlTable};
Binary file
package/lib/ui-react.js CHANGED
@@ -1 +1 @@
1
- import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Listener",n="Result",I="Ids",i="Table",u=i+"s",l=i+I,c="Row",a=c+"Count",p=c+I,g="Sorted"+c+I,b="Cell",C=b+I,m="Value",k=m+"s",w=m+I,y=e=>null==e,h=(e,t,o)=>y(e)?o?.():t(e),R=e=>o(e)==r,v=()=>{},q=(e,t)=>e.map(t),P=Object.keys,{createContext:f,useContext:x}=e,S=f([]),L=(e,t)=>{const o=x(S);return y(e)?o[t]:R(e)?((e,t)=>h(e,(e=>e[t])))(o[t+1]??{},e):e},B=(e,t)=>{const o=L(e,t);return y(e)||R(e)?o:e},T=e=>P(x(S)[e]??{}),M=e=>L(e,0),F=e=>B(e,0),E=e=>L(e,2),V=e=>B(e,2),A=e=>L(e,4),j=e=>B(e,4),D=e=>L(e,6),O=e=>B(e,6),Q=e=>L(e,8),W=e=>B(e,8),z=e=>L(e,10),G=e=>B(e,10),H=e=>e.toLowerCase();H(d);const J="Transaction";H(J);const{useCallback:K,useEffect:N,useMemo:U,useRef:X,useState:Y}=e,Z=(e,t,o=[])=>{const s=U((()=>t(e)),[e,...o]);return N((()=>()=>s.destroy()),[s]),s},$=(e,t,o,s=[],r)=>{const[,d]=Y(),n=K((()=>t?.["get"+e]?.(...s)??o),[t,...s]),[I]=Y(n),i=X(I);return U((()=>i.current=n()),[n]),_(e,t,((...e)=>{i.current=y(r)?n():e[r],d([])}),[],s),i.current},_=(e,t,o,s=[],r=[],...n)=>N((()=>{const s=t?.["add"+e+d]?.(...r,o,...n);return()=>t?.delListener(s)}),[t,...r,...s,...n]),ee=(e,t,o,s=[],r=v,d=[],...n)=>{const I=F(e);return K((e=>h(I,(s=>h(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[I,t,...s,...d,...n])},te=(e,t,o=v,s=[],...r)=>{const d=F(e);return K((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},oe=(e,t,o)=>{const s=G(e);return K((()=>s?.[t](o)),[s,t,o])},se=(e,t=[])=>U(e,t),re=()=>T(1),de=e=>$(u,F(e),{}),ne=e=>$(l,F(e),[],[]),Ie=(e,t)=>$(i,F(t),{},[e]),ie=(e,t)=>$(i+C,F(t),[],[e]),ue=(e,t)=>$(a,F(t),[],[e]),le=(e,t)=>$(p,F(t),[],[e]),ce=(e,t,o,s=0,r,d)=>$(g,F(d),[],[e,t,o,s,r],6),ae=(e,t,o)=>$(c,F(o),{},[e,t]),pe=(e,t,o)=>$(C,F(o),[],[e,t]),ge=(e,t,o,s)=>$(b,F(s),void 0,[e,t,o],4),be=e=>$(k,F(e),{}),Ce=e=>$(w,F(e),[],[]),me=(e,t)=>$(m,F(t),void 0,[e]),ke=(e,t,o,s,r)=>ee(o,u,e,t,s,r),we=(e,t,o,s,r,d)=>ee(s,i,t,o,r,d,e),ye=(e,t,o,s,r,d,n)=>ee(r,c,o,s,d,n,e,t),he=(e,t,o=[],s,r=v,d=[],n=!0)=>{const I=F(s);return K((o=>h(I,(s=>h(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[I,e,...o,...d,n])},Re=(e,t,o,s,r,d,n)=>ee(r,"PartialRow",o,s,d,n,e,t),ve=(e,t,o,s,r,d,n,I)=>ee(d,b,s,r,n,I,e,t,o),qe=(e,t,o,s,r)=>ee(o,k,e,t,s,r),Pe=(e,t,o,s,r)=>ee(o,"PartialValues",e,t,s,r),fe=(e,t,o,s,r,d)=>ee(s,m,t,o,r,d,e),xe=(e,t,o)=>te(e,u,t,o),Se=(e,t,o,s)=>te(t,i,o,s,e),Le=(e,t,o,s,r)=>te(o,c,s,r,e,t),Be=(e,t,o,s,r,d,n)=>te(r,b,d,n,e,t,o,s),Te=(e,t,o)=>te(e,k,t,o),Me=(e,t,o,s)=>te(t,m,o,s,e),Fe=(e,t,o,s)=>_(u,F(s),e,t,[],o),Ee=(e,t,o,s)=>_(l,F(s),e,t,[],o),Ve=(e,t,o,s,r)=>_(i,F(r),t,o,[e],s),Ae=(e,t,o,s,r)=>_(i+C,F(r),t,o,[e],s),je=(e,t,o,s,r)=>_(a,F(r),t,o,[e],s),De=(e,t,o,s,r)=>_(p,F(r),t,o,[e],s),Oe=(e,t,o,s,r,d,n,I,i)=>_(g,F(i),d,n,[e,t,o,s,r],I),Qe=(e,t,o,s,r,d)=>_(c,F(d),o,s,[e,t],r),We=(e,t,o,s,r,d)=>_(C,F(d),o,s,[e,t],r),ze=(e,t,o,s,r,d,n)=>_(b,F(n),s,r,[e,t,o],d),Ge=(e,t,o,s)=>_(k,F(s),e,t,[],o),He=(e,t,o,s)=>_(w,F(s),e,t,[],o),Je=(e,t,o,s,r)=>_(m,F(r),t,o,[e],s),Ke=(e,t,o)=>_("Start"+J,F(o),e,t),Ne=(e,t,o)=>_("WillFinish"+J,F(o),e,t),Ue=(e,t,o)=>_("DidFinish"+J,F(o),e,t),Xe=(e,t,o)=>Z(e,t,o),Ye=()=>T(3),Ze=e=>$("MetricIds",V(e),[]),$e=(e,t)=>$("Metric",V(t),void 0,[e]),_e=(e,t,o,s)=>_("Metric",V(s),t,o,[e]),et=(e,t,o)=>Z(e,t,o),tt=()=>T(5),ot=(e,t)=>$("SliceIds",j(t),[],[e]),st=e=>$("IndexIds",j(e),[]),rt=(e,t,o)=>$("Slice"+p,j(o),[],[e,t]),dt=(e,t,o,s)=>_("SliceIds",j(s),t,o,[e]),nt=(e,t,o,s,r)=>_("Slice"+p,j(r),o,s,[e,t]),It=(e,t,o)=>Z(e,t,o),it=()=>T(7),ut=e=>$("RelationshipIds",O(e),[]),lt=(e,t,o)=>$("RemoteRowId",O(o),void 0,[e,t]),ct=(e,t,o)=>$("Local"+p,O(o),[],[e,t]),at=(e,t,o)=>$("Linked"+p,O(o),[],[e,t]),pt=(e,t,o,s,r)=>_("RemoteRowId",O(r),o,s,[e,t]),gt=(e,t,o,s,r)=>_("Local"+p,O(r),o,s,[e,t]),bt=(e,t,o,s,r)=>_("Linked"+p,O(r),o,s,[e,t]),Ct=(e,t,o)=>Z(e,t,o),mt=()=>T(9),kt=e=>$("QueryIds",W(e),[]),wt=(e,t)=>$(n+i,W(t),{},[e]),yt=(e,t)=>$(n+i+C,W(t),[],[e]),ht=(e,t)=>$(n+a,W(t),[],[e]),Rt=(e,t)=>$(n+p,W(t),[],[e]),vt=(e,t,o,s=0,r,d)=>$(n+g,W(d),[],[e,t,o,s,r],6),qt=(e,t,o)=>$(n+c,W(o),{},[e,t]),Pt=(e,t,o)=>$(n+C,W(o),[],[e,t]),ft=(e,t,o,s)=>$(n+b,W(s),void 0,[e,t,o]),xt=(e,t,o,s)=>_(n+i,W(s),t,o,[e]),St=(e,t,o,s)=>_(n+i+C,W(s),t,o,[e]),Lt=(e,t,o,s)=>_(n+a,W(s),t,o,[e]),Bt=(e,t,o,s)=>_(n+p,W(s),t,o,[e]),Tt=(e,t,o,s,r,d,I,i)=>_(n+g,W(i),d,I,[e,t,o,s,r]),Mt=(e,t,o,s,r)=>_(n+c,W(r),o,s,[e,t]),Ft=(e,t,o,s,r)=>_(n+C,W(r),o,s,[e,t]),Et=(e,t,o,s,r,d)=>_(n+b,W(d),s,r,[e,t,o]),Vt=(e,t,o)=>Z(e,t,o),At=()=>T(11),jt=e=>$("CheckpointIds",G(e),[[],void 0,[]]),Dt=(e,t)=>$("Checkpoint",G(t),void 0,[e]),Ot=(e=v,t=[],o,s=v,r=[])=>{const d=G(o);return K((t=>h(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Qt=e=>oe(e,"goBackward"),Wt=e=>oe(e,"goForward"),zt=(e,t=[],o,s=v,r=[])=>{const d=G(o);return K((t=>h(d,(o=>h(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},Gt=e=>{const t=G(e),[o,r]=jt(t);return[(d=o,!(0==d.length)),Qt(t),r,h(r,(e=>t?.getCheckpoint(e)))??s];var d},Ht=e=>{const t=G(e),[,,[o]]=jt(t);return[!y(o),Wt(t),o,h(o,(e=>t?.getCheckpoint(e)))??s]},Jt=(e,t,o)=>_("CheckpointIds",G(o),e,t),Kt=(e,t,o,s)=>_("Checkpoint",G(s),t,o,[e]),Nt=(e,t,o=[],s,r=[])=>{const[,d]=Y(),n=U((()=>t(e)),[e,...o]);return N((()=>((async()=>{await(s?.(n)),d(1)})(),()=>{n?.destroy()})),[n,...r]),n},{PureComponent:Ut,Fragment:Xt,createElement:Yt,useCallback:Zt,useLayoutEffect:$t,useRef:_t,useState:eo}=e,to=(e,...t)=>y(e)?{}:e(...t),oo=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:so}=e,ro=({tableId:e,store:t,rowComponent:o=ao,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},I)=>lo(q(I,(d=>Yt(o,{...to(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),no=({queryId:e,queries:t,resultRowComponent:o=Po,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>lo(q(n,(r=>Yt(o,{...to(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Io=({relationshipId:e,relationships:t,rowComponent:o=ao,getRowComponentProps:s,separator:r,debugIds:d},n,I)=>{const[i,u,l]=oo(O(t),e),c=n(e,I,i);return lo(q(c,(e=>Yt(o,{...to(s,e),key:e,tableId:l,rowId:e,store:u,debugIds:d}))),r,d,I)},io=e=>({checkpoints:t,checkpointComponent:o=So,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=G(t);return lo(q(e(jt(n)),(e=>Yt(o,{...to(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},uo=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:I,relationshipsById:i,queries:u,queriesById:l,checkpoints:c,checkpointsById:a,children:p})=>{const g=t(S);return Yt(S.Provider,{value:so((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},I??g[6],{...g[7],...i},u??g[8],{...g[9],...l},c??g[10],{...g[11],...a}]),[e,o,s,r,d,n,I,i,u,l,c,a,g])},p)},lo=(e,t,o,s)=>{const r=y(t)||!Array.isArray(e)?e:q(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},co=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>lo(s+(ge(e,t,o,r)??s),void 0,d,o),ao=({tableId:e,rowId:t,store:o,cellComponent:s=co,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:I})=>lo(q(((e,t,o,s)=>{const r=pe(t,o,s);return e??r})(d,e,t,o),(d=>Yt(s,{...to(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:I}))),n,I,t),po=e=>ro(e,le(e.tableId,e.store)),go=({cellId:e,descending:t,offset:o,limit:s,...r})=>ro(r,ce(r.tableId,e,t,o,s,r.store)),bo=({store:e,tableComponent:t=po,getTableComponentProps:o,separator:s,debugIds:r})=>lo(q(ne(e),(s=>Yt(t,{...to(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Co=({valueId:e,store:t,debugIds:o})=>lo(s+(me(e,t)??s),void 0,o,e),mo=({store:e,valueComponent:t=Co,getValueComponentProps:o,separator:s,debugIds:r})=>lo(q(Ce(e),(s=>Yt(t,{...to(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ko=({metricId:e,metrics:t,debugIds:o})=>lo($e(e,t)??s,void 0,o,e),wo=({indexId:e,sliceId:t,indexes:o,rowComponent:s=ao,getRowComponentProps:r,separator:d,debugIds:n})=>{const[I,i,u]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(j(o),e),l=rt(e,t,I);return lo(q(l,(e=>Yt(s,{...to(r,e),key:e,tableId:u,rowId:e,store:i,debugIds:n}))),d,n,t)},yo=({indexId:e,indexes:t,sliceComponent:o=wo,getSliceComponentProps:s,separator:r,debugIds:d})=>lo(q(ot(e,t),(r=>Yt(o,{...to(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),ho=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=ao,getRowComponentProps:r,debugIds:d})=>{const[n,I,,i]=oo(O(o),e),u=lt(e,t,n);return lo(y(i)||y(u)?null:Yt(s,{...to(r,u),key:u,tableId:i,rowId:u,store:I,debugIds:d}),void 0,d,t)},Ro=e=>Io(e,ct,e.remoteRowId),vo=e=>Io(e,at,e.firstRowId),qo=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>lo(s+(ft(e,t,o,r)??s),void 0,d,o),Po=({queryId:e,rowId:t,queries:o,resultCellComponent:s=qo,getResultCellComponentProps:r,separator:d,debugIds:n})=>lo(q(Pt(e,t,o),(d=>Yt(s,{...to(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),fo=e=>no(e,Rt(e.queryId,e.queries)),xo=({cellId:e,descending:t,offset:o,limit:s,...r})=>no(r,vt(r.queryId,e,t,o,s,r.queries)),So=({checkpoints:e,checkpointId:t,debugIds:o})=>lo(Dt(t,e)??s,void 0,o,t),Lo=io((e=>e[0])),Bo=io((e=>y(e[1])?[]:[e[1]])),To=io((e=>e[2]));export{Lo as BackwardCheckpointsView,co as CellView,So as CheckpointView,Bo as CurrentCheckpointView,To as ForwardCheckpointsView,yo as IndexView,vo as LinkedRowsView,Ro as LocalRowsView,ko as MetricView,uo as Provider,ho as RemoteRowView,qo as ResultCellView,Po as ResultRowView,xo as ResultSortedTableView,fo as ResultTableView,ao as RowView,wo as SliceView,go as SortedTableView,po as TableView,bo as TablesView,Co as ValueView,mo as ValuesView,he as useAddRowCallback,ge as useCell,pe as useCellIds,We as useCellIdsListener,ze as useCellListener,Dt as useCheckpoint,jt as useCheckpointIds,Jt as useCheckpointIdsListener,Kt as useCheckpointListener,z as useCheckpoints,At as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Vt as useCreateCheckpoints,et as useCreateIndexes,Xe as useCreateMetrics,Nt as useCreatePersister,Ct as useCreateQueries,It as useCreateRelationships,se as useCreateStore,Be as useDelCellCallback,Le as useDelRowCallback,Se as useDelTableCallback,xe as useDelTablesCallback,Me as useDelValueCallback,Te as useDelValuesCallback,Ue as useDidFinishTransactionListener,Qt as useGoBackwardCallback,Wt as useGoForwardCallback,zt as useGoToCallback,st as useIndexIds,A as useIndexes,tt as useIndexesIds,j as useIndexesOrIndexesById,at as useLinkedRowIds,bt as useLinkedRowIdsListener,ct as useLocalRowIds,gt as useLocalRowIdsListener,$e as useMetric,Ze as useMetricIds,_e as useMetricListener,E as useMetrics,Ye as useMetricsIds,V as useMetricsOrMetricsById,Q as useQueries,mt as useQueriesIds,W as useQueriesOrQueriesById,kt as useQueryIds,Ht as useRedoInformation,ut as useRelationshipIds,D as useRelationships,it as useRelationshipsIds,O as useRelationshipsOrRelationshipsById,lt as useRemoteRowId,pt as useRemoteRowIdListener,ft as useResultCell,Pt as useResultCellIds,Ft as useResultCellIdsListener,Et as useResultCellListener,qt as useResultRow,ht as useResultRowCount,Lt as useResultRowCountListener,Rt as useResultRowIds,Bt as useResultRowIdsListener,Mt as useResultRowListener,vt as useResultSortedRowIds,Tt as useResultSortedRowIdsListener,wt as useResultTable,yt as useResultTableCellIds,St as useResultTableCellIdsListener,xt as useResultTableListener,ae as useRow,ue as useRowCount,je as useRowCountListener,le as useRowIds,De as useRowIdsListener,Qe as useRowListener,ve as useSetCellCallback,Ot as useSetCheckpointCallback,Re as useSetPartialRowCallback,Pe as useSetPartialValuesCallback,ye as useSetRowCallback,we as useSetTableCallback,ke as useSetTablesCallback,fe as useSetValueCallback,qe as useSetValuesCallback,ot as useSliceIds,dt as useSliceIdsListener,rt as useSliceRowIds,nt as useSliceRowIdsListener,ce as useSortedRowIds,Oe as useSortedRowIdsListener,Ke as useStartTransactionListener,M as useStore,re as useStoreIds,F as useStoreOrStoreById,Ie as useTable,ie as useTableCellIds,Ae as useTableCellIdsListener,ne as useTableIds,Ee as useTableIdsListener,Ve as useTableListener,de as useTables,Fe as useTablesListener,Gt as useUndoInformation,me as useValue,Ce as useValueIds,He as useValueIdsListener,Je as useValueListener,be as useValues,Ge as useValuesListener,Ne as useWillFinishTransactionListener};
1
+ import e,{useContext as t}from"react";const o=e=>typeof e,s="",r=o(s),d="Listener",n="Result",I="Ids",i="Table",u=i+"s",l=i+I,c="Row",a=c+"Count",p=c+I,g="Sorted"+c+I,b="Cell",C=b+I,m="Value",k=m+"s",w=m+I,y=e=>null==e,h=(e,t,o)=>y(e)?o?.():t(e),R=e=>o(e)==r,v=()=>{},q=(e,t)=>e.map(t),P=Object.keys,{createContext:f,useContext:x}=e,S=f([]),L=(e,t)=>{const o=x(S);return y(e)?o[t]:R(e)?((e,t)=>h(e,(e=>e[t])))(o[t+1]??{},e):e},B=(e,t)=>{const o=L(e,t);return y(e)||R(e)?o:e},T=e=>P(x(S)[e]??{}),M=e=>L(e,0),F=e=>B(e,0),E=e=>L(e,2),V=e=>B(e,2),A=e=>L(e,4),j=e=>B(e,4),D=e=>L(e,6),O=e=>B(e,6),Q=e=>L(e,8),W=e=>B(e,8),z=e=>L(e,10),G=e=>B(e,10),H=e=>e.toLowerCase();H(d);const J="Transaction";H(J);const{useCallback:K,useEffect:N,useMemo:U,useRef:X,useState:Y}=e,Z=(e,t,o=[])=>{const s=U((()=>t(e)),[e,...o]);return N((()=>()=>s.destroy()),[s]),s},$=(e,t,o,s=[],r)=>{const[,d]=Y(),n=K((()=>t?.["get"+e]?.(...s)??o),[t,...s]),[I]=Y(n),i=X(I);return U((()=>i.current=n()),[n]),_(e,t,((...e)=>{i.current=y(r)?n():e[r],d([])}),[],s),i.current},_=(e,t,o,s=[],r=[],...n)=>N((()=>{const s=t?.["add"+e+d]?.(...r,o,...n);return()=>t?.delListener(s)}),[t,...r,...s,...n]),ee=(e,t,o,s=[],r=v,d=[],...n)=>{const I=F(e);return K((e=>h(I,(s=>h(o(e,s),(e=>r(s["set"+t](...n,e),e)))))),[I,t,...s,...d,...n])},te=(e,t,o=v,s=[],...r)=>{const d=F(e);return K((()=>o(d?.["del"+t](...r))),[d,t,...s,...r])},oe=(e,t,o)=>{const s=G(e);return K((()=>s?.[t](o)),[s,t,o])},se=(e,t=[])=>U(e,t),re=()=>T(1),de=e=>$(u,F(e),{}),ne=e=>$(l,F(e),[],[]),Ie=(e,t)=>$(i,F(t),{},[e]),ie=(e,t)=>$(i+C,F(t),[],[e]),ue=(e,t)=>$(a,F(t),[],[e]),le=(e,t)=>$(p,F(t),[],[e]),ce=(e,t,o,s=0,r,d)=>$(g,F(d),[],[e,t,o,s,r],6),ae=(e,t,o)=>$(c,F(o),{},[e,t]),pe=(e,t,o)=>$(C,F(o),[],[e,t]),ge=(e,t,o,s)=>$(b,F(s),void 0,[e,t,o],4),be=e=>$(k,F(e),{}),Ce=e=>$(w,F(e),[],[]),me=(e,t)=>$(m,F(t),void 0,[e]),ke=(e,t,o,s,r)=>ee(o,u,e,t,s,r),we=(e,t,o,s,r,d)=>ee(s,i,t,o,r,d,e),ye=(e,t,o,s,r,d,n)=>ee(r,c,o,s,d,n,e,t),he=(e,t,o=[],s,r=v,d=[],n=!0)=>{const I=F(s);return K((o=>h(I,(s=>h(t(o,s),(t=>r(s.addRow(e,t,n),s,t)))))),[I,e,...o,...d,n])},Re=(e,t,o,s,r,d,n)=>ee(r,"PartialRow",o,s,d,n,e,t),ve=(e,t,o,s,r,d,n,I)=>ee(d,b,s,r,n,I,e,t,o),qe=(e,t,o,s,r)=>ee(o,k,e,t,s,r),Pe=(e,t,o,s,r)=>ee(o,"PartialValues",e,t,s,r),fe=(e,t,o,s,r,d)=>ee(s,m,t,o,r,d,e),xe=(e,t,o)=>te(e,u,t,o),Se=(e,t,o,s)=>te(t,i,o,s,e),Le=(e,t,o,s,r)=>te(o,c,s,r,e,t),Be=(e,t,o,s,r,d,n)=>te(r,b,d,n,e,t,o,s),Te=(e,t,o)=>te(e,k,t,o),Me=(e,t,o,s)=>te(t,m,o,s,e),Fe=(e,t,o,s)=>_(u,F(s),e,t,[],o),Ee=(e,t,o,s)=>_(l,F(s),e,t,[],o),Ve=(e,t,o,s,r)=>_(i,F(r),t,o,[e],s),Ae=(e,t,o,s,r)=>_(i+C,F(r),t,o,[e],s),je=(e,t,o,s,r)=>_(a,F(r),t,o,[e],s),De=(e,t,o,s,r)=>_(p,F(r),t,o,[e],s),Oe=(e,t,o,s,r,d,n,I,i)=>_(g,F(i),d,n,[e,t,o,s,r],I),Qe=(e,t,o,s,r,d)=>_(c,F(d),o,s,[e,t],r),We=(e,t,o,s,r,d)=>_(C,F(d),o,s,[e,t],r),ze=(e,t,o,s,r,d,n)=>_(b,F(n),s,r,[e,t,o],d),Ge=(e,t,o,s)=>_(k,F(s),e,t,[],o),He=(e,t,o,s)=>_(w,F(s),e,t,[],o),Je=(e,t,o,s,r)=>_(m,F(r),t,o,[e],s),Ke=(e,t,o)=>_("Start"+J,F(o),e,t),Ne=(e,t,o)=>_("WillFinish"+J,F(o),e,t),Ue=(e,t,o)=>_("DidFinish"+J,F(o),e,t),Xe=(e,t,o)=>Z(e,t,o),Ye=()=>T(3),Ze=e=>$("MetricIds",V(e),[]),$e=(e,t)=>$("Metric",V(t),void 0,[e]),_e=(e,t,o,s)=>_("Metric",V(s),t,o,[e]),et=(e,t,o)=>Z(e,t,o),tt=()=>T(5),ot=(e,t)=>$("SliceIds",j(t),[],[e]),st=e=>$("IndexIds",j(e),[]),rt=(e,t,o)=>$("Slice"+p,j(o),[],[e,t]),dt=(e,t,o,s)=>_("SliceIds",j(s),t,o,[e]),nt=(e,t,o,s,r)=>_("Slice"+p,j(r),o,s,[e,t]),It=(e,t,o)=>Z(e,t,o),it=()=>T(7),ut=e=>$("RelationshipIds",O(e),[]),lt=(e,t,o)=>$("RemoteRowId",O(o),void 0,[e,t]),ct=(e,t,o)=>$("Local"+p,O(o),[],[e,t]),at=(e,t,o)=>$("Linked"+p,O(o),[],[e,t]),pt=(e,t,o,s,r)=>_("RemoteRowId",O(r),o,s,[e,t]),gt=(e,t,o,s,r)=>_("Local"+p,O(r),o,s,[e,t]),bt=(e,t,o,s,r)=>_("Linked"+p,O(r),o,s,[e,t]),Ct=(e,t,o)=>Z(e,t,o),mt=()=>T(9),kt=e=>$("QueryIds",W(e),[]),wt=(e,t)=>$(n+i,W(t),{},[e]),yt=(e,t)=>$(n+i+C,W(t),[],[e]),ht=(e,t)=>$(n+a,W(t),[],[e]),Rt=(e,t)=>$(n+p,W(t),[],[e]),vt=(e,t,o,s=0,r,d)=>$(n+g,W(d),[],[e,t,o,s,r],6),qt=(e,t,o)=>$(n+c,W(o),{},[e,t]),Pt=(e,t,o)=>$(n+C,W(o),[],[e,t]),ft=(e,t,o,s)=>$(n+b,W(s),void 0,[e,t,o]),xt=(e,t,o,s)=>_(n+i,W(s),t,o,[e]),St=(e,t,o,s)=>_(n+i+C,W(s),t,o,[e]),Lt=(e,t,o,s)=>_(n+a,W(s),t,o,[e]),Bt=(e,t,o,s)=>_(n+p,W(s),t,o,[e]),Tt=(e,t,o,s,r,d,I,i)=>_(n+g,W(i),d,I,[e,t,o,s,r]),Mt=(e,t,o,s,r)=>_(n+c,W(r),o,s,[e,t]),Ft=(e,t,o,s,r)=>_(n+C,W(r),o,s,[e,t]),Et=(e,t,o,s,r,d)=>_(n+b,W(d),s,r,[e,t,o]),Vt=(e,t,o)=>Z(e,t,o),At=()=>T(11),jt=e=>$("CheckpointIds",G(e),[[],void 0,[]]),Dt=(e,t)=>$("Checkpoint",G(t),void 0,[e]),Ot=(e=v,t=[],o,s=v,r=[])=>{const d=G(o);return K((t=>h(d,(o=>{const r=e(t);s(o.addCheckpoint(r),o,r)}))),[d,...t,...r])},Qt=e=>oe(e,"goBackward"),Wt=e=>oe(e,"goForward"),zt=(e,t=[],o,s=v,r=[])=>{const d=G(o);return K((t=>h(d,(o=>h(e(t),(e=>s(o.goTo(e),e)))))),[d,...t,...r])},Gt=e=>{const t=G(e),[o,r]=jt(t);return[(d=o,!(0==d.length)),Qt(t),r,h(r,(e=>t?.getCheckpoint(e)))??s];var d},Ht=e=>{const t=G(e),[,,[o]]=jt(t);return[!y(o),Wt(t),o,h(o,(e=>t?.getCheckpoint(e)))??s]},Jt=(e,t,o)=>_("CheckpointIds",G(o),e,t),Kt=(e,t,o,s)=>_("Checkpoint",G(s),t,o,[e]),Nt=(e,t,o=[],s,r=[],d,n=[])=>{const[,I]=Y(),i=U((()=>t(e)),[e,...o]);return N((()=>((async()=>{s&&(await s(i),I([]))})(),()=>{i?.destroy(),d?.(i)})),[i,...r,...n]),i},{PureComponent:Ut,Fragment:Xt,createElement:Yt,useCallback:Zt,useLayoutEffect:$t,useRef:_t,useState:eo}=e,to=(e,...t)=>y(e)?{}:e(...t),oo=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],{useMemo:so}=e,ro=({tableId:e,store:t,rowComponent:o=ao,getRowComponentProps:s,customCellIds:r,separator:d,debugIds:n},I)=>lo(q(I,(d=>Yt(o,{...to(s,d),key:d,tableId:e,rowId:d,customCellIds:r,store:t,debugIds:n}))),d,n,e),no=({queryId:e,queries:t,resultRowComponent:o=Po,getResultRowComponentProps:s,separator:r,debugIds:d},n)=>lo(q(n,(r=>Yt(o,{...to(s,r),key:r,queryId:e,rowId:r,queries:t,debugIds:d}))),r,d,e),Io=({relationshipId:e,relationships:t,rowComponent:o=ao,getRowComponentProps:s,separator:r,debugIds:d},n,I)=>{const[i,u,l]=oo(O(t),e),c=n(e,I,i);return lo(q(c,(e=>Yt(o,{...to(s,e),key:e,tableId:l,rowId:e,store:u,debugIds:d}))),r,d,I)},io=e=>({checkpoints:t,checkpointComponent:o=So,getCheckpointComponentProps:s,separator:r,debugIds:d})=>{const n=G(t);return lo(q(e(jt(n)),(e=>Yt(o,{...to(s,e),key:e,checkpoints:n,checkpointId:e,debugIds:d}))),r)},uo=({store:e,storesById:o,metrics:s,metricsById:r,indexes:d,indexesById:n,relationships:I,relationshipsById:i,queries:u,queriesById:l,checkpoints:c,checkpointsById:a,children:p})=>{const g=t(S);return Yt(S.Provider,{value:so((()=>[e??g[0],{...g[1],...o},s??g[2],{...g[3],...r},d??g[4],{...g[5],...n},I??g[6],{...g[7],...i},u??g[8],{...g[9],...l},c??g[10],{...g[11],...a}]),[e,o,s,r,d,n,I,i,u,l,c,a,g])},p)},lo=(e,t,o,s)=>{const r=y(t)||!Array.isArray(e)?e:q(e,((e,o)=>o>0?[t,e]:e));return o?[s,":{",r,"}"]:r},co=({tableId:e,rowId:t,cellId:o,store:r,debugIds:d})=>lo(s+(ge(e,t,o,r)??s),void 0,d,o),ao=({tableId:e,rowId:t,store:o,cellComponent:s=co,getCellComponentProps:r,customCellIds:d,separator:n,debugIds:I})=>lo(q(((e,t,o,s)=>{const r=pe(t,o,s);return e??r})(d,e,t,o),(d=>Yt(s,{...to(r,d),key:d,tableId:e,rowId:t,cellId:d,store:o,debugIds:I}))),n,I,t),po=e=>ro(e,le(e.tableId,e.store)),go=({cellId:e,descending:t,offset:o,limit:s,...r})=>ro(r,ce(r.tableId,e,t,o,s,r.store)),bo=({store:e,tableComponent:t=po,getTableComponentProps:o,separator:s,debugIds:r})=>lo(q(ne(e),(s=>Yt(t,{...to(o,s),key:s,tableId:s,store:e,debugIds:r}))),s),Co=({valueId:e,store:t,debugIds:o})=>lo(s+(me(e,t)??s),void 0,o,e),mo=({store:e,valueComponent:t=Co,getValueComponentProps:o,separator:s,debugIds:r})=>lo(q(Ce(e),(s=>Yt(t,{...to(o,s),key:s,valueId:s,store:e,debugIds:r}))),s),ko=({metricId:e,metrics:t,debugIds:o})=>lo($e(e,t)??s,void 0,o,e),wo=({indexId:e,sliceId:t,indexes:o,rowComponent:s=ao,getRowComponentProps:r,separator:d,debugIds:n})=>{const[I,i,u]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(j(o),e),l=rt(e,t,I);return lo(q(l,(e=>Yt(s,{...to(r,e),key:e,tableId:u,rowId:e,store:i,debugIds:n}))),d,n,t)},yo=({indexId:e,indexes:t,sliceComponent:o=wo,getSliceComponentProps:s,separator:r,debugIds:d})=>lo(q(ot(e,t),(r=>Yt(o,{...to(s,r),key:r,indexId:e,sliceId:r,indexes:t,debugIds:d}))),r,d,e),ho=({relationshipId:e,localRowId:t,relationships:o,rowComponent:s=ao,getRowComponentProps:r,debugIds:d})=>{const[n,I,,i]=oo(O(o),e),u=lt(e,t,n);return lo(y(i)||y(u)?null:Yt(s,{...to(r,u),key:u,tableId:i,rowId:u,store:I,debugIds:d}),void 0,d,t)},Ro=e=>Io(e,ct,e.remoteRowId),vo=e=>Io(e,at,e.firstRowId),qo=({queryId:e,rowId:t,cellId:o,queries:r,debugIds:d})=>lo(s+(ft(e,t,o,r)??s),void 0,d,o),Po=({queryId:e,rowId:t,queries:o,resultCellComponent:s=qo,getResultCellComponentProps:r,separator:d,debugIds:n})=>lo(q(Pt(e,t,o),(d=>Yt(s,{...to(r,d),key:d,queryId:e,rowId:t,cellId:d,queries:o,debugIds:n}))),d,n,t),fo=e=>no(e,Rt(e.queryId,e.queries)),xo=({cellId:e,descending:t,offset:o,limit:s,...r})=>no(r,vt(r.queryId,e,t,o,s,r.queries)),So=({checkpoints:e,checkpointId:t,debugIds:o})=>lo(Dt(t,e)??s,void 0,o,t),Lo=io((e=>e[0])),Bo=io((e=>y(e[1])?[]:[e[1]])),To=io((e=>e[2]));export{Lo as BackwardCheckpointsView,co as CellView,So as CheckpointView,Bo as CurrentCheckpointView,To as ForwardCheckpointsView,yo as IndexView,vo as LinkedRowsView,Ro as LocalRowsView,ko as MetricView,uo as Provider,ho as RemoteRowView,qo as ResultCellView,Po as ResultRowView,xo as ResultSortedTableView,fo as ResultTableView,ao as RowView,wo as SliceView,go as SortedTableView,po as TableView,bo as TablesView,Co as ValueView,mo as ValuesView,he as useAddRowCallback,ge as useCell,pe as useCellIds,We as useCellIdsListener,ze as useCellListener,Dt as useCheckpoint,jt as useCheckpointIds,Jt as useCheckpointIdsListener,Kt as useCheckpointListener,z as useCheckpoints,At as useCheckpointsIds,G as useCheckpointsOrCheckpointsById,Vt as useCreateCheckpoints,et as useCreateIndexes,Xe as useCreateMetrics,Nt as useCreatePersister,Ct as useCreateQueries,It as useCreateRelationships,se as useCreateStore,Be as useDelCellCallback,Le as useDelRowCallback,Se as useDelTableCallback,xe as useDelTablesCallback,Me as useDelValueCallback,Te as useDelValuesCallback,Ue as useDidFinishTransactionListener,Qt as useGoBackwardCallback,Wt as useGoForwardCallback,zt as useGoToCallback,st as useIndexIds,A as useIndexes,tt as useIndexesIds,j as useIndexesOrIndexesById,at as useLinkedRowIds,bt as useLinkedRowIdsListener,ct as useLocalRowIds,gt as useLocalRowIdsListener,$e as useMetric,Ze as useMetricIds,_e as useMetricListener,E as useMetrics,Ye as useMetricsIds,V as useMetricsOrMetricsById,Q as useQueries,mt as useQueriesIds,W as useQueriesOrQueriesById,kt as useQueryIds,Ht as useRedoInformation,ut as useRelationshipIds,D as useRelationships,it as useRelationshipsIds,O as useRelationshipsOrRelationshipsById,lt as useRemoteRowId,pt as useRemoteRowIdListener,ft as useResultCell,Pt as useResultCellIds,Ft as useResultCellIdsListener,Et as useResultCellListener,qt as useResultRow,ht as useResultRowCount,Lt as useResultRowCountListener,Rt as useResultRowIds,Bt as useResultRowIdsListener,Mt as useResultRowListener,vt as useResultSortedRowIds,Tt as useResultSortedRowIdsListener,wt as useResultTable,yt as useResultTableCellIds,St as useResultTableCellIdsListener,xt as useResultTableListener,ae as useRow,ue as useRowCount,je as useRowCountListener,le as useRowIds,De as useRowIdsListener,Qe as useRowListener,ve as useSetCellCallback,Ot as useSetCheckpointCallback,Re as useSetPartialRowCallback,Pe as useSetPartialValuesCallback,ye as useSetRowCallback,we as useSetTableCallback,ke as useSetTablesCallback,fe as useSetValueCallback,qe as useSetValuesCallback,ot as useSliceIds,dt as useSliceIdsListener,rt as useSliceRowIds,nt as useSliceRowIdsListener,ce as useSortedRowIds,Oe as useSortedRowIdsListener,Ke as useStartTransactionListener,M as useStore,re as useStoreIds,F as useStoreOrStoreById,Ie as useTable,ie as useTableCellIds,Ae as useTableCellIdsListener,ne as useTableIds,Ee as useTableIdsListener,Ve as useTableListener,de as useTables,Fe as useTablesListener,Gt as useUndoInformation,me as useValue,Ce as useValueIds,He as useValueIdsListener,Je as useValueListener,be as useValues,Ge as useValuesListener,Ne as useWillFinishTransactionListener};
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,a="",n=l(a),o=l(!0),r=l(0),i=l(l),d="type",u="default",c="Ids",h="Table",m=h+"s",b=h+c,g="Row",p=g+"Count",I=g+c,f="Cell",w=f+c,y="Value",C=y+"s",v=y+c,k="currentTarget",T="value",S=e=>a+e,x=Math.floor,V=isFinite,R=(e,t)=>e instanceof t,q=e=>null==e,N=(e,t,s)=>q(e)?s?.():t(e),L=e=>e==n||e==o,M=e=>l(e)==i,E=e=>Array.isArray(e),z=(e,t,s)=>e.slice(t,s),$=e=>e.length,{PureComponent:O,Fragment:A,createElement:F,useCallback:J,useLayoutEffect:P,useRef:B,useState:H}=t,D=(e,...t)=>q(e)?{}:e(...t),Q=(e,t)=>e.forEach(t),j=(e,t)=>e.map(t),W=e=>0==$(e),U=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),te=(e,t)=>!q(((e,t)=>N(e,(e=>e[t])))(e,t)),se=(e,t)=>(delete e[t],e),le=(e,t)=>j(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>$(X(e)))(e),ne=e=>JSON.stringify(e,((e,t)=>R(t,Map)?K.fromEntries([...t]):t)),oe=JSON.parse,re="tinybaseStoreInspector",ie="TinyBase Store Inspector",de=["left","top","bottom","right","full"],ue="state",ce="sort",he="open",me="position",be=he,ge="editable",pe=(...e)=>ne(e),Ie=(e,t)=>j(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),J((s=>{t.setCell(ue,e,ge,(e=>!e)),s.preventDefault()}),[t,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',Ce=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ve='</svg>")',ke=ye+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Te=j([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ve)),Se=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ve,xe=Ce+`<path d='${we}' />`+ve,Ve=Ce+`<path d='${we}M20 20l60 60' />`+ve,Re="*::-webkit-scrollbar",qe=`#${re}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,t="")=>e.join(t))(le({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Re]:"width:0.5rem;height:0.5rem;",[Re+"-track"]:"background:#111",[Re+"-thumb"]:"background:#999;border:1px solid #111",[Re+"-thumb:hover"]:"background:#fff",[Re+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+ke,...ee(j(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...ee(j(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ke,"header>img:nth-of-type(6)":Se,...ee(j(Te,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":xe,"details[open]>summary img.done":Ve,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`& ${t}{${e}}`:"")))}`,Ne=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!0),[],e);return s.useValue(be,e)?null:F("img",{onClick:l,title:ie,"data-position":t})},Le=({uniqueId:e,summary:t,editable:l,handleEditable:a,children:n,s:o})=>{const r=!!s.useCell(ue,e,he,o),i=s.useSetCellCallback(ue,e,he,(e=>e[k].open),[],o);return F("details",{open:r,onToggle:i},F("summary",null,t,a?F("img",{onClick:a,className:l?"done":"edit"}):null),n)},Me=e=>{const t=l(e);return L(t)||t==r&&V(e)?t:void 0},Ee=(e,t,s,l,a)=>q(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),ze=(e,t,s)=>q(s)?e.delValue(t):e.setValue(t,s),$e=(e,t,s,l)=>e==n?t:e==r?s:l,{useCallback:Oe,useMemo:Ae,useState:Fe}=t,Je="editable",Pe=(e,t)=>j(s.useTableCellIds(e,t),(t=>e+"."+t)),Be=(e,t,s)=>{const l=Oe(e,t);return s?l:void 0},He=(...e)=>Ae((()=>e),e),De=(e,t)=>Ae((()=>({store:e,tableId:t})),[e,t]),Qe=(e,t)=>Ae((()=>({queries:e,queryId:t})),[e,t]),je=(e,t=!1,s,l=0,a,n,o,r)=>{const[[i,d,u],c]=Fe([e,t,l]),h=Oe((e=>{c(e),r?.(e)}),[r]),m=Be((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=Oe((e=>h([i,d,e])),[h,i,d]),g=!0===o?at:o;return[[i,d,u],m,Ae((()=>!1===o?null:F(g,{offset:u,limit:a,total:n,onChange:b})),[o,g,u,a,n,b])]},We=(e,t,s)=>Ae((()=>{const a=t??e;return ee(le(E(a)?ee(j(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:s,...(a=e,l(a)==n?{label:e}:e)}];var a})))}),[t,s,e]),Ue=({className:e,headerRow:t,idColumn:s,params:[l,a,n,o,r,i]})=>F("table",{className:e},i?F("caption",null,i):null,!1===t?null:F("thead",null,F("tr",null,!1===s?null:F(Ge,{sort:o??[],label:"Id",onClick:r}),le(l,(({label:e},t)=>F(Ge,{key:t,cellId:t,label:e,sort:o??[],onClick:r}))))),F("tbody",null,j(n,(e=>F("tr",{key:e},!1===s?null:F("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>F("td",{key:l},F(t,{...D(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>F("th",{onClick:Be((()=>n?.(e)),[n,e],n),className:q(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},q(s)||t!=e?null:(s?"↓":"↑")+" ",l),Ke=({localRowId:e,params:[l,a,n,o,r,i,d]})=>{const u=s.useRemoteRowId(r,e,i);return F("tr",null,!1===l?null:F(t.Fragment,null,F("th",null,e),F("th",null,u)),le(a,(({component:t,getComponentProps:s},l)=>{const[a,r]=l.split(".",2),i=a===n?e:a===o?u:null;return q(i)?null:F("td",{key:l},F(t,{...D(s,i,r),store:d,tableId:a,rowId:i,cellId:r}))})))},Xe=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:a=!0})=>{const[i,d]=Fe(),[u,c]=Fe(),[h,m]=Fe(),[b,g]=Fe(),[p,I]=Fe();u!==e&&(d(Me(e)),c(e),m(e+""),g(Number(e)||0),I(!!e));const f=Oe(((e,s)=>{s(e),c(e),t(e)}),[t]),w=Oe((()=>{if(!l?.()){const e=$e(i,r,o,n),s=$e(e,h,b,p);d(e),c(s),t(s)}}),[l,t,h,b,p,i]);return F("div",{className:s},a?F("button",{className:i,onClick:w},i):null,$e(i,F("input",{key:i,value:h,onChange:Oe((e=>f(e[k][T]+"",m)),[f])}),F("input",{key:i,type:"number",value:b,onChange:Oe((e=>f(Number(e[k][T]||0),g)),[f])}),F("input",{key:i,type:"checkbox",checked:p,onChange:Oe((e=>f(!!e[k].checked,I)),[f])})))},Ye=({tableId:e,cellId:t,descending:l,offset:a,limit:n,store:o,editable:r,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=je(t,l,i,a,n,s.useRowCount(e,o),d,u);return F(Ue,{...h,params:He(We(s.useTableCellIds(e,o),c,r?st:s.CellView),De(o,e),s.useSortedRowIds(e,...m,n,o),m,b,g)})},Ze=({store:e,editable:t=!1,valueComponent:l=(t?lt:s.ValueView),getValueComponentProps:a,className:n,headerRow:o,idColumn:r})=>F("table",{className:n},!1===o?null:F("thead",null,F("tr",null,!1===r?null:F("th",null,"Id"),F("th",null,y))),F("tbody",null,j(s.useValueIds(e),(t=>F("tr",{key:t},!1===r?null:F("th",null,t),F("td",null,F(l,{...D(a,t),valueId:t,store:e}))))))),_e=({indexId:e,sliceId:t,indexes:l,editable:a,customCells:n,...o})=>{const[r,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return F(Ue,{...o,params:He(We(s.useTableCellIds(d,i),n,a?st:s.CellView),De(i,d),s.useSliceRowIds(e,t,r))})},et=({relationshipId:e,relationships:l,editable:a,customCells:n,className:o,headerRow:r,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=We([...Pe(c,u),...Pe(h,u)],n,a?st:s.CellView),b=He(i,m,c,h,e,d,u);return F("table",{className:o},!1===r?null:F("thead",null,F("tr",null,!1===i?null:F(t.Fragment,null,F("th",null,c,".Id"),F("th",null,h,".Id")),le(m,(({label:e},t)=>F("th",{key:t},e))))),F("tbody",null,j(s.useRowIds(c,u),(e=>F(Ke,{key:e,localRowId:e,params:b})))))},tt=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:o,sortOnClick:r,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=je(t,l,r,a,n,s.useResultRowCount(e,o),i,u);return F(Ue,{...c,params:He(We(s.useResultTableCellIds(e,o),d,s.ResultCellView),Qe(o,e),s.useResultSortedRowIds(e,...h,n,o),h,m,b)})},st=({tableId:e,rowId:t,cellId:l,store:a,className:n,showType:o})=>F(Xe,{thing:s.useCell(e,t,l,a),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],a),className:n??Je+f,showType:o,hasSchema:s.useStoreOrStoreById(a)?.hasTablesSchema}),lt=({valueId:e,store:t,className:l,showType:a})=>F(Xe,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Je+y,showType:a,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),at=({onChange:e,total:s,offset:l=0,limit:a=s,singular:n="row",plural:o=n+"s"})=>{(l>s||l<0)&&(l=0,e(0));const r=Be((()=>e(l-a)),[e,l,a],l>0),i=Be((()=>e(l+a)),[e,l,a],l+a<s);return F(t.Fragment,null,s>a&&F(t.Fragment,null,F("button",{className:"previous",disabled:0==l,onClick:r},"←"),F("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?o:n)},nt=({indexes:e,indexesId:t,indexId:l,s:a})=>F(Le,{uniqueId:pe("i",t,l),summary:"Index: "+l,s:a},j(s.useSliceIds(l,e),(s=>F(ot,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a,key:s})))),ot=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=pe("i",t,s,l),[o,r]=fe(n,a);return F(Le,{uniqueId:n,summary:"Slice: "+l,editable:o,handleEditable:r,s:a},F(_e,{sliceId:l,indexId:s,indexes:e,editable:o}))},rt=({indexesId:e,s:t})=>{const l=s.useIndexes(e),a=s.useIndexIds(l);return q(l)?null:F(Le,{uniqueId:pe("i",e),summary:"Indexes: "+(e??u),s:t},W(a)?"No indexes defined":Ie(a,(s=>F(nt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},it=({metrics:e,metricId:t})=>F("tr",null,F("th",null,t),F("td",null,e?.getTableId(t)),F("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:F(Le,{uniqueId:pe("m",e),summary:"Metrics: "+(e??u),s:t},W(a)?"No metrics defined":F("table",null,F("thead",null,F("th",null,"Metric Id"),F("th",null,"Table Id"),F("th",null,"Metric")),F("tbody",null,j(a,(e=>F(it,{metrics:l,metricId:e,key:e}))))))},ut=({queries:e,queriesId:t,queryId:l,s:a})=>{const n=pe("q",t,l),[o,r,i]=oe(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a);return F(Le,{uniqueId:n,summary:"Query: "+l,s:a},F(tt,{queryId:l,queries:e,cellId:o,descending:r,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ct=({queriesId:e,s:t})=>{const l=s.useQueries(e),a=s.useQueryIds(l);return q(l)?null:F(Le,{uniqueId:pe("q",e),summary:"Queries: "+(e??u),s:t},W(a)?"No queries defined":Ie(a,(s=>F(ut,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=pe("r",t,s),[n,o]=fe(a,l);return F(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:o,s:l},F(et,{relationshipId:s,relationships:e,editable:n}))},mt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),a=s.useRelationshipIds(l);return q(l)?null:F(Le,{uniqueId:pe("r",e),summary:"Relationships: "+(e??u),s:t},W(a)?"No relationships defined":Ie(a,(s=>F(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},bt=({tableId:e,store:t,storeId:l,s:a})=>{const n=pe("t",l,e),[o,r,i]=oe(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a),[u,c]=fe(n,a);return F(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},F(Ye,{tableId:e,store:t,cellId:o,descending:r,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},gt=({store:e,storeId:t,s:l})=>{const a=pe("v",t),[n,o]=fe(a,l);return W(s.useValueIds(e))?null:F(Le,{uniqueId:a,summary:C,editable:n,handleEditable:o,s:l},F(Ze,{store:e,editable:n}))},pt=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:F(Le,{uniqueId:pe("s",e),summary:"Store: "+(e??u),s:t},F(gt,{storeId:e,store:l,s:t}),Ie(a,(s=>F(bt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},It=({s:e})=>{const t=B(null),l=B(0),[a,n]=H(!1),{scrollLeft:o,scrollTop:r}=s.useValues(e);P((()=>{const e=t.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=x(o)+e.clientWidth&&e.scrollHeight>=x(r)+e.clientHeight&&e.scrollTo(o,r)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,o,r]);const i=J((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),b=s.useIndexesIds(),g=s.useRelationships(),p=s.useRelationshipsIds(),I=s.useQueries(),f=s.useQueriesIds();return q(d)&&W(u)&&q(c)&&W(h)&&q(m)&&W(b)&&q(g)&&W(p)&&q(I)&&W(f)?F("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):F("article",{ref:t,onScroll:i},F(pt,{s:e}),j(u,(t=>F(pt,{storeId:t,s:e,key:t}))),F(dt,{s:e}),j(h,(t=>F(dt,{metricsId:t,s:e,key:t}))),F(rt,{s:e}),j(b,(t=>F(rt,{indexesId:t,s:e,key:t}))),F(mt,{s:e}),j(p,(t=>F(mt,{relationshipsId:t,s:e,key:t}))),F(ct,{s:e}),j(f,(t=>F(ct,{queriesId:t,s:e,key:t}))))};class ft extends O{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?F("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const wt=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!1),[],e),a=s.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return F("header",null,F("img",{title:ie}),F("span",null,ie),j(de,((e,s)=>s==t?null:F("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),F("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?F("main",{"data-position":t},F(wt,{s:e}),F(ft,null,F(It,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Rt(t).reduce(s,0);var s},vt=e=>e?.size??0,kt=Ct(vt),Tt=Ct(kt),St=Ct(Tt),xt=(e,t)=>e?.has(t)??!1,Vt=e=>q(e)||0==vt(e),Rt=e=>[...e?.values()??[]],qt=e=>e.clear(),Nt=(e,t)=>e?.forEach(t),Lt=(e,t)=>e?.delete(t),Mt=e=>new Map(e),Et=e=>[...e?.keys()??[]],zt=(e,t)=>e?.get(t),$t=(e,t)=>Nt(e,((e,s)=>t(s,e))),Ot=(e,t,s)=>q(s)?(Lt(e,t),e):e?.set(t,s),At=(e,t,s)=>(xt(e,t)||Ot(e,t,s()),zt(e,t)),Ft=(e,t,s,l=Ot)=>(le(t,((t,l)=>s(e,l,t))),$t(e,(s=>te(t,s)?0:l(e,s))),e),Jt=(e,t,s)=>{const l={};return Nt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Pt=(e,t,s)=>Jt(e,(e=>Jt(e,t,s)),ae),Bt=(e,t,s)=>Jt(e,(e=>Pt(e,t,s)),ae),Ht=(e,t)=>{const s=Mt();return Nt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Dt=e=>Ht(e,Ht),Qt=e=>Ht(e,Dt),jt=(e,t,s,l,a=0)=>N((s?At:zt)(e,t[a],a>$(t)-2?s:Mt),(n=>{if(a>$(t)-2)return l?.(n)&&Ot(e,t[a]),n;const o=jt(n,t,s,l,a+1);return Vt(n)&&Ot(e,t[a]),o})),Wt=Mt(),Ut=Mt(),Gt="storage",Kt=globalThis.window,Xt=e=>new Set(E(e)||q(e)?e:[e]),Yt=(e,t)=>e?.add(t),Zt=/^\d+$/,_t=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??a+t++,t=>{Zt.test(t)&&$(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=kt)=>t(e[0])+t(e[1]),ss=()=>[Mt(),Mt()],ls=e=>[...e],as=([e,t])=>e===t,ns=(e,t,s)=>q(e)||!_(e)||ae(e)||Y(e)?(s?.(),!1):(le(e,((s,l)=>{t(s,l)||se(e,l)})),!ae(e)),os=(e,t,s)=>Ot(e,t,zt(e,t)==-s?void 0:s),rs=()=>{let e,t,s=!1,l=!1,n=0;const o=Mt(),i=Mt(),c=Mt(),k=Mt(),T=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Mt(),P=Mt(),B=Xt(),H=Mt(),D=Mt(),W=Mt(),G=Mt(),K=ss(),X=ss(),Y=ss(),_=ss(),ee=ss(),re=ss(),ie=ss(),de=ss(),ue=ss(),ce=ss(),he=ss(),me=ss(),be=ss(),ge=ss(),pe=ss(),Ie=Mt(),fe=ss(),[we,ye,Ce,ve]=(e=>{let t;const[s,l]=_t(),n=Mt();return[(e,l,o,r=[],i=(()=>[]))=>{t??=ws;const d=s(1);return Ot(n,d,[e,l,o,r,i]),Yt(jt(l,o??[a],Xt),d),d},(e,s,...l)=>Q(((e,t=[a])=>{const s=[],l=(e,a)=>a==$(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):Q([t[a],null],(t=>l(zt(e,t),a+1)));return l(e,0),s})(e,s),(e=>Nt(e,(e=>zt(n,e)[0](t,...s??[],...l))))),e=>N(zt(n,e),(([,t,s])=>(jt(t,s??[a],void 0,(t=>(Lt(t,e),Vt(t)?1:0))),Ot(n,e),l(e),s))),e=>N(zt(n,e),(([e,,s=[],l,a])=>{const n=(...o)=>{const r=$(o);r==$(s)?e(t,...o,...a(o)):q(s[r])?Q(l[r]?.(...o)??[],(e=>n(...o,e))):n(...o,s[r])};n()}))]})(),ke=e=>{if(!ns(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!L(t)&&t!=r||(Me(e[u])!=t&&se(e,u),0))},Te=(t,s)=>(!e||xt(A,s)||lt(s))&&ns(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>ns(l?s:qe(s,e,t),((l,a)=>N(xe(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),xe=(t,s,l,a)=>e?N(zt(zt(A,t),l),(e=>Me(a)!=e[d]?lt(t,s,l,a,e[u]):a),(()=>lt(t,s,l,a))):q(Me(a))?lt(t,s,l,a):a,Ve=(e,t)=>ns(t?e:Ne(e),((t,s)=>N(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?N(zt(J,e),(t=>Me(s)!=t[d]?at(e,s,t[u]):s),(()=>at(e,s))):q(Me(s))?at(e,s):s,qe=(e,t,s)=>(N(zt(F,t),(([l,a])=>{Nt(l,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(a,(l=>{te(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(Nt(P,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(B,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft(A,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At(A,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(F,t,[l,a])}),((e,t)=>{Ot(A,t),Ot(F,t)})),$e=e=>Ft(J,e,((e,t,s)=>{Ot(J,t,s),N(s[u],(e=>Ot(P,t,e)),(()=>Yt(B,t)))}),((e,t)=>{Ot(J,t),Ot(P,t),Lt(B,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(W,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(W,e,(()=>(Ye(e,1),Ot(H,e,_t()),Ot(D,e,Mt()),Mt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ge(e,t,s))),Je=(e,t,s,l,a)=>Ft(At(t,s,(()=>(Ze(e,s,1),Mt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ke(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{xt(s,l)||_e(e,t,l,1);const n=zt(s,l);a!==n&&(et(e,t,l,n,a),Ot(s,l,a))},Be=(e,t,s,l,a)=>N(zt(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),He=e=>ae(e)?ms():Kt(e),De=e=>Ft(G,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{xt(G,e)||tt(e,1);const s=zt(G,e);t!==s&&(st(e,s,t),Ot(G,e,t))},je=(e,t)=>{const[s]=zt(H,e),l=s(t);return xt(zt(W,e),l)?je(e,t):l},We=e=>zt(W,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(H,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const o=zt(zt(F,e)?.[0],a);if(!q(o)&&!n)return Pe(e,s,l,a,o);const r=t=>{et(e,s,t,zt(l,t)),_e(e,s,t,-1),Ot(l,t)};q(o)?r(a):$t(l,r),Vt(l)&&(Ze(e,s,-1),Vt(Ot(t,s))&&(Ye(e,-1),Ot(W,e),Ot(H,e),Ot(D,e)))},Xe=e=>{const t=zt(P,e);if(!q(t))return Qe(e,t);st(e,zt(G,e)),tt(e,-1),Ot(G,e)},Ye=(e,t)=>os(o,e,t),Ze=(e,t,s)=>os(At(k,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(D,e),n=zt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&os(At(i,e,Mt),s,l),Ot(a,s,n!=-l?n+l:null),os(At(At(T,e,Mt),t,Mt),s,l)},et=(e,t,s,l,a)=>At(At(At(x,e,Mt),t,Mt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>os(V,e,t),st=(e,t,s)=>At(R,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(U(At(At(At(E,e,Mt),t,Mt),s,(()=>[])),l),a),at=(e,t,s)=>(U(At(O,e,(()=>[])),t),s),nt=(e,t,s)=>N(zt(zt(zt(x,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ct(e,t,s))])),ot=e=>N(zt(R,e),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ut(e))])),rt=e=>Vt(E)||Vt(he[e])?0:Nt(e?Qt(E):E,((t,s)=>Nt(t,((t,l)=>Nt(t,((t,a)=>ye(he[e],[s,l,a],t))))))),it=e=>Vt(O)||Vt(me[e])?0:Nt(e?Ht(O):O,((t,s)=>ye(me[e],[s],t))),dt=(e,t,s)=>{if(!Vt(t))return ye(e,s,(()=>Jt(t))),1},ut=e=>{const t=Vt(ie[e]),s=Vt(ue[e])&&Vt(_[e])&&Vt(ee[e])&&Vt(re[e])&&t&&Vt(X[e]),l=Vt(ce[e])&&Vt(de[e])&&Vt(Y[e])&&Vt(K[e]);if(!s||!l){const a=e?[Ht(o),Dt(i),Ht(c),Dt(k),Qt(T),Qt(x)]:[o,i,c,k,T,x];if(!s){dt(X[e],a[0]),Nt(a[1],((t,s)=>dt(_[e],t,[s]))),Nt(a[2],((t,s)=>{0!=t&&ye(ee[e],[s],It(s))}));const s=Xt();Nt(a[3],((l,a)=>{dt(re[e],l,[a])&&!t&&(ye(ie[e],[a,null]),Yt(s,a))})),t||Nt(a[5],((t,l)=>{if(!xt(s,l)){const s=Xt();Nt(t,(e=>Nt(e,(([t,l],a)=>l!==t?Yt(s,a):Lt(e,a))))),Nt(s,(t=>ye(ie[e],[l,t])))}})),Nt(a[4],((t,s)=>Nt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;Nt(a[5],((s,l)=>{let a;Nt(s,((s,n)=>{let o;Nt(s,(([s,r],i)=>{r!==s&&(ye(ce[e],[l,n,i],r,s,nt),t=a=o=1)})),o&&ye(de[e],[l,n],nt)})),a&&ye(Y[e],[l],nt)})),t&&ye(K[e],void 0,nt)}}},ct=e=>{const t=Vt(ge[e]),s=Vt(pe[e])&&Vt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(R)]:[V,R];if(t||dt(ge[e],l[0]),!s){let t;Nt(l[1],(([s,l],a)=>{l!==s&&(ye(pe[e],[a],l,s,ot),t=1)})),t&&ye(be[e],void 0,ot)}}},ht=(e,...t)=>(ps((()=>e(...j(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(o,t)?null:Jt(e,((e,s)=>-1===zt(zt(k,t),s)?null:Jt(e,(([,e])=>e??null),((e,t)=>as(t)))),ae)),ae),Jt(R,(([,e])=>e??null),((e,t)=>as(t)))],bt=()=>({cellsTouched:s,valuesTouched:l,changedCells:Bt(x,ls,as),invalidCells:Bt(E),changedValues:Jt(R,ls,as),invalidValues:Jt(O),changedTableIds:Jt(o),changedRowIds:Pt(k),changedCellIds:Bt(T),changedValueIds:Jt(V)}),gt=()=>Bt(W),pt=()=>Et(W),It=e=>vt(zt(W,S(e))),ft=e=>Et(zt(W,S(e))),wt=(e,t,s,l=0,a)=>{return j(z((o=zt(W,S(e)),r=(e,s)=>[q(t)?s:zt(e,S(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),j([...o?.entries()??[]],(([e,t])=>r(t,e))).sort(n)),l,q(a)?a:l+a),(([,e])=>e));var n,o,r},yt=(e,t)=>Et(zt(zt(W,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(W,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,Te,lt))(e)?Ae(e):0)),Kt=e=>ht((()=>Ve(e)?De(e):0)),Zt=e=>{try{Oe(oe(e))}catch{}return ws},is=t=>ht((()=>{if((e=ns(t,(e=>ns(e,ke))))&&(Le(t),!Vt(W))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,ke))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(W,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(W,e),(s=>xt(s,t)?Ge(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{Le({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),ps=(e,t)=>{if(-1!=n){Is();const s=e();return fs(t),s}},Is=()=>(-1!=n&&n++,1==n&&ye(Ie,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Vt(x),l=!Vt(R),n=1,rt(1),s&&ut(1),it(1),l&&ct(1),e?.(mt,bt)&&(Nt(x,((e,t)=>Nt(e,((e,s)=>Nt(e,(([e],l)=>Ee(ws,t,s,l,e))))))),Nt(R,(([e],t)=>ze(ws,t,e))),s=l=!1),ye(fe[0],void 0,mt,bt),n=-1,rt(0),s&&ut(0),it(0),l&&ct(0),ye(fe[1],void 0,mt,bt),n=0,s=l=!1,Q([o,i,c,k,T,x,E,V,R,O],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:pt,getTable:e=>Pt(zt(W,S(e))),getTableCellIds:e=>Et(zt(D,S(e))),getRowCount:It,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(W,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(W),hasTable:e=>xt(W,S(e)),hasTableCell:(e,t)=>xt(zt(D,S(e)),S(t)),hasRow:(e,t)=>xt(zt(W,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(W,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(W),getValuesJson:()=>ne(G),getJson:()=>ne([W,G]),getTablesSchemaJson:()=>ne(A),getValuesSchemaJson:()=>ne(J),getSchemaJson:()=>ne([A,J]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(ae(e)?us:Gt)(e),(ae(t)?ms:Kt)(t)})),setTables:Gt,setTable:(e,t)=>ht((e=>Te(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>ps((()=>{let l;return Se(e,l,t)&&(e=S(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);le(s,((s,a)=>Be(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>N(xe(e,t,s,M(l)?l(Ct(e,t,s)):l),(l=>Be(e,We(e),t,s,l)))),e,t,s),setValues:Kt,setPartialValues:e=>ht((()=>Ve(e,1)?le(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>N(Re(e,M(t)?t(Ut(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{le(e[0],((e,t)=>q(e)?cs(t):le(e,((e,s)=>q(e)?hs(t,s):le(e,((e,l)=>Ee(ws,t,s,l,e))))))),le(e[1],((e,t)=>ze(ws,t,e)))})),setTablesJson:Zt,setValuesJson:e=>{try{He(oe(e))}catch{}return ws},setJson:e=>ht((()=>{try{const[t,s]=oe(e);Oe(t),He(s)}catch{Zt(e)}})),setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>N(zt(W,e),(a=>N(zt(a,t),(n=>xt(n,s)?Ke(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>xt(G,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:ps,startTransaction:Is,finishTransaction:fs,forEachTable:e=>Nt(W,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(D,S(e)),t),forEachRow:(e,t)=>Nt(zt(W,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(W,S(e)),S(t)),s),forEachValue:e=>$t(G,e),addSortedRowIdsListener:(e,t,s,l,a,n,o)=>{let r=wt(e,t,s,l,a);return we((()=>{const o=wt(e,t,s,l,a);var i,d,u;d=r,$(i=o)===$(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(r=o,n(ws,e,t,s,l,a,r))}),ie[o?1:0],[e,t],[pt])},addStartTransactionListener:e=>we(e,Ie),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(Ce(e),ws),getListenerStats:()=>({tables:ts(K),tableIds:ts(X),tableCellIds:ts(_),table:ts(Y),rowCount:ts(ee),rowIds:ts(re),sortedRowIds:ts(ie),row:ts(de,Tt),cellIds:ts(ue,Tt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(pe),invalidValue:ts(me),transaction:kt(Ie)+ts(fe)}),createStore:rs,addListener:we,callListeners:ye};return le({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[pt]],[h+w]:[1,_,[pt]],[p]:[1,ee,[pt]],[I]:[1,re,[pt]],[g]:[2,de,[pt,ft]],[w]:[2,ue,[pt,ft]],[f]:[3,ce,[pt,ft,yt],e=>es(Ct(...e))],InvalidCell:[3,he],[C]:[0,be],[v]:[0,ge],[y]:[1,pe,[Wt],e=>es(Ut(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?z(a,0,e):void 0,s,l)})),Z(ws)},is=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(rs),a=de.indexOf(e);return s.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,[o,r]=[],i=[])=>{let d,u,c,h=0,m=0,b=0,g=0;At(Wt,i,(()=>0)),At(Ut,i,(()=>[]));const p=async e=>(2!=h&&(h=1,m++,await I.schedule((async()=>{await e(),h=0}))),I),I={load:async(s,l)=>await p((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(I.stopAutoLoad(),await I.load(s,a),g=1,c=l((async(s,l)=>{if(l){const t=l();await p((async()=>e.setTransactionChanges(t)))}else await p((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),I),stopAutoLoad:()=>(g&&(a(c),c=void 0,g=0),I),save:async t=>(1!=h&&(h=2,b++,await I.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}h=0}))),I),startAutoSave:async()=>(await I.stopAutoSave().save(),d=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();ae(s)&&ae(l)||I.save((()=>[s,l]))})),I),stopAutoSave:()=>(N(d,e.delListener),d=void 0,I),schedule:async(...e)=>(U(zt(Ut,i),...e),await(async()=>{if(!zt(Wt,i)){for(Ot(Wt,i,1);!q(u=G(zt(Ut,i)));)try{await u()}catch(e){n?.(e)}Ot(Wt,i,0)}})(),I),getStore:()=>e,destroy:()=>I.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:m,saves:b})};return o&&(I[o]=()=>r),Z(I)})(e,(async()=>oe(s.getItem(t))),(async e=>s.setItem(t,ne(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>oe(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l,["getStorageName",t]))(e,re,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!t}),await e.startAutoSave()})),F(A,null,F("aside",{id:re},F(Ne,{s:l}),F(yt,{s:l})),F("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>F(Ue,{...a,params:He(We(s.useResultTableCellIds(e,t),l,s.ResultCellView),Qe(t,e),s.useResultRowIds(e,t))}),e.SliceInHtmlTable=_e,e.SortedTableInHtmlTable=Ye,e.SortedTablePaginator=at,e.StoreInspector=e=>F(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>F(Ue,{...n,params:He(We(s.useTableCellIds(e,t),a,l?st:s.CellView),De(t,e),s.useRowIds(e,t))}),e.ValuesInHtmlTable=Ze},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
1
+ var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,a="",n=l(a),o=l(!0),r=l(0),i=l(l),d="type",u="default",c="Ids",h="Table",m=h+"s",b=h+c,g="Row",p=g+"Count",I=g+c,f="Cell",w=f+c,y="Value",C=y+"s",v=y+c,k="currentTarget",T="value",S=e=>a+e,x=Math.floor,V=isFinite,R=(e,t)=>e instanceof t,q=e=>null==e,N=(e,t,s)=>q(e)?s?.():t(e),L=e=>e==n||e==o,M=e=>l(e)==i,E=e=>Array.isArray(e),z=(e,t,s)=>e.slice(t,s),$=e=>e.length,{PureComponent:O,Fragment:A,createElement:F,useCallback:J,useLayoutEffect:P,useRef:B,useState:H}=t,D=(e,...t)=>q(e)?{}:e(...t),Q=(e,t)=>e.forEach(t),j=(e,t)=>e.map(t),W=e=>0==$(e),U=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),te=(e,t)=>!q(((e,t)=>N(e,(e=>e[t])))(e,t)),se=(e,t)=>(delete e[t],e),le=(e,t)=>j(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>$(X(e)))(e),ne=e=>JSON.stringify(e,((e,t)=>R(t,Map)?K.fromEntries([...t]):t)),oe=JSON.parse,re="tinybaseStoreInspector",ie="TinyBase Store Inspector",de=["left","top","bottom","right","full"],ue="state",ce="sort",he="open",me="position",be=he,ge="editable",pe=(...e)=>ne(e),Ie=(e,t)=>j(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),J((s=>{t.setCell(ue,e,ge,(e=>!e)),s.preventDefault()}),[t,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',Ce=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ve='</svg>")',ke=ye+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Te=j([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ve)),Se=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ve,xe=Ce+`<path d='${we}' />`+ve,Ve=Ce+`<path d='${we}M20 20l60 60' />`+ve,Re="*::-webkit-scrollbar",qe=((e,t="")=>e.join(t))(le({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Re]:"width:0.5rem;height:0.5rem;",[Re+"-track"]:"background:#111",[Re+"-thumb"]:"background:#999;border:1px solid #111",[Re+"-thumb:hover"]:"background:#fff",[Re+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+ke,...ee(j(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...ee(j(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ke,"header>img:nth-of-type(6)":Se,...ee(j(Te,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":xe,"details[open]>summary img.done":Ve,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${re} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${re} ${t}{${e}}`:""))),Ne=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!0),[],e);return s.useValue(be,e)?null:F("img",{onClick:l,title:ie,"data-position":t})},Le=({uniqueId:e,summary:t,editable:l,handleEditable:a,children:n,s:o})=>{const r=!!s.useCell(ue,e,he,o),i=s.useSetCellCallback(ue,e,he,(e=>e[k].open),[],o);return F("details",{open:r,onToggle:i},F("summary",null,t,a?F("img",{onClick:a,className:l?"done":"edit"}):null),n)},Me=e=>{const t=l(e);return L(t)||t==r&&V(e)?t:void 0},Ee=(e,t,s,l,a)=>q(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),ze=(e,t,s)=>q(s)?e.delValue(t):e.setValue(t,s),$e=(e,t,s,l)=>e==n?t:e==r?s:l,{useCallback:Oe,useMemo:Ae,useState:Fe}=t,Je="editable",Pe=(e,t)=>j(s.useTableCellIds(e,t),(t=>e+"."+t)),Be=(e,t,s)=>{const l=Oe(e,t);return s?l:void 0},He=(...e)=>Ae((()=>e),e),De=(e,t)=>Ae((()=>({store:e,tableId:t})),[e,t]),Qe=(e,t)=>Ae((()=>({queries:e,queryId:t})),[e,t]),je=(e,t=!1,s,l=0,a,n,o,r)=>{const[[i,d,u],c]=Fe([e,t,l]),h=Oe((e=>{c(e),r?.(e)}),[r]),m=Be((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=Oe((e=>h([i,d,e])),[h,i,d]),g=!0===o?at:o;return[[i,d,u],m,Ae((()=>!1===o?null:F(g,{offset:u,limit:a,total:n,onChange:b})),[o,g,u,a,n,b])]},We=(e,t,s)=>Ae((()=>{const a=t??e;return ee(le(E(a)?ee(j(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:s,...(a=e,l(a)==n?{label:e}:e)}];var a})))}),[t,s,e]),Ue=({className:e,headerRow:t,idColumn:s,params:[l,a,n,o,r,i]})=>F("table",{className:e},i?F("caption",null,i):null,!1===t?null:F("thead",null,F("tr",null,!1===s?null:F(Ge,{sort:o??[],label:"Id",onClick:r}),le(l,(({label:e},t)=>F(Ge,{key:t,cellId:t,label:e,sort:o??[],onClick:r}))))),F("tbody",null,j(n,(e=>F("tr",{key:e},!1===s?null:F("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>F("td",{key:l},F(t,{...D(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>F("th",{onClick:Be((()=>n?.(e)),[n,e],n),className:q(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},q(s)||t!=e?null:(s?"↓":"↑")+" ",l),Ke=({localRowId:e,params:[l,a,n,o,r,i,d]})=>{const u=s.useRemoteRowId(r,e,i);return F("tr",null,!1===l?null:F(t.Fragment,null,F("th",null,e),F("th",null,u)),le(a,(({component:t,getComponentProps:s},l)=>{const[a,r]=l.split(".",2),i=a===n?e:a===o?u:null;return q(i)?null:F("td",{key:l},F(t,{...D(s,i,r),store:d,tableId:a,rowId:i,cellId:r}))})))},Xe=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:a=!0})=>{const[i,d]=Fe(),[u,c]=Fe(),[h,m]=Fe(),[b,g]=Fe(),[p,I]=Fe();u!==e&&(d(Me(e)),c(e),m(e+""),g(Number(e)||0),I(!!e));const f=Oe(((e,s)=>{s(e),c(e),t(e)}),[t]),w=Oe((()=>{if(!l?.()){const e=$e(i,r,o,n),s=$e(e,h,b,p);d(e),c(s),t(s)}}),[l,t,h,b,p,i]);return F("div",{className:s},a?F("button",{className:i,onClick:w},i):null,$e(i,F("input",{key:i,value:h,onChange:Oe((e=>f(e[k][T]+"",m)),[f])}),F("input",{key:i,type:"number",value:b,onChange:Oe((e=>f(Number(e[k][T]||0),g)),[f])}),F("input",{key:i,type:"checkbox",checked:p,onChange:Oe((e=>f(!!e[k].checked,I)),[f])})))},Ye=({tableId:e,cellId:t,descending:l,offset:a,limit:n,store:o,editable:r,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=je(t,l,i,a,n,s.useRowCount(e,o),d,u);return F(Ue,{...h,params:He(We(s.useTableCellIds(e,o),c,r?st:s.CellView),De(o,e),s.useSortedRowIds(e,...m,n,o),m,b,g)})},Ze=({store:e,editable:t=!1,valueComponent:l=(t?lt:s.ValueView),getValueComponentProps:a,className:n,headerRow:o,idColumn:r})=>F("table",{className:n},!1===o?null:F("thead",null,F("tr",null,!1===r?null:F("th",null,"Id"),F("th",null,y))),F("tbody",null,j(s.useValueIds(e),(t=>F("tr",{key:t},!1===r?null:F("th",null,t),F("td",null,F(l,{...D(a,t),valueId:t,store:e}))))))),_e=({indexId:e,sliceId:t,indexes:l,editable:a,customCells:n,...o})=>{const[r,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return F(Ue,{...o,params:He(We(s.useTableCellIds(d,i),n,a?st:s.CellView),De(i,d),s.useSliceRowIds(e,t,r))})},et=({relationshipId:e,relationships:l,editable:a,customCells:n,className:o,headerRow:r,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=We([...Pe(c,u),...Pe(h,u)],n,a?st:s.CellView),b=He(i,m,c,h,e,d,u);return F("table",{className:o},!1===r?null:F("thead",null,F("tr",null,!1===i?null:F(t.Fragment,null,F("th",null,c,".Id"),F("th",null,h,".Id")),le(m,(({label:e},t)=>F("th",{key:t},e))))),F("tbody",null,j(s.useRowIds(c,u),(e=>F(Ke,{key:e,localRowId:e,params:b})))))},tt=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:o,sortOnClick:r,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=je(t,l,r,a,n,s.useResultRowCount(e,o),i,u);return F(Ue,{...c,params:He(We(s.useResultTableCellIds(e,o),d,s.ResultCellView),Qe(o,e),s.useResultSortedRowIds(e,...h,n,o),h,m,b)})},st=({tableId:e,rowId:t,cellId:l,store:a,className:n,showType:o})=>F(Xe,{thing:s.useCell(e,t,l,a),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],a),className:n??Je+f,showType:o,hasSchema:s.useStoreOrStoreById(a)?.hasTablesSchema}),lt=({valueId:e,store:t,className:l,showType:a})=>F(Xe,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Je+y,showType:a,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),at=({onChange:e,total:s,offset:l=0,limit:a=s,singular:n="row",plural:o=n+"s"})=>{(l>s||l<0)&&(l=0,e(0));const r=Be((()=>e(l-a)),[e,l,a],l>0),i=Be((()=>e(l+a)),[e,l,a],l+a<s);return F(t.Fragment,null,s>a&&F(t.Fragment,null,F("button",{className:"previous",disabled:0==l,onClick:r},"←"),F("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?o:n)},nt=({indexes:e,indexesId:t,indexId:l,s:a})=>F(Le,{uniqueId:pe("i",t,l),summary:"Index: "+l,s:a},j(s.useSliceIds(l,e),(s=>F(ot,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a,key:s})))),ot=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=pe("i",t,s,l),[o,r]=fe(n,a);return F(Le,{uniqueId:n,summary:"Slice: "+l,editable:o,handleEditable:r,s:a},F(_e,{sliceId:l,indexId:s,indexes:e,editable:o}))},rt=({indexesId:e,s:t})=>{const l=s.useIndexes(e),a=s.useIndexIds(l);return q(l)?null:F(Le,{uniqueId:pe("i",e),summary:"Indexes: "+(e??u),s:t},W(a)?"No indexes defined":Ie(a,(s=>F(nt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},it=({metrics:e,metricId:t})=>F("tr",null,F("th",null,t),F("td",null,e?.getTableId(t)),F("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:F(Le,{uniqueId:pe("m",e),summary:"Metrics: "+(e??u),s:t},W(a)?"No metrics defined":F("table",null,F("thead",null,F("th",null,"Metric Id"),F("th",null,"Table Id"),F("th",null,"Metric")),F("tbody",null,j(a,(e=>F(it,{metrics:l,metricId:e,key:e}))))))},ut=({queries:e,queriesId:t,queryId:l,s:a})=>{const n=pe("q",t,l),[o,r,i]=oe(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a);return F(Le,{uniqueId:n,summary:"Query: "+l,s:a},F(tt,{queryId:l,queries:e,cellId:o,descending:r,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ct=({queriesId:e,s:t})=>{const l=s.useQueries(e),a=s.useQueryIds(l);return q(l)?null:F(Le,{uniqueId:pe("q",e),summary:"Queries: "+(e??u),s:t},W(a)?"No queries defined":Ie(a,(s=>F(ut,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=pe("r",t,s),[n,o]=fe(a,l);return F(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:o,s:l},F(et,{relationshipId:s,relationships:e,editable:n}))},mt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),a=s.useRelationshipIds(l);return q(l)?null:F(Le,{uniqueId:pe("r",e),summary:"Relationships: "+(e??u),s:t},W(a)?"No relationships defined":Ie(a,(s=>F(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},bt=({tableId:e,store:t,storeId:l,s:a})=>{const n=pe("t",l,e),[o,r,i]=oe(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a),[u,c]=fe(n,a);return F(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},F(Ye,{tableId:e,store:t,cellId:o,descending:r,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},gt=({store:e,storeId:t,s:l})=>{const a=pe("v",t),[n,o]=fe(a,l);return W(s.useValueIds(e))?null:F(Le,{uniqueId:a,summary:C,editable:n,handleEditable:o,s:l},F(Ze,{store:e,editable:n}))},pt=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:F(Le,{uniqueId:pe("s",e),summary:"Store: "+(e??u),s:t},F(gt,{storeId:e,store:l,s:t}),Ie(a,(s=>F(bt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},It=({s:e})=>{const t=B(null),l=B(0),[a,n]=H(!1),{scrollLeft:o,scrollTop:r}=s.useValues(e);P((()=>{const e=t.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=x(o)+e.clientWidth&&e.scrollHeight>=x(r)+e.clientHeight&&e.scrollTo(o,r)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,o,r]);const i=J((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),b=s.useIndexesIds(),g=s.useRelationships(),p=s.useRelationshipsIds(),I=s.useQueries(),f=s.useQueriesIds();return q(d)&&W(u)&&q(c)&&W(h)&&q(m)&&W(b)&&q(g)&&W(p)&&q(I)&&W(f)?F("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):F("article",{ref:t,onScroll:i},F(pt,{s:e}),j(u,(t=>F(pt,{storeId:t,s:e,key:t}))),F(dt,{s:e}),j(h,(t=>F(dt,{metricsId:t,s:e,key:t}))),F(rt,{s:e}),j(b,(t=>F(rt,{indexesId:t,s:e,key:t}))),F(mt,{s:e}),j(p,(t=>F(mt,{relationshipsId:t,s:e,key:t}))),F(ct,{s:e}),j(f,(t=>F(ct,{queriesId:t,s:e,key:t}))))};class ft extends O{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}render(){return this.state.e?F("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const wt=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!1),[],e),a=s.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return F("header",null,F("img",{title:ie}),F("span",null,ie),j(de,((e,s)=>s==t?null:F("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),F("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?F("main",{"data-position":t},F(wt,{s:e}),F(ft,null,F(It,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Rt(t).reduce(s,0);var s},vt=e=>e?.size??0,kt=Ct(vt),Tt=Ct(kt),St=Ct(Tt),xt=(e,t)=>e?.has(t)??!1,Vt=e=>q(e)||0==vt(e),Rt=e=>[...e?.values()??[]],qt=e=>e.clear(),Nt=(e,t)=>e?.forEach(t),Lt=(e,t)=>e?.delete(t),Mt=e=>new Map(e),Et=e=>[...e?.keys()??[]],zt=(e,t)=>e?.get(t),$t=(e,t)=>Nt(e,((e,s)=>t(s,e))),Ot=(e,t,s)=>q(s)?(Lt(e,t),e):e?.set(t,s),At=(e,t,s)=>(xt(e,t)||Ot(e,t,s()),zt(e,t)),Ft=(e,t,s,l=Ot)=>(le(t,((t,l)=>s(e,l,t))),$t(e,(s=>te(t,s)?0:l(e,s))),e),Jt=(e,t,s)=>{const l={};return Nt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Pt=(e,t,s)=>Jt(e,(e=>Jt(e,t,s)),ae),Bt=(e,t,s)=>Jt(e,(e=>Pt(e,t,s)),ae),Ht=(e,t)=>{const s=Mt();return Nt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Dt=e=>Ht(e,Ht),Qt=e=>Ht(e,Dt),jt=(e,t,s,l,a=0)=>N((s?At:zt)(e,t[a],a>$(t)-2?s:Mt),(n=>{if(a>$(t)-2)return l?.(n)&&Ot(e,t[a]),n;const o=jt(n,t,s,l,a+1);return Vt(n)&&Ot(e,t[a]),o})),Wt=Mt(),Ut=Mt(),Gt="storage",Kt=globalThis.window,Xt=e=>new Set(E(e)||q(e)?e:[e]),Yt=(e,t)=>e?.add(t),Zt=/^\d+$/,_t=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??a+t++,t=>{Zt.test(t)&&$(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=kt)=>t(e[0])+t(e[1]),ss=()=>[Mt(),Mt()],ls=e=>[...e],as=([e,t])=>e===t,ns=(e,t,s)=>q(e)||!_(e)||ae(e)||Y(e)?(s?.(),!1):(le(e,((s,l)=>{t(s,l)||se(e,l)})),!ae(e)),os=(e,t,s)=>Ot(e,t,zt(e,t)==-s?void 0:s),rs=()=>{let e,t,s=!1,l=!1,n=0;const o=Mt(),i=Mt(),c=Mt(),k=Mt(),T=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Mt(),P=Mt(),B=Xt(),H=Mt(),D=Mt(),W=Mt(),G=Mt(),K=ss(),X=ss(),Y=ss(),_=ss(),ee=ss(),re=ss(),ie=ss(),de=ss(),ue=ss(),ce=ss(),he=ss(),me=ss(),be=ss(),ge=ss(),pe=ss(),Ie=Mt(),fe=ss(),[we,ye,Ce,ve]=(e=>{let t;const[s,l]=_t(),n=Mt();return[(e,l,o,r=[],i=(()=>[]))=>{t??=ws;const d=s(1);return Ot(n,d,[e,l,o,r,i]),Yt(jt(l,o??[a],Xt),d),d},(e,s,...l)=>Q(((e,t=[a])=>{const s=[],l=(e,a)=>a==$(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):Q([t[a],null],(t=>l(zt(e,t),a+1)));return l(e,0),s})(e,s),(e=>Nt(e,(e=>zt(n,e)[0](t,...s??[],...l))))),e=>N(zt(n,e),(([,t,s])=>(jt(t,s??[a],void 0,(t=>(Lt(t,e),Vt(t)?1:0))),Ot(n,e),l(e),s))),e=>N(zt(n,e),(([e,,s=[],l,a])=>{const n=(...o)=>{const r=$(o);r==$(s)?e(t,...o,...a(o)):q(s[r])?Q(l[r]?.(...o)??[],(e=>n(...o,e))):n(...o,s[r])};n()}))]})(),ke=e=>{if(!ns(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!L(t)&&t!=r||(Me(e[u])!=t&&se(e,u),0))},Te=(t,s)=>(!e||xt(A,s)||lt(s))&&ns(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>ns(l?s:qe(s,e,t),((l,a)=>N(xe(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),xe=(t,s,l,a)=>e?N(zt(zt(A,t),l),(e=>Me(a)!=e[d]?lt(t,s,l,a,e[u]):a),(()=>lt(t,s,l,a))):q(Me(a))?lt(t,s,l,a):a,Ve=(e,t)=>ns(t?e:Ne(e),((t,s)=>N(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?N(zt(J,e),(t=>Me(s)!=t[d]?at(e,s,t[u]):s),(()=>at(e,s))):q(Me(s))?at(e,s):s,qe=(e,t,s)=>(N(zt(F,t),(([l,a])=>{Nt(l,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(a,(l=>{te(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(Nt(P,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(B,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft(A,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At(A,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(F,t,[l,a])}),((e,t)=>{Ot(A,t),Ot(F,t)})),$e=e=>Ft(J,e,((e,t,s)=>{Ot(J,t,s),N(s[u],(e=>Ot(P,t,e)),(()=>Yt(B,t)))}),((e,t)=>{Ot(J,t),Ot(P,t),Lt(B,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(W,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(W,e,(()=>(Ye(e,1),Ot(H,e,_t()),Ot(D,e,Mt()),Mt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ge(e,t,s))),Je=(e,t,s,l,a)=>Ft(At(t,s,(()=>(Ze(e,s,1),Mt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ke(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{xt(s,l)||_e(e,t,l,1);const n=zt(s,l);a!==n&&(et(e,t,l,n,a),Ot(s,l,a))},Be=(e,t,s,l,a)=>N(zt(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),He=e=>ae(e)?ms():Kt(e),De=e=>Ft(G,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{xt(G,e)||tt(e,1);const s=zt(G,e);t!==s&&(st(e,s,t),Ot(G,e,t))},je=(e,t)=>{const[s]=zt(H,e),l=s(t);return xt(zt(W,e),l)?je(e,t):l},We=e=>zt(W,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(H,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const o=zt(zt(F,e)?.[0],a);if(!q(o)&&!n)return Pe(e,s,l,a,o);const r=t=>{et(e,s,t,zt(l,t)),_e(e,s,t,-1),Ot(l,t)};q(o)?r(a):$t(l,r),Vt(l)&&(Ze(e,s,-1),Vt(Ot(t,s))&&(Ye(e,-1),Ot(W,e),Ot(H,e),Ot(D,e)))},Xe=e=>{const t=zt(P,e);if(!q(t))return Qe(e,t);st(e,zt(G,e)),tt(e,-1),Ot(G,e)},Ye=(e,t)=>os(o,e,t),Ze=(e,t,s)=>os(At(k,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(D,e),n=zt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&os(At(i,e,Mt),s,l),Ot(a,s,n!=-l?n+l:null),os(At(At(T,e,Mt),t,Mt),s,l)},et=(e,t,s,l,a)=>At(At(At(x,e,Mt),t,Mt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>os(V,e,t),st=(e,t,s)=>At(R,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(U(At(At(At(E,e,Mt),t,Mt),s,(()=>[])),l),a),at=(e,t,s)=>(U(At(O,e,(()=>[])),t),s),nt=(e,t,s)=>N(zt(zt(zt(x,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ct(e,t,s))])),ot=e=>N(zt(R,e),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ut(e))])),rt=e=>Vt(E)||Vt(he[e])?0:Nt(e?Qt(E):E,((t,s)=>Nt(t,((t,l)=>Nt(t,((t,a)=>ye(he[e],[s,l,a],t))))))),it=e=>Vt(O)||Vt(me[e])?0:Nt(e?Ht(O):O,((t,s)=>ye(me[e],[s],t))),dt=(e,t,s)=>{if(!Vt(t))return ye(e,s,(()=>Jt(t))),1},ut=e=>{const t=Vt(ie[e]),s=Vt(ue[e])&&Vt(_[e])&&Vt(ee[e])&&Vt(re[e])&&t&&Vt(X[e]),l=Vt(ce[e])&&Vt(de[e])&&Vt(Y[e])&&Vt(K[e]);if(!s||!l){const a=e?[Ht(o),Dt(i),Ht(c),Dt(k),Qt(T),Qt(x)]:[o,i,c,k,T,x];if(!s){dt(X[e],a[0]),Nt(a[1],((t,s)=>dt(_[e],t,[s]))),Nt(a[2],((t,s)=>{0!=t&&ye(ee[e],[s],It(s))}));const s=Xt();Nt(a[3],((l,a)=>{dt(re[e],l,[a])&&!t&&(ye(ie[e],[a,null]),Yt(s,a))})),t||Nt(a[5],((t,l)=>{if(!xt(s,l)){const s=Xt();Nt(t,(e=>Nt(e,(([t,l],a)=>l!==t?Yt(s,a):Lt(e,a))))),Nt(s,(t=>ye(ie[e],[l,t])))}})),Nt(a[4],((t,s)=>Nt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;Nt(a[5],((s,l)=>{let a;Nt(s,((s,n)=>{let o;Nt(s,(([s,r],i)=>{r!==s&&(ye(ce[e],[l,n,i],r,s,nt),t=a=o=1)})),o&&ye(de[e],[l,n],nt)})),a&&ye(Y[e],[l],nt)})),t&&ye(K[e],void 0,nt)}}},ct=e=>{const t=Vt(ge[e]),s=Vt(pe[e])&&Vt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(R)]:[V,R];if(t||dt(ge[e],l[0]),!s){let t;Nt(l[1],(([s,l],a)=>{l!==s&&(ye(pe[e],[a],l,s,ot),t=1)})),t&&ye(be[e],void 0,ot)}}},ht=(e,...t)=>(ps((()=>e(...j(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(o,t)?null:Jt(e,((e,s)=>-1===zt(zt(k,t),s)?null:Jt(e,(([,e])=>e??null),((e,t)=>as(t)))),ae)),ae),Jt(R,(([,e])=>e??null),((e,t)=>as(t)))],bt=()=>({cellsTouched:s,valuesTouched:l,changedCells:Bt(x,ls,as),invalidCells:Bt(E),changedValues:Jt(R,ls,as),invalidValues:Jt(O),changedTableIds:Jt(o),changedRowIds:Pt(k),changedCellIds:Bt(T),changedValueIds:Jt(V)}),gt=()=>Bt(W),pt=()=>Et(W),It=e=>vt(zt(W,S(e))),ft=e=>Et(zt(W,S(e))),wt=(e,t,s,l=0,a)=>{return j(z((o=zt(W,S(e)),r=(e,s)=>[q(t)?s:zt(e,S(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),j([...o?.entries()??[]],(([e,t])=>r(t,e))).sort(n)),l,q(a)?a:l+a),(([,e])=>e));var n,o,r},yt=(e,t)=>Et(zt(zt(W,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(W,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,Te,lt))(e)?Ae(e):0)),Kt=e=>ht((()=>Ve(e)?De(e):0)),Zt=e=>{try{Oe(oe(e))}catch{}return ws},is=t=>ht((()=>{if((e=ns(t,(e=>ns(e,ke))))&&(Le(t),!Vt(W))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,ke))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(W,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(W,e),(s=>xt(s,t)?Ge(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{Le({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),ps=(e,t)=>{if(-1!=n){Is();const s=e();return fs(t),s}},Is=()=>(-1!=n&&n++,1==n&&ye(Ie,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Vt(x),l=!Vt(R),n=1,rt(1),s&&ut(1),it(1),l&&ct(1),e?.(mt,bt)&&(Nt(x,((e,t)=>Nt(e,((e,s)=>Nt(e,(([e],l)=>Ee(ws,t,s,l,e))))))),Nt(R,(([e],t)=>ze(ws,t,e))),s=l=!1),ye(fe[0],void 0,mt,bt),n=-1,rt(0),s&&ut(0),it(0),l&&ct(0),ye(fe[1],void 0,mt,bt),n=0,s=l=!1,Q([o,i,c,k,T,x,E,V,R,O],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:pt,getTable:e=>Pt(zt(W,S(e))),getTableCellIds:e=>Et(zt(D,S(e))),getRowCount:It,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(W,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(W),hasTable:e=>xt(W,S(e)),hasTableCell:(e,t)=>xt(zt(D,S(e)),S(t)),hasRow:(e,t)=>xt(zt(W,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(W,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(W),getValuesJson:()=>ne(G),getJson:()=>ne([W,G]),getTablesSchemaJson:()=>ne(A),getValuesSchemaJson:()=>ne(J),getSchemaJson:()=>ne([A,J]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(ae(e)?us:Gt)(e),(ae(t)?ms:Kt)(t)})),setTables:Gt,setTable:(e,t)=>ht((e=>Te(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>ps((()=>{let l;return Se(e,l,t)&&(e=S(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);le(s,((s,a)=>Be(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>N(xe(e,t,s,M(l)?l(Ct(e,t,s)):l),(l=>Be(e,We(e),t,s,l)))),e,t,s),setValues:Kt,setPartialValues:e=>ht((()=>Ve(e,1)?le(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>N(Re(e,M(t)?t(Ut(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{le(e[0],((e,t)=>q(e)?cs(t):le(e,((e,s)=>q(e)?hs(t,s):le(e,((e,l)=>Ee(ws,t,s,l,e))))))),le(e[1],((e,t)=>ze(ws,t,e)))})),setTablesJson:Zt,setValuesJson:e=>{try{He(oe(e))}catch{}return ws},setJson:e=>ht((()=>{try{const[t,s]=oe(e);Oe(t),He(s)}catch{Zt(e)}})),setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>N(zt(W,e),(a=>N(zt(a,t),(n=>xt(n,s)?Ke(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>xt(G,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:ps,startTransaction:Is,finishTransaction:fs,forEachTable:e=>Nt(W,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(D,S(e)),t),forEachRow:(e,t)=>Nt(zt(W,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(W,S(e)),S(t)),s),forEachValue:e=>$t(G,e),addSortedRowIdsListener:(e,t,s,l,a,n,o)=>{let r=wt(e,t,s,l,a);return we((()=>{const o=wt(e,t,s,l,a);var i,d,u;d=r,$(i=o)===$(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(r=o,n(ws,e,t,s,l,a,r))}),ie[o?1:0],[e,t],[pt])},addStartTransactionListener:e=>we(e,Ie),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(Ce(e),ws),getListenerStats:()=>({tables:ts(K),tableIds:ts(X),tableCellIds:ts(_),table:ts(Y),rowCount:ts(ee),rowIds:ts(re),sortedRowIds:ts(ie),row:ts(de,Tt),cellIds:ts(ue,Tt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(pe),invalidValue:ts(me),transaction:kt(Ie)+ts(fe)}),createStore:rs,addListener:we,callListeners:ye};return le({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[pt]],[h+w]:[1,_,[pt]],[p]:[1,ee,[pt]],[I]:[1,re,[pt]],[g]:[2,de,[pt,ft]],[w]:[2,ue,[pt,ft]],[f]:[3,ce,[pt,ft,yt],e=>es(Ct(...e))],InvalidCell:[3,he],[C]:[0,be],[v]:[0,ge],[y]:[1,pe,[Wt],e=>es(Ut(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?z(a,0,e):void 0,s,l)})),Z(ws)},is=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(rs),a=de.indexOf(e);return s.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,[o,r]=[],i=[])=>{let d,u,c,h=0,m=0,b=0,g=0;At(Wt,i,(()=>0)),At(Ut,i,(()=>[]));const p=async e=>(2!=h&&(h=1,m++,await I.schedule((async()=>{await e(),h=0}))),I),I={load:async(s,l)=>await p((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(I.stopAutoLoad(),await I.load(s,a),g=1,c=l((async(s,l)=>{if(l){const t=l();await p((async()=>e.setTransactionChanges(t)))}else await p((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),I),stopAutoLoad:()=>(g&&(a(c),c=void 0,g=0),I),save:async t=>(1!=h&&(h=2,b++,await I.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}h=0}))),I),startAutoSave:async()=>(await I.stopAutoSave().save(),d=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();ae(s)&&ae(l)||I.save((()=>[s,l]))})),I),stopAutoSave:()=>(N(d,e.delListener),d=void 0,I),schedule:async(...e)=>(U(zt(Ut,i),...e),await(async()=>{if(!zt(Wt,i)){for(Ot(Wt,i,1);!q(u=G(zt(Ut,i)));)try{await u()}catch(e){n?.(e)}Ot(Wt,i,0)}})(),I),getStore:()=>e,destroy:()=>I.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:m,saves:b})};return o&&(I[o]=()=>r),Z(I)})(e,(async()=>oe(s.getItem(t))),(async e=>s.setItem(t,ne(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>oe(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l,["getStorageName",t]))(e,re,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!t}),await e.startAutoSave()})),F(A,null,F("aside",{id:re},F(Ne,{s:l}),F(yt,{s:l})),F("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>F(Ue,{...a,params:He(We(s.useResultTableCellIds(e,t),l,s.ResultCellView),Qe(t,e),s.useResultRowIds(e,t))}),e.SliceInHtmlTable=_e,e.SortedTableInHtmlTable=Ye,e.SortedTablePaginator=at,e.StoreInspector=e=>F(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>F(Ue,{...n,params:He(We(s.useTableCellIds(e,t),a,l?st:s.CellView),De(t,e),s.useRowIds(e,t))}),e.ValuesInHtmlTable=Ze},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,l){"use strict";const a=e=>typeof e,o=a(""),n=a(!0),r=a(0),s="Value",i="currentTarget",d="value",u=isFinite,m=e=>null==e,{PureComponent:c,Fragment:h,createElement:b,useCallback:g,useLayoutEffect:p,useRef:w,useState:f}=t,I=(e,...t)=>m(e)?{}:e(...t),y=(e,t)=>e.map(t),C=Object,k=(e=[])=>C.fromEntries(e),v=(e,t)=>y(C.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",T='content:url("',R=T+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",S='</svg>")',N=T+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",V=y([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>R+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+S)),z=R+"<path d='M20 20l60 60M20 80l60-60' />"+S,M=R+`<path d='${x}' />`+S,$=R+`<path d='${x}M20 20l60 60' />`+S,q="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(v({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[q]:"width:0.5rem;height:0.5rem;",[q+"-track"]:"background:#111",[q+"-thumb"]:"background:#999;border:1px solid #111",[q+"-thumb:hover"]:"background:#fff",[q+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+N,...k(y(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...k(y(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":N,"header>img:nth-of-type(6)":z,...k(y(V,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":M,"details[open]>summary img.done":$,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem","th,td":"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`& ${t}{${e}}`:"")));const B=(e,t,l,a)=>e==o?t:e==r?l:a,{useCallback:F,useMemo:H,useState:O}=t,E="editable",P=(e,t)=>y(l.useTableCellIds(e,t),(t=>e+"."+t)),j=(e,t,l)=>{const a=F(e,t);return l?a:void 0},D=(...e)=>H((()=>e),e),A=(e,t)=>H((()=>({store:e,tableId:t})),[e,t]),L=(e,t)=>H((()=>({queries:e,queryId:t})),[e,t]),U=(e,t=!1,l,a=0,o,n,r,s)=>{const[[i,d,u],m]=O([e,t,a]),c=F((e=>{m(e),s?.(e)}),[s]),h=j((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=F((e=>c([i,d,e])),[c,i,d]),p=!0===r?Z:r;return[[i,d,u],h,H((()=>!1===r?null:b(p,{offset:u,limit:o,total:n,onChange:g})),[r,p,u,o,n,g])]},G=(e,t,l)=>H((()=>{const n=t??e;return k(v(Array.isArray(n)?k(y(n,(e=>[e,e]))):n,((e,t)=>{return[t,{label:t,component:l,...(n=e,a(n)==o?{label:e}:e)}];var n})))}),[t,l,e]),J=({className:e,headerRow:t,idColumn:l,params:[a,o,n,r,s,i]})=>b("table",{className:e},i?b("caption",null,i):null,!1===t?null:b("thead",null,b("tr",null,!1===l?null:b(K,{sort:r??[],label:"Id",onClick:s}),v(a,(({label:e},t)=>b(K,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),b("tbody",null,y(n,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),v(a,(({component:t,getComponentProps:l},a)=>b("td",{key:a},b(t,{...I(l,e,a),...o,rowId:e,cellId:a}))))))))),K=({cellId:e,sort:[t,l],label:a=e??"",onClick:o})=>b("th",{onClick:j((()=>o?.(e)),[o,e],o),className:m(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},m(l)||t!=e?null:(l?"↓":"↑")+" ",a),Q=({localRowId:e,params:[a,o,n,r,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===a?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),v(o,(({component:t,getComponentProps:l},a)=>{const[o,s]=a.split(".",2),i=o===n?e:o===r?u:null;return m(i)?null:b("td",{key:a},b(t,{...I(l,i,s),store:d,tableId:o,rowId:i,cellId:s}))})))},W=({thing:e,onThingChange:t,className:l,hasSchema:s,showType:m=!0})=>{const[c,h]=O(),[g,p]=O(),[w,f]=O(),[I,y]=O(),[C,k]=O();g!==e&&(h((e=>{const t=a(e);return(e=>e==o||e==n)(t)||t==r&&u(e)?t:void 0})(e)),p(e),f(e+""),y(Number(e)||0),k(!!e));const v=F(((e,l)=>{l(e),p(e),t(e)}),[t]),x=F((()=>{if(!s?.()){const e=B(c,r,n,o),l=B(e,w,I,C);h(e),p(l),t(l)}}),[s,t,w,I,C,c]);return b("div",{className:l},m?b("button",{className:c,onClick:x},c):null,B(c,b("input",{key:c,value:w,onChange:F((e=>v(e[i][d]+"",f)),[v])}),b("input",{key:c,type:"number",value:I,onChange:F((e=>v(Number(e[i][d]||0),y)),[v])}),b("input",{key:c,type:"checkbox",checked:C,onChange:F((e=>v(!!e[i].checked,k)),[v])})))},X=({tableId:e,rowId:t,cellId:a,store:o,className:n,showType:r})=>b(W,{thing:l.useCell(e,t,a,o),onThingChange:l.useSetCellCallback(e,t,a,(e=>e),[],o),className:n??E+"Cell",showType:r,hasSchema:l.useStoreOrStoreById(o)?.hasTablesSchema}),Y=({valueId:e,store:t,className:a,showType:o})=>b(W,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:a??E+s,showType:o,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),Z=({onChange:e,total:l,offset:a=0,limit:o=l,singular:n="row",plural:r=n+"s"})=>{(a>l||a<0)&&(a=0,e(0));const s=j((()=>e(a-o)),[e,a,o],a>0),i=j((()=>e(a+o)),[e,a,o],a+o<l);return b(t.Fragment,null,l>o&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==a,onClick:s},"←"),b("button",{className:"next",disabled:a+o>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+o)," of "),l," ",1!=l?r:n)};class _ extends c{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const ee=e=>new Map(e);ee(),ee(),e.EditableCellView=X,e.EditableValueView=Y,e.RelationshipInHtmlTable=({relationshipId:e,relationships:a,editable:o,customCells:n,className:r,headerRow:s,idColumn:i=!0})=>{const[d,u,m,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(a),e),h=G([...P(m,u),...P(c,u)],n,o?X:l.CellView),g=D(i,h,m,c,e,d,u);return b("table",{className:r},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,m,".Id"),b("th",null,c,".Id")),v(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,y(l.useRowIds(m,u),(e=>b(Q,{key:e,localRowId:e,params:g})))))},e.ResultSortedTableInHtmlTable=({queryId:e,cellId:t,descending:a,offset:o,limit:n,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[c,h,g]=U(t,a,s,o,n,l.useResultRowCount(e,r),i,u);return b(J,{...m,params:D(G(l.useResultTableCellIds(e,r),d,l.ResultCellView),L(r,e),l.useResultSortedRowIds(e,...c,n,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...o})=>b(J,{...o,params:D(G(l.useResultTableCellIds(e,t),a,l.ResultCellView),L(t,e),l.useResultRowIds(e,t))}),e.SliceInHtmlTable=({indexId:e,sliceId:t,indexes:a,editable:o,customCells:n,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(l.useIndexesOrIndexesById(a),e);return b(J,{...r,params:D(G(l.useTableCellIds(d,i),n,o?X:l.CellView),A(i,d),l.useSliceRowIds(e,t,s))})},e.SortedTableInHtmlTable=({tableId:e,cellId:t,descending:a,offset:o,limit:n,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...c})=>{const[h,g,p]=U(t,a,i,o,n,l.useRowCount(e,r),d,u);return b(J,{...c,params:D(G(l.useTableCellIds(e,r),m,s?X:l.CellView),A(r,e),l.useSortedRowIds(e,...h,n,r),h,g,p)})},e.SortedTablePaginator=Z,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:o,...n})=>b(J,{...n,params:D(G(l.useTableCellIds(e,t),o,a?X:l.CellView),A(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:a=(t?Y:l.ValueView),getValueComponentProps:o,className:n,headerRow:r,idColumn:i})=>b("table",{className:n},!1===r?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,y(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(a,{...I(o,t),valueId:t,store:e})))))))},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.React,e.TinyBaseUiReact);
1
+ var e,t;e=this,t=function(e,t,l){"use strict";const a=e=>typeof e,n=a(""),o=a(!0),r=a(0),s="Value",i="currentTarget",d="value",u=isFinite,m=e=>null==e,{PureComponent:c,Fragment:h,createElement:b,useCallback:g,useLayoutEffect:p,useRef:w,useState:f}=t,I=(e,...t)=>m(e)?{}:e(...t),y=(e,t)=>e.map(t),C=Object,k=(e=[])=>C.fromEntries(e),v=(e,t)=>y(C.entries(e),(([e,l])=>t(l,e))),x="tinybaseStoreInspector",T="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",R='content:url("',S=R+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",N='</svg>")',V=R+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",z=y([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>S+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+N)),$=S+"<path d='M20 20l60 60M20 80l60-60' />"+N,M=S+`<path d='${T}' />`+N,q=S+`<path d='${T}M20 20l60 60' />`+N,B="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(v({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[B]:"width:0.5rem;height:0.5rem;",[B+"-track"]:"background:#111",[B+"-thumb"]:"background:#999;border:1px solid #111",[B+"-thumb:hover"]:"background:#fff",[B+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+V,...k(y(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...k(y(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":V,"header>img:nth-of-type(6)":$,...k(y(z,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":M,"details[open]>summary img.done":q,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${x} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${x} ${t}{${e}}`:"")));const H=(e,t,l,a)=>e==n?t:e==r?l:a,{useCallback:O,useMemo:F,useState:E}=t,P="editable",j=(e,t)=>y(l.useTableCellIds(e,t),(t=>e+"."+t)),A=(e,t,l)=>{const a=O(e,t);return l?a:void 0},L=(...e)=>F((()=>e),e),U=(e,t)=>F((()=>({store:e,tableId:t})),[e,t]),D=(e,t)=>F((()=>({queries:e,queryId:t})),[e,t]),G=(e,t=!1,l,a=0,n,o,r,s)=>{const[[i,d,u],m]=E([e,t,a]),c=O((e=>{m(e),s?.(e)}),[s]),h=A((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=O((e=>c([i,d,e])),[c,i,d]),p=!0===r?_:r;return[[i,d,u],h,F((()=>!1===r?null:b(p,{offset:u,limit:n,total:o,onChange:g})),[r,p,u,n,o,g])]},J=(e,t,l)=>F((()=>{const o=t??e;return k(v(Array.isArray(o)?k(y(o,(e=>[e,e]))):o,((e,t)=>{return[t,{label:t,component:l,...(o=e,a(o)==n?{label:e}:e)}];var o})))}),[t,l,e]),K=({className:e,headerRow:t,idColumn:l,params:[a,n,o,r,s,i]})=>b("table",{className:e},i?b("caption",null,i):null,!1===t?null:b("thead",null,b("tr",null,!1===l?null:b(Q,{sort:r??[],label:"Id",onClick:s}),v(a,(({label:e},t)=>b(Q,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),b("tbody",null,y(o,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),v(a,(({component:t,getComponentProps:l},a)=>b("td",{key:a},b(t,{...I(l,e,a),...n,rowId:e,cellId:a}))))))))),Q=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>b("th",{onClick:A((()=>n?.(e)),[n,e],n),className:m(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},m(l)||t!=e?null:(l?"↓":"↑")+" ",a),W=({localRowId:e,params:[a,n,o,r,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===a?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),v(n,(({component:t,getComponentProps:l},a)=>{const[n,s]=a.split(".",2),i=n===o?e:n===r?u:null;return m(i)?null:b("td",{key:a},b(t,{...I(l,i,s),store:d,tableId:n,rowId:i,cellId:s}))})))},X=({thing:e,onThingChange:t,className:l,hasSchema:s,showType:m=!0})=>{const[c,h]=E(),[g,p]=E(),[w,f]=E(),[I,y]=E(),[C,k]=E();g!==e&&(h((e=>{const t=a(e);return(e=>e==n||e==o)(t)||t==r&&u(e)?t:void 0})(e)),p(e),f(e+""),y(Number(e)||0),k(!!e));const v=O(((e,l)=>{l(e),p(e),t(e)}),[t]),x=O((()=>{if(!s?.()){const e=H(c,r,o,n),l=H(e,w,I,C);h(e),p(l),t(l)}}),[s,t,w,I,C,c]);return b("div",{className:l},m?b("button",{className:c,onClick:x},c):null,H(c,b("input",{key:c,value:w,onChange:O((e=>v(e[i][d]+"",f)),[v])}),b("input",{key:c,type:"number",value:I,onChange:O((e=>v(Number(e[i][d]||0),y)),[v])}),b("input",{key:c,type:"checkbox",checked:C,onChange:O((e=>v(!!e[i].checked,k)),[v])})))},Y=({tableId:e,rowId:t,cellId:a,store:n,className:o,showType:r})=>b(X,{thing:l.useCell(e,t,a,n),onThingChange:l.useSetCellCallback(e,t,a,(e=>e),[],n),className:o??P+"Cell",showType:r,hasSchema:l.useStoreOrStoreById(n)?.hasTablesSchema}),Z=({valueId:e,store:t,className:a,showType:n})=>b(X,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:a??P+s,showType:n,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),_=({onChange:e,total:l,offset:a=0,limit:n=l,singular:o="row",plural:r=o+"s"})=>{(a>l||a<0)&&(a=0,e(0));const s=A((()=>e(a-n)),[e,a,n],a>0),i=A((()=>e(a+n)),[e,a,n],a+n<l);return b(t.Fragment,null,l>n&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==a,onClick:s},"←"),b("button",{className:"next",disabled:a+n>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+n)," of "),l," ",1!=l?r:o)},ee=e=>new Map(e);ee(),ee(),e.EditableCellView=Y,e.EditableValueView=Z,e.RelationshipInHtmlTable=({relationshipId:e,relationships:a,editable:n,customCells:o,className:r,headerRow:s,idColumn:i=!0})=>{const[d,u,m,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(a),e),h=J([...j(m,u),...j(c,u)],o,n?Y:l.CellView),g=L(i,h,m,c,e,d,u);return b("table",{className:r},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,m,".Id"),b("th",null,c,".Id")),v(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,y(l.useRowIds(m,u),(e=>b(W,{key:e,localRowId:e,params:g})))))},e.ResultSortedTableInHtmlTable=({queryId:e,cellId:t,descending:a,offset:n,limit:o,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[c,h,g]=G(t,a,s,n,o,l.useResultRowCount(e,r),i,u);return b(K,{...m,params:L(J(l.useResultTableCellIds(e,r),d,l.ResultCellView),D(r,e),l.useResultSortedRowIds(e,...c,o,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...n})=>b(K,{...n,params:L(J(l.useResultTableCellIds(e,t),a,l.ResultCellView),D(t,e),l.useResultRowIds(e,t))}),e.SliceInHtmlTable=({indexId:e,sliceId:t,indexes:a,editable:n,customCells:o,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(l.useIndexesOrIndexesById(a),e);return b(K,{...r,params:L(J(l.useTableCellIds(d,i),o,n?Y:l.CellView),U(i,d),l.useSliceRowIds(e,t,s))})},e.SortedTableInHtmlTable=({tableId:e,cellId:t,descending:a,offset:n,limit:o,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...c})=>{const[h,g,p]=G(t,a,i,n,o,l.useRowCount(e,r),d,u);return b(K,{...c,params:L(J(l.useTableCellIds(e,r),m,s?Y:l.CellView),U(r,e),l.useSortedRowIds(e,...h,o,r),h,g,p)})},e.SortedTablePaginator=_,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:n,...o})=>b(K,{...o,params:L(J(l.useTableCellIds(e,t),n,a?Y:l.CellView),U(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:a=(t?Z:l.ValueView),getValueComponentProps:n,className:o,headerRow:r,idColumn:i})=>b("table",{className:o},!1===r?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,y(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(a,{...I(n,t),valueId:t,store:e})))))))},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.React,e.TinyBaseUiReact);
Binary file