mithril-materialized
Version:
A materialize library for mithril.
46 lines (45 loc) • 1.48 kB
TypeScript
import { Component, Attributes } from 'mithril';
export interface IDropdownOption<T extends string | number> {
/** ID property of the selected item */
id?: T;
/** Label to show in the dropdown */
label: string;
/** Can we select the item */
disabled?: boolean;
/** Display a Materials Icon in front of the label */
iconName?: string;
/** Add a divider */
divider?: boolean;
}
export interface IDropdownOptions<T extends string | number> extends Partial<M.DropdownOptions>, Attributes {
/**
* Optional id of the dropdown element
* @default 'dropdown'
*/
id?: T;
/**
* Optional label when no item is selected
* @default 'Select'
*/
label?: string;
key?: string | number;
/** If true, disable the selection */
disabled?: boolean;
/** Item array to show in the dropdown. If the value is not supplied, uses he name. */
items: IDropdownOption<T>[];
/**
* Selected value or name
* @deprecated Use initialValue instead
*/
checkedId?: T;
/** Selected value or name */
initialValue?: T;
/** When a value or name is selected */
onchange?: (value: T) => void;
/** Uses Materialize icons as a prefix or postfix. */
iconName?: string;
/** Add a description underneath the input field. */
helperText?: string;
}
/** Dropdown component */
export declare const Dropdown: <T extends string | number>() => Component<IDropdownOptions<T>>;