@khanacademy/perseus 16.0.0 → 17.1.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 +74 -0
- package/dist/article-renderer.d.ts +1 -2
- package/dist/components.d.ts +0 -1
- package/dist/dependencies.d.ts +1 -0
- package/dist/es/index.css +20 -90
- package/dist/es/index.js +457 -1028
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +20 -90
- package/dist/index.d.ts +0 -1
- package/dist/index.js +456 -1031
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +1 -0
- package/dist/server-item-renderer.d.ts +42 -15
- package/dist/strings.js +1 -23
- package/dist/widgets/label-image/answer-pill.d.ts +10 -0
- package/dist/widgets/label-image/hide-answers-toggle.d.ts +6 -0
- package/dist/widgets/label-image/marker.d.ts +6 -9
- package/dist/widgets/label-image/types.d.ts +1 -0
- package/dist/widgets/label-image.d.ts +101 -12
- package/package.json +30 -22
- package/src/__stories__/server-item-renderer.stories.tsx +20 -1
- package/src/__testdata__/server-item-renderer.testdata.ts +173 -0
- package/src/__tests__/__snapshots__/renderer.test.tsx.snap +3 -3
- package/src/__tests__/server-item-renderer.test.tsx +38 -1
- package/src/article-renderer.tsx +13 -15
- package/src/components.ts +0 -1
- package/src/dependencies.ts +4 -0
- package/src/index.ts +0 -1
- package/src/perseus-types.ts +2 -0
- package/src/server-item-renderer.tsx +26 -14
- package/src/styles/khan-exercise.css +0 -24
- package/src/styles/widgets/label-image.less +32 -0
- package/src/widgets/__stories__/label-image.stories.tsx +73 -3
- package/src/widgets/__testdata__/label-image.testdata.ts +118 -1
- package/src/widgets/__tests__/__snapshots__/dropdown.test.ts.snap +2 -2
- package/src/widgets/label-image/__stories__/answer-pill.stories.tsx +62 -0
- package/src/widgets/label-image/__tests__/answer-pill.test.tsx +83 -0
- package/src/widgets/label-image/__tests__/hide-answers-toggle.test.tsx +39 -0
- package/src/widgets/label-image/answer-choices.tsx +7 -1
- package/src/widgets/label-image/answer-pill.tsx +89 -0
- package/src/widgets/label-image/hide-answers-toggle.tsx +40 -0
- package/src/widgets/label-image/marker.tsx +116 -174
- package/src/widgets/label-image/types.ts +1 -0
- package/src/widgets/label-image.test.ts +142 -52
- package/src/widgets/label-image.tsx +212 -135
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/tex-buttons.d.ts +0 -25
- 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/components/__stories__/text-buttons.stories.tsx +0 -54
- package/src/components/tex-buttons.tsx +0 -334
- package/src/item-renderer.tsx +0 -529
- package/src/mixins/provide-keypad.tsx +0 -137
package/dist/perseus-types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as PerseusLinter from "@khanacademy/perseus-linter";
|
|
1
2
|
/**
|
|
2
3
|
* A copy of the ItemRenderer which renders its question renderer and hints
|
|
3
4
|
* renderer normally instead of ReactDOM.render()ing them into elements in the
|
|
@@ -8,18 +9,18 @@
|
|
|
8
9
|
*/
|
|
9
10
|
import * as React from "react";
|
|
10
11
|
import Renderer from "./renderer";
|
|
11
|
-
import type { KeypadProps } from "./mixins/provide-keypad";
|
|
12
12
|
import type { APIOptions, FocusPath, PerseusDependenciesV2 } from "./types";
|
|
13
13
|
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
14
14
|
import type { KeypadContextRendererInterface, RendererInterface, KEScore } from "@khanacademy/perseus-core";
|
|
15
|
-
type
|
|
16
|
-
|
|
15
|
+
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
16
|
+
type OwnProps = {
|
|
17
17
|
apiOptions: APIOptions;
|
|
18
18
|
hintsVisible?: number;
|
|
19
19
|
item: {
|
|
20
20
|
hints: ReadonlyArray<any>;
|
|
21
21
|
question: any;
|
|
22
22
|
};
|
|
23
|
+
linterContext: LinterContextProps;
|
|
23
24
|
problemNum?: number;
|
|
24
25
|
reviewMode?: boolean;
|
|
25
26
|
keypadElement?: KeypadAPI | null | undefined;
|
|
@@ -32,6 +33,7 @@ type Props = OwnProps & HOCProps;
|
|
|
32
33
|
type DefaultProps = {
|
|
33
34
|
apiOptions: Props["apiOptions"];
|
|
34
35
|
onRendered: Props["onRendered"];
|
|
36
|
+
linterContext: Props["linterContext"];
|
|
35
37
|
};
|
|
36
38
|
type State = {
|
|
37
39
|
questionCompleted: boolean;
|
|
@@ -102,16 +104,41 @@ export declare class ServerItemRenderer extends React.Component<Props, State> im
|
|
|
102
104
|
setAssetStatus: (assetKey: string, status: boolean) => void;
|
|
103
105
|
render(): React.ReactNode;
|
|
104
106
|
}
|
|
105
|
-
declare const ref: React.ForwardRefExoticComponent<Omit<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps, "item" | "problemNum" | "reviewMode" | "keypadElement" | "hintsVisible" | "dependencies"> & {
|
|
108
|
+
linterContext?: PerseusLinter.LinterContextProps | undefined;
|
|
109
|
+
apiOptions?: Readonly<{
|
|
110
|
+
isArticle?: boolean | undefined;
|
|
111
|
+
onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
|
|
112
|
+
onFocusChange?: ((newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
|
|
113
|
+
GroupMetadataEditor?: React.ComponentType<any> | undefined;
|
|
114
|
+
showAlignmentOptions?: boolean | undefined;
|
|
115
|
+
readOnly?: boolean | undefined;
|
|
116
|
+
answerableCallback?: ((arg1: boolean) => unknown) | undefined;
|
|
117
|
+
getAnotherHint?: (() => unknown) | undefined;
|
|
118
|
+
interactionCallback?: (() => unknown) | undefined;
|
|
119
|
+
groupAnnotator?: ((groupNumber: number, widgetId: string) => React.ReactNode) | undefined;
|
|
120
|
+
imagePlaceholder?: React.ReactNode;
|
|
121
|
+
widgetPlaceholder?: React.ReactNode;
|
|
122
|
+
baseElements?: {
|
|
123
|
+
Link: React.ComponentType<any>;
|
|
124
|
+
} | undefined;
|
|
125
|
+
imagePreloader?: ((dimensions: import("./types").Dimensions) => React.ReactNode) | undefined;
|
|
126
|
+
trackInteraction?: ((args: {
|
|
127
|
+
type: string;
|
|
128
|
+
id: string;
|
|
129
|
+
correct?: boolean | undefined;
|
|
130
|
+
} & Partial<import("./types").TrackingGradedGroupExtraArguments> & Partial<import("./types").TrackingSequenceExtraArguments>) => void) | undefined;
|
|
131
|
+
customKeypad?: boolean | undefined;
|
|
132
|
+
nativeKeypadProxy?: ((blur: () => void) => KeypadAPI) | undefined;
|
|
133
|
+
isMobile?: boolean | undefined;
|
|
134
|
+
setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
|
|
135
|
+
useDraftEditor?: boolean | undefined;
|
|
136
|
+
hintProgressColor?: string | undefined;
|
|
137
|
+
canScrollPage?: boolean | undefined;
|
|
138
|
+
inModal?: boolean | undefined;
|
|
139
|
+
crossOutEnabled?: boolean | undefined;
|
|
140
|
+
editorChangeDelay?: number | undefined;
|
|
141
|
+
}> | undefined;
|
|
142
|
+
onRendered?: ((isRendered: boolean) => void) | undefined;
|
|
143
|
+
} & {}, "onRendered"> & React.RefAttributes<ServerItemRenderer>>;
|
|
117
144
|
export default ref;
|
package/dist/strings.js
CHANGED
|
@@ -20,6 +20,7 @@ module.exports = [
|
|
|
20
20
|
i18n.$_("[Marker for question %(number)s]", {}),
|
|
21
21
|
i18n.$_("[Sentence %(number)s]", {}),
|
|
22
22
|
i18n._("**Your answer should be** ", {}),
|
|
23
|
+
i18n.ngettext("%(num)s answer","%(num)s answers", {}),
|
|
23
24
|
i18n._("a *proper* fraction, like $1/2$ or $6/10$", {}),
|
|
24
25
|
i18n._("a *simplified improper* fraction, like $7/4$", {}),
|
|
25
26
|
i18n._("a *simplified proper* fraction, like $3/5$", {}),
|
|
@@ -53,8 +54,6 @@ module.exports = [
|
|
|
53
54
|
i18n._("Correct (but you crossed it out)", {}),
|
|
54
55
|
i18n._("Correct (selected)", {}),
|
|
55
56
|
i18n._("Correct!", {}),
|
|
56
|
-
i18n._("Cosine", {}),
|
|
57
|
-
i18n._("Cube root", {}),
|
|
58
57
|
i18n._("Current", {}),
|
|
59
58
|
// I18N: As in the command, "Dilate the polygon"
|
|
60
59
|
i18n._("Dilate", {}),
|
|
@@ -62,19 +61,13 @@ module.exports = [
|
|
|
62
61
|
i18n._("Dilation", {}),
|
|
63
62
|
i18n.$_("Dilation about %(point)s by %(scale)s", {}),
|
|
64
63
|
i18n.$_("Dilation of scale %(scale)s about %(point)s", {}),
|
|
65
|
-
i18n._("Divide", {}),
|
|
66
64
|
i18n._("Drag handles to make graph", {}),
|
|
67
65
|
i18n._("End of reading passage.", {}),
|
|
68
66
|
i18n._("entered in an invalid answer.", {}),
|
|
69
|
-
i18n._("Equals sign", {}),
|
|
70
67
|
i18n.$_("Error rendering: %(error)s", {}),
|
|
71
68
|
i18n._("Explain", {}),
|
|
72
|
-
i18n._("Exponent", {}),
|
|
73
69
|
i18n._("False", {}),
|
|
74
|
-
i18n._("Fraction, excluding the current expression", {}),
|
|
75
70
|
i18n._("Get another hint", {}),
|
|
76
|
-
i18n._("Greater than or equal to sign", {}),
|
|
77
|
-
i18n._("Greater than sign", {}),
|
|
78
71
|
i18n._("Hide answer choices", {}),
|
|
79
72
|
i18n._("Hide explanation", {}),
|
|
80
73
|
i18n._("Hint #%(pos)s", {}),
|
|
@@ -87,38 +80,27 @@ module.exports = [
|
|
|
87
80
|
i18n._("It looks like you left something blank or ", {}),
|
|
88
81
|
i18n._("Keep trying", {}),
|
|
89
82
|
i18n._("Khan Academy video wrapper", {}),
|
|
90
|
-
i18n._("Less than or equal to sign", {}),
|
|
91
|
-
i18n._("Less than sign", {}),
|
|
92
83
|
// I18N: a label next to a reading passage to denote the line number
|
|
93
84
|
i18n._("Line ", {}),
|
|
94
85
|
i18n.$_("line %(lineNumber)s", {}),
|
|
95
86
|
i18n.$_("lines %(lineRange)s", {}),
|
|
96
87
|
i18n._("Loading...", {}),
|
|
97
|
-
i18n._("Logarithm with base 10", {}),
|
|
98
|
-
i18n._("Logarithm with custom base", {}),
|
|
99
88
|
i18n._("Make circle filled", {}),
|
|
100
89
|
i18n._("Make circle open", {}),
|
|
101
90
|
i18n._("Make sure you fill in all cells in the matrix.", {}),
|
|
102
91
|
i18n._("Make sure you select something for every row.", {}),
|
|
103
|
-
i18n._("Minus", {}),
|
|
104
92
|
i18n.ngettext("Moves: %(num)s","Moves: %(num)s", {}),
|
|
105
|
-
i18n._("Multiply", {}),
|
|
106
|
-
i18n._("Natural logarithm", {}),
|
|
107
93
|
i18n._("Next question", {}),
|
|
108
94
|
i18n._("No", {}),
|
|
109
95
|
i18n._("None of the above", {}),
|
|
110
|
-
i18n._("Not-equals sign", {}),
|
|
111
96
|
i18n._("Note: For this question, the shape will not move.", {}),
|
|
112
97
|
i18n._("Number of divisions:", {}),
|
|
113
98
|
i18n._("Number of trials:", {}),
|
|
114
99
|
i18n._("Oops!", {}),
|
|
115
100
|
i18n._("open math keypad", {}),
|
|
116
101
|
i18n._("Parameter", {}),
|
|
117
|
-
i18n._("Phi", {}),
|
|
118
|
-
i18n._("Pi", {}),
|
|
119
102
|
i18n._("Please choose the correct number of answers.", {}),
|
|
120
103
|
i18n.$_("Please make sure the number of divisions is in the range %(divRangeString)s.", {}),
|
|
121
|
-
i18n._("Plus", {}),
|
|
122
104
|
i18n._("Reaction arrow pointing to the right.", {}),
|
|
123
105
|
// I18N: As in the command, "Reflect the polygon"
|
|
124
106
|
i18n._("Reflect", {}),
|
|
@@ -136,19 +118,15 @@ module.exports = [
|
|
|
136
118
|
i18n._("Run simulation", {}),
|
|
137
119
|
i18n._("Sample size:", {}),
|
|
138
120
|
i18n._("See video transcript", {}),
|
|
139
|
-
i18n._("Sine", {}),
|
|
140
121
|
i18n._("Skip to %(title)s", {}),
|
|
141
122
|
i18n._("Something went wrong.", {}),
|
|
142
123
|
i18n._("Sorry, I don't understand that!", {}),
|
|
143
|
-
i18n._("Square root", {}),
|
|
144
124
|
i18n._("Switch direction", {}),
|
|
145
|
-
i18n._("Tangent", {}),
|
|
146
125
|
i18n._("Tap each dot on the image to select all answers that apply.", {}),
|
|
147
126
|
i18n._("Tap each dot on the image to select an answer.", {}),
|
|
148
127
|
i18n._("Tap to add points", {}),
|
|
149
128
|
i18n._("That answer is numerically incorrect.", {}),
|
|
150
129
|
i18n._("The symbol %(questionSymbol)s indicates that question %(questionNumber)s references this portion of the passage.", {}),
|
|
151
|
-
i18n._("Theta", {}),
|
|
152
130
|
i18n._("This controls the proportion or percentage that will be used in your simulation.", {}),
|
|
153
131
|
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.", {}),
|
|
154
132
|
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.", {}),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type CSSProperties } from "aphrodite";
|
|
3
|
+
export declare const AnswerPill: (props: {
|
|
4
|
+
selectedAnswers: readonly string[];
|
|
5
|
+
showCorrectness?: "correct" | "incorrect";
|
|
6
|
+
markerRef?: HTMLElement;
|
|
7
|
+
side: "top" | "bottom" | "left" | "right";
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
}) => JSX.Element;
|
|
@@ -8,20 +8,17 @@ import type { InteractiveMarkerType } from "./types";
|
|
|
8
8
|
type Props = InteractiveMarkerType & {
|
|
9
9
|
showSelected: boolean;
|
|
10
10
|
showPulsate: boolean;
|
|
11
|
-
onClick: (e: MouseEvent) => void;
|
|
12
|
-
onKeyDown: (e: KeyboardEvent) => void;
|
|
11
|
+
onClick: (e: React.MouseEvent) => void;
|
|
12
|
+
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
13
|
+
onFocus: () => void;
|
|
14
|
+
onBlur: () => void;
|
|
15
|
+
focused: boolean;
|
|
13
16
|
};
|
|
14
|
-
|
|
15
|
-
isFocused: boolean;
|
|
16
|
-
};
|
|
17
|
-
export default class Marker extends React.Component<Props, State> {
|
|
17
|
+
export default class Marker extends React.Component<Props> {
|
|
18
18
|
_icon: HTMLElement | null | undefined;
|
|
19
19
|
static defaultProps: {
|
|
20
20
|
selected: ReadonlyArray<any>;
|
|
21
21
|
};
|
|
22
|
-
state: State;
|
|
23
|
-
handleFocus(): void;
|
|
24
|
-
handleBlur(): void;
|
|
25
22
|
renderIcon(): React.ReactElement<React.ComponentProps<"div">>;
|
|
26
23
|
render(): React.ReactNode;
|
|
27
24
|
}
|
|
@@ -10,8 +10,10 @@ import * as React from "react";
|
|
|
10
10
|
import AnswerChoices from "./label-image/answer-choices";
|
|
11
11
|
import Marker from "./label-image/marker";
|
|
12
12
|
import type { InteractiveMarkerType, InteractiveMarkerScore } from "./label-image/types";
|
|
13
|
+
import type { DependencyProps } from "../dependencies";
|
|
13
14
|
import type { ChangeableProps } from "../mixins/changeable";
|
|
14
15
|
import type { APIOptions, PerseusScore } from "../types";
|
|
16
|
+
export type PreferredPopoverDirection = "NONE" | "UP" | "DOWN" | "LEFT" | "RIGHT";
|
|
15
17
|
type MarkersState = {
|
|
16
18
|
markers: ReadonlyArray<InteractiveMarkerType>;
|
|
17
19
|
};
|
|
@@ -33,7 +35,7 @@ type Point = {
|
|
|
33
35
|
x: number;
|
|
34
36
|
y: number;
|
|
35
37
|
};
|
|
36
|
-
type LabelImageProps = ChangeableProps & {
|
|
38
|
+
type LabelImageProps = ChangeableProps & DependencyProps & {
|
|
37
39
|
apiOptions: APIOptions;
|
|
38
40
|
choices: ReadonlyArray<string>;
|
|
39
41
|
imageAlt: string;
|
|
@@ -44,12 +46,15 @@ type LabelImageProps = ChangeableProps & {
|
|
|
44
46
|
multipleAnswers: boolean;
|
|
45
47
|
hideChoicesFromInstructions: boolean;
|
|
46
48
|
questionCompleted: boolean;
|
|
49
|
+
preferredPopoverDirection?: PreferredPopoverDirection;
|
|
47
50
|
};
|
|
48
51
|
type LabelImageState = {
|
|
49
|
-
|
|
52
|
+
activeMarkerIndex: number;
|
|
50
53
|
markersInteracted: boolean;
|
|
54
|
+
focusedMarkerIndex: number;
|
|
55
|
+
hideAnswers: boolean;
|
|
51
56
|
};
|
|
52
|
-
declare class LabelImage extends React.Component<LabelImageProps, LabelImageState> {
|
|
57
|
+
export declare class LabelImage extends React.Component<LabelImageProps, LabelImageState> {
|
|
53
58
|
_markers: Array<Marker | null | undefined>;
|
|
54
59
|
_selectedMarkerPopup: Popover | null | undefined;
|
|
55
60
|
_answerChoices: AnswerChoices | null | undefined;
|
|
@@ -64,7 +69,7 @@ declare class LabelImage extends React.Component<LabelImageProps, LabelImageStat
|
|
|
64
69
|
/**
|
|
65
70
|
* Determine the image side given a marker position (as percent of size).
|
|
66
71
|
*/
|
|
67
|
-
static imageSideForMarkerPosition(x: number, y: number): "bottom" | "left" | "right" | "top" | "center";
|
|
72
|
+
static imageSideForMarkerPosition(x: number, y: number, preferredDirection: PreferredPopoverDirection | undefined): "bottom" | "left" | "right" | "top" | "center";
|
|
68
73
|
/**
|
|
69
74
|
* Calculate the next marker to navigate to, from the "this marker".
|
|
70
75
|
*
|
|
@@ -73,17 +78,13 @@ declare class LabelImage extends React.Component<LabelImageProps, LabelImageStat
|
|
|
73
78
|
*/
|
|
74
79
|
static navigateToMarkerIndex(navigateDirection: Direction, markers: ReadonlyArray<InteractiveMarkerType>, thisIndex: number): number;
|
|
75
80
|
constructor(props: LabelImageProps);
|
|
76
|
-
componentDidMount(): void;
|
|
77
|
-
componentWillUnmount(): void;
|
|
78
81
|
simpleValidate(rubric: LabelImageProps): PerseusScore;
|
|
79
82
|
getUserInput(): MarkersState;
|
|
80
83
|
showRationalesForCurrentlySelectedChoices(rubric: LabelImageProps): void;
|
|
81
84
|
dismissMarkerPopup(): void;
|
|
82
|
-
handleDocumentClick: (e: MouseEvent) => void;
|
|
83
|
-
handleDocumentKeyDown: (e: KeyboardEvent) => void;
|
|
84
85
|
handleMarkerChange(index: number, marker: InteractiveMarkerType): void;
|
|
85
|
-
|
|
86
|
-
handleMarkerKeyDown(index: number, e: KeyboardEvent): void;
|
|
86
|
+
activateMarker(index: number): void;
|
|
87
|
+
handleMarkerKeyDown(index: number, e: React.KeyboardEvent): void;
|
|
87
88
|
handleAnswerChoicesChangeForMarker(index: number, selection: ReadonlyArray<boolean>): void;
|
|
88
89
|
renderAnswerChoicesForMarker(index: number, marker: InteractiveMarkerType): React.ReactElement<React.ComponentProps<"div">>;
|
|
89
90
|
renderMarkers(): ReadonlyArray<React.ReactNode>;
|
|
@@ -93,7 +94,51 @@ declare class LabelImage extends React.Component<LabelImageProps, LabelImageStat
|
|
|
93
94
|
declare const _default: Readonly<{
|
|
94
95
|
name: string;
|
|
95
96
|
displayName: string;
|
|
96
|
-
getWidget?: (() =>
|
|
97
|
+
getWidget?: (() => React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../types").PerseusDependenciesV2> & {
|
|
98
|
+
apiOptions: Readonly<{
|
|
99
|
+
isArticle?: boolean | undefined;
|
|
100
|
+
onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
|
|
101
|
+
onFocusChange?: ((newFocusPath: import("../types").FocusPath, oldFocusPath: import("../types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
|
|
102
|
+
GroupMetadataEditor?: React.ComponentType<any> | undefined;
|
|
103
|
+
showAlignmentOptions?: boolean | undefined;
|
|
104
|
+
readOnly?: boolean | undefined;
|
|
105
|
+
answerableCallback?: ((arg1: boolean) => unknown) | undefined;
|
|
106
|
+
getAnotherHint?: (() => unknown) | undefined;
|
|
107
|
+
interactionCallback?: (() => unknown) | undefined;
|
|
108
|
+
groupAnnotator?: ((groupNumber: number, widgetId: string) => React.ReactNode) | undefined;
|
|
109
|
+
imagePlaceholder?: React.ReactNode;
|
|
110
|
+
widgetPlaceholder?: React.ReactNode;
|
|
111
|
+
baseElements?: {
|
|
112
|
+
Link: React.ComponentType<any>;
|
|
113
|
+
} | undefined;
|
|
114
|
+
imagePreloader?: ((dimensions: import("../types").Dimensions) => React.ReactNode) | undefined;
|
|
115
|
+
trackInteraction?: ((args: {
|
|
116
|
+
type: string;
|
|
117
|
+
id: string;
|
|
118
|
+
correct?: boolean | undefined;
|
|
119
|
+
} & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<import("../types").TrackingSequenceExtraArguments>) => void) | undefined;
|
|
120
|
+
customKeypad?: boolean | undefined;
|
|
121
|
+
nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
|
|
122
|
+
isMobile?: boolean | undefined;
|
|
123
|
+
setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
|
|
124
|
+
useDraftEditor?: boolean | undefined;
|
|
125
|
+
hintProgressColor?: string | undefined;
|
|
126
|
+
canScrollPage?: boolean | undefined;
|
|
127
|
+
inModal?: boolean | undefined;
|
|
128
|
+
crossOutEnabled?: boolean | undefined;
|
|
129
|
+
editorChangeDelay?: number | undefined;
|
|
130
|
+
}>;
|
|
131
|
+
choices: readonly string[];
|
|
132
|
+
imageAlt: string;
|
|
133
|
+
imageUrl: string;
|
|
134
|
+
imageWidth: number;
|
|
135
|
+
imageHeight: number;
|
|
136
|
+
markers: readonly InteractiveMarkerType[];
|
|
137
|
+
multipleAnswers: boolean;
|
|
138
|
+
hideChoicesFromInstructions: boolean;
|
|
139
|
+
questionCompleted: boolean;
|
|
140
|
+
preferredPopoverDirection?: PreferredPopoverDirection | undefined;
|
|
141
|
+
}, "analytics"> & React.RefAttributes<LabelImage>>) | undefined;
|
|
97
142
|
accessible?: boolean | ((props: any) => boolean) | undefined;
|
|
98
143
|
hidden?: boolean | undefined;
|
|
99
144
|
version?: import("../types").Version | undefined;
|
|
@@ -108,6 +153,50 @@ declare const _default: Readonly<{
|
|
|
108
153
|
propUpgrades?: {
|
|
109
154
|
[key: string]: (arg1: any) => any;
|
|
110
155
|
} | undefined;
|
|
111
|
-
widget:
|
|
156
|
+
widget: React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../types").PerseusDependenciesV2> & {
|
|
157
|
+
apiOptions: Readonly<{
|
|
158
|
+
isArticle?: boolean | undefined;
|
|
159
|
+
onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
|
|
160
|
+
onFocusChange?: ((newFocusPath: import("../types").FocusPath, oldFocusPath: import("../types").FocusPath, keypadElement?: Element | Text | null | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
|
|
161
|
+
GroupMetadataEditor?: React.ComponentType<any> | undefined;
|
|
162
|
+
showAlignmentOptions?: boolean | undefined;
|
|
163
|
+
readOnly?: boolean | undefined;
|
|
164
|
+
answerableCallback?: ((arg1: boolean) => unknown) | undefined;
|
|
165
|
+
getAnotherHint?: (() => unknown) | undefined;
|
|
166
|
+
interactionCallback?: (() => unknown) | undefined;
|
|
167
|
+
groupAnnotator?: ((groupNumber: number, widgetId: string) => React.ReactNode) | undefined;
|
|
168
|
+
imagePlaceholder?: React.ReactNode;
|
|
169
|
+
widgetPlaceholder?: React.ReactNode;
|
|
170
|
+
baseElements?: {
|
|
171
|
+
Link: React.ComponentType<any>;
|
|
172
|
+
} | undefined;
|
|
173
|
+
imagePreloader?: ((dimensions: import("../types").Dimensions) => React.ReactNode) | undefined;
|
|
174
|
+
trackInteraction?: ((args: {
|
|
175
|
+
type: string;
|
|
176
|
+
id: string;
|
|
177
|
+
correct?: boolean | undefined;
|
|
178
|
+
} & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<import("../types").TrackingSequenceExtraArguments>) => void) | undefined;
|
|
179
|
+
customKeypad?: boolean | undefined;
|
|
180
|
+
nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
|
|
181
|
+
isMobile?: boolean | undefined;
|
|
182
|
+
setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
|
|
183
|
+
useDraftEditor?: boolean | undefined;
|
|
184
|
+
hintProgressColor?: string | undefined;
|
|
185
|
+
canScrollPage?: boolean | undefined;
|
|
186
|
+
inModal?: boolean | undefined;
|
|
187
|
+
crossOutEnabled?: boolean | undefined;
|
|
188
|
+
editorChangeDelay?: number | undefined;
|
|
189
|
+
}>;
|
|
190
|
+
choices: readonly string[];
|
|
191
|
+
imageAlt: string;
|
|
192
|
+
imageUrl: string;
|
|
193
|
+
imageWidth: number;
|
|
194
|
+
imageHeight: number;
|
|
195
|
+
markers: readonly InteractiveMarkerType[];
|
|
196
|
+
multipleAnswers: boolean;
|
|
197
|
+
hideChoicesFromInstructions: boolean;
|
|
198
|
+
questionCompleted: boolean;
|
|
199
|
+
preferredPopoverDirection?: PreferredPopoverDirection | undefined;
|
|
200
|
+
}, "analytics"> & React.RefAttributes<LabelImage>>;
|
|
112
201
|
}>;
|
|
113
202
|
export default _default;
|
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": "17.1.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -22,33 +22,36 @@
|
|
|
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.
|
|
26
|
-
"@khanacademy/kmath": "^0.1.
|
|
27
|
-
"@khanacademy/math-input": "^16.1.
|
|
28
|
-
"@khanacademy/perseus-core": "1.4.
|
|
29
|
-
"@khanacademy/perseus-linter": "^0.3.
|
|
30
|
-
"@khanacademy/pure-markdown": "^0.2.
|
|
31
|
-
"@khanacademy/simple-markdown": "^0.11.
|
|
25
|
+
"@khanacademy/kas": "^0.3.7",
|
|
26
|
+
"@khanacademy/kmath": "^0.1.8",
|
|
27
|
+
"@khanacademy/math-input": "^16.1.2",
|
|
28
|
+
"@khanacademy/perseus-core": "1.4.1",
|
|
29
|
+
"@khanacademy/perseus-linter": "^0.3.10",
|
|
30
|
+
"@khanacademy/pure-markdown": "^0.2.13",
|
|
31
|
+
"@khanacademy/simple-markdown": "^0.11.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@khanacademy/wonder-blocks-button": "^6.2.
|
|
34
|
+
"@khanacademy/wonder-blocks-button": "^6.2.4",
|
|
35
35
|
"@khanacademy/wonder-blocks-clickable": "^4.0.11",
|
|
36
36
|
"@khanacademy/wonder-blocks-color": "^3.0.0",
|
|
37
37
|
"@khanacademy/wonder-blocks-core": "^6.3.0",
|
|
38
38
|
"@khanacademy/wonder-blocks-data": "^13.0.5",
|
|
39
|
-
"@khanacademy/wonder-blocks-dropdown": "^
|
|
40
|
-
"@khanacademy/wonder-blocks-form": "^4.3.
|
|
39
|
+
"@khanacademy/wonder-blocks-dropdown": "^4.0.0",
|
|
40
|
+
"@khanacademy/wonder-blocks-form": "^4.3.18",
|
|
41
41
|
"@khanacademy/wonder-blocks-i18n": "^2.0.2",
|
|
42
42
|
"@khanacademy/wonder-blocks-layout": "^2.0.24",
|
|
43
|
-
"@khanacademy/wonder-blocks-link": "^6.0.
|
|
44
|
-
"@khanacademy/wonder-blocks-modal": "^4.0.
|
|
45
|
-
"@khanacademy/wonder-blocks-
|
|
43
|
+
"@khanacademy/wonder-blocks-link": "^6.0.4",
|
|
44
|
+
"@khanacademy/wonder-blocks-modal": "^4.0.38",
|
|
45
|
+
"@khanacademy/wonder-blocks-pill": "^1.0.14",
|
|
46
|
+
"@khanacademy/wonder-blocks-popover": "^3.0.19",
|
|
46
47
|
"@khanacademy/wonder-blocks-progress-spinner": "^2.0.24",
|
|
47
48
|
"@khanacademy/wonder-blocks-spacing": "^4.0.1",
|
|
48
|
-
"@khanacademy/wonder-blocks-
|
|
49
|
+
"@khanacademy/wonder-blocks-switch": "^1.1.8",
|
|
50
|
+
"@khanacademy/wonder-blocks-tooltip": "^2.1.21",
|
|
49
51
|
"@khanacademy/wonder-blocks-typography": "^2.1.9",
|
|
50
52
|
"@khanacademy/wonder-stuff-core": "^1.5.1",
|
|
51
53
|
"@phosphor-icons/core": "^2.0.2",
|
|
54
|
+
"@popperjs/core": "^2.10.1",
|
|
52
55
|
"aphrodite": "^1.2.5",
|
|
53
56
|
"classnames": "^1.1.4",
|
|
54
57
|
"create-react-class": "^15.6.3",
|
|
@@ -63,27 +66,31 @@
|
|
|
63
66
|
"prop-types": "^15.6.1",
|
|
64
67
|
"react": "16.14.0",
|
|
65
68
|
"react-dom": "16.14.0",
|
|
69
|
+
"react-popper": "^2.0.0",
|
|
66
70
|
"underscore": "^1.4.4"
|
|
67
71
|
},
|
|
68
72
|
"peerDependencies": {
|
|
69
|
-
"@khanacademy/wonder-blocks-button": "^6.2.
|
|
73
|
+
"@khanacademy/wonder-blocks-button": "^6.2.4",
|
|
70
74
|
"@khanacademy/wonder-blocks-clickable": "^4.0.11",
|
|
71
75
|
"@khanacademy/wonder-blocks-color": "^3.0.0",
|
|
72
76
|
"@khanacademy/wonder-blocks-core": "^6.3.0",
|
|
73
77
|
"@khanacademy/wonder-blocks-data": "^13.0.5",
|
|
74
|
-
"@khanacademy/wonder-blocks-dropdown": "^
|
|
75
|
-
"@khanacademy/wonder-blocks-form": "^4.3.
|
|
78
|
+
"@khanacademy/wonder-blocks-dropdown": "^4.0.0",
|
|
79
|
+
"@khanacademy/wonder-blocks-form": "^4.3.18",
|
|
76
80
|
"@khanacademy/wonder-blocks-i18n": "^2.0.2",
|
|
77
81
|
"@khanacademy/wonder-blocks-layout": "^2.0.24",
|
|
78
|
-
"@khanacademy/wonder-blocks-link": "^6.0.
|
|
79
|
-
"@khanacademy/wonder-blocks-modal": "^4.0.
|
|
80
|
-
"@khanacademy/wonder-blocks-
|
|
82
|
+
"@khanacademy/wonder-blocks-link": "^6.0.4",
|
|
83
|
+
"@khanacademy/wonder-blocks-modal": "^4.0.38",
|
|
84
|
+
"@khanacademy/wonder-blocks-pill": "^1.0.14",
|
|
85
|
+
"@khanacademy/wonder-blocks-popover": "^3.0.19",
|
|
81
86
|
"@khanacademy/wonder-blocks-progress-spinner": "^2.0.24",
|
|
82
87
|
"@khanacademy/wonder-blocks-spacing": "^4.0.1",
|
|
83
|
-
"@khanacademy/wonder-blocks-
|
|
88
|
+
"@khanacademy/wonder-blocks-switch": "^1.1.8",
|
|
89
|
+
"@khanacademy/wonder-blocks-tooltip": "^2.1.21",
|
|
84
90
|
"@khanacademy/wonder-blocks-typography": "^2.1.9",
|
|
85
91
|
"@khanacademy/wonder-stuff-core": "^1.5.1",
|
|
86
92
|
"@phosphor-icons/core": "^2.0.2",
|
|
93
|
+
"@popperjs/core": "^2.10.1",
|
|
87
94
|
"aphrodite": "^1.2.5",
|
|
88
95
|
"classnames": "^1.1.4",
|
|
89
96
|
"create-react-class": "^15.6.3",
|
|
@@ -93,6 +100,7 @@
|
|
|
93
100
|
"prop-types": "^15.6.1",
|
|
94
101
|
"react": "16.14.0",
|
|
95
102
|
"react-dom": "16.14.0",
|
|
103
|
+
"react-popper": "^2.0.0",
|
|
96
104
|
"underscore": "^1.4.4"
|
|
97
105
|
},
|
|
98
106
|
"keywords": []
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import {ServerItemRendererWithDebugUI} from "../../../../testing/server-item-renderer-with-debug-ui";
|
|
4
|
+
import {testDependenciesV2} from "../../../../testing/test-dependencies";
|
|
4
5
|
import {
|
|
5
6
|
itemWithInput,
|
|
7
|
+
itemWithLintingError,
|
|
6
8
|
labelImageItem,
|
|
7
|
-
} from "../__testdata__/item-renderer.testdata";
|
|
9
|
+
} from "../__testdata__/server-item-renderer.testdata";
|
|
10
|
+
import {ServerItemRenderer} from "../server-item-renderer";
|
|
8
11
|
|
|
9
12
|
type StoryArgs = Record<any, any>;
|
|
10
13
|
|
|
@@ -23,3 +26,19 @@ export const InputNumberItem = (args: StoryArgs): React.ReactElement => {
|
|
|
23
26
|
export const LabelImageItem = (args: StoryArgs): React.ReactElement => {
|
|
24
27
|
return <ServerItemRendererWithDebugUI item={labelImageItem} />;
|
|
25
28
|
};
|
|
29
|
+
|
|
30
|
+
export const WithLintingError = (args: StoryArgs): React.ReactElement => {
|
|
31
|
+
return (
|
|
32
|
+
<ServerItemRenderer
|
|
33
|
+
problemNum={0}
|
|
34
|
+
item={itemWithLintingError}
|
|
35
|
+
dependencies={testDependenciesV2}
|
|
36
|
+
linterContext={{
|
|
37
|
+
contentType: "",
|
|
38
|
+
highlightLint: true,
|
|
39
|
+
paths: [],
|
|
40
|
+
stack: [],
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
};
|