@ebay/ui-core-react
Version:
Skin components build off React
2 lines (1 loc) • 2.99 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../tslib.es6-BW4cJBUu.js"),e=require("react"),v=require("classnames"),g=require("../utils-C9NL3q0j.js"),r=require("../use-tooltip-DEDSLeBq.js"),L=require("../dialog-previous-button-DVRDk2rt.js");require("react-remove-scroll");require("makeup-screenreader-trap");require("makeup-keyboard-trap");const U=require("../icon-M7M42naA.js");require("../icon-button-BeoRawG2.js");const z=require("classnames/dedupe"),A=require("../forwardRef-DBQKIlPy.js"),G=require("../lightbox-dialog-CwDKF5Id.js"),J=require("../icons/ebay-icon-information-16/index.js"),K=require("../floating-ui-BLTkNeJp.js"),Q=t=>{var{icon:n,className:o,children:a,forwardedRef:l,variant:c}=t,f=h.__rest(t,["icon","className","children","forwardedRef","variant"]);const p=c==="modal"?"dialog--mini":"infotip",i=typeof n=="string"?e.createElement(U.EbayIcon,{name:n}):n,u=a instanceof Function?a({icon:i}):a;return e.createElement("button",Object.assign({},f,{className:z("icon-btn icon-btn--transparent",o,`${p}__host`),type:"button",ref:l}),u||i||null)},y=A.withForwardRef(Q),V=({variant:t="default",pointer:n,overlayStyle:o,offset:a,noFlip:l,noShift:c,notInline:f,disabled:p,onExpand:i,onCollapse:u,children:b,open:H,initialExpanded:x,icon:F=e.createElement(J.EbayIconInformation16,null),a11yCloseText:q,"aria-label":P,className:S})=>{const m=e.useRef(null),{isExpanded:s,expandTooltip:$,collapseTooltip:d}=r.useTooltip({onCollapse:u,onExpand:i,expanded:H,initialExpanded:x,hostRef:m}),{overlayStyles:D,arrowStyles:B,refs:I}=K.useFloatingTooltip({open:s,hostRef:m,options:{pointer:n,offset:a,noFlip:l,noShift:c,notInline:f}}),E=t==="modal",M=e.useRef(null),R=g.findComponent(b,O),_=g.findComponent(b,j),w=g.findComponent(b,y)||e.createElement(y),k=()=>{s?d():$()};if(!_)throw new Error("EbayInfotip: Please use a EbayInfotipContent that defines the content of the infotip");const C=_.props,{children:N}=C,T=h.__rest(C,["children"]);return e.createElement(e.Fragment,null,e.createElement(r.Tooltip,{type:"infotip",isExpanded:s,className:v(S,{"dialog--mini":E}),ref:M},e.createElement(r.TooltipHost,null,e.cloneElement(w,Object.assign({ref:m,onClick:k,disabled:p,variant:t,"aria-label":P,"aria-expanded":s,icon:F},w.props))),!E&&e.createElement(r.TooltipContent,Object.assign({},T,{type:"infotip",style:Object.assign(Object.assign({},D),o),pointer:n,showCloseButton:!0,a11yCloseText:q,onClose:d,overlayRef:I.setOverlay,arrowRef:I.arrow,arrowStyle:B}),R,N)),E&&e.createElement(G.EbayLightboxDialog,Object.assign({},T,{open:s,onClose:d,a11yCloseText:q,className:"dialog--mini__overlay"}),e.createElement(L.EbayDialogHeader,null,R),N))},O=t=>{var{className:n}=t,o=h.__rest(t,["className"]);return e.createElement("span",Object.assign({},o,{className:v("infotip__heading",n)}))},j=({children:t})=>e.createElement(e.Fragment,null,t);exports.EbayInfotip=V;exports.EbayInfotipContent=j;exports.EbayInfotipHeading=O;exports.EbayInfotipHost=y;