@adriansteffan/reactive 0.0.40 → 0.0.42
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/mod-UqYdghJl.js +63938 -0
- package/dist/reactive.es.js +1 -1
- package/dist/reactive.umd.js +73 -55
- package/dist/style.css +3 -3
- package/dist/{web-B_iADh05.js → web-eGzX65_f.js} +1 -1
- package/dist/{web-WH3nbOGp.js → web-pL-YTTVv.js} +1 -1
- package/package.json +2 -2
- package/src/components/quest.tsx +3 -3
- package/src/components/upload.tsx +41 -6
- package/dist/mod-atv0jMSt.js +0 -73034
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adriansteffan/reactive",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-dom": "^18.2.0",
|
|
48
48
|
"react-icons": "^5.1.0",
|
|
49
49
|
"react-toastify": "^10.0.6",
|
|
50
|
-
"survey-react-ui": "^
|
|
50
|
+
"survey-react-ui": "^2.4.1",
|
|
51
51
|
"uuid": "^11.0.3"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
package/src/components/quest.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useCallback, createElement, ComponentType } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { defaultCss, Model, Question, Serializer } from 'survey-core';
|
|
3
3
|
import { ReactQuestionFactory, Survey, SurveyQuestionElementBase } from 'survey-react-ui';
|
|
4
4
|
import { ContrastLight } from 'survey-core/themes';
|
|
5
|
-
import 'survey-core/
|
|
5
|
+
import 'survey-core/survey-core.min.css';
|
|
6
6
|
|
|
7
7
|
type ComponentsMap = {
|
|
8
8
|
[key: string]: ComponentType<any>;
|
|
@@ -67,7 +67,7 @@ function Quest({
|
|
|
67
67
|
|
|
68
68
|
const survey = new Model({
|
|
69
69
|
...surveyJson,
|
|
70
|
-
css: { ...
|
|
70
|
+
css: { ...defaultCss, root: 'sd-root-modern custom-root' },
|
|
71
71
|
});
|
|
72
72
|
survey.applyTheme(ContrastLight);
|
|
73
73
|
|
|
@@ -112,15 +112,32 @@ function combineTrialsToCsv(
|
|
|
112
112
|
fun?: (obj: any) => any,
|
|
113
113
|
): FileUpload | FileUpload[] {
|
|
114
114
|
|
|
115
|
-
// Collect all flattener results first
|
|
115
|
+
// Collect all flattener results first, filtering out completely empty results
|
|
116
116
|
const allResults: (any[] | Record<string, any[]>)[] = names.flatMap((name) => {
|
|
117
117
|
const matchingItems = data.filter((d) => d.name === name);
|
|
118
118
|
|
|
119
119
|
return matchingItems.map((item) => {
|
|
120
120
|
const flattener = item.type && flatteningFunctions[item.type];
|
|
121
|
-
|
|
121
|
+
const result = flattener ? flattener(item) : [transform(item)];
|
|
122
|
+
|
|
123
|
+
// Filter out completely empty results
|
|
124
|
+
if (Array.isArray(result) && result.length === 0) {
|
|
125
|
+
return null; // Signal this trial should be completely skipped
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (result && typeof result === 'object' && !Array.isArray(result)) {
|
|
129
|
+
// Check if all arrays in the object are empty
|
|
130
|
+
const hasAnyData = Object.values(result).some(val =>
|
|
131
|
+
Array.isArray(val) && val.length > 0
|
|
132
|
+
);
|
|
133
|
+
if (!hasAnyData) {
|
|
134
|
+
return null; // Signal this trial should be completely skipped
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return result;
|
|
122
139
|
});
|
|
123
|
-
});
|
|
140
|
+
}).filter(result => result !== null);
|
|
124
141
|
|
|
125
142
|
// Check if any result is a multi-table object (has string keys with array values)
|
|
126
143
|
const hasMultiTable = allResults.some((result) =>
|
|
@@ -131,11 +148,16 @@ function combineTrialsToCsv(
|
|
|
131
148
|
);
|
|
132
149
|
|
|
133
150
|
if (!hasMultiTable) {
|
|
134
|
-
//
|
|
151
|
+
// all results are arrays, combine them into one CSV
|
|
135
152
|
const processedData = allResults
|
|
136
153
|
.flatMap((result) => Array.isArray(result) ? result : [])
|
|
137
154
|
.map((x) => (fun ? fun(x) : x));
|
|
138
155
|
|
|
156
|
+
// Skip creating CSV if all flatteners returned empty arrays
|
|
157
|
+
if (processedData.length === 0) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
|
|
139
161
|
return {
|
|
140
162
|
filename,
|
|
141
163
|
encoding: 'utf8' as const,
|
|
@@ -143,7 +165,7 @@ function combineTrialsToCsv(
|
|
|
143
165
|
};
|
|
144
166
|
}
|
|
145
167
|
|
|
146
|
-
//
|
|
168
|
+
// handle multi-table results
|
|
147
169
|
// Collect all table keys from all results
|
|
148
170
|
const allTableKeys = new Set<string>();
|
|
149
171
|
allResults.forEach((result) => {
|
|
@@ -171,6 +193,11 @@ function combineTrialsToCsv(
|
|
|
171
193
|
return [];
|
|
172
194
|
}).map((x) => (fun ? fun(x) : x));
|
|
173
195
|
|
|
196
|
+
// Skip creating CSV if all flatteners returned empty arrays for this table
|
|
197
|
+
if (tableData.length === 0) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
|
|
174
201
|
// Remove file extension from filename and add table key
|
|
175
202
|
const baseFilename = filename.replace(/\.csv$/, '');
|
|
176
203
|
|
|
@@ -181,6 +208,11 @@ function combineTrialsToCsv(
|
|
|
181
208
|
});
|
|
182
209
|
}
|
|
183
210
|
|
|
211
|
+
// Return empty array if no files were created
|
|
212
|
+
if (files.length === 0) {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
|
|
184
216
|
return files.length === 1 ? files[0] : files;
|
|
185
217
|
}
|
|
186
218
|
|
|
@@ -477,7 +509,10 @@ export default function Upload({
|
|
|
477
509
|
);
|
|
478
510
|
|
|
479
511
|
if (Array.isArray(result)) {
|
|
480
|
-
files
|
|
512
|
+
// Only push files if the array is not empty
|
|
513
|
+
if (result.length > 0) {
|
|
514
|
+
files.push(...result);
|
|
515
|
+
}
|
|
481
516
|
} else {
|
|
482
517
|
files.push(result);
|
|
483
518
|
}
|