botframework-webchat-fluent-theme 4.18.1-main.20240807.dfe788c → 4.18.1-main.20240813.c50aac5

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 (35) hide show
  1. package/dist/botframework-webchat-fluent-theme.css.map +1 -1
  2. package/dist/botframework-webchat-fluent-theme.d.mts +3 -1
  3. package/dist/botframework-webchat-fluent-theme.d.ts +3 -1
  4. package/dist/botframework-webchat-fluent-theme.development.css.map +1 -1
  5. package/dist/botframework-webchat-fluent-theme.development.js +1 -1
  6. package/dist/botframework-webchat-fluent-theme.development.js.map +1 -1
  7. package/dist/botframework-webchat-fluent-theme.js +1 -1
  8. package/dist/botframework-webchat-fluent-theme.js.map +1 -1
  9. package/dist/botframework-webchat-fluent-theme.mjs +1 -1
  10. package/dist/botframework-webchat-fluent-theme.mjs.map +1 -1
  11. package/dist/botframework-webchat-fluent-theme.production.min.css.map +1 -1
  12. package/dist/botframework-webchat-fluent-theme.production.min.js +1 -1
  13. package/dist/botframework-webchat-fluent-theme.production.min.js.map +1 -1
  14. package/package.json +4 -4
  15. package/src/components/activity/ActivityDecorator.module.css +305 -0
  16. package/src/components/activity/ActivityDecorator.tsx +26 -0
  17. package/src/components/activity/CopilotMessageHeader.module.css +42 -0
  18. package/src/components/activity/CopilotMessageHeader.tsx +41 -0
  19. package/src/components/activity/index.ts +1 -0
  20. package/src/components/preChatActivity/PreChatMessageActivity.module.css +4 -2
  21. package/src/components/preChatActivity/StarterPromptsCardAction.module.css +1 -1
  22. package/src/components/preChatActivity/StarterPromptsCardAction.tsx +2 -0
  23. package/src/components/preChatActivity/private/MonochromeImageMasker.module.css +3 -1
  24. package/src/components/sendBox/SendBox.module.css +3 -1
  25. package/src/components/sendBox/SendBox.tsx +23 -12
  26. package/src/components/sendBox/index.tsx +1 -1
  27. package/src/components/theme/Theme.module.css +223 -10
  28. package/src/components/theme/Theme.tsx +3 -2
  29. package/src/private/FluentThemeProvider.tsx +23 -14
  30. package/src/private/VariantComposer.ts +29 -0
  31. package/src/private/createComposer.tsx +16 -0
  32. package/src/private/useVariants.ts +7 -0
  33. package/src/styles/index.ts +2 -1
  34. package/src/styles/useVariantClassName.ts +16 -0
  35. package/src/testIds.ts +1 -0
@@ -3,7 +3,9 @@
3
3
 
