@splunk/visualizations 26.4.1 → 27.0.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.
Files changed (152) hide show
  1. package/Area.config.js +1262 -1600
  2. package/Area.config.js.map +7 -1
  3. package/Area.js +3002 -4930
  4. package/Area.js.map +7 -1
  5. package/Bar.config.js +1247 -1574
  6. package/Bar.config.js.map +7 -1
  7. package/Bar.js +2921 -4843
  8. package/Bar.js.map +7 -1
  9. package/Bubble.config.js +896 -1213
  10. package/Bubble.config.js.map +7 -1
  11. package/Bubble.js +2517 -4483
  12. package/Bubble.js.map +7 -1
  13. package/ChoroplethSvg.config.js +282 -582
  14. package/ChoroplethSvg.config.js.map +7 -1
  15. package/ChoroplethSvg.js +2004 -3810
  16. package/ChoroplethSvg.js.map +7 -1
  17. package/Column.config.js +1208 -1541
  18. package/Column.config.js.map +7 -1
  19. package/Column.js +2930 -4886
  20. package/Column.js.map +7 -1
  21. package/Ellipse.config.js +443 -774
  22. package/Ellipse.config.js.map +7 -1
  23. package/Ellipse.js +1651 -3341
  24. package/Ellipse.js.map +7 -1
  25. package/Events.config.js +207 -492
  26. package/Events.config.js.map +7 -1
  27. package/Events.js +2615 -4649
  28. package/Events.js.map +7 -1
  29. package/FillerGauge.config.js +420 -775
  30. package/FillerGauge.config.js.map +7 -1
  31. package/FillerGauge.js +2137 -4578
  32. package/FillerGauge.js.map +7 -1
  33. package/Image.config.js +144 -411
  34. package/Image.config.js.map +7 -1
  35. package/Image.js +1395 -3048
  36. package/Image.js.map +7 -1
  37. package/Line.config.js +1278 -1625
  38. package/Line.config.js.map +7 -1
  39. package/Line.js +2954 -4926
  40. package/Line.js.map +7 -1
  41. package/LinkGraph.config.js +390 -632
  42. package/LinkGraph.config.js.map +7 -1
  43. package/LinkGraph.js +5243 -6190
  44. package/LinkGraph.js.map +7 -1
  45. package/MIGRATION.md +6 -0
  46. package/Map.config.js +501 -801
  47. package/Map.config.js.map +7 -1
  48. package/Map.js +3369 -5676
  49. package/Map.js.map +7 -1
  50. package/Markdown.config.js +232 -528
  51. package/Markdown.config.js.map +7 -1
  52. package/Markdown.js +1645 -3216
  53. package/Markdown.js.map +7 -1
  54. package/MarkerGauge.config.js +308 -613
  55. package/MarkerGauge.config.js.map +7 -1
  56. package/MarkerGauge.js +2189 -4535
  57. package/MarkerGauge.js.map +7 -1
  58. package/ParallelCoordinates.config.js +282 -581
  59. package/ParallelCoordinates.config.js.map +7 -1
  60. package/ParallelCoordinates.js +2023 -4720
  61. package/ParallelCoordinates.js.map +7 -1
  62. package/Pie.config.js +278 -547
  63. package/Pie.config.js.map +7 -1
  64. package/Pie.js +1996 -3990
  65. package/Pie.js.map +7 -1
  66. package/Punchcard.config.js +291 -578
  67. package/Punchcard.config.js.map +7 -1
  68. package/Punchcard.js +2709 -5042
  69. package/Punchcard.js.map +7 -1
  70. package/Rectangle.config.js +455 -770
  71. package/Rectangle.config.js.map +7 -1
  72. package/Rectangle.js +1638 -3262
  73. package/Rectangle.js.map +7 -1
  74. package/Sankey.config.js +291 -626
  75. package/Sankey.config.js.map +7 -1
  76. package/Sankey.js +2737 -4909
  77. package/Sankey.js.map +7 -1
  78. package/Scatter.config.js +876 -1194
  79. package/Scatter.config.js.map +7 -1
  80. package/Scatter.js +2529 -4477
  81. package/Scatter.js.map +7 -1
  82. package/SingleValue.config.js +819 -1251
  83. package/SingleValue.config.js.map +7 -1
  84. package/SingleValue.js +4203 -7413
  85. package/SingleValue.js.map +7 -1
  86. package/SingleValueBasic.js +382 -1527
  87. package/SingleValueBasic.js.map +7 -1
  88. package/SingleValueIcon.config.js +781 -1207
  89. package/SingleValueIcon.config.js.map +7 -1
  90. package/SingleValueIcon.js +3350 -6285
  91. package/SingleValueIcon.js.map +7 -1
  92. package/SingleValueRadial.config.js +708 -1119
  93. package/SingleValueRadial.config.js.map +7 -1
  94. package/SingleValueRadial.js +3808 -6965
  95. package/SingleValueRadial.js.map +7 -1
  96. package/SparkLine.js +439 -746
  97. package/SparkLine.js.map +7 -1
  98. package/Table.config.js +565 -879
  99. package/Table.config.js.map +7 -1
  100. package/Table.js +3277 -5381
  101. package/Table.js.map +7 -1
  102. package/common/Charting.js +481 -1468
  103. package/common/Charting.js.map +7 -1
  104. package/common/ChartingApi.js +46 -170
  105. package/common/ChartingApi.js.map +7 -1
  106. package/common/DocExampleWithVizSandbox.js +270 -473
  107. package/common/DocExampleWithVizSandbox.js.map +7 -1
  108. package/common/EventsDoc.js +172 -464
  109. package/common/EventsDoc.js.map +7 -1
  110. package/common/GaugeMajorTicks.js +249 -347
  111. package/common/GaugeMajorTicks.js.map +7 -1
  112. package/common/GaugeValueMarker.js +201 -311
  113. package/common/GaugeValueMarker.js.map +7 -1
  114. package/common/OptionsDoc.js +347 -912
  115. package/common/OptionsDoc.js.map +7 -1
  116. package/common/OverviewDoc.js +435 -769
  117. package/common/OverviewDoc.js.map +7 -1
  118. package/common/SplunkVisualization.js +116 -259
  119. package/common/SplunkVisualization.js.map +7 -1
  120. package/common/SplunkVisualizationApi.js +40 -156
  121. package/common/SplunkVisualizationApi.js.map +7 -1
  122. package/common/ThemesDoc.js +271 -420
  123. package/common/ThemesDoc.js.map +7 -1
  124. package/common/chartingUtils.js +140 -312
  125. package/common/chartingUtils.js.map +7 -1
  126. package/common/docUtils.js +148 -266
  127. package/common/docUtils.js.map +7 -1
  128. package/common/gaugeUtils.js +280 -808
  129. package/common/gaugeUtils.js.map +7 -1
  130. package/common/shapeUtils.js +106 -211
  131. package/common/shapeUtils.js.map +7 -1
  132. package/common/utils/configUtils.js +126 -252
  133. package/common/utils/configUtils.js.map +7 -1
  134. package/common/utils/dataUtils.js +217 -812
  135. package/common/utils/dataUtils.js.map +7 -1
  136. package/common/utils/featureFlagUtils.js +53 -133
  137. package/common/utils/featureFlagUtils.js.map +7 -1
  138. package/common/utils/hocUtils.js +32 -122
  139. package/common/utils/hocUtils.js.map +7 -1
  140. package/common/utils/mapUtils.js +502 -1337
  141. package/common/utils/mapUtils.js.map +7 -1
  142. package/common/utils/singleValueUtils.js +462 -1010
  143. package/common/utils/singleValueUtils.js.map +7 -1
  144. package/common/utils/testHelper.js +92 -146
  145. package/common/utils/testHelper.js.map +7 -1
  146. package/common/utils/trellisUtils.js +237 -489
  147. package/common/utils/trellisUtils.js.map +7 -1
  148. package/common/utils/urlUtils.js +28 -112
  149. package/common/utils/urlUtils.js.map +7 -1
  150. package/common/withDashboardViz.js +1168 -2438
  151. package/common/withDashboardViz.js.map +7 -1
  152. package/package.json +52 -43
