@haniffalab/cherita-react 0.2.0-dev.2024-05-21.ca7d726c → 0.2.0-dev.2024-09-26.f9979478

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 (32) hide show
  1. package/dist/App.scss +67 -12
  2. package/dist/components/Offcanvas/index.js +9 -6
  3. package/dist/components/dotplot/Dotplot.js +5 -189
  4. package/dist/components/dotplot/DotplotControls.js +197 -0
  5. package/dist/components/heatmap/Heatmap.js +5 -31
  6. package/dist/components/heatmap/HeatmapControls.js +36 -0
  7. package/dist/components/matrixplot/Matrixplot.js +5 -59
  8. package/dist/components/matrixplot/MatrixplotControls.js +65 -0
  9. package/dist/components/obs-list/ObsList.js +251 -93
  10. package/dist/components/obs-list/ObsValueList.js +101 -0
  11. package/dist/components/obsm-list/ObsmList.js +25 -16
  12. package/dist/components/scatterplot/Legend.js +28 -36
  13. package/dist/components/scatterplot/Scatterplot.js +303 -119
  14. package/dist/components/scatterplot/ScatterplotControls.js +93 -0
  15. package/dist/components/scatterplot/SpatialControls.js +172 -0
  16. package/dist/components/scatterplot/Toolbox.js +18 -72
  17. package/dist/components/search-bar/SearchBar.js +2 -2
  18. package/dist/components/search-bar/SearchResults.js +2 -2
  19. package/dist/components/var-list/VarList.js +102 -40
  20. package/dist/components/violin/Violin.js +7 -46
  21. package/dist/components/violin/ViolinControls.js +50 -0
  22. package/dist/constants/colorscales.js +28 -0
  23. package/dist/constants/constants.js +11 -43
  24. package/dist/context/DatasetContext.js +122 -23
  25. package/dist/helpers/color-helper.js +54 -21
  26. package/dist/helpers/zarr-helper.js +39 -17
  27. package/dist/index.js +17 -11
  28. package/dist/utils/LoadingIndicators.js +33 -0
  29. package/dist/utils/requests.js +1 -1
  30. package/dist/utils/search.js +4 -3
  31. package/package.json +10 -4
  32. package/dist/utils/LoadingSpinner.js +0 -44
@@ -4,70 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Matrixplot = Matrixplot;
7
- exports.MatrixplotControls = MatrixplotControls;
8
- require("bootstrap/dist/css/bootstrap.min.css");
9
7
  var _react = _interopRequireWildcard(require("react"));
8
+ var _reactBootstrap = require("react-bootstrap");
10
9
  var _reactPlotly = _interopRequireDefault(require("react-plotly.js"));
11
10
  var _DatasetContext = require("../../context/DatasetContext");
12
- var _constants = require("../../constants/constants");
13
- var _reactBootstrap = require("react-bootstrap");
11
+ var _LoadingIndicators = require("../../utils/LoadingIndicators");
14
12
  var _requests = require("../../utils/requests");
