Repository URL to install this package:
|
Version:
3.12.20 ▾
|
export var FILTER_FROM_SEARCH_REGEX = {
fileSize: {
code: 1,
valueRegex: /^\s*(?:(?:([0-9]+)\s*(?:mb)?\s*-)|([>|<]))\s*([0-9]+)\s*(?:mb)?\s*$/i
},
fileTypes: {
code: 2,
valueRegex: /(.*)/
},
tags: {
code: 3,
valueRegex: /(.*)/
},
orientation: {
code: 4,
valueRegex: /^(any|portrait|square|landscape|panorama)$/i
},
resolution: {
code: 5,
valueRegex: /^\s*(?:(?:([0-9]+)\s*(?:px)?\s*-)|([>|<]))\s*([0-9]+)\s*(?:px)?\s*/i
},
style: {
code: 6,
valueRegex: /^(transparent|black\s*-\s*white|illustration)$/i
},
color: {
code: 7,
valueRegex: /^([a-zA-Z]+)$/
},
faces: {
code: 8,
valueRegex: /^(none|one|two|group)$/i
}
};
// possible filters in search (size:, type:, tag:, orientation:, resolution:, style:, color:, faces:)
export var checkIsFilterThere = function checkIsFilterThere(searchValue) {
var _searchValue$split;
var hasValue = (_searchValue$split = searchValue.split(':')) === null || _searchValue$split === void 0 ? void 0 : _searchValue$split[1];
// Found size filter
if (!hasValue) return 0;
if (/^size\s*:\s*$/i.test(searchValue)) {
return FILTER_FROM_SEARCH_REGEX.fileSize.code;
}
// Found file type filter
if (/^type\s*:\s*$/i.test(searchValue)) {
return FILTER_FROM_SEARCH_REGEX.fileTypes.code;
}
// Found tag filter
if (/^tag\s*:\s*$/i.test(searchValue)) {
return FILTER_FROM_SEARCH_REGEX.tags.code;
}
// Found orientation filter
if (/^orientation\s*:\s*$/i.test(searchValue)) {
return FILTER_FROM_SEARCH_REGEX.orientation.code;
}
// Found resolution filter
if (/^resolution\s*:\s*$/i.test(searchValue)) {
return FILTER_FROM_SEARCH_REGEX.resolution.code;
}
// Found style filter
if (/^style\s*:\s*$/i.test(searchValue)) {
return FILTER_FROM_SEARCH_REGEX.style.code;
}
// Found color filter
if (/^color\s*:\s*$/i.test(searchValue)) {
return FILTER_FROM_SEARCH_REGEX.color.code;
}
// Found faces filter
if (/^faces\s*:\s*$/i.test(searchValue)) {
return FILTER_FROM_SEARCH_REGEX.faces.code;
}
return 0;
};