@splunk/visualizations 25.0.1 → 25.1.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 (161) hide show
  1. package/.loki/reference/chrome_docker_PureVisualizations_PureMap_custom_base_layer_tile_server.png +0 -0
  2. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Area_Editor.png +0 -0
  3. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Bar_Editor.png +0 -0
  4. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Bubble_Editor.png +0 -0
  5. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_ChoroplethSvg_Editor.png +0 -0
  6. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Column_Editor.png +0 -0
  7. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Ellipse_Editor.png +0 -0
  8. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_FillerGauge_Editor.png +0 -0
  9. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Image_Editor.png +0 -0
  10. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Line_Editor.png +0 -0
  11. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_LinkGraph_Editor.png +0 -0
  12. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Map_Editor.png +0 -0
  13. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Markdown_Editor.png +0 -0
  14. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_MarkerGauge_Editor.png +0 -0
  15. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Parallel_Coordinates_Editor.png +0 -0
  16. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Pie_Editor.png +0 -0
  17. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Punchcard_Editor.png +0 -0
  18. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Rectangle_Editor.png +0 -0
  19. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Sankey_Editor.png +0 -0
  20. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Scatter_Editor.png +0 -0
  21. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Single_Value_Editor.png +0 -0
  22. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Single_Value_Icon_Editor.png +0 -0
  23. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Single_Value_Radial_Editor.png +0 -0
  24. package/.loki/reference/chrome_docker_VisualizationEditors_Editors_Table_Editor.png +0 -0
  25. package/Area.config.js +141 -152
  26. package/Area.config.js.map +1 -1
  27. package/Area.js +334 -431
  28. package/Area.js.map +1 -1
  29. package/Bar.config.js +143 -148
  30. package/Bar.config.js.map +1 -1
  31. package/Bar.js +336 -427
  32. package/Bar.js.map +1 -1
  33. package/Bubble.config.js +130 -117
  34. package/Bubble.config.js.map +1 -1
  35. package/Bubble.js +325 -398
  36. package/Bubble.js.map +1 -1
  37. package/ChoroplethSvg.config.js +86 -80
  38. package/ChoroplethSvg.config.js.map +1 -1
  39. package/ChoroplethSvg.js +305 -385
  40. package/ChoroplethSvg.js.map +1 -1
  41. package/Column.config.js +139 -146
  42. package/Column.config.js.map +1 -1
  43. package/Column.js +332 -425
  44. package/Column.js.map +1 -1
  45. package/Ellipse.config.js +86 -80
  46. package/Ellipse.config.js.map +1 -1
  47. package/Ellipse.js +288 -368
  48. package/Ellipse.js.map +1 -1
  49. package/FillerGauge.config.js +91 -85
  50. package/FillerGauge.config.js.map +1 -1
  51. package/FillerGauge.js +296 -376
  52. package/FillerGauge.js.map +1 -1
  53. package/Image.config.js +74 -74
  54. package/Image.config.js.map +1 -1
  55. package/Image.js +710 -798
  56. package/Image.js.map +1 -1
  57. package/Line.config.js +139 -137
  58. package/Line.config.js.map +1 -1
  59. package/Line.js +332 -416
  60. package/Line.js.map +1 -1
  61. package/LinkGraph.config.js +112 -112
  62. package/LinkGraph.config.js.map +1 -1
  63. package/LinkGraph.js +320 -405
  64. package/LinkGraph.js.map +1 -1
  65. package/Map.config.js +101 -95
  66. package/Map.config.js.map +1 -1
  67. package/Map.js +472 -518
  68. package/Map.js.map +1 -1
  69. package/Markdown.config.js +113 -113
  70. package/Markdown.config.js.map +1 -1
  71. package/Markdown.js +500 -574
  72. package/Markdown.js.map +1 -1
  73. package/MarkerGauge.config.js +192 -193
  74. package/MarkerGauge.config.js.map +1 -1
  75. package/MarkerGauge.js +1200 -1289
  76. package/MarkerGauge.js.map +1 -1
  77. package/ParallelCoordinates.config.js +138 -138
  78. package/ParallelCoordinates.config.js.map +1 -1
  79. package/ParallelCoordinates.js +292 -376
  80. package/ParallelCoordinates.js.map +1 -1
  81. package/Pie.config.js +133 -133
  82. package/Pie.config.js.map +1 -1
  83. package/Pie.js +496 -584
  84. package/Pie.js.map +1 -1
  85. package/Punchcard.config.js +139 -139
  86. package/Punchcard.config.js.map +1 -1
  87. package/Punchcard.js +315 -399
  88. package/Punchcard.js.map +1 -1
  89. package/Rectangle.config.js +267 -260
  90. package/Rectangle.config.js.map +1 -1
  91. package/Rectangle.js +499 -580
  92. package/Rectangle.js.map +1 -1
  93. package/Sankey.config.js +150 -143
  94. package/Sankey.config.js.map +1 -1
  95. package/Sankey.js +316 -390
  96. package/Sankey.js.map +1 -1
  97. package/Scatter.config.js +130 -117
  98. package/Scatter.config.js.map +1 -1
  99. package/Scatter.js +547 -623
  100. package/Scatter.js.map +1 -1
  101. package/SingleValue.config.js +119 -113
  102. package/SingleValue.config.js.map +1 -1
  103. package/SingleValue.js +523 -604
  104. package/SingleValue.js.map +1 -1
  105. package/SingleValueBasic.js +19 -19
  106. package/SingleValueBasic.js.map +1 -1
  107. package/SingleValueIcon.config.js +128 -120
  108. package/SingleValueIcon.config.js.map +1 -1
  109. package/SingleValueIcon.js +343 -420
  110. package/SingleValueIcon.js.map +1 -1
  111. package/SingleValueRadial.config.js +215 -178
  112. package/SingleValueRadial.config.js.map +1 -1
  113. package/SingleValueRadial.js +668 -749
  114. package/SingleValueRadial.js.map +1 -1
  115. package/Table.config.js +150 -151
  116. package/Table.config.js.map +1 -1
  117. package/Table.js +772 -854
  118. package/Table.js.map +1 -1
  119. package/common/Charting.js +11 -11
  120. package/common/Charting.js.map +1 -1
  121. package/common/ChartingApi.js +2 -2
  122. package/common/ChartingApi.js.map +1 -1
  123. package/common/EventsDoc.js +12 -12
  124. package/common/EventsDoc.js.map +1 -1
  125. package/common/GaugeMajorTicks.js +8 -8
  126. package/common/GaugeMajorTicks.js.map +1 -1
  127. package/common/GaugeValueMarker.js +8 -8
  128. package/common/GaugeValueMarker.js.map +1 -1
  129. package/common/OptionsDoc.js +51 -352
  130. package/common/OptionsDoc.js.map +1 -1
  131. package/common/OverviewDoc.js +22 -22
  132. package/common/OverviewDoc.js.map +1 -1
  133. package/common/SplunkVisualization.js +4 -4
  134. package/common/SplunkVisualization.js.map +1 -1
  135. package/common/SplunkVisualizationApi.js +2 -2
  136. package/common/SplunkVisualizationApi.js.map +1 -1
  137. package/common/ThemesDoc.js +19 -19
  138. package/common/ThemesDoc.js.map +1 -1
  139. package/common/chartingUtils.js +4 -4
  140. package/common/chartingUtils.js.map +1 -1
  141. package/common/docUtils.js +4 -4
  142. package/common/docUtils.js.map +1 -1
  143. package/common/gaugeUtils.js +13 -13
  144. package/common/gaugeUtils.js.map +1 -1
  145. package/common/shapeUtils.js +8 -8
  146. package/common/shapeUtils.js.map +1 -1
  147. package/common/utils/configUtils.js +17 -18
  148. package/common/utils/configUtils.js.map +1 -1
  149. package/common/utils/hocUtils.js +6 -86
  150. package/common/utils/hocUtils.js.map +1 -1
  151. package/common/utils/{JSONSchemaUtils.js → mapUtils.js} +89 -29
  152. package/common/utils/mapUtils.js.map +1 -0
  153. package/common/utils/singleValueUtils.js +14 -12
  154. package/common/utils/singleValueUtils.js.map +1 -1
  155. package/common/utils/testHelper.js +8 -8
  156. package/common/utils/testHelper.js.map +1 -1
  157. package/common/withDashboardViz.js +120 -207
  158. package/common/withDashboardViz.js.map +1 -1
  159. package/package.json +12 -12
  160. package/.loki/reference/chrome_docker_PureVisualizations_SvgChoroplethDynamic_SVG_Of_Size_Greater_Than_2_MB_Render.png +0 -0
  161. package/common/utils/JSONSchemaUtils.js.map +0 -1
package/MarkerGauge.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 = 214);
90
+ /******/ return __webpack_require__(__webpack_require__.s = 216);
91
91
  /******/ })
92
92
  /************************************************************************/
93
93
  /******/ ({
@@ -109,11 +109,11 @@ module.exports = require("react");
109
109
  /***/ 10:
110
110
  /***/ (function(module, exports) {
111
111
 
112
- module.exports = require("@splunk/themes/variables");
112
+ module.exports = require("@babel/runtime/helpers/classCallCheck");
113
113
 
114
114
  /***/ }),
115
115
 
116
- /***/ 101:
116
+ /***/ 102:
117
117
  /***/ (function(module, exports, __webpack_require__) {
118
118
 
119
119
  "use strict";
@@ -123,7 +123,7 @@ Object.defineProperty(exports, "__esModule", {
123
123
  value: true
124
124
  });
125
125
 
126
- var i18n_1 = __webpack_require__(3);
126
+ var i18n_1 = __webpack_require__(2);
127
127
 
128
128
  var gauge = {
129
129
  label: i18n_1._('Gauge Settings'),
@@ -178,7 +178,7 @@ exports.default = gauge;
178
178
 
179
179
  /***/ }),
180
180
 
181
- /***/ 102:
181
+ /***/ 103:
182
182
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
183
183
 
184
184
  "use strict";
@@ -193,7 +193,7 @@ __webpack_require__.r(__webpack_exports__);
193
193
  /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
194
194
  /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
195
195
  /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_3__);
196
- /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23);
196
+ /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(26);
197
197
  /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__);
198
198
 
199
199
 
@@ -433,7 +433,7 @@ MajorTicks.defaultProps = {
433
433
 
434
434
  /***/ }),
435
435
 
436
- /***/ 103:
436
+ /***/ 104:
437
437
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
438
438
 
439
439
  "use strict";
@@ -448,7 +448,7 @@ __webpack_require__.r(__webpack_exports__);
448
448
  /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
449
449
  /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
450
450
  /* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(styled_components__WEBPACK_IMPORTED_MODULE_3__);
451
- /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23);
451
+ /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(26);
452
452
  /* harmony import */ var _splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_splunk_visualizations_shared_numberUtils__WEBPACK_IMPORTED_MODULE_4__);
453
453
 
454
454
 
