@tanstack/angular-table 8.21.3 → 8.21.4

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.
@@ -15,6 +15,7 @@ import {
15
15
  Type,
16
16
  ViewContainerRef,
17
17
  } from '@angular/core'
18
+ import { memo } from '@tanstack/table-core'
18
19
  import { FlexRenderComponentProps } from './flex-render/context'
19
20
  import { FlexRenderFlags } from './flex-render/flags'
20
21
  import {
@@ -27,9 +28,9 @@ import {
27
28
  FlexRenderTemplateView,
28
29
  type FlexRenderTypedContent,
29
30
  FlexRenderView,
31
+ FlexRenderViewAllowedType,
30
32
  mapToFlexRenderTypedContent,
31
33
  } from './flex-render/view'
32
- import { memo } from '@tanstack/table-core'
33
34
 
34
35
  export {
35
36
  injectFlexRenderContext,
@@ -72,7 +73,10 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
72
73
  injector: Injector = inject(Injector)
73
74
 
74
75
  renderFlags = FlexRenderFlags.ViewFirstRender
75
- renderView: FlexRenderView<any> | null = null
76
+ renderView: FlexRenderView<
77
+ FlexRenderViewAllowedType,
78
+ FlexRenderTypedContent
79
+ > | null = null
76
80
 
77
81
  readonly #latestContent = () => {
78
82
  const { content, props } = this
@@ -83,17 +87,17 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
83
87
 
84
88
  #getContentValue = memo(
85
89
  () => [this.#latestContent(), this.props, this.content],
86
- latestContent => {
90
+ (latestContent) => {
87
91
  return mapToFlexRenderTypedContent(latestContent)
88
92
  },
89
- { key: 'flexRenderContentValue', debug: () => false }
93
+ { key: 'flexRenderContentValue', debug: () => false },
90
94
  )
91
95
 
92
96
  constructor(
93
97
  @Inject(ViewContainerRef)
94
98
  private readonly viewContainerRef: ViewContainerRef,
95
99
  @Inject(TemplateRef)
96
- private readonly templateRef: TemplateRef<any>
100
+ private readonly templateRef: TemplateRef<any>,
97
101
  ) {}
98
102
 
99
103
  ngOnChanges(changes: SimpleChanges) {
@@ -121,11 +125,14 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
121
125
  if (latestContent.kind === 'null' || !this.renderView) {
122
126
  this.renderFlags |= FlexRenderFlags.ContentChanged
123
127
  } else {
124
- this.renderView.content = latestContent
125
- const { kind: previousKind } = this.renderView.previousContent
126
- if (latestContent.kind !== previousKind) {
128
+ const { kind: currentKind } = this.renderView.content
129
+ if (
130
+ latestContent.kind !== currentKind ||
131
+ !this.renderView.eq(latestContent)
132
+ ) {
127
133
  this.renderFlags |= FlexRenderFlags.ContentChanged
128
134
  }
135
+ this.renderView.content = latestContent
129
136
  }
130
137
  this.update()
131
138
  }
@@ -190,7 +197,7 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
190
197
  // so we'll try to check for updates into ngDoCheck
191
198
  this.#changeDetectorRef.markForCheck()
192
199
  },
193
- { injector: this.viewContainerRef.injector }
200
+ { injector: this.viewContainerRef.injector },
194
201
  )
195
202
  }
196
203
  }
@@ -204,8 +211,8 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
204
211
  }
205
212
 
206
213
  #renderViewByContent(
