botframework-webchat-fluent-theme 4.17.0-main.20240411.647b269 → 4.17.0-main.20240416.4ff01ae

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/botframework-webchat-fluent-theme.development.css.map +1 -0
  2. package/dist/botframework-webchat-fluent-theme.development.js +2384 -0
  3. package/dist/botframework-webchat-fluent-theme.development.js.map +1 -0
  4. package/dist/botframework-webchat-fluent-theme.production.min.css.map +1 -0
  5. package/dist/botframework-webchat-fluent-theme.production.min.js +6 -16
  6. package/dist/botframework-webchat-fluent-theme.production.min.js.map +1 -1
  7. package/dist/index.css.map +1 -0
  8. package/dist/index.d.mts +27 -0
  9. package/dist/index.d.ts +27 -0
  10. package/dist/index.js +1062 -16
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +1076 -0
  13. package/dist/index.mjs.map +1 -1
  14. package/package.json +17 -7
  15. package/src/bundle.ts +9 -2
  16. package/src/components/DropZone.tsx +3 -0
  17. package/src/components/SendBox.tsx +3 -0
  18. package/src/components/SuggestedActions.tsx +3 -0
  19. package/src/components/TelephoneKeypad.tsx +1 -0
  20. package/src/components/Theme.module.css +60 -0
  21. package/src/components/Theme.tsx +11 -0
  22. package/src/components/dropZone/index.module.css +23 -0
  23. package/src/components/dropZone/index.tsx +107 -0
  24. package/src/components/sendbox/AddAttachmentButton.module.css +10 -0
  25. package/src/components/sendbox/AddAttachmentButton.tsx +65 -0
  26. package/src/components/sendbox/Attachments.module.css +7 -0
  27. package/src/components/sendbox/Attachments.tsx +31 -0
  28. package/src/components/sendbox/ErrorMessage.module.css +9 -0
  29. package/src/components/sendbox/ErrorMessage.tsx +15 -0
  30. package/src/components/sendbox/TelephoneKeypadToolbarButton.tsx +30 -0
  31. package/src/components/sendbox/TextArea.module.css +61 -0
  32. package/src/components/sendbox/TextArea.tsx +85 -0
  33. package/src/components/sendbox/Toolbar.module.css +49 -0
  34. package/src/components/sendbox/Toolbar.tsx +64 -0
  35. package/src/components/sendbox/index.module.css +58 -0
  36. package/src/components/sendbox/index.tsx +169 -0
  37. package/src/components/sendbox/private/useSubmitError.ts +46 -0
  38. package/src/components/sendbox/private/useUniqueId.ts +13 -0
  39. package/src/components/suggestedActions/AccessibleButton.tsx +59 -0
  40. package/src/components/suggestedActions/SuggestedAction.module.css +34 -0
  41. package/src/components/suggestedActions/SuggestedAction.tsx +87 -0
  42. package/src/components/suggestedActions/index.module.css +23 -0
  43. package/src/components/suggestedActions/index.tsx +98 -0
  44. package/src/components/suggestedActions/private/computeSuggestedActionText.ts +21 -0
  45. package/src/components/telephoneKeypad/Provider.tsx +22 -0
  46. package/src/components/telephoneKeypad/Surrogate.tsx +13 -0
  47. package/src/components/telephoneKeypad/index.ts +6 -0
  48. package/src/components/telephoneKeypad/private/Button.module.css +62 -0
  49. package/src/components/telephoneKeypad/private/Button.tsx +45 -0
  50. package/src/components/telephoneKeypad/private/Context.ts +18 -0
  51. package/src/components/telephoneKeypad/private/TelephoneKeypad.module.css +30 -0
  52. package/src/components/telephoneKeypad/private/TelephoneKeypad.tsx +137 -0
  53. package/src/components/telephoneKeypad/types.ts +1 -0
  54. package/src/components/telephoneKeypad/useShown.ts +9 -0
  55. package/src/env.d.ts +7 -0
  56. package/src/external.umd/botframework-webchat-api.ts +3 -0
  57. package/src/external.umd/botframework-webchat-component.ts +4 -0
  58. package/src/external.umd/react.ts +1 -0
  59. package/src/icons/AddDocumentIcon.tsx +20 -0
  60. package/src/icons/AttachmentIcon.tsx +20 -0
  61. package/src/icons/SendIcon.tsx +20 -0
  62. package/src/icons/TelephoneKeypad.tsx +20 -0
  63. package/src/index.ts +5 -1
  64. package/src/private/FluentThemeProvider.tsx +11 -7
  65. package/src/styles/injectStyle.ts +9 -0
  66. package/src/styles/useStyles.ts +19 -0
  67. package/src/styles.ts +4 -0
  68. package/src/testIds.ts +21 -0
  69. package/src/tsconfig.json +2 -1
  70. package/src/types/PropsOf.ts +7 -0
  71. package/src/external/ThemeProvider.tsx +0 -16
  72. package/src/private/SendBox.tsx +0 -7
