UNPKG

@zeix/ui-element

Version:

UIElement - a HTML-first library for reactive Web Components

32 lines (28 loc) 507 B
import { type Component, asInteger, component, fromEvents, setText, } from '../../..' export type BasicCounterProps = { count: number } export default component( 'basic-counter', { count: fromEvents( el => asInteger()(el, el.querySelector('span')?.textContent), 'button', { click: ({ value }) => ++value, }, ), }, (_, { first }) => [first('span', setText('count'))], ) declare global { interface HTMLElementTagNameMap { 'basic-counter': Component<BasicCounterProps> } }