@matrix-widget-toolkit/mui 2.0.6 → 2.1.0
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/README.md +3 -1
- package/build/cjs/components/ElementAvatar/ElementAvatar.d.cts +27 -0
- package/build/cjs/components/ElementAvatar/ElementAvatar.test.d.cts +1 -0
- package/build/cjs/components/ElementAvatar/createAvatarUrl.d.cts +3 -0
- package/build/cjs/components/ElementAvatar/createAvatarUrl.test.d.cts +1 -0
- package/build/cjs/components/ElementAvatar/getInitialLetter.d.cts +1 -0
- package/build/cjs/components/ElementAvatar/getInitialLetter.test.d.cts +1 -0
- package/build/cjs/components/ElementAvatar/index.d.cts +2 -0
- package/build/cjs/components/ElementAvatar/useIdColorHash.d.cts +12 -0
- package/build/cjs/components/ElementAvatar/useIdColorHash.test.d.cts +1 -0
- package/build/cjs/components/LoadingView/LoadingView.d.cts +2 -0
- package/build/cjs/components/LoadingView/LoadingView.test.d.cts +1 -0
- package/build/cjs/components/LoadingView/index.d.cts +1 -0
- package/build/cjs/components/MissingCapabilitiesError/MissingCapabilitiesError.d.cts +4 -0
- package/build/cjs/components/MissingCapabilitiesError/MissingCapabilitiesError.test.d.cts +1 -0
- package/build/cjs/components/MissingCapabilitiesError/index.d.cts +1 -0
- package/build/cjs/components/MuiCapabilitiesGuard/MuiCapabilitiesGuard.d.cts +19 -0
- package/build/cjs/components/MuiCapabilitiesGuard/MuiCapabilitiesGuard.test.d.cts +1 -0
- package/build/cjs/components/MuiCapabilitiesGuard/index.d.cts +2 -0
- package/build/cjs/components/MuiThemeProvider/EmotionCacheProvider.d.cts +2 -0
- package/build/cjs/components/MuiThemeProvider/MuiThemeProvider.d.cts +14 -0
- package/build/cjs/components/MuiThemeProvider/MuiThemeProvider.test.d.cts +1 -0
- package/build/cjs/components/MuiThemeProvider/environment.d.cts +23 -0
- package/build/cjs/components/MuiThemeProvider/environment.test.d.cts +1 -0
- package/build/cjs/components/MuiThemeProvider/index.d.cts +4 -0
- package/build/cjs/components/MuiThemeProvider/nonce.d.cts +6 -0
- package/build/cjs/components/MuiThemeProvider/theme.d.cts +5 -0
- package/build/cjs/components/MuiThemeProvider/theme.test.d.cts +1 -0
- package/build/cjs/components/MuiWidgetApiProvider/ChildError.d.cts +4 -0
- package/build/cjs/components/MuiWidgetApiProvider/ChildError.test.d.cts +1 -0
- package/build/cjs/components/MuiWidgetApiProvider/CopyableCode.d.cts +4 -0
- package/build/cjs/components/MuiWidgetApiProvider/CopyableCode.test.d.cts +1 -0
- package/build/cjs/components/MuiWidgetApiProvider/MissingParametersError.d.cts +6 -0
- package/build/cjs/components/MuiWidgetApiProvider/MissingParametersError.test.d.cts +1 -0
- package/build/cjs/components/MuiWidgetApiProvider/MobileClientError.d.cts +2 -0
- package/build/cjs/components/MuiWidgetApiProvider/MobileClientError.test.d.cts +1 -0
- package/build/cjs/components/MuiWidgetApiProvider/MuiWidgetApiProvider.d.cts +22 -0
- package/build/cjs/components/MuiWidgetApiProvider/MuiWidgetApiProvider.test.d.cts +1 -0
- package/build/cjs/components/MuiWidgetApiProvider/OutsideClientError.d.cts +2 -0
- package/build/cjs/components/MuiWidgetApiProvider/OutsideClientError.test.d.cts +1 -0
- package/build/cjs/components/MuiWidgetApiProvider/index.d.cts +2 -0
- package/build/cjs/components/index.d.cts +4 -0
- package/build/cjs/i18n/i18n.d.cts +12 -0
- package/build/cjs/i18n/index.d.cts +1 -0
- package/build/cjs/{index.js → index.cjs} +104 -31
- package/build/cjs/index.d.cts +6 -0
- package/build/cjs/setupTests.d.cts +1 -0
- package/build/esm/components/ElementAvatar/ElementAvatar.d.ts +27 -0
- package/build/esm/components/ElementAvatar/ElementAvatar.test.d.ts +1 -0
- package/build/esm/components/ElementAvatar/createAvatarUrl.d.ts +3 -0
- package/build/esm/components/ElementAvatar/createAvatarUrl.test.d.ts +1 -0
- package/build/esm/components/ElementAvatar/getInitialLetter.d.ts +1 -0
- package/build/esm/components/ElementAvatar/getInitialLetter.test.d.ts +1 -0
- package/build/esm/components/ElementAvatar/index.d.ts +2 -0
- package/build/esm/components/ElementAvatar/useIdColorHash.d.ts +12 -0
- package/build/esm/components/ElementAvatar/useIdColorHash.test.d.ts +1 -0
- package/build/esm/components/LoadingView/LoadingView.d.ts +2 -0
- package/build/esm/components/LoadingView/LoadingView.test.d.ts +1 -0
- package/build/esm/components/LoadingView/index.d.ts +1 -0
- package/build/esm/components/MissingCapabilitiesError/MissingCapabilitiesError.d.ts +4 -0
- package/build/esm/components/MissingCapabilitiesError/MissingCapabilitiesError.test.d.ts +1 -0
- package/build/esm/components/MissingCapabilitiesError/index.d.ts +1 -0
- package/build/esm/components/MuiCapabilitiesGuard/MuiCapabilitiesGuard.d.ts +19 -0
- package/build/esm/components/MuiCapabilitiesGuard/MuiCapabilitiesGuard.test.d.ts +1 -0
- package/build/esm/components/MuiCapabilitiesGuard/index.d.ts +2 -0
- package/build/esm/components/MuiThemeProvider/EmotionCacheProvider.d.ts +2 -0
- package/build/esm/components/MuiThemeProvider/MuiThemeProvider.d.ts +14 -0
- package/build/esm/components/MuiThemeProvider/MuiThemeProvider.test.d.ts +1 -0
- package/build/esm/components/MuiThemeProvider/environment.d.ts +23 -0
- package/build/esm/components/MuiThemeProvider/environment.test.d.ts +1 -0
- package/build/esm/components/MuiThemeProvider/index.d.ts +4 -0
- package/build/esm/components/MuiThemeProvider/nonce.d.ts +6 -0
- package/build/esm/components/MuiThemeProvider/theme.d.ts +5 -0
- package/build/esm/components/MuiThemeProvider/theme.test.d.ts +1 -0
- package/build/esm/components/MuiWidgetApiProvider/ChildError.d.ts +4 -0
- package/build/esm/components/MuiWidgetApiProvider/ChildError.test.d.ts +1 -0
- package/build/esm/components/MuiWidgetApiProvider/CopyableCode.d.ts +4 -0
- package/build/esm/components/MuiWidgetApiProvider/CopyableCode.test.d.ts +1 -0
- package/build/esm/components/MuiWidgetApiProvider/MissingParametersError.d.ts +6 -0
- package/build/esm/components/MuiWidgetApiProvider/MissingParametersError.test.d.ts +1 -0
- package/build/esm/components/MuiWidgetApiProvider/MobileClientError.d.ts +2 -0
- package/build/esm/components/MuiWidgetApiProvider/MobileClientError.test.d.ts +1 -0
- package/build/esm/components/MuiWidgetApiProvider/MuiWidgetApiProvider.d.ts +22 -0
- package/build/esm/components/MuiWidgetApiProvider/MuiWidgetApiProvider.test.d.ts +1 -0
- package/build/esm/components/MuiWidgetApiProvider/OutsideClientError.d.ts +2 -0
- package/build/esm/components/MuiWidgetApiProvider/OutsideClientError.test.d.ts +1 -0
- package/build/esm/components/MuiWidgetApiProvider/index.d.ts +2 -0
- package/build/esm/components/index.d.ts +4 -0
- package/build/esm/i18n/i18n.d.ts +12 -0
- package/build/esm/i18n/index.d.ts +1 -0
- package/build/esm/index.d.ts +6 -0
- package/build/esm/index.js +104 -31
- package/build/esm/setupTests.d.ts +1 -0
- package/package.json +43 -35
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Capability, WidgetEventCapability } from 'matrix-widget-api';
|
|
2
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the {@link MuiCapabilitiesGuard} component.
|
|
5
|
+
*/
|
|
6
|
+
export type MuiCapabilitiesGuardProps = PropsWithChildren<{
|
|
7
|
+
/**
|
|
8
|
+
* Required capabilities to display the `children`.
|
|
9
|
+
*/
|
|
10
|
+
capabilities: Array<WidgetEventCapability | Capability>;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* A guard that ask the user for capabilities and only shows the `children`
|
|
14
|
+
* if all capabilities were accepted.
|
|
15
|
+
* If capabilities are denied, a message and a button to retry is displayed
|
|
16
|
+
* instead.
|
|
17
|
+
* @param param0 - {@link MuiCapabilitiesGuardProps}
|
|
18
|
+
*/
|
|
19
|
+
export declare function MuiCapabilitiesGuard({ capabilities, children, }: MuiCapabilitiesGuardProps): ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '@fontsource/inter/400.css';
|
|
2
|
+
import '@fontsource/inter/600.css';
|
|
3
|
+
import { ThemeOptions } from '@mui/material';
|
|
4
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the {@link MuiThemeProvider} component.
|
|
7
|
+
*/
|
|
8
|
+
export type MuiThemeProviderProps = PropsWithChildren;
|
|
9
|
+
/**
|
|
10
|
+
* Provide a semantic UI based theme to the child components.
|
|
11
|
+
* @param param0 - {@link MuiThemeProviderProps}
|
|
12
|
+
*/
|
|
13
|
+
export declare function MuiThemeProvider({ children, }: MuiThemeProviderProps): ReactElement;
|
|
14
|
+
export declare function chooseTheme(theme: string): ThemeOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
__ENVIRONMENT__: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads environment variables starting with `REACT_APP_` from a global variable
|
|
8
|
+
* at runtime and falls back to `process.env` build time variables.
|
|
9
|
+
*
|
|
10
|
+
* @param name - The name of the environment variable, should start with
|
|
11
|
+
* `REACT_APP_`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEnvironment(name: string): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Reads environment variables starting with `REACT_APP_` from a global variable
|
|
16
|
+
* at runtime and falls back to `process.env` build time variables.
|
|
17
|
+
*
|
|
18
|
+
* @param name - The name of the environment variable, should start with
|
|
19
|
+
* `REACT_APP_`.
|
|
20
|
+
* @param defaultValue - The default value to return if the environment variable
|
|
21
|
+
* is not provided.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getEnvironment(name: string, defaultValue: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WidgetRegistration } from '@matrix-widget-toolkit/api';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
export declare const STATE_EVENT_WIDGETS = "im.vector.modular.widgets";
|
|
4
|
+
export declare function MissingParametersError({ widgetRegistration, }: {
|
|
5
|
+
widgetRegistration?: WidgetRegistration;
|
|
6
|
+
}): ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WidgetApi, WidgetRegistration } from '@matrix-widget-toolkit/api';
|
|
2
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the {@link (MuiWidgetApiProvider:function)} component.
|
|
5
|
+
*/
|
|
6
|
+
export type MuiWidgetApiProviderProps = PropsWithChildren<{
|
|
7
|
+
/**
|
|
8
|
+
* Configuration to set during Widget registration.
|
|
9
|
+
*/
|
|
10
|
+
widgetRegistration?: WidgetRegistration;
|
|
11
|
+
/**
|
|
12
|
+
* Result from a call to `WidgetApiImpl.create`.
|
|
13
|
+
*/
|
|
14
|
+
widgetApiPromise: Promise<WidgetApi>;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Provides the `WidgetApi` in the React context once it's fully
|
|
18
|
+
* initialized without errors.
|
|
19
|
+
* Use `useWidgetApi` to access it.
|
|
20
|
+
* @param param0 - {@link MuiWidgetApiProviderProps}
|
|
21
|
+
*/
|
|
22
|
+
export declare function MuiWidgetApiProvider({ widgetRegistration, widgetApiPromise, children, }: MuiWidgetApiProviderProps): ReactElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
2
|
+
/**
|
|
3
|
+
* Backend for usage with `i18n-next` that provides translations for internal
|
|
4
|
+
* messages.
|
|
5
|
+
*/
|
|
6
|
+
export declare const WidgetToolkitI18nBackend: import("i18next").BackendModule<object>;
|
|
7
|
+
/**
|
|
8
|
+
* A language detector that reads the language from the widget url.
|
|
9
|
+
*/
|
|
10
|
+
export declare class WidgetApiLanguageDetector extends LanguageDetector {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetApiLanguageDetector, WidgetToolkitI18nBackend } from './i18n';
|
package/build/esm/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import { deepmerge } from '@mui/utils';
|
|
|
9
9
|
import i18n from 'i18next';
|
|
10
10
|
import createCache from '@emotion/cache';
|
|
11
11
|
import { CacheProvider } from '@emotion/react';
|
|
12
|
-
import { split } from 'lodash';
|
|
13
12
|
import { useTranslation } from 'react-i18next';
|
|
14
13
|
import { useTimeout, useCopyToClipboard } from 'react-use';
|
|
15
14
|
import ErrorIcon from '@mui/icons-material/Error';
|
|
@@ -119,9 +118,11 @@ var fontFamily = [
|
|
|
119
118
|
'"Segoe UI Emoji"',
|
|
120
119
|
'"Noto Color Emoji"',
|
|
121
120
|
].join(',');
|
|
122
|
-
var
|
|
121
|
+
var primaryColorlight = getEnvironment('REACT_APP_LIGHT_PRIMARY_COLOR', '#007a61');
|
|
122
|
+
var primaryColorDark = getEnvironment('REACT_APP_DARK_PRIMARY_COLOR', '#129a78');
|
|
123
123
|
var primaryColorHighContrast = '#075D53';
|
|
124
|
-
var
|
|
124
|
+
var errorColorLight = '#d51928';
|
|
125
|
+
var errorColorDark = '#fd3e3c';
|
|
125
126
|
var errorColorHighContrast = '#AA0904';
|
|
126
127
|
function createSwitchStyleOverrides(_a) {
|
|
127
128
|
var trackColor = _a.trackColor, thumbColor = _a.thumbColor;
|
|
@@ -198,11 +199,11 @@ var baseTheme = {
|
|
|
198
199
|
},
|
|
199
200
|
palette: {
|
|
200
201
|
primary: {
|
|
201
|
-
main:
|
|
202
|
+
main: primaryColorlight,
|
|
202
203
|
contrastText: '#ffffff',
|
|
203
204
|
},
|
|
204
205
|
error: {
|
|
205
|
-
main:
|
|
206
|
+
main: errorColorLight,
|
|
206
207
|
contrastText: '#ffffff',
|
|
207
208
|
},
|
|
208
209
|
tonalOffset: 0.025,
|
|
@@ -449,6 +450,12 @@ var lightTheme = {
|
|
|
449
450
|
default: '#ffffff',
|
|
450
451
|
paper: '#f2f5f8',
|
|
451
452
|
},
|
|
453
|
+
primary: {
|
|
454
|
+
main: primaryColorlight,
|
|
455
|
+
},
|
|
456
|
+
error: {
|
|
457
|
+
main: errorColorLight,
|
|
458
|
+
},
|
|
452
459
|
text: {
|
|
453
460
|
primary: '#17191c',
|
|
454
461
|
secondary: '#61708b',
|
|
@@ -607,6 +614,12 @@ var darkTheme = {
|
|
|
607
614
|
default: '#15191e',
|
|
608
615
|
paper: '#20252b',
|
|
609
616
|
},
|
|
617
|
+
primary: {
|
|
618
|
+
main: primaryColorDark,
|
|
619
|
+
},
|
|
620
|
+
error: {
|
|
621
|
+
main: errorColorDark,
|
|
622
|
+
},
|
|
610
623
|
text: {
|
|
611
624
|
primary: '#ffffff',
|
|
612
625
|
secondary: '#b9bec6',
|
|
@@ -713,20 +726,28 @@ function createAvatarUrl(url, _a) {
|
|
|
713
726
|
* See the License for the specific language governing permissions and
|
|
714
727
|
* limitations under the License.
|
|
715
728
|
*/
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
729
|
+
// Based on the way Element selects the initial letter
|
|
730
|
+
// https://github.com/matrix-org/matrix-react-sdk/blob/667ec166d736dfb0ac49f67398a8b7a13db7d5ef/src/Avatar.ts#L121
|
|
731
|
+
function getInitialLetter(name) {
|
|
732
|
+
if (name.length < 1) {
|
|
733
|
+
return undefined;
|
|
734
|
+
}
|
|
735
|
+
var initial = name[0];
|
|
736
|
+
if ((initial === '@' || initial === '#' || initial === '+') && name[1]) {
|
|
737
|
+
name = name.substring(1);
|
|
723
738
|
}
|
|
724
|
-
|
|
725
|
-
return
|
|
739
|
+
// rely on the grapheme cluster splitter in the Intl.Segmenter to get the first character
|
|
740
|
+
return Array.from(new Intl.Segmenter().segment(name))
|
|
741
|
+
.map(function (_a) {
|
|
742
|
+
var segment = _a.segment;
|
|
743
|
+
return segment;
|
|
744
|
+
})
|
|
745
|
+
.slice(0, 1)[0]
|
|
746
|
+
.toUpperCase();
|
|
726
747
|
}
|
|
727
748
|
|
|
728
749
|
/*
|
|
729
|
-
* Copyright
|
|
750
|
+
* Copyright 2024 Nordeck IT + Consulting GmbH
|
|
730
751
|
*
|
|
731
752
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
732
753
|
* you may not use this file except in compliance with the License.
|
|
@@ -740,19 +761,28 @@ function getColor(id) {
|
|
|
740
761
|
* See the License for the specific language governing permissions and
|
|
741
762
|
* limitations under the License.
|
|
742
763
|
*/
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
764
|
+
/**
|
|
765
|
+
* Determines a number for a given Matrix ID or room ID, helps disambiguating users
|
|
766
|
+
* who are trying to impersonate someone else.
|
|
767
|
+
*
|
|
768
|
+
* {@link https://github.com/element-hq/compound-web/blob/5950e6827aaaca5a0b2540093f0b168ca590e8ca/src/components/Avatar/useIdColorHash.ts#L23}
|
|
769
|
+
* @copyright Copyright 2023 New Vector Ltd
|
|
770
|
+
*
|
|
771
|
+
* @param id - a Matrix ID or room ID
|
|
772
|
+
* @returns a hash of the ID provided
|
|
773
|
+
*/
|
|
774
|
+
function useIdColorHash(id) {
|
|
775
|
+
var MIN = 1;
|
|
776
|
+
var MAX = 6;
|
|
777
|
+
// Sum up the values of all the char codes in the string
|
|
778
|
+
var charCodeSum = id.split('').reduce(function (sum, char) {
|
|
779
|
+
return sum + char.charCodeAt(0);
|
|
780
|
+
}, 0);
|
|
781
|
+
return (charCodeSum % MAX) + MIN;
|
|
755
782
|
}
|
|
783
|
+
var isColorHash = function (value) {
|
|
784
|
+
return [1, 2, 3, 4, 5, 6].includes(value);
|
|
785
|
+
};
|
|
756
786
|
|
|
757
787
|
var __assign = (undefined && undefined.__assign) || function () {
|
|
758
788
|
__assign = Object.assign || function(t) {
|
|
@@ -776,17 +806,60 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
776
806
|
}
|
|
777
807
|
return t;
|
|
778
808
|
};
|
|
809
|
+
/**
|
|
810
|
+
* {@link https://github.com/element-hq/compound-design-tokens}
|
|
811
|
+
*/
|
|
812
|
+
var bgColors = {
|
|
813
|
+
dark: {
|
|
814
|
+
1: '#002600',
|
|
815
|
+
2: '#001b4e',
|
|
816
|
+
3: '#37004e',
|
|
817
|
+
4: '#22006a',
|
|
818
|
+
5: '#450018',
|
|
819
|
+
6: '#470000',
|
|
820
|
+
},
|
|
821
|
+
light: {
|
|
822
|
+
1: '#e0f8d9',
|
|
823
|
+
2: '#e3f5f8',
|
|
824
|
+
3: '#faeefb',
|
|
825
|
+
4: '#f1efff',
|
|
826
|
+
5: '#ffecf0',
|
|
827
|
+
6: '#ffefe4',
|
|
828
|
+
},
|
|
829
|
+
};
|
|
830
|
+
var colors = {
|
|
831
|
+
dark: {
|
|
832
|
+
1: '#56c02c',
|
|
833
|
+
2: '#21bacd',
|
|
834
|
+
3: '#d991de',
|
|
835
|
+
4: '#ad9cfe',
|
|
836
|
+
5: '#fe84a2',
|
|
837
|
+
6: '#f6913d',
|
|
838
|
+
},
|
|
839
|
+
light: {
|
|
840
|
+
1: '#005f00',
|
|
841
|
+
2: '#00548c',
|
|
842
|
+
3: '#822198',
|
|
843
|
+
4: '#5d26cd',
|
|
844
|
+
5: '#9f0850',
|
|
845
|
+
6: '#9b2200',
|
|
846
|
+
},
|
|
847
|
+
};
|
|
779
848
|
var StyledAvatar = styled(Avatar, {
|
|
780
849
|
shouldForwardProp: function (p) { return p !== 'color'; },
|
|
781
850
|
})(function (_a) {
|
|
782
|
-
var theme = _a.theme,
|
|
851
|
+
var theme = _a.theme, colorHash = _a.colorHash;
|
|
783
852
|
return ({
|
|
784
853
|
// increase the specificity of the css selector to override styles of
|
|
785
854
|
// chip or button components that provide their own css for avatars.
|
|
786
855
|
'&, &&.MuiChip-avatar': {
|
|
787
856
|
fontSize: 18,
|
|
788
|
-
background:
|
|
789
|
-
|
|
857
|
+
background: isColorHash(colorHash)
|
|
858
|
+
? bgColors[theme.palette.mode][colorHash]
|
|
859
|
+
: bgColors[theme.palette.mode][1],
|
|
860
|
+
color: isColorHash(colorHash)
|
|
861
|
+
? colors[theme.palette.mode][colorHash]
|
|
862
|
+
: colors[theme.palette.mode][1],
|
|
790
863
|
},
|
|
791
864
|
width: 24,
|
|
792
865
|
height: 24,
|
|
@@ -800,7 +873,7 @@ var ElementAvatar = forwardRef(function ElementAvatar(_a, ref) {
|
|
|
800
873
|
var avatarUrl = _a.avatarUrl, userId = _a.userId, displayName = _a.displayName, props = __rest(_a, ["avatarUrl", "userId", "displayName"]);
|
|
801
874
|
var src = avatarUrl ? createAvatarUrl(avatarUrl) : undefined;
|
|
802
875
|
var name = displayName !== null && displayName !== void 0 ? displayName : userId;
|
|
803
|
-
return (jsx(StyledAvatar, __assign({ ref: ref, alt: "", "aria-hidden": true, src: src,
|
|
876
|
+
return (jsx(StyledAvatar, __assign({ ref: ref, alt: "", "aria-hidden": true, src: src, colorHash: useIdColorHash(userId) }, props, { children: getInitialLetter(name) })));
|
|
804
877
|
});
|
|
805
878
|
|
|
806
879
|
function LoadingView() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
package/package.json
CHANGED
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matrix-widget-toolkit/mui",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A customized material-ui theme that matches the style of the Element Matrix client",
|
|
5
5
|
"author": "Nordeck IT + Consulting GmbH",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"source": "./src/index.ts",
|
|
8
|
-
"types": "./build/index.d.ts",
|
|
8
|
+
"types": "./build/esm/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"module": "./build/esm/index.js",
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./build/esm/index.d.ts",
|
|
14
|
+
"default": "./build/esm/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./build/cjs/index.d.cts",
|
|
18
|
+
"default": "./build/cjs/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
13
22
|
},
|
|
14
23
|
"type": "module",
|
|
15
24
|
"devDependencies": {
|
|
16
|
-
"@testing-library/jest-dom": "
|
|
17
|
-
"@testing-library/react": "
|
|
18
|
-
"@testing-library/user-event": "
|
|
19
|
-
"@types/
|
|
20
|
-
"@types/
|
|
21
|
-
"@
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
"@testing-library/jest-dom": "6.6.3",
|
|
26
|
+
"@testing-library/react": "16.0.1",
|
|
27
|
+
"@testing-library/user-event": "14.5.2",
|
|
28
|
+
"@types/node": "22.9.0",
|
|
29
|
+
"@types/react": "18.3.12",
|
|
30
|
+
"@vitest/coverage-v8": "2.1.5",
|
|
31
|
+
"axe-core": "4.10.2",
|
|
32
|
+
"copyfiles": "2.4.1",
|
|
33
|
+
"i18next-parser": "9.0.2",
|
|
34
|
+
"typescript": "5.6.3",
|
|
35
|
+
"vite": "5.4.11",
|
|
36
|
+
"vitest": "2.1.5"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": "18.3.1"
|
|
30
40
|
},
|
|
31
41
|
"scripts": {
|
|
32
42
|
"build": "tsc && rollup --config ../../rollup.config.mjs",
|
|
@@ -42,23 +52,21 @@
|
|
|
42
52
|
"generate-api-report": "tsc && api-extractor run --verbose --local"
|
|
43
53
|
},
|
|
44
54
|
"dependencies": {
|
|
45
|
-
"@emotion/cache": "
|
|
46
|
-
"@emotion/react": "
|
|
47
|
-
"@emotion/styled": "
|
|
48
|
-
"@fontsource/inter": "
|
|
55
|
+
"@emotion/cache": "11.13.1",
|
|
56
|
+
"@emotion/react": "11.13.3",
|
|
57
|
+
"@emotion/styled": "11.13.0",
|
|
58
|
+
"@fontsource/inter": "5.1.0",
|
|
49
59
|
"@matrix-widget-toolkit/api": "^3.4.2",
|
|
50
60
|
"@matrix-widget-toolkit/react": "^2.0.3",
|
|
51
|
-
"@mui/icons-material": "
|
|
52
|
-
"@mui/material": "
|
|
53
|
-
"@mui/utils": "
|
|
54
|
-
"i18next": "
|
|
55
|
-
"i18next-browser-languagedetector": "
|
|
56
|
-
"i18next-resources-to-backend": "
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"react": "
|
|
60
|
-
"react-i18next": "^15.0.3",
|
|
61
|
-
"react-use": "^17.5.1"
|
|
61
|
+
"@mui/icons-material": "6.1.7",
|
|
62
|
+
"@mui/material": "6.1.7",
|
|
63
|
+
"@mui/utils": "6.1.7",
|
|
64
|
+
"i18next": "23.16.5",
|
|
65
|
+
"i18next-browser-languagedetector": "8.0.0",
|
|
66
|
+
"i18next-resources-to-backend": "1.2.1",
|
|
67
|
+
"matrix-widget-api": "1.10.0",
|
|
68
|
+
"react-i18next": "15.1.1",
|
|
69
|
+
"react-use": "17.5.1"
|
|
62
70
|
},
|
|
63
71
|
"repository": {
|
|
64
72
|
"type": "git",
|
|
@@ -74,5 +82,5 @@
|
|
|
74
82
|
"matrix-widget-api"
|
|
75
83
|
],
|
|
76
84
|
"module": "./build/esm/index.js",
|
|
77
|
-
"main": "./build/cjs/index.
|
|
85
|
+
"main": "./build/cjs/index.cjs"
|
|
78
86
|
}
|