@simple-table/react 3.8.3 → 3.8.5
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 +1 -1
- package/dist/index.es.js +1 -1
- package/dist/types/core/src/consts/general-consts.d.ts +1 -0
- package/dist/types/core/src/core/SimpleTableVanilla.d.ts +39 -0
- package/dist/types/core/src/core/api/TableAPIImpl.d.ts +9 -0
- package/dist/types/core/src/core/rendering/RenderOrchestrator.d.ts +3 -0
- package/dist/types/core/src/core/rendering/TableRenderer.d.ts +3 -0
- package/dist/types/core/src/index.d.ts +2 -2
- package/dist/types/core/src/managers/AnimationCoordinator.d.ts +37 -0
- package/dist/types/core/src/types/FilterTypes.d.ts +10 -1
- package/dist/types/core/src/types/HeaderObject.d.ts +14 -0
- package/dist/types/core/src/utils/bodyCell/cellLiveRef.d.ts +9 -0
- package/dist/types/core/src/utils/bodyCell/styling.d.ts +3 -8
- package/dist/types/core/src/utils/bodyCell/types.d.ts +20 -1
- package/dist/types/core/src/utils/externalScroll.d.ts +11 -0
- package/dist/types/core/src/utils/headerCell/types.d.ts +2 -1
- package/dist/types/core/src/utils/nestedGridRowRenderer.d.ts +16 -0
- package/dist/types/core/src/utils/resizeUtils/sectionWidths.d.ts +20 -0
- package/dist/types/react/src/__tests__/animationCoordinator.test.d.ts +1 -0
- package/dist/types/react/src/__tests__/cellRendererMemoization.test.d.ts +1 -0
- package/dist/types/react/src/__tests__/columnVirtualizationViewportWidth.test.d.ts +1 -0
- package/dist/types/react/src/__tests__/maxHeightServerSidePaginationEmptyRows.test.d.ts +1 -0
- package/dist/types/react/src/__tests__/rowButtons.test.d.ts +1 -0
- package/dist/types/react/src/__tests__/serverSidePaginationCustomFooter.test.d.ts +1 -0
- package/dist/types/react/src/__tests__/updateDataDuringAnimation.test.d.ts +1 -0
- package/dist/types/react/src/index.d.ts +1 -1
- package/dist/types/react/src/types.d.ts +5 -2
- package/dist/types/react/src/utils/wrapReactRenderer.d.ts +10 -1
- package/package.json +2 -2
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
|
|
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:v,icons:O,rowButtons:R,onColumnOrderChange:E,onColumnWidthChange:x,onHeaderEdit:C,onColumnSelect:w}=t,I=c(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","rowButtons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]),T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},I),{rows:s,defaultHeaders:r.map(e=>j(e,n))}),E?{onColumnOrderChange:e=>E(e)}:{}),x?{onColumnWidthChange:e=>x(e)}:{}),C?{onHeaderEdit:(e,t)=>C(e,t)}:{}),w?{onColumnSelect:e=>w(e)}:{});if(void 0!==o&&(T.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))T.emptyStateRenderer=f(n,i);else{const e=i;T.emptyStateRenderer=()=>m(e)}if(void 0!==u)if(b(u))T.errorStateRenderer=f(n,u);else{const e=u;T.errorStateRenderer=()=>m(e)}if(void 0!==a)if(b(a))T.loadingStateRenderer=f(n,a);else{const e=a;T.loadingStateRenderer=()=>m(e)}return void 0!==S&&(T.tableEmptyStateRenderer=null===S?null:m(S)),void 0!==y&&(T.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!==v&&(T.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)}:{})}(v,n)),void 0!==O&&(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:g(r));return t}(O)),void 0!==R&&(T.rowButtons=R.map(t=>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,t))),T}"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 v 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 O=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(v,{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]})});O.displayName="SimpleTable",Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return n.asRows}}),exports.SimpleTable=O;
|
|
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
|
|
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 d}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=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 O(n){return u(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"]),u=Object.assign({},c);if(r&&(u.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&&(u.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&&(u.children=s.map(e=>y(e,n))),i){const e=Object.assign(Object.assign({},i),{rows:[]});u.nestedTable=j(e,n)}return u}function j(t,n){const{defaultHeaders:r,rows:o,footerRenderer:s,emptyStateRenderer:i,errorStateRenderer:c,loadingStateRenderer:u,tableEmptyStateRenderer:d,headerDropdown:a,columnEditorConfig:h,icons:j,rowButtons:E,onColumnOrderChange:R,onColumnWidthChange:C,onHeaderEdit:w,onColumnSelect:I}=t,x=l(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons","rowButtons","onColumnOrderChange","onColumnWidthChange","onHeaderEdit","onColumnSelect"]),H=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},x),{rows:o,defaultHeaders:r.map(e=>y(e,n))}),R?{onColumnOrderChange:e=>R(e)}:{}),C?{onColumnWidthChange:e=>C(e)}:{}),w?{onHeaderEdit:(e,t)=>w(e,t)}:{}),I?{onColumnSelect:e=>I(e)}:{});if(void 0!==s&&(H.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))H.emptyStateRenderer=p(n,i);else{const e=i;H.emptyStateRenderer=()=>S(e)}if(void 0!==c)if(v(c))H.errorStateRenderer=p(n,c);else{const e=c;H.errorStateRenderer=()=>S(e)}if(void 0!==u)if(v(u))H.loadingStateRenderer=p(n,u);else{const e=u;H.loadingStateRenderer=()=>S(e)}return void 0!==d&&(H.tableEmptyStateRenderer=null===d?null:S(d)),void 0!==a&&(H.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&&(H.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&&(H.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)),void 0!==E&&(H.rowButtons=E.map(t=>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,t))),H}"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,u){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(u){const e=t.getAPI();"function"==typeof u?u(e):u.current=e}return()=>{n(),t.destroy(),m.current=null,p.current=void 0,g.current=null,f.clear(),u&&"function"!=typeof u&&(u.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=>d(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
|
|
@@ -4,6 +4,7 @@ export declare const PAGE_SIZE = 20;
|
|
|
4
4
|
export declare const CSS_VAR_BORDER_WIDTH = "--st-border-width";
|
|
5
5
|
export declare const DEFAULT_BORDER_WIDTH = 1;
|
|
6
6
|
export declare const VIRTUALIZATION_THRESHOLD = 20;
|
|
7
|
+
export declare const UNVIRTUALIZED_ROW_WARNING_THRESHOLD = 500;
|
|
7
8
|
export declare const OVERSCAN_PIXELS = 800;
|
|
8
9
|
export declare const calculateBufferRowCount: (rowHeight: number) => number;
|
|
9
10
|
export declare const COLUMN_EDIT_WIDTH = 29.5;
|
|
@@ -60,6 +60,10 @@ export declare class SimpleTableVanilla {
|
|
|
60
60
|
private scrollEndTimeoutId;
|
|
61
61
|
private lastScrollTop;
|
|
62
62
|
private isUpdating;
|
|
63
|
+
/** Set once the dev-only "too many unvirtualized rows" warning has fired, so it never repeats. */
|
|
64
|
+
private hasWarnedUnvirtualizedRows;
|
|
65
|
+
/** Pending deferred check for the unvirtualized-rows warning (lets external-scroll seeding settle first). */
|
|
66
|
+
private unvirtualizedRowsCheckTimeoutId;
|
|
63
67
|
/** Currently resolved external scroll parent (HTMLElement or window). Null when external scroll mode is inactive. */
|
|
64
68
|
private resolvedScrollParent;
|
|
65
69
|
/** Bound scroll handler attached to the external scroll parent. */
|
|
@@ -70,6 +74,15 @@ export declare class SimpleTableVanilla {
|
|
|
70
74
|
private externalParentResizeObserver;
|
|
71
75
|
/** Cached visible viewport height of the table inside the external parent. Fed into virtualization. */
|
|
72
76
|
private externalViewportHeight;
|
|
77
|
+
/**
|
|
78
|
+
* rAF handle for retrying resolution of a configured-but-not-yet-resolvable
|
|
79
|
+
* `scrollParent` (e.g. a getter pointing at a ref attached on a later commit
|
|
80
|
+
* than this table's mount). Null when no retry is pending.
|
|
81
|
+
*/
|
|
82
|
+
private externalScrollRetryRaf;
|
|
83
|
+
/** Number of resolution retries attempted; bounded so we don't spin forever. */
|
|
84
|
+
private externalScrollRetryCount;
|
|
85
|
+
private static readonly EXTERNAL_SCROLL_MAX_RETRIES;
|
|
73
86
|
/** True iff the body-container scroll listener is currently attached. */
|
|
74
87
|
private bodyScrollListenerAttached;
|
|
75
88
|
/** Bound mouseleave handler on the body container. */
|
|
@@ -155,6 +168,13 @@ export declare class SimpleTableVanilla {
|
|
|
155
168
|
*/
|
|
156
169
|
private didColumnVisibilityChange;
|
|
157
170
|
private captureAnimationSnapshot;
|
|
171
|
+
/**
|
|
172
|
+
* Push the visible vertical viewport into the animation coordinator when
|
|
173
|
+
* external/page scroll is active (or clear it otherwise). Keeps the FLIP
|
|
174
|
+
* distance-scaling viewport-relative so cells don't slide the full
|
|
175
|
+
* conceptual distance when the table grows to its natural height.
|
|
176
|
+
*/
|
|
177
|
+
private updateAnimationVerticalScroll;
|
|
158
178
|
/**
|
|
159
179
|
* Open the accordion animation window for the next render: capture a FLIP
|
|
160
180
|
* snapshot, mark the active axis so cell renderers initialize incoming
|
|
@@ -180,6 +200,14 @@ export declare class SimpleTableVanilla {
|
|
|
180
200
|
* `maxHeight`). Idempotent — safe to call repeatedly.
|
|
181
201
|
*/
|
|
182
202
|
private syncExternalScrollWiring;
|
|
203
|
+
/**
|
|
204
|
+
* Retry resolving a configured `scrollParent` on the next animation frame.
|
|
205
|
+
* Used when the parent (typically a getter pointing at a ref) was not yet
|
|
206
|
+
* resolvable when external wiring last ran. Bounded by
|
|
207
|
+
* {@link SimpleTableVanilla.EXTERNAL_SCROLL_MAX_RETRIES} so a permanently
|
|
208
|
+
* unresolvable parent doesn't spin forever.
|
|
209
|
+
*/
|
|
210
|
+
private scheduleExternalScrollParentRetry;
|
|
183
211
|
private ensureBodyScrollListenerAttached;
|
|
184
212
|
private ensureBodyScrollListenerDetached;
|
|
185
213
|
private attachExternalScrollWiring;
|
|
@@ -250,6 +278,17 @@ export declare class SimpleTableVanilla {
|
|
|
250
278
|
*/
|
|
251
279
|
refitAutoSizeColumns(): void;
|
|
252
280
|
private render;
|
|
281
|
+
/**
|
|
282
|
+
* Dev-only safeguard. Schedules a one-shot, deferred check that warns when the
|
|
283
|
+
* table is about to render a very large number of rows with no virtualization
|
|
284
|
+
* active (no `height` / `maxHeight` and no bounded `scrollParent`). The check
|
|
285
|
+
* is deferred so external-scroll viewport seeding (which can momentarily leave
|
|
286
|
+
* `contentHeight` undefined on the first paint) has time to settle and we
|
|
287
|
+
* don't cry wolf for a correctly-configured table. Compiled out of production
|
|
288
|
+
* via the NODE_ENV guard. Never throws.
|
|
289
|
+
*/
|
|
290
|
+
private maybeScheduleUnvirtualizedRowsWarning;
|
|
291
|
+
private evaluateUnvirtualizedRowsWarning;
|
|
253
292
|
update(config: Partial<SimpleTableConfig>): void;
|
|
254
293
|
/** @deprecated Use {@link update} — same behavior. */
|
|
255
294
|
updateConfig(config: Partial<SimpleTableConfig>): void;
|
|
@@ -29,6 +29,15 @@ export interface TableAPIContext {
|
|
|
29
29
|
cellRegistry?: Map<string, {
|
|
30
30
|
updateContent: (value: any) => void;
|
|
31
31
|
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a cell (by its `getCellId` key) is currently mid-FLIP-animation.
|
|
34
|
+
* Live `updateData` content writes are skipped for animating cells so a
|
|
35
|
+
* data tick doesn't re-render / mutate a cell that is sliding to a new
|
|
36
|
+
* position (which causes visible jank). The underlying row data is still
|
|
37
|
+
* updated; only the in-place DOM refresh is deferred to the next tick or
|
|
38
|
+
* re-render once the animation settles.
|
|
39
|
+
*/
|
|
40
|
+
isCellAnimating?: (cellId: string) => boolean;
|
|
32
41
|
columnEditorOpen: boolean;
|
|
33
42
|
expandedDepthsManager: any;
|
|
34
43
|
selectionManager: SelectionManager | null;
|
|
@@ -12,6 +12,7 @@ import { SelectionManager } from "../../managers/SelectionManager";
|
|
|
12
12
|
import { RowSelectionManager } from "../../managers/RowSelectionManager";
|
|
13
13
|
import type { AnimationCoordinator, CellPosition } from "../../managers/AnimationCoordinator";
|
|
14
14
|
import type { AccordionAxis } from "../../utils/accordionAnimation";
|
|
15
|
+
import type { NestedTableFactory } from "../../utils/nestedGridRowRenderer";
|
|
15
16
|
import { FlattenRowsResult } from "../../utils/rowFlattening";
|
|
16
17
|
import { ProcessRowsResult } from "../../utils/rowProcessing";
|
|
17
18
|
import { MergedColumnEditorConfig, ResolvedIcons } from "../initialization/TableInitializer";
|
|
@@ -52,6 +53,8 @@ export interface RenderContext {
|
|
|
52
53
|
internalIsLoading: boolean;
|
|
53
54
|
isResizing: boolean;
|
|
54
55
|
localRows: Row[];
|
|
56
|
+
/** Injected factory for nested grid tables (breaks the SimpleTableVanilla import cycle). */
|
|
57
|
+
createNestedTable?: NestedTableFactory;
|
|
55
58
|
mainBodyRef: {
|
|
56
59
|
current: HTMLDivElement | null;
|
|
57
60
|
};
|
|
@@ -9,6 +9,7 @@ import { SelectionManager } from "../../managers/SelectionManager";
|
|
|
9
9
|
import { RowSelectionManager } from "../../managers/RowSelectionManager";
|
|
10
10
|
import type { AnimationCoordinator, CellPosition } from "../../managers/AnimationCoordinator";
|
|
11
11
|
import type { AccordionAxis } from "../../utils/accordionAnimation";
|
|
12
|
+
import type { NestedTableFactory } from "../../utils/nestedGridRowRenderer";
|
|
12
13
|
export interface TableRendererDeps {
|
|
13
14
|
/** Accordion animation axis for the in-flight collapse/expand. See {@link RenderContext.accordionAxis}. */
|
|
14
15
|
accordionAxis?: AccordionAxis;
|
|
@@ -81,6 +82,8 @@ export interface TableRendererDeps {
|
|
|
81
82
|
setIsResizing: (value: boolean) => void;
|
|
82
83
|
setRowStateMap: (map: Map<string | number, any>) => void;
|
|
83
84
|
sortManager: SortManager | null;
|
|
85
|
+
/** Injected factory for nested grid tables (breaks the SimpleTableVanilla import cycle). */
|
|
86
|
+
createNestedTable?: NestedTableFactory;
|
|
84
87
|
}
|
|
85
88
|
export declare class TableRenderer {
|
|
86
89
|
private sectionRenderer;
|
|
@@ -19,7 +19,7 @@ import type { TableAPI, SetHeaderRenameProps, ExportToCSVProps } from "./types/T
|
|
|
19
19
|
import type TableRowProps from "./types/TableRowProps";
|
|
20
20
|
import type Theme from "./types/Theme";
|
|
21
21
|
import type UpdateDataProps from "./types/UpdateCellProps";
|
|
22
|
-
import type { FilterCondition, TableFilterState } from "./types/FilterTypes";
|
|
22
|
+
import type { FilterCondition, TableFilterState, FilterOperator, StringFilterOperator, NumberFilterOperator, BooleanFilterOperator, DateFilterOperator, EnumFilterOperator } from "./types/FilterTypes";
|
|
23
23
|
import type { QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode } from "./types/QuickFilterTypes";
|
|
24
24
|
import type { ColumnVisibilityState } from "./types/ColumnVisibilityTypes";
|
|
25
25
|
import type RowSelectionChangeProps from "./types/RowSelectionChangeProps";
|
|
@@ -48,4 +48,4 @@ import type { RowId } from "./types/RowId";
|
|
|
48
48
|
import type { PinnedSectionsState } from "./types/PinnedSectionsState";
|
|
49
49
|
export { SimpleTableVanilla };
|
|
50
50
|
export { asRows } from "./utils/asRows";
|
|
51
|
-
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, FooterRendererProps, FooterPosition, GetRowId, GetRowIdParams, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, HeaderDropdown, HeaderDropdownProps, HeaderObject, HeaderRenderer, HeaderRendererProps, HeaderRendererComponents, OnRowGroupExpandProps, OnSortProps, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, PinnedSectionsState, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, };
|
|
51
|
+
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, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, PinnedSectionsState, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, };
|
|
@@ -57,6 +57,31 @@ export declare class AnimationCoordinator {
|
|
|
57
57
|
* stable within a single sort.
|
|
58
58
|
*/
|
|
59
59
|
private scrollerMetricsCache;
|
|
60
|
+
/**
|
|
61
|
+
* Vertical scroller metrics override for external/page-scroll mode. When the
|
|
62
|
+
* table has no internal vertical overflow (it grows to its natural height and
|
|
63
|
+
* a parent element / the window scrolls), the body container's own
|
|
64
|
+
* clientHeight/scrollHeight no longer describe the visible viewport, so
|
|
65
|
+
* {@link scaleFlipDistance} can't bound the FLIP journey and sort cells slide
|
|
66
|
+
* the full conceptual distance. The vanilla table pushes the real visible
|
|
67
|
+
* viewport here (from the same `getExternalScrollMetrics` the virtualizer
|
|
68
|
+
* uses) so the y-axis FLIP scaling matches the on-screen viewport. `null`
|
|
69
|
+
* when external scroll is inactive — internal scroller metrics are used as-is.
|
|
70
|
+
*/
|
|
71
|
+
private externalVerticalScroll;
|
|
72
|
+
/**
|
|
73
|
+
* The currently-scheduled (not-yet-started) FLIP frame. play() defers the
|
|
74
|
+
* transition start by two animation frames so the inverted "First" frame
|
|
75
|
+
* gets painted before the transition fires. Spam-clicking sort triggers a
|
|
76
|
+
* full re-render + play() inside that two-frame window: without coalescing,
|
|
77
|
+
* the stale chain's startTransition zeroes the transforms the newer cycle
|
|
78
|
+
* just inverted (a frame early), so the final transition animates
|
|
79
|
+
* identity→identity and nothing visibly moves — and many captured nodes are
|
|
80
|
+
* detached by the intervening render before they ever transition. Tracking
|
|
81
|
+
* the pending frame lets a new play() cancel the prior cycle and reset the
|
|
82
|
+
* transforms it left behind, so only the latest sort animates.
|
|
83
|
+
*/
|
|
84
|
+
private scheduledFlip;
|
|
60
85
|
constructor(opts?: AnimationCoordinatorOptions);
|
|
61
86
|
setEnabled(enabled: boolean): void;
|
|
62
87
|
setDuration(duration: number): void;
|
|
@@ -84,6 +109,18 @@ export declare class AnimationCoordinator {
|
|
|
84
109
|
* mutation in the loop.
|
|
85
110
|
*/
|
|
86
111
|
private getScrollerMetrics;
|
|
112
|
+
/**
|
|
113
|
+
* Supply (or clear) the vertical scroller metrics override used by
|
|
114
|
+
* {@link scaleFlipDistance} in external/page-scroll mode. Must be set before
|
|
115
|
+
* `captureSnapshot`/`retainCell`/`play` so the whole FLIP cycle scales
|
|
116
|
+
* against the real visible viewport. Pass `null` to fall back to the body
|
|
117
|
+
* container's own metrics (internal scroll).
|
|
118
|
+
*/
|
|
119
|
+
setExternalVerticalScroll(metrics: {
|
|
120
|
+
clientHeight: number;
|
|
121
|
+
scrollHeight: number;
|
|
122
|
+
scrollTop: number;
|
|
123
|
+
} | null): void;
|
|
87
124
|
private clearScrollerMetricsCache;
|
|
88
125
|
/**
|
|
89
126
|
* Capture pre-change positions for cells we may want to animate.
|
|
@@ -16,7 +16,16 @@ export interface TableFilterState {
|
|
|
16
16
|
[accessor: Accessor]: FilterCondition;
|
|
17
17
|
}
|
|
18
18
|
export declare const FILTER_OPERATOR_LABELS: Record<FilterOperator, string>;
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Returns the list of operators a column should expose in its filter UI.
|
|
21
|
+
*
|
|
22
|
+
* When `allowedOperators` is provided, the result is restricted to that list,
|
|
23
|
+
* preserving the consumer-specified order. Operators that aren't valid for the
|
|
24
|
+
* given column type are ignored. If the restriction would leave no valid
|
|
25
|
+
* operators (e.g. a misconfiguration), the full default list for the column
|
|
26
|
+
* type is returned so the filter UI never renders an empty dropdown.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getAvailableOperators: (columnType: "string" | "number" | "boolean" | "date" | "enum", allowedOperators?: FilterOperator[]) => FilterOperator[];
|
|
20
29
|
export declare const requiresSingleValue: (operator: FilterOperator) => boolean;
|
|
21
30
|
export declare const requiresMultipleValues: (operator: FilterOperator) => boolean;
|
|
22
31
|
export declare const requiresNoValue: (operator: FilterOperator) => boolean;
|
|
@@ -7,6 +7,7 @@ import { HeaderRenderer } from "./HeaderRendererProps";
|
|
|
7
7
|
import CellValue from "./CellValue";
|
|
8
8
|
import { SimpleTableProps } from "./SimpleTableProps";
|
|
9
9
|
import { QuickFilterGetter } from "./QuickFilterTypes";
|
|
10
|
+
import type { FilterOperator } from "./FilterTypes";
|
|
10
11
|
export type Accessor = keyof Row | string;
|
|
11
12
|
export type ColumnType = "string" | "number" | "boolean" | "date" | "enum" | "lineAreaChart" | "barChart" | "other";
|
|
12
13
|
export type ShowWhen = "parentCollapsed" | "parentExpanded" | "always";
|
|
@@ -81,6 +82,19 @@ type HeaderObject = {
|
|
|
81
82
|
expandable?: boolean;
|
|
82
83
|
exportValueGetter?: ExportValueGetter;
|
|
83
84
|
filterable?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Restricts which filter operators are shown in this column's filter dropdown.
|
|
87
|
+
* Only operators valid for the column's `type` are honored, and they appear in
|
|
88
|
+
* the order provided here. When omitted, all operators for the column type are
|
|
89
|
+
* shown. Has no effect on `enum` columns (which use a checkbox value picker
|
|
90
|
+
* instead of an operator dropdown).
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // String column limited to "contains" and "equals"
|
|
94
|
+
* { accessor: "name", type: "string", filterable: true,
|
|
95
|
+
* filterOperators: ["contains", "equals"] }
|
|
96
|
+
*/
|
|
97
|
+
filterOperators?: FilterOperator[];
|
|
84
98
|
headerRenderer?: HeaderRenderer;
|
|
85
99
|
hide?: boolean;
|
|
86
100
|
isEditable?: boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type Row from "../../types/Row";
|
|
2
|
+
import type TableRow from "../../types/TableRow";
|
|
3
|
+
import { CellRenderContext } from "./types";
|
|
4
|
+
export interface CellLiveRef {
|
|
5
|
+
row: Row;
|
|
6
|
+
tableRow: TableRow;
|
|
7
|
+
context: CellRenderContext;
|
|
8
|
+
}
|
|
9
|
+
export declare const cellLiveRefMap: WeakMap<HTMLElement, CellLiveRef>;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import type Row from "../../types/Row";
|
|
2
|
-
import type TableRow from "../../types/TableRow";
|
|
3
1
|
import { AbsoluteBodyCell, CellRegistryEntry, CellRenderContext } from "./types";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
context: CellRenderContext;
|
|
8
|
-
}
|
|
9
|
-
export declare const cellLiveRefMap: WeakMap<HTMLElement, CellLiveRef>;
|
|
2
|
+
import { CellLiveRef, cellLiveRefMap } from "./cellLiveRef";
|
|
3
|
+
export { cellLiveRefMap };
|
|
4
|
+
export type { CellLiveRef };
|
|
10
5
|
export declare const untrackCellByRow: (rowId: string, cellElement: HTMLElement) => void;
|
|
11
6
|
export declare const unregisterCellFromRegistry: (cellElement: HTMLElement, cellRegistry?: Map<string, CellRegistryEntry>) => void;
|
|
12
7
|
export declare const createBodyCellElement: (cell: AbsoluteBodyCell, context: CellRenderContext) => HTMLElement;
|
|
@@ -10,6 +10,7 @@ import type { CustomTheme } from "../../types/CustomTheme";
|
|
|
10
10
|
import type { HeightOffsets } from "../infiniteScrollUtils";
|
|
11
11
|
import type { AccordionAxis } from "../accordionAnimation";
|
|
12
12
|
import type { VanillaEmptyStateRenderer, VanillaErrorStateRenderer, VanillaLoadingStateRenderer } from "../../types/RowStateRendererProps";
|
|
13
|
+
import type { NestedTableFactory } from "../nestedGridRowRenderer";
|
|
13
14
|
type SetStateAction<T> = T | ((prevState: T) => T);
|
|
14
15
|
type Dispatch<A> = (value: A) => void;
|
|
15
16
|
export interface AbsoluteBodyCell {
|
|
@@ -83,8 +84,20 @@ export interface CellRenderContext {
|
|
|
83
84
|
heightOffsets?: HeightOffsets;
|
|
84
85
|
customTheme?: CustomTheme;
|
|
85
86
|
containerWidth?: number;
|
|
86
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Main section *content* width (sum of all non-pinned column widths). Drives
|
|
89
|
+
* the body section / row-separator width so the body is as wide as its
|
|
90
|
+
* content and scrolls horizontally. NOT the virtualization viewport — use
|
|
91
|
+
* `mainSectionViewportWidth` for getVisibleBodyCells.
|
|
92
|
+
*/
|
|
87
93
|
mainSectionContainerWidth?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Main section *visible* viewport width (container minus pinned sections).
|
|
96
|
+
* Used by getVisibleBodyCells to decide which cells intersect the viewport
|
|
97
|
+
* (column virtualization). NOT the content width — using the content width
|
|
98
|
+
* here makes every column count as visible, disabling virtualization.
|
|
99
|
+
*/
|
|
100
|
+
mainSectionViewportWidth?: number;
|
|
88
101
|
onCellEdit?: (params: CellEditParams) => void;
|
|
89
102
|
onCellClick?: (params: CellClickParams) => void;
|
|
90
103
|
onRowGroupExpand?: (props: OnRowGroupExpandProps) => void | Promise<void>;
|
|
@@ -103,6 +116,12 @@ export interface CellRenderContext {
|
|
|
103
116
|
loadingStateRenderer?: VanillaLoadingStateRenderer;
|
|
104
117
|
errorStateRenderer?: VanillaErrorStateRenderer;
|
|
105
118
|
emptyStateRenderer?: VanillaEmptyStateRenderer;
|
|
119
|
+
/**
|
|
120
|
+
* Factory used to instantiate nested grid tables. Injected by the host table
|
|
121
|
+
* so {@link nestedGridRowRenderer} never has to import the concrete
|
|
122
|
+
* `SimpleTableVanilla` class (which would create a render-module import cycle).
|
|
123
|
+
*/
|
|
124
|
+
createNestedTable?: NestedTableFactory;
|
|
106
125
|
getBorderClass: (cell: CellData) => string;
|
|
107
126
|
isSelected: (cell: CellData) => boolean;
|
|
108
127
|
isInitialFocusedCell: (cell: CellData) => boolean;
|
|
@@ -45,3 +45,14 @@ export declare const getExternalScrollMetrics: (parent: ResolvedScrollParent, ta
|
|
|
45
45
|
* Returns the raw scroll-top of the parent (used for direction tracking only).
|
|
46
46
|
*/
|
|
47
47
|
export declare const getParentScrollTop: (parent: ResolvedScrollParent) => number;
|
|
48
|
+
/**
|
|
49
|
+
* Height of the parent's own viewport (window.innerHeight, or the element's
|
|
50
|
+
* border-box height), independent of where the table sits inside it.
|
|
51
|
+
*
|
|
52
|
+
* Used as a provisional virtualization viewport before the table has been laid
|
|
53
|
+
* out: at that point the table∩viewport intersection is 0, which would disable
|
|
54
|
+
* virtualization and render every row at once. Seeding with the parent viewport
|
|
55
|
+
* keeps virtualization active on the first paint; a later precise recompute
|
|
56
|
+
* refines it. Returns 0 when the parent can't be measured.
|
|
57
|
+
*/
|
|
58
|
+
export declare const getParentViewportHeight: (parent: ResolvedScrollParent) => number;
|
|
@@ -52,7 +52,8 @@ export interface HeaderRenderContext {
|
|
|
52
52
|
icons: IconsConfig;
|
|
53
53
|
lastHeaderIndex: number;
|
|
54
54
|
mainBodyRef: RefObject<HTMLDivElement>;
|
|
55
|
-
mainSectionContainerWidth?: number; /** Main section
|
|
55
|
+
mainSectionContainerWidth?: number; /** Main section *content* width (sum of all non-pinned column widths). NOT the virtualization viewport. */
|
|
56
|
+
mainSectionViewportWidth?: number; /** Main section *visible* viewport width (container minus pinned); use for getVisibleCells when !pinned */
|
|
56
57
|
onColumnOrderChange?: (headers: HeaderObject[]) => void;
|
|
57
58
|
onColumnSelect?: (header: HeaderObject) => void;
|
|
58
59
|
onColumnWidthChange?: (headers: HeaderObject[]) => void;
|
|
@@ -6,6 +6,20 @@ import type TableRow from "../types/TableRow";
|
|
|
6
6
|
import type { CustomTheme } from "../types/CustomTheme";
|
|
7
7
|
import type { SimpleTableConfig } from "../types/SimpleTableConfig";
|
|
8
8
|
import { type HeightOffsets } from "./infiniteScrollUtils";
|
|
9
|
+
/**
|
|
10
|
+
* Minimal surface of a table instance this renderer drives. Declared
|
|
11
|
+
* structurally so this module never has to statically import the concrete
|
|
12
|
+
* `SimpleTableVanilla` class — that import would close a cycle
|
|
13
|
+
* (SimpleTableVanilla → RenderOrchestrator → TableRenderer → SectionRenderer →
|
|
14
|
+
* nestedGridRowRenderer → SimpleTableVanilla). The class is injected at render
|
|
15
|
+
* time via {@link NestedTableFactory} instead.
|
|
16
|
+
*/
|
|
17
|
+
export interface NestedTableInstance {
|
|
18
|
+
mount: () => void;
|
|
19
|
+
destroy: () => void;
|
|
20
|
+
}
|
|
21
|
+
/** Factory injected by the host table to instantiate a nested table. */
|
|
22
|
+
export type NestedTableFactory = (container: HTMLElement, config: SimpleTableConfig) => NestedTableInstance;
|
|
9
23
|
export interface NestedGridRowRenderContext {
|
|
10
24
|
rowHeight: number;
|
|
11
25
|
heightOffsets: HeightOffsets | undefined;
|
|
@@ -17,6 +31,8 @@ export interface NestedGridRowRenderContext {
|
|
|
17
31
|
errorStateRenderer?: SimpleTableConfig["errorStateRenderer"];
|
|
18
32
|
emptyStateRenderer?: SimpleTableConfig["emptyStateRenderer"];
|
|
19
33
|
icons?: SimpleTableConfig["icons"];
|
|
34
|
+
/** Injected constructor for nested tables (breaks the import cycle). */
|
|
35
|
+
createNestedTable?: NestedTableFactory;
|
|
20
36
|
}
|
|
21
37
|
/**
|
|
22
38
|
* Creates a nested grid row element: a div with class "st-row st-nested-grid-row"
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import type HeaderObject from "../../types/HeaderObject";
|
|
2
|
+
/**
|
|
3
|
+
* Width of the *visible* portion of the main (non-pinned) section: the container
|
|
4
|
+
* width minus the pinned section widths.
|
|
5
|
+
*
|
|
6
|
+
* This is the viewport used for column virtualization (getVisibleBodyCells /
|
|
7
|
+
* getVisibleCells) — NOT `mainWidth` from {@link recalculateAllSectionWidths},
|
|
8
|
+
* which is the full *content* width (sum of all main column widths). Passing the
|
|
9
|
+
* content width here makes every column count as "in viewport", disabling column
|
|
10
|
+
* virtualization (all columns render). See the column-virtualization regression
|
|
11
|
+
* tests.
|
|
12
|
+
*
|
|
13
|
+
* Returns `undefined` when the container has not been measured yet
|
|
14
|
+
* (`containerWidth` 0) so callers fall back to a live `clientWidth` read instead
|
|
15
|
+
* of virtualizing against a 0px viewport.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getMainSectionViewportWidth: ({ containerWidth, leftWidth, rightWidth, }: {
|
|
18
|
+
containerWidth: number;
|
|
19
|
+
leftWidth: number;
|
|
20
|
+
rightWidth: number;
|
|
21
|
+
}) => number | undefined;
|
|
2
22
|
/**
|
|
3
23
|
* Recalculate widths for all sections (left, right, main)
|
|
4
24
|
* Returns both constrained widths (for display) and raw content widths (for scrolling)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as SimpleTable } from "./SimpleTable";
|
|
2
2
|
export { asRows } from "simple-table-core";
|
|
3
3
|
export type { SimpleTableReactProps, TableInstance, ReactHeaderObject, ReactColumnEditorConfig, ReactIconsConfig, ReactIconElement, ReactCellRenderer, ReactHeaderRenderer, ReactFooterRenderer, ReactHeaderDropdown, ReactColumnEditorRowRenderer, ReactColumnEditorCustomRenderer, ReactLoadingStateRenderer, ReactErrorStateRenderer, ReactEmptyStateRenderer, HeaderRendererComponents, HeaderRendererProps, ColumnEditorRowRendererComponents, ColumnEditorRowRendererProps, ColumnEditorCustomRendererProps, FooterRendererProps, HeaderDropdownProps, } from "./types";
|
|
4
|
-
export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ChartOptions, ColumnEditorConfig, ColumnEditorRowRenderer, ColumnEditorCustomRenderer, ColumnEditorSearchFunction, ColumnType, ColumnVisibilityState, Comparator, ComparatorProps, CustomTheme, CustomThemeProps, DragHandlerProps, EmptyStateRenderer, EmptyStateRendererProps, EnumOption, ErrorStateRenderer, ErrorStateRendererProps, ExportToCSVProps, ExportValueGetter, ExportValueProps, FilterCondition, GetRowId, GetRowIdParams, HeaderDropdown, HeaderRenderer, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, OnRowGroupExpandProps, OnSortProps, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, } from "simple-table-core";
|
|
4
|
+
export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ChartOptions, ColumnEditorConfig, ColumnEditorRowRenderer, ColumnEditorCustomRenderer, ColumnEditorSearchFunction, ColumnType, ColumnVisibilityState, Comparator, ComparatorProps, CustomTheme, CustomThemeProps, DragHandlerProps, EmptyStateRenderer, EmptyStateRendererProps, EnumOption, ErrorStateRenderer, ErrorStateRendererProps, ExportToCSVProps, ExportValueGetter, ExportValueProps, FilterCondition, FilterOperator, StringFilterOperator, NumberFilterOperator, BooleanFilterOperator, DateFilterOperator, EnumFilterOperator, GetRowId, GetRowIdParams, HeaderDropdown, HeaderRenderer, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, OnRowGroupExpandProps, OnSortProps, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, } from "simple-table-core";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type { SimpleTableProps, SimpleTableConfig, HeaderObject, TableAPI, Row, CellRendererProps, HeaderRendererProps as VanillaHeaderRendererProps, FooterRendererProps as VanillaFooterRendererProps, LoadingStateRendererProps, ErrorStateRendererProps, EmptyStateRendererProps, HeaderDropdownProps as VanillaHeaderDropdownProps, ColumnEditorRowRendererProps as VanillaColumnEditorRowRendererProps, ColumnEditorCustomRendererProps as VanillaColumnEditorCustomRendererProps, ColumnEditorConfig } from "simple-table-core";
|
|
2
|
+
import type { SimpleTableProps, SimpleTableConfig, HeaderObject, TableAPI, Row, CellRendererProps, HeaderRendererProps as VanillaHeaderRendererProps, FooterRendererProps as VanillaFooterRendererProps, LoadingStateRendererProps, ErrorStateRendererProps, EmptyStateRendererProps, HeaderDropdownProps as VanillaHeaderDropdownProps, ColumnEditorRowRendererProps as VanillaColumnEditorRowRendererProps, ColumnEditorCustomRendererProps as VanillaColumnEditorCustomRendererProps, ColumnEditorConfig, RowButtonProps } from "simple-table-core";
|
|
3
3
|
/** Passed to React `headerRenderer` / `headerDropdown`; slots are React nodes. */
|
|
4
4
|
export interface HeaderRendererComponents {
|
|
5
5
|
sortIcon?: React.ReactNode;
|
|
@@ -62,6 +62,7 @@ export type ReactFooterRenderer = React.ComponentType<FooterRendererProps> | ((p
|
|
|
62
62
|
export type ReactHeaderDropdown = React.ComponentType<HeaderDropdownProps> | ((props: HeaderDropdownProps) => React.ReactNode);
|
|
63
63
|
export type ReactColumnEditorRowRenderer = React.ComponentType<ColumnEditorRowRendererProps> | ((props: ColumnEditorRowRendererProps) => React.ReactNode);
|
|
64
64
|
export type ReactColumnEditorCustomRenderer = React.ComponentType<ColumnEditorCustomRendererProps> | ((props: ColumnEditorCustomRendererProps) => React.ReactNode);
|
|
65
|
+
export type ReactRowButton = React.ComponentType<RowButtonProps> | ((props: RowButtonProps) => React.ReactNode);
|
|
65
66
|
export type ReactLoadingStateRenderer = React.ComponentType<LoadingStateRendererProps> | React.ReactNode;
|
|
66
67
|
export type ReactErrorStateRenderer = React.ComponentType<ErrorStateRendererProps> | React.ReactNode;
|
|
67
68
|
export type ReactEmptyStateRenderer = React.ComponentType<EmptyStateRendererProps> | React.ReactNode;
|
|
@@ -80,7 +81,7 @@ export interface ReactHeaderObject extends Omit<HeaderObject, "cellRenderer" | "
|
|
|
80
81
|
/** Nested grid: React table props minus row data and inherited state renderers. */
|
|
81
82
|
nestedTable?: Omit<SimpleTableReactProps, "rows" | "loadingStateRenderer" | "errorStateRenderer" | "emptyStateRenderer" | "tableEmptyStateRenderer">;
|
|
82
83
|
}
|
|
83
|
-
export interface SimpleTableReactProps extends Omit<SimpleTableProps, "defaultHeaders" | "footerRenderer" | "emptyStateRenderer" | "errorStateRenderer" | "loadingStateRenderer" | "tableEmptyStateRenderer" | "headerDropdown" | "columnEditorConfig" | "icons" | "rows" | "onColumnOrderChange" | "onColumnWidthChange" | "onHeaderEdit" | "onColumnSelect"> {
|
|
84
|
+
export interface SimpleTableReactProps extends Omit<SimpleTableProps, "defaultHeaders" | "footerRenderer" | "emptyStateRenderer" | "errorStateRenderer" | "loadingStateRenderer" | "tableEmptyStateRenderer" | "headerDropdown" | "columnEditorConfig" | "icons" | "rows" | "rowButtons" | "onColumnOrderChange" | "onColumnWidthChange" | "onHeaderEdit" | "onColumnSelect"> {
|
|
84
85
|
defaultHeaders: ReadonlyArray<ReactHeaderObject>;
|
|
85
86
|
onColumnOrderChange?: (newHeaders: ReactHeaderObject[]) => void;
|
|
86
87
|
onColumnWidthChange?: (headers: ReactHeaderObject[]) => void;
|
|
@@ -96,5 +97,7 @@ export interface SimpleTableReactProps extends Omit<SimpleTableProps, "defaultHe
|
|
|
96
97
|
headerDropdown?: ReactHeaderDropdown;
|
|
97
98
|
columnEditorConfig?: ReactColumnEditorConfig;
|
|
98
99
|
icons?: ReactIconsConfig;
|
|
100
|
+
/** Per-row action buttons; each entry returns JSX rendered into the row's selection column. */
|
|
101
|
+
rowButtons?: ReactRowButton[];
|
|
99
102
|
}
|
|
100
103
|
export type { CellRendererProps, LoadingStateRendererProps, ErrorStateRendererProps, EmptyStateRendererProps, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ColumnEditorCustomRendererProps as VanillaColumnEditorCustomRendererProps, ColumnEditorRowRendererProps as VanillaColumnEditorRowRendererProps, HeaderRendererProps as VanillaHeaderRendererProps, HeaderDropdownProps as VanillaHeaderDropdownProps, FooterRendererProps as VanillaFooterRendererProps } from "simple-table-core";
|
|
2
|
+
import type { ColumnEditorCustomRendererProps as VanillaColumnEditorCustomRendererProps, ColumnEditorRowRendererProps as VanillaColumnEditorRowRendererProps, HeaderRendererProps as VanillaHeaderRendererProps, HeaderDropdownProps as VanillaHeaderDropdownProps, FooterRendererProps as VanillaFooterRendererProps, RowButtonProps as VanillaRowButtonProps } from "simple-table-core";
|
|
3
3
|
import type { PortalBridge } from "../PortalBridge";
|
|
4
4
|
/**
|
|
5
5
|
* Wraps a React component into a function that returns an HTMLElement, matching
|
|
@@ -42,6 +42,15 @@ export declare function wrapReactColumnEditorRowRenderer(bridge: PortalBridge, C
|
|
|
42
42
|
* `columnEditorConfig.customRenderer` the same way as row slots.
|
|
43
43
|
*/
|
|
44
44
|
export declare function wrapReactColumnEditorCustomRenderer(bridge: PortalBridge, Component: React.ComponentType<object>): (props: VanillaColumnEditorCustomRendererProps) => HTMLElement;
|
|
45
|
+
/**
|
|
46
|
+
* Wraps a React row-button render function into the vanilla `RowButton`
|
|
47
|
+
* contract `(props) => HTMLElement`. Like {@link wrapReactRendererIntoFragment},
|
|
48
|
+
* it registers the element with the {@link PortalBridge} so the button renders
|
|
49
|
+
* inside the host React tree — preserving interactivity (onClick) and context —
|
|
50
|
+
* and uses `display: contents` so core's `st-row-button` wrapper styles the
|
|
51
|
+
* actual button rather than an extra box.
|
|
52
|
+
*/
|
|
53
|
+
export declare function wrapReactRowButton(bridge: PortalBridge, Component: React.ComponentType<VanillaRowButtonProps>): (props: VanillaRowButtonProps) => HTMLElement;
|
|
45
54
|
/**
|
|
46
55
|
* Renders a static ReactNode into an HTMLElement using server-side static
|
|
47
56
|
* rendering. Used for props like tableEmptyStateRenderer that are static markup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simple-table/react",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.5",
|
|
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.8.
|
|
32
|
+
"simple-table-core": "3.8.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@rollup/plugin-alias": "^4.0.4",
|