"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MultiSelectField = exports.MultiSelectLayoutStyle = void 0;
const internal_1 = require("../internal");
/**
* Represents the layout style of a multi-select field.
*/
var MultiSelectLayoutStyle;
(function (MultiSelectLayoutStyle) {
MultiSelectLayoutStyle["list"] = "list";
MultiSelectLayoutStyle["checkboxes"] = "checkboxes";
})(MultiSelectLayoutStyle = exports.MultiSelectLayoutStyle || (exports.MultiSelectLayoutStyle = {}));
/**
* Represents a multi-select field.
* @extends EditableField
*/
class MultiSelectField extends internal_1.EditableField {
/**
* Creates an instance of the MultiSelectField class.
* @param {string} id The unique identifier of the field.
* @param {string} label The label of the field.
* @param {SelectFieldOption[]} options The options to of the field.
*/
constructor(id, label, options) {
super(id);
this.displayType = 'multiSelect';
this.options = [];
this.layoutStyle = MultiSelectLayoutStyle.list;
this.setLabel(label);
if (options) {
this.setOptions(options);
}
}
/**
* Deserialize nested object properties into corresponding class instances
*/
deserializeNestedProperties() {
super.deserializeNestedProperties();
if (this.options) {
this.options = internal_1.MessageUtil.deserializeSelectFieldOptions(this.options);
}
}
/**
* Gets the default value.
* @returns {object[]} The default value.
*/
getDefaultValue() {
return this.defaultValue;
}
/**
* Sets the default value.
* @param {object[]} defaultValue The default value to set.
* @returns The updated instance of the MultiSelectField.
*/
setDefaultValue(defaultValue) {
this.defaultValue = defaultValue;
return this;
}
/**
* Gets the options.
* @returns {SelectFieldOption[]} The options.
*/
getOptions() {
return this.options;
}
/**
* Sets the options.
* @param {SelectFieldOption[]} options The options to set.
* @returns The updated instance of the MultiSelectField.
*/
setOptions(options) {
this.options = options;
return this;
}
/**
* Add an option.
* @param {SelectFieldOption} option The option to add.
* @returns The updated instance of the MultiSelectField.
*/
addOption(option) {
this.options.push(option);
return this;
}
/**
* Gets the layout style.
* @returns {MultiSelectLayoutStyle} The layout style.
*/
getLayoutStyle() {
return this.layoutStyle;
}
/**
* Sets the layout style.
* @param {MultiSelectLayoutStyle} layoutStyle The layout style to set.
* @returns The updated instance of the MultiSelectField.
*/
setLayoutStyle(layoutStyle) {
this.layoutStyle = layoutStyle;
return this;
}
}
exports.MultiSelectField = MultiSelectField;