@simple-table/react 3.0.0-beta.24 → 3.0.0-beta.26
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/utils/headerCell/types.d.ts +2 -0
- package/dist/types/core/src/utils/rowSeparatorRenderer.d.ts +4 -0
- package/dist/types/react/src/utils/ImperativeDomSlot.d.ts +24 -0
- package/dist/types/react/src/utils/wrapReactRenderer.d.ts +11 -0
- 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"),r=require("react"),t=require("simple-table-core"),n=require("react-dom"),o=require("react-dom/client"),c=require("react-dom/server");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=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 i(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}function a({node:t}){const n=r.useRef(null);return r.useLayoutEffect(()=>{const e=n.current;if(e)return e.appendChild(t),()=>{t.parentNode===e&&e.removeChild(t)}},[t]),e.jsx("span",{ref:n,style:{display:"contents"}})}function u(r){if(null!=r)return"string"==typeof r?r:r instanceof Node?e.jsx(a,{node:r}):void 0}function d(r){return t=>{const c=document.createElement("div"),s=o.createRoot(c);return n.flushSync(()=>{s.render(e.jsx(r,Object.assign({},t)))}),c}}function l(r){return t=>{const c=document.createElement("div"),s=o.createRoot(c),i=Object.assign(Object.assign({},t),{searchSection:t.searchSection?u(t.searchSection):null,listSection:u(t.listSection),resetSection:t.resetSection?u(t.resetSection):null});return n.flushSync(()=>{s.render(e.jsx(r,Object.assign({},i)))}),c}}function f(r){const t=document.createElement("div");return t.innerHTML=c.renderToStaticMarkup(e.jsx(e.Fragment,{children:r})),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 p(r){return c.renderToStaticMarkup(e.jsx(e.Fragment,{children:r}))}function m(e){return"function"==typeof e}function b(r){const{cellRenderer:t,headerRenderer:c,children:s,nestedTable:a}=r,u=i(r,["cellRenderer","headerRenderer","children","nestedTable"]),l=Object.assign({},u);var f;if(t&&(l.cellRenderer=(f=t,r=>{const t=document.createElement("div");t.style.display="contents";const c=o.createRoot(t);return n.flushSync(()=>{c.render(e.jsx(f,Object.assign({},r)))}),t})),c&&(l.headerRenderer=d(c)),s&&(l.children=s.map(b)),a){const e=Object.assign(Object.assign({},a),{rows:[]});l.nestedTable=R(e)}return l}function R(r){const{defaultHeaders:t,rows:c,footerRenderer:s,emptyStateRenderer:a,errorStateRenderer:R,loadingStateRenderer:y,tableEmptyStateRenderer:S,headerDropdown:g,columnEditorConfig:j,icons:O}=r,v=i(r,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons"]),h=Object.assign(Object.assign({},v),{rows:c,defaultHeaders:t.map(b)});if(void 0!==s&&(h.footerRenderer=d(s)),void 0!==a)if(m(a))h.emptyStateRenderer=d(a);else{const e=a;h.emptyStateRenderer=()=>f(e)}if(void 0!==R)if(m(R))h.errorStateRenderer=d(R);else{const e=R;h.errorStateRenderer=()=>f(e)}if(void 0!==y)if(m(y))h.loadingStateRenderer=d(y);else{const e=y;h.loadingStateRenderer=()=>f(e)}return void 0!==S&&(h.tableEmptyStateRenderer=null===S?null:f(S)),void 0!==g&&(h.headerDropdown=d(g)),void 0!==j&&(h.columnEditorConfig=function(r){const{rowRenderer:t,customRenderer:c}=r,s=i(r,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},s),t?{rowRenderer:(a=t,r=>{const t=document.createElement("div"),c=o.createRoot(t),s=Object.assign(Object.assign({},r),{components:(i=r.components,{expandIcon:u(i.expandIcon),checkbox:u(i.checkbox),dragIcon:u(i.dragIcon),labelContent:u(i.labelContent),pinIcon:u(i.pinIcon)})});var i;return n.flushSync(()=>{c.render(e.jsx(a,Object.assign({},s)))}),t})}:{}),c?{customRenderer:l(c)}:{});var a}(j)),void 0!==O&&(h.icons=function(e){const r={};for(const[t,n]of Object.entries(e))null!=n&&(r[t]="string"==typeof n||n instanceof HTMLElement||n instanceof SVGElement?n:p(n));return r}(O)),h}"function"==typeof SuppressedError&&SuppressedError;const y=s(r).default.forwardRef(function(n,o){const c=r.useRef(null),s=r.useRef(null),a=r.useRef(void 0),u=n;return r.useLayoutEffect(()=>{if(!c.current)return;let e=!1;return queueMicrotask(()=>{if(e||!c.current)return;const r=new t.SimpleTableVanilla(c.current,R(u));if(r.mount(),s.current=r,o){const e=r.getAPI();"function"==typeof o?o(e):o.current=e}}),()=>{e=!0;const r=s.current;r&&(r.destroy(),s.current=null,a.current=void 0,o&&"function"!=typeof o&&(o.current=null))}},[]),r.useLayoutEffect(()=>{const e=s.current;if(!e)return;const r=R(u);queueMicrotask(()=>{if(s.current!==e)return;if(a.current!==u.defaultHeaders)return a.current=u.defaultHeaders,void e.update(r);const t=i(r,["defaultHeaders"]);e.update(t)})}),e.jsx("div",{ref:c})});y.displayName="SimpleTable",Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return t.asRows}}),exports.SimpleTable=y,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
|
|
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 d}from"react-dom/client";import{renderToStaticMarkup as s}from"react-dom/server";function a(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 u({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(u,{node:r}):void 0}function f(r){return n=>{const t=document.createElement("div"),o=d(t);return i(()=>{o.render(e(r,Object.assign({},n)))}),t}}function m(r){return n=>{const t=document.createElement("div"),o=d(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 i(()=>{o.render(e(r,Object.assign({},c)))}),t}}function p(n){const t=document.createElement("div");return t.innerHTML=s(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 b(n){return s(e(r,{children:n}))}function g(e){return"function"==typeof e}function R(r){const{cellRenderer:n,headerRenderer:t,children:o,nestedTable:c}=r,s=a(r,["cellRenderer","headerRenderer","children","nestedTable"]),u=Object.assign({},s);var l;if(n&&(u.cellRenderer=(l=n,r=>{const n=document.createElement("div");n.style.display="contents";const t=d(n);return i(()=>{t.render(e(l,Object.assign({},r)))}),n})),t&&(u.headerRenderer=f(t)),o&&(u.children=o.map(R)),c){const e=Object.assign(Object.assign({},c),{rows:[]});u.nestedTable=y(e)}return u}function y(r){const{defaultHeaders:n,rows:t,footerRenderer:o,emptyStateRenderer:c,errorStateRenderer:s,loadingStateRenderer:u,tableEmptyStateRenderer:y,headerDropdown:S,columnEditorConfig:v,icons:O}=r,h=a(r,["defaultHeaders","rows","footerRenderer","emptyStateRenderer","errorStateRenderer","loadingStateRenderer","tableEmptyStateRenderer","headerDropdown","columnEditorConfig","icons"]),j=Object.assign(Object.assign({},h),{rows:t,defaultHeaders:n.map(R)});if(void 0!==o&&(j.footerRenderer=f(o)),void 0!==c)if(g(c))j.emptyStateRenderer=f(c);else{const e=c;j.emptyStateRenderer=()=>p(e)}if(void 0!==s)if(g(s))j.errorStateRenderer=f(s);else{const e=s;j.errorStateRenderer=()=>p(e)}if(void 0!==u)if(g(u))j.loadingStateRenderer=f(u);else{const e=u;j.loadingStateRenderer=()=>p(e)}return void 0!==y&&(j.tableEmptyStateRenderer=null===y?null:p(y)),void 0!==S&&(j.headerDropdown=f(S)),void 0!==v&&(j.columnEditorConfig=function(r){const{rowRenderer:n,customRenderer:t}=r,o=a(r,["rowRenderer","customRenderer"]);return Object.assign(Object.assign(Object.assign({},o),n?{rowRenderer:(c=n,r=>{const n=document.createElement("div"),t=d(n),o=Object.assign(Object.assign({},r),{components:(s=r.components,{expandIcon:l(s.expandIcon),checkbox:l(s.checkbox),dragIcon:l(s.dragIcon),labelContent:l(s.labelContent),pinIcon:l(s.pinIcon)})});var s;return i(()=>{t.render(e(c,Object.assign({},o)))}),n})}:{}),t?{customRenderer:m(t)}:{});var c}(v)),void 0!==O&&(j.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:b(t));return r}(O)),j}"function"==typeof SuppressedError&&SuppressedError;const S=n.forwardRef(function(r,n){const i=t(null),d=t(null),s=t(void 0),u=r;return o(()=>{if(!i.current)return;let e=!1;return queueMicrotask(()=>{if(e||!i.current)return;const r=new c(i.current,y(u));if(r.mount(),d.current=r,n){const e=r.getAPI();"function"==typeof n?n(e):n.current=e}}),()=>{e=!0;const r=d.current;r&&(r.destroy(),d.current=null,s.current=void 0,n&&"function"!=typeof n&&(n.current=null))}},[]),o(()=>{const e=d.current;if(!e)return;const r=y(u);queueMicrotask(()=>{if(d.current!==e)return;if(s.current!==u.defaultHeaders)return s.current=u.defaultHeaders,void e.update(r);const n=a(r,["defaultHeaders"]);e.update(n)})}),e("div",{ref:i})});function v(e){return e}function O(e){return e}function h(e){return e}S.displayName="SimpleTable";export{S as SimpleTable,v as defaultHeaderFromCore,O as defaultHeadersFromCore,h as mapToReactHeaderObjects};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -39,6 +39,8 @@ export interface HeaderRenderContext {
|
|
|
39
39
|
handleApplyFilter: (filter: FilterCondition) => void;
|
|
40
40
|
handleClearFilter: (accessor: Accessor) => void;
|
|
41
41
|
handleSelectAll?: (checked: boolean) => void;
|
|
42
|
+
/** Live header tree from table state (avoids stale `headers` snapshot in long-lived handlers). */
|
|
43
|
+
getHeaders: () => HeaderObject[];
|
|
42
44
|
headerHeight: number;
|
|
43
45
|
headerRegistry?: Map<string, {
|
|
44
46
|
setEditing: (editing: boolean) => void;
|
|
@@ -7,6 +7,10 @@ export interface CreateRowSeparatorOptions {
|
|
|
7
7
|
heightOffsets?: HeightOffsets;
|
|
8
8
|
customTheme?: CustomTheme;
|
|
9
9
|
isSticky?: boolean;
|
|
10
|
+
/** Same px width as the body/sticky section (`SectionRenderer` / sticky pane); omit to use 100%. */
|
|
11
|
+
sectionWidthPx?: number;
|
|
10
12
|
}
|
|
13
|
+
/** Keep separator width in sync with section layout (resize, pinned width changes). */
|
|
14
|
+
export declare const applyRowSeparatorSectionWidth: (separator: HTMLElement, sectionWidthPx?: number) => void;
|
|
11
15
|
export declare const createRowSeparator: (options: CreateRowSeparatorOptions) => HTMLElement;
|
|
12
16
|
export declare const createSpacerRow: (position: number, rowHeight: number, heightOffsets: HeightOffsets | undefined, customTheme: CustomTheme, className: string, height?: number) => HTMLElement;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ColumnEditorRowRendererComponents as VanillaColumnEditorRowComponents } from "simple-table-core";
|
|
3
|
+
type DomSlotProps = {
|
|
4
|
+
node: Node;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Bridges imperative DOM from simple-table-core into a React subtree. Core passes
|
|
8
|
+
* HTMLElement/SVG nodes as slots; React cannot render those as children directly.
|
|
9
|
+
* This host uses `display: contents` so flex/grid parents still lay out the slot.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ImperativeDomSlot({ node }: DomSlotProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* Converts a core column-editor slot (string markup or a live node) into a ReactNode.
|
|
14
|
+
*/
|
|
15
|
+
export declare function domSlotToReactNode(value: string | Node | null | undefined): React.ReactNode;
|
|
16
|
+
/** Maps core column-editor row slots (live DOM) to React nodes for `rowRenderer` JSX. */
|
|
17
|
+
export declare function mapColumnEditorRowComponentsForReact(components: VanillaColumnEditorRowComponents): {
|
|
18
|
+
expandIcon?: React.ReactNode;
|
|
19
|
+
checkbox?: React.ReactNode;
|
|
20
|
+
dragIcon?: React.ReactNode;
|
|
21
|
+
labelContent?: React.ReactNode;
|
|
22
|
+
pinIcon?: React.ReactNode;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { ColumnEditorCustomRendererProps as VanillaColumnEditorCustomRendererProps, ColumnEditorRowRendererProps as VanillaColumnEditorRowRendererProps } from "simple-table-core";
|
|
2
3
|
/**
|
|
3
4
|
* Wraps a React component into a function that returns an HTMLElement, matching
|
|
4
5
|
* the vanilla renderer contract expected by simple-table-core.
|
|
@@ -7,6 +8,16 @@ import React from "react";
|
|
|
7
8
|
* When core replaces or clears that DOM, the root is detached like other adapters.
|
|
8
9
|
*/
|
|
9
10
|
export declare function wrapReactRenderer<P extends object>(Component: React.ComponentType<P>): (props: P) => HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* Like {@link wrapReactRenderer} for column editor rows: core passes `components.*` as
|
|
13
|
+
* live DOM nodes; this maps them to React hosts so consumers can use normal JSX.
|
|
14
|
+
*/
|
|
15
|
+
export declare function wrapReactColumnEditorRowRenderer(Component: React.ComponentType<object>): (props: VanillaColumnEditorRowRendererProps) => HTMLElement;
|
|
16
|
+
/**
|
|
17
|
+
* Maps `searchSection` / `listSection` / `resetSection` HTMLElement slots for
|
|
18
|
+
* `columnEditorConfig.customRenderer` the same way as row slots.
|
|
19
|
+
*/
|
|
20
|
+
export declare function wrapReactColumnEditorCustomRenderer(Component: React.ComponentType<object>): (props: VanillaColumnEditorCustomRendererProps) => HTMLElement;
|
|
10
21
|
/**
|
|
11
22
|
* Like wrapReactRenderer but uses `display: contents` so layout is unchanged
|
|
12
23
|
* when core appends this node (no extra box vs a plain div).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simple-table/react",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.26",
|
|
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.0-beta.
|
|
32
|
+
"simple-table-core": "3.0.0-beta.26"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@rollup/plugin-alias": "^4.0.4",
|