@vitessce/tooltip 3.5.2 → 3.5.3

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.
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as React from "react";
2
- import React__default, { useRef, useState, useEffect } from "react";
2
+ import React__default, { useRef, useState, useEffect, useMemo } from "react";
3
3
  import { useVitessceContainer } from "@vitessce/vit-s";
4
4
  import * as ReactDOM from "react-dom";
5
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
5
6
  function getDefaultExportFromCjs(x) {
6
7
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
7
8
  }
@@ -1811,7 +1812,7 @@ function _toPropertyKey(arg) {
1811
1812
  var key = _toPrimitive(arg, "string");
1812
1813
  return _typeof$1(key) === "symbol" ? key : String(key);
1813
1814
  }
1814
- function _defineProperty$1(obj, key, value) {
1815
+ function _defineProperty(obj, key, value) {
1815
1816
  key = _toPropertyKey(key);
1816
1817
  if (key in obj) {
1817
1818
  Object.defineProperty(obj, key, {
@@ -1827,7 +1828,7 @@ function _defineProperty$1(obj, key, value) {
1827
1828
  }
1828
1829
  var specialProperty = "exact-prop: ​";
1829
1830
  function exactProp(propTypes2) {
1830
- return _extends$2({}, propTypes2, _defineProperty$1({}, specialProperty, function(props) {
1831
+ return _extends$2({}, propTypes2, _defineProperty({}, specialProperty, function(props) {
1831
1832
  var unsupportedProps = Object.keys(props).filter(function(prop) {
1832
1833
  return !propTypes2.hasOwnProperty(prop);
1833
1834
  });
@@ -2200,20 +2201,7 @@ function lighten(color, coefficient) {
2200
2201
  }
2201
2202
  return recomposeColor(color);
2202
2203
  }
2203
- function _defineProperty(obj, key, value) {
2204
- if (key in obj) {
2205
- Object.defineProperty(obj, key, {
2206
- value,
2207
- enumerable: true,
2208
- configurable: true,
2209
- writable: true
2210
- });
2211
- } else {
2212
- obj[key] = value;
2213
- }
2214
- return obj;
2215
- }
2216
- function _objectWithoutPropertiesLoose$1(source, excluded) {
2204
+ function _objectWithoutPropertiesLoose(source, excluded) {
2217
2205
  if (source == null)
2218
2206
  return {};
2219
2207
  var target = {};
@@ -2227,10 +2215,10 @@ function _objectWithoutPropertiesLoose$1(source, excluded) {
2227
2215
  }
2228
2216
  return target;
2229
2217
  }
2230
- function _objectWithoutProperties$1(source, excluded) {
2218
+ function _objectWithoutProperties(source, excluded) {
2231
2219
  if (source == null)
2232
2220
  return {};
2233
- var target = _objectWithoutPropertiesLoose$1(source, excluded);
2221
+ var target = _objectWithoutPropertiesLoose(source, excluded);
2234
2222
  var key, i;
2235
2223
  if (Object.getOwnPropertySymbols) {
2236
2224
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
@@ -2245,20 +2233,6 @@ function _objectWithoutProperties$1(source, excluded) {
2245
2233
  }
2246
2234
  return target;
2247
2235
  }
2248
- function _extends$1() {
2249
- _extends$1 = Object.assign ? Object.assign.bind() : function(target) {
2250
- for (var i = 1; i < arguments.length; i++) {
2251
- var source = arguments[i];
2252
- for (var key in source) {
2253
- if (Object.prototype.hasOwnProperty.call(source, key)) {
2254
- target[key] = source[key];
2255
- }
2256
- }
2257
- }
2258
- return target;
2259
- };
2260
- return _extends$1.apply(this, arguments);
2261
- }
2262
2236
  var keys = ["xs", "sm", "md", "lg", "xl"];
2263
2237
  function createBreakpoints(breakpoints) {
2264
2238
  var _breakpoints$values = breakpoints.values, values = _breakpoints$values === void 0 ? {
@@ -2267,7 +2241,7 @@ function createBreakpoints(breakpoints) {
2267
2241
  md: 960,
2268
2242
  lg: 1280,
2269
2243
  xl: 1920
2270
- } : _breakpoints$values, _breakpoints$unit = breakpoints.unit, unit = _breakpoints$unit === void 0 ? "px" : _breakpoints$unit, _breakpoints$step = breakpoints.step, step = _breakpoints$step === void 0 ? 5 : _breakpoints$step, other = _objectWithoutProperties$1(breakpoints, ["values", "unit", "step"]);
2244
+ } : _breakpoints$values, _breakpoints$unit = breakpoints.unit, unit = _breakpoints$unit === void 0 ? "px" : _breakpoints$unit, _breakpoints$step = breakpoints.step, step = _breakpoints$step === void 0 ? 5 : _breakpoints$step, other = _objectWithoutProperties(breakpoints, ["values", "unit", "step"]);
2271
2245
  function up(key) {
2272
2246
  var value = typeof values[key] === "number" ? values[key] : key;
2273
2247
  return "@media (min-width:".concat(value).concat(unit, ")");
@@ -2301,7 +2275,7 @@ function createBreakpoints(breakpoints) {
2301
2275
  }
2302
2276
  return values[key];
2303
2277
  }
2304
- return _extends$1({
2278
+ return _extends$2({
2305
2279
  keys,
2306
2280
  values,
2307
2281
  up,
@@ -2313,14 +2287,14 @@ function createBreakpoints(breakpoints) {
2313
2287
  }
2314
2288
  function createMixins(breakpoints, spacing, mixins) {
2315
2289
  var _toolbar;
2316
- return _extends$1({
2290
+ return _extends$2({
2317
2291
  gutters: function gutters() {
2318
2292
  var styles3 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2319
2293
  console.warn(["Material-UI: theme.mixins.gutters() is deprecated.", "You can use the source of the mixin directly:", "\n paddingLeft: theme.spacing(2),\n paddingRight: theme.spacing(2),\n [theme.breakpoints.up('sm')]: {\n paddingLeft: theme.spacing(3),\n paddingRight: theme.spacing(3),\n },\n "].join("\n"));
2320
- return _extends$1({
2294
+ return _extends$2({
2321
2295
  paddingLeft: spacing(2),
2322
2296
  paddingRight: spacing(2)
2323
- }, styles3, _defineProperty({}, breakpoints.up("sm"), _extends$1({
2297
+ }, styles3, _defineProperty({}, breakpoints.up("sm"), _extends$2({
2324
2298
  paddingLeft: spacing(3),
2325
2299
  paddingRight: spacing(3)
2326
2300
  }, styles3[breakpoints.up("sm")])));
@@ -2439,7 +2413,7 @@ function createPalette(palette) {
2439
2413
  light: green$1[300],
2440
2414
  main: green$1[500],
2441
2415
  dark: green$1[700]
2442
- } : _palette$success, _palette$type = palette.type, type = _palette$type === void 0 ? "light" : _palette$type, _palette$contrastThre = palette.contrastThreshold, contrastThreshold = _palette$contrastThre === void 0 ? 3 : _palette$contrastThre, _palette$tonalOffset = palette.tonalOffset, tonalOffset = _palette$tonalOffset === void 0 ? 0.2 : _palette$tonalOffset, other = _objectWithoutProperties$1(palette, ["primary", "secondary", "error", "warning", "info", "success", "type", "contrastThreshold", "tonalOffset"]);
2416
+ } : _palette$success, _palette$type = palette.type, type = _palette$type === void 0 ? "light" : _palette$type, _palette$contrastThre = palette.contrastThreshold, contrastThreshold = _palette$contrastThre === void 0 ? 3 : _palette$contrastThre, _palette$tonalOffset = palette.tonalOffset, tonalOffset = _palette$tonalOffset === void 0 ? 0.2 : _palette$tonalOffset, other = _objectWithoutProperties(palette, ["primary", "secondary", "error", "warning", "info", "success", "type", "contrastThreshold", "tonalOffset"]);
2443
2417
  function getContrastText(background) {
2444
2418
  var contrastText = getContrastRatio(background, dark.text.primary) >= contrastThreshold ? dark.text.primary : light.text.primary;
2445
2419
  {
@@ -2454,7 +2428,7 @@ function createPalette(palette) {
2454
2428
  var mainShade = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 500;
2455
2429
  var lightShade = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 300;
2456
2430
  var darkShade = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 700;
2457
- color = _extends$1({}, color);
2431
+ color = _extends$2({}, color);
2458
2432
  if (!color.main && color[mainShade]) {
2459
2433
  color.main = color[mainShade];
2460
2434
  }
@@ -2480,7 +2454,7 @@ function createPalette(palette) {
2480
2454
  console.error("Material-UI: The palette type `".concat(type, "` is not supported."));
2481
2455
  }
2482
2456
  }
2483
- var paletteOutput = deepmerge(_extends$1({
2457
+ var paletteOutput = deepmerge(_extends$2({
2484
2458
  // A collection of common colors.
2485
2459
  common: common$1,
2486
2460
  // The palette type, can be light or dark.
@@ -2531,7 +2505,7 @@ var caseAllCaps = {
2531
2505
  };
2532
2506
  var defaultFontFamily = '"Roboto", "Helvetica", "Arial", sans-serif';
2533
2507
  function createTypography(palette, typography) {
2534
- var _ref = typeof typography === "function" ? typography(palette) : typography, _ref$fontFamily = _ref.fontFamily, fontFamily = _ref$fontFamily === void 0 ? defaultFontFamily : _ref$fontFamily, _ref$fontSize = _ref.fontSize, fontSize = _ref$fontSize === void 0 ? 14 : _ref$fontSize, _ref$fontWeightLight = _ref.fontWeightLight, fontWeightLight = _ref$fontWeightLight === void 0 ? 300 : _ref$fontWeightLight, _ref$fontWeightRegula = _ref.fontWeightRegular, fontWeightRegular = _ref$fontWeightRegula === void 0 ? 400 : _ref$fontWeightRegula, _ref$fontWeightMedium = _ref.fontWeightMedium, fontWeightMedium = _ref$fontWeightMedium === void 0 ? 500 : _ref$fontWeightMedium, _ref$fontWeightBold = _ref.fontWeightBold, fontWeightBold = _ref$fontWeightBold === void 0 ? 700 : _ref$fontWeightBold, _ref$htmlFontSize = _ref.htmlFontSize, htmlFontSize = _ref$htmlFontSize === void 0 ? 16 : _ref$htmlFontSize, allVariants = _ref.allVariants, pxToRem2 = _ref.pxToRem, other = _objectWithoutProperties$1(_ref, ["fontFamily", "fontSize", "fontWeightLight", "fontWeightRegular", "fontWeightMedium", "fontWeightBold", "htmlFontSize", "allVariants", "pxToRem"]);
2508
+ var _ref = typeof typography === "function" ? typography(palette) : typography, _ref$fontFamily = _ref.fontFamily, fontFamily = _ref$fontFamily === void 0 ? defaultFontFamily : _ref$fontFamily, _ref$fontSize = _ref.fontSize, fontSize = _ref$fontSize === void 0 ? 14 : _ref$fontSize, _ref$fontWeightLight = _ref.fontWeightLight, fontWeightLight = _ref$fontWeightLight === void 0 ? 300 : _ref$fontWeightLight, _ref$fontWeightRegula = _ref.fontWeightRegular, fontWeightRegular = _ref$fontWeightRegula === void 0 ? 400 : _ref$fontWeightRegula, _ref$fontWeightMedium = _ref.fontWeightMedium, fontWeightMedium = _ref$fontWeightMedium === void 0 ? 500 : _ref$fontWeightMedium, _ref$fontWeightBold = _ref.fontWeightBold, fontWeightBold = _ref$fontWeightBold === void 0 ? 700 : _ref$fontWeightBold, _ref$htmlFontSize = _ref.htmlFontSize, htmlFontSize = _ref$htmlFontSize === void 0 ? 16 : _ref$htmlFontSize, allVariants = _ref.allVariants, pxToRem2 = _ref.pxToRem, other = _objectWithoutProperties(_ref, ["fontFamily", "fontSize", "fontWeightLight", "fontWeightRegular", "fontWeightMedium", "fontWeightBold", "htmlFontSize", "allVariants", "pxToRem"]);
2535
2509
  {
2536
2510
  if (typeof fontSize !== "number") {
2537
2511
  console.error("Material-UI: `fontSize` is required to be a number.");
@@ -2545,7 +2519,7 @@ function createTypography(palette, typography) {
2545
2519
  return "".concat(size / htmlFontSize * coef, "rem");
2546
2520
  };
2547
2521
  var buildVariant = function buildVariant2(fontWeight, size, lineHeight, letterSpacing, casing) {
2548
- return _extends$1({
2522
+ return _extends$2({
2549
2523
  fontFamily,
2550
2524
  fontWeight,
2551
2525
  fontSize: pxToRem(size),
@@ -2570,7 +2544,7 @@ function createTypography(palette, typography) {
2570
2544
  caption: buildVariant(fontWeightRegular, 12, 1.66, 0.4),
2571
2545
  overline: buildVariant(fontWeightRegular, 12, 2.66, 1, caseAllCaps)
2572
2546
  };
2573
- return deepmerge(_extends$1({
2547
+ return deepmerge(_extends$2({
2574
2548
  htmlFontSize,
2575
2549
  pxToRem,
2576
2550
  round: roundWithDeprecationWarning,
@@ -2750,7 +2724,7 @@ const transitions = {
2750
2724
  create: function create() {
2751
2725
  var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ["all"];
2752
2726
  var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2753
- var _options$duration = options.duration, durationOption = _options$duration === void 0 ? duration.standard : _options$duration, _options$easing = options.easing, easingOption = _options$easing === void 0 ? easing.easeInOut : _options$easing, _options$delay = options.delay, delay = _options$delay === void 0 ? 0 : _options$delay, other = _objectWithoutProperties$1(options, ["duration", "easing", "delay"]);
2727
+ var _options$duration = options.duration, durationOption = _options$duration === void 0 ? duration.standard : _options$duration, _options$easing = options.easing, easingOption = _options$easing === void 0 ? easing.easeInOut : _options$easing, _options$delay = options.delay, delay = _options$delay === void 0 ? 0 : _options$delay, other = _objectWithoutProperties(options, ["duration", "easing", "delay"]);
2754
2728
  {
2755
2729
  var isString = function isString2(value) {
2756
2730
  return typeof value === "string";
@@ -2798,7 +2772,7 @@ var zIndex = {
2798
2772
  const zIndex$1 = zIndex;
2799
2773
  function createTheme() {
2800
2774
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2801
- var _options$breakpoints = options.breakpoints, breakpointsInput = _options$breakpoints === void 0 ? {} : _options$breakpoints, _options$mixins = options.mixins, mixinsInput = _options$mixins === void 0 ? {} : _options$mixins, _options$palette = options.palette, paletteInput = _options$palette === void 0 ? {} : _options$palette, spacingInput = options.spacing, _options$typography = options.typography, typographyInput = _options$typography === void 0 ? {} : _options$typography, other = _objectWithoutProperties$1(options, ["breakpoints", "mixins", "palette", "spacing", "typography"]);
2775
+ var _options$breakpoints = options.breakpoints, breakpointsInput = _options$breakpoints === void 0 ? {} : _options$breakpoints, _options$mixins = options.mixins, mixinsInput = _options$mixins === void 0 ? {} : _options$mixins, _options$palette = options.palette, paletteInput = _options$palette === void 0 ? {} : _options$palette, spacingInput = options.spacing, _options$typography = options.typography, typographyInput = _options$typography === void 0 ? {} : _options$typography, other = _objectWithoutProperties(options, ["breakpoints", "mixins", "palette", "spacing", "typography"]);
2802
2776
  var palette = createPalette(paletteInput);
2803
2777
  var breakpoints = createBreakpoints(breakpointsInput);
2804
2778
  var spacing = createSpacing(spacingInput);
@@ -2961,20 +2935,6 @@ function _assertThisInitialized(self2) {
2961
2935
  }
2962
2936
  return self2;
2963
2937
  }
2964
- function _objectWithoutPropertiesLoose(source, excluded) {
2965
- if (source == null)
2966
- return {};
2967
- var target = {};
2968
- var sourceKeys = Object.keys(source);
2969
- var key, i;
2970
- for (i = 0; i < sourceKeys.length; i++) {
2971
- key = sourceKeys[i];
2972
- if (excluded.indexOf(key) >= 0)
2973
- continue;
2974
- target[key] = source[key];
2975
- }
2976
- return target;
2977
- }
2978
2938
  var plainObjectConstrurctor = {}.constructor;
2979
2939
  function cloneStyle(style) {
2980
2940
  if (style == null || typeof style !== "object")
@@ -4449,6 +4409,20 @@ var functionPlugin = function functionPlugin2() {
4449
4409
  };
4450
4410
  };
4451
4411
  const functions = functionPlugin;
4412
+ function _extends$1() {
4413
+ _extends$1 = Object.assign ? Object.assign.bind() : function(target) {
4414
+ for (var i = 1; i < arguments.length; i++) {
4415
+ var source = arguments[i];
4416
+ for (var key in source) {
4417
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
4418
+ target[key] = source[key];
4419
+ }
4420
+ }
4421
+ }
4422
+ return target;
4423
+ };
4424
+ return _extends$1.apply(this, arguments);
4425
+ }
4452
4426
  var at = "@global";
4453
4427
  var atPrefix = "@global ";
4454
4428
  var GlobalContainerRule = /* @__PURE__ */ function() {
@@ -5373,24 +5347,6 @@ function jssPreset() {
5373
5347
  ]
5374
5348
  };
5375
5349
  }
5376
- function _objectWithoutProperties(source, excluded) {
5377
- if (source == null)
5378
- return {};
5379
- var target = _objectWithoutPropertiesLoose(source, excluded);
5380
- var key, i;
5381
- if (Object.getOwnPropertySymbols) {
5382
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
5383
- for (i = 0; i < sourceSymbolKeys.length; i++) {
5384
- key = sourceSymbolKeys[i];
5385
- if (excluded.indexOf(key) >= 0)
5386
- continue;
5387
- if (!Object.prototype.propertyIsEnumerable.call(source, key))
5388
- continue;
5389
- target[key] = source[key];
5390
- }
5391
- }
5392
- return target;
5393
- }
5394
5350
  function mergeClasses() {
5395
5351
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
5396
5352
  var baseClasses = options.baseClasses, newClasses = options.newClasses, Component = options.Component;
@@ -5979,12 +5935,12 @@ var defaultTheme = createTheme();
5979
5935
  const defaultTheme$1 = defaultTheme;
5980
5936
  function makeStyles(stylesOrCreator) {
5981
5937
  var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
5982
- return makeStyles$1(stylesOrCreator, _extends$1({
5938
+ return makeStyles$1(stylesOrCreator, _extends$2({
5983
5939
  defaultTheme: defaultTheme$1
5984
5940
  }, options));
5985
5941
  }
5986
5942
  function withStyles2(stylesOrCreator, options) {
5987
- return withStylesWithoutDefault(stylesOrCreator, _extends$1({
5943
+ return withStylesWithoutDefault(stylesOrCreator, _extends$2({
5988
5944
  defaultTheme: defaultTheme$1
5989
5945
  }, options));
5990
5946
  }
@@ -6046,7 +6002,7 @@ var styles$1 = function styles(theme) {
6046
6002
  boxShadow: shadow
6047
6003
  };
6048
6004
  });
6049
- return _extends$1({
6005
+ return _extends$2({
6050
6006
  /* Styles applied to the root element. */
6051
6007
  root: {
6052
6008
  backgroundColor: theme.palette.background.paper,
@@ -6064,8 +6020,8 @@ var styles$1 = function styles(theme) {
6064
6020
  }, elevations);
6065
6021
  };
6066
6022
  var Paper = /* @__PURE__ */ React.forwardRef(function Paper2(props, ref) {
6067
- var classes = props.classes, className = props.className, _props$component = props.component, Component = _props$component === void 0 ? "div" : _props$component, _props$square = props.square, square = _props$square === void 0 ? false : _props$square, _props$elevation = props.elevation, elevation = _props$elevation === void 0 ? 1 : _props$elevation, _props$variant = props.variant, variant = _props$variant === void 0 ? "elevation" : _props$variant, other = _objectWithoutProperties$1(props, ["classes", "className", "component", "square", "elevation", "variant"]);
6068
- return /* @__PURE__ */ React.createElement(Component, _extends$1({
6023
+ var classes = props.classes, className = props.className, _props$component = props.component, Component = _props$component === void 0 ? "div" : _props$component, _props$square = props.square, square = _props$square === void 0 ? false : _props$square, _props$elevation = props.elevation, elevation = _props$elevation === void 0 ? 1 : _props$elevation, _props$variant = props.variant, variant = _props$variant === void 0 ? "elevation" : _props$variant, other = _objectWithoutProperties(props, ["classes", "className", "component", "square", "elevation", "variant"]);
6024
+ return /* @__PURE__ */ React.createElement(Component, _extends$2({
6069
6025
  className: clsx(classes.root, className, variant === "outlined" ? classes.outlined : classes["elevation".concat(elevation)], !square && classes.rounded),
6070
6026
  ref
6071
6027
  }, other));
@@ -7756,7 +7712,7 @@ function getAnchorEl(anchorEl) {
7756
7712
  var useEnhancedEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
7757
7713
  var defaultPopperOptions = {};
7758
7714
  var Popper = /* @__PURE__ */ React.forwardRef(function Popper2(props, ref) {
7759
- var anchorEl = props.anchorEl, children = props.children, container = props.container, _props$disablePortal = props.disablePortal, disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal, _props$keepMounted = props.keepMounted, keepMounted = _props$keepMounted === void 0 ? false : _props$keepMounted, modifiers2 = props.modifiers, open = props.open, _props$placement = props.placement, initialPlacement = _props$placement === void 0 ? "bottom" : _props$placement, _props$popperOptions = props.popperOptions, popperOptions = _props$popperOptions === void 0 ? defaultPopperOptions : _props$popperOptions, popperRefProp = props.popperRef, style = props.style, _props$transition = props.transition, transition2 = _props$transition === void 0 ? false : _props$transition, other = _objectWithoutProperties$1(props, ["anchorEl", "children", "container", "disablePortal", "keepMounted", "modifiers", "open", "placement", "popperOptions", "popperRef", "style", "transition"]);
7715
+ var anchorEl = props.anchorEl, children = props.children, container = props.container, _props$disablePortal = props.disablePortal, disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal, _props$keepMounted = props.keepMounted, keepMounted = _props$keepMounted === void 0 ? false : _props$keepMounted, modifiers2 = props.modifiers, open = props.open, _props$placement = props.placement, initialPlacement = _props$placement === void 0 ? "bottom" : _props$placement, _props$popperOptions = props.popperOptions, popperOptions = _props$popperOptions === void 0 ? defaultPopperOptions : _props$popperOptions, popperRefProp = props.popperRef, style = props.style, _props$transition = props.transition, transition2 = _props$transition === void 0 ? false : _props$transition, other = _objectWithoutProperties(props, ["anchorEl", "children", "container", "disablePortal", "keepMounted", "modifiers", "open", "placement", "popperOptions", "popperRef", "style", "transition"]);
7760
7716
  var tooltipRef = React.useRef(null);
7761
7717
  var ownRef = useForkRef(tooltipRef, ref);
7762
7718
  var popperRef = React.useRef(null);
@@ -7797,10 +7753,10 @@ var Popper = /* @__PURE__ */ React.forwardRef(function Popper2(props, ref) {
7797
7753
  }
7798
7754
  }
7799
7755
  }
7800
- var popper = new PopperJs(getAnchorEl(anchorEl), tooltipRef.current, _extends$1({
7756
+ var popper = new PopperJs(getAnchorEl(anchorEl), tooltipRef.current, _extends$2({
7801
7757
  placement: rtlPlacement
7802
7758
  }, popperOptions, {
7803
- modifiers: _extends$1({}, disablePortal ? {} : {
7759
+ modifiers: _extends$2({}, disablePortal ? {} : {
7804
7760
  // It's using scrollParent by default, we can use the viewport when using a portal.
7805
7761
  preventOverflow: {
7806
7762
  boundariesElement: "window"
@@ -7857,11 +7813,11 @@ var Popper = /* @__PURE__ */ React.forwardRef(function Popper2(props, ref) {
7857
7813
  return /* @__PURE__ */ React.createElement(Portal$1, {
7858
7814
  disablePortal,
7859
7815
  container
7860
- }, /* @__PURE__ */ React.createElement("div", _extends$1({
7816
+ }, /* @__PURE__ */ React.createElement("div", _extends$2({
7861
7817
  ref: handleRef,
7862
7818
  role: "tooltip"
7863
7819
  }, other, {
7864
- style: _extends$1({
7820
+ style: _extends$2({
7865
7821
  // Prevents scroll issue, waiting for Popper.js to add this style once initiated.
7866
7822
  position: "fixed",
7867
7823
  // Fix Popper.js display issue
@@ -8091,11 +8047,397 @@ function Tooltip2D(props) {
8091
8047
  ) : null
8092
8048
  ] }) });
8093
8049
  }
8050
+ function commonjsRequire(path) {
8051
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
8052
+ }
8053
+ var pluralize = { exports: {} };
8054
+ (function(module, exports) {
8055
+ (function(root, pluralize2) {
8056
+ if (typeof commonjsRequire === "function" && true && true) {
8057
+ module.exports = pluralize2();
8058
+ } else {
8059
+ root.pluralize = pluralize2();
8060
+ }
8061
+ })(commonjsGlobal, function() {
8062
+ var pluralRules = [];
8063
+ var singularRules = [];
8064
+ var uncountables = {};
8065
+ var irregularPlurals = {};
8066
+ var irregularSingles = {};
8067
+ function sanitizeRule(rule) {
8068
+ if (typeof rule === "string") {
8069
+ return new RegExp("^" + rule + "$", "i");
8070
+ }
8071
+ return rule;
8072
+ }
8073
+ function restoreCase(word, token) {
8074
+ if (word === token)
8075
+ return token;
8076
+ if (word === word.toLowerCase())
8077
+ return token.toLowerCase();
8078
+ if (word === word.toUpperCase())
8079
+ return token.toUpperCase();
8080
+ if (word[0] === word[0].toUpperCase()) {
8081
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
8082
+ }
8083
+ return token.toLowerCase();
8084
+ }
8085
+ function interpolate(str, args) {
8086
+ return str.replace(/\$(\d{1,2})/g, function(match, index) {
8087
+ return args[index] || "";
8088
+ });
8089
+ }
8090
+ function replace(word, rule) {
8091
+ return word.replace(rule[0], function(match, index) {
8092
+ var result = interpolate(rule[1], arguments);
8093
+ if (match === "") {
8094
+ return restoreCase(word[index - 1], result);
8095
+ }
8096
+ return restoreCase(match, result);
8097
+ });
8098
+ }
8099
+ function sanitizeWord(token, word, rules) {
8100
+ if (!token.length || uncountables.hasOwnProperty(token)) {
8101
+ return word;
8102
+ }
8103
+ var len = rules.length;
8104
+ while (len--) {
8105
+ var rule = rules[len];
8106
+ if (rule[0].test(word))
8107
+ return replace(word, rule);
8108
+ }
8109
+ return word;
8110
+ }
8111
+ function replaceWord(replaceMap, keepMap, rules) {
8112
+ return function(word) {
8113
+ var token = word.toLowerCase();
8114
+ if (keepMap.hasOwnProperty(token)) {
8115
+ return restoreCase(word, token);
8116
+ }
8117
+ if (replaceMap.hasOwnProperty(token)) {
8118
+ return restoreCase(word, replaceMap[token]);
8119
+ }
8120
+ return sanitizeWord(token, word, rules);
8121
+ };
8122
+ }
8123
+ function checkWord(replaceMap, keepMap, rules, bool) {
8124
+ return function(word) {
8125
+ var token = word.toLowerCase();
8126
+ if (keepMap.hasOwnProperty(token))
8127
+ return true;
8128
+ if (replaceMap.hasOwnProperty(token))
8129
+ return false;
8130
+ return sanitizeWord(token, token, rules) === token;
8131
+ };
8132
+ }
8133
+ function pluralize2(word, count, inclusive) {
8134
+ var pluralized = count === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
8135
+ return (inclusive ? count + " " : "") + pluralized;
8136
+ }
8137
+ pluralize2.plural = replaceWord(
8138
+ irregularSingles,
8139
+ irregularPlurals,
8140
+ pluralRules
8141
+ );
8142
+ pluralize2.isPlural = checkWord(
8143
+ irregularSingles,
8144
+ irregularPlurals,
8145
+ pluralRules
8146
+ );
8147
+ pluralize2.singular = replaceWord(
8148
+ irregularPlurals,
8149
+ irregularSingles,
8150
+ singularRules
8151
+ );
8152
+ pluralize2.isSingular = checkWord(
8153
+ irregularPlurals,
8154
+ irregularSingles,
8155
+ singularRules
8156
+ );
8157
+ pluralize2.addPluralRule = function(rule, replacement) {
8158
+ pluralRules.push([sanitizeRule(rule), replacement]);
8159
+ };
8160
+ pluralize2.addSingularRule = function(rule, replacement) {
8161
+ singularRules.push([sanitizeRule(rule), replacement]);
8162
+ };
8163
+ pluralize2.addUncountableRule = function(word) {
8164
+ if (typeof word === "string") {
8165
+ uncountables[word.toLowerCase()] = true;
8166
+ return;
8167
+ }
8168
+ pluralize2.addPluralRule(word, "$0");
8169
+ pluralize2.addSingularRule(word, "$0");
8170
+ };
8171
+ pluralize2.addIrregularRule = function(single, plural) {
8172
+ plural = plural.toLowerCase();
8173
+ single = single.toLowerCase();
8174
+ irregularSingles[single] = plural;
8175
+ irregularPlurals[plural] = single;
8176
+ };
8177
+ [
8178
+ // Pronouns.
8179
+ ["I", "we"],
8180
+ ["me", "us"],
8181
+ ["he", "they"],
8182
+ ["she", "they"],
8183
+ ["them", "them"],
8184
+ ["myself", "ourselves"],
8185
+ ["yourself", "yourselves"],
8186
+ ["itself", "themselves"],
8187
+ ["herself", "themselves"],
8188
+ ["himself", "themselves"],
8189
+ ["themself", "themselves"],
8190
+ ["is", "are"],
8191
+ ["was", "were"],
8192
+ ["has", "have"],
8193
+ ["this", "these"],
8194
+ ["that", "those"],
8195
+ // Words ending in with a consonant and `o`.
8196
+ ["echo", "echoes"],
8197
+ ["dingo", "dingoes"],
8198
+ ["volcano", "volcanoes"],
8199
+ ["tornado", "tornadoes"],
8200
+ ["torpedo", "torpedoes"],
8201
+ // Ends with `us`.
8202
+ ["genus", "genera"],
8203
+ ["viscus", "viscera"],
8204
+ // Ends with `ma`.
8205
+ ["stigma", "stigmata"],
8206
+ ["stoma", "stomata"],
8207
+ ["dogma", "dogmata"],
8208
+ ["lemma", "lemmata"],
8209
+ ["schema", "schemata"],
8210
+ ["anathema", "anathemata"],
8211
+ // Other irregular rules.
8212
+ ["ox", "oxen"],
8213
+ ["axe", "axes"],
8214
+ ["die", "dice"],
8215
+ ["yes", "yeses"],
8216
+ ["foot", "feet"],
8217
+ ["eave", "eaves"],
8218
+ ["goose", "geese"],
8219
+ ["tooth", "teeth"],
8220
+ ["quiz", "quizzes"],
8221
+ ["human", "humans"],
8222
+ ["proof", "proofs"],
8223
+ ["carve", "carves"],
8224
+ ["valve", "valves"],
8225
+ ["looey", "looies"],
8226
+ ["thief", "thieves"],
8227
+ ["groove", "grooves"],
8228
+ ["pickaxe", "pickaxes"],
8229
+ ["passerby", "passersby"]
8230
+ ].forEach(function(rule) {
8231
+ return pluralize2.addIrregularRule(rule[0], rule[1]);
8232
+ });
8233
+ [
8234
+ [/s?$/i, "s"],
8235
+ [/[^\u0000-\u007F]$/i, "$0"],
8236
+ [/([^aeiou]ese)$/i, "$1"],
8237
+ [/(ax|test)is$/i, "$1es"],
8238
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
8239
+ [/(e[mn]u)s?$/i, "$1s"],
8240
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
8241
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
8242
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
8243
+ [/(seraph|cherub)(?:im)?$/i, "$1im"],
8244
+ [/(her|at|gr)o$/i, "$1oes"],
8245
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
8246
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
8247
+ [/sis$/i, "ses"],
8248
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
8249
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
8250
+ [/([^ch][ieo][ln])ey$/i, "$1ies"],
8251
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
8252
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
8253
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
8254
+ [/(pe)(?:rson|ople)$/i, "$1ople"],
8255
+ [/(child)(?:ren)?$/i, "$1ren"],
8256
+ [/eaux$/i, "$0"],
8257
+ [/m[ae]n$/i, "men"],
8258
+ ["thou", "you"]
8259
+ ].forEach(function(rule) {
8260
+ return pluralize2.addPluralRule(rule[0], rule[1]);
8261
+ });
8262
+ [
8263
+ [/s$/i, ""],
8264
+ [/(ss)$/i, "$1"],
8265
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
8266
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
8267
+ [/ies$/i, "y"],
8268
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
8269
+ [/\b(mon|smil)ies$/i, "$1ey"],
8270
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
8271
+ [/(seraph|cherub)im$/i, "$1"],
8272
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
8273
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
8274
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
8275
+ [/(test)(?:is|es)$/i, "$1is"],
8276
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
8277
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
8278
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
8279
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
8280
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
8281
+ [/(matr|append)ices$/i, "$1ix"],
8282
+ [/(pe)(rson|ople)$/i, "$1rson"],
8283
+ [/(child)ren$/i, "$1"],
8284
+ [/(eau)x?$/i, "$1"],
8285
+ [/men$/i, "man"]
8286
+ ].forEach(function(rule) {
8287
+ return pluralize2.addSingularRule(rule[0], rule[1]);
8288
+ });
8289
+ [
8290
+ // Singular words with no plurals.
8291
+ "adulthood",
8292
+ "advice",
8293
+ "agenda",
8294
+ "aid",
8295
+ "aircraft",
8296
+ "alcohol",
8297
+ "ammo",
8298
+ "analytics",
8299
+ "anime",
8300
+ "athletics",
8301
+ "audio",
8302
+ "bison",
8303
+ "blood",
8304
+ "bream",
8305
+ "buffalo",
8306
+ "butter",
8307
+ "carp",
8308
+ "cash",
8309
+ "chassis",
8310
+ "chess",
8311
+ "clothing",
8312
+ "cod",
8313
+ "commerce",
8314
+ "cooperation",
8315
+ "corps",
8316
+ "debris",
8317
+ "diabetes",
8318
+ "digestion",
8319
+ "elk",
8320
+ "energy",
8321
+ "equipment",
8322
+ "excretion",
8323
+ "expertise",
8324
+ "firmware",
8325
+ "flounder",
8326
+ "fun",
8327
+ "gallows",
8328
+ "garbage",
8329
+ "graffiti",
8330
+ "hardware",
8331
+ "headquarters",
8332
+ "health",
8333
+ "herpes",
8334
+ "highjinks",
8335
+ "homework",
8336
+ "housework",
8337
+ "information",
8338
+ "jeans",
8339
+ "justice",
8340
+ "kudos",
8341
+ "labour",
8342
+ "literature",
8343
+ "machinery",
8344
+ "mackerel",
8345
+ "mail",
8346
+ "media",
8347
+ "mews",
8348
+ "moose",
8349
+ "music",
8350
+ "mud",
8351
+ "manga",
8352
+ "news",
8353
+ "only",
8354
+ "personnel",
8355
+ "pike",
8356
+ "plankton",
8357
+ "pliers",
8358
+ "police",
8359
+ "pollution",
8360
+ "premises",
8361
+ "rain",
8362
+ "research",
8363
+ "rice",
8364
+ "salmon",
8365
+ "scissors",
8366
+ "series",
8367
+ "sewage",
8368
+ "shambles",
8369
+ "shrimp",
8370
+ "software",
8371
+ "species",
8372
+ "staff",
8373
+ "swine",
8374
+ "tennis",
8375
+ "traffic",
8376
+ "transportation",
8377
+ "trout",
8378
+ "tuna",
8379
+ "wealth",
8380
+ "welfare",
8381
+ "whiting",
8382
+ "wildebeest",
8383
+ "wildlife",
8384
+ "you",
8385
+ /pok[eé]mon$/i,
8386
+ // Regexes.
8387
+ /[^aeiou]ese$/i,
8388
+ // "chinese", "japanese"
8389
+ /deer$/i,
8390
+ // "deer", "reindeer"
8391
+ /fish$/i,
8392
+ // "fish", "blowfish", "angelfish"
8393
+ /measles$/i,
8394
+ /o[iu]s$/i,
8395
+ // "carnivorous"
8396
+ /pox$/i,
8397
+ // "chickpox", "smallpox"
8398
+ /sheep$/i
8399
+ ].forEach(pluralize2.addUncountableRule);
8400
+ return pluralize2;
8401
+ });
8402
+ })(pluralize);
8403
+ var pluralizeExports = pluralize.exports;
8404
+ const plur = /* @__PURE__ */ getDefaultExportFromCjs(pluralizeExports);
8405
+ plur.addPluralRule("glomerulus", "glomeruli");
8406
+ plur.addPluralRule("interstitium", "interstitia");
8407
+ function cleanFeatureId(featureName) {
8408
+ if (featureName.startsWith("ENSG")) {
8409
+ return featureName.split(".")[0];
8410
+ }
8411
+ return featureName;
8412
+ }
8413
+ function transformInfoValues(info, featureType, featureLabelsMap) {
8414
+ if (info) {
8415
+ const newInfo = Object.fromEntries(
8416
+ Object.entries(info).map(([key, value]) => {
8417
+ if (key.toLowerCase().includes(featureType.toLowerCase())) {
8418
+ const newValue = (featureLabelsMap == null ? void 0 : featureLabelsMap.get(value)) || (featureLabelsMap == null ? void 0 : featureLabelsMap.get(cleanFeatureId(value))) || value;
8419
+ return [key, newValue];
8420
+ }
8421
+ return [key, value];
8422
+ })
8423
+ );
8424
+ return newInfo;
8425
+ }
8426
+ return info;
8427
+ }
8094
8428
  function TooltipContent(props) {
8095
8429
  const {
8096
- info
8430
+ info,
8431
+ featureType,
8432
+ featureLabelsMap
8097
8433
  } = props;
8098
- return /* @__PURE__ */ jsxRuntimeExports.jsx("table", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: Object.entries(info).map(([key, value]) => /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
8434
+ const mappedInfo = useMemo(() => {
8435
+ if (!featureType || !featureLabelsMap) {
8436
+ return info;
8437
+ }
8438
+ return transformInfoValues(info, featureType, featureLabelsMap);
8439
+ }, [info, featureType, featureLabelsMap]);
8440
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("table", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: Object.entries(mappedInfo).map(([key, value]) => /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { children: [
8099
8441
  /* @__PURE__ */ jsxRuntimeExports.jsx("th", { children: key }),
8100
8442
  /* @__PURE__ */ jsxRuntimeExports.jsx("td", { children: value })
8101
8443
  ] }, key)) }) });
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../src/TooltipContent.js"],"names":[],"mappings":"AAEA,gEAiBC"}
1
+ {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../src/TooltipContent.js"],"names":[],"mappings":"AAGA,gEA0BC"}
@@ -1,6 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from 'react';
2
+ import React, { useMemo } from 'react';
3
+ import { transformInfoValues } from './utils.js';
3
4
  export default function TooltipContent(props) {
4
- const { info, } = props;
5
- return (_jsx("table", { children: _jsx("tbody", { children: Object.entries(info).map(([key, value]) => (_jsxs("tr", { children: [_jsx("th", { children: key }), _jsx("td", { children: value })] }, key))) }) }));
5
+ const { info, featureType, featureLabelsMap, } = props;
6
+ const mappedInfo = useMemo(() => {
7
+ if (!featureType || !featureLabelsMap) {
8
+ return info;
9
+ }
10
+ return transformInfoValues(info, featureType, featureLabelsMap);
11
+ }, [info, featureType, featureLabelsMap]);
12
+ return (_jsx("table", { children: _jsx("tbody", { children: Object.entries(mappedInfo).map(([key, value]) => (_jsxs("tr", { children: [_jsx("th", { children: key }), _jsx("td", { children: value })] }, key))) }) }));
6
13
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Use the featureLabelsMap to transform the values in the info object.
3
+ * For example, there are cases where the info object looks like
4
+ * { "Marker Gene ID": "ENSG00000123456.1" }
5
+ * And we want to transform the values into Gene Symbols instead of Ensembl IDs.
6
+ * @param {object} info
7
+ * @param {string} featureType
8
+ * @param {Map<string,string>} featureLabelsMap
9
+ * @returns
10
+ */
11
+ export function transformInfoValues(info: object, featureType: string, featureLabelsMap: Map<string, string>): {
12
+ [k: string]: any;
13
+ };
14
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,0CALW,MAAM,eACN,MAAM,oBACN,GAAG,CAAC,MAAM,EAAC,MAAM,CAAC;;EAqB5B"}
@@ -0,0 +1,26 @@
1
+ import { cleanFeatureId } from '@vitessce/utils';
2
+ /**
3
+ * Use the featureLabelsMap to transform the values in the info object.
4
+ * For example, there are cases where the info object looks like
5
+ * { "Marker Gene ID": "ENSG00000123456.1" }
6
+ * And we want to transform the values into Gene Symbols instead of Ensembl IDs.
7
+ * @param {object} info
8
+ * @param {string} featureType
9
+ * @param {Map<string,string>} featureLabelsMap
10
+ * @returns
11
+ */
12
+ export function transformInfoValues(info, featureType, featureLabelsMap) {
13
+ if (info) {
14
+ const newInfo = Object.fromEntries(Object.entries(info).map(([key, value]) => {
15
+ if (key.toLowerCase().includes(featureType.toLowerCase())) {
16
+ const newValue = (featureLabelsMap?.get(value)
17
+ || featureLabelsMap?.get(cleanFeatureId(value))
18
+ || value);
19
+ return [key, newValue];
20
+ }
21
+ return [key, value];
22
+ }));
23
+ return newInfo;
24
+ }
25
+ return info;
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/tooltip",
3
- "version": "3.5.2",
3
+ "version": "3.5.3",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -17,7 +17,8 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "@material-ui/core": "~4.12.3",
20
- "@vitessce/vit-s": "3.5.2"
20
+ "@vitessce/vit-s": "3.5.3",
21
+ "@vitessce/utils": "3.5.3"
21
22
  },
22
23
  "devDependencies": {
23
24
  "react": "^18.0.0",
@@ -1,14 +1,24 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
+ import { transformInfoValues } from './utils.js';
2
3
 
3
4
  export default function TooltipContent(props) {
4
5
  const {
5
6
  info,
7
+ featureType,
8
+ featureLabelsMap,
6
9
  } = props;
7
10
 
11
+ const mappedInfo = useMemo(() => {
12
+ if (!featureType || !featureLabelsMap) {
13
+ return info;
14
+ }
15
+ return transformInfoValues(info, featureType, featureLabelsMap);
16
+ }, [info, featureType, featureLabelsMap]);
17
+
8
18
  return (
9
19
  <table>
10
20
  <tbody>
11
- {Object.entries(info).map(([key, value]) => (
21
+ {Object.entries(mappedInfo).map(([key, value]) => (
12
22
  <tr key={key}>
13
23
  <th>{key}</th>
14
24
  <td>{value}</td>
package/src/utils.js ADDED
@@ -0,0 +1,31 @@
1
+ import { cleanFeatureId } from '@vitessce/utils';
2
+
3
+ /**
4
+ * Use the featureLabelsMap to transform the values in the info object.
5
+ * For example, there are cases where the info object looks like
6
+ * { "Marker Gene ID": "ENSG00000123456.1" }
7
+ * And we want to transform the values into Gene Symbols instead of Ensembl IDs.
8
+ * @param {object} info
9
+ * @param {string} featureType
10
+ * @param {Map<string,string>} featureLabelsMap
11
+ * @returns
12
+ */
13
+ export function transformInfoValues(info, featureType, featureLabelsMap) {
14
+ if (info) {
15
+ const newInfo = Object.fromEntries(
16
+ Object.entries(info).map(([key, value]) => {
17
+ if (key.toLowerCase().includes(featureType.toLowerCase())) {
18
+ const newValue = (
19
+ featureLabelsMap?.get(value)
20
+ || featureLabelsMap?.get(cleanFeatureId(value))
21
+ || value
22
+ );
23
+ return [key, newValue];
24
+ }
25
+ return [key, value];
26
+ }),
27
+ );
28
+ return newInfo;
29
+ }
30
+ return info;
31
+ }