@pie-element/number-line 13.1.1 → 13.1.2-next.1
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/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/_virtual/_rolldown/runtime.js +11 -0
- package/dist/author/arrows.d.ts +28 -0
- package/dist/author/arrows.js +69 -0
- package/dist/author/card-bar.d.ts +20 -0
- package/dist/author/card-bar.js +41 -0
- package/dist/author/defaults.d.ts +178 -0
- package/dist/author/defaults.js +144 -0
- package/dist/author/domain.d.ts +15 -0
- package/dist/author/domain.js +54 -0
- package/dist/author/index.d.ts +23 -0
- package/dist/author/index.js +89 -0
- package/dist/author/main.d.ts +44 -0
- package/dist/author/main.js +485 -0
- package/dist/author/number-text-field.d.ts +13 -0
- package/dist/author/number-text-field.js +13 -0
- package/dist/author/point-config.d.ts +25 -0
- package/dist/author/point-config.js +69 -0
- package/dist/author/size.d.ts +24 -0
- package/dist/author/size.js +48 -0
- package/dist/author/ticks.d.ts +22 -0
- package/dist/author/ticks.js +115 -0
- package/dist/author/utils.d.ts +9 -0
- package/dist/author/utils.js +4 -0
- package/dist/browser/author/index.js +40259 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/controller/index.js +569 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +2 -0
- package/dist/browser/delivery-Ci_kZyOM.js +17903 -0
- package/dist/browser/delivery-Ci_kZyOM.js.map +1 -0
- package/dist/browser/dist-D5T-OaLo.js +19038 -0
- package/dist/browser/dist-D5T-OaLo.js.map +1 -0
- package/dist/browser/impureFunctionsAny.generated-Bqfato71.js +10162 -0
- package/dist/browser/impureFunctionsAny.generated-Bqfato71.js.map +1 -0
- package/dist/browser/number-line.css +2 -0
- package/dist/controller/defaults.d.ts +58 -0
- package/dist/controller/defaults.js +50 -0
- package/dist/controller/index.d.ts +47 -0
- package/dist/controller/index.js +165 -0
- package/dist/controller/tickUtils.d.ts +21 -0
- package/dist/controller/tickUtils.js +252 -0
- package/dist/controller/utils.d.ts +9 -0
- package/dist/controller/utils.js +68 -0
- package/dist/delivery/data-converter.d.ts +64 -0
- package/dist/delivery/data-converter.js +70 -0
- package/dist/delivery/draggable/index.d.ts +33 -0
- package/dist/delivery/draggable/index.js +39 -0
- package/dist/delivery/index.d.ts +35 -0
- package/dist/delivery/index.js +109 -0
- package/dist/delivery/number-line/colors.d.ts +11 -0
- package/dist/delivery/number-line/colors.js +5 -0
- package/dist/delivery/number-line/feedback.d.ts +19 -0
- package/dist/delivery/number-line/feedback.js +57 -0
- package/dist/delivery/number-line/graph/arrow.d.ts +30 -0
- package/dist/delivery/number-line/graph/arrow.js +27 -0
- package/dist/delivery/number-line/graph/elements/base.d.ts +16 -0
- package/dist/delivery/number-line/graph/elements/base.js +11 -0
- package/dist/delivery/number-line/graph/elements/builder.d.ts +33 -0
- package/dist/delivery/number-line/graph/elements/builder.js +30 -0
- package/dist/delivery/number-line/graph/elements/line.d.ts +51 -0
- package/dist/delivery/number-line/graph/elements/line.js +188 -0
- package/dist/delivery/number-line/graph/elements/point.d.ts +43 -0
- package/dist/delivery/number-line/graph/elements/point.js +127 -0
- package/dist/delivery/number-line/graph/elements/ray.d.ts +43 -0
- package/dist/delivery/number-line/graph/elements/ray.js +130 -0
- package/dist/delivery/number-line/graph/index.d.ts +59 -0
- package/dist/delivery/number-line/graph/index.js +196 -0
- package/dist/delivery/number-line/graph/line.d.ts +46 -0
- package/dist/delivery/number-line/graph/line.js +27 -0
- package/dist/delivery/number-line/graph/stacks.d.ts +10 -0
- package/dist/delivery/number-line/graph/stacks.js +40 -0
- package/dist/delivery/number-line/graph/tick-utils.d.ts +80 -0
- package/dist/delivery/number-line/graph/tick-utils.js +295 -0
- package/dist/delivery/number-line/graph/ticks.d.ts +46 -0
- package/dist/delivery/number-line/graph/ticks.js +115 -0
- package/dist/delivery/number-line/index.d.ts +35 -0
- package/dist/delivery/number-line/index.js +215 -0
- package/dist/delivery/number-line/point-chooser/button.d.ts +31 -0
- package/dist/delivery/number-line/point-chooser/button.js +36 -0
- package/dist/delivery/number-line/point-chooser/img.d.ts +10 -0
- package/dist/delivery/number-line/point-chooser/img.js +4 -0
- package/dist/delivery/number-line/point-chooser/index.d.ts +37 -0
- package/dist/delivery/number-line/point-chooser/index.js +154 -0
- package/dist/delivery/number-line/point-chooser/styles.d.ts +192 -0
- package/dist/delivery/number-line/transitions/fade.d.ts +34 -0
- package/dist/delivery/number-line/transitions/fade.js +75 -0
- package/dist/delivery/number-line/transitions/index.d.ts +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +197 -0
- package/dist/index.js +2 -0
- package/dist/runtime-support.d.ts +12 -0
- package/dist/runtime-support.js +12 -0
- package/package.json +87 -21
- package/CHANGELOG.json +0 -1247
- package/CHANGELOG.md +0 -2435
- package/LICENSE.md +0 -5
- package/README.md +0 -28
- package/configure/CHANGELOG.json +0 -827
- package/configure/CHANGELOG.md +0 -2082
- package/configure/lib/arrows.js +0 -89
- package/configure/lib/arrows.js.map +0 -1
- package/configure/lib/card-bar.js +0 -57
- package/configure/lib/card-bar.js.map +0 -1
- package/configure/lib/defaults.js +0 -177
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/domain.js +0 -87
- package/configure/lib/domain.js.map +0 -1
- package/configure/lib/index.js +0 -176
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -815
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/number-text-field.js +0 -26
- package/configure/lib/number-text-field.js.map +0 -1
- package/configure/lib/point-config.js +0 -84
- package/configure/lib/point-config.js.map +0 -1
- package/configure/lib/size.js +0 -66
- package/configure/lib/size.js.map +0 -1
- package/configure/lib/ticks.js +0 -234
- package/configure/lib/ticks.js.map +0 -1
- package/configure/lib/utils.js +0 -12
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -20
- package/controller/CHANGELOG.json +0 -332
- package/controller/CHANGELOG.md +0 -1360
- package/controller/lib/defaults.js +0 -56
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -430
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/tickUtils.js +0 -294
- package/controller/lib/tickUtils.js.map +0 -1
- package/controller/lib/utils.js +0 -168
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -20
- package/demo.gif +0 -0
- package/docs/config-schema.json +0 -2532
- package/docs/config-schema.json.md +0 -1844
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -39
- package/docs/demo/index.html +0 -1
- package/docs/pie-schema.json +0 -2461
- package/docs/pie-schema.json.md +0 -1228
- package/docs/schemas/config.json +0 -256
- package/lib/data-converter.js +0 -96
- package/lib/data-converter.js.map +0 -1
- package/lib/draggable/index.js +0 -114
- package/lib/draggable/index.js.map +0 -1
- package/lib/index.js +0 -196
- package/lib/index.js.map +0 -1
- package/lib/number-line/colors.js +0 -11
- package/lib/number-line/colors.js.map +0 -1
- package/lib/number-line/feedback.js +0 -92
- package/lib/number-line/feedback.js.map +0 -1
- package/lib/number-line/graph/arrow.js +0 -44
- package/lib/number-line/graph/arrow.js.map +0 -1
- package/lib/number-line/graph/elements/base.js +0 -20
- package/lib/number-line/graph/elements/base.js.map +0 -1
- package/lib/number-line/graph/elements/builder.js +0 -37
- package/lib/number-line/graph/elements/builder.js.map +0 -1
- package/lib/number-line/graph/elements/line.js +0 -259
- package/lib/number-line/graph/elements/line.js.map +0 -1
- package/lib/number-line/graph/elements/point.js +0 -204
- package/lib/number-line/graph/elements/point.js.map +0 -1
- package/lib/number-line/graph/elements/ray.js +0 -190
- package/lib/number-line/graph/elements/ray.js.map +0 -1
- package/lib/number-line/graph/index.js +0 -262
- package/lib/number-line/graph/index.js.map +0 -1
- package/lib/number-line/graph/line.js +0 -38
- package/lib/number-line/graph/line.js.map +0 -1
- package/lib/number-line/graph/stacks.js +0 -78
- package/lib/number-line/graph/stacks.js.map +0 -1
- package/lib/number-line/graph/tick-utils.js +0 -347
- package/lib/number-line/graph/tick-utils.js.map +0 -1
- package/lib/number-line/graph/ticks.js +0 -188
- package/lib/number-line/graph/ticks.js.map +0 -1
- package/lib/number-line/index.js +0 -384
- package/lib/number-line/index.js.map +0 -1
- package/lib/number-line/point-chooser/button.js +0 -49
- package/lib/number-line/point-chooser/button.js.map +0 -1
- package/lib/number-line/point-chooser/img.js +0 -8
- package/lib/number-line/point-chooser/img.js.map +0 -1
- package/lib/number-line/point-chooser/index.js +0 -197
- package/lib/number-line/point-chooser/index.js.map +0 -1
- package/lib/number-line/point-chooser/styles.js +0 -77
- package/lib/number-line/point-chooser/styles.js.map +0 -1
- package/lib/number-line/transitions/fade.js +0 -88
- package/lib/number-line/transitions/fade.js.map +0 -1
- package/lib/number-line/transitions/index.js +0 -14
- package/lib/number-line/transitions/index.js.map +0 -1
package/docs/schemas/config.json
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"title": "Number Line Question Schema",
|
|
3
|
-
"type": "object",
|
|
4
|
-
"definitions": {
|
|
5
|
-
"feedbackType": {
|
|
6
|
-
"type": "string",
|
|
7
|
-
"enum": [
|
|
8
|
-
"default",
|
|
9
|
-
"custom"
|
|
10
|
-
]
|
|
11
|
-
},
|
|
12
|
-
"pointType": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"enum": [
|
|
15
|
-
"full",
|
|
16
|
-
"empty"
|
|
17
|
-
],
|
|
18
|
-
"description": "Describes whether the point is filled-in or empty."
|
|
19
|
-
},
|
|
20
|
-
"domainPosition": {
|
|
21
|
-
"type": "number",
|
|
22
|
-
"description": "The position within the domain."
|
|
23
|
-
},
|
|
24
|
-
"point": {
|
|
25
|
-
"type": "object",
|
|
26
|
-
"properties": {
|
|
27
|
-
"type": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"enum": [
|
|
30
|
-
"point"
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
"pointType": {
|
|
34
|
-
"$ref": "#/definitions/pointType"
|
|
35
|
-
},
|
|
36
|
-
"domainPosition": {
|
|
37
|
-
"$ref": "#/definitions/domainPosition"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"required": [
|
|
41
|
-
"type",
|
|
42
|
-
"domainPosition",
|
|
43
|
-
"pointType"
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
"ray": {
|
|
47
|
-
"type": "object",
|
|
48
|
-
"properties": {
|
|
49
|
-
"type": "string",
|
|
50
|
-
"type": {
|
|
51
|
-
"enum": [
|
|
52
|
-
"ray"
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
"pointType": {
|
|
56
|
-
"$ref": "#/definitions/pointType"
|
|
57
|
-
},
|
|
58
|
-
"domainPosition": {
|
|
59
|
-
"$ref": "#/definitions/domainPosition"
|
|
60
|
-
},
|
|
61
|
-
"direction": {
|
|
62
|
-
"type": "string",
|
|
63
|
-
"enum": [
|
|
64
|
-
"positive",
|
|
65
|
-
"negative"
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"required": [
|
|
70
|
-
"type",
|
|
71
|
-
"pointType",
|
|
72
|
-
"direction",
|
|
73
|
-
"domainPosition"
|
|
74
|
-
]
|
|
75
|
-
},
|
|
76
|
-
"line": {
|
|
77
|
-
"type": "object",
|
|
78
|
-
"properties": {
|
|
79
|
-
"leftPoint": {
|
|
80
|
-
"$ref": "#/definitions/pointType"
|
|
81
|
-
},
|
|
82
|
-
"rightPoint": {
|
|
83
|
-
"$ref": "#/definitions/pointType"
|
|
84
|
-
},
|
|
85
|
-
"domainPosition": {
|
|
86
|
-
"$ref": "#/definitions/domainPosition"
|
|
87
|
-
},
|
|
88
|
-
"size": {
|
|
89
|
-
"type": "number"
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
"required": [
|
|
93
|
-
"leftPoint",
|
|
94
|
-
"rightPoint",
|
|
95
|
-
"size",
|
|
96
|
-
"domainPosition"
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"properties": {
|
|
101
|
-
"correctResponse": {
|
|
102
|
-
"type": "array",
|
|
103
|
-
"description": "Describes the correct response of points, rays, lines to be displayed on the number line.",
|
|
104
|
-
"items": {
|
|
105
|
-
"oneOf": [
|
|
106
|
-
{
|
|
107
|
-
"$ref": "#/definitions/ray"
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
"$ref": "#/definitions/line"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"$ref": "#/definitions/point"
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
"feedback": {
|
|
119
|
-
"type": "object",
|
|
120
|
-
"properties": {
|
|
121
|
-
"correctFeedbackType": {
|
|
122
|
-
"$ref": "#/definitions/feedbackType"
|
|
123
|
-
},
|
|
124
|
-
"partialFeedbackType": {
|
|
125
|
-
"$ref": "#/definitions/feedbackType"
|
|
126
|
-
},
|
|
127
|
-
"incorrectFeedbackType": {
|
|
128
|
-
"$ref": "#/definitions/feedbackType"
|
|
129
|
-
},
|
|
130
|
-
"correctFeedback": {
|
|
131
|
-
"type": "string",
|
|
132
|
-
"description": "Feedback to render if custom is the feedbackType"
|
|
133
|
-
},
|
|
134
|
-
"partialFeedback": {
|
|
135
|
-
"type": "string",
|
|
136
|
-
"description": "Feedback to render if custom is the feedbackType"
|
|
137
|
-
},
|
|
138
|
-
"incorrectFeedback": {
|
|
139
|
-
"type": "string",
|
|
140
|
-
"description": "Feedback to render if custom is the feedbackType"
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
"allowPartialScoring": {
|
|
145
|
-
"type": "boolean",
|
|
146
|
-
"description": "allow partial scoring"
|
|
147
|
-
},
|
|
148
|
-
"partialScoring": {
|
|
149
|
-
"type": "array",
|
|
150
|
-
"description": "An array of rules describing what percentage to give for the number of correct responses",
|
|
151
|
-
"items": {
|
|
152
|
-
"type": "object",
|
|
153
|
-
"properties": {
|
|
154
|
-
"numberOfCorrect": {
|
|
155
|
-
"type": "number"
|
|
156
|
-
},
|
|
157
|
-
"scorePercentage": {
|
|
158
|
-
"type": "number"
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
"required": [
|
|
162
|
-
"numberOfCorrect",
|
|
163
|
-
"scorePercentage"
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
"model": {
|
|
168
|
-
"type": "object",
|
|
169
|
-
"properties": {
|
|
170
|
-
"config": {
|
|
171
|
-
"type": "object",
|
|
172
|
-
"description": "An object describing the various configuration properties of the component.",
|
|
173
|
-
"properties": {
|
|
174
|
-
"width": {
|
|
175
|
-
"type": "number",
|
|
176
|
-
"description": "The width of the component",
|
|
177
|
-
"minimum": 400,
|
|
178
|
-
"maximum": 1600
|
|
179
|
-
},
|
|
180
|
-
"height": {
|
|
181
|
-
"type": "number",
|
|
182
|
-
"description": "The height of the component",
|
|
183
|
-
"minimum": 300,
|
|
184
|
-
"maximum": 800
|
|
185
|
-
},
|
|
186
|
-
"domain": {
|
|
187
|
-
"type": "array",
|
|
188
|
-
"description": "A two-number array representing the minimum and maximum values to be displayed on the number line.",
|
|
189
|
-
"minItems": 2,
|
|
190
|
-
"maxItems": 2
|
|
191
|
-
},
|
|
192
|
-
"initialType": {
|
|
193
|
-
"type": "string",
|
|
194
|
-
"description": "The initial type of point, line, or ray to be set by the component.",
|
|
195
|
-
"enum": [
|
|
196
|
-
"PF",
|
|
197
|
-
"LEE",
|
|
198
|
-
"LEF",
|
|
199
|
-
"LFE",
|
|
200
|
-
"LFF",
|
|
201
|
-
"REP",
|
|
202
|
-
"REN",
|
|
203
|
-
"RFP",
|
|
204
|
-
"RFN"
|
|
205
|
-
]
|
|
206
|
-
},
|
|
207
|
-
"snapPerTick": {
|
|
208
|
-
"type": "number",
|
|
209
|
-
"description": "The number of positions that are clickable between two ticks."
|
|
210
|
-
},
|
|
211
|
-
"exhibitOnly": {
|
|
212
|
-
"type": "boolean",
|
|
213
|
-
"description": "If true, the interacting with the component is disabled."
|
|
214
|
-
},
|
|
215
|
-
"maxNumberOfPoints": {
|
|
216
|
-
"type": "number",
|
|
217
|
-
"description": "The number of points which may be added to the component by the user."
|
|
218
|
-
},
|
|
219
|
-
"tickFrequency": {
|
|
220
|
-
"type": "number",
|
|
221
|
-
"description": "The total number of major ticks on the number line."
|
|
222
|
-
},
|
|
223
|
-
"availableTypes": {
|
|
224
|
-
"type": "object",
|
|
225
|
-
"description": "An object mapping point, ray, and line types to boolean values which specify whether or not the types are available for use in the component."
|
|
226
|
-
},
|
|
227
|
-
"initialElements": {
|
|
228
|
-
"type": "array",
|
|
229
|
-
"description": "Describes the elements that are to be initially displayed on the number line.",
|
|
230
|
-
"items": {
|
|
231
|
-
"oneOf": [
|
|
232
|
-
{
|
|
233
|
-
"$ref": "#/definitions/ray"
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
"$ref": "#/definitions/line"
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
"$ref": "#/definitions/point"
|
|
240
|
-
}
|
|
241
|
-
]
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
"required": [
|
|
248
|
-
"config"
|
|
249
|
-
]
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
"required": [
|
|
253
|
-
"correctResponse",
|
|
254
|
-
"model"
|
|
255
|
-
]
|
|
256
|
-
}
|
package/lib/data-converter.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toSessionFormat = exports.toGraphFormat = exports.switchPosition = exports.switchGraphLine = exports.lineIsSwitched = void 0;
|
|
7
|
-
const lineIsSwitched = line => {
|
|
8
|
-
let {
|
|
9
|
-
position
|
|
10
|
-
} = line;
|
|
11
|
-
return position.left > position.right;
|
|
12
|
-
};
|
|
13
|
-
exports.lineIsSwitched = lineIsSwitched;
|
|
14
|
-
const switchGraphLine = line => {
|
|
15
|
-
let {
|
|
16
|
-
position
|
|
17
|
-
} = line;
|
|
18
|
-
if (position.left < position.right) {
|
|
19
|
-
return line;
|
|
20
|
-
}
|
|
21
|
-
let {
|
|
22
|
-
leftPoint: newRightPoint,
|
|
23
|
-
rightPoint: newLeftPoint
|
|
24
|
-
} = line;
|
|
25
|
-
return {
|
|
26
|
-
leftPoint: newLeftPoint,
|
|
27
|
-
rightPoint: newRightPoint,
|
|
28
|
-
position: switchPosition(position),
|
|
29
|
-
type: 'line'
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.switchGraphLine = switchGraphLine;
|
|
33
|
-
const switchPosition = p => {
|
|
34
|
-
let {
|
|
35
|
-
left: newRight,
|
|
36
|
-
right: newLeft
|
|
37
|
-
} = p;
|
|
38
|
-
return {
|
|
39
|
-
left: newLeft,
|
|
40
|
-
right: newRight
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
exports.switchPosition = switchPosition;
|
|
44
|
-
const toSessionFormat = gf => {
|
|
45
|
-
if (gf.type === 'point') {
|
|
46
|
-
return {
|
|
47
|
-
type: 'point',
|
|
48
|
-
pointType: gf.pointType,
|
|
49
|
-
domainPosition: gf.position
|
|
50
|
-
};
|
|
51
|
-
} else if (gf.type === 'line') {
|
|
52
|
-
return {
|
|
53
|
-
type: 'line',
|
|
54
|
-
size: gf.position.right - gf.position.left,
|
|
55
|
-
domainPosition: gf.position.left,
|
|
56
|
-
leftPoint: gf.leftPoint,
|
|
57
|
-
rightPoint: gf.rightPoint
|
|
58
|
-
};
|
|
59
|
-
} else if (gf.type === 'ray') {
|
|
60
|
-
return {
|
|
61
|
-
type: 'ray',
|
|
62
|
-
domainPosition: gf.position,
|
|
63
|
-
pointType: gf.pointType,
|
|
64
|
-
direction: gf.direction
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
exports.toSessionFormat = toSessionFormat;
|
|
69
|
-
const toGraphFormat = sf => {
|
|
70
|
-
if (sf.type === 'point') {
|
|
71
|
-
return {
|
|
72
|
-
type: 'point',
|
|
73
|
-
pointType: sf.pointType,
|
|
74
|
-
position: sf.domainPosition
|
|
75
|
-
};
|
|
76
|
-
} else if (sf.type === 'line') {
|
|
77
|
-
return {
|
|
78
|
-
type: 'line',
|
|
79
|
-
position: {
|
|
80
|
-
left: sf.domainPosition,
|
|
81
|
-
right: sf.domainPosition + sf.size
|
|
82
|
-
},
|
|
83
|
-
leftPoint: sf.leftPoint,
|
|
84
|
-
rightPoint: sf.rightPoint
|
|
85
|
-
};
|
|
86
|
-
} else if (sf.type === 'ray') {
|
|
87
|
-
return {
|
|
88
|
-
type: 'ray',
|
|
89
|
-
position: sf.domainPosition,
|
|
90
|
-
pointType: sf.pointType,
|
|
91
|
-
direction: sf.direction
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
exports.toGraphFormat = toGraphFormat;
|
|
96
|
-
//# sourceMappingURL=data-converter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-converter.js","names":["lineIsSwitched","line","position","left","right","exports","switchGraphLine","leftPoint","newRightPoint","rightPoint","newLeftPoint","switchPosition","type","p","newRight","newLeft","toSessionFormat","gf","pointType","domainPosition","size","direction","toGraphFormat","sf"],"sources":["../src/data-converter.js"],"sourcesContent":["export const lineIsSwitched = (line) => {\n let { position } = line;\n return position.left > position.right;\n};\n\nexport const switchGraphLine = (line) => {\n let { position } = line;\n\n if (position.left < position.right) {\n return line;\n }\n\n let { leftPoint: newRightPoint, rightPoint: newLeftPoint } = line;\n\n return {\n leftPoint: newLeftPoint,\n rightPoint: newRightPoint,\n position: switchPosition(position),\n type: 'line',\n };\n};\n\nexport const switchPosition = (p) => {\n let { left: newRight, right: newLeft } = p;\n return { left: newLeft, right: newRight };\n};\n\nexport const toSessionFormat = (gf) => {\n if (gf.type === 'point') {\n return {\n type: 'point',\n pointType: gf.pointType,\n domainPosition: gf.position,\n };\n } else if (gf.type === 'line') {\n return {\n type: 'line',\n size: gf.position.right - gf.position.left,\n domainPosition: gf.position.left,\n leftPoint: gf.leftPoint,\n rightPoint: gf.rightPoint,\n };\n } else if (gf.type === 'ray') {\n return {\n type: 'ray',\n domainPosition: gf.position,\n pointType: gf.pointType,\n direction: gf.direction,\n };\n }\n};\n\nexport const toGraphFormat = (sf) => {\n if (sf.type === 'point') {\n return {\n type: 'point',\n pointType: sf.pointType,\n position: sf.domainPosition,\n };\n } else if (sf.type === 'line') {\n return {\n type: 'line',\n position: {\n left: sf.domainPosition,\n right: sf.domainPosition + sf.size,\n },\n leftPoint: sf.leftPoint,\n rightPoint: sf.rightPoint,\n };\n } else if (sf.type === 'ray') {\n return {\n type: 'ray',\n position: sf.domainPosition,\n pointType: sf.pointType,\n direction: sf.direction,\n };\n }\n};\n"],"mappings":"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","ignoreList":[]}
|
package/lib/draggable/index.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.Draggable = Draggable;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _core = require("@dnd-kit/core");
|
|
10
|
-
// Draggable.jsx
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Shared dnd-kit wrapper for Line + Point.
|
|
14
|
-
*
|
|
15
|
-
* Props:
|
|
16
|
-
* - id: string (unique)
|
|
17
|
-
* - disabled: boolean
|
|
18
|
-
* - grid: [stepX] (like grid={[is]})
|
|
19
|
-
* - bounds: { left: number, right: number } in px (like scaledLineBounds)
|
|
20
|
-
* - onMouseDown: (event) => void
|
|
21
|
-
* - onDragStart?: () => void
|
|
22
|
-
* - onDragMove?: (deltaX: number) => void // snapped + clamped
|
|
23
|
-
* - onDragEnd?: (deltaX: number) => void // snapped + clamped
|
|
24
|
-
* - children: ({ setNodeRef, attributes, listeners, translateX, isDragging, onMouseDown }) => ReactNode
|
|
25
|
-
*/
|
|
26
|
-
function Draggable({
|
|
27
|
-
id,
|
|
28
|
-
disabled,
|
|
29
|
-
grid,
|
|
30
|
-
bounds,
|
|
31
|
-
onMouseDown,
|
|
32
|
-
onDragStart,
|
|
33
|
-
onDragMove,
|
|
34
|
-
onDragEnd,
|
|
35
|
-
children
|
|
36
|
-
}) {
|
|
37
|
-
const {
|
|
38
|
-
attributes,
|
|
39
|
-
listeners,
|
|
40
|
-
setNodeRef,
|
|
41
|
-
transform
|
|
42
|
-
} = (0, _core.useDraggable)({
|
|
43
|
-
id,
|
|
44
|
-
disabled
|
|
45
|
-
});
|
|
46
|
-
const step = grid && grid[0] ? grid[0] : null;
|
|
47
|
-
|
|
48
|
-
// current transform.x from dnd-kit
|
|
49
|
-
let rawX = transform?.x ?? 0;
|
|
50
|
-
|
|
51
|
-
// grid snapping (grid={[step]})
|
|
52
|
-
if (step) {
|
|
53
|
-
rawX = Math.round(rawX / step) * step;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// clamp to bounds in px
|
|
57
|
-
if (bounds) {
|
|
58
|
-
if (typeof bounds.left === 'number') {
|
|
59
|
-
rawX = Math.max(bounds.left, rawX);
|
|
60
|
-
}
|
|
61
|
-
if (typeof bounds.right === 'number') {
|
|
62
|
-
rawX = Math.min(bounds.right, rawX);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const translateX = rawX;
|
|
66
|
-
const isDragging = !!transform;
|
|
67
|
-
|
|
68
|
-
// helpers to apply same snap+clamp to deltaX before callbacks
|
|
69
|
-
const snapClampDeltaX = deltaX => {
|
|
70
|
-
let x = deltaX;
|
|
71
|
-
if (step) {
|
|
72
|
-
x = Math.round(x / step) * step;
|
|
73
|
-
}
|
|
74
|
-
if (bounds) {
|
|
75
|
-
if (typeof bounds.left === 'number') {
|
|
76
|
-
x = Math.max(bounds.left, x);
|
|
77
|
-
}
|
|
78
|
-
if (typeof bounds.right === 'number') {
|
|
79
|
-
x = Math.min(bounds.right, x);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return x;
|
|
83
|
-
};
|
|
84
|
-
(0, _core.useDndMonitor)({
|
|
85
|
-
onDragStart(event) {
|
|
86
|
-
if (event.active.id !== id || disabled) return;
|
|
87
|
-
onDragStart?.();
|
|
88
|
-
},
|
|
89
|
-
onDragMove(event) {
|
|
90
|
-
if (event.active.id !== id || disabled) return;
|
|
91
|
-
const deltaX = event.delta.x || 0;
|
|
92
|
-
onDragMove?.(snapClampDeltaX(deltaX));
|
|
93
|
-
},
|
|
94
|
-
onDragEnd(event) {
|
|
95
|
-
if (event.active.id !== id || disabled) return;
|
|
96
|
-
const deltaX = event.delta.x || 0;
|
|
97
|
-
onDragEnd?.(snapClampDeltaX(deltaX));
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
const handleMouseDown = e => {
|
|
101
|
-
// same as before: prevent text selection
|
|
102
|
-
e.nativeEvent.preventDefault();
|
|
103
|
-
onMouseDown?.(e);
|
|
104
|
-
};
|
|
105
|
-
return children({
|
|
106
|
-
setNodeRef,
|
|
107
|
-
attributes,
|
|
108
|
-
listeners,
|
|
109
|
-
translateX,
|
|
110
|
-
isDragging,
|
|
111
|
-
onMouseDown: handleMouseDown
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_core","Draggable","id","disabled","grid","bounds","onMouseDown","onDragStart","onDragMove","onDragEnd","children","attributes","listeners","setNodeRef","transform","useDraggable","step","rawX","x","Math","round","left","max","right","min","translateX","isDragging","snapClampDeltaX","deltaX","useDndMonitor","event","active","delta","handleMouseDown","e","nativeEvent","preventDefault"],"sources":["../../src/draggable/index.js"],"sourcesContent":["// Draggable.jsx\nimport React from 'react';\nimport { useDraggable, useDndMonitor } from '@dnd-kit/core';\n\n/**\n * Shared dnd-kit wrapper for Line + Point.\n *\n * Props:\n * - id: string (unique)\n * - disabled: boolean\n * - grid: [stepX] (like grid={[is]})\n * - bounds: { left: number, right: number } in px (like scaledLineBounds)\n * - onMouseDown: (event) => void\n * - onDragStart?: () => void\n * - onDragMove?: (deltaX: number) => void // snapped + clamped\n * - onDragEnd?: (deltaX: number) => void // snapped + clamped\n * - children: ({ setNodeRef, attributes, listeners, translateX, isDragging, onMouseDown }) => ReactNode\n */\nexport function Draggable({\n id,\n disabled,\n grid,\n bounds,\n onMouseDown,\n onDragStart,\n onDragMove,\n onDragEnd,\n children,\n}) {\n const { attributes, listeners, setNodeRef, transform } = useDraggable({\n id,\n disabled,\n });\n\n const step = grid && grid[0] ? grid[0] : null;\n\n // current transform.x from dnd-kit\n let rawX = transform?.x ?? 0;\n\n // grid snapping (grid={[step]})\n if (step) {\n rawX = Math.round(rawX / step) * step;\n }\n\n // clamp to bounds in px\n if (bounds) {\n if (typeof bounds.left === 'number') {\n rawX = Math.max(bounds.left, rawX);\n }\n if (typeof bounds.right === 'number') {\n rawX = Math.min(bounds.right, rawX);\n }\n }\n\n const translateX = rawX;\n const isDragging = !!transform;\n\n // helpers to apply same snap+clamp to deltaX before callbacks\n const snapClampDeltaX = (deltaX) => {\n let x = deltaX;\n if (step) {\n x = Math.round(x / step) * step;\n }\n if (bounds) {\n if (typeof bounds.left === 'number') {\n x = Math.max(bounds.left, x);\n }\n if (typeof bounds.right === 'number') {\n x = Math.min(bounds.right, x);\n }\n }\n return x;\n };\n\n useDndMonitor({\n onDragStart(event) {\n if (event.active.id !== id || disabled) return;\n onDragStart?.();\n },\n onDragMove(event) {\n if (event.active.id !== id || disabled) return;\n const deltaX = event.delta.x || 0;\n onDragMove?.(snapClampDeltaX(deltaX));\n },\n onDragEnd(event) {\n if (event.active.id !== id || disabled) return;\n const deltaX = event.delta.x || 0;\n onDragEnd?.(snapClampDeltaX(deltaX));\n },\n });\n\n const handleMouseDown = (e) => {\n // same as before: prevent text selection\n e.nativeEvent.preventDefault();\n onMouseDown?.(e);\n };\n\n return children({\n setNodeRef,\n attributes,\n listeners,\n translateX,\n isDragging,\n onMouseDown: handleMouseDown,\n });\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAFA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,SAASA,CAAC;EACxBC,EAAE;EACFC,QAAQ;EACRC,IAAI;EACJC,MAAM;EACNC,WAAW;EACXC,WAAW;EACXC,UAAU;EACVC,SAAS;EACTC;AACF,CAAC,EAAE;EACD,MAAM;IAAEC,UAAU;IAAEC,SAAS;IAAEC,UAAU;IAAEC;EAAU,CAAC,GAAG,IAAAC,kBAAY,EAAC;IACpEb,EAAE;IACFC;EACF,CAAC,CAAC;EAEF,MAAMa,IAAI,GAAGZ,IAAI,IAAIA,IAAI,CAAC,CAAC,CAAC,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;;EAE7C;EACA,IAAIa,IAAI,GAAGH,SAAS,EAAEI,CAAC,IAAI,CAAC;;EAE5B;EACA,IAAIF,IAAI,EAAE;IACRC,IAAI,GAAGE,IAAI,CAACC,KAAK,CAACH,IAAI,GAAGD,IAAI,CAAC,GAAGA,IAAI;EACvC;;EAEA;EACA,IAAIX,MAAM,EAAE;IACV,IAAI,OAAOA,MAAM,CAACgB,IAAI,KAAK,QAAQ,EAAE;MACnCJ,IAAI,GAAGE,IAAI,CAACG,GAAG,CAACjB,MAAM,CAACgB,IAAI,EAAEJ,IAAI,CAAC;IACpC;IACA,IAAI,OAAOZ,MAAM,CAACkB,KAAK,KAAK,QAAQ,EAAE;MACpCN,IAAI,GAAGE,IAAI,CAACK,GAAG,CAACnB,MAAM,CAACkB,KAAK,EAAEN,IAAI,CAAC;IACrC;EACF;EAEA,MAAMQ,UAAU,GAAGR,IAAI;EACvB,MAAMS,UAAU,GAAG,CAAC,CAACZ,SAAS;;EAE9B;EACA,MAAMa,eAAe,GAAIC,MAAM,IAAK;IAClC,IAAIV,CAAC,GAAGU,MAAM;IACd,IAAIZ,IAAI,EAAE;MACRE,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACF,CAAC,GAAGF,IAAI,CAAC,GAAGA,IAAI;IACjC;IACA,IAAIX,MAAM,EAAE;MACV,IAAI,OAAOA,MAAM,CAACgB,IAAI,KAAK,QAAQ,EAAE;QACnCH,CAAC,GAAGC,IAAI,CAACG,GAAG,CAACjB,MAAM,CAACgB,IAAI,EAAEH,CAAC,CAAC;MAC9B;MACA,IAAI,OAAOb,MAAM,CAACkB,KAAK,KAAK,QAAQ,EAAE;QACpCL,CAAC,GAAGC,IAAI,CAACK,GAAG,CAACnB,MAAM,CAACkB,KAAK,EAAEL,CAAC,CAAC;MAC/B;IACF;IACA,OAAOA,CAAC;EACV,CAAC;EAED,IAAAW,mBAAa,EAAC;IACZtB,WAAWA,CAACuB,KAAK,EAAE;MACjB,IAAIA,KAAK,CAACC,MAAM,CAAC7B,EAAE,KAAKA,EAAE,IAAIC,QAAQ,EAAE;MACxCI,WAAW,GAAG,CAAC;IACjB,CAAC;IACDC,UAAUA,CAACsB,KAAK,EAAE;MAChB,IAAIA,KAAK,CAACC,MAAM,CAAC7B,EAAE,KAAKA,EAAE,IAAIC,QAAQ,EAAE;MACxC,MAAMyB,MAAM,GAAGE,KAAK,CAACE,KAAK,CAACd,CAAC,IAAI,CAAC;MACjCV,UAAU,GAAGmB,eAAe,CAACC,MAAM,CAAC,CAAC;IACvC,CAAC;IACDnB,SAASA,CAACqB,KAAK,EAAE;MACf,IAAIA,KAAK,CAACC,MAAM,CAAC7B,EAAE,KAAKA,EAAE,IAAIC,QAAQ,EAAE;MACxC,MAAMyB,MAAM,GAAGE,KAAK,CAACE,KAAK,CAACd,CAAC,IAAI,CAAC;MACjCT,SAAS,GAAGkB,eAAe,CAACC,MAAM,CAAC,CAAC;IACtC;EACF,CAAC,CAAC;EAEF,MAAMK,eAAe,GAAIC,CAAC,IAAK;IAC7B;IACAA,CAAC,CAACC,WAAW,CAACC,cAAc,CAAC,CAAC;IAC9B9B,WAAW,GAAG4B,CAAC,CAAC;EAClB,CAAC;EAED,OAAOxB,QAAQ,CAAC;IACdG,UAAU;IACVF,UAAU;IACVC,SAAS;IACTa,UAAU;IACVC,UAAU;IACVpB,WAAW,EAAE2B;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
|
package/lib/index.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "Graph", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _graph.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "NumberLineComponent", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _numberLine.default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
exports.tickUtils = exports.pointChooser = exports.default = exports.dataConverter = void 0;
|
|
20
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
var _dataConverter = _interopRequireWildcard(require("./data-converter"));
|
|
22
|
-
var dataConverter = _dataConverter;
|
|
23
|
-
exports.dataConverter = _dataConverter;
|
|
24
|
-
var pointChooser = _interopRequireWildcard(require("./number-line/point-chooser"));
|
|
25
|
-
exports.pointChooser = pointChooser;
|
|
26
|
-
var tickUtils = _interopRequireWildcard(require("./number-line/graph/tick-utils"));
|
|
27
|
-
exports.tickUtils = tickUtils;
|
|
28
|
-
var _graph = _interopRequireDefault(require("./number-line/graph"));
|
|
29
|
-
var _numberLine = _interopRequireDefault(require("./number-line"));
|
|
30
|
-
var _react = _interopRequireDefault(require("react"));
|
|
31
|
-
var _client = require("react-dom/client");
|
|
32
|
-
var _lodashEs = require("lodash-es");
|
|
33
|
-
var _mathRendering = require("@pie-lib/math-rendering");
|
|
34
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
35
|
-
//Expose some additional modules for configuration
|
|
36
|
-
|
|
37
|
-
class NumberLine extends HTMLElement {
|
|
38
|
-
constructor() {
|
|
39
|
-
super();
|
|
40
|
-
(0, _defineProperty2.default)(this, "_scheduleMathRender", () => {
|
|
41
|
-
if (this._mathRenderPending) return;
|
|
42
|
-
this._mathRenderPending = true;
|
|
43
|
-
requestAnimationFrame(() => {
|
|
44
|
-
if (this._mathObserver) {
|
|
45
|
-
this._mathObserver.disconnect();
|
|
46
|
-
}
|
|
47
|
-
(0, _mathRendering.renderMath)(this);
|
|
48
|
-
this._mathRenderPending = false;
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
if (this._mathObserver) {
|
|
51
|
-
this._mathObserver.observe(this, {
|
|
52
|
-
childList: true,
|
|
53
|
-
subtree: true,
|
|
54
|
-
characterData: false
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}, 50);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
this._root = null;
|
|
61
|
-
this._mathObserver = null;
|
|
62
|
-
this._mathRenderPending = false;
|
|
63
|
-
}
|
|
64
|
-
_initMathObserver() {
|
|
65
|
-
if (this._mathObserver) return;
|
|
66
|
-
this._mathObserver = new MutationObserver(() => {
|
|
67
|
-
this._scheduleMathRender();
|
|
68
|
-
});
|
|
69
|
-
this._mathObserver.observe(this, {
|
|
70
|
-
childList: true,
|
|
71
|
-
subtree: true,
|
|
72
|
-
characterData: false
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
_disconnectMathObserver() {
|
|
76
|
-
if (this._mathObserver) {
|
|
77
|
-
this._mathObserver.disconnect();
|
|
78
|
-
this._mathObserver = null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
set model(m) {
|
|
82
|
-
this._model = m;
|
|
83
|
-
this._applyInitialElements();
|
|
84
|
-
this._render();
|
|
85
|
-
this.dispatch('model-set');
|
|
86
|
-
}
|
|
87
|
-
set session(s) {
|
|
88
|
-
this._session = s;
|
|
89
|
-
this._applyInitialElements();
|
|
90
|
-
this._render();
|
|
91
|
-
}
|
|
92
|
-
get session() {
|
|
93
|
-
return this._session;
|
|
94
|
-
}
|
|
95
|
-
connectedCallback() {
|
|
96
|
-
this._initMathObserver();
|
|
97
|
-
this._render();
|
|
98
|
-
}
|
|
99
|
-
isComplete() {
|
|
100
|
-
return this._session ? (this._session.answer || []).length > 0 : false;
|
|
101
|
-
}
|
|
102
|
-
dispatch(type) {
|
|
103
|
-
this.dispatchEvent(new CustomEvent(type, {
|
|
104
|
-
bubbles: true,
|
|
105
|
-
detail: {
|
|
106
|
-
complete: this.isComplete()
|
|
107
|
-
}
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
|
-
dispatchSessionChanged() {
|
|
111
|
-
this.dispatch('session-changed');
|
|
112
|
-
}
|
|
113
|
-
addElement(data) {
|
|
114
|
-
if (!this._session) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
this._session.answer = this._session.answer || [];
|
|
118
|
-
this._session.answer.push((0, _dataConverter.toSessionFormat)(data));
|
|
119
|
-
this.dispatchSessionChanged();
|
|
120
|
-
this._render();
|
|
121
|
-
}
|
|
122
|
-
moveElement(index, el, position) {
|
|
123
|
-
let answer = this._session.answer[index];
|
|
124
|
-
if (!answer) {
|
|
125
|
-
throw new Error('cant find element at index: ', index);
|
|
126
|
-
}
|
|
127
|
-
if (el.type === 'line' && position.left === position.right) {
|
|
128
|
-
this._render();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
//set the new position
|
|
133
|
-
el.position = position;
|
|
134
|
-
let update = el.type === 'line' && (0, _dataConverter.lineIsSwitched)(el) ? (0, _dataConverter.switchGraphLine)(el) : el;
|
|
135
|
-
this._session.answer.splice(index, 1, (0, _dataConverter.toSessionFormat)(update));
|
|
136
|
-
this.dispatchSessionChanged();
|
|
137
|
-
this._render();
|
|
138
|
-
}
|
|
139
|
-
deleteElements(indices) {
|
|
140
|
-
this._session.answer = this._session.answer.filter((v, index) => {
|
|
141
|
-
return !indices.some(d => d === index);
|
|
142
|
-
});
|
|
143
|
-
this.dispatchSessionChanged();
|
|
144
|
-
this._render();
|
|
145
|
-
}
|
|
146
|
-
undoElement() {
|
|
147
|
-
this._session.answer.pop();
|
|
148
|
-
this.dispatchSessionChanged();
|
|
149
|
-
this._render();
|
|
150
|
-
}
|
|
151
|
-
clearElements() {
|
|
152
|
-
this._session.answer = [];
|
|
153
|
-
this.dispatchSessionChanged();
|
|
154
|
-
this._render();
|
|
155
|
-
}
|
|
156
|
-
_applyInitialElements() {
|
|
157
|
-
if (this._model && this._model.graph && this._model.graph.initialElements && this._session && (!this._session.answer || !this._session.answer.length)) {
|
|
158
|
-
this._session.answer = (0, _lodashEs.cloneDeep)(this._model.graph.initialElements);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
_render() {
|
|
162
|
-
if (this._model && this._session) {
|
|
163
|
-
if (!this._session.answer) {
|
|
164
|
-
this._applyInitialElements();
|
|
165
|
-
}
|
|
166
|
-
let answer = (this._session.answer || []).map(_dataConverter.toGraphFormat);
|
|
167
|
-
let model = (0, _lodashEs.cloneDeep)(this._model);
|
|
168
|
-
model.correctResponse = model.correctResponse && model.correctResponse.map(_dataConverter.toGraphFormat);
|
|
169
|
-
let props = {
|
|
170
|
-
model,
|
|
171
|
-
answer,
|
|
172
|
-
onAddElement: this.addElement.bind(this),
|
|
173
|
-
onMoveElement: this.moveElement.bind(this),
|
|
174
|
-
onDeleteElements: this.deleteElements.bind(this),
|
|
175
|
-
onUndoElement: this.undoElement.bind(this),
|
|
176
|
-
onClearElements: this.clearElements.bind(this)
|
|
177
|
-
};
|
|
178
|
-
let el = /*#__PURE__*/_react.default.createElement(_numberLine.default, props);
|
|
179
|
-
if (!this._root) {
|
|
180
|
-
this._root = (0, _client.createRoot)(this);
|
|
181
|
-
}
|
|
182
|
-
this._root.render(el);
|
|
183
|
-
|
|
184
|
-
// schedule math rendering via observer pipeline (for initial render as well)
|
|
185
|
-
this._scheduleMathRender();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
disconnectedCallback() {
|
|
189
|
-
this._disconnectMathObserver();
|
|
190
|
-
if (this._root) {
|
|
191
|
-
this._root.unmount();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
exports.default = NumberLine;
|
|
196
|
-
//# sourceMappingURL=index.js.map
|