@splunk/visualizations 25.1.0 → 25.3.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 (184) hide show
  1. package/.loki/reference/chrome_docker_PureVisualizations_PureEvents_Background_Color_Red.png +0 -0
  2. package/.loki/reference/chrome_docker_PureVisualizations_PureEvents_Basic.png +0 -0
  3. package/.loki/reference/chrome_docker_PureVisualizations_PureEvents_FieldSummaryTooltip_Actions_Simulated_Instance.png +0 -0
  4. package/.loki/reference/chrome_docker_PureVisualizations_PureEvents_FieldSummaryTooltip_Actions_for_Numeric_Field_Simulated_Instance.png +0 -0
  5. package/.loki/reference/chrome_docker_PureVisualizations_PureEvents_FieldSummaryTooltip_Dark.png +0 -0
  6. package/.loki/reference/chrome_docker_PureVisualizations_PureEvents_FieldSummaryTooltip_Light.png +0 -0
  7. package/.loki/reference/chrome_docker_PureVisualizations_PureSingleValueIcon_Background_color_cyan.png +0 -0
  8. package/.loki/reference/chrome_docker_PureVisualizations_PureSingleValueIcon_Unit_specified_Unit_Position_after_default.png +0 -0
  9. package/.loki/reference/chrome_docker_PureVisualizations_PureSingleValueIcon_Unit_specified_Unit_Position_before.png +0 -0
  10. package/.loki/reference/chrome_docker_PureVisualizations_PureSingleValue_Background_Color_white_Under_Label_and_Unit_specified.png +0 -0
  11. package/.loki/reference/chrome_docker_PureVisualizations_PureSingleValue_Major_Value_is_null.png +0 -0
  12. package/.loki/reference/chrome_docker_PureVisualizations_PureSingleValue_Unit_specified_Unit_Position_after_default.png +0 -0
  13. package/.loki/reference/chrome_docker_PureVisualizations_PureSingleValue_Unit_specified_Unit_Position_before.png +0 -0
  14. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Area_Editor.png +0 -0
  15. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Bar_Editor.png +0 -0
  16. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Bubble_Editor.png +0 -0
  17. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_ChoroplethSvg_Editor.png +0 -0
  18. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Column_Editor.png +0 -0
  19. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Ellipse_Editor.png +0 -0
  20. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Events_Editor.png +0 -0
  21. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_FillerGauge_Editor.png +0 -0
  22. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Image_Editor.png +0 -0
  23. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Line_Editor.png +0 -0
  24. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_LinkGraph_Editor.png +0 -0
  25. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Map_Editor.png +0 -0
  26. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Markdown_Editor.png +0 -0
  27. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_MarkerGauge_Editor.png +0 -0
  28. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Parallel_Coordinates_Editor.png +0 -0
  29. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Pie_Editor.png +0 -0
  30. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Punchcard_Editor.png +0 -0
  31. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Rectangle_Editor.png +0 -0
  32. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Sankey_Editor.png +0 -0
  33. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Scatter_Editor.png +0 -0
  34. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Single_Value_Editor.png +0 -0
  35. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Single_Value_Icon_Editor.png +0 -0
  36. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Single_Value_Radial_Editor.png +0 -0
  37. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Table_Editor.png +0 -0
  38. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Background_Color_Light_Blue.png +0 -0
  39. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Basic_Events.png +0 -0
  40. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Event_Actions.png +0 -0
  41. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Field_Actions.png +0 -0
  42. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Field_Summary.png +0 -0
  43. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Field_Summary_Simulated_Instance.png +0 -0
  44. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Footer_Fields.png +0 -0
  45. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Footer_Fields_with_Highlight.png +0 -0
  46. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Show_Placeholder.png +0 -0
  47. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Value_Highlighting.png +0 -0
  48. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Width_Height.png +0 -0
  49. package/.loki/reference/chrome_docker_Visualizations_Events_Events_Width_Percentage_50.png +0 -0
  50. package/.loki/reference/chrome_docker_Visualizations_Events_Events_With_Options.png +0 -0
  51. package/.loki/reference/chrome_docker_Visualizations_LinkGraph_LinkGraph_ES.png +0 -0
  52. package/.loki/reference/chrome_docker_Visualizations_Markdown_Markdown_Background_Color_af575a.png +0 -0
  53. package/.loki/reference/chrome_docker_Visualizations_Markdown_Markdown_Basic_Markdown.png +0 -0
  54. package/.loki/reference/chrome_docker_Visualizations_Markdown_Markdown_Begin_with_Text_Instead_of_Header.png +0 -0
  55. package/.loki/reference/chrome_docker_Visualizations_Markdown_Markdown_Font_Color_purple.png +0 -0
  56. package/.loki/reference/chrome_docker_Visualizations_Markdown_Markdown_Font_Size_custom.png +0 -0
  57. package/.loki/reference/chrome_docker_Visualizations_Markdown_Markdown_Font_Size_extraLarge.png +0 -0
  58. package/.loki/reference/chrome_docker_Visualizations_Markdown_Markdown_Markdown_with_number_as_DSL.png +0 -0
  59. package/.loki/reference/chrome_docker_Visualizations_Single_Value_Icon_Single_Value_Icon_Set_Unit_value_after.png +0 -0
  60. package/.loki/reference/chrome_docker_Visualizations_Single_Value_Icon_Single_Value_Icon_Set_Unit_value_before.png +0 -0
  61. package/.loki/reference/chrome_docker_Visualizations_Single_Value_Radial_Single_Value_Radial_Set_The_Unit_After.png +0 -0
  62. package/.loki/reference/chrome_docker_Visualizations_Single_Value_Radial_Single_Value_Radial_Set_The_Unit_Before.png +0 -0
  63. package/.loki/reference/chrome_docker_Visualizations_Single_Value_Single_Value_Set_Unit_Value_After.png +0 -0
  64. package/.loki/reference/chrome_docker_Visualizations_Single_Value_Single_Value_Set_Unit_Value_Before.png +0 -0
  65. package/Area.config.js +72 -22
  66. package/Area.config.js.map +1 -1
  67. package/Area.js +246 -185
  68. package/Area.js.map +1 -1
  69. package/Bar.config.js +17 -17
  70. package/Bar.config.js.map +1 -1
  71. package/Bar.js +191 -180
  72. package/Bar.js.map +1 -1
  73. package/Bubble.config.js +21 -14
  74. package/Bubble.config.js.map +1 -1
  75. package/Bubble.js +193 -175
  76. package/Bubble.js.map +1 -1
  77. package/ChoroplethSvg.config.js +6 -6
  78. package/ChoroplethSvg.config.js.map +1 -1
  79. package/ChoroplethSvg.js +180 -170
  80. package/ChoroplethSvg.js.map +1 -1
  81. package/Column.config.js +17 -17
  82. package/Column.config.js.map +1 -1
  83. package/Column.js +190 -180
  84. package/Column.js.map +1 -1
  85. package/Ellipse.config.js +3 -3
  86. package/Ellipse.config.js.map +1 -1
  87. package/Ellipse.js +144 -134
  88. package/Ellipse.js.map +1 -1
  89. package/Events.config.js +664 -0
  90. package/Events.config.js.map +1 -0
  91. package/Events.js +3114 -0
  92. package/Events.js.map +1 -0
  93. package/FillerGauge.config.js +20 -19
  94. package/FillerGauge.config.js.map +1 -1
  95. package/FillerGauge.js +183 -166
  96. package/FillerGauge.js.map +1 -1
  97. package/Image.config.js +5 -5
  98. package/Image.config.js.map +1 -1
  99. package/Image.js +128 -128
  100. package/Image.js.map +1 -1
  101. package/Line.config.js +73 -22
  102. package/Line.config.js.map +1 -1
  103. package/Line.js +253 -186
  104. package/Line.js.map +1 -1
  105. package/LinkGraph.config.js +15 -8
  106. package/LinkGraph.config.js.map +1 -1
  107. package/LinkGraph.js +25270 -434
  108. package/LinkGraph.js.map +1 -1
  109. package/Map.config.js +30 -29
  110. package/Map.config.js.map +1 -1
  111. package/Map.js +3064 -3125
  112. package/Map.js.map +1 -1
  113. package/Markdown.config.js +32 -10
  114. package/Markdown.config.js.map +1 -1
  115. package/Markdown.js +576 -529
  116. package/Markdown.js.map +1 -1
  117. package/MarkerGauge.config.js +16 -16
  118. package/MarkerGauge.config.js.map +1 -1
  119. package/MarkerGauge.js +1287 -1287
  120. package/MarkerGauge.js.map +1 -1
  121. package/ParallelCoordinates.config.js +14 -14
  122. package/ParallelCoordinates.config.js.map +1 -1
  123. package/ParallelCoordinates.js +532 -639
  124. package/ParallelCoordinates.js.map +1 -1
  125. package/Pie.config.js +16 -16
  126. package/Pie.config.js.map +1 -1
  127. package/Pie.js +1205 -1205
  128. package/Pie.js.map +1 -1
  129. package/Punchcard.config.js +14 -14
  130. package/Punchcard.config.js.map +1 -1
  131. package/Punchcard.js +2584 -2700
  132. package/Punchcard.js.map +1 -1
  133. package/Rectangle.config.js +7 -7
  134. package/Rectangle.config.js.map +1 -1
  135. package/Rectangle.js +726 -726
  136. package/Rectangle.js.map +1 -1
  137. package/Sankey.config.js +18 -18
  138. package/Sankey.config.js.map +1 -1
  139. package/Sankey.js +3132 -3253
  140. package/Sankey.js.map +1 -1
  141. package/Scatter.config.js +24 -16
  142. package/Scatter.config.js.map +1 -1
  143. package/Scatter.js +1402 -1395
  144. package/Scatter.js.map +1 -1
  145. package/SingleValue.config.js +11 -10
  146. package/SingleValue.config.js.map +1 -1
  147. package/SingleValue.js +2208 -2208
  148. package/SingleValue.js.map +1 -1
  149. package/SingleValueBasic.js +32 -32
  150. package/SingleValueBasic.js.map +1 -1
  151. package/SingleValueIcon.config.js +11 -10
  152. package/SingleValueIcon.config.js.map +1 -1
  153. package/SingleValueIcon.js +825 -966
  154. package/SingleValueIcon.js.map +1 -1
  155. package/SingleValueRadial.config.js +11 -10
  156. package/SingleValueRadial.config.js.map +1 -1
  157. package/SingleValueRadial.js +1897 -1897
  158. package/SingleValueRadial.js.map +1 -1
  159. package/Table.config.js +7 -7
  160. package/Table.config.js.map +1 -1
  161. package/Table.js +2158 -2155
  162. package/Table.js.map +1 -1
  163. package/common/EventsDoc.js +15 -8
  164. package/common/EventsDoc.js.map +1 -1
  165. package/common/GaugeMajorTicks.js +2 -2
  166. package/common/GaugeValueMarker.js +2 -2
  167. package/common/OptionsDoc.js +8 -8
  168. package/common/OptionsDoc.js.map +1 -1
  169. package/common/ThemesDoc.js +2 -2
  170. package/common/utils/configUtils.js +3 -3
  171. package/common/utils/configUtils.js.map +1 -1
  172. package/common/utils/dataUtils.js +136 -0
  173. package/common/utils/dataUtils.js.map +1 -0
  174. package/common/utils/hocUtils.js +2 -2
  175. package/common/utils/hocUtils.js.map +1 -1
  176. package/common/utils/mapUtils.js +11 -10
  177. package/common/utils/mapUtils.js.map +1 -1
  178. package/common/utils/singleValueUtils.js +3 -2
  179. package/common/utils/singleValueUtils.js.map +1 -1
  180. package/common/utils/testHelper.js +8 -8
  181. package/common/utils/testHelper.js.map +1 -1
  182. package/common/withDashboardViz.js +2 -2
  183. package/common/withDashboardViz.js.map +1 -1
  184. package/package.json +15 -13
package/Pie.js CHANGED
@@ -87,7 +87,7 @@ module.exports =
87
87
  /******/
88
88
  /******/
89
89
  /******/ // Load entry module and return exports
90
- /******/ return __webpack_require__(__webpack_require__.s = 230);
90
+ /******/ return __webpack_require__(__webpack_require__.s = 419);
91
91
  /******/ })
92
92
  /************************************************************************/