4
4
  --webchat-colorNeutralForeground1: var(--colorNeutralForeground1, #242424);
5
5
  --webchat-colorNeutralForeground2: var(--colorNeutralForeground2, #424242);
6
+ --webchat-colorNeutralForeground3: var(--colorNeutralForeground3, #616161);
6
7
  --webchat-colorNeutralForeground4: var(--colorNeutralForeground4, #707070);
8
+ --webchat-colorNeutralForeground5: var(--colorNeutralForeground5, #7e7e7e);
7
9
 
8
10
  --webchat-colorNeutralForeground2BrandHover: var(--colorNeutralForeground2BrandHover, #02729c);
9
11
  --webchat-colorNeutralForeground2BrandPressed: var(--colorNeutralForeground2BrandPressed, #01678c);
@@ -12,14 +14,16 @@
12
14
  --webchat-colorNeutralForegroundDisabled: var(--colorNeutralForegroundDisabled, #bdbdbd);
13
15
 
14
16
  --webchat-colorNeutralBackground1: var(--colorNeutralBackground1, #ffffff);
17
+ --webchat-colorNeutralBackground3: var(--colorNeutralBackground3, #f5f5f5);
15
18
  --webchat-colorNeutralBackground4: var(--colorNeutralBackground4, #f0f0f0);
16
19
  --webchat-colorNeutralBackground5: var(--colorNeutralBackground5, #ebebeb);
17
20
 
21
+ --webchat-colorTransparentBackground: var(--colorTransparentBackground, rgba(0, 0, 0, 0.4));
22
+
18
23
  --webchat-colorNeutralBackground1Disabled: var(--colorNeutralBackground1Disabled, #f0f0f0);
24
+ --webchat-colorNeutralBackground1Hover: var(--colorNeutralBackground1Pressed, #f0f0f0);
19
25
  --webchat-colorNeutralBackground1Pressed: var(--colorNeutralBackground1Pressed, #e0e0e0);
20
26
 
21
- --webchat-colorNeutralGrey94: var(--colorNeutralGrey94, #f0f0f0);
22
-
23
27
  --webchat-colorNeutralStroke1: var(--colorNeutralStroke1, #d1d1d1);
24
28
  --webchat-colorNeutralStroke2: var(--colorNeutralStroke2, #e0e0e0);
25
29
  --webchat-colorNeutralStroke1Selected: var(--colorNeutralStroke1Selected, #bdbdbd);
@@ -27,15 +31,20 @@
27
31
  --webchat-colorStrokeFocus2: var(--colorStrokeFocus2, #000000);
28
32
 
29
33
  --webchat-colorBrandStroke2: var(--colorBrandStroke2, #9edcf7);
34
+ --webchat-colorTransparentStroke: var(--colorTransparentStroke, transparent);
35
+
36
+ --webchat-colorBrandForeground1: var(--colorBrandForeground1, #01678c);
30
37
 
31
38
  --webchat-colorBrandForeground2Hover: var(--colorBrandForeground2Hover, #015a7a);
32
39
  --webchat-colorBrandForeground2Pressed: var(--colorBrandForeground2Pressed, #01384d);
40
+ --webchat-colorBrandStroke2Pressed: var(--colorBrandStroke2Pressed, #01384d);
33
41
 
34
42
  --webchat-colorBrandForegroundLink: var(--colorBrandForegroundLink, #01678c);
35
43
  --webchat-colorBrandForegroundLinkHover: var(--colorBrandForegroundLinkHover, #015a7a);
36
44
  --webchat-colorBrandForegroundLinkPressed: var(--colorBrandForegroundLinkPressed, #014259);
37
45
  --webchat-colorBrandForegroundLinkSelected: var(--colorBrandForegroundLinkSelected, #01678c);
38
46
 
47
+ --webchat-colorBrandBackground2: var(--colorBrandBackground2, #def2fc);
39
48
  --webchat-colorBrandBackground2Hover: var(--colorBrandBackground2Hover, #bee7fa);
40
49
  --webchat-colorBrandBackground2Pressed: var(--colorBrandBackground2Pressed, #7fd2f5);
41
50
 
@@ -49,19 +58,35 @@
49
58
  --webchat-colorGray190: var(--colorGray190, #201f1e);
50
59
  --webchat-colorGray200: var(--colorGray200, #1b1a19);
51
60
 
52
- /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/borderRadius.ts */
53
- --webchat-borderRadiusSmall: var(--borderRadiusSmall, 2px);
54
- --webchat-borderRadiusLarge: var(--borderRadiusLarge, 6px);
55
- --webchat-borderRadiusXLarge: var(--borderRadiusXLarge, 8px);
56
-
57
61
  /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/utils/shadows.ts */
62
+ --webchat-shadow2: var(--shadow2, 0 0 2px rgba(0, 0, 0, 12%), 0 1px 2px rgba(0, 0, 0, 14%));
63
+ --webchat-shadow4: var(--shadow4, 0 0 2px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.14));
58
64
  --webchat-shadow16: var(--shadow16, 0 6.4px 14.4px 0 rgba(0, 0, 0, 0.132), 0 1.2px 3.6px 0 rgba(0, 0, 0, 0.108));
65
+ --webchat-shadow64: var(--shadow64, 0 0 8px rgba(0, 0, 0, 0.12), 0 32px 64px rgba(0, 0, 0, 0.14));
59
66
 
60
67
  /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/spacings.ts */
68
+ --webchat-spacingHorizontalNone: var(--spacingHorizontalNone, 0);
69
+ --webchat-spacingHorizontalXXS: var(--spacingHorizontalXXS, 2px);
70
+ --webchat-spacingHorizontalXS: var(--spacingHorizontalXS, 4px);
71
+ --webchat-spacingHorizontalSNudge: var(--spacingHorizontalSNudge, 6px);
72
+ --webchat-spacingHorizontalS: var(--spacingHorizontalS, 8px);
61
73
  --webchat-spacingHorizontalMNudge: var(--spacingHorizontalMNudge, 10px);
62
74
  --webchat-spacingHorizontalM: var(--spacingHorizontalM, 12px);
75
+ --webchat-spacingHorizontalL: var(--spacingHorizontalL, 16px);
76
+ --webchat-spacingHorizontalXL: var(--spacingHorizontalXL, 20px);
77
+ --webchat-spacingHorizontalXXL: var(--spacingHorizontalXXL, 24px);
63
78
  --webchat-spacingHorizontalXXXL: var(--spacingHorizontalXXXL, 32px);
79
+ --webchat-spacingVerticalNone: var(--spacingVerticalNone, 0);
80
+ --webchat-spacingVerticalXXS: var(--spacingVerticalXXS, 2px);
81
+ --webchat-spacingVerticalXS: var(--spacingVerticalXS, 4px);
82
+ --webchat-spacingVerticalSNudge: var(--spacingVerticalSNudge, 6px);
83
+ --webchat-spacingVerticalS: var(--spacingVerticalS, 8px);
84
+ --webchat-spacingVerticalMNudge: var(--spacingVerticalMNudge, 10px);
85
+ --webchat-spacingVerticalM: var(--spacingVerticalM, 12px);
64
86
  --webchat-spacingVerticalL: var(--spacingVerticalL, 16px);
87
+ --webchat-spacingVerticalXL: var(--spacingVerticalXL, 20px);
88
+ --webchat-spacingVerticalXXL: var(--spacingVerticalXXL, 24px);
89
+ --webchat-spacingVerticalXXXL: var(--spacingVerticalXXXL, 32px);
65
90
 
66
91
  /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/fonts.ts */
67
92
  --webchat-fontFamilyBase: var(--fontFamilyBase, 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif);
@@ -72,12 +97,35 @@
72
97
  --webchat-fontWeightSemibold: var(--fontWeightSemibold, 600);
73
98
 
74
99
  /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/fonts.ts */
100
+ --webchat-fontSizeBase100: var(--fontSizeBase100, 10px);
101
+ --webchat-fontSizeBase200: var(--fontSizeBase200, 12px);
75
102
  --webchat-fontSizeBase300: var(--fontSizeBase300, 14px);
103
+ --webchat-fontSizeBase400: var(--fontSizeBase400, 16px);
104
+ --webchat-fontSizeBase500: var(--fontSizeBase500, 20px);
105
+ --webchat-fontSizeBase600: var(--fontSizeBase600, 24px);
76
106
  --webchat-fontSizeHero700: var(--fontSizeHero700, 28px);
107
+ --webchat-fontSizeHero800: var(--fontSizeHero800, 32px);
108
+ --webchat-fontSizeHero900: var(--fontSizeHero900, 40px);
77
109
 
110
+ --webchat-lineHeightBase100: var(--lineHeightBase100, 14px);
111
+ --webchat-lineHeightBase200: var(--lineHeightBase200, 16px);
78
112
  --webchat-lineHeightBase300: var(--lineHeightBase300, 20px);
113
+ --webchat-lineHeightBase400: var(--lineHeightBase400, 22px);
114
+ --webchat-lineHeightBase500: var(--lineHeightBase500, 28px);
115
+ --webchat-lineHeightBase600: var(--lineHeightBase600, 32px);
79
116
  --webchat-lineHeightHero700: var(--lineHeightHero700, 36px);
117
+ --webchat-lineHeightHero800: var(--lineHeightHero800, 40px);
118
+ --webchat-lineHeightHero900: var(--lineHeightHero900, 52px);
119
+ --webchat-lineHeightHero1000: var(--lineHeightHero1000, 92px);
120
+
121
+ /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/borderRadius.ts */
122
+ --webchat-borderRadiusSmall: var(--borderRadiusSmall, 2px);
123
+ --webchat-borderRadiusMedium: var(--borderRadiusMedium, 4px);
124
+ --webchat-borderRadiusLarge: var(--borderRadiusLarge, 6px);
125
+ --webchat-borderRadiusXLarge: var(--borderRadiusXLarge, 8px);
80
126
 
127
+ --webchat-strokeWidthThin: var(--strokeWidthThin, 1px);
128
+ --webchat-strokeWidthThick: var(--strokeWidthThicker, 2px);
81
129
  --webchat-strokeWidthThicker: var(--strokeWidthThicker, 3px);
82
130
 
83
131
  --webchat-durationUltraFast: var(--durationUltraFast, 0);
@@ -85,9 +133,6 @@
85
133
 
86
134
  --webchat-curveAccelerateMid: var(--curveAccelerateMid, cubic-bezier(1,0,1,1));
87
135
  --webchat-curveDecelerateMid: var(--curveDecelerateMid, cubic-bezier(0,0,0,1));
88
-
89
- /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/utils/shadows.ts */
90
- --webchat-shadow2: 0 0 2px rgba(0, 0, 0, 12%), 0 1px 2px rgba(0, 0, 0, 14%);
91
136
  }
92
137
 
93
138
  @media (prefers-reduced-motion) {
@@ -96,3 +141,171 @@
96
141
  --webchat-durationNormal: 0.01ms;
97
142
  }
98
143
  }
144
+
145
+ /* Style Options override */
146
+ :global(.webchat-fluent).theme :global(.webchat__css-custom-properties) {
147
+ --webchat__color--accent: var(--webchat-colorBrandForeground1);
148
+ --webchat__color--subtle: var(--webchat-colorNeutralForeground2);
149
+ --webchat__color--timestamp: var(--webchat-colorNeutralForeground3);
150
+ --webchat__font--primary: var(--webchat-fontFamilyBase);
151
+ --webchat__font-size--small: var(--webchat-fontSizeBase200);
152
+ --webchat__font-size--medium: var(--webchat-fontSizeBase300);
153
+ --webchat__line-height--small: var(--webchat-lineHeightBase200);
154
+ --webchat__line-height--medium: var(--webchat-lineHeightBase300);
155
+ --webchat__max-width--bubble: var(--webchat-bubble-maxWidth);
156
+ --webchat__min-height--bubble: var(--webchat-bubble-minHeight);
157
+ --webchat__padding--regular: var(--webchat-spacingVerticalS);
158
+ --webchat__padding--sendbox:
159
+ var(--webchat-spacingVerticalNone)
160
+ var(--webchat-spacingHorizontalMNudge)
161
+ var(--webchat-spacingHorizontalMNudge);
162
+ }
163
+
164
+ :global(.webchat-fluent).theme.variant-copilot :global(.webchat__css-custom-properties) {
165
+ --webchat__padding--sendbox:
166
+ var(--webchat-spacingVerticalNone)
167
+ var(--webchat-spacingHorizontalXL)
168
+ var(--webchat-spacingVerticalMNudge)
169
+ var(--webchat-spacingHorizontalMNudge);
170
+ }
171
+
172
+ /* Transcript surface */
173
+ :global(.webchat-fluent).theme :global(.webchat__surface) {
174
+ background-color: var(--webchat__color--surface);
175
+ }
176
+
177
+ :global(.webchat-fluent).theme.variant-copilot :global(.webchat__surface) {
178
+ box-sizing: border-box;
179
+ padding-inline-start: var(--webchat-spacingHorizontalMNudge);
180
+ }
181
+
182
+ /* Transcript scrollable */
183
+ :global(.webchat-fluent).theme :global(.webchat__basic-transcript .webchat__basic-transcript__scrollable) {
184
+ /* Edge uses -webkit-scrollbar if scrollbar-* is not set */
185
+ scrollbar-color: unset;
186
+ scrollbar-width: unset;
187
+ /* Firefox */
188
+ -moz-scrollbar-color: var(--webchat-colorNeutralForeground5) transparent;
189
+ -moz-scrollbar-width: thin;
190
+
191
+ &::-webkit-scrollbar {
192
+ width: var(--webchat-spacingVerticalMNudge);
193
+ visibility: hidden;
194
+ }
195
+
196
+ &:hover::-webkit-scrollbar {
197
+ width: var(--webchat-spacingVerticalMNudge);
198
+ }
199
+
200
+ &:hover::-webkit-scrollbar-thumb {
201
+ background-clip: padding-box;
202
+ background-color: var(--webchat-colorNeutralForeground5);
203
+ border-radius: 10px;
204
+ border-right: 4px solid transparent;
205
+ border: 3px solid transparent;
206
+ }
207
+
208
+ &:hover::-webkit-scrollbar-thumb:hover {
209
+ background-clip: padding-box;
210
+ background-color: var(--webchat-colorNeutralForeground5);
211
+ border-radius: 10px;
212
+ border-right: 2px solid transparent;
213
+ border: 1px solid transparent;
214
+ }
215
+ }
216
+
217
+ :global(.webchat-fluent).theme.variant-copilot :global(.webchat__basic-transcript .webchat__basic-transcript__scrollable) {
218
+ scrollbar-gutter: stable;
219
+ }
220
+
221
+ /* Transcript focus indicator color when in focus-visible state */
222
+ :global(.webchat-fluent).theme :global(.webchat__basic-transcript .webchat__basic-transcript__terminator:focus-visible + .webchat__basic-transcript__focus-indicator) {
223
+ border-color: var(--webchat-colorStrokeFocus2);
224
+ }
225
+
226
+ /* Transcript Activity indicator without focus-visible state */
227
+ :global(.webchat-fluent).theme :global(.webchat__basic-transcript:not(:focus-visible) .webchat__basic-transcript__activity-indicator--focus) {
228
+ /* Hide activity focus when no focus-visible state */
229
+ display: none;
230
+ }
231
+
232
+ /* Transcript Focus indicator when activity focused */
233
+ :global(.webchat-fluent).theme :global(.webchat__basic-transcript:focus-visible:has(.webchat__basic-transcript__activity-indicator--focus)) {
234
+ :global(.webchat__basic-transcript__focus-indicator) {
235
+ /* Hide transcript focus when an activity is focused */
236
+ display: none;
237
+ }
238
+ }
239
+
240
+ /* Transcript focused activity */
241
+ :global(.webchat-fluent).theme :global(.webchat__basic-transcript:focus-visible .webchat__basic-transcript__activity:has(.webchat__basic-transcript__activity-indicator--focus)) {
242
+ :global(.webchat__basic-transcript__activity-indicator--focus) {
243
+ /* Hide transcript activity focus when the activity is focused */
244
+ display: none;
245
+ }
246
+
247
+ :global(.webchat__bubble)::after, :global(.pre-chat-message-activity)::after {
248
+ content: '';
249
+ position: absolute;
250
+ inset: -2px;
251
+ border: var(--webchat-strokeWidthThick) solid var(--webchat-colorStrokeFocus2);
252
+ border-radius: var(--webchat__bubble--border-radius);
253
+ pointer-events: none;
254
+ }
255
+
256
+ :global(.pre-chat-message-activity)::after {
257
+ inset: 0;
258
+ border-radius: var(--webchat-borderRadiusSmall);
259
+ }
260
+ }
261
+
262
+ /* Transcript with a single pre-chat activity */
263
+ :global(.webchat-fluent).theme :global(.webchat__basic-transcript:has(.webchat__basic-transcript__activity:only-child):has(.pre-chat-message-activity) .webchat__basic-transcript__filler) {
264
+ /* limit grow to half of the size to center the activity */
265
+ flex-grow: 0.5;
266
+ }
267
+
268
+ /* Modal */
269
+ :global(.webchat-fluent).theme :global(.webchat__modal-dialog) {
270
+ height: 100%;
271
+ display: grid;
272
+ place-items: center;
273
+
274
+ &::backdrop {
275
+ background-color: var(--webchat-colorTransparentBackground);
276
+ }
277
+
278
+ :global(.webchat__modal-dialog__box) {
279
+ background-color: var(--webchat-colorNeutralBackground1);
280
+ border-radius: var(--webchat-borderRadiusXLarge);
281
+ position: relative;
282
+ color: var(--webchat-colorNeutralForeground1);
283
+ box-shadow: var(--webchat-shadow64);
284
+ }
285
+
286
+ :global(.webchat__modal-dialog__close-button) {
287
+ color: var(--webchat-colorNeutralForeground1);
288
+ transition: background-color var(--webchat-durationNormal) var(--webchat-curveDecelerateMid);
289
+ }
290
+
291
+ /* TODO: align with original fluent modal styles in WebChat as they don't match v9 anymore */
292
+ :global(.webchat__modal-dialog__close-button):focus:not(:active):hover {
293
+ background-color: var(--webchat-colorNeutralBackground3);
294
+ }
295
+
296
+ :global(.webchat__modal-dialog__close-button):focus:active {
297
+ background-color: var(--webchat-colorNeutralBackground4);
298
+ }
299
+
300
+ :global(.webchat__modal-dialog__close-button):not(:focus-visible) {
301
+ border: none;
302
+ }
303
+
304
+ :global(.webchat__modal-dialog__close-button):focus {
305
+ border-color: var(--webchat-colorStrokeFocus2);
306
+ }
307
+
308
+ :global(.webchat__modal-dialog__close-button-image) {
309
+ fill: currentColor;
310
+ }
311
+ }
@@ -1,11 +1,12 @@
1
1
  import React, { type ReactNode } from 'react';
2
2
  import cx from 'classnames';
3
3
  import styles from './Theme.module.css';
4
- import { useStyles } from '../../styles';
4
+ import { useStyles, useVariantClassName } from '../../styles';
5
5
 
6
6
  export const rootClassName = 'webchat-fluent';
7
7
 
8
8
  export default function Theme(props: Readonly<{ readonly children: ReactNode | undefined }>) {
9
9
  const classNames = useStyles(styles);
10
- return <div className={cx(rootClassName, classNames['theme'])}>{props.children}</div>;
10
+ const variantClassName = useVariantClassName(styles);
11
+ return <div className={cx(rootClassName, classNames['theme'], variantClassName)}>{props.children}</div>;
11
12
  }
@@ -1,15 +1,17 @@
1
+ import type { ActivityMiddleware } from 'botframework-webchat-api';
1
2
  import { Components } from 'botframework-webchat-component';
2
3
  import React, { memo, type ReactNode } from 'react';
3
4
 
4
- import type { ActivityMiddleware } from 'botframework-webchat-api';
5
+ import { ActivityDecorator } from '../components/activity';
5
6
  import { isPreChatMessageActivity, PreChatMessageActivity } from '../components/preChatActivity';
6
- import { SendBox } from '../components/sendBox';
7
+ import { PrimarySendBox } from '../components/sendBox';
7
8
  import { TelephoneKeypadProvider } from '../components/telephoneKeypad';
8
9
  import { WebChatTheme } from '../components/theme';
10
+ import VariantComposer, { VariantList } from './VariantComposer';
9
11
 
10
12
  const { ThemeProvider } = Components;
11
13
 
12
- type Props = Readonly<{ children?: ReactNode | undefined }>;
14
+ type Props = Readonly<{ children?: ReactNode | undefined; variant?: VariantList | undefined }>;
13
15
 
14
16
  const activityMiddleware: ActivityMiddleware[] = [
15
17
  () =>
@@ -21,19 +23,26 @@ const activityMiddleware: ActivityMiddleware[] = [
21
23
  return () => <PreChatMessageActivity activity={activity} />;
22
24
  }
23
25
 
24
- return next(...args);
26
+ const renderActivity = next(...args);
27
+
28
+ return renderActivity
29
+ ? (...args) => <ActivityDecorator activity={activity}>{renderActivity(...args)}</ActivityDecorator>
30
+ : renderActivity;
25
31
  }
26
32
  ];
27
- const sendBoxMiddleware = [() => () => () => SendBox];
28
-
29
- const FluentThemeProvider = ({ children }: Props) => (
30
- <WebChatTheme>
31
- <TelephoneKeypadProvider>
32
- <ThemeProvider activityMiddleware={activityMiddleware} sendBoxMiddleware={sendBoxMiddleware}>
33
- {children}
34
- </ThemeProvider>
35
- </TelephoneKeypadProvider>
36
- </WebChatTheme>
33
+
34
+ const sendBoxMiddleware = [() => () => () => PrimarySendBox];
35
+
36
+ const FluentThemeProvider = ({ children, variant = 'fluent' }: Props) => (
37
+ <VariantComposer variant={variant}>
38
+ <WebChatTheme>
39
+ <TelephoneKeypadProvider>
40
+ <ThemeProvider activityMiddleware={activityMiddleware} sendBoxMiddleware={sendBoxMiddleware}>
41
+ {children}
42
+ </ThemeProvider>
43
+ </TelephoneKeypadProvider>
44
+ </WebChatTheme>
45
+ </VariantComposer>
37
46
  );
38
47
 
39
48
  export default memo(FluentThemeProvider);
@@ -0,0 +1,29 @@
1
+ import { createContext } from 'react';
2
+
3
+ import createComposer from './createComposer';
4
+
5
+ type VariantName = 'fluent' | 'copilot' | '';
6
+
7
+ export type VariantList = `${VariantName}`;
8
+
9
+ export type VariantContextType = {
10
+ variant: VariantList;
11
+ };
12
+
13
+ export const VariantContext = createContext<VariantContextType>(
14
+ new Proxy(
15
+ {},
16
+ {
17
+ get() {
18
+ throw new Error('Unable to use VariantContext without VariantComposer');
19
+ }
20
+ }
21
+ ) as unknown as VariantContextType
22
+ );
23
+
24
+ const VariantComposer = createComposer<VariantContextType>(VariantContext, {
25
+ defaults: { variant: '' },
26
+ displayName: 'VariantComposer'
27
+ });
28
+
29
+ export default VariantComposer;
@@ -0,0 +1,16 @@
1
+ import React, { type Context, memo, type ReactNode, useMemo } from 'react';
2
+
3
+ export default function createComposer<
4
+ C,
5
+ P extends { children?: ReactNode | undefined } = Partial<C> & { children?: ReactNode | undefined }
6
+ >({ Provider }: Context<C>, { defaults, displayName }: Readonly<{ defaults: Readonly<C>; displayName: string }>) {
7
+ const Composer = ({ children, ...props }: Readonly<P>) => {
8
+ const value = useMemo(() => Object.freeze({ ...defaults, ...props }), [props]);
9
+
10
+ return <Provider value={value}>{children}</Provider>;
11
+ };
12
+
13
+ Composer.displayName = displayName;
14
+
15
+ return memo(Composer);
16
+ }
@@ -0,0 +1,7 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import { VariantContext } from './VariantComposer';
3
+
4
+ export default function useVariants() {
5
+ const { variant } = useContext(VariantContext);
6
+ return useMemo(() => variant.split(' '), [variant]);
7
+ }
@@ -1,4 +1,5 @@
1
1
  import injectStyle from './injectStyle';
2
2
  import useStyles from './useStyles';
3
+ import useVariantClassName from './useVariantClassName';
3
4
 
4
- export { injectStyle, useStyles };
5
+ export { injectStyle, useStyles, useVariantClassName };
@@ -0,0 +1,16 @@
1
+ import { useMemo } from 'react';
2
+ import useVariants from '../private/useVariants';
3
+ import useStyles from './useStyles';
4
+
5
+ export default function useVariantClassName<T extends CSSModuleClasses>(styles: T): string {
6
+ const classNames = useStyles(styles);
7
+ const variants = useVariants();
8
+ return useMemo(
9
+ () =>
10
+ variants
11
+ .map(variant => classNames[`variant-${variant}`])
12
+ .filter(value => value)
13
+ .join(' '),
14
+ [classNames, variants]
15
+ );
16
+ }
package/src/testIds.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  const testIds = {
2
+ preChatMessageActivityStarterPromptsCardAction: 'pre-chat message activity starter prompts card action',
2
3
  sendBoxDropZone: 'send box drop zone',
3
4
  sendBoxSendButton: 'send box send button',
4
5
  sendBoxTextBox: 'send box text area',