carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 2.2 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../../__internal__/utils/helpers/guid/index.js"),o=require("../../../__internal__/utils/helpers/tags/tags.js"),n=require("./simple-color.style.js");function l(e){return e&&e.__esModule?e:{default:e}}function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function a(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){c(e,r,t[r])}))}return e}const i=l(r).default.forwardRef(((l,c)=>{const{onChange:i,onBlur:u,onMouseDown:s,value:p,name:f,checked:y=!1,id:b,className:d,"aria-label":O}=l,j=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}(l,["onChange","onBlur","onMouseDown","value","name","checked","id","className","aria-label"]),{current:m}=r.useRef(b||t.default());return e.jsxs(n.StyledSimpleColor,(g=a({className:d},o.default("simple-color",l)),h=null!=(h={children:[e.jsx(n.StyledSimpleColorInput,a({onChange:i,onBlur:u,onMouseDown:s,checked:y,name:f,"aria-label":O,type:"radio",role:"radio",value:p,ref:c,id:m},j)),e.jsx(n.StyledColorSampleBox,{color:p,children:y&&e.jsx(n.StyledTickIcon,{color:p,type:"tick"})})]})?h:{},Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(h)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(h)).forEach((function(e){Object.defineProperty(g,e,Object.getOwnPropertyDescriptor(h,e))})),g));var g,h}));i.displayName="SimpleColor",exports.SimpleColor=i,exports.default=i;