@khanacademy/perseus 14.0.0 → 15.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 +25 -0
- package/dist/article-renderer.d.ts +1 -2
- package/dist/es/index.js +16 -468
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +13 -463
- package/dist/index.js.map +1 -1
- package/dist/multi-items/item-types.d.ts +1 -1
- package/dist/multi-items/multi-renderer.d.ts +2 -2
- package/dist/perseus-api.d.ts +0 -3
- package/dist/server-item-renderer.d.ts +2 -15
- package/dist/strings.js +1 -0
- package/dist/styles/shared.d.ts +1 -0
- package/dist/types.d.ts +0 -2
- package/dist/util/a11y.d.ts +1 -0
- package/dist/widgets/expression.d.ts +0 -12
- package/dist/widgets/graded-group.d.ts +1 -1
- package/dist/widgets/label-image.d.ts +1 -1
- package/dist/widgets/matcher.d.ts +0 -1
- package/dist/widgets/passage.d.ts +1 -1
- package/dist/widgets/radio/widget.d.ts +1 -1
- package/dist/widgets/simulator.d.ts +0 -1
- package/dist/widgets/sorter.d.ts +0 -1
- package/package.json +8 -8
- package/src/__stories__/server-item-renderer.stories.tsx +1 -1
- package/src/__testdata__/server-item-renderer.testdata.ts +160 -0
- package/src/__tests__/server-item-renderer.test.tsx +2 -2
- package/src/article-renderer.tsx +13 -15
- package/src/components/svg-image.tsx +1 -1
- package/src/hints-renderer.tsx +1 -0
- package/src/index.ts +0 -1
- package/src/multi-items/item-types.ts +1 -1
- package/src/multi-items/multi-renderer.tsx +4 -4
- package/src/perseus-api.tsx +0 -6
- package/src/server-item-renderer.tsx +12 -13
- package/src/types.ts +0 -5
- package/src/util.ts +1 -1
- package/src/widgets/__stories__/expression.stories.tsx +0 -1
- package/src/widgets/__tests__/expression-mobile.test.tsx +0 -1
- package/src/widgets/__tests__/expression.test.tsx +4 -15
- package/src/widgets/expression.tsx +1 -5
- package/src/widgets/graded-group.tsx +1 -1
- package/src/widgets/label-image/strings.ts +3 -1
- package/src/widgets/label-image.tsx +2 -2
- package/src/widgets/passage-ref.tsx +1 -1
- package/src/widgets/passage.tsx +1 -1
- package/src/widgets/radio/widget.tsx +1 -1
- package/src/widgets/radio.ts +1 -1
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/item-renderer.d.ts +0 -125
- package/dist/mixins/provide-keypad.d.ts +0 -39
- package/src/__stories__/item-renderer.stories.tsx +0 -30
- package/src/__testdata__/item-renderer.testdata.ts +0 -299
- package/src/__tests__/__snapshots__/item-renderer.test.tsx.snap +0 -224
- package/src/__tests__/item-renderer.test.tsx +0 -930
- package/src/item-renderer.tsx +0 -529
- package/src/mixins/provide-keypad.tsx +0 -137
|
@@ -20,7 +20,6 @@ import {ApiOptions} from "./perseus-api";
|
|
|
20
20
|
import Renderer from "./renderer";
|
|
21
21
|
import Util from "./util";
|
|
22
22
|
|
|
23
|
-
import type {KeypadProps} from "./mixins/provide-keypad";
|
|
24
23
|
import type {APIOptions, FocusPath, PerseusDependenciesV2} from "./types";
|
|
25
24
|
import type {KeypadAPI} from "@khanacademy/math-input";
|
|
26
25
|
import type {
|
|
@@ -31,19 +30,18 @@ import type {
|
|
|
31
30
|
|
|
32
31
|
const {mapObject} = Objective;
|
|
33
32
|
|
|
34
|
-
type OwnProps =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
question: any;
|
|
41
|
-
};
|
|
42
|
-
problemNum?: number;
|
|
43
|
-
reviewMode?: boolean;
|
|
44
|
-
keypadElement?: KeypadAPI | null | undefined;
|
|
45
|
-
dependencies: PerseusDependenciesV2;
|
|
33
|
+
type OwnProps = {
|
|
34
|
+
apiOptions: APIOptions;
|
|
35
|
+
hintsVisible?: number;
|
|
36
|
+
item: {
|
|
37
|
+
hints: ReadonlyArray<any>;
|
|
38
|
+
question: any;
|
|
46
39
|
};
|
|
40
|
+
problemNum?: number;
|
|
41
|
+
reviewMode?: boolean;
|
|
42
|
+
keypadElement?: KeypadAPI | null | undefined;
|
|
43
|
+
dependencies: PerseusDependenciesV2;
|
|
44
|
+
};
|
|
47
45
|
|
|
48
46
|
type HOCProps = {
|
|
49
47
|
onRendered: (isRendered: boolean) => void;
|
|
@@ -104,6 +102,7 @@ export class ServerItemRenderer
|
|
|
104
102
|
this._fullyRendered = false;
|
|
105
103
|
}
|
|
106
104
|
|
|
105
|
+
// eslint-disable-next-line react/no-unsafe
|
|
107
106
|
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
|
108
107
|
this.setState({
|
|
109
108
|
questionHighlightedWidgets: [],
|
package/src/types.ts
CHANGED
|
@@ -185,10 +185,6 @@ export type APIOptions = Readonly<{
|
|
|
185
185
|
// from the math-input repo instead of the existing perseus math
|
|
186
186
|
// input components.
|
|
187
187
|
customKeypad?: boolean;
|
|
188
|
-
// Whether to use v1 (Legacy) Keypad for MathInput mobile or
|
|
189
|
-
// use the new v2 Keypad
|
|
190
|
-
// TODO [LC-1088]: remove after v2 release
|
|
191
|
-
useV2Keypad?: boolean;
|
|
192
188
|
// If this is provided, it is called instead of appending an instance
|
|
193
189
|
// of `math-input`'s keypad to the body. This is used by the native
|
|
194
190
|
// apps so they can have the keypad be defined on the native side.
|
|
@@ -362,7 +358,6 @@ export type APIOptionsWithDefaults = Readonly<
|
|
|
362
358
|
inModal: NonNullable<APIOptions["inModal"]>;
|
|
363
359
|
isArticle: NonNullable<APIOptions["isArticle"]>;
|
|
364
360
|
isMobile: NonNullable<APIOptions["isMobile"]>;
|
|
365
|
-
useV2Keypad: NonNullable<APIOptions["useV2Keypad"]>;
|
|
366
361
|
onFocusChange: NonNullable<APIOptions["onFocusChange"]>;
|
|
367
362
|
onInputError: NonNullable<APIOptions["onInputError"]>;
|
|
368
363
|
readOnly: NonNullable<APIOptions["readOnly"]>;
|
package/src/util.ts
CHANGED
|
@@ -3,8 +3,8 @@ import _ from "underscore";
|
|
|
3
3
|
|
|
4
4
|
import {Errors} from "./logging/log";
|
|
5
5
|
import {PerseusError} from "./perseus-error";
|
|
6
|
-
import * as GraphieUtil from "./util.graphie";
|
|
7
6
|
import KhanAnswerTypes from "./util/answer-types";
|
|
7
|
+
import * as GraphieUtil from "./util.graphie";
|
|
8
8
|
|
|
9
9
|
import type {Range} from "./perseus-types";
|
|
10
10
|
import type {Widget, PerseusScore} from "./types";
|
|
@@ -42,7 +42,7 @@ const assertCorrect = (itemData: PerseusItem, input: string) => {
|
|
|
42
42
|
type: "perseus:expression-evaluated",
|
|
43
43
|
payload: {
|
|
44
44
|
result: "correct",
|
|
45
|
-
virtualKeypadVersion: "
|
|
45
|
+
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V2",
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
48
|
};
|
|
@@ -54,7 +54,7 @@ const assertIncorrect = (itemData: PerseusItem, input: string) => {
|
|
|
54
54
|
type: "perseus:expression-evaluated",
|
|
55
55
|
payload: {
|
|
56
56
|
result: "incorrect",
|
|
57
|
-
virtualKeypadVersion: "
|
|
57
|
+
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V2",
|
|
58
58
|
},
|
|
59
59
|
});
|
|
60
60
|
};
|
|
@@ -224,19 +224,8 @@ describe("Expression Widget", function () {
|
|
|
224
224
|
);
|
|
225
225
|
});
|
|
226
226
|
|
|
227
|
-
it("should
|
|
228
|
-
assertKeypadVersion({
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it("should set the virtual keypad version to MATH_INPUT_KEYPAD_V2 when customKeypad is set and useV2Keypad is true", () => {
|
|
232
|
-
assertKeypadVersion(
|
|
233
|
-
{customKeypad: true, useV2Keypad: true},
|
|
234
|
-
"MATH_INPUT_KEYPAD_V2",
|
|
235
|
-
);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("should default the virtual keypad version to PERSEUS_MATH_INPUT", () => {
|
|
239
|
-
assertKeypadVersion(Object.freeze({}), "PERSEUS_MATH_INPUT");
|
|
227
|
+
it("should default the virtual keypad version to MATH_INPUT_KEYPAD_V2", () => {
|
|
228
|
+
assertKeypadVersion(Object.freeze({}), "MATH_INPUT_KEYPAD_V2");
|
|
240
229
|
});
|
|
241
230
|
});
|
|
242
231
|
});
|
|
@@ -64,11 +64,7 @@ const deriveKeypadVersion = (apiOptions: APIOptions) => {
|
|
|
64
64
|
// can remove this `virtualKeypadVersion` field entirely.
|
|
65
65
|
return apiOptions.nativeKeypadProxy != null
|
|
66
66
|
? "REACT_NATIVE_KEYPAD"
|
|
67
|
-
:
|
|
68
|
-
? apiOptions.useV2Keypad === true
|
|
69
|
-
? "MATH_INPUT_KEYPAD_V2"
|
|
70
|
-
: "MATH_INPUT_KEYPAD_V1"
|
|
71
|
-
: "PERSEUS_MATH_INPUT";
|
|
67
|
+
: "MATH_INPUT_KEYPAD_V2";
|
|
72
68
|
};
|
|
73
69
|
|
|
74
70
|
type Rubric = PerseusExpressionWidgetOptions;
|
|
@@ -24,6 +24,7 @@ import a11y from "../util/a11y";
|
|
|
24
24
|
|
|
25
25
|
import GradedGroupAnswerBar from "./graded-group-answer-bar";
|
|
26
26
|
|
|
27
|
+
import type {ANSWER_BAR_STATES} from "./graded-group-answer-bar";
|
|
27
28
|
import type {PerseusGradedGroupWidgetOptions} from "../perseus-types";
|
|
28
29
|
import type {
|
|
29
30
|
PerseusScore,
|
|
@@ -31,7 +32,6 @@ import type {
|
|
|
31
32
|
WidgetExports,
|
|
32
33
|
WidgetProps,
|
|
33
34
|
} from "../types";
|
|
34
|
-
import type {ANSWER_BAR_STATES} from "./graded-group-answer-bar";
|
|
35
35
|
|
|
36
36
|
const GRADING_STATUSES = {
|
|
37
37
|
ungraded: "ungraded" as const,
|
|
@@ -22,12 +22,12 @@ import mediaQueries from "../styles/media-queries";
|
|
|
22
22
|
import AnswerChoices from "./label-image/answer-choices";
|
|
23
23
|
import Marker from "./label-image/marker";
|
|
24
24
|
|
|
25
|
-
import type {ChangeableProps} from "../mixins/changeable";
|
|
26
|
-
import type {APIOptions, PerseusScore, WidgetExports} from "../types";
|
|
27
25
|
import type {
|
|
28
26
|
InteractiveMarkerType,
|
|
29
27
|
InteractiveMarkerScore,
|
|
30
28
|
} from "./label-image/types";
|
|
29
|
+
import type {ChangeableProps} from "../mixins/changeable";
|
|
30
|
+
import type {APIOptions, PerseusScore, WidgetExports} from "../types";
|
|
31
31
|
|
|
32
32
|
type MarkersState = {
|
|
33
33
|
markers: ReadonlyArray<InteractiveMarkerType>;
|
|
@@ -7,6 +7,7 @@ import * as Changeable from "../mixins/changeable";
|
|
|
7
7
|
import {removeDenylistProps} from "../mixins/widget-prop-denylist";
|
|
8
8
|
import PerseusMarkdown from "../perseus-markdown";
|
|
9
9
|
|
|
10
|
+
import type {Passage, Reference} from "./passage";
|
|
10
11
|
import type {PerseusPassageRefWidgetOptions} from "../perseus-types";
|
|
11
12
|
import type {
|
|
12
13
|
ChangeFn,
|
|
@@ -14,7 +15,6 @@ import type {
|
|
|
14
15
|
WidgetExports,
|
|
15
16
|
WidgetProps,
|
|
16
17
|
} from "../types";
|
|
17
|
-
import type {Passage, Reference} from "./passage";
|
|
18
18
|
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
19
19
|
|
|
20
20
|
const EN_DASH = "\u2013";
|
package/src/widgets/passage.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import Renderer from "../renderer";
|
|
|
12
12
|
|
|
13
13
|
import PassageMarkdown from "./passage/passage-markdown";
|
|
14
14
|
|
|
15
|
+
import type {ParseState} from "./passage/passage-markdown";
|
|
15
16
|
import type {SerializedHighlightSet} from "../components/highlighting/types";
|
|
16
17
|
import type {ChangeableProps} from "../mixins/changeable";
|
|
17
18
|
import type {PerseusPassageWidgetOptions} from "../perseus-types";
|
|
@@ -21,7 +22,6 @@ import type {
|
|
|
21
22
|
WidgetInfo,
|
|
22
23
|
WidgetProps,
|
|
23
24
|
} from "../types";
|
|
24
|
-
import type {ParseState} from "./passage/passage-markdown";
|
|
25
25
|
import type {SingleASTNode} from "@khanacademy/simple-markdown";
|
|
26
26
|
|
|
27
27
|
// A fake paragraph to measure the line height of the passage,
|
|
@@ -8,12 +8,12 @@ import PassageRef from "../passage-ref";
|
|
|
8
8
|
|
|
9
9
|
import BaseRadio from "./base-radio";
|
|
10
10
|
|
|
11
|
+
import type {FocusFunction, ChoiceType} from "./base-radio";
|
|
11
12
|
import type {
|
|
12
13
|
PerseusRadioChoice,
|
|
13
14
|
PerseusRadioWidgetOptions,
|
|
14
15
|
} from "../../perseus-types";
|
|
15
16
|
import type {PerseusScore, WidgetProps, ChoiceState} from "../../types";
|
|
16
|
-
import type {FocusFunction, ChoiceType} from "./base-radio";
|
|
17
17
|
|
|
18
18
|
// RenderProps is the return type for radio.jsx#transform
|
|
19
19
|
export type RenderProps = {
|
package/src/widgets/radio.ts
CHANGED
|
@@ -5,9 +5,9 @@ import Util from "../util";
|
|
|
5
5
|
|
|
6
6
|
import Radio from "./radio/widget";
|
|
7
7
|
|
|
8
|
+
import type {RenderProps, RadioChoiceWithMetadata} from "./radio/widget";
|
|
8
9
|
import type {PerseusRadioWidgetOptions} from "../perseus-types";
|
|
9
10
|
import type {WidgetExports} from "../types";
|
|
10
|
-
import type {RenderProps, RadioChoiceWithMetadata} from "./radio/widget";
|
|
11
11
|
|
|
12
12
|
const {shuffle, random} = Util;
|
|
13
13
|
|