UNPKG

hrnet-select-p14

Version:

Composant React de sélection pour HRnet, conversion d'un plugin jQuery.

19 lines (18 loc) 1.58 kB
import './select-p14.css'; import e, { useState as p } from "react"; import l from "prop-types"; const d = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.16108%2010.0731C4.45387%209.2649%205.02785%208%206.1018%208H17.898C18.972%208%2019.5459%209.2649%2018.8388%2010.0731L13.3169%2016.3838C12.6197%2017.1806%2011.3801%2017.1806%2010.6829%2016.3838L5.16108%2010.0731ZM6.65274%209.5L11.8118%2015.396C11.9114%2015.5099%2012.0885%2015.5099%2012.1881%2015.396L17.3471%209.5H6.65274Z'%20fill='%23212121'/%3e%3c/svg%3e", g = ({ options: o, onChange: r, defaultValue: n, placeholder: i }) => { const [s, c] = p(!1), m = (t, a) => { t.preventDefault(), r(a), c(!1); }; return /* @__PURE__ */ e.createElement("div", { className: "custom-select", onClick: () => c(!s) }, /* @__PURE__ */ e.createElement("div", { className: "select-selected" }, n || i, /* @__PURE__ */ e.createElement("img", { src: d, alt: "caret", className: "select-caret" })), s && /* @__PURE__ */ e.createElement("ul", { className: "select-items" }, o.map((t) => /* @__PURE__ */ e.createElement("li", { key: t.id }, /* @__PURE__ */ e.createElement("a", { href: "", onClick: (a) => m(a, t.value) }, t.value))))); }; g.propTypes = { options: l.array, onChange: l.func, defaultValue: l.string, placeholder: l.string }; export { g as Select };