MCPcopy Index your code
hub / github.com/TanStack/table / FlexRenderDirective

Class FlexRenderDirective

packages/angular-table/src/flex-render.ts:54–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 providers: [FlexRenderComponentFactory],
53})
54export class FlexRenderDirective<TProps extends NonNullable<unknown>>
55 implements OnChanges, DoCheck
56{
57 readonly #flexRenderComponentFactory = inject(FlexRenderComponentFactory)
58 readonly #changeDetectorRef = inject(ChangeDetectorRef)
59
60 @Input({ required: true, alias: 'flexRender' })
61 content:
62 | number
63 | string
64 | ((props: TProps) => FlexRenderContent<TProps>)
65 | null
66 | undefined = undefined
67
68 @Input({ required: true, alias: 'flexRenderProps' })
69 props: TProps = {} as TProps
70
71 @Input({ required: false, alias: 'flexRenderInjector' })
72 injector: Injector = inject(Injector)
73
74 renderFlags = FlexRenderFlags.ViewFirstRender
75 renderView: FlexRenderView<any> | null = null
76
77 readonly #latestContent = () => {
78 const { content, props } = this
79 return typeof content !== 'function'
80 ? content
81 : runInInjectionContext(this.injector, () => content(props))
82 }
83
84 #getContentValue = memo(
85 () => [this.#latestContent(), this.props, this.content],
86 latestContent => {
87 return mapToFlexRenderTypedContent(latestContent)
88 },
89 { key: 'flexRenderContentValue', debug: () => false }
90 )
91
92 constructor(
93 @Inject(ViewContainerRef)
94 private readonly viewContainerRef: ViewContainerRef,
95 @Inject(TemplateRef)
96 private readonly templateRef: TemplateRef<any>
97 ) {}
98
99 ngOnChanges(changes: SimpleChanges) {
100 if (changes['props']) {
101 this.renderFlags |= FlexRenderFlags.PropsReferenceChanged
102 }
103 if (changes['content']) {
104 this.renderFlags |=
105 FlexRenderFlags.ContentChanged | FlexRenderFlags.ViewFirstRender
106 this.update()
107 }
108 }
109
110 ngDoCheck(): void {
111 if (this.renderFlags & FlexRenderFlags.ViewFirstRender) {

Callers

nothing calls this directly

Calls 3

memoFunction · 0.90
contentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…