@simple-table/react 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("simple-table-core"),n=require("react-dom"),o=require("react-dom/client"),c=require("react-dom/server");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function i({node:r}){const n=t.useRef(null);return t.useLayoutEffect(()=>{const e=n.current;if(e)return e.appendChild(r),()=>{r.parentNode===e&&e.removeChild(r)}},[r]),e.jsx("span",{ref:n,style:{display:"contents"}})}function a(t){if(null!=t)return"string"==typeof t?t:t instanceof Node?e.jsx(i,{node:t}):void 0}function d(e,t){queueMicrotask(()=>{n.flushSync(()=>{e.render(t)})})}function l(t){return r=>{const n=document.createElement("div");return d(o.createRoot(n),e.jsx(t,Object.assign({},r))),n}}function f(t){return r=>{const n=document.createElement("div"),c=o.createRoot(n),s=Object.assign(Object.assign({},r),{searchSection:r.searchSection?a(r.searchSection):null,listSection:a(r.listSection),resetSection:r.resetSection?a(r.resetSection):null});return d(c,e.jsx(t,Object.assign({},s))),n}}function p(t){const r=document.createElement("div");return r.innerHTML=c.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}(r)}function m(t){return c.renderToStaticMarkup(e.jsx(e.Fragment,{children:t}))}function b(e){return"function"==typeof e}function R(t){const{cellRenderer:r,headerRenderer:n,children:c,nestedTable:s}=t,i=u(t,["cellRenderer","headerRenderer","children","nestedTable"]),a=Object.assign({},i);var f;if(r&&(a.cellRenderer=(f=r,t=>{const r=document.createElement("div");return r.style.display="contents",d(o.createRoot(r),e.jsx(f,Object.assign({},t))),r})),n&&(a.headerRenderer=l(n)),c&&(a.children=c.map(R)),s){const e=Object.assign(Object.assign({},s),{rows:[]});a.nestedTable=y(e)}return a}function y(t){const{defaultHeaders:r,rows:n,footerRenderer:c,emptyStateRenderer:s,errorStateRenderer:i,loadingStateRenderer:y,tableEmptyStateRenderer:j,headerDropdown:g,columnEditorConfig:S,icons:O}=t,v=u(t,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons"]),h=Object.assign(Object.assign({},v),{rows:n,defaultHeaders:r.map(R)});if(void 0!==c&&(h.footerRenderer=l(c)),void 0!==s)if(b(s))h.emptyStateRenderer=l(s);else{const e=s;h.emptyStateRenderer=()=>p(e)}if(void 0!==i)if(b(i))h.errorStateRenderer=l(i);else{const e=i;h.errorStateRenderer=()=>p(e)}if(void 0!==y)if(b(y))h.loadingStateRenderer=l(y);else{const e=y;h.loadingStateRenderer=()=>p(e)}return void 0!==j&&(h.tableEmptyStateRenderer=null===j?null:p(j)),void 0!==g&&(h.headerDropdown=l(g)),void 0!==S&&(h.columnEditorConfig=function(t){const{rowRenderer:r,customRenderer:n}=t,c=u(t,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},c),r?{rowRenderer:(s=r,t=>{const r=document.createElement("div"),n=o.createRoot(r),c=Object.assign(Object.assign({},t),{components:(u=t.components,{expandIcon:a(u.expandIcon),checkbox:a(u.checkbox),dragIcon:a(u.dragIcon),labelContent:a(u.labelContent),pinIcon:a(u.pinIcon)})});var u;return d(n,e.jsx(s,Object.assign({},c))),r})}:{}),n?{customRenderer:f(n)}:{});var s}(S)),void 0!==O&&(h.icons=function(e){const t={};for(const[r,n]of Object.entries(e))null!=n&&(t[r]="string"==typeof n||n instanceof HTMLElement||n instanceof SVGElement?n:m(n));return t}(O)),h}"function"==typeof SuppressedError&&SuppressedError;const j=s(t).default.forwardRef(function(n,o){const c=t.useRef(null),s=t.useRef(null),i=t.useRef(void 0),a=t.useRef(null),d=n;return t.useLayoutEffect(()=>{if(!c.current)return;let e=!1;return queueMicrotask(()=>{if(e||!c.current)return;const t=new r.SimpleTableVanilla(c.current,y(d));if(t.mount(),s.current=t,o){const e=t.getAPI();"function"==typeof o?o(e):o.current=e}}),()=>{e=!0;const t=s.current;t&&(t.destroy(),s.current=null,i.current=void 0,a.current=null,o&&"function"!=typeof o&&(o.current=null))}},[]),t.useLayoutEffect(()=>{const e=s.current;if(!e)return;if(null!==a.current&&!function(e,t){const r=new Set([...Object.keys(e),...Object.keys(t)]);for(const n of r)if(e[n]!==t[n])return!0;return!1}(a.current,d))return;a.current=d;const t=y(d);queueMicrotask(()=>{if(s.current!==e)return;if(i.current!==d.defaultHeaders)return i.current=d.defaultHeaders,void e.update(t);const r=u(t,["defaultHeaders"]);e.update(r)})},[d]),e.jsx("div",{ref:c})});j.displayName="SimpleTable",Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return r.asRows}}),exports.SimpleTable=j,exports.defaultHeaderFromCore=function(e){return e},exports.defaultHeadersFromCore=function(e){return e},exports.mapToReactHeaderObjects=function(e){return e};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,Fragment as r}from"react/jsx-runtime";import n,{useRef as t,useLayoutEffect as o}from"react";import{SimpleTableVanilla as c}from"simple-table-core";export{asRows}from"simple-table-core";import{flushSync as i}from"react-dom";import{createRoot as
|
|
1
|
+
import{jsx as e,Fragment as r}from"react/jsx-runtime";import n,{useRef as t,useLayoutEffect as o}from"react";import{SimpleTableVanilla as c}from"simple-table-core";export{asRows}from"simple-table-core";import{flushSync as i}from"react-dom";import{createRoot as s}from"react-dom/client";import{renderToStaticMarkup as d}from"react-dom/server";function u(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(t=Object.getOwnPropertySymbols(e);o<t.length;o++)r.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(e,t[o])&&(n[t[o]]=e[t[o]])}return n}function a({node:r}){const n=t(null);return o(()=>{const e=n.current;if(e)return e.appendChild(r),()=>{r.parentNode===e&&e.removeChild(r)}},[r]),e("span",{ref:n,style:{display:"contents"}})}function l(r){if(null!=r)return"string"==typeof r?r:r instanceof Node?e(a,{node:r}):void 0}function f(e,r){queueMicrotask(()=>{i(()=>{e.render(r)})})}function m(r){return n=>{const t=document.createElement("div");return f(s(t),e(r,Object.assign({},n))),t}}function p(r){return n=>{const t=document.createElement("div"),o=s(t),c=Object.assign(Object.assign({},n),{searchSection:n.searchSection?l(n.searchSection):null,listSection:l(n.listSection),resetSection:n.resetSection?l(n.resetSection):null});return f(o,e(r,Object.assign({},c))),t}}function b(n){const t=document.createElement("div");return t.innerHTML=d(e(r,{children:n})),function(e){const r=Array.from(e.childNodes).filter(e=>e.nodeType!==Node.TEXT_NODE||null!=e.textContent&&""!==e.textContent.trim());return 1===r.length&&r[0]instanceof HTMLElement?(e.removeChild(r[0]),r[0]):e}(t)}function g(n){return d(e(r,{children:n}))}function y(e){return"function"==typeof e}function R(r){const{cellRenderer:n,headerRenderer:t,children:o,nestedTable:c}=r,i=u(r,["cellRenderer","headerRenderer","children","nestedTable"]),d=Object.assign({},i);var a;if(n&&(d.cellRenderer=(a=n,r=>{const n=document.createElement("div");return n.style.display="contents",f(s(n),e(a,Object.assign({},r))),n})),t&&(d.headerRenderer=m(t)),o&&(d.children=o.map(R)),c){const e=Object.assign(Object.assign({},c),{rows:[]});d.nestedTable=S(e)}return d}function S(r){const{defaultHeaders:n,rows:t,footerRenderer:o,emptyStateRenderer:c,errorStateRenderer:i,loadingStateRenderer:d,tableEmptyStateRenderer:a,headerDropdown:S,columnEditorConfig:O,icons:v}=r,j=u(r,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons"]),h=Object.assign(Object.assign({},j),{rows:t,defaultHeaders:n.map(R)});if(void 0!==o&&(h.footerRenderer=m(o)),void 0!==c)if(y(c))h.emptyStateRenderer=m(c);else{const e=c;h.emptyStateRenderer=()=>b(e)}if(void 0!==i)if(y(i))h.errorStateRenderer=m(i);else{const e=i;h.errorStateRenderer=()=>b(e)}if(void 0!==d)if(y(d))h.loadingStateRenderer=m(d);else{const e=d;h.loadingStateRenderer=()=>b(e)}return void 0!==a&&(h.tableEmptyStateRenderer=null===a?null:b(a)),void 0!==S&&(h.headerDropdown=m(S)),void 0!==O&&(h.columnEditorConfig=function(r){const{rowRenderer:n,customRenderer:t}=r,o=u(r,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},o),n?{rowRenderer:(c=n,r=>{const n=document.createElement("div"),t=s(n),o=Object.assign(Object.assign({},r),{components:(i=r.components,{expandIcon:l(i.expandIcon),checkbox:l(i.checkbox),dragIcon:l(i.dragIcon),labelContent:l(i.labelContent),pinIcon:l(i.pinIcon)})});var i;return f(t,e(c,Object.assign({},o))),n})}:{}),t?{customRenderer:p(t)}:{});var c}(O)),void 0!==v&&(h.icons=function(e){const r={};for(const[n,t]of Object.entries(e))null!=t&&(r[n]="string"==typeof t||t instanceof HTMLElement||t instanceof SVGElement?t:g(t));return r}(v)),h}"function"==typeof SuppressedError&&SuppressedError;const O=n.forwardRef(function(r,n){const i=t(null),s=t(null),d=t(void 0),a=t(null),l=r;return o(()=>{if(!i.current)return;let e=!1;return queueMicrotask(()=>{if(e||!i.current)return;const r=new c(i.current,S(l));if(r.mount(),s.current=r,n){const e=r.getAPI();"function"==typeof n?n(e):n.current=e}}),()=>{e=!0;const r=s.current;r&&(r.destroy(),s.current=null,d.current=void 0,a.current=null,n&&"function"!=typeof n&&(n.current=null))}},[]),o(()=>{const e=s.current;if(!e)return;if(null!==a.current&&!function(e,r){const n=new Set([...Object.keys(e),...Object.keys(r)]);for(const t of n)if(e[t]!==r[t])return!0;return!1}(a.current,l))return;a.current=l;const r=S(l);queueMicrotask(()=>{if(s.current!==e)return;if(d.current!==l.defaultHeaders)return d.current=l.defaultHeaders,void e.update(r);const n=u(r,["defaultHeaders"]);e.update(n)})},[l]),e("div",{ref:i})});function v(e){return e}function j(e){return e}function h(e){return e}O.displayName="SimpleTable";export{O as SimpleTable,v as defaultHeaderFromCore,j as defaultHeadersFromCore,h as mapToReactHeaderObjects};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -97,6 +97,12 @@ export declare class RenderOrchestrator {
|
|
|
97
97
|
getLastProcessedResult(): ProcessRowsResult | null;
|
|
98
98
|
invalidateCache(type?: "body" | "header" | "context" | "all"): void;
|
|
99
99
|
computeEffectiveHeaders(headers: HeaderObject[], config: SimpleTableConfig, customTheme: CustomTheme, containerWidth?: number): HeaderObject[];
|
|
100
|
+
/**
|
|
101
|
+
* Warms flattened/processed row caches so imperative APIs (e.g. getVisibleRows) are
|
|
102
|
+
* correct before the first ResizeObserver-driven render, without mutating the DOM.
|
|
103
|
+
*/
|
|
104
|
+
primeLastProcessedResult(context: RenderContext, state: RenderState): void;
|
|
105
|
+
private buildRowModelSnapshot;
|
|
100
106
|
render(elements: {
|
|
101
107
|
bodyContainer: HTMLElement;
|
|
102
108
|
content: HTMLElement;
|
|
@@ -11,4 +11,9 @@ export interface HorizontalScrollbarProps {
|
|
|
11
11
|
sectionScrollController?: SectionScrollController | null;
|
|
12
12
|
}
|
|
13
13
|
export declare const createHorizontalScrollbar: (props: HorizontalScrollbarProps) => HTMLElement | null;
|
|
14
|
+
/**
|
|
15
|
+
* Apply width props to an existing scrollbar from {@link createHorizontalScrollbar}.
|
|
16
|
+
* Used when layout is recreated without tearing down the DOM node (e.g. pinned resize).
|
|
17
|
+
*/
|
|
18
|
+
export declare const syncHorizontalScrollbarLayout: (container: HTMLElement, props: HorizontalScrollbarProps) => void;
|
|
14
19
|
export declare const cleanupHorizontalScrollbar: (container: HTMLElement, sectionScrollController?: SectionScrollController | null) => void;
|
|
@@ -21,9 +21,7 @@ export declare function wrapReactColumnEditorCustomRenderer(Component: React.Com
|
|
|
21
21
|
/**
|
|
22
22
|
* Like wrapReactRenderer but uses `display: contents` so layout is unchanged
|
|
23
23
|
* when core appends this node (no extra box vs a plain div).
|
|
24
|
-
*
|
|
25
|
-
* when vanilla renders cells from a React effect, where a deferred nested root
|
|
26
|
-
* would otherwise yield an empty container.
|
|
24
|
+
* Commit scheduling matches {@link wrapReactRenderer} (microtask + flushSync).
|
|
27
25
|
*/
|
|
28
26
|
export declare function wrapReactRendererIntoFragment<P extends object>(Component: React.ComponentType<P>): (props: P) => HTMLElement;
|
|
29
27
|
/**
|
|
@@ -35,8 +33,8 @@ export declare function wrapReactNode(node: React.ReactNode): HTMLElement;
|
|
|
35
33
|
* Converts a ReactNode to an HTML string using server-side static rendering.
|
|
36
34
|
* Used for icon props where the vanilla table expects a string | HTMLElement | SVGSVGElement.
|
|
37
35
|
* Uses renderToStaticMarkup so it works synchronously from any context — including
|
|
38
|
-
* inside a useEffect — unlike createRoot
|
|
39
|
-
* output when
|
|
36
|
+
* inside a useEffect — unlike createRoot alone without a follow-up commit, which
|
|
37
|
+
* can yield empty output when React defers the nested root.
|
|
40
38
|
*/
|
|
41
39
|
export declare function reactNodeToHtmlString(node: React.ReactNode): string;
|
|
42
40
|
/** Returns true if the value is a React component (function or class). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simple-table/react",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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.0.
|
|
32
|
+
"simple-table-core": "3.0.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@rollup/plugin-alias": "^4.0.4",
|