@splunk/visualizations 27.0.0 → 27.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 (79) hide show
  1. package/Area.config.js +269 -122
  2. package/Area.config.js.map +4 -4
  3. package/Area.js +1065 -209
  4. package/Area.js.map +4 -4
  5. package/Bar.config.js +266 -82
  6. package/Bar.config.js.map +4 -4
  7. package/Bar.js +1065 -171
  8. package/Bar.js.map +4 -4
  9. package/Bubble.config.js +127 -1
  10. package/Bubble.config.js.map +4 -4
  11. package/Bubble.js +323 -80
  12. package/Bubble.js.map +4 -4
  13. package/ChoroplethSvg.js +60 -30
  14. package/ChoroplethSvg.js.map +4 -4
  15. package/Column.config.js +271 -82
  16. package/Column.config.js.map +4 -4
  17. package/Column.js +1070 -171
  18. package/Column.js.map +4 -4
  19. package/Ellipse.js +44 -14
  20. package/Ellipse.js.map +4 -4
  21. package/Events.js +82 -52
  22. package/Events.js.map +4 -4
  23. package/FillerGauge.js +44 -14
  24. package/FillerGauge.js.map +4 -4
  25. package/Image.js +42 -12
  26. package/Image.js.map +4 -4
  27. package/Line.config.js +271 -119
  28. package/Line.config.js.map +4 -4
  29. package/Line.js +1067 -206
  30. package/Line.js.map +4 -4
  31. package/LinkGraph.js +563 -529
  32. package/LinkGraph.js.map +4 -4
  33. package/Map.js +44 -14
  34. package/Map.js.map +4 -4
  35. package/Markdown.js +46 -16
  36. package/Markdown.js.map +4 -4
  37. package/MarkerGauge.js +42 -12
  38. package/MarkerGauge.js.map +4 -4
  39. package/ParallelCoordinates.js +122 -86
  40. package/ParallelCoordinates.js.map +4 -4
  41. package/Pie.js +198 -81
  42. package/Pie.js.map +4 -4
  43. package/Punchcard.js +54 -24
  44. package/Punchcard.js.map +4 -4
  45. package/Rectangle.js +56 -26
  46. package/Rectangle.js.map +4 -4
  47. package/Sankey.js +68 -38
  48. package/Sankey.js.map +4 -4
  49. package/Scatter.config.js +127 -1
  50. package/Scatter.config.js.map +4 -4
  51. package/Scatter.js +323 -80
  52. package/Scatter.js.map +4 -4
  53. package/SingleValue.config.js +43 -67
  54. package/SingleValue.config.js.map +4 -4
  55. package/SingleValue.js +1419 -1351
  56. package/SingleValue.js.map +4 -4
  57. package/SingleValueBasic.js.map +1 -1
  58. package/SingleValueIcon.config.js +45 -69
  59. package/SingleValueIcon.config.js.map +4 -4
  60. package/SingleValueIcon.js +1307 -1238
  61. package/SingleValueIcon.js.map +4 -4
  62. package/SingleValueRadial.config.js +43 -67
  63. package/SingleValueRadial.config.js.map +4 -4
  64. package/SingleValueRadial.js +1352 -1266
  65. package/SingleValueRadial.js.map +4 -4
  66. package/TRELLIS.md +16 -15
  67. package/Table.js +52 -22
  68. package/Table.js.map +4 -4
  69. package/common/Charting.js +133 -27
  70. package/common/Charting.js.map +4 -4
  71. package/common/OptionsDoc.js +6 -1
  72. package/common/OptionsDoc.js.map +2 -2
  73. package/common/utils/singleValueUtils.js +8 -7
  74. package/common/utils/singleValueUtils.js.map +2 -2
  75. package/common/utils/trellisUtils.js +41 -1
  76. package/common/utils/trellisUtils.js.map +2 -2
  77. package/common/withDashboardViz.js +42 -12
  78. package/common/withDashboardViz.js.map +4 -4
  79. package/package.json +17 -18
@@ -133,59 +133,41 @@ var defaultImport7 = __toESM(require("lodash/isEmpty"));
133
133
  __reExport(isEmpty_exports, require("lodash/isEmpty"));
134
134
  var isEmpty_default = "default" in defaultImport7 ? defaultImport7.default : defaultImport7;
135
135
 
136
- // esm-externals:@splunk/visualization-context/FeatureFlagContext
137
- var FeatureFlagContext_exports = {};
138
- __export(FeatureFlagContext_exports, {
139
- default: () => FeatureFlagContext_default
140
- });
141
- var defaultImport8 = __toESM(require("@splunk/visualization-context/FeatureFlagContext"));
142
- __reExport(FeatureFlagContext_exports, require("@splunk/visualization-context/FeatureFlagContext"));
143
- var FeatureFlagContext_default = "default" in defaultImport8 ? defaultImport8.default : defaultImport8;
144
-
145
- // esm-externals:@splunk/visualization-schemas
146
- var visualization_schemas_exports = {};
147
- __export(visualization_schemas_exports, {
148
- default: () => visualization_schemas_default
149
- });
150
- var defaultImport9 = __toESM(require("@splunk/visualization-schemas"));
151
- __reExport(visualization_schemas_exports, require("@splunk/visualization-schemas"));
152
- var visualization_schemas_default = "default" in defaultImport9 ? defaultImport9.default : defaultImport9;
153
-
154
136
  // esm-externals:@splunk/visualizations-shared/style
155
137
  var style_exports = {};
156
138
  __export(style_exports, {
157
139
  default: () => style_default
158
140
  });
159
- var defaultImport10 = __toESM(require("@splunk/visualizations-shared/style"));
141
+ var defaultImport8 = __toESM(require("@splunk/visualizations-shared/style"));
160
142
  __reExport(style_exports, require("@splunk/visualizations-shared/style"));
161
- var style_default = "default" in defaultImport10 ? defaultImport10.default : defaultImport10;
143
+ var style_default = "default" in defaultImport8 ? defaultImport8.default : defaultImport8;
162
144
 
163
145
  // esm-externals:@splunk/ui-utils/i18n
164
146
  var i18n_exports = {};
165
147
  __export(i18n_exports, {
166
148
  default: () => i18n_default
167
149
  });
168
- var defaultImport11 = __toESM(require("@splunk/ui-utils/i18n"));
150
+ var defaultImport9 = __toESM(require("@splunk/ui-utils/i18n"));
169
151
  __reExport(i18n_exports, require("@splunk/ui-utils/i18n"));
170
- var i18n_default = "default" in defaultImport11 ? defaultImport11.default : defaultImport11;
152
+ var i18n_default = "default" in defaultImport9 ? defaultImport9.default : defaultImport9;
171
153
 
172
154
  // esm-externals:@splunk/visualizations-shared/SizeAwareWrapper
173
155
  var SizeAwareWrapper_exports = {};
174
156
  __export(SizeAwareWrapper_exports, {
175
157
  default: () => SizeAwareWrapper_default
176
158
  });
177
- var defaultImport12 = __toESM(require("@splunk/visualizations-shared/SizeAwareWrapper"));
159
+ var defaultImport10 = __toESM(require("@splunk/visualizations-shared/SizeAwareWrapper"));
178
160
  __reExport(SizeAwareWrapper_exports, require("@splunk/visualizations-shared/SizeAwareWrapper"));
179
- var SizeAwareWrapper_default = "default" in defaultImport12 ? defaultImport12.default : defaultImport12;
161
+ var SizeAwareWrapper_default = "default" in defaultImport10 ? defaultImport10.default : defaultImport10;
180
162
 
181
163
  // esm-externals:@splunk/visualizations-shared/Message
182
164
  var Message_exports = {};
183
165
  __export(Message_exports, {
184
166
  default: () => Message_default
185
167
  });
186
- var defaultImport13 = __toESM(require("@splunk/visualizations-shared/Message"));
168
+ var defaultImport11 = __toESM(require("@splunk/visualizations-shared/Message"));
187
169
  __reExport(Message_exports, require("@splunk/visualizations-shared/Message"));
188
- var Message_default = "default" in defaultImport13 ? defaultImport13.default : defaultImport13;
170
+ var Message_default = "default" in defaultImport11 ? defaultImport11.default : defaultImport11;
189
171
 
190
172
  // src/common/components/VizStyleWrapper.jsx
