tinybase 5.0.1 → 5.0.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 (42) hide show
  1. package/@types/ui-react/index.d.cts +62 -45
  2. package/@types/ui-react/index.d.ts +62 -45
  3. package/@types/ui-react/with-schemas/index.d.cts +83 -59
  4. package/@types/ui-react/with-schemas/index.d.ts +83 -59
  5. package/cjs/es6/min/ui-react/index.cjs +1 -1
  6. package/cjs/es6/min/ui-react/index.cjs.gz +0 -0
  7. package/cjs/es6/min/ui-react/with-schemas/index.cjs +1 -1
  8. package/cjs/es6/min/ui-react/with-schemas/index.cjs.gz +0 -0
  9. package/cjs/es6/ui-react/index.cjs +13 -6
  10. package/cjs/es6/ui-react/with-schemas/index.cjs +13 -6
  11. package/cjs/min/ui-react/index.cjs +1 -1
  12. package/cjs/min/ui-react/index.cjs.gz +0 -0
  13. package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
  14. package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
  15. package/cjs/ui-react/index.cjs +11 -6
  16. package/cjs/ui-react/with-schemas/index.cjs +11 -6
  17. package/es6/min/ui-react/index.js +1 -1
  18. package/es6/min/ui-react/index.js.gz +0 -0
  19. package/es6/min/ui-react/with-schemas/index.js +1 -1
  20. package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  21. package/es6/ui-react/index.js +13 -6
  22. package/es6/ui-react/with-schemas/index.js +13 -6
  23. package/min/ui-react/index.js +1 -1
  24. package/min/ui-react/index.js.gz +0 -0
  25. package/min/ui-react/with-schemas/index.js +1 -1
  26. package/min/ui-react/with-schemas/index.js.gz +0 -0
  27. package/package.json +1 -1
  28. package/readme.md +2 -2
  29. package/ui-react/index.js +11 -6
  30. package/ui-react/with-schemas/index.js +11 -6
  31. package/umd/es6/min/ui-react/index.js +1 -1
  32. package/umd/es6/min/ui-react/index.js.gz +0 -0
  33. package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
  34. package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  35. package/umd/es6/ui-react/index.js +16 -6
  36. package/umd/es6/ui-react/with-schemas/index.js +16 -6
  37. package/umd/min/ui-react/index.js +1 -1
  38. package/umd/min/ui-react/index.js.gz +0 -0
  39. package/umd/min/ui-react/with-schemas/index.js +1 -1
  40. package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
  41. package/umd/ui-react/index.js +12 -6
  42. package/umd/ui-react/with-schemas/index.js +12 -6
