@aquera/nile-elements 0.1.35-beta-2.0 → 0.1.36

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 (242) hide show
  1. package/README.md +12 -66
  2. package/demo/index.css +4 -7
  3. package/demo/index.html +36 -20
  4. package/demo/variables.css +0 -13
  5. package/demo/variables_v2.css +0 -13
  6. package/dist/{fixture-df8b52d7.esm.js → fixture-2b5b3aba.esm.js} +1 -1
  7. package/dist/{fixture-d5b55278.cjs.js → fixture-7bfb866e.cjs.js} +3 -3
  8. package/dist/fixture-7bfb866e.cjs.js.map +1 -0
  9. package/dist/index.cjs.js +1 -1
  10. package/dist/index.esm.js +1 -1
  11. package/dist/internal/animate.cjs.js +1 -1
  12. package/dist/internal/animate.cjs.js.map +1 -1
  13. package/dist/internal/animate.esm.js +1 -1
  14. package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
  15. package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
  16. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  17. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
  18. package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
  19. package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
  20. package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
  21. package/dist/nile-badge/nile-badge.test.esm.js +1 -1
  22. package/dist/nile-button/nile-button.test.cjs.js +1 -1
  23. package/dist/nile-button/nile-button.test.esm.js +1 -1
  24. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
  25. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
  26. package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
  27. package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
  28. package/dist/nile-card/nile-card.test.cjs.js +1 -1
  29. package/dist/nile-card/nile-card.test.esm.js +1 -1
  30. package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
  31. package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
  32. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  33. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  34. package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
  35. package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
  36. package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
  37. package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
  38. package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
  39. package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
  40. package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
  41. package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
  42. package/dist/nile-error-message/nile-error-message.cjs.js +1 -1
  43. package/dist/nile-error-message/nile-error-message.cjs.js.map +1 -1
  44. package/dist/nile-error-message/nile-error-message.css.cjs.js +1 -1
  45. package/dist/nile-error-message/nile-error-message.css.cjs.js.map +1 -1
  46. package/dist/nile-error-message/nile-error-message.css.esm.js +4 -6
  47. package/dist/nile-error-message/nile-error-message.esm.js +4 -4
  48. package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
  49. package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
  50. package/dist/nile-error-notification/nile-error-notification.css.cjs.js +1 -1
  51. package/dist/nile-error-notification/nile-error-notification.css.cjs.js.map +1 -1
  52. package/dist/nile-error-notification/nile-error-notification.css.esm.js +1 -1
  53. package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
  54. package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
  55. package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
  56. package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
  57. package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
  58. package/dist/nile-hero/nile-hero.test.esm.js +1 -1
  59. package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
  60. package/dist/nile-icon/nile-icon.test.esm.js +1 -1
  61. package/dist/nile-input/nile-input.test.cjs.js +1 -1
  62. package/dist/nile-input/nile-input.test.esm.js +1 -1
  63. package/dist/nile-link/nile-link.test.cjs.js +1 -1
  64. package/dist/nile-link/nile-link.test.esm.js +1 -1
  65. package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
  66. package/dist/nile-loader/nile-loader.test.esm.js +1 -1
  67. package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
  68. package/dist/nile-popover/nile-popover.test.esm.js +1 -1
  69. package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
  70. package/dist/nile-popup/nile-popup.test.esm.js +1 -1
  71. package/dist/nile-progress-bar/nile-progress-bar.css.cjs.js +1 -1
  72. package/dist/nile-progress-bar/nile-progress-bar.css.cjs.js.map +1 -1
  73. package/dist/nile-progress-bar/nile-progress-bar.css.esm.js +0 -1
  74. package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
  75. package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
  76. package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
  77. package/dist/nile-radio/nile-radio.test.esm.js +1 -1
  78. package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
  79. package/dist/nile-radio-group/nile-radio-group.test.esm.js +1 -1
  80. package/dist/nile-select/nile-select.cjs.js +1 -1
  81. package/dist/nile-select/nile-select.cjs.js.map +1 -1
  82. package/dist/nile-select/nile-select.esm.js +1 -1
  83. package/dist/nile-select/nile-select.test.cjs.js +1 -1
  84. package/dist/nile-select/nile-select.test.esm.js +1 -1
  85. package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
  86. package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
  87. package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
  88. package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
  89. package/dist/nile-table/nile-table.cjs.js.map +1 -1
  90. package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
  91. package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
  92. package/dist/nile-tooltip/index.cjs.js +1 -1
  93. package/dist/nile-tooltip/index.esm.js +1 -1
  94. package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
  95. package/dist/nile-tooltip/nile-tooltip.cjs.js.map +1 -1
  96. package/dist/nile-tooltip/nile-tooltip.css.cjs.js +1 -1
  97. package/dist/nile-tooltip/nile-tooltip.css.cjs.js.map +1 -1
  98. package/dist/nile-tooltip/nile-tooltip.css.esm.js +45 -78
  99. package/dist/nile-tooltip/nile-tooltip.esm.js +28 -23
  100. package/dist/src/index.d.ts +0 -1
  101. package/dist/src/index.js +0 -1
  102. package/dist/src/index.js.map +1 -1
  103. package/dist/src/nile-error-message/nile-error-message.css.js +4 -6
  104. package/dist/src/nile-error-message/nile-error-message.css.js.map +1 -1
  105. package/dist/src/nile-error-message/nile-error-message.d.ts +0 -4
  106. package/dist/src/nile-error-message/nile-error-message.js +0 -20
  107. package/dist/src/nile-error-message/nile-error-message.js.map +1 -1
  108. package/dist/src/nile-error-notification/nile-error-notification.css.js +1 -1
  109. package/dist/src/nile-error-notification/nile-error-notification.css.js.map +1 -1
  110. package/dist/src/nile-file-preview/index.d.ts +1 -0
  111. package/dist/src/nile-file-preview/index.js +2 -0
  112. package/dist/src/nile-file-preview/index.js.map +1 -0
  113. package/dist/src/{nile-filter-chip/nile-filter-chip.css.d.ts → nile-file-preview/nile-file-preview.css.d.ts} +1 -1
  114. package/dist/src/nile-file-preview/nile-file-preview.css.js +533 -0
  115. package/dist/src/nile-file-preview/nile-file-preview.css.js.map +1 -0
  116. package/dist/src/nile-file-preview/nile-file-preview.d.ts +48 -0
  117. package/dist/src/nile-file-preview/nile-file-preview.js +149 -0
  118. package/dist/src/nile-file-preview/nile-file-preview.js.map +1 -0
  119. package/dist/src/nile-file-preview/nile-file-preview.template.d.ts +11 -0
  120. package/dist/src/nile-file-preview/nile-file-preview.template.js +144 -0
  121. package/dist/src/nile-file-preview/nile-file-preview.template.js.map +1 -0
  122. package/dist/src/nile-file-preview/nile-file-preview.test.d.ts +7 -0
  123. package/dist/src/nile-file-preview/nile-file-preview.test.js +30 -0
  124. package/dist/src/nile-file-preview/nile-file-preview.test.js.map +1 -0
  125. package/dist/src/nile-file-preview/types/file-preview.enums.d.ts +23 -0
  126. package/dist/src/nile-file-preview/types/file-preview.enums.js +28 -0
  127. package/dist/src/nile-file-preview/types/file-preview.enums.js.map +1 -0
  128. package/dist/src/nile-file-preview/types/file-preview.interface.d.ts +4 -0
  129. package/dist/src/nile-file-preview/types/file-preview.interface.js +2 -0
  130. package/dist/src/nile-file-preview/types/file-preview.interface.js.map +1 -0
  131. package/dist/src/nile-file-preview/types/index.d.ts +2 -0
  132. package/dist/src/nile-file-preview/types/index.js +3 -0
  133. package/dist/src/nile-file-preview/types/index.js.map +1 -0
  134. package/dist/src/nile-file-preview/utils/file-preview.util.d.ts +3 -0
  135. package/dist/src/nile-file-preview/utils/file-preview.util.js +29 -0
  136. package/dist/src/nile-file-preview/utils/file-preview.util.js.map +1 -0
  137. package/dist/src/nile-file-preview/utils/index.d.ts +1 -0
  138. package/dist/src/nile-file-preview/utils/index.js +2 -0
  139. package/dist/src/nile-file-preview/utils/index.js.map +1 -0
  140. package/dist/src/nile-file-upload/index.d.ts +1 -0
  141. package/dist/src/nile-file-upload/index.js +2 -0
  142. package/dist/src/{nile-filter-chip → nile-file-upload}/index.js.map +1 -1
  143. package/dist/src/nile-file-upload/nile-file-upload.css.d.ts +12 -0
  144. package/dist/src/nile-file-upload/nile-file-upload.css.js +547 -0
  145. package/dist/src/nile-file-upload/nile-file-upload.css.js.map +1 -0
  146. package/dist/src/nile-file-upload/nile-file-upload.d.ts +45 -0
  147. package/dist/src/nile-file-upload/nile-file-upload.js +148 -0
  148. package/dist/src/nile-file-upload/nile-file-upload.js.map +1 -0
  149. package/dist/src/nile-file-upload/nile-file-upload.template.d.ts +11 -0
  150. package/dist/src/nile-file-upload/nile-file-upload.template.js +163 -0
  151. package/dist/src/nile-file-upload/nile-file-upload.template.js.map +1 -0
  152. package/dist/src/nile-file-upload/nile-file-upload.test.d.ts +7 -0
  153. package/dist/src/nile-file-upload/nile-file-upload.test.js +30 -0
  154. package/dist/src/nile-file-upload/nile-file-upload.test.js.map +1 -0
  155. package/dist/src/nile-file-upload/types/file-upload.enums.d.ts +28 -0
  156. package/dist/src/nile-file-upload/types/file-upload.enums.js +35 -0
  157. package/dist/src/nile-file-upload/types/file-upload.enums.js.map +1 -0
  158. package/dist/src/nile-file-upload/types/file-upload.type.d.ts +4 -0
  159. package/dist/src/nile-file-upload/types/file-upload.type.js +2 -0
  160. package/dist/src/nile-file-upload/types/file-upload.type.js.map +1 -0
  161. package/dist/src/nile-file-upload/types/index.d.ts +2 -0
  162. package/dist/src/nile-file-upload/types/index.js +3 -0
  163. package/dist/src/nile-file-upload/types/index.js.map +1 -0
  164. package/dist/src/nile-file-upload/utils/drag-drop.util.d.ts +19 -0
  165. package/dist/src/nile-file-upload/utils/drag-drop.util.js +77 -0
  166. package/dist/src/nile-file-upload/utils/drag-drop.util.js.map +1 -0
  167. package/dist/src/nile-file-upload/utils/file-validation.util.d.ts +9 -0
  168. package/dist/src/nile-file-upload/utils/file-validation.util.js +58 -0
  169. package/dist/src/nile-file-upload/utils/file-validation.util.js.map +1 -0
  170. package/dist/src/nile-progress-bar/nile-progress-bar.css.js +0 -1
  171. package/dist/src/nile-progress-bar/nile-progress-bar.css.js.map +1 -1
  172. package/dist/src/nile-select/nile-select.js +1 -1
  173. package/dist/src/nile-select/nile-select.js.map +1 -1
  174. package/dist/src/nile-table/nile-table.js.map +1 -1
  175. package/dist/src/nile-tooltip/nile-tooltip.css.js +43 -76
  176. package/dist/src/nile-tooltip/nile-tooltip.css.js.map +1 -1
  177. package/dist/src/nile-tooltip/nile-tooltip.d.ts +46 -24
  178. package/dist/src/nile-tooltip/nile-tooltip.js +232 -235
  179. package/dist/src/nile-tooltip/nile-tooltip.js.map +1 -1
  180. package/dist/tsconfig.tsbuildinfo +1 -1
  181. package/package.json +2 -2
  182. package/plop-templates/lit/index.ts.hbs +1 -1
  183. package/plop-templates/lit/lit.css.ts.hbs +1 -1
  184. package/plop-templates/lit/lit.ts.hbs +3 -7
  185. package/plopfile.js +1 -32
  186. package/src/index.ts +1 -2
  187. package/src/nile-error-message/nile-error-message.css.ts +4 -6
  188. package/src/nile-error-message/nile-error-message.ts +0 -18
  189. package/src/nile-error-notification/nile-error-notification.css.ts +1 -1
  190. package/src/nile-progress-bar/nile-progress-bar.css.ts +0 -1
  191. package/src/nile-select/nile-select.ts +1 -1
  192. package/src/nile-table/nile-table.ts +2 -2
  193. package/src/nile-tooltip/nile-tooltip.css.ts +44 -77
  194. package/src/nile-tooltip/nile-tooltip.ts +230 -268
  195. package/vscode-html-custom-data.json +95 -144
  196. package/dist/fixture-d5b55278.cjs.js.map +0 -1
  197. package/dist/nile-filter-chip/index.cjs.js +0 -2
  198. package/dist/nile-filter-chip/index.cjs.js.map +0 -1
  199. package/dist/nile-filter-chip/index.esm.js +0 -1
  200. package/dist/nile-filter-chip/nile-filter-chip.cjs.js +0 -2
  201. package/dist/nile-filter-chip/nile-filter-chip.cjs.js.map +0 -1
  202. package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js +0 -2
  203. package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js.map +0 -1
  204. package/dist/nile-filter-chip/nile-filter-chip.css.esm.js +0 -121
  205. package/dist/nile-filter-chip/nile-filter-chip.esm.js +0 -43
  206. package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +0 -2
  207. package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js.map +0 -1
  208. package/dist/nile-filter-chip/nile-filter-chip.test.esm.js +0 -20
  209. package/dist/nile-tooltip/nile-tooltip-utils.cjs.js +0 -2
  210. package/dist/nile-tooltip/nile-tooltip-utils.cjs.js.map +0 -1
  211. package/dist/nile-tooltip/nile-tooltip-utils.esm.js +0 -1
  212. package/dist/nile-tooltip/nile-tooltip.test.cjs.js +0 -2
  213. package/dist/nile-tooltip/nile-tooltip.test.cjs.js.map +0 -1
  214. package/dist/nile-tooltip/nile-tooltip.test.esm.js +0 -47
  215. package/dist/src/nile-filter-chip/index.d.ts +0 -1
  216. package/dist/src/nile-filter-chip/index.js +0 -2
  217. package/dist/src/nile-filter-chip/nile-filter-chip.css.js +0 -133
  218. package/dist/src/nile-filter-chip/nile-filter-chip.css.js.map +0 -1
  219. package/dist/src/nile-filter-chip/nile-filter-chip.d.ts +0 -36
  220. package/dist/src/nile-filter-chip/nile-filter-chip.js +0 -141
  221. package/dist/src/nile-filter-chip/nile-filter-chip.js.map +0 -1
  222. package/dist/src/nile-filter-chip/nile-filter-chip.test.d.ts +0 -1
  223. package/dist/src/nile-filter-chip/nile-filter-chip.test.js +0 -80
  224. package/dist/src/nile-filter-chip/nile-filter-chip.test.js.map +0 -1
  225. package/dist/src/nile-tooltip/nile-tooltip-utils.d.ts +0 -18
  226. package/dist/src/nile-tooltip/nile-tooltip-utils.js +0 -216
  227. package/dist/src/nile-tooltip/nile-tooltip-utils.js.map +0 -1
  228. package/dist/src/nile-tooltip/nile-tooltip.test.d.ts +0 -1
  229. package/dist/src/nile-tooltip/nile-tooltip.test.js +0 -148
  230. package/dist/src/nile-tooltip/nile-tooltip.test.js.map +0 -1
  231. package/plop-templates/lit/lit.template.ts.hbs +0 -3
  232. package/plop-templates/lit/lit.test.ts.hbs +0 -38
  233. package/plop-templates/lit/sub-components/index.ts.hbs +0 -4
  234. package/plop-templates/lit/types/index.ts.hbs +0 -0
  235. package/plop-templates/lit/types/type.ts.hbs +0 -3
  236. package/plop-templates/lit/utils/lit.utils.ts.hbs +0 -4
  237. package/src/nile-filter-chip/index.ts +0 -1
  238. package/src/nile-filter-chip/nile-filter-chip.css.ts +0 -138
  239. package/src/nile-filter-chip/nile-filter-chip.test.ts +0 -92
  240. package/src/nile-filter-chip/nile-filter-chip.ts +0 -136
  241. package/src/nile-tooltip/nile-tooltip-utils.ts +0 -271
  242. package/src/nile-tooltip/nile-tooltip.test.ts +0 -168
