UNPKG

@anoki/fse-marche-ui

Version:

FSE UI components library

80 lines (79 loc) 2.57 kB
import { j as e } from "./index.es137.js"; import { clsx as a } from "./index.es139.js"; import './components/ui/FilterDropDown/FilterDropDown.css';/* empty css */ import { ArrowDown as f } from "./index.es76.js"; import { useState as x, useRef as w, useMemo as h, useEffect as j } from "react"; import { ArrowList as v } from "./index.es162.js"; import { Col as N } from "./index.es10.js"; const L = ({ size: m, items: n = [], className: d, filter: c, setFilter: u, allStructuresLabel: l }) => { const [s, o] = x(!1), t = w(null), p = h(() => [l, ...n], [n, l]); return j(() => { const r = (i) => { t.current && !t.current.contains(i.target) && o(!1); }; return s ? document.addEventListener("mousedown", r) : document.removeEventListener("mousedown", r), () => { document.removeEventListener("mousedown", r); }; }, [s]), /* @__PURE__ */ e.jsxs( "div", { ref: t, style: m === "large" ? { width: "668px" } : { width: "322px" }, className: a(d, "ui-filter-dropdown"), children: [ /* @__PURE__ */ e.jsxs( "button", { className: "ui-button-accordion", type: "button", onClick: () => o(!s), children: [ /* @__PURE__ */ e.jsx("h3", { className: "fw-semibold fs-custom text-primary", children: c }), /* @__PURE__ */ e.jsx( f, { color: "primary", className: a("ui-arrow", { "ui-expanded": s }) } ) ] } ), s && /* @__PURE__ */ e.jsxs("div", { className: "ui-wrap-list-item-filter position-relative pt-x12", children: [ /* @__PURE__ */ e.jsx(v, { className: "ui-arrow-list position-absolute" }), /* @__PURE__ */ e.jsx("div", { className: "p-x24 h-full shadow", children: /* @__PURE__ */ e.jsx( N, { gap: "x24", text: "primary", fs: "custom", fw: "regular", className: "ui-list-item-filter h-full overflow fw-regular", children: p.map((r, i) => /* @__PURE__ */ e.jsx( "div", { onClick: () => { u(r), o(!1); }, children: r }, i )) } ) }) ] }) ] } ); }; export { L as FilterDropDown }; //# sourceMappingURL=index.es23.js.map