tinybase 7.2.0-beta.2 → 7.2.0

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 (44) hide show
  1. package/@types/queries/index.d.ts +333 -4
  2. package/@types/queries/with-schemas/index.d.ts +359 -4
  3. package/@types/ui-react/index.d.ts +477 -8
  4. package/@types/ui-react/with-schemas/index.d.ts +519 -8
  5. package/agents.md +34 -0
  6. package/index.js +100 -18
  7. package/min/index.js +1 -1
  8. package/min/index.js.gz +0 -0
  9. package/min/omni/index.js +1 -1
  10. package/min/omni/index.js.gz +0 -0
  11. package/min/omni/with-schemas/index.js +1 -1
  12. package/min/omni/with-schemas/index.js.gz +0 -0
  13. package/min/queries/index.js +1 -1
  14. package/min/queries/index.js.gz +0 -0
  15. package/min/queries/with-schemas/index.js +1 -1
  16. package/min/queries/with-schemas/index.js.gz +0 -0
  17. package/min/ui-react/index.js +1 -1
  18. package/min/ui-react/index.js.gz +0 -0
  19. package/min/ui-react/with-schemas/index.js +1 -1
  20. package/min/ui-react/with-schemas/index.js.gz +0 -0
  21. package/min/ui-react-dom/index.js +1 -1
  22. package/min/ui-react-dom/index.js.gz +0 -0
  23. package/min/ui-react-dom/with-schemas/index.js +1 -1
  24. package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
  25. package/min/ui-react-inspector/index.js +1 -1
  26. package/min/ui-react-inspector/index.js.gz +0 -0
  27. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  28. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  29. package/min/with-schemas/index.js +1 -1
  30. package/min/with-schemas/index.js.gz +0 -0
  31. package/omni/index.js +173 -48
  32. package/omni/with-schemas/index.js +173 -48
  33. package/package.json +3 -3
  34. package/queries/index.js +120 -18
  35. package/queries/with-schemas/index.js +120 -18
  36. package/readme.md +13 -13
  37. package/releases.md +40 -40
  38. package/ui-react/index.js +98 -30
  39. package/ui-react/with-schemas/index.js +98 -30
  40. package/ui-react-dom/index.js +38 -15
  41. package/ui-react-dom/with-schemas/index.js +38 -15
  42. package/ui-react-inspector/index.js +40 -17
  43. package/ui-react-inspector/with-schemas/index.js +40 -17
  44. package/with-schemas/index.js +100 -18
