mithril-materialized
Version:
A materialize library for mithril.
61 lines (60 loc) • 2.21 kB
TypeScript
import { Vnode, FactoryComponent, Attributes, Component } from 'mithril';
export interface IInputCheckbox extends Attributes {
/** Optional event handler when a checkbox is clicked */
onchange?: (checked: boolean) => void;
/** Label of the checkbox, can be a string or Vnode */
label?: string | Vnode<any, any>;
/** If true, the checkbox is checked */
checked?: boolean;
/** If true, the checkbox is disabled */
disabled?: boolean;
}
/** Component to show a check box */
export declare const InputCheckbox: FactoryComponent<IInputCheckbox>;
export interface IInputOption<T extends string | number> {
/** Option ID */
id: T;
/** Displayed label */
label: string;
/** Optional title, often used to display a tooltip - will only work when choosing browser-defaults */
title?: string;
/** Is the option disabled? */
disabled?: boolean;
/** Select image */
img?: string;
/** Select group label */
group?: string;
/** Optional class name */
className?: string;
/** Optional description */
description?: string;
}
export interface IOptions<T extends string | number> extends Attributes {
/** Element ID */
id?: string;
/** Optional title or label */
label?: string;
/** The options that you have */
options: IInputOption<T>[];
/** Event handler that is called when an option is changed */
onchange?: (checkedId: T[]) => void;
/**
* Selected id or ids (in case of multiple options)
* @deprecated Please use initialValue instead
*/
checkedId?: T | T[];
/** Selected id or ids (in case of multiple options) */
initialValue?: T | T[];
/** Optional description */
description?: string;
/** Optional CSS that is added to the input checkbox, e.g. if you add col s4, the items will be put inline */
checkboxClass?: string;
/** If true, start on a new row */
newRow?: boolean;
/** If true, add a mandatory '*' after the label */
isMandatory?: boolean;
/** If true, disable the options. */
disabled?: boolean;
}
/** A list of checkboxes */
export declare const Options: <T extends string | number>() => Component<IOptions<T>>;