1+ import { reactNode , validateProps } from '@msinternal/botframework-webchat-react-valibot' ;
12import { useStyles } from '@msinternal/botframework-webchat-styles/react' ;
23import cx from 'classnames' ;
3- import React , { memo , type ReactNode } from 'react' ;
4+ import React , { memo } from 'react' ;
5+ import { boolean , object , optional , pipe , readonly , string , type InferInput } from 'valibot' ;
46
57import styles from './StackedLayout.module.css' ;
68
7- type StackedLayoutRootProps = Readonly < {
8- ariaLabelId ?: string | undefined ;
9- children ?: ReactNode | undefined ;
10- extraTrailing ?: boolean | undefined ;
11- fromUser ?: boolean | undefined ;
12- hideAvatar ?: boolean | undefined ;
13- hideNub ?: boolean | undefined ;
14- isGroup ?: boolean | undefined ;
15- noMessage ?: boolean | undefined ;
16- showAvatar ?: boolean | undefined ;
17- showNub ?: boolean | undefined ;
18- topCallout ?: boolean | undefined ;
19- } > ;
9+ const stackedLayoutRootPropsSchema = pipe (
10+ object ( {
11+ ariaLabelId : optional ( string ( ) ) ,
12+ children : optional ( reactNode ( ) ) ,
13+ extraTrailing : optional ( boolean ( ) ) ,
14+ fromUser : optional ( boolean ( ) ) ,
15+ hideAvatar : optional ( boolean ( ) ) ,
16+ hideNub : optional ( boolean ( ) ) ,
17+ isGroup : optional ( boolean ( ) ) ,
18+ noMessage : optional ( boolean ( ) ) ,
19+ showAvatar : optional ( boolean ( ) ) ,
20+ showNub : optional ( boolean ( ) ) ,
21+ topCallout : optional ( boolean ( ) )
22+ } ) ,
23+ readonly ( )
24+ ) ;
25+
26+ type StackedLayoutRootProps = InferInput < typeof stackedLayoutRootPropsSchema > ;
2027
21- const StackedLayoutRoot = memo (
22- ( {
28+ const StackedLayoutRoot = memo ( ( props : StackedLayoutRootProps ) => {
29+ const {
2330 ariaLabelId,
2431 children,
2532 extraTrailing,
@@ -31,30 +38,30 @@ const StackedLayoutRoot = memo(
3138 showAvatar,
3239 showNub,
3340 topCallout
34- } : StackedLayoutRootProps ) => {
35- const classNames = useStyles ( styles ) ;
41+ } = validateProps ( stackedLayoutRootPropsSchema , props ) ;
42+ const classNames = useStyles ( styles ) ;
3643
37- return (
38- < div
39- aria-labelledby = { ariaLabelId }
40- className = { cx ( 'webchat__stacked-layout' , classNames [ 'stacked-layout' ] , {
41- [ classNames [ 'stacked-layout--from-user' ] ] : fromUser ,
42- [ classNames [ 'stacked-layout--extra-trailing' ] ] : extraTrailing ,
43- [ classNames [ 'stacked-layout--hide-avatar' ] ] : hideAvatar ,
44- [ classNames [ 'stacked-layout--hide-nub' ] ] : hideNub ,
45- [ classNames [ 'stacked-layout--group' ] ] : isGroup ,
46- [ classNames [ 'stacked-layout--no-message' ] ] : noMessage ,
47- [ classNames [ 'stacked-layout--show-avatar' ] ] : showAvatar ,
48- [ classNames [ 'stacked-layout--show-nub' ] ] : showNub ,
49- [ classNames [ 'stacked-layout--top-callout' ] ] : topCallout
50- } ) }
51- >
52- { children }
53- </ div >
54- ) ;
55- }
56- ) ;
44+ return (
45+ < div
46+ aria-labelledby = { ariaLabelId }
47+ className = { cx ( 'webchat__stacked-layout' , classNames [ 'stacked-layout' ] , {
48+ [ classNames [ 'stacked-layout--from-user' ] ] : fromUser ,
49+ [ classNames [ 'stacked-layout--extra-trailing' ] ] : extraTrailing ,
50+ [ classNames [ 'stacked-layout--hide-avatar' ] ] : hideAvatar ,
51+ [ classNames [ 'stacked-layout--hide-nub' ] ] : hideNub ,
52+ [ classNames [ 'stacked-layout--group' ] ] : isGroup ,
53+ [ classNames [ 'stacked-layout--no-message' ] ] : noMessage ,
54+ [ classNames [ 'stacked-layout--show-avatar' ] ] : showAvatar ,
55+ [ classNames [ 'stacked-layout--show-nub' ] ] : showNub ,
56+ [ classNames [ 'stacked-layout--top-callout' ] ] : topCallout
57+ } ) }
58+ >
59+ { children }
60+ </ div >
61+ ) ;
62+ } ) ;
5763
5864StackedLayoutRoot . displayName = 'StackedLayoutRoot' ;
5965
6066export default StackedLayoutRoot ;
67+ export { stackedLayoutRootPropsSchema , type StackedLayoutRootProps } ;
0 commit comments