@appbaseio/reactivecore
Advanced tools
Comparing version 10.2.0-alpha.3 to 10.2.0-alpha.4
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.transformValueToComponentStateFormat=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 _dayjs=require('dayjs');var _dayjs2=_interopRequireDefault(_dayjs);var _constants=require('./constants');var _dateFormats=require('./dateFormats');var _dateFormats2=_interopRequireDefault(_dateFormats);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.searchBox,_constants.queryTypes.suggestion),_defineProperty(_componentToTypeMap,_constants.componentTypes.AIAnswer,_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.reactiveChart,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.treeList,_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,_constants.componentTypes.searchBox];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||componentType===_constants.componentTypes.tabDataList;};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(props.componentType!==_constants.componentTypes.AIAnswer&&!isSearchComponent(props.componentType)&&!props.dataField){return null;}var endpoint=void 0;var compoundClause=props.compoundClause;if(props.endpoint instanceof Object){endpoint=props.endpoint;}var featuredSuggestionsProps={enableFeaturedSuggestions:props.enableFeaturedSuggestions,featuredSuggestionsConfig:props.featuredSuggestionsConfig};var faqSuggestionsProps={enableFAQSuggestions:props.enableFAQSuggestions,FAQSuggestionsConfig:props.FAQSuggestionsConfig};if(props.enableFAQSuggestions&&!props.searchboxId){faqSuggestionsProps={};console.error('Reactivesearch Error: You should also pass a searchboxId when passing enableFAQSuggestions as true.\nRefer to Searchbox component documentation specific to frontend frameworks.\n\nReact(https://docs.reactivesearch.io/docs/reactivesearch/react/search/searchbox/)\n\nVue(https://docs.reactivesearch.io/docs/reactivesearch/vue/search/SearchBox/).');}if(props.enableFeaturedSuggestions&&!props.searchboxId){featuredSuggestionsProps={};console.error('Reactivesearch Error: You should also pass a searchboxId when passing enableFeaturedSuggestions.\nRefer to Searchbox component documentation specific to frontend frameworks.\n\nReact(https://docs.reactivesearch.io/docs/reactivesearch/react/search/searchbox/)\n\nVue(https://docs.reactivesearch.io/docs/reactivesearch/vue/search/SearchBox/).');}if(compoundClause&&!['filter','must'].includes(compoundClause)){console.error("Reactivesearch Error: Invalid prop supplied - compoundClause. Prop can be one of ['filter', 'must']");compoundClause=undefined;}return _extends({id:componentId,type:queryType||_constants.queryTypes.search,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||undefined,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,highlightConfig:props.customHighlight||props.highlightConfig,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,index:props.index,compoundClause:compoundClause},queryType===_constants.queryTypes.suggestion?_extends({enablePopularSuggestions:props.enablePopularSuggestions,enableEndpointSuggestions:props.enableEndpointSuggestions,enableRecentSuggestions:props.enableRecentSuggestions,popularSuggestionsConfig:props.popularSuggestionsConfig,recentSuggestionsConfig:props.recentSuggestionsConfig,applyStopwords:props.applyStopwords,customStopwords:props.customStopwords,enablePredictiveSuggestions:props.enablePredictiveSuggestions,indexSuggestionsConfig:props.indexSuggestionsConfig,enableDocumentSuggestions:props.enableDocumentSuggestions,showDistinctSuggestions:props.showDistinctSuggestions,documentSuggestionsConfig:props.enableDocumentSuggestions?props.documentSuggestionsConfig:undefined},featuredSuggestionsProps,faqSuggestionsProps,{enableIndexSuggestions:props.enableIndexSuggestions},props.searchboxId?{searchboxId:props.searchboxId}:{}):{},{calendarInterval:props.calendarInterval,endpoint:endpoint,range:props.range},queryType!==_constants.queryTypes.suggestion&&props.enableAI&&execute?_extends({enableAI:true},props.AIConfig?{AIConfig:props.AIConfig}:{},{execute:true}):{},queryType!==_constants.queryTypes.suggestion?{vectorDataField:props.vectorDataField,imageValue:props.imageValue}:{});}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=componentProps.type?componentProps.type:componentToTypeMap[componentProps.componentType];var calcValues=store.selectedValues[component];var value=calcValues!==undefined&&calcValues!==null?calcValues.value:undefined;var queryFormat=componentProps.queryFormat;var calendarInterval=void 0;var interval=componentProps.interval;var type=queryType;var dataField=componentProps.dataField;var aggregations=componentProps.aggregations;var pagination=void 0;var from=componentProps.from;var range=void 0;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]};}}if(isDRSRangeComponent(component)){aggregations=['min','max'];}else if(componentProps.showHistogram){aggregations=['histogram'];}if(componentProps.componentType===_constants.componentTypes.dynamicRangeSlider||componentProps.componentType===_constants.componentTypes.rangeSlider){calendarInterval=Object.keys(_dateFormats2.default).includes(queryFormat)?componentProps.calendarInterval:undefined;if(value){if((0,_helper.isValidDateRangeQueryFormat)(componentProps.queryFormat)){value={start:(0,_helper.formatDate)((0,_dayjs2.default)(new Date(value.start)),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(new Date(value.end)),componentProps)};}else{value={start:parseFloat(value.start),end:parseFloat(value.end)};}}var rangeValue=void 0;if(componentProps.componentType===_constants.componentTypes.dynamicRangeSlider){rangeValue=store.aggregations[component+'__range__internal'];if(componentProps.nestedField){rangeValue=rangeValue&&store.aggregations[component+'__range__internal'][componentProps.nestedField].min?{start:store.aggregations[component+'__range__internal'][componentProps.nestedField].min.value,end:store.aggregations[component+'__range__internal'][componentProps.nestedField].max.value}:null;}else{rangeValue=rangeValue&&store.aggregations[component+'__range__internal'].min&&store.aggregations[component+'__range__internal'].min.value?{start:store.aggregations[component+'__range__internal'].min.value,end:store.aggregations[component+'__range__internal'].max.value}:null;}}else{rangeValue=componentProps.range;}if(rangeValue){if((0,_helper.isValidDateRangeQueryFormat)(componentProps.queryFormat)){range={start:(0,_helper.formatDate)((0,_dayjs2.default)(rangeValue.start),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(rangeValue.end),componentProps)};}else{range={start:parseFloat(rangeValue.start),end:parseFloat(rangeValue.end)};}}}if(dateRangeComponents.includes(componentProps.componentType)){if(value){if((0,_helper.isValidDateRangeQueryFormat)(componentProps.queryFormat)){if(typeof value==='string'){value={start:(0,_helper.formatDate)((0,_dayjs2.default)(value).subtract(24,'hour'),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(value),componentProps)};}else if(Array.isArray(value)){value=value.map(function(val){return{start:(0,_helper.formatDate)((0,_dayjs2.default)(val).subtract(24,'hour'),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(val),componentProps)};});}else{value={start:(0,_helper.formatDate)((0,_dayjs2.default)(value.start).subtract(24,'hour'),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(value.end),componentProps)};}}}}}if(queryType===_constants.queryTypes.geo){value=undefined;var geoCalcValues=store.selectedValues[component]||store.internalValues[component]||store.internalValues[getInternalComponentID(component)];if(geoCalcValues&&geoCalcValues.meta){if(geoCalcValues.meta.distance&&geoCalcValues.meta.coordinates){value={distance:geoCalcValues.meta.distance,location:geoCalcValues.meta.coordinates};if(componentProps.unit){value.unit=componentProps.unit;}}if(geoCalcValues.meta.mapBoxBounds&&geoCalcValues.meta.mapBoxBounds.top_left&&geoCalcValues.meta.mapBoxBounds.bottom_right){value={geoBoundingBox:{topLeft:geoCalcValues.meta.mapBoxBounds.top_left[1]+', '+geoCalcValues.meta.mapBoxBounds.top_left[0],bottomRight:geoCalcValues.meta.mapBoxBounds.bottom_right[1]+', '+geoCalcValues.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,selectAllLabel=componentProps.selectAllLabel;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(selectAllLabel&&absValue.length&&absValue.includes(selectAllLabel)){normalizedValue=absValue;}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;}var queryValue=value||undefined;if(componentProps.componentType===_constants.componentTypes.searchBox){if(Array.isArray(queryValue)){queryValue=undefined;}}var endpoint=void 0;if(componentProps.endpoint instanceof Object){endpoint=_extends({},endpoint||{},componentProps.endpoint);}return _extends({},componentProps,{endpoint:endpoint,calendarInterval:calendarInterval,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:queryValue,pagination:pagination,from:from,range:range},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(componentObject){var component=componentObject;var customQuery=store.customQueries[component];if(!isInternalComponent(component)){var calcValues=store.selectedValues[component]||store.internalValues[component];var imageValue=calcValues&&calcValues.meta&&calcValues.meta.imageValue;if((calcValues&&(calcValues.value||imageValue)||customQuery)&&!finalQuery[component]){var execute=false;var componentProps=store.props[component];if(Array.isArray(orderOfQueries)&&orderOfQueries.includes(component)&&!(componentProps.componentType===_constants.componentTypes.searchBox&&(componentProps.enableAI||componentProps.autosuggest===false))){execute=true;}var dependentQuery=getRSQuery(component,extractPropsFromState(store,component,_extends({},componentProps&&_extends({},componentProps.componentType===_constants.componentTypes.searchBox?_extends({},execute===false?{type:_constants.queryTypes.search}:{},calcValues.category?{categoryValue:calcValues.category}:{categoryValue:undefined},calcValues.value?{value:calcValues.value}:{},imageValue?{imageValue:imageValue}:{}):{},componentProps.componentType===_constants.componentTypes.categorySearch?_extends({},calcValues.category?{categoryValue:calcValues.category}:{categoryValue:undefined}):{}))),execute);if(dependentQuery){finalQuery[component]=dependentQuery;}}}});return finalQuery;};var transformValueToComponentStateFormat=exports.transformValueToComponentStateFormat=function transformValueToComponentStateFormat(value,componentProps){var componentType=componentProps.componentType,data=componentProps.data,queryFormat=componentProps.queryFormat;var transformedValue=value;var meta={};if(value){switch(componentType){case _constants.componentTypes.singleDataList:case _constants.componentTypes.tabDataList:transformedValue='';if(Array.isArray(value)&&typeof value[0]==='string'){transformedValue=value[0];}else if(typeof value==='object'&&value.label){transformedValue=value.label;}else{transformedValue=value;}break;case _constants.componentTypes.multiDataList:transformedValue=[];if(Array.isArray(value)){value.forEach(function(valObj){if(typeof valObj==='object'&&(valObj.label||valObj.value)){transformedValue.push(valObj.label||valObj.value);}else if(typeof valObj==='string'){transformedValue.push(valObj);}});}break;case _constants.componentTypes.toggleButton:transformedValue=[];if(Array.isArray(value)){value.forEach(function(valObj){if(typeof valObj==='object'&&valObj.label&&valObj.value){transformedValue.push(valObj);}else if(typeof valObj==='string'){var findDataObj=data.find(function(item){return item.label.trim()===valObj.trim()||item.value.trim()===valObj.trim();});transformedValue.push(findDataObj);}});}else if(typeof value==='object'&&value.label&&value.value){transformedValue=value.value;}else if(typeof value==='string'){var findDataObj=data.find(function(item){return item.label.trim()===value.trim()||item.value.trim()===value.trim();});transformedValue=findDataObj.value;}break;case _constants.componentTypes.singleRange:case _constants.componentTypes.singleDropdownRange:transformedValue={};if(!Array.isArray(value)&&typeof value==='object'){transformedValue=_extends({},value);}else if(typeof value==='string'){var _findDataObj=data.find(function(item){return item.label.trim()===value.trim();});transformedValue=_extends({},_findDataObj);}break;case _constants.componentTypes.multiDropdownRange:case _constants.componentTypes.multiRange:transformedValue=[];if(Array.isArray(value)){value.forEach(function(valObj){if(typeof valObj==='object'&&typeof valObj.start==='number'&&typeof valObj.end==='number'){var _findDataObj2=_extends({},valObj);if(!_findDataObj2.label){_findDataObj2=data.find(function(item){return item.start===valObj.start&&item.end===valObj.end;});}transformedValue.push(_findDataObj2);}else if(typeof valObj==='string'){var _findDataObj3=data.find(function(item){return item.label.trim()===valObj.trim();});transformedValue.push(_findDataObj3);}});}else if(typeof value==='string'){var _findDataObj4=data.find(function(item){return item.label.trim()===value.trim();});transformedValue.push(_findDataObj4);}break;case _constants.componentTypes.rangeSlider:case _constants.componentTypes.ratingsFilter:case _constants.componentTypes.dynamicRangeSlider:case _constants.componentTypes.reactiveChart:transformedValue=[];if(queryFormat){if(Array.isArray(value)){transformedValue=value.map(function(item){return(0,_helper.formatDate)((0,_dayjs2.default)(item),componentProps);});}else if(typeof value==='object'){transformedValue=[(0,_helper.formatDate)((0,_dayjs2.default)(value.start),componentProps),(0,_helper.formatDate)((0,_dayjs2.default)(value.end),componentProps)];}}else if(Array.isArray(value)){transformedValue=[].concat(_toConsumableArray(value));}else if(typeof value==='object'){transformedValue=[value.start,value.end];}else{transformedValue=value;}break;case _constants.componentTypes.numberBox:transformedValue=[];if(!Array.isArray(value)&&typeof value==='object'){transformedValue=value.start;}else if(typeof value==='number'){transformedValue=value;}break;case _constants.componentTypes.datePicker:transformedValue='';if(typeof value!=='object'){transformedValue=(0,_dayjs2.default)(value).format('YYYY-MM-DD');}else if(value.end){transformedValue=(0,_dayjs2.default)(value.end).format('YYYY-MM-DD');}else if(value.start){transformedValue=(0,_dayjs2.default)(value.start).add(24,'hour').format('YYYY-MM-DD');}break;case _constants.componentTypes.dateRange:transformedValue=[];if(Array.isArray(value)){transformedValue=value.map(function(t){return(0,_dayjs2.default)(t).format('YYYY-MM-DD');});}else if(typeof value==='object'){transformedValue=[(0,_dayjs2.default)(value.start).format('YYYY-MM-DD'),(0,_dayjs2.default)(value.end).format('YYYY-MM-DD')];}break;case _constants.componentTypes.categorySearch:transformedValue='';if(typeof value==='object'){transformedValue=value.value;if(value.category!==undefined){meta.category=value.category;}}else if(typeof value==='string'){transformedValue=value;}break;default:break;}}return{value:transformedValue,meta:meta};}; | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.transformValueToComponentStateFormat=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 _dayjs=require('dayjs');var _dayjs2=_interopRequireDefault(_dayjs);var _constants=require('./constants');var _dateFormats=require('./dateFormats');var _dateFormats2=_interopRequireDefault(_dateFormats);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.searchBox,_constants.queryTypes.suggestion),_defineProperty(_componentToTypeMap,_constants.componentTypes.AIAnswer,_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.reactiveChart,_constants.queryTypes.term),_defineProperty(_componentToTypeMap,_constants.componentTypes.treeList,_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,_constants.componentTypes.searchBox];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||componentType===_constants.componentTypes.tabDataList;};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(props.componentType!==_constants.componentTypes.AIAnswer&&!isSearchComponent(props.componentType)&&!props.dataField){return null;}var endpoint=void 0;var compoundClause=props.compoundClause;if(props.endpoint instanceof Object){endpoint=props.endpoint;}var featuredSuggestionsProps={enableFeaturedSuggestions:props.enableFeaturedSuggestions,featuredSuggestionsConfig:props.featuredSuggestionsConfig};var faqSuggestionsProps={enableFAQSuggestions:props.enableFAQSuggestions,FAQSuggestionsConfig:props.FAQSuggestionsConfig};if(props.enableFAQSuggestions&&!props.searchboxId){faqSuggestionsProps={};console.error('Reactivesearch Error: You should also pass a searchboxId when passing enableFAQSuggestions as true.\nRefer to Searchbox component documentation specific to frontend frameworks.\n\nReact(https://docs.reactivesearch.io/docs/reactivesearch/react/search/searchbox/)\n\nVue(https://docs.reactivesearch.io/docs/reactivesearch/vue/search/SearchBox/).');}if(props.enableFeaturedSuggestions&&!props.searchboxId){featuredSuggestionsProps={};console.error('Reactivesearch Error: You should also pass a searchboxId when passing enableFeaturedSuggestions.\nRefer to Searchbox component documentation specific to frontend frameworks.\n\nReact(https://docs.reactivesearch.io/docs/reactivesearch/react/search/searchbox/)\n\nVue(https://docs.reactivesearch.io/docs/reactivesearch/vue/search/SearchBox/).');}if(compoundClause&&!['filter','must'].includes(compoundClause)){console.error("Reactivesearch Error: Invalid prop supplied - compoundClause. Prop can be one of ['filter', 'must']");compoundClause=undefined;}return _extends({id:componentId,type:queryType||_constants.queryTypes.search,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||undefined,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,highlightConfig:props.customHighlight||props.highlightConfig,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,index:props.index,compoundClause:compoundClause},queryType===_constants.queryTypes.suggestion?_extends({enablePopularSuggestions:props.enablePopularSuggestions,enableEndpointSuggestions:props.enableEndpointSuggestions,enableRecentSuggestions:props.enableRecentSuggestions,popularSuggestionsConfig:props.popularSuggestionsConfig,recentSuggestionsConfig:props.recentSuggestionsConfig,applyStopwords:props.applyStopwords,customStopwords:props.customStopwords,enablePredictiveSuggestions:props.enablePredictiveSuggestions,indexSuggestionsConfig:props.indexSuggestionsConfig,enableDocumentSuggestions:props.enableDocumentSuggestions,showDistinctSuggestions:props.showDistinctSuggestions,documentSuggestionsConfig:props.enableDocumentSuggestions?props.documentSuggestionsConfig:undefined},featuredSuggestionsProps,faqSuggestionsProps,{enableIndexSuggestions:props.enableIndexSuggestions},props.searchboxId?{searchboxId:props.searchboxId}:{}):{},{calendarInterval:props.calendarInterval,endpoint:endpoint,range:props.range},queryType!==_constants.queryTypes.suggestion&&props.enableAI&&execute?_extends({enableAI:true},props.AIConfig?{AIConfig:props.AIConfig}:{},{execute:true}):{},queryType!==_constants.queryTypes.suggestion?{vectorDataField:props.vectorDataField||undefined,imageValue:props.imageValue||undefined}:{});}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=componentProps.type?componentProps.type:componentToTypeMap[componentProps.componentType];var calcValues=store.selectedValues[component];var value=calcValues!==undefined&&calcValues!==null?calcValues.value:undefined;var queryFormat=componentProps.queryFormat;var calendarInterval=void 0;var interval=componentProps.interval;var type=queryType;var dataField=componentProps.dataField;var aggregations=componentProps.aggregations;var pagination=void 0;var from=componentProps.from;var range=void 0;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]};}}if(isDRSRangeComponent(component)){aggregations=['min','max'];}else if(componentProps.showHistogram){aggregations=['histogram'];}if(componentProps.componentType===_constants.componentTypes.dynamicRangeSlider||componentProps.componentType===_constants.componentTypes.rangeSlider){calendarInterval=Object.keys(_dateFormats2.default).includes(queryFormat)?componentProps.calendarInterval:undefined;if(value){if((0,_helper.isValidDateRangeQueryFormat)(componentProps.queryFormat)){value={start:(0,_helper.formatDate)((0,_dayjs2.default)(new Date(value.start)),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(new Date(value.end)),componentProps)};}else{value={start:parseFloat(value.start),end:parseFloat(value.end)};}}var rangeValue=void 0;if(componentProps.componentType===_constants.componentTypes.dynamicRangeSlider){rangeValue=store.aggregations[component+'__range__internal'];if(componentProps.nestedField){rangeValue=rangeValue&&store.aggregations[component+'__range__internal'][componentProps.nestedField].min?{start:store.aggregations[component+'__range__internal'][componentProps.nestedField].min.value,end:store.aggregations[component+'__range__internal'][componentProps.nestedField].max.value}:null;}else{rangeValue=rangeValue&&store.aggregations[component+'__range__internal'].min&&store.aggregations[component+'__range__internal'].min.value?{start:store.aggregations[component+'__range__internal'].min.value,end:store.aggregations[component+'__range__internal'].max.value}:null;}}else{rangeValue=componentProps.range;}if(rangeValue){if((0,_helper.isValidDateRangeQueryFormat)(componentProps.queryFormat)){range={start:(0,_helper.formatDate)((0,_dayjs2.default)(rangeValue.start),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(rangeValue.end),componentProps)};}else{range={start:parseFloat(rangeValue.start),end:parseFloat(rangeValue.end)};}}}if(dateRangeComponents.includes(componentProps.componentType)){if(value){if((0,_helper.isValidDateRangeQueryFormat)(componentProps.queryFormat)){if(typeof value==='string'){value={start:(0,_helper.formatDate)((0,_dayjs2.default)(value).subtract(24,'hour'),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(value),componentProps)};}else if(Array.isArray(value)){value=value.map(function(val){return{start:(0,_helper.formatDate)((0,_dayjs2.default)(val).subtract(24,'hour'),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(val),componentProps)};});}else{value={start:(0,_helper.formatDate)((0,_dayjs2.default)(value.start).subtract(24,'hour'),componentProps),end:(0,_helper.formatDate)((0,_dayjs2.default)(value.end),componentProps)};}}}}}if(queryType===_constants.queryTypes.geo){value=undefined;var geoCalcValues=store.selectedValues[component]||store.internalValues[component]||store.internalValues[getInternalComponentID(component)];if(geoCalcValues&&geoCalcValues.meta){if(geoCalcValues.meta.distance&&geoCalcValues.meta.coordinates){value={distance:geoCalcValues.meta.distance,location:geoCalcValues.meta.coordinates};if(componentProps.unit){value.unit=componentProps.unit;}}if(geoCalcValues.meta.mapBoxBounds&&geoCalcValues.meta.mapBoxBounds.top_left&&geoCalcValues.meta.mapBoxBounds.bottom_right){value={geoBoundingBox:{topLeft:geoCalcValues.meta.mapBoxBounds.top_left[1]+', '+geoCalcValues.meta.mapBoxBounds.top_left[0],bottomRight:geoCalcValues.meta.mapBoxBounds.bottom_right[1]+', '+geoCalcValues.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,selectAllLabel=componentProps.selectAllLabel;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(selectAllLabel&&absValue.length&&absValue.includes(selectAllLabel)){normalizedValue=absValue;}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;}var queryValue=value||undefined;if(componentProps.componentType===_constants.componentTypes.searchBox){if(Array.isArray(queryValue)){queryValue=undefined;}}var endpoint=void 0;if(componentProps.endpoint instanceof Object){endpoint=_extends({},endpoint||{},componentProps.endpoint);}return _extends({},componentProps,{endpoint:endpoint,calendarInterval:calendarInterval,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:queryValue,pagination:pagination,from:from,range:range},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(componentObject){var component=componentObject;var customQuery=store.customQueries[component];if(!isInternalComponent(component)){var calcValues=store.selectedValues[component]||store.internalValues[component];var imageValue=calcValues&&calcValues.meta&&calcValues.meta.imageValue;if((calcValues&&(calcValues.value||imageValue)||customQuery)&&!finalQuery[component]){var execute=false;var componentProps=store.props[component];if(Array.isArray(orderOfQueries)&&orderOfQueries.includes(component)&&!(componentProps.componentType===_constants.componentTypes.searchBox&&(componentProps.enableAI||componentProps.autosuggest===false))){execute=true;}var dependentQuery=getRSQuery(component,extractPropsFromState(store,component,_extends({},componentProps&&_extends({},componentProps.componentType===_constants.componentTypes.searchBox?_extends({},execute===false?{type:_constants.queryTypes.search}:{},calcValues.category?{categoryValue:calcValues.category}:{categoryValue:undefined},calcValues.value?{value:calcValues.value}:{},imageValue?{imageValue:imageValue}:{}):{},componentProps.componentType===_constants.componentTypes.categorySearch?_extends({},calcValues.category?{categoryValue:calcValues.category}:{categoryValue:undefined}):{}))),execute);if(dependentQuery){finalQuery[component]=dependentQuery;}}}});return finalQuery;};var transformValueToComponentStateFormat=exports.transformValueToComponentStateFormat=function transformValueToComponentStateFormat(value,componentProps){var componentType=componentProps.componentType,data=componentProps.data,queryFormat=componentProps.queryFormat;var transformedValue=value;var meta={};if(value){switch(componentType){case _constants.componentTypes.singleDataList:case _constants.componentTypes.tabDataList:transformedValue='';if(Array.isArray(value)&&typeof value[0]==='string'){transformedValue=value[0];}else if(typeof value==='object'&&value.label){transformedValue=value.label;}else{transformedValue=value;}break;case _constants.componentTypes.multiDataList:transformedValue=[];if(Array.isArray(value)){value.forEach(function(valObj){if(typeof valObj==='object'&&(valObj.label||valObj.value)){transformedValue.push(valObj.label||valObj.value);}else if(typeof valObj==='string'){transformedValue.push(valObj);}});}break;case _constants.componentTypes.toggleButton:transformedValue=[];if(Array.isArray(value)){value.forEach(function(valObj){if(typeof valObj==='object'&&valObj.label&&valObj.value){transformedValue.push(valObj);}else if(typeof valObj==='string'){var findDataObj=data.find(function(item){return item.label.trim()===valObj.trim()||item.value.trim()===valObj.trim();});transformedValue.push(findDataObj);}});}else if(typeof value==='object'&&value.label&&value.value){transformedValue=value.value;}else if(typeof value==='string'){var findDataObj=data.find(function(item){return item.label.trim()===value.trim()||item.value.trim()===value.trim();});transformedValue=findDataObj.value;}break;case _constants.componentTypes.singleRange:case _constants.componentTypes.singleDropdownRange:transformedValue={};if(!Array.isArray(value)&&typeof value==='object'){transformedValue=_extends({},value);}else if(typeof value==='string'){var _findDataObj=data.find(function(item){return item.label.trim()===value.trim();});transformedValue=_extends({},_findDataObj);}break;case _constants.componentTypes.multiDropdownRange:case _constants.componentTypes.multiRange:transformedValue=[];if(Array.isArray(value)){value.forEach(function(valObj){if(typeof valObj==='object'&&typeof valObj.start==='number'&&typeof valObj.end==='number'){var _findDataObj2=_extends({},valObj);if(!_findDataObj2.label){_findDataObj2=data.find(function(item){return item.start===valObj.start&&item.end===valObj.end;});}transformedValue.push(_findDataObj2);}else if(typeof valObj==='string'){var _findDataObj3=data.find(function(item){return item.label.trim()===valObj.trim();});transformedValue.push(_findDataObj3);}});}else if(typeof value==='string'){var _findDataObj4=data.find(function(item){return item.label.trim()===value.trim();});transformedValue.push(_findDataObj4);}break;case _constants.componentTypes.rangeSlider:case _constants.componentTypes.ratingsFilter:case _constants.componentTypes.dynamicRangeSlider:case _constants.componentTypes.reactiveChart:transformedValue=[];if(queryFormat){if(Array.isArray(value)){transformedValue=value.map(function(item){return(0,_helper.formatDate)((0,_dayjs2.default)(item),componentProps);});}else if(typeof value==='object'){transformedValue=[(0,_helper.formatDate)((0,_dayjs2.default)(value.start),componentProps),(0,_helper.formatDate)((0,_dayjs2.default)(value.end),componentProps)];}}else if(Array.isArray(value)){transformedValue=[].concat(_toConsumableArray(value));}else if(typeof value==='object'){transformedValue=[value.start,value.end];}else{transformedValue=value;}break;case _constants.componentTypes.numberBox:transformedValue=[];if(!Array.isArray(value)&&typeof value==='object'){transformedValue=value.start;}else if(typeof value==='number'){transformedValue=value;}break;case _constants.componentTypes.datePicker:transformedValue='';if(typeof value!=='object'){transformedValue=(0,_dayjs2.default)(value).format('YYYY-MM-DD');}else if(value.end){transformedValue=(0,_dayjs2.default)(value.end).format('YYYY-MM-DD');}else if(value.start){transformedValue=(0,_dayjs2.default)(value.start).add(24,'hour').format('YYYY-MM-DD');}break;case _constants.componentTypes.dateRange:transformedValue=[];if(Array.isArray(value)){transformedValue=value.map(function(t){return(0,_dayjs2.default)(t).format('YYYY-MM-DD');});}else if(typeof value==='object'){transformedValue=[(0,_dayjs2.default)(value.start).format('YYYY-MM-DD'),(0,_dayjs2.default)(value.end).format('YYYY-MM-DD')];}break;case _constants.componentTypes.categorySearch:transformedValue='';if(typeof value==='object'){transformedValue=value.value;if(value.category!==undefined){meta.category=value.category;}}else if(typeof value==='string'){transformedValue=value;}break;default:break;}}return{value:transformedValue,meta:meta};}; |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "10.2.0-alpha.3", | ||
"version": "10.2.0-alpha.4", | ||
"description": "Core architecture of reactive UI libraries", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
236096
8