93
93
  /******/ ({
@@ -95,32 +95,39 @@ module.exports =
95
95
  /***/ 0:
96
96
  /***/ (function(module, exports) {
97
97
 
98
- module.exports = require("prop-types");
98
+ module.exports = require("react");
99
99
 
100
100
  /***/ }),
101
101
 
102
102
  /***/ 1:
103
103
  /***/ (function(module, exports) {
104
104
 
105
- module.exports = require("react");
105
+ module.exports = require("prop-types");
106
106
 
107
107
  /***/ }),
108
108
 
109
109
  /***/ 10:
110
110
  /***/ (function(module, exports) {
111
111
 
112
- module.exports = require("@babel/runtime/helpers/classCallCheck");
112
+ module.exports = require("@splunk/visualizations-shared/Message");
113
113
 
114
114
  /***/ }),
115
115
 
116
116
  /***/ 11:
117
117
  /***/ (function(module, exports) {
118
118
 
119
- module.exports = require("@splunk/visualizations-shared/colorUtils");
119
+ module.exports = require("@babel/runtime/helpers/classCallCheck");
120
120
 
121
121
  /***/ }),
122
122
 
123
123
  /***/ 12:
124
+ /***/ (function(module, exports) {
125
+
126
+ module.exports = require("@splunk/visualizations-shared/colorUtils");
127
+
128
+ /***/ }),
129
+
130
+ /***/ 13:
124
131
  /***/ (function(module, exports, __webpack_require__) {
125
132
 
126
133
  "use strict";
@@ -130,15 +137,15 @@ Object.defineProperty(exports, "__esModule", {
130
137
  value: true
131
138
  });
132
139
 
133
- var React = __webpack_require__(1);
140
+ var React = __webpack_require__(0);
134
141
 
135
142
  var styled_components_1 = __webpack_require__(4);
136
143
 
137
- var SizeAwareWrapper_1 = __webpack_require__(19);
144
+ var SizeAwareWrapper_1 = __webpack_require__(20);
138
145
 
139
- var style_1 = __webpack_require__(14);
146
+ var style_1 = __webpack_require__(15);
140
147
 
141
- var colorUtils_1 = __webpack_require__(11);
148
+ var colorUtils_1 = __webpack_require__(12);
142
149
 
143
150
  var Item = styled_components_1.default.div.attrs(function (_ref) {
144
151
  var width = _ref.width;
@@ -195,7 +202,7 @@ var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
195
202
 
196
203
  return React.createElement(FixSizeItem, {
197
204
  "data-test": "fix-size-item",
198
- "data-splunk-visualization-version": "25.1.0 - 812a9a4d8",
205
+ "data-splunk-visualization-version": "25.3.0 - dae70ec02",
199
206
  width: width,
200
207
  height: height,
201
208
  backgroundColor: backgroundColor
@@ -217,7 +224,7 @@ exports.default = withFixedSizeContainer;
217
224
 
218
225
  /***/ }),
219
226
 
220
- /***/ 13:
227
+ /***/ 14:
221
228
  /***/ (function(module, exports, __webpack_require__) {
222
229
 
223
230
  "use strict";
@@ -250,7 +257,7 @@ exports.extendStaticWrapperProps = extendStaticWrapperProps;
250
257
 
251
258
  /***/ }),
252
259
 
253
- /***/ 136:
260
+ /***/ 146:
254
261
  /***/ (function(module, exports, __webpack_require__) {
255
262
 
256
263
  "use strict";
@@ -278,21 +285,21 @@ var lodash_1 = __webpack_require__(3); // Charting imports i18n which needs to b
278
285
  // eslint-disable-next-line import/order
279
286
 
280
287
 
281
- var Charting_1 = __webpack_require__(55);
288
+ var Charting_1 = __webpack_require__(56);
282
289
 
283
- var charting_bundle_1 = __webpack_require__(51);
290
+ var charting_bundle_1 = __webpack_require__(53);
284
291
 
285
- var simpleXMLOptions_1 = __webpack_require__(61);
292
+ var simpleXMLOptions_1 = __webpack_require__(62);
286
293
 
287
- var config_1 = __webpack_require__(231);
294
+ var config_1 = __webpack_require__(420);
288
295
 
289
296
  exports.config = config_1.default;
290
297
 
291
- var withDashboardViz_1 = __webpack_require__(31);
298
+ var withDashboardViz_1 = __webpack_require__(32);
292
299
 
293
- var pieUtils_1 = __webpack_require__(233);
300
+ var pieUtils_1 = __webpack_require__(422);
294
301
 
295
- var chartingUtils_1 = __webpack_require__(50);
302
+ var chartingUtils_1 = __webpack_require__(52);
296
303
 
297
304
  var IconPlaceholder_1 = __webpack_require__(27);
298
305
 
@@ -380,29 +387,29 @@ exports.default = Pie;
380
387
 
381
388
  /***/ }),
382
389
 
383
- /***/ 14:
390
+ /***/ 15:
384
391
  /***/ (function(module, exports) {
385
392
 
386
393
  module.exports = require("@splunk/visualizations-shared/style");
387
394
 
388
395
  /***/ }),
389
396
 
390
- /***/ 15:
397
+ /***/ 16:
391
398
  /***/ (function(module, exports) {
392
399
 
393
400
  module.exports = require("@splunk/visualizations-shared/schemaUtils");
394
401
 
395
402
  /***/ }),
396
403
 
397
- /***/ 16:
404
+ /***/ 17:
398
405
  /***/ (function(module, exports, __webpack_require__) {
399
406
 
400
407
  "use strict";
401
408
 
402
409
 
403
- var _toConsumableArray = __webpack_require__(7);
410
+ var _toConsumableArray = __webpack_require__(8);
404
411
 
405
- var _defineProperty = __webpack_require__(6);
412
+ var _defineProperty = __webpack_require__(7);
406
413
 
407
414
  var __rest = this && this.__rest || function (s, e) {
408
415
  var t = {};
@@ -424,9 +431,9 @@ exports.insertLayout = exports.isDynamicOption = exports.uncollapseEditorConfig
424
431
 
425
432
  var lodash_1 = __webpack_require__(3);
426
433
 
427
- var schemaUtils_1 = __webpack_require__(15);
434
+ var schemaUtils_1 = __webpack_require__(16);
428
435
 
429
- var VizBehavior_1 = __webpack_require__(5);
436
+ var VizBehavior_1 = __webpack_require__(6);
430
437
 
431
438
  var dynamicOptionsDSLType = {
432
439
  type: 'string',
@@ -502,7 +509,7 @@ exports.enhanceOptionsSchemaWithDynamicOptions = enhanceOptionsSchemaWithDynamic
502
509
  */
503
510
 
504
511
  function enhanceConfig(vizConfig) {
505
- var enhancedConfig = vizConfig;
512
+ var enhancedConfig = Object.assign({}, vizConfig);
506
513
 
507
514
  if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS) !== -1) {
508
515
  enhancedConfig.optionsSchema = enhanceOptionsSchemaWithDynamicOptions(vizConfig.optionsSchema);
@@ -510,7 +517,7 @@ function enhanceConfig(vizConfig) {
510
517
 
511
518
  enhancedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
512
519
  return Object.assign(Object.assign({}, config), {
513
- open: false
520
+ open: config.open || false
514
521
  });
515
522
  });
516
523
  return enhancedConfig;
@@ -525,7 +532,7 @@ exports.enhanceConfig = enhanceConfig;
525
532
  */
526
533
 
527
534
  function uncollapseEditorConfig(vizConfig) {
528
- var editorPanelUncollapsedConfig = vizConfig;
535
+ var editorPanelUncollapsedConfig = Object.assign({}, vizConfig);
529
536
  editorPanelUncollapsedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
530
537
  return Object.assign(Object.assign({}, config), {
531
538
  open: true
@@ -631,24 +638,24 @@ exports.insertLayout = insertLayout;
631
638
 
632
639
  /***/ }),
633
640
 
634
- /***/ 18:
641
+ /***/ 19:
635
642
  /***/ (function(module, exports) {
636
643
 
637
644
  module.exports = require("@babel/runtime/helpers/createClass");
638
645
 
639
646
  /***/ }),
640
647
 
641
- /***/ 19:
648
+ /***/ 2:
642
649
  /***/ (function(module, exports) {
643
650
 
644
- module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
651
+ module.exports = require("@splunk/ui-utils/i18n");
645
652
 
646
653
  /***/ }),
647
654
 
648
- /***/ 2:
655
+ /***/ 20:
649
656
  /***/ (function(module, exports) {
650
657
 
651
- module.exports = require("@splunk/ui-utils/i18n");
658
+ module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
652
659
 
653
660
  /***/ }),
654
661
 
@@ -659,64 +666,198 @@ module.exports = require("@splunk/themes/pick");
659
666
 
660
667
  /***/ }),
661
668
 
662
- /***/ 22:
669
+ /***/ 23:
663
670
  /***/ (function(module, exports) {
664
671
 
665
672
  module.exports = require("@splunk/visualization-context/TimezoneContext");
666
673
 
667
674
  /***/ }),
668
675
 
669
- /***/ 23:
676
+ /***/ 24:
670
677
  /***/ (function(module, exports) {
671
678
 
672
679
  module.exports = require("@splunk/visualizations-shared/propUtils");
673
680
 
674
681
  /***/ }),
675
682
 
676
- /***/ 230:
683
+ /***/ 25:
684
+ /***/ (function(module, exports) {
685
+
686
+ module.exports = require("@splunk/visualizations-shared/hocUtils");
687
+
688
+ /***/ }),
689
+
690
+ /***/ 26:
691
+ /***/ (function(module, exports) {
692
+
693
+ module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");
694
+
695
+ /***/ }),
696
+
697
+ /***/ 27:
677
698
  /***/ (function(module, exports, __webpack_require__) {
678
699
 
679
700
  "use strict";
680
701
 
681
702
 
682
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
683
- if (k2 === undefined) k2 = k;
684
- Object.defineProperty(o, k2, {
685
- enumerable: true,
686
- get: function get() {
687
- return m[k];
688
- }
689
- });
690
- } : function (o, m, k, k2) {
691
- if (k2 === undefined) k2 = k;
692
- o[k2] = m[k];
703
+ Object.defineProperty(exports, "__esModule", {
704
+ value: true
693
705
  });
706
+ exports.shouldShowIconPlaceholder = void 0;
694
707
 
695
- var __exportStar = this && this.__exportStar || function (m, exports) {
696
- for (var p in m) {
697
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
708
+ var React = __webpack_require__(0);
709
+
710
+ var T = __webpack_require__(1);
711
+
712
+ var lodash_1 = __webpack_require__(3);
713
+
714
+ var i18n_1 = __webpack_require__(2);
715
+
716
+ var Message_1 = __webpack_require__(10);
717
+
718
+ var FixedSizeContainer_1 = __webpack_require__(13);
719
+ /**
720
+ * @method shouldShowIconPlaceholder
721
+ * @param {object} dataSources
722
+ * @param {boolean} loading
723
+ * @returns {boolean}
724
+ */
725
+
726
+
727
+ var shouldShowIconPlaceholder = function shouldShowIconPlaceholder(dataSources) {
728
+ var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
729
+ var data = lodash_1.get(dataSources, 'primary.data.columns[0]', undefined);
730
+ var noData = data === undefined;
731
+ var fields = lodash_1.get(dataSources, 'primary.data.fields[0]', undefined);
732
+ var noFields = fields === undefined;
733
+ return loading || noData || noFields;
734
+ };
735
+
736
+ exports.shouldShowIconPlaceholder = shouldShowIconPlaceholder;
737
+ var propTypes = {
738
+ icon: T.func,
739
+ width: T.oneOfType([T.string, T.number]),
740
+ height: T.oneOfType([T.string, T.number]),
741
+ // eslint-disable-next-line react/no-unused-prop-types
742
+ backgroundColor: T.string,
743
+ iconColor: T.string
744
+ };
745
+ /**
746
+ * @method IconPlaceholder
747
+ * @param {IconPlaceholderProps} props
748
+ * @returns {React.ReactElement}
749
+ */
750
+
751
+ var IconPlaceholder = function IconPlaceholder(props) {
752
+ var width = props.width,
753
+ height = props.height,
754
+ icon = props.icon,
755
+ iconColor = props.iconColor;
756
+
757
+ if (icon) {
758
+ return React.createElement(icon, {
759
+ style: {
760
+ left: '50%',
761
+ top: '50%',
762
+ color: iconColor,
763
+ opacity: 0.15,
764
+ position: 'absolute',
765
+ transform: 'translate(-50%, -50%)'
766
+ },
767
+ width: '50%',
768
+ height: '50%'
769
+ });
698
770
  }
771
+
772
+ return React.createElement(Message_1.default, {
773
+ width: width,
774
+ height: height,
775
+ level: "warning",
776
+ message: i18n_1._('No DataSource Connected')
777
+ });
778
+ };
779
+
780
+ IconPlaceholder.propTypes = propTypes;
781
+ IconPlaceholder.defaultProps = {
782
+ width: '100%',
783
+ height: 250
699
784
  };
785
+ exports.default = FixedSizeContainer_1.default(IconPlaceholder);
786
+
787
+ /***/ }),
788
+
789
+ /***/ 28:
790
+ /***/ (function(module, exports, __webpack_require__) {
791
+
792
+ "use strict";
793
+
794
+
795
+ var _defineProperty = __webpack_require__(7);
700
796
 
701
797
  Object.defineProperty(exports, "__esModule", {
702
798
  value: true
703
799
  });
704
- exports.default = void 0;
800
+ exports.getSortingParams = exports.SortParamsPropTypes = void 0;
705
801
 
706
- __exportStar(__webpack_require__(136), exports);
802
+ var T = __webpack_require__(1);
707
803
 
708
- var Pie_1 = __webpack_require__(136);
804
+ var lodash_1 = __webpack_require__(3);
709
805
 
710
- Object.defineProperty(exports, "default", {
711
- enumerable: true,
712
- get: function get() {
713
- return Pie_1.default;
714
- }
806
+ var DataSource_1 = __webpack_require__(39);
807
+
808
+ exports.SortParamsPropTypes = T.shape({
809
+ currentSortKey: T.string,
810
+ currentSortDir: T.oneOf(DataSource_1.validSortDirs),
811
+ onSort: T.func
715
812
  });
716
813
 
814
+ var getSortingParams = function getSortingParams(_ref) {
815
+ var requestParams = _ref.requestParams,
816
+ onRequestParamsChange = _ref.onRequestParamsChange;
817
+ var currentSortKey;
818
+ var currentSortDir;
819
+ var nextSortDirMap = {
820
+ asc: 'desc',
821
+ desc: 'asc',
822
+ none: 'asc'
823
+ };
824
+ var onSort;
825
+
826
+ if (lodash_1.isFunction(onRequestParamsChange)) {
827
+ if (requestParams && lodash_1.has(requestParams, 'sort')) {
828
+ currentSortKey = Object.keys(requestParams.sort).shift();
829
+ currentSortDir = requestParams.sort[currentSortKey];
830
+ } // undid memoization since there is a dependency on requestParams, which is a deeply nested object
831
+
832
+
833
+ onSort = function onSort(e, _ref2) {
834
+ var sortKey = _ref2.sortKey,
835
+ sortDir = _ref2.sortDir;
836
+
837
+ if (typeof sortKey === 'string') {
838
+ var nextSortDir = lodash_1.has(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : 'none';
839
+ onRequestParamsChange(Object.assign(Object.assign({}, requestParams), {
840
+ offset: 0,
841
+ sort: _defineProperty({}, sortKey, nextSortDir)
842
+ }));
843
+ } else {
844
+ onRequestParamsChange(requestParams);
845
+ }
846
+ };
847
+ }
848
+
849
+ return {
850
+ currentSortKey: currentSortKey,
851
+ currentSortDir: currentSortDir,
852
+ onSort: onSort
853
+ };
854
+ };
855
+
856
+ exports.getSortingParams = getSortingParams;
857
+
717
858
  /***/ }),
718
859
 
719
- /***/ 231:
860
+ /***/ 29:
720
861
  /***/ (function(module, exports, __webpack_require__) {
721
862
 
722
863
  "use strict";
@@ -725,1373 +866,1239 @@ Object.defineProperty(exports, "default", {
725
866
  Object.defineProperty(exports, "__esModule", {
726
867
  value: true
727
868
  });
869
+ exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;
728
870
 
729
- var ChartPie_1 = __webpack_require__(232);
871
+ var T = __webpack_require__(1);
730
872
 
731
- var placeholders_1 = __webpack_require__(45);
873
+ var lodash_1 = __webpack_require__(3);
732
874
 
733
- var i18n_1 = __webpack_require__(2);
875
+ exports.PaginatorParamsPropTypes = T.shape({
876
+ isPaging: T.bool,
877
+ current: T.number,
878
+ totalPages: T.number,
879
+ onChange: T.func
880
+ });
734
881
 
735
- var schemaUtils_1 = __webpack_require__(15);
882
+ var getPaginationParams = function getPaginationParams(_ref) {
883
+ var requestParams = _ref.requestParams,
884
+ meta = _ref.meta,
885
+ onRequestParamsChange = _ref.onRequestParamsChange;
886
+ var totalCount = meta && meta.totalCount || 0;
887
+ var offset = requestParams && requestParams.offset || 0;
888
+ var count = requestParams && requestParams.count;
889
+ var totalPages = typeof count === 'number' && count > 0 ? Math.ceil(totalCount / count) : 0;
890
+ var current = typeof count === 'number' && count > 0 ? Math.floor(offset / count) + 1 : 0;
891
+ var isPaging = totalPages > 1 && lodash_1.isFunction(onRequestParamsChange);
736
892
 
737
- var visualization_color_palettes_1 = __webpack_require__(44);
893
+ var onChangeHandler = function onChangeHandler(e, _ref2) {
894
+ var page = _ref2.page,
895
+ countArg = _ref2.count;
896
+ var newParams = lodash_1.cloneDeep(requestParams);
738
897
 
739
- var pick_1 = __webpack_require__(21);
898
+ if (typeof countArg === 'number') {
899
+ newParams.count = countArg;
900
+ newParams.offset = 0;
901
+ }
740
902
 
741
- var variables_1 = __webpack_require__(8);
903
+ var pageCount = typeof newParams.count === 'number' ? newParams.count : 10;
742
904
 
743
- var VizBehavior_1 = __webpack_require__(5);
905
+ if (typeof page === 'number' && page > 0) {
906
+ newParams.count = pageCount;
907
+ newParams.offset = (page - 1) * pageCount;
908
+ }
744
909
 
745
- var VizCategory_1 = __webpack_require__(30);
910
+ onRequestParamsChange(newParams);
911
+ };
746
912
 
747
- var configUtils_1 = __webpack_require__(16);
913
+ return {
914
+ isPaging: isPaging,
915
+ current: current,
916
+ totalPages: totalPages,
917
+ onChange: lodash_1.isFunction(onRequestParamsChange) ? onChangeHandler : lodash_1.noop
918
+ };
919
+ };
748
920
 
749
- var BackgroundColor_1 = __webpack_require__(49);
750
-
751
- var dataContract = {
752
- requiredDataSources: [{
753
- name: 'primary',
754
- description: 'DataSource that powers the visualization'
755
- }],
756
- optionalDataSources: [// Note: SCP-14090 disable ui for optional datasources. We may need to add it back later
757
- // {
758
- // name: 'annotation',
759
- // description: 'DataSource that populate event annotations',
760
- // },
761
- ],
762
- initialRequestParams: {
763
- primary: {
764
- offset: 0,
765
- count: 10000
766
- }
767
- }
768
- };
769
- var size = {
770
- initialWidth: 300,
771
- initialHeight: 300
772
- };
773
- var defaultContext = {};
774
- var optionsSchema = {
775
- backgroundColor: {
776
- default: '> themes.defaultBackgroundColor',
777
- description: 'Specify the color for the background. You may use a dataSource to apply the color. The default for enterprise light is "#ffffff". The default for enterprise dark is "#000000". The default for prisma dark is "#0b0c0e".',
778
- pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA,
779
- type: 'string'
780
- },
781
- collapseLabel: {
782
- description: 'Specify the label for the consolidated slice.',
783
- type: 'string',
784
- default: 'other'
785
- },
786
- collapseThreshold: {
787
- description: 'Specify the size threshold as a number between 0 and 1 (inclusive), of the whole pie at which slices collapse into one consolidated slice.',
788
- type: 'number',
789
- default: 0.01
790
- },
791
- label: {
792
- description: 'List of string values to display the pie chart labels.',
793
- type: 'array',
794
- items: {
795
- type: 'string'
796
- },
797
- default: '> primary | seriesByIndex(0)'
798
- },
799
- labelField: {
800
- default: '> label | getField()',
801
- description: 'Specify the field that corresponds to the labels.',
802
- type: 'string'
803
- },
804
- labelDisplay: {
805
- description: 'Specify whether to display the labels and/or slice percentages.',
806
- type: 'string',
807
- pattern: schemaUtils_1.getPattern(['values', 'valuesAndPercentage', 'off']),
808
- default: 'values'
809
- },
810
- resultLimit: {
811
- default: 50000,
812
- description: 'Specify the number of data points rendered in a chart.',
813
- type: 'number'
814
- },
815
- seriesColors: {
816
- default: visualization_color_palettes_1.VIZ_CATEGORICAL,
817
- description: 'Specify the colors used for a series. For example, ["#FF0000", "#0000FF", "#008000"].',
818
- type: 'array',
819
- items: {
820
- type: 'string'
821
- }
822
- },
823
- seriesColorsByField: {
824
- description: 'Specify the colors used for specific pie slice labels. For example: {"April": "#008000", "May": "#FFA500"}.',
825
- type: 'object'
826
- },
827
- showDonutHole: {
828
- default: false,
829
- description: 'Specify whether the pie should be a donut.',
830
- type: 'boolean'
831
- },
832
- value: {
833
- description: 'List of numerical values to power the pie chart.',
834
- type: 'array',
835
- items: {
836
- type: 'number'
837
- },
838
- default: '> primary | seriesByIndex(1)'
839
- },
840
- valueField: {
841
- default: '> value | getField()',
842
- description: 'Specify the field that corresponds to the data powering values.',
843
- type: 'string'
844
- }
845
- };
846
- var themes = {
847
- defaultBackgroundColor: function defaultBackgroundColor(props) {
848
- return pick_1.default({
849
- enterprise: {
850
- dark: variables_1.default.black(props),
851
- light: variables_1.default.backgroundColor(props)
852
- },
853
- prisma: variables_1.default.backgroundColorSidebar(props)
854
- })(props);
855
- }
856
- };
857
- var editorConfig = [{
858
- label: i18n_1._('General'),
859
- layout: [BackgroundColor_1.default({
860
- themes: themes
861
- })]
862
- }, {
863
- label: i18n_1._('Appearance'),
864
- layout: [[{
865
- label: i18n_1._('Display type'),
866
- option: 'showDonutHole',
867
- editor: 'editor.radioBar',
868
- editorProps: {
869
- values: [{
870
- label: i18n_1._('Pie'),
871
- value: false
872
- }, {
873
- label: i18n_1._('Donut'),
874
- value: true
875
- }]
876
- }
877
- }]]
878
- }, {
879
- label: i18n_1._('Labels'),
880
- layout: [[{
881
- label: i18n_1._('Label display'),
882
- option: 'labelDisplay',
883
- editor: 'editor.radioBar',
884
- editorProps: {
885
- values: [{
886
- label: i18n_1._('Values'),
887
- value: 'values'
888
- }, {
889
- label: i18n_1._('Values & Percent'),
890
- value: 'valuesAndPercentage'
891
- }, {
892
- label: i18n_1._('Off'),
893
- value: 'off'
894
- }]
895
- }
896
- }]]
897
- }, {
898
- label: i18n_1._('Collapse to Summary'),
899
- layout: [[{
900
- label: i18n_1._('Collapse Threshold'),
901
- option: 'collapseThreshold',
902
- editor: 'editor.number',
903
- editorProps: {
904
- min: 0,
905
- max: 1,
906
- step: 0.01
907
- }
908
- }], [{
909
- label: i18n_1._('Collapsed Slice Label'),
910
- option: 'collapseLabel',
911
- editor: 'editor.text'
912
- }]]
913
- }];
914
- /**
915
- * visualization configuration
916
- */
917
-
918
- var config = {
919
- /**
920
- * unique viz key
921
- */
922
- key: 'splunk.pie',
923
-
924
- /**
925
- * viz name
926
- */
927
- name: 'Pie',
928
- category: VizCategory_1.VizCategory.COMPARISONS,
929
-
930
- /**
931
- * viz icon
932
- */
933
- icon: ChartPie_1.default,
934
- placeholderIcon: placeholders_1.Pie,
935
- dataContract: dataContract,
936
- size: size,
937
- defaultContext: defaultContext,
938
- optionsSchema: optionsSchema,
939
- editorConfig: editorConfig,
940
- events: {
941
- 'point.click': {
942
- description: 'triggered when user clicks on a point in the pie chart'
943
- }
944
- },
945
- supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.PLACEHOLDER, VizBehavior_1.VizBehavior.EVENTS],
946
- themes: themes
947
- };
948
- exports.default = configUtils_1.enhanceConfig(config);
921
+ exports.getPaginationParams = getPaginationParams;
949
922
 
950
923
  /***/ }),
951
924
 
952
- /***/ 232:
925
+ /***/ 3:
953
926
  /***/ (function(module, exports) {
954
927
 
955
- module.exports = require("@splunk/react-icons/ChartPie");
928
+ module.exports = require("lodash");
956
929
 
957
930
  /***/ }),
958
931
 
959
- /***/ 233:
932
+ /***/ 31:
960
933
  /***/ (function(module, exports, __webpack_require__) {
961
934
 
962
935
  "use strict";
963
936
 
964
937
 
965
- var __rest = this && this.__rest || function (s, e) {
966
- var t = {};
967
-
968
- for (var p in s) {
969
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
970
- }
971
-
972
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
973
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
974
- }
975
- return t;
976
- };
977
-
978
938
  Object.defineProperty(exports, "__esModule", {
979
939
  value: true
980
940
  });
981
- exports.allInvalidDataValues = exports.invalidOptionField = exports.getPieOptionFieldIndex = exports.getPieMergedOptions = exports.convertToPieSCProperties = exports.mapToOldKey = exports.mapLabelDisplay = exports.convertToStringValues = void 0;
982
-
983
- var lodash_1 = __webpack_require__(3);
984
-
985
- var propUtils_1 = __webpack_require__(23);
986
-
987
- var dsl_1 = __webpack_require__(88);
988
-
989
- var hocUtils_1 = __webpack_require__(24);
941
+ exports.VizCategory = void 0;
942
+ var VizCategory;
990
943
 
991
- var JSONSchemaUtils_1 = __webpack_require__(25); // CONVERT THIS TO PIE THEN ADD TO Pie.TSX
992
- // map for key names which are either new or not present in SimpleXML options mapping
944
+ (function (VizCategory) {
945
+ VizCategory["SINGLE_VALUE"] = "Single Value";
946
+ VizCategory["TRENDS"] = "Trends";
947
+ VizCategory["COMPARISONS"] = "Comparisons";
948
+ VizCategory["TABLE"] = "Table";
949
+ VizCategory["GAUGE"] = "Gauge";
950
+ VizCategory["DISTRIBUTIONS"] = "Distributions";
951
+ VizCategory["CHOROPLETH"] = "Choropleth Maps";
952
+ VizCategory["SHAPES"] = "Shapes";
953
+ VizCategory["MISC"] = "misc";
954
+ VizCategory["FLOW"] = "Flow";
955
+ VizCategory["CORRELATION"] = "Correlation";
956
+ VizCategory["SPATIAL"] = "Spatial";
957
+ })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
993
958
 
959
+ /***/ }),
994
960
 
995
- var pieOptionsSCMapping = {
996
- resultLimit: 'resultTruncationLimit',
997
- seriesColorsByField: 'fieldColors',
998
- collapseThreshold: 'chart.sliceCollapsingThreshold',
999
- collapseLabel: 'chart.sliceCollapsingLabel'
1000
- };
1001
- /**
1002
- * Helper method to convert option which contains object literal values (e.g. arrays, objects)
1003
- * to strings as SC can only accept their stringified equivalents
1004
- * @method convertToStringValues
1005
- * @param {Object} options
1006
- * @returns {Object}
1007
- */
961
+ /***/ 32:
962
+ /***/ (function(module, exports, __webpack_require__) {
1008
963
 
1009
- var convertToStringValues = function convertToStringValues(options) {
1010
- var updatedOptions = propUtils_1.convertPropsToString({
1011
- vizProps: options,
1012
- propNames: ['seriesColors', 'fieldColors']
1013
- });
1014
- return Object.assign(Object.assign({}, options), updatedOptions);
1015
- };
964
+ "use strict";
1016
965
 
1017
- exports.convertToStringValues = convertToStringValues;
1018
- /**
1019
- * Helper method to map labelDisplay options to jsCharting options
1020
- * @method mapLabelDisplay
1021
- * @param {Object} options
1022
- * @returns {Object}
1023
- */
1024
966
 
1025
- var mapLabelDisplay = function mapLabelDisplay(_a) {
1026
- var labelDisplay = _a.labelDisplay,
1027
- options = __rest(_a, ["labelDisplay"]);
967
+ Object.defineProperty(exports, "__esModule", {
968
+ value: true
969
+ });
1028
970
 
1029
- var convertedOptions = Object.assign(Object.assign({}, options), {
1030
- // default for labelDisplay option is 'values'
1031
- 'chart.showLabels': true,
1032
- 'chart.showPercent': false
1033
- });
971
+ var React = __webpack_require__(0);
1034
972
 
1035
- if (labelDisplay === 'valuesAndPercentage') {
1036
- convertedOptions['chart.showPercent'] = true;
1037
- } else if (labelDisplay === 'off') {
1038
- convertedOptions['chart.showLabels'] = false;
1039
- }
973
+ var lodash_1 = __webpack_require__(3);
1040
974
 
1041
- return convertedOptions;
1042
- };
975
+ var getSettingsFromThemedProps_1 = __webpack_require__(33);
1043
976
 
1044
- exports.mapLabelDisplay = mapLabelDisplay;
1045
- /**
1046
- * Helper method to update the option names which can be mapped to SimpleXML options or
1047
- * can be used directly with SC if don't have a 1-1 mapping in SimpleXML
1048
- * @method mapToOldKey
1049
- * @param {Object} options
1050
- * @returns {Object}
1051
- */
977
+ var Options_1 = __webpack_require__(34);
1052
978
 
1053
- var mapToOldKey = function mapToOldKey(options) {
1054
- return lodash_1.mapKeys(options, function (val, key) {
1055
- return pieOptionsSCMapping[key] ? pieOptionsSCMapping[key] : key;
1056
- });
1057
- };
979
+ var SanitizeProps_1 = __webpack_require__(35);
1058
980
 
1059
- exports.mapToOldKey = mapToOldKey;
1060
- /**
1061
- * Chained helper for mapping the option properties (and values) we expose in config.ts into property values that splunk-charting accepts
1062
- * This is for options that has new key name and can not directly be mapped with SimpleXML or
1063
- * don't have a 1-1 mapping in SimpleXML (i.e. a straightforward name mapping where values are preserved)
1064
- * @method convertToPieSCProperties
1065
- * @param {Object} originalOptions
1066
- * @returns {Object}
1067
- */
981
+ var TimezoneContext_1 = __webpack_require__(23);
1068
982
 
1069
- var convertToPieSCProperties = function convertToPieSCProperties(originalOptions) {
1070
- return lodash_1.chain(exports.mapToOldKey(originalOptions)).thru(exports.convertToStringValues).thru(exports.mapLabelDisplay).value();
1071
- };
983
+ var moment_1 = __webpack_require__(36);
1072
984
 
1073
- exports.convertToPieSCProperties = convertToPieSCProperties;
1074
- /**
1075
- * Return all merged options (default + config) using vizConfig and options
1076
- * @param options
1077
- * @param vizConfig
1078
- * @returns
1079
- */
985
+ var styled_components_1 = __webpack_require__(4);
1080
986
 
1081
- var getPieMergedOptions = function getPieMergedOptions(options, vizConfig) {
1082
- return hocUtils_1.deepMergeWithArrayPrimitiveOverrides({}, options, JSONSchemaUtils_1.pickFieldFromJSONSchema(vizConfig.optionsSchema, 'default'));
1083
- };
987
+ var hocUtils_1 = __webpack_require__(25);
1084
988
 
1085
- exports.getPieMergedOptions = getPieMergedOptions;
1086
- /**
1087
- * Returns option's field index. If not found returns -1
1088
- * @param optionName
1089
- * @param dataSources
1090
- * @param options
1091
- * @param vizConfig
1092
- * @returns
1093
- */
989
+ var JSONSchemaUtils_1 = __webpack_require__(26);
1094
990
 
1095
- var getPieOptionFieldIndex = function getPieOptionFieldIndex(optionName, dataSources, options, vizConfig) {
1096
- var mergedOptions = exports.getPieMergedOptions(options, vizConfig); // find the field name configured for pie "value"
991
+ var SplunkVisualization_1 = __webpack_require__(37);
1097
992
 
1098
- var fieldName = dsl_1.getFieldsFromDSL(mergedOptions[optionName], dataSources)[0];
1099
- var fields = dataSources.primary.data.fields; // find the field index configured for pie "value"
993
+ var VizBehavior_1 = __webpack_require__(6);
1100
994
 
1101
- var fieldIndex = fields.findIndex(function (field) {
1102
- return (typeof field === 'string' ? field : field.name.toString()) === fieldName;
1103
- });
1104
- return fieldIndex;
1105
- };
995
+ var getSorting_1 = __webpack_require__(28);
1106
996
 
1107
- exports.getPieOptionFieldIndex = getPieOptionFieldIndex;
1108
- /**
1109
- * Returns true if columns data has invalid data format for specified option (label or value)
1110
- * @param optionName
1111
- * @param dataSources
1112
- * @param options
1113
- * @param vizConfig
1114
- * @returns
1115
- */
997
+ var getPagination_1 = __webpack_require__(29);
1116
998
 
1117
- var invalidOptionField = function invalidOptionField(optionName, dataSources, options, vizConfig) {
1118
- var columns = dataSources.primary.data.columns;
1119
- var fieldIndex = exports.getPieOptionFieldIndex(optionName, dataSources, options, vizConfig);
999
+ var useDeepMemo_1 = __webpack_require__(40);
1120
1000
 
1121
- if (fieldIndex === -1 || !columns[fieldIndex] || !Array.isArray(columns[fieldIndex]) || Array.isArray(columns[fieldIndex]) && !columns[fieldIndex].length) {
1122
- return true;
1123
- }
1001
+ var MissingPropsMessage_1 = __webpack_require__(41);
1124
1002
 
1125
- return false;
1126
- };
1003
+ var withEditModeCover_1 = __webpack_require__(42);
1127
1004
 
1128
- exports.invalidOptionField = invalidOptionField;
1005
+ var withPlaceholder_1 = __webpack_require__(43);
1129
1006
  /**
1130
- * Helper function to evaluate if all data values are invalid (zero or negative)
1007
+ * hoc that wraps a pure react visualization in a Dashboard visualization
1008
+ * @param {DashboardVizOpts} opts
1009
+ * @returns {HOC}
1131
1010
  */
1132
1011
 
1133
- var allInvalidDataValues = function allInvalidDataValues(dataSources, options, vizConfig) {
1134
- var columns = dataSources.primary.data.columns; // find the field index configured for pie "value"
1135
-
1136
- var valueFieldIndex = exports.getPieOptionFieldIndex('value', dataSources, options, vizConfig); // check if all values are invalid
1137
1012
 
1138
- if (Array.isArray(columns) && columns[valueFieldIndex] && Array.isArray(columns[valueFieldIndex])) {
1139
- return !columns[valueFieldIndex].some(function (value) {
1140
- return +value > 0;
1141
- });
1142
- }
1143
-
1144
- return false;
1145
- };
1013
+ var withDashboardViz = function withDashboardViz(opts) {
1014
+ var ReactViz = opts.ReactViz,
1015
+ vizConfig = opts.vizConfig,
1016
+ _opts$computeVizProps = opts.computeVizProps,
1017
+ computeVizProps = _opts$computeVizProps === void 0 ? function () {} : _opts$computeVizProps,
1018
+ disableEditModeCover = opts.disableEditModeCover,
1019
+ useIconPlaceholder = opts.useIconPlaceholder; // sanitizing props before sending them to reactviz.
1146
1020
 
1147
- exports.allInvalidDataValues = allInvalidDataValues;
1021
+ var SanitizedReactViz = SanitizeProps_1.withSanitizedProps(ReactViz);
1022
+ var defaultOptions = JSONSchemaUtils_1.pickFieldFromJSONSchema(vizConfig.optionsSchema, 'default');
1148
1023
 
1149
- /***/ }),
1024
+ var DashboardViz = function DashboardViz(props) {
1025
+ var mode = props.mode,
1026
+ hasEventHandlers = props.hasEventHandlers,
1027
+ dataSources = props.dataSources,
1028
+ options = props.options,
1029
+ _props$context = props.context,
1030
+ context = _props$context === void 0 ? {} : _props$context,
1031
+ width = props.width,
1032
+ height = props.height,
1033
+ onComputedProps = props.onComputedProps,
1034
+ onEventTrigger = props.onEventTrigger,
1035
+ theme = props.theme,
1036
+ onRequestParamsChange = props.onRequestParamsChange;
1150
1037
 
1151
- /***/ 24:
1152
- /***/ (function(module, exports) {
1038
+ var _React$useContext = React.useContext(TimezoneContext_1.default),
1039
+ serializedTimezone = _React$useContext.serializedTimezone;
1153
1040
 
1154
- module.exports = require("@splunk/visualizations-shared/hocUtils");
1041
+ if (serializedTimezone) {
1042
+ /*
1043
+ @splunk/moment currently does not allow us to customize the timezone on a per visualization basis.
1044
+ This ensures that if a timezone was provided via TimezoneContext @splunk/moment time formatting
1045
+ will use it.
1046
+ @TODO(pwied):
1047
+ - remove when we moved away from @splunk/moment
1048
+ - provide timezone context to dynamic option evaluation phase
1049
+ */
1050
+ if (!moment_1.default.getDefaultSplunkTimezone()) {
1051
+ moment_1.default.setDefaultSplunkTimezone(serializedTimezone);
1052
+ }
1053
+ }
1155
1054
 
1156
- /***/ }),
1055
+ var themeFunc = function themeFunc(themeVar) {
1056
+ var _a, _b;
1157
1057
 
1158
- /***/ 25:
1159
- /***/ (function(module, exports) {
1058
+ return (_b = (_a = vizConfig.themes)[themeVar]) === null || _b === void 0 ? void 0 : _b.call(_a, props);
1059
+ };
1160
1060
 
1161
- module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");
1061
+ var bgColorFromTheme = themeFunc('defaultBackgroundColor');
1162
1062
 
1163
- /***/ }),
1063
+ var _getSettingsFromTheme = getSettingsFromThemedProps_1.default({
1064
+ theme: theme
1065
+ }),
1066
+ currentThemeFamily = _getSettingsFromTheme.family,
1067
+ currentThemeColorScheme = _getSettingsFromTheme.colorScheme,
1068
+ currentThemeDensity = _getSettingsFromTheme.density;
1164
1069
 
1165
- /***/ 27:
1166
- /***/ (function(module, exports, __webpack_require__) {
1070
+ var evaluatedOptions = {}; // evaluatedOptions need to be initialized as an empty object
1167
1071
 
1168
- "use strict";
1072
+ evaluatedOptions = useDeepMemo_1.useDeepMemo(function () {
1073
+ try {
1074
+ return Options_1.Options.evaluate({
1075
+ context: lodash_1.defaultsDeep({}, context, vizConfig.defaultContext),
1076
+ options: hocUtils_1.deepMergeWithArrayPrimitiveOverrides({}, options, defaultOptions)
1077
+ }, dataSources, themeFunc);
1078
+ } catch (e) {
1079
+ // eslint-disable-next-line no-console
1080
+ console.error("unexpected error evaluating options: + ".concat(e.message));
1081
+ return {};
1082
+ }
1083
+ }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, options, context, dataSources, serializedTimezone]); // useEffect hook needs to be initialized before any early returns
1084
+ // this is in accordance with the order of hook calls being the same on each render https://reactjs.org/docs/hooks-rules.html#explanation
1169
1085
 
1086
+ React.useEffect(function () {
1087
+ onComputedProps(evaluatedOptions);
1088
+ }); // present warning message if any required props are missing
1170
1089
 
1171
- Object.defineProperty(exports, "__esModule", {
1172
- value: true
1173
- });
1174
- exports.shouldShowIconPlaceholder = void 0;
1090
+ var _vizConfig$requiredPr = vizConfig.requiredProps,
1091
+ requiredProps = _vizConfig$requiredPr === void 0 ? [] : _vizConfig$requiredPr,
1092
+ supports = vizConfig.supports;
1093
+ var missing = MissingPropsMessage_1.missingKeys(requiredProps, evaluatedOptions);
1175
1094
 
1176
- var React = __webpack_require__(1);
1095
+ if (missing.length > 0 && supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER)) {
1096
+ return React.createElement(MissingPropsMessage_1.default, {
1097
+ "data-test": "missing-props-message",
1098
+ width: width,
1099
+ height: height,
1100
+ missingProps: missing,
1101
+ backgroundColor: bgColorFromTheme
1102
+ });
1103
+ } // events
1177
1104
 
1178
- var T = __webpack_require__(0);
1179
1105
 
1180
- var lodash_1 = __webpack_require__(3);
1106
+ var eventCallbackProps = {};
1181
1107
 
1182
- var i18n_1 = __webpack_require__(2);
1108
+ if (hasEventHandlers && mode === 'view' && vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.EVENTS) > -1) {
1109
+ var supportedEvents = vizConfig.events;
1110
+ Object.keys(supportedEvents).forEach(function (eventName) {
1111
+ var eventCallbackPropName = lodash_1.camelCase("on.".concat(eventName));
1112
+ eventCallbackProps[eventCallbackPropName] = null; // todo: refactor single value and single value icon to send payload from viz
1113
+ // then remove these lines
1183
1114
 
1184
- var Message_1 = __webpack_require__(9);
1115
+ var payloadKeys = supportedEvents[eventName].payloadKeys;
1116
+ var payload = {};
1185
1117
 
1186
- var FixedSizeContainer_1 = __webpack_require__(12);
1187
- /**
1188
- * @method shouldShowIconPlaceholder
1189
- * @param {object} dataSources
1190
- * @param {boolean} loading
1191
- * @returns {boolean}
1192
- */
1118
+ if (Array.isArray(payloadKeys) && payloadKeys.length) {
1119
+ payloadKeys.forEach(function (p) {
1120
+ payload[p] = evaluatedOptions[p];
1121
+ });
1122
+ }
1193
1123
 
1124
+ eventCallbackProps[eventCallbackPropName] = function (ev) {
1125
+ if (ev && ev.payload) {
1126
+ payload = ev.payload;
1127
+ }
1194
1128
 
1195
- var shouldShowIconPlaceholder = function shouldShowIconPlaceholder(dataSources) {
1196
- var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1197
- var data = lodash_1.get(dataSources, 'primary.data.columns[0]', undefined);
1198
- var noData = data === undefined;
1199
- var fields = lodash_1.get(dataSources, 'primary.data.fields[0]', undefined);
1200
- var noFields = fields === undefined;
1201
- return loading || noData || noFields;
1202
- };
1129
+ return onEventTrigger({
1130
+ originalEvent: ev,
1131
+ payload: payload,
1132
+ type: eventName
1133
+ });
1134
+ };
1135
+ });
1136
+ } // compute pure viz props which are not from options
1203
1137
 
1204
- exports.shouldShowIconPlaceholder = shouldShowIconPlaceholder;
1205
- var propTypes = {
1206
- icon: T.func,
1207
- width: T.oneOfType([T.string, T.number]),
1208
- height: T.oneOfType([T.string, T.number]),
1209
- // eslint-disable-next-line react/no-unused-prop-types
1210
- backgroundColor: T.string,
1211
- iconColor: T.string
1212
- };
1213
- /**
1214
- * @method IconPlaceholder
1215
- * @param {IconPlaceholderProps} props
1216
- * @returns {React.ReactElement}
1217
- */
1218
1138
 
1219
- var IconPlaceholder = function IconPlaceholder(props) {
1220
- var width = props.width,
1221
- height = props.height,
1222
- icon = props.icon,
1223
- iconColor = props.iconColor;
1139
+ var computedVizProps = computeVizProps(Object.assign(Object.assign(Object.assign(Object.assign({}, props), evaluatedOptions), eventCallbackProps), {
1140
+ themeFunc: themeFunc
1141
+ }));
1142
+ /**
1143
+ * PAGE_AND_SORT behavior
1144
+ *
1145
+ * Some visualizations, like table, requires metadata about the datasource,
1146
+ * like total number of results, current count, offset, and sort, for rendering
1147
+ * paginator and sorting direction. In this approach, the visualization
1148
+ * allow users to set 'paginateDataSourceKey' to select which datasource
1149
+ * should the visualization extract the metadata from. It defaults to 'primary' datasource.
1150
+ * The visualization config should set the PAGE_AND_SORT behavior to receive
1151
+ * 'requestParams', 'meta' and onRequestParams callback as props.
1152
+ *
1153
+ * In future, we could automatically detect which all datasources are being used
1154
+ * and bind those magically to pagination/sorting behavior.
1155
+ */
1224
1156
 
1225
- if (icon) {
1226
- return React.createElement(icon, {
1227
- style: {
1228
- left: '50%',
1229
- top: '50%',
1230
- color: iconColor,
1231
- opacity: 0.15,
1232
- position: 'absolute',
1233
- transform: 'translate(-50%, -50%)'
1234
- },
1235
- width: '50%',
1236
- height: '50%'
1237
- });
1238
- }
1157
+ var dataSourceMetadata = {};
1158
+ var OptionKey = 'paginateDataSourceKey';
1159
+ var paginateDataSourceKey = lodash_1.has(evaluatedOptions, OptionKey) && evaluatedOptions[OptionKey] || 'primary';
1239
1160
 
1240
- return React.createElement(Message_1.default, {
1241
- width: width,
1242
- height: height,
1243
- level: "warning",
1244
- message: i18n_1._('No DataSource Connected')
1245
- });
1246
- };
1161
+ if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.PAGE_AND_SORT) > -1 && lodash_1.has(dataSources, paginateDataSourceKey)) {
1162
+ var requestParams = lodash_1.get(dataSources, [paginateDataSourceKey, 'requestParams'], {});
1163
+ var meta = lodash_1.get(dataSources, [paginateDataSourceKey, 'meta'], {});
1247
1164
 
1248
- IconPlaceholder.propTypes = propTypes;
1249
- IconPlaceholder.defaultProps = {
1250
- width: '100%',
1251
- height: 250
1252
- };
1253
- exports.default = FixedSizeContainer_1.default(IconPlaceholder);
1165
+ var handleRequestParamsChange = function handleRequestParamsChange(payload) {
1166
+ return onRequestParamsChange(paginateDataSourceKey, payload);
1167
+ };
1254
1168
 
1255
- /***/ }),
1169
+ var sortParams = getSorting_1.getSortingParams({
1170
+ requestParams: requestParams,
1171
+ meta: meta,
1172
+ onRequestParamsChange: handleRequestParamsChange
1173
+ });
1174
+ var paginatorParams = getPagination_1.getPaginationParams({
1175
+ requestParams: requestParams,
1176
+ meta: meta,
1177
+ onRequestParamsChange: handleRequestParamsChange
1178
+ });
1179
+ dataSourceMetadata = {
1180
+ sortParams: sortParams,
1181
+ paginatorParams: paginatorParams
1182
+ };
1183
+ }
1256
1184
 
1257
- /***/ 28:
1258
- /***/ (function(module, exports, __webpack_require__) {
1185
+ return React.createElement(SanitizedReactViz, Object.assign({
1186
+ mode: mode,
1187
+ width: width,
1188
+ height: height
1189
+ }, evaluatedOptions, computedVizProps, eventCallbackProps, dataSourceMetadata));
1190
+ };
1259
1191
 
1260
- "use strict";
1192
+ DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
1193
+ DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
1194
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1195
+ theme: {}
1196
+ }); // attach viz config
1261
1197
 
1198
+ DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
1262
1199
 
1263
- var _defineProperty = __webpack_require__(6);
1200
+ return styled_components_1.withTheme(withPlaceholder_1.default(withEditModeCover_1.default(DashboardViz, disableEditModeCover), useIconPlaceholder));
1201
+ };
1264
1202
 
1265
- Object.defineProperty(exports, "__esModule", {
1266
- value: true
1267
- });
1268
- exports.getSortingParams = exports.SortParamsPropTypes = void 0;
1203
+ exports.default = withDashboardViz;
1269
1204
 
1270
- var T = __webpack_require__(0);
1205
+ /***/ }),
1271
1206
 
1272
- var lodash_1 = __webpack_require__(3);
1207
+ /***/ 33:
1208
+ /***/ (function(module, exports) {
1273
1209
 
1274
- var DataSource_1 = __webpack_require__(38);
1210
+ module.exports = require("@splunk/themes/getSettingsFromThemedProps");
1275
1211
 
1276
- exports.SortParamsPropTypes = T.shape({
1277
- currentSortKey: T.string,
1278
- currentSortDir: T.oneOf(DataSource_1.validSortDirs),
1279
- onSort: T.func
1280
- });
1212
+ /***/ }),
1281
1213
 
1282
- var getSortingParams = function getSortingParams(_ref) {
1283
- var requestParams = _ref.requestParams,
1284
- onRequestParamsChange = _ref.onRequestParamsChange;
1285
- var currentSortKey;
1286
- var currentSortDir;
1287
- var nextSortDirMap = {
1288
- asc: 'desc',
1289
- desc: 'asc',
1290
- none: 'asc'
1291
- };
1292
- var onSort;
1214
+ /***/ 34:
1215
+ /***/ (function(module, exports) {
1293
1216
 
1294
- if (lodash_1.isFunction(onRequestParamsChange)) {
1295
- if (requestParams && lodash_1.has(requestParams, 'sort')) {
1296
- currentSortKey = Object.keys(requestParams.sort).shift();
1297
- currentSortDir = requestParams.sort[currentSortKey];
1298
- } // undid memoization since there is a dependency on requestParams, which is a deeply nested object
1217
+ module.exports = require("@splunk/visualization-encoding/Options");
1299
1218
 
1219
+ /***/ }),
1300
1220
 
1301
- onSort = function onSort(e, _ref2) {
1302
- var sortKey = _ref2.sortKey,
1303
- sortDir = _ref2.sortDir;
1221
+ /***/ 35:
1222
+ /***/ (function(module, exports) {
1304
1223
 
1305
- if (typeof sortKey === 'string') {
1306
- var nextSortDir = lodash_1.has(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : 'none';
1307
- onRequestParamsChange(Object.assign(Object.assign({}, requestParams), {
1308
- offset: 0,
1309
- sort: _defineProperty({}, sortKey, nextSortDir)
1310
- }));
1311
- } else {
1312
- onRequestParamsChange(requestParams);
1313
- }
1314
- };
1315
- }
1224
+ module.exports = require("@splunk/visualizations-shared/SanitizeProps");
1316
1225
 
1317
- return {
1318
- currentSortKey: currentSortKey,
1319
- currentSortDir: currentSortDir,
1320
- onSort: onSort
1321
- };
1322
- };
1226
+ /***/ }),
1323
1227
 
1324
- exports.getSortingParams = getSortingParams;
1228
+ /***/ 36:
1229
+ /***/ (function(module, exports) {
1230
+
1231
+ module.exports = require("@splunk/moment");
1325
1232
 
1326
1233
  /***/ }),
1327
1234
 
1328
- /***/ 29:
1235
+ /***/ 37:
1329
1236
  /***/ (function(module, exports, __webpack_require__) {
1330
1237
 
1331
1238
  "use strict";
1332
1239
 
1333
1240
 
1241
+ var _classCallCheck = __webpack_require__(11);
1242
+
1334
1243
  Object.defineProperty(exports, "__esModule", {
1335
1244
  value: true
1336
1245
  });
1337
- exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;
1246
+ exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
1247
+ /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
1338
1248
 
1339
- var T = __webpack_require__(0);
1249
+ var T = __webpack_require__(1);
1340
1250
 
1341
1251
  var lodash_1 = __webpack_require__(3);
1342
1252
 
1343
- exports.PaginatorParamsPropTypes = T.shape({
1344
- isPaging: T.bool,
1345
- current: T.number,
1346
- totalPages: T.number,
1347
- onChange: T.func
1348
- });
1253
+ var VizActionHandler_1 = __webpack_require__(38); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
1349
1254
 
1350
- var getPaginationParams = function getPaginationParams(_ref) {
1351
- var requestParams = _ref.requestParams,
1352
- meta = _ref.meta,
1353
- onRequestParamsChange = _ref.onRequestParamsChange;
1354
- var totalCount = meta && meta.totalCount || 0;
1355
- var offset = requestParams && requestParams.offset || 0;
1356
- var count = requestParams && requestParams.count;
1357
- var totalPages = typeof count === 'number' && count > 0 ? Math.ceil(totalCount / count) : 0;
1358
- var current = typeof count === 'number' && count > 0 ? Math.floor(offset / count) + 1 : 0;
1359
- var isPaging = totalPages > 1 && lodash_1.isFunction(onRequestParamsChange);
1360
1255
 
1361
- var onChangeHandler = function onChangeHandler(e, _ref2) {
1362
- var page = _ref2.page,
1363
- countArg = _ref2.count;
1364
- var newParams = lodash_1.cloneDeep(requestParams);
1256
+ exports.INITIAL_WIDTH = 250;
1257
+ exports.INITIAL_HEIGHT = 250;
1258
+ /**
1259
+ * A Splunk visualization
1260
+ */
1365
1261
 
1366
- if (typeof countArg === 'number') {
1367
- newParams.count = countArg;
1368
- newParams.offset = 0;
1369
- }
1262
+ var SplunkVisualization = function SplunkVisualization() {
1263
+ _classCallCheck(this, SplunkVisualization);
1264
+ };
1370
1265
 
1371
- var pageCount = typeof newParams.count === 'number' ? newParams.count : 10;
1266
+ SplunkVisualization.propTypes = {
1267
+ /**
1268
+ * display mode
1269
+ */
1270
+ mode: T.oneOf(['view', 'edit', 'export']).isRequired,
1372
1271
 
1373
- if (typeof page === 'number' && page > 0) {
1374
- newParams.count = pageCount;
1375
- newParams.offset = (page - 1) * pageCount;
1376
- }
1272
+ /**
1273
+ * width in pixel or string, defaults to 100%
1274
+ */
1275
+ width: T.oneOfType([T.string, T.number]).isRequired,
1377
1276
 
1378
- onRequestParamsChange(newParams);
1379
- };
1277
+ /**
1278
+ * height in pixel or string
1279
+ */
1280
+ height: T.oneOfType([T.string, T.number]).isRequired,
1380
1281
 
1381
- return {
1382
- isPaging: isPaging,
1383
- current: current,
1384
- totalPages: totalPages,
1385
- onChange: lodash_1.isFunction(onRequestParamsChange) ? onChangeHandler : lodash_1.noop
1386
- };
1387
- };
1282
+ /**
1283
+ * visualization context used for dynamic option evaluation
1284
+ */
1285
+ context: T.object,
1388
1286
 
1389
- exports.getPaginationParams = getPaginationParams;
1287
+ /**
1288
+ * visualization formatting options
1289
+ */
1290
+ options: T.object,
1390
1291
 
1391
- /***/ }),
1292
+ /**
1293
+ * A callback to update formatting options
1294
+ */
1295
+ onOptionsChange: T.func,
1392
1296
 
1393
- /***/ 3:
1394
- /***/ (function(module, exports) {
1297
+ /**
1298
+ * datasource state which include data and request params, object key indicate the datasource type.
1299
+ */
1300
+ dataSources: T.objectOf(T.shape({
1301
+ /**
1302
+ * current request params
1303
+ */
1304
+ requestParams: T.object,
1395
1305
 
1396
- module.exports = require("lodash");
1306
+ /**
1307
+ * current dataset
1308
+ */
1309
+ data: T.shape({
1310
+ fields: T.array,
1311
+ columns: T.array
1312
+ }),
1397
1313
 
1398
- /***/ }),
1314
+ /**
1315
+ * error
1316
+ */
1317
+ error: T.shape({
1318
+ level: T.string,
1319
+ message: T.string
1320
+ }),
1399
1321
 
1400
- /***/ 30:
1401
- /***/ (function(module, exports, __webpack_require__) {
1322
+ /**
1323
+ * meta data that came with the dataset
1324
+ */
1325
+ meta: T.object
1326
+ })),
1402
1327
 
1403
- "use strict";
1328
+ /**
1329
+ * A callback to trigger event
1330
+ */
1331
+ onEventTrigger: T.func,
1404
1332
 
1333
+ /**
1334
+ * Inform viz if there are handlers listening to events
1335
+ */
1336
+ hasEventHandlers: T.bool,
1405
1337
 
1406
- Object.defineProperty(exports, "__esModule", {
1407
- value: true
1408
- });
1409
- exports.VizCategory = void 0;
1410
- var VizCategory;
1338
+ /**
1339
+ * A callback to communicate computed props to a consumer
1340
+ */
1341
+ onComputedProps: T.func,
1411
1342
 
1412
- (function (VizCategory) {
1413
- VizCategory["SINGLE_VALUE"] = "Single Value";
1414
- VizCategory["TRENDS"] = "Trends";
1415
- VizCategory["COMPARISONS"] = "Comparisons";
1416
- VizCategory["TABLE"] = "Table";
1417
- VizCategory["GAUGE"] = "Gauge";
1418
- VizCategory["DISTRIBUTIONS"] = "Distributions";
1419
- VizCategory["CHOROPLETH"] = "Choropleth Maps";
1420
- VizCategory["SHAPES"] = "Shapes";
1421
- VizCategory["MISC"] = "misc";
1422
- VizCategory["FLOW"] = "Flow";
1423
- VizCategory["CORRELATION"] = "Correlation";
1424
- VizCategory["SPATIAL"] = "Spatial";
1425
- })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
1343
+ /**
1344
+ * A callback to obtain visualization api
1345
+ */
1346
+ vizActionHandlerRef: T.func,
1347
+ loading: T.bool,
1348
+ theme: T.object,
1349
+
1350
+ /**
1351
+ * A callback to request new data with updated request params
1352
+ */
1353
+ onRequestParamsChange: T.func
1354
+ };
1355
+ /**
1356
+ *
1357
+ */
1358
+
1359
+ SplunkVisualization.defaultProps = {
1360
+ // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
1361
+ width: '100%',
1362
+ height: exports.INITIAL_HEIGHT,
1363
+ dataSources: {},
1364
+ onEventTrigger: function onEventTrigger() {
1365
+ return {};
1366
+ },
1367
+ mode: 'view',
1368
+ hasEventHandlers: false,
1369
+ options: {},
1370
+ context: {},
1371
+ onOptionsChange: function onOptionsChange() {
1372
+ return {};
1373
+ },
1374
+ vizActionHandlerRef: function vizActionHandlerRef() {
1375
+ return new VizActionHandler_1.DefaultVizActionHandler();
1376
+ },
1377
+ onComputedProps: function onComputedProps() {
1378
+ return {};
1379
+ },
1380
+ loading: false,
1381
+ onRequestParamsChange: lodash_1.noop
1382
+ };
1383
+ exports.default = SplunkVisualization;
1426
1384
 
1427
1385
  /***/ }),
1428
1386
 
1429
- /***/ 31:
1387
+ /***/ 38:
1430
1388
  /***/ (function(module, exports, __webpack_require__) {
1431
1389
 
1432
1390
  "use strict";
1433
1391
 
1434
1392
 
1393
+ var _classCallCheck = __webpack_require__(11);
1394
+
1395
+ var _createClass = __webpack_require__(19);
1396
+
1435
1397
  Object.defineProperty(exports, "__esModule", {
1436
1398
  value: true
1437
1399
  });
1400
+ exports.DefaultVizActionHandler = void 0;
1438
1401
 
1439
- var React = __webpack_require__(1);
1402
+ var DefaultVizActionHandler = /*#__PURE__*/function () {
1403
+ function DefaultVizActionHandler() {
1404
+ _classCallCheck(this, DefaultVizActionHandler);
1405
+ }
1440
1406
 
1441
- var lodash_1 = __webpack_require__(3);
1407
+ _createClass(DefaultVizActionHandler, [{
1408
+ key: "focus",
1409
+ value: function focus() {// noop
1410
+ }
1411
+ }, {
1412
+ key: "snapshot",
1413
+ value: function snapshot() {
1414
+ return null; // noop
1415
+ }
1416
+ }]);
1442
1417
 
1443
- var getSettingsFromThemedProps_1 = __webpack_require__(32);
1418
+ return DefaultVizActionHandler;
1419
+ }();
1444
1420
 
1445
- var Options_1 = __webpack_require__(33);
1421
+ exports.DefaultVizActionHandler = DefaultVizActionHandler;
1446
1422
 
1447
- var SanitizeProps_1 = __webpack_require__(34);
1423
+ /***/ }),
1448
1424
 
1449
- var TimezoneContext_1 = __webpack_require__(22);
1425
+ /***/ 39:
1426
+ /***/ (function(module, exports, __webpack_require__) {
1450
1427
 
1451
- var moment_1 = __webpack_require__(35);
1428
+ "use strict";
1452
1429
 
1453
- var styled_components_1 = __webpack_require__(4);
1454
1430
 
1455
- var hocUtils_1 = __webpack_require__(24);
1431
+ Object.defineProperty(exports, "__esModule", {
1432
+ value: true
1433
+ });
1434
+ exports.validSortDirs = void 0;
1435
+ exports.validSortDirs = ['asc', 'desc', 'none'];
1436
+
1437
+ /***/ }),
1456
1438
 
1457
- var JSONSchemaUtils_1 = __webpack_require__(25);
1439
+ /***/ 4:
1440
+ /***/ (function(module, exports) {
1458
1441
 
1459
- var SplunkVisualization_1 = __webpack_require__(36);
1442
+ module.exports = require("styled-components");
1460
1443
 
1461
- var VizBehavior_1 = __webpack_require__(5);
1444
+ /***/ }),
1462
1445
 
1463
- var getSorting_1 = __webpack_require__(28);
1446
+ /***/ 40:
1447
+ /***/ (function(module, exports, __webpack_require__) {
1464
1448
 
1465
- var getPagination_1 = __webpack_require__(29);
1449
+ "use strict";
1466
1450
 
1467
- var useDeepMemo_1 = __webpack_require__(39);
1468
1451
 
1469
- var MissingPropsMessage_1 = __webpack_require__(40);
1452
+ Object.defineProperty(exports, "__esModule", {
1453
+ value: true
1454
+ });
1455
+ exports.useDeepMemo = void 0;
1470
1456
 
1471
- var withEditModeCover_1 = __webpack_require__(41);
1457
+ var react_1 = __webpack_require__(0);
1472
1458
 
1473
- var withPlaceholder_1 = __webpack_require__(42);
1459
+ var lodash_1 = __webpack_require__(3);
1474
1460
  /**
1475
- * hoc that wraps a pure react visualization in a Dashboard visualization
1476
- * @param {DashboardVizOpts} opts
1477
- * @returns {HOC}
1461
+ * This hook evaluates and stores the result of a passed function and only
1462
+ * re-evaluates the function when passed dependencies change.
1463
+ *
1464
+ * It is different from the internal React useMemo in the following aspects:
1465
+ * - it only stores the last evaluated result
1466
+ * - it uses a deep equality check to determine if dependencies have changed
1467
+ *
1468
+ * Inspired by apollo-client's useDeepMemo
1469
+ *
1470
+ * @param fn the function to be executed and
1471
+ * @param dependencies an array of dependencies
1478
1472
  */
1479
1473
 
1480
1474
 
1481
- var withDashboardViz = function withDashboardViz(opts) {
1482
- var ReactViz = opts.ReactViz,
1483
- vizConfig = opts.vizConfig,
1484
- _opts$computeVizProps = opts.computeVizProps,
1485
- computeVizProps = _opts$computeVizProps === void 0 ? function () {} : _opts$computeVizProps,
1486
- disableEditModeCover = opts.disableEditModeCover,
1487
- useIconPlaceholder = opts.useIconPlaceholder; // sanitizing props before sending them to reactviz.
1488
-
1489
- var SanitizedReactViz = SanitizeProps_1.withSanitizedProps(ReactViz);
1490
- var defaultOptions = JSONSchemaUtils_1.pickFieldFromJSONSchema(vizConfig.optionsSchema, 'default');
1475
+ var useDeepMemo = function useDeepMemo(fn, dependencies) {
1476
+ var ref = react_1.useRef();
1491
1477
 
1492
- var DashboardViz = function DashboardViz(props) {
1493
- var mode = props.mode,
1494
- hasEventHandlers = props.hasEventHandlers,
1495
- dataSources = props.dataSources,
1496
- options = props.options,
1497
- _props$context = props.context,
1498
- context = _props$context === void 0 ? {} : _props$context,
1499
- width = props.width,
1500
- height = props.height,
1501
- onComputedProps = props.onComputedProps,
1502
- onEventTrigger = props.onEventTrigger,
1503
- theme = props.theme,
1504
- onRequestParamsChange = props.onRequestParamsChange;
1478
+ if (!ref.current || !lodash_1.isEqual(dependencies, ref.current.dependencies)) {
1479
+ ref.current = {
1480
+ dependencies: dependencies,
1481
+ value: fn()
1482
+ };
1483
+ }
1505
1484
 
1506
- var _React$useContext = React.useContext(TimezoneContext_1.default),
1507
- serializedTimezone = _React$useContext.serializedTimezone;
1485
+ return ref.current.value;
1486
+ };
1508
1487
 
1509
- if (serializedTimezone) {
1510
- /*
1511
- @splunk/moment currently does not allow us to customize the timezone on a per visualization basis.
1512
- This ensures that if a timezone was provided via TimezoneContext @splunk/moment time formatting
1513
- will use it.
1514
- @TODO(pwied):
1515
- - remove when we moved away from @splunk/moment
1516
- - provide timezone context to dynamic option evaluation phase
1517
- */
1518
- if (!moment_1.default.getDefaultSplunkTimezone()) {
1519
- moment_1.default.setDefaultSplunkTimezone(serializedTimezone);
1520
- }
1521
- }
1488
+ exports.useDeepMemo = useDeepMemo;
1522
1489
 
1523
- var themeFunc = function themeFunc(themeVar) {
1524
- var _a, _b;
1490
+ /***/ }),
1525
1491
 
1526
- return (_b = (_a = vizConfig.themes)[themeVar]) === null || _b === void 0 ? void 0 : _b.call(_a, props);
1527
- };
1492
+ /***/ 41:
1493
+ /***/ (function(module, exports, __webpack_require__) {
1528
1494
 
1529
- var bgColorFromTheme = themeFunc('defaultBackgroundColor');
1495
+ "use strict";
1530
1496
 
1531
- var _getSettingsFromTheme = getSettingsFromThemedProps_1.default({
1532
- theme: theme
1533
- }),
1534
- currentThemeFamily = _getSettingsFromTheme.family,
1535
- currentThemeColorScheme = _getSettingsFromTheme.colorScheme,
1536
- currentThemeDensity = _getSettingsFromTheme.density;
1537
1497
 
1538
- var evaluatedOptions = {}; // evaluatedOptions need to be initialized as an empty object
1498
+ Object.defineProperty(exports, "__esModule", {
1499
+ value: true
1500
+ });
1501
+ exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
1539
1502
 
1540
- evaluatedOptions = useDeepMemo_1.useDeepMemo(function () {
1541
- try {
1542
- return Options_1.Options.evaluate({
1543
- context: lodash_1.defaultsDeep({}, context, vizConfig.defaultContext),
1544
- options: hocUtils_1.deepMergeWithArrayPrimitiveOverrides({}, options, defaultOptions)
1545
- }, dataSources, themeFunc);
1546
- } catch (e) {
1547
- // eslint-disable-next-line no-console
1548
- console.error("unexpected error evaluating options: + ".concat(e.message));
1549
- return {};
1550
- }
1551
- }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, options, context, dataSources, serializedTimezone]); // useEffect hook needs to be initialized before any early returns
1552
- // this is in accordance with the order of hook calls being the same on each render https://reactjs.org/docs/hooks-rules.html#explanation
1503
+ var React = __webpack_require__(0);
1553
1504
 
1554
- React.useEffect(function () {
1555
- onComputedProps(evaluatedOptions);
1556
- }); // present warning message if any required props are missing
1505
+ var T = __webpack_require__(1);
1557
1506
 
1558
- var _vizConfig$requiredPr = vizConfig.requiredProps,
1559
- requiredProps = _vizConfig$requiredPr === void 0 ? [] : _vizConfig$requiredPr,
1560
- supports = vizConfig.supports;
1561
- var missing = MissingPropsMessage_1.missingKeys(requiredProps, evaluatedOptions);
1507
+ var i18n_1 = __webpack_require__(2);
1562
1508
 
1563
- if (missing.length > 0 && supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER)) {
1564
- return React.createElement(MissingPropsMessage_1.default, {
1565
- "data-test": "missing-props-message",
1566
- width: width,
1567
- height: height,
1568
- missingProps: missing,
1569
- backgroundColor: bgColorFromTheme
1570
- });
1571
- } // events
1509
+ var Message_1 = __webpack_require__(10);
1572
1510
 
1511
+ var FixedSizeContainer_1 = __webpack_require__(13);
1512
+ /**
1513
+ * @method isMissing
1514
+ * @param {any} v
1515
+ * @returns {boolean} true if the input value === null or undefined
1516
+ */
1573
1517
 
1574
- var eventCallbackProps = {};
1575
1518
 
1576
- if (hasEventHandlers && mode === 'view' && vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.EVENTS) > -1) {
1577
- var supportedEvents = vizConfig.events;
1578
- Object.keys(supportedEvents).forEach(function (eventName) {
1579
- var eventCallbackPropName = lodash_1.camelCase("on.".concat(eventName));
1580
- eventCallbackProps[eventCallbackPropName] = null; // todo: refactor single value and single value icon to send payload from viz
1581
- // then remove these lines
1519
+ var isMissing = function isMissing(v) {
1520
+ return v === null || v === undefined;
1521
+ };
1582
1522
 
1583
- var payloadKeys = supportedEvents[eventName].payloadKeys;
1584
- var payload = {};
1523
+ exports.isMissing = isMissing;
1524
+ /**
1525
+ * @method misskingKeys
1526
+ * @param {string[]} keys
1527
+ * @param {object} target
1528
+ * @returns {string[]} the keys of missing required props
1529
+ */
1585
1530
 
1586
- if (Array.isArray(payloadKeys) && payloadKeys.length) {
1587
- payloadKeys.forEach(function (p) {
1588
- payload[p] = evaluatedOptions[p];
1589
- });
1590
- }
1531
+ var missingKeys = function missingKeys(keys, target) {
1532
+ return keys.filter(function (k) {
1533
+ return exports.isMissing(target[k]);
1534
+ });
1535
+ };
1591
1536
 
1592
- eventCallbackProps[eventCallbackPropName] = function (ev) {
1593
- if (ev && ev.payload) {
1594
- payload = ev.payload;
1595
- }
1537
+ exports.missingKeys = missingKeys;
1538
+ var propTypes = {
1539
+ width: T.oneOfType([T.string, T.number]),
1540
+ height: T.oneOfType([T.string, T.number]),
1541
+ // eslint-disable-next-line react/no-unused-prop-types
1542
+ backgroundColor: T.string,
1543
+ missingProps: T.arrayOf(T.string)
1544
+ };
1545
+ /**
1546
+ * @method MissingPropsMessage
1547
+ * @param {MissingPropsProps} props
1548
+ * @returns {React.ReactElement}
1549
+ */
1596
1550
 
1597
- return onEventTrigger({
1598
- originalEvent: ev,
1599
- payload: payload,
1600
- type: eventName
1601
- });
1602
- };
1603
- });
1604
- } // compute pure viz props which are not from options
1551
+ var MissingPropsMessage = function MissingPropsMessage(props) {
1552
+ var width = props.width,
1553
+ height = props.height,
1554
+ missingProps = props.missingProps;
1555
+ return React.createElement(Message_1.default, {
1556
+ "data-test": "message",
1557
+ width: width,
1558
+ height: height,
1559
+ message: i18n_1._("Missing property: ".concat(missingProps.join(', ')))
1560
+ });
1561
+ };
1605
1562
 
1563
+ exports.MissingPropsMessage = MissingPropsMessage;
1564
+ exports.MissingPropsMessage.propTypes = propTypes;
1565
+ exports.MissingPropsMessage.defaultProps = {
1566
+ width: '100%',
1567
+ height: 250
1568
+ };
1569
+ exports.default = FixedSizeContainer_1.default(exports.MissingPropsMessage);
1606
1570
 
1607
- var computedVizProps = computeVizProps(Object.assign(Object.assign(Object.assign(Object.assign({}, props), evaluatedOptions), eventCallbackProps), {
1608
- themeFunc: themeFunc
1609
- }));
1610
- /**
1611
- * PAGE_AND_SORT behavior
1612
- *
1613
- * Some visualizations, like table, requires metadata about the datasource,
1614
- * like total number of results, current count, offset, and sort, for rendering
1615
- * paginator and sorting direction. In this approach, the visualization
1616
- * allow users to set 'paginateDataSourceKey' to select which datasource
1617
- * should the visualization extract the metadata from. It defaults to 'primary' datasource.
1618
- * The visualization config should set the PAGE_AND_SORT behavior to receive
1619
- * 'requestParams', 'meta' and onRequestParams callback as props.
1620
- *
1621
- * In future, we could automatically detect which all datasources are being used
1622
- * and bind those magically to pagination/sorting behavior.
1623
- */
1571
+ /***/ }),
1624
1572
 
1625
- var dataSourceMetadata = {};
1626
- var OptionKey = 'paginateDataSourceKey';
1627
- var paginateDataSourceKey = lodash_1.has(evaluatedOptions, OptionKey) && evaluatedOptions[OptionKey] || 'primary';
1573
+ /***/ 419:
1574
+ /***/ (function(module, exports, __webpack_require__) {
1628
1575
 
1629
- if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.PAGE_AND_SORT) > -1 && lodash_1.has(dataSources, paginateDataSourceKey)) {
1630
- var requestParams = lodash_1.get(dataSources, [paginateDataSourceKey, 'requestParams'], {});
1631
- var meta = lodash_1.get(dataSources, [paginateDataSourceKey, 'meta'], {});
1576
+ "use strict";
1632
1577
 
1633
- var handleRequestParamsChange = function handleRequestParamsChange(payload) {
1634
- return onRequestParamsChange(paginateDataSourceKey, payload);
1635
- };
1636
1578
 
1637
- var sortParams = getSorting_1.getSortingParams({
1638
- requestParams: requestParams,
1639
- meta: meta,
1640
- onRequestParamsChange: handleRequestParamsChange
1641
- });
1642
- var paginatorParams = getPagination_1.getPaginationParams({
1643
- requestParams: requestParams,
1644
- meta: meta,
1645
- onRequestParamsChange: handleRequestParamsChange
1646
- });
1647
- dataSourceMetadata = {
1648
- sortParams: sortParams,
1649
- paginatorParams: paginatorParams
1650
- };
1579
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1580
+ if (k2 === undefined) k2 = k;
1581
+ Object.defineProperty(o, k2, {
1582
+ enumerable: true,
1583
+ get: function get() {
1584
+ return m[k];
1651
1585
  }
1586
+ });
1587
+ } : function (o, m, k, k2) {
1588
+ if (k2 === undefined) k2 = k;
1589
+ o[k2] = m[k];
1590
+ });
1652
1591
 
1653
- return React.createElement(SanitizedReactViz, Object.assign({
1654
- mode: mode,
1655
- width: width,
1656
- height: height
1657
- }, evaluatedOptions, computedVizProps, eventCallbackProps, dataSourceMetadata));
1658
- };
1592
+ var __exportStar = this && this.__exportStar || function (m, exports) {
1593
+ for (var p in m) {
1594
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1595
+ }
1596
+ };
1659
1597
 
1660
- DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
1661
- DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
1662
- // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
1663
- theme: {}
1664
- }); // attach viz config
1598
+ Object.defineProperty(exports, "__esModule", {
1599
+ value: true
1600
+ });
1601
+ exports.default = void 0;
1665
1602
 
1666
- DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
1603
+ __exportStar(__webpack_require__(146), exports);
1667
1604
 
1668
- return styled_components_1.withTheme(withPlaceholder_1.default(withEditModeCover_1.default(DashboardViz, disableEditModeCover), useIconPlaceholder));
1669
- };
1605
+ var Pie_1 = __webpack_require__(146);
1670
1606
 
1671
- exports.default = withDashboardViz;
1607
+ Object.defineProperty(exports, "default", {
1608
+ enumerable: true,
1609
+ get: function get() {
1610
+ return Pie_1.default;
1611
+ }
1612
+ });
1672
1613
 
1673
1614
  /***/ }),
