@khanacademy/perseus 14.0.0 → 16.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/es/index.js +7 -13
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/index.js +6 -7
  5. package/dist/index.js.map +1 -1
  6. package/dist/multi-items/item-types.d.ts +1 -1
  7. package/dist/multi-items/multi-renderer.d.ts +2 -2
  8. package/dist/perseus-api.d.ts +0 -3
  9. package/dist/strings.js +1 -0
  10. package/dist/styles/shared.d.ts +1 -0
  11. package/dist/types.d.ts +0 -2
  12. package/dist/util/a11y.d.ts +1 -0
  13. package/dist/widgets/expression.d.ts +0 -12
  14. package/dist/widgets/graded-group.d.ts +1 -1
  15. package/dist/widgets/label-image.d.ts +1 -1
  16. package/dist/widgets/matcher.d.ts +0 -1
  17. package/dist/widgets/passage.d.ts +1 -1
  18. package/dist/widgets/radio/widget.d.ts +1 -1
  19. package/dist/widgets/simulator.d.ts +0 -1
  20. package/dist/widgets/sorter.d.ts +0 -1
  21. package/package.json +8 -8
  22. package/src/__tests__/server-item-renderer.test.tsx +1 -1
  23. package/src/components/svg-image.tsx +1 -1
  24. package/src/hints-renderer.tsx +1 -0
  25. package/src/multi-items/item-types.ts +1 -1
  26. package/src/multi-items/multi-renderer.tsx +4 -4
  27. package/src/perseus-api.tsx +0 -6
  28. package/src/server-item-renderer.tsx +1 -0
  29. package/src/types.ts +0 -5
  30. package/src/util.ts +1 -1
  31. package/src/widgets/__stories__/expression.stories.tsx +0 -1
  32. package/src/widgets/__tests__/expression-mobile.test.tsx +0 -1
  33. package/src/widgets/__tests__/expression.test.tsx +4 -15
  34. package/src/widgets/expression.tsx +1 -5
  35. package/src/widgets/graded-group.tsx +1 -1
  36. package/src/widgets/label-image/strings.ts +3 -1
  37. package/src/widgets/label-image.tsx +2 -2
  38. package/src/widgets/passage-ref.tsx +1 -1
  39. package/src/widgets/passage.tsx +1 -1
  40. package/src/widgets/radio/widget.tsx +1 -1
  41. package/src/widgets/radio.ts +1 -1
  42. package/tsconfig-build.tsbuildinfo +1 -1
@@ -8,8 +8,8 @@
8
8
  * interface, so it's compatible with our tree traversal functions.
9
9
  * - And the various types of nodes that compose a tree.
10
10
  */
11
- import type { WidgetDict, ImageDict } from "../types";
12
11
  import type { Tree, ArrayNode, ObjectNode } from "./tree-types";
12
+ import type { WidgetDict, ImageDict } from "../types";
13
13
  export type ContentNode = {
14
14
  __type: "content" | "item";
15
15
  content?: string | null | undefined;
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
2
  import Renderer from "../renderer";
3
- import type { Widget } from "../renderer";
4
- import type { APIOptions, FilterCriterion, PerseusDependenciesV2 } from "../types";
5
3
  import type { Item, ContentNode, HintNode, TagsNode } from "./item-types";
6
4
  import type { Shape, ArrayShape } from "./shape-types";
7
5
  import type { Tree } from "./tree-types";
8
6
  import type { TreeMapper, ContentMapper, HintMapper, Path } from "./trees";
7
+ import type { Widget } from "../renderer";
8
+ import type { APIOptions, FilterCriterion, PerseusDependenciesV2 } from "../types";
9
9
  import type { PropsFor } from "@khanacademy/wonder-blocks-core";
10
10
  type Hint = any;
11
11
  type Score = any;
@@ -53,7 +53,6 @@ export declare const ApiOptions: {
53
53
  customKeypad: PropTypes.Requireable<boolean>;
54
54
  nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>;
55
55
  isMobile: PropTypes.Requireable<boolean>;
56
- useV2Keypad: PropTypes.Requireable<boolean>;
57
56
  setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
58
57
  useDraftEditor: PropTypes.Requireable<boolean>;
59
58
  hintProgressColor: PropTypes.Requireable<string>;
@@ -85,7 +84,6 @@ export declare const ApiOptions: {
85
84
  correct?: boolean | undefined;
86
85
  } & Partial<import("./types").TrackingGradedGroupExtraArguments> & Partial<import("./types").TrackingSequenceExtraArguments>) => void) | undefined;
