@tanstack/table-core 8.10.7 → 8.11.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "8.10.7",
4
+ "version": "8.11.1",
5
5
  "description": "Headless UI for building powerful tables & datagrids for TS/JS.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/tanstack/table#readme",
@@ -23,6 +23,8 @@ export interface ColumnSizingInfoState {
23
23
 
24
24
  export type ColumnResizeMode = 'onChange' | 'onEnd'
25
25
 
26
+ export type ColumnResizeDirection = 'ltr' | 'rtl'
27
+
26
28
  export interface ColumnSizingOptions {
27
29
  /**
28
30
  * Determines when the columnSizing state is updated. `onChange` updates the state when the user is dragging the resize handle. `onEnd` updates the state when the user releases the resize handle.
@@ -36,6 +38,12 @@ export interface ColumnSizingOptions {
36
38
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
37
39
  */
38
40
  enableColumnResizing?: boolean
41
+ /**
42
+ * Enables or disables right-to-left support for resizing the column. defaults to 'ltr'.
43
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#rtl)
44
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-sizing)
45
+ */
46
+ columnResizeDirection?: ColumnResizeDirection
39
47
  /**
40
48
  * If provided, this function will be called with an `updaterFn` when `state.columnSizing` changes. This overrides the default internal state management, so you will also need to supply `state.columnSizing` from your own managed state.
41
49
  * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-sizing#oncolumnsizingchange)
@@ -52,7 +60,7 @@ export interface ColumnSizingOptions {
52
60
 
53
61
  export type ColumnSizingDefaultOptions = Pick<
54
62
  ColumnSizingOptions,
55
- 'columnResizeMode' | 'onColumnSizingChange' | 'onColumnSizingInfoChange'
63
+ 'columnResizeMode' | 'onColumnSizingChange' | 'onColumnSizingInfoChange' | 'columnResizeDirection'
56
64
  >
57
65
 
58
66
  export interface ColumnSizingInstance {
@@ -225,6 +233,7 @@ export const ColumnSizing: TableFeature = {
225
233
  ): ColumnSizingDefaultOptions => {
226
234
  return {
227
235
  columnResizeMode: 'onEnd',
236
+ columnResizeDirection: 'ltr',
228
237
  onColumnSizingChange: makeStateUpdater('columnSizing', table),
229
238
  onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', table),
230
239
  }
@@ -346,7 +355,8 @@ export const ColumnSizing: TableFeature = {
346
355
  }
347
356
 
348
357
  table.setColumnSizingInfo(old => {
349
- const deltaOffset = clientXPos - (old?.startOffset ?? 0)
358
+ const deltaDirection = table.options.columnResizeDirection === 'rtl' ? -1 : 1
359
+ const deltaOffset = (clientXPos - (old?.startOffset ?? 0)) * deltaDirection
350
360
  const deltaPercentage = Math.max(
351
361
  deltaOffset / (old?.startSize ?? 0),
352
362
  -0.999999
@@ -126,13 +126,13 @@ export interface RowSelectionInstance<TData extends RowData> {
126
126
  */
127
127
  getIsAllRowsSelected: () => boolean
128
128
  /**
129
- * Returns whether or not all rows on the current page are selected.
129
+ * Returns whether or not any rows on the current page are selected.
130
130
  * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomepagerowsselected)
131
131
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
132
132
  */
133
133
  getIsSomePageRowsSelected: () => boolean
134
134
  /**
135
- * Returns whether or not all rows in the table are selected.
135
+ * Returns whether or not any rows in the table are selected.
136
136
  * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomerowsselected)
137
137
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)
138
138
  */
package/src/types.ts CHANGED
@@ -200,12 +200,12 @@ export type StringOrTemplateHeader<TData, TValue> =
200
200
  | string
201
201
  | ColumnDefTemplate<HeaderContext<TData, TValue>>
202
202
 
203
- interface StringHeaderIdentifier {
203
+ export interface StringHeaderIdentifier {
204
204
  header: string
205
205
  id?: string
206
206
  }
207
207
 
208
- interface IdIdentifier<TData extends RowData, TValue> {
208
+ export interface IdIdentifier<TData extends RowData, TValue> {
209
209
  id: string
210
210
  header?: StringOrTemplateHeader<TData, TValue>
211
211
  }
@@ -265,7 +265,7 @@ export type AccessorFnColumnDef<
265
265
  TValue = unknown,
266
266
  > = AccessorFnColumnDefBase<TData, TValue> & ColumnIdentifiers<TData, TValue>
267
267
 
268
- interface AccessorKeyColumnDefBase<TData extends RowData, TValue = unknown>
268
+ export interface AccessorKeyColumnDefBase<TData extends RowData, TValue = unknown>
269
269
  extends ColumnDefBase<TData, TValue> {
270
270
  id?: string
271
271
  accessorKey: (string & {}) | keyof TData