UNPKG

geostyler

Version:
71 lines (70 loc) 2.33 kB
import { jsx as o, jsxs as f } from "react/jsx-runtime"; import { useState as c, useEffect as a } from "react"; import { NumberExpressionInput as b } from "../../ExpressionInput/NumberExpressionInput/NumberExpressionInput.js"; import { StringExpressionInput as d } from "../../ExpressionInput/StringExpressionInput/StringExpressionInput.js"; import { BooleanExpressionInput as y } from "../../ExpressionInput/BooleanExpressionInput/BooleanExpressionInput.js"; import { isGeoStylerNumberFunction as S, isGeoStylerBooleanFunction as x } from "geostyler-style"; /* empty css */ import { Tooltip as N, Select as w } from "antd"; import { FieldStringOutlined as F, FieldNumberOutlined as I, FieldBinaryOutlined as k } from "@ant-design/icons"; import { useGeoStylerLocale as E } from "../../../context/GeoStylerContext/GeoStylerContext.js"; const z = ({ value: t, onChange: e, forcedType: m, inputProps: l }) => { const p = E("UnknownInput"), [s, i] = c(m || "string"); a(() => { typeof t == "number" || S(t) ? i("number") : typeof t == "boolean" || x(t) ? i("boolean") : i("string"); }, [t]); let n = /* @__PURE__ */ o( d, { onChange: e, onCancel: () => e(void 0), value: t, inputProps: l } ); s === "number" ? n = /* @__PURE__ */ o( b, { onChange: e, onCancel: () => e(void 0), value: t, inputProps: l } ) : s === "boolean" && (n = /* @__PURE__ */ o( y, { onChange: e, onCancel: () => e(void 0), value: t, switchProps: l } )); const u = (r) => { i(r), r === "string" ? e("") : r === "number" ? e(0) : r === "boolean" && e(!1); }; return m ? /* @__PURE__ */ o("div", { className: "gs-unknown-input", children: n }) : /* @__PURE__ */ f("div", { className: "gs-unknown-input", children: [ n, /* @__PURE__ */ o(N, { title: p.typeSelectToolip, children: /* @__PURE__ */ o( w, { className: "gs-type-select", options: [ { label: /* @__PURE__ */ o(F, {}), value: "string" }, { label: /* @__PURE__ */ o(I, {}), value: "number" }, { label: /* @__PURE__ */ o(k, {}), value: "boolean" } ], value: s, onChange: u } ) }) ] }); }; export { z as UnknownInput, z as default };