Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* State definition.
* @type {!Object}
* @static
*/
Autocomplete.STATE = {
/**
* Activate or Deactivate the suggestion of the best align region. If true,
* the component will try to find a better region to align, otherwise,
* it will keep the position at the bottom.
* @type {boolean}
* @default true.
*/
autoBestAlign: {
value: true,
validator: core.isBoolean,
},
/**
* Function that converts a given item to the format that should be used by
* the autocomplete.
* @type {!function()}
*/
format: {
value: function(item) {
if (core.isString(item)) {
item = {
textPrimary: item,
};
}
if (core.isObject(item) && !item.text) {
item.text = item.textPrimary;
* }
*/
select: {
value: function(selectedValue) {
this.inputElement.value = selectedValue.text;
this.inputElement.focus();
},
validator: core.isFunction,
},
/**
* Indicates if the component is visible or not.
* @type {boolean}
*/
visible: {
validator: core.isBoolean,
value: false,
},
};
export {AutocompleteBase};
export default AutocompleteBase;
* Defines the internal value that controls the related field logic visibility
* @type {boolean}
* @default false
*/
isShowing_: {
validator: core.isBoolean,
value: false,
internal: true,
},
/**
* Defines if this field has a behavior to hide and show the value
* @type {boolean}
* @default false
*/
isTogglePassword: {
validator: core.isBoolean,
value: false,
},
/**
* Defines the maximum length for this field.
* @type {number}
*/
maxLength: {
validator: core.isNumber,
},
/**
* Defines the function name to 'oninput' event
* @type {function}
*/
onInput: {
validator: core.isFunction,
},
setUpPortal_(portalElement) {
if (
!portalElement ||
(!isElement(portalElement) &&
!isString(portalElement) &&
!isBoolean(portalElement))
) {
return;
} else if (isBoolean(portalElement) && portalElement) {
portalElement = 'body';
}
if (isServerSide()) {
this.portalElement = true;
return;
}
portalElement = this.getPortalElement_(portalElement);
if (portalElement) {
const placeholder = document.createElement('div');
portalElement.appendChild(placeholder);
this.element = placeholder;
setUpPortal_(portalElement) {
if (
!portalElement ||
(!isElement(portalElement) &&
!isString(portalElement) &&
!isBoolean(portalElement))
) {
return;
} else if (isBoolean(portalElement) && portalElement) {
portalElement = 'body';
}
if (isServerSide()) {
this.portalElement = true;
return;
}
portalElement = this.getPortalElement_(portalElement);
if (portalElement) {
const placeholder = document.createElement('div');
validator: core.isString,
value: 'on',
},
/**
* Defines which classes this input field should have
* @type {string}
*/
classes: {
validator: core.isString,
},
/**
* Defines "disabled" html attribute
* @type {boolean}
*/
disabled: {
validator: core.isBoolean,
},
/**
* Defines if while exposed state, the related field shall be editable
* It only works combined with isTogglePassword
* @type {boolean}
*/
editableWhileVisible: {
validator: core.isBoolean,
value: false,
},
/**
* Defines the index of the field
* @type {number}
*/
fieldIndex: {
validator: core.isNumber,
export function applyAttribute(component, element, name, value) {
const eventName = getEventFromListenerAttr_(name);
if (eventName) {
attachEvent_(component, element, name, eventName, value);
return;
}
value = fixCheckedAttr_(name, value);
setValueAttrAsProperty_(element, name, value);
if (isBoolean(value)) {
setBooleanAttr_(element, name, value);
} else {
getOriginalFn('attributes')(element, name, value);
}
}