UNPKG

carbon-react

Version:

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

2 lines (1 loc) 3.07 kB
import{jsxs as e,jsx as t}from"react/jsx-runtime";import"react";import"../../style/utils/filter-styled-system-padding-props.js";import r from"../../style/utils/filter-styled-system-margin-props.js";import n from"../../__internal__/utils/helpers/tags/tags.js";import{StyledHeading as i,StyledHeader as a,StyledHeaderContent as l,StyledHeadingTitle as o,StyledSeparator as c,StyledDivider as s,StyledHeadingBackButton as d,StyledHeadingIcon as p,StyledSubHeader as u,StyledHeaderHelp as b,StyledHeadingPills as h}from"./heading.style.js";import f from"../../hooks/__internal__/useLocale/useLocale.js";function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){y(e,t,r[t])}))}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const O=y=>{var{children:O,backLink:j,divider:k=!0,help:v,helpAriaLabel:P,helpLink:w,pills:L,separator:_=!1,subheader:S,subtitleId:D,headingType:I="h1",title:x,titleId:A}=y,E=function(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}(y,["children","backLink","divider","help","helpAriaLabel","helpLink","pills","separator","subheader","subtitleId","headingType","title","titleId"]);const T=f(),B=r(E);return x?e(i,g(m({},n("heading",E),B),{children:[e(a,{"data-element":"header-container",divider:k,subheader:!!S,hasBackLink:!!j,children:[j&&(()=>{const e="string"==typeof j?{href:j}:{onClick:j};return t(d,g(m({"aria-label":T.heading.backLinkAriaLabel(),"data-element":"back","data-role":"heading-back-button",onMouseDown:e=>e.currentTarget.focus({preventScroll:!0})},e),{children:t(p,{type:"chevron_left"})}))})(),e(l,{children:[t(o,{withMargin:!!L||!!v,variant:I,"data-element":"title",id:A,children:x}),(v||w)&&t(b,{"data-element":"help",tooltipPosition:"right",href:w,ariaLabel:P,children:v}),L&&t(h,{"data-element":"pills","data-role":"heading-pills-container",children:L})]}),_&&t(c,{"data-role":"heading-separator"}),S&&t(u,{"data-element":"subtitle","data-role":"subtitle",id:D,hasBackLink:!!j,hasSeparator:_,children:S})]}),k&&t(s,{"data-element":"divider","data-role":"heading-divider"}),O]})):null};export{O as Heading,O as default};