Skip to content

Commit 5164969

Browse files
committed
Reorganize
1 parent d2d5ef3 commit 5164969

16 files changed

Lines changed: 123 additions & 123 deletions

packages/experience-chat-launcher/src/private/ChatLauncher.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import { instance, object, optional, pipe, readonly, string, type InferInput } f
1919

2020
import ChatLauncherStylesheet from '../stylesheet/ChatLauncherStylesheet';
2121
import styles from './ChatLauncher.module.css';
22-
import Button from './private/Button';
2322
import ChatLauncherButton from './private/ChatLauncherButton';
24-
import ChatLauncherModal from './private/ChatLauncherPopover';
25-
import NonModalPopover from './private/NonModalPopover';
23+
import ChatLauncherPopover from './private/ChatLauncherPopover';
24+
import Button from './private/polymiddleware/Button';
25+
import NonModalPopover from './private/polymiddleware/NonModalPopover';
2626

2727
const chatLauncherPropsSchema = pipe(
2828
object({
@@ -62,7 +62,7 @@ function ChatLauncher(props: ChatLauncherProps) {
6262
<Composer directLine={directLine} polymiddleware={polymiddleware} store={store} styleOptions={styleOptions}>
6363
<ChatLauncherStylesheet nonce={nonce} />
6464
<ChatLauncherButtonPolymiddlewareProxy hasMessage={true} popoverTargetRef={popoverTargetRef} />
65-
<ChatLauncherModal ref={popoverTargetRef} />
65+
<ChatLauncherPopover ref={popoverTargetRef} />
6666
</Composer>
6767
</div>
6868
);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { refObject, validateProps } from '@msinternal/botframework-webchat-react-valibot';
2+
import { ButtonPolymiddlewareProxy } from 'botframework-webchat-api/middleware';
3+
import React, { memo } from 'react';
4+
import { object, optional, pipe, readonly, type InferInput } from 'valibot';
5+
6+
import Icon from '../Icon';
7+
8+
const dismissButtonPropsSchema = pipe(
9+
object({
10+
popoverRef: optional(refObject<Element>())
11+
}),
12+
readonly()
13+
);
14+
15+
type DismissButtonProps = InferInput<typeof dismissButtonPropsSchema>;
16+
17+
function DismissButton(props: DismissButtonProps) {
18+
const { popoverRef } = validateProps(dismissButtonPropsSchema, props);
19+
20+
return (
21+
<ButtonPolymiddlewareProxy appearance="flat" popoverTargetAction="hide" popoverTargetRef={popoverRef}>
22+
<Icon appearance="button" icon="dismiss" />
23+
</ButtonPolymiddlewareProxy>
24+
);
25+
}
26+
27+
DismissButton.displayName = 'ChatLauncherPopover/DismissButton';
28+
29+
export default memo(DismissButton);
30+
export { dismissButtonPropsSchema, type DismissButtonProps };
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ButtonPolymiddlewareProxy } from 'botframework-webchat-api/middleware';
2+
import React, { memo } from 'react';
3+
import { object, pipe, readonly, type InferInput } from 'valibot';
4+
5+
import Icon from '../Icon';
6+
7+
const restartButtonPropsSchema = pipe(object({}), readonly());
8+
9+
type RestartButtonProps = InferInput<typeof restartButtonPropsSchema>;
10+
11+
function RestartButton(_: RestartButtonProps) {
12+
return (
13+
<ButtonPolymiddlewareProxy appearance="flat">
14+
<Icon appearance="button" icon="arrow-clockwise" />
15+
</ButtonPolymiddlewareProxy>
16+
);
17+
}
18+
19+
RestartButton.displayName = 'ChatLauncherPopover/RestartButton';
20+
21+
export default memo(RestartButton);
22+
export { restartButtonPropsSchema, type RestartButtonProps };

packages/experience-chat-launcher/src/private/private/ChatLauncherPopoverTitleBar.module.css renamed to packages/experience-chat-launcher/src/private/private/ChatLauncherPopover/TitleBar.module.css

File renamed without changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { refObject, validateProps } from '@msinternal/botframework-webchat-react-valibot';
2+
import { useStyles } from '@msinternal/botframework-webchat-styles/react';
3+
import React, { forwardRef, memo } from 'react';
4+
import { object, optional, pipe, readonly, type InferInput } from 'valibot';
5+
6+
import DismissButton from './DismissButton';
7+
import RestartButton from './RestartButton';
8+
import styles from './TitleBar.module.css';
9+
import TitleText from './TitleText';
10+
11+
const titleBarPropsSchema = pipe(
12+
object({
13+
popoverRef: optional(refObject<Element>())
14+
}),
15+
readonly()
16+
);
17+
18+
type TitleBarProps = InferInput<typeof titleBarPropsSchema>;
19+
20+
function TitleBar(props: TitleBarProps) {
21+
const { popoverRef } = validateProps(titleBarPropsSchema, props);
22+
23+
const classNames = useStyles(styles);
24+
25+
return (
26+
<div className={classNames['chat-launcher-popover__title-bar']}>
27+
<TitleText>{'Contoso agent'}</TitleText>
28+
<RestartButton />
29+
<DismissButton popoverRef={popoverRef} />
30+
</div>
31+
);
32+
}
33+
34+
TitleBar.displayName = 'ChatLauncherPopover/TitleBar';
35+
36+
export default memo(forwardRef(TitleBar));
37+
export { titleBarPropsSchema, type TitleBarProps };

packages/experience-chat-launcher/src/private/private/ChatLauncherPopoverTitleText.module.css renamed to packages/experience-chat-launcher/src/private/private/ChatLauncherPopover/TitleText.module.css

File renamed without changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { reactNode, validateProps } from '@msinternal/botframework-webchat-react-valibot';
2+
import { useStyles } from '@msinternal/botframework-webchat-styles/react';
3+
import React, { memo } from 'react';
4+
import { object, optional, pipe, readonly, type InferInput } from 'valibot';
5+
6+
import styles from './TitleText.module.css';
7+
8+
const titleTextPropsSchema = pipe(
9+
object({
10+
children: optional(reactNode())
11+
}),
12+
readonly()
13+
);
14+
15+
type TitleTextProps = InferInput<typeof titleTextPropsSchema>;
16+
17+
function TitleText(props: TitleTextProps) {
18+
const { children } = validateProps(titleTextPropsSchema, props);
19+
20+
const classNames = useStyles(styles);
21+
22+
return <div className={classNames['chat-launcher-popover__title-text']}>{children}</div>;
23+
}
24+
25+
TitleText.displayName = 'ChatLauncherPopover/TitleText';
26+
27+
export default memo(TitleText);
28+
export { titleTextPropsSchema, type TitleTextProps };

packages/experience-chat-launcher/src/private/private/ChatLauncherPopover.tsx renamed to packages/experience-chat-launcher/src/private/private/ChatLauncherPopover/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import mergeRefs from 'merge-refs';
33
import React, { forwardRef, memo, useRef, type ForwardedRef } from 'react';
44
import { object, pipe, readonly, type InferInput } from 'valibot';
55

6-
import ChatLauncherPopoverTitleBar from './ChatLauncherPopoverTitleBar';
6+
import TitleBar from './TitleBar';
77

88
const chatLauncherPopoverPropsSchema = pipe(object({}), readonly());
99

@@ -15,7 +15,7 @@ function ChatLauncherPopover(_: ChatLauncherPopoverProps, ref: ForwardedRef<Elem
1515
return (
1616
// TODO: [P2] Is it correct to force-cast ref to HTMLDivElement?
1717
<PopoverPolymiddlewareProxy popover="manual" ref={mergeRefs(popoverRef, ref)} type="nonmodal">
18-
<ChatLauncherPopoverTitleBar popoverRef={popoverRef} />
18+
<TitleBar popoverRef={popoverRef} />
1919
</PopoverPolymiddlewareProxy>
2020
);
2121
}

packages/experience-chat-launcher/src/private/private/ChatLauncherPopoverDismissButton.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

packages/experience-chat-launcher/src/private/private/ChatLauncherPopoverRestartButton.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)