@@ -638,88 +638,11 @@ ValueMarker.defaultProps = {
638
638
  /***/ 11:
639
639
  /***/ (function(module, exports) {
640
640
 
641
- module.exports = require("@splunk/visualizations-shared/Message");
642
-
643
- /***/ }),
644
-
645
- /***/ 12:
646
- /***/ (function(module, exports) {
647
-
648
- module.exports = require("@babel/runtime/helpers/classCallCheck");
649
-
650
- /***/ }),
651
-
652
- /***/ 13:
653
- /***/ (function(module, exports) {
654
-
655
641
  module.exports = require("@splunk/visualizations-shared/colorUtils");
656
642
 
657
643
  /***/ }),
658
644
 
659
- /***/ 133:
660
- /***/ (function(module, exports, __webpack_require__) {
661
-
662
- "use strict";
663
-
664
-
665
- var __rest = this && this.__rest || function (s, e) {
666
- var t = {};
667
-
668
- for (var p in s) {
669
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
670
- }
671
-
672
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
673
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
674
- }
675
- return t;
676
- };
677
-
678
- Object.defineProperty(exports, "__esModule", {
679
- value: true
680
- });
681
- exports.config = exports.computeVizProps = exports.PureMarkerGauge = void 0;
682
-
683
- var lodash_1 = __webpack_require__(2);
684
-
685
- var MarkerGauge_1 = __webpack_require__(215);
686
-
687
- var config_1 = __webpack_require__(217);
688
-
689
- exports.config = config_1.default;
690
-
691
- var withDashboardViz_1 = __webpack_require__(30);
692
-
693
- var gaugeUtils_1 = __webpack_require__(80);
694
-
695
- exports.PureMarkerGauge = MarkerGauge_1.default;
696
- var validOptions = Object.keys(config_1.default.optionsSchema);
697
-
698
- var computeVizProps = function computeVizProps(_a) {
699
- var props = __rest(_a, []);
700
-
701
- var options = lodash_1.chain(props).pick(validOptions).thru(gaugeUtils_1.convertToGaugeProperties).value();
702
- var defaultColors = {
703
- fillColor: config_1.default.themes.defaultFillColor(props),
704
- majorTickFillColor: config_1.default.themes.majorTickFillColor(props),
705
- majorTickStrokeColor: config_1.default.themes.majorTickStrokeColor(props),
706
- valueMarkerFillColor: config_1.default.themes.valueMarkerFillColor(props),
707
- valueMarkerLabelFillColor: config_1.default.themes.valueMarkerLabelFillColor(props)
708
- };
709
- return Object.assign(Object.assign({}, options), defaultColors);
710
- };
711
-
712
- exports.computeVizProps = computeVizProps;
713
- var viz = withDashboardViz_1.default({
714
- ReactViz: MarkerGauge_1.default,
715
- computeVizProps: exports.computeVizProps,
716
- vizConfig: config_1.default
717
- });
718
- exports.default = viz;
719
-
720
- /***/ }),
721
-
722
- /***/ 14:
645
+ /***/ 12:
723
646
  /***/ (function(module, exports, __webpack_require__) {
724
647
 
725
648
  "use strict";
@@ -733,11 +656,11 @@ var React = __webpack_require__(1);
733
656
 
734
657
  var styled_components_1 = __webpack_require__(4);
735
658
 
736
- var SizeAwareWrapper_1 = __webpack_require__(18);
659
+ var SizeAwareWrapper_1 = __webpack_require__(19);
737
660
 
738
- var style_1 = __webpack_require__(15);
661
+ var style_1 = __webpack_require__(14);
739
662
 
740
- var colorUtils_1 = __webpack_require__(13);
663
+ var colorUtils_1 = __webpack_require__(11);
741
664
 
742
665
  var Item = styled_components_1.default.div.attrs(function (_ref) {
743
666
  var width = _ref.width;
@@ -794,7 +717,7 @@ var withFixedSizeContainer = function withFixedSizeContainer(Viz) {
794
717
 
795
718
  return React.createElement(FixSizeItem, {
796
719
  "data-test": "fix-size-item",
797
- "data-splunk-visualization-version": "25.0.1 - de10ad954",
720
+ "data-splunk-visualization-version": "25.1.0 - 812a9a4d8",
798
721
  width: width,
799
722
  height: height,
800
723
  backgroundColor: backgroundColor
@@ -816,104 +739,126 @@ exports.default = withFixedSizeContainer;
816
739
 
817
740
  /***/ }),
818
741
 
819
- /***/ 15:
820
- /***/ (function(module, exports) {
821
-
822
- module.exports = require("@splunk/visualizations-shared/style");
823
-
824
- /***/ }),
742
+ /***/ 13:
743
+ /***/ (function(module, exports, __webpack_require__) {
825
744
 
826
- /***/ 16:
827
- /***/ (function(module, exports) {
745
+ "use strict";
828
746
 
829
- module.exports = require("@splunk/visualizations-shared/schemaUtils");
830
747
 
831
- /***/ }),
748
+ Object.defineProperty(exports, "__esModule", {
749
+ value: true
750
+ });
751
+ exports.extendStaticWrapperProps = void 0;
752
+ /**
753
+ * @method extendStaticWrapperProps
754
+ * @param {Object} props
755
+ * @param {DashboardVizType} props.Wrapper
756
+ * @param {DashboardVizType} props.Visualization
757
+ */
832
758
 
833
- /***/ 17:
834
- /***/ (function(module, exports) {
759
+ var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
760
+ var Wrapper = _ref.Wrapper,
761
+ Visualization = _ref.Visualization;
762
+ var extendProperties = ['propTypes', 'defaultProps', 'config'];
763
+ extendProperties.forEach(function (prop) {
764
+ if (Visualization[prop]) {
765
+ // eslint-disable-next-line no-param-reassign
766
+ Wrapper[prop] = Visualization[prop];
767
+ }
768
+ });
769
+ };
835
770
 
836
- module.exports = require("@babel/runtime/helpers/createClass");
771
+ exports.extendStaticWrapperProps = extendStaticWrapperProps;
837
772
 
838
773
  /***/ }),
839
774
 
840
- /***/ 18:
841
- /***/ (function(module, exports) {
842
-
843
- module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
775
+ /***/ 134:
776
+ /***/ (function(module, exports, __webpack_require__) {
844
777
 
845
- /***/ }),
778
+ "use strict";
846
779
 
847
- /***/ 2:
848
- /***/ (function(module, exports) {
849
780
 
850
- module.exports = require("lodash");
781
+ var __rest = this && this.__rest || function (s, e) {
782
+ var t = {};
851
783
 
852
- /***/ }),
784
+ for (var p in s) {
785
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
786
+ }
853
787
 
854
- /***/ 20:
855
- /***/ (function(module, exports) {
788
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
789
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
790
+ }
791
+ return t;
792
+ };
856
793
 
857
- module.exports = require("@splunk/themes/pick");
794
+ Object.defineProperty(exports, "__esModule", {
795
+ value: true
796
+ });
797
+ exports.config = exports.computeVizProps = exports.PureMarkerGauge = void 0;
858
798
 
859
- /***/ }),
799
+ var lodash_1 = __webpack_require__(3);
860
800
 
861
- /***/ 21:
862
- /***/ (function(module, exports) {
801
+ var MarkerGauge_1 = __webpack_require__(217);
863
802
 
864
- module.exports = require("@splunk/visualization-context/TimezoneContext");
803
+ var config_1 = __webpack_require__(219);
865
804
 
866
- /***/ }),
805
+ exports.config = config_1.default;
867
806
 
868
- /***/ 214:
869
- /***/ (function(module, exports, __webpack_require__) {
807
+ var withDashboardViz_1 = __webpack_require__(31);
870
808
 
871
- "use strict";
809
+ var gaugeUtils_1 = __webpack_require__(80);
872
810
 
811
+ exports.PureMarkerGauge = MarkerGauge_1.default;
812
+ var validOptions = Object.keys(config_1.default.optionsSchema);
873
813
 
874
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
875
- if (k2 === undefined) k2 = k;
876
- Object.defineProperty(o, k2, {
877
- enumerable: true,
878
- get: function get() {
879
- return m[k];
880
- }
881
- });
882
- } : function (o, m, k, k2) {
883
- if (k2 === undefined) k2 = k;
884
- o[k2] = m[k];
885
- });
814
+ var computeVizProps = function computeVizProps(_a) {
815
+ var props = __rest(_a, []);
886
816
 
887
- var __exportStar = this && this.__exportStar || function (m, exports) {
888
- for (var p in m) {
889
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
890
- }
817
+ var options = lodash_1.chain(props).pick(validOptions).thru(gaugeUtils_1.convertToGaugeProperties).value();
818
+ var defaultColors = {
819
+ fillColor: config_1.default.themes.defaultFillColor(props),
820
+ majorTickFillColor: config_1.default.themes.majorTickFillColor(props),
821
+ majorTickStrokeColor: config_1.default.themes.majorTickStrokeColor(props),
822
+ valueMarkerFillColor: config_1.default.themes.valueMarkerFillColor(props),
823
+ valueMarkerLabelFillColor: config_1.default.themes.valueMarkerLabelFillColor(props)
824
+ };
825
+ return Object.assign(Object.assign({}, options), defaultColors);
891
826
  };
892
827
 
893
- Object.defineProperty(exports, "__esModule", {
894
- value: true
828
+ exports.computeVizProps = computeVizProps;
829
+ var viz = withDashboardViz_1.default({
830
+ ReactViz: MarkerGauge_1.default,
831
+ computeVizProps: exports.computeVizProps,
832
+ vizConfig: config_1.default
895
833
  });
896
- exports.default = void 0;
834
+ exports.default = viz;
835
+
836
+ /***/ }),
897
837
 
898
- __exportStar(__webpack_require__(133), exports);
838
+ /***/ 14:
839
+ /***/ (function(module, exports) {
899
840
 
900
- var MarkerGauge_1 = __webpack_require__(133);
841
+ module.exports = require("@splunk/visualizations-shared/style");
901
842
 
902
- Object.defineProperty(exports, "default", {
903
- enumerable: true,
904
- get: function get() {
905
- return MarkerGauge_1.default;
906
- }
907
- });
843
+ /***/ }),
844
+
845
+ /***/ 15:
846
+ /***/ (function(module, exports) {
847
+
848
+ module.exports = require("@splunk/visualizations-shared/schemaUtils");
908
849
 
909
850
  /***/ }),
910
851
 
911
- /***/ 215:
852
+ /***/ 16:
912
853
  /***/ (function(module, exports, __webpack_require__) {
913
854
 
914
855
  "use strict";
915
856
 
916
857
 
858
+ var _toConsumableArray = __webpack_require__(7);
859
+
860
+ var _defineProperty = __webpack_require__(6);
861
+
917
862
  var __rest = this && this.__rest || function (s, e) {
918
863
  var t = {};
919
864
 
@@ -930,32 +875,336 @@ var __rest = this && this.__rest || function (s, e) {
930
875
  Object.defineProperty(exports, "__esModule", {
931
876
  value: true
932
877
  });
878
+ exports.insertLayout = exports.isDynamicOption = exports.uncollapseEditorConfig = exports.generatePrecisionValues = exports.getInitialPreset = exports.enhanceOptionsSchemaWithDynamicOptions = exports.enhanceConfig = void 0;
933
879
 
934
- var React = __webpack_require__(1);
935
-
936
- var react_1 = __webpack_require__(1);
937
-
938
- var T = __webpack_require__(0);
939
-
940
- var styled_components_1 = __webpack_require__(4);
941
-
942
- var lodash_1 = __webpack_require__(2);
880
+ var lodash_1 = __webpack_require__(3);
943
881
 
944
- var i18n_1 = __webpack_require__(3);
882
+ var schemaUtils_1 = __webpack_require__(15);
945
883
 
946
- var style_1 = __webpack_require__(15);
884
+ var VizBehavior_1 = __webpack_require__(5);
947
885
 
948
- var SizeAwareWrapper_1 = __webpack_require__(18);
886
+ var dynamicOptionsDSLType = {
887
+ type: 'string',
888
+ pattern: schemaUtils_1.DYNAMIC_OPTIONS_DSL_PATTERN
889
+ };
890
+ /**
891
+ * Helper function to extend an options schema with dynamic options DSL
892
+ * @param optionsSchema a visualization's options schema
893
+ * @returns an updated options schema that additionally allows strings starting with > for each option
894
+ */
949
895
 
950
- var Message_1 = __webpack_require__(11);
896
+ function enhanceOptionsSchemaWithDynamicOptions(optionsSchema) {
897
+ var enhancedOptionsSchema = {};
898
+ Object.keys(optionsSchema).forEach(function (key) {
899
+ var _a = optionsSchema[key],
900
+ title = _a.title,
901
+ description = _a.description,
902
+ readOnly = _a.readOnly,
903
+ writeOnly = _a.writeOnly,
904
+ examples = _a.examples,
905
+ defaultValue = _a.default,
906
+ type = _a.type,
907
+ properties = _a.properties,
908
+ patternProperties = _a.patternProperties,
909
+ remainingSchemaEntry = __rest(_a, ["title", "description", "readOnly", "writeOnly", "examples", "default", "type", "properties", "patternProperties"]);
951
910
 
952
- var id_1 = __webpack_require__(216);
911
+ var annotations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, title !== undefined && {
912
+ title: title
913
+ }), description !== undefined && {
914
+ description: description
915
+ }), readOnly !== undefined && {
916
+ readOnly: readOnly
917
+ }), writeOnly !== undefined && {
918
+ writeOnly: writeOnly
919
+ }), examples !== undefined && {
920
+ examples: examples
921
+ }), defaultValue !== undefined && {
922
+ default: defaultValue
923
+ });
953
924
 
954
- var gaugeUtils_1 = __webpack_require__(80);
925
+ if (type === 'object') {
926
+ enhancedOptionsSchema[key] = Object.assign(Object.assign(Object.assign(Object.assign({}, remainingSchemaEntry), annotations), {
927
+ type: type
928
+ }), properties && {
929
+ properties: enhanceOptionsSchemaWithDynamicOptions(properties)
930
+ });
931
+
932
+ if (patternProperties) {
933
+ var enhancedPatternProperties = {};
934
+ Object.keys(patternProperties).forEach(function (opt) {
935
+ enhancedPatternProperties = Object.assign(Object.assign({}, enhancedPatternProperties), enhanceOptionsSchemaWithDynamicOptions(_defineProperty({}, opt, patternProperties[opt])));
936
+ });
937
+ enhancedOptionsSchema[key].patternProperties = enhancedPatternProperties;
938
+ }
939
+ } else {
940
+ enhancedOptionsSchema[key] = Object.assign(Object.assign({}, annotations), {
941
+ anyOf: [Object.assign(Object.assign({}, type !== undefined && {
942
+ type: type
943
+ }), remainingSchemaEntry), dynamicOptionsDSLType]
944
+ });
945
+ }
946
+ });
947
+ return enhancedOptionsSchema;
948
+ }
949
+
950
+ exports.enhanceOptionsSchemaWithDynamicOptions = enhanceOptionsSchemaWithDynamicOptions;
951
+ /**
952
+ * Helper function to enhance a Visualization Config as needed based on behaviors specified in supports block
953
+ * this function also collapse all editor panels
954
+ * @param vizConfig a Visualization Config
955
+ * @returns an enhanced Visualization Config containing updated config entries based on behaviors it supports
956
+ * and containing `open: false` for all editor panels in editorConfig
957
+ */
958
+
959
+ function enhanceConfig(vizConfig) {
960
+ var enhancedConfig = vizConfig;
961
+
962
+ if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS) !== -1) {
963
+ enhancedConfig.optionsSchema = enhanceOptionsSchemaWithDynamicOptions(vizConfig.optionsSchema);
964
+ }
965
+
966
+ enhancedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
967
+ return Object.assign(Object.assign({}, config), {
968
+ open: false
969
+ });
970
+ });
971
+ return enhancedConfig;
972
+ }
973
+
974
+ exports.enhanceConfig = enhanceConfig;
975
+ /**
976
+ * Helper function to uncollapse all editor panels by adding `open: true` to the editorConfig
977
+ * Created for editor unit tests
978
+ * @param vizConfig a Visualization Config
979
+ * @returns a Visualization Config containing `open: true` for all editor panels in editorConfig
980
+ */
981
+
982
+ function uncollapseEditorConfig(vizConfig) {
983
+ var editorPanelUncollapsedConfig = vizConfig;
984
+ editorPanelUncollapsedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
985
+ return Object.assign(Object.assign({}, config), {
986
+ open: true
987
+ });
988
+ });
989
+ return editorPanelUncollapsedConfig;
990
+ }
991
+
992
+ exports.uncollapseEditorConfig = uncollapseEditorConfig;
993
+
994
+ function isDynamicOption(option) {
995
+ return option && typeof option === 'string' && option.trim().startsWith('>') || false;
996
+ }
997
+
998
+ exports.isDynamicOption = isDynamicOption; // private helpers to improve readability of getInitialPreset
999
+ // this shouldn't be tested since this util isn't something that we expect to use outside of getInitialPreset
1000
+
1001
+ /**
1002
+ * this checks to make sure that all values within vizContext are compatible with the given preset's context to determine the initialPreset
1003
+ * if a preset has explicitly specified a key as being undefined, the vizContext must also has that key as undefined, or else this CANNOT be the initialPreset
1004
+ * the inverse is true; if a preset has key is NOT undefined, it must also be NOT undefined in the corresponding vizContext
1005
+ * the internal config contents are irrelevant (as the user could customize them in source), just as long as the presence of `undefined`s match up
1006
+ *
1007
+ * Since the presetConfigs have explicit undefined keys to override the existing config, we need to explicitly check the undefined values
1008
+ */
1009
+
1010
+ function hasCompatibleContexts(vizContext, presetContext) {
1011
+ var presetContextKeys = Object.keys(presetContext);
1012
+ return presetContextKeys.every(function (contextKey) {
1013
+ return presetContext[contextKey] === undefined && vizContext[contextKey] === undefined || presetContext[contextKey] !== undefined && vizContext[contextKey] !== undefined;
1014
+ });
1015
+ }
1016
+ /**
1017
+ * Checks to make sure that dynamic (non-dynamic) options in a given preset are also dynamic (non-dynamic) in the vizOptions
1018
+ */
1019
+
1020
+
1021
+ function hasCompatibleOptions(vizOptions, presetOptions) {
1022
+ var presetOptionKeys = Object.keys(presetOptions);
1023
+ return presetOptionKeys.every(function (optionKey) {
1024
+ return isDynamicOption(presetOptions[optionKey]) === isDynamicOption(vizOptions[optionKey]);
1025
+ });
1026
+ }
1027
+ /**
1028
+ * Evaluates whether there is an initialPreset that fits the current state of vizContext + vizOptions
1029
+ * This function ignores extraneous vizOptions or vizContext keys, as they could be outside the scope of what the preset is intended to configure
1030
+ *
1031
+ * @param {Object} vizContext - the current vizContext definition
1032
+ * @param {Object} vizOptions - the current vizOptions definition
1033
+ * @param {PresetEntry[]} presets - the list of presets, one of which can be considered an initialPreset
1034
+ */
1035
+
1036
+
1037
+ function getInitialPreset(vizContext, vizOptions, presets) {
1038
+ return presets.find(function (preset) {
1039
+ var presetContext = lodash_1.get(preset, ['value', 'context'], {});
1040
+ var presetOptions = lodash_1.get(preset, ['value', 'options'], {});
1041
+ var presetContextKeys = Object.keys(presetContext);
1042
+ var presetOptionKeys = Object.keys(presetOptions); // all presets have to explicitly specify which options to reset (i.e. need explicitly undefined keys)
1043
+ // if not, then the preset is invalid in config.ts
1044
+
1045
+ if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
1046
+ return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
1047
+ });
1048
+ }
1049
+
1050
+ exports.getInitialPreset = getInitialPreset;
1051
+ /**
1052
+ * generates number precision values for a Select editor
1053
+ *
1054
+ * @param {Number} numPrecisionValues - number of integer precision values to generate
1055
+ * @returns {{ label: string; value; string }[]} array of { label, value } tuples
1056
+ */
1057
+
1058
+ function generatePrecisionValues(numPrecisionValues) {
1059
+ return lodash_1.range(0, numPrecisionValues + 1).map(function (i) {
1060
+ return {
1061
+ label: "".concat(i, " (0").concat(i > 0 ? '.' : '').concat('0'.repeat(i), ")"),
1062
+ value: i
1063
+ };
1064
+ });
1065
+ }
1066
+
1067
+ exports.generatePrecisionValues = generatePrecisionValues;
1068
+ /**
1069
+ * insert layout in layout array, return a new layout array instead of updating the original
1070
+ *
1071
+ * @param {EditorLayoutConfig[][]} layout - editor layout
1072
+ * @param {Number} index - the index to insert layout item(s)
1073
+ * @param {EditorLayoutConfig[][]} layoutItems - the item(s) to insert
1074
+ * @returns {EditorLayoutConfig[][]} new editor layout with insertion
1075
+ */
1076
+
1077
+ var insertLayout = function insertLayout(layout, index) {
1078
+ for (var _len = arguments.length, layoutItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1079
+ layoutItems[_key - 2] = arguments[_key];
1080
+ }
1081
+
1082
+ return [].concat(_toConsumableArray(layout.slice(0, index)), layoutItems, _toConsumableArray(layout.slice(index)));
1083
+ };
1084
+
1085
+ exports.insertLayout = insertLayout;
1086
+
1087
+ /***/ }),
1088
+
1089
+ /***/ 18:
1090
+ /***/ (function(module, exports) {
1091
+
1092
+ module.exports = require("@babel/runtime/helpers/createClass");
1093
+
1094
+ /***/ }),
1095
+
1096
+ /***/ 19:
1097
+ /***/ (function(module, exports) {
1098
+
1099
+ module.exports = require("@splunk/visualizations-shared/SizeAwareWrapper");
1100
+
1101
+ /***/ }),
1102
+
1103
+ /***/ 2:
1104
+ /***/ (function(module, exports) {
1105
+
1106
+ module.exports = require("@splunk/ui-utils/i18n");
1107
+
1108
+ /***/ }),
1109
+
1110
+ /***/ 21:
1111
+ /***/ (function(module, exports) {
1112
+
1113
+ module.exports = require("@splunk/themes/pick");
1114
+
1115
+ /***/ }),
1116
+
1117
+ /***/ 216:
1118
+ /***/ (function(module, exports, __webpack_require__) {
1119
+
1120
+ "use strict";
1121
+
1122
+
1123
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1124
+ if (k2 === undefined) k2 = k;
1125
+ Object.defineProperty(o, k2, {
1126
+ enumerable: true,
1127
+ get: function get() {
1128
+ return m[k];
1129
+ }
1130
+ });
1131
+ } : function (o, m, k, k2) {
1132
+ if (k2 === undefined) k2 = k;
1133
+ o[k2] = m[k];
1134
+ });
1135
+
1136
+ var __exportStar = this && this.__exportStar || function (m, exports) {
1137
+ for (var p in m) {
1138
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1139
+ }
1140
+ };
1141
+
1142
+ Object.defineProperty(exports, "__esModule", {
1143
+ value: true
1144
+ });
1145
+ exports.default = void 0;
1146
+
1147
+ __exportStar(__webpack_require__(134), exports);
1148
+
1149
+ var MarkerGauge_1 = __webpack_require__(134);
1150
+
1151
+ Object.defineProperty(exports, "default", {
1152
+ enumerable: true,
1153
+ get: function get() {
1154
+ return MarkerGauge_1.default;
1155
+ }
1156
+ });
1157
+
1158
+ /***/ }),
1159
+
1160
+ /***/ 217:
1161
+ /***/ (function(module, exports, __webpack_require__) {
1162
+
1163
+ "use strict";
1164
+
1165
+
1166
+ var __rest = this && this.__rest || function (s, e) {
1167
+ var t = {};
1168
+
1169
+ for (var p in s) {
1170
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
1171
+ }
1172
+
1173
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1174
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
1175
+ }
1176
+ return t;
1177
+ };
1178
+
1179
+ Object.defineProperty(exports, "__esModule", {
1180
+ value: true
1181
+ });
1182
+
1183
+ var React = __webpack_require__(1);
1184
+
1185
+ var react_1 = __webpack_require__(1);
1186
+
1187
+ var T = __webpack_require__(0);
1188
+
1189
+ var styled_components_1 = __webpack_require__(4);
1190
+
1191
+ var lodash_1 = __webpack_require__(3);
1192
+
1193
+ var i18n_1 = __webpack_require__(2);
1194
+
1195
+ var style_1 = __webpack_require__(14);
1196
+
1197
+ var SizeAwareWrapper_1 = __webpack_require__(19);
1198
+
1199
+ var Message_1 = __webpack_require__(9);
1200
+
1201
+ var id_1 = __webpack_require__(218);
1202
+
1203
+ var gaugeUtils_1 = __webpack_require__(80);
955
1204
 
956
- var GaugeMajorTicks_1 = __webpack_require__(102);
1205
+ var GaugeMajorTicks_1 = __webpack_require__(103);
957
1206
 
958
- var GaugeValueMarker_1 = __webpack_require__(103);
1207
+ var GaugeValueMarker_1 = __webpack_require__(104);
959
1208
 
960
1209
  var MAX_VERTICAL_CONTAINER_WIDTH = 200;
961
1210
  var MIN_VERTICAL_CONTAINER_HEIGHT = 200;
@@ -1279,14 +1528,14 @@ exports.default = MarkerGauge;
1279
1528
 
1280
1529
  /***/ }),
