bitmovin-player-ui
Advanced tools
Comparing version 3.29.0 to 3.30.0
@@ -7,2 +7,7 @@ # Change Log | ||
## [3.30.0] | ||
### Added | ||
- Sort `AudioTracks` inside the `AudioTrackSelectBox` and the `AudioTrackListBox` by their identifier. | ||
## [3.29.0] | ||
@@ -748,2 +753,3 @@ | ||
[3.30.0]: https://github.com/bitmovin/bitmovin-player-ui/compare/v3.29.0...v3.30.0 | ||
[3.29.0]: https://github.com/bitmovin/bitmovin-player-ui/compare/v3.28.1...v3.29.0 | ||
@@ -750,0 +756,0 @@ [3.28.1]: https://github.com/bitmovin/bitmovin-player-ui/compare/v3.28.0...v3.28.1 |
@@ -16,3 +16,3 @@ "use strict"; | ||
if (!_this.listElement.hasItem(audioTrack.id)) { | ||
_this.listElement.addItem(audioTrack.id, i18n_1.i18n.getLocalizer(audioTrack.label)); | ||
_this.listElement.addItem(audioTrack.id, i18n_1.i18n.getLocalizer(audioTrack.label), true); | ||
} | ||
@@ -19,0 +19,0 @@ }; |
@@ -65,8 +65,9 @@ import { Component, ComponentConfig } from './component'; | ||
/** | ||
* Adds an item to this selector by appending it to the end of the list of items. If an item with the specified | ||
* key already exists, it is replaced. | ||
* Adds an item to this selector by doing a sorted insert or by appending the element to the end of the list of items. | ||
* If an item with the specified key already exists, it is replaced. | ||
* @param key the key of the item to add | ||
* @param label the (human-readable) label of the item to add | ||
* @param sortedInsert whether the item should be added respecting the order of keys | ||
*/ | ||
addItem(key: string, label: LocalizableText): void; | ||
addItem(key: string, label: LocalizableText, sortedInsert?: boolean): void; | ||
/** | ||
@@ -73,0 +74,0 @@ * Removes an item from this selector. |
@@ -62,8 +62,10 @@ "use strict"; | ||
/** | ||
* Adds an item to this selector by appending it to the end of the list of items. If an item with the specified | ||
* key already exists, it is replaced. | ||
* Adds an item to this selector by doing a sorted insert or by appending the element to the end of the list of items. | ||
* If an item with the specified key already exists, it is replaced. | ||
* @param key the key of the item to add | ||
* @param label the (human-readable) label of the item to add | ||
* @param sortedInsert whether the item should be added respecting the order of keys | ||
*/ | ||
ListSelector.prototype.addItem = function (key, label) { | ||
ListSelector.prototype.addItem = function (key, label, sortedInsert) { | ||
if (sortedInsert === void 0) { sortedInsert = false; } | ||
var listItem = { key: key, label: i18n_1.i18n.performLocalization(label) }; | ||
@@ -80,3 +82,15 @@ // Apply filter function | ||
this.removeItem(key); // This will trigger an ItemRemoved and an ItemAdded event | ||
this.items.push(listItem); | ||
// Add the item to the list | ||
if (sortedInsert) { | ||
var index = this.items.findIndex(function (entry) { return entry.key > key; }); | ||
if (index < 0) { | ||
this.items.push(listItem); | ||
} | ||
else { | ||
this.items.splice(index, 0, listItem); | ||
} | ||
} | ||
else { | ||
this.items.push(listItem); | ||
} | ||
this.onItemAddedEvent(key); | ||
@@ -83,0 +97,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = '3.29.0'; | ||
exports.version = '3.30.0'; | ||
// Management | ||
@@ -6,0 +6,0 @@ var uimanager_1 = require("./uimanager"); |
{ | ||
"name": "bitmovin-player-ui", | ||
"version": "3.29.0", | ||
"version": "3.30.0", | ||
"description": "Bitmovin Player UI Framework", | ||
@@ -5,0 +5,0 @@ "main": "./dist/js/framework/main.js", |
@@ -55,3 +55,3 @@ import { MockHelper } from './helper/MockHelper'; | ||
playerMock.eventEmitter.fireAudioAddedEvent('a-3', 'A3'); | ||
expect(listSelectorMock.addItem).toHaveBeenCalledWith('a-3', expect.any(Function)); // i18n.t in our case | ||
expect(listSelectorMock.addItem).toHaveBeenCalledWith('a-3', expect.any(Function), true); | ||
}); | ||
@@ -58,0 +58,0 @@ }); |
@@ -23,2 +23,27 @@ import { ListItem, ListSelector, ListSelectorConfig } from '../../src/ts/components/listselector'; | ||
it('adds new items to the end of the list', () => { | ||
listSelector.addItem('A', 'itemA'); | ||
listSelector.addItem('C', 'itemC'); | ||
listSelector.addItem('B', 'itemB'); | ||
expect(listSelector.getItems()).toEqual([ | ||
{ key: 'A', label: 'itemA' }, | ||
{ key: 'C', label: 'itemC' }, | ||
{ key: 'B', label: 'itemB' }, | ||
]); | ||
}); | ||
it('adds items respecting the key order if sortedInsert is true', () => { | ||
const sortedInsert = true; | ||
listSelector.addItem('A', 'itemA', sortedInsert); | ||
listSelector.addItem('C', 'itemC', sortedInsert); | ||
listSelector.addItem('B', 'itemB', sortedInsert); | ||
expect(listSelector.getItems()).toEqual([ | ||
{ key: 'A', label: 'itemA' }, | ||
{ key: 'B', label: 'itemB' }, | ||
{ key: 'C', label: 'itemC' }, | ||
]); | ||
}); | ||
it('overrides existing value', () => { | ||
@@ -25,0 +50,0 @@ listSelector.addItem('itemKey', 'itemLabelOld'); |
@@ -49,3 +49,3 @@ import { ListItem, ListSelector, ListSelectorConfig } from './components/listselector'; | ||
if (!this.listElement.hasItem(audioTrack.id)) { | ||
this.listElement.addItem(audioTrack.id, i18n.getLocalizer(audioTrack.label)); | ||
this.listElement.addItem(audioTrack.id, i18n.getLocalizer(audioTrack.label), true); | ||
} | ||
@@ -52,0 +52,0 @@ }; |
@@ -102,8 +102,9 @@ import {Component, ComponentConfig} from './component'; | ||
/** | ||
* Adds an item to this selector by appending it to the end of the list of items. If an item with the specified | ||
* key already exists, it is replaced. | ||
* Adds an item to this selector by doing a sorted insert or by appending the element to the end of the list of items. | ||
* If an item with the specified key already exists, it is replaced. | ||
* @param key the key of the item to add | ||
* @param label the (human-readable) label of the item to add | ||
* @param sortedInsert whether the item should be added respecting the order of keys | ||
*/ | ||
addItem(key: string, label: LocalizableText) { | ||
addItem(key: string, label: LocalizableText, sortedInsert = false) { | ||
const listItem = { key: key, label: i18n.performLocalization(label) }; | ||
@@ -124,3 +125,13 @@ | ||
this.items.push(listItem); | ||
// Add the item to the list | ||
if (sortedInsert) { | ||
const index = this.items.findIndex(entry => entry.key > key); | ||
if (index < 0) { | ||
this.items.push(listItem); | ||
} else { | ||
this.items.splice(index, 0, listItem); | ||
} | ||
} else { | ||
this.items.push(listItem); | ||
} | ||
this.onItemAddedEvent(key); | ||
@@ -127,0 +138,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4409298
49268