botframework-webchat-fluent-theme 4.17.0-main.20240411.ff34969 → 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.
- package/dist/botframework-webchat-fluent-theme.development.css.map +1 -0
- package/dist/botframework-webchat-fluent-theme.development.js +384 -2081
- 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.d.mts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +360 -648
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1076 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
- package/src/components/Theme.module.css +60 -0
- package/src/components/Theme.tsx +4 -64
- 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 +3 -12
- package/src/components/sendbox/ErrorMessage.module.css +9 -0
- package/src/components/sendbox/ErrorMessage.tsx +2 -13
- package/src/components/sendbox/TelephoneKeypadToolbarButton.tsx +1 -1
- package/src/components/sendbox/TextArea.module.css +61 -0
- package/src/components/sendbox/TextArea.tsx +9 -70
- package/src/components/sendbox/Toolbar.module.css +49 -0
- package/src/components/sendbox/Toolbar.tsx +4 -55
- package/src/components/sendbox/index.module.css +58 -0
- package/src/components/sendbox/index.tsx +16 -81
- package/src/components/suggestedActions/SuggestedAction.module.css +34 -0
- package/src/components/suggestedActions/SuggestedAction.tsx +5 -47
- package/src/components/suggestedActions/index.module.css +23 -0
- package/src/components/suggestedActions/index.tsx +18 -23
- 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 +30 -0
- package/src/components/telephoneKeypad/private/TelephoneKeypad.tsx +4 -35
- package/src/env.d.ts +7 -0
- 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
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
|
-
}
|