@tanstack/angular-table 9.0.0-alpha.45 → 9.0.0-alpha.46

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.
@@ -2,8 +2,8 @@ import * as i0 from '@angular/core';
2
2
  import { InjectionToken, input, inject, Directive, reflectComponentType, Injectable, KeyValueDiffers, ChangeDetectorRef, OutputEmitterRef, TemplateRef, Type, runInInjectionContext, computed, effect, untracked, Injector, ViewContainerRef, DestroyRef, signal, assertInInjectionContext } from '@angular/core';
3
3
  import { constructTable, createColumnHelper } from '@tanstack/table-core';
4
4
  export * from '@tanstack/table-core';
5
- import { injectSelector, shallow } from '@tanstack/angular-store';
6
5
  import { toObservable } from '@angular/core/rxjs-interop';
6
+ export { shallow } from '@tanstack/angular-store';
7
7
 
8
8
  /**
9
9
  * Injection token that provides access to the current cell.
@@ -55,15 +55,15 @@ class TanStackTableCell {
55
55
  * Provided as a required signal input so DI consumers always read the latest value.
56
56
  */
57
57
  cell = input.required({ ...(ngDevMode ? { debugName: "cell" } : /* istanbul ignore next */ {}), alias: 'tanStackTableCell' });
58
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: TanStackTableCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
59
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.11", type: TanStackTableCell, isStandalone: true, selector: "[tanStackTableCell]", inputs: { cell: { classPropertyName: "cell", publicName: "tanStackTableCell", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
58
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TanStackTableCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
59
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.12", type: TanStackTableCell, isStandalone: true, selector: "[tanStackTableCell]", inputs: { cell: { classPropertyName: "cell", publicName: "tanStackTableCell", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
60
60
  {
61
61
  provide: TanStackTableCellToken,
62
62
  useFactory: () => inject(TanStackTableCell).cell,
63
63
  },
64
64
  ], exportAs: ["cell"], ngImport: i0 });
65
65
  }
66
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: TanStackTableCell, decorators: [{
66
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TanStackTableCell, decorators: [{
67
67
  type: Directive,
68
68
  args: [{
69
69
  selector: '[tanStackTableCell]',
@@ -132,15 +132,15 @@ class TanStackTableHeader {
132
132
  * Provided as a required signal input so DI consumers always read the latest value.
133
133
  */
134
134
  header = input.required({ ...(ngDevMode ? { debugName: "header" } : /* istanbul ignore next */ {}), alias: 'tanStackTableHeader' });
135
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: TanStackTableHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
136
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.11", type: TanStackTableHeader, isStandalone: true, selector: "[tanStackTableHeader]", inputs: { header: { classPropertyName: "header", publicName: "tanStackTableHeader", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
135
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TanStackTableHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
136
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.12", type: TanStackTableHeader, isStandalone: true, selector: "[tanStackTableHeader]", inputs: { header: { classPropertyName: "header", publicName: "tanStackTableHeader", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
137
137
  {
138
138
  provide: TanStackTableHeaderToken,
139
139
  useFactory: () => inject(TanStackTableHeader).header,
140
140
  },
141
141
  ], exportAs: ["header"], ngImport: i0 });
142
142
  }
143
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: TanStackTableHeader, decorators: [{
143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TanStackTableHeader, decorators: [{
144
144
  type: Directive,
145
145
  args: [{
146
146
  selector: '[tanStackTableHeader]',
@@ -211,15 +211,15 @@ class TanStackTable {
211
211
  * Provided as a required signal input so DI consumers always read the latest value.
212
212
  */
213
213
  table = input.required({ ...(ngDevMode ? { debugName: "table" } : /* istanbul ignore next */ {}), alias: 'tanStackTable' });
214
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: TanStackTable, deps: [], target: i0.ɵɵFactoryTarget.Directive });
215
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.11", type: TanStackTable, isStandalone: true, selector: "[tanStackTable]", inputs: { table: { classPropertyName: "table", publicName: "tanStackTable", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
214
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TanStackTable, deps: [], target: i0.ɵɵFactoryTarget.Directive });
215
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.12", type: TanStackTable, isStandalone: true, selector: "[tanStackTable]", inputs: { table: { classPropertyName: "table", publicName: "tanStackTable", isSignal: true, isRequired: true, transformFunction: null } }, providers: [
216
216
  {
217
217
  provide: TanStackTableToken,
218
218
  useFactory: () => inject(TanStackTable).table,
219
219
  },
220
220
  ], exportAs: ["table"], ngImport: i0 });
221
221
  }
222
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: TanStackTable, decorators: [{
222
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: TanStackTable, decorators: [{
223
223
  type: Directive,
224
224
  args: [{
225
225
  selector: '[tanStackTable]',
@@ -355,6 +355,10 @@ class FlexRenderComponentInstance {
355
355
  }
356
356
  }
357
357
 
358
+ /**
359
+ * Creates and manages Angular component instances used by flex-rendered table
360
+ * content.
361
+ */
358
362
  class FlexRenderComponentFactory {
359
363
  #viewContainerRef;
360
364
  constructor(viewContainerRef) {
@@ -374,12 +378,18 @@ class FlexRenderComponentFactory {
374
378
  view.setOutputs(outputs);
375
379
  return view;
376
380
  }
377
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FlexRenderComponentFactory, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Injectable });
378
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FlexRenderComponentFactory });
381
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: FlexRenderComponentFactory, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Injectable });
382
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: FlexRenderComponentFactory });
379
383
  }