@@ -1,17 +1,23 @@
1
- import { __decorate } from "tslib";
2
1
  /**
3
2
  * Copyright Aquera Inc 2023
4
3
  *
5
4
  * This source code is licensed under the BSD-3-Clause license found in the
6
5
  * LICENSE file in the root directory of this source tree.
7
6
  */
8
- import { html } from 'lit';
9
- import { customElement, property, query } from 'lit/decorators.js';
7
+ import { __decorate } from "tslib";
10
8
  import { styles } from './nile-tooltip.css';
9
+ import '../nile-popup/nile-popup';
10
+ import { animateTo, parseDuration, stopAnimations } from '../internal/animate';
11
+ import { classMap } from 'lit/directives/class-map.js';
12
+ import { customElement, property, query } from 'lit/decorators.js';
13
+ import { getAnimation, setDefaultAnimation, } from '../utilities/animation-registry';
14
+ import { html } from 'lit';
15
+ // import { LocalizeController } from '../utilities/localize';
16
+ import { waitForEvent } from '../internal/event';
17
+ import { watch } from '../internal/watch';
11
18
  import NileElement from '../internal/nile-element';
12
- import { isInViewport, getValidTooltipPosition, getCaretPosition } from './nile-tooltip-utils';
13
19
  /**
14
- * Nile tooltip component.
20
+ * Nile icon component.
15
21
  *
16
22
  * @tag nile-tooltip
17
23
  *
@@ -19,288 +25,279 @@ import { isInViewport, getValidTooltipPosition, getCaretPosition } from './nile-
19
25
  let NileTooltip = class NileTooltip extends NileElement {
20
26
  constructor() {
21
27
  super(...arguments);
28
+ /** The tooltip's content. If you need to display HTML, use the `content` slot instead. */
22
29
  this.content = '';
