6
6
import Component from '@glimmer/component' ;
7
7
import { assert } from '@ember/debug' ;
8
8
9
- export const PLACEMENTS = [
10
- 'top' ,
11
- 'top-start' ,
12
- 'top-end' ,
13
- 'right' ,
14
- 'right-start' ,
15
- 'right-end' ,
16
- 'bottom' ,
17
- 'bottom-start' ,
18
- 'bottom-end' ,
19
- 'left' ,
20
- 'left-start' ,
21
- 'left-end' ,
22
- ] ;
9
+ import type { Props as TippyProps } from 'tippy.js' ;
10
+ import { HdsTooltipPlacementValues } from './types.ts' ;
23
11
24
- export default class HdsTooltipIndexComponent extends Component {
12
+ export const PLACEMENTS : string [ ] = Object . values ( HdsTooltipPlacementValues ) ;
13
+
14
+ export interface HdsTooltipSignature {
15
+ Args : {
16
+ extraTippyOptions : Omit < TippyProps , 'placement' | 'offset' > ;
17
+ isInline ?: boolean ;
18
+ offset ?: [ number , number ] ;
19
+ placement : HdsTooltipPlacementValues ;
20
+ text : string ;
21
+ } ;
22
+ Blocks : {
23
+ default : [ ] ;
24
+ } ;
25
+ Element : HTMLButtonElement ;
26
+ }
27
+
28
+ export default class HdsTooltipIndexComponent extends Component < HdsTooltipSignature > {
25
29
/**
26
30
* @param text
27
31
* @type {string }
28
32
* @description text content for tooltip
29
33
*/
30
- get text ( ) {
31
- let { text } = this . args ;
34
+ get text ( ) : string {
35
+ const { text } = this . args ;
32
36
33
37
assert (
34
38
'@text for "Hds::TooltipButton" must have a valid value' ,
@@ -38,8 +42,8 @@ export default class HdsTooltipIndexComponent extends Component {
38
42
return text ;
39
43
}
40
44
41
- get options ( ) {
42
- let { placement } = this . args ;
45
+ get options ( ) : TippyProps {
46
+ const { placement } = this . args ;
43
47
44
48
assert (
45
49
'@placement for "Hds::TooltipButton" must have a valid value' ,
@@ -48,10 +52,9 @@ export default class HdsTooltipIndexComponent extends Component {
48
52
49
53
return {
50
54
...this . args . extraTippyOptions ,
51
- // takes string
52
55
placement : placement ,
53
- // takes array of 2 numbers (skidding, distance): array(0, 0 )
54
- offset : this . args . offset ,
56
+ // takes array of 2 numbers (skidding, distance): array(0, 10 )
57
+ offset : this . args . offset ? this . args . offset : [ 0 , 10 ] ,
55
58
} ;
56
59
}
57
60
@@ -61,8 +64,8 @@ export default class HdsTooltipIndexComponent extends Component {
61
64
* @default true
62
65
* @description sets display for the button
63
66
*/
64
- get isInline ( ) {
65
- let { isInline = true } = this . args ;
67
+ get isInline ( ) : boolean {
68
+ const { isInline = true } = this . args ;
66
69
return isInline ;
67
70
}
68
71
@@ -71,8 +74,8 @@ export default class HdsTooltipIndexComponent extends Component {
71
74
* @method classNames
72
75
* @return {string } The "class" attribute to apply to the component.
73
76
*/
74
- get classNames ( ) {
75
- let classes = [ 'hds-tooltip-button' ] ;
77
+ get classNames ( ) : string {
78
+ const classes = [ 'hds-tooltip-button' ] ;
76
79
77
80
// add a class based on the @isInline argument
78
81
if ( this . isInline ) {
0 commit comments