15
- var _LoadingSpinner = require("../../utils/LoadingSpinner");
16
13
  var _jsxRuntime = require("react/jsx-runtime");
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
- function MatrixplotControls() {
21
- const dataset = (0, _DatasetContext.useDataset)();
22
- const dispatch = (0, _DatasetContext.useDatasetDispatch)();
23
- const colorScaleList = _constants.PLOTLY_COLORSCALES.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
24
- active: dataset.controls.colorScale === item,
25
- onClick: () => {
26
- dispatch({
27
- type: "set.controls.colorScale",
28
- colorScale: item
29
- });
30
- },
31
- children: item
32
- }, item));
33
- const standardScaleList = _constants.MATRIXPLOT_STANDARDSCALES.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
34
- active: dataset.controls.standardScale === item.name,
35
- onClick: () => {
36
- dispatch({
37
- type: "set.controls.standardScale",
38
- standardScale: item.value
39
- });
40
- },
41
- children: item.name
42
- }, item.value));
43
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonToolbar, {
44
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ButtonGroup, {
45
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
46
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
47
- id: "dropdownColorscale",
48
- variant: "light",
49
- children: dataset.controls.colorScale
50
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
51
- children: colorScaleList
52
- })]
53
- })
54
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ButtonGroup, {
55
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.InputGroup, {
56
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.InputGroup.Text, {
57
- children: "Standard scale"
58
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
59
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
60
- id: "dropdownStandardScale",
61
- variant: "light",
62
- children: dataset.controls.standardScale
63
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
64
- children: standardScaleList
65
- })]
66
- })]
67
- })
68
- })]
69
- });
70
- }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
71
17
  function Matrixplot() {
72
18
  const ENDPOINT = "matrixplot";
73
19
  const dataset = (0, _DatasetContext.useDataset)();
@@ -132,7 +78,7 @@ function Matrixplot() {
132
78
  if (hasSelections) {
133
79
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
134
80
  className: "cherita-matrixplot position-relative",
135
- children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingSpinner.LoadingSpinner, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactPlotly.default, {
81
+ children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicators.LoadingSpinner, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactPlotly.default, {
136
82
  data: data,
137
83
  layout: layout,
138
84
  useResizeHandler: true,
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MatrixplotControls = MatrixplotControls;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _lodash = _interopRequireDefault(require("lodash"));
9
+ var _reactBootstrap = require("react-bootstrap");
10
+ var _colorscales = require("../../constants/colorscales");
11
+ var _constants = require("../../constants/constants");
12
+ var _DatasetContext = require("../../context/DatasetContext");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function MatrixplotControls() {
16
+ const dataset = (0, _DatasetContext.useDataset)();
17
+ const dispatch = (0, _DatasetContext.useDatasetDispatch)();
18
+ const colorScaleList = _lodash.default.keys(_colorscales.COLORSCALES).map(key => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
19
+ active: dataset.controls.colorScale === key,
20
+ onClick: () => {
21
+ dispatch({
22
+ type: "set.controls.colorScale",
23
+ colorScale: key
24
+ });
25
+ },
26
+ children: key
27
+ }, key));
28
+ const standardScaleList = _constants.MATRIXPLOT_STANDARDSCALES.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Item, {
29
+ active: dataset.controls.standardScale === item.name,
30
+ onClick: () => {
31
+ dispatch({
32
+ type: "set.controls.standardScale",
33
+ standardScale: item.value
34
+ });
35
+ },
36
+ children: item.name
37
+ }, item.value));
38
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonToolbar, {
39
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ButtonGroup, {
40
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
41
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
42
+ id: "dropdownColorscale",
43
+ variant: "light",
44
+ children: dataset.controls.colorScale
45
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
46
+ children: colorScaleList
47
+ })]
48
+ })
49
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ButtonGroup, {
50
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.InputGroup, {
51
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.InputGroup.Text, {
52
+ children: "Standard scale"
53
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Dropdown, {
54
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Toggle, {
55
+ id: "dropdownStandardScale",
56
+ variant: "light",
57
+ children: dataset.controls.standardScale
58
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Dropdown.Menu, {
59
+ children: standardScaleList
60
+ })]
61
+ })]
62
+ })
63
+ })]
64
+ });
65
+ }
@@ -4,19 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ObsColsList = ObsColsList;
7
- require("bootstrap/dist/css/bootstrap.min.css");
8
- require("bootstrap/dist/js/bootstrap.bundle.min.js");
9
- var _lodash = _interopRequireDefault(require("lodash"));
10
7
  var _react = _interopRequireWildcard(require("react"));
8
+ var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
9
+ var _reactFontawesome = require("@fortawesome/react-fontawesome");
10
+ var _lodash = _interopRequireDefault(require("lodash"));
11
+ var _reactBootstrap = require("react-bootstrap");
12
+ var _ObsValueList = require("./ObsValueList");
13
+ var _constants = require("../../constants/constants");
11
14
  var _DatasetContext = require("../../context/DatasetContext");
15
+ var _colorHelper = require("../../helpers/color-helper");
16
+ var _LoadingIndicators = require("../../utils/LoadingIndicators");
12
17
  var _requests = require("../../utils/requests");
