@tanstack/preact-table 9.0.0-alpha.21 → 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.
Files changed (43) hide show
  1. package/dist/FlexRender.cjs +50 -0
  2. package/dist/FlexRender.cjs.map +1 -0
  3. package/dist/FlexRender.d.cts +51 -0
  4. package/dist/{esm/FlexRender.d.ts → FlexRender.d.ts} +20 -15
  5. package/dist/FlexRender.js +49 -0
  6. package/dist/FlexRender.js.map +1 -0
  7. package/dist/Subscribe.cjs +36 -0
  8. package/dist/Subscribe.cjs.map +1 -0
  9. package/dist/Subscribe.d.cts +49 -0
  10. package/dist/Subscribe.d.ts +49 -0
  11. package/dist/Subscribe.js +36 -0
  12. package/dist/Subscribe.js.map +1 -0
  13. package/dist/createTableHook.cjs +334 -0
  14. package/dist/createTableHook.cjs.map +1 -0
  15. package/dist/createTableHook.d.cts +358 -0
  16. package/dist/createTableHook.d.ts +358 -0
  17. package/dist/createTableHook.js +334 -0
  18. package/dist/createTableHook.js.map +1 -0
  19. package/dist/index.cjs +18 -0
  20. package/dist/index.d.cts +6 -0
  21. package/dist/index.d.ts +6 -0
  22. package/dist/{esm/index.js → index.js} +5 -10
  23. package/dist/useTable.cjs +38 -0
  24. package/dist/useTable.cjs.map +1 -0
  25. package/dist/useTable.d.cts +60 -0
  26. package/dist/useTable.d.ts +60 -0
  27. package/dist/useTable.js +38 -0
  28. package/dist/useTable.js.map +1 -0
  29. package/package.json +11 -13
  30. package/src/useTable.ts +14 -19
  31. package/dist/esm/FlexRender.js +0 -41
  32. package/dist/esm/FlexRender.js.map +0 -1
  33. package/dist/esm/Subscribe.d.ts +0 -44
  34. package/dist/esm/Subscribe.js +0 -9
  35. package/dist/esm/Subscribe.js.map +0 -1
  36. package/dist/esm/createTableHook.d.ts +0 -349
  37. package/dist/esm/createTableHook.js +0 -133
  38. package/dist/esm/createTableHook.js.map +0 -1
  39. package/dist/esm/index.d.ts +0 -5
  40. package/dist/esm/index.js.map +0 -1
  41. package/dist/esm/useTable.d.ts +0 -52
  42. package/dist/esm/useTable.js +0 -46
  43. package/dist/esm/useTable.js.map +0 -1
@@ -0,0 +1,50 @@
1
+ let preact_jsx_runtime = require("preact/jsx-runtime");
2
+
3
+ //#region src/FlexRender.tsx
4
+ function isPreactComponent(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.isPreactComponent;
11
+ })();
12
+ }
13
+ function isExoticComponent(component) {
14
+ return typeof component === "object" && typeof component.$$typeof === "symbol" && ["preact.memo", "preact.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 : isPreactComponent(Comp) ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(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
+ exports.FlexRender = FlexRender;
49
+ exports.flexRender = flexRender;
50
+ //# sourceMappingURL=FlexRender.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlexRender.cjs","names":[],"sources":["../src/FlexRender.tsx"],"sourcesContent":["import type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentChild, ComponentType } from 'preact'\n\nexport type Renderable<TProps> = ComponentChild | ComponentType<TProps>\n\nfunction isPreactComponent<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.isPreactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['preact.memo', 'preact.forward_ref'].includes(\n component.$$typeof.description,\n )\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> | null,\n props: TProps,\n): ComponentChild | Element | null {\n return !Comp ? null : isPreactComponent<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":";;;AAWA,SAAS,kBACP,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,eAAe,qBAAqB,CAAC,SACpC,UAAU,SAAS,YACpB;;;;;;AAQL,SAAgB,WACd,MACA,OACiC;AACjC,QAAO,CAAC,OAAO,OAAO,kBAA0B,KAAK,GACnD,4CAAC,MAAD,EAAM,GAAI,OAAS,IAEnB;;;;;;;;;;;;;;;;;;;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 { ComponentChild, ComponentType } from "preact";
3
+
4
+ //#region src/FlexRender.d.ts
5
+ type Renderable<TProps> = ComponentChild | 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> | null, props: TProps): ComponentChild | Element | null;
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>): ComponentChild;
49
+ //#endregion
50
+ export { FlexRender, FlexRenderProps, Renderable, flexRender };
51
+ //# sourceMappingURL=FlexRender.d.cts.map
@@ -1,11 +1,13 @@
1
- import { Cell, CellData, Header, RowData, TableFeatures } from '@tanstack/table-core';
2
- import { ComponentChild, ComponentType } from 'preact';
3
- export type Renderable<TProps> = ComponentChild | ComponentType<TProps>;
1
+ import { Cell, CellData, Header, RowData, TableFeatures } from "@tanstack/table-core";
2
+ import { ComponentChild, ComponentType } from "preact";
3
+
4
+ //#region src/FlexRender.d.ts
5
+ type Renderable<TProps> = ComponentChild | ComponentType<TProps>;
4
6
  /**
5
7
  * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
6
8
  * @example flexRender(cell.column.columnDef.cell, cell.getContext())
7
9
  */
