import { ToggleButton, ToggleButtonConfig } from '../buttons/ToggleButton'; import { SettingsPanel, SettingsPanelConfig } from './SettingsPanel'; import { UIInstanceManager } from '../../UIManager'; import { Component, ComponentConfig } from '../Component'; import { ArrayUtils } from '../../utils/ArrayUtils'; import { PlayerAPI } from 'bitmovin-player'; import { i18n } from '../../localization/i18n'; /** * Configuration interface for the {@link SettingsToggleButton}. * * @category Configs */ export interface SettingsToggleButtonConfig extends ToggleButtonConfig { /** * The settings panel whose visibility the button should toggle. */ settingsPanel: SettingsPanel; /** * Decides if the button should be automatically hidden when the settings panel does not contain any active settings. * Default: true */ autoHideWhenNoActiveSettings?: boolean; } /** * A button that toggles visibility of a settings panel. * * @category Buttons */ export class SettingsToggleButton extends ToggleButton { private visibleSettingsPanels: SettingsPanel[] = []; constructor(config: SettingsToggleButtonConfig) { super(config); if (!config.settingsPanel) { throw new Error('Required SettingsPanel is missing'); } // Setting both ariaLabels on the parent ToggleButton suppresses its default // `aria-pressed` attribute (see the ToggleButtonConfig.ariaLabel doc) so we don't end // up announcing both pressed/unpressed *and* expanded/collapsed for the same widget. // Using the same localizer for both states keeps the announced name stable. const settingsLabel = i18n.getLocalizer('settings'); this.config = this.mergeConfig( config, { cssClass: 'ui-settingstogglebutton', text: settingsLabel, onAriaLabel: settingsLabel, offAriaLabel: settingsLabel, settingsPanel: null, autoHideWhenNoActiveSettings: true, }, this.config, ); // The element renders as a native `