hrnet-select-p14
Version:
Composant React de sélection pour HRnet, conversion d'un plugin jQuery.
2 lines (1 loc) • 1.63 kB
JavaScript
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react"),require("prop-types")):typeof define=="function"&&define.amd?define(["exports","react","prop-types"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.SelectP14={},t.React,t.PropTypes))})(this,function(t,e,n){"use strict";const r="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",c=({options:a,onChange:p,defaultValue:d,placeholder:m})=>{const[i,o]=e.useState(!1),u=(s,l)=>{s.preventDefault(),p(l),o(!1)};return e.createElement("div",{className:"custom-select",onClick:()=>o(!i)},e.createElement("div",{className:"select-selected"},d||m,e.createElement("img",{src:r,alt:"caret",className:"select-caret"})),i&&e.createElement("ul",{className:"select-items"},a.map(s=>e.createElement("li",{key:s.id},e.createElement("a",{href:"",onClick:l=>u(l,s.value)},s.value)))))};c.propTypes={options:n.array,onChange:n.func,defaultValue:n.string,placeholder:n.string},t.Select=c,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});