@lifesg/react-design-system 1.0.0-alpha.3 → 1.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -26,7 +26,7 @@ import{jsx,jsxs,Fragment}from"react/jsx-runtime";import*as React from"react";imp
26
26
  outline: none;
27
27
  background-color: ${Color.Neutral[7]};
28
28
  }
29
- `,Component$5=({children:e,iconType:t,...r},a)=>{let i;if(e)i=e;else{if(!t)return console.error("IconButton - Did not specify a valid children or iconType prop"),null;i=jsx(Icon,{type:t})}return jsx(Main$1,{ref:a,...r,children:i})},IconButton=React__default.forwardRef(Component$5),MediaWidths={mobileS:320,mobileM:375,mobileL:480,tablet:1199,desktopM:1399,desktopL:1999,desktop4k:3840},getMediaQuerySpec=e=>Object.keys(MediaWidths).reduce(((t,r)=>{const a=MediaWidths[r];return t[r]=`@media screen and (${e}: ${a}px)`,t}),{}),MediaQuery={MaxWidth:getMediaQuerySpec("max-width"),MinWidth:getMediaQuerySpec("min-width")},FontFamily={OpenSans:{Regular:"Open Sans",Semibold:"Open Sans Semibold",Bold:"Open Sans Bold",Light:"Open Sans Light"},MerriWeather:"Merriweather"},BaseTextStyleSet={D1:{fontFamily:FontFamily.OpenSans.Bold,fontSize:3,fontWeight:700,lineHeight:4,letterSpacing:-.056},D2:{fontFamily:FontFamily.OpenSans.Bold,fontSize:2.5,fontWeight:700,lineHeight:3.5,letterSpacing:-.032},D3:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.625,fontWeight:700,lineHeight:2.25},D4:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.375,fontWeight:700,lineHeight:1.75},DBody:{fontFamily:FontFamily.OpenSans.Regular,fontSize:1.375,lineHeight:1.75},H1:{fontFamily:FontFamily.OpenSans.Bold,fontSize:2,fontWeight:700,lineHeight:2.5},H2:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.625,fontWeight:700,lineHeight:2.25},H3:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.375,fontWeight:700,lineHeight:1.75},H4:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.125,fontWeight:700,lineHeight:1.625},H5:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1,fontWeight:700,lineHeight:1.5,letterSpacing:.014},H6:{fontFamily:FontFamily.OpenSans.Bold,fontSize:.875,fontWeight:700,lineHeight:1.6,letterSpacing:.012},Body:{fontFamily:FontFamily.OpenSans.Regular,fontSize:1.125,lineHeight:1.625},BodySmall:{fontFamily:FontFamily.OpenSans.Regular,fontSize:1,lineHeight:1.5,letterSpacing:.014},XSmall:{fontFamily:FontFamily.OpenSans.Regular,fontSize:.75,lineHeight:1.2,letterSpacing:.012}},TextStyleSpec={collections:{base:BaseTextStyleSet},defaultValue:"base"},getThemeTextStyles=e=>t=>{const r=t.theme,a=getCollection(TextStyleSpec,r[ThemeContextKeys.textStyleScheme]);return r.options&&r.options.textStyle?getValue(a,e,r.options.textStyle):getValue(a,e)},TextStyle={D1:{fontFamily:getThemeTextStyles("D1.fontFamily"),fontSize:getThemeTextStyles("D1.fontSize"),fontWeight:getThemeTextStyles("D1.fontWeight"),lineHeight:getThemeTextStyles("D1.lineHeight"),letterSpacing:getThemeTextStyles("D1.letterSpacing")},D2:{fontFamily:getThemeTextStyles("D2.fontFamily"),fontSize:getThemeTextStyles("D2.fontSize"),fontWeight:getThemeTextStyles("D2.fontWeight"),lineHeight:getThemeTextStyles("D2.lineHeight"),letterSpacing:getThemeTextStyles("D2.letterSpacing")},D3:{fontFamily:getThemeTextStyles("D3.fontFamily"),fontSize:getThemeTextStyles("D3.fontSize"),fontWeight:getThemeTextStyles("D3.fontWeight"),lineHeight:getThemeTextStyles("D3.lineHeight"),letterSpacing:getThemeTextStyles("D3.letterSpacing")},D4:{fontFamily:getThemeTextStyles("D4.fontFamily"),fontSize:getThemeTextStyles("D4.fontSize"),fontWeight:getThemeTextStyles("D4.fontWeight"),lineHeight:getThemeTextStyles("D4.lineHeight"),letterSpacing:getThemeTextStyles("D4.letterSpacing")},DBody:{fontFamily:getThemeTextStyles("DBody.fontFamily"),fontSize:getThemeTextStyles("DBody.fontSize"),fontWeight:getThemeTextStyles("DBody.fontWeight"),lineHeight:getThemeTextStyles("DBody.lineHeight"),letterSpacing:getThemeTextStyles("DBody.letterSpacing")},H1:{fontFamily:getThemeTextStyles("H1.fontFamily"),fontSize:getThemeTextStyles("H1.fontSize"),fontWeight:getThemeTextStyles("H1.fontWeight"),lineHeight:getThemeTextStyles("H1.lineHeight"),letterSpacing:getThemeTextStyles("H1.letterSpacing")},H2:{fontFamily:getThemeTextStyles("H2.fontFamily"),fontSize:getThemeTextStyles("H2.fontSize"),fontWeight:getThemeTextStyles("H2.fontWeight"),lineHeight:getThemeTextStyles("H2.lineHeight"),letterSpacing:getThemeTextStyles("H2.letterSpacing")},H3:{fontFamily:getThemeTextStyles("H3.fontFamily"),fontSize:getThemeTextStyles("H3.fontSize"),fontWeight:getThemeTextStyles("H3.fontWeight"),lineHeight:getThemeTextStyles("H3.lineHeight"),letterSpacing:getThemeTextStyles("H3.letterSpacing")},H4:{fontFamily:getThemeTextStyles("H4.fontFamily"),fontSize:getThemeTextStyles("H4.fontSize"),fontWeight:getThemeTextStyles("H4.fontWeight"),lineHeight:getThemeTextStyles("H4.lineHeight"),letterSpacing:getThemeTextStyles("H4.letterSpacing")},H5:{fontFamily:getThemeTextStyles("H5.fontFamily"),fontSize:getThemeTextStyles("H5.fontSize"),fontWeight:getThemeTextStyles("H5.fontWeight"),lineHeight:getThemeTextStyles("H5.lineHeight"),letterSpacing:getThemeTextStyles("H5.letterSpacing")},H6:{fontFamily:getThemeTextStyles("H6.fontFamily"),fontSize:getThemeTextStyles("H6.fontSize"),fontWeight:getThemeTextStyles("H6.fontWeight"),lineHeight:getThemeTextStyles("H6.lineHeight"),letterSpacing:getThemeTextStyles("H6.letterSpacing")},Body:{fontFamily:getThemeTextStyles("Body.fontFamily"),fontSize:getThemeTextStyles("Body.fontSize"),fontWeight:getThemeTextStyles("Body.fontWeight"),lineHeight:getThemeTextStyles("Body.lineHeight"),letterSpacing:getThemeTextStyles("Body.letterSpacing")},BodySmall:{fontFamily:getThemeTextStyles("BodySmall.fontFamily"),fontSize:getThemeTextStyles("BodySmall.fontSize"),fontWeight:getThemeTextStyles("BodySmall.fontWeight"),lineHeight:getThemeTextStyles("BodySmall.lineHeight"),letterSpacing:getThemeTextStyles("BodySmall.letterSpacing")},XSmall:{fontFamily:getThemeTextStyles("XSmall.fontFamily"),fontSize:getThemeTextStyles("XSmall.fontSize"),fontWeight:getThemeTextStyles("XSmall.fontWeight"),lineHeight:getThemeTextStyles("XSmall.lineHeight"),letterSpacing:getThemeTextStyles("XSmall.letterSpacing")}},getFont=e=>{switch(e){case 700:case"bold":return FontFamily.OpenSans.Bold;case 600:case"semibold":return FontFamily.OpenSans.Semibold;case 300:case"light":return FontFamily.OpenSans.Light;case 400:case"regular":return FontFamily.OpenSans.Regular;default:return""}},getFontFamily=(e,t)=>r=>{const a=TextStyle[e].fontFamily(r),i=TextStyle[e].fontWeight(r);return Object.values(FontFamily.OpenSans).includes(a)?css`
29
+ `,Component$5=({children:e,iconType:t,...r},a)=>{let i;if(e)i=e;else{if(!t)return console.error("IconButton - Did not specify a valid children or iconType prop"),null;i=jsx(Icon,{type:t})}return jsx(Main$1,{ref:a,...r,children:i})},IconButton=React__default.forwardRef(Component$5),MediaWidths$1={mobileS:320,mobileM:375,mobileL:480,tablet:1199,desktopM:1399,desktopL:1999,desktop4k:3840},getMediaQuerySpec=e=>Object.keys(MediaWidths$1).reduce(((t,r)=>{const a=MediaWidths$1[r];return t[r]=`@media screen and (${e}: ${a}px)`,t}),{}),MediaQuery={MaxWidth:getMediaQuerySpec("max-width"),MinWidth:getMediaQuerySpec("min-width")},MediaWidths=MediaWidths$1,FontFamily={OpenSans:{Regular:"Open Sans",Semibold:"Open Sans Semibold",Bold:"Open Sans Bold",Light:"Open Sans Light"},MerriWeather:"Merriweather"},BaseTextStyleSet={D1:{fontFamily:FontFamily.OpenSans.Bold,fontSize:3,fontWeight:700,lineHeight:4,letterSpacing:-.056},D2:{fontFamily:FontFamily.OpenSans.Bold,fontSize:2.5,fontWeight:700,lineHeight:3.5,letterSpacing:-.032},D3:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.625,fontWeight:700,lineHeight:2.25},D4:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.375,fontWeight:700,lineHeight:1.75},DBody:{fontFamily:FontFamily.OpenSans.Regular,fontSize:1.375,lineHeight:1.75},H1:{fontFamily:FontFamily.OpenSans.Bold,fontSize:2,fontWeight:700,lineHeight:2.5},H2:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.625,fontWeight:700,lineHeight:2.25},H3:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.375,fontWeight:700,lineHeight:1.75},H4:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1.125,fontWeight:700,lineHeight:1.625},H5:{fontFamily:FontFamily.OpenSans.Bold,fontSize:1,fontWeight:700,lineHeight:1.5,letterSpacing:.014},H6:{fontFamily:FontFamily.OpenSans.Bold,fontSize:.875,fontWeight:700,lineHeight:1.6,letterSpacing:.012},Body:{fontFamily:FontFamily.OpenSans.Regular,fontSize:1.125,lineHeight:1.625},BodySmall:{fontFamily:FontFamily.OpenSans.Regular,fontSize:1,lineHeight:1.5,letterSpacing:.014},XSmall:{fontFamily:FontFamily.OpenSans.Regular,fontSize:.75,lineHeight:1.2,letterSpacing:.012}},TextStyleSpec={collections:{base:BaseTextStyleSet},defaultValue:"base"},getThemeTextStyles=e=>t=>{const r=t.theme,a=getCollection(TextStyleSpec,r[ThemeContextKeys.textStyleScheme]);return r.options&&r.options.textStyle?getValue(a,e,r.options.textStyle):getValue(a,e)},TextStyle={D1:{fontFamily:getThemeTextStyles("D1.fontFamily"),fontSize:getThemeTextStyles("D1.fontSize"),fontWeight:getThemeTextStyles("D1.fontWeight"),lineHeight:getThemeTextStyles("D1.lineHeight"),letterSpacing:getThemeTextStyles("D1.letterSpacing")},D2:{fontFamily:getThemeTextStyles("D2.fontFamily"),fontSize:getThemeTextStyles("D2.fontSize"),fontWeight:getThemeTextStyles("D2.fontWeight"),lineHeight:getThemeTextStyles("D2.lineHeight"),letterSpacing:getThemeTextStyles("D2.letterSpacing")},D3:{fontFamily:getThemeTextStyles("D3.fontFamily"),fontSize:getThemeTextStyles("D3.fontSize"),fontWeight:getThemeTextStyles("D3.fontWeight"),lineHeight:getThemeTextStyles("D3.lineHeight"),letterSpacing:getThemeTextStyles("D3.letterSpacing")},D4:{fontFamily:getThemeTextStyles("D4.fontFamily"),fontSize:getThemeTextStyles("D4.fontSize"),fontWeight:getThemeTextStyles("D4.fontWeight"),lineHeight:getThemeTextStyles("D4.lineHeight"),letterSpacing:getThemeTextStyles("D4.letterSpacing")},DBody:{fontFamily:getThemeTextStyles("DBody.fontFamily"),fontSize:getThemeTextStyles("DBody.fontSize"),fontWeight:getThemeTextStyles("DBody.fontWeight"),lineHeight:getThemeTextStyles("DBody.lineHeight"),letterSpacing:getThemeTextStyles("DBody.letterSpacing")},H1:{fontFamily:getThemeTextStyles("H1.fontFamily"),fontSize:getThemeTextStyles("H1.fontSize"),fontWeight:getThemeTextStyles("H1.fontWeight"),lineHeight:getThemeTextStyles("H1.lineHeight"),letterSpacing:getThemeTextStyles("H1.letterSpacing")},H2:{fontFamily:getThemeTextStyles("H2.fontFamily"),fontSize:getThemeTextStyles("H2.fontSize"),fontWeight:getThemeTextStyles("H2.fontWeight"),lineHeight:getThemeTextStyles("H2.lineHeight"),letterSpacing:getThemeTextStyles("H2.letterSpacing")},H3:{fontFamily:getThemeTextStyles("H3.fontFamily"),fontSize:getThemeTextStyles("H3.fontSize"),fontWeight:getThemeTextStyles("H3.fontWeight"),lineHeight:getThemeTextStyles("H3.lineHeight"),letterSpacing:getThemeTextStyles("H3.letterSpacing")},H4:{fontFamily:getThemeTextStyles("H4.fontFamily"),fontSize:getThemeTextStyles("H4.fontSize"),fontWeight:getThemeTextStyles("H4.fontWeight"),lineHeight:getThemeTextStyles("H4.lineHeight"),letterSpacing:getThemeTextStyles("H4.letterSpacing")},H5:{fontFamily:getThemeTextStyles("H5.fontFamily"),fontSize:getThemeTextStyles("H5.fontSize"),fontWeight:getThemeTextStyles("H5.fontWeight"),lineHeight:getThemeTextStyles("H5.lineHeight"),letterSpacing:getThemeTextStyles("H5.letterSpacing")},H6:{fontFamily:getThemeTextStyles("H6.fontFamily"),fontSize:getThemeTextStyles("H6.fontSize"),fontWeight:getThemeTextStyles("H6.fontWeight"),lineHeight:getThemeTextStyles("H6.lineHeight"),letterSpacing:getThemeTextStyles("H6.letterSpacing")},Body:{fontFamily:getThemeTextStyles("Body.fontFamily"),fontSize:getThemeTextStyles("Body.fontSize"),fontWeight:getThemeTextStyles("Body.fontWeight"),lineHeight:getThemeTextStyles("Body.lineHeight"),letterSpacing:getThemeTextStyles("Body.letterSpacing")},BodySmall:{fontFamily:getThemeTextStyles("BodySmall.fontFamily"),fontSize:getThemeTextStyles("BodySmall.fontSize"),fontWeight:getThemeTextStyles("BodySmall.fontWeight"),lineHeight:getThemeTextStyles("BodySmall.lineHeight"),letterSpacing:getThemeTextStyles("BodySmall.letterSpacing")},XSmall:{fontFamily:getThemeTextStyles("XSmall.fontFamily"),fontSize:getThemeTextStyles("XSmall.fontSize"),fontWeight:getThemeTextStyles("XSmall.fontWeight"),lineHeight:getThemeTextStyles("XSmall.lineHeight"),letterSpacing:getThemeTextStyles("XSmall.letterSpacing")}},getFont=e=>{switch(e){case 700:case"bold":return FontFamily.OpenSans.Bold;case 600:case"semibold":return FontFamily.OpenSans.Semibold;case 300:case"light":return FontFamily.OpenSans.Light;case 400:case"regular":return FontFamily.OpenSans.Regular;default:return""}},getFontFamily=(e,t)=>r=>{const a=TextStyle[e].fontFamily(r),i=TextStyle[e].fontWeight(r);return Object.values(FontFamily.OpenSans).includes(a)?css`
30
30
  font-family: ${getFont(t)||getFont(i)||a};
