@appbaseio/reactivecore
Advanced tools
Comparing version 9.10.2 to 9.11.0
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var componentTypes=exports.componentTypes={reactiveList:'REACTIVELIST',dataSearch:'DATASEARCH',categorySearch:'CATEGORYSEARCH',singleList:'SINGLELIST',multiList:'MULTILIST',singleDataList:'SINGLEDATALIST',singleDropdownList:'SINGLEDROPDOWNLIST',multiDataList:'MULTIDATALIST',multiDropdownList:'MULTIDROPDOWNLIST',singleDropdownRange:'SINGLEDROPDOWNRANGE',numberBox:'NUMBERBOX',tagCloud:'TAGCLOUD',toggleButton:'TOGGLEBUTTON',reactiveComponent:'REACTIVECOMPONENT',datePicker:'DATEPICKER',dateRange:'DATERANGE',dynamicRangeSlider:'DYNAMICRANGESLIDER',multiDropdownRange:'MULTIDROPDOWNRANGE',singleRange:'SINGLERANGE',multiRange:'MULTIRANGE',rangeSlider:'RANGESLIDER',ratingsFilter:'RATINGSFILTER',rangeInput:'RANGEINPUT',geoDistanceDropdown:'GEO_DISTANCE_DROPDOWN',geoDistanceSlider:'GEO_DISTANCE_SLIDER',reactiveMap:'REACTIVE_MAP'};var queryTypes=exports.queryTypes={search:'search',term:'term',range:'range',geo:'geo'};var validProps=exports.validProps=['componentType','aggregationField','aggregationSize','dataField','includeFields','excludeFields','size','from','sortBy','sortOptions','pagination','autoFocus','autosuggest','debounce','defaultValue','defaultSuggestions','fieldWeights','filterLabel','fuzziness','highlight','highlightField','nestedField','placeholder','queryFormat','searchOperators','enableSynonyms','enableQuerySuggestions','enablePopularSuggestions','queryString','categoryField','strictSelection','selectAllLabel','showCheckbox','showFilter','showSearch','showCount','showLoadMore','loadMoreLabel','showMissing','missingLabel','data','showRadio','multiSelect','includeNullValues','interval','showHistogram','snap','stepValue','range','showSlider','parseDate','unit'];var CLEAR_ALL=exports.CLEAR_ALL={NEVER:'never',ALWAYS:'always',DEFAULT:'default'}; | ||
Object.defineProperty(exports,"__esModule",{value:true});var componentTypes=exports.componentTypes={reactiveList:'REACTIVELIST',dataSearch:'DATASEARCH',categorySearch:'CATEGORYSEARCH',singleList:'SINGLELIST',multiList:'MULTILIST',singleDataList:'SINGLEDATALIST',singleDropdownList:'SINGLEDROPDOWNLIST',multiDataList:'MULTIDATALIST',multiDropdownList:'MULTIDROPDOWNLIST',singleDropdownRange:'SINGLEDROPDOWNRANGE',numberBox:'NUMBERBOX',tagCloud:'TAGCLOUD',toggleButton:'TOGGLEBUTTON',reactiveComponent:'REACTIVECOMPONENT',datePicker:'DATEPICKER',dateRange:'DATERANGE',dynamicRangeSlider:'DYNAMICRANGESLIDER',multiDropdownRange:'MULTIDROPDOWNRANGE',singleRange:'SINGLERANGE',multiRange:'MULTIRANGE',rangeSlider:'RANGESLIDER',ratingsFilter:'RATINGSFILTER',rangeInput:'RANGEINPUT',geoDistanceDropdown:'GEO_DISTANCE_DROPDOWN',geoDistanceSlider:'GEO_DISTANCE_SLIDER',reactiveMap:'REACTIVE_MAP'};var queryTypes=exports.queryTypes={search:'search',term:'term',range:'range',geo:'geo'};var validProps=exports.validProps=['componentType','aggregationField','aggregationSize','distinctField','distinctFieldConfig','dataField','includeFields','excludeFields','size','from','sortBy','sortOptions','pagination','autoFocus','autosuggest','debounce','defaultValue','defaultSuggestions','fieldWeights','filterLabel','fuzziness','highlight','highlightField','nestedField','placeholder','queryFormat','searchOperators','enableSynonyms','enableQuerySuggestions','enablePopularSuggestions','queryString','categoryField','strictSelection','selectAllLabel','showCheckbox','showFilter','showSearch','showCount','showLoadMore','loadMoreLabel','showMissing','missingLabel','data','showRadio','multiSelect','includeNullValues','interval','showHistogram','snap','stepValue','range','showSlider','parseDate','unit'];var CLEAR_ALL=exports.CLEAR_ALL={NEVER:'never',ALWAYS:'always',DEFAULT:'default'}; |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}var flatten=function flatten(arr){return arr.reduce(function(flat,toFlatten){return flat.concat(Array.isArray(toFlatten)?flatten(toFlatten):toFlatten);},[]);};var extractSuggestion=function extractSuggestion(val){switch(typeof val){case'string':return val;case'object':if(Array.isArray(val)){return flatten(val);}return null;default:return val;}};function replaceDiacritics(s){var str=s?String(s):'';var diacritics=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g];var chars=['A','a','E','e','I','i','O','o','U','u','N','n','C','c'];for(var i=0;i<diacritics.length;i+=1){str=str.replace(diacritics[i],chars[i]);}return str;}var getPredictiveSuggestions=function getPredictiveSuggestions(_ref){var suggestions=_ref.suggestions,currentValue=_ref.currentValue,wordsToShowAfterHighlight=_ref.wordsToShowAfterHighlight;var suggestionMap={};if(currentValue){var currentValueTrimmed=currentValue.trim();var parsedSuggestion=suggestions.reduce(function(agg,_ref2){var label=_ref2.label,rest=_objectWithoutProperties(_ref2,['label']);var parsedContent=new DOMParser().parseFromString(label,'text/html').documentElement.textContent;var regexString='^('+currentValueTrimmed+')\\w+';var regex=new RegExp(regexString,'i');var regexExecution=regex.exec(parsedContent);if(!regexExecution){regexString='^('+currentValueTrimmed+')';regex=new RegExp(regexString,'i');regexExecution=regex.exec(parsedContent);}if(regexExecution){var matchedString=parsedContent.slice(regexExecution.index,parsedContent.length);var suggestionPhrase=currentValueTrimmed+'<mark class="highlight">'+matchedString.slice(currentValueTrimmed.length).split(' ').slice(0,wordsToShowAfterHighlight+1).join(' ')+'</mark>';if(!suggestionMap[suggestionPhrase]){suggestionMap[suggestionPhrase]=1;return[].concat(_toConsumableArray(agg),[_extends({label:suggestionPhrase,isPredictiveSuggestion:true},rest)]);}return agg;}return agg;},[]);return parsedSuggestion;}return[];};var getSuggestions=function getSuggestions(_ref3){var fields=_ref3.fields,suggestions=_ref3.suggestions,currentValue=_ref3.currentValue,_ref3$suggestionPrope=_ref3.suggestionProperties,suggestionProperties=_ref3$suggestionPrope===undefined?[]:_ref3$suggestionPrope,_ref3$showDistinctSug=_ref3.showDistinctSuggestions,showDistinctSuggestions=_ref3$showDistinctSug===undefined?false:_ref3$showDistinctSug,_ref3$enablePredictiv=_ref3.enablePredictiveSuggestions,enablePredictiveSuggestions=_ref3$enablePredictiv===undefined?false:_ref3$enablePredictiv,_ref3$wordsToShowAfte=_ref3.wordsToShowAfterHighlight,wordsToShowAfterHighlight=_ref3$wordsToShowAfte===undefined?2:_ref3$wordsToShowAfte,enableSynonyms=_ref3.enableSynonyms;var suggestionsList=[];var labelsList=[];var skipWordMatch=false;var populateSuggestionsList=function populateSuggestionsList(val,parsedSource,source){var isWordMatch=skipWordMatch||currentValue.trim().split(' ').some(function(term){return replaceDiacritics(val).toLowerCase().includes(replaceDiacritics(term));});if(isWordMatch&&!labelsList.includes(val)||source._promoted){var defaultOption={label:val,value:val,source:source};var additionalKeys={};if(Array.isArray(suggestionProperties)&&suggestionProperties.length>0){suggestionProperties.forEach(function(prop){if(parsedSource.hasOwnProperty(prop)){additionalKeys=_extends({},additionalKeys,_defineProperty({},prop,parsedSource[prop]));}});}var option=_extends({},defaultOption,additionalKeys);labelsList=[].concat(_toConsumableArray(labelsList),[val]);suggestionsList=[].concat(_toConsumableArray(suggestionsList),[option]);if(showDistinctSuggestions){return true;}}return false;};var parseField=function parseField(parsedSource){var field=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var source=arguments.length>2&&arguments[2]!==undefined?arguments[2]:parsedSource;if(typeof parsedSource==='object'){var fieldNodes=field.split('.');var label=parsedSource[fieldNodes[0]];if(Array.isArray(label)){if(label.length>1){label=label.filter(function(i){return i&&i.toString().toLowerCase().includes(currentValue.toString().toLowerCase());});}label=label[0];}if(label){if(fieldNodes.length>1){var children=field.substring(fieldNodes[0].length+1);parseField(label,children,source);}else{var val=extractSuggestion(label);if(val){return populateSuggestionsList(val,parsedSource,source);}}}}return false;};var traverseSuggestions=function traverseSuggestions(){if(showDistinctSuggestions){suggestions.forEach(function(item){fields.some(function(field){return parseField(item,field);});});}else{suggestions.forEach(function(item){fields.forEach(function(field){parseField(item,field);});});}};traverseSuggestions();if(suggestionsList.length<suggestions.length&&!skipWordMatch&&enableSynonyms){skipWordMatch=true;traverseSuggestions();}if(enablePredictiveSuggestions){var predictiveSuggestions=getPredictiveSuggestions({suggestions:suggestionsList,currentValue:currentValue,wordsToShowAfterHighlight:wordsToShowAfterHighlight});suggestionsList=predictiveSuggestions;}return suggestionsList;};exports.default=getSuggestions; | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}var flatten=function flatten(arr){return arr.reduce(function(flat,toFlatten){return flat.concat(Array.isArray(toFlatten)?flatten(toFlatten):toFlatten);},[]);};var extractSuggestion=function extractSuggestion(val){switch(typeof val){case'string':return val;case'object':if(Array.isArray(val)){return flatten(val);}return null;default:return val;}};function replaceDiacritics(s){var str=s?String(s):'';var diacritics=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g];var chars=['A','a','E','e','I','i','O','o','U','u','N','n','C','c'];for(var i=0;i<diacritics.length;i+=1){str=str.replace(diacritics[i],chars[i]);}return str;}function escapeRegExp(){var string=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return string.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');}var getPredictiveSuggestions=function getPredictiveSuggestions(_ref){var suggestions=_ref.suggestions,currentValue=_ref.currentValue,wordsToShowAfterHighlight=_ref.wordsToShowAfterHighlight;var suggestionMap={};if(currentValue){var currentValueTrimmed=currentValue.trim();var parsedSuggestion=suggestions.reduce(function(agg,_ref2){var label=_ref2.label,rest=_objectWithoutProperties(_ref2,['label']);var parsedContent=new DOMParser().parseFromString(label,'text/html').documentElement.textContent;var regexString='^('+escapeRegExp(currentValueTrimmed)+')\\w+';var regex=new RegExp(regexString,'i');var regexExecution=regex.exec(parsedContent);if(!regexExecution){regexString='^('+escapeRegExp(currentValueTrimmed)+')';regex=new RegExp(regexString,'i');regexExecution=regex.exec(parsedContent);}if(regexExecution){var matchedString=parsedContent.slice(regexExecution.index,parsedContent.length);var highlightedWord=matchedString.slice(currentValueTrimmed.length).split(' ').slice(0,wordsToShowAfterHighlight+1).join(' ');var suggestionPhrase=currentValueTrimmed+'<mark class="highlight">'+highlightedWord+'</mark>';var suggestionValue=''+currentValueTrimmed+highlightedWord;if(!suggestionMap[suggestionPhrase]){suggestionMap[suggestionPhrase]=1;return[].concat(_toConsumableArray(agg),[_extends({},rest,{label:suggestionPhrase,value:suggestionValue,isPredictiveSuggestion:true})]);}return agg;}return agg;},[]);return parsedSuggestion;}return[];};var getSuggestions=function getSuggestions(_ref3){var fields=_ref3.fields,suggestions=_ref3.suggestions,currentValue=_ref3.currentValue,_ref3$suggestionPrope=_ref3.suggestionProperties,suggestionProperties=_ref3$suggestionPrope===undefined?[]:_ref3$suggestionPrope,_ref3$showDistinctSug=_ref3.showDistinctSuggestions,showDistinctSuggestions=_ref3$showDistinctSug===undefined?false:_ref3$showDistinctSug,_ref3$enablePredictiv=_ref3.enablePredictiveSuggestions,enablePredictiveSuggestions=_ref3$enablePredictiv===undefined?false:_ref3$enablePredictiv,_ref3$wordsToShowAfte=_ref3.wordsToShowAfterHighlight,wordsToShowAfterHighlight=_ref3$wordsToShowAfte===undefined?2:_ref3$wordsToShowAfte,enableSynonyms=_ref3.enableSynonyms;var suggestionsList=[];var labelsList=[];var skipWordMatch=false;var populateSuggestionsList=function populateSuggestionsList(val,parsedSource,source){var isWordMatch=skipWordMatch||currentValue.trim().split(' ').some(function(term){return replaceDiacritics(val).toLowerCase().includes(replaceDiacritics(term));});if(isWordMatch&&!labelsList.includes(val)||source._promoted){var defaultOption={label:val,value:val,source:source};var additionalKeys={};if(Array.isArray(suggestionProperties)&&suggestionProperties.length>0){suggestionProperties.forEach(function(prop){if(parsedSource.hasOwnProperty(prop)){additionalKeys=_extends({},additionalKeys,_defineProperty({},prop,parsedSource[prop]));}});}var option=_extends({},defaultOption,additionalKeys);labelsList=[].concat(_toConsumableArray(labelsList),[val]);suggestionsList=[].concat(_toConsumableArray(suggestionsList),[option]);if(showDistinctSuggestions){return true;}}return false;};var parseField=function parseField(parsedSource){var field=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var source=arguments.length>2&&arguments[2]!==undefined?arguments[2]:parsedSource;if(typeof parsedSource==='object'){var fieldNodes=field.split('.');var label=parsedSource[fieldNodes[0]];if(Array.isArray(label)){if(label.length>1){label=label.filter(function(i){return i&&i.toString().toLowerCase().includes(currentValue.toString().toLowerCase());});}label=label[0];}if(label){if(fieldNodes.length>1){var children=field.substring(fieldNodes[0].length+1);parseField(label,children,source);}else{var val=extractSuggestion(label);if(val){return populateSuggestionsList(val,parsedSource,source);}}}}return false;};var traverseSuggestions=function traverseSuggestions(){if(showDistinctSuggestions){suggestions.forEach(function(item){fields.some(function(field){return parseField(item,field);});});}else{suggestions.forEach(function(item){fields.forEach(function(field){parseField(item,field);});});}};traverseSuggestions();if(suggestionsList.length<suggestions.length&&!skipWordMatch&&enableSynonyms){skipWordMatch=true;traverseSuggestions();}if(enablePredictiveSuggestions){var predictiveSuggestions=getPredictiveSuggestions({suggestions:suggestionsList,currentValue:currentValue,wordsToShowAfterHighlight:wordsToShowAfterHighlight});suggestionsList=predictiveSuggestions;}return suggestionsList;};exports.default=getSuggestions; |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.getDependentQueries=exports.extractPropsFromState=exports.getValidInterval=exports.getRSQuery=exports.hasPaginationSupport=exports.isComponentUsesLabelAsValue=exports.isSearchComponent=exports.isDRSRangeComponent=exports.getHistogramComponentID=exports.getInternalComponentID=exports.isInternalComponent=exports.getNormalizedField=exports.componentToTypeMap=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _componentToTypeMap;exports.flatReactProp=flatReactProp;var _xdate=require('xdate');var _xdate2=_interopRequireDefault(_xdate);var _constants=require('./constants');var _helper=require('./helper');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var componentToTypeMap=exports.componentToTypeMap=(_componentToTypeMap={},_defineProperty(_componentToTypeMap,_constants.componentTypes.reactiveList,_constants.queryTypes.search),_defineProperty(_componentToTypeMap,_constants.componentTypes.dataSearch,_constants.queryTypes.search),_defineProperty(_componentToTypeMap,_constants.componentTypes.categorySearch,_constants.queryTypes.search),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleDataList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleDropdownList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiDataList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiDropdownList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.tagCloud,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.toggleButton,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.numberBox,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.datePicker,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.dateRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.dynamicRangeSlider,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleDropdownRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiDropdownRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.rangeSlider,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.ratingsFilter,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.rangeInput,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.geoDistanceDropdown,_constants.queryTypes.geo),_defineProperty(_componentToTypeMap,_constants.componentTypes.geoDistanceSlider,_constants.queryTypes.geo),_defineProperty(_componentToTypeMap,_constants.componentTypes.reactiveMap,_constants.queryTypes.geo),_componentToTypeMap);var multiRangeComponents=[_constants.componentTypes.multiRange,_constants.componentTypes.multiDropdownRange];var dateRangeComponents=[_constants.componentTypes.dateRange,_constants.componentTypes.datePicker];var searchComponents=[_constants.componentTypes.categorySearch,_constants.componentTypes.dataSearch];var listComponentsWithPagination=[_constants.componentTypes.singleList,_constants.componentTypes.multiList,_constants.componentTypes.singleDropdownList,_constants.componentTypes.multiDropdownList];var getNormalizedField=exports.getNormalizedField=function getNormalizedField(field){if(field&&!Array.isArray(field)){return[field];}return field;};var isInternalComponent=exports.isInternalComponent=function isInternalComponent(){var componentID=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentID.endsWith('__internal');};var getInternalComponentID=exports.getInternalComponentID=function getInternalComponentID(){var componentID=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentID+'__internal';};var getHistogramComponentID=exports.getHistogramComponentID=function getHistogramComponentID(){var componentID=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentID+'__histogram__internal';};var isDRSRangeComponent=exports.isDRSRangeComponent=function isDRSRangeComponent(){var componentID=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentID.endsWith('__range__internal');};var isSearchComponent=exports.isSearchComponent=function isSearchComponent(){var componentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return searchComponents.includes(componentType);};var isComponentUsesLabelAsValue=exports.isComponentUsesLabelAsValue=function isComponentUsesLabelAsValue(){var componentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentType===_constants.componentTypes.multiDataList||componentType===_constants.componentTypes.singleDataList;};var hasPaginationSupport=exports.hasPaginationSupport=function hasPaginationSupport(){var componentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return listComponentsWithPagination.includes(componentType);};var getRSQuery=exports.getRSQuery=function getRSQuery(componentId,props){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;if(props&&componentId){var queryType=props.type?props.type:componentToTypeMap[props.componentType];if(!isSearchComponent(props.componentType)&&!props.dataField){return null;}return{id:componentId,type:queryType,dataField:getNormalizedField(props.dataField),execute:execute,react:props.react,highlight:props.highlight,highlightField:getNormalizedField(props.highlightField),fuzziness:props.fuzziness,searchOperators:props.searchOperators,includeFields:props.includeFields,excludeFields:props.excludeFields,size:props.size,aggregationSize:props.aggregationSize,from:props.from,queryFormat:props.queryFormat,sortBy:props.sortBy,fieldWeights:getNormalizedField(props.fieldWeights),includeNullValues:props.includeNullValues,aggregationField:props.aggregationField||undefined,categoryField:props.categoryField||undefined,missingLabel:props.missingLabel||undefined,showMissing:props.showMissing,nestedField:props.nestedField||undefined,interval:props.interval,customHighlight:props.customHighlight,customQuery:props.customQuery,defaultQuery:props.defaultQuery,value:props.value,categoryValue:props.categoryValue||undefined,after:props.after||undefined,aggregations:props.aggregations||undefined,enableSynonyms:props.enableSynonyms,selectAllLabel:props.selectAllLabel,pagination:props.pagination,queryString:props.queryString};}return null;};var getValidInterval=exports.getValidInterval=function getValidInterval(interval){var range=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var min=Math.ceil((range.end-range.start)/100)||1;if(!interval){return min;}else if(interval<min){return min;}return interval;};var extractPropsFromState=exports.extractPropsFromState=function extractPropsFromState(store,component,customOptions){var componentProps=store.props[component];if(!componentProps){return null;}var queryType=componentToTypeMap[componentProps.componentType];var calcValues=store.selectedValues[component]||store.internalValues[component];var value=calcValues!==undefined&&calcValues!==null?calcValues.value:undefined;var queryFormat=componentProps.queryFormat;var interval=componentProps.interval;var type=componentToTypeMap[componentProps.componentType];var dataField=componentProps.dataField;var aggregations=void 0;var pagination=void 0;var from=componentProps.from;if(queryType===_constants.queryTypes.term){if(componentProps.showLoadMore&&hasPaginationSupport(componentProps.componentType)){pagination=true;}if(value!=null&&typeof value==='object'&&value.value){value=value.value;}else if(Array.isArray(value)){var parsedValue=[];value.forEach(function(val){if(val!=null&&typeof val==='object'&&val.value){parsedValue.push(val.value);}else{parsedValue.push(val);}});value=parsedValue;}}if(queryType===_constants.queryTypes.range){if(Array.isArray(value)){if(multiRangeComponents.includes(componentProps.componentType)){value=value.map(function(_ref){var start=_ref.start,end=_ref.end;return{start:start,end:end};});}else{value={start:value[0],end:value[1]};}}else if(componentProps.showHistogram){var internalComponentID=getInternalComponentID(component);var internalComponentValue=store.internalValues[internalComponentID];if(!internalComponentValue){var histogramComponentID=getHistogramComponentID(component);internalComponentValue=store.internalValues[histogramComponentID];}if(internalComponentValue&&Array.isArray(internalComponentValue.value)){value={start:internalComponentValue.value[0],end:internalComponentValue.value[1]};interval=getValidInterval(interval,value);}}if(isDRSRangeComponent(component)){aggregations=['min','max'];}else if(componentProps.showHistogram){aggregations=['histogram'];}if(dateRangeComponents.includes(componentProps.componentType)){queryFormat='or';if(value){if(typeof value==='string'){value={start:(0,_helper.formatDate)(new _xdate2.default(value).addHours(-24),componentProps),end:(0,_helper.formatDate)(new _xdate2.default(value),componentProps)};}else if(Array.isArray(value)){value=value.map(function(val){return{start:(0,_helper.formatDate)(new _xdate2.default(val).addHours(-24),componentProps),end:(0,_helper.formatDate)(new _xdate2.default(val),componentProps)};});}}}}if(queryType===_constants.queryTypes.geo){value=undefined;if(calcValues&&calcValues.meta){if(calcValues.meta.distance&&calcValues.meta.coordinates){value={distance:calcValues.meta.distance,location:calcValues.meta.coordinates};if(componentProps.unit){value.unit=componentProps.unit;}}if(calcValues.meta.mapBoxBounds&&calcValues.meta.mapBoxBounds.top_left&&calcValues.meta.mapBoxBounds.bottom_right){value={geoBoundingBox:{topLeft:calcValues.meta.mapBoxBounds.top_left[1]+', '+calcValues.meta.mapBoxBounds.top_left[0],bottomRight:calcValues.meta.mapBoxBounds.bottom_right[1]+', '+calcValues.meta.mapBoxBounds.bottom_right[0]}};}}}if(componentProps.componentType===_constants.componentTypes.numberBox){if(queryFormat==='exact'){type='term';}else{type='range';if(queryFormat==='lte'){value={end:value,boost:2.0};}else{value={start:value,boost:2.0};}}queryFormat='or';}if(componentProps.componentType===_constants.componentTypes.reactiveComponent){type='term';dataField='reactive_component_field';value=undefined;}if(isSearchComponent(componentProps.componentType)&&!value){value='';}if(isComponentUsesLabelAsValue(componentProps.componentType)){var data=componentProps.data;var absValue=[];if(value&&Array.isArray(value)){absValue=value;}else if(value&&typeof value==='string'){absValue=[value];}var normalizedValue=[];if(absValue.length){if(data&&Array.isArray(data)){absValue.forEach(function(val){var dataItem=data.find(function(o){return o.label===val;});if(dataItem&&dataItem.value){normalizedValue.push(dataItem.value);}});}}if(normalizedValue.length){value=normalizedValue;}else{value=undefined;}}if(componentProps.componentType===_constants.componentTypes.reactiveList){if(value>0){from=(value-1)*(componentProps.size||10);}value=undefined;}return _extends({},componentProps,{dataField:dataField,queryFormat:queryFormat,type:type,aggregations:aggregations,interval:interval,react:store.dependencyTree?store.dependencyTree[component]:undefined,customQuery:store.customQueries?store.customQueries[component]:undefined,defaultQuery:store.defaultQueries?store.defaultQueries[component]:undefined,customHighlight:store.customHighlightOptions?store.customHighlightOptions[component]:undefined,categoryValue:store.internalValues[component]?store.internalValues[component].category:undefined,value:value,pagination:pagination,from:from},customOptions);};function flatReactProp(reactProp,componentID){var flattenReact=[];var flatReact=function flatReact(react){if(react&&Object.keys(react)){Object.keys(react).forEach(function(r){if(react[r]){if(typeof react[r]==='string'){flattenReact=[].concat(_toConsumableArray(flattenReact),[react[r]]);}else if(Array.isArray(react[r])){flattenReact=[].concat(_toConsumableArray(flattenReact),_toConsumableArray(react[r]));}else if(typeof react[r]==='object'){flatReact(react[r]);}}});}};flatReact(reactProp);flattenReact=flattenReact.filter(function(react){return react!==componentID;});return flattenReact;}var getDependentQueries=exports.getDependentQueries=function getDependentQueries(store,componentID){var orderOfQueries=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var finalQuery={};var react=flatReactProp(store.dependencyTree[componentID],componentID);react.forEach(function(component){var componentProps=store.props[component];var shouldAddInternalQuery=componentProps?isSearchComponent(componentProps.componentType):null;var customQuery=store.customQueries[component];if(!isInternalComponent(component)||shouldAddInternalQuery){var calcValues=store.selectedValues[component]||store.internalValues[component];if((calcValues||customQuery)&&!finalQuery[component]){var execute=false;if(Array.isArray(orderOfQueries)&&orderOfQueries.includes(component)){execute=true;}var dependentQuery=getRSQuery(component,extractPropsFromState(store,component),execute);if(dependentQuery){finalQuery[component]=dependentQuery;}}}});return finalQuery;}; | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.getDependentQueries=exports.extractPropsFromState=exports.getValidInterval=exports.getRSQuery=exports.hasPaginationSupport=exports.isComponentUsesLabelAsValue=exports.isSearchComponent=exports.isDRSRangeComponent=exports.getHistogramComponentID=exports.getInternalComponentID=exports.isInternalComponent=exports.getNormalizedField=exports.componentToTypeMap=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _componentToTypeMap;exports.flatReactProp=flatReactProp;var _xdate=require('xdate');var _xdate2=_interopRequireDefault(_xdate);var _constants=require('./constants');var _helper=require('./helper');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var componentToTypeMap=exports.componentToTypeMap=(_componentToTypeMap={},_defineProperty(_componentToTypeMap,_constants.componentTypes.reactiveList,_constants.queryTypes.search),_defineProperty(_componentToTypeMap,_constants.componentTypes.dataSearch,_constants.queryTypes.search),_defineProperty(_componentToTypeMap,_constants.componentTypes.categorySearch,_constants.queryTypes.search),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleDataList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleDropdownList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiDataList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiDropdownList,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.tagCloud,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.toggleButton,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.numberBox,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.datePicker,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.dateRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.dynamicRangeSlider,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleDropdownRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiDropdownRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.singleRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.multiRange,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.rangeSlider,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.ratingsFilter,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.rangeInput,_constants.queryTypes.range),_defineProperty(_componentToTypeMap,_constants.componentTypes.geoDistanceDropdown,_constants.queryTypes.geo),_defineProperty(_componentToTypeMap,_constants.componentTypes.geoDistanceSlider,_constants.queryTypes.geo),_defineProperty(_componentToTypeMap,_constants.componentTypes.reactiveMap,_constants.queryTypes.geo),_componentToTypeMap);var multiRangeComponents=[_constants.componentTypes.multiRange,_constants.componentTypes.multiDropdownRange];var dateRangeComponents=[_constants.componentTypes.dateRange,_constants.componentTypes.datePicker];var searchComponents=[_constants.componentTypes.categorySearch,_constants.componentTypes.dataSearch];var listComponentsWithPagination=[_constants.componentTypes.singleList,_constants.componentTypes.multiList,_constants.componentTypes.singleDropdownList,_constants.componentTypes.multiDropdownList];var getNormalizedField=exports.getNormalizedField=function getNormalizedField(field){if(field&&!Array.isArray(field)){return[field];}return field;};var isInternalComponent=exports.isInternalComponent=function isInternalComponent(){var componentID=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentID.endsWith('__internal');};var getInternalComponentID=exports.getInternalComponentID=function getInternalComponentID(){var componentID=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentID+'__internal';};var getHistogramComponentID=exports.getHistogramComponentID=function getHistogramComponentID(){var componentID=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentID+'__histogram__internal';};var isDRSRangeComponent=exports.isDRSRangeComponent=function isDRSRangeComponent(){var componentID=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentID.endsWith('__range__internal');};var isSearchComponent=exports.isSearchComponent=function isSearchComponent(){var componentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return searchComponents.includes(componentType);};var isComponentUsesLabelAsValue=exports.isComponentUsesLabelAsValue=function isComponentUsesLabelAsValue(){var componentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentType===_constants.componentTypes.multiDataList||componentType===_constants.componentTypes.singleDataList;};var hasPaginationSupport=exports.hasPaginationSupport=function hasPaginationSupport(){var componentType=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return listComponentsWithPagination.includes(componentType);};var getRSQuery=exports.getRSQuery=function getRSQuery(componentId,props){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;if(props&&componentId){var queryType=props.type?props.type:componentToTypeMap[props.componentType];if(!isSearchComponent(props.componentType)&&!props.dataField){return null;}return{id:componentId,type:queryType,dataField:getNormalizedField(props.dataField),execute:execute,react:props.react,highlight:props.highlight,highlightField:getNormalizedField(props.highlightField),fuzziness:props.fuzziness,searchOperators:props.searchOperators,includeFields:props.includeFields,excludeFields:props.excludeFields,size:props.size,aggregationSize:props.aggregationSize,from:props.from,queryFormat:props.queryFormat,sortBy:props.sortBy,fieldWeights:getNormalizedField(props.fieldWeights),includeNullValues:props.includeNullValues,aggregationField:props.aggregationField||undefined,categoryField:props.categoryField||undefined,missingLabel:props.missingLabel||undefined,showMissing:props.showMissing,nestedField:props.nestedField||undefined,interval:props.interval,customHighlight:props.customHighlight,customQuery:props.customQuery,defaultQuery:props.defaultQuery,value:props.value,categoryValue:props.categoryValue||undefined,after:props.after||undefined,aggregations:props.aggregations||undefined,enableSynonyms:props.enableSynonyms,selectAllLabel:props.selectAllLabel,pagination:props.pagination,queryString:props.queryString,distinctField:props.distinctField,distinctFieldConfig:props.distinctFieldConfig};}return null;};var getValidInterval=exports.getValidInterval=function getValidInterval(interval){var range=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var min=Math.ceil((range.end-range.start)/100)||1;if(!interval){return min;}else if(interval<min){return min;}return interval;};var extractPropsFromState=exports.extractPropsFromState=function extractPropsFromState(store,component,customOptions){var componentProps=store.props[component];if(!componentProps){return null;}var queryType=componentToTypeMap[componentProps.componentType];var calcValues=store.selectedValues[component]||store.internalValues[component];var value=calcValues!==undefined&&calcValues!==null?calcValues.value:undefined;var queryFormat=componentProps.queryFormat;var interval=componentProps.interval;var type=componentToTypeMap[componentProps.componentType];var dataField=componentProps.dataField;var aggregations=void 0;var pagination=void 0;var from=componentProps.from;if(queryType===_constants.queryTypes.term){if(componentProps.showLoadMore&&hasPaginationSupport(componentProps.componentType)){pagination=true;}if(value!=null&&typeof value==='object'&&value.value){value=value.value;}else if(Array.isArray(value)){var parsedValue=[];value.forEach(function(val){if(val!=null&&typeof val==='object'&&val.value){parsedValue.push(val.value);}else{parsedValue.push(val);}});value=parsedValue;}}if(queryType===_constants.queryTypes.range){if(Array.isArray(value)){if(multiRangeComponents.includes(componentProps.componentType)){value=value.map(function(_ref){var start=_ref.start,end=_ref.end;return{start:start,end:end};});}else{value={start:value[0],end:value[1]};}}else if(componentProps.showHistogram){var internalComponentID=getInternalComponentID(component);var internalComponentValue=store.internalValues[internalComponentID];if(!internalComponentValue){var histogramComponentID=getHistogramComponentID(component);internalComponentValue=store.internalValues[histogramComponentID];}if(internalComponentValue&&Array.isArray(internalComponentValue.value)){value={start:internalComponentValue.value[0],end:internalComponentValue.value[1]};interval=getValidInterval(interval,value);}}if(isDRSRangeComponent(component)){aggregations=['min','max'];}else if(componentProps.showHistogram){aggregations=['histogram'];}if(dateRangeComponents.includes(componentProps.componentType)){queryFormat='or';if(value){if(typeof value==='string'){value={start:(0,_helper.formatDate)(new _xdate2.default(value).addHours(-24),componentProps),end:(0,_helper.formatDate)(new _xdate2.default(value),componentProps)};}else if(Array.isArray(value)){value=value.map(function(val){return{start:(0,_helper.formatDate)(new _xdate2.default(val).addHours(-24),componentProps),end:(0,_helper.formatDate)(new _xdate2.default(val),componentProps)};});}}}}if(queryType===_constants.queryTypes.geo){value=undefined;if(calcValues&&calcValues.meta){if(calcValues.meta.distance&&calcValues.meta.coordinates){value={distance:calcValues.meta.distance,location:calcValues.meta.coordinates};if(componentProps.unit){value.unit=componentProps.unit;}}if(calcValues.meta.mapBoxBounds&&calcValues.meta.mapBoxBounds.top_left&&calcValues.meta.mapBoxBounds.bottom_right){value={geoBoundingBox:{topLeft:calcValues.meta.mapBoxBounds.top_left[1]+', '+calcValues.meta.mapBoxBounds.top_left[0],bottomRight:calcValues.meta.mapBoxBounds.bottom_right[1]+', '+calcValues.meta.mapBoxBounds.bottom_right[0]}};}}}if(componentProps.componentType===_constants.componentTypes.numberBox){if(queryFormat==='exact'){type='term';}else{type='range';if(queryFormat==='lte'){value={end:value,boost:2.0};}else{value={start:value,boost:2.0};}}queryFormat='or';}if(componentProps.componentType===_constants.componentTypes.reactiveComponent){type='term';dataField='reactive_component_field';value=undefined;}if(isSearchComponent(componentProps.componentType)&&!value){value='';}if(isComponentUsesLabelAsValue(componentProps.componentType)){var data=componentProps.data;var absValue=[];if(value&&Array.isArray(value)){absValue=value;}else if(value&&typeof value==='string'){absValue=[value];}var normalizedValue=[];if(absValue.length){if(data&&Array.isArray(data)){absValue.forEach(function(val){var dataItem=data.find(function(o){return o.label===val;});if(dataItem&&dataItem.value){normalizedValue.push(dataItem.value);}});}}if(normalizedValue.length){value=normalizedValue;}else{value=undefined;}}if(componentProps.componentType===_constants.componentTypes.reactiveList){if(value>0){from=(value-1)*(componentProps.size||10);}value=undefined;}return _extends({},componentProps,{dataField:dataField,queryFormat:queryFormat,type:type,aggregations:aggregations,interval:interval,react:store.dependencyTree?store.dependencyTree[component]:undefined,customQuery:store.customQueries?store.customQueries[component]:undefined,defaultQuery:store.defaultQueries?store.defaultQueries[component]:undefined,customHighlight:store.customHighlightOptions?store.customHighlightOptions[component]:undefined,categoryValue:store.internalValues[component]?store.internalValues[component].category:undefined,value:value,pagination:pagination,from:from},customOptions);};function flatReactProp(reactProp,componentID){var flattenReact=[];var flatReact=function flatReact(react){if(react&&Object.keys(react)){Object.keys(react).forEach(function(r){if(react[r]){if(typeof react[r]==='string'){flattenReact=[].concat(_toConsumableArray(flattenReact),[react[r]]);}else if(Array.isArray(react[r])){flattenReact=[].concat(_toConsumableArray(flattenReact),_toConsumableArray(react[r]));}else if(typeof react[r]==='object'){flatReact(react[r]);}}});}};flatReact(reactProp);flattenReact=flattenReact.filter(function(react){return react!==componentID;});return flattenReact;}var getDependentQueries=exports.getDependentQueries=function getDependentQueries(store,componentID){var orderOfQueries=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var finalQuery={};var react=flatReactProp(store.dependencyTree[componentID],componentID);react.forEach(function(component){var componentProps=store.props[component];var shouldAddInternalQuery=componentProps?isSearchComponent(componentProps.componentType):null;var customQuery=store.customQueries[component];if(!isInternalComponent(component)||shouldAddInternalQuery){var calcValues=store.selectedValues[component]||store.internalValues[component];if((calcValues||customQuery)&&!finalQuery[component]){var execute=false;if(Array.isArray(orderOfQueries)&&orderOfQueries.includes(component)){execute=true;}var dependentQuery=getRSQuery(component,extractPropsFromState(store,component),execute);if(dependentQuery){finalQuery[component]=dependentQuery;}}}});return finalQuery;}; |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "9.10.2", | ||
"version": "9.11.0", | ||
"description": "Core architecture of reactive UI libraries", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
162859