package/src/env.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ // CSS modules
2
+ type CSSModuleClasses = { readonly [key: string]: any };
3
+
4
+ declare module '*.module.css' {
5
+ const classes: CSSModuleClasses;
6
+ export default classes;
7
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ hooks: (globalThis as any).WebChat.hooks
3
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ Components: (globalThis as any).WebChat.Components,
3
+ hooks: (globalThis as any).WebChat.hooks
4
+ };
@@ -0,0 +1 @@
1
+ module.exports = (globalThis as any).React;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ export function AddDocumentIcon(props: Readonly<{ readonly className?: string }>) {
4
+ return (
5
+ <svg
6
+ aria-hidden="true"
7
+ className={props.className}
8
+ fill="currentColor"
9
+ height="1em"
10
+ viewBox="0 0 20 20"
11
+ width="1em"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ >
14
+ <path
15
+ d="M6 2a2 2 0 0 0-2 2v5.2c.32-.08.66-.15 1-.18V4a1 1 0 0 1 1-1h4v3.5c0 .83.67 1.5 1.5 1.5H15v8a1 1 0 0 1-1 1h-3.6c-.18.36-.4.7-.66 1H14a2 2 0 0 0 2-2V7.41c0-.4-.16-.78-.44-1.06l-3.91-3.91A1.5 1.5 0 0 0 10.59 2H6Zm8.8 5h-3.3a.5.5 0 0 1-.5-.5V3.2L14.8 7ZM10 14.5a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm-4-2a.5.5 0 0 0-1 0V14H3.5a.5.5 0 0 0 0 1H5v1.5a.5.5 0 0 0 1 0V15h1.5a.5.5 0 0 0 0-1H6v-1.5Z"
16
+ fill="currentColor"
17
+ />
18
+ </svg>
19
+ );
20
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ export function AttachmentIcon(props: Readonly<{ readonly className?: string }>) {
4
+ return (
5
+ <svg
6
+ aria-hidden="true"
7
+ className={props.className}
8
+ fill="currentColor"
9
+ height="1em"
10
+ viewBox="0 0 20 20"
11
+ width="1em"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ >
14
+ <path
15
+ d="m4.83 10.48 5.65-5.65a3 3 0 0 1 4.25 4.24L8 15.8a1.5 1.5 0 0 1-2.12-2.12l6-6.01a.5.5 0 1 0-.7-.71l-6 6.01a2.5 2.5 0 0 0 3.53 3.54l6.71-6.72a4 4 0 1 0-5.65-5.66L4.12 9.78a.5.5 0 0 0 .7.7Z"
16
+ fill="currentColor"
17
+ />
18
+ </svg>
19
+ );
20
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ export function SendIcon(props: Readonly<{ readonly className?: string }>) {
4
+ return (
5
+ <svg
6
+ aria-hidden="true"
7
+ className={props.className}
8
+ fill="currentColor"
9
+ height="1em"
10
+ viewBox="0 0 20 20"
11
+ width="1em"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ >
14
+ <path
15
+ d="M2.18 2.11a.5.5 0 0 1 .54-.06l15 7.5a.5.5 0 0 1 0 .9l-15 7.5a.5.5 0 0 1-.7-.58L3.98 10 2.02 2.63a.5.5 0 0 1 .16-.52Zm2.7 8.39-1.61 6.06L16.38 10 3.27 3.44 4.88 9.5h6.62a.5.5 0 1 1 0 1H4.88Z"
16
+ fill="currentColor"
17
+ />
18
+ </svg>
19
+ );
20
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ export function TelephoneKeypadIcon(props: Readonly<{ readonly className?: string }>) {
4
+ return (
5
+ <svg
6
+ aria-hidden="true"
7
+ className={props.className}
8
+ fill="currentColor"
9
+ height="1em"
10
+ viewBox="0 0 20 20"
11
+ width="1em"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ >
14
+ <path
15
+ d="M6 5.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Zm0 4a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5ZM7.25 12a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0ZM10 5.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5ZM11.25 8a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0ZM10 13.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5ZM11.25 16a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0ZM14 5.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5ZM15.25 8a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0ZM14 13.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z"
16
+ fill="currentColor"
17
+ />
18
+ </svg>
19
+ );
20
+ }
package/src/index.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  import { injectMetaTag } from 'inject-meta-tag';
2
2
 
3
3
  import FluentThemeProvider from './private/FluentThemeProvider';
4
+ import testIds from './testIds';
5
+ import { injectStyle } from './styles';
4
6
 
5
7
  declare const NPM_PACKAGE_VERSION: string;
6
8
 
7
9
  injectMetaTag('botframework-webchat-fluent-theme:version', NPM_PACKAGE_VERSION);
8
10
 
9
- export { FluentThemeProvider };
11
+ injectStyle();
12
+
13
+ export { FluentThemeProvider, testIds };
@@ -1,18 +1,22 @@
1
+ import { Components } from 'botframework-webchat-component';
1
2
  import React, { memo, type ReactNode } from 'react';
2
3
 
3
- import ThemeProvider from '../external/ThemeProvider';
4
- import SendBox from './SendBox';
4
+ import { TelephoneKeypadProvider } from '../components/TelephoneKeypad';
5
+ import WebChatTheme from '../components/Theme';
6
+ import SendBox from '../components/SendBox';
5
7
 
6
- type Props = Readonly<{ children?: ReactNode | undefined }>;
8
+ const { ThemeProvider } = Components;
7
9
 
8
- const STYLE_OPTIONS = { bubbleBackground: '#fee' };
10
+ type Props = Readonly<{ children?: ReactNode | undefined }>;
9
11
 
10
12
  const sendBoxMiddleware = [() => () => () => SendBox];
11
13
 
12
14
  const FluentThemeProvider = ({ children }: Props) => (
13
- <ThemeProvider sendBoxMiddleware={sendBoxMiddleware} styleOptions={STYLE_OPTIONS}>
14
- {children}
15
- </ThemeProvider>
15
+ <WebChatTheme>
16
+ <TelephoneKeypadProvider>
17
+ <ThemeProvider sendBoxMiddleware={sendBoxMiddleware}>{children}</ThemeProvider>
18
+ </TelephoneKeypadProvider>
19
+ </WebChatTheme>
16
20
  );
17
21
 
18
22
  export default memo(FluentThemeProvider);
@@ -0,0 +1,9 @@
1
+ export const injectedStyles = '@--INJECTED-STYLES-CONTENT--@';
2
+
3
+ export default function injectStyles() {
4
+ if (globalThis.document) {
5
+ const style = document.createElement('style');
6
+ style.append(document.createTextNode(injectedStyles));
7
+ document.head.appendChild(style);
8
+ }
9
+ }
@@ -0,0 +1,19 @@
1
+ import { useMemo } from 'react';
2
+
3
+ function useStyles<T extends CSSModuleClasses>(styles: T): T {
4
+ // @ts-expect-error: entries/fromEntries don't allow to specify keys type
5
+ return useMemo(
6
+ () =>
7
+ Object.freeze(
8
+ Object.fromEntries(
9
+ Object.entries(styles).map(([baseClassName, resultClassName]) => [
10
+ baseClassName,
11
+ `${baseClassName} ${resultClassName}`
12
+ ])
13
+ )
14
+ ),
15
+ [styles]
16
+ );
17
+ }
18
+
19
+ export default useStyles;
package/src/styles.ts ADDED
@@ -0,0 +1,4 @@
1
+ import injectStyle from './styles/injectStyle';
2
+ import useStyles from './styles/useStyles';
3
+
4
+ export { injectStyle, useStyles };
package/src/testIds.ts ADDED
@@ -0,0 +1,21 @@
1
+ const testIds = {
2
+ sendBoxDropZone: 'send box drop zone',
3
+ sendBoxSendButton: 'send box send button',
4
+ sendBoxTextBox: 'send box text area',
5
+ sendBoxTelephoneKeypadButton1: `send box telephone keypad button 1`,
6
+ sendBoxTelephoneKeypadButton2: `send box telephone keypad button 2`,
7
+ sendBoxTelephoneKeypadButton3: `send box telephone keypad button 3`,
8
+ sendBoxTelephoneKeypadButton4: `send box telephone keypad button 4`,
9
+ sendBoxTelephoneKeypadButton5: `send box telephone keypad button 5`,
10
+ sendBoxTelephoneKeypadButton6: `send box telephone keypad button 6`,
11
+ sendBoxTelephoneKeypadButton7: `send box telephone keypad button 7`,
12
+ sendBoxTelephoneKeypadButton8: `send box telephone keypad button 8`,
13
+ sendBoxTelephoneKeypadButton9: `send box telephone keypad button 9`,
14
+ sendBoxTelephoneKeypadButton0: `send box telephone keypad button 0`,
15
+ sendBoxTelephoneKeypadButtonStar: `send box telephone keypad button star`,
16
+ sendBoxTelephoneKeypadButtonPound: `send box telephone keypad button pound`,
17
+ sendBoxTelephoneKeypadToolbarButton: 'send box telephone keypad toolbar button',
18
+ sendBoxUploadButton: 'send box upload button'
19
+ };
20
+
21
+ export default testIds;
package/src/tsconfig.json CHANGED
@@ -5,7 +5,8 @@
5
5
  "jsx": "react",
6
6
  "moduleResolution": "Bundler",
7
7
  "skipLibCheck": true,
8
- "target": "ESNext"
8
+ "target": "ESNext",
9
+ "plugins": [{ "name": "typescript-plugin-css-modules" }]
9
10
  },
10
11
  "extends": "@tsconfig/strictest/tsconfig.json"
11
12
  }
@@ -0,0 +1,7 @@
1
+ import { type ComponentType, type MemoExoticComponent } from 'react';
2
+
3
+ export type PropsOf<T> = T extends ComponentType<infer P>
4
+ ? P
5
+ : T extends MemoExoticComponent<ComponentType<infer P>>
6
+ ? P
7
+ : never;
@@ -1,16 +0,0 @@
1
- import { type Components } from 'botframework-webchat-component';
2
-
3
- // TODO: We should do isomorphic:
4
- // - If loading UMD, we should look at window.WebChat.Components.ThemeProvider
5
- // - Otherwise, we should import { type Components } from 'botframework-webchat-component'
6
- type ThemeProviderType = (typeof Components)['ThemeProvider'];
7
-
8
- const {
9
- WebChat: {
10
- Components: { ThemeProvider }
11
- }
12
- } = globalThis as unknown as {
13
- WebChat: { Components: { ThemeProvider: ThemeProviderType } };
14
- };
15
-
16
- export default ThemeProvider;
@@ -1,7 +0,0 @@
1
- import React, { memo } from 'react';
2
-
3
- type Props = Readonly<{ className?: string | undefined }>;
4
-
5
- const SendBox = ({ className }: Props) => <div className={className}>{'Fluent send box'}</div>;
6
-
7
- export default memo(SendBox);