Skip to content

Commit c5c781a

Browse files
authored
feat: change default state selectors to all (#6246)
* feat: change default state selectors to all * add basic-subscribe example
1 parent 2d1dfd9 commit c5c781a

155 files changed

Lines changed: 6374 additions & 4695 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@
823823
{ "to": "framework/react/examples/basic-use-legacy-table", "label": "Basic (useLegacyTable)" },
824824
{ "to": "framework/react/examples/basic-external-state", "label": "Basic (External State)" },
825825
{ "to": "framework/react/examples/basic-external-atoms", "label": "Basic (External Atoms)" },
826+
{ "to": "framework/react/examples/basic-subscribe", "label": "Basic (Subscribe)" },
826827
{ "to": "framework/react/examples/column-groups", "label": "Header Groups" }
827828
]
828829
},
@@ -864,6 +865,7 @@
864865
{ "to": "framework/preact/examples/basic-use-app-table", "label": "Basic (useAppTable)" },
865866
{ "to": "framework/preact/examples/basic-external-state", "label": "Basic (External State)" },
866867
{ "to": "framework/preact/examples/basic-external-atoms", "label": "Basic (External Atoms)" },
868+
{ "to": "framework/preact/examples/basic-subscribe", "label": "Basic (Subscribe)" },
867869
{ "to": "framework/preact/examples/column-groups", "label": "Header Groups" }
868870
]
869871
},

docs/framework/angular/reference/functions/injectTable.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ title: injectTable
66
# Function: injectTable()
77

88
```ts
9-
function injectTable<TFeatures, TData, TSelected>(options, selector): AngularTable<TFeatures, TData, TSelected>;
9+
function injectTable<TFeatures, TData, TSelected>(options, selector?): AngularTable<TFeatures, TData, TSelected>;
1010
```
1111

12-
Defined in: [injectTable.ts:124](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L124)
12+
Defined in: [injectTable.ts:133](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L133)
1313

1414
Creates and returns an Angular-reactive table instance.
1515

@@ -42,7 +42,7 @@ The returned table is also signal-reactive: table state and table APIs are wired
4242

4343
() => `TableOptions`\<`TFeatures`, `TData`\>
4444

45-
### selector
45+
### selector?
4646

4747
(`state`) => `TSelected`
4848

docs/framework/angular/reference/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ title: "@tanstack/angular-table"
3838
- [FlexRenderContent](type-aliases/FlexRenderContent.md)
3939
- [FlexRenderInputContent](type-aliases/FlexRenderInputContent.md)
4040
- [RenderableComponent](type-aliases/RenderableComponent.md)
41+
- [SubscribeSource](type-aliases/SubscribeSource.md)
4142

4243
## Variables
4344

docs/framework/angular/reference/interfaces/AngularTableComputed.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: AngularTableComputed
55

66
# Interface: AngularTableComputed()\<TFeatures\>
77

8-
Defined in: [injectTable.ts:28](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L28)
8+
Defined in: [injectTable.ts:40](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L40)
99

1010
Store mode: pass `selector` (required) to project from full table state.
1111
Source mode: pass `source` (atom or store); omit `selector` for the whole value
@@ -24,7 +24,7 @@ inference.
2424
AngularTableComputed<TSourceValue>(props): Signal<Readonly<TSourceValue>>;
2525
```
2626

27-
Defined in: [injectTable.ts:29](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L29)
27+
Defined in: [injectTable.ts:41](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L41)
2828

2929
Store mode: pass `selector` (required) to project from full table state.
3030
Source mode: pass `source` (atom or store); omit `selector` for the whole value
@@ -51,7 +51,7 @@ inference.
5151

5252
##### source
5353

54-
`Atom`\<`TSourceValue`\> \| `ReadonlyAtom`\<`TSourceValue`\>
54+
[`SubscribeSource`](../type-aliases/SubscribeSource.md)\<`TSourceValue`\>
5555

5656
### Returns
5757

@@ -63,7 +63,7 @@ inference.
6363
AngularTableComputed<TSourceValue, TSubSelected>(props): Signal<Readonly<TSubSelected>>;
6464
```
6565

