Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fluent theme] Add Fluent SendBox #5122

Merged
merged 92 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
d25226c
[WIP] Add Fluent package
OEvgeny Apr 4, 2024
336cd19
TEXT_INPUT_DROPZONE -> TEXT_INPUT_DROP_ZONE
OEvgeny Apr 8, 2024
99dfaca
classnames -> classNames
OEvgeny Apr 8, 2024
a40cd36
Add more Readonly to the god of reaonly
OEvgeny Apr 8, 2024
91eb9ab
Sort
OEvgeny Apr 8, 2024
935c8e3
Sort style properties asc
OEvgeny Apr 8, 2024
03c8ea4
Specify deps
OEvgeny Apr 8, 2024
c5d3917
DropZone to own file
OEvgeny Apr 8, 2024
7dedf64
Remove <span> tag
OEvgeny Apr 8, 2024
82ebf45
dropzone -> drop-zone
OEvgeny Apr 8, 2024
2b35ae5
AttachmentDropZone -> DropZone
OEvgeny Apr 8, 2024
8e12f41
webchat__sendbox__root -> webchat__sendbox
OEvgeny Apr 8, 2024
63c9c14
Naming and freezing
OEvgeny Apr 8, 2024
f583b51
Forbid arbitrary props
OEvgeny Apr 8, 2024
1e79d06
webchat__ -> webchat-fluent__
OEvgeny Apr 8, 2024
e2c85dd
disabled -> aria-disabled
OEvgeny Apr 8, 2024
fe49b40
Use native form
OEvgeny Apr 8, 2024
8e9af05
DialpadIcon -> TelephoneKeypadIcon
OEvgeny Apr 8, 2024
65dc2d3
Readonly<T> -> readonly
OEvgeny Apr 8, 2024
e455d8a
useStlyeToEmotionObject -> useStyleToEmotionObject
OEvgeny Apr 8, 2024
9b31391
Add message length exceeded aria
OEvgeny Apr 8, 2024
acc6952
TEXT_INPUT_DIALPAD_BUTTON_ALT -> TEXT_INPUT_TELEPHON_KEYPAD_BUTTON_ALT
OEvgeny Apr 8, 2024
9b316a8
integration: sendMessage
OEvgeny Apr 8, 2024
87ac3d0
integration: SuggestedActions
OEvgeny Apr 8, 2024
e6f62b6
Remove unnecessary readonly
OEvgeny Apr 8, 2024
9b18a55
milestone: passing build
OEvgeny Apr 8, 2024
53f9c90
Remove unused types
OEvgeny Apr 8, 2024
1cee7f0
Redo import UMD
compulim Apr 8, 2024
48fa10c
Remove obsolate tsconfig
OEvgeny Apr 8, 2024
c599dd5
Fix attachments types
OEvgeny Apr 8, 2024
b08e8e6
Rework attachments display
OEvgeny Apr 8, 2024
1efb044
Add attachment counter test
compulim Apr 8, 2024
f8e0446
Always use latest attachments
OEvgeny Apr 8, 2024
7e31062
Respect style options for file upload
OEvgeny Apr 8, 2024
6f8deb6
Remove empty space
OEvgeny Apr 8, 2024
6f3b0a5
Add tests
compulim Apr 8, 2024
2e06951
Fix aria-label
compulim Apr 9, 2024
67e3afc
Typo and aria-label
compulim Apr 9, 2024
133d3f1
Fix aria-label
compulim Apr 9, 2024
423126c
Add padding around send box
compulim Apr 9, 2024
b05bf8e
Add connectivity status test
compulim Apr 9, 2024
29b33a2
Rename aria-label
compulim Apr 9, 2024
25de370
Add suggested actions test
compulim Apr 9, 2024
1cee5a5
Add padding
compulim Apr 9, 2024
9a1d9ee
Rename umd
compulim Apr 9, 2024
c141002
Add data-testid
compulim Apr 9, 2024
835ed6c
Add send on ENTER key test
compulim Apr 9, 2024
be2536d
Add send button click test
compulim Apr 9, 2024
e0e5cdc
Add useRefFrom for useCallback
compulim Apr 9, 2024
3d15f19
Use useSendBoxAttachments
compulim Apr 9, 2024
9a5c7d6
Sort
compulim Apr 9, 2024
b6b22af
Simplify ToolbarButton props.type
compulim Apr 9, 2024
2abcce2
Use button.type
compulim Apr 9, 2024
e2a2db3
Refactor DropZone components
compulim Apr 9, 2024
1d03c7b
Remove red color
compulim Apr 9, 2024
2ffa72a
Rename to <WebChatTheme>
compulim Apr 9, 2024
f30b474
TextArea improvements:
OEvgeny Apr 9, 2024
884ad7f
Fix drop zone and add droppable class
compulim Apr 9, 2024
a66ae60
SuggestedActions and more:
OEvgeny Apr 10, 2024
de2c320
TextArea: padding and rows
OEvgeny Apr 10, 2024
051f273
SendBox: Add ErrorMessage for connect and empty
OEvgeny Apr 10, 2024
cb288e7
Add drag and drop test
compulim Apr 10, 2024
6ea2d3e
Fix drag over icon
compulim Apr 10, 2024
b2a0e95
SendBox: focus back on the input
OEvgeny Apr 10, 2024
c84f4dc
Theme: better align with Design Brand colors
OEvgeny Apr 10, 2024
805bffa
SuggestedActions: move icon one pixel to the top
OEvgeny Apr 10, 2024
3f8f304
CodeStyle: prefer not to use erly return
OEvgeny Apr 10, 2024
ccfe07b
Self bugbash
OEvgeny Apr 10, 2024
2ebc8de
Fix: SuggestedActions types
OEvgeny Apr 10, 2024
a7691b9
SendBox: wire maxMessageLength
OEvgeny Apr 10, 2024
518ff7d
Toolbar: fix disabled button is clickable
OEvgeny Apr 10, 2024
443ff0d
SendBox: update simple snapshot
OEvgeny Apr 10, 2024
b92e489
Adding new vars
compulim Apr 10, 2024
73ea46c
Tests: enable tests and add more
OEvgeny Apr 10, 2024
18d72a7
SendBox: fix able to send form with Enter when maxLength exceeded
OEvgeny Apr 10, 2024
5640037
TextBox: fix doppelganger width
OEvgeny Apr 10, 2024
4c76727
Tests: fix host.sendKeys usage
OEvgeny Apr 10, 2024
d4524e4
Add telephone keypad
compulim Apr 10, 2024
1fe6b45
Theme: prefix webchat variables and fallback to fluent if present
OEvgeny Apr 10, 2024
0727143
Tests: rollback unwanted
OEvgeny Apr 10, 2024
82ba203
Test: disable problematic activeElement check for now
OEvgeny Apr 10, 2024
335aee2
AddAttachmentButton: remove unused icon prop
OEvgeny Apr 10, 2024
dcb3158
SendBox: reorganize modules
OEvgeny Apr 10, 2024
3f3f667
AddAttachmentsButton: remove unused import
OEvgeny Apr 10, 2024
4327fa4
Localize: remove TODO and fix localization docs
OEvgeny Apr 10, 2024
0a0040f
ESCAPE key to close DTMF keypad
compulim Apr 11, 2024
f0569e0
Add more test
compulim Apr 11, 2024
9e7cddc
Styles: avoid lint warnings
OEvgeny Apr 11, 2024
6243e8b
Reduce height when hiding
compulim Apr 11, 2024
803efbb
Add test entrypoints
compulim Apr 11, 2024
21153c0
Add entry
compulim Apr 11, 2024
9b6c6f3
Add entry
compulim Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- `useSendMessage` hook is updated to support sending attachments with a message. To reduce complexity, the `useSendFiles` hook is being deprecated. The hook will be removed on or after 2026-04-03
- `styleOptions.uploadThumbnailHeight` and `styleOptions.uploadThumbnailWidth` must be a `number` of pixels
- `useSuggestedActions` type is updated to align with its actual implementation, by [@OEvgeny](https://github.com/OEvgeny), in PR [#5122](https://github.com/microsoft/BotFramework-WebChat/pull/5122)

### Added

- Resolves [#5083](https://github.com/microsoft/BotFramework-WebChat/issues/5083). Added `sendAttachmentOn` style option to send attachments and text in a single activity, by [@ms-jb](https://github.com/ms-jb) and [@compulim](https://github.com/compulim)
- Resolves [#5083](https://github.com/microsoft/BotFramework-WebChat/issues/5083). Added `sendAttachmentOn` style option to send attachments and text in a single activity, by [@ms-jb](https://github.com/ms-jb) and [@compulim](https://github.com/compulim), in PR [#5123](https://github.com/microsoft/BotFramework-WebChat/pull/5123)
- `useSendMessage` hook is updated to support sending attachments with a message
- `useSendBoxAttachments` hook is added to get/set attachments in the send box
- Resolves [#5081](https://github.com/microsoft/BotFramework-WebChat/issues/5081). Added `uploadAccept` and `uploadMultiple` style options, by [@ms-jb](https://github.com/ms-jb), in PR [#5048](https://github.com/microsoft/BotFramework-WebChat/pull/5048)
- Added `sendBoxMiddleware` and `sendBoxToolbarMiddleware`, by [@compulim](https://github.com/compulim), in PR [#5120](https://github.com/microsoft/BotFramework-WebChat/pull/5120)
- Added `botframework-webchat-fluent-theme` package for applying Fluent UI theme to Web Chat, by [@compulim](https://github.com/compulim), in PR [#5120](https://github.com/microsoft/BotFramework-WebChat/pull/5120)
- (Experimental) Added `botframework-webchat-fluent-theme` package for applying Fluent UI theme to Web Chat, by [@compulim](https://github.com/compulim) and [@OEvgeny](https://github.com/OEvgeny), in PR [#5120](https://github.com/microsoft/BotFramework-WebChat/pull/5120)
- Inherits Fluent CSS palette if available, in PR [#5122](https://github.com/microsoft/BotFramework-WebChat/pull/5122)
- New send box with Fluent look-and-feel, in PR [#5122](https://github.com/microsoft/BotFramework-WebChat/pull/5122)
- `styleOptions.maxMessageLength` to specify maximum length of the outgoing message
- Drag-and-drop file support, in PR [#5122](https://github.com/microsoft/BotFramework-WebChat/pull/5122)
- Added telephone keypad (DTMF keypad), in PR [#5122](https://github.com/microsoft/BotFramework-WebChat/pull/5122)
- Added `<ThemeProvider>` component to apply theme pack to Web Chat, by [@compulim](https://github.com/compulim), in PR [#5120](https://github.com/microsoft/BotFramework-WebChat/pull/5120)
- Added `useMakeThumbnail` hook option to create a thumbnail from the file given, by [@compulim](https://github.com/compulim), in PR [#5123](https://github.com/microsoft/BotFramework-WebChat/pull/5123) and [#5122](https://github.com/microsoft/BotFramework-WebChat/pull/5122)

### Fixed

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions __tests__/html/fluentTheme/attachFile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
</head>
<body>
<main id="webchat"></main>
<script type="text/babel">
run(async function () {
const {
React,
ReactDOM: { render },
WebChat: { FluentThemeProvider, ReactWebChat }
} = window; // Imports in UMD fashion.

const { directLine, store } = testHelpers.createDirectLineEmulator();

const App = () => <ReactWebChat directLine={directLine} locale="yue" store={store} />;

render(
<FluentThemeProvider>
<App />
</FluentThemeProvider>,
document.getElementById('webchat')
);

await pageConditions.uiConnected();

await pageObjects.uploadFile('seaofthieves.jpg');

await pageConditions.became(
'attachment count change to 1',
() => {
try {
// It seems "yue" doesn't use plural form of "one".
expect(document.querySelector('.webchat-fluent__sendbox__attachment').textContent.trim()).toBe(
'1 件附件'
);

return true;
} catch {
return false;
}
},
1000
);

await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/fluentTheme/attachFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('Fluent theme applied', () => {
test('attach a single file', () => runHTML('fluentTheme/attachFile'));
});
90 changes: 90 additions & 0 deletions __tests__/html/fluentTheme/attachMultipleFiles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
</head>
<body>
<main id="webchat"></main>
<script type="text/babel">
run(async function () {
const {
React,
ReactDOM: { render },
WebChat: { FluentThemeProvider, ReactWebChat }
} = window; // Imports in UMD fashion.

const { directLine, store } = testHelpers.createDirectLineEmulator();

const App = () => (
<ReactWebChat
activityMiddleware={testHelpers.createRunHookActivityMiddleware()}
directLine={directLine}
store={store}
/>
);

render(
<FluentThemeProvider>
<App />
</FluentThemeProvider>,
document.getElementById('webchat')
);

await pageConditions.uiConnected();

const blob1 = new File(
[
await (
await fetch(
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface1.jpg'
)
).blob()
],
'surface1.jpg',
{ type: 'image/jpeg' }
);

const blob2 = new File(
[
await (
await fetch(
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface2.jpg'
)
).blob()
],
'surface2.jpg',
{ type: 'image/jpeg' }
);

await pageObjects.runHook(({ useSendBoxAttachments }) =>
useSendBoxAttachments()[1]([{ blob: blob1 }, { blob: blob2 }])
);

await pageConditions.became(
'attachment count change to 2',
() => {
try {
expect(document.querySelector('.webchat-fluent__sendbox__attachment').textContent.trim()).toBe(
'2 attachments'
);

return true;
} catch {
return false;
}
},
1000
);

await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/fluentTheme/attachMultipleFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('Fluent theme applied', () => {
test('attach multiple files', () => runHTML('fluentTheme/attachMultipleFiles'));
});
60 changes: 60 additions & 0 deletions __tests__/html/fluentTheme/autoResize.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
</head>
<body>
<main id="webchat"></main>
<script type="text/babel">
run(async function () {
const {
React,
ReactDOM: { render },
WebChat: { FluentThemeProvider, ReactWebChat }
} = window; // Imports in UMD fashion.

const { directLine, store } = testHelpers.createDirectLineEmulator();

const App = () => <ReactWebChat directLine={directLine} store={store} />;

render(
<FluentThemeProvider>
<App />
</FluentThemeProvider>,
document.getElementById('webchat')
);

await pageConditions.uiConnected();

await directLine.emulateIncomingActivity(
'Eiusmod anim adipisicing cupidatat adipisicing officia sint qui consequat veniam id aute.'
);

await pageConditions.numActivitiesShown(1);
document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`).focus();

// With new lines
document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`).value = ['One', 'Two', 'Three'].join('\n');
await host.sendKeys(' ');
await host.snapshot();

// With a single long line
document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`).value = '';
await host.sendKeys('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris '.repeat(2));
await host.snapshot();

// With a scroll-bar when passed 10 lines
document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`).value += ['', 'One', 'Two', 'Three'].join('\n');
await host.sendKeys(' ');
await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/fluentTheme/autoResize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('Fluent theme applied', () => {
test('textbox auto resize', () => runHTML('fluentTheme/autoResize'));
});
39 changes: 39 additions & 0 deletions __tests__/html/fluentTheme/connectivityStatus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
</head>
<body>
<main id="webchat"></main>
<script type="text/babel">
run(async function () {
const {
React,
ReactDOM: { render },
WebChat: { FluentThemeProvider, ReactWebChat }
} = window; // Imports in UMD fashion.

const { directLine, store } = testHelpers.createDirectLineEmulator({ autoConnect: false });

const App = () => <ReactWebChat directLine={directLine} store={store} />;

render(
<FluentThemeProvider>
<App />
</FluentThemeProvider>,
document.getElementById('webchat')
);

// THEN: Should render the activity.
await host.snapshot();
});
</script>
</body>
</html>
Loading
Loading