13
- var _chromaJs = _interopRequireDefault(require("chroma-js"));
14
- var _LoadingSpinner = require("../../utils/LoadingSpinner");
15
- var _reactBootstrap = require("react-bootstrap");
16
18
  var _jsxRuntime = require("react/jsx-runtime");
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
22
  const N_BINS = 5;
21
23
  function binContinuous(data) {
22
24
  let nBins = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : N_BINS;
@@ -47,17 +49,19 @@ function binDiscrete(data) {
47
49
  };
48
50
  }
49
51
  function ObsColsList() {
50
- var _dataset$selectedObs;
52
+ var _dataset$selectedObs, _dataset$selectedObs4, _dataset$selectedObs6;
51
53
  const ENDPOINT = "obs/cols";
52
54
  const dataset = (0, _DatasetContext.useDataset)();
53
55
  const dispatch = (0, _DatasetContext.useDatasetDispatch)();
54
- const [obsColsList, setObsColsList] = (0, _react.useState)([]);
55
- const [obs, setObs] = (0, _react.useState)([]);
56
- const [updatedObsColsList, setUpdatedObsColsList] = (0, _react.useState)(false);
56
+ const [obsCols, setObsCols] = (0, _react.useState)({});
57
+ const [updatedObsCols, setupdatedObsCols] = (0, _react.useState)(false);
57
58
  const [active, setActive] = (0, _react.useState)((_dataset$selectedObs = dataset.selectedObs) === null || _dataset$selectedObs === void 0 ? void 0 : _dataset$selectedObs.name);
58
59
  const [params, setParams] = (0, _react.useState)({
59
60
  url: dataset.url
60
61
  });
62
+ const {
63
+ getColor
64
+ } = (0, _colorHelper.useColor)();
61
65
  (0, _react.useEffect)(() => {
62
66
  setParams(p => {
63
67
  return {
@@ -73,101 +77,265 @@ function ObsColsList() {
73
77
  } = (0, _requests.useFetch)(ENDPOINT, params, {
74
78
  refetchOnMount: false
75
79
  });
76
- const validateSelection = (0, _react.useCallback)(selectedObs => {
77
- if (updatedObsColsList) {
78
- if (!_lodash.default.some(obsColsList, selectedObs)) {
80
+ const validateSelection = (0, _react.useCallback)(obs => {
81
+ if (!_lodash.default.isEqual(_lodash.default.omit(obsCols[obs.name], ["omit"]), _lodash.default.omit(obs, ["omit"]))) return false;
82
+ if (!_lodash.default.isEqual(obsCols[obs.name].omit, obs.omit)) {
83
+ setObsCols(o => {
84
+ return {
85
+ ...o,
86
+ [obs.name]: {
87
+ ...o[obs.name],
88
+ omit: obs.omit
89
+ }
90
+ };
91
+ });
92
+ }
93
+ return true;
94
+ }, [obsCols]);
95
+ (0, _react.useEffect)(() => {
96
+ if (updatedObsCols) {
97
+ if (dataset.selectedObs) {
98
+ if (validateSelection(dataset.selectedObs)) {
99
+ setActive(dataset.selectedObs.name);
100
+ } else {
101
+ dispatch({
102
+ type: "select.obs",
103
+ obs: null
104
+ });
105
+ setActive(null);
106
+ }
107
+ } else {
79
108
  setActive(null);
80
- dispatch({
81
- type: "obsSelected",
82
- obs: null
83
- });
84
109
  }
85
110
  }
86
- }, [dispatch, obsColsList, updatedObsColsList]);
111
+ }, [dataset.selectedObs, dispatch, updatedObsCols, validateSelection]);
112
+
113
+ // @TODO: change api to return all obs and truncate here
87
114
  (0, _react.useEffect)(() => {
88
115
  if (!isPending && !serverError) {
89
- setObs(fetchedData.reduce((result, key) => {
90
- const colors = _chromaJs.default.scale("Accent").colors(key.n_values, "rgb");
91
- result[key.name] = {
92
- type: key.type
93
- };
94
- if (key.type === "categorical") {
95
- result[key.name]["is_truncated"] = key.is_truncated;
96
- result[key.name]["n_values"] = key.n_values;
97
- result[key.name]["values"] = key.values;
98
- result[key.name]["state"] = key.values.map((value, index) => {
99
- return {
100
- value: value,
101
- color: (0, _chromaJs.default)(colors[index]).rgb(),
102
- checked: true
103
- };
104
- });
105
- }
106
- return result;
107
- }, {}));
108
- setObsColsList(fetchedData.map(d => {
109
- if (d.type === "continuous") {
116
+ setObsCols(_lodash.default.keyBy(_lodash.default.map(fetchedData, d => {
117
+ if (d.type === _constants.OBS_TYPES.CONTINUOUS) {
110
118
  d = binContinuous(d);
111
- }
112
- if (d.type === "discrete") {
119
+ } else if (d.type === _constants.OBS_TYPES.DISCRETE) {
113
120
  d = binDiscrete(d);
114
121
  }
115
- return d;
116
- }));
117
- setUpdatedObsColsList(true);
122
+ return {
123
+ ...d,
124
+ omit: []
125
+ };
126
+ }), "name"));
127
+ setupdatedObsCols(true);
118
128
  }
119
129
  }, [fetchedData, isPending, serverError]);
120
- (0, _react.useEffect)(() => {
121
- if (dataset.selectedObs) {
122
- validateSelection(dataset.selectedObs);
123
- setActive(dataset.selectedObs.name);
124
- } else {
125
- setActive(null);
126
- }
127
- }, [dataset.selectedObs, validateSelection]);
128
- (0, _react.useEffect)(() => {
129
- dispatch({
130
- type: "set.obs",
131
- value: obs
130
+ const toggleAll = (0, _react.useCallback)((item, checked, active) => {
131
+ const omit = checked ? [] : _lodash.default.map(item.values, v => item.codes[v]);
132
+ setObsCols(o => {
133
+ return {
134
+ ...o,
135
+ [item.name]: {
136
+ ...item,
137
+ omit: omit
138
+ }
139
+ };
132
140
  });
133
- }, [obs, dispatch]);
141
+ if (active === item.name) {
142
+ dispatch({
143
+ type: "select.obs",
144
+ obs: {
145
+ ...item,
146
+ omit: omit
147
+ }
148
+ });
149
+ }
150
+ }, [dispatch]);
134
151
  const categoricalList = (0, _react.useCallback)(function (item) {
152
+ var _dataset$selectedObs2, _dataset$selectedObs3;
135
153
  let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
154
+ const codesMap = _lodash.default.invert(item.codes);
155
+ const inLabelObs = _lodash.default.some(dataset.labelObs, i => _lodash.default.isEqual(i, {
156
+ name: item.name,
157
+ type: item.type,
158
+ codesMap: codesMap
159
+ }));
160
+ const min = _lodash.default.min(_lodash.default.values(item.codes));
161
+ const max = _lodash.default.max(_lodash.default.values(item.codes));
136
162
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
137
163
  eventKey: item.name,
138
164
  className: item.name === active ? "cherita-accordion-active" : "",
139
165
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Header, {
140
166
  children: item.name
141
167
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Body, {
142
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
143
- variant: "flush",
144
- children: item.values.map((value, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
168
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ListGroup, {
169
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
145
170
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
146
- className: "d-flex justify-content-between",
171
+ className: "d-flex",
147
172
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
148
- className: "text-wrap text-break",
149
- children: value
150
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
151
- className: "cm-string cm-color",
152
- style: {
153
- backgroundColor: "rgb(".concat(obs[item.name]["state"][index]["color"], ")")
154
- }
173
+ className: "flex-grow-1",
174
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Form.Check, {
175
+ // prettier-ignore
176
+ type: "switch",
177
+ id: "custom-switch",
178
+ label: "Toggle all",
179
+ checked: !item.omit.length,
180
+ onChange: () => {
181
+ toggleAll(item, !!item.omit.length, active);
182
+ }
183
+ })
184
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
185
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonGroup, {
186
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
187
+ variant: inLabelObs ? "primary" : "outline-primary",
188
+ size: "sm",
189
+ onClick: () => {
190
+ if (inLabelObs) {
191
+ dispatch({
192
+ type: "remove.label.obs",
193
+ obsName: item.name
194
+ });
195
+ } else {
196
+ dispatch({
197
+ type: "add.label.obs",
198
+ obs: {
199
+ name: item.name,
200
+ type: item.type,
201
+ codesMap: codesMap
202
+ }
203
+ });
204
+ }
205
+ },
206
+ title: "Add to tooltip",
207
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
208
+ icon: _freeSolidSvgIcons.faFont
209
+ })
210
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
211
+ variant: dataset.sliceBy.obs && ((_dataset$selectedObs2 = dataset.selectedObs) === null || _dataset$selectedObs2 === void 0 ? void 0 : _dataset$selectedObs2.name) === item.name ? "primary" : "outline-primary",
212
+ size: "sm",
213
+ onClick: () => {
214
+ dispatch({
215
+ type: "toggle.slice.obs",
216
+ obs: item
217
+ });
218
+ },
219
+ title: "Slice to selected",
220
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
221
+ icon: _freeSolidSvgIcons.faEye
222
+ })
223
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
224
+ variant: dataset.colorEncoding === _constants.COLOR_ENCODINGS.OBS && ((_dataset$selectedObs3 = dataset.selectedObs) === null || _dataset$selectedObs3 === void 0 ? void 0 : _dataset$selectedObs3.name) === item.name ? "primary" : "outline-primary",
225
+ size: "sm",
226
+ onClick: () => {
227
+ dispatch({
228
+ type: "select.obs",
229
+ obs: item
230
+ });
231
+ dispatch({
232
+ type: "set.colorEncoding",
233
+ value: "obs"
234
+ });
235
+ },
236
+ title: "Set as color encoding",
237
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
238
+ icon: _freeSolidSvgIcons.faDroplet
239
+ })
240
+ })]
241
+ })
155
242
  })]
156
243
  })
157
- }, index))
244
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ObsValueList.ObsValueList, {
245
+ item: item,
246
+ onChange: value => {
247
+ const newItem = {
248
+ ...item,
249
+ omit: !_lodash.default.includes(item.omit, item.codes[value]) ? [...item.omit, item.codes[value]] : _lodash.default.filter(item.omit, o => o !== item.codes[value])
250
+ };
251
+ setObsCols(o => {
252
+ return {
253
+ ...o,
254
+ [item.name]: newItem
255
+ };
256
+ });
257
+ if (active === item.name) {
258
+ dispatch({
259
+ type: "select.obs",
260
+ obs: newItem
261
+ });
262
+ }
263
+ },
264
+ getFillColor: value => {
265
+ return "rgb(".concat(getColor((item.codes[value] - min) / (max - min), true, _lodash.default.includes(item.omit, item.codes[value]), {
266
+ alpha: 1
267
+ }, "obs"), ")");
268
+ }
269
+ })]
158
270
  })