31
31
  font-weight: normal !important;
32
32
  `:css`
@@ -538,7 +538,7 @@ import{jsx,jsxs,Fragment}from"react/jsx-runtime";import*as React from"react";imp
538
538
  margin: 0.25rem !important;
539
539
  `,PreviousLink=styled(Text.Hyperlink.Small)`
540
540
  margin: 0.25rem !important;
541
- `,Breadcrumb=({links:e,fadeColor:t,fadePosition:r="both",itemStyle:a,id:i,...n})=>{const[s,o]=useState(!!r),[l,h]=useState("left"===r||"both"===r),[p,c]=useState("right"===r||"both"===r),d=useRef(null),u=useRef(null);useResizeDetector({onResize:useCallback((()=>{const t=u.current,r=d.current;t&&r&&e&&e.length>1&&window.innerWidth<=MediaWidths.tablet&&(t.scrollLeft=t.scrollWidth-r.offsetWidth)}),[e.length]),targetRef:d,refreshMode:"debounce",refreshRate:50});const m=()=>{if(s){o(window.innerWidth<MediaWidths.tablet);const e=u.current,t=d.current;e&&t&&e.scrollWidth>t.offsetWidth?(o(!0),h(e.scrollLeft>=1),c(e.scrollWidth-e.scrollLeft>t.offsetWidth)):o(!1)}};if(useEffect((()=>{const e=u.current;return m(),window.addEventListener("resize",m),e&&e.addEventListener("scroll",m),()=>{window.removeEventListener("resize",m),e&&e.removeEventListener("scroll",m)}}),[]),!e)return null;return jsxs(Wrapper$5,{ref:d,id:i||"breadcrumb",...n,children:[jsx("nav",{children:jsx(Content,{ref:u,children:e.map(((t,r)=>{let i;return t.children?(i=r!==e.length-1&&t.href?jsx(PreviousLink,{...t,weight:"semibold"}):jsx(CurrentLabel,{weight:"semibold",children:t.children}),jsxs(Item$1,{$styleProps:a,children:[i,r<e.length-1&&jsx(Caret,{type:"chevron-right"})]},r)):null}))})}),s&&jsxs(Fragment,{children:[l&&jsx(Fade,{$backgroundColor:t,$position:"left"}),p&&jsx(Fade,{$backgroundColor:t,$position:"right"})]})]})},Container$a=styled.div`
541
+ `,Breadcrumb=({links:e,fadeColor:t,fadePosition:r="both",itemStyle:a,id:i,...n})=>{const[s,o]=useState(!!r),[l,h]=useState("left"===r||"both"===r),[p,c]=useState("right"===r||"both"===r),d=useRef(null),u=useRef(null);useResizeDetector({onResize:useCallback((()=>{const t=u.current,r=d.current;t&&r&&e&&e.length>1&&window.innerWidth<=MediaWidths$1.tablet&&(t.scrollLeft=t.scrollWidth-r.offsetWidth)}),[e.length]),targetRef:d,refreshMode:"debounce",refreshRate:50});const m=()=>{if(s){o(window.innerWidth<MediaWidths$1.tablet);const e=u.current,t=d.current;e&&t&&e.scrollWidth>t.offsetWidth?(o(!0),h(e.scrollLeft>=1),c(e.scrollWidth-e.scrollLeft>t.offsetWidth)):o(!1)}};if(useEffect((()=>{const e=u.current;return m(),window.addEventListener("resize",m),e&&e.addEventListener("scroll",m),()=>{window.removeEventListener("resize",m),e&&e.removeEventListener("scroll",m)}}),[]),!e)return null;return jsxs(Wrapper$5,{ref:d,id:i||"breadcrumb",...n,children:[jsx("nav",{children:jsx(Content,{ref:u,children:e.map(((t,r)=>{let i;return t.children?(i=r!==e.length-1&&t.href?jsx(PreviousLink,{...t,weight:"semibold"}):jsx(CurrentLabel,{weight:"semibold",children:t.children}),jsxs(Item$1,{$styleProps:a,children:[i,r<e.length-1&&jsx(Caret,{type:"chevron-right"})]},r)):null}))})}),s&&jsxs(Fragment,{children:[l&&jsx(Fade,{$backgroundColor:t,$position:"left"}),p&&jsx(Fade,{$backgroundColor:t,$position:"right"})]})]})},Container$a=styled.div`
542
542
  display: flex;
