@tanstack/table-core 9.0.0-beta.43 → 9.0.0-beta.44
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/core/rows/coreRowsFeature.types.d.cts +12 -1
- package/dist/core/rows/coreRowsFeature.types.d.ts +12 -1
- package/dist/core/table/constructTable.cjs +1 -0
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.js +1 -0
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +2 -1
- package/dist/core/table/coreTablesFeature.types.d.ts +2 -1
- package/dist/core/table/coreTablesFeature.utils.cjs +4 -1
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +2 -1
- package/dist/core/table/coreTablesFeature.utils.d.ts +2 -1
- package/dist/core/table/coreTablesFeature.utils.js +4 -1
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.cjs +13 -2
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.js +13 -2
- package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +35 -5
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +35 -5
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +50 -3
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +8 -6
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +8 -6
- package/dist/features/row-selection/rowSelectionFeature.utils.js +50 -3
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/types/TableFeatures.d.cts +22 -2
- package/dist/types/TableFeatures.d.ts +22 -2
- package/package.json +1 -1
- package/skills/api-not-found/SKILL.md +1 -1
- package/skills/client-vs-server/SKILL.md +1 -1
- package/skills/column-faceting/SKILL.md +1 -1
- package/skills/column-filtering/SKILL.md +1 -1
- package/skills/column-ordering/SKILL.md +1 -1
- package/skills/column-pinning/SKILL.md +1 -1
- package/skills/column-resizing/SKILL.md +1 -1
- package/skills/column-sizing/SKILL.md +1 -1
- package/skills/column-visibility/SKILL.md +1 -1
- package/skills/core/SKILL.md +37 -2
- package/skills/custom-features/SKILL.md +30 -2
- package/skills/expanding/SKILL.md +1 -1
- package/skills/global-filtering/SKILL.md +1 -1
- package/skills/grouping/SKILL.md +1 -1
- package/skills/migrate-v8-to-v9/SKILL.md +1 -1
- package/skills/pagination/SKILL.md +1 -1
- package/skills/row-pinning/SKILL.md +1 -1
- package/skills/row-selection/SKILL.md +91 -3
- package/skills/sorting/SKILL.md +1 -1
- package/skills/table-features/SKILL.md +1 -1
- package/skills/typescript/SKILL.md +1 -1
- package/src/core/rows/coreRowsFeature.types.ts +12 -1
- package/src/core/table/constructTable.ts +4 -0
- package/src/core/table/coreTablesFeature.types.ts +2 -1
- package/src/core/table/coreTablesFeature.utils.ts +7 -1
- package/src/features/row-selection/rowSelectionFeature.ts +19 -1
- package/src/features/row-selection/rowSelectionFeature.types.ts +37 -3
- package/src/features/row-selection/rowSelectionFeature.utils.ts +114 -14
- package/src/types/TableFeatures.ts +32 -2
|
@@ -8,6 +8,15 @@ import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
|
8
8
|
//#region src/core/rows/coreRowsFeature.types.d.ts
|
|
9
9
|
interface Row_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
10
10
|
_cellsCache?: WeakMap<Column<TFeatures, TData, unknown>, Cell<TFeatures, TData, unknown>>;
|
|
11
|
+
/**
|
|
12
|
+
* Internal cache used while resolving the current display order.
|
|
13
|
+
*
|
|
14
|
+
* This value may be stale until display order is recomputed. Use
|
|
15
|
+
* `row.getDisplayIndex()` instead; it refreshes and validates the cached
|
|
16
|
+
* position before returning it.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
11
20
|
_displayIndexCache: number;
|
|
12
21
|
_uniqueValuesCache: Record<string, unknown>;
|
|
13
22
|
_valuesCache: Record<string, unknown>;
|
|
@@ -47,7 +56,9 @@ interface Row_CoreProperties<in out TFeatures extends TableFeatures, in out TDat
|
|
|
47
56
|
interface Row_Row<in out TFeatures extends TableFeatures, in out TData extends RowData> extends Row_CoreProperties<TFeatures, TData> {
|
|
48
57
|
/**
|
|
49
58
|
* Returns the zero-based index of the row in the current display order
|
|
50
|
-
* before pagination, or `-1` if the row is not in that model.
|
|
59
|
+
* before pagination, or `-1` if the row is not in that model. Use this for
|
|
60
|
+
* display row-number columns instead of `row.index` or the internal
|
|
61
|
+
* `_displayIndexCache` field.
|
|
51
62
|
*/
|
|
52
63
|
getDisplayIndex: () => number;
|
|
53
64
|
/**
|
|
@@ -8,6 +8,15 @@ import { TableFeatures } from "../../types/TableFeatures.js";
|
|
|
8
8
|
//#region src/core/rows/coreRowsFeature.types.d.ts
|
|
9
9
|
interface Row_CoreProperties<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
10
10
|
_cellsCache?: WeakMap<Column<TFeatures, TData, unknown>, Cell<TFeatures, TData, unknown>>;
|
|
11
|
+
/**
|
|
12
|
+
* Internal cache used while resolving the current display order.
|
|
13
|
+
*
|
|
14
|
+
* This value may be stale until display order is recomputed. Use
|
|
15
|
+
* `row.getDisplayIndex()` instead; it refreshes and validates the cached
|
|
16
|
+
* position before returning it.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
11
20
|
_displayIndexCache: number;
|
|
12
21
|
_uniqueValuesCache: Record<string, unknown>;
|
|
13
22
|
_valuesCache: Record<string, unknown>;
|
|
@@ -47,7 +56,9 @@ interface Row_CoreProperties<in out TFeatures extends TableFeatures, in out TDat
|
|
|
47
56
|
interface Row_Row<in out TFeatures extends TableFeatures, in out TData extends RowData> extends Row_CoreProperties<TFeatures, TData> {
|
|
48
57
|
/**
|
|
49
58
|
* Returns the zero-based index of the row in the current display order
|
|
50
|
-
* before pagination, or `-1` if the row is not in that model.
|
|
59
|
+
* before pagination, or `-1` if the row is not in that model. Use this for
|
|
60
|
+
* display row-number columns instead of `row.index` or the internal
|
|
61
|
+
* `_displayIndexCache` field.
|
|
51
62
|
*/
|
|
52
63
|
getDisplayIndex: () => number;
|
|
53
64
|
/**
|
|
@@ -95,6 +95,7 @@ function constructTable(tableOptions) {
|
|
|
95
95
|
}
|
|
96
96
|
return snapshot;
|
|
97
97
|
}, { debugName: "table/store" }));
|
|
98
|
+
for (let i = 0; i < featuresList.length; i++) featuresList[i].initTableInstanceData?.(table);
|
|
98
99
|
if (process.env.NODE_ENV === "development" && (tableOptions.debugAll || tableOptions.debugTable)) {
|
|
99
100
|
const features = Object.keys(table._features);
|
|
100
101
|
const rowModels = Object.entries({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructTable.cjs","names":["cloneState","coreFeatures","atomToStore"],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils'\nimport type { Atom } from '@tanstack/store'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState, TableState_All } from '../../types/TableState'\n\n/**\n * Builds the initial table state from registered features and user initial state.\n *\n * Each feature contributes its default state before user-provided `initialState` values are merged in.\n */\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\n/**\n * Constructs a table instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions.features.coreReactivityFeature!\n\n // Strip the non-feature slots: type-only meta slots, row model factories,\n // and row model fn registries all live on the `features` option but are not\n // table features themselves.\n const {\n aggregationFns,\n columnMeta: _columnMeta,\n coreRowModel,\n expandedRowModel,\n facetedMinMaxValues,\n facetedRowModel,\n facetedUniqueValues,\n filterFns,\n filterMeta: _filterMeta,\n filteredRowModel,\n groupedRowModel,\n paginatedRowModel,\n sortFns,\n sortedRowModel,\n tableMeta: _tableMeta,\n ...features\n } = tableOptions.features\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...features },\n _rowModels: {},\n _rowModelFns: { aggregationFns, filterFns, sortFns },\n baseAtoms: {},\n atoms: {},\n } as unknown as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n const mergedOptions = { ...defaultOptions, ...tableOptions }\n\n if (_reactivity.wrapExternalAtoms && mergedOptions.atoms) {\n for (const [atomKey, _atom] of Object.entries(mergedOptions.atoms)) {\n const atom = _atom as Atom<any>\n const wrappedAtom = _reactivity.createWritableAtom(atom.get(), {\n debugName: `externalAtom/${atomKey}`,\n })\n ;(mergedOptions.atoms as any)[atomKey] = wrappedAtom\n // Two-way syncing between the original atom and the wrapped one.\n let syncExternal = false\n const syncAtomToWrappedSub = atom.subscribe((value) => {\n if (syncExternal) return\n wrappedAtom.set(value)\n })\n const syncWrappedToAtomSub = wrappedAtom.subscribe((value) => {\n syncExternal = true\n atom.set(value)\n syncExternal = false\n })\n _reactivity.addSubscription(syncAtomToWrappedSub)\n _reactivity.addSubscription(syncWrappedToAtomSub)\n }\n }\n\n if (_reactivity.createOptionsStore) {\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >(mergedOptions, { debugName: 'table/optionsStore' })\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get() {\n return table.optionsStore!.get()\n },\n set(value) {\n table.optionsStore!.set(() => value) // or your real update shape\n },\n })\n } else {\n table.options = mergedOptions\n }\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState_All\n >\n\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read either external atom or base atom\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n const externalAtoms = table.options.atoms as\n | Partial<Record<keyof TableState_All, Atom<unknown>>>\n | undefined\n const externalAtom = externalAtoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key]!.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table_syncExternalStateToBaseAtoms(table)\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures> & TableState_All\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n ;(snapshot as Record<string, unknown>)[key] = table.atoms[key]!.get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.entries({\n coreRowModel,\n filteredRowModel,\n groupedRowModel,\n sortedRowModel,\n expandedRowModel,\n paginatedRowModel,\n facetedRowModel,\n facetedMinMaxValues,\n facetedUniqueValues,\n })\n .filter(([, factory]) => factory)\n .map(([key]) => key)\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}\\n`,\n { table },\n )\n }\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.constructTableAPIs?.(table)\n }\n\n return table as unknown as Table<TFeatures, TData>\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,qBACd,UACA,eAA2D,CAAC,GACrC;CACvB,OAAO,OAAO,QAAQ,CAAC,CAAC,SAAS,YAAY;EAC3C,eAAe,QAAQ,kBAAkB,YAAY,KAAK;CAC5D,CAAC;CACD,OAAOA,yBAAW,YAAY;AAChC;;;;;;AAOA,SAAgB,eAGd,cAAuE;CACvE,MAAM,cAAc,aAAa,SAAS;CAK1C,MAAM,EACJ,gBACA,YAAY,aACZ,cACA,kBACA,qBACA,iBACA,qBACA,WACA,YAAY,aACZ,kBACA,iBACA,mBACA,SACA,gBACA,WAAW,YACX,GAAG,aACD,aAAa;CAEjB,MAAM,QAAQ;EACZ;EACA,WAAW;GAAE,GAAGC;GAAc,GAAG;EAAS;EAC1C,YAAY,CAAC;EACb,cAAc;GAAE;GAAgB;GAAW;EAAQ;EACnD,WAAW,CAAC;EACZ,OAAO,CAAC;CACV;CAEA,MAAM,eAAoC,OAAO,OAAO,MAAM,SAAS;CAMvE,MAAM,gBAAgB;EAAE,GAJD,aAAa,QAAQ,KAAK,YAAY;GAC3D,OAAO,OAAO,OAAO,KAAK,QAAQ,yBAAyB,KAAK,CAAC;EACnE,GAAG,CAAC,CAEoC;EAAG,GAAG;CAAa;CAE3D,IAAI,YAAY,qBAAqB,cAAc,OACjD,KAAK,MAAM,CAAC,SAAS,UAAU,OAAO,QAAQ,cAAc,KAAK,GAAG;EAClE,MAAM,OAAO;EACb,MAAM,cA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,IAAI,UAAU,QAAQ,KAAK;GACzC,MAAM,MAAM,UAAU;GACrB,AAAC,SAAqC,OAAO,MAAM,MAAM,IAAI,CAAE,IAAI;EACtE;EACA,OAAO;CACT,GACA,EAAE,WAAW,cAAc,CAC7B,CACF;CAEA,IACE,QAAQ,IAAI,aAAa,kBACxB,aAAa,YAAY,aAAa,aACvC;EACA,MAAM,WAAW,OAAO,KAAK,MAAM,SAAS;EAC5C,MAAM,YAAY,OAAO,QAAQ;GAC/B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,CAAC,CACC,QAAQ,GAAG,aAAa,OAAO,CAAC,CAChC,KAAK,CAAC,SAAS,GAAG;EACrB,MAAM,SAAS,OAAO,KAAK,MAAM,YAAY;EAE7C,QAAQ,IACN;;gBAEU,SAAS,KAAK,kBAAkB,EAAE;;gBAElC,UAAU,SAAS,UAAU,KAAK,kBAAkB,IAAI,SAAS;;gBAEjE,OAAO,KAAK,kBAAkB,EAAE,KAC1C,EAAE,MAAM,CACV;CACF;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,aAAa,EAAE,CAAE,qBAAqB,KAAK;CAG7C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"constructTable.cjs","names":["cloneState","coreFeatures","atomToStore"],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils'\nimport type { Atom } from '@tanstack/store'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState, TableState_All } from '../../types/TableState'\n\n/**\n * Builds the initial table state from registered features and user initial state.\n *\n * Each feature contributes its default state before user-provided `initialState` values are merged in.\n */\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\n/**\n * Constructs a table instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions.features.coreReactivityFeature!\n\n // Strip the non-feature slots: type-only meta slots, row model factories,\n // and row model fn registries all live on the `features` option but are not\n // table features themselves.\n const {\n aggregationFns,\n columnMeta: _columnMeta,\n coreRowModel,\n expandedRowModel,\n facetedMinMaxValues,\n facetedRowModel,\n facetedUniqueValues,\n filterFns,\n filterMeta: _filterMeta,\n filteredRowModel,\n groupedRowModel,\n paginatedRowModel,\n sortFns,\n sortedRowModel,\n tableMeta: _tableMeta,\n ...features\n } = tableOptions.features\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...features },\n _rowModels: {},\n _rowModelFns: { aggregationFns, filterFns, sortFns },\n baseAtoms: {},\n atoms: {},\n } as unknown as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n const mergedOptions = { ...defaultOptions, ...tableOptions }\n\n if (_reactivity.wrapExternalAtoms && mergedOptions.atoms) {\n for (const [atomKey, _atom] of Object.entries(mergedOptions.atoms)) {\n const atom = _atom as Atom<any>\n const wrappedAtom = _reactivity.createWritableAtom(atom.get(), {\n debugName: `externalAtom/${atomKey}`,\n })\n ;(mergedOptions.atoms as any)[atomKey] = wrappedAtom\n // Two-way syncing between the original atom and the wrapped one.\n let syncExternal = false\n const syncAtomToWrappedSub = atom.subscribe((value) => {\n if (syncExternal) return\n wrappedAtom.set(value)\n })\n const syncWrappedToAtomSub = wrappedAtom.subscribe((value) => {\n syncExternal = true\n atom.set(value)\n syncExternal = false\n })\n _reactivity.addSubscription(syncAtomToWrappedSub)\n _reactivity.addSubscription(syncWrappedToAtomSub)\n }\n }\n\n if (_reactivity.createOptionsStore) {\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >(mergedOptions, { debugName: 'table/optionsStore' })\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get() {\n return table.optionsStore!.get()\n },\n set(value) {\n table.optionsStore!.set(() => value) // or your real update shape\n },\n })\n } else {\n table.options = mergedOptions\n }\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState_All\n >\n\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read either external atom or base atom\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n const externalAtoms = table.options.atoms as\n | Partial<Record<keyof TableState_All, Atom<unknown>>>\n | undefined\n const externalAtom = externalAtoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key]!.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table_syncExternalStateToBaseAtoms(table)\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures> & TableState_All\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n ;(snapshot as Record<string, unknown>)[key] = table.atoms[key]!.get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.initTableInstanceData?.(table)\n }\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.entries({\n coreRowModel,\n filteredRowModel,\n groupedRowModel,\n sortedRowModel,\n expandedRowModel,\n paginatedRowModel,\n facetedRowModel,\n facetedMinMaxValues,\n facetedUniqueValues,\n })\n .filter(([, factory]) => factory)\n .map(([key]) => key)\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}\\n`,\n { table },\n )\n }\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.constructTableAPIs?.(table)\n }\n\n return table as unknown as Table<TFeatures, TData>\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,qBACd,UACA,eAA2D,CAAC,GACrC;CACvB,OAAO,OAAO,QAAQ,CAAC,CAAC,SAAS,YAAY;EAC3C,eAAe,QAAQ,kBAAkB,YAAY,KAAK;CAC5D,CAAC;CACD,OAAOA,yBAAW,YAAY;AAChC;;;;;;AAOA,SAAgB,eAGd,cAAuE;CACvE,MAAM,cAAc,aAAa,SAAS;CAK1C,MAAM,EACJ,gBACA,YAAY,aACZ,cACA,kBACA,qBACA,iBACA,qBACA,WACA,YAAY,aACZ,kBACA,iBACA,mBACA,SACA,gBACA,WAAW,YACX,GAAG,aACD,aAAa;CAEjB,MAAM,QAAQ;EACZ;EACA,WAAW;GAAE,GAAGC;GAAc,GAAG;EAAS;EAC1C,YAAY,CAAC;EACb,cAAc;GAAE;GAAgB;GAAW;EAAQ;EACnD,WAAW,CAAC;EACZ,OAAO,CAAC;CACV;CAEA,MAAM,eAAoC,OAAO,OAAO,MAAM,SAAS;CAMvE,MAAM,gBAAgB;EAAE,GAJD,aAAa,QAAQ,KAAK,YAAY;GAC3D,OAAO,OAAO,OAAO,KAAK,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;GAE1B,OAAO,MAAM,UAAU,IAAI,CAAE,IAAI;EACnC,GACA,EAAE,WAAW,eAAe,MAAM,CACpC;CACF;CAEA,mEAAmC,KAAK;CAExC,MAAM,QAAQC,gDACZ,YAAY,yBACJ;EACJ,MAAM,WAAW,CAAC;EAClB,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;GACzC,MAAM,MAAM,UAAU;GACrB,AAAC,SAAqC,OAAO,MAAM,MAAM,IAAI,CAAE,IAAI;EACtE;EACA,OAAO;CACT,GACA,EAAE,WAAW,cAAc,CAC7B,CACF;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,aAAa,EAAE,CAAE,wBAAwB,KAAK;CAGhD,IACE,QAAQ,IAAI,aAAa,kBACxB,aAAa,YAAY,aAAa,aACvC;EACA,MAAM,WAAW,OAAO,KAAK,MAAM,SAAS;EAC5C,MAAM,YAAY,OAAO,QAAQ;GAC/B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,CAAC,CACC,QAAQ,GAAG,aAAa,OAAO,CAAC,CAChC,KAAK,CAAC,SAAS,GAAG;EACrB,MAAM,SAAS,OAAO,KAAK,MAAM,YAAY;EAE7C,QAAQ,IACN;;gBAEU,SAAS,KAAK,kBAAkB,EAAE;;gBAElC,UAAU,SAAS,UAAU,KAAK,kBAAkB,IAAI,SAAS;;gBAEjE,OAAO,KAAK,kBAAkB,EAAE,KAC1C,EAAE,MAAM,CACV;CACF;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,aAAa,EAAE,CAAE,qBAAqB,KAAK;CAG7C,OAAO;AACT"}
|
|
@@ -95,6 +95,7 @@ function constructTable(tableOptions) {
|
|
|
95
95
|
}
|
|
96
96
|
return snapshot;
|
|
97
97
|
}, { debugName: "table/store" }));
|
|
98
|
+
for (let i = 0; i < featuresList.length; i++) featuresList[i].initTableInstanceData?.(table);
|
|
98
99
|
if (process.env.NODE_ENV === "development" && (tableOptions.debugAll || tableOptions.debugTable)) {
|
|
99
100
|
const features = Object.keys(table._features);
|
|
100
101
|
const rowModels = Object.entries({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructTable.js","names":[],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils'\nimport type { Atom } from '@tanstack/store'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState, TableState_All } from '../../types/TableState'\n\n/**\n * Builds the initial table state from registered features and user initial state.\n *\n * Each feature contributes its default state before user-provided `initialState` values are merged in.\n */\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\n/**\n * Constructs a table instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions.features.coreReactivityFeature!\n\n // Strip the non-feature slots: type-only meta slots, row model factories,\n // and row model fn registries all live on the `features` option but are not\n // table features themselves.\n const {\n aggregationFns,\n columnMeta: _columnMeta,\n coreRowModel,\n expandedRowModel,\n facetedMinMaxValues,\n facetedRowModel,\n facetedUniqueValues,\n filterFns,\n filterMeta: _filterMeta,\n filteredRowModel,\n groupedRowModel,\n paginatedRowModel,\n sortFns,\n sortedRowModel,\n tableMeta: _tableMeta,\n ...features\n } = tableOptions.features\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...features },\n _rowModels: {},\n _rowModelFns: { aggregationFns, filterFns, sortFns },\n baseAtoms: {},\n atoms: {},\n } as unknown as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n const mergedOptions = { ...defaultOptions, ...tableOptions }\n\n if (_reactivity.wrapExternalAtoms && mergedOptions.atoms) {\n for (const [atomKey, _atom] of Object.entries(mergedOptions.atoms)) {\n const atom = _atom as Atom<any>\n const wrappedAtom = _reactivity.createWritableAtom(atom.get(), {\n debugName: `externalAtom/${atomKey}`,\n })\n ;(mergedOptions.atoms as any)[atomKey] = wrappedAtom\n // Two-way syncing between the original atom and the wrapped one.\n let syncExternal = false\n const syncAtomToWrappedSub = atom.subscribe((value) => {\n if (syncExternal) return\n wrappedAtom.set(value)\n })\n const syncWrappedToAtomSub = wrappedAtom.subscribe((value) => {\n syncExternal = true\n atom.set(value)\n syncExternal = false\n })\n _reactivity.addSubscription(syncAtomToWrappedSub)\n _reactivity.addSubscription(syncWrappedToAtomSub)\n }\n }\n\n if (_reactivity.createOptionsStore) {\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >(mergedOptions, { debugName: 'table/optionsStore' })\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get() {\n return table.optionsStore!.get()\n },\n set(value) {\n table.optionsStore!.set(() => value) // or your real update shape\n },\n })\n } else {\n table.options = mergedOptions\n }\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState_All\n >\n\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read either external atom or base atom\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n const externalAtoms = table.options.atoms as\n | Partial<Record<keyof TableState_All, Atom<unknown>>>\n | undefined\n const externalAtom = externalAtoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key]!.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table_syncExternalStateToBaseAtoms(table)\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures> & TableState_All\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n ;(snapshot as Record<string, unknown>)[key] = table.atoms[key]!.get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.entries({\n coreRowModel,\n filteredRowModel,\n groupedRowModel,\n sortedRowModel,\n expandedRowModel,\n paginatedRowModel,\n facetedRowModel,\n facetedMinMaxValues,\n facetedUniqueValues,\n })\n .filter(([, factory]) => factory)\n .map(([key]) => key)\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}\\n`,\n { table },\n )\n }\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.constructTableAPIs?.(table)\n }\n\n return table as unknown as Table<TFeatures, TData>\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,qBACd,UACA,eAA2D,CAAC,GACrC;CACvB,OAAO,OAAO,QAAQ,CAAC,CAAC,SAAS,YAAY;EAC3C,eAAe,QAAQ,kBAAkB,YAAY,KAAK;CAC5D,CAAC;CACD,OAAO,WAA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,EAAE;;gBAElC,UAAU,SAAS,UAAU,KAAK,kBAAkB,IAAI,SAAS;;gBAEjE,OAAO,KAAK,kBAAkB,EAAE,KAC1C,EAAE,MAAM,CACV;CACF;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,aAAa,EAAE,CAAE,qBAAqB,KAAK;CAG7C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"constructTable.js","names":[],"sources":["../../../src/core/table/constructTable.ts"],"sourcesContent":["import { coreFeatures } from '../coreFeatures'\nimport { cloneState } from '../../utils'\nimport { atomToStore } from '../reactivity/coreReactivityFeature.utils'\nimport { table_syncExternalStateToBaseAtoms } from './coreTablesFeature.utils'\nimport type { Atom } from '@tanstack/store'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\nimport type { TableState, TableState_All } from '../../types/TableState'\n\n/**\n * Builds the initial table state from registered features and user initial state.\n *\n * Each feature contributes its default state before user-provided `initialState` values are merged in.\n */\nexport function getInitialTableState<TFeatures extends TableFeatures>(\n features: TFeatures,\n initialState: Partial<TableState<TFeatures>> | undefined = {},\n): TableState<TFeatures> {\n Object.values(features).forEach((feature) => {\n initialState = feature.getInitialState?.(initialState) ?? initialState\n })\n return cloneState(initialState) as TableState<TFeatures>\n}\n\n/**\n * Constructs a table instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(tableOptions: TableOptions<TFeatures, TData>): Table<TFeatures, TData> {\n const _reactivity = tableOptions.features.coreReactivityFeature!\n\n // Strip the non-feature slots: type-only meta slots, row model factories,\n // and row model fn registries all live on the `features` option but are not\n // table features themselves.\n const {\n aggregationFns,\n columnMeta: _columnMeta,\n coreRowModel,\n expandedRowModel,\n facetedMinMaxValues,\n facetedRowModel,\n facetedUniqueValues,\n filterFns,\n filterMeta: _filterMeta,\n filteredRowModel,\n groupedRowModel,\n paginatedRowModel,\n sortFns,\n sortedRowModel,\n tableMeta: _tableMeta,\n ...features\n } = tableOptions.features\n\n const table = {\n _reactivity,\n _features: { ...coreFeatures, ...features },\n _rowModels: {},\n _rowModelFns: { aggregationFns, filterFns, sortFns },\n baseAtoms: {},\n atoms: {},\n } as unknown as Table_Internal<TFeatures, TData>\n\n const featuresList: Array<TableFeature> = Object.values(table._features)\n\n const defaultOptions = featuresList.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultTableOptions?.(table))\n }, {}) as TableOptions<TFeatures, TData>\n\n const mergedOptions = { ...defaultOptions, ...tableOptions }\n\n if (_reactivity.wrapExternalAtoms && mergedOptions.atoms) {\n for (const [atomKey, _atom] of Object.entries(mergedOptions.atoms)) {\n const atom = _atom as Atom<any>\n const wrappedAtom = _reactivity.createWritableAtom(atom.get(), {\n debugName: `externalAtom/${atomKey}`,\n })\n ;(mergedOptions.atoms as any)[atomKey] = wrappedAtom\n // Two-way syncing between the original atom and the wrapped one.\n let syncExternal = false\n const syncAtomToWrappedSub = atom.subscribe((value) => {\n if (syncExternal) return\n wrappedAtom.set(value)\n })\n const syncWrappedToAtomSub = wrappedAtom.subscribe((value) => {\n syncExternal = true\n atom.set(value)\n syncExternal = false\n })\n _reactivity.addSubscription(syncAtomToWrappedSub)\n _reactivity.addSubscription(syncWrappedToAtomSub)\n }\n }\n\n if (_reactivity.createOptionsStore) {\n // @ts-ignore - direct set\n table.optionsStore = _reactivity.createWritableAtom<\n TableOptions<TFeatures, TData>\n >(mergedOptions, { debugName: 'table/optionsStore' })\n Object.defineProperty(table, 'options', {\n configurable: true,\n enumerable: true,\n get() {\n return table.optionsStore!.get()\n },\n set(value) {\n table.optionsStore!.set(() => value) // or your real update shape\n },\n })\n } else {\n table.options = mergedOptions\n }\n\n table.initialState = getInitialTableState(\n table._features,\n table.options.initialState,\n )\n\n const stateKeys = Object.keys(table.initialState) as Array<\n string & keyof TableState_All\n >\n\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n table.baseAtoms[key] = _reactivity.createWritableAtom(\n table.initialState[key],\n {\n debugName: `table/baseAtoms/${key}`,\n },\n ) as any\n\n // create readonly derived atom: on each get(), read either external atom or base atom\n ;(table.atoms as any)[key] = _reactivity.createReadonlyAtom(\n () => {\n const externalAtoms = table.options.atoms as\n | Partial<Record<keyof TableState_All, Atom<unknown>>>\n | undefined\n const externalAtom = externalAtoms?.[key]\n if (externalAtom) {\n return externalAtom.get()\n }\n return table.baseAtoms[key]!.get()\n },\n { debugName: `table/atoms/${key}` },\n )\n }\n\n table_syncExternalStateToBaseAtoms(table)\n\n table.store = atomToStore(\n _reactivity.createReadonlyAtom(\n () => {\n const snapshot = {} as TableState<TFeatures> & TableState_All\n for (let i = 0; i < stateKeys.length; i++) {\n const key = stateKeys[i]!\n ;(snapshot as Record<string, unknown>)[key] = table.atoms[key]!.get()\n }\n return snapshot\n },\n { debugName: 'table/store' },\n ),\n )\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.initTableInstanceData?.(table)\n }\n\n if (\n process.env.NODE_ENV === 'development' &&\n (tableOptions.debugAll || tableOptions.debugTable)\n ) {\n const features = Object.keys(table._features)\n const rowModels = Object.entries({\n coreRowModel,\n filteredRowModel,\n groupedRowModel,\n sortedRowModel,\n expandedRowModel,\n paginatedRowModel,\n facetedRowModel,\n facetedMinMaxValues,\n facetedUniqueValues,\n })\n .filter(([, factory]) => factory)\n .map(([key]) => key)\n const states = Object.keys(table.initialState)\n\n console.log(\n `Constructing Table Instance\n\n Features: ${features.join('\\n ')}\n\n Row Models: ${rowModels.length ? rowModels.join('\\n ') : '(none)'}\n\n States: ${states.join('\\n ')}\\n`,\n { table },\n )\n }\n\n for (let i = 0; i < featuresList.length; i++) {\n featuresList[i]!.constructTableAPIs?.(table)\n }\n\n return table as unknown as Table<TFeatures, TData>\n}\n"],"mappings":";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,MAAM,SAAS;EAC5C,MAAM,YAAY,OAAO,QAAQ;GAC/B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,CAAC,CACC,QAAQ,GAAG,aAAa,OAAO,CAAC,CAChC,KAAK,CAAC,SAAS,GAAG;EACrB,MAAM,SAAS,OAAO,KAAK,MAAM,YAAY;EAE7C,QAAQ,IACN;;gBAEU,SAAS,KAAK,kBAAkB,EAAE;;gBAElC,UAAU,SAAS,UAAU,KAAK,kBAAkB,IAAI,SAAS;;gBAEjE,OAAO,KAAK,kBAAkB,EAAE,KAC1C,EAAE,MAAM,CACV;CACF;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,aAAa,EAAE,CAAE,qBAAqB,KAAK;CAG7C,OAAO;AACT"}
|
|
@@ -184,7 +184,8 @@ interface Table_Table<in out TFeatures extends TableFeatures, in out TData exten
|
|
|
184
184
|
*
|
|
185
185
|
* Prefer feature-specific reset APIs, such as `resetPagination`, when a state
|
|
186
186
|
* slice may be owned by an external atom or needs that feature's blank/default
|
|
187
|
-
* reset behavior.
|
|
187
|
+
* reset behavior. After resetting internal atoms, this also invokes feature
|
|
188
|
+
* reset hooks for mutable, transient table-instance data.
|
|
188
189
|
*/
|
|
189
190
|
reset: () => void;
|
|
190
191
|
/**
|
|
@@ -184,7 +184,8 @@ interface Table_Table<in out TFeatures extends TableFeatures, in out TData exten
|
|
|
184
184
|
*
|
|
185
185
|
* Prefer feature-specific reset APIs, such as `resetPagination`, when a state
|
|
186
186
|
* slice may be owned by an external atom or needs that feature's blank/default
|
|
187
|
-
* reset behavior.
|
|
187
|
+
* reset behavior. After resetting internal atoms, this also invokes feature
|
|
188
|
+
* reset hooks for mutable, transient table-instance data.
|
|
188
189
|
*/
|
|
189
190
|
reset: () => void;
|
|
190
191
|
/**
|
|
@@ -25,7 +25,8 @@ function table_syncExternalStateToBaseAtoms(table) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Resets all internal table base atoms to `table.initialState
|
|
28
|
+
* Resets all internal table base atoms to `table.initialState`, then clears
|
|
29
|
+
* transient instance data through registered feature reset hooks.
|
|
29
30
|
*
|
|
30
31
|
* This resets internally owned state slices in a single reactivity batch. Use
|
|
31
32
|
* feature-specific reset APIs when a slice may be externally owned.
|
|
@@ -44,6 +45,8 @@ function table_reset(table) {
|
|
|
44
45
|
table.baseAtoms[key].set(snap[key]);
|
|
45
46
|
}
|
|
46
47
|
});
|
|
48
|
+
const features = Object.values(table._features);
|
|
49
|
+
for (let i = 0; i < features.length; i++) features[i].resetTableInstanceData?.(table);
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* Merges new table options with the current resolved options.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreTablesFeature.utils.cjs","names":["cloneState","functionalUpdate"],"sources":["../../../src/core/table/coreTablesFeature.utils.ts"],"sourcesContent":["import { cloneState, functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\n\n/**\n * Synchronizes externally controlled state slices into the table's base atoms.\n *\n * This keeps legacy `options.state` values reflected in the atom graph so\n * derived atoms, stores, and table APIs read a consistent snapshot.\n *\n * @example\n * ```ts\n * table_syncExternalStateToBaseAtoms(table)\n * ```\n */\nexport function table_syncExternalStateToBaseAtoms<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n const state = table.options.state\n if (!state) {\n return\n }\n\n table._reactivity.batch(() => {\n for (const key in state) {\n const baseAtom = (table.baseAtoms as Record<string, any>)[key]\n if (!baseAtom) {\n continue\n }\n\n const externalState = state[key as keyof typeof state]\n if (externalState !== table._reactivity.untrack(() => baseAtom.get())) {\n baseAtom.set(() => externalState)\n }\n }\n })\n}\n\n/**\n * Resets all internal table base atoms to `table.initialState
|
|
1
|
+
{"version":3,"file":"coreTablesFeature.utils.cjs","names":["cloneState","functionalUpdate"],"sources":["../../../src/core/table/coreTablesFeature.utils.ts"],"sourcesContent":["import { cloneState, functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\n\n/**\n * Synchronizes externally controlled state slices into the table's base atoms.\n *\n * This keeps legacy `options.state` values reflected in the atom graph so\n * derived atoms, stores, and table APIs read a consistent snapshot.\n *\n * @example\n * ```ts\n * table_syncExternalStateToBaseAtoms(table)\n * ```\n */\nexport function table_syncExternalStateToBaseAtoms<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n const state = table.options.state\n if (!state) {\n return\n }\n\n table._reactivity.batch(() => {\n for (const key in state) {\n const baseAtom = (table.baseAtoms as Record<string, any>)[key]\n if (!baseAtom) {\n continue\n }\n\n const externalState = state[key as keyof typeof state]\n if (externalState !== table._reactivity.untrack(() => baseAtom.get())) {\n baseAtom.set(() => externalState)\n }\n }\n })\n}\n\n/**\n * Resets all internal table base atoms to `table.initialState`, then clears\n * transient instance data through registered feature reset hooks.\n *\n * This resets internally owned state slices in a single reactivity batch. Use\n * feature-specific reset APIs when a slice may be externally owned.\n *\n * @example\n * ```ts\n * table_reset(table)\n * ```\n */\nexport function table_reset<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n const snap = cloneState(table.initialState)\n table._reactivity.batch(() => {\n const keys = Object.keys(snap) as Array<keyof typeof snap>\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n ;(table.baseAtoms as any)[key].set(snap[key])\n }\n })\n\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.resetTableInstanceData?.(table)\n }\n}\n\n/**\n * Merges new table options with the current resolved options.\n *\n * If `options.mergeOptions` is provided, it owns the merge behavior; otherwise\n * options are shallow-merged. Static options that should never change after\n * initialization are restored on a fresh object so framework merge helpers may\n * return readonly getter/proxy objects.\n *\n * @example\n * ```ts\n * const options = table_mergeOptions(table, nextOptions)\n * ```\n */\nexport function table_mergeOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n newOptions: TableOptions<TFeatures, TData>,\n) {\n const { features, atoms, initialState } = table.options\n\n // simple merge if no mergeOptions is provided - performant\n if (!table.options.mergeOptions) {\n return {\n ...table.options,\n ...newOptions,\n features,\n atoms,\n initialState,\n }\n }\n\n // else use the mergeOptions function and preserve getters/setters\n const mergedOptions = table.options.mergeOptions(\n table.options as TableOptions<TFeatures, TData>,\n newOptions,\n )\n const descriptors: PropertyDescriptorMap = {\n ...Object.getOwnPropertyDescriptors(mergedOptions),\n }\n\n return Object.defineProperties(\n Object.create(Object.getPrototypeOf(mergedOptions)),\n {\n ...descriptors,\n features: {\n value: features,\n enumerable: true,\n configurable: true,\n writable: true,\n },\n atoms: {\n value: atoms,\n enumerable: true,\n configurable: true,\n writable: true,\n },\n initialState: {\n value: initialState,\n enumerable: true,\n configurable: true,\n writable: true,\n },\n },\n ) as TableOptions<TFeatures, TData>\n}\n\n/**\n * Updates the table options object.\n *\n * The updater receives the current resolved options and the merged result is\n * immediately assigned to the table instance.\n *\n * @example\n * ```ts\n * table_setOptions(table, (old) => old)\n * ```\n */\nexport function table_setOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<TableOptions<TFeatures, TData>>,\n): void {\n const newOptions = functionalUpdate(\n updater,\n table.options as TableOptions<TFeatures, TData>,\n )\n const mergedOptions = table_mergeOptions(table, newOptions)\n\n if (table.optionsStore) {\n table.optionsStore.set(() => mergedOptions)\n } else {\n table.options = mergedOptions\n }\n table_syncExternalStateToBaseAtoms(table)\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,S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d,UAAU;EACZ;EACA,cAAc;GACZ,OAAO;GACP,YAAY;GACZ,cAAc;GACd,UAAU;EACZ;CACF,CACF;AACF;;;;;;;;;;;;AAaA,SAAgB,iBAId,OACA,SACM;CAKN,MAAM,gBAAgB,mBAAmB,OAJtBC,+BACjB,SACA,MAAM,OAEiD,CAAC;CAE1D,IAAI,MAAM,cACR,MAAM,aAAa,UAAU,aAAa;MAE1C,MAAM,UAAU;CAElB,mCAAmC,KAAK;AAC1C"}
|
|
@@ -17,7 +17,8 @@ import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
|
17
17
|
*/
|
|
18
18
|
declare function table_syncExternalStateToBaseAtoms<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
|
|
19
19
|
/**
|
|
20
|
-
* Resets all internal table base atoms to `table.initialState
|
|
20
|
+
* Resets all internal table base atoms to `table.initialState`, then clears
|
|
21
|
+
* transient instance data through registered feature reset hooks.
|
|
21
22
|
*
|
|
22
23
|
* This resets internally owned state slices in a single reactivity batch. Use
|
|
23
24
|
* feature-specific reset APIs when a slice may be externally owned.
|
|
@@ -17,7 +17,8 @@ import { TableFeatures } from "../../types/TableFeatures.js";
|
|
|
17
17
|
*/
|
|
18
18
|
declare function table_syncExternalStateToBaseAtoms<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): void;
|
|
19
19
|
/**
|
|
20
|
-
* Resets all internal table base atoms to `table.initialState
|
|
20
|
+
* Resets all internal table base atoms to `table.initialState`, then clears
|
|
21
|
+
* transient instance data through registered feature reset hooks.
|
|
21
22
|
*
|
|
22
23
|
* This resets internally owned state slices in a single reactivity batch. Use
|
|
23
24
|
* feature-specific reset APIs when a slice may be externally owned.
|
|
@@ -25,7 +25,8 @@ function table_syncExternalStateToBaseAtoms(table) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Resets all internal table base atoms to `table.initialState
|
|
28
|
+
* Resets all internal table base atoms to `table.initialState`, then clears
|
|
29
|
+
* transient instance data through registered feature reset hooks.
|
|
29
30
|
*
|
|
30
31
|
* This resets internally owned state slices in a single reactivity batch. Use
|
|
31
32
|
* feature-specific reset APIs when a slice may be externally owned.
|
|
@@ -44,6 +45,8 @@ function table_reset(table) {
|
|
|
44
45
|
table.baseAtoms[key].set(snap[key]);
|
|
45
46
|
}
|
|
46
47
|
});
|
|
48
|
+
const features = Object.values(table._features);
|
|
49
|
+
for (let i = 0; i < features.length; i++) features[i].resetTableInstanceData?.(table);
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* Merges new table options with the current resolved options.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreTablesFeature.utils.js","names":[],"sources":["../../../src/core/table/coreTablesFeature.utils.ts"],"sourcesContent":["import { cloneState, functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\n\n/**\n * Synchronizes externally controlled state slices into the table's base atoms.\n *\n * This keeps legacy `options.state` values reflected in the atom graph so\n * derived atoms, stores, and table APIs read a consistent snapshot.\n *\n * @example\n * ```ts\n * table_syncExternalStateToBaseAtoms(table)\n * ```\n */\nexport function table_syncExternalStateToBaseAtoms<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n const state = table.options.state\n if (!state) {\n return\n }\n\n table._reactivity.batch(() => {\n for (const key in state) {\n const baseAtom = (table.baseAtoms as Record<string, any>)[key]\n if (!baseAtom) {\n continue\n }\n\n const externalState = state[key as keyof typeof state]\n if (externalState !== table._reactivity.untrack(() => baseAtom.get())) {\n baseAtom.set(() => externalState)\n }\n }\n })\n}\n\n/**\n * Resets all internal table base atoms to `table.initialState
|
|
1
|
+
{"version":3,"file":"coreTablesFeature.utils.js","names":[],"sources":["../../../src/core/table/coreTablesFeature.utils.ts"],"sourcesContent":["import { cloneState, functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableOptions } from '../../types/TableOptions'\n\n/**\n * Synchronizes externally controlled state slices into the table's base atoms.\n *\n * This keeps legacy `options.state` values reflected in the atom graph so\n * derived atoms, stores, and table APIs read a consistent snapshot.\n *\n * @example\n * ```ts\n * table_syncExternalStateToBaseAtoms(table)\n * ```\n */\nexport function table_syncExternalStateToBaseAtoms<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n const state = table.options.state\n if (!state) {\n return\n }\n\n table._reactivity.batch(() => {\n for (const key in state) {\n const baseAtom = (table.baseAtoms as Record<string, any>)[key]\n if (!baseAtom) {\n continue\n }\n\n const externalState = state[key as keyof typeof state]\n if (externalState !== table._reactivity.untrack(() => baseAtom.get())) {\n baseAtom.set(() => externalState)\n }\n }\n })\n}\n\n/**\n * Resets all internal table base atoms to `table.initialState`, then clears\n * transient instance data through registered feature reset hooks.\n *\n * This resets internally owned state slices in a single reactivity batch. Use\n * feature-specific reset APIs when a slice may be externally owned.\n *\n * @example\n * ```ts\n * table_reset(table)\n * ```\n */\nexport function table_reset<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): void {\n const snap = cloneState(table.initialState)\n table._reactivity.batch(() => {\n const keys = Object.keys(snap) as Array<keyof typeof snap>\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n ;(table.baseAtoms as any)[key].set(snap[key])\n }\n })\n\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.resetTableInstanceData?.(table)\n }\n}\n\n/**\n * Merges new table options with the current resolved options.\n *\n * If `options.mergeOptions` is provided, it owns the merge behavior; otherwise\n * options are shallow-merged. Static options that should never change after\n * initialization are restored on a fresh object so framework merge helpers may\n * return readonly getter/proxy objects.\n *\n * @example\n * ```ts\n * const options = table_mergeOptions(table, nextOptions)\n * ```\n */\nexport function table_mergeOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n newOptions: TableOptions<TFeatures, TData>,\n) {\n const { features, atoms, initialState } = table.options\n\n // simple merge if no mergeOptions is provided - performant\n if (!table.options.mergeOptions) {\n return {\n ...table.options,\n ...newOptions,\n features,\n atoms,\n initialState,\n }\n }\n\n // else use the mergeOptions function and preserve getters/setters\n const mergedOptions = table.options.mergeOptions(\n table.options as TableOptions<TFeatures, TData>,\n newOptions,\n )\n const descriptors: PropertyDescriptorMap = {\n ...Object.getOwnPropertyDescriptors(mergedOptions),\n }\n\n return Object.defineProperties(\n Object.create(Object.getPrototypeOf(mergedOptions)),\n {\n ...descriptors,\n features: {\n value: features,\n enumerable: true,\n configurable: true,\n writable: true,\n },\n atoms: {\n value: atoms,\n enumerable: true,\n configurable: true,\n writable: true,\n },\n initialState: {\n value: initialState,\n enumerable: true,\n configurable: true,\n writable: true,\n },\n },\n ) as TableOptions<TFeatures, TData>\n}\n\n/**\n * Updates the table options object.\n *\n * The updater receives the current resolved options and the merged result is\n * immediately assigned to the table instance.\n *\n * @example\n * ```ts\n * table_setOptions(table, (old) => old)\n * ```\n */\nexport function table_setOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<TableOptions<TFeatures, TData>>,\n): void {\n const newOptions = functionalUpdate(\n updater,\n table.options as TableOptions<TFeatures, TData>,\n )\n const mergedOptions = table_mergeOptions(table, newOptions)\n\n if (table.optionsStore) {\n table.optionsStore.set(() => mergedOptions)\n } else {\n table.options = mergedOptions\n }\n table_syncExternalStateToBaseAtoms(table)\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAgB,mCAGd,OAA+C;CAC/C,MAAM,QAAQ,MAAM,QAAQ;CAC5B,IAAI,CAAC,OACH;CAGF,MAAM,YAAY,YAAY;EAC5B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SAAgB,iBAId,OACA,SACM;CAKN,MAAM,gBAAgB,mBAAmB,OAJtB,iBACjB,SACA,MAAM,OAEiD,CAAC;CAE1D,IAAI,MAAM,cACR,MAAM,aAAa,UAAU,aAAa;MAE1C,MAAM,UAAU;CAElB,mCAAmC,KAAK;AAC1C"}
|
|
@@ -6,6 +6,12 @@ const require_rowSelectionFeature_utils = require('./rowSelectionFeature.utils.c
|
|
|
6
6
|
* Feature that adds row selection state and APIs for row and page selection.
|
|
7
7
|
*/
|
|
8
8
|
const rowSelectionFeature = {
|
|
9
|
+
initTableInstanceData: (table) => {
|
|
10
|
+
table._lastSelectedRowId = null;
|
|
11
|
+
},
|
|
12
|
+
resetTableInstanceData: (table) => {
|
|
13
|
+
table._lastSelectedRowId = null;
|
|
14
|
+
},
|
|
9
15
|
getInitialState: (initialState) => {
|
|
10
16
|
return {
|
|
11
17
|
rowSelection: require_rowSelectionFeature_utils.getDefaultRowSelectionState(),
|
|
@@ -17,7 +23,12 @@ const rowSelectionFeature = {
|
|
|
17
23
|
onRowSelectionChange: require_utils.makeStateUpdater("rowSelection", table),
|
|
18
24
|
enableRowSelection: true,
|
|
19
25
|
enableMultiRowSelection: true,
|
|
20
|
-
|
|
26
|
+
enableRowRangeSelection: true,
|
|
27
|
+
enableSubRowSelection: true,
|
|
28
|
+
isRowRangeSelectionEvent: (event) => {
|
|
29
|
+
const rangeEvent = event;
|
|
30
|
+
return Boolean(rangeEvent.shiftKey || rangeEvent.nativeEvent?.shiftKey);
|
|
31
|
+
}
|
|
21
32
|
};
|
|
22
33
|
},
|
|
23
34
|
assignRowPrototype: (prototype, table) => {
|
|
@@ -43,7 +54,7 @@ const rowSelectionFeature = {
|
|
|
43
54
|
row_getCanSelect: { fn: (row) => require_rowSelectionFeature_utils.row_getCanSelect(row) },
|
|
44
55
|
row_getCanSelectSubRows: { fn: (row) => require_rowSelectionFeature_utils.row_getCanSelectSubRows(row) },
|
|
45
56
|
row_getCanMultiSelect: { fn: (row) => require_rowSelectionFeature_utils.row_getCanMultiSelect(row) },
|
|
46
|
-
row_getToggleSelectedHandler: { fn: (row) => require_rowSelectionFeature_utils.row_getToggleSelectedHandler(row) }
|
|
57
|
+
row_getToggleSelectedHandler: { fn: (row, opts) => require_rowSelectionFeature_utils.row_getToggleSelectedHandler(row, opts) }
|
|
47
58
|
});
|
|
48
59
|
},
|
|
49
60
|
constructTableAPIs: (table) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rowSelectionFeature.cjs","names":["getDefaultRowSelectionState","makeStateUpdater","row_toggleSelected","row_getIsSelected","row_getIsSomeSelected","row_getIsAllSubRowsSelected","row_getCanSelect","row_getCanSelectSubRows","row_getCanMultiSelect","row_getToggleSelectedHandler","table_setRowSelection","table_resetRowSelection","table_toggleAllRowsSelected","table_toggleAllPageRowsSelected","table_getPreSelectedRowModel","table_getSelectedRowModel","table_getFilteredSelectedRowModel","table_getGroupedSelectedRowModel","table_getSelectedRowIds","table_getIsAllRowsSelected","table_getIsAllPageRowsSelected","table_getIsSomeRowsSelected","table_getIsSomePageRowsSelected","table_getToggleAllRowsSelectedHandler","table_getToggleAllPageRowsSelectedHandler"],"sources":["../../../src/features/row-selection/rowSelectionFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowSelectionState,\n row_getCanMultiSelect,\n row_getCanSelect,\n row_getCanSelectSubRows,\n row_getIsAllSubRowsSelected,\n row_getIsSelected,\n row_getIsSomeSelected,\n row_getToggleSelectedHandler,\n row_toggleSelected,\n table_getFilteredSelectedRowModel,\n table_getGroupedSelectedRowModel,\n table_getIsAllPageRowsSelected,\n table_getIsAllRowsSelected,\n table_getIsSomePageRowsSelected,\n table_getIsSomeRowsSelected,\n table_getPreSelectedRowModel,\n table_getSelectedRowIds,\n table_getSelectedRowModel,\n table_getToggleAllPageRowsSelectedHandler,\n table_getToggleAllRowsSelectedHandler,\n table_resetRowSelection,\n table_setRowSelection,\n table_toggleAllPageRowsSelected,\n table_toggleAllRowsSelected,\n} from './rowSelectionFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds row selection state and APIs for row and page selection.\n */\nexport const rowSelectionFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n rowSelection: getDefaultRowSelectionState(),\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowSelectionFeature', prototype, table, {\n row_toggleSelected: {\n fn: (row, value, opts) => row_toggleSelected(row, value, opts),\n },\n row_getIsSelected: {\n fn: (row) => row_getIsSelected(row),\n },\n row_getIsSomeSelected: {\n fn: (row) => row_getIsSomeSelected(row),\n memoDeps: (row) => [\n row.subRows,\n row.table.atoms.rowSelection?.get(),\n row.table.options.enableRowSelection,\n ],\n },\n row_getIsAllSubRowsSelected: {\n fn: (row) => row_getIsAllSubRowsSelected(row),\n memoDeps: (row) => [\n row.subRows,\n row.table.atoms.rowSelection?.get(),\n row.table.options.enableRowSelection,\n ],\n },\n row_getCanSelect: {\n fn: (row) => row_getCanSelect(row),\n },\n row_getCanSelectSubRows: {\n fn: (row) => row_getCanSelectSubRows(row),\n },\n row_getCanMultiSelect: {\n fn: (row) => row_getCanMultiSelect(row),\n },\n row_getToggleSelectedHandler: {\n fn: (row) => row_getToggleSelectedHandler(row),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowSelectionFeature', table, {\n table_setRowSelection: {\n fn: (updater) => table_setRowSelection(table, updater),\n },\n table_resetRowSelection: {\n fn: (defaultState) => table_resetRowSelection(table, defaultState),\n },\n table_toggleAllRowsSelected: {\n fn: (value, opts) => table_toggleAllRowsSelected(table, value, opts),\n },\n table_toggleAllPageRowsSelected: {\n fn: (value, opts) =>\n table_toggleAllPageRowsSelected(table, value, opts),\n },\n table_getPreSelectedRowModel: {\n fn: () => table_getPreSelectedRowModel(table),\n },\n table_getSelectedRowModel: {\n fn: () => table_getSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getCoreRowModel(),\n ],\n },\n table_getFilteredSelectedRowModel: {\n fn: () => table_getFilteredSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n ],\n },\n table_getGroupedSelectedRowModel: {\n fn: () => table_getGroupedSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getSortedRowModel(),\n ],\n },\n table_getSelectedRowIds: {\n fn: () => table_getSelectedRowIds(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsAllRowsSelected: {\n fn: () => table_getIsAllRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsAllPageRowsSelected: {\n fn: () => table_getIsAllPageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsSomeRowsSelected: {\n fn: () => table_getIsSomeRowsSelected(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsSomePageRowsSelected: {\n fn: () => table_getIsSomePageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getToggleAllRowsSelectedHandler: {\n fn: () => table_getToggleAllRowsSelectedHandler(table),\n },\n table_getToggleAllPageRowsSelectedHandler: {\n fn: () => table_getToggleAllPageRowsSelectedHandler(table),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAoCA,MAAa,sBAAoC;CAC/C,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAcA,8DAA4B;GAC1C,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsBC,+BAAiB,gBAAgB,KAAK;GAC5D,oBAAoB;GACpB,yBAAyB;GACzB,uBAAuB;
|
|
1
|
+
{"version":3,"file":"rowSelectionFeature.cjs","names":["getDefaultRowSelectionState","makeStateUpdater","row_toggleSelected","row_getIsSelected","row_getIsSomeSelected","row_getIsAllSubRowsSelected","row_getCanSelect","row_getCanSelectSubRows","row_getCanMultiSelect","row_getToggleSelectedHandler","table_setRowSelection","table_resetRowSelection","table_toggleAllRowsSelected","table_toggleAllPageRowsSelected","table_getPreSelectedRowModel","table_getSelectedRowModel","table_getFilteredSelectedRowModel","table_getGroupedSelectedRowModel","table_getSelectedRowIds","table_getIsAllRowsSelected","table_getIsAllPageRowsSelected","table_getIsSomeRowsSelected","table_getIsSomePageRowsSelected","table_getToggleAllRowsSelectedHandler","table_getToggleAllPageRowsSelectedHandler"],"sources":["../../../src/features/row-selection/rowSelectionFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowSelectionState,\n row_getCanMultiSelect,\n row_getCanSelect,\n row_getCanSelectSubRows,\n row_getIsAllSubRowsSelected,\n row_getIsSelected,\n row_getIsSomeSelected,\n row_getToggleSelectedHandler,\n row_toggleSelected,\n table_getFilteredSelectedRowModel,\n table_getGroupedSelectedRowModel,\n table_getIsAllPageRowsSelected,\n table_getIsAllRowsSelected,\n table_getIsSomePageRowsSelected,\n table_getIsSomeRowsSelected,\n table_getPreSelectedRowModel,\n table_getSelectedRowIds,\n table_getSelectedRowModel,\n table_getToggleAllPageRowsSelectedHandler,\n table_getToggleAllRowsSelectedHandler,\n table_resetRowSelection,\n table_setRowSelection,\n table_toggleAllPageRowsSelected,\n table_toggleAllRowsSelected,\n} from './rowSelectionFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds row selection state and APIs for row and page selection.\n */\nexport const rowSelectionFeature: TableFeature = {\n initTableInstanceData: (table) => {\n // @ts-ignore - _lastSelectedRowId is row selection table instance data\n table._lastSelectedRowId = null\n },\n\n resetTableInstanceData: (table) => {\n // @ts-ignore - _lastSelectedRowId is row selection table instance data\n table._lastSelectedRowId = null\n },\n\n getInitialState: (initialState) => {\n return {\n rowSelection: getDefaultRowSelectionState(),\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableRowRangeSelection: true,\n enableSubRowSelection: true,\n isRowRangeSelectionEvent: (event) => {\n const rangeEvent = event as {\n shiftKey?: boolean\n nativeEvent?: { shiftKey?: boolean }\n }\n return Boolean(rangeEvent.shiftKey || rangeEvent.nativeEvent?.shiftKey)\n },\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowSelectionFeature', prototype, table, {\n row_toggleSelected: {\n fn: (row, value, opts) => row_toggleSelected(row, value, opts),\n },\n row_getIsSelected: {\n fn: (row) => row_getIsSelected(row),\n },\n row_getIsSomeSelected: {\n fn: (row) => row_getIsSomeSelected(row),\n memoDeps: (row) => [\n row.subRows,\n row.table.atoms.rowSelection?.get(),\n row.table.options.enableRowSelection,\n ],\n },\n row_getIsAllSubRowsSelected: {\n fn: (row) => row_getIsAllSubRowsSelected(row),\n memoDeps: (row) => [\n row.subRows,\n row.table.atoms.rowSelection?.get(),\n row.table.options.enableRowSelection,\n ],\n },\n row_getCanSelect: {\n fn: (row) => row_getCanSelect(row),\n },\n row_getCanSelectSubRows: {\n fn: (row) => row_getCanSelectSubRows(row),\n },\n row_getCanMultiSelect: {\n fn: (row) => row_getCanMultiSelect(row),\n },\n row_getToggleSelectedHandler: {\n fn: (row, opts) => row_getToggleSelectedHandler(row, opts),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowSelectionFeature', table, {\n table_setRowSelection: {\n fn: (updater) => table_setRowSelection(table, updater),\n },\n table_resetRowSelection: {\n fn: (defaultState) => table_resetRowSelection(table, defaultState),\n },\n table_toggleAllRowsSelected: {\n fn: (value, opts) => table_toggleAllRowsSelected(table, value, opts),\n },\n table_toggleAllPageRowsSelected: {\n fn: (value, opts) =>\n table_toggleAllPageRowsSelected(table, value, opts),\n },\n table_getPreSelectedRowModel: {\n fn: () => table_getPreSelectedRowModel(table),\n },\n table_getSelectedRowModel: {\n fn: () => table_getSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getCoreRowModel(),\n ],\n },\n table_getFilteredSelectedRowModel: {\n fn: () => table_getFilteredSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n ],\n },\n table_getGroupedSelectedRowModel: {\n fn: () => table_getGroupedSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getSortedRowModel(),\n ],\n },\n table_getSelectedRowIds: {\n fn: () => table_getSelectedRowIds(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsAllRowsSelected: {\n fn: () => table_getIsAllRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsAllPageRowsSelected: {\n fn: () => table_getIsAllPageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsSomeRowsSelected: {\n fn: () => table_getIsSomeRowsSelected(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsSomePageRowsSelected: {\n fn: () => table_getIsSomePageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getToggleAllRowsSelectedHandler: {\n fn: () => table_getToggleAllRowsSelectedHandler(table),\n },\n table_getToggleAllPageRowsSelected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AUC,kEAAgC,KAAK;IAC/C,gBAAgB;KACd,MAAM,MAAM,cAAc,IAAI;KAC9B,MAAM,qBAAqB;KAC3B,MAAM,QAAQ;IAChB;GACF;GACA,uCAAuC,EACrC,UAAUC,wEAAsC,KAAK,EACvD;GACA,2CAA2C,EACzC,UAAUC,4EAA0C,KAAK,EAC3D;EACF,CAAC;CACH;AACF"}
|
|
@@ -6,6 +6,12 @@ import { getDefaultRowSelectionState, row_getCanMultiSelect, row_getCanSelect, r
|
|
|
6
6
|
* Feature that adds row selection state and APIs for row and page selection.
|
|
7
7
|
*/
|
|
8
8
|
const rowSelectionFeature = {
|
|
9
|
+
initTableInstanceData: (table) => {
|
|
10
|
+
table._lastSelectedRowId = null;
|
|
11
|
+
},
|
|
12
|
+
resetTableInstanceData: (table) => {
|
|
13
|
+
table._lastSelectedRowId = null;
|
|
14
|
+
},
|
|
9
15
|
getInitialState: (initialState) => {
|
|
10
16
|
return {
|
|
11
17
|
rowSelection: getDefaultRowSelectionState(),
|
|
@@ -17,7 +23,12 @@ const rowSelectionFeature = {
|
|
|
17
23
|
onRowSelectionChange: makeStateUpdater("rowSelection", table),
|
|
18
24
|
enableRowSelection: true,
|
|
19
25
|
enableMultiRowSelection: true,
|
|
20
|
-
|
|
26
|
+
enableRowRangeSelection: true,
|
|
27
|
+
enableSubRowSelection: true,
|
|
28
|
+
isRowRangeSelectionEvent: (event) => {
|
|
29
|
+
const rangeEvent = event;
|
|
30
|
+
return Boolean(rangeEvent.shiftKey || rangeEvent.nativeEvent?.shiftKey);
|
|
31
|
+
}
|
|
21
32
|
};
|
|
22
33
|
},
|
|
23
34
|
assignRowPrototype: (prototype, table) => {
|
|
@@ -43,7 +54,7 @@ const rowSelectionFeature = {
|
|
|
43
54
|
row_getCanSelect: { fn: (row) => row_getCanSelect(row) },
|
|
44
55
|
row_getCanSelectSubRows: { fn: (row) => row_getCanSelectSubRows(row) },
|
|
45
56
|
row_getCanMultiSelect: { fn: (row) => row_getCanMultiSelect(row) },
|
|
46
|
-
row_getToggleSelectedHandler: { fn: (row) => row_getToggleSelectedHandler(row) }
|
|
57
|
+
row_getToggleSelectedHandler: { fn: (row, opts) => row_getToggleSelectedHandler(row, opts) }
|
|
47
58
|
});
|
|
48
59
|
},
|
|
49
60
|
constructTableAPIs: (table) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rowSelectionFeature.js","names":[],"sources":["../../../src/features/row-selection/rowSelectionFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowSelectionState,\n row_getCanMultiSelect,\n row_getCanSelect,\n row_getCanSelectSubRows,\n row_getIsAllSubRowsSelected,\n row_getIsSelected,\n row_getIsSomeSelected,\n row_getToggleSelectedHandler,\n row_toggleSelected,\n table_getFilteredSelectedRowModel,\n table_getGroupedSelectedRowModel,\n table_getIsAllPageRowsSelected,\n table_getIsAllRowsSelected,\n table_getIsSomePageRowsSelected,\n table_getIsSomeRowsSelected,\n table_getPreSelectedRowModel,\n table_getSelectedRowIds,\n table_getSelectedRowModel,\n table_getToggleAllPageRowsSelectedHandler,\n table_getToggleAllRowsSelectedHandler,\n table_resetRowSelection,\n table_setRowSelection,\n table_toggleAllPageRowsSelected,\n table_toggleAllRowsSelected,\n} from './rowSelectionFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds row selection state and APIs for row and page selection.\n */\nexport const rowSelectionFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n rowSelection: getDefaultRowSelectionState(),\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowSelectionFeature', prototype, table, {\n row_toggleSelected: {\n fn: (row, value, opts) => row_toggleSelected(row, value, opts),\n },\n row_getIsSelected: {\n fn: (row) => row_getIsSelected(row),\n },\n row_getIsSomeSelected: {\n fn: (row) => row_getIsSomeSelected(row),\n memoDeps: (row) => [\n row.subRows,\n row.table.atoms.rowSelection?.get(),\n row.table.options.enableRowSelection,\n ],\n },\n row_getIsAllSubRowsSelected: {\n fn: (row) => row_getIsAllSubRowsSelected(row),\n memoDeps: (row) => [\n row.subRows,\n row.table.atoms.rowSelection?.get(),\n row.table.options.enableRowSelection,\n ],\n },\n row_getCanSelect: {\n fn: (row) => row_getCanSelect(row),\n },\n row_getCanSelectSubRows: {\n fn: (row) => row_getCanSelectSubRows(row),\n },\n row_getCanMultiSelect: {\n fn: (row) => row_getCanMultiSelect(row),\n },\n row_getToggleSelectedHandler: {\n fn: (row) => row_getToggleSelectedHandler(row),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowSelectionFeature', table, {\n table_setRowSelection: {\n fn: (updater) => table_setRowSelection(table, updater),\n },\n table_resetRowSelection: {\n fn: (defaultState) => table_resetRowSelection(table, defaultState),\n },\n table_toggleAllRowsSelected: {\n fn: (value, opts) => table_toggleAllRowsSelected(table, value, opts),\n },\n table_toggleAllPageRowsSelected: {\n fn: (value, opts) =>\n table_toggleAllPageRowsSelected(table, value, opts),\n },\n table_getPreSelectedRowModel: {\n fn: () => table_getPreSelectedRowModel(table),\n },\n table_getSelectedRowModel: {\n fn: () => table_getSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getCoreRowModel(),\n ],\n },\n table_getFilteredSelectedRowModel: {\n fn: () => table_getFilteredSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n ],\n },\n table_getGroupedSelectedRowModel: {\n fn: () => table_getGroupedSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getSortedRowModel(),\n ],\n },\n table_getSelectedRowIds: {\n fn: () => table_getSelectedRowIds(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsAllRowsSelected: {\n fn: () => table_getIsAllRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsAllPageRowsSelected: {\n fn: () => table_getIsAllPageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsSomeRowsSelected: {\n fn: () => table_getIsSomeRowsSelected(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsSomePageRowsSelected: {\n fn: () => table_getIsSomePageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getToggleAllRowsSelectedHandler: {\n fn: () => table_getToggleAllRowsSelectedHandler(table),\n },\n table_getToggleAllPageRowsSelectedHandler: {\n fn: () => table_getToggleAllPageRowsSelectedHandler(table),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAoCA,MAAa,sBAAoC;CAC/C,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAc,4BAA4B;GAC1C,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsB,iBAAiB,gBAAgB,KAAK;GAC5D,oBAAoB;GACpB,yBAAyB;GACzB,uBAAuB;
|
|
1
|
+
{"version":3,"file":"rowSelectionFeature.js","names":[],"sources":["../../../src/features/row-selection/rowSelectionFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowSelectionState,\n row_getCanMultiSelect,\n row_getCanSelect,\n row_getCanSelectSubRows,\n row_getIsAllSubRowsSelected,\n row_getIsSelected,\n row_getIsSomeSelected,\n row_getToggleSelectedHandler,\n row_toggleSelected,\n table_getFilteredSelectedRowModel,\n table_getGroupedSelectedRowModel,\n table_getIsAllPageRowsSelected,\n table_getIsAllRowsSelected,\n table_getIsSomePageRowsSelected,\n table_getIsSomeRowsSelected,\n table_getPreSelectedRowModel,\n table_getSelectedRowIds,\n table_getSelectedRowModel,\n table_getToggleAllPageRowsSelectedHandler,\n table_getToggleAllRowsSelectedHandler,\n table_resetRowSelection,\n table_setRowSelection,\n table_toggleAllPageRowsSelected,\n table_toggleAllRowsSelected,\n} from './rowSelectionFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds row selection state and APIs for row and page selection.\n */\nexport const rowSelectionFeature: TableFeature = {\n initTableInstanceData: (table) => {\n // @ts-ignore - _lastSelectedRowId is row selection table instance data\n table._lastSelectedRowId = null\n },\n\n resetTableInstanceData: (table) => {\n // @ts-ignore - _lastSelectedRowId is row selection table instance data\n table._lastSelectedRowId = null\n },\n\n getInitialState: (initialState) => {\n return {\n rowSelection: getDefaultRowSelectionState(),\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableRowRangeSelection: true,\n enableSubRowSelection: true,\n isRowRangeSelectionEvent: (event) => {\n const rangeEvent = event as {\n shiftKey?: boolean\n nativeEvent?: { shiftKey?: boolean }\n }\n return Boolean(rangeEvent.shiftKey || rangeEvent.nativeEvent?.shiftKey)\n },\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowSelectionFeature', prototype, table, {\n row_toggleSelected: {\n fn: (row, value, opts) => row_toggleSelected(row, value, opts),\n },\n row_getIsSelected: {\n fn: (row) => row_getIsSelected(row),\n },\n row_getIsSomeSelected: {\n fn: (row) => row_getIsSomeSelected(row),\n memoDeps: (row) => [\n row.subRows,\n row.table.atoms.rowSelection?.get(),\n row.table.options.enableRowSelection,\n ],\n },\n row_getIsAllSubRowsSelected: {\n fn: (row) => row_getIsAllSubRowsSelected(row),\n memoDeps: (row) => [\n row.subRows,\n row.table.atoms.rowSelection?.get(),\n row.table.options.enableRowSelection,\n ],\n },\n row_getCanSelect: {\n fn: (row) => row_getCanSelect(row),\n },\n row_getCanSelectSubRows: {\n fn: (row) => row_getCanSelectSubRows(row),\n },\n row_getCanMultiSelect: {\n fn: (row) => row_getCanMultiSelect(row),\n },\n row_getToggleSelectedHandler: {\n fn: (row, opts) => row_getToggleSelectedHandler(row, opts),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowSelectionFeature', table, {\n table_setRowSelection: {\n fn: (updater) => table_setRowSelection(table, updater),\n },\n table_resetRowSelection: {\n fn: (defaultState) => table_resetRowSelection(table, defaultState),\n },\n table_toggleAllRowsSelected: {\n fn: (value, opts) => table_toggleAllRowsSelected(table, value, opts),\n },\n table_toggleAllPageRowsSelected: {\n fn: (value, opts) =>\n table_toggleAllPageRowsSelected(table, value, opts),\n },\n table_getPreSelectedRowModel: {\n fn: () => table_getPreSelectedRowModel(table),\n },\n table_getSelectedRowModel: {\n fn: () => table_getSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getCoreRowModel(),\n ],\n },\n table_getFilteredSelectedRowModel: {\n fn: () => table_getFilteredSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n ],\n },\n table_getGroupedSelectedRowModel: {\n fn: () => table_getGroupedSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getSortedRowModel(),\n ],\n },\n table_getSelectedRowIds: {\n fn: () => table_getSelectedRowIds(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsAllRowsSelected: {\n fn: () => table_getIsAllRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsAllPageRowsSelected: {\n fn: () => table_getIsAllPageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsSomeRowsSelected: {\n fn: () => table_getIsSomeRowsSelected(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsSomePageRowsSelected: {\n fn: () => table_getIsSomePageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getToggleAllRowsSelectedHandler: {\n fn: () => table_getToggleAllRowsSelectedHandler(table),\n },\n table_getToggleAllPageRowsSelectedHandler: {\n fn: () => table_getToggleAllPageRowsSelectedHandler(table),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAoCA,MAAa,sBAAoC;CAC/C,wBAAwB,UAAU;EAEhC,MAAM,qBAAqB;CAC7B;CAEA,yBAAyB,UAAU;EAEjC,MAAM,qBAAqB;CAC7B;CAEA,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAc,4BAA4B;GAC1C,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsB,iBAAiB,gBAAgB,KAAK;GAC5D,oBAAoB;GACpB,yBAAyB;GACzB,yBAAyB;GACzB,uBAAuB;GACvB,2BAA2B,UAAU;IACnC,MAAM,aAAa;IAInB,OAAO,QAAQ,WAAW,YAAY,WAAW,aAAa,QAAQ;GACxE;EACF;CACF;CAEA,qBAAqB,WAAW,UAAU;EACxC,oBAAoB,uBAAuB,WAAW,OAAO;GAC3D,oBAAoB,EAClB,KAAK,KAAK,OAAO,SAAS,mBAAmB,KAAK,OAAO,IAAI,EAC/D;GACA,mBAAmB,EACjB,KAAK,QAAQ,kBAAkB,GAAG,EACpC;GACA,uBAAuB;IACrB,KAAK,QAAQ,sBAAsB,GAAG;IACtC,WAAW,QAAQ;KACjB,IAAI;KACJ,IAAI,MAAM,MAAM,cAAc,IAAI;KAClC,IAAI,MAAM,QAAQ;IACpB;GACF;GACA,6BAA6B;IAC3B,KAAK,Q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,MAAM,MAAM,cAAc,IAAI;KAC9B,MAAM,oBAAoB;KAC1B,MAAM,QAAQ;IAChB;GACF;GACA,gCAAgC;IAC9B,UAAU,+BAA+B,KAAK;IAC9C,gBAAgB;KACd,MAAM,MAAM,cAAc,IAAI;KAC9B,MAAM,qBAAqB;KAC3B,MAAM,QAAQ;IAChB;GACF;GACA,6BAA6B;IAC3B,UAAU,4BAA4B,KAAK;IAC3C,gBAAgB,CAAC,MAAM,MAAM,cAAc,IAAI,CAAC;GAClD;GACA,iCAAiC;IAC/B,UAAU,gCAAgC,KAAK;IAC/C,gBAAgB;KACd,MAAM,MAAM,cAAc,IAAI;KAC9B,MAAM,qBAAqB;KAC3B,MAAM,QAAQ;IAChB;GACF;GACA,uCAAuC,EACrC,UAAU,sCAAsC,KAAK,EACvD;GACA,2CAA2C,EACzC,UAAU,0CAA0C,KAAK,EAC3D;EACF,CAAC;CACH;AACF"}
|
|
@@ -5,10 +5,25 @@ import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
|
5
5
|
|
|
6
6
|
//#region src/features/row-selection/rowSelectionFeature.types.d.ts
|
|
7
7
|
type RowSelectionState = Record<string, true>;
|
|
8
|
+
/**
|
|
9
|
+
* Controls how toggling a row affects its descendants.
|
|
10
|
+
*/
|
|
11
|
+
interface ToggleSelectedOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Whether selectable child rows should be toggled recursively. Defaults to
|
|
14
|
+
* `true`.
|
|
15
|
+
*/
|
|
16
|
+
selectChildren?: boolean;
|
|
17
|
+
}
|
|
8
18
|
interface TableState_RowSelection {
|
|
9
19
|
rowSelection: RowSelectionState;
|
|
10
20
|
}
|
|
11
21
|
interface TableOptions_RowSelection<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
22
|
+
/**
|
|
23
|
+
* Enables inclusive row range selection through
|
|
24
|
+
* `row.getToggleSelectedHandler()`. Defaults to `true`.
|
|
25
|
+
*/
|
|
26
|
+
enableRowRangeSelection?: boolean;
|
|
12
27
|
/**
|
|
13
28
|
* Allows rows to be selected alongside other rows.
|
|
14
29
|
*
|
|
@@ -28,6 +43,14 @@ interface TableOptions_RowSelection<in out TFeatures extends TableFeatures, in o
|
|
|
28
43
|
* grouping features and defaults to `true`.
|
|
29
44
|
*/
|
|
30
45
|
enableSubRowSelection?: boolean | ((row: Row<TFeatures, TData>) => boolean);
|
|
46
|
+
/**
|
|
47
|
+
* Determines whether a row-selection handler event should select or
|
|
48
|
+
* deselect the inclusive range from the most recent handler interaction.
|
|
49
|
+
*
|
|
50
|
+
* By default, events with `shiftKey` directly on the event or on
|
|
51
|
+
* `event.nativeEvent` are treated as range-selection events.
|
|
52
|
+
*/
|
|
53
|
+
isRowRangeSelectionEvent?: (event: unknown) => boolean;
|
|
31
54
|
/**
|
|
32
55
|
* Called with an updater when row selection state changes. Pair this with
|
|
33
56
|
* `state.rowSelection` when using external state; external atoms can own the
|
|
@@ -62,16 +85,23 @@ interface Row_RowSelection {
|
|
|
62
85
|
getIsSomeSelected: () => boolean;
|
|
63
86
|
/**
|
|
64
87
|
* Creates a checkbox-style handler that toggles this row's selected state.
|
|
88
|
+
* Pass the original checkbox click event, or a framework event whose
|
|
89
|
+
* `nativeEvent` is that click, so Shift range selection can detect the
|
|
90
|
+
* modifier key.
|
|
65
91
|
*/
|
|
66
|
-
getToggleSelectedHandler: () => (event: unknown) => void;
|
|
92
|
+
getToggleSelectedHandler: (opts?: ToggleSelectedOptions) => (event: unknown) => void;
|
|
67
93
|
/**
|
|
68
94
|
* Selects/deselects the row.
|
|
69
95
|
*/
|
|
70
|
-
toggleSelected: (value?: boolean, opts?:
|
|
71
|
-
selectChildren?: boolean;
|
|
72
|
-
}) => void;
|
|
96
|
+
toggleSelected: (value?: boolean, opts?: ToggleSelectedOptions) => void;
|
|
73
97
|
}
|
|
74
98
|
interface Table_RowSelection<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
99
|
+
/**
|
|
100
|
+
* The most recent row interacted with through the row selection handler.
|
|
101
|
+
*
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
_lastSelectedRowId: string | null;
|
|
75
105
|
/**
|
|
76
106
|
* Builds a selected-row model from rows after filtering.
|
|
77
107
|
*/
|
|
@@ -140,5 +170,5 @@ interface Table_RowSelection<in out TFeatures extends TableFeatures, in out TDat
|
|
|
140
170
|
}) => void;
|
|
141
171
|
}
|
|
142
172
|
//#endregion
|
|
143
|
-
export { RowSelectionState, Row_RowSelection, TableOptions_RowSelection, TableState_RowSelection, Table_RowSelection };
|
|
173
|
+
export { RowSelectionState, Row_RowSelection, TableOptions_RowSelection, TableState_RowSelection, Table_RowSelection, ToggleSelectedOptions };
|
|
144
174
|
//# sourceMappingURL=rowSelectionFeature.types.d.cts.map
|