UNPKG

carbon-react

Version:

A library of reusable React components for easily building user interfaces.

2 lines (1 loc) 2.08 kB
import{jsxs as e,jsx as r}from"react/jsx-runtime";import t,{useRef as o}from"react";import n from"../../../__internal__/utils/helpers/guid/index.js";import l from"../../../__internal__/utils/helpers/tags/tags.js";import{StyledSimpleColor as c,StyledSimpleColorInput as a,StyledColorSampleBox as i,StyledTickIcon as s}from"./simple-color.style.js";function u(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){u(e,r,t[r])}))}return e}const f=t.forwardRef(((t,u)=>{const{onChange:f,onBlur:b,onMouseDown:m,value:O,name:y,checked:j=!1,id:d,className:g,"aria-label":h}=t,w=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},l=Object.keys(e);for(o=0;o<l.length;o++)t=l[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)t=l[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(t,["onChange","onBlur","onMouseDown","value","name","checked","id","className","aria-label"]),{current:P}=o(d||n());return e(c,(v=p({className:g},l("simple-color",t)),_=null!=(_={children:[r(a,p({onChange:f,onBlur:b,onMouseDown:m,checked:j,name:y,"aria-label":h,type:"radio",role:"radio",value:O,ref:u,id:P},w)),r(i,{color:O,children:j&&r(s,{color:O,type:"tick"})})]})?_:{},Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(_)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(_)).forEach((function(e){Object.defineProperty(v,e,Object.getOwnPropertyDescriptor(_,e))})),v));var v,_}));f.displayName="SimpleColor";export{f as SimpleColor,f as default};