@decidables/detectable-elements 0.0.3
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/CHANGELOG.md +29 -0
- package/LICENSE.md +1112 -0
- package/README.md +1218 -0
- package/lib/detectableElements.esm.js +18385 -0
- package/lib/detectableElements.esm.js.map +1 -0
- package/lib/detectableElements.esm.min.js +13 -0
- package/lib/detectableElements.esm.min.js.map +1 -0
- package/lib/detectableElements.umd.js +18413 -0
- package/lib/detectableElements.umd.js.map +1 -0
- package/lib/detectableElements.umd.min.js +13 -0
- package/lib/detectableElements.umd.min.js.map +1 -0
- package/package.json +58 -0
- package/src/components/detectable-control.js +272 -0
- package/src/components/detectable-response.js +414 -0
- package/src/components/detectable-table.js +602 -0
- package/src/components/index.js +7 -0
- package/src/components/rdk-task.js +586 -0
- package/src/components/roc-space.js +1220 -0
- package/src/components/sdt-model.js +1835 -0
- package/src/detectable-element.js +121 -0
- package/src/equations/dc2far.js +182 -0
- package/src/equations/dc2hr.js +191 -0
- package/src/equations/facr2far.js +120 -0
- package/src/equations/hm2hr.js +121 -0
- package/src/equations/hmfacr2acc.js +161 -0
- package/src/equations/hrfar2c.js +179 -0
- package/src/equations/hrfar2d.js +162 -0
- package/src/equations/index.js +8 -0
- package/src/equations/sdt-equation.js +141 -0
- package/src/examples/double-interactive.js +171 -0
- package/src/examples/human.js +184 -0
- package/src/examples/index.js +6 -0
- package/src/examples/interactive.js +131 -0
- package/src/examples/model.js +203 -0
- package/src/examples/sdt-example.js +76 -0
- package/src/examples/unequal.js +43 -0
- package/src/index.js +6 -0
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@decidables/detectable-elements",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "detectable-elements: Web Components for visualizing Signal Detection Theory",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./lib/detectableElements.umd.min.js",
|
|
7
|
+
"browser": "./lib/detectableElements.umd.min.js",
|
|
8
|
+
"module": "./lib/detectableElements.esm.min.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./lib/*.js": "./lib/*.js",
|
|
11
|
+
".": "./src/index.js",
|
|
12
|
+
"./components": "./src/components/index.js",
|
|
13
|
+
"./equations": "./src/equations/index.js",
|
|
14
|
+
"./examples": "./src/examples/index.js",
|
|
15
|
+
"./*": "./src/*.js"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/decidables/decidables.git",
|
|
20
|
+
"directory": "libraries/detectable-elements"
|
|
21
|
+
},
|
|
22
|
+
"bugs": "https://github.com/decidables/decidables/issues",
|
|
23
|
+
"homepage": "https://github.com/decidables/decidables/tree/main/libraries/detectable-elements",
|
|
24
|
+
"author": "Adam Krawitz (https://web.uvic.ca/psyc/krawitz/)",
|
|
25
|
+
"license": "CC-BY-SA-4.0 AND GPL-3.0-or-later",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"package.json",
|
|
31
|
+
"*.md",
|
|
32
|
+
"src",
|
|
33
|
+
"lib"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"lint": "gulp lint",
|
|
37
|
+
"test": "web-test-runner test/**/*.test.js --config ../../.webtestrunnerrc.js",
|
|
38
|
+
"test:watch": "web-test-runner test/**/*.test.js --config ../../.webtestrunnerrc.js --watch",
|
|
39
|
+
"test:file": "web-test-runner $@ --config ../../.webtestrunnerrc.js",
|
|
40
|
+
"build": "gulp build"
|
|
41
|
+
},
|
|
42
|
+
"browserslist": [
|
|
43
|
+
"> 0.25%",
|
|
44
|
+
"not dead"
|
|
45
|
+
],
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@web/test-runner": "^0.13.27",
|
|
48
|
+
"gulp": "^4.0.2"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@decidables/decidables-elements": "^0.0.4",
|
|
52
|
+
"@decidables/detectable-math": "^0.0.3",
|
|
53
|
+
"d3": "^7.3.0",
|
|
54
|
+
"jstat": "^1.9.5",
|
|
55
|
+
"lit": "^2.1.2"
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "f3e3115ad33a8e1ad5db8ae455b67f571f4561c6"
|
|
58
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
|
|
2
|
+
import {html, css} from 'lit';
|
|
3
|
+
|
|
4
|
+
import '@decidables/decidables-elements/button';
|
|
5
|
+
import '@decidables/decidables-elements/slider';
|
|
6
|
+
import '@decidables/decidables-elements/switch';
|
|
7
|
+
import '@decidables/decidables-elements/toggle';
|
|
8
|
+
import '@decidables/decidables-elements/toggle-option';
|
|
9
|
+
|
|
10
|
+
import DetectableElement from '../detectable-element';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
DetectableControl element
|
|
14
|
+
<detectable-control>
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
export default class DetectableControl extends DetectableElement {
|
|
20
|
+
static get properties() {
|
|
21
|
+
return {
|
|
22
|
+
trials: {
|
|
23
|
+
attribute: 'trials',
|
|
24
|
+
type: Number,
|
|
25
|
+
reflect: true,
|
|
26
|
+
},
|
|
27
|
+
duration: {
|
|
28
|
+
attribute: 'duration',
|
|
29
|
+
type: Number,
|
|
30
|
+
reflect: true,
|
|
31
|
+
},
|
|
32
|
+
coherence: {
|
|
33
|
+
attribute: 'coherence',
|
|
34
|
+
type: Number,
|
|
35
|
+
reflect: true,
|
|
36
|
+
},
|
|
37
|
+
payoff: {
|
|
38
|
+
attribute: 'payoff',
|
|
39
|
+
type: Number,
|
|
40
|
+
reflect: true,
|
|
41
|
+
},
|
|
42
|
+
color: {
|
|
43
|
+
attribute: 'color',
|
|
44
|
+
type: String,
|
|
45
|
+
reflect: true,
|
|
46
|
+
},
|
|
47
|
+
zRoc: {
|
|
48
|
+
attribute: 'z-roc',
|
|
49
|
+
type: Boolean,
|
|
50
|
+
reflect: true,
|
|
51
|
+
},
|
|
52
|
+
run: {
|
|
53
|
+
attribute: 'run',
|
|
54
|
+
type: Boolean,
|
|
55
|
+
reflect: true,
|
|
56
|
+
},
|
|
57
|
+
pause: {
|
|
58
|
+
attribute: 'pause',
|
|
59
|
+
type: Boolean,
|
|
60
|
+
reflect: true,
|
|
61
|
+
},
|
|
62
|
+
reset: {
|
|
63
|
+
attribute: 'reset',
|
|
64
|
+
type: Boolean,
|
|
65
|
+
reflect: true,
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
state: {
|
|
69
|
+
atribute: false,
|
|
70
|
+
type: String,
|
|
71
|
+
reflect: false,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
constructor() {
|
|
77
|
+
super();
|
|
78
|
+
|
|
79
|
+
// Attributes
|
|
80
|
+
this.trials = undefined;
|
|
81
|
+
this.duration = undefined;
|
|
82
|
+
this.coherence = undefined;
|
|
83
|
+
this.payoff = undefined;
|
|
84
|
+
this.colors = ['none', 'accuracy', 'stimulus', 'response', 'outcome'];
|
|
85
|
+
this.color = undefined;
|
|
86
|
+
this.zRoc = undefined;
|
|
87
|
+
this.run = false;
|
|
88
|
+
this.pause = false;
|
|
89
|
+
this.reset = false;
|
|
90
|
+
|
|
91
|
+
// Properties
|
|
92
|
+
this.states = ['resetted', 'running', 'paused', 'ended'];
|
|
93
|
+
this.state = 'resetted';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
setTrials(e) {
|
|
97
|
+
this.trials = e.target.value;
|
|
98
|
+
this.dispatchEvent(new CustomEvent('detectable-control-trials', {
|
|
99
|
+
detail: {
|
|
100
|
+
trials: this.trials,
|
|
101
|
+
},
|
|
102
|
+
bubbles: true,
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setDuration(e) {
|
|
107
|
+
this.duration = e.target.value;
|
|
108
|
+
this.dispatchEvent(new CustomEvent('detectable-control-duration', {
|
|
109
|
+
detail: {
|
|
110
|
+
duration: this.duration,
|
|
111
|
+
},
|
|
112
|
+
bubbles: true,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
setCoherence(e) {
|
|
117
|
+
this.coherence = e.target.value;
|
|
118
|
+
this.dispatchEvent(new CustomEvent('detectable-control-coherence', {
|
|
119
|
+
detail: {
|
|
120
|
+
coherence: this.coherence,
|
|
121
|
+
},
|
|
122
|
+
bubbles: true,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setPayoff(e) {
|
|
127
|
+
this.payoff = e.target.value;
|
|
128
|
+
this.dispatchEvent(new CustomEvent('detectable-control-payoff', {
|
|
129
|
+
detail: {
|
|
130
|
+
payoff: this.payoff,
|
|
131
|
+
},
|
|
132
|
+
bubbles: true,
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
chooseColor(e) {
|
|
137
|
+
this.color = e.target.value;
|
|
138
|
+
this.dispatchEvent(new CustomEvent('detectable-control-color', {
|
|
139
|
+
detail: {
|
|
140
|
+
color: this.color,
|
|
141
|
+
},
|
|
142
|
+
bubbles: true,
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
flipZRoc(e) {
|
|
147
|
+
this.zRoc = e.target.checked;
|
|
148
|
+
this.dispatchEvent(new CustomEvent('detectable-control-z-roc', {
|
|
149
|
+
detail: {
|
|
150
|
+
zRoc: this.zRoc,
|
|
151
|
+
},
|
|
152
|
+
bubbles: true,
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
doRun() {
|
|
157
|
+
this.state = 'running';
|
|
158
|
+
this.dispatchEvent(new CustomEvent('detectable-control-run', {
|
|
159
|
+
detail: {},
|
|
160
|
+
bubbles: true,
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
doPause() {
|
|
165
|
+
this.state = 'paused';
|
|
166
|
+
this.dispatchEvent(new CustomEvent('detectable-control-pause', {
|
|
167
|
+
detail: {},
|
|
168
|
+
bubbles: true,
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
doReset() {
|
|
173
|
+
this.state = 'resetted';
|
|
174
|
+
this.dispatchEvent(new CustomEvent('detectable-control-reset', {
|
|
175
|
+
detail: {},
|
|
176
|
+
bubbles: true,
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
complete() {
|
|
181
|
+
this.state = 'ended';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static get styles() {
|
|
185
|
+
return [
|
|
186
|
+
super.styles,
|
|
187
|
+
css`
|
|
188
|
+
:host {
|
|
189
|
+
display: inline-block;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.holder {
|
|
193
|
+
display: flex;
|
|
194
|
+
|
|
195
|
+
flex-direction: row;
|
|
196
|
+
|
|
197
|
+
align-items: stretch;
|
|
198
|
+
justify-content: center;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.buttons {
|
|
202
|
+
display: flex;
|
|
203
|
+
|
|
204
|
+
flex-direction: column;
|
|
205
|
+
|
|
206
|
+
align-items: stretch;
|
|
207
|
+
justify-content: center;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/* Payoff Slider */
|
|
211
|
+
.payoff {
|
|
212
|
+
--decidables-spinner-prefix: "$";
|
|
213
|
+
}
|
|
214
|
+
`,
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
render() {
|
|
219
|
+
return html`
|
|
220
|
+
<div class="holder">
|
|
221
|
+
${this.trials
|
|
222
|
+
? html`<decidables-slider min="1" max="100" step="1" .value=${this.trials} @change=${this.setTrials.bind(this)} @input=${this.setTrials.bind(this)}>Trials</decidables-slider>`
|
|
223
|
+
: html``}
|
|
224
|
+
${this.duration
|
|
225
|
+
? html`<decidables-slider min="10" max="2000" step="10" .value=${this.duration} @change=${this.setDuration.bind(this)} @input=${this.setDuration.bind(this)}>Duration</decidables-slider>`
|
|
226
|
+
: html``}
|
|
227
|
+
${this.coherence
|
|
228
|
+
? html`<decidables-slider min="0" max="1" step=".01" .value=${this.coherence} @change=${this.setCoherence.bind(this)} @input=${this.setCoherence.bind(this)}>Coherence</decidables-slider>`
|
|
229
|
+
: html``}
|
|
230
|
+
${this.payoff
|
|
231
|
+
? html`<decidables-slider class="payoff" min="0" max="100" step="1" .value=${this.payoff} @change=${this.setPayoff.bind(this)} @input=${this.setPayoff.bind(this)}>Payoff</decidables-slider>`
|
|
232
|
+
: html``}
|
|
233
|
+
${this.color !== undefined
|
|
234
|
+
? html`
|
|
235
|
+
<decidables-toggle @change=${this.chooseColor.bind(this)}>
|
|
236
|
+
<span slot="label">Emphasis</span>
|
|
237
|
+
<decidables-toggle-option name=${`${this.uniqueId}-color`} value="none" ?checked=${this.color === 'none'}>None</decidables-toggle-option>
|
|
238
|
+
<decidables-toggle-option name=${`${this.uniqueId}-color`} value="accuracy" ?checked=${this.color === 'accuracy'}>Accuracy</decidables-toggle-option>
|
|
239
|
+
<decidables-toggle-option name=${`${this.uniqueId}-color`} value="stimulus" ?checked=${this.color === 'stimulus'}>Stimulus</decidables-toggle-option>
|
|
240
|
+
<decidables-toggle-option name=${`${this.uniqueId}-color`} value="response" ?checked=${this.color === 'response'}>Response</decidables-toggle-option>
|
|
241
|
+
<decidables-toggle-option name=${`${this.uniqueId}-color`} value="outcome" ?checked=${this.color === 'outcome'}>Outcome</decidables-toggle-option>
|
|
242
|
+
</decidables-toggle>
|
|
243
|
+
`
|
|
244
|
+
: html``}
|
|
245
|
+
${this.zRoc !== undefined
|
|
246
|
+
? html`
|
|
247
|
+
<decidables-switch ?checked=${this.zRoc} @change=${this.flipZRoc.bind(this)}>
|
|
248
|
+
<span class="math-var">z</span>ROC
|
|
249
|
+
<span slot="off-label">ROC</span>
|
|
250
|
+
</decidables-switch>
|
|
251
|
+
`
|
|
252
|
+
: html``}
|
|
253
|
+
${this.run || this.pause || this.reset
|
|
254
|
+
? html`
|
|
255
|
+
<div class="buttons">
|
|
256
|
+
${this.run
|
|
257
|
+
? html`<decidables-button name="run" ?disabled=${this.state === 'running' || this.state === 'ended'} @click=${this.doRun.bind(this)}>Run</decidables-button>`
|
|
258
|
+
: html``}
|
|
259
|
+
${this.pause
|
|
260
|
+
? html`<decidables-button name="pause" ?disabled=${this.state !== 'running'} @click=${this.doPause.bind(this)}>Pause</decidables-button>`
|
|
261
|
+
: html``}
|
|
262
|
+
${this.reset
|
|
263
|
+
? html`<decidables-button name="reset" ?disabled=${this.state === 'resetted'} @click=${this.doReset.bind(this)}>Reset</decidables-button>`
|
|
264
|
+
: html``}
|
|
265
|
+
</div>
|
|
266
|
+
`
|
|
267
|
+
: html``}
|
|
268
|
+
</div>`;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
customElements.define('detectable-control', DetectableControl);
|