@splunk/visualizations 27.5.0 → 28.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/Area.config.js +19 -21
  2. package/Area.config.js.map +3 -3
  3. package/Area.js +54 -32
  4. package/Area.js.map +3 -3
  5. package/Bar.config.js +18 -21
  6. package/Bar.config.js.map +3 -3
  7. package/Bar.js +48 -31
  8. package/Bar.js.map +3 -3
  9. package/Bubble.config.js +39 -44
  10. package/Bubble.config.js.map +4 -4
  11. package/Bubble.js +69 -51
  12. package/Bubble.js.map +4 -4
  13. package/CHANGELOG.external.md +35 -7
  14. package/ChoroplethSvg.config.js +47 -43
  15. package/ChoroplethSvg.config.js.map +4 -4
  16. package/ChoroplethSvg.js +72 -45
  17. package/ChoroplethSvg.js.map +4 -4
  18. package/Column.config.js +15 -20
  19. package/Column.config.js.map +3 -3
  20. package/Column.js +42 -29
  21. package/Column.js.map +3 -3
  22. package/Ellipse.config.js +16 -7
  23. package/Ellipse.config.js.map +2 -2
  24. package/Ellipse.js +45 -19
  25. package/Ellipse.js.map +2 -2
  26. package/Events.config.js +38 -27
  27. package/Events.config.js.map +4 -4
  28. package/Events.js +113 -97
  29. package/Events.js.map +4 -4
  30. package/FEATUREFLAGS.md +9 -9
  31. package/FillerGauge.config.js +20 -13
  32. package/FillerGauge.config.js.map +3 -3
  33. package/FillerGauge.js +76 -27
  34. package/FillerGauge.js.map +4 -4
  35. package/Image.config.js +5 -6
  36. package/Image.config.js.map +2 -2
  37. package/Image.js +29 -14
  38. package/Image.js.map +2 -2
  39. package/Line.config.js +15 -20
  40. package/Line.config.js.map +3 -3
  41. package/Line.js +50 -31
  42. package/Line.js.map +3 -3
  43. package/LinkGraph.config.js +39 -46
  44. package/LinkGraph.config.js.map +3 -3
  45. package/LinkGraph.js +70 -50
  46. package/LinkGraph.js.map +3 -3
  47. package/MIGRATION.md +169 -40
  48. package/Map.config.js +36 -13
  49. package/Map.config.js.map +4 -4
  50. package/Map.js +170 -105
  51. package/Map.js.map +4 -4
  52. package/Markdown.config.js +4 -5
  53. package/Markdown.config.js.map +2 -2
  54. package/Markdown.js +117 -72
  55. package/Markdown.js.map +3 -3
  56. package/MarkerGauge.config.js +14 -12
  57. package/MarkerGauge.config.js.map +3 -3
  58. package/MarkerGauge.js +107 -69
  59. package/MarkerGauge.js.map +4 -4
  60. package/ParallelCoordinates.config.js +14 -12
  61. package/ParallelCoordinates.config.js.map +3 -3
  62. package/ParallelCoordinates.js +113 -59
  63. package/ParallelCoordinates.js.map +3 -3
  64. package/Pie.config.js +51 -38
  65. package/Pie.config.js.map +4 -4
  66. package/Pie.js +109 -85
  67. package/Pie.js.map +4 -4
  68. package/Punchcard.config.js +36 -34
  69. package/Punchcard.config.js.map +4 -4
  70. package/Punchcard.js +153 -87
  71. package/Punchcard.js.map +4 -4
  72. package/README.internal.md +15 -15
  73. package/README.md +10 -10
  74. package/Rectangle.config.js +16 -7
  75. package/Rectangle.config.js.map +2 -2
  76. package/Rectangle.js +45 -19
  77. package/Rectangle.js.map +2 -2
  78. package/Sankey.config.js +69 -17
  79. package/Sankey.config.js.map +4 -4
  80. package/Sankey.js +178 -49
  81. package/Sankey.js.map +4 -4
  82. package/Scatter.config.js +37 -42
  83. package/Scatter.config.js.map +3 -3
  84. package/Scatter.js +70 -53
  85. package/Scatter.js.map +3 -3
  86. package/SingleValue.config.js +32 -18
  87. package/SingleValue.config.js.map +4 -4
  88. package/SingleValue.js +237 -93
  89. package/SingleValue.js.map +4 -4
  90. package/SingleValueBasic.js +1 -0
  91. package/SingleValueBasic.js.map +2 -2
  92. package/SingleValueIcon.config.js +22 -11
  93. package/SingleValueIcon.config.js.map +2 -2
  94. package/SingleValueIcon.js +84 -28
  95. package/SingleValueIcon.js.map +2 -2
  96. package/SingleValueRadial.config.js +34 -23
  97. package/SingleValueRadial.config.js.map +3 -3
  98. package/SingleValueRadial.js +89 -48
  99. package/SingleValueRadial.js.map +4 -4
  100. package/SparkLine.js +153 -49
  101. package/SparkLine.js.map +2 -2
  102. package/Table.config.js +71 -51
  103. package/Table.config.js.map +3 -3
  104. package/Table.js +282 -145
  105. package/Table.js.map +3 -3
  106. package/Timeline.config.js +36 -34
  107. package/Timeline.config.js.map +4 -4
  108. package/Timeline.js +67 -59
  109. package/Timeline.js.map +4 -4
  110. package/common/Charting.js +1 -0
  111. package/common/Charting.js.map +2 -2
  112. package/common/ChartingApi.js +1 -0
  113. package/common/ChartingApi.js.map +1 -1
  114. package/common/DocExampleWithVizSandbox.js +7 -2
  115. package/common/DocExampleWithVizSandbox.js.map +2 -2
  116. package/common/EventsDoc.js +31 -5
  117. package/common/EventsDoc.js.map +4 -4
  118. package/common/GaugeMajorTicks.js +4 -1
  119. package/common/GaugeMajorTicks.js.map +2 -2
  120. package/common/GaugeValueMarker.js +31 -3
  121. package/common/GaugeValueMarker.js.map +4 -4
  122. package/common/OptionsDoc.js +4 -1
  123. package/common/OptionsDoc.js.map +2 -2
  124. package/common/OverviewDoc.js +66 -50
  125. package/common/OverviewDoc.js.map +4 -4
  126. package/common/SplunkVisualization.js +1 -0
  127. package/common/SplunkVisualization.js.map +1 -1
  128. package/common/SplunkVisualizationApi.js +1 -0
  129. package/common/SplunkVisualizationApi.js.map +1 -1
  130. package/common/ThemedDefaults.js +67 -0
  131. package/common/ThemedDefaults.js.map +7 -0
  132. package/common/ThemesDoc.js +6 -9
  133. package/common/ThemesDoc.js.map +2 -2
  134. package/common/chartingUtils.js +1 -0
  135. package/common/chartingUtils.js.map +2 -2
  136. package/common/docUtils.js +6 -1
  137. package/common/docUtils.js.map +2 -2
  138. package/common/gaugeUtils.js +6 -1
  139. package/common/gaugeUtils.js.map +2 -2
  140. package/common/shapeUtils.js +6 -4
  141. package/common/shapeUtils.js.map +2 -2
  142. package/common/utils/configUtils.js +4 -5
  143. package/common/utils/configUtils.js.map +2 -2
  144. package/common/utils/dataUtils.js +1 -0
  145. package/common/utils/dataUtils.js.map +2 -2
  146. package/common/utils/featureFlagUtils.js +1 -0
  147. package/common/utils/featureFlagUtils.js.map +1 -1
  148. package/common/utils/hocUtils.js +1 -0
  149. package/common/utils/hocUtils.js.map +1 -1
  150. package/common/utils/mapUtils.js +35 -22
  151. package/common/utils/mapUtils.js.map +4 -4
  152. package/common/utils/singleValueUtils.js +8 -2
  153. package/common/utils/singleValueUtils.js.map +2 -2
  154. package/common/utils/styleUtils.js +1 -0
  155. package/common/utils/styleUtils.js.map +1 -1
  156. package/common/utils/testHelper.js +1 -0
  157. package/common/utils/testHelper.js.map +1 -1
  158. package/common/utils/trellisUtils.js +1 -0
  159. package/common/utils/trellisUtils.js.map +1 -1
  160. package/common/utils/urlUtils.js +1 -0
  161. package/common/utils/urlUtils.js.map +1 -1
  162. package/common/withDashboardViz.js +25 -8
  163. package/common/withDashboardViz.js.map +2 -2
  164. package/package.json +37 -35
