@vonage/vivid 3.52.0 → 3.54.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/README.md +1 -1
- package/accordion/index.cjs +1 -1
- package/accordion/index.js +1 -1
- package/accordion-item/index.cjs +1 -1
- package/accordion-item/index.js +1 -1
- package/alert/index.cjs +3 -3
- package/alert/index.js +3 -3
- package/appearance-ui/index.cjs +1 -1
- package/appearance-ui/index.js +1 -1
- package/audio-player/index.cjs +3 -3
- package/audio-player/index.js +3 -3
- package/avatar/index.cjs +1 -1
- package/avatar/index.js +1 -1
- package/badge/index.cjs +1 -1
- package/badge/index.js +1 -1
- package/banner/index.cjs +2 -2
- package/banner/index.js +2 -2
- package/breadcrumb-item/index.cjs +1 -1
- package/breadcrumb-item/index.js +1 -1
- package/button/index.cjs +2 -2
- package/button/index.js +2 -2
- package/card/index.cjs +2 -2
- package/card/index.js +2 -2
- package/checkbox/index.cjs +3 -2
- package/checkbox/index.js +3 -2
- package/combobox/index.cjs +5 -5
- package/combobox/index.js +5 -5
- package/custom-elements.json +1162 -99
- package/data-grid/index.cjs +1 -1
- package/data-grid/index.js +1 -1
- package/date-picker/index.cjs +7 -6
- package/date-picker/index.js +7 -6
- package/date-range-picker/index.cjs +7 -6
- package/date-range-picker/index.js +7 -6
- package/dial-pad/index.cjs +33 -0
- package/dial-pad/index.js +31 -0
- package/dialog/index.cjs +4 -4
- package/dialog/index.js +4 -4
- package/divider/index.cjs +1 -1
- package/divider/index.js +1 -1
- package/elevation/index.cjs +1 -1
- package/elevation/index.js +1 -1
- package/empty-state/index.cjs +2 -2
- package/empty-state/index.js +2 -2
- package/fab/index.cjs +2 -2
- package/fab/index.js +2 -2
- package/file-picker/index.cjs +4 -3
- package/file-picker/index.js +4 -3
- package/header/index.cjs +2 -2
- package/header/index.js +2 -2
- package/icon/index.cjs +1 -1
- package/icon/index.js +1 -1
- package/index.cjs +132 -122
- package/index.js +46 -43
- package/layout/index.cjs +1 -1
- package/layout/index.js +1 -1
- package/lib/appearance-ui/appearance-ui.d.ts +1 -1
- package/lib/audio-player/audio-player.d.ts +4 -0
- package/lib/audio-player/locale.d.ts +2 -0
- package/lib/components.d.ts +2 -0
- package/lib/dial-pad/definition.d.ts +3 -0
- package/lib/dial-pad/dial-pad.d.ts +17 -0
- package/lib/dial-pad/dial-pad.template.d.ts +4 -0
- package/lib/dial-pad/locale.d.ts +18 -0
- package/lib/enums.d.ts +7 -0
- package/lib/menu/menu.d.ts +1 -0
- package/lib/nav-disclosure/nav-disclosure.d.ts +5 -0
- package/lib/text-anchor/definition.d.ts +1 -0
- package/lib/text-anchor/text-anchor.d.ts +5 -0
- package/lib/video-player/definition.d.ts +3 -0
- package/lib/video-player/locale.d.ts +1 -0
- package/lib/video-player/video-player.d.ts +17 -0
- package/lib/video-player/video-player.template.d.ts +4 -0
- package/lib/video-player/vivid-video-svg.d.ts +1 -0
- package/listbox/index.cjs +2 -2
- package/listbox/index.js +2 -2
- package/locales/en-GB.cjs +33 -1
- package/locales/en-GB.js +33 -1
- package/locales/en-US.cjs +201 -1
- package/locales/en-US.js +201 -1
- package/locales/ja-JP.cjs +200 -1
- package/locales/ja-JP.js +200 -1
- package/locales/zh-CN.cjs +202 -1
- package/locales/zh-CN.js +202 -1
- package/menu/index.cjs +6 -6
- package/menu/index.js +6 -6
- package/menu-item/index.cjs +2 -2
- package/menu-item/index.js +2 -2
- package/nav/index.cjs +1 -1
- package/nav/index.js +1 -1
- package/nav-disclosure/index.cjs +2 -2
- package/nav-disclosure/index.js +2 -2
- package/nav-item/index.cjs +2 -2
- package/nav-item/index.js +2 -2
- package/note/index.cjs +2 -2
- package/note/index.js +2 -2
- package/number-field/index.cjs +5 -4
- package/number-field/index.js +5 -4
- package/option/index.cjs +2 -2
- package/option/index.js +2 -2
- package/package.json +1 -1
- package/pagination/index.cjs +3 -3
- package/pagination/index.js +3 -3
- package/popup/index.cjs +4 -4
- package/popup/index.js +4 -4
- package/progress/index.cjs +1 -1
- package/progress/index.js +1 -1
- package/progress-ring/index.cjs +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.cjs +1 -1
- package/radio/index.js +1 -1
- package/radio-group/index.cjs +1 -1
- package/radio-group/index.js +1 -1
- package/range-slider/index.cjs +2 -2
- package/range-slider/index.js +2 -2
- package/select/index.cjs +7 -6
- package/select/index.js +7 -6
- package/selectable-box/index.cjs +5 -4
- package/selectable-box/index.js +5 -4
- package/shared/applyMixinsWithObservables.cjs +15 -0
- package/shared/applyMixinsWithObservables.js +13 -0
- package/shared/definition.cjs +1 -1
- package/shared/definition.js +1 -1
- package/shared/definition11.cjs +3 -3
- package/shared/definition11.js +3 -3
- package/shared/definition14.cjs +2 -2
- package/shared/definition14.js +2 -2
- package/shared/definition15.cjs +8 -9
- package/shared/definition15.js +8 -9
- package/shared/definition16.cjs +3 -3
- package/shared/definition16.js +3 -3
- package/shared/definition17.cjs +2 -2
- package/shared/definition17.js +3 -3
- package/shared/definition18.cjs +3 -3
- package/shared/definition18.js +3 -3
- package/shared/definition19.cjs +3 -3
- package/shared/definition19.js +3 -3
- package/shared/definition20.cjs +196 -224
- package/shared/definition20.js +191 -219
- package/shared/definition21.cjs +264 -67
- package/shared/definition21.js +263 -65
- package/shared/definition22.cjs +66 -57
- package/shared/definition22.js +64 -56
- package/shared/definition23.cjs +42 -76
- package/shared/definition23.js +41 -75
- package/shared/definition24.cjs +70 -2402
- package/shared/definition24.js +69 -2401
- package/shared/definition25.cjs +2402 -46
- package/shared/definition25.js +2401 -45
- package/shared/definition26.cjs +63 -30
- package/shared/definition26.js +62 -29
- package/shared/definition27.cjs +28 -56
- package/shared/definition27.js +27 -55
- package/shared/definition28.cjs +35 -881
- package/shared/definition28.js +34 -879
- package/shared/definition29.cjs +922 -60
- package/shared/definition29.js +922 -61
- package/shared/definition30.cjs +68 -86
- package/shared/definition30.js +67 -85
- package/shared/definition31.cjs +98 -21
- package/shared/definition31.js +98 -21
- package/shared/definition32.cjs +24 -12
- package/shared/definition32.js +23 -11
- package/shared/definition33.cjs +11 -50
- package/shared/definition33.js +10 -49
- package/shared/definition34.cjs +26 -515
- package/shared/definition34.js +26 -515
- package/shared/definition35.cjs +448 -194
- package/shared/definition35.js +448 -192
- package/shared/definition36.cjs +256 -202
- package/shared/definition36.js +253 -201
- package/shared/definition37.cjs +204 -65
- package/shared/definition37.js +203 -63
- package/shared/definition38.cjs +63 -57
- package/shared/definition38.js +60 -55
- package/shared/definition39.cjs +65 -432
- package/shared/definition39.js +64 -431
- package/shared/definition4.cjs +2 -2
- package/shared/definition4.js +2 -2
- package/shared/definition40.cjs +441 -34
- package/shared/definition40.js +438 -31
- package/shared/definition41.cjs +34 -576
- package/shared/definition41.js +33 -575
- package/shared/definition42.cjs +531 -654
- package/shared/definition42.js +531 -654
- package/shared/definition43.cjs +690 -114
- package/shared/definition43.js +689 -113
- package/shared/definition44.cjs +124 -79
- package/shared/definition44.js +122 -77
- package/shared/definition45.cjs +78 -520
- package/shared/definition45.js +77 -518
- package/shared/definition46.cjs +520 -119
- package/shared/definition46.js +518 -118
- package/shared/definition47.cjs +118 -135
- package/shared/definition47.js +117 -134
- package/shared/definition48.cjs +151 -19
- package/shared/definition48.js +150 -18
- package/shared/definition49.cjs +21 -84
- package/shared/definition49.js +20 -83
- package/shared/definition5.cjs +100 -19
- package/shared/definition5.js +100 -19
- package/shared/definition50.cjs +52 -505
- package/shared/definition50.js +51 -504
- package/shared/definition51.cjs +526 -28
- package/shared/definition51.js +525 -27
- package/shared/definition52.cjs +28 -123
- package/shared/definition52.js +26 -122
- package/shared/definition53.cjs +110 -309
- package/shared/definition53.js +110 -308
- package/shared/definition54.cjs +255 -271
- package/shared/definition54.js +255 -271
- package/shared/definition55.cjs +315 -776
- package/shared/definition55.js +314 -775
- package/shared/definition56.cjs +818 -107
- package/shared/definition56.js +817 -106
- package/shared/definition57.cjs +85 -55
- package/shared/definition57.js +84 -54
- package/shared/definition58.cjs +125 -72
- package/shared/definition58.js +124 -71
- package/shared/definition59.cjs +72 -285
- package/shared/definition59.js +73 -286
- package/shared/definition6.cjs +1 -1
- package/shared/definition6.js +1 -1
- package/shared/definition60.cjs +298 -39
- package/shared/definition60.js +297 -38
- package/shared/definition61.cjs +66044 -1687
- package/shared/definition61.js +66043 -1686
- package/shared/definition62.cjs +50 -0
- package/shared/definition62.js +46 -0
- package/shared/definition63.cjs +1828 -0
- package/shared/definition63.js +1824 -0
- package/shared/definition7.cjs +2 -2
- package/shared/definition7.js +2 -2
- package/shared/definition8.cjs +2 -2
- package/shared/definition8.js +2 -2
- package/shared/definition9.cjs +1 -1
- package/shared/definition9.js +1 -1
- package/shared/enums.cjs +9 -0
- package/shared/enums.js +9 -1
- package/shared/icon.cjs +20 -2
- package/shared/icon.js +21 -3
- package/shared/index2.cjs +73 -37
- package/shared/index2.js +73 -37
- package/shared/key-codes2.js +1 -1
- package/shared/listbox.cjs +1 -1
- package/shared/listbox.js +1 -1
- package/shared/localization/Locale.d.ts +4 -0
- package/shared/patterns/form-elements/form-elements.d.ts +2 -3
- package/shared/presentationDate.cjs +16 -5
- package/shared/presentationDate.js +16 -5
- package/shared/text-anchor.cjs +6 -0
- package/shared/text-anchor.js +6 -0
- package/shared/text-anchor.template.cjs +6 -1
- package/shared/text-anchor.template.js +6 -1
- package/shared/text-field.cjs +1 -1
- package/shared/text-field.js +1 -1
- package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
- package/shared/utils/numberConverter.d.ts +2 -0
- package/side-drawer/index.cjs +1 -1
- package/side-drawer/index.js +1 -1
- package/slider/index.cjs +1 -1
- package/slider/index.js +1 -1
- package/split-button/index.cjs +2 -2
- package/split-button/index.js +2 -2
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/switch/index.cjs +2 -2
- package/switch/index.js +2 -2
- package/tab/index.cjs +2 -2
- package/tab/index.js +2 -2
- package/tab-panel/index.cjs +1 -1
- package/tab-panel/index.js +1 -1
- package/tabs/index.cjs +4 -4
- package/tabs/index.js +4 -4
- package/tag/index.cjs +2 -2
- package/tag/index.js +2 -2
- package/tag-group/index.cjs +1 -1
- package/tag-group/index.js +1 -1
- package/text-area/index.cjs +4 -3
- package/text-area/index.js +4 -3
- package/text-field/index.cjs +4 -3
- package/text-field/index.js +4 -3
- package/time-picker/index.cjs +8 -7
- package/time-picker/index.js +8 -7
- package/toggletip/index.cjs +5 -5
- package/toggletip/index.js +5 -5
- package/tooltip/index.cjs +5 -5
- package/tooltip/index.js +5 -5
- package/tree-item/index.cjs +2 -2
- package/tree-item/index.js +2 -2
- package/tree-view/index.cjs +1 -1
- package/tree-view/index.js +1 -1
- package/video-player/index.cjs +17 -0
- package/video-player/index.js +15 -0
- package/vivid.api.json +332 -0
package/shared/definition5.cjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const index = require('./index.cjs');
|
|
4
4
|
const definition = require('./definition11.cjs');
|
|
5
|
-
const definition$1 = require('./
|
|
5
|
+
const definition$1 = require('./definition46.cjs');
|
|
6
|
+
const enums = require('./enums.cjs');
|
|
6
7
|
require('./affix.cjs');
|
|
7
8
|
require('./index2.cjs');
|
|
8
9
|
const localized = require('./localized.cjs');
|
|
@@ -24,12 +25,22 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
24
25
|
__defProp(target, key, result);
|
|
25
26
|
return result;
|
|
26
27
|
};
|
|
28
|
+
const validSkipByConverter = {
|
|
29
|
+
toView(value) {
|
|
30
|
+
return value;
|
|
31
|
+
},
|
|
32
|
+
fromView(value) {
|
|
33
|
+
return Object.values(enums.MediaSkipBy).includes(value) ? value : void 0;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
27
36
|
class AudioPlayer extends index.FoundationElement {
|
|
28
37
|
constructor() {
|
|
29
38
|
super(...arguments);
|
|
30
39
|
this.playButtonAriaLabel = null;
|
|
31
40
|
this.pauseButtonAriaLabel = null;
|
|
32
41
|
this.sliderAriaLabel = null;
|
|
42
|
+
this.skipForwardButtonAriaLabel = null;
|
|
43
|
+
this.skipBackwardButtonAriaLabel = null;
|
|
33
44
|
this.disabled = false;
|
|
34
45
|
this.notime = false;
|
|
35
46
|
this.paused = true;
|
|
@@ -37,26 +48,18 @@ class AudioPlayer extends index.FoundationElement {
|
|
|
37
48
|
* @internal
|
|
38
49
|
*/
|
|
39
50
|
this._rewind = () => {
|
|
40
|
-
this.paused = true;
|
|
41
51
|
if (this._playerEl) {
|
|
42
|
-
this._playerEl.pause();
|
|
43
52
|
this._playerEl.currentTime = this._playerEl.duration * (Number(this._sliderEl.value) / 100);
|
|
44
53
|
}
|
|
45
54
|
};
|
|
46
55
|
}
|
|
47
56
|
connectedCallback() {
|
|
48
57
|
super.connectedCallback();
|
|
49
|
-
this.addEventListener("keydown", this._rewind);
|
|
50
|
-
this.addEventListener("mousedown", this._rewind);
|
|
51
|
-
this.addEventListener("keyup", this._rewind);
|
|
52
58
|
document.addEventListener("mouseup", this._rewind);
|
|
53
59
|
}
|
|
54
60
|
disconnectedCallback() {
|
|
55
61
|
super.disconnectedCallback();
|
|
56
|
-
|
|
57
|
-
this.removeEventListener("mousedown", this._rewind);
|
|
58
|
-
this.removeEventListener("keyup", this._rewind);
|
|
59
|
-
document.removeEventListener("mouseup", this._rewind);
|
|
62
|
+
document.addEventListener("mouseup", this._rewind);
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* @internal
|
|
@@ -70,6 +73,22 @@ class AudioPlayer extends index.FoundationElement {
|
|
|
70
73
|
}
|
|
71
74
|
this.paused = !this.paused;
|
|
72
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
_onSkipButtonClick(isForward) {
|
|
80
|
+
if (this._playerEl) {
|
|
81
|
+
const currentTime = this._playerEl.currentTime;
|
|
82
|
+
const skipDirection = isForward ? 1 : -1;
|
|
83
|
+
const skipValue = parseInt(this.skipBy) * skipDirection;
|
|
84
|
+
const newTime = currentTime + skipValue;
|
|
85
|
+
this._playerEl.currentTime = Math.max(
|
|
86
|
+
0,
|
|
87
|
+
Math.min(this._playerEl.duration, newTime)
|
|
88
|
+
);
|
|
89
|
+
this._updateProgress();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
73
92
|
/**
|
|
74
93
|
* @internal
|
|
75
94
|
*/
|
|
@@ -103,6 +122,19 @@ class AudioPlayer extends index.FoundationElement {
|
|
|
103
122
|
totalTime.textContent = this._formatTime(this._playerEl.duration);
|
|
104
123
|
}
|
|
105
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
_handleSliderEvent(event) {
|
|
129
|
+
if (event.target === this._sliderEl) {
|
|
130
|
+
this.paused = true;
|
|
131
|
+
if (this._playerEl) {
|
|
132
|
+
this._playerEl.pause();
|
|
133
|
+
}
|
|
134
|
+
this._rewind();
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
106
138
|
/**
|
|
107
139
|
* @internal
|
|
108
140
|
*/
|
|
@@ -121,6 +153,12 @@ __decorateClass([
|
|
|
121
153
|
__decorateClass([
|
|
122
154
|
index.attr({ attribute: "slider-aria-label" })
|
|
123
155
|
], AudioPlayer.prototype, "sliderAriaLabel", 2);
|
|
156
|
+
__decorateClass([
|
|
157
|
+
index.attr({ attribute: "skip-forward-aria-label" })
|
|
158
|
+
], AudioPlayer.prototype, "skipForwardButtonAriaLabel", 2);
|
|
159
|
+
__decorateClass([
|
|
160
|
+
index.attr({ attribute: "skip-backward-aria-label" })
|
|
161
|
+
], AudioPlayer.prototype, "skipBackwardButtonAriaLabel", 2);
|
|
124
162
|
__decorateClass([
|
|
125
163
|
index.attr
|
|
126
164
|
], AudioPlayer.prototype, "connotation", 2);
|
|
@@ -133,6 +171,12 @@ __decorateClass([
|
|
|
133
171
|
__decorateClass([
|
|
134
172
|
index.attr({ mode: "boolean" })
|
|
135
173
|
], AudioPlayer.prototype, "notime", 2);
|
|
174
|
+
__decorateClass([
|
|
175
|
+
index.attr({
|
|
176
|
+
attribute: "skip-by",
|
|
177
|
+
converter: validSkipByConverter
|
|
178
|
+
})
|
|
179
|
+
], AudioPlayer.prototype, "skipBy", 2);
|
|
136
180
|
__decorateClass([
|
|
137
181
|
index.observable
|
|
138
182
|
], AudioPlayer.prototype, "paused", 2);
|
|
@@ -145,19 +189,43 @@ const getClasses = ({ disabled, duration }) => classNames.classNames(["disabled"
|
|
|
145
189
|
function renderButton(context) {
|
|
146
190
|
const buttonTag = context.tagFor(definition.Button);
|
|
147
191
|
return index.html`<${buttonTag} class="pause" @click="${(x) => x._togglePlay()}"
|
|
148
|
-
icon="${(x) => x.paused ? "play-solid" : "pause-solid"}"
|
|
149
|
-
aria-label="${(x) => x.paused ? x.playButtonAriaLabel || x.locale.audioPlayer.playButtonLabel : x.pauseButtonAriaLabel || x.locale.audioPlayer.
|
|
150
|
-
size='condensed'
|
|
192
|
+
icon="${(x) => x.paused ? "play-solid" : "pause-solid"}"
|
|
193
|
+
aria-label="${(x) => x.paused ? x.playButtonAriaLabel || x.locale.audioPlayer.playButtonLabel : x.pauseButtonAriaLabel || x.locale.audioPlayer.pauseButtonLabel}"
|
|
194
|
+
size='condensed'
|
|
151
195
|
connotation="${(x) => x.connotation}"
|
|
152
|
-
?disabled="${(x) => x.disabled || !x.duration}"
|
|
196
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
153
197
|
></${buttonTag}>`;
|
|
154
198
|
}
|
|
199
|
+
function renderBackwardSkipButtons(context) {
|
|
200
|
+
const buttonTag = context.tagFor(definition.Button);
|
|
201
|
+
return index.html`
|
|
202
|
+
<${buttonTag} class="skip backward" @click="${(x) => x._onSkipButtonClick(false)}"
|
|
203
|
+
icon="${(x) => x.skipBy == enums.MediaSkipBy.Five ? "5-sec-backward-line" : x.skipBy == enums.MediaSkipBy.Thirty ? "30-sec-backward-line" : "10-sec-backward-line"}"
|
|
204
|
+
size='condensed'
|
|
205
|
+
aria-label="${(x) => x.skipBackwardButtonAriaLabel || x.locale.audioPlayer.skipBackwardButton}"
|
|
206
|
+
connotation="${(x) => x.connotation}"
|
|
207
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
208
|
+
></${buttonTag}>
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
function renderForwardSkipButtons(context) {
|
|
212
|
+
const buttonTag = context.tagFor(definition.Button);
|
|
213
|
+
return index.html`
|
|
214
|
+
<${buttonTag} class="skip forward" @click="${(x) => x._onSkipButtonClick(true)}"
|
|
215
|
+
icon="${(x) => x.skipBy == enums.MediaSkipBy.Five ? "5-sec-forward-line" : x.skipBy == enums.MediaSkipBy.Thirty ? "30-sec-forward-line" : "10-sec-forward-line"}"
|
|
216
|
+
size='condensed'
|
|
217
|
+
aria-label="${(x) => x.skipForwardButtonAriaLabel || x.locale.audioPlayer.skipForwardButton}"
|
|
218
|
+
connotation="${(x) => x.connotation}"
|
|
219
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
220
|
+
></${buttonTag}>
|
|
221
|
+
`;
|
|
222
|
+
}
|
|
155
223
|
function renderSlider(context) {
|
|
156
224
|
const sliderTag = context.tagFor(definition$1.Slider);
|
|
157
225
|
return index.html`<${sliderTag}
|
|
158
|
-
${ref.ref("_sliderEl")} class="slider"
|
|
226
|
+
${ref.ref("_sliderEl")} class="slider"
|
|
159
227
|
aria-label="${(x) => x.sliderAriaLabel || x.locale.audioPlayer.sliderLabel}"
|
|
160
|
-
value="0" max="100"
|
|
228
|
+
value="0" max="100"
|
|
161
229
|
connotation="${(x) => x.connotation}"
|
|
162
230
|
?disabled="${(x) => x.disabled || !x.duration}">
|
|
163
231
|
</${sliderTag}>`;
|
|
@@ -170,10 +238,23 @@ function renderTimestamp() {
|
|
|
170
238
|
</div>`;
|
|
171
239
|
}
|
|
172
240
|
const AudioPlayerTemplate = (context) => {
|
|
173
|
-
return index.html` <div
|
|
241
|
+
return index.html` <div
|
|
242
|
+
class="base ${getClasses}"
|
|
243
|
+
@keyup="${(x, c) => x._handleSliderEvent(c.event)}"
|
|
244
|
+
@keydown="${(x, c) => x._handleSliderEvent(c.event)}"
|
|
245
|
+
@mousedown="${(x, c) => x._handleSliderEvent(c.event)}"
|
|
246
|
+
>
|
|
174
247
|
<div class="controls">
|
|
175
|
-
${
|
|
176
|
-
|
|
248
|
+
${when.when(
|
|
249
|
+
(x) => x.skipBy && x.skipBy != enums.MediaSkipBy.Zero,
|
|
250
|
+
renderBackwardSkipButtons(context)
|
|
251
|
+
)}
|
|
252
|
+
${renderButton(context)}
|
|
253
|
+
${when.when(
|
|
254
|
+
(x) => x.skipBy && x.skipBy != enums.MediaSkipBy.Zero,
|
|
255
|
+
renderForwardSkipButtons(context)
|
|
256
|
+
)}
|
|
257
|
+
${when.when((x) => !x.notime, renderTimestamp())} ${renderSlider(context)}
|
|
177
258
|
</div>
|
|
178
259
|
<audio
|
|
179
260
|
${ref.ref("_playerEl")}
|
package/shared/definition5.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { a as attr, F as FoundationElement, o as observable, h as html, r as registerFactory } from './index.js';
|
|
2
2
|
import { B as Button, a as buttonRegistries } from './definition11.js';
|
|
3
|
-
import { S as Slider, a as sliderRegistries } from './
|
|
3
|
+
import { S as Slider, a as sliderRegistries } from './definition46.js';
|
|
4
|
+
import { M as MediaSkipBy } from './enums.js';
|
|
4
5
|
import './affix.js';
|
|
5
6
|
import './index2.js';
|
|
6
7
|
import { L as Localized } from './localized.js';
|
|
@@ -22,12 +23,22 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
22
23
|
__defProp(target, key, result);
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
26
|
+
const validSkipByConverter = {
|
|
27
|
+
toView(value) {
|
|
28
|
+
return value;
|
|
29
|
+
},
|
|
30
|
+
fromView(value) {
|
|
31
|
+
return Object.values(MediaSkipBy).includes(value) ? value : void 0;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
25
34
|
class AudioPlayer extends FoundationElement {
|
|
26
35
|
constructor() {
|
|
27
36
|
super(...arguments);
|
|
28
37
|
this.playButtonAriaLabel = null;
|
|
29
38
|
this.pauseButtonAriaLabel = null;
|
|
30
39
|
this.sliderAriaLabel = null;
|
|
40
|
+
this.skipForwardButtonAriaLabel = null;
|
|
41
|
+
this.skipBackwardButtonAriaLabel = null;
|
|
31
42
|
this.disabled = false;
|
|
32
43
|
this.notime = false;
|
|
33
44
|
this.paused = true;
|
|
@@ -35,26 +46,18 @@ class AudioPlayer extends FoundationElement {
|
|
|
35
46
|
* @internal
|
|
36
47
|
*/
|
|
37
48
|
this._rewind = () => {
|
|
38
|
-
this.paused = true;
|
|
39
49
|
if (this._playerEl) {
|
|
40
|
-
this._playerEl.pause();
|
|
41
50
|
this._playerEl.currentTime = this._playerEl.duration * (Number(this._sliderEl.value) / 100);
|
|
42
51
|
}
|
|
43
52
|
};
|
|
44
53
|
}
|
|
45
54
|
connectedCallback() {
|
|
46
55
|
super.connectedCallback();
|
|
47
|
-
this.addEventListener("keydown", this._rewind);
|
|
48
|
-
this.addEventListener("mousedown", this._rewind);
|
|
49
|
-
this.addEventListener("keyup", this._rewind);
|
|
50
56
|
document.addEventListener("mouseup", this._rewind);
|
|
51
57
|
}
|
|
52
58
|
disconnectedCallback() {
|
|
53
59
|
super.disconnectedCallback();
|
|
54
|
-
|
|
55
|
-
this.removeEventListener("mousedown", this._rewind);
|
|
56
|
-
this.removeEventListener("keyup", this._rewind);
|
|
57
|
-
document.removeEventListener("mouseup", this._rewind);
|
|
60
|
+
document.addEventListener("mouseup", this._rewind);
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
60
63
|
* @internal
|
|
@@ -68,6 +71,22 @@ class AudioPlayer extends FoundationElement {
|
|
|
68
71
|
}
|
|
69
72
|
this.paused = !this.paused;
|
|
70
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
_onSkipButtonClick(isForward) {
|
|
78
|
+
if (this._playerEl) {
|
|
79
|
+
const currentTime = this._playerEl.currentTime;
|
|
80
|
+
const skipDirection = isForward ? 1 : -1;
|
|
81
|
+
const skipValue = parseInt(this.skipBy) * skipDirection;
|
|
82
|
+
const newTime = currentTime + skipValue;
|
|
83
|
+
this._playerEl.currentTime = Math.max(
|
|
84
|
+
0,
|
|
85
|
+
Math.min(this._playerEl.duration, newTime)
|
|
86
|
+
);
|
|
87
|
+
this._updateProgress();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
71
90
|
/**
|
|
72
91
|
* @internal
|
|
73
92
|
*/
|
|
@@ -101,6 +120,19 @@ class AudioPlayer extends FoundationElement {
|
|
|
101
120
|
totalTime.textContent = this._formatTime(this._playerEl.duration);
|
|
102
121
|
}
|
|
103
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
_handleSliderEvent(event) {
|
|
127
|
+
if (event.target === this._sliderEl) {
|
|
128
|
+
this.paused = true;
|
|
129
|
+
if (this._playerEl) {
|
|
130
|
+
this._playerEl.pause();
|
|
131
|
+
}
|
|
132
|
+
this._rewind();
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
104
136
|
/**
|
|
105
137
|
* @internal
|
|
106
138
|
*/
|
|
@@ -119,6 +151,12 @@ __decorateClass([
|
|
|
119
151
|
__decorateClass([
|
|
120
152
|
attr({ attribute: "slider-aria-label" })
|
|
121
153
|
], AudioPlayer.prototype, "sliderAriaLabel", 2);
|
|
154
|
+
__decorateClass([
|
|
155
|
+
attr({ attribute: "skip-forward-aria-label" })
|
|
156
|
+
], AudioPlayer.prototype, "skipForwardButtonAriaLabel", 2);
|
|
157
|
+
__decorateClass([
|
|
158
|
+
attr({ attribute: "skip-backward-aria-label" })
|
|
159
|
+
], AudioPlayer.prototype, "skipBackwardButtonAriaLabel", 2);
|
|
122
160
|
__decorateClass([
|
|
123
161
|
attr
|
|
124
162
|
], AudioPlayer.prototype, "connotation", 2);
|
|
@@ -131,6 +169,12 @@ __decorateClass([
|
|
|
131
169
|
__decorateClass([
|
|
132
170
|
attr({ mode: "boolean" })
|
|
133
171
|
], AudioPlayer.prototype, "notime", 2);
|
|
172
|
+
__decorateClass([
|
|
173
|
+
attr({
|
|
174
|
+
attribute: "skip-by",
|
|
175
|
+
converter: validSkipByConverter
|
|
176
|
+
})
|
|
177
|
+
], AudioPlayer.prototype, "skipBy", 2);
|
|
134
178
|
__decorateClass([
|
|
135
179
|
observable
|
|
136
180
|
], AudioPlayer.prototype, "paused", 2);
|
|
@@ -143,19 +187,43 @@ const getClasses = ({ disabled, duration }) => classNames(["disabled", Boolean(d
|
|
|
143
187
|
function renderButton(context) {
|
|
144
188
|
const buttonTag = context.tagFor(Button);
|
|
145
189
|
return html`<${buttonTag} class="pause" @click="${(x) => x._togglePlay()}"
|
|
146
|
-
icon="${(x) => x.paused ? "play-solid" : "pause-solid"}"
|
|
147
|
-
aria-label="${(x) => x.paused ? x.playButtonAriaLabel || x.locale.audioPlayer.playButtonLabel : x.pauseButtonAriaLabel || x.locale.audioPlayer.
|
|
148
|
-
size='condensed'
|
|
190
|
+
icon="${(x) => x.paused ? "play-solid" : "pause-solid"}"
|
|
191
|
+
aria-label="${(x) => x.paused ? x.playButtonAriaLabel || x.locale.audioPlayer.playButtonLabel : x.pauseButtonAriaLabel || x.locale.audioPlayer.pauseButtonLabel}"
|
|
192
|
+
size='condensed'
|
|
149
193
|
connotation="${(x) => x.connotation}"
|
|
150
|
-
?disabled="${(x) => x.disabled || !x.duration}"
|
|
194
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
151
195
|
></${buttonTag}>`;
|
|
152
196
|
}
|
|
197
|
+
function renderBackwardSkipButtons(context) {
|
|
198
|
+
const buttonTag = context.tagFor(Button);
|
|
199
|
+
return html`
|
|
200
|
+
<${buttonTag} class="skip backward" @click="${(x) => x._onSkipButtonClick(false)}"
|
|
201
|
+
icon="${(x) => x.skipBy == MediaSkipBy.Five ? "5-sec-backward-line" : x.skipBy == MediaSkipBy.Thirty ? "30-sec-backward-line" : "10-sec-backward-line"}"
|
|
202
|
+
size='condensed'
|
|
203
|
+
aria-label="${(x) => x.skipBackwardButtonAriaLabel || x.locale.audioPlayer.skipBackwardButton}"
|
|
204
|
+
connotation="${(x) => x.connotation}"
|
|
205
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
206
|
+
></${buttonTag}>
|
|
207
|
+
`;
|
|
208
|
+
}
|
|
209
|
+
function renderForwardSkipButtons(context) {
|
|
210
|
+
const buttonTag = context.tagFor(Button);
|
|
211
|
+
return html`
|
|
212
|
+
<${buttonTag} class="skip forward" @click="${(x) => x._onSkipButtonClick(true)}"
|
|
213
|
+
icon="${(x) => x.skipBy == MediaSkipBy.Five ? "5-sec-forward-line" : x.skipBy == MediaSkipBy.Thirty ? "30-sec-forward-line" : "10-sec-forward-line"}"
|
|
214
|
+
size='condensed'
|
|
215
|
+
aria-label="${(x) => x.skipForwardButtonAriaLabel || x.locale.audioPlayer.skipForwardButton}"
|
|
216
|
+
connotation="${(x) => x.connotation}"
|
|
217
|
+
?disabled="${(x) => x.disabled || !x.duration}"
|
|
218
|
+
></${buttonTag}>
|
|
219
|
+
`;
|
|
220
|
+
}
|
|
153
221
|
function renderSlider(context) {
|
|
154
222
|
const sliderTag = context.tagFor(Slider);
|
|
155
223
|
return html`<${sliderTag}
|
|
156
|
-
${ref("_sliderEl")} class="slider"
|
|
224
|
+
${ref("_sliderEl")} class="slider"
|
|
157
225
|
aria-label="${(x) => x.sliderAriaLabel || x.locale.audioPlayer.sliderLabel}"
|
|
158
|
-
value="0" max="100"
|
|
226
|
+
value="0" max="100"
|
|
159
227
|
connotation="${(x) => x.connotation}"
|
|
160
228
|
?disabled="${(x) => x.disabled || !x.duration}">
|
|
161
229
|
</${sliderTag}>`;
|
|
@@ -168,10 +236,23 @@ function renderTimestamp() {
|
|
|
168
236
|
</div>`;
|
|
169
237
|
}
|
|
170
238
|
const AudioPlayerTemplate = (context) => {
|
|
171
|
-
return html` <div
|
|
239
|
+
return html` <div
|
|
240
|
+
class="base ${getClasses}"
|
|
241
|
+
@keyup="${(x, c) => x._handleSliderEvent(c.event)}"
|
|
242
|
+
@keydown="${(x, c) => x._handleSliderEvent(c.event)}"
|
|
243
|
+
@mousedown="${(x, c) => x._handleSliderEvent(c.event)}"
|
|
244
|
+
>
|
|
172
245
|
<div class="controls">
|
|
173
|
-
${
|
|
174
|
-
|
|
246
|
+
${when(
|
|
247
|
+
(x) => x.skipBy && x.skipBy != MediaSkipBy.Zero,
|
|
248
|
+
renderBackwardSkipButtons(context)
|
|
249
|
+
)}
|
|
250
|
+
${renderButton(context)}
|
|
251
|
+
${when(
|
|
252
|
+
(x) => x.skipBy && x.skipBy != MediaSkipBy.Zero,
|
|
253
|
+
renderForwardSkipButtons(context)
|
|
254
|
+
)}
|
|
255
|
+
${when((x) => !x.notime, renderTimestamp())} ${renderSlider(context)}
|
|
175
256
|
</div>
|
|
176
257
|
<audio
|
|
177
258
|
${ref("_playerEl")}
|