@khanacademy/perseus 18.0.1 → 19.0.0
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 +6 -0
- package/dist/es/index.css +0 -24
- package/dist/es/index.js +77 -2496
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +0 -24
- package/dist/index.d.ts +0 -1
- package/dist/index.js +75 -2496
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +2 -109
- package/dist/strings.js +0 -29
- package/dist/types.d.ts +0 -4
- package/dist/widgets/expression.d.ts +2 -2
- package/dist/widgets.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/widgets.test.ts +0 -1
- package/src/extra-widgets.ts +0 -2
- package/src/index.ts +0 -1
- package/src/perseus-types.ts +1 -154
- package/src/styles/perseus-renderer.less +0 -1
- package/src/types.ts +0 -5
- package/src/util/register-all-widgets-for-testing.ts +1 -3
- package/src/widgets/__tests__/renderQuestion.tsx +11 -3
- package/src/widgets.ts +1 -9
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/widgets/transformer.d.ts +0 -94
- package/src/styles/widgets/transformer.less +0 -29
- package/src/widgets/__stories__/transformer.stories.tsx +0 -14
- package/src/widgets/__testdata__/transformer.testdata.ts +0 -107
- package/src/widgets/transformer.tsx +0 -2936
package/dist/perseus-types.d.ts
CHANGED
|
@@ -70,7 +70,6 @@ export type SequenceWidget = Widget<'sequence', PerseusSequenceWidgetOptions>;
|
|
|
70
70
|
export type SimulatorWidget = Widget<'simulator', PerseusSimulatorWidgetOptions>;
|
|
71
71
|
export type SorterWidget = Widget<'sorter', PerseusSorterWidgetOptions>;
|
|
72
72
|
export type TableWidget = Widget<'table', PerseusTableWidgetOptions>;
|
|
73
|
-
export type TransformerWidget = Widget<'transformer', PerseusTransformerWidgetOptions>;
|
|
74
73
|
export type ExampleGraphieWidget = Widget<'example-graphie-widget', PerseusExampleGraphieWidgetOptions>;
|
|
75
74
|
export type ExampleWidget = Widget<'example-widget', PerseusExampleWidgetOptions>;
|
|
76
75
|
export type InputNumberWidget = Widget<'input-number', PerseusInputNumberWidgetOptions>;
|
|
@@ -82,7 +81,7 @@ export type SimpleMarkdownTesterWidget = Widget<'simple-markdown-tester', Perseu
|
|
|
82
81
|
export type UnitInputWidget = Widget<'unit-input', PerseusUnitInputWidgetOptions>;
|
|
83
82
|
export type VideoWidget = Widget<'video', PerseusVideoWidgetOptions>;
|
|
84
83
|
export type AutoCorrectWidget = Widget<'deprecated-standin', PerseusWidgetOptions>;
|
|
85
|
-
export type PerseusWidget = CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ExampleGraphieWidget | ExampleWidget | ExplanationWidget | ExpressionWidget | GradedGroupSetWidget | GradedGroupWidget | GrapherWidget | GroupWidget | IFrameWidget | ImageWidget | InputNumberWidget | InteractionWidget | InteractiveGraphWidget | LabelImageWidget | LightsPuzzleWidget | MatcherWidget | MatrixWidget | MeasurerWidget | MoleculeRendererWidget | NumberLineWidget | NumericInputWidget | OrdererWidget | PassageRefWidget | PassageWidget | PlotterWidget | RadioWidget | ReactionDiagramWidget | RefTargetWidget | SequenceWidget | SimpleMarkdownTesterWidget | SimulatorWidget | SorterWidget | TableWidget |
|
|
84
|
+
export type PerseusWidget = CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ExampleGraphieWidget | ExampleWidget | ExplanationWidget | ExpressionWidget | GradedGroupSetWidget | GradedGroupWidget | GrapherWidget | GroupWidget | IFrameWidget | ImageWidget | InputNumberWidget | InteractionWidget | InteractiveGraphWidget | LabelImageWidget | LightsPuzzleWidget | MatcherWidget | MatrixWidget | MeasurerWidget | MoleculeRendererWidget | NumberLineWidget | NumericInputWidget | OrdererWidget | PassageRefWidget | PassageWidget | PlotterWidget | RadioWidget | ReactionDiagramWidget | RefTargetWidget | SequenceWidget | SimpleMarkdownTesterWidget | SimulatorWidget | SorterWidget | TableWidget | UnitInputWidget | VideoWidget | AutoCorrectWidget;
|
|
86
85
|
export type PerseusImageBackground = {
|
|
87
86
|
url: string | null | undefined;
|
|
88
87
|
width?: number;
|
|
@@ -468,85 +467,6 @@ export type PerseusTableWidgetOptions = {
|
|
|
468
467
|
columns: number;
|
|
469
468
|
answers: ReadonlyArray<ReadonlyArray<string>>;
|
|
470
469
|
};
|
|
471
|
-
export type PerseusTransformerWidgetOptions = {
|
|
472
|
-
correct: {
|
|
473
|
-
shape: {
|
|
474
|
-
type: ReadonlyArray<"polygon-5" | "polygon-3" | "polygon-4" | "lineSegment" | "polygon-6" | "angle" | "line" | "circle">;
|
|
475
|
-
coords: ReadonlyArray<Coord>;
|
|
476
|
-
options?: ReadonlyArray<{
|
|
477
|
-
reflex?: boolean;
|
|
478
|
-
}>;
|
|
479
|
-
};
|
|
480
|
-
transformations: ReadonlyArray<PerseusTransformerTransformation>;
|
|
481
|
-
};
|
|
482
|
-
drawSolutionShape: boolean;
|
|
483
|
-
gradeEmpty: boolean;
|
|
484
|
-
graph: {
|
|
485
|
-
backgroundImage: {
|
|
486
|
-
bottom?: number;
|
|
487
|
-
height?: number;
|
|
488
|
-
left?: number;
|
|
489
|
-
scale?: number;
|
|
490
|
-
url?: string;
|
|
491
|
-
width?: number;
|
|
492
|
-
};
|
|
493
|
-
gridStep?: [number, number];
|
|
494
|
-
labels?: ["x", "y"];
|
|
495
|
-
markings: "none" | "graph" | "grid";
|
|
496
|
-
range: [[number, number], [number, number]];
|
|
497
|
-
rulerLabel?: string;
|
|
498
|
-
rulerTicks?: number;
|
|
499
|
-
showProtractor: boolean;
|
|
500
|
-
showRuler?: boolean;
|
|
501
|
-
snapStep?: [number, number];
|
|
502
|
-
step: [number, number];
|
|
503
|
-
};
|
|
504
|
-
graphMode: "dynamic" | "interactive" | "static";
|
|
505
|
-
listMode: "interactive" | "dynamic" | "static";
|
|
506
|
-
starting: {
|
|
507
|
-
shape: {
|
|
508
|
-
type: ReadonlyArray<"polygon-5" | "polygon-3" | "polygon-4" | "lineSegment" | "polygon-6">;
|
|
509
|
-
coords: ReadonlyArray<Coord>;
|
|
510
|
-
options?: ReadonlyArray<Empty>;
|
|
511
|
-
} | {
|
|
512
|
-
type: "polygon-3";
|
|
513
|
-
coords: [Coord, Coord, Coord];
|
|
514
|
-
} | {
|
|
515
|
-
type: [
|
|
516
|
-
"polygon-3" | "lineSegment" | "polygon-4" | "polygon-5" | "polygon-6" | "line" | "circle"
|
|
517
|
-
];
|
|
518
|
-
coords: ReadonlyArray<Coord>;
|
|
519
|
-
options: [Empty];
|
|
520
|
-
} | {
|
|
521
|
-
type: ["polygon-3"];
|
|
522
|
-
coords: [Coord, Coord, Coord];
|
|
523
|
-
options?: [Empty];
|
|
524
|
-
} | {
|
|
525
|
-
type: ["angle"];
|
|
526
|
-
coords: [Coord, Coord, Coord];
|
|
527
|
-
options: [
|
|
528
|
-
{
|
|
529
|
-
reflex: boolean;
|
|
530
|
-
}
|
|
531
|
-
];
|
|
532
|
-
} | {
|
|
533
|
-
type: ["line" | "lineSegment"];
|
|
534
|
-
coords: [Coord, Coord];
|
|
535
|
-
options?: [Empty];
|
|
536
|
-
} | {
|
|
537
|
-
type: "polygon";
|
|
538
|
-
coords: ReadonlyArray<Coord>;
|
|
539
|
-
};
|
|
540
|
-
transformations: ReadonlyArray<PerseusTransformerTransformation>;
|
|
541
|
-
};
|
|
542
|
-
tools: {
|
|
543
|
-
dilation: DilationTool;
|
|
544
|
-
reflection: ReflectionTool;
|
|
545
|
-
rotation: RotationTool;
|
|
546
|
-
translation: TranslationTool;
|
|
547
|
-
};
|
|
548
|
-
version: number;
|
|
549
|
-
};
|
|
550
470
|
export type DilationTransformation = {
|
|
551
471
|
type: "dilation";
|
|
552
472
|
center: Coord;
|
|
@@ -575,33 +495,6 @@ export type TranslationTransformation = {
|
|
|
575
495
|
vector: Coord;
|
|
576
496
|
contraints: Empty;
|
|
577
497
|
};
|
|
578
|
-
export type PerseusTransformerTransformation = DilationTransformation | ReflectionTransformation | RotationTransformation | TranslationTransformation;
|
|
579
|
-
type DilationTool = {
|
|
580
|
-
constraints: PerseusTransformerToolConstraints;
|
|
581
|
-
coord: Coord;
|
|
582
|
-
enabled: boolean;
|
|
583
|
-
required?: boolean;
|
|
584
|
-
};
|
|
585
|
-
type ReflectionTool = {
|
|
586
|
-
constraints: PerseusTransformerToolConstraints;
|
|
587
|
-
coords: [Coord, Coord];
|
|
588
|
-
enabled: boolean;
|
|
589
|
-
required?: boolean;
|
|
590
|
-
};
|
|
591
|
-
type RotationTool = {
|
|
592
|
-
constraints: PerseusTransformerToolConstraints;
|
|
593
|
-
coord: Coord;
|
|
594
|
-
enabled: boolean;
|
|
595
|
-
required?: boolean;
|
|
596
|
-
};
|
|
597
|
-
type TranslationTool = {
|
|
598
|
-
constraints: Empty;
|
|
599
|
-
enabled: boolean;
|
|
600
|
-
required?: boolean;
|
|
601
|
-
};
|
|
602
|
-
export type PerseusTransformerToolConstraints = {
|
|
603
|
-
fixed: boolean;
|
|
604
|
-
};
|
|
605
498
|
export type PerseusInteractionWidgetOptions = {
|
|
606
499
|
graph: PerseusInteractionGraph;
|
|
607
500
|
elements: ReadonlyArray<PerseusInteractionElement>;
|
|
@@ -774,5 +667,5 @@ export type PerseusPassageRefTargetWidgetOptions = any;
|
|
|
774
667
|
export type PerseusReactionDiagramWidgetOptions = any;
|
|
775
668
|
export type PerseusSimpleMarkdownTesterWidgetOptions = any;
|
|
776
669
|
export type PerseusUnitInputWidgetOptions = any;
|
|
777
|
-
export type PerseusWidgetOptions = PerseusCategorizerWidgetOptions | PerseusCSProgramWidgetOptions | PerseusDefinitionWidgetOptions | PerseusDropdownWidgetOptions | PerseusExampleGraphieWidgetOptions | PerseusExampleWidgetOptions | PerseusExplanationWidgetOptions | PerseusExpressionWidgetOptions | PerseusGradedGroupSetWidgetOptions | PerseusGradedGroupWidgetOptions | PerseusIFrameWidgetOptions | PerseusImageWidgetOptions | PerseusInputNumberWidgetOptions | PerseusInteractionWidgetOptions | PerseusInteractiveGraphWidgetOptions | PerseusLabelImageWidgetOptions | PerseusLightsPuzzleWidgetOptions | PerseusMatcherWidgetOptions | PerseusMatrixWidgetOptions | PerseusMeasurerWidgetOptions | PerseusMoleculeRendererWidgetOptions | PerseusNumberLineWidgetOptions | PerseusNumericInputWidgetOptions | PerseusOrdererWidgetOptions | PerseusPassageRefTargetWidgetOptions | PerseusPassageRefWidgetOptions | PerseusPassageWidgetOptions | PerseusPlotterWidgetOptions | PerseusRadioWidgetOptions | PerseusReactionDiagramWidgetOptions | PerseusSequenceWidgetOptions | PerseusSimpleMarkdownTesterWidgetOptions | PerseusSimulatorWidgetOptions | PerseusSorterWidgetOptions | PerseusTableWidgetOptions |
|
|
670
|
+
export type PerseusWidgetOptions = PerseusCategorizerWidgetOptions | PerseusCSProgramWidgetOptions | PerseusDefinitionWidgetOptions | PerseusDropdownWidgetOptions | PerseusExampleGraphieWidgetOptions | PerseusExampleWidgetOptions | PerseusExplanationWidgetOptions | PerseusExpressionWidgetOptions | PerseusGradedGroupSetWidgetOptions | PerseusGradedGroupWidgetOptions | PerseusIFrameWidgetOptions | PerseusImageWidgetOptions | PerseusInputNumberWidgetOptions | PerseusInteractionWidgetOptions | PerseusInteractiveGraphWidgetOptions | PerseusLabelImageWidgetOptions | PerseusLightsPuzzleWidgetOptions | PerseusMatcherWidgetOptions | PerseusMatrixWidgetOptions | PerseusMeasurerWidgetOptions | PerseusMoleculeRendererWidgetOptions | PerseusNumberLineWidgetOptions | PerseusNumericInputWidgetOptions | PerseusOrdererWidgetOptions | PerseusPassageRefTargetWidgetOptions | PerseusPassageRefWidgetOptions | PerseusPassageWidgetOptions | PerseusPlotterWidgetOptions | PerseusRadioWidgetOptions | PerseusReactionDiagramWidgetOptions | PerseusSequenceWidgetOptions | PerseusSimpleMarkdownTesterWidgetOptions | PerseusSimulatorWidgetOptions | PerseusSorterWidgetOptions | PerseusTableWidgetOptions | PerseusUnitInputWidgetOptions | PerseusVideoWidgetOptions;
|
|
778
671
|
export {};
|
package/dist/strings.js
CHANGED
|
@@ -31,7 +31,6 @@ module.exports = [
|
|
|
31
31
|
i18n._("a multiple of pi, like $12\\ \\text{pi}$ or $2/3\\ \\text{pi}$", {}),
|
|
32
32
|
i18n._("a percent, like $12.34\\%$", {}),
|
|
33
33
|
i18n._("Add highlight", {}),
|
|
34
|
-
i18n._("Add transformations below:", {}),
|
|
35
34
|
i18n._("an *exact* decimal, like $0.75$", {}),
|
|
36
35
|
i18n._("an *improper* fraction, like $10/7$ or $14/8$", {}),
|
|
37
36
|
i18n._("an integer, like $6$", {}),
|
|
@@ -55,12 +54,6 @@ module.exports = [
|
|
|
55
54
|
i18n._("Correct (selected)", {}),
|
|
56
55
|
i18n._("Correct!", {}),
|
|
57
56
|
i18n._("Current", {}),
|
|
58
|
-
// I18N: As in the command, "Dilate the polygon"
|
|
59
|
-
i18n._("Dilate", {}),
|
|
60
|
-
i18n._("dilation", {}),
|
|
61
|
-
i18n._("Dilation", {}),
|
|
62
|
-
i18n.$_("Dilation about %(point)s by %(scale)s", {}),
|
|
63
|
-
i18n.$_("Dilation of scale %(scale)s about %(point)s", {}),
|
|
64
57
|
i18n._("Drag handles to make graph", {}),
|
|
65
58
|
i18n._("End of reading passage.", {}),
|
|
66
59
|
i18n._("entered in an invalid answer.", {}),
|
|
@@ -93,7 +86,6 @@ module.exports = [
|
|
|
93
86
|
i18n._("Next question", {}),
|
|
94
87
|
i18n._("No", {}),
|
|
95
88
|
i18n._("None of the above", {}),
|
|
96
|
-
i18n._("Note: For this question, the shape will not move.", {}),
|
|
97
89
|
i18n._("Number of divisions:", {}),
|
|
98
90
|
i18n._("Number of trials:", {}),
|
|
99
91
|
i18n._("Oops!", {}),
|
|
@@ -102,19 +94,7 @@ module.exports = [
|
|
|
102
94
|
i18n._("Please choose the correct number of answers.", {}),
|
|
103
95
|
i18n.$_("Please make sure the number of divisions is in the range %(divRangeString)s.", {}),
|
|
104
96
|
i18n._("Reaction arrow pointing to the right.", {}),
|
|
105
|
-
// I18N: As in the command, "Reflect the polygon"
|
|
106
|
-
i18n._("Reflect", {}),
|
|
107
|
-
i18n._("reflection", {}),
|
|
108
|
-
i18n._("Reflection", {}),
|
|
109
|
-
i18n.$_("Reflection over the line from %(point1)s to %(point2)s", {}),
|
|
110
97
|
i18n._("Remove highlight", {}),
|
|
111
|
-
// I18N: As in the command, "Rotate the polygon"
|
|
112
|
-
i18n._("Rotate", {}),
|
|
113
|
-
i18n._("rotation", {}),
|
|
114
|
-
i18n._("Rotation", {}),
|
|
115
|
-
// I18N: %(point)s must come before %(degrees)s in this phrase
|
|
116
|
-
i18n.$_("Rotation about %(point)s by %(degrees)s", {}),
|
|
117
|
-
i18n.$_("Rotation by %(degrees)s about %(point)s", {}),
|
|
118
98
|
i18n._("Run simulation", {}),
|
|
119
99
|
i18n._("Sample size:", {}),
|
|
120
100
|
i18n._("See video transcript", {}),
|
|
@@ -131,16 +111,8 @@ module.exports = [
|
|
|
131
111
|
i18n._("This controls the proportion or percentage that will be used in your simulation.", {}),
|
|
132
112
|
i18n._("This controls the sample size that will be used in your simulation. For example, if you set this to 100, then for each trial, responses from 100 participants will be simulated.", {}),
|
|
133
113
|
i18n._("This is the number of trials used in the simulation. For example, if set to 50, then the survey will be conducted 50 times.", {}),
|
|
134
|
-
// I18N: As in the command, "Translate the polygon"
|
|
135
|
-
i18n._("Translate", {}),
|
|
136
|
-
i18n._("translation", {}),
|
|
137
|
-
i18n._("Translation", {}),
|
|
138
|
-
// I18N: As in the command, "Translation by <3, 1>"
|
|
139
|
-
i18n.$_("Translation by %(vector)s", {}),
|
|
140
114
|
i18n._("True", {}),
|
|
141
115
|
i18n._("Try again", {}),
|
|
142
|
-
i18n._("Undo", {}),
|
|
143
|
-
i18n._("Use the interactive graph to define a correct transformation.", {}),
|
|
144
116
|
i18n._("Value", {}),
|
|
145
117
|
i18n._("We could not understand your answer. Please check your answer for extra text or symbols.", {}),
|
|
146
118
|
i18n._("We couldn't grade your answer.", {}),
|
|
@@ -152,5 +124,4 @@ module.exports = [
|
|
|
152
124
|
i18n._("Your answer is almost correct, but it needs to be simplified.", {}),
|
|
153
125
|
i18n._("Your answer is close, but you may have approximated pi. Enter your answer as a multiple of pi, like <code>12\\ \\text{pi}</code> or <code>2/3\\ \\text{pi}</code>", {}),
|
|
154
126
|
i18n._("Your answer:", {}),
|
|
155
|
-
i18n._("Your transformation must use a %(type)s.", {}),
|
|
156
127
|
];
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SerializedHighlightSet } from "./components/highlighting/types";
|
|
2
1
|
import type { ILogger } from "./logging/log";
|
|
3
2
|
import type { Item } from "./multi-items/item-types";
|
|
4
3
|
import type { PerseusAnswerArea, PerseusRenderer, PerseusWidget } from "./perseus-types";
|
|
@@ -65,9 +64,6 @@ export type ChangeHandler = (arg1: {
|
|
|
65
64
|
choiceStates?: ReadonlyArray<ChoiceState>;
|
|
66
65
|
currentValue?: string;
|
|
67
66
|
selected?: number;
|
|
68
|
-
tools?: ReadonlyArray<any>;
|
|
69
|
-
transformations?: ReadonlyArray<any>;
|
|
70
|
-
highlights?: SerializedHighlightSet;
|
|
71
67
|
plot?: any;
|
|
72
68
|
}, callback?: () => unknown | null | undefined, silent?: boolean) => unknown;
|
|
73
69
|
export type ImageUploader = (file: string, callback: (url: string) => unknown) => unknown;
|
|
@@ -210,7 +210,7 @@ declare const _default: Readonly<{
|
|
|
210
210
|
onFocus: (blurPath: import("../types").FocusPath) => void;
|
|
211
211
|
times: boolean;
|
|
212
212
|
value: string;
|
|
213
|
-
}, "
|
|
213
|
+
}, "trackInteraction" | "onChange" | "static" | "analytics" | "problemNum" | "questionCompleted" | "keypadElement" | "alignment" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "findWidgets" | "keypadConfiguration" | "reviewModeRubric" | "isLastUsedWidget"> & {
|
|
214
214
|
value?: string | undefined;
|
|
215
215
|
onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
216
216
|
onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
@@ -410,7 +410,7 @@ declare const _default: Readonly<{
|
|
|
410
410
|
onFocus: (blurPath: import("../types").FocusPath) => void;
|
|
411
411
|
times: boolean;
|
|
412
412
|
value: string;
|
|
413
|
-
}, "
|
|
413
|
+
}, "trackInteraction" | "onChange" | "static" | "analytics" | "problemNum" | "questionCompleted" | "keypadElement" | "alignment" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "findWidgets" | "keypadConfiguration" | "reviewModeRubric" | "isLastUsedWidget"> & {
|
|
414
414
|
value?: string | undefined;
|
|
415
415
|
onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
416
416
|
onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
package/dist/widgets.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const registerWidgets: (widgets: ReadonlyArray<WidgetExports>) =>
|
|
|
9
9
|
* @param name - the widget that you are trying to replace
|
|
10
10
|
* @param replacementName - the name of the widget that takes its place
|
|
11
11
|
*
|
|
12
|
-
* e.g. replaceWidget("transformer", "
|
|
12
|
+
* e.g. replaceWidget("transformer", "deprecated-standin") will make it so the
|
|
13
13
|
* transformer widget is replaced by the always correct widget
|
|
14
14
|
*/
|
|
15
15
|
export declare const replaceWidget: (name: string, replacementName: string) => void;
|
package/package.json
CHANGED
package/src/extra-widgets.ts
CHANGED
|
@@ -33,7 +33,6 @@ import Sequence from "./widgets/sequence";
|
|
|
33
33
|
import Simulator from "./widgets/simulator";
|
|
34
34
|
import Sorter from "./widgets/sorter";
|
|
35
35
|
import Table from "./widgets/table";
|
|
36
|
-
import Transformer from "./widgets/transformer";
|
|
37
36
|
import Unit from "./widgets/unit";
|
|
38
37
|
import Video from "./widgets/video";
|
|
39
38
|
|
|
@@ -70,7 +69,6 @@ export default [
|
|
|
70
69
|
Simulator,
|
|
71
70
|
Sorter,
|
|
72
71
|
Table,
|
|
73
|
-
Transformer,
|
|
74
72
|
Unit,
|
|
75
73
|
Video,
|
|
76
74
|
DeprecatedStandin,
|
package/src/index.ts
CHANGED
|
@@ -31,7 +31,6 @@ export {default as Radio} from "./widgets/radio";
|
|
|
31
31
|
export {default as BaseRadio} from "./widgets/radio/base-radio";
|
|
32
32
|
export {default as Categorizer} from "./widgets/categorizer";
|
|
33
33
|
export {default as InteractiveGraphWidget} from "./widgets/interactive-graph";
|
|
34
|
-
export {default as TransformerWidget} from "./widgets/transformer";
|
|
35
34
|
export {default as MatrixWidget} from "./widgets/matrix";
|
|
36
35
|
export {default as TableWidget} from "./widgets/table";
|
|
37
36
|
export {default as PlotterWidget} from "./widgets/plotter";
|
package/src/perseus-types.ts
CHANGED
|
@@ -90,7 +90,7 @@ type Widget<Type extends string, Options> = {
|
|
|
90
90
|
// Whether this widget is displayed with the values and is immutable. For display only
|
|
91
91
|
// NOTE: perseus_data.go says this is required even though it isn't necessary.
|
|
92
92
|
static?: boolean;
|
|
93
|
-
// Whether a widget is scored. Usually true except for IFrame widgets (deprecated)
|
|
93
|
+
// Whether a widget is scored. Usually true except for IFrame widgets (deprecated)
|
|
94
94
|
// Default: true
|
|
95
95
|
graded?: boolean;
|
|
96
96
|
// The HTML alignment of the widget. "default" or "block"
|
|
@@ -164,9 +164,6 @@ export type SimulatorWidget = Widget<'simulator', PerseusSimulatorWidgetOptions>
|
|
|
164
164
|
export type SorterWidget = Widget<'sorter', PerseusSorterWidgetOptions>;
|
|
165
165
|
// prettier-ignore
|
|
166
166
|
export type TableWidget = Widget<'table', PerseusTableWidgetOptions>;
|
|
167
|
-
// prettier-ignore
|
|
168
|
-
export type TransformerWidget = Widget<'transformer', PerseusTransformerWidgetOptions>;
|
|
169
|
-
|
|
170
167
|
// prettier-ignore
|
|
171
168
|
export type ExampleGraphieWidget = Widget<'example-graphie-widget', PerseusExampleGraphieWidgetOptions>;
|
|
172
169
|
// prettier-ignore
|
|
@@ -228,7 +225,6 @@ export type PerseusWidget =
|
|
|
228
225
|
| SimulatorWidget
|
|
229
226
|
| SorterWidget
|
|
230
227
|
| TableWidget
|
|
231
|
-
| TransformerWidget
|
|
232
228
|
| UnitInputWidget
|
|
233
229
|
| VideoWidget
|
|
234
230
|
| AutoCorrectWidget;
|
|
@@ -456,7 +452,6 @@ export type PerseusGrapherWidgetOptions = {
|
|
|
456
452
|
// Two points on the same slope in the tangent wave line.
|
|
457
453
|
coords: [Coord, Coord];
|
|
458
454
|
};
|
|
459
|
-
// TODO(jeremy): Unify with PerseusTransformerWidgetOptions's .graph
|
|
460
455
|
graph: {
|
|
461
456
|
backgroundImage: {
|
|
462
457
|
bottom?: number;
|
|
@@ -990,115 +985,6 @@ export type PerseusTableWidgetOptions = {
|
|
|
990
985
|
answers: ReadonlyArray<ReadonlyArray<string>>;
|
|
991
986
|
};
|
|
992
987
|
|
|
993
|
-
export type PerseusTransformerWidgetOptions = {
|
|
994
|
-
correct: {
|
|
995
|
-
shape: {
|
|
996
|
-
type: ReadonlyArray<
|
|
997
|
-
| "polygon-5"
|
|
998
|
-
| "polygon-3"
|
|
999
|
-
| "polygon-4"
|
|
1000
|
-
| "lineSegment"
|
|
1001
|
-
| "polygon-6"
|
|
1002
|
-
| "angle"
|
|
1003
|
-
| "line"
|
|
1004
|
-
| "circle"
|
|
1005
|
-
>;
|
|
1006
|
-
coords: ReadonlyArray<Coord>;
|
|
1007
|
-
options?: ReadonlyArray<{
|
|
1008
|
-
reflex?: boolean;
|
|
1009
|
-
}>;
|
|
1010
|
-
};
|
|
1011
|
-
transformations: ReadonlyArray<PerseusTransformerTransformation>;
|
|
1012
|
-
};
|
|
1013
|
-
drawSolutionShape: boolean;
|
|
1014
|
-
gradeEmpty: boolean;
|
|
1015
|
-
// TODO(jeremy): Unify with PerseusGrapherWidgetOptions's .graph
|
|
1016
|
-
graph: {
|
|
1017
|
-
backgroundImage: {
|
|
1018
|
-
bottom?: number;
|
|
1019
|
-
height?: number;
|
|
1020
|
-
left?: number;
|
|
1021
|
-
scale?: number;
|
|
1022
|
-
url?: string;
|
|
1023
|
-
width?: number;
|
|
1024
|
-
};
|
|
1025
|
-
gridStep?: [number, number];
|
|
1026
|
-
labels?: ["x", "y"];
|
|
1027
|
-
markings: "none" | "graph" | "grid";
|
|
1028
|
-
range: [[number, number], [number, number]];
|
|
1029
|
-
rulerLabel?: string;
|
|
1030
|
-
rulerTicks?: number;
|
|
1031
|
-
showProtractor: boolean;
|
|
1032
|
-
showRuler?: boolean;
|
|
1033
|
-
snapStep?: [number, number];
|
|
1034
|
-
step: [number, number];
|
|
1035
|
-
};
|
|
1036
|
-
graphMode: "dynamic" | "interactive" | "static";
|
|
1037
|
-
listMode: "interactive" | "dynamic" | "static";
|
|
1038
|
-
starting: {
|
|
1039
|
-
shape:
|
|
1040
|
-
| {
|
|
1041
|
-
type: ReadonlyArray<
|
|
1042
|
-
| "polygon-5"
|
|
1043
|
-
| "polygon-3"
|
|
1044
|
-
| "polygon-4"
|
|
1045
|
-
| "lineSegment"
|
|
1046
|
-
| "polygon-6"
|
|
1047
|
-
>;
|
|
1048
|
-
coords: ReadonlyArray<Coord>;
|
|
1049
|
-
options?: ReadonlyArray<Empty>;
|
|
1050
|
-
}
|
|
1051
|
-
| {
|
|
1052
|
-
type: "polygon-3";
|
|
1053
|
-
coords: [Coord, Coord, Coord];
|
|
1054
|
-
}
|
|
1055
|
-
| {
|
|
1056
|
-
type: [
|
|
1057
|
-
| "polygon-3"
|
|
1058
|
-
| "lineSegment"
|
|
1059
|
-
| "polygon-4"
|
|
1060
|
-
| "polygon-5"
|
|
1061
|
-
| "polygon-6"
|
|
1062
|
-
| "line"
|
|
1063
|
-
| "circle",
|
|
1064
|
-
];
|
|
1065
|
-
coords: ReadonlyArray<Coord>;
|
|
1066
|
-
options: [Empty];
|
|
1067
|
-
}
|
|
1068
|
-
| {
|
|
1069
|
-
type: ["polygon-3"];
|
|
1070
|
-
coords: [Coord, Coord, Coord];
|
|
1071
|
-
options?: [Empty];
|
|
1072
|
-
}
|
|
1073
|
-
| {
|
|
1074
|
-
type: ["angle"];
|
|
1075
|
-
coords: [Coord, Coord, Coord];
|
|
1076
|
-
options: [
|
|
1077
|
-
{
|
|
1078
|
-
reflex: boolean;
|
|
1079
|
-
},
|
|
1080
|
-
];
|
|
1081
|
-
}
|
|
1082
|
-
| {
|
|
1083
|
-
type: ["line" | "lineSegment"];
|
|
1084
|
-
coords: [Coord, Coord];
|
|
1085
|
-
options?: [Empty];
|
|
1086
|
-
}
|
|
1087
|
-
| {
|
|
1088
|
-
type: "polygon";
|
|
1089
|
-
coords: ReadonlyArray<Coord>;
|
|
1090
|
-
};
|
|
1091
|
-
transformations: ReadonlyArray<PerseusTransformerTransformation>;
|
|
1092
|
-
};
|
|
1093
|
-
tools: {
|
|
1094
|
-
dilation: DilationTool;
|
|
1095
|
-
reflection: ReflectionTool;
|
|
1096
|
-
rotation: RotationTool;
|
|
1097
|
-
translation: TranslationTool;
|
|
1098
|
-
};
|
|
1099
|
-
version: number;
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
988
|
export type DilationTransformation = {
|
|
1103
989
|
type: "dilation";
|
|
1104
990
|
center: Coord;
|
|
@@ -1131,44 +1017,6 @@ export type TranslationTransformation = {
|
|
|
1131
1017
|
contraints: Empty;
|
|
1132
1018
|
};
|
|
1133
1019
|
|
|
1134
|
-
export type PerseusTransformerTransformation =
|
|
1135
|
-
| DilationTransformation
|
|
1136
|
-
| ReflectionTransformation
|
|
1137
|
-
| RotationTransformation
|
|
1138
|
-
| TranslationTransformation;
|
|
1139
|
-
|
|
1140
|
-
type DilationTool = {
|
|
1141
|
-
constraints: PerseusTransformerToolConstraints;
|
|
1142
|
-
coord: Coord;
|
|
1143
|
-
enabled: boolean;
|
|
1144
|
-
required?: boolean;
|
|
1145
|
-
};
|
|
1146
|
-
|
|
1147
|
-
type ReflectionTool = {
|
|
1148
|
-
constraints: PerseusTransformerToolConstraints;
|
|
1149
|
-
coords: [Coord, Coord];
|
|
1150
|
-
enabled: boolean;
|
|
1151
|
-
required?: boolean;
|
|
1152
|
-
};
|
|
1153
|
-
|
|
1154
|
-
type RotationTool = {
|
|
1155
|
-
constraints: PerseusTransformerToolConstraints;
|
|
1156
|
-
coord: Coord;
|
|
1157
|
-
enabled: boolean;
|
|
1158
|
-
required?: boolean;
|
|
1159
|
-
};
|
|
1160
|
-
|
|
1161
|
-
type TranslationTool = {
|
|
1162
|
-
constraints: Empty;
|
|
1163
|
-
enabled: boolean;
|
|
1164
|
-
required?: boolean;
|
|
1165
|
-
};
|
|
1166
|
-
|
|
1167
|
-
export type PerseusTransformerToolConstraints = {
|
|
1168
|
-
// Whether we should prevent the student from repositioning the tool
|
|
1169
|
-
fixed: boolean;
|
|
1170
|
-
};
|
|
1171
|
-
|
|
1172
1020
|
export type PerseusInteractionWidgetOptions = {
|
|
1173
1021
|
// The definition of the graph
|
|
1174
1022
|
graph: PerseusInteractionGraph;
|
|
@@ -1514,6 +1362,5 @@ export type PerseusWidgetOptions =
|
|
|
1514
1362
|
| PerseusSimulatorWidgetOptions
|
|
1515
1363
|
| PerseusSorterWidgetOptions
|
|
1516
1364
|
| PerseusTableWidgetOptions
|
|
1517
|
-
| PerseusTransformerWidgetOptions
|
|
1518
1365
|
| PerseusUnitInputWidgetOptions
|
|
1519
1366
|
| PerseusVideoWidgetOptions;
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {SerializedHighlightSet} from "./components/highlighting/types";
|
|
2
1
|
import type {ILogger} from "./logging/log";
|
|
3
2
|
import type {Item} from "./multi-items/item-types";
|
|
4
3
|
import type {
|
|
@@ -92,10 +91,6 @@ export type ChangeHandler = (
|
|
|
92
91
|
currentValue?: string;
|
|
93
92
|
// perseus-all-package/widgets/dropdown.jsx
|
|
94
93
|
selected?: number;
|
|
95
|
-
// perseus-all-package/widgets/transformer.jsx
|
|
96
|
-
tools?: ReadonlyArray<any>;
|
|
97
|
-
transformations?: ReadonlyArray<any>;
|
|
98
|
-
highlights?: SerializedHighlightSet;
|
|
99
94
|
// perseus-all-package/widgets/grapher.jsx
|
|
100
95
|
plot?: any;
|
|
101
96
|
},
|
|
@@ -9,7 +9,5 @@ import * as Widgets from "../widgets";
|
|
|
9
9
|
export const registerAllWidgetsForTesting = () => {
|
|
10
10
|
Widgets.registerWidgets(allWidgets);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
// uncomment this line
|
|
14
|
-
// Widgets.replaceWidget("transformer", "deprecated-standin");
|
|
12
|
+
Widgets.replaceWidget("transformer", "deprecated-standin");
|
|
15
13
|
};
|
|
@@ -2,9 +2,16 @@ import {RenderStateRoot} from "@khanacademy/wonder-blocks-core";
|
|
|
2
2
|
import {render} from "@testing-library/react";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import {
|
|
6
|
+
testDependenciesV2,
|
|
7
|
+
testDependencies,
|
|
8
|
+
// eslint-disable-next-line import/no-relative-packages
|
|
9
|
+
} from "../../../../../testing/test-dependencies";
|
|
10
|
+
import {
|
|
11
|
+
DependenciesContext,
|
|
12
|
+
useDependencies,
|
|
13
|
+
setDependencies,
|
|
14
|
+
} from "../../dependencies";
|
|
8
15
|
import * as Perseus from "../../index";
|
|
9
16
|
import {registerAllWidgetsForTesting} from "../../util/register-all-widgets-for-testing";
|
|
10
17
|
|
|
@@ -27,6 +34,7 @@ export const renderQuestion = (
|
|
|
27
34
|
) => void;
|
|
28
35
|
unmount: RenderResult["unmount"];
|
|
29
36
|
} => {
|
|
37
|
+
setDependencies(testDependencies);
|
|
30
38
|
registerAllWidgetsForTesting();
|
|
31
39
|
|
|
32
40
|
let renderer: Perseus.Renderer | null = null;
|
package/src/widgets.ts
CHANGED
|
@@ -48,7 +48,7 @@ export const registerWidgets = (widgets: ReadonlyArray<WidgetExports>) => {
|
|
|
48
48
|
* @param name - the widget that you are trying to replace
|
|
49
49
|
* @param replacementName - the name of the widget that takes its place
|
|
50
50
|
*
|
|
51
|
-
* e.g. replaceWidget("transformer", "
|
|
51
|
+
* e.g. replaceWidget("transformer", "deprecated-standin") will make it so the
|
|
52
52
|
* transformer widget is replaced by the always correct widget
|
|
53
53
|
*/
|
|
54
54
|
export const replaceWidget = (name: string, replacementName: string) => {
|
|
@@ -61,10 +61,6 @@ export const replaceWidget = (name: string, replacementName: string) => {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
registerWidget(name, substituteWidget);
|
|
64
|
-
|
|
65
|
-
if (Log) {
|
|
66
|
-
Log.log(`INFO: Replacing widget ${name} with ${replacementName}`);
|
|
67
|
-
}
|
|
68
64
|
};
|
|
69
65
|
|
|
70
66
|
export const registerEditors = (editorsToRegister: ReadonlyArray<Editor>) => {
|
|
@@ -97,10 +93,6 @@ export const replaceEditor = (name: string, replacementName: string) => {
|
|
|
97
93
|
}
|
|
98
94
|
|
|
99
95
|
editors[name] = substituteEditor;
|
|
100
|
-
|
|
101
|
-
if (Log) {
|
|
102
|
-
Log.log(`INFO: Replacing editor ${name} with ${replacementName}`);
|
|
103
|
-
}
|
|
104
96
|
};
|
|
105
97
|
|
|
106
98
|
export const getWidget = (
|