1281
1530
 
1282
- /***/ 216:
1531
+ /***/ 218:
1283
1532
  /***/ (function(module, exports) {
1284
1533
 
1285
1534
  module.exports = require("@splunk/ui-utils/id");
1286
1535
 
1287
1536
  /***/ }),
1288
1537
 
1289
- /***/ 217:
1538
+ /***/ 219:
1290
1539
  /***/ (function(module, exports, __webpack_require__) {
1291
1540
 
1292
1541
  "use strict";
@@ -1296,25 +1545,25 @@ Object.defineProperty(exports, "__esModule", {
1296
1545
  value: true
1297
1546
  });
1298
1547
 
1299
- var i18n_1 = __webpack_require__(3);
1548
+ var i18n_1 = __webpack_require__(2);
1300
1549
 
1301
- var GaugeMarker_1 = __webpack_require__(218);
1550
+ var GaugeMarker_1 = __webpack_require__(220);
1302
1551
 
1303
1552
  var placeholders_1 = __webpack_require__(45);
1304
1553
 
1305
- var schemaUtils_1 = __webpack_require__(16);
1554
+ var schemaUtils_1 = __webpack_require__(15);
1306
1555
 
1307
- var variables_1 = __webpack_require__(10);
1556
+ var variables_1 = __webpack_require__(8);
1308
1557
 
1309
- var pick_1 = __webpack_require__(20);
1558
+ var pick_1 = __webpack_require__(21);
1310
1559
 
1311
- var Gauge_1 = __webpack_require__(101);
1560
+ var Gauge_1 = __webpack_require__(102);
1312
1561
 
1313
1562
  var VizBehavior_1 = __webpack_require__(5);
1314
1563
 
1315
- var VizCategory_1 = __webpack_require__(29);
1564
+ var VizCategory_1 = __webpack_require__(30);
1316
1565
 
1317
- var configUtils_1 = __webpack_require__(6);
1566
+ var configUtils_1 = __webpack_require__(16);
1318
1567
 
1319
1568
  var BackgroundColor_1 = __webpack_require__(49);
1320
1569
 
@@ -1373,8 +1622,7 @@ var optionsSchema = {
1373
1622
  value: {
1374
1623
  description: 'Color for sub range.',
1375
1624
  type: 'string',
1376
- pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN // insert pattern for color variables - #HEX etc
1377
-
1625
+ pattern: schemaUtils_1.COLOR_OR_TOKEN_PATTERN_WITH_RGBA
1378
1626
  }
1379
1627
  },
1380
1628
  required: ['from', 'to', 'value'],
@@ -1538,62 +1786,42 @@ exports.default = configUtils_1.enhanceConfig(config);
1538
1786
 
1539
1787
  /***/ }),
1540
1788
 
1541
- /***/ 218:
1789
+ /***/ 22:
1542
1790
  /***/ (function(module, exports) {
1543
1791
 
1544
- module.exports = require("@splunk/react-icons/GaugeMarker");
1792
+ module.exports = require("@splunk/visualization-context/TimezoneContext");
1545
1793
 
1546
1794
  /***/ }),
1547
1795
 
1548
- /***/ 23:
1796
+ /***/ 220:
1549
1797
  /***/ (function(module, exports) {
1550
1798
 
1551
- module.exports = require("@splunk/visualizations-shared/numberUtils");
1799
+ module.exports = require("@splunk/react-icons/GaugeMarker");
1552
1800
 
1553
1801
  /***/ }),
1554
1802
 
1555
1803
  /***/ 24:
