@swisspost/design-system-components 1.4.0 → 1.5.1

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.
Files changed (162) hide show
  1. package/dist/cjs/check-one-of-4c2e8b2e.js +10 -0
  2. package/dist/cjs/check-one-of-4c2e8b2e.js.map +1 -0
  3. package/dist/cjs/{check-type-f24cf91d.js → check-type-508a21a5.js} +1 -7
  4. package/dist/cjs/check-type-508a21a5.js.map +1 -0
  5. package/dist/cjs/fade-8c6d4fa7.js +12 -0
  6. package/dist/cjs/fade-8c6d4fa7.js.map +1 -0
  7. package/dist/cjs/{index-50d7d035.js → index-12cc37c9.js} +107 -5
  8. package/dist/cjs/index-12cc37c9.js.map +1 -0
  9. package/dist/cjs/index-f8f6f146.js +28 -0
  10. package/dist/cjs/index-f8f6f146.js.map +1 -0
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/package-112e1698.js +7 -0
  13. package/dist/cjs/package-112e1698.js.map +1 -0
  14. package/dist/cjs/post-alert.cjs.entry.js +105 -0
  15. package/dist/cjs/post-alert.cjs.entry.js.map +1 -0
  16. package/dist/cjs/post-collapsible.cjs.entry.js +6 -5
  17. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  18. package/dist/cjs/post-components.cjs.js +2 -2
  19. package/dist/cjs/post-icon.cjs.entry.js +12 -21
  20. package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
  21. package/dist/cjs/post-tab-header.cjs.entry.js +4 -4
  22. package/dist/cjs/post-tab-header.cjs.entry.js.map +1 -1
  23. package/dist/cjs/post-tab-panel.cjs.entry.js +2 -2
  24. package/dist/cjs/post-tabs.cjs.entry.js +31 -17
  25. package/dist/cjs/post-tabs.cjs.entry.js.map +1 -1
  26. package/dist/cjs/post-tooltip.cjs.entry.js +5097 -0
  27. package/dist/cjs/post-tooltip.cjs.entry.js.map +1 -0
  28. package/dist/collection/collection-manifest.json +3 -1
  29. package/dist/collection/components/post-alert/alert-types.js +2 -0
  30. package/dist/collection/components/post-alert/alert-types.js.map +1 -0
  31. package/dist/collection/components/post-alert/post-alert.css +35 -0
  32. package/dist/collection/components/post-alert/post-alert.js +255 -0
  33. package/dist/collection/components/post-alert/post-alert.js.map +1 -0
  34. package/dist/collection/components/post-collapsible/post-collapsible.css +2 -227
  35. package/dist/collection/components/post-icon/post-icon.css +1 -102
  36. package/dist/collection/components/post-tab-header/post-tab-header.css +3 -337
  37. package/dist/collection/components/post-tab-header/post-tab-header.js +1 -1
  38. package/dist/collection/components/post-tab-header/post-tab-header.js.map +1 -1
  39. package/dist/collection/components/post-tab-panel/post-tab-panel.css +1 -3
  40. package/dist/collection/components/post-tabs/post-tabs.css +1 -148
  41. package/dist/collection/components/post-tabs/post-tabs.js +26 -7
  42. package/dist/collection/components/post-tabs/post-tabs.js.map +1 -1
  43. package/dist/collection/components/post-tooltip/post-tooltip.css +1 -0
  44. package/dist/collection/components/post-tooltip/post-tooltip.js +338 -0
  45. package/dist/collection/components/post-tooltip/post-tooltip.js.map +1 -0
  46. package/dist/collection/components/post-tooltip/types.js +2 -0
  47. package/dist/collection/components/post-tooltip/types.js.map +1 -0
  48. package/dist/collection/utils/property-checkers/check-one-of.js.map +1 -1
  49. package/dist/collection/utils/property-checkers/check-pattern.js +5 -0
  50. package/dist/collection/utils/property-checkers/check-pattern.js.map +1 -0
  51. package/dist/collection/utils/property-checkers/index.js +3 -0
  52. package/dist/collection/utils/property-checkers/index.js.map +1 -1
  53. package/dist/components/check-one-of.js +8 -0
  54. package/dist/components/check-one-of.js.map +1 -0
  55. package/dist/components/check-type.js +1 -6
  56. package/dist/components/check-type.js.map +1 -1
  57. package/dist/components/fade.js +9 -0
  58. package/dist/components/fade.js.map +1 -0
  59. package/dist/components/package.js +1 -1
  60. package/dist/components/post-alert.d.ts +11 -0
  61. package/dist/components/post-alert.js +135 -0
  62. package/dist/components/post-alert.js.map +1 -0
  63. package/dist/components/post-collapsible.js +3 -2
  64. package/dist/components/post-collapsible.js.map +1 -1
  65. package/dist/components/post-icon.js +1 -135
  66. package/dist/components/post-icon.js.map +1 -1
  67. package/dist/components/post-icon2.js +146 -0
  68. package/dist/components/post-icon2.js.map +1 -0
  69. package/dist/components/post-tab-header.js +2 -2
  70. package/dist/components/post-tab-header.js.map +1 -1
  71. package/dist/components/post-tabs.js +27 -13
  72. package/dist/components/post-tabs.js.map +1 -1
  73. package/dist/components/post-tooltip.d.ts +11 -0
  74. package/dist/components/post-tooltip.js +5118 -0
  75. package/dist/components/post-tooltip.js.map +1 -0
  76. package/dist/docs.json +313 -3
  77. package/dist/esm/check-one-of-ded5e15e.js +8 -0
  78. package/dist/esm/check-one-of-ded5e15e.js.map +1 -0
  79. package/dist/esm/{check-type-67411ed3.js → check-type-18ebb4e7.js} +2 -7
  80. package/dist/esm/check-type-18ebb4e7.js.map +1 -0
  81. package/dist/esm/fade-671f1489.js +9 -0
  82. package/dist/esm/fade-671f1489.js.map +1 -0
  83. package/dist/esm/{index-cc0e53f0.js → index-5611074b.js} +107 -5
  84. package/dist/esm/index-5611074b.js.map +1 -0
  85. package/dist/esm/index-7f723686.js +24 -0
  86. package/dist/esm/index-7f723686.js.map +1 -0
  87. package/dist/esm/loader.js +3 -3
  88. package/dist/esm/package-331628f1.js +5 -0
  89. package/dist/esm/package-331628f1.js.map +1 -0
  90. package/dist/esm/post-alert.entry.js +101 -0
  91. package/dist/esm/post-alert.entry.js.map +1 -0
  92. package/dist/esm/post-collapsible.entry.js +5 -4
  93. package/dist/esm/post-collapsible.entry.js.map +1 -1
  94. package/dist/esm/post-components.js +3 -3
  95. package/dist/esm/post-icon.entry.js +7 -16
  96. package/dist/esm/post-icon.entry.js.map +1 -1
  97. package/dist/esm/post-tab-header.entry.js +4 -4
  98. package/dist/esm/post-tab-header.entry.js.map +1 -1
  99. package/dist/esm/post-tab-panel.entry.js +2 -2
  100. package/dist/esm/post-tabs.entry.js +29 -15
  101. package/dist/esm/post-tabs.entry.js.map +1 -1
  102. package/dist/esm/post-tooltip.entry.js +5093 -0
  103. package/dist/esm/post-tooltip.entry.js.map +1 -0
  104. package/dist/post-components/p-0d37fe44.entry.js +2 -0
  105. package/dist/post-components/p-0d37fe44.entry.js.map +1 -0
  106. package/dist/post-components/p-123bb6fb.entry.js +2 -0
  107. package/dist/post-components/p-123bb6fb.entry.js.map +1 -0
  108. package/dist/post-components/p-15fc087f.js +2 -0
  109. package/dist/post-components/p-15fc087f.js.map +1 -0
  110. package/dist/post-components/p-65a9d1c2.entry.js +2 -0
  111. package/dist/post-components/p-7240ae7b.entry.js +2 -0
  112. package/dist/post-components/p-7240ae7b.entry.js.map +1 -0
  113. package/dist/post-components/p-75a7b352.js +2 -0
  114. package/dist/post-components/p-75a7b352.js.map +1 -0
  115. package/dist/post-components/p-8c386036.entry.js +9 -0
  116. package/dist/post-components/p-8c386036.entry.js.map +1 -0
  117. package/dist/post-components/p-97a064da.entry.js +2 -0
  118. package/dist/post-components/{p-6dad6a8a.entry.js.map → p-97a064da.entry.js.map} +1 -1
  119. package/dist/post-components/p-bcc705f1.js +2 -0
  120. package/dist/post-components/p-bcc705f1.js.map +1 -0
  121. package/dist/post-components/p-ccae1c68.entry.js +2 -0
  122. package/dist/post-components/p-ccae1c68.entry.js.map +1 -0
  123. package/dist/post-components/p-d94db268.js +3 -0
  124. package/dist/post-components/p-d94db268.js.map +1 -0
  125. package/dist/post-components/p-e5306504.js +2 -0
  126. package/dist/post-components/p-e5306504.js.map +1 -0
  127. package/dist/post-components/p-eb3ff4dc.js +2 -0
  128. package/dist/post-components/post-components.esm.js +1 -1
  129. package/dist/post-components/post-components.esm.js.map +1 -1
  130. package/dist/types/components/post-alert/alert-types.d.ts +2 -0
  131. package/dist/types/components/post-alert/post-alert.d.ts +49 -0
  132. package/dist/types/components/post-tabs/post-tabs.d.ts +1 -0
  133. package/dist/types/components/post-tooltip/post-tooltip.d.ts +66 -0
  134. package/dist/types/components/post-tooltip/types.d.ts +2 -0
  135. package/dist/types/components.d.ts +115 -0
  136. package/dist/types/utils/property-checkers/check-one-of.d.ts +1 -1
  137. package/dist/types/utils/property-checkers/check-pattern.d.ts +1 -0
  138. package/dist/types/utils/property-checkers/index.d.ts +3 -1
  139. package/package.json +12 -8
  140. package/dist/cjs/check-type-f24cf91d.js.map +0 -1
  141. package/dist/cjs/index-50d7d035.js.map +0 -1
  142. package/dist/cjs/package-e8a6597e.js +0 -7
  143. package/dist/cjs/package-e8a6597e.js.map +0 -1
  144. package/dist/esm/check-type-67411ed3.js.map +0 -1
  145. package/dist/esm/index-cc0e53f0.js.map +0 -1
  146. package/dist/esm/package-b514d0f6.js +0 -5
  147. package/dist/esm/package-b514d0f6.js.map +0 -1
  148. package/dist/post-components/p-1388585d.entry.js +0 -2
  149. package/dist/post-components/p-1388585d.entry.js.map +0 -1
  150. package/dist/post-components/p-58916755.js +0 -2
  151. package/dist/post-components/p-5b3445dc.entry.js +0 -2
  152. package/dist/post-components/p-5b3445dc.entry.js.map +0 -1
  153. package/dist/post-components/p-6341b9b4.js +0 -3
  154. package/dist/post-components/p-6341b9b4.js.map +0 -1
  155. package/dist/post-components/p-6dad6a8a.entry.js +0 -2
  156. package/dist/post-components/p-b95ec099.entry.js +0 -2
  157. package/dist/post-components/p-cc92afb7.entry.js +0 -2
  158. package/dist/post-components/p-cc92afb7.entry.js.map +0 -1
  159. package/dist/post-components/p-f549b3fc.js +0 -2
  160. package/dist/post-components/p-f549b3fc.js.map +0 -1
  161. /package/dist/post-components/{p-b95ec099.entry.js.map → p-65a9d1c2.entry.js.map} +0 -0
  162. /package/dist/post-components/{p-58916755.js.map → p-eb3ff4dc.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"post-tabs.js","sourceRoot":"","sources":["../../../../src/components/post-tabs/post-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,eAAe,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component, Host, h, Element, Method, Event, EventEmitter, Prop } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { fadeIn, fadeOut } from '../../animations';\n\n@Component({\n tag: 'post-tabs',\n styleUrl: 'post-tabs.scss',\n shadow: true,\n})\nexport class PostTabs {\n private activeTab: HTMLPostTabHeaderElement;\n private showing: Animation;\n private hiding: Animation;\n private isLoaded = false;\n\n private get tabs(): NodeListOf<HTMLPostTabHeaderElement> {\n return this.host.querySelectorAll('post-tab-header');\n }\n\n @Element() host: HTMLPostTabsElement;\n\n /**\n * The name of the panel that is initially shown.\n * If not specified, it defaults to the panel associated with the first tab.\n *\n * **Changing this value after initialization has no effect.**\n */\n @Prop() readonly activePanel: HTMLPostTabPanelElement['name'];\n\n /**\n * An event emitted after the active tab changes, when the fade in transition of its associated panel is finished.\n * The payload is the name of the newly shown panel.\n */\n @Event() tabChange: EventEmitter<HTMLPostTabPanelElement['name']>;\n\n componentDidLoad() {\n this.moveMisplacedTabs();\n this.enableTabs();\n\n const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;\n this.show(initiallyActivePanel);\n\n this.isLoaded = true;\n }\n\n /**\n * Shows the panel with the given name and selects its associated tab.\n * Any other panel that was previously shown becomes hidden and its associated tab is unselected.\n */\n @Method()\n async show(panelName: string) {\n // do nothing if the tab is already active\n if (panelName === this.activeTab?.panel) {\n return;\n }\n\n const previousTab = this.activeTab;\n const newTab : HTMLPostTabHeaderElement = this.host.querySelector(`post-tab-header[panel=${panelName}]`);\n this.activateTab(newTab);\n\n // if a panel is currently being displayed, remove it from the view and complete the associated animation\n if (this.showing) {\n this.showing.effect['target'].style.display = 'none';\n this.showing.finish();\n }\n\n // hide the currently visible panel only if no other animation is running\n if (previousTab && !this.showing && !this.hiding) {\n this.hidePanel(previousTab.panel);\n }\n\n // wait for any hiding animation to complete before showing the selected tab\n if (this.hiding) {\n await this.hiding.finished;\n }\n\n this.showSelectedPanel();\n\n // wait for any display animation to complete for the returned promise to fully resolve\n if (this.showing) {\n await this.showing.finished;\n }\n\n this.tabChange.emit(this.activeTab.panel);\n }\n private moveMisplacedTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(tab => {\n if (tab.getAttribute('slot') === 'tabs') return;\n tab.setAttribute('slot', 'tabs');\n });\n }\n\n private enableTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(async tab => {\n await tab.componentOnReady();\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n\n // if the tab has an \"aria-controls\" attribute it was already linked to its panel: do nothing\n if (tabTitle.getAttribute('aria-controls')) return;\n\n const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');\n tabTitle.setAttribute('aria-controls', tabPanel.id);\n tabPanel.setAttribute('aria-labelledby', tabTitle.id);\n\n tab.addEventListener('click', e => {\n e.preventDefault();\n this.show(tab.panel);\n });\n });\n\n // if the currently active tab was removed from the DOM then select the first one\n if (this.activeTab && !this.activeTab.isConnected) {\n this.show(this.tabs.item(0).panel);\n }\n }\n\n private activateTab(tab: HTMLPostTabHeaderElement) {\n if (this.activeTab) {\n const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'false');\n tabTitle.classList.remove('active');\n }\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'true');\n tabTitle.classList.add('active');\n\n this.activeTab = tab;\n }\n\n private hidePanel(panelName: HTMLPostTabPanelElement['name']) {\n const previousPanel = this.getPanel(panelName);\n\n if (!previousPanel) return;\n\n this.hiding = fadeOut(previousPanel);\n this.hiding.onfinish = () => {\n previousPanel.style.display = 'none';\n this.hiding = null;\n };\n }\n\n private showSelectedPanel() {\n const panel = this.getPanel(this.activeTab.panel);\n panel.style.display = 'block';\n\n // prevent the initially selected panel from fading in\n if (!this.isLoaded) return;\n\n this.showing = fadeIn(panel);\n this.showing.onfinish = () => {\n this.showing = null;\n };\n }\n\n private getPanel(name: string): HTMLPostTabPanelElement {\n return this.host.querySelector(\n `post-tab-panel[name=${name}]`\n );\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div class=\"tabs-wrapper\">\n <ul class=\"tabs nav\" role=\"tablist\">\n <slot name=\"tabs\" onSlotchange={() => this.enableTabs()} />\n </ul>\n </div>\n <div class=\"tab-content\">\n <slot onSlotchange={() => this.moveMisplacedTabs()} />\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"post-tabs.js","sourceRoot":"","sources":["../../../../src/components/post-tabs/post-tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAOnD,MAAM,OAAO,QAAQ;;IAIX,aAAQ,GAAG,KAAK,CAAC;;;EAEzB,IAAY,IAAI;IACd,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;EACvD,CAAC;EAkBD,gBAAgB;IACd,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACzB,IAAI,CAAC,UAAU,EAAE,CAAC;IAElB,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACzE,KAAK,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAErC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;EACvB,CAAC;EAED;;;KAGG;EAEH,KAAK,CAAC,IAAI,CAAC,SAAiB;;IAC1B,0CAA0C;IAC1C,IAAI,SAAS,MAAK,MAAA,IAAI,CAAC,SAAS,0CAAE,KAAK,CAAA,EAAE;MACvC,OAAO;KACR;IAED,MAAM,WAAW,GAAG,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AAC,IAAI,CAAC,iBAAiB,EAAE,GAAI,CAClD,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop } from '@stencil/core';\nimport { version } from '../../../package.json';\nimport { fadeIn, fadeOut } from '../../animations';\n\n@Component({\n tag: 'post-tabs',\n styleUrl: 'post-tabs.scss',\n shadow: true,\n})\nexport class PostTabs {\n private activeTab: HTMLPostTabHeaderElement;\n private showing: Animation;\n private hiding: Animation;\n private isLoaded = false;\n\n private get tabs(): NodeListOf<HTMLPostTabHeaderElement> {\n return this.host.querySelectorAll('post-tab-header');\n }\n\n @Element() host: HTMLPostTabsElement;\n\n /**\n * The name of the panel that is initially shown.\n * If not specified, it defaults to the panel associated with the first tab.\n *\n * **Changing this value after initialization has no effect.**\n */\n @Prop() readonly activePanel: HTMLPostTabPanelElement['name'];\n\n /**\n * An event emitted after the active tab changes, when the fade in transition of its associated panel is finished.\n * The payload is the name of the newly shown panel.\n */\n @Event() tabChange: EventEmitter<HTMLPostTabPanelElement['name']>;\n\n componentDidLoad() {\n this.moveMisplacedTabs();\n this.enableTabs();\n\n const initiallyActivePanel = this.activePanel || this.tabs.item(0).panel;\n void this.show(initiallyActivePanel);\n\n this.isLoaded = true;\n }\n\n /**\n * Shows the panel with the given name and selects its associated tab.\n * Any other panel that was previously shown becomes hidden and its associated tab is unselected.\n */\n @Method()\n async show(panelName: string) {\n // do nothing if the tab is already active\n if (panelName === this.activeTab?.panel) {\n return;\n }\n\n const previousTab = this.activeTab;\n const newTab: HTMLPostTabHeaderElement = this.host.querySelector(\n `post-tab-header[panel=${panelName}]`,\n );\n this.activateTab(newTab);\n\n // if a panel is currently being displayed, remove it from the view and complete the associated animation\n if (this.showing) {\n this.showing.effect['target'].style.display = 'none';\n this.showing.finish();\n }\n\n // hide the currently visible panel only if no other animation is running\n if (previousTab && !this.showing && !this.hiding) {\n this.hidePanel(previousTab.panel);\n }\n\n // wait for any hiding animation to complete before showing the selected tab\n if (this.hiding) {\n await this.hiding.finished;\n }\n\n this.showSelectedPanel();\n\n // wait for any display animation to complete for the returned promise to fully resolve\n if (this.showing) {\n await this.showing.finished;\n }\n\n this.tabChange.emit(this.activeTab.panel);\n }\n\n private moveMisplacedTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(tab => {\n if (tab.getAttribute('slot') === 'tabs') return;\n tab.setAttribute('slot', 'tabs');\n });\n }\n\n private enableTabs() {\n if (!this.tabs) return;\n\n this.tabs.forEach(async tab => {\n await tab.componentOnReady();\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n\n // if the tab has an \"aria-controls\" attribute it was already linked to its panel: do nothing\n if (tabTitle.getAttribute('aria-controls')) return;\n\n const tabPanel = this.getPanel(tab.panel).shadowRoot.querySelector('.tab-pane');\n tabTitle.setAttribute('aria-controls', tabPanel.id);\n tabPanel.setAttribute('aria-labelledby', tabTitle.id);\n\n tab.addEventListener('click', () => {\n void this.show(tab.panel);\n });\n\n tab.addEventListener('keydown', ({ key }) => {\n if (key === 'ArrowRight' || key === 'ArrowLeft') this.navigateTabs(tab, key);\n });\n });\n\n // if the currently active tab was removed from the DOM then select the first one\n if (this.activeTab && !this.activeTab.isConnected) {\n void this.show(this.tabs.item(0).panel);\n }\n }\n\n private activateTab(tab: HTMLPostTabHeaderElement) {\n if (this.activeTab) {\n const tabTitle = this.activeTab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'false');\n tabTitle.setAttribute('tabindex', '-1');\n tabTitle.classList.remove('active');\n }\n\n const tabTitle = tab.shadowRoot.querySelector('.tab-title');\n tabTitle.setAttribute('aria-selected', 'true');\n tabTitle.removeAttribute('tabindex');\n tabTitle.classList.add('active');\n\n this.activeTab = tab;\n }\n\n private hidePanel(panelName: HTMLPostTabPanelElement['name']) {\n const previousPanel = this.getPanel(panelName);\n\n if (!previousPanel) return;\n\n this.hiding = fadeOut(previousPanel);\n this.hiding.onfinish = () => {\n previousPanel.style.display = 'none';\n this.hiding = null;\n };\n }\n\n private showSelectedPanel() {\n const panel = this.getPanel(this.activeTab.panel);\n panel.style.display = 'block';\n\n // prevent the initially selected panel from fading in\n if (!this.isLoaded) return;\n\n this.showing = fadeIn(panel);\n this.showing.onfinish = () => {\n this.showing = null;\n };\n }\n\n private getPanel(name: string): HTMLPostTabPanelElement {\n return this.host.querySelector(`post-tab-panel[name=${name}]`);\n }\n\n private navigateTabs(tab: HTMLPostTabHeaderElement, key: 'ArrowRight' | 'ArrowLeft') {\n const activeTabIndex = Array.from(this.tabs).indexOf(tab);\n\n let nextTab: HTMLPostTabHeaderElement;\n if (key === 'ArrowRight') {\n nextTab = this.tabs[activeTabIndex + 1] || this.tabs[0];\n } else {\n nextTab = this.tabs[activeTabIndex - 1] || this.tabs[this.tabs.length - 1];\n }\n\n if (!nextTab) return;\n\n const nextTabTitle = nextTab.shadowRoot.querySelector('.tab-title') as HTMLAnchorElement;\n nextTabTitle.focus();\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div class=\"tabs-wrapper\">\n <div class=\"tabs\" role=\"tablist\">\n <slot name=\"tabs\" onSlotchange={() => this.enableTabs()} />\n </div>\n </div>\n <div class=\"tab-content\">\n <slot onSlotchange={() => this.moveMisplacedTabs()} />\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ :host,.bg-yellow{--post-bg-opacity: 1;background-color:rgba(var(--post-bg-rgb), var(--post-bg-opacity)) !important;color:var(--post-contrast-color) !important}.bg-yellow{--post-contrast-color: #000;--post-contrast-color-inverted: #fff;--post-gray-10: hsl(0, 0%, 90%);--post-gray-20: hsl(0, 0%, 80%);--post-gray-40: hsl(0, 0%, 60%);--post-gray-60: hsl(0, 0%, 40%);--post-gray-80: hsl(0, 0%, 20%);--post-yellow: #fc0;--post-light: #faf9f8;--post-gray: #f4f3f1;--post-dark: hsl(0, 0%, 20%);--post-primary: hsl(0, 0%, 20%);--post-white: #fff;--post-black: #000;--post-success: #2c911c;--post-info: #cce4ee;--post-warning: #f49e00;--post-danger: #a51728;--post-nightblue: #004976;--post-nightblue-bright: #0076a8;--post-petrol: #006d68;--post-petrol-bright: #00968f;--post-coral: #9e2a2f;--post-coral-bright: #e03c31;--post-olive: #716135;--post-olive-bright: #aa9d2e;--post-purple: #80276c;--post-purple-bright: #c5299b;--post-aubergine: #523178;--post-aubergine-bright: #7566a0;--post-contrast-color-rgb: 0, 0, 0;--post-contrast-color-inverted-rgb: 255, 255, 255;--post-gray-10-rgb: 230, 230, 230;--post-gray-20-rgb: 204, 204, 204;--post-gray-40-rgb: 153, 153, 153;--post-gray-60-rgb: 102, 102, 102;--post-gray-80-rgb: 51, 51, 51;--post-yellow-rgb: 255, 204, 0;--post-light-rgb: 250, 249, 248;--post-gray-rgb: 244, 243, 241;--post-dark-rgb: 51, 51, 51;--post-primary-rgb: 51, 51, 51;--post-white-rgb: 255, 255, 255;--post-black-rgb: 0, 0, 0;--post-success-rgb: 44, 145, 28;--post-info-rgb: 204, 228, 238;--post-warning-rgb: 244, 158, 0;--post-danger-rgb: 165, 23, 40;--post-nightblue-rgb: 0, 73, 118;--post-nightblue-bright-rgb: 0, 118, 168;--post-petrol-rgb: 0, 109, 104;--post-petrol-bright-rgb: 0, 150, 143;--post-coral-rgb: 158, 42, 47;--post-coral-bright-rgb: 224, 60, 49;--post-olive-rgb: 113, 97, 53;--post-olive-bright-rgb: 170, 157, 46;--post-purple-rgb: 128, 39, 108;--post-purple-bright-rgb: 197, 41, 155;--post-aubergine-rgb: 82, 49, 120;--post-aubergine-bright-rgb: 117, 102, 160}:host{--post-contrast-color: #fff;--post-contrast-color-inverted: #000;--post-dark: #faf9f8;--post-light: hsl(0, 0%, 20%);--post-gray-80: hsl(0, 0%, 90%);--post-gray-60: hsl(0, 0%, 80%);--post-gray-40: hsl(0, 0%, 60%);--post-gray-20: hsl(0, 0%, 40%);--post-gray-10: hsl(0, 0%, 20%);--post-contrast-color-rgb: 255, 255, 255;--post-contrast-color-inverted-rgb: 0, 0, 0;--post-dark-rgb: 250, 249, 248;--post-light-rgb: 51, 51, 51;--post-gray-80-rgb: 230, 230, 230;--post-gray-60-rgb: 204, 204, 204;--post-gray-40-rgb: 153, 153, 153;--post-gray-20-rgb: 102, 102, 102;--post-gray-10-rgb: 51, 51, 51}@layer polyfill{[popover]{position:fixed;z-index:2147483647;inset:0;padding:.25em;width:fit-content;height:fit-content;border-width:initial;border-color:initial;border-image:initial;border-style:solid;background-color:canvas;color:canvastext;overflow:auto;margin:auto}[popover]:not(.\:popover-open){display:none}[popover]:is(dialog[open]){display:revert}[anchor].\:popover-open{inset:auto}@supports selector([popover]:open){[popover]:not(.\:popover-open,dialog[open]){display:revert}[anchor]:is(:open){inset:auto}}@supports selector([popover]:popover-open){[popover]:not(.\:popover-open,dialog[open]){display:revert}[anchor]:is(:popover-open){inset:auto}}@supports not (background-color: canvas){[popover]{background-color:white;color:black}}@supports(width: -moz-fit-content){[popover]{width:-moz-fit-content;height:-moz-fit-content}}@supports not (inset: 0){[popover]{top:0;left:0;right:0;bottom:0}}}:host{--post-bg-rgb: 51, 51, 51}div{position:absolute;z-index:1070;width:max-content;max-width:30ch;margin:0;padding:.25rem .5rem;color:inherit;background-color:inherit;border-color:rgba(0,0,0,0);border-radius:4px;overflow:visible;pointer-events:none}.arrow{position:absolute;width:.7071067812rem;aspect-ratio:1/1;background-color:inherit;rotate:45deg;pointer-events:none;z-index:-1;border-right:2px solid rgba(0,0,0,0);border-bottom:2px solid rgba(0,0,0,0)}.bg-yellow{--post-bg-rgb: 255, 204, 0}
@@ -0,0 +1,338 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { arrow, autoUpdate, computePosition, flip, inline, offset, shift, } from '@floating-ui/dom';
3
+ import isFocusable from 'ally.js/esm/is/focusable';
4
+ // Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green
5
+ import '@oddbird/popover-polyfill';
6
+ // Patch for long press on touch devices
7
+ import 'long-press-event';
8
+ import { version } from '../../../package.json';
9
+ import { checkOneOf } from '../../utils';
10
+ import { BACKGROUND_COLOR } from './types';
11
+ const SIDE_MAP = {
12
+ top: 'bottom',
13
+ right: 'left',
14
+ bottom: 'top',
15
+ left: 'right',
16
+ };
17
+ export class PostTooltip {
18
+ validateBackgroundColor(newValue = this.backgroundColor) {
19
+ checkOneOf(newValue, BACKGROUND_COLOR, `The post-tooltip "background-color" prop should contain one of those values: ${BACKGROUND_COLOR.join(', ')}`);
20
+ if (newValue === 'yellow') {
21
+ this.tooltipClasses = 'bg-yellow';
22
+ }
23
+ else {
24
+ this.tooltipClasses = 'bg-primary';
25
+ }
26
+ }
27
+ constructor() {
28
+ this.tooltipClasses = undefined;
29
+ this.backgroundColor = 'primary';
30
+ this.placement = 'top';
31
+ // Create local versions of event handlers for de-registration
32
+ // https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class
33
+ this.localShowTooltip = e => this.show(e.target);
34
+ this.localHideTooltip = this.hide.bind(this);
35
+ this.localToggleTooltip = this.toggle.bind(this);
36
+ }
37
+ componentWillLoad() {
38
+ this.validateBackgroundColor();
39
+ // Append tooltip host to the end of the body to get around overflow: hidden restrictions
40
+ // for browsers that don't support popover yet
41
+ document.body.appendChild(this.host);
42
+ }
43
+ connectedCallback() {
44
+ if (!this.host.id) {
45
+ throw new Error('No id set: <post-tooltip> must have an id, linking it to it\'s target element using the data-tooltip-target attribute.');
46
+ }
47
+ if (!this.triggers) {
48
+ throw new Error(`No trigger found for <post-tooltip id="${this.host.id}">, please add the 'data-tooltip-target="${this.host.id}" attribute to the trigger element.`);
49
+ }
50
+ // Patch popovertargetaction="interest" until it's implemented
51
+ // https://github.com/openui/open-ui/issues/767#issuecomment-1654177227
52
+ this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));
53
+ }
54
+ /**
55
+ * Remove a bunch of event listeners if the tooltip gets removed from the DOM
56
+ */
57
+ disconnectedCallback() {
58
+ this.triggers.forEach(trigger => {
59
+ trigger.removeEventListener('mouseenter', this.localShowTooltip);
60
+ trigger.removeEventListener('mouseleave', this.localHideTooltip);
61
+ trigger.removeEventListener('focus', this.localShowTooltip);
62
+ trigger.removeEventListener('blur', this.localHideTooltip);
63
+ trigger.removeEventListener('long-press', this.localShowTooltip);
64
+ });
65
+ if (this.tooltipRef)
66
+ this.tooltipRef.removeEventListener('beforetoggle', this.localToggleTooltip);
67
+ if (typeof this.clearAutoUpdate === 'function')
68
+ this.clearAutoUpdate();
69
+ }
70
+ componentDidLoad() {
71
+ // Has the benefit of rendering the tooltip without the popover attribute which
72
+ // causes the tooltip to show up on the page if it's not linked to a target. This makes
73
+ // the error obvious.
74
+ if (!this.host.id || !this.triggers)
75
+ return false;
76
+ this.tooltipRef.setAttribute('popover', '');
77
+ this.tooltipRef.addEventListener('beforetoggle', this.handleToggle.bind(this));
78
+ }
79
+ /**
80
+ * Programmatically display the tooltip
81
+ * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
82
+ */
83
+ async show(target) {
84
+ this.eventTarget = target;
85
+ this.tooltipRef.showPopover();
86
+ }
87
+ /**
88
+ * Programmatically hide this tooltip
89
+ */
90
+ async hide() {
91
+ this.eventTarget = null;
92
+ this.tooltipRef.hidePopover();
93
+ }
94
+ /**
95
+ * Toggle tooltip display
96
+ * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
97
+ * @param force Pass true to always show or false to always hide
98
+ */
99
+ async toggle(target, force) {
100
+ this.eventTarget = target;
101
+ this.tooltipRef.togglePopover(force);
102
+ }
103
+ get triggers() {
104
+ return document.querySelectorAll(`[data-tooltip-target="${this.host.id}"]`);
105
+ }
106
+ patchPopoverTargetActionInterest(trigger) {
107
+ trigger.addEventListener('mouseenter', this.localShowTooltip);
108
+ trigger.addEventListener('mouseleave', this.localHideTooltip);
109
+ trigger.addEventListener('focus', this.localShowTooltip);
110
+ trigger.addEventListener('blur', this.localHideTooltip);
111
+ trigger.addEventListener('long-press', this.localShowTooltip);
112
+ // Patch missing aria-describedby attribute on the trigger without overriding existing values
113
+ const describedBy = trigger.getAttribute('aria-describedby');
114
+ if (!(describedBy === null || describedBy === void 0 ? void 0 : describedBy.includes(this.host.id))) {
115
+ const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;
116
+ trigger.setAttribute('aria-describedby', newDescribedBy);
117
+ }
118
+ // Patch missing focus ability on the trigger element
119
+ if (!isFocusable(trigger)) {
120
+ trigger.setAttribute('tabindex', '0');
121
+ }
122
+ }
123
+ /**
124
+ * Start or stop auto updates based on tooltip events.
125
+ * Tooltips can be closed or opened with other methods than class members,
126
+ * therefore listening to the toggle event is safer for cleaning up.
127
+ * @param e ToggleEvent
128
+ */
129
+ handleToggle(e) {
130
+ const isOpen = e.newState === 'open';
131
+ if (isOpen) {
132
+ this.startAutoupdates();
133
+ }
134
+ else {
135
+ if (typeof this.clearAutoUpdate === 'function')
136
+ this.clearAutoUpdate();
137
+ }
138
+ }
139
+ /**
140
+ * Start listening for DOM updates, scroll events etc. that have
141
+ * an influence on tooltip positioning
142
+ */
143
+ startAutoupdates() {
144
+ this.clearAutoUpdate = autoUpdate(this.eventTarget, this.tooltipRef, this.positionTooltip.bind(this));
145
+ }
146
+ // Tooltip and arrow positioning with floating-ui
147
+ // Docs: https://floating-ui.com/docs/computePosition
148
+ async positionTooltip() {
149
+ const { x, y, middlewareData, placement: currentPlacement, } = await computePosition(this.eventTarget, this.tooltipRef, {
150
+ placement: this.placement || 'top',
151
+ middleware: [
152
+ flip(),
153
+ inline(),
154
+ shift({ padding: 8 }),
155
+ offset(12),
156
+ arrow({ element: this.arrowRef, padding: 8 }),
157
+ ],
158
+ });
159
+ // Tooltip
160
+ this.tooltipRef.style.left = `${x}px`;
161
+ this.tooltipRef.style.top = `${y}px`;
162
+ // Arrow
163
+ // Tutorial: https://codesandbox.io/s/mystifying-kare-ee3hmh?file=/src/index.js
164
+ const side = currentPlacement.split('-')[0];
165
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
166
+ const staticSide = SIDE_MAP[side];
167
+ Object.assign(this.arrowRef.style, {
168
+ top: arrowY ? `${arrowY}px` : '',
169
+ left: arrowX ? `${arrowX}px` : '',
170
+ [staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,
171
+ });
172
+ }
173
+ render() {
174
+ return (h(Host, { "data-version": version }, h("div", { role: "tooltip", tabindex: "-1", class: this.tooltipClasses, ref: (el) => (this.tooltipRef = el) }, h("span", { class: "arrow", ref: el => {
175
+ this.arrowRef = el;
176
+ } }), h("slot", null))));
177
+ }
178
+ static get is() { return "post-tooltip"; }
179
+ static get encapsulation() { return "shadow"; }
180
+ static get originalStyleUrls() {
181
+ return {
182
+ "$": ["post-tooltip.scss"]
183
+ };
184
+ }
185
+ static get styleUrls() {
186
+ return {
187
+ "$": ["post-tooltip.css"]
188
+ };
189
+ }
190
+ static get properties() {
191
+ return {
192
+ "backgroundColor": {
193
+ "type": "string",
194
+ "mutable": false,
195
+ "complexType": {
196
+ "original": "BackgroundColor",
197
+ "resolved": "\"primary\" | \"yellow\"",
198
+ "references": {
199
+ "BackgroundColor": {
200
+ "location": "import",
201
+ "path": "./types"
202
+ }
203
+ }
204
+ },
205
+ "required": false,
206
+ "optional": true,
207
+ "docs": {
208
+ "tags": [],
209
+ "text": "Defines the background color of the tooltip.\nChoose the one that provides the best contrast in your scenario."
210
+ },
211
+ "attribute": "background-color",
212
+ "reflect": false,
213
+ "defaultValue": "'primary'"
214
+ },
215
+ "placement": {
216
+ "type": "string",
217
+ "mutable": false,
218
+ "complexType": {
219
+ "original": "Placement",
220
+ "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
221
+ "references": {
222
+ "Placement": {
223
+ "location": "import",
224
+ "path": "@floating-ui/dom"
225
+ }
226
+ }
227
+ },
228
+ "required": false,
229
+ "optional": true,
230
+ "docs": {
231
+ "tags": [],
232
+ "text": "Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\nTooltips are automatically flipped to the opposite side if there is not enough available space and are shifted\ntowards the viewport if they would overlap edge boundaries."
233
+ },
234
+ "attribute": "placement",
235
+ "reflect": false,
236
+ "defaultValue": "'top'"
237
+ }
238
+ };
239
+ }
240
+ static get states() {
241
+ return {
242
+ "tooltipClasses": {}
243
+ };
244
+ }
245
+ static get methods() {
246
+ return {
247
+ "show": {
248
+ "complexType": {
249
+ "signature": "(target: HTMLElement) => Promise<void>",
250
+ "parameters": [{
251
+ "tags": [{
252
+ "name": "param",
253
+ "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
254
+ }],
255
+ "text": "An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
256
+ }],
257
+ "references": {
258
+ "Promise": {
259
+ "location": "global"
260
+ },
261
+ "HTMLElement": {
262
+ "location": "global"
263
+ }
264
+ },
265
+ "return": "Promise<void>"
266
+ },
267
+ "docs": {
268
+ "text": "Programmatically display the tooltip",
269
+ "tags": [{
270
+ "name": "param",
271
+ "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
272
+ }]
273
+ }
274
+ },
275
+ "hide": {
276
+ "complexType": {
277
+ "signature": "() => Promise<void>",
278
+ "parameters": [],
279
+ "references": {
280
+ "Promise": {
281
+ "location": "global"
282
+ }
283
+ },
284
+ "return": "Promise<void>"
285
+ },
286
+ "docs": {
287
+ "text": "Programmatically hide this tooltip",
288
+ "tags": []
289
+ }
290
+ },
291
+ "toggle": {
292
+ "complexType": {
293
+ "signature": "(target: HTMLElement, force?: boolean) => Promise<void>",
294
+ "parameters": [{
295
+ "tags": [{
296
+ "name": "param",
297
+ "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
298
+ }],
299
+ "text": "An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
300
+ }, {
301
+ "tags": [{
302
+ "name": "param",
303
+ "text": "force Pass true to always show or false to always hide"
304
+ }],
305
+ "text": "Pass true to always show or false to always hide"
306
+ }],
307
+ "references": {
308
+ "Promise": {
309
+ "location": "global"
310
+ },
311
+ "HTMLElement": {
312
+ "location": "global"
313
+ }
314
+ },
315
+ "return": "Promise<void>"
316
+ },
317
+ "docs": {
318
+ "text": "Toggle tooltip display",
319
+ "tags": [{
320
+ "name": "param",
321
+ "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
322
+ }, {
323
+ "name": "param",
324
+ "text": "force Pass true to always show or false to always hide"
325
+ }]
326
+ }
327
+ }
328
+ };
329
+ }
330
+ static get elementRef() { return "host"; }
331
+ static get watchers() {
332
+ return [{
333
+ "propName": "backgroundColor",
334
+ "methodName": "validateBackgroundColor"
335
+ }];
336
+ }
337
+ }
338
+ //# sourceMappingURL=post-tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-tooltip.js","sourceRoot":"","sources":["../../../../src/components/post-tooltip/post-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EACL,KAAK,EACL,UAAU,EACV,eAAe,EACf,IAAI,EACJ,MAAM,EACN,MAAM,EAEN,KAAK,GACN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,0FAA0F;AAC1F,OAAO,2BAA2B,CAAC;AAEnC,wCAAwC;AACxC,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAC;AAE5D,MAAM,QAAQ,GAAG;EACf,GA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AG,EAAE,CAAC;UACrB,CAAC,GACK;QACR,eAAa,CACT,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n inline,\n offset,\n Placement,\n shift,\n} from '@floating-ui/dom';\nimport isFocusable from 'ally.js/esm/is/focusable';\n\n// Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green\nimport '@oddbird/popover-polyfill';\n\n// Patch for long press on touch devices\nimport 'long-press-event';\n\nimport { version } from '../../../package.json';\nimport { checkOneOf } from '../../utils';\nimport { BACKGROUND_COLOR, BackgroundColor } from './types';\n\nconst SIDE_MAP = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n};\n\ninterface PopoverElement {\n showPopover: () => void;\n hidePopover: () => void;\n togglePopover: (force?: boolean) => boolean;\n}\n\n@Component({\n tag: 'post-tooltip',\n styleUrl: 'post-tooltip.scss',\n shadow: true,\n})\nexport class PostTooltip {\n private tooltipRef: HTMLDivElement & PopoverElement;\n private arrowRef: HTMLElement;\n private clearAutoUpdate: () => void;\n private readonly localShowTooltip: (e: Event) => Promise<void>;\n private readonly localHideTooltip: () => Promise<void>;\n private readonly localToggleTooltip: () => Promise<void>;\n private eventTarget: Element;\n\n @Element() host: HTMLPostTooltipElement;\n\n @State() tooltipClasses: string;\n\n /**\n * Defines the background color of the tooltip.\n * Choose the one that provides the best contrast in your scenario.\n */\n @Prop() readonly backgroundColor?: BackgroundColor = 'primary';\n\n /**\n * Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\n * Tooltips are automatically flipped to the opposite side if there is not enough available space and are shifted\n * towards the viewport if they would overlap edge boundaries.\n */\n @Prop() readonly placement?: Placement = 'top';\n\n @Watch('backgroundColor')\n validateBackgroundColor(newValue = this.backgroundColor) {\n checkOneOf(\n newValue,\n BACKGROUND_COLOR,\n `The post-tooltip \"background-color\" prop should contain one of those values: ${BACKGROUND_COLOR.join(\n ', ',\n )}`,\n );\n\n if (newValue === 'yellow') {\n this.tooltipClasses = 'bg-yellow';\n } else {\n this.tooltipClasses = 'bg-primary';\n }\n }\n\n constructor() {\n // Create local versions of event handlers for de-registration\n // https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class\n this.localShowTooltip = e => this.show(e.target as HTMLElement);\n this.localHideTooltip = this.hide.bind(this);\n this.localToggleTooltip = this.toggle.bind(this);\n }\n\n componentWillLoad() {\n this.validateBackgroundColor();\n\n // Append tooltip host to the end of the body to get around overflow: hidden restrictions\n // for browsers that don't support popover yet\n document.body.appendChild(this.host);\n }\n\n connectedCallback() {\n if (!this.host.id) {\n throw new Error(\n 'No id set: <post-tooltip> must have an id, linking it to it\\'s target element using the data-tooltip-target attribute.',\n );\n }\n\n if (!this.triggers) {\n throw new Error(\n `No trigger found for <post-tooltip id=\"${this.host.id}\">, please add the 'data-tooltip-target=\"${this.host.id}\" attribute to the trigger element.`,\n );\n }\n\n // Patch popovertargetaction=\"interest\" until it's implemented\n // https://github.com/openui/open-ui/issues/767#issuecomment-1654177227\n this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));\n }\n\n /**\n * Remove a bunch of event listeners if the tooltip gets removed from the DOM\n */\n disconnectedCallback() {\n this.triggers.forEach(trigger => {\n trigger.removeEventListener('mouseenter', this.localShowTooltip);\n trigger.removeEventListener('mouseleave', this.localHideTooltip);\n trigger.removeEventListener('focus', this.localShowTooltip);\n trigger.removeEventListener('blur', this.localHideTooltip);\n trigger.removeEventListener('long-press', this.localShowTooltip);\n });\n if (this.tooltipRef)\n this.tooltipRef.removeEventListener('beforetoggle', this.localToggleTooltip);\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\n }\n\n componentDidLoad() {\n // Has the benefit of rendering the tooltip without the popover attribute which\n // causes the tooltip to show up on the page if it's not linked to a target. This makes\n // the error obvious.\n if (!this.host.id || !this.triggers) return false;\n\n this.tooltipRef.setAttribute('popover', '');\n this.tooltipRef.addEventListener('beforetoggle', this.handleToggle.bind(this));\n }\n\n /**\n * Programmatically display the tooltip\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n */\n @Method()\n async show(target: HTMLElement) {\n this.eventTarget = target;\n this.tooltipRef.showPopover();\n }\n\n /**\n * Programmatically hide this tooltip\n */\n @Method()\n async hide() {\n this.eventTarget = null;\n this.tooltipRef.hidePopover();\n }\n\n /**\n * Toggle tooltip display\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n * @param force Pass true to always show or false to always hide\n */\n @Method()\n async toggle(target: HTMLElement, force?: boolean) {\n this.eventTarget = target;\n this.tooltipRef.togglePopover(force);\n }\n\n private get triggers() {\n return document.querySelectorAll(`[data-tooltip-target=\"${this.host.id}\"]`);\n }\n\n private patchPopoverTargetActionInterest(trigger: Element) {\n trigger.addEventListener('mouseenter', this.localShowTooltip);\n trigger.addEventListener('mouseleave', this.localHideTooltip);\n trigger.addEventListener('focus', this.localShowTooltip);\n trigger.addEventListener('blur', this.localHideTooltip);\n trigger.addEventListener('long-press', this.localShowTooltip);\n\n // Patch missing aria-describedby attribute on the trigger without overriding existing values\n const describedBy = trigger.getAttribute('aria-describedby');\n if (!describedBy?.includes(this.host.id)) {\n const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;\n trigger.setAttribute('aria-describedby', newDescribedBy);\n }\n\n // Patch missing focus ability on the trigger element\n if (!isFocusable(trigger)) {\n trigger.setAttribute('tabindex', '0');\n }\n }\n\n /**\n * Start or stop auto updates based on tooltip events.\n * Tooltips can be closed or opened with other methods than class members,\n * therefore listening to the toggle event is safer for cleaning up.\n * @param e ToggleEvent\n */\n private handleToggle(e: ToggleEvent) {\n const isOpen = e.newState === 'open';\n if (isOpen) {\n this.startAutoupdates();\n } else {\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\n }\n }\n\n /**\n * Start listening for DOM updates, scroll events etc. that have\n * an influence on tooltip positioning\n */\n private startAutoupdates() {\n this.clearAutoUpdate = autoUpdate(\n this.eventTarget,\n this.tooltipRef,\n this.positionTooltip.bind(this),\n );\n }\n\n // Tooltip and arrow positioning with floating-ui\n // Docs: https://floating-ui.com/docs/computePosition\n private async positionTooltip() {\n const {\n x,\n y,\n middlewareData,\n placement: currentPlacement,\n } = await computePosition(this.eventTarget, this.tooltipRef, {\n placement: this.placement || 'top',\n middleware: [\n flip(),\n inline(),\n shift({ padding: 8 }),\n offset(12), // 4px outside of element to account for focus outline + ~arrow size\n arrow({ element: this.arrowRef, padding: 8 }),\n ],\n });\n\n // Tooltip\n this.tooltipRef.style.left = `${x}px`;\n this.tooltipRef.style.top = `${y}px`;\n\n // Arrow\n // Tutorial: https://codesandbox.io/s/mystifying-kare-ee3hmh?file=/src/index.js\n const side = currentPlacement.split('-')[0];\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n const staticSide = SIDE_MAP[side];\n\n Object.assign(this.arrowRef.style, {\n top: arrowY ? `${arrowY}px` : '',\n left: arrowX ? `${arrowX}px` : '',\n [staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,\n });\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div\n role=\"tooltip\"\n tabindex=\"-1\"\n class={this.tooltipClasses}\n ref={(el: HTMLDivElement & PopoverElement) => (this.tooltipRef = el)}\n >\n <span\n class=\"arrow\"\n ref={el => {\n this.arrowRef = el;\n }}\n ></span>\n <slot></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export const BACKGROUND_COLOR = ['primary', 'yellow'];
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/post-tooltip/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAU,CAAC","sourcesContent":["export const BACKGROUND_COLOR = ['primary', 'yellow'] as const;\n\nexport type BackgroundColor = (typeof BACKGROUND_COLOR)[number];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"check-one-of.js","sourceRoot":"","sources":["../../../../src/utils/property-checkers/check-one-of.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,KAAa;EACxE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n"]}
1
+ {"version":3,"file":"check-one-of.js","sourceRoot":"","sources":["../../../../src/utils/property-checkers/check-one-of.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAI,KAAQ,EAAE,cAA4B,EAAE,KAAa;EACjF,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: readonly T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export function checkPattern(value, pattern, errorMessage) {
2
+ if (typeof value !== 'string' || !pattern.test(value))
3
+ throw new Error(errorMessage);
4
+ }
5
+ //# sourceMappingURL=check-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-pattern.js","sourceRoot":"","sources":["../../../../src/utils/property-checkers/check-pattern.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,OAAe,EAAE,YAAoB;EAChF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AACvF,CAAC","sourcesContent":["export function checkPattern(value: unknown, pattern: RegExp, errorMessage: string) {\n if (typeof value !== 'string' || !pattern.test(value)) throw new Error(errorMessage);\n}\n"]}
@@ -1,9 +1,12 @@
1
1
  import { emptyOr } from './empty-or';
2
2
  import { checkOneOf } from './check-one-of';
3
+ import { checkPattern } from './check-pattern';
3
4
  import { checkType } from './check-type';
4
5
  export const checkEmptyOrOneOf = emptyOr(checkOneOf);
6
+ export const checkEmptyOrPattern = emptyOr(checkPattern);
5
7
  export const checkEmptyOrType = emptyOr(checkType);
6
8
  export * from './check-non-empty';
7
9
  export * from './check-one-of';
10
+ export * from './check-pattern';
8
11
  export * from './check-type';
9
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/property-checkers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnD,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC","sourcesContent":["import { emptyOr } from './empty-or';\nimport { checkOneOf } from './check-one-of';\nimport { checkType } from './check-type';\n\nexport const checkEmptyOrOneOf = emptyOr(checkOneOf);\nexport const checkEmptyOrType = emptyOr(checkType);\n\nexport * from './check-non-empty';\nexport * from './check-one-of';\nexport * from './check-type';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/property-checkers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnD,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC","sourcesContent":["import { emptyOr } from './empty-or';\nimport { checkOneOf } from './check-one-of';\nimport { checkPattern } from './check-pattern';\nimport { checkType } from './check-type';\n\nexport const checkEmptyOrOneOf = emptyOr(checkOneOf);\nexport const checkEmptyOrPattern = emptyOr(checkPattern);\nexport const checkEmptyOrType = emptyOr(checkType);\n\nexport * from './check-non-empty';\nexport * from './check-one-of';\nexport * from './check-pattern';\nexport * from './check-type';\n"]}
@@ -0,0 +1,8 @@
1
+ function checkOneOf(value, possibleValues, error) {
2
+ if (!possibleValues.includes(value))
3
+ throw new Error(error);
4
+ }
5
+
6
+ export { checkOneOf as c };
7
+
8
+ //# sourceMappingURL=check-one-of.js.map
@@ -0,0 +1 @@
1
+ {"file":"check-one-of.js","mappings":"SAAgB,UAAU,CAAI,KAAQ,EAAE,cAA4B,EAAE,KAAa;EACjF,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D;;;;","names":[],"sources":["./src/utils/property-checkers/check-one-of.ts"],"sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: readonly T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n"],"version":3}
@@ -1,8 +1,3 @@
1
- function checkOneOf(value, possibleValues, error) {
2
- if (!possibleValues.includes(value))
3
- throw new Error(error);
4
- }
5
-
6
1
  function checkType(value, type, error) {
7
2
  const typeIsArray = type === 'array';
8
3
  const valueIsArray = Array.isArray(value);
@@ -16,6 +11,6 @@ function checkType(value, type, error) {
16
11
  }
17
12
  }
18
13
 
19
- export { checkOneOf as a, checkType as c };
14
+ export { checkType as c };
20
15
 
21
16
  //# sourceMappingURL=check-type.js.map
@@ -1 +1 @@
1
- {"file":"check-type.js","mappings":"SAAgB,UAAU,CAAI,KAAQ,EAAE,cAAmB,EAAE,KAAa;EACxE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9D;;SCMgB,SAAS,CAAC,KAAc,EAAE,IAAkB,EAAE,KAAa;EACzE,MAAM,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC;EACrC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,YAAY,KAAK,WAAW;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GAC1D;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,IAAI;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GACnD;AACH;;;;","names":[],"sources":["./src/utils/property-checkers/check-one-of.ts","./src/utils/property-checkers/check-type.ts"],"sourcesContent":["export function checkOneOf<T>(value: T, possibleValues: T[], error: string) {\n if (!possibleValues.includes(value)) throw new Error(error);\n}\n","export type PropertyType =\n | 'boolean'\n | 'number'\n | 'string'\n | 'array'\n | 'object'\n | 'function';\n\nexport function checkType(value: unknown, type: PropertyType, error: string) {\n const typeIsArray = type === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if (valueIsArray !== typeIsArray) throw new Error(error);\n } else {\n if (typeof value !== type) throw new Error(error);\n }\n}\n"],"version":3}
1
+ {"file":"check-type.js","mappings":"SAQgB,SAAS,CAAC,KAAc,EAAE,IAAkB,EAAE,KAAa;EACzE,MAAM,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC;EACrC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;EAE1C,IAAI,WAAW,IAAI,YAAY,EAAE;IAC/B,IAAI,YAAY,KAAK,WAAW;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GAC1D;OAAM;IACL,IAAI,OAAO,KAAK,KAAK,IAAI;MAAE,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;GACnD;AACH;;;;","names":[],"sources":["./src/utils/property-checkers/check-type.ts"],"sourcesContent":["export type PropertyType =\n | 'boolean'\n | 'number'\n | 'string'\n | 'array'\n | 'object'\n | 'function';\n\nexport function checkType(value: unknown, type: PropertyType, error: string) {\n const typeIsArray = type === 'array';\n const valueIsArray = Array.isArray(value);\n\n if (typeIsArray || valueIsArray) {\n if (valueIsArray !== typeIsArray) throw new Error(error);\n } else {\n if (typeof value !== type) throw new Error(error);\n }\n}\n"],"version":3}
@@ -0,0 +1,9 @@
1
+ const fadeDuration = 200;
2
+ const fadedOutKeyFrame = { opacity: '0' };
3
+ const fadedInKeyFrame = { opacity: '1' };
4
+ const fadeIn = (el) => el.animate([fadedOutKeyFrame, fadedInKeyFrame], { duration: fadeDuration });
5
+ const fadeOut = (el) => el.animate([fadedInKeyFrame, fadedOutKeyFrame], { duration: fadeDuration });
6
+
7
+ export { fadeIn as a, fadeOut as f };
8
+
9
+ //# sourceMappingURL=fade.js.map
@@ -0,0 +1 @@
1
+ {"file":"fade.js","mappings":"AAAA,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,gBAAgB,GAAG,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC;AACxC,MAAM,eAAe,GAAG,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC;MAE1B,MAAM,GAAG,CAAC,EAAW,KAAgB,EAAE,CAAC,OAAO,CAC1D,CAAE,gBAAgB,EAAE,eAAe,CAAE,EACrC,EAAE,QAAQ,EAAE,YAAY,EAAE,EAC1B;MAEW,OAAO,GAAG,CAAC,EAAW,KAAgB,EAAE,CAAC,OAAO,CAC3D,CAAE,eAAe,EAAE,gBAAgB,CAAE,EACrC,EAAE,QAAQ,EAAE,YAAY,EAAE;;;;","names":[],"sources":["./src/animations/fade.ts"],"sourcesContent":["const fadeDuration = 200;\nconst fadedOutKeyFrame = {opacity: '0'};\nconst fadedInKeyFrame = {opacity: '1'};\n\nexport const fadeIn = (el: Element): Animation => el.animate(\n [ fadedOutKeyFrame, fadedInKeyFrame ],\n { duration: fadeDuration }\n);\n\nexport const fadeOut = (el: Element): Animation => el.animate(\n [ fadedInKeyFrame, fadedOutKeyFrame ],\n { duration: fadeDuration }\n);\n"],"version":3}
@@ -1,4 +1,4 @@
1
- const version = "1.4.0";
1
+ const version = "1.5.1";
2
2
 
3
3
  export { version as v };
4
4
 
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface PostAlert extends Components.PostAlert, HTMLElement {}
4
+ export const PostAlert: {
5
+ prototype: PostAlert;
6
+ new (): PostAlert;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;