159
271
  })]
160
272
  }, item.name);
161
- }, [obs]);
273
+ }, [dataset.labelObs, dataset.sliceBy.obs, (_dataset$selectedObs4 = dataset.selectedObs) === null || _dataset$selectedObs4 === void 0 ? void 0 : _dataset$selectedObs4.name, dataset.colorEncoding, toggleAll, dispatch, getColor]);
162
274
  const continuousList = (0, _react.useCallback)(function (item) {
275
+ var _dataset$selectedObs5;
163
276
  let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
277
+ const inLabelObs = _lodash.default.some(dataset.labelObs, i => _lodash.default.isEqual(i, {
278
+ name: item.name,
279
+ type: item.type
280
+ }));
164
281
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
165
282
  eventKey: item.name,
166
283
  className: item.name === active ? "cherita-accordion-active" : "",
167
284
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Header, {
168
285
  children: item.name
169
286
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Body, {
170
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
287
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup, {
288
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.ListGroup.Item, {
289
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
290
+ className: "d-flex justify-content-end",
291
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.ButtonGroup, {
292
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
293
+ variant: inLabelObs ? "primary" : "outline-primary",
294
+ size: "sm",
295
+ onClick: () => {
296
+ if (inLabelObs) {
297
+ dispatch({
298
+ type: "remove.label.obs",
299
+ obsName: item.name
300
+ });
301
+ } else {
302
+ dispatch({
303
+ type: "add.label.obs",
304
+ obs: {
305
+ name: item.name,
306
+ type: item.type
307
+ }
308
+ });
309
+ }
310
+ },
311
+ title: "Add to tooltip",
312
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
313
+ icon: _freeSolidSvgIcons.faFont
314
+ })
315
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Button, {
316
+ variant: dataset.colorEncoding === _constants.COLOR_ENCODINGS.OBS && ((_dataset$selectedObs5 = dataset.selectedObs) === null || _dataset$selectedObs5 === void 0 ? void 0 : _dataset$selectedObs5.name) === item.name ? "primary" : "outline-primary",
317
+ size: "sm",
318
+ onClick: key => {
319
+ if (key != null) {
320
+ dispatch({
321
+ type: "select.obs",
322
+ obs: item
323
+ });
324
+ dispatch({
325
+ type: "set.colorEncoding",
326
+ value: "obs"
327
+ });
328
+ }
329
+ },
330
+ title: "Set as color encoding",
331
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFontawesome.FontAwesomeIcon, {
332
+ icon: _freeSolidSvgIcons.faDroplet
333
+ })
334
+ })]
335
+ })
336
+ })
337
+ })
338
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
171
339
  children: ["Min: ", item.min]