207
- content: FlexRenderTypedContent
208
- ): FlexRenderView<any> | null {
214
+ content: FlexRenderTypedContent,
215
+ ): FlexRenderView<FlexRenderViewAllowedType, FlexRenderTypedContent> | null {
209
216
  if (content.kind === 'primitive') {
210
217
  return this.#renderStringContent(content)
211
218
  } else if (content.kind === 'templateRef') {
@@ -220,7 +227,7 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
220
227
  }
221
228
 
222
229
  #renderStringContent(
223
- template: Extract<FlexRenderTypedContent, { kind: 'primitive' }>
230
+ template: Extract<FlexRenderTypedContent, { kind: 'primitive' }>,
224
231
  ): FlexRenderTemplateView {
225
232
  const context = () => {
226
233
  return typeof this.content === 'string' ||
@@ -237,7 +244,7 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
237
244
  }
238
245
 
239
246
  #renderTemplateRefContent(
240
- template: Extract<FlexRenderTypedContent, { kind: 'templateRef' }>
247
+ template: Extract<FlexRenderTypedContent, { kind: 'templateRef' }>,
241
248
  ): FlexRenderTemplateView {
242
249
  const latestContext = () => this.props
243
250
  const view = this.viewContainerRef.createEmbeddedView(template.content, {
@@ -252,7 +259,7 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
252
259
  flexRenderComponent: Extract<
253
260
  FlexRenderTypedContent,
254
261
  { kind: 'flexRenderComponent' }
255
- >
262
+ >,
256
263
  ): FlexRenderComponentView {
257
264
  const { inputs, outputs, injector } = flexRenderComponent.content
258
265
 
@@ -266,20 +273,20 @@ export class FlexRenderDirective<TProps extends NonNullable<unknown>>
266
273
  })
267
274
  const view = this.#flexRenderComponentFactory.createComponent(
268
275
  flexRenderComponent.content,
269
- componentInjector
276
+ componentInjector,
270
277
  )
271
278
  return new FlexRenderComponentView(flexRenderComponent, view)
272
279
  }
273
280
 
274
281
  #renderCustomComponent(
275
- component: Extract<FlexRenderTypedContent, { kind: 'component' }>
282
+ component: Extract<FlexRenderTypedContent, { kind: 'component' }>,
276
283
  ): FlexRenderComponentView {
277
284
  const view = this.#flexRenderComponentFactory.createComponent(
278
285
  flexRenderComponent(component.content, {
279
286
  inputs: this.props,
280
287
  injector: this.injector,
281
288
  }),
282
- this.injector
289
+ this.injector,
283
290
  )
284
291
  return new FlexRenderComponentView(component, view)
285
292
  }
package/src/index.ts CHANGED
@@ -26,7 +26,7 @@ export {
26
26
  } from './flex-render/flex-render-component'
27
27
 
28
28
  export function createAngularTable<TData extends RowData>(
29
- options: () => TableOptions<TData>
29
+ options: () => TableOptions<TData>,
30
30
  ): Table<TData> & Signal<Table<TData>> {
31
31
  return lazyInit(() => {
32
32
  const resolvedOptions = {
@@ -53,7 +53,7 @@ export function createAngularTable<TData extends RowData>(
53
53
  ...resolvedOptions,
54
54
  ...tableOptions,
55
55
  state: { ...tableState, ...tableOptions.state },
56
- onStateChange: updater => {
56
+ onStateChange: (updater) => {
57
57
  const value =
58
58
  updater instanceof Function ? updater(tableState) : updater
59
59
  state.set(value)
@@ -70,7 +70,7 @@ export function createAngularTable<TData extends RowData>(
70
70
  },
71
71
  {
72
72
  equal: () => false,
73
- }
73
+ },
74
74
  )
75
75
 
76
76
  // proxify Table instance to provide ability for consumer to listen to any table state changes
package/src/proxy.ts CHANGED
@@ -4,7 +4,7 @@ import { type Table } from '@tanstack/table-core'
4
4
  type TableSignal<T> = Table<T> & Signal<Table<T>>
5
5
 
6
6
  export function proxifyTable<T>(
7
- tableSignal: Signal<Table<T>>
7
+ tableSignal: Signal<Table<T>>,
8
8
  ): Table<T> & Signal<Table<T>> {
9
9
  const internalState = tableSignal as TableSignal<T>
10
10