@haniffalab/cherita-react 1.0.0-dev.2025-03-24.e68f9e22 → 1.0.0-dev.2025-03-24.4a3636c2

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.
@@ -150,7 +150,7 @@ function ObsColsList(_ref) {
150
150
  });
151
151
  dispatch({
152
152
  type: "set.colorEncoding",
153
- value: "obs"
153
+ value: _constants.COLOR_ENCODINGS.OBS
154
154
  });
155
155
  };
156
156
  const toggleObs = (item, value) => {
@@ -36,7 +36,7 @@ function ObsmKeysList() {
36
36
  refetchOnMount: false
37
37
  });
38
38
  (0, _react.useEffect)(() => {
39
- if (!isPending && !serverError) {
39
+ if (!isPending && !serverError && fetchedData) {
40
40
  setObsmKeysList(fetchedData);
41
41
  }
42
42
  }, [fetchedData, isPending, serverError]);
@@ -133,7 +133,7 @@ function Pseudospatial(_ref) {
133
133
  serverError
134
134
  } = usePseudospatialData(plotType);
135
135
  (0, _react.useEffect)(() => {
136
- if (!isPending && !serverError) {
136
+ if (!isPending && !serverError && fetchedData) {
137
137
  setData(fetchedData.data);
138
138
  setLayout(fetchedData.layout);
139
139
  updateColorscale(colorscale.current);
@@ -119,7 +119,7 @@ function SingleSelectionItem(_ref3) {
119
119
  refetchOnMount: false,
120
120
  enabled: !!dataset.diseaseDatasets.length
121
121
  });
122
- const hasDiseaseInfo = !isPending && !serverError && !!fetchedData.length;
122
+ const hasDiseaseInfo = !isPending && !serverError && !!fetchedData?.length;
123
123
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
124
124
  className: `d-flex justify-content-between ${hasDiseaseInfo ? "cursor-pointer" : ""}`,
125
125
  onClick: () => {
@@ -202,13 +202,17 @@ function VarItem(_ref5) {
202
202
  });
203
203
  dispatch({
204
204
  type: "set.colorEncoding",
205
- value: "var"
205
+ value: _constants.COLOR_ENCODINGS.VAR
206
206
  });
207
207
  } else if (mode === _constants.SELECTION_MODES.MULTIPLE) {
208
208
  dispatch({
209
209
  type: "select.multivar",
210
210
  var: item
211
211
  });
212
+ dispatch({
213
+ type: "set.colorEncoding",
214
+ value: _constants.COLOR_ENCODINGS.VAR
215
+ });
212
216
  }
213
217
  };
214
218
  const removeVar = () => {
@@ -87,7 +87,7 @@ function DiseaseVarList(_ref) {
87
87
  setDiseaseVars(diseaseData.fetchedData);
88
88
  }
89
89
  }, [diseaseData.fetchedData, diseaseData.isPending, diseaseData.serverError]);
90
- const varMeans = useVarMean(diseaseVars, diseaseVars && dataset.varSort.disease.sort === _constants.VAR_SORT.MATRIX);
90
+ const varMeans = useVarMean(diseaseVars, !!diseaseVars?.length && dataset.varSort.disease.sort === _constants.VAR_SORT.MATRIX);
91
91
  (0, _react.useEffect)(() => {
92
92
  if (dataset.varSort.disease.sort === _constants.VAR_SORT.MATRIX) {
93
93
  if (!varMeans.isPending && !varMeans.serverError) {
@@ -189,7 +189,7 @@ function VarNamesList(_ref2) {
189
189
  // @TODO: deferr sortedVarButtons ?
190
190
  (0, _react.useEffect)(() => {
191
191
  if (dataset.varSort.var.sort === _constants.VAR_SORT.MATRIX) {
192
- if (!varMeans.isPending && !varMeans.serverError) {
192
+ if (!varMeans.isPending && !varMeans.serverError && varMeans.fetchedData) {
193
193
  setSortedVarButtons(_lodash.default.orderBy(varButtons, o => {
194
194
  return sortMeans(o, varMeans.fetchedData);
195
195
  }, dataset.varSort.var.sortOrder));
@@ -50,22 +50,13 @@ const useZarr = function (_ref2) {
50
50
  let s = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
51
51
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : GET_OPTIONS;
52
52
  let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
53
- const {
54
- enabled = true
55
- } = opts;
56
53
  const {
57
54
  data = null,
58
- isPending = false,
55
+ isLoading: isPending = false,
59
56
  error: serverError = null
60
57
  } = (0, _reactQuery.useQuery)({
61
58
  queryKey: ["zarr", url, path, s],
62
- queryFn: () => {
63
- if (enabled) {
64
- return fetchDataFromZarr(url, path, s, options);
65
- } else {
66
- return;
67
- }
68
- },
59
+ queryFn: () => fetchDataFromZarr(url, path, s, options),
69
60
  retry: (failureCount, _ref3) => {
70
61
  let {
71
62
  error
@@ -94,30 +85,21 @@ const useMultipleZarr = function (inputs) {
94
85
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GET_OPTIONS;
95
86
  let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
96
87
  let agg = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : aggregateData;
97
- const {
98
- enabled = true
99
- } = opts;
100
88
  const combine = (0, _react.useCallback)(results => {
101
89
  return {
102
90
  data: agg(inputs, results.map(result => result.data)),
103
- isPending: results.some(result => result.isPending),
91
+ isLoading: results.some(result => result.isLoading),
104
92
  serverError: results.find(result => result.error)
105
93
  };
106
94
  }, [agg, inputs]);
107
95
  const {
108
96
  data = null,
109
- isPending = false,
97
+ isLoading: isPending = false,
110
98
  serverError = null
111
99
  } = (0, _reactQuery.useQueries)({
112
100
  queries: inputs.map(input => ({
113
101
  queryKey: ["zarr", input.url, input.path, input.s],
114
- queryFn: () => {
115
- if (enabled) {
116
- return fetchDataFromZarr(input.url, input.path, input.s, options);
117
- } else {
118
- return;
119
- }
120
- },
102
+ queryFn: () => fetchDataFromZarr(input.url, input.path, input.s, options),
121
103
  retry: (failureCount, _ref4) => {
122
104
  let {
123
105
  error
@@ -132,7 +132,7 @@ const useFilter = data => {
132
132
  filteredIndices: null,
133
133
  valueMin: _lodash.default.min(obsData.data),
134
134
  valueMax: _lodash.default.max(obsData.data),
135
- slicedLength: obsData.data.length
135
+ slicedLength: obsData.data?.length
136
136
  };
137
137
  }
138
138
  }, [dataset.colorEncoding, isContinuous, isInSlice, isPending, obsData.data, obsmData.data, serverError, xData.data]);
@@ -45,12 +45,9 @@ const useFetch = function (endpoint, params) {
45
45
  refetchOnWindowFocus: false
46
46
  };
47
47
  let apiUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
48
- const {
49
- enabled = true
50
- } = opts;
51
48
  const {
52
49
  data: fetchedData = null,
53
- isPending = false,
50
+ isLoading: isPending = false,
54
51
  error: serverError = null
55
52
  } = (0, _reactQuery.useQuery)({
56
53
  queryKey: [endpoint, params],
@@ -58,11 +55,7 @@ const useFetch = function (endpoint, params) {
58
55
  let {
59
56
  signal
60
57
  } = _ref;
61
- if (enabled) {
62
- return fetchData(endpoint, params, signal, apiUrl);
63
- } else {
64
- return;
65
- }
58
+ return fetchData(endpoint, params, signal, apiUrl);
66
59
  },
67
60
  retry: (failureCount, _ref2) => {
68
61
  let {
@@ -87,13 +80,10 @@ const useDebouncedFetch = function (endpoint, params) {
87
80
  refetchOnWindowFocus: false
88
81
  };
89
82
  let apiUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
90
- const {
91
- enabled = true
92
- } = opts;
93
83
  const debouncedParams = (0, _usehooks.useDebounce)(params, delay);
94
84
  const {
95
85
  data: fetchedData = null,
96
- isPending = false,
86
+ isLoading: isPending = false,
97
87
  error: serverError = null
98
88
  } = (0, _reactQuery.useQuery)({
99
89
  queryKey: [endpoint, debouncedParams],
@@ -101,11 +91,7 @@ const useDebouncedFetch = function (endpoint, params) {
101
91
  let {
102
92
  signal
103
93
  } = _ref3;
104
- if (enabled) {
105
- return fetchData(endpoint, debouncedParams, signal, apiUrl);
106
- } else {
107
- return;
108
- }
94
+ return fetchData(endpoint, debouncedParams, signal, apiUrl);
109
95
  },
110
96
  retry: (failureCount, _ref4) => {
111
97
  let {
@@ -141,7 +141,7 @@ export function ObsColsList(_ref) {
141
141
  });
142
142
  dispatch({
143
143
  type: "set.colorEncoding",
144
- value: "obs"
144
+ value: COLOR_ENCODINGS.OBS
145
145
  });
146
146
  };
147
147
  const toggleObs = (item, value) => {
@@ -28,7 +28,7 @@ export function ObsmKeysList() {
28
28
  refetchOnMount: false
29
29
  });
30
30
  useEffect(() => {
31
- if (!isPending && !serverError) {
31
+ if (!isPending && !serverError && fetchedData) {
32
32
  setObsmKeysList(fetchedData);
33
33
  }
34
34
  }, [fetchedData, isPending, serverError]);
@@ -123,7 +123,7 @@ export function Pseudospatial(_ref) {
123
123
  serverError
124
124
  } = usePseudospatialData(plotType);
125
125
  useEffect(() => {
126
- if (!isPending && !serverError) {
126
+ if (!isPending && !serverError && fetchedData) {
127
127
  setData(fetchedData.data);
128
128
  setLayout(fetchedData.layout);
129
129
  updateColorscale(colorscale.current);
@@ -109,7 +109,7 @@ export function SingleSelectionItem(_ref3) {
109
109
  refetchOnMount: false,
110
110
  enabled: !!dataset.diseaseDatasets.length
111
111
  });
112
- const hasDiseaseInfo = !isPending && !serverError && !!fetchedData.length;
112
+ const hasDiseaseInfo = !isPending && !serverError && !!fetchedData?.length;
113
113
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
114
114
  className: `d-flex justify-content-between ${hasDiseaseInfo ? "cursor-pointer" : ""}`,
115
115
  onClick: () => {
@@ -192,13 +192,17 @@ export function VarItem(_ref5) {
192
192
  });
193
193
  dispatch({
194
194
  type: "set.colorEncoding",
195
- value: "var"
195
+ value: COLOR_ENCODINGS.VAR
196
196
  });
197
197
  } else if (mode === SELECTION_MODES.MULTIPLE) {
198
198
  dispatch({
199
199
  type: "select.multivar",
200
200
  var: item
201
201
  });
202
+ dispatch({
203
+ type: "set.colorEncoding",
204
+ value: COLOR_ENCODINGS.VAR
205
+ });
202
206
  }
203
207
  };
204
208
  const removeVar = () => {
@@ -78,7 +78,7 @@ function DiseaseVarList(_ref) {
78
78
  setDiseaseVars(diseaseData.fetchedData);
79
79
  }
80
80
  }, [diseaseData.fetchedData, diseaseData.isPending, diseaseData.serverError]);
81
- const varMeans = useVarMean(diseaseVars, diseaseVars && dataset.varSort.disease.sort === VAR_SORT.MATRIX);
81
+ const varMeans = useVarMean(diseaseVars, !!diseaseVars?.length && dataset.varSort.disease.sort === VAR_SORT.MATRIX);
82
82
  useEffect(() => {
83
83
  if (dataset.varSort.disease.sort === VAR_SORT.MATRIX) {
84
84
  if (!varMeans.isPending && !varMeans.serverError) {
@@ -180,7 +180,7 @@ export function VarNamesList(_ref2) {
180
180
  // @TODO: deferr sortedVarButtons ?
181
181
  useEffect(() => {
182
182
  if (dataset.varSort.var.sort === VAR_SORT.MATRIX) {
183
- if (!varMeans.isPending && !varMeans.serverError) {
183
+ if (!varMeans.isPending && !varMeans.serverError && varMeans.fetchedData) {
184
184
  setSortedVarButtons(_.orderBy(varButtons, o => {
185
185
  return sortMeans(o, varMeans.fetchedData);
186
186
  }, dataset.varSort.var.sortOrder));
@@ -43,22 +43,13 @@ export const useZarr = function (_ref2) {
43
43
  let s = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
44
44
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : GET_OPTIONS;
45
45
  let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
46
- const {
47
- enabled = true
48
- } = opts;
49
46
  const {
50
47
  data = null,
51
- isPending = false,
48
+ isLoading: isPending = false,
52
49
  error: serverError = null
53
50
  } = useQuery({
54
51
  queryKey: ["zarr", url, path, s],
55
- queryFn: () => {
56
- if (enabled) {
57
- return fetchDataFromZarr(url, path, s, options);
58
- } else {
59
- return;
60
- }
61
- },
52
+ queryFn: () => fetchDataFromZarr(url, path, s, options),
62
53
  retry: (failureCount, _ref3) => {
63
54
  let {
64
55
  error
@@ -86,30 +77,21 @@ export const useMultipleZarr = function (inputs) {
86
77
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GET_OPTIONS;
87
78
  let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
88
79
  let agg = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : aggregateData;
89
- const {
90
- enabled = true
91
- } = opts;
92
80
  const combine = useCallback(results => {
93
81
  return {
94
82
  data: agg(inputs, results.map(result => result.data)),
95
- isPending: results.some(result => result.isPending),
83
+ isLoading: results.some(result => result.isLoading),
96
84
  serverError: results.find(result => result.error)
97
85
  };
98
86
  }, [agg, inputs]);
99
87
  const {
100
88
  data = null,
101
- isPending = false,
89
+ isLoading: isPending = false,
102
90
  serverError = null
103
91
  } = useQueries({
104
92
  queries: inputs.map(input => ({
105
93
  queryKey: ["zarr", input.url, input.path, input.s],
106
- queryFn: () => {
107
- if (enabled) {
108
- return fetchDataFromZarr(input.url, input.path, input.s, options);
109
- } else {
110
- return;
111
- }
112
- },
94
+ queryFn: () => fetchDataFromZarr(input.url, input.path, input.s, options),
113
95
  retry: (failureCount, _ref4) => {
114
96
  let {
115
97
  error
@@ -125,7 +125,7 @@ export const useFilter = data => {
125
125
  filteredIndices: null,
126
126
  valueMin: _.min(obsData.data),
127
127
  valueMax: _.max(obsData.data),
128
- slicedLength: obsData.data.length
128
+ slicedLength: obsData.data?.length
129
129
  };
130
130
  }
131
131
  }, [dataset.colorEncoding, isContinuous, isInSlice, isPending, obsData.data, obsmData.data, serverError, xData.data]);
@@ -38,12 +38,9 @@ export const useFetch = function (endpoint, params) {
38
38
  refetchOnWindowFocus: false
39
39
  };
40
40
  let apiUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
41
- const {
42
- enabled = true
43
- } = opts;
44
41
  const {
45
42
  data: fetchedData = null,
46
- isPending = false,
43
+ isLoading: isPending = false,
47
44
  error: serverError = null
48
45
  } = useQuery({
49
46
  queryKey: [endpoint, params],
@@ -51,11 +48,7 @@ export const useFetch = function (endpoint, params) {
51
48
  let {
52
49
  signal
53
50
  } = _ref;
54
- if (enabled) {
55
- return fetchData(endpoint, params, signal, apiUrl);
56
- } else {
57
- return;
58
- }
51
+ return fetchData(endpoint, params, signal, apiUrl);
59
52
  },
60
53
  retry: (failureCount, _ref2) => {
61
54
  let {
@@ -79,13 +72,10 @@ export const useDebouncedFetch = function (endpoint, params) {
79
72
  refetchOnWindowFocus: false
80
73
  };
81
74
  let apiUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
82
- const {
83
- enabled = true
84
- } = opts;
85
75
  const debouncedParams = useDebounce(params, delay);
86
76
  const {
87
77
  data: fetchedData = null,
88
- isPending = false,
78
+ isLoading: isPending = false,
89
79
  error: serverError = null
90
80
  } = useQuery({
91
81
  queryKey: [endpoint, debouncedParams],
@@ -93,11 +83,7 @@ export const useDebouncedFetch = function (endpoint, params) {
93
83
  let {
94
84
  signal
95
85
  } = _ref3;
96
- if (enabled) {
97
- return fetchData(endpoint, debouncedParams, signal, apiUrl);
98
- } else {
99
- return;
100
- }
86
+ return fetchData(endpoint, debouncedParams, signal, apiUrl);
101
87
  },
102
88
  retry: (failureCount, _ref4) => {
103
89
  let {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haniffalab/cherita-react",
3
- "version": "1.0.0-dev.2025-03-24.e68f9e22",
3
+ "version": "1.0.0-dev.2025-03-24.4a3636c2",
4
4
  "author": "Haniffa Lab",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -124,5 +124,5 @@
124
124
  "url": "https://github.com/haniffalab/cherita-react/issues"
125
125
  },
126
126
  "homepage": "https://github.com/haniffalab/cherita-react#readme",
127
- "prereleaseSha": "e68f9e229175e0ae46213cb14d13374dceec0af0"
127
+ "prereleaseSha": "4a3636c254e52e5e84f1b75d398255b31c46099f"
128
128
  }