@popmenu/audio-player 0.126.0 → 0.126.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.
Files changed (47) hide show
  1. package/build/{components → cjs/components}/AudioPlayer/AudioPlayer.d.ts +3 -3
  2. package/build/{components → cjs/components}/AudioPlayer/AudioPlayerProps.d.ts +10 -10
  3. package/build/{components → cjs/components}/AudioPlayer/index.d.ts +2 -2
  4. package/build/{components → cjs/components}/AudioPlayer/util/audioPlayerReducer.d.ts +11 -11
  5. package/build/{components → cjs/components}/AudioPlayer/util/formatTime.d.ts +1 -1
  6. package/build/{components → cjs/components}/AudioPlayer/util/index.d.ts +5 -5
  7. package/build/{components → cjs/components}/AudioPlayer/util/setupAudioRef.d.ts +8 -8
  8. package/build/{components → cjs/components}/AudioPlayer/util/types.d.ts +77 -77
  9. package/build/{components → cjs/components}/AudioPlayer/util/useVolumeIcon.d.ts +2 -2
  10. package/build/{components → cjs/components}/index.d.ts +1 -1
  11. package/build/{index.d.ts → cjs/index.d.ts} +1 -1
  12. package/build/cjs/index.js +341 -0
  13. package/build/cjs/index.js.map +1 -0
  14. package/build/esm/_virtual/index.js +4 -0
  15. package/build/esm/_virtual/index.js.map +1 -0
  16. package/build/esm/components/AudioPlayer/AudioPlayer.d.ts +3 -0
  17. package/build/esm/components/AudioPlayer/AudioPlayer.js +67 -0
  18. package/build/esm/components/AudioPlayer/AudioPlayer.js.map +1 -0
  19. package/build/esm/components/AudioPlayer/AudioPlayerProps.d.ts +10 -0
  20. package/build/esm/components/AudioPlayer/index.d.ts +2 -0
  21. package/build/esm/components/AudioPlayer/util/audioPlayerReducer.d.ts +11 -0
  22. package/build/esm/components/AudioPlayer/util/audioPlayerReducer.js +113 -0
  23. package/build/esm/components/AudioPlayer/util/audioPlayerReducer.js.map +1 -0
  24. package/build/esm/components/AudioPlayer/util/formatTime.d.ts +1 -0
  25. package/build/esm/components/AudioPlayer/util/formatTime.js +13 -0
  26. package/build/esm/components/AudioPlayer/util/formatTime.js.map +1 -0
  27. package/build/esm/components/AudioPlayer/util/index.d.ts +5 -0
  28. package/build/esm/components/AudioPlayer/util/setupAudioRef.d.ts +8 -0
  29. package/build/esm/components/AudioPlayer/util/setupAudioRef.js +34 -0
  30. package/build/esm/components/AudioPlayer/util/setupAudioRef.js.map +1 -0
  31. package/build/esm/components/AudioPlayer/util/types.d.ts +77 -0
  32. package/build/esm/components/AudioPlayer/util/types.js +33 -0
  33. package/build/esm/components/AudioPlayer/util/types.js.map +1 -0
  34. package/build/esm/components/AudioPlayer/util/useVolumeIcon.d.ts +2 -0
  35. package/build/esm/components/AudioPlayer/util/useVolumeIcon.js +23 -0
  36. package/build/esm/components/AudioPlayer/util/useVolumeIcon.js.map +1 -0
  37. package/build/esm/components/index.d.ts +1 -0
  38. package/build/esm/index.d.ts +1 -0
  39. package/build/esm/index.js +2 -0
  40. package/build/esm/index.js.map +1 -0
  41. package/build/esm/node_modules/classnames/index.js +81 -0
  42. package/build/esm/node_modules/classnames/index.js.map +1 -0
  43. package/package.json +8 -5
  44. package/build/index.es.js +0 -1258
  45. package/build/index.es.js.map +0 -1
  46. package/build/index.js +0 -1295
  47. package/build/index.js.map +0 -1
