@haniffalab/cherita-react 0.2.0-dev.2024-03-27.ee875ba3 → 0.2.0-dev.2024-04-04.2167aa53
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/App.scss +7 -0
- package/dist/components/obs-list/ObsList.js +15 -6
- package/package.json +2 -2
package/dist/App.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import "bootstrap/scss/accordion";
|
|
2
|
+
|
|
1
3
|
// Theme CSS
|
|
2
4
|
.cherita-container {
|
|
3
5
|
margin: 40px auto;
|
|
@@ -73,6 +75,11 @@
|
|
|
73
75
|
left: 20px;
|
|
74
76
|
width: 200px;
|
|
75
77
|
}
|
|
78
|
+
|
|
79
|
+
.cherita-accordion-active .accordion-button {
|
|
80
|
+
background-color: $accordion-button-active-bg
|
|
81
|
+
}
|
|
82
|
+
|
|
76
83
|
.grad-step {
|
|
77
84
|
display: inline-block;
|
|
78
85
|
height: 20px;
|
|
@@ -48,13 +48,14 @@ function binDiscrete(data) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
function ObsColsList() {
|
|
51
|
+
var _dataset$selectedObs;
|
|
51
52
|
const ENDPOINT = "obs/cols";
|
|
52
53
|
const dataset = (0, _DatasetContext.useDataset)();
|
|
53
54
|
const dispatch = (0, _DatasetContext.useDatasetDispatch)();
|
|
54
55
|
const [obsColsList, setObsColsList] = (0, _react.useState)([]);
|
|
55
56
|
const [obs, setObs] = (0, _react.useState)([]);
|
|
56
57
|
const [updatedObsColsList, setUpdatedObsColsList] = (0, _react.useState)(false);
|
|
57
|
-
const [active, setActive] = (0, _react.useState)(null);
|
|
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
|
});
|
|
@@ -122,6 +123,8 @@ function ObsColsList() {
|
|
|
122
123
|
if (dataset.selectedObs) {
|
|
123
124
|
validateSelection(dataset.selectedObs);
|
|
124
125
|
setActive(dataset.selectedObs.name);
|
|
126
|
+
} else {
|
|
127
|
+
setActive(null);
|
|
125
128
|
}
|
|
126
129
|
}, [dataset.selectedObs, validateSelection]);
|
|
127
130
|
(0, _react.useEffect)(() => {
|
|
@@ -131,8 +134,10 @@ function ObsColsList() {
|
|
|
131
134
|
});
|
|
132
135
|
}, [obs, dispatch]);
|
|
133
136
|
function categoricalList(item) {
|
|
137
|
+
let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
134
138
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
|
|
135
139
|
eventKey: item.name,
|
|
140
|
+
className: item.name === active ? "cherita-accordion-active" : "",
|
|
136
141
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Header, {
|
|
137
142
|
children: item.name
|
|
138
143
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Body, {
|
|
@@ -151,8 +156,10 @@ function ObsColsList() {
|
|
|
151
156
|
}, item.name);
|
|
152
157
|
}
|
|
153
158
|
function continuousList(item) {
|
|
159
|
+
let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
154
160
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
|
|
155
161
|
eventKey: item.name,
|
|
162
|
+
className: item.name === active ? "cherita-accordion-active" : "",
|
|
156
163
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Header, {
|
|
157
164
|
children: item.name
|
|
158
165
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Body, {
|
|
@@ -171,8 +178,10 @@ function ObsColsList() {
|
|
|
171
178
|
}, item.name);
|
|
172
179
|
}
|
|
173
180
|
function otherList(item) {
|
|
181
|
+
let active = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
174
182
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Accordion.Item, {
|
|
175
183
|
eventKey: item.name,
|
|
184
|
+
className: item.name === active ? "cherita-accordion-active" : "",
|
|
176
185
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Header, {
|
|
177
186
|
children: item.name
|
|
178
187
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion.Body, {
|
|
@@ -182,13 +191,13 @@ function ObsColsList() {
|
|
|
182
191
|
}
|
|
183
192
|
const obsList = (0, _react.useMemo)(() => obsColsList.map(item => {
|
|
184
193
|
if (item.type === "categorical") {
|
|
185
|
-
return categoricalList(item);
|
|
194
|
+
return categoricalList(item, active);
|
|
186
195
|
} else if (item.type === "continuous") {
|
|
187
|
-
return continuousList(item);
|
|
196
|
+
return continuousList(item, active);
|
|
188
197
|
} else {
|
|
189
|
-
return otherList(item);
|
|
198
|
+
return otherList(item, active);
|
|
190
199
|
}
|
|
191
|
-
}), [obsColsList]);
|
|
200
|
+
}), [obsColsList, active]);
|
|
192
201
|
if (!serverError) {
|
|
193
202
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
194
203
|
className: "position-relative",
|
|
@@ -196,7 +205,7 @@ function ObsColsList() {
|
|
|
196
205
|
className: "list-group overflow-auto",
|
|
197
206
|
children: [isPending && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LoadingSpinner.LoadingSpinner, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Accordion, {
|
|
198
207
|
flush: true,
|
|
199
|
-
|
|
208
|
+
defaultActiveKey: active,
|
|
200
209
|
onSelect: key => {
|
|
201
210
|
if (key != null) {
|
|
202
211
|
dispatch({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haniffalab/cherita-react",
|
|
3
|
-
"version": "0.2.0-dev.2024-
|
|
3
|
+
"version": "0.2.0-dev.2024-04-04.2167aa53",
|
|
4
4
|
"author": "",
|
|
5
5
|
"license": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"url": "https://github.com/haniffalab/cherita-react/issues"
|
|
79
79
|
},
|
|
80
80
|
"homepage": "https://github.com/haniffalab/cherita-react#readme",
|
|
81
|
-
"prereleaseSha": "
|
|
81
|
+
"prereleaseSha": "2167aa53fbf527f25f71ab2e3825a3c1fe2033a6"
|
|
82
82
|
}
|