543
543
  justify-content: center;
544
544
  align-items: center;
@@ -901,7 +901,7 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,a=Object.pr
901
901
  background: none;
902
902
  border: none;
903
903
  padding: 0;
904
- `,Popover=({children:e,visible:t,onMobileClose:r,...a})=>{const i=a["data-testid"]||"popover",[n,s]=useState("none"),o=useRef(null),l=reactResponsive.exports.useMediaQuery({maxWidth:MediaWidths.mobileL}),h=useRef(n);useEffect((()=>(d(),window.addEventListener("resize",debounce_1(p,300)),()=>{window.removeEventListener("resize",debounce_1(p,300))})),[]);const p=()=>{d()},c=()=>{r&&r()},d=()=>{const e=u();var t;e&&(t=e,h.current=t,s(t))},u=()=>{if(o.current){const e=o.current.getBoundingClientRect(),t=24,r=e.y<t,a=window.innerWidth-t;return e.x<t?r?"top-left":"left":e.x+e.width>a?r?"top-right":"right":("top-left"===h.current||"left"===h.current)&&e.x-e.width/2>t||("top-right"===h.current||"right"===h.current)&&e.x+2*e.width<a?r?"top-center":"none":void 0}},m=()=>"string"==typeof e?jsx(Text.BodySmall,{children:e}):e;return jsxs(Fragment,{children:[jsx(Bubble$1,{ref:o,"data-testid":i,$visible:t,$offset:n,...a,children:m()}),l&&jsx(Modal$1,{show:t,onOverlayClick:c,children:jsx(MobileModalBox,{onClose:c,children:m()})})]})},withPopover=(e,t)=>r=>{const{onPopoverAppear:a,onPopoverDismiss:i,...n}=r,s=t.trigger||"click",o=n,[l,h]=useState(!1),p=useRef(),c=reactResponsive.exports.useMediaQuery({maxWidth:MediaWidths.mobileL});useEffect((()=>{if(!c)return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}}),[l]);const d=e=>{p&&!p.current.contains(e.target)&&(l&&h(!1),i&&i())};return jsxs(HOCWrapper$1,{id:"popover-hoc-wrapper",ref:p,children:[jsx(HOCTrigger,{id:`popover-hoc-trigger${t["data-testid"]&&`-${t["data-testid"]}`}`,type:"button",onClick:e=>{e.preventDefault(),("click"===s||c)&&(h(!l),!l&&a&&a(),l&&i&&i())},onMouseEnter:()=>{"hover"!==s||c||h(!0)},onMouseLeave:()=>{"hover"===s&&l&&!c&&h(!1)},"aria-label":"popover-button",children:jsx(e,{...o})}),jsx(Popover,{visible:l,id:t.id,"data-testid":t["data-testid"],onMobileClose:()=>{h(!1)},children:t.content})]})},TriggerArea=styled.button`
904
+ `,Popover=({children:e,visible:t,onMobileClose:r,...a})=>{const i=a["data-testid"]||"popover",[n,s]=useState("none"),o=useRef(null),l=reactResponsive.exports.useMediaQuery({maxWidth:MediaWidths$1.mobileL}),h=useRef(n);useEffect((()=>(d(),window.addEventListener("resize",debounce_1(p,300)),()=>{window.removeEventListener("resize",debounce_1(p,300))})),[]);const p=()=>{d()},c=()=>{r&&r()},d=()=>{const e=u();var t;e&&(t=e,h.current=t,s(t))},u=()=>{if(o.current){const e=o.current.getBoundingClientRect(),t=24,r=e.y<t,a=window.innerWidth-t;return e.x<t?r?"top-left":"left":e.x+e.width>a?r?"top-right":"right":("top-left"===h.current||"left"===h.current)&&e.x-e.width/2>t||("top-right"===h.current||"right"===h.current)&&e.x+2*e.width<a?r?"top-center":"none":void 0}},m=()=>"string"==typeof e?jsx(Text.BodySmall,{children:e}):e;return jsxs(Fragment,{children:[jsx(Bubble$1,{ref:o,"data-testid":i,$visible:t,$offset:n,...a,children:m()}),l&&jsx(Modal$1,{show:t,onOverlayClick:c,children:jsx(MobileModalBox,{onClose:c,children:m()})})]})},withPopover=(e,t)=>r=>{const{onPopoverAppear:a,onPopoverDismiss:i,...n}=r,s=t.trigger||"click",o=n,[l,h]=useState(!1),p=useRef(),c=reactResponsive.exports.useMediaQuery({maxWidth:MediaWidths$1.mobileL});useEffect((()=>{if(!c)return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}}),[l]);const d=e=>{p&&!p.current.contains(e.target)&&(l&&h(!1),i&&i())};return jsxs(HOCWrapper$1,{id:"popover-hoc-wrapper",ref:p,children:[jsx(HOCTrigger,{id:`popover-hoc-trigger${t["data-testid"]&&`-${t["data-testid"]}`}`,type:"button",onClick:e=>{e.preventDefault(),("click"===s||c)&&(h(!l),!l&&a&&a(),l&&i&&i())},onMouseEnter:()=>{"hover"!==s||c||h(!0)},onMouseLeave:()=>{"hover"===s&&l&&!c&&h(!1)},"aria-label":"popover-button",children:jsx(e,{...o})}),jsx(Popover,{visible:l,id:t.id,"data-testid":t["data-testid"],onMobileClose:()=>{h(!1)},children:t.content})]})},TriggerArea=styled.button`
905
905
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
906
906
  border: none;
