import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; // // // // // // // export const HeaderFooterReferenceType = { DEFAULT: "default", FIRST: "first", EVEN: "even", } as const; // // // // // // // // // // // // // // // // export type IHeaderFooterOptions = { readonly type?: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType]; readonly id?: number; }; class FooterReferenceAttributes extends XmlAttributeComponent<{ readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType]; readonly id: string; }> { protected readonly xmlKeys = { type: "w:type", id: "r:id", }; } export const HeaderFooterType = { HEADER: "w:headerReference", FOOTER: "w:footerReference", } as const; export class HeaderFooterReference extends XmlComponent { public constructor(type: (typeof HeaderFooterType)[keyof typeof HeaderFooterType], options: IHeaderFooterOptions) { super(type); this.root.push( new FooterReferenceAttributes({ type: options.type || HeaderFooterReferenceType.DEFAULT, id: `rId${options.id}`, }), ); } }