66-
Defined in: [injectTable.ts:34](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L34)
66+
Defined in: [injectTable.ts:46](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L46)
6767

6868
Store mode: pass `selector` (required) to project from full table state.
6969
Source mode: pass `source` (atom or store); omit `selector` for the whole value
@@ -94,7 +94,7 @@ inference.
9494

9595
##### source
9696

97-
`Atom`\<`TSourceValue`\> \| `ReadonlyAtom`\<`TSourceValue`\>
97+
[`SubscribeSource`](../type-aliases/SubscribeSource.md)\<`TSourceValue`\>
9898

9999
### Returns
100100

@@ -106,7 +106,7 @@ inference.
106106
AngularTableComputed<TSubSelected>(props): Signal<Readonly<TSubSelected>>;
107107
```
108108

109-
Defined in: [injectTable.ts:39](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L39)
109+
Defined in: [injectTable.ts:51](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L51)
110110

111111
Store mode: pass `selector` (required) to project from full table state.
112112
Source mode: pass `source` (atom or store); omit `selector` for the whole value

docs/framework/angular/reference/type-aliases/AngularTable.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,19 @@ title: AngularTable
99
type AngularTable<TFeatures, TData, TSelected> = Table<TFeatures, TData> & object;
1010
```
1111

12-
Defined in: [injectTable.ts:45](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L45)
12+
Defined in: [injectTable.ts:57](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L57)
1313

1414
## Type Declaration
1515

16-
### computed()
16+
### computed
1717

1818
```ts
19-
computed: <TSubSelected>(props) => Signal<Readonly<TSubSelected>>;
19+
computed: AngularTableComputed<TFeatures>;
2020
```
2121

2222
Creates a computed that subscribe to changes in the table store with a custom selector.
2323
Default equality function is "shallow".
2424

25-
#### Type Parameters
26-
27-
##### TSubSelected
28-
29-
`TSubSelected` = \{
30-
\}
31-
32-
#### Parameters
33-
34-
##### props
35-
36-
###### equal?
37-
38-
`ValueEqualityFn`\<`TSubSelected`\>
39-
40-
###### selector
41-
42-
(`state`) => `TSubSelected`
43-
44-
#### Returns
45-
46-
`Signal`\<`Readonly`\<`TSubSelected`\>\>
47-
4825
### state
4926

5027
```ts
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
id: SubscribeSource
3+
title: SubscribeSource
4+
---
5+
6+
# Type Alias: SubscribeSource\<TValue\>
7+
8+
```ts
9+
type SubscribeSource<TValue> =
10+
| Atom<TValue>
11+
| ReadonlyAtom<TValue>
12+
| Store<TValue>
13+
| ReadonlyStore<TValue>;
14+
```
15+
16+
Defined in: [injectTable.ts:28](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L28)
17+
18+
## Type Parameters
19+
20+
### TValue
21+
22+
`TValue`

docs/framework/react/reference/index/functions/Subscribe.md

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ title: Subscribe
88
## Call Signature
99

1010
```ts
11-
function Subscribe<TFeatures, TData, TSourceValue>(props): ReactNode | Promise<ReactNode>;
11+
function Subscribe<TSourceValue>(props): ReactNode | Promise<ReactNode>;
1212
```
1313

14-
Defined in: [Subscribe.ts:148](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L148)
14+
Defined in: [Subscribe.ts:125](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L125)
1515

1616
A React component that allows you to subscribe to the table state.
1717

@@ -22,14 +22,6 @@ contextual typing works. This standalone component uses a union `props` type.
2222

2323
### Type Parameters
2424

25-
#### TFeatures
26-
27-
`TFeatures` *extends* `TableFeatures`
28-
29-
#### TData
30-
31-
`TData` *extends* `RowData`
32-
3325
#### TSourceValue
3426

3527
`TSourceValue`
@@ -38,7 +30,7 @@ contextual typing works. This standalone component uses a union `props` type.
3830

3931
#### props
4032

41-
[`SubscribePropsWithSourceIdentity`](../type-aliases/SubscribePropsWithSourceIdentity.md)\<`TFeatures`, `TData`, `TSourceValue`\>
33+
[`SubscribePropsWithSourceIdentity`](../type-aliases/SubscribePropsWithSourceIdentity.md)\<`TSourceValue`\>
4234

4335
### Returns
4436

@@ -48,7 +40,7 @@ contextual typing works. This standalone component uses a union `props` type.
4840

4941
```tsx
5042
// As a standalone component — full store
51-
<Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
43+
<Subscribe source={table.store} selector={(state) => ({ rowSelection: state.rowSelection })}>
5244
{({ rowSelection }) => (
5345
<div>Selected rows: {Object.keys(rowSelection).length}</div>
5446
)}
@@ -57,15 +49,14 @@ contextual typing works. This standalone component uses a union `props` type.
5749