30
+ /** Size Property to decide the tool tip size */
31
+ this.size = 'small';
32
+ /**
33
+ * The preferred placement of the tooltip. Note that the actual placement may vary as needed to keep the tooltip
34
+ * inside of the viewport.
35
+ */
23
36
  this.placement = 'top';
37
+ /** Disables the tooltip so it won't show when triggered. */
24
38
  this.disabled = false;
39
+ /** The distance in pixels from which to offset the tooltip away from its target. */
40
+ this.distance = 8;
41
+ /** Indicates whether or not the tooltip is open. You can use this in lieu of the show/hide methods. */
25
42
  this.open = false;
43
+ /** The distance in pixels from which to offset the tooltip along its target. */
44
+ this.skidding = 0;
26
45
  /**
27
46
  * Controls how the tooltip is activated. Possible options include `click`, `hover`, `focus`, and `manual`. Multiple
28
47
  * options can be passed by separating them with a space. When manual is used, the tooltip must be activated
29
48
  * programmatically.
30
49
  */
31
50
  this.trigger = 'hover focus';
32
- this.distance = 8;
33
- this.SHIFT_OFFSET = 16;
34
- /** The distance in pixels from which to offset the tooltip along its target. */
35
- this.skidding = 0;
51
+ /**
52
+ * Enable this option to prevent the tooltip from being clipped when the component is placed inside a container with
53
+ * `overflow: auto|hidden|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all,
54
+ * scenarios.
55
+ */
36
56
  this.hoist = false;
