Skip to content
API

Methods

Available methods on TimepickerUI instance

create()

Initialize the timepicker. Must be called before using other methods.

index.tstypescript
1const picker = new TimepickerUI(input);
2picker.create();

open(callback?)

Open the timepicker modal programmatically.

index.tstypescript
1picker.open();
2
3picker.open(() => {
4 console.log('Picker opened');
5});

close(updateInput?, callback?)

Close the timepicker modal.

index.tstypescript
1picker.close();
2
3picker.close(true, () => {
4 console.log('Picker closed with update');
5});

getValue()

Get current selected time value.

index.tstypescript
1const value = picker.getValue();
2
3{
4 hour: '10',
5 minutes: '30',
6 type: 'AM',
7 time: '10:30 AM',
8 degreesHours: 300,
9 degreesMinutes: 180
10}

setValue(time, updateInput?)

Set time value programmatically.

index.tstypescript
1picker.setValue('10:30 AM');
2
3picker.setValue('15:45', false);

update(options, callback?)

Update picker options dynamically.

index.tstypescript
1picker.update({
2 options: {
3 ui: {
4 theme: 'dark'
5 },
6 clock: {
7 type: '24h'
8 }
9 },
10 create: true
11}, () => {
12 console.log('Updated');
13});

destroy(options?)

Destroy the picker instance and clean up.

index.tstypescript
1picker.destroy();
2
3picker.destroy({
4 keepInputValue: true,
5 callback: () => console.log('Destroyed')
6});

getElement()

Get the root wrapper element.

index.tstypescript
const wrapper = picker.getElement();

Static Methods

TimepickerUI.getById(id)

index.tstypescript
1const picker = new TimepickerUI(input, { id: 'my-picker' });
2picker.create();
3
4const instance = TimepickerUI.getById('my-picker');

TimepickerUI.getAllInstances()

index.tstypescript
1const allPickers = TimepickerUI.getAllInstances();
2console.log(allPickers.length);

TimepickerUI.destroyAll()

index.tstypescript
TimepickerUI.destroyAll();

TimepickerUI.isAvailable(selector)

index.tstypescript
1if (TimepickerUI.isAvailable('#timepicker')) {
2 console.log('Element exists in DOM');
3}