UNPKG

jb-number-input-react

Version:
69 lines (65 loc) 2.73 kB
'use strict'; var React = require('react'); require('jb-number-input'); var jbInputReact = require('jb-input-react'); // eslint-disable-next-line react/display-name const JBNumberInput = React.forwardRef((props, ref) => { const element = React.useRef(null); const [refChangeCount, refChangeCountSetter] = React.useState(0); React.useImperativeHandle(ref, () => (element ? element.current : {}), [element]); //to force rerender for events React.useEffect(() => { refChangeCountSetter(refChangeCount + 1); }, [element.current]); jbInputReact.useJBInputAttribute(element, props); jbInputReact.useJBInputEvents(element, props); React.useEffect(() => { if (element?.current) { element.current.minValue = props.minValue; } }, [props.minValue]); React.useEffect(() => { if (element.current) { element.current.maxValue = props.maxValue; } }, [props.maxValue]); React.useEffect(() => { if (element.current && props.acceptNegative !== undefined) { element.current.acceptNegative = props.acceptNegative; } }, [props.acceptNegative]); React.useEffect(() => { if (element.current) { element.current.decimalPrecision = props.decimalPrecision; } }, [props.decimalPrecision]); React.useEffect(() => { if (element.current && typeof props.showControlButton == "boolean") { element.current.showControlButton = props.showControlButton; } }, [props.showControlButton]); React.useEffect(() => { if (element.current && typeof props.showThousandSeparator == "boolean") { element.current.showThousandSeparator = props.showThousandSeparator; } }, [props.showThousandSeparator]); React.useEffect(() => { if (element.current && typeof props.thousandSeparator == "string") { element.current.thousandSeparator = props.thousandSeparator; } }, [props.thousandSeparator]); React.useEffect(() => { if (element.current && typeof props.step == "number") { element.current.step = props.step; } }, [props.step]); React.useEffect(() => { if (element.current && typeof props.showPersianNumber == "boolean") { element.current.showPersianNumber = props.showPersianNumber; } }, [props.showPersianNumber]); return (React.createElement("jb-number-input", { ref: element, class: props.className }, props.children)); }); JBNumberInput.displayName = "JBNumberInput"; exports.JBNumberInput = JBNumberInput; //# sourceMappingURL=JBNumberInput.cjs.js.map