1.0.6 • Published 6 years ago

@adler-it/webstack-dialog v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Classes

DialogConfig

Definitions

function validate<T>(value: T) => boolean | string

Return true if ok, otherwise error message.

Method

NameArgumentsReturn TypeDescription
setWidth(width: string)DialogConfigSet modal width.
addNumber(label: string, key: string, validator: validate\<number>, defaultValue: number, readOnly: boolean, editable: boolean)DialogConfigAdd Number input to Dialog.
addBoolen(label: string, key: string, defaultValue: boolean, editable: boolean)DialogConfigAdd Boolean input to Dialog.
addDate(label: string, key: string, defaultValue: Date, validator: validate\<Date>, readOnly: boolean, editable: boolean)DialogConfigAdd Date input to Dialog.
addTime(label: string, key: string, defaultValue: Date, validator: validate\<Date>, readonly: boolean, editable: boolean)DialogConfigAdd Time input to Dialog.
addSelect(label: string, key: string, options: {id: number, name: string}, defaultValue: number, validator: validate\<number>, multiple: boolean, readOnly: boolean, editable: boolean)DialogConfigAdd Select input to Dialog.
addAuto(label: string, key: string, options: string[], defaultValue: string, validator: validate\<string>, readOnly: boolean, editable: boolean)DialogConfigAdd String with autocomplete input to Dialog.
addText(label: string, key: string, defaultValue: string, validator: validate\<string>, readOnly: boolean, editable: boolean)DialogConfigAdd long String input to Dialog.
addString(label: string, key: string, defaultValue: string, validator: validate\<string>, readOnly: boolean, editable: boolean)DialogConfigAdd String input to Dialog.

Components

Dialog

Properties

NameTypeDefaultDescription

Method

NameArgumentsReturn TypeDescription
showconsifg: DialogConfig, onResult: (result: object) => voidvoidDialog will popup with given settings, then on user input onResult is called with result object.
hidevoidClose dialog and clear it.

Usage

import { DialogConfig, Dialog } from 'webstack-dialog'
...
class CustomComponent extend Component {
	handleClick = () => {
		const conf = new DialogConfig('Write your details')
			.addString('FirstName', 'firstName')
			.addString('LastName', 'lastName')
			.addNumber('Age', 'age', value => value < 18? 'Age must be 18 or above!' : false, 18)
			.addSelect('Gender', 'gender', [{id: 0, label: 'male'}, {id: 2, label: 'female'}], value => value? true : 'required')
			.addAuto('Birthplace', 'birthplace', ['Czeckia','Japan', '...'], '')

		this._dialog.show(conf, result => {
			//result === { firstName: ?, lastName: ?, age: ?,  gender: ?, birthplace: ?}
			this._dialog.hide();
		})
	}
	render() {
		return (
			<div>
				<FlatButton onClick={this.handleClick}>
				<Dialog ref={i = this._dialog = i}/>
			</div>
		)
	}
} 
...
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago