UNPKG

fui-fancyui

Version:
97 lines (96 loc) 2.52 kB
"use client"; import { jsx as s, jsxs as L } from "react/jsx-runtime"; import T, { useState as A, useId as C, useEffect as H } from "react"; import M from "../../molecules/InputWrapper/InputWrapper.js"; import O from "../FancyNumberInput/FancyNumberInput.js"; import P from "../../../utils/functions/clampLayer/clampLayer.js"; import U from "../../atoms/RawSlider/RawSlider.js"; import q from "../../../design/designFunctions/countNegativLayerUpwards/countNegativLayerUpwards.js"; import { generateInputWrapperStyles as z, InputElementWrapper as D } from "./FancyRangeSlider.style.js"; function $(N) { const { id: o, label: S, layer: e = 2, onChange: n, systemMessage: i, max: u = 100, min: m = 0, transparentBackground: d, displayNumberInput: p = !1, icon: v, align: V, placeholder: R, themeType: c, outlined: W, outlinedBackgroundStrength: B, outlinedRemoveBorder: E, disabled: f, className: j, readOnly: y, ...k } = N, [r, l] = T.useState(0), [g, w] = A(!1), t = m ? Number(m) : 0, a = u ? Number(u) : 100, F = C(), h = o || F, b = (I) => { var x; l(Number((x = I.target) == null ? void 0 : x.value) ?? 0), w(!0), n == null || n(I); }; return H(() => { r > a && l(a), r < t && l(t); }, [a, t]), /* @__PURE__ */ s( M, { id: h, label: S, hasValue: g, outlined: W, outlinedBackgroundStrength: B, outlinedRemoveBorder: E, className: j, underline: !1, isActive: g, transparentBackground: d, externalStyle: z({ hasNumberInput: p }), disabled: f || y, placeholder: R, themeType: c, layer: e, align: V, labelVariant: "static", icon: v, systemMessage: i, InputElement: /* @__PURE__ */ L(D, { children: [ /* @__PURE__ */ s( U, { id: h, value: r, max: a, min: t, readOnly: y, onChange: b, themeType: c, layer: e ? P(e - 2) : 1, disabled: f, ...k } ), p && /* @__PURE__ */ s( O, { value: r, autoWidth: !0, layer: e ? q(e, 2) : 1, align: "center", max: a, min: t, onChange: b, transparentBackground: d, systemMessage: i } ) ] }) } ); } export { $ as default };