1674
1615
 
1675
- /***/ 32:
1676
- /***/ (function(module, exports) {
1616
+ /***/ 42:
1617
+ /***/ (function(module, exports, __webpack_require__) {
1677
1618
 
1678
- module.exports = require("@splunk/themes/getSettingsFromThemedProps");
1619
+ "use strict";
1679
1620
 
1680
- /***/ }),
1681
1621
 
1682
- /***/ 33:
1683
- /***/ (function(module, exports) {
1622
+ Object.defineProperty(exports, "__esModule", {
1623
+ value: true
1624
+ });
1684
1625
 
1685
- module.exports = require("@splunk/visualization-encoding/Options");
1626
+ var React = __webpack_require__(0);
1686
1627
 
1687
- /***/ }),
1628
+ var styled_components_1 = __webpack_require__(4);
1688
1629
 
1689
- /***/ 34:
1690
- /***/ (function(module, exports) {
1630
+ var hocUtils_1 = __webpack_require__(14);
1691
1631
 
1692
- module.exports = require("@splunk/visualizations-shared/SanitizeProps");
1632
+ var Cover = styled_components_1.default.div.withConfig({
1633
+ displayName: "withEditModeCover__Cover",
1634
+ componentId: "sc-1gsbnxb-0"
1635
+ })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
1636
+ var Blocker = styled_components_1.default.div.attrs({
1637
+ 'data-splunk-visualization-version': "25.3.0 - dae70ec02"
1638
+ }).withConfig({
1639
+ displayName: "withEditModeCover__Blocker",
1640
+ componentId: "sc-1gsbnxb-1"
1641
+ })(["position:relative;width:100%;height:100%;"]);
1642
+ /**
1643
+ * HOC that renders a cover layer in edit mode
1644
+ * @method withEditModeCover
1645
+ * @param {ExtendedDashViz} Visualization
1646
+ * @returns {ExtendedDashViz} Wrapper
1647
+ */
1693
1648
 
1694
- /***/ }),
1649
+ var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
1650
+ var Wrapper = function Wrapper(props) {
1651
+ var mode = props.mode;
1652
+ var showEditCover = mode === 'edit' && !disableEditModeCover;
1653
+ return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
1654
+ "data-test": "edit-mode-cover"
1655
+ }));
1656
+ };
1695
1657
 