37
- this.hasTooltipSlot = false;
38
- this.hoverTimeout = 0;
39
- this.caretSize = 6;
40
- this.originalPlacement = this.placement;
41
- this.updateTooltipPosition = () => {
42
- if (!isInViewport(this.triggerContainer)) {
43
- this.open = false;
44
- return;
45
- }
46
- const triggerRect = this.triggerContainer.getBoundingClientRect();
47
- const tooltipRect = this.tooltip.getBoundingClientRect();
48
- const viewportWidth = window.innerWidth;
49
- const viewportHeight = window.innerHeight;
50
- let { top, left, placement } = getValidTooltipPosition(triggerRect, tooltipRect, this.originalPlacement, this.distance, this.skidding, this.caretSize, viewportWidth, viewportHeight);
51
- // FallBack Positions
52
- // Bottom
53
- if (this.originalPlacement.startsWith('bottom')) {
54
- const availableSpaceBelow = viewportHeight - triggerRect.bottom;
55
- if (availableSpaceBelow < tooltipRect.height + this.distance) {
56
- let newPlacement = 'top';
57
- if (this.originalPlacement === 'bottom-start') {
58
- newPlacement = 'top';
59
- }
60
- else if (this.originalPlacement === 'bottom-end') {
61
- newPlacement = 'top';
62
- }
63
- const newPosition = getValidTooltipPosition(triggerRect, tooltipRect, newPlacement, this.distance, this.skidding, this.caretSize, viewportWidth, viewportHeight);
64
- top = newPosition.top;
65
- left = newPosition.left;
66
- placement = newPosition.placement;
67
- }
68
- }
69
- // Top
70
- if (this.originalPlacement.startsWith('top')) {
71
- const availableSpaceAbove = triggerRect.top;
72
- const availableSpaceBelow = viewportHeight - triggerRect.bottom;
73
- if (availableSpaceAbove < tooltipRect.height + this.distance && availableSpaceBelow >= tooltipRect.height + this.distance) {
74
- let newPlacement = 'bottom';
75
- if (this.originalPlacement === 'top-start') {
76
- newPlacement = 'bottom-start';
77
- }
78
- else if (this.originalPlacement === 'top-end') {
79
- newPlacement = 'bottom-end';
80
- }
81
- const newPosition = getValidTooltipPosition(triggerRect, tooltipRect, newPlacement, this.distance, this.skidding, this.caretSize, viewportWidth, viewportHeight);
82
- top = newPosition.top;
83
- left = newPosition.left;
84
- placement = newPosition.placement;
85
- }
86
- }
87
- // Left
88
- if (this.originalPlacement.startsWith('left')) {
89
- const availableSpaceLeft = triggerRect.left;
90
- const availableSpaceRight = viewportWidth - triggerRect.right;
91
- if (availableSpaceLeft < tooltipRect.width + this.distance && availableSpaceRight >= tooltipRect.width + this.distance) {
92
- let newPlacement = 'right';
93
- if (this.originalPlacement === 'left-start') {
94
- newPlacement = 'right-start';
95
- }
96
- else if (this.originalPlacement === 'left-end') {
97
- newPlacement = 'right-end';
98
- }
99
- const newPosition = getValidTooltipPosition(triggerRect, tooltipRect, newPlacement, this.distance, this.skidding, this.caretSize, viewportWidth, viewportHeight);
100
- top = newPosition.top;
101
- left = newPosition.left;
102
- placement = newPosition.placement;
103
- }
104
- }
105
- // Right
106
- if (this.originalPlacement.startsWith('right')) {
107
- const availableSpaceRight = viewportWidth - triggerRect.right;
108
- const availableSpaceLeft = triggerRect.left;
109
- if (availableSpaceRight < tooltipRect.width + this.distance && availableSpaceLeft >= tooltipRect.width + this.distance) {
110
- let newPlacement = 'left';
111
- if (this.originalPlacement === 'right-start') {
112
- newPlacement = 'left-start';
113
- }
114
- else if (this.originalPlacement === 'right-end') {
115
- newPlacement = 'left-end';
116
- }
117
- const newPosition = getValidTooltipPosition(triggerRect, tooltipRect, newPlacement, this.distance, this.skidding, this.caretSize, viewportWidth, viewportHeight);
118
- top = newPosition.top;
119
- left = newPosition.left;
120
- placement = newPosition.placement;
121
- }
122
- }
123
- this.setAttribute('placement', placement);
124
- this.tooltip.style.top = `${top}px`;
125
- this.tooltip.style.left = `${left}px`;
126
- const { caretLeft, caretTop } = getCaretPosition({
127
- placement,
128
- tooltipRect,
129
- triggerRect,
130
- caretSize: this.caretSize,
131
- left,
132
- top
133
- });
134
- this.caret.style.left = `${caretLeft}px`;
135
- this.caret.style.top = `${caretTop}px`;
136
- };
137
- this.showTooltip = () => {
138
- const trimmedContent = this.content.trim();
139
- if (!trimmedContent && !this.hasTooltipSlot) {
140
- return;
141
- }
142
- if (!this.disabled && isInViewport(this.triggerContainer)) {
143
- this.emit('nile-show');
144
- this.open = true;
145
- this.updateComplete.then(() => {
146
- requestAnimationFrame(() => {
147
- this.updateTooltipPosition();
148
- this.emit('nile-after-show');
149
- });
150
- });
151
- }
152
- else {
153
- this.open = false;
154
- }
155
- };
156
- this.hideTooltip = () => {
157
- this.emit('nile-hide');
158
- this.open = false;
159
- setTimeout(() => {
160
- this.emit('nile-after-hide');
161
- }, 200);
162
- };
163
- this.handleMouseOver = () => {
164
- if (this.trigger.includes('hover')) {
165
- clearTimeout(this.hoverTimeout);
166
- this.hoverTimeout = window.setTimeout(() => this.showTooltip(), 300);
167
- }
168
- };
169
- this.handleMouseOut = () => {
170
- if (this.trigger.includes('hover')) {
171
- clearTimeout(this.hoverTimeout);
172
- this.hoverTimeout = window.setTimeout(() => this.hideTooltip(), 150);
173
- }
174
- };
175
- this.handleClick = () => {
176
- if (this.trigger.includes('click')) {
177
- if (!this.open && isInViewport(this.triggerContainer)) {
178
- this.showTooltip();
179
- }
180
- else {
181
- this.hideTooltip();
182
- }
183
- }
184
- };
185
- this.handleFocus = () => {
186
- if (this.trigger.includes('focus')) {
187
- this.showTooltip();
188
- }
189
- };
190
- this.handleBlur = () => {
191
- if (this.trigger.includes('focus')) {
192
- this.hideTooltip();
193
- }
194
- };
195
57
  }
58
+ /**
59
+ * The styles for Tooltip
60
+ * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
61
+ */
196
62
  static get styles() {
197
63
  return [styles];
198
64
  }
199
65
  connectedCallback() {
200
66
  super.connectedCallback();
201
- this.originalPlacement = this.placement;
202
- window.addEventListener('resize', this.updateTooltipPosition);
203
- window.addEventListener('scroll', this.updateTooltipPosition, true);
67
+ this.handleBlur = this.handleBlur.bind(this);
68
+ this.handleClick = this.handleClick.bind(this);
69
+ this.handleFocus = this.handleFocus.bind(this);
70
+ this.handleKeyDown = this.handleKeyDown.bind(this);
71
+ this.handleMouseOver = this.handleMouseOver.bind(this);
72
+ this.handleMouseOut = this.handleMouseOut.bind(this);
73
+ this.updateComplete.then(() => {
74
+ this.addEventListener('blur', this.handleBlur, true);
75
+ this.addEventListener('focus', this.handleFocus, true);
76
+ this.addEventListener('click', this.handleClick);
77
+ this.addEventListener('keydown', this.handleKeyDown);
78
+ this.addEventListener('mouseover', this.handleMouseOver);
79
+ this.addEventListener('mouseout', this.handleMouseOut);
80
+ });
204
81
  }