8
- export declare function flexRender<TProps extends object>(Comp: Renderable<TProps> | null, props: TProps): ComponentChild | Element | null;
10
+ declare function flexRender<TProps extends object>(Comp: Renderable<TProps> | null, props: TProps): ComponentChild | Element | null;
9
11
  /**
10
12
  * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
11
13
  * Only one prop (`cell`, `header`, or `footer`) may be passed.
@@ -13,18 +15,18 @@ export declare function flexRender<TProps extends object>(Comp: Renderable<TProp
13
15
  * @example <FlexRender header={header} />
14
16
  * @example <FlexRender footer={footer} />
15
17
  */
16
- export type FlexRenderProps<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> = {
17
- cell: Cell<TFeatures, TData, TValue>;
18
- header?: never;
19
- footer?: never;
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;
20
22
  } | {
21
- header: Header<TFeatures, TData, TValue>;
22
- cell?: never;
23
- footer?: never;
23
+ header: Header<TFeatures, TData, TValue>;
24
+ cell?: never;
25
+ footer?: never;
24
26
  } | {
25
- footer: Header<TFeatures, TData, TValue>;
26
- cell?: never;
27
- header?: never;
27
+ footer: Header<TFeatures, TData, TValue>;
28
+ cell?: never;
29
+ header?: never;
28
30
  };
29
31
  /**
30
32
  * Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup.
@@ -43,4 +45,7 @@ export type FlexRenderProps<TFeatures extends TableFeatures, TData extends RowDa
43
45
  * flexRender(footer.column.columnDef.footer, footer.getContext())
44
46
  * ```
45
47
  */