5850
```tsx
5951
// Entire source (atom or store) — no selector
60-
<Subscribe table={table} source={table.atoms.rowSelection}>
52+
<Subscribe source={table.atoms.rowSelection}>
6153
{(rowSelection) => <div>...</div>}
6254
</Subscribe>
6355
```
6456

6557
```tsx
6658
// Project source value (e.g. one row’s selection)
6759
<Subscribe
68-
table={table}
6960
source={table.atoms.rowSelection}
7061
selector={(rowSelection) => rowSelection?.[row.id]}
7162
>
@@ -85,10 +76,10 @@ contextual typing works. This standalone component uses a union `props` type.
8576
## Call Signature
8677

8778
```ts
88-
function Subscribe<TFeatures, TData, TSourceValue, TSelected>(props): ReactNode | Promise<ReactNode>;
79+
function Subscribe<TSourceValue, TSelected>(props): ReactNode | Promise<ReactNode>;
8980
```
9081

91-
Defined in: [Subscribe.ts:155](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L155)
82+
Defined in: [Subscribe.ts:128](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L128)
9283

9384
A React component that allows you to subscribe to the table state.
9485

@@ -99,14 +90,6 @@ contextual typing works. This standalone component uses a union `props` type.
9990

10091
### Type Parameters
10192

102-
#### TFeatures
103-
104-
`TFeatures` *extends* `TableFeatures`
105-
106-
#### TData
107-
108-
`TData` *extends* `RowData`
109-
11093
#### TSourceValue
11194

11295
`TSourceValue`
@@ -119,7 +102,7 @@ contextual typing works. This standalone component uses a union `props` type.
119102

120103
#### props
121104

122-
[`SubscribePropsWithSourceWithSelector`](../type-aliases/SubscribePropsWithSourceWithSelector.md)\<`TFeatures`, `TData`, `TSourceValue`, `TSelected`\>
105+
[`SubscribePropsWithSourceWithSelector`](../type-aliases/SubscribePropsWithSourceWithSelector.md)\<`TSourceValue`, `TSelected`\>
123106

124107
### Returns
125108

@@ -129,7 +112,7 @@ contextual typing works. This standalone component uses a union `props` type.
129112

130113
```tsx
131114
// As a standalone component — full store
132-
<Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
115+
<Subscribe source={table.store} selector={(state) => ({ rowSelection: state.rowSelection })}>
133116
{({ rowSelection }) => (
134117
<div>Selected rows: {Object.keys(rowSelection).length}</div>
135118
)}
@@ -138,15 +121,14 @@ contextual typing works. This standalone component uses a union `props` type.
138121

139122
```tsx
140123
// Entire source (atom or store) — no selector
141-
<Subscribe table={table} source={table.atoms.rowSelection}>
124+
<Subscribe source={table.atoms.rowSelection}>
142125
{(rowSelection) => <div>...</div>}
143126
</Subscribe>
144127
```
145128