205
- updated(changedProps) {
206
- super.updated?.(changedProps);
207
- const validPlacements = [
208
- 'top', 'top-start', 'top-end',
209
- 'right', 'right-start', 'right-end',
210
- 'bottom', 'bottom-start', 'bottom-end',
211
- 'left', 'left-start', 'left-end'
212
- ];
213
- if (!validPlacements.includes(this.placement)) {
214
- console.warn(`[nile-tooltip] Invalid placement "${this.placement}", defaulting to "bottom".`);
215
- this.placement = 'top';
82
+ firstUpdated() {
83
+ this.body.hidden = !this.open;
84
+ // If the tooltip is visible on init, update its position
85
+ if (this.open) {
86
+ this.popup.active = true;
87
+ this.popup.reposition();
216
88
  }
217
- if (!validPlacements.includes(this.originalPlacement)) {
218
- this.originalPlacement = 'top';
89
+ }
90
+ disconnectedCallback() {
91
+ super.disconnectedCallback();
92
+ this.removeEventListener('blur', this.handleBlur, true);
93
+ this.removeEventListener('focus', this.handleFocus, true);
94
+ this.removeEventListener('click', this.handleClick);
95
+ this.removeEventListener('keydown', this.handleKeyDown);
96
+ this.removeEventListener('mouseover', this.handleMouseOver);
97
+ this.removeEventListener('mouseout', this.handleMouseOut);
98
+ }
99
+ handleBlur() {
100
+ if (this.hasTrigger('focus')) {
101
+ this.hide();
219
102
  }
220
- if (changedProps.has('open') && this.open) {
221
- this.updateComplete.then(() => {
222
- requestAnimationFrame(() => {
223
- this.updateTooltipPosition();
224
- });
103
+ }
104
+ handleClick() {
105
+ if (this.hasTrigger('click')) {
106
+ if (this.open) {
107
+ this.hide();
108
+ }
109
+ else {
110
+ this.show();
111
+ }
112
+ }
113
+ }
114
+ handleFocus() {
115
+ if (this.hasTrigger('focus')) {
116
+ this.show();
117
+ }
118
+ }
119
+ handleKeyDown(event) {
120
+ // Pressing escape when the target element has focus should dismiss the tooltip
121
+ if (this.open && event.key === 'Escape') {
122
+ event.stopPropagation();
123
+ this.hide();
124
+ }
125
+ }
126
+ handleMouseOver() {
127
+ if (this.hasTrigger('hover')) {
128
+ const delay = parseDuration(getComputedStyle(this).getPropertyValue('--show-delay'));
129
+ clearTimeout(this.hoverTimeout);
130
+ this.hoverTimeout = window.setTimeout(() => this.show(), delay);
131
+ }
132
+ }
133
+ handleMouseOut() {
134
+ if (this.hasTrigger('hover')) {
135
+ const delay = parseDuration(getComputedStyle(this).getPropertyValue('--hide-delay'));
136
+ clearTimeout(this.hoverTimeout);
137
+ this.hoverTimeout = window.setTimeout(() => this.hide(), delay);
138
+ }
139
+ }
140
+ hasTrigger(triggerType) {
141
+ const triggers = this.trigger.split(' ');
142
+ return triggers.includes(triggerType);
143
+ }
144
+ async handleOpenChange() {
145
+ if (this.open) {
146
+ if (this.disabled) {
147
+ return;
148
+ }
149
+ // Show
150
+ this.emit('nile-show');
151
+ await stopAnimations(this.body);
152
+ this.body.hidden = false;
153
+ this.popup.active = true;
154
+ const { keyframes, options } = getAnimation(this, 'tooltip.show', {
155
+ dir: '',
225
156
  });
157
+ await animateTo(this.popup.popup, keyframes, options);
158
+ this.emit('nile-after-show');
159
+ }
160
+ else {
161
+ // Hide
162
+ this.emit('nile-hide');
163
+ await stopAnimations(this.body);
164
+ const { keyframes, options } = getAnimation(this, 'tooltip.hide', {
165
+ dir: '',
166
+ });
167
+ await animateTo(this.popup.popup, keyframes, options);
168
+ this.popup.active = false;
169
+ this.body.hidden = true;
170
+ this.emit('nile-after-hide');
226
171
  }
227
172
  }
228
- disconnectedCallback() {
229
- super.disconnectedCallback();
230
- window.removeEventListener('resize', this.updateTooltipPosition);
231
- window.removeEventListener('scroll', this.updateTooltipPosition, true);
173
+ async handleOptionsChange() {
174
+ if (this.hasUpdated) {
175
+ await this.updateComplete;
176
+ this.popup.reposition();
177
+ }
232
178
  }
233
- handleTooltipSlotChange() {
234
- const nodes = this.tooltipSlot.assignedNodes({ flatten: true });
235
- this.hasTooltipSlot = nodes.length > 0;
236
- this.requestUpdate();
179
+ handleDisabledChange() {
180
+ if (this.disabled && this.open) {
181
+ this.hide();
182
+ }
183
+ }
184
+ /** Shows the tooltip. */
185
+ async show() {
186
+ if (this.open || !this.content?.trim().length) {
187
+ return undefined;
188
+ }
189
+ this.open = true;
190
+ return waitForEvent(this, 'nile-after-show');
191
+ }
192
+ /** Hides the tooltip */
193
+ async hide() {
194
+ if (!this.open) {
195
+ return undefined;
196
+ }
197
+ this.open = false;
198
+ return waitForEvent(this, 'nile-after-hide');
237
199
  }
238
200
  render() {
239
201
  return html `
240
- <div
241
- class="tooltip"
242
- id="tooltip"
202
+ <nile-popup
203
+ part="base"
204
+ exportparts="
205
+ popup:base__popup,
206
+ arrow:base__arrow
207
+ "
208
+ class=${classMap({
209
+ tooltip: true,
210
+ 'tooltip--open': this.open,
211
+ })}
212
+ placement=${this.placement}
213
+ distance=${this.distance}
214
+ skidding=${this.skidding}
215
+ strategy=${this.hoist ? 'fixed' : 'absolute'}
216
+ flip
217
+ shift
218
+ arrow
243
219
  >
244
- <div class="tooltip-content" part="content">
245
- <slot name="content" @slotchange=${this.handleTooltipSlotChange}></slot>
246
- ${!this.hasTooltipSlot ? html `${this.content}` : null}
247
- </div>
248
- <div class="tooltip-caret" style="--caret-size: ${this.caretSize}px;"></div>
249
- </div>
220
+ <slot slot="anchor" aria-describedby="tooltip"></slot>
250
221
 
251
- <div
252
- class="trigger-container"
253
- tabindex="0"
254
- @mouseover=${this.handleMouseOver}
255
- @mouseout=${this.handleMouseOut}
256
- @click=${this.handleClick}
257
- @focusin=${this.handleFocus}
258
- @focusout=${this.handleBlur}
259
- aria-describedby="tooltip"
260
- >
261
- <slot></slot>
262
- </div>
222
+ <slot
223
+ name="content"
224
+ part="body"
225
+ id="tooltip"
226
+ class=${classMap({
227
+ tooltip__body: true,
228
+ 'tooltip__body--large': this.size === 'large',
229
+ })}
230
+ role="tooltip"
231
+ aria-live=${this.open ? 'polite' : 'off'}
232
+ >
233
+ ${this.content}
234
+ </slot>
235
+ </nile-popup>
263
236
  `;
264
237
  }
265
238
  };
266
239
  __decorate([
267
- property({ type: String })
240
+ query('slot:not([name])')
241
+ ], NileTooltip.prototype, "defaultSlot", void 0);
242
+ __decorate([
243
+ query('.tooltip__body')
244
+ ], NileTooltip.prototype, "body", void 0);
245
+ __decorate([
246
+ query('nile-popup')
247
+ ], NileTooltip.prototype, "popup", void 0);
248
+ __decorate([
249
+ property({ type: String, reflect: true })
268
250
  ], NileTooltip.prototype, "content", void 0);
269
251
  __decorate([
270
- property({ type: String })
252
+ property({ reflect: true })
253
+ ], NileTooltip.prototype, "size", void 0);
254
+ __decorate([
255
+ property()
271
256
  ], NileTooltip.prototype, "placement", void 0);
272
257
  __decorate([
273
258
  property({ type: Boolean, reflect: true })
274
259
  ], NileTooltip.prototype, "disabled", void 0);
275
- __decorate([
276
- property({ type: Boolean, reflect: true })
277
- ], NileTooltip.prototype, "open", void 0);
278
- __decorate([
279
- property()
280
- ], NileTooltip.prototype, "trigger", void 0);
281
260
  __decorate([
282
261
  property({ type: Number })
283
262
  ], NileTooltip.prototype, "distance", void 0);
263
+ __decorate([
264
+ property({ type: Boolean, reflect: true })
265
+ ], NileTooltip.prototype, "open", void 0);
284
266
  __decorate([
285
267
  property({ type: Number })
286
268
  ], NileTooltip.prototype, "skidding", void 0);
287
269
  __decorate([
288
- property({ type: Boolean, reflect: true })
289
- ], NileTooltip.prototype, "hoist", void 0);
270
+ property()
271
+ ], NileTooltip.prototype, "trigger", void 0);
290
272
  __decorate([
291
- query('.tooltip')
292
- ], NileTooltip.prototype, "tooltip", void 0);
273
+ property({ type: Boolean })
274
+ ], NileTooltip.prototype, "hoist", void 0);
293
275
  __decorate([
294
- query('.trigger-container')
295
- ], NileTooltip.prototype, "triggerContainer", void 0);
276
+ watch('open', { waitUntilFirstUpdate: true })
277
+ ], NileTooltip.prototype, "handleOpenChange", null);
296
278
  __decorate([
297
- query('.tooltip-caret')
298
- ], NileTooltip.prototype, "caret", void 0);
279
+ watch(['content', 'distance', 'hoist', 'placement', 'skidding'])
280
+ ], NileTooltip.prototype, "handleOptionsChange", null);
299
281
  __decorate([
300
- query('slot[name="content"]')
301
- ], NileTooltip.prototype, "tooltipSlot", void 0);
282
+ watch('disabled')
283
+ ], NileTooltip.prototype, "handleDisabledChange", null);
302
284
  NileTooltip = __decorate([
303
285
  customElement('nile-tooltip')
304
286
  ], NileTooltip);
