@grafana/scenes 6.1.4 → 6.1.5--canary.1071.13674684765.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js +4 -3
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFiltersCombobox.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js +1 -22
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/utils.js.map +1 -1
- package/dist/esm/variables/adhoc/getAdhocOptionSearcher.js +2 -3
- package/dist/esm/variables/adhoc/getAdhocOptionSearcher.js.map +1 -1
- package/dist/esm/variables/components/getOptionSearcher.js +2 -3
- package/dist/esm/variables/components/getOptionSearcher.js.map +1 -1
- package/dist/esm/variables/filter.js +35 -0
- package/dist/esm/variables/filter.js.map +1 -0
- package/dist/esm/variables/utils.js +1 -23
- package/dist/esm/variables/utils.js.map +1 -1
- package/dist/index.js +36 -48
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13,9 +13,9 @@ var schema = require('@grafana/schema');
|
|
|
13
13
|
var ui = require('@grafana/ui');
|
|
14
14
|
var e2eSelectors = require('@grafana/e2e-selectors');
|
|
15
15
|
var css = require('@emotion/css');
|
|
16
|
+
var uFuzzy = require('@leeoniya/ufuzzy');
|
|
16
17
|
var react = require('@floating-ui/react');
|
|
17
18
|
var reactVirtual = require('@tanstack/react-virtual');
|
|
18
|
-
var uFuzzy = require('@leeoniya/ufuzzy');
|
|
19
19
|
var reactUse = require('react-use');
|
|
20
20
|
var operators = require('rxjs/operators');
|
|
21
21
|
var ReactGridLayout = require('react-grid-layout');
|
|
@@ -2833,14 +2833,44 @@ function findActiveGroupByVariablesByUid(dsUid) {
|
|
|
2833
2833
|
return void 0;
|
|
2834
2834
|
}
|
|
2835
2835
|
|
|
2836
|
+
const REGEXP_NON_ASCII = /[^ -~]/m;
|
|
2837
|
+
const REGEXP_ONLY_SYMBOLS = /^[\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]+$/m;
|
|
2838
|
+
const outOfOrderLimit = 5;
|
|
2839
|
+
const maxNeedleLength = 25;
|
|
2840
|
+
const maxFuzzyTerms = 5;
|
|
2841
|
+
const rankThreshold = 1e4;
|
|
2842
|
+
const uf = new uFuzzy__default["default"]({ intraMode: 1 });
|
|
2843
|
+
function fuzzyFind(options, haystack, needle) {
|
|
2844
|
+
let matches = [];
|
|
2845
|
+
if (needle === "") {
|
|
2846
|
+
matches = options;
|
|
2847
|
+
} else if (REGEXP_NON_ASCII.test(needle) || REGEXP_ONLY_SYMBOLS.test(needle) || needle.length > maxNeedleLength || uf.split(needle).length > maxFuzzyTerms) {
|
|
2848
|
+
for (let i = 0; i < haystack.length; i++) {
|
|
2849
|
+
let item = haystack[i];
|
|
2850
|
+
if (item.includes(needle)) {
|
|
2851
|
+
matches.push(options[i]);
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
} else {
|
|
2855
|
+
const [idxs, info, order] = uf.search(haystack, needle, outOfOrderLimit, rankThreshold);
|
|
2856
|
+
if (idxs == null ? void 0 : idxs.length) {
|
|
2857
|
+
if (info && order) {
|
|
2858
|
+
matches = order.map((idx) => options[info.idx[idx]]);
|
|
2859
|
+
} else {
|
|
2860
|
+
matches = idxs.map((idx) => options[idx]);
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
return matches;
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2836
2867
|
function getOptionSearcher(options, includeAll = false) {
|
|
2837
2868
|
let allOptions = options;
|
|
2838
2869
|
if (includeAll) {
|
|
2839
2870
|
allOptions = [{ value: ALL_VARIABLE_VALUE, label: ALL_VARIABLE_TEXT }, ...allOptions];
|
|
2840
2871
|
}
|
|
2841
2872
|
const haystack = allOptions.map((o) => o.label);
|
|
2842
|
-
|
|
2843
|
-
return (search) => fuzzySearch(search).map((i) => allOptions[i]);
|
|
2873
|
+
return (search) => fuzzyFind(allOptions, haystack, search);
|
|
2844
2874
|
}
|
|
2845
2875
|
|
|
2846
2876
|
var __defProp$G = Object.defineProperty;
|
|
@@ -3604,8 +3634,7 @@ function getAdhocOptionSearcher(options) {
|
|
|
3604
3634
|
var _a;
|
|
3605
3635
|
return (_a = o.label) != null ? _a : String(o.value);
|
|
3606
3636
|
});
|
|
3607
|
-
|
|
3608
|
-
return (search) => fuzzySearch(search).map((i) => options[i]);
|
|
3637
|
+
return (search) => fuzzyFind(options, haystack, search);
|
|
3609
3638
|
}
|
|
3610
3639
|
|
|
3611
3640
|
var __defProp$E = Object.defineProperty;
|
|
@@ -4141,26 +4170,6 @@ const VIRTUAL_LIST_OVERSCAN = 5;
|
|
|
4141
4170
|
const VIRTUAL_LIST_ITEM_HEIGHT = 38;
|
|
4142
4171
|
const VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;
|
|
4143
4172
|
const ERROR_STATE_DROPDOWN_WIDTH = 366;
|
|
4144
|
-
const REGEXP_NON_ASCII = /[^ -~]/m;
|
|
4145
|
-
function searchOptions(options) {
|
|
4146
|
-
const haystack = options.map((o) => {
|
|
4147
|
-
var _a;
|
|
4148
|
-
return (_a = o.label) != null ? _a : o.value;
|
|
4149
|
-
});
|
|
4150
|
-
const fuzzySearch = getFuzzySearcher(haystack);
|
|
4151
|
-
return (search, filterInputType) => {
|
|
4152
|
-
if (REGEXP_NON_ASCII.test(search)) {
|
|
4153
|
-
return options.filter((o) => {
|
|
4154
|
-
var _a, _b;
|
|
4155
|
-
return ((_a = o.label) == null ? void 0 : _a.includes(search)) || ((_b = o.value) == null ? void 0 : _b.includes(search)) || false;
|
|
4156
|
-
});
|
|
4157
|
-
}
|
|
4158
|
-
if (filterInputType === "operator" && search !== "") {
|
|
4159
|
-
search = `"${search}"`;
|
|
4160
|
-
}
|
|
4161
|
-
return fuzzySearch(search).map((i) => options[i]);
|
|
4162
|
-
};
|
|
4163
|
-
}
|
|
4164
4173
|
const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
|
|
4165
4174
|
const setupDropdownAccessibility = (options, listRef, disabledIndicesRef) => {
|
|
4166
4175
|
var _a, _b, _c, _d;
|
|
@@ -4500,7 +4509,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
|
4500
4509
|
const listRef = React.useRef([]);
|
|
4501
4510
|
const disabledIndicesRef = React.useRef([]);
|
|
4502
4511
|
const filterInputTypeRef = React.useRef(!isAlwaysWip ? "value" : "key");
|
|
4503
|
-
const optionsSearcher = React.useMemo(() =>
|
|
4512
|
+
const optionsSearcher = React.useMemo(() => getAdhocOptionSearcher(options), [options]);
|
|
4504
4513
|
const isLastFilter = React.useMemo(() => {
|
|
4505
4514
|
if (isAlwaysWip) {
|
|
4506
4515
|
return false;
|
|
@@ -4609,7 +4618,7 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
|
|
|
4609
4618
|
[refs.domReference]
|
|
4610
4619
|
);
|
|
4611
4620
|
const filteredDropDownItems = flattenOptionGroups(
|
|
4612
|
-
handleOptionGroups(optionsSearcher(preventFiltering ? "" : inputValue
|
|
4621
|
+
handleOptionGroups(optionsSearcher(preventFiltering ? "" : inputValue))
|
|
4613
4622
|
);
|
|
4614
4623
|
if (allowCustomValue && filterInputType !== "operator" && inputValue) {
|
|
4615
4624
|
filteredDropDownItems.push({
|
|
@@ -6278,27 +6287,6 @@ function handleOptionGroups(values) {
|
|
|
6278
6287
|
}
|
|
6279
6288
|
return result;
|
|
6280
6289
|
}
|
|
6281
|
-
function getFuzzySearcher(haystack, limit = 1e4) {
|
|
6282
|
-
const ufuzzy = new uFuzzy__default["default"]();
|
|
6283
|
-
const FIRST = Array.from({ length: Math.min(limit, haystack.length) }, (_, i) => i);
|
|
6284
|
-
return (search) => {
|
|
6285
|
-
if (search === "") {
|
|
6286
|
-
return FIRST;
|
|
6287
|
-
}
|
|
6288
|
-
const [idxs, info, order] = ufuzzy.search(haystack, search);
|
|
6289
|
-
if (idxs) {
|
|
6290
|
-
if (info && order) {
|
|
6291
|
-
const outIdxs = Array(Math.min(order.length, limit));
|
|
6292
|
-
for (let i = 0; i < outIdxs.length; i++) {
|
|
6293
|
-
outIdxs[i] = info.idx[order[i]];
|
|
6294
|
-
}
|
|
6295
|
-
return outIdxs;
|
|
6296
|
-
}
|
|
6297
|
-
return idxs.slice(0, limit);
|
|
6298
|
-
}
|
|
6299
|
-
return [];
|
|
6300
|
-
};
|
|
6301
|
-
}
|
|
6302
6290
|
|
|
6303
6291
|
var __defProp$x = Object.defineProperty;
|
|
6304
6292
|
var __defProps$l = Object.defineProperties;
|