@@ -8,7 +8,16 @@ import sysEnter2Icon from '@ui5/webcomponents-icons/dist/sys-enter-2.js';
8
8
import { useI18nBundle , useStylesheet } from '@ui5/webcomponents-react-base' ;
9
9
import { clsx } from 'clsx' ;
10
10
import { forwardRef } from 'react' ;
11
- import { ERROR_TYPE , WARNING_TYPE , INFORMATION_TYPE , SUCCESS_TYPE } from '../../i18n/i18n-defaults.js' ;
11
+ import {
12
+ ERROR_TYPE ,
13
+ WARNING_TYPE ,
14
+ INFORMATION_TYPE ,
15
+ SUCCESS_TYPE ,
16
+ ERROR ,
17
+ SUCCESS ,
18
+ WARNING ,
19
+ INFORMATION
20
+ } from '../../i18n/i18n-defaults.js' ;
12
21
import type { ButtonDomRef , ButtonPropTypes } from '../../webComponents/index.js' ;
13
22
import { Button } from '../../webComponents/index.js' ;
14
23
import { classNames , styleData } from './MessageViewButton.module.css.js' ;
@@ -32,18 +41,19 @@ export interface MessageViewButtonProptypes
32
41
interface Types {
33
42
icon : string ;
34
43
i18nLabel : { key : string ; defaultText : string } ;
44
+ tooltip : { key : string ; defaultText : string } ;
35
45
}
36
46
37
47
const getTypes = ( type : MessageViewButtonProptypes [ 'type' ] ) : Types => {
38
48
switch ( type ) {
39
49
case ValueState . Negative :
40
- return { icon : errorIcon , i18nLabel : ERROR_TYPE } ;
50
+ return { icon : errorIcon , i18nLabel : ERROR_TYPE , tooltip : ERROR } ;
41
51
case ValueState . Positive :
42
- return { icon : sysEnter2Icon , i18nLabel : SUCCESS_TYPE } ;
52
+ return { icon : sysEnter2Icon , i18nLabel : SUCCESS_TYPE , tooltip : SUCCESS } ;
43
53
case ValueState . Critical :
44
- return { icon : alertIcon , i18nLabel : WARNING_TYPE } ;
54
+ return { icon : alertIcon , i18nLabel : WARNING_TYPE , tooltip : WARNING } ;
45
55
default :
46
- return { icon : informationIcon , i18nLabel : INFORMATION_TYPE } ;
56
+ return { icon : informationIcon , i18nLabel : INFORMATION_TYPE , tooltip : INFORMATION } ;
47
57
}
48
58
} ;
49
59
@@ -54,7 +64,7 @@ const MessageViewButton = forwardRef<ButtonDomRef, MessageViewButtonProptypes>((
54
64
const { type = ValueState . Negative , counter, className, tooltip, accessibleName, ...rest } = props ;
55
65
useStylesheet ( styleData , MessageViewButton . displayName ) ;
56
66
const classes = clsx ( classNames . btn , className ) ;
57
- const { icon, i18nLabel } = getTypes ( type ) ;
67
+ const { icon, i18nLabel, tooltip : title } = getTypes ( type ) ;
58
68
59
69
const i18nBundle = useI18nBundle ( '@ui5/webcomponents-react' ) ;
60
70
const label = i18nBundle . getText ( i18nLabel ) ;
@@ -65,7 +75,7 @@ const MessageViewButton = forwardRef<ButtonDomRef, MessageViewButtonProptypes>((
65
75
icon = { icon }
66
76
{ ...rest }
67
77
data-type = { type }
68
- tooltip = { tooltip ?? label }
78
+ tooltip = { tooltip ?? i18nBundle . getText ( title ) }
69
79
accessibleName = { accessibleName ?? label }
70
80
>
71
81
{ counter > 1 && counter }
0 commit comments