// Section list slots are ``s carrying these directives, the list stamps the window // through them. Each has a context guard so the `let-` bindings infer at the call site import { Directive, TemplateRef, inject } from '@angular/core'; import type { ISection as ICoreSection, ISeparators, } from '@symbiote-native/components'; import type { IVListSeparatorContext } from '../virtualized-list'; // A section may bring its own `item` and `separator` templates, which beat the list's export type ISection = ICoreSection & { item?: TemplateRef>; separator?: TemplateRef>; }; // The `renderItem` info arg of RN, `$implicit` is the item so `let-item` binds it export type IVSectionItemContext = { $implicit: ItemT; item: ItemT; index: number; section: ISection; separators: ISeparators; }; // The `renderSectionHeader` and `renderSectionFooter` info arg, `$implicit` is the section export type IVSectionContext = { $implicit: ISection; section: ISection; }; // RN's separator props around a section edge, `props` is the same bag whole so a forwarding // layer can pass it on without naming every key export type IVSectionSeparatorContext = IVListSeparatorContext & { section?: ISection; leadingSection?: ISection; trailingSection?: ISection; props?: IVListSeparatorContext; }; @Directive({ selector: '[vSectionItem]', standalone: true }) export class VSectionItemDirective { readonly templateRef = inject>>(TemplateRef); static ngTemplateContextGuard( _dir: VSectionItemDirective, _ctx: unknown, ): _ctx is IVSectionItemContext { return true; } } // Rendered above each section's items, RN's `renderSectionHeader` @Directive({ selector: '[vSectionHeader]', standalone: true }) export class VSectionHeaderDirective { readonly templateRef = inject>>(TemplateRef); static ngTemplateContextGuard( _dir: VSectionHeaderDirective, _ctx: unknown, ): _ctx is IVSectionContext { return true; } } // Rendered below each section's items, RN's `renderSectionFooter` @Directive({ selector: '[vSectionFooter]', standalone: true }) export class VSectionFooterDirective { readonly templateRef = inject>>(TemplateRef); static ngTemplateContextGuard( _dir: VSectionFooterDirective, _ctx: unknown, ): _ctx is IVSectionContext { return true; } } // Painted before a section's first item and after its last, RN's `SectionSeparatorComponent` @Directive({ selector: '[vSectionSeparator]', standalone: true }) export class VSectionSeparatorDirective { readonly templateRef = inject>>(TemplateRef); static ngTemplateContextGuard( _dir: VSectionSeparatorDirective, _ctx: unknown, ): _ctx is IVSectionSeparatorContext { return true; } }