How to use the @dojo/widgets/time-picker.getOptions function in @dojo/widgets

To help you get started, we’ve selected a few @dojo/widgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dojo / widgets / src / examples / src / widgets / time-picker / FilteredOnInput.tsx View on Github external
export default factory(function Basic({ middleware: { icache } }) {
	const options = getOptions();

	function getFilteredOptions(value: string | undefined) {
		let matching: TimeUnits[] = [];

		if (value) {
			matching = options.filter((option) => {
				const { hour, minute = 0 } = option;
				const hours = hour >= 10 ? hour : `0${hour}`;
				const minutes = minute >= 10 ? minute : `0${minute}`;
				return `${hours}:${minutes}`.indexOf(value) === 0;
			});
		}

		return matching.length ? matching : options;
	}