@matrix-widget-toolkit/mui 1.1.0 → 1.1.2
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/build/cjs/index.js +20 -8
- package/build/esm/index.js +20 -8
- package/build/index.d.ts +6 -6
- package/package.json +2 -2
package/build/cjs/index.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var material = require('@mui/material');
|
|
5
|
+
var react$2 = require('react');
|
|
5
6
|
require('@fontsource/inter/400.css');
|
|
6
7
|
require('@fontsource/inter/600.css');
|
|
7
8
|
var react$1 = require('@matrix-widget-toolkit/react');
|
|
8
9
|
var locale = require('@mui/material/locale');
|
|
9
10
|
var utils = require('@mui/utils');
|
|
10
11
|
var i18n = require('i18next');
|
|
11
|
-
var react$2 = require('react');
|
|
12
12
|
var createCache = require('@emotion/cache');
|
|
13
13
|
var react = require('@emotion/react');
|
|
14
14
|
var lodash = require('lodash');
|
|
@@ -681,10 +681,11 @@ function ElementMuiThemeProvider(_a) {
|
|
|
681
681
|
*/
|
|
682
682
|
function createAvatarUrl(url, _a) {
|
|
683
683
|
var _b = _a === void 0 ? {} : _a, _c = _b.size, size = _c === void 0 ? 60 : _c;
|
|
684
|
-
var
|
|
685
|
-
if (
|
|
684
|
+
var mxcPrefix = 'mxc://';
|
|
685
|
+
if (url.indexOf(mxcPrefix) !== 0) {
|
|
686
686
|
return url;
|
|
687
687
|
}
|
|
688
|
+
var mxcUrl = url.slice(mxcPrefix.length);
|
|
688
689
|
// TODO: Instead of retrieving the home server from an env variable, it would
|
|
689
690
|
// be good to get this passed by the widget host, e.g. as an URL parameter.
|
|
690
691
|
// In general our tight CSP makes it difficult to load images from this
|
|
@@ -693,7 +694,7 @@ function createAvatarUrl(url, _a) {
|
|
|
693
694
|
// current users id and resolving the home server URL from the well-known
|
|
694
695
|
// endpoint. However, this would also require a broad connect-src in the CSP.
|
|
695
696
|
var homeServer = getEnvironment('REACT_APP_HOME_SERVER_URL', 'https://matrix-client.matrix.org');
|
|
696
|
-
var imageUrl = new URL("/_matrix/media/r0/thumbnail/".concat(mxcUrl
|
|
697
|
+
var imageUrl = new URL("/_matrix/media/r0/thumbnail/".concat(mxcUrl, "?width=").concat(size, "&height=").concat(size, "&method=crop"), homeServer);
|
|
697
698
|
return imageUrl.toString();
|
|
698
699
|
}
|
|
699
700
|
|
|
@@ -764,6 +765,17 @@ var __assign$9 = (undefined && undefined.__assign) || function () {
|
|
|
764
765
|
};
|
|
765
766
|
return __assign$9.apply(this, arguments);
|
|
766
767
|
};
|
|
768
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
769
|
+
var t = {};
|
|
770
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
771
|
+
t[p] = s[p];
|
|
772
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
773
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
774
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
775
|
+
t[p[i]] = s[p[i]];
|
|
776
|
+
}
|
|
777
|
+
return t;
|
|
778
|
+
};
|
|
767
779
|
var StyledAvatar = material.styled(material.Avatar, {
|
|
768
780
|
shouldForwardProp: function (p) { return p !== 'color'; },
|
|
769
781
|
})(function (_a) {
|
|
@@ -784,12 +796,12 @@ var StyledAvatar = material.styled(material.Avatar, {
|
|
|
784
796
|
* A component to display user and room avatars in the style of Element.
|
|
785
797
|
* @param param0 - {@link ElementAvatarProps}
|
|
786
798
|
*/
|
|
787
|
-
function ElementAvatar(_a) {
|
|
788
|
-
var avatarUrl = _a.avatarUrl, userId = _a.userId, displayName = _a.displayName,
|
|
799
|
+
var ElementAvatar = react$2.forwardRef(function ElementAvatar(_a, ref) {
|
|
800
|
+
var avatarUrl = _a.avatarUrl, userId = _a.userId, displayName = _a.displayName, props = __rest(_a, ["avatarUrl", "userId", "displayName"]);
|
|
789
801
|
var src = avatarUrl ? createAvatarUrl(avatarUrl) : undefined;
|
|
790
802
|
var name = displayName !== null && displayName !== void 0 ? displayName : userId;
|
|
791
|
-
return (jsxRuntime.jsx(StyledAvatar, __assign$9({ alt: "", "aria-hidden": true, src: src, color: getColor(userId)
|
|
792
|
-
}
|
|
803
|
+
return (jsxRuntime.jsx(StyledAvatar, __assign$9({ ref: ref, alt: "", "aria-hidden": true, src: src, color: getColor(userId) }, props, { children: getInitialLetter(name) })));
|
|
804
|
+
});
|
|
793
805
|
|
|
794
806
|
var __assign$8 = (undefined && undefined.__assign) || function () {
|
|
795
807
|
__assign$8 = Object.assign || function(t) {
|
package/build/esm/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { createTheme, ThemeProvider, CssBaseline, styled, Avatar, Box, CircularProgress, Typography, Alert, AlertTitle, Button, Paper, IconButton, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions } from '@mui/material';
|
|
3
|
+
import { useState, useEffect, useMemo, forwardRef, useCallback } from 'react';
|
|
3
4
|
import '@fontsource/inter/400.css';
|
|
4
5
|
import '@fontsource/inter/600.css';
|
|
5
6
|
import { ThemeSelectionProvider, useThemeSelection, CapabilitiesGuard, useWidgetApi, WidgetApiProvider } from '@matrix-widget-toolkit/react';
|
|
6
7
|
import { deDE, enUS } from '@mui/material/locale';
|
|
7
8
|
import { deepmerge, unstable_useId } from '@mui/utils';
|
|
8
9
|
import i18n from 'i18next';
|
|
9
|
-
import { useState, useEffect, useMemo, useCallback } from 'react';
|
|
10
10
|
import createCache from '@emotion/cache';
|
|
11
11
|
import { CacheProvider } from '@emotion/react';
|
|
12
12
|
import { split } from 'lodash';
|
|
@@ -669,10 +669,11 @@ function ElementMuiThemeProvider(_a) {
|
|
|
669
669
|
*/
|
|
670
670
|
function createAvatarUrl(url, _a) {
|
|
671
671
|
var _b = _a === void 0 ? {} : _a, _c = _b.size, size = _c === void 0 ? 60 : _c;
|
|
672
|
-
var
|
|
673
|
-
if (
|
|
672
|
+
var mxcPrefix = 'mxc://';
|
|
673
|
+
if (url.indexOf(mxcPrefix) !== 0) {
|
|
674
674
|
return url;
|
|
675
675
|
}
|
|
676
|
+
var mxcUrl = url.slice(mxcPrefix.length);
|
|
676
677
|
// TODO: Instead of retrieving the home server from an env variable, it would
|
|
677
678
|
// be good to get this passed by the widget host, e.g. as an URL parameter.
|
|
678
679
|
// In general our tight CSP makes it difficult to load images from this
|
|
@@ -681,7 +682,7 @@ function createAvatarUrl(url, _a) {
|
|
|
681
682
|
// current users id and resolving the home server URL from the well-known
|
|
682
683
|
// endpoint. However, this would also require a broad connect-src in the CSP.
|
|
683
684
|
var homeServer = getEnvironment('REACT_APP_HOME_SERVER_URL', 'https://matrix-client.matrix.org');
|
|
684
|
-
var imageUrl = new URL("/_matrix/media/r0/thumbnail/".concat(mxcUrl
|
|
685
|
+
var imageUrl = new URL("/_matrix/media/r0/thumbnail/".concat(mxcUrl, "?width=").concat(size, "&height=").concat(size, "&method=crop"), homeServer);
|
|
685
686
|
return imageUrl.toString();
|
|
686
687
|
}
|
|
687
688
|
|
|
@@ -752,6 +753,17 @@ var __assign$9 = (undefined && undefined.__assign) || function () {
|
|
|
752
753
|
};
|
|
753
754
|
return __assign$9.apply(this, arguments);
|
|
754
755
|
};
|
|
756
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
757
|
+
var t = {};
|
|
758
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
759
|
+
t[p] = s[p];
|
|
760
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
761
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
762
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
763
|
+
t[p[i]] = s[p[i]];
|
|
764
|
+
}
|
|
765
|
+
return t;
|
|
766
|
+
};
|
|
755
767
|
var StyledAvatar = styled(Avatar, {
|
|
756
768
|
shouldForwardProp: function (p) { return p !== 'color'; },
|
|
757
769
|
})(function (_a) {
|
|
@@ -772,12 +784,12 @@ var StyledAvatar = styled(Avatar, {
|
|
|
772
784
|
* A component to display user and room avatars in the style of Element.
|
|
773
785
|
* @param param0 - {@link ElementAvatarProps}
|
|
774
786
|
*/
|
|
775
|
-
function ElementAvatar(_a) {
|
|
776
|
-
var avatarUrl = _a.avatarUrl, userId = _a.userId, displayName = _a.displayName,
|
|
787
|
+
var ElementAvatar = forwardRef(function ElementAvatar(_a, ref) {
|
|
788
|
+
var avatarUrl = _a.avatarUrl, userId = _a.userId, displayName = _a.displayName, props = __rest(_a, ["avatarUrl", "userId", "displayName"]);
|
|
777
789
|
var src = avatarUrl ? createAvatarUrl(avatarUrl) : undefined;
|
|
778
790
|
var name = displayName !== null && displayName !== void 0 ? displayName : userId;
|
|
779
|
-
return (jsx(StyledAvatar, __assign$9({ alt: "", "aria-hidden": true, src: src, color: getColor(userId)
|
|
780
|
-
}
|
|
791
|
+
return (jsx(StyledAvatar, __assign$9({ ref: ref, alt: "", "aria-hidden": true, src: src, color: getColor(userId) }, props, { children: getInitialLetter(name) })));
|
|
792
|
+
});
|
|
781
793
|
|
|
782
794
|
var __assign$8 = (undefined && undefined.__assign) || function () {
|
|
783
795
|
__assign$8 = Object.assign || function(t) {
|
package/build/index.d.ts
CHANGED
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
/// <reference types="react" />
|
|
7
7
|
|
|
8
|
+
import { AvatarProps } from '@mui/material';
|
|
8
9
|
import { BackendModule } from 'i18next';
|
|
9
10
|
import { Capability } from 'matrix-widget-api';
|
|
11
|
+
import { CommonProps } from '@mui/material/OverridableComponent';
|
|
12
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
10
13
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
11
14
|
import { PropsWithChildren } from 'react';
|
|
12
15
|
import { ReactElement } from 'react';
|
|
13
|
-
import {
|
|
14
|
-
import { Theme } from '@mui/material';
|
|
16
|
+
import { RefAttributes } from 'react';
|
|
15
17
|
import { WidgetApi } from '@matrix-widget-toolkit/api';
|
|
16
18
|
import { WidgetEventCapability } from 'matrix-widget-api';
|
|
17
19
|
import { WidgetRegistration } from '@matrix-widget-toolkit/api';
|
|
@@ -20,7 +22,7 @@ import { WidgetRegistration } from '@matrix-widget-toolkit/api';
|
|
|
20
22
|
* A component to display user and room avatars in the style of Element.
|
|
21
23
|
* @param param0 - {@link ElementAvatarProps}
|
|
22
24
|
*/
|
|
23
|
-
export declare
|
|
25
|
+
export declare const ElementAvatar: ForwardRefExoticComponent<Pick<ElementAvatarProps, "id" | "userId" | "displayName" | "avatarUrl" | "title" | "children" | "slot" | "onReset" | "onError" | "color" | "translate" | keyof CommonProps | "sx" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "variant" | "alt" | "imgProps" | "sizes" | "src" | "srcSet"> & RefAttributes<HTMLDivElement>>;
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* Props for the {@link ElementAvatar} component.
|
|
@@ -42,9 +44,7 @@ export declare type ElementAvatarProps = {
|
|
|
42
44
|
* If not provided, the initial letter based on the display name or userId is used instead.
|
|
43
45
|
*/
|
|
44
46
|
avatarUrl?: string;
|
|
45
|
-
|
|
46
|
-
sx?: SxProps<Theme>;
|
|
47
|
-
};
|
|
47
|
+
} & AvatarProps;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Reads environment variables starting with `REACT_APP_` from a global variable
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matrix-widget-toolkit/mui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/node": "^16.18.14",
|
|
19
19
|
"@types/react": "^17.0.45",
|
|
20
20
|
"copyfiles": "^2.4.1",
|
|
21
|
-
"i18next-parser": "^7.
|
|
21
|
+
"i18next-parser": "^7.7.0",
|
|
22
22
|
"jest-axe": "^7.0.0",
|
|
23
23
|
"react": "^17.0.2",
|
|
24
24
|
"react-scripts": "5.0.1",
|