import { AttachInternals as ElInternals, Component as Cmp, Element as El, Event as StencilEvent, EventEmitter, h, Listen as StencilListen, Method as StencilMethod, Prop as Input, State as StencilState, Watch as StencilWatch, } from '@stencil/core'; @Cmp({ tag: 'import-aliasing', formAssociated: true, }) export class FormAssociatedCmp { @Input() user: string; @StencilEvent() myEvent: EventEmitter; @El() el!: HTMLElement; @ElInternals() internals: ElementInternals; @StencilState() changeCount = 0; @StencilState() methodCalledCount = 0; @StencilState() eventCaughtCount = 0; @StencilListen('myEvent') onMyEventTriggered() { this.eventCaughtCount += 1; } @StencilWatch('user') onNameChange() { this.changeCount += 1; } @StencilMethod() async myMethod() { this.methodCalledCount += 1; this.myEvent.emit(); return this.el; } componentWillLoad() { this.internals.setFormValue('my default value'); } render() { return [

My name is {this.user}

,

Name changed {this.changeCount} time(s)

,

Method called {this.methodCalledCount} time(s)

,

Event triggered {this.eventCaughtCount} time(s)

, ]; } }