191
173
  var VizStyleWrapper = styled_components_default.div.attrs(({ dataTestKey }) => ({
@@ -239,99 +221,99 @@ var SingleValueBasic_exports = {};
239
221
  __export(SingleValueBasic_exports, {
240
222
  default: () => SingleValueBasic_default
241
223
  });
242
- var defaultImport14 = __toESM(require("@splunk/visualizations/SingleValueBasic"));
224
+ var defaultImport12 = __toESM(require("@splunk/visualizations/SingleValueBasic"));
243
225
  __reExport(SingleValueBasic_exports, require("@splunk/visualizations/SingleValueBasic"));
244
- var SingleValueBasic_default = "default" in defaultImport14 ? defaultImport14.default : defaultImport14;
226
+ var SingleValueBasic_default = "default" in defaultImport12 ? defaultImport12.default : defaultImport12;
245
227
 
246
228
  // esm-externals:@splunk/react-icons/enterprise/Activity
247
229
  var Activity_exports = {};
248
230
  __export(Activity_exports, {
249
231
  default: () => Activity_default
250
232
  });
251
- var defaultImport15 = __toESM(require("@splunk/react-icons/enterprise/Activity"));
233
+ var defaultImport13 = __toESM(require("@splunk/react-icons/enterprise/Activity"));
252
234
  __reExport(Activity_exports, require("@splunk/react-icons/enterprise/Activity"));
253
- var Activity_default = "default" in defaultImport15 ? defaultImport15.default : defaultImport15;
235
+ var Activity_default = "default" in defaultImport13 ? defaultImport13.default : defaultImport13;
254
236
 
255
237
  // esm-externals:@splunk/react-icons/enterprise/Clock
256
238
  var Clock_exports = {};
257
239
  __export(Clock_exports, {
258
240
  default: () => Clock_default
259
241
  });
260
- var defaultImport16 = __toESM(require("@splunk/react-icons/enterprise/Clock"));
242
+ var defaultImport14 = __toESM(require("@splunk/react-icons/enterprise/Clock"));
261
243
  __reExport(Clock_exports, require("@splunk/react-icons/enterprise/Clock"));
262
- var Clock_default = "default" in defaultImport16 ? defaultImport16.default : defaultImport16;
244
+ var Clock_default = "default" in defaultImport14 ? defaultImport14.default : defaultImport14;
263
245
 
264
246
  // esm-externals:@splunk/react-icons/enterprise/Pencil
265
247
  var Pencil_exports = {};
266
248
  __export(Pencil_exports, {
267
249
  default: () => Pencil_default
268
250
  });
269
- var defaultImport17 = __toESM(require("@splunk/react-icons/enterprise/Pencil"));
251
+ var defaultImport15 = __toESM(require("@splunk/react-icons/enterprise/Pencil"));
270
252
  __reExport(Pencil_exports, require("@splunk/react-icons/enterprise/Pencil"));
271
- var Pencil_default = "default" in defaultImport17 ? defaultImport17.default : defaultImport17;
253
+ var Pencil_default = "default" in defaultImport15 ? defaultImport15.default : defaultImport15;
272
254
 
273
255
  // esm-externals:@splunk/react-icons/enterprise/Star
274
256
  var Star_exports = {};
275
257
  __export(Star_exports, {
276
258
  default: () => Star_default
277
259
  });
278
- var defaultImport18 = __toESM(require("@splunk/react-icons/enterprise/Star"));
260
+ var defaultImport16 = __toESM(require("@splunk/react-icons/enterprise/Star"));
279
261
  __reExport(Star_exports, require("@splunk/react-icons/enterprise/Star"));
280
- var Star_default = "default" in defaultImport18 ? defaultImport18.default : defaultImport18;
262
+ var Star_default = "default" in defaultImport16 ? defaultImport16.default : defaultImport16;
281
263
 
282
264
  // esm-externals:@splunk/react-icons/enterprise/Question
283
265
  var Question_exports = {};
284
266
  __export(Question_exports, {
285
267
  default: () => Question_default
286
268
  });
287
- var defaultImport19 = __toESM(require("@splunk/react-icons/enterprise/Question"));
269
+ var defaultImport17 = __toESM(require("@splunk/react-icons/enterprise/Question"));
288
270
  __reExport(Question_exports, require("@splunk/react-icons/enterprise/Question"));
289
- var Question_default = "default" in defaultImport19 ? defaultImport19.default : defaultImport19;
271
+ var Question_default = "default" in defaultImport17 ? defaultImport17.default : defaultImport17;
290
272
 
291
273
  // esm-externals:lodash
292
274
  var lodash_exports = {};
293
275
  __export(lodash_exports, {
294
276
  default: () => lodash_default
295
277
  });
296
- var defaultImport20 = __toESM(require("lodash"));
278
+ var defaultImport18 = __toESM(require("lodash"));
297
279
  __reExport(lodash_exports, require("lodash"));
298
- var lodash_default = "default" in defaultImport20 ? defaultImport20.default : defaultImport20;
280
+ var lodash_default = "default" in defaultImport18 ? defaultImport18.default : defaultImport18;
299
281
 
300
282
  // esm-externals:@splunk/visualizations-shared/numberUtils
301
283
  var numberUtils_exports = {};
302
284
  __export(numberUtils_exports, {
303
285
  default: () => numberUtils_default
304
286
  });
305
- var defaultImport21 = __toESM(require("@splunk/visualizations-shared/numberUtils"));
287
+ var defaultImport19 = __toESM(require("@splunk/visualizations-shared/numberUtils"));
306
288
  __reExport(numberUtils_exports, require("@splunk/visualizations-shared/numberUtils"));
307
- var numberUtils_default = "default" in defaultImport21 ? defaultImport21.default : defaultImport21;
289
+ var numberUtils_default = "default" in defaultImport19 ? defaultImport19.default : defaultImport19;
308
290
 
309
291
  // esm-externals:@splunk/visualizations-shared/domUtils
310
292
  var domUtils_exports = {};
311
293
  __export(domUtils_exports, {
312
294
  default: () => domUtils_default
313
295
  });
314
- var defaultImport22 = __toESM(require("@splunk/visualizations-shared/domUtils"));
296
+ var defaultImport20 = __toESM(require("@splunk/visualizations-shared/domUtils"));
315
297
  __reExport(domUtils_exports, require("@splunk/visualizations-shared/domUtils"));
316
- var domUtils_default = "default" in defaultImport22 ? defaultImport22.default : defaultImport22;
298
+ var domUtils_default = "default" in defaultImport20 ? defaultImport20.default : defaultImport20;
317
299
 
318
300
  // esm-externals:@splunk/visualizations-shared/propUtils
319
301
  var propUtils_exports = {};
320
302
  __export(propUtils_exports, {
321
303
  default: () => propUtils_default
322
304
  });
323
- var defaultImport23 = __toESM(require("@splunk/visualizations-shared/propUtils"));
305
+ var defaultImport21 = __toESM(require("@splunk/visualizations-shared/propUtils"));
324
306
  __reExport(propUtils_exports, require("@splunk/visualizations-shared/propUtils"));
325
- var propUtils_default = "default" in defaultImport23 ? defaultImport23.default : defaultImport23;
307
+ var propUtils_default = "default" in defaultImport21 ? defaultImport21.default : defaultImport21;
326
308
 
327
309
  // esm-externals:@splunk/visualizations-shared/colorConstants
328
310
  var colorConstants_exports = {};
329
311
  __export(colorConstants_exports, {
330
312
  default: () => colorConstants_default
331
313
  });
332
- var defaultImport24 = __toESM(require("@splunk/visualizations-shared/colorConstants"));
314
+ var defaultImport22 = __toESM(require("@splunk/visualizations-shared/colorConstants"));
333
315
  __reExport(colorConstants_exports, require("@splunk/visualizations-shared/colorConstants"));
334
- var colorConstants_default = "default" in defaultImport24 ? defaultImport24.default : defaultImport24;
316
+ var colorConstants_default = "default" in defaultImport22 ? defaultImport22.default : defaultImport22;
335
317
 
336
318
  // src/common/utils/singleValueUtils.js
337
319
  var DEFAULT_FONT = 12;
@@ -667,16 +649,16 @@ var computeSingleValueContent = ({
667
649
  smallVizProps
668
650
  };
669
651
  };
670
- var handleValueClickCallback = (ev, majorValue, majorValueField, trendValue, onValueClick, trellisEnabled = false, trellisSplityBy = "", trellisKey = "") => {
671
- let payload = {
652
+ var handleValueClickCallback = (ev, majorValue, majorValueField, trendValue, onValueClick, trellisEnabled = false, trellisSplitBy = "", trellisKey = "") => onValueClick(__spreadProps(__spreadValues({}, ev), {
653
+ payload: __spreadValues({
672
654
  trendValue,
673
655
  value: majorValue,
674
656
  name: majorValueField
675
- };
676
- if (trellisEnabled) {
677
- payload = __spreadProps(__spreadValues({}, payload), { "trellis.name": trellisSplityBy, "trellis.value": trellisKey });
678
- }
679
- return onValueClick(__spreadProps(__spreadValues({}, ev), { payload }));
657
+ }, trellisEnabled && { "trellis.name": trellisSplitBy, "trellis.value": trellisKey })
658
+ }));
659
+ var getTrendColorWithPercent = (options) => {
660
+ const shouldUsePercentTrendColor = options.trendColor === "> trendValue | rangeValue(trendColorEditorConfig)" && options.trendDisplay === "percent";
661
+ return shouldUsePercentTrendColor ? { trendColor: "> trendValuePercent | rangeValue(trendColorEditorConfig)" } : {};
680
662
  };
681
663
 
682
664
  // src/SingleValueIcon/PureSingleValueIcon/utils/iconUtils.js
@@ -860,6 +842,34 @@ SingleValueIconLayout.propTypes = __spreadProps(__spreadValues({}, SingleValueBa
860
842
  });
861
843
  var SingleValueIconLayout_default = SingleValueIconLayout;
862
844
 
845
+ // esm-externals:@splunk/visualization-context/FeatureFlagContext
846
+ var FeatureFlagContext_exports = {};
847
+ __export(FeatureFlagContext_exports, {
848
+ default: () => FeatureFlagContext_default
849
+ });
850
+ var defaultImport23 = __toESM(require("@splunk/visualization-context/FeatureFlagContext"));
851
+ __reExport(FeatureFlagContext_exports, require("@splunk/visualization-context/FeatureFlagContext"));
852
+ var FeatureFlagContext_default = "default" in defaultImport23 ? defaultImport23.default : defaultImport23;
853
+
854
+ // esm-externals:@splunk/visualization-schemas
855
+ var visualization_schemas_exports = {};
856
+ __export(visualization_schemas_exports, {
857
+ default: () => visualization_schemas_default
858
+ });
859
+ var defaultImport24 = __toESM(require("@splunk/visualization-schemas"));
860
+ __reExport(visualization_schemas_exports, require("@splunk/visualization-schemas"));
861
+ var visualization_schemas_default = "default" in defaultImport24 ? defaultImport24.default : defaultImport24;
862
+
863
+ // src/common/hooks/useTrellisEnabled.ts
864
+ var useTrellisFeatureFlagOn = () => {
865
+ const context = (0, react_exports.useContext)(FeatureFlagContext_default);
866
+ return Boolean(context == null ? void 0 : context.visualizations_enableTrellis);
867
+ };
868
+ var useTrellisEnabled = (layoutType = visualization_schemas_exports.LAYOUT_TYPE.Off) => {
869
+ const trellisFeatureEnabled = useTrellisFeatureFlagOn();
870
+ return trellisFeatureEnabled && layoutType === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
871
+ };
872
+
863
873
  // src/SingleValueIcon/PureSingleValueIcon/SingleValueIcon.jsx
864
874
  var Container = styled_components_default.div`
865
875
  overflow: hidden;
@@ -908,11 +918,7 @@ var SingleValueIcon = (_a) => {
908
918
  defaultFontColor: defaultColors.defaultFontColor,
909
919
  defaultBlockFontColor: defaultColors.defaultBlockFontColor
910
920
  });
911
- const featureFlagContext = react_default.useContext(FeatureFlagContext_default);
912
- const isTrellisFeatureFlagOn = Boolean(
913
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
914
- );
915
- const trellisEnabled = isTrellisFeatureFlagOn && splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
921
+ const trellisEnabled = useTrellisEnabled(splitByLayout);
916
922
  const handleValueClick = (0, react_exports.useCallback)(
917
923
  (ev) => handleValueClickCallback(
918
924
  ev,
@@ -1059,7 +1065,7 @@ var SingleValueIcon = (_a) => {
1059
1065
  IconLayout
1060
1066
  );
1061
1067
  };
1062
- if (isTrellisFeatureFlagOn && splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
1068
+ if (trellisEnabled) {
1063
1069
  return /* @__PURE__ */ react_default.createElement(react_default.Fragment, null, /* @__PURE__ */ react_default.createElement(
1064
1070
  TrellisTitle,
1065
1071
  {
@@ -1468,7 +1474,7 @@ var withFixedSizeContainer = (Viz) => {
1468
1474
  FixSizeItem,
1469
1475
  {
1470
1476
  "data-test": "fix-size-item",
1471
- "data-splunk-visualization-version": "27.0.0 - 9bf093b7d",
1477
+ "data-splunk-visualization-version": "27.1.0 - fe8b048df",
1472
1478
  width,
1473
1479
  height,
1474
1480
  backgroundColor
@@ -1534,7 +1540,7 @@ var Cover = styled_components_default.div`
1534
1540
  bottom: 0;
1535
1541
  `;
1536
1542
  var Blocker = styled_components_default.div.attrs({
1537
- "data-splunk-visualization-version": "27.0.0 - 9bf093b7d"
1543
+ "data-splunk-visualization-version": "27.1.0 - fe8b048df"
1538
1544
  })`
1539
1545
  position: relative;
1540
1546
  width: 100%;
@@ -2021,782 +2027,1131 @@ var getFeatureFlag = (context, flagName) => {
2021
2027
  return false;
2022
2028
  };
2023
2029
 
2024
- // src/common/withDashboardViz.tsx
2025
- var withDashboardViz = (opts) => {
2026
- const {
2027
- ReactViz,
2028
- vizConfig,
2029
- computeVizProps: computeVizProps2 = () => {
2030
- },
2031
- disableEditModeCover,
2032
- useIconPlaceholder
2033
- } = opts;
2034
- const SanitizedReactViz = (0, SanitizeProps_exports.withSanitizedProps)(ReactViz);
2035
- const defaultOptions = (0, JSONSchemaUtils_exports.pickFieldFromJSONSchema)(vizConfig.optionsSchema, "default");
2036
- const DashboardViz = (props) => {
2037
- var _a;
2038
- const {
2039
- mode,
2040
- hasEventHandlers,
2041
- dataSources,
2042
- // type of { [key: string]: DataSource }
2043
- options,
2044
- context = {},
2045
- width,
2046
- height,
2047
- onComputedProps,
2048
- onEventTrigger,
2049
- theme,
2050
- onRequestParamsChange
2051
- } = props;
2052
- const { serializedTimezone } = react_exports.useContext(TimezoneContext_default);
2053
- if (serializedTimezone) {
2054
- if (!moment_default.getDefaultSplunkTimezone()) {
2055
- moment_default.setDefaultSplunkTimezone(serializedTimezone);
2030
+ // esm-externals:@splunk/visualizations-shared/trellisUtils
2031
+ var trellisUtils_exports = {};
2032
+ __export(trellisUtils_exports, {
2033
+ default: () => trellisUtils_default
2034
+ });
2035
+ var defaultImport37 = __toESM(require("@splunk/visualizations-shared/trellisUtils"));
2036
+ __reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisUtils"));
2037
+ var trellisUtils_default = "default" in defaultImport37 ? defaultImport37.default : defaultImport37;
2038
+
2039
+ // src/common/utils/trellisUtils.ts
2040
+ var AGGREGATIONS = "aggregations";
2041
+ var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
2042
+ var _a, _b, _c, _d;
2043
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2044
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2045
+ let splitDataSources = null;
2046
+ let errorCode = null;
2047
+ if (fields && fields.length) {
2048
+ splitDataSources = {};
2049
+ for (let i = 0; i < fields.length; i += 1) {
2050
+ const fieldName = fields[i].name;
2051
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
2052
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
2053
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2054
+ );
2055
+ splitDataSources[fieldName].primary.data.fields = [fields[i]];
2056
+ splitDataSources[fieldName].primary.data.columns = [columns[i]];
2056
2057
  }
2057
2058
  }
2058
- const themeFunc = (themeVar) => {
2059
- var _a2, _b;
2060
- return (_b = (_a2 = vizConfig.themes)[themeVar]) == null ? void 0 : _b.call(_a2, props);
2061
- };
2062
- const bgColorFromTheme = themeFunc("defaultBackgroundColor");
2063
- const {
2064
- family: currentThemeFamily,
2065
- colorScheme: currentThemeColorScheme,
2066
- density: currentThemeDensity
2067
- } = getSettingsFromThemedProps_default({ theme });
2068
- let evaluatedOptions = {};
2069
- const [evaluatedOptionsAsync, setEvaluatedOptionsAsync] = react_exports.useState({});
2070
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2071
- const [visualizationID] = react_exports.useState(`${vizConfig.name} - ${(0, id_exports.createGUID)()}`);
2072
- const [dataSourcesInState, setDataSourcesInState] = react_exports.useState({});
2073
- const [dataFramesInState, setDataFramesInState] = react_exports.useState();
2074
- const [useAsyncEvaluatedOptions, setUseAsyncEvaluatedOptions] = react_exports.useState(
2075
- Boolean(getFeatureFlag(featureFlagContext, "visualizations_useWebWorkersForDSL"))
2076
- );
2077
- const isDownsamplingEnabledByFeatureFlag = Boolean(
2078
- featureFlagContext == null ? void 0 : featureFlagContext.visualizations_enableDownsampling
2079
- );
2080
- const isMounted = react_exports.useRef(true);
2081
- const optionsToEvaluate = react_exports.useMemo(
2082
- () => ({
2083
- context: (0, lodash_exports.defaultsDeep)({}, context, vizConfig.defaultContext),
2084
- options: (0, hocUtils_exports.deepMergeWithArrayPrimitiveOverrides)({}, options, defaultOptions)
2085
- }),
2086
- [options, context]
2087
- );
2088
- const [threshold, setThreshold] = react_exports.useState(Number(width));
2089
- const onDownsamplingThresholdChange = react_exports.useCallback((newThreshold) => {
2090
- setThreshold(newThreshold);
2091
- }, []);
2092
- const isDownsamplingEnabled = react_exports.useMemo(() => {
2093
- return isDownsamplingEnabledByFeatureFlag && isDownsamplingEnabledForViz({ vizConfig });
2094
- }, [isDownsamplingEnabledByFeatureFlag]);
2095
- const downsamplingProps = react_exports.useMemo(() => {
2096
- if (!isDownsamplingEnabled) {
2097
- return {};
2098
- }
2099
- return {
2100
- onDownsamplingThresholdChange,
2101
- originalDataSources: dataSources
2102
- };
2103
- }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
2104
- const downsampledDataSources = useDownsampleDataSources_default({
2105
- options: optionsToEvaluate.options,
2106
- context: optionsToEvaluate.context,
2107
- dataSources,
2108
- threshold,
2109
- isDownsamplingEnabled
2110
- });
2111
- evaluatedOptions = useDeepMemo(() => {
2112
- try {
2113
- if (useAsyncEvaluatedOptions) {
2114
- const asyncDynamicOptionsEvaluatorParams = {
2115
- visualizationID,
2116
- props,
2117
- options: optionsToEvaluate,
2118
- dataSources: downsampledDataSources,
2119
- theme: vizConfig.themes,
2120
- bypassCloneDeepOptionScope: Boolean(
2121
- getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
2122
- ),
2123
- lazyLoadingDataFrame: Boolean(
2124
- getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
2125
- )
2126
- };
2127
- async_dynamic_options_evaluator_default.evaluate(asyncDynamicOptionsEvaluatorParams).then((results) => {
2128
- setEvaluatedOptionsAsync(results.results);
2129
- }).catch(() => {
2130
- if (isMounted.current) {
2131
- setUseAsyncEvaluatedOptions(false);
2132
- }
2133
- });
2134
- } else {
2135
- let dataFrames = dataFramesInState;
2136
- if (downsampledDataSources !== dataSourcesInState) {
2137
- setDataSourcesInState(downsampledDataSources);
2138
- dataFrames = Options_exports.Options.dataFrameFromDataSource(
2139
- downsampledDataSources,
2140
- getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
2141
- );
2142
- setDataFramesInState(dataFrames);
2143
- }
2144
- const result = Options_exports.Options.evaluate(
2145
- optionsToEvaluate,
2146
- downsampledDataSources,
2147
- themeFunc,
2148
- dataFrames,
2149
- getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
2150
- );
2151
- return result;
2059
+ } else {
2060
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2061
+ }
2062
+ return { splitDataSources, errorCode };
2063
+ };
2064
+ var dataSourcesSplitByAggregationsTimechartAndChart = (dataSource) => {
2065
+ var _a, _b, _c, _d;
2066
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2067
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2068
+ let splitDataSources = null;
2069
+ let splitByFields = [];
2070
+ let errorCode = null;
2071
+ if (typeof fields[0] !== "string") {
2072
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2073
+ }
2074
+ if (splitByFields && splitByFields.length > 0) {
2075
+ splitDataSources = {};
2076
+ splitByFields.forEach((splitByField) => {
2077
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
2078
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2079
+ );
2080
+ splitDataSources[splitByField].primary.data.fields = [fields[0]];
2081
+ splitDataSources[splitByField].primary.data.columns = [columns[0]];
2082
+ fields.forEach((field, idx) => {
2083
+ const fieldName = field == null ? void 0 : field.name;
2084
+ if (fieldName !== "_time" && !(fieldName == null ? void 0 : fieldName.startsWith("_")) && field.data_source === splitByField) {
2085
+ splitDataSources[splitByField].primary.data.fields.push(field);
2086
+ splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
2152
2087
  }
2153
- } catch (e) {
2154
- console.error(`unexpected error evaluating options: ${e.message}`);
2155
- return {};
2156
- }
2157
- return {};
2158
- }, [
2159
- currentThemeFamily,
2160
- currentThemeColorScheme,
2161
- currentThemeDensity,
2162
- optionsToEvaluate,
2163
- downsampledDataSources,
2164
- serializedTimezone,
2165
- useAsyncEvaluatedOptions
2166
- ]);
2167
- const evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync;
2168
- const isTrellisFeatureFlagOn = Boolean(
2169
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2170
- );
2171
- let clonedEvaluatedOptions = evaluatedOptionsToUse;
2172
- if (isTrellisFeatureFlagOn && ((_a = vizConfig == null ? void 0 : vizConfig.supports) == null ? void 0 : _a.includes("trellis" /* TRELLIS */)) && (clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.splitByLayout) === "trellis" /* TRELLIS */) {
2173
- clonedEvaluatedOptions = __spreadProps(__spreadValues({}, evaluatedOptionsToUse), {
2174
- backgroundColor: clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
2175
2088
  });
2176
- }
2177
- react_exports.useEffect(() => {
2178
- onComputedProps(clonedEvaluatedOptions);
2179
2089
  });
2180
- react_exports.useEffect(() => {
2181
- return () => {
2182
- if (useAsyncEvaluatedOptions) {
2183
- isMounted.current = false;
2184
- async_dynamic_options_evaluator_default.reset(visualizationID);
2185
- }
2186
- };
2187
- }, []);
2188
- const { requiredProps = [], supports } = vizConfig;
2189
- const missing = missingKeys(requiredProps, evaluatedOptionsToUse);
2190
- if (missing.length > 0 && supports.includes("placeholder" /* PLACEHOLDER */) && vizConfig.key !== "splunk.singlevalue") {
2191
- return /* @__PURE__ */ react_exports.createElement(
2192
- MissingPropsMessage_default,
2193
- {
2194
- "data-test": "missing-props-message",
2195
- width,
2196
- height,
2197
- missingProps: missing,
2198
- backgroundColor: bgColorFromTheme
2199
- }
2200
- );
2201
- }
2202
- const eventCallbackProps = {};
2203
- if (hasEventHandlers && mode === "view" && vizConfig.supports.indexOf("events" /* EVENTS */) > -1) {
2204
- const supportedEvents = vizConfig.events;
2205
- Object.keys(supportedEvents).forEach((eventName) => {
2206
- const { parentKeys, payloadKeys } = supportedEvents[eventName];
2207
- const eventCallbackPropName = (0, lodash_exports.camelCase)(`on.${eventName}`);
2208
- let payload = {};
2209
- if (Array.isArray(payloadKeys) && payloadKeys.length) {
2210
- payloadKeys.forEach((p) => {
2211
- payload[p] = evaluatedOptionsToUse[p];
2212
- });
2213
- }
2214
- eventCallbackProps[eventCallbackPropName] = (ev) => {
2215
- if (ev && ev.payload) {
2216
- payload = ev.payload;
2217
- }
2218
- return onEventTrigger({ originalEvent: ev, payload, type: eventName });
2219
- };
2220
- if (parentKeys) {
2221
- for (let i = parentKeys.length - 1; i >= 0; i -= 1) {
2222
- const newObject = {};
2223
- newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
2224
- eventCallbackProps[eventCallbackPropName] = newObject;
2090
+ } else if ((!splitByFields || !splitByFields.length) && fields.length > 1) {
2091
+ splitDataSources = {};
2092
+ for (let i = 1; i < fields.length; i += 1) {
2093
+ const fieldName = fields[i].name;
2094
+ if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
2095
+ splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
2096
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2097
+ );
2098
+ splitDataSources[fieldName].primary.data.fields = [fields[0], fields[i]];
2099
+ splitDataSources[fieldName].primary.data.columns = [columns[0], columns[i]];
2100
+ }
2101
+ }
2102
+ } else {
2103
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2104
+ }
2105
+ return { splitDataSources, errorCode };
2106
+ };
2107
+ var dataSourcesSplitByAggregationsStats = (dataSource) => {
2108
+ var _a, _b, _c, _d;
2109
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2110
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2111
+ let splitDataSources = null;
2112
+ let splitByFields = [];
2113
+ let errorCode = null;
2114
+ if (typeof fields[0] !== "string") {
2115
+ splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysStats)(fields);
2116
+ }
2117
+ if (splitByFields && splitByFields.length > 0) {
2118
+ splitDataSources = {};
2119
+ splitByFields.forEach((splitByField) => {
2120
+ splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
2121
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2122
+ );
2123
+ splitDataSources[splitByField].primary.data.fields = [fields[0]];
2124
+ splitDataSources[splitByField].primary.data.columns = [columns[0]];
2125
+ const idx = fields.findIndex((field) => field.name === splitByField);
2126
+ if (idx > 0) {
2127
+ splitDataSources[splitByField].primary.data.fields.push(fields[idx]);
2128
+ splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
2129
+ }
2130
+ });
2131
+ } else {
2132
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2133
+ }
2134
+ return { splitDataSources, errorCode };
2135
+ };
2136
+ var dataSourcesSplitByModeTimechart = (dataSource, splitBy) => {
2137
+ var _a, _b, _c, _d, _e;
2138
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2139
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2140
+ let splitDataSources = null;
2141
+ let splitByFields = [];
2142
+ let errorCode = null;
2143
+ if (typeof fields[0] !== "string") {
2144
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
2145
+ }
2146
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2147
+ splitDataSources = {};
2148
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2149
+ const valueKeys = [];
2150
+ for (let i = 1; i < fields.length; i += 1) {
2151
+ if (!((_e = fields[i].name) == null ? void 0 : _e.startsWith("_"))) {
2152
+ valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
2153
+ }
2154
+ }
2155
+ valueKeys.forEach((val) => {
2156
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2157
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2158
+ );
2159
+ splitDataSources[val].primary.data.fields = [
2160
+ { name: fields[0].name },
2161
+ ...dataSourceKeys.map((k) => ({
2162
+ name: k
2163
+ }))
2164
+ ];
2165
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
2166
+ dataSourceKeys.forEach((dsKey) => {
2167
+ fields.forEach((field, idx) => {
2168
+ if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
2169
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
2225
2170
  }
2226
- }
2171
+ });
2227
2172
  });
2173
+ });
2174
+ } else {
2175
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2176
+ }
2177
+ return { splitDataSources, errorCode };
2178
+ };
2179
+ var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
2180
+ var _a, _b, _c, _d;
2181
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2182
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2183
+ let splitDataSources = null;
2184
+ let splitByFields = [];
2185
+ let errorCode = null;
2186
+ if (typeof fields[0] !== "string") {
2187
+ splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
2188
+ }
2189
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2190
+ splitDataSources = {};
2191
+ const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
2192
+ const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
2193
+ const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
2194
+ const nonDataSourceAggregations = [];
2195
+ if (!dataSourceKeys.length && fields[0].groupby_rank === "0" && fields.length && !fields[1].groupby_rank) {
2196
+ for (let i = 1; i < fields.length; i += 1) {
2197
+ nonDataSourceAggregations.push(fields[i].name);
2198
+ }
2228
2199
  }
2229
- const computedVizProps = computeVizProps2(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, props), evaluatedOptionsToUse), eventCallbackProps), {
2230
- themeFunc
2231
- }));
2232
- let dataSourceMetadata = {};
2233
- const OptionKey = "paginateDataSourceKey";
2234
- const paginateDataSourceKey = (0, lodash_exports.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || "primary";
2235
- if (vizConfig.supports.indexOf("page-and-sort" /* PAGE_AND_SORT */) > -1 && (0, lodash_exports.has)(dataSources, paginateDataSourceKey)) {
2236
- const requestParams = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "requestParams"], {});
2237
- const meta = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "meta"], {});
2238
- const handleRequestParamsChange = (payload) => onRequestParamsChange(paginateDataSourceKey, payload);
2239
- const sortParams = getSortingParams({
2240
- requestParams,
2241
- meta,
2242
- onRequestParamsChange: handleRequestParamsChange
2200
+ if (splitByFieldIdx === 0) {
2201
+ const valueKeys = (0, lodash_exports.cloneDeep)(columns[0]);
2202
+ valueKeys.forEach((val, idx) => {
2203
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2204
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2205
+ );
2206
+ splitDataSources[val].primary.data.fields = [];
2207
+ if (otherSplitBy.length) {
2208
+ splitDataSources[val].primary.data.fields = [{ name: otherSplitBy[0] }];
2209
+ }
2210
+ if (dataSourceKeys.length) {
2211
+ const columnValues = [[]];
2212
+ splitDataSources[val].primary.data.fields = [
2213
+ ...splitDataSources[val].primary.data.fields,
2214
+ ...dataSourceKeys.map((k) => ({
2215
+ name: k
2216
+ }))
2217
+ ];
2218
+ dataSourceKeys.forEach(() => {
2219
+ columnValues.push([]);
2220
+ });
2221
+ for (let i = 1; i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); i += 1) {
2222
+ columnValues[0].push(
2223
+ fields[i].splitby_value ? fields[i].splitby_value : fields[i].name
2224
+ );
2225
+ dataSourceKeys.forEach((dskey, dsIndx) => {
2226
+ const mul = (fields.length - 1) / dataSourceKeys.length;
2227
+ columnValues[dsIndx + 1].push(columns[i + dsIndx * mul][idx]);
2228
+ });
2229
+ }
2230
+ splitDataSources[val].primary.data.columns = columnValues;
2231
+ } else if (nonDataSourceAggregations.length) {
2232
+ const columnValues = [];
2233
+ fields.forEach((aggregationField, fieldIdx) => {
2234
+ if (fieldIdx > 0) {
2235
+ splitDataSources[val].primary.data.fields.push(aggregationField);
2236
+ columnValues.push([columns[fieldIdx][idx]]);
2237
+ }
2238
+ });
2239
+ splitDataSources[val].primary.data.columns = columnValues;
2240
+ }
2243
2241
  });
2244
- const paginatorParams = getPaginationParams({
2245
- requestParams,
2246
- meta,
2247
- onRequestParamsChange: handleRequestParamsChange
2242
+ } else {
2243
+ const valueKeys = [];
2244
+ for (let i = 1; i < fields.length; i += 1) {
2245
+ valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
2246
+ }
2247
+ valueKeys.forEach((val) => {
2248
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2249
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2250
+ );
2251
+ splitDataSources[val].primary.data.fields = [
2252
+ { name: otherSplitBy[0] },
2253
+ ...dataSourceKeys.map((k) => ({
2254
+ name: k
2255
+ }))
2256
+ ];
2257
+ splitDataSources[val].primary.data.columns = [[...columns[0]]];
2258
+ dataSourceKeys.forEach((dsKey) => {
2259
+ fields.forEach((field, idx) => {
2260
+ if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
2261
+ splitDataSources[val].primary.data.columns.push([...columns[idx]]);
2262
+ }
2263
+ });
2264
+ });
2248
2265
  });
2249
- dataSourceMetadata = {
2250
- sortParams,
2251
- paginatorParams
2252
- };
2253
- }
2254
- if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
2255
- return null;
2256
2266
  }
