@adriansteffan/reactive 0.2.0 → 0.2.2
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-C-XUCKhQ.js → mod-CZYkml9p.js} +586 -586
- package/dist/mod.d.ts +4 -2
- package/dist/reactive.es.js +39 -39
- package/dist/reactive.umd.js +110 -110
- package/dist/{web-Dv2PC8fG.js → web-BVQpCNK1.js} +1 -1
- package/dist/{web-Dpb5MAUc.js → web-Ce2dHghr.js} +1 -1
- package/package.json +1 -1
- package/src/utils/common.ts +7 -3
- package/template/src/Experiment.tsx +3 -3
package/package.json
CHANGED
package/src/utils/common.ts
CHANGED
|
@@ -197,7 +197,9 @@ export function registerExperimentParams(experiment: any[]) {
|
|
|
197
197
|
if (params) {
|
|
198
198
|
for (const param of params) {
|
|
199
199
|
if(!item.hideSettings || (item.hideSettings !== true && !item.hideSettings.includes(param.name))){
|
|
200
|
-
sharedRegistry.
|
|
200
|
+
if (!sharedRegistry.some((p) => p.name === param.name)) {
|
|
201
|
+
sharedRegistry.push(param);
|
|
202
|
+
}
|
|
201
203
|
}
|
|
202
204
|
}
|
|
203
205
|
}
|
|
@@ -211,11 +213,10 @@ export function registerComponentParams(
|
|
|
211
213
|
providedComponentParams[type] = params;
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
export function
|
|
216
|
+
export function prepareTimeline(experiment: any[], options: { subset?: boolean } = {}): any[] {
|
|
215
217
|
registerExperimentParams(experiment);
|
|
216
218
|
|
|
217
219
|
timelineRepresentation.length = 0;
|
|
218
|
-
|
|
219
220
|
experiment.forEach((item) => {
|
|
220
221
|
timelineRepresentation.push({
|
|
221
222
|
type: item.type ?? 'NoTypeSpecified',
|
|
@@ -223,6 +224,8 @@ export function subsetExperimentByParam(experiment: any[]) {
|
|
|
223
224
|
});
|
|
224
225
|
});
|
|
225
226
|
|
|
227
|
+
if (!options.subset) return experiment;
|
|
228
|
+
|
|
226
229
|
const include = getParam('includeSubset', undefined);
|
|
227
230
|
const exclude = getParam('excludeSubset', undefined);
|
|
228
231
|
|
|
@@ -255,6 +258,7 @@ export function subsetExperimentByParam(experiment: any[]) {
|
|
|
255
258
|
return experimentFiltered;
|
|
256
259
|
}
|
|
257
260
|
|
|
261
|
+
|
|
258
262
|
export function canvasCountdown(seconds: number) {
|
|
259
263
|
if (seconds <= 0) {
|
|
260
264
|
return [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { useState, useRef } from 'react';
|
|
3
|
-
import { ExperimentRunner, BaseComponentProps, ExperimentConfig, registerSimulation, registerFlattener, sampleParticipants } from '@adriansteffan/reactive';
|
|
3
|
+
import { ExperimentRunner, BaseComponentProps, ExperimentConfig, registerSimulation, registerFlattener, sampleParticipants, prepareTimeline } from '@adriansteffan/reactive';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const config: ExperimentConfig = { showProgressBar: true };
|
|
@@ -66,7 +66,7 @@ const CustomQuestion = () => {
|
|
|
66
66
|
|
|
67
67
|
// --- Timeline ---
|
|
68
68
|
|
|
69
|
-
const experiment = [
|
|
69
|
+
const experiment = prepareTimeline([
|
|
70
70
|
{
|
|
71
71
|
name: 'introtext',
|
|
72
72
|
type: 'Text',
|
|
@@ -149,7 +149,7 @@ const experiment = [
|
|
|
149
149
|
content: <>Thank you for participating in our study, you can now close the browser window.</>,
|
|
150
150
|
},
|
|
151
151
|
},
|
|
152
|
-
];
|
|
152
|
+
]);
|
|
153
153
|
|
|
154
154
|
// --- Simulation config ---
|
|
155
155
|
const simulationConfig = {
|