tinybase 5.2.1 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/cjs/es6/min/ui-react/index.cjs +1 -1
  2. package/cjs/es6/min/ui-react/index.cjs.gz +0 -0
  3. package/cjs/es6/min/ui-react/with-schemas/index.cjs +1 -1
  4. package/cjs/es6/min/ui-react/with-schemas/index.cjs.gz +0 -0
  5. package/cjs/es6/ui-react/index.cjs +10 -1
  6. package/cjs/es6/ui-react/with-schemas/index.cjs +10 -1
  7. package/cjs/min/ui-react/index.cjs +1 -1
  8. package/cjs/min/ui-react/index.cjs.gz +0 -0
  9. package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
  10. package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
  11. package/cjs/ui-react/index.cjs +10 -1
  12. package/cjs/ui-react/with-schemas/index.cjs +10 -1
  13. package/es6/min/ui-react/index.js +1 -1
  14. package/es6/min/ui-react/index.js.gz +0 -0
  15. package/es6/min/ui-react/with-schemas/index.js +1 -1
  16. package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  17. package/es6/ui-react/index.js +10 -1
  18. package/es6/ui-react/with-schemas/index.js +10 -1
  19. package/min/ui-react/index.js +1 -1
  20. package/min/ui-react/index.js.gz +0 -0
  21. package/min/ui-react/with-schemas/index.js +1 -1
  22. package/min/ui-react/with-schemas/index.js.gz +0 -0
  23. package/package.json +1 -1
  24. package/readme.md +2 -2
  25. package/ui-react/index.js +10 -1
  26. package/ui-react/with-schemas/index.js +10 -1
  27. package/umd/es6/min/ui-react/index.js +1 -1
  28. package/umd/es6/min/ui-react/index.js.gz +0 -0
  29. package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
  30. package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  31. package/umd/es6/ui-react/index.js +12 -1
  32. package/umd/es6/ui-react/with-schemas/index.js +12 -1
  33. package/umd/min/ui-react/index.js +1 -1
  34. package/umd/min/ui-react/index.js.gz +0 -0
  35. package/umd/min/ui-react/with-schemas/index.js +1 -1
  36. package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
  37. package/umd/ui-react/index.js +12 -1
  38. package/umd/ui-react/with-schemas/index.js +12 -1
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r=t(t),u="Listener",n="Result",d="Has",i="Ids",a="Table",c=a+"s",I=a+i,p="Row",C=p+"Count",b=p+i,w="Sorted"+p+i,R="Cell",k=R+i,v="Value",y=v+"s",g=v+i,h=e=>null==e,m=(e,s,t)=>h(e)?null==t?void 0:t():s(e),L=e=>t(e)==o,f=e=>t(e)==r,S=e=>e.length,T=()=>{},V=(e,s)=>e.every(s),P=(e,s)=>S(e)===S(s)&&V(e,((e,t)=>s[t]===e)),x=(e,s)=>e.map(s),O=Object,q=e=>O.getPrototypeOf(e),B=O.entries,H=e=>!h(e)&&m(q(e),(e=>e==O.prototype||h(q(e))),(()=>!0)),M=O.keys,D=(e,s)=>m(e,(e=>e[s])),j=(e,s)=>{const t=B(e);return S(t)===S(M(s))&&V(t,(([e,t])=>H(t)?!!H(s[e])&&j(s[e],t):s[e]===t))},{createContext:F,useContext:E,useEffect:Q}=s,A=F([]),G=(e,s)=>{var t;const l=E(A);return h(e)?l[s]:L(e)?D(null!=(t=l[s+1])?t:{},e):e},U=(e,s)=>{const t=G(e,s);return h(e)||L(e)?t:e},W=e=>{var s;return M(null!=(s=E(A)[e])?s:{})},z=e=>U(e,0),J=e=>U(e,2),K=e=>U(e,4),N=e=>U(e,6),X=e=>U(e,8),Y=e=>U(e,10),Z=e=>e.toLowerCase();Z(u);const $="Transaction";Z($);var _=(e,s,t)=>new Promise(((l,o)=>{var r=e=>{try{n(t.next(e))}catch(e){o(e)}},u=e=>{try{n(t.throw(e))}catch(e){o(e)}},n=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,u);n((t=t.apply(e,s)).next())}));const{useCallback:ee,useEffect:se,useMemo:te,useLayoutEffect:le,useRef:oe,useState:re,useSyncExternalStore:ue}=s,ne=[],de=[{},[],[ne,void 0,ne],void 0,!1,0],ie=[j,P,([e,s,t],[l,o,r])=>s===o&&P(e,l)&&P(t,r)],ae=(e,s)=>e===s,ce=(e,s,t=ne)=>{const[,l]=re(),[o,r]=re();return se((()=>{const t=e?s(e):void 0;return r(t),l([]),null==t?void 0:t.destroy}),[e,...t]),o},Ie=(e,s,...t)=>{var l;const o=null==(l=null==e?void 0:e["add"+s+u])?void 0:l.call(e,...t);return()=>null==e?void 0:e.delListener(o)},pe=(e,s,t,o=ne)=>{const r=oe(de[t]),u=ee((()=>{var l,u,n;const d=null!=(u=null==(l=null==s?void 0:s[(4==t?"has":"get")+e])?void 0:l.call(s,...o))?u:de[t];return(null!=(n=ie[t])?n:ae)(d,r.current)?r.current:r.current=d}),[s,t,e,...o]),n=ee((r=>Ie(s,(4==t?d:l)+e,...o,r)),[s,t,e,...o]);return ue(n,u)},Ce=(e,s,t,l=ne,o=ne,...r)=>le((()=>Ie(s,e,...o,t,...r)),[s,e,...o,...l,...r]),be=(e,s,t,l=ne,o=T,r=ne,...u)=>{const n=z(e);return ee((e=>m(n,(l=>m(t(e,l),(t=>o(l["set"+s](...we(u,l,e),t),t)))))),[n,s,...l,...r,...Re(u)])},we=(e,s,t)=>x(e,(e=>f(e)?e(t,s):e)),Re=e=>{return s=e=>!f(e),e.filter(s);var s},ke=(e,s,t=T,l=ne,...o)=>{const r=z(e);return ee((e=>t(null==r?void 0:r["del"+s](...we(o,r,e)))),[r,s,...l,...Re(o)])},ve=(e,s,t)=>{const l=Y(e);return ee((()=>null==l?void 0:l[s](t)),[l,s,t])},ye=e=>pe(I,z(e),1),ge=(e,s)=>pe(b,z(s),1,[e]),he=(e,s,t,l=0,o,r)=>pe(w,z(r),1,[e,s,t,l,o]),me=(e,s,t)=>pe(k,z(t),1,[e,s]),Le=(e,s,t,l)=>pe(R,z(l),3,[e,s,t]),fe=e=>pe(g,z(e),1),Se=(e,s)=>pe(v,z(s),3,[e]),Te=(e,s)=>pe("Metric",J(s),3,[e]),Ve=(e,s)=>pe("SliceIds",K(s),1,[e]),Pe=(e,s,t)=>pe("Slice"+b,K(t),1,[e,s]),xe=(e,s,t)=>pe("RemoteRowId",N(t),3,[e,s]),Oe=(e,s,t)=>pe("Local"+b,N(t),1,[e,s]),qe=(e,s,t)=>pe("Linked"+b,N(t),1,[e,s]),Be=(e,s)=>pe(n+b,X(s),1,[e]),He=(e,s,t,l=0,o,r)=>pe(n+w,X(r),1,[e,s,t,l,o]),Me=(e,s,t)=>pe(n+k,X(t),1,[e,s]),De=(e,s,t,l)=>pe(n+R,X(l),3,[e,s,t]),je=e=>pe("CheckpointIds",Y(e),2),Fe=(e,s)=>pe("Checkpoint",Y(s),3,[e]),Ee=e=>ve(e,"goBackward"),Qe=e=>ve(e,"goForward"),{PureComponent:Ae,Fragment:Ge,createElement:Ue,useCallback:We,useLayoutEffect:ze,useRef:Je,useState:Ke}=s,Ne=(e,...s)=>h(e)?{}:e(...s),Xe=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var Ye=Object.defineProperty,Ze=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,es=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable,ts=(e,s,t)=>s in e?Ye(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ls=(e,s)=>{for(var t in s||(s={}))es.call(s,t)&&ts(e,t,s[t]);if(_e)for(var t of _e(s))ss.call(s,t)&&ts(e,t,s[t]);return e},os=(e,s)=>Ze(e,$e(s)),rs=(e,s)=>{var t={};for(var l in e)es.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&_e)for(var l of _e(e))s.indexOf(l)<0&&ss.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:us,useContext:ns,useMemo:ds,useState:is}=s,as=({tableId:e,store:s,rowComponent:t=ws,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>Cs(x(n,(r=>Ue(t,os(ls({},Ne(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),cs=({queryId:e,queries:s,resultRowComponent:t=gs,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>Cs(x(u,(o=>Ue(t,os(ls({},Ne(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),Is=({relationshipId:e,relationships:s,rowComponent:t=ws,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=Xe(N(s),e),c=u(e,n,d);return Cs(x(c,(e=>Ue(t,os(ls({},Ne(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},ps=e=>({checkpoints:s,checkpointComponent:t=hs,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=Y(s);return Cs(x(e(je(u)),(e=>Ue(t,os(ls({},Ne(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},Cs=(e,s,t,l)=>{const o=h(s)||!Array.isArray(e)?e:x(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},bs=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return Cs(l+(null!=(u=Le(e,s,t,o))?u:l),void 0,r,t)},ws=({tableId:e,rowId:s,store:t,cellComponent:l=bs,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>Cs(x(((e,s,t,l)=>{const o=me(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>Ue(l,os(ls({},Ne(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),Rs=e=>as(e,ge(e.tableId,e.store)),ks=({valueId:e,store:s,debugIds:t})=>{var o;return Cs(l+(null!=(o=Se(e,s))?o:l),void 0,t,e)},vs=({indexId:e,sliceId:s,indexes:t,rowComponent:l=ws,getRowComponentProps:o,separator:r,debugIds:u})=>{const[n,d,i]=((e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(s)])(K(t),e),a=Pe(e,s,n);return Cs(x(a,(e=>Ue(l,os(ls({},Ne(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},ys=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return Cs(l+(null!=(u=De(e,s,t,o))?u:l),void 0,r,t)},gs=({queryId:e,rowId:s,queries:t,resultCellComponent:l=ys,getResultCellComponentProps:o,separator:r,debugIds:u})=>Cs(x(Me(e,s,t),(r=>Ue(l,os(ls({},Ne(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),hs=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return Cs(null!=(o=Fe(s,e))?o:l,void 0,t,s)},ms=ps((e=>e[0])),Ls=ps((e=>h(e[1])?[]:[e[1]])),fs=ps((e=>e[2]));e.BackwardCheckpointsView=ms,e.CellView=bs,e.CheckpointView=hs,e.CurrentCheckpointView=Ls,e.ForwardCheckpointsView=fs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=vs,getSliceComponentProps:l,separator:o,debugIds:r})=>Cs(x(Ve(e,s),(o=>Ue(t,os(ls({},Ne(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>Is(e,qe,e.firstRowId),e.LocalRowsView=e=>Is(e,Oe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return Cs(null!=(o=Te(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:s,metrics:t,metricsById:l,indexes:o,indexesById:r,relationships:u,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const p=ns(A),[C,b]=is({}),w=us(((e,s)=>b((t=>D(t,e)==s?t:os(ls({},t),{[e]:s})))),[]),R=us((e=>b((s=>ls({},((e,s)=>(delete e[s],e))(s,e))))),[]);return Ue(A.Provider,{value:ds((()=>[null!=e?e:p[0],ls(ls(ls({},p[1]),s),C),null!=t?t:p[2],ls(ls({},p[3]),l),null!=o?o:p[4],ls(ls({},p[5]),r),null!=u?u:p[6],ls(ls({},p[7]),n),null!=d?d:p[8],ls(ls({},p[9]),i),null!=a?a:p[10],ls(ls({},p[11]),c),w,R]),[e,s,C,t,l,o,r,u,n,d,i,a,c,p,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=ws,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=Xe(N(t),e),i=xe(e,s,u);return Cs(h(d)||h(i)?null:Ue(l,os(ls({},Ne(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=ys,e.ResultRowView=gs,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=rs(s,["cellId","descending","offset","limit"]);return cs(u,He(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>cs(e,Be(e.queryId,e.queries)),e.RowView=ws,e.SliceView=vs,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=rs(s,["cellId","descending","offset","limit"]);return as(u,he(u.tableId,t,l,o,r,u.store))},e.TableView=Rs,e.TablesView=({store:e,tableComponent:s=Rs,getTableComponentProps:t,separator:l,debugIds:o})=>Cs(x(ye(e),(l=>Ue(s,os(ls({},Ne(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=ks,e.ValuesView=({store:e,valueComponent:s=ks,getValueComponentProps:t,separator:l,debugIds:o})=>Cs(x(fe(e),(l=>Ue(s,os(ls({},Ne(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=ne,l,o=T,r=ne,u=!0)=>{const n=z(l);return ee((t=>m(n,(l=>m(s(t,l),(s=>o(l.addRow(f(e)?e(t,l):e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=Le,e.useCellIds=me,e.useCellIdsListener=(e,s,t,l,o,r)=>Ce(k,z(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>Ce(R,z(u),l,o,[e,s,t],r),e.useCheckpoint=Fe,e.useCheckpointIds=je,e.useCheckpointIdsListener=(e,s,t)=>Ce("CheckpointIds",Y(t),e,s),e.useCheckpointListener=(e,s,t,l)=>Ce("Checkpoint",Y(l),s,t,[e]),e.useCheckpoints=e=>G(e,10),e.useCheckpointsIds=()=>W(11),e.useCheckpointsOrCheckpointsById=Y,e.useCreateCheckpoints=(e,s,t)=>ce(e,s,t),e.useCreateIndexes=(e,s,t)=>ce(e,s,t),e.useCreateMergeableStore=(e,s=ne)=>te(e,s),e.useCreateMetrics=(e,s,t)=>ce(e,s,t),e.useCreatePersister=(e,s,t=ne,l,o=ne,r,u=ne)=>{const[,n]=re(),[d,i]=re();return se((()=>{_(void 0,null,(function*(){const t=e?yield s(e):void 0;i(t),t&&l&&_(void 0,null,(function*(){yield l(t),n([])}))}))}),[e,...t,...o]),se((()=>()=>{d&&(d.destroy(),null==r||r(d))}),[d,...u]),d},e.useCreateQueries=(e,s,t)=>ce(e,s,t),e.useCreateRelationships=(e,s,t)=>ce(e,s,t),e.useCreateStore=(e,s=ne)=>te(e,s),e.useCreateSynchronizer=(e,s,t=ne,l,o=ne)=>{const[r,u]=re();return se((()=>{_(void 0,null,(function*(){const t=e?yield s(e):void 0;u(t)}))}),[e,...t]),se((()=>()=>{r&&(r.destroy(),null==l||l(r))}),[r,...o]),r},e.useDelCellCallback=(e,s,t,l,o,r,u)=>ke(o,R,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>ke(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>ke(s,a,t,l,e),e.useDelTablesCallback=(e,s,t)=>ke(e,c,s,t),e.useDelValueCallback=(e,s,t,l)=>ke(s,v,t,l,e),e.useDelValuesCallback=(e,s,t)=>ke(e,y,s,t),e.useDidFinishTransactionListener=(e,s,t)=>Ce("DidFinish"+$,z(t),e,s),e.useGoBackwardCallback=Ee,e.useGoForwardCallback=Qe,e.useGoToCallback=(e,s=ne,t,l=T,o=ne)=>{const r=Y(t);return ee((s=>m(r,(t=>m(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useHasCell=(e,s,t,l)=>pe(R,z(l),4,[e,s,t]),e.useHasCellListener=(e,s,t,l,o,r,u)=>Ce(d+R,z(u),l,o,[e,s,t],r),e.useHasRow=(e,s,t)=>pe(p,z(t),4,[e,s]),e.useHasRowListener=(e,s,t,l,o,r)=>Ce(d+p,z(r),t,l,[e,s],o),e.useHasTable=(e,s)=>pe(a,z(s),4,[e]),e.useHasTableCell=(e,s,t)=>pe(a+R,z(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,l,o,r)=>Ce(d+a+R,z(r),t,l,[e,s],o),e.useHasTableListener=(e,s,t,l,o)=>Ce(d+a,z(o),s,t,[e],l),e.useHasTables=e=>pe(c,z(e),4,[]),e.useHasTablesListener=(e,s,t,l)=>Ce(d+c,z(l),e,s,[],t),e.useHasValue=(e,s)=>pe(v,z(s),4,[e]),e.useHasValueListener=(e,s,t,l,o)=>Ce(d+v,z(o),s,t,[e],l),e.useHasValues=e=>pe(y,z(e),4,[]),e.useHasValuesListener=(e,s,t,l)=>Ce(d+y,z(l),e,s,[],t),e.useIndexIds=e=>pe("IndexIds",K(e),1),e.useIndexes=e=>G(e,4),e.useIndexesIds=()=>W(5),e.useIndexesOrIndexesById=K,e.useLinkedRowIds=qe,e.useLinkedRowIdsListener=(e,s,t,l,o)=>Ce("Linked"+b,N(o),t,l,[e,s]),e.useLocalRowIds=Oe,e.useLocalRowIdsListener=(e,s,t,l,o)=>Ce("Local"+b,N(o),t,l,[e,s]),e.useMetric=Te,e.useMetricIds=e=>pe("MetricIds",J(e),1),e.useMetricListener=(e,s,t,l)=>Ce("Metric",J(l),s,t,[e]),e.useMetrics=e=>G(e,2),e.useMetricsIds=()=>W(3),e.useMetricsOrMetricsById=J,e.useProvideStore=(e,s)=>{const{12:t,13:l}=E(A);Q((()=>(null==t||t(e,s),()=>null==l?void 0:l(e))),[t,e,s,l])},e.useQueries=e=>G(e,8),e.useQueriesIds=()=>W(9),e.useQueriesOrQueriesById=X,e.useQueryIds=e=>pe("QueryIds",X(e),1),e.useRedoInformation=e=>{var s;const t=Y(e),[,,[o]]=je(t);return[!h(o),Qe(t),o,null!=(s=m(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationshipIds=e=>pe("RelationshipIds",N(e),1),e.useRelationships=e=>G(e,6),e.useRelationshipsIds=()=>W(7),e.useRelationshipsOrRelationshipsById=N,e.useRemoteRowId=xe,e.useRemoteRowIdListener=(e,s,t,l,o)=>Ce("RemoteRowId",N(o),t,l,[e,s]),e.useResultCell=De,e.useResultCellIds=Me,e.useResultCellIdsListener=(e,s,t,l,o)=>Ce(n+k,X(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>Ce(n+R,X(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>pe(n+p,X(t),0,[e,s]),e.useResultRowCount=(e,s)=>pe(n+C,X(s),5,[e]),e.useResultRowCountListener=(e,s,t,l)=>Ce(n+C,X(l),s,t,[e]),e.useResultRowIds=Be,e.useResultRowIdsListener=(e,s,t,l)=>Ce(n+b,X(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>Ce(n+p,X(o),t,l,[e,s]),e.useResultSortedRowIds=He,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,u,d)=>Ce(n+w,X(d),r,u,[e,s,t,l,o]),e.useResultTable=(e,s)=>pe(n+a,X(s),0,[e]),e.useResultTableCellIds=(e,s)=>pe(n+a+k,X(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,l)=>Ce(n+a+k,X(l),s,t,[e]),e.useResultTableListener=(e,s,t,l)=>Ce(n+a,X(l),s,t,[e]),e.useRow=(e,s,t)=>pe(p,z(t),0,[e,s]),e.useRowCount=(e,s)=>pe(C,z(s),5,[e]),e.useRowCountListener=(e,s,t,l,o)=>Ce(C,z(o),s,t,[e],l),e.useRowIds=ge,e.useRowIdsListener=(e,s,t,l,o)=>Ce(b,z(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>Ce(p,z(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>be(r,R,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=T,s=ne,t,l=T,o=ne)=>{const r=Y(t);return ee((s=>m(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>be(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>be(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>be(o,p,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>be(l,a,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>be(t,c,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>be(l,v,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>be(t,y,e,s,l,o),e.useSliceIds=Ve,e.useSliceIdsListener=(e,s,t,l)=>Ce("SliceIds",K(l),s,t,[e]),e.useSliceRowIds=Pe,e.useSliceRowIdsListener=(e,s,t,l,o)=>Ce("Slice"+b,K(o),t,l,[e,s]),e.useSortedRowIds=he,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>Ce(w,z(d),r,u,[e,s,t,l,o],n),e.useStartTransactionListener=(e,s,t)=>Ce("Start"+$,z(t),e,s),e.useStore=e=>G(e,0),e.useStoreIds=()=>W(1),e.useStoreOrStoreById=z,e.useTable=(e,s)=>pe(a,z(s),0,[e]),e.useTableCellIds=(e,s)=>pe(a+k,z(s),1,[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>Ce(a+k,z(o),s,t,[e],l),e.useTableIds=ye,e.useTableIdsListener=(e,s,t,l)=>Ce(I,z(l),e,s,ne,t),e.useTableListener=(e,s,t,l,o)=>Ce(a,z(o),s,t,[e],l),e.useTables=e=>pe(c,z(e),0),e.useTablesListener=(e,s,t,l)=>Ce(c,z(l),e,s,ne,t),e.useUndoInformation=e=>{var s;const t=Y(e),[o,r]=je(t);return[(u=o,!(0==S(u))),Ee(t),r,null!=(s=m(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=Se,e.useValueIds=fe,e.useValueIdsListener=(e,s,t,l)=>Ce(g,z(l),e,s,ne,t),e.useValueListener=(e,s,t,l,o)=>Ce(v,z(o),s,t,[e],l),e.useValues=e=>pe(y,z(e),0),e.useValuesListener=(e,s,t,l)=>Ce(y,z(l),e,s,ne,t),e.useWillFinishTransactionListener=(e,s,t)=>Ce("WillFinish"+$,z(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r=t(t),u="Listener",n="Result",d="Has",i="Ids",a="Table",c=a+"s",I=a+i,p="Row",C=p+"Count",b=p+i,w="Sorted"+p+i,R="Cell",k=R+i,v="Value",y=v+"s",g=v+i,h=globalThis,m=e=>null==e,L=(e,s,t)=>m(e)?null==t?void 0:t():s(e),f=e=>t(e)==o,S=e=>t(e)==r,T=e=>e.length,V=()=>{},P=(e,s)=>e.every(s),x=(e,s)=>T(e)===T(s)&&P(e,((e,t)=>s[t]===e)),O=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!m(e)&&L(B(e),(e=>e==q.prototype||m(B(e))),(()=>!0)),D=q.keys,j=(e,s)=>L(e,(e=>e[s])),F=(e,s)=>{const t=H(e);return T(t)===T(D(s))&&P(t,(([e,t])=>M(t)?!!M(s[e])&&F(s[e],t):s[e]===t))},{createContext:E,useContext:Q,useEffect:A}=s,G=(z=()=>E([]),((e,s)=>s in e)(U=h,W="tinybase_uirc")||(U[W]=z()),U[W]);var U,W,z;const _=(e,s)=>{var t;const l=Q(G);return m(e)?l[s]:f(e)?j(null!=(t=l[s+1])?t:{},e):e},J=(e,s)=>{const t=_(e,s);return m(e)||f(e)?t:e},K=e=>{var s;return D(null!=(s=Q(G)[e])?s:{})},N=e=>J(e,0),X=e=>J(e,2),Y=e=>J(e,4),Z=e=>J(e,6),$=e=>J(e,8),ee=e=>J(e,10),se=e=>e.toLowerCase();se(u);const te="Transaction";se(te);var le=(e,s,t)=>new Promise(((l,o)=>{var r=e=>{try{n(t.next(e))}catch(e){o(e)}},u=e=>{try{n(t.throw(e))}catch(e){o(e)}},n=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,u);n((t=t.apply(e,s)).next())}));const{useCallback:oe,useEffect:re,useMemo:ue,useLayoutEffect:ne,useRef:de,useState:ie,useSyncExternalStore:ae}=s,ce=[],Ie=[{},[],[ce,void 0,ce],void 0,!1,0],pe=[F,x,([e,s,t],[l,o,r])=>s===o&&x(e,l)&&x(t,r)],Ce=(e,s)=>e===s,be=(e,s,t=ce)=>{const[,l]=ie(),[o,r]=ie();return re((()=>{const t=e?s(e):void 0;return r(t),l([]),null==t?void 0:t.destroy}),[e,...t]),o},we=(e,s,...t)=>{var l;const o=null==(l=null==e?void 0:e["add"+s+u])?void 0:l.call(e,...t);return()=>null==e?void 0:e.delListener(o)},Re=(e,s,t,o=ce)=>{const r=de(Ie[t]),u=oe((()=>{var l,u,n;const d=null!=(u=null==(l=null==s?void 0:s[(4==t?"has":"get")+e])?void 0:l.call(s,...o))?u:Ie[t];return(null!=(n=pe[t])?n:Ce)(d,r.current)?r.current:r.current=d}),[s,t,e,...o]),n=oe((r=>we(s,(4==t?d:l)+e,...o,r)),[s,t,e,...o]);return ae(n,u)},ke=(e,s,t,l=ce,o=ce,...r)=>ne((()=>we(s,e,...o,t,...r)),[s,e,...o,...l,...r]),ve=(e,s,t,l=ce,o=V,r=ce,...u)=>{const n=N(e);return oe((e=>L(n,(l=>L(t(e,l),(t=>o(l["set"+s](...ye(u,l,e),t),t)))))),[n,s,...l,...r,...ge(u)])},ye=(e,s,t)=>O(e,(e=>S(e)?e(t,s):e)),ge=e=>{return s=e=>!S(e),e.filter(s);var s},he=(e,s,t=V,l=ce,...o)=>{const r=N(e);return oe((e=>t(null==r?void 0:r["del"+s](...ye(o,r,e)))),[r,s,...l,...ge(o)])},me=(e,s,t)=>{const l=ee(e);return oe((()=>null==l?void 0:l[s](t)),[l,s,t])},Le=e=>Re(I,N(e),1),fe=(e,s)=>Re(b,N(s),1,[e]),Se=(e,s,t,l=0,o,r)=>Re(w,N(r),1,[e,s,t,l,o]),Te=(e,s,t)=>Re(k,N(t),1,[e,s]),Ve=(e,s,t,l)=>Re(R,N(l),3,[e,s,t]),Pe=e=>Re(g,N(e),1),xe=(e,s)=>Re(v,N(s),3,[e]),Oe=(e,s)=>Re("Metric",X(s),3,[e]),qe=(e,s)=>Re("SliceIds",Y(s),1,[e]),Be=(e,s,t)=>Re("Slice"+b,Y(t),1,[e,s]),He=(e,s,t)=>Re("RemoteRowId",Z(t),3,[e,s]),Me=(e,s,t)=>Re("Local"+b,Z(t),1,[e,s]),De=(e,s,t)=>Re("Linked"+b,Z(t),1,[e,s]),je=(e,s)=>Re(n+b,$(s),1,[e]),Fe=(e,s,t,l=0,o,r)=>Re(n+w,$(r),1,[e,s,t,l,o]),Ee=(e,s,t)=>Re(n+k,$(t),1,[e,s]),Qe=(e,s,t,l)=>Re(n+R,$(l),3,[e,s,t]),Ae=e=>Re("CheckpointIds",ee(e),2),Ge=(e,s)=>Re("Checkpoint",ee(s),3,[e]),Ue=e=>me(e,"goBackward"),We=e=>me(e,"goForward"),{PureComponent:ze,Fragment:_e,createElement:Je,useCallback:Ke,useLayoutEffect:Ne,useRef:Xe,useState:Ye}=s,Ze=(e,...s)=>m(e)?{}:e(...s),$e=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var es=Object.defineProperty,ss=Object.defineProperties,ts=Object.getOwnPropertyDescriptors,ls=Object.getOwnPropertySymbols,os=Object.prototype.hasOwnProperty,rs=Object.prototype.propertyIsEnumerable,us=(e,s,t)=>s in e?es(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ns=(e,s)=>{for(var t in s||(s={}))os.call(s,t)&&us(e,t,s[t]);if(ls)for(var t of ls(s))rs.call(s,t)&&us(e,t,s[t]);return e},ds=(e,s)=>ss(e,ts(s)),is=(e,s)=>{var t={};for(var l in e)os.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&ls)for(var l of ls(e))s.indexOf(l)<0&&rs.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:as,useContext:cs,useMemo:Is,useState:ps}=s,Cs=({tableId:e,store:s,rowComponent:t=ys,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>ks(O(n,(r=>Je(t,ds(ns({},Ze(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),bs=({queryId:e,queries:s,resultRowComponent:t=fs,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>ks(O(u,(o=>Je(t,ds(ns({},Ze(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),ws=({relationshipId:e,relationships:s,rowComponent:t=ys,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=$e(Z(s),e),c=u(e,n,d);return ks(O(c,(e=>Je(t,ds(ns({},Ze(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},Rs=e=>({checkpoints:s,checkpointComponent:t=Ss,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=ee(s);return ks(O(e(Ae(u)),(e=>Je(t,ds(ns({},Ze(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},ks=(e,s,t,l)=>{const o=m(s)||!Array.isArray(e)?e:O(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},vs=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return ks(l+(null!=(u=Ve(e,s,t,o))?u:l),void 0,r,t)},ys=({tableId:e,rowId:s,store:t,cellComponent:l=vs,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>ks(O(((e,s,t,l)=>{const o=Te(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>Je(l,ds(ns({},Ze(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),gs=e=>Cs(e,fe(e.tableId,e.store)),hs=({valueId:e,store:s,debugIds:t})=>{var o;return ks(l+(null!=(o=xe(e,s))?o:l),void 0,t,e)},ms=({indexId:e,sliceId:s,indexes:t,rowComponent:l=ys,getRowComponentProps:o,separator:r,debugIds:u})=>{const[n,d,i]=((e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(s)])(Y(t),e),a=Be(e,s,n);return ks(O(a,(e=>Je(l,ds(ns({},Ze(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},Ls=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return ks(l+(null!=(u=Qe(e,s,t,o))?u:l),void 0,r,t)},fs=({queryId:e,rowId:s,queries:t,resultCellComponent:l=Ls,getResultCellComponentProps:o,separator:r,debugIds:u})=>ks(O(Ee(e,s,t),(r=>Je(l,ds(ns({},Ze(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),Ss=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return ks(null!=(o=Ge(s,e))?o:l,void 0,t,s)},Ts=Rs((e=>e[0])),Vs=Rs((e=>m(e[1])?[]:[e[1]])),Ps=Rs((e=>e[2]));e.BackwardCheckpointsView=Ts,e.CellView=vs,e.CheckpointView=Ss,e.CurrentCheckpointView=Vs,e.ForwardCheckpointsView=Ps,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=ms,getSliceComponentProps:l,separator:o,debugIds:r})=>ks(O(qe(e,s),(o=>Je(t,ds(ns({},Ze(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>ws(e,De,e.firstRowId),e.LocalRowsView=e=>ws(e,Me,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return ks(null!=(o=Oe(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:s,metrics:t,metricsById:l,indexes:o,indexesById:r,relationships:u,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const p=cs(G),[C,b]=ps({}),w=as(((e,s)=>b((t=>j(t,e)==s?t:ds(ns({},t),{[e]:s})))),[]),R=as((e=>b((s=>ns({},((e,s)=>(delete e[s],e))(s,e))))),[]);return Je(G.Provider,{value:Is((()=>[null!=e?e:p[0],ns(ns(ns({},p[1]),s),C),null!=t?t:p[2],ns(ns({},p[3]),l),null!=o?o:p[4],ns(ns({},p[5]),r),null!=u?u:p[6],ns(ns({},p[7]),n),null!=d?d:p[8],ns(ns({},p[9]),i),null!=a?a:p[10],ns(ns({},p[11]),c),w,R]),[e,s,C,t,l,o,r,u,n,d,i,a,c,p,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=ys,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=$e(Z(t),e),i=He(e,s,u);return ks(m(d)||m(i)?null:Je(l,ds(ns({},Ze(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=Ls,e.ResultRowView=fs,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=is(s,["cellId","descending","offset","limit"]);return bs(u,Fe(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>bs(e,je(e.queryId,e.queries)),e.RowView=ys,e.SliceView=ms,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=is(s,["cellId","descending","offset","limit"]);return Cs(u,Se(u.tableId,t,l,o,r,u.store))},e.TableView=gs,e.TablesView=({store:e,tableComponent:s=gs,getTableComponentProps:t,separator:l,debugIds:o})=>ks(O(Le(e),(l=>Je(s,ds(ns({},Ze(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=hs,e.ValuesView=({store:e,valueComponent:s=hs,getValueComponentProps:t,separator:l,debugIds:o})=>ks(O(Pe(e),(l=>Je(s,ds(ns({},Ze(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=ce,l,o=V,r=ce,u=!0)=>{const n=N(l);return oe((t=>L(n,(l=>L(s(t,l),(s=>o(l.addRow(S(e)?e(t,l):e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=Ve,e.useCellIds=Te,e.useCellIdsListener=(e,s,t,l,o,r)=>ke(k,N(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>ke(R,N(u),l,o,[e,s,t],r),e.useCheckpoint=Ge,e.useCheckpointIds=Ae,e.useCheckpointIdsListener=(e,s,t)=>ke("CheckpointIds",ee(t),e,s),e.useCheckpointListener=(e,s,t,l)=>ke("Checkpoint",ee(l),s,t,[e]),e.useCheckpoints=e=>_(e,10),e.useCheckpointsIds=()=>K(11),e.useCheckpointsOrCheckpointsById=ee,e.useCreateCheckpoints=(e,s,t)=>be(e,s,t),e.useCreateIndexes=(e,s,t)=>be(e,s,t),e.useCreateMergeableStore=(e,s=ce)=>ue(e,s),e.useCreateMetrics=(e,s,t)=>be(e,s,t),e.useCreatePersister=(e,s,t=ce,l,o=ce,r,u=ce)=>{const[,n]=ie(),[d,i]=ie();return re((()=>{le(void 0,null,(function*(){const t=e?yield s(e):void 0;i(t),t&&l&&le(void 0,null,(function*(){yield l(t),n([])}))}))}),[e,...t,...o]),re((()=>()=>{d&&(d.destroy(),null==r||r(d))}),[d,...u]),d},e.useCreateQueries=(e,s,t)=>be(e,s,t),e.useCreateRelationships=(e,s,t)=>be(e,s,t),e.useCreateStore=(e,s=ce)=>ue(e,s),e.useCreateSynchronizer=(e,s,t=ce,l,o=ce)=>{const[r,u]=ie();return re((()=>{le(void 0,null,(function*(){const t=e?yield s(e):void 0;u(t)}))}),[e,...t]),re((()=>()=>{r&&(r.destroy(),null==l||l(r))}),[r,...o]),r},e.useDelCellCallback=(e,s,t,l,o,r,u)=>he(o,R,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>he(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>he(s,a,t,l,e),e.useDelTablesCallback=(e,s,t)=>he(e,c,s,t),e.useDelValueCallback=(e,s,t,l)=>he(s,v,t,l,e),e.useDelValuesCallback=(e,s,t)=>he(e,y,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ke("DidFinish"+te,N(t),e,s),e.useGoBackwardCallback=Ue,e.useGoForwardCallback=We,e.useGoToCallback=(e,s=ce,t,l=V,o=ce)=>{const r=ee(t);return oe((s=>L(r,(t=>L(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useHasCell=(e,s,t,l)=>Re(R,N(l),4,[e,s,t]),e.useHasCellListener=(e,s,t,l,o,r,u)=>ke(d+R,N(u),l,o,[e,s,t],r),e.useHasRow=(e,s,t)=>Re(p,N(t),4,[e,s]),e.useHasRowListener=(e,s,t,l,o,r)=>ke(d+p,N(r),t,l,[e,s],o),e.useHasTable=(e,s)=>Re(a,N(s),4,[e]),e.useHasTableCell=(e,s,t)=>Re(a+R,N(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,l,o,r)=>ke(d+a+R,N(r),t,l,[e,s],o),e.useHasTableListener=(e,s,t,l,o)=>ke(d+a,N(o),s,t,[e],l),e.useHasTables=e=>Re(c,N(e),4,[]),e.useHasTablesListener=(e,s,t,l)=>ke(d+c,N(l),e,s,[],t),e.useHasValue=(e,s)=>Re(v,N(s),4,[e]),e.useHasValueListener=(e,s,t,l,o)=>ke(d+v,N(o),s,t,[e],l),e.useHasValues=e=>Re(y,N(e),4,[]),e.useHasValuesListener=(e,s,t,l)=>ke(d+y,N(l),e,s,[],t),e.useIndexIds=e=>Re("IndexIds",Y(e),1),e.useIndexes=e=>_(e,4),e.useIndexesIds=()=>K(5),e.useIndexesOrIndexesById=Y,e.useLinkedRowIds=De,e.useLinkedRowIdsListener=(e,s,t,l,o)=>ke("Linked"+b,Z(o),t,l,[e,s]),e.useLocalRowIds=Me,e.useLocalRowIdsListener=(e,s,t,l,o)=>ke("Local"+b,Z(o),t,l,[e,s]),e.useMetric=Oe,e.useMetricIds=e=>Re("MetricIds",X(e),1),e.useMetricListener=(e,s,t,l)=>ke("Metric",X(l),s,t,[e]),e.useMetrics=e=>_(e,2),e.useMetricsIds=()=>K(3),e.useMetricsOrMetricsById=X,e.useProvideStore=(e,s)=>{const{12:t,13:l}=Q(G);A((()=>(null==t||t(e,s),()=>null==l?void 0:l(e))),[t,e,s,l])},e.useQueries=e=>_(e,8),e.useQueriesIds=()=>K(9),e.useQueriesOrQueriesById=$,e.useQueryIds=e=>Re("QueryIds",$(e),1),e.useRedoInformation=e=>{var s;const t=ee(e),[,,[o]]=Ae(t);return[!m(o),We(t),o,null!=(s=L(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationshipIds=e=>Re("RelationshipIds",Z(e),1),e.useRelationships=e=>_(e,6),e.useRelationshipsIds=()=>K(7),e.useRelationshipsOrRelationshipsById=Z,e.useRemoteRowId=He,e.useRemoteRowIdListener=(e,s,t,l,o)=>ke("RemoteRowId",Z(o),t,l,[e,s]),e.useResultCell=Qe,e.useResultCellIds=Ee,e.useResultCellIdsListener=(e,s,t,l,o)=>ke(n+k,$(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>ke(n+R,$(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>Re(n+p,$(t),0,[e,s]),e.useResultRowCount=(e,s)=>Re(n+C,$(s),5,[e]),e.useResultRowCountListener=(e,s,t,l)=>ke(n+C,$(l),s,t,[e]),e.useResultRowIds=je,e.useResultRowIdsListener=(e,s,t,l)=>ke(n+b,$(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>ke(n+p,$(o),t,l,[e,s]),e.useResultSortedRowIds=Fe,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,u,d)=>ke(n+w,$(d),r,u,[e,s,t,l,o]),e.useResultTable=(e,s)=>Re(n+a,$(s),0,[e]),e.useResultTableCellIds=(e,s)=>Re(n+a+k,$(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,l)=>ke(n+a+k,$(l),s,t,[e]),e.useResultTableListener=(e,s,t,l)=>ke(n+a,$(l),s,t,[e]),e.useRow=(e,s,t)=>Re(p,N(t),0,[e,s]),e.useRowCount=(e,s)=>Re(C,N(s),5,[e]),e.useRowCountListener=(e,s,t,l,o)=>ke(C,N(o),s,t,[e],l),e.useRowIds=fe,e.useRowIdsListener=(e,s,t,l,o)=>ke(b,N(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>ke(p,N(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>ve(r,R,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=V,s=ce,t,l=V,o=ce)=>{const r=ee(t);return oe((s=>L(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>ve(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>ve(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>ve(o,p,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>ve(l,a,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>ve(t,c,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>ve(l,v,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>ve(t,y,e,s,l,o),e.useSliceIds=qe,e.useSliceIdsListener=(e,s,t,l)=>ke("SliceIds",Y(l),s,t,[e]),e.useSliceRowIds=Be,e.useSliceRowIdsListener=(e,s,t,l,o)=>ke("Slice"+b,Y(o),t,l,[e,s]),e.useSortedRowIds=Se,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>ke(w,N(d),r,u,[e,s,t,l,o],n),e.useStartTransactionListener=(e,s,t)=>ke("Start"+te,N(t),e,s),e.useStore=e=>_(e,0),e.useStoreIds=()=>K(1),e.useStoreOrStoreById=N,e.useTable=(e,s)=>Re(a,N(s),0,[e]),e.useTableCellIds=(e,s)=>Re(a+k,N(s),1,[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>ke(a+k,N(o),s,t,[e],l),e.useTableIds=Le,e.useTableIdsListener=(e,s,t,l)=>ke(I,N(l),e,s,ce,t),e.useTableListener=(e,s,t,l,o)=>ke(a,N(o),s,t,[e],l),e.useTables=e=>Re(c,N(e),0),e.useTablesListener=(e,s,t,l)=>ke(c,N(l),e,s,ce,t),e.useUndoInformation=e=>{var s;const t=ee(e),[o,r]=Ae(t);return[(u=o,!(0==T(u))),Ue(t),r,null!=(s=L(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=xe,e.useValueIds=Pe,e.useValueIdsListener=(e,s,t,l)=>ke(g,N(l),e,s,ce,t),e.useValueListener=(e,s,t,l,o)=>ke(v,N(o),s,t,[e],l),e.useValues=e=>Re(y,N(e),0),e.useValuesListener=(e,s,t,l)=>ke(y,N(l),e,s,ce,t),e.useWillFinishTransactionListener=(e,s,t)=>ke("WillFinish"+te,N(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
Binary file
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r=t(t),u="Listener",n="Result",d="Has",i="Ids",a="Table",c=a+"s",I=a+i,p="Row",C=p+"Count",b=p+i,w="Sorted"+p+i,R="Cell",k=R+i,v="Value",y=v+"s",g=v+i,h=e=>null==e,m=(e,s,t)=>h(e)?null==t?void 0:t():s(e),L=e=>t(e)==o,f=e=>t(e)==r,S=e=>e.length,T=()=>{},V=(e,s)=>e.every(s),P=(e,s)=>S(e)===S(s)&&V(e,((e,t)=>s[t]===e)),x=(e,s)=>e.map(s),O=Object,q=e=>O.getPrototypeOf(e),B=O.entries,H=e=>!h(e)&&m(q(e),(e=>e==O.prototype||h(q(e))),(()=>!0)),M=O.keys,D=(e,s)=>m(e,(e=>e[s])),j=(e,s)=>{const t=B(e);return S(t)===S(M(s))&&V(t,(([e,t])=>H(t)?!!H(s[e])&&j(s[e],t):s[e]===t))},{createContext:F,useContext:E,useEffect:Q}=s,A=F([]),G=(e,s)=>{var t;const l=E(A);return h(e)?l[s]:L(e)?D(null!=(t=l[s+1])?t:{},e):e},U=(e,s)=>{const t=G(e,s);return h(e)||L(e)?t:e},W=e=>{var s;return M(null!=(s=E(A)[e])?s:{})},z=e=>U(e,0),J=e=>U(e,2),K=e=>U(e,4),N=e=>U(e,6),X=e=>U(e,8),Y=e=>U(e,10),Z=e=>e.toLowerCase();Z(u);const $="Transaction";Z($);var _=(e,s,t)=>new Promise(((l,o)=>{var r=e=>{try{n(t.next(e))}catch(e){o(e)}},u=e=>{try{n(t.throw(e))}catch(e){o(e)}},n=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,u);n((t=t.apply(e,s)).next())}));const{useCallback:ee,useEffect:se,useMemo:te,useLayoutEffect:le,useRef:oe,useState:re,useSyncExternalStore:ue}=s,ne=[],de=[{},[],[ne,void 0,ne],void 0,!1,0],ie=[j,P,([e,s,t],[l,o,r])=>s===o&&P(e,l)&&P(t,r)],ae=(e,s)=>e===s,ce=(e,s,t=ne)=>{const[,l]=re(),[o,r]=re();return se((()=>{const t=e?s(e):void 0;return r(t),l([]),null==t?void 0:t.destroy}),[e,...t]),o},Ie=(e,s,...t)=>{var l;const o=null==(l=null==e?void 0:e["add"+s+u])?void 0:l.call(e,...t);return()=>null==e?void 0:e.delListener(o)},pe=(e,s,t,o=ne)=>{const r=oe(de[t]),u=ee((()=>{var l,u,n;const d=null!=(u=null==(l=null==s?void 0:s[(4==t?"has":"get")+e])?void 0:l.call(s,...o))?u:de[t];return(null!=(n=ie[t])?n:ae)(d,r.current)?r.current:r.current=d}),[s,t,e,...o]),n=ee((r=>Ie(s,(4==t?d:l)+e,...o,r)),[s,t,e,...o]);return ue(n,u)},Ce=(e,s,t,l=ne,o=ne,...r)=>le((()=>Ie(s,e,...o,t,...r)),[s,e,...o,...l,...r]),be=(e,s,t,l=ne,o=T,r=ne,...u)=>{const n=z(e);return ee((e=>m(n,(l=>m(t(e,l),(t=>o(l["set"+s](...we(u,l,e),t),t)))))),[n,s,...l,...r,...Re(u)])},we=(e,s,t)=>x(e,(e=>f(e)?e(t,s):e)),Re=e=>{return s=e=>!f(e),e.filter(s);var s},ke=(e,s,t=T,l=ne,...o)=>{const r=z(e);return ee((e=>t(null==r?void 0:r["del"+s](...we(o,r,e)))),[r,s,...l,...Re(o)])},ve=(e,s,t)=>{const l=Y(e);return ee((()=>null==l?void 0:l[s](t)),[l,s,t])},ye=e=>pe(I,z(e),1),ge=(e,s)=>pe(b,z(s),1,[e]),he=(e,s,t,l=0,o,r)=>pe(w,z(r),1,[e,s,t,l,o]),me=(e,s,t)=>pe(k,z(t),1,[e,s]),Le=(e,s,t,l)=>pe(R,z(l),3,[e,s,t]),fe=e=>pe(g,z(e),1),Se=(e,s)=>pe(v,z(s),3,[e]),Te=(e,s)=>pe("Metric",J(s),3,[e]),Ve=(e,s)=>pe("SliceIds",K(s),1,[e]),Pe=(e,s,t)=>pe("Slice"+b,K(t),1,[e,s]),xe=(e,s,t)=>pe("RemoteRowId",N(t),3,[e,s]),Oe=(e,s,t)=>pe("Local"+b,N(t),1,[e,s]),qe=(e,s,t)=>pe("Linked"+b,N(t),1,[e,s]),Be=(e,s)=>pe(n+b,X(s),1,[e]),He=(e,s,t,l=0,o,r)=>pe(n+w,X(r),1,[e,s,t,l,o]),Me=(e,s,t)=>pe(n+k,X(t),1,[e,s]),De=(e,s,t,l)=>pe(n+R,X(l),3,[e,s,t]),je=e=>pe("CheckpointIds",Y(e),2),Fe=(e,s)=>pe("Checkpoint",Y(s),3,[e]),Ee=e=>ve(e,"goBackward"),Qe=e=>ve(e,"goForward"),{PureComponent:Ae,Fragment:Ge,createElement:Ue,useCallback:We,useLayoutEffect:ze,useRef:Je,useState:Ke}=s,Ne=(e,...s)=>h(e)?{}:e(...s),Xe=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var Ye=Object.defineProperty,Ze=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,es=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable,ts=(e,s,t)=>s in e?Ye(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ls=(e,s)=>{for(var t in s||(s={}))es.call(s,t)&&ts(e,t,s[t]);if(_e)for(var t of _e(s))ss.call(s,t)&&ts(e,t,s[t]);return e},os=(e,s)=>Ze(e,$e(s)),rs=(e,s)=>{var t={};for(var l in e)es.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&_e)for(var l of _e(e))s.indexOf(l)<0&&ss.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:us,useContext:ns,useMemo:ds,useState:is}=s,as=({tableId:e,store:s,rowComponent:t=ws,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>Cs(x(n,(r=>Ue(t,os(ls({},Ne(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),cs=({queryId:e,queries:s,resultRowComponent:t=gs,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>Cs(x(u,(o=>Ue(t,os(ls({},Ne(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),Is=({relationshipId:e,relationships:s,rowComponent:t=ws,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=Xe(N(s),e),c=u(e,n,d);return Cs(x(c,(e=>Ue(t,os(ls({},Ne(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},ps=e=>({checkpoints:s,checkpointComponent:t=hs,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=Y(s);return Cs(x(e(je(u)),(e=>Ue(t,os(ls({},Ne(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},Cs=(e,s,t,l)=>{const o=h(s)||!Array.isArray(e)?e:x(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},bs=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return Cs(l+(null!=(u=Le(e,s,t,o))?u:l),void 0,r,t)},ws=({tableId:e,rowId:s,store:t,cellComponent:l=bs,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>Cs(x(((e,s,t,l)=>{const o=me(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>Ue(l,os(ls({},Ne(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),Rs=e=>as(e,ge(e.tableId,e.store)),ks=({valueId:e,store:s,debugIds:t})=>{var o;return Cs(l+(null!=(o=Se(e,s))?o:l),void 0,t,e)},vs=({indexId:e,sliceId:s,indexes:t,rowComponent:l=ws,getRowComponentProps:o,separator:r,debugIds:u})=>{const[n,d,i]=((e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(s)])(K(t),e),a=Pe(e,s,n);return Cs(x(a,(e=>Ue(l,os(ls({},Ne(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},ys=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return Cs(l+(null!=(u=De(e,s,t,o))?u:l),void 0,r,t)},gs=({queryId:e,rowId:s,queries:t,resultCellComponent:l=ys,getResultCellComponentProps:o,separator:r,debugIds:u})=>Cs(x(Me(e,s,t),(r=>Ue(l,os(ls({},Ne(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),hs=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return Cs(null!=(o=Fe(s,e))?o:l,void 0,t,s)},ms=ps((e=>e[0])),Ls=ps((e=>h(e[1])?[]:[e[1]])),fs=ps((e=>e[2]));e.BackwardCheckpointsView=ms,e.CellView=bs,e.CheckpointView=hs,e.CurrentCheckpointView=Ls,e.ForwardCheckpointsView=fs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=vs,getSliceComponentProps:l,separator:o,debugIds:r})=>Cs(x(Ve(e,s),(o=>Ue(t,os(ls({},Ne(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>Is(e,qe,e.firstRowId),e.LocalRowsView=e=>Is(e,Oe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return Cs(null!=(o=Te(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:s,metrics:t,metricsById:l,indexes:o,indexesById:r,relationships:u,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const p=ns(A),[C,b]=is({}),w=us(((e,s)=>b((t=>D(t,e)==s?t:os(ls({},t),{[e]:s})))),[]),R=us((e=>b((s=>ls({},((e,s)=>(delete e[s],e))(s,e))))),[]);return Ue(A.Provider,{value:ds((()=>[null!=e?e:p[0],ls(ls(ls({},p[1]),s),C),null!=t?t:p[2],ls(ls({},p[3]),l),null!=o?o:p[4],ls(ls({},p[5]),r),null!=u?u:p[6],ls(ls({},p[7]),n),null!=d?d:p[8],ls(ls({},p[9]),i),null!=a?a:p[10],ls(ls({},p[11]),c),w,R]),[e,s,C,t,l,o,r,u,n,d,i,a,c,p,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=ws,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=Xe(N(t),e),i=xe(e,s,u);return Cs(h(d)||h(i)?null:Ue(l,os(ls({},Ne(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=ys,e.ResultRowView=gs,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=rs(s,["cellId","descending","offset","limit"]);return cs(u,He(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>cs(e,Be(e.queryId,e.queries)),e.RowView=ws,e.SliceView=vs,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=rs(s,["cellId","descending","offset","limit"]);return as(u,he(u.tableId,t,l,o,r,u.store))},e.TableView=Rs,e.TablesView=({store:e,tableComponent:s=Rs,getTableComponentProps:t,separator:l,debugIds:o})=>Cs(x(ye(e),(l=>Ue(s,os(ls({},Ne(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=ks,e.ValuesView=({store:e,valueComponent:s=ks,getValueComponentProps:t,separator:l,debugIds:o})=>Cs(x(fe(e),(l=>Ue(s,os(ls({},Ne(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=ne,l,o=T,r=ne,u=!0)=>{const n=z(l);return ee((t=>m(n,(l=>m(s(t,l),(s=>o(l.addRow(f(e)?e(t,l):e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=Le,e.useCellIds=me,e.useCellIdsListener=(e,s,t,l,o,r)=>Ce(k,z(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>Ce(R,z(u),l,o,[e,s,t],r),e.useCheckpoint=Fe,e.useCheckpointIds=je,e.useCheckpointIdsListener=(e,s,t)=>Ce("CheckpointIds",Y(t),e,s),e.useCheckpointListener=(e,s,t,l)=>Ce("Checkpoint",Y(l),s,t,[e]),e.useCheckpoints=e=>G(e,10),e.useCheckpointsIds=()=>W(11),e.useCheckpointsOrCheckpointsById=Y,e.useCreateCheckpoints=(e,s,t)=>ce(e,s,t),e.useCreateIndexes=(e,s,t)=>ce(e,s,t),e.useCreateMergeableStore=(e,s=ne)=>te(e,s),e.useCreateMetrics=(e,s,t)=>ce(e,s,t),e.useCreatePersister=(e,s,t=ne,l,o=ne,r,u=ne)=>{const[,n]=re(),[d,i]=re();return se((()=>{_(void 0,null,(function*(){const t=e?yield s(e):void 0;i(t),t&&l&&_(void 0,null,(function*(){yield l(t),n([])}))}))}),[e,...t,...o]),se((()=>()=>{d&&(d.destroy(),null==r||r(d))}),[d,...u]),d},e.useCreateQueries=(e,s,t)=>ce(e,s,t),e.useCreateRelationships=(e,s,t)=>ce(e,s,t),e.useCreateStore=(e,s=ne)=>te(e,s),e.useCreateSynchronizer=(e,s,t=ne,l,o=ne)=>{const[r,u]=re();return se((()=>{_(void 0,null,(function*(){const t=e?yield s(e):void 0;u(t)}))}),[e,...t]),se((()=>()=>{r&&(r.destroy(),null==l||l(r))}),[r,...o]),r},e.useDelCellCallback=(e,s,t,l,o,r,u)=>ke(o,R,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>ke(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>ke(s,a,t,l,e),e.useDelTablesCallback=(e,s,t)=>ke(e,c,s,t),e.useDelValueCallback=(e,s,t,l)=>ke(s,v,t,l,e),e.useDelValuesCallback=(e,s,t)=>ke(e,y,s,t),e.useDidFinishTransactionListener=(e,s,t)=>Ce("DidFinish"+$,z(t),e,s),e.useGoBackwardCallback=Ee,e.useGoForwardCallback=Qe,e.useGoToCallback=(e,s=ne,t,l=T,o=ne)=>{const r=Y(t);return ee((s=>m(r,(t=>m(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useHasCell=(e,s,t,l)=>pe(R,z(l),4,[e,s,t]),e.useHasCellListener=(e,s,t,l,o,r,u)=>Ce(d+R,z(u),l,o,[e,s,t],r),e.useHasRow=(e,s,t)=>pe(p,z(t),4,[e,s]),e.useHasRowListener=(e,s,t,l,o,r)=>Ce(d+p,z(r),t,l,[e,s],o),e.useHasTable=(e,s)=>pe(a,z(s),4,[e]),e.useHasTableCell=(e,s,t)=>pe(a+R,z(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,l,o,r)=>Ce(d+a+R,z(r),t,l,[e,s],o),e.useHasTableListener=(e,s,t,l,o)=>Ce(d+a,z(o),s,t,[e],l),e.useHasTables=e=>pe(c,z(e),4,[]),e.useHasTablesListener=(e,s,t,l)=>Ce(d+c,z(l),e,s,[],t),e.useHasValue=(e,s)=>pe(v,z(s),4,[e]),e.useHasValueListener=(e,s,t,l,o)=>Ce(d+v,z(o),s,t,[e],l),e.useHasValues=e=>pe(y,z(e),4,[]),e.useHasValuesListener=(e,s,t,l)=>Ce(d+y,z(l),e,s,[],t),e.useIndexIds=e=>pe("IndexIds",K(e),1),e.useIndexes=e=>G(e,4),e.useIndexesIds=()=>W(5),e.useIndexesOrIndexesById=K,e.useLinkedRowIds=qe,e.useLinkedRowIdsListener=(e,s,t,l,o)=>Ce("Linked"+b,N(o),t,l,[e,s]),e.useLocalRowIds=Oe,e.useLocalRowIdsListener=(e,s,t,l,o)=>Ce("Local"+b,N(o),t,l,[e,s]),e.useMetric=Te,e.useMetricIds=e=>pe("MetricIds",J(e),1),e.useMetricListener=(e,s,t,l)=>Ce("Metric",J(l),s,t,[e]),e.useMetrics=e=>G(e,2),e.useMetricsIds=()=>W(3),e.useMetricsOrMetricsById=J,e.useProvideStore=(e,s)=>{const{12:t,13:l}=E(A);Q((()=>(null==t||t(e,s),()=>null==l?void 0:l(e))),[t,e,s,l])},e.useQueries=e=>G(e,8),e.useQueriesIds=()=>W(9),e.useQueriesOrQueriesById=X,e.useQueryIds=e=>pe("QueryIds",X(e),1),e.useRedoInformation=e=>{var s;const t=Y(e),[,,[o]]=je(t);return[!h(o),Qe(t),o,null!=(s=m(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationshipIds=e=>pe("RelationshipIds",N(e),1),e.useRelationships=e=>G(e,6),e.useRelationshipsIds=()=>W(7),e.useRelationshipsOrRelationshipsById=N,e.useRemoteRowId=xe,e.useRemoteRowIdListener=(e,s,t,l,o)=>Ce("RemoteRowId",N(o),t,l,[e,s]),e.useResultCell=De,e.useResultCellIds=Me,e.useResultCellIdsListener=(e,s,t,l,o)=>Ce(n+k,X(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>Ce(n+R,X(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>pe(n+p,X(t),0,[e,s]),e.useResultRowCount=(e,s)=>pe(n+C,X(s),5,[e]),e.useResultRowCountListener=(e,s,t,l)=>Ce(n+C,X(l),s,t,[e]),e.useResultRowIds=Be,e.useResultRowIdsListener=(e,s,t,l)=>Ce(n+b,X(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>Ce(n+p,X(o),t,l,[e,s]),e.useResultSortedRowIds=He,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,u,d)=>Ce(n+w,X(d),r,u,[e,s,t,l,o]),e.useResultTable=(e,s)=>pe(n+a,X(s),0,[e]),e.useResultTableCellIds=(e,s)=>pe(n+a+k,X(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,l)=>Ce(n+a+k,X(l),s,t,[e]),e.useResultTableListener=(e,s,t,l)=>Ce(n+a,X(l),s,t,[e]),e.useRow=(e,s,t)=>pe(p,z(t),0,[e,s]),e.useRowCount=(e,s)=>pe(C,z(s),5,[e]),e.useRowCountListener=(e,s,t,l,o)=>Ce(C,z(o),s,t,[e],l),e.useRowIds=ge,e.useRowIdsListener=(e,s,t,l,o)=>Ce(b,z(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>Ce(p,z(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>be(r,R,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=T,s=ne,t,l=T,o=ne)=>{const r=Y(t);return ee((s=>m(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>be(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>be(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>be(o,p,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>be(l,a,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>be(t,c,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>be(l,v,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>be(t,y,e,s,l,o),e.useSliceIds=Ve,e.useSliceIdsListener=(e,s,t,l)=>Ce("SliceIds",K(l),s,t,[e]),e.useSliceRowIds=Pe,e.useSliceRowIdsListener=(e,s,t,l,o)=>Ce("Slice"+b,K(o),t,l,[e,s]),e.useSortedRowIds=he,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>Ce(w,z(d),r,u,[e,s,t,l,o],n),e.useStartTransactionListener=(e,s,t)=>Ce("Start"+$,z(t),e,s),e.useStore=e=>G(e,0),e.useStoreIds=()=>W(1),e.useStoreOrStoreById=z,e.useTable=(e,s)=>pe(a,z(s),0,[e]),e.useTableCellIds=(e,s)=>pe(a+k,z(s),1,[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>Ce(a+k,z(o),s,t,[e],l),e.useTableIds=ye,e.useTableIdsListener=(e,s,t,l)=>Ce(I,z(l),e,s,ne,t),e.useTableListener=(e,s,t,l,o)=>Ce(a,z(o),s,t,[e],l),e.useTables=e=>pe(c,z(e),0),e.useTablesListener=(e,s,t,l)=>Ce(c,z(l),e,s,ne,t),e.useUndoInformation=e=>{var s;const t=Y(e),[o,r]=je(t);return[(u=o,!(0==S(u))),Ee(t),r,null!=(s=m(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=Se,e.useValueIds=fe,e.useValueIdsListener=(e,s,t,l)=>Ce(g,z(l),e,s,ne,t),e.useValueListener=(e,s,t,l,o)=>Ce(v,z(o),s,t,[e],l),e.useValues=e=>pe(y,z(e),0),e.useValuesListener=(e,s,t,l)=>Ce(y,z(l),e,s,ne,t),e.useWillFinishTransactionListener=(e,s,t)=>Ce("WillFinish"+$,z(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,l="",o=t(l),r=t(t),u="Listener",n="Result",d="Has",i="Ids",a="Table",c=a+"s",I=a+i,p="Row",C=p+"Count",b=p+i,w="Sorted"+p+i,R="Cell",k=R+i,v="Value",y=v+"s",g=v+i,h=globalThis,m=e=>null==e,L=(e,s,t)=>m(e)?null==t?void 0:t():s(e),f=e=>t(e)==o,S=e=>t(e)==r,T=e=>e.length,V=()=>{},P=(e,s)=>e.every(s),x=(e,s)=>T(e)===T(s)&&P(e,((e,t)=>s[t]===e)),O=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!m(e)&&L(B(e),(e=>e==q.prototype||m(B(e))),(()=>!0)),D=q.keys,j=(e,s)=>L(e,(e=>e[s])),F=(e,s)=>{const t=H(e);return T(t)===T(D(s))&&P(t,(([e,t])=>M(t)?!!M(s[e])&&F(s[e],t):s[e]===t))},{createContext:E,useContext:Q,useEffect:A}=s,G=(z=()=>E([]),((e,s)=>s in e)(U=h,W="tinybase_uirc")||(U[W]=z()),U[W]);var U,W,z;const _=(e,s)=>{var t;const l=Q(G);return m(e)?l[s]:f(e)?j(null!=(t=l[s+1])?t:{},e):e},J=(e,s)=>{const t=_(e,s);return m(e)||f(e)?t:e},K=e=>{var s;return D(null!=(s=Q(G)[e])?s:{})},N=e=>J(e,0),X=e=>J(e,2),Y=e=>J(e,4),Z=e=>J(e,6),$=e=>J(e,8),ee=e=>J(e,10),se=e=>e.toLowerCase();se(u);const te="Transaction";se(te);var le=(e,s,t)=>new Promise(((l,o)=>{var r=e=>{try{n(t.next(e))}catch(e){o(e)}},u=e=>{try{n(t.throw(e))}catch(e){o(e)}},n=e=>e.done?l(e.value):Promise.resolve(e.value).then(r,u);n((t=t.apply(e,s)).next())}));const{useCallback:oe,useEffect:re,useMemo:ue,useLayoutEffect:ne,useRef:de,useState:ie,useSyncExternalStore:ae}=s,ce=[],Ie=[{},[],[ce,void 0,ce],void 0,!1,0],pe=[F,x,([e,s,t],[l,o,r])=>s===o&&x(e,l)&&x(t,r)],Ce=(e,s)=>e===s,be=(e,s,t=ce)=>{const[,l]=ie(),[o,r]=ie();return re((()=>{const t=e?s(e):void 0;return r(t),l([]),null==t?void 0:t.destroy}),[e,...t]),o},we=(e,s,...t)=>{var l;const o=null==(l=null==e?void 0:e["add"+s+u])?void 0:l.call(e,...t);return()=>null==e?void 0:e.delListener(o)},Re=(e,s,t,o=ce)=>{const r=de(Ie[t]),u=oe((()=>{var l,u,n;const d=null!=(u=null==(l=null==s?void 0:s[(4==t?"has":"get")+e])?void 0:l.call(s,...o))?u:Ie[t];return(null!=(n=pe[t])?n:Ce)(d,r.current)?r.current:r.current=d}),[s,t,e,...o]),n=oe((r=>we(s,(4==t?d:l)+e,...o,r)),[s,t,e,...o]);return ae(n,u)},ke=(e,s,t,l=ce,o=ce,...r)=>ne((()=>we(s,e,...o,t,...r)),[s,e,...o,...l,...r]),ve=(e,s,t,l=ce,o=V,r=ce,...u)=>{const n=N(e);return oe((e=>L(n,(l=>L(t(e,l),(t=>o(l["set"+s](...ye(u,l,e),t),t)))))),[n,s,...l,...r,...ge(u)])},ye=(e,s,t)=>O(e,(e=>S(e)?e(t,s):e)),ge=e=>{return s=e=>!S(e),e.filter(s);var s},he=(e,s,t=V,l=ce,...o)=>{const r=N(e);return oe((e=>t(null==r?void 0:r["del"+s](...ye(o,r,e)))),[r,s,...l,...ge(o)])},me=(e,s,t)=>{const l=ee(e);return oe((()=>null==l?void 0:l[s](t)),[l,s,t])},Le=e=>Re(I,N(e),1),fe=(e,s)=>Re(b,N(s),1,[e]),Se=(e,s,t,l=0,o,r)=>Re(w,N(r),1,[e,s,t,l,o]),Te=(e,s,t)=>Re(k,N(t),1,[e,s]),Ve=(e,s,t,l)=>Re(R,N(l),3,[e,s,t]),Pe=e=>Re(g,N(e),1),xe=(e,s)=>Re(v,N(s),3,[e]),Oe=(e,s)=>Re("Metric",X(s),3,[e]),qe=(e,s)=>Re("SliceIds",Y(s),1,[e]),Be=(e,s,t)=>Re("Slice"+b,Y(t),1,[e,s]),He=(e,s,t)=>Re("RemoteRowId",Z(t),3,[e,s]),Me=(e,s,t)=>Re("Local"+b,Z(t),1,[e,s]),De=(e,s,t)=>Re("Linked"+b,Z(t),1,[e,s]),je=(e,s)=>Re(n+b,$(s),1,[e]),Fe=(e,s,t,l=0,o,r)=>Re(n+w,$(r),1,[e,s,t,l,o]),Ee=(e,s,t)=>Re(n+k,$(t),1,[e,s]),Qe=(e,s,t,l)=>Re(n+R,$(l),3,[e,s,t]),Ae=e=>Re("CheckpointIds",ee(e),2),Ge=(e,s)=>Re("Checkpoint",ee(s),3,[e]),Ue=e=>me(e,"goBackward"),We=e=>me(e,"goForward"),{PureComponent:ze,Fragment:_e,createElement:Je,useCallback:Ke,useLayoutEffect:Ne,useRef:Xe,useState:Ye}=s,Ze=(e,...s)=>m(e)?{}:e(...s),$e=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var es=Object.defineProperty,ss=Object.defineProperties,ts=Object.getOwnPropertyDescriptors,ls=Object.getOwnPropertySymbols,os=Object.prototype.hasOwnProperty,rs=Object.prototype.propertyIsEnumerable,us=(e,s,t)=>s in e?es(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ns=(e,s)=>{for(var t in s||(s={}))os.call(s,t)&&us(e,t,s[t]);if(ls)for(var t of ls(s))rs.call(s,t)&&us(e,t,s[t]);return e},ds=(e,s)=>ss(e,ts(s)),is=(e,s)=>{var t={};for(var l in e)os.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&ls)for(var l of ls(e))s.indexOf(l)<0&&rs.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:as,useContext:cs,useMemo:Is,useState:ps}=s,Cs=({tableId:e,store:s,rowComponent:t=ys,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>ks(O(n,(r=>Je(t,ds(ns({},Ze(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),bs=({queryId:e,queries:s,resultRowComponent:t=fs,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>ks(O(u,(o=>Je(t,ds(ns({},Ze(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),ws=({relationshipId:e,relationships:s,rowComponent:t=ys,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=$e(Z(s),e),c=u(e,n,d);return ks(O(c,(e=>Je(t,ds(ns({},Ze(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},Rs=e=>({checkpoints:s,checkpointComponent:t=Ss,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=ee(s);return ks(O(e(Ae(u)),(e=>Je(t,ds(ns({},Ze(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},ks=(e,s,t,l)=>{const o=m(s)||!Array.isArray(e)?e:O(e,((e,t)=>t>0?[s,e]:e));return t?[l,":{",o,"}"]:o},vs=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return ks(l+(null!=(u=Ve(e,s,t,o))?u:l),void 0,r,t)},ys=({tableId:e,rowId:s,store:t,cellComponent:l=vs,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>ks(O(((e,s,t,l)=>{const o=Te(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>Je(l,ds(ns({},Ze(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),gs=e=>Cs(e,fe(e.tableId,e.store)),hs=({valueId:e,store:s,debugIds:t})=>{var o;return ks(l+(null!=(o=xe(e,s))?o:l),void 0,t,e)},ms=({indexId:e,sliceId:s,indexes:t,rowComponent:l=ys,getRowComponentProps:o,separator:r,debugIds:u})=>{const[n,d,i]=((e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(s)])(Y(t),e),a=Be(e,s,n);return ks(O(a,(e=>Je(l,ds(ns({},Ze(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},Ls=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return ks(l+(null!=(u=Qe(e,s,t,o))?u:l),void 0,r,t)},fs=({queryId:e,rowId:s,queries:t,resultCellComponent:l=Ls,getResultCellComponentProps:o,separator:r,debugIds:u})=>ks(O(Ee(e,s,t),(r=>Je(l,ds(ns({},Ze(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),Ss=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return ks(null!=(o=Ge(s,e))?o:l,void 0,t,s)},Ts=Rs((e=>e[0])),Vs=Rs((e=>m(e[1])?[]:[e[1]])),Ps=Rs((e=>e[2]));e.BackwardCheckpointsView=Ts,e.CellView=vs,e.CheckpointView=Ss,e.CurrentCheckpointView=Vs,e.ForwardCheckpointsView=Ps,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=ms,getSliceComponentProps:l,separator:o,debugIds:r})=>ks(O(qe(e,s),(o=>Je(t,ds(ns({},Ze(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>ws(e,De,e.firstRowId),e.LocalRowsView=e=>ws(e,Me,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return ks(null!=(o=Oe(e,s))?o:l,void 0,t,e)},e.Provider=({store:e,storesById:s,metrics:t,metricsById:l,indexes:o,indexesById:r,relationships:u,relationshipsById:n,queries:d,queriesById:i,checkpoints:a,checkpointsById:c,children:I})=>{const p=cs(G),[C,b]=ps({}),w=as(((e,s)=>b((t=>j(t,e)==s?t:ds(ns({},t),{[e]:s})))),[]),R=as((e=>b((s=>ns({},((e,s)=>(delete e[s],e))(s,e))))),[]);return Je(G.Provider,{value:Is((()=>[null!=e?e:p[0],ns(ns(ns({},p[1]),s),C),null!=t?t:p[2],ns(ns({},p[3]),l),null!=o?o:p[4],ns(ns({},p[5]),r),null!=u?u:p[6],ns(ns({},p[7]),n),null!=d?d:p[8],ns(ns({},p[9]),i),null!=a?a:p[10],ns(ns({},p[11]),c),w,R]),[e,s,C,t,l,o,r,u,n,d,i,a,c,p,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:l=ys,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=$e(Z(t),e),i=He(e,s,u);return ks(m(d)||m(i)?null:Je(l,ds(ns({},Ze(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=Ls,e.ResultRowView=fs,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=is(s,["cellId","descending","offset","limit"]);return bs(u,Fe(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>bs(e,je(e.queryId,e.queries)),e.RowView=ys,e.SliceView=ms,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=is(s,["cellId","descending","offset","limit"]);return Cs(u,Se(u.tableId,t,l,o,r,u.store))},e.TableView=gs,e.TablesView=({store:e,tableComponent:s=gs,getTableComponentProps:t,separator:l,debugIds:o})=>ks(O(Le(e),(l=>Je(s,ds(ns({},Ze(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=hs,e.ValuesView=({store:e,valueComponent:s=hs,getValueComponentProps:t,separator:l,debugIds:o})=>ks(O(Pe(e),(l=>Je(s,ds(ns({},Ze(t,l)),{key:l,valueId:l,store:e,debugIds:o})))),l),e.useAddRowCallback=(e,s,t=ce,l,o=V,r=ce,u=!0)=>{const n=N(l);return oe((t=>L(n,(l=>L(s(t,l),(s=>o(l.addRow(S(e)?e(t,l):e,s,u),l,s)))))),[n,e,...t,...r,u])},e.useCell=Ve,e.useCellIds=Te,e.useCellIdsListener=(e,s,t,l,o,r)=>ke(k,N(r),t,l,[e,s],o),e.useCellListener=(e,s,t,l,o,r,u)=>ke(R,N(u),l,o,[e,s,t],r),e.useCheckpoint=Ge,e.useCheckpointIds=Ae,e.useCheckpointIdsListener=(e,s,t)=>ke("CheckpointIds",ee(t),e,s),e.useCheckpointListener=(e,s,t,l)=>ke("Checkpoint",ee(l),s,t,[e]),e.useCheckpoints=e=>_(e,10),e.useCheckpointsIds=()=>K(11),e.useCheckpointsOrCheckpointsById=ee,e.useCreateCheckpoints=(e,s,t)=>be(e,s,t),e.useCreateIndexes=(e,s,t)=>be(e,s,t),e.useCreateMergeableStore=(e,s=ce)=>ue(e,s),e.useCreateMetrics=(e,s,t)=>be(e,s,t),e.useCreatePersister=(e,s,t=ce,l,o=ce,r,u=ce)=>{const[,n]=ie(),[d,i]=ie();return re((()=>{le(void 0,null,(function*(){const t=e?yield s(e):void 0;i(t),t&&l&&le(void 0,null,(function*(){yield l(t),n([])}))}))}),[e,...t,...o]),re((()=>()=>{d&&(d.destroy(),null==r||r(d))}),[d,...u]),d},e.useCreateQueries=(e,s,t)=>be(e,s,t),e.useCreateRelationships=(e,s,t)=>be(e,s,t),e.useCreateStore=(e,s=ce)=>ue(e,s),e.useCreateSynchronizer=(e,s,t=ce,l,o=ce)=>{const[r,u]=ie();return re((()=>{le(void 0,null,(function*(){const t=e?yield s(e):void 0;u(t)}))}),[e,...t]),re((()=>()=>{r&&(r.destroy(),null==l||l(r))}),[r,...o]),r},e.useDelCellCallback=(e,s,t,l,o,r,u)=>he(o,R,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>he(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>he(s,a,t,l,e),e.useDelTablesCallback=(e,s,t)=>he(e,c,s,t),e.useDelValueCallback=(e,s,t,l)=>he(s,v,t,l,e),e.useDelValuesCallback=(e,s,t)=>he(e,y,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ke("DidFinish"+te,N(t),e,s),e.useGoBackwardCallback=Ue,e.useGoForwardCallback=We,e.useGoToCallback=(e,s=ce,t,l=V,o=ce)=>{const r=ee(t);return oe((s=>L(r,(t=>L(e(s),(e=>l(t.goTo(e),e)))))),[r,...s,...o])},e.useHasCell=(e,s,t,l)=>Re(R,N(l),4,[e,s,t]),e.useHasCellListener=(e,s,t,l,o,r,u)=>ke(d+R,N(u),l,o,[e,s,t],r),e.useHasRow=(e,s,t)=>Re(p,N(t),4,[e,s]),e.useHasRowListener=(e,s,t,l,o,r)=>ke(d+p,N(r),t,l,[e,s],o),e.useHasTable=(e,s)=>Re(a,N(s),4,[e]),e.useHasTableCell=(e,s,t)=>Re(a+R,N(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,l,o,r)=>ke(d+a+R,N(r),t,l,[e,s],o),e.useHasTableListener=(e,s,t,l,o)=>ke(d+a,N(o),s,t,[e],l),e.useHasTables=e=>Re(c,N(e),4,[]),e.useHasTablesListener=(e,s,t,l)=>ke(d+c,N(l),e,s,[],t),e.useHasValue=(e,s)=>Re(v,N(s),4,[e]),e.useHasValueListener=(e,s,t,l,o)=>ke(d+v,N(o),s,t,[e],l),e.useHasValues=e=>Re(y,N(e),4,[]),e.useHasValuesListener=(e,s,t,l)=>ke(d+y,N(l),e,s,[],t),e.useIndexIds=e=>Re("IndexIds",Y(e),1),e.useIndexes=e=>_(e,4),e.useIndexesIds=()=>K(5),e.useIndexesOrIndexesById=Y,e.useLinkedRowIds=De,e.useLinkedRowIdsListener=(e,s,t,l,o)=>ke("Linked"+b,Z(o),t,l,[e,s]),e.useLocalRowIds=Me,e.useLocalRowIdsListener=(e,s,t,l,o)=>ke("Local"+b,Z(o),t,l,[e,s]),e.useMetric=Oe,e.useMetricIds=e=>Re("MetricIds",X(e),1),e.useMetricListener=(e,s,t,l)=>ke("Metric",X(l),s,t,[e]),e.useMetrics=e=>_(e,2),e.useMetricsIds=()=>K(3),e.useMetricsOrMetricsById=X,e.useProvideStore=(e,s)=>{const{12:t,13:l}=Q(G);A((()=>(null==t||t(e,s),()=>null==l?void 0:l(e))),[t,e,s,l])},e.useQueries=e=>_(e,8),e.useQueriesIds=()=>K(9),e.useQueriesOrQueriesById=$,e.useQueryIds=e=>Re("QueryIds",$(e),1),e.useRedoInformation=e=>{var s;const t=ee(e),[,,[o]]=Ae(t);return[!m(o),We(t),o,null!=(s=L(o,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l]},e.useRelationshipIds=e=>Re("RelationshipIds",Z(e),1),e.useRelationships=e=>_(e,6),e.useRelationshipsIds=()=>K(7),e.useRelationshipsOrRelationshipsById=Z,e.useRemoteRowId=He,e.useRemoteRowIdListener=(e,s,t,l,o)=>ke("RemoteRowId",Z(o),t,l,[e,s]),e.useResultCell=Qe,e.useResultCellIds=Ee,e.useResultCellIdsListener=(e,s,t,l,o)=>ke(n+k,$(o),t,l,[e,s]),e.useResultCellListener=(e,s,t,l,o,r)=>ke(n+R,$(r),l,o,[e,s,t]),e.useResultRow=(e,s,t)=>Re(n+p,$(t),0,[e,s]),e.useResultRowCount=(e,s)=>Re(n+C,$(s),5,[e]),e.useResultRowCountListener=(e,s,t,l)=>ke(n+C,$(l),s,t,[e]),e.useResultRowIds=je,e.useResultRowIdsListener=(e,s,t,l)=>ke(n+b,$(l),s,t,[e]),e.useResultRowListener=(e,s,t,l,o)=>ke(n+p,$(o),t,l,[e,s]),e.useResultSortedRowIds=Fe,e.useResultSortedRowIdsListener=(e,s,t,l,o,r,u,d)=>ke(n+w,$(d),r,u,[e,s,t,l,o]),e.useResultTable=(e,s)=>Re(n+a,$(s),0,[e]),e.useResultTableCellIds=(e,s)=>Re(n+a+k,$(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,l)=>ke(n+a+k,$(l),s,t,[e]),e.useResultTableListener=(e,s,t,l)=>ke(n+a,$(l),s,t,[e]),e.useRow=(e,s,t)=>Re(p,N(t),0,[e,s]),e.useRowCount=(e,s)=>Re(C,N(s),5,[e]),e.useRowCountListener=(e,s,t,l,o)=>ke(C,N(o),s,t,[e],l),e.useRowIds=fe,e.useRowIdsListener=(e,s,t,l,o)=>ke(b,N(o),s,t,[e],l),e.useRowListener=(e,s,t,l,o,r)=>ke(p,N(r),t,l,[e,s],o),e.useSetCellCallback=(e,s,t,l,o,r,u,n)=>ve(r,R,l,o,u,n,e,s,t),e.useSetCheckpointCallback=(e=V,s=ce,t,l=V,o=ce)=>{const r=ee(t);return oe((s=>L(r,(t=>{const o=e(s);l(t.addCheckpoint(o),t,o)}))),[r,...s,...o])},e.useSetPartialRowCallback=(e,s,t,l,o,r,u)=>ve(o,"PartialRow",t,l,r,u,e,s),e.useSetPartialValuesCallback=(e,s,t,l,o)=>ve(t,"PartialValues",e,s,l,o),e.useSetRowCallback=(e,s,t,l,o,r,u)=>ve(o,p,t,l,r,u,e,s),e.useSetTableCallback=(e,s,t,l,o,r)=>ve(l,a,s,t,o,r,e),e.useSetTablesCallback=(e,s,t,l,o)=>ve(t,c,e,s,l,o),e.useSetValueCallback=(e,s,t,l,o,r)=>ve(l,v,s,t,o,r,e),e.useSetValuesCallback=(e,s,t,l,o)=>ve(t,y,e,s,l,o),e.useSliceIds=qe,e.useSliceIdsListener=(e,s,t,l)=>ke("SliceIds",Y(l),s,t,[e]),e.useSliceRowIds=Be,e.useSliceRowIdsListener=(e,s,t,l,o)=>ke("Slice"+b,Y(o),t,l,[e,s]),e.useSortedRowIds=Se,e.useSortedRowIdsListener=(e,s,t,l,o,r,u,n,d)=>ke(w,N(d),r,u,[e,s,t,l,o],n),e.useStartTransactionListener=(e,s,t)=>ke("Start"+te,N(t),e,s),e.useStore=e=>_(e,0),e.useStoreIds=()=>K(1),e.useStoreOrStoreById=N,e.useTable=(e,s)=>Re(a,N(s),0,[e]),e.useTableCellIds=(e,s)=>Re(a+k,N(s),1,[e]),e.useTableCellIdsListener=(e,s,t,l,o)=>ke(a+k,N(o),s,t,[e],l),e.useTableIds=Le,e.useTableIdsListener=(e,s,t,l)=>ke(I,N(l),e,s,ce,t),e.useTableListener=(e,s,t,l,o)=>ke(a,N(o),s,t,[e],l),e.useTables=e=>Re(c,N(e),0),e.useTablesListener=(e,s,t,l)=>ke(c,N(l),e,s,ce,t),e.useUndoInformation=e=>{var s;const t=ee(e),[o,r]=Ae(t);return[(u=o,!(0==T(u))),Ue(t),r,null!=(s=L(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=xe,e.useValueIds=Pe,e.useValueIdsListener=(e,s,t,l)=>ke(g,N(l),e,s,ce,t),e.useValueListener=(e,s,t,l,o)=>ke(v,N(o),s,t,[e],l),e.useValues=e=>Re(y,N(e),0),e.useValuesListener=(e,s,t,l)=>ke(y,N(l),e,s,ce,t),e.useWillFinishTransactionListener=(e,s,t)=>ke("WillFinish"+te,N(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
@@ -10,6 +10,7 @@
10
10
  'use strict';
11
11
 
12
12
  const getTypeOf = (thing) => typeof thing;
13
+ const TINYBASE = 'tinybase';
13
14
  const EMPTY_STRING = '';
14
15
  const STRING = getTypeOf(EMPTY_STRING);
15
16
  const FUNCTION = getTypeOf(getTypeOf);
@@ -33,6 +34,7 @@
33
34
  const VALUES = VALUE + 's';
34
35
  const VALUE_IDS = VALUE + IDS;
35
36
 
37
+ const GLOBAL = globalThis;
36
38
  const isUndefined = (thing) => thing == void 0;
37
39
  const ifNotUndefined = (value, then, otherwise) =>
38
40
  isUndefined(value)
@@ -70,6 +72,7 @@
70
72
  );
71
73
  const objIds = object.keys;
72
74
  const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
75
+ const objHas = (obj, id) => id in obj;
73
76
  const objDel = (obj, id) => {
74
77
  delete obj[id];
75
78
  return obj;
@@ -88,13 +91,21 @@
88
91
  )
89
92
  );
90
93
  };
94
+ const objEnsure = (obj, id, getDefaultValue) => {
95
+ if (!objHas(obj, id)) {
96
+ obj[id] = getDefaultValue();
97
+ }
98
+ return obj[id];
99
+ };
91
100
 
92
101
  const {
93
102
  createContext,
94
103
  useContext: useContext$1,
95
104
  useEffect: useEffect$1,
96
105
  } = React;
97
- const Context = createContext([]);
106
+ const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () =>
107
+ createContext([]),
108
+ );
98
109
  const useThing = (id, offset) => {
99
110
  var _a;
100
111
  const contextValue = useContext$1(Context);
@@ -10,6 +10,7 @@
10
10
  'use strict';
11
11
 
12
12
  const getTypeOf = (thing) => typeof thing;
13
+ const TINYBASE = 'tinybase';
13
14
  const EMPTY_STRING = '';
14
15
  const STRING = getTypeOf(EMPTY_STRING);
15
16
  const FUNCTION = getTypeOf(getTypeOf);
@@ -33,6 +34,7 @@
33
34
  const VALUES = VALUE + 's';
34
35
  const VALUE_IDS = VALUE + IDS;
35
36
 
37
+ const GLOBAL = globalThis;
36
38
  const isUndefined = (thing) => thing == void 0;
37
39
  const ifNotUndefined = (value, then, otherwise) =>
38
40
  isUndefined(value)
@@ -70,6 +72,7 @@
70
72
  );
71
73
  const objIds = object.keys;
72
74
  const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
75
+ const objHas = (obj, id) => id in obj;
73
76
  const objDel = (obj, id) => {
74
77
  delete obj[id];
75
78
  return obj;
@@ -88,13 +91,21 @@
88
91
  )
89
92
  );
90
93
  };
94
+ const objEnsure = (obj, id, getDefaultValue) => {
95
+ if (!objHas(obj, id)) {
96
+ obj[id] = getDefaultValue();
97
+ }
98
+ return obj[id];
99
+ };
91
100
 
92
101
  const {
93
102
  createContext,
94
103
  useContext: useContext$1,
95
104
  useEffect: useEffect$1,
96
105
  } = React;
97
- const Context = createContext([]);
106
+ const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () =>
107
+ createContext([]),
108
+ );
98
109
  const useThing = (id, offset) => {
99
110
  var _a;
100
111
  const contextValue = useContext$1(Context);
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",p=C+"Count",b=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",L=g+"s",h=g+a,y=e=>null==e,m=(e,s,t)=>y(e)?t?.():s(e),S=e=>t(e)==r,T=e=>t(e)==u,V=e=>e.length,f=()=>{},x=(e,s)=>e.every(s),v=(e,s)=>V(e)===V(s)&&x(e,((e,t)=>s[t]===e)),P=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!y(e)&&m(B(e),(e=>e==q.prototype||y(B(e))),(()=>!0)),D=q.keys,F=(e,s)=>m(e,(e=>e[s])),O=(e,s)=>(delete e[s],e),Q=(e,s)=>{const t=H(e);return V(t)===V(D(s))&&x(t,(([e,t])=>M(t)?!!M(s[e])&&Q(s[e],t):s[e]===t))},{createContext:E,useContext:A,useEffect:G}=s,j=E([]),U=(e,s)=>{const t=A(j);return y(e)?t[s]:S(e)?F(t[s+1]??{},e):e},W=(e,s)=>{const t=U(e,s);return y(e)||S(e)?t:e},z=e=>D(A(j)[e]??{}),J=e=>W(e,0),K=e=>W(e,2),N=e=>W(e,4),X=e=>W(e,6),Y=e=>W(e,8),Z=e=>W(e,10),$=e=>e.toLowerCase();$(l);const _="Transaction";$(_);const{useCallback:ee,useEffect:se,useMemo:te,useLayoutEffect:oe,useRef:re,useState:ue,useSyncExternalStore:le}=s,ne=[],de=[{},[],[ne,void 0,ne],void 0,!1,0],ae=[Q,v,([e,s,t],[o,r,u])=>s===r&&v(e,o)&&v(t,u)],ie=(e,s)=>e===s,ce=(e,s,t=ne)=>{const[,o]=ue(),[r,u]=ue();return se((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},Ie=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Ce=(e,s,t,r=ne)=>{const u=re(de[t]),l=ee((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??de[t];return(ae[t]??ie)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=ee((u=>Ie(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return le(n,l)},pe=(e,s,t,o=ne,r=ne,...u)=>oe((()=>Ie(s,e,...r,t,...u)),[s,e,...r,...o,...u]),be=(e,s,t,o=ne,r=f,u=ne,...l)=>{const n=J(e);return ee((e=>m(n,(o=>m(t(e,o),(t=>r(o["set"+s](...we(l,o,e),t),t)))))),[n,s,...o,...u,...Re(l)])},we=(e,s,t)=>P(e,(e=>T(e)?e(t,s):e)),Re=e=>{return s=e=>!T(e),e.filter(s);var s},ke=(e,s,t=f,o=ne,...r)=>{const u=J(e);return ee((e=>t(u?.["del"+s](...we(r,u,e)))),[u,s,...o,...Re(r)])},ge=(e,s,t)=>{const o=Z(e);return ee((()=>o?.[s](t)),[o,s,t])},Le=e=>Ce(I,J(e),1),he=(e,s)=>Ce(b,J(s),1,[e]),ye=(e,s,t,o=0,r,u)=>Ce(w,J(u),1,[e,s,t,o,r]),me=(e,s,t)=>Ce(k,J(t),1,[e,s]),Se=(e,s,t,o)=>Ce(R,J(o),3,[e,s,t]),Te=e=>Ce(h,J(e),1),Ve=(e,s)=>Ce(g,J(s),3,[e]),fe=(e,s)=>Ce("Metric",K(s),3,[e]),xe=(e,s)=>Ce("SliceIds",N(s),1,[e]),ve=(e,s,t)=>Ce("Slice"+b,N(t),1,[e,s]),Pe=(e,s,t)=>Ce("RemoteRowId",X(t),3,[e,s]),qe=(e,s,t)=>Ce("Local"+b,X(t),1,[e,s]),Be=(e,s,t)=>Ce("Linked"+b,X(t),1,[e,s]),He=(e,s)=>Ce(n+b,Y(s),1,[e]),Me=(e,s,t,o=0,r,u)=>Ce(n+w,Y(u),1,[e,s,t,o,r]),De=(e,s,t)=>Ce(n+k,Y(t),1,[e,s]),Fe=(e,s,t,o)=>Ce(n+R,Y(o),3,[e,s,t]),Oe=e=>Ce("CheckpointIds",Z(e),2),Qe=(e,s)=>Ce("Checkpoint",Z(s),3,[e]),Ee=e=>ge(e,"goBackward"),Ae=e=>ge(e,"goForward"),{PureComponent:Ge,Fragment:je,createElement:Ue,useCallback:We,useLayoutEffect:ze,useRef:Je,useState:Ke}=s,Ne=(e,...s)=>y(e)?{}:e(...s),Xe=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Ye,useContext:Ze,useMemo:$e,useState:_e}=s,es=({tableId:e,store:s,rowComponent:t=ls,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>rs(P(n,(u=>Ue(t,{...Ne(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),ss=({queryId:e,queries:s,resultRowComponent:t=cs,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>rs(P(l,(r=>Ue(t,{...Ne(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ts=({relationshipId:e,relationships:s,rowComponent:t=ls,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=Xe(X(s),e),c=l(e,n,d);return rs(P(c,(e=>Ue(t,{...Ne(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},os=e=>({checkpoints:s,checkpointComponent:t=Is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Z(s);return rs(P(e(Oe(l)),(e=>Ue(t,{...Ne(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},rs=(e,s,t,o)=>{const r=y(s)||!Array.isArray(e)?e:P(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},us=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>rs(o+(Se(e,s,t,r)??o),void 0,u,t),ls=({tableId:e,rowId:s,store:t,cellComponent:o=us,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>rs(P(((e,s,t,o)=>{const r=me(s,t,o);return e??r})(u,e,s,t),(u=>Ue(o,{...Ne(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),ns=e=>es(e,he(e.tableId,e.store)),ds=({valueId:e,store:s,debugIds:t})=>rs(o+(Ve(e,s)??o),void 0,t,e),as=({indexId:e,sliceId:s,indexes:t,rowComponent:o=ls,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(N(t),e),i=ve(e,s,n);return rs(P(i,(e=>Ue(o,{...Ne(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},is=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>rs(o+(Fe(e,s,t,r)??o),void 0,u,t),cs=({queryId:e,rowId:s,queries:t,resultCellComponent:o=is,getResultCellComponentProps:r,separator:u,debugIds:l})=>rs(P(De(e,s,t),(u=>Ue(o,{...Ne(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),Is=({checkpoints:e,checkpointId:s,debugIds:t})=>rs(Qe(s,e)??o,void 0,t,s),Cs=os((e=>e[0])),ps=os((e=>y(e[1])?[]:[e[1]])),bs=os((e=>e[2]));e.BackwardCheckpointsView=Cs,e.CellView=us,e.CheckpointView=Is,e.CurrentCheckpointView=ps,e.ForwardCheckpointsView=bs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=as,getSliceComponentProps:o,separator:r,debugIds:u})=>rs(P(xe(e,s),(r=>Ue(t,{...Ne(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ts(e,Be,e.firstRowId),e.LocalRowsView=e=>ts(e,qe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>rs(fe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=Ze(j),[p,b]=_e({}),w=Ye(((e,s)=>b((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),R=Ye((e=>b((s=>({...O(s,e)})))),[]);return Ue(j.Provider,{value:$e((()=>[e??C[0],{...C[1],...s,...p},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,p,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=ls,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Xe(X(t),e),a=Pe(e,s,l);return rs(y(d)||y(a)?null:Ue(o,{...Ne(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=is,e.ResultRowView=cs,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ss(r,Me(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>ss(e,He(e.queryId,e.queries)),e.RowView=ls,e.SliceView=as,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>es(r,ye(r.tableId,e,s,t,o,r.store)),e.TableView=ns,e.TablesView=({store:e,tableComponent:s=ns,getTableComponentProps:t,separator:o,debugIds:r})=>rs(P(Le(e),(o=>Ue(s,{...Ne(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ds,e.ValuesView=({store:e,valueComponent:s=ds,getValueComponentProps:t,separator:o,debugIds:r})=>rs(P(Te(e),(o=>Ue(s,{...Ne(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ne,o,r=f,u=ne,l=!0)=>{const n=J(o);return ee((t=>m(n,(o=>m(s(t,o),(s=>r(o.addRow(T(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=Se,e.useCellIds=me,e.useCellIdsListener=(e,s,t,o,r,u)=>pe(k,J(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>pe(R,J(l),o,r,[e,s,t],u),e.useCheckpoint=Qe,e.useCheckpointIds=Oe,e.useCheckpointIdsListener=(e,s,t)=>pe("CheckpointIds",Z(t),e,s),e.useCheckpointListener=(e,s,t,o)=>pe("Checkpoint",Z(o),s,t,[e]),e.useCheckpoints=e=>U(e,10),e.useCheckpointsIds=()=>z(11),e.useCheckpointsOrCheckpointsById=Z,e.useCreateCheckpoints=(e,s,t)=>ce(e,s,t),e.useCreateIndexes=(e,s,t)=>ce(e,s,t),e.useCreateMergeableStore=(e,s=ne)=>te(e,s),e.useCreateMetrics=(e,s,t)=>ce(e,s,t),e.useCreatePersister=(e,s,t=ne,o,r=ne,u,l=ne)=>{const[,n]=ue(),[d,a]=ue();return se((()=>{(async()=>{const t=e?await s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),se((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>ce(e,s,t),e.useCreateRelationships=(e,s,t)=>ce(e,s,t),e.useCreateStore=(e,s=ne)=>te(e,s),e.useCreateSynchronizer=(e,s,t=ne,o,r=ne)=>{const[u,l]=ue();return se((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),se((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>ke(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>ke(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>ke(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>ke(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>ke(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>ke(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>pe("DidFinish"+_,J(t),e,s),e.useGoBackwardCallback=Ee,e.useGoForwardCallback=Ae,e.useGoToCallback=(e,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>m(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Ce(R,J(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>pe(d+R,J(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Ce(C,J(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>pe(d+C,J(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Ce(i,J(s),4,[e]),e.useHasTableCell=(e,s,t)=>Ce(i+R,J(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>pe(d+i+R,J(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>pe(d+i,J(r),s,t,[e],o),e.useHasTables=e=>Ce(c,J(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>pe(d+c,J(o),e,s,[],t),e.useHasValue=(e,s)=>Ce(g,J(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>pe(d+g,J(r),s,t,[e],o),e.useHasValues=e=>Ce(L,J(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>pe(d+L,J(o),e,s,[],t),e.useIndexIds=e=>Ce("IndexIds",N(e),1),e.useIndexes=e=>U(e,4),e.useIndexesIds=()=>z(5),e.useIndexesOrIndexesById=N,e.useLinkedRowIds=Be,e.useLinkedRowIdsListener=(e,s,t,o,r)=>pe("Linked"+b,X(r),t,o,[e,s]),e.useLocalRowIds=qe,e.useLocalRowIdsListener=(e,s,t,o,r)=>pe("Local"+b,X(r),t,o,[e,s]),e.useMetric=fe,e.useMetricIds=e=>Ce("MetricIds",K(e),1),e.useMetricListener=(e,s,t,o)=>pe("Metric",K(o),s,t,[e]),e.useMetrics=e=>U(e,2),e.useMetricsIds=()=>z(3),e.useMetricsOrMetricsById=K,e.useProvideStore=(e,s)=>{const{12:t,13:o}=A(j);G((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>U(e,8),e.useQueriesIds=()=>z(9),e.useQueriesOrQueriesById=Y,e.useQueryIds=e=>Ce("QueryIds",Y(e),1),e.useRedoInformation=e=>{const s=Z(e),[,,[t]]=Oe(s);return[!y(t),Ae(s),t,m(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Ce("RelationshipIds",X(e),1),e.useRelationships=e=>U(e,6),e.useRelationshipsIds=()=>z(7),e.useRelationshipsOrRelationshipsById=X,e.useRemoteRowId=Pe,e.useRemoteRowIdListener=(e,s,t,o,r)=>pe("RemoteRowId",X(r),t,o,[e,s]),e.useResultCell=Fe,e.useResultCellIds=De,e.useResultCellIdsListener=(e,s,t,o,r)=>pe(n+k,Y(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>pe(n+R,Y(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Ce(n+C,Y(t),0,[e,s]),e.useResultRowCount=(e,s)=>Ce(n+p,Y(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>pe(n+p,Y(o),s,t,[e]),e.useResultRowIds=He,e.useResultRowIdsListener=(e,s,t,o)=>pe(n+b,Y(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>pe(n+C,Y(r),t,o,[e,s]),e.useResultSortedRowIds=Me,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>pe(n+w,Y(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Ce(n+i,Y(s),0,[e]),e.useResultTableCellIds=(e,s)=>Ce(n+i+k,Y(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>pe(n+i+k,Y(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>pe(n+i,Y(o),s,t,[e]),e.useRow=(e,s,t)=>Ce(C,J(t),0,[e,s]),e.useRowCount=(e,s)=>Ce(p,J(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>pe(p,J(r),s,t,[e],o),e.useRowIds=he,e.useRowIdsListener=(e,s,t,o,r)=>pe(b,J(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>pe(C,J(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>be(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=f,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>be(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>be(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>be(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>be(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>be(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>be(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>be(t,L,e,s,o,r),e.useSliceIds=xe,e.useSliceIdsListener=(e,s,t,o)=>pe("SliceIds",N(o),s,t,[e]),e.useSliceRowIds=ve,e.useSliceRowIdsListener=(e,s,t,o,r)=>pe("Slice"+b,N(r),t,o,[e,s]),e.useSortedRowIds=ye,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>pe(w,J(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>pe("Start"+_,J(t),e,s),e.useStore=e=>U(e,0),e.useStoreIds=()=>z(1),e.useStoreOrStoreById=J,e.useTable=(e,s)=>Ce(i,J(s),0,[e]),e.useTableCellIds=(e,s)=>Ce(i+k,J(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>pe(i+k,J(r),s,t,[e],o),e.useTableIds=Le,e.useTableIdsListener=(e,s,t,o)=>pe(I,J(o),e,s,ne,t),e.useTableListener=(e,s,t,o,r)=>pe(i,J(r),s,t,[e],o),e.useTables=e=>Ce(c,J(e),0),e.useTablesListener=(e,s,t,o)=>pe(c,J(o),e,s,ne,t),e.useUndoInformation=e=>{const s=Z(e),[t,r]=Oe(s);return[(u=t,!(0==V(u))),Ee(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Ve,e.useValueIds=Te,e.useValueIdsListener=(e,s,t,o)=>pe(h,J(o),e,s,ne,t),e.useValueListener=(e,s,t,o,r)=>pe(g,J(r),s,t,[e],o),e.useValues=e=>Ce(L,J(e),0),e.useValuesListener=(e,s,t,o)=>pe(L,J(o),e,s,ne,t),e.useWillFinishTransactionListener=(e,s,t)=>pe("WillFinish"+_,J(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",b=C+"Count",p=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",h=g+"s",y=g+a,L=globalThis,m=e=>null==e,S=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==r,V=e=>t(e)==u,f=e=>e.length,v=()=>{},x=(e,s)=>e.every(s),P=(e,s)=>f(e)===f(s)&&x(e,((e,t)=>s[t]===e)),q=(e,s)=>e.map(s),B=Object,H=e=>B.getPrototypeOf(e),M=B.entries,D=e=>!m(e)&&S(H(e),(e=>e==B.prototype||m(H(e))),(()=>!0)),F=B.keys,O=(e,s)=>S(e,(e=>e[s])),Q=(e,s)=>(delete e[s],e),E=(e,s)=>{const t=M(e);return f(t)===f(F(s))&&x(t,(([e,t])=>D(t)?!!D(s[e])&&E(s[e],t):s[e]===t))},{createContext:A,useContext:G,useEffect:j}=s,U=(_=()=>A([]),((e,s)=>s in e)(W=L,z="tinybase_uirc")||(W[z]=_()),W[z]);var W,z,_;const J=(e,s)=>{const t=G(U);return m(e)?t[s]:T(e)?O(t[s+1]??{},e):e},K=(e,s)=>{const t=J(e,s);return m(e)||T(e)?t:e},N=e=>F(G(U)[e]??{}),X=e=>K(e,0),Y=e=>K(e,2),Z=e=>K(e,4),$=e=>K(e,6),ee=e=>K(e,8),se=e=>K(e,10),te=e=>e.toLowerCase();te(l);const oe="Transaction";te(oe);const{useCallback:re,useEffect:ue,useMemo:le,useLayoutEffect:ne,useRef:de,useState:ae,useSyncExternalStore:ie}=s,ce=[],Ie=[{},[],[ce,void 0,ce],void 0,!1,0],Ce=[E,P,([e,s,t],[o,r,u])=>s===r&&P(e,o)&&P(t,u)],be=(e,s)=>e===s,pe=(e,s,t=ce)=>{const[,o]=ae(),[r,u]=ae();return ue((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},we=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Re=(e,s,t,r=ce)=>{const u=de(Ie[t]),l=re((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??Ie[t];return(Ce[t]??be)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=re((u=>we(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return ie(n,l)},ke=(e,s,t,o=ce,r=ce,...u)=>ne((()=>we(s,e,...r,t,...u)),[s,e,...r,...o,...u]),ge=(e,s,t,o=ce,r=v,u=ce,...l)=>{const n=X(e);return re((e=>S(n,(o=>S(t(e,o),(t=>r(o["set"+s](...he(l,o,e),t),t)))))),[n,s,...o,...u,...ye(l)])},he=(e,s,t)=>q(e,(e=>V(e)?e(t,s):e)),ye=e=>{return s=e=>!V(e),e.filter(s);var s},Le=(e,s,t=v,o=ce,...r)=>{const u=X(e);return re((e=>t(u?.["del"+s](...he(r,u,e)))),[u,s,...o,...ye(r)])},me=(e,s,t)=>{const o=se(e);return re((()=>o?.[s](t)),[o,s,t])},Se=e=>Re(I,X(e),1),Te=(e,s)=>Re(p,X(s),1,[e]),Ve=(e,s,t,o=0,r,u)=>Re(w,X(u),1,[e,s,t,o,r]),fe=(e,s,t)=>Re(k,X(t),1,[e,s]),ve=(e,s,t,o)=>Re(R,X(o),3,[e,s,t]),xe=e=>Re(y,X(e),1),Pe=(e,s)=>Re(g,X(s),3,[e]),qe=(e,s)=>Re("Metric",Y(s),3,[e]),Be=(e,s)=>Re("SliceIds",Z(s),1,[e]),He=(e,s,t)=>Re("Slice"+p,Z(t),1,[e,s]),Me=(e,s,t)=>Re("RemoteRowId",$(t),3,[e,s]),De=(e,s,t)=>Re("Local"+p,$(t),1,[e,s]),Fe=(e,s,t)=>Re("Linked"+p,$(t),1,[e,s]),Oe=(e,s)=>Re(n+p,ee(s),1,[e]),Qe=(e,s,t,o=0,r,u)=>Re(n+w,ee(u),1,[e,s,t,o,r]),Ee=(e,s,t)=>Re(n+k,ee(t),1,[e,s]),Ae=(e,s,t,o)=>Re(n+R,ee(o),3,[e,s,t]),Ge=e=>Re("CheckpointIds",se(e),2),je=(e,s)=>Re("Checkpoint",se(s),3,[e]),Ue=e=>me(e,"goBackward"),We=e=>me(e,"goForward"),{PureComponent:ze,Fragment:_e,createElement:Je,useCallback:Ke,useLayoutEffect:Ne,useRef:Xe,useState:Ye}=s,Ze=(e,...s)=>m(e)?{}:e(...s),$e=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:es,useContext:ss,useMemo:ts,useState:os}=s,rs=({tableId:e,store:s,rowComponent:t=is,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ds(q(n,(u=>Je(t,{...Ze(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),us=({queryId:e,queries:s,resultRowComponent:t=ps,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ds(q(l,(r=>Je(t,{...Ze(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ls=({relationshipId:e,relationships:s,rowComponent:t=is,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=$e($(s),e),c=l(e,n,d);return ds(q(c,(e=>Je(t,{...Ze(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},ns=e=>({checkpoints:s,checkpointComponent:t=ws,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=se(s);return ds(q(e(Ge(l)),(e=>Je(t,{...Ze(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ds=(e,s,t,o)=>{const r=m(s)||!Array.isArray(e)?e:q(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},as=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ds(o+(ve(e,s,t,r)??o),void 0,u,t),is=({tableId:e,rowId:s,store:t,cellComponent:o=as,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ds(q(((e,s,t,o)=>{const r=fe(s,t,o);return e??r})(u,e,s,t),(u=>Je(o,{...Ze(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),cs=e=>rs(e,Te(e.tableId,e.store)),Is=({valueId:e,store:s,debugIds:t})=>ds(o+(Pe(e,s)??o),void 0,t,e),Cs=({indexId:e,sliceId:s,indexes:t,rowComponent:o=is,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(Z(t),e),i=He(e,s,n);return ds(q(i,(e=>Je(o,{...Ze(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},bs=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ds(o+(Ae(e,s,t,r)??o),void 0,u,t),ps=({queryId:e,rowId:s,queries:t,resultCellComponent:o=bs,getResultCellComponentProps:r,separator:u,debugIds:l})=>ds(q(Ee(e,s,t),(u=>Je(o,{...Ze(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),ws=({checkpoints:e,checkpointId:s,debugIds:t})=>ds(je(s,e)??o,void 0,t,s),Rs=ns((e=>e[0])),ks=ns((e=>m(e[1])?[]:[e[1]])),gs=ns((e=>e[2]));e.BackwardCheckpointsView=Rs,e.CellView=as,e.CheckpointView=ws,e.CurrentCheckpointView=ks,e.ForwardCheckpointsView=gs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Cs,getSliceComponentProps:o,separator:r,debugIds:u})=>ds(q(Be(e,s),(r=>Je(t,{...Ze(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ls(e,Fe,e.firstRowId),e.LocalRowsView=e=>ls(e,De,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ds(qe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=ss(U),[b,p]=os({}),w=es(((e,s)=>p((t=>O(t,e)==s?t:{...t,[e]:s}))),[]),R=es((e=>p((s=>({...Q(s,e)})))),[]);return Je(U.Provider,{value:ts((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=is,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=$e($(t),e),a=Me(e,s,l);return ds(m(d)||m(a)?null:Je(o,{...Ze(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=bs,e.ResultRowView=ps,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>us(r,Qe(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>us(e,Oe(e.queryId,e.queries)),e.RowView=is,e.SliceView=Cs,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>rs(r,Ve(r.tableId,e,s,t,o,r.store)),e.TableView=cs,e.TablesView=({store:e,tableComponent:s=cs,getTableComponentProps:t,separator:o,debugIds:r})=>ds(q(Se(e),(o=>Je(s,{...Ze(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=Is,e.ValuesView=({store:e,valueComponent:s=Is,getValueComponentProps:t,separator:o,debugIds:r})=>ds(q(xe(e),(o=>Je(s,{...Ze(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ce,o,r=v,u=ce,l=!0)=>{const n=X(o);return re((t=>S(n,(o=>S(s(t,o),(s=>r(o.addRow(V(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=ve,e.useCellIds=fe,e.useCellIdsListener=(e,s,t,o,r,u)=>ke(k,X(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>ke(R,X(l),o,r,[e,s,t],u),e.useCheckpoint=je,e.useCheckpointIds=Ge,e.useCheckpointIdsListener=(e,s,t)=>ke("CheckpointIds",se(t),e,s),e.useCheckpointListener=(e,s,t,o)=>ke("Checkpoint",se(o),s,t,[e]),e.useCheckpoints=e=>J(e,10),e.useCheckpointsIds=()=>N(11),e.useCheckpointsOrCheckpointsById=se,e.useCreateCheckpoints=(e,s,t)=>pe(e,s,t),e.useCreateIndexes=(e,s,t)=>pe(e,s,t),e.useCreateMergeableStore=(e,s=ce)=>le(e,s),e.useCreateMetrics=(e,s,t)=>pe(e,s,t),e.useCreatePersister=(e,s,t=ce,o,r=ce,u,l=ce)=>{const[,n]=ae(),[d,a]=ae();return ue((()=>{(async()=>{const t=e?await s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),ue((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>pe(e,s,t),e.useCreateRelationships=(e,s,t)=>pe(e,s,t),e.useCreateStore=(e,s=ce)=>le(e,s),e.useCreateSynchronizer=(e,s,t=ce,o,r=ce)=>{const[u,l]=ae();return ue((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),ue((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>Le(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>Le(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>Le(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>Le(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>Le(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>Le(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ke("DidFinish"+oe,X(t),e,s),e.useGoBackwardCallback=Ue,e.useGoForwardCallback=We,e.useGoToCallback=(e,s=ce,t,o=v,r=ce)=>{const u=se(t);return re((s=>S(u,(t=>S(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Re(R,X(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>ke(d+R,X(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Re(C,X(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>ke(d+C,X(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Re(i,X(s),4,[e]),e.useHasTableCell=(e,s,t)=>Re(i+R,X(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>ke(d+i+R,X(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>ke(d+i,X(r),s,t,[e],o),e.useHasTables=e=>Re(c,X(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>ke(d+c,X(o),e,s,[],t),e.useHasValue=(e,s)=>Re(g,X(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>ke(d+g,X(r),s,t,[e],o),e.useHasValues=e=>Re(h,X(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>ke(d+h,X(o),e,s,[],t),e.useIndexIds=e=>Re("IndexIds",Z(e),1),e.useIndexes=e=>J(e,4),e.useIndexesIds=()=>N(5),e.useIndexesOrIndexesById=Z,e.useLinkedRowIds=Fe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>ke("Linked"+p,$(r),t,o,[e,s]),e.useLocalRowIds=De,e.useLocalRowIdsListener=(e,s,t,o,r)=>ke("Local"+p,$(r),t,o,[e,s]),e.useMetric=qe,e.useMetricIds=e=>Re("MetricIds",Y(e),1),e.useMetricListener=(e,s,t,o)=>ke("Metric",Y(o),s,t,[e]),e.useMetrics=e=>J(e,2),e.useMetricsIds=()=>N(3),e.useMetricsOrMetricsById=Y,e.useProvideStore=(e,s)=>{const{12:t,13:o}=G(U);j((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>J(e,8),e.useQueriesIds=()=>N(9),e.useQueriesOrQueriesById=ee,e.useQueryIds=e=>Re("QueryIds",ee(e),1),e.useRedoInformation=e=>{const s=se(e),[,,[t]]=Ge(s);return[!m(t),We(s),t,S(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Re("RelationshipIds",$(e),1),e.useRelationships=e=>J(e,6),e.useRelationshipsIds=()=>N(7),e.useRelationshipsOrRelationshipsById=$,e.useRemoteRowId=Me,e.useRemoteRowIdListener=(e,s,t,o,r)=>ke("RemoteRowId",$(r),t,o,[e,s]),e.useResultCell=Ae,e.useResultCellIds=Ee,e.useResultCellIdsListener=(e,s,t,o,r)=>ke(n+k,ee(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>ke(n+R,ee(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Re(n+C,ee(t),0,[e,s]),e.useResultRowCount=(e,s)=>Re(n+b,ee(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>ke(n+b,ee(o),s,t,[e]),e.useResultRowIds=Oe,e.useResultRowIdsListener=(e,s,t,o)=>ke(n+p,ee(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>ke(n+C,ee(r),t,o,[e,s]),e.useResultSortedRowIds=Qe,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>ke(n+w,ee(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Re(n+i,ee(s),0,[e]),e.useResultTableCellIds=(e,s)=>Re(n+i+k,ee(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>ke(n+i+k,ee(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>ke(n+i,ee(o),s,t,[e]),e.useRow=(e,s,t)=>Re(C,X(t),0,[e,s]),e.useRowCount=(e,s)=>Re(b,X(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>ke(b,X(r),s,t,[e],o),e.useRowIds=Te,e.useRowIdsListener=(e,s,t,o,r)=>ke(p,X(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>ke(C,X(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>ge(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=v,s=ce,t,o=v,r=ce)=>{const u=se(t);return re((s=>S(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>ge(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>ge(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>ge(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>ge(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>ge(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>ge(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>ge(t,h,e,s,o,r),e.useSliceIds=Be,e.useSliceIdsListener=(e,s,t,o)=>ke("SliceIds",Z(o),s,t,[e]),e.useSliceRowIds=He,e.useSliceRowIdsListener=(e,s,t,o,r)=>ke("Slice"+p,Z(r),t,o,[e,s]),e.useSortedRowIds=Ve,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>ke(w,X(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>ke("Start"+oe,X(t),e,s),e.useStore=e=>J(e,0),e.useStoreIds=()=>N(1),e.useStoreOrStoreById=X,e.useTable=(e,s)=>Re(i,X(s),0,[e]),e.useTableCellIds=(e,s)=>Re(i+k,X(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>ke(i+k,X(r),s,t,[e],o),e.useTableIds=Se,e.useTableIdsListener=(e,s,t,o)=>ke(I,X(o),e,s,ce,t),e.useTableListener=(e,s,t,o,r)=>ke(i,X(r),s,t,[e],o),e.useTables=e=>Re(c,X(e),0),e.useTablesListener=(e,s,t,o)=>ke(c,X(o),e,s,ce,t),e.useUndoInformation=e=>{const s=se(e),[t,r]=Ge(s);return[(u=t,!(0==f(u))),Ue(s),r,S(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Pe,e.useValueIds=xe,e.useValueIdsListener=(e,s,t,o)=>ke(y,X(o),e,s,ce,t),e.useValueListener=(e,s,t,o,r)=>ke(g,X(r),s,t,[e],o),e.useValues=e=>Re(h,X(e),0),e.useValuesListener=(e,s,t,o)=>ke(h,X(o),e,s,ce,t),e.useWillFinishTransactionListener=(e,s,t)=>ke("WillFinish"+oe,X(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
Binary file
@@ -1 +1 @@
1
- var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",p=C+"Count",b=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",L=g+"s",h=g+a,y=e=>null==e,m=(e,s,t)=>y(e)?t?.():s(e),S=e=>t(e)==r,T=e=>t(e)==u,V=e=>e.length,f=()=>{},x=(e,s)=>e.every(s),v=(e,s)=>V(e)===V(s)&&x(e,((e,t)=>s[t]===e)),P=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!y(e)&&m(B(e),(e=>e==q.prototype||y(B(e))),(()=>!0)),D=q.keys,F=(e,s)=>m(e,(e=>e[s])),O=(e,s)=>(delete e[s],e),Q=(e,s)=>{const t=H(e);return V(t)===V(D(s))&&x(t,(([e,t])=>M(t)?!!M(s[e])&&Q(s[e],t):s[e]===t))},{createContext:E,useContext:A,useEffect:G}=s,j=E([]),U=(e,s)=>{const t=A(j);return y(e)?t[s]:S(e)?F(t[s+1]??{},e):e},W=(e,s)=>{const t=U(e,s);return y(e)||S(e)?t:e},z=e=>D(A(j)[e]??{}),J=e=>W(e,0),K=e=>W(e,2),N=e=>W(e,4),X=e=>W(e,6),Y=e=>W(e,8),Z=e=>W(e,10),$=e=>e.toLowerCase();$(l);const _="Transaction";$(_);const{useCallback:ee,useEffect:se,useMemo:te,useLayoutEffect:oe,useRef:re,useState:ue,useSyncExternalStore:le}=s,ne=[],de=[{},[],[ne,void 0,ne],void 0,!1,0],ae=[Q,v,([e,s,t],[o,r,u])=>s===r&&v(e,o)&&v(t,u)],ie=(e,s)=>e===s,ce=(e,s,t=ne)=>{const[,o]=ue(),[r,u]=ue();return se((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},Ie=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Ce=(e,s,t,r=ne)=>{const u=re(de[t]),l=ee((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??de[t];return(ae[t]??ie)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=ee((u=>Ie(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return le(n,l)},pe=(e,s,t,o=ne,r=ne,...u)=>oe((()=>Ie(s,e,...r,t,...u)),[s,e,...r,...o,...u]),be=(e,s,t,o=ne,r=f,u=ne,...l)=>{const n=J(e);return ee((e=>m(n,(o=>m(t(e,o),(t=>r(o["set"+s](...we(l,o,e),t),t)))))),[n,s,...o,...u,...Re(l)])},we=(e,s,t)=>P(e,(e=>T(e)?e(t,s):e)),Re=e=>{return s=e=>!T(e),e.filter(s);var s},ke=(e,s,t=f,o=ne,...r)=>{const u=J(e);return ee((e=>t(u?.["del"+s](...we(r,u,e)))),[u,s,...o,...Re(r)])},ge=(e,s,t)=>{const o=Z(e);return ee((()=>o?.[s](t)),[o,s,t])},Le=e=>Ce(I,J(e),1),he=(e,s)=>Ce(b,J(s),1,[e]),ye=(e,s,t,o=0,r,u)=>Ce(w,J(u),1,[e,s,t,o,r]),me=(e,s,t)=>Ce(k,J(t),1,[e,s]),Se=(e,s,t,o)=>Ce(R,J(o),3,[e,s,t]),Te=e=>Ce(h,J(e),1),Ve=(e,s)=>Ce(g,J(s),3,[e]),fe=(e,s)=>Ce("Metric",K(s),3,[e]),xe=(e,s)=>Ce("SliceIds",N(s),1,[e]),ve=(e,s,t)=>Ce("Slice"+b,N(t),1,[e,s]),Pe=(e,s,t)=>Ce("RemoteRowId",X(t),3,[e,s]),qe=(e,s,t)=>Ce("Local"+b,X(t),1,[e,s]),Be=(e,s,t)=>Ce("Linked"+b,X(t),1,[e,s]),He=(e,s)=>Ce(n+b,Y(s),1,[e]),Me=(e,s,t,o=0,r,u)=>Ce(n+w,Y(u),1,[e,s,t,o,r]),De=(e,s,t)=>Ce(n+k,Y(t),1,[e,s]),Fe=(e,s,t,o)=>Ce(n+R,Y(o),3,[e,s,t]),Oe=e=>Ce("CheckpointIds",Z(e),2),Qe=(e,s)=>Ce("Checkpoint",Z(s),3,[e]),Ee=e=>ge(e,"goBackward"),Ae=e=>ge(e,"goForward"),{PureComponent:Ge,Fragment:je,createElement:Ue,useCallback:We,useLayoutEffect:ze,useRef:Je,useState:Ke}=s,Ne=(e,...s)=>y(e)?{}:e(...s),Xe=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Ye,useContext:Ze,useMemo:$e,useState:_e}=s,es=({tableId:e,store:s,rowComponent:t=ls,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>rs(P(n,(u=>Ue(t,{...Ne(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),ss=({queryId:e,queries:s,resultRowComponent:t=cs,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>rs(P(l,(r=>Ue(t,{...Ne(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ts=({relationshipId:e,relationships:s,rowComponent:t=ls,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=Xe(X(s),e),c=l(e,n,d);return rs(P(c,(e=>Ue(t,{...Ne(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},os=e=>({checkpoints:s,checkpointComponent:t=Is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Z(s);return rs(P(e(Oe(l)),(e=>Ue(t,{...Ne(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},rs=(e,s,t,o)=>{const r=y(s)||!Array.isArray(e)?e:P(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},us=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>rs(o+(Se(e,s,t,r)??o),void 0,u,t),ls=({tableId:e,rowId:s,store:t,cellComponent:o=us,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>rs(P(((e,s,t,o)=>{const r=me(s,t,o);return e??r})(u,e,s,t),(u=>Ue(o,{...Ne(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),ns=e=>es(e,he(e.tableId,e.store)),ds=({valueId:e,store:s,debugIds:t})=>rs(o+(Ve(e,s)??o),void 0,t,e),as=({indexId:e,sliceId:s,indexes:t,rowComponent:o=ls,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(N(t),e),i=ve(e,s,n);return rs(P(i,(e=>Ue(o,{...Ne(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},is=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>rs(o+(Fe(e,s,t,r)??o),void 0,u,t),cs=({queryId:e,rowId:s,queries:t,resultCellComponent:o=is,getResultCellComponentProps:r,separator:u,debugIds:l})=>rs(P(De(e,s,t),(u=>Ue(o,{...Ne(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),Is=({checkpoints:e,checkpointId:s,debugIds:t})=>rs(Qe(s,e)??o,void 0,t,s),Cs=os((e=>e[0])),ps=os((e=>y(e[1])?[]:[e[1]])),bs=os((e=>e[2]));e.BackwardCheckpointsView=Cs,e.CellView=us,e.CheckpointView=Is,e.CurrentCheckpointView=ps,e.ForwardCheckpointsView=bs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=as,getSliceComponentProps:o,separator:r,debugIds:u})=>rs(P(xe(e,s),(r=>Ue(t,{...Ne(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ts(e,Be,e.firstRowId),e.LocalRowsView=e=>ts(e,qe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>rs(fe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=Ze(j),[p,b]=_e({}),w=Ye(((e,s)=>b((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),R=Ye((e=>b((s=>({...O(s,e)})))),[]);return Ue(j.Provider,{value:$e((()=>[e??C[0],{...C[1],...s,...p},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,p,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=ls,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Xe(X(t),e),a=Pe(e,s,l);return rs(y(d)||y(a)?null:Ue(o,{...Ne(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=is,e.ResultRowView=cs,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>ss(r,Me(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>ss(e,He(e.queryId,e.queries)),e.RowView=ls,e.SliceView=as,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>es(r,ye(r.tableId,e,s,t,o,r.store)),e.TableView=ns,e.TablesView=({store:e,tableComponent:s=ns,getTableComponentProps:t,separator:o,debugIds:r})=>rs(P(Le(e),(o=>Ue(s,{...Ne(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ds,e.ValuesView=({store:e,valueComponent:s=ds,getValueComponentProps:t,separator:o,debugIds:r})=>rs(P(Te(e),(o=>Ue(s,{...Ne(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ne,o,r=f,u=ne,l=!0)=>{const n=J(o);return ee((t=>m(n,(o=>m(s(t,o),(s=>r(o.addRow(T(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=Se,e.useCellIds=me,e.useCellIdsListener=(e,s,t,o,r,u)=>pe(k,J(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>pe(R,J(l),o,r,[e,s,t],u),e.useCheckpoint=Qe,e.useCheckpointIds=Oe,e.useCheckpointIdsListener=(e,s,t)=>pe("CheckpointIds",Z(t),e,s),e.useCheckpointListener=(e,s,t,o)=>pe("Checkpoint",Z(o),s,t,[e]),e.useCheckpoints=e=>U(e,10),e.useCheckpointsIds=()=>z(11),e.useCheckpointsOrCheckpointsById=Z,e.useCreateCheckpoints=(e,s,t)=>ce(e,s,t),e.useCreateIndexes=(e,s,t)=>ce(e,s,t),e.useCreateMergeableStore=(e,s=ne)=>te(e,s),e.useCreateMetrics=(e,s,t)=>ce(e,s,t),e.useCreatePersister=(e,s,t=ne,o,r=ne,u,l=ne)=>{const[,n]=ue(),[d,a]=ue();return se((()=>{(async()=>{const t=e?await s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),se((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>ce(e,s,t),e.useCreateRelationships=(e,s,t)=>ce(e,s,t),e.useCreateStore=(e,s=ne)=>te(e,s),e.useCreateSynchronizer=(e,s,t=ne,o,r=ne)=>{const[u,l]=ue();return se((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),se((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>ke(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>ke(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>ke(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>ke(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>ke(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>ke(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>pe("DidFinish"+_,J(t),e,s),e.useGoBackwardCallback=Ee,e.useGoForwardCallback=Ae,e.useGoToCallback=(e,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>m(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Ce(R,J(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>pe(d+R,J(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Ce(C,J(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>pe(d+C,J(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Ce(i,J(s),4,[e]),e.useHasTableCell=(e,s,t)=>Ce(i+R,J(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>pe(d+i+R,J(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>pe(d+i,J(r),s,t,[e],o),e.useHasTables=e=>Ce(c,J(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>pe(d+c,J(o),e,s,[],t),e.useHasValue=(e,s)=>Ce(g,J(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>pe(d+g,J(r),s,t,[e],o),e.useHasValues=e=>Ce(L,J(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>pe(d+L,J(o),e,s,[],t),e.useIndexIds=e=>Ce("IndexIds",N(e),1),e.useIndexes=e=>U(e,4),e.useIndexesIds=()=>z(5),e.useIndexesOrIndexesById=N,e.useLinkedRowIds=Be,e.useLinkedRowIdsListener=(e,s,t,o,r)=>pe("Linked"+b,X(r),t,o,[e,s]),e.useLocalRowIds=qe,e.useLocalRowIdsListener=(e,s,t,o,r)=>pe("Local"+b,X(r),t,o,[e,s]),e.useMetric=fe,e.useMetricIds=e=>Ce("MetricIds",K(e),1),e.useMetricListener=(e,s,t,o)=>pe("Metric",K(o),s,t,[e]),e.useMetrics=e=>U(e,2),e.useMetricsIds=()=>z(3),e.useMetricsOrMetricsById=K,e.useProvideStore=(e,s)=>{const{12:t,13:o}=A(j);G((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>U(e,8),e.useQueriesIds=()=>z(9),e.useQueriesOrQueriesById=Y,e.useQueryIds=e=>Ce("QueryIds",Y(e),1),e.useRedoInformation=e=>{const s=Z(e),[,,[t]]=Oe(s);return[!y(t),Ae(s),t,m(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Ce("RelationshipIds",X(e),1),e.useRelationships=e=>U(e,6),e.useRelationshipsIds=()=>z(7),e.useRelationshipsOrRelationshipsById=X,e.useRemoteRowId=Pe,e.useRemoteRowIdListener=(e,s,t,o,r)=>pe("RemoteRowId",X(r),t,o,[e,s]),e.useResultCell=Fe,e.useResultCellIds=De,e.useResultCellIdsListener=(e,s,t,o,r)=>pe(n+k,Y(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>pe(n+R,Y(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Ce(n+C,Y(t),0,[e,s]),e.useResultRowCount=(e,s)=>Ce(n+p,Y(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>pe(n+p,Y(o),s,t,[e]),e.useResultRowIds=He,e.useResultRowIdsListener=(e,s,t,o)=>pe(n+b,Y(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>pe(n+C,Y(r),t,o,[e,s]),e.useResultSortedRowIds=Me,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>pe(n+w,Y(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Ce(n+i,Y(s),0,[e]),e.useResultTableCellIds=(e,s)=>Ce(n+i+k,Y(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>pe(n+i+k,Y(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>pe(n+i,Y(o),s,t,[e]),e.useRow=(e,s,t)=>Ce(C,J(t),0,[e,s]),e.useRowCount=(e,s)=>Ce(p,J(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>pe(p,J(r),s,t,[e],o),e.useRowIds=he,e.useRowIdsListener=(e,s,t,o,r)=>pe(b,J(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>pe(C,J(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>be(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=f,s=ne,t,o=f,r=ne)=>{const u=Z(t);return ee((s=>m(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>be(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>be(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>be(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>be(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>be(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>be(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>be(t,L,e,s,o,r),e.useSliceIds=xe,e.useSliceIdsListener=(e,s,t,o)=>pe("SliceIds",N(o),s,t,[e]),e.useSliceRowIds=ve,e.useSliceRowIdsListener=(e,s,t,o,r)=>pe("Slice"+b,N(r),t,o,[e,s]),e.useSortedRowIds=ye,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>pe(w,J(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>pe("Start"+_,J(t),e,s),e.useStore=e=>U(e,0),e.useStoreIds=()=>z(1),e.useStoreOrStoreById=J,e.useTable=(e,s)=>Ce(i,J(s),0,[e]),e.useTableCellIds=(e,s)=>Ce(i+k,J(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>pe(i+k,J(r),s,t,[e],o),e.useTableIds=Le,e.useTableIdsListener=(e,s,t,o)=>pe(I,J(o),e,s,ne,t),e.useTableListener=(e,s,t,o,r)=>pe(i,J(r),s,t,[e],o),e.useTables=e=>Ce(c,J(e),0),e.useTablesListener=(e,s,t,o)=>pe(c,J(o),e,s,ne,t),e.useUndoInformation=e=>{const s=Z(e),[t,r]=Oe(s);return[(u=t,!(0==V(u))),Ee(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Ve,e.useValueIds=Te,e.useValueIdsListener=(e,s,t,o)=>pe(h,J(o),e,s,ne,t),e.useValueListener=(e,s,t,o,r)=>pe(g,J(r),s,t,[e],o),e.useValues=e=>Ce(L,J(e),0),e.useValuesListener=(e,s,t,o)=>pe(L,J(o),e,s,ne,t),e.useWillFinishTransactionListener=(e,s,t)=>pe("WillFinish"+_,J(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
1
+ var e,s;e=this,s=function(e,s){"use strict";const t=e=>typeof e,o="",r=t(o),u=t(t),l="Listener",n="Result",d="Has",a="Ids",i="Table",c=i+"s",I=i+a,C="Row",b=C+"Count",p=C+a,w="Sorted"+C+a,R="Cell",k=R+a,g="Value",h=g+"s",y=g+a,L=globalThis,m=e=>null==e,S=(e,s,t)=>m(e)?t?.():s(e),T=e=>t(e)==r,V=e=>t(e)==u,f=e=>e.length,v=()=>{},x=(e,s)=>e.every(s),P=(e,s)=>f(e)===f(s)&&x(e,((e,t)=>s[t]===e)),q=(e,s)=>e.map(s),B=Object,H=e=>B.getPrototypeOf(e),M=B.entries,D=e=>!m(e)&&S(H(e),(e=>e==B.prototype||m(H(e))),(()=>!0)),F=B.keys,O=(e,s)=>S(e,(e=>e[s])),Q=(e,s)=>(delete e[s],e),E=(e,s)=>{const t=M(e);return f(t)===f(F(s))&&x(t,(([e,t])=>D(t)?!!D(s[e])&&E(s[e],t):s[e]===t))},{createContext:A,useContext:G,useEffect:j}=s,U=(_=()=>A([]),((e,s)=>s in e)(W=L,z="tinybase_uirc")||(W[z]=_()),W[z]);var W,z,_;const J=(e,s)=>{const t=G(U);return m(e)?t[s]:T(e)?O(t[s+1]??{},e):e},K=(e,s)=>{const t=J(e,s);return m(e)||T(e)?t:e},N=e=>F(G(U)[e]??{}),X=e=>K(e,0),Y=e=>K(e,2),Z=e=>K(e,4),$=e=>K(e,6),ee=e=>K(e,8),se=e=>K(e,10),te=e=>e.toLowerCase();te(l);const oe="Transaction";te(oe);const{useCallback:re,useEffect:ue,useMemo:le,useLayoutEffect:ne,useRef:de,useState:ae,useSyncExternalStore:ie}=s,ce=[],Ie=[{},[],[ce,void 0,ce],void 0,!1,0],Ce=[E,P,([e,s,t],[o,r,u])=>s===r&&P(e,o)&&P(t,u)],be=(e,s)=>e===s,pe=(e,s,t=ce)=>{const[,o]=ae(),[r,u]=ae();return ue((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},we=(e,s,...t)=>{const o=e?.["add"+s+l]?.(...t);return()=>e?.delListener(o)},Re=(e,s,t,r=ce)=>{const u=de(Ie[t]),l=re((()=>{const o=s?.[(4==t?"has":"get")+e]?.(...r)??Ie[t];return(Ce[t]??be)(o,u.current)?u.current:u.current=o}),[s,t,e,...r]),n=re((u=>we(s,(4==t?d:o)+e,...r,u)),[s,t,e,...r]);return ie(n,l)},ke=(e,s,t,o=ce,r=ce,...u)=>ne((()=>we(s,e,...r,t,...u)),[s,e,...r,...o,...u]),ge=(e,s,t,o=ce,r=v,u=ce,...l)=>{const n=X(e);return re((e=>S(n,(o=>S(t(e,o),(t=>r(o["set"+s](...he(l,o,e),t),t)))))),[n,s,...o,...u,...ye(l)])},he=(e,s,t)=>q(e,(e=>V(e)?e(t,s):e)),ye=e=>{return s=e=>!V(e),e.filter(s);var s},Le=(e,s,t=v,o=ce,...r)=>{const u=X(e);return re((e=>t(u?.["del"+s](...he(r,u,e)))),[u,s,...o,...ye(r)])},me=(e,s,t)=>{const o=se(e);return re((()=>o?.[s](t)),[o,s,t])},Se=e=>Re(I,X(e),1),Te=(e,s)=>Re(p,X(s),1,[e]),Ve=(e,s,t,o=0,r,u)=>Re(w,X(u),1,[e,s,t,o,r]),fe=(e,s,t)=>Re(k,X(t),1,[e,s]),ve=(e,s,t,o)=>Re(R,X(o),3,[e,s,t]),xe=e=>Re(y,X(e),1),Pe=(e,s)=>Re(g,X(s),3,[e]),qe=(e,s)=>Re("Metric",Y(s),3,[e]),Be=(e,s)=>Re("SliceIds",Z(s),1,[e]),He=(e,s,t)=>Re("Slice"+p,Z(t),1,[e,s]),Me=(e,s,t)=>Re("RemoteRowId",$(t),3,[e,s]),De=(e,s,t)=>Re("Local"+p,$(t),1,[e,s]),Fe=(e,s,t)=>Re("Linked"+p,$(t),1,[e,s]),Oe=(e,s)=>Re(n+p,ee(s),1,[e]),Qe=(e,s,t,o=0,r,u)=>Re(n+w,ee(u),1,[e,s,t,o,r]),Ee=(e,s,t)=>Re(n+k,ee(t),1,[e,s]),Ae=(e,s,t,o)=>Re(n+R,ee(o),3,[e,s,t]),Ge=e=>Re("CheckpointIds",se(e),2),je=(e,s)=>Re("Checkpoint",se(s),3,[e]),Ue=e=>me(e,"goBackward"),We=e=>me(e,"goForward"),{PureComponent:ze,Fragment:_e,createElement:Je,useCallback:Ke,useLayoutEffect:Ne,useRef:Xe,useState:Ye}=s,Ze=(e,...s)=>m(e)?{}:e(...s),$e=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:es,useContext:ss,useMemo:ts,useState:os}=s,rs=({tableId:e,store:s,rowComponent:t=is,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ds(q(n,(u=>Je(t,{...Ze(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),us=({queryId:e,queries:s,resultRowComponent:t=ps,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ds(q(l,(r=>Je(t,{...Ze(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ls=({relationshipId:e,relationships:s,rowComponent:t=is,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=$e($(s),e),c=l(e,n,d);return ds(q(c,(e=>Je(t,{...Ze(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},ns=e=>({checkpoints:s,checkpointComponent:t=ws,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=se(s);return ds(q(e(Ge(l)),(e=>Je(t,{...Ze(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ds=(e,s,t,o)=>{const r=m(s)||!Array.isArray(e)?e:q(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},as=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ds(o+(ve(e,s,t,r)??o),void 0,u,t),is=({tableId:e,rowId:s,store:t,cellComponent:o=as,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ds(q(((e,s,t,o)=>{const r=fe(s,t,o);return e??r})(u,e,s,t),(u=>Je(o,{...Ze(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),cs=e=>rs(e,Te(e.tableId,e.store)),Is=({valueId:e,store:s,debugIds:t})=>ds(o+(Pe(e,s)??o),void 0,t,e),Cs=({indexId:e,sliceId:s,indexes:t,rowComponent:o=is,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(Z(t),e),i=He(e,s,n);return ds(q(i,(e=>Je(o,{...Ze(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},bs=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ds(o+(Ae(e,s,t,r)??o),void 0,u,t),ps=({queryId:e,rowId:s,queries:t,resultCellComponent:o=bs,getResultCellComponentProps:r,separator:u,debugIds:l})=>ds(q(Ee(e,s,t),(u=>Je(o,{...Ze(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),ws=({checkpoints:e,checkpointId:s,debugIds:t})=>ds(je(s,e)??o,void 0,t,s),Rs=ns((e=>e[0])),ks=ns((e=>m(e[1])?[]:[e[1]])),gs=ns((e=>e[2]));e.BackwardCheckpointsView=Rs,e.CellView=as,e.CheckpointView=ws,e.CurrentCheckpointView=ks,e.ForwardCheckpointsView=gs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Cs,getSliceComponentProps:o,separator:r,debugIds:u})=>ds(q(Be(e,s),(r=>Je(t,{...Ze(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>ls(e,Fe,e.firstRowId),e.LocalRowsView=e=>ls(e,De,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ds(qe(e,s)??o,void 0,t,e),e.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:a,checkpoints:i,checkpointsById:c,children:I})=>{const C=ss(U),[b,p]=os({}),w=es(((e,s)=>p((t=>O(t,e)==s?t:{...t,[e]:s}))),[]),R=es((e=>p((s=>({...Q(s,e)})))),[]);return Je(U.Provider,{value:ts((()=>[e??C[0],{...C[1],...s,...b},t??C[2],{...C[3],...o},r??C[4],{...C[5],...u},l??C[6],{...C[7],...n},d??C[8],{...C[9],...a},i??C[10],{...C[11],...c},w,R]),[e,s,b,t,o,r,u,l,n,d,a,i,c,C,w,R])},I)},e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=is,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=$e($(t),e),a=Me(e,s,l);return ds(m(d)||m(a)?null:Je(o,{...Ze(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=bs,e.ResultRowView=ps,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>us(r,Qe(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>us(e,Oe(e.queryId,e.queries)),e.RowView=is,e.SliceView=Cs,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>rs(r,Ve(r.tableId,e,s,t,o,r.store)),e.TableView=cs,e.TablesView=({store:e,tableComponent:s=cs,getTableComponentProps:t,separator:o,debugIds:r})=>ds(q(Se(e),(o=>Je(s,{...Ze(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=Is,e.ValuesView=({store:e,valueComponent:s=Is,getValueComponentProps:t,separator:o,debugIds:r})=>ds(q(xe(e),(o=>Je(s,{...Ze(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),e.useAddRowCallback=(e,s,t=ce,o,r=v,u=ce,l=!0)=>{const n=X(o);return re((t=>S(n,(o=>S(s(t,o),(s=>r(o.addRow(V(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},e.useCell=ve,e.useCellIds=fe,e.useCellIdsListener=(e,s,t,o,r,u)=>ke(k,X(u),t,o,[e,s],r),e.useCellListener=(e,s,t,o,r,u,l)=>ke(R,X(l),o,r,[e,s,t],u),e.useCheckpoint=je,e.useCheckpointIds=Ge,e.useCheckpointIdsListener=(e,s,t)=>ke("CheckpointIds",se(t),e,s),e.useCheckpointListener=(e,s,t,o)=>ke("Checkpoint",se(o),s,t,[e]),e.useCheckpoints=e=>J(e,10),e.useCheckpointsIds=()=>N(11),e.useCheckpointsOrCheckpointsById=se,e.useCreateCheckpoints=(e,s,t)=>pe(e,s,t),e.useCreateIndexes=(e,s,t)=>pe(e,s,t),e.useCreateMergeableStore=(e,s=ce)=>le(e,s),e.useCreateMetrics=(e,s,t)=>pe(e,s,t),e.useCreatePersister=(e,s,t=ce,o,r=ce,u,l=ce)=>{const[,n]=ae(),[d,a]=ae();return ue((()=>{(async()=>{const t=e?await s(e):void 0;a(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),ue((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},e.useCreateQueries=(e,s,t)=>pe(e,s,t),e.useCreateRelationships=(e,s,t)=>pe(e,s,t),e.useCreateStore=(e,s=ce)=>le(e,s),e.useCreateSynchronizer=(e,s,t=ce,o,r=ce)=>{const[u,l]=ae();return ue((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),ue((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},e.useDelCellCallback=(e,s,t,o,r,u,l)=>Le(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>Le(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>Le(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>Le(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>Le(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>Le(e,h,s,t),e.useDidFinishTransactionListener=(e,s,t)=>ke("DidFinish"+oe,X(t),e,s),e.useGoBackwardCallback=Ue,e.useGoForwardCallback=We,e.useGoToCallback=(e,s=ce,t,o=v,r=ce)=>{const u=se(t);return re((s=>S(u,(t=>S(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},e.useHasCell=(e,s,t,o)=>Re(R,X(o),4,[e,s,t]),e.useHasCellListener=(e,s,t,o,r,u,l)=>ke(d+R,X(l),o,r,[e,s,t],u),e.useHasRow=(e,s,t)=>Re(C,X(t),4,[e,s]),e.useHasRowListener=(e,s,t,o,r,u)=>ke(d+C,X(u),t,o,[e,s],r),e.useHasTable=(e,s)=>Re(i,X(s),4,[e]),e.useHasTableCell=(e,s,t)=>Re(i+R,X(t),4,[e,s]),e.useHasTableCellListener=(e,s,t,o,r,u)=>ke(d+i+R,X(u),t,o,[e,s],r),e.useHasTableListener=(e,s,t,o,r)=>ke(d+i,X(r),s,t,[e],o),e.useHasTables=e=>Re(c,X(e),4,[]),e.useHasTablesListener=(e,s,t,o)=>ke(d+c,X(o),e,s,[],t),e.useHasValue=(e,s)=>Re(g,X(s),4,[e]),e.useHasValueListener=(e,s,t,o,r)=>ke(d+g,X(r),s,t,[e],o),e.useHasValues=e=>Re(h,X(e),4,[]),e.useHasValuesListener=(e,s,t,o)=>ke(d+h,X(o),e,s,[],t),e.useIndexIds=e=>Re("IndexIds",Z(e),1),e.useIndexes=e=>J(e,4),e.useIndexesIds=()=>N(5),e.useIndexesOrIndexesById=Z,e.useLinkedRowIds=Fe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>ke("Linked"+p,$(r),t,o,[e,s]),e.useLocalRowIds=De,e.useLocalRowIdsListener=(e,s,t,o,r)=>ke("Local"+p,$(r),t,o,[e,s]),e.useMetric=qe,e.useMetricIds=e=>Re("MetricIds",Y(e),1),e.useMetricListener=(e,s,t,o)=>ke("Metric",Y(o),s,t,[e]),e.useMetrics=e=>J(e,2),e.useMetricsIds=()=>N(3),e.useMetricsOrMetricsById=Y,e.useProvideStore=(e,s)=>{const{12:t,13:o}=G(U);j((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},e.useQueries=e=>J(e,8),e.useQueriesIds=()=>N(9),e.useQueriesOrQueriesById=ee,e.useQueryIds=e=>Re("QueryIds",ee(e),1),e.useRedoInformation=e=>{const s=se(e),[,,[t]]=Ge(s);return[!m(t),We(s),t,S(t,(e=>s?.getCheckpoint(e)))??o]},e.useRelationshipIds=e=>Re("RelationshipIds",$(e),1),e.useRelationships=e=>J(e,6),e.useRelationshipsIds=()=>N(7),e.useRelationshipsOrRelationshipsById=$,e.useRemoteRowId=Me,e.useRemoteRowIdListener=(e,s,t,o,r)=>ke("RemoteRowId",$(r),t,o,[e,s]),e.useResultCell=Ae,e.useResultCellIds=Ee,e.useResultCellIdsListener=(e,s,t,o,r)=>ke(n+k,ee(r),t,o,[e,s]),e.useResultCellListener=(e,s,t,o,r,u)=>ke(n+R,ee(u),o,r,[e,s,t]),e.useResultRow=(e,s,t)=>Re(n+C,ee(t),0,[e,s]),e.useResultRowCount=(e,s)=>Re(n+b,ee(s),5,[e]),e.useResultRowCountListener=(e,s,t,o)=>ke(n+b,ee(o),s,t,[e]),e.useResultRowIds=Oe,e.useResultRowIdsListener=(e,s,t,o)=>ke(n+p,ee(o),s,t,[e]),e.useResultRowListener=(e,s,t,o,r)=>ke(n+C,ee(r),t,o,[e,s]),e.useResultSortedRowIds=Qe,e.useResultSortedRowIdsListener=(e,s,t,o,r,u,l,d)=>ke(n+w,ee(d),u,l,[e,s,t,o,r]),e.useResultTable=(e,s)=>Re(n+i,ee(s),0,[e]),e.useResultTableCellIds=(e,s)=>Re(n+i+k,ee(s),1,[e]),e.useResultTableCellIdsListener=(e,s,t,o)=>ke(n+i+k,ee(o),s,t,[e]),e.useResultTableListener=(e,s,t,o)=>ke(n+i,ee(o),s,t,[e]),e.useRow=(e,s,t)=>Re(C,X(t),0,[e,s]),e.useRowCount=(e,s)=>Re(b,X(s),5,[e]),e.useRowCountListener=(e,s,t,o,r)=>ke(b,X(r),s,t,[e],o),e.useRowIds=Te,e.useRowIdsListener=(e,s,t,o,r)=>ke(p,X(r),s,t,[e],o),e.useRowListener=(e,s,t,o,r,u)=>ke(C,X(u),t,o,[e,s],r),e.useSetCellCallback=(e,s,t,o,r,u,l,n)=>ge(u,R,o,r,l,n,e,s,t),e.useSetCheckpointCallback=(e=v,s=ce,t,o=v,r=ce)=>{const u=se(t);return re((s=>S(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},e.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>ge(r,"PartialRow",t,o,u,l,e,s),e.useSetPartialValuesCallback=(e,s,t,o,r)=>ge(t,"PartialValues",e,s,o,r),e.useSetRowCallback=(e,s,t,o,r,u,l)=>ge(r,C,t,o,u,l,e,s),e.useSetTableCallback=(e,s,t,o,r,u)=>ge(o,i,s,t,r,u,e),e.useSetTablesCallback=(e,s,t,o,r)=>ge(t,c,e,s,o,r),e.useSetValueCallback=(e,s,t,o,r,u)=>ge(o,g,s,t,r,u,e),e.useSetValuesCallback=(e,s,t,o,r)=>ge(t,h,e,s,o,r),e.useSliceIds=Be,e.useSliceIdsListener=(e,s,t,o)=>ke("SliceIds",Z(o),s,t,[e]),e.useSliceRowIds=He,e.useSliceRowIdsListener=(e,s,t,o,r)=>ke("Slice"+p,Z(r),t,o,[e,s]),e.useSortedRowIds=Ve,e.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>ke(w,X(d),u,l,[e,s,t,o,r],n),e.useStartTransactionListener=(e,s,t)=>ke("Start"+oe,X(t),e,s),e.useStore=e=>J(e,0),e.useStoreIds=()=>N(1),e.useStoreOrStoreById=X,e.useTable=(e,s)=>Re(i,X(s),0,[e]),e.useTableCellIds=(e,s)=>Re(i+k,X(s),1,[e]),e.useTableCellIdsListener=(e,s,t,o,r)=>ke(i+k,X(r),s,t,[e],o),e.useTableIds=Se,e.useTableIdsListener=(e,s,t,o)=>ke(I,X(o),e,s,ce,t),e.useTableListener=(e,s,t,o,r)=>ke(i,X(r),s,t,[e],o),e.useTables=e=>Re(c,X(e),0),e.useTablesListener=(e,s,t,o)=>ke(c,X(o),e,s,ce,t),e.useUndoInformation=e=>{const s=se(e),[t,r]=Ge(s);return[(u=t,!(0==f(u))),Ue(s),r,S(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Pe,e.useValueIds=xe,e.useValueIdsListener=(e,s,t,o)=>ke(y,X(o),e,s,ce,t),e.useValueListener=(e,s,t,o,r)=>ke(g,X(r),s,t,[e],o),e.useValues=e=>Re(h,X(e),0),e.useValuesListener=(e,s,t,o)=>ke(h,X(o),e,s,ce,t),e.useWillFinishTransactionListener=(e,s,t)=>ke("WillFinish"+oe,X(t),e,s)},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReact={},e.React);
@@ -10,6 +10,7 @@
10
10
  'use strict';
11
11
 
12
12
  const getTypeOf = (thing) => typeof thing;
13
+ const TINYBASE = 'tinybase';
13
14
  const EMPTY_STRING = '';
14
15
  const STRING = getTypeOf(EMPTY_STRING);
15
16
  const FUNCTION = getTypeOf(getTypeOf);
@@ -33,6 +34,7 @@
33
34
  const VALUES = VALUE + 's';
34
35
  const VALUE_IDS = VALUE + IDS;
35
36
 
37
+ const GLOBAL = globalThis;
36
38
  const isUndefined = (thing) => thing == void 0;
37
39
  const ifNotUndefined = (value, then, otherwise) =>
38
40
  isUndefined(value) ? otherwise?.() : then(value);
@@ -66,6 +68,7 @@
66
68
  );
67
69
  const objIds = object.keys;
68
70
  const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
71
+ const objHas = (obj, id) => id in obj;
69
72
  const objDel = (obj, id) => {
70
73
  delete obj[id];
71
74
  return obj;
@@ -84,13 +87,21 @@
84
87
  )
85
88
  );
86
89
  };
90
+ const objEnsure = (obj, id, getDefaultValue) => {
91
+ if (!objHas(obj, id)) {
92
+ obj[id] = getDefaultValue();
93
+ }
94
+ return obj[id];
95
+ };
87
96
 
88
97
  const {
89
98
  createContext,
90
99
  useContext: useContext$1,
91
100
  useEffect: useEffect$1,
92
101
  } = React;
93
- const Context = createContext([]);
102
+ const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () =>
103
+ createContext([]),
104
+ );
94
105
  const useThing = (id, offset) => {
95
106
  const contextValue = useContext$1(Context);
96
107
  return isUndefined(id)
@@ -10,6 +10,7 @@
10
10
  'use strict';
11
11
 
12
12
  const getTypeOf = (thing) => typeof thing;
13
+ const TINYBASE = 'tinybase';
13
14
  const EMPTY_STRING = '';
14
15
  const STRING = getTypeOf(EMPTY_STRING);
15
16
  const FUNCTION = getTypeOf(getTypeOf);
@@ -33,6 +34,7 @@
33
34
  const VALUES = VALUE + 's';
34
35
  const VALUE_IDS = VALUE + IDS;
35
36
 
37
+ const GLOBAL = globalThis;
36
38
  const isUndefined = (thing) => thing == void 0;
37
39
  const ifNotUndefined = (value, then, otherwise) =>
38
40
  isUndefined(value) ? otherwise?.() : then(value);
@@ -66,6 +68,7 @@
66
68
  );
67
69
  const objIds = object.keys;
68
70
  const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
71
+ const objHas = (obj, id) => id in obj;
69
72
  const objDel = (obj, id) => {
70
73
  delete obj[id];
71
74
  return obj;
@@ -84,13 +87,21 @@
84
87
  )
85
88
  );
86
89
  };
90
+ const objEnsure = (obj, id, getDefaultValue) => {
91
+ if (!objHas(obj, id)) {
92
+ obj[id] = getDefaultValue();
93
+ }
94
+ return obj[id];
95
+ };
87
96
 
88
97
  const {
89
98
  createContext,
90
99
  useContext: useContext$1,
91
100
  useEffect: useEffect$1,
92
101
  } = React;
93
- const Context = createContext([]);
102
+ const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () =>
103
+ createContext([]),
104
+ );
94
105
  const useThing = (id, offset) => {
95
106
  const contextValue = useContext$1(Context);
96
107
  return isUndefined(id)