1696
- /***/ 35:
1697
- /***/ (function(module, exports) {
1658
+ hocUtils_1.extendStaticWrapperProps({
1659
+ Wrapper: Wrapper,
1660
+ Visualization: Visualization
1661
+ });
1662
+ return Wrapper;
1663
+ };
1698
1664
 
1699
- module.exports = require("@splunk/moment");
1665
+ exports.default = withEditModeCover;
1700
1666
 
1701
1667
  /***/ }),
1702
1668
 
1703
- /***/ 36:
1669
+ /***/ 420:
1704
1670
  /***/ (function(module, exports, __webpack_require__) {
1705
1671
 
1706
1672
  "use strict";
1707
1673
 
1708
1674
 
1709
- var _classCallCheck = __webpack_require__(10);
1710
-
1711
1675
  Object.defineProperty(exports, "__esModule", {
1712
1676
  value: true
1713
1677
  });
1714
- exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
1715
- /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
1716
-
1717
- var T = __webpack_require__(0);
1718
1678
 
1719
- var lodash_1 = __webpack_require__(3);
1720
-
1721
- var VizActionHandler_1 = __webpack_require__(37); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
1722
-
1723
-
1724
- exports.INITIAL_WIDTH = 250;
1725
- exports.INITIAL_HEIGHT = 250;
1726
- /**
1727
- * A Splunk visualization
1728
- */
1729
-
1730
- var SplunkVisualization = function SplunkVisualization() {
1731
- _classCallCheck(this, SplunkVisualization);
1732
- };
1733
-
1734
- SplunkVisualization.propTypes = {
1735
- /**
1736
- * display mode
1737
- */
1738
- mode: T.oneOf(['view', 'edit', 'export']).isRequired,
1679
+ var ChartPie_1 = __webpack_require__(421);
1739
1680
 
1740
- /**
1741
- * width in pixel or string, defaults to 100%
1742
- */
1743
- width: T.oneOfType([T.string, T.number]).isRequired,
1681
+ var placeholders_1 = __webpack_require__(44);
1744
1682
 
1745
- /**
1746
- * height in pixel or string
1747
- */
1748
- height: T.oneOfType([T.string, T.number]).isRequired,
1683
+ var i18n_1 = __webpack_require__(2);
1749
1684
 
1750
- /**
1751
- * visualization context used for dynamic option evaluation
1752
- */
1753
- context: T.object,
1685
+ var schemaUtils_1 = __webpack_require__(16);
1754
1686
 
1755
- /**
1756
- * visualization formatting options
1757
- */
1758
- options: T.object,
1687
+ var visualization_color_palettes_1 = __webpack_require__(46);
1759
1688
 
1760
- /**
1761
- * A callback to update formatting options
1762
- */
1763
- onOptionsChange: T.func,
1689
+ var pick_1 = __webpack_require__(21);
1764
1690
 
1765
- /**
1766
- * datasource state which include data and request params, object key indicate the datasource type.
1767
- */
1768
- dataSources: T.objectOf(T.shape({
1769
- /**
1770
- * current request params
1771
- */
1772
- requestParams: T.object,
1691
+ var variables_1 = __webpack_require__(9);
1773
1692
 
1774
- /**
1775
- * current dataset
1776
- */
1777
- data: T.shape({
1778
- fields: T.array,
1779
- columns: T.array
1780
- }),
1693
+ var VizBehavior_1 = __webpack_require__(6);
1781
1694
 
1782
- /**
1783
- * error
1784
- */
1785
- error: T.shape({
1786
- level: T.string,
1787
- message: T.string
1788
- }),
1695
+ var VizCategory_1 = __webpack_require__(31);
1789
1696
 
1790
- /**
1791
- * meta data that came with the dataset
1792
- */
1793
- meta: T.object
1794
- })),
1697
+ var configUtils_1 = __webpack_require__(17);
1795
1698
 
1796
- /**
1797
- * A callback to trigger event
1798
- */
1799
- onEventTrigger: T.func,
1699
+ var BackgroundColor_1 = __webpack_require__(50);
1800
1700
 
1801
- /**
1802
- * Inform viz if there are handlers listening to events
1803
- */
1804
- hasEventHandlers: T.bool,
1701
+ var dataContract = {
1702
+ requiredDataSources: [{
1703
+ name: 'primary',
1704
+ description: 'DataSource that powers the visualization'
1705
+ }],
1706
+ optionalDataSources: [// Note: SCP-14090 disable ui for optional datasources. We may need to add it back later
1707
+ // {
1708
+ // name: 'annotation',
1709
+ // description: 'DataSource that populate event annotations',
1710
+ // },
1711
+ ],
1712
+ initialRequestParams: {
1713
+ primary: {
1714
+ offset: 0,
1715
+ count: 10000
1716
+ }
1717
+ }
1718
+ };
1719
+ var size = {
1720
+ initialWidth: 300,
1721
+ initialHeight: 300
1722
+ };
1723
+ var defaultContext = {};
1724
+ var optionsSchema = {
1725
+ backgroundColor: {
1726
+ default: '> themes.defaultBackgroundColor',
1727
+ description: 'Specify the color for the background. You may use a dataSource to apply the color. The default for enterprise light is "#ffffff". The default for enterprise dark is "#000000". The default for prisma dark is "#0b0c0e".',
1728
+ pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA,
1729
+ type: 'string'
1730
+ },
1731
+ collapseLabel: {
1732
+ description: 'Specify the label for the consolidated slice.',
1733
+ type: 'string',
1734
+ default: 'other'
1735
+ },
1736
+ collapseThreshold: {
1737
+ description: 'Specify the size threshold as a number between 0 and 1 (inclusive), of the whole pie at which slices collapse into one consolidated slice.',
1738
+ type: 'number',
1739
+ default: 0.01
1740
+ },
1741
+ label: {
1742
+ description: 'List of string values to display the pie chart labels.',
1743
+ type: 'array',
1744
+ items: {
1745
+ type: 'string'
1746
+ },
1747
+ default: '> primary | seriesByIndex(0)'
1748
+ },
1749
+ labelField: {
1750
+ default: '> label | getField()',
1751
+ description: 'Specify the field that corresponds to the labels.',
1752
+ type: 'string'
1753
+ },
1754
+ labelDisplay: {
1755
+ description: 'Specify whether to display the labels and/or slice percentages.',
1756
+ type: 'string',
1757
+ pattern: schemaUtils_1.getPattern(['values', 'valuesAndPercentage', 'off']),
1758
+ default: 'values'
1759
+ },
1760
+ resultLimit: {
1761
+ default: 50000,
1762
+ description: 'Specify the number of data points rendered in a chart.',
1763
+ type: 'number'
1764
+ },
1765
+ seriesColors: {
1766
+ default: visualization_color_palettes_1.VIZ_CATEGORICAL,
1767
+ description: 'Specify the colors used for a series. For example, ["#FF0000", "#0000FF", "#008000"].',
1768
+ type: 'array',
1769
+ items: {
1770
+ type: 'string'
1771
+ }
1772
+ },
1773
+ seriesColorsByField: {
1774
+ description: 'Specify the colors used for specific pie slice labels. For example: {"April": "#008000", "May": "#FFA500"}.',
1775
+ type: 'object'
1776
+ },
1777
+ showDonutHole: {
1778
+ default: false,
1779
+ description: 'Specify whether the pie should be a donut.',
1780
+ type: 'boolean'
1781
+ },
1782
+ value: {
1783
+ description: 'List of numerical values to power the pie chart.',
1784
+ type: 'array',
1785
+ items: {
1786
+ type: 'number'
1787
+ },
1788
+ default: '> primary | seriesByIndex(1)'
1789
+ },
1790
+ valueField: {
1791
+ default: '> value | getField()',
1792
+ description: 'Specify the field that corresponds to the data powering values.',
1793
+ type: 'string'
1794
+ }
1795
+ };
1796
+ var themes = {
1797
+ defaultBackgroundColor: function defaultBackgroundColor(props) {
1798
+ return pick_1.default({
1799
+ enterprise: {
1800
+ dark: variables_1.default.black(props),
1801
+ light: variables_1.default.backgroundColor(props)
1802
+ },
1803
+ prisma: variables_1.default.backgroundColorSidebar(props)
1804
+ })(props);
1805
+ }
1806
+ };
1807
+ var editorConfig = [{
1808
+ label: i18n_1._('General'),
1809
+ layout: [BackgroundColor_1.default({
1810
+ themes: themes
1811
+ })]
1812
+ }, {
1813
+ label: i18n_1._('Appearance'),
1814
+ layout: [[{
1815
+ label: i18n_1._('Display type'),
1816
+ option: 'showDonutHole',
1817
+ editor: 'editor.radioBar',
1818
+ editorProps: {
1819
+ values: [{
1820
+ label: i18n_1._('Pie'),
1821
+ value: false
1822
+ }, {
1823
+ label: i18n_1._('Donut'),
1824
+ value: true
1825
+ }]
1826
+ }
1827
+ }]]
1828
+ }, {
1829
+ label: i18n_1._('Labels'),
1830
+ layout: [[{
1831
+ label: i18n_1._('Label display'),
1832
+ option: 'labelDisplay',
1833
+ editor: 'editor.radioBar',
1834
+ editorProps: {
1835
+ values: [{
1836
+ label: i18n_1._('Values'),
1837
+ value: 'values'
1838
+ }, {
1839
+ label: i18n_1._('Values & Percent'),
1840
+ value: 'valuesAndPercentage'
1841
+ }, {
1842
+ label: i18n_1._('Off'),
1843
+ value: 'off'
1844
+ }]
1845
+ }
1846
+ }]]
1847
+ }, {
1848
+ label: i18n_1._('Collapse to Summary'),
1849
+ layout: [[{
1850
+ label: i18n_1._('Collapse Threshold'),
1851
+ option: 'collapseThreshold',
1852
+ editor: 'editor.number',
1853
+ editorProps: {
1854
+ min: 0,
1855
+ max: 1,
1856
+ step: 0.01
1857
+ }
1858
+ }], [{
1859
+ label: i18n_1._('Collapsed Slice Label'),
1860
+ option: 'collapseLabel',
1861
+ editor: 'editor.text'
1862
+ }]]
1863
+ }];
1864
+ /**
1865
+ * visualization configuration
1866
+ */
1805
1867
 
1868
+ var config = {
1806
1869
  /**
1807
- * A callback to communicate computed props to a consumer
1870
+ * unique viz key
1808
1871
  */
1809
- onComputedProps: T.func,
1872
+ key: 'splunk.pie',
1810
1873
 
1811
1874
  /**
1812
- * A callback to obtain visualization api
1875
+ * viz name
1813
1876
  */
1814
- vizActionHandlerRef: T.func,
1815
- loading: T.bool,
1816
- theme: T.object,
1877
+ name: 'Pie',
1878
+ category: VizCategory_1.VizCategory.COMPARISONS,
1817
1879
 
1818
1880
  /**
1819
- * A callback to request new data with updated request params
1881
+ * viz icon
1820
1882
  */
1821
- onRequestParamsChange: T.func
1822
- };
1823
- /**
1824
- *
1825
- */
1826
-
1827
- SplunkVisualization.defaultProps = {
1828
- // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
1829
- width: '100%',
1830
- height: exports.INITIAL_HEIGHT,
1831
- dataSources: {},
1832
- onEventTrigger: function onEventTrigger() {
1833
- return {};
1834
- },
1835
- mode: 'view',
1836
- hasEventHandlers: false,
1837
- options: {},
1838
- context: {},
1839
- onOptionsChange: function onOptionsChange() {
1840
- return {};
1841
- },
1842
- vizActionHandlerRef: function vizActionHandlerRef() {
1843
- return new VizActionHandler_1.DefaultVizActionHandler();
1844
- },
1845
- onComputedProps: function onComputedProps() {
1846
- return {};
1883
+ icon: ChartPie_1.default,
1884
+ placeholderIcon: placeholders_1.Pie,
1885
+ dataContract: dataContract,
1886
+ size: size,
1887
+ defaultContext: defaultContext,
1888
+ optionsSchema: optionsSchema,
1889
+ editorConfig: editorConfig,
1890
+ events: {
1891
+ 'point.click': {
1892
+ description: 'triggered when user clicks on a point in the pie chart'
1893
+ }
1847
1894
  },
1848
- loading: false,
1849
- onRequestParamsChange: lodash_1.noop
1895
+ supports: [VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS, VizBehavior_1.VizBehavior.PLACEHOLDER, VizBehavior_1.VizBehavior.EVENTS],
1896
+ themes: themes
1850
1897
  };
1851
- exports.default = SplunkVisualization;
1898
+ exports.default = configUtils_1.enhanceConfig(config);
1852
1899
 
1853
1900
  /***/ }),
1854
1901
 
1855
- /***/ 37:
1856
- /***/ (function(module, exports, __webpack_require__) {
1857
-
1858
- "use strict";
1859
-
1860
-
1861
- var _classCallCheck = __webpack_require__(10);
1862
-
1863
- var _createClass = __webpack_require__(18);
1864
-
1865
- Object.defineProperty(exports, "__esModule", {
1866
- value: true
1867
- });
1868
- exports.DefaultVizActionHandler = void 0;
1869
-
1870
- var DefaultVizActionHandler = /*#__PURE__*/function () {
1871
- function DefaultVizActionHandler() {
1872
- _classCallCheck(this, DefaultVizActionHandler);
1873
- }
1874
-
1875
- _createClass(DefaultVizActionHandler, [{
1876
- key: "focus",
1877
- value: function focus() {// noop
1878
- }
1879
- }, {
1880
- key: "snapshot",
1881
- value: function snapshot() {
1882
- return null; // noop
1883
- }
1884
- }]);
1885
-
1886
- return DefaultVizActionHandler;
1887
- }();
1902
+ /***/ 421:
1903
+ /***/ (function(module, exports) {
1888
1904
 
1889
- exports.DefaultVizActionHandler = DefaultVizActionHandler;
1905
+ module.exports = require("@splunk/react-icons/ChartPie");
1890
1906
 
1891
1907
  /***/ }),
1892
1908
 
1893
- /***/ 38:
1909
+ /***/ 422:
1894
1910
  /***/ (function(module, exports, __webpack_require__) {
1895
1911
 
1896
1912
  "use strict";
1897
1913
 
1898
1914
 
1899
- Object.defineProperty(exports, "__esModule", {
1900
- value: true
1901
- });
1902
- exports.validSortDirs = void 0;
1903
- exports.validSortDirs = ['asc', 'desc', 'none'];
1904
-
1905
- /***/ }),
1906
-
1907
- /***/ 39:
1908
- /***/ (function(module, exports, __webpack_require__) {
1915
+ var __rest = this && this.__rest || function (s, e) {
1916
+ var t = {};
1909
1917
 
1910
- "use strict";
1918
+ for (var p in s) {
1919
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1920
+ }
1911
1921
 
1922
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1923
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1924
+ }
1925
+ return t;
1926
+ };
1912
1927
 
1913
1928
  Object.defineProperty(exports, "__esModule", {
1914
1929
  value: true
1915
1930
  });
1916
- exports.useDeepMemo = void 0;
1917
-
1918
- var react_1 = __webpack_require__(1);
1931
+ exports.allInvalidDataValues = exports.invalidOptionField = exports.getPieOptionFieldIndex = exports.getPieMergedOptions = exports.convertToPieSCProperties = exports.mapToOldKey = exports.mapLabelDisplay = exports.convertToStringValues = void 0;
1919
1932
 
1920
1933
  var lodash_1 = __webpack_require__(3);
1921
- /**
1922
- * This hook evaluates and stores the result of a passed function and only
1923
- * re-evaluates the function when passed dependencies change.
1924
- *
1925
- * It is different from the internal React useMemo in the following aspects:
1926
- * - it only stores the last evaluated result
1927
- * - it uses a deep equality check to determine if dependencies have changed
1928
- *
1929
- * Inspired by apollo-client's useDeepMemo
1930
- *
1931
- * @param fn the function to be executed and
1932
- * @param dependencies an array of dependencies
1933
- */
1934
-
1935
-
1936
- var useDeepMemo = function useDeepMemo(fn, dependencies) {
1937
- var ref = react_1.useRef();
1938
-
1939
- if (!ref.current || !lodash_1.isEqual(dependencies, ref.current.dependencies)) {
1940
- ref.current = {
1941
- dependencies: dependencies,
1942
- value: fn()
1943
- };
1944
- }
1945
-
1946
- return ref.current.value;
1947
- };
1948
-
1949
- exports.useDeepMemo = useDeepMemo;
1950
-
1951
- /***/ }),
1952
-
1953
- /***/ 4:
1954
- /***/ (function(module, exports) {
1955
1934
 
1956
- module.exports = require("styled-components");
1957
-
1958
- /***/ }),
1959
-
1960
- /***/ 40:
1961
- /***/ (function(module, exports, __webpack_require__) {
1962
-
1963
- "use strict";
1935
+ var propUtils_1 = __webpack_require__(24);
1964
1936
 
1937
+ var dsl_1 = __webpack_require__(93);
1965
1938
 
1966
- Object.defineProperty(exports, "__esModule", {
1967
- value: true
1968
- });
1969
- exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
1939
+ var hocUtils_1 = __webpack_require__(25);
1970
1940
 
1971
- var React = __webpack_require__(1);
1941
+ var JSONSchemaUtils_1 = __webpack_require__(26); // CONVERT THIS TO PIE THEN ADD TO Pie.TSX
1942
+ // map for key names which are either new or not present in SimpleXML options mapping
1972
1943
 
1973
- var T = __webpack_require__(0);
1974
1944
 
1975
- var i18n_1 = __webpack_require__(2);
1945
+ var pieOptionsSCMapping = {
1946
+ resultLimit: 'resultTruncationLimit',
1947
+ seriesColorsByField: 'fieldColors',
1948
+ collapseThreshold: 'chart.sliceCollapsingThreshold',
1949
+ collapseLabel: 'chart.sliceCollapsingLabel'
1950
+ };
1951
+ /**
1952
+ * Helper method to convert option which contains object literal values (e.g. arrays, objects)
1953
+ * to strings as SC can only accept their stringified equivalents
1954
+ * @method convertToStringValues
1955
+ * @param {Object} options
1956
+ * @returns {Object}
1957
+ */
1976
1958
 
1977
- var Message_1 = __webpack_require__(9);
1959
+ var convertToStringValues = function convertToStringValues(options) {
1960
+ var updatedOptions = propUtils_1.convertPropsToString({
1961
+ vizProps: options,
1962
+ propNames: ['seriesColors', 'fieldColors']
1963
+ });
1964
+ return Object.assign(Object.assign({}, options), updatedOptions);
1965
+ };
1978
1966
 
1979
- var FixedSizeContainer_1 = __webpack_require__(12);
1967
+ exports.convertToStringValues = convertToStringValues;
1980
1968
  /**
1981
- * @method isMissing
1982
- * @param {any} v
1983
- * @returns {boolean} true if the input value === null or undefined
1969
+ * Helper method to map labelDisplay options to jsCharting options
1970
+ * @method mapLabelDisplay
1971
+ * @param {Object} options
1972
+ * @returns {Object}
1984
1973
  */
1985
1974
 
1975
+ var mapLabelDisplay = function mapLabelDisplay(_a) {
1976
+ var labelDisplay = _a.labelDisplay,
1977
+ options = __rest(_a, ["labelDisplay"]);
1978
+
1979
+ var convertedOptions = Object.assign(Object.assign({}, options), {
1980
+ // default for labelDisplay option is 'values'
1981
+ 'chart.showLabels': true,
1982
+ 'chart.showPercent': false
1983
+ });
1984
+
1985
+ if (labelDisplay === 'valuesAndPercentage') {
1986
+ convertedOptions['chart.showPercent'] = true;
1987
+ } else if (labelDisplay === 'off') {
1988
+ convertedOptions['chart.showLabels'] = false;
1989
+ }
1986
1990
 
1987
- var isMissing = function isMissing(v) {
1988
- return v === null || v === undefined;
1991
+ return convertedOptions;
1989
1992
  };
1990
1993
 
1991
- exports.isMissing = isMissing;
1994
+ exports.mapLabelDisplay = mapLabelDisplay;
1992
1995
  /**
1993
- * @method misskingKeys
1994
- * @param {string[]} keys
1995
- * @param {object} target
1996
- * @returns {string[]} the keys of missing required props
1996
+ * Helper method to update the option names which can be mapped to SimpleXML options or
1997
+ * can be used directly with SC if don't have a 1-1 mapping in SimpleXML
1998
+ * @method mapToOldKey
1999
+ * @param {Object} options
2000
+ * @returns {Object}
1997
2001
  */
1998
2002
 
1999
- var missingKeys = function missingKeys(keys, target) {
2000
- return keys.filter(function (k) {
2001
- return exports.isMissing(target[k]);
2003
+ var mapToOldKey = function mapToOldKey(options) {
2004
+ return lodash_1.mapKeys(options, function (val, key) {
2005
+ return pieOptionsSCMapping[key] ? pieOptionsSCMapping[key] : key;
2002
2006
  });
2003
2007
  };
2004
2008
 
2005
- exports.missingKeys = missingKeys;
2006
- var propTypes = {
2007
- width: T.oneOfType([T.string, T.number]),
2008
- height: T.oneOfType([T.string, T.number]),
2009
- // eslint-disable-next-line react/no-unused-prop-types
2010
- backgroundColor: T.string,
2011
- missingProps: T.arrayOf(T.string)
2012
- };
2009
+ exports.mapToOldKey = mapToOldKey;
2013
2010
  /**
2014
- * @method MissingPropsMessage
2015
- * @param {MissingPropsProps} props
2016
- * @returns {React.ReactElement}
2011
+ * Chained helper for mapping the option properties (and values) we expose in config.ts into property values that splunk-charting accepts
2012
+ * This is for options that has new key name and can not directly be mapped with SimpleXML or
2013
+ * don't have a 1-1 mapping in SimpleXML (i.e. a straightforward name mapping where values are preserved)
2014
+ * @method convertToPieSCProperties
2015
+ * @param {Object} originalOptions
2016
+ * @returns {Object}
2017
2017
  */
2018
2018
 
2019
- var MissingPropsMessage = function MissingPropsMessage(props) {
2020
- var width = props.width,
2021
- height = props.height,
2022
- missingProps = props.missingProps;
2023
- return React.createElement(Message_1.default, {
2024
- "data-test": "message",
2025
- width: width,
2026
- height: height,
2027
- message: i18n_1._("Missing property: ".concat(missingProps.join(', ')))
2028
- });
2019
+ var convertToPieSCProperties = function convertToPieSCProperties(originalOptions) {
2020
+ return lodash_1.chain(exports.mapToOldKey(originalOptions)).thru(exports.convertToStringValues).thru(exports.mapLabelDisplay).value();
2029
2021
  };
2030
2022
 
2031
- exports.MissingPropsMessage = MissingPropsMessage;
2032
- exports.MissingPropsMessage.propTypes = propTypes;
2033
- exports.MissingPropsMessage.defaultProps = {
2034
- width: '100%',
2035
- height: 250
2023
+ exports.convertToPieSCProperties = convertToPieSCProperties;
2024
+ /**
2025
+ * Return all merged options (default + config) using vizConfig and options
2026
+ * @param options
2027
+ * @param vizConfig
2028
+ * @returns
2029
+ */
2030
+
2031
+ var getPieMergedOptions = function getPieMergedOptions(options, vizConfig) {
2032
+ return hocUtils_1.deepMergeWithArrayPrimitiveOverrides({}, options, JSONSchemaUtils_1.pickFieldFromJSONSchema(vizConfig.optionsSchema, 'default'));
2036
2033
  };
2037
- exports.default = FixedSizeContainer_1.default(exports.MissingPropsMessage);
2038
2034
 
2039
- /***/ }),
2035
+ exports.getPieMergedOptions = getPieMergedOptions;
2036
+ /**
2037
+ * Returns option's field index. If not found returns -1
2038
+ * @param optionName
2039
+ * @param dataSources
2040
+ * @param options
2041
+ * @param vizConfig
2042
+ * @returns
2043
+ */
2040
2044
 
2041
- /***/ 41:
2042
- /***/ (function(module, exports, __webpack_require__) {
2045
+ var getPieOptionFieldIndex = function getPieOptionFieldIndex(optionName, dataSources, options, vizConfig) {
2046
+ var mergedOptions = exports.getPieMergedOptions(options, vizConfig); // find the field name configured for pie "value"
2043
2047
 
2044
- "use strict";
2048
+ var fieldName = dsl_1.getFieldsFromDSL(mergedOptions[optionName], dataSources)[0];
2049
+ var fields = dataSources.primary.data.fields; // find the field index configured for pie "value"
2045
2050
 
2051
+ var fieldIndex = fields.findIndex(function (field) {
2052
+ return (typeof field === 'string' ? field : field.name.toString()) === fieldName;
2053
+ });
2054
+ return fieldIndex;
2055
+ };
2046
2056
 
2047
- Object.defineProperty(exports, "__esModule", {
2048
- value: true
2049
- });
2057
+ exports.getPieOptionFieldIndex = getPieOptionFieldIndex;
2058
+ /**
2059
+ * Returns true if columns data has invalid data format for specified option (label or value)
2060
+ * @param optionName
2061
+ * @param dataSources
2062
+ * @param options
2063
+ * @param vizConfig
2064
+ * @returns
2065
+ */
2050
2066
 
2051
- var React = __webpack_require__(1);
2067
+ var invalidOptionField = function invalidOptionField(optionName, dataSources, options, vizConfig) {
2068
+ var columns = dataSources.primary.data.columns;
2069
+ var fieldIndex = exports.getPieOptionFieldIndex(optionName, dataSources, options, vizConfig);
2052
2070
 
2053
- var styled_components_1 = __webpack_require__(4);
2071
+ if (fieldIndex === -1 || !columns[fieldIndex] || !Array.isArray(columns[fieldIndex]) || Array.isArray(columns[fieldIndex]) && !columns[fieldIndex].length) {
2072
+ return true;
2073
+ }
2054
2074
 
2055
- var hocUtils_1 = __webpack_require__(13);
2075
+ return false;
2076
+ };
2056
2077
 
2057
- var Cover = styled_components_1.default.div.withConfig({
2058
- displayName: "withEditModeCover__Cover",
2059
- componentId: "sc-1gsbnxb-0"
2060
- })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
2061
- var Blocker = styled_components_1.default.div.attrs({
2062
- 'data-splunk-visualization-version': "25.1.0 - 812a9a4d8"
2063
- }).withConfig({
2064
- displayName: "withEditModeCover__Blocker",
2065
- componentId: "sc-1gsbnxb-1"
2066
- })(["position:relative;width:100%;height:100%;"]);
2078
+ exports.invalidOptionField = invalidOptionField;
2067
2079
  /**
2068
- * HOC that renders a cover layer in edit mode
2069
- * @method withEditModeCover
2070
- * @param {ExtendedDashViz} Visualization
2071
- * @returns {ExtendedDashViz} Wrapper
2080
+ * Helper function to evaluate if all data values are invalid (zero or negative)
2072
2081
  */
2073
2082
 
2074
- var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
2075
- var Wrapper = function Wrapper(props) {
2076
- var mode = props.mode;
2077
- var showEditCover = mode === 'edit' && !disableEditModeCover;
2078
- return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
2079
- "data-test": "edit-mode-cover"
2080
- }));
2081
- };
2083
+ var allInvalidDataValues = function allInvalidDataValues(dataSources, options, vizConfig) {
2084
+ var columns = dataSources.primary.data.columns; // find the field index configured for pie "value"
2082
2085
 
2083
- hocUtils_1.extendStaticWrapperProps({
2084
- Wrapper: Wrapper,
2085
- Visualization: Visualization
2086
- });
2087
- return Wrapper;
2086
+ var valueFieldIndex = exports.getPieOptionFieldIndex('value', dataSources, options, vizConfig); // check if all values are invalid
2087
+
2088
+ if (Array.isArray(columns) && columns[valueFieldIndex] && Array.isArray(columns[valueFieldIndex])) {
2089
+ return !columns[valueFieldIndex].some(function (value) {
2090
+ return +value > 0;
2091
+ });
2092
+ }
2093
+
2094
+ return false;
2088
2095
  };
2089
2096
 
2090
- exports.default = withEditModeCover;
2097
+ exports.allInvalidDataValues = allInvalidDataValues;
2091
2098
 
2092
2099
  /***/ }),
2093
2100
 
2094
- /***/ 42:
2101
+ /***/ 43:
2095
2102
  /***/ (function(module, exports, __webpack_require__) {
2096
2103
 
2097
2104
  "use strict";
@@ -2101,17 +2108,17 @@ Object.defineProperty(exports, "__esModule", {
2101
2108
  value: true
2102
2109
  });
2103
2110
 
2104
- var React = __webpack_require__(1);
2111
+ var React = __webpack_require__(0);
2105
2112
 
2106
- var colorUtils_1 = __webpack_require__(11);
2113
+ var colorUtils_1 = __webpack_require__(12);
2107
2114
 
2108
- var variables_1 = __webpack_require__(8);
2115
+ var variables_1 = __webpack_require__(9);
2109
2116
 
2110
2117
  var IconPlaceholder_1 = __webpack_require__(27);
2111
2118
 
2112
- var VizBehavior_1 = __webpack_require__(5);
2119
+ var VizBehavior_1 = __webpack_require__(6);
2113
2120
 
2114
- var hocUtils_1 = __webpack_require__(13);
2121
+ var hocUtils_1 = __webpack_require__(14);
2115
2122
 
2116
2123
  var withPlaceholder = function withPlaceholder(Visualization) {
2117
2124
  var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
@@ -2159,18 +2166,18 @@ exports.default = withPlaceholder;
2159
2166
  /***/ 44:
2160
2167
  /***/ (function(module, exports) {
2161
2168
 
2162
- module.exports = require("@splunk/visualization-color-palettes");
2169
+ module.exports = require("@splunk/visualization-icons/placeholders");
2163
2170
 
2164
2171
  /***/ }),
2165
2172
 
2166
- /***/ 45:
2173
+ /***/ 46:
2167
2174
  /***/ (function(module, exports) {
2168
2175
 
2169
- module.exports = require("@splunk/visualization-icons/placeholders");
2176
+ module.exports = require("@splunk/visualization-color-palettes");
2170
2177
 
2171
2178
  /***/ }),
2172
2179
 
2173
- /***/ 49:
2180
+ /***/ 50:
2174
2181
  /***/ (function(module, exports, __webpack_require__) {
2175
2182
 
2176
2183
  "use strict";
@@ -2201,51 +2208,13 @@ exports.default = background;
2201
2208
 
2202
2209
  /***/ }),
2203
2210
 
2204
- /***/ 5:
2205
- /***/ (function(module, exports, __webpack_require__) {
2206
-
2207
- "use strict";
2208
-
2209
-
2210
- Object.defineProperty(exports, "__esModule", {
2211
- value: true
2212
- });
2213
- exports.VizBehavior = void 0;
2214
- var VizBehavior;
2215
-
2216
- (function (VizBehavior) {
2217
- /**
2218
- * Dynamic Options Behavior.
2219
- * This allows visualization options to be powered by data
2220
- *
2221
- * **Example**
2222
- *
2223
- * sparklineValues: ">primary|seriesByIndex(0)"
2224
- * would configure sparklineValues with an array of data points
2225
- * coming from the first series in the primary datasource
2226
- *
2227
- */
2228
- VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
2229
- VizBehavior["EVENTS"] = "events";
2230
- /**
2231
- * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
2232
- * missing.
2233
- * @type {string}
2234
- */
2235
-
2236
- VizBehavior["PLACEHOLDER"] = "placeholder";
2237
- VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
2238
- })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
2239
-
2240
- /***/ }),
2241
-
2242
- /***/ 50:
2211
+ /***/ 52:
2243
2212
  /***/ (function(module, exports, __webpack_require__) {
2244
2213
 
2245
2214
  "use strict";
2246
2215
 
2247
2216
 
2248
- var _toConsumableArray = __webpack_require__(7);
2217
+ var _toConsumableArray = __webpack_require__(8);
2249
2218
 
2250
2219
  var __rest = this && this.__rest || function (s, e) {
2251
2220
  var t = {};
@@ -2461,14 +2430,14 @@ exports.constructFieldsAndColumns = constructFieldsAndColumns;
2461
2430
 
2462
2431
  /***/ }),
2463
2432
 
2464
- /***/ 51:
2433
+ /***/ 53:
2465
2434
  /***/ (function(module, exports) {
2466
2435
 
2467
2436
  module.exports = require("@splunk/charting-bundle");
2468
2437
 
2469
2438
  /***/ }),
2470
2439
 
2471
- /***/ 55:
2440
+ /***/ 56:
2472
2441
  /***/ (function(module, exports, __webpack_require__) {
2473
2442
 
2474
2443
  "use strict";
@@ -2484,34 +2453,34 @@ var lodash_1 = __webpack_require__(3);
2484
2453
 
2485
2454
  var i18n_1 = __webpack_require__(2);
2486
2455
 
2487
- var visualization_color_palettes_1 = __webpack_require__(44);
2456
+ var visualization_color_palettes_1 = __webpack_require__(46);
2488
2457
 
2489
- var react_1 = __webpack_require__(1);
2458
+ var react_1 = __webpack_require__(0);
2490
2459
 
2491
- var React = __webpack_require__(1);
2460
+ var React = __webpack_require__(0);
2492
2461
 
2493
- var T = __webpack_require__(0);
2462
+ var T = __webpack_require__(1);
2494
2463
 
2495
- var react_event_listener_1 = __webpack_require__(56);
2464
+ var react_event_listener_1 = __webpack_require__(57);
2496
2465
 
2497
- __webpack_require__(57); // fixme, @splunk/charting should be refactor to use locale & timezone instead of i18n functions
2466
+ __webpack_require__(58); // fixme, @splunk/charting should be refactor to use locale & timezone instead of i18n functions
2498
2467
 
2499
2468
 
2500
- var charting_bundle_1 = __webpack_require__(51);
2469
+ var charting_bundle_1 = __webpack_require__(53);
2501
2470
 
2502
- var TimezoneContext_1 = __webpack_require__(22);
2471
+ var TimezoneContext_1 = __webpack_require__(23);
2503
2472
 
2504
- var style_1 = __webpack_require__(14);
2473
+ var style_1 = __webpack_require__(15);
2505
2474
 
2506
2475
  var styled_components_1 = __webpack_require__(4);
2507
2476
 
2508
- var Message_1 = __webpack_require__(9);
2477
+ var Message_1 = __webpack_require__(10);
2509
2478
 
2510
- var useSplunkTheme_1 = __webpack_require__(58);
2479
+ var useSplunkTheme_1 = __webpack_require__(59);
2511
2480
 
2512
- var themeUtils_1 = __webpack_require__(59);
2481
+ var themeUtils_1 = __webpack_require__(60);
2513
2482
 
2514
- var ChartingApi_1 = __webpack_require__(60);
2483
+ var ChartingApi_1 = __webpack_require__(61);
2515
2484
 
2516
2485
  exports.NO_INPLACE_PROPS = ['chart', 'chart.orientation', 'layout.splitSeries', 'chart.style', 'legend.placement'];
2517
2486
 
@@ -2891,50 +2860,81 @@ exports.default = withEmptyChartMessage(Charting);
2891
2860
 
2892
2861
  /***/ }),
2893
2862
 
2894
- /***/ 56:
2863
+ /***/ 57:
2895
2864
  /***/ (function(module, exports) {
2896
2865
 
2897
2866
  module.exports = require("react-event-listener");
2898
2867
 
2899
2868
  /***/ }),
2900
2869
 
2901
- /***/ 57:
2870
+ /***/ 58:
2902
2871
  /***/ (function(module, exports) {
2903
2872
 
2904
2873
  module.exports = require("@splunk/visualizations-shared/i18n");
2905
2874
 
2906
2875
  /***/ }),
2907
2876
 
2908
- /***/ 58:
2877
+ /***/ 59:
2909
2878
  /***/ (function(module, exports) {
2910
2879
 
2911
2880
  module.exports = require("@splunk/themes/useSplunkTheme");
2912
2881
 
2913
2882
  /***/ }),
2914
2883
 
2915
- /***/ 59:
2916
- /***/ (function(module, exports) {
2884
+ /***/ 6:
2885
+ /***/ (function(module, exports, __webpack_require__) {
2917
2886
 
2918
- module.exports = require("@splunk/visualizations-shared/themeUtils");
2887
+ "use strict";
2888
+
2889
+
2890
+ Object.defineProperty(exports, "__esModule", {
2891
+ value: true
2892
+ });
2893
+ exports.VizBehavior = void 0;
2894
+ var VizBehavior;
2895
+
2896
+ (function (VizBehavior) {
2897
+ /**
2898
+ * Dynamic Options Behavior.
2899
+ * This allows visualization options to be powered by data
2900
+ *
2901
+ * **Example**
2902
+ *
2903
+ * sparklineValues: ">primary|seriesByIndex(0)"
2904
+ * would configure sparklineValues with an array of data points
2905
+ * coming from the first series in the primary datasource
2906
+ *
2907
+ */
2908
+ VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
2909
+ VizBehavior["EVENTS"] = "events";
2910
+ /**
2911
+ * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
2912
+ * missing.
2913
+ * @type {string}
2914
+ */
2915
+
2916
+ VizBehavior["PLACEHOLDER"] = "placeholder";
2917
+ VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
2918
+ })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
2919
2919
 
2920
2920
  /***/ }),
2921
2921
 
2922
- /***/ 6:
2922
+ /***/ 60:
2923
2923
  /***/ (function(module, exports) {
2924
2924
 
2925
- module.exports = require("@babel/runtime/helpers/defineProperty");
2925
+ module.exports = require("@splunk/visualizations-shared/themeUtils");
2926
2926
 
2927
2927
  /***/ }),
2928
2928
 
2929
- /***/ 60:
2929
+ /***/ 61:
2930
2930
  /***/ (function(module, exports, __webpack_require__) {
2931
2931
 
2932
2932
  "use strict";
2933
2933
 
2934
2934
 
2935
- var _classCallCheck = __webpack_require__(10);
2935
+ var _classCallCheck = __webpack_require__(11);
2936
2936
 
2937
- var _createClass = __webpack_require__(18);
2937
+ var _createClass = __webpack_require__(19);
2938
2938
 
2939
2939
  Object.defineProperty(exports, "__esModule", {
2940
2940
  value: true
@@ -2995,7 +2995,7 @@ exports.ChartingApiFunctional = ChartingApiFunctional;
2995
2995
 
2996
2996
  /***/ }),
2997
2997
 
2998
- /***/ 61:
2998
+ /***/ 62:
2999
2999
  /***/ (function(module, exports) {
3000
3000
 
3001
3001
  module.exports = require("@splunk/visualizations-shared/simpleXMLOptions");
@@ -3005,28 +3005,28 @@ module.exports = require("@splunk/visualizations-shared/simpleXMLOptions");
3005
3005
  /***/ 7:
3006
3006
  /***/ (function(module, exports) {
3007
3007
 
3008
- module.exports = require("@babel/runtime/helpers/toConsumableArray");
3008
+ module.exports = require("@babel/runtime/helpers/defineProperty");
3009
3009
 
3010
3010
  /***/ }),
3011
3011
 
3012
3012
  /***/ 8:
3013
3013
  /***/ (function(module, exports) {
3014
3014
 
3015
- module.exports = require("@splunk/themes/variables");
3015
+ module.exports = require("@babel/runtime/helpers/toConsumableArray");
3016
3016
 
3017
3017
  /***/ }),
3018
3018
 
3019
- /***/ 88:
3019
+ /***/ 9:
3020
3020
  /***/ (function(module, exports) {
3021
3021
 
3022
- module.exports = require("@splunk/visualization-encoding/utils/dsl");
3022
+ module.exports = require("@splunk/themes/variables");
3023
3023
 
3024
3024
  /***/ }),
3025
3025
 
3026
- /***/ 9:
3026
+ /***/ 93:
3027
3027
  /***/ (function(module, exports) {
3028
3028
 
3029
- module.exports = require("@splunk/visualizations-shared/Message");
3029
+ module.exports = require("@splunk/visualization-encoding/utils/dsl");
3030
3030
 
3031
3031
  /***/ })
3032
3032