@1024pix/pix-ui 20.1.0 → 20.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Pix-UI Changelog
2
2
 
3
+ ## v20.2.0 (25/10/2022)
4
+
5
+
6
+ ### :rocket: Amélioration
7
+ - [#267](https://github.com/1024pix/pix-ui/pull/267) [FEATURE] Gérer l'échappement de la tooltip (PIX-6114)
8
+
3
9
  ## v20.1.0 (13/10/2022)
4
10
 
5
11
 
@@ -1,4 +1,12 @@
1
- <span class="pix-tooltip" ...attributes>
1
+ <span
2
+ class="pix-tooltip"
3
+ {{on-escape-action this.hideTooltip}}
4
+ {{on "mouseover" this.showTooltip}}
5
+ {{on "mouseout" this.hideTooltipOnMouseOut}}
6
+ {{on "focusin" this.showTooltip}}
7
+ {{on "focusout" this.hideTooltip}}
8
+ ...attributes
9
+ >
2
10
  {{#if (has-block "triggerElement")}}
3
11
  {{yield to="triggerElement"}}
4
12
  {{/if}}
@@ -1,4 +1,5 @@
1
1
  import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
2
3
 
3
4
  export default class PixTooltip extends Component {
4
5
  get position() {
@@ -18,4 +19,25 @@ export default class PixTooltip extends Component {
18
19
  get display() {
19
20
  return typeof this.args.hide === 'undefined' || !this.args.hide;
20
21
  }
22
+
23
+ @action
24
+ showTooltip(event) {
25
+ event.target.classList.add('pix-tooltip--visible');
26
+ }
27
+
28
+ @action
29
+ hideTooltip(event) {
30
+ event.target.classList.remove('pix-tooltip--visible');
31
+ }
32
+
33
+ @action
34
+ hideTooltipOnMouseOut(event) {
35
+ const isFocused = document.activeElement === event.target;
36
+
37
+ if (isFocused) {
38
+ return;
39
+ }
40
+
41
+ this.hideTooltip(event);
42
+ }
21
43
  }
@@ -5,9 +5,10 @@
5
5
  display: flex;
6
6
  justify-content: center;
7
7
  align-items: center;
8
+ }
8
9
 
9
- & > *:first-child:hover + .pix-tooltip__content,
10
- & > *:first-child:focus + .pix-tooltip__content {
10
+ .pix-tooltip--visible {
11
+ + .pix-tooltip__content {
11
12
  display: block;
12
13
  opacity: 1;
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "20.1.0",
3
+ "version": "20.2.0",
4
4
  "description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
5
5
  "keywords": [
6
6
  "ember-addon"