380
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FlexRenderComponentFactory, decorators: [{
384
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: FlexRenderComponentFactory, decorators: [{
381
385
  type: Injectable
382
386
  }], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
387
+ /**
388
+ * Runtime wrapper around an Angular component rendered by `FlexRenderDirective`.
389
+ *
390
+ * It diffs inputs and outputs across table updates so component renderers can
391
+ * be reused instead of recreated on every cell/header render.
392
+ */
383
393
  class FlexRenderComponentRef {
384
394
  componentRef;
385
395
  componentInjector;
@@ -531,6 +541,13 @@ class FlexRenderComponentOutputManager {
531
541
  }
532
542
  }
533
543
 
544
+ /**
545
+ * Normalizes arbitrary Angular flex-render content into the renderer's internal
546
+ * tagged representation.
547
+ *
548
+ * This lets the directive decide whether to reuse, update, or recreate an
549
+ * embedded view or component view.
550
+ */
534
551
  function mapToFlexRenderTypedContent(content) {
535
552
  if (content === null || content === undefined) {
536
553
  return { kind: 'null' };
@@ -570,6 +587,12 @@ class FlexRenderView {
570
587
  this.#content = content;
571
588
  }
572
589
  }
590
+ /**
591
+ * Tracks an Angular embedded template view rendered by `FlexRenderDirective`.
592
+ *
593
+ * Template views receive updated props through their proxied context and can be
594
+ * reused while the rendered content kind stays compatible.
595
+ */
573
596
  class FlexRenderTemplateView extends FlexRenderView {
574
597
  constructor(initialContent, view) {
575
598
  super(initialContent, view);
@@ -600,6 +623,12 @@ class FlexRenderTemplateView extends FlexRenderView {
600
623
  this.content.content === compare.content));
601
624
  }
602
625
  }
626
+ /**
627
+ * Tracks an Angular component view rendered by `FlexRenderDirective`.
628
+ *
629
+ * Component views own input/output updates for `flexRenderComponent(...)`
630
+ * results and component classes rendered directly from column definitions.
631
+ */
603
632
  class FlexRenderComponentView extends FlexRenderView {
604
633
  constructor(initialContent, view) {
605
634
  super(initialContent, view);
@@ -955,10 +984,10 @@ class FlexRenderCell {
955
984
  renderer.destroy();
956
985
  });
957
986
  }
958
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FlexRenderCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
959
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.11", type: FlexRenderCell, isStandalone: true, selector: "ng-template[flexRenderCell], ng-template[flexRenderFooter], ng-template[flexRenderHeader]", inputs: { cell: { classPropertyName: "cell", publicName: "flexRenderCell", isSignal: true, isRequired: false, transformFunction: null }, header: { classPropertyName: "header", publicName: "flexRenderHeader", isSignal: true, isRequired: false, transformFunction: null }, footer: { classPropertyName: "footer", publicName: "flexRenderFooter", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
987
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: FlexRenderCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
988
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.12", type: FlexRenderCell, isStandalone: true, selector: "ng-template[flexRenderCell], ng-template[flexRenderFooter], ng-template[flexRenderHeader]", inputs: { cell: { classPropertyName: "cell", publicName: "flexRenderCell", isSignal: true, isRequired: false, transformFunction: null }, header: { classPropertyName: "header", publicName: "flexRenderHeader", isSignal: true, isRequired: false, transformFunction: null }, footer: { classPropertyName: "footer", publicName: "flexRenderFooter", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
960
989
  }
961
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FlexRenderCell, decorators: [{
990
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: FlexRenderCell, decorators: [{
962
991
  type: Directive,
963
992
  args: [{
964
993
  selector: 'ng-template[flexRenderCell], ng-template[flexRenderFooter], ng-template[flexRenderHeader]',
@@ -1032,10 +1061,10 @@ class FlexRenderDirective {
1032
1061
  renderer.destroy();
1033
1062
  });
1034
1063
  }
1035
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FlexRenderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1036
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.11", type: FlexRenderDirective, isStandalone: true, selector: "ng-template[flexRender]", inputs: { content: { classPropertyName: "content", publicName: "flexRender", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "flexRenderProps", isSignal: true, isRequired: false, transformFunction: null }, injector: { classPropertyName: "injector", publicName: "flexRenderInjector", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
1064
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: FlexRenderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1065
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.12", type: FlexRenderDirective, isStandalone: true, selector: "ng-template[flexRender]", inputs: { content: { classPropertyName: "content", publicName: "flexRender", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "flexRenderProps", isSignal: true, isRequired: false, transformFunction: null }, injector: { classPropertyName: "injector", publicName: "flexRenderInjector", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
1037
1066
  }
1038
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: FlexRenderDirective, decorators: [{
1067
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: FlexRenderDirective, decorators: [{
1039
1068
  type: Directive,
1040
1069
  args: [{
1041
1070
  selector: 'ng-template[flexRender]',
@@ -1105,6 +1134,14 @@ function signalToWritableAtom(signal, injector) {
1105
1134
  },
1106
1135
  });
1107
1136
  }
1137
+ /**
1138
+ * Creates the table-core reactivity bindings used by the Angular adapter.
1139
+ *
1140
+ * Readonly table atoms are backed by Angular `computed` signals and writable
1141
+ * atoms by Angular `signal`. Subscriptions bridge through `toObservable` with
1142
+ * the caller's injector so table APIs can be consumed from Angular `computed`
1143
+ * and `effect` calls.
1144
+ */
1108
1145
  function angularReactivity(injector) {
1109
1146
  return {
1110
1147
  createOptionsStore: true,
@@ -1183,7 +1220,7 @@ function angularReactivity(injector) {
1183
1220
  *
1184
1221
  * @returns An Angular-reactive TanStack Table instance.
1185
1222
  */
1186
- function injectTable(options, selector) {
1223
+ function injectTable(options) {
1187
1224
  assertInInjectionContext(injectTable);
1188
1225
  const injector = inject(Injector);
1189
1226
  return lazyInit(() => {
@@ -1206,27 +1243,29 @@ function injectTable(options, selector) {
1206
1243
  ...newOptions,
1207
1244
  })));
1208
1245
  }, { injector, debugName: 'tableOptionsUpdate' });
1209
- table.computed = function Subscribe(props) {
1210
- const source = props.source ?? table.store;
1211
- return injectSelector(source, props.selector, {
1212
- compare: props.equal ?? shallow,
1213
- injector,
1214
- });
1215
- };
1216
- Object.defineProperty(table, 'state', {
1217
- value: computed(() => selector?.(table.store.get()) ?? table.store.get()),
1218
- });
1219
- Object.defineProperty(table, 'value', {
1220
- value: computed(() => {
1221
- table.store.get();
1222
- table.optionsStore.get();
1223
- return table;
1224
- }, { equal: () => false }),
1225
- });
1226
1246
  return table;
1227
1247
  });
1228
1248
  }
1229
1249
 
1250
+ /**
1251
+ * Creates app-scoped Angular table helpers with features, row models, and
1252
+ * renderable component maps pre-bound.
1253
+ *
1254
+ * Use this when an app or design system wants typed `injectAppTable`,
1255
+ * pre-bound column helpers, and typed table/cell/header context injection
1256
+ * helpers without repeating the same feature and component generics.
1257
+ *
1258
+ * @example
1259
+ * ```ts
1260
+ * const { injectAppTable, createAppColumnHelper } = createTableHook({
1261
+ * _features,
1262
+ * _rowModels: {},
1263
+ * tableComponents: {},
1264
+ * cellComponents: {},
1265
+ * headerComponents: {},
1266
+ * })
1267
+ * ```
1268
+ */
1230
1269
  function createTableHook({ tableComponents, cellComponents, headerComponents, ...defaultTableOptions }) {
1231
1270
  function injectTableContext$1() {
1232
1271
  return injectTableContext();
@@ -1243,7 +1282,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
1243
1282
  function injectFlexRenderCellContext() {
1244
1283
  return injectFlexRenderContext();
1245
1284
  }
1246
- function injectAppTable(tableOptions, selector) {
1285
+ function injectAppTable(tableOptions) {
1247
1286
  function appCell(cell) {
1248
1287
  return cell;
1249
1288
  }
@@ -1265,7 +1304,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
1265
1304
  },
1266
1305
  };
1267
1306
  return injectTable(() => {
1268
- const options = {
1307
+ return {
1269
1308
  ...defaultTableOptions,
1270
1309
  ...tableOptions(),
1271
1310
  _features: {
@@ -1273,8 +1312,7 @@ function createTableHook({ tableComponents, cellComponents, headerComponents, ..
1273
1312
  appTableFeatures,
1274
1313
  },
1275
1314
  };
1276
- return options;
1277
- }, selector);
1315
+ });
1278
1316
  }
1279
1317
  function createAppColumnHelper() {
1280
1318
  // The runtime implementation is the same - components are attached at render time