@tanstack/react-table 9.0.0-alpha.22 → 9.0.0-alpha.23
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/FlexRender.cjs +52 -0
- package/dist/FlexRender.cjs.map +1 -0
- package/dist/FlexRender.d.cts +51 -0
- package/dist/FlexRender.d.ts +51 -0
- package/dist/FlexRender.js +49 -0
- package/dist/FlexRender.js.map +1 -0
- package/dist/Subscribe.cjs +39 -0
- package/dist/Subscribe.cjs.map +1 -0
- package/dist/Subscribe.d.cts +49 -0
- package/dist/Subscribe.d.ts +49 -0
- package/dist/Subscribe.js +38 -0
- package/dist/Subscribe.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/createTableHook.cjs +313 -0
- package/dist/createTableHook.cjs.map +1 -0
- package/dist/createTableHook.d.cts +358 -0
- package/dist/createTableHook.d.ts +358 -0
- package/dist/createTableHook.js +311 -0
- package/dist/createTableHook.js.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/{esm/index.js → index.js} +5 -10
- package/dist/legacy.cjs +14 -0
- package/dist/legacy.d.cts +2 -0
- package/dist/legacy.d.ts +2 -0
- package/dist/legacy.js +3 -0
- package/dist/useLegacyTable.cjs +167 -0
- package/dist/useLegacyTable.cjs.map +1 -0
- package/dist/useLegacyTable.d.cts +214 -0
- package/dist/{esm/useLegacyTable.d.ts → useLegacyTable.d.ts} +79 -74
- package/dist/useLegacyTable.js +156 -0
- package/dist/useLegacyTable.js.map +1 -0
- package/dist/useTable.cjs +41 -0
- package/dist/useTable.cjs.map +1 -0
- package/dist/useTable.d.cts +60 -0
- package/dist/useTable.d.ts +60 -0
- package/dist/useTable.js +40 -0
- package/dist/useTable.js.map +1 -0
- package/package.json +16 -20
- package/src/createTableHook.tsx +6 -7
- package/dist/esm/FlexRender.d.ts +0 -46
- package/dist/esm/FlexRender.js +0 -39
- package/dist/esm/FlexRender.js.map +0 -1
- package/dist/esm/Subscribe.d.ts +0 -44
- package/dist/esm/Subscribe.js +0 -10
- package/dist/esm/Subscribe.js.map +0 -1
- package/dist/esm/createTableHook.d.ts +0 -349
- package/dist/esm/createTableHook.js +0 -130
- package/dist/esm/createTableHook.js.map +0 -1
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/legacy.d.ts +0 -1
- package/dist/esm/legacy.js +0 -15
- package/dist/esm/legacy.js.map +0 -1
- package/dist/esm/useLegacyTable.js +0 -111
- package/dist/esm/useLegacyTable.js.map +0 -1
- package/dist/esm/useTable.d.ts +0 -55
- package/dist/esm/useTable.js +0 -37
- package/dist/esm/useTable.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
react = require_runtime.__toESM(react);
|
|
4
|
+
|
|
5
|
+
//#region src/FlexRender.tsx
|
|
6
|
+
function isReactComponent(component) {
|
|
7
|
+
return isClassComponent(component) || typeof component === "function" || isExoticComponent(component);
|
|
8
|
+
}
|
|
9
|
+
function isClassComponent(component) {
|
|
10
|
+
return typeof component === "function" && (() => {
|
|
11
|
+
const proto = Object.getPrototypeOf(component);
|
|
12
|
+
return proto.prototype && proto.prototype.isReactComponent;
|
|
13
|
+
})();
|
|
14
|
+
}
|
|
15
|
+
function isExoticComponent(component) {
|
|
16
|
+
return typeof component === "object" && typeof component.$$typeof === "symbol" && ["react.memo", "react.forward_ref"].includes(component.$$typeof.description);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
|
|
20
|
+
* @example flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
21
|
+
*/
|
|
22
|
+
function flexRender(Comp, props) {
|
|
23
|
+
return !Comp ? null : isReactComponent(Comp) ? /* @__PURE__ */ react.default.createElement(Comp, props) : Comp;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
|
|
27
|
+
* Only one prop (`cell`, `header`, or `footer`) may be passed.
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <FlexRender cell={cell} />
|
|
31
|
+
* <FlexRender header={header} />
|
|
32
|
+
* <FlexRender footer={footer} />
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* This replaces calling `flexRender` directly like this:
|
|
36
|
+
* ```tsx
|
|
37
|
+
* flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
38
|
+
* flexRender(header.column.columnDef.header, header.getContext())
|
|
39
|
+
* flexRender(footer.column.columnDef.footer, footer.getContext())
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
function FlexRender(props) {
|
|
43
|
+
if ("cell" in props && props.cell) return flexRender(props.cell.column.columnDef.cell, props.cell.getContext());
|
|
44
|
+
if ("header" in props && props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
|
|
45
|
+
if ("footer" in props && props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.FlexRender = FlexRender;
|
|
51
|
+
exports.flexRender = flexRender;
|
|
52
|
+
//# sourceMappingURL=FlexRender.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlexRender.cjs","names":[],"sources":["../src/FlexRender.tsx"],"sourcesContent":["import React from 'react'\nimport type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentType, JSX, ReactNode } from 'react'\n\nexport type Renderable<TProps> = ReactNode | ComponentType<TProps>\n\nfunction isReactComponent<TProps>(\n component: unknown,\n): component is ComponentType<TProps> {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\n/**\n * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.\n * @example flexRender(cell.column.columnDef.cell, cell.getContext())\n */\nexport function flexRender<TProps extends object>(\n Comp: Renderable<TProps>,\n props: TProps,\n): ReactNode | JSX.Element {\n return !Comp ? null : isReactComponent<TProps>(Comp) ? (\n <Comp {...props} />\n ) : (\n Comp\n )\n}\n\n/**\n * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.\n * Only one prop (`cell`, `header`, or `footer`) may be passed.\n * @example <FlexRender cell={cell} />\n * @example <FlexRender header={header} />\n * @example <FlexRender footer={footer} />\n */\nexport type FlexRenderProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> =\n | { cell: Cell<TFeatures, TData, TValue>; header?: never; footer?: never }\n | {\n header: Header<TFeatures, TData, TValue>\n cell?: never\n footer?: never\n }\n | {\n footer: Header<TFeatures, TData, TValue>\n cell?: never\n header?: never\n }\n\n/**\n * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.\n * Only one prop (`cell`, `header`, or `footer`) may be passed.\n * @example\n * ```tsx\n * <FlexRender cell={cell} />\n * <FlexRender header={header} />\n * <FlexRender footer={footer} />\n * ```\n *\n * This replaces calling `flexRender` directly like this:\n * ```tsx\n * flexRender(cell.column.columnDef.cell, cell.getContext())\n * flexRender(header.column.columnDef.header, header.getContext())\n * flexRender(footer.column.columnDef.footer, footer.getContext())\n * ```\n */\nexport function FlexRender<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(props: FlexRenderProps<TFeatures, TData, TValue>) {\n if ('cell' in props && props.cell) {\n return flexRender(props.cell.column.columnDef.cell, props.cell.getContext())\n }\n if ('header' in props && props.header) {\n return flexRender(\n props.header.column.columnDef.header,\n props.header.getContext(),\n )\n }\n if ('footer' in props && props.footer) {\n return flexRender(\n props.footer.column.columnDef.footer,\n props.footer.getContext(),\n )\n }\n return null\n}\n"],"mappings":";;;;;AAYA,SAAS,iBACP,WACoC;AACpC,QACE,iBAAiB,UAAU,IAC3B,OAAO,cAAc,cACrB,kBAAkB,UAAU;;AAIhC,SAAS,iBAAiB,WAAgB;AACxC,QACE,OAAO,cAAc,qBACd;EACL,MAAM,QAAQ,OAAO,eAAe,UAAU;AAC9C,SAAO,MAAM,aAAa,MAAM,UAAU;KACxC;;AAIR,SAAS,kBAAkB,WAAgB;AACzC,QACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,cAAc,oBAAoB,CAAC,SAAS,UAAU,SAAS,YAAY;;;;;;AAQhF,SAAgB,WACd,MACA,OACyB;AACzB,QAAO,CAAC,OAAO,OAAO,iBAAyB,KAAK,GAClD,4CAAC,MAAS,MAAS,GAEnB;;;;;;;;;;;;;;;;;;;AA6CJ,SAAgB,WAId,OAAkD;AAClD,KAAI,UAAU,SAAS,MAAM,KAC3B,QAAO,WAAW,MAAM,KAAK,OAAO,UAAU,MAAM,MAAM,KAAK,YAAY,CAAC;AAE9E,KAAI,YAAY,SAAS,MAAM,OAC7B,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAEH,KAAI,YAAY,SAAS,MAAM,OAC7B,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAEH,QAAO"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Cell, CellData, Header, RowData, TableFeatures } from "@tanstack/table-core";
|
|
2
|
+
import React, { ComponentType, JSX, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/FlexRender.d.ts
|
|
5
|
+
type Renderable<TProps> = ReactNode | ComponentType<TProps>;
|
|
6
|
+
/**
|
|
7
|
+
* If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
|
|
8
|
+
* @example flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
9
|
+
*/
|
|
10
|
+
declare function flexRender<TProps extends object>(Comp: Renderable<TProps>, props: TProps): ReactNode | JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
|
|
13
|
+
* Only one prop (`cell`, `header`, or `footer`) may be passed.
|
|
14
|
+
* @example <FlexRender cell={cell} />
|
|
15
|
+
* @example <FlexRender header={header} />
|
|
16
|
+
* @example <FlexRender footer={footer} />
|
|
17
|
+
*/
|
|
18
|
+
type FlexRenderProps<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> = {
|
|
19
|
+
cell: Cell<TFeatures, TData, TValue>;
|
|
20
|
+
header?: never;
|
|
21
|
+
footer?: never;
|
|
22
|
+
} | {
|
|
23
|
+
header: Header<TFeatures, TData, TValue>;
|
|
24
|
+
cell?: never;
|
|
25
|
+
footer?: never;
|
|
26
|
+
} | {
|
|
27
|
+
footer: Header<TFeatures, TData, TValue>;
|
|
28
|
+
cell?: never;
|
|
29
|
+
header?: never;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
|
|
33
|
+
* Only one prop (`cell`, `header`, or `footer`) may be passed.
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <FlexRender cell={cell} />
|
|
37
|
+
* <FlexRender header={header} />
|
|
38
|
+
* <FlexRender footer={footer} />
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* This replaces calling `flexRender` directly like this:
|
|
42
|
+
* ```tsx
|
|
43
|
+
* flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
44
|
+
* flexRender(header.column.columnDef.header, header.getContext())
|
|
45
|
+
* flexRender(footer.column.columnDef.footer, footer.getContext())
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function FlexRender<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | JSX.Element | null | undefined;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { FlexRender, FlexRenderProps, Renderable, flexRender };
|
|
51
|
+
//# sourceMappingURL=FlexRender.d.cts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Cell, CellData, Header, RowData, TableFeatures } from "@tanstack/table-core";
|
|
2
|
+
import React, { ComponentType, JSX, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/FlexRender.d.ts
|
|
5
|
+
type Renderable<TProps> = ReactNode | ComponentType<TProps>;
|
|
6
|
+
/**
|
|
7
|
+
* If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
|
|
8
|
+
* @example flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
9
|
+
*/
|
|
10
|
+
declare function flexRender<TProps extends object>(Comp: Renderable<TProps>, props: TProps): ReactNode | JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
|
|
13
|
+
* Only one prop (`cell`, `header`, or `footer`) may be passed.
|
|
14
|
+
* @example <FlexRender cell={cell} />
|
|
15
|
+
* @example <FlexRender header={header} />
|
|
16
|
+
* @example <FlexRender footer={footer} />
|
|
17
|
+
*/
|
|
18
|
+
type FlexRenderProps<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> = {
|
|
19
|
+
cell: Cell<TFeatures, TData, TValue>;
|
|
20
|
+
header?: never;
|
|
21
|
+
footer?: never;
|
|
22
|
+
} | {
|
|
23
|
+
header: Header<TFeatures, TData, TValue>;
|
|
24
|
+
cell?: never;
|
|
25
|
+
footer?: never;
|
|
26
|
+
} | {
|
|
27
|
+
footer: Header<TFeatures, TData, TValue>;
|
|
28
|
+
cell?: never;
|
|
29
|
+
header?: never;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
|
|
33
|
+
* Only one prop (`cell`, `header`, or `footer`) may be passed.
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <FlexRender cell={cell} />
|
|
37
|
+
* <FlexRender header={header} />
|
|
38
|
+
* <FlexRender footer={footer} />
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* This replaces calling `flexRender` directly like this:
|
|
42
|
+
* ```tsx
|
|
43
|
+
* flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
44
|
+
* flexRender(header.column.columnDef.header, header.getContext())
|
|
45
|
+
* flexRender(footer.column.columnDef.footer, footer.getContext())
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function FlexRender<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | JSX.Element | null | undefined;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { FlexRender, FlexRenderProps, Renderable, flexRender };
|
|
51
|
+
//# sourceMappingURL=FlexRender.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/FlexRender.tsx
|
|
4
|
+
function isReactComponent(component) {
|
|
5
|
+
return isClassComponent(component) || typeof component === "function" || isExoticComponent(component);
|
|
6
|
+
}
|
|
7
|
+
function isClassComponent(component) {
|
|
8
|
+
return typeof component === "function" && (() => {
|
|
9
|
+
const proto = Object.getPrototypeOf(component);
|
|
10
|
+
return proto.prototype && proto.prototype.isReactComponent;
|
|
11
|
+
})();
|
|
12
|
+
}
|
|
13
|
+
function isExoticComponent(component) {
|
|
14
|
+
return typeof component === "object" && typeof component.$$typeof === "symbol" && ["react.memo", "react.forward_ref"].includes(component.$$typeof.description);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
|
|
18
|
+
* @example flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
19
|
+
*/
|
|
20
|
+
function flexRender(Comp, props) {
|
|
21
|
+
return !Comp ? null : isReactComponent(Comp) ? /* @__PURE__ */ React.createElement(Comp, props) : Comp;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
|
|
25
|
+
* Only one prop (`cell`, `header`, or `footer`) may be passed.
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <FlexRender cell={cell} />
|
|
29
|
+
* <FlexRender header={header} />
|
|
30
|
+
* <FlexRender footer={footer} />
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* This replaces calling `flexRender` directly like this:
|
|
34
|
+
* ```tsx
|
|
35
|
+
* flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
36
|
+
* flexRender(header.column.columnDef.header, header.getContext())
|
|
37
|
+
* flexRender(footer.column.columnDef.footer, footer.getContext())
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
function FlexRender(props) {
|
|
41
|
+
if ("cell" in props && props.cell) return flexRender(props.cell.column.columnDef.cell, props.cell.getContext());
|
|
42
|
+
if ("header" in props && props.header) return flexRender(props.header.column.columnDef.header, props.header.getContext());
|
|
43
|
+
if ("footer" in props && props.footer) return flexRender(props.footer.column.columnDef.footer, props.footer.getContext());
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { FlexRender, flexRender };
|
|
49
|
+
//# sourceMappingURL=FlexRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlexRender.js","names":[],"sources":["../src/FlexRender.tsx"],"sourcesContent":["import React from 'react'\nimport type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentType, JSX, ReactNode } from 'react'\n\nexport type Renderable<TProps> = ReactNode | ComponentType<TProps>\n\nfunction isReactComponent<TProps>(\n component: unknown,\n): component is ComponentType<TProps> {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\n/**\n * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.\n * @example flexRender(cell.column.columnDef.cell, cell.getContext())\n */\nexport function flexRender<TProps extends object>(\n Comp: Renderable<TProps>,\n props: TProps,\n): ReactNode | JSX.Element {\n return !Comp ? null : isReactComponent<TProps>(Comp) ? (\n <Comp {...props} />\n ) : (\n Comp\n )\n}\n\n/**\n * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.\n * Only one prop (`cell`, `header`, or `footer`) may be passed.\n * @example <FlexRender cell={cell} />\n * @example <FlexRender header={header} />\n * @example <FlexRender footer={footer} />\n */\nexport type FlexRenderProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> =\n | { cell: Cell<TFeatures, TData, TValue>; header?: never; footer?: never }\n | {\n header: Header<TFeatures, TData, TValue>\n cell?: never\n footer?: never\n }\n | {\n footer: Header<TFeatures, TData, TValue>\n cell?: never\n header?: never\n }\n\n/**\n * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.\n * Only one prop (`cell`, `header`, or `footer`) may be passed.\n * @example\n * ```tsx\n * <FlexRender cell={cell} />\n * <FlexRender header={header} />\n * <FlexRender footer={footer} />\n * ```\n *\n * This replaces calling `flexRender` directly like this:\n * ```tsx\n * flexRender(cell.column.columnDef.cell, cell.getContext())\n * flexRender(header.column.columnDef.header, header.getContext())\n * flexRender(footer.column.columnDef.footer, footer.getContext())\n * ```\n */\nexport function FlexRender<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(props: FlexRenderProps<TFeatures, TData, TValue>) {\n if ('cell' in props && props.cell) {\n return flexRender(props.cell.column.columnDef.cell, props.cell.getContext())\n }\n if ('header' in props && props.header) {\n return flexRender(\n props.header.column.columnDef.header,\n props.header.getContext(),\n )\n }\n if ('footer' in props && props.footer) {\n return flexRender(\n props.footer.column.columnDef.footer,\n props.footer.getContext(),\n )\n }\n return null\n}\n"],"mappings":";;;AAYA,SAAS,iBACP,WACoC;AACpC,QACE,iBAAiB,UAAU,IAC3B,OAAO,cAAc,cACrB,kBAAkB,UAAU;;AAIhC,SAAS,iBAAiB,WAAgB;AACxC,QACE,OAAO,cAAc,qBACd;EACL,MAAM,QAAQ,OAAO,eAAe,UAAU;AAC9C,SAAO,MAAM,aAAa,MAAM,UAAU;KACxC;;AAIR,SAAS,kBAAkB,WAAgB;AACzC,QACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,cAAc,oBAAoB,CAAC,SAAS,UAAU,SAAS,YAAY;;;;;;AAQhF,SAAgB,WACd,MACA,OACyB;AACzB,QAAO,CAAC,OAAO,OAAO,iBAAyB,KAAK,GAClD,oCAAC,MAAS,MAAS,GAEnB;;;;;;;;;;;;;;;;;;;AA6CJ,SAAgB,WAId,OAAkD;AAClD,KAAI,UAAU,SAAS,MAAM,KAC3B,QAAO,WAAW,MAAM,KAAK,OAAO,UAAU,MAAM,MAAM,KAAK,YAAY,CAAC;AAE9E,KAAI,YAAY,SAAS,MAAM,OAC7B,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAEH,KAAI,YAAY,SAAS,MAAM,OAC7B,QAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,YAAY,CAC1B;AAEH,QAAO"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
4
|
+
let _tanstack_react_store = require("@tanstack/react-store");
|
|
5
|
+
|
|
6
|
+
//#region src/Subscribe.ts
|
|
7
|
+
/**
|
|
8
|
+
* A React component that allows you to subscribe to the table state.
|
|
9
|
+
*
|
|
10
|
+
* This is useful for opting into state re-renders for specific parts of the table state.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // As a standalone component
|
|
15
|
+
* <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
16
|
+
* {({ rowSelection }) => (
|
|
17
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
18
|
+
* )}
|
|
19
|
+
* </Subscribe>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* // As table.Subscribe (table instance method)
|
|
25
|
+
* <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
26
|
+
* {({ rowSelection }) => (
|
|
27
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
28
|
+
* )}
|
|
29
|
+
* </table.Subscribe>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function Subscribe(props) {
|
|
33
|
+
const selected = (0, _tanstack_react_store.useStore)(props.table.store, props.selector, _tanstack_react_store.shallow);
|
|
34
|
+
return typeof props.children === "function" ? props.children(selected) : props.children;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.Subscribe = Subscribe;
|
|
39
|
+
//# sourceMappingURL=Subscribe.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Subscribe.cjs","names":["shallow"],"sources":["../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { shallow, useStore } from '@tanstack/react-store'\nimport type {\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = {\n /**\n * The table instance to subscribe to. Required when using as a standalone component.\n * Not needed when using as `table.Subscribe`.\n */\n table: Table<TFeatures, TData>\n /**\n * A selector function that selects the part of the table state to subscribe to.\n * This allows for fine-grained reactivity by only re-rendering when the selected state changes.\n */\n selector: (state: NoInfer<TableState<TFeatures>>) => TSelected\n /**\n * The children to render. Can be a function that receives the selected state, or a React node.\n */\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * A React component that allows you to subscribe to the table state.\n *\n * This is useful for opting into state re-renders for specific parts of the table state.\n *\n * @example\n * ```tsx\n * // As a standalone component\n * <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // As table.Subscribe (table instance method)\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </table.Subscribe>\n * ```\n */\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n props: SubscribeProps<TFeatures, TData, TSelected>,\n): ReturnType<FunctionComponent> {\n const selected = useStore(props.table.store, props.selector, shallow)\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,UAKd,OAC+B;CAC/B,MAAM,+CAAoB,MAAM,MAAM,OAAO,MAAM,UAAUA,8BAAQ;AAErE,QAAO,OAAO,MAAM,aAAa,aAC7B,MAAM,SAAS,SAAS,GACxB,MAAM"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NoInfer, RowData, Table, TableFeatures, TableState } from "@tanstack/table-core";
|
|
2
|
+
import { FunctionComponent, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/Subscribe.d.ts
|
|
5
|
+
type SubscribeProps<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}> = {
|
|
6
|
+
/**
|
|
7
|
+
* The table instance to subscribe to. Required when using as a standalone component.
|
|
8
|
+
* Not needed when using as `table.Subscribe`.
|
|
9
|
+
*/
|
|
10
|
+
table: Table<TFeatures, TData>;
|
|
11
|
+
/**
|
|
12
|
+
* A selector function that selects the part of the table state to subscribe to.
|
|
13
|
+
* This allows for fine-grained reactivity by only re-rendering when the selected state changes.
|
|
14
|
+
*/
|
|
15
|
+
selector: (state: NoInfer<TableState<TFeatures>>) => TSelected;
|
|
16
|
+
/**
|
|
17
|
+
* The children to render. Can be a function that receives the selected state, or a React node.
|
|
18
|
+
*/
|
|
19
|
+
children: ((state: TSelected) => ReactNode) | ReactNode;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A React component that allows you to subscribe to the table state.
|
|
23
|
+
*
|
|
24
|
+
* This is useful for opting into state re-renders for specific parts of the table state.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // As a standalone component
|
|
29
|
+
* <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
30
|
+
* {({ rowSelection }) => (
|
|
31
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
32
|
+
* )}
|
|
33
|
+
* </Subscribe>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* // As table.Subscribe (table instance method)
|
|
39
|
+
* <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
40
|
+
* {({ rowSelection }) => (
|
|
41
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
42
|
+
* )}
|
|
43
|
+
* </table.Subscribe>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}>(props: SubscribeProps<TFeatures, TData, TSelected>): ReturnType<FunctionComponent>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { Subscribe, SubscribeProps };
|
|
49
|
+
//# sourceMappingURL=Subscribe.d.cts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NoInfer, RowData, Table, TableFeatures, TableState } from "@tanstack/table-core";
|
|
2
|
+
import { FunctionComponent, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/Subscribe.d.ts
|
|
5
|
+
type SubscribeProps<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}> = {
|
|
6
|
+
/**
|
|
7
|
+
* The table instance to subscribe to. Required when using as a standalone component.
|
|
8
|
+
* Not needed when using as `table.Subscribe`.
|
|
9
|
+
*/
|
|
10
|
+
table: Table<TFeatures, TData>;
|
|
11
|
+
/**
|
|
12
|
+
* A selector function that selects the part of the table state to subscribe to.
|
|
13
|
+
* This allows for fine-grained reactivity by only re-rendering when the selected state changes.
|
|
14
|
+
*/
|
|
15
|
+
selector: (state: NoInfer<TableState<TFeatures>>) => TSelected;
|
|
16
|
+
/**
|
|
17
|
+
* The children to render. Can be a function that receives the selected state, or a React node.
|
|
18
|
+
*/
|
|
19
|
+
children: ((state: TSelected) => ReactNode) | ReactNode;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A React component that allows you to subscribe to the table state.
|
|
23
|
+
*
|
|
24
|
+
* This is useful for opting into state re-renders for specific parts of the table state.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // As a standalone component
|
|
29
|
+
* <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
30
|
+
* {({ rowSelection }) => (
|
|
31
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
32
|
+
* )}
|
|
33
|
+
* </Subscribe>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* // As table.Subscribe (table instance method)
|
|
39
|
+
* <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
40
|
+
* {({ rowSelection }) => (
|
|
41
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
42
|
+
* )}
|
|
43
|
+
* </table.Subscribe>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function Subscribe<TFeatures extends TableFeatures, TData extends RowData, TSelected = {}>(props: SubscribeProps<TFeatures, TData, TSelected>): ReturnType<FunctionComponent>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { Subscribe, SubscribeProps };
|
|
49
|
+
//# sourceMappingURL=Subscribe.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { shallow, useStore } from "@tanstack/react-store";
|
|
4
|
+
|
|
5
|
+
//#region src/Subscribe.ts
|
|
6
|
+
/**
|
|
7
|
+
* A React component that allows you to subscribe to the table state.
|
|
8
|
+
*
|
|
9
|
+
* This is useful for opting into state re-renders for specific parts of the table state.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // As a standalone component
|
|
14
|
+
* <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
15
|
+
* {({ rowSelection }) => (
|
|
16
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
17
|
+
* )}
|
|
18
|
+
* </Subscribe>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // As table.Subscribe (table instance method)
|
|
24
|
+
* <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
|
|
25
|
+
* {({ rowSelection }) => (
|
|
26
|
+
* <div>Selected rows: {Object.keys(rowSelection).length}</div>
|
|
27
|
+
* )}
|
|
28
|
+
* </table.Subscribe>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function Subscribe(props) {
|
|
32
|
+
const selected = useStore(props.table.store, props.selector, shallow);
|
|
33
|
+
return typeof props.children === "function" ? props.children(selected) : props.children;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Subscribe };
|
|
38
|
+
//# sourceMappingURL=Subscribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Subscribe.js","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { shallow, useStore } from '@tanstack/react-store'\nimport type {\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = {\n /**\n * The table instance to subscribe to. Required when using as a standalone component.\n * Not needed when using as `table.Subscribe`.\n */\n table: Table<TFeatures, TData>\n /**\n * A selector function that selects the part of the table state to subscribe to.\n * This allows for fine-grained reactivity by only re-rendering when the selected state changes.\n */\n selector: (state: NoInfer<TableState<TFeatures>>) => TSelected\n /**\n * The children to render. Can be a function that receives the selected state, or a React node.\n */\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * A React component that allows you to subscribe to the table state.\n *\n * This is useful for opting into state re-renders for specific parts of the table state.\n *\n * @example\n * ```tsx\n * // As a standalone component\n * <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // As table.Subscribe (table instance method)\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </table.Subscribe>\n * ```\n */\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n props: SubscribeProps<TFeatures, TData, TSelected>,\n): ReturnType<FunctionComponent> {\n const selected = useStore(props.table.store, props.selector, shallow)\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,UAKd,OAC+B;CAC/B,MAAM,WAAW,SAAS,MAAM,MAAM,OAAO,MAAM,UAAU,QAAQ;AAErE,QAAO,OAAO,MAAM,aAAa,aAC7B,MAAM,SAAS,SAAS,GACxB,MAAM"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|