@simple-table/react 3.9.7 → 3.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("simple-table-core"),r=require("react-dom/server"),o=require("react-dom");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=s(t);function c(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function u({node:n}){const r=t.useRef(null);return t.useLayoutEffect(()=>{const e=r.current;if(e)return e.appendChild(n),()=>{n.parentNode===e&&e.removeChild(n)}},[n]),e.jsx("span",{ref:r,style:{display:"contents"}})}function a(t){if(null!=t)return"string"==typeof t?t:t instanceof Node?e.jsx(u,{node:t}):void 0}function l(e){return{sortIcon:a(null==e?void 0:e.sortIcon),filterIcon:a(null==e?void 0:e.filterIcon),collapseIcon:a(null==e?void 0:e.collapseIcon),labelContent:a(null==e?void 0:e.labelContent)}}function d(t){if(null!=t){if("string"==typeof t){if(""===t)return;return e.jsx("span",{style:{display:"contents"},dangerouslySetInnerHTML:{__html:t}})}return t instanceof Node?e.jsx(u,{node:t}):void 0}}"function"==typeof SuppressedError&&SuppressedError;const f=Symbol.for("simple-table.wrappedRenderer");function p(e){return"function"==typeof e&&Boolean(e[f])}function h(e){return e[f]=!0,e}function m(t,n){return p(n)?n:h(r=>{const o=document.createElement("div");return t.register(e.jsx(n,Object.assign({},r)),o),o})}function g(t,n){return p(n)?n:h(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:(i=r.components,{expandIcon:a(i.expandIcon),checkbox:a(i.checkbox),dragIcon:a(i.dragIcon),labelContent:a(i.labelContent),pinIcon:a(i.pinIcon)})});var i;return t.register(e.jsx(n,Object.assign({},s)),o),o})}function b(t,n){return p(n)?n:h(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{searchSection:r.searchSection?a(r.searchSection):null,listSection:a(r.listSection),resetSection:r.resetSection?a(r.resetSection):null});return t.register(e.jsx(n,Object.assign({},s)),o),o})}function j(t){const n=document.createElement("div");return n.innerHTML=r.renderToStaticMarkup(e.jsx(e.Fragment,{children:t})),function(e){const t=Array.from(e.childNodes).filter(e=>e.nodeType!==Node.TEXT_NODE||null!=e.textContent&&""!==e.textContent.trim());return 1===t.length&&t[0]instanceof HTMLElement?(e.removeChild(t[0]),t[0]):e}(n)}function y(t){return r.renderToStaticMarkup(e.jsx(e.Fragment,{children:t}))}function S(e){return"function"==typeof e}function v(t,n){const{cellRenderer:r,headerRenderer:o,children:s,nestedTable:i}=t,u=c(t,["cellRenderer","headerRenderer","children","nestedTable"]),a=Object.assign({},u);if(r&&(a.cellRenderer=function(t,n){return p(n)?n:h(r=>{const o=document.createElement("div");return o.style.display="contents",t.register(e.jsx(n,Object.assign({},r)),o),o})}(n,r)),o&&(a.headerRenderer=function(t,n){if(p(n))return n;let r=null;return h(o=>{const s=Object.assign(Object.assign({},o),{components:l(o.components)}),i=e.jsx(n,Object.assign({},s));return r&&t.update(r,i)||(r=document.createElement("div"),t.register(i,r)),r})}(n,o)),s&&(a.children=s.map(e=>v(e,n))),i){const e=Object.assign(Object.assign({},i),{rows:[]});a.nestedTable=O(e,n)}return a}function O(t,n){const{defaultHeaders:r,rows:o,footerRenderer:s,emptyStateRenderer:i,errorStateRenderer:u,loadingStateRenderer:a,tableEmptyStateRenderer:f,headerDropdown:O,columnEditorConfig:R,icons:E,rowButtons:x,onColumnOrderChange:C,onColumnWidthChange:w,onHeaderEdit:I,onColumnSelect:H}=t,T=c(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","rowButtons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]),A=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},T),{rows:o,defaultHeaders:r.map(e=>v(e,n)),onRendererHostDiscard:n.disposeHost}),C?{onColumnOrderChange:e=>C(e)}:{}),w?{onColumnWidthChange:e=>w(e)}:{}),I?{onHeaderEdit:(e,t)=>I(e,t)}:{}),H?{onColumnSelect:e=>H(e)}:{});if(void 0!==s&&(A.footerRenderer=function(t,n){return p(n)?n:h(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{nextIcon:d((i={nextIcon:r.nextIcon,prevIcon:r.prevIcon}).nextIcon),prevIcon:d(i.prevIcon)});var i;return t.register(e.jsx(n,Object.assign({},s)),o),o})}(n,s)),void 0!==i)if(S(i))A.emptyStateRenderer=m(n,i);else{const e=i;A.emptyStateRenderer=()=>j(e)}if(void 0!==u)if(S(u))A.errorStateRenderer=m(n,u);else{const e=u;A.errorStateRenderer=()=>j(e)}if(void 0!==a)if(S(a))A.loadingStateRenderer=m(n,a);else{const e=a;A.loadingStateRenderer=()=>j(e)}return void 0!==f&&(A.tableEmptyStateRenderer=null===f?null:j(f)),void 0!==O&&(A.headerDropdown=function(t,n){return p(n)?n:h(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:l(r.components)});return t.register(e.jsx(n,Object.assign({},s)),o),o})}(n,O)),void 0!==R&&(A.columnEditorConfig=function(e,t){const{rowRenderer:n,customRenderer:r}=e,o=c(e,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},o),n?{rowRenderer:g(t,n)}:{}),r?{customRenderer:b(t,r)}:{})}(R,n)),void 0!==E&&(A.icons=function(e){const t={};for(const[n,r]of Object.entries(e))null!=r&&(t[n]="string"==typeof r||r instanceof HTMLElement||r instanceof SVGElement?r:y(r));return t}(E)),void 0!==x&&(A.rowButtons=x.map(t=>function(t,n){return p(n)?n:h(r=>{const o=document.createElement("div");return o.style.display="contents",t.register(e.jsx(n,Object.assign({},r)),o),o})}(n,t))),A}const R="data-st-portal-id";class E{constructor(){this.entries=new Map,this.listeners=new Set,this.nextId=0,this.cachedSnapshot=[],this.snapshotDirty=!0,this.emitScheduled=!1,this.disposeHost=e=>{if("function"!=typeof e.getAttribute)return;const t=[],n=e.getAttribute(R);null!==n&&t.push(n),e.querySelectorAll(`[${R}]`).forEach(e=>{const n=e.getAttribute(R);null!==n&&t.push(n)});for(const e of t)this.unregister(e)},this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),this.getSnapshot=()=>(this.snapshotDirty&&(this.cachedSnapshot=Array.from(this.entries.values()),this.snapshotDirty=!1),this.cachedSnapshot)}register(e,t){const n="st-portal-"+this.nextId++;return t.setAttribute(R,n),this.entries.set(n,{id:n,container:t,node:e}),this.scheduleEmit(),{id:n,unregister:()=>this.unregister(n)}}update(e,t){const n=e.getAttribute(R);if(null===n)return!1;const r=this.entries.get(n);return!(!r||r.container!==e||(r.node=t,this.scheduleEmit(),0))}unregister(e){this.entries.delete(e)&&this.scheduleEmit()}clear(){0!==this.entries.size&&(this.entries.clear(),this.emit())}emit(){this.snapshotDirty=!0;for(const e of this.listeners)e()}scheduleEmit(){this.emitScheduled||(this.emitScheduled=!0,queueMicrotask(()=>{this.emitScheduled=!1,this.emit()}))}}class x extends i.default.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("[simple-table] A custom renderer threw while rendering:",e)}render(){return this.state.hasError?null:this.props.children}}const C=i.default.forwardRef(function(r,s){const i=t.useRef(null),u=t.useRef(null);null===u.current&&(u.current=new E);const a=u.current,l=t.useRef(null),d=t.useRef(void 0),f=t.useRef(null),p=r;t.useLayoutEffect(()=>{const e=i.current;if(!e)return;const t=new n.SimpleTableVanilla(e,O(p,a));if(t.mount(),l.current=t,f.current=p,d.current=p.defaultHeaders,s){const e=t.getAPI();"function"==typeof s?s(e):s.current=e}return()=>{t.destroy(),l.current=null,d.current=void 0,f.current=null,a.clear(),s&&"function"!=typeof s&&(s.current=null)}},[]),t.useLayoutEffect(()=>{const e=l.current;if(!e)return;if(null!==f.current&&!function(e,t){const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const r of n)if(e[r]!==t[r])return!0;return!1}(f.current,p))return;f.current=p;const t=O(p,a);if(d.current!==p.defaultHeaders)return d.current=p.defaultHeaders,void e.update(t);const n=c(t,["defaultHeaders"]);e.update(n)},[p]);const h=function(n){return t.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot).map(t=>o.createPortal(e.jsx(x,{children:t.node}),t.container,t.id))}(a),m=Array.isArray(h)&&h.length>0,g=t.useRef(!1),b=t.useRef(Boolean(p.isLoading));return t.useLayoutEffect(()=>{var e,t;const n=l.current;if(!n)return;const r=Boolean(p.isLoading),o=b.current&&!r;b.current=r,o?null===(e=n.refitAutoSizeColumns)||void 0===e||e.call(n):!g.current&&m&&(g.current=!0,null===(t=n.refitAutoSizeColumns)||void 0===t||t.call(n))},[m,p.isLoading]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:i}),h]})});C.displayName="SimpleTable",Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return n.asRows}}),exports.SimpleTable=C;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("simple-table-core"),r=require("react-dom/server"),o=require("react-dom");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(t);function i(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function a({node:n}){const r=t.useRef(null);return t.useLayoutEffect(()=>{const e=r.current;if(e)return e.appendChild(n),()=>{n.parentNode===e&&e.removeChild(n)}},[n]),e.jsx("span",{ref:r,style:{display:"contents"}})}function u(t){if(null!=t)return"string"==typeof t?t:t instanceof Node?e.jsx(a,{node:t}):void 0}function l(e){return{sortIcon:u(null==e?void 0:e.sortIcon),filterIcon:u(null==e?void 0:e.filterIcon),collapseIcon:u(null==e?void 0:e.collapseIcon),labelContent:u(null==e?void 0:e.labelContent)}}function d(t){if(null!=t){if("string"==typeof t){if(""===t)return;return e.jsx("span",{style:{display:"contents"},dangerouslySetInnerHTML:{__html:t}})}return t instanceof Node?e.jsx(a,{node:t}):void 0}}"function"==typeof SuppressedError&&SuppressedError;const f=Symbol.for("simple-table.wrappedRenderer");function h(e){return"function"==typeof e&&Boolean(e[f])}function p(e){return e[f]=!0,e}function m(t,n){return h(n)?n:p(r=>{const o=document.createElement("div");return t.register(e.jsx(n,Object.assign({},r)),o),o})}function g(t,n){return h(n)?n:p(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:(c=r.components,{expandIcon:u(c.expandIcon),checkbox:u(c.checkbox),dragIcon:u(c.dragIcon),labelContent:u(c.labelContent),pinIcon:u(c.pinIcon)})});var c;return t.register(e.jsx(n,Object.assign({},s)),o),o})}function b(t,n){return h(n)?n:p(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{searchSection:r.searchSection?u(r.searchSection):null,listSection:u(r.listSection),resetSection:r.resetSection?u(r.resetSection):null});return t.register(e.jsx(n,Object.assign({},s)),o),o})}function y(t){const n=document.createElement("div");return n.innerHTML=r.renderToStaticMarkup(e.jsx(e.Fragment,{children:t})),function(e){const t=Array.from(e.childNodes).filter(e=>e.nodeType!==Node.TEXT_NODE||null!=e.textContent&&""!==e.textContent.trim());return 1===t.length&&t[0]instanceof HTMLElement?(e.removeChild(t[0]),t[0]):e}(n)}function j(t){return r.renderToStaticMarkup(e.jsx(e.Fragment,{children:t}))}function R(e){return"function"==typeof e}function S(t,n){const{cellRenderer:r,headerRenderer:o,children:s,nestedTable:c}=t,a=i(t,["cellRenderer","headerRenderer","children","nestedTable"]),u=String(t.accessor),d=Object.assign({},a);if(r&&(d.cellRenderer=function(t,n,r){if(h(r))return r;const o=t.cellRendererCache.get(n);if(o)return o.component=r,o.wrapped;const s={component:r,wrapped:null},c=p(n=>{const r=s.component,o=document.createElement("div");return o.style.display="contents",t.register(e.jsx(r,Object.assign({},n)),o),o});return s.wrapped=c,t.cellRendererCache.set(n,s),c}(n,u,r)),o&&(d.headerRenderer=function(t,n,r){if(h(r))return r;const o=t.headerRendererCache.get(n);if(o)return o.component=r,o.wrapped;const s={component:r,wrapped:null};let c=null;const i=p(n=>{const r=s.component,o=Object.assign(Object.assign({},n),{components:l(n.components)}),i=e.jsx(r,Object.assign({},o));return c&&t.update(c,i)||(c=document.createElement("div"),t.register(i,c)),c});return s.wrapped=i,t.headerRendererCache.set(n,s),i}(n,u,o)),s&&(d.children=s.map(e=>S(e,n))),c){const e=Object.assign(Object.assign({},c),{rows:[]});d.nestedTable=v(e,n)}return d}function v(t,r){const{defaultHeaders:o,rows:s,footerRenderer:c,emptyStateRenderer:a,errorStateRenderer:u,loadingStateRenderer:f,tableEmptyStateRenderer:v,headerDropdown:O,columnEditorConfig:C,icons:w,rowButtons:E,onColumnOrderChange:x,onColumnWidthChange:I,onHeaderEdit:H,onColumnSelect:A}=t,T=i(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","rowButtons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]);r.pruneRendererCaches(n.collectHeaderAccessors(o));const D=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},T),{rows:s,defaultHeaders:o.map(e=>S(e,r)),onRendererHostDiscard:r.disposeHost}),x?{onColumnOrderChange:e=>x(e)}:{}),I?{onColumnWidthChange:e=>I(e)}:{}),H?{onHeaderEdit:(e,t)=>H(e,t)}:{}),A?{onColumnSelect:e=>A(e)}:{});if(void 0!==c&&(D.footerRenderer=function(t,n){return h(n)?n:p(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{nextIcon:d((c={nextIcon:r.nextIcon,prevIcon:r.prevIcon}).nextIcon),prevIcon:d(c.prevIcon)});var c;return t.register(e.jsx(n,Object.assign({},s)),o),o})}(r,c)),void 0!==a)if(R(a))D.emptyStateRenderer=m(r,a);else{const e=a;D.emptyStateRenderer=()=>y(e)}if(void 0!==u)if(R(u))D.errorStateRenderer=m(r,u);else{const e=u;D.errorStateRenderer=()=>y(e)}if(void 0!==f)if(R(f))D.loadingStateRenderer=m(r,f);else{const e=f;D.loadingStateRenderer=()=>y(e)}return void 0!==v&&(D.tableEmptyStateRenderer=null===v?null:y(v)),void 0!==O&&(D.headerDropdown=function(t,n){return h(n)?n:p(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:l(r.components)});return t.register(e.jsx(n,Object.assign({},s)),o),o})}(r,O)),void 0!==C&&(D.columnEditorConfig=function(e,t){const{rowRenderer:n,customRenderer:r}=e,o=i(e,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},o),n?{rowRenderer:g(t,n)}:{}),r?{customRenderer:b(t,r)}:{})}(C,r)),void 0!==w&&(D.icons=function(e){const t={};for(const[n,r]of Object.entries(e))null!=r&&(t[n]="string"==typeof r||r instanceof HTMLElement||r instanceof SVGElement?r:j(r));return t}(w)),void 0!==E&&(D.rowButtons=E.map(t=>function(t,n){return h(n)?n:p(r=>{const o=document.createElement("div");return o.style.display="contents",t.register(e.jsx(n,Object.assign({},r)),o),o})}(r,t))),D}const O="data-st-portal-id";class C{constructor(){this.entries=new Map,this.listeners=new Set,this.nextId=0,this.cachedSnapshot=[],this.snapshotDirty=!0,this.emitScheduled=!1,this.cellRendererCache=new Map,this.headerRendererCache=new Map,this.disposeHost=e=>{if("function"!=typeof e.getAttribute)return;const t=[],n=e.getAttribute(O);null!==n&&t.push(n),e.querySelectorAll(`[${O}]`).forEach(e=>{const n=e.getAttribute(O);null!==n&&t.push(n)});for(const e of t)this.unregister(e)},this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),this.getSnapshot=()=>(this.snapshotDirty&&(this.cachedSnapshot=Array.from(this.entries.values()),this.snapshotDirty=!1),this.cachedSnapshot)}register(e,t){const n="st-portal-"+this.nextId++;return t.setAttribute(O,n),this.entries.set(n,{id:n,container:t,node:e}),this.scheduleEmit(),{id:n,unregister:()=>this.unregister(n)}}update(e,t){const n=e.getAttribute(O);if(null===n)return!1;const r=this.entries.get(n);return!(!r||r.container!==e||(r.node=t,this.scheduleEmit(),0))}unregister(e){this.entries.delete(e)&&this.scheduleEmit()}clear(){this.cellRendererCache.clear(),this.headerRendererCache.clear(),0!==this.entries.size&&(this.entries.clear(),this.emit())}pruneRendererCaches(e){for(const t of this.cellRendererCache.keys())e.has(t)||this.cellRendererCache.delete(t);for(const t of this.headerRendererCache.keys())e.has(t)||this.headerRendererCache.delete(t)}emit(){this.snapshotDirty=!0;for(const e of this.listeners)e()}scheduleEmit(){this.emitScheduled||(this.emitScheduled=!0,queueMicrotask(()=>{this.emitScheduled=!1,this.emit()}))}}class w extends c.default.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("[simple-table] A custom renderer threw while rendering:",e)}render(){return this.state.hasError?null:this.props.children}}const E=c.default.forwardRef(function(r,s){const c=t.useRef(null),i=t.useRef(null);null===i.current&&(i.current=new C);const a=i.current,u=t.useRef(null),l=t.useRef(void 0),d=t.useRef(void 0),f=t.useRef(null),h=r;t.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=new n.SimpleTableVanilla(e,v(h,a));if(t.mount(),u.current=t,f.current=h,l.current=h.defaultHeaders,d.current=h.rows,s){const e=t.getAPI();"function"==typeof s?s(e):s.current=e}return()=>{t.destroy(),u.current=null,l.current=void 0,d.current=void 0,f.current=null,a.clear(),s&&"function"!=typeof s&&(s.current=null)}},[]),t.useLayoutEffect(()=>{const e=u.current;if(!e)return;if(null!==f.current&&!function(e,t){const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const r of n)if(e[r]!==t[r])return!0;return!1}(f.current,h))return;f.current=h;const t=v(h,a),r=Object.assign({},t),o=n.headersStructurallyEqual(l.current,h.defaultHeaders);l.current=h.defaultHeaders,o&&delete r.defaultHeaders;const s=n.rowsShallowUnchanged(d.current,h.rows,h.getRowId);d.current=h.rows,s&&delete r.rows,e.update(r)},[h]);const p=function(n){return t.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot).map(t=>o.createPortal(e.jsx(w,{children:t.node}),t.container,t.id))}(a),m=Array.isArray(p)&&p.length>0,g=t.useRef(!1),b=t.useRef(Boolean(h.isLoading));return t.useLayoutEffect(()=>{var e,t;const n=u.current;if(!n)return;const r=Boolean(h.isLoading),o=b.current&&!r;b.current=r,o?null===(e=n.refitAutoSizeColumns)||void 0===e||e.call(n):!g.current&&m&&(g.current=!0,null===(t=n.refitAutoSizeColumns)||void 0===t||t.call(n))},[m,h.isLoading]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:c}),p]})});E.displayName="SimpleTable",Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return n.asRows}}),exports.SimpleTable=E;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import r,{useRef as o,useLayoutEffect as s,useSyncExternalStore as i}from"react";import{SimpleTableVanilla as c}from"simple-table-core";export{asRows}from"simple-table-core";import{renderToStaticMarkup as u}from"react-dom/server";import{createPortal as l}from"react-dom";function a(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function d({node:t}){const n=o(null);return s(()=>{const e=n.current;if(e)return e.appendChild(t),()=>{t.parentNode===e&&e.removeChild(t)}},[t]),e("span",{ref:n,style:{display:"contents"}})}function f(t){if(null!=t)return"string"==typeof t?t:t instanceof Node?e(d,{node:t}):void 0}function h(e){return{sortIcon:f(null==e?void 0:e.sortIcon),filterIcon:f(null==e?void 0:e.filterIcon),collapseIcon:f(null==e?void 0:e.collapseIcon),labelContent:f(null==e?void 0:e.labelContent)}}function p(t){if(null!=t){if("string"==typeof t){if(""===t)return;return e("span",{style:{display:"contents"},dangerouslySetInnerHTML:{__html:t}})}return t instanceof Node?e(d,{node:t}):void 0}}"function"==typeof SuppressedError&&SuppressedError;const m=Symbol.for("simple-table.wrappedRenderer");function g(e){return"function"==typeof e&&Boolean(e[m])}function b(e){return e[m]=!0,e}function S(t,n){return g(n)?n:b(r=>{const o=document.createElement("div");return t.register(e(n,Object.assign({},r)),o),o})}function y(t,n){return g(n)?n:b(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:(i=r.components,{expandIcon:f(i.expandIcon),checkbox:f(i.checkbox),dragIcon:f(i.dragIcon),labelContent:f(i.labelContent),pinIcon:f(i.pinIcon)})});var i;return t.register(e(n,Object.assign({},s)),o),o})}function O(t,n){return g(n)?n:b(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{searchSection:r.searchSection?f(r.searchSection):null,listSection:f(r.listSection),resetSection:r.resetSection?f(r.resetSection):null});return t.register(e(n,Object.assign({},s)),o),o})}function v(n){const r=document.createElement("div");return r.innerHTML=u(e(t,{children:n})),function(e){const t=Array.from(e.childNodes).filter(e=>e.nodeType!==Node.TEXT_NODE||null!=e.textContent&&""!==e.textContent.trim());return 1===t.length&&t[0]instanceof HTMLElement?(e.removeChild(t[0]),t[0]):e}(r)}function j(n){return u(e(t,{children:n}))}function E(e){return"function"==typeof e}function R(t,n){const{cellRenderer:r,headerRenderer:o,children:s,nestedTable:i}=t,c=a(t,["cellRenderer","headerRenderer","children","nestedTable"]),u=Object.assign({},c);if(r&&(u.cellRenderer=function(t,n){return g(n)?n:b(r=>{const o=document.createElement("div");return o.style.display="contents",t.register(e(n,Object.assign({},r)),o),o})}(n,r)),o&&(u.headerRenderer=function(t,n){if(g(n))return n;let r=null;return b(o=>{const s=Object.assign(Object.assign({},o),{components:h(o.components)}),i=e(n,Object.assign({},s));return r&&t.update(r,i)||(r=document.createElement("div"),t.register(i,r)),r})}(n,o)),s&&(u.children=s.map(e=>R(e,n))),i){const e=Object.assign(Object.assign({},i),{rows:[]});u.nestedTable=C(e,n)}return u}function C(t,n){const{defaultHeaders:r,rows:o,footerRenderer:s,emptyStateRenderer:i,errorStateRenderer:c,loadingStateRenderer:u,tableEmptyStateRenderer:l,headerDropdown:d,columnEditorConfig:f,icons:m,rowButtons:C,onColumnOrderChange:w,onColumnWidthChange:I,onHeaderEdit:x,onColumnSelect:H}=t,A=a(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","rowButtons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]),D=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},A),{rows:o,defaultHeaders:r.map(e=>R(e,n)),onRendererHostDiscard:n.disposeHost}),w?{onColumnOrderChange:e=>w(e)}:{}),I?{onColumnWidthChange:e=>I(e)}:{}),x?{onHeaderEdit:(e,t)=>x(e,t)}:{}),H?{onColumnSelect:e=>H(e)}:{});if(void 0!==s&&(D.footerRenderer=function(t,n){return g(n)?n:b(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{nextIcon:p((i={nextIcon:r.nextIcon,prevIcon:r.prevIcon}).nextIcon),prevIcon:p(i.prevIcon)});var i;return t.register(e(n,Object.assign({},s)),o),o})}(n,s)),void 0!==i)if(E(i))D.emptyStateRenderer=S(n,i);else{const e=i;D.emptyStateRenderer=()=>v(e)}if(void 0!==c)if(E(c))D.errorStateRenderer=S(n,c);else{const e=c;D.errorStateRenderer=()=>v(e)}if(void 0!==u)if(E(u))D.loadingStateRenderer=S(n,u);else{const e=u;D.loadingStateRenderer=()=>v(e)}return void 0!==l&&(D.tableEmptyStateRenderer=null===l?null:v(l)),void 0!==d&&(D.headerDropdown=function(t,n){return g(n)?n:b(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:h(r.components)});return t.register(e(n,Object.assign({},s)),o),o})}(n,d)),void 0!==f&&(D.columnEditorConfig=function(e,t){const{rowRenderer:n,customRenderer:r}=e,o=a(e,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},o),n?{rowRenderer:y(t,n)}:{}),r?{customRenderer:O(t,r)}:{})}(f,n)),void 0!==m&&(D.icons=function(e){const t={};for(const[n,r]of Object.entries(e))null!=r&&(t[n]="string"==typeof r||r instanceof HTMLElement||r instanceof SVGElement?r:j(r));return t}(m)),void 0!==C&&(D.rowButtons=C.map(t=>function(t,n){return g(n)?n:b(r=>{const o=document.createElement("div");return o.style.display="contents",t.register(e(n,Object.assign({},r)),o),o})}(n,t))),D}const w="data-st-portal-id";class I{constructor(){this.entries=new Map,this.listeners=new Set,this.nextId=0,this.cachedSnapshot=[],this.snapshotDirty=!0,this.emitScheduled=!1,this.disposeHost=e=>{if("function"!=typeof e.getAttribute)return;const t=[],n=e.getAttribute(w);null!==n&&t.push(n),e.querySelectorAll(`[${w}]`).forEach(e=>{const n=e.getAttribute(w);null!==n&&t.push(n)});for(const e of t)this.unregister(e)},this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),this.getSnapshot=()=>(this.snapshotDirty&&(this.cachedSnapshot=Array.from(this.entries.values()),this.snapshotDirty=!1),this.cachedSnapshot)}register(e,t){const n="st-portal-"+this.nextId++;return t.setAttribute(w,n),this.entries.set(n,{id:n,container:t,node:e}),this.scheduleEmit(),{id:n,unregister:()=>this.unregister(n)}}update(e,t){const n=e.getAttribute(w);if(null===n)return!1;const r=this.entries.get(n);return!(!r||r.container!==e||(r.node=t,this.scheduleEmit(),0))}unregister(e){this.entries.delete(e)&&this.scheduleEmit()}clear(){0!==this.entries.size&&(this.entries.clear(),this.emit())}emit(){this.snapshotDirty=!0;for(const e of this.listeners)e()}scheduleEmit(){this.emitScheduled||(this.emitScheduled=!0,queueMicrotask(()=>{this.emitScheduled=!1,this.emit()}))}}class x extends r.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("[simple-table] A custom renderer threw while rendering:",e)}render(){return this.state.hasError?null:this.props.children}}const H=r.forwardRef(function(r,u){const d=o(null),f=o(null);null===f.current&&(f.current=new I);const h=f.current,p=o(null),m=o(void 0),g=o(null),b=r;s(()=>{const e=d.current;if(!e)return;const t=new c(e,C(b,h));if(t.mount(),p.current=t,g.current=b,m.current=b.defaultHeaders,u){const e=t.getAPI();"function"==typeof u?u(e):u.current=e}return()=>{t.destroy(),p.current=null,m.current=void 0,g.current=null,h.clear(),u&&"function"!=typeof u&&(u.current=null)}},[]),s(()=>{const e=p.current;if(!e)return;if(null!==g.current&&!function(e,t){const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const r of n)if(e[r]!==t[r])return!0;return!1}(g.current,b))return;g.current=b;const t=C(b,h);if(m.current!==b.defaultHeaders)return m.current=b.defaultHeaders,void e.update(t);const n=a(t,["defaultHeaders"]);e.update(n)},[b]);const S=function(t){return i(t.subscribe,t.getSnapshot,t.getSnapshot).map(t=>l(e(x,{children:t.node}),t.container,t.id))}(h),y=Array.isArray(S)&&S.length>0,O=o(!1),v=o(Boolean(b.isLoading));return s(()=>{var e,t;const n=p.current;if(!n)return;const r=Boolean(b.isLoading),o=v.current&&!r;v.current=r,o?null===(e=n.refitAutoSizeColumns)||void 0===e||e.call(n):!O.current&&y&&(O.current=!0,null===(t=n.refitAutoSizeColumns)||void 0===t||t.call(n))},[y,b.isLoading]),n(t,{children:[e("div",{ref:d}),S]})});H.displayName="SimpleTable";export{H as SimpleTable};
1
+ import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import r,{useRef as o,useLayoutEffect as s,useSyncExternalStore as c}from"react";import{collectHeaderAccessors as i,SimpleTableVanilla as a,headersStructurallyEqual as d,rowsShallowUnchanged as l}from"simple-table-core";export{asRows}from"simple-table-core";import{renderToStaticMarkup as u}from"react-dom/server";import{createPortal as h}from"react-dom";function p(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function f({node:t}){const n=o(null);return s(()=>{const e=n.current;if(e)return e.appendChild(t),()=>{t.parentNode===e&&e.removeChild(t)}},[t]),e("span",{ref:n,style:{display:"contents"}})}function m(t){if(null!=t)return"string"==typeof t?t:t instanceof Node?e(f,{node:t}):void 0}function g(e){return{sortIcon:m(null==e?void 0:e.sortIcon),filterIcon:m(null==e?void 0:e.filterIcon),collapseIcon:m(null==e?void 0:e.collapseIcon),labelContent:m(null==e?void 0:e.labelContent)}}function b(t){if(null!=t){if("string"==typeof t){if(""===t)return;return e("span",{style:{display:"contents"},dangerouslySetInnerHTML:{__html:t}})}return t instanceof Node?e(f,{node:t}):void 0}}"function"==typeof SuppressedError&&SuppressedError;const y=Symbol.for("simple-table.wrappedRenderer");function S(e){return"function"==typeof e&&Boolean(e[y])}function R(e){return e[y]=!0,e}function O(t,n){return S(n)?n:R(r=>{const o=document.createElement("div");return t.register(e(n,Object.assign({},r)),o),o})}function v(t,n){return S(n)?n:R(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:(c=r.components,{expandIcon:m(c.expandIcon),checkbox:m(c.checkbox),dragIcon:m(c.dragIcon),labelContent:m(c.labelContent),pinIcon:m(c.pinIcon)})});var c;return t.register(e(n,Object.assign({},s)),o),o})}function C(t,n){return S(n)?n:R(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{searchSection:r.searchSection?m(r.searchSection):null,listSection:m(r.listSection),resetSection:r.resetSection?m(r.resetSection):null});return t.register(e(n,Object.assign({},s)),o),o})}function j(n){const r=document.createElement("div");return r.innerHTML=u(e(t,{children:n})),function(e){const t=Array.from(e.childNodes).filter(e=>e.nodeType!==Node.TEXT_NODE||null!=e.textContent&&""!==e.textContent.trim());return 1===t.length&&t[0]instanceof HTMLElement?(e.removeChild(t[0]),t[0]):e}(r)}function w(n){return u(e(t,{children:n}))}function E(e){return"function"==typeof e}function I(t,n){const{cellRenderer:r,headerRenderer:o,children:s,nestedTable:c}=t,i=p(t,["cellRenderer","headerRenderer","children","nestedTable"]),a=String(t.accessor),d=Object.assign({},i);if(r&&(d.cellRenderer=function(t,n,r){if(S(r))return r;const o=t.cellRendererCache.get(n);if(o)return o.component=r,o.wrapped;const s={component:r,wrapped:null},c=R(n=>{const r=s.component,o=document.createElement("div");return o.style.display="contents",t.register(e(r,Object.assign({},n)),o),o});return s.wrapped=c,t.cellRendererCache.set(n,s),c}(n,a,r)),o&&(d.headerRenderer=function(t,n,r){if(S(r))return r;const o=t.headerRendererCache.get(n);if(o)return o.component=r,o.wrapped;const s={component:r,wrapped:null};let c=null;const i=R(n=>{const r=s.component,o=Object.assign(Object.assign({},n),{components:g(n.components)}),i=e(r,Object.assign({},o));return c&&t.update(c,i)||(c=document.createElement("div"),t.register(i,c)),c});return s.wrapped=i,t.headerRendererCache.set(n,s),i}(n,a,o)),s&&(d.children=s.map(e=>I(e,n))),c){const e=Object.assign(Object.assign({},c),{rows:[]});d.nestedTable=x(e,n)}return d}function x(t,n){const{defaultHeaders:r,rows:o,footerRenderer:s,emptyStateRenderer:c,errorStateRenderer:a,loadingStateRenderer:d,tableEmptyStateRenderer:l,headerDropdown:u,columnEditorConfig:h,icons:f,rowButtons:m,onColumnOrderChange:y,onColumnWidthChange:x,onHeaderEdit:H,onColumnSelect:A}=t,D=p(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","rowButtons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]);n.pruneRendererCaches(i(r));const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},D),{rows:o,defaultHeaders:r.map(e=>I(e,n)),onRendererHostDiscard:n.disposeHost}),y?{onColumnOrderChange:e=>y(e)}:{}),x?{onColumnWidthChange:e=>x(e)}:{}),H?{onHeaderEdit:(e,t)=>H(e,t)}:{}),A?{onColumnSelect:e=>A(e)}:{});if(void 0!==s&&(T.footerRenderer=function(t,n){return S(n)?n:R(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{nextIcon:b((c={nextIcon:r.nextIcon,prevIcon:r.prevIcon}).nextIcon),prevIcon:b(c.prevIcon)});var c;return t.register(e(n,Object.assign({},s)),o),o})}(n,s)),void 0!==c)if(E(c))T.emptyStateRenderer=O(n,c);else{const e=c;T.emptyStateRenderer=()=>j(e)}if(void 0!==a)if(E(a))T.errorStateRenderer=O(n,a);else{const e=a;T.errorStateRenderer=()=>j(e)}if(void 0!==d)if(E(d))T.loadingStateRenderer=O(n,d);else{const e=d;T.loadingStateRenderer=()=>j(e)}return void 0!==l&&(T.tableEmptyStateRenderer=null===l?null:j(l)),void 0!==u&&(T.headerDropdown=function(t,n){return S(n)?n:R(r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:g(r.components)});return t.register(e(n,Object.assign({},s)),o),o})}(n,u)),void 0!==h&&(T.columnEditorConfig=function(e,t){const{rowRenderer:n,customRenderer:r}=e,o=p(e,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},o),n?{rowRenderer:v(t,n)}:{}),r?{customRenderer:C(t,r)}:{})}(h,n)),void 0!==f&&(T.icons=function(e){const t={};for(const[n,r]of Object.entries(e))null!=r&&(t[n]="string"==typeof r||r instanceof HTMLElement||r instanceof SVGElement?r:w(r));return t}(f)),void 0!==m&&(T.rowButtons=m.map(t=>function(t,n){return S(n)?n:R(r=>{const o=document.createElement("div");return o.style.display="contents",t.register(e(n,Object.assign({},r)),o),o})}(n,t))),T}const H="data-st-portal-id";class A{constructor(){this.entries=new Map,this.listeners=new Set,this.nextId=0,this.cachedSnapshot=[],this.snapshotDirty=!0,this.emitScheduled=!1,this.cellRendererCache=new Map,this.headerRendererCache=new Map,this.disposeHost=e=>{if("function"!=typeof e.getAttribute)return;const t=[],n=e.getAttribute(H);null!==n&&t.push(n),e.querySelectorAll(`[${H}]`).forEach(e=>{const n=e.getAttribute(H);null!==n&&t.push(n)});for(const e of t)this.unregister(e)},this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),this.getSnapshot=()=>(this.snapshotDirty&&(this.cachedSnapshot=Array.from(this.entries.values()),this.snapshotDirty=!1),this.cachedSnapshot)}register(e,t){const n="st-portal-"+this.nextId++;return t.setAttribute(H,n),this.entries.set(n,{id:n,container:t,node:e}),this.scheduleEmit(),{id:n,unregister:()=>this.unregister(n)}}update(e,t){const n=e.getAttribute(H);if(null===n)return!1;const r=this.entries.get(n);return!(!r||r.container!==e||(r.node=t,this.scheduleEmit(),0))}unregister(e){this.entries.delete(e)&&this.scheduleEmit()}clear(){this.cellRendererCache.clear(),this.headerRendererCache.clear(),0!==this.entries.size&&(this.entries.clear(),this.emit())}pruneRendererCaches(e){for(const t of this.cellRendererCache.keys())e.has(t)||this.cellRendererCache.delete(t);for(const t of this.headerRendererCache.keys())e.has(t)||this.headerRendererCache.delete(t)}emit(){this.snapshotDirty=!0;for(const e of this.listeners)e()}scheduleEmit(){this.emitScheduled||(this.emitScheduled=!0,queueMicrotask(()=>{this.emitScheduled=!1,this.emit()}))}}class D extends r.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.error("[simple-table] A custom renderer threw while rendering:",e)}render(){return this.state.hasError?null:this.props.children}}const T=r.forwardRef(function(r,i){const u=o(null),p=o(null);null===p.current&&(p.current=new A);const f=p.current,m=o(null),g=o(void 0),b=o(void 0),y=o(null),S=r;s(()=>{const e=u.current;if(!e)return;const t=new a(e,x(S,f));if(t.mount(),m.current=t,y.current=S,g.current=S.defaultHeaders,b.current=S.rows,i){const e=t.getAPI();"function"==typeof i?i(e):i.current=e}return()=>{t.destroy(),m.current=null,g.current=void 0,b.current=void 0,y.current=null,f.clear(),i&&"function"!=typeof i&&(i.current=null)}},[]),s(()=>{const e=m.current;if(!e)return;if(null!==y.current&&!function(e,t){const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const r of n)if(e[r]!==t[r])return!0;return!1}(y.current,S))return;y.current=S;const t=x(S,f),n=Object.assign({},t),r=d(g.current,S.defaultHeaders);g.current=S.defaultHeaders,r&&delete n.defaultHeaders;const o=l(b.current,S.rows,S.getRowId);b.current=S.rows,o&&delete n.rows,e.update(n)},[S]);const R=function(t){return c(t.subscribe,t.getSnapshot,t.getSnapshot).map(t=>h(e(D,{children:t.node}),t.container,t.id))}(f),O=Array.isArray(R)&&R.length>0,v=o(!1),C=o(Boolean(S.isLoading));return s(()=>{var e,t;const n=m.current;if(!n)return;const r=Boolean(S.isLoading),o=C.current&&!r;C.current=r,o?null===(e=n.refitAutoSizeColumns)||void 0===e||e.call(n):!v.current&&O&&(v.current=!0,null===(t=n.refitAutoSizeColumns)||void 0===t||t.call(n))},[O,S.isLoading]),n(t,{children:[e("div",{ref:u}),R]})});T.displayName="SimpleTable";export{T as SimpleTable};
2
2
  //# sourceMappingURL=index.es.js.map
