@simple-table/react 3.7.7 → 3.8.1

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"),s=require("react-dom");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(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 s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}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 d(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 l(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 f(t,n){return r=>{const s=document.createElement("div");return t.register(e.jsx(n,Object.assign({},r)),s),s}}function h(t,n){return r=>{const s=document.createElement("div"),o=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({},o)),s),s}}function p(t,n){return r=>{const s=document.createElement("div"),o=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({},o)),s),s}}function m(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 g(t){return r.renderToStaticMarkup(e.jsx(e.Fragment,{children:t}))}function b(e){return"function"==typeof e}function j(t,n){const{cellRenderer:r,headerRenderer:s,children:o,nestedTable:i}=t,u=c(t,["cellRenderer","headerRenderer","children","nestedTable"]),a=Object.assign({},u);if(r&&(a.cellRenderer=function(t,n){return r=>{const s=document.createElement("div");return s.style.display="contents",t.register(e.jsx(n,Object.assign({},r)),s),s}}(n,r)),s&&(a.headerRenderer=function(t,n){return r=>{const s=document.createElement("div"),o=Object.assign(Object.assign({},r),{components:d(r.components)});return t.register(e.jsx(n,Object.assign({},o)),s),s}}(n,s)),o&&(a.children=o.map(e=>j(e,n))),i){const e=Object.assign(Object.assign({},i),{rows:[]});a.nestedTable=S(e,n)}return a}function S(t,n){const{defaultHeaders:r,rows:s,footerRenderer:o,emptyStateRenderer:i,errorStateRenderer:u,loadingStateRenderer:a,tableEmptyStateRenderer:S,headerDropdown:y,columnEditorConfig:O,icons:v,onColumnOrderChange:R,onColumnWidthChange:x,onHeaderEdit:E,onColumnSelect:C}=t,I=c(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]),w=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},I),{rows:s,defaultHeaders:r.map(e=>j(e,n))}),R?{onColumnOrderChange:e=>R(e)}:{}),x?{onColumnWidthChange:e=>x(e)}:{}),E?{onHeaderEdit:(e,t)=>E(e,t)}:{}),C?{onColumnSelect:e=>C(e)}:{});if(void 0!==o&&(w.footerRenderer=function(t,n){return r=>{const s=document.createElement("div"),o=Object.assign(Object.assign({},r),{nextIcon:l((i={nextIcon:r.nextIcon,prevIcon:r.prevIcon}).nextIcon),prevIcon:l(i.prevIcon)});var i;return t.register(e.jsx(n,Object.assign({},o)),s),s}}(n,o)),void 0!==i)if(b(i))w.emptyStateRenderer=f(n,i);else{const e=i;w.emptyStateRenderer=()=>m(e)}if(void 0!==u)if(b(u))w.errorStateRenderer=f(n,u);else{const e=u;w.errorStateRenderer=()=>m(e)}if(void 0!==a)if(b(a))w.loadingStateRenderer=f(n,a);else{const e=a;w.loadingStateRenderer=()=>m(e)}return void 0!==S&&(w.tableEmptyStateRenderer=null===S?null:m(S)),void 0!==y&&(w.headerDropdown=function(t,n){return r=>{const s=document.createElement("div"),o=Object.assign(Object.assign({},r),{components:d(r.components)});return t.register(e.jsx(n,Object.assign({},o)),s),s}}(n,y)),void 0!==O&&(w.columnEditorConfig=function(e,t){const{rowRenderer:n,customRenderer:r}=e,s=c(e,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},s),n?{rowRenderer:h(t,n)}:{}),r?{customRenderer:p(t,r)}:{})}(O,n)),void 0!==v&&(w.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:g(r));return t}(v)),w}"function"==typeof SuppressedError&&SuppressedError;class y{constructor(){this.entries=new Map,this.listeners=new Set,this.nextId=0,this.cachedSnapshot=[],this.snapshotDirty=!0,this.emitScheduled=!1,this.pruneScheduled=!1,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 this.entries.set(n,{id:n,container:t,node:e}),this.scheduleEmit(),{id:n,unregister:()=>this.unregister(n)}}unregister(e){this.entries.delete(e)&&this.scheduleEmit()}attach(e){const t=new MutationObserver(()=>this.schedulePrune());return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}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()}))}schedulePrune(){this.pruneScheduled||(this.pruneScheduled=!0,queueMicrotask(()=>{this.pruneScheduled=!1;let e=!1;for(const[t,n]of this.entries)n.container.isConnected||(this.entries.delete(t),e=!0);e&&this.emit()}))}}class O 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 v=i.default.forwardRef(function(r,o){const i=t.useRef(null),u=t.useRef(null);null===u.current&&(u.current=new y);const a=u.current,d=t.useRef(null),l=t.useRef(void 0),f=t.useRef(null),h=r;t.useLayoutEffect(()=>{const e=i.current;if(!e)return;const t=new n.SimpleTableVanilla(e,S(h,a));t.mount(),d.current=t,f.current=h,l.current=h.defaultHeaders;const r=a.attach(e);if(o){const e=t.getAPI();"function"==typeof o?o(e):o.current=e}return()=>{r(),t.destroy(),d.current=null,l.current=void 0,f.current=null,a.clear(),o&&"function"!=typeof o&&(o.current=null)}},[]),t.useLayoutEffect(()=>{const e=d.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=S(h,a);if(l.current!==h.defaultHeaders)return l.current=h.defaultHeaders,void e.update(t);const n=c(t,["defaultHeaders"]);e.update(n)},[h]);const p=function(n){return t.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot).map(t=>s.createPortal(e.jsx(O,{children:t.node}),t.container,t.id))}(a);return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:i}),p]})});v.displayName="SimpleTable",Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return n.asRows}}),exports.SimpleTable=v;
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"),s=require("react-dom");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(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 s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]])}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 d(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 l(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 f(t,n){return r=>{const s=document.createElement("div");return t.register(e.jsx(n,Object.assign({},r)),s),s}}function h(t,n){return r=>{const s=document.createElement("div"),o=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({},o)),s),s}}function p(t,n){return r=>{const s=document.createElement("div"),o=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({},o)),s),s}}function m(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 g(t){return r.renderToStaticMarkup(e.jsx(e.Fragment,{children:t}))}function b(e){return"function"==typeof e}function S(t,n){const{cellRenderer:r,headerRenderer:s,children:o,nestedTable:i}=t,u=c(t,["cellRenderer","headerRenderer","children","nestedTable"]),a=Object.assign({},u);if(r&&(a.cellRenderer=function(t,n){return r=>{const s=document.createElement("div");return s.style.display="contents",t.register(e.jsx(n,Object.assign({},r)),s),s}}(n,r)),s&&(a.headerRenderer=function(t,n){return r=>{const s=document.createElement("div"),o=Object.assign(Object.assign({},r),{components:d(r.components)});return t.register(e.jsx(n,Object.assign({},o)),s),s}}(n,s)),o&&(a.children=o.map(e=>S(e,n))),i){const e=Object.assign(Object.assign({},i),{rows:[]});a.nestedTable=j(e,n)}return a}function j(t,n){const{defaultHeaders:r,rows:s,footerRenderer:o,emptyStateRenderer:i,errorStateRenderer:u,loadingStateRenderer:a,tableEmptyStateRenderer:j,headerDropdown:y,columnEditorConfig:O,icons:v,onColumnOrderChange:R,onColumnWidthChange:E,onHeaderEdit:x,onColumnSelect:C}=t,I=c(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]),w=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},I),{rows:s,defaultHeaders:r.map(e=>S(e,n))}),R?{onColumnOrderChange:e=>R(e)}:{}),E?{onColumnWidthChange:e=>E(e)}:{}),x?{onHeaderEdit:(e,t)=>x(e,t)}:{}),C?{onColumnSelect:e=>C(e)}:{});if(void 0!==o&&(w.footerRenderer=function(t,n){return r=>{const s=document.createElement("div"),o=Object.assign(Object.assign({},r),{nextIcon:l((i={nextIcon:r.nextIcon,prevIcon:r.prevIcon}).nextIcon),prevIcon:l(i.prevIcon)});var i;return t.register(e.jsx(n,Object.assign({},o)),s),s}}(n,o)),void 0!==i)if(b(i))w.emptyStateRenderer=f(n,i);else{const e=i;w.emptyStateRenderer=()=>m(e)}if(void 0!==u)if(b(u))w.errorStateRenderer=f(n,u);else{const e=u;w.errorStateRenderer=()=>m(e)}if(void 0!==a)if(b(a))w.loadingStateRenderer=f(n,a);else{const e=a;w.loadingStateRenderer=()=>m(e)}return void 0!==j&&(w.tableEmptyStateRenderer=null===j?null:m(j)),void 0!==y&&(w.headerDropdown=function(t,n){return r=>{const s=document.createElement("div"),o=Object.assign(Object.assign({},r),{components:d(r.components)});return t.register(e.jsx(n,Object.assign({},o)),s),s}}(n,y)),void 0!==O&&(w.columnEditorConfig=function(e,t){const{rowRenderer:n,customRenderer:r}=e,s=c(e,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},s),n?{rowRenderer:h(t,n)}:{}),r?{customRenderer:p(t,r)}:{})}(O,n)),void 0!==v&&(w.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:g(r));return t}(v)),w}"function"==typeof SuppressedError&&SuppressedError;class y{constructor(){this.entries=new Map,this.listeners=new Set,this.nextId=0,this.cachedSnapshot=[],this.snapshotDirty=!0,this.emitScheduled=!1,this.pruneScheduled=!1,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 this.entries.set(n,{id:n,container:t,node:e}),this.scheduleEmit(),{id:n,unregister:()=>this.unregister(n)}}unregister(e){this.entries.delete(e)&&this.scheduleEmit()}attach(e){const t=new MutationObserver(()=>this.schedulePrune());return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}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()}))}schedulePrune(){this.pruneScheduled||(this.pruneScheduled=!0,queueMicrotask(()=>{this.pruneScheduled=!1;let e=!1;for(const[t,n]of this.entries)n.container.isConnected||(this.entries.delete(t),e=!0);e&&this.emit()}))}}class O 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 v=i.default.forwardRef(function(r,o){const i=t.useRef(null),u=t.useRef(null);null===u.current&&(u.current=new y);const a=u.current,d=t.useRef(null),l=t.useRef(void 0),f=t.useRef(null),h=r;t.useLayoutEffect(()=>{const e=i.current;if(!e)return;const t=new n.SimpleTableVanilla(e,j(h,a));t.mount(),d.current=t,f.current=h,l.current=h.defaultHeaders;const r=a.attach(e);if(o){const e=t.getAPI();"function"==typeof o?o(e):o.current=e}return()=>{r(),t.destroy(),d.current=null,l.current=void 0,f.current=null,a.clear(),o&&"function"!=typeof o&&(o.current=null)}},[]),t.useLayoutEffect(()=>{const e=d.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=j(h,a);if(l.current!==h.defaultHeaders)return l.current=h.defaultHeaders,void e.update(t);const n=c(t,["defaultHeaders"]);e.update(n)},[h]);const p=function(n){return t.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot).map(t=>s.createPortal(e.jsx(O,{children:t.node}),t.container,t.id))}(a),m=t.useRef(!1);return t.useLayoutEffect(()=>{var e;if(m.current)return;const t=d.current;t&&Array.isArray(p)&&p.length>0&&(m.current=!0,null===(e=t.refitAutoSizeColumns)||void 0===e||e.call(t))},[p]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:i}),p]})});v.displayName="SimpleTable",Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return n.asRows}}),exports.SimpleTable=v;
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 d}from"react-dom/server";import{createPortal as u}from"react-dom";function l(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: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 h(t){if(null!=t)return"string"==typeof t?t:t instanceof Node?e(a,{node:t}):void 0}function f(e){return{sortIcon:h(null==e?void 0:e.sortIcon),filterIcon:h(null==e?void 0:e.filterIcon),collapseIcon:h(null==e?void 0:e.collapseIcon),labelContent:h(null==e?void 0:e.labelContent)}}function m(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(a,{node:t}):void 0}}function p(t,n){return r=>{const o=document.createElement("div");return t.register(e(n,Object.assign({},r)),o),o}}function g(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:(i=r.components,{expandIcon:h(i.expandIcon),checkbox:h(i.checkbox),dragIcon:h(i.dragIcon),labelContent:h(i.labelContent),pinIcon:h(i.pinIcon)})});var i;return t.register(e(n,Object.assign({},s)),o),o}}function b(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{searchSection:r.searchSection?h(r.searchSection):null,listSection:h(r.listSection),resetSection:r.resetSection?h(r.resetSection):null});return t.register(e(n,Object.assign({},s)),o),o}}function S(n){const r=document.createElement("div");return r.innerHTML=d(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 O(n){return d(e(t,{children:n}))}function v(e){return"function"==typeof e}function y(t,n){const{cellRenderer:r,headerRenderer:o,children:s,nestedTable:i}=t,c=l(t,["cellRenderer","headerRenderer","children","nestedTable"]),d=Object.assign({},c);if(r&&(d.cellRenderer=function(t,n){return r=>{const o=document.createElement("div");return o.style.display="contents",t.register(e(n,Object.assign({},r)),o),o}}(n,r)),o&&(d.headerRenderer=function(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:f(r.components)});return t.register(e(n,Object.assign({},s)),o),o}}(n,o)),s&&(d.children=s.map(e=>y(e,n))),i){const e=Object.assign(Object.assign({},i),{rows:[]});d.nestedTable=j(e,n)}return d}function j(t,n){const{defaultHeaders:r,rows:o,footerRenderer:s,emptyStateRenderer:i,errorStateRenderer:c,loadingStateRenderer:d,tableEmptyStateRenderer:u,headerDropdown:a,columnEditorConfig:h,icons:j,onColumnOrderChange:E,onColumnWidthChange:R,onHeaderEdit:C,onColumnSelect:I}=t,w=l(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]),x=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w),{rows:o,defaultHeaders:r.map(e=>y(e,n))}),E?{onColumnOrderChange:e=>E(e)}:{}),R?{onColumnWidthChange:e=>R(e)}:{}),C?{onHeaderEdit:(e,t)=>C(e,t)}:{}),I?{onColumnSelect:e=>I(e)}:{});if(void 0!==s&&(x.footerRenderer=function(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{nextIcon:m((i={nextIcon:r.nextIcon,prevIcon:r.prevIcon}).nextIcon),prevIcon:m(i.prevIcon)});var i;return t.register(e(n,Object.assign({},s)),o),o}}(n,s)),void 0!==i)if(v(i))x.emptyStateRenderer=p(n,i);else{const e=i;x.emptyStateRenderer=()=>S(e)}if(void 0!==c)if(v(c))x.errorStateRenderer=p(n,c);else{const e=c;x.errorStateRenderer=()=>S(e)}if(void 0!==d)if(v(d))x.loadingStateRenderer=p(n,d);else{const e=d;x.loadingStateRenderer=()=>S(e)}return void 0!==u&&(x.tableEmptyStateRenderer=null===u?null:S(u)),void 0!==a&&(x.headerDropdown=function(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:f(r.components)});return t.register(e(n,Object.assign({},s)),o),o}}(n,a)),void 0!==h&&(x.columnEditorConfig=function(e,t){const{rowRenderer:n,customRenderer:r}=e,o=l(e,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},o),n?{rowRenderer:g(t,n)}:{}),r?{customRenderer:b(t,r)}:{})}(h,n)),void 0!==j&&(x.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:O(r));return t}(j)),x}"function"==typeof SuppressedError&&SuppressedError;class E{constructor(){this.entries=new Map,this.listeners=new Set,this.nextId=0,this.cachedSnapshot=[],this.snapshotDirty=!0,this.emitScheduled=!1,this.pruneScheduled=!1,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 this.entries.set(n,{id:n,container:t,node:e}),this.scheduleEmit(),{id:n,unregister:()=>this.unregister(n)}}unregister(e){this.entries.delete(e)&&this.scheduleEmit()}attach(e){const t=new MutationObserver(()=>this.schedulePrune());return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}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()}))}schedulePrune(){this.pruneScheduled||(this.pruneScheduled=!0,queueMicrotask(()=>{this.pruneScheduled=!1;let e=!1;for(const[t,n]of this.entries)n.container.isConnected||(this.entries.delete(t),e=!0);e&&this.emit()}))}}class R 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 C=r.forwardRef(function(r,d){const a=o(null),h=o(null);null===h.current&&(h.current=new E);const f=h.current,m=o(null),p=o(void 0),g=o(null),b=r;s(()=>{const e=a.current;if(!e)return;const t=new c(e,j(b,f));t.mount(),m.current=t,g.current=b,p.current=b.defaultHeaders;const n=f.attach(e);if(d){const e=t.getAPI();"function"==typeof d?d(e):d.current=e}return()=>{n(),t.destroy(),m.current=null,p.current=void 0,g.current=null,f.clear(),d&&"function"!=typeof d&&(d.current=null)}},[]),s(()=>{const e=m.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=j(b,f);if(p.current!==b.defaultHeaders)return p.current=b.defaultHeaders,void e.update(t);const n=l(t,["defaultHeaders"]);e.update(n)},[b]);const S=function(t){return i(t.subscribe,t.getSnapshot,t.getSnapshot).map(t=>u(e(R,{children:t.node}),t.container,t.id))}(f);return n(t,{children:[e("div",{ref:a}),S]})});C.displayName="SimpleTable";export{C 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 i}from"react";import{SimpleTableVanilla as c}from"simple-table-core";export{asRows}from"simple-table-core";import{renderToStaticMarkup as d}from"react-dom/server";import{createPortal as u}from"react-dom";function l(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: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 h(t){if(null!=t)return"string"==typeof t?t:t instanceof Node?e(a,{node:t}):void 0}function f(e){return{sortIcon:h(null==e?void 0:e.sortIcon),filterIcon:h(null==e?void 0:e.filterIcon),collapseIcon:h(null==e?void 0:e.collapseIcon),labelContent:h(null==e?void 0:e.labelContent)}}function m(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(a,{node:t}):void 0}}function p(t,n){return r=>{const o=document.createElement("div");return t.register(e(n,Object.assign({},r)),o),o}}function g(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:(i=r.components,{expandIcon:h(i.expandIcon),checkbox:h(i.checkbox),dragIcon:h(i.dragIcon),labelContent:h(i.labelContent),pinIcon:h(i.pinIcon)})});var i;return t.register(e(n,Object.assign({},s)),o),o}}function b(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{searchSection:r.searchSection?h(r.searchSection):null,listSection:h(r.listSection),resetSection:r.resetSection?h(r.resetSection):null});return t.register(e(n,Object.assign({},s)),o),o}}function S(n){const r=document.createElement("div");return r.innerHTML=d(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 O(n){return d(e(t,{children:n}))}function v(e){return"function"==typeof e}function y(t,n){const{cellRenderer:r,headerRenderer:o,children:s,nestedTable:i}=t,c=l(t,["cellRenderer","headerRenderer","children","nestedTable"]),d=Object.assign({},c);if(r&&(d.cellRenderer=function(t,n){return r=>{const o=document.createElement("div");return o.style.display="contents",t.register(e(n,Object.assign({},r)),o),o}}(n,r)),o&&(d.headerRenderer=function(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:f(r.components)});return t.register(e(n,Object.assign({},s)),o),o}}(n,o)),s&&(d.children=s.map(e=>y(e,n))),i){const e=Object.assign(Object.assign({},i),{rows:[]});d.nestedTable=j(e,n)}return d}function j(t,n){const{defaultHeaders:r,rows:o,footerRenderer:s,emptyStateRenderer:i,errorStateRenderer:c,loadingStateRenderer:d,tableEmptyStateRenderer:u,headerDropdown:a,columnEditorConfig:h,icons:j,onColumnOrderChange:E,onColumnWidthChange:R,onHeaderEdit:C,onColumnSelect:I}=t,w=l(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]),x=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},w),{rows:o,defaultHeaders:r.map(e=>y(e,n))}),E?{onColumnOrderChange:e=>E(e)}:{}),R?{onColumnWidthChange:e=>R(e)}:{}),C?{onHeaderEdit:(e,t)=>C(e,t)}:{}),I?{onColumnSelect:e=>I(e)}:{});if(void 0!==s&&(x.footerRenderer=function(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{nextIcon:m((i={nextIcon:r.nextIcon,prevIcon:r.prevIcon}).nextIcon),prevIcon:m(i.prevIcon)});var i;return t.register(e(n,Object.assign({},s)),o),o}}(n,s)),void 0!==i)if(v(i))x.emptyStateRenderer=p(n,i);else{const e=i;x.emptyStateRenderer=()=>S(e)}if(void 0!==c)if(v(c))x.errorStateRenderer=p(n,c);else{const e=c;x.errorStateRenderer=()=>S(e)}if(void 0!==d)if(v(d))x.loadingStateRenderer=p(n,d);else{const e=d;x.loadingStateRenderer=()=>S(e)}return void 0!==u&&(x.tableEmptyStateRenderer=null===u?null:S(u)),void 0!==a&&(x.headerDropdown=function(t,n){return r=>{const o=document.createElement("div"),s=Object.assign(Object.assign({},r),{components:f(r.components)});return t.register(e(n,Object.assign({},s)),o),o}}(n,a)),void 0!==h&&(x.columnEditorConfig=function(e,t){const{rowRenderer:n,customRenderer:r}=e,o=l(e,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},o),n?{rowRenderer:g(t,n)}:{}),r?{customRenderer:b(t,r)}:{})}(h,n)),void 0!==j&&(x.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:O(r));return t}(j)),x}"function"==typeof SuppressedError&&SuppressedError;class E{constructor(){this.entries=new Map,this.listeners=new Set,this.nextId=0,this.cachedSnapshot=[],this.snapshotDirty=!0,this.emitScheduled=!1,this.pruneScheduled=!1,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 this.entries.set(n,{id:n,container:t,node:e}),this.scheduleEmit(),{id:n,unregister:()=>this.unregister(n)}}unregister(e){this.entries.delete(e)&&this.scheduleEmit()}attach(e){const t=new MutationObserver(()=>this.schedulePrune());return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}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()}))}schedulePrune(){this.pruneScheduled||(this.pruneScheduled=!0,queueMicrotask(()=>{this.pruneScheduled=!1;let e=!1;for(const[t,n]of this.entries)n.container.isConnected||(this.entries.delete(t),e=!0);e&&this.emit()}))}}class R 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 C=r.forwardRef(function(r,d){const a=o(null),h=o(null);null===h.current&&(h.current=new E);const f=h.current,m=o(null),p=o(void 0),g=o(null),b=r;s(()=>{const e=a.current;if(!e)return;const t=new c(e,j(b,f));t.mount(),m.current=t,g.current=b,p.current=b.defaultHeaders;const n=f.attach(e);if(d){const e=t.getAPI();"function"==typeof d?d(e):d.current=e}return()=>{n(),t.destroy(),m.current=null,p.current=void 0,g.current=null,f.clear(),d&&"function"!=typeof d&&(d.current=null)}},[]),s(()=>{const e=m.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=j(b,f);if(p.current!==b.defaultHeaders)return p.current=b.defaultHeaders,void e.update(t);const n=l(t,["defaultHeaders"]);e.update(n)},[b]);const S=function(t){return i(t.subscribe,t.getSnapshot,t.getSnapshot).map(t=>u(e(R,{children:t.node}),t.container,t.id))}(f),O=o(!1);return s(()=>{var e;if(O.current)return;const t=m.current;t&&Array.isArray(S)&&S.length>0&&(O.current=!0,null===(e=t.refitAutoSizeColumns)||void 0===e||e.call(t))},[S]),n(t,{children:[e("div",{ref:a}),S]})});C.displayName="SimpleTable";export{C as SimpleTable};
2
2
  //# sourceMappingURL=index.es.js.map
