carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 1.93 kB
JavaScript
import{jsx as e,jsxs as r,Fragment as t}from"react/jsx-runtime";import n,{useRef as o}from"react";import i from"../../../__internal__/utils/helpers/guid/index.js";import c from"../../../__internal__/utils/logger/index.js";import l from"./option-group-header.style.js";import p from"../../icon/icon.component.js";function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}const u=n.forwardRef(((n,u)=>{var{label:f,icon:s,style:b,id:O,children:y}=n,d=function(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}(n,["label","icon","style","id","children"]);const m=o(O||i());return y||f||c.warn("OptionGroupHeader requires either a label or children to be provided"),e(l,(j=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),n.forEach((function(r){a(e,r,t[r])}))}return e}({style:b,id:m.current},d),g=null!=(g={ref:u,"data-component":"option-group-header",children:y||r(t,{children:[s&&e(p,{type:s}),e("h4",{children:f})]})})?g:{},Object.getOwnPropertyDescriptors?Object.defineProperties(j,Object.getOwnPropertyDescriptors(g)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(g)).forEach((function(e){Object.defineProperty(j,e,Object.getOwnPropertyDescriptor(g,e))})),j));var j,g}));u.displayName="OptionGroupHeader";export{u as default};