1556
- /***/ (function(module, exports, __webpack_require__) {
1557
-
1558
- "use strict";
1559
-
1560
-
1561
- Object.defineProperty(exports, "__esModule", {
1562
- value: true
1563
- });
1564
- exports.pickFieldFromJSONSchema = void 0;
1565
-
1566
- var lodash_1 = __webpack_require__(2);
1804
+ /***/ (function(module, exports) {
1567
1805
 
1568
- var pickFieldFromJSONSchema = function pickFieldFromJSONSchema(optionsSchema) {
1569
- var fieldName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
1570
- return Object.keys(optionsSchema).reduce(function (accum, k) {
1571
- if (lodash_1.has(optionsSchema[k], fieldName)) {
1572
- accum[k] = optionsSchema[k][fieldName];
1573
- } else if (lodash_1.get(optionsSchema, [k, 'type']) === 'object' && lodash_1.has(optionsSchema[k], 'properties')) {
1574
- var nestedSchema = exports.pickFieldFromJSONSchema(optionsSchema[k].properties, fieldName);
1806
+ module.exports = require("@splunk/visualizations-shared/hocUtils");
1575
1807
 
1576
- if (!lodash_1.isEmpty(nestedSchema)) {
1577
- accum[k] = nestedSchema;
1578
- }
1579
- }
1808
+ /***/ }),
1580
1809
 
1581
- return accum;
1582
- }, {});
1583
- };
1810
+ /***/ 25:
1811
+ /***/ (function(module, exports) {
1584
1812
 
1585
- exports.pickFieldFromJSONSchema = pickFieldFromJSONSchema;
1813
+ module.exports = require("@splunk/visualizations-shared/JSONSchemaUtils");
1586
1814
 
1587
1815
  /***/ }),
1588
1816
 
1589
- /***/ 25:
1817
+ /***/ 26:
1590
1818
  /***/ (function(module, exports) {
1591
1819
 
1592
- module.exports = require("@babel/runtime/helpers/typeof");
1820
+ module.exports = require("@splunk/visualizations-shared/numberUtils");
1593
1821
 
1594
1822
  /***/ }),
1595
1823
 
1596
- /***/ 26:
1824
+ /***/ 27:
1597
1825
  /***/ (function(module, exports, __webpack_require__) {
1598
1826
 
1599
1827
  "use strict";
@@ -1608,13 +1836,13 @@ var React = __webpack_require__(1);
1608
1836
 
1609
1837
  var T = __webpack_require__(0);
1610
1838
 
1611
- var lodash_1 = __webpack_require__(2);
1839
+ var lodash_1 = __webpack_require__(3);
1612
1840
 
1613
- var i18n_1 = __webpack_require__(3);
1841
+ var i18n_1 = __webpack_require__(2);
1614
1842
 
1615
- var Message_1 = __webpack_require__(11);
1843
+ var Message_1 = __webpack_require__(9);
1616
1844
 
1617
- var FixedSizeContainer_1 = __webpack_require__(14);
1845
+ var FixedSizeContainer_1 = __webpack_require__(12);
1618
1846
  /**
1619
1847
  * @method shouldShowIconPlaceholder
1620
1848
  * @param {object} dataSources
@@ -1668,954 +1896,674 @@ var IconPlaceholder = function IconPlaceholder(props) {
1668
1896
  });
1669
1897
  }
1670
1898
 
1671
- return React.createElement(Message_1.default, {
1672
- width: width,
1673
- height: height,
1674
- level: "warning",
1675
- message: i18n_1._('No DataSource Connected')
1676
- });
1677
- };
1678
-
1679
- IconPlaceholder.propTypes = propTypes;
1680
- IconPlaceholder.defaultProps = {
1681
- width: '100%',
1682
- height: 250
1683
- };
1684
- exports.default = FixedSizeContainer_1.default(IconPlaceholder);
1685
-
1686
- /***/ }),
1687
-
1688
- /***/ 27:
1689
- /***/ (function(module, exports, __webpack_require__) {
1690
-
1691
- "use strict";
1692
-
1693
-
1694
- var _defineProperty = __webpack_require__(7);
1695
-
1696
- Object.defineProperty(exports, "__esModule", {
1697
- value: true
1698
- });
1699
- exports.getSortingParams = exports.SortParamsPropTypes = void 0;
1700
-
1701
- var T = __webpack_require__(0);
1702
-
1703
- var lodash_1 = __webpack_require__(2);
1704
-
1705
- var DataSource_1 = __webpack_require__(37);
1706
-
1707
- exports.SortParamsPropTypes = T.shape({
1708
- currentSortKey: T.string,
1709
- currentSortDir: T.oneOf(DataSource_1.validSortDirs),
1710
- onSort: T.func
1711
- });
1712
-
1713
- var getSortingParams = function getSortingParams(_ref) {
1714
- var requestParams = _ref.requestParams,
1715
- onRequestParamsChange = _ref.onRequestParamsChange;
1716
- var currentSortKey;
1717
- var currentSortDir;
1718
- var nextSortDirMap = {
1719
- asc: 'desc',
1720
- desc: 'asc',
1721
- none: 'asc'
1722
- };
1723
- var onSort;
1724
-
1725
- if (lodash_1.isFunction(onRequestParamsChange)) {
1726
- if (requestParams && lodash_1.has(requestParams, 'sort')) {
1727
- currentSortKey = Object.keys(requestParams.sort).shift();
1728
- currentSortDir = requestParams.sort[currentSortKey];
1729
- } // undid memoization since there is a dependency on requestParams, which is a deeply nested object
1730
-
1731
-
1732
- onSort = function onSort(e, _ref2) {
1733
- var sortKey = _ref2.sortKey,
1734
- sortDir = _ref2.sortDir;
1735
-
1736
- if (typeof sortKey === 'string') {
1737
- var nextSortDir = lodash_1.has(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : 'none';
1738
- onRequestParamsChange(Object.assign(Object.assign({}, requestParams), {
1739
- offset: 0,
1740
- sort: _defineProperty({}, sortKey, nextSortDir)
1741
- }));
1742
- } else {
1743
- onRequestParamsChange(requestParams);
1744
- }
1745
- };
1746
- }
1747
-
1748
- return {
1749
- currentSortKey: currentSortKey,
1750
- currentSortDir: currentSortDir,
1751
- onSort: onSort
1752
- };
1753
- };
1754
-
1755
- exports.getSortingParams = getSortingParams;
1756
-
1757
- /***/ }),
1758
-
1759
- /***/ 28:
1760
- /***/ (function(module, exports, __webpack_require__) {
1761
-
1762
- "use strict";
1763
-
1764
-
1765
- Object.defineProperty(exports, "__esModule", {
1766
- value: true
1767
- });
1768
- exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;
1769
-
1770
- var T = __webpack_require__(0);
1771
-
1772
- var lodash_1 = __webpack_require__(2);
1773
-
1774
- exports.PaginatorParamsPropTypes = T.shape({
1775
- isPaging: T.bool,
1776
- current: T.number,
1777
- totalPages: T.number,
1778
- onChange: T.func
1779
- });
1780
-
1781
- var getPaginationParams = function getPaginationParams(_ref) {
1782
- var requestParams = _ref.requestParams,
1783
- meta = _ref.meta,
1784
- onRequestParamsChange = _ref.onRequestParamsChange;
1785
- var totalCount = meta && meta.totalCount || 0;
1786
- var offset = requestParams && requestParams.offset || 0;
1787
- var count = requestParams && requestParams.count;
1788
- var totalPages = typeof count === 'number' && count > 0 ? Math.ceil(totalCount / count) : 0;
1789
- var current = typeof count === 'number' && count > 0 ? Math.floor(offset / count) + 1 : 0;
1790
- var isPaging = totalPages > 1 && lodash_1.isFunction(onRequestParamsChange);
1791
-
1792
- var onChangeHandler = function onChangeHandler(e, _ref2) {
1793
- var page = _ref2.page,
1794
- countArg = _ref2.count;
1795
- var newParams = lodash_1.cloneDeep(requestParams);
1796
-
1797
- if (typeof countArg === 'number') {
1798
- newParams.count = countArg;
1799
- newParams.offset = 0;
1800
- }
1801
-
1802
- var pageCount = typeof newParams.count === 'number' ? newParams.count : 10;
1803
-
1804
- if (typeof page === 'number' && page > 0) {
1805
- newParams.count = pageCount;
1806
- newParams.offset = (page - 1) * pageCount;
1807
- }
1808
-
1809
- onRequestParamsChange(newParams);
1810
- };
1811
-
1812
- return {
1813
- isPaging: isPaging,
1814
- current: current,
1815
- totalPages: totalPages,
1816
- onChange: lodash_1.isFunction(onRequestParamsChange) ? onChangeHandler : lodash_1.noop
1817
- };
1818
- };
1819
-
1820
- exports.getPaginationParams = getPaginationParams;
1821
-
1822
- /***/ }),
1823
-
1824
- /***/ 29:
1825
- /***/ (function(module, exports, __webpack_require__) {
1826
-
1827
- "use strict";
1828
-
1829
-
1830
- Object.defineProperty(exports, "__esModule", {
1831
- value: true
1832
- });
1833
- exports.VizCategory = void 0;
1834
- var VizCategory;
1835
-
1836
- (function (VizCategory) {
1837
- VizCategory["SINGLE_VALUE"] = "Single Value";
1838
- VizCategory["TRENDS"] = "Trends";
1839
- VizCategory["COMPARISONS"] = "Comparisons";
1840
- VizCategory["TABLE"] = "Table";
1841
- VizCategory["GAUGE"] = "Gauge";
1842
- VizCategory["DISTRIBUTIONS"] = "Distributions";
1843
- VizCategory["CHOROPLETH"] = "Choropleth Maps";
1844
- VizCategory["SHAPES"] = "Shapes";
1845
- VizCategory["MISC"] = "misc";
1846
- VizCategory["FLOW"] = "Flow";
1847
- VizCategory["CORRELATION"] = "Correlation";
1848
- VizCategory["SPATIAL"] = "Spatial";
1849
- })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
1850
-
1851
- /***/ }),
1852
-
1853
- /***/ 3:
1854
- /***/ (function(module, exports) {
1899
+ return React.createElement(Message_1.default, {
1900
+ width: width,
1901
+ height: height,
1902
+ level: "warning",
1903
+ message: i18n_1._('No DataSource Connected')
1904
+ });
1905
+ };
1855
1906
 
1856
- module.exports = require("@splunk/ui-utils/i18n");
1907
+ IconPlaceholder.propTypes = propTypes;
1908
+ IconPlaceholder.defaultProps = {
1909
+ width: '100%',
1910
+ height: 250
1911
+ };
1912
+ exports.default = FixedSizeContainer_1.default(IconPlaceholder);
1857
1913
 
1858
1914
  /***/ }),
1859
1915
 
1860
- /***/ 30:
1916
+ /***/ 28:
1861
1917
  /***/ (function(module, exports, __webpack_require__) {
1862
1918
 
1863
1919
  "use strict";
1864
1920
 
1865
1921
 
1922
+ var _defineProperty = __webpack_require__(6);
1923
+
1866
1924
  Object.defineProperty(exports, "__esModule", {
1867
1925
  value: true
1868
1926
  });
1927
+ exports.getSortingParams = exports.SortParamsPropTypes = void 0;
1869
1928
 
1870
- var React = __webpack_require__(1);
1871
-
1872
- var lodash_1 = __webpack_require__(2);
1873
-
1874
- var getSettingsFromThemedProps_1 = __webpack_require__(31);
1875
-
1876
- var Options_1 = __webpack_require__(32);
1877
-
1878
- var SanitizeProps_1 = __webpack_require__(33);
1879
-
1880
- var TimezoneContext_1 = __webpack_require__(21);
1881
-
1882
- var moment_1 = __webpack_require__(34);
1883
-
1884
- var styled_components_1 = __webpack_require__(4);
1885
-
1886
- var SplunkVisualization_1 = __webpack_require__(35);
1887
-
1888
- var VizBehavior_1 = __webpack_require__(5);
1889
-
1890
- var getSorting_1 = __webpack_require__(27);
1891
-
1892
- var getPagination_1 = __webpack_require__(28);
1893
-
1894
- var useDeepMemo_1 = __webpack_require__(38);
1895
-
1896
- var JSONSchemaUtils_1 = __webpack_require__(24);
1897
-
1898
- var MissingPropsMessage_1 = __webpack_require__(39);
1899
-
1900
- var withEditModeCover_1 = __webpack_require__(40);
1929
+ var T = __webpack_require__(0);
1901
1930
 
1902
- var withPlaceholder_1 = __webpack_require__(42);
1931
+ var lodash_1 = __webpack_require__(3);
1903
1932
 
1904
- var hocUtils_1 = __webpack_require__(8);
1905
- /**
1906
- * hoc that wraps a pure react visualization in a Dashboard visualization
1907
- * @param {DashboardVizOpts} opts
1908
- * @returns {HOC}
1909
- */
1933
+ var DataSource_1 = __webpack_require__(38);
1910
1934
 
1935
+ exports.SortParamsPropTypes = T.shape({
1936
+ currentSortKey: T.string,
1937
+ currentSortDir: T.oneOf(DataSource_1.validSortDirs),
1938
+ onSort: T.func
1939
+ });
1911
1940
 
1912
- var withDashboardViz = function withDashboardViz(opts) {
1913
- var ReactViz = opts.ReactViz,
1914
- vizConfig = opts.vizConfig,
1915
- _opts$computeVizProps = opts.computeVizProps,
1916
- computeVizProps = _opts$computeVizProps === void 0 ? function () {} : _opts$computeVizProps,
1917
- disableEditModeCover = opts.disableEditModeCover,
1918
- useIconPlaceholder = opts.useIconPlaceholder; // sanitizing props before sending them to reactviz.
1941
+ var getSortingParams = function getSortingParams(_ref) {
1942
+ var requestParams = _ref.requestParams,
1943
+ onRequestParamsChange = _ref.onRequestParamsChange;
1944
+ var currentSortKey;
1945
+ var currentSortDir;
1946
+ var nextSortDirMap = {
1947
+ asc: 'desc',
1948
+ desc: 'asc',
1949
+ none: 'asc'
1950
+ };
1951
+ var onSort;
1919
1952
 
1920
- var SanitizedReactViz = SanitizeProps_1.withSanitizedProps(ReactViz);
1921
- var defaultOptions = JSONSchemaUtils_1.pickFieldFromJSONSchema(vizConfig.optionsSchema, 'default');
1953
+ if (lodash_1.isFunction(onRequestParamsChange)) {
1954
+ if (requestParams && lodash_1.has(requestParams, 'sort')) {
1955
+ currentSortKey = Object.keys(requestParams.sort).shift();
1956
+ currentSortDir = requestParams.sort[currentSortKey];
1957
+ } // undid memoization since there is a dependency on requestParams, which is a deeply nested object
1922
1958
 
1923
- var DashboardViz = function DashboardViz(props) {
1924
- var mode = props.mode,
1925
- hasEventHandlers = props.hasEventHandlers,
1926
- dataSources = props.dataSources,
1927
- options = props.options,
1928
- _props$context = props.context,
1929
- context = _props$context === void 0 ? {} : _props$context,
1930
- width = props.width,
1931
- height = props.height,
1932
- onComputedProps = props.onComputedProps,
1933
- onEventTrigger = props.onEventTrigger,
1934
- theme = props.theme,
1935
- onRequestParamsChange = props.onRequestParamsChange;
1936
1959
 
1937
- var _React$useContext = React.useContext(TimezoneContext_1.default),
1938
- serializedTimezone = _React$useContext.serializedTimezone;
1960
+ onSort = function onSort(e, _ref2) {
1961
+ var sortKey = _ref2.sortKey,
1962
+ sortDir = _ref2.sortDir;
1939
1963
 
1940
- if (serializedTimezone) {
1941
- /*
1942
- @splunk/moment currently does not allow us to customize the timezone on a per visualization basis.
1943
- This ensures that if a timezone was provided via TimezoneContext @splunk/moment time formatting
1944
- will use it.
1945
- @TODO(pwied):
1946
- - remove when we moved away from @splunk/moment
1947
- - provide timezone context to dynamic option evaluation phase
1948
- */
1949
- if (!moment_1.default.getDefaultSplunkTimezone()) {
1950
- moment_1.default.setDefaultSplunkTimezone(serializedTimezone);
1964
+ if (typeof sortKey === 'string') {
1965
+ var nextSortDir = lodash_1.has(nextSortDirMap, sortDir) ? nextSortDirMap[sortDir] : 'none';
1966
+ onRequestParamsChange(Object.assign(Object.assign({}, requestParams), {
1967
+ offset: 0,
1968
+ sort: _defineProperty({}, sortKey, nextSortDir)
1969
+ }));
1970
+ } else {
1971
+ onRequestParamsChange(requestParams);
1951
1972
  }
1952
- }
1953
-
1954
- var themeFunc = function themeFunc(themeVar) {
1955
- var _a, _b;
1956
-
1957
- return (_b = (_a = vizConfig.themes)[themeVar]) === null || _b === void 0 ? void 0 : _b.call(_a, props);
1958
1973
  };
1974
+ }
1959
1975
 
1960
- var bgColorFromTheme = themeFunc('defaultBackgroundColor');
1961
-
1962
- var _getSettingsFromTheme = getSettingsFromThemedProps_1.default({
1963
- theme: theme
1964
- }),
1965
- currentThemeFamily = _getSettingsFromTheme.family,
1966
- currentThemeColorScheme = _getSettingsFromTheme.colorScheme,
1967
- currentThemeDensity = _getSettingsFromTheme.density;
1968
-
1969
- var evaluatedOptions = {}; // evaluatedOptions need to be initialized as an empty object
1970
-
1971
- evaluatedOptions = useDeepMemo_1.useDeepMemo(function () {
1972
- try {
1973
- return Options_1.Options.evaluate({
1974
- context: lodash_1.defaultsDeep({}, context, vizConfig.defaultContext),
1975
- options: hocUtils_1.deepMergeWithArrayPrimitiveOverrides({}, options, defaultOptions)
1976
- }, dataSources, themeFunc);
1977
- } catch (e) {
1978
- // eslint-disable-next-line no-console
1979
- console.error("unexpected error evaluating options: + ".concat(e.message));
1980
- return {};
1981
- }
1982
- }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, options, context, dataSources, serializedTimezone]); // useEffect hook needs to be initialized before any early returns
1983
- // this is in accordance with the order of hook calls being the same on each render https://reactjs.org/docs/hooks-rules.html#explanation
1984
-
1985
- React.useEffect(function () {
1986
- onComputedProps(evaluatedOptions);
1987
- }); // present warning message if any required props are missing
1988
-
1989
- var _vizConfig$requiredPr = vizConfig.requiredProps,
1990
- requiredProps = _vizConfig$requiredPr === void 0 ? [] : _vizConfig$requiredPr,
1991
- supports = vizConfig.supports;
1992
- var missing = MissingPropsMessage_1.missingKeys(requiredProps, evaluatedOptions);
1993
-
1994
- if (missing.length > 0 && supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER)) {
1995
- return React.createElement(MissingPropsMessage_1.default, {
1996
- "data-test": "missing-props-message",
1997
- width: width,
1998
- height: height,
1999
- missingProps: missing,
2000
- backgroundColor: bgColorFromTheme
2001
- });
2002
- } // events
2003
-
2004
-
2005
- var eventCallbackProps = {};
2006
-
2007
- if (hasEventHandlers && mode === 'view' && vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.EVENTS) > -1) {
2008
- var supportedEvents = vizConfig.events;
2009
- Object.keys(supportedEvents).forEach(function (eventName) {
2010
- var eventCallbackPropName = lodash_1.camelCase("on.".concat(eventName));
2011
- eventCallbackProps[eventCallbackPropName] = null; // todo: refactor single value and single value icon to send payload from viz
2012
- // then remove these lines
2013
-
2014
- var payloadKeys = supportedEvents[eventName].payloadKeys;
2015
- var payload = {};
2016
-
2017
- if (Array.isArray(payloadKeys) && payloadKeys.length) {
2018
- payloadKeys.forEach(function (p) {
2019
- payload[p] = evaluatedOptions[p];
2020
- });
2021
- }
2022
-
2023
- eventCallbackProps[eventCallbackPropName] = function (ev) {
2024
- if (ev && ev.payload) {
2025
- payload = ev.payload;
2026
- }
2027
-
2028
- return onEventTrigger({
2029
- originalEvent: ev,
2030
- payload: payload,
2031
- type: eventName
2032
- });
2033
- };
2034
- });
2035
- } // compute pure viz props which are not from options
2036
-
2037
-
2038
- var computedVizProps = computeVizProps(Object.assign(Object.assign(Object.assign(Object.assign({}, props), evaluatedOptions), eventCallbackProps), {
2039
- themeFunc: themeFunc
2040
- }));
2041
- /**
2042
- * PAGE_AND_SORT behavior
2043
- *
2044
- * Some visualizations, like table, requires metadata about the datasource,
2045
- * like total number of results, current count, offset, and sort, for rendering
2046
- * paginator and sorting direction. In this approach, the visualization
2047
- * allow users to set 'paginateDataSourceKey' to select which datasource
2048
- * should the visualization extract the metadata from. It defaults to 'primary' datasource.
2049
- * The visualization config should set the PAGE_AND_SORT behavior to receive
2050
- * 'requestParams', 'meta' and onRequestParams callback as props.
2051
- *
2052
- * In future, we could automatically detect which all datasources are being used
2053
- * and bind those magically to pagination/sorting behavior.
2054
- */
2055
-
2056
- var dataSourceMetadata = {};
2057
- var OptionKey = 'paginateDataSourceKey';
2058
- var paginateDataSourceKey = lodash_1.has(evaluatedOptions, OptionKey) && evaluatedOptions[OptionKey] || 'primary';
1976
+ return {
1977
+ currentSortKey: currentSortKey,
1978
+ currentSortDir: currentSortDir,
1979
+ onSort: onSort
1980
+ };
1981
+ };
2059
1982
 
2060
- if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.PAGE_AND_SORT) > -1 && lodash_1.has(dataSources, paginateDataSourceKey)) {
2061
- var requestParams = lodash_1.get(dataSources, [paginateDataSourceKey, 'requestParams'], {});
2062
- var meta = lodash_1.get(dataSources, [paginateDataSourceKey, 'meta'], {});
1983
+ exports.getSortingParams = getSortingParams;
2063
1984
 
2064
- var handleRequestParamsChange = function handleRequestParamsChange(payload) {
2065
- return onRequestParamsChange(paginateDataSourceKey, payload);
2066
- };
1985
+ /***/ }),
2067
1986
 
2068
- var sortParams = getSorting_1.getSortingParams({
2069
- requestParams: requestParams,
2070
- meta: meta,
2071
- onRequestParamsChange: handleRequestParamsChange
2072
- });
2073
- var paginatorParams = getPagination_1.getPaginationParams({
2074
- requestParams: requestParams,
2075
- meta: meta,
2076
- onRequestParamsChange: handleRequestParamsChange
2077
- });
2078
- dataSourceMetadata = {
2079
- sortParams: sortParams,
2080
- paginatorParams: paginatorParams
2081
- };
2082
- }
1987
+ /***/ 29:
1988
+ /***/ (function(module, exports, __webpack_require__) {
2083
1989
 
2084
- return React.createElement(SanitizedReactViz, Object.assign({
2085
- mode: mode,
2086
- width: width,
2087
- height: height
2088
- }, evaluatedOptions, computedVizProps, eventCallbackProps, dataSourceMetadata));
2089
- };
1990
+ "use strict";
2090
1991
 
2091
- DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
2092
- DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
2093
- // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
2094
- theme: {}
2095
- }); // attach viz config
2096
1992
 
2097
- DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
1993
+ Object.defineProperty(exports, "__esModule", {
1994
+ value: true
1995
+ });
1996
+ exports.getPaginationParams = exports.PaginatorParamsPropTypes = void 0;
2098
1997
 
2099
- return styled_components_1.withTheme(withPlaceholder_1.default(withEditModeCover_1.default(DashboardViz, disableEditModeCover), useIconPlaceholder));
2100
- };
1998
+ var T = __webpack_require__(0);
2101
1999
 
2102
- exports.default = withDashboardViz;
2000
+ var lodash_1 = __webpack_require__(3);
2103
2001
 
2104
- /***/ }),
2002
+ exports.PaginatorParamsPropTypes = T.shape({
2003
+ isPaging: T.bool,
2004
+ current: T.number,
2005
+ totalPages: T.number,
2006
+ onChange: T.func
2007
+ });
2105
2008
 
2106
- /***/ 31:
2107
- /***/ (function(module, exports) {
2009
+ var getPaginationParams = function getPaginationParams(_ref) {
2010
+ var requestParams = _ref.requestParams,
2011
+ meta = _ref.meta,
2012
+ onRequestParamsChange = _ref.onRequestParamsChange;
2013
+ var totalCount = meta && meta.totalCount || 0;
2014
+ var offset = requestParams && requestParams.offset || 0;
2015
+ var count = requestParams && requestParams.count;
2016
+ var totalPages = typeof count === 'number' && count > 0 ? Math.ceil(totalCount / count) : 0;
2017
+ var current = typeof count === 'number' && count > 0 ? Math.floor(offset / count) + 1 : 0;
2018
+ var isPaging = totalPages > 1 && lodash_1.isFunction(onRequestParamsChange);
2108
2019
 
2109
- module.exports = require("@splunk/themes/getSettingsFromThemedProps");
2020
+ var onChangeHandler = function onChangeHandler(e, _ref2) {
2021
+ var page = _ref2.page,
2022
+ countArg = _ref2.count;
2023
+ var newParams = lodash_1.cloneDeep(requestParams);
2110
2024
 
2111
- /***/ }),
2025
+ if (typeof countArg === 'number') {
2026
+ newParams.count = countArg;
2027
+ newParams.offset = 0;
2028
+ }
2112
2029
 
2113
- /***/ 32:
2114
- /***/ (function(module, exports) {
2030
+ var pageCount = typeof newParams.count === 'number' ? newParams.count : 10;
2115
2031
 
2116
- module.exports = require("@splunk/visualization-encoding/Options");
2032
+ if (typeof page === 'number' && page > 0) {
2033
+ newParams.count = pageCount;
2034
+ newParams.offset = (page - 1) * pageCount;
2035
+ }
2117
2036
 
2118
- /***/ }),
2037
+ onRequestParamsChange(newParams);
2038
+ };
2119
2039
 
2120
- /***/ 33:
2121
- /***/ (function(module, exports) {
2040
+ return {
2041
+ isPaging: isPaging,
2042
+ current: current,
2043
+ totalPages: totalPages,
2044
+ onChange: lodash_1.isFunction(onRequestParamsChange) ? onChangeHandler : lodash_1.noop
2045
+ };
2046
+ };
2122
2047
 
2123
- module.exports = require("@splunk/visualizations-shared/SanitizeProps");
2048
+ exports.getPaginationParams = getPaginationParams;
2124
2049
 
2125
2050
  /***/ }),
