Skip to content

Commit 9032a8c

Browse files
committed
Add schema
1 parent ed253f5 commit 9032a8c

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

packages/component/src/Activity/StackedLayoutMain.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1+
import { reactNode, validateProps } from '@msinternal/botframework-webchat-react-valibot';
12
import { useStyles } from '@msinternal/botframework-webchat-styles/react';
23
import cx from 'classnames';
3-
import React, { memo, type ReactNode } from 'react';
4+
import React, { memo } from 'react';
5+
import { object, optional, pipe, readonly, type InferOutput } from 'valibot';
46

57
import styles from './StackedLayout.module.css';
68

7-
type StackedLayoutMainProps = Readonly<{
8-
avatar?: ReactNode | undefined;
9-
children?: ReactNode | undefined;
10-
}>;
9+
const stackedLayoutMainPropsSchema = pipe(
10+
object({
11+
avatar: optional(reactNode()),
12+
children: optional(reactNode())
13+
}),
14+
readonly()
15+
);
1116

12-
const StackedLayoutMain = memo(({ avatar, children }: StackedLayoutMainProps) => {
17+
type StackedLayoutMainProps = InferOutput<typeof stackedLayoutMainPropsSchema>;
18+
19+
const StackedLayoutMain = memo((props: StackedLayoutMainProps) => {
20+
const { avatar, children } = validateProps(stackedLayoutMainPropsSchema, props);
1321
const classNames = useStyles(styles);
1422

1523
return (
@@ -24,3 +32,4 @@ const StackedLayoutMain = memo(({ avatar, children }: StackedLayoutMainProps) =>
2432
StackedLayoutMain.displayName = 'StackedLayoutMain';
2533

2634
export default StackedLayoutMain;
35+
export { stackedLayoutMainPropsSchema, type StackedLayoutMainProps };

0 commit comments

Comments
 (0)