@uncinc/uncinc-react-kitchen-sink 2.20.9 → 2.20.11
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/dist/components/MediaPlayer/index.lazy.js +52 -0
- package/dist/components/MediaPlayer/types.d.ts +5 -1
- package/dist/config/i18next/locales/en.json +3 -1
- package/dist/config/i18next/locales/nl.json +3 -1
- package/dist/hooks/useDialogHelpers.d.ts +13 -3
- package/dist/hooks/useDialogHelpers.js +16 -5
- package/package.json +1 -1
|
@@ -8,10 +8,12 @@ import React, { useEffect, useMemo } from 'react';
|
|
|
8
8
|
import c from 'classnames';
|
|
9
9
|
import { useVideoJS } from 'react-hook-videojs';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import VideoJSTypes from 'video.js';
|
|
11
12
|
import 'video.js/dist/video-js.css';
|
|
12
13
|
import './style.scss';
|
|
13
14
|
var MediaPlayer = function MediaPlayer(_ref) {
|
|
14
15
|
var src = _ref.src,
|
|
16
|
+
altVideoSrc = _ref.altVideoSrc,
|
|
15
17
|
type = _ref.type,
|
|
16
18
|
controls = _ref.controls,
|
|
17
19
|
posterUrl = _ref.posterUrl,
|
|
@@ -44,6 +46,7 @@ var MediaPlayer = function MediaPlayer(_ref) {
|
|
|
44
46
|
duration: 'durationDisplay',
|
|
45
47
|
seekbar: 'progressControl',
|
|
46
48
|
captions: 'subsCapsButton',
|
|
49
|
+
audioDescription: 'audioTrackButton',
|
|
47
50
|
volume: 'volumePanel',
|
|
48
51
|
fullscreen: 'fullscreenToggle'
|
|
49
52
|
};
|
|
@@ -96,6 +99,55 @@ var MediaPlayer = function MediaPlayer(_ref) {
|
|
|
96
99
|
if (onReady) {
|
|
97
100
|
onReady(player);
|
|
98
101
|
}
|
|
102
|
+
if (altVideoSrc) {
|
|
103
|
+
var audioTracks = player.audioTracks();
|
|
104
|
+
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
audioTracks.addTrack(new VideoJSTypes.AudioTrack({
|
|
107
|
+
id: 'main',
|
|
108
|
+
kind: 'main',
|
|
109
|
+
label: t('organisms.media_player.standard_audio'),
|
|
110
|
+
language: altVideoSrc.language,
|
|
111
|
+
enabled: true
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
audioTracks.addTrack(new VideoJSTypes.AudioTrack({
|
|
116
|
+
id: 'ad',
|
|
117
|
+
kind: 'alternative',
|
|
118
|
+
label: t('organisms.media_player.alt_audio'),
|
|
119
|
+
language: altVideoSrc.language,
|
|
120
|
+
enabled: false
|
|
121
|
+
}));
|
|
122
|
+
|
|
123
|
+
// Handle switching
|
|
124
|
+
audioTracks.on('change', function () {
|
|
125
|
+
var currentTime = player.currentTime();
|
|
126
|
+
var isPaused = player.paused();
|
|
127
|
+
var activeTrack = Array.from(audioTracks).find(function (track) {
|
|
128
|
+
return track.enabled;
|
|
129
|
+
});
|
|
130
|
+
if (!activeTrack) return;
|
|
131
|
+
if (activeTrack.id === 'ad') {
|
|
132
|
+
player.src({
|
|
133
|
+
src: altVideoSrc.src,
|
|
134
|
+
type: type
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
player.src({
|
|
138
|
+
src: src,
|
|
139
|
+
type: type
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
player.one('loadedmetadata', function () {
|
|
143
|
+
player.currentTime(currentTime);
|
|
144
|
+
if (!isPaused) {
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
146
|
+
player.play();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
99
151
|
if (autoPlay && onPlay) {
|
|
100
152
|
player.one('play', function (event) {
|
|
101
153
|
return onPlay(player, event);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { VideoJsPlayer as NativeVideoJsPlayer, VideoJsPlayerOptions } from 'video.js';
|
|
2
2
|
export type MimeType = 'audio/3gpp' | 'audio/aac' | 'audio/flac' | 'audio/mpeg' | 'audio/mp3' | 'audio/mp4' | 'audio/ogg' | 'audio/wav' | 'audio/webm' | 'video/3gpp' | 'video/mpeg' | 'video/mpeg' | 'video/mp4' | 'video/ogg' | 'video/quicktime' | 'video/webm' | 'video/youtube' | 'video/vimeo';
|
|
3
|
-
export type Control = 'play' | 'currentTime' | 'timeDivider' | 'duration' | 'seekbar' | 'captions' | 'volume' | 'fullscreen';
|
|
3
|
+
export type Control = 'play' | 'currentTime' | 'timeDivider' | 'duration' | 'seekbar' | 'captions' | 'volume' | 'fullscreen' | 'audioDescription';
|
|
4
4
|
export type VideoJSControls = {
|
|
5
5
|
[K in Control]: string;
|
|
6
6
|
};
|
|
7
7
|
export type VideoJsPlayer = NativeVideoJsPlayer;
|
|
8
8
|
export type MediaPlayerProps = {
|
|
9
9
|
src: string;
|
|
10
|
+
altVideoSrc?: {
|
|
11
|
+
src: string;
|
|
12
|
+
language: string;
|
|
13
|
+
};
|
|
10
14
|
type: MimeType;
|
|
11
15
|
controls?: Control[] | false;
|
|
12
16
|
posterUrl?: string;
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
},
|
|
35
35
|
"organisms": {
|
|
36
36
|
"media_player": {
|
|
37
|
-
"not_supported_message": "The current file cannot be played."
|
|
37
|
+
"not_supported_message": "The current file cannot be played.",
|
|
38
|
+
"standard_audio" : "Standard audio",
|
|
39
|
+
"alt_audio": "Alternative audio"
|
|
38
40
|
},
|
|
39
41
|
"text": {
|
|
40
42
|
"read_more": "Read more",
|
|
@@ -72,7 +72,9 @@
|
|
|
72
72
|
},
|
|
73
73
|
"organisms": {
|
|
74
74
|
"media_player": {
|
|
75
|
-
"not_supported_message": "Het huidige bestand kan niet worden afgespeeld."
|
|
75
|
+
"not_supported_message": "Het huidige bestand kan niet worden afgespeeld.",
|
|
76
|
+
"standard_audio" : "Standaard audio",
|
|
77
|
+
"alt_audio": "Alternatieve audio"
|
|
76
78
|
},
|
|
77
79
|
"text": {
|
|
78
80
|
"read_more": "Lees meer",
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type UseDialogHelpersOptions<T extends HTMLElement> = {
|
|
3
3
|
id?: string;
|
|
4
4
|
wrapperElement: RefObject<T>;
|
|
5
5
|
closeFunction: () => void;
|
|
6
6
|
isOpen: boolean;
|
|
7
7
|
disableClosers: boolean;
|
|
8
|
-
}
|
|
8
|
+
} & ({
|
|
9
|
+
ariaLabel: string;
|
|
10
|
+
ariaLabelledBy?: never;
|
|
11
|
+
} | {
|
|
12
|
+
ariaLabel?: never;
|
|
13
|
+
ariaLabelledBy: string;
|
|
14
|
+
} | {
|
|
15
|
+
ariaLabel?: never;
|
|
16
|
+
ariaLabelledBy?: never;
|
|
17
|
+
});
|
|
9
18
|
/**
|
|
10
19
|
* Hook to allow you to implement your own Dialog component.
|
|
11
20
|
* This takes care of focus, and closing the Dialog by
|
|
@@ -15,7 +24,8 @@ export default function useDialogHelpers<T extends HTMLElement>(options: UseDial
|
|
|
15
24
|
readonly id: string;
|
|
16
25
|
readonly labelId: string;
|
|
17
26
|
readonly dialogHelpersProps: {
|
|
27
|
+
'aria-labelledby'?: string | undefined;
|
|
28
|
+
'aria-label'?: string | undefined;
|
|
18
29
|
role: string;
|
|
19
|
-
'aria-labelledby': string;
|
|
20
30
|
};
|
|
21
31
|
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
1
7
|
import { useEffect } from 'react';
|
|
2
8
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
9
|
import useClickOutside from './useClickOutside';
|
|
@@ -14,7 +20,9 @@ export default function useDialogHelpers(options) {
|
|
|
14
20
|
wrapperElement = options.wrapperElement,
|
|
15
21
|
closeFunction = options.closeFunction,
|
|
16
22
|
isOpen = options.isOpen,
|
|
17
|
-
disableClosers = options.disableClosers
|
|
23
|
+
disableClosers = options.disableClosers,
|
|
24
|
+
ariaLabel = options.ariaLabel,
|
|
25
|
+
ariaLabelledBy = options.ariaLabelledBy;
|
|
18
26
|
|
|
19
27
|
/**
|
|
20
28
|
* Allows you to disable these two hooks.
|
|
@@ -72,10 +80,13 @@ export default function useDialogHelpers(options) {
|
|
|
72
80
|
* Create a labelId for A11Y
|
|
73
81
|
*/
|
|
74
82
|
var labelId = "".concat(id, "-label");
|
|
75
|
-
var dialogHelpersProps = {
|
|
76
|
-
role: 'dialog'
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
var dialogHelpersProps = _objectSpread(_objectSpread({
|
|
84
|
+
role: 'dialog'
|
|
85
|
+
}, ariaLabel && {
|
|
86
|
+
'aria-label': ariaLabel
|
|
87
|
+
}), ariaLabelledBy && {
|
|
88
|
+
'aria-labelledby': ariaLabelledBy
|
|
89
|
+
});
|
|
79
90
|
return {
|
|
80
91
|
id: id,
|
|
81
92
|
labelId: labelId,
|