) {
super.updated(changedProperties);
if (changedProperties.has('variant')) {
this.updateAriaRole();
}
}
override disconnectedCallback() {
super.disconnectedCallback();
console.log('📋 Alert: Cleanup complete (no USWDS JavaScript required)');
}
private updateAriaRole() {
const role = this.variant === 'error' || this.variant === 'emergency' ? 'alert' : 'status';
this.setAttribute('role', role);
}
private getAlertClasses(): string {
const classes = [
'usa-alert',
`usa-alert--${this.variant}`,
this.slim ? 'usa-alert--slim' : '',
this.noIcon ? 'usa-alert--no-icon' : '',
];
return classes.filter(Boolean).join(' ');
}
// Use light DOM for USWDS compatibility
protected override createRenderRoot(): HTMLElement {
return this as any;
}
private renderHeading() {
if (!this.heading) return '';
return html`${this.heading}
`;
}
override render() {
// Use tag for text property, empty
for slotted content (filled in updated())
// This ensures proper USWDS HTML structure
const textContent = this.text
? html`
${this.text}
`
: html``;
return html`
${this.renderHeading()}
${textContent}
`;
}
}