@@ -1 +1 @@
1
- const e=e=>typeof e,t=e(""),n=e(!0),s=e(0),r=e(e),o="Listener",a="Result",i="Ids",d="Table",l="Row",c=l+"Count",u=l+i,v="Sorted"+l+i,h="Cell",w=h+i,g=Math,L=g.max,f=g.min,R=isFinite,y=e=>void 0===e,m=(p=y,(e,t,n)=>p(e)?n?.():t(e));var p;const T=t=>e(t)==r,b=e=>Array.isArray(e),C=e=>e.length,S=()=>{},I=(e,t)=>e.every(t),Q=(e,t)=>e.forEach(t),E=e=>x(e,(e,t)=>e+t,0),M=e=>0==C(e),x=(e,t,n)=>e.reduce(t,n),D=(e,...t)=>e.push(...t),j=e=>e?.size??0,k=(e,t)=>e?.has(t)??!1,z=e=>y(e)||0==j(e),A=e=>[...e?.values()??[]],F=e=>e.clear(),P=(e,t)=>e?.forEach(t),V=(e,t)=>e?.delete(t),O=Object,W=O.entries,q=O.freeze,B=e=>new Map(e),G=(e,t)=>e?.get(t),H=(e,t)=>P(e,(e,n)=>t(n,e)),J=(e,t,n)=>y(n)?(V(e,t),e):e?.set(t,n),K=(e,t,n,s)=>(k(e,t)?s?.(G(e,t)):J(e,t,n()),G(e,t)),N=(e,t,n,s)=>{const r={};return P(e,(e,t)=>{{const n=e;r[t]=n}}),r},U=(e,t,n,s,r=0)=>m((n?K:G)(e,t[r],r>C(t)-2?n:B),o=>{if(r>C(t)-2)return s?.(o)&&J(e,t[r]),o;const a=U(o,t,n,s,r+1);return z(o)&&J(e,t[r]),a}),X=B([["avg",[(e,t)=>E(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,s)=>e+(t-n)/s]],["max",[e=>L(...e),(e,t)=>L(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:L(t,e)]],["min",[e=>f(...e),(e,t)=>f(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:f(t,e)]],["sum",[e=>E(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),Y=e=>new Set(b(e)||y(e)?e:[e]),Z=(e,t)=>e?.add(t),$=(()=>{const r=new WeakMap;return i=>(r.has(i)||r.set(i,(r=>{const i=r.createStore,g=i(),L=i(),f=B(),{addListener:p,callListeners:E,delListener:x}=L,[$,_,ee,te,ne,se,re,oe,,ae,ie,de,le,ce]=((e,t,n,s,r)=>{const o=e.hasRow,a=B(),i=B(),d=B(),l=B(),c=B(),u=B(),v=(t,n,...s)=>{const r=K(u,t,Y);return Q(s,t=>Z(r,t)&&n&&e.callListener(t)),s},h=(t,...n)=>m(G(u,t),s=>{Q(M(n)?A(s):n,t=>{e.delListener(t),V(s,t)}),z(s)&&J(u,t)}),w=(e,t)=>{J(a,e,t),k(i,e)||(J(i,e,[()=>{},B()]),J(l,e,B()),J(c,e,B()),r(d))},g=e=>{J(a,e),J(i,e),J(l,e),J(c,e),h(e),r(d)};return[()=>e,()=>{return e=a,[...e?.keys()??[]];var e},e=>H(i,e),e=>k(i,e),e=>G(a,e),e=>G(i,e),(e,t)=>J(i,e,t),w,(t,s,r,a,i)=>{w(t,s);const d=B(),u=B(),g=G(l,t),L=G(c,t),f=t=>{const r=n=>e.getCell(s,t,n),l=G(g,t),c=o(s,t)?n(a(r,t)):void 0;var v,h;if(l===c||b(l)&&b(c)&&(h=c,C(v=l)===C(h)&&I(v,(e,t)=>h[t]===e))||J(d,t,[l,c]),!y(i)){const e=G(L,t),n=o(s,t)?i(r,t):void 0;e!=n&&J(u,t,n)}},R=e=>{r(()=>{P(d,([,e],t)=>J(g,t,e)),P(u,(e,t)=>J(L,t,e))},d,u,g,L,e),F(d),F(u)};H(g,f),e.hasTable(s)&&Q(e.getRowIds(s),e=>{k(g,e)||f(e)}),R(!0),h(t),v(t,0,e.addRowListener(s,null,(e,t,n)=>f(n)),e.addTableListener(s,()=>R()))},g,e=>s(e,d),()=>H(u,g),v,h]})(r,0,S,p,E),ue=(e,t,...n)=>Q(n,n=>Z(K(K(f,t,B),e,Y),n)),ve=e=>{m(G(f,e),e=>{H(e,(e,t)=>P(t,t=>e.delListener(t))),F(e)}),Q([L,g],t=>t.delTable(e))},he=(e,t,n)=>ue(t,e,t.addStartTransactionListener(n.startTransaction),t.addDidFinishTransactionListener(()=>n.finishTransaction())),we=(o,a,i,d={})=>{var l;oe(o,a),re(o,[i,(l=d,new Map(W(l)))]),ve(o);const[,c]=se(o),u=[],v=[[void 0,[a,void 0,void 0,[],B()]]],h=[],w=[],f=[];i({select:(e,t)=>{const n=T(e)?[C(u)+"",e]:[y(t)?e:t,n=>n(e,t)];return D(u,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const s=y(n)||T(t)?void 0:t,r=y(s)?t:n,o=[e,[e,s,T(r)?r:e=>e(r),[],B()]];return D(v,o),{as:e=>o[0]=e}},where:(e,t,n)=>D(h,T(e)?e:y(n)?n=>n(e)===t:s=>s(e,t)===n),group:(e,t,n,s,r)=>{const o=[e,[e,T(t)?[t,n,s,r]:G(X,t)??[(e,t)=>t]]];return D(w,o),{as:e=>o[0]=e}},having:(e,t)=>D(f,T(e)?e:n=>n(e)===t),param:e=>G(c,e)});const p=B(u);if(z(p))return Le;const b=B(v);H(b,(e,[,t])=>m(G(b,t),({3:t})=>y(e)?0:D(t,e)));const S=B(w);let E=g;if(z(S)&&M(f))E=L;else{he(o,E,L);const r=B();H(S,(e,[t,n])=>Z(K(r,t,Y),[e,n]));const a=Y();H(p,e=>k(r,e)?0:Z(a,e));const i=B(),d=(a,i,d,l)=>m(a,([c,u,v,h])=>{H(i,(o,[a])=>{const i=K(c,o,B),u=G(i,d),v=l?void 0:a;if(u!==v){const a=Y([[u,v]]),l=j(i);J(i,d,v),P(G(r,o),([r,o])=>{const d=((e,t,n,s,r,o=!1)=>{if(z(n))return;const[a,i,d,l]=r;return o||=y(e),P(s,([n,s])=>{o||(e=y(n)?i?.(e,s,t++):y(s)?d?.(e,n,t--):l?.(e,s,n,t),o||=y(e))}),o?a(A(n),j(n)):e})(h[r],l,i,a,o);h[r]=y((r=>{if(null===r)return"null";const o=e(r);return(e=>e==t||e==n)(o)||o==s&&R(r)?o:void 0})(d))?void 0:d})}}),z(u)||!I(f,e=>e(e=>h[e]))?L.delRow(o,v):y(v)?a[2]=L.addRow(o,h):L.setRow(o,v,h)});ue(E,o,E.addRowListener(o,null,(e,t,n,s)=>{const l=[],c=[],u=B(),v=E.hasRow(o,n);let h=!v;P(a,e=>{const[t,r,a]=s(o,n,e);D(l,r),D(c,a),h||=t}),H(r,e=>{const[t,,r]=s(o,n,e);(h||t)&&J(u,e,[r])}),h&&d(U(i,l,void 0,([,e])=>(V(e,n),z(e))),u,n,1),v&&d(U(i,c,()=>{const e={};return P(a,t=>e[t]=E.getCell(o,n,t)),[B(),Y(),void 0,e]},([,e])=>{Z(e,n)}),u,n)}))}he(o,r,E);const x=(e,t,n,s)=>{const i=e=>r.getCell(t,n,e);Q(s,t=>{const[n,,s,a,d]=G(b,t),l=s?.(i,e),[c,u]=G(d,e)??[];l!=c&&(y(u)||ce(o,u),J(d,e,y(l)?void 0:[l,...le(o,1,r.addRowListener(n,l,()=>x(e,n,l,a)))]))}),(e=>{const t=(t,n)=>r.getCell(...y(n)?[a,e,t]:t===a?[a,e,n]:[G(b,t)?.[0],G(G(b,t)?.[4],e)?.[0],n]);E.transaction(()=>I(h,e=>e(t))?H(p,(n,s)=>((e,t,n,s,r)=>y(r)?e.delCell(t,n,s,!0):e.setCell(t,n,s,r))(E,o,e,n,s(t,e))):E.delRow(o,e))})(e)},{3:F}=G(b,void 0);return E.transaction(()=>le(o,1,r.addRowListener(a,null,(e,t,n)=>{r.hasRow(a,n)?x(n,a,n,F):(E.delRow(o,n),P(b,({4:e})=>m(G(e,n),([,t])=>{ce(o,t),J(e,n)})))}))),Le},ge=(e,t)=>(m(se(e),n=>L.transaction(()=>we(e,ne(e),n[0],t))),Le),Le={setQueryDefinition:we,delQueryDefinition:e=>(ve(e),ae(e),Le),setParamValues:ge,setParamValue:(e,t,n)=>ge(e,{...N(se(e)?.[1]),[t]:n}),getStore:$,getQueryIds:_,forEachQuery:ee,hasQuery:te,getTableId:ne,addQueryIdsListener:e=>ie(()=>e(Le)),delListener:e=>(x(e),Le),destroy:de,getListenerStats:()=>{const{tables:e,tableIds:t,transaction:n,...s}=L.getListenerStats();return s}};return fe=([e,t],n)=>{Q(e?["get","has","forEach"]:["get"],e=>Le[e+a+n]=(...t)=>L[e+n](...t)),Le["add"+a+n+o]=(...e)=>{return L["add"+n+o](...(s=e,r=t,s.slice(0,r)),(n,...s)=>e[t](Le,...s),!0);var s,r}},((e=[])=>{O.fromEntries(e)})(((e,t)=>((e,t)=>e.map(t))(W(e),([e,n])=>t(n,e)))({[d]:[1,1],[d+w]:[0,1],[c]:[0,1],[u]:[0,1],[v]:[0,5],[l]:[1,2],[w]:[0,2],[h]:[1,3]},(e,t)=>[t,fe(e,t)])),q(Le);var fe})(i)),r.get(i))})();export{$ as createQueries};
1
+ const e=e=>typeof e,t=e(""),n=e(!0),r=e(0),s=e(e),a="Listener",o="Result",i="Ids",d="Table",l="Row",c=l+"Count",u=l+i,v="Sorted"+l+i,g="Cell",L=g+i,h=e=>(t,n,r)=>e(t)?r?.():n(t),w=Math,f=w.max,m=w.min,y=isFinite,R=e=>null==e,p=e=>void 0===e,T=h(R),b=h(p),C=t=>e(t)==s,V=e=>Array.isArray(e),P=e=>e.length,S=()=>{},I=(e,t)=>e.every(t),Q=(e,t)=>P(e)===P(t)&&I(e,(e,n)=>t[n]===e),E=(e,t)=>V(e)&&V(t)?Q(e,t):e===t,M=(e,t)=>e.forEach(t),k=e=>D(e,(e,t)=>e+t,0),x=e=>0==P(e),D=(e,t,n)=>e.reduce(t,n),j=(e,...t)=>e.push(...t),z=e=>t=>D(B(t),(t,n)=>t+e(n),0),A=e=>e?.size??0,F=z(A),O=z(F),W=(e,t)=>e?.has(t)??!1,q=e=>p(e)||0==A(e),B=e=>[...e?.values()??[]],G=e=>e.clear(),H=(e,t)=>e?.forEach(t),J=(e,t)=>e?.delete(t),K=Object,N=e=>K.getPrototypeOf(e),U=K.entries,X=e=>!R(e)&&T(N(e),e=>e==K.prototype||R(N(e)),()=>!0),Y=K.keys,Z=K.freeze,$=(e,t)=>b(e,e=>e[t]),_=(e,t,n=(e,t)=>e===t)=>{const r=U(e);return P(r)===P(Y(t))&&I(r,([e,r])=>X(r)?!!X(t[e])&&_(t[e],r):n(r,t[e]))},ee=e=>new Map(e),te=(e,t)=>e?.get(t),ne=(e,t)=>H(e,(e,n)=>t(n,e)),re=(e,t,n)=>p(n)?(J(e,t),e):e?.set(t,n),se=(e,t,n,r)=>(W(e,t)?r?.(te(e,t)):re(e,t,n()),te(e,t)),ae=(e,t,n,r)=>{const s={};return H(e,(e,t)=>{{const n=e;s[t]=n}}),s},oe=(e,t,n,r,s=0)=>b((n?se:te)(e,t[s],s>P(t)-2?n:ee),a=>{if(s>P(t)-2)return r?.(a)&&re(e,t[s]),a;const o=oe(a,t,n,r,s+1);return q(a)&&re(e,t[s]),o}),ie=ee([["avg",[(e,t)=>k(e)/t,(e,t,n)=>e+(t-e)/(n+1),(e,t,n)=>e+(e-t)/(n-1),(e,t,n,r)=>e+(t-n)/r]],["max",[e=>f(...e),(e,t)=>f(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:f(t,e)]],["min",[e=>m(...e),(e,t)=>m(t,e),(e,t)=>t==e?void 0:e,(e,t,n)=>n==e?void 0:m(t,e)]],["sum",[e=>k(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,n)=>e-n+t]]]),de=e=>new Set(V(e)||p(e)?e:[e]),le=(e,t)=>e?.add(t),ce=(()=>{const s=new WeakMap;return i=>(s.has(i)||s.set(i,(s=>{const i=s.createStore,h=i(),w=i(),f=ee(),m=ee(),R=ee(),{addListener:T,callListeners:k,delListener:D}=w,[z,N,X,ce,ue,ve,ge,Le,,he,we,fe,me,ye]=((e,t,n,r,s)=>{const a=e.hasRow,o=ee(),i=ee(),d=ee(),l=ee(),c=ee(),u=ee(),v=(t,n,...r)=>{const s=se(u,t,de);return M(r,t=>le(s,t)&&n&&e.callListener(t)),r},g=(t,...n)=>b(te(u,t),r=>{M(x(n)?B(r):n,t=>{e.delListener(t),J(r,t)}),q(r)&&re(u,t)}),L=(e,t)=>{re(o,e,t),W(i,e)||(re(i,e,[]),re(l,e,ee()),re(c,e,ee()),s(d))},h=e=>{re(o,e),re(i,e),re(l,e),re(c,e),g(e),s(d)};return[()=>e,()=>{return e=o,[...e?.keys()??[]];var e},e=>ne(i,e),e=>W(i,e),e=>te(o,e),e=>te(i,e),(e,t)=>re(i,e,t),L,(t,r,s,o,i)=>{L(t,r);const d=ee(),u=ee(),h=te(l,t),w=te(c,t),f=t=>{const s=n=>e.getCell(r,t,n),l=te(h,t),c=a(r,t)?n(o(s,t)):void 0;if(l===c||V(l)&&V(c)&&Q(l,c)||re(d,t,[l,c]),!p(i)){const e=te(w,t),n=a(r,t)?i(s,t):void 0;e!=n&&re(u,t,n)}},m=e=>{s(()=>{H(d,([,e],t)=>re(h,t,e)),H(u,(e,t)=>re(w,t,e))},d,u,h,w,e),G(d),G(u)};ne(h,f),e.hasTable(r)&&M(e.getRowIds(r),e=>{W(h,e)||f(e)}),m(!0),g(t),v(t,0,e.addRowListener(r,null,(e,t,n)=>f(n)),e.addTableListener(r,()=>m()))},h,e=>r(e,d),()=>ne(u,h),v,g]})(s,0,S,T,k),Re=(e,t,...n)=>M(n,n=>le(se(se(f,t,ee),e,de),n)),pe=e=>{b(te(f,e),e=>{ne(e,(e,t)=>H(t,t=>e.delListener(t))),G(e)}),M([w,h],t=>t.delTable(e))},Te=(e,t,n)=>Re(t,e,t.addStartTransactionListener(n.startTransaction),t.addDidFinishTransactionListener(()=>n.finishTransaction())),be=(a,o,i,d={})=>{const l=Pe(a);var c;Le(a,o),ge(a,[i,(c=d,new Map(U(c)))]),Ce(a,l,d),pe(a);const[,u]=ve(a),v=[],g=[[void 0,[o,void 0,void 0,[],ee()]]],L=[],f=[],m=[];i({select:(e,t)=>{const n=C(e)?[P(v)+"",e]:[p(t)?e:t,n=>n(e,t)];return j(v,n),{as:e=>n[0]=e}},join:(e,t,n)=>{const r=p(n)||C(t)?void 0:t,s=p(r)?t:n,a=[e,[e,r,C(s)?s:e=>e(s),[],ee()]];return j(g,a),{as:e=>a[0]=e}},where:(e,t,n)=>j(L,C(e)?e:p(n)?n=>n(e)===t:r=>r(e,t)===n),group:(e,t,n,r,s)=>{const a=[e,[e,C(t)?[t,n,r,s]:te(ie,t)??[(e,t)=>t]]];return j(f,a),{as:e=>a[0]=e}},having:(e,t)=>j(m,C(e)?e:n=>n(e)===t),param:e=>te(u,e)});const R=ee(v);if(q(R))return Ie;const T=ee(g);ne(T,(e,[,t])=>b(te(T,t),({3:t})=>p(e)?0:j(t,e)));const V=ee(f);let S=h;if(q(V)&&x(m))S=w;else{Te(a,S,w);const s=ee();ne(V,(e,[t,n])=>le(se(s,t,de),[e,n]));const o=de();ne(R,e=>W(s,e)?0:le(o,e));const i=ee(),d=(o,i,d,l)=>b(o,([c,u,v,g])=>{ne(i,(a,[o])=>{const i=se(c,a,ee),u=te(i,d),v=l?void 0:o;if(u!==v){const o=de([[u,v]]),l=A(i);re(i,d,v),H(te(s,a),([s,a])=>{const d=((e,t,n,r,s,a=!1)=>{if(q(n))return;const[o,i,d,l]=s;return a||=p(e),H(r,([n,r])=>{a||(e=p(n)?i?.(e,r,t++):p(r)?d?.(e,n,t--):l?.(e,r,n,t),a||=p(e))}),a?o(B(n),A(n)):e})(g[s],l,i,o,a);g[s]=p((s=>{if(null===s)return"null";const a=e(s);return(e=>e==t||e==n)(a)||a==r&&y(s)?a:void 0})(d))?void 0:d})}}),q(u)||!I(m,e=>e(e=>g[e]))?w.delRow(a,v):p(v)?o[2]=w.addRow(a,g):w.setRow(a,v,g)});Re(S,a,S.addRowListener(a,null,(e,t,n,r)=>{const l=[],c=[],u=ee(),v=S.hasRow(a,n);let g=!v;H(o,e=>{const[t,s,o]=r(a,n,e);j(l,s),j(c,o),g||=t}),ne(s,e=>{const[t,,s]=r(a,n,e);(g||t)&&re(u,e,[s])}),g&&d(oe(i,l,void 0,([,e])=>(J(e,n),q(e))),u,n,1),v&&d(oe(i,c,()=>{const e={};return H(o,t=>e[t]=S.getCell(a,n,t)),[ee(),de(),void 0,e]},([,e])=>{le(e,n)}),u,n)}))}Te(a,s,S);const Q=(e,t,n,r)=>{const i=e=>s.getCell(t,n,e);M(r,t=>{const[n,,r,o,d]=te(T,t),l=r?.(i,e),[c,u]=te(d,e)??[];l!=c&&(p(u)||ye(a,u),re(d,e,p(l)?void 0:[l,...me(a,1,s.addRowListener(n,l,()=>Q(e,n,l,o)))]))}),(e=>{const t=(t,n)=>s.getCell(...p(n)?[o,e,t]:t===o?[o,e,n]:[te(T,t)?.[0],te(te(T,t)?.[4],e)?.[0],n]);S.transaction(()=>I(L,e=>e(t))?ne(R,(n,r)=>((e,t,n,r,s)=>p(s)?e.delCell(t,n,r,!0):e.setCell(t,n,r,s))(S,a,e,n,r(t,e))):S.delRow(a,e))})(e)},{3:E}=te(T,void 0);return S.transaction(()=>me(a,1,s.addRowListener(o,null,(e,t,n)=>{s.hasRow(o,n)?Q(n,o,n,E):(S.delRow(a,n),H(T,({4:e})=>b(te(e,n),([,t])=>{ye(a,t),re(e,n)})))}))),Ie},Ce=(e,t,n)=>{const r=de([...Y(t),...Y(n)]);let s=0;H(r,r=>{const a=$(n,r);E($(t,r),a)||(s=1,k(R,[e,r],a))}),s&&k(m,[e],n)},Ve=(e,t,n=0)=>(b(ve(e),([r,s])=>{!n&&_(ae(s),t,E)||w.transaction(()=>be(e,ue(e),r,t))}),Ie),Pe=e=>ae(ve(e)?.[1]),Se=(e,t)=>te(ve(e)?.[1],t),Ie={setQueryDefinition:be,delQueryDefinition:e=>{const t=Pe(e);return pe(e),he(e),Ce(e,t,{}),Ie},getParamValues:Pe,getParamValue:Se,setParamValues:Ve,setParamValue:(e,t,n)=>(E(Se(e,t),n)||Ve(e,{...Pe(e),[t]:n},1),Ie),getStore:z,getQueryIds:N,forEachQuery:X,hasQuery:ce,getTableId:ue,addQueryIdsListener:e=>we(()=>e(Ie)),addParamValuesListener:(e,t)=>T((e,n,r)=>t(Ie,n,r),m,[e]),addParamValueListener:(e,t,n)=>T((e,t,r,s)=>n(Ie,t,r,s),R,[e,t]),delListener:e=>(D(e),Ie),destroy:fe,getListenerStats:()=>{const{tables:e,tableIds:t,transaction:n,...r}=w.getListenerStats();return{...r,paramValues:F(m),paramValue:O(R)}}};return Qe=([e,t],n)=>{M(e?["get","has","forEach"]:["get"],e=>Ie[e+o+n]=(...t)=>w[e+n](...t)),Ie["add"+o+n+a]=(...e)=>{return w["add"+n+a](...(r=e,s=t,r.slice(0,s)),(n,...r)=>e[t](Ie,...r),!0);var r,s}},((e=[])=>{K.fromEntries(e)})(((e,t)=>((e,t)=>e.map(t))(U(e),([e,n])=>t(n,e)))({[d]:[1,1],[d+L]:[0,1],[c]:[0,1],[u]:[0,1],[v]:[0,5],[l]:[1,2],[L]:[0,2],[g]:[1,3]},(e,t)=>[t,Qe(e,t)])),Z(Ie);var Qe})(i)),s.get(i))})();export{ce as createQueries};
@@ -1 +1 @@
1
- import e from"react";import{jsx as t}from"react/jsx-runtime";const o=e=>typeof e,r="",s=o(r),d=o(o),n="Result",i="Has",l="Ids",u="Table",c=u+"s",a=u+l,I="Row",p=I+"Count",g=I+l,b="Sorted"+I+l,m="Cell",C=m+l,y="Value",w=y+"s",h=y+l,f="Transaction",v="Partial",R="Finish",k="Status",P="Metric",q="Slice",x="RemoteRowId",S="Local",B="Linked",T="Checkpoint",L=e=>(t,o,r)=>e(t)?r?.():o(t),V=globalThis,E=e=>null==e,j=e=>void 0===e,z=L(E),A=L(j),F=e=>o(e)==s,M=e=>o(e)==d,O=e=>e.length,D=()=>{},H=(e,t)=>e.every(t),Q=(e,t)=>O(e)===O(t)&&H(e,(e,o)=>t[o]===e),W=(e,t)=>e.map(t),_=(e,t,o)=>e.with(t,o),G=Object,J=e=>G.getPrototypeOf(e),K=G.entries,N=e=>!E(e)&&z(J(e),e=>e==G.prototype||E(J(e)),()=>!0),U=G.keys,X=(e,t)=>A(e,e=>e[t]),Y=(e,t)=>{const o=K(e);return O(o)===O(U(t))&&H(o,([e,o])=>N(o)?!!N(t[e])&&Y(t[e],o):t[e]===o)},{PureComponent:Z,createContext:$,useCallback:ee,useContext:te,useEffect:oe,useLayoutEffect:re,useMemo:se,useRef:de,useState:ne,useSyncExternalStore:ie}=e,le=(e,...t)=>j(e)?{}:e(...t),ue=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],ce="tinybase_uirc",ae=V[ce]?V[ce]:V[ce]=$([]),Ie=(e,t)=>{const o=te(ae);return j(e)?o[2*t]:F(e)?X(o[2*t+1],e):e},pe=(e,t)=>{const o=Ie(e,t);return j(e)||F(e)?o:e},ge=(e,t,o)=>{const{16:r,17:s}=te(ae);oe(()=>(r?.(o,e,t),()=>s?.(o,e)),[r,e,t,o,s])},be=e=>U(te(ae)[2*e+1]??{}),me=0,Ce=1,ye=2,we=3,he=4,fe=5,ve=6,Re=7,ke=(e,t,o,r,s)=>[o??t[2*e],{...t[2*e+1],...r,...s[e]}],Pe=({store:e,storesById:o,metrics:r,metricsById:s,indexes:d,indexesById:n,relationships:i,relationshipsById:l,queries:u,queriesById:c,checkpoints:a,checkpointsById:I,persister:p,persistersById:g,synchronizer:b,synchronizersById:m,children:C})=>{const y=te(ae),[w,h]=ne(()=>W([,,,,,,,,].fill(0),(e,t)=>({}))),f=ee((e,t,o)=>h(r=>X(r[e],t)==o?r:_(r,e,{...r[e],[t]:o})),[]),v=ee((e,t)=>h(o=>((e,t)=>t in e)(o[e],t)?_(o,e,((e,t)=>(delete e[t],e))(o[e],t)):o),[]);return t(ae.Provider,{value:se(()=>[...ke(0,y,e,o,w),...ke(1,y,r,s,w),...ke(2,y,d,n,w),...ke(3,y,i,l,w),...ke(4,y,u,c,w),...ke(5,y,a,I,w),...ke(6,y,p,g,w),...ke(7,y,b,m,w),f,v],[w,e,o,r,s,d,n,i,l,u,c,a,I,p,g,b,m,y,f,v]),children:C})},qe=[],xe=[{},[],[qe,void 0,qe],void 0,!1,0],Se=[Y,Q,([e,t,o],[r,s,d])=>t===s&&Q(e,r)&&Q(o,d)],Be=(e,t)=>e===t,Te=(e,t,o=qe)=>{const[,r]=ne(),[s,d]=ne();return oe(()=>{const o=e?t(e):void 0;return d(o),r([]),o?.destroy},[e,...o]),s},Le=(e,t,...o)=>{const r=e?.["add"+t+"Listener"]?.(...o);return()=>e?.delListener?.(r)},Ve=(e,t,o,s=qe)=>{const d=de(xe[o]),n=ee(()=>{const r=t?.[(4==o?"has":"get")+e]?.(...s)??xe[o];return(Se[o]??Be)(r,d.current)?d.current:d.current=r},[t,o,e,...s]),l=ee(d=>Le(t,(4==o?i:r)+e,...s,d),[t,o,e,...s]);return ie(l,n,n)},Ee=(e,t,o,r=qe,s=qe,...d)=>re(()=>Le(t,e,...s,o,...d),[t,e,...s,...r,...d]),je=(e,t,o,r=qe,s=D,d=qe,n="",...i)=>ee(r=>A(e,e=>A(o(r,e),o=>s(e[n+t](...Fe(i,e,r),o),o))),[e,t,...r,...d,n,...Me(i)]),ze=(e,t,o,r=qe,s=D,d=qe,...n)=>je(Je(e),t,o,r,s,d,"set",...n),Ae=(e,t,o,s=qe,d=D,n=qe,...i)=>je(Eo(e),t,o,s,d,n,r,...i),Fe=(e,t,o)=>W(e,e=>M(e)?e(o,t):e),Me=e=>{return t=e=>!M(e),e.filter(t);var t},Oe=(e,t,o=D,r=qe,...s)=>{const d=Je(e);return ee(e=>o(d?.["del"+t](...Fe(s,d,e))),[d,t,...r,...Me(s)])},De=(e,t,o)=>{const r=rr(e);return ee(()=>r?.[t](o),[r,t,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o.goTo(e),e))),[d,...t,...s])},ar=e=>{const t=rr(e),[o,s]=dr(t);return[(d=o,!(0==O(d))),lr(t),s,A(s,e=>t?.getCheckpoint(e))??r];var d},Ir=e=>{const t=rr(e),[,,[o]]=dr(t);return[!j(o),ur(t),o,A(o,e=>t?.getCheckpoint(e))??r]},pr=(e,t,o)=>Ee(T+l,rr(o),e,t),gr=(e,t,o,r)=>Ee(T,rr(r),t,o,[e]),br=(e,t,o=qe,r,s=qe,d,n=qe)=>{const[,i]=ne(),[l,u]=ne();return oe(()=>{(async()=>{const o=e?await t(e):void 0;u(o),o&&r&&(async()=>{await r(o),i([])})()})()},[e,...o,...s]),oe(()=>()=>{l&&(l.destroy(),d?.(l))},[l,...n]),l},mr=()=>be(6),Cr=e=>Ie(e,6),yr=e=>pe(e,6),wr=(e,t)=>ge(e,t,6),hr=e=>Ve(k,yr(e),5,[]),fr=(e,t,o)=>Ee(k,yr(o),e,t,[]),vr=(e,t,o=qe,r,s=qe)=>{const[d,n]=ne();return oe(()=>{(async()=>{const o=e?await t(e):void 0;n(o)})()},[e,...o]),oe(()=>()=>{d&&(d.destroy(),r?.(d))},[d,...s]),d},Rr=()=>be(7),kr=e=>Ie(e,7),Pr=e=>pe(e,7),qr=(e,t)=>ge(e,t,7),xr=e=>Ve(k,Pr(e),5,[]),Sr=(e,t,o)=>Ee(k,Pr(o),e,t,[]),Br=(e,t,o,r)=>{const s=j(t)||!Array.isArray(e)?e:W(e,(e,o)=>o>0?[t,e]:e);return o?[r,":{",s,"}"]:s},Tr=({checkpoints:e,checkpointId:t,debugIds:o})=>Br(nr(t,e)??r,void 0,o,t),Lr=({queryId:e,rowId:t,cellId:o,queries:s,debugIds:d})=>Br(r+(Wo(e,t,o,s)??r),void 0,d,o),Vr=({queryId:e,rowId:o,queries:r,resultCellComponent:s=Lr,getResultCellComponentProps:d,separator:n,debugIds:i})=>Br(W(Qo(e,o,r),n=>t(s,{...le(d,n),queryId:e,rowId:o,cellId:n,queries:r,debugIds:i},n)),n,i,o),Er=({tableId:e,rowId:t,cellId:o,store:s,debugIds:d})=>Br(r+(ut(e,t,o,s)??r),void 0,d,o),jr=({tableId:e,rowId:o,store:r,cellComponent:s=Er,getCellComponentProps:d,customCellIds:n,separator:i,debugIds:l})=>Br(W(((e,t,o,r)=>{const s=it(t,o,r);return e??s})(n,e,o,r),n=>t(s,{...le(d,n),tableId:e,rowId:o,cellId:n,store:r,debugIds:l},n)),i,l,o),zr=({tableId:e,store:o,rowComponent:r=jr,getRowComponentProps:s,customCellIds:d,separator:n,debugIds:i},l)=>Br(W(l,n=>t(r,{...le(s,n),tableId:e,rowId:n,customCellIds:d,store:o,debugIds:i},n)),n,i,e),Ar=({queryId:e,queries:o,resultRowComponent:r=Vr,getResultRowComponentProps:s,separator:d,debugIds:n},i)=>Br(W(i,d=>t(r,{...le(s,d),queryId:e,rowId:d,queries:o,debugIds:n},d)),d,n,e),Fr=({relationshipId:e,relationships:o,rowComponent:r=jr,getRowComponentProps:s,separator:d,debugIds:n},i,l)=>{const[u,c,a]=ue(fo(o),e),I=i(e,l,u);return Br(W(I,e=>t(r,{...le(s,e),tableId:a,rowId:e,store:c,debugIds:n},e)),d,n,l)},Mr=e=>({checkpoints:o,checkpointComponent:r=Tr,getCheckpointComponentProps:s,separator:d,debugIds:n})=>{const i=rr(o);return Br(W(e(dr(i)),e=>t(r,{...le(s,e),checkpoints:i,checkpointId:e,debugIds:n},e)),d)},Or=Mr(e=>e[0]),Dr=Mr(e=>j(e[1])?[]:[e[1]]),Hr=Mr(e=>e[2]),Qr=({indexId:e,sliceId:o,indexes:r,rowComponent:s=jr,getRowComponentProps:d,separator:n,debugIds:i})=>{const[l,u,c]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(ao(r),e),a=bo(e,o,l);return Br(W(a,e=>t(s,{...le(d,e),tableId:c,rowId:e,store:u,debugIds:i},e)),n,i,o)},Wr=({indexId:e,indexes:o,sliceComponent:r=Qr,getSliceComponentProps:s,separator:d,debugIds:n})=>Br(W(po(e,o),d=>t(r,{...le(s,d),indexId:e,sliceId:d,indexes:o,debugIds:n},d)),d,n,e),_r=e=>Fr(e,qo,e.firstRowId),Gr=e=>Fr(e,Po,e.remoteRowId),Jr=({metricId:e,metrics:t,debugIds:o})=>Br(no(e,t)??r,void 0,o,e),Kr=({relationshipId:e,localRowId:o,relationships:r,rowComponent:s=jr,getRowComponentProps:d,debugIds:n})=>{const[i,l,,u]=ue(fo(r),e),c=ko(e,o,i);return Br(j(u)||j(c)?null:t(s,{...le(d,c),tableId:u,rowId:c,store:l,debugIds:n},c),void 0,n,o)},Nr=({cellId:e,descending:t,offset:o,limit:r,...s})=>Ar(s,Do(s.queryId,e,t,o,r,s.queries)),Ur=e=>Ar(e,Oo(e.queryId,e.queries)),Xr=({cellId:e,descending:t,offset:o,limit:r,...s})=>zr(s,st(s.tableId,e,t,o,r,s.store)),Yr=e=>zr(e,rt(e.tableId,e.store)),Zr=({store:e,tableComponent:o=Yr,getTableComponentProps:r,separator:s,debugIds:d})=>Br(W(Ye(e),s=>t(o,{...le(r,s),tableId:s,store:e,debugIds:d},s)),s),$r=({valueId:e,store:t,debugIds:o})=>Br(r+(gt(e,t)??r),void 0,o,e),es=({store:e,valueComponent:o=$r,getValueComponentProps:r,separator:s,debugIds:d})=>Br(W(It(e),s=>t(o,{...le(r,s),valueId:s,store:e,debugIds:d},s)),s);export{Or as BackwardCheckpointsView,Er as CellView,Tr as CheckpointView,Dr as CurrentCheckpointView,Hr as ForwardCheckpointsView,Wr as IndexView,_r as LinkedRowsView,Gr as LocalRowsView,Jr as MetricView,fe as OFFSET_CHECKPOINTS,ye as OFFSET_INDEXES,Ce as OFFSET_METRICS,ve as OFFSET_PERSISTER,he as OFFSET_QUERIES,we as OFFSET_RELATIONSHIPS,me as OFFSET_STORE,Re as OFFSET_SYNCHRONIZER,Pe as Provider,Kr as RemoteRowView,Lr as ResultCellView,Vr as ResultRowView,Nr as ResultSortedTableView,Ur as ResultTableView,jr as RowView,Qr as SliceView,Xr as SortedTableView,Yr as TableView,Zr as TablesView,$r as ValueView,es as ValuesView,yt as useAddRowCallback,ut as useCell,it as useCellIds,Qt as useCellIdsListener,_t as useCellListener,nr as useCheckpoint,dr as useCheckpointIds,pr as useCheckpointIdsListener,gr as useCheckpointListener,or as useCheckpoints,tr as useCheckpointsIds,rr as useCheckpointsOrCheckpointsById,er as useCreateCheckpoints,lo as useCreateIndexes,Ne as useCreateMergeableStore,$t as useCreateMetrics,br as useCreatePersister,To as useCreateQueries,yo as useCreateRelationships,Qe as useCreateStore,vr as useCreateSynchronizer,xt as useDelCellCallback,qt as useDelRowCallback,Pt as useDelTableCallback,kt as useDelTablesCallback,Bt as useDelValueCallback,St as useDelValuesCallback,Zt as useDidFinishTransactionListener,lr as useGoBackwardCallback,ur as useGoForwardCallback,cr as useGoToCallback,lt as useHasCell,Wt as useHasCellListener,dt as useHasRow,Dt as useHasRowListener,Ze as useHasTable,tt as useHasTableCell,At as useHasTableCellListener,Et as useHasTableListener,Ue as useHasTables,Tt as useHasTablesListener,pt as useHasValue,Nt as useHasValueListener,ct as useHasValues,Gt as useHasValuesListener,go as useIndexIds,co as useIndexes,uo as useIndexesIds,ao as useIndexesOrIndexesById,qo as useLinkedRowIds,Bo as useLinkedRowIdsListener,Po as useLocalRowIds,So as useLocalRowIdsListener,no as useMetric,so as useMetricIds,io as useMetricListener,to as useMetrics,eo as useMetricsIds,oo as useMetricsOrMetricsById,Cr as usePersister,mr as usePersisterIds,yr as usePersisterOrPersisterById,hr as usePersisterStatus,fr as usePersisterStatusListener,sr as useProvideCheckpoints,Io as useProvideIndexes,ro as useProvideMetrics,wr as useProvidePersister,jo as useProvideQueries,vo as useProvideRelationships,Ke as useProvideStore,qr as useProvideSynchronizer,Vo as useQueries,Lo as useQueriesIds,Eo as useQueriesOrQueriesById,zo as useQueryIds,Ir as useRedoInformation,Ro as useRelationshipIds,ho as useRelationships,wo as useRelationshipsIds,fo as useRelationshipsOrRelationshipsById,ko as useRemoteRowId,xo as useRemoteRowIdListener,Wo as useResultCell,Qo as useResultCellIds,Xo as useResultCellIdsListener,Yo as useResultCellListener,Ho as useResultRow,Mo as useResultRowCount,Jo as useResultRowCountListener,Oo as useResultRowIds,Ko as useResultRowIdsListener,Uo as useResultRowListener,Do as useResultSortedRowIds,No as useResultSortedRowIdsListener,Ao as useResultTable,Fo as useResultTableCellIds,Go as useResultTableCellIdsListener,_o as useResultTableListener,nt as useRow,ot as useRowCount,Ft as useRowCountListener,rt as useRowIds,Mt as useRowIdsListener,Ht as useRowListener,ht as useSetCellCallback,ir as useSetCheckpointCallback,Zo as useSetParamValueCallback,$o as useSetParamValuesCallback,wt as useSetPartialRowCallback,vt as useSetPartialValuesCallback,Ct as useSetRowCallback,mt as useSetTableCallback,bt as useSetTablesCallback,Rt as useSetValueCallback,ft as useSetValuesCallback,po as useSliceIds,mo as useSliceIdsListener,bo as useSliceRowIds,Co as useSliceRowIdsListener,st as useSortedRowIds,Ot as useSortedRowIdsListener,He as useSortedRowIdsListenerImpl,Xt as useStartTransactionListener,_e as useStore,We as useStoreIds,Je as useStoreOrStoreById,Ge as useStores,kr as useSynchronizer,Rr as useSynchronizerIds,Pr as useSynchronizerOrSynchronizerById,xr as useSynchronizerStatus,Sr as useSynchronizerStatusListener,$e as useTable,et as useTableCellIds,zt as useTableCellIdsListener,Ye as useTableIds,Vt as useTableIdsListener,jt as useTableListener,Xe as useTables,Lt as useTablesListener,ar as useUndoInformation,gt as useValue,It as useValueIds,Kt as useValueIdsListener,Ut as useValueListener,at as useValues,Jt as useValuesListener,Yt as useWillFinishTransactionListener};
1
+ import e from"react";import{jsx as t}from"react/jsx-runtime";const o=e=>typeof e,r="",s=o(r),d=o(o),n="Result",a="Has",i="Ids",l="Table",u=l+"s",c=l+i,I="Row",p=I+"Count",g=I+i,b="Sorted"+I+i,m="Cell",C=m+i,y="Value",w=y+"s",h=y+i,v="Transaction",P="Partial",f="Finish",R="Status",k="Metric",q="Slice",x="RemoteRowId",S="Local",B="Linked",T="Checkpoint",V=e=>(t,o,r)=>e(t)?r?.():o(t),L=globalThis,E=e=>null==e,j=e=>void 0===e,z=V(E),A=V(j),F=e=>o(e)==s,M=e=>o(e)==d,O=e=>Array.isArray(e),D=e=>e.length,H=()=>{},Q=(e,t)=>e.every(t),W=(e,t)=>D(e)===D(t)&&Q(e,(e,o)=>t[o]===e),_=(e,t)=>O(e)&&O(t)?W(e,t):e===t,G=(e,t)=>e.map(t),J=(e,t,o)=>e.with(t,o),K=Object,N=e=>K.getPrototypeOf(e),U=K.entries,X=e=>!E(e)&&z(N(e),e=>e==K.prototype||E(N(e)),()=>!0),Y=K.keys,Z=(e,t)=>A(e,e=>e[t]),$=(e,t,o=(e,t)=>e===t)=>{const r=U(e);return D(r)===D(Y(t))&&Q(r,([e,r])=>X(r)?!!X(t[e])&&$(t[e],r):o(r,t[e]))},{PureComponent:ee,createContext:te,useCallback:oe,useContext:re,useEffect:se,useLayoutEffect:de,useMemo:ne,useRef:ae,useState:ie,useSyncExternalStore:le}=e,ue=(e,...t)=>j(e)?{}:e(...t),ce=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],Ie="tinybase_uirc",pe=L[Ie]?L[Ie]:L[Ie]=te([]),ge=(e,t)=>{const o=re(pe);return j(e)?o[2*t]:F(e)?Z(o[2*t+1],e):e},be=(e,t)=>{const o=ge(e,t);return j(e)||F(e)?o:e},me=(e,t,o)=>{const{16:r,17:s}=re(pe);se(()=>(r?.(o,e,t),()=>s?.(o,e)),[r,e,t,o,s])},Ce=e=>Y(re(pe)[2*e+1]??{}),ye=0,we=1,he=2,ve=3,Pe=4,fe=5,Re=6,ke=7,qe=(e,t,o,r,s)=>[o??t[2*e],{...t[2*e+1],...r,...s[e]}],xe=({store:e,storesById:o,metrics:r,metricsById:s,indexes:d,indexesById:n,relationships:a,relationshipsById:i,queries:l,queriesById:u,checkpoints:c,checkpointsById:I,persister:p,persistersById:g,synchronizer:b,synchronizersById:m,children:C})=>{const y=re(pe),[w,h]=ie(()=>G([,,,,,,,,].fill(0),(e,t)=>({}))),v=oe((e,t,o)=>h(r=>Z(r[e],t)==o?r:J(r,e,{...r[e],[t]:o})),[]),P=oe((e,t)=>h(o=>((e,t)=>t in e)(o[e],t)?J(o,e,((e,t)=>(delete e[t],e))(o[e],t)):o),[]);return t(pe.Provider,{value:ne(()=>[...qe(0,y,e,o,w),...qe(1,y,r,s,w),...qe(2,y,d,n,w),...qe(3,y,a,i,w),...qe(4,y,l,u,w),...qe(5,y,c,I,w),...qe(6,y,p,g,w),...qe(7,y,b,m,w),v,P],[w,e,o,r,s,d,n,a,i,l,u,c,I,p,g,b,m,y,v,P]),children:C})},Se=[],Be=[{},[],[Se,void 0,Se],{},void 0,void 0,!1,0],Te=[$,W,([e,t,o],[r,s,d])=>t===s&&W(e,r)&&W(o,d),(e,t)=>$(e,t,_),_],Ve=(e,t)=>e===t,Le=(e,t,o=Se)=>{const[,r]=ie(),[s,d]=ie();return se(()=>{const o=e?t(e):void 0;return d(o),r([]),o?.destroy},[e,...o]),s},Ee=(e,t,...o)=>{const r=e?.["add"+t+"Listener"]?.(...o);return()=>e?.delListener?.(r)},je=(e,t,o,s=Se)=>{const d=ae(Be[o]),n=oe(()=>{const r=t?.[(6==o?"has":"get")+e]?.(...s)??Be[o];return(Te[o]??Ve)(r,d.current)?d.current:d.current=r},[t,o,e,...s]),i=oe(d=>Ee(t,(6==o?a:r)+e,...s,d),[t,o,e,...s]);return le(i,n,n)},ze=(e,t,o,r=Se,s=Se,...d)=>de(()=>Ee(t,e,...s,o,...d),[t,e,...s,...r,...d]),Ae=(e,t,o,r=Se,s=H,d=Se,n,...a)=>oe(r=>A(e,e=>A(o(r,e),o=>s(e[n+t](...Oe(a,e,r),o),o))),[e,t,...r,...d,n,...De(a)]),Fe=(e,t,o,r,s,d,...n)=>Ae(Ne(e),t,o,r,s,d,"set",...n),Me=(e,t,o,s,d,n,...a)=>Ae(zo(e),t,o,s,d,n,r,...a),Oe=(e,t,o)=>G(e,e=>M(e)?e(o,t):e),De=e=>{return t=e=>!M(e),e.filter(t);var t},He=(e,t,o=H,r=Se,...s)=>{const d=Ne(e);return oe(e=>o(d?.["del"+t](...Oe(s,d,e))),[d,t,...r,...De(s)])},Qe=(e,t,o)=>{const r=lr(e);return oe(()=>r?.[t](o),[r,t,o])},We=(e,t,o,r,s,d,n,a,i)=>ze(b,Ne(i),d,n,[e,t,o,r,s],a),_e=(e,t=Se)=>ne(e,t),Ge=()=>Ce(0),Je=e=>ge(e,0),Ke=()=>({...re(pe)[1]}),Ne=e=>be(e,0),Ue=(e,t)=>me(e,t,0),Xe=(e,t=Se)=>ne(e,t),Ye=e=>je(u,Ne(e),6,[]),Ze=e=>je(u,Ne(e),0),$e=e=>je(c,Ne(e),1),et=(e,t)=>je(l,Ne(t),6,[e]),tt=(e,t)=>je(l,Ne(t),0,[e]),ot=(e,t)=>je(l+C,Ne(t),1,[e]),rt=(e,t,o)=>je(l+m,Ne(o),6,[e,t]),st=(e,t)=>je(p,Ne(t),7,[e]),dt=(e,t)=>je(g,Ne(t),1,[e]),nt=(e,t,o,r,s,d)=>((e,t,o,r,s,d)=>je(b,Ne(d),1,[e,t,o,r,s]))(...X(e)?[e.tableId,e.cellId,e.descending??!1,e.offset??0,e.limit,t]:[e,t,o,r,s,d]),at=(e,t,o)=>je(I,Ne(o),6,[e,t]),it=(e,t,o)=>je(I,Ne(o),0,[e,t]),lt=(e,t,o)=>je(C,Ne(o),1,[e,t]),ut=(e,t,o,r)=>je(m,Ne(r),6,[e,t,o]),ct=(e,t,o,r)=>je(m,Ne(r),5,[e,t,o]),It=e=>je(w,Ne(e),6,[]),pt=e=>je(w,Ne(e),0),gt=e=>je(h,Ne(e),1),bt=(e,t)=>je(y,Ne(t),6,[e]),mt=(e,t)=>je(y,Ne(t),5,[e]),Ct=(e,t,o,r,s)=>Fe(o,u,e,t,r,s),yt=(e,t,o,r,s,d)=>Fe(r,l,t,o,s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),_t=(e,t,o,r,s,d)=>ze(C,Ne(d),o,r,[e,t],s),Gt=(e,t,o,r,s,d,n)=>ze(a+m,Ne(n),r,s,[e,t,o],d),Jt=(e,t,o,r,s,d,n)=>ze(m,Ne(n),r,s,[e,t,o],d),Kt=(e,t,o,r)=>ze(a+w,Ne(r),e,t,[],o),Nt=(e,t,o,r)=>ze(w,Ne(r),e,t,Se,o),Ut=(e,t,o,r)=>ze(h,Ne(r),e,t,Se,o),Xt=(e,t,o,r,s)=>ze(a+y,Ne(s),t,o,[e],r),Yt=(e,t,o,r,s)=>ze(y,Ne(s),t,o,[e],r),Zt=(e,t,o)=>ze("Start"+v,Ne(o),e,t),$t=(e,t,o)=>ze("Will"+f+v,Ne(o),e,t),eo=(e,t,o)=>ze("Did"+f+v,Ne(o),e,t),to=(e,t,o)=>Le(e,t,o),oo=()=>Ce(1),ro=e=>ge(e,1),so=e=>be(e,1),no=(e,t)=>me(e,t,1),ao=e=>je(k+i,so(e),1),io=(e,t)=>je(k,so(t),5,[e]),lo=(e,t,o,r)=>ze(k,so(r),t,o,[e]),uo=(e,t,o)=>Le(e,t,o),co=()=>Ce(2),Io=e=>ge(e,2),po=e=>be(e,2),go=(e,t)=>me(e,t,2),bo=(e,t)=>je(q+i,po(t),1,[e]),mo=e=>je("Index"+i,po(e),1),Co=(e,t,o)=>je(q+g,po(o),1,[e,t]),yo=(e,t,o,r)=>ze(q+i,po(r),t,o,[e]),wo=(e,t,o,r,s)=>ze(q+g,po(s),o,r,[e,t]),ho=(e,t,o)=>Le(e,t,o),vo=()=>Ce(3),Po=e=>ge(e,3),fo=e=>be(e,3),Ro=(e,t)=>me(e,t,3),ko=e=>je("Relationship"+i,fo(e),1),qo=(e,t,o)=>je(x,fo(o),5,[e,t]),xo=(e,t,o)=>je(S+g,fo(o),1,[e,t]),So=(e,t,o)=>je(B+g,fo(o),1,[e,t]),Bo=(e,t,o,r,s)=>ze(x,fo(s),o,r,[e,t]),To=(e,t,o,r,s)=>ze(S+g,fo(s),o,r,[e,t]),Vo=(e,t,o,r,s)=>ze(B+g,fo(s),o,r,[e,t]),Lo=(e,t,o)=>Le(e,t,o),Eo=()=>Ce(4),jo=e=>ge(e,4),zo=e=>be(e,4),Ao=(e,t)=>me(e,t,4),Fo=e=>je("Query"+i,zo(e),1),Mo=(e,t)=>je(n+l,zo(t),0,[e]),Oo=(e,t)=>je(n+l+C,zo(t),1,[e]),Do=(e,t)=>je(n+p,zo(t),7,[e]),Ho=(e,t)=>je(n+g,zo(t),1,[e]),Qo=(e,t,o,r=0,s,d)=>je(n+b,zo(d),1,[e,t,o,r,s]),Wo=(e,t,o)=>je(n+I,zo(o),0,[e,t]),_o=(e,t,o)=>je(n+C,zo(o),1,[e,t]),Go=(e,t,o,r)=>je(n+m,zo(r),5,[e,t,o]),Jo=(e,t,o,r)=>ze(n+l,zo(r),t,o,[e]),Ko=(e,t,o,r)=>ze(n+l+C,zo(r),t,o,[e]),No=(e,t,o,r)=>ze(n+p,zo(r),t,o,[e]),Uo=(e,t,o,r)=>ze(n+g,zo(r),t,o,[e]),Xo=(e,t,o,r,s,d,a,i)=>ze(n+b,zo(i),d,a,[e,t,o,r,s]),Yo=(e,t,o,r,s)=>ze(n+I,zo(s),o,r,[e,t]),Zo=(e,t,o,r,s)=>ze(n+C,zo(s),o,r,[e,t]),$o=(e,t,o,r,s,d)=>ze(n+m,zo(d),r,s,[e,t,o]),er=(e,t)=>je("ParamValues",zo(t),3,[e]),tr=(e,t,o)=>je("ParamValue",zo(o),4,[e,t]),or=(e,t,o,r)=>ze("ParamValues",zo(r),t,o,[e]),rr=(e,t,o,r,s)=>ze("ParamValue",zo(s),o,r,[e,t]),sr=(e,t,o,r,s,d,n)=>Me(s,"setParamValue",o,r,d,n,e,t),dr=(e,t,o,r,s,d)=>Me(r,"setParamValues",t,o,s,d,e),nr=(e,t,o)=>Le(e,t,o),ar=()=>Ce(5),ir=e=>ge(e,5),lr=e=>be(e,5),ur=(e,t)=>me(e,t,5),cr=e=>je(T+i,lr(e),2),Ir=(e,t)=>je(T,lr(t),5,[e]),pr=(e=H,t=Se,o,r=H,s=Se)=>{const d=lr(o);return oe(t=>A(d,o=>{const s=e(t);r(o.addCheckpoint(s),o,s)}),[d,...t,...s])},gr=e=>Qe(e,"goBackward"),br=e=>Qe(e,"goForward"),mr=(e,t=Se,o,r=H,s=Se)=>{const d=lr(o);return oe(t=>A(d,o=>A(e(t),e=>r(o.goTo(e),e))),[d,...t,...s])},Cr=e=>{const t=lr(e),[o,s]=cr(t);return[(d=o,!(0==D(d))),gr(t),s,A(s,e=>t?.getCheckpoint(e))??r];var d},yr=e=>{const t=lr(e),[,,[o]]=cr(t);return[!j(o),br(t),o,A(o,e=>t?.getCheckpoint(e))??r]},wr=(e,t,o)=>ze(T+i,lr(o),e,t),hr=(e,t,o,r)=>ze(T,lr(r),t,o,[e]),vr=(e,t,o=Se,r,s=Se,d,n=Se)=>{const[,a]=ie(),[i,l]=ie();return se(()=>{(async()=>{const o=e?await t(e):void 0;l(o),o&&r&&(async()=>{await r(o),a([])})()})()},[e,...o,...s]),se(()=>()=>{i&&(i.destroy(),d?.(i))},[i,...n]),i},Pr=()=>Ce(6),fr=e=>ge(e,6),Rr=e=>be(e,6),kr=(e,t)=>me(e,t,6),qr=e=>je(R,Rr(e),7,[]),xr=(e,t,o)=>ze(R,Rr(o),e,t,[]),Sr=(e,t,o=Se,r,s=Se)=>{const[d,n]=ie();return se(()=>{(async()=>{const o=e?await t(e):void 0;n(o)})()},[e,...o]),se(()=>()=>{d&&(d.destroy(),r?.(d))},[d,...s]),d},Br=()=>Ce(7),Tr=e=>ge(e,7),Vr=e=>be(e,7),Lr=(e,t)=>me(e,t,7),Er=e=>je(R,Vr(e),7,[]),jr=(e,t,o)=>ze(R,Vr(o),e,t,[]),zr=(e,t,o,r)=>{const s=j(t)||!O(e)?e:G(e,(e,o)=>o>0?[t,e]:e);return o?[r,":{",s,"}"]:s},Ar=({checkpoints:e,checkpointId:t,debugIds:o})=>zr(Ir(t,e)??r,void 0,o,t),Fr=({queryId:e,rowId:t,cellId:o,queries:s,debugIds:d})=>zr(r+(Go(e,t,o,s)??r),void 0,d,o),Mr=({queryId:e,rowId:o,queries:r,resultCellComponent:s=Fr,getResultCellComponentProps:d,separator:n,debugIds:a})=>zr(G(_o(e,o,r),n=>t(s,{...ue(d,n),queryId:e,rowId:o,cellId:n,queries:r,debugIds:a},n)),n,a,o),Or=({tableId:e,rowId:t,cellId:o,store:s,debugIds:d})=>zr(r+(ct(e,t,o,s)??r),void 0,d,o),Dr=({tableId:e,rowId:o,store:r,cellComponent:s=Or,getCellComponentProps:d,customCellIds:n,separator:a,debugIds:i})=>zr(G(((e,t,o,r)=>{const s=lt(t,o,r);return e??s})(n,e,o,r),n=>t(s,{...ue(d,n),tableId:e,rowId:o,cellId:n,store:r,debugIds:i},n)),a,i,o),Hr=({tableId:e,store:o,rowComponent:r=Dr,getRowComponentProps:s,customCellIds:d,separator:n,debugIds:a},i)=>zr(G(i,n=>t(r,{...ue(s,n),tableId:e,rowId:n,customCellIds:d,store:o,debugIds:a},n)),n,a,e),Qr=({queryId:e,queries:o,resultRowComponent:r=Mr,getResultRowComponentProps:s,separator:d,debugIds:n},a)=>zr(G(a,d=>t(r,{...ue(s,d),queryId:e,rowId:d,queries:o,debugIds:n},d)),d,n,e),Wr=({relationshipId:e,relationships:o,rowComponent:r=Dr,getRowComponentProps:s,separator:d,debugIds:n},a,i)=>{const[l,u,c]=ce(fo(o),e),I=a(e,i,l);return zr(G(I,e=>t(r,{...ue(s,e),tableId:c,rowId:e,store:u,debugIds:n},e)),d,n,i)},_r=e=>({checkpoints:o,checkpointComponent:r=Ar,getCheckpointComponentProps:s,separator:d,debugIds:n})=>{const a=lr(o);return zr(G(e(cr(a)),e=>t(r,{...ue(s,e),checkpoints:a,checkpointId:e,debugIds:n},e)),d)},Gr=_r(e=>e[0]),Jr=_r(e=>j(e[1])?[]:[e[1]]),Kr=_r(e=>e[2]),Nr=({indexId:e,sliceId:o,indexes:r,rowComponent:s=Dr,getRowComponentProps:d,separator:n,debugIds:a})=>{const[i,l,u]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(po(r),e),c=Co(e,o,i);return zr(G(c,e=>t(s,{...ue(d,e),tableId:u,rowId:e,store:l,debugIds:a},e)),n,a,o)},Ur=({indexId:e,indexes:o,sliceComponent:r=Nr,getSliceComponentProps:s,separator:d,debugIds:n})=>zr(G(bo(e,o),d=>t(r,{...ue(s,d),indexId:e,sliceId:d,indexes:o,debugIds:n},d)),d,n,e),Xr=e=>Wr(e,So,e.firstRowId),Yr=e=>Wr(e,xo,e.remoteRowId),Zr=({metricId:e,metrics:t,debugIds:o})=>zr(io(e,t)??r,void 0,o,e),$r=({relationshipId:e,localRowId:o,relationships:r,rowComponent:s=Dr,getRowComponentProps:d,debugIds:n})=>{const[a,i,,l]=ce(fo(r),e),u=qo(e,o,a);return zr(j(l)||j(u)?null:t(s,{...ue(d,u),tableId:l,rowId:u,store:i,debugIds:n},u),void 0,n,o)},es=({cellId:e,descending:t,offset:o,limit:r,...s})=>Qr(s,Qo(s.queryId,e,t,o,r,s.queries)),ts=e=>Qr(e,Ho(e.queryId,e.queries)),os=({cellId:e,descending:t,offset:o,limit:r,...s})=>Hr(s,nt(s.tableId,e,t,o,r,s.store)),rs=e=>Hr(e,dt(e.tableId,e.store)),ss=({store:e,tableComponent:o=rs,getTableComponentProps:r,separator:s,debugIds:d})=>zr(G($e(e),s=>t(o,{...ue(r,s),tableId:s,store:e,debugIds:d},s)),s),ds=({valueId:e,store:t,debugIds:o})=>zr(r+(mt(e,t)??r),void 0,o,e),ns=({store:e,valueComponent:o=ds,getValueComponentProps:r,separator:s,debugIds:d})=>zr(G(gt(e),s=>t(o,{...ue(r,s),valueId:s,store:e,debugIds:d},s)),s);export{Gr as BackwardCheckpointsView,Or as CellView,Ar as CheckpointView,Jr as CurrentCheckpointView,Kr as ForwardCheckpointsView,Ur as IndexView,Xr as LinkedRowsView,Yr as LocalRowsView,Zr as MetricView,fe as OFFSET_CHECKPOINTS,he as OFFSET_INDEXES,we as OFFSET_METRICS,Re as OFFSET_PERSISTER,Pe as OFFSET_QUERIES,ve as OFFSET_RELATIONSHIPS,ye as OFFSET_STORE,ke as OFFSET_SYNCHRONIZER,xe as Provider,$r as RemoteRowView,Fr as ResultCellView,Mr as ResultRowView,es as ResultSortedTableView,ts as ResultTableView,Dr as RowView,Nr as SliceView,os as SortedTableView,rs as TableView,ss as TablesView,ds as ValueView,ns as ValuesView,ht as useAddRowCallback,ct as useCell,lt as useCellIds,_t as useCellIdsListener,Jt as useCellListener,Ir as useCheckpoint,cr as useCheckpointIds,wr as useCheckpointIdsListener,hr as useCheckpointListener,ir as useCheckpoints,ar as useCheckpointsIds,lr as useCheckpointsOrCheckpointsById,nr as useCreateCheckpoints,uo as useCreateIndexes,Xe as useCreateMergeableStore,to as useCreateMetrics,vr as useCreatePersister,Lo as useCreateQueries,ho as useCreateRelationships,_e as useCreateStore,Sr as useCreateSynchronizer,Bt as useDelCellCallback,St as useDelRowCallback,xt as useDelTableCallback,qt as useDelTablesCallback,Vt as useDelValueCallback,Tt as useDelValuesCallback,eo as useDidFinishTransactionListener,gr as useGoBackwardCallback,br as useGoForwardCallback,mr as useGoToCallback,ut as useHasCell,Gt as useHasCellListener,at as useHasRow,Qt as useHasRowListener,et as useHasTable,rt as useHasTableCell,Mt as useHasTableCellListener,zt as useHasTableListener,Ye as useHasTables,Lt as useHasTablesListener,bt as useHasValue,Xt as useHasValueListener,It as useHasValues,Kt as useHasValuesListener,mo as useIndexIds,Io as useIndexes,co as useIndexesIds,po as useIndexesOrIndexesById,So as useLinkedRowIds,Vo as useLinkedRowIdsListener,xo as useLocalRowIds,To as useLocalRowIdsListener,io as useMetric,ao as useMetricIds,lo as useMetricListener,ro as useMetrics,oo as useMetricsIds,so as useMetricsOrMetricsById,tr as useParamValue,rr as useParamValueListener,er as useParamValues,or as useParamValuesListener,fr as usePersister,Pr as usePersisterIds,Rr as usePersisterOrPersisterById,qr as usePersisterStatus,xr as usePersisterStatusListener,ur as useProvideCheckpoints,go as useProvideIndexes,no as useProvideMetrics,kr as useProvidePersister,Ao as useProvideQueries,Ro as useProvideRelationships,Ue as useProvideStore,Lr as useProvideSynchronizer,jo as useQueries,Eo as useQueriesIds,zo as useQueriesOrQueriesById,Fo as useQueryIds,yr as useRedoInformation,ko as useRelationshipIds,Po as useRelationships,vo as useRelationshipsIds,fo as useRelationshipsOrRelationshipsById,qo as useRemoteRowId,Bo as useRemoteRowIdListener,Go as useResultCell,_o as useResultCellIds,Zo as useResultCellIdsListener,$o as useResultCellListener,Wo as useResultRow,Do as useResultRowCount,No as useResultRowCountListener,Ho as useResultRowIds,Uo as useResultRowIdsListener,Yo as useResultRowListener,Qo as useResultSortedRowIds,Xo as useResultSortedRowIdsListener,Mo as useResultTable,Oo as useResultTableCellIds,Ko as useResultTableCellIdsListener,Jo as useResultTableListener,it as useRow,st as useRowCount,Ot as useRowCountListener,dt as useRowIds,Dt as useRowIdsListener,Wt as useRowListener,Pt as useSetCellCallback,pr as useSetCheckpointCallback,sr as useSetParamValueCallback,dr as useSetParamValuesCallback,vt as useSetPartialRowCallback,Rt as useSetPartialValuesCallback,wt as useSetRowCallback,yt as useSetTableCallback,Ct as useSetTablesCallback,kt as useSetValueCallback,ft as useSetValuesCallback,bo as useSliceIds,yo as useSliceIdsListener,Co as useSliceRowIds,wo as useSliceRowIdsListener,nt as useSortedRowIds,Ht as useSortedRowIdsListener,We as useSortedRowIdsListenerImpl,Zt as useStartTransactionListener,Je as useStore,Ge as useStoreIds,Ne as useStoreOrStoreById,Ke as useStores,Tr as useSynchronizer,Br as useSynchronizerIds,Vr as useSynchronizerOrSynchronizerById,Er as useSynchronizerStatus,jr as useSynchronizerStatusListener,tt as useTable,ot as useTableCellIds,Ft as useTableCellIdsListener,$e as useTableIds,jt as useTableIdsListener,At as useTableListener,Ze as useTables,Et as useTablesListener,Cr as useUndoInformation,mt as useValue,gt as useValueIds,Ut as useValueIdsListener,Yt as useValueListener,pt as useValues,Nt as useValuesListener,$t as useWillFinishTransactionListener};
Binary file
@@ -1 +1 @@
1
- import e from"react";import{jsx as t}from"react/jsx-runtime";const o=e=>typeof e,r="",s=o(r),d=o(o),n="Result",i="Has",l="Ids",u="Table",c=u+"s",a=u+l,I="Row",p=I+"Count",g=I+l,b="Sorted"+I+l,m="Cell",C=m+l,y="Value",w=y+"s",h=y+l,f="Transaction",v="Partial",R="Finish",k="Status",P="Metric",q="Slice",x="RemoteRowId",S="Local",B="Linked",T="Checkpoint",L=e=>(t,o,r)=>e(t)?r?.():o(t),V=globalThis,E=e=>null==e,j=e=>void 0===e,z=L(E),A=L(j),F=e=>o(e)==s,M=e=>o(e)==d,O=e=>e.length,D=()=>{},H=(e,t)=>e.every(t),Q=(e,t)=>O(e)===O(t)&&H(e,(e,o)=>t[o]===e),W=(e,t)=>e.map(t),_=(e,t,o)=>e.with(t,o),G=Object,J=e=>G.getPrototypeOf(e),K=G.entries,N=e=>!E(e)&&z(J(e),e=>e==G.prototype||E(J(e)),()=>!0),U=G.keys,X=(e,t)=>A(e,e=>e[t]),Y=(e,t)=>{const o=K(e);return O(o)===O(U(t))&&H(o,([e,o])=>N(o)?!!N(t[e])&&Y(t[e],o):t[e]===o)},{PureComponent:Z,createContext:$,useCallback:ee,useContext:te,useEffect:oe,useLayoutEffect:re,useMemo:se,useRef:de,useState:ne,useSyncExternalStore:ie}=e,le=(e,...t)=>j(e)?{}:e(...t),ue=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],ce="tinybase_uirc",ae=V[ce]?V[ce]:V[ce]=$([]),Ie=(e,t)=>{const o=te(ae);return j(e)?o[2*t]:F(e)?X(o[2*t+1],e):e},pe=(e,t)=>{const o=Ie(e,t);return j(e)||F(e)?o:e},ge=(e,t,o)=>{const{16:r,17:s}=te(ae);oe(()=>(r?.(o,e,t),()=>s?.(o,e)),[r,e,t,o,s])},be=e=>U(te(ae)[2*e+1]??{}),me=0,Ce=1,ye=2,we=3,he=4,fe=5,ve=6,Re=7,ke=(e,t,o,r,s)=>[o??t[2*e],{...t[2*e+1],...r,...s[e]}],Pe=({store:e,storesById:o,metrics:r,metricsById:s,indexes:d,indexesById:n,relationships:i,relationshipsById:l,queries:u,queriesById:c,checkpoints:a,checkpointsById:I,persister:p,persistersById:g,synchronizer:b,synchronizersById:m,children:C})=>{const y=te(ae),[w,h]=ne(()=>W([,,,,,,,,].fill(0),(e,t)=>({}))),f=ee((e,t,o)=>h(r=>X(r[e],t)==o?r:_(r,e,{...r[e],[t]:o})),[]),v=ee((e,t)=>h(o=>((e,t)=>t in e)(o[e],t)?_(o,e,((e,t)=>(delete e[t],e))(o[e],t)):o),[]);return t(ae.Provider,{value:se(()=>[...ke(0,y,e,o,w),...ke(1,y,r,s,w),...ke(2,y,d,n,w),...ke(3,y,i,l,w),...ke(4,y,u,c,w),...ke(5,y,a,I,w),...ke(6,y,p,g,w),...ke(7,y,b,m,w),f,v],[w,e,o,r,s,d,n,i,l,u,c,a,I,p,g,b,m,y,f,v]),children:C})},qe=[],xe=[{},[],[qe,void 0,qe],void 0,!1,0],Se=[Y,Q,([e,t,o],[r,s,d])=>t===s&&Q(e,r)&&Q(o,d)],Be=(e,t)=>e===t,Te=(e,t,o=qe)=>{const[,r]=ne(),[s,d]=ne();return oe(()=>{const o=e?t(e):void 0;return d(o),r([]),o?.destroy},[e,...o]),s},Le=(e,t,...o)=>{const r=e?.["add"+t+"Listener"]?.(...o);return()=>e?.delListener?.(r)},Ve=(e,t,o,s=qe)=>{const d=de(xe[o]),n=ee(()=>{const r=t?.[(4==o?"has":"get")+e]?.(...s)??xe[o];return(Se[o]??Be)(r,d.current)?d.current:d.current=r},[t,o,e,...s]),l=ee(d=>Le(t,(4==o?i:r)+e,...s,d),[t,o,e,...s]);return ie(l,n,n)},Ee=(e,t,o,r=qe,s=qe,...d)=>re(()=>Le(t,e,...s,o,...d),[t,e,...s,...r,...d]),je=(e,t,o,r=qe,s=D,d=qe,n="",...i)=>ee(r=>A(e,e=>A(o(r,e),o=>s(e[n+t](...Fe(i,e,r),o),o))),[e,t,...r,...d,n,...Me(i)]),ze=(e,t,o,r=qe,s=D,d=qe,...n)=>je(Je(e),t,o,r,s,d,"set",...n),Ae=(e,t,o,s=qe,d=D,n=qe,...i)=>je(Eo(e),t,o,s,d,n,r,...i),Fe=(e,t,o)=>W(e,e=>M(e)?e(o,t):e),Me=e=>{return t=e=>!M(e),e.filter(t);var t},Oe=(e,t,o=D,r=qe,...s)=>{const d=Je(e);return ee(e=>o(d?.["del"+t](...Fe(s,d,e))),[d,t,...r,...Me(s)])},De=(e,t,o)=>{const r=rr(e);return ee(()=>r?.[t](o),[r,t,o])},He=(e,t,o,r,s,d,n,i,l)=>Ee(b,Je(l),d,n,[e,t,o,r,s],i),Qe=(e,t=qe)=>se(e,t),We=()=>be(0),_e=e=>Ie(e,0),Ge=()=>({...te(ae)[1]}),Je=e=>pe(e,0),Ke=(e,t)=>ge(e,t,0),Ne=(e,t=qe)=>se(e,t),Ue=e=>Ve(c,Je(e),4,[]),Xe=e=>Ve(c,Je(e),0),Ye=e=>Ve(a,Je(e),1),Ze=(e,t)=>Ve(u,Je(t),4,[e]),$e=(e,t)=>Ve(u,Je(t),0,[e]),et=(e,t)=>Ve(u+C,Je(t),1,[e]),tt=(e,t,o)=>Ve(u+m,Je(o),4,[e,t]),ot=(e,t)=>Ve(p,Je(t),5,[e]),rt=(e,t)=>Ve(g,Je(t),1,[e]),st=(e,t,o,r,s,d)=>((e,t,o,r,s,d)=>Ve(b,Je(d),1,[e,t,o,r,s]))(...N(e)?[e.tableId,e.cellId,e.descending??!1,e.offset??0,e.limit,t]:[e,t,o,r,s,d]),dt=(e,t,o)=>Ve(I,Je(o),4,[e,t]),nt=(e,t,o)=>Ve(I,Je(o),0,[e,t]),it=(e,t,o)=>Ve(C,Je(o),1,[e,t]),lt=(e,t,o,r)=>Ve(m,Je(r),4,[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Zo=(e,t,o,r,s,d,n)=>Ae(s,"setParamValue",o,r,d,n,e,t),$o=(e,t,o,r,s,d)=>Ae(r,"setParamValues",t,o,s,d,e),er=(e,t,o)=>Te(e,t,o),tr=()=>be(5),or=e=>Ie(e,5),rr=e=>pe(e,5),sr=(e,t)=>ge(e,t,5),dr=e=>Ve(T+l,rr(e),2),nr=(e,t)=>Ve(T,rr(t),3,[e]),ir=(e=D,t=qe,o,r=D,s=qe)=>{const d=rr(o);return ee(t=>A(d,o=>{const s=e(t);r(o.addCheckpoint(s),o,s)}),[d,...t,...s])},lr=e=>De(e,"goBackward"),ur=e=>De(e,"goForward"),cr=(e,t=qe,o,r=D,s=qe)=>{const d=rr(o);return ee(t=>A(d,o=>A(e(t),e=>r(o.goTo(e),e))),[d,...t,...s])},ar=e=>{const t=rr(e),[o,s]=dr(t);return[(d=o,!(0==O(d))),lr(t),s,A(s,e=>t?.getCheckpoint(e))??r];var d},Ir=e=>{const t=rr(e),[,,[o]]=dr(t);return[!j(o),ur(t),o,A(o,e=>t?.getCheckpoint(e))??r]},pr=(e,t,o)=>Ee(T+l,rr(o),e,t),gr=(e,t,o,r)=>Ee(T,rr(r),t,o,[e]),br=(e,t,o=qe,r,s=qe,d,n=qe)=>{const[,i]=ne(),[l,u]=ne();return oe(()=>{(async()=>{const o=e?await t(e):void 0;u(o),o&&r&&(async()=>{await r(o),i([])})()})()},[e,...o,...s]),oe(()=>()=>{l&&(l.destroy(),d?.(l))},[l,...n]),l},mr=()=>be(6),Cr=e=>Ie(e,6),yr=e=>pe(e,6),wr=(e,t)=>ge(e,t,6),hr=e=>Ve(k,yr(e),5,[]),fr=(e,t,o)=>Ee(k,yr(o),e,t,[]),vr=(e,t,o=qe,r,s=qe)=>{const[d,n]=ne();return oe(()=>{(async()=>{const o=e?await t(e):void 0;n(o)})()},[e,...o]),oe(()=>()=>{d&&(d.destroy(),r?.(d))},[d,...s]),d},Rr=()=>be(7),kr=e=>Ie(e,7),Pr=e=>pe(e,7),qr=(e,t)=>ge(e,t,7),xr=e=>Ve(k,Pr(e),5,[]),Sr=(e,t,o)=>Ee(k,Pr(o),e,t,[]),Br=(e,t,o,r)=>{const s=j(t)||!Array.isArray(e)?e:W(e,(e,o)=>o>0?[t,e]:e);return o?[r,":{",s,"}"]:s},Tr=({checkpoints:e,checkpointId:t,debugIds:o})=>Br(nr(t,e)??r,void 0,o,t),Lr=({queryId:e,rowId:t,cellId:o,queries:s,debugIds:d})=>Br(r+(Wo(e,t,o,s)??r),void 0,d,o),Vr=({queryId:e,rowId:o,queries:r,resultCellComponent:s=Lr,getResultCellComponentProps:d,separator:n,debugIds:i})=>Br(W(Qo(e,o,r),n=>t(s,{...le(d,n),queryId:e,rowId:o,cellId:n,queries:r,debugIds:i},n)),n,i,o),Er=({tableId:e,rowId:t,cellId:o,store:s,debugIds:d})=>Br(r+(ut(e,t,o,s)??r),void 0,d,o),jr=({tableId:e,rowId:o,store:r,cellComponent:s=Er,getCellComponentProps:d,customCellIds:n,separator:i,debugIds:l})=>Br(W(((e,t,o,r)=>{const s=it(t,o,r);return e??s})(n,e,o,r),n=>t(s,{...le(d,n),tableId:e,rowId:o,cellId:n,store:r,debugIds:l},n)),i,l,o),zr=({tableId:e,store:o,rowComponent:r=jr,getRowComponentProps:s,customCellIds:d,separator:n,debugIds:i},l)=>Br(W(l,n=>t(r,{...le(s,n),tableId:e,rowId:n,customCellIds:d,store:o,debugIds:i},n)),n,i,e),Ar=({queryId:e,queries:o,resultRowComponent:r=Vr,getResultRowComponentProps:s,separator:d,debugIds:n},i)=>Br(W(i,d=>t(r,{...le(s,d),queryId:e,rowId:d,queries:o,debugIds:n},d)),d,n,e),Fr=({relationshipId:e,relationships:o,rowComponent:r=jr,getRowComponentProps:s,separator:d,debugIds:n},i,l)=>{const[u,c,a]=ue(fo(o),e),I=i(e,l,u);return Br(W(I,e=>t(r,{...le(s,e),tableId:a,rowId:e,store:c,debugIds:n},e)),d,n,l)},Mr=e=>({checkpoints:o,checkpointComponent:r=Tr,getCheckpointComponentProps:s,separator:d,debugIds:n})=>{const i=rr(o);return Br(W(e(dr(i)),e=>t(r,{...le(s,e),checkpoints:i,checkpointId:e,debugIds:n},e)),d)},Or=Mr(e=>e[0]),Dr=Mr(e=>j(e[1])?[]:[e[1]]),Hr=Mr(e=>e[2]),Qr=({indexId:e,sliceId:o,indexes:r,rowComponent:s=jr,getRowComponentProps:d,separator:n,debugIds:i})=>{const[l,u,c]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(ao(r),e),a=bo(e,o,l);return Br(W(a,e=>t(s,{...le(d,e),tableId:c,rowId:e,store:u,debugIds:i},e)),n,i,o)},Wr=({indexId:e,indexes:o,sliceComponent:r=Qr,getSliceComponentProps:s,separator:d,debugIds:n})=>Br(W(po(e,o),d=>t(r,{...le(s,d),indexId:e,sliceId:d,indexes:o,debugIds:n},d)),d,n,e),_r=e=>Fr(e,qo,e.firstRowId),Gr=e=>Fr(e,Po,e.remoteRowId),Jr=({metricId:e,metrics:t,debugIds:o})=>Br(no(e,t)??r,void 0,o,e),Kr=({relationshipId:e,localRowId:o,relationships:r,rowComponent:s=jr,getRowComponentProps:d,debugIds:n})=>{const[i,l,,u]=ue(fo(r),e),c=ko(e,o,i);return Br(j(u)||j(c)?null:t(s,{...le(d,c),tableId:u,rowId:c,store:l,debugIds:n},c),void 0,n,o)},Nr=({cellId:e,descending:t,offset:o,limit:r,...s})=>Ar(s,Do(s.queryId,e,t,o,r,s.queries)),Ur=e=>Ar(e,Oo(e.queryId,e.queries)),Xr=({cellId:e,descending:t,offset:o,limit:r,...s})=>zr(s,st(s.tableId,e,t,o,r,s.store)),Yr=e=>zr(e,rt(e.tableId,e.store)),Zr=({store:e,tableComponent:o=Yr,getTableComponentProps:r,separator:s,debugIds:d})=>Br(W(Ye(e),s=>t(o,{...le(r,s),tableId:s,store:e,debugIds:d},s)),s),$r=({valueId:e,store:t,debugIds:o})=>Br(r+(gt(e,t)??r),void 0,o,e),es=({store:e,valueComponent:o=$r,getValueComponentProps:r,separator:s,debugIds:d})=>Br(W(It(e),s=>t(o,{...le(r,s),valueId:s,store:e,debugIds:d},s)),s);export{Or as BackwardCheckpointsView,Er as CellView,Tr as CheckpointView,Dr as CurrentCheckpointView,Hr as ForwardCheckpointsView,Wr as IndexView,_r as LinkedRowsView,Gr as LocalRowsView,Jr as MetricView,fe as OFFSET_CHECKPOINTS,ye as OFFSET_INDEXES,Ce as OFFSET_METRICS,ve as OFFSET_PERSISTER,he as OFFSET_QUERIES,we as OFFSET_RELATIONSHIPS,me as OFFSET_STORE,Re as OFFSET_SYNCHRONIZER,Pe as Provider,Kr as RemoteRowView,Lr as ResultCellView,Vr as ResultRowView,Nr as ResultSortedTableView,Ur as ResultTableView,jr as RowView,Qr as SliceView,Xr as SortedTableView,Yr as TableView,Zr as TablesView,$r as ValueView,es as ValuesView,yt as useAddRowCallback,ut as useCell,it as useCellIds,Qt as useCellIdsListener,_t as useCellListener,nr as useCheckpoint,dr as useCheckpointIds,pr as useCheckpointIdsListener,gr as useCheckpointListener,or as useCheckpoints,tr as useCheckpointsIds,rr as useCheckpointsOrCheckpointsById,er as useCreateCheckpoints,lo as useCreateIndexes,Ne as useCreateMergeableStore,$t as useCreateMetrics,br as useCreatePersister,To as useCreateQueries,yo as useCreateRelationships,Qe as useCreateStore,vr as useCreateSynchronizer,xt as useDelCellCallback,qt as useDelRowCallback,Pt as useDelTableCallback,kt as useDelTablesCallback,Bt as useDelValueCallback,St as useDelValuesCallback,Zt as useDidFinishTransactionListener,lr as useGoBackwardCallback,ur as useGoForwardCallback,cr as useGoToCallback,lt as useHasCell,Wt as useHasCellListener,dt as useHasRow,Dt as useHasRowListener,Ze as useHasTable,tt as useHasTableCell,At as useHasTableCellListener,Et as useHasTableListener,Ue as useHasTables,Tt as useHasTablesListener,pt as useHasValue,Nt as useHasValueListener,ct as useHasValues,Gt as useHasValuesListener,go as useIndexIds,co as useIndexes,uo as useIndexesIds,ao as useIndexesOrIndexesById,qo as useLinkedRowIds,Bo as useLinkedRowIdsListener,Po as useLocalRowIds,So as useLocalRowIdsListener,no as useMetric,so as useMetricIds,io as useMetricListener,to as useMetrics,eo as useMetricsIds,oo as useMetricsOrMetricsById,Cr as usePersister,mr as usePersisterIds,yr as usePersisterOrPersisterById,hr as usePersisterStatus,fr as usePersisterStatusListener,sr as useProvideCheckpoints,Io as useProvideIndexes,ro as useProvideMetrics,wr as useProvidePersister,jo as useProvideQueries,vo as useProvideRelationships,Ke as useProvideStore,qr as useProvideSynchronizer,Vo as useQueries,Lo as useQueriesIds,Eo as useQueriesOrQueriesById,zo as useQueryIds,Ir as useRedoInformation,Ro as useRelationshipIds,ho as useRelationships,wo as useRelationshipsIds,fo as useRelationshipsOrRelationshipsById,ko as useRemoteRowId,xo as useRemoteRowIdListener,Wo as useResultCell,Qo as useResultCellIds,Xo as useResultCellIdsListener,Yo as useResultCellListener,Ho as useResultRow,Mo as useResultRowCount,Jo as useResultRowCountListener,Oo as useResultRowIds,Ko as useResultRowIdsListener,Uo as useResultRowListener,Do as useResultSortedRowIds,No as useResultSortedRowIdsListener,Ao as useResultTable,Fo as useResultTableCellIds,Go as useResultTableCellIdsListener,_o as useResultTableListener,nt as useRow,ot as useRowCount,Ft as useRowCountListener,rt as useRowIds,Mt as useRowIdsListener,Ht as useRowListener,ht as useSetCellCallback,ir as useSetCheckpointCallback,Zo as useSetParamValueCallback,$o as useSetParamValuesCallback,wt as useSetPartialRowCallback,vt as useSetPartialValuesCallback,Ct as useSetRowCallback,mt as useSetTableCallback,bt as useSetTablesCallback,Rt as useSetValueCallback,ft as useSetValuesCallback,po as useSliceIds,mo as useSliceIdsListener,bo as useSliceRowIds,Co as useSliceRowIdsListener,st as useSortedRowIds,Ot as useSortedRowIdsListener,He as useSortedRowIdsListenerImpl,Xt as useStartTransactionListener,_e as useStore,We as useStoreIds,Je as useStoreOrStoreById,Ge as useStores,kr as useSynchronizer,Rr as useSynchronizerIds,Pr as useSynchronizerOrSynchronizerById,xr as useSynchronizerStatus,Sr as useSynchronizerStatusListener,$e as useTable,et as useTableCellIds,zt as useTableCellIdsListener,Ye as useTableIds,Vt as useTableIdsListener,jt as useTableListener,Xe as useTables,Lt as useTablesListener,ar as useUndoInformation,gt as useValue,It as useValueIds,Kt as useValueIdsListener,Ut as useValueListener,at as useValues,Jt as useValuesListener,Yt as useWillFinishTransactionListener};
1
+ import e from"react";import{jsx as t}from"react/jsx-runtime";const o=e=>typeof e,r="",s=o(r),d=o(o),n="Result",a="Has",i="Ids",l="Table",u=l+"s",c=l+i,I="Row",p=I+"Count",g=I+i,b="Sorted"+I+i,m="Cell",C=m+i,y="Value",w=y+"s",h=y+i,v="Transaction",P="Partial",f="Finish",R="Status",k="Metric",q="Slice",x="RemoteRowId",S="Local",B="Linked",T="Checkpoint",V=e=>(t,o,r)=>e(t)?r?.():o(t),L=globalThis,E=e=>null==e,j=e=>void 0===e,z=V(E),A=V(j),F=e=>o(e)==s,M=e=>o(e)==d,O=e=>Array.isArray(e),D=e=>e.length,H=()=>{},Q=(e,t)=>e.every(t),W=(e,t)=>D(e)===D(t)&&Q(e,(e,o)=>t[o]===e),_=(e,t)=>O(e)&&O(t)?W(e,t):e===t,G=(e,t)=>e.map(t),J=(e,t,o)=>e.with(t,o),K=Object,N=e=>K.getPrototypeOf(e),U=K.entries,X=e=>!E(e)&&z(N(e),e=>e==K.prototype||E(N(e)),()=>!0),Y=K.keys,Z=(e,t)=>A(e,e=>e[t]),$=(e,t,o=(e,t)=>e===t)=>{const r=U(e);return D(r)===D(Y(t))&&Q(r,([e,r])=>X(r)?!!X(t[e])&&$(t[e],r):o(r,t[e]))},{PureComponent:ee,createContext:te,useCallback:oe,useContext:re,useEffect:se,useLayoutEffect:de,useMemo:ne,useRef:ae,useState:ie,useSyncExternalStore:le}=e,ue=(e,...t)=>j(e)?{}:e(...t),ce=(e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)],Ie="tinybase_uirc",pe=L[Ie]?L[Ie]:L[Ie]=te([]),ge=(e,t)=>{const o=re(pe);return j(e)?o[2*t]:F(e)?Z(o[2*t+1],e):e},be=(e,t)=>{const o=ge(e,t);return j(e)||F(e)?o:e},me=(e,t,o)=>{const{16:r,17:s}=re(pe);se(()=>(r?.(o,e,t),()=>s?.(o,e)),[r,e,t,o,s])},Ce=e=>Y(re(pe)[2*e+1]??{}),ye=0,we=1,he=2,ve=3,Pe=4,fe=5,Re=6,ke=7,qe=(e,t,o,r,s)=>[o??t[2*e],{...t[2*e+1],...r,...s[e]}],xe=({store:e,storesById:o,metrics:r,metricsById:s,indexes:d,indexesById:n,relationships:a,relationshipsById:i,queries:l,queriesById:u,checkpoints:c,checkpointsById:I,persister:p,persistersById:g,synchronizer:b,synchronizersById:m,children:C})=>{const y=re(pe),[w,h]=ie(()=>G([,,,,,,,,].fill(0),(e,t)=>({}))),v=oe((e,t,o)=>h(r=>Z(r[e],t)==o?r:J(r,e,{...r[e],[t]:o})),[]),P=oe((e,t)=>h(o=>((e,t)=>t in e)(o[e],t)?J(o,e,((e,t)=>(delete e[t],e))(o[e],t)):o),[]);return t(pe.Provider,{value:ne(()=>[...qe(0,y,e,o,w),...qe(1,y,r,s,w),...qe(2,y,d,n,w),...qe(3,y,a,i,w),...qe(4,y,l,u,w),...qe(5,y,c,I,w),...qe(6,y,p,g,w),...qe(7,y,b,m,w),v,P],[w,e,o,r,s,d,n,a,i,l,u,c,I,p,g,b,m,y,v,P]),children:C})},Se=[],Be=[{},[],[Se,void 0,Se],{},void 0,void 0,!1,0],Te=[$,W,([e,t,o],[r,s,d])=>t===s&&W(e,r)&&W(o,d),(e,t)=>$(e,t,_),_],Ve=(e,t)=>e===t,Le=(e,t,o=Se)=>{const[,r]=ie(),[s,d]=ie();return se(()=>{const o=e?t(e):void 0;return d(o),r([]),o?.destroy},[e,...o]),s},Ee=(e,t,...o)=>{const r=e?.["add"+t+"Listener"]?.(...o);return()=>e?.delListener?.(r)},je=(e,t,o,s=Se)=>{const d=ae(Be[o]),n=oe(()=>{const r=t?.[(6==o?"has":"get")+e]?.(...s)??Be[o];return(Te[o]??Ve)(r,d.current)?d.current:d.current=r},[t,o,e,...s]),i=oe(d=>Ee(t,(6==o?a:r)+e,...s,d),[t,o,e,...s]);return le(i,n,n)},ze=(e,t,o,r=Se,s=Se,...d)=>de(()=>Ee(t,e,...s,o,...d),[t,e,...s,...r,...d]),Ae=(e,t,o,r=Se,s=H,d=Se,n,...a)=>oe(r=>A(e,e=>A(o(r,e),o=>s(e[n+t](...Oe(a,e,r),o),o))),[e,t,...r,...d,n,...De(a)]),Fe=(e,t,o,r,s,d,...n)=>Ae(Ne(e),t,o,r,s,d,"set",...n),Me=(e,t,o,s,d,n,...a)=>Ae(zo(e),t,o,s,d,n,r,...a),Oe=(e,t,o)=>G(e,e=>M(e)?e(o,t):e),De=e=>{return t=e=>!M(e),e.filter(t);var t},He=(e,t,o=H,r=Se,...s)=>{const d=Ne(e);return oe(e=>o(d?.["del"+t](...Oe(s,d,e))),[d,t,...r,...De(s)])},Qe=(e,t,o)=>{const r=lr(e);return oe(()=>r?.[t](o),[r,t,o])},We=(e,t,o,r,s,d,n,a,i)=>ze(b,Ne(i),d,n,[e,t,o,r,s],a),_e=(e,t=Se)=>ne(e,t),Ge=()=>Ce(0),Je=e=>ge(e,0),Ke=()=>({...re(pe)[1]}),Ne=e=>be(e,0),Ue=(e,t)=>me(e,t,0),Xe=(e,t=Se)=>ne(e,t),Ye=e=>je(u,Ne(e),6,[]),Ze=e=>je(u,Ne(e),0),$e=e=>je(c,Ne(e),1),et=(e,t)=>je(l,Ne(t),6,[e]),tt=(e,t)=>je(l,Ne(t),0,[e]),ot=(e,t)=>je(l+C,Ne(t),1,[e]),rt=(e,t,o)=>je(l+m,Ne(o),6,[e,t]),st=(e,t)=>je(p,Ne(t),7,[e]),dt=(e,t)=>je(g,Ne(t),1,[e]),nt=(e,t,o,r,s,d)=>((e,t,o,r,s,d)=>je(b,Ne(d),1,[e,t,o,r,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r,[e,t]),Zo=(e,t,o,r,s)=>ze(n+C,zo(s),o,r,[e,t]),$o=(e,t,o,r,s,d)=>ze(n+m,zo(d),r,s,[e,t,o]),er=(e,t)=>je("ParamValues",zo(t),3,[e]),tr=(e,t,o)=>je("ParamValue",zo(o),4,[e,t]),or=(e,t,o,r)=>ze("ParamValues",zo(r),t,o,[e]),rr=(e,t,o,r,s)=>ze("ParamValue",zo(s),o,r,[e,t]),sr=(e,t,o,r,s,d,n)=>Me(s,"setParamValue",o,r,d,n,e,t),dr=(e,t,o,r,s,d)=>Me(r,"setParamValues",t,o,s,d,e),nr=(e,t,o)=>Le(e,t,o),ar=()=>Ce(5),ir=e=>ge(e,5),lr=e=>be(e,5),ur=(e,t)=>me(e,t,5),cr=e=>je(T+i,lr(e),2),Ir=(e,t)=>je(T,lr(t),5,[e]),pr=(e=H,t=Se,o,r=H,s=Se)=>{const d=lr(o);return oe(t=>A(d,o=>{const s=e(t);r(o.addCheckpoint(s),o,s)}),[d,...t,...s])},gr=e=>Qe(e,"goBackward"),br=e=>Qe(e,"goForward"),mr=(e,t=Se,o,r=H,s=Se)=>{const d=lr(o);return oe(t=>A(d,o=>A(e(t),e=>r(o.goTo(e),e))),[d,...t,...s])},Cr=e=>{const t=lr(e),[o,s]=cr(t);return[(d=o,!(0==D(d))),gr(t),s,A(s,e=>t?.getCheckpoint(e))??r];var d},yr=e=>{const t=lr(e),[,,[o]]=cr(t);return[!j(o),br(t),o,A(o,e=>t?.getCheckpoint(e))??r]},wr=(e,t,o)=>ze(T+i,lr(o),e,t),hr=(e,t,o,r)=>ze(T,lr(r),t,o,[e]),vr=(e,t,o=Se,r,s=Se,d,n=Se)=>{const[,a]=ie(),[i,l]=ie();return se(()=>{(async()=>{const o=e?await t(e):void 0;l(o),o&&r&&(async()=>{await r(o),a([])})()})()},[e,...o,...s]),se(()=>()=>{i&&(i.destroy(),d?.(i))},[i,...n]),i},Pr=()=>Ce(6),fr=e=>ge(e,6),Rr=e=>be(e,6),kr=(e,t)=>me(e,t,6),qr=e=>je(R,Rr(e),7,[]),xr=(e,t,o)=>ze(R,Rr(o),e,t,[]),Sr=(e,t,o=Se,r,s=Se)=>{const[d,n]=ie();return se(()=>{(async()=>{const o=e?await t(e):void 0;n(o)})()},[e,...o]),se(()=>()=>{d&&(d.destroy(),r?.(d))},[d,...s]),d},Br=()=>Ce(7),Tr=e=>ge(e,7),Vr=e=>be(e,7),Lr=(e,t)=>me(e,t,7),Er=e=>je(R,Vr(e),7,[]),jr=(e,t,o)=>ze(R,Vr(o),e,t,[]),zr=(e,t,o,r)=>{const s=j(t)||!O(e)?e:G(e,(e,o)=>o>0?[t,e]:e);return o?[r,":{",s,"}"]:s},Ar=({checkpoints:e,checkpointId:t,debugIds:o})=>zr(Ir(t,e)??r,void 0,o,t),Fr=({queryId:e,rowId:t,cellId:o,queries:s,debugIds:d})=>zr(r+(Go(e,t,o,s)??r),void 0,d,o),Mr=({queryId:e,rowId:o,queries:r,resultCellComponent:s=Fr,getResultCellComponentProps:d,separator:n,debugIds:a})=>zr(G(_o(e,o,r),n=>t(s,{...ue(d,n),queryId:e,rowId:o,cellId:n,queries:r,debugIds:a},n)),n,a,o),Or=({tableId:e,rowId:t,cellId:o,store:s,debugIds:d})=>zr(r+(ct(e,t,o,s)??r),void 0,d,o),Dr=({tableId:e,rowId:o,store:r,cellComponent:s=Or,getCellComponentProps:d,customCellIds:n,separator:a,debugIds:i})=>zr(G(((e,t,o,r)=>{const s=lt(t,o,r);return e??s})(n,e,o,r),n=>t(s,{...ue(d,n),tableId:e,rowId:o,cellId:n,store:r,debugIds:i},n)),a,i,o),Hr=({tableId:e,store:o,rowComponent:r=Dr,getRowComponentProps:s,customCellIds:d,separator:n,debugIds:a},i)=>zr(G(i,n=>t(r,{...ue(s,n),tableId:e,rowId:n,customCellIds:d,store:o,debugIds:a},n)),n,a,e),Qr=({queryId:e,queries:o,resultRowComponent:r=Mr,getResultRowComponentProps:s,separator:d,debugIds:n},a)=>zr(G(a,d=>t(r,{...ue(s,d),queryId:e,rowId:d,queries:o,debugIds:n},d)),d,n,e),Wr=({relationshipId:e,relationships:o,rowComponent:r=Dr,getRowComponentProps:s,separator:d,debugIds:n},a,i)=>{const[l,u,c]=ce(fo(o),e),I=a(e,i,l);return zr(G(I,e=>t(r,{...ue(s,e),tableId:c,rowId:e,store:u,debugIds:n},e)),d,n,i)},_r=e=>({checkpoints:o,checkpointComponent:r=Ar,getCheckpointComponentProps:s,separator:d,debugIds:n})=>{const a=lr(o);return zr(G(e(cr(a)),e=>t(r,{...ue(s,e),checkpoints:a,checkpointId:e,debugIds:n},e)),d)},Gr=_r(e=>e[0]),Jr=_r(e=>j(e[1])?[]:[e[1]]),Kr=_r(e=>e[2]),Nr=({indexId:e,sliceId:o,indexes:r,rowComponent:s=Dr,getRowComponentProps:d,separator:n,debugIds:a})=>{const[i,l,u]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(po(r),e),c=Co(e,o,i);return zr(G(c,e=>t(s,{...ue(d,e),tableId:u,rowId:e,store:l,debugIds:a},e)),n,a,o)},Ur=({indexId:e,indexes:o,sliceComponent:r=Nr,getSliceComponentProps:s,separator:d,debugIds:n})=>zr(G(bo(e,o),d=>t(r,{...ue(s,d),indexId:e,sliceId:d,indexes:o,debugIds:n},d)),d,n,e),Xr=e=>Wr(e,So,e.firstRowId),Yr=e=>Wr(e,xo,e.remoteRowId),Zr=({metricId:e,metrics:t,debugIds:o})=>zr(io(e,t)??r,void 0,o,e),$r=({relationshipId:e,localRowId:o,relationships:r,rowComponent:s=Dr,getRowComponentProps:d,debugIds:n})=>{const[a,i,,l]=ce(fo(r),e),u=qo(e,o,a);return zr(j(l)||j(u)?null:t(s,{...ue(d,u),tableId:l,rowId:u,store:i,debugIds:n},u),void 0,n,o)},es=({cellId:e,descending:t,offset:o,limit:r,...s})=>Qr(s,Qo(s.queryId,e,t,o,r,s.queries)),ts=e=>Qr(e,Ho(e.queryId,e.queries)),os=({cellId:e,descending:t,offset:o,limit:r,...s})=>Hr(s,nt(s.tableId,e,t,o,r,s.store)),rs=e=>Hr(e,dt(e.tableId,e.store)),ss=({store:e,tableComponent:o=rs,getTableComponentProps:r,separator:s,debugIds:d})=>zr(G($e(e),s=>t(o,{...ue(r,s),tableId:s,store:e,debugIds:d},s)),s),ds=({valueId:e,store:t,debugIds:o})=>zr(r+(mt(e,t)??r),void 0,o,e),ns=({store:e,valueComponent:o=ds,getValueComponentProps:r,separator:s,debugIds:d})=>zr(G(gt(e),s=>t(o,{...ue(r,s),valueId:s,store:e,debugIds:d},s)),s);export{Gr as BackwardCheckpointsView,Or as CellView,Ar as CheckpointView,Jr as CurrentCheckpointView,Kr as ForwardCheckpointsView,Ur as IndexView,Xr as LinkedRowsView,Yr as LocalRowsView,Zr as MetricView,fe as OFFSET_CHECKPOINTS,he as OFFSET_INDEXES,we as OFFSET_METRICS,Re as OFFSET_PERSISTER,Pe as OFFSET_QUERIES,ve as OFFSET_RELATIONSHIPS,ye as OFFSET_STORE,ke as OFFSET_SYNCHRONIZER,xe as Provider,$r as RemoteRowView,Fr as ResultCellView,Mr as ResultRowView,es as ResultSortedTableView,ts as ResultTableView,Dr as RowView,Nr as SliceView,os as SortedTableView,rs as TableView,ss as TablesView,ds as ValueView,ns as ValuesView,ht as useAddRowCallback,ct as useCell,lt as useCellIds,_t as useCellIdsListener,Jt as useCellListener,Ir as useCheckpoint,cr as useCheckpointIds,wr as useCheckpointIdsListener,hr as useCheckpointListener,ir as useCheckpoints,ar as useCheckpointsIds,lr as useCheckpointsOrCheckpointsById,nr as useCreateCheckpoints,uo as useCreateIndexes,Xe as useCreateMergeableStore,to as useCreateMetrics,vr as useCreatePersister,Lo as useCreateQueries,ho as useCreateRelationships,_e as useCreateStore,Sr as useCreateSynchronizer,Bt as useDelCellCallback,St as useDelRowCallback,xt as useDelTableCallback,qt as useDelTablesCallback,Vt as useDelValueCallback,Tt as useDelValuesCallback,eo as useDidFinishTransactionListener,gr as useGoBackwardCallback,br as useGoForwardCallback,mr as useGoToCallback,ut as useHasCell,Gt as useHasCellListener,at as useHasRow,Qt as useHasRowListener,et as useHasTable,rt as useHasTableCell,Mt as useHasTableCellListener,zt as useHasTableListener,Ye as useHasTables,Lt as useHasTablesListener,bt as useHasValue,Xt as useHasValueListener,It as useHasValues,Kt as useHasValuesListener,mo as useIndexIds,Io as useIndexes,co as useIndexesIds,po as useIndexesOrIndexesById,So as useLinkedRowIds,Vo as useLinkedRowIdsListener,xo as useLocalRowIds,To as useLocalRowIdsListener,io as useMetric,ao as useMetricIds,lo as useMetricListener,ro as useMetrics,oo as useMetricsIds,so as useMetricsOrMetricsById,tr as useParamValue,rr as useParamValueListener,er as useParamValues,or as useParamValuesListener,fr as usePersister,Pr as usePersisterIds,Rr as usePersisterOrPersisterById,qr as usePersisterStatus,xr as usePersisterStatusListener,ur as useProvideCheckpoints,go as useProvideIndexes,no as useProvideMetrics,kr as useProvidePersister,Ao as useProvideQueries,Ro as useProvideRelationships,Ue as useProvideStore,Lr as useProvideSynchronizer,jo as useQueries,Eo as useQueriesIds,zo as useQueriesOrQueriesById,Fo as useQueryIds,yr as useRedoInformation,ko as useRelationshipIds,Po as useRelationships,vo as useRelationshipsIds,fo as useRelationshipsOrRelationshipsById,qo as useRemoteRowId,Bo as useRemoteRowIdListener,Go as useResultCell,_o as useResultCellIds,Zo as useResultCellIdsListener,$o as useResultCellListener,Wo as useResultRow,Do as useResultRowCount,No as useResultRowCountListener,Ho as useResultRowIds,Uo as useResultRowIdsListener,Yo as useResultRowListener,Qo as useResultSortedRowIds,Xo as useResultSortedRowIdsListener,Mo as useResultTable,Oo as useResultTableCellIds,Ko as useResultTableCellIdsListener,Jo as useResultTableListener,it as useRow,st as useRowCount,Ot as useRowCountListener,dt as useRowIds,Dt as useRowIdsListener,Wt as useRowListener,Pt as useSetCellCallback,pr as useSetCheckpointCallback,sr as useSetParamValueCallback,dr as useSetParamValuesCallback,vt as useSetPartialRowCallback,Rt as useSetPartialValuesCallback,wt as useSetRowCallback,yt as useSetTableCallback,Ct as useSetTablesCallback,kt as useSetValueCallback,ft as useSetValuesCallback,bo as useSliceIds,yo as useSliceIdsListener,Co as useSliceRowIds,wo as useSliceRowIdsListener,nt as useSortedRowIds,Ht as useSortedRowIdsListener,We as useSortedRowIdsListenerImpl,Zt as useStartTransactionListener,Je as useStore,Ge as useStoreIds,Ne as useStoreOrStoreById,Ke as useStores,Tr as useSynchronizer,Br as useSynchronizerIds,Vr as useSynchronizerOrSynchronizerById,Er as useSynchronizerStatus,jr as useSynchronizerStatusListener,tt as useTable,ot as useTableCellIds,Ft as useTableCellIdsListener,$e as useTableIds,jt as useTableIdsListener,At as useTableListener,Ze as useTables,Et as useTablesListener,Cr as useUndoInformation,mt as useValue,gt as useValueIds,Ut as useValueIdsListener,Yt as useValueListener,pt as useValues,Nt as useValuesListener,$t as useWillFinishTransactionListener};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as l,Fragment as t}from"react/jsx-runtime";import r from"react";import{CellView as n,ResultCellView as a,ValueView as s}from"../ui-react/index.js";const o=e=>typeof e,c=o(""),i=o(!0),d=o(0),h=o(o),u="Result",m="Ids",C="Table",p="Row",b=p+"Count",f=p+m,I="Sorted"+p+m,g="Cell",x=g+m,y="Value",N=y+m,v="currentTarget",w="value",T="extra",k=e=>(l,t,r)=>e(l)?r?.():t(l),S=globalThis,R=Math.min,A=isFinite,B=e=>null==e,q=e=>void 0===e,P=e=>!1===e,E=k(B),L=k(q),O=e=>o(e)==c,V=e=>o(e)==h,j=e=>e.length,M=()=>{},F=(e,l)=>e.every(l),H=(e,l)=>j(e)===j(l)&&F(e,(e,t)=>l[t]===e),$=(e,l)=>e.map(l),_=Object,z=e=>_.getPrototypeOf(e),D=_.entries,G=e=>!B(e)&&E(z(e),e=>e==_.prototype||B(z(e)),()=>!0),J=_.keys,K=(e=[])=>_.fromEntries(e),Q=(e,l)=>$(D(e),([e,t])=>l(t,e)),U=(e,l)=>{const t=D(e);return j(t)===j(J(l))&&F(t,([e,t])=>G(t)?!!G(l[e])&&U(l[e],t):l[e]===t)},{PureComponent:W,createContext:X,useCallback:Y,useContext:Z,useEffect:ee,useLayoutEffect:le,useMemo:te,useRef:re,useState:ne,useSyncExternalStore:ae}=r,se=(e,...l)=>q(e)?{}:e(...l),oe="tinybase_uirc",ce=S[oe]?S[oe]:S[oe]=X([]),ie=(e,l)=>{const t=((e,l)=>{const t=Z(ce);return q(e)?t[2*l]:O(e)?((e,l)=>L(e,e=>e[l]))(t[2*l+1],e):e})(e,l);return q(e)||O(e)?t:e},de=[],he=[{},[],[de,void 0,de],void 0,!1,0],ue=[U,H,([e,l,t],[r,n,a])=>l===n&&H(e,r)&&H(t,a)],me=(e,l)=>e===l,Ce=(e,l,t,r=de)=>{const n=re(he[t]),a=Y(()=>{const a=l?.[(4==t?"has":"get")+e]?.(...r)??he[t];return(ue[t]??me)(a,n.current)?n.current:n.current=a},[l,t,e,...r]),s=Y(n=>((e,l,...t)=>{const r=e?.["add"+l+"Listener"]?.(...t);return()=>e?.delListener?.(r)})(l,(4==t?"Has":"")+e,...r,n),[l,t,e,...r]);return ae(s,a,a)},pe=(e,l,t,r=de,n=M,a=de,...s)=>((e,l,t,r=de,n=M,a=de,s="",...o)=>Y(r=>L(e,e=>L(t(r,e),t=>n(e[s+l](...be(o,e,r),t),t))),[e,l,...r,...a,s,...fe(o)]))(Ie(e),l,t,r,n,a,"set",...s),be=(e,l,t)=>$(e,e=>V(e)?e(t,l):e),fe=e=>{return l=e=>!V(e),e.filter(l);var l},Ie=e=>ie(e,0),ge=(e,l)=>Ce(C+x,Ie(l),1,[e]),xe=(e,l)=>Ce(f,Ie(l),1,[e]),ye=(e,l,t,r,n,a)=>((e,l,t,r,n,a)=>Ce(I,Ie(a),1,[e,l,t,r,n]))(...G(e)?[e.tableId,e.cellId,e.descending??!1,e.offset??0,e.limit,l]:[e,l,t,r,n,a]),Ne=(e,l,t,r)=>Ce(g,Ie(r),3,[e,l,t]),ve=(e,l)=>Ce(y,Ie(l),3,[e]),we=(e,l,t,r,n,a,s,o)=>pe(a,g,r,n,s,o,e,l,t),Te=(e,l,t,r,n,a)=>pe(r,y,l,t,n,a,e),ke=e=>ie(e,2),Se=(e,l,t)=>Ce("Slice"+f,ke(t),1,[e,l]),Re=e=>ie(e,3),Ae=e=>ie(e,4),Be=(e,l)=>Ce(u+C+x,Ae(l),1,[e]),qe=(e,l)=>Ce(u+f,Ae(l),1,[e]),Pe=(e,l,t,r=0,n,a)=>Ce(u+I,Ae(a),1,[e,l,t,r,n]),Ee=(e,l,t,r)=>e==c?l:e==d?t:e==i?r:null,Le=(e,l)=>te(()=>({store:e,tableId:l}),[e,l]),Oe=(e,l)=>te(()=>({queries:e,queryId:l}),[e,l]),Ve=(e,l,t)=>{const r=Y(e,l);return t?r:void 0},je=(...e)=>te(()=>e,e),Me=(e,l,t)=>te(()=>{const r=l??e;return n=Array.isArray(r)?K($(r,e=>[e,e])):r,a=(e,l)=>({label:l,component:t,...O(e)?{label:e}:e}),K(Q(n,(e,l)=>[l,a(e,l)]));var n,a},[l,t,e]),Fe="editable",He=(l=[],t,r=0)=>$(l,({component:l},n)=>e("td",{className:T,children:e(l,{...t})},$e(n,r))),$e=(e,l)=>(l?">":"<")+e,_e=(l=[],t=0)=>$(l,({label:l},r)=>e("th",{className:T,children:l},$e(r,t))),ze=({cellId:e,sort:[t,r],label:n=e??"",onClick:a})=>l("th",{onClick:Ve(()=>a?.(e),[a,e],a),className:q(r)||t!=e?void 0:`sorted ${r?"de":"a"}scending`,children:[q(r)||t!=e?null:(r?"↓":"↑")+" ",n]}),De=({className:t,headerRow:r,idColumn:n,params:[a,s,o,c,i,d,h,u]})=>l("table",{className:t,children:[u?e("caption",{children:u}):null,!1===r?null:e("thead",{children:l("tr",{children:[_e(c),!1===n?null:e(ze,{sort:d??[],label:"Id",onClick:h}),Q(a,({label:l},t)=>e(ze,{cellId:t,label:l,sort:d??[],onClick:h},t)),_e(i,1)]})}),e("tbody",{children:$(o,t=>{const r={...s,rowId:t};return l("tr",{children:[He(c,r),P(n)?null:e("th",{title:t,children:t}),Q(a,({component:l,getComponentProps:n},a)=>e("td",{children:e(l,{...se(n,t,a),...r,cellId:a})},a)),He(i,r,1)]},t)})})]}),Ge=({thing:t,onThingChange:r,className:n,hasSchema:a,showType:s=!0})=>{const[h,u]=ne(),[m,C]=ne(),[p,b]=ne(),[f,I]=ne(),[g,x]=ne();m!==t&&(u((e=>{if(null===e)return"null";const l=o(e);return(e=>e==c||e==i)(l)||l==d&&A(e)?l:void 0})(t)),C(t),b(t+""),I(Number(t)||0),x(!!t));const y=Y((e,l)=>{l(e),C(e),r(e)},[r]),N=Y(()=>{if(!a?.()){const e=Ee(h,d,i,c),l=Ee(e,p,f,g);u(e),C(l),r(l)}},[a,r,p,f,g,h]),T=Ee(h,e("input",{value:p,onChange:Y(e=>y(e[v][w]+"",b),[y])},h),e("input",{type:"number",value:f,onChange:Y(e=>y(Number(e[v][w]||0),I),[y])},h),e("input",{type:"checkbox",checked:g,onChange:Y(e=>y(!!e[v].checked,x),[y])},h));return l("div",{className:n,children:[s&&T?e("button",{title:h,className:h,onClick:N,children:h}):null,T]})},Je=({tableId:l,rowId:t,cellId:r,store:n,className:a,showType:s})=>e(Ge,{thing:Ne(l,t,r,n),onThingChange:we(l,t,r,e=>e,[],n),className:a??Fe+g,showType:s,hasSchema:Ie(n)?.hasTablesSchema}),Ke=({valueId:l,store:t,className:r,showType:n})=>e(Ge,{thing:ve(l,t),onThingChange:Te(l,e=>e,[],t),className:r??Fe+y,showType:n,hasSchema:Ie(t)?.hasValuesSchema}),Qe=(e,l)=>$(ge(e,l),l=>e+"."+l),Ue=({localRowId:r,params:[n,a,s,o,c,i,d,h,u]})=>{const m=((e,l,t)=>Ce("RemoteRowId",Re(t),3,[e,l]))(c,r,i),C={tableId:s??"",rowId:r,store:d};return l("tr",{children:[He(h,C),P(n)?null:l(t,{children:[e("th",{title:r,children:r}),e("th",{title:m,children:m})]}),Q(a,({component:l,getComponentProps:t},n)=>{const[a,c]=((e,l="",t)=>e.split(l,t))(n,".",2),i=a===s?r:a===o?m:void 0;return q(i)?null:e("td",{children:e(l,{...se(t,i,c),store:d,tableId:a,rowId:i,cellId:c})},n)}),He(u,C,1)]})},We=({relationshipId:r,relationships:a,editable:s,customCells:o,extraCellsBefore:c,extraCellsAfter:i,className:d,headerRow:h,idColumn:u=!0})=>{const[m,C,p,b]=((e,l)=>[e,e?.getStore(),e?.getLocalTableId(l),e?.getRemoteTableId(l)])(Re(a),r),f=Me([...Qe(p,C),...Qe(b,C)],o,s?Je:n),I=je(u,f,p,b,r,m,C,c,i);return l("table",{className:d,children:[P(h)?null:e("thead",{children:l("tr",{children:[_e(c),P(u)?null:l(t,{children:[l("th",{children:[p,".Id"]}),l("th",{children:[b,".Id"]})]}),Q(f,({label:l},t)=>e("th",{children:l},t)),_e(i,1)]})}),e("tbody",{children:$(xe(p,C),l=>e(Ue,{localRowId:l,params:I},l))})]})},Xe=(l,t=!1,r,n=0,a,s,o,c)=>{const[[i,d,h],u]=ne([l,t,n]),m=Y(e=>{u(e),c?.(e)},[c]),C=Ve(e=>m([e,e==i&&!d,h]),[m,i,d,h],r),p=Y(e=>m([i,d,e]),[m,i,d]),b=!0===o?Ye:o;return[[i,d,h],C,te(()=>P(o)?null:e(b,{offset:h,limit:a,total:s,onChange:p}),[o,b,h,a,s,p])]},Ye=({onChange:r,total:n,offset:a=0,limit:s=n,singular:o="row",plural:c=o+"s"})=>{(a>n||a<0)&&(a=0,r(0));const i=Ve(()=>r(a-s),[r,a,s],a>0),d=Ve(()=>r(a+s),[r,a,s],a+s<n);return l(t,{children:[n>s&&l(t,{children:[e("button",{className:"previous",disabled:0==a,onClick:i,children:"←"}),e("button",{className:"next",disabled:a+s>=n,onClick:d,children:"→"}),a+1," to ",R(n,a+s)," of "]}),n," ",1!=n?c:o]})},Ze=({queryId:l,cellId:t,descending:r,offset:n,limit:s,queries:o,sortOnClick:c,paginator:i=!1,customCells:d,extraCellsBefore:h,extraCellsAfter:m,onChange:C,...p})=>{const[f,I,g]=Xe(t,r,c,n,s,((e,l)=>Ce(u+b,Ae(l),5,[e]))(l,o),i,C);return e(De,{...p,params:je(Me(Be(l,o),d,a),Oe(o,l),Pe(l,...f,s,o),h,m,f,I,g)})},el=({queryId:l,queries:t,customCells:r,extraCellsBefore:n,extraCellsAfter:s,...o})=>e(De,{...o,params:je(Me(Be(l,t),r,a),Oe(t,l),qe(l,t),n,s)}),ll=({indexId:l,sliceId:t,indexes:r,editable:a,customCells:s,extraCellsBefore:o,extraCellsAfter:c,...i})=>{const[d,h,u]=((e,l)=>[e,e?.getStore(),e?.getTableId(l)])(ke(r),l);return e(De,{...i,params:je(Me(ge(u,h),s,a?Je:n),Le(h,u),Se(l,t,d),o,c)})},tl=({tableId:l,cellId:t,descending:r,offset:a,limit:s,store:o,editable:c,sortOnClick:i,paginator:d=!1,onChange:h,customCells:u,extraCellsBefore:m,extraCellsAfter:C,...p})=>{const[f,I,g]=Xe(t,r,i,a,s,((e,l)=>Ce(b,Ie(l),5,[e]))(l,o),d,h);return e(De,{...p,params:je(Me(ge(l,o),u,c?Je:n),Le(o,l),ye(l,...f,s,o),m,C,f,I,g)})},rl=({tableId:l,store:t,editable:r,customCells:a,extraCellsBefore:s,extraCellsAfter:o,...c})=>e(De,{...c,params:je(Me(ge(l,t),a,r?Je:n),Le(t,l),xe(l,t),s,o)}),nl=(l=[],t,r=0)=>$(l,({component:l},n)=>e("td",{className:T,children:e(l,{...t})},$e(n,r))),al=({store:t,editable:r=!1,valueComponent:n=(r?Ke:s),getValueComponentProps:a,extraCellsBefore:o,extraCellsAfter:c,className:i,headerRow:d,idColumn:h})=>{return l("table",{className:i,children:[!1===d?null:e("thead",{children:l("tr",{children:[_e(o),!1===h?null:e("th",{children:"Id"}),e("th",{children:y}),_e(c,1)]})}),e("tbody",{children:$((u=t,Ce(N,Ie(u),1)),r=>{const s={valueId:r,store:t};return l("tr",{children:[nl(o,s),P(h)?null:e("th",{title:r,children:r}),e("td",{children:e(n,{...se(a,r),...s})}),nl(c,s,1)]},r)})})]});var u};export{Je as EditableCellView,Ke as EditableValueView,Ue as RelationshipInHtmlRow,We as RelationshipInHtmlTable,Ze as ResultSortedTableInHtmlTable,el as ResultTableInHtmlTable,ll as SliceInHtmlTable,tl as SortedTableInHtmlTable,Ye as SortedTablePaginator,rl as TableInHtmlTable,al as ValuesInHtmlTable,Xe as useSortingAndPagination};
1
+ import{jsx as e,jsxs as l,Fragment as t}from"react/jsx-runtime";import r from"react";import{CellView as n,ResultCellView as a,ValueView as s}from"../ui-react/index.js";const o=e=>typeof e,c=o(""),i=o(!0),d=o(0),h=o(o),u="Result",m="Ids",C="Table",p="Row",b=p+"Count",f=p+m,I="Sorted"+p+m,g="Cell",x=g+m,y="Value",N=y+m,v="currentTarget",w="value",T="extra",k=e=>(l,t,r)=>e(l)?r?.():t(l),S=globalThis,R=Math.min,A=isFinite,B=e=>null==e,q=e=>void 0===e,P=e=>!1===e,E=k(B),L=k(q),O=e=>o(e)==c,V=e=>o(e)==h,j=e=>Array.isArray(e),M=e=>e.length,F=()=>{},H=(e,l)=>e.every(l),$=(e,l)=>M(e)===M(l)&&H(e,(e,t)=>l[t]===e),_=(e,l)=>j(e)&&j(l)?$(e,l):e===l,z=(e,l)=>e.map(l),D=Object,G=e=>D.getPrototypeOf(e),J=D.entries,K=e=>!B(e)&&E(G(e),e=>e==D.prototype||B(G(e)),()=>!0),Q=D.keys,U=(e=[])=>D.fromEntries(e),W=(e,l)=>z(J(e),([e,t])=>l(t,e)),X=(e,l,t=(e,l)=>e===l)=>{const r=J(e);return M(r)===M(Q(l))&&H(r,([e,r])=>K(r)?!!K(l[e])&&X(l[e],r):t(r,l[e]))},{PureComponent:Y,createContext:Z,useCallback:ee,useContext:le,useEffect:te,useLayoutEffect:re,useMemo:ne,useRef:ae,useState:se,useSyncExternalStore:oe}=r,ce=(e,...l)=>q(e)?{}:e(...l),ie="tinybase_uirc",de=S[ie]?S[ie]:S[ie]=Z([]),he=(e,l)=>{const t=((e,l)=>{const t=le(de);return q(e)?t[2*l]:O(e)?((e,l)=>L(e,e=>e[l]))(t[2*l+1],e):e})(e,l);return q(e)||O(e)?t:e},ue=[],me=[{},[],[ue,void 0,ue],{},void 0,void 0,!1,0],Ce=[X,$,([e,l,t],[r,n,a])=>l===n&&$(e,r)&&$(t,a),(e,l)=>X(e,l,_),_],pe=(e,l)=>e===l,be=(e,l,t,r=ue)=>{const n=ae(me[t]),a=ee(()=>{const a=l?.[(6==t?"has":"get")+e]?.(...r)??me[t];return(Ce[t]??pe)(a,n.current)?n.current:n.current=a},[l,t,e,...r]),s=ee(n=>((e,l,...t)=>{const r=e?.["add"+l+"Listener"]?.(...t);return()=>e?.delListener?.(r)})(l,(6==t?"Has":"")+e,...r,n),[l,t,e,...r]);return oe(s,a,a)},fe=(e,l,t,r,n,a,...s)=>((e,l,t,r=ue,n=F,a=ue,s,...o)=>ee(r=>L(e,e=>L(t(r,e),t=>n(e[s+l](...Ie(o,e,r),t),t))),[e,l,...r,...a,s,...ge(o)]))(xe(e),l,t,r,n,a,"set",...s),Ie=(e,l,t)=>z(e,e=>V(e)?e(t,l):e),ge=e=>{return l=e=>!V(e),e.filter(l);var l},xe=e=>he(e,0),ye=(e,l)=>be(C+x,xe(l),1,[e]),Ne=(e,l)=>be(f,xe(l),1,[e]),ve=(e,l,t,r,n,a)=>((e,l,t,r,n,a)=>be(I,xe(a),1,[e,l,t,r,n]))(...K(e)?[e.tableId,e.cellId,e.descending??!1,e.offset??0,e.limit,l]:[e,l,t,r,n,a]),we=(e,l,t,r)=>be(g,xe(r),5,[e,l,t]),Te=(e,l)=>be(y,xe(l),5,[e]),ke=(e,l,t,r,n,a,s,o)=>fe(a,g,r,n,s,o,e,l,t),Se=(e,l,t,r,n,a)=>fe(r,y,l,t,n,a,e),Re=e=>he(e,2),Ae=(e,l,t)=>be("Slice"+f,Re(t),1,[e,l]),Be=e=>he(e,3),qe=e=>he(e,4),Pe=(e,l)=>be(u+C+x,qe(l),1,[e]),Ee=(e,l)=>be(u+f,qe(l),1,[e]),Le=(e,l,t,r=0,n,a)=>be(u+I,qe(a),1,[e,l,t,r,n]),Oe=(e,l,t,r)=>e==c?l:e==d?t:e==i?r:null,Ve=(e,l)=>ne(()=>({store:e,tableId:l}),[e,l]),je=(e,l)=>ne(()=>({queries:e,queryId:l}),[e,l]),Me=(e,l,t)=>{const r=ee(e,l);return t?r:void 0},Fe=(...e)=>ne(()=>e,e),He=(e,l,t)=>ne(()=>{const r=l??e;return n=j(r)?U(z(r,e=>[e,e])):r,a=(e,l)=>({label:l,component:t,...O(e)?{label:e}:e}),U(W(n,(e,l)=>[l,a(e,l)]));var n,a},[l,t,e]),$e="editable",_e=(l=[],t,r=0)=>z(l,({component:l},n)=>e("td",{className:T,children:e(l,{...t})},ze(n,r))),ze=(e,l)=>(l?">":"<")+e,De=(l=[],t=0)=>z(l,({label:l},r)=>e("th",{className:T,children:l},ze(r,t))),Ge=({cellId:e,sort:[t,r],label:n=e??"",onClick:a})=>l("th",{onClick:Me(()=>a?.(e),[a,e],a),className:q(r)||t!=e?void 0:`sorted ${r?"de":"a"}scending`,children:[q(r)||t!=e?null:(r?"↓":"↑")+" ",n]}),Je=({className:t,headerRow:r,idColumn:n,params:[a,s,o,c,i,d,h,u]})=>l("table",{className:t,children:[u?e("caption",{children:u}):null,!1===r?null:e("thead",{children:l("tr",{children:[De(c),!1===n?null:e(Ge,{sort:d??[],label:"Id",onClick:h}),W(a,({label:l},t)=>e(Ge,{cellId:t,label:l,sort:d??[],onClick:h},t)),De(i,1)]})}),e("tbody",{children:z(o,t=>{const r={...s,rowId:t};return l("tr",{children:[_e(c,r),P(n)?null:e("th",{title:t,children:t}),W(a,({component:l,getComponentProps:n},a)=>e("td",{children:e(l,{...ce(n,t,a),...r,cellId:a})},a)),_e(i,r,1)]},t)})})]}),Ke=({thing:t,onThingChange:r,className:n,hasSchema:a,showType:s=!0})=>{const[h,u]=se(),[m,C]=se(),[p,b]=se(),[f,I]=se(),[g,x]=se();m!==t&&(u((e=>{if(null===e)return"null";const l=o(e);return(e=>e==c||e==i)(l)||l==d&&A(e)?l:void 0})(t)),C(t),b(t+""),I(Number(t)||0),x(!!t));const y=ee((e,l)=>{l(e),C(e),r(e)},[r]),N=ee(()=>{if(!a?.()){const e=Oe(h,d,i,c),l=Oe(e,p,f,g);u(e),C(l),r(l)}},[a,r,p,f,g,h]),T=Oe(h,e("input",{value:p,onChange:ee(e=>y(e[v][w]+"",b),[y])},h),e("input",{type:"number",value:f,onChange:ee(e=>y(Number(e[v][w]||0),I),[y])},h),e("input",{type:"checkbox",checked:g,onChange:ee(e=>y(!!e[v].checked,x),[y])},h));return l("div",{className:n,children:[s&&T?e("button",{title:h,className:h,onClick:N,children:h}):null,T]})},Qe=({tableId:l,rowId:t,cellId:r,store:n,className:a,showType:s})=>e(Ke,{thing:we(l,t,r,n),onThingChange:ke(l,t,r,e=>e,[],n),className:a??$e+g,showType:s,hasSchema:xe(n)?.hasTablesSchema}),Ue=({valueId:l,store:t,className:r,showType:n})=>e(Ke,{thing:Te(l,t),onThingChange:Se(l,e=>e,[],t),className:r??$e+y,showType:n,hasSchema:xe(t)?.hasValuesSchema}),We=(e,l)=>z(ye(e,l),l=>e+"."+l),Xe=({localRowId:r,params:[n,a,s,o,c,i,d,h,u]})=>{const m=((e,l,t)=>be("RemoteRowId",Be(t),5,[e,l]))(c,r,i),C={tableId:s??"",rowId:r,store:d};return l("tr",{children:[_e(h,C),P(n)?null:l(t,{children:[e("th",{title:r,children:r}),e("th",{title:m,children:m})]}),W(a,({component:l,getComponentProps:t},n)=>{const[a,c]=((e,l="",t)=>e.split(l,t))(n,".",2),i=a===s?r:a===o?m:void 0;return q(i)?null:e("td",{children:e(l,{...ce(t,i,c),store:d,tableId:a,rowId:i,cellId:c})},n)}),_e(u,C,1)]})},Ye=({relationshipId:r,relationships:a,editable:s,customCells:o,extraCellsBefore:c,extraCellsAfter:i,className:d,headerRow:h,idColumn:u=!0})=>{const[m,C,p,b]=((e,l)=>[e,e?.getStore(),e?.getLocalTableId(l),e?.getRemoteTableId(l)])(Be(a),r),f=He([...We(p,C),...We(b,C)],o,s?Qe:n),I=Fe(u,f,p,b,r,m,C,c,i);return l("table",{className:d,children:[P(h)?null:e("thead",{children:l("tr",{children:[De(c),P(u)?null:l(t,{children:[l("th",{children:[p,".Id"]}),l("th",{children:[b,".Id"]})]}),W(f,({label:l},t)=>e("th",{children:l},t)),De(i,1)]})}),e("tbody",{children:z(Ne(p,C),l=>e(Xe,{localRowId:l,params:I},l))})]})},Ze=(l,t=!1,r,n=0,a,s,o,c)=>{const[[i,d,h],u]=se([l,t,n]),m=ee(e=>{u(e),c?.(e)},[c]),C=Me(e=>m([e,e==i&&!d,h]),[m,i,d,h],r),p=ee(e=>m([i,d,e]),[m,i,d]),b=!0===o?el:o;return[[i,d,h],C,ne(()=>P(o)?null:e(b,{offset:h,limit:a,total:s,onChange:p}),[o,b,h,a,s,p])]},el=({onChange:r,total:n,offset:a=0,limit:s=n,singular:o="row",plural:c=o+"s"})=>{(a>n||a<0)&&(a=0,r(0));const i=Me(()=>r(a-s),[r,a,s],a>0),d=Me(()=>r(a+s),[r,a,s],a+s<n);return l(t,{children:[n>s&&l(t,{children:[e("button",{className:"previous",disabled:0==a,onClick:i,children:"←"}),e("button",{className:"next",disabled:a+s>=n,onClick:d,children:"→"}),a+1," to ",R(n,a+s)," of "]}),n," ",1!=n?c:o]})},ll=({queryId:l,cellId:t,descending:r,offset:n,limit:s,queries:o,sortOnClick:c,paginator:i=!1,customCells:d,extraCellsBefore:h,extraCellsAfter:m,onChange:C,...p})=>{const[f,I,g]=Ze(t,r,c,n,s,((e,l)=>be(u+b,qe(l),7,[e]))(l,o),i,C);return e(Je,{...p,params:Fe(He(Pe(l,o),d,a),je(o,l),Le(l,...f,s,o),h,m,f,I,g)})},tl=({queryId:l,queries:t,customCells:r,extraCellsBefore:n,extraCellsAfter:s,...o})=>e(Je,{...o,params:Fe(He(Pe(l,t),r,a),je(t,l),Ee(l,t),n,s)}),rl=({indexId:l,sliceId:t,indexes:r,editable:a,customCells:s,extraCellsBefore:o,extraCellsAfter:c,...i})=>{const[d,h,u]=((e,l)=>[e,e?.getStore(),e?.getTableId(l)])(Re(r),l);return e(Je,{...i,params:Fe(He(ye(u,h),s,a?Qe:n),Ve(h,u),Ae(l,t,d),o,c)})},nl=({tableId:l,cellId:t,descending:r,offset:a,limit:s,store:o,editable:c,sortOnClick:i,paginator:d=!1,onChange:h,customCells:u,extraCellsBefore:m,extraCellsAfter:C,...p})=>{const[f,I,g]=Ze(t,r,i,a,s,((e,l)=>be(b,xe(l),7,[e]))(l,o),d,h);return e(Je,{...p,params:Fe(He(ye(l,o),u,c?Qe:n),Ve(o,l),ve(l,...f,s,o),m,C,f,I,g)})},al=({tableId:l,store:t,editable:r,customCells:a,extraCellsBefore:s,extraCellsAfter:o,...c})=>e(Je,{...c,params:Fe(He(ye(l,t),a,r?Qe:n),Ve(t,l),Ne(l,t),s,o)}),sl=(l=[],t,r=0)=>z(l,({component:l},n)=>e("td",{className:T,children:e(l,{...t})},ze(n,r))),ol=({store:t,editable:r=!1,valueComponent:n=(r?Ue:s),getValueComponentProps:a,extraCellsBefore:o,extraCellsAfter:c,className:i,headerRow:d,idColumn:h})=>{return l("table",{className:i,children:[!1===d?null:e("thead",{children:l("tr",{children:[De(o),!1===h?null:e("th",{children:"Id"}),e("th",{children:y}),De(c,1)]})}),e("tbody",{children:z((u=t,be(N,xe(u),1)),r=>{const s={valueId:r,store:t};return l("tr",{children:[sl(o,s),P(h)?null:e("th",{title:r,children:r}),e("td",{children:e(n,{...ce(a,r),...s})}),sl(c,s,1)]},r)})})]});var u};export{Qe as EditableCellView,Ue as EditableValueView,Xe as RelationshipInHtmlRow,Ye as RelationshipInHtmlTable,ll as ResultSortedTableInHtmlTable,tl as ResultTableInHtmlTable,rl as SliceInHtmlTable,nl as SortedTableInHtmlTable,el as SortedTablePaginator,al as TableInHtmlTable,ol as ValuesInHtmlTable,Ze as useSortingAndPagination};
Binary file
@@ -1 +1 @@
1
- import{jsx as e,jsxs as l,Fragment as t}from"react/jsx-runtime";import r from"react";import{CellView as n,ResultCellView as a,ValueView as s}from"../../ui-react/with-schemas/index.js";const o=e=>typeof e,c=o(""),i=o(!0),d=o(0),h=o(o),u="Result",m="Ids",C="Table",p="Row",b=p+"Count",f=p+m,I="Sorted"+p+m,g="Cell",x=g+m,y="Value",N=y+m,v="currentTarget",w="value",T="extra",k=e=>(l,t,r)=>e(l)?r?.():t(l),S=globalThis,R=Math.min,A=isFinite,B=e=>null==e,q=e=>void 0===e,P=e=>!1===e,E=k(B),L=k(q),O=e=>o(e)==c,V=e=>o(e)==h,j=e=>e.length,M=()=>{},F=(e,l)=>e.every(l),H=(e,l)=>j(e)===j(l)&&F(e,(e,t)=>l[t]===e),$=(e,l)=>e.map(l),_=Object,z=e=>_.getPrototypeOf(e),D=_.entries,G=e=>!B(e)&&E(z(e),e=>e==_.prototype||B(z(e)),()=>!0),J=_.keys,K=(e=[])=>_.fromEntries(e),Q=(e,l)=>$(D(e),([e,t])=>l(t,e)),U=(e,l)=>{const t=D(e);return j(t)===j(J(l))&&F(t,([e,t])=>G(t)?!!G(l[e])&&U(l[e],t):l[e]===t)},{PureComponent:W,createContext:X,useCallback:Y,useContext:Z,useEffect:ee,useLayoutEffect:le,useMemo:te,useRef:re,useState:ne,useSyncExternalStore:ae}=r,se=(e,...l)=>q(e)?{}:e(...l),oe="tinybase_uirc",ce=S[oe]?S[oe]:S[oe]=X([]),ie=(e,l)=>{const t=((e,l)=>{const t=Z(ce);return q(e)?t[2*l]:O(e)?((e,l)=>L(e,e=>e[l]))(t[2*l+1],e):e})(e,l);return q(e)||O(e)?t:e},de=[],he=[{},[],[de,void 0,de],void 0,!1,0],ue=[U,H,([e,l,t],[r,n,a])=>l===n&&H(e,r)&&H(t,a)],me=(e,l)=>e===l,Ce=(e,l,t,r=de)=>{const n=re(he[t]),a=Y(()=>{const a=l?.[(4==t?"has":"get")+e]?.(...r)??he[t];return(ue[t]??me)(a,n.current)?n.current:n.current=a},[l,t,e,...r]),s=Y(n=>((e,l,...t)=>{const r=e?.["add"+l+"Listener"]?.(...t);return()=>e?.delListener?.(r)})(l,(4==t?"Has":"")+e,...r,n),[l,t,e,...r]);return ae(s,a,a)},pe=(e,l,t,r=de,n=M,a=de,...s)=>((e,l,t,r=de,n=M,a=de,s="",...o)=>Y(r=>L(e,e=>L(t(r,e),t=>n(e[s+l](...be(o,e,r),t),t))),[e,l,...r,...a,s,...fe(o)]))(Ie(e),l,t,r,n,a,"set",...s),be=(e,l,t)=>$(e,e=>V(e)?e(t,l):e),fe=e=>{return l=e=>!V(e),e.filter(l);var l},Ie=e=>ie(e,0),ge=(e,l)=>Ce(C+x,Ie(l),1,[e]),xe=(e,l)=>Ce(f,Ie(l),1,[e]),ye=(e,l,t,r,n,a)=>((e,l,t,r,n,a)=>Ce(I,Ie(a),1,[e,l,t,r,n]))(...G(e)?[e.tableId,e.cellId,e.descending??!1,e.offset??0,e.limit,l]:[e,l,t,r,n,a]),Ne=(e,l,t,r)=>Ce(g,Ie(r),3,[e,l,t]),ve=(e,l)=>Ce(y,Ie(l),3,[e]),we=(e,l,t,r,n,a,s,o)=>pe(a,g,r,n,s,o,e,l,t),Te=(e,l,t,r,n,a)=>pe(r,y,l,t,n,a,e),ke=e=>ie(e,2),Se=(e,l,t)=>Ce("Slice"+f,ke(t),1,[e,l]),Re=e=>ie(e,3),Ae=e=>ie(e,4),Be=(e,l)=>Ce(u+C+x,Ae(l),1,[e]),qe=(e,l)=>Ce(u+f,Ae(l),1,[e]),Pe=(e,l,t,r=0,n,a)=>Ce(u+I,Ae(a),1,[e,l,t,r,n]),Ee=(e,l,t,r)=>e==c?l:e==d?t:e==i?r:null,Le=(e,l)=>te(()=>({store:e,tableId:l}),[e,l]),Oe=(e,l)=>te(()=>({queries:e,queryId:l}),[e,l]),Ve=(e,l,t)=>{const r=Y(e,l);return t?r:void 0},je=(...e)=>te(()=>e,e),Me=(e,l,t)=>te(()=>{const r=l??e;return n=Array.isArray(r)?K($(r,e=>[e,e])):r,a=(e,l)=>({label:l,component:t,...O(e)?{label:e}:e}),K(Q(n,(e,l)=>[l,a(e,l)]));var n,a},[l,t,e]),Fe="editable",He=(l=[],t,r=0)=>$(l,({component:l},n)=>e("td",{className:T,children:e(l,{...t})},$e(n,r))),$e=(e,l)=>(l?">":"<")+e,_e=(l=[],t=0)=>$(l,({label:l},r)=>e("th",{className:T,children:l},$e(r,t))),ze=({cellId:e,sort:[t,r],label:n=e??"",onClick:a})=>l("th",{onClick:Ve(()=>a?.(e),[a,e],a),className:q(r)||t!=e?void 0:`sorted ${r?"de":"a"}scending`,children:[q(r)||t!=e?null:(r?"↓":"↑")+" ",n]}),De=({className:t,headerRow:r,idColumn:n,params:[a,s,o,c,i,d,h,u]})=>l("table",{className:t,children:[u?e("caption",{children:u}):null,!1===r?null:e("thead",{children:l("tr",{children:[_e(c),!1===n?null:e(ze,{sort:d??[],label:"Id",onClick:h}),Q(a,({label:l},t)=>e(ze,{cellId:t,label:l,sort:d??[],onClick:h},t)),_e(i,1)]})}),e("tbody",{children:$(o,t=>{const r={...s,rowId:t};return l("tr",{children:[He(c,r),P(n)?null:e("th",{title:t,children:t}),Q(a,({component:l,getComponentProps:n},a)=>e("td",{children:e(l,{...se(n,t,a),...r,cellId:a})},a)),He(i,r,1)]},t)})})]}),Ge=({thing:t,onThingChange:r,className:n,hasSchema:a,showType:s=!0})=>{const[h,u]=ne(),[m,C]=ne(),[p,b]=ne(),[f,I]=ne(),[g,x]=ne();m!==t&&(u((e=>{if(null===e)return"null";const l=o(e);return(e=>e==c||e==i)(l)||l==d&&A(e)?l:void 0})(t)),C(t),b(t+""),I(Number(t)||0),x(!!t));const y=Y((e,l)=>{l(e),C(e),r(e)},[r]),N=Y(()=>{if(!a?.()){const e=Ee(h,d,i,c),l=Ee(e,p,f,g);u(e),C(l),r(l)}},[a,r,p,f,g,h]),T=Ee(h,e("input",{value:p,onChange:Y(e=>y(e[v][w]+"",b),[y])},h),e("input",{type:"number",value:f,onChange:Y(e=>y(Number(e[v][w]||0),I),[y])},h),e("input",{type:"checkbox",checked:g,onChange:Y(e=>y(!!e[v].checked,x),[y])},h));return l("div",{className:n,children:[s&&T?e("button",{title:h,className:h,onClick:N,children:h}):null,T]})},Je=({tableId:l,rowId:t,cellId:r,store:n,className:a,showType:s})=>e(Ge,{thing:Ne(l,t,r,n),onThingChange:we(l,t,r,e=>e,[],n),className:a??Fe+g,showType:s,hasSchema:Ie(n)?.hasTablesSchema}),Ke=({valueId:l,store:t,className:r,showType:n})=>e(Ge,{thing:ve(l,t),onThingChange:Te(l,e=>e,[],t),className:r??Fe+y,showType:n,hasSchema:Ie(t)?.hasValuesSchema}),Qe=(e,l)=>$(ge(e,l),l=>e+"."+l),Ue=({localRowId:r,params:[n,a,s,o,c,i,d,h,u]})=>{const m=((e,l,t)=>Ce("RemoteRowId",Re(t),3,[e,l]))(c,r,i),C={tableId:s??"",rowId:r,store:d};return l("tr",{children:[He(h,C),P(n)?null:l(t,{children:[e("th",{title:r,children:r}),e("th",{title:m,children:m})]}),Q(a,({component:l,getComponentProps:t},n)=>{const[a,c]=((e,l="",t)=>e.split(l,t))(n,".",2),i=a===s?r:a===o?m:void 0;return q(i)?null:e("td",{children:e(l,{...se(t,i,c),store:d,tableId:a,rowId:i,cellId:c})},n)}),He(u,C,1)]})},We=({relationshipId:r,relationships:a,editable:s,customCells:o,extraCellsBefore:c,extraCellsAfter:i,className:d,headerRow:h,idColumn:u=!0})=>{const[m,C,p,b]=((e,l)=>[e,e?.getStore(),e?.getLocalTableId(l),e?.getRemoteTableId(l)])(Re(a),r),f=Me([...Qe(p,C),...Qe(b,C)],o,s?Je:n),I=je(u,f,p,b,r,m,C,c,i);return l("table",{className:d,children:[P(h)?null:e("thead",{children:l("tr",{children:[_e(c),P(u)?null:l(t,{children:[l("th",{children:[p,".Id"]}),l("th",{children:[b,".Id"]})]}),Q(f,({label:l},t)=>e("th",{children:l},t)),_e(i,1)]})}),e("tbody",{children:$(xe(p,C),l=>e(Ue,{localRowId:l,params:I},l))})]})},Xe=(l,t=!1,r,n=0,a,s,o,c)=>{const[[i,d,h],u]=ne([l,t,n]),m=Y(e=>{u(e),c?.(e)},[c]),C=Ve(e=>m([e,e==i&&!d,h]),[m,i,d,h],r),p=Y(e=>m([i,d,e]),[m,i,d]),b=!0===o?Ye:o;return[[i,d,h],C,te(()=>P(o)?null:e(b,{offset:h,limit:a,total:s,onChange:p}),[o,b,h,a,s,p])]},Ye=({onChange:r,total:n,offset:a=0,limit:s=n,singular:o="row",plural:c=o+"s"})=>{(a>n||a<0)&&(a=0,r(0));const i=Ve(()=>r(a-s),[r,a,s],a>0),d=Ve(()=>r(a+s),[r,a,s],a+s<n);return l(t,{children:[n>s&&l(t,{children:[e("button",{className:"previous",disabled:0==a,onClick:i,children:"←"}),e("button",{className:"next",disabled:a+s>=n,onClick:d,children:"→"}),a+1," to ",R(n,a+s)," of "]}),n," ",1!=n?c:o]})},Ze=({queryId:l,cellId:t,descending:r,offset:n,limit:s,queries:o,sortOnClick:c,paginator:i=!1,customCells:d,extraCellsBefore:h,extraCellsAfter:m,onChange:C,...p})=>{const[f,I,g]=Xe(t,r,c,n,s,((e,l)=>Ce(u+b,Ae(l),5,[e]))(l,o),i,C);return e(De,{...p,params:je(Me(Be(l,o),d,a),Oe(o,l),Pe(l,...f,s,o),h,m,f,I,g)})},el=({queryId:l,queries:t,customCells:r,extraCellsBefore:n,extraCellsAfter:s,...o})=>e(De,{...o,params:je(Me(Be(l,t),r,a),Oe(t,l),qe(l,t),n,s)}),ll=({indexId:l,sliceId:t,indexes:r,editable:a,customCells:s,extraCellsBefore:o,extraCellsAfter:c,...i})=>{const[d,h,u]=((e,l)=>[e,e?.getStore(),e?.getTableId(l)])(ke(r),l);return e(De,{...i,params:je(Me(ge(u,h),s,a?Je:n),Le(h,u),Se(l,t,d),o,c)})},tl=({tableId:l,cellId:t,descending:r,offset:a,limit:s,store:o,editable:c,sortOnClick:i,paginator:d=!1,onChange:h,customCells:u,extraCellsBefore:m,extraCellsAfter:C,...p})=>{const[f,I,g]=Xe(t,r,i,a,s,((e,l)=>Ce(b,Ie(l),5,[e]))(l,o),d,h);return e(De,{...p,params:je(Me(ge(l,o),u,c?Je:n),Le(o,l),ye(l,...f,s,o),m,C,f,I,g)})},rl=({tableId:l,store:t,editable:r,customCells:a,extraCellsBefore:s,extraCellsAfter:o,...c})=>e(De,{...c,params:je(Me(ge(l,t),a,r?Je:n),Le(t,l),xe(l,t),s,o)}),nl=(l=[],t,r=0)=>$(l,({component:l},n)=>e("td",{className:T,children:e(l,{...t})},$e(n,r))),al=({store:t,editable:r=!1,valueComponent:n=(r?Ke:s),getValueComponentProps:a,extraCellsBefore:o,extraCellsAfter:c,className:i,headerRow:d,idColumn:h})=>{return l("table",{className:i,children:[!1===d?null:e("thead",{children:l("tr",{children:[_e(o),!1===h?null:e("th",{children:"Id"}),e("th",{children:y}),_e(c,1)]})}),e("tbody",{children:$((u=t,Ce(N,Ie(u),1)),r=>{const s={valueId:r,store:t};return l("tr",{children:[nl(o,s),P(h)?null:e("th",{title:r,children:r}),e("td",{children:e(n,{...se(a,r),...s})}),nl(c,s,1)]},r)})})]});var u};export{Je as EditableCellView,Ke as EditableValueView,Ue as RelationshipInHtmlRow,We as RelationshipInHtmlTable,Ze as ResultSortedTableInHtmlTable,el as ResultTableInHtmlTable,ll as SliceInHtmlTable,tl as SortedTableInHtmlTable,Ye as SortedTablePaginator,rl as TableInHtmlTable,al as ValuesInHtmlTable,Xe as useSortingAndPagination};
1
+ import{jsx as e,jsxs as l,Fragment as t}from"react/jsx-runtime";import r from"react";import{CellView as n,ResultCellView as a,ValueView as s}from"../../ui-react/with-schemas/index.js";const o=e=>typeof e,c=o(""),i=o(!0),d=o(0),h=o(o),u="Result",m="Ids",C="Table",p="Row",b=p+"Count",f=p+m,I="Sorted"+p+m,g="Cell",x=g+m,y="Value",N=y+m,v="currentTarget",w="value",T="extra",k=e=>(l,t,r)=>e(l)?r?.():t(l),S=globalThis,R=Math.min,A=isFinite,B=e=>null==e,q=e=>void 0===e,P=e=>!1===e,E=k(B),L=k(q),O=e=>o(e)==c,V=e=>o(e)==h,j=e=>Array.isArray(e),M=e=>e.length,F=()=>{},H=(e,l)=>e.every(l),$=(e,l)=>M(e)===M(l)&&H(e,(e,t)=>l[t]===e),_=(e,l)=>j(e)&&j(l)?$(e,l):e===l,z=(e,l)=>e.map(l),D=Object,G=e=>D.getPrototypeOf(e),J=D.entries,K=e=>!B(e)&&E(G(e),e=>e==D.prototype||B(G(e)),()=>!0),Q=D.keys,U=(e=[])=>D.fromEntries(e),W=(e,l)=>z(J(e),([e,t])=>l(t,e)),X=(e,l,t=(e,l)=>e===l)=>{const r=J(e);return M(r)===M(Q(l))&&H(r,([e,r])=>K(r)?!!K(l[e])&&X(l[e],r):t(r,l[e]))},{PureComponent:Y,createContext:Z,useCallback:ee,useContext:le,useEffect:te,useLayoutEffect:re,useMemo:ne,useRef:ae,useState:se,useSyncExternalStore:oe}=r,ce=(e,...l)=>q(e)?{}:e(...l),ie="tinybase_uirc",de=S[ie]?S[ie]:S[ie]=Z([]),he=(e,l)=>{const t=((e,l)=>{const t=le(de);return q(e)?t[2*l]:O(e)?((e,l)=>L(e,e=>e[l]))(t[2*l+1],e):e})(e,l);return q(e)||O(e)?t:e},ue=[],me=[{},[],[ue,void 0,ue],{},void 0,void 0,!1,0],Ce=[X,$,([e,l,t],[r,n,a])=>l===n&&$(e,r)&&$(t,a),(e,l)=>X(e,l,_),_],pe=(e,l)=>e===l,be=(e,l,t,r=ue)=>{const n=ae(me[t]),a=ee(()=>{const a=l?.[(6==t?"has":"get")+e]?.(...r)??me[t];return(Ce[t]??pe)(a,n.current)?n.current:n.current=a},[l,t,e,...r]),s=ee(n=>((e,l,...t)=>{const r=e?.["add"+l+"Listener"]?.(...t);return()=>e?.delListener?.(r)})(l,(6==t?"Has":"")+e,...r,n),[l,t,e,...r]);return oe(s,a,a)},fe=(e,l,t,r,n,a,...s)=>((e,l,t,r=ue,n=F,a=ue,s,...o)=>ee(r=>L(e,e=>L(t(r,e),t=>n(e[s+l](...Ie(o,e,r),t),t))),[e,l,...r,...a,s,...ge(o)]))(xe(e),l,t,r,n,a,"set",...s),Ie=(e,l,t)=>z(e,e=>V(e)?e(t,l):e),ge=e=>{return l=e=>!V(e),e.filter(l);var l},xe=e=>he(e,0),ye=(e,l)=>be(C+x,xe(l),1,[e]),Ne=(e,l)=>be(f,xe(l),1,[e]),ve=(e,l,t,r,n,a)=>((e,l,t,r,n,a)=>be(I,xe(a),1,[e,l,t,r,n]))(...K(e)?[e.tableId,e.cellId,e.descending??!1,e.offset??0,e.limit,l]:[e,l,t,r,n,a]),we=(e,l,t,r)=>be(g,xe(r),5,[e,l,t]),Te=(e,l)=>be(y,xe(l),5,[e]),ke=(e,l,t,r,n,a,s,o)=>fe(a,g,r,n,s,o,e,l,t),Se=(e,l,t,r,n,a)=>fe(r,y,l,t,n,a,e),Re=e=>he(e,2),Ae=(e,l,t)=>be("Slice"+f,Re(t),1,[e,l]),Be=e=>he(e,3),qe=e=>he(e,4),Pe=(e,l)=>be(u+C+x,qe(l),1,[e]),Ee=(e,l)=>be(u+f,qe(l),1,[e]),Le=(e,l,t,r=0,n,a)=>be(u+I,qe(a),1,[e,l,t,r,n]),Oe=(e,l,t,r)=>e==c?l:e==d?t:e==i?r:null,Ve=(e,l)=>ne(()=>({store:e,tableId:l}),[e,l]),je=(e,l)=>ne(()=>({queries:e,queryId:l}),[e,l]),Me=(e,l,t)=>{const r=ee(e,l);return t?r:void 0},Fe=(...e)=>ne(()=>e,e),He=(e,l,t)=>ne(()=>{const r=l??e;return n=j(r)?U(z(r,e=>[e,e])):r,a=(e,l)=>({label:l,component:t,...O(e)?{label:e}:e}),U(W(n,(e,l)=>[l,a(e,l)]));var n,a},[l,t,e]),$e="editable",_e=(l=[],t,r=0)=>z(l,({component:l},n)=>e("td",{className:T,children:e(l,{...t})},ze(n,r))),ze=(e,l)=>(l?">":"<")+e,De=(l=[],t=0)=>z(l,({label:l},r)=>e("th",{className:T,children:l},ze(r,t))),Ge=({cellId:e,sort:[t,r],label:n=e??"",onClick:a})=>l("th",{onClick:Me(()=>a?.(e),[a,e],a),className:q(r)||t!=e?void 0:`sorted ${r?"de":"a"}scending`,children:[q(r)||t!=e?null:(r?"↓":"↑")+" ",n]}),Je=({className:t,headerRow:r,idColumn:n,params:[a,s,o,c,i,d,h,u]})=>l("table",{className:t,children:[u?e("caption",{children:u}):null,!1===r?null:e("thead",{children:l("tr",{children:[De(c),!1===n?null:e(Ge,{sort:d??[],label:"Id",onClick:h}),W(a,({label:l},t)=>e(Ge,{cellId:t,label:l,sort:d??[],onClick:h},t)),De(i,1)]})}),e("tbody",{children:z(o,t=>{const r={...s,rowId:t};return l("tr",{children:[_e(c,r),P(n)?null:e("th",{title:t,children:t}),W(a,({component:l,getComponentProps:n},a)=>e("td",{children:e(l,{...ce(n,t,a),...r,cellId:a})},a)),_e(i,r,1)]},t)})})]}),Ke=({thing:t,onThingChange:r,className:n,hasSchema:a,showType:s=!0})=>{const[h,u]=se(),[m,C]=se(),[p,b]=se(),[f,I]=se(),[g,x]=se();m!==t&&(u((e=>{if(null===e)return"null";const l=o(e);return(e=>e==c||e==i)(l)||l==d&&A(e)?l:void 0})(t)),C(t),b(t+""),I(Number(t)||0),x(!!t));const y=ee((e,l)=>{l(e),C(e),r(e)},[r]),N=ee(()=>{if(!a?.()){const e=Oe(h,d,i,c),l=Oe(e,p,f,g);u(e),C(l),r(l)}},[a,r,p,f,g,h]),T=Oe(h,e("input",{value:p,onChange:ee(e=>y(e[v][w]+"",b),[y])},h),e("input",{type:"number",value:f,onChange:ee(e=>y(Number(e[v][w]||0),I),[y])},h),e("input",{type:"checkbox",checked:g,onChange:ee(e=>y(!!e[v].checked,x),[y])},h));return l("div",{className:n,children:[s&&T?e("button",{title:h,className:h,onClick:N,children:h}):null,T]})},Qe=({tableId:l,rowId:t,cellId:r,store:n,className:a,showType:s})=>e(Ke,{thing:we(l,t,r,n),onThingChange:ke(l,t,r,e=>e,[],n),className:a??$e+g,showType:s,hasSchema:xe(n)?.hasTablesSchema}),Ue=({valueId:l,store:t,className:r,showType:n})=>e(Ke,{thing:Te(l,t),onThingChange:Se(l,e=>e,[],t),className:r??$e+y,showType:n,hasSchema:xe(t)?.hasValuesSchema}),We=(e,l)=>z(ye(e,l),l=>e+"."+l),Xe=({localRowId:r,params:[n,a,s,o,c,i,d,h,u]})=>{const m=((e,l,t)=>be("RemoteRowId",Be(t),5,[e,l]))(c,r,i),C={tableId:s??"",rowId:r,store:d};return l("tr",{children:[_e(h,C),P(n)?null:l(t,{children:[e("th",{title:r,children:r}),e("th",{title:m,children:m})]}),W(a,({component:l,getComponentProps:t},n)=>{const[a,c]=((e,l="",t)=>e.split(l,t))(n,".",2),i=a===s?r:a===o?m:void 0;return q(i)?null:e("td",{children:e(l,{...ce(t,i,c),store:d,tableId:a,rowId:i,cellId:c})},n)}),_e(u,C,1)]})},Ye=({relationshipId:r,relationships:a,editable:s,customCells:o,extraCellsBefore:c,extraCellsAfter:i,className:d,headerRow:h,idColumn:u=!0})=>{const[m,C,p,b]=((e,l)=>[e,e?.getStore(),e?.getLocalTableId(l),e?.getRemoteTableId(l)])(Be(a),r),f=He([...We(p,C),...We(b,C)],o,s?Qe:n),I=Fe(u,f,p,b,r,m,C,c,i);return l("table",{className:d,children:[P(h)?null:e("thead",{children:l("tr",{children:[De(c),P(u)?null:l(t,{children:[l("th",{children:[p,".Id"]}),l("th",{children:[b,".Id"]})]}),W(f,({label:l},t)=>e("th",{children:l},t)),De(i,1)]})}),e("tbody",{children:z(Ne(p,C),l=>e(Xe,{localRowId:l,params:I},l))})]})},Ze=(l,t=!1,r,n=0,a,s,o,c)=>{const[[i,d,h],u]=se([l,t,n]),m=ee(e=>{u(e),c?.(e)},[c]),C=Me(e=>m([e,e==i&&!d,h]),[m,i,d,h],r),p=ee(e=>m([i,d,e]),[m,i,d]),b=!0===o?el:o;return[[i,d,h],C,ne(()=>P(o)?null:e(b,{offset:h,limit:a,total:s,onChange:p}),[o,b,h,a,s,p])]},el=({onChange:r,total:n,offset:a=0,limit:s=n,singular:o="row",plural:c=o+"s"})=>{(a>n||a<0)&&(a=0,r(0));const i=Me(()=>r(a-s),[r,a,s],a>0),d=Me(()=>r(a+s),[r,a,s],a+s<n);return l(t,{children:[n>s&&l(t,{children:[e("button",{className:"previous",disabled:0==a,onClick:i,children:"←"}),e("button",{className:"next",disabled:a+s>=n,onClick:d,children:"→"}),a+1," to ",R(n,a+s)," of "]}),n," ",1!=n?c:o]})},ll=({queryId:l,cellId:t,descending:r,offset:n,limit:s,queries:o,sortOnClick:c,paginator:i=!1,customCells:d,extraCellsBefore:h,extraCellsAfter:m,onChange:C,...p})=>{const[f,I,g]=Ze(t,r,c,n,s,((e,l)=>be(u+b,qe(l),7,[e]))(l,o),i,C);return e(Je,{...p,params:Fe(He(Pe(l,o),d,a),je(o,l),Le(l,...f,s,o),h,m,f,I,g)})},tl=({queryId:l,queries:t,customCells:r,extraCellsBefore:n,extraCellsAfter:s,...o})=>e(Je,{...o,params:Fe(He(Pe(l,t),r,a),je(t,l),Ee(l,t),n,s)}),rl=({indexId:l,sliceId:t,indexes:r,editable:a,customCells:s,extraCellsBefore:o,extraCellsAfter:c,...i})=>{const[d,h,u]=((e,l)=>[e,e?.getStore(),e?.getTableId(l)])(Re(r),l);return e(Je,{...i,params:Fe(He(ye(u,h),s,a?Qe:n),Ve(h,u),Ae(l,t,d),o,c)})},nl=({tableId:l,cellId:t,descending:r,offset:a,limit:s,store:o,editable:c,sortOnClick:i,paginator:d=!1,onChange:h,customCells:u,extraCellsBefore:m,extraCellsAfter:C,...p})=>{const[f,I,g]=Ze(t,r,i,a,s,((e,l)=>be(b,xe(l),7,[e]))(l,o),d,h);return e(Je,{...p,params:Fe(He(ye(l,o),u,c?Qe:n),Ve(o,l),ve(l,...f,s,o),m,C,f,I,g)})},al=({tableId:l,store:t,editable:r,customCells:a,extraCellsBefore:s,extraCellsAfter:o,...c})=>e(Je,{...c,params:Fe(He(ye(l,t),a,r?Qe:n),Ve(t,l),Ne(l,t),s,o)}),sl=(l=[],t,r=0)=>z(l,({component:l},n)=>e("td",{className:T,children:e(l,{...t})},ze(n,r))),ol=({store:t,editable:r=!1,valueComponent:n=(r?Ue:s),getValueComponentProps:a,extraCellsBefore:o,extraCellsAfter:c,className:i,headerRow:d,idColumn:h})=>{return l("table",{className:i,children:[!1===d?null:e("thead",{children:l("tr",{children:[De(o),!1===h?null:e("th",{children:"Id"}),e("th",{children:y}),De(c,1)]})}),e("tbody",{children:z((u=t,be(N,xe(u),1)),r=>{const s={valueId:r,store:t};return l("tr",{children:[sl(o,s),P(h)?null:e("th",{title:r,children:r}),e("td",{children:e(n,{...ce(a,r),...s})}),sl(c,s,1)]},r)})})]});var u};export{Qe as EditableCellView,Ue as EditableValueView,Xe as RelationshipInHtmlRow,Ye as RelationshipInHtmlTable,ll as ResultSortedTableInHtmlTable,tl as ResultTableInHtmlTable,rl as SliceInHtmlTable,nl as SortedTableInHtmlTable,el as SortedTablePaginator,al as TableInHtmlTable,ol as ValuesInHtmlTable,Ze as useSortingAndPagination};