UNPKG

@ultraviolet/plus

Version:
32 lines (31 loc) 1 kB
"use client"; import { jsx } from "@emotion/react/jsx-runtime"; import { NumberInputV2 } from "@ultraviolet/ui"; import { useState, useEffect } from "react"; import { useOverlay } from "../OverlayContext.js"; import { ItemResourceName } from "../componentStyle.js"; import { Regular } from "./Regular.js"; const NumberInput = ({ amount, minValue = 0, maxValue = 100, getAmountValue, itemCallback, controls = true }) => { const { isOverlay } = useOverlay(); const [value, setValue] = useState(amount); useEffect(() => { getAmountValue?.(amount); }, [getAmountValue, amount]); return isOverlay ? /* @__PURE__ */ jsx(ItemResourceName, { animated: false, children: /* @__PURE__ */ jsx(Regular, { children: amount }) }) : /* @__PURE__ */ jsx(NumberInputV2, { min: minValue, max: maxValue, size: "small", onChange: (newValue) => { setValue(newValue); itemCallback?.(newValue, true); getAmountValue?.(newValue); }, value, controls }); }; export { NumberInput };