2126
2051
 
2127
- /***/ 34:
2052
+ /***/ 3:
2128
2053
  /***/ (function(module, exports) {
2129
2054
 
2130
- module.exports = require("@splunk/moment");
2055
+ module.exports = require("lodash");
2131
2056
 
2132
2057
  /***/ }),
2133
2058
 
2134
- /***/ 35:
2059
+ /***/ 30:
2135
2060
  /***/ (function(module, exports, __webpack_require__) {
2136
2061
 
2137
2062
  "use strict";
2138
2063
 
2139
2064
 
2140
- var _classCallCheck = __webpack_require__(12);
2141
-
2142
2065
  Object.defineProperty(exports, "__esModule", {
2143
2066
  value: true
2144
2067
  });
2145
- exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
2146
- /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
2147
-
2148
- var T = __webpack_require__(0);
2149
-
2150
- var lodash_1 = __webpack_require__(2);
2151
-
2152
- var VizActionHandler_1 = __webpack_require__(36); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
2153
-
2154
-
2155
- exports.INITIAL_WIDTH = 250;
2156
- exports.INITIAL_HEIGHT = 250;
2157
- /**
2158
- * A Splunk visualization
2159
- */
2160
-
2161
- var SplunkVisualization = function SplunkVisualization() {
2162
- _classCallCheck(this, SplunkVisualization);
2163
- };
2068
+ exports.VizCategory = void 0;
2069
+ var VizCategory;
2164
2070
 
2165
- SplunkVisualization.propTypes = {
2166
- /**
2167
- * display mode
2168
- */
2169
- mode: T.oneOf(['view', 'edit', 'export']).isRequired,
2071
+ (function (VizCategory) {
2072
+ VizCategory["SINGLE_VALUE"] = "Single Value";
2073
+ VizCategory["TRENDS"] = "Trends";
2074
+ VizCategory["COMPARISONS"] = "Comparisons";
2075
+ VizCategory["TABLE"] = "Table";
2076
+ VizCategory["GAUGE"] = "Gauge";
2077
+ VizCategory["DISTRIBUTIONS"] = "Distributions";
2078
+ VizCategory["CHOROPLETH"] = "Choropleth Maps";
2079
+ VizCategory["SHAPES"] = "Shapes";
2080
+ VizCategory["MISC"] = "misc";
2081
+ VizCategory["FLOW"] = "Flow";
2082
+ VizCategory["CORRELATION"] = "Correlation";
2083
+ VizCategory["SPATIAL"] = "Spatial";
2084
+ })(VizCategory = exports.VizCategory || (exports.VizCategory = {}));
2170
2085
 
2171
- /**
2172
- * width in pixel or string, defaults to 100%
2173
- */
2174
- width: T.oneOfType([T.string, T.number]).isRequired,
2086
+ /***/ }),
2175
2087
 
2176
- /**
2177
- * height in pixel or string
2178
- */
2179
- height: T.oneOfType([T.string, T.number]).isRequired,
2088
+ /***/ 31:
2089
+ /***/ (function(module, exports, __webpack_require__) {
2180
2090
 
2181
- /**
2182
- * visualization context used for dynamic option evaluation
2183
- */
2184
- context: T.object,
2091
+ "use strict";
2185
2092
 
2186
- /**
2187
- * visualization formatting options
2188
- */
2189
- options: T.object,
2190
2093
 
2191
- /**
2192
- * A callback to update formatting options
2193
- */
2194
- onOptionsChange: T.func,
2094
+ Object.defineProperty(exports, "__esModule", {
2095
+ value: true
2096
+ });
2195
2097
 
2196
- /**
2197
- * datasource state which include data and request params, object key indicate the datasource type.
2198
- */
2199
- dataSources: T.objectOf(T.shape({
2200
- /**
2201
- * current request params
2202
- */
2203
- requestParams: T.object,
2098
+ var React = __webpack_require__(1);
2204
2099
 
2205
- /**
2206
- * current dataset
2207
- */
2208
- data: T.shape({
2209
- fields: T.array,
2210
- columns: T.array
2211
- }),
2100
+ var lodash_1 = __webpack_require__(3);
2212
2101
 
2213
- /**
2214
- * error
2215
- */
2216
- error: T.shape({
2217
- level: T.string,
2218
- message: T.string
2219
- }),
2102
+ var getSettingsFromThemedProps_1 = __webpack_require__(32);
2220
2103
 
2221
- /**
2222
- * meta data that came with the dataset
2223
- */
2224
- meta: T.object
2225
- })),
2104
+ var Options_1 = __webpack_require__(33);
2226
2105
 
2227
- /**
2228
- * A callback to trigger event
2229
- */
2230
- onEventTrigger: T.func,
2106
+ var SanitizeProps_1 = __webpack_require__(34);
2231
2107
 
2232
- /**
2233
- * Inform viz if there are handlers listening to events
2234
- */
2235
- hasEventHandlers: T.bool,
2108
+ var TimezoneContext_1 = __webpack_require__(22);
2236
2109
 
2237
- /**
2238
- * A callback to communicate computed props to a consumer
2239
- */
2240
- onComputedProps: T.func,
2110
+ var moment_1 = __webpack_require__(35);
2241
2111
 
2242
- /**
2243
- * A callback to obtain visualization api
2244
- */
2245
- vizActionHandlerRef: T.func,
2246
- loading: T.bool,
2247
- theme: T.object,
2112
+ var styled_components_1 = __webpack_require__(4);
2248
2113
 
2249
- /**
2250
- * A callback to request new data with updated request params
2251
- */
2252
- onRequestParamsChange: T.func
2253
- };
2254
- /**
2255
- *
2256
- */
2114
+ var hocUtils_1 = __webpack_require__(24);
2257
2115
 
2258
- SplunkVisualization.defaultProps = {
2259
- // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
2260
- width: '100%',
2261
- height: exports.INITIAL_HEIGHT,
2262
- dataSources: {},
2263
- onEventTrigger: function onEventTrigger() {
2264
- return {};
2265
- },
2266
- mode: 'view',
2267
- hasEventHandlers: false,
2268
- options: {},
2269
- context: {},
2270
- onOptionsChange: function onOptionsChange() {
2271
- return {};
2272
- },
2273
- vizActionHandlerRef: function vizActionHandlerRef() {
2274
- return new VizActionHandler_1.DefaultVizActionHandler();
2275
- },
2276
- onComputedProps: function onComputedProps() {
2277
- return {};
2278
- },
2279
- loading: false,
2280
- onRequestParamsChange: lodash_1.noop
2281
- };
2282
- exports.default = SplunkVisualization;
2116
+ var JSONSchemaUtils_1 = __webpack_require__(25);
2283
2117
 
2284
- /***/ }),
2118
+ var SplunkVisualization_1 = __webpack_require__(36);
2285
2119
 
2286
- /***/ 36:
2287
- /***/ (function(module, exports, __webpack_require__) {
2120
+ var VizBehavior_1 = __webpack_require__(5);
2288
2121
 
2289
- "use strict";
2122
+ var getSorting_1 = __webpack_require__(28);
2290
2123
 
2124
+ var getPagination_1 = __webpack_require__(29);
2291
2125
 
2292
- var _classCallCheck = __webpack_require__(12);
2126
+ var useDeepMemo_1 = __webpack_require__(39);
2293
2127
 
2294
- var _createClass = __webpack_require__(17);
2128
+ var MissingPropsMessage_1 = __webpack_require__(40);
2295
2129
 
2296
- Object.defineProperty(exports, "__esModule", {
2297
- value: true
2298
- });
2299
- exports.DefaultVizActionHandler = void 0;
2130
+ var withEditModeCover_1 = __webpack_require__(41);
2300
2131
 
2301
- var DefaultVizActionHandler = /*#__PURE__*/function () {
2302
- function DefaultVizActionHandler() {
2303
- _classCallCheck(this, DefaultVizActionHandler);
2304
- }
2132
+ var withPlaceholder_1 = __webpack_require__(42);
2133
+ /**
2134
+ * hoc that wraps a pure react visualization in a Dashboard visualization
2135
+ * @param {DashboardVizOpts} opts
2136
+ * @returns {HOC}
2137
+ */
2305
2138
 
2306
- _createClass(DefaultVizActionHandler, [{
2307
- key: "focus",
2308
- value: function focus() {// noop
2309
- }
2310
- }, {
2311
- key: "snapshot",
2312
- value: function snapshot() {
2313
- return null; // noop
2314
- }
2315
- }]);
2316
2139
 
2317
- return DefaultVizActionHandler;
2318
- }();
2140
+ var withDashboardViz = function withDashboardViz(opts) {
2141
+ var ReactViz = opts.ReactViz,
2142
+ vizConfig = opts.vizConfig,
2143
+ _opts$computeVizProps = opts.computeVizProps,
2144
+ computeVizProps = _opts$computeVizProps === void 0 ? function () {} : _opts$computeVizProps,
2145
+ disableEditModeCover = opts.disableEditModeCover,
2146
+ useIconPlaceholder = opts.useIconPlaceholder; // sanitizing props before sending them to reactviz.
2319
2147
 
2320
- exports.DefaultVizActionHandler = DefaultVizActionHandler;
2148
+ var SanitizedReactViz = SanitizeProps_1.withSanitizedProps(ReactViz);
2149
+ var defaultOptions = JSONSchemaUtils_1.pickFieldFromJSONSchema(vizConfig.optionsSchema, 'default');
2321
2150
 
2322
- /***/ }),
2151
+ var DashboardViz = function DashboardViz(props) {
2152
+ var mode = props.mode,
2153
+ hasEventHandlers = props.hasEventHandlers,
2154
+ dataSources = props.dataSources,
2155
+ options = props.options,
2156
+ _props$context = props.context,
2157
+ context = _props$context === void 0 ? {} : _props$context,
2158
+ width = props.width,
2159
+ height = props.height,
2160
+ onComputedProps = props.onComputedProps,
2161
+ onEventTrigger = props.onEventTrigger,
2162
+ theme = props.theme,
2163
+ onRequestParamsChange = props.onRequestParamsChange;
2323
2164
 
2324
- /***/ 37:
2325
- /***/ (function(module, exports, __webpack_require__) {
2165
+ var _React$useContext = React.useContext(TimezoneContext_1.default),
2166
+ serializedTimezone = _React$useContext.serializedTimezone;
2326
2167
 
2327
- "use strict";
2168
+ if (serializedTimezone) {
2169
+ /*
2170
+ @splunk/moment currently does not allow us to customize the timezone on a per visualization basis.
2171
+ This ensures that if a timezone was provided via TimezoneContext @splunk/moment time formatting
2172
+ will use it.
2173
+ @TODO(pwied):
2174
+ - remove when we moved away from @splunk/moment
2175
+ - provide timezone context to dynamic option evaluation phase
2176
+ */
2177
+ if (!moment_1.default.getDefaultSplunkTimezone()) {
2178
+ moment_1.default.setDefaultSplunkTimezone(serializedTimezone);
2179
+ }
2180
+ }
2328
2181
 
2182
+ var themeFunc = function themeFunc(themeVar) {
2183
+ var _a, _b;
2329
2184
 
2330
- Object.defineProperty(exports, "__esModule", {
2331
- value: true
2332
- });
2333
- exports.validSortDirs = void 0;
2334
- exports.validSortDirs = ['asc', 'desc', 'none'];
2185
+ return (_b = (_a = vizConfig.themes)[themeVar]) === null || _b === void 0 ? void 0 : _b.call(_a, props);
2186
+ };
2335
2187
 
2336
- /***/ }),
2188
+ var bgColorFromTheme = themeFunc('defaultBackgroundColor');
2337
2189
 
2338
- /***/ 38:
2339
- /***/ (function(module, exports, __webpack_require__) {
2190
+ var _getSettingsFromTheme = getSettingsFromThemedProps_1.default({
2191
+ theme: theme
2192
+ }),
2193
+ currentThemeFamily = _getSettingsFromTheme.family,
2194
+ currentThemeColorScheme = _getSettingsFromTheme.colorScheme,
2195
+ currentThemeDensity = _getSettingsFromTheme.density;
2340
2196
 
2341
- "use strict";
2197
+ var evaluatedOptions = {}; // evaluatedOptions need to be initialized as an empty object
2342
2198
 
2199
+ evaluatedOptions = useDeepMemo_1.useDeepMemo(function () {
2200
+ try {
2201
+ return Options_1.Options.evaluate({
2202
+ context: lodash_1.defaultsDeep({}, context, vizConfig.defaultContext),
2203
+ options: hocUtils_1.deepMergeWithArrayPrimitiveOverrides({}, options, defaultOptions)
2204
+ }, dataSources, themeFunc);
2205
+ } catch (e) {
2206
+ // eslint-disable-next-line no-console
2207
+ console.error("unexpected error evaluating options: + ".concat(e.message));
2208
+ return {};
2209
+ }
2210
+ }, [currentThemeFamily, currentThemeColorScheme, currentThemeDensity, options, context, dataSources, serializedTimezone]); // useEffect hook needs to be initialized before any early returns
2211
+ // this is in accordance with the order of hook calls being the same on each render https://reactjs.org/docs/hooks-rules.html#explanation
2343
2212
 
2344
- Object.defineProperty(exports, "__esModule", {
2345
- value: true
2346
- });
2347
- exports.useDeepMemo = void 0;
2213
+ React.useEffect(function () {
2214
+ onComputedProps(evaluatedOptions);
2215
+ }); // present warning message if any required props are missing
2348
2216
 
2349
- var react_1 = __webpack_require__(1);
2217
+ var _vizConfig$requiredPr = vizConfig.requiredProps,
2218
+ requiredProps = _vizConfig$requiredPr === void 0 ? [] : _vizConfig$requiredPr,
2219
+ supports = vizConfig.supports;
2220
+ var missing = MissingPropsMessage_1.missingKeys(requiredProps, evaluatedOptions);
2350
2221
 
2351
- var lodash_1 = __webpack_require__(2);
2352
- /**
2353
- * This hook evaluates and stores the result of a passed function and only
2354
- * re-evaluates the function when passed dependencies change.
2355
- *
2356
- * It is different from the internal React useMemo in the following aspects:
2357
- * - it only stores the last evaluated result
2358
- * - it uses a deep equality check to determine if dependencies have changed
2359
- *
2360
- * Inspired by apollo-client's useDeepMemo
2361
- *
2362
- * @param fn the function to be executed and
2363
- * @param dependencies an array of dependencies
2364
- */
2222
+ if (missing.length > 0 && supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER)) {
2223
+ return React.createElement(MissingPropsMessage_1.default, {
2224
+ "data-test": "missing-props-message",
2225
+ width: width,
2226
+ height: height,
2227
+ missingProps: missing,
2228
+ backgroundColor: bgColorFromTheme
2229
+ });
2230
+ } // events
2365
2231
 
2366
2232
 
2367
- var useDeepMemo = function useDeepMemo(fn, dependencies) {
2368
- var ref = react_1.useRef();
2233
+ var eventCallbackProps = {};
2369
2234
 
2370
- if (!ref.current || !lodash_1.isEqual(dependencies, ref.current.dependencies)) {
2371
- ref.current = {
2372
- dependencies: dependencies,
2373
- value: fn()
2374
- };
2375
- }
2235
+ if (hasEventHandlers && mode === 'view' && vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.EVENTS) > -1) {
2236
+ var supportedEvents = vizConfig.events;
2237
+ Object.keys(supportedEvents).forEach(function (eventName) {
2238
+ var eventCallbackPropName = lodash_1.camelCase("on.".concat(eventName));
2239
+ eventCallbackProps[eventCallbackPropName] = null; // todo: refactor single value and single value icon to send payload from viz
2240
+ // then remove these lines
2376
2241
 
2377
- return ref.current.value;
2378
- };
2242
+ var payloadKeys = supportedEvents[eventName].payloadKeys;
2243
+ var payload = {};
2379
2244
 
2380
- exports.useDeepMemo = useDeepMemo;
2245
+ if (Array.isArray(payloadKeys) && payloadKeys.length) {
2246
+ payloadKeys.forEach(function (p) {
2247
+ payload[p] = evaluatedOptions[p];
2248
+ });
2249
+ }
2381
2250
 
2382
- /***/ }),
2251
+ eventCallbackProps[eventCallbackPropName] = function (ev) {
2252
+ if (ev && ev.payload) {
2253
+ payload = ev.payload;
2254
+ }
2383
2255
 
2384
- /***/ 39:
2385
- /***/ (function(module, exports, __webpack_require__) {
2256
+ return onEventTrigger({
2257
+ originalEvent: ev,
2258
+ payload: payload,
2259
+ type: eventName
2260
+ });
2261
+ };
2262
+ });
2263
+ } // compute pure viz props which are not from options
2386
2264
 
2387
- "use strict";
2388
2265
 
2266
+ var computedVizProps = computeVizProps(Object.assign(Object.assign(Object.assign(Object.assign({}, props), evaluatedOptions), eventCallbackProps), {
2267
+ themeFunc: themeFunc
2268
+ }));
2269
+ /**
2270
+ * PAGE_AND_SORT behavior
2271
+ *
2272
+ * Some visualizations, like table, requires metadata about the datasource,
2273
+ * like total number of results, current count, offset, and sort, for rendering
2274
+ * paginator and sorting direction. In this approach, the visualization
2275
+ * allow users to set 'paginateDataSourceKey' to select which datasource
2276
+ * should the visualization extract the metadata from. It defaults to 'primary' datasource.
2277
+ * The visualization config should set the PAGE_AND_SORT behavior to receive
2278
+ * 'requestParams', 'meta' and onRequestParams callback as props.
2279
+ *
2280
+ * In future, we could automatically detect which all datasources are being used
2281
+ * and bind those magically to pagination/sorting behavior.
2282
+ */
2389
2283
 
2390
- Object.defineProperty(exports, "__esModule", {
2391
- value: true
2392
- });
2393
- exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
2284
+ var dataSourceMetadata = {};
2285
+ var OptionKey = 'paginateDataSourceKey';
2286
+ var paginateDataSourceKey = lodash_1.has(evaluatedOptions, OptionKey) && evaluatedOptions[OptionKey] || 'primary';
2394
2287
 
2395
- var React = __webpack_require__(1);
2288
+ if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.PAGE_AND_SORT) > -1 && lodash_1.has(dataSources, paginateDataSourceKey)) {
2289
+ var requestParams = lodash_1.get(dataSources, [paginateDataSourceKey, 'requestParams'], {});
2290
+ var meta = lodash_1.get(dataSources, [paginateDataSourceKey, 'meta'], {});
2396
2291
 
2397
- var T = __webpack_require__(0);
2292
+ var handleRequestParamsChange = function handleRequestParamsChange(payload) {
2293
+ return onRequestParamsChange(paginateDataSourceKey, payload);
2294
+ };
2398
2295
 
2399
- var i18n_1 = __webpack_require__(3);
2296
+ var sortParams = getSorting_1.getSortingParams({
2297
+ requestParams: requestParams,
2298
+ meta: meta,
2299
+ onRequestParamsChange: handleRequestParamsChange
2300
+ });
2301
+ var paginatorParams = getPagination_1.getPaginationParams({
2302
+ requestParams: requestParams,
2303
+ meta: meta,
2304
+ onRequestParamsChange: handleRequestParamsChange
2305
+ });
2306
+ dataSourceMetadata = {
2307
+ sortParams: sortParams,
2308
+ paginatorParams: paginatorParams
2309
+ };
2310
+ }
2400
2311
 
