UNPKG

@finos/legend-shared

Version:
59 lines 2.19 kB
/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { action, computed, makeObservable, observable } from 'mobx'; export var ADVANCED_FUZZY_SEARCH_MODE; (function (ADVANCED_FUZZY_SEARCH_MODE) { ADVANCED_FUZZY_SEARCH_MODE["STANDARD"] = "standard"; ADVANCED_FUZZY_SEARCH_MODE["INCLUDE"] = "include match"; ADVANCED_FUZZY_SEARCH_MODE["EXACT"] = "exact match"; ADVANCED_FUZZY_SEARCH_MODE["INVERSE"] = "excludes exact match"; })(ADVANCED_FUZZY_SEARCH_MODE || (ADVANCED_FUZZY_SEARCH_MODE = {})); export class FuzzySearchAdvancedConfigState { currentMode = ADVANCED_FUZZY_SEARCH_MODE.STANDARD; onSearchModeChange; constructor(onSearchModeChange) { makeObservable(this, { currentMode: observable, isAdvancedSearchActive: computed, setCurrentMode: action, }); this.onSearchModeChange = onSearchModeChange; } get isAdvancedSearchActive() { return this.currentMode !== ADVANCED_FUZZY_SEARCH_MODE.STANDARD; } generateSearchText(val) { switch (this.currentMode) { case ADVANCED_FUZZY_SEARCH_MODE.INCLUDE: { return `'"${val}"`; } case ADVANCED_FUZZY_SEARCH_MODE.EXACT: { return `="${val}"`; } case ADVANCED_FUZZY_SEARCH_MODE.INVERSE: { return `!"${val}"`; } default: { return val; } } } setCurrentMode(val) { this.currentMode = val; this.onSearchModeChange(); } } //# sourceMappingURL=FuzzySearchAdvancedConfigState.js.map