@@ -8,7 +8,16 @@ import sysEnter2Icon from '@ui5/webcomponents-icons/dist/sys-enter-2.js';
88import { useI18nBundle , useStylesheet } from '@ui5/webcomponents-react-base' ;
99import { clsx } from 'clsx' ;
1010import { 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' ;
1221import type { ButtonDomRef , ButtonPropTypes } from '../../webComponents/index.js' ;
1322import { Button } from '../../webComponents/index.js' ;
1423import { classNames , styleData } from './MessageViewButton.module.css.js' ;
@@ -32,18 +41,19 @@ export interface MessageViewButtonProptypes
3241interface Types {
3342 icon : string ;
3443 i18nLabel : { key : string ; defaultText : string } ;
44+ tooltip : { key : string ; defaultText : string } ;
3545}
3646
3747const getTypes = ( type : MessageViewButtonProptypes [ 'type' ] ) : Types => {
3848 switch ( type ) {
3949 case ValueState . Negative :
40- return { icon : errorIcon , i18nLabel : ERROR_TYPE } ;
50+ return { icon : errorIcon , i18nLabel : ERROR_TYPE , tooltip : ERROR } ;
4151 case ValueState . Positive :
42- return { icon : sysEnter2Icon , i18nLabel : SUCCESS_TYPE } ;
52+ return { icon : sysEnter2Icon , i18nLabel : SUCCESS_TYPE , tooltip : SUCCESS } ;
4353 case ValueState . Critical :
44- return { icon : alertIcon , i18nLabel : WARNING_TYPE } ;
54+ return { icon : alertIcon , i18nLabel : WARNING_TYPE , tooltip : WARNING } ;
4555 default :
46- return { icon : informationIcon , i18nLabel : INFORMATION_TYPE } ;
56+ return { icon : informationIcon , i18nLabel : INFORMATION_TYPE , tooltip : INFORMATION } ;
4757 }
4858} ;
4959
@@ -54,7 +64,7 @@ const MessageViewButton = forwardRef<ButtonDomRef, MessageViewButtonProptypes>((
5464 const { type = ValueState . Negative , counter, className, tooltip, accessibleName, ...rest } = props ;
5565 useStylesheet ( styleData , MessageViewButton . displayName ) ;
5666 const classes = clsx ( classNames . btn , className ) ;
57- const { icon, i18nLabel } = getTypes ( type ) ;
67+ const { icon, i18nLabel, tooltip : title } = getTypes ( type ) ;
5868
5969 const i18nBundle = useI18nBundle ( '@ui5/webcomponents-react' ) ;
6070 const label = i18nBundle . getText ( i18nLabel ) ;
@@ -65,7 +75,7 @@ const MessageViewButton = forwardRef<ButtonDomRef, MessageViewButtonProptypes>((
6575 icon = { icon }
6676 { ...rest }
6777 data-type = { type }
68- tooltip = { tooltip ?? label }
78+ tooltip = { tooltip ?? i18nBundle . getText ( title ) }
6979 accessibleName = { accessibleName ?? label }
7080 >
7181 { counter > 1 && counter }
0 commit comments