2401
- var Message_1 = __webpack_require__(11);
2312
+ return React.createElement(SanitizedReactViz, Object.assign({
2313
+ mode: mode,
2314
+ width: width,
2315
+ height: height
2316
+ }, evaluatedOptions, computedVizProps, eventCallbackProps, dataSourceMetadata));
2317
+ };
2402
2318
 
2403
- var FixedSizeContainer_1 = __webpack_require__(14);
2404
- /**
2405
- * @method isMissing
2406
- * @param {any} v
2407
- * @returns {boolean} true if the input value === null or undefined
2408
- */
2319
+ DashboardViz.propTypes = Object.assign(Object.assign({}, SplunkVisualization_1.default.propTypes), ReactViz.propTypes);
2320
+ DashboardViz.defaultProps = Object.assign(Object.assign(Object.assign({}, SplunkVisualization_1.default.defaultProps), ReactViz.defaultProps), {
2321
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
2322
+ theme: {}
2323
+ }); // attach viz config
2409
2324
 
2325
+ DashboardViz.config = vizConfig; // @ts-ignore: TODO fix sc upgrade TS issues
2410
2326
 
2411
- var isMissing = function isMissing(v) {
2412
- return v === null || v === undefined;
2327
+ return styled_components_1.withTheme(withPlaceholder_1.default(withEditModeCover_1.default(DashboardViz, disableEditModeCover), useIconPlaceholder));
2413
2328
  };
2414
2329
 
2415
- exports.isMissing = isMissing;
2416
- /**
2417
- * @method misskingKeys
2418
- * @param {string[]} keys
2419
- * @param {object} target
2420
- * @returns {string[]} the keys of missing required props
2421
- */
2330
+ exports.default = withDashboardViz;
2422
2331
 
2423
- var missingKeys = function missingKeys(keys, target) {
2424
- return keys.filter(function (k) {
2425
- return exports.isMissing(target[k]);
2426
- });
2427
- };
2332
+ /***/ }),
2428
2333
 
2429
- exports.missingKeys = missingKeys;
2430
- var propTypes = {
2431
- width: T.oneOfType([T.string, T.number]),
2432
- height: T.oneOfType([T.string, T.number]),
2433
- // eslint-disable-next-line react/no-unused-prop-types
2434
- backgroundColor: T.string,
2435
- missingProps: T.arrayOf(T.string)
2436
- };
2437
- /**
2438
- * @method MissingPropsMessage
2439
- * @param {MissingPropsProps} props
2440
- * @returns {React.ReactElement}
2441
- */
2334
+ /***/ 32:
2335
+ /***/ (function(module, exports) {
2442
2336
 
2443
- var MissingPropsMessage = function MissingPropsMessage(props) {
2444
- var width = props.width,
2445
- height = props.height,
2446
- missingProps = props.missingProps;
2447
- return React.createElement(Message_1.default, {
2448
- "data-test": "message",
2449
- width: width,
2450
- height: height,
2451
- message: i18n_1._("Missing property: ".concat(missingProps.join(', ')))
2452
- });
2453
- };
2337
+ module.exports = require("@splunk/themes/getSettingsFromThemedProps");
2338
+
2339
+ /***/ }),
2340
+
2341
+ /***/ 33:
2342
+ /***/ (function(module, exports) {
2454
2343
 
2455
- exports.MissingPropsMessage = MissingPropsMessage;
2456
- exports.MissingPropsMessage.propTypes = propTypes;
2457
- exports.MissingPropsMessage.defaultProps = {
2458
- width: '100%',
2459
- height: 250
2460
- };
2461
- exports.default = FixedSizeContainer_1.default(exports.MissingPropsMessage);
2344
+ module.exports = require("@splunk/visualization-encoding/Options");
2462
2345
 
2463
2346
  /***/ }),
2464
2347
 
2465
- /***/ 4:
2348
+ /***/ 34:
2466
2349
  /***/ (function(module, exports) {
2467
2350
 
2468
- module.exports = require("styled-components");
2351
+ module.exports = require("@splunk/visualizations-shared/SanitizeProps");
2469
2352
 
2470
2353
  /***/ }),
2471
2354
 
2472
- /***/ 40:
2355
+ /***/ 35:
2356
+ /***/ (function(module, exports) {
2357
+
2358
+ module.exports = require("@splunk/moment");
2359
+
2360
+ /***/ }),
2361
+
2362
+ /***/ 36:
2473
2363
  /***/ (function(module, exports, __webpack_require__) {
2474
2364
 
2475
2365
  "use strict";
2476
2366
 
2477
2367
 
2368
+ var _classCallCheck = __webpack_require__(10);
2369
+
2478
2370
  Object.defineProperty(exports, "__esModule", {
2479
2371
  value: true
2480
2372
  });
2373
+ exports.INITIAL_HEIGHT = exports.INITIAL_WIDTH = void 0;
2374
+ /* eslint-disable react/no-unused-prop-types,react/prefer-stateless-function */
2481
2375
 
2482
- var React = __webpack_require__(1);
2376
+ var T = __webpack_require__(0);
2483
2377
 
2484
- var styled_components_1 = __webpack_require__(4);
2378
+ var lodash_1 = __webpack_require__(3);
2485
2379
 
2486
- var hocUtils_1 = __webpack_require__(8);
2380
+ var VizActionHandler_1 = __webpack_require__(37); // this is identical to the initial height and width we use in BaseVisualization in dashboard-visualizations
2487
2381
 
2488
- var Cover = styled_components_1.default.div.withConfig({
2489
- displayName: "withEditModeCover__Cover",
2490
- componentId: "sc-1gsbnxb-0"
2491
- })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
2492
- var Blocker = styled_components_1.default.div.attrs({
2493
- 'data-splunk-visualization-version': "25.0.1 - de10ad954"
2494
- }).withConfig({
2495
- displayName: "withEditModeCover__Blocker",
2496
- componentId: "sc-1gsbnxb-1"
2497
- })(["position:relative;width:100%;height:100%;"]);
2382
+
2383
+ exports.INITIAL_WIDTH = 250;
2384
+ exports.INITIAL_HEIGHT = 250;
2498
2385
  /**
2499
- * HOC that renders a cover layer in edit mode
2500
- * @method withEditModeCover
2501
- * @param {ExtendedDashViz} Visualization
2502
- * @returns {ExtendedDashViz} Wrapper
2386
+ * A Splunk visualization
2503
2387
  */
2504
2388
 
2505
- var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
2506
- var Wrapper = function Wrapper(props) {
2507
- var mode = props.mode;
2508
- var showEditCover = mode === 'edit' && !disableEditModeCover;
2509
- return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
2510
- "data-test": "edit-mode-cover"
2511
- }));
2512
- };
2513
-
2514
- hocUtils_1.extendStaticWrapperProps({
2515
- Wrapper: Wrapper,
2516
- Visualization: Visualization
2517
- });
2518
- return Wrapper;
2389
+ var SplunkVisualization = function SplunkVisualization() {
2390
+ _classCallCheck(this, SplunkVisualization);
2519
2391
  };
2520
2392
 
2521
- exports.default = withEditModeCover;
2522
-
2523
- /***/ }),
2393
+ SplunkVisualization.propTypes = {
2394
+ /**
2395
+ * display mode
2396
+ */
2397
+ mode: T.oneOf(['view', 'edit', 'export']).isRequired,
2524
2398
 
2525
- /***/ 41:
2526
- /***/ (function(module, exports) {
2399
+ /**
2400
+ * width in pixel or string, defaults to 100%
2401
+ */
2402
+ width: T.oneOfType([T.string, T.number]).isRequired,
2527
2403
 
2528
- module.exports = require("@splunk/visualizations-shared/mapUtils");
2404
+ /**
2405
+ * height in pixel or string
2406
+ */
2407
+ height: T.oneOfType([T.string, T.number]).isRequired,
2529
2408
 
2530
- /***/ }),
2409
+ /**
2410
+ * visualization context used for dynamic option evaluation
2411
+ */
2412
+ context: T.object,
2531
2413
 
2532
- /***/ 42:
2533
- /***/ (function(module, exports, __webpack_require__) {
2414
+ /**
2415
+ * visualization formatting options
2416
+ */
2417
+ options: T.object,
2534
2418
 
2535
- "use strict";
2419
+ /**
2420
+ * A callback to update formatting options
2421
+ */
2422
+ onOptionsChange: T.func,
2536
2423
 
2424
+ /**
2425
+ * datasource state which include data and request params, object key indicate the datasource type.
2426
+ */
2427
+ dataSources: T.objectOf(T.shape({
2428
+ /**
2429
+ * current request params
2430
+ */
2431
+ requestParams: T.object,
2537
2432
 
2538
- Object.defineProperty(exports, "__esModule", {
2539
- value: true
2540
- });
2433
+ /**
2434
+ * current dataset
2435
+ */
2436
+ data: T.shape({
2437
+ fields: T.array,
2438
+ columns: T.array
2439
+ }),
2541
2440
 
2542
- var React = __webpack_require__(1);
2441
+ /**
2442
+ * error
2443
+ */
2444
+ error: T.shape({
2445
+ level: T.string,
2446
+ message: T.string
2447
+ }),
2543
2448
 
2544
- var colorUtils_1 = __webpack_require__(13);
2449
+ /**
2450
+ * meta data that came with the dataset
2451
+ */
2452
+ meta: T.object
2453
+ })),
2545
2454
 
2546
- var variables_1 = __webpack_require__(10);
2455
+ /**
2456
+ * A callback to trigger event
2457
+ */
2458
+ onEventTrigger: T.func,
2547
2459
 
2548
- var IconPlaceholder_1 = __webpack_require__(26);
2460
+ /**
2461
+ * Inform viz if there are handlers listening to events
2462
+ */
2463
+ hasEventHandlers: T.bool,
2549
2464
 
2550
- var VizBehavior_1 = __webpack_require__(5);
2465
+ /**
2466
+ * A callback to communicate computed props to a consumer
2467
+ */
2468
+ onComputedProps: T.func,
2551
2469
 
2552
- var hocUtils_1 = __webpack_require__(8);
2470
+ /**
2471
+ * A callback to obtain visualization api
2472
+ */
2473
+ vizActionHandlerRef: T.func,
2474
+ loading: T.bool,
2475
+ theme: T.object,
2553
2476
 
2554
- var withPlaceholder = function withPlaceholder(Visualization) {
2555
- var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
2556
- var config = Visualization.config;
2557
- var themes = config.themes;
2477
+ /**
2478
+ * A callback to request new data with updated request params
2479
+ */
2480
+ onRequestParamsChange: T.func
2481
+ };
2482
+ /**
2483
+ *
2484
+ */
2558
2485
 
2559
- var Wrapper = function Wrapper(props) {
2560
- var _a, _b;
2486
+ SplunkVisualization.defaultProps = {
2487
+ // BaseVisualization in dashboard-visualizations uses 100% for width but 250 for height
2488
+ width: '100%',
2489
+ height: exports.INITIAL_HEIGHT,
2490
+ dataSources: {},
2491
+ onEventTrigger: function onEventTrigger() {
2492
+ return {};
2493
+ },
2494
+ mode: 'view',
2495
+ hasEventHandlers: false,
2496
+ options: {},
2497
+ context: {},
2498
+ onOptionsChange: function onOptionsChange() {
2499
+ return {};
2500
+ },
2501
+ vizActionHandlerRef: function vizActionHandlerRef() {
2502
+ return new VizActionHandler_1.DefaultVizActionHandler();
2503
+ },
2504
+ onComputedProps: function onComputedProps() {
2505
+ return {};
2506
+ },
2507
+ loading: false,
2508
+ onRequestParamsChange: lodash_1.noop
2509
+ };
2510
+ exports.default = SplunkVisualization;
2561
2511
 
2562
- var dataSources = props.dataSources,
2563
- loading = props.loading,
2564
- options = props.options,
2565
- height = props.height,
2566
- width = props.width;
2567
- var showPlaceholder = useIconPlaceholder(dataSources, loading, options);
2568
- var bgColorFromTheme = colorUtils_1.isColor(options === null || options === void 0 ? void 0 : options.backgroundColor) ? options === null || options === void 0 ? void 0 : options.backgroundColor : (_a = themes === null || themes === void 0 ? void 0 : themes.defaultBackgroundColor) === null || _a === void 0 ? void 0 : _a.call(themes, props);
2569
- var icon = (_b = config.placeholderIcon) !== null && _b !== void 0 ? _b : config.icon;
2570
- var iconColor = variables_1.default.contentColorActive(props);
2512
+ /***/ }),
2571
2513
 
2572
- if (config.supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && showPlaceholder) {
2573
- return React.createElement(IconPlaceholder_1.default, {
2574
- "data-test": "icon-placeholder",
2575
- icon: icon,
2576
- width: width,
2577
- height: height,
2578
- backgroundColor: bgColorFromTheme,
2579
- iconColor: iconColor
2580
- });
2581
- }
2514
+ /***/ 37:
2515
+ /***/ (function(module, exports, __webpack_require__) {
2582
2516
 
2583
- return React.createElement(Visualization, Object.assign({}, props));
2584
- };
2517
+ "use strict";
2585
2518
 
2586
- hocUtils_1.extendStaticWrapperProps({
2587
- Wrapper: Wrapper,
2588
- Visualization: Visualization
2589
- });
2590
- return Wrapper;
2591
- };
2592
2519
 
2593
- exports.default = withPlaceholder;
2520
+ var _classCallCheck = __webpack_require__(10);
2594
2521
 
2595
- /***/ }),
2522
+ var _createClass = __webpack_require__(18);
2596
2523
 
