@riverty/web-components 5.4.0 → 5.6.0

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 (214) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +3 -3
  3. package/custom-elements.json +27 -15
  4. package/dist/cjs/{index-BnETQtSf.js → index-DJ4H_bFj.js} +382 -5
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/r-accordion-item.cjs.entry.js +1 -1
  7. package/dist/cjs/r-accordion-panel.cjs.entry.js +1 -1
  8. package/dist/cjs/r-accordion-section.cjs.entry.js +1 -1
  9. package/dist/cjs/r-accordion-trigger.cjs.entry.js +1 -1
  10. package/dist/cjs/r-accordion.cjs.entry.js +2 -2
  11. package/dist/cjs/r-alert.cjs.entry.js +1 -1
  12. package/dist/cjs/r-badge.cjs.entry.js +1 -1
  13. package/dist/cjs/r-button.cjs.entry.js +2 -2
  14. package/dist/cjs/r-checkbox-group.cjs.entry.js +1 -1
  15. package/dist/cjs/r-checkbox.cjs.entry.js +5 -5
  16. package/dist/cjs/r-design-system-devtools.cjs.entry.js +1 -1
  17. package/dist/cjs/r-dialog.cjs.entry.js +8 -10
  18. package/dist/cjs/r-hint_3.cjs.entry.js +136 -38
  19. package/dist/cjs/r-icon-button.cjs.entry.js +4 -4
  20. package/dist/cjs/r-icon.cjs.entry.js +3 -3
  21. package/dist/cjs/r-input-code.cjs.entry.js +1 -1
  22. package/dist/cjs/r-input-date.cjs.entry.js +7 -7
  23. package/dist/cjs/r-input-password.cjs.entry.js +3 -3
  24. package/dist/cjs/r-input-phone-number.cjs.entry.js +5 -5
  25. package/dist/cjs/r-input.cjs.entry.js +19 -6
  26. package/dist/cjs/r-list-item.cjs.entry.js +5 -6
  27. package/dist/cjs/r-pagination.cjs.entry.js +1 -1
  28. package/dist/cjs/r-panel.cjs.entry.js +1 -1
  29. package/dist/cjs/r-popover-action.cjs.entry.js +1 -1
  30. package/dist/cjs/r-popover-content.cjs.entry.js +1 -1
  31. package/dist/cjs/r-popover-headline.cjs.entry.js +1 -1
  32. package/dist/cjs/r-popover-trigger.cjs.entry.js +1 -1
  33. package/dist/cjs/r-popover.cjs.entry.js +1 -1
  34. package/dist/cjs/r-progress-bar.cjs.entry.js +1 -1
  35. package/dist/cjs/r-radio-button-description.cjs.entry.js +1 -1
  36. package/dist/cjs/r-radio-button-leading.cjs.entry.js +1 -1
  37. package/dist/cjs/r-radio-button-title.cjs.entry.js +1 -1
  38. package/dist/cjs/r-radio-button-trailing.cjs.entry.js +1 -1
  39. package/dist/cjs/r-radio-button.cjs.entry.js +1 -1
  40. package/dist/cjs/r-radio-group.cjs.entry.js +7 -7
  41. package/dist/cjs/r-select-option.cjs.entry.js +1 -1
  42. package/dist/cjs/r-select.cjs.entry.js +3 -3
  43. package/dist/cjs/r-skip-link.cjs.entry.js +1 -1
  44. package/dist/cjs/r-stepper-item.cjs.entry.js +1 -1
  45. package/dist/cjs/r-stepper.cjs.entry.js +1 -1
  46. package/dist/cjs/r-tab-panel.cjs.entry.js +1 -1
  47. package/dist/cjs/r-tab.cjs.entry.js +1 -1
  48. package/dist/cjs/r-tabs-list.cjs.entry.js +1 -1
  49. package/dist/cjs/r-tabs.cjs.entry.js +1 -1
  50. package/dist/cjs/r-textarea.cjs.entry.js +1 -1
  51. package/dist/cjs/r-toast-group.cjs.entry.js +15 -5
  52. package/dist/cjs/r-toast.cjs.entry.js +10 -11
  53. package/dist/cjs/web-components.cjs.js +2 -2
  54. package/dist/collection/components/accordion/accordion.js +1 -2
  55. package/dist/collection/components/button/button.js +1 -2
  56. package/dist/collection/components/checkbox/checkbox.js +4 -5
  57. package/dist/collection/components/dialog/dialog.css +1 -1
  58. package/dist/collection/components/dialog/dialog.js +23 -8
  59. package/dist/collection/components/icon/bundled-icons/riverty-kit.json +1 -1
  60. package/dist/collection/components/icon/icon.js +2 -2
  61. package/dist/collection/components/icon/riverty-kit.js +1 -1
  62. package/dist/collection/components/icon-button/icon-button.js +3 -4
  63. package/dist/collection/components/input/input.js +37 -5
  64. package/dist/collection/components/input-date/input-date.js +7 -7
  65. package/dist/collection/components/input-password/input-password.js +3 -3
  66. package/dist/collection/components/input-phone-number/input-phone-number.js +5 -5
  67. package/dist/collection/components/label/label.js +4 -4
  68. package/dist/collection/components/list-item/list-item/list-item.css +19 -11
  69. package/dist/collection/components/list-item/list-item/list-item.js +41 -4
  70. package/dist/collection/components/radio-group/radio-group.js +7 -7
  71. package/dist/collection/components/select/select.js +3 -4
  72. package/dist/collection/components/textarea/textarea.js +1 -1
  73. package/dist/collection/components/toast/toast.css +8 -2
  74. package/dist/collection/components/toast/toast.js +10 -11
  75. package/dist/collection/components/toast-group/toast-group.css +14 -13
  76. package/dist/collection/components/toast-group/toast-group.js +14 -4
  77. package/dist/collection/components/tooltip/tooltip.css +6 -71
  78. package/dist/collection/components/tooltip/tooltip.js +135 -33
  79. package/dist/esm/{index-CTxpqopm.js → index-Da7qOBFr.js} +382 -5
  80. package/dist/esm/loader.js +3 -3
  81. package/dist/esm/r-accordion-item.entry.js +1 -1
  82. package/dist/esm/r-accordion-panel.entry.js +1 -1
  83. package/dist/esm/r-accordion-section.entry.js +1 -1
  84. package/dist/esm/r-accordion-trigger.entry.js +1 -1
  85. package/dist/esm/r-accordion.entry.js +2 -2
  86. package/dist/esm/r-alert.entry.js +1 -1
  87. package/dist/esm/r-badge.entry.js +1 -1
  88. package/dist/esm/r-button.entry.js +2 -2
  89. package/dist/esm/r-checkbox-group.entry.js +1 -1
  90. package/dist/esm/r-checkbox.entry.js +5 -5
  91. package/dist/esm/r-design-system-devtools.entry.js +1 -1
  92. package/dist/esm/r-dialog.entry.js +8 -10
  93. package/dist/esm/r-hint_3.entry.js +136 -38
  94. package/dist/esm/r-icon-button.entry.js +4 -4
  95. package/dist/esm/r-icon.entry.js +3 -3
  96. package/dist/esm/r-input-code.entry.js +1 -1
  97. package/dist/esm/r-input-date.entry.js +7 -7
  98. package/dist/esm/r-input-password.entry.js +3 -3
  99. package/dist/esm/r-input-phone-number.entry.js +5 -5
  100. package/dist/esm/r-input.entry.js +19 -6
  101. package/dist/esm/r-list-item.entry.js +5 -6
  102. package/dist/esm/r-pagination.entry.js +1 -1
  103. package/dist/esm/r-panel.entry.js +1 -1
  104. package/dist/esm/r-popover-action.entry.js +1 -1
  105. package/dist/esm/r-popover-content.entry.js +1 -1
  106. package/dist/esm/r-popover-headline.entry.js +1 -1
  107. package/dist/esm/r-popover-trigger.entry.js +1 -1
  108. package/dist/esm/r-popover.entry.js +1 -1
  109. package/dist/esm/r-progress-bar.entry.js +1 -1
  110. package/dist/esm/r-radio-button-description.entry.js +1 -1
  111. package/dist/esm/r-radio-button-leading.entry.js +1 -1
  112. package/dist/esm/r-radio-button-title.entry.js +1 -1
  113. package/dist/esm/r-radio-button-trailing.entry.js +1 -1
  114. package/dist/esm/r-radio-button.entry.js +1 -1
  115. package/dist/esm/r-radio-group.entry.js +7 -7
  116. package/dist/esm/r-select-option.entry.js +1 -1
  117. package/dist/esm/r-select.entry.js +3 -3
  118. package/dist/esm/r-skip-link.entry.js +1 -1
  119. package/dist/esm/r-stepper-item.entry.js +1 -1
  120. package/dist/esm/r-stepper.entry.js +1 -1
  121. package/dist/esm/r-tab-panel.entry.js +1 -1
  122. package/dist/esm/r-tab.entry.js +1 -1
  123. package/dist/esm/r-tabs-list.entry.js +1 -1
  124. package/dist/esm/r-tabs.entry.js +1 -1
  125. package/dist/esm/r-textarea.entry.js +1 -1
  126. package/dist/esm/r-toast-group.entry.js +15 -5
  127. package/dist/esm/r-toast.entry.js +10 -11
  128. package/dist/esm/web-components.js +3 -3
  129. package/dist/types/components/accordion/accordion.d.ts +0 -1
  130. package/dist/types/components/button/button.d.ts +0 -1
  131. package/dist/types/components/checkbox/checkbox.d.ts +0 -1
  132. package/dist/types/components/dialog/dialog.d.ts +6 -1
  133. package/dist/types/components/icon/exports.d.ts +1 -0
  134. package/dist/types/components/icon/icon-data.d.ts +1 -0
  135. package/dist/types/components/icon/icon.d.ts +1 -1
  136. package/dist/types/components/icon/riverty-kit.d.ts +1 -0
  137. package/dist/types/components/icon-button/icon-button.d.ts +0 -1
  138. package/dist/types/components/input/input.d.ts +6 -0
  139. package/dist/types/components/input-date/input-date.d.ts +1 -1
  140. package/dist/types/components/input-password/input-password.d.ts +1 -1
  141. package/dist/types/components/input-phone-number/input-phone-number.d.ts +1 -1
  142. package/dist/types/components/label/label.d.ts +1 -1
  143. package/dist/types/components/list-item/list-item/list-item.d.ts +6 -1
  144. package/dist/types/components/radio-group/radio-group.d.ts +1 -1
  145. package/dist/types/components/select/select.d.ts +1 -2
  146. package/dist/types/components/textarea/textarea.d.ts +3 -3
  147. package/dist/types/components/toast/toast.d.ts +1 -3
  148. package/dist/types/components/toast-group/toast-group.d.ts +2 -0
  149. package/dist/types/components/tooltip/tooltip.d.ts +12 -4
  150. package/dist/types/components.d.ts +63 -40
  151. package/dist/web-components/bundled-icons/riverty-kit.json +1 -1
  152. package/dist/web-components/{p-aecd025b.entry.js → p-00ca474f.entry.js} +1 -1
  153. package/dist/web-components/{p-9c40f9cd.entry.js → p-0bb04d79.entry.js} +1 -1
  154. package/dist/web-components/{p-48dfb286.entry.js → p-1ae69897.entry.js} +1 -1
  155. package/dist/web-components/{p-4cf01f30.entry.js → p-1c2497de.entry.js} +1 -1
  156. package/dist/web-components/{p-03ff9abf.entry.js → p-230e44ae.entry.js} +1 -1
  157. package/dist/web-components/p-29a1e75f.entry.js +1 -0
  158. package/dist/web-components/{p-1157b7f4.entry.js → p-2b2f581a.entry.js} +1 -1
  159. package/dist/web-components/{p-0a424361.entry.js → p-3b4e3faf.entry.js} +1 -1
  160. package/dist/web-components/p-3bc93d65.entry.js +1 -0
  161. package/dist/web-components/{p-dc93ed55.entry.js → p-429213ea.entry.js} +1 -1
  162. package/dist/web-components/{p-c7a9da98.entry.js → p-44ae9f33.entry.js} +1 -1
  163. package/dist/web-components/{p-c60294d4.entry.js → p-44be9992.entry.js} +1 -1
  164. package/dist/web-components/{p-66c454ce.entry.js → p-4652635a.entry.js} +1 -1
  165. package/dist/web-components/{p-e50503d0.entry.js → p-4bd3e077.entry.js} +1 -1
  166. package/dist/web-components/{p-89ff32dc.entry.js → p-4e3df002.entry.js} +1 -1
  167. package/dist/web-components/p-51a5804b.entry.js +1 -0
  168. package/dist/web-components/{p-2d85c0f3.entry.js → p-72c0c0d8.entry.js} +1 -1
  169. package/dist/web-components/{p-e273950c.entry.js → p-72fa1fd1.entry.js} +1 -1
  170. package/dist/web-components/{p-135be1d5.entry.js → p-755cc697.entry.js} +1 -1
  171. package/dist/web-components/{p-e74c363a.entry.js → p-77155630.entry.js} +1 -1
  172. package/dist/web-components/{p-3ea6a1be.entry.js → p-8028c2a9.entry.js} +1 -1
  173. package/dist/web-components/{p-3fc2b23b.entry.js → p-828cb164.entry.js} +1 -1
  174. package/dist/web-components/{p-988a7731.entry.js → p-85a9af42.entry.js} +1 -1
  175. package/dist/web-components/{p-24130cdb.entry.js → p-87f39749.entry.js} +1 -1
  176. package/dist/web-components/{p-c9b2389b.entry.js → p-89136369.entry.js} +1 -1
  177. package/dist/web-components/{p-77dc268e.entry.js → p-8c577cda.entry.js} +1 -1
  178. package/dist/web-components/{p-8d2f4097.entry.js → p-96ddeb7f.entry.js} +1 -1
  179. package/dist/web-components/{p-735da2bb.entry.js → p-9b08e9ee.entry.js} +1 -1
  180. package/dist/web-components/{p-6b7d5236.entry.js → p-9e50120b.entry.js} +1 -1
  181. package/dist/web-components/{p-900923ab.entry.js → p-9eb1f262.entry.js} +1 -1
  182. package/dist/web-components/p-Da7qOBFr.js +2 -0
  183. package/dist/web-components/{p-2394508f.entry.js → p-a022f356.entry.js} +1 -1
  184. package/dist/web-components/{p-df81177e.entry.js → p-a58124c4.entry.js} +1 -1
  185. package/dist/web-components/p-a5be3395.entry.js +1 -0
  186. package/dist/web-components/{p-9891afb8.entry.js → p-a7e7f8fa.entry.js} +1 -1
  187. package/dist/web-components/p-b2cec978.entry.js +1 -0
  188. package/dist/web-components/{p-71d6c4d7.entry.js → p-c7f8e59b.entry.js} +1 -1
  189. package/dist/web-components/{p-f625b739.entry.js → p-c937bd92.entry.js} +1 -1
  190. package/dist/web-components/p-cbcd7699.entry.js +1 -0
  191. package/dist/web-components/{p-fdf70aed.entry.js → p-d3ff65b0.entry.js} +1 -1
  192. package/dist/web-components/p-e0e2f2b2.entry.js +1 -0
  193. package/dist/web-components/{p-8d6a35e3.entry.js → p-e49b1ec3.entry.js} +1 -1
  194. package/dist/web-components/p-e4b66277.entry.js +1 -0
  195. package/dist/web-components/p-e6a31881.entry.js +1 -0
  196. package/dist/web-components/{p-05ba30ba.entry.js → p-f1e22caa.entry.js} +1 -1
  197. package/dist/web-components/p-f6a92287.entry.js +1 -0
  198. package/dist/web-components/p-f770e22b.entry.js +1 -0
  199. package/dist/web-components/p-f7adb875.entry.js +1 -0
  200. package/dist/web-components/web-components.esm.js +1 -1
  201. package/package.json +2 -1
  202. package/dist/web-components/p-0ac858b8.entry.js +0 -1
  203. package/dist/web-components/p-0bb0de18.entry.js +0 -1
  204. package/dist/web-components/p-10724c18.entry.js +0 -1
  205. package/dist/web-components/p-1ed3efd7.entry.js +0 -1
  206. package/dist/web-components/p-20f979ff.entry.js +0 -1
  207. package/dist/web-components/p-31c8388d.entry.js +0 -1
  208. package/dist/web-components/p-333707b2.entry.js +0 -1
  209. package/dist/web-components/p-61f78bf6.entry.js +0 -1
  210. package/dist/web-components/p-8f719321.entry.js +0 -1
  211. package/dist/web-components/p-9f583ed1.entry.js +0 -1
  212. package/dist/web-components/p-CTxpqopm.js +0 -2
  213. package/dist/web-components/p-caca2855.entry.js +0 -1
  214. package/dist/web-components/p-ef0f43e0.entry.js +0 -1