@@ -1,2508 +1,935 @@
1
- /*!
2
- * Copyright © 2024 Splunk Inc.
3
- * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
4
- * in part without a valid written license from Splunk Inc. is PROHIBITED.
5
- */
6
- module.exports =
7
- /******/ (function(modules) { // webpackBootstrap
8
- /******/ // The module cache
9
- /******/ var installedModules = {};
10
- /******/
11
- /******/ // The require function
12
- /******/ function __webpack_require__(moduleId) {
13
- /******/
14
- /******/ // Check if module is in cache
15
- /******/ if(installedModules[moduleId]) {
16
- /******/ return installedModules[moduleId].exports;
17
- /******/ }
18
- /******/ // Create a new module (and put it into the cache)
19
- /******/ var module = installedModules[moduleId] = {
20
- /******/ i: moduleId,
21
- /******/ l: false,
22
- /******/ exports: {}
23
- /******/ };
24
- /******/
25
- /******/ // Execute the module function
26
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
27
- /******/
28
- /******/ // Flag the module as loaded
29
- /******/ module.l = true;
30
- /******/
31
- /******/ // Return the exports of the module
32
- /******/ return module.exports;
33
- /******/ }
34
- /******/
35
- /******/
36
- /******/ // expose the modules object (__webpack_modules__)
37
- /******/ __webpack_require__.m = modules;
38
- /******/
39
- /******/ // expose the module cache
40
- /******/ __webpack_require__.c = installedModules;
41
- /******/
42
- /******/ // define getter function for harmony exports
43
- /******/ __webpack_require__.d = function(exports, name, getter) {
44
- /******/ if(!__webpack_require__.o(exports, name)) {
45
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
46
- /******/ }
47
- /******/ };
48
- /******/
49
- /******/ // define __esModule on exports
50
- /******/ __webpack_require__.r = function(exports) {
51
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
52
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
53
- /******/ }
54
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
55
- /******/ };
56
- /******/
57
- /******/ // create a fake namespace object
58
- /******/ // mode & 1: value is a module id, require it
59
- /******/ // mode & 2: merge all properties of value into the ns
60
- /******/ // mode & 4: return value when already ns object
61
- /******/ // mode & 8|1: behave like require
62
- /******/ __webpack_require__.t = function(value, mode) {
63
- /******/ if(mode & 1) value = __webpack_require__(value);
64
- /******/ if(mode & 8) return value;
65
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
66
- /******/ var ns = Object.create(null);
67
- /******/ __webpack_require__.r(ns);
68
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
69
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
70
- /******/ return ns;
71
- /******/ };
72
- /******/
73
- /******/ // getDefaultExport function for compatibility with non-harmony modules
74
- /******/ __webpack_require__.n = function(module) {
75
- /******/ var getter = module && module.__esModule ?
76
- /******/ function getDefault() { return module['default']; } :
77
- /******/ function getModuleExports() { return module; };
78
- /******/ __webpack_require__.d(getter, 'a', getter);
79
- /******/ return getter;
80
- /******/ };
81
- /******/
82
- /******/ // Object.prototype.hasOwnProperty.call
83
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
84
- /******/
85
- /******/ // __webpack_public_path__
86
- /******/ __webpack_require__.p = "";
87
- /******/
88
- /******/
89
- /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 103);
91
- /******/ })
92
- /************************************************************************/
93
- /******/ ([
94
- /* 0 */
95
- /***/ (function(module, exports) {
96
-
97
- module.exports = require("react");
98
-
99
- /***/ }),
100
- /* 1 */
101
- /***/ (function(module, exports) {
102
-
103
- module.exports = require("prop-types");
104
-
105
- /***/ }),
106
- /* 2 */
107
- /***/ (function(module, exports) {
108
-
109
- module.exports = require("styled-components");
110
-
111
- /***/ }),
112
- /* 3 */
113
- /***/ (function(module, exports) {
114
-
115
- module.exports = require("lodash");
116
-
117
- /***/ }),
118
- /* 4 */
119
- /***/ (function(module, exports) {
120
-
121
- module.exports = require("@babel/runtime/helpers/classCallCheck");
122
-
123
- /***/ }),
124
- /* 5 */
125
- /***/ (function(module, exports) {
126
-
127
- module.exports = require("@splunk/ui-utils/i18n");
128
-
129
- /***/ }),
130
- /* 6 */,
131
- /* 7 */
132
- /***/ (function(module, exports) {
133
-
134
- module.exports = require("@babel/runtime/helpers/createClass");
135
-
136
- /***/ }),
137
- /* 8 */
138
- /***/ (function(module, exports) {
139
-
140
- module.exports = require("@babel/runtime/helpers/slicedToArray");
141
-
142
- /***/ }),
143
- /* 9 */
144
- /***/ (function(module, exports) {
145
-
146
- module.exports = require("@splunk/visualizations-shared/numberUtils");
147
-
148
- /***/ }),
149
- /* 10 */
150
- /***/ (function(module, exports) {
151
-
152
- module.exports = require("@babel/runtime/helpers/defineProperty");
153
-
154
- /***/ }),
155
- /* 11 */,
156
- /* 12 */,
157
- /* 13 */,
158
- /* 14 */
159
- /***/ (function(module, exports, __webpack_require__) {
160
-
161
- "use strict";
162
-
163
-
164
- var _classCallCheck = __webpack_require__(4);
165
-
166
- var _createClass = __webpack_require__(7);
167
-
168
- Object.defineProperty(exports, "__esModule", {
169
- value: true
170
- });
171
- exports.DefaultVizActionHandler = void 0;
172
-
173
- var DefaultVizActionHandler = /*#__PURE__*/function () {
174
- function DefaultVizActionHandler() {
175
- _classCallCheck(this, DefaultVizActionHandler);
176
- }
177
-
178
- _createClass(DefaultVizActionHandler, [{
179
- key: "focus",
180
- value: function focus() {// noop
181
- }
182
- }, {
183
- key: "snapshot",
184
- value: function snapshot() {
185
- return null; // noop
186
- }
187
- }]);
188
-
189
- return DefaultVizActionHandler;
190
- }();
191
-
192
- exports.DefaultVizActionHandler = DefaultVizActionHandler;
193
-
194
- /***/ }),
195
- /* 15 */,
196
- /* 16 */
197
- /***/ (function(module, exports) {
198
-
199
- module.exports = require("@splunk/visualizations-shared/colorUtils");
200
-
201
- /***/ }),
202
- /* 17 */,
203
- /* 18 */
204
- /***/ (function(module, exports, __webpack_require__) {
205
-
206
- "use strict";
207
-
208
-
209
- Object.defineProperty(exports, "__esModule", {
210
- value: true
211
- });
212
- exports.VizBehavior = void 0;
213
- var VizBehavior;
214
-
215
- (function (VizBehavior) {
216
- /**
217
- * Dynamic Options Behavior.
218
- * This allows visualization options to be powered by data
219
- *
220
- * **Example**
221
- *
222
- * sparklineValues: ">primary|seriesByIndex(0)"
223
- * would configure sparklineValues with an array of data points
224
- * coming from the first series in the primary datasource
225
- *
226
- */
227
- VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
228
- VizBehavior["EVENTS"] = "events";
229
- VizBehavior["DOWNSAMPLING"] = "downsampling";
230
- /**
231
- * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
232
- * missing.
233
- * @type {string}
234
- */
235
-
236
- VizBehavior["PLACEHOLDER"] = "placeholder";
237
- VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
238
- VizBehavior["TRELLIS"] = "trellis";
239
- })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
240
-
241
- /***/ }),
242
- /* 19 */
243
- /***/ (function(module, exports, __webpack_require__) {
244
-
245
- "use strict";
246
-
247
-
248
- Object.defineProperty(exports, "__esModule", {
249
- value: true
250
- });
251
- exports.VizCategory = void 0;
252
- var VizCategory;
253
-
254
- (function (VizCategory) {
255
- VizCategory["SINGLE_VALUE"] = "Single Value";
256
- VizCategory["TRENDS"] = "Trends";
257
- VizCategory["COMPARISONS"] = "Comparisons";
258
- VizCategory["TABLE"] = "Table";
259
- VizCategory["GAUGE"] = "Gauge";
260
- VizCategory["DISTRIBUTIONS"] = "Distributions";
261
- VizCategory["CHOROPLETH"] = "Choropleth Maps";
262
- VizCategory["SHAPES"] = "Shapes";
263
- VizCategory["MISC"] = "misc";
264
- VizCategory["FLOW"] = "Flow";
265
- VizCategory["CORRELATION"] = "Correlation";
266
- VizCategory["SPATIAL"] = "Spatial";
267
- })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
268
-
269
- /***/ }),
270
- /* 20 */,
271
- /* 21 */,
272
- /* 22 */
273
- /***/ (function(module, exports) {
274
-
275
- module.exports = require("@babel/runtime/helpers/toConsumableArray");
276
-
277
- /***/ }),
278
- /* 23 */,
279
- /* 24 */
280
- /***/ (function(module, exports) {
281
-
282
- module.exports = require("@splunk/visualizations-shared/Message");
283
-
284
- /***/ }),
285
- /* 25 */
286
- /***/ (function(module, exports, __webpack_require__) {
287
-
288
- "use strict";
289
-
290
-
291
- Object.defineProperty(exports, "__esModule", {
292
- value: true
293
- });
294
- exports.downsampleDataSources = exports.calculateDownsamplingThreshold = exports.calculateThresholdOnRangeSelect = exports.isDownsamplingEnabledForViz = exports.convertToArrOfObjects = void 0;
295
-
296
- var numberUtils_1 = __webpack_require__(9);
297
-
298
- var interfaces_1 = __webpack_require__(32); // TODO: utilize this fn in ParallelCoordinates
299
-
300
-
301
- var convertToArrOfObjects = function convertToArrOfObjects(columns, fields) {
302
- if (!columns || !columns[0] || !columns[0].length) return [];
303
- var data = [];
304
-
305
- var _loop = function _loop(i) {
306
- var newObj = {};
307
- fields.forEach(function (field, index) {
308
- var fieldName = typeof field === 'string' ? field : field.name;
309
-
310
- if (columns[index][i] === '') {
311
- newObj[fieldName] = null;
312
- } else {
313
- newObj[fieldName] = columns[index][i];
314
- }
315
- });
316
- data.push(newObj);
317
- };
318
-
319
- for (var i = 0; i < columns[0].length; i += 1) {
320
- _loop(i);
321
- }
322
-
323
- return data;
324
- };
325
-
326
- exports.convertToArrOfObjects = convertToArrOfObjects; // LTTB algorithm which can be used to downsample time series data while striving to maintain
327
- // the spikes and overall shape of the chart
328
- // Copied from https://github.com/sveinn-steinarsson/flot-downsample/blob/0815010016fc94b1bbc6a010afb8aad13ada6d0d/jquery.flot.downsample.js
329
- // Modifications include:
330
- // 1) Convert to modern JavaScript(use const, let, and use array.push to push to last element of array)
331
- // 2) Convert to camel case
332
- // 3) Convert to TS and also return the indices of the points that are in the downsampled result.
333
- // 4) Add a new parameter preferredDownsampleIndices that correspond to the indices of points
334
- // that should be used in case of a tie of the max area in a bucket
335
-
336
- var largestTriangleThreeBuckets = function largestTriangleThreeBuckets(data, threshold, preferredDownsampleIndices) {
337
- var dataLength = data.length;
338
- var downsampledIndices = [];
339
-
340
- if (threshold >= dataLength || threshold === 0) {
341
- var allIndices = data.map(function (values, index) {
342
- return index;
343
- });
344
- return {
345
- downsampledData: data,
346
- downsampledIndices: allIndices
347
- }; // Nothing to do
348
- }
349
-
350
- var sampled = [];
351
- var sampledIndex = 0; // Bucket size. Leave room for start and end data points
352
-
353
- var every = (dataLength - 2) / (threshold - 2);
354
- var a = 0; // Initially a is the first point in the triangle
355
-
356
- var maxAreaPoint;
357
- var maxArea;
358
- var area;
359
- var nextA;
360
- sampled.push(data[a]); // Always add the first point
361
-
362
- downsampledIndices.push(0); // eslint-disable-next-line no-plusplus
363
-
364
- for (var i = 0; i < threshold - 2; i++) {
365
- // Calculate point average for next bucket (containing c)
366
- var avgX = 0;
367
- var avgY = 0;
368
- var avgRangeStart = Math.floor((i + 1) * every) + 1;
369
- var avgRangeEnd = Math.floor((i + 2) * every) + 1;
370
- avgRangeEnd = avgRangeEnd < dataLength ? avgRangeEnd : dataLength;
371
- var avgRangeLength = avgRangeEnd - avgRangeStart; // eslint-disable-next-line no-plusplus
372
-
373
- for (; avgRangeStart < avgRangeEnd; avgRangeStart++) {
374
- avgX += Number(data[avgRangeStart][0]); // * 1 enforces Number (value may be Date)
375
-
376
- avgY += data[avgRangeStart][1] * 1;
377
- }
378
-
379
- avgX /= avgRangeLength;
380
- avgY /= avgRangeLength; // Get the range for this bucket
381
-
382
- var rangeOffs = Math.floor((i + 0) * every) + 1;
383
- var rangeTo = Math.floor((i + 1) * every) + 1; // Point a
384
-
385
- var pointAX = Number(data[a][0]); // Enforce Number (value may be Date)
386
-
387
- var pointAY = data[a][1] * 1; // eslint-disable-next-line no-multi-assign
388
-
389
- maxArea = area = -1;
390
- var maxAreaIndex = rangeOffs; // eslint-disable-next-line no-plusplus
391
-
392
- for (; rangeOffs < rangeTo; rangeOffs++) {
393
- // Calculate triangle area over three buckets
394
- area = Math.abs((pointAX - avgX) * (data[rangeOffs][1] - pointAY) - (pointAX - Number(data[rangeOffs][0])) * (avgY - pointAY)) * 0.5; // Modification: try to downsample the least amount of points possible when there are multiple series
395
- // If all points in a bucket have the same area, prioritize the one with an x index
396
- // that also existed from another series so we don't add another point unnecessarily.
397
- // By default LTTB picks the leftmost point in the bucket
398
-
399
- if (area > maxArea || area === maxArea && preferredDownsampleIndices.has(rangeOffs)) {
400
- maxArea = area;
401
- maxAreaPoint = data[rangeOffs];
402
- nextA = rangeOffs; // Next a is this b
403
- // Modification: save the index of the point with the most area
404
-
405
- maxAreaIndex = rangeOffs;
406
- }
407
- } // eslint-disable-next-line no-plusplus
408
-
409
-
410
- sampled[sampledIndex++] = maxAreaPoint; // Pick this point from the bucket
411
-
412
- downsampledIndices.push(maxAreaIndex);
413
- a = nextA; // This a is the next a (chosen b)
414
- } // eslint-disable-next-line no-plusplus
415
-
416
-
417
- sampled[sampledIndex++] = data[dataLength - 1]; // Always add last
418
-
419
- downsampledIndices.push(dataLength - 1);
420
- return {
421
- downsampledData: sampled,
422
- downsampledIndices: downsampledIndices
423
- };
424
- };
425
- /**
426
- * Strictly coerces the entire column to numbers if it only consists of numeric strings or numbers. Also determines
427
- * if at least one of the values in the column can be loosely coerced to a number.
428
- * If the column cannot be strictly downsampled (if it contains nulls or non-numeric strings), returns an empty array and
429
- * returns that it cannot downsample the column.
430
- */
431
-
432
-
433
- var strictlyCoerceYColumn = function strictlyCoerceYColumn(column, options) {
434
- var isNullCoercionEnabled = options.nullValueDisplay === 'zero'; // Splunk charting allows for numbers in formats such as negative hex that
435
- // Number() does not support and also allows loose coercion of hex numbers (but not other formats)
436
- // We want to identify columns which contain at least one value that can be loosely coerced
437
-
438
- var canLooselyCoerceSomeValues = column.findIndex(function (value) {
439
- return (0, numberUtils_1.startsWithNumber)("".concat(value)) || isNullCoercionEnabled && value === null;
440
- }) >= 0; // If not all values in column can be strictly coerced to a number, we do not downsample
441
-
442
- var coercedColumn = [];
443
- var canDownsampleColumn = !column.some(function (value) {
444
- var coercedValue = Number(value);
445
- var coerceValueToZero = isNullCoercionEnabled && value === null; // if it can't be parsed or isn't safe, fail
446
-
447
- if (Number.isNaN(coercedValue) || coercedValue <= Number.MIN_SAFE_INTEGER || coercedValue >= Number.MAX_SAFE_INTEGER || typeof value !== 'string' && typeof value !== 'number' && !coerceValueToZero) {
448
- return true;
449
- } // save value and continue to next
450
-
451
-
452
- coercedColumn.push(coercedValue);
453
- return false;
454
- });
455
- return {
456
- canDownsampleColumn: canDownsampleColumn,
457
- canLooselyCoerceSomeValues: canLooselyCoerceSomeValues,
458
- coercedColumn: canDownsampleColumn ? coercedColumn : []
459
- };
460
- };
461
- /**
462
- * Tries to coerce the x-column to numbers or dates, if it is eligible for downsampling.
463
- * Only strictly increasing x-columns are eligible for downsampling.
464
- * If the column is not eligible for downsampling, returns an empty array.
465
- */
466
-
467
-
468
- var strictlyCoerceXColumn = function strictlyCoerceXColumn(column, fieldType) {
469
- if (fieldType === 'number') {
470
- var coercedXColumn = column.map(function (xValue) {
471
- return Number(xValue);
472
- });
473
-
474
- if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
475
- return coercedXColumn;
476
- }
477
- } else if (fieldType === 'time') {
478
- var _coercedXColumn = column.map(function (xValue) {
479
- return new Date(xValue);
480
- });
481
-
482
- if (isColumnStrictlyIncreasing(_coercedXColumn, fieldType)) {
483
- return _coercedXColumn;
484
- }
485
- }
486
-
487
- return [];
488
- };
489
-
490
- var isDownsamplingEnabledForViz = function isDownsamplingEnabledForViz(_ref) {
491
- var vizConfig = _ref.vizConfig;
492
-
493
- var _a;
494
-
495
- return (_a = vizConfig.supports) === null || _a === void 0 ? void 0 : _a.includes(interfaces_1.VizBehavior.DOWNSAMPLING);
496
- };
497
-
498
- exports.isDownsamplingEnabledForViz = isDownsamplingEnabledForViz;
499
-
500
- var calculateThresholdOnRangeSelect = function calculateThresholdOnRangeSelect(_ref2) {
501
- var firstIndex = _ref2.firstIndex,
502
- lastIndex = _ref2.lastIndex,
503
- dataSources = _ref2.dataSources,
504
- width = _ref2.width;
505
-
506
- var _a, _b, _c;
507
-
508
- var window = lastIndex - firstIndex + 1;
509
- var ratio = Math.round(Number(((_c = (_b = (_a = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.columns[0]) === null || _c === void 0 ? void 0 : _c.length) / window) * 10) / 10;
510
- return Math.round(ratio * Number(width));
511
- };
512
-
513
- exports.calculateThresholdOnRangeSelect = calculateThresholdOnRangeSelect;
514
- /**
515
- * Calculates the downsampling threshold based on the range selection. If search zoom is enabled or there is no selection,
516
- * then returns the width of the visualization.
517
- *
518
- * Otherwise calculates the threshold based on the ratio of the window selected compared to the size of the non-downsampled
519
- * data sources. Returns null if the chart event's dataset does not match the passed in primary data source or if the chart is zoomed
520
- * in for a categorical chart.
521
- */
522
-
523
- var calculateDownsamplingThreshold = function calculateDownsamplingThreshold(_ref3) {
524
- var enableSearchZoom = _ref3.enableSearchZoom,
525
- dataSources = _ref3.dataSources,
526
- selectChartEvent = _ref3.selectChartEvent,
527
- width = _ref3.width,
528
- xField = _ref3.xField;
529
-
530
- var _a, _b, _c;
531
-
532
- if (enableSearchZoom || !selectChartEvent) {
533
- return Number(width);
534
- }
535
-
536
- var primaryDataSource = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary;
537
-
538
- if (!primaryDataSource) {
539
- return null;
540
- }
541
-
542
- var startXIndex = selectChartEvent.startXIndex,
543
- endXIndex = selectChartEvent.endXIndex,
544
- currentTarget = selectChartEvent.currentTarget;
545
-
546
- try {
547
- var xFieldIndex = (_a = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _a === void 0 ? void 0 : _a.fields.findIndex(function (field) {
548
- return field.name === xField;
549
- });
550
- var downsampledXFieldIndex = (_b = currentTarget.dataSet) === null || _b === void 0 ? void 0 : _b.fields.findIndex(function (field) {
551
- return field === xField;
552
- });
553
-
554
- if (xFieldIndex === -1 || downsampledXFieldIndex === -1) {
555
- return null;
556
- }
557
-
558
- var fullSeries = (_c = primaryDataSource === null || primaryDataSource === void 0 ? void 0 : primaryDataSource.data) === null || _c === void 0 ? void 0 : _c.columns[xFieldIndex];
559
- var downsampledSeries = currentTarget.dataSet.seriesList[downsampledXFieldIndex];
560
- var firstIndex = fullSeries.findIndex(function (x) {
561
- return downsampledSeries[startXIndex] === x;
562
- });
563
- var lastIndex = fullSeries.findIndex(function (x) {
564
- return downsampledSeries[endXIndex] === x;
565
- });
566
-
567
- if (firstIndex >= 0 && lastIndex >= 0 && firstIndex <= lastIndex) {
568
- return (0, exports.calculateThresholdOnRangeSelect)({
569
- firstIndex: firstIndex,
570
- lastIndex: lastIndex,
571
- dataSources: dataSources,
572
- width: width
573
- });
574
- }
575
- } catch (e) {
576
- // eslint-disable-next-line no-console
577
- console.error('Error occurred while setting downsample threshold on range select event', e);
578
- }
579
-
580
- return null;
581
- };
582
-
583
- exports.calculateDownsamplingThreshold = calculateDownsamplingThreshold;
584
-
585
- var isColumnStrictlyIncreasing = function isColumnStrictlyIncreasing(column, fieldType) {
586
- return column.every(function (value, index) {
587
- if (fieldType === 'number') {
588
- if (Number.isNaN(value)) {
589
- return false;
590
- }
591
- }
592
-
593
- if (fieldType === 'time') {
594
- if (Number.isNaN(value.getTime())) {
595
- return false;
596
- }
597
- }
598
-
599
- if (index === 0) {
600
- return true;
601
- }
602
-
603
- return value > column[index - 1];
604
- });
605
- };
606
- /**
607
- * Verifies that all of the columns that are displayed in a chart can be downsampled. Valid columns that can be
608
- * displayed are those that contain at least one number. We can only downsample columns that only consist of numbers.
609
- *
610
- * If all columns can be downsampled, returns the x column coerced to time/number and y columns coerced to numbers.
611
- * If not all columns can be downsampled, then returns empty arrays for both x and y
612
- */
613
-
614
-
615
- var tryToCoerceAllDisplayedFields = function tryToCoerceAllDisplayedFields(ds, xField, yFields, fieldTypes, options) {
616
- var xColumn = [];
617
- var yColumns = [];
618
- var canDownsample = !ds.data.fields.some(function (field, index) {
619
- var _a, _b;
620
-
621
- var fieldName = (_a = field.name) !== null && _a !== void 0 ? _a : field;
622
- var fieldType = (_b = fieldTypes[index]) !== null && _b !== void 0 ? _b : 'unknown';
623
- var column = ds.data.columns[index];
624
- var hasDisplayedColumnThatCantBeDownsampled = false;
625
-
626
- if (fieldName === xField) {
627
- xColumn = strictlyCoerceXColumn(column, fieldType);
628
- } else if (yFields.has(fieldName)) {
629
- var _strictlyCoerceYColum = strictlyCoerceYColumn(ds.data.columns[index], options),
630
- coercedColumn = _strictlyCoerceYColum.coercedColumn,
631
- canLooselyCoerceSomeValues = _strictlyCoerceYColum.canLooselyCoerceSomeValues,
632
- canDownsampleColumn = _strictlyCoerceYColum.canDownsampleColumn; // do not perform downsampling if a column can possibly be displayed but cannot
633
- // be downsampled using LTTB
634
-
635
-
636
- hasDisplayedColumnThatCantBeDownsampled = canLooselyCoerceSomeValues && !canDownsampleColumn;
637
-
638
- if (hasDisplayedColumnThatCantBeDownsampled) {
639
- return true;
640
- }
641
-
642
- if (canDownsampleColumn) {
643
- yColumns.push(coercedColumn);
644
- }
645
- }
646
-
647
- return false;
648
- });
649
-
650
- if (canDownsample) {
651
- return {
652
- xColumn: xColumn,
653
- yColumns: yColumns
654
- };
655
- }
656
-
657
- return {
658
- xColumn: [],
659
- yColumns: []
660
- };
661
- };
662
-
663
- var pickIndicesFromDataSource = function pickIndicesFromDataSource(ds, indices) {
664
- var sortedIndices = Array.from(indices).sort(function (a, b) {
665
- return a - b;
666
- });
667
- var slicedColumns = [];
668
- ds.data.columns.forEach(function (column) {
669
- var slicedColumn = [];
670
- sortedIndices.forEach(function (index) {
671
- slicedColumn.push(column[index]);
672
- });
673
- slicedColumns.push(slicedColumn);
674
- }); // update data columns with downsampled columns
675
-
676
- return Object.assign(Object.assign({}, ds), {
677
- data: Object.assign(Object.assign({}, ds.data), {
678
- columns: slicedColumns
679
- })
680
- });
681
- };
682
-
683
- var downsampleDataSources = function downsampleDataSources(_ref4) {
684
- var dataSources = _ref4.dataSources,
685
- threshold = _ref4.threshold,
686
- options = _ref4.options;
687
-
688
- var _a, _b, _c;
689
-
690
- var primaryDS = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary; // only downsample time series when number of data points are over threshold
691
-
692
- var numPoints = (_c = (_b = (_a = primaryDS === null || primaryDS === void 0 ? void 0 : primaryDS.data) === null || _a === void 0 ? void 0 : _a.columns[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
693
-
694
- if (Number.isNaN(threshold) || numPoints <= threshold || threshold < 2) {
695
- return dataSources;
696
- }
697
-
698
- var xField = options.xField,
699
- yFields = options.yFields,
700
- fieldTypes = options.fieldTypes;
701
-
702
- if (!xField || !(yFields === null || yFields === void 0 ? void 0 : yFields.length) || !(fieldTypes === null || fieldTypes === void 0 ? void 0 : fieldTypes.length)) {
703
- return dataSources;
704
- }
705
-
706
- var nonInternalYFields = new Set(yFields.filter(function (yField) {
707
- return !yField.startsWith('_');
708
- }));
709
- var maxPointsInDownsample = Math.min(nonInternalYFields.size * threshold, numPoints); // Do not try to downsample if there are too many downsampled pts
710
- // At the worst case, each series has non-overlapping downsampled pts
711
- // which will mean that all points will be included in the downsampled result
712
- // This will just lead to additional overhead due to coercing each
713
- // x and y field to number
714
-
715
- if (maxPointsInDownsample >= numPoints) {
716
- return dataSources;
717
- }
718
-
719
- var _tryToCoerceAllDispla = tryToCoerceAllDisplayedFields(primaryDS, xField, nonInternalYFields, fieldTypes, options),
720
- xColumn = _tryToCoerceAllDispla.xColumn,
721
- yColumns = _tryToCoerceAllDispla.yColumns;
722
-
723
- if (!yColumns.length || !xColumn.length) {
724
- return dataSources;
725
- }
726
-
727
- var downsampledDataSources = Object.assign({}, dataSources);
728
- var downsampledIndices = new Set();
729
- yColumns.forEach(function (yColumn, columnIndex) {
730
- // perform LTTB downsampling for current series, LTTB takes an [x, y] pair
731
- var xyPair = yColumn.map(function (yValue, index) {
732
- return [xColumn[index], yValue];
733
- });
734
-
735
- try {
736
- var _largestTriangleThree = largestTriangleThreeBuckets(xyPair, threshold, downsampledIndices),
737
- downsampledIndicesForSeries = _largestTriangleThree.downsampledIndices;
738
-
739
- downsampledIndicesForSeries.forEach(function (downsampleIndex) {
740
- return downsampledIndices.add(downsampleIndex);
741
- });
742
- } catch (e) {
743
- // eslint-disable-next-line no-console
744
- console.error("Error occurred while downsampling column ".concat(columnIndex), e);
745
- }
746
- }); // update data columns with downsampled columns
747
-
748
- downsampledDataSources.primary = pickIndicesFromDataSource(primaryDS, downsampledIndices);
749
- return downsampledDataSources;
750
- };
751
-
752
- exports.downsampleDataSources = downsampleDataSources;
753
-
754
- /***/ }),
755
- /* 26 */
756
- /***/ (function(module, exports, __webpack_require__) {
757
-
758
- "use strict";
759
-
760
-
761
- Object.defineProperty(exports, "__esModule", {
762
- value: true
763
- });
764
- exports.validOutputModes = exports.validSortDirs = void 0;
765
- exports.validSortDirs = ['asc', 'desc', 'none'];
766
- exports.validOutputModes = ['json_cols', 'json'];
767
-
768
- /***/ }),
769
- /* 27 */,
770
- /* 28 */
771
- /***/ (function(module, exports) {
772
-
773
- module.exports = require("@splunk/visualization-context/TimezoneContext");
774
-
775
- /***/ }),
776
- /* 29 */
777
- /***/ (function(module, exports) {
778
-
779
- module.exports = require("@splunk/visualizations-shared/style");
780
-
781
- /***/ }),
782
- /* 30 */,
783
- /* 31 */
784
- /***/ (function(module, exports, __webpack_require__) {
785
-
786
- "use strict";
787
-
788
-
789
- Object.defineProperty(exports, "__esModule", {
790
- value: true
791
- });
792
-
793
- var react_1 = __webpack_require__(0);
794
-
795
- function usePrevious(value) {
796
- var ref = (0, react_1.useRef)();
797
- (0, react_1.useEffect)(function () {
798
- ref.current = value;
799
- });
800
- return ref.current;
801
- }
802
-
803
- exports.default = usePrevious;
804
-
805
- /***/ }),
806
- /* 32 */
807
- /***/ (function(module, exports, __webpack_require__) {
808
-
809
- "use strict";
810
-
811
-
812
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
813
- if (k2 === undefined) k2 = k;
814
- var desc = Object.getOwnPropertyDescriptor(m, k);
815
-
816
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
817
- desc = {
818
- enumerable: true,
819
- get: function get() {
820
- return m[k];
821
- }
822
- };
823
- }
824
-
825
- Object.defineProperty(o, k2, desc);
826
- } : function (o, m, k, k2) {
827
- if (k2 === undefined) k2 = k;
828
- o[k2] = m[k];
829
- });
830
-
831
- var __exportStar = this && this.__exportStar || function (m, exports) {
832
- for (var p in m) {
833
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
834
- }
835
- };
836
-
837
- Object.defineProperty(exports, "__esModule", {
838
- value: true
839
- });
840
-
841
- __exportStar(__webpack_require__(33), exports);
842
-
843
- __exportStar(__webpack_require__(34), exports);
844
-
845
- __exportStar(__webpack_require__(26), exports);
846
-
847
- __exportStar(__webpack_require__(35), exports);
848
-
849
- __exportStar(__webpack_require__(36), exports);
850
-
851
- __exportStar(__webpack_require__(37), exports);
852
-
853
- __exportStar(__webpack_require__(38), exports);
854
-
855
- __exportStar(__webpack_require__(39), exports);
856
-
857
- __exportStar(__webpack_require__(40), exports);
858
-
859
- __exportStar(__webpack_require__(14), exports);
860
-
861
- __exportStar(__webpack_require__(18), exports);
862
-
863
- __exportStar(__webpack_require__(19), exports);
864
-
865
- __exportStar(__webpack_require__(41), exports);
866
-
867
- __exportStar(__webpack_require__(42), exports);
868
-
869
- __exportStar(__webpack_require__(43), exports);
870
-
871
- __exportStar(__webpack_require__(44), exports);
872
-
873
- __exportStar(__webpack_require__(45), exports);
874
-
875
- __exportStar(__webpack_require__(46), exports);
876
-
877
- /***/ }),
878
- /* 33 */
879
- /***/ (function(module, exports, __webpack_require__) {
880
-
881
- "use strict";
882
-
883
-
884
- Object.defineProperty(exports, "__esModule", {
885
- value: true
886
- });
887
-
888
- /***/ }),
889
- /* 34 */
890
- /***/ (function(module, exports, __webpack_require__) {
891
-
892
- "use strict";
893
-
894
- /**
895
- * A data structure used at runtime to wire up a visualization.
896
- */
897
-
898
- Object.defineProperty(exports, "__esModule", {
899
- value: true
900
- });
901
-
902
- /***/ }),
903
- /* 35 */
904
- /***/ (function(module, exports, __webpack_require__) {
905
-
906
- "use strict";
907
-
908
-
909
- Object.defineProperty(exports, "__esModule", {
910
- value: true
911
- });
912
-
913
- /***/ }),
914
- /* 36 */
915
- /***/ (function(module, exports, __webpack_require__) {
916
-
917
- "use strict";
918
-
919
-
920
- Object.defineProperty(exports, "__esModule", {
921
- value: true
922
- });
923
-
924
- /***/ }),
925
- /* 37 */
926
- /***/ (function(module, exports, __webpack_require__) {
927
-
928
- "use strict";
929
-
930
-
931
- Object.defineProperty(exports, "__esModule", {
932
- value: true
933
- });
934
-
935
- /***/ }),
936
- /* 38 */
937
- /***/ (function(module, exports, __webpack_require__) {
938
-
939
- "use strict";
940
-
941
-
942
- Object.defineProperty(exports, "__esModule", {
943
- value: true
944
- });
945
-
946
- /***/ }),
947
- /* 39 */
948
- /***/ (function(module, exports, __webpack_require__) {
949
-
950
- "use strict";
951
-
952
-
953
- Object.defineProperty(exports, "__esModule", {
954
- value: true
955
- });
956
-
957
- /***/ }),
958
- /* 40 */
959
- /***/ (function(module, exports, __webpack_require__) {
960
-
961
- "use strict";
962
-
963
-
964
- Object.defineProperty(exports, "__esModule", {
965
- value: true
966
- });
967
-
968
- /***/ }),
969
- /* 41 */
970
- /***/ (function(module, exports, __webpack_require__) {
971
-
972
- "use strict";
973
-
974
-
975
- Object.defineProperty(exports, "__esModule", {
976
- value: true
977
- });
978
-
979
- /***/ }),
980
- /* 42 */
981
- /***/ (function(module, exports, __webpack_require__) {
982
-
983
- "use strict";
984
-
985
-
986
- Object.defineProperty(exports, "__esModule", {
987
- value: true
988
- });
989
-
990
- /***/ }),
991
- /* 43 */
992
- /***/ (function(module, exports, __webpack_require__) {
993
-
994
- "use strict";
995
-
996
-
997
- Object.defineProperty(exports, "__esModule", {
998
- value: true
999
- });
1000
-
1001
- /***/ }),
1002
- /* 44 */
1003
- /***/ (function(module, exports, __webpack_require__) {
1004
-
1005
- "use strict";
1006
-
1007
-
1008
- Object.defineProperty(exports, "__esModule", {
1009
- value: true
1010
- });
1011
-
1012
- /***/ }),
1013
- /* 45 */
1014
- /***/ (function(module, exports, __webpack_require__) {
1015
-
1016
- "use strict";
1017
-
1018
-
1019
- Object.defineProperty(exports, "__esModule", {
1020
- value: true
1021
- });
1022
-
1023
- /***/ }),
1024
- /* 46 */
1025
- /***/ (function(module, exports, __webpack_require__) {
1026
-
1027
- "use strict";
1028
-
1029
-
1030
- Object.defineProperty(exports, "__esModule", {
1031
- value: true
1032
- });
1033
-
1034
- /***/ }),
1035
- /* 47 */,
1036
- /* 48 */,
1037
- /* 49 */,
1038
- /* 50 */,
1039
- /* 51 */,
1040
- /* 52 */,
1041
- /* 53 */,
1042
- /* 54 */,
1043
- /* 55 */,
1044
- /* 56 */,
1045
- /* 57 */
1046
- /***/ (function(module, exports, __webpack_require__) {
1047
-
1048
- "use strict";
1049
-
1050
-
1051
- var _classCallCheck = __webpack_require__(4);
1052
-
1053
- Object.defineProperty(exports, "__esModule", {
1054
- value: true
1055
- });
1056
- exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
1057
- /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
1058
-
1059
- var T = __webpack_require__(1);
1060
-
1061
- var lodash_1 = __webpack_require__(3);
1062
-
1063
- var VizActionHandler_1 = __webpack_require__(14); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
1064
-
1065
-
1066
- exports.INITIAL_WIDTH = 250;
1067
- exports.INITIAL_HEIGHT = 250;
1068
- /**
1069
- * A Splunk visualization
1070
- */
1071
-
1072
- var SplunkVisualization = function SplunkVisualization() {
1073
- _classCallCheck(this, SplunkVisualization);
1074
- };
1075
-
1076
- SplunkVisualization.propTypes = {
1077
- /**
1078
- * display mode
1079
- */
1080
- mode: T.oneOf(['view', 'edit', 'export']).isRequired,
1081
-
1082
- /**
1083
- * width in pixel or string, defaults to 100%
1084
- */
1085
- width: T.oneOfType([T.string, T.number]).isRequired,
1086
-
1087
- /**
1088
- * height in pixel or string
1089
- */
1090
- height: T.oneOfType([T.string, T.number]).isRequired,
1091
-
1092
- /**
1093
- * visualization context used for dynamic option evaluation
1094
- */
1095
- context: T.object,
1096
-
1097
- /**
1098
- * visualization formatting options
1099
- */
1100
- options: T.object,
1101
-
1102
- /**
1103
- * A callback to update formatting options
1104
- */
1105
- onOptionsChange: T.func,
1106
-
1107
- /**
1108
- * datasource state which include data and request params, object key indicate the datasource type.
1109
- */
1110
- dataSources: T.objectOf(T.shape({
1111
- /**
1112
- * current request params
1113
- */
1114
- requestParams: T.object,
1115
-
1116
- /**
1117
- * current dataset
1118
- */
1119
- data: T.shape({
1120
- fields: T.array,
1121
- columns: T.array
1122
- }),
1123
-
1124
- /**
1125
- * error
1126
- */
1127
- error: T.shape({
1128
- level: T.string,
1129
- message: T.string
1130
- }),
1131
-
1132
- /**
1133
- * meta data that came with the dataset
1134
- */
1135
- meta: T.object
1136
- })),
1137
-
1138
- /**
1139
- * A callback to trigger event
1140
- */
1141
- onEventTrigger: T.func,
1142
-
1143
- /**
1144
- * Inform viz if there are handlers listening to events
1145
- */
1146
- hasEventHandlers: T.bool,
1147
-
1148
- /**
1149
- * A callback to communicate computed props to a consumer
1150
- */
1151
- onComputedProps: T.func,
1152
-
1153
- /**
1154
- * A callback to obtain visualization api
1155
- */
1156
- vizActionHandlerRef: T.func,
1157
- loading: T.bool,
1158
- theme: T.object,
1159
-
1160
- /**
1161
- * A callback to request new data with updated request params
1162
- */
1163
- onRequestParamsChange: T.func
1164
- };
1165
- /**
1166
- *
1167
- */
1168
-
1169
- SplunkVisualization.defaultProps = {
1170
- // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
1171
- width: '100%',
1172
- height: exports.INITIAL_HEIGHT,
1173
- dataSources: {},
1174
- onEventTrigger: function onEventTrigger() {
1175
- return {};
1176
- },
1177
- mode: 'view',
1178
- hasEventHandlers: false,
1179
- options: {},
1180
- context: {},
1181
- onOptionsChange: function onOptionsChange() {
1182
- return {};
1183
- },
1184
- vizActionHandlerRef: function vizActionHandlerRef() {
1185
- return new VizActionHandler_1.DefaultVizActionHandler();
1186
- },
1187
- onComputedProps: function onComputedProps() {
1188
- return {};
1189
- },
1190
- loading: false,
1191
- onRequestParamsChange: lodash_1.noop
1192
- };
1193
- exports.default = SplunkVisualization;
1194
-
1195
- /***/ }),
1196
- /* 58 */
1197
- /***/ (function(module, exports) {
1198
-
1199
- module.exports = require("@splunk/themes/variables");
1200
-
1201
- /***/ }),
1202
- /* 59 */,
1203
- /* 60 */,
1204
- /* 61 */,
1205
- /* 62 */
1206
- /***/ (function(module, exports) {
1207
-
1208
- module.exports = require("@splunk/visualization-encoding/Options");
1209
-
1210
- /***/ }),
1211
- /* 63 */
1212
- /***/ (function(module, exports, __webpack_require__) {
1213
-
1214
- "use strict";
1215
-
1216
-
1217
- var _slicedToArray = __webpack_require__(8);
1218
-
1219
- Object.defineProperty(exports, "__esModule", {
1220
- value: true
1221
- });
1222
-
1223
- var React = __webpack_require__(0);
1224
-
1225
- var styled_components_1 = __webpack_require__(2);
1226
-
1227
- var style_1 = __webpack_require__(29);
1228
-
1229
- var colorUtils_1 = __webpack_require__(16);
1230
-
1231
- var SizeAwareWrapper_1 = __webpack_require__(116);
1232
-
1233
- var Item = styled_components_1.default.div.attrs(function (_ref) {
1234
- var width = _ref.width;
1235
- return {
1236
- style: {
1237
- width: (0, style_1.toPx)(width)
1238
- }
1239
- };
1240
- }).withConfig({
1241
- displayName: "FixedSizeContainer__Item",
1242
- componentId: "sc-1yhgpod-0"
1243
- })(["position:relative;background-color:", "};"], function (props) {
1244
- return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
1245
- }); // Use `.attrs()` for highly dynamic styles. Ref: https://github.com/styled-components/styled-components/issues/134#issuecomment-312415291
1246
-
1247
- var FixSizeItem = styled_components_1.default.div.attrs(function (_ref2) {
1248
- var width = _ref2.width,
1249
- height = _ref2.height;
1250
- return {
1251
- style: Object.assign(Object.assign({}, width && {
1252
- width: (0, style_1.toPx)(width)
1253
- }), height && {
1254
- height: (0, style_1.toPx)(height)
1255
- })
1256
- };
1257
- }).withConfig({
1258
- displayName: "FixedSizeContainer__FixSizeItem",
1259
- componentId: "sc-1yhgpod-1"
1260
- })(["position:relative;flex-direction:column;flex:1;display:flex;background-color:", "};"], function (props) {
1261
- return (0, colorUtils_1.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor;
1262
- });
1263
- var ItemContent = styled_components_1.default.div.withConfig({
1264
- displayName: "FixedSizeContainer__ItemContent",
1265
- componentId: "sc-1yhgpod-2"
1266
- })(["position:relative;min-height:100px;width:100%;"]);
1267
- var FixSizeItemContent = styled_components_1.default.div.withConfig({
1268
- displayName: "FixedSizeContainer__FixSizeItemContent",
1269
- componentId: "sc-1yhgpod-3"
1270
- })(["min-height:0px;flex:1;position:relative;box-sizing:border-box;"]);
1271
-
1272
- var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
1273
- var FixedSizeContainer = function FixedSizeContainer(props) {
1274
- var width = props.width,
1275
- height = props.height,
1276
- backgroundColor = props.backgroundColor;
1277
- var cachedHandleResize = React.useCallback(function (w, h) {
1278
- setContainerWidth(w);
1279
- setContainerHeight(h);
1280
- }, []);
1281
-
1282
- var _React$useState = React.useState(Number(props.width)),
1283
- _React$useState2 = _slicedToArray(_React$useState, 2),
1284
- containerWidth = _React$useState2[0],
1285
- setContainerWidth = _React$useState2[1];
1286
-
1287
- var _React$useState3 = React.useState(Number(props.height)),
1288
- _React$useState4 = _slicedToArray(_React$useState3, 2),
1289
- containerHeight = _React$useState4[0],
1290
- setContainerHeight = _React$useState4[1];
1291
-
1292
- if (!height) {
1293
- return React.createElement(Item, {
1294
- "data-test": "item",
1295
- width: width,
1296
- backgroundColor: backgroundColor
1297
- }, React.createElement(ItemContent, null, React.createElement(Viz, Object.assign({}, props))));
1298
- }
1299
-
1300
- return React.createElement(FixSizeItem, {
1301
- "data-test": "fix-size-item",
1302
- "data-splunk-visualization-version": "26.4.1 - 2b7482c08",
1303
- width: width,
1304
- height: height,
1305
- backgroundColor: backgroundColor
1306
- }, React.createElement(FixSizeItemContent, null, React.createElement(SizeAwareWrapper_1.default, {
1307
- width: width,
1308
- height: height,
1309
- onResize: cachedHandleResize
1310
- }), React.createElement(Viz, Object.assign({}, props, {
1311
- width: containerWidth,
1312
- height: containerHeight
1313
- }))));
1314
- };
1315
-
1316
- FixedSizeContainer.displayName = 'withFixedSizeContainer';
1317
- return FixedSizeContainer;
1318
- };
1319
-
1320
- exports.default = withFixedSizeContainer;
1321
-
1322
- /***/ }),
1323
- /* 64 */
1324
- /***/ (function(module, exports, __webpack_require__) {
1325
-
1326
- "use strict";
1327
-
1328
-
1329
- Object.defineProperty(exports, "__esModule", {
1330
- value: true
1331
- });
1332
- exports.extendStaticWrapperProps = void 0;
1333
- /**
1334
- * @method extendStaticWrapperProps
1335
- * @param {Object} props
1336
- * @param {DashboardVizType} props.Wrapper
1337
- * @param {DashboardVizType} props.Visualization
1338
- */
1339
-
1340
- var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
1341
- var Wrapper = _ref.Wrapper,
1342
- Visualization = _ref.Visualization;
1343
- var extendProperties = ['propTypes', 'defaultProps', 'config'];
1344
- extendProperties.forEach(function (prop) {
1345
- if (Visualization[prop]) {
1346
- // eslint-disable-next-line no-param-reassign
1347
- Wrapper[prop] = Visualization[prop];
1348
- }
1349
- });
1350
- };
1351
-
1352
- exports.extendStaticWrapperProps = extendStaticWrapperProps;
1353
-
1354
- /***/ }),
1355
- /* 65 */,
1356
- /* 66 */,
1357
- /* 67 */,
1358
- /* 68 */,
1359
- /* 69 */,
1360
- /* 70 */,
1361
- /* 71 */,
1362
- /* 72 */,
1363
- /* 73 */,
1364
- /* 74 */,
1365
- /* 75 */,
1366
- /* 76 */,
1367
- /* 77 */,
1368
- /* 78 */,
1369
- /* 79 */,
1370
- /* 80 */,
1371
- /* 81 */,
1372
- /* 82 */,
1373
- /* 83 */,
1374
- /* 84 */,
1375
- /* 85 */,
1376
- /* 86 */,
1377
- /* 87 */,
1378
- /* 88 */,
1379
- /* 89 */,
1380
- /* 90 */,
1381
- /* 91 */,
1382
- /* 92 */,
1383
- /* 93 */,
1384
- /* 94 */,
1385
- /* 95 */,
1386
- /* 96 */,
1387
- /* 97 */,
1388
- /* 98 */,
1389
- /* 99 */,
1390
- /* 100 */,
1391
- /* 101 */,
1392
- /* 102 */,
1393
- /* 103 */
1394
- /***/ (function(module, exports, __webpack_require__) {
1395
-
1396
- "use strict";
1397
-
1398
-
1399
- var _slicedToArray = __webpack_require__(8);
1400
-
1401
- Object.defineProperty(exports, "__esModule", {
1402
- value: true
1403
- });
1404
-
1405
- var React = __webpack_require__(0);
1406
-
1407
- var lodash_1 = __webpack_require__(3);
1408
-
1409
- var getSettingsFromThemedProps_1 = __webpack_require__(104);
1410
-
1411
- var Options_1 = __webpack_require__(62);
1412
-
1413
- var SanitizeProps_1 = __webpack_require__(105);
1414
-
1415
- var TimezoneContext_1 = __webpack_require__(28);
1416
-
1417
- var moment_1 = __webpack_require__(106);
1418
-
1419
- var FeatureFlagContext_1 = __webpack_require__(107);
1420
-
1421
- var styled_components_1 = __webpack_require__(2);
1422
-
1423
- var hocUtils_1 = __webpack_require__(108);
1424
-
1425
- var JSONSchemaUtils_1 = __webpack_require__(109);
1426
-
1427
- var async_dynamic_options_evaluator_1 = __webpack_require__(110);
1428
-
1429
- var id_1 = __webpack_require__(111);
1430
-
1431
- var SplunkVisualization_1 = __webpack_require__(57);
1432
-
1433
- var VizBehavior_1 = __webpack_require__(18);
1434
-
1435
- var getSorting_1 = __webpack_require__(112);
1436
-
1437
- var getPagination_1 = __webpack_require__(113);
1438
-
1439
- var useDeepMemo_1 = __webpack_require__(114);
1440
-
1441
- var MissingPropsMessage_1 = __webpack_require__(115);
1442
-
1443
- var withEditModeCover_1 = __webpack_require__(117);
1444
-
1445
- var withPlaceholder_1 = __webpack_require__(118);
1446
-
1447
- var useDownsampleDataSources_1 = __webpack_require__(120);
1448
-
1449
- var dataUtils_1 = __webpack_require__(25);
1450
-
1451
- var featureFlagUtils_1 = __webpack_require__(122);
1452
- /**
1453
- * hoc that wraps a pure react visualization in a Dashboard visualization
1454
- * @param {DashboardVizOpts} opts
1455
- * @returns {HOC}
1456
- */
1457
-
1458
-
1459
- var withDashboardViz = function withDashboardViz(opts) {
1460
- var ReactViz = opts.ReactViz,
1461
- vizConfig = opts.vizConfig,
1462
- _opts$computeVizProps = opts.computeVizProps,
1463
- computeVizProps = _opts$computeVizProps === void 0 ? function () {} : _opts$computeVizProps,
1464
- disableEditModeCover = opts.disableEditModeCover,
1465
- useIconPlaceholder = opts.useIconPlaceholder; // sanitizing props before sending them to reactviz.
1466
-
1467
- var SanitizedReactViz = (0, SanitizeProps_1.withSanitizedProps)(ReactViz);
1468
- var defaultOptions = (0, JSONSchemaUtils_1.pickFieldFromJSONSchema)(vizConfig.optionsSchema, 'default');
1469
-
1470
- var DashboardViz = function DashboardViz(props) {
1471
- var _a;
1472
-
1473
- var mode = props.mode,
1474
- hasEventHandlers = props.hasEventHandlers,
1475
- dataSources = props.dataSources,
1476
- options = props.options,
1477
- _props$context = props.context,
1478
- context = _props$context === void 0 ? {} : _props$context,
1479
- width = props.width,
1480
- height = props.height,
1481
- onComputedProps = props.onComputedProps,
1482
- onEventTrigger = props.onEventTrigger,
1483
- theme = props.theme,
1484
- onRequestParamsChange = props.onRequestParamsChange;
1485
-
1486
- var _React$useContext = React.useContext(TimezoneContext_1.default),
1487
- serializedTimezone = _React$useContext.serializedTimezone;
1488
-
1489
- if (serializedTimezone) {
1490
- /*
1491
- @splunk/moment currently does not allow us to customize the timezone on a per visualization basis.
1492
- This ensures that if a timezone was provided via TimezoneContext @splunk/moment time formatting
1493
- will use it.
1494
- @TODO(pwied):
1495
- - remove when we moved away from @splunk/moment
1496
- - provide timezone context to dynamic option evaluation phase
1497
- */
1498
- if (!moment_1.default.getDefaultSplunkTimezone()) {
1499
- moment_1.default.setDefaultSplunkTimezone(serializedTimezone);
1500
- }
1501
- }
1502
-
1503
- var themeFunc = function themeFunc(themeVar) {
1504
- var _a, _b;
1505
-
1506
- return (_b = (_a = vizConfig.themes)[themeVar]) === null || _b === void 0 ? void 0 : _b.call(_a, props);
1507
- };
1508
-
1509
- var bgColorFromTheme = themeFunc('defaultBackgroundColor');
1510
-
1511
- var _ref = (0, getSettingsFromThemedProps_1.default)({
1512
- theme: theme
1513
- }),
1514
- currentThemeFamily = _ref.family,
1515
- currentThemeColorScheme = _ref.colorScheme,
1516
- currentThemeDensity = _ref.density;
1517
-
1518
- var evaluatedOptions = {}; // evaluatedOptions need to be initialized as an empty object
1519
-
1520
- var _React$useState = React.useState({}),
1521
- _React$useState2 = _slicedToArray(_React$useState, 2),
1522
- evaluatedOptionsAsync = _React$useState2[0],
1523
- setEvaluatedOptionsAsync = _React$useState2[1]; // evaluatedOptions need to be initialized as an empty object
1524
-
1525
-
1526
- var featureFlagContext = React.useContext(FeatureFlagContext_1.default);
1527
-
1528
- var _React$useState3 = React.useState("".concat(vizConfig.name, " - ").concat((0, id_1.createGUID)())),
1529
- _React$useState4 = _slicedToArray(_React$useState3, 1),
1530
- visualizationID = _React$useState4[0];
1531
-
1532
- var _React$useState5 = React.useState({}),
1533
- _React$useState6 = _slicedToArray(_React$useState5, 2),
1534
- dataSourcesInState = _React$useState6[0],
1535
- setDataSourcesInState = _React$useState6[1];
1536
-
1537
- var _React$useState7 = React.useState(),
1538
- _React$useState8 = _slicedToArray(_React$useState7, 2),
1539
- dataFramesInState = _React$useState8[0],
1540
- setDataFramesInState = _React$useState8[1];
1541
-
1542
- var _React$useState9 = React.useState(Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_useWebWorkersForDSL'))),
1543
- _React$useState10 = _slicedToArray(_React$useState9, 2),
1544
- useAsyncEvaluatedOptions = _React$useState10[0],
1545
- setUseAsyncEvaluatedOptions = _React$useState10[1];
1546
-
1547
- var isDownsamplingEnabledByFeatureFlag = Boolean(featureFlagContext === null || featureFlagContext === void 0 ? void 0 : featureFlagContext.visualizations_enableDownsampling);
1548
- var isMounted = React.useRef(true);
1549
- var optionsToEvaluate = React.useMemo(function () {
1550
- return {
1551
- context: (0, lodash_1.defaultsDeep)({}, context, vizConfig.defaultContext),
1552
- options: (0, hocUtils_1.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
1553
- };
1554
- }, [options, context]);
1555
-
1556
- var _React$useState11 = React.useState(Number(width)),
1557
- _React$useState12 = _slicedToArray(_React$useState11, 2),
1558
- threshold = _React$useState12[0],
1559
- setThreshold = _React$useState12[1];
1560
-
1561
- var onDownsamplingThresholdChange = React.useCallback(function (newThreshold) {
1562
- setThreshold(newThreshold);
1563
- }, []);
1564
- var isDownsamplingEnabled = React.useMemo(function () {
1565
- return isDownsamplingEnabledByFeatureFlag && (0, dataUtils_1.isDownsamplingEnabledForViz)({
1566
- vizConfig: vizConfig
1567
- });
1568
- }, [isDownsamplingEnabledByFeatureFlag]);
1569
- var downsamplingProps = React.useMemo(function () {
1570
- if (!isDownsamplingEnabled) {
1571
- return {};
1572
- }
1573
-
1574
- return {
1575
- onDownsamplingThresholdChange: onDownsamplingThresholdChange,
1576
- originalDataSources: dataSources
1577
- };
1578
- }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
1579
- var downsampledDataSources = (0, useDownsampleDataSources_1.default)({
1580
- options: optionsToEvaluate.options,
1581
- context: optionsToEvaluate.context,
1582
- dataSources: dataSources,
1583
- threshold: threshold,
1584
- isDownsamplingEnabled: isDownsamplingEnabled
1585
- });
1586
- evaluatedOptions = (0, useDeepMemo_1.useDeepMemo)(function () {
1587
- try {
1588
- if (useAsyncEvaluatedOptions) {
1589
- var asyncDynamicOptionsEvaluatorParams = {
1590
- visualizationID: visualizationID,
1591
- props: props,
1592
- options: optionsToEvaluate,
1593
- dataSources: downsampledDataSources,
1594
- theme: vizConfig.themes,
1595
- bypassCloneDeepOptionScope: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope')),
1596
- lazyLoadingDataFrame: Boolean((0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'))
1597
- };
1598
- async_dynamic_options_evaluator_1.default.evaluate(asyncDynamicOptionsEvaluatorParams).then(function (results) {
1599
- setEvaluatedOptionsAsync(results.results);
1600
- }).catch(function () {
1601
- if (isMounted.current) {
1602
- setUseAsyncEvaluatedOptions(false);
1603
- }
1604
- });
1605
- } else {
1606
- var dataFrames = dataFramesInState;
1607
-
1608
- if (downsampledDataSources !== dataSourcesInState) {
1609
- setDataSourcesInState(downsampledDataSources);
1610
- dataFrames = Options_1.Options.dataFrameFromDataSource(downsampledDataSources, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_lazyLoadingDataFrame'));
1611
- setDataFramesInState(dataFrames);
1612
- }
1613
-
1614
- var result = Options_1.Options.evaluate(optionsToEvaluate, downsampledDataSources, themeFunc, dataFrames, (0, featureFlagUtils_1.getFeatureFlag)(featureFlagContext, 'visualizations_bypassCloneDeepOptionScope'));
1615
- return result;
1616
- }
1617
- } catch (e) {
1618
- // eslint-disable-next-line no-console
1619
- console.error("unexpected error evaluating options: ".concat(e.message));
1620
- return {};
1621
- }
1622
-
1623
- return {};
1624
- }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, optionsToEvaluate, downsampledDataSources, serializedTimezone, useAsyncEvaluatedOptions]);
1625
- var evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync; // trellis specific backgroundColor update for onComputedProps
1626
- // if trellis is enabled following these three criteria - 1) trellis feature flag is enabled 2) vizConfig supports array has 'trellis' 3) option 'splitByLayout' is set to 'trellis
1627
- // onComputedProps api should return back trellisBackgroundColor value for backgroundColor option to support coloring of sibling panels (for eg:- title/ description on UDF side)
1628
-
1629
- var isTrellisFeatureFlagOn = Boolean(featureFlagContext && featureFlagContext.visualizations_enableTrellis);
1630
- var clonedEvaluatedOptions = evaluatedOptionsToUse;
1631
-
1632
- if (isTrellisFeatureFlagOn && ((_a = vizConfig === null || vizConfig === void 0 ? void 0 : vizConfig.supports) === null || _a === void 0 ? void 0 : _a.includes(VizBehavior_1.VizBehavior.TRELLIS)) && (clonedEvaluatedOptions === null || clonedEvaluatedOptions === void 0 ? void 0 : clonedEvaluatedOptions.splitByLayout) === VizBehavior_1.VizBehavior.TRELLIS) {
1633
- clonedEvaluatedOptions = Object.assign(Object.assign({}, evaluatedOptionsToUse), {
1634
- backgroundColor: clonedEvaluatedOptions === null || clonedEvaluatedOptions === void 0 ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
1635
- });
1636
- } // useEffect hook needs to be initialized before any early returns
1637
- // this is in accordance with the order of hook calls being the same on each render https://reactjs.org/docs/hooks-rules.html#explanation
1638
-
1639
-
1640
- React.useEffect(function () {
1641
- onComputedProps(clonedEvaluatedOptions);
1642
- });
1643
- React.useEffect(function () {
1644
- return function () {
1645
- if (useAsyncEvaluatedOptions) {
1646
- isMounted.current = false;
1647
- async_dynamic_options_evaluator_1.default.reset(visualizationID);
1648
- }
1649
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
1650
- }, []); // present warning message if any required props are missing
1651
-
1652
- var _vizConfig$requiredPr = vizConfig.requiredProps,
1653
- requiredProps = _vizConfig$requiredPr === void 0 ? [] : _vizConfig$requiredPr,
1654
- supports = vizConfig.supports;
1655
- var missing = (0, MissingPropsMessage_1.missingKeys)(requiredProps, evaluatedOptionsToUse);
1656
-
1657
- if (missing.length > 0 && supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && vizConfig.key !== 'splunk.singlevalue' // For SV missing props msg is not displayed if required props majorValue is missing, instead this will be handled from the component, instead handled within component
1658
- ) {
1659
- return React.createElement(MissingPropsMessage_1.default, {
1660
- "data-test": "missing-props-message",
1661
- width: width,
1662
- height: height,
1663
- missingProps: missing,
1664
- backgroundColor: bgColorFromTheme
1665
- });
1666
- } // events
1667
-
1668
-
1669
- var eventCallbackProps = {};
1670
-
1671
- if (hasEventHandlers && mode === 'view' && vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.EVENTS) > -1) {
1672
- var supportedEvents = vizConfig.events;
1673
- Object.keys(supportedEvents).forEach(function (eventName) {
1674
- var _supportedEvents$even = supportedEvents[eventName],
1675
- parentKeys = _supportedEvents$even.parentKeys,
1676
- payloadKeys = _supportedEvents$even.payloadKeys;
1677
- var eventCallbackPropName = (0, lodash_1.camelCase)("on.".concat(eventName)); // todo: refactor single value and single value icon to send payload from viz
1678
- // then remove these lines
1679
-
1680
- var payload = {};
1681
-
1682
- if (Array.isArray(payloadKeys) && payloadKeys.length) {
1683
- payloadKeys.forEach(function (p) {
1684
- payload[p] = evaluatedOptionsToUse[p];
1685
- });
1686
- }
1687
-
1688
- eventCallbackProps[eventCallbackPropName] = function (ev) {
1689
- if (ev && ev.payload) {
1690
- payload = ev.payload;
1691
- }
1692
-
1693
- return onEventTrigger({
1694
- originalEvent: ev,
1695
- payload: payload,
1696
- type: eventName
1697
- });
1698
- };
1699
-
1700
- if (parentKeys) {
1701
- for (var i = parentKeys.length - 1; i >= 0; i -= 1) {
1702
- var newObject = {};
1703
- newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
1704
- eventCallbackProps[eventCallbackPropName] = newObject;
1705
- }
1706
- }
1707
- });
1708
- } // compute pure viz props which are not from options
1709
-
1710
-
1711
- var computedVizProps = computeVizProps(Object.assign(Object.assign(Object.assign(Object.assign({}, props), evaluatedOptionsToUse), eventCallbackProps), {
1712
- themeFunc: themeFunc
1713
- }));
1714
- /**
1715
- * PAGE_AND_SORT behavior
1716
- *
1717
- * Some visualizations, like table, requires metadata about the datasource,
1718
- * like total number of results, current count, offset, and sort, for rendering
1719
- * paginator and sorting direction. In this approach, the visualization
1720
- * allow users to set 'paginateDataSourceKey' to select which datasource
1721
- * should the visualization extract the metadata from. It defaults to 'primary' datasource.
1722
- * The visualization config should set the PAGE_AND_SORT behavior to receive
1723
- * 'requestParams', 'meta' and onRequestParams callback as props.
1724
- *
1725
- * In future, we could automatically detect which all datasources are being used
1726
- * and bind those magically to pagination/sorting behavior.
1727
- */
1728
-
1729
- var dataSourceMetadata = {};
1730
- var OptionKey = 'paginateDataSourceKey';
1731
- var paginateDataSourceKey = (0, lodash_1.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || 'primary';
1732
-
1733
- if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.PAGE_AND_SORT) > -1 && (0, lodash_1.has)(dataSources, paginateDataSourceKey)) {
1734
- var requestParams = (0, lodash_1.get)(dataSources, [paginateDataSourceKey, 'requestParams'], {});
1735
- var meta = (0, lodash_1.get)(dataSources, [paginateDataSourceKey, 'meta'], {});
1736
-
1737
- var handleRequestParamsChange = function handleRequestParamsChange(payload) {
1738
- return onRequestParamsChange(paginateDataSourceKey, payload);
1739
- };
1740
-
1741
- var sortParams = (0, getSorting_1.getSortingParams)({
1742
- requestParams: requestParams,
1743
- meta: meta,
1744
- onRequestParamsChange: handleRequestParamsChange
1745
- });
1746
- var paginatorParams = (0, getPagination_1.getPaginationParams)({
1747
- requestParams: requestParams,
1748
- meta: meta,
1749
- onRequestParamsChange: handleRequestParamsChange
1750
- });
1751
- dataSourceMetadata = {
1752
- sortParams: sortParams,
1753
- paginatorParams: paginatorParams
1754
- };
1755
- } // if were using webworkers and this is the first render we dont want to show a viz with missing data so we return null
1756
-
1757
-
1758
- if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
1759
- return null;
1760
- }
1761
-
1762
- return React.createElement(SanitizedReactViz, Object.assign({
1763
- mode: mode,
1764
- width: width,
1765
- height: height
1766
- }, downsamplingProps, evaluatedOptionsToUse, computedVizProps, eventCallbackProps, dataSourceMetadata));
1767
- };
1768
-
1769
- DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
1770
- DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
1771
- // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1772
- theme: {}
1773
- }); // attach viz config
1774
-
1775
- DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
1776
-
1777
- return (0, styled_components_1.withTheme)((0, withPlaceholder_1.default)((0, withEditModeCover_1.default)(DashboardViz, disableEditModeCover), useIconPlaceholder));
1778
- };
1779
-
1780
- exports.default = withDashboardViz;
1781
-
1782
- /***/ }),
1783
- /* 104 */
1784
- /***/ (function(module, exports) {
1785
-
1786
- module.exports = require("@splunk/themes/getSettingsFromThemedProps");
1787
-
1788
- /***/ }),
1789
- /* 105 */
1790
- /***/ (function(module, exports) {
1791
-
1792
- module.exports = require("@splunk/visualizations-shared/SanitizeProps");
1793
-
1794
- /***/ }),
1795
- /* 106 */
1796
- /***/ (function(module, exports) {
1797
-
1798
- module.exports = require("@splunk/moment");
1799
-
1800
- /***/ }),
1801
- /* 107 */
1802
- /***/ (function(module, exports) {
1803
-
1804
- module.exports = require("@splunk/visualization-context/FeatureFlagContext");
1805
-
1806
- /***/ }),
1807
- /* 108 */
1808
- /***/ (function(module, exports) {
1809
-
1810
- module.exports = require("@splunk/visualizations-shared/hocUtils");
1811
-
1812
- /***/ }),
1813
- /* 109 */
1814
- /***/ (function(module, exports) {
1815
-
1816
- module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");
1817
-
1818
- /***/ }),
1819
- /* 110 */
1820
- /***/ (function(module, exports) {
1821
-
1822
- module.exports = require("@splunk/async-dynamic-options-evaluator");
1823
-
1824
- /***/ }),
1825
- /* 111 */
1826
- /***/ (function(module, exports) {
1827
-
1828
- module.exports = require("@splunk/ui-utils/id");
1829
-
1830
- /***/ }),
1831
- /* 112 */
1832
- /***/ (function(module, exports, __webpack_require__) {
1833
-
1834
- "use strict";
1835
-
1836
-
1837
- var _defineProperty = __webpack_require__(10);
1
+ /* Copyright © 2020 Splunk Inc.
2
+ SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
+ in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __getProtoOf = Object.getPrototypeOf;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ var __export = (target, all) => {
28
+ for (var name in all)
29
+ __defProp(target, name, { get: all[name], enumerable: true });
30
+ };
31
+ var __copyProps = (to, from, except, desc) => {
32
+ if (from && typeof from === "object" || typeof from === "function") {
33
+ for (let key of __getOwnPropNames(from))
34
+ if (!__hasOwnProp.call(to, key) && key !== except)
35
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
36
+ }
37
+ return to;
38
+ };
39
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
40
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
41
+ // If the importer is in node compatibility mode or this is not an ESM
42
+ // file that has been converted to a CommonJS file using a Babel-
43
+ // compatible transform (i.e. "__esModule" has not been set), then set
44
+ // "default" to the CommonJS "module.exports" for node compatibility.
45
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
46
+ mod
47
+ ));
48
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
49
+
50
+ // src/common/withDashboardViz.tsx
51
+ var withDashboardViz_exports = {};
52
+ __export(withDashboardViz_exports, {
53
+ default: () => withDashboardViz_default
54
+ });
55
+ module.exports = __toCommonJS(withDashboardViz_exports);
1838
56
 
1839
- Object.defineProperty(exports, "__esModule", {
1840
- value: true
57
+ // esm-externals:react
58
+ var react_exports = {};
59
+ __export(react_exports, {
60
+ default: () => react_default
61
+ });
62
+ var defaultImport = __toESM(require("react"));
63
+ __reExport(react_exports, require("react"));
64
+ var react_default = "default" in defaultImport ? defaultImport.default : defaultImport;
65
+
66
+ // esm-externals:lodash
67
+ var lodash_exports = {};
68
+ __export(lodash_exports, {
69
+ default: () => lodash_default
70
+ });
71
+ var defaultImport2 = __toESM(require("lodash"));
72
+ __reExport(lodash_exports, require("lodash"));
73
+ var lodash_default = "default" in defaultImport2 ? defaultImport2.default : defaultImport2;
74
+
75
+ // esm-externals:@splunk/themes/getSettingsFromThemedProps
76
+ var getSettingsFromThemedProps_exports = {};
77
+ __export(getSettingsFromThemedProps_exports, {
78
+ default: () => getSettingsFromThemedProps_default
79
+ });
80
+ var defaultImport3 = __toESM(require("@splunk/themes/getSettingsFromThemedProps"));
81
+ __reExport(getSettingsFromThemedProps_exports, require("@splunk/themes/getSettingsFromThemedProps"));
82
+ var getSettingsFromThemedProps_default = "default" in defaultImport3 ? defaultImport3.default : defaultImport3;
83
+
84
+ // esm-externals:@splunk/visualization-encoding/Options
85
+ var Options_exports = {};
86
+ __export(Options_exports, {
87
+ default: () => Options_default
88
+ });
89
+ var defaultImport4 = __toESM(require("@splunk/visualization-encoding/Options"));
90
+ __reExport(Options_exports, require("@splunk/visualization-encoding/Options"));
91
+ var Options_default = "default" in defaultImport4 ? defaultImport4.default : defaultImport4;
92
+
93
+ // esm-externals:@splunk/visualizations-shared/SanitizeProps
94
+ var SanitizeProps_exports = {};
95
+ __export(SanitizeProps_exports, {
96
+ default: () => SanitizeProps_default
97
+ });
98
+ var defaultImport5 = __toESM(require("@splunk/visualizations-shared/SanitizeProps"));
99
+ __reExport(SanitizeProps_exports, require("@splunk/visualizations-shared/SanitizeProps"));
100
+ var SanitizeProps_default = "default" in defaultImport5 ? defaultImport5.default : defaultImport5;
101
+
102
+ // esm-externals:@splunk/visualization-context/TimezoneContext
103
+ var TimezoneContext_exports = {};
104
+ __export(TimezoneContext_exports, {
105
+ default: () => TimezoneContext_default
106
+ });
107
+ var defaultImport6 = __toESM(require("@splunk/visualization-context/TimezoneContext"));
108
+ __reExport(TimezoneContext_exports, require("@splunk/visualization-context/TimezoneContext"));
109
+ var TimezoneContext_default = "default" in defaultImport6 ? defaultImport6.default : defaultImport6;
110
+
111
+ // esm-externals:@splunk/moment
112
+ var moment_exports = {};
113
+ __export(moment_exports, {
114
+ default: () => moment_default
115
+ });
116
+ var defaultImport7 = __toESM(require("@splunk/moment"));
117
+ __reExport(moment_exports, require("@splunk/moment"));
118
+ var moment_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;
119
+
120
+ // esm-externals:@splunk/visualization-context/FeatureFlagContext
121
+ var FeatureFlagContext_exports = {};
122
+ __export(FeatureFlagContext_exports, {
123
+ default: () => FeatureFlagContext_default
124
+ });
125
+ var defaultImport8 = __toESM(require("@splunk/visualization-context/FeatureFlagContext"));
126
+ __reExport(FeatureFlagContext_exports, require("@splunk/visualization-context/FeatureFlagContext"));
127
+ var FeatureFlagContext_default = "default" in defaultImport8 ? defaultImport8.default : defaultImport8;
128
+
129
+ // esm-externals:styled-components
130
+ var styled_components_exports = {};
131
+ __export(styled_components_exports, {
132
+ default: () => styled_components_default
133
+ });
134
+ var defaultImport9 = __toESM(require("styled-components"));
135
+ __reExport(styled_components_exports, require("styled-components"));
136
+ var styled_components_default = "default" in defaultImport9 ? defaultImport9.default : defaultImport9;
137
+
138
+ // esm-externals:@splunk/visualizations-shared/hocUtils
139
+ var hocUtils_exports = {};
140
+ __export(hocUtils_exports, {
141
+ default: () => hocUtils_default
1841
142
  });
1842
- exports.getSortingParams = exports.SortParamsPropTypes = void 0;
143
+ var defaultImport10 = __toESM(require("@splunk/visualizations-shared/hocUtils"));
144
+ __reExport(hocUtils_exports, require("@splunk/visualizations-shared/hocUtils"));
145
+ var hocUtils_default = "default" in defaultImport10 ? defaultImport10.default : defaultImport10;
146
+
147
+ // esm-externals:@splunk/visualizations-shared/JSONSchemaUtils
148
+ var JSONSchemaUtils_exports = {};
149
+ __export(JSONSchemaUtils_exports, {
150
+ default: () => JSONSchemaUtils_default
151
+ });
152
+ var defaultImport11 = __toESM(require("@splunk/visualizations-shared/JSONSchemaUtils"));
153
+ __reExport(JSONSchemaUtils_exports, require("@splunk/visualizations-shared/JSONSchemaUtils"));
154
+ var JSONSchemaUtils_default = "default" in defaultImport11 ? defaultImport11.default : defaultImport11;
155
+
156
+ // esm-externals:@splunk/async-dynamic-options-evaluator
157
+ var async_dynamic_options_evaluator_exports = {};
158
+ __export(async_dynamic_options_evaluator_exports, {
159
+ default: () => async_dynamic_options_evaluator_default
160
+ });
161
+ var defaultImport12 = __toESM(require("@splunk/async-dynamic-options-evaluator"));
162
+ __reExport(async_dynamic_options_evaluator_exports, require("@splunk/async-dynamic-options-evaluator"));
163
+ var async_dynamic_options_evaluator_default = "default" in defaultImport12 ? defaultImport12.default : defaultImport12;
164
+
165
+ // esm-externals:@splunk/ui-utils/id
166
+ var id_exports = {};
167
+ __export(id_exports, {
168
+ default: () => id_default
169
+ });
170
+ var defaultImport13 = __toESM(require("@splunk/ui-utils/id"));
171
+ __reExport(id_exports, require("@splunk/ui-utils/id"));
172
+ var id_default = "default" in defaultImport13 ? defaultImport13.default : defaultImport13;
173
+
174
+ // esm-externals:prop-types
175
+ var prop_types_exports = {};
176
+ __export(prop_types_exports, {
177
+ default: () => prop_types_default
178
+ });
179
+ var defaultImport14 = __toESM(require("prop-types"));
180
+ __reExport(prop_types_exports, require("prop-types"));
181
+ var prop_types_default = "default" in defaultImport14 ? defaultImport14.default : defaultImport14;
1843
182
 
1844
- var T = __webpack_require__(1);
183
+ // src/common/interfaces/VizActionHandler.ts
184
+ var DefaultVizActionHandler = class {
185
+ focus() {
186
+ }
187
+ snapshot() {
188
+ return null;
189
+ }
190
+ };
1845
191
 
1846
- var lodash_1 = __webpack_require__(3);
192
+ // src/common/SplunkVisualization.tsx
193
+ var INITIAL_HEIGHT = 250;
194
+ var SplunkVisualization = class {
195
+ };
196
+ SplunkVisualization.propTypes = {
197
+ /**
198
+ * display mode
199
+ */
200
+ mode: prop_types_exports.oneOf(["view", "edit", "export"]).isRequired,
201
+ /**
202
+ * width in pixel or string, defaults to 100%
203
+ */
204
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]).isRequired,
205
+ /**
206
+ * height in pixel or string
207
+ */
208
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]).isRequired,
209
+ /**
210
+ * visualization context used for dynamic option evaluation
211
+ */
212
+ context: prop_types_exports.object,
213
+ /**
214
+ * visualization formatting options
215
+ */
216
+ options: prop_types_exports.object,
217
+ /**
218
+ * A callback to update formatting options
219
+ */
220
+ onOptionsChange: prop_types_exports.func,
221
+ /**
222
+ * datasource state which include data and request params, object key indicate the datasource type.
223
+ */
224
+ dataSources: prop_types_exports.objectOf(
225
+ prop_types_exports.shape({
226
+ /**
227
+ * current request params
228
+ */
229
+ requestParams: prop_types_exports.object,
230
+ /**
231
+ * current dataset
232
+ */
233
+ data: prop_types_exports.shape({
234
+ fields: prop_types_exports.array,
235
+ columns: prop_types_exports.array
236
+ }),
237
+ /**
238
+ * error
239
+ */
240
+ error: prop_types_exports.shape({
241
+ level: prop_types_exports.string,
242
+ message: prop_types_exports.string
243
+ }),
244
+ /**
245
+ * meta data that came with the dataset
246
+ */
247
+ meta: prop_types_exports.object
248
+ })
249
+ ),
250
+ /**
251
+ * A callback to trigger event
252
+ */
253
+ onEventTrigger: prop_types_exports.func,
254
+ /**
255
+ * Inform viz if there are handlers listening to events
256
+ */
257
+ hasEventHandlers: prop_types_exports.bool,
258
+ /**
259
+ * A callback to communicate computed props to a consumer
260
+ */
261
+ onComputedProps: prop_types_exports.func,
262
+ /**
263
+ * A callback to obtain visualization api
264
+ */
265
+ vizActionHandlerRef: prop_types_exports.func,
266
+ loading: prop_types_exports.bool,
267
+ theme: prop_types_exports.object,
268
+ /**
269
+ * A callback to request new data with updated request params
270
+ */
271
+ onRequestParamsChange: prop_types_exports.func
272
+ };
273
+ /**
274
+ *
275
+ */
276
+ SplunkVisualization.defaultProps = {
277
+ // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
278
+ width: "100%",
279
+ height: INITIAL_HEIGHT,
280
+ dataSources: {},
281
+ onEventTrigger: () => ({}),
282
+ mode: "view",
283
+ hasEventHandlers: false,
284
+ options: {},
285
+ context: {},
286
+ onOptionsChange: () => ({}),
287
+ vizActionHandlerRef: () => new DefaultVizActionHandler(),
288
+ onComputedProps: () => ({}),
289
+ loading: false,
290
+ onRequestParamsChange: lodash_exports.noop
291
+ };
292
+ var SplunkVisualization_default = SplunkVisualization;
1847
293
 
1848
- var DataSource_1 = __webpack_require__(26);
294
+ // src/common/interfaces/DataSource.ts
295
+ var validSortDirs = ["asc", "desc", "none"];
1849
296
 
1850
- exports.SortParamsPropTypes = T.shape({
1851
- currentSortKey: T.string,
1852
- currentSortDir: T.oneOf(DataSource_1.validSortDirs),
1853
- onSort: T.func
297
+ // src/common/hooks/getSorting.ts
298
+ var SortParamsPropTypes = prop_types_exports.shape({
299
+ currentSortKey: prop_types_exports.string,
300
+ currentSortDir: prop_types_exports.oneOf(validSortDirs),
301
+ onSort: prop_types_exports.func
1854
302
  });
1855
-
1856
- var getSortingParams = function getSortingParams(_ref) {
1857
- var requestParams = _ref.requestParams,
1858
- onRequestParamsChange = _ref.onRequestParamsChange;
1859
- var currentSortKey;
1860
- var currentSortDir;
1861
- var nextSortDirMap = {
1862
- asc: 'desc',
1863
- desc: 'asc',
1864
- none: 'asc'
303
+ var getSortingParams = ({ requestParams, onRequestParamsChange }) => {
304
+ let currentSortKey;
305
+ let currentSortDir;
306
+ const nextSortDirMap = {
307
+ asc: "desc",
308
+ desc: "asc",
309
+ none: "asc"
1865
310
  };
1866
- var onSort;
1867
-
1868
- if (typeof onRequestParamsChange === 'function') {
1869
- if (requestParams && (0, lodash_1.has)(requestParams, 'sort')) {
311
+ let onSort;
312
+ if (typeof onRequestParamsChange === "function") {
313
+ if (requestParams && (0, lodash_exports.has)(requestParams, "sort")) {
1870
314
  currentSortKey = Object.keys(requestParams.sort).shift();
1871
315
  currentSortDir = requestParams.sort[currentSortKey];
1872
- } // undid memoization since there is a dependency on requestParams, which is a deeply nested object
1873
-
1874
-
1875
- onSort = function onSort(e, _ref2) {
1876
- var sortKey = _ref2.sortKey,
1877
- sortDir = _ref2.sortDir;
1878
-
1879
- if (typeof sortKey === 'string') {
1880
- var nextSortDir = (0, lodash_1.has)(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : 'none';
1881
- onRequestParamsChange(Object.assign(Object.assign({}, requestParams), {
1882
- offset: 0,
1883
- sort: _defineProperty({}, sortKey, nextSortDir)
1884
- }));
316
+ }
317
+ onSort = (e, { sortKey, sortDir }) => {
318
+ if (typeof sortKey === "string") {
319
+ const nextSortDir = (0, lodash_exports.has)(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : "none";
320
+ onRequestParamsChange(__spreadValues(__spreadValues({}, requestParams), { offset: 0, sort: { [sortKey]: nextSortDir } }));
1885
321
  } else {
1886
322
  onRequestParamsChange(requestParams);
1887
323
  }
1888
324
  };
1889
325
  }
1890
-
1891
326
  return {
1892
- currentSortKey: currentSortKey,
1893
- currentSortDir: currentSortDir,
1894
- onSort: onSort
327
+ currentSortKey,
328
+ currentSortDir,
329
+ onSort
1895
330
  };
1896
331
  };
1897
332
 
1898
- exports.getSortingParams = getSortingParams;
1899
-
1900
- /***/ }),
1901
- /* 113 */
1902
- /***/ (function(module, exports, __webpack_require__) {
1903
-
1904
- "use strict";
1905
-
1906
-
1907
- Object.defineProperty(exports, "__esModule", {
1908
- value: true
1909
- });
1910
- exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;
1911
-
1912
- var T = __webpack_require__(1);
1913
-
1914
- var lodash_1 = __webpack_require__(3);
1915
-
1916
- exports.PaginatorParamsPropTypes = T.shape({
1917
- isPaging: T.bool,
1918
- current: T.number,
1919
- totalPages: T.number,
1920
- onChange: T.func
333
+ // src/common/hooks/getPagination.ts
334
+ var PaginatorParamsPropTypes = prop_types_exports.shape({
335
+ isPaging: prop_types_exports.bool,
336
+ current: prop_types_exports.number,
337
+ totalPages: prop_types_exports.number,
338
+ onChange: prop_types_exports.func
1921
339
  });
1922
-
1923
- var getPaginationParams = function getPaginationParams(_ref) {
1924
- var requestParams = _ref.requestParams,
1925
- meta = _ref.meta,
1926
- onRequestParamsChange = _ref.onRequestParamsChange;
1927
- var totalCount = meta && meta.totalCount || 0;
1928
- var offset = requestParams && requestParams.offset || 0;
1929
- var count = requestParams && requestParams.count;
1930
- var totalPages = typeof count === 'number' && count > 0 ? Math.ceil(totalCount / count) : 0;
1931
- var current = typeof count === 'number' && count > 0 ? Math.floor(offset / count) + 1 : 0;
1932
- var isPaging = totalPages > 1 && typeof onRequestParamsChange === 'function';
1933
-
1934
- var onChangeHandler = function onChangeHandler(e, _ref2) {
1935
- var page = _ref2.page,
1936
- countArg = _ref2.count;
1937
- var newParams = (0, lodash_1.cloneDeep)(requestParams);
1938
-
1939
- if (typeof countArg === 'number') {
340
+ var getPaginationParams = ({
341
+ requestParams,
342
+ meta,
343
+ onRequestParamsChange
344
+ }) => {
345
+ const totalCount = meta && meta.totalCount || 0;
346
+ const offset = requestParams && requestParams.offset || 0;
347
+ const count = requestParams && requestParams.count;
348
+ const totalPages = typeof count === "number" && count > 0 ? Math.ceil(totalCount / count) : 0;
349
+ const current = typeof count === "number" && count > 0 ? Math.floor(offset / count) + 1 : 0;
350
+ const isPaging = totalPages > 1 && typeof onRequestParamsChange === "function";
351
+ const onChangeHandler = (e, { page, count: countArg }) => {
352
+ const newParams = (0, lodash_exports.cloneDeep)(requestParams);
353
+ if (typeof countArg === "number") {
1940
354
  newParams.count = countArg;
1941
355
  newParams.offset = 0;
1942
356
  }
1943
-
1944
- var pageCount = typeof newParams.count === 'number' ? newParams.count : 10;
1945
-
1946
- if (typeof page === 'number' && page > 0) {
357
+ const pageCount = typeof newParams.count === "number" ? newParams.count : 10;
358
+ if (typeof page === "number" && page > 0) {
1947
359
  newParams.count = pageCount;
1948
360
  newParams.offset = (page - 1) * pageCount;
1949
361
  }
1950
-
1951
362
  onRequestParamsChange(newParams);
1952
363
  };
1953
-
1954
364
  return {
1955
- isPaging: isPaging,
1956
- current: current,
1957
- totalPages: totalPages,
1958
- onChange: typeof onRequestParamsChange === 'function' ? onChangeHandler : lodash_1.noop
365
+ isPaging,
366
+ current,
367
+ totalPages,
368
+ onChange: typeof onRequestParamsChange === "function" ? onChangeHandler : lodash_exports.noop
1959
369
  };
1960
370
  };
1961
371
 
1962
- exports.getPaginationParams = getPaginationParams;
1963
-
1964
- /***/ }),
1965
- /* 114 */
1966
- /***/ (function(module, exports, __webpack_require__) {
1967
-
1968
- "use strict";
1969
-
1970
-
1971
- Object.defineProperty(exports, "__esModule", {
1972
- value: true
1973
- });
1974
- exports.useDeepMemo = void 0;
1975
-
1976
- var react_1 = __webpack_require__(0);
1977
-
1978
- var lodash_1 = __webpack_require__(3);
1979
- /**
1980
- * This hook evaluates and stores the result of a passed function and only
1981
- * re-evaluates the function when passed dependencies change.
1982
- *
1983
- * It is different from the internal React useMemo in the following aspects:
1984
- * - it only stores the last evaluated result
1985
- * - it uses a deep equality check to determine if dependencies have changed
1986
- *
1987
- * Inspired by apollo-client's useDeepMemo
1988
- *
1989
- * @param fn the function to be executed and
1990
- * @param dependencies an array of dependencies
1991
- */
1992
-
1993
-
1994
- var useDeepMemo = function useDeepMemo(fn, dependencies) {
1995
- var ref = (0, react_1.useRef)();
1996
-
1997
- if (!ref.current || !(0, lodash_1.isEqual)(dependencies, ref.current.dependencies)) {
372
+ // src/common/hooks/useDeepMemo.ts
373
+ var useDeepMemo = (fn, dependencies) => {
374
+ const ref = (0, react_exports.useRef)();
375
+ if (!ref.current || !(0, lodash_exports.isEqual)(dependencies, ref.current.dependencies)) {
1998
376
  ref.current = {
1999
- dependencies: dependencies,
377
+ dependencies,
2000
378
  value: fn()
2001
379
  };
2002
380
  }
2003
-
2004
381
  return ref.current.value;
2005
382
  };
2006
383
 
2007
- exports.useDeepMemo = useDeepMemo;
2008
-
2009
- /***/ }),
2010
- /* 115 */
2011
- /***/ (function(module, exports, __webpack_require__) {
2012
-
2013
- "use strict";
2014
-
2015
-
2016
- Object.defineProperty(exports, "__esModule", {
2017
- value: true
384
+ // esm-externals:@splunk/ui-utils/i18n
385
+ var i18n_exports = {};
386
+ __export(i18n_exports, {
387
+ default: () => i18n_default
2018
388
  });
2019
- exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
2020
-
2021
- var React = __webpack_require__(0);
2022
-
2023
- var T = __webpack_require__(1);
2024
-
2025
- var i18n_1 = __webpack_require__(5);
2026
-
2027
- var Message_1 = __webpack_require__(24);
2028
-
2029
- var FixedSizeContainer_1 = __webpack_require__(63);
2030
- /**
2031
- * @method isMissing
2032
- * @param {any} v
2033
- * @returns {boolean} true if the input value === null or undefined
2034
- */
2035
-
2036
-
2037
- var isMissing = function isMissing(v) {
2038
- return v === null || v === undefined;
389
+ var defaultImport15 = __toESM(require("@splunk/ui-utils/i18n"));
390
+ __reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
391
+ var i18n_default = "default" in defaultImport15 ? defaultImport15.default : defaultImport15;
392
+
393
+ // esm-externals:@splunk/visualizations-shared/Message
394
+ var Message_exports = {};
395
+ __export(Message_exports, {
396
+ default: () => Message_default
397
+ });
398
+ var defaultImport16 = __toESM(require("@splunk/visualizations-shared/Message"));
399
+ __reExport(Message_exports, require("@splunk/visualizations-shared/Message"));
400
+ var Message_default = "default" in defaultImport16 ? defaultImport16.default : defaultImport16;
401
+
402
+ // esm-externals:@splunk/visualizations-shared/style
403
+ var style_exports = {};
404
+ __export(style_exports, {
405
+ default: () => style_default
406
+ });
407
+ var defaultImport17 = __toESM(require("@splunk/visualizations-shared/style"));
408
+ __reExport(style_exports, require("@splunk/visualizations-shared/style"));
409
+ var style_default = "default" in defaultImport17 ? defaultImport17.default : defaultImport17;
410
+
411
+ // esm-externals:@splunk/visualizations-shared/colorUtils
412
+ var colorUtils_exports = {};
413
+ __export(colorUtils_exports, {
414
+ default: () => colorUtils_default
415
+ });
416
+ var defaultImport18 = __toESM(require("@splunk/visualizations-shared/colorUtils"));
417
+ __reExport(colorUtils_exports, require("@splunk/visualizations-shared/colorUtils"));
418
+ var colorUtils_default = "default" in defaultImport18 ? defaultImport18.default : defaultImport18;
419
+
420
+ // esm-externals:@splunk/visualizations-shared/SizeAwareWrapper
421
+ var SizeAwareWrapper_exports = {};
422
+ __export(SizeAwareWrapper_exports, {
423
+ default: () => SizeAwareWrapper_default
424
+ });
425
+ var defaultImport19 = __toESM(require("@splunk/visualizations-shared/SizeAwareWrapper"));
426
+ __reExport(SizeAwareWrapper_exports, require("@splunk/visualizations-shared/SizeAwareWrapper"));
427
+ var SizeAwareWrapper_default = "default" in defaultImport19 ? defaultImport19.default : defaultImport19;
428
+
429
+ // src/common/hocs/FixedSizeContainer.tsx
430
+ var Item = styled_components_default.div.attrs(({ width }) => ({
431
+ style: {
432
+ width: (0, style_exports.toPx)(width)
433
+ }
434
+ }))`
435
+ position: relative;
436
+ background-color: ${(props) => (0, colorUtils_exports.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor}};
437
+ `;
438
+ var FixSizeItem = styled_components_default.div.attrs(({ width, height }) => ({
439
+ style: __spreadValues(__spreadValues({}, width && { width: (0, style_exports.toPx)(width) }), height && { height: (0, style_exports.toPx)(height) })
440
+ }))`
441
+ position: relative;
442
+ flex-direction: column;
443
+ flex: 1;
444
+ display: flex;
445
+ background-color: ${(props) => (0, colorUtils_exports.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor}};
446
+ `;
447
+ var ItemContent = styled_components_default.div`
448
+ position: relative;
449
+ min-height: 100px;
450
+ width: 100%;
451
+ `;
452
+ var FixSizeItemContent = styled_components_default.div`
453
+ min-height: 0px;
454
+ flex: 1;
455
+ position: relative;
456
+ box-sizing: border-box;
457
+ `;
458
+ var withFixedSizeContainer = (Viz) => {
459
+ const FixedSizeContainer = (props) => {
460
+ const { width, height, backgroundColor } = props;
461
+ const cachedHandleResize = react_exports.useCallback((w, h) => {
462
+ setContainerWidth(w);
463
+ setContainerHeight(h);
464
+ }, []);
465
+ const [containerWidth, setContainerWidth] = react_exports.useState(Number(props.width));
466
+ const [containerHeight, setContainerHeight] = react_exports.useState(Number(props.height));
467
+ if (!height) {
468
+ return /* @__PURE__ */ react_exports.createElement(Item, { "data-test": "item", width, backgroundColor }, /* @__PURE__ */ react_exports.createElement(ItemContent, null, /* @__PURE__ */ react_exports.createElement(Viz, __spreadValues({}, props))));
469
+ }
470
+ return /* @__PURE__ */ react_exports.createElement(
471
+ FixSizeItem,
472
+ {
473
+ "data-test": "fix-size-item",
474
+ "data-splunk-visualization-version": "27.0.0 - 9bf093b7d",
475
+ width,
476
+ height,
477
+ backgroundColor
478
+ },
479
+ /* @__PURE__ */ react_exports.createElement(FixSizeItemContent, null, /* @__PURE__ */ react_exports.createElement(SizeAwareWrapper_default, { width, height, onResize: cachedHandleResize }), /* @__PURE__ */ react_exports.createElement(Viz, __spreadProps(__spreadValues({}, props), { width: containerWidth, height: containerHeight })))
480
+ );
481
+ };
482
+ FixedSizeContainer.displayName = "withFixedSizeContainer";
483
+ return FixedSizeContainer;
2039
484
  };
485
+ var FixedSizeContainer_default = withFixedSizeContainer;
2040
486
 
2041
- exports.isMissing = isMissing;
2042
- /**
2043
- * @method misskingKeys
2044
- * @param {string[]} keys
2045
- * @param {object} target
2046
- * @returns {string[]} the keys of missing required props
2047
- */
2048
-
2049
- var missingKeys = function missingKeys(keys, target) {
2050
- return keys.filter(function (k) {
2051
- return (0, exports.isMissing)(target[k]);
2052
- });
487
+ // src/common/components/MissingPropsMessage.tsx
488
+ var isMissing = (v) => {
489
+ return v === null || v === void 0;
2053
490
  };
2054
-
2055
- exports.missingKeys = missingKeys;
491
+ var missingKeys = (keys, target) => keys.filter((k) => isMissing(target[k]));
2056
492
  var propTypes = {
2057
- width: T.oneOfType([T.string, T.number]),
2058
- height: T.oneOfType([T.string, T.number]),
493
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
494
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
2059
495
  // eslint-disable-next-line react/no-unused-prop-types
2060
- backgroundColor: T.string,
2061
- missingProps: T.arrayOf(T.string)
496
+ backgroundColor: prop_types_exports.string,
497
+ missingProps: prop_types_exports.arrayOf(prop_types_exports.string)
2062
498
  };
2063
- /**
2064
- * @method MissingPropsMessage
2065
- * @param {MissingPropsProps} props
2066
- * @returns {React.ReactElement}
2067
- */
2068
-
2069
- var MissingPropsMessage = function MissingPropsMessage(props) {
2070
- var width = props.width,
2071
- height = props.height,
2072
- missingProps = props.missingProps;
2073
- return React.createElement(Message_1.default, {
2074
- "data-test": "message",
2075
- width: width,
2076
- height: height,
2077
- message: (0, i18n_1._)("Missing property: ".concat(missingProps.join(', ')))
2078
- });
499
+ var MissingPropsMessage = (props) => {
500
+ const { width, height, missingProps } = props;
501
+ return /* @__PURE__ */ react_exports.createElement(
502
+ Message_default,
503
+ {
504
+ "data-test": "message",
505
+ width,
506
+ height,
507
+ message: (0, i18n_exports._)(`Missing property: ${missingProps.join(", ")}`)
508
+ }
509
+ );
2079
510
  };
2080
-
2081
- exports.MissingPropsMessage = MissingPropsMessage;
2082
- exports.MissingPropsMessage.propTypes = propTypes;
2083
- exports.MissingPropsMessage.defaultProps = {
2084
- width: '100%',
511
+ MissingPropsMessage.propTypes = propTypes;
512
+ MissingPropsMessage.defaultProps = {
513
+ width: "100%",
2085
514
  height: 250
2086
515
  };
2087
- exports.default = (0, FixedSizeContainer_1.default)(exports.MissingPropsMessage);
2088
-
2089
- /***/ }),
2090
- /* 116 */
2091
- /***/ (function(module, exports) {
2092
-
2093
- module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
2094
-
2095
- /***/ }),
2096
- /* 117 */
2097
- /***/ (function(module, exports, __webpack_require__) {
2098
-
2099
- "use strict";
2100
-
2101
-
2102
- Object.defineProperty(exports, "__esModule", {
2103
- value: true
2104
- });
2105
-
2106
- var React = __webpack_require__(0);
2107
-
2108
- var styled_components_1 = __webpack_require__(2);
2109
-
2110
- var hocUtils_1 = __webpack_require__(64);
2111
-
2112
- var Cover = styled_components_1.default.div.withConfig({
2113
- displayName: "withEditModeCover__Cover",
2114
- componentId: "sc-1gsbnxb-0"
2115
- })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
2116
- var Blocker = styled_components_1.default.div.attrs({
2117
- 'data-splunk-visualization-version': "26.4.1 - 2b7482c08"
2118
- }).withConfig({
2119
- displayName: "withEditModeCover__Blocker",
2120
- componentId: "sc-1gsbnxb-1"
2121
- })(["position:relative;width:100%;height:100%;"]);
2122
- /**
2123
- * HOC that renders a cover layer in edit mode
2124
- * @method withEditModeCover
2125
- * @param {ExtendedDashViz} Visualization
2126
- * @returns {ExtendedDashViz} Wrapper
2127
- */
516
+ var MissingPropsMessage_default = FixedSizeContainer_default(MissingPropsMessage);
517
+
518
+ // src/common/utils/hocUtils.ts
519
+ var extendStaticWrapperProps = ({
520
+ Wrapper,
521
+ Visualization
522
+ }) => {
523
+ const extendProperties = ["propTypes", "defaultProps", "config"];
524
+ extendProperties.forEach((prop) => {
525
+ if (Visualization[prop]) {
526
+ Wrapper[prop] = Visualization[prop];
527
+ }
528
+ });
529
+ };
2128
530
 
2129
- var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
2130
- var Wrapper = function Wrapper(props) {
2131
- var mode = props.mode;
2132
- var showEditCover = mode === 'edit' && !disableEditModeCover;
2133
- return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
2134
- "data-test": "edit-mode-cover"
2135
- }));
531
+ // src/common/hocs/withEditModeCover.tsx
532
+ var Cover = styled_components_default.div`
533
+ position: absolute;
534
+ left: 0;
535
+ right: 0;
536
+ top: 0;
537
+ bottom: 0;
538
+ `;
539
+ var Blocker = styled_components_default.div.attrs({
540
+ "data-splunk-visualization-version": "27.0.0 - 9bf093b7d"
541
+ })`
542
+ position: relative;
543
+ width: 100%;
544
+ height: 100%;
545
+ `;
546
+ var withEditModeCover = (Visualization, disableEditModeCover) => {
547
+ const Wrapper = (props) => {
548
+ const { mode } = props;
549
+ const showEditCover = mode === "edit" && !disableEditModeCover;
550
+ return /* @__PURE__ */ react_exports.createElement(Blocker, null, /* @__PURE__ */ react_exports.createElement(Visualization, __spreadValues({}, props)), showEditCover && /* @__PURE__ */ react_exports.createElement(Cover, { "data-test": "edit-mode-cover" }));
2136
551
  };
2137
-
2138
- (0, hocUtils_1.extendStaticWrapperProps)({
2139
- Wrapper: Wrapper,
2140
- Visualization: Visualization
2141
- });
552
+ extendStaticWrapperProps({ Wrapper, Visualization });
2142
553
  return Wrapper;
2143
554
  };
555
+ var withEditModeCover_default = withEditModeCover;
2144
556
 
2145
- exports.default = withEditModeCover;
2146
-
2147
- /***/ }),
2148
- /* 118 */
2149
- /***/ (function(module, exports, __webpack_require__) {
2150
-
2151
- "use strict";
2152
-
2153
-
2154
- Object.defineProperty(exports, "__esModule", {
2155
- value: true
557
+ // esm-externals:@splunk/themes/variables
558
+ var variables_exports = {};
559
+ __export(variables_exports, {
560
+ default: () => variables_default
2156
561
  });
562
+ var defaultImport20 = __toESM(require("@splunk/themes/variables"));
563
+ __reExport(variables_exports, require("@splunk/themes/variables"));
564
+ var variables_default = "default" in defaultImport20 ? defaultImport20.default : defaultImport20;
565
+
566
+ // src/common/components/IconPlaceholder.tsx
567
+ var shouldShowIconPlaceholder = (dataSources, loading = false) => {
568
+ const data = (0, lodash_exports.get)(dataSources, "primary.data.columns[0]", void 0);
569
+ const noData = data === void 0;
570
+ const fields = (0, lodash_exports.get)(dataSources, "primary.data.fields[0]", void 0);
571
+ const noFields = fields === void 0;
572
+ return loading || noData || noFields;
573
+ };
574
+ var propTypes2 = {
575
+ icon: prop_types_exports.func,
576
+ width: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
577
+ height: prop_types_exports.oneOfType([prop_types_exports.string, prop_types_exports.number]),
578
+ // eslint-disable-next-line react/no-unused-prop-types
579
+ backgroundColor: prop_types_exports.string,
580
+ iconColor: prop_types_exports.string
581
+ };
582
+ var IconPlaceholder = (props) => {
583
+ const { width, height, icon, iconColor } = props;
584
+ if (icon) {
585
+ return react_exports.createElement(icon, {
586
+ style: {
587
+ left: "50%",
588
+ top: "50%",
589
+ color: iconColor,
590
+ opacity: 0.15,
591
+ position: "absolute",
592
+ transform: "translate(-50%, -50%)"
593
+ },
594
+ width: "50%",
595
+ height: "50%",
596
+ "data-test": "icon-placeholder"
597
+ });
598
+ }
599
+ return /* @__PURE__ */ react_exports.createElement(Message_default, { width, height, level: "warning", message: (0, i18n_exports._)("No DataSource Connected") });
600
+ };
601
+ IconPlaceholder.propTypes = propTypes2;
602
+ IconPlaceholder.defaultProps = {
603
+ width: "100%",
604
+ height: 250
605
+ };
606
+ var IconPlaceholder_default = FixedSizeContainer_default(IconPlaceholder);
2157
607
 
2158
- var React = __webpack_require__(0);
2159
-
2160
- var colorUtils_1 = __webpack_require__(16);
2161
-
2162
- var variables_1 = __webpack_require__(58);
2163
-
2164
- var IconPlaceholder_1 = __webpack_require__(119);
2165
-
2166
- var VizBehavior_1 = __webpack_require__(18);
2167
-
2168
- var hocUtils_1 = __webpack_require__(64);
2169
-
2170
- var withPlaceholder = function withPlaceholder(Visualization) {
2171
- var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
2172
- var config = Visualization.config;
2173
- var themes = config.themes;
2174
-
2175
- var Wrapper = function Wrapper(props) {
608
+ // src/common/hocs/withPlaceholder.tsx
609
+ var withPlaceholder = (Visualization, useIconPlaceholder = shouldShowIconPlaceholder) => {
610
+ const { config } = Visualization;
611
+ const { themes } = config;
612
+ const Wrapper = (props) => {
2176
613
  var _a, _b;
2177
-
2178
- var dataSources = props.dataSources,
2179
- loading = props.loading,
2180
- options = props.options,
2181
- height = props.height,
2182
- width = props.width;
2183
- var showPlaceholder = useIconPlaceholder(dataSources, loading, options);
2184
- var bgColorFromTheme = (0, colorUtils_1.isColor)(options === null || options === void 0 ? void 0 : options.backgroundColor) ? options === null || options === void 0 ? void 0 : options.backgroundColor : (_a = themes === null || themes === void 0 ? void 0 : themes.defaultBackgroundColor) === null || _a === void 0 ? void 0 : _a.call(themes, props);
2185
- var icon = (_b = config.placeholderIcon) !== null && _b !== void 0 ? _b : config.icon;
2186
- var iconColor = variables_1.default.contentColorActive(props);
2187
-
2188
- if (config.supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && showPlaceholder) {
2189
- return React.createElement(IconPlaceholder_1.default, {
2190
- "data-test": "icon-placeholder",
2191
- icon: icon,
2192
- width: width,
2193
- height: height,
2194
- backgroundColor: bgColorFromTheme,
2195
- iconColor: iconColor
2196
- });
614
+ const { dataSources, loading, options, height, width } = props;
615
+ const showPlaceholder = useIconPlaceholder(dataSources, loading, options);
616
+ const bgColorFromTheme = (0, colorUtils_exports.isColor)(options == null ? void 0 : options.backgroundColor) ? options == null ? void 0 : options.backgroundColor : (_a = themes == null ? void 0 : themes.defaultBackgroundColor) == null ? void 0 : _a.call(themes, props);
617
+ const icon = (_b = config.placeholderIcon) != null ? _b : config.icon;
618
+ const iconColor = variables_default.contentColorActive(props);
619
+ if (config.supports.includes("placeholder" /* PLACEHOLDER */) && showPlaceholder) {
620
+ return /* @__PURE__ */ react_exports.createElement(
621
+ IconPlaceholder_default,
622
+ {
623
+ "data-test": "icon-placeholder",
624
+ icon,
625
+ width,
626
+ height,
627
+ backgroundColor: bgColorFromTheme,
628
+ iconColor
629
+ }
630
+ );
2197
631
  }
2198
-
2199
- return React.createElement(Visualization, Object.assign({}, props));
632
+ return /* @__PURE__ */ react_exports.createElement(Visualization, __spreadValues({}, props));
2200
633
  };
634
+ extendStaticWrapperProps({ Wrapper, Visualization });
635
+ return Wrapper;
636
+ };
637
+ var withPlaceholder_default = withPlaceholder;
2201
638
 
2202
- (0, hocUtils_1.extendStaticWrapperProps)({
2203
- Wrapper: Wrapper,
2204
- Visualization: Visualization
639
+ // esm-externals:@splunk/visualizations-shared/numberUtils
640
+ var numberUtils_exports = {};
641
+ __export(numberUtils_exports, {
642
+ default: () => numberUtils_default
643
+ });
644
+ var defaultImport21 = __toESM(require("@splunk/visualizations-shared/numberUtils"));
645
+ __reExport(numberUtils_exports, require("@splunk/visualizations-shared/numberUtils"));
646
+ var numberUtils_default = "default" in defaultImport21 ? defaultImport21.default : defaultImport21;
647
+
648
+ // src/common/utils/dataUtils.ts
649
+ var largestTriangleThreeBuckets = (data, threshold, preferredDownsampleIndices) => {
650
+ const dataLength = data.length;
651
+ const downsampledIndices = [];
652
+ if (threshold >= dataLength || threshold === 0) {
653
+ const allIndices = data.map((values, index) => index);
654
+ return { downsampledData: data, downsampledIndices: allIndices };
655
+ }
656
+ const sampled = [];
657
+ let sampledIndex = 0;
658
+ const every = (dataLength - 2) / (threshold - 2);
659
+ let a = 0;
660
+ let maxAreaPoint;
661
+ let maxArea;
662
+ let area;
663
+ let nextA;
664
+ sampled.push(data[a]);
665
+ downsampledIndices.push(0);
666
+ for (let i = 0; i < threshold - 2; i++) {
667
+ let avgX = 0;
668
+ let avgY = 0;
669
+ let avgRangeStart = Math.floor((i + 1) * every) + 1;
670
+ let avgRangeEnd = Math.floor((i + 2) * every) + 1;
671
+ avgRangeEnd = avgRangeEnd < dataLength ? avgRangeEnd : dataLength;
672
+ const avgRangeLength = avgRangeEnd - avgRangeStart;
673
+ for (; avgRangeStart < avgRangeEnd; avgRangeStart++) {
674
+ avgX += Number(data[avgRangeStart][0]);
675
+ avgY += data[avgRangeStart][1] * 1;
676
+ }
677
+ avgX /= avgRangeLength;
678
+ avgY /= avgRangeLength;
679
+ let rangeOffs = Math.floor((i + 0) * every) + 1;
680
+ const rangeTo = Math.floor((i + 1) * every) + 1;
681
+ const pointAX = Number(data[a][0]);
682
+ const pointAY = data[a][1] * 1;
683
+ maxArea = area = -1;
684
+ let maxAreaIndex = rangeOffs;
685
+ for (; rangeOffs < rangeTo; rangeOffs++) {
686
+ area = Math.abs(
687
+ (pointAX - avgX) * (data[rangeOffs][1] - pointAY) - (pointAX - Number(data[rangeOffs][0])) * (avgY - pointAY)
688
+ ) * 0.5;
689
+ if (area > maxArea || area === maxArea && preferredDownsampleIndices.has(rangeOffs)) {
690
+ maxArea = area;
691
+ maxAreaPoint = data[rangeOffs];
692
+ nextA = rangeOffs;
693
+ maxAreaIndex = rangeOffs;
694
+ }
695
+ }
696
+ sampled[sampledIndex++] = maxAreaPoint;
697
+ downsampledIndices.push(maxAreaIndex);
698
+ a = nextA;
699
+ }
700
+ sampled[sampledIndex++] = data[dataLength - 1];
701
+ downsampledIndices.push(dataLength - 1);
702
+ return { downsampledData: sampled, downsampledIndices };
703
+ };
704
+ var strictlyCoerceYColumn = (column, options) => {
705
+ const isNullCoercionEnabled = options.nullValueDisplay === "zero";
706
+ const canLooselyCoerceSomeValues = column.findIndex(
707
+ (value) => (0, numberUtils_exports.startsWithNumber)(`${value}`) || isNullCoercionEnabled && value === null
708
+ ) >= 0;
709
+ const coercedColumn = [];
710
+ const canDownsampleColumn = !column.some((value) => {
711
+ const coercedValue = Number(value);
712
+ const coerceValueToZero = isNullCoercionEnabled && value === null;
713
+ if (Number.isNaN(coercedValue) || coercedValue <= Number.MIN_SAFE_INTEGER || coercedValue >= Number.MAX_SAFE_INTEGER || typeof value !== "string" && typeof value !== "number" && !coerceValueToZero) {
714
+ return true;
715
+ }
716
+ coercedColumn.push(coercedValue);
717
+ return false;
718
+ });
719
+ return {
720
+ canDownsampleColumn,
721
+ canLooselyCoerceSomeValues,
722
+ coercedColumn: canDownsampleColumn ? coercedColumn : []
723
+ };
724
+ };
725
+ var strictlyCoerceXColumn = (column, fieldType) => {
726
+ if (fieldType === "number") {
727
+ const coercedXColumn = column.map((xValue) => Number(xValue));
728
+ if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
729
+ return coercedXColumn;
730
+ }
731
+ } else if (fieldType === "time") {
732
+ const coercedXColumn = column.map((xValue) => new Date(xValue));
733
+ if (isColumnStrictlyIncreasing(coercedXColumn, fieldType)) {
734
+ return coercedXColumn;
735
+ }
736
+ }
737
+ return [];
738
+ };
739
+ var isDownsamplingEnabledForViz = ({ vizConfig }) => {
740
+ var _a;
741
+ return (_a = vizConfig.supports) == null ? void 0 : _a.includes("downsampling" /* DOWNSAMPLING */);
742
+ };
743
+ var isColumnStrictlyIncreasing = (column, fieldType) => {
744
+ return column.every((value, index) => {
745
+ if (fieldType === "number") {
746
+ if (Number.isNaN(value)) {
747
+ return false;
748
+ }
749
+ }
750
+ if (fieldType === "time") {
751
+ if (Number.isNaN(value.getTime())) {
752
+ return false;
753
+ }
754
+ }
755
+ if (index === 0) {
756
+ return true;
757
+ }
758
+ return value > column[index - 1];
2205
759
  });
2206
- return Wrapper;
2207
- };
2208
-
2209
- exports.default = withPlaceholder;
2210
-
2211
- /***/ }),
2212
- /* 119 */
2213
- /***/ (function(module, exports, __webpack_require__) {
2214
-
2215
- "use strict";
2216
-
2217
-
2218
- Object.defineProperty(exports, "__esModule", {
2219
- value: true
2220
- });
2221
- exports.shouldShowIconPlaceholder = void 0;
2222
-
2223
- var React = __webpack_require__(0);
2224
-
2225
- var T = __webpack_require__(1);
2226
-
2227
- var lodash_1 = __webpack_require__(3);
2228
-
2229
- var i18n_1 = __webpack_require__(5);
2230
-
2231
- var Message_1 = __webpack_require__(24);
2232
-
2233
- var FixedSizeContainer_1 = __webpack_require__(63);
2234
- /**
2235
- * @method shouldShowIconPlaceholder
2236
- * @param {object} dataSources
2237
- * @param {boolean} loading
2238
- * @returns {boolean}
2239
- */
2240
-
2241
-
2242
- var shouldShowIconPlaceholder = function shouldShowIconPlaceholder(dataSources) {
2243
- var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2244
- var data = (0, lodash_1.get)(dataSources, 'primary.data.columns[0]', undefined);
2245
- var noData = data === undefined;
2246
- var fields = (0, lodash_1.get)(dataSources, 'primary.data.fields[0]', undefined);
2247
- var noFields = fields === undefined;
2248
- return loading || noData || noFields;
2249
760
  };
2250
-
2251
- exports.shouldShowIconPlaceholder = shouldShowIconPlaceholder;
2252
- var propTypes = {
2253
- icon: T.func,
2254
- width: T.oneOfType([T.string, T.number]),
2255
- height: T.oneOfType([T.string, T.number]),
2256
- // eslint-disable-next-line react/no-unused-prop-types
2257
- backgroundColor: T.string,
2258
- iconColor: T.string
761
+ var tryToCoerceAllDisplayedFields = (ds, xField, yFields, fieldTypes, options) => {
762
+ let xColumn = [];
763
+ const yColumns = [];
764
+ const canDownsample = !ds.data.fields.some((field, index) => {
765
+ var _a, _b;
766
+ const fieldName = (_a = field.name) != null ? _a : field;
767
+ const fieldType = (_b = fieldTypes[index]) != null ? _b : "unknown";
768
+ const column = ds.data.columns[index];
769
+ let hasDisplayedColumnThatCantBeDownsampled = false;
770
+ if (fieldName === xField) {
771
+ xColumn = strictlyCoerceXColumn(column, fieldType);
772
+ } else if (yFields.has(fieldName)) {
773
+ const { coercedColumn, canLooselyCoerceSomeValues, canDownsampleColumn } = strictlyCoerceYColumn(
774
+ ds.data.columns[index],
775
+ options
776
+ );
777
+ hasDisplayedColumnThatCantBeDownsampled = canLooselyCoerceSomeValues && !canDownsampleColumn;
778
+ if (hasDisplayedColumnThatCantBeDownsampled) {
779
+ return true;
780
+ }
781
+ if (canDownsampleColumn) {
782
+ yColumns.push(coercedColumn);
783
+ }
784
+ }
785
+ return false;
786
+ });
787
+ if (canDownsample) {
788
+ return { xColumn, yColumns };
789
+ }
790
+ return { xColumn: [], yColumns: [] };
2259
791
  };
2260
- /**
2261
- * @method IconPlaceholder
2262
- * @param {IconPlaceholderProps} props
2263
- * @returns {React.ReactElement}
2264
- */
2265
-
2266
- var IconPlaceholder = function IconPlaceholder(props) {
2267
- var width = props.width,
2268
- height = props.height,
2269
- icon = props.icon,
2270
- iconColor = props.iconColor;
2271
-
2272
- if (icon) {
2273
- return React.createElement(icon, {
2274
- style: {
2275
- left: '50%',
2276
- top: '50%',
2277
- color: iconColor,
2278
- opacity: 0.15,
2279
- position: 'absolute',
2280
- transform: 'translate(-50%, -50%)'
2281
- },
2282
- width: '50%',
2283
- height: '50%',
2284
- 'data-test': 'icon-placeholder'
792
+ var pickIndicesFromDataSource = (ds, indices) => {
793
+ const sortedIndices = Array.from(indices).sort((a, b) => a - b);
794
+ const slicedColumns = [];
795
+ ds.data.columns.forEach((column) => {
796
+ const slicedColumn = [];
797
+ sortedIndices.forEach((index) => {
798
+ slicedColumn.push(column[index]);
2285
799
  });
2286
- }
2287
-
2288
- return React.createElement(Message_1.default, {
2289
- width: width,
2290
- height: height,
2291
- level: "warning",
2292
- message: (0, i18n_1._)('No DataSource Connected')
800
+ slicedColumns.push(slicedColumn);
801
+ });
802
+ return __spreadProps(__spreadValues({}, ds), {
803
+ data: __spreadProps(__spreadValues({}, ds.data), {
804
+ columns: slicedColumns
805
+ })
2293
806
  });
2294
807
  };
2295
-
2296
- IconPlaceholder.propTypes = propTypes;
2297
- IconPlaceholder.defaultProps = {
2298
- width: '100%',
2299
- height: 250
2300
- };
2301
- exports.default = (0, FixedSizeContainer_1.default)(IconPlaceholder);
2302
-
2303
- /***/ }),
2304
- /* 120 */
2305
- /***/ (function(module, exports, __webpack_require__) {
2306
-
2307
- "use strict";
2308
-
2309
-
2310
- var _slicedToArray = __webpack_require__(8);
2311
-
2312
- Object.defineProperty(exports, "__esModule", {
2313
- value: true
2314
- });
2315
-
2316
- var react_1 = __webpack_require__(0);
2317
-
2318
- var lodash_1 = __webpack_require__(3);
2319
-
2320
- var dataUtils_1 = __webpack_require__(25);
2321
-
2322
- var usePrevious_1 = __webpack_require__(31);
2323
-
2324
- var useGetXAndYFields_1 = __webpack_require__(121); // Options properties which impact/require re-downsample on change.
2325
-
2326
-
2327
- var downsampleVizOptionProperties = ['nullValueDisplay'];
2328
-
2329
- var useDownsampleDataSources = function useDownsampleDataSources(_ref) {
2330
- var dataSources = _ref.dataSources,
2331
- options = _ref.options,
2332
- context = _ref.context,
2333
- threshold = _ref.threshold,
2334
- isDownsamplingEnabled = _ref.isDownsamplingEnabled;
2335
- var isFirstUseEffectCall = (0, react_1.useRef)(true);
2336
- var xAndYFieldsWithTypes = (0, useGetXAndYFields_1.default)({
2337
- shouldEvaluateDSL: isDownsamplingEnabled,
2338
- options: options,
2339
- context: context,
2340
- dataSources: dataSources
2341
- }); // Extract viz options that impact downsampling.
2342
-
2343
- var downsampleVizOptions = (0, react_1.useMemo)(function () {
2344
- return (0, lodash_1.pick)(options, downsampleVizOptionProperties);
2345
- }, [options]);
2346
- var downsampleDSOptions = (0, react_1.useMemo)(function () {
2347
- return Object.assign(Object.assign({}, downsampleVizOptions), xAndYFieldsWithTypes);
2348
- }, [xAndYFieldsWithTypes, downsampleVizOptions]);
2349
- var previousDownsampleDSOptions = (0, usePrevious_1.default)(downsampleDSOptions);
2350
- var previousDataSources = (0, usePrevious_1.default)(dataSources);
2351
- var previousThreshold = (0, usePrevious_1.default)(threshold);
2352
-
2353
- var _ref2 = (0, react_1.useState)(function () {
2354
- return isDownsamplingEnabled ? (0, dataUtils_1.downsampleDataSources)({
2355
- dataSources: dataSources,
2356
- threshold: threshold,
2357
- options: downsampleDSOptions
2358
- }) : dataSources;
2359
- }),
2360
- _ref3 = _slicedToArray(_ref2, 2),
2361
- downsampledDataSources = _ref3[0],
2362
- setDownsampledDataSources = _ref3[1];
2363
-
2364
- var debouncedDownsampleDataSources = (0, react_1.useMemo)(function () {
2365
- return (0, lodash_1.debounce)(function (downsampleOptions) {
2366
- var downsampledResult = (0, dataUtils_1.downsampleDataSources)(downsampleOptions);
2367
- setDownsampledDataSources(downsampledResult);
2368
- }, 100, {
2369
- trailing: true
808
+ var downsampleDataSources = ({ dataSources, threshold, options }) => {
809
+ var _a, _b, _c;
810
+ const primaryDS = dataSources == null ? void 0 : dataSources.primary;
811
+ const numPoints = (_c = (_b = (_a = primaryDS == null ? void 0 : primaryDS.data) == null ? void 0 : _a.columns[0]) == null ? void 0 : _b.length) != null ? _c : 0;
812
+ if (Number.isNaN(threshold) || numPoints <= threshold || threshold < 2) {
813
+ return dataSources;
814
+ }
815
+ const { xField, yFields, fieldTypes } = options;
816
+ if (!xField || !(yFields == null ? void 0 : yFields.length) || !(fieldTypes == null ? void 0 : fieldTypes.length)) {
817
+ return dataSources;
818
+ }
819
+ const nonInternalYFields = new Set(yFields.filter((yField) => !yField.startsWith("_")));
820
+ const maxPointsInDownsample = Math.min(nonInternalYFields.size * threshold, numPoints);
821
+ if (maxPointsInDownsample >= numPoints) {
822
+ return dataSources;
823
+ }
824
+ const { xColumn, yColumns } = tryToCoerceAllDisplayedFields(
825
+ primaryDS,
826
+ xField,
827
+ nonInternalYFields,
828
+ fieldTypes,
829
+ options
830
+ );
831
+ if (!yColumns.length || !xColumn.length) {
832
+ return dataSources;
833
+ }
834
+ const downsampledDataSources = __spreadValues({}, dataSources);
835
+ const downsampledIndices = /* @__PURE__ */ new Set();
836
+ yColumns.forEach((yColumn, columnIndex) => {
837
+ const xyPair = yColumn.map((yValue, index) => {
838
+ return [xColumn[index], yValue];
2370
839
  });
2371
- }, []);
2372
- (0, react_1.useEffect)(function () {
2373
- // don't downsample again on the use effect call that happened due to the initial render
2374
- // this is since we already downsampled as part of the useState call
2375
- if (isFirstUseEffectCall.current) {
2376
- isFirstUseEffectCall.current = false;
2377
- return;
2378
- }
2379
-
2380
- if (!isDownsamplingEnabled) {
2381
- setDownsampledDataSources(dataSources);
2382
- return;
840
+ try {
841
+ const { downsampledIndices: downsampledIndicesForSeries } = largestTriangleThreeBuckets(
842
+ xyPair,
843
+ threshold,
844
+ downsampledIndices
845
+ );
846
+ downsampledIndicesForSeries.forEach((downsampleIndex) => downsampledIndices.add(downsampleIndex));
847
+ } catch (e) {
848
+ console.error(`Error occurred while downsampling column ${columnIndex}`, e);
2383
849
  }
2384
-
2385
- if ((0, lodash_1.isEqual)(previousDownsampleDSOptions, downsampleDSOptions) && previousDataSources === dataSources && previousThreshold === threshold) {
2386
- return;
2387
- } // Debounce the downsampling so we don't have to downsample and execute DSL multiple times
2388
- // while the viz is being resized
2389
-
2390
-
2391
- debouncedDownsampleDataSources({
2392
- dataSources: dataSources,
2393
- options: downsampleDSOptions,
2394
- threshold: threshold
2395
- }); // need to detect if this runs as part of the initial render
2396
- }, [dataSources, downsampleDSOptions, debouncedDownsampleDataSources, xAndYFieldsWithTypes, threshold, isDownsamplingEnabled, previousDataSources, previousThreshold, previousDownsampleDSOptions]);
850
+ });
851
+ downsampledDataSources.primary = pickIndicesFromDataSource(primaryDS, downsampledIndices);
2397
852
  return downsampledDataSources;
2398
853
  };
2399
854
 
2400
- exports.default = useDownsampleDataSources;
2401
-
2402
- /***/ }),
2403
- /* 121 */
2404
- /***/ (function(module, exports, __webpack_require__) {
2405
-
2406
- "use strict";
2407
-
2408
-
2409
- var _toConsumableArray = __webpack_require__(22);
2410
-
2411
- Object.defineProperty(exports, "__esModule", {
2412
- value: true
2413
- });
2414
-
2415
- var react_1 = __webpack_require__(0);
2416
-
2417
- var Options_1 = __webpack_require__(62);
2418
- /**
2419
- * Hook that evaluates the DSL for subset of a viz's options needed to determine
2420
- * its x and y fields as well as the types of all its fields.
2421
- */
2422
-
2423
-
2424
- var useGetXAndYFields = function useGetXAndYFields(_ref) {
2425
- var shouldEvaluateDSL = _ref.shouldEvaluateDSL,
2426
- options = _ref.options,
2427
- context = _ref.context,
2428
- dataSources = _ref.dataSources;
855
+ // src/common/hooks/usePrevious.ts
856
+ function usePrevious(value) {
857
+ const ref = (0, react_exports.useRef)();
858
+ (0, react_exports.useEffect)(() => {
859
+ ref.current = value;
860
+ });
861
+ return ref.current;
862
+ }
2429
863
 
2430
- var _ref2 = (0, react_1.useMemo)(function () {
864
+ // src/common/hooks/useGetXAndYFields.tsx
865
+ var useGetXAndYFields = ({
866
+ shouldEvaluateDSL,
867
+ options,
868
+ context,
869
+ dataSources
870
+ }) => {
871
+ const { dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint } = (0, react_exports.useMemo)(() => {
2431
872
  var _a, _b, _c;
2432
-
2433
873
  if (!shouldEvaluateDSL) {
2434
874
  return {
2435
875
  dataSourcesWithOnlyOnePoint: null,
2436
876
  dataFrameWithOnlyOnePoint: null
2437
877
  };
2438
878
  }
2439
-
2440
- if (!((_c = (_b = (_a = dataSources === null || dataSources === void 0 ? void 0 : dataSources.primary) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.columns) === null || _c === void 0 ? void 0 : _c.length)) {
879
+ if (!((_c = (_b = (_a = dataSources == null ? void 0 : dataSources.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.columns) == null ? void 0 : _c.length)) {
2441
880
  return {
2442
881
  dataSourcesWithOnlyOnePoint: null,
2443
882
  dataFrameWithOnlyOnePoint: null
2444
883
  };
2445
884
  }
2446
-
2447
- var primaryDS = dataSources.primary;
2448
- var columnsWithOnlyOnePoint = primaryDS.data.columns.map(function (column) {
885
+ const { primary: primaryDS } = dataSources;
886
+ const columnsWithOnlyOnePoint = primaryDS.data.columns.map((column) => {
2449
887
  return [column[0]];
2450
888
  });
2451
- var filteredDataSources = {
2452
- primary: Object.assign(Object.assign({}, primaryDS), {
2453
- data: Object.assign(Object.assign({}, primaryDS.data), {
889
+ const filteredDataSources = {
890
+ primary: __spreadProps(__spreadValues({}, primaryDS), {
891
+ data: __spreadProps(__spreadValues({}, primaryDS.data), {
2454
892
  columns: columnsWithOnlyOnePoint
2455
893
  })
2456
894
  })
2457
895
  };
2458
896
  return {
2459
897
  dataSourcesWithOnlyOnePoint: filteredDataSources,
2460
- dataFrameWithOnlyOnePoint: Options_1.Options.dataFrameFromDataSource(filteredDataSources)
898
+ dataFrameWithOnlyOnePoint: Options_exports.Options.dataFrameFromDataSource(filteredDataSources)
2461
899
  };
2462
- }, [dataSources, shouldEvaluateDSL]),
2463
- dataSourcesWithOnlyOnePoint = _ref2.dataSourcesWithOnlyOnePoint,
2464
- dataFrameWithOnlyOnePoint = _ref2.dataFrameWithOnlyOnePoint;
2465
-
2466
- var xAndYFieldsWithTypes = (0, react_1.useMemo)(function () {
900
+ }, [dataSources, shouldEvaluateDSL]);
901
+ const xAndYFieldsWithTypes = (0, react_exports.useMemo)(() => {
2467
902
  try {
2468
903
  if (!dataSourcesWithOnlyOnePoint || !dataFrameWithOnlyOnePoint) {
2469
904
  return options;
2470
905
  }
2471
-
2472
- if (!(options === null || options === void 0 ? void 0 : options.x) || !(options === null || options === void 0 ? void 0 : options.y) && !(options === null || options === void 0 ? void 0 : options.y2)) {
906
+ if (!(options == null ? void 0 : options.x) || !(options == null ? void 0 : options.y) && !(options == null ? void 0 : options.y2)) {
2473
907
  return options;
2474
908
  }
2475
-
2476
- var optionsToEvaluate = {
909
+ const optionsToEvaluate = {
2477
910
  x: options.x,
2478
- xField: '> x | getField()',
911
+ xField: "> x | getField()",
2479
912
  y: options.y,
2480
- yFields: options.y ? '> y | getField()' : undefined,
913
+ yFields: options.y ? "> y | getField()" : void 0,
2481
914
  y2: options.y2,
2482
- y2Fields: options.y2 ? '> y2 | getField()' : undefined,
2483
- fieldTypes: '> primary | getType()'
915
+ y2Fields: options.y2 ? "> y2 | getField()" : void 0,
916
+ fieldTypes: "> primary | getType()"
2484
917
  };
2485
-
2486
- var _Options_1$Options$ev = Options_1.Options.evaluate({
2487
- options: optionsToEvaluate,
2488
- context: context
2489
- }, dataSourcesWithOnlyOnePoint, function () {}, dataFrameWithOnlyOnePoint),
2490
- _Options_1$Options$ev2 = _Options_1$Options$ev.xField,
2491
- xField = _Options_1$Options$ev2 === void 0 ? '' : _Options_1$Options$ev2,
2492
- _Options_1$Options$ev3 = _Options_1$Options$ev.yFields,
2493
- yFields = _Options_1$Options$ev3 === void 0 ? [] : _Options_1$Options$ev3,
2494
- _Options_1$Options$ev4 = _Options_1$Options$ev.y2Fields,
2495
- y2Fields = _Options_1$Options$ev4 === void 0 ? [] : _Options_1$Options$ev4,
2496
- fieldTypes = _Options_1$Options$ev.fieldTypes;
2497
-
918
+ const { xField = "", yFields = [], y2Fields = [], fieldTypes } = Options_exports.Options.evaluate(
919
+ { options: optionsToEvaluate, context },
920
+ dataSourcesWithOnlyOnePoint,
921
+ () => {
922
+ },
923
+ dataFrameWithOnlyOnePoint
924
+ );
2498
925
  return {
2499
- xField: xField,
2500
- yFields: [].concat(_toConsumableArray(yFields), _toConsumableArray(y2Fields)),
2501
- fieldTypes: fieldTypes
926
+ xField,
927
+ yFields: [...yFields, ...y2Fields],
928
+ fieldTypes
2502
929
  };
2503
930
  } catch (e) {
2504
931
  return {
2505
- xField: undefined,
932
+ xField: void 0,
2506
933
  yFields: [],
2507
934
  fieldTypes: []
2508
935
  };
@@ -2510,50 +937,353 @@ var useGetXAndYFields = function useGetXAndYFields(_ref) {
2510
937
  }, [options, context, dataSourcesWithOnlyOnePoint, dataFrameWithOnlyOnePoint]);
2511
938
  return xAndYFieldsWithTypes;
2512
939
  };
940
+ var useGetXAndYFields_default = useGetXAndYFields;
941
+
942
+ // src/common/hooks/useDownsampleDataSources.tsx
943
+ var downsampleVizOptionProperties = ["nullValueDisplay"];
944
+ var useDownsampleDataSources = ({
945
+ dataSources,
946
+ options,
947
+ context,
948
+ threshold,
949
+ isDownsamplingEnabled
950
+ }) => {
951
+ const isFirstUseEffectCall = (0, react_exports.useRef)(true);
952
+ const xAndYFieldsWithTypes = useGetXAndYFields_default({
953
+ shouldEvaluateDSL: isDownsamplingEnabled,
954
+ options,
955
+ context,
956
+ dataSources
957
+ });
958
+ const downsampleVizOptions = (0, react_exports.useMemo)(() => (0, lodash_exports.pick)(options, downsampleVizOptionProperties), [options]);
959
+ const downsampleDSOptions = (0, react_exports.useMemo)(
960
+ () => __spreadValues(__spreadValues({}, downsampleVizOptions), xAndYFieldsWithTypes),
961
+ [xAndYFieldsWithTypes, downsampleVizOptions]
962
+ );
963
+ const previousDownsampleDSOptions = usePrevious(downsampleDSOptions);
964
+ const previousDataSources = usePrevious(dataSources);
965
+ const previousThreshold = usePrevious(threshold);
966
+ const [downsampledDataSources, setDownsampledDataSources] = (0, react_exports.useState)(() => {
967
+ return isDownsamplingEnabled ? downsampleDataSources({
968
+ dataSources,
969
+ threshold,
970
+ options: downsampleDSOptions
971
+ }) : dataSources;
972
+ });
973
+ const debouncedDownsampleDataSources = (0, react_exports.useMemo)(() => {
974
+ return (0, lodash_exports.debounce)(
975
+ (downsampleOptions) => {
976
+ const downsampledResult = downsampleDataSources(downsampleOptions);
977
+ setDownsampledDataSources(downsampledResult);
978
+ },
979
+ 100,
980
+ { trailing: true }
981
+ );
982
+ }, []);
983
+ (0, react_exports.useEffect)(() => {
984
+ if (isFirstUseEffectCall.current) {
985
+ isFirstUseEffectCall.current = false;
986
+ return;
987
+ }
988
+ if (!isDownsamplingEnabled) {
989
+ setDownsampledDataSources(dataSources);
990
+ return;
991
+ }
992
+ if ((0, lodash_exports.isEqual)(previousDownsampleDSOptions, downsampleDSOptions) && previousDataSources === dataSources && previousThreshold === threshold) {
993
+ return;
994
+ }
995
+ debouncedDownsampleDataSources({
996
+ dataSources,
997
+ options: downsampleDSOptions,
998
+ // Dont want to re-downsample everytime the options change
999
+ threshold
1000
+ });
1001
+ }, [
1002
+ dataSources,
1003
+ downsampleDSOptions,
1004
+ debouncedDownsampleDataSources,
1005
+ xAndYFieldsWithTypes,
1006
+ threshold,
1007
+ isDownsamplingEnabled,
1008
+ previousDataSources,
1009
+ previousThreshold,
1010
+ previousDownsampleDSOptions
1011
+ ]);
1012
+ return downsampledDataSources;
1013
+ };
1014
+ var useDownsampleDataSources_default = useDownsampleDataSources;
2513
1015
 
2514
- exports.default = useGetXAndYFields;
2515
-
2516
- /***/ }),
2517
- /* 122 */
2518
- /***/ (function(module, exports, __webpack_require__) {
2519
-
2520
- "use strict";
2521
-
2522
-
2523
- Object.defineProperty(exports, "__esModule", {
2524
- value: true
1016
+ // esm-externals:@splunk/visualization-context/FeatureFlags
1017
+ var FeatureFlags_exports = {};
1018
+ __export(FeatureFlags_exports, {
1019
+ default: () => FeatureFlags_default
2525
1020
  });
2526
- exports.getFeatureFlag = void 0;
2527
-
2528
- var FeatureFlags_1 = __webpack_require__(123);
1021
+ var defaultImport22 = __toESM(require("@splunk/visualization-context/FeatureFlags"));
1022
+ __reExport(FeatureFlags_exports, require("@splunk/visualization-context/FeatureFlags"));
1023
+ var FeatureFlags_default = "default" in defaultImport22 ? defaultImport22.default : defaultImport22;
2529
1024
 
2530
- var getFeatureFlag = function getFeatureFlag(context, flagName) {
2531
- // look for feature flag in context first
2532
- if (context && Object.keys(context).find(function (key) {
2533
- return key === flagName;
2534
- })) {
1025
+ // src/common/utils/featureFlagUtils.ts
1026
+ var getFeatureFlag = (context, flagName) => {
1027
+ if (context && Object.keys(context).find((key) => key === flagName)) {
2535
1028
  return context[flagName];
2536
- } // fall back to defaults
2537
-
2538
-
2539
- if (Object.keys(FeatureFlags_1.default).find(function (key) {
2540
- return key === flagName;
2541
- })) {
2542
- return FeatureFlags_1.default[flagName];
2543
- } // fall back to false
2544
-
2545
-
1029
+ }
1030
+ if (Object.keys(FeatureFlags_default).find((key) => key === flagName)) {
1031
+ return FeatureFlags_default[flagName];
1032
+ }
2546
1033
  return false;
2547
1034
  };
2548
1035
 
2549
- exports.getFeatureFlag = getFeatureFlag;
2550
-
2551
- /***/ }),
2552
- /* 123 */
2553
- /***/ (function(module, exports) {
2554
-
2555
- module.exports = require("@splunk/visualization-context/FeatureFlags");
2556
-
2557
- /***/ })
2558
- /******/ ]);
2559
- //# sourceMappingURL=withDashboardViz.js.map
1036
+ // src/common/withDashboardViz.tsx
1037
+ var withDashboardViz = (opts) => {
1038
+ const {
1039
+ ReactViz,
1040
+ vizConfig,
1041
+ computeVizProps = () => {
1042
+ },
1043
+ disableEditModeCover,
1044
+ useIconPlaceholder
1045
+ } = opts;
1046
+ const SanitizedReactViz = (0, SanitizeProps_exports.withSanitizedProps)(ReactViz);
1047
+ const defaultOptions = (0, JSONSchemaUtils_exports.pickFieldFromJSONSchema)(vizConfig.optionsSchema, "default");
1048
+ const DashboardViz = (props) => {
1049
+ var _a;
1050
+ const {
1051
+ mode,
1052
+ hasEventHandlers,
1053
+ dataSources,
1054
+ // type of { [key: string]: DataSource }
1055
+ options,
1056
+ context = {},
1057
+ width,
1058
+ height,
1059
+ onComputedProps,
1060
+ onEventTrigger,
1061
+ theme,
1062
+ onRequestParamsChange
1063
+ } = props;
1064
+ const { serializedTimezone } = react_exports.useContext(TimezoneContext_default);
1065
+ if (serializedTimezone) {
1066
+ if (!moment_default.getDefaultSplunkTimezone()) {
1067
+ moment_default.setDefaultSplunkTimezone(serializedTimezone);
1068
+ }
1069
+ }
1070
+ const themeFunc = (themeVar) => {
1071
+ var _a2, _b;
1072
+ return (_b = (_a2 = vizConfig.themes)[themeVar]) == null ? void 0 : _b.call(_a2, props);
1073
+ };
1074
+ const bgColorFromTheme = themeFunc("defaultBackgroundColor");
1075
+ const {
1076
+ family: currentThemeFamily,
1077
+ colorScheme: currentThemeColorScheme,
1078
+ density: currentThemeDensity
1079
+ } = getSettingsFromThemedProps_default({ theme });
1080
+ let evaluatedOptions = {};
1081
+ const [evaluatedOptionsAsync, setEvaluatedOptionsAsync] = react_exports.useState({});
1082
+ const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
1083
+ const [visualizationID] = react_exports.useState(`${vizConfig.name} - ${(0, id_exports.createGUID)()}`);
1084
+ const [dataSourcesInState, setDataSourcesInState] = react_exports.useState({});
1085
+ const [dataFramesInState, setDataFramesInState] = react_exports.useState();
1086
+ const [useAsyncEvaluatedOptions, setUseAsyncEvaluatedOptions] = react_exports.useState(
1087
+ Boolean(getFeatureFlag(featureFlagContext, "visualizations_useWebWorkersForDSL"))
1088
+ );
1089
+ const isDownsamplingEnabledByFeatureFlag = Boolean(
1090
+ featureFlagContext == null ? void 0 : featureFlagContext.visualizations_enableDownsampling
1091
+ );
1092
+ const isMounted = react_exports.useRef(true);
1093
+ const optionsToEvaluate = react_exports.useMemo(
1094
+ () => ({
1095
+ context: (0, lodash_exports.defaultsDeep)({}, context, vizConfig.defaultContext),
1096
+ options: (0, hocUtils_exports.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
1097
+ }),
1098
+ [options, context]
1099
+ );
1100
+ const [threshold, setThreshold] = react_exports.useState(Number(width));
1101
+ const onDownsamplingThresholdChange = react_exports.useCallback((newThreshold) => {
1102
+ setThreshold(newThreshold);
1103
+ }, []);
1104
+ const isDownsamplingEnabled = react_exports.useMemo(() => {
1105
+ return isDownsamplingEnabledByFeatureFlag && isDownsamplingEnabledForViz({ vizConfig });
1106
+ }, [isDownsamplingEnabledByFeatureFlag]);
1107
+ const downsamplingProps = react_exports.useMemo(() => {
1108
+ if (!isDownsamplingEnabled) {
1109
+ return {};
1110
+ }
1111
+ return {
1112
+ onDownsamplingThresholdChange,
1113
+ originalDataSources: dataSources
1114
+ };
1115
+ }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
1116
+ const downsampledDataSources = useDownsampleDataSources_default({
1117
+ options: optionsToEvaluate.options,
1118
+ context: optionsToEvaluate.context,
1119
+ dataSources,
1120
+ threshold,
1121
+ isDownsamplingEnabled
1122
+ });
1123
+ evaluatedOptions = useDeepMemo(() => {
1124
+ try {
1125
+ if (useAsyncEvaluatedOptions) {
1126
+ const asyncDynamicOptionsEvaluatorParams = {
1127
+ visualizationID,
1128
+ props,
1129
+ options: optionsToEvaluate,
1130
+ dataSources: downsampledDataSources,
1131
+ theme: vizConfig.themes,
1132
+ bypassCloneDeepOptionScope: Boolean(
1133
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
1134
+ ),
1135
+ lazyLoadingDataFrame: Boolean(
1136
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
1137
+ )
1138
+ };
1139
+ async_dynamic_options_evaluator_default.evaluate(asyncDynamicOptionsEvaluatorParams).then((results) => {
1140
+ setEvaluatedOptionsAsync(results.results);
1141
+ }).catch(() => {
1142
+ if (isMounted.current) {
1143
+ setUseAsyncEvaluatedOptions(false);
1144
+ }
1145
+ });
1146
+ } else {
1147
+ let dataFrames = dataFramesInState;
1148
+ if (downsampledDataSources !== dataSourcesInState) {
1149
+ setDataSourcesInState(downsampledDataSources);
1150
+ dataFrames = Options_exports.Options.dataFrameFromDataSource(
1151
+ downsampledDataSources,
1152
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
1153
+ );
1154
+ setDataFramesInState(dataFrames);
1155
+ }
1156
+ const result = Options_exports.Options.evaluate(
1157
+ optionsToEvaluate,
1158
+ downsampledDataSources,
1159
+ themeFunc,
1160
+ dataFrames,
1161
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
1162
+ );
1163
+ return result;
1164
+ }
1165
+ } catch (e) {
1166
+ console.error(`unexpected error evaluating options: ${e.message}`);
1167
+ return {};
1168
+ }
1169
+ return {};
1170
+ }, [
1171
+ currentThemeFamily,
1172
+ currentThemeColorScheme,
1173
+ currentThemeDensity,
1174
+ optionsToEvaluate,
1175
+ downsampledDataSources,
1176
+ serializedTimezone,
1177
+ useAsyncEvaluatedOptions
1178
+ ]);
1179
+ const evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync;
1180
+ const isTrellisFeatureFlagOn = Boolean(
1181
+ featureFlagContext && featureFlagContext.visualizations_enableTrellis
1182
+ );
1183
+ let clonedEvaluatedOptions = evaluatedOptionsToUse;
1184
+ if (isTrellisFeatureFlagOn && ((_a = vizConfig == null ? void 0 : vizConfig.supports) == null ? void 0 : _a.includes("trellis" /* TRELLIS */)) && (clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.splitByLayout) === "trellis" /* TRELLIS */) {
1185
+ clonedEvaluatedOptions = __spreadProps(__spreadValues({}, evaluatedOptionsToUse), {
1186
+ backgroundColor: clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
1187
+ });
1188
+ }
1189
+ react_exports.useEffect(() => {
1190
+ onComputedProps(clonedEvaluatedOptions);
1191
+ });
1192
+ react_exports.useEffect(() => {
1193
+ return () => {
1194
+ if (useAsyncEvaluatedOptions) {
1195
+ isMounted.current = false;
1196
+ async_dynamic_options_evaluator_default.reset(visualizationID);
1197
+ }
1198
+ };
1199
+ }, []);
1200
+ const { requiredProps = [], supports } = vizConfig;
1201
+ const missing = missingKeys(requiredProps, evaluatedOptionsToUse);
1202
+ if (missing.length > 0 && supports.includes("placeholder" /* PLACEHOLDER */) && vizConfig.key !== "splunk.singlevalue") {
1203
+ return /* @__PURE__ */ react_exports.createElement(
1204
+ MissingPropsMessage_default,
1205
+ {
1206
+ "data-test": "missing-props-message",
1207
+ width,
1208
+ height,
1209
+ missingProps: missing,
1210
+ backgroundColor: bgColorFromTheme
1211
+ }
1212
+ );
1213
+ }
1214
+ const eventCallbackProps = {};
1215
+ if (hasEventHandlers && mode === "view" && vizConfig.supports.indexOf("events" /* EVENTS */) > -1) {
1216
+ const supportedEvents = vizConfig.events;
1217
+ Object.keys(supportedEvents).forEach((eventName) => {
1218
+ const { parentKeys, payloadKeys } = supportedEvents[eventName];
1219
+ const eventCallbackPropName = (0, lodash_exports.camelCase)(`on.${eventName}`);
1220
+ let payload = {};
1221
+ if (Array.isArray(payloadKeys) && payloadKeys.length) {
1222
+ payloadKeys.forEach((p) => {
1223
+ payload[p] = evaluatedOptionsToUse[p];
1224
+ });
1225
+ }
1226
+ eventCallbackProps[eventCallbackPropName] = (ev) => {
1227
+ if (ev && ev.payload) {
1228
+ payload = ev.payload;
1229
+ }
1230
+ return onEventTrigger({ originalEvent: ev, payload, type: eventName });
1231
+ };
1232
+ if (parentKeys) {
1233
+ for (let i = parentKeys.length - 1; i >= 0; i -= 1) {
1234
+ const newObject = {};
1235
+ newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
1236
+ eventCallbackProps[eventCallbackPropName] = newObject;
1237
+ }
1238
+ }
1239
+ });
1240
+ }
1241
+ const computedVizProps = computeVizProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, props), evaluatedOptionsToUse), eventCallbackProps), {
1242
+ themeFunc
1243
+ }));
1244
+ let dataSourceMetadata = {};
1245
+ const OptionKey = "paginateDataSourceKey";
1246
+ const paginateDataSourceKey = (0, lodash_exports.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || "primary";
1247
+ if (vizConfig.supports.indexOf("page-and-sort" /* PAGE_AND_SORT */) > -1 && (0, lodash_exports.has)(dataSources, paginateDataSourceKey)) {
1248
+ const requestParams = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "requestParams"], {});
1249
+ const meta = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "meta"], {});
1250
+ const handleRequestParamsChange = (payload) => onRequestParamsChange(paginateDataSourceKey, payload);
1251
+ const sortParams = getSortingParams({
1252
+ requestParams,
1253
+ meta,
1254
+ onRequestParamsChange: handleRequestParamsChange
1255
+ });
1256
+ const paginatorParams = getPaginationParams({
1257
+ requestParams,
1258
+ meta,
1259
+ onRequestParamsChange: handleRequestParamsChange
1260
+ });
1261
+ dataSourceMetadata = {
1262
+ sortParams,
1263
+ paginatorParams
1264
+ };
1265
+ }
1266
+ if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
1267
+ return null;
1268
+ }
1269
+ return /* @__PURE__ */ react_exports.createElement(
1270
+ SanitizedReactViz,
1271
+ __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
1272
+ mode,
1273
+ width,
1274
+ height
1275
+ }, downsamplingProps), evaluatedOptionsToUse), computedVizProps), eventCallbackProps), dataSourceMetadata)
1276
+ );
1277
+ };
1278
+ DashboardViz.propTypes = __spreadValues(__spreadValues({}, SplunkVisualization_default.propTypes), ReactViz.propTypes);
1279
+ DashboardViz.defaultProps = __spreadProps(__spreadValues(__spreadValues({}, SplunkVisualization_default.defaultProps), ReactViz.defaultProps), {
1280
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1281
+ theme: {}
1282
+ });
1283
+ DashboardViz.config = vizConfig;
1284
+ return (0, styled_components_exports.withTheme)(
1285
+ withPlaceholder_default(withEditModeCover_default(DashboardViz, disableEditModeCover), useIconPlaceholder)
1286
+ );
1287
+ };
1288
+ var withDashboardViz_default = withDashboardViz;
1289
+ //# sourceMappingURL=withDashboardViz.js.map