@khanacademy/perseus 9.0.0 → 10.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 +12 -0
- package/dist/components/info-tip.d.ts +2 -1
- package/dist/components/input-with-examples.d.ts +1 -1
- package/dist/components/sortable.d.ts +1 -1
- package/dist/es/index.css +3 -5
- package/dist/es/index.js +6 -16
- package/dist/es/index.js.map +1 -1
- package/dist/hint-renderer.d.ts +2 -1
- package/dist/hints-renderer.d.ts +2 -1
- package/dist/index.css +3 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -17
- package/dist/index.js.map +1 -1
- package/dist/item-renderer.d.ts +2 -1
- package/dist/multi-items/multi-renderer.d.ts +2 -1
- package/dist/renderer.d.ts +3 -8
- package/dist/types.d.ts +1 -6
- package/dist/widget-container.d.ts +2 -1
- package/dist/widgets/expression.d.ts +8 -8
- package/dist/widgets/grapher.d.ts +2 -1
- package/dist/widgets/passage-ref.d.ts +2 -1
- package/package.json +2 -2
- package/src/__tests__/renderer.test.tsx +0 -2
- package/src/__tests__/server-item-renderer.test.tsx +2 -4
- package/src/components/info-tip.tsx +3 -4
- package/src/components/input-with-examples.tsx +1 -1
- package/src/components/sortable.tsx +1 -1
- package/src/hint-renderer.tsx +2 -1
- package/src/hints-renderer.tsx +2 -9
- package/src/index.ts +0 -1
- package/src/item-renderer.tsx +2 -7
- package/src/multi-items/multi-renderer.tsx +2 -7
- package/src/renderer.tsx +3 -3
- package/src/server-item-renderer.tsx +0 -1
- package/src/types.ts +1 -8
- package/src/widget-container.tsx +2 -1
- package/src/widgets/__tests__/renderQuestion.tsx +3 -11
- package/src/widgets/expression.tsx +2 -7
- package/src/widgets/grapher.tsx +4 -12
- package/src/widgets/passage-ref.tsx +1 -1
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/item-renderer.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import HintsRenderer from "./hints-renderer";
|
|
|
3
3
|
import Renderer from "./renderer";
|
|
4
4
|
import type { KeypadProps } from "./mixins/provide-keypad";
|
|
5
5
|
import type { PerseusItem } from "./perseus-types";
|
|
6
|
-
import type { APIOptions, FocusPath,
|
|
6
|
+
import type { APIOptions, FocusPath, PerseusDependenciesV2 } from "./types";
|
|
7
7
|
import type { KEScore } from "@khanacademy/perseus-core";
|
|
8
|
+
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
8
9
|
type Props = // These props are used by the ProvideKeypad mixin.
|
|
9
10
|
KeypadProps & {
|
|
10
11
|
apiOptions: APIOptions;
|
|
@@ -6,10 +6,11 @@ import type { Item, ContentNode, HintNode, TagsNode } from "./item-types";
|
|
|
6
6
|
import type { Shape, ArrayShape } from "./shape-types";
|
|
7
7
|
import type { Tree } from "./tree-types";
|
|
8
8
|
import type { TreeMapper, ContentMapper, HintMapper, Path } from "./trees";
|
|
9
|
+
import type { PropsFor } from "@khanacademy/wonder-blocks-core";
|
|
9
10
|
type Hint = any;
|
|
10
11
|
type Score = any;
|
|
11
12
|
type SerializedState = any;
|
|
12
|
-
type RendererProps =
|
|
13
|
+
type RendererProps = PropsFor<typeof Renderer>;
|
|
13
14
|
type ContentRendererElement = React.ReactElement<any>;
|
|
14
15
|
type HintRendererElement = React.ReactElement<any>;
|
|
15
16
|
type ContentRendererData = {
|
package/dist/renderer.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import * as React from "react";
|
|
|
2
2
|
import InteractionTracker from "./interaction-tracker";
|
|
3
3
|
import TranslationLinter from "./translation-linter";
|
|
4
4
|
import type { PerseusRenderer, PerseusWidgetOptions } from "./perseus-types";
|
|
5
|
-
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath,
|
|
5
|
+
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, PerseusScore, WidgetInfo, WidgetProps } from "./types";
|
|
6
|
+
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
6
7
|
import "./styles/perseus-renderer.less";
|
|
7
8
|
type WidgetState = {
|
|
8
9
|
isMobile?: boolean;
|
|
@@ -68,12 +69,6 @@ type State = {
|
|
|
68
69
|
jiptContent: any;
|
|
69
70
|
lastUsedWidgetId: string | null | undefined;
|
|
70
71
|
};
|
|
71
|
-
type Context = LinterContextProps & {
|
|
72
|
-
content: string;
|
|
73
|
-
widgets: {
|
|
74
|
-
[id: string]: any;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
72
|
type DefaultProps = {
|
|
78
73
|
alwaysUpdate: Props["alwaysUpdate"];
|
|
79
74
|
content: Props["content"];
|
|
@@ -103,7 +98,7 @@ declare class Renderer extends React.Component<Props, State> {
|
|
|
103
98
|
translationIndex: number;
|
|
104
99
|
widgetIds: Array<string>;
|
|
105
100
|
static defaultProps: DefaultProps;
|
|
106
|
-
constructor(props: Props
|
|
101
|
+
constructor(props: Props);
|
|
107
102
|
componentDidMount(): void;
|
|
108
103
|
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
109
104
|
shouldComponentUpdate(nextProps: Props, nextState: State): any | boolean;
|
package/dist/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { PerseusWidget } from "./perseus-types";
|
|
|
5
5
|
import type { SizeClass } from "./util/sizing-utils";
|
|
6
6
|
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
7
7
|
import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
|
|
8
|
+
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
8
9
|
import type { Result } from "@khanacademy/wonder-blocks-data";
|
|
9
10
|
import type * as React from "react";
|
|
10
11
|
export type FocusPath = ReadonlyArray<string> | null | undefined;
|
|
@@ -202,12 +203,6 @@ export type APIOptionsWithDefaults = Readonly<APIOptions & {
|
|
|
202
203
|
showAlignmentOptions: NonNullable<APIOptions["showAlignmentOptions"]>;
|
|
203
204
|
useDraftEditor: NonNullable<APIOptions["useDraftEditor"]>;
|
|
204
205
|
}>;
|
|
205
|
-
export type LinterContextProps = {
|
|
206
|
-
contentType: string;
|
|
207
|
-
highlightLint: boolean;
|
|
208
|
-
paths: ReadonlyArray<string>;
|
|
209
|
-
stack: ReadonlyArray<string>;
|
|
210
|
-
};
|
|
211
206
|
export type Tracking = "" | "all";
|
|
212
207
|
export type TrackingGradedGroupExtraArguments = {
|
|
213
208
|
status: "correct" | "incorrect" | "invalid";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { PerseusWidgetOptions } from "./perseus-types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { WidgetProps } from "./types";
|
|
4
|
+
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
4
5
|
type Props = {
|
|
5
6
|
shouldHighlight: boolean;
|
|
6
7
|
type: string;
|
|
@@ -153,7 +153,7 @@ declare const _default: Readonly<{
|
|
|
153
153
|
onChange: import("../types").ChangeHandler;
|
|
154
154
|
trackInteraction: (extraData?: {} | undefined) => void;
|
|
155
155
|
isLastUsedWidget: boolean;
|
|
156
|
-
linterContext: import("
|
|
156
|
+
linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
|
|
157
157
|
containerSizeClass: import("../util/sizing-utils").SizeClass;
|
|
158
158
|
} & import("../types").PerseusDependenciesV2 & {
|
|
159
159
|
apiOptions: Readonly<Readonly<{
|
|
@@ -211,16 +211,16 @@ declare const _default: Readonly<{
|
|
|
211
211
|
}>;
|
|
212
212
|
buttonSets: readonly string[];
|
|
213
213
|
functions: readonly string[];
|
|
214
|
-
linterContext: import("
|
|
214
|
+
linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
|
|
215
215
|
onBlur: (blurPath: import("../types").FocusPath) => void;
|
|
216
216
|
onFocus: (blurPath: import("../types").FocusPath) => void;
|
|
217
217
|
times: boolean;
|
|
218
218
|
value: string;
|
|
219
|
-
}, "static" | "trackInteraction" | "onChange" | "problemNum" | "questionCompleted" | "keypadElement" | "alignment" | "
|
|
219
|
+
}, "static" | "trackInteraction" | "onChange" | "problemNum" | "questionCompleted" | "keypadElement" | "alignment" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "findWidgets" | "keypadConfiguration" | "reviewModeRubric" | "isLastUsedWidget" | "analytics"> & {
|
|
220
220
|
value?: string | undefined;
|
|
221
221
|
onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
222
222
|
onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
223
|
-
linterContext?: import("
|
|
223
|
+
linterContext?: import("@khanacademy/perseus-linter").LinterContextProps | undefined;
|
|
224
224
|
apiOptions?: Readonly<Readonly<{
|
|
225
225
|
isArticle?: boolean | undefined;
|
|
226
226
|
onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
|
|
@@ -359,7 +359,7 @@ declare const _default: Readonly<{
|
|
|
359
359
|
onChange: import("../types").ChangeHandler;
|
|
360
360
|
trackInteraction: (extraData?: {} | undefined) => void;
|
|
361
361
|
isLastUsedWidget: boolean;
|
|
362
|
-
linterContext: import("
|
|
362
|
+
linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
|
|
363
363
|
containerSizeClass: import("../util/sizing-utils").SizeClass;
|
|
364
364
|
} & import("../types").PerseusDependenciesV2 & {
|
|
365
365
|
apiOptions: Readonly<Readonly<{
|
|
@@ -417,16 +417,16 @@ declare const _default: Readonly<{
|
|
|
417
417
|
}>;
|
|
418
418
|
buttonSets: readonly string[];
|
|
419
419
|
functions: readonly string[];
|
|
420
|
-
linterContext: import("
|
|
420
|
+
linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
|
|
421
421
|
onBlur: (blurPath: import("../types").FocusPath) => void;
|
|
422
422
|
onFocus: (blurPath: import("../types").FocusPath) => void;
|
|
423
423
|
times: boolean;
|
|
424
424
|
value: string;
|
|
425
|
-
}, "static" | "trackInteraction" | "onChange" | "problemNum" | "questionCompleted" | "keypadElement" | "alignment" | "
|
|
425
|
+
}, "static" | "trackInteraction" | "onChange" | "problemNum" | "questionCompleted" | "keypadElement" | "alignment" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "findWidgets" | "keypadConfiguration" | "reviewModeRubric" | "isLastUsedWidget" | "analytics"> & {
|
|
426
426
|
value?: string | undefined;
|
|
427
427
|
onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
428
428
|
onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
429
|
-
linterContext?: import("
|
|
429
|
+
linterContext?: import("@khanacademy/perseus-linter").LinterContextProps | undefined;
|
|
430
430
|
apiOptions?: Readonly<Readonly<{
|
|
431
431
|
isArticle?: boolean | undefined;
|
|
432
432
|
onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
|
|
@@ -4,6 +4,7 @@ import type { Coord } from "../interactive2/types";
|
|
|
4
4
|
import type { PerseusGrapherWidgetOptions } from "../perseus-types";
|
|
5
5
|
import type { PerseusScore, WidgetProps } from "../types";
|
|
6
6
|
import type { GridDimensions } from "../util";
|
|
7
|
+
import type { PropsFor } from "@khanacademy/wonder-blocks-core";
|
|
7
8
|
type UserInput = any;
|
|
8
9
|
type RenderProps = {
|
|
9
10
|
availableTypes: PerseusGrapherWidgetOptions["availableTypes"];
|
|
@@ -30,7 +31,7 @@ declare class Grapher extends React.Component<Props> {
|
|
|
30
31
|
box: NonNullable<Props["graph"]["box"]>;
|
|
31
32
|
gridStep: NonNullable<Props["graph"]["gridStep"]>;
|
|
32
33
|
}): ReadonlyArray<GridDimensions>;
|
|
33
|
-
_calculateMobileTickStep(gridStep:
|
|
34
|
+
_calculateMobileTickStep(gridStep: NonNullable<PropsFor<typeof Graphie>["gridStep"]>, step: NonNullable<PropsFor<typeof Graphie>["step"]>, ranges: NonNullable<PropsFor<typeof Graphie>["ranges"]>): any;
|
|
34
35
|
_setupGraphie: (arg1: any, arg2: any) => void;
|
|
35
36
|
showHairlines: (arg1: Coord) => void;
|
|
36
37
|
hideHairlines: () => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { PerseusPassageRefWidgetOptions } from "../perseus-types";
|
|
3
|
-
import type { ChangeFn, PerseusScore, WidgetProps
|
|
3
|
+
import type { ChangeFn, PerseusScore, WidgetProps } from "../types";
|
|
4
|
+
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
4
5
|
type UserInput = RenderProps & {
|
|
5
6
|
static: boolean | null | undefined;
|
|
6
7
|
reviewModeRubric: Rubric;
|
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": "
|
|
6
|
+
"version": "10.0.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@khanacademy/kas": "^0.3.1",
|
|
25
25
|
"@khanacademy/kmath": "^0.1.2",
|
|
26
|
-
"@khanacademy/math-input": "^10.0.
|
|
26
|
+
"@khanacademy/math-input": "^10.0.1",
|
|
27
27
|
"@khanacademy/perseus-core": "0.2.0",
|
|
28
28
|
"@khanacademy/perseus-linter": "^0.3.2",
|
|
29
29
|
"@khanacademy/pure-markdown": "^0.2.4",
|
|
@@ -149,7 +149,6 @@ describe("renderer", () => {
|
|
|
149
149
|
mockRunLinter.mockClear();
|
|
150
150
|
|
|
151
151
|
// Act
|
|
152
|
-
// @ts-expect-error - TS2345 - Argument of type '{ problemNum: number; linterContext: { readonly contentType: "exercise"; readonly highlightLint: true; readonly paths: readonly []; readonly stack: readonly []; }; }' is not assignable to parameter of type 'Pick<{}, never> & InexactPartial<Pick<{}, never>> & InexactPartial<Pick<DefaultProps, keyof DefaultProps>>'.
|
|
153
152
|
rerender(question1, {...extraProps, problemNum: 1});
|
|
154
153
|
|
|
155
154
|
// Assert
|
|
@@ -1334,7 +1333,6 @@ describe("renderer", () => {
|
|
|
1334
1333
|
},
|
|
1335
1334
|
},
|
|
1336
1335
|
{},
|
|
1337
|
-
// @ts-expect-error - TS2345 - Argument of type '{ problemNum: number; }' is not assignable to parameter of type 'Pick<{}, never> & InexactPartial<Pick<{}, never>> & InexactPartial<Pick<DefaultProps, keyof DefaultProps>>'.
|
|
1338
1336
|
{problemNum: 1},
|
|
1339
1337
|
);
|
|
1340
1338
|
|
|
@@ -28,6 +28,7 @@ import MockWidgetExport from "./mock-widget";
|
|
|
28
28
|
import type {PerseusItem} from "../perseus-types";
|
|
29
29
|
import type {APIOptions} from "../types";
|
|
30
30
|
import type {MockAssetLoadingWidget} from "./mock-asset-loading-widget";
|
|
31
|
+
import type {PropsFor} from "@khanacademy/wonder-blocks-core";
|
|
31
32
|
|
|
32
33
|
// This looks alot like `widgets/__tests__/renderQuestion.jsx', except we use
|
|
33
34
|
// the ServerItemRenderer instead of Renderer
|
|
@@ -35,10 +36,7 @@ const renderQuestion = (
|
|
|
35
36
|
question: PerseusItem,
|
|
36
37
|
apiOptions: APIOptions = Object.freeze({}),
|
|
37
38
|
optionalProps: Partial<
|
|
38
|
-
|
|
39
|
-
typeof WrappedServerItemRenderer,
|
|
40
|
-
React.ComponentProps<typeof WrappedServerItemRenderer>
|
|
41
|
-
>
|
|
39
|
+
PropsFor<typeof WrappedServerItemRenderer>
|
|
42
40
|
> = Object.freeze({}),
|
|
43
41
|
): {
|
|
44
42
|
container: HTMLElement;
|
|
@@ -9,10 +9,9 @@ import * as React from "react";
|
|
|
9
9
|
|
|
10
10
|
import ReactComponentsInfoTip from "./info-tip/info-tip";
|
|
11
11
|
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
>;
|
|
12
|
+
import type {PropsFor} from "@khanacademy/wonder-blocks-core";
|
|
13
|
+
|
|
14
|
+
type Props = PropsFor<typeof ReactComponentsInfoTip>;
|
|
16
15
|
|
|
17
16
|
type State = {
|
|
18
17
|
didMount: boolean;
|
|
@@ -12,7 +12,7 @@ import MathOutput from "./math-output";
|
|
|
12
12
|
import TextInput from "./text-input";
|
|
13
13
|
import Tooltip, {HorizontalDirection, VerticalDirection} from "./tooltip";
|
|
14
14
|
|
|
15
|
-
import type {LinterContextProps} from "
|
|
15
|
+
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
16
16
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
17
17
|
|
|
18
18
|
const {captureScratchpadTouchStart} = Util;
|
|
@@ -13,8 +13,8 @@ import {ClassNames as ApiClassNames} from "../perseus-api";
|
|
|
13
13
|
import Renderer from "../renderer";
|
|
14
14
|
import Util from "../util";
|
|
15
15
|
|
|
16
|
-
import type {LinterContextProps} from "../types";
|
|
17
16
|
import type {Position} from "../util";
|
|
17
|
+
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
18
18
|
|
|
19
19
|
export enum Layout {
|
|
20
20
|
HORIZONTAL = "horizontal",
|
package/src/hint-renderer.tsx
CHANGED
|
@@ -8,7 +8,8 @@ import Renderer from "./renderer";
|
|
|
8
8
|
import {baseUnitPx, hintBorderWidth, kaGreen, gray97} from "./styles/constants";
|
|
9
9
|
import mediaQueries from "./styles/media-queries";
|
|
10
10
|
|
|
11
|
-
import type {APIOptions
|
|
11
|
+
import type {APIOptions} from "./types";
|
|
12
|
+
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
12
13
|
|
|
13
14
|
type Props = {
|
|
14
15
|
apiOptions: APIOptions;
|
package/src/hints-renderer.tsx
CHANGED
|
@@ -22,12 +22,9 @@ import Util from "./util";
|
|
|
22
22
|
|
|
23
23
|
import type Renderer from "./renderer";
|
|
24
24
|
import type {APIOptionsWithDefaults} from "./types";
|
|
25
|
+
import type {PropsFor} from "@khanacademy/wonder-blocks-core";
|
|
25
26
|
|
|
26
|
-
type Props =
|
|
27
|
-
Renderer,
|
|
28
|
-
// @ts-expect-error - TS2344 - Type 'Renderer' does not satisfy the constraint 'keyof IntrinsicElements | JSXElementConstructor<any>'.
|
|
29
|
-
React.ComponentProps<typeof Renderer>
|
|
30
|
-
> & {
|
|
27
|
+
type Props = PropsFor<typeof Renderer> & {
|
|
31
28
|
className?: string;
|
|
32
29
|
// note (mcurtis): I think this should be $ReadOnlyArray<PerseusRenderer>,
|
|
33
30
|
// but things spiraled out of control when I tried to change it
|
|
@@ -36,7 +33,6 @@ type Props = JSX.LibraryManagedAttributes<
|
|
|
36
33
|
};
|
|
37
34
|
|
|
38
35
|
type DefaultProps = {
|
|
39
|
-
// @ts-expect-error - TS2339 - Property 'linterContext' does not exist on type '{ className?: string | undefined; hints: readonly any[]; hintsVisible?: number | undefined; }'.
|
|
40
36
|
linterContext: Props["linterContext"];
|
|
41
37
|
};
|
|
42
38
|
|
|
@@ -126,7 +122,6 @@ class HintsRenderer extends React.Component<Props, State> {
|
|
|
126
122
|
// false in hints.
|
|
127
123
|
return {
|
|
128
124
|
...ApiOptions.defaults,
|
|
129
|
-
// @ts-expect-error - TS2339 - Property 'apiOptions' does not exist on type 'Readonly<{ className?: string | undefined; hints: readonly any[]; hintsVisible?: number | undefined; }> & Readonly<{ children?: ReactNode; }>'.
|
|
130
125
|
...this.props.apiOptions,
|
|
131
126
|
readOnly: false,
|
|
132
127
|
};
|
|
@@ -196,10 +191,8 @@ class HintsRenderer extends React.Component<Props, State> {
|
|
|
196
191
|
ref={"hintRenderer" + i}
|
|
197
192
|
key={"hintRenderer" + i}
|
|
198
193
|
apiOptions={apiOptions}
|
|
199
|
-
// @ts-expect-error - TS2339 - Property 'findExternalWidgets' does not exist on type 'Readonly<{ className?: string | undefined; hints: readonly any[]; hintsVisible?: number | undefined; }> & Readonly<{ children?: ReactNode; }>'.
|
|
200
194
|
findExternalWidgets={this.props.findExternalWidgets}
|
|
201
195
|
linterContext={PerseusLinter.pushContextStack(
|
|
202
|
-
// @ts-expect-error - TS2339 - Property 'linterContext' does not exist on type 'Readonly<{ className?: string | undefined; hints: readonly any[]; hintsVisible?: number | undefined; }> & Readonly<{ children?: ReactNode; }>'.
|
|
203
196
|
this.props.linterContext,
|
|
204
197
|
"hints[" + i + "]",
|
|
205
198
|
)}
|
package/src/index.ts
CHANGED
package/src/item-renderer.tsx
CHANGED
|
@@ -17,13 +17,9 @@ import reactRender from "./util/react-render";
|
|
|
17
17
|
|
|
18
18
|
import type {KeypadProps} from "./mixins/provide-keypad";
|
|
19
19
|
import type {PerseusItem} from "./perseus-types";
|
|
20
|
-
import type {
|
|
21
|
-
APIOptions,
|
|
22
|
-
FocusPath,
|
|
23
|
-
LinterContextProps,
|
|
24
|
-
PerseusDependenciesV2,
|
|
25
|
-
} from "./types";
|
|
20
|
+
import type {APIOptions, FocusPath, PerseusDependenciesV2} from "./types";
|
|
26
21
|
import type {KEScore} from "@khanacademy/perseus-core";
|
|
22
|
+
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
27
23
|
|
|
28
24
|
const {mapObject} = Objective;
|
|
29
25
|
|
|
@@ -228,7 +224,6 @@ class ItemRenderer extends React.Component<Props, State> {
|
|
|
228
224
|
ref={(node) => (this.hintsRenderer = node)}
|
|
229
225
|
hints={this.props.item.hints}
|
|
230
226
|
hintsVisible={this.state.hintsVisible}
|
|
231
|
-
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
232
227
|
apiOptions={apiOptions}
|
|
233
228
|
linterContext={PerseusLinter.pushContextStack(
|
|
234
229
|
this.props.linterContext,
|
|
@@ -61,16 +61,13 @@ import type {Item, ContentNode, HintNode, TagsNode} from "./item-types";
|
|
|
61
61
|
import type {Shape, ArrayShape} from "./shape-types";
|
|
62
62
|
import type {Tree} from "./tree-types";
|
|
63
63
|
import type {TreeMapper, ContentMapper, HintMapper, Path} from "./trees";
|
|
64
|
+
import type {PropsFor} from "@khanacademy/wonder-blocks-core";
|
|
64
65
|
|
|
65
66
|
type Hint = any; // TODO(mdr)
|
|
66
67
|
type Score = any; // TODO(mdr)
|
|
67
68
|
type SerializedState = any; // TODO(mdr)
|
|
68
69
|
|
|
69
|
-
type RendererProps =
|
|
70
|
-
typeof Renderer,
|
|
71
|
-
// @ts-expect-error - TS2344 - Type 'typeof Renderer' does not satisfy the constraint 'keyof IntrinsicElements | JSXElementConstructor<any>'.
|
|
72
|
-
React.ComponentProps<typeof Renderer>
|
|
73
|
-
>;
|
|
70
|
+
type RendererProps = PropsFor<typeof Renderer>;
|
|
74
71
|
|
|
75
72
|
type ContentRendererElement = React.ReactElement<any>;
|
|
76
73
|
type HintRendererElement = React.ReactElement<any>;
|
|
@@ -314,7 +311,6 @@ class MultiRenderer extends React.Component<Props, State> {
|
|
|
314
311
|
makeRenderer: () => (
|
|
315
312
|
<HintsRenderer
|
|
316
313
|
{...this._getRendererProps()}
|
|
317
|
-
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
318
314
|
findExternalWidgets={findExternalWidgets}
|
|
319
315
|
hints={[hint]}
|
|
320
316
|
/>
|
|
@@ -514,7 +510,6 @@ class MultiRenderer extends React.Component<Props, State> {
|
|
|
514
510
|
(renderers as any).firstN = (n: any) => (
|
|
515
511
|
<HintsRenderer
|
|
516
512
|
{...this._getRendererProps()}
|
|
517
|
-
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
518
513
|
findExternalWidgets={
|
|
519
514
|
hintRendererDatas[0]
|
|
520
515
|
? hintRendererDatas[0].findExternalWidgets
|
package/src/renderer.tsx
CHANGED
|
@@ -35,11 +35,11 @@ import type {
|
|
|
35
35
|
APIOptionsWithDefaults,
|
|
36
36
|
FilterCriterion,
|
|
37
37
|
FocusPath,
|
|
38
|
-
LinterContextProps,
|
|
39
38
|
PerseusScore,
|
|
40
39
|
WidgetInfo,
|
|
41
40
|
WidgetProps,
|
|
42
41
|
} from "./types";
|
|
42
|
+
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
43
43
|
|
|
44
44
|
import "./styles/perseus-renderer.less";
|
|
45
45
|
|
|
@@ -250,8 +250,8 @@ class Renderer extends React.Component<Props, State> {
|
|
|
250
250
|
linterContext: PerseusLinter.linterContextDefault,
|
|
251
251
|
};
|
|
252
252
|
|
|
253
|
-
constructor(props: Props
|
|
254
|
-
super(props
|
|
253
|
+
constructor(props: Props) {
|
|
254
|
+
super(props);
|
|
255
255
|
this._translationLinter = new TranslationLinter();
|
|
256
256
|
|
|
257
257
|
this.state = {
|
|
@@ -421,7 +421,6 @@ export class ServerItemRenderer
|
|
|
421
421
|
<HintsRenderer
|
|
422
422
|
hints={this.props.item.hints}
|
|
423
423
|
hintsVisible={this.props.hintsVisible}
|
|
424
|
-
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
425
424
|
apiOptions={apiOptions}
|
|
426
425
|
ref={(elem) => (this.hintsRenderer = elem)}
|
|
427
426
|
/>
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {PerseusWidget} from "./perseus-types";
|
|
|
5
5
|
import type {SizeClass} from "./util/sizing-utils";
|
|
6
6
|
import type {KeypadAPI} from "@khanacademy/math-input";
|
|
7
7
|
import type {AnalyticsEventHandlerFn} from "@khanacademy/perseus-core";
|
|
8
|
+
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
8
9
|
import type {Result} from "@khanacademy/wonder-blocks-data";
|
|
9
10
|
import type * as React from "react";
|
|
10
11
|
|
|
@@ -375,14 +376,6 @@ export type APIOptionsWithDefaults = Readonly<
|
|
|
375
376
|
}
|
|
376
377
|
>;
|
|
377
378
|
|
|
378
|
-
export type LinterContextProps = {
|
|
379
|
-
contentType: string;
|
|
380
|
-
highlightLint: boolean;
|
|
381
|
-
paths: ReadonlyArray<string>;
|
|
382
|
-
stack: ReadonlyArray<string>;
|
|
383
|
-
// additional properties can be added to the context by widgets
|
|
384
|
-
};
|
|
385
|
-
|
|
386
379
|
export type Tracking =
|
|
387
380
|
// Track interactions once
|
|
388
381
|
| ""
|
package/src/widget-container.tsx
CHANGED
|
@@ -9,7 +9,8 @@ import {containerSizeClass, getClassFromWidth} from "./util/sizing-utils";
|
|
|
9
9
|
import * as Widgets from "./widgets";
|
|
10
10
|
|
|
11
11
|
import type {PerseusWidgetOptions} from "./perseus-types";
|
|
12
|
-
import type {
|
|
12
|
+
import type {WidgetProps} from "./types";
|
|
13
|
+
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
13
14
|
|
|
14
15
|
type Props = {
|
|
15
16
|
shouldHighlight: boolean;
|
|
@@ -10,27 +10,20 @@ import {registerAllWidgetsForTesting} from "../../util/register-all-widgets-for-
|
|
|
10
10
|
|
|
11
11
|
import type {PerseusRenderer} from "../../perseus-types";
|
|
12
12
|
import type {APIOptions} from "../../types";
|
|
13
|
+
import type {PropsFor} from "@khanacademy/wonder-blocks-core";
|
|
13
14
|
|
|
14
15
|
type RenderResult = ReturnType<typeof render>;
|
|
15
16
|
|
|
16
17
|
export const renderQuestion = (
|
|
17
18
|
question: PerseusRenderer,
|
|
18
19
|
apiOptions: APIOptions = Object.freeze({}),
|
|
19
|
-
extraProps?:
|
|
20
|
-
typeof Perseus.Renderer,
|
|
21
|
-
// @ts-expect-error - TS2344 - Type 'typeof Renderer' does not satisfy the constraint 'keyof IntrinsicElements | JSXElementConstructor<any>'.
|
|
22
|
-
React.ComponentProps<typeof Perseus.Renderer>
|
|
23
|
-
>,
|
|
20
|
+
extraProps?: PropsFor<typeof Perseus.Renderer>,
|
|
24
21
|
): {
|
|
25
22
|
container: HTMLElement;
|
|
26
23
|
renderer: Perseus.Renderer;
|
|
27
24
|
rerender: (
|
|
28
25
|
question: PerseusRenderer,
|
|
29
|
-
extraProps?:
|
|
30
|
-
typeof Perseus.Renderer,
|
|
31
|
-
// @ts-expect-error - TS2344 - Type 'typeof Renderer' does not satisfy the constraint 'keyof IntrinsicElements | JSXElementConstructor<any>'.
|
|
32
|
-
React.ComponentProps<typeof Perseus.Renderer>
|
|
33
|
-
>,
|
|
26
|
+
extraProps?: PropsFor<typeof Perseus.Renderer>,
|
|
34
27
|
) => void;
|
|
35
28
|
unmount: RenderResult["unmount"];
|
|
36
29
|
} => {
|
|
@@ -57,7 +50,6 @@ export const renderQuestion = (
|
|
|
57
50
|
}
|
|
58
51
|
const renderAgain = (
|
|
59
52
|
question: PerseusRenderer,
|
|
60
|
-
// @ts-expect-error - TS2344 - Type 'typeof Renderer' does not satisfy the constraint 'keyof IntrinsicElements | JSXElementConstructor<any>'.
|
|
61
53
|
extraProps: undefined | React.ComponentProps<typeof Perseus.Renderer>,
|
|
62
54
|
) => {
|
|
63
55
|
rerender(
|
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
WidgetProps,
|
|
31
31
|
} from "../types";
|
|
32
32
|
import type {Keys as Key} from "@khanacademy/math-input";
|
|
33
|
+
import type {PropsFor} from "@khanacademy/wonder-blocks-core";
|
|
33
34
|
|
|
34
35
|
type InputPath = ReadonlyArray<string>;
|
|
35
36
|
|
|
@@ -673,13 +674,7 @@ const propUpgrades = {
|
|
|
673
674
|
|
|
674
675
|
const ExpressionWithDependencies = React.forwardRef<
|
|
675
676
|
Expression,
|
|
676
|
-
Omit<
|
|
677
|
-
JSX.LibraryManagedAttributes<
|
|
678
|
-
typeof Expression,
|
|
679
|
-
React.ComponentProps<typeof Expression>
|
|
680
|
-
>,
|
|
681
|
-
keyof ReturnType<typeof useDependencies>
|
|
682
|
-
>
|
|
677
|
+
Omit<PropsFor<typeof Expression>, keyof ReturnType<typeof useDependencies>>
|
|
683
678
|
>((props, ref) => {
|
|
684
679
|
const deps = useDependencies();
|
|
685
680
|
return <Expression ref={ref} analytics={deps.analytics} {...props} />;
|
package/src/widgets/grapher.tsx
CHANGED
|
@@ -36,6 +36,7 @@ import type {ChangeableProps} from "../mixins/changeable";
|
|
|
36
36
|
import type {PerseusGrapherWidgetOptions} from "../perseus-types";
|
|
37
37
|
import type {PerseusScore, WidgetExports, WidgetProps} from "../types";
|
|
38
38
|
import type {GridDimensions} from "../util";
|
|
39
|
+
import type {PropsFor} from "@khanacademy/wonder-blocks-core";
|
|
39
40
|
|
|
40
41
|
// @ts-expect-error - TS2339 - Property 'MovablePoint' does not exist on type 'typeof Graphie'.
|
|
41
42
|
const MovablePoint = Graphie.MovablePoint;
|
|
@@ -473,18 +474,9 @@ class Grapher extends React.Component<Props> {
|
|
|
473
474
|
}
|
|
474
475
|
|
|
475
476
|
_calculateMobileTickStep(
|
|
476
|
-
gridStep:
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
>["gridStep"],
|
|
480
|
-
step: JSX.LibraryManagedAttributes<
|
|
481
|
-
typeof Graphie,
|
|
482
|
-
Required<React.ComponentProps<typeof Graphie>>
|
|
483
|
-
>["step"],
|
|
484
|
-
ranges: JSX.LibraryManagedAttributes<
|
|
485
|
-
typeof Graphie,
|
|
486
|
-
Required<React.ComponentProps<typeof Graphie>>
|
|
487
|
-
>["ranges"],
|
|
477
|
+
gridStep: NonNullable<PropsFor<typeof Graphie>["gridStep"]>,
|
|
478
|
+
step: NonNullable<PropsFor<typeof Graphie>["step"]>,
|
|
479
|
+
ranges: NonNullable<PropsFor<typeof Graphie>["ranges"]>,
|
|
488
480
|
): any {
|
|
489
481
|
const tickStep = Util.constrainedTickStepsFromTickSteps(step, ranges);
|
|
490
482
|
|
|
@@ -13,9 +13,9 @@ import type {
|
|
|
13
13
|
PerseusScore,
|
|
14
14
|
WidgetExports,
|
|
15
15
|
WidgetProps,
|
|
16
|
-
LinterContextProps,
|
|
17
16
|
} from "../types";
|
|
18
17
|
import type {Passage, Reference} from "./passage";
|
|
18
|
+
import type {LinterContextProps} from "@khanacademy/perseus-linter";
|
|
19
19
|
|
|
20
20
|
const EN_DASH = "\u2013";
|
|
21
21
|
|