172
340
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
173
341
  children: ["Max: ", item.max]
@@ -180,7 +348,7 @@ function ObsColsList() {
180
348
  })]
181
349
  })]
182
350
  }, item.name);
183
- }, []);
351
+ }, [dataset.colorEncoding, dataset.labelObs, (_dataset$selectedObs6 = dataset.selectedObs) === null || _dataset$selectedObs6 === void 0 ? void 0 : _dataset$selectedObs6.name, dispatch]);
184
352
  const otherList = (0, _react.useCallback)(function (item) {
185
353
  let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
186
354
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
@@ -193,35 +361,25 @@ function ObsColsList() {
193
361
  })]
194
362
  }, item.name);
195
363
  }, []);
196
- const obsList = (0, _react.useMemo)(() => obsColsList.map(item => {
197
- if (item.type === "categorical") {
364
+ const obsList = (0, _react.useMemo)(() => _lodash.default.keys(obsCols).map(o => {
365
+ const item = obsCols[o];
366
+ if (item.type === _constants.OBS_TYPES.CATEGORICAL) {
198
367
  return categoricalList(item, active);
199
- } else if (item.type === "continuous") {
368
+ } else if (item.type === _constants.OBS_TYPES.CONTINUOUS) {
200
369
  return continuousList(item, active);
201
370
  } else {
202
371
  return otherList(item, active);
203
372
  }
204
- }), [obsColsList, categoricalList, active, continuousList, otherList]);
373
+ }), [obsCols, categoricalList, active, continuousList, otherList]);
205
374
  if (!serverError) {
206
375
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
207
- className: "position-relative",
376
+ className: "position-relative h-100",
208
377
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
209
- className: "list-group overflow-auto",
210
- children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingSpinner.LoadingSpinner, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion, {
378
+ className: "list-group overflow-auto h-100",
379
+ children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingIndicators.LoadingSpinner, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion, {
211
380
  flush: true,
212
381
  defaultActiveKey: active,
213
- onSelect: key => {
214
- if (key != null) {
215
- dispatch({
216
- type: "obsSelected",
217
- obs: obsColsList.find(obs => obs.name === key)
218
- });
219
- dispatch({
220
- type: "set.colorEncoding",
221
- value: "obs"
222
- });
223
- }
224
- },
382
+ alwaysOpen: true,
225
383
  children: obsList
226
384
  })]
227
385
  })