@popmenu/common-ui 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/index.d.ts +0 -1
- package/build/index.es.js +101 -442
- package/build/index.es.js.map +1 -1
- package/build/index.js +96 -438
- package/build/index.js.map +1 -1
- package/package.json +3 -2
- package/CHANGELOG.md +0 -415
- package/build/components/AudioPlayer/AudioPlayer.d.ts +0 -3
- package/build/components/AudioPlayer/AudioPlayerProps.d.ts +0 -10
- package/build/components/AudioPlayer/index.d.ts +0 -2
- package/build/components/AudioPlayer/util/audioPlayerReducer.d.ts +0 -11
- package/build/components/AudioPlayer/util/formatTime.d.ts +0 -1
- package/build/components/AudioPlayer/util/index.d.ts +0 -5
- package/build/components/AudioPlayer/util/setupAudioRef.d.ts +0 -8
- package/build/components/AudioPlayer/util/types.d.ts +0 -77
- package/build/components/AudioPlayer/util/useVolumeIcon.d.ts +0 -2
package/build/index.js
CHANGED
|
@@ -6,9 +6,8 @@ var Alert = require('@material-ui/lab/Alert');
|
|
|
6
6
|
var core = require('@material-ui/core');
|
|
7
7
|
var AppBar = require('@material-ui/core/AppBar');
|
|
8
8
|
var React = require('react');
|
|
9
|
-
var MuiIconButton = require('@material-ui/core/IconButton');
|
|
10
|
-
var styles = require('@material-ui/core/styles');
|
|
11
9
|
var MuiAvatar = require('@material-ui/core/Avatar');
|
|
10
|
+
var styles = require('@material-ui/core/styles');
|
|
12
11
|
var Badge = require('@material-ui/core/Badge');
|
|
13
12
|
var MuiButton = require('@material-ui/core/Button');
|
|
14
13
|
var CircularProgress = require('@material-ui/core/CircularProgress');
|
|
@@ -30,6 +29,7 @@ var DialogTitle = require('@material-ui/core/DialogTitle');
|
|
|
30
29
|
var Drawer = require('@material-ui/core/Drawer');
|
|
31
30
|
var FormControl = require('@material-ui/core/FormControl');
|
|
32
31
|
var Grid = require('@material-ui/core/Grid');
|
|
32
|
+
var MuiIconButton = require('@material-ui/core/IconButton');
|
|
33
33
|
var InputAdornment = require('@material-ui/core/InputAdornment');
|
|
34
34
|
var LinearProgress = require('@material-ui/core/LinearProgress');
|
|
35
35
|
var List = require('@material-ui/core/List');
|
|
@@ -75,7 +75,6 @@ var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
|
|
75
75
|
var AppBar__default = /*#__PURE__*/_interopDefaultLegacy(AppBar);
|
|
76
76
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
77
77
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
78
|
-
var MuiIconButton__default = /*#__PURE__*/_interopDefaultLegacy(MuiIconButton);
|
|
79
78
|
var MuiAvatar__default = /*#__PURE__*/_interopDefaultLegacy(MuiAvatar);
|
|
80
79
|
var Badge__default = /*#__PURE__*/_interopDefaultLegacy(Badge);
|
|
81
80
|
var MuiButton__default = /*#__PURE__*/_interopDefaultLegacy(MuiButton);
|
|
@@ -98,6 +97,7 @@ var DialogTitle__default = /*#__PURE__*/_interopDefaultLegacy(DialogTitle);
|
|
|
98
97
|
var Drawer__default = /*#__PURE__*/_interopDefaultLegacy(Drawer);
|
|
99
98
|
var FormControl__default = /*#__PURE__*/_interopDefaultLegacy(FormControl);
|
|
100
99
|
var Grid__default = /*#__PURE__*/_interopDefaultLegacy(Grid);
|
|
100
|
+
var MuiIconButton__default = /*#__PURE__*/_interopDefaultLegacy(MuiIconButton);
|
|
101
101
|
var InputAdornment__default = /*#__PURE__*/_interopDefaultLegacy(InputAdornment);
|
|
102
102
|
var LinearProgress__default = /*#__PURE__*/_interopDefaultLegacy(LinearProgress);
|
|
103
103
|
var List__default = /*#__PURE__*/_interopDefaultLegacy(List);
|
|
@@ -209,113 +209,41 @@ function SvgUser(props) {
|
|
|
209
209
|
})));
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
var
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
var _path$16;
|
|
249
|
-
|
|
250
|
-
function _extends$1a() { _extends$1a = 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$1a.apply(this, arguments); }
|
|
251
|
-
|
|
252
|
-
function SvgVolumeDown(props) {
|
|
253
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$1a({
|
|
254
|
-
viewBox: "0 0 16 16",
|
|
255
|
-
strokeLinecap: "round",
|
|
256
|
-
strokeLinejoin: "round",
|
|
257
|
-
stroke: "currentColor",
|
|
258
|
-
width: "1em",
|
|
259
|
-
height: "1em",
|
|
260
|
-
fill: "none"
|
|
261
|
-
}, props), _path$16 || (_path$16 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
262
|
-
d: "M8.999 3.333L5.665 6H3v4h2.666L9 12.667V3.333zm3.026 2.307a3.333 3.333 0 010 4.714"
|
|
263
|
-
})));
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
var _path$15;
|
|
267
|
-
|
|
268
|
-
function _extends$19() { _extends$19 = 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$19.apply(this, arguments); }
|
|
269
|
-
|
|
270
|
-
function SvgVolumeMute(props) {
|
|
271
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$19({
|
|
272
|
-
viewBox: "0 0 16 16",
|
|
273
|
-
strokeLinecap: "round",
|
|
274
|
-
strokeLinejoin: "round",
|
|
275
|
-
stroke: "currentColor",
|
|
276
|
-
width: "1em",
|
|
277
|
-
height: "1em",
|
|
278
|
-
fill: "none"
|
|
279
|
-
}, props), _path$15 || (_path$15 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
280
|
-
d: "M7.333 3.333L4 6H1.333v4H4l3.333 2.667V3.333z"
|
|
281
|
-
})));
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
var _path$14;
|
|
285
|
-
|
|
286
|
-
function _extends$18() { _extends$18 = 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$18.apply(this, arguments); }
|
|
287
|
-
|
|
288
|
-
function SvgVolumeOff(props) {
|
|
289
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$18({
|
|
290
|
-
viewBox: "0 0 16 16",
|
|
291
|
-
strokeLinecap: "round",
|
|
292
|
-
strokeLinejoin: "round",
|
|
293
|
-
stroke: "currentColor",
|
|
294
|
-
width: "1em",
|
|
295
|
-
height: "1em",
|
|
296
|
-
fill: "none"
|
|
297
|
-
}, props), _path$14 || (_path$14 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
298
|
-
d: "M7.333 3.333L4 6H1.333v4H4l3.333 2.667V3.333zm8 2.667l-4 4m0-4l4 4"
|
|
299
|
-
})));
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
var _path$13;
|
|
303
|
-
|
|
304
|
-
function _extends$17() { _extends$17 = 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$17.apply(this, arguments); }
|
|
305
|
-
|
|
306
|
-
function SvgVolumeUp(props) {
|
|
307
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$17({
|
|
308
|
-
viewBox: "0 0 16 16",
|
|
309
|
-
strokeLinecap: "round",
|
|
310
|
-
strokeLinejoin: "round",
|
|
311
|
-
stroke: "currentColor",
|
|
312
|
-
width: "1em",
|
|
313
|
-
height: "1em",
|
|
314
|
-
fill: "none"
|
|
315
|
-
}, props), _path$13 || (_path$13 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
316
|
-
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"
|
|
317
|
-
})));
|
|
318
|
-
}
|
|
212
|
+
var useIconStyles = core.makeStyles(function (_a) {
|
|
213
|
+
var spacing = _a.spacing, palette = _a.palette;
|
|
214
|
+
var getFontSize = function (_a) {
|
|
215
|
+
var size = _a.size;
|
|
216
|
+
var sizes = {
|
|
217
|
+
inherit: 'inherit',
|
|
218
|
+
small: spacing(1.5),
|
|
219
|
+
medium: spacing(2),
|
|
220
|
+
large: spacing(2.5),
|
|
221
|
+
'extra-large': spacing(3),
|
|
222
|
+
};
|
|
223
|
+
return size ? sizes[size] : 'inherit';
|
|
224
|
+
};
|
|
225
|
+
var getColor = function (props) {
|
|
226
|
+
var semanticColors = ['primary', 'secondary', 'info', 'success', 'warning', 'error'];
|
|
227
|
+
var value = 'inherit';
|
|
228
|
+
if (props.color) {
|
|
229
|
+
if (semanticColors.includes(props.color.split('.')[0])) {
|
|
230
|
+
var _a = props.color.split('.'), color = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
|
|
231
|
+
value = palette[color][variant];
|
|
232
|
+
}
|
|
233
|
+
else if (props.color.search(/^(rgb|hsla|#)/) !== -1) {
|
|
234
|
+
value = props.color;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return value;
|
|
238
|
+
};
|
|
239
|
+
return {
|
|
240
|
+
root: {
|
|
241
|
+
color: getColor,
|
|
242
|
+
fontSize: getFontSize,
|
|
243
|
+
strokeWidth: '1.3px',
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
});
|
|
319
247
|
|
|
320
248
|
var classnames = {exports: {}};
|
|
321
249
|
|
|
@@ -377,42 +305,6 @@ var classnames = {exports: {}};
|
|
|
377
305
|
|
|
378
306
|
var classNames = classnames.exports;
|
|
379
307
|
|
|
380
|
-
var useIconStyles = core.makeStyles(function (_a) {
|
|
381
|
-
var spacing = _a.spacing, palette = _a.palette;
|
|
382
|
-
var getFontSize = function (_a) {
|
|
383
|
-
var size = _a.size;
|
|
384
|
-
var sizes = {
|
|
385
|
-
inherit: 'inherit',
|
|
386
|
-
small: spacing(1.5),
|
|
387
|
-
medium: spacing(2),
|
|
388
|
-
large: spacing(2.5),
|
|
389
|
-
'extra-large': spacing(3),
|
|
390
|
-
};
|
|
391
|
-
return size ? sizes[size] : 'inherit';
|
|
392
|
-
};
|
|
393
|
-
var getColor = function (props) {
|
|
394
|
-
var semanticColors = ['primary', 'secondary', 'info', 'success', 'warning', 'error'];
|
|
395
|
-
var value = 'inherit';
|
|
396
|
-
if (props.color) {
|
|
397
|
-
if (semanticColors.includes(props.color.split('.')[0])) {
|
|
398
|
-
var _a = props.color.split('.'), color = _a[0], _b = _a[1], variant = _b === void 0 ? 'main' : _b;
|
|
399
|
-
value = palette[color][variant];
|
|
400
|
-
}
|
|
401
|
-
else if (props.color.search(/^(rgb|hsla|#)/) !== -1) {
|
|
402
|
-
value = props.color;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return value;
|
|
406
|
-
};
|
|
407
|
-
return {
|
|
408
|
-
root: {
|
|
409
|
-
color: getColor,
|
|
410
|
-
fontSize: getFontSize,
|
|
411
|
-
strokeWidth: '1.3px',
|
|
412
|
-
},
|
|
413
|
-
};
|
|
414
|
-
});
|
|
415
|
-
|
|
416
308
|
var iconStaticClassName = 'pop-icon';
|
|
417
309
|
var Icon = function (props) {
|
|
418
310
|
var icon = props.icon, className = props.className, restProps = __rest(props, ["icon", "className"]);
|
|
@@ -431,295 +323,6 @@ Icon.defaultProps = {
|
|
|
431
323
|
};
|
|
432
324
|
Icon.displayName = 'Icon';
|
|
433
325
|
|
|
434
|
-
var IconButton = React.forwardRef(function (props, ref) {
|
|
435
|
-
return React__default['default'].createElement(MuiIconButton__default['default'], __assign({ ref: ref }, props));
|
|
436
|
-
});
|
|
437
|
-
IconButton.displayName = 'IconButton';
|
|
438
|
-
IconButton.defaultProps = {
|
|
439
|
-
color: 'secondary',
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
var useTypographyStyles = styles.makeStyles(function () { return ({
|
|
443
|
-
root: function (_a) {
|
|
444
|
-
var _b;
|
|
445
|
-
var weight = _a.weight;
|
|
446
|
-
return (__assign((_b = {}, _b["& ." + iconStaticClassName] = {
|
|
447
|
-
position: 'relative',
|
|
448
|
-
top: '0.125em',
|
|
449
|
-
padding: '0 0.125em',
|
|
450
|
-
boxSizing: 'content-box',
|
|
451
|
-
}, _b), (weight && { fontWeight: (weight === 'semi-bold' && 600) || (weight === 'bold' && 700) || 400 })));
|
|
452
|
-
},
|
|
453
|
-
caption: {
|
|
454
|
-
display: 'inline',
|
|
455
|
-
},
|
|
456
|
-
overline: {
|
|
457
|
-
display: 'inline',
|
|
458
|
-
},
|
|
459
|
-
}); });
|
|
460
|
-
|
|
461
|
-
var Typography = React.forwardRef(function (props, ref) {
|
|
462
|
-
props.weight; var restProps = __rest(props, ["weight"]);
|
|
463
|
-
var classes = useTypographyStyles(props);
|
|
464
|
-
return React__default['default'].createElement(core.Typography, __assign({ ref: ref, classes: classes }, restProps));
|
|
465
|
-
});
|
|
466
|
-
Typography.displayName = 'Typography';
|
|
467
|
-
|
|
468
|
-
var useStyles$1 = core.makeStyles(function (_a) {
|
|
469
|
-
var spacing = _a.spacing;
|
|
470
|
-
return ({
|
|
471
|
-
root: {
|
|
472
|
-
'&:last-child': {
|
|
473
|
-
marginBottom: 0,
|
|
474
|
-
},
|
|
475
|
-
marginBottom: spacing(4),
|
|
476
|
-
padding: spacing(4),
|
|
477
|
-
},
|
|
478
|
-
});
|
|
479
|
-
});
|
|
480
|
-
var Paper = React.forwardRef(function (props, ref) {
|
|
481
|
-
var legacyStyles = props.legacyStyles, restProps = __rest(props, ["legacyStyles"]);
|
|
482
|
-
var classes = useStyles$1(props);
|
|
483
|
-
return React__default['default'].createElement(core.Paper, __assign({}, ref, { classes: __assign({}, (legacyStyles && classes)) }, restProps));
|
|
484
|
-
});
|
|
485
|
-
Paper.displayName = 'Paper';
|
|
486
|
-
Paper.defaultProps = {
|
|
487
|
-
legacyStyles: false,
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
var AUDIO_PLAYER_EVENT_TYPES;
|
|
491
|
-
(function (AUDIO_PLAYER_EVENT_TYPES) {
|
|
492
|
-
AUDIO_PLAYER_EVENT_TYPES["TOGGLE_PLAYBACK"] = "TOGGLE_PLAYBACK";
|
|
493
|
-
AUDIO_PLAYER_EVENT_TYPES["TOGGLE_VOLUME_CONTROL"] = "TOGGLE_VOLUME_CONTROL";
|
|
494
|
-
AUDIO_PLAYER_EVENT_TYPES["TOGGLE_MUTE"] = "TOGGLE_MUTE";
|
|
495
|
-
AUDIO_PLAYER_EVENT_TYPES["VOLUME_CHANGE"] = "VOLUME_CHANGE";
|
|
496
|
-
AUDIO_PLAYER_EVENT_TYPES["TIME_CHANGE"] = "TIME_CHANGE";
|
|
497
|
-
AUDIO_PLAYER_EVENT_TYPES["DURATION_CHANGE"] = "DURATION_CHANGE";
|
|
498
|
-
AUDIO_PLAYER_EVENT_TYPES["SET_TIME"] = "SET_TIME";
|
|
499
|
-
AUDIO_PLAYER_EVENT_TYPES["CAN_PLAY"] = "CAN_PLAY";
|
|
500
|
-
AUDIO_PLAYER_EVENT_TYPES["RESET"] = "RESET";
|
|
501
|
-
})(AUDIO_PLAYER_EVENT_TYPES || (AUDIO_PLAYER_EVENT_TYPES = {}));
|
|
502
|
-
var PLAYBACK_STATES;
|
|
503
|
-
(function (PLAYBACK_STATES) {
|
|
504
|
-
PLAYBACK_STATES["NONE"] = "NONE";
|
|
505
|
-
PLAYBACK_STATES["PAUSED"] = "PAUSED";
|
|
506
|
-
PLAYBACK_STATES["PLAYING"] = "PLAYING";
|
|
507
|
-
})(PLAYBACK_STATES || (PLAYBACK_STATES = {}));
|
|
508
|
-
var CONTROL_LABELS;
|
|
509
|
-
(function (CONTROL_LABELS) {
|
|
510
|
-
CONTROL_LABELS["PAUSE"] = "PAUSE";
|
|
511
|
-
CONTROL_LABELS["PLAY"] = "PLAY";
|
|
512
|
-
CONTROL_LABELS["MUTE"] = "MUTE";
|
|
513
|
-
CONTROL_LABELS["UNMUTE"] = "UNMUTE";
|
|
514
|
-
})(CONTROL_LABELS || (CONTROL_LABELS = {}));
|
|
515
|
-
var VOLUME_CONTROL_STATES;
|
|
516
|
-
(function (VOLUME_CONTROL_STATES) {
|
|
517
|
-
VOLUME_CONTROL_STATES["SHOW"] = "SHOW";
|
|
518
|
-
VOLUME_CONTROL_STATES["HIDE"] = "HIDE";
|
|
519
|
-
})(VOLUME_CONTROL_STATES || (VOLUME_CONTROL_STATES = {}));
|
|
520
|
-
|
|
521
|
-
var initialAudioPlayerState = {
|
|
522
|
-
playback: PLAYBACK_STATES.NONE,
|
|
523
|
-
volumeControls: VOLUME_CONTROL_STATES.HIDE,
|
|
524
|
-
context: {
|
|
525
|
-
volume: 100,
|
|
526
|
-
playbackButtonLabel: CONTROL_LABELS.PLAY,
|
|
527
|
-
volumeButtonLabel: CONTROL_LABELS.MUTE,
|
|
528
|
-
},
|
|
529
|
-
};
|
|
530
|
-
var getPlayback = function (_a) {
|
|
531
|
-
var audio = _a.current;
|
|
532
|
-
var playback = PLAYBACK_STATES.NONE;
|
|
533
|
-
if (audio) {
|
|
534
|
-
var paused = audio.paused, readyState = audio.readyState;
|
|
535
|
-
if (readyState === 0) {
|
|
536
|
-
playback = PLAYBACK_STATES.NONE;
|
|
537
|
-
}
|
|
538
|
-
else if (paused) {
|
|
539
|
-
playback = PLAYBACK_STATES.PAUSED;
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
playback = PLAYBACK_STATES.PLAYING;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
return playback;
|
|
546
|
-
};
|
|
547
|
-
var audioPlayerReducer = function (state, event) {
|
|
548
|
-
var _a, _b;
|
|
549
|
-
var audioRef = state.context.audioRef;
|
|
550
|
-
var nextState = __assign({}, state);
|
|
551
|
-
switch (state.playback) {
|
|
552
|
-
case PLAYBACK_STATES.NONE:
|
|
553
|
-
if (event.type === AUDIO_PLAYER_EVENT_TYPES.CAN_PLAY) {
|
|
554
|
-
nextState.playback = getPlayback(audioRef);
|
|
555
|
-
return nextState;
|
|
556
|
-
}
|
|
557
|
-
break;
|
|
558
|
-
case PLAYBACK_STATES.PAUSED:
|
|
559
|
-
if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK) {
|
|
560
|
-
(_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
|
561
|
-
nextState.playback = getPlayback(audioRef);
|
|
562
|
-
nextState.context.playbackButtonLabel = CONTROL_LABELS.PAUSE;
|
|
563
|
-
return nextState;
|
|
564
|
-
}
|
|
565
|
-
break;
|
|
566
|
-
case PLAYBACK_STATES.PLAYING:
|
|
567
|
-
if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK) {
|
|
568
|
-
(_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.pause();
|
|
569
|
-
nextState.playback = getPlayback(audioRef);
|
|
570
|
-
nextState.context.playbackButtonLabel = CONTROL_LABELS.PLAY;
|
|
571
|
-
return nextState;
|
|
572
|
-
}
|
|
573
|
-
if (event.type === AUDIO_PLAYER_EVENT_TYPES.TIME_CHANGE) {
|
|
574
|
-
return nextState;
|
|
575
|
-
}
|
|
576
|
-
break;
|
|
577
|
-
}
|
|
578
|
-
switch (state.volumeControls) {
|
|
579
|
-
case VOLUME_CONTROL_STATES.SHOW:
|
|
580
|
-
if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_VOLUME_CONTROL) {
|
|
581
|
-
nextState.volumeControls = VOLUME_CONTROL_STATES.HIDE;
|
|
582
|
-
return nextState;
|
|
583
|
-
}
|
|
584
|
-
if (event.type === AUDIO_PLAYER_EVENT_TYPES.VOLUME_CHANGE) {
|
|
585
|
-
if (nextState.context.volume !== event.context.volume) {
|
|
586
|
-
nextState.context.volume = event.context.volume;
|
|
587
|
-
if (audioRef.current) {
|
|
588
|
-
audioRef.current.volume = event.context.volume;
|
|
589
|
-
}
|
|
590
|
-
return nextState;
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
break;
|
|
594
|
-
case VOLUME_CONTROL_STATES.HIDE:
|
|
595
|
-
if (event.type === AUDIO_PLAYER_EVENT_TYPES.TOGGLE_VOLUME_CONTROL) {
|
|
596
|
-
nextState.volumeControls = VOLUME_CONTROL_STATES.SHOW;
|
|
597
|
-
return nextState;
|
|
598
|
-
}
|
|
599
|
-
break;
|
|
600
|
-
}
|
|
601
|
-
switch (event.type) {
|
|
602
|
-
case AUDIO_PLAYER_EVENT_TYPES.TOGGLE_MUTE:
|
|
603
|
-
if (audioRef.current) {
|
|
604
|
-
audioRef.current.muted = !audioRef.current.muted;
|
|
605
|
-
return nextState;
|
|
606
|
-
}
|
|
607
|
-
break;
|
|
608
|
-
case AUDIO_PLAYER_EVENT_TYPES.SET_TIME:
|
|
609
|
-
if (audioRef.current) {
|
|
610
|
-
audioRef.current.currentTime = event.context.time;
|
|
611
|
-
return nextState;
|
|
612
|
-
}
|
|
613
|
-
break;
|
|
614
|
-
case AUDIO_PLAYER_EVENT_TYPES.RESET:
|
|
615
|
-
if (audioRef.current) {
|
|
616
|
-
audioRef.current.currentTime = 0;
|
|
617
|
-
nextState.playback = getPlayback(audioRef);
|
|
618
|
-
return nextState;
|
|
619
|
-
}
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
return state;
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
var useVolumeIcon = function (state) {
|
|
626
|
-
var volumeIcon = SvgVolumeUp;
|
|
627
|
-
if (state.context.volume >= 0.5) {
|
|
628
|
-
volumeIcon = SvgVolumeUp;
|
|
629
|
-
}
|
|
630
|
-
else if (state.context.volume < 0.5 && state.context.volume > 0) {
|
|
631
|
-
volumeIcon = SvgVolumeDown;
|
|
632
|
-
}
|
|
633
|
-
else if (state.context.volume === 0) {
|
|
634
|
-
volumeIcon = SvgVolumeMute;
|
|
635
|
-
}
|
|
636
|
-
if (state.context.audioRef.current) {
|
|
637
|
-
if (state.context.audioRef.current.muted) {
|
|
638
|
-
volumeIcon = SvgVolumeOff;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
return volumeIcon;
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
var appendZero = function (num) { return (num < 10 ? "0" + num : num); };
|
|
645
|
-
var formatTime = function (time, remaning) {
|
|
646
|
-
if (remaning === void 0) { remaning = false; }
|
|
647
|
-
var dateTime = new Date(0, 0, 0, 0, 0, time, 0);
|
|
648
|
-
var dateTimeH = appendZero(dateTime.getHours());
|
|
649
|
-
var dateTimeM = appendZero(dateTime.getMinutes());
|
|
650
|
-
var dateTimeS = appendZero(dateTime.getSeconds());
|
|
651
|
-
var minus = remaning ? '-' : '';
|
|
652
|
-
return dateTimeH > 0 ? "" + minus + dateTimeH + ":" + dateTimeM + ":" + dateTimeS : "" + minus + dateTimeM + ":" + dateTimeS;
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
var setupAudioRef = function (config) { return function () {
|
|
656
|
-
var _a, _b, _c, _d;
|
|
657
|
-
var audioRef = config.audioRef, send = config.send;
|
|
658
|
-
var handleDurationChange = function (event) {
|
|
659
|
-
var duration = event.target.duration;
|
|
660
|
-
send({ type: AUDIO_PLAYER_EVENT_TYPES.DURATION_CHANGE, context: { duration: duration } });
|
|
661
|
-
};
|
|
662
|
-
var handleTimeUpdate = function (event) {
|
|
663
|
-
var currentTime = event.target.currentTime;
|
|
664
|
-
send({ type: AUDIO_PLAYER_EVENT_TYPES.TIME_CHANGE, context: { currentTime: currentTime } });
|
|
665
|
-
};
|
|
666
|
-
var handleCanPlay = function () {
|
|
667
|
-
send({ type: AUDIO_PLAYER_EVENT_TYPES.CAN_PLAY });
|
|
668
|
-
};
|
|
669
|
-
var handleEnded = function () {
|
|
670
|
-
send({ type: AUDIO_PLAYER_EVENT_TYPES.RESET });
|
|
671
|
-
};
|
|
672
|
-
(_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('durationchange', handleDurationChange);
|
|
673
|
-
(_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('timeupdate', handleTimeUpdate);
|
|
674
|
-
(_c = audioRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('canplay', handleCanPlay);
|
|
675
|
-
(_d = audioRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleEnded);
|
|
676
|
-
return function () {
|
|
677
|
-
var _a, _b, _c, _d;
|
|
678
|
-
(_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('durationchange', handleDurationChange);
|
|
679
|
-
(_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('timeupdate', handleTimeUpdate);
|
|
680
|
-
(_c = audioRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('canplay', handleCanPlay);
|
|
681
|
-
(_d = audioRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('ended', handleEnded);
|
|
682
|
-
};
|
|
683
|
-
}; };
|
|
684
|
-
|
|
685
|
-
var AudioPlayer = function (props) {
|
|
686
|
-
var _a, _b, _c, _d, _f;
|
|
687
|
-
var src = props.src, _g = props.classes, classes = _g === void 0 ? {} : _g;
|
|
688
|
-
var volumeRef = React.useRef(null);
|
|
689
|
-
var audioRef = React.useRef(null);
|
|
690
|
-
var spacing = core.useTheme().spacing;
|
|
691
|
-
var _h = React.useState(false), disableRipple = _h[0], setDisableRipple = _h[1];
|
|
692
|
-
var _j = React.useReducer(audioPlayerReducer, __assign(__assign({}, initialAudioPlayerState), { context: __assign(__assign({}, initialAudioPlayerState.context), { audioRef: audioRef }) })), state = _j[0], send = _j[1];
|
|
693
|
-
React.useEffect(setupAudioRef({ audioRef: audioRef, send: send }), [audioRef]);
|
|
694
|
-
var PlaybackIcon = state.playback !== PLAYBACK_STATES.PAUSED ? SvgPause : SvgPlay;
|
|
695
|
-
var VolumeIcon = React.useMemo(function () { return useVolumeIcon(state); }, [state.context.volume, (_a = state.context.audioRef.current) === null || _a === void 0 ? void 0 : _a.muted]);
|
|
696
|
-
var togglePlayback = function () { return send({ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK }); };
|
|
697
|
-
var toggleVolumeControl = function () { return send({ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_VOLUME_CONTROL }); };
|
|
698
|
-
var toggleMute = function () { return send({ type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_MUTE }); };
|
|
699
|
-
var setTime = function (_e, time) { return send({ type: AUDIO_PLAYER_EVENT_TYPES.SET_TIME, context: { time: time } }); };
|
|
700
|
-
var setVolume = function (_e, volume) { return send({ type: AUDIO_PLAYER_EVENT_TYPES.VOLUME_CHANGE, context: { volume: volume } }); };
|
|
701
|
-
return (React__default['default'].createElement(core.Box, { display: "flex", alignItems: "center", gridGap: spacing(1), className: classNames([classes.root]) },
|
|
702
|
-
React__default['default'].createElement("audio", { ref: audioRef, src: src }),
|
|
703
|
-
React__default['default'].createElement(core.Box, null,
|
|
704
|
-
React__default['default'].createElement(IconButton, { classes: { root: classes.playbackToggle }, "aria-label": state.context.playbackButtonLabel, disabled: state.playback === PLAYBACK_STATES.NONE, onClick: togglePlayback },
|
|
705
|
-
React__default['default'].createElement(Icon, { icon: PlaybackIcon })),
|
|
706
|
-
React__default['default'].createElement(IconButton, { classes: { root: classes.volumeToggle }, "aria-label": state.context.volumeButtonLabel, ref: volumeRef, onClick: toggleMute, onMouseEnter: toggleVolumeControl, onMouseLeave: toggleVolumeControl, disableRipple: disableRipple },
|
|
707
|
-
React__default['default'].createElement(Icon, { icon: VolumeIcon }),
|
|
708
|
-
React__default['default'].createElement(core.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([classes.volumeSlider]) }, function (_a) {
|
|
709
|
-
var TransitionProps = _a.TransitionProps;
|
|
710
|
-
return (React__default['default'].createElement(core.Grow, __assign({}, TransitionProps),
|
|
711
|
-
React__default['default'].createElement(Paper, { elevation: 1 },
|
|
712
|
-
React__default['default'].createElement(core.Box, { py: 1, height: 80 },
|
|
713
|
-
React__default['default'].createElement(core.Slider, { color: "secondary", orientation: "vertical", value: state.context.volume, onChange: setVolume, max: 1, step: 0.01 })))));
|
|
714
|
-
}))),
|
|
715
|
-
React__default['default'].createElement(core.Box, { display: "flex", flexGrow: 1, alignItems: "center", gridGap: spacing(1) },
|
|
716
|
-
React__default['default'].createElement(core.Box, { flexBasis: 60, flexShrink: 0 },
|
|
717
|
-
React__default['default'].createElement(Typography, { classes: { root: classes.playbackText } }, formatTime(((_b = state.context.audioRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0))),
|
|
718
|
-
React__default['default'].createElement(core.Slider, { classes: { root: classes.playbackSlider }, color: "secondary", value: ((_c = state.context.audioRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) || 0, max: ((_d = state.context.audioRef.current) === null || _d === void 0 ? void 0 : _d.duration) || 1, onChange: setTime, disabled: state.playback === PLAYBACK_STATES.NONE }),
|
|
719
|
-
React__default['default'].createElement(core.Box, { flexBasis: 60, flexShrink: 0, textAlign: "end" },
|
|
720
|
-
React__default['default'].createElement(Typography, { classes: { root: classes.lengthText } }, formatTime(((_f = state.context.audioRef.current) === null || _f === void 0 ? void 0 : _f.duration) || 0))))));
|
|
721
|
-
};
|
|
722
|
-
|
|
723
326
|
var LoadingStatus;
|
|
724
327
|
(function (LoadingStatus) {
|
|
725
328
|
LoadingStatus["ERROR"] = "ERROR";
|
|
@@ -833,6 +436,32 @@ var Checkbox = React.forwardRef(function (props, ref) {
|
|
|
833
436
|
});
|
|
834
437
|
Checkbox.displayName = 'Checkbox';
|
|
835
438
|
|
|
439
|
+
var useTypographyStyles = styles.makeStyles(function () { return ({
|
|
440
|
+
root: function (_a) {
|
|
441
|
+
var _b;
|
|
442
|
+
var weight = _a.weight;
|
|
443
|
+
return (__assign((_b = {}, _b["& ." + iconStaticClassName] = {
|
|
444
|
+
position: 'relative',
|
|
445
|
+
top: '0.125em',
|
|
446
|
+
padding: '0 0.125em',
|
|
447
|
+
boxSizing: 'content-box',
|
|
448
|
+
}, _b), (weight && { fontWeight: (weight === 'semi-bold' && 600) || (weight === 'bold' && 700) || 400 })));
|
|
449
|
+
},
|
|
450
|
+
caption: {
|
|
451
|
+
display: 'inline',
|
|
452
|
+
},
|
|
453
|
+
overline: {
|
|
454
|
+
display: 'inline',
|
|
455
|
+
},
|
|
456
|
+
}); });
|
|
457
|
+
|
|
458
|
+
var Typography = React.forwardRef(function (props, ref) {
|
|
459
|
+
props.weight; var restProps = __rest(props, ["weight"]);
|
|
460
|
+
var classes = useTypographyStyles(props);
|
|
461
|
+
return React__default['default'].createElement(core.Typography, __assign({ ref: ref, classes: classes }, restProps));
|
|
462
|
+
});
|
|
463
|
+
Typography.displayName = 'Typography';
|
|
464
|
+
|
|
836
465
|
var getFadeStop = function (_a, typographyVariant) {
|
|
837
466
|
var typography = _a.typography;
|
|
838
467
|
return !isNaN(Number(typography[typographyVariant].lineHeight))
|
|
@@ -891,7 +520,7 @@ var SemanticColors;
|
|
|
891
520
|
SemanticColors["SECONDARY_DARK"] = "secondary.dark";
|
|
892
521
|
SemanticColors["SECONDARY_LIGHT"] = "secondary.light";
|
|
893
522
|
})(SemanticColors || (SemanticColors = {}));
|
|
894
|
-
var useStyles = core.makeStyles(function (theme) { return ({
|
|
523
|
+
var useStyles$1 = core.makeStyles(function (theme) { return ({
|
|
895
524
|
dividerRoot: {
|
|
896
525
|
gap: theme.spacing(2),
|
|
897
526
|
},
|
|
@@ -929,7 +558,7 @@ var useStyles = core.makeStyles(function (theme) { return ({
|
|
|
929
558
|
}); });
|
|
930
559
|
var Divider = function (props) {
|
|
931
560
|
var className = props.className, text = props.text, textTransform = props.textTransform, TypographyProps = props.TypographyProps;
|
|
932
|
-
var classes = useStyles(props);
|
|
561
|
+
var classes = useStyles$1(props);
|
|
933
562
|
var casingOffset = textTransform === 'lowercase' ? '.25rem' : 'unset';
|
|
934
563
|
return (React__default['default'].createElement(core.Box, { className: classNames([classes.dividerRoot, className]), display: "flex", alignItems: "center" },
|
|
935
564
|
React__default['default'].createElement(core.Box, { className: classes.dividerLine, display: "flex", flexGrow: 1, height: "1px", marginTop: casingOffset }),
|
|
@@ -942,6 +571,14 @@ Divider.defaultProps = {
|
|
|
942
571
|
textTransform: 'lowercase',
|
|
943
572
|
};
|
|
944
573
|
|
|
574
|
+
var IconButton = React.forwardRef(function (props, ref) {
|
|
575
|
+
return React__default['default'].createElement(MuiIconButton__default['default'], __assign({ ref: ref }, props));
|
|
576
|
+
});
|
|
577
|
+
IconButton.displayName = 'IconButton';
|
|
578
|
+
IconButton.defaultProps = {
|
|
579
|
+
color: 'secondary',
|
|
580
|
+
};
|
|
581
|
+
|
|
945
582
|
var useLinkStyles = styles.makeStyles(function (theme) { return ({
|
|
946
583
|
root: function (props) {
|
|
947
584
|
var _a;
|
|
@@ -961,6 +598,28 @@ Link.defaultProps = {
|
|
|
961
598
|
};
|
|
962
599
|
Link.displayName = 'Link';
|
|
963
600
|
|
|
601
|
+
var useStyles = core.makeStyles(function (_a) {
|
|
602
|
+
var spacing = _a.spacing;
|
|
603
|
+
return ({
|
|
604
|
+
root: {
|
|
605
|
+
'&:last-child': {
|
|
606
|
+
marginBottom: 0,
|
|
607
|
+
},
|
|
608
|
+
marginBottom: spacing(4),
|
|
609
|
+
padding: spacing(4),
|
|
610
|
+
},
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
var Paper = React.forwardRef(function (props, ref) {
|
|
614
|
+
var legacyStyles = props.legacyStyles, restProps = __rest(props, ["legacyStyles"]);
|
|
615
|
+
var classes = useStyles(props);
|
|
616
|
+
return React__default['default'].createElement(core.Paper, __assign({}, ref, { classes: __assign({}, (legacyStyles && classes)) }, restProps));
|
|
617
|
+
});
|
|
618
|
+
Paper.displayName = 'Paper';
|
|
619
|
+
Paper.defaultProps = {
|
|
620
|
+
legacyStyles: false,
|
|
621
|
+
};
|
|
622
|
+
|
|
964
623
|
var PaperContent = function (props) {
|
|
965
624
|
var children = props.children;
|
|
966
625
|
return React__default['default'].createElement(core.Box, { padding: 4 }, children);
|
|
@@ -1585,7 +1244,6 @@ Object.defineProperty(exports, 'Tabs', {
|
|
|
1585
1244
|
return Tabs__default['default'];
|
|
1586
1245
|
}
|
|
1587
1246
|
});
|
|
1588
|
-
exports.AudioPlayer = AudioPlayer;
|
|
1589
1247
|
exports.Avatar = Avatar;
|
|
1590
1248
|
exports.Button = Button;
|
|
1591
1249
|
exports.Checkbox = Checkbox;
|