package/Table.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /* Copyright © 2020 Splunk Inc.
2
2
  SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
3
3
  in part without a valid written license from Splunk Inc. is PROHIBITED. */
4
+ "use strict";
4
5
  var __create = Object.create;
5
6
  var __defProp = Object.defineProperty;
6
7
  var __defProps = Object.defineProperties;
@@ -191,11 +192,9 @@ var configUtils_default = "default" in defaultImport13 ? defaultImport13.default
191
192
  // src/common/utils/configUtils.ts
192
193
  function enhanceConfig(vizConfig) {
193
194
  const enhancedConfig = __spreadValues({}, vizConfig);
194
- enhancedConfig.editorConfig = vizConfig.editorConfig.map(
195
- (config2) => {
196
- return __spreadProps(__spreadValues({}, config2), { open: config2.open || false });
197
- }
198
- );
195
+ enhancedConfig.editorConfig = vizConfig.editorConfig.map((config2) => {
196
+ return __spreadProps(__spreadValues({}, config2), { open: config2.open || false });
197
+ });
199
198
  return enhancedConfig;
200
199
  }
201
200
  function generatePrecisionValues(numPrecisionValues) {
@@ -208,6 +207,15 @@ function generatePrecisionValues(numPrecisionValues) {
208
207
  );
209
208
  }
210
209
 
210
+ // src/common/ThemedDefaults.tsx
211
+ var defaultBackgroundColor = (props) => pick_default({
212
+ enterprise: {
213
+ dark: variables_default.black(props),
214
+ light: variables_default.white(props)
215
+ },
216
+ prisma: variables_default.backgroundColorSection(props)
217
+ })(props);
218
+
211
219
  // src/Table/config.ts