146129
```tsx
147130
// Project source value (e.g. one row’s selection)
148131
<Subscribe
149-
table={table}
150132
source={table.atoms.rowSelection}
151133
selector={(rowSelection) => rowSelection?.[row.id]}
152134
>
@@ -166,10 +148,10 @@ contextual typing works. This standalone component uses a union `props` type.
166148
## Call Signature
167149

168150
```ts
169-
function Subscribe<TFeatures, TData, TSelected>(props): ReactNode | Promise<ReactNode>;
151+
function Subscribe<TFeatures, TSelected>(props): ReactNode | Promise<ReactNode>;
170152
```
171153

172-
Defined in: [Subscribe.ts:168](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L168)
154+
Defined in: [Subscribe.ts:131](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L131)
173155

174156
A React component that allows you to subscribe to the table state.
175157

@@ -184,10 +166,6 @@ contextual typing works. This standalone component uses a union `props` type.
184166

185167
`TFeatures` *extends* `TableFeatures`
186168

187-
#### TData
188-
189-
`TData` *extends* `RowData`
190-
191169
#### TSelected
192170

193171
`TSelected`
@@ -196,7 +174,7 @@ contextual typing works. This standalone component uses a union `props` type.
196174

197175
#### props
198176

199-
[`SubscribePropsWithStore`](../type-aliases/SubscribePropsWithStore.md)\<`TFeatures`, `TData`, `TSelected`\>
177+
[`SubscribePropsWithStore`](../type-aliases/SubscribePropsWithStore.md)\<`TFeatures`, `TSelected`\>
200178

201179
### Returns
202180

@@ -206,7 +184,7 @@ contextual typing works. This standalone component uses a union `props` type.
206184

207185
```tsx
208186
// As a standalone component — full store
209-
<Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>
187+
<Subscribe source={table.store} selector={(state) => ({ rowSelection: state.rowSelection })}>
210188
{({ rowSelection }) => (
211189
<div>Selected rows: {Object.keys(rowSelection).length}</div>
212190
)}
@@ -215,15 +193,14 @@ contextual typing works. This standalone component uses a union `props` type.
215193

216194
```tsx
217195
// Entire source (atom or store) — no selector
218-
<Subscribe table={table} source={table.atoms.rowSelection}>
196+
<Subscribe source={table.atoms.rowSelection}>
219197
{(rowSelection) => <div>...</div>}
220198
</Subscribe>
221199
```
222200

223201
```tsx
224202
// Project source value (e.g. one row’s selection)
225203
<Subscribe
226-
table={table}
227204
source={table.atoms.rowSelection}
228205
selector={(rowSelection) => rowSelection?.[row.id]}
229206
>

docs/framework/react/reference/index/functions/createTableHook.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ TFeatures is already known from the createTableHook call; TData is inferred from
110110

111111
##### TSelected
112112

113-
`TSelected` = \{
114-
\}
113+
`TSelected` = `TableState`\<`TFeatures`\>
115114

116115
#### Parameters
117116

docs/framework/react/reference/index/functions/useTable.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ title: useTable
66
# Function: useTable()
77

88
```ts
9-
function useTable<TFeatures, TData, TSelected>(tableOptions, selector): ReactTable<TFeatures, TData, TSelected>;
9+
function useTable<TFeatures, TData, TSelected>(tableOptions, selector?): ReactTable<TFeatures, TData, TSelected>;
1010
```
1111

12-
Defined in: [useTable.ts:112](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L112)
12+
Defined in: [useTable.ts:108](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L108)
1313

1414
## Type Parameters
1515

@@ -23,16 +23,15 @@ Defined in: [useTable.ts:112](https://github.com/TanStack/table/blob/main/packag
2323

2424
### TSelected
2525

26-
`TSelected` = \{
27-
\}
26+
`TSelected` = `TableState`\<`TFeatures`\>
2827

2928
## Parameters
3029

3130
### tableOptions
3231

3332
`TableOptions`\<`TFeatures`, `TData`\>
3433

35-
### selector
34+
### selector?
3635

3736
(`state`) => `TSelected`
3837

0 commit comments

Comments
 (0)