import { ComponentConfig, Component } from '../Component';
import { DOM } from '../../DOM';
import { EventDispatcher, Event, NoArgs } from '../../EventDispatcher';
import { LocalizableText, i18n } from '../../localization/i18n';
import { Icon } from '../Icon';
export enum LabelStyle {
/**
* Only display the label text.
*/
Text = 'text',
/**
* Display the label with an icon and text.
* The Icon is displayed before the text.
*/
TextWithLeadingIcon = 'text-icon-leading',
/**
* Display the label with an icon and text.
* The Icon is displayed after the text.
*/
TextWithTrailingIcon = 'text-icon-trailing',
}
/**
* Configuration interface for a {@link Label} component.
*
* @category Configs
*/
export interface LabelConfig extends ComponentConfig {
/**
* The text as string or localize callback on the label.
*/
text?: LocalizableText;
/**
* WCAG20 standard: Associate label to form control.
*/
for?: string;
/**
* The style of the label.
* Default: {@link LabelStyle.Text}
*/
labelStyle?: LabelStyle;
}
/**
* A text label with optional icon.
*
* DOM example:
*
*
* ...some text...
*
*
*
* @category Components
*/
export class Label extends Component {
private text: LocalizableText;
private textElement: DOM | null = null;
private labelEvents = {
onClick: new EventDispatcher