lucid-ui
Version:
A UI component library from Xandr.
15 lines • 944 B
JavaScript
import _ from 'lodash';
import React, { useCallback } from 'react';
import { lucidClassNames } from '../../util/style-helpers';
const cx = lucidClassNames.bind('&-TimeSelect');
const TimeSelectInput = ({ className, value, step, name, disabled, onChange, }) => {
const cleanedValue = value !== null ? _.toString(value).padStart(2, '0') : '00';
const cleanOnChange = useCallback((event) => onChange(_.get(event, 'target.value', 0)), [onChange]);
const isDisabledClass = disabled ? '&-time-disabled' : '';
return (React.createElement("input", { className: cx('&-time', className, isDisabledClass), key: 'input', "aria-label": name, autoComplete: 'off', "data-input": 'true', disabled: disabled, max: 60, min: -15, name: name, onChange: cleanOnChange, step: step, type: 'number', value: cleanedValue }));
};
TimeSelectInput.defaultProps = {
step: 1,
};
export default TimeSelectInput;
//# sourceMappingURL=TimeSelectInput.js.map