2597
- /***/ 43:
2598
- /***/ (function(module, exports) {
2524
+ Object.defineProperty(exports, "__esModule", {
2525
+ value: true
2526
+ });
2527
+ exports.DefaultVizActionHandler = void 0;
2599
2528
 
2600
- module.exports = require("@splunk/visualizations-shared/colorConstants");
2529
+ var DefaultVizActionHandler = /*#__PURE__*/function () {
2530
+ function DefaultVizActionHandler() {
2531
+ _classCallCheck(this, DefaultVizActionHandler);
2532
+ }
2601
2533
 
2602
- /***/ }),
2534
+ _createClass(DefaultVizActionHandler, [{
2535
+ key: "focus",
2536
+ value: function focus() {// noop
2537
+ }
2538
+ }, {
2539
+ key: "snapshot",
2540
+ value: function snapshot() {
2541
+ return null; // noop
2542
+ }
2543
+ }]);
2603
2544
 
2604
- /***/ 45:
2605
- /***/ (function(module, exports) {
2545
+ return DefaultVizActionHandler;
2546
+ }();
2606
2547
 
2607
- module.exports = require("@splunk/visualization-icons/placeholders");
2548
+ exports.DefaultVizActionHandler = DefaultVizActionHandler;
2608
2549
 
2609
2550
  /***/ }),
2610
2551
 
2611
- /***/ 47:
2612
- /***/ (function(module, exports) {
2552
+ /***/ 38:
2553
+ /***/ (function(module, exports, __webpack_require__) {
2613
2554
 
2614
- module.exports = require("@babel/runtime/helpers/extends");
2555
+ "use strict";
2556
+
2557
+
2558
+ Object.defineProperty(exports, "__esModule", {
2559
+ value: true
2560
+ });
2561
+ exports.validSortDirs = void 0;
2562
+ exports.validSortDirs = ['asc', 'desc', 'none'];
2615
2563
 
2616
2564
  /***/ }),
2617
2565
 
2618
- /***/ 49:
2566
+ /***/ 39:
2619
2567
  /***/ (function(module, exports, __webpack_require__) {
2620
2568
 
2621
2569
  "use strict";
@@ -2624,29 +2572,51 @@ module.exports = require("@babel/runtime/helpers/extends");
2624
2572
  Object.defineProperty(exports, "__esModule", {
2625
2573
  value: true
2626
2574
  });
2575
+ exports.useDeepMemo = void 0;
2627
2576
 
2628
- var i18n_1 = __webpack_require__(3);
2577
+ var react_1 = __webpack_require__(1);
2629
2578
 
2630
- var background = function background(_ref) {
2631
- var label = _ref.label,
2632
- themes = _ref.themes,
2633
- labelPosition = _ref.labelPosition;
2634
- return [{
2635
- label: i18n_1._(label || 'Background'),
2636
- option: 'backgroundColor',
2637
- editor: 'editor.color',
2638
- editorProps: {
2639
- labelPosition: labelPosition || 'top',
2640
- themes: themes
2641
- }
2642
- }];
2579
+ var lodash_1 = __webpack_require__(3);
2580
+ /**
2581
+ * This hook evaluates and stores the result of a passed function and only
2582
+ * re-evaluates the function when passed dependencies change.
2583
+ *
2584
+ * It is different from the internal React useMemo in the following aspects:
2585
+ * - it only stores the last evaluated result
2586
+ * - it uses a deep equality check to determine if dependencies have changed
2587
+ *
2588
+ * Inspired by apollo-client's useDeepMemo
2589
+ *
2590
+ * @param fn the function to be executed and
2591
+ * @param dependencies an array of dependencies
2592
+ */
2593
+
2594
+
2595
+ var useDeepMemo = function useDeepMemo(fn, dependencies) {
2596
+ var ref = react_1.useRef();
2597
+
2598
+ if (!ref.current || !lodash_1.isEqual(dependencies, ref.current.dependencies)) {
2599
+ ref.current = {
2600
+ dependencies: dependencies,
2601
+ value: fn()
2602
+ };
2603
+ }
2604
+
2605
+ return ref.current.value;
2643
2606
  };
2644
2607
 
2645
- exports.default = background;
2608
+ exports.useDeepMemo = useDeepMemo;
2646
2609
 
2647
2610
  /***/ }),
2648
2611
 
2649
- /***/ 5:
2612
+ /***/ 4:
2613
+ /***/ (function(module, exports) {
2614
+
2615
+ module.exports = require("styled-components");
2616
+
2617
+ /***/ }),
2618
+
2619
+ /***/ 40:
2650
2620
  /***/ (function(module, exports, __webpack_require__) {
2651
2621
 
2652
2622
  "use strict";
@@ -2655,363 +2625,304 @@ exports.default = background;
2655
2625
  Object.defineProperty(exports, "__esModule", {
2656
2626
  value: true
2657
2627
  });
2658
- exports.VizBehavior = void 0;
2659
- var VizBehavior;
2628
+ exports.MissingPropsMessage = exports.missingKeys = exports.isMissing = void 0;
2660
2629
 
2661
- (function (VizBehavior) {
2662
- /**
2663
- * Dynamic Options Behavior.
2664
- * This allows visualization options to be powered by data
2665
- *
2666
- * **Example**
2667
- *
2668
- * sparklineValues: ">primary|seriesByIndex(0)"
2669
- * would configure sparklineValues with an array of data points
2670
- * coming from the first series in the primary datasource
2671
- *
2672
- */
2673
- VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
2674
- VizBehavior["EVENTS"] = "events";
2675
- /**
2676
- * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
2677
- * missing.
2678
- * @type {string}
2679
- */
2630
+ var React = __webpack_require__(1);
2680
2631
 
2681
- VizBehavior["PLACEHOLDER"] = "placeholder";
2682
- VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
2683
- })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
2632
+ var T = __webpack_require__(0);
2684
2633
 
2685
- /***/ }),
2634
+ var i18n_1 = __webpack_require__(2);
2686
2635
 
2687
- /***/ 6:
2688
- /***/ (function(module, exports, __webpack_require__) {
2636
+ var Message_1 = __webpack_require__(9);
2689
2637
 
2690
- "use strict";
2638
+ var FixedSizeContainer_1 = __webpack_require__(12);
2639
+ /**
2640
+ * @method isMissing
2641
+ * @param {any} v
2642
+ * @returns {boolean} true if the input value === null or undefined
2643
+ */
2691
2644
 
2692
2645
 
2693
- var _toConsumableArray = __webpack_require__(9);
2646
+ var isMissing = function isMissing(v) {
2647
+ return v === null || v === undefined;
2648
+ };
2694
2649
 
2695
- var _defineProperty = __webpack_require__(7);
2650
+ exports.isMissing = isMissing;
2651
+ /**
2652
+ * @method misskingKeys
2653
+ * @param {string[]} keys
2654
+ * @param {object} target
2655
+ * @returns {string[]} the keys of missing required props
2656
+ */
2696
2657
 
2697
- var __rest = this && this.__rest || function (s, e) {
2698
- var t = {};
2658
+ var missingKeys = function missingKeys(keys, target) {
2659
+ return keys.filter(function (k) {
2660
+ return exports.isMissing(target[k]);
2661
+ });
2662
+ };
2699
2663
 
2700
- for (var p in s) {
2701
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2702
- }
2664
+ exports.missingKeys = missingKeys;
2665
+ var propTypes = {
2666
+ width: T.oneOfType([T.string, T.number]),
2667
+ height: T.oneOfType([T.string, T.number]),
2668
+ // eslint-disable-next-line react/no-unused-prop-types
2669
+ backgroundColor: T.string,
2670
+ missingProps: T.arrayOf(T.string)
2671
+ };
2672
+ /**
2673
+ * @method MissingPropsMessage
2674
+ * @param {MissingPropsProps} props
2675
+ * @returns {React.ReactElement}
2676
+ */
2703
2677
 
2704
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2705
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2706
- }
2707
- return t;
2678
+ var MissingPropsMessage = function MissingPropsMessage(props) {
2679
+ var width = props.width,
2680
+ height = props.height,
2681
+ missingProps = props.missingProps;
2682
+ return React.createElement(Message_1.default, {
2683
+ "data-test": "message",
2684
+ width: width,
2685
+ height: height,
2686
+ message: i18n_1._("Missing property: ".concat(missingProps.join(', ')))
2687
+ });
2688
+ };
2689
+
2690
+ exports.MissingPropsMessage = MissingPropsMessage;
2691
+ exports.MissingPropsMessage.propTypes = propTypes;
2692
+ exports.MissingPropsMessage.defaultProps = {
2693
+ width: '100%',
2694
+ height: 250
2708
2695
  };
2696
+ exports.default = FixedSizeContainer_1.default(exports.MissingPropsMessage);
2697
+
2698
+ /***/ }),
2699
+
2700
+ /***/ 41:
2701
+ /***/ (function(module, exports, __webpack_require__) {
2702
+
2703
+ "use strict";
2704
+
2709
2705
 
2710
2706
  Object.defineProperty(exports, "__esModule", {
2711
2707
  value: true
2712
2708
  });
2713
- exports.insertLayout = exports.uncollapseEditorConfig = exports.generatePrecisionValues = exports.getInitialPreset = exports.isDynamicOption = exports.enhanceOptionsSchemaWithDynamicOptions = exports.enhanceConfig = void 0;
2714
2709
 
2715
- var lodash_1 = __webpack_require__(2);
2710
+ var React = __webpack_require__(1);
2716
2711
 
2717
- var schemaUtils_1 = __webpack_require__(16);
2712
+ var styled_components_1 = __webpack_require__(4);
2718
2713
 
2719
- var VizBehavior_1 = __webpack_require__(5);
2714
+ var hocUtils_1 = __webpack_require__(13);
2720
2715
 
2721
- var dynamicOptionsDSLType = {
2722
- type: 'string',
2723
- pattern: schemaUtils_1.DYNAMIC_OPTIONS_DSL_PATTERN
2724
- };
2716
+ var Cover = styled_components_1.default.div.withConfig({
2717
+ displayName: "withEditModeCover__Cover",
2718
+ componentId: "sc-1gsbnxb-0"
2719
+ })(["position:absolute;left:0;right:0;top:0;bottom:0;"]);
2720
+ var Blocker = styled_components_1.default.div.attrs({
2721
+ 'data-splunk-visualization-version': "25.1.0 - 812a9a4d8"
2722
+ }).withConfig({
2723
+ displayName: "withEditModeCover__Blocker",
2724
+ componentId: "sc-1gsbnxb-1"
2725
+ })(["position:relative;width:100%;height:100%;"]);
2725
2726
  /**
2726
- * Helper function to extend an options schema with dynamic options DSL
2727
- * @param optionsSchema a visualization's options schema
2728
- * @returns an updated options schema that additionally allows strings starting with > for each option
2727
+ * HOC that renders a cover layer in edit mode
2728
+ * @method withEditModeCover
2729
+ * @param {ExtendedDashViz} Visualization
2730
+ * @returns {ExtendedDashViz} Wrapper
2729
2731
  */
2730
2732
 
2731
- function enhanceOptionsSchemaWithDynamicOptions(optionsSchema) {
2732
- var enhancedOptionsSchema = {};
2733
- Object.keys(optionsSchema).forEach(function (key) {
2734
- var _a = optionsSchema[key],
2735
- title = _a.title,
2736
- description = _a.description,
2737
- readOnly = _a.readOnly,
2738
- writeOnly = _a.writeOnly,
2739
- examples = _a.examples,
2740
- defaultValue = _a.default,
2741
- type = _a.type,
2742
- properties = _a.properties,
2743
- patternProperties = _a.patternProperties,
2744
- remainingSchemaEntry = __rest(_a, ["title", "description", "readOnly", "writeOnly", "examples", "default", "type", "properties", "patternProperties"]);
2733
+ var withEditModeCover = function withEditModeCover(Visualization, disableEditModeCover) {
2734
+ var Wrapper = function Wrapper(props) {
2735
+ var mode = props.mode;
2736
+ var showEditCover = mode === 'edit' && !disableEditModeCover;
2737
+ return React.createElement(Blocker, null, React.createElement(Visualization, Object.assign({}, props)), showEditCover && React.createElement(Cover, {
2738
+ "data-test": "edit-mode-cover"
2739
+ }));
2740
+ };
2745
2741
 
2746
- var annotations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, title !== undefined && {
2747
- title: title
2748
- }), description !== undefined && {
2749
- description: description
2750
- }), readOnly !== undefined && {
2751
- readOnly: readOnly
2752
- }), writeOnly !== undefined && {
2753
- writeOnly: writeOnly
2754
- }), examples !== undefined && {
2755
- examples: examples
2756
- }), defaultValue !== undefined && {
2757
- default: defaultValue
2758
- });
2742
+ hocUtils_1.extendStaticWrapperProps({
2743
+ Wrapper: Wrapper,
2744
+ Visualization: Visualization
2745
+ });
2746
+ return Wrapper;
2747
+ };
2759
2748
 
2760
- if (type === 'object') {
2761
- enhancedOptionsSchema[key] = Object.assign(Object.assign(Object.assign(Object.assign({}, remainingSchemaEntry), annotations), {
2762
- type: type
2763
- }), properties && {
2764
- properties: enhanceOptionsSchemaWithDynamicOptions(properties)
2765
- });
2749
+ exports.default = withEditModeCover;
2766
2750
 
2767
- if (patternProperties) {
2768
- var enhancedPatternProperties = {};
2769
- Object.keys(patternProperties).forEach(function (opt) {
2770
- enhancedPatternProperties = Object.assign(Object.assign({}, enhancedPatternProperties), enhanceOptionsSchemaWithDynamicOptions(_defineProperty({}, opt, patternProperties[opt])));
2771
- });
2772
- enhancedOptionsSchema[key].patternProperties = enhancedPatternProperties;
2773
- }
2774
- } else {
2775
- enhancedOptionsSchema[key] = Object.assign(Object.assign({}, annotations), {
2776
- anyOf: [Object.assign(Object.assign({}, type !== undefined && {
2777
- type: type
2778
- }), remainingSchemaEntry), dynamicOptionsDSLType]
2779
- });
2780
- }
2781
- });
2782
- return enhancedOptionsSchema;
2783
- }
2751
+ /***/ }),
2784
2752
 
2785
- exports.enhanceOptionsSchemaWithDynamicOptions = enhanceOptionsSchemaWithDynamicOptions;
2786
- /**
2787
- * Helper function to enhance a Visualization Config as needed based on behaviors specified in supports block
2788
- * this function also collapse all editor panels
2789
- * @param vizConfig a Visualization Config
2790
- * @returns an enhanced Visualization Config containing updated config entries based on behaviors it supports
2791
- * and containing `open: false` for all editor panels in editorConfig
2792
- */
2753
+ /***/ 42:
2754
+ /***/ (function(module, exports, __webpack_require__) {
2793
2755
 
2794
- function enhanceConfig(vizConfig) {
2795
- var enhancedConfig = vizConfig;
2756
+ "use strict";
2796
2757
 
2797
- if (vizConfig.supports.indexOf(VizBehavior_1.VizBehavior.DYNAMIC_OPTIONS) !== -1) {
2798
- enhancedConfig.optionsSchema = enhanceOptionsSchemaWithDynamicOptions(vizConfig.optionsSchema);
2799
- }
2800
2758
 
2801
- enhancedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
2802
- return Object.assign(Object.assign({}, config), {
2803
- open: false
2804
- });
2805
- });
2806
- return enhancedConfig;
2807
- }
2759
+ Object.defineProperty(exports, "__esModule", {
2760
+ value: true
2761
+ });
2808
2762
 
2809
- exports.enhanceConfig = enhanceConfig;
2810
- /**
2811
- * Helper function to uncollapse all editor panels by adding `open: true` to the editorConfig
2812
- * Created for editor unit tests
2813
- * @param vizConfig a Visualization Config
2814
- * @returns a Visualization Config containing `open: true` for all editor panels in editorConfig
2815
- */
2763
+ var React = __webpack_require__(1);
2816
2764
 
2817
- function uncollapseEditorConfig(vizConfig) {
2818
- var editorPanelUncollapsedConfig = vizConfig;
2819
- editorPanelUncollapsedConfig.editorConfig = vizConfig.editorConfig.map(function (config) {
2820
- return Object.assign(Object.assign({}, config), {
2821
- open: true
2822
- });
2823
- });
2824
- return editorPanelUncollapsedConfig;
2825
- }
2765
+ var colorUtils_1 = __webpack_require__(11);
2826
2766
 
2827
- exports.uncollapseEditorConfig = uncollapseEditorConfig;
2767
+ var variables_1 = __webpack_require__(8);
2828
2768
 
2829
- function isDynamicOption(option) {
2830
- return option && typeof option === 'string' && option.trim().startsWith('>') || false;
2831
- }
2769
+ var IconPlaceholder_1 = __webpack_require__(27);
2832
2770
 
2833
- exports.isDynamicOption = isDynamicOption; // private helpers to improve readability of getInitialPreset
2834
- // this shouldn't be tested since this util isn't something that we expect to use outside of getInitialPreset
2771
+ var VizBehavior_1 = __webpack_require__(5);
2835
2772
 
