@ebay/ui-core-react
Version:
Skin components build off React
2 lines (1 loc) • 2.51 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../tslib.es6-BW4cJBUu.js"),e=require("react"),s=require("../utils-C9NL3q0j.js"),r=require("../use-tooltip-DEDSLeBq.js"),k=require("classnames"),z=require("../floating-ui-BLTkNeJp.js"),A=require("../random-id-DlJj_RWH.js");require("../array.polyfill.flat-5BAolFdk.js");require("../icon-M7M42naA.js");const v=()=>null,w=()=>null,H=({index:t,children:a})=>e.createElement(e.Fragment,null,t!==void 0&&e.createElement("span",{className:"tourtip__index"},t),a),_=t=>{var{as:a,children:l,className:p}=t,n=b.__rest(t,["as","children","className"]);const c=a||"h2";return e.createElement(c,Object.assign({},n,{className:k("tourtip__heading",p)}),l)},D=t=>{var{a11yCloseText:a,"aria-label":l,className:p,children:n,onCollapse:c,onExpand:q,overlayStyle:x,open:R,pointer:f,offset:S,noFlip:O,noShift:j,notInline:F}=t,I=b.__rest(t,["a11yCloseText","aria-label","className","children","onCollapse","onExpand","overlayStyle","open","pointer","offset","noFlip","noShift","notInline"]);const u=e.useRef(null),{isExpanded:d,collapseTooltip:N}=r.useTooltip({onExpand:q,onCollapse:c,initialExpanded:!0,expanded:R,hostRef:u}),{overlayStyles:P,arrowStyles:B,refs:E}=z.useFloatingTooltip({open:d,hostRef:u,options:{pointer:f,offset:S,noFlip:O,noShift:j,notInline:F}}),L=e.useRef(null),T=s.findComponent(n,v);if(!T)throw new Error("EbayTourtip: Please use a EbayTourtipContent that defines the content of the tourtip");const h=T.props,{children:M}=h,U=b.__rest(h,["children"]),m=s.findComponent(n,w);if(!m)throw new Error("EbayTourtip: Please use a EbayTourtipHost that defines the host of the tourtip");const o=s.findComponent(n,_),g=s.findComponent(n,H),C=A.useRandomId(),i=o?.props.id,y=o?i??(C?`tourtip-label-${C}`:void 0):void 0,$=o&&y&&!i?e.cloneElement(o,{id:y}):o;return e.createElement(r.Tooltip,Object.assign({},I,{className:p,type:"tourtip",isExpanded:d,ref:L}),e.createElement(r.TooltipHost,Object.assign({},m.props,{forwardedRef:u,"aria-label":l,"aria-expanded":d})),e.createElement(r.TooltipContent,Object.assign({},U,{a11yCloseText:a,ariaLabelledBy:y,onClose:N,pointer:f,showCloseButton:!0,style:Object.assign(Object.assign({},P),x),type:"tourtip",overlayRef:E.setOverlay,arrowRef:E.arrow,arrowStyle:B}),$,M,g&&e.createElement(r.TooltipFooter,{type:"tourtip"},g)))};exports.Tooltip=r.Tooltip;exports.EbayTourtip=D;exports.EbayTourtipContent=v;exports.EbayTourtipFooter=H;exports.EbayTourtipHeading=_;exports.EbayTourtipHost=w;