87
86
  customKeypad?: boolean | undefined;
88
- useV2Keypad?: boolean | undefined;
89
87
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
90
88
  isMobile?: boolean | undefined;
91
89
  setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
@@ -107,7 +105,6 @@ export declare const ApiOptions: {
107
105
  inModal: NonNullable<boolean | undefined>;
108
106
  isArticle: NonNullable<boolean | undefined>;
109
107
  isMobile: NonNullable<boolean | undefined>;
110
- useV2Keypad: NonNullable<boolean | undefined>;
111
108
  onFocusChange: (newFocusPath: import("./types").FocusPath, oldFocusPath: import("./types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown;
112
109
  onInputError: (widgetId: any, value: string, message?: string | null | undefined) => unknown;
113
110
  readOnly: NonNullable<boolean | undefined>;
package/dist/strings.js CHANGED
@@ -75,6 +75,7 @@ module.exports = [
75
75
  i18n._("Get another hint", {}),
76
76
  i18n._("Greater than or equal to sign", {}),
77
77
  i18n._("Greater than sign", {}),
78
+ i18n._("Hide answer choices", {}),
78
79
  i18n._("Hide explanation", {}),
79
80
  i18n._("Hint #%(pos)s", {}),
80
81
  i18n._("Hints", {}),
@@ -1,2 +1,3 @@
1
+ import type { StyleDeclaration } from "aphrodite";
1
2
  declare const _default: StyleDeclaration;
2
3
  export default _default;
package/dist/types.d.ts CHANGED
@@ -102,7 +102,6 @@ export type APIOptions = Readonly<{
102
102
  imagePreloader?: (dimensions: Dimensions) => React.ReactNode;
103
103
  trackInteraction?: (args: TrackInteractionArgs) => void;
104
104
  customKeypad?: boolean;
105
- useV2Keypad?: boolean;
106
105
  nativeKeypadProxy?: (blur: () => void) => KeypadAPI;
107
106
  isMobile?: boolean;
108
107
  setDrawingAreaAvailable?: (arg1: boolean) => unknown;
@@ -196,7 +195,6 @@ export type APIOptionsWithDefaults = Readonly<APIOptions & {
196
195
  inModal: NonNullable<APIOptions["inModal"]>;
197
196
  isArticle: NonNullable<APIOptions["isArticle"]>;
198
197
  isMobile: NonNullable<APIOptions["isMobile"]>;
199
- useV2Keypad: NonNullable<APIOptions["useV2Keypad"]>;
200
198
  onFocusChange: NonNullable<APIOptions["onFocusChange"]>;
201
199
  onInputError: NonNullable<APIOptions["onInputError"]>;
202
200
  readOnly: NonNullable<APIOptions["readOnly"]>;
@@ -1,2 +1,3 @@
1
+ import type { StyleDeclaration } from "aphrodite";
1
2
  declare const _default: StyleDeclaration;
2
3
  export default _default;
@@ -112,7 +112,6 @@ declare const _default: Readonly<{
112
112
  correct?: boolean | undefined;
113
113
  } & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<import("../types").TrackingSequenceExtraArguments>) => void) | undefined;
114
114
  customKeypad?: boolean | undefined;
115
- useV2Keypad?: boolean | undefined;
116
115
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
117
116
  isMobile?: boolean | undefined;
118
117
  setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
@@ -134,7 +133,6 @@ declare const _default: Readonly<{
134
133
  inModal: NonNullable<boolean | undefined>;
135
134
  isArticle: NonNullable<boolean | undefined>;
136
135
  isMobile: NonNullable<boolean | undefined>;
137
- useV2Keypad: NonNullable<boolean | undefined>;
138
136
  onFocusChange: (newFocusPath: import("../types").FocusPath, oldFocusPath: import("../types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown;
139
137
  onInputError: (widgetId: any, value: string, message?: string | null | undefined) => unknown;
140
138
  readOnly: NonNullable<boolean | undefined>;
@@ -177,7 +175,6 @@ declare const _default: Readonly<{
177
175
  correct?: boolean | undefined;
178
176
  } & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<import("../types").TrackingSequenceExtraArguments>) => void) | undefined;
179
177
  customKeypad?: boolean | undefined;
180
- useV2Keypad?: boolean | undefined;
181
178
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
182
179
  isMobile?: boolean | undefined;
183
180
  setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
@@ -199,7 +196,6 @@ declare const _default: Readonly<{
199
196
  inModal: NonNullable<boolean | undefined>;
200
197
  isArticle: NonNullable<boolean | undefined>;
201
198
  isMobile: NonNullable<boolean | undefined>;
202
- useV2Keypad: NonNullable<boolean | undefined>;
203
199
  onFocusChange: (newFocusPath: import("../types").FocusPath, oldFocusPath: import("../types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown;
204
200
  onInputError: (widgetId: any, value: string, message?: string | null | undefined) => unknown;
205
201
  readOnly: NonNullable<boolean | undefined>;
@@ -242,7 +238,6 @@ declare const _default: Readonly<{
242
238
  correct?: boolean | undefined;
243
239
  } & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<import("../types").TrackingSequenceExtraArguments>) => void) | undefined;
244
240
  customKeypad?: boolean | undefined;
245
- useV2Keypad?: boolean | undefined;
246
241
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
247
242
  isMobile?: boolean | undefined;
248
243
  setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
@@ -264,7 +259,6 @@ declare const _default: Readonly<{
264
259
  inModal: NonNullable<boolean | undefined>;
265
260
  isArticle: NonNullable<boolean | undefined>;
266
261
  isMobile: NonNullable<boolean | undefined>;
267
- useV2Keypad: NonNullable<boolean | undefined>;
268
262
  onFocusChange: (newFocusPath: import("../types").FocusPath, oldFocusPath: import("../types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown;
269
263
  onInputError: (widgetId: any, value: string, message?: string | null | undefined) => unknown;
270
264
  readOnly: NonNullable<boolean | undefined>;
@@ -318,7 +312,6 @@ declare const _default: Readonly<{
318
312
  correct?: boolean | undefined;
319
313
  } & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<import("../types").TrackingSequenceExtraArguments>) => void) | undefined;
320
314
  customKeypad?: boolean | undefined;
321
- useV2Keypad?: boolean | undefined;
322
315
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
323
316
  isMobile?: boolean | undefined;
324
317
  setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
@@ -340,7 +333,6 @@ declare const _default: Readonly<{
340
333
  inModal: NonNullable<boolean | undefined>;
341
334
  isArticle: NonNullable<boolean | undefined>;
342
335
  isMobile: NonNullable<boolean | undefined>;
343
- useV2Keypad: NonNullable<boolean | undefined>;
344
336
  onFocusChange: (newFocusPath: import("../types").FocusPath, oldFocusPath: import("../types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown;
345
337
  onInputError: (widgetId: any, value: string, message?: string | null | undefined) => unknown;
346
338
  readOnly: NonNullable<boolean | undefined>;
@@ -383,7 +375,6 @@ declare const _default: Readonly<{
383
375
  correct?: boolean | undefined;
384
376
  } & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<import("../types").TrackingSequenceExtraArguments>) => void) | undefined;
385
377
  customKeypad?: boolean | undefined;
386
- useV2Keypad?: boolean | undefined;
387
378
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
388
379
  isMobile?: boolean | undefined;
389
380
  setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
@@ -405,7 +396,6 @@ declare const _default: Readonly<{
405
396
  inModal: NonNullable<boolean | undefined>;
406
397
  isArticle: NonNullable<boolean | undefined>;
407
398
  isMobile: NonNullable<boolean | undefined>;
408
- useV2Keypad: NonNullable<boolean | undefined>;
409
399
  onFocusChange: (newFocusPath: import("../types").FocusPath, oldFocusPath: import("../types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown;
410
400
  onInputError: (widgetId: any, value: string, message?: string | null | undefined) => unknown;
411
401
  readOnly: NonNullable<boolean | undefined>;
@@ -448,7 +438,6 @@ declare const _default: Readonly<{
448
438
  correct?: boolean | undefined;
449
439
  } & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<import("../types").TrackingSequenceExtraArguments>) => void) | undefined;
450
440
  customKeypad?: boolean | undefined;
451
- useV2Keypad?: boolean | undefined;
452
441
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
453
442
  isMobile?: boolean | undefined;
454
443
  setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
@@ -470,7 +459,6 @@ declare const _default: Readonly<{
470
459
  inModal: NonNullable<boolean | undefined>;
471
460
  isArticle: NonNullable<boolean | undefined>;
472
461
  isMobile: NonNullable<boolean | undefined>;
473
- useV2Keypad: NonNullable<boolean | undefined>;
474
462
  onFocusChange: (newFocusPath: import("../types").FocusPath, oldFocusPath: import("../types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown;
475
463
  onInputError: (widgetId: any, value: string, message?: string | null | undefined) => unknown;
476
464
  readOnly: NonNullable<boolean | undefined>;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
+ import type { ANSWER_BAR_STATES } from "./graded-group-answer-bar";
2
3
  import type { PerseusGradedGroupWidgetOptions } from "../perseus-types";
3
4
  import type { TrackingGradedGroupExtraArguments, WidgetProps } from "../types";
4
- import type { ANSWER_BAR_STATES } from "./graded-group-answer-bar";
5
5
  declare const GRADING_STATUSES: {
6
6
  readonly ungraded: "ungraded";
7
7
  readonly correct: "correct";
@@ -9,9 +9,9 @@ import { Popover } from "@khanacademy/wonder-blocks-popover";
9
9
  import * as React from "react";
10
10
  import AnswerChoices from "./label-image/answer-choices";
11
11
  import Marker from "./label-image/marker";
12
+ import type { InteractiveMarkerType, InteractiveMarkerScore } from "./label-image/types";
12
13
  import type { ChangeableProps } from "../mixins/changeable";
13
14
  import type { APIOptions, PerseusScore } from "../types";
14
- import type { InteractiveMarkerType, InteractiveMarkerScore } from "./label-image/types";
15
15
  type MarkersState = {
16
16
  markers: ReadonlyArray<InteractiveMarkerType>;
17
17
  };
@@ -29,7 +29,6 @@ export declare class Matcher extends React.Component<any, any> {
29
29
  customKeypad: PropTypes.Requireable<boolean>;
30
30
  nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>;
31
31
  isMobile: PropTypes.Requireable<boolean>;
32
- useV2Keypad: PropTypes.Requireable<boolean>;
33
32
  setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
34
33
  useDraftEditor: PropTypes.Requireable<boolean>;
35
34
  hintProgressColor: PropTypes.Requireable<string>;
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
+ import type { ParseState } from "./passage/passage-markdown";
2
3
  import type { SerializedHighlightSet } from "../components/highlighting/types";
3
4
  import type { ChangeableProps } from "../mixins/changeable";
4
5
  import type { PerseusPassageWidgetOptions } from "../perseus-types";
5
6
  import type { PerseusScore, WidgetInfo, WidgetProps } from "../types";
6
- import type { ParseState } from "./passage/passage-markdown";
7
7
  import type { SingleASTNode } from "@khanacademy/simple-markdown";
8
8
  export declare class LineHeightMeasurer extends React.Component<Record<any, any>> {
9
9
  _line: HTMLDivElement | null | undefined;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
+ import type { FocusFunction } from "./base-radio";
2
3
  import type { PerseusRadioChoice, PerseusRadioWidgetOptions } from "../../perseus-types";
3
4
  import type { PerseusScore, WidgetProps, ChoiceState } from "../../types";
4
- import type { FocusFunction } from "./base-radio";
5
5
  export type RenderProps = {
6
6
  numCorrect: number;
7
7
  hasNoneOfTheAbove?: boolean;
@@ -24,7 +24,6 @@ declare class Simulator extends React.Component<any, any> {
24
24
  customKeypad: PropTypes.Requireable<boolean>;
25
25
  nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>;
26
26
  isMobile: PropTypes.Requireable<boolean>;
27
- useV2Keypad: PropTypes.Requireable<boolean>;
28
27
  setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
29
28
  useDraftEditor: PropTypes.Requireable<boolean>;
30
29
  hintProgressColor: PropTypes.Requireable<string>;
@@ -25,7 +25,6 @@ declare class Sorter extends React.Component<any, any> {
25
25
  customKeypad: PropTypes.Requireable<boolean>;
26
26
  nativeKeypadProxy: PropTypes.Requireable<(...args: any[]) => any>;
27
27
  isMobile: PropTypes.Requireable<boolean>;
28
- useV2Keypad: PropTypes.Requireable<boolean>;
29
28
  setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
30
29
  useDraftEditor: PropTypes.Requireable<boolean>;
31
30
  hintProgressColor: PropTypes.Requireable<string>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "14.0.0",
6
+ "version": "16.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -22,13 +22,13 @@
22
22
  "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
23
23
  },
24
24
  "dependencies": {
25
- "@khanacademy/kas": "^0.3.5",
26
- "@khanacademy/kmath": "^0.1.6",
27
- "@khanacademy/math-input": "^16.0.0",
28
- "@khanacademy/perseus-core": "1.3.0",
29
- "@khanacademy/perseus-linter": "^0.3.8",
30
- "@khanacademy/pure-markdown": "^0.2.11",
31
- "@khanacademy/simple-markdown": "^0.11.0"
25
+ "@khanacademy/kas": "^0.3.6",
26
+ "@khanacademy/kmath": "^0.1.7",
27
+ "@khanacademy/math-input": "^16.1.0",
28
+ "@khanacademy/perseus-core": "1.4.0",
29
+ "@khanacademy/perseus-linter": "^0.3.9",
30
+ "@khanacademy/pure-markdown": "^0.2.12",
31
+ "@khanacademy/simple-markdown": "^0.11.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@khanacademy/wonder-blocks-button": "^6.2.2",
@@ -25,9 +25,9 @@ import MockAssetLoadingWidgetExport, {
25
25
  } from "./mock-asset-loading-widget";
26
26
  import MockWidgetExport from "./mock-widget";
27
27
 
28
+ import type {MockAssetLoadingWidget} from "./mock-asset-loading-widget";
28
29
  import type {PerseusItem} from "../perseus-types";
29
30
  import type {APIOptions} from "../types";
30
- import type {MockAssetLoadingWidget} from "./mock-asset-loading-widget";
31
31
  import type {KeypadAPI} from "@khanacademy/math-input";
32
32
  import type {PropsFor} from "@khanacademy/wonder-blocks-core";
33
33
 
@@ -16,10 +16,10 @@ import FixedToResponsive from "./fixed-to-responsive";
16
16
  import Graphie from "./graphie";
17
17
  import ImageLoader from "./image-loader";
18
18
 
19
+ import type {ImageProps} from "./image-loader";
19
20
  import type {Coord} from "../interactive2/types";
20
21
  import type {Size} from "../perseus-types";
21
22
  import type {Alignment, Dimensions} from "../types";
22
- import type {ImageProps} from "./image-loader";
23
23
 
24
24
  // Minimum image width to make an image appear as zoomable.
25
25
  const ZOOMABLE_THRESHOLD = 700;
@@ -59,6 +59,7 @@ class HintsRenderer extends React.Component<Props, State> {
59
59
  this._cacheHintImages();
60
60
  }
61
61
 
62
+ // eslint-disable-next-line react/no-unsafe
62
63
  UNSAFE_componentWillReceiveProps(nextProps: Props) {
63
64
  // @ts-expect-error - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
64
65
  if (nextProps.hintsVisible - this.props.hintsVisible > 1) {
@@ -8,8 +8,8 @@
8
8
  * interface, so it's compatible with our tree traversal functions.
9
9
  * - And the various types of nodes that compose a tree.
10
10
  */
11
- import type {WidgetDict, ImageDict} from "../types";
12
11
  import type {Tree, ArrayNode, ObjectNode} from "./tree-types";
12
+ import type {WidgetDict, ImageDict} from "../types";
13
13
 
14
14
  export type ContentNode = {
15
15
  // TODO(mdr): When we first drafted the multi-item feature, we named
@@ -50,6 +50,10 @@ import Util from "../util";
50
50
  import {itemToTree} from "./items";
51
51
  import {buildMapper} from "./trees";
52
52
 
53
+ import type {Item, ContentNode, HintNode, TagsNode} from "./item-types";
54
+ import type {Shape, ArrayShape} from "./shape-types";
55
+ import type {Tree} from "./tree-types";
56
+ import type {TreeMapper, ContentMapper, HintMapper, Path} from "./trees";
53
57
  import type {Widget} from "../renderer";
54
58
  import type {
55
59
  APIOptions,
@@ -57,10 +61,6 @@ import type {
57
61
  PerseusDependenciesV2,
58
62
  PerseusScore,
59
63
  } from "../types";
60
- import type {Item, ContentNode, HintNode, TagsNode} from "./item-types";
61
- import type {Shape, ArrayShape} from "./shape-types";
62
- import type {Tree} from "./tree-types";
63
- import type {TreeMapper, ContentMapper, HintMapper, Path} from "./trees";
64
64
  import type {PropsFor} from "@khanacademy/wonder-blocks-core";
65
65
 
66
66
  type Hint = any; // TODO(mdr)
@@ -100,11 +100,6 @@ export const ApiOptions = {
100
100
  // Indicates whether or not to use mobile styling.
101
101
  isMobile: PropTypes.bool,
102
102
 
103
- // Whether to use v1 (Legacy) Keypad for MathInput mobile or
104
- // use the new v2 Keypad
105
- // TODO [LC-1088]: remove after v2 release
106
- useV2Keypad: PropTypes.bool,
107
-
108
103
  // A function, called with a bool indicating whether use of the
109
104
  // drawing area (scratchpad) should be allowed/disallowed.
110
105
  // Previously handled by `Khan.scratchpad.enable/disable`
@@ -150,7 +145,6 @@ export const ApiOptions = {
150
145
  defaults: {
151
146
  isArticle: false,
152
147
  isMobile: false,
153
- useV2Keypad: false,
154
148
  onInputError: function () {},
155
149
  onFocusChange: function () {},
156
150
  GroupMetadataEditor: StubTagEditor,
@@ -104,6 +104,7 @@ export class ServerItemRenderer
104
104
  this._fullyRendered = false;
105
105
  }
106
106
 
107
+ // eslint-disable-next-line react/no-unsafe
107
108
  UNSAFE_componentWillReceiveProps(nextProps: Props) {
108
109
  this.setState({
109
110
  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";
@@ -46,7 +46,6 @@ const WrappedKeypadContext = ({
46
46
  apiOptions={{
47
47
  isMobile: isMobile,
48
48
  customKeypad: customKeypad,
49
- useV2Keypad: true,
50
49
  }}
51
50
  />
52
51
  );
@@ -37,7 +37,6 @@ function RendererWithContext({item}) {
37
37
  apiOptions={{
38
38
  isMobile: true,
39
39
  customKeypad: true,
40
- useV2Keypad: true,
41
40
  }}
42
41
  item={item}
43
42
  problemNum={0}
@@ -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: "PERSEUS_MATH_INPUT",
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: "PERSEUS_MATH_INPUT",
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 set the virtual keypad version to MATH_INPUT_KEYPAD_V1 when customKeypad is set and useV2Keypad is unset", () => {
228
- assertKeypadVersion({customKeypad: true}, "MATH_INPUT_KEYPAD_V1");
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
- : apiOptions.customKeypad === true
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,
@@ -1,3 +1,5 @@
1
+ import * as i18n from "@khanacademy/wonder-blocks-i18n";
2
+
1
3
  export const strings = {
2
- hideAnswersToggleLabel: "Hide answer choices",
4
+ hideAnswersToggleLabel: i18n._("Hide answer choices"),
3
5
  };
@@ -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";
@@ -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 = {
@@ -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