2257
- return /* @__PURE__ */ react_exports.createElement(
2258
- SanitizedReactViz,
2259
- __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
2260
- mode,
2261
- width,
2262
- height
2263
- }, downsamplingProps), evaluatedOptionsToUse), computedVizProps), eventCallbackProps), dataSourceMetadata)
2264
- );
2265
- };
2266
- DashboardViz.propTypes = __spreadValues(__spreadValues({}, SplunkVisualization_default.propTypes), ReactViz.propTypes);
2267
- DashboardViz.defaultProps = __spreadProps(__spreadValues(__spreadValues({}, SplunkVisualization_default.defaultProps), ReactViz.defaultProps), {
2268
- // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
2269
- theme: {}
2270
- });
2271
- DashboardViz.config = vizConfig;
2272
- return (0, styled_components_exports.withTheme)(
2273
- withPlaceholder_default(withEditModeCover_default(DashboardViz, disableEditModeCover), useIconPlaceholder)
2274
- );
2267
+ } else {
2268
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2269
+ }
2270
+ return { splitDataSources, errorCode };
2275
2271
  };
2276
- var withDashboardViz_default = withDashboardViz;
2277
-
2278
- // esm-externals:@splunk/visualization-color-palettes/editors/PresetPalettes
2279
- var PresetPalettes_exports = {};
2280
- __export(PresetPalettes_exports, {
2281
- default: () => PresetPalettes_default
2282
- });
2283
- var defaultImport37 = __toESM(require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
2284
- __reExport(PresetPalettes_exports, require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
2285
- var PresetPalettes_default = "default" in defaultImport37 ? defaultImport37.default : defaultImport37;
2286
-
2287
- // esm-externals:@splunk/themes/pick
2288
- var pick_exports2 = {};
2289
- __export(pick_exports2, {
2290
- default: () => pick_default2
2291
- });
2292
- var defaultImport38 = __toESM(require("@splunk/themes/pick"));
2293
- __reExport(pick_exports2, require("@splunk/themes/pick"));
2294
- var pick_default2 = "default" in defaultImport38 ? defaultImport38.default : defaultImport38;
2295
-
2296
- // esm-externals:@splunk/visualizations-shared/configUtils
2297
- var configUtils_exports = {};
2298
- __export(configUtils_exports, {
2299
- default: () => configUtils_default
2300
- });
2301
- var defaultImport39 = __toESM(require("@splunk/visualizations-shared/configUtils"));
2302
- __reExport(configUtils_exports, require("@splunk/visualizations-shared/configUtils"));
2303
- var configUtils_default = "default" in defaultImport39 ? defaultImport39.default : defaultImport39;
2304
-
2305
- // src/common/configContext/singleValueContext.ts
2306
- var defaultContext = {
2307
- trendColorConfig: [
2308
- {
2309
- to: 0,
2310
- value: "#9E2520"
2311
- },
2312
- {
2313
- from: 0,
2314
- value: "#1C6B2D"
2315
- }
2316
- ],
2317
- majorColorConfig: [
2318
- { to: 20, value: "#D41F1F" },
2319
- { from: 20, to: 40, value: "#D94E17" },
2320
- { from: 40, to: 60, value: "#CBA700" },
2321
- { from: 60, to: 80, value: "#669922" },
2322
- { from: 80, value: "#118832" }
2323
- ],
2324
- majorColorMatchConfig: [{ match: "", value: "#5C33FF" }]
2272
+ var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
2273
+ var _a, _b, _c, _d, _e, _f;
2274
+ const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
2275
+ const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
2276
+ let splitDataSources = null;
2277
+ let splitByFields = [];
2278
+ let errorCode = null;
2279
+ if (typeof fields[0] !== "string") {
2280
+ splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
2281
+ }
2282
+ const splitByIndex = fields == null ? void 0 : fields.findIndex(
2283
+ (field) => field === splitBy || field.name === splitBy
2284
+ );
2285
+ if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
2286
+ const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
2287
+ splitDataSources = {};
2288
+ splitByColumn.forEach((val, idx) => {
2289
+ if (!splitDataSources[val]) {
2290
+ splitDataSources[val] = [idx];
2291
+ } else {
2292
+ splitDataSources[val].push(idx);
2293
+ }
2294
+ });
2295
+ const cloneFields = (0, lodash_exports.cloneDeep)(fields);
2296
+ cloneFields.splice(splitByIndex, 1);
2297
+ const valueKeys = Object.keys(splitDataSources);
2298
+ valueKeys.forEach((val) => {
2299
+ const valIndices = (0, lodash_exports.cloneDeep)(splitDataSources[val]);
2300
+ splitDataSources[val] = (0, lodash_exports.cloneDeep)(
2301
+ (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
2302
+ );
2303
+ splitDataSources[val].primary.data.fields = cloneFields;
2304
+ splitDataSources[val].primary.data.columns = [];
2305
+ columns.forEach((col, idx) => {
2306
+ if (idx !== splitByIndex) {
2307
+ const newCol = valIndices.map((valIdx) => col[valIdx]);
2308
+ splitDataSources[val].primary.data.columns.push(newCol);
2309
+ }
2310
+ });
2311
+ });
2312
+ } else {
2313
+ errorCode = "INVALID_SPLIT_BY_FIELD";
2314
+ }
2315
+ return { splitDataSources, errorCode };
2325
2316
  };
2326
-
2327
- // src/common/editorConfig/StaticMajorAndTrendLayout.js
2328
- var StaticMajorAndTrendLayout = [
2329
- [
2330
- {
2331
- label: (0, i18n_exports._)("Unit position"),
2332
- // todo: we need a new editor combining unit and position
2333
- option: "unitPosition",
2334
- editor: "editor.select",
2335
- editorProps: {
2336
- values: [
2337
- { label: (0, i18n_exports._)("Before"), value: "before" },
2338
- { label: (0, i18n_exports._)("After"), value: "after" }
2339
- ]
2340
- },
2341
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
2342
- },
2343
- {
2344
- label: (0, i18n_exports._)("Unit label"),
2345
- option: "unit",
2346
- editor: "editor.text",
2347
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
2348
- }
2349
- ],
2350
- [
2351
- {
2352
- label: (0, i18n_exports._)("Precision"),
2353
- option: "numberPrecision",
2354
- editor: "editor.number",
2355
- editorProps: {
2356
- min: 0,
2357
- max: 20
2358
- },
2359
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
2317
+ var getTrellisDataSourcesBySplitMode = (splitMode, dataSources, trellisSplitBy) => {
2318
+ let result = null;
2319
+ try {
2320
+ if (splitMode === trellisUtils_exports.TIMECHART) {
2321
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeTimechart(dataSources, trellisSplitBy);
2322
+ } else if (splitMode === trellisUtils_exports.STATS) {
2323
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsStats(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.STATS);
2324
+ } else if (splitMode === trellisUtils_exports.CHART) {
2325
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeChart(dataSources, trellisSplitBy);
2326
+ } else if (splitMode === trellisUtils_exports.UNKNOWN) {
2327
+ result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsUnknown(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.UNKNOWN);
2360
2328
  }
2361
- ]
2362
- ];
2363
- var StaticMajorAndTrendLayout_default = StaticMajorAndTrendLayout;
2364
-
2365
- // src/common/editorConfig/StaticBackgroundColorEditor.js
2366
- var StaticBackgroundColorEditor = {
2367
- label: (0, i18n_exports._)("Background color"),
2368
- option: "backgroundColor",
2369
- editor: "editor.color",
2370
- showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.backgroundColor)
2329
+ } catch (ex) {
2330
+ console.error("getTrellisDataSourcesBySplitMode ", ex);
2331
+ result = { splitDataSources: null, errorCode: "UNKNOWN" };
2332
+ }
2333
+ return result;
2371
2334
  };
2372
- var StaticBackgroundColorEditor_default = StaticBackgroundColorEditor;
2373
-
2374
- // src/common/editorConfig/StaticIconColorEditor.js
2375
- var StaticIconColorEditor = [
2376
- {
2377
- label: (0, i18n_exports._)("Icon"),
2378
- option: "iconColor",
2379
- editor: "editor.color",
2380
- showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.iconColor),
2381
- editorProps: {
2382
- labelPosition: "top",
2383
- value: null,
2384
- palette: [null, ...colorConstants_exports.COLOR_EDITOR_PALETTE]
2385
- }
2335
+ var turnOffLegendDisplayWhenTrellisIsOn = (isTrellisOn, options) => {
2336
+ if (isTrellisOn && !options.legendDisplay) {
2337
+ return {
2338
+ legendDisplay: "off"
2339
+ };
2386
2340
  }
2387
- ];
2388
- var StaticIconColorEditor_default = StaticIconColorEditor;
2389
-
2390
- // src/common/editorConfig/StaticMajorColorEditor.js
2391
- var StaticMajorColorEditor = {
2392
- label: (0, i18n_exports._)("Major value"),
2393
- option: "majorColor",
2394
- editor: "editor.color",
2395
- showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.majorColor)
2341
+ return {};
2342
+ };
2343
+ var calculateSharedMinMax = (splitData) => {
2344
+ let max = -Infinity;
2345
+ let min = Infinity;
2346
+ Object.keys(splitData).forEach((splitByKey) => {
2347
+ const datasources = splitData[splitByKey];
2348
+ Object.keys(datasources).forEach((datasourceName) => {
2349
+ const dataColumns = datasources[datasourceName].data.columns;
2350
+ dataColumns.forEach((column) => {
2351
+ column.forEach((point) => {
2352
+ const pointNumber = Number(point);
2353
+ if (pointNumber > max) {
2354
+ max = pointNumber;
2355
+ }
2356
+ if (pointNumber < min) {
2357
+ min = pointNumber;
2358
+ }
2359
+ });
2360
+ });
2361
+ });
2362
+ });
2363
+ return [min, max];
2396
2364
  };
2397
- var StaticMajorColorEditor_default = StaticMajorColorEditor;
2398
-
2399
- // src/common/editorConfig/StaticTrendColorEditor.js
2400
- var StaticTrendColorEditor = {
2401
- label: (0, i18n_exports._)("Trend value"),
2402
- option: "trendColor",
2403
- editor: "editor.color",
2404
- showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.trendColor),
2405
- isDisabled: ({ options }) => options.trendDisplay === "off"
2365
+ var determineMinMax = (splitData, trellisSharedScale, yAxisMin, yAxisMax, stackMode) => {
2366
+ if (!trellisSharedScale || stackMode === "stacked100" || yAxisMin !== "auto" && yAxisMax !== "auto")
2367
+ return [yAxisMin, yAxisMax];
2368
+ const [sharedMin, sharedMax] = calculateSharedMinMax(splitData);
2369
+ const shouldUseSharedMax = sharedMax !== -Infinity && yAxisMax === "auto";
2370
+ const shouldUseSharedMin = sharedMin !== Infinity && yAxisMin === "auto";
2371
+ return [shouldUseSharedMin ? sharedMin : yAxisMin, shouldUseSharedMax ? sharedMax : yAxisMax];
2406
2372
  };
2407
- var StaticTrendColorEditor_default = StaticTrendColorEditor;
2408
2373
 
2409
- // src/common/editorConfig/DynamicMajorColorEditor.js
2410
- var getDynamicMajorColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
2411
- label: (0, i18n_exports._)("Major value"),
2412
- option: "majorColor",
2413
- context: "majorColorEditorConfig",
2414
- editor: "editor.dynamicColor",
2415
- showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.majorColor),
2416
- editorProps: {
2417
- labelPosition: "top",
2418
- flyoutTitle: (0, i18n_exports._)("Dynamic coloring: major value"),
2419
- formatters: [
2420
- {
2421
- label: (0, i18n_exports._)("Ranges"),
2422
- value: "rangeValue",
2423
- defaults: {
2424
- majorValue: defaultContext2.majorColorConfig
2425
- }
2426
- },
2427
- {
2428
- label: (0, i18n_exports._)("Matches"),
2429
- value: "matchValue",
2430
- defaults: {
2431
- majorValue: defaultContext2.majorColorMatchConfig
2432
- }
2433
- }
2434
- ],
2435
- dataSelectors: [
2436
- {
2437
- label: (0, i18n_exports._)("Major value"),
2438
- value: "majorValue"
2374
+ // src/common/withDashboardViz.tsx
2375
+ var withDashboardViz = (opts) => {
2376
+ const {
2377
+ ReactViz,
2378
+ vizConfig,
2379
+ computeVizProps: computeVizProps2 = () => {
2380
+ },
2381
+ computeVizPropsBeforeEval: computeVizPropsBeforeEval2 = () => {
2382
+ },
2383
+ disableEditModeCover,
2384
+ useIconPlaceholder
2385
+ } = opts;
2386
+ const SanitizedReactViz = (0, SanitizeProps_exports.withSanitizedProps)(ReactViz);
2387
+ const defaultOptions = (0, JSONSchemaUtils_exports.pickFieldFromJSONSchema)(vizConfig.optionsSchema, "default");
2388
+ const DashboardViz = (props) => {
2389
+ var _a;
2390
+ const {
2391
+ mode,
2392
+ hasEventHandlers,
2393
+ dataSources,
2394
+ // type of { [key: string]: DataSource }
2395
+ options,
2396
+ context = {},
2397
+ width,
2398
+ height,
2399
+ onComputedProps,
2400
+ onEventTrigger,
2401
+ theme,
2402
+ onRequestParamsChange
2403
+ } = props;
2404
+ const { serializedTimezone } = react_exports.useContext(TimezoneContext_default);
2405
+ if (serializedTimezone) {
2406
+ if (!moment_default.getDefaultSplunkTimezone()) {
2407
+ moment_default.setDefaultSplunkTimezone(serializedTimezone);
2439
2408
  }
2440
- ],
2441
- defaultPalettesConfig: defaultPalettesConfig2
2442
- }
2443
- });
2444
-
2445
- // src/common/editorConfig/DynamicTrendColorEditor.js
2446
- var getDynamicTrendColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
2447
- label: (0, i18n_exports._)("Trend value"),
2448
- option: "trendColor",
2449
- context: "trendColorEditorConfig",
2450
- editor: "editor.dynamicColor",
2451
- showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.trendColor),
2452
- editorProps: {
2453
- labelPosition: "top",
2454
- flyoutTitle: (0, i18n_exports._)("Dynamic coloring: trend value"),
2455
- formatters: [
2456
- {
2457
- label: (0, i18n_exports._)("Ranges"),
2458
- value: "rangeValue",
2459
- defaults: {
2460
- trendValue: defaultContext2.trendColorConfig
2461
- }
2462
- }
2463
- ],
2464
- dataSelectors: [
2465
- {
2466
- label: (0, i18n_exports._)("Trend value"),
2467
- value: "trendValue"
2409
+ }
2410
+ const themeFunc = (themeVar) => {
2411
+ var _a2, _b;
2412
+ return (_b = (_a2 = vizConfig.themes)[themeVar]) == null ? void 0 : _b.call(_a2, props);
2413
+ };
2414
+ const bgColorFromTheme = themeFunc("defaultBackgroundColor");
2415
+ const {
2416
+ family: currentThemeFamily,
2417
+ colorScheme: currentThemeColorScheme,
2418
+ density: currentThemeDensity
2419
+ } = getSettingsFromThemedProps_default({ theme });
2420
+ let evaluatedOptions = {};
2421
+ const [evaluatedOptionsAsync, setEvaluatedOptionsAsync] = react_exports.useState({});
2422
+ const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2423
+ const [visualizationID] = react_exports.useState(`${vizConfig.name} - ${(0, id_exports.createGUID)()}`);
2424
+ const [dataSourcesInState, setDataSourcesInState] = react_exports.useState({});
2425
+ const [dataFramesInState, setDataFramesInState] = react_exports.useState();
2426
+ const [useAsyncEvaluatedOptions, setUseAsyncEvaluatedOptions] = react_exports.useState(
2427
+ Boolean(getFeatureFlag(featureFlagContext, "visualizations_useWebWorkersForDSL"))
2428
+ );
2429
+ const isDownsamplingEnabledByFeatureFlag = Boolean(
2430
+ featureFlagContext == null ? void 0 : featureFlagContext.visualizations_enableDownsampling
2431
+ );
2432
+ const isTrellisFeatureFlagOn2 = Boolean(
2433
+ featureFlagContext && featureFlagContext.visualizations_enableTrellis
2434
+ );
2435
+ const isTrellisOn = isTrellisFeatureFlagOn2 && ((_a = vizConfig == null ? void 0 : vizConfig.supports) == null ? void 0 : _a.includes("trellis" /* TRELLIS */)) && (options == null ? void 0 : options.splitByLayout) === "trellis" /* TRELLIS */;
2436
+ const isMounted = react_exports.useRef(true);
2437
+ const optionsToEvaluate = react_exports.useMemo(() => {
2438
+ var _a2;
2439
+ const legendDisplay = turnOffLegendDisplayWhenTrellisIsOn(isTrellisOn, options);
2440
+ const computedOptions = (_a2 = computeVizPropsBeforeEval2(options)) != null ? _a2 : {};
2441
+ return {
2442
+ context: (0, lodash_exports.defaultsDeep)({}, context, vizConfig.defaultContext),
2443
+ options: (0, hocUtils_exports.deepMergeWithArrayPrimitiveOverrides)(
2444
+ {},
2445
+ legendDisplay,
2446
+ computedOptions,
2447
+ options,
2448
+ defaultOptions
2449
+ )
2450
+ };
2451
+ }, [isTrellisOn, options, context]);
2452
+ const [threshold, setThreshold] = react_exports.useState(Number(width));
2453
+ const onDownsamplingThresholdChange = react_exports.useCallback((newThreshold) => {
2454
+ setThreshold(newThreshold);
2455
+ }, []);
2456
+ const isDownsamplingEnabled = react_exports.useMemo(() => {
2457
+ return isDownsamplingEnabledByFeatureFlag && isDownsamplingEnabledForViz({ vizConfig });
2458
+ }, [isDownsamplingEnabledByFeatureFlag]);
2459
+ const downsamplingProps = react_exports.useMemo(() => {
2460
+ if (!isDownsamplingEnabled) {
2461
+ return {};
2468
2462
  }
2469
- ],
2470
- defaultPalettesConfig: defaultPalettesConfig2
2471
- }
2472
- });
2473
-
2474
- // src/common/editorConfig/DynamicBackgroundColorEditor.js
2475
- var getDynamicBackgroundColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
2476
- label: (0, i18n_exports._)("Background color"),
2477
- option: "backgroundColor",
2478
- context: "backgroundColorEditorConfig",
2479
- editor: "editor.dynamicColor",
2480
- showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.backgroundColor),
2481
- editorProps: {
2482
- labelPosition: "top",
2483
- flyoutTitle: (0, i18n_exports._)("Dynamic coloring: background"),
2484
- formatters: [
2485
- {
2486
- label: (0, i18n_exports._)("Ranges"),
2487
- value: "rangeValue",
2488
- defaults: {
2489
- majorValue: defaultContext2.majorColorConfig,
2490
- trendValue: defaultContext2.trendColorConfig
2491
- }
2492
- },
2493
- {
2494
- label: (0, i18n_exports._)("Matches"),
2495
- value: "matchValue",
2496
- defaults: {
2497
- majorValue: defaultContext2.majorColorMatchConfig
2463
+ return {
2464
+ onDownsamplingThresholdChange,
2465
+ originalDataSources: dataSources
2466
+ };
2467
+ }, [dataSources, isDownsamplingEnabled, onDownsamplingThresholdChange]);
2468
+ const downsampledDataSources = useDownsampleDataSources_default({
2469
+ options: optionsToEvaluate.options,
2470
+ context: optionsToEvaluate.context,
2471
+ dataSources,
2472
+ threshold,
2473
+ isDownsamplingEnabled
2474
+ });
2475
+ evaluatedOptions = useDeepMemo(() => {
2476
+ try {
2477
+ if (useAsyncEvaluatedOptions) {
2478
+ const asyncDynamicOptionsEvaluatorParams = {
2479
+ visualizationID,
2480
+ props,
2481
+ options: optionsToEvaluate,
2482
+ dataSources: downsampledDataSources,
2483
+ theme: vizConfig.themes,
2484
+ bypassCloneDeepOptionScope: Boolean(
2485
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
2486
+ ),
2487
+ lazyLoadingDataFrame: Boolean(
2488
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
2489
+ )
2490
+ };
2491
+ async_dynamic_options_evaluator_default.evaluate(asyncDynamicOptionsEvaluatorParams).then((results) => {
2492
+ setEvaluatedOptionsAsync(results.results);
2493
+ }).catch(() => {
2494
+ if (isMounted.current) {
2495
+ setUseAsyncEvaluatedOptions(false);
2496
+ }
2497
+ });
2498
+ } else {
2499
+ let dataFrames = dataFramesInState;
2500
+ if (downsampledDataSources !== dataSourcesInState) {
2501
+ setDataSourcesInState(downsampledDataSources);
2502
+ dataFrames = Options_exports.Options.dataFrameFromDataSource(
2503
+ downsampledDataSources,
2504
+ getFeatureFlag(featureFlagContext, "visualizations_lazyLoadingDataFrame")
2505
+ );
2506
+ setDataFramesInState(dataFrames);
2507
+ }
2508
+ const result = Options_exports.Options.evaluate(
2509
+ optionsToEvaluate,
2510
+ downsampledDataSources,
2511
+ themeFunc,
2512
+ dataFrames,
2513
+ getFeatureFlag(featureFlagContext, "visualizations_bypassCloneDeepOptionScope")
2514
+ );
2515
+ return result;
2498
2516
  }
2517
+ } catch (e) {
2518
+ console.error(`unexpected error evaluating options: ${e.message}`);
2519
+ return {};
2499
2520
  }
2500
- ],
2501
- dataSelectors: [
2502
- {
2503
- label: (0, i18n_exports._)("Major Value"),
2504
- value: "majorValue"
2505
- },
2506
- {
2507
- label: (0, i18n_exports._)("Trend"),
2508
- value: "trendValue"
2509
- }
2510
- ],
2511
- defaultPalettesConfig: defaultPalettesConfig2
2512
- }
2513
- });
2514
-
2515
- // src/common/editorConfig/TrellisEditors.ts
2516
- var TrellisEditorConfig = [
2517
- [
2518
- {
2519
- label: (0, i18n_exports._)("Trellis layout"),
2520
- option: "splitByLayout",
2521
- editor: "editor.toggle",
2522
- showEditor: () => {
2523
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2524
- const isTrellisFeatureFlagOn = Boolean(
2525
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2526
- );
2527
- return isTrellisFeatureFlagOn;
2528
- }
2521
+ return {};
2522
+ }, [
2523
+ currentThemeFamily,
2524
+ currentThemeColorScheme,
2525
+ currentThemeDensity,
2526
+ optionsToEvaluate,
2527
+ downsampledDataSources,
2528
+ serializedTimezone,
2529
+ useAsyncEvaluatedOptions
2530
+ ]);
2531
+ const evaluatedOptionsToUse = !useAsyncEvaluatedOptions ? evaluatedOptions : evaluatedOptionsAsync;
2532
+ let clonedEvaluatedOptions = evaluatedOptionsToUse;
2533
+ if (isTrellisOn) {
2534
+ clonedEvaluatedOptions = __spreadProps(__spreadValues({}, evaluatedOptionsToUse), {
2535
+ backgroundColor: clonedEvaluatedOptions == null ? void 0 : clonedEvaluatedOptions.trellisBackgroundColor
2536
+ });
2529
2537
  }
2530
- ],
2531
- [
2532
- {
2533
- label: (0, i18n_exports._)("Split by"),
2534
- option: "trellisSplitBy",
2535
- editor: "editor.trellisSplitBy",
2536
- editorProps: {
2537
- dataSourceKey: "primary"
2538
- },
2539
- showEditor: ({ options }) => {
2540
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2541
- const isTrellisFeatureFlagOn = Boolean(
2542
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2543
- );
2544
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
2545
- }
2538
+ react_exports.useEffect(() => {
2539
+ onComputedProps(clonedEvaluatedOptions);
2540
+ });
2541
+ react_exports.useEffect(() => {
2542
+ return () => {
2543
+ if (useAsyncEvaluatedOptions) {
2544
+ isMounted.current = false;
2545
+ async_dynamic_options_evaluator_default.reset(visualizationID);
2546
+ }
2547
+ };
2548
+ }, []);
2549
+ const { requiredProps = [], supports } = vizConfig;
2550
+ const missing = missingKeys(requiredProps, evaluatedOptionsToUse);
2551
+ if (missing.length > 0 && supports.includes("placeholder" /* PLACEHOLDER */) && vizConfig.key !== "splunk.singlevalue") {
2552
+ return /* @__PURE__ */ react_exports.createElement(
2553
+ MissingPropsMessage_default,
2554
+ {
2555
+ "data-test": "missing-props-message",
2556
+ width,
2557
+ height,
2558
+ missingProps: missing,
2559
+ backgroundColor: bgColorFromTheme
2560
+ }
2561
+ );
2546
2562
  }
2547
- ],
2548
- [
2549
- {
2550
- label: (0, i18n_exports._)("Number of columns"),
2551
- option: "trellisColumns",
2552
- editor: "editor.number",
2553
- editorProps: {
2554
- min: 1
2555
- },
2556
- placeholder: (0, i18n_exports._)("Auto"),
2557
- showEditor: ({ options }) => {
2558
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2559
- const isTrellisFeatureFlagOn = Boolean(
2560
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2561
- );
2562
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
2563
- }
2563
+ const eventCallbackProps = {};
2564
+ if (hasEventHandlers && mode === "view" && vizConfig.supports.indexOf("events" /* EVENTS */) > -1) {
2565
+ const supportedEvents = vizConfig.events;
2566
+ Object.keys(supportedEvents).forEach((eventName) => {
2567
+ const { parentKeys, payloadKeys } = supportedEvents[eventName];
2568
+ const eventCallbackPropName = (0, lodash_exports.camelCase)(`on.${eventName}`);
2569
+ let payload = {};
2570
+ if (Array.isArray(payloadKeys) && payloadKeys.length) {
2571
+ payloadKeys.forEach((p) => {
2572
+ payload[p] = evaluatedOptionsToUse[p];
2573
+ });
2574
+ }
2575
+ eventCallbackProps[eventCallbackPropName] = (ev) => {
2576
+ if (ev && ev.payload) {
2577
+ payload = ev.payload;
2578
+ }
2579
+ return onEventTrigger({ originalEvent: ev, payload, type: eventName });
2580
+ };
2581
+ if (parentKeys) {
2582
+ for (let i = parentKeys.length - 1; i >= 0; i -= 1) {
2583
+ const newObject = {};
2584
+ newObject[parentKeys[i]] = eventCallbackProps[eventCallbackPropName];
2585
+ eventCallbackProps[eventCallbackPropName] = newObject;
2586
+ }
2587
+ }
2588
+ });
2564
2589
  }
2565
- ],
2566
- [
2567
- {
2568
- label: (0, i18n_exports._)("Min column width"),
2569
- option: "trellisMinColumnWidth",
2570
- editor: "editor.number",
2571
- editorProps: {
2572
- min: 1
2573
- },
2574
- showEditor: ({ options }) => {
2575
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2576
- const isTrellisFeatureFlagOn = Boolean(
2577
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2578
- );
2579
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
2580
- }
2581
- },
2590
+ const computedVizProps = computeVizProps2(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, props), evaluatedOptionsToUse), eventCallbackProps), {
2591
+ themeFunc
2592
+ }));
2593
+ let dataSourceMetadata = {};
2594
+ const OptionKey = "paginateDataSourceKey";
2595
+ const paginateDataSourceKey = (0, lodash_exports.has)(evaluatedOptionsToUse, OptionKey) && evaluatedOptionsToUse[OptionKey] || "primary";
2596
+ if (vizConfig.supports.indexOf("page-and-sort" /* PAGE_AND_SORT */) > -1 && (0, lodash_exports.has)(dataSources, paginateDataSourceKey)) {
2597
+ const requestParams = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "requestParams"], {});
2598
+ const meta = (0, lodash_exports.get)(dataSources, [paginateDataSourceKey, "meta"], {});
2599
+ const handleRequestParamsChange = (payload) => onRequestParamsChange(paginateDataSourceKey, payload);
2600
+ const sortParams = getSortingParams({
2601
+ requestParams,
2602
+ meta,
2603
+ onRequestParamsChange: handleRequestParamsChange
2604
+ });
2605
+ const paginatorParams = getPaginationParams({
2606
+ requestParams,
2607
+ meta,
2608
+ onRequestParamsChange: handleRequestParamsChange
2609
+ });
2610
+ dataSourceMetadata = {
2611
+ sortParams,
2612
+ paginatorParams
2613
+ };
2614
+ }
2615
+ if (useAsyncEvaluatedOptions && Object.keys(evaluatedOptionsToUse).length === 0) {
2616
+ return null;
2617
+ }
2618
+ return /* @__PURE__ */ react_exports.createElement(
2619
+ SanitizedReactViz,
2620
+ __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
2621
+ mode,
2622
+ width,
2623
+ height
2624
+ }, downsamplingProps), evaluatedOptionsToUse), computedVizProps), eventCallbackProps), dataSourceMetadata)
2625
+ );
2626
+ };
2627
+ DashboardViz.propTypes = __spreadValues(__spreadValues({}, SplunkVisualization_default.propTypes), ReactViz.propTypes);
2628
+ DashboardViz.defaultProps = __spreadProps(__spreadValues(__spreadValues({}, SplunkVisualization_default.defaultProps), ReactViz.defaultProps), {
2629
+ // using withTheme requires component to receive theme prop. In case the consumer did not provide ThemeProvider, a default empty object will prevent warnings.
2630
+ theme: {}
2631
+ });
2632
+ DashboardViz.config = vizConfig;
2633
+ return (0, styled_components_exports.withTheme)(
2634
+ withPlaceholder_default(withEditModeCover_default(DashboardViz, disableEditModeCover), useIconPlaceholder)
2635
+ );
2636
+ };
2637
+ var withDashboardViz_default = withDashboardViz;
2638
+
2639
+ // esm-externals:@splunk/visualization-color-palettes/editors/PresetPalettes
2640
+ var PresetPalettes_exports = {};
2641
+ __export(PresetPalettes_exports, {
2642
+ default: () => PresetPalettes_default
2643
+ });
2644
+ var defaultImport38 = __toESM(require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
2645
+ __reExport(PresetPalettes_exports, require("@splunk/visualization-color-palettes/editors/PresetPalettes"));
2646
+ var PresetPalettes_default = "default" in defaultImport38 ? defaultImport38.default : defaultImport38;
2647
+
2648
+ // esm-externals:@splunk/themes/pick
2649
+ var pick_exports2 = {};
2650
+ __export(pick_exports2, {
2651
+ default: () => pick_default2
2652
+ });
2653
+ var defaultImport39 = __toESM(require("@splunk/themes/pick"));
2654
+ __reExport(pick_exports2, require("@splunk/themes/pick"));
2655
+ var pick_default2 = "default" in defaultImport39 ? defaultImport39.default : defaultImport39;
2656
+
2657
+ // esm-externals:@splunk/visualizations-shared/configUtils
2658
+ var configUtils_exports = {};
2659
+ __export(configUtils_exports, {
2660
+ default: () => configUtils_default
2661
+ });
2662
+ var defaultImport40 = __toESM(require("@splunk/visualizations-shared/configUtils"));
2663
+ __reExport(configUtils_exports, require("@splunk/visualizations-shared/configUtils"));
2664
+ var configUtils_default = "default" in defaultImport40 ? defaultImport40.default : defaultImport40;
2665
+
2666
+ // src/common/configContext/singleValueContext.ts
2667
+ var defaultContext = {
2668
+ trendColorConfig: [
2582
2669
  {
2583
- label: (0, i18n_exports._)("Row height"),
2584
- option: "trellisRowHeight",
2585
- editor: "editor.number",
2670
+ to: 0,
2671
+ value: "#9E2520"
2672
+ },
2673
+ {
2674
+ from: 0,
2675
+ value: "#1C6B2D"
2676
+ }
2677
+ ],
2678
+ majorColorConfig: [
2679
+ { to: 20, value: "#D41F1F" },
2680
+ { from: 20, to: 40, value: "#D94E17" },
2681
+ { from: 40, to: 60, value: "#CBA700" },
2682
+ { from: 60, to: 80, value: "#669922" },
2683
+ { from: 80, value: "#118832" }
2684
+ ],
2685
+ majorColorMatchConfig: [{ match: "", value: "#5C33FF" }],
2686
+ trendValueCopy: "> trendValue",
2687
+ divisor: "> majorValue | subtract(trendValueCopy) | divideBy(100)",
2688
+ trendValuePercent: "> trendValue | divideBy(divisor)"
2689
+ };
2690
+
2691
+ // src/common/editorConfig/StaticMajorAndTrendLayout.js
2692
+ var StaticMajorAndTrendLayout = [
2693
+ [
2694
+ {
2695
+ label: (0, i18n_exports._)("Unit position"),
2696
+ // todo: we need a new editor combining unit and position
2697
+ option: "unitPosition",
2698
+ editor: "editor.select",
2586
2699
  editorProps: {
2587
- min: 1
2700
+ values: [
2701
+ { label: (0, i18n_exports._)("Before"), value: "before" },
2702
+ { label: (0, i18n_exports._)("After"), value: "after" }
2703
+ ]
2588
2704
  },
2589
- showEditor: ({ options }) => {
2590
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2591
- const isTrellisFeatureFlagOn = Boolean(
2592
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2593
- );
2594
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
2595
- }
2705
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
2706
+ },
2707
+ {
2708
+ label: (0, i18n_exports._)("Unit label"),
2709
+ option: "unit",
2710
+ editor: "editor.text",
2711
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
2596
2712
  }
2597
2713
  ],
2598
2714
  [
2599
2715
  {
2600
- label: (0, i18n_exports._)("Max number of components per page"),
2601
- option: "trellisPageCount",
2716
+ label: (0, i18n_exports._)("Precision"),
2717
+ option: "numberPrecision",
2602
2718
  editor: "editor.number",
2603
2719
  editorProps: {
2604
- min: 1
2720
+ min: 0,
2721
+ max: 20
2605
2722
  },
2606
- showEditor: ({ options }) => {
2607
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2608
- const isTrellisFeatureFlagOn = Boolean(
2609
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2610
- );
2611
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
2612
- }
2723
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
2613
2724
  }
2614
2725
  ]
2615
2726
  ];
2616
- var TrellisBackgroundColorEditor = {
2617
- label: (0, i18n_exports._)("Trellis background"),
2618
- option: "trellisBackgroundColor",
2727
+ var StaticMajorAndTrendLayout_default = StaticMajorAndTrendLayout;
2728
+
2729
+ // src/common/editorConfig/StaticBackgroundColorEditor.js
2730
+ var StaticBackgroundColorEditor = {
2731
+ label: (0, i18n_exports._)("Background color"),
2732
+ option: "backgroundColor",
2619
2733
  editor: "editor.color",
2620
- showEditor: ({ options }) => {
2621
- const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
2622
- const isTrellisFeatureFlagOn = Boolean(
2623
- featureFlagContext && featureFlagContext.visualizations_enableTrellis
2624
- );
2625
- return isTrellisFeatureFlagOn && options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
2626
- }
2734
+ showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.backgroundColor)
2627
2735
  };
2736
+ var StaticBackgroundColorEditor_default = StaticBackgroundColorEditor;
2628
2737
 
2629
- // src/common/utils/configUtils.ts
2630
- function enhanceConfig(vizConfig) {
2631
- const enhancedConfig = __spreadValues({}, vizConfig);
2632
- enhancedConfig.editorConfig = vizConfig.editorConfig.map(
2633
- (config3) => {
2634
- return __spreadProps(__spreadValues({}, config3), { open: config3.open || false });
2635
- }
2636
- );
2637
- return enhancedConfig;
2638
- }
2639
- function hasCompatibleContexts(vizContext, presetContext) {
2640
- const presetContextKeys = Object.keys(presetContext);
2641
- return presetContextKeys.every(
2642
- (contextKey) => presetContext[contextKey] === void 0 && vizContext[contextKey] === void 0 || presetContext[contextKey] !== void 0 && vizContext[contextKey] !== void 0
2643
- );
2644
- }
2645
- function hasCompatibleOptions(vizOptions, presetOptions) {
2646
- const presetOptionKeys = Object.keys(presetOptions);
2647
- return presetOptionKeys.every(
2648
- (optionKey) => (0, configUtils_exports.isDynamicOption)(presetOptions[optionKey]) === (0, configUtils_exports.isDynamicOption)(vizOptions[optionKey])
2649
- );
2650
- }
2651
- function getInitialPreset(vizContext, vizOptions, presets2) {
2652
- return presets2.find((preset) => {
2653
- const presetContext = (0, lodash_exports.get)(preset, ["value", "context"], {});
2654
- const presetOptions = (0, lodash_exports.get)(preset, ["value", "options"], {});
2655
- const presetContextKeys = Object.keys(presetContext);
2656
- const presetOptionKeys = Object.keys(presetOptions);
2657
- if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
2658
- return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
2659
- });
2660
- }
2661
-
2662
- // src/SingleValueIcon/config.ts
2663
- var dataContract = {
2664
- requiredDataSources: [
2665
- {
2666
- name: "primary",
2667
- description: "DataSource that powers the visualization"
2738
+ // src/common/editorConfig/StaticIconColorEditor.js
2739
+ var StaticIconColorEditor = [
2740
+ {
2741
+ label: (0, i18n_exports._)("Icon"),
2742
+ option: "iconColor",
2743
+ editor: "editor.color",
2744
+ showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.iconColor),
2745
+ editorProps: {
2746
+ labelPosition: "top",
2747
+ value: null,
2748
+ palette: [null, ...colorConstants_exports.COLOR_EDITOR_PALETTE]
2668
2749
  }
2669
- ],
2670
- optionalDataSources: [],
2671
- initialRequestParams: {
2672
- primary: { offset: 0, count: 1e4 }
2673
2750
  }
2751
+ ];
2752
+ var StaticIconColorEditor_default = StaticIconColorEditor;
2753
+
2754
+ // src/common/editorConfig/StaticMajorColorEditor.js
2755
+ var StaticMajorColorEditor = {
2756
+ label: (0, i18n_exports._)("Major value"),
2757
+ option: "majorColor",
2758
+ editor: "editor.color",
2759
+ showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.majorColor)
2674
2760
  };
2675
- var size = {
2676
- initialWidth: 250,
2677
- initialHeight: 250
2678
- };
2679
- var basePresetContext = {
2680
- iconColorEditorConfig: void 0,
2681
- majorColorEditorConfig: void 0,
2682
- trendColorEditorConfig: void 0,
2683
- backgroundColorEditorConfig: void 0
2684
- };
2685
- var basePresetOptions = {
2686
- iconColor: void 0,
2687
- majorColor: void 0,
2688
- trendColor: void 0,
2689
- backgroundColor: void 0
2761
+ var StaticMajorColorEditor_default = StaticMajorColorEditor;
2762
+
2763
+ // src/common/editorConfig/StaticTrendColorEditor.js
2764
+ var StaticTrendColorEditor = {
2765
+ label: (0, i18n_exports._)("Trend value"),
2766
+ option: "trendColor",
2767
+ editor: "editor.color",
2768
+ showEditor: ({ options }) => !(0, configUtils_exports.isDynamicOption)(options.trendColor),
2769
+ isDisabled: ({ options }) => options.trendDisplay === "off"
2690
2770
  };
2691
- var presets = [
2692
- {
2693
- // dummy context variables to allow for resetting of unused context states
2694
- label: (0, i18n_exports._)("None"),
2695
- name: "singleValueIcon.none",
2696
- value: {
2697
- context: __spreadValues({}, basePresetContext),
2698
- options: __spreadValues({}, basePresetOptions)
2699
- }
2700
- },
2701
- {
2702
- label: (0, i18n_exports._)("Icon"),
2703
- name: "singleValueIcon.icon",
2704
- value: {
2705
- context: __spreadProps(__spreadValues({}, basePresetContext), {
2706
- iconColorEditorConfig: defaultContext.majorColorConfig
2707
- }),
2708
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
2709
- iconColor: "> majorValue | rangeValue(iconColorEditorConfig)"
2710
- })
2711
- }
2712
- },
2713
- {
2714
- label: (0, i18n_exports._)("Major value"),
2715
- name: "singleValueIcon.majorValue",
2716
- value: {
2717
- context: __spreadProps(__spreadValues({}, basePresetContext), {
2718
- majorColorEditorConfig: defaultContext.majorColorConfig
2719
- }),
2720
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
2721
- majorColor: "> majorValue | rangeValue(majorColorEditorConfig)"
2722
- })
2771
+ var StaticTrendColorEditor_default = StaticTrendColorEditor;
2772
+
2773
+ // src/common/editorConfig/DynamicMajorColorEditor.js
2774
+ var getDynamicMajorColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
2775
+ label: (0, i18n_exports._)("Major value"),
2776
+ option: "majorColor",
2777
+ context: "majorColorEditorConfig",
2778
+ editor: "editor.dynamicColor",
2779
+ showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.majorColor),
2780
+ editorProps: {
2781
+ labelPosition: "top",
2782
+ flyoutTitle: (0, i18n_exports._)("Dynamic coloring: major value"),
2783
+ formatters: [
2784
+ {
2785
+ label: (0, i18n_exports._)("Ranges"),
2786
+ value: "rangeValue",
2787
+ defaults: {
2788
+ majorValue: defaultContext2.majorColorConfig
2789
+ }
2790
+ },
2791
+ {
2792
+ label: (0, i18n_exports._)("Matches"),
2793
+ value: "matchValue",
2794
+ defaults: {
2795
+ majorValue: defaultContext2.majorColorMatchConfig
2796
+ }
2797
+ }
2798
+ ],
2799
+ dataSelectors: [
2800
+ {
2801
+ label: (0, i18n_exports._)("Major value"),
2802
+ value: "majorValue"
2803
+ }
2804
+ ],
2805
+ defaultPalettesConfig: defaultPalettesConfig2
2806
+ }
2807
+ });
2808
+
2809
+ // src/common/editorConfig/DynamicTrendColorEditor.js
2810
+ var getDynamicTrendColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
2811
+ label: (0, i18n_exports._)("Trend value"),
2812
+ option: "trendColor",
2813
+ context: "trendColorEditorConfig",
2814
+ editor: "editor.dynamicColor",
2815
+ showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.trendColor),
2816
+ editorProps: {
2817
+ labelPosition: "top",
2818
+ flyoutTitle: (0, i18n_exports._)("Dynamic coloring: trend value"),
2819
+ formatters: [
2820
+ {
2821
+ label: (0, i18n_exports._)("Ranges"),
2822
+ value: "rangeValue",
2823
+ defaults: {
2824
+ trendValue: defaultContext2.trendColorConfig
2825
+ }
2826
+ }
2827
+ ],
2828
+ dataSelectors: [
2829
+ {
2830
+ label: (0, i18n_exports._)("Trend value"),
2831
+ value: "trendValue"
2832
+ }
2833
+ ],
2834
+ defaultPalettesConfig: defaultPalettesConfig2
2835
+ }
2836
+ });
2837
+
2838
+ // src/common/editorConfig/DynamicBackgroundColorEditor.js
2839
+ var getDynamicBackgroundColorEditor = ({ defaultContext: defaultContext2, defaultPalettesConfig: defaultPalettesConfig2 }) => ({
2840
+ label: (0, i18n_exports._)("Background color"),
2841
+ option: "backgroundColor",
2842
+ context: "backgroundColorEditorConfig",
2843
+ editor: "editor.dynamicColor",
2844
+ showEditor: ({ options }) => (0, configUtils_exports.isDynamicOption)(options.backgroundColor),
2845
+ editorProps: {
2846
+ labelPosition: "top",
2847
+ flyoutTitle: (0, i18n_exports._)("Dynamic coloring: background"),
2848
+ formatters: [
2849
+ {
2850
+ label: (0, i18n_exports._)("Ranges"),
2851
+ value: "rangeValue",
2852
+ defaults: {
2853
+ majorValue: defaultContext2.majorColorConfig,
2854
+ trendValue: defaultContext2.trendColorConfig
2855
+ }
2856
+ },
2857
+ {
2858
+ label: (0, i18n_exports._)("Matches"),
2859
+ value: "matchValue",
2860
+ defaults: {
2861
+ majorValue: defaultContext2.majorColorMatchConfig
2862
+ }
2863
+ }
2864
+ ],
2865
+ dataSelectors: [
2866
+ {
2867
+ label: (0, i18n_exports._)("Major Value"),
2868
+ value: "majorValue"
2869
+ },
2870
+ {
2871
+ label: (0, i18n_exports._)("Trend"),
2872
+ value: "trendValue"
2873
+ }
2874
+ ],
2875
+ defaultPalettesConfig: defaultPalettesConfig2
2876
+ }
2877
+ });
2878
+
2879
+ // src/common/editorConfig/TrellisEditors.ts
2880
+ var isTrellisFeatureFlagOn = ({ featureFlags }) => {
2881
+ return Boolean(featureFlags == null ? void 0 : featureFlags.visualizations_enableTrellis);
2882
+ };
2883
+ var isTrellisEnabled = ({ options, featureFlags }) => {
2884
+ const { splitByLayout = visualization_schemas_exports.LAYOUT_TYPE.Off } = options;
2885
+ return isTrellisFeatureFlagOn({ featureFlags }) && splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis;
2886
+ };
2887
+ var TrellisEditorConfig = [
2888
+ [
2889
+ {
2890
+ label: (0, i18n_exports._)("Trellis layout"),
2891
+ option: "splitByLayout",
2892
+ editor: "editor.toggle",
2893
+ showEditor: isTrellisFeatureFlagOn
2723
2894
  }
2724
- },
2725
- {
2726
- label: (0, i18n_exports._)("Trend value"),
2727
- name: "singleValueIcon.trend",
2728
- value: {
2729
- context: __spreadProps(__spreadValues({}, basePresetContext), {
2730
- trendColorEditorConfig: defaultContext.trendColorConfig
2731
- }),
2732
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
2733
- trendColor: "> trendValue | rangeValue(trendColorEditorConfig)"
2734
- })
2895
+ ],
2896
+ [
2897
+ {
2898
+ label: (0, i18n_exports._)("Split by"),
2899
+ option: "trellisSplitBy",
2900
+ editor: "editor.trellisSplitBy",
2901
+ editorProps: {
2902
+ dataSourceKey: "primary"
2903
+ },
2904
+ showEditor: isTrellisEnabled
2735
2905
  }
2736
- },
2737
- {
2738
- label: (0, i18n_exports._)("Icon and Major value"),
2739
- name: "singleValueIcon.iconAndMajorValue",
2740
- value: {
2741
- context: __spreadProps(__spreadValues({}, basePresetContext), {
2742
- iconColorEditorConfig: defaultContext.majorColorConfig,
2743
- majorColorEditorConfig: defaultContext.majorColorConfig
2744
- }),
2745
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
2746
- iconColor: "> majorValue | rangeValue(iconColorEditorConfig)",
2747
- majorColor: "> majorValue | rangeValue(majorColorEditorConfig)"
2748
- })
2906
+ ],
2907
+ [
2908
+ {
2909
+ label: (0, i18n_exports._)("Number of columns"),
2910
+ option: "trellisColumns",
2911
+ editor: "editor.number",
2912
+ editorProps: {
2913
+ min: 1
2914
+ },
2915
+ placeholder: (0, i18n_exports._)("Auto"),
2916
+ showEditor: isTrellisEnabled
2749
2917
  }
2750
- },
2751
- {
2752
- label: (0, i18n_exports._)("Background"),
2753
- name: "singleValueIcon.background",
2754
- value: {
2755
- context: __spreadProps(__spreadValues({}, basePresetContext), {
2756
- backgroundColorEditorConfig: defaultContext.majorColorConfig
2757
- }),
2758
- options: __spreadProps(__spreadValues({}, basePresetOptions), {
2759
- backgroundColor: "> majorValue | rangeValue(backgroundColorEditorConfig)"
2760
- })
2918
+ ],
2919
+ [
2920
+ {
2921
+ label: (0, i18n_exports._)("Min column width"),
2922
+ option: "trellisMinColumnWidth",
2923
+ editor: "editor.number",
2924
+ editorProps: {
2925
+ min: 1
2926
+ },
2927
+ showEditor: isTrellisEnabled
2928
+ },
2929
+ {
2930
+ label: (0, i18n_exports._)("Row height"),
2931
+ option: "trellisRowHeight",
2932
+ editor: "editor.number",
2933
+ editorProps: {
2934
+ min: 1
2935
+ },
2936
+ showEditor: isTrellisEnabled
2761
2937
  }
2762
- }
2938
+ ],
2939
+ [
2940
+ {
2941
+ label: (0, i18n_exports._)("Max number of components per page"),
2942
+ option: "trellisPageCount",
2943
+ editor: "editor.number",
2944
+ editorProps: {
2945
+ min: 1
2946
+ },
2947
+ showEditor: isTrellisEnabled
2948
+ }
2949
+ ]
2763
2950
  ];
