@matrix-widget-toolkit/mui 1.0.1
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 +84 -0
- package/build/cjs/index.js +951 -0
- package/build/esm/index.js +933 -0
- package/build/index.d.ts +107 -0
- package/build/locales/de/widget-toolkit.json +40 -0
- package/build/locales/en/widget-toolkit.json +40 -0
- package/package.json +71 -0
|
@@ -0,0 +1,951 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('@matrix-widget-toolkit/react');
|
|
5
|
+
var material = require('@mui/material');
|
|
6
|
+
var utils = require('@mui/utils');
|
|
7
|
+
var reactI18next = require('react-i18next');
|
|
8
|
+
var reactUse = require('react-use');
|
|
9
|
+
var ErrorIcon = require('@mui/icons-material/Error');
|
|
10
|
+
require('@fontsource/inter/400.css');
|
|
11
|
+
require('@fontsource/inter/600.css');
|
|
12
|
+
var locale = require('@mui/material/locale');
|
|
13
|
+
var i18n = require('i18next');
|
|
14
|
+
var react$2 = require('react');
|
|
15
|
+
var createCache = require('@emotion/cache');
|
|
16
|
+
var react$1 = require('@emotion/react');
|
|
17
|
+
var CheckOutlinedIcon = require('@mui/icons-material/CheckOutlined');
|
|
18
|
+
var ContentCopyOutlinedIcon = require('@mui/icons-material/ContentCopyOutlined');
|
|
19
|
+
var api = require('@matrix-widget-toolkit/api');
|
|
20
|
+
var LanguageDetector = require('i18next-browser-languagedetector');
|
|
21
|
+
var resourcesToBackend = require('i18next-resources-to-backend');
|
|
22
|
+
|
|
23
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
24
|
+
|
|
25
|
+
var ErrorIcon__default = /*#__PURE__*/_interopDefaultCompat(ErrorIcon);
|
|
26
|
+
var i18n__default = /*#__PURE__*/_interopDefaultCompat(i18n);
|
|
27
|
+
var createCache__default = /*#__PURE__*/_interopDefaultCompat(createCache);
|
|
28
|
+
var CheckOutlinedIcon__default = /*#__PURE__*/_interopDefaultCompat(CheckOutlinedIcon);
|
|
29
|
+
var ContentCopyOutlinedIcon__default = /*#__PURE__*/_interopDefaultCompat(ContentCopyOutlinedIcon);
|
|
30
|
+
var LanguageDetector__default = /*#__PURE__*/_interopDefaultCompat(LanguageDetector);
|
|
31
|
+
var resourcesToBackend__default = /*#__PURE__*/_interopDefaultCompat(resourcesToBackend);
|
|
32
|
+
|
|
33
|
+
var __assign$a = (undefined && undefined.__assign) || function () {
|
|
34
|
+
__assign$a = Object.assign || function(t) {
|
|
35
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
+
s = arguments[i];
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
};
|
|
42
|
+
return __assign$a.apply(this, arguments);
|
|
43
|
+
};
|
|
44
|
+
function LoadingView() {
|
|
45
|
+
var id = utils.unstable_useId();
|
|
46
|
+
var isLongLoad = reactUse.useTimeout(100)[0];
|
|
47
|
+
var t = reactI18next.useTranslation('widget-toolkit').t;
|
|
48
|
+
return isLongLoad() ? (jsxRuntime.jsxs(material.Box, __assign$a({ display: "flex", flexDirection: "column", alignItems: "center", p: 2 }, { children: [jsxRuntime.jsx(material.CircularProgress, { "aria-labelledby": id }), jsxRuntime.jsx(material.Typography, __assign$a({ py: 2, variant: "h6", id: id }, { children: t('loading.message', 'Loading…') }))] }))) : (jsxRuntime.jsx(jsxRuntime.Fragment, {}));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var __assign$9 = (undefined && undefined.__assign) || function () {
|
|
52
|
+
__assign$9 = Object.assign || function(t) {
|
|
53
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
54
|
+
s = arguments[i];
|
|
55
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
56
|
+
t[p] = s[p];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
return __assign$9.apply(this, arguments);
|
|
61
|
+
};
|
|
62
|
+
function MissingCapabilitiesError(_a) {
|
|
63
|
+
var onRetry = _a.onRetry;
|
|
64
|
+
var t = reactI18next.useTranslation('widget-toolkit').t;
|
|
65
|
+
return (jsxRuntime.jsx(material.Box, __assign$9({ my: 2 }, { children: jsxRuntime.jsxs(material.Alert, __assign$9({ severity: "error", icon: jsxRuntime.jsx(ErrorIcon__default.default, {}) }, { children: [jsxRuntime.jsx(material.AlertTitle, { children: t('missing-capabilities.title', 'Missing capabilities') }), jsxRuntime.jsx(material.Typography, __assign$9({ variant: "body2" }, { children: t('missing-capabilities.instructions', 'The minimum capabilities required for this widget are missing. Make sure to grant all requested capabilities.') })), jsxRuntime.jsx(material.Box, __assign$9({ mt: 1 }, { children: jsxRuntime.jsx(material.Button, __assign$9({ variant: "contained", onClick: onRetry }, { children: t('missing-capabilities.request-capabilities', 'Request capabilities') })) }))] })) })));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var __assign$8 = (undefined && undefined.__assign) || function () {
|
|
69
|
+
__assign$8 = Object.assign || function(t) {
|
|
70
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
71
|
+
s = arguments[i];
|
|
72
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
73
|
+
t[p] = s[p];
|
|
74
|
+
}
|
|
75
|
+
return t;
|
|
76
|
+
};
|
|
77
|
+
return __assign$8.apply(this, arguments);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* A guard that ask the user for capabilities and only shows the `children`
|
|
81
|
+
* if all capabilities were accepted.
|
|
82
|
+
* If capabilities are denined, a message and a button to retry is displayed
|
|
83
|
+
* instead.
|
|
84
|
+
* @param param0 - {@link MuiCapabilitiesGuardProps}
|
|
85
|
+
*/
|
|
86
|
+
function MuiCapabilitiesGuard(_a) {
|
|
87
|
+
var capabilities = _a.capabilities, children = _a.children;
|
|
88
|
+
return (jsxRuntime.jsx(react.CapabilitiesGuard, __assign$8({ capabilities: capabilities, loadingComponent: LoadingView, missingCapabilitiesComponent: MissingCapabilitiesError }, { children: children })));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/*
|
|
92
|
+
* Copyright 2022 Nordeck IT + Consulting GmbH
|
|
93
|
+
*
|
|
94
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
95
|
+
* you may not use this file except in compliance with the License.
|
|
96
|
+
* You may obtain a copy of the License at
|
|
97
|
+
*
|
|
98
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
99
|
+
*
|
|
100
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
101
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
102
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
103
|
+
* See the License for the specific language governing permissions and
|
|
104
|
+
* limitations under the License.
|
|
105
|
+
*/
|
|
106
|
+
var getWindowEnvironment = function () {
|
|
107
|
+
var environment = {};
|
|
108
|
+
if (typeof window.__ENVIRONMENT__ === 'string') {
|
|
109
|
+
var encoded = window.__ENVIRONMENT__;
|
|
110
|
+
// check if mustache placeholder hasn't been replaced for some reason.
|
|
111
|
+
if (!encoded.match(/^{{.*}}$/)) {
|
|
112
|
+
try {
|
|
113
|
+
environment = JSON.parse(atob(encoded));
|
|
114
|
+
}
|
|
115
|
+
catch (_a) {
|
|
116
|
+
console.warn('window.__ENVIRONMENT__ has an unexpected format', encoded);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return environment;
|
|
121
|
+
};
|
|
122
|
+
var environment = getWindowEnvironment();
|
|
123
|
+
function getEnvironment(name, defaultValue) {
|
|
124
|
+
var value = environment[name] || process.env[name];
|
|
125
|
+
return value !== null && value !== void 0 ? value : defaultValue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* Copyright 2022 Nordeck IT + Consulting GmbH
|
|
130
|
+
*
|
|
131
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
132
|
+
* you may not use this file except in compliance with the License.
|
|
133
|
+
* You may obtain a copy of the License at
|
|
134
|
+
*
|
|
135
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
136
|
+
*
|
|
137
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
138
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
139
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
140
|
+
* See the License for the specific language governing permissions and
|
|
141
|
+
* limitations under the License.
|
|
142
|
+
*/
|
|
143
|
+
/**
|
|
144
|
+
* Retrieve the nonce passed by our Docker base image.
|
|
145
|
+
* @returns A nonce that can be used to perform operations that are disabled in
|
|
146
|
+
* our CSP by default.
|
|
147
|
+
*/
|
|
148
|
+
function getNonce() {
|
|
149
|
+
return window['NONCE'];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var __assign$7 = (undefined && undefined.__assign) || function () {
|
|
153
|
+
__assign$7 = Object.assign || function(t) {
|
|
154
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
155
|
+
s = arguments[i];
|
|
156
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
157
|
+
t[p] = s[p];
|
|
158
|
+
}
|
|
159
|
+
return t;
|
|
160
|
+
};
|
|
161
|
+
return __assign$7.apply(this, arguments);
|
|
162
|
+
};
|
|
163
|
+
function createEmotionCache() {
|
|
164
|
+
return createCache__default.default({
|
|
165
|
+
key: 'widget',
|
|
166
|
+
nonce: getNonce(),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
var cache = createEmotionCache();
|
|
170
|
+
function EmotionCacheProvider(_a) {
|
|
171
|
+
var children = _a.children;
|
|
172
|
+
return jsxRuntime.jsx(react$1.CacheProvider, __assign$7({ value: cache }, { children: children }));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/*
|
|
176
|
+
* Copyright 2022 Nordeck IT + Consulting GmbH
|
|
177
|
+
*
|
|
178
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
179
|
+
* you may not use this file except in compliance with the License.
|
|
180
|
+
* You may obtain a copy of the License at
|
|
181
|
+
*
|
|
182
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
183
|
+
*
|
|
184
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
185
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
186
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
187
|
+
* See the License for the specific language governing permissions and
|
|
188
|
+
* limitations under the License.
|
|
189
|
+
*/
|
|
190
|
+
var fontFamily = [
|
|
191
|
+
'Inter',
|
|
192
|
+
'Twemoji',
|
|
193
|
+
'"Apple Color Emoji"',
|
|
194
|
+
'"Segoe UI Emoji"',
|
|
195
|
+
'Arial',
|
|
196
|
+
'Helvetica',
|
|
197
|
+
'sans-serif',
|
|
198
|
+
'"Noto Color Emoji"',
|
|
199
|
+
].join(',');
|
|
200
|
+
var primaryColor = getEnvironment('REACT_APP_PRIMARY_COLOR', '#0dbd8b');
|
|
201
|
+
var primaryColorHighContrast = '#075D53';
|
|
202
|
+
var errorColor = '#ff5b55';
|
|
203
|
+
var errorColorHighContrast = '#AA0904';
|
|
204
|
+
function createSwitchStyleOverrides(_a) {
|
|
205
|
+
var trackColor = _a.trackColor, thumbColor = _a.thumbColor;
|
|
206
|
+
return {
|
|
207
|
+
root: function (_a) {
|
|
208
|
+
var theme = _a.theme;
|
|
209
|
+
return ({
|
|
210
|
+
width: 48,
|
|
211
|
+
height: 24,
|
|
212
|
+
padding: 0,
|
|
213
|
+
'& .MuiSwitch-switchBase': {
|
|
214
|
+
padding: 0,
|
|
215
|
+
margin: 2,
|
|
216
|
+
transitionDuration: '300ms',
|
|
217
|
+
'&.Mui-checked': {
|
|
218
|
+
transform: 'translateX(16px)',
|
|
219
|
+
color: '#fff',
|
|
220
|
+
'& + .MuiSwitch-track': {
|
|
221
|
+
backgroundColor: theme.palette.primary.main,
|
|
222
|
+
opacity: 1,
|
|
223
|
+
border: 0,
|
|
224
|
+
},
|
|
225
|
+
'&.Mui-disabled + .MuiSwitch-track': {
|
|
226
|
+
opacity: 0.5,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
'&.Mui-focusVisible .MuiSwitch-thumb': {
|
|
230
|
+
color: theme.palette.primary.main,
|
|
231
|
+
border: '6px solid #fff',
|
|
232
|
+
},
|
|
233
|
+
'&.Mui-disabled .MuiSwitch-thumb': {
|
|
234
|
+
color: thumbColor,
|
|
235
|
+
},
|
|
236
|
+
'&.Mui-disabled + .MuiSwitch-track': {
|
|
237
|
+
opacity: theme.palette.mode === 'light' ? 0.7 : 0.3,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
'& .MuiSwitch-thumb': {
|
|
241
|
+
boxSizing: 'border-box',
|
|
242
|
+
width: 20,
|
|
243
|
+
height: 20,
|
|
244
|
+
},
|
|
245
|
+
'& .MuiSwitch-track': {
|
|
246
|
+
borderRadius: 26 / 2,
|
|
247
|
+
backgroundColor: trackColor,
|
|
248
|
+
opacity: 1,
|
|
249
|
+
transition: theme.transitions.create(['background-color'], {
|
|
250
|
+
duration: 500,
|
|
251
|
+
}),
|
|
252
|
+
},
|
|
253
|
+
'& .MuiSwitch-switchBase.Mui-checked': {
|
|
254
|
+
transform: 'translateX(24px)',
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Create the default theme to use defaultTheme.typography.pxToRem to calculate
|
|
262
|
+
* font sizes.
|
|
263
|
+
*
|
|
264
|
+
* When using font sizes in our theme, we should always prefer relative units
|
|
265
|
+
* over absolute ones, so that a user can set a different base size in his
|
|
266
|
+
* browser settings.
|
|
267
|
+
*/
|
|
268
|
+
var defaultTheme = material.createTheme();
|
|
269
|
+
var baseTheme = {
|
|
270
|
+
shape: {
|
|
271
|
+
borderRadius: 8,
|
|
272
|
+
},
|
|
273
|
+
palette: {
|
|
274
|
+
primary: {
|
|
275
|
+
main: primaryColor,
|
|
276
|
+
contrastText: '#ffffff',
|
|
277
|
+
},
|
|
278
|
+
error: {
|
|
279
|
+
main: errorColor,
|
|
280
|
+
contrastText: '#ffffff',
|
|
281
|
+
},
|
|
282
|
+
tonalOffset: 0.025,
|
|
283
|
+
},
|
|
284
|
+
typography: {
|
|
285
|
+
fontFamily: fontFamily,
|
|
286
|
+
fontWeightLight: 400,
|
|
287
|
+
fontWeightMedium: 600,
|
|
288
|
+
fontWeightBold: 600,
|
|
289
|
+
body1: {
|
|
290
|
+
fontSize: defaultTheme.typography.pxToRem(15),
|
|
291
|
+
},
|
|
292
|
+
body2: {
|
|
293
|
+
fontSize: defaultTheme.typography.pxToRem(12),
|
|
294
|
+
},
|
|
295
|
+
button: {
|
|
296
|
+
fontSize: defaultTheme.typography.pxToRem(14),
|
|
297
|
+
textTransform: 'none',
|
|
298
|
+
},
|
|
299
|
+
h1: {
|
|
300
|
+
fontSize: defaultTheme.typography.pxToRem(28),
|
|
301
|
+
},
|
|
302
|
+
h2: {
|
|
303
|
+
fontSize: defaultTheme.typography.pxToRem(24),
|
|
304
|
+
},
|
|
305
|
+
h3: {
|
|
306
|
+
fontSize: defaultTheme.typography.pxToRem(20),
|
|
307
|
+
},
|
|
308
|
+
h4: {
|
|
309
|
+
fontSize: defaultTheme.typography.pxToRem(16),
|
|
310
|
+
},
|
|
311
|
+
h5: {
|
|
312
|
+
fontSize: defaultTheme.typography.pxToRem(15),
|
|
313
|
+
fontWeight: 600,
|
|
314
|
+
textTransform: 'none',
|
|
315
|
+
},
|
|
316
|
+
h6: {
|
|
317
|
+
fontSize: defaultTheme.typography.pxToRem(14),
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
components: {
|
|
321
|
+
// Additional text in Element alerts is a bit smaller
|
|
322
|
+
MuiAlert: {
|
|
323
|
+
styleOverrides: {
|
|
324
|
+
message: {
|
|
325
|
+
fontSize: defaultTheme.typography.pxToRem(12),
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
// We don't want to use sticky headers for list titles by default
|
|
330
|
+
MuiListSubheader: {
|
|
331
|
+
defaultProps: {
|
|
332
|
+
disableSticky: true,
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
// Use smaller text fields by default
|
|
336
|
+
MuiTextField: {
|
|
337
|
+
defaultProps: {
|
|
338
|
+
size: 'small',
|
|
339
|
+
// TODO: color: 'secondary',
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
MuiSelect: {
|
|
343
|
+
defaultProps: {
|
|
344
|
+
size: 'small',
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
// Dialogs have a different padding and font style
|
|
348
|
+
MuiDialog: {
|
|
349
|
+
styleOverrides: {
|
|
350
|
+
paper: function (_a) {
|
|
351
|
+
var theme = _a.theme;
|
|
352
|
+
return ({
|
|
353
|
+
margin: theme.breakpoints.down('xs') ? '8px' : undefined,
|
|
354
|
+
});
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
MuiDialogTitle: {
|
|
359
|
+
defaultProps: {
|
|
360
|
+
padding: [3],
|
|
361
|
+
fontSize: defaultTheme.typography.pxToRem(24),
|
|
362
|
+
fontWeight: 600,
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
MuiDialogActions: {
|
|
366
|
+
defaultProps: {
|
|
367
|
+
sx: { padding: 3 },
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
MuiBackdrop: {
|
|
371
|
+
styleOverrides: {
|
|
372
|
+
root: function (_a) {
|
|
373
|
+
var theme = _a.theme;
|
|
374
|
+
return ({
|
|
375
|
+
backgroundColor: theme.palette.mode === 'dark' ? '#000' : 'rgba(46,48,51,.38)',
|
|
376
|
+
opacity: 0.8,
|
|
377
|
+
});
|
|
378
|
+
},
|
|
379
|
+
invisible: {
|
|
380
|
+
backgroundColor: 'unset',
|
|
381
|
+
opacity: 'unset',
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
// Tooltips have a darker background
|
|
386
|
+
MuiTooltip: {
|
|
387
|
+
styleOverrides: {
|
|
388
|
+
tooltip: function (_a) {
|
|
389
|
+
var theme = _a.theme;
|
|
390
|
+
return ({
|
|
391
|
+
fontSize: defaultTheme.typography.pxToRem(12),
|
|
392
|
+
backgroundColor: 'rgb(33, 38, 44)',
|
|
393
|
+
padding: theme.spacing(1),
|
|
394
|
+
});
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
// Buttons have to ripple but have the default keyboard focus ring instead
|
|
399
|
+
MuiButtonBase: {
|
|
400
|
+
defaultProps: {
|
|
401
|
+
disableRipple: true,
|
|
402
|
+
},
|
|
403
|
+
styleOverrides: {
|
|
404
|
+
root: {
|
|
405
|
+
// Restore keyboard focus outline to the default browser value
|
|
406
|
+
'&.Mui-focusVisible': {
|
|
407
|
+
outline: 'revert',
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
MuiButton: {
|
|
413
|
+
defaultProps: {
|
|
414
|
+
disableElevation: true,
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
MuiButtonGroup: {
|
|
418
|
+
defaultProps: {
|
|
419
|
+
disableRipple: true,
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
// Make toggle buttons small by default
|
|
423
|
+
MuiToggleButton: {
|
|
424
|
+
defaultProps: {
|
|
425
|
+
size: 'small',
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
// Switches look different in Element, similar to the iOS one.
|
|
429
|
+
MuiSwitch: {
|
|
430
|
+
defaultProps: {
|
|
431
|
+
disableRipple: true,
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
MuiDivider: {
|
|
435
|
+
styleOverrides: {
|
|
436
|
+
withChildren: {
|
|
437
|
+
// Make sure it is possible to use an ellipsis inside the divider.
|
|
438
|
+
// This gives the children more space and less space to the divider
|
|
439
|
+
// itself.
|
|
440
|
+
'&::before, &::after': {
|
|
441
|
+
width: 'auto',
|
|
442
|
+
flexGrow: 1,
|
|
443
|
+
minWidth: '10%',
|
|
444
|
+
},
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
// Make sure that radios have a focus visible effect as we removed the ripple
|
|
449
|
+
MuiRadio: {
|
|
450
|
+
styleOverrides: {
|
|
451
|
+
root: {
|
|
452
|
+
'&.Mui-focusVisible svg:first-of-type': {
|
|
453
|
+
outlineColor: 'Highlight',
|
|
454
|
+
outlineStyle: 'auto',
|
|
455
|
+
outlineWidth: '2px',
|
|
456
|
+
// Things are doubled here because Highlight is only supported by
|
|
457
|
+
// Firefox
|
|
458
|
+
outline: 'auto 2px -webkit-focus-ring-color',
|
|
459
|
+
outlineOffset: -2,
|
|
460
|
+
borderRadius: '50%',
|
|
461
|
+
},
|
|
462
|
+
// Remove the ripple
|
|
463
|
+
'&:hover': {
|
|
464
|
+
bgcolor: 'transparent',
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
var lightTheme = {
|
|
472
|
+
palette: {
|
|
473
|
+
mode: 'light',
|
|
474
|
+
background: {
|
|
475
|
+
default: '#ffffff',
|
|
476
|
+
paper: '#f2f5f8',
|
|
477
|
+
},
|
|
478
|
+
text: {
|
|
479
|
+
primary: '#17191c',
|
|
480
|
+
secondary: '#61708b',
|
|
481
|
+
},
|
|
482
|
+
divider: '#e3e8f0',
|
|
483
|
+
},
|
|
484
|
+
components: {
|
|
485
|
+
// Switches look different in Element, similar to the iOS one.
|
|
486
|
+
MuiSwitch: {
|
|
487
|
+
styleOverrides: createSwitchStyleOverrides({
|
|
488
|
+
trackColor: '#E9E9EA',
|
|
489
|
+
thumbColor: defaultTheme.palette.grey[600],
|
|
490
|
+
}),
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
};
|
|
494
|
+
var lightHighContrastTheme = {
|
|
495
|
+
palette: {
|
|
496
|
+
mode: 'light',
|
|
497
|
+
// Choosing different colors to have the correct contrast
|
|
498
|
+
primary: {
|
|
499
|
+
main: primaryColorHighContrast,
|
|
500
|
+
},
|
|
501
|
+
error: {
|
|
502
|
+
main: errorColorHighContrast,
|
|
503
|
+
},
|
|
504
|
+
success: {
|
|
505
|
+
main: '#37623B',
|
|
506
|
+
},
|
|
507
|
+
warning: {
|
|
508
|
+
main: '#795015',
|
|
509
|
+
contrastText: '#ffffff',
|
|
510
|
+
},
|
|
511
|
+
info: {
|
|
512
|
+
main: '#025E88',
|
|
513
|
+
},
|
|
514
|
+
background: {
|
|
515
|
+
default: '#ffffff',
|
|
516
|
+
// We explicitly don't have a paper color and choose to add borders
|
|
517
|
+
// instead. Otherwise our colors would all have to compare their contrast
|
|
518
|
+
// to the paper color (the worst case).
|
|
519
|
+
paper: '#ffffff',
|
|
520
|
+
},
|
|
521
|
+
text: {
|
|
522
|
+
primary: '#101214',
|
|
523
|
+
secondary: '#3F4345',
|
|
524
|
+
},
|
|
525
|
+
action: {
|
|
526
|
+
active: '#5e6266',
|
|
527
|
+
},
|
|
528
|
+
divider: '#5e6266',
|
|
529
|
+
// Stronger tonal offset as the colors are darker and won't change that much.
|
|
530
|
+
tonalOffset: 0.2,
|
|
531
|
+
},
|
|
532
|
+
components: {
|
|
533
|
+
MuiCard: {
|
|
534
|
+
defaultProps: {
|
|
535
|
+
// We disabled the background, but can use the border instead.
|
|
536
|
+
variant: 'outlined',
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
MuiAlert: {
|
|
540
|
+
defaultProps: {
|
|
541
|
+
// We disabled the background, but can use the border instead.
|
|
542
|
+
variant: 'outlined',
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
MuiChip: {
|
|
546
|
+
defaultProps: {
|
|
547
|
+
// We disabled the background, but can use the border instead.
|
|
548
|
+
variant: 'outlined',
|
|
549
|
+
},
|
|
550
|
+
styleOverrides: {
|
|
551
|
+
// Make the border color and delete icon have a higher contrast
|
|
552
|
+
root: function (_a) {
|
|
553
|
+
var theme = _a.theme;
|
|
554
|
+
return ({
|
|
555
|
+
borderColor: theme.palette.divider,
|
|
556
|
+
'& .MuiChip-deleteIconOutlinedColorDefault': {
|
|
557
|
+
color: theme.palette.divider,
|
|
558
|
+
'&:hover': {
|
|
559
|
+
color: theme.palette.divider,
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
},
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
MuiInputBase: {
|
|
567
|
+
styleOverrides: {
|
|
568
|
+
input: {
|
|
569
|
+
// Contrast requirements of at least 4.5:1 are also required for
|
|
570
|
+
// placeholder text!
|
|
571
|
+
'&::placeholder': {
|
|
572
|
+
color: '#52575A',
|
|
573
|
+
opacity: 0.9,
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
MuiOutlinedInput: {
|
|
579
|
+
styleOverrides: {
|
|
580
|
+
notchedOutline: function (_a) {
|
|
581
|
+
var theme = _a.theme;
|
|
582
|
+
return ({
|
|
583
|
+
// Give inputs borders a higher contrast
|
|
584
|
+
borderColor: theme.palette.text.primary,
|
|
585
|
+
});
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
// Switches look different in Element, similar to the iOS one.
|
|
590
|
+
// The normal off color has no sufficient contrast
|
|
591
|
+
MuiSwitch: {
|
|
592
|
+
styleOverrides: createSwitchStyleOverrides({
|
|
593
|
+
trackColor: '#8293AB',
|
|
594
|
+
thumbColor: defaultTheme.palette.grey[100],
|
|
595
|
+
}),
|
|
596
|
+
},
|
|
597
|
+
// Make toggle buttons have more contrast for the selected state
|
|
598
|
+
MuiToggleButton: {
|
|
599
|
+
styleOverrides: {
|
|
600
|
+
root: function (_a) {
|
|
601
|
+
var theme = _a.theme, ownerState = _a.ownerState;
|
|
602
|
+
if (ownerState.disabled) {
|
|
603
|
+
// Keep original style
|
|
604
|
+
return {};
|
|
605
|
+
}
|
|
606
|
+
var selectedColor = ownerState.color === 'standard' || ownerState.color === undefined
|
|
607
|
+
? theme.palette.common.white
|
|
608
|
+
: theme.palette[ownerState.color].contrastText;
|
|
609
|
+
var selectedBackgroundColor = ownerState.color === 'standard' || ownerState.color === undefined
|
|
610
|
+
? theme.palette.grey['700']
|
|
611
|
+
: theme.palette[ownerState.color].main;
|
|
612
|
+
var selectedHoverBackgroundColor = ownerState.color === 'standard' || ownerState.color === undefined
|
|
613
|
+
? theme.palette.grey['800']
|
|
614
|
+
: theme.palette[ownerState.color].dark;
|
|
615
|
+
return {
|
|
616
|
+
'&.Mui-selected': {
|
|
617
|
+
backgroundColor: selectedBackgroundColor,
|
|
618
|
+
color: selectedColor,
|
|
619
|
+
'&:hover': {
|
|
620
|
+
backgroundColor: selectedHoverBackgroundColor,
|
|
621
|
+
},
|
|
622
|
+
},
|
|
623
|
+
};
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
};
|
|
629
|
+
var darkTheme = {
|
|
630
|
+
palette: {
|
|
631
|
+
mode: 'dark',
|
|
632
|
+
background: {
|
|
633
|
+
default: '#15191e',
|
|
634
|
+
paper: '#20252b',
|
|
635
|
+
},
|
|
636
|
+
text: {
|
|
637
|
+
primary: '#ffffff',
|
|
638
|
+
secondary: '#b9bec6',
|
|
639
|
+
},
|
|
640
|
+
divider: '#394049',
|
|
641
|
+
},
|
|
642
|
+
components: {
|
|
643
|
+
// Switches look different in Element, similar to the iOS one.
|
|
644
|
+
MuiSwitch: {
|
|
645
|
+
styleOverrides: createSwitchStyleOverrides({
|
|
646
|
+
trackColor: '#39393D',
|
|
647
|
+
thumbColor: defaultTheme.palette.grey[600],
|
|
648
|
+
}),
|
|
649
|
+
},
|
|
650
|
+
},
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
var __assign$6 = (undefined && undefined.__assign) || function () {
|
|
654
|
+
__assign$6 = Object.assign || function(t) {
|
|
655
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
656
|
+
s = arguments[i];
|
|
657
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
658
|
+
t[p] = s[p];
|
|
659
|
+
}
|
|
660
|
+
return t;
|
|
661
|
+
};
|
|
662
|
+
return __assign$6.apply(this, arguments);
|
|
663
|
+
};
|
|
664
|
+
/**
|
|
665
|
+
* Provide a semantic UI based theme to the child components.
|
|
666
|
+
* @param param0 - {@link MuiThemeProviderProps}
|
|
667
|
+
*/
|
|
668
|
+
function MuiThemeProvider(_a) {
|
|
669
|
+
var children = _a.children;
|
|
670
|
+
return (jsxRuntime.jsx(EmotionCacheProvider, { children: jsxRuntime.jsx(react.ThemeSelectionProvider, { children: jsxRuntime.jsx(ElementMuiThemeProvider, { children: children }) }) }));
|
|
671
|
+
}
|
|
672
|
+
function chooseTheme(theme) {
|
|
673
|
+
var isDark = theme === 'dark';
|
|
674
|
+
var isForceHighContrast = !!getEnvironment('REACT_APP_FORCE_HIGH_CONTRAST_THEME');
|
|
675
|
+
var isHighContrast = isForceHighContrast || theme === 'light-high-contrast';
|
|
676
|
+
if (isDark) {
|
|
677
|
+
return darkTheme;
|
|
678
|
+
}
|
|
679
|
+
else if (isHighContrast) {
|
|
680
|
+
return lightHighContrastTheme;
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
return lightTheme;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
function ElementMuiThemeProvider(_a) {
|
|
687
|
+
var _b;
|
|
688
|
+
var children = _a.children;
|
|
689
|
+
var theme = react.useThemeSelection().theme;
|
|
690
|
+
var _c = react$2.useState((_b = i18n__default.default.languages) === null || _b === void 0 ? void 0 : _b[0]), locale$1 = _c[0], setLocale = _c[1];
|
|
691
|
+
react$2.useEffect(function () {
|
|
692
|
+
var callback = function () { return setLocale(i18n__default.default.languages[0]); };
|
|
693
|
+
i18n__default.default.on('languageChanged', callback);
|
|
694
|
+
return function () { return i18n__default.default.off('languageChanged', callback); };
|
|
695
|
+
}, []);
|
|
696
|
+
var muiTheme = react$2.useMemo(function () {
|
|
697
|
+
var themeOptions = chooseTheme(theme);
|
|
698
|
+
var localeOptions = locale$1 === 'de' ? locale.deDE : locale.enUS;
|
|
699
|
+
return material.createTheme(utils.deepmerge(baseTheme, themeOptions), localeOptions);
|
|
700
|
+
}, [locale$1, theme]);
|
|
701
|
+
return (jsxRuntime.jsxs(material.ThemeProvider, __assign$6({ theme: muiTheme }, { children: [jsxRuntime.jsx(material.CssBaseline, {}), children] })));
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
var __assign$5 = (undefined && undefined.__assign) || function () {
|
|
705
|
+
__assign$5 = Object.assign || function(t) {
|
|
706
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
707
|
+
s = arguments[i];
|
|
708
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
709
|
+
t[p] = s[p];
|
|
710
|
+
}
|
|
711
|
+
return t;
|
|
712
|
+
};
|
|
713
|
+
return __assign$5.apply(this, arguments);
|
|
714
|
+
};
|
|
715
|
+
function CopyableCode(_a) {
|
|
716
|
+
var code = _a.code;
|
|
717
|
+
var t = reactI18next.useTranslation('widget-toolkit').t;
|
|
718
|
+
var _b = react$2.useState(false), hasCopied = _b[0], setHasCopied = _b[1];
|
|
719
|
+
var _c = reactUse.useCopyToClipboard(), copyToClipboard = _c[1];
|
|
720
|
+
return (jsxRuntime.jsx(material.Paper, __assign$5({ sx: { position: 'relative' } }, { children: jsxRuntime.jsxs(material.Box, __assign$5({ sx: { overflowY: 'auto' } }, { children: [jsxRuntime.jsx(material.Box, __assign$5({ component: "code", sx: { userSelect: 'all' }, m: 0 }, { children: jsxRuntime.jsx(material.Box, __assign$5({ component: "pre", m: 2 }, { children: code })) })), jsxRuntime.jsx(material.IconButton, __assign$5({ sx: function (theme) { return ({
|
|
721
|
+
position: 'absolute',
|
|
722
|
+
right: theme.spacing(1),
|
|
723
|
+
bottom: theme.spacing(1),
|
|
724
|
+
}); }, onClick: function () {
|
|
725
|
+
copyToClipboard(code);
|
|
726
|
+
setHasCopied(true);
|
|
727
|
+
}, onBlur: function () { return setHasCopied(false); }, "aria-label": t('code.copy-to-clipboard', 'Copy to clipboard') }, { children: hasCopied ? jsxRuntime.jsx(CheckOutlinedIcon__default.default, {}) : jsxRuntime.jsx(ContentCopyOutlinedIcon__default.default, {}) }))] })) })));
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
var __assign$4 = (undefined && undefined.__assign) || function () {
|
|
731
|
+
__assign$4 = Object.assign || function(t) {
|
|
732
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
733
|
+
s = arguments[i];
|
|
734
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
735
|
+
t[p] = s[p];
|
|
736
|
+
}
|
|
737
|
+
return t;
|
|
738
|
+
};
|
|
739
|
+
return __assign$4.apply(this, arguments);
|
|
740
|
+
};
|
|
741
|
+
function ChildError(_a) {
|
|
742
|
+
var _b;
|
|
743
|
+
var error = _a.error;
|
|
744
|
+
var t = reactI18next.useTranslation('widget-toolkit').t;
|
|
745
|
+
return (jsxRuntime.jsx(material.Box, __assign$4({ my: 2 }, { children: jsxRuntime.jsxs(material.Alert, __assign$4({ severity: "error", icon: jsxRuntime.jsx(ErrorIcon__default.default, {}) }, { children: [jsxRuntime.jsx(material.AlertTitle, { children: t('error.title', 'Ohh no!') }), jsxRuntime.jsx(material.Typography, __assign$4({ variant: "body2" }, { children: t('error.instructions', 'An error occured inside the widget. You can try to reopen the widget.') })), jsxRuntime.jsx(material.Box, __assign$4({ mt: 1 }, { children: jsxRuntime.jsx(CopyableCode, { code: "".concat((_b = error.stack) !== null && _b !== void 0 ? _b : error) }) }))] })) })));
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
var __assign$3 = (undefined && undefined.__assign) || function () {
|
|
749
|
+
__assign$3 = Object.assign || function(t) {
|
|
750
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
751
|
+
s = arguments[i];
|
|
752
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
753
|
+
t[p] = s[p];
|
|
754
|
+
}
|
|
755
|
+
return t;
|
|
756
|
+
};
|
|
757
|
+
return __assign$3.apply(this, arguments);
|
|
758
|
+
};
|
|
759
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
760
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
761
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
762
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
763
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
764
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
765
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
766
|
+
});
|
|
767
|
+
};
|
|
768
|
+
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
769
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
770
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
771
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
772
|
+
function step(op) {
|
|
773
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
774
|
+
while (_) try {
|
|
775
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
776
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
777
|
+
switch (op[0]) {
|
|
778
|
+
case 0: case 1: t = op; break;
|
|
779
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
780
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
781
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
782
|
+
default:
|
|
783
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
784
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
785
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
786
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
787
|
+
if (t[2]) _.ops.pop();
|
|
788
|
+
_.trys.pop(); continue;
|
|
789
|
+
}
|
|
790
|
+
op = body.call(thisArg, _);
|
|
791
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
792
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
function MissingParametersError(_a) {
|
|
796
|
+
var _this = this;
|
|
797
|
+
var widgetRegistration = _a.widgetRegistration;
|
|
798
|
+
var t = reactI18next.useTranslation('widget-toolkit').t;
|
|
799
|
+
var widgetApi = react.useWidgetApi();
|
|
800
|
+
var _b = react$2.useState(false), isErrorDialogOpen = _b[0], setErrorDialogOpen = _b[1];
|
|
801
|
+
var _c = react$2.useState(false), isCompleted = _c[0], setCompleted = _c[1];
|
|
802
|
+
var handleRepairWidget = react$2.useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
803
|
+
return __generator(this, function (_b) {
|
|
804
|
+
switch (_b.label) {
|
|
805
|
+
case 0:
|
|
806
|
+
_b.trys.push([0, 2, , 3]);
|
|
807
|
+
return [4 /*yield*/, api.repairWidgetRegistration(widgetApi, widgetRegistration)];
|
|
808
|
+
case 1:
|
|
809
|
+
_b.sent();
|
|
810
|
+
setCompleted(true);
|
|
811
|
+
return [3 /*break*/, 3];
|
|
812
|
+
case 2:
|
|
813
|
+
_b.sent();
|
|
814
|
+
setErrorDialogOpen(true);
|
|
815
|
+
return [3 /*break*/, 3];
|
|
816
|
+
case 3: return [2 /*return*/];
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
}); }, [widgetApi, widgetRegistration]);
|
|
820
|
+
var errorDialogTitleId = utils.unstable_useId();
|
|
821
|
+
var errorDialogTextId = utils.unstable_useId();
|
|
822
|
+
var successDialogTitleId = utils.unstable_useId();
|
|
823
|
+
var successDialogTextId = utils.unstable_useId();
|
|
824
|
+
return (jsxRuntime.jsxs(material.Box, __assign$3({ my: 2 }, { children: [jsxRuntime.jsxs(material.Alert, __assign$3({ severity: "error", icon: jsxRuntime.jsx(ErrorIcon__default.default, {}) }, { children: [jsxRuntime.jsx(material.AlertTitle, { children: t('missing-parameters.title', 'Wrong widget registration') }), jsxRuntime.jsx(material.Typography, __assign$3({ variant: "body2" }, { children: t('missing-parameters.instructions', 'The widget is not registered correctly. Make sure to include the correct parameters in the widget URL:') })), jsxRuntime.jsx(material.Box, __assign$3({ my: 1 }, { children: jsxRuntime.jsx(CopyableCode, { code: api.generateWidgetRegistrationUrl() }) })), jsxRuntime.jsx(material.Typography, __assign$3({ variant: "body2" }, { children: t('missing-parameters.repair-instructions', 'You can either modify the widget registration manually or fix it automatically:') })), jsxRuntime.jsx(material.Box, __assign$3({ mt: 1 }, { children: jsxRuntime.jsx(material.Button, __assign$3({ variant: "contained", onClick: handleRepairWidget }, { children: t('missing-parameters.repair', 'Repair registration') })) }))] })), jsxRuntime.jsxs(material.Dialog, __assign$3({ open: isErrorDialogOpen, onClose: function () { return setErrorDialogOpen(false); }, "aria-labelledby": errorDialogTitleId, "aria-describedby": errorDialogTextId }, { children: [jsxRuntime.jsx(material.DialogTitle, __assign$3({ id: errorDialogTitleId }, { children: t('missing-parameters.permissions-error.title', 'Error') })), jsxRuntime.jsx(material.DialogContent, { children: jsxRuntime.jsx(material.DialogContentText, __assign$3({ id: errorDialogTextId }, { children: t('missing-parameters.permissions-error.instructions', 'Insufficient permissions, could not configure widget. Only room admins can configure the widget.') })) }), jsxRuntime.jsx(material.DialogActions, { children: jsxRuntime.jsx(material.Button, __assign$3({ onClick: function () { return setErrorDialogOpen(false); }, autoFocus: true }, { children: t('missing-parameters.permissions-error.close', 'Close') })) })] })), jsxRuntime.jsxs(material.Dialog, __assign$3({ open: isCompleted, "aria-labelledby": successDialogTitleId, "aria-describedby": successDialogTextId }, { children: [jsxRuntime.jsx(material.DialogTitle, __assign$3({ id: successDialogTitleId }, { children: t('missing-parameters.completed.title', 'Widget configuration complete') })), jsxRuntime.jsx(material.DialogContent, { children: jsxRuntime.jsx(material.DialogContentText, __assign$3({ id: successDialogTextId }, { children: t('missing-parameters.completed.instructions', 'Configuration completed, reopen the widget to start using it.') })) })] }))] })));
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
var __assign$2 = (undefined && undefined.__assign) || function () {
|
|
828
|
+
__assign$2 = Object.assign || function(t) {
|
|
829
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
830
|
+
s = arguments[i];
|
|
831
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
832
|
+
t[p] = s[p];
|
|
833
|
+
}
|
|
834
|
+
return t;
|
|
835
|
+
};
|
|
836
|
+
return __assign$2.apply(this, arguments);
|
|
837
|
+
};
|
|
838
|
+
function MobileClientError() {
|
|
839
|
+
var t = reactI18next.useTranslation('widget-toolkit').t;
|
|
840
|
+
return (jsxRuntime.jsx(material.Box, __assign$2({ m: 2 }, { children: jsxRuntime.jsxs(material.Alert, __assign$2({ severity: "error", icon: jsxRuntime.jsx(ErrorIcon__default.default, {}) }, { children: [jsxRuntime.jsx(material.AlertTitle, { children: t('mobile-client.title', 'Mobile clients are not supported') }), t('mobile-client.instructions', "The widget doesn't work in mobile clients due to technical limitations. Open the widget on you Desktop or Web client.")] })) })));
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
var __assign$1 = (undefined && undefined.__assign) || function () {
|
|
844
|
+
__assign$1 = Object.assign || function(t) {
|
|
845
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
846
|
+
s = arguments[i];
|
|
847
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
848
|
+
t[p] = s[p];
|
|
849
|
+
}
|
|
850
|
+
return t;
|
|
851
|
+
};
|
|
852
|
+
return __assign$1.apply(this, arguments);
|
|
853
|
+
};
|
|
854
|
+
function OutsideClientError() {
|
|
855
|
+
var t = reactI18next.useTranslation('widget-toolkit').t;
|
|
856
|
+
return (jsxRuntime.jsx(material.Box, __assign$1({ m: 2 }, { children: jsxRuntime.jsxs(material.Alert, __assign$1({ severity: "error", icon: jsxRuntime.jsx(ErrorIcon__default.default, {}) }, { children: [jsxRuntime.jsx(material.AlertTitle, { children: t('outside-client.title', 'Only runs as a widget') }), jsxRuntime.jsx(material.Typography, __assign$1({ variant: "body2" }, { children: t('outside-client.instructions', "You need to register this URL as a widget, it's not possible to use it standalone. Run this command in the matrix room you want to register the widget in:") })), jsxRuntime.jsx(material.Box, __assign$1({ mt: 1 }, { children: jsxRuntime.jsx(CopyableCode, { code: "/addwidget ".concat(api.generateWidgetRegistrationUrl({
|
|
857
|
+
includeParameters: false,
|
|
858
|
+
})) }) }))] })) })));
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
862
|
+
__assign = Object.assign || function(t) {
|
|
863
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
864
|
+
s = arguments[i];
|
|
865
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
866
|
+
t[p] = s[p];
|
|
867
|
+
}
|
|
868
|
+
return t;
|
|
869
|
+
};
|
|
870
|
+
return __assign.apply(this, arguments);
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* Provides the `WidgetApi` in the React context once it's fully
|
|
874
|
+
* initialized without errors.
|
|
875
|
+
* Use `useWidgetApi` to access it.
|
|
876
|
+
* @param param0 - {@link MuiWidgetApiProviderProps}
|
|
877
|
+
*/
|
|
878
|
+
function MuiWidgetApiProvider(_a) {
|
|
879
|
+
var widgetRegistration = _a.widgetRegistration, widgetApiPromise = _a.widgetApiPromise, children = _a.children;
|
|
880
|
+
return (jsxRuntime.jsx(react.WidgetApiProvider, __assign({ widgetApiPromise: widgetApiPromise, widgetRegistration: widgetRegistration, loadingViewComponent: LoadingView, mobileClientErrorComponent: MobileClientError, childErrorComponent: ChildError, outsideClientErrorComponent: OutsideClientError, missingCapabilitiesComponent: MissingCapabilitiesError, missingParametersErrorComponent: MissingParametersError }, { children: children })));
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/*
|
|
884
|
+
* Copyright 2022 Nordeck IT + Consulting GmbH
|
|
885
|
+
*
|
|
886
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
887
|
+
* you may not use this file except in compliance with the License.
|
|
888
|
+
* You may obtain a copy of the License at
|
|
889
|
+
*
|
|
890
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
891
|
+
*
|
|
892
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
893
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
894
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
895
|
+
* See the License for the specific language governing permissions and
|
|
896
|
+
* limitations under the License.
|
|
897
|
+
*/
|
|
898
|
+
var __extends = (undefined && undefined.__extends) || (function () {
|
|
899
|
+
var extendStatics = function (d, b) {
|
|
900
|
+
extendStatics = Object.setPrototypeOf ||
|
|
901
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
902
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
903
|
+
return extendStatics(d, b);
|
|
904
|
+
};
|
|
905
|
+
return function (d, b) {
|
|
906
|
+
if (typeof b !== "function" && b !== null)
|
|
907
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
908
|
+
extendStatics(d, b);
|
|
909
|
+
function __() { this.constructor = d; }
|
|
910
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
911
|
+
};
|
|
912
|
+
})();
|
|
913
|
+
/**
|
|
914
|
+
* Backend for usage with `i18n-next` that provides translations for internal
|
|
915
|
+
* messages.
|
|
916
|
+
*/
|
|
917
|
+
var WidgetToolkitI18nBackend = resourcesToBackend__default.default(function (lng, ns, clb) {
|
|
918
|
+
import("../locales/".concat(lng, "/").concat(ns, ".json"))
|
|
919
|
+
.then(function (resources) { return clb(null, resources); })
|
|
920
|
+
.catch(function (err) { return clb(err, undefined); });
|
|
921
|
+
});
|
|
922
|
+
/**
|
|
923
|
+
* A language detector that reads the language from the widget url.
|
|
924
|
+
*/
|
|
925
|
+
var WidgetApiLanguageDetector = /** @class */ (function (_super) {
|
|
926
|
+
__extends(WidgetApiLanguageDetector, _super);
|
|
927
|
+
function WidgetApiLanguageDetector() {
|
|
928
|
+
var _this = _super.call(this, undefined, {
|
|
929
|
+
// prefer the widget api and fallback to the browser settings.
|
|
930
|
+
order: ['widgetApi', 'navigator'],
|
|
931
|
+
}) || this;
|
|
932
|
+
var widgetApiLanguageDetector = {
|
|
933
|
+
name: 'widgetApi',
|
|
934
|
+
lookup: function () {
|
|
935
|
+
var clientLanguage = api.extractWidgetParameters().clientLanguage;
|
|
936
|
+
return clientLanguage;
|
|
937
|
+
},
|
|
938
|
+
};
|
|
939
|
+
_this.addDetector(widgetApiLanguageDetector);
|
|
940
|
+
return _this;
|
|
941
|
+
}
|
|
942
|
+
return WidgetApiLanguageDetector;
|
|
943
|
+
}(LanguageDetector__default.default));
|
|
944
|
+
|
|
945
|
+
exports.MuiCapabilitiesGuard = MuiCapabilitiesGuard;
|
|
946
|
+
exports.MuiThemeProvider = MuiThemeProvider;
|
|
947
|
+
exports.MuiWidgetApiProvider = MuiWidgetApiProvider;
|
|
948
|
+
exports.WidgetApiLanguageDetector = WidgetApiLanguageDetector;
|
|
949
|
+
exports.WidgetToolkitI18nBackend = WidgetToolkitI18nBackend;
|
|
950
|
+
exports.getEnvironment = getEnvironment;
|
|
951
|
+
exports.getNonce = getNonce;
|