907
907
  background: none;
@@ -916,7 +916,7 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,a=Object.pr
916
916
  display: inline;
917
917
  position: relative;
918
918
  width: fit-content;
919
- `,AddonTrigger=({addonType:e="popover",icon:t,"data-testid":r,...a})=>jsx(TriggerArea,{"data-testid":r,...a,children:"string"==typeof t?jsx(Icon,{type:t,id:`${e}-icon`}):t||jsx(Icon,{type:"info",id:`${e}-icon`})}),PopoverAddon=({addon:e})=>{const[t,r]=useState(!1),a=useRef(),i=useRef(!1),n=reactResponsive.exports.useMediaQuery({maxWidth:MediaWidths.mobileL}),s=e=>{i.current=e,r(e)};useEffect((()=>{if(!n)return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}}),[]);const o=e=>{a&&!a.current.contains(e.target)&&i.current&&s(!1)};return jsxs(AddonWrapper,{ref:a,id:"addon-popover-wrapper",children:[jsx(Popover,{visible:t,id:e.id,"data-testid":e["data-testid"],onMobileClose:()=>{t&&s(!1)},children:e.content}),jsx(AddonTrigger,{addonType:e.type,icon:e.icon,id:`popover-hoc-trigger${e["data-testid"]&&`-${e["data-testid"]}`}`,onClick:()=>s(!t),"aria-label":"popover-button",type:"button"})]})},Label$2=styled.label`
919
+ `,AddonTrigger=({addonType:e="popover",icon:t,"data-testid":r,...a})=>jsx(TriggerArea,{"data-testid":r,...a,children:"string"==typeof t?jsx(Icon,{type:t,id:`${e}-icon`}):t||jsx(Icon,{type:"info",id:`${e}-icon`})}),PopoverAddon=({addon:e})=>{const[t,r]=useState(!1),a=useRef(),i=useRef(!1),n=reactResponsive.exports.useMediaQuery({maxWidth:MediaWidths$1.mobileL}),s=e=>{i.current=e,r(e)};useEffect((()=>{if(!n)return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}}),[]);const o=e=>{a&&!a.current.contains(e.target)&&i.current&&s(!1)};return jsxs(AddonWrapper,{ref:a,id:"addon-popover-wrapper",children:[jsx(Popover,{visible:t,id:e.id,"data-testid":e["data-testid"],onMobileClose:()=>{t&&s(!1)},children:e.content}),jsx(AddonTrigger,{addonType:e.type,icon:e.icon,id:`popover-hoc-trigger${e["data-testid"]&&`-${e["data-testid"]}`}`,onClick:()=>s(!t),"aria-label":"popover-button",type:"button"})]})},Label$2=styled.label`
920
920
  ${TextStyleHelper.getTextStyle("H5","semibold")}
