clay-autocomplete
Advanced tools
Comparing version 2.7.0 to 2.8.0
@@ -14,2 +14,4 @@ 'use strict'; | ||
var _metal = require('metal'); | ||
var _clayComponent = require('clay-component'); | ||
@@ -53,5 +55,72 @@ | ||
_createClass(ClayAutocomplete, [{ | ||
key: '_handleDataChange', | ||
key: 'attached', | ||
/** | ||
* @inheritDoc | ||
*/ | ||
value: function attached() { | ||
this._dropdownItemFocused = null; | ||
this.addListener('dataChange', this._defaultDataChange, true); | ||
this.addListener('inputChange', this._defaultInputChange, true); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
}, { | ||
key: 'disposed', | ||
value: function disposed() { | ||
this._dropdownItemFocused = null; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
}, { | ||
key: 'syncFilteredItems', | ||
value: function syncFilteredItems() { | ||
this._dropdownItemFocused = null; | ||
} | ||
/** | ||
* Sets filtered items with received data | ||
* @private | ||
*/ | ||
}, { | ||
key: '_defaultDataChange', | ||
value: function _defaultDataChange() { | ||
if (this._query) { | ||
this.filteredItems = this.refs.dataProvider.filter(this._query, this.extractData); | ||
} else { | ||
this.filteredItems = []; | ||
} | ||
} | ||
/** | ||
* Filters the items according to received input | ||
* @param {!Event} event | ||
* @private | ||
*/ | ||
}, { | ||
key: '_defaultInputChange', | ||
value: function _defaultInputChange(event) { | ||
this._query = event.data.value; | ||
if (this._query) { | ||
if ((0, _metal.isFunction)(this.dataSource)) { | ||
this.refs.dataProvider.updateData(this._query); | ||
} else { | ||
this.filteredItems = this.refs.dataProvider.filter(this._query, this.extractData); | ||
} | ||
} else { | ||
this.filteredItems = []; | ||
} | ||
} | ||
/** | ||
* Continues the propagation of the data change event | ||
@@ -62,2 +131,5 @@ * @param {!Event} event | ||
*/ | ||
}, { | ||
key: '_handleDataChange', | ||
value: function _handleDataChange(event) { | ||
@@ -85,26 +157,2 @@ return !this.emit({ | ||
/** | ||
* Handles the filtered items event and continues to propagate. | ||
* @param {!Event} event | ||
* @param {!string} query | ||
* @protected | ||
* @return {Boolean} If the event has been prevented or not. | ||
*/ | ||
}, { | ||
key: '_handleFilteredItems', | ||
value: function _handleFilteredItems(event, query) { | ||
if (query) { | ||
this.filteredItems = this.refs.dataProvider.filter(query, this.extractData); | ||
} else { | ||
this.filteredItems = []; | ||
} | ||
return !this.emit({ | ||
data: this.filteredItems, | ||
name: 'filteredItems', | ||
originalEvent: event | ||
}); | ||
} | ||
/** | ||
* Handle the selected item in the dropdown and trigger the itemSelected event. | ||
@@ -171,14 +219,12 @@ * @param {!Event} event | ||
value: function _handleOnInput(event) { | ||
var query = event.target.value; | ||
var value = event.target.value; | ||
if (this.enableAutocomplete) { | ||
this._handleFilteredItems(event, query); | ||
} | ||
var char = event.data || value.substr(-1); | ||
return !this.emit({ | ||
data: { | ||
value: event.target.value, | ||
char: event.data | ||
value: value, | ||
char: char | ||
}, | ||
name: 'queryChange', | ||
name: 'inputChange', | ||
originalEvent: event | ||
@@ -249,32 +295,2 @@ }); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
}, { | ||
key: 'attached', | ||
value: function attached() { | ||
this._dropdownItemFocused = null; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
}, { | ||
key: 'disposed', | ||
value: function disposed() { | ||
this._dropdownItemFocused = null; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
}, { | ||
key: 'syncFilteredItems', | ||
value: function syncFilteredItems() { | ||
this._dropdownItemFocused = null; | ||
} | ||
}]); | ||
@@ -312,10 +328,22 @@ | ||
/** | ||
* The array of data items that the data source contains or | ||
* the URL for the data provider to request. | ||
* The array of data items that the data source contains, | ||
* the URL for the data provider to request, or a function | ||
* that receives the query and returns a promise with the | ||
* elements. | ||
* | ||
* @instance | ||
* @default undefined | ||
* @memberof ClayAutocomplete | ||
* @type {!(string|object|array|function)} | ||
*/ | ||
dataSource: _metalState.Config.oneOfType([_metalState.Config.array(), _metalState.Config.func(), _metalState.Config.object(), _metalState.Config.string()]).required(), | ||
/** | ||
* Set the request debounce time | ||
* @instance | ||
* @default 200 | ||
* @memberof ClayAutocomplete | ||
* @type {!(string|object|array)} | ||
* @type {?(number)} | ||
*/ | ||
dataSource: _metalState.Config.oneOfType([_metalState.Config.string(), _metalState.Config.object(), _metalState.Config.array()]).required(), | ||
debounceTime: _metalState.Config.number().value(200), | ||
@@ -348,3 +376,7 @@ /** | ||
*/ | ||
enableAutocomplete: _metalState.Config.bool().value(true), | ||
enableAutocomplete: _metalState.Config.validator(function (value) { | ||
if (value) { | ||
console.warn('🚨 `enableAutocomplete` has been deprecated and will be removed in the next major version.'); | ||
} | ||
}), | ||
@@ -417,2 +449,21 @@ /** | ||
/** | ||
* Flag to define how often to refetch data (ms) | ||
* @instance | ||
* @default 0 | ||
* @memberof ClayAutocomplete | ||
* @type {?(number|undefined)} | ||
*/ | ||
pollingInterval: _metalState.Config.number().value(0), | ||
/** | ||
* Specifies explicitly if request needs to be made with debounce | ||
* (userInput) or with polling (polling) | ||
* @instance | ||
* @default undefined | ||
* @memberof ClayAutocomplete | ||
* @type {?(object|array)} | ||
*/ | ||
requestInputMode: _metalState.Config.oneOf(['polling', 'userInput']).value('userInput'), | ||
/** | ||
* Set ups the request options | ||
@@ -437,8 +488,12 @@ * @default undefined | ||
* Flag to define how often to refetch data (ms) | ||
* @instance | ||
* @default 0 | ||
* @instance | ||
* @memberof ClayAutocomplete | ||
* @type {?(number|undefined)} | ||
*/ | ||
requestPolling: _metalState.Config.number().value(0), | ||
requestPolling: _metalState.Config.validator(function (value) { | ||
if (value) { | ||
console.warn('🚨 `requestPolling` has been renamed to `pollingInterval` and will be deprecated and removed in the next release.'); | ||
} | ||
}), | ||
@@ -445,0 +500,0 @@ /** |
@@ -58,4 +58,4 @@ 'use strict'; | ||
opt_ijData = opt_ijData_deprecated || opt_ijData; | ||
/** @type {!Array<?>|!Object|!goog.soy.data.SanitizedContent|string} */ | ||
var dataSource = soy.asserts.assertType(goog.isObject(opt_data.dataSource) || goog.isArray(opt_data.dataSource) || goog.isString(opt_data.dataSource) || opt_data.dataSource instanceof goog.soy.data.SanitizedContent, 'dataSource', opt_data.dataSource, '!Array<?>|!Object|!goog.soy.data.SanitizedContent|string'); | ||
/** @type {!Array<?>|!Object|!goog.soy.data.SanitizedContent|*|string} */ | ||
var dataSource = opt_data.dataSource; | ||
/** @type {*|null|undefined} */ | ||
@@ -89,7 +89,9 @@ var _handleDataChange = opt_data._handleDataChange; | ||
var inputValue = soy.asserts.assertType(opt_data.inputValue == null || goog.isString(opt_data.inputValue) || opt_data.inputValue instanceof goog.soy.data.SanitizedContent, 'inputValue', opt_data.inputValue, '!goog.soy.data.SanitizedContent|null|string|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var pollingInterval = soy.asserts.assertType(opt_data.pollingInterval == null || goog.isNumber(opt_data.pollingInterval), 'pollingInterval', opt_data.pollingInterval, 'null|number|undefined'); | ||
/** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */ | ||
var requestInputMode = soy.asserts.assertType(opt_data.requestInputMode == null || goog.isString(opt_data.requestInputMode) || opt_data.requestInputMode instanceof goog.soy.data.SanitizedContent, 'requestInputMode', opt_data.requestInputMode, '!goog.soy.data.SanitizedContent|null|string|undefined'); | ||
/** @type {null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}} */ | ||
var requestOptions = soy.asserts.assertType(opt_data.requestOptions == null || goog.isObject(opt_data.requestOptions), 'requestOptions', opt_data.requestOptions, 'null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}'); | ||
/** @type {null|number|undefined} */ | ||
var requestPolling = soy.asserts.assertType(opt_data.requestPolling == null || goog.isNumber(opt_data.requestPolling), 'requestPolling', opt_data.requestPolling, 'null|number|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var requestRetries = soy.asserts.assertType(opt_data.requestRetries == null || goog.isNumber(opt_data.requestRetries), 'requestRetries', opt_data.requestRetries, 'null|number|undefined'); | ||
@@ -100,3 +102,3 @@ /** @type {null|number|undefined} */ | ||
var unstable_content = soy.asserts.assertType(opt_data.unstable_content == null || goog.isFunction(opt_data.unstable_content), 'unstable_content', opt_data.unstable_content, 'function()|null|undefined'); | ||
var attributes__soy41 = function attributes__soy41() { | ||
var attributes__soy42 = function attributes__soy42() { | ||
incrementalDom.attr('class', 'dropdown-full' + (elementClasses ? ' ' + elementClasses : ' form-group')); | ||
@@ -109,7 +111,7 @@ incrementalDom.attr('data-onkeydown', _handleOnKeydown); | ||
incrementalDom.elementOpenStart('div'); | ||
attributes__soy41(); | ||
attributes__soy42(); | ||
incrementalDom.elementOpenEnd(); | ||
soyIdom.print(unstable_content); | ||
$input({ _handleOnBlur: _handleOnBlur, _handleOnFocus: _handleOnFocus, _handleOnInput: _handleOnInput, _handleOnKeydown: _handleOnKeydown, inputElementClasses: inputElementClasses, inputName: inputName, inputValue: inputValue }, opt_ijData); | ||
$dropdown({ _handleDataChange: _handleDataChange, _handleDropdownItemClick: _handleDropdownItemClick, contentRenderer: contentRenderer, dataSource: dataSource, filteredItems: filteredItems, initialData: initialData, requestOptions: requestOptions, requestPolling: requestPolling, requestRetries: requestRetries, requestTimeout: requestTimeout }, opt_ijData); | ||
$dropdown({ _handleDataChange: _handleDataChange, _handleDropdownItemClick: _handleDropdownItemClick, contentRenderer: contentRenderer, dataSource: dataSource, filteredItems: filteredItems, initialData: initialData, pollingInterval: pollingInterval, requestInputMode: requestInputMode, requestOptions: requestOptions, requestRetries: requestRetries, requestTimeout: requestTimeout }, opt_ijData); | ||
incrementalDom.elementClose('div'); | ||
@@ -120,3 +122,3 @@ }; | ||
* @typedef {{ | ||
* dataSource: (!Array<?>|!Object|!goog.soy.data.SanitizedContent|string), | ||
* dataSource: (!Array<?>|!Object|!goog.soy.data.SanitizedContent|*|string), | ||
* _handleDataChange: (*|null|undefined), | ||
@@ -136,4 +138,5 @@ * _handleDropdownItemClick: (*|null|undefined), | ||
* inputValue: (!goog.soy.data.SanitizedContent|null|string|undefined), | ||
* pollingInterval: (null|number|undefined), | ||
* requestInputMode: (!goog.soy.data.SanitizedContent|null|string|undefined), | ||
* requestOptions: (null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}), | ||
* requestPolling: (null|number|undefined), | ||
* requestRetries: (null|number|undefined), | ||
@@ -173,3 +176,3 @@ * requestTimeout: (null|number|undefined), | ||
var inputValue = soy.asserts.assertType(opt_data.inputValue == null || goog.isString(opt_data.inputValue) || opt_data.inputValue instanceof goog.soy.data.SanitizedContent, 'inputValue', opt_data.inputValue, '!goog.soy.data.SanitizedContent|null|string|undefined'); | ||
var attributes__soy110 = function attributes__soy110() { | ||
var attributes__soy112 = function attributes__soy112() { | ||
incrementalDom.attr('class', inputElementClasses ? inputElementClasses : 'form-control'); | ||
@@ -193,3 +196,3 @@ if (inputName) { | ||
incrementalDom.elementOpenStart('input'); | ||
attributes__soy110(); | ||
attributes__soy112(); | ||
incrementalDom.elementOpenEnd(); | ||
@@ -224,4 +227,4 @@ incrementalDom.elementClose('input'); | ||
opt_ijData = opt_ijData_deprecated || opt_ijData; | ||
/** @type {!Array<?>|!Object|!goog.soy.data.SanitizedContent|string} */ | ||
var dataSource = soy.asserts.assertType(goog.isObject(opt_data.dataSource) || goog.isArray(opt_data.dataSource) || goog.isString(opt_data.dataSource) || opt_data.dataSource instanceof goog.soy.data.SanitizedContent, 'dataSource', opt_data.dataSource, '!Array<?>|!Object|!goog.soy.data.SanitizedContent|string'); | ||
/** @type {!Array<?>|!Object|!goog.soy.data.SanitizedContent|*|string} */ | ||
var dataSource = opt_data.dataSource; | ||
/** @type {*|null|undefined} */ | ||
@@ -237,25 +240,27 @@ var _handleDataChange = opt_data._handleDataChange; | ||
var initialData = soy.asserts.assertType(opt_data.initialData == null || goog.isObject(opt_data.initialData) || goog.isArray(opt_data.initialData), 'initialData', opt_data.initialData, '!Array<?>|!Object|null|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var pollingInterval = soy.asserts.assertType(opt_data.pollingInterval == null || goog.isNumber(opt_data.pollingInterval), 'pollingInterval', opt_data.pollingInterval, 'null|number|undefined'); | ||
/** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */ | ||
var requestInputMode = soy.asserts.assertType(opt_data.requestInputMode == null || goog.isString(opt_data.requestInputMode) || opt_data.requestInputMode instanceof goog.soy.data.SanitizedContent, 'requestInputMode', opt_data.requestInputMode, '!goog.soy.data.SanitizedContent|null|string|undefined'); | ||
/** @type {null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}} */ | ||
var requestOptions = soy.asserts.assertType(opt_data.requestOptions == null || goog.isObject(opt_data.requestOptions), 'requestOptions', opt_data.requestOptions, 'null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}'); | ||
/** @type {null|number|undefined} */ | ||
var requestPolling = soy.asserts.assertType(opt_data.requestPolling == null || goog.isNumber(opt_data.requestPolling), 'requestPolling', opt_data.requestPolling, 'null|number|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var requestRetries = soy.asserts.assertType(opt_data.requestRetries == null || goog.isNumber(opt_data.requestRetries), 'requestRetries', opt_data.requestRetries, 'null|number|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var requestTimeout = soy.asserts.assertType(opt_data.requestTimeout == null || goog.isNumber(opt_data.requestTimeout), 'requestTimeout', opt_data.requestTimeout, 'null|number|undefined'); | ||
var isVisible__soy126 = filteredItems && filteredItems.length > 0 ? true : false; | ||
var classes__soy133 = ''; | ||
classes__soy133 += 'dropdown-menu'; | ||
classes__soy133 += isVisible__soy126 ? ' show' : ''; | ||
var param151 = function param151() { | ||
var isVisible__soy129 = filteredItems && filteredItems.length > 0 ? true : false; | ||
var classes__soy136 = ''; | ||
classes__soy136 += 'dropdown-menu'; | ||
classes__soy136 += isVisible__soy129 ? ' show' : ''; | ||
var param154 = function param154() { | ||
incrementalDom.elementOpenStart('ul'); | ||
incrementalDom.attr('class', classes__soy133); | ||
incrementalDom.attr('class', classes__soy136); | ||
incrementalDom.attr('ref', 'dropdown'); | ||
incrementalDom.elementOpenEnd(); | ||
if (filteredItems) { | ||
var item141List = filteredItems; | ||
var item141ListLen = item141List.length; | ||
for (var item141Index = 0; item141Index < item141ListLen; item141Index++) { | ||
var item141Data = item141List[item141Index]; | ||
soy.$$getDelegateFn(soy.$$getDelTemplateId('ClayAutocomplete.Item.idom'), contentRenderer, true)({ _handleDropdownItemClick: _handleDropdownItemClick, data: item141Data, index: item141Index }, opt_ijData); | ||
var item144List = filteredItems; | ||
var item144ListLen = item144List.length; | ||
for (var item144Index = 0; item144Index < item144ListLen; item144Index++) { | ||
var item144Data = item144List[item144Index]; | ||
soy.$$getDelegateFn(soy.$$getDelTemplateId('ClayAutocomplete.Item.idom'), contentRenderer, true)({ _handleDropdownItemClick: _handleDropdownItemClick, data: item144Data, index: item144Index }, opt_ijData); | ||
} | ||
@@ -265,3 +270,3 @@ } | ||
}; | ||
$templateAlias1({ content: param151, dataSource: dataSource, events: { dataChange: _handleDataChange }, initialData: initialData, ref: 'dataProvider', requestOptions: requestOptions, requestPolling: requestPolling, requestRetries: requestRetries, requestTimeout: requestTimeout }, opt_ijData); | ||
$templateAlias1({ content: param154, dataSource: dataSource, events: { dataChange: _handleDataChange }, initialData: initialData, pollingInterval: pollingInterval, ref: 'dataProvider', requestInputMode: requestInputMode, requestOptions: requestOptions, requestRetries: requestRetries, requestTimeout: requestTimeout }, opt_ijData); | ||
}; | ||
@@ -271,3 +276,3 @@ exports.dropdown = $dropdown; | ||
* @typedef {{ | ||
* dataSource: (!Array<?>|!Object|!goog.soy.data.SanitizedContent|string), | ||
* dataSource: (!Array<?>|!Object|!goog.soy.data.SanitizedContent|*|string), | ||
* _handleDataChange: (*|null|undefined), | ||
@@ -278,4 +283,5 @@ * _handleDropdownItemClick: (*|null|undefined), | ||
* initialData: (!Array<?>|!Object|null|undefined), | ||
* pollingInterval: (null|number|undefined), | ||
* requestInputMode: (!goog.soy.data.SanitizedContent|null|string|undefined), | ||
* requestOptions: (null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}), | ||
* requestPolling: (null|number|undefined), | ||
* requestRetries: (null|number|undefined), | ||
@@ -314,12 +320,12 @@ * requestTimeout: (null|number|undefined), | ||
if (data.matches && data.matches.length > 0) { | ||
var char175List = data.matches; | ||
var char175ListLen = char175List.length; | ||
for (var char175Index = 0; char175Index < char175ListLen; char175Index++) { | ||
var char175Data = char175List[char175Index]; | ||
if (char175Data.match) { | ||
var char179List = data.matches; | ||
var char179ListLen = char179List.length; | ||
for (var char179Index = 0; char179Index < char179ListLen; char179Index++) { | ||
var char179Data = char179List[char179Index]; | ||
if (char179Data.match) { | ||
incrementalDom.elementOpen('strong'); | ||
soyIdom.print(char175Data.value); | ||
soyIdom.print(char179Data.value); | ||
incrementalDom.elementClose('strong'); | ||
} else { | ||
soyIdom.print(char175Data.value); | ||
soyIdom.print(char179Data.value); | ||
} | ||
@@ -345,8 +351,8 @@ } | ||
exports.render.params = ["dataSource", "_handleDataChange", "_handleDropdownItemClick", "_handleOnBlur", "_handleOnFocus", "_handleOnInput", "_handleOnKeydown", "contentRenderer", "elementClasses", "filteredItems", "id", "initialData", "inputElementClasses", "inputName", "inputValue", "requestOptions", "requestPolling", "requestRetries", "requestTimeout", "unstable_content"]; | ||
exports.render.types = { "dataSource": "string|[]|list<?>", "_handleDataChange": "any", "_handleDropdownItemClick": "any", "_handleOnBlur": "any", "_handleOnFocus": "any", "_handleOnInput": "any", "_handleOnKeydown": "any", "contentRenderer": "string", "elementClasses": "string", "filteredItems": "list<?>", "id": "string", "initialData": "[]|list<?>", "inputElementClasses": "string", "inputName": "string", "inputValue": "string", "requestOptions": "[\n\t\tmethod: string,\n\t\tmode: string,\n\t\tcache: string,\n\t\tcredentials: string,\n\t\theaders: [],\n\t\tredirect: string,\n\t\treferrer: string,\n\t\tbody: []\n\t]", "requestPolling": "number", "requestRetries": "number", "requestTimeout": "number", "unstable_content": "html" }; | ||
exports.render.params = ["dataSource", "_handleDataChange", "_handleDropdownItemClick", "_handleOnBlur", "_handleOnFocus", "_handleOnInput", "_handleOnKeydown", "contentRenderer", "elementClasses", "filteredItems", "id", "initialData", "inputElementClasses", "inputName", "inputValue", "pollingInterval", "requestInputMode", "requestOptions", "requestRetries", "requestTimeout", "unstable_content"]; | ||
exports.render.types = { "dataSource": "string|[]|list<?>|any", "_handleDataChange": "any", "_handleDropdownItemClick": "any", "_handleOnBlur": "any", "_handleOnFocus": "any", "_handleOnInput": "any", "_handleOnKeydown": "any", "contentRenderer": "string", "elementClasses": "string", "filteredItems": "list<?>", "id": "string", "initialData": "[]|list<?>", "inputElementClasses": "string", "inputName": "string", "inputValue": "string", "pollingInterval": "number", "requestInputMode": "string", "requestOptions": "[\n\t\tmethod: string,\n\t\tmode: string,\n\t\tcache: string,\n\t\tcredentials: string,\n\t\theaders: [],\n\t\tredirect: string,\n\t\treferrer: string,\n\t\tbody: []\n\t]", "requestRetries": "number", "requestTimeout": "number", "unstable_content": "html" }; | ||
exports.input.params = ["_handleOnBlur", "_handleOnFocus", "_handleOnInput", "_handleOnKeydown", "inputElementClasses", "inputName", "inputValue"]; | ||
exports.input.types = { "_handleOnBlur": "any", "_handleOnFocus": "any", "_handleOnInput": "any", "_handleOnKeydown": "any", "inputElementClasses": "string", "inputName": "string", "inputValue": "string" }; | ||
exports.dropdown.params = ["dataSource", "_handleDataChange", "_handleDropdownItemClick", "contentRenderer", "filteredItems", "initialData", "requestOptions", "requestPolling", "requestRetries", "requestTimeout"]; | ||
exports.dropdown.types = { "dataSource": "string|[]|list<?>", "_handleDataChange": "any", "_handleDropdownItemClick": "any", "contentRenderer": "string", "filteredItems": "list<?>", "initialData": "[]|list<?>", "requestOptions": "[\n\t\tmethod: string,\n\t\tmode: string,\n\t\tcache: string,\n\t\tcredentials: string,\n\t\theaders: [],\n\t\tredirect: string,\n\t\treferrer: string,\n\t\tbody: []\n\t]", "requestPolling": "number", "requestRetries": "number", "requestTimeout": "number" }; | ||
exports.dropdown.params = ["dataSource", "_handleDataChange", "_handleDropdownItemClick", "contentRenderer", "filteredItems", "initialData", "pollingInterval", "requestInputMode", "requestOptions", "requestRetries", "requestTimeout"]; | ||
exports.dropdown.types = { "dataSource": "string|[]|list<?>|any", "_handleDataChange": "any", "_handleDropdownItemClick": "any", "contentRenderer": "string", "filteredItems": "list<?>", "initialData": "[]|list<?>", "pollingInterval": "number", "requestInputMode": "string", "requestOptions": "[\n\t\tmethod: string,\n\t\tmode: string,\n\t\tcache: string,\n\t\tcredentials: string,\n\t\theaders: [],\n\t\tredirect: string,\n\t\treferrer: string,\n\t\tbody: []\n\t]", "requestRetries": "number", "requestTimeout": "number" }; | ||
exports.templates = templates = exports; | ||
@@ -353,0 +359,0 @@ return exports; |
{ | ||
"name": "clay-autocomplete", | ||
"version": "2.7.0", | ||
"version": "2.8.0", | ||
"description": "Metal ClayAutocomplete component", | ||
@@ -30,3 +30,3 @@ "license": "BSD-3-Clause", | ||
"dependencies": { | ||
"clay-data-provider": "^2.7.0", | ||
"clay-data-provider": "^2.8.0", | ||
"metal": "^2.16.0", | ||
@@ -44,8 +44,8 @@ "metal-component": "^2.16.0", | ||
"babel-preset-env": "^1.6.0", | ||
"browserslist-config-clay": "^2.7.0", | ||
"clay-css": "^2.7.0", | ||
"browserslist-config-clay": "^2.8.0", | ||
"clay-css": "^2.8.0", | ||
"metal-dom": "^2.13.2", | ||
"metal-tools-soy": "^6.0.0", | ||
"webpack": "^3.0.0", | ||
"webpack-config-clay": "^2.7.0" | ||
"webpack-config-clay": "^2.8.0" | ||
}, | ||
@@ -55,3 +55,3 @@ "browserslist": [ | ||
], | ||
"gitHead": "860f3be9e01cbab321bd7f2ff2abfdc931383b61" | ||
"gitHead": "96302c7d38bc968cb83651caaec70ddbcbe36b97" | ||
} |
@@ -182,3 +182,3 @@ import {triggerEvent} from 'metal-dom'; | ||
}, | ||
name: 'queryChange', | ||
name: 'inputChange', | ||
originalEvent: expect.any(Object), | ||
@@ -275,50 +275,2 @@ }) | ||
it('should render a ClayAutocomplete and emit an event on filtered items', () => { | ||
component = new ClayAutocomplete({ | ||
dataSource, | ||
}); | ||
const spy = jest.spyOn(component, 'emit'); | ||
const {input} = component.refs; | ||
input.value = 'br'; | ||
triggerEvent(input, 'input', {data: 'r'}); | ||
jest.runAllTimers(); | ||
expect(spy).toHaveBeenCalled(); | ||
expect(spy).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
data: expect.any(Object), | ||
name: 'filteredItems', | ||
originalEvent: expect.any(Object), | ||
}) | ||
); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
it('should render a ClayAutocomplete and not emit an event on filtered items when disabled autocomplete', () => { | ||
component = new ClayAutocomplete({ | ||
dataSource, | ||
enableAutocomplete: false, | ||
}); | ||
const spy = jest.spyOn(component, 'emit'); | ||
const {input} = component.refs; | ||
input.value = 'b'; | ||
triggerEvent(input, 'input', {data: 'b'}); | ||
jest.runAllTimers(); | ||
expect(spy).not.toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
data: expect.any(Object), | ||
name: 'filteredItems', | ||
originalEvent: expect.any(Object), | ||
}) | ||
); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
it('should render a ClayAutocomplete and filtered items with structured data', () => { | ||
@@ -337,3 +289,2 @@ component = new ClayAutocomplete({ | ||
const spy = jest.spyOn(component, 'emit'); | ||
const {input} = component.refs; | ||
@@ -346,10 +297,2 @@ | ||
expect(spy).toHaveBeenCalled(); | ||
expect(spy).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
data: expect.any(Object), | ||
name: 'filteredItems', | ||
originalEvent: expect.any(Object), | ||
}) | ||
); | ||
expect(component).toMatchSnapshot(); | ||
@@ -356,0 +299,0 @@ }); |
import 'clay-data-provider'; | ||
import {Config} from 'metal-state'; | ||
import {isFunction} from 'metal'; | ||
import ClayComponent from 'clay-component'; | ||
@@ -15,2 +16,63 @@ import defineWebComponent from 'metal-web-component'; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
attached() { | ||
this._dropdownItemFocused = null; | ||
this.addListener('dataChange', this._defaultDataChange, true); | ||
this.addListener('inputChange', this._defaultInputChange, true); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
disposed() { | ||
this._dropdownItemFocused = null; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
syncFilteredItems() { | ||
this._dropdownItemFocused = null; | ||
} | ||
/** | ||
* Sets filtered items with received data | ||
* @private | ||
*/ | ||
_defaultDataChange() { | ||
if (this._query) { | ||
this.filteredItems = this.refs.dataProvider.filter( | ||
this._query, | ||
this.extractData | ||
); | ||
} else { | ||
this.filteredItems = []; | ||
} | ||
} | ||
/** | ||
* Filters the items according to received input | ||
* @param {!Event} event | ||
* @private | ||
*/ | ||
_defaultInputChange(event) { | ||
this._query = event.data.value; | ||
if (this._query) { | ||
if (isFunction(this.dataSource)) { | ||
this.refs.dataProvider.updateData(this._query); | ||
} else { | ||
this.filteredItems = this.refs.dataProvider.filter( | ||
this._query, | ||
this.extractData | ||
); | ||
} | ||
} else { | ||
this.filteredItems = []; | ||
} | ||
} | ||
/** | ||
* Continues the propagation of the data change event | ||
@@ -40,26 +102,2 @@ * @param {!Event} event | ||
/** | ||
* Handles the filtered items event and continues to propagate. | ||
* @param {!Event} event | ||
* @param {!string} query | ||
* @protected | ||
* @return {Boolean} If the event has been prevented or not. | ||
*/ | ||
_handleFilteredItems(event, query) { | ||
if (query) { | ||
this.filteredItems = this.refs.dataProvider.filter( | ||
query, | ||
this.extractData | ||
); | ||
} else { | ||
this.filteredItems = []; | ||
} | ||
return !this.emit({ | ||
data: this.filteredItems, | ||
name: 'filteredItems', | ||
originalEvent: event, | ||
}); | ||
} | ||
/** | ||
* Handle the selected item in the dropdown and trigger the itemSelected event. | ||
@@ -114,14 +152,11 @@ * @param {!Event} event | ||
_handleOnInput(event) { | ||
const query = event.target.value; | ||
const {value} = event.target; | ||
const char = event.data || value.substr(-1); | ||
if (this.enableAutocomplete) { | ||
this._handleFilteredItems(event, query); | ||
} | ||
return !this.emit({ | ||
data: { | ||
value: event.target.value, | ||
char: event.data, | ||
value, | ||
char, | ||
}, | ||
name: 'queryChange', | ||
name: 'inputChange', | ||
originalEvent: event, | ||
@@ -200,23 +235,2 @@ }); | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
attached() { | ||
this._dropdownItemFocused = null; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
disposed() { | ||
this._dropdownItemFocused = null; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
syncFilteredItems() { | ||
this._dropdownItemFocused = null; | ||
} | ||
} | ||
@@ -249,16 +263,29 @@ | ||
/** | ||
* The array of data items that the data source contains or | ||
* the URL for the data provider to request. | ||
* The array of data items that the data source contains, | ||
* the URL for the data provider to request, or a function | ||
* that receives the query and returns a promise with the | ||
* elements. | ||
* | ||
* @instance | ||
* @default undefined | ||
* @instance | ||
* @memberof ClayAutocomplete | ||
* @type {!(string|object|array)} | ||
* @type {!(string|object|array|function)} | ||
*/ | ||
dataSource: Config.oneOfType([ | ||
Config.array(), | ||
Config.func(), | ||
Config.object(), | ||
Config.string(), | ||
Config.object(), | ||
Config.array(), | ||
]).required(), | ||
/** | ||
* Set the request debounce time | ||
* @instance | ||
* @default 200 | ||
* @memberof ClayAutocomplete | ||
* @type {?(number)} | ||
*/ | ||
debounceTime: Config.number().value(200), | ||
/** | ||
* Object that wires events with default listeners | ||
@@ -289,3 +316,9 @@ * @default undefined | ||
*/ | ||
enableAutocomplete: Config.bool().value(true), | ||
enableAutocomplete: Config.validator(value => { | ||
if (value) { | ||
console.warn( | ||
'🚨 `enableAutocomplete` has been deprecated and will be removed in the next major version.' | ||
); | ||
} | ||
}), | ||
@@ -358,2 +391,21 @@ /** | ||
/** | ||
* Flag to define how often to refetch data (ms) | ||
* @instance | ||
* @default 0 | ||
* @memberof ClayAutocomplete | ||
* @type {?(number|undefined)} | ||
*/ | ||
pollingInterval: Config.number().value(0), | ||
/** | ||
* Specifies explicitly if request needs to be made with debounce | ||
* (userInput) or with polling (polling) | ||
* @instance | ||
* @default undefined | ||
* @memberof ClayAutocomplete | ||
* @type {?(object|array)} | ||
*/ | ||
requestInputMode: Config.oneOf(['polling', 'userInput']).value('userInput'), | ||
/** | ||
* Set ups the request options | ||
@@ -378,8 +430,14 @@ * @default undefined | ||
* Flag to define how often to refetch data (ms) | ||
* @instance | ||
* @default 0 | ||
* @instance | ||
* @memberof ClayAutocomplete | ||
* @type {?(number|undefined)} | ||
*/ | ||
requestPolling: Config.number().value(0), | ||
requestPolling: Config.validator(value => { | ||
if (value) { | ||
console.warn( | ||
'🚨 `requestPolling` has been renamed to `pollingInterval` and will be deprecated and removed in the next release.' | ||
); | ||
} | ||
}), | ||
@@ -386,0 +444,0 @@ /** |
@@ -39,4 +39,4 @@ /* jshint ignore:start */ | ||
opt_ijData = opt_ijData_deprecated || opt_ijData; | ||
/** @type {!Array<?>|!Object|!goog.soy.data.SanitizedContent|string} */ | ||
var dataSource = soy.asserts.assertType(goog.isObject(opt_data.dataSource) || goog.isArray(opt_data.dataSource) || (goog.isString(opt_data.dataSource) || opt_data.dataSource instanceof goog.soy.data.SanitizedContent), 'dataSource', opt_data.dataSource, '!Array<?>|!Object|!goog.soy.data.SanitizedContent|string'); | ||
/** @type {!Array<?>|!Object|!goog.soy.data.SanitizedContent|*|string} */ | ||
var dataSource = opt_data.dataSource; | ||
/** @type {*|null|undefined} */ | ||
@@ -70,7 +70,9 @@ var _handleDataChange = opt_data._handleDataChange; | ||
var inputValue = soy.asserts.assertType(opt_data.inputValue == null || (goog.isString(opt_data.inputValue) || opt_data.inputValue instanceof goog.soy.data.SanitizedContent), 'inputValue', opt_data.inputValue, '!goog.soy.data.SanitizedContent|null|string|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var pollingInterval = soy.asserts.assertType(opt_data.pollingInterval == null || goog.isNumber(opt_data.pollingInterval), 'pollingInterval', opt_data.pollingInterval, 'null|number|undefined'); | ||
/** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */ | ||
var requestInputMode = soy.asserts.assertType(opt_data.requestInputMode == null || (goog.isString(opt_data.requestInputMode) || opt_data.requestInputMode instanceof goog.soy.data.SanitizedContent), 'requestInputMode', opt_data.requestInputMode, '!goog.soy.data.SanitizedContent|null|string|undefined'); | ||
/** @type {null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}} */ | ||
var requestOptions = soy.asserts.assertType(opt_data.requestOptions == null || goog.isObject(opt_data.requestOptions), 'requestOptions', opt_data.requestOptions, 'null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}'); | ||
/** @type {null|number|undefined} */ | ||
var requestPolling = soy.asserts.assertType(opt_data.requestPolling == null || goog.isNumber(opt_data.requestPolling), 'requestPolling', opt_data.requestPolling, 'null|number|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var requestRetries = soy.asserts.assertType(opt_data.requestRetries == null || goog.isNumber(opt_data.requestRetries), 'requestRetries', opt_data.requestRetries, 'null|number|undefined'); | ||
@@ -81,3 +83,3 @@ /** @type {null|number|undefined} */ | ||
var unstable_content = soy.asserts.assertType(opt_data.unstable_content == null || goog.isFunction(opt_data.unstable_content), 'unstable_content', opt_data.unstable_content, 'function()|null|undefined'); | ||
var attributes__soy41 = function() { | ||
var attributes__soy42 = function() { | ||
incrementalDom.attr('class', 'dropdown-full' + (elementClasses ? ' ' + elementClasses : ' form-group')); | ||
@@ -90,7 +92,7 @@ incrementalDom.attr('data-onkeydown', _handleOnKeydown); | ||
incrementalDom.elementOpenStart('div'); | ||
attributes__soy41(); | ||
attributes__soy42(); | ||
incrementalDom.elementOpenEnd(); | ||
soyIdom.print(unstable_content); | ||
$input({_handleOnBlur: _handleOnBlur, _handleOnFocus: _handleOnFocus, _handleOnInput: _handleOnInput, _handleOnKeydown: _handleOnKeydown, inputElementClasses: inputElementClasses, inputName: inputName, inputValue: inputValue}, opt_ijData); | ||
$dropdown({_handleDataChange: _handleDataChange, _handleDropdownItemClick: _handleDropdownItemClick, contentRenderer: contentRenderer, dataSource: dataSource, filteredItems: filteredItems, initialData: initialData, requestOptions: requestOptions, requestPolling: requestPolling, requestRetries: requestRetries, requestTimeout: requestTimeout}, opt_ijData); | ||
$dropdown({_handleDataChange: _handleDataChange, _handleDropdownItemClick: _handleDropdownItemClick, contentRenderer: contentRenderer, dataSource: dataSource, filteredItems: filteredItems, initialData: initialData, pollingInterval: pollingInterval, requestInputMode: requestInputMode, requestOptions: requestOptions, requestRetries: requestRetries, requestTimeout: requestTimeout}, opt_ijData); | ||
incrementalDom.elementClose('div'); | ||
@@ -101,3 +103,3 @@ }; | ||
* @typedef {{ | ||
* dataSource: (!Array<?>|!Object|!goog.soy.data.SanitizedContent|string), | ||
* dataSource: (!Array<?>|!Object|!goog.soy.data.SanitizedContent|*|string), | ||
* _handleDataChange: (*|null|undefined), | ||
@@ -117,4 +119,5 @@ * _handleDropdownItemClick: (*|null|undefined), | ||
* inputValue: (!goog.soy.data.SanitizedContent|null|string|undefined), | ||
* pollingInterval: (null|number|undefined), | ||
* requestInputMode: (!goog.soy.data.SanitizedContent|null|string|undefined), | ||
* requestOptions: (null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}), | ||
* requestPolling: (null|number|undefined), | ||
* requestRetries: (null|number|undefined), | ||
@@ -155,3 +158,3 @@ * requestTimeout: (null|number|undefined), | ||
var inputValue = soy.asserts.assertType(opt_data.inputValue == null || (goog.isString(opt_data.inputValue) || opt_data.inputValue instanceof goog.soy.data.SanitizedContent), 'inputValue', opt_data.inputValue, '!goog.soy.data.SanitizedContent|null|string|undefined'); | ||
var attributes__soy110 = function() { | ||
var attributes__soy112 = function() { | ||
incrementalDom.attr('class', inputElementClasses ? inputElementClasses : 'form-control'); | ||
@@ -175,3 +178,3 @@ if (inputName) { | ||
incrementalDom.elementOpenStart('input'); | ||
attributes__soy110(); | ||
attributes__soy112(); | ||
incrementalDom.elementOpenEnd(); | ||
@@ -207,4 +210,4 @@ incrementalDom.elementClose('input'); | ||
opt_ijData = opt_ijData_deprecated || opt_ijData; | ||
/** @type {!Array<?>|!Object|!goog.soy.data.SanitizedContent|string} */ | ||
var dataSource = soy.asserts.assertType(goog.isObject(opt_data.dataSource) || goog.isArray(opt_data.dataSource) || (goog.isString(opt_data.dataSource) || opt_data.dataSource instanceof goog.soy.data.SanitizedContent), 'dataSource', opt_data.dataSource, '!Array<?>|!Object|!goog.soy.data.SanitizedContent|string'); | ||
/** @type {!Array<?>|!Object|!goog.soy.data.SanitizedContent|*|string} */ | ||
var dataSource = opt_data.dataSource; | ||
/** @type {*|null|undefined} */ | ||
@@ -220,25 +223,27 @@ var _handleDataChange = opt_data._handleDataChange; | ||
var initialData = soy.asserts.assertType(opt_data.initialData == null || goog.isObject(opt_data.initialData) || goog.isArray(opt_data.initialData), 'initialData', opt_data.initialData, '!Array<?>|!Object|null|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var pollingInterval = soy.asserts.assertType(opt_data.pollingInterval == null || goog.isNumber(opt_data.pollingInterval), 'pollingInterval', opt_data.pollingInterval, 'null|number|undefined'); | ||
/** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */ | ||
var requestInputMode = soy.asserts.assertType(opt_data.requestInputMode == null || (goog.isString(opt_data.requestInputMode) || opt_data.requestInputMode instanceof goog.soy.data.SanitizedContent), 'requestInputMode', opt_data.requestInputMode, '!goog.soy.data.SanitizedContent|null|string|undefined'); | ||
/** @type {null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}} */ | ||
var requestOptions = soy.asserts.assertType(opt_data.requestOptions == null || goog.isObject(opt_data.requestOptions), 'requestOptions', opt_data.requestOptions, 'null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}'); | ||
/** @type {null|number|undefined} */ | ||
var requestPolling = soy.asserts.assertType(opt_data.requestPolling == null || goog.isNumber(opt_data.requestPolling), 'requestPolling', opt_data.requestPolling, 'null|number|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var requestRetries = soy.asserts.assertType(opt_data.requestRetries == null || goog.isNumber(opt_data.requestRetries), 'requestRetries', opt_data.requestRetries, 'null|number|undefined'); | ||
/** @type {null|number|undefined} */ | ||
var requestTimeout = soy.asserts.assertType(opt_data.requestTimeout == null || goog.isNumber(opt_data.requestTimeout), 'requestTimeout', opt_data.requestTimeout, 'null|number|undefined'); | ||
var isVisible__soy126 = filteredItems && (filteredItems.length) > 0 ? true : false; | ||
var classes__soy133 = ''; | ||
classes__soy133 += 'dropdown-menu'; | ||
classes__soy133 += isVisible__soy126 ? ' show' : ''; | ||
var param151 = function() { | ||
var isVisible__soy129 = filteredItems && (filteredItems.length) > 0 ? true : false; | ||
var classes__soy136 = ''; | ||
classes__soy136 += 'dropdown-menu'; | ||
classes__soy136 += isVisible__soy129 ? ' show' : ''; | ||
var param154 = function() { | ||
incrementalDom.elementOpenStart('ul'); | ||
incrementalDom.attr('class', classes__soy133); | ||
incrementalDom.attr('class', classes__soy136); | ||
incrementalDom.attr('ref', 'dropdown'); | ||
incrementalDom.elementOpenEnd(); | ||
if (filteredItems) { | ||
var item141List = filteredItems; | ||
var item141ListLen = item141List.length; | ||
for (var item141Index = 0; item141Index < item141ListLen; item141Index++) { | ||
var item141Data = item141List[item141Index]; | ||
soy.$$getDelegateFn(soy.$$getDelTemplateId('ClayAutocomplete.Item.idom'), contentRenderer, true)({_handleDropdownItemClick: _handleDropdownItemClick, data: item141Data, index: item141Index}, opt_ijData); | ||
var item144List = filteredItems; | ||
var item144ListLen = item144List.length; | ||
for (var item144Index = 0; item144Index < item144ListLen; item144Index++) { | ||
var item144Data = item144List[item144Index]; | ||
soy.$$getDelegateFn(soy.$$getDelTemplateId('ClayAutocomplete.Item.idom'), contentRenderer, true)({_handleDropdownItemClick: _handleDropdownItemClick, data: item144Data, index: item144Index}, opt_ijData); | ||
} | ||
@@ -248,3 +253,3 @@ } | ||
}; | ||
$templateAlias1({content: param151, dataSource: dataSource, events: {dataChange: _handleDataChange}, initialData: initialData, ref: 'dataProvider', requestOptions: requestOptions, requestPolling: requestPolling, requestRetries: requestRetries, requestTimeout: requestTimeout}, opt_ijData); | ||
$templateAlias1({content: param154, dataSource: dataSource, events: {dataChange: _handleDataChange}, initialData: initialData, pollingInterval: pollingInterval, ref: 'dataProvider', requestInputMode: requestInputMode, requestOptions: requestOptions, requestRetries: requestRetries, requestTimeout: requestTimeout}, opt_ijData); | ||
}; | ||
@@ -254,3 +259,3 @@ exports.dropdown = $dropdown; | ||
* @typedef {{ | ||
* dataSource: (!Array<?>|!Object|!goog.soy.data.SanitizedContent|string), | ||
* dataSource: (!Array<?>|!Object|!goog.soy.data.SanitizedContent|*|string), | ||
* _handleDataChange: (*|null|undefined), | ||
@@ -261,4 +266,5 @@ * _handleDropdownItemClick: (*|null|undefined), | ||
* initialData: (!Array<?>|!Object|null|undefined), | ||
* pollingInterval: (null|number|undefined), | ||
* requestInputMode: (!goog.soy.data.SanitizedContent|null|string|undefined), | ||
* requestOptions: (null|undefined|{body: !Object, cache: (!goog.soy.data.SanitizedContent|string), credentials: (!goog.soy.data.SanitizedContent|string), headers: !Object, method: (!goog.soy.data.SanitizedContent|string), mode: (!goog.soy.data.SanitizedContent|string), redirect: (!goog.soy.data.SanitizedContent|string), referrer: (!goog.soy.data.SanitizedContent|string),}), | ||
* requestPolling: (null|number|undefined), | ||
* requestRetries: (null|number|undefined), | ||
@@ -298,12 +304,12 @@ * requestTimeout: (null|number|undefined), | ||
if (data.matches && (data.matches.length) > 0) { | ||
var char175List = data.matches; | ||
var char175ListLen = char175List.length; | ||
for (var char175Index = 0; char175Index < char175ListLen; char175Index++) { | ||
var char175Data = char175List[char175Index]; | ||
if (char175Data.match) { | ||
var char179List = data.matches; | ||
var char179ListLen = char179List.length; | ||
for (var char179Index = 0; char179Index < char179ListLen; char179Index++) { | ||
var char179Data = char179List[char179Index]; | ||
if (char179Data.match) { | ||
incrementalDom.elementOpen('strong'); | ||
soyIdom.print(char175Data.value); | ||
soyIdom.print(char179Data.value); | ||
incrementalDom.elementClose('strong'); | ||
} else { | ||
soyIdom.print(char175Data.value); | ||
soyIdom.print(char179Data.value); | ||
} | ||
@@ -329,8 +335,8 @@ } | ||
exports.render.params = ["dataSource","_handleDataChange","_handleDropdownItemClick","_handleOnBlur","_handleOnFocus","_handleOnInput","_handleOnKeydown","contentRenderer","elementClasses","filteredItems","id","initialData","inputElementClasses","inputName","inputValue","requestOptions","requestPolling","requestRetries","requestTimeout","unstable_content"]; | ||
exports.render.types = {"dataSource":"string|[]|list<?>","_handleDataChange":"any","_handleDropdownItemClick":"any","_handleOnBlur":"any","_handleOnFocus":"any","_handleOnInput":"any","_handleOnKeydown":"any","contentRenderer":"string","elementClasses":"string","filteredItems":"list<?>","id":"string","initialData":"[]|list<?>","inputElementClasses":"string","inputName":"string","inputValue":"string","requestOptions":"[\n\t\tmethod: string,\n\t\tmode: string,\n\t\tcache: string,\n\t\tcredentials: string,\n\t\theaders: [],\n\t\tredirect: string,\n\t\treferrer: string,\n\t\tbody: []\n\t]","requestPolling":"number","requestRetries":"number","requestTimeout":"number","unstable_content":"html"}; | ||
exports.render.params = ["dataSource","_handleDataChange","_handleDropdownItemClick","_handleOnBlur","_handleOnFocus","_handleOnInput","_handleOnKeydown","contentRenderer","elementClasses","filteredItems","id","initialData","inputElementClasses","inputName","inputValue","pollingInterval","requestInputMode","requestOptions","requestRetries","requestTimeout","unstable_content"]; | ||
exports.render.types = {"dataSource":"string|[]|list<?>|any","_handleDataChange":"any","_handleDropdownItemClick":"any","_handleOnBlur":"any","_handleOnFocus":"any","_handleOnInput":"any","_handleOnKeydown":"any","contentRenderer":"string","elementClasses":"string","filteredItems":"list<?>","id":"string","initialData":"[]|list<?>","inputElementClasses":"string","inputName":"string","inputValue":"string","pollingInterval":"number","requestInputMode":"string","requestOptions":"[\n\t\tmethod: string,\n\t\tmode: string,\n\t\tcache: string,\n\t\tcredentials: string,\n\t\theaders: [],\n\t\tredirect: string,\n\t\treferrer: string,\n\t\tbody: []\n\t]","requestRetries":"number","requestTimeout":"number","unstable_content":"html"}; | ||
exports.input.params = ["_handleOnBlur","_handleOnFocus","_handleOnInput","_handleOnKeydown","inputElementClasses","inputName","inputValue"]; | ||
exports.input.types = {"_handleOnBlur":"any","_handleOnFocus":"any","_handleOnInput":"any","_handleOnKeydown":"any","inputElementClasses":"string","inputName":"string","inputValue":"string"}; | ||
exports.dropdown.params = ["dataSource","_handleDataChange","_handleDropdownItemClick","contentRenderer","filteredItems","initialData","requestOptions","requestPolling","requestRetries","requestTimeout"]; | ||
exports.dropdown.types = {"dataSource":"string|[]|list<?>","_handleDataChange":"any","_handleDropdownItemClick":"any","contentRenderer":"string","filteredItems":"list<?>","initialData":"[]|list<?>","requestOptions":"[\n\t\tmethod: string,\n\t\tmode: string,\n\t\tcache: string,\n\t\tcredentials: string,\n\t\theaders: [],\n\t\tredirect: string,\n\t\treferrer: string,\n\t\tbody: []\n\t]","requestPolling":"number","requestRetries":"number","requestTimeout":"number"}; | ||
exports.dropdown.params = ["dataSource","_handleDataChange","_handleDropdownItemClick","contentRenderer","filteredItems","initialData","pollingInterval","requestInputMode","requestOptions","requestRetries","requestTimeout"]; | ||
exports.dropdown.types = {"dataSource":"string|[]|list<?>|any","_handleDataChange":"any","_handleDropdownItemClick":"any","contentRenderer":"string","filteredItems":"list<?>","initialData":"[]|list<?>","pollingInterval":"number","requestInputMode":"string","requestOptions":"[\n\t\tmethod: string,\n\t\tmode: string,\n\t\tcache: string,\n\t\tcredentials: string,\n\t\theaders: [],\n\t\tredirect: string,\n\t\treferrer: string,\n\t\tbody: []\n\t]","requestRetries":"number","requestTimeout":"number"}; | ||
templates = exports; | ||
@@ -337,0 +343,0 @@ return exports; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
152500
1931
Updatedclay-data-provider@^2.8.0