@@ -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](...x(u,(s=>f(s)?s(e,l):s)),t),t)))))),[n,s,...l,...r,...u])},we=(e,s,t=T,l=ne,...o)=>{const r=z(e);return ee((()=>t(null==r?void 0:r["del"+s](...o))),[r,s,...l,...o])},Re=(e,s,t)=>{const l=Y(e);return ee((()=>null==l?void 0:l[s](t)),[l,s,t])},ke=e=>pe(I,z(e),1),ve=(e,s)=>pe(b,z(s),1,[e]),ye=(e,s,t,l=0,o,r)=>pe(w,z(r),1,[e,s,t,l,o]),ge=(e,s,t)=>pe(k,z(t),1,[e,s]),he=(e,s,t,l)=>pe(R,z(l),3,[e,s,t]),me=e=>pe(g,z(e),1),Le=(e,s)=>pe(v,z(s),3,[e]),fe=(e,s)=>pe("Metric",J(s),3,[e]),Se=(e,s)=>pe("SliceIds",K(s),1,[e]),Te=(e,s,t)=>pe("Slice"+b,K(t),1,[e,s]),Ve=(e,s,t)=>pe("RemoteRowId",N(t),3,[e,s]),Pe=(e,s,t)=>pe("Local"+b,N(t),1,[e,s]),xe=(e,s,t)=>pe("Linked"+b,N(t),1,[e,s]),Oe=(e,s)=>pe(n+b,X(s),1,[e]),qe=(e,s,t,l=0,o,r)=>pe(n+w,X(r),1,[e,s,t,l,o]),Be=(e,s,t)=>pe(n+k,X(t),1,[e,s]),He=(e,s,t,l)=>pe(n+R,X(l),3,[e,s,t]),Me=e=>pe("CheckpointIds",Y(e),2),De=(e,s)=>pe("Checkpoint",Y(s),3,[e]),je=e=>Re(e,"goBackward"),Fe=e=>Re(e,"goForward"),{PureComponent:Ee,Fragment:Qe,createElement:Ae,useCallback:Ge,useLayoutEffect:Ue,useRef:We,useState:ze}=s,Je=(e,...s)=>h(e)?{}:e(...s),Ke=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var Ne=Object.defineProperty,Xe=Object.defineProperties,Ye=Object.getOwnPropertyDescriptors,Ze=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable,es=(e,s,t)=>s in e?Ne(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ss=(e,s)=>{for(var t in s||(s={}))$e.call(s,t)&&es(e,t,s[t]);if(Ze)for(var t of Ze(s))_e.call(s,t)&&es(e,t,s[t]);return e},ts=(e,s)=>Xe(e,Ye(s)),ls=(e,s)=>{var t={};for(var l in e)$e.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&Ze)for(var l of Ze(e))s.indexOf(l)<0&&_e.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:os,useContext:rs,useMemo:us,useState:ns}=s,ds=({tableId:e,store:s,rowComponent:t=Cs,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>Is(x(n,(r=>Ae(t,ts(ss({},Je(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),is=({queryId:e,queries:s,resultRowComponent:t=vs,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>Is(x(u,(o=>Ae(t,ts(ss({},Je(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),as=({relationshipId:e,relationships:s,rowComponent:t=Cs,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=Ke(N(s),e),c=u(e,n,d);return Is(x(c,(e=>Ae(t,ts(ss({},Je(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},cs=e=>({checkpoints:s,checkpointComponent:t=ys,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=Y(s);return Is(x(e(Me(u)),(e=>Ae(t,ts(ss({},Je(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},Is=(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},ps=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return Is(l+(null!=(u=he(e,s,t,o))?u:l),void 0,r,t)},Cs=({tableId:e,rowId:s,store:t,cellComponent:l=ps,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>Is(x(((e,s,t,l)=>{const o=ge(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>Ae(l,ts(ss({},Je(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),bs=e=>ds(e,ve(e.tableId,e.store)),ws=({valueId:e,store:s,debugIds:t})=>{var o;return Is(l+(null!=(o=Le(e,s))?o:l),void 0,t,e)},Rs=({indexId:e,sliceId:s,indexes:t,rowComponent:l=Cs,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=Te(e,s,n);return Is(x(a,(e=>Ae(l,ts(ss({},Je(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},ks=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return Is(l+(null!=(u=He(e,s,t,o))?u:l),void 0,r,t)},vs=({queryId:e,rowId:s,queries:t,resultCellComponent:l=ks,getResultCellComponentProps:o,separator:r,debugIds:u})=>Is(x(Be(e,s,t),(r=>Ae(l,ts(ss({},Je(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),ys=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return Is(null!=(o=De(s,e))?o:l,void 0,t,s)},gs=cs((e=>e[0])),hs=cs((e=>h(e[1])?[]:[e[1]])),ms=cs((e=>e[2]));e.BackwardCheckpointsView=gs,e.CellView=ps,e.CheckpointView=ys,e.CurrentCheckpointView=hs,e.ForwardCheckpointsView=ms,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Rs,getSliceComponentProps:l,separator:o,debugIds:r})=>Is(x(Se(e,s),(o=>Ae(t,ts(ss({},Je(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>as(e,xe,e.firstRowId),e.LocalRowsView=e=>as(e,Pe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return Is(null!=(o=fe(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=rs(A),[C,b]=ns({}),w=os(((e,s)=>b((t=>D(t,e)==s?t:ts(ss({},t),{[e]:s})))),[]),R=os((e=>b((s=>ss({},((e,s)=>(delete e[s],e))(s,e))))),[]);return Ae(A.Provider,{value:us((()=>[null!=e?e:p[0],ss(ss(ss({},p[1]),s),C),null!=t?t:p[2],ss(ss({},p[3]),l),null!=o?o:p[4],ss(ss({},p[5]),r),null!=u?u:p[6],ss(ss({},p[7]),n),null!=d?d:p[8],ss(ss({},p[9]),i),null!=a?a:p[10],ss(ss({},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=Cs,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=Ke(N(t),e),i=Ve(e,s,u);return Is(h(d)||h(i)?null:Ae(l,ts(ss({},Je(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=ks,e.ResultRowView=vs,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=ls(s,["cellId","descending","offset","limit"]);return is(u,qe(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>is(e,Oe(e.queryId,e.queries)),e.RowView=Cs,e.SliceView=Rs,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=ls(s,["cellId","descending","offset","limit"]);return ds(u,ye(u.tableId,t,l,o,r,u.store))},e.TableView=bs,e.TablesView=({store:e,tableComponent:s=bs,getTableComponentProps:t,separator:l,debugIds:o})=>Is(x(ke(e),(l=>Ae(s,ts(ss({},Je(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=ws,e.ValuesView=({store:e,valueComponent:s=ws,getValueComponentProps:t,separator:l,debugIds:o})=>Is(x(me(e),(l=>Ae(s,ts(ss({},Je(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=he,e.useCellIds=ge,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=De,e.useCheckpointIds=Me,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((()=>{const t=e?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)=>we(o,R,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>we(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>we(s,a,t,l,e),e.useDelTablesCallback=(e,s,t)=>we(e,c,s,t),e.useDelValueCallback=(e,s,t,l)=>we(s,v,t,l,e),e.useDelValuesCallback=(e,s,t)=>we(e,y,s,t),e.useDidFinishTransactionListener=(e,s,t)=>Ce("DidFinish"+$,z(t),e,s),e.useGoBackwardCallback=je,e.useGoForwardCallback=Fe,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=xe,e.useLinkedRowIdsListener=(e,s,t,l,o)=>Ce("Linked"+b,N(o),t,l,[e,s]),e.useLocalRowIds=Pe,e.useLocalRowIdsListener=(e,s,t,l,o)=>Ce("Local"+b,N(o),t,l,[e,s]),e.useMetric=fe,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]]=Me(t);return[!h(o),Fe(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=Ve,e.useRemoteRowIdListener=(e,s,t,l,o)=>Ce("RemoteRowId",N(o),t,l,[e,s]),e.useResultCell=He,e.useResultCellIds=Be,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=Oe,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=qe,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=ve,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=Se,e.useSliceIdsListener=(e,s,t,l)=>Ce("SliceIds",K(l),s,t,[e]),e.useSliceRowIds=Te,e.useSliceRowIdsListener=(e,s,t,l,o)=>Ce("Slice"+b,K(o),t,l,[e,s]),e.useSortedRowIds=ye,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=ke,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]=Me(t);return[(u=o,!(0==S(u))),je(t),r,null!=(s=m(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=Le,e.useValueIds=me,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=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((()=>{const t=e?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);
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](...x(u,(s=>f(s)?s(e,l):s)),t),t)))))),[n,s,...l,...r,...u])},we=(e,s,t=T,l=ne,...o)=>{const r=z(e);return ee((()=>t(null==r?void 0:r["del"+s](...o))),[r,s,...l,...o])},Re=(e,s,t)=>{const l=Y(e);return ee((()=>null==l?void 0:l[s](t)),[l,s,t])},ke=e=>pe(I,z(e),1),ve=(e,s)=>pe(b,z(s),1,[e]),ye=(e,s,t,l=0,o,r)=>pe(w,z(r),1,[e,s,t,l,o]),ge=(e,s,t)=>pe(k,z(t),1,[e,s]),he=(e,s,t,l)=>pe(R,z(l),3,[e,s,t]),me=e=>pe(g,z(e),1),Le=(e,s)=>pe(v,z(s),3,[e]),fe=(e,s)=>pe("Metric",J(s),3,[e]),Se=(e,s)=>pe("SliceIds",K(s),1,[e]),Te=(e,s,t)=>pe("Slice"+b,K(t),1,[e,s]),Ve=(e,s,t)=>pe("RemoteRowId",N(t),3,[e,s]),Pe=(e,s,t)=>pe("Local"+b,N(t),1,[e,s]),xe=(e,s,t)=>pe("Linked"+b,N(t),1,[e,s]),Oe=(e,s)=>pe(n+b,X(s),1,[e]),qe=(e,s,t,l=0,o,r)=>pe(n+w,X(r),1,[e,s,t,l,o]),Be=(e,s,t)=>pe(n+k,X(t),1,[e,s]),He=(e,s,t,l)=>pe(n+R,X(l),3,[e,s,t]),Me=e=>pe("CheckpointIds",Y(e),2),De=(e,s)=>pe("Checkpoint",Y(s),3,[e]),je=e=>Re(e,"goBackward"),Fe=e=>Re(e,"goForward"),{PureComponent:Ee,Fragment:Qe,createElement:Ae,useCallback:Ge,useLayoutEffect:Ue,useRef:We,useState:ze}=s,Je=(e,...s)=>h(e)?{}:e(...s),Ke=(e,s)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(s),null==e?void 0:e.getRemoteTableId(s)];var Ne=Object.defineProperty,Xe=Object.defineProperties,Ye=Object.getOwnPropertyDescriptors,Ze=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable,es=(e,s,t)=>s in e?Ne(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,ss=(e,s)=>{for(var t in s||(s={}))$e.call(s,t)&&es(e,t,s[t]);if(Ze)for(var t of Ze(s))_e.call(s,t)&&es(e,t,s[t]);return e},ts=(e,s)=>Xe(e,Ye(s)),ls=(e,s)=>{var t={};for(var l in e)$e.call(e,l)&&s.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&Ze)for(var l of Ze(e))s.indexOf(l)<0&&_e.call(e,l)&&(t[l]=e[l]);return t};const{useCallback:os,useContext:rs,useMemo:us,useState:ns}=s,ds=({tableId:e,store:s,rowComponent:t=Cs,getRowComponentProps:l,customCellIds:o,separator:r,debugIds:u},n)=>Is(x(n,(r=>Ae(t,ts(ss({},Je(l,r)),{key:r,tableId:e,rowId:r,customCellIds:o,store:s,debugIds:u})))),r,u,e),is=({queryId:e,queries:s,resultRowComponent:t=vs,getResultRowComponentProps:l,separator:o,debugIds:r},u)=>Is(x(u,(o=>Ae(t,ts(ss({},Je(l,o)),{key:o,queryId:e,rowId:o,queries:s,debugIds:r})))),o,r,e),as=({relationshipId:e,relationships:s,rowComponent:t=Cs,getRowComponentProps:l,separator:o,debugIds:r},u,n)=>{const[d,i,a]=Ke(N(s),e),c=u(e,n,d);return Is(x(c,(e=>Ae(t,ts(ss({},Je(l,e)),{key:e,tableId:a,rowId:e,store:i,debugIds:r})))),o,r,n)},cs=e=>({checkpoints:s,checkpointComponent:t=ys,getCheckpointComponentProps:l,separator:o,debugIds:r})=>{const u=Y(s);return Is(x(e(Me(u)),(e=>Ae(t,ts(ss({},Je(l,e)),{key:e,checkpoints:u,checkpointId:e,debugIds:r})))),o)},Is=(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},ps=({tableId:e,rowId:s,cellId:t,store:o,debugIds:r})=>{var u;return Is(l+(null!=(u=he(e,s,t,o))?u:l),void 0,r,t)},Cs=({tableId:e,rowId:s,store:t,cellComponent:l=ps,getCellComponentProps:o,customCellIds:r,separator:u,debugIds:n})=>Is(x(((e,s,t,l)=>{const o=ge(s,t,l);return null!=e?e:o})(r,e,s,t),(r=>Ae(l,ts(ss({},Je(o,r)),{key:r,tableId:e,rowId:s,cellId:r,store:t,debugIds:n})))),u,n,s),bs=e=>ds(e,ve(e.tableId,e.store)),ws=({valueId:e,store:s,debugIds:t})=>{var o;return Is(l+(null!=(o=Le(e,s))?o:l),void 0,t,e)},Rs=({indexId:e,sliceId:s,indexes:t,rowComponent:l=Cs,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=Te(e,s,n);return Is(x(a,(e=>Ae(l,ts(ss({},Je(o,e)),{key:e,tableId:i,rowId:e,store:d,debugIds:u})))),r,u,s)},ks=({queryId:e,rowId:s,cellId:t,queries:o,debugIds:r})=>{var u;return Is(l+(null!=(u=He(e,s,t,o))?u:l),void 0,r,t)},vs=({queryId:e,rowId:s,queries:t,resultCellComponent:l=ks,getResultCellComponentProps:o,separator:r,debugIds:u})=>Is(x(Be(e,s,t),(r=>Ae(l,ts(ss({},Je(o,r)),{key:r,queryId:e,rowId:s,cellId:r,queries:t,debugIds:u})))),r,u,s),ys=({checkpoints:e,checkpointId:s,debugIds:t})=>{var o;return Is(null!=(o=De(s,e))?o:l,void 0,t,s)},gs=cs((e=>e[0])),hs=cs((e=>h(e[1])?[]:[e[1]])),ms=cs((e=>e[2]));e.BackwardCheckpointsView=gs,e.CellView=ps,e.CheckpointView=ys,e.CurrentCheckpointView=hs,e.ForwardCheckpointsView=ms,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=Rs,getSliceComponentProps:l,separator:o,debugIds:r})=>Is(x(Se(e,s),(o=>Ae(t,ts(ss({},Je(l,o)),{key:o,indexId:e,sliceId:o,indexes:s,debugIds:r})))),o,r,e),e.LinkedRowsView=e=>as(e,xe,e.firstRowId),e.LocalRowsView=e=>as(e,Pe,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>{var o;return Is(null!=(o=fe(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=rs(A),[C,b]=ns({}),w=os(((e,s)=>b((t=>D(t,e)==s?t:ts(ss({},t),{[e]:s})))),[]),R=os((e=>b((s=>ss({},((e,s)=>(delete e[s],e))(s,e))))),[]);return Ae(A.Provider,{value:us((()=>[null!=e?e:p[0],ss(ss(ss({},p[1]),s),C),null!=t?t:p[2],ss(ss({},p[3]),l),null!=o?o:p[4],ss(ss({},p[5]),r),null!=u?u:p[6],ss(ss({},p[7]),n),null!=d?d:p[8],ss(ss({},p[9]),i),null!=a?a:p[10],ss(ss({},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=Cs,getRowComponentProps:o,debugIds:r})=>{const[u,n,,d]=Ke(N(t),e),i=Ve(e,s,u);return Is(h(d)||h(i)?null:Ae(l,ts(ss({},Je(o,i)),{key:i,tableId:d,rowId:i,store:n,debugIds:r})),void 0,r,s)},e.ResultCellView=ks,e.ResultRowView=vs,e.ResultSortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=ls(s,["cellId","descending","offset","limit"]);return is(u,qe(u.queryId,t,l,o,r,u.queries))},e.ResultTableView=e=>is(e,Oe(e.queryId,e.queries)),e.RowView=Cs,e.SliceView=Rs,e.SortedTableView=e=>{var s=e,{cellId:t,descending:l,offset:o,limit:r}=s,u=ls(s,["cellId","descending","offset","limit"]);return ds(u,ye(u.tableId,t,l,o,r,u.store))},e.TableView=bs,e.TablesView=({store:e,tableComponent:s=bs,getTableComponentProps:t,separator:l,debugIds:o})=>Is(x(ke(e),(l=>Ae(s,ts(ss({},Je(t,l)),{key:l,tableId:l,store:e,debugIds:o})))),l),e.ValueView=ws,e.ValuesView=({store:e,valueComponent:s=ws,getValueComponentProps:t,separator:l,debugIds:o})=>Is(x(me(e),(l=>Ae(s,ts(ss({},Je(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=he,e.useCellIds=ge,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=De,e.useCheckpointIds=Me,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((()=>{const t=e?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)=>we(o,R,r,u,e,s,t,l),e.useDelRowCallback=(e,s,t,l,o)=>we(t,p,l,o,e,s),e.useDelTableCallback=(e,s,t,l)=>we(s,a,t,l,e),e.useDelTablesCallback=(e,s,t)=>we(e,c,s,t),e.useDelValueCallback=(e,s,t,l)=>we(s,v,t,l,e),e.useDelValuesCallback=(e,s,t)=>we(e,y,s,t),e.useDidFinishTransactionListener=(e,s,t)=>Ce("DidFinish"+$,z(t),e,s),e.useGoBackwardCallback=je,e.useGoForwardCallback=Fe,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=xe,e.useLinkedRowIdsListener=(e,s,t,l,o)=>Ce("Linked"+b,N(o),t,l,[e,s]),e.useLocalRowIds=Pe,e.useLocalRowIdsListener=(e,s,t,l,o)=>Ce("Local"+b,N(o),t,l,[e,s]),e.useMetric=fe,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]]=Me(t);return[!h(o),Fe(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=Ve,e.useRemoteRowIdListener=(e,s,t,l,o)=>Ce("RemoteRowId",N(o),t,l,[e,s]),e.useResultCell=He,e.useResultCellIds=Be,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=Oe,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=qe,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=ve,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=Se,e.useSliceIdsListener=(e,s,t,l)=>Ce("SliceIds",K(l),s,t,[e]),e.useSliceRowIds=Te,e.useSliceRowIdsListener=(e,s,t,l,o)=>Ce("Slice"+b,K(o),t,l,[e,s]),e.useSortedRowIds=ye,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=ke,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]=Me(t);return[(u=o,!(0==S(u))),je(t),r,null!=(s=m(r,(e=>null==t?void 0:t.getCheckpoint(e))))?s:l];var u},e.useValue=Le,e.useValueIds=me,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=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((()=>{const t=e?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);
@@ -52,6 +52,7 @@
52
52
  arrayEvery(array1, (value1, index) => array2[index] === value1);
53
53
  const arrayMap = (array, cb) => array.map(cb);
54
54
  const arrayIsEmpty = (array) => size(array) == 0;
55
+ const arrayFilter = (array, cb) => array.filter(cb);
55
56
 
56
57
  const object = Object;
57
58
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -291,9 +292,7 @@
291
292
  ifNotUndefined(get(parameter, store2), (thing) =>
292
293
  then(
293
294
  store2['set' + settable](
294
- ...arrayMap(args, (arg) =>
295
- isFunction(arg) ? arg(parameter, store2) : arg,
296
- ),
295
+ ...argsOrGetArgs(args, store2, parameter),
297
296
  thing,
298
297
  ),
299
298
  thing,
@@ -301,9 +300,13 @@
301
300
  ),
302
301
  ),
303
302
  // eslint-disable-next-line react-hooks/exhaustive-deps
304
- [store, settable, ...getDeps, ...thenDeps, ...args],
303
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
305
304
  );
306
305
  };
306
+ const argsOrGetArgs = (args, store, parameter) =>
307
+ arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
308
+ const nonFunctionDeps = (args) =>
309
+ arrayFilter(args, (arg) => !isFunction(arg));
307
310
  const useDel = (
308
311
  storeOrStoreId,
309
312
  deletable,
@@ -313,9 +316,16 @@
313
316
  ) => {
314
317
  const store = useStoreOrStoreById(storeOrStoreId);
315
318
  return useCallback$2(
316
- () => then(store == null ? void 0 : store['del' + deletable](...args)),
319
+ (parameter) =>
320
+ then(
321
+ store == null
322
+ ? void 0
323
+ : store['del' + deletable](
324
+ ...argsOrGetArgs(args, store, parameter),
325
+ ),
326
+ ),
317
327
  // eslint-disable-next-line react-hooks/exhaustive-deps
318
- [store, deletable, ...thenDeps, ...args],
328
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
319
329
  );
320
330
  };
321
331
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
@@ -52,6 +52,7 @@
52
52
  arrayEvery(array1, (value1, index) => array2[index] === value1);
53
53
  const arrayMap = (array, cb) => array.map(cb);
54
54
  const arrayIsEmpty = (array) => size(array) == 0;
55
+ const arrayFilter = (array, cb) => array.filter(cb);
55
56
 
56
57
  const object = Object;
57
58
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -291,9 +292,7 @@
291
292
  ifNotUndefined(get(parameter, store2), (thing) =>
292
293
  then(
293
294
  store2['set' + settable](
294
- ...arrayMap(args, (arg) =>
295
- isFunction(arg) ? arg(parameter, store2) : arg,
296
- ),
295
+ ...argsOrGetArgs(args, store2, parameter),
297
296
  thing,
298
297
  ),
299
298
  thing,
@@ -301,9 +300,13 @@
301
300
  ),
302
301
  ),
303
302
  // eslint-disable-next-line react-hooks/exhaustive-deps
304
- [store, settable, ...getDeps, ...thenDeps, ...args],
303
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
305
304
  );
306
305
  };
306
+ const argsOrGetArgs = (args, store, parameter) =>
307
+ arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
308
+ const nonFunctionDeps = (args) =>
309
+ arrayFilter(args, (arg) => !isFunction(arg));
307
310
  const useDel = (
308
311
  storeOrStoreId,
309
312
  deletable,
@@ -313,9 +316,16 @@
313
316
  ) => {
314
317
  const store = useStoreOrStoreById(storeOrStoreId);
315
318
  return useCallback$2(
316
- () => then(store == null ? void 0 : store['del' + deletable](...args)),
319
+ (parameter) =>
320
+ then(
321
+ store == null
322
+ ? void 0
323
+ : store['del' + deletable](
324
+ ...argsOrGetArgs(args, store, parameter),
325
+ ),
326
+ ),
317
327
  // eslint-disable-next-line react-hooks/exhaustive-deps
318
- [store, deletable, ...thenDeps, ...args],
328
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
319
329
  );
320
330
  };
321
331
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
@@ -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](...P(l,(s=>T(s)?s(e,o):s)),t),t)))))),[n,s,...o,...u,...l])},we=(e,s,t=f,o=ne,...r)=>{const u=J(e);return ee((()=>t(u?.["del"+s](...r))),[u,s,...o,...r])},Re=(e,s,t)=>{const o=Z(e);return ee((()=>o?.[s](t)),[o,s,t])},ke=e=>Ce(I,J(e),1),ge=(e,s)=>Ce(b,J(s),1,[e]),Le=(e,s,t,o=0,r,u)=>Ce(w,J(u),1,[e,s,t,o,r]),he=(e,s,t)=>Ce(k,J(t),1,[e,s]),ye=(e,s,t,o)=>Ce(R,J(o),3,[e,s,t]),me=e=>Ce(h,J(e),1),Se=(e,s)=>Ce(g,J(s),3,[e]),Te=(e,s)=>Ce("Metric",K(s),3,[e]),Ve=(e,s)=>Ce("SliceIds",N(s),1,[e]),fe=(e,s,t)=>Ce("Slice"+b,N(t),1,[e,s]),xe=(e,s,t)=>Ce("RemoteRowId",X(t),3,[e,s]),ve=(e,s,t)=>Ce("Local"+b,X(t),1,[e,s]),Pe=(e,s,t)=>Ce("Linked"+b,X(t),1,[e,s]),qe=(e,s)=>Ce(n+b,Y(s),1,[e]),Be=(e,s,t,o=0,r,u)=>Ce(n+w,Y(u),1,[e,s,t,o,r]),He=(e,s,t)=>Ce(n+k,Y(t),1,[e,s]),Me=(e,s,t,o)=>Ce(n+R,Y(o),3,[e,s,t]),De=e=>Ce("CheckpointIds",Z(e),2),Fe=(e,s)=>Ce("Checkpoint",Z(s),3,[e]),Oe=e=>Re(e,"goBackward"),Qe=e=>Re(e,"goForward"),{PureComponent:Ee,Fragment:Ae,createElement:Ge,useCallback:je,useLayoutEffect:Ue,useRef:We,useState:ze}=s,Je=(e,...s)=>y(e)?{}:e(...s),Ke=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Ne,useContext:Xe,useMemo:Ye,useState:Ze}=s,$e=({tableId:e,store:s,rowComponent:t=rs,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ts(P(n,(u=>Ge(t,{...Je(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),_e=({queryId:e,queries:s,resultRowComponent:t=as,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ts(P(l,(r=>Ge(t,{...Je(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),es=({relationshipId:e,relationships:s,rowComponent:t=rs,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=Ke(X(s),e),c=l(e,n,d);return ts(P(c,(e=>Ge(t,{...Je(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},ss=e=>({checkpoints:s,checkpointComponent:t=is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Z(s);return ts(P(e(De(l)),(e=>Ge(t,{...Je(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ts=(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},os=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ts(o+(ye(e,s,t,r)??o),void 0,u,t),rs=({tableId:e,rowId:s,store:t,cellComponent:o=os,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ts(P(((e,s,t,o)=>{const r=he(s,t,o);return e??r})(u,e,s,t),(u=>Ge(o,{...Je(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),us=e=>$e(e,ge(e.tableId,e.store)),ls=({valueId:e,store:s,debugIds:t})=>ts(o+(Se(e,s)??o),void 0,t,e),ns=({indexId:e,sliceId:s,indexes:t,rowComponent:o=rs,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(N(t),e),i=fe(e,s,n);return ts(P(i,(e=>Ge(o,{...Je(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},ds=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ts(o+(Me(e,s,t,r)??o),void 0,u,t),as=({queryId:e,rowId:s,queries:t,resultCellComponent:o=ds,getResultCellComponentProps:r,separator:u,debugIds:l})=>ts(P(He(e,s,t),(u=>Ge(o,{...Je(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),is=({checkpoints:e,checkpointId:s,debugIds:t})=>ts(Fe(s,e)??o,void 0,t,s),cs=ss((e=>e[0])),Is=ss((e=>y(e[1])?[]:[e[1]])),Cs=ss((e=>e[2]));e.BackwardCheckpointsView=cs,e.CellView=os,e.CheckpointView=is,e.CurrentCheckpointView=Is,e.ForwardCheckpointsView=Cs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=ns,getSliceComponentProps:o,separator:r,debugIds:u})=>ts(P(Ve(e,s),(r=>Ge(t,{...Je(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>es(e,Pe,e.firstRowId),e.LocalRowsView=e=>es(e,ve,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ts(Te(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=Xe(j),[p,b]=Ze({}),w=Ne(((e,s)=>b((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),R=Ne((e=>b((s=>({...O(s,e)})))),[]);return Ge(j.Provider,{value:Ye((()=>[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=rs,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Ke(X(t),e),a=xe(e,s,l);return ts(y(d)||y(a)?null:Ge(o,{...Je(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=ds,e.ResultRowView=as,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>_e(r,Be(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>_e(e,qe(e.queryId,e.queries)),e.RowView=rs,e.SliceView=ns,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>$e(r,Le(r.tableId,e,s,t,o,r.store)),e.TableView=us,e.TablesView=({store:e,tableComponent:s=us,getTableComponentProps:t,separator:o,debugIds:r})=>ts(P(ke(e),(o=>Ge(s,{...Je(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ls,e.ValuesView=({store:e,valueComponent:s=ls,getValueComponentProps:t,separator:o,debugIds:r})=>ts(P(me(e),(o=>Ge(s,{...Je(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=ye,e.useCellIds=he,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=Fe,e.useCheckpointIds=De,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((()=>{const t=e?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)=>we(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>we(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>we(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>we(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>we(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>we(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>pe("DidFinish"+_,J(t),e,s),e.useGoBackwardCallback=Oe,e.useGoForwardCallback=Qe,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=Pe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>pe("Linked"+b,X(r),t,o,[e,s]),e.useLocalRowIds=ve,e.useLocalRowIdsListener=(e,s,t,o,r)=>pe("Local"+b,X(r),t,o,[e,s]),e.useMetric=Te,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]]=De(s);return[!y(t),Qe(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=xe,e.useRemoteRowIdListener=(e,s,t,o,r)=>pe("RemoteRowId",X(r),t,o,[e,s]),e.useResultCell=Me,e.useResultCellIds=He,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=qe,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=Be,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=ge,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=Ve,e.useSliceIdsListener=(e,s,t,o)=>pe("SliceIds",N(o),s,t,[e]),e.useSliceRowIds=fe,e.useSliceRowIdsListener=(e,s,t,o,r)=>pe("Slice"+b,N(r),t,o,[e,s]),e.useSortedRowIds=Le,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=ke,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]=De(s);return[(u=t,!(0==V(u))),Oe(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Se,e.useValueIds=me,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",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((()=>{const t=e?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);
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](...P(l,(s=>T(s)?s(e,o):s)),t),t)))))),[n,s,...o,...u,...l])},we=(e,s,t=f,o=ne,...r)=>{const u=J(e);return ee((()=>t(u?.["del"+s](...r))),[u,s,...o,...r])},Re=(e,s,t)=>{const o=Z(e);return ee((()=>o?.[s](t)),[o,s,t])},ke=e=>Ce(I,J(e),1),ge=(e,s)=>Ce(b,J(s),1,[e]),Le=(e,s,t,o=0,r,u)=>Ce(w,J(u),1,[e,s,t,o,r]),he=(e,s,t)=>Ce(k,J(t),1,[e,s]),ye=(e,s,t,o)=>Ce(R,J(o),3,[e,s,t]),me=e=>Ce(h,J(e),1),Se=(e,s)=>Ce(g,J(s),3,[e]),Te=(e,s)=>Ce("Metric",K(s),3,[e]),Ve=(e,s)=>Ce("SliceIds",N(s),1,[e]),fe=(e,s,t)=>Ce("Slice"+b,N(t),1,[e,s]),xe=(e,s,t)=>Ce("RemoteRowId",X(t),3,[e,s]),ve=(e,s,t)=>Ce("Local"+b,X(t),1,[e,s]),Pe=(e,s,t)=>Ce("Linked"+b,X(t),1,[e,s]),qe=(e,s)=>Ce(n+b,Y(s),1,[e]),Be=(e,s,t,o=0,r,u)=>Ce(n+w,Y(u),1,[e,s,t,o,r]),He=(e,s,t)=>Ce(n+k,Y(t),1,[e,s]),Me=(e,s,t,o)=>Ce(n+R,Y(o),3,[e,s,t]),De=e=>Ce("CheckpointIds",Z(e),2),Fe=(e,s)=>Ce("Checkpoint",Z(s),3,[e]),Oe=e=>Re(e,"goBackward"),Qe=e=>Re(e,"goForward"),{PureComponent:Ee,Fragment:Ae,createElement:Ge,useCallback:je,useLayoutEffect:Ue,useRef:We,useState:ze}=s,Je=(e,...s)=>y(e)?{}:e(...s),Ke=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Ne,useContext:Xe,useMemo:Ye,useState:Ze}=s,$e=({tableId:e,store:s,rowComponent:t=rs,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ts(P(n,(u=>Ge(t,{...Je(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),_e=({queryId:e,queries:s,resultRowComponent:t=as,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ts(P(l,(r=>Ge(t,{...Je(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),es=({relationshipId:e,relationships:s,rowComponent:t=rs,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,a,i]=Ke(X(s),e),c=l(e,n,d);return ts(P(c,(e=>Ge(t,{...Je(o,e),key:e,tableId:i,rowId:e,store:a,debugIds:u}))),r,u,n)},ss=e=>({checkpoints:s,checkpointComponent:t=is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Z(s);return ts(P(e(De(l)),(e=>Ge(t,{...Je(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ts=(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},os=({tableId:e,rowId:s,cellId:t,store:r,debugIds:u})=>ts(o+(ye(e,s,t,r)??o),void 0,u,t),rs=({tableId:e,rowId:s,store:t,cellComponent:o=os,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ts(P(((e,s,t,o)=>{const r=he(s,t,o);return e??r})(u,e,s,t),(u=>Ge(o,{...Je(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),us=e=>$e(e,ge(e.tableId,e.store)),ls=({valueId:e,store:s,debugIds:t})=>ts(o+(Se(e,s)??o),void 0,t,e),ns=({indexId:e,sliceId:s,indexes:t,rowComponent:o=rs,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,a]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(N(t),e),i=fe(e,s,n);return ts(P(i,(e=>Ge(o,{...Je(r,e),key:e,tableId:a,rowId:e,store:d,debugIds:l}))),u,l,s)},ds=({queryId:e,rowId:s,cellId:t,queries:r,debugIds:u})=>ts(o+(Me(e,s,t,r)??o),void 0,u,t),as=({queryId:e,rowId:s,queries:t,resultCellComponent:o=ds,getResultCellComponentProps:r,separator:u,debugIds:l})=>ts(P(He(e,s,t),(u=>Ge(o,{...Je(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),is=({checkpoints:e,checkpointId:s,debugIds:t})=>ts(Fe(s,e)??o,void 0,t,s),cs=ss((e=>e[0])),Is=ss((e=>y(e[1])?[]:[e[1]])),Cs=ss((e=>e[2]));e.BackwardCheckpointsView=cs,e.CellView=os,e.CheckpointView=is,e.CurrentCheckpointView=Is,e.ForwardCheckpointsView=Cs,e.IndexView=({indexId:e,indexes:s,sliceComponent:t=ns,getSliceComponentProps:o,separator:r,debugIds:u})=>ts(P(Ve(e,s),(r=>Ge(t,{...Je(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),e.LinkedRowsView=e=>es(e,Pe,e.firstRowId),e.LocalRowsView=e=>es(e,ve,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:t})=>ts(Te(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=Xe(j),[p,b]=Ze({}),w=Ne(((e,s)=>b((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),R=Ne((e=>b((s=>({...O(s,e)})))),[]);return Ge(j.Provider,{value:Ye((()=>[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=rs,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Ke(X(t),e),a=xe(e,s,l);return ts(y(d)||y(a)?null:Ge(o,{...Je(r,a),key:a,tableId:d,rowId:a,store:n,debugIds:u}),void 0,u,s)},e.ResultCellView=ds,e.ResultRowView=as,e.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>_e(r,Be(r.queryId,e,s,t,o,r.queries)),e.ResultTableView=e=>_e(e,qe(e.queryId,e.queries)),e.RowView=rs,e.SliceView=ns,e.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>$e(r,Le(r.tableId,e,s,t,o,r.store)),e.TableView=us,e.TablesView=({store:e,tableComponent:s=us,getTableComponentProps:t,separator:o,debugIds:r})=>ts(P(ke(e),(o=>Ge(s,{...Je(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),e.ValueView=ls,e.ValuesView=({store:e,valueComponent:s=ls,getValueComponentProps:t,separator:o,debugIds:r})=>ts(P(me(e),(o=>Ge(s,{...Je(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=ye,e.useCellIds=he,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=Fe,e.useCheckpointIds=De,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((()=>{const t=e?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)=>we(r,R,u,l,e,s,t,o),e.useDelRowCallback=(e,s,t,o,r)=>we(t,C,o,r,e,s),e.useDelTableCallback=(e,s,t,o)=>we(s,i,t,o,e),e.useDelTablesCallback=(e,s,t)=>we(e,c,s,t),e.useDelValueCallback=(e,s,t,o)=>we(s,g,t,o,e),e.useDelValuesCallback=(e,s,t)=>we(e,L,s,t),e.useDidFinishTransactionListener=(e,s,t)=>pe("DidFinish"+_,J(t),e,s),e.useGoBackwardCallback=Oe,e.useGoForwardCallback=Qe,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=Pe,e.useLinkedRowIdsListener=(e,s,t,o,r)=>pe("Linked"+b,X(r),t,o,[e,s]),e.useLocalRowIds=ve,e.useLocalRowIdsListener=(e,s,t,o,r)=>pe("Local"+b,X(r),t,o,[e,s]),e.useMetric=Te,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]]=De(s);return[!y(t),Qe(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=xe,e.useRemoteRowIdListener=(e,s,t,o,r)=>pe("RemoteRowId",X(r),t,o,[e,s]),e.useResultCell=Me,e.useResultCellIds=He,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=qe,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=Be,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=ge,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=Ve,e.useSliceIdsListener=(e,s,t,o)=>pe("SliceIds",N(o),s,t,[e]),e.useSliceRowIds=fe,e.useSliceRowIdsListener=(e,s,t,o,r)=>pe("Slice"+b,N(r),t,o,[e,s]),e.useSortedRowIds=Le,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=ke,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]=De(s);return[(u=t,!(0==V(u))),Oe(s),r,m(r,(e=>s?.getCheckpoint(e)))??o];var u},e.useValue=Se,e.useValueIds=me,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",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((()=>{const t=e?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);
@@ -48,6 +48,7 @@
48
48
  arrayEvery(array1, (value1, index) => array2[index] === value1);
49
49
  const arrayMap = (array, cb) => array.map(cb);
50
50
  const arrayIsEmpty = (array) => size(array) == 0;
51
+ const arrayFilter = (array, cb) => array.filter(cb);
51
52
 
52
53
  const object = Object;
53
54
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -247,9 +248,7 @@
247
248
  ifNotUndefined(get(parameter, store2), (thing) =>
248
249
  then(
249
250
  store2['set' + settable](
250
- ...arrayMap(args, (arg) =>
251
- isFunction(arg) ? arg(parameter, store2) : arg,
252
- ),
251
+ ...argsOrGetArgs(args, store2, parameter),
253
252
  thing,
254
253
  ),
255
254
  thing,
@@ -257,9 +256,13 @@
257
256
  ),
258
257
  ),
259
258
  // eslint-disable-next-line react-hooks/exhaustive-deps
260
- [store, settable, ...getDeps, ...thenDeps, ...args],
259
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
261
260
  );
262
261
  };
262
+ const argsOrGetArgs = (args, store, parameter) =>
263
+ arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
264
+ const nonFunctionDeps = (args) =>
265
+ arrayFilter(args, (arg) => !isFunction(arg));
263
266
  const useDel = (
264
267
  storeOrStoreId,
265
268
  deletable,
@@ -269,9 +272,12 @@
269
272
  ) => {
270
273
  const store = useStoreOrStoreById(storeOrStoreId);
271
274
  return useCallback$2(
272
- () => then(store?.['del' + deletable](...args)),
275
+ (parameter) =>
276
+ then(
277
+ store?.['del' + deletable](...argsOrGetArgs(args, store, parameter)),
278
+ ),
273
279
  // eslint-disable-next-line react-hooks/exhaustive-deps
274
- [store, deletable, ...thenDeps, ...args],
280
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
275
281
  );
276
282
  };
277
283
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
@@ -48,6 +48,7 @@
48
48
  arrayEvery(array1, (value1, index) => array2[index] === value1);
49
49
  const arrayMap = (array, cb) => array.map(cb);
50
50
  const arrayIsEmpty = (array) => size(array) == 0;
51
+ const arrayFilter = (array, cb) => array.filter(cb);
51
52
 
52
53
  const object = Object;
53
54
  const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
@@ -247,9 +248,7 @@
247
248
  ifNotUndefined(get(parameter, store2), (thing) =>
248
249
  then(
249
250
  store2['set' + settable](
250
- ...arrayMap(args, (arg) =>
251
- isFunction(arg) ? arg(parameter, store2) : arg,
252
- ),
251
+ ...argsOrGetArgs(args, store2, parameter),
253
252
  thing,
254
253
  ),
255
254
  thing,
@@ -257,9 +256,13 @@
257
256
  ),
258
257
  ),
259
258
  // eslint-disable-next-line react-hooks/exhaustive-deps
260
- [store, settable, ...getDeps, ...thenDeps, ...args],
259
+ [store, settable, ...getDeps, ...thenDeps, ...nonFunctionDeps(args)],
261
260
  );
262
261
  };
262
+ const argsOrGetArgs = (args, store, parameter) =>
263
+ arrayMap(args, (arg) => (isFunction(arg) ? arg(parameter, store) : arg));
264
+ const nonFunctionDeps = (args) =>
265
+ arrayFilter(args, (arg) => !isFunction(arg));
263
266
  const useDel = (
264
267
  storeOrStoreId,
265
268
  deletable,
@@ -269,9 +272,12 @@
269
272
  ) => {
270
273
  const store = useStoreOrStoreById(storeOrStoreId);
271
274
  return useCallback$2(
272
- () => then(store?.['del' + deletable](...args)),
275
+ (parameter) =>
276
+ then(
277
+ store?.['del' + deletable](...argsOrGetArgs(args, store, parameter)),
278
+ ),
273
279
  // eslint-disable-next-line react-hooks/exhaustive-deps
274
- [store, deletable, ...thenDeps, ...args],
280
+ [store, deletable, ...thenDeps, ...nonFunctionDeps(args)],
275
281
  );
276
282
  };
277
283
  const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {