/* eslint-disable @typescript-eslint/no-unused-vars */ namespace Providers.OSUI.Dropdown.VirtualSelect.Search { /** * Class that represents the custom configurations received by the Dropdown Search mode. */ export class VirtualSelectSearchConfig extends AbstractVirtualSelectConfig { /** Lets the user select more than one option. */ public AllowMultipleSelection: boolean; /** * Method used to get the key values of the given selected values * * @protected */ protected getSelectedValues(): string[] { const selectedKeyvalues = []; // Has selected values? if (this.StartingSelection?.length > 0) { // Check if it's multiple options if (this.AllowMultipleSelection) { // Get the selected key value for (const option of this.StartingSelection) { if (option.value !== OSFramework.OSUI.Constants.EmptyString) { selectedKeyvalues.push(option.value); } } } else { // It's Single option, set only the first given value if (this.StartingSelection[0].value !== OSFramework.OSUI.Constants.EmptyString) { selectedKeyvalues.push(this.StartingSelection[0].value); } } } return selectedKeyvalues; } /** * Set the configs for the Dropdown Search mode */ public getProviderConfig(): VirtualSelectOpts { const virtualSelectSearchOpts = { multiple: this.AllowMultipleSelection, ariaLabelText: this.AllowMultipleSelection ? VirtualSelect.Enum.PropertiesValues.AriaLabelMultipleValue : VirtualSelect.Enum.PropertiesValues.AriaLabelSingleValue, }; return this.mergeConfigs(super.getProviderConfig(), virtualSelectSearchOpts, this.providerExtendedOptions); } /** * Override, validate configs key values * * @param key Name of the configuration property being validated * @param value Value to validate */ public validateDefault(key: string, value: unknown): unknown { let validatedValue = undefined; switch (key) { case Enum.Properties.AllowMultipleSelection: validatedValue = this.validateBoolean(value as boolean, false); break; default: validatedValue = super.validateDefault(key, value); break; } return validatedValue; } } }