@vitessce/heatmap 3.8.13 → 3.9.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.
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
2
+ import { B as BaseDecoder } from "./index-DYmO2OXo.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -720,6 +720,17 @@ const DEFAULT_LIGHT2_COLOR = [235, 235, 235];
720
720
  function getDefaultColor(theme) {
721
721
  return theme === "dark" ? DEFAULT_DARK_COLOR : theme === "light" ? DEFAULT_LIGHT_COLOR$3 : DEFAULT_LIGHT2_COLOR;
722
722
  }
723
+ const PALETTE = [
724
+ [68, 119, 170],
725
+ [136, 204, 238],
726
+ [68, 170, 153],
727
+ [17, 119, 51],
728
+ [153, 153, 51],
729
+ [221, 204, 119],
730
+ [204, 102, 119],
731
+ [136, 34, 85],
732
+ [170, 68, 153]
733
+ ];
723
734
  const DEFAULT_GL_OPTIONS = { webgl2: true };
724
735
  function createDefaultUpdateCellsHover(componentName) {
725
736
  return (hoverInfo) => log$5.warn(`${componentName} updateCellsHover: ${hoverInfo.cellId}`);
@@ -9760,6 +9771,7 @@ const CoordinationType$1 = {
9760
9771
  OBS_SET_HIGHLIGHT: "obsSetHighlight",
9761
9772
  OBS_SET_EXPANSION: "obsSetExpansion",
9762
9773
  OBS_SET_COLOR: "obsSetColor",
9774
+ FEATURE_COLOR: "featureColor",
9763
9775
  FEATURE_HIGHLIGHT: "featureHighlight",
9764
9776
  FEATURE_SELECTION: "featureSelection",
9765
9777
  FEATURE_SET_SELECTION: "featureSetSelection",
@@ -10337,6 +10349,8 @@ const COMPONENT_COORDINATION_TYPES = {
10337
10349
  CoordinationType$1.OBS_SET_FILTER,
10338
10350
  CoordinationType$1.OBS_SET_HIGHLIGHT,
10339
10351
  CoordinationType$1.OBS_SET_COLOR,
10352
+ CoordinationType$1.FEATURE_COLOR,
10353
+ CoordinationType$1.FEATURE_FILTER_MODE,
10340
10354
  CoordinationType$1.FEATURE_HIGHLIGHT,
10341
10355
  CoordinationType$1.FEATURE_SELECTION,
10342
10356
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
@@ -10551,6 +10565,8 @@ const COMPONENT_COORDINATION_TYPES = {
10551
10565
  CoordinationType$1.SPATIAL_SPOT_STROKE_WIDTH,
10552
10566
  CoordinationType$1.SPATIAL_LAYER_COLOR,
10553
10567
  CoordinationType$1.OBS_COLOR_ENCODING,
10568
+ CoordinationType$1.FEATURE_COLOR,
10569
+ CoordinationType$1.FEATURE_FILTER_MODE,
10554
10570
  CoordinationType$1.FEATURE_VALUE_COLORMAP,
10555
10571
  CoordinationType$1.FEATURE_VALUE_COLORMAP_RANGE,
10556
10572
  CoordinationType$1.FEATURE_SELECTION,
@@ -33776,6 +33792,7 @@ function Legend(props) {
33776
33792
  positionRelative = false,
33777
33793
  highContrast = false,
33778
33794
  obsType,
33795
+ isPointsLayer = false,
33779
33796
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
33780
33797
  featureType: _featureType = void 0,
33781
33798
  // Unused but accepted for API compatibility
@@ -33783,6 +33800,9 @@ function Legend(props) {
33783
33800
  considerSelections = true,
33784
33801
  obsColorEncoding,
33785
33802
  featureSelection,
33803
+ featureFilterMode,
33804
+ featureColor,
33805
+ featureIndex,
33786
33806
  featureLabelsMap,
33787
33807
  featureValueColormap,
33788
33808
  featureValueColormapRange,
@@ -33826,15 +33846,95 @@ function Legend(props) {
33826
33846
  debouncedSetRange(rangeValue);
33827
33847
  }
33828
33848
  }, [debouncedSetRange]);
33849
+ const obsLabel = capitalize$2(obsType ?? null);
33829
33850
  const isDarkTheme = theme === "dark";
33830
- const isStaticColor = obsColorEncoding === "spatialChannelColor" || obsColorEncoding === "spatialLayerColor";
33831
- const isSetColor = obsColorEncoding === "cellSetSelection";
33851
+ const isStaticColor = !isPointsLayer && (obsColorEncoding === "spatialChannelColor" || obsColorEncoding === "spatialLayerColor");
33852
+ const isSetColor = !isPointsLayer && obsColorEncoding === "cellSetSelection";
33832
33853
  const layerColor = Array.isArray(spatialLayerColor) && spatialLayerColor.length === 3 ? spatialLayerColor : getDefaultColor(theme ?? "light");
33833
33854
  const channelColor = Array.isArray(spatialChannelColor) && spatialChannelColor.length === 3 ? spatialChannelColor : getDefaultColor(theme ?? "light");
33834
33855
  const staticColor = obsColorEncoding === "spatialChannelColor" ? channelColor : layerColor;
33835
- const visible = visibleProp && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && featureSelection && Array.isArray(featureSelection) && featureSelection.length >= 1 || isSetColor && ((obsSetSelection == null ? void 0 : obsSetSelection.length) ?? 0) > 0 && ((obsSetColor == null ? void 0 : obsSetColor.length) ?? 0) > 0 || isStaticColor);
33856
+ const visible = visibleProp && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && featureSelection && Array.isArray(featureSelection) && featureSelection.length >= 1 || isSetColor && ((obsSetSelection == null ? void 0 : obsSetSelection.length) ?? 0) > 0 && ((obsSetColor == null ? void 0 : obsSetColor.length) ?? 0) > 0 || isStaticColor || isPointsLayer);
33857
+ const pointsLegendElements = [];
33858
+ if (isPointsLayer) {
33859
+ const MAX_NUM_COLORS = 10;
33860
+ const hasFeatureSelection = Array.isArray(featureSelection) && featureSelection.length > 0;
33861
+ const showUnselected = featureFilterMode !== "featureSelection";
33862
+ if (obsColorEncoding === "spatialLayerColor") {
33863
+ if (!hasFeatureSelection) {
33864
+ pointsLegendElements.push({
33865
+ name: obsLabel,
33866
+ color: staticColor
33867
+ });
33868
+ } else {
33869
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
33870
+ limitedFeatureSelection.forEach((featureName) => {
33871
+ pointsLegendElements.push({
33872
+ name: featureName,
33873
+ color: staticColor
33874
+ });
33875
+ });
33876
+ }
33877
+ } else if (obsColorEncoding === "geneSelection") {
33878
+ if (!hasFeatureSelection) {
33879
+ pointsLegendElements.push({
33880
+ name: obsLabel,
33881
+ color: staticColor
33882
+ });
33883
+ } else {
33884
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
33885
+ limitedFeatureSelection.forEach((featureName) => {
33886
+ var _a3;
33887
+ const featureColorMatch = Array.isArray(featureColor) ? (_a3 = featureColor.find((fc) => fc.name === featureName)) == null ? void 0 : _a3.color : null;
33888
+ pointsLegendElements.push({
33889
+ name: featureName,
33890
+ // If no color is specified for this feature, use staticColor.
33891
+ color: featureColorMatch ?? staticColor
33892
+ });
33893
+ });
33894
+ }
33895
+ } else if (obsColorEncoding === "randomByFeature") {
33896
+ if (!hasFeatureSelection) {
33897
+ pointsLegendElements.push({
33898
+ name: obsLabel,
33899
+ // For now, using black and white for this.
33900
+ // (It should not match any color in PALETTE)
33901
+ color: isDarkTheme ? [255, 255, 255] : [0, 0, 0]
33902
+ });
33903
+ } else {
33904
+ const limitedFeatureSelection = featureSelection.slice(0, MAX_NUM_COLORS);
33905
+ limitedFeatureSelection.forEach((featureName) => {
33906
+ const varIndex = (featureIndex ?? []).indexOf(featureName);
33907
+ const featureColorMatch = varIndex >= 0 ? PALETTE[varIndex % PALETTE.length] : null;
33908
+ pointsLegendElements.push({
33909
+ name: featureName,
33910
+ // If no color is specified for this feature, use staticColor.
33911
+ color: featureColorMatch ?? staticColor
33912
+ });
33913
+ });
33914
+ }
33915
+ } else if (obsColorEncoding === "random") {
33916
+ pointsLegendElements.push({
33917
+ name: obsLabel,
33918
+ // For now, using black and white for this.
33919
+ // (It should not match any color in PALETTE)
33920
+ color: isDarkTheme ? [255, 255, 255] : [0, 0, 0]
33921
+ });
33922
+ }
33923
+ if (showUnselected) {
33924
+ pointsLegendElements.push({
33925
+ name: "Unselected",
33926
+ color: getDefaultColor(theme ?? "light")
33927
+ });
33928
+ }
33929
+ }
33836
33930
  const levelZeroNames = useMemo(() => Array.from(new Set((obsSetSelection == null ? void 0 : obsSetSelection.map((setPath) => setPath[0])) || [])), [obsSetSelection]);
33837
- const dynamicHeight = isSetColor && obsSetSelection ? levelZeroNames.length * titleHeight + ((obsSetSelection == null ? void 0 : obsSetSelection.length) ?? 0) * (rectHeight + rectMarginY) : height2 + (!pointsVisible && contoursVisible ? 25 : 0);
33931
+ const dynamicHeight = isPointsLayer ? (
33932
+ // Height logic for points layers.
33933
+ pointsLegendElements.length * (rectHeight + rectMarginY) + titleHeight
33934
+ ) : (
33935
+ // Height logic for non-points layers.
33936
+ isSetColor && obsSetSelection ? levelZeroNames.length * titleHeight + ((obsSetSelection == null ? void 0 : obsSetSelection.length) ?? 0) * (rectHeight + rectMarginY) : height2 + (!pointsVisible && contoursVisible ? 25 : 0)
33937
+ );
33838
33938
  const availHeight = maxHeight2 !== null ? Math.max(0, maxHeight2 - 4) : Infinity;
33839
33939
  const needsScroll = Number.isFinite(availHeight) && dynamicHeight > availHeight + 1;
33840
33940
  useEffect(() => {
@@ -33846,8 +33946,8 @@ function Legend(props) {
33846
33946
  svg.selectAll("g").remove();
33847
33947
  svg.attr("width", width2).attr("height", dynamicHeight);
33848
33948
  const g2 = svg.append("g").attr("width", width2).attr("height", dynamicHeight);
33849
- const showInteractiveSlider2 = setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
33850
- if (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "")) {
33949
+ const showInteractiveSlider2 = !isPointsLayer && setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
33950
+ if (!isPointsLayer && (!considerSelections || ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? ""))) {
33851
33951
  const combinedExtent = combineExtents(extent2 ?? null, featureAggregationStrategy ?? null) || [0, 1];
33852
33952
  const [xMin, xMax] = combinedExtent;
33853
33953
  if (featureValueColormap && pointsVisible) {
@@ -33907,10 +34007,10 @@ function Legend(props) {
33907
34007
  });
33908
34008
  }
33909
34009
  }
33910
- if (isStaticColor) {
34010
+ if (!isPointsLayer && isStaticColor) {
33911
34011
  g2.append("rect").attr("x", 0).attr("y", titleHeight).attr("width", width2 - 4).attr("height", rectHeight).attr("fill", `rgb(${staticColor[0]},${staticColor[1]},${staticColor[2]})`);
33912
34012
  }
33913
- if (isSetColor && obsSetSelection && obsSetColor) {
34013
+ if (!isPointsLayer && isSetColor && obsSetSelection && obsSetColor) {
33914
34014
  const obsSetSelectionByLevelZero = {};
33915
34015
  obsSetSelection.forEach((setPath) => {
33916
34016
  const levelZeroName = setPath[0];
@@ -33932,6 +34032,16 @@ function Legend(props) {
33932
34032
  });
33933
34033
  });
33934
34034
  }
34035
+ if (isPointsLayer) {
34036
+ let y = 0;
34037
+ g2.append("text").attr("text-anchor", "start").attr("dominant-baseline", "hanging").attr("x", 0).attr("y", y).text("Points").style("font-size", "9px").style("fill", foregroundColor);
34038
+ y += titleHeight;
34039
+ pointsLegendElements.forEach(({ name: name2, color: color2 }) => {
34040
+ g2.append("rect").attr("x", 0).attr("y", y).attr("width", rectHeight).attr("height", rectHeight).attr("fill", `rgb(${color2[0]},${color2[1]},${color2[2]})`);
34041
+ g2.append("text").attr("text-anchor", "start").attr("dominant-baseline", "hanging").attr("x", rectHeight + rectMarginX).attr("y", y).text(name2).style("font-size", "9px").style("fill", foregroundColor);
34042
+ y += rectHeight + rectMarginY;
34043
+ });
34044
+ }
33935
34045
  const featureSelectionLabelRaw = featureSelection && featureSelection.length >= 1 && !isStaticColor ? featureSelection.map((geneName) => (featureLabelsMap == null ? void 0 : featureLabelsMap.get(geneName)) || (featureLabelsMap == null ? void 0 : featureLabelsMap.get(cleanFeatureId(geneName))) || geneName) : null;
33936
34046
  let featureSelectionLabelRawStr = "";
33937
34047
  if (featureAggregationStrategy === "first") {
@@ -33958,12 +34068,11 @@ function Legend(props) {
33958
34068
  }
33959
34069
  const combinedMissing = combineMissings(missing ?? null, featureAggregationStrategy ?? null);
33960
34070
  const featureSelectionLabel = combinedMissing ? `${featureSelectionLabelRawStr} (${Math.round(combinedMissing * 100)}% NaN)` : featureSelectionLabelRawStr;
33961
- const obsLabel = capitalize$2(obsType ?? null);
33962
34071
  const featureLabel = considerSelections ? featureSelectionLabel || capitalize$2(featureValueType ?? null) : capitalize$2(featureValueType ?? null);
33963
34072
  const mainLabel = showObsLabel ? obsLabel : featureLabel;
33964
34073
  const subLabel = showObsLabel ? featureLabel : null;
33965
34074
  const hasSubLabel = subLabel !== null;
33966
- if (!isSetColor) {
34075
+ if (!isPointsLayer && !isSetColor) {
33967
34076
  g2.append("text").attr("text-anchor", hasSubLabel ? "start" : "end").attr("dominant-baseline", "hanging").attr("x", hasSubLabel ? 0 : width2 - 4).attr("y", 0).text(mainLabel ?? "").style("font-size", "10px").style("fill", foregroundColor);
33968
34077
  if (hasSubLabel) {
33969
34078
  g2.append("text").attr("text-anchor", "end").attr("dominant-baseline", "hanging").attr("x", width2 - 5).attr("y", titleHeight + rectHeight).text(subLabel ?? "").style("font-size", "9px").style("fill", foregroundColor);
@@ -34002,7 +34111,7 @@ function Legend(props) {
34002
34111
  showObsLabel,
34003
34112
  staticColor
34004
34113
  ]);
34005
- const showInteractiveSlider = setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
34114
+ const showInteractiveSlider = !isPointsLayer && setFeatureValueColormapRange && ["geneSelection", "geneExpression"].includes(obsColorEncoding ?? "") && pointsVisible && featureValueColormap;
34006
34115
  const globalExtent = useMemo(() => {
34007
34116
  const combined = combineExtents(extent2 ?? null, featureAggregationStrategy ?? null);
34008
34117
  return combined || [0, 1];
@@ -138072,22 +138181,22 @@ function addDecoder(cases, importFn) {
138072
138181
  }
138073
138182
  cases.forEach((c) => registry$1.set(c, importFn));
138074
138183
  }
138075
- addDecoder([void 0, 1], () => import("./raw-DBEZoTXk.js").then((m) => m.default));
138076
- addDecoder(5, () => import("./lzw-DIDyT49t.js").then((m) => m.default));
138184
+ addDecoder([void 0, 1], () => import("./raw-X9wB5QOd.js").then((m) => m.default));
138185
+ addDecoder(5, () => import("./lzw-CqQYDnuj.js").then((m) => m.default));
138077
138186
  addDecoder(6, () => {
138078
138187
  throw new Error("old style JPEG compression is not supported.");
138079
138188
  });
138080
- addDecoder(7, () => import("./jpeg-BQH57nGA.js").then((m) => m.default));
138081
- addDecoder([8, 32946], () => import("./deflate-C6kM_d3H.js").then((m) => m.default));
138082
- addDecoder(32773, () => import("./packbits-x4mUZGOp.js").then((m) => m.default));
138189
+ addDecoder(7, () => import("./jpeg-BgSqSBcW.js").then((m) => m.default));
138190
+ addDecoder([8, 32946], () => import("./deflate-BkVXwIOr.js").then((m) => m.default));
138191
+ addDecoder(32773, () => import("./packbits-DLjqHTtn.js").then((m) => m.default));
138083
138192
  addDecoder(
138084
138193
  34887,
138085
- () => import("./lerc-Bcypgvlf.js").then(async (m) => {
138194
+ () => import("./lerc-Bh37u7Qj.js").then(async (m) => {
138086
138195
  await m.zstd.init();
138087
138196
  return m;
138088
138197
  }).then((m) => m.default)
138089
138198
  );
138090
- addDecoder(50001, () => import("./webimage-DNvdSc-_.js").then((m) => m.default));
138199
+ addDecoder(50001, () => import("./webimage-CgODQeEE.js").then((m) => m.default));
138091
138200
  function decodeRowAcc(row, stride) {
138092
138201
  let length2 = row.length - stride;
138093
138202
  let offset2 = 0;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a, H } from "./index-BB2ssozJ.js";
1
+ import { a, H } from "./index-DYmO2OXo.js";
2
2
  export {
3
3
  a as Heatmap,
4
4
  H as HeatmapSubscriber
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DYmO2OXo.js";
2
2
  const dctZigZag = new Int32Array([
3
3
  0,
4
4
  1,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-BB2ssozJ.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-DYmO2OXo.js";
3
3
  const LercParameters = {
4
4
  AddCompression: 1
5
5
  };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DYmO2OXo.js";
2
2
  const MIN_BITS = 9;
3
3
  const CLEAR_CODE = 256;
4
4
  const EOI_CODE = 257;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DYmO2OXo.js";
2
2
  class PackbitsDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  const dataView = new DataView(buffer);
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DYmO2OXo.js";
2
2
  class RawDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  return buffer;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-BB2ssozJ.js";
1
+ import { B as BaseDecoder } from "./index-DYmO2OXo.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/heatmap",
3
- "version": "3.8.13",
3
+ "version": "3.9.0",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -19,15 +19,15 @@
19
19
  "lodash-es": "^4.17.21",
20
20
  "uuid": "^9.0.0",
21
21
  "react-aria": "^3.28.0",
22
- "@vitessce/styles": "3.8.13",
23
- "@vitessce/constants-internal": "3.8.13",
24
- "@vitessce/gl": "3.8.13",
25
- "@vitessce/sets-utils": "3.8.13",
26
- "@vitessce/tooltip": "3.8.13",
27
- "@vitessce/utils": "3.8.13",
28
- "@vitessce/legend": "3.8.13",
29
- "@vitessce/vit-s": "3.8.13",
30
- "@vitessce/workers": "3.8.13"
22
+ "@vitessce/constants-internal": "3.9.0",
23
+ "@vitessce/gl": "3.9.0",
24
+ "@vitessce/styles": "3.9.0",
25
+ "@vitessce/legend": "3.9.0",
26
+ "@vitessce/sets-utils": "3.9.0",
27
+ "@vitessce/tooltip": "3.9.0",
28
+ "@vitessce/workers": "3.9.0",
29
+ "@vitessce/vit-s": "3.9.0",
30
+ "@vitessce/utils": "3.9.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@testing-library/jest-dom": "^6.6.3",