botframework-webchat-fluent-theme 4.17.0-main.20240416.e3f5401 → 4.17.0-main.20240423.d9e4f4d
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/dist/botframework-webchat-fluent-theme.development.css.map +1 -0
- package/dist/botframework-webchat-fluent-theme.development.js +418 -2085
- package/dist/botframework-webchat-fluent-theme.development.js.map +1 -1
- package/dist/botframework-webchat-fluent-theme.production.min.css.map +1 -0
- package/dist/botframework-webchat-fluent-theme.production.min.js +1 -3
- package/dist/botframework-webchat-fluent-theme.production.min.js.map +1 -1
- package/dist/index.css.map +1 -0
- package/dist/index.js +285 -545
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +335 -595
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -5
- package/src/components/Theme.module.css +80 -0
- package/src/components/Theme.tsx +4 -65
- package/src/components/dropZone/index.module.css +23 -0
- package/src/components/dropZone/index.tsx +6 -31
- package/src/components/sendbox/AddAttachmentButton.module.css +10 -0
- package/src/components/sendbox/AddAttachmentButton.tsx +5 -17
- package/src/components/sendbox/Attachments.module.css +7 -0
- package/src/components/sendbox/Attachments.tsx +7 -13
- package/src/components/sendbox/ErrorMessage.module.css +9 -0
- package/src/components/sendbox/ErrorMessage.tsx +2 -13
- package/src/components/sendbox/TelephoneKeypadToolbarButton.tsx +3 -2
- package/src/components/sendbox/TextArea.module.css +63 -0
- package/src/components/sendbox/TextArea.tsx +9 -70
- package/src/components/sendbox/Toolbar.module.css +51 -0
- package/src/components/sendbox/Toolbar.tsx +7 -55
- package/src/components/sendbox/index.module.css +101 -0
- package/src/components/sendbox/index.tsx +18 -77
- package/src/components/suggestedActions/SuggestedAction.module.css +35 -0
- package/src/components/suggestedActions/SuggestedAction.tsx +3 -43
- package/src/components/suggestedActions/index.module.css +23 -0
- package/src/components/suggestedActions/index.tsx +6 -29
- package/src/components/telephoneKeypad/private/Button.module.css +62 -0
- package/src/components/telephoneKeypad/private/Button.tsx +5 -67
- package/src/components/telephoneKeypad/private/TelephoneKeypad.module.css +59 -0
- package/src/components/telephoneKeypad/private/TelephoneKeypad.tsx +17 -35
- package/src/env.d.ts +7 -0
- package/src/icons/AddDocumentIcon.tsx +0 -1
- package/src/icons/AttachmentIcon.tsx +0 -1
- package/src/icons/InfoSmallIcon.tsx +17 -0
- package/src/icons/SendIcon.tsx +0 -1
- package/src/icons/TelephoneKeypad.tsx +0 -1
- package/src/index.ts +3 -0
- package/src/styles/injectStyle.ts +9 -0
- package/src/styles/useStyles.ts +19 -0
- package/src/styles.ts +4 -0
- package/src/tsconfig.json +2 -1
- package/src/private/useStyleToEmotionObject.ts +0 -32
- package/src/styles/index.ts +0 -15
|
@@ -1,47 +1,22 @@
|
|
|
1
1
|
import React, { KeyboardEventHandler, memo, useCallback, useEffect, useRef, type ReactNode } from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
2
3
|
import { useRefFrom } from 'use-ref-from';
|
|
4
|
+
import { Components } from 'botframework-webchat-component';
|
|
3
5
|
|
|
4
|
-
import { useStyles } from '../../../styles';
|
|
5
6
|
import Button from './Button';
|
|
6
7
|
// import HorizontalDialPadController from './HorizontalDialPadController';
|
|
7
8
|
import testIds from '../../../testIds';
|
|
8
9
|
import { type DTMF } from '../types';
|
|
9
10
|
import useShown from '../useShown';
|
|
11
|
+
import styles from './TelephoneKeypad.module.css';
|
|
12
|
+
import { useStyles } from '../../../styles';
|
|
13
|
+
import InfoSmallIcon from '../../../icons/InfoSmallIcon';
|
|
10
14
|
|
|
11
|
-
const
|
|
12
|
-
'webchat__telephone-keypad': {
|
|
13
|
-
/* Commented out whitelabel styles for now. */
|
|
14
|
-
// background: getHighContrastDarkThemeColor(highContrastColor: black, darkThemeColor: gray190, string, defaultColor: gray10),
|
|
15
|
-
// borderRadius: '8px 8px 0px 0px',
|
|
16
|
-
// boxShadow: '-3px 0px 7px 0px rgba(0, 0, 0, 0.13), -0.6px 0px 1.8px 0px rgba(0, 0, 0, 0.10)',
|
|
17
|
-
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
background: 'var(--webchat-colorNeutralBackground1)',
|
|
20
|
-
// border: isHighContrastTheme() ? `1px solid ${white}` : 'none',
|
|
21
|
-
border: 'none',
|
|
22
|
-
borderRadius: 'var(--webchat-borderRadiusXLarge)',
|
|
23
|
-
// boxShadow: 'var(--shadow16)',
|
|
24
|
-
display: 'flex',
|
|
25
|
-
flexDirection: 'column',
|
|
26
|
-
fontFamily: 'var(--webchat-fontFamilyBase)',
|
|
27
|
-
justifyContent: 'center'
|
|
28
|
-
// margin: 'var(--spacingHorizontalMNudge)'
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
'webchat__telephone-keypad__box': {
|
|
32
|
-
boxSizing: 'border-box',
|
|
33
|
-
display: 'grid',
|
|
34
|
-
gap: '16px',
|
|
35
|
-
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
36
|
-
gridTemplateRows: 'repeat(4, 1fr)',
|
|
37
|
-
justifyItems: 'center',
|
|
38
|
-
padding: '16px',
|
|
39
|
-
width: '100%'
|
|
40
|
-
}
|
|
41
|
-
};
|
|
15
|
+
const { LocalizedString } = Components;
|
|
42
16
|
|
|
43
17
|
type Props = Readonly<{
|
|
44
18
|
autoFocus?: boolean | undefined;
|
|
19
|
+
className?: string | undefined;
|
|
45
20
|
isHorizontal: boolean;
|
|
46
21
|
onButtonClick: (button: DTMF) => void;
|
|
47
22
|
}>;
|
|
@@ -54,14 +29,14 @@ const Orientation = memo(
|
|
|
54
29
|
// <HorizontalDialPadController>{children}</HorizontalDialPadController>
|
|
55
30
|
false
|
|
56
31
|
) : (
|
|
57
|
-
<div className={classNames['
|
|
32
|
+
<div className={classNames['telephone-keypad__box']}>{children}</div>
|
|
58
33
|
);
|
|
59
34
|
}
|
|
60
35
|
);
|
|
61
36
|
|
|
62
37
|
Orientation.displayName = 'TelephoneKeypad:Orientation';
|
|
63
38
|
|
|
64
|
-
const TelephoneKeypad = memo(({ autoFocus, onButtonClick, isHorizontal }: Props) => {
|
|
39
|
+
const TelephoneKeypad = memo(({ autoFocus, className, onButtonClick, isHorizontal }: Props) => {
|
|
65
40
|
const autoFocusRef = useRefFrom(autoFocus);
|
|
66
41
|
const classNames = useStyles(styles);
|
|
67
42
|
const firstButtonRef = useRef<HTMLButtonElement>(null);
|
|
@@ -95,7 +70,7 @@ const TelephoneKeypad = memo(({ autoFocus, onButtonClick, isHorizontal }: Props)
|
|
|
95
70
|
}, [autoFocusRef, firstButtonRef]);
|
|
96
71
|
|
|
97
72
|
return (
|
|
98
|
-
<div className={classNames['
|
|
73
|
+
<div className={cx(classNames['telephone-keypad'], className)} onKeyDown={handleKeyDown}>
|
|
99
74
|
<Orientation isHorizontal={isHorizontal}>
|
|
100
75
|
<Button
|
|
101
76
|
button="1"
|
|
@@ -159,6 +134,13 @@ const TelephoneKeypad = memo(({ autoFocus, onButtonClick, isHorizontal }: Props)
|
|
|
159
134
|
onClick={handleButtonPoundClick}
|
|
160
135
|
/>
|
|
161
136
|
</Orientation>
|
|
137
|
+
<div className={classNames['telephone-keypad__info-message']}>
|
|
138
|
+
<InfoSmallIcon />
|
|
139
|
+
<LocalizedString
|
|
140
|
+
linkClassName={classNames['telephone-keypad__info-message-link']}
|
|
141
|
+
stringIds="TELEPHONE_KEYPAD_INPUT_MESSAGE"
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
162
144
|
</div>
|
|
163
145
|
);
|
|
164
146
|
});
|
package/src/env.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
|
|
3
|
+
export default memo((props: Readonly<{ readonly className?: string }>) => (
|
|
4
|
+
<svg
|
|
5
|
+
aria-hidden="true"
|
|
6
|
+
className={props.className}
|
|
7
|
+
height="1em"
|
|
8
|
+
viewBox="0 0 16 16"
|
|
9
|
+
width="1em"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M8.5 7.5a.5.5 0 1 0-1 0v3a.5.5 0 0 0 1 0v-3Zm.25-2a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1ZM2 8a6 6 0 1 1 12 0A6 6 0 0 1 2 8Z"
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
));
|
package/src/icons/SendIcon.tsx
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,9 +2,12 @@ import { injectMetaTag } from 'inject-meta-tag';
|
|
|
2
2
|
|
|
3
3
|
import FluentThemeProvider from './private/FluentThemeProvider';
|
|
4
4
|
import testIds from './testIds';
|
|
5
|
+
import { injectStyle } from './styles';
|
|
5
6
|
|
|
6
7
|
declare const NPM_PACKAGE_VERSION: string;
|
|
7
8
|
|
|
8
9
|
injectMetaTag('botframework-webchat-fluent-theme:version', NPM_PACKAGE_VERSION);
|
|
9
10
|
|
|
11
|
+
injectStyle();
|
|
12
|
+
|
|
10
13
|
export { FluentThemeProvider, testIds };
|
|
@@ -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
package/src/tsconfig.json
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import createEmotion, { type Emotion } from '@emotion/css/create-instance';
|
|
2
|
-
// TODO: [P0] Use `math-random`. Today, it requires "crypto" today, maybe missing "conditions" or what.
|
|
3
|
-
// import random from 'math-random';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
|
|
6
|
-
const { random } = Math;
|
|
7
|
-
|
|
8
|
-
const emotionPool: Record<string, Emotion> = {};
|
|
9
|
-
const nonce = '';
|
|
10
|
-
|
|
11
|
-
/* eslint no-magic-numbers: ["error", { "ignore": [0, 2, 5, 26, 65] }] */
|
|
12
|
-
|
|
13
|
-
function createCSSKey() {
|
|
14
|
-
return random()
|
|
15
|
-
.toString(26)
|
|
16
|
-
.substr(2, 5)
|
|
17
|
-
.replace(/\d/gu, (value: string) => String.fromCharCode(value.charCodeAt(0) + 65));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default function useStyleToEmotionObject() {
|
|
21
|
-
return useMemo(() => {
|
|
22
|
-
// Emotion doesn't hash with nonce. We need to provide the pooling mechanism.
|
|
23
|
-
// 1. If 2 instances use different nonce, they should result in different hash;
|
|
24
|
-
// 2. If 2 instances are being mounted, pooling will make sure we render only 1 set of <style> tags, instead of 2.
|
|
25
|
-
const emotion =
|
|
26
|
-
// Prefix "id-" to prevent object injection attack.
|
|
27
|
-
emotionPool[`id-${nonce}`] ||
|
|
28
|
-
(emotionPool[`id-${nonce}`] = createEmotion({ key: `webchat--css-${createCSSKey()}`, nonce }));
|
|
29
|
-
|
|
30
|
-
return (style: TemplateStringsArray) => emotion.css(style);
|
|
31
|
-
}, []);
|
|
32
|
-
}
|
package/src/styles/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
import useStyleToEmotionObject from '../private/useStyleToEmotionObject';
|
|
4
|
-
|
|
5
|
-
export function useStyles<T extends Record<`webchat-fluent__${string}`, any>>(styles: T): Record<keyof T, string> {
|
|
6
|
-
const getClassName = useStyleToEmotionObject();
|
|
7
|
-
// @ts-expect-error: entries/fromEntries don't allow to specify keys type
|
|
8
|
-
return useMemo(
|
|
9
|
-
() =>
|
|
10
|
-
Object.freeze(
|
|
11
|
-
Object.fromEntries(Object.entries(styles).map(([cls, style]) => [cls, `${cls} ${getClassName(style)}`]))
|
|
12
|
-
),
|
|
13
|
-
[styles, getClassName]
|
|
14
|
-
);
|
|
15
|
-
}
|