212
220
  var dataContract = {
213
221
  requiredDataSources: [
@@ -314,7 +322,10 @@ var textAlignConfigTable = {
314
322
  option: "tableFormat.align",
315
323
  editorProps: {
316
324
  values: [
317
- { label: (0, i18n_exports._)("Auto"), value: "> table | type() | matchValue(tableAlignByType)" },
325
+ {
326
+ label: (0, i18n_exports._)("Auto"),
327
+ value: "> table | type() | matchValue(tableAlignByType)"
328
+ },
318
329
  { label: (0, i18n_exports._)("Left"), value: "left", icon: TextAlignLeft_default },
319
330
  { label: (0, i18n_exports._)("Center"), value: "center", icon: TextAlignCenter_default },
320
331
  { label: (0, i18n_exports._)("Right"), value: "right", icon: TextAlignRight_default }
@@ -365,13 +376,7 @@ var sequentialColorConfig = [
365
376
  ];
366
377
  var matchColorConfig = [{ match: "", value: "#5C33FF" }];
367
378
  var themes = {
368
- defaultBackgroundColor: (props) => pick_default({
369
- enterprise: {
370
- dark: variables_default.black(props),
371
- light: variables_default.backgroundColor(props)
372
- },
373
- prisma: variables_default.backgroundColorSidebar(props)
374
- })(props),
379
+ defaultBackgroundColor,
375
380
  defaultHeaderBackgroundColor: (props) => pick_default({
376
381
  enterprise: {
377
382
  dark: variables_default.gray20(props),
@@ -391,7 +396,7 @@ var themes = {
391
396
  dark: "#0D1012",
392
397
  light: variables_default.backgroundColor(props)
393
398
  },
394
- prisma: variables_default.backgroundColorSidebar(props)
399
+ prisma: { dark: variables_default.backgroundColorSidebar(props), light: variables_default.white(props) }
395
400
  })(props),
396
401
  textColor: (props) => pick_default({
397
402
  enterprise: variables_default.textColor(props),
@@ -407,10 +412,7 @@ var themes = {
407
412
  prisma: variables_default.contentColorInverted(props)
408
413
  })(props)
409
414
  };
410
- var backgroundColorPaletteSet = /* @__PURE__ */ new Set([
411
- ...colorConstants_exports.COLOR_EDITOR_PALETTE,
412
- ...(0, lodash_exports.map)(themes, (t) => (0, lodash_exports.get)(t, "defaultBackgroundColor"))
413
- ]);
415
+ var backgroundColorPaletteSet = /* @__PURE__ */ new Set([...colorConstants_exports.COLOR_EDITOR_PALETTE]);
414
416
  var EDITOR_LABEL_WIDTH = 100;
415
417
  var editorConfig = [
416
418
  {
@@ -486,7 +488,10 @@ var editorConfig = [
486
488
  editor: "editor.select",
487
489
  editorProps: {
488
490
  values: [
489
- { label: (0, i18n_exports._)("Proportional (Default)"), value: "proportional" },
491
+ {
492
+ label: (0, i18n_exports._)("Proportional (Default)"),
493
+ value: "proportional"
494
+ },
490
495
  { label: (0, i18n_exports._)("Monospace"), value: "monospace" }
491
496
  ],
492
497
  labelPosition: "top",
@@ -501,10 +506,22 @@ var editorConfig = [
501
506
  editor: "editor.select",
502
507
  editorProps: {
503
508
  values: [
504
- { label: (0, i18n_exports._)("Extra Small (font 10px, row 24px)"), value: "extraSmall" },
505
- { label: (0, i18n_exports._)("Small (font 12px, row 24px)"), value: "small" },
506
- { label: (0, i18n_exports._)("Default (font 14px, row 32px)"), value: "default" },
507
- { label: (0, i18n_exports._)("Large (font 16px, row 36px)"), value: "large" }
509
+ {
510
+ label: (0, i18n_exports._)("Extra Small (font 10px, row 24px)"),
511
+ value: "extraSmall"
512
+ },
513
+ {
514
+ label: (0, i18n_exports._)("Small (font 12px, row 24px)"),
515
+ value: "small"
516
+ },
517
+ {
518
+ label: (0, i18n_exports._)("Default (font 14px, row 32px)"),
519
+ value: "default"
520
+ },
521
+ {
522
+ label: (0, i18n_exports._)("Large (font 16px, row 36px)"),
523
+ value: "large"
524
+ }
508
525
  ],
509
526
  labelPosition: "top",
510
527
  labelWidth: EDITOR_LABEL_WIDTH
@@ -602,7 +619,10 @@ var editorConfig = [
602
619
  editor: "editor.radioBar",
603
620
  editorProps: {
604
621
  values: [
605
- { label: (0, i18n_exports._)("Off"), value: false },
622
+ {
623
+ label: (0, i18n_exports._)("Off"),
624
+ value: false
625
+ },
606
626
  { label: (0, i18n_exports._)("On"), value: true }
607
627
  ]
608
628
  }
@@ -1026,9 +1046,14 @@ var Item = styled_components_default.div.attrs(({ width }) => ({
1026
1046
  position: relative;
1027
1047
  background-color: ${(props) => (0, colorUtils_exports.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor}};
1028
1048
  `;
1029
- var FixSizeItem = styled_components_default.div.attrs(({ width, height }) => ({
1030
- style: __spreadValues(__spreadValues({}, width && { width: (0, style_exports.toPx)(width) }), height && { height: (0, style_exports.toPx)(height) })
1031
- }))`
1049
+ var FixSizeItem = styled_components_default.div.attrs(
1050
+ ({
1051
+ width,
1052
+ height
1053
+ }) => ({
1054
+ style: __spreadValues(__spreadValues({}, width && { width: (0, style_exports.toPx)(width) }), height && { height: (0, style_exports.toPx)(height) })
1055
+ })
1056
+ )`
1032
1057
  position: relative;
1033
1058
  flex-direction: column;
1034
1059
  flex: 1;
@@ -1062,7 +1087,7 @@ var withFixedSizeContainer = (Viz) => {
1062
1087
  FixSizeItem,
1063
1088
  {
1064
1089
  "data-test": "fix-size-item",
1065
- "data-splunk-visualization-version": "27.5.0 - 5cfbc7064",
1090
+ "data-splunk-visualization-version": "28.0.0 - 0c5f07712",
1066
1091
  width,
1067
1092
  height,
1068
1093
  backgroundColor
@@ -1128,7 +1153,7 @@ var Cover = styled_components_default.div`
1128
1153
  bottom: 0;
1129
1154
  `;
1130
1155
  var Blocker = styled_components_default.div.attrs({
1131
- "data-splunk-visualization-version": "27.5.0 - 5cfbc7064"
1156
+ "data-splunk-visualization-version": "28.0.0 - 0c5f07712"
1132
1157
  })`
1133
1158
  position: relative;
1134
1159
  width: 100%;
@@ -1497,7 +1522,12 @@ var useGetXAndYFields = ({
1497
1522
  y2Fields: options.y2 ? "> y2 | getField()" : void 0,
1498
1523
  fieldTypes: "> primary | getType()"
1499
1524
  };
1500
- const { xField = "", yFields = [], y2Fields = [], fieldTypes } = Options_exports.Options.evaluate(
1525
+ const {
1526
+ xField = "",
1527
+ yFields = [],
1528
+ y2Fields = [],
1529
+ fieldTypes
1530
+ } = Options_exports.Options.evaluate(
1501
1531
  { options: optionsToEvaluate, context },
1502
1532
  dataSourcesWithOnlyOnePoint,
1503
1533
  () => {
@@ -1778,7 +1808,9 @@ var withDashboardViz = (opts) => {
1778
1808
  return result;
1779
1809
  }
1780
1810
  } catch (e) {
1781
- console.error(`unexpected error evaluating options: ${e.message}`);
1811
+ if (e instanceof Error) {
1812
+ console.error(`unexpected error evaluating options: ${e.message}`);
1813
+ }
1782
1814
  return {};
1783
1815
  }
1784
1816
  return {};
@@ -1837,7 +1869,11 @@ var withDashboardViz = (opts) => {
1837
1869
  if (ev && ev.payload) {
1838
1870
  payload = ev.payload;
1839
1871
  }
1840
- return onEventTrigger({ originalEvent: ev, payload, type: eventName });
1872
+ return onEventTrigger({
1873
+ originalEvent: ev,
1874
+ payload,
1875
+ type: eventName
1876
+ });
1841
1877
  };
1842
1878
  if (parentKeys) {
1843
1879
  for (let i = parentKeys.length - 1; i >= 0; i -= 1) {
@@ -1955,11 +1991,11 @@ var empty = {};
1955
1991
  var getOverflowStyles = ({ textOverflow }) => {
1956
1992
  return textOverflowStyles[textOverflow] || empty;
1957
1993
  };
1958
- var generateKey = (value = "", i) => `${i}-${value}`;
1994
+ var generateKey = (i = "", value = "") => `${value}-${i}`;
1959
1995
  var getTextOverflowType = (columnFormat, columnId, currentColumn) => getAttributeFromColumnFormat("textOverflow", columnFormat, columnId, currentColumn);
1960
1996
  var generateHeader = (value, columnId, i, columnFormat, tableFormat, showInternalFields) => {
1961
1997
  const ret = {
1962
- key: generateKey(value, i),
1998
+ key: generateKey(value, String(i)),
1963
1999
  value,
1964
2000
  align: "left",
1965
2001
  columnId,
@@ -2288,21 +2324,19 @@ var useTable = (tableArgs = {}) => {
2288
2324
  }
2289
2325
  const tableHeader = {
2290
2326
  visibility: visualization_schemas_exports.validHeaderVisibilities.indexOf(headerVisibility) >= 0 ? headerVisibility : "inline",
2291
- cells: table.map(
2292
- (f, i) => {
2293
- if (i < headers.length) {
2294
- return generateHeader(
2295
- headers[i],
2296
- columnIds[i],
2297
- i,
2298
- columnFormat,
2299
- tableFormat,
2300
- showInternalFields
2301
- );
2302
- }
2303
- return generateHeader("", "", i, columnFormat, tableFormat, showInternalFields);
2327
+ cells: table.map((f, i) => {
2328
+ if (i < headers.length) {
2329
+ return generateHeader(
2330
+ headers[i],
2331
+ columnIds[i],
2332
+ i,
2333
+ columnFormat,
2334
+ tableFormat,
2335
+ showInternalFields
2336
+ );
2304
2337
  }
2305
- ),
2338
+ return generateHeader("", "", i, columnFormat, tableFormat, showInternalFields);
2339
+ }),
2306
2340
  style: {
2307
2341
  backgroundColor: (0, lodash_exports.has)(tableFormat, "headerBackgroundColor") && (0, colorUtils_exports.isColor)(tableFormat.headerBackgroundColor) && tableFormat.headerBackgroundColor || void 0,
2308
2342
  color: (0, lodash_exports.has)(tableFormat, "headerColor") && (0, colorUtils_exports.isColor)(tableFormat.headerColor) && tableFormat.headerColor || void 0
@@ -2442,6 +2476,7 @@ var StyledTooltip = styled_components_default.div`
2442
2476
  padding: 3px 8px;
2443
2477
  font-size: 12px;
2444
2478
  `;
2479
+ var preventDefault = (e) => e.preventDefault();
2445
2480
  var _SparkLine = class _SparkLine extends react_exports.Component {
2446
2481
  constructor(props, ...rest) {
2447
2482
  super(props, ...rest);
@@ -2452,21 +2487,99 @@ var _SparkLine = class _SparkLine extends react_exports.Component {
2452
2487
  });
2453
2488
  this.state = {
2454
2489
  anchor: null,
2455
- currentPointX: null,
2456
- open: false,
2457
- rectArea: null,
2458
- tooltip: null
2490
+ activeIndex: 0,
2491
+ hoveredIndex: null,
2492
+ componentIsFocused: false
2459
2493
  };
2460
- this.titleId = (0, id_exports.createDOMID)();
2494
+ this.titleId = (0, id_exports.createDOMID)("sparkline-title");
2495
+ this.pointRefs = [];
2496
+ this.containerRef = react_default.createRef();
2497
+ this.handleKeyDown = this.handleKeyDown.bind(this);
2498
+ this.handleMouseOver = this.handleMouseOver.bind(this);
2499
+ this.handleMouseLeave = this.handleMouseLeave.bind(this);
2500
+ this.handleFocus = this.handleFocus.bind(this);
2501
+ this.handleBlur = this.handleBlur.bind(this);
2502
+ }
2503
+ handleFocus(event) {
2504
+ const { target } = event;
2505
+ const { pointIndex: pointIndexStr } = target.dataset || {};
2506
+ const { activeIndex, componentIsFocused, hoveredIndex } = this.state;
2507
+ if (pointIndexStr !== void 0) {
2508
+ const pointIndex = parseInt(pointIndexStr, 10);
2509
+ if (activeIndex !== pointIndex || !componentIsFocused || hoveredIndex !== null) {
2510
+ this.setState({
2511
+ activeIndex: pointIndex,
2512
+ hoveredIndex: null,
2513
+ componentIsFocused: true
2514
+ });
2515
+ }
2516
+ } else if (this.pointRefs.length > 0) {
2517
+ const indexToFocus = activeIndex ? Math.min(this.pointRefs.length - 1, activeIndex) : 0;
2518
+ this.pointRefs[indexToFocus].focus();
2519
+ }
2520
+ }
2521
+ handleBlur(event) {
2522
+ if (this.containerRef.current && !this.containerRef.current.contains(event.relatedTarget)) {
2523
+ this.setState({ componentIsFocused: false });
2524
+ }
2525
+ }
2526
+ handleKeyDown(event) {
2527
+ const { data } = this.props;
2528
+ const { activeIndex } = this.state;
2529
+ const numPoints = data.length;
2530
+ if (numPoints === 0) {
2531
+ return;
2532
+ }
2533
+ const allowedKeys = ["ArrowLeft", "ArrowRight", "Home", "End"];
2534
+ if (!allowedKeys.includes(event.key)) {
2535
+ return;
2536
+ }
2537
+ let newIndex = activeIndex;
2538
+ switch (event.key) {
2539
+ case "Home":
2540
+ newIndex = 0;
2541
+ break;
2542
+ case "End":
2543
+ newIndex = numPoints - 1;
2544
+ break;
2545
+ case "ArrowLeft":
2546
+ newIndex = Math.max(0, activeIndex - 1);
2547
+ break;
2548
+ case "ArrowRight":
2549
+ newIndex = Math.min(numPoints - 1, activeIndex + 1);
2550
+ break;
2551
+ default:
2552
+ return;
2553
+ }
2554
+ if (newIndex !== activeIndex) {
2555
+ event.preventDefault();
2556
+ if (this.pointRefs[newIndex]) {
2557
+ this.pointRefs[newIndex].focus();
2558
+ }
2559
+ }
2560
+ }
2561
+ handleMouseOver(event) {
2562
+ const pointIndexStr = event.target.dataset && event.target.dataset.pointIndex;
2563
+ if (pointIndexStr !== void 0) {
2564
+ const pointIndex = parseInt(pointIndexStr, 10);
2565
+ if (this.state.hoveredIndex !== pointIndex) {
2566
+ this.setState({ hoveredIndex: pointIndex });
2567
+ }
2568
+ }
2569
+ }
2570
+ handleMouseLeave() {
2571
+ if (this.state.hoveredIndex !== null) {
2572
+ this.setState({ hoveredIndex: null });
2573
+ }
2461
2574
  }
2462
2575
  getMax() {
2463
2576
  const { data, acceptNull, yMax } = this.props;
2464
- const dataMax = () => acceptNull ? (0, lodash_exports.max)(this.fillNull(data)) : (0, lodash_exports.max)(data);
2577
+ const dataMax = () => acceptNull ? (0, lodash_exports.max)(this.fillNull()) : (0, lodash_exports.max)(data);
2465
2578
  return yMax !== void 0 ? yMax : dataMax();
2466
2579
  }
2467
2580
  getMin() {
2468
2581
  const { data, acceptNull, yMin } = this.props;
2469
- const dataMin = () => acceptNull ? (0, lodash_exports.min)(this.fillNull(data)) : (0, lodash_exports.min)(data);
2582
+ const dataMin = () => acceptNull ? (0, lodash_exports.min)(this.fillNull()) : (0, lodash_exports.min)(data);
2470
2583
  return yMin !== void 0 ? yMin : dataMin();
2471
2584
  }
2472
2585
  /**
@@ -2546,15 +2659,14 @@ var _SparkLine = class _SparkLine extends react_exports.Component {
2546
2659
  })).map((p) => [p.x, p.y]);
2547
2660
  }
2548
2661
  /**
2549
- * Renders rect area for helping figure out which is the nearest point so that
2550
- * render related cursor and tooltip.
2662
+ * Renders rect area for each datapoint for interactions and screen reader support
2551
2663
  * @param {Array} points - array of points coordination.
2552
2664
  * @param {Number} xMargin - margin of x axis.
2553
2665
  * @return {Array} array of svg rect objects
2554
2666
  * @private
2555
2667
  */
2556
2668
  renderRect(points, xMargin) {
2557
- const { data, height } = this.props;
2669
+ const { data, height, showTooltip } = this.props;
2558
2670
  const xUnit = this.getXUnit(xMargin);
2559
2671
  return points.map((p, i) => (
2560
2672
  /* eslint-disable react/no-array-index-key */
@@ -2562,20 +2674,20 @@ var _SparkLine = class _SparkLine extends react_exports.Component {
2562
2674
  "rect",
2563
2675
  {
2564
2676
  key: `${i}_${p[0]}`,
2677
+ role: "img",
2678
+ "aria-label": `Value: ${data[i] === null ? "N/A" : data[i]}, point ${i + 1} of ${data.length}`,
2565
2679
  "data-test": `rect-${i}`,
2680
+ "data-point-index": i,
2681
+ tabIndex: showTooltip && this.state.activeIndex === i ? 0 : -1,
2682
+ ref: (el) => {
2683
+ this.pointRefs[i] = el;
2684
+ },
2566
2685
  x: p[0] - xUnit / 2 <= 0 ? 0 : p[0] - xUnit / 2,
2567
2686
  y: 0,
2568
2687
  width: i === 0 && data.length !== 1 ? xUnit / 2 : xUnit,
2569
2688
  height,
2570
2689
  style: { fillOpacity: 0 },
2571
- onMouseOver: (e) => {
2572
- this.setState({
2573
- open: data[i] !== null,
2574
- rectArea: data[i] === null ? null : e.target,
2575
- tooltip: data[i],
2576
- currentPointX: p[0]
2577
- });
2578
- }
2690
+ onMouseDown: preventDefault
2579
2691
  }
2580
2692
  )
2581
2693
  ));
@@ -2611,22 +2723,16 @@ var _SparkLine = class _SparkLine extends react_exports.Component {
2611
2723
  }
2612
2724
  )));
2613
2725
  }
2614
- renderCursor() {
2615
- const {
2616
- cursorStroke,
2617
- cursorStrokeWidth,
2618
- cursorStrokeLinecap,
2619
- cursorStrokeDasharray,
2620
- height
2621
- } = this.props;
2622
- return this.state.rectArea !== null && /* @__PURE__ */ react_default.createElement(
2726
+ renderCursor(currentPointX, shouldRender) {
2727
+ const { cursorStroke, cursorStrokeWidth, cursorStrokeLinecap, cursorStrokeDasharray, height } = this.props;
2728
+ return shouldRender && /* @__PURE__ */ react_default.createElement(
2623
2729
  "line",
2624
2730
  {
2625
2731
  "data-test": "cursor",
2626
2732
  ref: this.handleCursorMount,
2627
- x1: this.state.currentPointX,
2733
+ x1: currentPointX,
2628
2734
  y1: 0,
2629
- x2: this.state.currentPointX,
2735
+ x2: currentPointX,
2630
2736
  y2: height,
2631
2737
  style: {
2632
2738
  stroke: cursorStroke,
@@ -2637,19 +2743,20 @@ var _SparkLine = class _SparkLine extends react_exports.Component {
2637
2743
  }
2638
2744
  );
2639
2745
  }
2640
- renderTooltip() {
2641
- return this.state.anchor !== null && /* @__PURE__ */ react_default.createElement(
2746
+ renderTooltip(tooltipValue, isOpen) {
2747
+ const { anchor } = this.state;
2748
+ return /* @__PURE__ */ react_default.createElement(
2642
2749
  Popover_default,
2643
2750
  {
2644
2751
  "data-test": "tooltip",
2645
- open: this.state.open,
2646
- anchor: this.state.anchor,
2647
- "data-test-value": this.state.tooltip,
2752
+ open: isOpen,
2753
+ anchor,
2754
+ "data-test-value": tooltipValue,
2648
2755
  appearance: "inverted",
2649
2756
  defaultPlacement: "above",
2650
2757
  animation: false
2651
2758
  },
2652
- /* @__PURE__ */ react_default.createElement(StyledTooltip, null, this.state.anchor !== null ? this.state.tooltip : void 0)
2759
+ /* @__PURE__ */ react_default.createElement(StyledTooltip, null, tooltipValue)
2653
2760
  );
2654
2761
  }
2655
2762
  /**
@@ -2720,39 +2827,69 @@ var _SparkLine = class _SparkLine extends react_exports.Component {
2720
2827
  width,
2721
2828
  title
2722
2829
  } = this.props;
2830
+ const { activeIndex, hoveredIndex, componentIsFocused } = this.state;
2723
2831
  if (data.length === 0) {
2724
2832
  return null;
2725
2833
  }
2834
+ if (this.pointRefs.length !== data.length) {
2835
+ this.pointRefs.length = data.length;
2836
+ }
2726
2837
  const xMargin = endDotRadius + endDotStrokeWidth / 2;
2727
2838
  const yMargin = Math.max(lineStrokeWidth / 2, endDotRadius + endDotStrokeWidth / 2);
2728
2839
  const points = this.dataToPoints(xMargin, yMargin);
2729
2840
  const dotsToShow = Math.max(showEndDot && 1, (0, lodash_exports.isFinite)(endDotCount) && endDotCount > 0 && endDotCount);
2841
+ let currentPointX = null;
2842
+ let tooltipValue = null;
2843
+ let showCursorAndTooltip = false;
2844
+ let interactiveProps = {};
2845
+ if (showTooltip) {
2846
+ const isHovered = hoveredIndex !== null;
2847
+ const shouldDisplayInteractiveElements = (isHovered || componentIsFocused) && data.length > 0;
2848
+ if (shouldDisplayInteractiveElements) {
2849
+ const displayIndex = isHovered ? hoveredIndex : activeIndex;
2850
+ if (displayIndex !== null && displayIndex >= 0 && data.length > displayIndex && points.length > displayIndex) {
2851
+ const displayPointCoords = points[displayIndex];
2852
+ if (displayPointCoords) {
2853
+ [currentPointX] = displayPointCoords;
2854
+ }
2855
+ tooltipValue = data[displayIndex];
2856
+ showCursorAndTooltip = currentPointX !== null;
2857
+ }
2858
+ }
2859
+ interactiveProps = {
2860
+ onKeyDown: this.handleKeyDown,
2861
+ onMouseOver: this.handleMouseOver,
2862
+ onMouseLeave: this.handleMouseLeave,
2863
+ onFocus: this.handleFocus,
2864
+ onBlur: this.handleBlur
2865
+ };
2866
+ }
2867
+ const ariaLabel = title || (0, i18n_exports._)("Source count over time sparkline trend");
2730
2868
  return /* @__PURE__ */ react_default.createElement(
2731
2869
  "div",
2732
- __spreadValues({
2870
+ __spreadValues(__spreadValues({
2733
2871
  "data-test": "line",
2734
2872
  "data-test-type": isArea ? "area" : "line",
2735
- onMouseOut: () => {
2736
- this.setState({
2737
- open: false,
2738
- anchor: null,
2739
- rectArea: null,
2740
- currentPointX: null
2741
- });
2742
- },
2743
- ref: elementRef
2744
- }, (0, lodash_exports.omit)(this.props, (0, lodash_exports.keys)(_SparkLine.propTypes))),
2873
+ role: "group",
2874
+ ref: (el) => {
2875
+ this.containerRef.current = el;
2876
+ if (typeof elementRef === "function") {
2877
+ elementRef(el);
2878
+ } else if (elementRef && typeof elementRef === "object") {
2879
+ elementRef.current = el;
2880
+ }
2881
+ }
2882
+ }, interactiveProps), (0, lodash_exports.omit)(this.props, (0, lodash_exports.keys)(_SparkLine.propTypes))),
2745
2883
  /* @__PURE__ */ react_default.createElement(
2746
2884
  StyledSvg,
2747
2885
  {
2748
2886
  height,
2749
2887
  width,
2750
- role: "img",
2751
2888
  "aria-labelledby": this.titleId,
2752
2889
  "data-test": "sparkline-svg"
2753
2890
  },
2754
- /* @__PURE__ */ react_default.createElement("title", { id: this.titleId, "data-test": "sparkline-title" }, title || (0, i18n_exports._)("Source count over time sparkline trend")),
2755
- /* @__PURE__ */ react_default.createElement("g", null, this.renderCursor(), this.renderPolyline(points), this.renderArea(points), dotsToShow ? this.renderEndDots(points, dotsToShow, xMargin) : null, showTooltip ? this.renderRect(points, xMargin) : null, showTooltip ? this.renderTooltip() : null)
2891
+ /* @__PURE__ */ react_default.createElement("title", { id: this.titleId, "data-test": "sparkline-title" }, ariaLabel),
2892
+ /* @__PURE__ */ react_default.createElement("g", null, showTooltip ? this.renderCursor(currentPointX, showCursorAndTooltip) : null, this.renderPolyline(points), this.renderArea(points), dotsToShow ? this.renderEndDots(points, dotsToShow, xMargin) : null, this.renderRect(points, xMargin), showTooltip ? this.renderTooltip(tooltipValue, showCursorAndTooltip) : null)
2756
2893
  )
2757
2894
  );
2758
2895
  }
@@ -2871,7 +3008,7 @@ var SparklineCell = ({
2871
3008
  data = data.slice(1);
2872
3009
  }
2873
3010
  react_exports.useLayoutEffect(() => {
2874
- setHeight(cellEl == null ? void 0 : cellEl.offsetHeight);
3011
+ setHeight((cellEl == null ? void 0 : cellEl.offsetHeight) || 20);
2875
3012
  }, [cellEl]);
2876
3013
  const cellStyle = react_exports.useMemo(
2877
3014
  () => __spreadProps(__spreadValues({}, cell.style), {
@@ -2886,6 +3023,7 @@ var SparklineCell = ({
2886
3023
  () => ({
2887
3024
  paddingLeft: `${paddingLeftRight}px`,
2888
3025
  paddingTop: `${paddingTopBottom}px`,
3026
+ // eslint-disable-next-line no-unsafe-optional-chaining
2889
3027
  width: width === "auto" ? `${(cellEl == null ? void 0 : cellEl.offsetWidth) - paddingLeftRight * 2}px` : `${width}px`,
2890
3028
  height: `${height - paddingTopBottom * 2}px`
2891
3029
  }),
@@ -2921,14 +3059,12 @@ var SparklineCell = ({
2921
3059
  SparklineCell.displayName = "SparklineCell";
2922
3060
 
2923
3061
  // src/Table/PureTable.tsx
2924
- var MINIMUM_COLUMN_SIZE = 30;
3062
+ var MINIMUM_COLUMN_SIZE = 60;
2925
3063
  var INITIAL_UNSET_COLUMN_WIDTH = 90;
2926
3064
  var NonVisibleTableHead = styled_components_default(Table_default.Head)`
2927
3065
  pointer-events: none;
2928
3066
  & [data-test='head-cell'] > div {
2929
- height: 0;
2930
- padding: 0;
2931
- margin: 0;
3067
+ display: none;
2932
3068
  }
2933
3069
  `;
2934
3070
  var FixedTableHead = styled_components_default(Table_default.Head)`
@@ -2945,10 +3081,7 @@ var TableHeadCell = styled_components_default(Table_default.HeadCell)`
2945
3081
  `;
2946
3082
  var VizTableContainer = styled_components_default.div`
2947
3083
  box-sizing: border-box;
2948
- padding: ${pick_default({
2949
- enterprise: variables_default.spacingHalf,
2950
- prisma: variables_default.spacingSmall
2951
- })};
3084
+ padding: ${variables_default.spacingSmall};
2952
3085
  background-color: ${(props) => (0, colorUtils_exports.isColor)(props.backgroundColor) && props.backgroundColor || props.theme.defaultBackgroundColor};
2953
3086
  display: flex;
2954
3087
  flex-flow: column nowrap;
@@ -2971,11 +3104,9 @@ var SUITableContainer = styled_components_default.div`
2971
3104
  box-sizing: border-box;
2972
3105
  flex-grow: 1;
2973
3106
  overflow: hidden;
3107
+
2974
3108
  ${({ width, height, isPaging, theme }) => {
2975
- const padding = pick_default({
2976
- enterprise: variables_default.spacingHalf({ theme }),
2977
- prisma: variables_default.spacingSmall({ theme })
2978
- })({ theme });
3109
+ const padding = variables_default.spacingSmall({ theme });
2979
3110
  const paddingOffset = parseInt(padding, 10) * 2;
2980
3111
  return (0, style_exports.toDimension)({
2981
3112
  width: width - paddingOffset,
@@ -2995,7 +3126,7 @@ var SUITableContainer = styled_components_default.div`
2995
3126
  `}
2996
3127
 
2997
3128
  ${({ headerStyle }) => headerStyle && headerStyle.color && styled_components_exports.css`
2998
- & [data-test='head-cell'] > button > span {
3129
+ & [data-test='head-cell'] > div > button > span {
2999
3130
  color: ${headerStyle.color};
3000
3131
  }
3001
3132
  `}
@@ -3039,7 +3170,13 @@ var withEmptyTableMessage = (Viz) => {
3039
3170
  headerVisibility,
3040
3171
  showRowNumbers,
3041
3172
  showInternalFields,
3042
- tableFormat: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, tableFormat), (tableFormat == null ? void 0 : tableFormat.headerAlign) && { headerAlign: (0, lodash_exports.cloneDeep)(tableFormat.headerAlign) }), (tableFormat == null ? void 0 : tableFormat.align) && { align: (0, lodash_exports.cloneDeep)(tableFormat.align) }), (tableFormat == null ? void 0 : tableFormat.cellTypes) && { cellTypes: (0, lodash_exports.cloneDeep)(tableFormat.cellTypes) }), (tableFormat == null ? void 0 : tableFormat.data) && { data: (0, lodash_exports.cloneDeep)(tableFormat.data) }),
3173
+ tableFormat: __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, tableFormat), (tableFormat == null ? void 0 : tableFormat.headerAlign) && {
3174
+ headerAlign: (0, lodash_exports.cloneDeep)(tableFormat.headerAlign)
3175
+ }), (tableFormat == null ? void 0 : tableFormat.align) && {
3176
+ align: (0, lodash_exports.cloneDeep)(tableFormat.align)
3177
+ }), (tableFormat == null ? void 0 : tableFormat.cellTypes) && {
3178
+ cellTypes: (0, lodash_exports.cloneDeep)(tableFormat.cellTypes)
3179
+ }), (tableFormat == null ? void 0 : tableFormat.data) && { data: (0, lodash_exports.cloneDeep)(tableFormat.data) }),
3043
3180
  columnFormat,
3044
3181
  paginationOffset: paginatorParams == null ? void 0 : paginatorParams.current,
3045
3182
  count
@@ -3137,7 +3274,11 @@ var PureTable = (props) => {
3137
3274
  );
3138
3275
  const drilldownHandler = react_exports.useCallback(
3139
3276
  (e) => {
3140
- const element = e.target;
3277
+ var _a2;
3278
+ const element = (_a2 = e.target) == null ? void 0 : _a2.closest("[data-row-index]");
3279
+ if (!element) {
3280
+ return;
3281
+ }
3141
3282
  const row = element.getAttribute("data-row-index");
3142
3283
  const col = element.getAttribute("data-col-index");
3143
3284
  const arrayIndex = element.getAttribute("data-array-index") || -1;
@@ -3191,9 +3332,6 @@ var PureTable = (props) => {
3191
3332
  e.stopPropagation();
3192
3333
  }
3193
3334
  }, []);
3194
- const handleEventHeadCellMouseUp = react_exports.useCallback(() => {
3195
- setResizing(false);
3196
- }, [setResizing]);
3197
3335
  const handleKeyDown = (e) => {
3198
3336
  if (e.keyCode !== 13) {
3199
3337
  return;
@@ -3219,7 +3357,6 @@ var PureTable = (props) => {
3219
3357
  if (mode === "edit") {
3220
3358
  debouncedOnColumnFormatChange(updatedCF);
3221
3359
  }
3222
- setResizing(false);
3223
3360
  };
3224
3361
  const fontMapped = fontMap[font] || fontMap.proportional;
3225
3362
  const fontSizeMapped = fontSizeMap[fontSize] || fontSizeMap.default;
@@ -3235,6 +3372,7 @@ var PureTable = (props) => {
3235
3372
  }).length;
3236
3373
  const isFullyFixed = visibleHeaderCells.length === numberOfFixedHeaders;
3237
3374
  const isHeaderHidden = headerVisibility === "none";
3375
+ const onSortToUse = isResizing ? lodash_exports.noop : onSort;
3238
3376
  return /* @__PURE__ */ react_exports.createElement(
3239
3377
  VizTableContainer,
3240
3378
  {
@@ -3297,9 +3435,8 @@ var PureTable = (props) => {
3297
3435
  sortDir: sortKey === currentSortKey ? currentSortDir : "none",
3298
3436
  width: (_b2 = (_a2 = columns[value]) == null ? void 0 : _a2.width) != null ? _b2 : INITIAL_UNSET_COLUMN_WIDTH,
3299
3437
  onMouseDown: handleEventHeadCellMouseDown,
3300
- onMouseUp: handleEventHeadCellMouseUp,
3301
3438
  value,
3302
- onSort: isResizing || showRowNumbers && value === "#" || isHeaderHidden ? null : onSort,
3439
+ onSort: showRowNumbers && value === "#" || isHeaderHidden ? null : onSortToUse,
3303
3440
  resizable: !isHeaderHidden,
3304
3441
  style: showRowNumbers && value === "#" ? __spreadProps(__spreadValues({}, style), { cursor: "auto" }) : style,
3305
3442
  headerVisibility
@@ -3308,31 +3445,29 @@ var PureTable = (props) => {
3308
3445
  }
3309
3446
  )),
3310
3447
  /* @__PURE__ */ react_exports.createElement(Table_default.Body, null, tableBody.rows.map(
3311
- (row) => /* @__PURE__ */ react_exports.createElement(Table_default.Row, { key: row.key }, row.cells.filter((c) => c.showCell).map(
3312
- (cell) => {
3313
- var _a2, _b2;
3314
- return /* @__PURE__ */ react_exports.createElement(SwitchTableCell, { key: cell.key, type: cell.cellType }, /* @__PURE__ */ react_exports.createElement(
3315
- TextCell,
3316
- {
3317
- cell,
3318
- useMouseOverEffect: !!onCellClick
3319
- }
3320
- ), /* @__PURE__ */ react_exports.createElement(
3321
- SparklineCell,
3322
- {
3323
- cell,
3324
- useMouseOverEffect: !!onCellClick,
3325
- width: (_b2 = (_a2 = columns[cell.header]) == null ? void 0 : _a2.width) != null ? _b2 : "auto"
3326
- }
3327
- ), /* @__PURE__ */ react_exports.createElement(
3328
- ArrayCell,
3329
- {
3330
- cell,
3331
- useMouseOverEffect: !!onCellClick
3332
- }
3333
- ));
3334
- }
3335
- ))
3448
+ (row) => /* @__PURE__ */ react_exports.createElement(Table_default.Row, { key: row.key }, row.cells.filter((c) => c.showCell).map((cell) => {
3449
+ var _a2, _b2;
3450
+ return /* @__PURE__ */ react_exports.createElement(SwitchTableCell, { key: cell.key, type: cell.cellType }, /* @__PURE__ */ react_exports.createElement(
3451
+ TextCell,
3452
+ {
3453
+ cell,
3454
+ useMouseOverEffect: !!onCellClick
3455
+ }
3456
+ ), /* @__PURE__ */ react_exports.createElement(
3457
+ SparklineCell,
3458
+ {
3459
+ cell,
3460
+ useMouseOverEffect: !!onCellClick,
3461
+ width: (_b2 = (_a2 = columns[cell.header]) == null ? void 0 : _a2.width) != null ? _b2 : "auto"
3462
+ }
3463
+ ), /* @__PURE__ */ react_exports.createElement(
3464
+ ArrayCell,
3465
+ {
3466
+ cell,
3467
+ useMouseOverEffect: !!onCellClick
3468
+ }
3469
+ ));
3470
+ }))
3336
3471
  ))
3337
3472
  )
3338
3473
  ),
@@ -3436,7 +3571,9 @@ var computeVizProps = (_a) => {
3436
3571
  (color) => color || themeTextColor
3437
3572
  );
3438
3573
  }
3439
- vizProps.columnFormat[columnKey] = __spreadValues(__spreadValues(__spreadValues({}, vizProps.columnFormat[columnKey]), columnProperties.rowBackgroundColors && { rowBackgroundColors }), columnProperties.rowColors && { rowColors });
3574
+ vizProps.columnFormat[columnKey] = __spreadValues(__spreadValues(__spreadValues({}, vizProps.columnFormat[columnKey]), columnProperties.rowBackgroundColors && {
3575
+ rowBackgroundColors
3576
+ }), columnProperties.rowColors && { rowColors });
3440
3577
  });
3441
3578
  vizProps.columnIds = (_d = (_c = (_b = (_a2 = vizProps.dataSources) == null ? void 0 : _a2.primary) == null ? void 0 : _b.data) == null ? void 0 : _c.fields.map((field) => {
3442
3579
  var _a3;