UNPKG

@anoki/fse-ui

Version:

FSE UI components library

106 lines (105 loc) 3.28 kB
import { j as a } from "./index.es237.js"; import './components/ui/SearchDocument/SearchDocument.css';/* empty css */ import { clsx as n } from "./index.es239.js"; import { useState as u } from "react"; import { Close as C } from "./index.es179.js"; import { Col as N } from "./index.es61.js"; import { Button as y } from "./index.es32.js"; const V = ({ btnText: d, helperText: f, value: x, items: b, setValue: g }) => { const [c, h] = u(x), [p, o] = u([]), j = (e) => { const s = e.target.value; if (h(s), s.length >= 3) { const t = b.filter( (r) => { var l, i; return [(i = (l = r.classification) == null ? void 0 : l.type) == null ? void 0 : i.label].some( (m) => m == null ? void 0 : m.toLowerCase().includes(s.toLowerCase()) ); } ); o(t); } else o([]); }, w = (e) => { var s, t; h((t = (s = e.classification) == null ? void 0 : s.type) == null ? void 0 : t.label), o([]); }, v = (e, s) => { if (!s) return e; const t = e.toLowerCase().indexOf(s.toLowerCase()); if (t === -1) return e; const r = e.slice(0, t), l = e.slice(t, t + s.length), i = e.slice(t + s.length); return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [ r, /* @__PURE__ */ a.jsx("span", { className: "text-primary fw-bold", children: l }), i ] }); }; return /* @__PURE__ */ a.jsxs("div", { className: n("ui-search", "br-x4 bg-border-secondary w-full"), children: [ /* @__PURE__ */ a.jsxs("div", { className: "position-relative", children: [ /* @__PURE__ */ a.jsx( "input", { id: "search", type: "search", className: n( "ui-search-input", "fs-6 text-slate-20 br-x4 w-full pl-x24" ), placeholder: f, "aria-label": "Barra di ricerca", value: c, onChange: j } ), c && c.length >= 3 && /* @__PURE__ */ a.jsx( C, { className: "ui-clean-button", onClick: () => { h(""), o([]); } } ) ] }), p.length > 0 && /* @__PURE__ */ a.jsx("div", { className: "ui-wrap-list-item-search shadow position-absolute p-x24", children: /* @__PURE__ */ a.jsx( N, { gap: "x24", fw: "regular", text: "secondary", fs: "6", className: "ui-list-item-search overflow-y-auto ", children: p.map((e, s) => { var t, r, l, i; return /* @__PURE__ */ a.jsx("div", { onClick: () => w(e), children: (r = (t = e.classification) == null ? void 0 : t.type) != null && r.label ? v( (i = (l = e.classification) == null ? void 0 : l.type) == null ? void 0 : i.label, c || "" ) : "" }, s); }) } ) }), /* @__PURE__ */ a.jsx("div", { className: n("ui-div-btn"), children: /* @__PURE__ */ a.jsx( y, { className: n( "ui-btn-search", "bg-primary text-white fs-7 fw-semibold br-x4" ), onClick: () => { o([]), g(c ?? ""); }, children: d } ) }) ] }); }; export { V as SearchDocument }; //# sourceMappingURL=index.es118.js.map