@@ -11,3 +11,10 @@ export declare const TABLE_HEADER_CELL_WIDTH_DEFAULT = 150;
11
11
  export declare const PINNED_BORDER_WIDTH = 1;
12
12
  export declare const CHART_COLUMN_TYPES: string[];
13
13
  export declare const OPTIMAL_CHART_COLUMN_WIDTH = 150;
14
+ export declare const AUTO_SIZE_HEAD_SAMPLE_SIZE = 25;
15
+ export declare const AUTO_SIZE_STRIDED_SAMPLE_SIZE = 75;
16
+ export declare const AUTO_SIZE_MAX_WIDTH = 500;
17
+ export declare const AUTO_SIZE_OUTLIER_PERCENTILE = 95;
18
+ export declare const AUTO_SIZE_OUTLIER_THRESHOLD = 0.5;
19
+ export declare const AUTO_SIZE_MIN_SAMPLE_FOR_CLIP = 20;
20
+ export declare const AUTO_SIZE_WIDTH_BUFFER = 2;
@@ -14,6 +14,12 @@ export declare class SimpleTableVanilla {
14
14
  private localRows;
15
15
  private headers;
16
16
  private essentialAccessors;
17
+ /** Accessors of leaf columns that should size to content (width:"auto" or autoSizeColumns). */
18
+ private autoSizeAccessors;
19
+ /** Accessors awaiting a content-fit measurement on the next render. */
20
+ private pendingAutoSize;
21
+ /** Guard against re-entrancy while the auto-size pass re-renders. */
22
+ private isAutoSizing;
17
23
  private currentPage;
18
24
  private scrollTop;
19
25
  private scrollDirection;
@@ -215,6 +221,34 @@ export declare class SimpleTableVanilla {
215
221
  private updateAriaLiveRegion;
216
222
  private getRenderContext;
217
223
  private getRenderState;
224
+ /** A leaf column that should size to content (declared with width:"auto"). */
225
+ private isAutoSizeLeaf;
226
+ private computeAutoSizeAccessors;
227
+ private getAutoSizeStyleRoot;
228
+ /**
229
+ * Rows that content-fit ("auto") measurement should sample. With client-side
230
+ * pagination only the current page is rendered, so fit columns to the page's
231
+ * rows rather than the entire dataset — otherwise off-page values inflate
232
+ * every auto column's width.
233
+ */
234
+ private getAutoSizeRows;
235
+ /** Immutably write measured pixel widths into the leaf headers. */
236
+ private applyMeasuredWidths;
237
+ /**
238
+ * Measure and apply content-fit widths for any pending "auto" columns, then
239
+ * re-render once at the final widths. Called at the end of render(); the
240
+ * measurement reads the just-rendered (provisional-width) DOM and the
241
+ * corrective render happens in the same synchronous task, so there is no
242
+ * visible width snap.
243
+ */
244
+ private maybeAutoSizeColumns;
245
+ /**
246
+ * Re-run the content-fit measurement for all auto-size columns. Useful for
247
+ * host frameworks (e.g. React) whose custom renderers mount asynchronously:
248
+ * calling this from a layout effect (pre-paint) re-measures once the real
249
+ * renderer DOM is present, so the column fits accurately without flicker.
250
+ */
251
+ refitAutoSizeColumns(): void;
218
252
  private render;
219
253
  update(config: Partial<SimpleTableConfig>): void;
220
254
  /** @deprecated Use {@link update} — same behavior. */
@@ -1,4 +1,4 @@
1
- import HeaderObject from "../types/HeaderObject";
1
+ import HeaderObject, { Accessor } from "../types/HeaderObject";
2
2
  interface AutoScaleConfig {
3
3
  autoExpandColumns: boolean;
4
4
  containerWidth: number;
@@ -8,6 +8,13 @@ interface AutoScaleConfig {
8
8
  current: HTMLDivElement | null;
9
9
  };
10
10
  isResizing?: boolean;
11
+ /**
12
+ * Currently collapsed header accessors. Auto-scale must only account for the
13
+ * leaf columns that are actually visible for the current collapsed state —
14
+ * otherwise it sums the widths of hidden child columns and under-expands,
15
+ * leaving empty space on the right.
16
+ */
17
+ collapsedHeaders?: Set<Accessor>;
11
18
  }
12
19
  type HeaderUpdateCallback = (headers: HeaderObject[]) => void;
13
20
  export declare const applyAutoScaleToHeaders: (headers: HeaderObject[], options: AutoScaleConfig) => HeaderObject[];
@@ -10,6 +10,12 @@ import { QuickFilterGetter } from "./QuickFilterTypes";
10
10
  export type Accessor = keyof Row | string;
11
11
  export type ColumnType = "string" | "number" | "boolean" | "date" | "enum" | "lineAreaChart" | "barChart" | "other";
12
12
  export type ShowWhen = "parentCollapsed" | "parentExpanded" | "always";
13
+ /**
14
+ * Controls what an auto-sized column (`width: "auto"`) fits to:
15
+ * - "content" (default): fit the wider of the header and the sampled cell content
16
+ * - "header": fit the header label only (ignore cell content)
17
+ */
18
+ export type AutoSizeMode = "content" | "header";
13
19
  export interface ChartOptions {
14
20
  min?: number;
15
21
  max?: number;
@@ -57,6 +63,13 @@ type HeaderObject = {
57
63
  accessor: Accessor;
58
64
  aggregation?: AggregationConfig;
59
65
  align?: "left" | "center" | "right";
66
+ /**
67
+ * When `width` is the string `"auto"`, the column is sized to fit its content
68
+ * on load (and re-fit when row data changes). `autoSizeMode` controls whether
69
+ * it fits the header + cells (`"content"`, default) or the header label only
70
+ * (`"header"`). `minWidth` / `maxWidth` clamp the computed width.
71
+ */
72
+ autoSizeMode?: AutoSizeMode;
60
73
  cellRenderer?: CellRenderer;
61
74
  chartOptions?: ChartOptions;
62
75
  children?: HeaderObject[];
@@ -92,6 +105,10 @@ type HeaderObject = {
92
105
  valueFormatter?: ValueFormatter;
93
106
  valueGetter?: ValueGetter;
94
107
  showWhen?: ShowWhen;
108
+ /**
109
+ * Column width. A number or px/fr/% string sets a fixed/proportional width.
110
+ * The special value `"auto"` sizes the column to fit its content (see `autoSizeMode`).
111
+ */
95
112
  width: number | string;
96
113
  maxWidth?: number | string;
97
114
  };
@@ -1,6 +1,6 @@
1
1
  import type Row from "../../types/Row";
2
2
  import type TableRow from "../../types/TableRow";
3
- import { AbsoluteBodyCell, CellRenderContext } from "./types";
3
+ import { AbsoluteBodyCell, CellRegistryEntry, CellRenderContext } from "./types";
4
4
  export interface CellLiveRef {
5
5
  row: Row;
6
6
  tableRow: TableRow;
@@ -8,6 +8,7 @@ export interface CellLiveRef {
8
8
  }
9
9
  export declare const cellLiveRefMap: WeakMap<HTMLElement, CellLiveRef>;
10
10
  export declare const untrackCellByRow: (rowId: string, cellElement: HTMLElement) => void;
11
+ export declare const unregisterCellFromRegistry: (cellElement: HTMLElement, cellRegistry?: Map<string, CellRegistryEntry>) => void;
11
12
  export declare const createBodyCellElement: (cell: AbsoluteBodyCell, context: CellRenderContext) => HTMLElement;
12
13
  export declare const updateBodyCellPosition: (cellElement: HTMLElement, cell: AbsoluteBodyCell) => void;
13
14
  export declare const updateBodyCellElement: (cellElement: HTMLElement, cell: AbsoluteBodyCell, context: CellRenderContext) => void;
@@ -1,4 +1,29 @@
1
1
  import HeaderObject, { Accessor } from "../types/HeaderObject";
2
+ /**
3
+ * Build the set of row indices to sample for auto-size measurement.
4
+ * Hybrid strategy: the first `headSize` rows (always include the top / initial
5
+ * viewport) plus `stridedSize` rows spread at an even stride across the rest of
6
+ * the dataset, so wide values deeper in the data are caught without scanning
7
+ * every row. Strided (not random) keeps the result deterministic across renders.
8
+ */
9
+ export declare const buildHybridSampleIndices: (rowCount: number, headSize: number, stridedSize: number) => number[];
10
+ /** Linear-interpolated percentile (0-100) of a numeric array. */
11
+ export declare const percentileOf: (values: number[], percentile: number) => number;
12
+ /**
13
+ * Choose a representative "content width" from sampled cell widths, clipping
14
+ * outliers only when they clearly stand apart from the bulk of the data.
15
+ *
16
+ * - Uses the true max when the column is uniform (max close to the percentile),
17
+ * so nothing legitimate gets truncated.
18
+ * - Falls back to the percentile width only when `max > p * (1 + threshold)` and
19
+ * there are enough samples to trust the percentile, so a single rogue 2000px
20
+ * row can't define the whole column.
21
+ */
22
+ export declare const selectContentWidthWithOutlierClip: (widths: number[], options?: {
23
+ percentile?: number;
24
+ threshold?: number;
25
+ minSampleForClip?: number;
26
+ }) => number;
2
27
  /**
3
28
  * Find all leaf headers (headers without children) in a header tree
4
29
  * Takes collapsed state into account - when a header is collapsed, only returns
@@ -9,6 +34,8 @@ export declare const findLeafHeaders: (header: HeaderObject, collapsedHeaders?:
9
34
  export declare const DEFAULT_FR_PX = 150;
10
35
  /** Default total table width used when normalizing fr/% if container width unknown */
11
36
  export declare const DEFAULT_TABLE_WIDTH = 800;
37
+ /** True when a header's width requests content-based auto-sizing (`width: "auto"`). */
38
+ export declare const isAutoWidth: (header: HeaderObject) => boolean;
12
39
  /**
13
40
  * Normalize header widths so that fr and % are converted to pixels.
14
41
  * Call this as soon as headers are received so the rest of the code can assume numeric widths.
@@ -52,7 +79,20 @@ export declare const calculateHeaderContentWidth: (accessor: Accessor, options?:
52
79
  rows?: any[];
53
80
  header?: HeaderObject;
54
81
  maxWidth?: number;
82
+ /** Leading rows always measured (default AUTO_SIZE_HEAD_SAMPLE_SIZE) */
83
+ headSampleSize?: number;
84
+ /** Rows sampled at an even stride across the rest (default AUTO_SIZE_STRIDED_SAMPLE_SIZE) */
85
+ stridedSampleSize?: number;
86
+ /** Back-compat: when set, used as the head sample size (strided defaults to 0) */
55
87
  sampleSize?: number;
88
+ /** Outlier clip percentile (default AUTO_SIZE_OUTLIER_PERCENTILE) */
89
+ outlierPercentile?: number;
90
+ /** Outlier clip threshold fraction (default AUTO_SIZE_OUTLIER_THRESHOLD) */
91
+ outlierThreshold?: number;
92
+ /** When "header", ignore cell content and fit the header label only */
93
+ autoSizeMode?: "content" | "header";
94
+ /** Theme passed to a custom cellRenderer during measurement */
95
+ theme?: any;
56
96
  /** Scope `.st-cell-content` font/padding sampling to this table instance */
57
97
  styleRoot?: ParentNode | null;
58
98
  }) => number;
@@ -39,6 +39,8 @@ export interface TableInstance {
39
39
  update(config: Partial<SimpleTableConfig>): void;
40
40
  destroy(): void;
41
41
  getAPI(): TableAPI;
42
+ /** Re-measure auto-size columns (used after async React renderers mount). */
43
+ refitAutoSizeColumns?(): void;
42
44
  }
43
45
  export type ReactIconElement = React.ReactNode;
44
46
  export interface ReactIconsConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-table/react",
3
- "version": "3.7.7",
3
+ "version": "3.8.1",
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.7.7"
32
+ "simple-table-core": "3.8.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@rollup/plugin-alias": "^4.0.4",