11/* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 2] }] */
22
33import { validateProps } from '@msinternal/botframework-webchat-react-valibot' ;
4+ import { useStyles } from '@msinternal/botframework-webchat-styles/react' ;
45import { type Action as AdaptiveCardAction , type OpenUrlAction , type SubmitAction } from 'adaptivecards' ;
56import { ErrorBoxPolymiddlewareProxy } from 'botframework-webchat-api/middleware' ;
67import { getTabIndex , hooks } from 'botframework-webchat-component' ;
78import { type DirectLineCardAction } from 'botframework-webchat-core' ;
8- import classNames from 'classnames' ;
9+ import cx from 'classnames' ;
910import React , {
1011 memo ,
1112 useCallback ,
@@ -19,7 +20,6 @@ import React, {
1920import { useRefFrom } from 'use-ref-from' ;
2021import { any , boolean , object , optional , pipe , readonly , string , type InferInput } from 'valibot' ;
2122
22- import useStyleSet from '../../hooks/useStyleSet' ;
2323import useAdaptiveCardsHostConfig from '../hooks/useAdaptiveCardsHostConfig' ;
2424import useAdaptiveCardsPackage from '../hooks/useAdaptiveCardsPackage' ;
2525import { BotFrameworkCardAction } from './AdaptiveCardBuilder' ;
@@ -32,6 +32,8 @@ import useRoleModEffect from './AdaptiveCardHacks/useRoleModEffect';
3232import { directLineCardActionSchema } from './private/directLineSchema' ;
3333import renderAdaptiveCard from './private/renderAdaptiveCard' ;
3434
35+ import styles from './AdaptiveCardRenderer.module.css' ;
36+
3537const { useLocalizer, usePerformCardAction, useRenderMarkdownAsHTML, useScrollToEnd, useUIState } = hooks ;
3638
3739const adaptiveCardRendererPropsSchema = pipe (
@@ -54,7 +56,6 @@ function AdaptiveCardRenderer(props: AdaptiveCardRendererProps) {
5456 tapAction
5557 } = validateProps ( adaptiveCardRendererPropsSchema , props ) ;
5658
57- const [ { adaptiveCardRenderer : adaptiveCardRendererStyleSet } ] = useStyleSet ( ) ;
5859 const [ { GlobalSettings, HostConfig } ] = useAdaptiveCardsPackage ( ) ;
5960 const [ adaptiveCardsHostConfig ] = useAdaptiveCardsHostConfig ( ) ;
6061 const [ uiState ] = useUIState ( ) ;
@@ -63,6 +64,7 @@ function AdaptiveCardRenderer(props: AdaptiveCardRendererProps) {
6364 const performCardAction = usePerformCardAction ( ) ;
6465 const renderMarkdownAsHTML = useRenderMarkdownAsHTML ( 'adaptive cards' ) ;
6566 const scrollToEnd = useScrollToEnd ( ) ;
67+ const classNames = useStyles ( styles ) ;
6668
6769 const disabled = uiState === 'disabled' || disabledFromProps ;
6870 const tapActionRef = useValueRef ( tapAction ) ;
@@ -249,7 +251,7 @@ function AdaptiveCardRenderer(props: AdaptiveCardRendererProps) {
249251 < ErrorBoxPolymiddlewareProxy error = { errors [ 0 ] } where = { localize ( 'ADAPTIVE_CARD_ERROR_BOX_TITLE_RENDER' ) } />
250252 ) : (
251253 < div
252- className = { classNames ( adaptiveCardRendererStyleSet + ' ', 'webchat__adaptive -card-renderer') }
254+ className = { cx ( 'adaptive-card-renderer ', classNames [ 'adaptive -card-renderer'] ) }
253255 onClick = { handleClickAndKeyPressForTapAction as MouseEventHandler < HTMLDivElement > }
254256 onKeyPress = { handleClickAndKeyPressForTapAction as KeyboardEventHandler < HTMLDivElement > }
255257 ref = { contentRef }
0 commit comments