diff --git a/package-lock.json b/package-lock.json index dad8c2c..a4b339c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "foris", - "version": "0.1.0-beta.7", + "version": "0.1.0-beta.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0646b86..c2ded42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foris", - "version": "0.1.0-beta.7", + "version": "0.1.0-beta.8", "description": "Set of components and utils for Foris and its plugins.", "author": "CZ.NIC, z.s.p.o.", "repository": { diff --git a/src/bootstrap/NumberInput.js b/src/bootstrap/NumberInput.js index 63139da..e841622 100644 --- a/src/bootstrap/NumberInput.js +++ b/src/bootstrap/NumberInput.js @@ -6,8 +6,9 @@ */ import React from "react"; - import PropTypes from "prop-types"; + +import { useConditionalTimeout } from "utils/hooks"; import { Input } from "./Input"; import "./NumberInput.css"; @@ -33,15 +34,25 @@ NumberInput.defaultProps = { value: 0, }; -export function NumberInput({ onChange, inlineText, ...props }) { +export function NumberInput({ + onChange, inlineText, value, ...props +}) { + function updateValue(initialValue, difference) { + onChange({ target: { value: initialValue + difference } }); + } + + const enableIncrease = useConditionalTimeout({ callback: updateValue }, value, 1); + const enableDecrease = useConditionalTimeout({ callback: updateValue }, value, -1); + return ( - +
{inlineText &&

{inlineText}

}