UNPKG

@ebay/ui-core-react

Version:

Skin components build off React

2 lines (1 loc) 2.94 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("../tslib.es6-C4EgNkz1.js"),e=require("react"),j=require("classnames"),E=require("../notice-content-C0ZStfuX.js"),D=require("../notice-content-9iF4T8uB.js"),O=require("../icon-I30uh1Ov.js"),$=require("../random-id-DlJj_RWH.js"),A=require("../utils-C9NL3q0j.js"),v=require("../icons/ebay-icon-lightbulb-24/index.js"),k=require("../icons/ebay-icon-attention-filled-16/index.js"),x=require("../icons/ebay-icon-confirmation-filled-16/index.js"),L=require("../icons/ebay-icon-information-filled-16/index.js"),P=require("../icons/ebay-icon-close-16/index.js"),N=require("../notice-footer-G6VPjVZu.js"),R=require("../notice-cta-CKl_qBge.js"),w={attention:k.EbayIconAttentionFilled16,confirmation:x.EbayIconConfirmationFilled16,information:L.EbayIconInformationFilled16},M=n=>{var{status:t="general",children:i,className:a,"aria-label":c,"aria-roledescription":C="Notice",a11yDismissText:u,educationIcon:f,iconClass:p,prominent:g,onDismiss:q=()=>{}}=n,S=y.__rest(n,["status","children","className","aria-label","aria-roledescription","a11yDismissText","educationIcon","iconClass","prominent","onDismiss"]);const[h,_]=e.useState(!1),[m,F]=e.useState("");e.useEffect(()=>{F($.randomId())},[]);const d=A.findComponent(i,E.EbayNoticeContent),s=t!=="general"&&t!=="none",r=t==="education";let o=null;const l={className:p,a11yText:c,a11yVariant:"label"};if(s)if(r)o=f||e.createElement(v.EbayIconLightbulb24,Object.assign({},l));else{const b=w[t];o=e.createElement(b,Object.assign({},l))}if(!d)throw new Error("EbaySectionNotice: Please use a EbayNoticeContent that defines the content of the notice");const T=b=>{_(!0),q(b)};return h?null:e.createElement("section",Object.assign({},S,{className:j(a,"section-notice",{[`section-notice--${t}`]:s,"section-notice--education":r&&g,"section-notice--large-icon":r}),"aria-label":s?null:c,"aria-labelledby":s?`section-notice-${t}-${m}`:null,"aria-roledescription":C}),o&&e.createElement("div",{className:"section-notice__header",id:`section-notice-${t}-${m}`},typeof o=="string"?e.createElement(O.EbayIcon,Object.assign({name:o},l)):o),e.createElement(D.NoticeContent,Object.assign({},d.props,{type:"section"})),i,u&&e.createElement(I,null,e.createElement("button",{"aria-label":u,className:"fake-link page-notice__dismiss",onClick:T},e.createElement(P.EbayIconClose16,null))))},V=n=>{var{className:t,as:i,children:a}=n,c=y.__rest(n,["className","as","children"]);return e.createElement(N.NoticeTitle,Object.assign({},c,{className:t,as:i,type:"section"}),a)},I=({className:n,children:t})=>e.createElement(N.NoticeFooter,{className:n,type:"section"},t),z=({className:n,children:t})=>e.createElement(R.NoticeCTA,{className:n,type:"section"},t);exports.EbayNoticeContent=E.EbayNoticeContent;exports.EbaySectionNotice=M;exports.EbaySectionNoticeCTA=z;exports.EbaySectionNoticeFooter=I;exports.EbaySectionNoticeTitle=V;