305
287
  export { NileTooltip };
288
+ setDefaultAnimation('tooltip.show', {
289
+ keyframes: [
290
+ { opacity: 0, scale: 0.8 },
291
+ { opacity: 1, scale: 1 },
292
+ ],
293
+ options: { duration: 150, easing: 'ease' },
294
+ });
295
+ setDefaultAnimation('tooltip.hide', {
296
+ keyframes: [
297
+ { opacity: 1, scale: 1 },
298
+ { opacity: 0, scale: 0.8 },
299
+ ],
300
+ options: { duration: 150, easing: 'ease' },
301
+ });
302
+ export default NileTooltip;
306
303
  //# sourceMappingURL=nile-tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-tooltip.js","sourceRoot":"","sources":["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AAC,SAAS;;;;;;qBAMnD,IAAI,CAAC,eAAe;oBACrB,IAAI,CAAC,cAAc;iBACtB,IAAI,CAAC,WAAW;mBACd,IAAI,CAAC,WAAW;oBACf,IAAI,CAAC,UAAU;;;;;KAK9B,CAAC;IACJ,CAAC;CACF,CAAA;AA7U6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAc;AAEzC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAaJ;AACqB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAkB;AACjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAc;AAM7C;IAAX,QAAQ,EAAE;4CAAyB;AACR;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAc;AAGb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAc;AACG;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEvC;IAAlB,KAAK,CAAC,UAAU,CAAC;4CAAuB;AACZ;IAA5B,KAAK,CAAC,oBAAoB,CAAC;qDAAgC;AACnC;IAAxB,KAAK,CAAC,gBAAgB,CAAC;0CAAqB;AACd;IAA9B,KAAK,CAAC,sBAAsB,CAAC;gDAA+B;AAjClD,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA8UvB","sourcesContent":["\n/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { LitElement, html, css, CSSResultArray } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styles } from './nile-tooltip.css';\nimport NileElement from '../internal/nile-element';\nimport { isInViewport, getValidTooltipPosition, getCaretPosition } from './nile-tooltip-utils';\n\n/**\n * Nile tooltip component.\n *\n * @tag nile-tooltip\n *\n */\n@customElement('nile-tooltip')\nexport class NileTooltip extends NileElement {\n @property({ type: String }) content = '';\n @property({ type: String })\n placement:\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end' = 'top';\n @property({ type: Boolean, reflect: true }) disabled = false;\n @property({ type: Boolean, reflect: true }) open = false;\n /**\n * Controls how the tooltip is activated. Possible options include `click`, `hover`, `focus`, and `manual`. Multiple\n * options can be passed by separating them with a space. When manual is used, the tooltip must be activated\n * programmatically.\n */\n @property() trigger = 'hover focus';\n @property({ type: Number }) distance = 8;\n private readonly SHIFT_OFFSET = 16;\n /** The distance in pixels from which to offset the tooltip along its target. */\n @property({ type: Number }) skidding = 0;\n @property({ type: Boolean, reflect: true }) hoist = false;\n\n @query('.tooltip') tooltip!: HTMLElement;\n @query('.trigger-container') triggerContainer!: HTMLElement;\n @query('.tooltip-caret') caret!: HTMLElement;\n @query('slot[name=\"content\"]') tooltipSlot!: HTMLSlotElement;\n\n private hasTooltipSlot = false;\n private hoverTimeout: number = 0;\n private caretSize = 6;\n private originalPlacement: string = this.placement;\n\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.originalPlacement = this.placement;\n window.addEventListener('resize', this.updateTooltipPosition);\n window.addEventListener('scroll', this.updateTooltipPosition, true);\n }\n\n updated(changedProps: Map<string, unknown>) {\n super.updated?.(changedProps);\n\n const validPlacements = [\n 'top', 'top-start', 'top-end',\n 'right', 'right-start', 'right-end',\n 'bottom', 'bottom-start', 'bottom-end',\n 'left', 'left-start', 'left-end'\n ];\n\n if (!validPlacements.includes(this.placement)) {\n console.warn(`[nile-tooltip] Invalid placement \"${this.placement}\", defaulting to \"bottom\".`);\n this.placement = 'top';\n }\n\n if (!validPlacements.includes(this.originalPlacement)) {\n this.originalPlacement = 'top';\n }\n \n if (changedProps.has('open') && this.open) {\n this.updateComplete.then(() => {\n requestAnimationFrame(() => {\n this.updateTooltipPosition();\n });\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener('resize', this.updateTooltipPosition);\n window.removeEventListener('scroll', this.updateTooltipPosition, true);\n }\n\n private handleTooltipSlotChange() {\n const nodes = this.tooltipSlot.assignedNodes({ flatten: true });\n this.hasTooltipSlot = nodes.length > 0;\n this.requestUpdate();\n }\n\n private updateTooltipPosition = () => {\n if (!isInViewport(this.triggerContainer)) {\n this.open = false;\n return;\n }\n\n const triggerRect = this.triggerContainer.getBoundingClientRect();\n const tooltipRect = this.tooltip.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n \n let { top, left, placement } = getValidTooltipPosition(\n triggerRect,\n tooltipRect,\n this.originalPlacement,\n this.distance,\n this.skidding,\n this.caretSize,\n viewportWidth,\n viewportHeight\n );\n\n // FallBack Positions\n\n // Bottom\n if (this.originalPlacement.startsWith('bottom')) {\n const availableSpaceBelow = viewportHeight - triggerRect.bottom;\n if (availableSpaceBelow < tooltipRect.height + this.distance) {\n let newPlacement: typeof this.originalPlacement = 'top';\n if (this.originalPlacement === 'bottom-start') {\n newPlacement = 'top';\n } else if (this.originalPlacement === 'bottom-end') {\n newPlacement = 'top';\n }\n \n const newPosition = getValidTooltipPosition(\n triggerRect,\n tooltipRect,\n newPlacement,\n this.distance,\n this.skidding,\n this.caretSize,\n viewportWidth,\n viewportHeight\n );\n top = newPosition.top;\n left = newPosition.left;\n placement = newPosition.placement;\n }\n }\n // Top\n if (this.originalPlacement.startsWith('top')) {\n const availableSpaceAbove = triggerRect.top;\n const availableSpaceBelow = viewportHeight - triggerRect.bottom;\n if (availableSpaceAbove < tooltipRect.height + this.distance && availableSpaceBelow >= tooltipRect.height + this.distance) {\n let newPlacement: typeof this.originalPlacement = 'bottom';\n if (this.originalPlacement === 'top-start') {\n newPlacement = 'bottom-start';\n } else if (this.originalPlacement === 'top-end') {\n newPlacement = 'bottom-end';\n }\n \n const newPosition = getValidTooltipPosition(\n triggerRect,\n tooltipRect,\n newPlacement,\n this.distance,\n this.skidding,\n this.caretSize,\n viewportWidth,\n viewportHeight\n );\n top = newPosition.top;\n left = newPosition.left;\n placement = newPosition.placement;\n }\n }\n\n // Left\n if (this.originalPlacement.startsWith('left')) {\n const availableSpaceLeft = triggerRect.left;\n const availableSpaceRight = viewportWidth - triggerRect.right;\n if (availableSpaceLeft < tooltipRect.width + this.distance && availableSpaceRight >= tooltipRect.width + this.distance) {\n let newPlacement: typeof this.originalPlacement = 'right';\n if (this.originalPlacement === 'left-start') {\n newPlacement = 'right-start';\n } else if (this.originalPlacement === 'left-end') {\n newPlacement = 'right-end';\n }\n \n const newPosition = getValidTooltipPosition(\n triggerRect,\n tooltipRect,\n newPlacement,\n this.distance,\n this.skidding,\n this.caretSize,\n viewportWidth,\n viewportHeight\n );\n top = newPosition.top;\n left = newPosition.left;\n placement = newPosition.placement;\n }\n }\n\n // Right\n if (this.originalPlacement.startsWith('right')) {\n const availableSpaceRight = viewportWidth - triggerRect.right;\n const availableSpaceLeft = triggerRect.left;\n if (availableSpaceRight < tooltipRect.width + this.distance && availableSpaceLeft >= tooltipRect.width + this.distance) {\n let newPlacement: typeof this.originalPlacement = 'left';\n if (this.originalPlacement === 'right-start') {\n newPlacement = 'left-start';\n } else if (this.originalPlacement === 'right-end') {\n newPlacement = 'left-end';\n }\n \n const newPosition = getValidTooltipPosition(\n triggerRect,\n tooltipRect,\n newPlacement,\n this.distance,\n this.skidding,\n this.caretSize,\n viewportWidth,\n viewportHeight\n );\n top = newPosition.top;\n left = newPosition.left;\n placement = newPosition.placement;\n }\n }\n\n this.setAttribute('placement', placement);\n this.tooltip.style.top = `${top}px`;\n this.tooltip.style.left = `${left}px`;\n\n const { caretLeft, caretTop } = getCaretPosition({\n placement,\n tooltipRect,\n triggerRect,\n caretSize: this.caretSize,\n left,\n top\n });\n\n this.caret.style.left = `${caretLeft}px`;\n this.caret.style.top = `${caretTop}px`;\n };\n\n private showTooltip = () => {\n const trimmedContent = this.content.trim();\n if (!trimmedContent && !this.hasTooltipSlot) {\n return;\n }\n if (!this.disabled && isInViewport(this.triggerContainer)) {\n this.emit('nile-show');\n this.open = true;\n this.updateComplete.then(() => {\n requestAnimationFrame(() => {\n this.updateTooltipPosition();\n this.emit('nile-after-show');\n });\n });\n } else {\n this.open = false;\n }\n };\n\n private hideTooltip = () => {\n this.emit('nile-hide');\n this.open = false;\n setTimeout(() => {\n this.emit('nile-after-hide');\n }, 200);\n };\n\n private handleMouseOver = () => {\n if (this.trigger.includes('hover')) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = window.setTimeout(() => this.showTooltip(), 300);\n }\n };\n\n private handleMouseOut = () => {\n if (this.trigger.includes('hover')) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = window.setTimeout(() => this.hideTooltip(), 150);\n }\n };\n\n private handleClick = () => {\n if (this.trigger.includes('click')) {\n if (!this.open && isInViewport(this.triggerContainer)) {\n this.showTooltip();\n } else {\n this.hideTooltip();\n }\n }\n };\n\n private handleFocus = () => {\n if (this.trigger.includes('focus')) {\n this.showTooltip();\n }\n };\n \n\n private handleBlur = () => {\n if (this.trigger.includes('focus')) {\n this.hideTooltip();\n }\n };\n\n render() {\n return html`\n <div\n class=\"tooltip\"\n id=\"tooltip\"\n >\n <div class=\"tooltip-content\" part=\"content\">\n <slot name=\"content\" @slotchange=${this.handleTooltipSlotChange}></slot>\n ${!this.hasTooltipSlot ? html`${this.content}` : null}\n </div>\n <div class=\"tooltip-caret\" style=\"--caret-size: ${this.caretSize}px;\"></div>\n </div>\n\n <div\n class=\"trigger-container\"\n tabindex=\"0\"\n @mouseover=${this.handleMouseOver}\n @mouseout=${this.handleMouseOut}\n @click=${this.handleClick}\n @focusin=${this.handleFocus}\n @focusout=${this.handleBlur}\n aria-describedby=\"tooltip\"\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-tooltip': NileTooltip;\n }\n}\n"]}
