UNPKG

geostyler

Version:
102 lines (101 loc) 2.47 kB
import { jsx as t, jsxs as e, Fragment as I } from "react/jsx-runtime"; import { useState as S, useEffect as j } from "react"; import { Slider as k, InputNumber as b, Button as N } from "antd"; import { FunctionUI as w } from "../../FunctionUI/FunctionUI.js"; import { isGeoStylerFunction as l } from "geostyler-style"; import { FunctionOutlined as x } from "@ant-design/icons"; /* empty css */ const z = ({ slider: V = !1, sliderProps: f = {}, /* more safety */ onChange: r, onCancel: p, value: i, className: d, inputProps: y = {}, /* more safety */ functionUiProps: F }) => { let u = "number-expression-input"; d && (u += ` ${d}`); const [o, c] = S(() => l(i) ? void 0 : i); return j(() => { l(i) || c(i); }, [i]), l(i) ? /* @__PURE__ */ t("span", { className: u, children: /* @__PURE__ */ t( w, { type: "number", value: i, ...F, onChange: r, onCancel: () => p == null ? void 0 : p("number") } ) }) : /* @__PURE__ */ t("span", { className: u, children: V ? /* @__PURE__ */ e("div", { className: "slider-wrapper", children: [ /* @__PURE__ */ t( k, { ...f, value: o, range: !1, onChange: (s) => { const m = s === null ? void 0 : Number(s); r == null || r(m), c(m); } } ), /* @__PURE__ */ e("div", { className: "number-wrapper", children: [ /* @__PURE__ */ t( b, { ...f, value: o, onChange: (s) => { const m = s === null ? void 0 : Number(s); r == null || r(m), c(m); } } ), /* @__PURE__ */ t( N, { icon: /* @__PURE__ */ t(x, {}), onClick: () => { r == null || r({ name: "property", args: [""] }); } } ) ] }) ] }) : /* @__PURE__ */ e(I, { children: [ /* @__PURE__ */ t( b, { value: i, onChange: (s) => { const m = s === null ? void 0 : Number(s); r == null || r(m); }, ...y } ), /* @__PURE__ */ t( N, { icon: /* @__PURE__ */ t(x, {}), onClick: () => { r == null || r({ name: "property", args: [""] }); } } ) ] }) }); }; export { z as NumberExpressionInput, z as default };