botframework-webchat-fluent-theme 4.18.1-main.20240813.c50aac5 → 4.18.1-main.20240823.c5330cc

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botframework-webchat-fluent-theme",
3
- "version": "4.18.1-main.20240813.c50aac5",
3
+ "version": "4.18.1-main.20240823.c5330cc",
4
4
  "description": "Fluent theme for Bot Framework Web Chat",
5
5
  "main": "./dist/botframework-webchat-fluent-theme.js",
6
6
  "types": "./dist/botframework-webchat-fluent-theme.d.ts",
@@ -69,9 +69,9 @@
69
69
  "typescript": "^5.4.5"
70
70
  },
71
71
  "dependencies": {
72
- "botframework-webchat-api": "4.18.1-main.20240813.c50aac5",
73
- "botframework-webchat-component": "4.18.1-main.20240813.c50aac5",
74
- "botframework-webchat-core": "4.18.1-main.20240813.c50aac5",
72
+ "botframework-webchat-api": "4.18.1-main.20240823.c5330cc",
73
+ "botframework-webchat-component": "4.18.1-main.20240823.c5330cc",
74
+ "botframework-webchat-core": "4.18.1-main.20240823.c5330cc",
75
75
  "classnames": "2.5.1",
76
76
  "inject-meta-tag": "0.0.1",
77
77
  "math-random": "2.0.1",
@@ -1,6 +1,7 @@
1
1
 
2
2
  :global(.webchat-fluent) .activity-decorator {
3
3
  display: contents;
4
+ font-family: var(--webchat__font--primary);
4
5
 
5
6
  --webchat__bubble--inline-padding: var(--webchat-spacingHorizontalL);
6
7
  --webchat__bubble--block-padding: var(--webchat-spacingVerticalM);
@@ -10,8 +10,12 @@ import Loader from './Loader';
10
10
  export const rootClassName = 'webchat-fluent-decorator';
11
11
 
12
12
  const middleware: DecoratorMiddleware[] = [
13
- init => init === 'activity border' && (next => request => (request.state === 'completion' ? Flair : next(request))),
14
- init => init === 'activity border' && (next => request => (request.state === 'informative' ? Loader : next(request)))
13
+ init =>
14
+ init === 'activity border' &&
15
+ (next => request => (request.livestreamingState === 'completing' ? Flair : next(request))),
16
+ init =>
17
+ init === 'activity border' &&
18
+ (next => request => (request.livestreamingState === 'preparing' ? Loader : next(request)))
15
19
  ];
16
20
 
17
21
  function WebChatDecorator(props: Readonly<{ readonly children?: ReactNode | undefined }>) {
@@ -8,30 +8,35 @@
8
8
  cursor: pointer;
9
9
  display: grid;
10
10
  gap: 8px;
11
- grid-template-areas: 'image title' 'image subtitle';
12
- grid-template-columns: 20px 1fr;
11
+ grid-template-areas: 'title' 'subtitle';
12
+ grid-template-columns: 1fr;
13
13
  grid-template-rows: auto 1fr;
14
14
  overflow: hidden;
15
15
  padding: 16px 20px;
16
16
  text-align: left;
17
17
  user-select: none;
18
- }
19
18
 
20
- :global(.webchat-fluent) .pre-chat-message-activity__card-action-box:disabled {
21
- background-color: var(--webchat-colorNeutralBackground1Disabled);
22
- }
19
+ &:has(.pre-chat-message-activity__card-action-image) {
20
+ grid-template-areas: 'image title' 'image subtitle';
21
+ grid-template-columns: 20px 1fr;
22
+ }
23
23
 
24
- :global(.webchat-fluent) .pre-chat-message-activity__card-action-box:hover {
25
- background-color: var(--webchat-colorNeutralBackground1Hover);
26
- }
24
+ &:disabled {
25
+ background-color: var(--webchat-colorNeutralBackgroundDisabled);
26
+ }
27
27
 
28
- :global(.webchat-fluent) .pre-chat-message-activity__card-action-box:active {
29
- background-color: var(--webchat-colorNeutralBackground1Pressed);
30
- }
28
+ &:hover {
29
+ background-color: var(--webchat-colorNeutralBackground1Hover);
30
+ }
31
+
32
+ &:active {
33
+ background-color: var(--webchat-colorNeutralBackground1Pressed);
34
+ }
31
35
 
32
- :global(.webchat-fluent) .pre-chat-message-activity__card-action-box:focus-visible {
33
- outline: solid 2px var(--webchat-colorStrokeFocus2);
34
- outline-offset: -2px;
36
+ &:focus-visible {
37
+ outline: solid 2px var(--webchat-colorStrokeFocus2);
38
+ outline-offset: -2px;
39
+ }
35
40
  }
36
41
 
37
42
  :global(.webchat-fluent) .pre-chat-message-activity__card-action-image {
@@ -1,14 +1,14 @@
1
- import { hooks } from 'botframework-webchat-component';
1
+ import { Components, hooks } from 'botframework-webchat-component';
2
2
  import { type DirectLineCardAction } from 'botframework-webchat-core';
3
3
  import cx from 'classnames';
4
4
  import React, { memo, useCallback, useMemo } from 'react';
5
5
  import { useRefFrom } from 'use-ref-from';
6
6
  import { useStyles } from '../../styles/index.js';
7
7
  import testIds from '../../testIds.js';
8
- import MonochromeImageMasker from './private/MonochromeImageMasker.js';
9
8
  import styles from './StarterPromptsCardAction.module.css';
10
9
 
11
10
  const { useFocus, useRenderMarkdownAsHTML, useSendBoxValue } = hooks;
11
+ const { MonochromeImageMasker } = Components;
12
12
 
13
13
  type Props = Readonly<{
14
14
  className?: string | undefined;
@@ -1,26 +1,7 @@
1
- import type { WebChatActivity } from 'botframework-webchat-core';
2
- import { array, literal, object, safeParse, string, type InferOutput } from 'valibot';
3
-
4
- const messageEntity = object({
5
- '@context': literal('https://schema.org'),
6
- '@id': literal(''), // Must be empty string.
7
- '@type': literal('Message'),
8
- keywords: array(string()),
9
- type: literal('https://schema.org/Message')
10
- });
11
-
12
- type MessageEntity = InferOutput<typeof messageEntity>;
1
+ import { getOrgSchemaMessage, type WebChatActivity } from 'botframework-webchat-core';
13
2
 
14
3
  export default function isPreChatMessageActivity(
15
4
  activity: undefined | WebChatActivity
16
5
  ): activity is WebChatActivity & { type: 'message' } {
17
- if (activity?.type !== 'message') {
18
- return false;
19
- }
20
-
21
- const message = activity.entities?.find(
22
- (entity): entity is MessageEntity => safeParse(messageEntity, entity).success
23
- );
24
-
25
- return !!message?.keywords.includes('PreChatMessage');
6
+ return !!(activity && getOrgSchemaMessage(activity?.entities || [])?.keywords?.includes('PreChatMessage'));
26
7
  }
@@ -1,43 +1,45 @@
1
1
  :global(.webchat-fluent).theme {
2
2
  display: contents;
3
3
 
4
+ --webchat-colorNeutralForegroundDisabled: var(--colorNeutralForegroundDisabled, #bdbdbd);
4
5
  --webchat-colorNeutralForeground1: var(--colorNeutralForeground1, #242424);
6
+ --webchat-colorNeutralForeground1Hover: var(--colorNeutralForeground1Hover, #242424);
7
+ --webchat-colorNeutralForeground1Pressed: var(--colorNeutralForeground1Pressed, #242424);
5
8
  --webchat-colorNeutralForeground2: var(--colorNeutralForeground2, #424242);
6
- --webchat-colorNeutralForeground3: var(--colorNeutralForeground3, #616161);
7
- --webchat-colorNeutralForeground4: var(--colorNeutralForeground4, #707070);
8
- --webchat-colorNeutralForeground5: var(--colorNeutralForeground5, #7e7e7e);
9
-
10
9
  --webchat-colorNeutralForeground2BrandHover: var(--colorNeutralForeground2BrandHover, #02729c);
11
10
  --webchat-colorNeutralForeground2BrandPressed: var(--colorNeutralForeground2BrandPressed, #01678c);
12
11
  --webchat-colorNeutralForeground2BrandSelected: var(--colorNeutralForeground2BrandSelected, #067191);
12
+ --webchat-colorNeutralForeground3: var(--colorNeutralForeground3, #616161);
13
+ --webchat-colorNeutralForeground4: var(--colorNeutralForeground4, #707070);
14
+ --webchat-colorNeutralForeground5: var(--colorNeutralForeground5, #7e7e7e);
13
15
 
14
- --webchat-colorNeutralForegroundDisabled: var(--colorNeutralForegroundDisabled, #bdbdbd);
15
-
16
+ --webchat-colorNeutralBackgroundDisabled: var(--colorNeutralBackgroundDisabled, #f0f0f0);
16
17
  --webchat-colorNeutralBackground1: var(--colorNeutralBackground1, #ffffff);
18
+ --webchat-colorNeutralBackground1Hover: var(--colorNeutralBackground1Hover, #f5f5f5);
19
+ --webchat-colorNeutralBackground1Pressed: var(--colorNeutralBackground1Pressed, #e0e0e0);
17
20
  --webchat-colorNeutralBackground3: var(--colorNeutralBackground3, #f5f5f5);
18
21
  --webchat-colorNeutralBackground4: var(--colorNeutralBackground4, #f0f0f0);
19
22
  --webchat-colorNeutralBackground5: var(--colorNeutralBackground5, #ebebeb);
20
23
 
21
24
  --webchat-colorTransparentBackground: var(--colorTransparentBackground, rgba(0, 0, 0, 0.4));
22
25
 
23
- --webchat-colorNeutralBackground1Disabled: var(--colorNeutralBackground1Disabled, #f0f0f0);
24
- --webchat-colorNeutralBackground1Hover: var(--colorNeutralBackground1Pressed, #f0f0f0);
25
- --webchat-colorNeutralBackground1Pressed: var(--colorNeutralBackground1Pressed, #e0e0e0);
26
-
26
+ --webchat-colorNeutralStrokeDisabled: var(--colorNeutralStrokeDisabled, #e0e0e0);
27
27
  --webchat-colorNeutralStroke1: var(--colorNeutralStroke1, #d1d1d1);
28
- --webchat-colorNeutralStroke2: var(--colorNeutralStroke2, #e0e0e0);
28
+ --webchat-colorNeutralStroke1Hover: var(--colorNeutralStroke1Hover, #c7c7c7);
29
+ --webchat-colorNeutralStroke1Pressed: var(--colorNeutralStroke1Pressed, #b3b3b3);
29
30
  --webchat-colorNeutralStroke1Selected: var(--colorNeutralStroke1Selected, #bdbdbd);
31
+ --webchat-colorNeutralStroke2: var(--colorNeutralStroke2, #e0e0e0);
30
32
 
31
33
  --webchat-colorStrokeFocus2: var(--colorStrokeFocus2, #000000);
32
34
 
33
35
  --webchat-colorBrandStroke2: var(--colorBrandStroke2, #9edcf7);
36
+ --webchat-colorBrandStroke2Pressed: var(--colorBrandStroke2Pressed, #01384d);
37
+
34
38
  --webchat-colorTransparentStroke: var(--colorTransparentStroke, transparent);
35
39
 
36
40
  --webchat-colorBrandForeground1: var(--colorBrandForeground1, #01678c);
37
-
38
41
  --webchat-colorBrandForeground2Hover: var(--colorBrandForeground2Hover, #015a7a);
39
42
  --webchat-colorBrandForeground2Pressed: var(--colorBrandForeground2Pressed, #01384d);
40
- --webchat-colorBrandStroke2Pressed: var(--colorBrandStroke2Pressed, #01384d);
41
43
 
42
44
  --webchat-colorBrandForegroundLink: var(--colorBrandForegroundLink, #01678c);
43
45
  --webchat-colorBrandForegroundLinkHover: var(--colorBrandForegroundLinkHover, #015a7a);
@@ -76,6 +78,8 @@
76
78
  --webchat-spacingHorizontalXL: var(--spacingHorizontalXL, 20px);
77
79
  --webchat-spacingHorizontalXXL: var(--spacingHorizontalXXL, 24px);
78
80
  --webchat-spacingHorizontalXXXL: var(--spacingHorizontalXXXL, 32px);
81
+
82
+ /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/spacings.ts */
79
83
  --webchat-spacingVerticalNone: var(--spacingVerticalNone, 0);
80
84
  --webchat-spacingVerticalXXS: var(--spacingVerticalXXS, 2px);
81
85
  --webchat-spacingVerticalXS: var(--spacingVerticalXS, 4px);
@@ -124,13 +128,17 @@
124
128
  --webchat-borderRadiusLarge: var(--borderRadiusLarge, 6px);
125
129
  --webchat-borderRadiusXLarge: var(--borderRadiusXLarge, 8px);
126
130
 
131
+ /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/strokeWidths.ts */
127
132
  --webchat-strokeWidthThin: var(--strokeWidthThin, 1px);
128
133
  --webchat-strokeWidthThick: var(--strokeWidthThicker, 2px);
129
134
  --webchat-strokeWidthThicker: var(--strokeWidthThicker, 3px);
130
135
 
136
+ /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/durations.ts */
131
137
  --webchat-durationUltraFast: var(--durationUltraFast, 0);
132
138
  --webchat-durationNormal: var(--durationNormal, 200ms);
139
+ --webchat-durationUltraSlow: var(--durationUltraSlow, 500ms);
133
140
 
141
+ /* https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/curves.ts */
134
142
  --webchat-curveAccelerateMid: var(--curveAccelerateMid, cubic-bezier(1,0,1,1));
135
143
  --webchat-curveDecelerateMid: var(--curveDecelerateMid, cubic-bezier(0,0,0,1));
136
144
  }
@@ -309,3 +317,58 @@
309
317
  fill: currentColor;
310
318
  }
311
319
  }
320
+
321
+ /* Activity button */
322
+ :global(.webchat-fluent).theme :global(.webchat__activity-button) {
323
+ background: var(--webchat-colorNeutralBackground1);
324
+ border-radius: var(--webchat-borderRadiusMedium);
325
+ border: var(--webchat-strokeWidthThin) solid var(--webchat-colorNeutralStroke1);
326
+ color: var(--webchat-colorNeutralForeground1);
327
+ gap: var(--webchat-spacingHorizontalXS);
328
+ padding: 5px var(--webchat-spacingHorizontalM);
329
+
330
+ &:hover {
331
+ background: var(--webchat-colorNeutralBackground1Hover);
332
+ border: var(--webchat-strokeWidthThin) solid var(--webchat-colorNeutralStroke1Hover);
333
+ color: var(--webchat-colorNeutralForeground1Hover);
334
+ }
335
+
336
+ &:active {
337
+ background: var(--webchat-colorNeutralBackground1Pressed);
338
+ border: var(--webchat-strokeWidthThin) solid var(--webchat-colorNeutralStroke1Pressed);
339
+ color: var(--webchat-colorNeutralForeground1Pressed);
340
+ }
341
+
342
+ &:focus-visible {
343
+ background: var(--webchat-colorNeutralBackground1);
344
+ outline: var(--webchat-strokeWidthThick) solid var(--webchat-colorStrokeFocus2);
345
+ outline-offset: calc(var(--webchat-strokeWidthThick) * -1);
346
+ }
347
+
348
+ &:disabled {
349
+ background: var(--webchat-colorNeutralBackgroundDisabled);
350
+ border: var(--webchat-strokeWidthThin) solid var(--webchat-colorNeutralStrokeDisabled);
351
+ color: var(--webchat-colorNeutralForegroundDisabled);
352
+ }
353
+
354
+ :global(.webchat__activity-button__icon) {
355
+ height: 20px;
356
+ width: 20px;
357
+ }
358
+ }
359
+
360
+ /* Copy button */
361
+ :global(.webchat-fluent).theme :global(.webchat__activity-copy-button) {
362
+ :global(.webchat__activity-copy-button__copied-text) {
363
+ background-color: var(--webchat-colorNeutralBackground1);
364
+ }
365
+
366
+ &:global(.webchat__activity-copy-button--copied) :global(.webchat__activity-copy-button__copied-text) {
367
+ animation-duration: var(--webchat-durationUltraSlow);
368
+ }
369
+ }
370
+
371
+ /* Monochrome image masker */
372
+ :global(.webchat-fluent).theme :global(.webchat__monochrome-image-masker) {
373
+ background-color: var(--webchat-colorNeutralForeground4);
374
+ }
@@ -13,7 +13,7 @@ const { ThemeProvider } = Components;
13
13
 
14
14
  type Props = Readonly<{ children?: ReactNode | undefined; variant?: VariantList | undefined }>;
15
15
 
16
- const activityMiddleware: ActivityMiddleware[] = [
16
+ const activityMiddleware: readonly ActivityMiddleware[] = Object.freeze([
17
17
  () =>
18
18
  next =>
19
19
  (...args) => {
@@ -29,7 +29,7 @@ const activityMiddleware: ActivityMiddleware[] = [
29
29
  ? (...args) => <ActivityDecorator activity={activity}>{renderActivity(...args)}</ActivityDecorator>
30
30
  : renderActivity;
31
31
  }
32
- ];
32
+ ]);
33
33
 
34
34
  const sendBoxMiddleware = [() => () => () => PrimarySendBox];
35
35
 
@@ -1,7 +0,0 @@
1
- :global(.webchat-fluent) .pre-chat-message-activity__monochrome-image-masker {
2
- background-color: var(--webchat-colorNeutralForeground4);
3
- -webkit-mask-image: var(--mask-image);
4
- mask-image: var(--mask-image);
5
- -webkit-mask-repeat: no-repeat;
6
- mask-repeat: no-repeat;
7
- }
@@ -1,19 +0,0 @@
1
- import cx from 'classnames';
2
- import React, { memo, useMemo, type CSSProperties } from 'react';
3
- import { useStyles } from '../../../styles/index.js';
4
- import styles from './MonochromeImageMasker.module.css';
5
-
6
- type Props = Readonly<{ className?: string | undefined; src: string }>;
7
-
8
- const MonochromeImageMasker = ({ className, src }: Props) => {
9
- const classNames = useStyles(styles);
10
- const style = useMemo(() => ({ '--mask-image': `url(${src})` }) as CSSProperties, [src]);
11
-
12
- return (
13
- <div className={cx(className, classNames['pre-chat-message-activity__monochrome-image-masker'])} style={style} />
14
- );
15
- };
16
-
17
- MonochromeImageMasker.displayName = 'MonochromeImageMasker';
18
-
19
- export default memo(MonochromeImageMasker);