diff --git a/README.md b/README.md index 336ec6b..a033019 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ import TimeField from 'react-simple-timefield'; value={time} // {String} required, format '00:00' or '00:00:00' onChange={(event, value) => {...}} // {Function} required input={} // {Element} default: + inputRef={(ref) => {...}} // {Function} input's ref colon=":" // {String} default: ":" showSeconds // {Boolean} default: false /> @@ -86,11 +87,15 @@ in `demo/index.tsx` file. ```bash # run development mode cd demo +npm install +npm install --only=dev npm run dev ``` #### Build: ```bash +npm install +npm install --only=dev npm test npm run format npm run build diff --git a/src/index.tsx b/src/index.tsx index 5603fcd..8b711ff 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -64,6 +64,7 @@ interface Props { onChange?: onChangeType; showSeconds?: boolean; input: ReactElement | null; + inputRef?: () => HTMLInputElement | null; colon?: string; style?: CSSProperties | {}; } @@ -196,7 +197,7 @@ export default class TimeField extends React.Component { render(): ReactElement { const {value} = this.state; - const {onChange, style, showSeconds, input, colon, ...props} = this.props; //eslint-disable-line no-unused-vars + const {onChange, style, showSeconds, input, inputRef, colon, ...props} = this.props; //eslint-disable-line no-unused-vars const onChangeHandler = (event: ChangeEvent) => this.onInputChange(event, (e: ChangeEvent, v: string) => onChange && onChange(e, v)); @@ -213,6 +214,7 @@ export default class TimeField extends React.Component {