diff --git a/src/lib/utils/list.js b/src/lib/utils/list.js index 94703dc..9a5b147 100644 --- a/src/lib/utils/list.js +++ b/src/lib/utils/list.js @@ -142,10 +142,10 @@ export function getFilterProps(object) { * @param {?string} inputValue * @param {?Set} excludeSelected * @param {ComponentConfig} config - * @param {SearchProps|null} searchProps + * @param {SearchProps} searchProps * @returns {object[]} */ -export function filterList(options, inputValue, excludeSelected, config, searchProps) { +export function filterList(options, inputValue, excludeSelected, config, searchProps = {}) { if (!searchProps.keepSelectionInList && excludeSelected) { options = options .filter(opt => !excludeSelected.has(opt[config.valueField])) @@ -219,12 +219,14 @@ export function fieldInit(type, options, groupItemsField) { const isValue = type === 'value'; let val = isValue ? 'value' : 'text'; // selectize style defaults if (options && options.length) { + // @ts-ignore const firstItem = options[0][groupItemsField] ? options[0][groupItemsField][0] : options[0]; if (!firstItem || typeof firstItem === 'string') return val; const autoAddItem = isValue ? 0 : 1; const guessList = isValue ? ['id', 'value', 'ID'] : ['name', 'title', 'label']; + // @ts-ignore val = Object.keys(firstItem).filter(prop => guessList.includes(prop)) .concat([Object.keys(firstItem)[autoAddItem]]) // auto add field (used as fallback) if empty list is returned .shift(); diff --git a/src/lib/utils/sifter.js b/src/lib/utils/sifter.js index 3d06c03..0de91b5 100644 --- a/src/lib/utils/sifter.js +++ b/src/lib/utils/sifter.js @@ -27,7 +27,7 @@ * * @constructor * @param {array|object} items - * @param {object} items + * @param {object} [settings] */ var Sifter = function(items, settings) { this.items = items; @@ -112,7 +112,7 @@ Sifter.prototype.iterator = function(object, callback) { * If an item is not a match, 0 will be returned by the function. * * @param {object|string} search - * @param {object} options (optional) + * @param {object} [options] * @returns {function} */ Sifter.prototype.getScoreFunction = function(search, options) { @@ -425,6 +425,7 @@ var getattr = function(obj, name, nesting) { if (!obj || !name) return; if (!nesting) return obj[name]; var names = name.split("."); + // @ts-ignore while(names.length && (obj = obj[names.shift()])); return obj; };