@@ -9,6 +9,75 @@ export class Tooltip {
9
9
  this.arrowPositionState = 'left';
10
10
  this.isShown = false;
11
11
  this.uniqueId = `r-tooltip-${Date.now().toString(32)}${Math.random().toString(32)}`.replace(/\./g, '');
12
+ this.getOffsetLeft = (arrowPosition) => {
13
+ var _a, _b, _c;
14
+ const offsetLeft = Math.abs(((_a = this.element) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) - ((_c = (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) === null || _c === void 0 ? void 0 : _c.width));
15
+ switch (arrowPosition) {
16
+ case 'center':
17
+ return offsetLeft / 2;
18
+ case 'right':
19
+ return offsetLeft;
20
+ default:
21
+ return 0;
22
+ }
23
+ };
24
+ this.alignTooltipPosition = () => {
25
+ var _a, _b, _c, _d, _e, _f, _g;
26
+ const offsetHeight = Math.abs(((_a = this.element) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) - ((_c = (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) === null || _c === void 0 ? void 0 : _c.height)) / 2;
27
+ const offsetLeft = this.getOffsetLeft(this.arrowPositionState);
28
+ const hostHeight = ((_e = (_d = this.element) === null || _d === void 0 ? void 0 : _d.getBoundingClientRect()) === null || _e === void 0 ? void 0 : _e.height) + this.arrowHeight || 0;
29
+ const hostWidth = ((_g = (_f = this.element) === null || _f === void 0 ? void 0 : _f.getBoundingClientRect()) === null || _g === void 0 ? void 0 : _g.width) + this.arrowWidth || 0;
30
+ switch (this.positionState) {
31
+ case 'top':
32
+ this.alignPosition(this.tooltip, -offsetLeft, -this.tooltipContainerHeight);
33
+ break;
34
+ case 'bottom':
35
+ this.alignPosition(this.tooltip, -offsetLeft, hostHeight);
36
+ break;
37
+ case 'left':
38
+ this.alignPosition(this.tooltip, -this.tooltipContainerWidth, -offsetHeight);
39
+ break;
40
+ case 'right':
41
+ this.alignPosition(this.tooltip, hostWidth, -offsetHeight);
42
+ break;
43
+ default:
44
+ break;
45
+ }
46
+ };
47
+ this.alignArrowPosition = () => {
48
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
49
+ const offsetHeight = Math.abs(((_a = this.element) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) - ((_c = (_b = this.arrow) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) === null || _c === void 0 ? void 0 : _c.height)) / 2;
50
+ const offsetLeft = Math.abs(((_d = this.element) === null || _d === void 0 ? void 0 : _d.getBoundingClientRect().width) - ((_f = (_e = this.arrow) === null || _e === void 0 ? void 0 : _e.getBoundingClientRect()) === null || _f === void 0 ? void 0 : _f.width)) / 2;
51
+ const hostHeight = ((_h = (_g = this.element) === null || _g === void 0 ? void 0 : _g.getBoundingClientRect()) === null || _h === void 0 ? void 0 : _h.height) || 0;
52
+ const hostWidth = ((_k = (_j = this.element) === null || _j === void 0 ? void 0 : _j.getBoundingClientRect()) === null || _k === void 0 ? void 0 : _k.width) || 0;
53
+ switch (this.positionState) {
54
+ case 'top':
55
+ this.alignPosition(this.arrow, offsetLeft, -this.arrowHeight);
56
+ break;
57
+ case 'bottom':
58
+ this.alignPosition(this.arrow, offsetLeft, hostHeight);
59
+ break;
60
+ case 'left':
61
+ this.alignPosition(this.arrow, -this.arrowWidth, offsetHeight);
62
+ break;
63
+ case 'right':
64
+ this.alignPosition(this.arrow, hostWidth, offsetHeight);
65
+ break;
66
+ default:
67
+ break;
68
+ }
69
+ };
70
+ this.alignPosition = (element, offsetLeft, offsetTop) => {
71
+ var _a;
72
+ if (!element) {
73
+ return;
74
+ }
75
+ let elementOffset = (_a = this.element) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
76
+ let left = elementOffset.left + offsetLeft;
77
+ let top = elementOffset.top + offsetTop;
78
+ element.style.left = `${left > 0 ? left : 0}px`;
79
+ element.style.top = `${top}px`;
80
+ };
12
81
  /**
13
82
  * Listen on hovering tooltip element and update tooltip position if needed
14
83
  */
@@ -26,11 +95,22 @@ export class Tooltip {
26
95
  };
27
96
  this.showTooltip = () => {
28
97
  this.isShown = true;
29
- this.tooltipValue.classList.add('r-tooltip--content--visible');
98
+ this.tooltip.classList.add('r-tooltip--content--visible');
30
99
  };
31
100
  this.removeTooltip = () => {
32
101
  this.isShown = false;
33
- this.tooltipValue.classList.remove('r-tooltip--content--visible');
102
+ this.tooltip.style.width = 'max-content';
103
+ this.tooltip.classList.remove('r-tooltip--content--visible');
104
+ };
105
+ this.handleScroll = () => {
106
+ if (!this.isShown) {
107
+ return;
108
+ }
109
+ if (!this.isOnScreen) {
110
+ this.removeTooltip();
111
+ return;
112
+ }
113
+ this.setCorrectPosition();
34
114
  };
35
115
  }
36
116
  /**
@@ -59,30 +139,47 @@ export class Tooltip {
59
139
  this.removeTooltip();
60
140
  }
61
141
  }
62
- /**
63
- * Tooltip element value
64
- */
65
- get tooltipValue() {
66
- var _a, _b;
67
- return (_b = (_a = this.element) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.getElementById(this.uniqueId);
68
- }
69
142
  /**
70
143
  * Parent with non visible overflow
71
144
  */
72
145
  get overflowedParent() {
73
146
  return this.findOverflowParent(this.element.parentElement);
74
147
  }
148
+ get arrowWidth() {
149
+ var _a;
150
+ return ((_a = this.arrow) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) || 0;
151
+ }
152
+ get arrowHeight() {
153
+ var _a;
154
+ return ((_a = this.arrow) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
155
+ }
156
+ get tooltipContainerWidth() {
157
+ var _a, _b;
158
+ return ((_b = (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.width) + this.arrowWidth || 0;
159
+ }
160
+ get tooltipContainerHeight() {
161
+ var _a, _b;
162
+ return ((_b = (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height) + this.arrowHeight || 0;
163
+ }
75
164
  /**
76
165
  * Available space at the top
77
166
  */
78
167
  get top() {
79
- return !this.overflowedParent ? this.element.getBoundingClientRect().top : Math.abs(this.overflowedParent.getBoundingClientRect().top - this.element.getBoundingClientRect().top);
168
+ return this.element.getBoundingClientRect().top;
80
169
  }
81
170
  /**
82
171
  * Available space on the left
83
172
  */
84
173
  get left() {
85
- return !this.overflowedParent ? this.element.getBoundingClientRect().left : Math.abs(this.overflowedParent.getBoundingClientRect().left - this.element.getBoundingClientRect().left);
174
+ return this.element.getBoundingClientRect().left;
175
+ }
176
+ get isOnScreen() {
177
+ const parent = this.overflowedParent || document.documentElement;
178
+ const parentRect = parent.getBoundingClientRect();
179
+ const elementRect = this.element.getBoundingClientRect();
180
+ const isVerticallyVisible = elementRect.top >= parentRect.top && elementRect.bottom <= parentRect.bottom;
181
+ const isHorizontallyVisible = elementRect.left >= parentRect.left && elementRect.right <= parentRect.right;
182
+ return isVerticallyVisible && isHorizontallyVisible;
86
183
  }
87
184
  /**
88
185
  * Available space at the bottom
@@ -91,7 +188,7 @@ export class Tooltip {
91
188
  function calculateBottomSpace(element) {
92
189
  return window.innerHeight - element.getBoundingClientRect().top - element.getBoundingClientRect().height;
93
190
  }
94
- return !this.overflowedParent ? calculateBottomSpace(this.element) : Math.abs(calculateBottomSpace(this.overflowedParent) - calculateBottomSpace(this.element));
191
+ return calculateBottomSpace(this.element);
95
192
  }
96
193
  /**
97
194
  * Available space on the right
@@ -100,35 +197,31 @@ export class Tooltip {
100
197
  function calculateRightSpace(element) {
101
198
  return window.innerWidth - element.getBoundingClientRect().left - element.getBoundingClientRect().width;
102
199
  }
103
- return !this.overflowedParent ? calculateRightSpace(this.element) : Math.abs(calculateRightSpace(this.overflowedParent) - calculateRightSpace(this.element));
200
+ return calculateRightSpace(this.element);
104
201
  }
105
202
  /**
106
203
  * Defines which horizontal placement is available
107
204
  */
108
205
  get horizontalPlacement() {
109
- var _a;
110
- return ((_a = this.tooltipValue) === null || _a === void 0 ? void 0 : _a.offsetWidth) + OFFSET < this.left ? 'left' : 'right';
206
+ return this.tooltipContainerWidth + OFFSET < this.left ? 'left' : 'right';
111
207
  }
112
208
  /**
113
209
  * Defines which vertical placement is available
114
210
  */
115
211
  get verticalPlacement() {
116
- var _a;
117
- return ((_a = this.tooltipValue) === null || _a === void 0 ? void 0 : _a.offsetHeight) + OFFSET < this.top ? 'top' : 'bottom';
212
+ return this.tooltipContainerHeight + OFFSET < this.top ? 'top' : 'bottom';
118
213
  }
119
214
  /**
120
215
  * Checks if there is enough space for placing tooltip vertically
121
216
  */
122
217
  get isEnoughSpaceVertically() {
123
- var _a, _b;
124
- return ((_a = this.tooltipValue) === null || _a === void 0 ? void 0 : _a.offsetHeight) + OFFSET < this.top || ((_b = this.tooltipValue) === null || _b === void 0 ? void 0 : _b.offsetHeight) + OFFSET < this.bottom;
218
+ return this.tooltipContainerHeight + OFFSET < this.top || this.tooltipContainerHeight + OFFSET < this.bottom;
125
219
  }
126
220
  /**
127
221
  * Checks if there is enough space for placing tooltip horizontally
128
222
  */
129
223
  get isEnoughSpaceHorizontally() {
130
- var _a, _b;
131
- return ((_a = this.tooltipValue) === null || _a === void 0 ? void 0 : _a.offsetWidth) + OFFSET < this.left || ((_b = this.tooltipValue) === null || _b === void 0 ? void 0 : _b.offsetWidth) + OFFSET < this.right;
224
+ return this.tooltipContainerWidth + OFFSET < this.left || this.tooltipContainerWidth + OFFSET < this.right;
132
225
  }
133
226
  get activeElement() {
134
227
  return this.element.querySelector('r-button, r-icon-button, a, button, [tabindex]:not([tabindex="-1"])');
@@ -143,13 +236,16 @@ export class Tooltip {
143
236
  * Listen to active child element
144
237
  */
145
238
  componentDidLoad() {
146
- var _a, _b;
239
+ var _a, _b, _c;
147
240
  (_a = this.activeElement) === null || _a === void 0 ? void 0 : _a.addEventListener('focus', () => {
148
241
  this.handleFocus();
149
242
  });
150
243
  (_b = this.activeElement) === null || _b === void 0 ? void 0 : _b.addEventListener('blur', () => {
151
244
  this.removeTooltip();
152
245
  });
246
+ (_c = this.overflowedParent) === null || _c === void 0 ? void 0 : _c.addEventListener('scroll', () => {
247
+ this.handleScroll();
248
+ });
153
249
  }
154
250
  /**
155
251
  * Finds first element's parent with not visible overflow.
@@ -198,25 +294,32 @@ export class Tooltip {
198
294
  * First it checks the available space for a defined position and then sets the new one based on the available space.
199
295
  */
200
296
  setCorrectPosition() {
201
- var _a, _b, _c, _d;
202
- if (!this.tooltipValue || !this.isShown) {
297
+ if (!this.tooltip || !this.isShown) {
203
298
  return;
204
299
  }
205
300
  switch (this.position) {
206
301
  case 'top':
207
- this.positionState = ((_a = this.tooltipValue) === null || _a === void 0 ? void 0 : _a.offsetHeight) + OFFSET < this.top ? this.position : this.getAlternativePosition();
302
+ this.positionState = this.tooltipContainerHeight + OFFSET < this.top ? this.position : this.getAlternativePosition();
208
303
  break;
209
304
  case 'bottom':
210
- this.positionState = ((_b = this.tooltipValue) === null || _b === void 0 ? void 0 : _b.offsetHeight) + OFFSET < this.bottom ? this.position : this.getAlternativePosition();
305
+ this.positionState = this.tooltipContainerHeight + OFFSET < this.bottom ? this.position : this.getAlternativePosition();
211
306
  break;
212
307
  case 'left':
213
- this.positionState = ((_c = this.tooltipValue) === null || _c === void 0 ? void 0 : _c.offsetWidth) + OFFSET < this.left ? this.position : this.getAlternativePosition();
308
+ this.positionState = this.tooltipContainerWidth + OFFSET < this.left ? this.position : this.getAlternativePosition();
214
309
  break;
215
310
  case 'right':
216
- this.positionState = ((_d = this.tooltipValue) === null || _d === void 0 ? void 0 : _d.offsetWidth) + OFFSET < this.right ? this.position : this.getAlternativePosition();
311
+ this.positionState = this.tooltipContainerWidth + OFFSET < this.right ? this.position : this.getAlternativePosition();
217
312
  break;
218
313
  }
219
314
  this.adjustArrowPosition();
315
+ this.alignTooltipPosition();
316
+ this.alignArrowPosition();
317
+ // allow tooltip content wrap and recalculate position
318
+ if (this.tooltip.style.width === 'fit-content') {
319
+ return;
320
+ }
321
+ this.tooltip.style.width = 'fit-content';
322
+ this.alignTooltipPosition();
220
323
  }
221
324
  /**
222
325
  * Adjusts arrow correct position.
@@ -224,10 +327,9 @@ export class Tooltip {
224
327
  * For right & left tooltip positions there is only one position = "center".
225
328
  */
226
329
  adjustArrowPosition() {
227
- var _a, _b;
228
- const isEnoughTooltipSpaceLeft = ((_a = this.tooltipValue) === null || _a === void 0 ? void 0 : _a.offsetWidth) / 2 + OFFSET < this.left;
229
- const isEnoughTooltipSpaceRight = ((_b = this.tooltipValue) === null || _b === void 0 ? void 0 : _b.offsetWidth) / 2 + OFFSET < this.right;
230
- if (isEnoughTooltipSpaceLeft && isEnoughTooltipSpaceRight || this.positionState === 'left' || this.positionState === 'right') {
330
+ const isEnoughTooltipSpaceLeft = this.tooltipContainerWidth / 2 + OFFSET < this.left;
331
+ const isEnoughTooltipSpaceRight = this.tooltipContainerWidth / 2 + OFFSET < this.right;
332
+ if (isEnoughTooltipSpaceLeft && isEnoughTooltipSpaceRight || !isEnoughTooltipSpaceLeft && !isEnoughTooltipSpaceRight || this.positionState === 'left' || this.positionState === 'right') {
231
333
  this.arrowPositionState = 'center';
232
334
  }
233
335
  else if (!isEnoughTooltipSpaceLeft) {
@@ -253,7 +355,7 @@ export class Tooltip {
253
355
  role: 'tooltip',
254
356
  'aria-hidden': `${!isShown}`
255
357
  };
256
- return (h(Host, Object.assign({ key: 'e168f9f1212433eb17769c11260f546e441ca274' }, hostAttrs, { onMouseenter: this.handleHover, onMouseleave: this.removeTooltip }), h("div", { key: 'b8ea713c2b09b6053af73ac7d26a30f210c90e94', class: "r-tooltip" }, h("div", Object.assign({ key: '19cc679ec640dc98f167077e0bab16423e186258', class: "r-tooltip--trigger", onFocus: this.handleFocus, onBlur: this.removeTooltip }, triggerAttrs), h("slot", { key: '17266fefef386f3b417d8e7d112e0345aa98e878' })), h("div", Object.assign({ key: 'e53283c02be43833362277fc8fe78e99c4a9adba', class: "r-tooltip--content" }, contentAttrs), text), h("div", { key: '98f1caf44ec7bd286cb8126022692d825f4ab617', class: "r-tooltip--arrow" }))));
358
+ return (h(Host, Object.assign({ key: 'f0b2e0117f0604d325becbcc05686433fbd3d506' }, hostAttrs, { onMouseenter: this.handleHover, onMouseleave: this.removeTooltip }), h("div", { key: '2f5ff7638dedddd04dac78a2131438457211354b', class: "r-tooltip" }, h("div", Object.assign({ key: 'cb562089f6e7ac27b99ba09953c2f28f29e3e649', class: "r-tooltip--trigger", onFocus: this.handleFocus, onBlur: this.removeTooltip }, triggerAttrs), h("slot", { key: '2e09b16563b9aa325ff64f10af1ad5f4728a2417' })), h("div", Object.assign({ key: 'ffe53881e5ec5335073a7adf2ed5479f3a56f00f', class: "r-tooltip--content", ref: (el) => this.tooltip = el }, contentAttrs), text), h("div", { key: '3f85fb76e934b18d5963d125699d00776c6abbac', ref: (el) => this.arrow = el, class: "r-tooltip--arrow" }))));
257
359
  }
258
360
  static get is() { return "r-tooltip"; }
259
361
  static get encapsulation() { return "shadow"; }