@nylas/web-elements 0.0.0-canary-20251006194336 → 0.0.0-canary-20251007161342
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/dist/cdn/nylas-scheduler-editor/nylas-scheduler-editor.es.js +1920 -1830
- package/dist/cdn/nylas-scheduling/nylas-scheduling.es.js +1058 -968
- package/dist/cjs/calendar-agenda-fill-icon_37.cjs.entry.js +1 -1
- package/dist/cjs/calendar-agenda-fill-icon_37.cjs.entry.js.map +1 -1
- package/dist/cjs/info-icon.tooltip-component.entry.cjs.js.map +1 -1
- package/dist/cjs/info-icon_2.cjs.entry.js +150 -6
- package/dist/cjs/info-icon_2.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/nylas-web-elements.cjs.js +1 -1
- package/dist/collection/components/design-system/tooltip-component/toolitp-component.js +180 -8
- package/dist/collection/components/design-system/tooltip-component/toolitp-component.js.map +1 -1
- package/dist/collection/components/design-system/tooltip-component/tooltip-component.css +64 -52
- package/dist/collection/components/scheduler-editor/nylas-specific-time-availability-picker/nylas-specific-time-availability-picker.css +4 -1
- package/dist/components/nylas-additional-participants.js +1 -1
- package/dist/components/nylas-availability-picker.js +1 -1
- package/dist/components/nylas-booking-calendar-picker.js +1 -1
- package/dist/components/nylas-booking-confirmation-redirect.js +1 -1
- package/dist/components/nylas-booking-confirmation-type.js +1 -1
- package/dist/components/nylas-booking-form.js +1 -1
- package/dist/components/nylas-buffer-time.js +1 -1
- package/dist/components/nylas-cancel-booking-form.js +1 -1
- package/dist/components/nylas-cancellation-policy.js +1 -1
- package/dist/components/nylas-confirmation-email.js +1 -1
- package/dist/components/nylas-connected-calendars.js +1 -1
- package/dist/components/nylas-custom-event-slug.js +1 -1
- package/dist/components/nylas-customize-booking-settings.js +1 -1
- package/dist/components/nylas-disable-emails.js +1 -1
- package/dist/components/nylas-editor-tabs-group.js +1 -1
- package/dist/components/nylas-editor-tabs.js +1 -1
- package/dist/components/nylas-event-calendar.js +1 -1
- package/dist/components/nylas-event-capacity.js +1 -1
- package/dist/components/nylas-event-description.js +1 -1
- package/dist/components/nylas-event-location.js +1 -1
- package/dist/components/nylas-event-title.js +1 -1
- package/dist/components/nylas-feedback-form.js +1 -1
- package/dist/components/nylas-limit-future-bookings.js +1 -1
- package/dist/components/nylas-min-booking-notice.js +1 -1
- package/dist/components/nylas-min-cancellation-notice.js +1 -1
- package/dist/components/nylas-page-name.js +1 -1
- package/dist/components/nylas-participant-booking-calendars.js +1 -1
- package/dist/components/nylas-participants-custom-availability.js +1 -1
- package/dist/components/nylas-reminder-emails.js +1 -1
- package/dist/components/nylas-scheduler-editor.js +32 -32
- package/dist/components/nylas-scheduling-method.js +1 -1
- package/dist/components/nylas-scheduling.js +5 -5
- package/dist/components/nylas-specific-time-availability-picker.js +1 -1
- package/dist/components/nylas-timeslot-interval.js +1 -1
- package/dist/components/{p-rxJJy5Oo.js → p-3545RJLr.js} +3 -3
- package/dist/components/{p-rxJJy5Oo.js.map → p-3545RJLr.js.map} +1 -1
- package/dist/components/{p-Cn55Fpla.js → p-7BhSS-Bd.js} +4 -4
- package/dist/components/{p-Cn55Fpla.js.map → p-7BhSS-Bd.js.map} +1 -1
- package/dist/components/{p-uQkH95_y.js → p-8_2du_nN.js} +3 -3
- package/dist/components/{p-uQkH95_y.js.map → p-8_2du_nN.js.map} +1 -1
- package/dist/components/{p-BozYWwCV.js → p-BCGUSoeG.js} +5 -5
- package/dist/components/{p-BozYWwCV.js.map → p-BCGUSoeG.js.map} +1 -1
- package/dist/components/{p-_d4igWlQ.js → p-BCIPr2QS.js} +3 -3
- package/dist/components/{p-_d4igWlQ.js.map → p-BCIPr2QS.js.map} +1 -1
- package/dist/components/{p-BECn9Pde.js → p-BMmV9VHf.js} +3 -3
- package/dist/components/{p-BECn9Pde.js.map → p-BMmV9VHf.js.map} +1 -1
- package/dist/components/{p-Bd6ktb2T.js → p-BQ7rKcsT.js} +3 -3
- package/dist/components/{p-Bd6ktb2T.js.map → p-BQ7rKcsT.js.map} +1 -1
- package/dist/components/{p-D4eqsyJm.js → p-BZgNerLB.js} +3 -3
- package/dist/components/{p-D4eqsyJm.js.map → p-BZgNerLB.js.map} +1 -1
- package/dist/components/{p-CFr7S7xZ.js → p-BbiXF9bo.js} +3 -3
- package/dist/components/{p-CFr7S7xZ.js.map → p-BbiXF9bo.js.map} +1 -1
- package/dist/components/{p-C0MruP24.js → p-BcOFblKk.js} +4 -4
- package/dist/components/{p-C0MruP24.js.map → p-BcOFblKk.js.map} +1 -1
- package/dist/components/{p-CjhVAUET.js → p-Bfqgcme8.js} +3 -3
- package/dist/components/{p-CjhVAUET.js.map → p-Bfqgcme8.js.map} +1 -1
- package/dist/components/{p-DP89yVjq.js → p-BjzdJtGW.js} +30 -30
- package/dist/components/{p-DP89yVjq.js.map → p-BjzdJtGW.js.map} +1 -1
- package/dist/components/{p-BsfPlCjP.js → p-Blck8Bcs.js} +4 -4
- package/dist/components/p-Blck8Bcs.js.map +1 -0
- package/dist/components/{p-D0DW7WaN.js → p-ByHRNvMZ.js} +3 -3
- package/dist/components/{p-D0DW7WaN.js.map → p-ByHRNvMZ.js.map} +1 -1
- package/dist/components/{p-Lm5wEjg5.js → p-C05AC9Oo.js} +3 -3
- package/dist/components/{p-Lm5wEjg5.js.map → p-C05AC9Oo.js.map} +1 -1
- package/dist/components/{p-CCycsGz-.js → p-CF2aDTBc.js} +4 -4
- package/dist/components/{p-CCycsGz-.js.map → p-CF2aDTBc.js.map} +1 -1
- package/dist/components/{p-DqTU9p1H.js → p-CRtNpnB8.js} +23 -23
- package/dist/components/{p-DqTU9p1H.js.map → p-CRtNpnB8.js.map} +1 -1
- package/dist/components/{p-4TFwsEyH.js → p-CZB1eeSS.js} +3 -3
- package/dist/components/{p-4TFwsEyH.js.map → p-CZB1eeSS.js.map} +1 -1
- package/dist/components/{p-GONArOts.js → p-CekZ56Hp.js} +3 -3
- package/dist/components/{p-GONArOts.js.map → p-CekZ56Hp.js.map} +1 -1
- package/dist/components/{p-DdWVjiOc.js → p-CjPPHFwZ.js} +3 -3
- package/dist/components/{p-DdWVjiOc.js.map → p-CjPPHFwZ.js.map} +1 -1
- package/dist/components/{p-Ddn7OFh6.js → p-Cok725Bi.js} +3 -3
- package/dist/components/{p-Ddn7OFh6.js.map → p-Cok725Bi.js.map} +1 -1
- package/dist/components/{p-2YQ61G9I.js → p-Cs7HqJ7u.js} +4 -4
- package/dist/components/{p-2YQ61G9I.js.map → p-Cs7HqJ7u.js.map} +1 -1
- package/dist/components/{p-BH-NeWHo.js → p-D6pAwX0V.js} +3 -3
- package/dist/components/{p-BH-NeWHo.js.map → p-D6pAwX0V.js.map} +1 -1
- package/dist/components/{p-CMYBbZIf.js → p-D80tLNpo.js} +8 -8
- package/dist/components/{p-CMYBbZIf.js.map → p-D80tLNpo.js.map} +1 -1
- package/dist/components/{p-CmT8m71G.js → p-DASjycch.js} +4 -4
- package/dist/components/{p-CmT8m71G.js.map → p-DASjycch.js.map} +1 -1
- package/dist/components/p-DKdNE-lT.js +191 -0
- package/dist/components/p-DKdNE-lT.js.map +1 -0
- package/dist/components/{p-c8B2BLMf.js → p-DbbFBnQl.js} +3 -3
- package/dist/components/{p-c8B2BLMf.js.map → p-DbbFBnQl.js.map} +1 -1
- package/dist/components/{p-hDljvFV5.js → p-DcBAJ-gA.js} +3 -3
- package/dist/components/{p-hDljvFV5.js.map → p-DcBAJ-gA.js.map} +1 -1
- package/dist/components/{p-CpcxmM9o.js → p-Drzrlmky.js} +3 -3
- package/dist/components/{p-CpcxmM9o.js.map → p-Drzrlmky.js.map} +1 -1
- package/dist/components/{p-CcXk4esK.js → p-DwiTuOmm.js} +3 -3
- package/dist/components/{p-CcXk4esK.js.map → p-DwiTuOmm.js.map} +1 -1
- package/dist/components/{p-Do_nkNrq.js → p-DzLGxevU.js} +3 -3
- package/dist/components/{p-Do_nkNrq.js.map → p-DzLGxevU.js.map} +1 -1
- package/dist/components/{p-DkowyBip.js → p-I7R8QIAX.js} +3 -3
- package/dist/components/{p-DkowyBip.js.map → p-I7R8QIAX.js.map} +1 -1
- package/dist/components/{p-Bh9O62dp.js → p-clfLpsrR.js} +3 -3
- package/dist/components/{p-Bh9O62dp.js.map → p-clfLpsrR.js.map} +1 -1
- package/dist/components/{p-Cef4ZiLB.js → p-jfGWG79j.js} +3 -3
- package/dist/components/{p-Cef4ZiLB.js.map → p-jfGWG79j.js.map} +1 -1
- package/dist/components/textarea-component.js +1 -1
- package/dist/components/tooltip-component.js +1 -1
- package/dist/esm/calendar-agenda-fill-icon_37.entry.js +1 -1
- package/dist/esm/calendar-agenda-fill-icon_37.entry.js.map +1 -1
- package/dist/esm/info-icon.tooltip-component.entry.js.map +1 -1
- package/dist/esm/info-icon_2.entry.js +150 -6
- package/dist/esm/info-icon_2.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/nylas-web-elements.js +1 -1
- package/dist/nylas-web-elements/info-icon.tooltip-component.entry.esm.js.map +1 -1
- package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
- package/dist/nylas-web-elements/p-3036b46c.entry.js +2 -0
- package/dist/nylas-web-elements/p-3036b46c.entry.js.map +1 -0
- package/dist/nylas-web-elements/{p-2c5fd494.entry.js → p-52c3551d.entry.js} +2 -2
- package/dist/nylas-web-elements/{p-2c5fd494.entry.js.map → p-52c3551d.entry.js.map} +1 -1
- package/dist/types/components/design-system/tooltip-component/toolitp-component.d.ts +25 -3
- package/dist/types/components.d.ts +8 -4
- package/package.json +2 -2
- package/dist/components/p-BsfPlCjP.js.map +0 -1
- package/dist/components/p-C6fgjGAL.js +0 -43
- package/dist/components/p-C6fgjGAL.js.map +0 -1
- package/dist/nylas-web-elements/p-4ebae0d7.entry.js +0 -2
- package/dist/nylas-web-elements/p-4ebae0d7.entry.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info-icon.tooltip-component.entry.cjs.js","sources":["src/common/icons/icon.css?tag=info-icon&encapsulation=scoped","src/common/icons/info.tsx","src/components/design-system/tooltip-component/tooltip-component.scss?tag=tooltip-component&encapsulation=shadow","src/components/design-system/tooltip-component/toolitp-component.tsx"],"sourcesContent":[":host {\n display: flex;\n}\n","import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'info-icon',\n styleUrl: 'icon.css',\n scoped: true,\n})\nexport class InfoIcon {\n @Prop() width: string = '14';\n @Prop() height: string = '14';\n\n render() {\n return (\n <svg width={this.width} height={this.height} fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\"\n d=\"M6.5 5.5C6.77614 5.5 7 5.72386 7 6V9C7 9.27614 6.77614 9.5 6.5 9.5C6.22386 9.5 6 9.27614 6 9V6C6 5.72386 6.22386 5.5 6.5 5.5ZM6.50001 4.74907C6.91369 4.74907 7.24905 4.41371 7.24905 4.00003C7.24905 3.58635 6.91369 3.251 6.50001 3.251C6.08633 3.251 5.75098 3.58635 5.75098 4.00003C5.75098 4.41371 6.08633 4.74907 6.50001 4.74907ZM0.5 6.5C0.5 3.18629 3.18629 0.5 6.5 0.5C9.81371 0.5 12.5 3.18629 12.5 6.5C12.5 9.81371 9.81371 12.5 6.5 12.5C3.18629 12.5 0.5 9.81371 0.5 6.5ZM6.5 1.5C3.73858 1.5 1.5 3.73858 1.5 6.5C1.5 9.26142 3.73858 11.5 6.5 11.5C9.26142 11.5 11.5 9.26142 11.5 6.5C11.5 3.73858 9.26142 1.5 6.5 1.5Z\"\n />\n </svg>\n );\n }\n}\n","@use '../../../common/styles/variables' as *;\n\n.tooltip-container {\n position: relative;\n display: flex;\n @include default-css-variables;\n}\n\n.tooltip-content {\n display: none;\n background-color: var(--nylas-base-800);\n color: var(--nylas-base-0);\n text-align: left;\n border-radius: 6px;\n padding: 5px 0;\n position: absolute;\n z-index: 1;\n transition: opacity 0.3s;\n padding: 0.5rem 1rem;\n max-width: 200px;\n width: max-content;\n}\n\n/* Position-specific styles */\n.tooltip-content.top {\n bottom: 0;\n left: 0;\n margin-bottom: 1.25rem;\n transform: translateX(-50%);\n}\n\n.tooltip-content.right {\n top: 50%;\n left: 0%;\n margin-left: 1.25rem;\n transform: translateY(-50%);\n}\n\n.tooltip-content.bottom {\n top: 0;\n left: 0;\n margin-top: 1.25rem;\n transform: translateX(-50%);\n}\n\n.tooltip-content.left {\n top: 50%;\n right: 0%;\n margin-right: 1.25rem;\n transform: translateY(-50%);\n}\n\n.tooltip-container:hover .tooltip-content,\n.tooltip-container:focus-within .tooltip-content {\n display: inline;\n}\n\n/* Arrow styles */\n.tooltip-content::after {\n content: '';\n position: absolute;\n top: -0.75rem;\n left: 50%;\n transform: rotate(180deg);\n border-width: 6px;\n border-style: solid;\n border-color: var(--nylas-base-900) transparent transparent transparent;\n}\n\n.tooltip-content {\n &.top::after {\n top: 100%;\n left: 50%;\n transform: rotate(0deg);\n }\n\n &.bottom::after {\n top: -0.75rem;\n left: 50%;\n transform: rotate(180deg);\n }\n\n &.left::after {\n top: 47.5%;\n left: 100%;\n transform: rotate(270deg);\n }\n\n &.right::after {\n top: 47.5%;\n left: -0.75rem;\n transform: rotate(90deg);\n }\n}\n","import { Component, Element, Prop, h } from '@stencil/core';\n\n/**\n * The `tooltip-component` component is a UI component that displays a tooltip.\n *\n * @part tc__container - The tooltip container.\n * @part tc__content - The tooltip content.\n */\n@Component({\n tag: 'tooltip-component',\n styleUrl: 'tooltip-component.scss',\n shadow: true,\n})\nexport class TooltipComponent {\n @Element() el!: HTMLElement;\n /**\n * The position of the tooltip.\n */\n @Prop() position: 'top' | 'bottom' | 'left' | 'right' = 'bottom';\n\n showTooltip(event: FocusEvent) {\n ((event.target as HTMLElement).nextElementSibling as HTMLElement)!.style.display = 'inline';\n }\n\n hideTooltip(event: FocusEvent) {\n ((event.target as HTMLElement).nextElementSibling as HTMLElement)!.style.display = 'none';\n }\n render() {\n return (\n <div class=\"tooltip-container\" part=\"tc__container\">\n <span class=\"info-icon\" tabindex=\"0\" onFocus={this.showTooltip.bind(this)} onBlur={this.hideTooltip.bind(this)}>\n <slot name=\"tooltip-icon\">i</slot>\n </span>\n <span class={`tooltip-content ${this.position}`} part=\"tc__content\">\n <slot name=\"tooltip-content\">This is a help text.</slot>\n </span>\n </div>\n );\n }\n}\n"],"names":["h"],"mappings":";;;;AAAA,MAAM,OAAO,GAAG,+BAA+B;;MCOlC,QAAQ,GAAA,MAAA;AALrB,IAAA,WAAA,CAAA,OAAA,EAAA;;AAMU,QAAA,IAAK,CAAA,KAAA,GAAW,IAAI;AACpB,QAAA,IAAM,CAAA,MAAA,GAAW,IAAI;AAY9B;IAVC,MAAM,GAAA;QACJ,QACEA,kEAAK,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,4BAA4B,EAAA,EACzFA,OACE,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,wmBAAwmB,EAAA,CAC1mB,CACE;;;;;AClBZ,MAAM,mBAAmB,GAAG,q4GAAq4G;;MCap5G,gBAAgB,GAAA,MAAA;AAL7B,IAAA,WAAA,CAAA,OAAA,EAAA;;AAUU,QAAA,IAAQ,CAAA,QAAA,GAAwC,QAAQ;AAqBjE;AAnBC,IAAA,WAAW,CAAC,KAAiB,EAAA;QACzB,KAAK,CAAC,MAAsB,CAAC,kBAAmC,CAAC,KAAK,CAAC,OAAO,GAAG,QAAQ;;AAG7F,IAAA,WAAW,CAAC,KAAiB,EAAA;QACzB,KAAK,CAAC,MAAsB,CAAC,kBAAmC,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM;;IAE3F,MAAM,GAAA;QACJ,QACEA,kEAAK,KAAK,EAAC,mBAAmB,EAAC,IAAI,EAAC,eAAe,EAAA,EACjDA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAC,GAAG,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA,EAC5GA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,IAAI,EAAC,cAAc,EAAA,EAAA,GAAA,CAAS,CAC7B,EACPA,OAAM,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAE,CAAA,gBAAA,EAAmB,IAAI,CAAC,QAAQ,CAAE,CAAA,EAAE,IAAI,EAAC,aAAa,EAAA,EACjEA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,IAAI,EAAC,iBAAiB,2BAA4B,CACnD,CACH;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"info-icon.tooltip-component.entry.cjs.js","sources":["src/common/icons/icon.css?tag=info-icon&encapsulation=scoped","src/common/icons/info.tsx","src/components/design-system/tooltip-component/tooltip-component.scss?tag=tooltip-component&encapsulation=shadow","src/components/design-system/tooltip-component/toolitp-component.tsx"],"sourcesContent":[":host {\n display: flex;\n}\n","import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'info-icon',\n styleUrl: 'icon.css',\n scoped: true,\n})\nexport class InfoIcon {\n @Prop() width: string = '14';\n @Prop() height: string = '14';\n\n render() {\n return (\n <svg width={this.width} height={this.height} fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\"\n d=\"M6.5 5.5C6.77614 5.5 7 5.72386 7 6V9C7 9.27614 6.77614 9.5 6.5 9.5C6.22386 9.5 6 9.27614 6 9V6C6 5.72386 6.22386 5.5 6.5 5.5ZM6.50001 4.74907C6.91369 4.74907 7.24905 4.41371 7.24905 4.00003C7.24905 3.58635 6.91369 3.251 6.50001 3.251C6.08633 3.251 5.75098 3.58635 5.75098 4.00003C5.75098 4.41371 6.08633 4.74907 6.50001 4.74907ZM0.5 6.5C0.5 3.18629 3.18629 0.5 6.5 0.5C9.81371 0.5 12.5 3.18629 12.5 6.5C12.5 9.81371 9.81371 12.5 6.5 12.5C3.18629 12.5 0.5 9.81371 0.5 6.5ZM6.5 1.5C3.73858 1.5 1.5 3.73858 1.5 6.5C1.5 9.26142 3.73858 11.5 6.5 11.5C9.26142 11.5 11.5 9.26142 11.5 6.5C11.5 3.73858 9.26142 1.5 6.5 1.5Z\"\n />\n </svg>\n );\n }\n}\n","@use '../../../common/styles/variables' as *;\n\n.tooltip-container {\n position: relative;\n display: flex;\n @include default-css-variables;\n}\n\n.info-icon {\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n outline: none;\n transition: opacity 0.2s ease-in-out;\n\n &:hover {\n opacity: 0.8;\n }\n\n &:active {\n opacity: 0.6;\n }\n\n &:focus-visible {\n outline: 2px solid var(--nylas-primary-500, #2563eb);\n outline-offset: 2px;\n border-radius: 2px;\n }\n\n &[aria-pressed='true'] {\n opacity: 1;\n background-color: var(--nylas-primary-50, rgba(37, 99, 235, 0.1));\n border-radius: 4px;\n }\n}\n\n.tooltip-content {\n display: none;\n background-color: var(--nylas-base-800);\n color: var(--nylas-base-0);\n text-align: left;\n border-radius: 6px;\n padding: 0.5rem 1rem;\n max-width: 300px;\n width: max-content;\n z-index: 9999;\n opacity: 0;\n transition: opacity 0.2s ease-in-out;\n pointer-events: none;\n box-shadow:\n 0 4px 6px -1px rgba(0, 0, 0, 0.1),\n 0 2px 4px -1px rgba(0, 0, 0, 0.06);\n\n &.tooltip-visible {\n display: block;\n opacity: 1;\n pointer-events: auto;\n }\n}\n\n/* Arrow styles */\n.tooltip-content::after {\n content: '';\n position: absolute;\n border-width: 6px;\n border-style: solid;\n}\n\n.tooltip-content {\n &.top::after {\n bottom: -12px;\n left: 50%;\n transform: translateX(-50%);\n border-color: var(--nylas-base-800) transparent transparent transparent;\n }\n\n &.bottom::after {\n top: -12px;\n left: 50%;\n transform: translateX(-50%);\n border-color: transparent transparent var(--nylas-base-800) transparent;\n }\n\n &.left::after {\n right: -12px;\n top: 50%;\n transform: translateY(-50%);\n border-color: transparent transparent transparent var(--nylas-base-800);\n }\n\n &.right::after {\n left: -12px;\n top: 50%;\n transform: translateY(-50%);\n border-color: transparent var(--nylas-base-800) transparent transparent;\n }\n}\n\n/* Animation for tooltip appearance */\n@keyframes tooltip-fade-in {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.tooltip-visible {\n animation: tooltip-fade-in 0.15s ease-out;\n}\n","import { Component, Element, Prop, State, h, Listen } from '@stencil/core';\n\ntype TooltipPosition = 'top' | 'bottom' | 'left' | 'right';\n\ninterface PositionCoordinates {\n top: number;\n left: number;\n position: TooltipPosition;\n}\n\n/**\n * The `tooltip-component` component is a UI component that displays a tooltip.\n * It automatically adjusts its position to avoid being cut off by viewport or container boundaries.\n *\n * @part tc__container - The tooltip container.\n * @part tc__content - The tooltip content.\n */\n@Component({\n tag: 'tooltip-component',\n styleUrl: 'tooltip-component.scss',\n shadow: true,\n})\nexport class TooltipComponent {\n @Element() el!: HTMLElement;\n\n /**\n * The preferred position of the tooltip.\n * The tooltip will attempt to use this position but will automatically adjust if it would be cut off.\n */\n @Prop() position: TooltipPosition = 'bottom';\n\n /**\n * Controls the visibility of the tooltip.\n */\n @State() isVisible = false;\n\n /**\n * Tracks if the tooltip is pinned open via click.\n */\n @State() isPinned = false;\n\n /**\n * The actual position being used after boundary detection.\n */\n @State() actualPosition: TooltipPosition = this.position;\n\n /**\n * Calculated position coordinates for the tooltip.\n */\n @State() tooltipStyle: { top: string; left: string } = { top: '0', left: '0' };\n\n private tooltipContentEl?: HTMLElement;\n private tooltipId = `tooltip-${Math.random().toString(36).substr(2, 9)}`;\n\n /**\n * Listen for Escape key to close tooltip\n */\n @Listen('keydown', { target: 'window' })\n handleKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape' && this.isVisible) {\n this.isPinned = false;\n this.hideTooltip();\n }\n }\n\n /**\n * Listen for clicks outside to close pinned tooltip\n */\n @Listen('click', { target: 'document' })\n handleDocumentClick(event: MouseEvent) {\n if (!this.isPinned || !this.isVisible) {\n return;\n }\n\n // Check if click is outside the component\n const clickedInside = this.el.contains(event.target as Node);\n if (!clickedInside) {\n this.isPinned = false;\n this.hideTooltip();\n }\n }\n\n /**\n * Calculate the best position for the tooltip to avoid cutoff\n */\n private calculatePosition(): PositionCoordinates {\n if (!this.tooltipContentEl) {\n return { top: 0, left: 0, position: this.position };\n }\n\n const triggerEl = this.el.shadowRoot?.querySelector('.info-icon') as HTMLElement;\n if (!triggerEl) {\n return { top: 0, left: 0, position: this.position };\n }\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const tooltipRect = this.tooltipContentEl.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Calculate available space in each direction\n const spaceAbove = triggerRect.top;\n const spaceBelow = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n // Determine the best position based on available space\n let bestPosition = this.position;\n const positions: TooltipPosition[] = ['top', 'bottom', 'left', 'right'];\n\n // Check if preferred position fits\n const fitsInPreferred = this.checkPositionFits(this.position, triggerRect, tooltipRect, spaceAbove, spaceBelow, spaceLeft, spaceRight);\n\n if (!fitsInPreferred) {\n // Find alternative position with most space\n bestPosition = this.findBestAlternativePosition(positions, triggerRect, tooltipRect, spaceAbove, spaceBelow, spaceLeft, spaceRight);\n }\n\n // Calculate coordinates based on the chosen position\n const coordinates = this.getPositionCoordinates(bestPosition, triggerRect, tooltipRect, viewportWidth, viewportHeight);\n\n return { ...coordinates, position: bestPosition };\n }\n\n /**\n * Check if tooltip fits in a given position\n */\n private checkPositionFits(\n position: TooltipPosition,\n _triggerRect: DOMRect,\n tooltipRect: DOMRect,\n spaceAbove: number,\n spaceBelow: number,\n spaceLeft: number,\n spaceRight: number,\n ): boolean {\n const margin = 20; // 1.25rem margin + arrow\n\n switch (position) {\n case 'top':\n return spaceAbove >= tooltipRect.height + margin;\n case 'bottom':\n return spaceBelow >= tooltipRect.height + margin;\n case 'left':\n return spaceLeft >= tooltipRect.width + margin;\n case 'right':\n return spaceRight >= tooltipRect.width + margin;\n default:\n return false;\n }\n }\n\n /**\n * Find the best alternative position with the most available space\n */\n private findBestAlternativePosition(\n positions: TooltipPosition[],\n _triggerRect: DOMRect,\n _tooltipRect: DOMRect,\n spaceAbove: number,\n spaceBelow: number,\n spaceLeft: number,\n spaceRight: number,\n ): TooltipPosition {\n const spaces = {\n top: spaceAbove,\n bottom: spaceBelow,\n left: spaceLeft,\n right: spaceRight,\n };\n\n // Sort positions by available space\n const sortedPositions = positions.sort((a, b) => spaces[b] - spaces[a]);\n\n // Return the position with the most space\n return sortedPositions[0];\n }\n\n /**\n * Get position coordinates for the tooltip\n */\n private getPositionCoordinates(\n position: TooltipPosition,\n triggerRect: DOMRect,\n tooltipRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): { top: number; left: number } {\n let top = 0;\n let left = 0;\n const margin = 8; // Small margin for spacing\n\n switch (position) {\n case 'top':\n top = triggerRect.top - tooltipRect.height - margin;\n left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;\n break;\n case 'bottom':\n top = triggerRect.bottom + margin;\n left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;\n break;\n case 'left':\n top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2;\n left = triggerRect.left - tooltipRect.width - margin;\n break;\n case 'right':\n top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2;\n left = triggerRect.right + margin;\n break;\n }\n\n // Ensure tooltip stays within viewport bounds\n left = Math.max(margin, Math.min(left, viewportWidth - tooltipRect.width - margin));\n top = Math.max(margin, Math.min(top, viewportHeight - tooltipRect.height - margin));\n\n return { top, left };\n }\n\n /**\n * Show the tooltip with position calculation\n */\n private showTooltip() {\n this.isVisible = true;\n\n // Wait for next frame to ensure tooltip is rendered\n requestAnimationFrame(() => {\n const position = this.calculatePosition();\n this.actualPosition = position.position;\n this.tooltipStyle = {\n top: `${position.top}px`,\n left: `${position.left}px`,\n };\n });\n }\n\n /**\n * Hide the tooltip\n */\n private hideTooltip() {\n // Don't hide if tooltip is pinned\n if (this.isPinned) {\n return;\n }\n this.isVisible = false;\n }\n\n /**\n * Handle click to pin/unpin tooltip\n */\n private handleClick = (event: MouseEvent) => {\n event.stopPropagation();\n this.isPinned = !this.isPinned;\n\n if (this.isPinned) {\n this.showTooltip();\n } else {\n this.isVisible = false;\n }\n };\n\n /**\n * Handle mouse enter\n */\n private handleMouseEnter = () => {\n if (!this.isPinned) {\n this.showTooltip();\n }\n };\n\n /**\n * Handle mouse leave\n */\n private handleMouseLeave = () => {\n this.hideTooltip();\n };\n\n /**\n * Handle focus\n */\n private handleFocus = () => {\n if (!this.isPinned) {\n this.showTooltip();\n }\n };\n\n /**\n * Handle blur\n */\n private handleBlur = () => {\n this.hideTooltip();\n };\n\n render() {\n return (\n <div class=\"tooltip-container\" part=\"tc__container\">\n <span\n class=\"info-icon\"\n tabindex=\"0\"\n role=\"button\"\n aria-describedby={this.tooltipId}\n aria-expanded={this.isVisible ? 'true' : 'false'}\n aria-pressed={this.isPinned ? 'true' : 'false'}\n onClick={this.handleClick}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n >\n <slot name=\"tooltip-icon\">i</slot>\n </span>\n <span\n ref={el => (this.tooltipContentEl = el)}\n id={this.tooltipId}\n role=\"tooltip\"\n aria-hidden={!this.isVisible ? 'true' : 'false'}\n class={{\n 'tooltip-content': true,\n 'tooltip-visible': this.isVisible,\n [this.actualPosition]: true,\n }}\n style={\n this.isVisible\n ? {\n position: 'fixed',\n top: this.tooltipStyle.top,\n left: this.tooltipSt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AA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,IAAI,EAAC,cAAc,EAAA,EAAA,GAAA,CAAS,CAC7B,EACPA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EACE,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC,EACvC,EAAE,EAAE,IAAI,CAAC,SAAS,EAClB,IAAI,EAAC,SAAS,EAAA,aAAA,EACD,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,GAAG,OAAO,EAC/C,KAAK,EAAE;AACL,gBAAA,iBAAiB,EAAE,IAAI;gBACvB,iBAAiB,EAAE,IAAI,CAAC,SAAS;AACjC,gBAAA,CAAC,IAAI,CAAC,cAAc,GAAG,IAAI;AAC5B,aAAA,EACD,KAAK,EACH,IAAI,CAAC;AACH,kBAAE;AACE,oBAAA,QAAQ,EAAE,OAAO;AACjB,oBAAA,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG;AAC1B,oBAAA,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI;AAC7B;kBACD,EAAE,EAER,IAAI,EAAC,aAAa,EAAA,EAElBA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,IAAI,EAAC,iBAAiB,2BAA4B,CACnD,CACH;;;;;;;;;"}
|
|
@@ -16,21 +16,165 @@ const InfoIcon = class {
|
|
|
16
16
|
};
|
|
17
17
|
InfoIcon.style = iconCss;
|
|
18
18
|
|
|
19
|
-
const tooltipComponentCss = ".tooltip-container{position:relative;display:flex;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-50:#ffeae8;--nylas-error-100:#ffc5bf;--nylas-error-200:#fecaca;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:\"Inter\", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff}.tooltip-content{display:none;background-color:var(--nylas-base-800);color:var(--nylas-base-0);text-align:left;border-radius:6px;padding:
|
|
19
|
+
const tooltipComponentCss = ".tooltip-container{position:relative;display:flex;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-50:#ffeae8;--nylas-error-100:#ffc5bf;--nylas-error-200:#fecaca;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:\"Inter\", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff}.info-icon{cursor:pointer;display:inline-flex;align-items:center;justify-content:center;outline:none;transition:opacity 0.2s ease-in-out}.info-icon:hover{opacity:0.8}.info-icon:active{opacity:0.6}.info-icon:focus-visible{outline:2px solid var(--nylas-primary-500, #2563eb);outline-offset:2px;border-radius:2px}.info-icon[aria-pressed=true]{opacity:1;background-color:var(--nylas-primary-50, rgba(37, 99, 235, 0.1));border-radius:4px}.tooltip-content{display:none;background-color:var(--nylas-base-800);color:var(--nylas-base-0);text-align:left;border-radius:6px;padding:0.5rem 1rem;max-width:300px;width:max-content;z-index:9999;opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;box-shadow:0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)}.tooltip-content.tooltip-visible{display:block;opacity:1;pointer-events:auto}.tooltip-content::after{content:\"\";position:absolute;border-width:6px;border-style:solid}.tooltip-content.top::after{bottom:-12px;left:50%;transform:translateX(-50%);border-color:var(--nylas-base-800) transparent transparent transparent}.tooltip-content.bottom::after{top:-12px;left:50%;transform:translateX(-50%);border-color:transparent transparent var(--nylas-base-800) transparent}.tooltip-content.left::after{right:-12px;top:50%;transform:translateY(-50%);border-color:transparent transparent transparent var(--nylas-base-800)}.tooltip-content.right::after{left:-12px;top:50%;transform:translateY(-50%);border-color:transparent var(--nylas-base-800) transparent transparent}@keyframes tooltip-fade-in{from{opacity:0;transform:scale(0.95)}to{opacity:1;transform:scale(1)}}.tooltip-visible{animation:tooltip-fade-in 0.15s ease-out}";
|
|
20
20
|
|
|
21
21
|
const TooltipComponent = class {
|
|
22
22
|
constructor(hostRef) {
|
|
23
23
|
index.registerInstance(this, hostRef);
|
|
24
24
|
this.position = 'bottom';
|
|
25
|
+
this.isVisible = false;
|
|
26
|
+
this.isPinned = false;
|
|
27
|
+
this.actualPosition = this.position;
|
|
28
|
+
this.tooltipStyle = { top: '0', left: '0' };
|
|
29
|
+
this.tooltipId = `tooltip-${Math.random().toString(36).substr(2, 9)}`;
|
|
30
|
+
this.handleClick = (event) => {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
this.isPinned = !this.isPinned;
|
|
33
|
+
if (this.isPinned) {
|
|
34
|
+
this.showTooltip();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.isVisible = false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.handleMouseEnter = () => {
|
|
41
|
+
if (!this.isPinned) {
|
|
42
|
+
this.showTooltip();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this.handleMouseLeave = () => {
|
|
46
|
+
this.hideTooltip();
|
|
47
|
+
};
|
|
48
|
+
this.handleFocus = () => {
|
|
49
|
+
if (!this.isPinned) {
|
|
50
|
+
this.showTooltip();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this.handleBlur = () => {
|
|
54
|
+
this.hideTooltip();
|
|
55
|
+
};
|
|
25
56
|
}
|
|
26
|
-
|
|
27
|
-
event.
|
|
57
|
+
handleKeyDown(event) {
|
|
58
|
+
if (event.key === 'Escape' && this.isVisible) {
|
|
59
|
+
this.isPinned = false;
|
|
60
|
+
this.hideTooltip();
|
|
61
|
+
}
|
|
28
62
|
}
|
|
29
|
-
|
|
30
|
-
|
|
63
|
+
handleDocumentClick(event) {
|
|
64
|
+
if (!this.isPinned || !this.isVisible) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const clickedInside = this.el.contains(event.target);
|
|
68
|
+
if (!clickedInside) {
|
|
69
|
+
this.isPinned = false;
|
|
70
|
+
this.hideTooltip();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
calculatePosition() {
|
|
74
|
+
if (!this.tooltipContentEl) {
|
|
75
|
+
return { top: 0, left: 0, position: this.position };
|
|
76
|
+
}
|
|
77
|
+
const triggerEl = this.el.shadowRoot?.querySelector('.info-icon');
|
|
78
|
+
if (!triggerEl) {
|
|
79
|
+
return { top: 0, left: 0, position: this.position };
|
|
80
|
+
}
|
|
81
|
+
const triggerRect = triggerEl.getBoundingClientRect();
|
|
82
|
+
const tooltipRect = this.tooltipContentEl.getBoundingClientRect();
|
|
83
|
+
const viewportWidth = window.innerWidth;
|
|
84
|
+
const viewportHeight = window.innerHeight;
|
|
85
|
+
const spaceAbove = triggerRect.top;
|
|
86
|
+
const spaceBelow = viewportHeight - triggerRect.bottom;
|
|
87
|
+
const spaceLeft = triggerRect.left;
|
|
88
|
+
const spaceRight = viewportWidth - triggerRect.right;
|
|
89
|
+
let bestPosition = this.position;
|
|
90
|
+
const positions = ['top', 'bottom', 'left', 'right'];
|
|
91
|
+
const fitsInPreferred = this.checkPositionFits(this.position, triggerRect, tooltipRect, spaceAbove, spaceBelow, spaceLeft, spaceRight);
|
|
92
|
+
if (!fitsInPreferred) {
|
|
93
|
+
bestPosition = this.findBestAlternativePosition(positions, triggerRect, tooltipRect, spaceAbove, spaceBelow, spaceLeft, spaceRight);
|
|
94
|
+
}
|
|
95
|
+
const coordinates = this.getPositionCoordinates(bestPosition, triggerRect, tooltipRect, viewportWidth, viewportHeight);
|
|
96
|
+
return { ...coordinates, position: bestPosition };
|
|
97
|
+
}
|
|
98
|
+
checkPositionFits(position, _triggerRect, tooltipRect, spaceAbove, spaceBelow, spaceLeft, spaceRight) {
|
|
99
|
+
const margin = 20;
|
|
100
|
+
switch (position) {
|
|
101
|
+
case 'top':
|
|
102
|
+
return spaceAbove >= tooltipRect.height + margin;
|
|
103
|
+
case 'bottom':
|
|
104
|
+
return spaceBelow >= tooltipRect.height + margin;
|
|
105
|
+
case 'left':
|
|
106
|
+
return spaceLeft >= tooltipRect.width + margin;
|
|
107
|
+
case 'right':
|
|
108
|
+
return spaceRight >= tooltipRect.width + margin;
|
|
109
|
+
default:
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
findBestAlternativePosition(positions, _triggerRect, _tooltipRect, spaceAbove, spaceBelow, spaceLeft, spaceRight) {
|
|
114
|
+
const spaces = {
|
|
115
|
+
top: spaceAbove,
|
|
116
|
+
bottom: spaceBelow,
|
|
117
|
+
left: spaceLeft,
|
|
118
|
+
right: spaceRight,
|
|
119
|
+
};
|
|
120
|
+
const sortedPositions = positions.sort((a, b) => spaces[b] - spaces[a]);
|
|
121
|
+
return sortedPositions[0];
|
|
122
|
+
}
|
|
123
|
+
getPositionCoordinates(position, triggerRect, tooltipRect, viewportWidth, viewportHeight) {
|
|
124
|
+
let top = 0;
|
|
125
|
+
let left = 0;
|
|
126
|
+
const margin = 8;
|
|
127
|
+
switch (position) {
|
|
128
|
+
case 'top':
|
|
129
|
+
top = triggerRect.top - tooltipRect.height - margin;
|
|
130
|
+
left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
|
|
131
|
+
break;
|
|
132
|
+
case 'bottom':
|
|
133
|
+
top = triggerRect.bottom + margin;
|
|
134
|
+
left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
|
|
135
|
+
break;
|
|
136
|
+
case 'left':
|
|
137
|
+
top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2;
|
|
138
|
+
left = triggerRect.left - tooltipRect.width - margin;
|
|
139
|
+
break;
|
|
140
|
+
case 'right':
|
|
141
|
+
top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2;
|
|
142
|
+
left = triggerRect.right + margin;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
left = Math.max(margin, Math.min(left, viewportWidth - tooltipRect.width - margin));
|
|
146
|
+
top = Math.max(margin, Math.min(top, viewportHeight - tooltipRect.height - margin));
|
|
147
|
+
return { top, left };
|
|
148
|
+
}
|
|
149
|
+
showTooltip() {
|
|
150
|
+
this.isVisible = true;
|
|
151
|
+
requestAnimationFrame(() => {
|
|
152
|
+
const position = this.calculatePosition();
|
|
153
|
+
this.actualPosition = position.position;
|
|
154
|
+
this.tooltipStyle = {
|
|
155
|
+
top: `${position.top}px`,
|
|
156
|
+
left: `${position.left}px`,
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
hideTooltip() {
|
|
161
|
+
if (this.isPinned) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.isVisible = false;
|
|
31
165
|
}
|
|
32
166
|
render() {
|
|
33
|
-
return (index.h("div", { key: '
|
|
167
|
+
return (index.h("div", { key: 'd82dac77b548a6d6ca9650aa429af409985e3bf4', class: "tooltip-container", part: "tc__container" }, index.h("span", { key: 'eb857c7fd2dbccede22e082fc348ab368925bced', class: "info-icon", tabindex: "0", role: "button", "aria-describedby": this.tooltipId, "aria-expanded": this.isVisible ? 'true' : 'false', "aria-pressed": this.isPinned ? 'true' : 'false', onClick: this.handleClick, onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave, onFocus: this.handleFocus, onBlur: this.handleBlur }, index.h("slot", { key: '339815177903ecda6f7dd9087e29ba7318646241', name: "tooltip-icon" }, "i")), index.h("span", { key: '2aeb712b6dfc88326fc09161d64b79e4e4aec4bb', ref: el => (this.tooltipContentEl = el), id: this.tooltipId, role: "tooltip", "aria-hidden": !this.isVisible ? 'true' : 'false', class: {
|
|
168
|
+
'tooltip-content': true,
|
|
169
|
+
'tooltip-visible': this.isVisible,
|
|
170
|
+
[this.actualPosition]: true,
|
|
171
|
+
}, style: this.isVisible
|
|
172
|
+
? {
|
|
173
|
+
position: 'fixed',
|
|
174
|
+
top: this.tooltipStyle.top,
|
|
175
|
+
left: this.tooltipStyle.left,
|
|
176
|
+
}
|
|
177
|
+
: {}, part: "tc__content" }, index.h("slot", { key: 'f777710f0713bc2ce34ad1a5db207bb249ff38f7', name: "tooltip-content" }, "This is a help text."))));
|
|
34
178
|
}
|
|
35
179
|
get el() { return index.getElement(this); }
|
|
36
180
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"info-icon.tooltip-component.entry.cjs.js","mappings":";;;;AAAA,MAAM,OAAO,GAAG,+BAA+B;;MCOlC,QAAQ,GAAA,MAAA;AALrB,IAAA,WAAA,CAAA,OAAA,EAAA;;AAMU,QAAA,IAAK,CAAA,KAAA,GAAW,IAAI;AACpB,QAAA,IAAM,CAAA,MAAA,GAAW,IAAI;AAY9B;IAVC,MAAM,GAAA;QACJ,QACEA,kEAAK,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,4BAA4B,EAAA,EACzFA,OACE,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,IAAI,EAAC,cAAc,EACnB,CAAC,EAAC,wmBAAwmB,EAAA,CAC1mB,CACE;;;;;AClBZ,MAAM,mBAAmB,GAAG,q4GAAq4G;;MCap5G,gBAAgB,GAAA,MAAA;AAL7B,IAAA,WAAA,CAAA,OAAA,EAAA;;AAUU,QAAA,IAAQ,CAAA,QAAA,GAAwC,QAAQ;AAqBjE;AAnBC,IAAA,WAAW,CAAC,KAAiB,EAAA;QACzB,KAAK,CAAC,MAAsB,CAAC,kBAAmC,CAAC,KAAK,CAAC,OAAO,GAAG,QAAQ;;AAG7F,IAAA,WAAW,CAAC,KAAiB,EAAA;QACzB,KAAK,CAAC,MAAsB,CAAC,kBAAmC,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM;;IAE3F,MAAM,GAAA;QACJ,QACEA,kEAAK,KAAK,EAAC,mBAAmB,EAAC,IAAI,EAAC,eAAe,EAAA,EACjDA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAC,GAAG,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA,EAC5GA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,IAAI,EAAC,cAAc,EAAA,EAAA,GAAA,CAAS,CAC7B,EACPA,OAAM,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAE,CAAA,gBAAA,EAAmB,IAAI,CAAC,QAAQ,CAAE,CAAA,EAAE,IAAI,EAAC,aAAa,EAAA,EACjEA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,IAAI,EAAC,iBAAiB,2BAA4B,CACnD,CACH;;;;;;;;;","names":["h"],"sources":["src/common/icons/icon.css?tag=info-icon&encapsulation=scoped","src/common/icons/info.tsx","src/components/design-system/tooltip-component/tooltip-component.scss?tag=tooltip-component&encapsulation=shadow","src/components/design-system/tooltip-component/toolitp-component.tsx"],"sourcesContent":[":host {\n display: flex;\n}\n","import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'info-icon',\n styleUrl: 'icon.css',\n scoped: true,\n})\nexport class InfoIcon {\n @Prop() width: string = '14';\n @Prop() height: string = '14';\n\n render() {\n return (\n <svg width={this.width} height={this.height} fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\"\n d=\"M6.5 5.5C6.77614 5.5 7 5.72386 7 6V9C7 9.27614 6.77614 9.5 6.5 9.5C6.22386 9.5 6 9.27614 6 9V6C6 5.72386 6.22386 5.5 6.5 5.5ZM6.50001 4.74907C6.91369 4.74907 7.24905 4.41371 7.24905 4.00003C7.24905 3.58635 6.91369 3.251 6.50001 3.251C6.08633 3.251 5.75098 3.58635 5.75098 4.00003C5.75098 4.41371 6.08633 4.74907 6.50001 4.74907ZM0.5 6.5C0.5 3.18629 3.18629 0.5 6.5 0.5C9.81371 0.5 12.5 3.18629 12.5 6.5C12.5 9.81371 9.81371 12.5 6.5 12.5C3.18629 12.5 0.5 9.81371 0.5 6.5ZM6.5 1.5C3.73858 1.5 1.5 3.73858 1.5 6.5C1.5 9.26142 3.73858 11.5 6.5 11.5C9.26142 11.5 11.5 9.26142 11.5 6.5C11.5 3.73858 9.26142 1.5 6.5 1.5Z\"\n />\n </svg>\n );\n }\n}\n","@use '../../../common/styles/variables' as *;\n\n.tooltip-container {\n position: relative;\n display: flex;\n @include default-css-variables;\n}\n\n.tooltip-content {\n display: none;\n background-color: var(--nylas-base-800);\n color: var(--nylas-base-0);\n text-align: left;\n border-radius: 6px;\n padding: 5px 0;\n position: absolute;\n z-index: 1;\n transition: opacity 0.3s;\n padding: 0.5rem 1rem;\n max-width: 200px;\n width: max-content;\n}\n\n/* Position-specific styles */\n.tooltip-content.top {\n bottom: 0;\n left: 0;\n margin-bottom: 1.25rem;\n transform: translateX(-50%);\n}\n\n.tooltip-content.right {\n top: 50%;\n left: 0%;\n margin-left: 1.25rem;\n transform: translateY(-50%);\n}\n\n.tooltip-content.bottom {\n top: 0;\n left: 0;\n margin-top: 1.25rem;\n transform: translateX(-50%);\n}\n\n.tooltip-content.left {\n top: 50%;\n right: 0%;\n margin-right: 1.25rem;\n transform: translateY(-50%);\n}\n\n.tooltip-container:hover .tooltip-content,\n.tooltip-container:focus-within .tooltip-content {\n display: inline;\n}\n\n/* Arrow styles */\n.tooltip-content::after {\n content: '';\n position: absolute;\n top: -0.75rem;\n left: 50%;\n transform: rotate(180deg);\n border-width: 6px;\n border-style: solid;\n border-color: var(--nylas-base-900) transparent transparent transparent;\n}\n\n.tooltip-content {\n &.top::after {\n top: 100%;\n left: 50%;\n transform: rotate(0deg);\n }\n\n &.bottom::after {\n top: -0.75rem;\n left: 50%;\n transform: rotate(180deg);\n }\n\n &.left::after {\n top: 47.5%;\n left: 100%;\n transform: rotate(270deg);\n }\n\n &.right::after {\n top: 47.5%;\n left: -0.75rem;\n transform: rotate(90deg);\n }\n}\n","import { Component, Element, Prop, h } from '@stencil/core';\n\n/**\n * The `tooltip-component` component is a UI component that displays a tooltip.\n *\n * @part tc__container - The tooltip container.\n * @part tc__content - The tooltip content.\n */\n@Component({\n tag: 'tooltip-component',\n styleUrl: 'tooltip-component.scss',\n shadow: true,\n})\nexport class TooltipComponent {\n @Element() el!: HTMLElement;\n /**\n * The position of the tooltip.\n */\n @Prop() position: 'top' | 'bottom' | 'left' | 'right' = 'bottom';\n\n showTooltip(event: FocusEvent) {\n ((event.target as HTMLElement).nextElementSibling as HTMLElement)!.style.display = 'inline';\n }\n\n hideTooltip(event: FocusEvent) {\n ((event.target as HTMLElement).nextElementSibling as HTMLElement)!.style.display = 'none';\n }\n render() {\n return (\n <div class=\"tooltip-container\" part=\"tc__container\">\n <span class=\"info-icon\" tabindex=\"0\" onFocus={this.showTooltip.bind(this)} onBlur={this.hideTooltip.bind(this)}>\n <slot name=\"tooltip-icon\">i</slot>\n </span>\n <span class={`tooltip-content ${this.position}`} part=\"tc__content\">\n <slot name=\"tooltip-content\">This is a help text.</slot>\n </span>\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"info-icon.tooltip-component.entry.cjs.js","mappings":";;;;AAAA,MAAM,OAAO,GAAG,+BAA+B;;MCOlC,QAAQ,GAAA,MAAA;AALrB,IAAA,WAAA,CAAA,OAAA,EAAA;;AAMU,QA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E,EAAE,IAAI,CAAC,SAAS,EAClB,IAAI,EAAC,SAAS,EAAA,aAAA,EACD,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,GAAG,OAAO,EAC/C,KAAK,EAAE;AACL,gBAAA,iBAAiB,EAAE,IAAI;gBACvB,iBAAiB,EAAE,IAAI,CAAC,SAAS;AACjC,gBAAA,CAAC,IAAI,CAAC,cAAc,GAAG,IAAI;AAC5B,aAAA,EACD,KAAK,EACH,IAAI,CAAC;AACH,kBAAE;AACE,oBAAA,QAAQ,EAAE,OAAO;AACjB,oBAAA,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG;AAC1B,oBAAA,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI;AAC7B;kBACD,EAAE,EAER,IAAI,EAAC,aAAa,EAAA,EAElBA,OAAA,CAAA,MAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAM,IAAI,EAAC,iBAAiB,2BAA4B,CACnD,CACH;;;;;;;;;","names":["h"],"sources":["src/common/icons/icon.css?tag=info-icon&encapsulation=scoped","src/common/icons/info.tsx","src/components/design-system/tooltip-component/tooltip-component.scss?tag=tooltip-component&encapsulation=shadow","src/components/design-system/tooltip-component/toolitp-component.tsx"],"sourcesContent":[":host {\n display: flex;\n}\n","import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'info-icon',\n styleUrl: 'icon.css',\n scoped: true,\n})\nexport class InfoIcon {\n @Prop() width: string = '14';\n @Prop() height: string = '14';\n\n render() {\n return (\n <svg width={this.width} height={this.height} fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fill=\"currentColor\"\n d=\"M6.5 5.5C6.77614 5.5 7 5.72386 7 6V9C7 9.27614 6.77614 9.5 6.5 9.5C6.22386 9.5 6 9.27614 6 9V6C6 5.72386 6.22386 5.5 6.5 5.5ZM6.50001 4.74907C6.91369 4.74907 7.24905 4.41371 7.24905 4.00003C7.24905 3.58635 6.91369 3.251 6.50001 3.251C6.08633 3.251 5.75098 3.58635 5.75098 4.00003C5.75098 4.41371 6.08633 4.74907 6.50001 4.74907ZM0.5 6.5C0.5 3.18629 3.18629 0.5 6.5 0.5C9.81371 0.5 12.5 3.18629 12.5 6.5C12.5 9.81371 9.81371 12.5 6.5 12.5C3.18629 12.5 0.5 9.81371 0.5 6.5ZM6.5 1.5C3.73858 1.5 1.5 3.73858 1.5 6.5C1.5 9.26142 3.73858 11.5 6.5 11.5C9.26142 11.5 11.5 9.26142 11.5 6.5C11.5 3.73858 9.26142 1.5 6.5 1.5Z\"\n />\n </svg>\n );\n }\n}\n","@use '../../../common/styles/variables' as *;\n\n.tooltip-container {\n position: relative;\n display: flex;\n @include default-css-variables;\n}\n\n.info-icon {\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n outline: none;\n transition: opacity 0.2s ease-in-out;\n\n &:hover {\n opacity: 0.8;\n }\n\n &:active {\n opacity: 0.6;\n }\n\n &:focus-visible {\n outline: 2px solid var(--nylas-primary-500, #2563eb);\n outline-offset: 2px;\n border-radius: 2px;\n }\n\n &[aria-pressed='true'] {\n opacity: 1;\n background-color: var(--nylas-primary-50, rgba(37, 99, 235, 0.1));\n border-radius: 4px;\n }\n}\n\n.tooltip-content {\n display: none;\n background-color: var(--nylas-base-800);\n color: var(--nylas-base-0);\n text-align: left;\n border-radius: 6px;\n padding: 0.5rem 1rem;\n max-width: 300px;\n width: max-content;\n z-index: 9999;\n opacity: 0;\n transition: opacity 0.2s ease-in-out;\n pointer-events: none;\n box-shadow:\n 0 4px 6px -1px rgba(0, 0, 0, 0.1),\n 0 2px 4px -1px rgba(0, 0, 0, 0.06);\n\n &.tooltip-visible {\n display: block;\n opacity: 1;\n pointer-events: auto;\n }\n}\n\n/* Arrow styles */\n.tooltip-content::after {\n content: '';\n position: absolute;\n border-width: 6px;\n border-style: solid;\n}\n\n.tooltip-content {\n &.top::after {\n bottom: -12px;\n left: 50%;\n transform: translateX(-50%);\n border-color: var(--nylas-base-800) transparent transparent transparent;\n }\n\n &.bottom::after {\n top: -12px;\n left: 50%;\n transform: translateX(-50%);\n border-color: transparent transparent var(--nylas-base-800) transparent;\n }\n\n &.left::after {\n right: -12px;\n top: 50%;\n transform: translateY(-50%);\n border-color: transparent transparent transparent var(--nylas-base-800);\n }\n\n &.right::after {\n left: -12px;\n top: 50%;\n transform: translateY(-50%);\n border-color: transparent var(--nylas-base-800) transparent transparent;\n }\n}\n\n/* Animation for tooltip appearance */\n@keyframes tooltip-fade-in {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.tooltip-visible {\n animation: tooltip-fade-in 0.15s ease-out;\n}\n","import { Component, Element, Prop, State, h, Listen } from '@stencil/core';\n\ntype TooltipPosition = 'top' | 'bottom' | 'left' | 'right';\n\ninterface PositionCoordinates {\n top: number;\n left: number;\n position: TooltipPosition;\n}\n\n/**\n * The `tooltip-component` component is a UI component that displays a tooltip.\n * It automatically adjusts its position to avoid being cut off by viewport or container boundaries.\n *\n * @part tc__container - The tooltip container.\n * @part tc__content - The tooltip content.\n */\n@Component({\n tag: 'tooltip-component',\n styleUrl: 'tooltip-component.scss',\n shadow: true,\n})\nexport class TooltipComponent {\n @Element() el!: HTMLElement;\n\n /**\n * The preferred position of the tooltip.\n * The tooltip will attempt to use this position but will automatically adjust if it would be cut off.\n */\n @Prop() position: TooltipPosition = 'bottom';\n\n /**\n * Controls the visibility of the tooltip.\n */\n @State() isVisible = false;\n\n /**\n * Tracks if the tooltip is pinned open via click.\n */\n @State() isPinned = false;\n\n /**\n * The actual position being used after boundary detection.\n */\n @State() actualPosition: TooltipPosition = this.position;\n\n /**\n * Calculated position coordinates for the tooltip.\n */\n @State() tooltipStyle: { top: string; left: string } = { top: '0', left: '0' };\n\n private tooltipContentEl?: HTMLElement;\n private tooltipId = `tooltip-${Math.random().toString(36).substr(2, 9)}`;\n\n /**\n * Listen for Escape key to close tooltip\n */\n @Listen('keydown', { target: 'window' })\n handleKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape' && this.isVisible) {\n this.isPinned = false;\n this.hideTooltip();\n }\n }\n\n /**\n * Listen for clicks outside to close pinned tooltip\n */\n @Listen('click', { target: 'document' })\n handleDocumentClick(event: MouseEvent) {\n if (!this.isPinned || !this.isVisible) {\n return;\n }\n\n // Check if click is outside the component\n const clickedInside = this.el.contains(event.target as Node);\n if (!clickedInside) {\n this.isPinned = false;\n this.hideTooltip();\n }\n }\n\n /**\n * Calculate the best position for the tooltip to avoid cutoff\n */\n private calculatePosition(): PositionCoordinates {\n if (!this.tooltipContentEl) {\n return { top: 0, left: 0, position: this.position };\n }\n\n const triggerEl = this.el.shadowRoot?.querySelector('.info-icon') as HTMLElement;\n if (!triggerEl) {\n return { top: 0, left: 0, position: this.position };\n }\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const tooltipRect = this.tooltipContentEl.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Calculate available space in each direction\n const spaceAbove = triggerRect.top;\n const spaceBelow = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n // Determine the best position based on available space\n let bestPosition = this.position;\n const positions: TooltipPosition[] = ['top', 'bottom', 'left', 'right'];\n\n // Check if preferred position fits\n const fitsInPreferred = this.checkPositionFits(this.position, triggerRect, tooltipRect, spaceAbove, spaceBelow, spaceLeft, spaceRight);\n\n if (!fitsInPreferred) {\n // Find alternative position with most space\n bestPosition = this.findBestAlternativePosition(positions, triggerRect, tooltipRect, spaceAbove, spaceBelow, spaceLeft, spaceRight);\n }\n\n // Calculate coordinates based on the chosen position\n const coordinates = this.getPositionCoordinates(bestPosition, triggerRect, tooltipRect, viewportWidth, viewportHeight);\n\n return { ...coordinates, position: bestPosition };\n }\n\n /**\n * Check if tooltip fits in a given position\n */\n private checkPositionFits(\n position: TooltipPosition,\n _triggerRect: DOMRect,\n tooltipRect: DOMRect,\n spaceAbove: number,\n spaceBelow: number,\n spaceLeft: number,\n spaceRight: number,\n ): boolean {\n const margin = 20; // 1.25rem margin + arrow\n\n switch (position) {\n case 'top':\n return spaceAbove >= tooltipRect.height + margin;\n case 'bottom':\n return spaceBelow >= tooltipRect.height + margin;\n case 'left':\n return spaceLeft >= tooltipRect.width + margin;\n case 'right':\n return spaceRight >= tooltipRect.width + margin;\n default:\n return false;\n }\n }\n\n /**\n * Find the best alternative position with the most available space\n */\n private findBestAlternativePosition(\n positions: TooltipPosition[],\n _triggerRect: DOMRect,\n _tooltipRect: DOMRect,\n spaceAbove: number,\n spaceBelow: number,\n spaceLeft: number,\n spaceRight: number,\n ): TooltipPosition {\n const spaces = {\n top: spaceAbove,\n bottom: spaceBelow,\n left: spaceLeft,\n right: spaceRight,\n };\n\n // Sort positions by available space\n const sortedPositions = positions.sort((a, b) => spaces[b] - spaces[a]);\n\n // Return the position with the most space\n return sortedPositions[0];\n }\n\n /**\n * Get position coordinates for the tooltip\n */\n private getPositionCoordinates(\n position: TooltipPosition,\n triggerRect: DOMRect,\n tooltipRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): { top: number; left: number } {\n let top = 0;\n let left = 0;\n const margin = 8; // Small margin for spacing\n\n switch (position) {\n case 'top':\n top = triggerRect.top - tooltipRect.height - margin;\n left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;\n break;\n case 'bottom':\n top = triggerRect.bottom + margin;\n left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;\n break;\n case 'left':\n top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2;\n left = triggerRect.left - tooltipRect.width - margin;\n break;\n case 'right':\n top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2;\n left = triggerRect.right + margin;\n break;\n }\n\n // Ensure tooltip stays within viewport bounds\n left = Math.max(margin, Math.min(left, viewportWidth - tooltipRect.width - margin));\n top = Math.max(margin, Math.min(top, viewportHeight - tooltipRect.height - margin));\n\n return { top, left };\n }\n\n /**\n * Show the tooltip with position calculation\n */\n private showTooltip() {\n this.isVisible = true;\n\n // Wait for next frame to ensure tooltip is rendered\n requestAnimationFrame(() => {\n const position = this.calculatePosition();\n this.actualPosition = position.position;\n this.tooltipStyle = {\n top: `${position.top}px`,\n left: `${position.left}px`,\n };\n });\n }\n\n /**\n * Hide the tooltip\n */\n private hideTooltip() {\n // Don't hide if tooltip is pinned\n if (this.isPinned) {\n return;\n }\n this.isVisible = false;\n }\n\n /**\n * Handle click to pin/unpin tooltip\n */\n private handleClick = (event: MouseEvent) => {\n event.stopPropagation();\n this.isPinned = !this.isPinned;\n\n if (this.isPinned) {\n this.showTooltip();\n } else {\n this.isVisible = false;\n }\n };\n\n /**\n * Handle mouse enter\n */\n private handleMouseEnter = () => {\n if (!this.isPinned) {\n this.showTooltip();\n }\n };\n\n /**\n * Handle mouse leave\n */\n private handleMouseLeave = () => {\n this.hideTooltip();\n };\n\n /**\n * Handle focus\n */\n private handleFocus = () => {\n if (!this.isPinned) {\n this.showTooltip();\n }\n };\n\n /**\n * Handle blur\n */\n private handleBlur = () => {\n this.hideTooltip();\n };\n\n render() {\n return (\n <div class=\"tooltip-container\" part=\"tc__container\">\n <span\n class=\"info-icon\"\n tabindex=\"0\"\n role=\"button\"\n aria-describedby={this.tooltipId}\n aria-expanded={this.isVisible ? 'true' : 'false'}\n aria-pressed={this.isPinned ? 'true' : 'false'}\n onClick={this.handleClick}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n >\n <slot name=\"tooltip-icon\">i</slot>\n </span>\n <span\n ref={el => (this.tooltipContentEl = el)}\n id={this.tooltipId}\n role=\"tooltip\"\n aria-hidden={!this.isVisible ? 'true' : 'false'}\n class={{\n 'tooltip-content': true,\n 'tooltip-visible': this.isVisible,\n [this.actualPosition]: true,\n }}\n style={\n this.isVisible\n ? {\n position: 'fixed',\n top: this.tooltipStyle.top,\n left: this.tooltipStyle.left,\n }\n : {}\n }\n part=\"tc__content\"\n >\n <slot name=\"tooltip-content\">This is a help text.</slot>\n </span>\n </div>\n );\n }\n}\n"],"version":3}
|