Skip to content

Commit e91608e

Browse files
authored
feat: update column pinning terminology from left/right to start/end (#6398)
* feat: update column pinning terminology from left/right to start/end * update beta number * update variable names and clarify left to right associations
1 parent 3381f42 commit e91608e

451 files changed

Lines changed: 3363 additions & 2510 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/framework/alpine/guide/column-ordering.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ By default, columns are ordered in the order they are defined in the `columns` a
4040

4141
There are 3 table features that can reorder columns, which happen in the following order:
4242

43-
1. [Column Pinning](./column-pinning) - If pinning, columns are split into left, center (unpinned), and right pinned columns.
43+
1. [Column Pinning](./column-pinning) - If pinning, columns are split into start, center (unpinned), and end pinned columns.
4444
2. Manual **Column Ordering** - A manually specified column order is applied.
4545
3. [Grouping](./grouping) - If grouping is enabled, a grouping state is active, and `tableOptions.groupedColumnMode` is set to `'reorder' | 'remove'`, then the grouped columns are reordered to the start of the column flow.
4646

@@ -173,9 +173,9 @@ Columns expose helpers for reading their current position after column pinning,
173173

174174
```ts
175175
column.getIndex()
176-
column.getIndex('left')
176+
column.getIndex('start')
177177
column.getIndex('center')
178-
column.getIndex('right')
178+
column.getIndex('end')
179179

180180
column.getIsFirstColumn()
181181
column.getIsLastColumn()

docs/framework/alpine/guide/column-pinning.md

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,19 @@ const table = createTable({
3636

3737
## Column Pinning (Alpine) Guide
3838

39-
TanStack Table offers state and APIs helpful for implementing column pinning features in your table UI. You can implement column pinning in multiple ways. You can either split pinned columns into their own separate tables, or you can keep all columns in the same table, but use the pinning state to order the columns correctly and use sticky CSS to pin the columns to the left or right.
39+
TanStack Table offers state and APIs helpful for implementing column pinning features in your table UI. You can implement column pinning in multiple ways. You can either split pinned columns into their own separate tables, or you can keep all columns in the same table, but use the pinning state to order the columns correctly and use sticky CSS to pin the columns to the start or end.
40+
41+
`start` and `end` are logical pinning regions. In LTR languages/layouts, `start` usually corresponds to left and `end` to right. In RTL languages/layouts, `start` usually corresponds to right and `end` to left.
4042

4143
### How Column Pinning Affects Column Order
4244

4345
There are 3 table features that can reorder columns, which happen in the following order:
4446

45-
1. **Column Pinning** - If pinning, columns are split into left, center (unpinned), and right pinned columns.
47+
1. **Column Pinning** - If pinning, columns are split into start, center (unpinned), and end pinned columns.
4648
2. Manual [Column Ordering](./column-ordering) - A manually specified column order is applied.
4749
3. [Grouping](./grouping) - If grouping is enabled, a grouping state is active, and `tableOptions.groupedColumnMode` is set to `'reorder' | 'remove'`, then the grouped columns are reordered to the start of the column flow.
4850

49-
The only way to change the order of the pinned columns is in the `columnPinning.left` and `columnPinning.right` state itself. `columnOrder` state will only affect the order of the unpinned ("center") columns.
51+
The only way to change the order of the pinned columns is in the `columnPinning.start` and `columnPinning.end` state itself. `columnOrder` state will only affect the order of the unpinned ("center") columns.
5052

5153
### Column Pinning State
5254

@@ -66,8 +68,8 @@ import type { ColumnPinningState } from '@tanstack/alpine-table'
6668
const features = tableFeatures({ columnPinningFeature })
6769

6870
const columnPinningAtom = createAtom<ColumnPinningState>({
69-
left: [],
70-
right: [],
71+
start: [],
72+
end: [],
7173
})
7274

7375
// subscribe wherever it is needed
@@ -89,7 +91,7 @@ Alternatively, the v8-style `state.columnPinning` plus `onColumnPinningChange` p
8991

9092
```ts
9193
const local = Alpine.reactive({
92-
columnPinning: { left: [], right: [] } as ColumnPinningState,
94+
columnPinning: { start: [], end: [] } as ColumnPinningState,
9395
})
9496

9597
const table = createTable({
@@ -119,8 +121,8 @@ const table = createTable({
119121
//...
120122
initialState: {
121123
columnPinning: {
122-
left: ['expand-column'],
123-
right: ['actions-column'],
124+
start: ['expand-column'],
125+
end: ['actions-column'],
124126
},
125127
//...
126128
},
@@ -135,20 +137,20 @@ const table = createTable({
135137
There are a handful of useful Column API methods to help you implement column pinning features:
136138

137139
- `column.getCanPin`: Use to determine if a column can be pinned.
138-
- `column.pin`: Use to pin a column to the left or right. Or use to unpin a column.
140+
- `column.pin`: Use to pin a column to the start or end. Or use to unpin a column.
139141
- `column.getIsPinned`: Use to determine where a column is pinned.
140142
- `column.getPinnedIndex`: Use to read the column's index within its pinned column group.
141-
- `column.getStart`: Use to provide the correct `left` CSS value for a pinned column.
142-
- `column.getAfter`: Use to provide the correct `right` CSS value for a pinned column.
143+
- `column.getStart`: Use to provide the correct `start` CSS value for a pinned column.
144+
- `column.getAfter`: Use to provide the correct `end` CSS value for a pinned column.
143145
- `column.getIsLastColumn`: Use to determine if a column is the last column in its pinned group. Useful for adding a box-shadow.
144146
- `column.getIsFirstColumn`: Use to determine if a column is the first column in its pinned group. Useful for adding a box-shadow.
145147

146148
Use `table.setColumnPinning` to update the pinning state directly. Use `table.resetColumnPinning` to reset to `initialState.columnPinning`, or pass `true` to clear both pinned column arrays.
147149

148150
```ts
149151
table.setColumnPinning({
150-
left: ['firstName'],
151-
right: ['actions'],
152+
start: ['firstName'],
153+
end: ['actions'],
152154
})
153155

154156
table.resetColumnPinning()
@@ -158,44 +160,44 @@ table.resetColumnPinning(true)
158160
The table instance exposes pinned column and header helpers for each region:
159161

160162
```ts
161-
table.getLeftLeafColumns()
163+
table.getStartLeafColumns()
162164
table.getCenterLeafColumns()
163-
table.getRightLeafColumns()
165+
table.getEndLeafColumns()
164166

165-
table.getLeftVisibleLeafColumns()
167+
table.getStartVisibleLeafColumns()
166168
table.getCenterVisibleLeafColumns()
167-
table.getRightVisibleLeafColumns()
169+
table.getEndVisibleLeafColumns()
168170

169-
table.getLeftHeaderGroups()
171+
table.getStartHeaderGroups()
170172
table.getCenterHeaderGroups()
171-
table.getRightHeaderGroups()
173+
table.getEndHeaderGroups()
172174

173-
table.getLeftFooterGroups()
175+
table.getStartFooterGroups()
174176
table.getCenterFooterGroups()
175-
table.getRightFooterGroups()
177+
table.getEndFooterGroups()
176178

177-
table.getLeftFlatHeaders()
179+
table.getStartFlatHeaders()
178180
table.getCenterFlatHeaders()
179-
table.getRightFlatHeaders()
181+
table.getEndFlatHeaders()
180182

181-
table.getLeftLeafHeaders()
183+
table.getStartLeafHeaders()
182184
table.getCenterLeafHeaders()
183-
table.getRightLeafHeaders()
185+
table.getEndLeafHeaders()
184186
```
185187

186188
You can also request pinned leaf columns by region with `table.getPinnedLeafColumns(position)` and visible pinned leaf columns with `table.getPinnedVisibleLeafColumns(position)`.
187189

188190
```ts
189-
table.getPinnedLeafColumns('left')
191+
table.getPinnedLeafColumns('start')
190192
table.getPinnedLeafColumns('center')
191-
table.getPinnedLeafColumns('right')
193+
table.getPinnedLeafColumns('end')
192194

193-
table.getPinnedVisibleLeafColumns('left')
195+
table.getPinnedVisibleLeafColumns('start')
194196
table.getPinnedVisibleLeafColumns('center')
195-
table.getPinnedVisibleLeafColumns('right')
197+
table.getPinnedVisibleLeafColumns('end')
196198
```
197199

198-
Use `table.getIsSomeColumnsPinned()` to check if any columns are pinned, or pass `'left'` or `'right'` to check one pinned side.
200+
Use `table.getIsSomeColumnsPinned()` to check if any columns are pinned, or pass `'start'` or `'end'` to check one pinned side.
199201

200202
### Wiring up the pinning UI
201203

@@ -211,8 +213,8 @@ Because Alpine does not initialize directives inside content set with `x-html`,
211213
<template x-if="!header.isPlaceholder && header.column.getCanPin()">
212214
<div class="pin-actions">
213215
<button
214-
x-show="header.column.getIsPinned() !== 'left'"
215-
@click="header.column.pin('left')"
216+
x-show="header.column.getIsPinned() !== 'start'"
217+
@click="header.column.pin('start')"
216218
>
217219
&lt;=
218220
</button>
@@ -223,8 +225,8 @@ Because Alpine does not initialize directives inside content set with `x-html`,
223225
X
224226
</button>
225227
<button
226-
x-show="header.column.getIsPinned() !== 'right'"
227-
@click="header.column.pin('right')"
228+
x-show="header.column.getIsPinned() !== 'end'"
229+
@click="header.column.pin('end')"
228230
>
229231
=&gt;
230232
</button>
@@ -237,4 +239,4 @@ Because Alpine does not initialize directives inside content set with `x-html`,
237239

238240
If you are just using sticky CSS to pin columns, you can for the most part, just render the table as you normally would with the `table.getHeaderGroups` and `row.getVisibleCells` methods.
239241

240-
However, if you are splitting up pinned columns into their own separate tables, you can make use of the `table.getLeftHeaderGroups`, `table.getCenterHeaderGroups`, `table.getRightHeaderGroups`, `row.getLeftVisibleCells`, `row.getCenterVisibleCells`, and `row.getRightVisibleCells` methods to only render the columns that are relevant to the current table.
242+
However, if you are splitting up pinned columns into their own separate tables, you can make use of the `table.getStartHeaderGroups`, `table.getCenterHeaderGroups`, `table.getEndHeaderGroups`, `row.getStartVisibleCells`, `row.getCenterVisibleCells`, and `row.getEndVisibleCells` methods to only render the columns that are relevant to the current table.

docs/framework/alpine/guide/column-sizing.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ Use the column and header APIs to read the calculated size and offsets for rende
135135
column.getSize()
136136
header.getSize()
137137

138-
column.getStart() // left offset in the current column flow
139-
column.getStart('left')
138+
column.getStart() // start offset in the current column flow
139+
column.getStart('start')
140140
column.getStart('center')
141-
column.getStart('right')
141+
column.getStart('end')
142142

143-
column.getAfter() // right offset in the current column flow
144-
column.getAfter('left')
143+
column.getAfter() // end offset in the current column flow
144+
column.getAfter('start')
145145
column.getAfter('center')
146-
column.getAfter('right')
146+
column.getAfter('end')
147147

148148
column.resetSize()
149149
```
@@ -152,9 +152,9 @@ The table instance also exposes total size helpers. These are useful when buildi
152152

153153
```ts
154154
table.getTotalSize()
155-
table.getLeftTotalSize()
155+
table.getStartTotalSize()
156156
table.getCenterTotalSize()
157-
table.getRightTotalSize()
157+
table.getEndTotalSize()
158158
```
159159

160160
If you need to update sizing state directly, use `table.setColumnSizing`. Use `table.resetColumnSizing` to reset to `initialState.columnSizing`, or pass `true` to reset to the feature default.

docs/framework/alpine/guide/grouping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Grouping in TanStack table is a feature that applies to columns and allows you t
4444

4545
Grouping can also affect column order. There are 3 table features that can reorder columns, which happen in the following order:
4646

47-
1. [Column Pinning](./column-pinning) - If pinning, columns are split into left, center (unpinned), and right pinned columns.
47+
1. [Column Pinning](./column-pinning) - If pinning, columns are split into start, center (unpinned), and end pinned columns.
4848
2. Manual [Column Ordering](./column-ordering) - A manually specified column order is applied.
4949
3. **Grouping** - If grouping is enabled, a grouping state is active, and `tableOptions.groupedColumnMode` is set to `'reorder' | 'remove'`, then the grouped columns are reordered to the start of the column flow.
5050

docs/framework/alpine/reference/functions/createTable.md

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

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

12-
Defined in: [createTable.ts:27](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTable.ts#L27)
12+
Defined in: [createTable.ts:46](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTable.ts#L46)
13+
14+
Creates an Alpine-reactive table instance.
15+
16+
Reactivity is bridged through a single version counter that every proxied
17+
table read registers as a dependency, so by default ANY state change
18+
re-evaluates every Alpine binding that touches the table. Pass a `selector`
19+
to gate that: the counter then only bumps when the selected slice of state
20+
changes (shallow compare). Use `() => ({})` to opt out of state-driven
21+
re-evaluation entirely and handle high-frequency state (e.g. column
22+
resizing) with explicit `table.atoms.<slice>.subscribe()` side effects.
23+
Options changes (e.g. new `data`) always re-evaluate.
1324

1425
## Type Parameters
1526

@@ -27,6 +38,16 @@ Defined in: [createTable.ts:27](https://github.com/TanStack/table/blob/main/pack
2738

2839
`TableOptions`\<`TFeatures`, `TData`\>
2940

41+
### selector?
42+
43+
(`state`) => `unknown`
44+
3045
## Returns
3146

3247
[`AlpineTable`](../type-aliases/AlpineTable.md)\<`TFeatures`, `TData`\>
48+
49+
## Example
50+
51+
```ts
52+
const table = createTable(options, (state) => ({ sorting: state.sorting }))
53+
```

docs/framework/alpine/reference/functions/createTableHook.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: createTableHook
99
function createTableHook<TFeatures>(__namedParameters): object;
1010
```
1111

12-
Defined in: [createTableHook.ts:21](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTableHook.ts#L21)
12+
Defined in: [createTableHook.ts:26](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTableHook.ts#L26)
1313

1414
## Type Parameters
1515

@@ -52,7 +52,7 @@ createAppColumnHelper: <TData>() => ColumnHelper<TFeatures, TData>;
5252
### createAppTable()
5353

5454
```ts
55-
createAppTable: <TData>(tableOptions) => AppAlpineTable<TFeatures, TData>;
55+
createAppTable: <TData>(tableOptions, selector?) => AppAlpineTable<TFeatures, TData>;
5656
```
5757

5858
#### Type Parameters
@@ -67,6 +67,10 @@ createAppTable: <TData>(tableOptions) => AppAlpineTable<TFeatures, TData>;
6767

6868
`Omit`\<`TableOptions`\<`TFeatures`, `TData`\>, `"features"`\>
6969

70+
##### selector?
71+
72+
(`state`) => `unknown`
73+
7074
#### Returns
7175

7276
[`AppAlpineTable`](../type-aliases/AppAlpineTable.md)\<`TFeatures`, `TData`\>

docs/framework/alpine/reference/type-aliases/AlpineTable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: AlpineTable
99
type AlpineTable<TFeatures, TData> = Table<TFeatures, TData> & object;
1010
```
1111

12-
Defined in: [createTable.ts:12](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTable.ts#L12)
12+
Defined in: [createTable.ts:14](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTable.ts#L14)
1313

1414
## Type Declaration
1515

docs/framework/alpine/reference/type-aliases/AppAlpineTable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: AppAlpineTable
99
type AppAlpineTable<TFeatures, TData> = AlpineTable<TFeatures, TData>;
1010
```
1111

12-
Defined in: [createTableHook.ts:11](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTableHook.ts#L11)
12+
Defined in: [createTableHook.ts:16](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTableHook.ts#L16)
1313

1414
## Type Parameters
1515

docs/framework/alpine/reference/type-aliases/AppColumnHelper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: AppColumnHelper
99
type AppColumnHelper<TFeatures, TData> = ReturnType<typeof coreCreateColumnHelper>;
1010
```
1111

12-
Defined in: [createTableHook.ts:16](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTableHook.ts#L16)
12+
Defined in: [createTableHook.ts:21](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTableHook.ts#L21)
1313

1414
## Type Parameters
1515

docs/framework/alpine/reference/type-aliases/CreateTableHookOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: CreateTableHookOptions
99
type CreateTableHookOptions<TFeatures> = Omit<TableOptions<TFeatures, any>, "columns" | "data" | "state">;
1010
```
1111

12-
Defined in: [createTableHook.ts:6](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTableHook.ts#L6)
12+
Defined in: [createTableHook.ts:11](https://github.com/TanStack/table/blob/main/packages/alpine-table/src/createTableHook.ts#L11)
1313

1414
## Type Parameters
1515

0 commit comments

Comments
 (0)