2836
- /**
2837
- * this checks to make sure that all values within vizContext are compatible with the given preset's context to determine the initialPreset
2838
- * if a preset has explicitly specified a key as being undefined, the vizContext must also has that key as undefined, or else this CANNOT be the initialPreset
2839
- * the inverse is true; if a preset has key is NOT undefined, it must also be NOT undefined in the corresponding vizContext
2840
- * the internal config contents are irrelevant (as the user could customize them in source), just as long as the presence of `undefined`s match up
2841
- *
2842
- * Since the presetConfigs have explicit undefined keys to override the existing config, we need to explicitly check the undefined values
2843
- */
2773
+ var hocUtils_1 = __webpack_require__(13);
2844
2774
 
2845
- function hasCompatibleContexts(vizContext, presetContext) {
2846
- var presetContextKeys = Object.keys(presetContext);
2847
- return presetContextKeys.every(function (contextKey) {
2848
- return presetContext[contextKey] === undefined && vizContext[contextKey] === undefined || presetContext[contextKey] !== undefined && vizContext[contextKey] !== undefined;
2849
- });
2850
- }
2851
- /**
2852
- * Checks to make sure that dynamic (non-dynamic) options in a given preset are also dynamic (non-dynamic) in the vizOptions
2853
- */
2775
+ var withPlaceholder = function withPlaceholder(Visualization) {
2776
+ var useIconPlaceholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IconPlaceholder_1.shouldShowIconPlaceholder;
2777
+ var config = Visualization.config;
2778
+ var themes = config.themes;
2854
2779
 
2780
+ var Wrapper = function Wrapper(props) {
2781
+ var _a, _b;
2855
2782
 
2856
- function hasCompatibleOptions(vizOptions, presetOptions) {
2857
- var presetOptionKeys = Object.keys(presetOptions);
2858
- return presetOptionKeys.every(function (optionKey) {
2859
- return isDynamicOption(presetOptions[optionKey]) === isDynamicOption(vizOptions[optionKey]);
2860
- });
2861
- }
2862
- /**
2863
- * Evaluates whether there is an initialPreset that fits the current state of vizContext + vizOptions
2864
- * This function ignores extraneous vizOptions or vizContext keys, as they could be outside the scope of what the preset is intended to configure
2865
- *
2866
- * @param {Object} vizContext - the current vizContext definition
2867
- * @param {Object} vizOptions - the current vizOptions definition
2868
- * @param {PresetEntry[]} presets - the list of presets, one of which can be considered an initialPreset
2869
- */
2783
+ var dataSources = props.dataSources,
2784
+ loading = props.loading,
2785
+ options = props.options,
2786
+ height = props.height,
2787
+ width = props.width;
2788
+ var showPlaceholder = useIconPlaceholder(dataSources, loading, options);
2789
+ var bgColorFromTheme = colorUtils_1.isColor(options === null || options === void 0 ? void 0 : options.backgroundColor) ? options === null || options === void 0 ? void 0 : options.backgroundColor : (_a = themes === null || themes === void 0 ? void 0 : themes.defaultBackgroundColor) === null || _a === void 0 ? void 0 : _a.call(themes, props);
2790
+ var icon = (_b = config.placeholderIcon) !== null && _b !== void 0 ? _b : config.icon;
2791
+ var iconColor = variables_1.default.contentColorActive(props);
2870
2792
 
2793
+ if (config.supports.includes(VizBehavior_1.VizBehavior.PLACEHOLDER) && showPlaceholder) {
2794
+ return React.createElement(IconPlaceholder_1.default, {
2795
+ "data-test": "icon-placeholder",
2796
+ icon: icon,
2797
+ width: width,
2798
+ height: height,
2799
+ backgroundColor: bgColorFromTheme,
2800
+ iconColor: iconColor
2801
+ });
2802
+ }
2871
2803
 
2872
- function getInitialPreset(vizContext, vizOptions, presets) {
2873
- return presets.find(function (preset) {
2874
- var presetContext = lodash_1.get(preset, ['value', 'context'], {});
2875
- var presetOptions = lodash_1.get(preset, ['value', 'options'], {});
2876
- var presetContextKeys = Object.keys(presetContext);
2877
- var presetOptionKeys = Object.keys(presetOptions); // all presets have to explicitly specify which options to reset (i.e. need explicitly undefined keys)
2878
- // if not, then the preset is invalid in config.ts
2804
+ return React.createElement(Visualization, Object.assign({}, props));
2805
+ };
2879
2806
 
2880
- if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
2881
- return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
2807
+ hocUtils_1.extendStaticWrapperProps({
2808
+ Wrapper: Wrapper,
2809
+ Visualization: Visualization
2882
2810
  });
2883
- }
2811
+ return Wrapper;
2812
+ };
2884
2813
 
2885
- exports.getInitialPreset = getInitialPreset;
2886
- /**
2887
- * generates number precision values for a Select editor
2888
- *
2889
- * @param {Number} numPrecisionValues - number of integer precision values to generate
2890
- * @returns {{ label: string; value; string }[]} array of { label, value } tuples
2891
- */
2814
+ exports.default = withPlaceholder;
2892
2815
 
2893
- function generatePrecisionValues(numPrecisionValues) {
2894
- return lodash_1.range(0, numPrecisionValues + 1).map(function (i) {
2895
- return {
2896
- label: "".concat(i, " (0").concat(i > 0 ? '.' : '').concat('0'.repeat(i), ")"),
2897
- value: i
2898
- };
2899
- });
2900
- }
2816
+ /***/ }),
2901
2817
 
2902
- exports.generatePrecisionValues = generatePrecisionValues;
2903
- /**
2904
- * insert layout in layout array, return a new layout array instead of updating the original
2905
- *
2906
- * @param {EditorLayoutConfig[][]} layout - editor layout
2907
- * @param {Number} index - the index to insert layout item(s)
2908
- * @param {EditorLayoutConfig[][]} layoutItems - the item(s) to insert
2909
- * @returns {EditorLayoutConfig[][]} new editor layout with insertion
2910
- */
2818
+ /***/ 43:
2819
+ /***/ (function(module, exports) {
2911
2820
 
2912
- var insertLayout = function insertLayout(layout, index) {
2913
- for (var _len = arguments.length, layoutItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2914
- layoutItems[_key - 2] = arguments[_key];
2915
- }
2821
+ module.exports = require("@splunk/visualizations-shared/colorConstants");
2916
2822
 
2917
- return [].concat(_toConsumableArray(layout.slice(0, index)), layoutItems, _toConsumableArray(layout.slice(index)));
2918
- };
2823
+ /***/ }),
2919
2824
 
2920
- exports.insertLayout = insertLayout;
2825
+ /***/ 45:
2826
+ /***/ (function(module, exports) {
2827
+
2828
+ module.exports = require("@splunk/visualization-icons/placeholders");
2921
2829
 
2922
2830
  /***/ }),
2923
2831
 
2924
- /***/ 7:
2832
+ /***/ 47:
2925
2833
  /***/ (function(module, exports) {
2926
2834
 
2927
- module.exports = require("@babel/runtime/helpers/defineProperty");
2835
+ module.exports = require("@babel/runtime/helpers/extends");
2928
2836
 
2929
2837
  /***/ }),
2930
2838
 
2931
- /***/ 8:
2839
+ /***/ 49:
2932
2840
  /***/ (function(module, exports, __webpack_require__) {
2933
2841
 
2934
2842
  "use strict";
2935
2843
 
2936
2844
 
2937
- var _typeof = __webpack_require__(25);
2845
+ Object.defineProperty(exports, "__esModule", {
2846
+ value: true
2847
+ });
2848
+
2849
+ var i18n_1 = __webpack_require__(2);
2850
+
2851
+ var background = function background(_ref) {
2852
+ var label = _ref.label,
2853
+ themes = _ref.themes,
2854
+ labelPosition = _ref.labelPosition;
2855
+ return [{
2856
+ label: i18n_1._(label || 'Background'),
2857
+ option: 'backgroundColor',
2858
+ editor: 'editor.color',
2859
+ editorProps: {
2860
+ labelPosition: labelPosition || 'top',
2861
+ themes: themes
2862
+ }
2863
+ }];
2864
+ };
2865
+
2866
+ exports.default = background;
2867
+
2868
+ /***/ }),
2869
+
2870
+ /***/ 5:
2871
+ /***/ (function(module, exports, __webpack_require__) {
2872
+
2873
+ "use strict";
2874
+
2938
2875
 
2939
2876
  Object.defineProperty(exports, "__esModule", {
2940
2877
  value: true
2941
2878
  });
2942
- exports.deepMergeWithArrayPrimitiveOverrides = exports.extendStaticWrapperProps = void 0;
2879
+ exports.VizBehavior = void 0;
2880
+ var VizBehavior;
2881
+
2882
+ (function (VizBehavior) {
2883
+ /**
2884
+ * Dynamic Options Behavior.
2885
+ * This allows visualization options to be powered by data
2886
+ *
2887
+ * **Example**
2888
+ *
2889
+ * sparklineValues: ">primary|seriesByIndex(0)"
2890
+ * would configure sparklineValues with an array of data points
2891
+ * coming from the first series in the primary datasource
2892
+ *
2893
+ */
2894
+ VizBehavior["DYNAMIC_OPTIONS"] = "dynamic-options";
2895
+ VizBehavior["EVENTS"] = "events";
2896
+ /**
2897
+ * Placeholder behavior: visualization will display a placeholder rather than fail if any of the `requiredProps` is
2898
+ * missing.
2899
+ * @type {string}
2900
+ */
2943
2901
 
2944
- var lodash_1 = __webpack_require__(2);
2902
+ VizBehavior["PLACEHOLDER"] = "placeholder";
2903
+ VizBehavior["PAGE_AND_SORT"] = "page-and-sort";
2904
+ })(VizBehavior = exports.VizBehavior || (exports.VizBehavior = {}));
2945
2905
 
2946
- var mapUtils_1 = __webpack_require__(41);
2947
- /**
2948
- * @method extendStaticWrapperProps
2949
- * @param {Object} props
2950
- * @param {DashboardVizType} props.Wrapper
2951
- * @param {DashboardVizType} props.Visualization
2952
- */
2906
+ /***/ }),
2953
2907
 
2908
+ /***/ 6:
2909
+ /***/ (function(module, exports) {
2954
2910
 
2955
- var extendStaticWrapperProps = function extendStaticWrapperProps(_ref) {
2956
- var Wrapper = _ref.Wrapper,
2957
- Visualization = _ref.Visualization;
2958
- var extendProperties = ['propTypes', 'defaultProps', 'config'];
2959
- extendProperties.forEach(function (prop) {
2960
- if (Visualization[prop]) {
2961
- // eslint-disable-next-line no-param-reassign
2962
- Wrapper[prop] = Visualization[prop];
2963
- }
2964
- });
2965
- };
2911
+ module.exports = require("@babel/runtime/helpers/defineProperty");
2966
2912
 
2967
- exports.extendStaticWrapperProps = extendStaticWrapperProps;
2968
- /**
2969
- * helper to deeply merge objects while preserving arrays in earlier source objects
2970
- * deeply nested primitive keys are merged similarly to lodash's defaultsDeep, while keys with arrays of primitives will be preserved if already present in the resultant merged object
2971
- * this prevents default arrays of primitives from appending values to user-defined arrays (this occurs if the default array is longer than the user-defined one).
2972
- * Array of objects gets merged with the defaults, where the defaults can be an array of objects. Closest matching default object from the defaults list based on key - value pair
2973
- * will be used for merging defaults for each object in the array. If no closest match found, first object in default array list used for merging.
2974
- *
2975
- * @method deepMergeWithArrayPrimitiveOverrides
2976
- * @param {Object} initial - target object to merge values into
2977
- * @param {Object[]} sources - other default options to be merged into the resultant object if no explicit value is provided, with earlier args taking precedence over later ones
2978
- *
2979
- * @returns {Object}
2980
- */
2913
+ /***/ }),
2981
2914
 
2982
- var deepMergeWithArrayPrimitiveOverrides = function deepMergeWithArrayPrimitiveOverrides(initial) {
2983
- var clone = lodash_1.cloneDeep(initial);
2915
+ /***/ 7:
2916
+ /***/ (function(module, exports) {
2984
2917
 
2985
- for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2986
- sources[_key - 1] = arguments[_key];
2987
- }
2918
+ module.exports = require("@babel/runtime/helpers/toConsumableArray");
2988
2919
 
2989
- sources.forEach(function (sourceToApply) {
2990
- Object.keys(sourceToApply).forEach(function (sourceKey) {
2991
- if (!Object.prototype.hasOwnProperty.call(clone, sourceKey)) {
2992
- clone[sourceKey] = lodash_1.cloneDeep(sourceToApply[sourceKey]);
2993
- }
2920
+ /***/ }),
2994
2921
 
2995
- if (clone[sourceKey] && _typeof(clone[sourceKey]) === 'object' && !Array.isArray(clone[sourceKey]) && _typeof(sourceToApply[sourceKey]) === 'object') {
2996
- clone[sourceKey] = exports.deepMergeWithArrayPrimitiveOverrides(clone[sourceKey], sourceToApply[sourceKey]);
2997
- } else if (Array.isArray(clone[sourceKey]) && _typeof(clone[sourceKey][0]) === 'object' && !Array.isArray(clone[sourceKey][0])) {
2998
- // If option is an array of objects
2999
- for (var i = 0; i < clone[sourceKey].length; i += 1) {
3000
- if (_typeof(clone[sourceKey][i]) === 'object') {
3001
- var closestMatchIdx = mapUtils_1.findClosestMatchFromDefaultList(sourceToApply[sourceKey], clone[sourceKey][i]);
3002
-
3003
- if (closestMatchIdx > -1) {
3004
- clone[sourceKey][i] = exports.deepMergeWithArrayPrimitiveOverrides(clone[sourceKey][i], sourceToApply[sourceKey][closestMatchIdx]);
3005
- }
3006
- }
3007
- }
3008
- }
3009
- });
3010
- });
3011
- return clone;
3012
- };
2922
+ /***/ 8:
2923
+ /***/ (function(module, exports) {
3013
2924
 
3014
- exports.deepMergeWithArrayPrimitiveOverrides = deepMergeWithArrayPrimitiveOverrides;
2925
+ module.exports = require("@splunk/themes/variables");
3015
2926
 
3016
2927
  /***/ }),
3017
2928
 
@@ -3021,18 +2932,18 @@ exports.deepMergeWithArrayPrimitiveOverrides = deepMergeWithArrayPrimitiveOverri
3021
2932
  "use strict";
3022
2933
 
3023
2934
 
3024
- var _toConsumableArray = __webpack_require__(9);
2935
+ var _toConsumableArray = __webpack_require__(7);
3025
2936
 
3026
2937
  Object.defineProperty(exports, "__esModule", {
3027
2938
  value: true
3028
2939
  });
3029
2940
  exports.convertToGaugeProperties = exports.mapValueLabelDisplay = exports.mapToOldKey = exports.getGradientDimensions = exports.getGradientStops = exports.getGradientStopColors = exports.getGradientStopOffsets = exports.getGaugeRange = exports.validateRanges = exports.getSortedRanges = exports.getMarkerGaugeValueMarkerPositions = exports.getMarkerBarDimensions = exports.getFillerGaugeValueMarkerPositions = exports.getFillBarDimensions = exports.getGaugeBarHeight = exports.getGaugeBarWidth = exports.getGaugeBarStartPositions = exports.getGaugeBarLength = exports.assignGaugeColor = exports.getGaugeDimensions = exports.getGaugeStartPosition = exports.getGaugeLength = exports.getGaugeHeight = exports.getGaugeWidth = exports.FILL_THICKNESS = exports.GAUGE_THICKNESS = void 0;
3030
2941
 
3031
- var lodash_1 = __webpack_require__(2);
2942
+ var lodash_1 = __webpack_require__(3);
3032
2943
 
3033
2944
  var colorConstants_1 = __webpack_require__(43);
3034
2945
 
3035
- var i18n_1 = __webpack_require__(3);
2946
+ var i18n_1 = __webpack_require__(2);
3036
2947
 
3037
2948
  exports.GAUGE_THICKNESS = 50;
3038
2949
  exports.FILL_THICKNESS = 38;
@@ -3787,7 +3698,7 @@ exports.convertToGaugeProperties = convertToGaugeProperties;
3787
3698
  /***/ 9:
3788
3699
  /***/ (function(module, exports) {
3789
3700
 
3790
- module.exports = require("@babel/runtime/helpers/toConsumableArray");
3701
+ module.exports = require("@splunk/visualizations-shared/Message");
3791
3702
 
3792
3703
  /***/ })
3793
3704