@adriansteffan/reactive 0.0.30 → 0.0.32
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/LICENSE +21 -0
- package/README.md +9 -1
- package/dist/{mod-BY9yD0Pz.js → mod-OYK5S6rI.js} +94 -88
- package/dist/mod.d.ts +5 -2
- package/dist/reactive.es.js +1 -1
- package/dist/reactive.umd.js +12 -12
- package/dist/style.css +1 -1
- package/dist/{web-D4yetCSC.js → web-D0E0X8r4.js} +1 -1
- package/dist/{web-Crj4uOnK.js → web-GcUUyn5k.js} +1 -1
- package/package.json +1 -2
- package/src/components/experimentrunner.tsx +1 -0
- package/src/components/upload.tsx +30 -12
- package/template/src/index.css +1 -1
- package/vite.config.ts +0 -11
- package/dist/preset.css +0 -134
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adriansteffan/reactive",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"types": "./dist/mod.d.ts"
|
|
24
24
|
},
|
|
25
25
|
"./style.css": "./dist/style.css",
|
|
26
|
-
"./preset.css": "./dist/preset.css",
|
|
27
26
|
"./array": {
|
|
28
27
|
"import": "./dist/reactive.es.js",
|
|
29
28
|
"require": "./dist/reactive.umd.js",
|
|
@@ -88,22 +88,39 @@ function convertArrayOfObjectsToCSV(data: DataObject[]): string {
|
|
|
88
88
|
return [headerRow, ...dataRows].join('\n');
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// TODO: for better cohesion move this into the components on registration
|
|
92
|
+
const defaultFlatteningFunctions = {
|
|
93
|
+
'CanvasBlock': (item: TrialData) => {
|
|
94
|
+
const responseData = item.responseData;
|
|
95
|
+
if (Array.isArray(responseData)) {
|
|
96
|
+
return responseData.map((i) => ({
|
|
97
|
+
block: item.name,
|
|
98
|
+
...i,
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const transform = ({responseData, ...obj}: any) => ({ ...obj, ...Object.entries(responseData || {}).reduce((acc, [k, v]) => ({...acc, [`data_${k}`]: v}), {}) });
|
|
106
|
+
|
|
91
107
|
function combineTrialsToCsv(
|
|
92
108
|
data: any[],
|
|
93
109
|
filename: string,
|
|
94
110
|
names: string[],
|
|
111
|
+
flatteningFunctions: Record<string, (item: any) => any[]>,
|
|
95
112
|
fun?: (obj: any) => any,
|
|
96
113
|
) {
|
|
114
|
+
|
|
97
115
|
const processedData = names
|
|
98
116
|
.flatMap((name) => {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
return [];
|
|
117
|
+
const matchingItems = data.filter((d) => d.name === name);
|
|
118
|
+
|
|
119
|
+
return matchingItems.flatMap((item) => {
|
|
120
|
+
const flattener = item.type && flatteningFunctions[item.type];
|
|
121
|
+
|
|
122
|
+
return flattener ? flattener(item) : transform(item);
|
|
123
|
+
});
|
|
107
124
|
})
|
|
108
125
|
.map((x) => (fun ? fun(x) : x));
|
|
109
126
|
|
|
@@ -256,7 +273,7 @@ export default function Upload({
|
|
|
256
273
|
sessionID,
|
|
257
274
|
generateFiles,
|
|
258
275
|
sessionCSVBuilder,
|
|
259
|
-
|
|
276
|
+
trialCSVBuilder,
|
|
260
277
|
uploadRaw = true,
|
|
261
278
|
autoUpload = false,
|
|
262
279
|
androidFolderName,
|
|
@@ -264,7 +281,7 @@ export default function Upload({
|
|
|
264
281
|
sessionID?: string | null;
|
|
265
282
|
generateFiles: (sessionID: string, data: TrialData[], store?: Store) => FileUpload[];
|
|
266
283
|
sessionCSVBuilder: CSVBuilder;
|
|
267
|
-
|
|
284
|
+
trialCSVBuilder: {flatteners: Record<string, ((item: TrialData) => Record<string, any>[])>, builders: CSVBuilder[]};
|
|
268
285
|
uploadRaw: boolean;
|
|
269
286
|
autoUpload: boolean;
|
|
270
287
|
androidFolderName?: string;
|
|
@@ -396,13 +413,14 @@ export default function Upload({
|
|
|
396
413
|
});
|
|
397
414
|
}
|
|
398
415
|
|
|
399
|
-
if (
|
|
400
|
-
for (const builder of
|
|
416
|
+
if (trialCSVBuilder) {
|
|
417
|
+
for (const builder of trialCSVBuilder.builders) {
|
|
401
418
|
files.push(
|
|
402
419
|
combineTrialsToCsv(
|
|
403
420
|
data,
|
|
404
421
|
`${sessionIDUpload}${builder.filename}.csv`,
|
|
405
422
|
builder.trials ?? [],
|
|
423
|
+
{...defaultFlatteningFunctions, ...trialCSVBuilder.flatteners},
|
|
406
424
|
builder.fun,
|
|
407
425
|
),
|
|
408
426
|
);
|
package/template/src/index.css
CHANGED
package/vite.config.ts
CHANGED
|
@@ -2,9 +2,7 @@ import { defineConfig } from 'vite';
|
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import dts from 'vite-plugin-dts';
|
|
5
|
-
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
6
5
|
import tailwindcssPostcss from '@tailwindcss/postcss';
|
|
7
|
-
import tailwindcss from 'tailwindcss';
|
|
8
6
|
import autoprefixer from 'autoprefixer';
|
|
9
7
|
|
|
10
8
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -14,15 +12,6 @@ export default defineConfig(() => {
|
|
|
14
12
|
plugins: [
|
|
15
13
|
react(),
|
|
16
14
|
dts({ include: ['src'] , rollupTypes: true}),
|
|
17
|
-
viteStaticCopy({
|
|
18
|
-
targets: [
|
|
19
|
-
{
|
|
20
|
-
src: 'src/index.css',
|
|
21
|
-
dest: '.',
|
|
22
|
-
rename: 'preset.css',
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
}),
|
|
26
15
|
],
|
|
27
16
|
css: {
|
|
28
17
|
postcss: {
|
package/dist/preset.css
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
@import 'tailwindcss';
|
|
2
|
-
|
|
3
|
-
@source '../dist/**/*.{js,ts,jsx,tsx}';
|
|
4
|
-
|
|
5
|
-
@theme {
|
|
6
|
-
--font-*: initial;
|
|
7
|
-
--font-sans: Atkinson Hyperlegible, sans-serif;
|
|
8
|
-
--font-atkinson: Atkinson Hyperlegible, sans-serif;
|
|
9
|
-
|
|
10
|
-
--animate-slide-down: slideDown 0.8s ease-out forwards;
|
|
11
|
-
--animate-fade-in: fadeIn 0.5s ease-out forwards;
|
|
12
|
-
|
|
13
|
-
@keyframes slideDown {
|
|
14
|
-
0% {
|
|
15
|
-
transform: translateY(-10px);
|
|
16
|
-
opacity: 0;
|
|
17
|
-
}
|
|
18
|
-
100% {
|
|
19
|
-
transform: translateY(0);
|
|
20
|
-
opacity: 1;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
@keyframes fadeIn {
|
|
24
|
-
0% {
|
|
25
|
-
opacity: 0;
|
|
26
|
-
}
|
|
27
|
-
100% {
|
|
28
|
-
opacity: 1;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@keyframes slideDown {
|
|
35
|
-
0% {
|
|
36
|
-
transform: translateY(-10px);
|
|
37
|
-
opacity: 0;
|
|
38
|
-
}
|
|
39
|
-
100% {
|
|
40
|
-
transform: translateY(0);
|
|
41
|
-
opacity: 1;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@keyframes fadeIn {
|
|
46
|
-
0% {
|
|
47
|
-
opacity: 0;
|
|
48
|
-
}
|
|
49
|
-
100% {
|
|
50
|
-
opacity: 1;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/*
|
|
55
|
-
The default border color has changed to `currentColor` in Tailwind CSS v4,
|
|
56
|
-
so we've added these compatibility styles to make sure everything still
|
|
57
|
-
looks the same as it did with Tailwind CSS v3.
|
|
58
|
-
|
|
59
|
-
If we ever want to remove these styles, we need to add an explicit border
|
|
60
|
-
color utility to any element that depends on these defaults.
|
|
61
|
-
*/
|
|
62
|
-
@layer base {
|
|
63
|
-
*,
|
|
64
|
-
::after,
|
|
65
|
-
::before,
|
|
66
|
-
::backdrop,
|
|
67
|
-
::file-selector-button {
|
|
68
|
-
border-color: var(--color-gray-200, currentColor);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
:root {
|
|
73
|
-
--font-atkinson: 'Atkinson Hyperlegible', system-ui, sans-serif;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
* {
|
|
77
|
-
-webkit-touch-callout: none;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@font-face {
|
|
81
|
-
font-family: 'Atkinson Hyperlegible';
|
|
82
|
-
src: url('/Atkinson_Hyperlegible/AtkinsonHyperlegible-Regular.ttf') format('truetype');
|
|
83
|
-
font-weight: 400;
|
|
84
|
-
font-style: normal;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@font-face {
|
|
88
|
-
font-family: 'Atkinson Hyperlegible';
|
|
89
|
-
src: url('/Atkinson_Hyperlegible/AtkinsonHyperlegible-Bold.ttf') format('truetype');
|
|
90
|
-
font-weight: 700;
|
|
91
|
-
font-style: normal;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@font-face {
|
|
95
|
-
font-family: 'Atkinson Hyperlegible';
|
|
96
|
-
src: url('/Atkinson_Hyperlegible/AtkinsonHyperlegible-Italic.ttf') format('truetype');
|
|
97
|
-
font-weight: 400;
|
|
98
|
-
font-style: italic;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@font-face {
|
|
102
|
-
font-family: 'Atkinson Hyperlegible';
|
|
103
|
-
src: url('/Atkinson_Hyperlegible/AtkinsonHyperlegible-BoldItalic.ttf') format('truetype');
|
|
104
|
-
font-weight: 700;
|
|
105
|
-
font-style: italic;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/* customization for the surveyjs elements - a bit hacky and broken*/
|
|
109
|
-
.sd-root-modern {
|
|
110
|
-
background-color: white !important;
|
|
111
|
-
background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
|
|
112
|
-
background-size: 16px 16px;
|
|
113
|
-
position: relative; /* Make sure position is set for proper rendering */
|
|
114
|
-
font-family: 'Atkinson Hyperlegible', sans-serif; /* Added this line */
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.sd-root-modern * {
|
|
118
|
-
font-family: 'Atkinson Hyperlegible', sans-serif;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/* for the rating group panel, maybe we can move that into the component at some point*/
|
|
122
|
-
.sd-row,
|
|
123
|
-
.sd-clearfix {
|
|
124
|
-
padding-bottom: 20px !important;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/* fix pet peeve in surveyjs */
|
|
128
|
-
@media (max-width: 639px) {
|
|
129
|
-
.sd-imagepicker__item--inline {
|
|
130
|
-
margin-left: auto;
|
|
131
|
-
margin-right: auto;
|
|
132
|
-
margin-top: 10px;
|
|
133
|
-
}
|
|
134
|
-
}
|