1
+ {"version":3,"file":"nile-tooltip.js","sourceRoot":"","sources":["../../../src/nile-tooltip/nile-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,8DAA8D;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAGnD;;;;;GAKG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,WAAW;IAArC;;QAgBL,0FAA0F;QAC/C,YAAO,GAAG,EAAE,CAAC;QAExD,gDAAgD;QACnB,SAAI,GAAsB,OAAO,CAAC;QAE/D;;;WAGG;QACS,cAAS,GAYJ,KAAK,CAAC;QAEvB,4DAA4D;QAChB,aAAQ,GAAG,KAAK,CAAC;QAE7D,oFAAoF;QACxD,aAAQ,GAAG,CAAC,CAAC;QAEzC,uGAAuG;QAC3D,SAAI,GAAG,KAAK,CAAC;QAEzD,gFAAgF;QACpD,aAAQ,GAAG,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A4QvB;;AAED,mBAAmB,CAAC,cAAc,EAAE;IAClC,SAAS,EAAE;QACT,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;QAC1B,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KACzB;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;CAC3C,CAAC,CAAC;AAEH,mBAAmB,CAAC,cAAc,EAAE;IAClC,SAAS,EAAE;QACT,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QACxB,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;KAC3B;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;CAC3C,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { LitElement, CSSResultArray, TemplateResult } from 'lit';\nimport { styles } from './nile-tooltip.css';\nimport '../nile-popup/nile-popup';\nimport { animateTo, parseDuration, stopAnimations } from '../internal/animate';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport {\n getAnimation,\n setDefaultAnimation,\n} from '../utilities/animation-registry';\nimport { html } from 'lit';\n// import { LocalizeController } from '../utilities/localize';\nimport { waitForEvent } from '../internal/event';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport type { CSSResultGroup } from 'lit';\nimport type NilePopup from '../nile-popup/nile-popup';\n/**\n * Nile icon component.\n *\n * @tag nile-tooltip\n *\n */\n@customElement('nile-tooltip')\nexport class NileTooltip extends NileElement {\n /**\n * The styles for Tooltip\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private hoverTimeout: number;\n // private readonly localize = new LocalizeController(this);\n\n @query('slot:not([name])') defaultSlot: HTMLSlotElement;\n @query('.tooltip__body') body: HTMLElement;\n @query('nile-popup') popup: NilePopup;\n\n /** The tooltip's content. If you need to display HTML, use the `content` slot instead. */\n @property({ type: String, reflect: true }) content = '';\n\n /** Size Property to decide the tool tip size */\n @property({ reflect: true }) size: 'small' | 'large' = 'small';\n\n /**\n * The preferred placement of the tooltip. Note that the actual placement may vary as needed to keep the tooltip\n * inside of the viewport.\n */\n @property() placement:\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end' = 'top';\n\n /** Disables the tooltip so it won't show when triggered. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** The distance in pixels from which to offset the tooltip away from its target. */\n @property({ type: Number }) distance = 8;\n\n /** Indicates whether or not the tooltip is open. You can use this in lieu of the show/hide methods. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** The distance in pixels from which to offset the tooltip along its target. */\n @property({ type: Number }) skidding = 0;\n\n /**\n * Controls how the tooltip is activated. Possible options include `click`, `hover`, `focus`, and `manual`. Multiple\n * options can be passed by separating them with a space. When manual is used, the tooltip must be activated\n * programmatically.\n */\n @property() trigger = 'hover focus';\n\n /**\n * Enable this option to prevent the tooltip from being clipped when the component is placed inside a container with\n * `overflow: auto|hidden|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all,\n * scenarios.\n */\n @property({ type: Boolean }) hoist = false;\n\n connectedCallback() {\n super.connectedCallback();\n this.handleBlur = this.handleBlur.bind(this);\n this.handleClick = this.handleClick.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleMouseOver = this.handleMouseOver.bind(this);\n this.handleMouseOut = this.handleMouseOut.bind(this);\n\n this.updateComplete.then(() => {\n this.addEventListener('blur', this.handleBlur, true);\n this.addEventListener('focus', this.handleFocus, true);\n this.addEventListener('click', this.handleClick);\n this.addEventListener('keydown', this.handleKeyDown);\n this.addEventListener('mouseover', this.handleMouseOver);\n this.addEventListener('mouseout', this.handleMouseOut);\n });\n }\n\n firstUpdated() {\n this.body.hidden = !this.open;\n\n // If the tooltip is visible on init, update its position\n if (this.open) {\n this.popup.active = true;\n this.popup.reposition();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('blur', this.handleBlur, true);\n this.removeEventListener('focus', this.handleFocus, true);\n this.removeEventListener('click', this.handleClick);\n this.removeEventListener('keydown', this.handleKeyDown);\n this.removeEventListener('mouseover', this.handleMouseOver);\n this.removeEventListener('mouseout', this.handleMouseOut);\n }\n\n private handleBlur() {\n if (this.hasTrigger('focus')) {\n this.hide();\n }\n }\n\n private handleClick() {\n if (this.hasTrigger('click')) {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n }\n\n private handleFocus() {\n if (this.hasTrigger('focus')) {\n this.show();\n }\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n // Pressing escape when the target element has focus should dismiss the tooltip\n if (this.open && event.key === 'Escape') {\n event.stopPropagation();\n this.hide();\n }\n }\n\n private handleMouseOver() {\n if (this.hasTrigger('hover')) {\n const delay = parseDuration(\n getComputedStyle(this).getPropertyValue('--show-delay')\n );\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = window.setTimeout(() => this.show(), delay);\n }\n }\n\n private handleMouseOut() {\n if (this.hasTrigger('hover')) {\n const delay = parseDuration(\n getComputedStyle(this).getPropertyValue('--hide-delay')\n );\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = window.setTimeout(() => this.hide(), delay);\n }\n }\n\n private hasTrigger(triggerType: string) {\n const triggers = this.trigger.split(' ');\n return triggers.includes(triggerType);\n }\n\n @watch('open', { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n if (this.disabled) {\n return;\n }\n\n // Show\n this.emit('nile-show');\n\n await stopAnimations(this.body);\n this.body.hidden = false;\n this.popup.active = true;\n const { keyframes, options } = getAnimation(this, 'tooltip.show', {\n dir: '',\n });\n await animateTo(this.popup.popup, keyframes, options);\n\n this.emit('nile-after-show');\n } else {\n // Hide\n this.emit('nile-hide');\n\n await stopAnimations(this.body);\n const { keyframes, options } = getAnimation(this, 'tooltip.hide', {\n dir: '',\n });\n await animateTo(this.popup.popup, keyframes, options);\n this.popup.active = false;\n this.body.hidden = true;\n\n this.emit('nile-after-hide');\n }\n }\n\n @watch(['content', 'distance', 'hoist', 'placement', 'skidding'])\n async handleOptionsChange() {\n if (this.hasUpdated) {\n await this.updateComplete;\n this.popup.reposition();\n }\n }\n\n @watch('disabled')\n handleDisabledChange() {\n if (this.disabled && this.open) {\n this.hide();\n }\n }\n\n /** Shows the tooltip. */\n async show() {\n if (this.open || !this.content?.trim().length) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, 'nile-after-show');\n }\n\n /** Hides the tooltip */\n async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, 'nile-after-hide');\n }\n\n render() {\n return html`\n <nile-popup\n part=\"base\"\n exportparts=\"\n popup:base__popup,\n arrow:base__arrow\n \"\n class=${classMap({\n tooltip: true,\n 'tooltip--open': this.open,\n })}\n placement=${this.placement}\n distance=${this.distance}\n skidding=${this.skidding}\n strategy=${this.hoist ? 'fixed' : 'absolute'}\n flip\n shift\n arrow\n >\n <slot slot=\"anchor\" aria-describedby=\"tooltip\"></slot>\n\n <slot\n name=\"content\"\n part=\"body\"\n id=\"tooltip\"\n class=${classMap({\n tooltip__body: true,\n 'tooltip__body--large': this.size === 'large',\n })}\n role=\"tooltip\"\n aria-live=${this.open ? 'polite' : 'off'}\n >\n ${this.content}\n </slot>\n </nile-popup>\n `;\n }\n}\n\nsetDefaultAnimation('tooltip.show', {\n keyframes: [\n { opacity: 0, scale: 0.8 },\n { opacity: 1, scale: 1 },\n ],\n options: { duration: 150, easing: 'ease' },\n});\n\nsetDefaultAnimation('tooltip.hide', {\n keyframes: [\n { opacity: 1, scale: 1 },\n { opacity: 0, scale: 0.8 },\n ],\n options: { duration: 150, easing: 'ease' },\n});\n\nexport default NileTooltip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-tooltip': NileTooltip;\n }\n}\n"]}