import { Component } from 'preact'; type RowProps = { action?: (...args: any[]) => void; actionArgs?: any[]; buttonAction?: () => void; buttonClass?: string; buttonText?: string; desc?: string; disabled?: boolean; circle?: string; circleAlign?: string; faded?: boolean; hasButton?: boolean; label: string; spinnerClass?: string; stylekitClass?: string; subRows?: RowProps[]; subtitle?: string; }; type Props = RowProps; export class MenuRow extends Component { onClick = ($event: Event) => { if (this.props.disabled || !this.props.action) { return; } $event.stopPropagation(); if (this.props.actionArgs) { this.props.action(...this.props.actionArgs); } else { this.props.action(); } }; clickAccessoryButton = ($event: Event) => { if (this.props.disabled) { return; } $event.stopPropagation(); this.props.buttonAction?.(); }; render() { return (
{this.props.circle && (!this.props.circleAlign || this.props.circleAlign == 'left') && (
)}
{this.props.label}
{this.props.subtitle && (
{this.props.subtitle}
)} {this.props.children}
{this.props.subRows && this.props.subRows.length > 0 && (
{this.props.subRows.map((row) => { return ( ); })}
)}
{this.props.circle && this.props.circleAlign == 'right' && (
)} {this.props.hasButton && (
)} {this.props.spinnerClass && (
)}
); } }