UNPKG

geostyler

Version:
67 lines (66 loc) 2.06 kB
import { jsx as i } from "react/jsx-runtime"; import { useRef as C, useState as h, useLayoutEffect as I } from "react"; import { Form as b, AutoComplete as L, Input as D } from "antd"; import T from "lodash-es/get.js"; /* empty css */ import { useGeoStylerData as k, useGeoStylerLocale as w } from "../../../context/GeoStylerContext/GeoStylerContext.js"; const _ = ({ value: a, validateStatus: u = "success", onValueChange: s, selectedAttribute: S, size: p }) => { var d; const r = k(), l = w("TextFilterField"), t = C(void 0), [f, g] = h(0), [m, x] = h(0); I(() => { t && t.current && t.current.input && (t.current.input.selectionStart = f, t.current.input.selectionEnd = m); }, [f, m, a]); const F = (e) => { s && s(e.target.value); }, E = (e) => { s && s(e); }, y = u !== "success" ? l.help : null, c = []; return r && "exampleFeatures" in r && ((d = r == null ? void 0 : r.exampleFeatures) == null ? void 0 : d.features).forEach((o) => { const n = T(o, `properties[${S}]`); n && c.indexOf(n) === -1 && c.push(n); }), /* @__PURE__ */ i("div", { className: "gs-text-filter-field", children: /* @__PURE__ */ i( b.Item, { label: l.label, colon: !1, validateStatus: u, help: y, hasFeedback: !0, children: c.length > 0 ? /* @__PURE__ */ i( L, { size: p, value: a, onChange: E, placeholder: l.placeholder, dataSource: c, filterOption: (e, o) => typeof e != "string" ? !1 : o.key.toLowerCase().includes(e.toLowerCase()) } ) : /* @__PURE__ */ i( D, { size: p, ref: t, draggable: !0, onDragStart: (e) => e.preventDefault(), value: a, onChange: (e) => { F(e); const o = e.target.selectionStart, n = e.target.selectionEnd; g(o), x(n); }, placeholder: l.placeholder } ) } ) }); }; export { _ as TextFilterField };