2764
- var themes = {
2765
- defaultFontColor: (props) => pick_default2({
2766
- enterprise: {
2767
- dark: variables_default.textColor(props),
2768
- light: variables_default.gray20(props)
2769
- },
2770
- prisma: variables_default.contentColorActive(props)
2771
- })(props),
2772
- defaultBlockFontColor: (props) => pick_default2({
2773
- enterprise: variables_default.white(props),
2774
- prisma: variables_default.contentColorActive(props)
2775
- })(props)
2951
+ var TimechartTrellisEditorConfig = [
2952
+ [
2953
+ {
2954
+ label: (0, i18n_exports._)("Trellis layout"),
2955
+ option: "splitByLayout",
2956
+ editor: "editor.toggle",
2957
+ showEditor: isTrellisFeatureFlagOn,
2958
+ // add help text for timecharts
2959
+ editorProps: {
2960
+ help: (0, i18n_exports._)(
2961
+ "Y2-axis and overlay field configurations are not supported when trellis is enabled."
2962
+ ),
2963
+ helpFormat: "under"
2964
+ }
2965
+ }
2966
+ ],
2967
+ ...TrellisEditorConfig.slice(1),
2968
+ [
2969
+ {
2970
+ label: (0, i18n_exports._)("Shared y-axis scale"),
2971
+ option: "trellisSharedScale",
2972
+ editor: "editor.checkbox",
2973
+ showEditor: isTrellisEnabled
2974
+ }
2975
+ ]
2976
+ ];
2977
+ var TrellisBackgroundColorEditor = {
2978
+ label: (0, i18n_exports._)("Trellis background"),
2979
+ option: "trellisBackgroundColor",
2980
+ editor: "editor.color",
2981
+ showEditor: isTrellisEnabled
2776
2982
  };
2777
- var editorConfig = [
2778
- {
2779
- label: (0, i18n_exports._)("Data configurations"),
2780
- layout: [
2781
- [
2782
- {
2783
- label: (0, i18n_exports._)("Value"),
2784
- editor: "editor.columnSelector",
2785
- option: "majorValue",
2786
- context: "valuesContext",
2787
- editorProps: {
2788
- dataSourceKey: "primary",
2789
- prepareValue: (definition) => {
2790
- const {
2791
- options: { majorValue: baseSPL }
2792
- } = definition;
2793
- return {
2794
- context: {},
2795
- options: {
2796
- majorValue: `${baseSPL} | lastPoint()`,
2797
- trendValue: `${baseSPL} | delta(-2)`
2798
- }
2799
- };
2983
+
2984
+ // src/common/utils/configUtils.ts
2985
+ function enhanceConfig(vizConfig) {
2986
+ const enhancedConfig = __spreadValues({}, vizConfig);
2987
+ enhancedConfig.editorConfig = vizConfig.editorConfig.map(
2988
+ (config3) => {
2989
+ return __spreadProps(__spreadValues({}, config3), { open: config3.open || false });
2990
+ }
2991
+ );
2992
+ return enhancedConfig;
2993
+ }
2994
+ function hasCompatibleContexts(vizContext, presetContext) {
2995
+ const presetContextKeys = Object.keys(presetContext);
2996
+ return presetContextKeys.every(
2997
+ (contextKey) => presetContext[contextKey] === void 0 && vizContext[contextKey] === void 0 || presetContext[contextKey] !== void 0 && vizContext[contextKey] !== void 0
2998
+ );
2999
+ }
3000
+ function hasCompatibleOptions(vizOptions, presetOptions) {
3001
+ const presetOptionKeys = Object.keys(presetOptions);
3002
+ return presetOptionKeys.every(
3003
+ (optionKey) => (0, configUtils_exports.isDynamicOption)(presetOptions[optionKey]) === (0, configUtils_exports.isDynamicOption)(vizOptions[optionKey])
3004
+ );
3005
+ }
3006
+ function getInitialPreset(vizContext, vizOptions, presets2) {
3007
+ return presets2.find((preset) => {
3008
+ const presetContext = (0, lodash_exports.get)(preset, ["value", "context"], {});
3009
+ const presetOptions = (0, lodash_exports.get)(preset, ["value", "options"], {});
3010
+ const presetContextKeys = Object.keys(presetContext);
3011
+ const presetOptionKeys = Object.keys(presetOptions);
3012
+ if (presetContextKeys.length === 0 || presetOptionKeys.length === 0) return false;
3013
+ return hasCompatibleContexts(vizContext, presetContext) && hasCompatibleOptions(vizOptions, presetOptions);
3014
+ });
3015
+ }
3016
+
3017
+ // src/SingleValueIcon/config.ts
3018
+ var dataContract = {
3019
+ requiredDataSources: [
3020
+ {
3021
+ name: "primary",
3022
+ description: "DataSource that powers the visualization"
3023
+ }
3024
+ ],
3025
+ optionalDataSources: [],
3026
+ initialRequestParams: {
3027
+ primary: { offset: 0, count: 1e4 }
3028
+ }
3029
+ };
3030
+ var size = {
3031
+ initialWidth: 250,
3032
+ initialHeight: 250
3033
+ };
3034
+ var basePresetContext = {
3035
+ iconColorEditorConfig: void 0,
3036
+ majorColorEditorConfig: void 0,
3037
+ trendColorEditorConfig: void 0,
3038
+ backgroundColorEditorConfig: void 0
3039
+ };
3040
+ var basePresetOptions = {
3041
+ iconColor: void 0,
3042
+ majorColor: void 0,
3043
+ trendColor: void 0,
3044
+ backgroundColor: void 0
3045
+ };
3046
+ var presets = [
3047
+ {
3048
+ // dummy context variables to allow for resetting of unused context states
3049
+ label: (0, i18n_exports._)("None"),
3050
+ name: "singleValueIcon.none",
3051
+ value: {
3052
+ context: __spreadValues({}, basePresetContext),
3053
+ options: __spreadValues({}, basePresetOptions)
3054
+ }
3055
+ },
3056
+ {
3057
+ label: (0, i18n_exports._)("Icon"),
3058
+ name: "singleValueIcon.icon",
3059
+ value: {
3060
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3061
+ iconColorEditorConfig: defaultContext.majorColorConfig
3062
+ }),
3063
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3064
+ iconColor: "> majorValue | rangeValue(iconColorEditorConfig)"
3065
+ })
3066
+ }
3067
+ },
3068
+ {
3069
+ label: (0, i18n_exports._)("Major value"),
3070
+ name: "singleValueIcon.majorValue",
3071
+ value: {
3072
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3073
+ majorColorEditorConfig: defaultContext.majorColorConfig
3074
+ }),
3075
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3076
+ majorColor: "> majorValue | rangeValue(majorColorEditorConfig)"
3077
+ })
3078
+ }
3079
+ },
3080
+ {
3081
+ label: (0, i18n_exports._)("Trend value"),
3082
+ name: "singleValueIcon.trend",
3083
+ value: {
3084
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3085
+ trendColorEditorConfig: defaultContext.trendColorConfig
3086
+ }),
3087
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3088
+ trendColor: "> trendValue | rangeValue(trendColorEditorConfig)"
3089
+ })
3090
+ }
3091
+ },
3092
+ {
3093
+ label: (0, i18n_exports._)("Icon and Major value"),
3094
+ name: "singleValueIcon.iconAndMajorValue",
3095
+ value: {
3096
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3097
+ iconColorEditorConfig: defaultContext.majorColorConfig,
3098
+ majorColorEditorConfig: defaultContext.majorColorConfig
3099
+ }),
3100
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3101
+ iconColor: "> majorValue | rangeValue(iconColorEditorConfig)",
3102
+ majorColor: "> majorValue | rangeValue(majorColorEditorConfig)"
3103
+ })
3104
+ }
3105
+ },
3106
+ {
3107
+ label: (0, i18n_exports._)("Background"),
3108
+ name: "singleValueIcon.background",
3109
+ value: {
3110
+ context: __spreadProps(__spreadValues({}, basePresetContext), {
3111
+ backgroundColorEditorConfig: defaultContext.majorColorConfig
3112
+ }),
3113
+ options: __spreadProps(__spreadValues({}, basePresetOptions), {
3114
+ backgroundColor: "> majorValue | rangeValue(backgroundColorEditorConfig)"
3115
+ })
3116
+ }
3117
+ }
3118
+ ];
3119
+ var themes = {
3120
+ defaultFontColor: (props) => pick_default2({
3121
+ enterprise: {
3122
+ dark: variables_default.textColor(props),
3123
+ light: variables_default.gray20(props)
3124
+ },
3125
+ prisma: variables_default.contentColorActive(props)
3126
+ })(props),
3127
+ defaultBlockFontColor: (props) => pick_default2({
3128
+ enterprise: variables_default.white(props),
3129
+ prisma: variables_default.contentColorActive(props)
3130
+ })(props)
3131
+ };
3132
+ var editorConfig = [
3133
+ {
3134
+ label: (0, i18n_exports._)("Data configurations"),
3135
+ layout: [
3136
+ [
3137
+ {
3138
+ label: (0, i18n_exports._)("Value"),
3139
+ editor: "editor.columnSelector",
3140
+ option: "majorValue",
3141
+ context: "valuesContext",
3142
+ editorProps: {
3143
+ dataSourceKey: "primary",
3144
+ prepareValue: (definition) => {
3145
+ const {
3146
+ options: { majorValue: baseSPL }
3147
+ } = definition;
3148
+ return {
3149
+ context: {},
3150
+ options: {
3151
+ majorValue: `${baseSPL} | lastPoint()`,
3152
+ trendValue: `${baseSPL} | delta(-2)`
3153
+ }
3154
+ };
2800
3155
  }
2801
3156
  },
2802
3157
  isDisabled: ({ options }) => options.splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis
@@ -2888,458 +3243,152 @@ var editorConfig = [
2888
3243
  value: "trendValue"
2889
3244
  }
2890
3245
  ],
2891
- defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig
2892
- }
2893
- }
2894
- ],
2895
- [
2896
- __spreadProps(__spreadValues({}, StaticMajorColorEditor_default), {
2897
- editorProps: {
2898
- themes
2899
- }
2900
- })
2901
- ],
2902
- [getDynamicMajorColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
2903
- [
2904
- __spreadProps(__spreadValues({}, StaticTrendColorEditor_default), {
2905
- editorProps: {
2906
- themes
2907
- }
2908
- })
2909
- ],
2910
- [getDynamicTrendColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
2911
- [
2912
- __spreadProps(__spreadValues({}, StaticBackgroundColorEditor_default), {
2913
- editorProps: {
2914
- themes
2915
- }
2916
- })
2917
- ],
2918
- [
2919
- __spreadProps(__spreadValues({}, TrellisBackgroundColorEditor), {
2920
- editorProps: {
2921
- themes
2922
- }
2923
- })
2924
- ],
2925
- [getDynamicBackgroundColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
2926
- [
2927
- {
2928
- label: (0, i18n_exports._)("Major value size (px)"),
2929
- option: "majorFontSize",
2930
- editor: "editor.number",
2931
- editorProps: {
2932
- min: 1
2933
- },
2934
- placeholder: (0, i18n_exports._)("Auto"),
2935
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
2936
- },
2937
- {
2938
- label: (0, i18n_exports._)("Trend value size (px)"),
2939
- option: "trendFontSize",
2940
- editor: "editor.number",
2941
- editorProps: {
2942
- min: 1
2943
- },
2944
- placeholder: (0, i18n_exports._)("Auto"),
2945
- showEditor: ({ options }) => options.showValue || options.showValue === void 0,
2946
- isDisabled: ({ options }) => options.trendDisplay === "off"
2947
- }
2948
- ],
2949
- [
2950
- {
2951
- label: (0, i18n_exports._)("Major value abbreviation"),
2952
- option: "shouldAbbreviateMajorValue",
2953
- editor: "editor.checkbox"
2954
- }
2955
- ],
2956
- [
2957
- {
2958
- label: (0, i18n_exports._)("Trend value abbreviation"),
2959
- option: "shouldAbbreviateTrendValue",
2960
- editor: "editor.checkbox"
2961
- }
2962
- ],
2963
- [
2964
- {
2965
- label: (0, i18n_exports._)("Alignment"),
2966
- editor: "editor.radioBar",
2967
- option: "align",
2968
- editorProps: {
2969
- values: [
2970
- { label: (0, i18n_exports._)("Left"), value: "left" },
2971
- { label: (0, i18n_exports._)("Center"), value: "center" },
2972
- { label: (0, i18n_exports._)("Right"), value: "right" }
2973
- ]
2974
- },
2975
- showEditor: ({ options }) => options.showValue || options.showValue === void 0
2976
- }
2977
- ]
2978
- ]
2979
- }
2980
- ];
2981
- var config = {
2982
- /**
2983
- * unique viz key
2984
- */
2985
- key: "splunk.singlevalueicon",
2986
- /**
2987
- * viz name
2988
- */
2989
- name: (0, i18n_exports._)("Single value icon"),
2990
- category: "Single Value" /* SINGLE_VALUE */,
2991
- /**
2992
- * viz icon
2993
- */
2994
- icon: null,
2995
- dataContract,
2996
- size,
2997
- defaultContext,
2998
- optionsSchema: visualization_schemas_exports.singleValueIconOptionsSchema,
2999
- editorConfig,
3000
- events: {
3001
- "value.click": {
3002
- description: "trigger when user clicks major value or icon",
3003
- payloadKeys: ["majorValue", "trendValue", "icon"]
3004
- }
3005
- },
3006
- supports: ["dynamic-options" /* DYNAMIC_OPTIONS */, "events" /* EVENTS */, "trellis" /* TRELLIS */],
3007
- themes
3008
- };
3009
- var config_default = enhanceConfig(config);
3010
-
3011
- // esm-externals:@splunk/react-ui/Paginator
3012
- var Paginator_exports = {};
3013
- __export(Paginator_exports, {
3014
- default: () => Paginator_default
3015
- });
3016
- var defaultImport40 = __toESM(require("@splunk/react-ui/Paginator"));
3017
- __reExport(Paginator_exports, require("@splunk/react-ui/Paginator"));
3018
- var Paginator_default = "default" in defaultImport40 ? defaultImport40.default : defaultImport40;
3019
-
3020
- // esm-externals:@splunk/themes
3021
- var themes_exports = {};
3022
- __export(themes_exports, {
3023
- default: () => themes_default
3024
- });
3025
- var defaultImport41 = __toESM(require("@splunk/themes"));
3026
- __reExport(themes_exports, require("@splunk/themes"));
3027
- var themes_default = "default" in defaultImport41 ? defaultImport41.default : defaultImport41;
3028
-
3029
- // esm-externals:@splunk/themes/useSplunkTheme
3030
- var useSplunkTheme_exports = {};
3031
- __export(useSplunkTheme_exports, {
3032
- default: () => useSplunkTheme_default
3033
- });
3034
- var defaultImport42 = __toESM(require("@splunk/themes/useSplunkTheme"));
3035
- __reExport(useSplunkTheme_exports, require("@splunk/themes/useSplunkTheme"));
3036
- var useSplunkTheme_default = "default" in defaultImport42 ? defaultImport42.default : defaultImport42;
3037
-
3038
- // esm-externals:@splunk/visualizations-shared/trellisUtils
3039
- var trellisUtils_exports = {};
3040
- __export(trellisUtils_exports, {
3041
- default: () => trellisUtils_default
3042
- });
3043
- var defaultImport43 = __toESM(require("@splunk/visualizations-shared/trellisUtils"));
3044
- __reExport(trellisUtils_exports, require("@splunk/visualizations-shared/trellisUtils"));
3045
- var trellisUtils_default = "default" in defaultImport43 ? defaultImport43.default : defaultImport43;
3046
-
3047
- // src/common/utils/trellisUtils.ts
3048
- var AGGREGATIONS = "aggregations";
3049
- var dataSourcesSplitByAggregationsUnknown = (dataSource) => {
3050
- var _a, _b, _c, _d;
3051
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3052
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3053
- let splitDataSources = null;
3054
- let errorCode = null;
3055
- if (fields && fields.length) {
3056
- splitDataSources = {};
3057
- for (let i = 0; i < fields.length; i += 1) {
3058
- const fieldName = fields[i].name;
3059
- if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
3060
- splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
3061
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3062
- );
3063
- splitDataSources[fieldName].primary.data.fields = [fields[i]];
3064
- splitDataSources[fieldName].primary.data.columns = [columns[i]];
3065
- }
3066
- }
3067
- } else {
3068
- errorCode = "INVALID_SPLIT_BY_FIELD";
3069
- }
3070
- return { splitDataSources, errorCode };
3071
- };
3072
- var dataSourcesSplitByAggregationsTimechartAndChart = (dataSource) => {
3073
- var _a, _b, _c, _d;
3074
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3075
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3076
- let splitDataSources = null;
3077
- let splitByFields = [];
3078
- let errorCode = null;
3079
- if (typeof fields[0] !== "string") {
3080
- splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
3081
- }
3082
- if (splitByFields && splitByFields.length > 0) {
3083
- splitDataSources = {};
3084
- splitByFields.forEach((splitByField) => {
3085
- splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
3086
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3087
- );
3088
- splitDataSources[splitByField].primary.data.fields = [fields[0]];
3089
- splitDataSources[splitByField].primary.data.columns = [columns[0]];
3090
- fields.forEach((field, idx) => {
3091
- const fieldName = field == null ? void 0 : field.name;
3092
- if (fieldName !== "_time" && !(fieldName == null ? void 0 : fieldName.startsWith("_")) && field.data_source === splitByField) {
3093
- splitDataSources[splitByField].primary.data.fields.push(field);
3094
- splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
3095
- }
3096
- });
3097
- });
3098
- } else if ((!splitByFields || !splitByFields.length) && fields.length > 1) {
3099
- splitDataSources = {};
3100
- for (let i = 1; i < fields.length; i += 1) {
3101
- const fieldName = fields[i].name;
3102
- if (!(fieldName == null ? void 0 : fieldName.startsWith("_"))) {
3103
- splitDataSources[fieldName] = (0, lodash_exports.cloneDeep)(
3104
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3105
- );
3106
- splitDataSources[fieldName].primary.data.fields = [fields[0], fields[i]];
3107
- splitDataSources[fieldName].primary.data.columns = [columns[0], columns[i]];
3108
- }
3109
- }
3110
- } else {
3111
- errorCode = "INVALID_SPLIT_BY_FIELD";
3112
- }
3113
- return { splitDataSources, errorCode };
3114
- };
3115
- var dataSourcesSplitByAggregationsStats = (dataSource) => {
3116
- var _a, _b, _c, _d;
3117
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3118
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3119
- let splitDataSources = null;
3120
- let splitByFields = [];
3121
- let errorCode = null;
3122
- if (typeof fields[0] !== "string") {
3123
- splitByFields = (0, trellisUtils_exports.extractDataSourceAggregationKeysStats)(fields);
3124
- }
3125
- if (splitByFields && splitByFields.length > 0) {
3126
- splitDataSources = {};
3127
- splitByFields.forEach((splitByField) => {
3128
- splitDataSources[splitByField] = (0, lodash_exports.cloneDeep)(
3129
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3130
- );
3131
- splitDataSources[splitByField].primary.data.fields = [fields[0]];
3132
- splitDataSources[splitByField].primary.data.columns = [columns[0]];
3133
- const idx = fields.findIndex((field) => field.name === splitByField);
3134
- if (idx > 0) {
3135
- splitDataSources[splitByField].primary.data.fields.push(fields[idx]);
3136
- splitDataSources[splitByField].primary.data.columns.push(columns[idx]);
3137
- }
3138
- });
3139
- } else {
3140
- errorCode = "INVALID_SPLIT_BY_FIELD";
3141
- }
3142
- return { splitDataSources, errorCode };
3143
- };
3144
- var dataSourcesSplitByModeTimechart = (dataSource, splitBy) => {
3145
- var _a, _b, _c, _d, _e;
3146
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3147
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3148
- let splitDataSources = null;
3149
- let splitByFields = [];
3150
- let errorCode = null;
3151
- if (typeof fields[0] !== "string") {
3152
- splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
3153
- }
3154
- if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
3155
- splitDataSources = {};
3156
- const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
3157
- const valueKeys = [];
3158
- for (let i = 1; i < fields.length; i += 1) {
3159
- if (!((_e = fields[i].name) == null ? void 0 : _e.startsWith("_"))) {
3160
- valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
3161
- }
3162
- }
3163
- valueKeys.forEach((val) => {
3164
- splitDataSources[val] = (0, lodash_exports.cloneDeep)(
3165
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3166
- );
3167
- splitDataSources[val].primary.data.fields = [
3168
- { name: fields[0].name },
3169
- ...dataSourceKeys.map((k) => ({
3170
- name: k
3171
- }))
3172
- ];
3173
- splitDataSources[val].primary.data.columns = [[...columns[0]]];
3174
- dataSourceKeys.forEach((dsKey) => {
3175
- fields.forEach((field, idx) => {
3176
- if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
3177
- splitDataSources[val].primary.data.columns.push([...columns[idx]]);
3178
- }
3179
- });
3180
- });
3181
- });
3182
- } else {
3183
- errorCode = "INVALID_SPLIT_BY_FIELD";
3184
- }
3185
- return { splitDataSources, errorCode };
3186
- };
3187
- var dataSourcesSplitByModeChart = (dataSource, splitBy) => {
3188
- var _a, _b, _c, _d;
3189
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3190
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3191
- let splitDataSources = null;
3192
- let splitByFields = [];
3193
- let errorCode = null;
3194
- if (typeof fields[0] !== "string") {
3195
- splitByFields = (0, trellisUtils_exports.extractSplitByFieldsChartFields)(fields);
3196
- }
3197
- if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
3198
- splitDataSources = {};
3199
- const splitByFieldIdx = splitByFields.findIndex((f) => f === splitBy);
3200
- const otherSplitBy = splitByFields.filter((f) => f !== splitBy);
3201
- const dataSourceKeys = (0, trellisUtils_exports.extractDataSourceAggregationKeysChart)(fields);
3202
- const nonDataSourceAggregations = [];
3203
- if (!dataSourceKeys.length && fields[0].groupby_rank === "0" && fields.length && !fields[1].groupby_rank) {
3204
- for (let i = 1; i < fields.length; i += 1) {
3205
- nonDataSourceAggregations.push(fields[i].name);
3206
- }
3207
- }
3208
- if (splitByFieldIdx === 0) {
3209
- const valueKeys = (0, lodash_exports.cloneDeep)(columns[0]);
3210
- valueKeys.forEach((val, idx) => {
3211
- splitDataSources[val] = (0, lodash_exports.cloneDeep)(
3212
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3213
- );
3214
- splitDataSources[val].primary.data.fields = [];
3215
- if (otherSplitBy.length) {
3216
- splitDataSources[val].primary.data.fields = [{ name: otherSplitBy[0] }];
3246
+ defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig
3247
+ }
3217
3248
  }
3218
- if (dataSourceKeys.length) {
3219
- const columnValues = [[]];
3220
- splitDataSources[val].primary.data.fields = [
3221
- ...splitDataSources[val].primary.data.fields,
3222
- ...dataSourceKeys.map((k) => ({
3223
- name: k
3224
- }))
3225
- ];
3226
- dataSourceKeys.forEach(() => {
3227
- columnValues.push([]);
3228
- });
3229
- for (let i = 1; i <= Math.ceil((fields.length - 1) / dataSourceKeys.length); i += 1) {
3230
- columnValues[0].push(
3231
- fields[i].splitby_value ? fields[i].splitby_value : fields[i].name
3232
- );
3233
- dataSourceKeys.forEach((dskey, dsIndx) => {
3234
- const mul = (fields.length - 1) / dataSourceKeys.length;
3235
- columnValues[dsIndx + 1].push(columns[i + dsIndx * mul][idx]);
3236
- });
3249
+ ],
3250
+ [
3251
+ __spreadProps(__spreadValues({}, StaticMajorColorEditor_default), {
3252
+ editorProps: {
3253
+ themes
3237
3254
  }
3238
- splitDataSources[val].primary.data.columns = columnValues;
3239
- } else if (nonDataSourceAggregations.length) {
3240
- const columnValues = [];
3241
- fields.forEach((aggregationField, fieldIdx) => {
3242
- if (fieldIdx > 0) {
3243
- splitDataSources[val].primary.data.fields.push(aggregationField);
3244
- columnValues.push([columns[fieldIdx][idx]]);
3245
- }
3246
- });
3247
- splitDataSources[val].primary.data.columns = columnValues;
3255
+ })
3256
+ ],
3257
+ [getDynamicMajorColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3258
+ [
3259
+ __spreadProps(__spreadValues({}, StaticTrendColorEditor_default), {
3260
+ editorProps: {
3261
+ themes
3262
+ }
3263
+ })
3264
+ ],
3265
+ [getDynamicTrendColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3266
+ [
3267
+ __spreadProps(__spreadValues({}, StaticBackgroundColorEditor_default), {
3268
+ editorProps: {
3269
+ themes
3270
+ }
3271
+ })
3272
+ ],
3273
+ [
3274
+ __spreadProps(__spreadValues({}, TrellisBackgroundColorEditor), {
3275
+ editorProps: {
3276
+ themes
3277
+ }
3278
+ })
3279
+ ],
3280
+ [getDynamicBackgroundColorEditor({ defaultContext, defaultPalettesConfig: PresetPalettes_exports.defaultPalettesConfig })],
3281
+ [
3282
+ {
3283
+ label: (0, i18n_exports._)("Major value size (px)"),
3284
+ option: "majorFontSize",
3285
+ editor: "editor.number",
3286
+ editorProps: {
3287
+ min: 1
3288
+ },
3289
+ placeholder: (0, i18n_exports._)("Auto"),
3290
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
3291
+ },
3292
+ {
3293
+ label: (0, i18n_exports._)("Trend value size (px)"),
3294
+ option: "trendFontSize",
3295
+ editor: "editor.number",
3296
+ editorProps: {
3297
+ min: 1
3298
+ },
3299
+ placeholder: (0, i18n_exports._)("Auto"),
3300
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0,
3301
+ isDisabled: ({ options }) => options.trendDisplay === "off"
3248
3302
  }
3249
- });
3250
- } else {
3251
- const valueKeys = [];
3252
- for (let i = 1; i < fields.length; i += 1) {
3253
- valueKeys.push(fields[i].splitby_value ? fields[i].splitby_value : fields[i].name);
3254
- }
3255
- valueKeys.forEach((val) => {
3256
- splitDataSources[val] = (0, lodash_exports.cloneDeep)(
3257
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3258
- );
3259
- splitDataSources[val].primary.data.fields = [
3260
- { name: otherSplitBy[0] },
3261
- ...dataSourceKeys.map((k) => ({
3262
- name: k
3263
- }))
3264
- ];
3265
- splitDataSources[val].primary.data.columns = [[...columns[0]]];
3266
- dataSourceKeys.forEach((dsKey) => {
3267
- fields.forEach((field, idx) => {
3268
- if (field.data_source === dsKey && (field.splitby_value === val || field.name === val)) {
3269
- splitDataSources[val].primary.data.columns.push([...columns[idx]]);
3270
- }
3271
- });
3272
- });
3273
- });
3274
- }
3275
- } else {
3276
- errorCode = "INVALID_SPLIT_BY_FIELD";
3277
- }
3278
- return { splitDataSources, errorCode };
3279
- };
3280
- var dataSourcesSplitByModeStatsorUnknown = (dataSource, splitBy, splitMode) => {
3281
- var _a, _b, _c, _d, _e, _f;
3282
- const fields = (_b = (_a = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _a.data) == null ? void 0 : _b.fields;
3283
- const columns = (_d = (_c = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _c.data) == null ? void 0 : _d.columns;
3284
- let splitDataSources = null;
3285
- let splitByFields = [];
3286
- let errorCode = null;
3287
- if (typeof fields[0] !== "string") {
3288
- splitByFields = splitMode !== trellisUtils_exports.UNKNOWN ? (0, trellisUtils_exports.extractSplitByFieldsForStats)(fields) : (0, trellisUtils_exports.extractSplitByFieldsForUnknown)(fields);
3289
- }
3290
- const splitByIndex = fields == null ? void 0 : fields.findIndex(
3291
- (field) => field === splitBy || field.name === splitBy
3292
- );
3293
- if (splitByFields && splitByFields.indexOf(splitBy) > -1) {
3294
- const splitByColumn = (_f = (_e = dataSource == null ? void 0 : dataSource.primary) == null ? void 0 : _e.data) == null ? void 0 : _f.columns[splitByIndex];
3295
- splitDataSources = {};
3296
- splitByColumn.forEach((val, idx) => {
3297
- if (!splitDataSources[val]) {
3298
- splitDataSources[val] = [idx];
3299
- } else {
3300
- splitDataSources[val].push(idx);
3301
- }
3302
- });
3303
- const cloneFields = (0, lodash_exports.cloneDeep)(fields);
3304
- cloneFields.splice(splitByIndex, 1);
3305
- const valueKeys = Object.keys(splitDataSources);
3306
- valueKeys.forEach((val) => {
3307
- const valIndices = (0, lodash_exports.cloneDeep)(splitDataSources[val]);
3308
- splitDataSources[val] = (0, lodash_exports.cloneDeep)(
3309
- (0, lodash_exports.omit)(dataSource, ["primary.data.fields", "primary.data.columns"])
3310
- );
3311
- splitDataSources[val].primary.data.fields = cloneFields;
3312
- splitDataSources[val].primary.data.columns = [];
3313
- columns.forEach((col, idx) => {
3314
- if (idx !== splitByIndex) {
3315
- const newCol = valIndices.map((valIdx) => col[valIdx]);
3316
- splitDataSources[val].primary.data.columns.push(newCol);
3303
+ ],
3304
+ [
3305
+ {
3306
+ label: (0, i18n_exports._)("Major value abbreviation"),
3307
+ option: "shouldAbbreviateMajorValue",
3308
+ editor: "editor.checkbox"
3317
3309
  }
3318
- });
3319
- });
3320
- } else {
3321
- errorCode = "INVALID_SPLIT_BY_FIELD";
3310
+ ],
3311
+ [
3312
+ {
3313
+ label: (0, i18n_exports._)("Trend value abbreviation"),
3314
+ option: "shouldAbbreviateTrendValue",
3315
+ editor: "editor.checkbox"
3316
+ }
3317
+ ],
3318
+ [
3319
+ {
3320
+ label: (0, i18n_exports._)("Alignment"),
3321
+ editor: "editor.radioBar",
3322
+ option: "align",
3323
+ editorProps: {
3324
+ values: [
3325
+ { label: (0, i18n_exports._)("Left"), value: "left" },
3326
+ { label: (0, i18n_exports._)("Center"), value: "center" },
3327
+ { label: (0, i18n_exports._)("Right"), value: "right" }
3328
+ ]
3329
+ },
3330
+ showEditor: ({ options }) => options.showValue || options.showValue === void 0
3331
+ }
3332
+ ]
3333
+ ]
3322
3334
  }
3323
- return { splitDataSources, errorCode };
3324
- };
3325
- var getTrellisDataSourcesBySplitMode = (splitMode, dataSources, trellisSplitBy) => {
3326
- let result = null;
3327
- try {
3328
- if (splitMode === trellisUtils_exports.TIMECHART) {
3329
- result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeTimechart(dataSources, trellisSplitBy);
3330
- } else if (splitMode === trellisUtils_exports.STATS) {
3331
- result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsStats(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.STATS);
3332
- } else if (splitMode === trellisUtils_exports.CHART) {
3333
- result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsTimechartAndChart(dataSources) : dataSourcesSplitByModeChart(dataSources, trellisSplitBy);
3334
- } else if (splitMode === trellisUtils_exports.UNKNOWN) {
3335
- result = trellisSplitBy === AGGREGATIONS ? dataSourcesSplitByAggregationsUnknown(dataSources) : dataSourcesSplitByModeStatsorUnknown(dataSources, trellisSplitBy, trellisUtils_exports.UNKNOWN);
3335
+ ];
3336
+ var config = {
3337
+ /**
3338
+ * unique viz key
3339
+ */
3340
+ key: "splunk.singlevalueicon",
3341
+ /**
3342
+ * viz name
3343
+ */
3344
+ name: (0, i18n_exports._)("Single value icon"),
3345
+ category: "Single Value" /* SINGLE_VALUE */,
3346
+ /**
3347
+ * viz icon
3348
+ */
3349
+ icon: null,
3350
+ dataContract,
3351
+ size,
3352
+ defaultContext,
3353
+ optionsSchema: visualization_schemas_exports.singleValueIconOptionsSchema,
3354
+ editorConfig,
3355
+ events: {
3356
+ "value.click": {
3357
+ description: "trigger when user clicks major value or icon",
3358
+ payloadKeys: ["majorValue", "trendValue", "icon"]
3336
3359
  }
3337
- } catch (ex) {
3338
- console.error("getTrellisDataSourcesBySplitMode ", ex);
3339
- result = { splitDataSources: null, errorCode: "UNKNOWN" };
3340
- }
3341
- return result;
3360
+ },
3361
+ supports: ["dynamic-options" /* DYNAMIC_OPTIONS */, "events" /* EVENTS */, "trellis" /* TRELLIS */],
3362
+ themes
3342
3363
  };
3364
+ var config_default = enhanceConfig(config);
3365
+
3366
+ // esm-externals:@splunk/react-ui/Paginator
3367
+ var Paginator_exports = {};
3368
+ __export(Paginator_exports, {
3369
+ default: () => Paginator_default
3370
+ });
3371
+ var defaultImport41 = __toESM(require("@splunk/react-ui/Paginator"));
3372
+ __reExport(Paginator_exports, require("@splunk/react-ui/Paginator"));
3373
+ var Paginator_default = "default" in defaultImport41 ? defaultImport41.default : defaultImport41;
3374
+
3375
+ // esm-externals:@splunk/themes
3376
+ var themes_exports = {};
3377
+ __export(themes_exports, {
3378
+ default: () => themes_default
3379
+ });
3380
+ var defaultImport42 = __toESM(require("@splunk/themes"));
3381
+ __reExport(themes_exports, require("@splunk/themes"));
3382
+ var themes_default = "default" in defaultImport42 ? defaultImport42.default : defaultImport42;
3383
+
3384
+ // esm-externals:@splunk/themes/useSplunkTheme
3385
+ var useSplunkTheme_exports = {};
3386
+ __export(useSplunkTheme_exports, {
3387
+ default: () => useSplunkTheme_default
3388
+ });
3389
+ var defaultImport43 = __toESM(require("@splunk/themes/useSplunkTheme"));
3390
+ __reExport(useSplunkTheme_exports, require("@splunk/themes/useSplunkTheme"));
3391
+ var useSplunkTheme_default = "default" in defaultImport43 ? defaultImport43.default : defaultImport43;
3343
3392
 
3344
3393
  // src/common/hocs/withTrellis.tsx
3345
3394
  var TrellisContainer = styled_components_default.div`
@@ -3403,7 +3452,11 @@ var withTrellis = (Viz) => {
3403
3452
  trellisMinColumnWidth,
3404
3453
  trellisRowHeight,
3405
3454
  splitByLayout,
3406
- trellisSplitBy
3455
+ trellisSplitBy,
3456
+ trellisSharedScale,
3457
+ stackMode,
3458
+ yAxisMin,
3459
+ yAxisMax
3407
3460
  } = mergedOptions;
3408
3461
  const colCount = trellisColumns > 0 ? trellisColumns : defaultOptions.trellisColumns;
3409
3462
  const pageCount = +trellisPageCount > 0 ? +trellisPageCount : defaultOptions.trellisPageCount;
@@ -3474,10 +3527,10 @@ var withTrellis = (Viz) => {
3474
3527
  [pageNum, pagedData]
3475
3528
  );
3476
3529
  const featureFlagContext = react_exports.useContext(FeatureFlagContext_default);
3477
- const isTrellisFeatureFlagOn = Boolean(
3530
+ const isTrellisFeatureFlagOn2 = Boolean(
3478
3531
  featureFlagContext && featureFlagContext.visualizations_enableTrellis
3479
3532
  );
3480
- if (!isTrellisFeatureFlagOn || !splitByLayout || splitByLayout !== visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
3533
+ if (!isTrellisFeatureFlagOn2 || !splitByLayout || splitByLayout !== visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
3481
3534
  return /* @__PURE__ */ react_exports.createElement(Viz, __spreadValues({}, opts));
3482
3535
  }
3483
3536
  if (splitByLayout === visualization_schemas_exports.LAYOUT_TYPE.Trellis) {
@@ -3506,6 +3559,13 @@ var withTrellis = (Viz) => {
3506
3559
  splitByKeys = splitByKeysModified;
3507
3560
  totalPages = splitByKeysModified ? Math.ceil(splitByKeysModified.length / pageCount) : 0;
3508
3561
  }
3562
+ const [calculatedMin, calculatedMax] = determineMinMax(
3563
+ modifiedDataSourceBySplitBy,
3564
+ trellisSharedScale,
3565
+ yAxisMin,
3566
+ yAxisMax,
3567
+ stackMode
3568
+ );
3509
3569
  return /* @__PURE__ */ react_exports.createElement(TrellisContainer, { height, width, backgroundColor: trellisBackgroundColor }, /* @__PURE__ */ react_exports.createElement(
3510
3570
  TrellisContainerGrid,
3511
3571
  {
@@ -3514,7 +3574,7 @@ var withTrellis = (Viz) => {
3514
3574
  colMinWidth,
3515
3575
  rowHeight
3516
3576
  },
3517
- pagedData && pagedData.map((splitByKey, idx) => /* @__PURE__ */ react_exports.createElement(
3577
+ pagedData == null ? void 0 : pagedData.map((splitByKey, idx) => /* @__PURE__ */ react_exports.createElement(
3518
3578
  "div",
3519
3579
  {
3520
3580
  className: "child",
@@ -3535,7 +3595,10 @@ var withTrellis = (Viz) => {
3535
3595
  trellisKey: splitByKey,
3536
3596
  trellisSplitBy: currTrellisSplitBy,
3537
3597
  dataSources: modifiedDataSourceBySplitBy[splitByKey],
3538
- options,
3598
+ options: __spreadProps(__spreadValues({}, options), {
3599
+ yAxisMin: calculatedMin,
3600
+ yAxisMax: calculatedMax
3601
+ }),
3539
3602
  key: `viz-${idx.toString()}`,
3540
3603
  height: containerHeight,
3541
3604
  width: containerWidth
@@ -3582,7 +3645,13 @@ var computeVizProps = ({
3582
3645
  trellisSplitBy
3583
3646
  };
3584
3647
  };
3585
- var viz = withTrellis_default(withDashboardViz_default({ ReactViz: SingleValueIcon_default, vizConfig: config_default, computeVizProps }));
3648
+ var computeVizPropsBeforeEval = (options) => {
3649
+ const trendColor = getTrendColorWithPercent(options);
3650
+ return __spreadValues({}, trendColor);
3651
+ };
3652
+ var viz = withTrellis_default(
3653
+ withDashboardViz_default({ ReactViz: SingleValueIcon_default, vizConfig: config_default, computeVizProps, computeVizPropsBeforeEval })
3654
+ );
3586
3655
  var { themes: themes2 } = config_default;
3587
3656
  var SingleValueIcon_default2 = viz;
3588
3657
  //# sourceMappingURL=SingleValueIcon.js.map