package/build/index.es.js DELETED
@@ -1,1258 +0,0 @@
1
- import * as React from 'react';
2
- import React__default, { createElement, forwardRef, createContext, useRef, useState, useReducer, useEffect, useMemo } from 'react';
3
- import { makeStyles, Typography as Typography$1, Link as Link$1, Paper as Paper$1, useTheme, Box, Popper, Grow, Slider } from '@material-ui/core';
4
- import '@material-ui/lab/Alert';
5
- import '@material-ui/core/AppBar';
6
- import MuiAvatar from '@material-ui/core/Avatar';
7
- import { makeStyles as makeStyles$1 } from '@material-ui/core/styles';
8
- import '@material-ui/core/Badge';
9
- import '@material-ui/core/Button';
10
- import '@material-ui/core/CircularProgress';
11
- import '@material-ui/core/ButtonGroup';
12
- import '@material-ui/core/Card';
13
- import '@material-ui/core/CardActionArea';
14
- import '@material-ui/core/CardActions';
15
- import '@material-ui/core/CardContent';
16
- import '@material-ui/core/CardHeader';
17
- import '@material-ui/core/CardMedia';
18
- import MuiCheckbox from '@material-ui/core/Checkbox';
19
- import FormControlLabel from '@material-ui/core/FormControlLabel';
20
- import '@material-ui/core/Chip';
21
- import '@material-ui/core/Collapse';
22
- import '@material-ui/core/Dialog';
23
- import '@material-ui/core/DialogActions';
24
- import '@material-ui/core/DialogContent';
25
- import '@material-ui/core/DialogTitle';
26
- import '@material-ui/core/Drawer';
27
- import '@material-ui/core/FormControl';
28
- import '@material-ui/core/Grid';
29
- import MuiIconButton from '@material-ui/core/IconButton';
30
- import '@material-ui/core/InputAdornment';
31
- import '@material-ui/core/LinearProgress';
32
- import '@material-ui/core/List';
33
- import '@material-ui/core/ListItem';
34
- import '@material-ui/core/ListItemAvatar';
35
- import '@material-ui/core/ListItemIcon';
36
- import '@material-ui/core/ListItemSecondaryAction';
37
- import '@material-ui/core/ListItemText';
38
- import '@material-ui/core/Menu';
39
- import '@material-ui/core/MenuItem';
40
- import '@material-ui/core/MenuList';
41
- import MuiRadio from '@material-ui/core/Radio';
42
- import '@material-ui/core/TextField';
43
- import MuiSwitch from '@material-ui/core/Switch';
44
- import '@material-ui/core/Tab';
45
- import '@material-ui/core/Tabs';
46
- import MuiToggleButton from '@material-ui/lab/ToggleButton';
47
- import MuiToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
48
- import MuiTooltip from '@material-ui/core/Tooltip';
49
-
50
- /*! *****************************************************************************
51
- Copyright (c) Microsoft Corporation.
52
-
53
- Permission to use, copy, modify, and/or distribute this software for any
54
- purpose with or without fee is hereby granted.
55
-
56
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
57
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
58
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
59
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
60
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
61
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
62
- PERFORMANCE OF THIS SOFTWARE.
63
- ***************************************************************************** */
64
-
65
- var __assign$1 = function() {
66
- __assign$1 = Object.assign || function __assign(t) {
67
- for (var s, i = 1, n = arguments.length; i < n; i++) {
68
- s = arguments[i];
69
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
70
- }
71
- return t;
72
- };
73
- return __assign$1.apply(this, arguments);
74
- };
75
-
76
- var classnames$1 = {exports: {}};
77
-
78
- /*!
79
- Copyright (c) 2018 Jed Watson.
80
- Licensed under the MIT License (MIT), see
81
- http://jedwatson.github.io/classnames
82
- */
83
-
84
- (function (module) {
85
- /* global define */
86
-
87
- (function () {
88
-
89
- var hasOwn = {}.hasOwnProperty;
90
-
91
- function classNames() {
92
- var classes = [];
93
-
94
- for (var i = 0; i < arguments.length; i++) {
95
- var arg = arguments[i];
96
- if (!arg) continue;
97
-
98
- var argType = typeof arg;
99
-
100
- if (argType === 'string' || argType === 'number') {
101
- classes.push(arg);
102
- } else if (Array.isArray(arg)) {
103
- if (arg.length) {
104
- var inner = classNames.apply(null, arg);
105
- if (inner) {
106
- classes.push(inner);
107
- }
108
- }
109
- } else if (argType === 'object') {
110
- if (arg.toString === Object.prototype.toString) {
111
- for (var key in arg) {
112
- if (hasOwn.call(arg, key) && arg[key]) {
113
- classes.push(key);
114
- }
115
- }
116
- } else {
117
- classes.push(arg.toString());
118
- }
119
- }
120
- }
121
-
122
- return classes.join(' ');
123
- }
124
-
125
- if (module.exports) {
126
- classNames.default = classNames;
127
- module.exports = classNames;
128
- } else {
129
- window.classNames = classNames;
130
- }
131
- }());
132
- }(classnames$1));
133
-
134
- var classNames$1 = classnames$1.exports;
135
-
136
- var _path$Q;
137
-
138
- function _extends$21() { _extends$21 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$21.apply(this, arguments); }
139
-
140
- function SvgPause(props) {
141
- return /*#__PURE__*/React.createElement("svg", _extends$21({
142
- viewBox: "0 0 16 16",
143
- fill: "none",
144
- strokeLinecap: "round",
145
- strokeLinejoin: "round",
146
- width: "1em",
147
- height: "1em"
148
- }, props), _path$Q || (_path$Q = /*#__PURE__*/React.createElement("path", {
149
- d: "M6.667 2.667H4v10.666h2.667V2.666zm5.333 0H9.333v10.666H12V2.666z",
150
- stroke: "currentColor"
151
- })));
152
- }
153
-
154
- var _path$P;
155
-
156
- function _extends$1$() { _extends$1$ = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1$.apply(this, arguments); }
157
-
158
- function SvgPlay(props) {
159
- return /*#__PURE__*/React.createElement("svg", _extends$1$({
160
- viewBox: "0 0 16 16",
161
- fill: "none",
162
- strokeLinecap: "round",
163
- strokeLinejoin: "round",
164
- width: "1em",
165
- height: "1em"
166
- }, props), _path$P || (_path$P = /*#__PURE__*/React.createElement("path", {
167
- d: "M3.333 2l9.334 6-9.334 6V2z",
168
- stroke: "currentColor"
169
- })));
170
- }
171
-
172
- var _path$I;
173
-
174
- function _extends$1O() { _extends$1O = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1O.apply(this, arguments); }
175
-
176
- function SvgVolumeDown(props) {
177
- return /*#__PURE__*/React.createElement("svg", _extends$1O({
178
- viewBox: "0 0 16 16",
179
- fill: "none",
180
- strokeLinecap: "round",
181
- strokeLinejoin: "round",
182
- width: "1em",
183
- height: "1em"
184
- }, props), _path$I || (_path$I = /*#__PURE__*/React.createElement("path", {
185
- d: "M8.999 3.333L5.665 6H3v4h2.666L9 12.667V3.333zm3.026 2.307a3.333 3.333 0 010 4.714",
186
- stroke: "currentColor"
187
- })));
188
- }
189
-
190
- var _path$H;
191
-
192
- function _extends$1N() { _extends$1N = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1N.apply(this, arguments); }
193
-
194
- function SvgVolumeMute(props) {
195
- return /*#__PURE__*/React.createElement("svg", _extends$1N({
196
- viewBox: "0 0 16 16",
197
- fill: "none",
198
- strokeLinecap: "round",
199
- strokeLinejoin: "round",
200
- width: "1em",
201
- height: "1em"
202
- }, props), _path$H || (_path$H = /*#__PURE__*/React.createElement("path", {
203
- d: "M7.333 3.333L4 6H1.333v4H4l3.333 2.667V3.333z",
204
- stroke: "currentColor"
205
- })));
206
- }
207
-
208
- var _path$G;
209
-
210
- function _extends$1M() { _extends$1M = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1M.apply(this, arguments); }
211
-
212
- function SvgVolumeOff(props) {
213
- return /*#__PURE__*/React.createElement("svg", _extends$1M({
214
- viewBox: "0 0 16 16",
215
- fill: "none",
216
- strokeLinecap: "round",
217
- strokeLinejoin: "round",
218
- width: "1em",
219
- height: "1em"
220
- }, props), _path$G || (_path$G = /*#__PURE__*/React.createElement("path", {
221
- d: "M7.333 3.333L4 6H1.333v4H4l3.333 2.667V3.333zm8 2.667l-4 4m0-4l4 4",
222
- stroke: "currentColor"
223
- })));
224
- }
225
-
226
- var _path$F;
227
-
228
- function _extends$1L() { _extends$1L = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1L.apply(this, arguments); }
229
-
230
- function SvgVolumeUp(props) {
231
- return /*#__PURE__*/React.createElement("svg", _extends$1L({
232
- viewBox: "0 0 16 16",
233
- fill: "none",
234
- strokeLinecap: "round",
235
- strokeLinejoin: "round",
236
- width: "1em",
237
- height: "1em"
238
- }, props), _path$F || (_path$F = /*#__PURE__*/React.createElement("path", {
239
- d: "M7.333 3.333L4 6H1.333v4H4l3.333 2.667V3.333zm5.38-.046a6.667 6.667 0 010 9.426M10.36 5.64a3.333 3.333 0 010 4.713",
240
- stroke: "currentColor"
241
- })));
242
- }
243
-
244
- /*! *****************************************************************************
245
- Copyright (c) Microsoft Corporation.
246
-
247
- Permission to use, copy, modify, and/or distribute this software for any
248
- purpose with or without fee is hereby granted.
249
-
250
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
251
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
252
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
253
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
254
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
255
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
256
- PERFORMANCE OF THIS SOFTWARE.
257
- ***************************************************************************** */
258
-
259
- var __assign = function() {
260
- __assign = Object.assign || function __assign(t) {
261
- for (var s, i = 1, n = arguments.length; i < n; i++) {
262
- s = arguments[i];
263
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
264
- }
265
- return t;
266
- };
267
- return __assign.apply(this, arguments);
268
- };
269
-
270
- function __rest(s, e) {
271
- var t = {};
272
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
273
- t[p] = s[p];
274
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
275
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
276
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
277
- t[p[i]] = s[p[i]];
278
- }
279
- return t;
280
- }
281
-
282
- var _path$1D;
283
-
284
- function _extends$3H() { _extends$3H = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3H.apply(this, arguments); }
285
-
286
- function SvgUser(props) {
287
- return /*#__PURE__*/React.createElement("svg", _extends$3H({
288
- viewBox: "0 0 16 16",
289
- fill: "none",
290
- strokeLinecap: "round",
291
- strokeLinejoin: "round",
292
- width: "1em",
293
- height: "1em"
294
- }, props), _path$1D || (_path$1D = /*#__PURE__*/React.createElement("path", {
295
- d: "M13.333 14v-1.333A2.667 2.667 0 0010.667 10H5.333a2.667 2.667 0 00-2.666 2.667V14M8 7.333A2.667 2.667 0 108 2a2.667 2.667 0 000 5.333z",
296
- stroke: "currentColor"
297
- })));
298
- }
299
-
300
- var useIconStyles = makeStyles(function (_a) {
301
- var spacing = _a.spacing, palette = _a.palette;
302
- var getFontSize = function (_a) {
303
- var size = _a.size;
304
- var sizes = {
305
- inherit: 'inherit',
306
- small: spacing(1.5),
307
- medium: spacing(2),
308
- large: spacing(2.5),
309
- 'extra-large': spacing(3),
310
- };
311
- return size ? sizes[size] : 'inherit';
312
- };
313
- var getColor = function (props) {
314
- var semanticColors = ['primary', 'secondary', 'info', 'success', 'warning', 'error'];
315
- var value = 'inherit';
316
- if (props.color) {
317
- if (semanticColors.includes(props.color.split('.')[0])) {
318
- var _a = props.color.split('.'), color = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
319
- // @ts-expect-error - todo.
320
- value = palette[color][variant];
321
- }
322
- else if (props.color.search(/^(rgb|hsla|#)/) !== -1) {
323
- value = props.color;
324
- }
325
- }
326
- return value;
327
- };
328
- return {
329
- root: {
330
- color: getColor,
331
- fontSize: getFontSize,
332
- strokeWidth: '1.3px',
333
- },
334
- };
335
- });
336
-
337
- var classnames = {exports: {}};
338
-
339
- /*!
340
- Copyright (c) 2018 Jed Watson.
341
- Licensed under the MIT License (MIT), see
342
- http://jedwatson.github.io/classnames
343
- */
344
-
345
- (function (module) {
346
- /* global define */
347
-
348
- (function () {
349
-
350
- var hasOwn = {}.hasOwnProperty;
351
-
352
- function classNames() {
353
- var classes = [];
354
-
355
- for (var i = 0; i < arguments.length; i++) {
356
- var arg = arguments[i];
357
- if (!arg) continue;
358
-
359
- var argType = typeof arg;
360
-
361
- if (argType === 'string' || argType === 'number') {
362
- classes.push(arg);
363
- } else if (Array.isArray(arg)) {
364
- if (arg.length) {
365
- var inner = classNames.apply(null, arg);
366
- if (inner) {
367
- classes.push(inner);
368
- }
369
- }
370
- } else if (argType === 'object') {
371
- if (arg.toString === Object.prototype.toString) {
372
- for (var key in arg) {
373
- if (hasOwn.call(arg, key) && arg[key]) {
374
- classes.push(key);
375
- }
376
- }
377
- } else {
378
- classes.push(arg.toString());
379
- }
380
- }
381
- }
382
-
383
- return classes.join(' ');
384
- }
385
-
386
- if (module.exports) {
387
- classNames.default = classNames;
388
- module.exports = classNames;
389
- } else {
390
- window.classNames = classNames;
391
- }
392
- }());
393
- }(classnames));
394
-
395
- var classNames = classnames.exports;
396
-
397
- var iconStaticClassName = 'pop-icon';
398
- var Icon = function (props) {
399
- var icon = props.icon, className = props.className, restProps = __rest(props, ["icon", "className"]);
400
- var hasAccessibleAttr = Boolean(restProps['aria-describedby'] || restProps['aria-label']);
401
- if (!hasAccessibleAttr && restProps['aria-hidden'] === undefined) {
402
- restProps['aria-hidden'] = true;
403
- }
404
- var classes = useIconStyles(props);
405
- var isValid = true;
406
- if (!icon || (typeof icon === 'function' && icon({}) === undefined)) {
407
- isValid = false;
408
- }
409
- return isValid
410
- ? createElement(icon, __assign({ className: classNames([classes.root, iconStaticClassName, className]) }, restProps))
411
- : null;
412
- };
413
- Icon.defaultProps = {
414
- size: 'inherit',
415
- color: 'inherit',
416
- };
417
- Icon.displayName = 'Icon';
418
-
419
- var LoadingStatus;
420
- (function (LoadingStatus) {
421
- LoadingStatus["ERROR"] = "ERROR";
422
- LoadingStatus["LOADED"] = "LOADED";
423
- LoadingStatus["PENDING"] = "PENDING";
424
- })(LoadingStatus || (LoadingStatus = {}));
425
- var useImgProps = function (avatarProps) {
426
- var _a = React__default.useState(LoadingStatus.PENDING), loaded = _a[0], setLoaded = _a[1];
427
- var imgProps = __assign(__assign({}, avatarProps.imgProps), { onLoad: function (event) {
428
- var _a, _b;
429
- setLoaded(LoadingStatus.LOADED);
430
- (_b = (_a = avatarProps.imgProps) === null || _a === void 0 ? void 0 : _a.onLoad) === null || _b === void 0 ? void 0 : _b.call(_a, event);
431
- } });
432
- return { imgProps: imgProps, loaded: loaded };
433
- };
434
-
435
- var getAvatarDimensions = function (theme, props) {
436
- var factors = {
437
- 'extra-small': 3,
438
- small: 4,
439
- medium: 5,
440
- large: 6,
441
- 'extra-large': 12.5,
442
- };
443
- var sizeFactor = factors[props.size || 'medium'];
444
- return theme.spacing(sizeFactor);
445
- };
446
- var getAvatarFontSize = function (props) {
447
- var fontSizes = {
448
- 'extra-small': '0.75rem',
449
- small: '1rem',
450
- medium: '1rem',
451
- large: '1.25rem',
452
- 'extra-large': '3.5rem',
453
- };
454
- return fontSizes[props.size];
455
- };
456
- var useAvatarStyles = makeStyles$1(function (theme) { return ({
457
- root: function (props) { return ({
458
- width: getAvatarDimensions(theme, props),
459
- height: getAvatarDimensions(theme, props),
460
- fontSize: getAvatarFontSize(props),
461
- backgroundColor: props.loaded === LoadingStatus.LOADED ? 'transparent' : props.background,
462
- color: theme.palette.getContrastText(props.background),
463
- objectFit: props.fit,
464
- }); },
465
- fallback: function (props) { return ({
466
- fontSize: getAvatarDimensions(theme, props),
467
- strokeWidth: 1,
468
- }); },
469
- }); });
470
-
471
- var Avatar = forwardRef(function (props, ref) {
472
- var children = props.children, src = props.src, alt = props.alt, fallback = props.fallback, muiProps = __rest(props, ["children", "src", "alt", "fallback"]);
473
- var _a = useImgProps(props), imgProps = _a.imgProps, loaded = _a.loaded;
474
- var classes = useAvatarStyles(__assign(__assign({}, props), { loaded: loaded }));
475
- var displayAltTextFallback = src && alt;
476
- var displayNoFallback = fallback === 'none';
477
- var displayCustomFallback = fallback !== 'none' && typeof fallback !== 'undefined';
478
- var Fallback;
479
- if (displayAltTextFallback) {
480
- Fallback = null;
481
- }
482
- else if (displayNoFallback) {
483
- Fallback = ' ';
484
- }
485
- else if (displayCustomFallback) {
486
- Fallback = fallback;
487
- }
488
- else {
489
- Fallback = React__default.createElement(Icon, { icon: SvgUser, className: classes.fallback });
490
- }
491
- return (React__default.createElement(MuiAvatar, __assign({ ref: ref, classes: { root: classes.root }, src: src, alt: alt }, muiProps, { imgProps: imgProps }), children || Fallback));
492
- });
493
- Avatar.defaultProps = {
494
- size: 'medium',
495
- fit: 'cover',
496
- background: '#E0E0E0',
497
- };
498
- Avatar.displayName = 'Avatar';
499
-
500
- makeStyles$1(function (theme) { return ({
501
- circle: {
502
- backgroundColor: theme.palette.grey[300],
503
- borderRadius: '50%',
504
- height: theme.spacing(0.65),
505
- width: theme.spacing(0.65),
506
- margin: theme.spacing(1) + "px 0 " + theme.spacing(1) + "px " + theme.spacing(1) + "px",
507
- },
508
- container: {
509
- border: "1px solid " + theme.palette.secondary.light,
510
- borderRadius: theme.spacing(0.5),
511
- flexGrow: 1,
512
- },
513
- titleBar: {
514
- display: 'flex',
515
- flexDirection: 'row',
516
- borderBottom: "1px solid " + theme.palette.secondary.light,
517
- width: '100%',
518
- },
519
- }); });
520
-
521
- makeStyles$1(function () { return ({
522
- root: {
523
- minWidth: 'unset',
524
- },
525
- label: {
526
- textTransform: function (_a) {
527
- var textTransform = _a.textTransform;
528
- return textTransform;
529
- },
530
- },
531
- }); });
532
-
533
- var Checkbox = forwardRef(function (props, ref) {
534
- var label = props.label, disabled = props.disabled, LabelProps = props.LabelProps, muiProps = __rest(props, ["label", "disabled", "LabelProps"]);
535
- var control = React__default.createElement(MuiCheckbox, __assign({ disabled: label ? undefined : disabled }, muiProps));
536
- return label ? (React__default.createElement(FormControlLabel, __assign({ disabled: disabled, inputRef: ref, control: control, label: label }, LabelProps))) : (control);
537
- });
538
- Checkbox.displayName = 'Checkbox';
539
-
540
- var getBackground = function (theme) { return function (props) {
541
- var variant = props.variant, severity = props.severity;
542
- var background = theme.palette.grey[100];
543
- var backgrounds = {
544
- outlined: 'none',
545
- error: 'error.main',
546
- warning: 'warning.main',
547
- info: 'info.light',
548
- success: 'success.light',
549
- };
550
- if (variant === 'outlined') {
551
- background = backgrounds[variant];
552
- }
553
- else if (severity) {
554
- var _a = backgrounds[severity].split('.'), color = _a[0], colorVariant = _a[1];
555
- // @ts-expect-error - todo.
556
- background = theme.palette[color][colorVariant];
557
- }
558
- return background;
559
- }; };
560
- var getColor = function (theme) { return function (props) {
561
- var variant = props.variant, severity = props.severity;
562
- var textColor;
563
- if (variant === 'outlined' && severity) {
564
- var textColors = {
565
- error: theme.palette.error.main,
566
- info: theme.palette.info.main,
567
- warning: theme.palette.warning.dark,
568
- success: theme.palette.success.dark,
569
- };
570
- textColor = textColors[severity];
571
- }
572
- else if (variant === 'outlined' && !severity) {
573
- textColor = theme.palette.grey[700];
574
- }
575
- else if ((variant === 'default' || variant === undefined) && severity) {
576
- var textColors = {
577
- error: theme.palette.common.white,
578
- info: theme.palette.secondary.main,
579
- warning: theme.palette.secondary.main,
580
- success: theme.palette.secondary.main,
581
- };
582
- textColor = textColors[severity];
583
- }
584
- return textColor;
585
- }; };
586
- var getBorder = function (theme) { return function (props) {
587
- var variant = props.variant, severity = props.severity;
588
- var borderColor;
589
- if (variant === 'outlined' && severity) {
590
- var borderColors = {
591
- error: theme.palette.error.main,
592
- info: theme.palette.info.main,
593
- warning: theme.palette.warning.dark,
594
- success: theme.palette.success.dark,
595
- };
596
- borderColor = borderColors[severity];
597
- }
598
- return borderColor;
599
- }; };
600
- // using `any` here is a bit of cheating but it doesn't matter since this doesn't depend on
601
- // any component-specific props
602
- makeStyles$1(function (theme) { return ({
603
- root: {
604
- background: getBackground(theme),
605
- color: getColor(theme),
606
- borderColor: getBorder(theme),
607
- borderRadius: theme.spacing(0.5),
608
- },
609
- icon: {
610
- color: 'inherit',
611
- height: theme.spacing(2),
612
- width: theme.spacing(2),
613
- },
614
- deleteIcon: {
615
- color: theme.palette.grey[500],
616
- },
617
- }); });
618
-
619
- var defaultTypographyProps = {
620
- variant: 'body1',
621
- };
622
-
623
- var weights = {
624
- regular: 400,
625
- medium: 500,
626
- 'semi-bold': 600,
627
- bold: 700,
628
- };
629
- var getCustomColor = function (theme, color) {
630
- var isCommonColor = color && ['white', 'black'].includes(color);
631
- var isGreyColor = color && color.match(/^grey\.\d{3}/);
632
- var isSemanticColor = color && color.match(/(primary|secondary|info|success|error|warning).?(light|dark)?/);
633
- var isTextColor = color && ['textPrimary', 'textSecondary'].includes(color);
634
- switch (true) {
635
- case isCommonColor:
636
- // @ts-expect-error - todo.
637
- return theme.palette.common[color];
638
- case Boolean(isGreyColor):
639
- var scale = color.split('.')[1];
640
- // @ts-expect-error - todo.
641
- return theme.palette.grey[scale] || theme.palette.grey[900];
642
- case Boolean(isSemanticColor):
643
- var _a = color.split('.'), paletteKey = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
644
- // @ts-expect-error - todo.
645
- return theme.palette[paletteKey][variant];
646
- case isTextColor:
647
- // @ts-expect-error - todo.
648
- return theme.palette.text[color.slice(4).toLowerCase()];
649
- default:
650
- return undefined;
651
- }
652
- };
653
- var useTypographyStyles = makeStyles$1(function (theme) {
654
- var _a;
655
- return ({
656
- root: (_a = {},
657
- _a["& ." + iconStaticClassName] = {
658
- position: 'relative',
659
- top: '0.125em',
660
- padding: '0 0.125em',
661
- boxSizing: 'content-box',
662
- },
663
- _a.fontFamily = theme.typography.fontFamily,
664
- _a.fontWeight = function (_a) {
665
- var variant = _a.variant, weight = _a.weight;
666
- return (weight ? weights[weight] : theme.typography[variant].fontWeight);
667
- },
668
- _a.fontSize = function (_a) {
669
- var variant = _a.variant;
670
- return theme.typography[variant].fontSize;
671
- },
672
- _a.lineHeight = function (_a) {
673
- var variant = _a.variant;
674
- return theme.typography[variant].lineHeight;
675
- },
676
- _a.textTransform = function (_a) {
677
- var variant = _a.variant;
678
- return theme.typography[variant].textTransform;
679
- },
680
- _a.color = function (_a) {
681
- var color = _a.color, variant = _a.variant;
682
- return (color && getCustomColor(theme, color)) || theme.typography[variant].color;
683
- },
684
- _a),
685
- caption: {
686
- display: 'inline',
687
- },
688
- overline: {
689
- display: 'inline',
690
- },
691
- });
692
- });
693
-
694
- var Typography = function (props) {
695
- props.weight; props.color; var TypographyRef = props.TypographyRef, restProps = __rest(props, ["weight", "color", "TypographyRef"]);
696
- var classes = useTypographyStyles(__assign({}, props));
697
- var variantMapping = { subtitle1: 'p' };
698
- return React__default.createElement(Typography$1, __assign({ classes: classes, variantMapping: variantMapping, ref: TypographyRef }, restProps));
699
- };
700
- Typography.displayName = 'Typography';
701
- Typography.defaultProps = defaultTypographyProps;
702
-
703
- var getFadeStop = function (_a, typographyVariant) {
704
- var typography = _a.typography;
705
- // @ts-expect-error - todo.
706
- return !isNaN(Number(typography[typographyVariant].lineHeight))
707
- ? // @ts-expect-error - todo.
708
- typography[typographyVariant].lineHeight + "rem"
709
- : // @ts-expect-error - todo.
710
- typography[typographyVariant].lineHeight;
711
- };
712
- makeStyles(function (theme) { return ({
713
- overlay: {
714
- position: 'absolute',
715
- top: 0,
716
- left: 0,
717
- height: '100%',
718
- width: '100%',
719
- background: function (props) { return "linear-gradient(to top, white, #FFF0 " + getFadeStop(theme, props.typographyVariant) + ")"; },
720
- },
721
- }); });
722
-
723
- var SemanticColors;
724
- (function (SemanticColors) {
725
- SemanticColors["PRIMARY_MAIN"] = "primary.main";
726
- SemanticColors["PRIMARY_DARK"] = "primary.dark";
727
- SemanticColors["PRIMARY_LIGHT"] = "primary.light";
728
- SemanticColors["SECONDARY_MAIN"] = "secondary.main";
729
- SemanticColors["SECONDARY_DARK"] = "secondary.dark";
730
- SemanticColors["SECONDARY_LIGHT"] = "secondary.light";
731
- })(SemanticColors || (SemanticColors = {}));
732
- makeStyles(function (theme) { return ({
733
- dividerRoot: {
734
- gap: theme.spacing(2),
735
- },
736
- textRoot: {
737
- color: function (props) {
738
- var textColor = props.textColor;
739
- if (Object.values(SemanticColors).includes(textColor)) {
740
- var _a = textColor.split('.'), semanticColor = _a[0], shade = _a[1];
741
- // @ts-expect-error - todo.
742
- return theme.palette[semanticColor][shade];
743
- }
744
- else if (textColor) {
745
- return textColor;
746
- }
747
- else {
748
- return 'black';
749
- }
750
- },
751
- textTransform: function (props) { return props.textTransform; },
752
- },
753
- dividerLine: {
754
- backgroundColor: function (props) {
755
- var dividerColor = props.dividerColor;
756
- if (Object.values(SemanticColors).includes(dividerColor)) {
757
- var _a = dividerColor.split('.'), semanticColor = _a[0], shade = _a[1];
758
- // @ts-expect-error - todo.
759
- return theme.palette[semanticColor][shade];
760
- }
761
- else if (dividerColor) {
762
- return dividerColor;
763
- }
764
- else {
765
- return theme.palette.grey[500];
766
- }
767
- },
768
- },
769
- }); });
770
-
771
- var IconButton = forwardRef(function (props, ref) {
772
- return React__default.createElement(MuiIconButton, __assign({ ref: ref }, props));
773
- });
774
- IconButton.displayName = 'IconButton';
775
- IconButton.defaultProps = {
776
- color: 'secondary',
777
- };
778
-
779
- var useLinkStyles = makeStyles$1(function (theme) { return ({
780
- root: function (props) {
781
- var _a;
782
- return (__assign(__assign({ display: 'flex' }, (props.color === undefined && { color: theme.palette.info.main })), (_a = {}, _a["& ." + iconStaticClassName] = {
783
- alignSelf: 'center',
784
- }, _a)));
785
- },
786
- }); });
787
-
788
- // eslint-disable-next-line react/display-name -- false positive
789
- var Link = forwardRef(function (props, ref) {
790
- var children = props.children, muiProps = __rest(props, ["children"]);
791
- var classes = useLinkStyles(props);
792
- return (React__default.createElement(Link$1, __assign({ ref: ref, classes: { root: classes.root } }, muiProps), children));
793
- });
794
- Link.defaultProps = {
795
- variant: 'body1',
796
- };
797
- Link.displayName = 'Link';
798
-
799
- var useStyles$4 = makeStyles(function (_a) {
800
- var spacing = _a.spacing;
801
- return ({
802
- root: {
803
- '&:last-child': {
804
- marginBottom: 0,
805
- },
806
- marginBottom: spacing(4),
807
- padding: spacing(4),
808
- },
809
- });
810
- });
811
- var Paper = forwardRef(function (props, ref) {
812
- var legacyStyles = props.legacyStyles, restProps = __rest(props, ["legacyStyles"]);
813
- var classes = useStyles$4(props);
814
- return React__default.createElement(Paper$1, __assign({}, ref, { classes: __assign({}, (legacyStyles && classes)) }, restProps));
815
- });
816
- Paper.displayName = 'Paper';
817
- Paper.defaultProps = {
818
- legacyStyles: false,
819
- };
820
-
821
- var Radio = forwardRef(function (props, ref) {
822
- var label = props.label, disabled = props.disabled, LabelProps = props.LabelProps, muiProps = __rest(props, ["label", "disabled", "LabelProps"]);
823
- var control = React__default.createElement(MuiRadio, __assign({ disabled: label ? undefined : disabled }, muiProps));
824
- return label ? (React__default.createElement(FormControlLabel, __assign({ disabled: disabled, inputRef: ref, control: control, label: label }, LabelProps))) : (control);
825
- });
826
- Radio.displayName = 'Radio';
827
-
828
- makeStyles$1(function () { return ({
829
- textfield: {
830
- background: function (props) { return (props.backgroundTransparency ? '#FFFFFF44' : 'none'); },
831
- borderTopLeftRadius: 4,
832
- borderBottomLeftRadius: 4,
833
- '& fieldset': {
834
- borderRight: 'none',
835
- borderTopRightRadius: 0,
836
- borderBottomRightRadius: 0,
837
- },
838
- },
839
- button: {
840
- borderTopLeftRadius: 0,
841
- borderBottomLeftRadius: 0,
842
- alignSelf: 'stretch',
843
- },
844
- input: {
845
- color: function (props) { return props.inputTextColor || 'inherit'; },
846
- '&$focused fieldset': {
847
- top: -4,
848
- },
849
- },
850
- focused: {},
851
- }); });
852
-
853
- var useSwitchStyles = makeStyles$1(function (theme) { return ({
854
- checked: {
855
- '& $thumb': {
856
- background: theme.palette.success.main,
857
- },
858
- '&& + $track': {
859
- backgroundColor: theme.palette.success.main,
860
- },
861
- },
862
- thumb: {},
863
- track: {},
864
- }); });
865
-
866
- var Switch = forwardRef(function (props, ref) {
867
- var label = props.label, disabled = props.disabled, LabelProps = props.LabelProps, muiProps = __rest(props, ["label", "disabled", "LabelProps"]);
868
- var classes = useSwitchStyles(props);
869
- var control = React__default.createElement(MuiSwitch, __assign({ classes: classes, disabled: label ? undefined : disabled }, muiProps));
870
- return label ? (React__default.createElement(FormControlLabel, __assign({ disabled: disabled, inputRef: ref, control: control, label: label }, LabelProps))) : (control);
871
- });
872
- Switch.displayName = 'Switch';
873
-
874
- var useToggleButtonStyles = makeStyles$1(function (theme) { return ({
875
- root: {
876
- color: theme.palette.text.primary,
877
- },
878
- selected: {
879
- '&&': {
880
- '&:hover': {
881
- backgroundColor: function (props) { return theme.palette[props.color || 'primary'].dark; },
882
- },
883
- backgroundColor: function (props) { return theme.palette[props.color || 'primary'].main; },
884
- color: 'white',
885
- },
886
- },
887
- }); });
888
-
889
- var ToggleButton = forwardRef(function (props, ref) {
890
- var children = props.children, muiProps = __rest(props, ["children"]);
891
- var classes = useToggleButtonStyles(props);
892
- return (React__default.createElement(MuiToggleButton, __assign({ ref: ref, classes: {
893
- root: classes.root,
894
- selected: classes.selected,
895
- } }, muiProps), children));
896
- });
897
- ToggleButton.defaultProps = {
898
- color: 'primary',
899
- };
900
- ToggleButton.displayName = 'ToggleButton';
901
-
902
- var useToggleButtonGroupStyles = makeStyles$1(function (theme) { return ({
903
- root: {
904
- '&&': {
905
- backgroundColor: theme.palette.grey[300],
906
- },
907
- },
908
- }); });
909
-
910
- var ToggleButtonGroup = forwardRef(function (props, ref) {
911
- var children = props.children, _a = props.color, color = _a === void 0 ? 'primary' : _a, muiProps = __rest(props, ["children", "color"]);
912
- var classes = useToggleButtonGroupStyles(props);
913
- var childrenWithProps = React__default.Children.map(children, function (child) {
914
- if (!React__default.isValidElement(child)) {
915
- return null;
916
- }
917
- return React__default.cloneElement(child, { color: color });
918
- });
919
- return (React__default.createElement(MuiToggleButtonGroup, __assign({ ref: ref, classes: { root: classes.root } }, muiProps), childrenWithProps));
920
- });
921
- ToggleButtonGroup.displayName = 'ToggleButtonGroup';
922
-
923
- var useTooltipStyles = makeStyles$1(function (_a) {
924
- var typography = _a.typography;
925
- return ({
926
- tooltip: {
927
- fontSize: typography.pxToRem(16),
928
- },
929
- });
930
- });
931
-
932
- var Tooltip = forwardRef(function (props, ref) {
933
- var classes = useTooltipStyles(props);
934
- return React__default.createElement(MuiTooltip, __assign({ ref: ref, classes: classes }, props));
935
- });
936
- Tooltip.displayName = 'Tooltip';
937
-
938
- makeStyles(function () { return ({
939
- root: {
940
- height: 56,
941
- },
942
- }); });
943
- makeStyles(function (theme) { return ({
944
- root: {
945
- height: '100%',
946
- width: 'min-content',
947
- borderRadius: theme.spacing(1),
948
- },
949
- input: {
950
- '&::-webkit-clear-button, &::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
951
- display: 'none',
952
- },
953
- '-moz-appearance': 'textfield',
954
- minWidth: 40,
955
- padding: 0,
956
- textAlign: 'center',
957
- },
958
- adornedStart: {
959
- padding: 0,
960
- },
961
- adornedEnd: {
962
- padding: 0,
963
- },
964
- }); });
965
-
966
- makeStyles(function () { return ({
967
- root: {
968
- display: 'flex',
969
- flexDirection: 'column',
970
- alignItems: 'center',
971
- gridGap: 16,
972
- },
973
- }); });
974
-
975
- var FollowerAuthenticationDialogContext = createContext(null);
976
- FollowerAuthenticationDialogContext.Provider;
977
-
978
- makeStyles(function () { return ({
979
- form: {
980
- display: 'flex',
981
- flexDirection: 'column',
982
- alignItems: 'center',
983
- width: '100%',
984
- gridGap: 16,
985
- },
986
- }); });
987
-
988
- makeStyles(function () { return ({
989
- main: {
990
- width: '100%',
991
- display: 'flex',
992
- flexDirection: 'column',
993
- gridGap: 16,
994
- },
995
- }); });
996
-
997
- makeStyles(function () { return ({
998
- root: {
999
- position: 'absolute',
1000
- top: 0,
1001
- right: 0,
1002
- },
1003
- }); });
1004
-
1005
- var AUDIO_PLAYER_EVENT_TYPES;
1006
- (function (AUDIO_PLAYER_EVENT_TYPES) {
1007
- AUDIO_PLAYER_EVENT_TYPES["TOGGLE_PLAYBACK"] = "TOGGLE_PLAYBACK";
1008
- AUDIO_PLAYER_EVENT_TYPES["TOGGLE_VOLUME_CONTROL"] = "TOGGLE_VOLUME_CONTROL";
1009
- AUDIO_PLAYER_EVENT_TYPES["TOGGLE_MUTE"] = "TOGGLE_MUTE";
1010
- AUDIO_PLAYER_EVENT_TYPES["VOLUME_CHANGE"] = "VOLUME_CHANGE";
1011
- AUDIO_PLAYER_EVENT_TYPES["TIME_CHANGE"] = "TIME_CHANGE";
1012
- AUDIO_PLAYER_EVENT_TYPES["DURATION_CHANGE"] = "DURATION_CHANGE";
1013
- AUDIO_PLAYER_EVENT_TYPES["SET_TIME"] = "SET_TIME";
1014
- AUDIO_PLAYER_EVENT_TYPES["CAN_PLAY"] = "CAN_PLAY";
1015
- AUDIO_PLAYER_EVENT_TYPES["RESET"] = "RESET";
1016
- })(AUDIO_PLAYER_EVENT_TYPES || (AUDIO_PLAYER_EVENT_TYPES = {}));
1017
- var PLAYBACK_STATES;
1018
- (function (PLAYBACK_STATES) {
1019
- PLAYBACK_STATES["NONE"] = "NONE";
1020
- PLAYBACK_STATES["PAUSED"] = "PAUSED";
1021
- PLAYBACK_STATES["PLAYING"] = "PLAYING";
1022
- })(PLAYBACK_STATES || (PLAYBACK_STATES = {}));
1023
- var CONTROL_LABELS;
1024
- (function (CONTROL_LABELS) {
1025
- CONTROL_LABELS["PAUSE"] = "PAUSE";
1026
- CONTROL_LABELS["PLAY"] = "PLAY";
1027
- CONTROL_LABELS["MUTE"] = "MUTE";
1028
- CONTROL_LABELS["UNMUTE"] = "UNMUTE";
1029
- })(CONTROL_LABELS || (CONTROL_LABELS = {}));
1030
- var VOLUME_CONTROL_STATES;
1031
- (function (VOLUME_CONTROL_STATES) {
1032
- VOLUME_CONTROL_STATES["SHOW"] = "SHOW";
1033
- VOLUME_CONTROL_STATES["HIDE"] = "HIDE";
1034
- })(VOLUME_CONTROL_STATES || (VOLUME_CONTROL_STATES = {}));
1035
-
1036
- var initialAudioPlayerState = {
1037
- playback: PLAYBACK_STATES.NONE,
1038
- volumeControls: VOLUME_CONTROL_STATES.HIDE,
1039
- context: {
1040
- volume: 100,
1041
- playbackButtonLabel: CONTROL_LABELS.PLAY,
1042
- volumeButtonLabel: CONTROL_LABELS.MUTE,
1043
- },
1044
- };
1045
- var getPlayback = function (_a) {
1046
- var audio = _a.current;
1047
- var playback = PLAYBACK_STATES.NONE;
1048
- if (audio) {
1049
- var paused = audio.paused, readyState = audio.readyState;
1050
- if (readyState === 0) {
1051
- playback = PLAYBACK_STATES.NONE;
1052
- }
1053
- else if (paused) {
1054
- playback = PLAYBACK_STATES.PAUSED;
1055
- }
1056
- else {
1057
- playback = PLAYBACK_STATES.PLAYING;
1058
- }
1059
- }
1060
- return playback;
1061
- };
1062
- var audioPlayerReducer = function (state, event) {
1063
- var _a, _b, _c;
1064
- var audioRef = state.context.audioRef;
1065
- var nextState = __assign$1({}, state);
1066
- switch (state.playback) {
1067
- case PLAYBACK_STATES.NONE:
1068
- if (event.type === AUDIO_PLAYER_EVENT_TYPES.CAN_PLAY) {
1069
- nextState.playback = getPlayback(audioRef);
1070
- return nextState;
1071
- }
1072
- // Required for iOS users. iOS prevents media from being loaded before user interaction.
1073
- if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK) {
1074
- (_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.play();
1075
- }
1076
- break;
1077
- case PLAYBACK_STATES.PAUSED:
1078
- if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK) {
1079
- (_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.play();
1080
- nextState.playback = getPlayback(audioRef);
1081
- nextState.context.playbackButtonLabel = CONTROL_LABELS.PAUSE;
1082
- return nextState;
1083
- }
1084
- break;
1085
- case PLAYBACK_STATES.PLAYING:
1086
- if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK) {
1087
- (_c = audioRef.current) === null || _c === void 0 ? void 0 : _c.pause();
1088
- nextState.playback = getPlayback(audioRef);
1089
- nextState.context.playbackButtonLabel = CONTROL_LABELS.PLAY;
1090
- return nextState;
1091
- }
1092
- if (event.type === AUDIO_PLAYER_EVENT_TYPES.TIME_CHANGE) {
1093
- return nextState;
1094
- }
1095
- break;
1096
- }
1097
- switch (state.volumeControls) {
1098
- case VOLUME_CONTROL_STATES.SHOW:
1099
- if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_VOLUME_CONTROL) {
1100
- nextState.volumeControls = VOLUME_CONTROL_STATES.HIDE;
1101
- return nextState;
1102
- }
1103
- if (event.type === AUDIO_PLAYER_EVENT_TYPES.VOLUME_CHANGE) {
1104
- if (nextState.context.volume !== event.context.volume) {
1105
- nextState.context.volume = event.context.volume;
1106
- if (audioRef.current) {
1107
- audioRef.current.volume = event.context.volume;
1108
- }
1109
- return nextState;
1110
- }
1111
- }
1112
- break;
1113
- case VOLUME_CONTROL_STATES.HIDE:
1114
- if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_VOLUME_CONTROL) {
1115
- nextState.volumeControls = VOLUME_CONTROL_STATES.SHOW;
1116
- return nextState;
1117
- }
1118
- break;
1119
- }
1120
- switch (event.type) {
1121
- case AUDIO_PLAYER_EVENT_TYPES.TOGGLE_MUTE:
1122
- if (audioRef.current) {
1123
- audioRef.current.muted = !audioRef.current.muted;
1124
- return nextState;
1125
- }
1126
- break;
1127
- case AUDIO_PLAYER_EVENT_TYPES.SET_TIME:
1128
- if (audioRef.current) {
1129
- audioRef.current.currentTime = event.context.time;
1130
- return nextState;
1131
- }
1132
- break;
1133
- case AUDIO_PLAYER_EVENT_TYPES.RESET:
1134
- if (audioRef.current) {
1135
- audioRef.current.currentTime = 0;
1136
- nextState.playback = getPlayback(audioRef);
1137
- return nextState;
1138
- }
1139
- break;
1140
- }
1141
- return state;
1142
- };
1143
-
1144
- var useVolumeIcon = function (state) {
1145
- var volumeIcon = SvgVolumeUp;
1146
- if (state.context.volume >= 0.5) {
1147
- volumeIcon = SvgVolumeUp;
1148
- }
1149
- else if (state.context.volume < 0.5 && state.context.volume > 0) {
1150
- volumeIcon = SvgVolumeDown;
1151
- }
1152
- else if (state.context.volume === 0) {
1153
- volumeIcon = SvgVolumeMute;
1154
- }
1155
- if (state.context.audioRef.current) {
1156
- if (state.context.audioRef.current.muted) {
1157
- volumeIcon = SvgVolumeOff;
1158
- }
1159
- }
1160
- return volumeIcon;
1161
- };
1162
-
1163
- var appendZero = function (num) { return (num < 10 ? "0" + num : num); };
1164
- var formatTime = function (time, remaning) {
1165
- if (remaning === void 0) { remaning = false; }
1166
- var dateTime = new Date(0, 0, 0, 0, 0, time, 0);
1167
- var dateTimeH = appendZero(dateTime.getHours());
1168
- var dateTimeM = appendZero(dateTime.getMinutes());
1169
- var dateTimeS = appendZero(dateTime.getSeconds());
1170
- var minus = remaning ? '-' : '';
1171
- return dateTimeH > 0 ? "" + minus + dateTimeH + ":" + dateTimeM + ":" + dateTimeS : "" + minus + dateTimeM + ":" + dateTimeS;
1172
- };
1173
-
1174
- var setupAudioRef = function (config) { return function () {
1175
- var _a, _b, _c, _d;
1176
- var audioRef = config.audioRef, send = config.send;
1177
- var handleDurationChange = function (event) {
1178
- var duration = event.target.duration;
1179
- send({ type: AUDIO_PLAYER_EVENT_TYPES.DURATION_CHANGE, context: { duration: duration } });
1180
- };
1181
- var handleTimeUpdate = function (event) {
1182
- var currentTime = event.target.currentTime;
1183
- send({ type: AUDIO_PLAYER_EVENT_TYPES.TIME_CHANGE, context: { currentTime: currentTime } });
1184
- };
1185
- var handleCanPlay = function () {
1186
- send({ type: AUDIO_PLAYER_EVENT_TYPES.CAN_PLAY });
1187
- };
1188
- var handleEnded = function () {
1189
- send({ type: AUDIO_PLAYER_EVENT_TYPES.RESET });
1190
- };
1191
- (_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('durationchange', handleDurationChange);
1192
- (_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('timeupdate', handleTimeUpdate);
1193
- (_c = audioRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('canplay', handleCanPlay);
1194
- (_d = audioRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleEnded);
1195
- return function () {
1196
- var _a, _b, _c, _d;
1197
- (_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('durationchange', handleDurationChange);
1198
- (_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('timeupdate', handleTimeUpdate);
1199
- (_c = audioRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('canplay', handleCanPlay);
1200
- (_d = audioRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('ended', handleEnded);
1201
- };
1202
- }; };
1203
-
1204
- var getPlaybackIcon = function (status) {
1205
- var icon;
1206
- switch (status) {
1207
- case PLAYBACK_STATES.PAUSED:
1208
- icon = SvgPlay;
1209
- break;
1210
- case PLAYBACK_STATES.PLAYING:
1211
- icon = SvgPause;
1212
- break;
1213
- case PLAYBACK_STATES.NONE:
1214
- icon = SvgPlay;
1215
- break;
1216
- }
1217
- return icon;
1218
- };
1219
- var AudioPlayer = function (props) {
1220
- var _a, _b, _c, _d, _f, _g;
1221
- var src = props.src, _h = props.classes, classes = _h === void 0 ? {} : _h;
1222
- var volumeRef = useRef(null);
1223
- var audioRef = useRef(null);
1224
- var spacing = useTheme().spacing;
1225
- var _j = useState(false), disableRipple = _j[0], setDisableRipple = _j[1];
1226
- var _k = useReducer(audioPlayerReducer, __assign$1(__assign$1({}, initialAudioPlayerState), { context: __assign$1(__assign$1({}, initialAudioPlayerState.context), { audioRef: audioRef }) })), state = _k[0], send = _k[1];
1227
- useEffect(setupAudioRef({ audioRef: audioRef, send: send }), [audioRef]);
1228
- var PlaybackIcon = getPlaybackIcon(state.playback);
1229
- var VolumeIcon = useMemo(function () { return useVolumeIcon(state); }, [state.context.volume, (_a = state.context.audioRef.current) === null || _a === void 0 ? void 0 : _a.muted]);
1230
- var togglePlayback = function () { return send({ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK }); };
1231
- var toggleVolumeControl = function () { return send({ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_VOLUME_CONTROL }); };
1232
- var toggleMute = function () { return send({ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_MUTE }); };
1233
- var setTime = function (_e, time) { return send({ type: AUDIO_PLAYER_EVENT_TYPES.SET_TIME, context: { time: time } }); };
1234
- var setVolume = function (_e, volume) { return send({ type: AUDIO_PLAYER_EVENT_TYPES.VOLUME_CHANGE, context: { volume: volume } }); };
1235
- return (React__default.createElement(Box, { display: "flex", alignItems: "center", gridGap: spacing(1), className: classNames$1([classes.root]) },
1236
- React__default.createElement("audio", { ref: audioRef, src: src }),
1237
- React__default.createElement(Box, null,
1238
- React__default.createElement(IconButton, __assign$1({}, (classes.playbackToggle && { classes: { root: classes.playbackToggle } }), { "aria-label": state.context.playbackButtonLabel, disabled: ((_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.networkState) === 2, onClick: togglePlayback }),
1239
- React__default.createElement(Icon, { icon: PlaybackIcon })),
1240
- React__default.createElement(IconButton, __assign$1({}, (classes.volumeToggle && { classes: { root: classes.volumeToggle } }), { "aria-label": state.context.volumeButtonLabel, ref: volumeRef, onClick: toggleMute, onMouseEnter: toggleVolumeControl, onMouseLeave: toggleVolumeControl, disableRipple: disableRipple }),
1241
- React__default.createElement(Icon, { icon: VolumeIcon }),
1242
- React__default.createElement(Popper, { onClick: function (e) { return e.stopPropagation(); }, onMouseEnter: function () { return setDisableRipple(true); }, onMouseLeave: function () { return setDisableRipple(false); }, open: state.volumeControls === VOLUME_CONTROL_STATES.SHOW, anchorEl: function () { return volumeRef.current; }, transition: true, placement: "top", className: classNames$1([classes.volumeSlider]) }, function (_a) {
1243
- var TransitionProps = _a.TransitionProps;
1244
- return (React__default.createElement(Grow, __assign$1({}, TransitionProps),
1245
- React__default.createElement(Paper, { elevation: 1 },
1246
- React__default.createElement(Box, { py: 1, height: 80 },
1247
- React__default.createElement(Slider, { color: "secondary", orientation: "vertical", value: state.context.volume, onChange: setVolume, max: 1, step: 0.01 })))));
1248
- }))),
1249
- React__default.createElement(Box, { display: "flex", flexGrow: 1, alignItems: "center", gridGap: spacing(1) },
1250
- React__default.createElement(Box, { flexBasis: 60, flexShrink: 0 },
1251
- React__default.createElement(Typography, __assign$1({}, (classes.playbackText && { classes: { root: classes.playbackText } })), formatTime(((_c = state.context.audioRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) || 0))),
1252
- React__default.createElement(Slider, __assign$1({}, (classes.playbackSlider && { classes: { root: classes.playbackSlider } }), { color: "secondary", value: ((_d = state.context.audioRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) || 0, max: ((_f = state.context.audioRef.current) === null || _f === void 0 ? void 0 : _f.duration) || 1, onChange: setTime, disabled: state.playback === PLAYBACK_STATES.NONE })),
1253
- React__default.createElement(Box, { flexBasis: 60, flexShrink: 0, textAlign: "end" },
1254
- React__default.createElement(Typography, __assign$1({}, (classes.lengthText && { classes: { root: classes.lengthText } })), formatTime(((_g = state.context.audioRef.current) === null || _g === void 0 ? void 0 : _g.duration) || 0))))));
1255
- };
1256
-
1257
- export { AudioPlayer };
1258
- //# sourceMappingURL=index.es.js.map