921
921
 
922
922
  color: ${e=>e.disabled?Color.Neutral[4](e):Color.Neutral[3](e)};
@@ -2158,5 +2158,5 @@ var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,a=Object.pr
2158
2158
  `}}}
2159
2159
  `,HOCWrapper=styled.div`
2160
2160
  position: relative;
2161
- `,Tooltip=({visible:e,position:t="top",children:r,...a})=>{const i=a["data-testid"]||"tooltip",[n,s]=useState(t),o=useRef(null);useEffect((()=>(h(),window.addEventListener("resize",debounce_1(l,300)),()=>{window.removeEventListener("resize",debounce_1(l,300))})),[]);const l=()=>{h()},h=()=>{if(o.current){const e=o.current.getBoundingClientRect();if(e.x<0)switch(t){case"left":case"top":case"bottom":s("right");break;case"right":s("top")}else if(e.x+e.width>window.outerWidth)switch(t){case"right":case"top":case"bottom":s("left");break;case"left":s("top")}else s(t)}};return jsxs(Bubble,{position:n,"data-testid":i,visible:e,ref:o,...a,children:["string"==typeof r?jsx(Text.BodySmall,{children:r}):r,jsx(Arrow,{position:n})]})},withTooltip=(e,t)=>r=>{const{tooltipVisible:a,position:i,...n}=r;return jsxs(HOCWrapper,{children:[jsx(e,{...n}),jsx(Tooltip,{visible:a,position:i,children:t.content})]})};export{Accordion,Alert,BaseTheme,BookingSGTheme,BoxContainer,Breadcrumb,Button,Checkbox,Color,DateInput,Form,Icon,IconButton,Input$2 as Input,InputGroup,InputMultiSelect,InputSelect,LinkList,LoadingDots,LoadingSpinner,Masonry,MediaQuery,Modal,Overlay,Popover,RadioButton,RedirectScope,Text,TextList,TextStyle,TextStyleHelper,Textarea,ThemeContextKeys,Timeline,Timepicker,ToggleButton$1 as ToggleButton,Tooltip,Transition,withPopover,withTooltip};
2161
+ `,Tooltip=({visible:e,position:t="top",children:r,...a})=>{const i=a["data-testid"]||"tooltip",[n,s]=useState(t),o=useRef(null);useEffect((()=>(h(),window.addEventListener("resize",debounce_1(l,300)),()=>{window.removeEventListener("resize",debounce_1(l,300))})),[]);const l=()=>{h()},h=()=>{if(o.current){const e=o.current.getBoundingClientRect();if(e.x<0)switch(t){case"left":case"top":case"bottom":s("right");break;case"right":s("top")}else if(e.x+e.width>window.outerWidth)switch(t){case"right":case"top":case"bottom":s("left");break;case"left":s("top")}else s(t)}};return jsxs(Bubble,{position:n,"data-testid":i,visible:e,ref:o,...a,children:["string"==typeof r?jsx(Text.BodySmall,{children:r}):r,jsx(Arrow,{position:n})]})},withTooltip=(e,t)=>r=>{const{tooltipVisible:a,position:i,...n}=r;return jsxs(HOCWrapper,{children:[jsx(e,{...n}),jsx(Tooltip,{visible:a,position:i,children:t.content})]})};export{Accordion,Alert,BaseTheme,BookingSGTheme,BoxContainer,Breadcrumb,Button,Checkbox,Color,DateInput,Form,Icon,IconButton,Input$2 as Input,InputGroup,InputMultiSelect,InputSelect,LinkList,LoadingDots,LoadingSpinner,Masonry,MediaQuery,MediaWidths,Modal,Overlay,Popover,RadioButton,RedirectScope,Text,TextList,TextStyle,TextStyleHelper,Textarea,ThemeContextKeys,Timeline,Timepicker,ToggleButton$1 as ToggleButton,Tooltip,Transition,withPopover,withTooltip};
2162
2162
  //# sourceMappingURL=index.js.map