@grafana/scenes 5.25.1--canary.967.11837797508.0 → 5.25.1

Sign up to get free protection for your applications and to get access to all the features.
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');
17
16
  var react = require('@floating-ui/react');
18
17
  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');
@@ -529,8 +529,6 @@ function cloneSceneObjectState(sceneState, withState) {
529
529
  for (const child of propValue) {
530
530
  if (child instanceof SceneObjectBase) {
531
531
  newArray.push(child.clone());
532
- } else if (typeof child === "object") {
533
- newArray.push(__spreadValues$L({}, child));
534
532
  } else {
535
533
  newArray.push(child);
536
534
  }
@@ -2345,6 +2343,7 @@ var __spreadValues$G = (a, b) => {
2345
2343
  return a;
2346
2344
  };
2347
2345
  var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
2346
+ const GLOBAL_ANNOTATION_ID = 0;
2348
2347
  function filterAnnotations(data, filters) {
2349
2348
  var _a;
2350
2349
  if (!Array.isArray(data) || data.length === 0) {
@@ -2362,11 +2361,11 @@ function filterAnnotations(data, filters) {
2362
2361
  const sourceField = frame.fields.find((f) => f.name === "source");
2363
2362
  if (sourceField) {
2364
2363
  if (panelIdField && sourceField.values[index].type === "dashboard") {
2365
- matching = panelIdField.values[index] === filters.panelId;
2364
+ matching = [filters.panelId, GLOBAL_ANNOTATION_ID].includes(panelIdField.values[index]);
2366
2365
  }
2367
2366
  const sourceFilter = sourceField.values[index].filter;
2368
2367
  if (sourceFilter) {
2369
- const includes = ((_a = sourceFilter.ids) != null ? _a : []).includes(filters.panelId);
2368
+ const includes = [...(_a = sourceFilter.ids) != null ? _a : [], GLOBAL_ANNOTATION_ID].includes(filters.panelId);
2370
2369
  if (sourceFilter.exclude) {
2371
2370
  if (includes) {
2372
2371
  matching = false;
@@ -2505,48 +2504,14 @@ function findActiveGroupByVariablesByUid(dsUid) {
2505
2504
  return void 0;
2506
2505
  }
2507
2506
 
2508
- function getOptionSearcher(options, includeAll) {
2509
- const ufuzzy = new uFuzzy__default["default"]();
2507
+ function getOptionSearcher(options, includeAll = false) {
2510
2508
  let allOptions = options;
2511
- const haystack = [];
2512
- const limit = 1e4;
2513
2509
  if (includeAll) {
2514
2510
  allOptions = [{ value: ALL_VARIABLE_VALUE, label: ALL_VARIABLE_TEXT }, ...allOptions];
2515
2511
  }
2516
- return (search) => {
2517
- if (search === "") {
2518
- if (allOptions.length > limit) {
2519
- return allOptions.slice(0, limit);
2520
- } else {
2521
- return allOptions;
2522
- }
2523
- }
2524
- if (haystack.length === 0) {
2525
- for (let i = 0; i < allOptions.length; i++) {
2526
- haystack.push(allOptions[i].label);
2527
- }
2528
- }
2529
- const [idxs, info, order] = ufuzzy.search(haystack, search);
2530
- const filteredOptions = [];
2531
- if (idxs) {
2532
- for (let i = 0; i < idxs.length; i++) {
2533
- if (info && order) {
2534
- const idx = order[i];
2535
- filteredOptions.push(allOptions[idxs[idx]]);
2536
- } else {
2537
- filteredOptions.push(allOptions[idxs[i]]);
2538
- }
2539
- if (filteredOptions.length > limit) {
2540
- return filteredOptions;
2541
- }
2542
- }
2543
- return filteredOptions;
2544
- }
2545
- if (allOptions.length > limit) {
2546
- return allOptions.slice(0, limit);
2547
- }
2548
- return allOptions;
2549
- };
2512
+ const haystack = allOptions.map((o) => o.label);
2513
+ const fuzzySearch = getFuzzySearcher(haystack);
2514
+ return (search) => fuzzySearch(search).map((i) => allOptions[i]);
2550
2515
  }
2551
2516
 
2552
2517
  var __defProp$F = Object.defineProperty;
@@ -3235,44 +3200,12 @@ const getStyles$f = (theme) => ({
3235
3200
  });
3236
3201
 
3237
3202
  function getAdhocOptionSearcher(options) {
3238
- const ufuzzy = new uFuzzy__default["default"]();
3239
- const haystack = [];
3240
- const limit = 1e4;
3241
- return (search) => {
3203
+ const haystack = options.map((o) => {
3242
3204
  var _a;
3243
- if (search === "") {
3244
- if (options.length > limit) {
3245
- return options.slice(0, limit);
3246
- } else {
3247
- return options;
3248
- }
3249
- }
3250
- if (haystack.length === 0) {
3251
- for (let i = 0; i < options.length; i++) {
3252
- haystack.push((_a = options[i].label) != null ? _a : String(options[i].value));
3253
- }
3254
- }
3255
- const [idxs, info, order] = ufuzzy.search(haystack, search);
3256
- const filteredOptions = [];
3257
- if (idxs) {
3258
- for (let i = 0; i < idxs.length; i++) {
3259
- if (info && order) {
3260
- const idx = order[i];
3261
- filteredOptions.push(options[idxs[idx]]);
3262
- } else {
3263
- filteredOptions.push(options[idxs[i]]);
3264
- }
3265
- if (filteredOptions.length > limit) {
3266
- return filteredOptions;
3267
- }
3268
- }
3269
- return filteredOptions;
3270
- }
3271
- if (options.length > limit) {
3272
- return options.slice(0, limit);
3273
- }
3274
- return options;
3275
- };
3205
+ return (_a = o.label) != null ? _a : String(o.value);
3206
+ });
3207
+ const fuzzySearch = getFuzzySearcher(haystack);
3208
+ return (search) => fuzzySearch(search).map((i) => options[i]);
3276
3209
  }
3277
3210
 
3278
3211
  var __defProp$D = Object.defineProperty;
@@ -3798,55 +3731,16 @@ const VIRTUAL_LIST_ITEM_HEIGHT = 38;
3798
3731
  const VIRTUAL_LIST_ITEM_HEIGHT_WITH_DESCRIPTION = 60;
3799
3732
  const ERROR_STATE_DROPDOWN_WIDTH = 366;
3800
3733
  function fuzzySearchOptions(options) {
3801
- const ufuzzy = new uFuzzy__default["default"]();
3802
- const haystack = [];
3803
- const limit = 1e4;
3804
- return (search, filterInputType) => {
3734
+ const haystack = options.map((o) => {
3805
3735
  var _a;
3806
- if (search === "") {
3807
- if (options.length > limit) {
3808
- return options.slice(0, limit);
3809
- } else {
3810
- return options;
3811
- }
3812
- }
3813
- if (filterInputType === "operator") {
3814
- const filteredOperators = [];
3815
- for (let i = 0; i < options.length; i++) {
3816
- if ((_a = options[i].label || options[i].value) == null ? void 0 : _a.includes(search)) {
3817
- filteredOperators.push(options[i]);
3818
- if (filteredOperators.length > limit) {
3819
- return filteredOperators;
3820
- }
3821
- }
3822
- }
3823
- return filteredOperators;
3824
- }
3825
- if (haystack.length === 0) {
3826
- for (let i = 0; i < options.length; i++) {
3827
- haystack.push(options[i].label || options[i].value);
3828
- }
3829
- }
3830
- const [idxs, info, order] = ufuzzy.search(haystack, search);
3831
- const filteredOptions = [];
3832
- if (idxs) {
3833
- for (let i = 0; i < idxs.length; i++) {
3834
- if (info && order) {
3835
- const idx = order[i];
3836
- filteredOptions.push(options[idxs[idx]]);
3837
- } else {
3838
- filteredOptions.push(options[idxs[i]]);
3839
- }
3840
- if (filteredOptions.length > limit) {
3841
- return filteredOptions;
3842
- }
3843
- }
3844
- return filteredOptions;
3845
- }
3846
- if (options.length > limit) {
3847
- return options.slice(0, limit);
3736
+ return (_a = o.label) != null ? _a : o.value;
3737
+ });
3738
+ const fuzzySearch = getFuzzySearcher(haystack);
3739
+ return (search, filterInputType) => {
3740
+ if (filterInputType === "operator" && search !== "") {
3741
+ search = `"${search}"`;
3848
3742
  }
3849
- return options;
3743
+ return fuzzySearch(search).map((i) => options[i]);
3850
3744
  };
3851
3745
  }
3852
3746
  const flattenOptionGroups = (options) => options.flatMap((option) => option.options ? [option, ...option.options] : [option]);
@@ -5869,6 +5763,27 @@ function handleOptionGroups(values) {
5869
5763
  }
5870
5764
  return result;
5871
5765
  }
5766
+ function getFuzzySearcher(haystack, limit = 1e4) {
5767
+ const ufuzzy = new uFuzzy__default["default"]();
5768
+ const FIRST = Array.from({ length: Math.min(limit, haystack.length) }, (_, i) => i);
5769
+ return (search) => {
5770
+ if (search === "") {
5771
+ return FIRST;
5772
+ }
5773
+ const [idxs, info, order] = ufuzzy.search(haystack, search);
5774
+ if (idxs) {
5775
+ if (info && order) {
5776
+ const outIdxs = Array(Math.min(order.length, limit));
5777
+ for (let i = 0; i < outIdxs.length; i++) {
5778
+ outIdxs[i] = info.idx[order[i]];
5779
+ }
5780
+ return outIdxs;
5781
+ }
5782
+ return idxs.slice(0, limit);
5783
+ }
5784
+ return [];
5785
+ };
5786
+ }
5872
5787
 
5873
5788
  var __defProp$w = Object.defineProperty;
5874
5789
  var __defProps$k = Object.defineProperties;