46
- export declare function FlexRender<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>): ComponentChild;
48
+ declare function FlexRender<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>): ComponentChild;
49
+ //#endregion
50
+ export { FlexRender, FlexRenderProps, Renderable, flexRender };
51
+ //# sourceMappingURL=FlexRender.d.ts.map
@@ -0,0 +1,49 @@
1
+ import { jsx } from "preact/jsx-runtime";
2
+
3
+ //#region src/FlexRender.tsx
4
+ function isPreactComponent(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.isPreactComponent;
11
+ })();
12
+ }
13
+ function isExoticComponent(component) {
14
+ return typeof component === "object" && typeof component.$$typeof === "symbol" && ["preact.memo", "preact.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 : isPreactComponent(Comp) ? /* @__PURE__ */ jsx(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 type {\n Cell,\n CellData,\n Header,\n RowData,\n TableFeatures,\n} from '@tanstack/table-core'\nimport type { ComponentChild, ComponentType } from 'preact'\n\nexport type Renderable<TProps> = ComponentChild | ComponentType<TProps>\n\nfunction isPreactComponent<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.isPreactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['preact.memo', 'preact.forward_ref'].includes(\n component.$$typeof.description,\n )\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> | null,\n props: TProps,\n): ComponentChild | Element | null {\n return !Comp ? null : isPreactComponent<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":";;;AAWA,SAAS,kBACP,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,eAAe,qBAAqB,CAAC,SACpC,UAAU,SAAS,YACpB;;;;;;AAQL,SAAgB,WACd,MACA,OACiC;AACjC,QAAO,CAAC,OAAO,OAAO,kBAA0B,KAAK,GACnD,oBAAC,MAAD,EAAM,GAAI,OAAS,IAEnB;;;;;;;;;;;;;;;;;;;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,36 @@
1
+ let _tanstack_preact_store = require("@tanstack/preact-store");
2
+
3
+ //#region src/Subscribe.ts
4
+ /**
5
+ * A Preact component that allows you to subscribe to the table state.
6
+ *
7
+ * This is useful for opting into state re-renders for specific parts of the table state.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * // As a standalone component
12
+ * <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
13
+ * {({ rowSelection }) => (
14
+ * <div>Selected rows: {Object.keys(rowSelection).length}</div>
15
+ * )}
16
+ * </Subscribe>
17
+ * ```
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * // As table.Subscribe (table instance method)
22
+ * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
23
+ * {({ rowSelection }) => (
24
+ * <div>Selected rows: {Object.keys(rowSelection).length}</div>
25
+ * )}
26
+ * </table.Subscribe>
27
+ * ```
28
+ */
29
+ function Subscribe(props) {
30
+ const selected = (0, _tanstack_preact_store.useStore)(props.table.store, props.selector);
31
+ return typeof props.children === "function" ? props.children(selected) : props.children;
32
+ }
33
+
34
+ //#endregion
35
+ exports.Subscribe = Subscribe;
36
+ //# sourceMappingURL=Subscribe.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Subscribe.cjs","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["import { useStore } from '@tanstack/preact-store'\nimport type {\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\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 Preact node.\n */\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * A Preact 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>(props: SubscribeProps<TFeatures, TData, TSelected>): ComponentChildren {\n const selected = useStore(props.table.store, props.selector)\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,UAId,OAAuE;CACvE,MAAM,gDAAoB,MAAM,MAAM,OAAO,MAAM,SAAS;AAE5D,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 { ComponentChildren } from "preact";
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 Preact node.
18
+ */
19
+ children: ((state: TSelected) => ComponentChildren) | ComponentChildren;
20
+ };
21
+ /**
22
+ * A Preact 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>): ComponentChildren;
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 { ComponentChildren } from "preact";
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 Preact node.
18
+ */
19
+ children: ((state: TSelected) => ComponentChildren) | ComponentChildren;
20
+ };
21
+ /**
22
+ * A Preact 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>): ComponentChildren;
47
+ //#endregion
48
+ export { Subscribe, SubscribeProps };
49
+ //# sourceMappingURL=Subscribe.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { useStore } from "@tanstack/preact-store";
2
+
3
+ //#region src/Subscribe.ts
4
+ /**
5
+ * A Preact component that allows you to subscribe to the table state.
6
+ *
7
+ * This is useful for opting into state re-renders for specific parts of the table state.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * // As a standalone component
12
+ * <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
13
+ * {({ rowSelection }) => (
14
+ * <div>Selected rows: {Object.keys(rowSelection).length}</div>
15
+ * )}
16
+ * </Subscribe>
17
+ * ```
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * // As table.Subscribe (table instance method)
22
+ * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>
23
+ * {({ rowSelection }) => (
24
+ * <div>Selected rows: {Object.keys(rowSelection).length}</div>
25
+ * )}
26
+ * </table.Subscribe>
27
+ * ```
28
+ */
29
+ function Subscribe(props) {
30
+ const selected = useStore(props.table.store, props.selector);
31
+ return typeof props.children === "function" ? props.children(selected) : props.children;
32
+ }
33
+
34
+ //#endregion
35
+ export { Subscribe };
36
+ //# sourceMappingURL=Subscribe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Subscribe.js","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["import { useStore } from '@tanstack/preact-store'\nimport type {\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentChildren } from 'preact'\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 Preact node.\n */\n children: ((state: TSelected) => ComponentChildren) | ComponentChildren\n}\n\n/**\n * A Preact 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>(props: SubscribeProps<TFeatures, TData, TSelected>): ComponentChildren {\n const selected = useStore(props.table.store, props.selector)\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,UAId,OAAuE;CACvE,MAAM,WAAW,SAAS,MAAM,MAAM,OAAO,MAAM,SAAS;AAE5D,QAAO,OAAO,MAAM,aAAa,aAC7B,MAAM,SAAS,SAAS,GACxB,MAAM"}