@tanstack/react-table 9.0.0-alpha.49 → 9.0.0-alpha.52
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.map +1 -1
- package/dist/FlexRender.js.map +1 -1
- package/dist/Subscribe.cjs +0 -1
- package/dist/Subscribe.cjs.map +1 -1
- package/dist/Subscribe.js.map +1 -1
- package/dist/createTableHook.cjs.map +1 -1
- package/dist/createTableHook.js.map +1 -1
- package/dist/reactivity.cjs +0 -1
- package/dist/reactivity.cjs.map +1 -1
- package/dist/reactivity.js.map +1 -1
- package/dist/useLegacyTable.cjs +0 -1
- package/dist/useLegacyTable.cjs.map +1 -1
- package/dist/useLegacyTable.d.cts +2 -3
- package/dist/useLegacyTable.d.ts +2 -3
- package/dist/useLegacyTable.js.map +1 -1
- package/dist/useTable.cjs +0 -1
- package/dist/useTable.cjs.map +1 -1
- package/dist/useTable.d.cts +12 -2
- package/dist/useTable.d.ts +12 -2
- package/dist/useTable.js.map +1 -1
- package/package.json +4 -4
- package/skills/react/compose-with-tanstack-store/SKILL.md +1 -1
- package/skills/react/migrate-v8-to-v9/SKILL.md +4 -4
- package/skills/react/production-readiness/SKILL.md +1 -1
- package/skills/react/table-state/SKILL.md +1 -1
- package/src/useLegacyTable.ts +1 -1
- package/src/useTable.ts +13 -3
package/dist/FlexRender.cjs.map
CHANGED
|
@@ -1 +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 const cell = props.cell\n const def = cell.column.columnDef\n const groupingCell = cell as typeof cell & {\n getIsAggregated?: () => boolean\n getIsPlaceholder?: () => boolean\n }\n const groupingDef = def as typeof def & {\n aggregatedCell?: typeof def.cell\n }\n if (groupingCell.getIsAggregated?.()) {\n return flexRender(\n groupingDef.aggregatedCell ?? def.cell,\n cell.getContext(),\n )\n }\n if (groupingCell.getIsPlaceholder?.()) {\n return null\n }\n return flexRender(def.cell, 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;CACpC,OACE,iBAAiB,
|
|
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 const cell = props.cell\n const def = cell.column.columnDef\n const groupingCell = cell as typeof cell & {\n getIsAggregated?: () => boolean\n getIsPlaceholder?: () => boolean\n }\n const groupingDef = def as typeof def & {\n aggregatedCell?: typeof def.cell\n }\n if (groupingCell.getIsAggregated?.()) {\n return flexRender(\n groupingDef.aggregatedCell ?? def.cell,\n cell.getContext(),\n )\n }\n if (groupingCell.getIsPlaceholder?.()) {\n return null\n }\n return flexRender(def.cell, 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;CACpC,OACE,iBAAiB,SAAS,KAC1B,OAAO,cAAc,cACrB,kBAAkB,SAAS;AAE/B;AAEA,SAAS,iBAAiB,WAAgB;CACxC,OACE,OAAO,cAAc,qBACd;EACL,MAAM,QAAQ,OAAO,eAAe,SAAS;EAC7C,OAAO,MAAM,aAAa,MAAM,UAAU;CAC5C,GAAG;AAEP;AAEA,SAAS,kBAAkB,WAAgB;CACzC,OACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,cAAc,mBAAmB,EAAE,SAAS,UAAU,SAAS,WAAW;AAE/E;;;;;AAMA,SAAgB,WACd,MACA,OACyB;CACzB,OAAO,CAAC,OAAO,OAAO,iBAAyB,IAAI,IACjD,4CAAC,MAAS,KAAQ,IAElB;AAEJ;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,WAId,OAAkD;CAClD,IAAI,UAAU,SAAS,MAAM,MAAM;;EACjC,MAAM,OAAO,MAAM;EACnB,MAAM,MAAM,KAAK,OAAO;EACxB,MAAM,eAAe;EAIrB,MAAM,cAAc;EAGpB,6BAAI,aAAa,gHAAkB,GACjC,OAAO,WACL,YAAY,kBAAkB,IAAI,MAClC,KAAK,WAAW,CAClB;EAEF,6BAAI,aAAa,iHAAmB,GAClC,OAAO;EAET,OAAO,WAAW,IAAI,MAAM,KAAK,WAAW,CAAC;CAC/C;CACA,IAAI,YAAY,SAAS,MAAM,QAC7B,OAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,WAAW,CAC1B;CAEF,IAAI,YAAY,SAAS,MAAM,QAC7B,OAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,WAAW,CAC1B;CAEF,OAAO;AACT"}
|
package/dist/FlexRender.js.map
CHANGED
|
@@ -1 +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 const cell = props.cell\n const def = cell.column.columnDef\n const groupingCell = cell as typeof cell & {\n getIsAggregated?: () => boolean\n getIsPlaceholder?: () => boolean\n }\n const groupingDef = def as typeof def & {\n aggregatedCell?: typeof def.cell\n }\n if (groupingCell.getIsAggregated?.()) {\n return flexRender(\n groupingDef.aggregatedCell ?? def.cell,\n cell.getContext(),\n )\n }\n if (groupingCell.getIsPlaceholder?.()) {\n return null\n }\n return flexRender(def.cell, 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;CACpC,OACE,iBAAiB,
|
|
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 const cell = props.cell\n const def = cell.column.columnDef\n const groupingCell = cell as typeof cell & {\n getIsAggregated?: () => boolean\n getIsPlaceholder?: () => boolean\n }\n const groupingDef = def as typeof def & {\n aggregatedCell?: typeof def.cell\n }\n if (groupingCell.getIsAggregated?.()) {\n return flexRender(\n groupingDef.aggregatedCell ?? def.cell,\n cell.getContext(),\n )\n }\n if (groupingCell.getIsPlaceholder?.()) {\n return null\n }\n return flexRender(def.cell, 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;CACpC,OACE,iBAAiB,SAAS,KAC1B,OAAO,cAAc,cACrB,kBAAkB,SAAS;AAE/B;AAEA,SAAS,iBAAiB,WAAgB;CACxC,OACE,OAAO,cAAc,qBACd;EACL,MAAM,QAAQ,OAAO,eAAe,SAAS;EAC7C,OAAO,MAAM,aAAa,MAAM,UAAU;CAC5C,GAAG;AAEP;AAEA,SAAS,kBAAkB,WAAgB;CACzC,OACE,OAAO,cAAc,YACrB,OAAO,UAAU,aAAa,YAC9B,CAAC,cAAc,mBAAmB,EAAE,SAAS,UAAU,SAAS,WAAW;AAE/E;;;;;AAMA,SAAgB,WACd,MACA,OACyB;CACzB,OAAO,CAAC,OAAO,OAAO,iBAAyB,IAAI,IACjD,oCAAC,MAAS,KAAQ,IAElB;AAEJ;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,WAId,OAAkD;CAClD,IAAI,UAAU,SAAS,MAAM,MAAM;;EACjC,MAAM,OAAO,MAAM;EACnB,MAAM,MAAM,KAAK,OAAO;EACxB,MAAM,eAAe;EAIrB,MAAM,cAAc;EAGpB,6BAAI,aAAa,gHAAkB,GACjC,OAAO,WACL,YAAY,kBAAkB,IAAI,MAClC,KAAK,WAAW,CAClB;EAEF,6BAAI,aAAa,iHAAmB,GAClC,OAAO;EAET,OAAO,WAAW,IAAI,MAAM,KAAK,WAAW,CAAC;CAC/C;CACA,IAAI,YAAY,SAAS,MAAM,QAC7B,OAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,WAAW,CAC1B;CAEF,IAAI,YAAY,SAAS,MAAM,QAC7B,OAAO,WACL,MAAM,OAAO,OAAO,UAAU,QAC9B,MAAM,OAAO,WAAW,CAC1B;CAEF,OAAO;AACT"}
|
package/dist/Subscribe.cjs
CHANGED
package/dist/Subscribe.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subscribe.cjs","names":["shallow"],"sources":["../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport type {\n Atom,\n ReadonlyAtom,\n ReadonlyStore,\n Store,\n} from '@tanstack/react-store'\nimport type { TableFeatures, TableState } from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeSource<TValue> =\n | Atom<TValue>\n | ReadonlyAtom<TValue>\n | Store<TValue>\n | ReadonlyStore<TValue>\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TSelected,\n> = {\n source: SubscribeSource<TableState<TFeatures>>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<TSourceValue> = {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store). The selector\n * receives the source value; children receive the projected `TSelected`.\n */\nexport type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected). Prefer\n * {@link SubscribePropsWithSourceIdentity} or {@link SubscribePropsWithSourceWithSelector}\n * for clearer inference when `selector` is omitted.\n */\nexport type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TSelected>\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\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 * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so JSX\n * contextual typing works. This standalone component uses a union `props` type.\n *\n * @example\n * ```tsx\n * // As a standalone component — full store\n * <Subscribe source={table.store} 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 * // Entire source (atom or store) — no selector\n * <Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // Project source value (e.g. one row’s selection)\n * <Subscribe\n * source={table.atoms.rowSelection}\n * selector={(rowSelection) => rowSelection?.[row.id]}\n * >\n * {(selected) => <tr data-selected={!!selected}>...</tr>}\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<TSourceValue>(\n props: SubscribePropsWithSourceIdentity<TSourceValue>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TSourceValue, TSelected>(\n props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TFeatures extends TableFeatures, TSelected>(\n props: SubscribePropsWithStore<TFeatures, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TSelected, TSourceValue>,\n): ReturnType<FunctionComponent> {\n const selected = useSelector(\n // Atom and store share the same selection protocol; union args need a widen for TS.\n props.source,\n props.selector as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ReactNode)(selected)\n : props.children\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Subscribe.cjs","names":["shallow"],"sources":["../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport type {\n Atom,\n ReadonlyAtom,\n ReadonlyStore,\n Store,\n} from '@tanstack/react-store'\nimport type { TableFeatures, TableState } from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeSource<TValue> =\n | Atom<TValue>\n | ReadonlyAtom<TValue>\n | Store<TValue>\n | ReadonlyStore<TValue>\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TSelected,\n> = {\n source: SubscribeSource<TableState<TFeatures>>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<TSourceValue> = {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store). The selector\n * receives the source value; children receive the projected `TSelected`.\n */\nexport type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected). Prefer\n * {@link SubscribePropsWithSourceIdentity} or {@link SubscribePropsWithSourceWithSelector}\n * for clearer inference when `selector` is omitted.\n */\nexport type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TSelected>\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\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 * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so JSX\n * contextual typing works. This standalone component uses a union `props` type.\n *\n * @example\n * ```tsx\n * // As a standalone component — full store\n * <Subscribe source={table.store} 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 * // Entire source (atom or store) — no selector\n * <Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // Project source value (e.g. one row’s selection)\n * <Subscribe\n * source={table.atoms.rowSelection}\n * selector={(rowSelection) => rowSelection?.[row.id]}\n * >\n * {(selected) => <tr data-selected={!!selected}>...</tr>}\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<TSourceValue>(\n props: SubscribePropsWithSourceIdentity<TSourceValue>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TSourceValue, TSelected>(\n props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TFeatures extends TableFeatures, TSelected>(\n props: SubscribePropsWithStore<TFeatures, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TSelected, TSourceValue>,\n): ReturnType<FunctionComponent> {\n const selected = useSelector(\n // Atom and store share the same selection protocol; union args need a widen for TS.\n props.source,\n props.selector as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ReactNode)(selected)\n : props.children\n}\n"],"mappings":";;;;;AAqIA,SAAgB,UAKd,OAC+B;CAC/B,MAAM,kDAEJ,MAAM,QACN,MAAM,UACN,EACE,SAASA,8BACX,CACF;CAEA,OAAO,OAAO,MAAM,aAAa,aAC5B,MAAM,SAA6C,QAAQ,IAC5D,MAAM;AACZ"}
|
package/dist/Subscribe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Subscribe.js","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport type {\n Atom,\n ReadonlyAtom,\n ReadonlyStore,\n Store,\n} from '@tanstack/react-store'\nimport type { TableFeatures, TableState } from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeSource<TValue> =\n | Atom<TValue>\n | ReadonlyAtom<TValue>\n | Store<TValue>\n | ReadonlyStore<TValue>\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TSelected,\n> = {\n source: SubscribeSource<TableState<TFeatures>>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<TSourceValue> = {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store). The selector\n * receives the source value; children receive the projected `TSelected`.\n */\nexport type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected). Prefer\n * {@link SubscribePropsWithSourceIdentity} or {@link SubscribePropsWithSourceWithSelector}\n * for clearer inference when `selector` is omitted.\n */\nexport type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TSelected>\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\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 * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so JSX\n * contextual typing works. This standalone component uses a union `props` type.\n *\n * @example\n * ```tsx\n * // As a standalone component — full store\n * <Subscribe source={table.store} 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 * // Entire source (atom or store) — no selector\n * <Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // Project source value (e.g. one row’s selection)\n * <Subscribe\n * source={table.atoms.rowSelection}\n * selector={(rowSelection) => rowSelection?.[row.id]}\n * >\n * {(selected) => <tr data-selected={!!selected}>...</tr>}\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<TSourceValue>(\n props: SubscribePropsWithSourceIdentity<TSourceValue>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TSourceValue, TSelected>(\n props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TFeatures extends TableFeatures, TSelected>(\n props: SubscribePropsWithStore<TFeatures, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TSelected, TSourceValue>,\n): ReturnType<FunctionComponent> {\n const selected = useSelector(\n // Atom and store share the same selection protocol; union args need a widen for TS.\n props.source,\n props.selector as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ReactNode)(selected)\n : props.children\n}\n"],"mappings":";;;;;AAqIA,SAAgB,UAKd,OAC+B;CAC/B,MAAM,WAAW,YAEf,MAAM,QACN,MAAM,UACN,EACE,SAAS,
|
|
1
|
+
{"version":3,"file":"Subscribe.js","names":[],"sources":["../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport type {\n Atom,\n ReadonlyAtom,\n ReadonlyStore,\n Store,\n} from '@tanstack/react-store'\nimport type { TableFeatures, TableState } from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeSource<TValue> =\n | Atom<TValue>\n | ReadonlyAtom<TValue>\n | Store<TValue>\n | ReadonlyStore<TValue>\n\n/**\n * Subscribe to `table.store` (full table state). The selector receives the full\n * {@link TableState}.\n */\nexport type SubscribePropsWithStore<\n TFeatures extends TableFeatures,\n TSelected,\n> = {\n source: SubscribeSource<TableState<TFeatures>>\n /**\n * Select from full table state. Re-renders when the selected value changes\n * (shallow compare).\n *\n * Required in store mode so you never accidentally subscribe to the whole\n * store without an explicit projection.\n */\n selector: (state: TableState<TFeatures>) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or\n * `table.optionsStore`). Omitting `selector` is equivalent to the identity\n * selector — children receive `TSourceValue`.\n */\nexport type SubscribePropsWithSourceIdentity<TSourceValue> = {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a projected value from a source (atom or store). The selector\n * receives the source value; children receive the projected `TSelected`.\n */\nexport type SubscribePropsWithSourceWithSelector<TSourceValue, TSelected> = {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * Subscribe to a single source — atom or store (identity or projected). Prefer\n * {@link SubscribePropsWithSourceIdentity} or {@link SubscribePropsWithSourceWithSelector}\n * for clearer inference when `selector` is omitted.\n */\nexport type SubscribePropsWithSource<TSourceValue, TSelected = TSourceValue> =\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TSelected = unknown,\n TSourceValue = unknown,\n> =\n | SubscribePropsWithStore<TFeatures, TSelected>\n | SubscribePropsWithSourceIdentity<TSourceValue>\n | SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>\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 * For `table.Subscribe` from `useTable`, prefer that API — it uses overloads so JSX\n * contextual typing works. This standalone component uses a union `props` type.\n *\n * @example\n * ```tsx\n * // As a standalone component — full store\n * <Subscribe source={table.store} 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 * // Entire source (atom or store) — no selector\n * <Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // Project source value (e.g. one row’s selection)\n * <Subscribe\n * source={table.atoms.rowSelection}\n * selector={(rowSelection) => rowSelection?.[row.id]}\n * >\n * {(selected) => <tr data-selected={!!selected}>...</tr>}\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<TSourceValue>(\n props: SubscribePropsWithSourceIdentity<TSourceValue>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TSourceValue, TSelected>(\n props: SubscribePropsWithSourceWithSelector<TSourceValue, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<TFeatures extends TableFeatures, TSelected>(\n props: SubscribePropsWithStore<TFeatures, TSelected>,\n): ReturnType<FunctionComponent>\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TSelected,\n TSourceValue,\n>(\n props: SubscribeProps<TFeatures, TSelected, TSourceValue>,\n): ReturnType<FunctionComponent> {\n const selected = useSelector(\n // Atom and store share the same selection protocol; union args need a widen for TS.\n props.source,\n props.selector as Parameters<typeof useSelector>[1],\n {\n compare: shallow,\n },\n ) as TSelected\n\n return typeof props.children === 'function'\n ? (props.children as (state: TSelected) => ReactNode)(selected)\n : props.children\n}\n"],"mappings":";;;;;AAqIA,SAAgB,UAKd,OAC+B;CAC/B,MAAM,WAAW,YAEf,MAAM,QACN,MAAM,UACN,EACE,SAAS,QACX,CACF;CAEA,OAAO,OAAO,MAAM,aAAa,aAC5B,MAAM,SAA6C,QAAQ,IAC5D,MAAM;AACZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTableHook.cjs","names":["FlexRender","useTable"],"sources":["../src/createTableHook.tsx"],"sourcesContent":["'use client'\n/* eslint-disable @eslint-react/no-context-provider */\nimport React, { createContext, useContext, useMemo } from 'react'\nimport { createColumnHelper as coreCreateColumnHelper } from '@tanstack/table-core'\nimport { useTable } from './useTable'\nimport { FlexRender } from './FlexRender'\nimport type {\n AccessorFn,\n AccessorFnColumnDef,\n AccessorKeyColumnDef,\n Cell,\n CellContext,\n CellData,\n Column,\n ColumnDef,\n DeepKeys,\n DeepValue,\n DisplayColumnDef,\n GroupColumnDef,\n Header,\n IdentifiedColumnDef,\n NoInfer,\n Row,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentType, ReactNode } from 'react'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// Enhanced Context Types with Pre-bound Components\n// =============================================================================\n\n/**\n * Enhanced CellContext with pre-bound cell components.\n * The `cell` property includes the registered cellComponents.\n */\nexport type AppCellContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> = {\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode }\n column: Column<TFeatures, TData, TValue>\n getValue: CellContext<TFeatures, TData, TValue>['getValue']\n renderValue: CellContext<TFeatures, TData, TValue>['renderValue']\n row: Row<TFeatures, TData>\n table: Table<TFeatures, TData>\n}\n\n/**\n * Enhanced HeaderContext with pre-bound header components.\n * The `header` property includes the registered headerComponents.\n */\nexport type AppHeaderContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n column: Column<TFeatures, TData, TValue>\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode }\n table: Table<TFeatures, TData>\n}\n\n// =============================================================================\n// Enhanced Column Definition Types\n// =============================================================================\n\n/**\n * Template type for column definitions that can be a string or a function.\n */\nexport type AppColumnDefTemplate<TProps extends object> =\n | string\n | ((props: TProps) => any)\n\n/**\n * Enhanced column definition base with pre-bound components in cell/header/footer contexts.\n */\nexport type AppColumnDefBase<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n IdentifiedColumnDef<TFeatures, TData, TValue>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, TValue, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n}\n\n/**\n * Enhanced display column definition with pre-bound components.\n */\nexport type AppDisplayColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n DisplayColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n}\n\n/**\n * Enhanced group column definition with pre-bound components.\n */\nexport type AppGroupColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n GroupColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer' | 'columns'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n columns?: Array<ColumnDef<TFeatures, TData, unknown>>\n}\n\n// =============================================================================\n// Enhanced Column Helper Type\n// =============================================================================\n\n/**\n * Enhanced column helper with pre-bound components in cell/header/footer contexts.\n * This enables TypeScript to know about the registered components when defining columns.\n */\nexport type AppColumnHelper<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n /**\n * Creates a data column definition with an accessor key or function.\n * The cell, header, and footer contexts include pre-bound components.\n */\n accessor: <\n TAccessor extends AccessorFn<TData> | DeepKeys<TData>,\n TValue extends TAccessor extends AccessorFn<TData, infer TReturn>\n ? TReturn\n : TAccessor extends DeepKeys<TData>\n ? DeepValue<TData, TAccessor>\n : never,\n >(\n accessor: TAccessor,\n column: TAccessor extends AccessorFn<TData>\n ? AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n > & { id: string }\n : AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n >,\n ) => TAccessor extends AccessorFn<TData>\n ? AccessorFnColumnDef<TFeatures, TData, TValue>\n : AccessorKeyColumnDef<TFeatures, TData, TValue>\n\n /**\n * Wraps an array of column definitions to preserve each column's individual TValue type.\n */\n columns: <TColumns extends ReadonlyArray<ColumnDef<TFeatures, TData, any>>>(\n columns: [...TColumns],\n ) => Array<ColumnDef<TFeatures, TData, any>> & [...TColumns]\n\n /**\n * Creates a display column definition for non-data columns.\n * The cell, header, and footer contexts include pre-bound components.\n */\n display: (\n column: AppDisplayColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => DisplayColumnDef<TFeatures, TData, unknown>\n\n /**\n * Creates a group column definition with nested child columns.\n * The cell, header, and footer contexts include pre-bound components.\n */\n group: (\n column: AppGroupColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => GroupColumnDef<TFeatures, TData, unknown>\n}\n\n// =============================================================================\n// CreateTableHook Options and Props\n// =============================================================================\n\n/**\n * Options for creating a table hook with pre-bound components and default table options.\n * Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initialState'.\n */\nexport type CreateTableHookOptions<\n TFeatures extends TableFeatures,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n> & {\n /**\n * Table-level components that need access to the table instance.\n * These are available directly on the table object returned by useAppTable.\n * Use `useTableContext()` inside these components.\n * @example { PaginationControls, GlobalFilter, RowCount }\n */\n tableComponents?: TTableComponents\n /**\n * Cell-level components that need access to the cell instance.\n * These are available on the cell object passed to AppCell's children.\n * Use `useCellContext()` inside these components.\n * @example { TextCell, NumberCell, DateCell, CurrencyCell }\n */\n cellComponents?: TCellComponents\n /**\n * Header-level components that need access to the header instance.\n * These are available on the header object passed to AppHeader/AppFooter's children.\n * Use `useHeaderContext()` inside these components.\n * @example { SortIndicator, ColumnFilter, ResizeHandle }\n */\n headerComponents?: THeaderComponents\n}\n\n/**\n * Props for AppTable component - without selector\n */\nexport interface AppTablePropsWithoutSelector {\n children: ReactNode\n selector?: never\n}\n\n/**\n * Props for AppTable component - with selector\n */\nexport interface AppTablePropsWithSelector<\n TFeatures extends TableFeatures,\n TSelected,\n> {\n children: (state: TSelected) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Props for AppCell component - without selector\n */\nexport interface AppCellPropsWithoutSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> {\n cell: Cell<TFeatures, TData, TValue>\n children: (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n selector?: never\n}\n\n/**\n * Props for AppCell component - with selector\n */\nexport interface AppCellPropsWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n TSelected,\n> {\n cell: Cell<TFeatures, TData, TValue>\n children: (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n state: TSelected,\n ) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Props for AppHeader/AppFooter component - without selector\n */\nexport interface AppHeaderPropsWithoutSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> {\n header: Header<TFeatures, TData, TValue>\n children: (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n selector?: never\n}\n\n/**\n * Props for AppHeader/AppFooter component - with selector\n */\nexport interface AppHeaderPropsWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n TSelected,\n> {\n header: Header<TFeatures, TData, TValue>\n children: (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TSelected,\n ) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Component type for AppCell - wraps a cell and provides cell context with optional Subscribe\n */\nexport interface AppCellComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> {\n <TValue extends CellData = CellData>(\n props: AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >,\n ): ReactNode\n <TValue extends CellData = CellData, TSelected = unknown>(\n props: AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TSelected\n >,\n ): ReactNode\n}\n\n/**\n * Component type for AppHeader/AppFooter - wraps a header and provides header context with optional Subscribe\n */\nexport interface AppHeaderComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> {\n <TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n <TValue extends CellData = CellData, TSelected = unknown>(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TSelected\n >,\n ): ReactNode\n}\n\n/**\n * Component type for AppTable - root wrapper with optional Subscribe\n */\nexport interface AppTableComponent<TFeatures extends TableFeatures> {\n (props: AppTablePropsWithoutSelector): ReactNode\n <TSelected>(props: AppTablePropsWithSelector<TFeatures, TSelected>): ReactNode\n}\n\n/**\n * Extended table API returned by useAppTable with all App wrapper components\n */\nexport type AppReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = ReactTable<TFeatures, TData, TSelected> &\n NoInfer<TTableComponents> & {\n /**\n * Root wrapper component that provides table context with optional Subscribe.\n * @example\n * ```tsx\n * // Without selector - children is ReactNode\n * <table.AppTable>\n * <table>...</table>\n * </table.AppTable>\n *\n * // With selector - children receives selected state\n * <table.AppTable selector={(s) => s.pagination}>\n * {(pagination) => <div>Page {pagination.pageIndex}</div>}\n * </table.AppTable>\n * ```\n */\n AppTable: AppTableComponent<TFeatures>\n /**\n * Wraps a cell and provides cell context with pre-bound cellComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * // Without selector\n * <table.AppCell cell={cell}>\n * {(c) => <td><c.TextCell /></td>}\n * </table.AppCell>\n *\n * // With selector - children receives cell and selected state\n * <table.AppCell cell={cell} selector={(s) => s.columnFilters}>\n * {(c, filters) => <td>{filters.length}</td>}\n * </table.AppCell>\n * ```\n */\n AppCell: AppCellComponent<TFeatures, TData, NoInfer<TCellComponents>>\n /**\n * Wraps a header and provides header context with pre-bound headerComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * // Without selector\n * <table.AppHeader header={header}>\n * {(h) => <th><h.SortIndicator /></th>}\n * </table.AppHeader>\n *\n * // With selector\n * <table.AppHeader header={header} selector={(s) => s.sorting}>\n * {(h, sorting) => <th>{sorting.length} sorted</th>}\n * </table.AppHeader>\n * ```\n */\n AppHeader: AppHeaderComponent<TFeatures, TData, NoInfer<THeaderComponents>>\n /**\n * Wraps a footer and provides header context with pre-bound headerComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * <table.AppFooter header={footer}>\n * {(f) => <td><table.FlexRender footer={footer} /></td>}\n * </table.AppFooter>\n * ```\n */\n AppFooter: AppHeaderComponent<TFeatures, TData, NoInfer<THeaderComponents>>\n }\n\n/**\n * Creates a custom table hook with pre-bound components for composition.\n *\n * This is the table equivalent of TanStack Form's `createFormHook`. It allows you to:\n * - Define features, row models, and default options once, shared across all tables\n * - Register reusable table, cell, and header components\n * - Access table/cell/header instances via context in those components\n * - Get a `useAppTable` hook that returns an extended table with App wrapper components\n * - Get a `createAppColumnHelper` function pre-bound to your features\n *\n * @example\n * ```tsx\n * // hooks/table.ts\n * export const {\n * useAppTable,\n * createAppColumnHelper,\n * useTableContext,\n * useCellContext,\n * useHeaderContext,\n * } = createTableHook({\n * _features: tableFeatures({\n * rowPaginationFeature,\n * rowSortingFeature,\n * columnFilteringFeature,\n * }),\n * _rowModels: {\n * paginatedRowModel: createPaginatedRowModel(),\n * sortedRowModel: createSortedRowModel(sortFns),\n * filteredRowModel: createFilteredRowModel(filterFns),\n * },\n * tableComponents: { PaginationControls, RowCount },\n * cellComponents: { TextCell, NumberCell },\n * headerComponents: { SortIndicator, ColumnFilter },\n * })\n *\n * // Create column helper with TFeatures already bound\n * const columnHelper = createAppColumnHelper<Person>()\n *\n * // components/table-components.tsx\n * function PaginationControls() {\n * const table = useTableContext() // TFeatures already known!\n * return <table.Subscribe selector={(s) => s.pagination}>...</table.Subscribe>\n * }\n *\n * // features/users.tsx\n * function UsersTable({ data }: { data: Person[] }) {\n * const table = useAppTable({\n * columns,\n * data, // TData inferred from Person[]\n * })\n *\n * return (\n * <table.AppTable>\n * <table>\n * <thead>\n * {table.getHeaderGroups().map(headerGroup => (\n * <tr key={headerGroup.id}>\n * {headerGroup.headers.map(h => (\n * <table.AppHeader header={h} key={h.id}>\n * {(header) => (\n * <th>\n * <table.FlexRender header={h} />\n * <header.SortIndicator />\n * </th>\n * )}\n * </table.AppHeader>\n * ))}\n * </tr>\n * ))}\n * </thead>\n * <tbody>\n * {table.getRowModel().rows.map(row => (\n * <tr key={row.id}>\n * {row.getAllCells().map(c => (\n * <table.AppCell cell={c} key={c.id}>\n * {(cell) => <td><cell.TextCell /></td>}\n * </table.AppCell>\n * ))}\n * </tr>\n * ))}\n * </tbody>\n * </table>\n * <table.PaginationControls />\n * </table.AppTable>\n * )\n * }\n * ```\n */\nexport function createTableHook<\n TFeatures extends TableFeatures,\n const TTableComponents extends Record<string, ComponentType<any>>,\n const TCellComponents extends Record<string, ComponentType<any>>,\n const THeaderComponents extends Record<string, ComponentType<any>>,\n>({\n tableComponents,\n cellComponents,\n headerComponents,\n ...defaultTableOptions\n}: CreateTableHookOptions<\n TFeatures,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n>) {\n // Create contexts internally with TFeatures baked in\n const TableContext = createContext<ReactTable<TFeatures, any, any>>(\n null as never,\n )\n const CellContext = createContext<Cell<TFeatures, any, any>>(null as never)\n const HeaderContext = createContext<Header<TFeatures, any, any>>(\n null as never,\n )\n\n /**\n * Create a column helper pre-bound to the features and components configured in this table hook.\n * The cell, header, and footer contexts include pre-bound components (e.g., `cell.TextCell`).\n * @example\n * ```tsx\n * const columnHelper = createAppColumnHelper<Person>()\n *\n * const columns = [\n * columnHelper.accessor('firstName', {\n * header: 'First Name',\n * cell: ({ cell }) => <cell.TextCell />, // cell has pre-bound components!\n * }),\n * columnHelper.accessor('age', {\n * header: 'Age',\n * cell: ({ cell }) => <cell.NumberCell />,\n * }),\n * ]\n * ```\n */\n function createAppColumnHelper<TData extends RowData>(): AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n > {\n // The runtime implementation is the same - components are attached at render time\n // This cast provides the enhanced types for column definitions\n return coreCreateColumnHelper<TFeatures, TData>() as AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >\n }\n\n /**\n * Access the table instance from within an `AppTable` wrapper.\n * Use this in custom `tableComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function PaginationControls() {\n * const table = useTableContext()\n * return (\n * <table.Subscribe selector={(s) => s.pagination}>\n * {(pagination) => (\n * <div>\n * <button onClick={() => table.previousPage()}>Prev</button>\n * <span>Page {pagination.pageIndex + 1}</span>\n * <button onClick={() => table.nextPage()}>Next</button>\n * </div>\n * )}\n * </table.Subscribe>\n * )\n * }\n * ```\n */\n function useTableContext<TData extends RowData = RowData>(): ReactTable<\n TFeatures,\n TData\n > {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const table = useContext(TableContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!table) {\n throw new Error(\n '`useTableContext` must be used within an `AppTable` component. ' +\n 'Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.',\n )\n }\n\n return table as ReactTable<TFeatures, TData>\n }\n\n /**\n * Access the cell instance from within an `AppCell` wrapper.\n * Use this in custom `cellComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function TextCell() {\n * const cell = useCellContext<string>()\n * return <span>{cell.getValue()}</span>\n * }\n *\n * function NumberCell({ format }: { format?: Intl.NumberFormatOptions }) {\n * const cell = useCellContext<number>()\n * return <span>{cell.getValue().toLocaleString(undefined, format)}</span>\n * }\n * ```\n */\n function useCellContext<TValue extends CellData = CellData>() {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const cell = useContext(CellContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!cell) {\n throw new Error(\n '`useCellContext` must be used within an `AppCell` component. ' +\n 'Make sure your component is wrapped with `<table.AppCell cell={cell}>...</table.AppCell>`.',\n )\n }\n\n return cell as Cell<TFeatures, any, TValue>\n }\n\n /**\n * Access the header instance from within an `AppHeader` or `AppFooter` wrapper.\n * Use this in custom `headerComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function SortIndicator() {\n * const header = useHeaderContext()\n * const sorted = header.column.getIsSorted()\n * return sorted === 'asc' ? '🔼' : sorted === 'desc' ? '🔽' : null\n * }\n *\n * function ColumnFilter() {\n * const header = useHeaderContext()\n * if (!header.column.getCanFilter()) return null\n * return (\n * <input\n * value={(header.column.getFilterValue() ?? '') as string}\n * onChange={(e) => header.column.setFilterValue(e.target.value)}\n * placeholder=\"Filter...\"\n * />\n * )\n * }\n * ```\n */\n function useHeaderContext<TValue extends CellData = CellData>() {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const header = useContext(HeaderContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!header) {\n throw new Error(\n '`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.',\n )\n }\n\n return header as Header<TFeatures, any, TValue>\n }\n\n /**\n * Context-aware FlexRender component for cells.\n * Uses the cell from context, so no need to pass cell prop.\n */\n function CellFlexRender() {\n const cell = useCellContext()\n return <FlexRender cell={cell} />\n }\n\n /**\n * Context-aware FlexRender component for headers.\n * Uses the header from context, so no need to pass header prop.\n */\n function HeaderFlexRender() {\n const header = useHeaderContext()\n return <FlexRender header={header} />\n }\n\n /**\n * Context-aware FlexRender component for footers.\n * Uses the header from context, so no need to pass footer prop.\n */\n function FooterFlexRender() {\n const header = useHeaderContext()\n return <FlexRender footer={header} />\n }\n\n /**\n * Enhanced useTable hook that returns a table with App wrapper components\n * and pre-bound tableComponents attached directly to the table object.\n *\n * Default options from createTableHook are automatically merged with\n * the options passed here. Options passed here take precedence.\n *\n * TFeatures is already known from the createTableHook call; TData is inferred from the data prop.\n */\n function useAppTable<\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n >(\n tableOptions: Omit<\n TableOptions<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: (state: TableState<TFeatures>) => TSelected,\n ): AppReactTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n > {\n // Merge default options with provided options (provided takes precedence)\n const table = useTable<TFeatures, TData, TSelected>(\n { ...defaultTableOptions, ...tableOptions } as TableOptions<\n TFeatures,\n TData\n >,\n selector,\n )\n\n // AppTable - Root wrapper that provides table context with optional Subscribe\n const AppTable = useMemo(() => {\n function AppTableImpl(props: AppTablePropsWithoutSelector): ReactNode\n function AppTableImpl<TAppTableSelected>(\n props: AppTablePropsWithSelector<TFeatures, TAppTableSelected>,\n ): ReactNode\n function AppTableImpl<TAppTableSelected>(\n props:\n | AppTablePropsWithoutSelector\n | AppTablePropsWithSelector<TFeatures, TAppTableSelected>,\n ): ReactNode {\n const { children, selector: appTableSelector } = props\n\n return (\n <TableContext.Provider value={table}>\n {appTableSelector ? (\n <table.Subscribe selector={appTableSelector}>\n {(state: TAppTableSelected) =>\n (children as (state: TAppTableSelected) => ReactNode)(state)\n }\n </table.Subscribe>\n ) : (\n children\n )}\n </TableContext.Provider>\n )\n }\n return AppTableImpl as AppTableComponent<TFeatures>\n }, [table])\n\n // AppCell - Wraps cell with context, pre-bound cellComponents, and optional Subscribe\n const AppCell = useMemo(() => {\n function AppCellImpl<TValue extends CellData = CellData>(\n props: AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >,\n ): ReactNode\n function AppCellImpl<\n TValue extends CellData = CellData,\n TAppCellSelected = unknown,\n >(\n props: AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TAppCellSelected\n >,\n ): ReactNode\n function AppCellImpl<\n TValue extends CellData = CellData,\n TAppCellSelected = unknown,\n >(\n props:\n | AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >\n | AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TAppCellSelected\n >,\n ): ReactNode {\n const { cell, children, selector: appCellSelector } = props as any\n const extendedCell = Object.assign(cell, {\n FlexRender: CellFlexRender,\n ...cellComponents,\n })\n\n return (\n <CellContext.Provider value={cell}>\n {appCellSelector ? (\n <table.Subscribe selector={appCellSelector}>\n {(state: TAppCellSelected) =>\n (\n children as (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n state: TAppCellSelected,\n ) => ReactNode\n )(extendedCell, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedCell)\n )}\n </CellContext.Provider>\n )\n }\n return AppCellImpl as AppCellComponent<TFeatures, TData, TCellComponents>\n }, [table])\n\n // AppHeader - Wraps header with context, pre-bound headerComponents, and optional Subscribe\n const AppHeader = useMemo(() => {\n function AppHeaderImpl<TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n function AppHeaderImpl<\n TValue extends CellData = CellData,\n TAppHeaderSelected = unknown,\n >(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppHeaderSelected\n >,\n ): ReactNode\n function AppHeaderImpl<\n TValue extends CellData = CellData,\n TAppHeaderSelected = unknown,\n >(\n props:\n | AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >\n | AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppHeaderSelected\n >,\n ): ReactNode {\n const { header, children, selector: appHeaderSelector } = props as any\n const extendedHeader = Object.assign(header, {\n FlexRender: HeaderFlexRender,\n ...headerComponents,\n })\n\n return (\n <HeaderContext.Provider value={header}>\n {appHeaderSelector ? (\n <table.Subscribe selector={appHeaderSelector}>\n {(state: TAppHeaderSelected) =>\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TAppHeaderSelected,\n ) => ReactNode\n )(extendedHeader, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedHeader)\n )}\n </HeaderContext.Provider>\n )\n }\n return AppHeaderImpl as AppHeaderComponent<\n TFeatures,\n TData,\n THeaderComponents\n >\n }, [table])\n\n // AppFooter - Same as AppHeader (footers use Header type)\n const AppFooter = useMemo(() => {\n function AppFooterImpl<TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n function AppFooterImpl<\n TValue extends CellData = CellData,\n TAppFooterSelected = unknown,\n >(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppFooterSelected\n >,\n ): ReactNode\n function AppFooterImpl<\n TValue extends CellData = CellData,\n TAppFooterSelected = unknown,\n >(\n props:\n | AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >\n | AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppFooterSelected\n >,\n ): ReactNode {\n const { header, children, selector: appFooterSelector } = props as any\n const extendedHeader = Object.assign(header, {\n FlexRender: FooterFlexRender,\n ...headerComponents,\n })\n\n return (\n <HeaderContext.Provider value={header}>\n {appFooterSelector ? (\n <table.Subscribe selector={appFooterSelector}>\n {(state: TAppFooterSelected) =>\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TAppFooterSelected,\n ) => ReactNode\n )(extendedHeader, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedHeader)\n )}\n </HeaderContext.Provider>\n )\n }\n return AppFooterImpl as AppHeaderComponent<\n TFeatures,\n TData,\n THeaderComponents\n >\n }, [table])\n\n // Combine everything into the extended table API\n const extendedTable = useMemo(() => {\n return Object.assign(table, {\n AppTable,\n AppCell,\n AppHeader,\n AppFooter,\n ...tableComponents,\n }) as AppReactTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n >\n }, [table, AppTable, AppCell, AppHeader, AppFooter])\n\n return extendedTable\n }\n\n return {\n appFeatures: defaultTableOptions._features as TFeatures,\n createAppColumnHelper,\n useAppTable,\n useTableContext,\n useCellContext,\n useHeaderContext,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6kBA,SAAgB,gBAKd,EACA,iBACA,gBACA,kBACA,GAAG,uBAMF;CAED,MAAM,wCACJ,KACD;CACD,MAAM,uCAAuD,KAAc;CAC3E,MAAM,yCACJ,KACD;;;;;;;;;;;;;;;;;;;;CAqBD,SAAS,wBAKP;EAGA,qDAAiD;;;;;;;;;;;;;;;;;;;;;;;;;CA+BnD,SAAS,kBAGP;EAGA,MAAM,8BAAmB,aAAa;EAGtC,IAAI,CAAC,OACH,MAAM,IAAI,MACR,kJAED;EAGH,OAAO;;;;;;;;;;;;;;;;;;;;CAqBT,SAAS,iBAAqD;EAG5D,MAAM,6BAAkB,YAAY;EAGpC,IAAI,CAAC,MACH,MAAM,IAAI,MACR,0JAED;EAGH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BT,SAAS,mBAAuD;EAG9D,MAAM,+BAAoB,cAAc;EAGxC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,kFACD;EAGH,OAAO;;;;;;CAOT,SAAS,iBAAiB;EACxB,MAAM,OAAO,gBAAgB;EAC7B,OAAO,4CAACA,+BAAD,EAAkB,MAAQ;;;;;;CAOnC,SAAS,mBAAmB;EAC1B,MAAM,SAAS,kBAAkB;EACjC,OAAO,4CAACA,+BAAD,EAAoB,QAAU;;;;;;CAOvC,SAAS,mBAAmB;EAC1B,MAAM,SAAS,kBAAkB;EACjC,OAAO,4CAACA,+BAAD,EAAY,QAAQ,QAAU;;;;;;;;;;;CAYvC,SAAS,YAIP,cAIA,UAQA;EAEA,MAAM,QAAQC,0BACZ;GAAE,GAAG;GAAqB,GAAG;GAAc,EAI3C,SACD;EAGD,MAAM,oCAAyB;GAK7B,SAAS,aACP,OAGW;IACX,MAAM,EAAE,UAAU,UAAU,qBAAqB;IAEjD,OACE,4CAAC,aAAa,UAAd,EAAuB,OAAO,OAUN,EATrB,mBACC,4CAAC,MAAM,WAAP,EAAiB,UAAU,kBAIT,GAHd,UACC,SAAqD,MAAM,CAE9C,GAElB,SAEoB;;GAG5B,OAAO;KACN,CAAC,MAAM,CAAC;EAGX,MAAM,mCAAwB;GAqB5B,SAAS,YAIP,OAcW;IACX,MAAM,EAAE,MAAM,UAAU,UAAU,oBAAoB;IACtD,MAAM,eAAe,OAAO,OAAO,MAAM;KACvC,YAAY;KACZ,GAAG;KACJ,CAAC;IAEF,OACE,4CAAC,YAAY,UAAb,EAAsB,OAAO,MAqBN,EApBpB,kBACC,4CAAC,MAAM,WAAP,EAAiB,UAAU,iBAUT,GATd,UAEE,SAKA,cAAc,MAAM,CAER,GAGhB,SAIA,aAAa,CAEI;;GAG3B,OAAO;KACN,CAAC,MAAM,CAAC;EAGX,MAAM,qCAA0B;GAqB9B,SAAS,cAIP,OAcW;IACX,MAAM,EAAE,QAAQ,UAAU,UAAU,sBAAsB;IAC1D,MAAM,iBAAiB,OAAO,OAAO,QAAQ;KAC3C,YAAY;KACZ,GAAG;KACJ,CAAC;IAEF,OACE,4CAAC,cAAc,UAAf,EAAwB,OAAO,QAqBN,EApBtB,oBACC,4CAAC,MAAM,WAAP,EAAiB,UAAU,mBAUT,GATd,UAEE,SAKA,gBAAgB,MAAM,CAEV,GAGhB,SAIA,eAAe,CAEI;;GAG7B,OAAO;KAKN,CAAC,MAAM,CAAC;EAGX,MAAM,qCAA0B;GAqB9B,SAAS,cAIP,OAcW;IACX,MAAM,EAAE,QAAQ,UAAU,UAAU,sBAAsB;IAC1D,MAAM,iBAAiB,OAAO,OAAO,QAAQ;KAC3C,YAAY;KACZ,GAAG;KACJ,CAAC;IAEF,OACE,4CAAC,cAAc,UAAf,EAAwB,OAAO,QAqBN,EApBtB,oBACC,4CAAC,MAAM,WAAP,EAAiB,UAAU,mBAUT,GATd,UAEE,SAKA,gBAAgB,MAAM,CAEV,GAGhB,SAIA,eAAe,CAEI;;GAG7B,OAAO;KAKN,CAAC,MAAM,CAAC;EAoBX,gCAjBoC;GAClC,OAAO,OAAO,OAAO,OAAO;IAC1B;IACA;IACA;IACA;IACA,GAAG;IACJ,CAAC;KAQD;GAAC;GAAO;GAAU;GAAS;GAAW;GAAU,CAE/B;;CAGtB,OAAO;EACL,aAAa,oBAAoB;EACjC;EACA;EACA;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"createTableHook.cjs","names":["FlexRender","useTable"],"sources":["../src/createTableHook.tsx"],"sourcesContent":["'use client'\n/* eslint-disable @eslint-react/no-context-provider */\nimport React, { createContext, useContext, useMemo } from 'react'\nimport { createColumnHelper as coreCreateColumnHelper } from '@tanstack/table-core'\nimport { useTable } from './useTable'\nimport { FlexRender } from './FlexRender'\nimport type {\n AccessorFn,\n AccessorFnColumnDef,\n AccessorKeyColumnDef,\n Cell,\n CellContext,\n CellData,\n Column,\n ColumnDef,\n DeepKeys,\n DeepValue,\n DisplayColumnDef,\n GroupColumnDef,\n Header,\n IdentifiedColumnDef,\n NoInfer,\n Row,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentType, ReactNode } from 'react'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// Enhanced Context Types with Pre-bound Components\n// =============================================================================\n\n/**\n * Enhanced CellContext with pre-bound cell components.\n * The `cell` property includes the registered cellComponents.\n */\nexport type AppCellContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> = {\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode }\n column: Column<TFeatures, TData, TValue>\n getValue: CellContext<TFeatures, TData, TValue>['getValue']\n renderValue: CellContext<TFeatures, TData, TValue>['renderValue']\n row: Row<TFeatures, TData>\n table: Table<TFeatures, TData>\n}\n\n/**\n * Enhanced HeaderContext with pre-bound header components.\n * The `header` property includes the registered headerComponents.\n */\nexport type AppHeaderContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n column: Column<TFeatures, TData, TValue>\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode }\n table: Table<TFeatures, TData>\n}\n\n// =============================================================================\n// Enhanced Column Definition Types\n// =============================================================================\n\n/**\n * Template type for column definitions that can be a string or a function.\n */\nexport type AppColumnDefTemplate<TProps extends object> =\n | string\n | ((props: TProps) => any)\n\n/**\n * Enhanced column definition base with pre-bound components in cell/header/footer contexts.\n */\nexport type AppColumnDefBase<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n IdentifiedColumnDef<TFeatures, TData, TValue>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, TValue, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n}\n\n/**\n * Enhanced display column definition with pre-bound components.\n */\nexport type AppDisplayColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n DisplayColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n}\n\n/**\n * Enhanced group column definition with pre-bound components.\n */\nexport type AppGroupColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n GroupColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer' | 'columns'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n columns?: Array<ColumnDef<TFeatures, TData, unknown>>\n}\n\n// =============================================================================\n// Enhanced Column Helper Type\n// =============================================================================\n\n/**\n * Enhanced column helper with pre-bound components in cell/header/footer contexts.\n * This enables TypeScript to know about the registered components when defining columns.\n */\nexport type AppColumnHelper<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n /**\n * Creates a data column definition with an accessor key or function.\n * The cell, header, and footer contexts include pre-bound components.\n */\n accessor: <\n TAccessor extends AccessorFn<TData> | DeepKeys<TData>,\n TValue extends TAccessor extends AccessorFn<TData, infer TReturn>\n ? TReturn\n : TAccessor extends DeepKeys<TData>\n ? DeepValue<TData, TAccessor>\n : never,\n >(\n accessor: TAccessor,\n column: TAccessor extends AccessorFn<TData>\n ? AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n > & { id: string }\n : AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n >,\n ) => TAccessor extends AccessorFn<TData>\n ? AccessorFnColumnDef<TFeatures, TData, TValue>\n : AccessorKeyColumnDef<TFeatures, TData, TValue>\n\n /**\n * Wraps an array of column definitions to preserve each column's individual TValue type.\n */\n columns: <TColumns extends ReadonlyArray<ColumnDef<TFeatures, TData, any>>>(\n columns: [...TColumns],\n ) => Array<ColumnDef<TFeatures, TData, any>> & [...TColumns]\n\n /**\n * Creates a display column definition for non-data columns.\n * The cell, header, and footer contexts include pre-bound components.\n */\n display: (\n column: AppDisplayColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => DisplayColumnDef<TFeatures, TData, unknown>\n\n /**\n * Creates a group column definition with nested child columns.\n * The cell, header, and footer contexts include pre-bound components.\n */\n group: (\n column: AppGroupColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => GroupColumnDef<TFeatures, TData, unknown>\n}\n\n// =============================================================================\n// CreateTableHook Options and Props\n// =============================================================================\n\n/**\n * Options for creating a table hook with pre-bound components and default table options.\n * Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initialState'.\n */\nexport type CreateTableHookOptions<\n TFeatures extends TableFeatures,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n> & {\n /**\n * Table-level components that need access to the table instance.\n * These are available directly on the table object returned by useAppTable.\n * Use `useTableContext()` inside these components.\n * @example { PaginationControls, GlobalFilter, RowCount }\n */\n tableComponents?: TTableComponents\n /**\n * Cell-level components that need access to the cell instance.\n * These are available on the cell object passed to AppCell's children.\n * Use `useCellContext()` inside these components.\n * @example { TextCell, NumberCell, DateCell, CurrencyCell }\n */\n cellComponents?: TCellComponents\n /**\n * Header-level components that need access to the header instance.\n * These are available on the header object passed to AppHeader/AppFooter's children.\n * Use `useHeaderContext()` inside these components.\n * @example { SortIndicator, ColumnFilter, ResizeHandle }\n */\n headerComponents?: THeaderComponents\n}\n\n/**\n * Props for AppTable component - without selector\n */\nexport interface AppTablePropsWithoutSelector {\n children: ReactNode\n selector?: never\n}\n\n/**\n * Props for AppTable component - with selector\n */\nexport interface AppTablePropsWithSelector<\n TFeatures extends TableFeatures,\n TSelected,\n> {\n children: (state: TSelected) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Props for AppCell component - without selector\n */\nexport interface AppCellPropsWithoutSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> {\n cell: Cell<TFeatures, TData, TValue>\n children: (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n selector?: never\n}\n\n/**\n * Props for AppCell component - with selector\n */\nexport interface AppCellPropsWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n TSelected,\n> {\n cell: Cell<TFeatures, TData, TValue>\n children: (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n state: TSelected,\n ) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Props for AppHeader/AppFooter component - without selector\n */\nexport interface AppHeaderPropsWithoutSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> {\n header: Header<TFeatures, TData, TValue>\n children: (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n selector?: never\n}\n\n/**\n * Props for AppHeader/AppFooter component - with selector\n */\nexport interface AppHeaderPropsWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n TSelected,\n> {\n header: Header<TFeatures, TData, TValue>\n children: (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TSelected,\n ) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Component type for AppCell - wraps a cell and provides cell context with optional Subscribe\n */\nexport interface AppCellComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> {\n <TValue extends CellData = CellData>(\n props: AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >,\n ): ReactNode\n <TValue extends CellData = CellData, TSelected = unknown>(\n props: AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TSelected\n >,\n ): ReactNode\n}\n\n/**\n * Component type for AppHeader/AppFooter - wraps a header and provides header context with optional Subscribe\n */\nexport interface AppHeaderComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> {\n <TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n <TValue extends CellData = CellData, TSelected = unknown>(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TSelected\n >,\n ): ReactNode\n}\n\n/**\n * Component type for AppTable - root wrapper with optional Subscribe\n */\nexport interface AppTableComponent<TFeatures extends TableFeatures> {\n (props: AppTablePropsWithoutSelector): ReactNode\n <TSelected>(props: AppTablePropsWithSelector<TFeatures, TSelected>): ReactNode\n}\n\n/**\n * Extended table API returned by useAppTable with all App wrapper components\n */\nexport type AppReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = ReactTable<TFeatures, TData, TSelected> &\n NoInfer<TTableComponents> & {\n /**\n * Root wrapper component that provides table context with optional Subscribe.\n * @example\n * ```tsx\n * // Without selector - children is ReactNode\n * <table.AppTable>\n * <table>...</table>\n * </table.AppTable>\n *\n * // With selector - children receives selected state\n * <table.AppTable selector={(s) => s.pagination}>\n * {(pagination) => <div>Page {pagination.pageIndex}</div>}\n * </table.AppTable>\n * ```\n */\n AppTable: AppTableComponent<TFeatures>\n /**\n * Wraps a cell and provides cell context with pre-bound cellComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * // Without selector\n * <table.AppCell cell={cell}>\n * {(c) => <td><c.TextCell /></td>}\n * </table.AppCell>\n *\n * // With selector - children receives cell and selected state\n * <table.AppCell cell={cell} selector={(s) => s.columnFilters}>\n * {(c, filters) => <td>{filters.length}</td>}\n * </table.AppCell>\n * ```\n */\n AppCell: AppCellComponent<TFeatures, TData, NoInfer<TCellComponents>>\n /**\n * Wraps a header and provides header context with pre-bound headerComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * // Without selector\n * <table.AppHeader header={header}>\n * {(h) => <th><h.SortIndicator /></th>}\n * </table.AppHeader>\n *\n * // With selector\n * <table.AppHeader header={header} selector={(s) => s.sorting}>\n * {(h, sorting) => <th>{sorting.length} sorted</th>}\n * </table.AppHeader>\n * ```\n */\n AppHeader: AppHeaderComponent<TFeatures, TData, NoInfer<THeaderComponents>>\n /**\n * Wraps a footer and provides header context with pre-bound headerComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * <table.AppFooter header={footer}>\n * {(f) => <td><table.FlexRender footer={footer} /></td>}\n * </table.AppFooter>\n * ```\n */\n AppFooter: AppHeaderComponent<TFeatures, TData, NoInfer<THeaderComponents>>\n }\n\n/**\n * Creates a custom table hook with pre-bound components for composition.\n *\n * This is the table equivalent of TanStack Form's `createFormHook`. It allows you to:\n * - Define features, row models, and default options once, shared across all tables\n * - Register reusable table, cell, and header components\n * - Access table/cell/header instances via context in those components\n * - Get a `useAppTable` hook that returns an extended table with App wrapper components\n * - Get a `createAppColumnHelper` function pre-bound to your features\n *\n * @example\n * ```tsx\n * // hooks/table.ts\n * export const {\n * useAppTable,\n * createAppColumnHelper,\n * useTableContext,\n * useCellContext,\n * useHeaderContext,\n * } = createTableHook({\n * _features: tableFeatures({\n * rowPaginationFeature,\n * rowSortingFeature,\n * columnFilteringFeature,\n * }),\n * _rowModels: {\n * paginatedRowModel: createPaginatedRowModel(),\n * sortedRowModel: createSortedRowModel(sortFns),\n * filteredRowModel: createFilteredRowModel(filterFns),\n * },\n * tableComponents: { PaginationControls, RowCount },\n * cellComponents: { TextCell, NumberCell },\n * headerComponents: { SortIndicator, ColumnFilter },\n * })\n *\n * // Create column helper with TFeatures already bound\n * const columnHelper = createAppColumnHelper<Person>()\n *\n * // components/table-components.tsx\n * function PaginationControls() {\n * const table = useTableContext() // TFeatures already known!\n * return <table.Subscribe selector={(s) => s.pagination}>...</table.Subscribe>\n * }\n *\n * // features/users.tsx\n * function UsersTable({ data }: { data: Person[] }) {\n * const table = useAppTable({\n * columns,\n * data, // TData inferred from Person[]\n * })\n *\n * return (\n * <table.AppTable>\n * <table>\n * <thead>\n * {table.getHeaderGroups().map(headerGroup => (\n * <tr key={headerGroup.id}>\n * {headerGroup.headers.map(h => (\n * <table.AppHeader header={h} key={h.id}>\n * {(header) => (\n * <th>\n * <table.FlexRender header={h} />\n * <header.SortIndicator />\n * </th>\n * )}\n * </table.AppHeader>\n * ))}\n * </tr>\n * ))}\n * </thead>\n * <tbody>\n * {table.getRowModel().rows.map(row => (\n * <tr key={row.id}>\n * {row.getAllCells().map(c => (\n * <table.AppCell cell={c} key={c.id}>\n * {(cell) => <td><cell.TextCell /></td>}\n * </table.AppCell>\n * ))}\n * </tr>\n * ))}\n * </tbody>\n * </table>\n * <table.PaginationControls />\n * </table.AppTable>\n * )\n * }\n * ```\n */\nexport function createTableHook<\n TFeatures extends TableFeatures,\n const TTableComponents extends Record<string, ComponentType<any>>,\n const TCellComponents extends Record<string, ComponentType<any>>,\n const THeaderComponents extends Record<string, ComponentType<any>>,\n>({\n tableComponents,\n cellComponents,\n headerComponents,\n ...defaultTableOptions\n}: CreateTableHookOptions<\n TFeatures,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n>) {\n // Create contexts internally with TFeatures baked in\n const TableContext = createContext<ReactTable<TFeatures, any, any>>(\n null as never,\n )\n const CellContext = createContext<Cell<TFeatures, any, any>>(null as never)\n const HeaderContext = createContext<Header<TFeatures, any, any>>(\n null as never,\n )\n\n /**\n * Create a column helper pre-bound to the features and components configured in this table hook.\n * The cell, header, and footer contexts include pre-bound components (e.g., `cell.TextCell`).\n * @example\n * ```tsx\n * const columnHelper = createAppColumnHelper<Person>()\n *\n * const columns = [\n * columnHelper.accessor('firstName', {\n * header: 'First Name',\n * cell: ({ cell }) => <cell.TextCell />, // cell has pre-bound components!\n * }),\n * columnHelper.accessor('age', {\n * header: 'Age',\n * cell: ({ cell }) => <cell.NumberCell />,\n * }),\n * ]\n * ```\n */\n function createAppColumnHelper<TData extends RowData>(): AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n > {\n // The runtime implementation is the same - components are attached at render time\n // This cast provides the enhanced types for column definitions\n return coreCreateColumnHelper<TFeatures, TData>() as AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >\n }\n\n /**\n * Access the table instance from within an `AppTable` wrapper.\n * Use this in custom `tableComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function PaginationControls() {\n * const table = useTableContext()\n * return (\n * <table.Subscribe selector={(s) => s.pagination}>\n * {(pagination) => (\n * <div>\n * <button onClick={() => table.previousPage()}>Prev</button>\n * <span>Page {pagination.pageIndex + 1}</span>\n * <button onClick={() => table.nextPage()}>Next</button>\n * </div>\n * )}\n * </table.Subscribe>\n * )\n * }\n * ```\n */\n function useTableContext<TData extends RowData = RowData>(): ReactTable<\n TFeatures,\n TData\n > {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const table = useContext(TableContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!table) {\n throw new Error(\n '`useTableContext` must be used within an `AppTable` component. ' +\n 'Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.',\n )\n }\n\n return table as ReactTable<TFeatures, TData>\n }\n\n /**\n * Access the cell instance from within an `AppCell` wrapper.\n * Use this in custom `cellComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function TextCell() {\n * const cell = useCellContext<string>()\n * return <span>{cell.getValue()}</span>\n * }\n *\n * function NumberCell({ format }: { format?: Intl.NumberFormatOptions }) {\n * const cell = useCellContext<number>()\n * return <span>{cell.getValue().toLocaleString(undefined, format)}</span>\n * }\n * ```\n */\n function useCellContext<TValue extends CellData = CellData>() {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const cell = useContext(CellContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!cell) {\n throw new Error(\n '`useCellContext` must be used within an `AppCell` component. ' +\n 'Make sure your component is wrapped with `<table.AppCell cell={cell}>...</table.AppCell>`.',\n )\n }\n\n return cell as Cell<TFeatures, any, TValue>\n }\n\n /**\n * Access the header instance from within an `AppHeader` or `AppFooter` wrapper.\n * Use this in custom `headerComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function SortIndicator() {\n * const header = useHeaderContext()\n * const sorted = header.column.getIsSorted()\n * return sorted === 'asc' ? '🔼' : sorted === 'desc' ? '🔽' : null\n * }\n *\n * function ColumnFilter() {\n * const header = useHeaderContext()\n * if (!header.column.getCanFilter()) return null\n * return (\n * <input\n * value={(header.column.getFilterValue() ?? '') as string}\n * onChange={(e) => header.column.setFilterValue(e.target.value)}\n * placeholder=\"Filter...\"\n * />\n * )\n * }\n * ```\n */\n function useHeaderContext<TValue extends CellData = CellData>() {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const header = useContext(HeaderContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!header) {\n throw new Error(\n '`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.',\n )\n }\n\n return header as Header<TFeatures, any, TValue>\n }\n\n /**\n * Context-aware FlexRender component for cells.\n * Uses the cell from context, so no need to pass cell prop.\n */\n function CellFlexRender() {\n const cell = useCellContext()\n return <FlexRender cell={cell} />\n }\n\n /**\n * Context-aware FlexRender component for headers.\n * Uses the header from context, so no need to pass header prop.\n */\n function HeaderFlexRender() {\n const header = useHeaderContext()\n return <FlexRender header={header} />\n }\n\n /**\n * Context-aware FlexRender component for footers.\n * Uses the header from context, so no need to pass footer prop.\n */\n function FooterFlexRender() {\n const header = useHeaderContext()\n return <FlexRender footer={header} />\n }\n\n /**\n * Enhanced useTable hook that returns a table with App wrapper components\n * and pre-bound tableComponents attached directly to the table object.\n *\n * Default options from createTableHook are automatically merged with\n * the options passed here. Options passed here take precedence.\n *\n * TFeatures is already known from the createTableHook call; TData is inferred from the data prop.\n */\n function useAppTable<\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n >(\n tableOptions: Omit<\n TableOptions<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: (state: TableState<TFeatures>) => TSelected,\n ): AppReactTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n > {\n // Merge default options with provided options (provided takes precedence)\n const table = useTable<TFeatures, TData, TSelected>(\n { ...defaultTableOptions, ...tableOptions } as TableOptions<\n TFeatures,\n TData\n >,\n selector,\n )\n\n // AppTable - Root wrapper that provides table context with optional Subscribe\n const AppTable = useMemo(() => {\n function AppTableImpl(props: AppTablePropsWithoutSelector): ReactNode\n function AppTableImpl<TAppTableSelected>(\n props: AppTablePropsWithSelector<TFeatures, TAppTableSelected>,\n ): ReactNode\n function AppTableImpl<TAppTableSelected>(\n props:\n | AppTablePropsWithoutSelector\n | AppTablePropsWithSelector<TFeatures, TAppTableSelected>,\n ): ReactNode {\n const { children, selector: appTableSelector } = props\n\n return (\n <TableContext.Provider value={table}>\n {appTableSelector ? (\n <table.Subscribe selector={appTableSelector}>\n {(state: TAppTableSelected) =>\n (children as (state: TAppTableSelected) => ReactNode)(state)\n }\n </table.Subscribe>\n ) : (\n children\n )}\n </TableContext.Provider>\n )\n }\n return AppTableImpl as AppTableComponent<TFeatures>\n }, [table])\n\n // AppCell - Wraps cell with context, pre-bound cellComponents, and optional Subscribe\n const AppCell = useMemo(() => {\n function AppCellImpl<TValue extends CellData = CellData>(\n props: AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >,\n ): ReactNode\n function AppCellImpl<\n TValue extends CellData = CellData,\n TAppCellSelected = unknown,\n >(\n props: AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TAppCellSelected\n >,\n ): ReactNode\n function AppCellImpl<\n TValue extends CellData = CellData,\n TAppCellSelected = unknown,\n >(\n props:\n | AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >\n | AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TAppCellSelected\n >,\n ): ReactNode {\n const { cell, children, selector: appCellSelector } = props as any\n const extendedCell = Object.assign(cell, {\n FlexRender: CellFlexRender,\n ...cellComponents,\n })\n\n return (\n <CellContext.Provider value={cell}>\n {appCellSelector ? (\n <table.Subscribe selector={appCellSelector}>\n {(state: TAppCellSelected) =>\n (\n children as (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n state: TAppCellSelected,\n ) => ReactNode\n )(extendedCell, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedCell)\n )}\n </CellContext.Provider>\n )\n }\n return AppCellImpl as AppCellComponent<TFeatures, TData, TCellComponents>\n }, [table])\n\n // AppHeader - Wraps header with context, pre-bound headerComponents, and optional Subscribe\n const AppHeader = useMemo(() => {\n function AppHeaderImpl<TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n function AppHeaderImpl<\n TValue extends CellData = CellData,\n TAppHeaderSelected = unknown,\n >(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppHeaderSelected\n >,\n ): ReactNode\n function AppHeaderImpl<\n TValue extends CellData = CellData,\n TAppHeaderSelected = unknown,\n >(\n props:\n | AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >\n | AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppHeaderSelected\n >,\n ): ReactNode {\n const { header, children, selector: appHeaderSelector } = props as any\n const extendedHeader = Object.assign(header, {\n FlexRender: HeaderFlexRender,\n ...headerComponents,\n })\n\n return (\n <HeaderContext.Provider value={header}>\n {appHeaderSelector ? (\n <table.Subscribe selector={appHeaderSelector}>\n {(state: TAppHeaderSelected) =>\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TAppHeaderSelected,\n ) => ReactNode\n )(extendedHeader, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedHeader)\n )}\n </HeaderContext.Provider>\n )\n }\n return AppHeaderImpl as AppHeaderComponent<\n TFeatures,\n TData,\n THeaderComponents\n >\n }, [table])\n\n // AppFooter - Same as AppHeader (footers use Header type)\n const AppFooter = useMemo(() => {\n function AppFooterImpl<TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n function AppFooterImpl<\n TValue extends CellData = CellData,\n TAppFooterSelected = unknown,\n >(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppFooterSelected\n >,\n ): ReactNode\n function AppFooterImpl<\n TValue extends CellData = CellData,\n TAppFooterSelected = unknown,\n >(\n props:\n | AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >\n | AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppFooterSelected\n >,\n ): ReactNode {\n const { header, children, selector: appFooterSelector } = props as any\n const extendedHeader = Object.assign(header, {\n FlexRender: FooterFlexRender,\n ...headerComponents,\n })\n\n return (\n <HeaderContext.Provider value={header}>\n {appFooterSelector ? (\n <table.Subscribe selector={appFooterSelector}>\n {(state: TAppFooterSelected) =>\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TAppFooterSelected,\n ) => ReactNode\n )(extendedHeader, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedHeader)\n )}\n </HeaderContext.Provider>\n )\n }\n return AppFooterImpl as AppHeaderComponent<\n TFeatures,\n TData,\n THeaderComponents\n >\n }, [table])\n\n // Combine everything into the extended table API\n const extendedTable = useMemo(() => {\n return Object.assign(table, {\n AppTable,\n AppCell,\n AppHeader,\n AppFooter,\n ...tableComponents,\n }) as AppReactTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n >\n }, [table, AppTable, AppCell, AppHeader, AppFooter])\n\n return extendedTable\n }\n\n return {\n appFeatures: defaultTableOptions._features as TFeatures,\n createAppColumnHelper,\n useAppTable,\n useTableContext,\n useCellContext,\n useHeaderContext,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6kBA,SAAgB,gBAKd,EACA,iBACA,gBACA,kBACA,GAAG,uBAMF;CAED,MAAM,wCACJ,IACF;CACA,MAAM,uCAAuD,IAAa;CAC1E,MAAM,yCACJ,IACF;;;;;;;;;;;;;;;;;;;;CAqBA,SAAS,wBAKP;EAGA,oDAAgD;CAMlD;;;;;;;;;;;;;;;;;;;;;;;;CAyBA,SAAS,kBAGP;EAGA,MAAM,8BAAmB,YAAY;EAGrC,IAAI,CAAC,OACH,MAAM,IAAI,MACR,iJAEF;EAGF,OAAO;CACT;;;;;;;;;;;;;;;;;;;CAoBA,SAAS,iBAAqD;EAG5D,MAAM,6BAAkB,WAAW;EAGnC,IAAI,CAAC,MACH,MAAM,IAAI,MACR,yJAEF;EAGF,OAAO;CACT;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BA,SAAS,mBAAuD;EAG9D,MAAM,+BAAoB,aAAa;EAGvC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,iFACF;EAGF,OAAO;CACT;;;;;CAMA,SAAS,iBAAiB;EACxB,MAAM,OAAO,eAAe;EAC5B,OAAO,4CAACA,+BAAD,EAAkB,KAAO;CAClC;;;;;CAMA,SAAS,mBAAmB;EAC1B,MAAM,SAAS,iBAAiB;EAChC,OAAO,4CAACA,+BAAD,EAAoB,OAAS;CACtC;;;;;CAMA,SAAS,mBAAmB;EAC1B,MAAM,SAAS,iBAAiB;EAChC,OAAO,4CAACA,+BAAD,EAAY,QAAQ,OAAS;CACtC;;;;;;;;;;CAWA,SAAS,YAIP,cAIA,UAQA;EAEA,MAAM,QAAQC,0BACZ;GAAE,GAAG;GAAqB,GAAG;EAAa,GAI1C,QACF;EAGA,MAAM,oCAAyB;GAK7B,SAAS,aACP,OAGW;IACX,MAAM,EAAE,UAAU,UAAU,qBAAqB;IAEjD,OACE,4CAAC,aAAa,UAAd,EAAuB,OAAO,MAUP,GATpB,mBACC,4CAAC,MAAM,WAAP,EAAiB,UAAU,iBAIV,IAHb,UACC,SAAqD,KAAK,CAE9C,IAEjB,QAEmB;GAE3B;GACA,OAAO;EACT,GAAG,CAAC,KAAK,CAAC;EAGV,MAAM,mCAAwB;GAqB5B,SAAS,YAIP,OAcW;IACX,MAAM,EAAE,MAAM,UAAU,UAAU,oBAAoB;IACtD,MAAM,eAAe,OAAO,OAAO,MAAM;KACvC,YAAY;KACZ,GAAG;IACL,CAAC;IAED,OACE,4CAAC,YAAY,UAAb,EAAsB,OAAO,KAqBP,GApBnB,kBACC,4CAAC,MAAM,WAAP,EAAiB,UAAU,gBAUV,IATb,UAEE,SAKA,cAAc,KAAK,CAER,IAGf,SAIA,YAAY,CAEI;GAE1B;GACA,OAAO;EACT,GAAG,CAAC,KAAK,CAAC;EAGV,MAAM,qCAA0B;GAqB9B,SAAS,cAIP,OAcW;IACX,MAAM,EAAE,QAAQ,UAAU,UAAU,sBAAsB;IAC1D,MAAM,iBAAiB,OAAO,OAAO,QAAQ;KAC3C,YAAY;KACZ,GAAG;IACL,CAAC;IAED,OACE,4CAAC,cAAc,UAAf,EAAwB,OAAO,OAqBP,GApBrB,oBACC,4CAAC,MAAM,WAAP,EAAiB,UAAU,kBAUV,IATb,UAEE,SAKA,gBAAgB,KAAK,CAEV,IAGf,SAIA,cAAc,CAEI;GAE5B;GACA,OAAO;EAKT,GAAG,CAAC,KAAK,CAAC;EAGV,MAAM,qCAA0B;GAqB9B,SAAS,cAIP,OAcW;IACX,MAAM,EAAE,QAAQ,UAAU,UAAU,sBAAsB;IAC1D,MAAM,iBAAiB,OAAO,OAAO,QAAQ;KAC3C,YAAY;KACZ,GAAG;IACL,CAAC;IAED,OACE,4CAAC,cAAc,UAAf,EAAwB,OAAO,OAqBP,GApBrB,oBACC,4CAAC,MAAM,WAAP,EAAiB,UAAU,kBAUV,IATb,UAEE,SAKA,gBAAgB,KAAK,CAEV,IAGf,SAIA,cAAc,CAEI;GAE5B;GACA,OAAO;EAKT,GAAG,CAAC,KAAK,CAAC;EAoBV,gCAjBoC;GAClC,OAAO,OAAO,OAAO,OAAO;IAC1B;IACA;IACA;IACA;IACA,GAAG;GACL,CAAC;EAQH,GAAG;GAAC;GAAO;GAAU;GAAS;GAAW;EAAS,CAE/B;CACrB;CAEA,OAAO;EACL,aAAa,oBAAoB;EACjC;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTableHook.js","names":["coreCreateColumnHelper"],"sources":["../src/createTableHook.tsx"],"sourcesContent":["'use client'\n/* eslint-disable @eslint-react/no-context-provider */\nimport React, { createContext, useContext, useMemo } from 'react'\nimport { createColumnHelper as coreCreateColumnHelper } from '@tanstack/table-core'\nimport { useTable } from './useTable'\nimport { FlexRender } from './FlexRender'\nimport type {\n AccessorFn,\n AccessorFnColumnDef,\n AccessorKeyColumnDef,\n Cell,\n CellContext,\n CellData,\n Column,\n ColumnDef,\n DeepKeys,\n DeepValue,\n DisplayColumnDef,\n GroupColumnDef,\n Header,\n IdentifiedColumnDef,\n NoInfer,\n Row,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentType, ReactNode } from 'react'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// Enhanced Context Types with Pre-bound Components\n// =============================================================================\n\n/**\n * Enhanced CellContext with pre-bound cell components.\n * The `cell` property includes the registered cellComponents.\n */\nexport type AppCellContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> = {\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode }\n column: Column<TFeatures, TData, TValue>\n getValue: CellContext<TFeatures, TData, TValue>['getValue']\n renderValue: CellContext<TFeatures, TData, TValue>['renderValue']\n row: Row<TFeatures, TData>\n table: Table<TFeatures, TData>\n}\n\n/**\n * Enhanced HeaderContext with pre-bound header components.\n * The `header` property includes the registered headerComponents.\n */\nexport type AppHeaderContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n column: Column<TFeatures, TData, TValue>\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode }\n table: Table<TFeatures, TData>\n}\n\n// =============================================================================\n// Enhanced Column Definition Types\n// =============================================================================\n\n/**\n * Template type for column definitions that can be a string or a function.\n */\nexport type AppColumnDefTemplate<TProps extends object> =\n | string\n | ((props: TProps) => any)\n\n/**\n * Enhanced column definition base with pre-bound components in cell/header/footer contexts.\n */\nexport type AppColumnDefBase<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n IdentifiedColumnDef<TFeatures, TData, TValue>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, TValue, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n}\n\n/**\n * Enhanced display column definition with pre-bound components.\n */\nexport type AppDisplayColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n DisplayColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n}\n\n/**\n * Enhanced group column definition with pre-bound components.\n */\nexport type AppGroupColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n GroupColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer' | 'columns'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n columns?: Array<ColumnDef<TFeatures, TData, unknown>>\n}\n\n// =============================================================================\n// Enhanced Column Helper Type\n// =============================================================================\n\n/**\n * Enhanced column helper with pre-bound components in cell/header/footer contexts.\n * This enables TypeScript to know about the registered components when defining columns.\n */\nexport type AppColumnHelper<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n /**\n * Creates a data column definition with an accessor key or function.\n * The cell, header, and footer contexts include pre-bound components.\n */\n accessor: <\n TAccessor extends AccessorFn<TData> | DeepKeys<TData>,\n TValue extends TAccessor extends AccessorFn<TData, infer TReturn>\n ? TReturn\n : TAccessor extends DeepKeys<TData>\n ? DeepValue<TData, TAccessor>\n : never,\n >(\n accessor: TAccessor,\n column: TAccessor extends AccessorFn<TData>\n ? AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n > & { id: string }\n : AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n >,\n ) => TAccessor extends AccessorFn<TData>\n ? AccessorFnColumnDef<TFeatures, TData, TValue>\n : AccessorKeyColumnDef<TFeatures, TData, TValue>\n\n /**\n * Wraps an array of column definitions to preserve each column's individual TValue type.\n */\n columns: <TColumns extends ReadonlyArray<ColumnDef<TFeatures, TData, any>>>(\n columns: [...TColumns],\n ) => Array<ColumnDef<TFeatures, TData, any>> & [...TColumns]\n\n /**\n * Creates a display column definition for non-data columns.\n * The cell, header, and footer contexts include pre-bound components.\n */\n display: (\n column: AppDisplayColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => DisplayColumnDef<TFeatures, TData, unknown>\n\n /**\n * Creates a group column definition with nested child columns.\n * The cell, header, and footer contexts include pre-bound components.\n */\n group: (\n column: AppGroupColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => GroupColumnDef<TFeatures, TData, unknown>\n}\n\n// =============================================================================\n// CreateTableHook Options and Props\n// =============================================================================\n\n/**\n * Options for creating a table hook with pre-bound components and default table options.\n * Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initialState'.\n */\nexport type CreateTableHookOptions<\n TFeatures extends TableFeatures,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n> & {\n /**\n * Table-level components that need access to the table instance.\n * These are available directly on the table object returned by useAppTable.\n * Use `useTableContext()` inside these components.\n * @example { PaginationControls, GlobalFilter, RowCount }\n */\n tableComponents?: TTableComponents\n /**\n * Cell-level components that need access to the cell instance.\n * These are available on the cell object passed to AppCell's children.\n * Use `useCellContext()` inside these components.\n * @example { TextCell, NumberCell, DateCell, CurrencyCell }\n */\n cellComponents?: TCellComponents\n /**\n * Header-level components that need access to the header instance.\n * These are available on the header object passed to AppHeader/AppFooter's children.\n * Use `useHeaderContext()` inside these components.\n * @example { SortIndicator, ColumnFilter, ResizeHandle }\n */\n headerComponents?: THeaderComponents\n}\n\n/**\n * Props for AppTable component - without selector\n */\nexport interface AppTablePropsWithoutSelector {\n children: ReactNode\n selector?: never\n}\n\n/**\n * Props for AppTable component - with selector\n */\nexport interface AppTablePropsWithSelector<\n TFeatures extends TableFeatures,\n TSelected,\n> {\n children: (state: TSelected) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Props for AppCell component - without selector\n */\nexport interface AppCellPropsWithoutSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> {\n cell: Cell<TFeatures, TData, TValue>\n children: (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n selector?: never\n}\n\n/**\n * Props for AppCell component - with selector\n */\nexport interface AppCellPropsWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n TSelected,\n> {\n cell: Cell<TFeatures, TData, TValue>\n children: (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n state: TSelected,\n ) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Props for AppHeader/AppFooter component - without selector\n */\nexport interface AppHeaderPropsWithoutSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> {\n header: Header<TFeatures, TData, TValue>\n children: (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n selector?: never\n}\n\n/**\n * Props for AppHeader/AppFooter component - with selector\n */\nexport interface AppHeaderPropsWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n TSelected,\n> {\n header: Header<TFeatures, TData, TValue>\n children: (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TSelected,\n ) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Component type for AppCell - wraps a cell and provides cell context with optional Subscribe\n */\nexport interface AppCellComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> {\n <TValue extends CellData = CellData>(\n props: AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >,\n ): ReactNode\n <TValue extends CellData = CellData, TSelected = unknown>(\n props: AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TSelected\n >,\n ): ReactNode\n}\n\n/**\n * Component type for AppHeader/AppFooter - wraps a header and provides header context with optional Subscribe\n */\nexport interface AppHeaderComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> {\n <TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n <TValue extends CellData = CellData, TSelected = unknown>(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TSelected\n >,\n ): ReactNode\n}\n\n/**\n * Component type for AppTable - root wrapper with optional Subscribe\n */\nexport interface AppTableComponent<TFeatures extends TableFeatures> {\n (props: AppTablePropsWithoutSelector): ReactNode\n <TSelected>(props: AppTablePropsWithSelector<TFeatures, TSelected>): ReactNode\n}\n\n/**\n * Extended table API returned by useAppTable with all App wrapper components\n */\nexport type AppReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = ReactTable<TFeatures, TData, TSelected> &\n NoInfer<TTableComponents> & {\n /**\n * Root wrapper component that provides table context with optional Subscribe.\n * @example\n * ```tsx\n * // Without selector - children is ReactNode\n * <table.AppTable>\n * <table>...</table>\n * </table.AppTable>\n *\n * // With selector - children receives selected state\n * <table.AppTable selector={(s) => s.pagination}>\n * {(pagination) => <div>Page {pagination.pageIndex}</div>}\n * </table.AppTable>\n * ```\n */\n AppTable: AppTableComponent<TFeatures>\n /**\n * Wraps a cell and provides cell context with pre-bound cellComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * // Without selector\n * <table.AppCell cell={cell}>\n * {(c) => <td><c.TextCell /></td>}\n * </table.AppCell>\n *\n * // With selector - children receives cell and selected state\n * <table.AppCell cell={cell} selector={(s) => s.columnFilters}>\n * {(c, filters) => <td>{filters.length}</td>}\n * </table.AppCell>\n * ```\n */\n AppCell: AppCellComponent<TFeatures, TData, NoInfer<TCellComponents>>\n /**\n * Wraps a header and provides header context with pre-bound headerComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * // Without selector\n * <table.AppHeader header={header}>\n * {(h) => <th><h.SortIndicator /></th>}\n * </table.AppHeader>\n *\n * // With selector\n * <table.AppHeader header={header} selector={(s) => s.sorting}>\n * {(h, sorting) => <th>{sorting.length} sorted</th>}\n * </table.AppHeader>\n * ```\n */\n AppHeader: AppHeaderComponent<TFeatures, TData, NoInfer<THeaderComponents>>\n /**\n * Wraps a footer and provides header context with pre-bound headerComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * <table.AppFooter header={footer}>\n * {(f) => <td><table.FlexRender footer={footer} /></td>}\n * </table.AppFooter>\n * ```\n */\n AppFooter: AppHeaderComponent<TFeatures, TData, NoInfer<THeaderComponents>>\n }\n\n/**\n * Creates a custom table hook with pre-bound components for composition.\n *\n * This is the table equivalent of TanStack Form's `createFormHook`. It allows you to:\n * - Define features, row models, and default options once, shared across all tables\n * - Register reusable table, cell, and header components\n * - Access table/cell/header instances via context in those components\n * - Get a `useAppTable` hook that returns an extended table with App wrapper components\n * - Get a `createAppColumnHelper` function pre-bound to your features\n *\n * @example\n * ```tsx\n * // hooks/table.ts\n * export const {\n * useAppTable,\n * createAppColumnHelper,\n * useTableContext,\n * useCellContext,\n * useHeaderContext,\n * } = createTableHook({\n * _features: tableFeatures({\n * rowPaginationFeature,\n * rowSortingFeature,\n * columnFilteringFeature,\n * }),\n * _rowModels: {\n * paginatedRowModel: createPaginatedRowModel(),\n * sortedRowModel: createSortedRowModel(sortFns),\n * filteredRowModel: createFilteredRowModel(filterFns),\n * },\n * tableComponents: { PaginationControls, RowCount },\n * cellComponents: { TextCell, NumberCell },\n * headerComponents: { SortIndicator, ColumnFilter },\n * })\n *\n * // Create column helper with TFeatures already bound\n * const columnHelper = createAppColumnHelper<Person>()\n *\n * // components/table-components.tsx\n * function PaginationControls() {\n * const table = useTableContext() // TFeatures already known!\n * return <table.Subscribe selector={(s) => s.pagination}>...</table.Subscribe>\n * }\n *\n * // features/users.tsx\n * function UsersTable({ data }: { data: Person[] }) {\n * const table = useAppTable({\n * columns,\n * data, // TData inferred from Person[]\n * })\n *\n * return (\n * <table.AppTable>\n * <table>\n * <thead>\n * {table.getHeaderGroups().map(headerGroup => (\n * <tr key={headerGroup.id}>\n * {headerGroup.headers.map(h => (\n * <table.AppHeader header={h} key={h.id}>\n * {(header) => (\n * <th>\n * <table.FlexRender header={h} />\n * <header.SortIndicator />\n * </th>\n * )}\n * </table.AppHeader>\n * ))}\n * </tr>\n * ))}\n * </thead>\n * <tbody>\n * {table.getRowModel().rows.map(row => (\n * <tr key={row.id}>\n * {row.getAllCells().map(c => (\n * <table.AppCell cell={c} key={c.id}>\n * {(cell) => <td><cell.TextCell /></td>}\n * </table.AppCell>\n * ))}\n * </tr>\n * ))}\n * </tbody>\n * </table>\n * <table.PaginationControls />\n * </table.AppTable>\n * )\n * }\n * ```\n */\nexport function createTableHook<\n TFeatures extends TableFeatures,\n const TTableComponents extends Record<string, ComponentType<any>>,\n const TCellComponents extends Record<string, ComponentType<any>>,\n const THeaderComponents extends Record<string, ComponentType<any>>,\n>({\n tableComponents,\n cellComponents,\n headerComponents,\n ...defaultTableOptions\n}: CreateTableHookOptions<\n TFeatures,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n>) {\n // Create contexts internally with TFeatures baked in\n const TableContext = createContext<ReactTable<TFeatures, any, any>>(\n null as never,\n )\n const CellContext = createContext<Cell<TFeatures, any, any>>(null as never)\n const HeaderContext = createContext<Header<TFeatures, any, any>>(\n null as never,\n )\n\n /**\n * Create a column helper pre-bound to the features and components configured in this table hook.\n * The cell, header, and footer contexts include pre-bound components (e.g., `cell.TextCell`).\n * @example\n * ```tsx\n * const columnHelper = createAppColumnHelper<Person>()\n *\n * const columns = [\n * columnHelper.accessor('firstName', {\n * header: 'First Name',\n * cell: ({ cell }) => <cell.TextCell />, // cell has pre-bound components!\n * }),\n * columnHelper.accessor('age', {\n * header: 'Age',\n * cell: ({ cell }) => <cell.NumberCell />,\n * }),\n * ]\n * ```\n */\n function createAppColumnHelper<TData extends RowData>(): AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n > {\n // The runtime implementation is the same - components are attached at render time\n // This cast provides the enhanced types for column definitions\n return coreCreateColumnHelper<TFeatures, TData>() as AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >\n }\n\n /**\n * Access the table instance from within an `AppTable` wrapper.\n * Use this in custom `tableComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function PaginationControls() {\n * const table = useTableContext()\n * return (\n * <table.Subscribe selector={(s) => s.pagination}>\n * {(pagination) => (\n * <div>\n * <button onClick={() => table.previousPage()}>Prev</button>\n * <span>Page {pagination.pageIndex + 1}</span>\n * <button onClick={() => table.nextPage()}>Next</button>\n * </div>\n * )}\n * </table.Subscribe>\n * )\n * }\n * ```\n */\n function useTableContext<TData extends RowData = RowData>(): ReactTable<\n TFeatures,\n TData\n > {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const table = useContext(TableContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!table) {\n throw new Error(\n '`useTableContext` must be used within an `AppTable` component. ' +\n 'Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.',\n )\n }\n\n return table as ReactTable<TFeatures, TData>\n }\n\n /**\n * Access the cell instance from within an `AppCell` wrapper.\n * Use this in custom `cellComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function TextCell() {\n * const cell = useCellContext<string>()\n * return <span>{cell.getValue()}</span>\n * }\n *\n * function NumberCell({ format }: { format?: Intl.NumberFormatOptions }) {\n * const cell = useCellContext<number>()\n * return <span>{cell.getValue().toLocaleString(undefined, format)}</span>\n * }\n * ```\n */\n function useCellContext<TValue extends CellData = CellData>() {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const cell = useContext(CellContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!cell) {\n throw new Error(\n '`useCellContext` must be used within an `AppCell` component. ' +\n 'Make sure your component is wrapped with `<table.AppCell cell={cell}>...</table.AppCell>`.',\n )\n }\n\n return cell as Cell<TFeatures, any, TValue>\n }\n\n /**\n * Access the header instance from within an `AppHeader` or `AppFooter` wrapper.\n * Use this in custom `headerComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function SortIndicator() {\n * const header = useHeaderContext()\n * const sorted = header.column.getIsSorted()\n * return sorted === 'asc' ? '🔼' : sorted === 'desc' ? '🔽' : null\n * }\n *\n * function ColumnFilter() {\n * const header = useHeaderContext()\n * if (!header.column.getCanFilter()) return null\n * return (\n * <input\n * value={(header.column.getFilterValue() ?? '') as string}\n * onChange={(e) => header.column.setFilterValue(e.target.value)}\n * placeholder=\"Filter...\"\n * />\n * )\n * }\n * ```\n */\n function useHeaderContext<TValue extends CellData = CellData>() {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const header = useContext(HeaderContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!header) {\n throw new Error(\n '`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.',\n )\n }\n\n return header as Header<TFeatures, any, TValue>\n }\n\n /**\n * Context-aware FlexRender component for cells.\n * Uses the cell from context, so no need to pass cell prop.\n */\n function CellFlexRender() {\n const cell = useCellContext()\n return <FlexRender cell={cell} />\n }\n\n /**\n * Context-aware FlexRender component for headers.\n * Uses the header from context, so no need to pass header prop.\n */\n function HeaderFlexRender() {\n const header = useHeaderContext()\n return <FlexRender header={header} />\n }\n\n /**\n * Context-aware FlexRender component for footers.\n * Uses the header from context, so no need to pass footer prop.\n */\n function FooterFlexRender() {\n const header = useHeaderContext()\n return <FlexRender footer={header} />\n }\n\n /**\n * Enhanced useTable hook that returns a table with App wrapper components\n * and pre-bound tableComponents attached directly to the table object.\n *\n * Default options from createTableHook are automatically merged with\n * the options passed here. Options passed here take precedence.\n *\n * TFeatures is already known from the createTableHook call; TData is inferred from the data prop.\n */\n function useAppTable<\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n >(\n tableOptions: Omit<\n TableOptions<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: (state: TableState<TFeatures>) => TSelected,\n ): AppReactTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n > {\n // Merge default options with provided options (provided takes precedence)\n const table = useTable<TFeatures, TData, TSelected>(\n { ...defaultTableOptions, ...tableOptions } as TableOptions<\n TFeatures,\n TData\n >,\n selector,\n )\n\n // AppTable - Root wrapper that provides table context with optional Subscribe\n const AppTable = useMemo(() => {\n function AppTableImpl(props: AppTablePropsWithoutSelector): ReactNode\n function AppTableImpl<TAppTableSelected>(\n props: AppTablePropsWithSelector<TFeatures, TAppTableSelected>,\n ): ReactNode\n function AppTableImpl<TAppTableSelected>(\n props:\n | AppTablePropsWithoutSelector\n | AppTablePropsWithSelector<TFeatures, TAppTableSelected>,\n ): ReactNode {\n const { children, selector: appTableSelector } = props\n\n return (\n <TableContext.Provider value={table}>\n {appTableSelector ? (\n <table.Subscribe selector={appTableSelector}>\n {(state: TAppTableSelected) =>\n (children as (state: TAppTableSelected) => ReactNode)(state)\n }\n </table.Subscribe>\n ) : (\n children\n )}\n </TableContext.Provider>\n )\n }\n return AppTableImpl as AppTableComponent<TFeatures>\n }, [table])\n\n // AppCell - Wraps cell with context, pre-bound cellComponents, and optional Subscribe\n const AppCell = useMemo(() => {\n function AppCellImpl<TValue extends CellData = CellData>(\n props: AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >,\n ): ReactNode\n function AppCellImpl<\n TValue extends CellData = CellData,\n TAppCellSelected = unknown,\n >(\n props: AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TAppCellSelected\n >,\n ): ReactNode\n function AppCellImpl<\n TValue extends CellData = CellData,\n TAppCellSelected = unknown,\n >(\n props:\n | AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >\n | AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TAppCellSelected\n >,\n ): ReactNode {\n const { cell, children, selector: appCellSelector } = props as any\n const extendedCell = Object.assign(cell, {\n FlexRender: CellFlexRender,\n ...cellComponents,\n })\n\n return (\n <CellContext.Provider value={cell}>\n {appCellSelector ? (\n <table.Subscribe selector={appCellSelector}>\n {(state: TAppCellSelected) =>\n (\n children as (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n state: TAppCellSelected,\n ) => ReactNode\n )(extendedCell, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedCell)\n )}\n </CellContext.Provider>\n )\n }\n return AppCellImpl as AppCellComponent<TFeatures, TData, TCellComponents>\n }, [table])\n\n // AppHeader - Wraps header with context, pre-bound headerComponents, and optional Subscribe\n const AppHeader = useMemo(() => {\n function AppHeaderImpl<TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n function AppHeaderImpl<\n TValue extends CellData = CellData,\n TAppHeaderSelected = unknown,\n >(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppHeaderSelected\n >,\n ): ReactNode\n function AppHeaderImpl<\n TValue extends CellData = CellData,\n TAppHeaderSelected = unknown,\n >(\n props:\n | AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >\n | AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppHeaderSelected\n >,\n ): ReactNode {\n const { header, children, selector: appHeaderSelector } = props as any\n const extendedHeader = Object.assign(header, {\n FlexRender: HeaderFlexRender,\n ...headerComponents,\n })\n\n return (\n <HeaderContext.Provider value={header}>\n {appHeaderSelector ? (\n <table.Subscribe selector={appHeaderSelector}>\n {(state: TAppHeaderSelected) =>\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TAppHeaderSelected,\n ) => ReactNode\n )(extendedHeader, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedHeader)\n )}\n </HeaderContext.Provider>\n )\n }\n return AppHeaderImpl as AppHeaderComponent<\n TFeatures,\n TData,\n THeaderComponents\n >\n }, [table])\n\n // AppFooter - Same as AppHeader (footers use Header type)\n const AppFooter = useMemo(() => {\n function AppFooterImpl<TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n function AppFooterImpl<\n TValue extends CellData = CellData,\n TAppFooterSelected = unknown,\n >(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppFooterSelected\n >,\n ): ReactNode\n function AppFooterImpl<\n TValue extends CellData = CellData,\n TAppFooterSelected = unknown,\n >(\n props:\n | AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >\n | AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppFooterSelected\n >,\n ): ReactNode {\n const { header, children, selector: appFooterSelector } = props as any\n const extendedHeader = Object.assign(header, {\n FlexRender: FooterFlexRender,\n ...headerComponents,\n })\n\n return (\n <HeaderContext.Provider value={header}>\n {appFooterSelector ? (\n <table.Subscribe selector={appFooterSelector}>\n {(state: TAppFooterSelected) =>\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TAppFooterSelected,\n ) => ReactNode\n )(extendedHeader, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedHeader)\n )}\n </HeaderContext.Provider>\n )\n }\n return AppFooterImpl as AppHeaderComponent<\n TFeatures,\n TData,\n THeaderComponents\n >\n }, [table])\n\n // Combine everything into the extended table API\n const extendedTable = useMemo(() => {\n return Object.assign(table, {\n AppTable,\n AppCell,\n AppHeader,\n AppFooter,\n ...tableComponents,\n }) as AppReactTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n >\n }, [table, AppTable, AppCell, AppHeader, AppFooter])\n\n return extendedTable\n }\n\n return {\n appFeatures: defaultTableOptions._features as TFeatures,\n createAppColumnHelper,\n useAppTable,\n useTableContext,\n useCellContext,\n useHeaderContext,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6kBA,SAAgB,gBAKd,EACA,iBACA,gBACA,kBACA,GAAG,uBAMF;CAED,MAAM,eAAe,cACnB,KACD;CACD,MAAM,cAAc,cAAyC,KAAc;CAC3E,MAAM,gBAAgB,cACpB,KACD;;;;;;;;;;;;;;;;;;;;CAqBD,SAAS,wBAKP;EAGA,OAAOA,oBAA0C;;;;;;;;;;;;;;;;;;;;;;;;;CA+BnD,SAAS,kBAGP;EAGA,MAAM,QAAQ,WAAW,aAAa;EAGtC,IAAI,CAAC,OACH,MAAM,IAAI,MACR,kJAED;EAGH,OAAO;;;;;;;;;;;;;;;;;;;;CAqBT,SAAS,iBAAqD;EAG5D,MAAM,OAAO,WAAW,YAAY;EAGpC,IAAI,CAAC,MACH,MAAM,IAAI,MACR,0JAED;EAGH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BT,SAAS,mBAAuD;EAG9D,MAAM,SAAS,WAAW,cAAc;EAGxC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,kFACD;EAGH,OAAO;;;;;;CAOT,SAAS,iBAAiB;EACxB,MAAM,OAAO,gBAAgB;EAC7B,OAAO,oCAAC,YAAD,EAAkB,MAAQ;;;;;;CAOnC,SAAS,mBAAmB;EAC1B,MAAM,SAAS,kBAAkB;EACjC,OAAO,oCAAC,YAAD,EAAoB,QAAU;;;;;;CAOvC,SAAS,mBAAmB;EAC1B,MAAM,SAAS,kBAAkB;EACjC,OAAO,oCAAC,YAAD,EAAY,QAAQ,QAAU;;;;;;;;;;;CAYvC,SAAS,YAIP,cAIA,UAQA;EAEA,MAAM,QAAQ,SACZ;GAAE,GAAG;GAAqB,GAAG;GAAc,EAI3C,SACD;EAGD,MAAM,WAAW,cAAc;GAK7B,SAAS,aACP,OAGW;IACX,MAAM,EAAE,UAAU,UAAU,qBAAqB;IAEjD,OACE,oCAAC,aAAa,UAAd,EAAuB,OAAO,OAUN,EATrB,mBACC,oCAAC,MAAM,WAAP,EAAiB,UAAU,kBAIT,GAHd,UACC,SAAqD,MAAM,CAE9C,GAElB,SAEoB;;GAG5B,OAAO;KACN,CAAC,MAAM,CAAC;EAGX,MAAM,UAAU,cAAc;GAqB5B,SAAS,YAIP,OAcW;IACX,MAAM,EAAE,MAAM,UAAU,UAAU,oBAAoB;IACtD,MAAM,eAAe,OAAO,OAAO,MAAM;KACvC,YAAY;KACZ,GAAG;KACJ,CAAC;IAEF,OACE,oCAAC,YAAY,UAAb,EAAsB,OAAO,MAqBN,EApBpB,kBACC,oCAAC,MAAM,WAAP,EAAiB,UAAU,iBAUT,GATd,UAEE,SAKA,cAAc,MAAM,CAER,GAGhB,SAIA,aAAa,CAEI;;GAG3B,OAAO;KACN,CAAC,MAAM,CAAC;EAGX,MAAM,YAAY,cAAc;GAqB9B,SAAS,cAIP,OAcW;IACX,MAAM,EAAE,QAAQ,UAAU,UAAU,sBAAsB;IAC1D,MAAM,iBAAiB,OAAO,OAAO,QAAQ;KAC3C,YAAY;KACZ,GAAG;KACJ,CAAC;IAEF,OACE,oCAAC,cAAc,UAAf,EAAwB,OAAO,QAqBN,EApBtB,oBACC,oCAAC,MAAM,WAAP,EAAiB,UAAU,mBAUT,GATd,UAEE,SAKA,gBAAgB,MAAM,CAEV,GAGhB,SAIA,eAAe,CAEI;;GAG7B,OAAO;KAKN,CAAC,MAAM,CAAC;EAGX,MAAM,YAAY,cAAc;GAqB9B,SAAS,cAIP,OAcW;IACX,MAAM,EAAE,QAAQ,UAAU,UAAU,sBAAsB;IAC1D,MAAM,iBAAiB,OAAO,OAAO,QAAQ;KAC3C,YAAY;KACZ,GAAG;KACJ,CAAC;IAEF,OACE,oCAAC,cAAc,UAAf,EAAwB,OAAO,QAqBN,EApBtB,oBACC,oCAAC,MAAM,WAAP,EAAiB,UAAU,mBAUT,GATd,UAEE,SAKA,gBAAgB,MAAM,CAEV,GAGhB,SAIA,eAAe,CAEI;;GAG7B,OAAO;KAKN,CAAC,MAAM,CAAC;EAoBX,OAjBsB,cAAc;GAClC,OAAO,OAAO,OAAO,OAAO;IAC1B;IACA;IACA;IACA;IACA,GAAG;IACJ,CAAC;KAQD;GAAC;GAAO;GAAU;GAAS;GAAW;GAAU,CAE/B;;CAGtB,OAAO;EACL,aAAa,oBAAoB;EACjC;EACA;EACA;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"createTableHook.js","names":["coreCreateColumnHelper"],"sources":["../src/createTableHook.tsx"],"sourcesContent":["'use client'\n/* eslint-disable @eslint-react/no-context-provider */\nimport React, { createContext, useContext, useMemo } from 'react'\nimport { createColumnHelper as coreCreateColumnHelper } from '@tanstack/table-core'\nimport { useTable } from './useTable'\nimport { FlexRender } from './FlexRender'\nimport type {\n AccessorFn,\n AccessorFnColumnDef,\n AccessorKeyColumnDef,\n Cell,\n CellContext,\n CellData,\n Column,\n ColumnDef,\n DeepKeys,\n DeepValue,\n DisplayColumnDef,\n GroupColumnDef,\n Header,\n IdentifiedColumnDef,\n NoInfer,\n Row,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ComponentType, ReactNode } from 'react'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// Enhanced Context Types with Pre-bound Components\n// =============================================================================\n\n/**\n * Enhanced CellContext with pre-bound cell components.\n * The `cell` property includes the registered cellComponents.\n */\nexport type AppCellContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> = {\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode }\n column: Column<TFeatures, TData, TValue>\n getValue: CellContext<TFeatures, TData, TValue>['getValue']\n renderValue: CellContext<TFeatures, TData, TValue>['renderValue']\n row: Row<TFeatures, TData>\n table: Table<TFeatures, TData>\n}\n\n/**\n * Enhanced HeaderContext with pre-bound header components.\n * The `header` property includes the registered headerComponents.\n */\nexport type AppHeaderContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n column: Column<TFeatures, TData, TValue>\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode }\n table: Table<TFeatures, TData>\n}\n\n// =============================================================================\n// Enhanced Column Definition Types\n// =============================================================================\n\n/**\n * Template type for column definitions that can be a string or a function.\n */\nexport type AppColumnDefTemplate<TProps extends object> =\n | string\n | ((props: TProps) => any)\n\n/**\n * Enhanced column definition base with pre-bound components in cell/header/footer contexts.\n */\nexport type AppColumnDefBase<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n IdentifiedColumnDef<TFeatures, TData, TValue>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, TValue, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>\n >\n}\n\n/**\n * Enhanced display column definition with pre-bound components.\n */\nexport type AppDisplayColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n DisplayColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n}\n\n/**\n * Enhanced group column definition with pre-bound components.\n */\nexport type AppGroupColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n GroupColumnDef<TFeatures, TData, unknown>,\n 'cell' | 'header' | 'footer' | 'columns'\n> & {\n cell?: AppColumnDefTemplate<\n AppCellContext<TFeatures, TData, unknown, TCellComponents>\n >\n header?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n footer?: AppColumnDefTemplate<\n AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>\n >\n columns?: Array<ColumnDef<TFeatures, TData, unknown>>\n}\n\n// =============================================================================\n// Enhanced Column Helper Type\n// =============================================================================\n\n/**\n * Enhanced column helper with pre-bound components in cell/header/footer contexts.\n * This enables TypeScript to know about the registered components when defining columns.\n */\nexport type AppColumnHelper<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = {\n /**\n * Creates a data column definition with an accessor key or function.\n * The cell, header, and footer contexts include pre-bound components.\n */\n accessor: <\n TAccessor extends AccessorFn<TData> | DeepKeys<TData>,\n TValue extends TAccessor extends AccessorFn<TData, infer TReturn>\n ? TReturn\n : TAccessor extends DeepKeys<TData>\n ? DeepValue<TData, TAccessor>\n : never,\n >(\n accessor: TAccessor,\n column: TAccessor extends AccessorFn<TData>\n ? AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n > & { id: string }\n : AppColumnDefBase<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n THeaderComponents\n >,\n ) => TAccessor extends AccessorFn<TData>\n ? AccessorFnColumnDef<TFeatures, TData, TValue>\n : AccessorKeyColumnDef<TFeatures, TData, TValue>\n\n /**\n * Wraps an array of column definitions to preserve each column's individual TValue type.\n */\n columns: <TColumns extends ReadonlyArray<ColumnDef<TFeatures, TData, any>>>(\n columns: [...TColumns],\n ) => Array<ColumnDef<TFeatures, TData, any>> & [...TColumns]\n\n /**\n * Creates a display column definition for non-data columns.\n * The cell, header, and footer contexts include pre-bound components.\n */\n display: (\n column: AppDisplayColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => DisplayColumnDef<TFeatures, TData, unknown>\n\n /**\n * Creates a group column definition with nested child columns.\n * The cell, header, and footer contexts include pre-bound components.\n */\n group: (\n column: AppGroupColumnDef<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >,\n ) => GroupColumnDef<TFeatures, TData, unknown>\n}\n\n// =============================================================================\n// CreateTableHook Options and Props\n// =============================================================================\n\n/**\n * Options for creating a table hook with pre-bound components and default table options.\n * Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initialState'.\n */\nexport type CreateTableHookOptions<\n TFeatures extends TableFeatures,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = Omit<\n TableOptions<TFeatures, any>,\n 'columns' | 'data' | 'store' | 'state' | 'initialState'\n> & {\n /**\n * Table-level components that need access to the table instance.\n * These are available directly on the table object returned by useAppTable.\n * Use `useTableContext()` inside these components.\n * @example { PaginationControls, GlobalFilter, RowCount }\n */\n tableComponents?: TTableComponents\n /**\n * Cell-level components that need access to the cell instance.\n * These are available on the cell object passed to AppCell's children.\n * Use `useCellContext()` inside these components.\n * @example { TextCell, NumberCell, DateCell, CurrencyCell }\n */\n cellComponents?: TCellComponents\n /**\n * Header-level components that need access to the header instance.\n * These are available on the header object passed to AppHeader/AppFooter's children.\n * Use `useHeaderContext()` inside these components.\n * @example { SortIndicator, ColumnFilter, ResizeHandle }\n */\n headerComponents?: THeaderComponents\n}\n\n/**\n * Props for AppTable component - without selector\n */\nexport interface AppTablePropsWithoutSelector {\n children: ReactNode\n selector?: never\n}\n\n/**\n * Props for AppTable component - with selector\n */\nexport interface AppTablePropsWithSelector<\n TFeatures extends TableFeatures,\n TSelected,\n> {\n children: (state: TSelected) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Props for AppCell component - without selector\n */\nexport interface AppCellPropsWithoutSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> {\n cell: Cell<TFeatures, TData, TValue>\n children: (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n selector?: never\n}\n\n/**\n * Props for AppCell component - with selector\n */\nexport interface AppCellPropsWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TCellComponents extends Record<string, ComponentType<any>>,\n TSelected,\n> {\n cell: Cell<TFeatures, TData, TValue>\n children: (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n state: TSelected,\n ) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Props for AppHeader/AppFooter component - without selector\n */\nexport interface AppHeaderPropsWithoutSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> {\n header: Header<TFeatures, TData, TValue>\n children: (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n selector?: never\n}\n\n/**\n * Props for AppHeader/AppFooter component - with selector\n */\nexport interface AppHeaderPropsWithSelector<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n TSelected,\n> {\n header: Header<TFeatures, TData, TValue>\n children: (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TSelected,\n ) => ReactNode\n selector: (state: TableState<TFeatures>) => TSelected\n}\n\n/**\n * Component type for AppCell - wraps a cell and provides cell context with optional Subscribe\n */\nexport interface AppCellComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TCellComponents extends Record<string, ComponentType<any>>,\n> {\n <TValue extends CellData = CellData>(\n props: AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >,\n ): ReactNode\n <TValue extends CellData = CellData, TSelected = unknown>(\n props: AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TSelected\n >,\n ): ReactNode\n}\n\n/**\n * Component type for AppHeader/AppFooter - wraps a header and provides header context with optional Subscribe\n */\nexport interface AppHeaderComponent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> {\n <TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n <TValue extends CellData = CellData, TSelected = unknown>(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TSelected\n >,\n ): ReactNode\n}\n\n/**\n * Component type for AppTable - root wrapper with optional Subscribe\n */\nexport interface AppTableComponent<TFeatures extends TableFeatures> {\n (props: AppTablePropsWithoutSelector): ReactNode\n <TSelected>(props: AppTablePropsWithSelector<TFeatures, TSelected>): ReactNode\n}\n\n/**\n * Extended table API returned by useAppTable with all App wrapper components\n */\nexport type AppReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected,\n TTableComponents extends Record<string, ComponentType<any>>,\n TCellComponents extends Record<string, ComponentType<any>>,\n THeaderComponents extends Record<string, ComponentType<any>>,\n> = ReactTable<TFeatures, TData, TSelected> &\n NoInfer<TTableComponents> & {\n /**\n * Root wrapper component that provides table context with optional Subscribe.\n * @example\n * ```tsx\n * // Without selector - children is ReactNode\n * <table.AppTable>\n * <table>...</table>\n * </table.AppTable>\n *\n * // With selector - children receives selected state\n * <table.AppTable selector={(s) => s.pagination}>\n * {(pagination) => <div>Page {pagination.pageIndex}</div>}\n * </table.AppTable>\n * ```\n */\n AppTable: AppTableComponent<TFeatures>\n /**\n * Wraps a cell and provides cell context with pre-bound cellComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * // Without selector\n * <table.AppCell cell={cell}>\n * {(c) => <td><c.TextCell /></td>}\n * </table.AppCell>\n *\n * // With selector - children receives cell and selected state\n * <table.AppCell cell={cell} selector={(s) => s.columnFilters}>\n * {(c, filters) => <td>{filters.length}</td>}\n * </table.AppCell>\n * ```\n */\n AppCell: AppCellComponent<TFeatures, TData, NoInfer<TCellComponents>>\n /**\n * Wraps a header and provides header context with pre-bound headerComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * // Without selector\n * <table.AppHeader header={header}>\n * {(h) => <th><h.SortIndicator /></th>}\n * </table.AppHeader>\n *\n * // With selector\n * <table.AppHeader header={header} selector={(s) => s.sorting}>\n * {(h, sorting) => <th>{sorting.length} sorted</th>}\n * </table.AppHeader>\n * ```\n */\n AppHeader: AppHeaderComponent<TFeatures, TData, NoInfer<THeaderComponents>>\n /**\n * Wraps a footer and provides header context with pre-bound headerComponents.\n * Optionally accepts a selector for Subscribe functionality.\n * @example\n * ```tsx\n * <table.AppFooter header={footer}>\n * {(f) => <td><table.FlexRender footer={footer} /></td>}\n * </table.AppFooter>\n * ```\n */\n AppFooter: AppHeaderComponent<TFeatures, TData, NoInfer<THeaderComponents>>\n }\n\n/**\n * Creates a custom table hook with pre-bound components for composition.\n *\n * This is the table equivalent of TanStack Form's `createFormHook`. It allows you to:\n * - Define features, row models, and default options once, shared across all tables\n * - Register reusable table, cell, and header components\n * - Access table/cell/header instances via context in those components\n * - Get a `useAppTable` hook that returns an extended table with App wrapper components\n * - Get a `createAppColumnHelper` function pre-bound to your features\n *\n * @example\n * ```tsx\n * // hooks/table.ts\n * export const {\n * useAppTable,\n * createAppColumnHelper,\n * useTableContext,\n * useCellContext,\n * useHeaderContext,\n * } = createTableHook({\n * _features: tableFeatures({\n * rowPaginationFeature,\n * rowSortingFeature,\n * columnFilteringFeature,\n * }),\n * _rowModels: {\n * paginatedRowModel: createPaginatedRowModel(),\n * sortedRowModel: createSortedRowModel(sortFns),\n * filteredRowModel: createFilteredRowModel(filterFns),\n * },\n * tableComponents: { PaginationControls, RowCount },\n * cellComponents: { TextCell, NumberCell },\n * headerComponents: { SortIndicator, ColumnFilter },\n * })\n *\n * // Create column helper with TFeatures already bound\n * const columnHelper = createAppColumnHelper<Person>()\n *\n * // components/table-components.tsx\n * function PaginationControls() {\n * const table = useTableContext() // TFeatures already known!\n * return <table.Subscribe selector={(s) => s.pagination}>...</table.Subscribe>\n * }\n *\n * // features/users.tsx\n * function UsersTable({ data }: { data: Person[] }) {\n * const table = useAppTable({\n * columns,\n * data, // TData inferred from Person[]\n * })\n *\n * return (\n * <table.AppTable>\n * <table>\n * <thead>\n * {table.getHeaderGroups().map(headerGroup => (\n * <tr key={headerGroup.id}>\n * {headerGroup.headers.map(h => (\n * <table.AppHeader header={h} key={h.id}>\n * {(header) => (\n * <th>\n * <table.FlexRender header={h} />\n * <header.SortIndicator />\n * </th>\n * )}\n * </table.AppHeader>\n * ))}\n * </tr>\n * ))}\n * </thead>\n * <tbody>\n * {table.getRowModel().rows.map(row => (\n * <tr key={row.id}>\n * {row.getAllCells().map(c => (\n * <table.AppCell cell={c} key={c.id}>\n * {(cell) => <td><cell.TextCell /></td>}\n * </table.AppCell>\n * ))}\n * </tr>\n * ))}\n * </tbody>\n * </table>\n * <table.PaginationControls />\n * </table.AppTable>\n * )\n * }\n * ```\n */\nexport function createTableHook<\n TFeatures extends TableFeatures,\n const TTableComponents extends Record<string, ComponentType<any>>,\n const TCellComponents extends Record<string, ComponentType<any>>,\n const THeaderComponents extends Record<string, ComponentType<any>>,\n>({\n tableComponents,\n cellComponents,\n headerComponents,\n ...defaultTableOptions\n}: CreateTableHookOptions<\n TFeatures,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n>) {\n // Create contexts internally with TFeatures baked in\n const TableContext = createContext<ReactTable<TFeatures, any, any>>(\n null as never,\n )\n const CellContext = createContext<Cell<TFeatures, any, any>>(null as never)\n const HeaderContext = createContext<Header<TFeatures, any, any>>(\n null as never,\n )\n\n /**\n * Create a column helper pre-bound to the features and components configured in this table hook.\n * The cell, header, and footer contexts include pre-bound components (e.g., `cell.TextCell`).\n * @example\n * ```tsx\n * const columnHelper = createAppColumnHelper<Person>()\n *\n * const columns = [\n * columnHelper.accessor('firstName', {\n * header: 'First Name',\n * cell: ({ cell }) => <cell.TextCell />, // cell has pre-bound components!\n * }),\n * columnHelper.accessor('age', {\n * header: 'Age',\n * cell: ({ cell }) => <cell.NumberCell />,\n * }),\n * ]\n * ```\n */\n function createAppColumnHelper<TData extends RowData>(): AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n > {\n // The runtime implementation is the same - components are attached at render time\n // This cast provides the enhanced types for column definitions\n return coreCreateColumnHelper<TFeatures, TData>() as AppColumnHelper<\n TFeatures,\n TData,\n TCellComponents,\n THeaderComponents\n >\n }\n\n /**\n * Access the table instance from within an `AppTable` wrapper.\n * Use this in custom `tableComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function PaginationControls() {\n * const table = useTableContext()\n * return (\n * <table.Subscribe selector={(s) => s.pagination}>\n * {(pagination) => (\n * <div>\n * <button onClick={() => table.previousPage()}>Prev</button>\n * <span>Page {pagination.pageIndex + 1}</span>\n * <button onClick={() => table.nextPage()}>Next</button>\n * </div>\n * )}\n * </table.Subscribe>\n * )\n * }\n * ```\n */\n function useTableContext<TData extends RowData = RowData>(): ReactTable<\n TFeatures,\n TData\n > {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const table = useContext(TableContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!table) {\n throw new Error(\n '`useTableContext` must be used within an `AppTable` component. ' +\n 'Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.',\n )\n }\n\n return table as ReactTable<TFeatures, TData>\n }\n\n /**\n * Access the cell instance from within an `AppCell` wrapper.\n * Use this in custom `cellComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function TextCell() {\n * const cell = useCellContext<string>()\n * return <span>{cell.getValue()}</span>\n * }\n *\n * function NumberCell({ format }: { format?: Intl.NumberFormatOptions }) {\n * const cell = useCellContext<number>()\n * return <span>{cell.getValue().toLocaleString(undefined, format)}</span>\n * }\n * ```\n */\n function useCellContext<TValue extends CellData = CellData>() {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const cell = useContext(CellContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!cell) {\n throw new Error(\n '`useCellContext` must be used within an `AppCell` component. ' +\n 'Make sure your component is wrapped with `<table.AppCell cell={cell}>...</table.AppCell>`.',\n )\n }\n\n return cell as Cell<TFeatures, any, TValue>\n }\n\n /**\n * Access the header instance from within an `AppHeader` or `AppFooter` wrapper.\n * Use this in custom `headerComponents` passed to `createTableHook`.\n * TFeatures is already known from the createTableHook call.\n *\n * @example\n * ```tsx\n * function SortIndicator() {\n * const header = useHeaderContext()\n * const sorted = header.column.getIsSorted()\n * return sorted === 'asc' ? '🔼' : sorted === 'desc' ? '🔽' : null\n * }\n *\n * function ColumnFilter() {\n * const header = useHeaderContext()\n * if (!header.column.getCanFilter()) return null\n * return (\n * <input\n * value={(header.column.getFilterValue() ?? '') as string}\n * onChange={(e) => header.column.setFilterValue(e.target.value)}\n * placeholder=\"Filter...\"\n * />\n * )\n * }\n * ```\n */\n function useHeaderContext<TValue extends CellData = CellData>() {\n // `useContext` keeps React 18 support; `use(Context)` is React 19+ only.\n // eslint-disable-next-line @eslint-react/no-use-context -- intentional for React 18\n const header = useContext(HeaderContext)\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!header) {\n throw new Error(\n '`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.',\n )\n }\n\n return header as Header<TFeatures, any, TValue>\n }\n\n /**\n * Context-aware FlexRender component for cells.\n * Uses the cell from context, so no need to pass cell prop.\n */\n function CellFlexRender() {\n const cell = useCellContext()\n return <FlexRender cell={cell} />\n }\n\n /**\n * Context-aware FlexRender component for headers.\n * Uses the header from context, so no need to pass header prop.\n */\n function HeaderFlexRender() {\n const header = useHeaderContext()\n return <FlexRender header={header} />\n }\n\n /**\n * Context-aware FlexRender component for footers.\n * Uses the header from context, so no need to pass footer prop.\n */\n function FooterFlexRender() {\n const header = useHeaderContext()\n return <FlexRender footer={header} />\n }\n\n /**\n * Enhanced useTable hook that returns a table with App wrapper components\n * and pre-bound tableComponents attached directly to the table object.\n *\n * Default options from createTableHook are automatically merged with\n * the options passed here. Options passed here take precedence.\n *\n * TFeatures is already known from the createTableHook call; TData is inferred from the data prop.\n */\n function useAppTable<\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n >(\n tableOptions: Omit<\n TableOptions<TFeatures, TData>,\n '_features' | '_rowModels'\n >,\n selector?: (state: TableState<TFeatures>) => TSelected,\n ): AppReactTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n > {\n // Merge default options with provided options (provided takes precedence)\n const table = useTable<TFeatures, TData, TSelected>(\n { ...defaultTableOptions, ...tableOptions } as TableOptions<\n TFeatures,\n TData\n >,\n selector,\n )\n\n // AppTable - Root wrapper that provides table context with optional Subscribe\n const AppTable = useMemo(() => {\n function AppTableImpl(props: AppTablePropsWithoutSelector): ReactNode\n function AppTableImpl<TAppTableSelected>(\n props: AppTablePropsWithSelector<TFeatures, TAppTableSelected>,\n ): ReactNode\n function AppTableImpl<TAppTableSelected>(\n props:\n | AppTablePropsWithoutSelector\n | AppTablePropsWithSelector<TFeatures, TAppTableSelected>,\n ): ReactNode {\n const { children, selector: appTableSelector } = props\n\n return (\n <TableContext.Provider value={table}>\n {appTableSelector ? (\n <table.Subscribe selector={appTableSelector}>\n {(state: TAppTableSelected) =>\n (children as (state: TAppTableSelected) => ReactNode)(state)\n }\n </table.Subscribe>\n ) : (\n children\n )}\n </TableContext.Provider>\n )\n }\n return AppTableImpl as AppTableComponent<TFeatures>\n }, [table])\n\n // AppCell - Wraps cell with context, pre-bound cellComponents, and optional Subscribe\n const AppCell = useMemo(() => {\n function AppCellImpl<TValue extends CellData = CellData>(\n props: AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >,\n ): ReactNode\n function AppCellImpl<\n TValue extends CellData = CellData,\n TAppCellSelected = unknown,\n >(\n props: AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TAppCellSelected\n >,\n ): ReactNode\n function AppCellImpl<\n TValue extends CellData = CellData,\n TAppCellSelected = unknown,\n >(\n props:\n | AppCellPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents\n >\n | AppCellPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n TCellComponents,\n TAppCellSelected\n >,\n ): ReactNode {\n const { cell, children, selector: appCellSelector } = props as any\n const extendedCell = Object.assign(cell, {\n FlexRender: CellFlexRender,\n ...cellComponents,\n })\n\n return (\n <CellContext.Provider value={cell}>\n {appCellSelector ? (\n <table.Subscribe selector={appCellSelector}>\n {(state: TAppCellSelected) =>\n (\n children as (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n state: TAppCellSelected,\n ) => ReactNode\n )(extendedCell, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n cell: Cell<TFeatures, TData, TValue> &\n TCellComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedCell)\n )}\n </CellContext.Provider>\n )\n }\n return AppCellImpl as AppCellComponent<TFeatures, TData, TCellComponents>\n }, [table])\n\n // AppHeader - Wraps header with context, pre-bound headerComponents, and optional Subscribe\n const AppHeader = useMemo(() => {\n function AppHeaderImpl<TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n function AppHeaderImpl<\n TValue extends CellData = CellData,\n TAppHeaderSelected = unknown,\n >(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppHeaderSelected\n >,\n ): ReactNode\n function AppHeaderImpl<\n TValue extends CellData = CellData,\n TAppHeaderSelected = unknown,\n >(\n props:\n | AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >\n | AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppHeaderSelected\n >,\n ): ReactNode {\n const { header, children, selector: appHeaderSelector } = props as any\n const extendedHeader = Object.assign(header, {\n FlexRender: HeaderFlexRender,\n ...headerComponents,\n })\n\n return (\n <HeaderContext.Provider value={header}>\n {appHeaderSelector ? (\n <table.Subscribe selector={appHeaderSelector}>\n {(state: TAppHeaderSelected) =>\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TAppHeaderSelected,\n ) => ReactNode\n )(extendedHeader, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedHeader)\n )}\n </HeaderContext.Provider>\n )\n }\n return AppHeaderImpl as AppHeaderComponent<\n TFeatures,\n TData,\n THeaderComponents\n >\n }, [table])\n\n // AppFooter - Same as AppHeader (footers use Header type)\n const AppFooter = useMemo(() => {\n function AppFooterImpl<TValue extends CellData = CellData>(\n props: AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >,\n ): ReactNode\n function AppFooterImpl<\n TValue extends CellData = CellData,\n TAppFooterSelected = unknown,\n >(\n props: AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppFooterSelected\n >,\n ): ReactNode\n function AppFooterImpl<\n TValue extends CellData = CellData,\n TAppFooterSelected = unknown,\n >(\n props:\n | AppHeaderPropsWithoutSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents\n >\n | AppHeaderPropsWithSelector<\n TFeatures,\n TData,\n TValue,\n THeaderComponents,\n TAppFooterSelected\n >,\n ): ReactNode {\n const { header, children, selector: appFooterSelector } = props as any\n const extendedHeader = Object.assign(header, {\n FlexRender: FooterFlexRender,\n ...headerComponents,\n })\n\n return (\n <HeaderContext.Provider value={header}>\n {appFooterSelector ? (\n <table.Subscribe selector={appFooterSelector}>\n {(state: TAppFooterSelected) =>\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n state: TAppFooterSelected,\n ) => ReactNode\n )(extendedHeader, state)\n }\n </table.Subscribe>\n ) : (\n (\n children as (\n header: Header<TFeatures, TData, TValue> &\n THeaderComponents & { FlexRender: () => ReactNode },\n ) => ReactNode\n )(extendedHeader)\n )}\n </HeaderContext.Provider>\n )\n }\n return AppFooterImpl as AppHeaderComponent<\n TFeatures,\n TData,\n THeaderComponents\n >\n }, [table])\n\n // Combine everything into the extended table API\n const extendedTable = useMemo(() => {\n return Object.assign(table, {\n AppTable,\n AppCell,\n AppHeader,\n AppFooter,\n ...tableComponents,\n }) as AppReactTable<\n TFeatures,\n TData,\n TSelected,\n TTableComponents,\n TCellComponents,\n THeaderComponents\n >\n }, [table, AppTable, AppCell, AppHeader, AppFooter])\n\n return extendedTable\n }\n\n return {\n appFeatures: defaultTableOptions._features as TFeatures,\n createAppColumnHelper,\n useAppTable,\n useTableContext,\n useCellContext,\n useHeaderContext,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6kBA,SAAgB,gBAKd,EACA,iBACA,gBACA,kBACA,GAAG,uBAMF;CAED,MAAM,eAAe,cACnB,IACF;CACA,MAAM,cAAc,cAAyC,IAAa;CAC1E,MAAM,gBAAgB,cACpB,IACF;;;;;;;;;;;;;;;;;;;;CAqBA,SAAS,wBAKP;EAGA,OAAOA,mBAAyC;CAMlD;;;;;;;;;;;;;;;;;;;;;;;;CAyBA,SAAS,kBAGP;EAGA,MAAM,QAAQ,WAAW,YAAY;EAGrC,IAAI,CAAC,OACH,MAAM,IAAI,MACR,iJAEF;EAGF,OAAO;CACT;;;;;;;;;;;;;;;;;;;CAoBA,SAAS,iBAAqD;EAG5D,MAAM,OAAO,WAAW,WAAW;EAGnC,IAAI,CAAC,MACH,MAAM,IAAI,MACR,yJAEF;EAGF,OAAO;CACT;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BA,SAAS,mBAAuD;EAG9D,MAAM,SAAS,WAAW,aAAa;EAGvC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,iFACF;EAGF,OAAO;CACT;;;;;CAMA,SAAS,iBAAiB;EACxB,MAAM,OAAO,eAAe;EAC5B,OAAO,oCAAC,YAAD,EAAkB,KAAO;CAClC;;;;;CAMA,SAAS,mBAAmB;EAC1B,MAAM,SAAS,iBAAiB;EAChC,OAAO,oCAAC,YAAD,EAAoB,OAAS;CACtC;;;;;CAMA,SAAS,mBAAmB;EAC1B,MAAM,SAAS,iBAAiB;EAChC,OAAO,oCAAC,YAAD,EAAY,QAAQ,OAAS;CACtC;;;;;;;;;;CAWA,SAAS,YAIP,cAIA,UAQA;EAEA,MAAM,QAAQ,SACZ;GAAE,GAAG;GAAqB,GAAG;EAAa,GAI1C,QACF;EAGA,MAAM,WAAW,cAAc;GAK7B,SAAS,aACP,OAGW;IACX,MAAM,EAAE,UAAU,UAAU,qBAAqB;IAEjD,OACE,oCAAC,aAAa,UAAd,EAAuB,OAAO,MAUP,GATpB,mBACC,oCAAC,MAAM,WAAP,EAAiB,UAAU,iBAIV,IAHb,UACC,SAAqD,KAAK,CAE9C,IAEjB,QAEmB;GAE3B;GACA,OAAO;EACT,GAAG,CAAC,KAAK,CAAC;EAGV,MAAM,UAAU,cAAc;GAqB5B,SAAS,YAIP,OAcW;IACX,MAAM,EAAE,MAAM,UAAU,UAAU,oBAAoB;IACtD,MAAM,eAAe,OAAO,OAAO,MAAM;KACvC,YAAY;KACZ,GAAG;IACL,CAAC;IAED,OACE,oCAAC,YAAY,UAAb,EAAsB,OAAO,KAqBP,GApBnB,kBACC,oCAAC,MAAM,WAAP,EAAiB,UAAU,gBAUV,IATb,UAEE,SAKA,cAAc,KAAK,CAER,IAGf,SAIA,YAAY,CAEI;GAE1B;GACA,OAAO;EACT,GAAG,CAAC,KAAK,CAAC;EAGV,MAAM,YAAY,cAAc;GAqB9B,SAAS,cAIP,OAcW;IACX,MAAM,EAAE,QAAQ,UAAU,UAAU,sBAAsB;IAC1D,MAAM,iBAAiB,OAAO,OAAO,QAAQ;KAC3C,YAAY;KACZ,GAAG;IACL,CAAC;IAED,OACE,oCAAC,cAAc,UAAf,EAAwB,OAAO,OAqBP,GApBrB,oBACC,oCAAC,MAAM,WAAP,EAAiB,UAAU,kBAUV,IATb,UAEE,SAKA,gBAAgB,KAAK,CAEV,IAGf,SAIA,cAAc,CAEI;GAE5B;GACA,OAAO;EAKT,GAAG,CAAC,KAAK,CAAC;EAGV,MAAM,YAAY,cAAc;GAqB9B,SAAS,cAIP,OAcW;IACX,MAAM,EAAE,QAAQ,UAAU,UAAU,sBAAsB;IAC1D,MAAM,iBAAiB,OAAO,OAAO,QAAQ;KAC3C,YAAY;KACZ,GAAG;IACL,CAAC;IAED,OACE,oCAAC,cAAc,UAAf,EAAwB,OAAO,OAqBP,GApBrB,oBACC,oCAAC,MAAM,WAAP,EAAiB,UAAU,kBAUV,IATb,UAEE,SAKA,gBAAgB,KAAK,CAEV,IAGf,SAIA,cAAc,CAEI;GAE5B;GACA,OAAO;EAKT,GAAG,CAAC,KAAK,CAAC;EAoBV,OAjBsB,cAAc;GAClC,OAAO,OAAO,OAAO,OAAO;IAC1B;IACA;IACA;IACA;IACA,GAAG;GACL,CAAC;EAQH,GAAG;GAAC;GAAO;GAAU;GAAS;GAAW;EAAS,CAE/B;CACrB;CAEA,OAAO;EACL,aAAa,oBAAoB;EACjC;EACA;EACA;EACA;EACA;CACF;AACF"}
|
package/dist/reactivity.cjs
CHANGED
package/dist/reactivity.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactivity.cjs","names":[],"sources":["../src/reactivity.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/react-store'\nimport type {\n TableAtomOptions,\n TableReactivityBindings,\n} from '@tanstack/table-core/reactivity'\n\n/**\n * Creates the table-core reactivity bindings used by the React adapter.\n *\n * React stores table state in TanStack Store atoms and leaves options as plain\n * resolved data because `useTable` synchronizes options during render.\n */\nexport function reactReactivity(): TableReactivityBindings {\n return {\n createOptionsStore: false,\n schedule: (fn) => queueMicrotask(fn),\n batch,\n untrack: (fn) => fn(),\n createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => {\n return createAtom(() => fn(), {\n compare: options?.compare,\n })\n },\n createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {\n return createAtom(value, {\n compare: options?.compare,\n })\n },\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"reactivity.cjs","names":[],"sources":["../src/reactivity.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/react-store'\nimport type {\n TableAtomOptions,\n TableReactivityBindings,\n} from '@tanstack/table-core/reactivity'\n\n/**\n * Creates the table-core reactivity bindings used by the React adapter.\n *\n * React stores table state in TanStack Store atoms and leaves options as plain\n * resolved data because `useTable` synchronizes options during render.\n */\nexport function reactReactivity(): TableReactivityBindings {\n return {\n createOptionsStore: false,\n schedule: (fn) => queueMicrotask(fn),\n batch,\n untrack: (fn) => fn(),\n createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => {\n return createAtom(() => fn(), {\n compare: options?.compare,\n })\n },\n createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {\n return createAtom(value, {\n compare: options?.compare,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,kBAA2C;CACzD,OAAO;EACL,oBAAoB;EACpB,WAAW,OAAO,eAAe,EAAE;EACnC;EACA,UAAU,OAAO,GAAG;EACpB,qBAAwB,IAAa,YAAkC;GACrE,mDAAwB,GAAG,GAAG,EAC5B,2DAAS,QAAS,QACpB,CAAC;EACH;EACA,qBAAwB,OAAU,YAAkC;GAClE,6CAAkB,OAAO,EACvB,2DAAS,QAAS,QACpB,CAAC;EACH;CACF;AACF"}
|
package/dist/reactivity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactivity.js","names":[],"sources":["../src/reactivity.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/react-store'\nimport type {\n TableAtomOptions,\n TableReactivityBindings,\n} from '@tanstack/table-core/reactivity'\n\n/**\n * Creates the table-core reactivity bindings used by the React adapter.\n *\n * React stores table state in TanStack Store atoms and leaves options as plain\n * resolved data because `useTable` synchronizes options during render.\n */\nexport function reactReactivity(): TableReactivityBindings {\n return {\n createOptionsStore: false,\n schedule: (fn) => queueMicrotask(fn),\n batch,\n untrack: (fn) => fn(),\n createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => {\n return createAtom(() => fn(), {\n compare: options?.compare,\n })\n },\n createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {\n return createAtom(value, {\n compare: options?.compare,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,kBAA2C;CACzD,OAAO;EACL,oBAAoB;EACpB,WAAW,OAAO,eAAe,
|
|
1
|
+
{"version":3,"file":"reactivity.js","names":[],"sources":["../src/reactivity.ts"],"sourcesContent":["import { batch, createAtom } from '@tanstack/react-store'\nimport type {\n TableAtomOptions,\n TableReactivityBindings,\n} from '@tanstack/table-core/reactivity'\n\n/**\n * Creates the table-core reactivity bindings used by the React adapter.\n *\n * React stores table state in TanStack Store atoms and leaves options as plain\n * resolved data because `useTable` synchronizes options during render.\n */\nexport function reactReactivity(): TableReactivityBindings {\n return {\n createOptionsStore: false,\n schedule: (fn) => queueMicrotask(fn),\n batch,\n untrack: (fn) => fn(),\n createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => {\n return createAtom(() => fn(), {\n compare: options?.compare,\n })\n },\n createWritableAtom: <T>(value: T, options?: TableAtomOptions<T>) => {\n return createAtom(value, {\n compare: options?.compare,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,kBAA2C;CACzD,OAAO;EACL,oBAAoB;EACpB,WAAW,OAAO,eAAe,EAAE;EACnC;EACA,UAAU,OAAO,GAAG;EACpB,qBAAwB,IAAa,YAAkC;GACrE,OAAO,iBAAiB,GAAG,GAAG,EAC5B,2DAAS,QAAS,QACpB,CAAC;EACH;EACA,qBAAwB,OAAU,YAAkC;GAClE,OAAO,WAAW,OAAO,EACvB,2DAAS,QAAS,QACpB,CAAC;EACH;CACF;AACF"}
|
package/dist/useLegacyTable.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLegacyTable.cjs","names":["filterFns","sortFns","aggregationFns","useTable","stockFeatures"],"sources":["../src/useLegacyTable.ts"],"sourcesContent":["'use client'\n\nimport {\n aggregationFns,\n createColumnHelper,\n createExpandedRowModel,\n createFacetedMinMaxValues,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createGroupedRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n filterFns,\n sortFns,\n stockFeatures,\n} from '@tanstack/table-core'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useTable } from './useTable'\nimport type {\n AggregationFns,\n Cell,\n Column,\n ColumnDef,\n CreateRowModels_All,\n FilterFns,\n Header,\n HeaderGroup,\n Row,\n RowData,\n RowModel,\n SortFns,\n StockFeatures,\n Table,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// V8-style row model factory functions\n// These are stub functions that act as markers for useLegacyTable to know\n// which row models to enable. They don't actually do anything - the real\n// implementation is handled by useLegacyTable internally.\n// =============================================================================\n\n/**\n * @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the filtered row model.\n */\nexport function getFilteredRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the sorted row model.\n */\nexport function getSortedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the paginated row model.\n */\nexport function getPaginationRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the expanded row model.\n */\nexport function getExpandedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the grouped row model.\n */\nexport function getGroupedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted row model.\n */\nexport function getFacetedRowModel<\n TData extends RowData,\n>(): FacetedRowModelFactory<TData> {\n return (() => () => {}) as unknown as FacetedRowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted min/max values.\n */\nexport function getFacetedMinMaxValues<\n TData extends RowData,\n>(): FacetedMinMaxValuesFactory<TData> {\n return () => () => undefined\n}\n\n/**\n * @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted unique values.\n */\nexport function getFacetedUniqueValues<\n TData extends RowData,\n>(): FacetedUniqueValuesFactory<TData> {\n return () => () => new Map()\n}\n\n/**\n * @deprecated The core row model is always created automatically in v9.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It does nothing - the core row model is always available.\n */\nexport function getCoreRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n// =============================================================================\n// Type definitions\n// =============================================================================\n\n/**\n * Row model factory function type from v8 API\n */\nexport type RowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted row model factory function type from v8 API\n */\nexport type FacetedRowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted min/max values factory function type from v8 API\n */\nexport type FacetedMinMaxValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => undefined | [number, number]\n\n/**\n * Faceted unique values factory function type from v8 API\n */\nexport type FacetedUniqueValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => Map<any, number>\n\n/**\n * Legacy v8-style row model options\n */\nexport interface LegacyRowModelOptions<TData extends RowData> {\n /**\n * Returns the core row model for the table.\n * @deprecated This option is no longer needed in v9. The core row model is always created automatically.\n */\n getCoreRowModel?: RowModelFactory<TData>\n /**\n * Returns the filtered row model for the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n getFilteredRowModel?: RowModelFactory<TData>\n /**\n * Returns the sorted row model for the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n getSortedRowModel?: RowModelFactory<TData>\n /**\n * Returns the paginated row model for the table.\n * @deprecated Use `_rowModels.paginatedRowModel` with `createPaginatedRowModel()` instead.\n */\n getPaginationRowModel?: RowModelFactory<TData>\n /**\n * Returns the expanded row model for the table.\n * @deprecated Use `_rowModels.expandedRowModel` with `createExpandedRowModel()` instead.\n */\n getExpandedRowModel?: RowModelFactory<TData>\n /**\n * Returns the grouped row model for the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n getGroupedRowModel?: RowModelFactory<TData>\n /**\n * Returns the faceted row model for a column.\n * @deprecated Use `_rowModels.facetedRowModel` with `createFacetedRowModel()` instead.\n */\n getFacetedRowModel?: FacetedRowModelFactory<TData>\n /**\n * Returns the faceted min/max values for a column.\n * @deprecated Use `_rowModels.facetedMinMaxValues` with `createFacetedMinMaxValues()` instead.\n */\n getFacetedMinMaxValues?: FacetedMinMaxValuesFactory<TData>\n /**\n * Returns the faceted unique values for a column.\n * @deprecated Use `_rowModels.facetedUniqueValues` with `createFacetedUniqueValues()` instead.\n */\n getFacetedUniqueValues?: FacetedUniqueValuesFactory<TData>\n /**\n * Additional filter functions to apply to the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n filterFns?: FilterFns\n /**\n * Additional sort functions to apply to the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n sortFns?: SortFns\n /**\n * Additional aggregation functions to apply to the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n aggregationFns?: AggregationFns\n}\n\n/**\n * Legacy v8-style table options that work with useLegacyTable.\n *\n * This type omits `_features` and `_rowModels` and instead accepts the v8-style\n * `get*RowModel` function options.\n *\n * @deprecated This is a compatibility layer for migrating from v8. Use `useTable` with explicit `_features` and `_rowModels` instead.\n */\nexport type LegacyTableOptions<TData extends RowData> = Omit<\n TableOptions<StockFeatures, TData>,\n '_features' | '_rowModels'\n> &\n LegacyRowModelOptions<TData>\n\n/**\n * Legacy table instance type that includes the v8-style `getState()` method.\n *\n * @deprecated Use `useTable` with explicit state selection instead.\n */\nexport type LegacyReactTable<TData extends RowData> = ReactTable<\n StockFeatures,\n TData,\n TableState<StockFeatures>\n> & {\n /**\n * Returns the current table state.\n * @deprecated In v9, access state directly via `table.state` or use `table.store.state` for the full state.\n */\n getState: () => TableState<StockFeatures>\n /**\n * Sets the current table state.\n * @deprecated In v9, access state directly via `table.baseAtoms`\n */\n setState: (state: TableState<StockFeatures>) => void\n}\n\n// =============================================================================\n// Legacy type aliases - StockFeatures hardcoded for simpler prop typing with useLegacyTable\n// =============================================================================\n\n/** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumn<TData extends RowData, TValue = unknown> = Column<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Row<TFeatures, TData> with useTable instead. */\nexport type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>\n\n/** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyCell<TData extends RowData, TValue = unknown> = Cell<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyHeader<TData extends RowData, TValue = unknown> = Header<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */\nexport type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<\n StockFeatures,\n TData\n>\n\n/** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumnDef<\n TData extends RowData,\n TValue = unknown,\n> = ColumnDef<StockFeatures, TData, TValue>\n\n/** @deprecated Use Table<TFeatures, TData> with useTable instead. */\nexport type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>\n\n// =============================================================================\n// Legacy column helper - StockFeatures hardcoded\n// =============================================================================\n\n/**\n * @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.\n *\n * A column helper with StockFeatures pre-bound for use with useLegacyTable.\n * Only requires TData—no need to specify TFeatures.\n */\nexport function legacyCreateColumnHelper<TData extends RowData>() {\n return createColumnHelper<StockFeatures, TData>()\n}\n\n// =============================================================================\n// useLegacyTable hook\n// =============================================================================\n\n/**\n * @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.\n *\n * Use the new `useTable` hook instead with explicit `_features` and `_rowModels`:\n *\n * ```tsx\n * // New v9 API\n * const _features = tableFeatures({\n * columnFilteringFeature,\n * rowSortingFeature,\n * rowPaginationFeature,\n * })\n *\n * const table = useTable({\n * _features,\n * _rowModels: {\n * filteredRowModel: createFilteredRowModel(filterFns),\n * sortedRowModel: createSortedRowModel(sortFns),\n * paginatedRowModel: createPaginatedRowModel(),\n * },\n * columns,\n * data,\n * })\n * ```\n *\n * Key differences from v8:\n * - Features are tree-shakeable - only import what you use\n * - Row models are explicitly passed via `_rowModels`\n * - Use `table.Subscribe` for fine-grained re-renders\n * - State is accessed via `table.state` after selecting with the 2nd argument\n *\n * @param options - Legacy v8-style table options\n * @returns A table instance with the full state subscribed and a `getState()` method\n */\nexport function useLegacyTable<TData extends RowData>(\n options: LegacyTableOptions<TData>,\n): LegacyReactTable<TData> {\n const {\n // Extract legacy row model options\n getCoreRowModel: _getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n getPaginationRowModel,\n getExpandedRowModel,\n getGroupedRowModel,\n getFacetedRowModel,\n getFacetedMinMaxValues,\n getFacetedUniqueValues,\n // Rest of the options\n ...restOptions\n } = options\n\n const [_rowModels] = useState(() => {\n const rowModels: CreateRowModels_All<StockFeatures, TData> = {}\n\n // Legacy row model options are setup-only. Capture the first render's\n // marker options to match the table instance lifecycle.\n\n if (getFilteredRowModel) {\n rowModels.filteredRowModel = createFilteredRowModel({\n ...filterFns,\n ...options.filterFns,\n })\n }\n\n if (getSortedRowModel) {\n rowModels.sortedRowModel = createSortedRowModel({\n ...sortFns,\n ...options.sortFns,\n })\n }\n\n if (getPaginationRowModel) {\n rowModels.paginatedRowModel = createPaginatedRowModel()\n }\n\n if (getExpandedRowModel) {\n rowModels.expandedRowModel = createExpandedRowModel()\n }\n\n if (getGroupedRowModel) {\n rowModels.groupedRowModel = createGroupedRowModel({\n ...aggregationFns,\n ...options.aggregationFns,\n })\n }\n\n if (getFacetedRowModel) {\n rowModels.facetedRowModel = createFacetedRowModel()\n }\n\n if (getFacetedMinMaxValues) {\n rowModels.facetedMinMaxValues = createFacetedMinMaxValues()\n }\n\n if (getFacetedUniqueValues) {\n rowModels.facetedUniqueValues = createFacetedUniqueValues()\n }\n\n return rowModels\n })\n\n // Call useTable with the v9 API, subscribing to all state changes\n const table = useTable<StockFeatures, TData, TableState<StockFeatures>>(\n {\n ...restOptions,\n _features: stockFeatures,\n _rowModels,\n },\n (state) => state,\n )\n\n const getState = useCallback(() => {\n return table.state\n }, [table])\n\n const setState = useCallback(\n (state: TableState<StockFeatures>) => {\n Object.entries(state).forEach(([key, value]) => {\n // @ts-expect-error - baseAtoms is indexed by dynamic string keys\n table.baseAtoms[key].set(value)\n })\n },\n [table],\n )\n\n return useMemo(\n () => ({\n ...table,\n getState,\n setState,\n }),\n [table, getState, setState],\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAoDA,SAAgB,sBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,oBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,wBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,sBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,qBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,qBAEmB;CACjC,oBAAoB;;;;;;;;AAStB,SAAgB,yBAEuB;CACrC,mBAAmB;;;;;;;;AASrB,SAAgB,yBAEuB;CACrC,mCAAmB,IAAI,KAAK;;;;;;;;AAS9B,SAAgB,kBAEY;CAC1B,oBAAoB;;;;;;;;AAiMtB,SAAgB,2BAAkD;CAChE,qDAAiD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCnD,SAAgB,eACd,SACyB;CACzB,MAAM,EAEJ,iBAAiB,kBACjB,qBACA,mBACA,uBACA,qBACA,oBACA,oBACA,wBACA,wBAEA,GAAG,gBACD;CAEJ,MAAM,CAAC,wCAA6B;EAClC,MAAM,YAAuD,EAAE;EAK/D,IAAI,qBACF,UAAU,oEAA0C;GAClD,GAAGA;GACH,GAAG,QAAQ;GACZ,CAAC;EAGJ,IAAI,mBACF,UAAU,gEAAsC;GAC9C,GAAGC;GACH,GAAG,QAAQ;GACZ,CAAC;EAGJ,IAAI,uBACF,UAAU,uEAA6C;EAGzD,IAAI,qBACF,UAAU,qEAA2C;EAGvD,IAAI,oBACF,UAAU,kEAAwC;GAChD,GAAGC;GACH,GAAG,QAAQ;GACZ,CAAC;EAGJ,IAAI,oBACF,UAAU,mEAAyC;EAGrD,IAAI,wBACF,UAAU,2EAAiD;EAG7D,IAAI,wBACF,UAAU,2EAAiD;EAG7D,OAAO;GACP;CAGF,MAAM,QAAQC,0BACZ;EACE,GAAG;EACH,WAAWC;EACX;EACD,GACA,UAAU,MACZ;CAED,MAAM,wCAA6B;EACjC,OAAO,MAAM;IACZ,CAAC,MAAM,CAAC;CAEX,MAAM,mCACH,UAAqC;EACpC,OAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,KAAK,WAAW;GAE9C,MAAM,UAAU,KAAK,IAAI,MAAM;IAC/B;IAEJ,CAAC,MAAM,CACR;CAED,iCACS;EACL,GAAG;EACH;EACA;EACD,GACD;EAAC;EAAO;EAAU;EAAS,CAC5B"}
|
|
1
|
+
{"version":3,"file":"useLegacyTable.cjs","names":["filterFns","sortFns","aggregationFns","useTable","stockFeatures"],"sources":["../src/useLegacyTable.ts"],"sourcesContent":["'use client'\n\nimport {\n aggregationFns,\n createColumnHelper,\n createExpandedRowModel,\n createFacetedMinMaxValues,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createGroupedRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n filterFns,\n sortFns,\n stockFeatures,\n} from '@tanstack/table-core'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useTable } from './useTable'\nimport type {\n AggregationFns,\n Cell,\n Column,\n ColumnDef,\n CreateRowModels_All,\n FilterFns,\n Header,\n HeaderGroup,\n Row,\n RowData,\n RowModel,\n SortFns,\n StockFeatures,\n Table,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// V8-style row model factory functions\n// These are stub functions that act as markers for useLegacyTable to know\n// which row models to enable. They don't actually do anything - the real\n// implementation is handled by useLegacyTable internally.\n// =============================================================================\n\n/**\n * @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the filtered row model.\n */\nexport function getFilteredRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the sorted row model.\n */\nexport function getSortedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the paginated row model.\n */\nexport function getPaginationRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the expanded row model.\n */\nexport function getExpandedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the grouped row model.\n */\nexport function getGroupedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted row model.\n */\nexport function getFacetedRowModel<\n TData extends RowData,\n>(): FacetedRowModelFactory<TData> {\n return (() => () => {}) as unknown as FacetedRowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted min/max values.\n */\nexport function getFacetedMinMaxValues<\n TData extends RowData,\n>(): FacetedMinMaxValuesFactory<TData> {\n return () => () => undefined\n}\n\n/**\n * @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted unique values.\n */\nexport function getFacetedUniqueValues<\n TData extends RowData,\n>(): FacetedUniqueValuesFactory<TData> {\n return () => () => new Map()\n}\n\n/**\n * @deprecated The core row model is always created automatically in v9.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It does nothing - the core row model is always available.\n */\nexport function getCoreRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n// =============================================================================\n// Type definitions\n// =============================================================================\n\n/**\n * Row model factory function type from v8 API\n */\nexport type RowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted row model factory function type from v8 API\n */\nexport type FacetedRowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted min/max values factory function type from v8 API\n */\nexport type FacetedMinMaxValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => undefined | [number, number]\n\n/**\n * Faceted unique values factory function type from v8 API\n */\nexport type FacetedUniqueValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => Map<any, number>\n\n/**\n * Legacy v8-style row model options\n */\nexport interface LegacyRowModelOptions<TData extends RowData> {\n /**\n * Returns the core row model for the table.\n * @deprecated This option is no longer needed in v9. The core row model is always created automatically.\n */\n getCoreRowModel?: RowModelFactory<TData>\n /**\n * Returns the filtered row model for the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n getFilteredRowModel?: RowModelFactory<TData>\n /**\n * Returns the sorted row model for the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n getSortedRowModel?: RowModelFactory<TData>\n /**\n * Returns the paginated row model for the table.\n * @deprecated Use `_rowModels.paginatedRowModel` with `createPaginatedRowModel()` instead.\n */\n getPaginationRowModel?: RowModelFactory<TData>\n /**\n * Returns the expanded row model for the table.\n * @deprecated Use `_rowModels.expandedRowModel` with `createExpandedRowModel()` instead.\n */\n getExpandedRowModel?: RowModelFactory<TData>\n /**\n * Returns the grouped row model for the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n getGroupedRowModel?: RowModelFactory<TData>\n /**\n * Returns the faceted row model for a column.\n * @deprecated Use `_rowModels.facetedRowModel` with `createFacetedRowModel()` instead.\n */\n getFacetedRowModel?: FacetedRowModelFactory<TData>\n /**\n * Returns the faceted min/max values for a column.\n * @deprecated Use `_rowModels.facetedMinMaxValues` with `createFacetedMinMaxValues()` instead.\n */\n getFacetedMinMaxValues?: FacetedMinMaxValuesFactory<TData>\n /**\n * Returns the faceted unique values for a column.\n * @deprecated Use `_rowModels.facetedUniqueValues` with `createFacetedUniqueValues()` instead.\n */\n getFacetedUniqueValues?: FacetedUniqueValuesFactory<TData>\n /**\n * Additional filter functions to apply to the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n filterFns?: FilterFns\n /**\n * Additional sort functions to apply to the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n sortFns?: SortFns\n /**\n * Additional aggregation functions to apply to the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n aggregationFns?: AggregationFns\n}\n\n/**\n * Legacy v8-style table options that work with useLegacyTable.\n *\n * This type omits `_features` and `_rowModels` and instead accepts the v8-style\n * `get*RowModel` function options.\n *\n * @deprecated This is a compatibility layer for migrating from v8. Use `useTable` with explicit `_features` and `_rowModels` instead.\n */\nexport type LegacyTableOptions<TData extends RowData> = Omit<\n TableOptions<StockFeatures, TData>,\n '_features' | '_rowModels'\n> &\n LegacyRowModelOptions<TData>\n\n/**\n * Legacy table instance type that includes the v8-style `getState()` method.\n *\n * @deprecated Use `useTable` with explicit state selection instead.\n */\nexport type LegacyReactTable<TData extends RowData> = ReactTable<\n StockFeatures,\n TData,\n TableState<StockFeatures>\n> & {\n /**\n * Returns the current table state.\n * @deprecated In v9, access state directly via `table.state` or use `table.state` for the full state.\n */\n getState: () => TableState<StockFeatures>\n /**\n * Sets the current table state.\n * @deprecated In v9, access state directly via `table.baseAtoms`\n */\n setState: (state: TableState<StockFeatures>) => void\n}\n\n// =============================================================================\n// Legacy type aliases - StockFeatures hardcoded for simpler prop typing with useLegacyTable\n// =============================================================================\n\n/** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumn<TData extends RowData, TValue = unknown> = Column<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Row<TFeatures, TData> with useTable instead. */\nexport type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>\n\n/** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyCell<TData extends RowData, TValue = unknown> = Cell<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyHeader<TData extends RowData, TValue = unknown> = Header<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */\nexport type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<\n StockFeatures,\n TData\n>\n\n/** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumnDef<\n TData extends RowData,\n TValue = unknown,\n> = ColumnDef<StockFeatures, TData, TValue>\n\n/** @deprecated Use Table<TFeatures, TData> with useTable instead. */\nexport type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>\n\n// =============================================================================\n// Legacy column helper - StockFeatures hardcoded\n// =============================================================================\n\n/**\n * @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.\n *\n * A column helper with StockFeatures pre-bound for use with useLegacyTable.\n * Only requires TData—no need to specify TFeatures.\n */\nexport function legacyCreateColumnHelper<TData extends RowData>() {\n return createColumnHelper<StockFeatures, TData>()\n}\n\n// =============================================================================\n// useLegacyTable hook\n// =============================================================================\n\n/**\n * @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.\n *\n * Use the new `useTable` hook instead with explicit `_features` and `_rowModels`:\n *\n * ```tsx\n * // New v9 API\n * const _features = tableFeatures({\n * columnFilteringFeature,\n * rowSortingFeature,\n * rowPaginationFeature,\n * })\n *\n * const table = useTable({\n * _features,\n * _rowModels: {\n * filteredRowModel: createFilteredRowModel(filterFns),\n * sortedRowModel: createSortedRowModel(sortFns),\n * paginatedRowModel: createPaginatedRowModel(),\n * },\n * columns,\n * data,\n * })\n * ```\n *\n * Key differences from v8:\n * - Features are tree-shakeable - only import what you use\n * - Row models are explicitly passed via `_rowModels`\n * - Use `table.Subscribe` for fine-grained re-renders\n * - State is accessed via `table.state` after selecting with the 2nd argument\n *\n * @param options - Legacy v8-style table options\n * @returns A table instance with the full state subscribed and a `getState()` method\n */\nexport function useLegacyTable<TData extends RowData>(\n options: LegacyTableOptions<TData>,\n): LegacyReactTable<TData> {\n const {\n // Extract legacy row model options\n getCoreRowModel: _getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n getPaginationRowModel,\n getExpandedRowModel,\n getGroupedRowModel,\n getFacetedRowModel,\n getFacetedMinMaxValues,\n getFacetedUniqueValues,\n // Rest of the options\n ...restOptions\n } = options\n\n const [_rowModels] = useState(() => {\n const rowModels: CreateRowModels_All<StockFeatures, TData> = {}\n\n // Legacy row model options are setup-only. Capture the first render's\n // marker options to match the table instance lifecycle.\n\n if (getFilteredRowModel) {\n rowModels.filteredRowModel = createFilteredRowModel({\n ...filterFns,\n ...options.filterFns,\n })\n }\n\n if (getSortedRowModel) {\n rowModels.sortedRowModel = createSortedRowModel({\n ...sortFns,\n ...options.sortFns,\n })\n }\n\n if (getPaginationRowModel) {\n rowModels.paginatedRowModel = createPaginatedRowModel()\n }\n\n if (getExpandedRowModel) {\n rowModels.expandedRowModel = createExpandedRowModel()\n }\n\n if (getGroupedRowModel) {\n rowModels.groupedRowModel = createGroupedRowModel({\n ...aggregationFns,\n ...options.aggregationFns,\n })\n }\n\n if (getFacetedRowModel) {\n rowModels.facetedRowModel = createFacetedRowModel()\n }\n\n if (getFacetedMinMaxValues) {\n rowModels.facetedMinMaxValues = createFacetedMinMaxValues()\n }\n\n if (getFacetedUniqueValues) {\n rowModels.facetedUniqueValues = createFacetedUniqueValues()\n }\n\n return rowModels\n })\n\n // Call useTable with the v9 API, subscribing to all state changes\n const table = useTable<StockFeatures, TData, TableState<StockFeatures>>(\n {\n ...restOptions,\n _features: stockFeatures,\n _rowModels,\n },\n (state) => state,\n )\n\n const getState = useCallback(() => {\n return table.state\n }, [table])\n\n const setState = useCallback(\n (state: TableState<StockFeatures>) => {\n Object.entries(state).forEach(([key, value]) => {\n // @ts-expect-error - baseAtoms is indexed by dynamic string keys\n table.baseAtoms[key].set(value)\n })\n },\n [table],\n )\n\n return useMemo(\n () => ({\n ...table,\n getState,\n setState,\n }),\n [table, getState, setState],\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAoDA,SAAgB,sBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,oBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,wBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,sBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,qBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,qBAEmB;CACjC,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,yBAEuB;CACrC,mBAAmB;AACrB;;;;;;;AAQA,SAAgB,yBAEuB;CACrC,mCAAmB,IAAI,IAAI;AAC7B;;;;;;;AAQA,SAAgB,kBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAgMA,SAAgB,2BAAkD;CAChE,oDAAgD;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,eACd,SACyB;CACzB,MAAM,EAEJ,iBAAiB,kBACjB,qBACA,mBACA,uBACA,qBACA,oBACA,oBACA,wBACA,wBAEA,GAAG,gBACD;CAEJ,MAAM,CAAC,wCAA6B;EAClC,MAAM,YAAuD,CAAC;EAK9D,IAAI,qBACF,UAAU,oEAA0C;GAClD,GAAGA;GACH,GAAG,QAAQ;EACb,CAAC;EAGH,IAAI,mBACF,UAAU,gEAAsC;GAC9C,GAAGC;GACH,GAAG,QAAQ;EACb,CAAC;EAGH,IAAI,uBACF,UAAU,sEAA4C;EAGxD,IAAI,qBACF,UAAU,oEAA0C;EAGtD,IAAI,oBACF,UAAU,kEAAwC;GAChD,GAAGC;GACH,GAAG,QAAQ;EACb,CAAC;EAGH,IAAI,oBACF,UAAU,kEAAwC;EAGpD,IAAI,wBACF,UAAU,0EAAgD;EAG5D,IAAI,wBACF,UAAU,0EAAgD;EAG5D,OAAO;CACT,CAAC;CAGD,MAAM,QAAQC,0BACZ;EACE,GAAG;EACH,WAAWC;EACX;CACF,IACC,UAAU,KACb;CAEA,MAAM,wCAA6B;EACjC,OAAO,MAAM;CACf,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,mCACH,UAAqC;EACpC,OAAO,QAAQ,KAAK,EAAE,SAAS,CAAC,KAAK,WAAW;GAE9C,MAAM,UAAU,KAAK,IAAI,KAAK;EAChC,CAAC;CACH,GACA,CAAC,KAAK,CACR;CAEA,iCACS;EACL,GAAG;EACH;EACA;CACF,IACA;EAAC;EAAO;EAAU;CAAQ,CAC5B;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactTable } from "./useTable.cjs";
|
|
2
|
-
import * as _$_tanstack_table_core0 from "@tanstack/table-core";
|
|
3
2
|
import { AggregationFns, Cell, Column, ColumnDef, FilterFns, Header, HeaderGroup, Row, RowData, RowModel, SortFns, StockFeatures, Table, TableOptions, TableState } from "@tanstack/table-core";
|
|
4
3
|
|
|
5
4
|
//#region src/useLegacyTable.d.ts
|
|
@@ -164,7 +163,7 @@ type LegacyTableOptions<TData extends RowData> = Omit<TableOptions<StockFeatures
|
|
|
164
163
|
type LegacyReactTable<TData extends RowData> = ReactTable<StockFeatures, TData, TableState<StockFeatures>> & {
|
|
165
164
|
/**
|
|
166
165
|
* Returns the current table state.
|
|
167
|
-
* @deprecated In v9, access state directly via `table.state` or use `table.
|
|
166
|
+
* @deprecated In v9, access state directly via `table.state` or use `table.state` for the full state.
|
|
168
167
|
*/
|
|
169
168
|
getState: () => TableState<StockFeatures>;
|
|
170
169
|
/**
|
|
@@ -193,7 +192,7 @@ type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>;
|
|
|
193
192
|
* A column helper with StockFeatures pre-bound for use with useLegacyTable.
|
|
194
193
|
* Only requires TData—no need to specify TFeatures.
|
|
195
194
|
*/
|
|
196
|
-
declare function legacyCreateColumnHelper<TData extends RowData>():
|
|
195
|
+
declare function legacyCreateColumnHelper<TData extends RowData>(): import("@tanstack/table-core").ColumnHelper<StockFeatures, TData>;
|
|
197
196
|
/**
|
|
198
197
|
* @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.
|
|
199
198
|
*
|
package/dist/useLegacyTable.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactTable } from "./useTable.js";
|
|
2
|
-
import * as _$_tanstack_table_core0 from "@tanstack/table-core";
|
|
3
2
|
import { AggregationFns, Cell, Column, ColumnDef, FilterFns, Header, HeaderGroup, Row, RowData, RowModel, SortFns, StockFeatures, Table, TableOptions, TableState } from "@tanstack/table-core";
|
|
4
3
|
|
|
5
4
|
//#region src/useLegacyTable.d.ts
|
|
@@ -164,7 +163,7 @@ type LegacyTableOptions<TData extends RowData> = Omit<TableOptions<StockFeatures
|
|
|
164
163
|
type LegacyReactTable<TData extends RowData> = ReactTable<StockFeatures, TData, TableState<StockFeatures>> & {
|
|
165
164
|
/**
|
|
166
165
|
* Returns the current table state.
|
|
167
|
-
* @deprecated In v9, access state directly via `table.state` or use `table.
|
|
166
|
+
* @deprecated In v9, access state directly via `table.state` or use `table.state` for the full state.
|
|
168
167
|
*/
|
|
169
168
|
getState: () => TableState<StockFeatures>;
|
|
170
169
|
/**
|
|
@@ -193,7 +192,7 @@ type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>;
|
|
|
193
192
|
* A column helper with StockFeatures pre-bound for use with useLegacyTable.
|
|
194
193
|
* Only requires TData—no need to specify TFeatures.
|
|
195
194
|
*/
|
|
196
|
-
declare function legacyCreateColumnHelper<TData extends RowData>():
|
|
195
|
+
declare function legacyCreateColumnHelper<TData extends RowData>(): import("@tanstack/table-core").ColumnHelper<StockFeatures, TData>;
|
|
197
196
|
/**
|
|
198
197
|
* @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.
|
|
199
198
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLegacyTable.js","names":[],"sources":["../src/useLegacyTable.ts"],"sourcesContent":["'use client'\n\nimport {\n aggregationFns,\n createColumnHelper,\n createExpandedRowModel,\n createFacetedMinMaxValues,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createGroupedRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n filterFns,\n sortFns,\n stockFeatures,\n} from '@tanstack/table-core'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useTable } from './useTable'\nimport type {\n AggregationFns,\n Cell,\n Column,\n ColumnDef,\n CreateRowModels_All,\n FilterFns,\n Header,\n HeaderGroup,\n Row,\n RowData,\n RowModel,\n SortFns,\n StockFeatures,\n Table,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// V8-style row model factory functions\n// These are stub functions that act as markers for useLegacyTable to know\n// which row models to enable. They don't actually do anything - the real\n// implementation is handled by useLegacyTable internally.\n// =============================================================================\n\n/**\n * @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the filtered row model.\n */\nexport function getFilteredRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the sorted row model.\n */\nexport function getSortedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the paginated row model.\n */\nexport function getPaginationRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the expanded row model.\n */\nexport function getExpandedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the grouped row model.\n */\nexport function getGroupedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted row model.\n */\nexport function getFacetedRowModel<\n TData extends RowData,\n>(): FacetedRowModelFactory<TData> {\n return (() => () => {}) as unknown as FacetedRowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted min/max values.\n */\nexport function getFacetedMinMaxValues<\n TData extends RowData,\n>(): FacetedMinMaxValuesFactory<TData> {\n return () => () => undefined\n}\n\n/**\n * @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted unique values.\n */\nexport function getFacetedUniqueValues<\n TData extends RowData,\n>(): FacetedUniqueValuesFactory<TData> {\n return () => () => new Map()\n}\n\n/**\n * @deprecated The core row model is always created automatically in v9.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It does nothing - the core row model is always available.\n */\nexport function getCoreRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n// =============================================================================\n// Type definitions\n// =============================================================================\n\n/**\n * Row model factory function type from v8 API\n */\nexport type RowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted row model factory function type from v8 API\n */\nexport type FacetedRowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted min/max values factory function type from v8 API\n */\nexport type FacetedMinMaxValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => undefined | [number, number]\n\n/**\n * Faceted unique values factory function type from v8 API\n */\nexport type FacetedUniqueValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => Map<any, number>\n\n/**\n * Legacy v8-style row model options\n */\nexport interface LegacyRowModelOptions<TData extends RowData> {\n /**\n * Returns the core row model for the table.\n * @deprecated This option is no longer needed in v9. The core row model is always created automatically.\n */\n getCoreRowModel?: RowModelFactory<TData>\n /**\n * Returns the filtered row model for the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n getFilteredRowModel?: RowModelFactory<TData>\n /**\n * Returns the sorted row model for the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n getSortedRowModel?: RowModelFactory<TData>\n /**\n * Returns the paginated row model for the table.\n * @deprecated Use `_rowModels.paginatedRowModel` with `createPaginatedRowModel()` instead.\n */\n getPaginationRowModel?: RowModelFactory<TData>\n /**\n * Returns the expanded row model for the table.\n * @deprecated Use `_rowModels.expandedRowModel` with `createExpandedRowModel()` instead.\n */\n getExpandedRowModel?: RowModelFactory<TData>\n /**\n * Returns the grouped row model for the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n getGroupedRowModel?: RowModelFactory<TData>\n /**\n * Returns the faceted row model for a column.\n * @deprecated Use `_rowModels.facetedRowModel` with `createFacetedRowModel()` instead.\n */\n getFacetedRowModel?: FacetedRowModelFactory<TData>\n /**\n * Returns the faceted min/max values for a column.\n * @deprecated Use `_rowModels.facetedMinMaxValues` with `createFacetedMinMaxValues()` instead.\n */\n getFacetedMinMaxValues?: FacetedMinMaxValuesFactory<TData>\n /**\n * Returns the faceted unique values for a column.\n * @deprecated Use `_rowModels.facetedUniqueValues` with `createFacetedUniqueValues()` instead.\n */\n getFacetedUniqueValues?: FacetedUniqueValuesFactory<TData>\n /**\n * Additional filter functions to apply to the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n filterFns?: FilterFns\n /**\n * Additional sort functions to apply to the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n sortFns?: SortFns\n /**\n * Additional aggregation functions to apply to the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n aggregationFns?: AggregationFns\n}\n\n/**\n * Legacy v8-style table options that work with useLegacyTable.\n *\n * This type omits `_features` and `_rowModels` and instead accepts the v8-style\n * `get*RowModel` function options.\n *\n * @deprecated This is a compatibility layer for migrating from v8. Use `useTable` with explicit `_features` and `_rowModels` instead.\n */\nexport type LegacyTableOptions<TData extends RowData> = Omit<\n TableOptions<StockFeatures, TData>,\n '_features' | '_rowModels'\n> &\n LegacyRowModelOptions<TData>\n\n/**\n * Legacy table instance type that includes the v8-style `getState()` method.\n *\n * @deprecated Use `useTable` with explicit state selection instead.\n */\nexport type LegacyReactTable<TData extends RowData> = ReactTable<\n StockFeatures,\n TData,\n TableState<StockFeatures>\n> & {\n /**\n * Returns the current table state.\n * @deprecated In v9, access state directly via `table.state` or use `table.store.state` for the full state.\n */\n getState: () => TableState<StockFeatures>\n /**\n * Sets the current table state.\n * @deprecated In v9, access state directly via `table.baseAtoms`\n */\n setState: (state: TableState<StockFeatures>) => void\n}\n\n// =============================================================================\n// Legacy type aliases - StockFeatures hardcoded for simpler prop typing with useLegacyTable\n// =============================================================================\n\n/** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumn<TData extends RowData, TValue = unknown> = Column<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Row<TFeatures, TData> with useTable instead. */\nexport type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>\n\n/** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyCell<TData extends RowData, TValue = unknown> = Cell<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyHeader<TData extends RowData, TValue = unknown> = Header<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */\nexport type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<\n StockFeatures,\n TData\n>\n\n/** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumnDef<\n TData extends RowData,\n TValue = unknown,\n> = ColumnDef<StockFeatures, TData, TValue>\n\n/** @deprecated Use Table<TFeatures, TData> with useTable instead. */\nexport type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>\n\n// =============================================================================\n// Legacy column helper - StockFeatures hardcoded\n// =============================================================================\n\n/**\n * @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.\n *\n * A column helper with StockFeatures pre-bound for use with useLegacyTable.\n * Only requires TData—no need to specify TFeatures.\n */\nexport function legacyCreateColumnHelper<TData extends RowData>() {\n return createColumnHelper<StockFeatures, TData>()\n}\n\n// =============================================================================\n// useLegacyTable hook\n// =============================================================================\n\n/**\n * @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.\n *\n * Use the new `useTable` hook instead with explicit `_features` and `_rowModels`:\n *\n * ```tsx\n * // New v9 API\n * const _features = tableFeatures({\n * columnFilteringFeature,\n * rowSortingFeature,\n * rowPaginationFeature,\n * })\n *\n * const table = useTable({\n * _features,\n * _rowModels: {\n * filteredRowModel: createFilteredRowModel(filterFns),\n * sortedRowModel: createSortedRowModel(sortFns),\n * paginatedRowModel: createPaginatedRowModel(),\n * },\n * columns,\n * data,\n * })\n * ```\n *\n * Key differences from v8:\n * - Features are tree-shakeable - only import what you use\n * - Row models are explicitly passed via `_rowModels`\n * - Use `table.Subscribe` for fine-grained re-renders\n * - State is accessed via `table.state` after selecting with the 2nd argument\n *\n * @param options - Legacy v8-style table options\n * @returns A table instance with the full state subscribed and a `getState()` method\n */\nexport function useLegacyTable<TData extends RowData>(\n options: LegacyTableOptions<TData>,\n): LegacyReactTable<TData> {\n const {\n // Extract legacy row model options\n getCoreRowModel: _getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n getPaginationRowModel,\n getExpandedRowModel,\n getGroupedRowModel,\n getFacetedRowModel,\n getFacetedMinMaxValues,\n getFacetedUniqueValues,\n // Rest of the options\n ...restOptions\n } = options\n\n const [_rowModels] = useState(() => {\n const rowModels: CreateRowModels_All<StockFeatures, TData> = {}\n\n // Legacy row model options are setup-only. Capture the first render's\n // marker options to match the table instance lifecycle.\n\n if (getFilteredRowModel) {\n rowModels.filteredRowModel = createFilteredRowModel({\n ...filterFns,\n ...options.filterFns,\n })\n }\n\n if (getSortedRowModel) {\n rowModels.sortedRowModel = createSortedRowModel({\n ...sortFns,\n ...options.sortFns,\n })\n }\n\n if (getPaginationRowModel) {\n rowModels.paginatedRowModel = createPaginatedRowModel()\n }\n\n if (getExpandedRowModel) {\n rowModels.expandedRowModel = createExpandedRowModel()\n }\n\n if (getGroupedRowModel) {\n rowModels.groupedRowModel = createGroupedRowModel({\n ...aggregationFns,\n ...options.aggregationFns,\n })\n }\n\n if (getFacetedRowModel) {\n rowModels.facetedRowModel = createFacetedRowModel()\n }\n\n if (getFacetedMinMaxValues) {\n rowModels.facetedMinMaxValues = createFacetedMinMaxValues()\n }\n\n if (getFacetedUniqueValues) {\n rowModels.facetedUniqueValues = createFacetedUniqueValues()\n }\n\n return rowModels\n })\n\n // Call useTable with the v9 API, subscribing to all state changes\n const table = useTable<StockFeatures, TData, TableState<StockFeatures>>(\n {\n ...restOptions,\n _features: stockFeatures,\n _rowModels,\n },\n (state) => state,\n )\n\n const getState = useCallback(() => {\n return table.state\n }, [table])\n\n const setState = useCallback(\n (state: TableState<StockFeatures>) => {\n Object.entries(state).forEach(([key, value]) => {\n // @ts-expect-error - baseAtoms is indexed by dynamic string keys\n table.baseAtoms[key].set(value)\n })\n },\n [table],\n )\n\n return useMemo(\n () => ({\n ...table,\n getState,\n setState,\n }),\n [table, getState, setState],\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAoDA,SAAgB,sBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,oBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,wBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,sBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,qBAEY;CAC1B,oBAAoB;;;;;;;;AAStB,SAAgB,qBAEmB;CACjC,oBAAoB;;;;;;;;AAStB,SAAgB,yBAEuB;CACrC,mBAAmB;;;;;;;;AASrB,SAAgB,yBAEuB;CACrC,mCAAmB,IAAI,KAAK;;;;;;;;AAS9B,SAAgB,kBAEY;CAC1B,oBAAoB;;;;;;;;AAiMtB,SAAgB,2BAAkD;CAChE,OAAO,oBAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCnD,SAAgB,eACd,SACyB;CACzB,MAAM,EAEJ,iBAAiB,kBACjB,qBACA,mBACA,uBACA,qBACA,oBACA,oBACA,wBACA,wBAEA,GAAG,gBACD;CAEJ,MAAM,CAAC,cAAc,eAAe;EAClC,MAAM,YAAuD,EAAE;EAK/D,IAAI,qBACF,UAAU,mBAAmB,uBAAuB;GAClD,GAAG;GACH,GAAG,QAAQ;GACZ,CAAC;EAGJ,IAAI,mBACF,UAAU,iBAAiB,qBAAqB;GAC9C,GAAG;GACH,GAAG,QAAQ;GACZ,CAAC;EAGJ,IAAI,uBACF,UAAU,oBAAoB,yBAAyB;EAGzD,IAAI,qBACF,UAAU,mBAAmB,wBAAwB;EAGvD,IAAI,oBACF,UAAU,kBAAkB,sBAAsB;GAChD,GAAG;GACH,GAAG,QAAQ;GACZ,CAAC;EAGJ,IAAI,oBACF,UAAU,kBAAkB,uBAAuB;EAGrD,IAAI,wBACF,UAAU,sBAAsB,2BAA2B;EAG7D,IAAI,wBACF,UAAU,sBAAsB,2BAA2B;EAG7D,OAAO;GACP;CAGF,MAAM,QAAQ,SACZ;EACE,GAAG;EACH,WAAW;EACX;EACD,GACA,UAAU,MACZ;CAED,MAAM,WAAW,kBAAkB;EACjC,OAAO,MAAM;IACZ,CAAC,MAAM,CAAC;CAEX,MAAM,WAAW,aACd,UAAqC;EACpC,OAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,KAAK,WAAW;GAE9C,MAAM,UAAU,KAAK,IAAI,MAAM;IAC/B;IAEJ,CAAC,MAAM,CACR;CAED,OAAO,eACE;EACL,GAAG;EACH;EACA;EACD,GACD;EAAC;EAAO;EAAU;EAAS,CAC5B"}
|
|
1
|
+
{"version":3,"file":"useLegacyTable.js","names":[],"sources":["../src/useLegacyTable.ts"],"sourcesContent":["'use client'\n\nimport {\n aggregationFns,\n createColumnHelper,\n createExpandedRowModel,\n createFacetedMinMaxValues,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createGroupedRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n filterFns,\n sortFns,\n stockFeatures,\n} from '@tanstack/table-core'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useTable } from './useTable'\nimport type {\n AggregationFns,\n Cell,\n Column,\n ColumnDef,\n CreateRowModels_All,\n FilterFns,\n Header,\n HeaderGroup,\n Row,\n RowData,\n RowModel,\n SortFns,\n StockFeatures,\n Table,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// V8-style row model factory functions\n// These are stub functions that act as markers for useLegacyTable to know\n// which row models to enable. They don't actually do anything - the real\n// implementation is handled by useLegacyTable internally.\n// =============================================================================\n\n/**\n * @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the filtered row model.\n */\nexport function getFilteredRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the sorted row model.\n */\nexport function getSortedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the paginated row model.\n */\nexport function getPaginationRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the expanded row model.\n */\nexport function getExpandedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the grouped row model.\n */\nexport function getGroupedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted row model.\n */\nexport function getFacetedRowModel<\n TData extends RowData,\n>(): FacetedRowModelFactory<TData> {\n return (() => () => {}) as unknown as FacetedRowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted min/max values.\n */\nexport function getFacetedMinMaxValues<\n TData extends RowData,\n>(): FacetedMinMaxValuesFactory<TData> {\n return () => () => undefined\n}\n\n/**\n * @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted unique values.\n */\nexport function getFacetedUniqueValues<\n TData extends RowData,\n>(): FacetedUniqueValuesFactory<TData> {\n return () => () => new Map()\n}\n\n/**\n * @deprecated The core row model is always created automatically in v9.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It does nothing - the core row model is always available.\n */\nexport function getCoreRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n// =============================================================================\n// Type definitions\n// =============================================================================\n\n/**\n * Row model factory function type from v8 API\n */\nexport type RowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted row model factory function type from v8 API\n */\nexport type FacetedRowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted min/max values factory function type from v8 API\n */\nexport type FacetedMinMaxValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => undefined | [number, number]\n\n/**\n * Faceted unique values factory function type from v8 API\n */\nexport type FacetedUniqueValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => Map<any, number>\n\n/**\n * Legacy v8-style row model options\n */\nexport interface LegacyRowModelOptions<TData extends RowData> {\n /**\n * Returns the core row model for the table.\n * @deprecated This option is no longer needed in v9. The core row model is always created automatically.\n */\n getCoreRowModel?: RowModelFactory<TData>\n /**\n * Returns the filtered row model for the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n getFilteredRowModel?: RowModelFactory<TData>\n /**\n * Returns the sorted row model for the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n getSortedRowModel?: RowModelFactory<TData>\n /**\n * Returns the paginated row model for the table.\n * @deprecated Use `_rowModels.paginatedRowModel` with `createPaginatedRowModel()` instead.\n */\n getPaginationRowModel?: RowModelFactory<TData>\n /**\n * Returns the expanded row model for the table.\n * @deprecated Use `_rowModels.expandedRowModel` with `createExpandedRowModel()` instead.\n */\n getExpandedRowModel?: RowModelFactory<TData>\n /**\n * Returns the grouped row model for the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n getGroupedRowModel?: RowModelFactory<TData>\n /**\n * Returns the faceted row model for a column.\n * @deprecated Use `_rowModels.facetedRowModel` with `createFacetedRowModel()` instead.\n */\n getFacetedRowModel?: FacetedRowModelFactory<TData>\n /**\n * Returns the faceted min/max values for a column.\n * @deprecated Use `_rowModels.facetedMinMaxValues` with `createFacetedMinMaxValues()` instead.\n */\n getFacetedMinMaxValues?: FacetedMinMaxValuesFactory<TData>\n /**\n * Returns the faceted unique values for a column.\n * @deprecated Use `_rowModels.facetedUniqueValues` with `createFacetedUniqueValues()` instead.\n */\n getFacetedUniqueValues?: FacetedUniqueValuesFactory<TData>\n /**\n * Additional filter functions to apply to the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n filterFns?: FilterFns\n /**\n * Additional sort functions to apply to the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n sortFns?: SortFns\n /**\n * Additional aggregation functions to apply to the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n aggregationFns?: AggregationFns\n}\n\n/**\n * Legacy v8-style table options that work with useLegacyTable.\n *\n * This type omits `_features` and `_rowModels` and instead accepts the v8-style\n * `get*RowModel` function options.\n *\n * @deprecated This is a compatibility layer for migrating from v8. Use `useTable` with explicit `_features` and `_rowModels` instead.\n */\nexport type LegacyTableOptions<TData extends RowData> = Omit<\n TableOptions<StockFeatures, TData>,\n '_features' | '_rowModels'\n> &\n LegacyRowModelOptions<TData>\n\n/**\n * Legacy table instance type that includes the v8-style `getState()` method.\n *\n * @deprecated Use `useTable` with explicit state selection instead.\n */\nexport type LegacyReactTable<TData extends RowData> = ReactTable<\n StockFeatures,\n TData,\n TableState<StockFeatures>\n> & {\n /**\n * Returns the current table state.\n * @deprecated In v9, access state directly via `table.state` or use `table.state` for the full state.\n */\n getState: () => TableState<StockFeatures>\n /**\n * Sets the current table state.\n * @deprecated In v9, access state directly via `table.baseAtoms`\n */\n setState: (state: TableState<StockFeatures>) => void\n}\n\n// =============================================================================\n// Legacy type aliases - StockFeatures hardcoded for simpler prop typing with useLegacyTable\n// =============================================================================\n\n/** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumn<TData extends RowData, TValue = unknown> = Column<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Row<TFeatures, TData> with useTable instead. */\nexport type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>\n\n/** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyCell<TData extends RowData, TValue = unknown> = Cell<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyHeader<TData extends RowData, TValue = unknown> = Header<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */\nexport type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<\n StockFeatures,\n TData\n>\n\n/** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumnDef<\n TData extends RowData,\n TValue = unknown,\n> = ColumnDef<StockFeatures, TData, TValue>\n\n/** @deprecated Use Table<TFeatures, TData> with useTable instead. */\nexport type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>\n\n// =============================================================================\n// Legacy column helper - StockFeatures hardcoded\n// =============================================================================\n\n/**\n * @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.\n *\n * A column helper with StockFeatures pre-bound for use with useLegacyTable.\n * Only requires TData—no need to specify TFeatures.\n */\nexport function legacyCreateColumnHelper<TData extends RowData>() {\n return createColumnHelper<StockFeatures, TData>()\n}\n\n// =============================================================================\n// useLegacyTable hook\n// =============================================================================\n\n/**\n * @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.\n *\n * Use the new `useTable` hook instead with explicit `_features` and `_rowModels`:\n *\n * ```tsx\n * // New v9 API\n * const _features = tableFeatures({\n * columnFilteringFeature,\n * rowSortingFeature,\n * rowPaginationFeature,\n * })\n *\n * const table = useTable({\n * _features,\n * _rowModels: {\n * filteredRowModel: createFilteredRowModel(filterFns),\n * sortedRowModel: createSortedRowModel(sortFns),\n * paginatedRowModel: createPaginatedRowModel(),\n * },\n * columns,\n * data,\n * })\n * ```\n *\n * Key differences from v8:\n * - Features are tree-shakeable - only import what you use\n * - Row models are explicitly passed via `_rowModels`\n * - Use `table.Subscribe` for fine-grained re-renders\n * - State is accessed via `table.state` after selecting with the 2nd argument\n *\n * @param options - Legacy v8-style table options\n * @returns A table instance with the full state subscribed and a `getState()` method\n */\nexport function useLegacyTable<TData extends RowData>(\n options: LegacyTableOptions<TData>,\n): LegacyReactTable<TData> {\n const {\n // Extract legacy row model options\n getCoreRowModel: _getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n getPaginationRowModel,\n getExpandedRowModel,\n getGroupedRowModel,\n getFacetedRowModel,\n getFacetedMinMaxValues,\n getFacetedUniqueValues,\n // Rest of the options\n ...restOptions\n } = options\n\n const [_rowModels] = useState(() => {\n const rowModels: CreateRowModels_All<StockFeatures, TData> = {}\n\n // Legacy row model options are setup-only. Capture the first render's\n // marker options to match the table instance lifecycle.\n\n if (getFilteredRowModel) {\n rowModels.filteredRowModel = createFilteredRowModel({\n ...filterFns,\n ...options.filterFns,\n })\n }\n\n if (getSortedRowModel) {\n rowModels.sortedRowModel = createSortedRowModel({\n ...sortFns,\n ...options.sortFns,\n })\n }\n\n if (getPaginationRowModel) {\n rowModels.paginatedRowModel = createPaginatedRowModel()\n }\n\n if (getExpandedRowModel) {\n rowModels.expandedRowModel = createExpandedRowModel()\n }\n\n if (getGroupedRowModel) {\n rowModels.groupedRowModel = createGroupedRowModel({\n ...aggregationFns,\n ...options.aggregationFns,\n })\n }\n\n if (getFacetedRowModel) {\n rowModels.facetedRowModel = createFacetedRowModel()\n }\n\n if (getFacetedMinMaxValues) {\n rowModels.facetedMinMaxValues = createFacetedMinMaxValues()\n }\n\n if (getFacetedUniqueValues) {\n rowModels.facetedUniqueValues = createFacetedUniqueValues()\n }\n\n return rowModels\n })\n\n // Call useTable with the v9 API, subscribing to all state changes\n const table = useTable<StockFeatures, TData, TableState<StockFeatures>>(\n {\n ...restOptions,\n _features: stockFeatures,\n _rowModels,\n },\n (state) => state,\n )\n\n const getState = useCallback(() => {\n return table.state\n }, [table])\n\n const setState = useCallback(\n (state: TableState<StockFeatures>) => {\n Object.entries(state).forEach(([key, value]) => {\n // @ts-expect-error - baseAtoms is indexed by dynamic string keys\n table.baseAtoms[key].set(value)\n })\n },\n [table],\n )\n\n return useMemo(\n () => ({\n ...table,\n getState,\n setState,\n }),\n [table, getState, setState],\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAoDA,SAAgB,sBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,oBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,wBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,sBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,qBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,qBAEmB;CACjC,oBAAoB,CAAC;AACvB;;;;;;;AAQA,SAAgB,yBAEuB;CACrC,mBAAmB;AACrB;;;;;;;AAQA,SAAgB,yBAEuB;CACrC,mCAAmB,IAAI,IAAI;AAC7B;;;;;;;AAQA,SAAgB,kBAEY;CAC1B,oBAAoB,CAAC;AACvB;;;;;;;AAgMA,SAAgB,2BAAkD;CAChE,OAAO,mBAAyC;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,eACd,SACyB;CACzB,MAAM,EAEJ,iBAAiB,kBACjB,qBACA,mBACA,uBACA,qBACA,oBACA,oBACA,wBACA,wBAEA,GAAG,gBACD;CAEJ,MAAM,CAAC,cAAc,eAAe;EAClC,MAAM,YAAuD,CAAC;EAK9D,IAAI,qBACF,UAAU,mBAAmB,uBAAuB;GAClD,GAAG;GACH,GAAG,QAAQ;EACb,CAAC;EAGH,IAAI,mBACF,UAAU,iBAAiB,qBAAqB;GAC9C,GAAG;GACH,GAAG,QAAQ;EACb,CAAC;EAGH,IAAI,uBACF,UAAU,oBAAoB,wBAAwB;EAGxD,IAAI,qBACF,UAAU,mBAAmB,uBAAuB;EAGtD,IAAI,oBACF,UAAU,kBAAkB,sBAAsB;GAChD,GAAG;GACH,GAAG,QAAQ;EACb,CAAC;EAGH,IAAI,oBACF,UAAU,kBAAkB,sBAAsB;EAGpD,IAAI,wBACF,UAAU,sBAAsB,0BAA0B;EAG5D,IAAI,wBACF,UAAU,sBAAsB,0BAA0B;EAG5D,OAAO;CACT,CAAC;CAGD,MAAM,QAAQ,SACZ;EACE,GAAG;EACH,WAAW;EACX;CACF,IACC,UAAU,KACb;CAEA,MAAM,WAAW,kBAAkB;EACjC,OAAO,MAAM;CACf,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,WAAW,aACd,UAAqC;EACpC,OAAO,QAAQ,KAAK,EAAE,SAAS,CAAC,KAAK,WAAW;GAE9C,MAAM,UAAU,KAAK,IAAI,KAAK;EAChC,CAAC;CACH,GACA,CAAC,KAAK,CACR;CAEA,OAAO,eACE;EACL,GAAG;EACH;EACA;CACF,IACA;EAAC;EAAO;EAAU;CAAQ,CAC5B;AACF"}
|
package/dist/useTable.cjs
CHANGED
package/dist/useTable.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTable.cjs","names":["reactReactivity","Subscribe","FlexRender","shallow"],"sources":["../src/useTable.ts"],"sourcesContent":["'use client'\n\nimport { useMemo, useState } from 'react'\nimport { constructTable } from '@tanstack/table-core'\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport { reactReactivity } from './reactivity'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribePropsWithStore, SubscribeSource } from './Subscribe'\nimport type {\n CellData,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type ReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n> = Table<TFeatures, TData> & {\n /**\n * A React HOC (Higher Order 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 * Pass `source` to subscribe to a single atom or store (e.g. `table.atoms.rowSelection`\n * or `table.optionsStore`) instead of the full `table.store`.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <tr key={row.id}>...</tr>\n * )}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection} selector={(s) => s?.[row.id]}>\n * {() => <tr key={row.id}>...</tr>}\n * </table.Subscribe>\n */\n /**\n * Overloads (not a single union) so `selector` callbacks get correct contextual\n * types in JSX; a union of two `selector` signatures degrades to implicit `any`.\n *\n * Source **without** `selector` is a separate overload so children receive `TSourceValue`\n * (identity projection). If `selector` were optional on one overload, `TSubSelected`\n * would default to `unknown` instead of inferring from the source.\n *\n * The **source** overloads are listed first so `TSourceValue` is inferred from `source`.\n */\n Subscribe: {\n <TSourceValue>(props: {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n }): ReturnType<FunctionComponent>\n <TSourceValue, TSubSelected>(props: {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSubSelected\n children: ((state: TSubSelected) => ReactNode) | ReactNode\n }): ReturnType<FunctionComponent>\n <TSubSelected>(\n props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>,\n ): ReturnType<FunctionComponent>\n }\n /**\n * A React component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n *\n * @example\n * ```tsx\n * <table.FlexRender cell={cell} />\n * <table.FlexRender header={header} />\n * <table.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 */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ReactNode\n /**\n * The selected state of the table. This state may not match the structure of
|
|
1
|
+
{"version":3,"file":"useTable.cjs","names":["reactReactivity","Subscribe","FlexRender","shallow"],"sources":["../src/useTable.ts"],"sourcesContent":["'use client'\n\nimport { useMemo, useState } from 'react'\nimport { constructTable } from '@tanstack/table-core'\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport { reactReactivity } from './reactivity'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribePropsWithStore, SubscribeSource } from './Subscribe'\nimport type {\n CellData,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type ReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n> = Omit<Table<TFeatures, TData>, 'store'> & {\n /**\n * @deprecated Prefer `table.state` for render reads,\n * `table.atoms.<slice>.get()` for slice snapshots, or\n * `table.Subscribe` / `useSelector(table.store, selector)` for explicit\n * subscriptions. `table.store.state` is a current-value snapshot and is easy\n * to misuse in render code.\n */\n readonly store: Table<TFeatures, TData>['store']\n /**\n * A React HOC (Higher Order 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 * Pass `source` to subscribe to a single atom or store (e.g. `table.atoms.rowSelection`\n * or `table.optionsStore`) instead of the full `table.store`.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <tr key={row.id}>...</tr>\n * )}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection} selector={(s) => s?.[row.id]}>\n * {() => <tr key={row.id}>...</tr>}\n * </table.Subscribe>\n */\n /**\n * Overloads (not a single union) so `selector` callbacks get correct contextual\n * types in JSX; a union of two `selector` signatures degrades to implicit `any`.\n *\n * Source **without** `selector` is a separate overload so children receive `TSourceValue`\n * (identity projection). If `selector` were optional on one overload, `TSubSelected`\n * would default to `unknown` instead of inferring from the source.\n *\n * The **source** overloads are listed first so `TSourceValue` is inferred from `source`.\n */\n Subscribe: {\n <TSourceValue>(props: {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n }): ReturnType<FunctionComponent>\n <TSourceValue, TSubSelected>(props: {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSubSelected\n children: ((state: TSubSelected) => ReactNode) | ReactNode\n }): ReturnType<FunctionComponent>\n <TSubSelected>(\n props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>,\n ): ReturnType<FunctionComponent>\n }\n /**\n * A React component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n *\n * @example\n * ```tsx\n * <table.FlexRender cell={cell} />\n * <table.FlexRender header={header} />\n * <table.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 */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ReactNode\n /**\n * The selected state of the table. This state may not match the structure of\n * the full table state because it is selected by the selector function that\n * you pass as the 2nd argument to `useTable`.\n *\n * @example\n * const table = useTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state\n *\n * console.log(table.state.globalFilter)\n */\n readonly state: Readonly<TSelected>\n}\n\n/**\n * Creates a React table instance backed by TanStack Store atoms.\n *\n * The optional selector projects from `table.store`; the selected value is\n * exposed on `table.state` and compared shallowly for React re-renders. Omit\n * the selector to subscribe to every registered table state slice, or pass a\n * narrower selector and use `table.Subscribe` lower in the tree for targeted\n * subscriptions.\n *\n * @example\n * ```tsx\n * const table = useTable(\n * {\n * _features,\n * _rowModels: {},\n * columns,\n * data,\n * },\n * (state) => ({ pagination: state.pagination }),\n * )\n *\n * table.state.pagination\n * ```\n */\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n>(\n tableOptions: TableOptions<TFeatures, TData>,\n selector?: (state: TableState<TFeatures>) => TSelected,\n): ReactTable<TFeatures, TData, TSelected> {\n const [table] = useState(() => {\n const tableInstance = constructTable({\n ...tableOptions,\n _features: {\n coreReativityFeature: reactReactivity(),\n ...tableOptions._features,\n },\n }) as unknown as ReactTable<TFeatures, TData, TSelected>\n\n tableInstance.Subscribe = ((props: any) => {\n const source = props.source ?? tableInstance.store\n\n return Subscribe({\n ...props,\n source,\n })\n }) as ReactTable<TFeatures, TData, TSelected>['Subscribe']\n\n tableInstance.FlexRender = FlexRender\n\n return tableInstance\n })\n\n // sync options on every render\n table.setOptions((prev) => ({\n ...prev,\n ...tableOptions,\n }))\n\n const state = useSelector(table.store, selector, { compare: shallow })\n\n // we know this is not the most efficient way to return the table,\n // but it is required for the react compiler to work\n return useMemo(\n () => ({\n ...table,\n options: tableOptions,\n state,\n }),\n [table, tableOptions, state],\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6IA,SAAgB,SAKd,cACA,UACyC;CACzC,MAAM,CAAC,mCAAwB;EAC7B,MAAM,yDAA+B;GACnC,GAAG;GACH,WAAW;IACT,sBAAsBA,mCAAgB;IACtC,GAAG,aAAa;GAClB;EACF,CAAC;EAED,cAAc,cAAc,UAAe;GACzC,MAAM,SAAS,MAAM,UAAU,cAAc;GAE7C,OAAOC,4BAAU;IACf,GAAG;IACH;GACF,CAAC;EACH;EAEA,cAAc,aAAaC;EAE3B,OAAO;CACT,CAAC;CAGD,MAAM,YAAY,UAAU;EAC1B,GAAG;EACH,GAAG;CACL,EAAE;CAEF,MAAM,+CAAoB,MAAM,OAAO,UAAU,EAAE,SAASC,8BAAQ,CAAC;CAIrE,iCACS;EACL,GAAG;EACH,SAAS;EACT;CACF,IACA;EAAC;EAAO;EAAc;CAAK,CAC7B;AACF"}
|
package/dist/useTable.d.cts
CHANGED
|
@@ -4,7 +4,15 @@ import { FunctionComponent, ReactNode } from "react";
|
|
|
4
4
|
import { CellData, RowData, Table, TableFeatures, TableOptions, TableState } from "@tanstack/table-core";
|
|
5
5
|
|
|
6
6
|
//#region src/useTable.d.ts
|
|
7
|
-
type ReactTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = TableState<TFeatures>> = Table<TFeatures, TData> & {
|
|
7
|
+
type ReactTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = TableState<TFeatures>> = Omit<Table<TFeatures, TData>, 'store'> & {
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Prefer `table.state` for render reads,
|
|
10
|
+
* `table.atoms.<slice>.get()` for slice snapshots, or
|
|
11
|
+
* `table.Subscribe` / `useSelector(table.store, selector)` for explicit
|
|
12
|
+
* subscriptions. `table.store.state` is a current-value snapshot and is easy
|
|
13
|
+
* to misuse in render code.
|
|
14
|
+
*/
|
|
15
|
+
readonly store: Table<TFeatures, TData>['store'];
|
|
8
16
|
/**
|
|
9
17
|
* A React HOC (Higher Order Component) that allows you to subscribe to the table state.
|
|
10
18
|
*
|
|
@@ -73,7 +81,9 @@ type ReactTable<TFeatures extends TableFeatures, TData extends RowData, TSelecte
|
|
|
73
81
|
*/
|
|
74
82
|
FlexRender: <TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>) => ReactNode;
|
|
75
83
|
/**
|
|
76
|
-
* The selected state of the table. This state may not match the structure of
|
|
84
|
+
* The selected state of the table. This state may not match the structure of
|
|
85
|
+
* the full table state because it is selected by the selector function that
|
|
86
|
+
* you pass as the 2nd argument to `useTable`.
|
|
77
87
|
*
|
|
78
88
|
* @example
|
|
79
89
|
* const table = useTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state
|
package/dist/useTable.d.ts
CHANGED
|
@@ -4,7 +4,15 @@ import { CellData, RowData, Table, TableFeatures, TableOptions, TableState } fro
|
|
|
4
4
|
import { FunctionComponent, ReactNode } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/useTable.d.ts
|
|
7
|
-
type ReactTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = TableState<TFeatures>> = Table<TFeatures, TData> & {
|
|
7
|
+
type ReactTable<TFeatures extends TableFeatures, TData extends RowData, TSelected = TableState<TFeatures>> = Omit<Table<TFeatures, TData>, 'store'> & {
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Prefer `table.state` for render reads,
|
|
10
|
+
* `table.atoms.<slice>.get()` for slice snapshots, or
|
|
11
|
+
* `table.Subscribe` / `useSelector(table.store, selector)` for explicit
|
|
12
|
+
* subscriptions. `table.store.state` is a current-value snapshot and is easy
|
|
13
|
+
* to misuse in render code.
|
|
14
|
+
*/
|
|
15
|
+
readonly store: Table<TFeatures, TData>['store'];
|
|
8
16
|
/**
|
|
9
17
|
* A React HOC (Higher Order Component) that allows you to subscribe to the table state.
|
|
10
18
|
*
|
|
@@ -73,7 +81,9 @@ type ReactTable<TFeatures extends TableFeatures, TData extends RowData, TSelecte
|
|
|
73
81
|
*/
|
|
74
82
|
FlexRender: <TValue extends CellData = CellData>(props: FlexRenderProps<TFeatures, TData, TValue>) => ReactNode;
|
|
75
83
|
/**
|
|
76
|
-
* The selected state of the table. This state may not match the structure of
|
|
84
|
+
* The selected state of the table. This state may not match the structure of
|
|
85
|
+
* the full table state because it is selected by the selector function that
|
|
86
|
+
* you pass as the 2nd argument to `useTable`.
|
|
77
87
|
*
|
|
78
88
|
* @example
|
|
79
89
|
* const table = useTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state
|
package/dist/useTable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTable.js","names":[],"sources":["../src/useTable.ts"],"sourcesContent":["'use client'\n\nimport { useMemo, useState } from 'react'\nimport { constructTable } from '@tanstack/table-core'\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport { reactReactivity } from './reactivity'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribePropsWithStore, SubscribeSource } from './Subscribe'\nimport type {\n CellData,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type ReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n> = Table<TFeatures, TData> & {\n /**\n * A React HOC (Higher Order 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 * Pass `source` to subscribe to a single atom or store (e.g. `table.atoms.rowSelection`\n * or `table.optionsStore`) instead of the full `table.store`.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <tr key={row.id}>...</tr>\n * )}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection} selector={(s) => s?.[row.id]}>\n * {() => <tr key={row.id}>...</tr>}\n * </table.Subscribe>\n */\n /**\n * Overloads (not a single union) so `selector` callbacks get correct contextual\n * types in JSX; a union of two `selector` signatures degrades to implicit `any`.\n *\n * Source **without** `selector` is a separate overload so children receive `TSourceValue`\n * (identity projection). If `selector` were optional on one overload, `TSubSelected`\n * would default to `unknown` instead of inferring from the source.\n *\n * The **source** overloads are listed first so `TSourceValue` is inferred from `source`.\n */\n Subscribe: {\n <TSourceValue>(props: {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n }): ReturnType<FunctionComponent>\n <TSourceValue, TSubSelected>(props: {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSubSelected\n children: ((state: TSubSelected) => ReactNode) | ReactNode\n }): ReturnType<FunctionComponent>\n <TSubSelected>(\n props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>,\n ): ReturnType<FunctionComponent>\n }\n /**\n * A React component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n *\n * @example\n * ```tsx\n * <table.FlexRender cell={cell} />\n * <table.FlexRender header={header} />\n * <table.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 */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ReactNode\n /**\n * The selected state of the table. This state may not match the structure of
|
|
1
|
+
{"version":3,"file":"useTable.js","names":[],"sources":["../src/useTable.ts"],"sourcesContent":["'use client'\n\nimport { useMemo, useState } from 'react'\nimport { constructTable } from '@tanstack/table-core'\nimport { shallow, useSelector } from '@tanstack/react-store'\nimport { reactReactivity } from './reactivity'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribePropsWithStore, SubscribeSource } from './Subscribe'\nimport type {\n CellData,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type ReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n> = Omit<Table<TFeatures, TData>, 'store'> & {\n /**\n * @deprecated Prefer `table.state` for render reads,\n * `table.atoms.<slice>.get()` for slice snapshots, or\n * `table.Subscribe` / `useSelector(table.store, selector)` for explicit\n * subscriptions. `table.store.state` is a current-value snapshot and is easy\n * to misuse in render code.\n */\n readonly store: Table<TFeatures, TData>['store']\n /**\n * A React HOC (Higher Order 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 * Pass `source` to subscribe to a single atom or store (e.g. `table.atoms.rowSelection`\n * or `table.optionsStore`) instead of the full `table.store`.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <tr key={row.id}>...</tr>\n * )}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection}>\n * {(rowSelection) => <div>...</div>}\n * </table.Subscribe>\n *\n * @example\n * <table.Subscribe source={table.atoms.rowSelection} selector={(s) => s?.[row.id]}>\n * {() => <tr key={row.id}>...</tr>}\n * </table.Subscribe>\n */\n /**\n * Overloads (not a single union) so `selector` callbacks get correct contextual\n * types in JSX; a union of two `selector` signatures degrades to implicit `any`.\n *\n * Source **without** `selector` is a separate overload so children receive `TSourceValue`\n * (identity projection). If `selector` were optional on one overload, `TSubSelected`\n * would default to `unknown` instead of inferring from the source.\n *\n * The **source** overloads are listed first so `TSourceValue` is inferred from `source`.\n */\n Subscribe: {\n <TSourceValue>(props: {\n source: SubscribeSource<TSourceValue>\n selector?: undefined\n children: ((state: TSourceValue) => ReactNode) | ReactNode\n }): ReturnType<FunctionComponent>\n <TSourceValue, TSubSelected>(props: {\n source: SubscribeSource<TSourceValue>\n selector: (state: TSourceValue) => TSubSelected\n children: ((state: TSubSelected) => ReactNode) | ReactNode\n }): ReturnType<FunctionComponent>\n <TSubSelected>(\n props: Omit<SubscribePropsWithStore<TFeatures, TSubSelected>, 'source'>,\n ): ReturnType<FunctionComponent>\n }\n /**\n * A React component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n *\n * @example\n * ```tsx\n * <table.FlexRender cell={cell} />\n * <table.FlexRender header={header} />\n * <table.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 */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ReactNode\n /**\n * The selected state of the table. This state may not match the structure of\n * the full table state because it is selected by the selector function that\n * you pass as the 2nd argument to `useTable`.\n *\n * @example\n * const table = useTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state\n *\n * console.log(table.state.globalFilter)\n */\n readonly state: Readonly<TSelected>\n}\n\n/**\n * Creates a React table instance backed by TanStack Store atoms.\n *\n * The optional selector projects from `table.store`; the selected value is\n * exposed on `table.state` and compared shallowly for React re-renders. Omit\n * the selector to subscribe to every registered table state slice, or pass a\n * narrower selector and use `table.Subscribe` lower in the tree for targeted\n * subscriptions.\n *\n * @example\n * ```tsx\n * const table = useTable(\n * {\n * _features,\n * _rowModels: {},\n * columns,\n * data,\n * },\n * (state) => ({ pagination: state.pagination }),\n * )\n *\n * table.state.pagination\n * ```\n */\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = TableState<TFeatures>,\n>(\n tableOptions: TableOptions<TFeatures, TData>,\n selector?: (state: TableState<TFeatures>) => TSelected,\n): ReactTable<TFeatures, TData, TSelected> {\n const [table] = useState(() => {\n const tableInstance = constructTable({\n ...tableOptions,\n _features: {\n coreReativityFeature: reactReactivity(),\n ...tableOptions._features,\n },\n }) as unknown as ReactTable<TFeatures, TData, TSelected>\n\n tableInstance.Subscribe = ((props: any) => {\n const source = props.source ?? tableInstance.store\n\n return Subscribe({\n ...props,\n source,\n })\n }) as ReactTable<TFeatures, TData, TSelected>['Subscribe']\n\n tableInstance.FlexRender = FlexRender\n\n return tableInstance\n })\n\n // sync options on every render\n table.setOptions((prev) => ({\n ...prev,\n ...tableOptions,\n }))\n\n const state = useSelector(table.store, selector, { compare: shallow })\n\n // we know this is not the most efficient way to return the table,\n // but it is required for the react compiler to work\n return useMemo(\n () => ({\n ...table,\n options: tableOptions,\n state,\n }),\n [table, tableOptions, state],\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6IA,SAAgB,SAKd,cACA,UACyC;CACzC,MAAM,CAAC,SAAS,eAAe;EAC7B,MAAM,gBAAgB,eAAe;GACnC,GAAG;GACH,WAAW;IACT,sBAAsB,gBAAgB;IACtC,GAAG,aAAa;GAClB;EACF,CAAC;EAED,cAAc,cAAc,UAAe;GACzC,MAAM,SAAS,MAAM,UAAU,cAAc;GAE7C,OAAO,UAAU;IACf,GAAG;IACH;GACF,CAAC;EACH;EAEA,cAAc,aAAa;EAE3B,OAAO;CACT,CAAC;CAGD,MAAM,YAAY,UAAU;EAC1B,GAAG;EACH,GAAG;CACL,EAAE;CAEF,MAAM,QAAQ,YAAY,MAAM,OAAO,UAAU,EAAE,SAAS,QAAQ,CAAC;CAIrE,OAAO,eACE;EACL,GAAG;EACH,SAAS;EACT;CACF,IACA;EAAC;EAAO;EAAc;CAAK,CAC7B;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-table",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.52",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for React.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@tanstack/react-store": "^0.11.0",
|
|
58
|
-
"@tanstack/table-core": "9.0.0-alpha.
|
|
58
|
+
"@tanstack/table-core": "9.0.0-alpha.52"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@eslint-react/eslint-plugin": "^5.8.
|
|
62
|
-
"@types/react": "^19.2.
|
|
61
|
+
"@eslint-react/eslint-plugin": "^5.8.8",
|
|
62
|
+
"@types/react": "^19.2.15",
|
|
63
63
|
"@vitejs/plugin-react": "^6.0.2",
|
|
64
64
|
"eslint-plugin-react-compiler": "19.1.0-rc.2",
|
|
65
65
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
@@ -179,7 +179,7 @@ function Table({ data, filter }) {
|
|
|
179
179
|
| `<table.Subscribe>` / `<Subscribe>` | ✓ | Surgical re-render boundaries inside the tree |
|
|
180
180
|
| `useSelector(table.atoms.X)` | ✓ | Narrowest possible subscription to one slice |
|
|
181
181
|
| `table.atoms.X.get()` | ✗ current-value read | Inside event handlers / effects |
|
|
182
|
-
| `table.
|
|
182
|
+
| `table.state` | ✗ current-value read | Debugging / one-shot reads |
|
|
183
183
|
|
|
184
184
|
| Write path | Owner | Effect |
|
|
185
185
|
| ------------------------------- | ----------------- | ---------------------------------------------------------------------------------- |
|
|
@@ -6,7 +6,7 @@ description: >
|
|
|
6
6
|
memory has a v9 equivalent enumerated below: `useReactTable` → `useTable`,
|
|
7
7
|
root `get*RowModel` options → `_rowModels` with factory + *Fns parameter,
|
|
8
8
|
`createColumnHelper<TData>` → `createColumnHelper<typeof _features, TData>`,
|
|
9
|
-
`table.getState()` → `table.
|
|
9
|
+
`table.getState()` → `table.state` / `table.store.state` / `table.atoms.X.get()`,
|
|
10
10
|
`sortingFn` → `sortFn`, `enablePinning` → split, `_`-prefixed APIs unprefixed,
|
|
11
11
|
`ColumnSizing` split into `columnSizingFeature` + `columnResizingFeature`.
|
|
12
12
|
For incremental migration, `useLegacyTable` from `@tanstack/react-table/legacy`
|
|
@@ -120,12 +120,12 @@ const state = table.getState()
|
|
|
120
120
|
const cells = row._getAllCellsByColumnId()
|
|
121
121
|
|
|
122
122
|
// v9
|
|
123
|
-
const all = table.
|
|
123
|
+
const all = table.state // flat snapshot
|
|
124
124
|
const sorting = table.atoms.sorting.get() // per-slice atom
|
|
125
125
|
const cells = row.getAllCellsByColumnId() // no underscore — APIs unprefixed
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
In components, prefer `<table.Subscribe>` over `table.
|
|
128
|
+
In components, prefer `<table.Subscribe>` over `table.state` for reactivity (see `tanstack-table/react/table-state`).
|
|
129
129
|
|
|
130
130
|
### Renames
|
|
131
131
|
|
|
@@ -329,7 +329,7 @@ function Toolbar({ table }) {
|
|
|
329
329
|
}
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
-
`getState` was removed. Use `table.
|
|
332
|
+
`getState` was removed. Use `table.state` for a flat snapshot, `table.state` if you passed a `useTable` selector, or `<table.Subscribe>` for reactive reads.
|
|
333
333
|
Source: `docs/framework/react/guide/migrating.md`; `examples/react/basic-subscribe/src/main.tsx`.
|
|
334
334
|
|
|
335
335
|
### HIGH `enablePinning: true` on v9
|
|
@@ -269,7 +269,7 @@ function SelectedCount({ table }) {
|
|
|
269
269
|
}
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
-
`<table.Subscribe>` still selects from `table.
|
|
272
|
+
`<table.Subscribe>` still selects from `table.state` (the full state). For a single slice, `useSelector(table.atoms.X)` skips even constructing the snapshot.
|
|
273
273
|
Source: `docs/framework/react/guide/table-state.md`.
|
|
274
274
|
|
|
275
275
|
### MEDIUM Hoisting heavy table state reads above virtualizers
|
|
@@ -258,7 +258,7 @@ function Pager({ table }) {
|
|
|
258
258
|
}
|
|
259
259
|
```
|
|
260
260
|
|
|
261
|
-
`.get()` and `table.
|
|
261
|
+
`.get()` and `table.state` are current-value reads, not subscriptions. The component never re-renders when the atom changes.
|
|
262
262
|
Source: `docs/framework/react/guide/table-state.md`; `examples/react/basic-subscribe/src/main.tsx`.
|
|
263
263
|
|
|
264
264
|
### HIGH Passing both `atoms.X` and `state.X` for the same slice
|
package/src/useLegacyTable.ts
CHANGED
|
@@ -279,7 +279,7 @@ export type LegacyReactTable<TData extends RowData> = ReactTable<
|
|
|
279
279
|
> & {
|
|
280
280
|
/**
|
|
281
281
|
* Returns the current table state.
|
|
282
|
-
* @deprecated In v9, access state directly via `table.state` or use `table.
|
|
282
|
+
* @deprecated In v9, access state directly via `table.state` or use `table.state` for the full state.
|
|
283
283
|
*/
|
|
284
284
|
getState: () => TableState<StockFeatures>
|
|
285
285
|
/**
|
package/src/useTable.ts
CHANGED
|
@@ -22,7 +22,15 @@ export type ReactTable<
|
|
|
22
22
|
TFeatures extends TableFeatures,
|
|
23
23
|
TData extends RowData,
|
|
24
24
|
TSelected = TableState<TFeatures>,
|
|
25
|
-
> = Table<TFeatures, TData> & {
|
|
25
|
+
> = Omit<Table<TFeatures, TData>, 'store'> & {
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Prefer `table.state` for render reads,
|
|
28
|
+
* `table.atoms.<slice>.get()` for slice snapshots, or
|
|
29
|
+
* `table.Subscribe` / `useSelector(table.store, selector)` for explicit
|
|
30
|
+
* subscriptions. `table.store.state` is a current-value snapshot and is easy
|
|
31
|
+
* to misuse in render code.
|
|
32
|
+
*/
|
|
33
|
+
readonly store: Table<TFeatures, TData>['store']
|
|
26
34
|
/**
|
|
27
35
|
* A React HOC (Higher Order Component) that allows you to subscribe to the table state.
|
|
28
36
|
*
|
|
@@ -95,7 +103,9 @@ export type ReactTable<
|
|
|
95
103
|
props: FlexRenderProps<TFeatures, TData, TValue>,
|
|
96
104
|
) => ReactNode
|
|
97
105
|
/**
|
|
98
|
-
* The selected state of the table. This state may not match the structure of
|
|
106
|
+
* The selected state of the table. This state may not match the structure of
|
|
107
|
+
* the full table state because it is selected by the selector function that
|
|
108
|
+
* you pass as the 2nd argument to `useTable`.
|
|
99
109
|
*
|
|
100
110
|
* @example
|
|
101
111
|
* const table = useTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state
|
|
@@ -144,7 +154,7 @@ export function useTable<
|
|
|
144
154
|
coreReativityFeature: reactReactivity(),
|
|
145
155
|
...tableOptions._features,
|
|
146
156
|
},
|
|
147
|
-
}) as ReactTable<TFeatures, TData, TSelected>
|
|
157
|
+
}) as unknown as ReactTable<TFeatures, TData, TSelected>
|
|
148
158
|
|
|
149
159
|
tableInstance.Subscribe = ((props: any) => {
|
|
150
160
|
const source = props.source ?? tableInstance.store
|