@@ -69,6 +69,14 @@ export declare class SimpleTableVanilla {
69
69
  private headerRegistry;
70
70
  private rowIndexMap;
71
71
  private animationCoordinator;
72
+ /**
73
+ * When true, the sort subscriber skips `captureAnimationSnapshot` so
74
+ * live-update-driven reorder/visibility changes don't FLIP-animate.
75
+ * User-initiated sorts leave this false and keep FLIP.
76
+ */
77
+ private suppressNextAnimationSnapshot;
78
+ /** Lazily created once — callers often invoke getAPI() every live tick. */
79
+ private cachedAPI;
72
80
  private autoScaleManager;
73
81
  private dimensionManager;
74
82
  private scrollManager;
@@ -41,6 +41,8 @@ export interface TableAPIContext {
41
41
  * re-render once the animation settles.
42
42
  */
43
43
  isCellAnimating?: (cellId: string) => boolean;
44
+ /** True while any FLIP cell transition is in flight (blocks live re-sort/re-filter). */
45
+ hasAnimatingCells?: () => boolean;
44
46
  columnEditorOpen: boolean;
45
47
  expandedDepthsManager: any;
46
48
  selectionManager: SelectionManager | null;
@@ -50,6 +52,17 @@ export interface TableAPIContext {
50
52
  getCachedFlattenResult?: () => FlattenRowsResult | null;
51
53
  getCachedProcessedResult?: () => ProcessRowsResult | null;
52
54
  onRender: () => void;
55
+ /**
56
+ * Bust the flatten / body row caches so the next render re-runs quick filter
57
+ * (and related processing) against in-place mutated row values.
58
+ */
59
+ invalidateRowsCache?: () => void;
60
+ /**
61
+ * Run `fn` without capturing a FLIP snapshot when sort/filter subscribers
62
+ * fire. Used for live-update-driven reorder/visibility changes so high-
63
+ * frequency ticks don't spam sort animations.
64
+ */
65
+ runWithoutAnimationSnapshot?: (fn: () => void) => void;
53
66
  setHeaders: (headers: HeaderObject[]) => void;
54
67
  setCurrentPage: (page: number) => void;
55
68
  setColumnEditorOpen: (open: boolean) => void;
@@ -49,4 +49,6 @@ import type { RowId } from "./types/RowId";
49
49
  import type { PinnedSectionsState } from "./types/PinnedSectionsState";
50
50
  export { SimpleTableVanilla };
51
51
  export { asRows } from "./utils/asRows";
52
+ export { headersStructurallyEqual, collectHeaderAccessors, rowsShallowUnchanged, shallowEqualRow, SHALLOW_ROW_COMPARE_MAX, } from "./utils/propSyncEqual";
53
+ export type { HeaderStructureLike, GetRowIdLike } from "./utils/propSyncEqual";
52
54
  export type { Accessor, AggregationConfig, AggregationType, AnimationsConfig, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ChartOptions, ColumnEditorConfig, ColumnEditorCustomRenderer, ColumnEditorCustomRendererProps, ColumnEditorRowRenderer, ColumnEditorRowRendererComponents, ColumnEditorRowRendererProps, ColumnEditorSearchFunction, ColumnType, ColumnVisibilityState, Comparator, ComparatorProps, CustomTheme, CustomThemeProps, DragHandlerProps, EmptyStateRenderer, EmptyStateRendererProps, EnumOption, ErrorStateRenderer, ErrorStateRendererProps, ExportToCSVProps, ExportValueGetter, ExportValueProps, FilterCondition, FilterOperator, StringFilterOperator, NumberFilterOperator, BooleanFilterOperator, DateFilterOperator, EnumFilterOperator, FooterRendererProps, FooterPosition, GetRowId, GetRowIdParams, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, HeaderDropdown, HeaderDropdownProps, HeaderObject, HeaderRenderer, HeaderRendererProps, HeaderRendererComponents, OnRowGroupExpandProps, OnSortProps, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowSelectionMode, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, PinnedSectionsState, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, };
@@ -117,6 +117,8 @@ export declare class AnimationCoordinator {
117
117
  setEasing(easing: string): void;
118
118
  isEnabled(): boolean;
119
119
  isInFlight(cellId: string): boolean;
120
+ /** True while any FLIP / retained-cell transition is still running. */
121
+ hasInFlight(): boolean;
120
122
  getDuration(): number;
121
123
  getEasing(): string;
122
124
  /**
@@ -53,6 +53,8 @@ export interface SimpleTableConfig {
53
53
  /** @see SimpleTableProps.showRowSelectionColumn */
54
54
  showRowSelectionColumn?: boolean;
55
55
  enableStickyParents?: boolean;
56
+ /** @see SimpleTableProps.enableVirtualization */
57
+ enableVirtualization?: boolean;
56
58
  errorStateRenderer?: VanillaErrorStateRenderer;
57
59
  expandAll?: boolean;
58
60
  externalFilterHandling?: boolean;
@@ -57,6 +57,13 @@ export interface SimpleTableProps {
57
57
  */
58
58
  showRowSelectionColumn?: boolean;
59
59
  enableStickyParents?: boolean;
60
+ /**
61
+ * When false, disables both row and column virtualization so every row and
62
+ * column is rendered in the DOM. Useful for print, a11y tooling, or small
63
+ * datasets that still need a fixed `height` / `maxHeight` for layout.
64
+ * Default true.
65
+ */
66
+ enableVirtualization?: boolean;
60
67
  errorStateRenderer?: ErrorStateRenderer;
61
68
  expandAll?: boolean;
62
69
  externalFilterHandling?: boolean;
@@ -108,6 +108,11 @@ export interface CellRenderContext {
108
108
  * here makes every column count as visible, disabling virtualization.
109
109
  */
110
110
  mainSectionViewportWidth?: number;
111
+ /**
112
+ * When false, skip column virtualization and render every body cell in the
113
+ * main section. Default true. Mirrors {@link SimpleTableProps.enableVirtualization}.
114
+ */
115
+ enableVirtualization?: boolean;
111
116
  onCellEdit?: (params: CellEditParams) => void;
112
117
  onCellClick?: (params: CellClickParams) => void;
113
118
  onRowGroupExpand?: (props: OnRowGroupExpandProps) => void | Promise<void>;
@@ -60,6 +60,8 @@ export interface HeaderRenderContext {
60
60
  mainBodyRef: RefObject<HTMLDivElement>;
61
61
  mainSectionContainerWidth?: number; /** Main section *content* width (sum of all non-pinned column widths). NOT the virtualization viewport. */
62
62
  mainSectionViewportWidth?: number; /** Main section *visible* viewport width (container minus pinned); use for getVisibleCells when !pinned */
63
+ /** When false, skip column virtualization and render every header cell in the main section. Default true. */
64
+ enableVirtualization?: boolean;
63
65
  onColumnOrderChange?: (headers: HeaderObject[]) => void;
64
66
  onColumnSelect?: (header: HeaderObject) => void;
65
67
  onColumnWidthChange?: (headers: HeaderObject[]) => void;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Shared prop-sync helpers for framework adapters.
3
+ * Used to skip no-op `defaultHeaders` / `rows` updates when consumers rebuild
4
+ * column configs or shallow-clone rows every render.
5
+ */
6
+ /** Minimal header shape for structural comparison (renderers ignored). */
7
+ export type HeaderStructureLike = {
8
+ accessor: string | number | symbol;
9
+ width?: number | string;
10
+ minWidth?: number | string;
11
+ maxWidth?: number | string;
12
+ label?: string;
13
+ type?: string;
14
+ pinned?: string | boolean | null;
15
+ hide?: boolean;
16
+ isSortable?: boolean;
17
+ filterable?: boolean;
18
+ align?: string;
19
+ collapsible?: boolean;
20
+ collapseDefault?: boolean;
21
+ showWhen?: string;
22
+ isEditable?: boolean;
23
+ isEssential?: boolean;
24
+ disableReorder?: boolean;
25
+ expandable?: boolean;
26
+ excludeFromRender?: boolean;
27
+ autoSizeMode?: string;
28
+ tooltip?: string;
29
+ quickFilterable?: boolean;
30
+ filterOperators?: ReadonlyArray<string>;
31
+ children?: ReadonlyArray<HeaderStructureLike>;
32
+ };
33
+ /**
34
+ * True when two header trees describe the same columns (accessors, widths,
35
+ * flags, nesting). Ignores renderer identity.
36
+ */
37
+ export declare function headersStructurallyEqual(a: ReadonlyArray<HeaderStructureLike> | undefined, b: ReadonlyArray<HeaderStructureLike> | undefined): boolean;
38
+ /** Collect every accessor in a header tree (for renderer-cache pruning). */
39
+ export declare function collectHeaderAccessors(headers: ReadonlyArray<HeaderStructureLike>, into?: Set<string>): Set<string>;
40
+ /**
41
+ * Shallow equality of a single row object (own enumerable keys, `===` values).
42
+ * Identical references are equal. In-place mutation on a shared object is
43
+ * invisible — callers must pass new object identities when data changes.
44
+ */
45
+ export declare function shallowEqualRow(a: object, b: object): boolean;
46
+ export type GetRowIdLike = (params: {
47
+ row: unknown;
48
+ depth?: number;
49
+ index?: number;
50
+ rowPath?: (string | number)[];
51
+ rowIndexPath?: number[];
52
+ groupingKey?: string;
53
+ }) => string | number | undefined;
54
+ /**
55
+ * Above this length, skip per-field shallow compares when row object identity
56
+ * differs. Same-array-ref and same-row-object cases stay O(1) / O(n) pointer
57
+ * checks. Protects huge client datasets from O(n × fields) scans.
58
+ */
59
+ export declare const SHALLOW_ROW_COMPARE_MAX = 50000;
60
+ /**
61
+ * True when `next` is a no-op relative to `prev` for table sync:
62
+ * same length, matching `getRowId` sequence (when provided), and each row
63
+ * either the same object or shallow-equal (for modest list sizes).
64
+ */
65
+ export declare function rowsShallowUnchanged(prev: ReadonlyArray<object> | undefined, next: ReadonlyArray<object> | undefined, getRowId?: GetRowIdLike): boolean;
@@ -55,6 +55,13 @@ export declare const calculateNestedTableHeight: ({ calculatedHeight, customHeig
55
55
  * getNestedValue(row, "releaseDate[0]") returns row.releaseDate[0]
56
56
  */
57
57
  export declare const getNestedValue: (obj: Row, path: Accessor) => CellValue;
58
+ /**
59
+ * True when both arrays have the same length and the same row object references
60
+ * at each index. Used by FilterManager / SortManager so in-place live updates
61
+ * that recompute filter/sort only notify subscribers when membership or order
62
+ * actually changed (`.filter()` / `handleSort` always allocate new arrays).
63
+ */
64
+ export declare const rowsOrderEqual: (a: Row[], b: Row[]) => boolean;
58
65
  /**
59
66
  * Set a nested property value in an object using dot notation and array bracket notation
60
67
  * Examples:
@@ -27,7 +27,16 @@ interface PortalEntry {
27
27
  * tagged with {@link PORTAL_ID_ATTR} inside that host, so React unmounts exactly
28
28
  * those subtrees. Reuse/reparent paths never signal, so a reused node keeps its
29
29
  * portal entry (and its content) with zero churn.
30
+ *
31
+ * {@link cellRendererCache} / {@link headerRendererCache} keep one wrapped
32
+ * renderer per accessor so unstable column rebuilds (new Component identity,
33
+ * same accessor) reuse the portal host instead of remounting React state.
30
34
  */
35
+ /** Mutable slot so wrapped renderers keep a stable closure across rebuilds. */
36
+ export type CachedRendererSlot<T = unknown> = {
37
+ component: T;
38
+ wrapped: unknown;
39
+ };
31
40
  export declare class PortalBridge {
32
41
  private entries;
33
42
  private listeners;
@@ -35,6 +44,10 @@ export declare class PortalBridge {
35
44
  private cachedSnapshot;
36
45
  private snapshotDirty;
37
46
  private emitScheduled;
47
+ /** Per-accessor cached cellRenderer wrappers (stable across rebuildHeaders). */
48
+ readonly cellRendererCache: Map<string, CachedRendererSlot<unknown>>;
49
+ /** Per-accessor cached headerRenderer wrappers. */
50
+ readonly headerRendererCache: Map<string, CachedRendererSlot<unknown>>;
38
51
  /**
39
52
  * Register a React node to be rendered into `container`. The container is
40
53
  * returned to core synchronously (matching the vanilla renderer contract); the
@@ -65,6 +78,11 @@ export declare class PortalBridge {
65
78
  disposeHost: (host: HTMLElement) => void;
66
79
  /** Remove all entries (used on table teardown). */
67
80
  clear(): void;
81
+ /**
82
+ * Drop cached wrappers for accessors no longer present in the header tree
83
+ * so remounted columns with the same accessor don't reuse a stale Component box.
84
+ */
85
+ pruneRendererCaches(liveAccessors: ReadonlySet<string>): void;
68
86
  subscribe: (listener: () => void) => (() => void);
69
87
  getSnapshot: () => PortalEntry[];
70
88
  private emit;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Re-export shared prop-sync helpers from core so React tests/imports that
3
+ * target this path keep working. Source of truth: simple-table-core.
4
+ */
5
+ export { headersStructurallyEqual, collectHeaderAccessors, rowsShallowUnchanged, shallowEqualRow, SHALLOW_ROW_COMPARE_MAX, } from "simple-table-core";
6
+ export type { HeaderStructureLike, GetRowIdLike } from "simple-table-core";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Re-export shared row-sync helpers from core.
3
+ * Source of truth: simple-table-core `propSyncEqual`.
4
+ */
5
+ export { rowsShallowUnchanged, shallowEqualRow, SHALLOW_ROW_COMPARE_MAX, } from "simple-table-core";
6
+ export type { GetRowIdLike } from "simple-table-core";
@@ -39,6 +39,18 @@ export declare function wrapReactRendererIntoFragment<P extends object>(bridge:
39
39
  * the React subtree and wiping local state.
40
40
  */
41
41
  export declare function wrapReactHeaderRenderer(bridge: PortalBridge, Component: React.ComponentType<VanillaHeaderRendererProps>): (props: VanillaHeaderRendererProps) => HTMLElement;
42
+ /**
43
+ * Like {@link wrapReactRendererIntoFragment}, but reuses one wrapper per
44
+ * `accessor` on the bridge. When the consumer rebuilds columns with a new
45
+ * Component identity, the slot's `component` is updated in place so the
46
+ * wrapped function identity stays stable across `defaultHeaders` rebuilds.
47
+ */
48
+ export declare function wrapCachedCellRenderer<P extends object>(bridge: PortalBridge, accessor: string, Component: React.ComponentType<P>): (props: P) => HTMLElement;
49
+ /**
50
+ * Like {@link wrapReactHeaderRenderer}, but reuses one host-bearing wrapper per
51
+ * `accessor` so unstable column rebuilds do not remount header React state.
52
+ */
53
+ export declare function wrapCachedHeaderRenderer(bridge: PortalBridge, accessor: string, Component: React.ComponentType<VanillaHeaderRendererProps>): (props: VanillaHeaderRendererProps) => HTMLElement;
42
54
  /**
43
55
  * Like {@link wrapReactHeaderRenderer} for the header dropdown, which shares the
44
56
  * same `components` slot shape.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-table/react",
3
- "version": "3.9.7",
3
+ "version": "3.9.9",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/types/react/src/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "react-dom": ">=18.0.0"
30
30
  },
31
31
  "dependencies": {
32
- "simple-table-core": "3.9.7"
32
+ "simple-table-core": "3.9.9"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@rollup/plugin-alias": "^4.0.4",