@khanacademy/perseus 21.3.0 → 21.4.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/dist/es/index.css +17 -1
- package/dist/es/index.js +258 -139
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +17 -1
- package/dist/index.js +254 -128
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +9 -1
- package/dist/perseus-types.d.ts +1 -21
- package/dist/renderer.d.ts +19 -16
- package/dist/server-item-renderer.d.ts +9 -1
- package/dist/strings.js +0 -4
- package/dist/types.d.ts +11 -1
- package/dist/util/svg.d.ts +9 -0
- package/dist/widgets/expression.d.ts +54 -6
- package/dist/widgets/interactive-graphs/axis-ticks.d.ts +2 -0
- package/dist/widgets/interactive-graphs/graphs/components/arrowhead.d.ts +8 -0
- package/dist/widgets/interactive-graphs/graphs/components/svg-line.d.ts +10 -0
- package/dist/widgets/interactive-graphs/graphs/components/vector.d.ts +9 -0
- package/dist/widgets/interactive-graphs/graphs/types.d.ts +2 -5
- package/dist/widgets/interactive-graphs/reducer/interactive-graph-state.d.ts +9 -8
- package/dist/widgets/interactive-graphs/reducer/use-graph-config.d.ts +10 -0
- package/dist/widgets/interactive-graphs/types.d.ts +1 -0
- package/dist/widgets/label-image.d.ts +18 -2
- package/dist/widgets/radio/radio.d.ts +5 -8
- package/package.json +1 -1
- package/dist/widgets/interactive-graphs/reducer/use-graph-state.d.ts +0 -11
- package/dist/widgets/lights-puzzle.d.ts +0 -53
- package/dist/widgets/reaction-diagram.d.ts +0 -42
package/dist/perseus-api.d.ts
CHANGED
|
@@ -95,7 +95,15 @@ export declare const ApiOptions: {
|
|
|
95
95
|
inModal?: boolean | undefined;
|
|
96
96
|
crossOutEnabled?: boolean | undefined;
|
|
97
97
|
editorChangeDelay?: number | undefined;
|
|
98
|
-
flags?:
|
|
98
|
+
flags?: {
|
|
99
|
+
mafs?: false | {
|
|
100
|
+
polygon?: boolean | undefined;
|
|
101
|
+
linear?: boolean | undefined;
|
|
102
|
+
segment?: boolean | undefined;
|
|
103
|
+
"linear-system"?: boolean | undefined;
|
|
104
|
+
ray?: boolean | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
} | undefined;
|
|
99
107
|
onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
100
108
|
}> & {
|
|
101
109
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
package/dist/perseus-types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Interval, vec } from "mafs";
|
|
|
3
3
|
export type Range = Interval;
|
|
4
4
|
export type Size = [number, number];
|
|
5
5
|
export type CollinearTuple = readonly [vec.Vector2, vec.Vector2];
|
|
6
|
+
export type ShowSolutions = "all" | "selected" | "none";
|
|
6
7
|
export type StyleParams = {
|
|
7
8
|
fill?: string;
|
|
8
9
|
stroke?: string;
|
|
@@ -431,12 +432,6 @@ export type PerseusLabelImageMarker = {
|
|
|
431
432
|
x: number;
|
|
432
433
|
y: number;
|
|
433
434
|
};
|
|
434
|
-
export type PerseusLightsPuzzleWidgetOptions = {
|
|
435
|
-
cells?: ReadonlyArray<ReadonlyArray<boolean>>;
|
|
436
|
-
startCells?: ReadonlyArray<ReadonlyArray<boolean>>;
|
|
437
|
-
flipPattern?: string;
|
|
438
|
-
moveCount?: number;
|
|
439
|
-
};
|
|
440
435
|
export type PerseusMatcherWidgetOptions = {
|
|
441
436
|
labels: ReadonlyArray<string>;
|
|
442
437
|
left: ReadonlyArray<string>;
|
|
@@ -788,21 +783,6 @@ export type PerseusMoleculeRendererWidgetOptions = {
|
|
|
788
783
|
export type PerseusPassageRefTargetWidgetOptions = {
|
|
789
784
|
content: string;
|
|
790
785
|
};
|
|
791
|
-
export type PerseusReactionDiagramWidgetOptions = {
|
|
792
|
-
rotationAngle: ReadonlyArray<number>;
|
|
793
|
-
widgetId: string;
|
|
794
|
-
separators: ReadonlyArray<PerseusReactionDiagramSeparators>;
|
|
795
|
-
smiles: ReadonlyArray<string>;
|
|
796
|
-
};
|
|
797
|
-
export type PerseusReactionDiagramSeparators = {
|
|
798
|
-
type: string;
|
|
799
|
-
topText: string;
|
|
800
|
-
bottomText: string;
|
|
801
|
-
};
|
|
802
|
-
export type PerseusReactionDiagramSeparatorsData = {
|
|
803
|
-
topText: string;
|
|
804
|
-
bottomText: string;
|
|
805
|
-
};
|
|
806
786
|
export type PerseusSimpleMarkdownTesterWidgetOptions = {
|
|
807
787
|
value: string;
|
|
808
788
|
};
|
package/dist/renderer.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import InteractionTracker from "./interaction-tracker";
|
|
|
3
3
|
import TranslationLinter from "./translation-linter";
|
|
4
4
|
import WidgetContainer from "./widget-container";
|
|
5
5
|
import type { DependenciesContext } from "./dependencies";
|
|
6
|
-
import type { PerseusRenderer, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap } from "./perseus-types";
|
|
6
|
+
import type { PerseusRenderer, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions } from "./perseus-types";
|
|
7
7
|
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, PerseusScore, WidgetProps } from "./types";
|
|
8
8
|
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
9
9
|
import "./styles/perseus-renderer.less";
|
|
@@ -60,14 +60,31 @@ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
|
|
|
60
60
|
problemNum?: number;
|
|
61
61
|
questionCompleted?: boolean;
|
|
62
62
|
reviewMode?: boolean | null | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* If set to "all", all rationales or solutions will be shown. If set to
|
|
65
|
+
* "selected", soltions will only be shown for selected choices. If set to
|
|
66
|
+
* "none", solutions will not be shown-- equivalent to `undefined`.
|
|
67
|
+
*/
|
|
68
|
+
showSolutions?: ShowSolutions;
|
|
63
69
|
content: PerseusRenderer["content"];
|
|
64
70
|
serializedState?: any;
|
|
71
|
+
/**
|
|
72
|
+
* Callback which is called when serialized state changes with the new
|
|
73
|
+
* serialized state.
|
|
74
|
+
*/
|
|
65
75
|
onSerializedStateUpdated: (serializedState: {
|
|
66
76
|
[key: string]: any;
|
|
67
77
|
}) => unknown;
|
|
78
|
+
/**
|
|
79
|
+
* If linterContext.highlightLint is true, then content will be passed to
|
|
80
|
+
* the linter and any warnings will be highlighted in the rendered output.
|
|
81
|
+
*/
|
|
68
82
|
linterContext: LinterContextProps;
|
|
69
83
|
legacyPerseusLint?: ReadonlyArray<string>;
|
|
70
84
|
widgets: PerseusRenderer["widgets"];
|
|
85
|
+
/**
|
|
86
|
+
* Skip adding paragraph class
|
|
87
|
+
*/
|
|
71
88
|
inline?: boolean;
|
|
72
89
|
};
|
|
73
90
|
type State = {
|
|
@@ -81,21 +98,7 @@ type State = {
|
|
|
81
98
|
jiptContent: any;
|
|
82
99
|
lastUsedWidgetId: string | null | undefined;
|
|
83
100
|
};
|
|
84
|
-
type DefaultProps =
|
|
85
|
-
alwaysUpdate: Props["alwaysUpdate"];
|
|
86
|
-
content: Props["content"];
|
|
87
|
-
findExternalWidgets: Props["findExternalWidgets"];
|
|
88
|
-
highlightedWidgets: Props["highlightedWidgets"];
|
|
89
|
-
images: Props["images"];
|
|
90
|
-
linterContext: Props["linterContext"];
|
|
91
|
-
onInteractWithWidget: Props["onInteractWithWidget"];
|
|
92
|
-
onRender: Props["onRender"];
|
|
93
|
-
onSerializedStateUpdated: Props["onSerializedStateUpdated"];
|
|
94
|
-
questionCompleted: Props["questionCompleted"];
|
|
95
|
-
reviewMode: Props["reviewMode"];
|
|
96
|
-
serializedState: Props["serializedState"];
|
|
97
|
-
widgets: Props["widgets"];
|
|
98
|
-
};
|
|
101
|
+
type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExternalWidgets" | "highlightedWidgets" | "images" | "linterContext" | "onInteractWithWidget" | "onRender" | "onSerializedStateUpdated" | "questionCompleted" | "showSolutions" | "reviewMode" | "serializedState" | "widgets">>;
|
|
99
102
|
declare class Renderer extends React.Component<Props, State> {
|
|
100
103
|
_currentFocus: FocusPath | null | undefined;
|
|
101
104
|
_foundTextNodes: boolean;
|
|
@@ -137,7 +137,15 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
|
|
|
137
137
|
inModal?: boolean | undefined;
|
|
138
138
|
crossOutEnabled?: boolean | undefined;
|
|
139
139
|
editorChangeDelay?: number | undefined;
|
|
140
|
-
flags?:
|
|
140
|
+
flags?: {
|
|
141
|
+
mafs?: false | {
|
|
142
|
+
polygon?: boolean | undefined;
|
|
143
|
+
linear?: boolean | undefined;
|
|
144
|
+
segment?: boolean | undefined;
|
|
145
|
+
"linear-system"?: boolean | undefined;
|
|
146
|
+
ray?: boolean | undefined;
|
|
147
|
+
} | undefined;
|
|
148
|
+
} | undefined;
|
|
141
149
|
onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
142
150
|
}> | undefined;
|
|
143
151
|
linterContext?: PerseusLinter.LinterContextProps | undefined;
|
package/dist/strings.js
CHANGED
|
@@ -46,7 +46,6 @@ module.exports = [
|
|
|
46
46
|
i18n._("Choose all answers that apply:", {}),
|
|
47
47
|
i18n._("Click each dot on the image to select all answers that apply.", {}),
|
|
48
48
|
i18n._("Click each dot on the image to select an answer.", {}),
|
|
49
|
-
i18n._("Click on the tiles to change the lights.", {}),
|
|
50
49
|
i18n._("Click to add points", {}),
|
|
51
50
|
i18n._("Click to add vertices", {}),
|
|
52
51
|
i18n._("close math keypad", {}),
|
|
@@ -86,7 +85,6 @@ module.exports = [
|
|
|
86
85
|
i18n._("Make circle open", {}),
|
|
87
86
|
i18n._("Make sure you fill in all cells in the matrix.", {}),
|
|
88
87
|
i18n._("Make sure you select something for every row.", {}),
|
|
89
|
-
i18n.ngettext("Moves: %(num)s","Moves: %(num)s", {}),
|
|
90
88
|
i18n._("Next question", {}),
|
|
91
89
|
i18n._("No", {}),
|
|
92
90
|
i18n._("None of the above", {}),
|
|
@@ -95,7 +93,6 @@ module.exports = [
|
|
|
95
93
|
i18n._("open math keypad", {}),
|
|
96
94
|
i18n._("Please choose the correct number of answers.", {}),
|
|
97
95
|
i18n.$_("Please make sure the number of divisions is in the range %(divRangeString)s.", {}),
|
|
98
|
-
i18n._("Reaction arrow pointing to the right.", {}),
|
|
99
96
|
i18n._("Remove highlight", {}),
|
|
100
97
|
i18n._("See video transcript", {}),
|
|
101
98
|
i18n._("Skip to %(title)s", {}),
|
|
@@ -113,7 +110,6 @@ module.exports = [
|
|
|
113
110
|
i18n._("We could not understand your answer. Please check your answer for extra text or symbols.", {}),
|
|
114
111
|
i18n._("We couldn't grade your answer.", {}),
|
|
115
112
|
i18n._("Yes", {}),
|
|
116
|
-
i18n._("You must turn on all of the lights to continue.", {}),
|
|
117
113
|
i18n._("Your answer includes a wrong variable letter.", {}),
|
|
118
114
|
i18n._("Your answer includes use of a variable with the wrong case.", {}),
|
|
119
115
|
i18n._("Your answer is almost correct, but it is missing a <code>\\%</code> at the end.", {}),
|
package/dist/types.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ type TrackInteractionArgs = {
|
|
|
77
77
|
id: string;
|
|
78
78
|
correct?: boolean;
|
|
79
79
|
} & Partial<TrackingGradedGroupExtraArguments> & Partial<TrackingSequenceExtraArguments>;
|
|
80
|
+
export declare const MafsFlags: readonly ["segment", "linear", "linear-system", "ray", "polygon"];
|
|
80
81
|
/**
|
|
81
82
|
* APIOptions provides different ways to customize the behaviour of Perseus.
|
|
82
83
|
*
|
|
@@ -198,7 +199,16 @@ export type APIOptions = Readonly<{
|
|
|
198
199
|
*/
|
|
199
200
|
editorChangeDelay?: number;
|
|
200
201
|
/** Feature flags that can be passed from consuming application. */
|
|
201
|
-
flags?:
|
|
202
|
+
flags?: {
|
|
203
|
+
/**
|
|
204
|
+
* Flags related to the interactive-graph Mafs migration.
|
|
205
|
+
*
|
|
206
|
+
* Add values to the `MafsFlags` array to create new flags.
|
|
207
|
+
*/
|
|
208
|
+
mafs?: false | {
|
|
209
|
+
[Key in (typeof MafsFlags)[number]]?: boolean;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
202
212
|
/**
|
|
203
213
|
* This is a callback function that returns all of the Widget props
|
|
204
214
|
* after they have been transformed by the widget's transform function.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function pathBuilder(): PathBuilder;
|
|
2
|
+
export declare class PathBuilder {
|
|
3
|
+
private path;
|
|
4
|
+
private scaleFactor;
|
|
5
|
+
build(): string;
|
|
6
|
+
move(x: number, y: number): PathBuilder;
|
|
7
|
+
curve(control1X: number, control1Y: number, control2X: number, control2Y: number, endX: number, endY: number): PathBuilder;
|
|
8
|
+
scale(factor: number): PathBuilder;
|
|
9
|
+
}
|
|
@@ -123,7 +123,15 @@ declare const _default: Readonly<{
|
|
|
123
123
|
inModal?: boolean | undefined;
|
|
124
124
|
crossOutEnabled?: boolean | undefined;
|
|
125
125
|
editorChangeDelay?: number | undefined;
|
|
126
|
-
flags?:
|
|
126
|
+
flags?: {
|
|
127
|
+
mafs?: false | {
|
|
128
|
+
polygon?: boolean | undefined;
|
|
129
|
+
linear?: boolean | undefined;
|
|
130
|
+
segment?: boolean | undefined;
|
|
131
|
+
"linear-system"?: boolean | undefined;
|
|
132
|
+
ray?: boolean | undefined;
|
|
133
|
+
} | undefined;
|
|
134
|
+
} | undefined;
|
|
127
135
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
128
136
|
}> & {
|
|
129
137
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
@@ -190,7 +198,15 @@ declare const _default: Readonly<{
|
|
|
190
198
|
inModal?: boolean | undefined;
|
|
191
199
|
crossOutEnabled?: boolean | undefined;
|
|
192
200
|
editorChangeDelay?: number | undefined;
|
|
193
|
-
flags?:
|
|
201
|
+
flags?: {
|
|
202
|
+
mafs?: false | {
|
|
203
|
+
polygon?: boolean | undefined;
|
|
204
|
+
linear?: boolean | undefined;
|
|
205
|
+
segment?: boolean | undefined;
|
|
206
|
+
"linear-system"?: boolean | undefined;
|
|
207
|
+
ray?: boolean | undefined;
|
|
208
|
+
} | undefined;
|
|
209
|
+
} | undefined;
|
|
194
210
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
195
211
|
}> & {
|
|
196
212
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
@@ -257,7 +273,15 @@ declare const _default: Readonly<{
|
|
|
257
273
|
inModal?: boolean | undefined;
|
|
258
274
|
crossOutEnabled?: boolean | undefined;
|
|
259
275
|
editorChangeDelay?: number | undefined;
|
|
260
|
-
flags?:
|
|
276
|
+
flags?: {
|
|
277
|
+
mafs?: false | {
|
|
278
|
+
polygon?: boolean | undefined;
|
|
279
|
+
linear?: boolean | undefined;
|
|
280
|
+
segment?: boolean | undefined;
|
|
281
|
+
"linear-system"?: boolean | undefined;
|
|
282
|
+
ray?: boolean | undefined;
|
|
283
|
+
} | undefined;
|
|
284
|
+
} | undefined;
|
|
261
285
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
262
286
|
}> & {
|
|
263
287
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
@@ -321,7 +345,15 @@ declare const _default: Readonly<{
|
|
|
321
345
|
inModal?: boolean | undefined;
|
|
322
346
|
crossOutEnabled?: boolean | undefined;
|
|
323
347
|
editorChangeDelay?: number | undefined;
|
|
324
|
-
flags?:
|
|
348
|
+
flags?: {
|
|
349
|
+
mafs?: false | {
|
|
350
|
+
polygon?: boolean | undefined;
|
|
351
|
+
linear?: boolean | undefined;
|
|
352
|
+
segment?: boolean | undefined;
|
|
353
|
+
"linear-system"?: boolean | undefined;
|
|
354
|
+
ray?: boolean | undefined;
|
|
355
|
+
} | undefined;
|
|
356
|
+
} | undefined;
|
|
325
357
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
326
358
|
}> & {
|
|
327
359
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
@@ -388,7 +420,15 @@ declare const _default: Readonly<{
|
|
|
388
420
|
inModal?: boolean | undefined;
|
|
389
421
|
crossOutEnabled?: boolean | undefined;
|
|
390
422
|
editorChangeDelay?: number | undefined;
|
|
391
|
-
flags?:
|
|
423
|
+
flags?: {
|
|
424
|
+
mafs?: false | {
|
|
425
|
+
polygon?: boolean | undefined;
|
|
426
|
+
linear?: boolean | undefined;
|
|
427
|
+
segment?: boolean | undefined;
|
|
428
|
+
"linear-system"?: boolean | undefined;
|
|
429
|
+
ray?: boolean | undefined;
|
|
430
|
+
} | undefined;
|
|
431
|
+
} | undefined;
|
|
392
432
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
393
433
|
}> & {
|
|
394
434
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
@@ -455,7 +495,15 @@ declare const _default: Readonly<{
|
|
|
455
495
|
inModal?: boolean | undefined;
|
|
456
496
|
crossOutEnabled?: boolean | undefined;
|
|
457
497
|
editorChangeDelay?: number | undefined;
|
|
458
|
-
flags?:
|
|
498
|
+
flags?: {
|
|
499
|
+
mafs?: false | {
|
|
500
|
+
polygon?: boolean | undefined;
|
|
501
|
+
linear?: boolean | undefined;
|
|
502
|
+
segment?: boolean | undefined;
|
|
503
|
+
"linear-system"?: boolean | undefined;
|
|
504
|
+
ray?: boolean | undefined;
|
|
505
|
+
} | undefined;
|
|
506
|
+
} | undefined;
|
|
459
507
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
460
508
|
}> & {
|
|
461
509
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
export declare const showTickLabel: (gridStep: number, tickStep: number, label: number) => boolean;
|
|
2
3
|
export declare function generateTickLocations(tickStep: number, min: number, max: number): number[];
|
|
3
4
|
type Props = {
|
|
4
5
|
tickStep: [number, number];
|
|
5
6
|
range: [[number, number], [number, number]];
|
|
7
|
+
gridStep: [number, number];
|
|
6
8
|
};
|
|
7
9
|
export declare const AxisTicks: (props: Props) => JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { vec } from "mafs";
|
|
2
|
+
import type { SVGProps } from "react";
|
|
3
|
+
export type Props = {
|
|
4
|
+
start: vec.Vector2;
|
|
5
|
+
end: vec.Vector2;
|
|
6
|
+
style?: SVGProps<SVGLineElement>["style"];
|
|
7
|
+
className?: string;
|
|
8
|
+
testId?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function SVGLine(props: Props): JSX.Element;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Interval, vec } from "mafs";
|
|
1
|
+
import type { vec } from "mafs";
|
|
3
2
|
export interface InteractiveLineProps {
|
|
4
|
-
|
|
5
|
-
snaps: [number, number];
|
|
6
|
-
range: [x: Interval, y: Interval];
|
|
3
|
+
points: Readonly<[vec.Vector2, vec.Vector2]>;
|
|
7
4
|
onMovePoint: (endpointIndex: number, destination: vec.Vector2) => unknown;
|
|
8
5
|
onMoveLine: (delta: vec.Vector2) => unknown;
|
|
9
6
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { PerseusGraphType } from "../../../perseus-types";
|
|
2
|
-
import type { InteractiveGraphState } from "../types";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
2
|
+
import type { InteractiveGraphProps, InteractiveGraphState } from "../types";
|
|
3
|
+
export type InitializeGraphStateParam = {
|
|
4
|
+
range: InteractiveGraphProps["range"];
|
|
5
|
+
step: InteractiveGraphProps["step"];
|
|
6
|
+
snapStep: InteractiveGraphProps["snapStep"];
|
|
7
|
+
graph: InteractiveGraphProps["graph"];
|
|
8
|
+
markings: InteractiveGraphProps["markings"];
|
|
9
|
+
};
|
|
10
|
+
export declare function initializeGraphState(params: InitializeGraphStateParam): InteractiveGraphState;
|
|
10
11
|
export declare function getGradableGraph(state: InteractiveGraphState, initialGraph: PerseusGraphType): PerseusGraphType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Interval, vec } from "mafs";
|
|
3
|
+
type GraphConfig = {
|
|
4
|
+
range: [Interval, Interval];
|
|
5
|
+
snapStep: vec.Vector2;
|
|
6
|
+
markings: "graph" | "grid" | "none";
|
|
7
|
+
};
|
|
8
|
+
export declare const GraphConfigContext: React.Context<GraphConfig>;
|
|
9
|
+
export default function useGraphConfig(): GraphConfig;
|
|
10
|
+
export {};
|
|
@@ -18,6 +18,7 @@ export interface InteractiveGraphStateCommon {
|
|
|
18
18
|
hasBeenInteractedWith: boolean;
|
|
19
19
|
range: [Interval, Interval];
|
|
20
20
|
snapStep: vec.Vector2;
|
|
21
|
+
markings: InteractiveGraphProps["markings"];
|
|
21
22
|
}
|
|
22
23
|
export interface SegmentGraphState extends InteractiveGraphStateCommon {
|
|
23
24
|
type: "segment";
|
|
@@ -122,7 +122,15 @@ declare const _default: Readonly<{
|
|
|
122
122
|
inModal?: boolean | undefined;
|
|
123
123
|
crossOutEnabled?: boolean | undefined;
|
|
124
124
|
editorChangeDelay?: number | undefined;
|
|
125
|
-
flags?:
|
|
125
|
+
flags?: {
|
|
126
|
+
mafs?: false | {
|
|
127
|
+
polygon?: boolean | undefined;
|
|
128
|
+
linear?: boolean | undefined;
|
|
129
|
+
segment?: boolean | undefined;
|
|
130
|
+
"linear-system"?: boolean | undefined;
|
|
131
|
+
ray?: boolean | undefined;
|
|
132
|
+
} | undefined;
|
|
133
|
+
} | undefined;
|
|
126
134
|
onWidgetStartProps?: ((widgets: import("..").PerseusWidgetsMap) => void) | undefined;
|
|
127
135
|
}>;
|
|
128
136
|
choices: readonly string[];
|
|
@@ -171,7 +179,15 @@ declare const _default: Readonly<{
|
|
|
171
179
|
inModal?: boolean | undefined;
|
|
172
180
|
crossOutEnabled?: boolean | undefined;
|
|
173
181
|
editorChangeDelay?: number | undefined;
|
|
174
|
-
flags?:
|
|
182
|
+
flags?: {
|
|
183
|
+
mafs?: false | {
|
|
184
|
+
polygon?: boolean | undefined;
|
|
185
|
+
linear?: boolean | undefined;
|
|
186
|
+
segment?: boolean | undefined;
|
|
187
|
+
"linear-system"?: boolean | undefined;
|
|
188
|
+
ray?: boolean | undefined;
|
|
189
|
+
} | undefined;
|
|
190
|
+
} | undefined;
|
|
175
191
|
onWidgetStartProps?: ((widgets: import("..").PerseusWidgetsMap) => void) | undefined;
|
|
176
192
|
}>;
|
|
177
193
|
choices: readonly string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { FocusFunction } from "./base-radio";
|
|
3
|
-
import type { PerseusRadioChoice, PerseusRadioWidgetOptions } from "../../perseus-types";
|
|
3
|
+
import type { PerseusRadioChoice, PerseusRadioWidgetOptions, ShowSolutions } from "../../perseus-types";
|
|
4
4
|
import type { PerseusScore, WidgetProps, ChoiceState } from "../../types";
|
|
5
5
|
export type RenderProps = {
|
|
6
6
|
numCorrect: number;
|
|
@@ -10,6 +10,7 @@ export type RenderProps = {
|
|
|
10
10
|
deselectEnabled?: boolean;
|
|
11
11
|
choices: ReadonlyArray<RadioChoiceWithMetadata>;
|
|
12
12
|
selectedChoices: ReadonlyArray<PerseusRadioChoice["correct"]>;
|
|
13
|
+
showSolutions?: ShowSolutions;
|
|
13
14
|
choiceStates?: ReadonlyArray<ChoiceState>;
|
|
14
15
|
values?: ReadonlyArray<boolean>;
|
|
15
16
|
};
|
|
@@ -22,13 +23,7 @@ type UserInput = {
|
|
|
22
23
|
};
|
|
23
24
|
type Rubric = PerseusRadioWidgetOptions;
|
|
24
25
|
type Props = WidgetProps<RenderProps, Rubric>;
|
|
25
|
-
type DefaultProps =
|
|
26
|
-
choices: Props["choices"];
|
|
27
|
-
multipleSelect: Props["multipleSelect"];
|
|
28
|
-
countChoices: Props["countChoices"];
|
|
29
|
-
deselectEnabled: Props["deselectEnabled"];
|
|
30
|
-
linterContext: Props["linterContext"];
|
|
31
|
-
};
|
|
26
|
+
type DefaultProps = Required<Pick<Props, "choices" | "multipleSelect" | "countChoices" | "deselectEnabled" | "linterContext" | "showSolutions">>;
|
|
32
27
|
export type RadioChoiceWithMetadata = PerseusRadioChoice & {
|
|
33
28
|
originalIndex: number;
|
|
34
29
|
correct: boolean;
|
|
@@ -38,6 +33,7 @@ declare class Radio extends React.Component<Props> {
|
|
|
38
33
|
static defaultProps: DefaultProps;
|
|
39
34
|
static validate(userInput: UserInput, rubric: Rubric): PerseusScore;
|
|
40
35
|
static getUserInputFromProps(props: Props): UserInput;
|
|
36
|
+
componentDidUpdate(prevProps: Props): void;
|
|
41
37
|
_renderRenderer: (content?: string) => React.ReactElement;
|
|
42
38
|
focus(choiceIndex?: number | null): boolean;
|
|
43
39
|
registerFocusFunction(fun: FocusFunction): void;
|
|
@@ -51,6 +47,7 @@ declare class Radio extends React.Component<Props> {
|
|
|
51
47
|
* Turn on rationale display for the currently selected choices. Note that
|
|
52
48
|
* this leaves rationales on for choices that are already showing
|
|
53
49
|
* rationales.
|
|
50
|
+
* @deprecated Internal only. Use `showSolutions` prop instead.
|
|
54
51
|
*/
|
|
55
52
|
showRationalesForCurrentlySelectedChoices: (arg1: PerseusRadioWidgetOptions) => void;
|
|
56
53
|
/**
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { InteractiveGraphAction } from "./interactive-graph-action";
|
|
3
|
-
import type { InteractiveGraphState } from "../types";
|
|
4
|
-
export declare const GraphStateContext: React.Context<{
|
|
5
|
-
state: InteractiveGraphState;
|
|
6
|
-
dispatch: React.Dispatch<InteractiveGraphAction>;
|
|
7
|
-
}>;
|
|
8
|
-
export default function useGraphState(): {
|
|
9
|
-
state: InteractiveGraphState;
|
|
10
|
-
dispatch: React.Dispatch<InteractiveGraphAction>;
|
|
11
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as Changeable from "../mixins/changeable";
|
|
3
|
-
import type { PerseusLightsPuzzleWidgetOptions } from "../perseus-types";
|
|
4
|
-
type LightsPuzzleProps = Changeable.ChangeableProps & {
|
|
5
|
-
cells: PerseusLightsPuzzleWidgetOptions["cells"];
|
|
6
|
-
startCells: PerseusLightsPuzzleWidgetOptions["startCells"];
|
|
7
|
-
flipPattern: PerseusLightsPuzzleWidgetOptions["flipPattern"];
|
|
8
|
-
moveCount: PerseusLightsPuzzleWidgetOptions["moveCount"];
|
|
9
|
-
};
|
|
10
|
-
type DefaultProps = {
|
|
11
|
-
cells: LightsPuzzleProps["cells"];
|
|
12
|
-
startCells: LightsPuzzleProps["startCells"];
|
|
13
|
-
flipPattern: LightsPuzzleProps["flipPattern"];
|
|
14
|
-
moveCount: LightsPuzzleProps["moveCount"];
|
|
15
|
-
};
|
|
16
|
-
declare class LightsPuzzle extends React.Component<LightsPuzzleProps> {
|
|
17
|
-
_currPattern: any;
|
|
18
|
-
_nextPattern: any;
|
|
19
|
-
_patternIndex: number;
|
|
20
|
-
static defaultProps: DefaultProps;
|
|
21
|
-
getUserInput: () => any;
|
|
22
|
-
render(): React.ReactNode;
|
|
23
|
-
change: (...args: ReadonlyArray<unknown>) => any;
|
|
24
|
-
_width: () => number;
|
|
25
|
-
componentDidMount(): void;
|
|
26
|
-
componentDidUpdate(prevProps: any): void;
|
|
27
|
-
_initNextPatterns: () => void;
|
|
28
|
-
_shiftPatterns: () => void;
|
|
29
|
-
_flipTile: (FlipCoords: any) => void;
|
|
30
|
-
_reset: () => void;
|
|
31
|
-
simpleValidate: (arg1: any) => any;
|
|
32
|
-
}
|
|
33
|
-
declare const _default: Readonly<{
|
|
34
|
-
name: string;
|
|
35
|
-
displayName: string;
|
|
36
|
-
getWidget?: (() => typeof LightsPuzzle) | undefined;
|
|
37
|
-
widget: typeof LightsPuzzle;
|
|
38
|
-
accessible?: boolean | ((props: any) => boolean) | undefined;
|
|
39
|
-
hidden?: boolean | undefined;
|
|
40
|
-
version?: import("../types").Version | undefined;
|
|
41
|
-
supportedAlignments?: readonly import("../types").Alignment[] | undefined;
|
|
42
|
-
defaultAlignment?: import("../types").Alignment | undefined;
|
|
43
|
-
getDefaultAlignment?: (() => import("../types").Alignment) | undefined;
|
|
44
|
-
isLintable?: boolean | undefined;
|
|
45
|
-
tracking?: import("../types").Tracking | undefined;
|
|
46
|
-
traverseChildWidgets?: any;
|
|
47
|
-
transform?: import("../types").WidgetTransform | undefined;
|
|
48
|
-
staticTransform?: import("../types").WidgetTransform | undefined;
|
|
49
|
-
propUpgrades?: {
|
|
50
|
-
[key: string]: (arg1: any) => any;
|
|
51
|
-
} | undefined;
|
|
52
|
-
}>;
|
|
53
|
-
export default _default;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { PerseusReactionDiagramWidgetOptions } from "../perseus-types";
|
|
3
|
-
type ReactionDiagramProps = {
|
|
4
|
-
rotationAngle: PerseusReactionDiagramWidgetOptions["rotationAngle"];
|
|
5
|
-
separators: PerseusReactionDiagramWidgetOptions["separators"];
|
|
6
|
-
smiles: PerseusReactionDiagramWidgetOptions["smiles"];
|
|
7
|
-
widgetId: PerseusReactionDiagramWidgetOptions["widgetId"];
|
|
8
|
-
};
|
|
9
|
-
type DefaultProps = {
|
|
10
|
-
rotationAngle: ReactionDiagramProps["rotationAngle"];
|
|
11
|
-
separators: ReactionDiagramProps["separators"];
|
|
12
|
-
smiles: ReactionDiagramProps["smiles"];
|
|
13
|
-
};
|
|
14
|
-
declare class ReactionDiagramWidget extends React.Component<ReactionDiagramProps> {
|
|
15
|
-
static defaultProps: DefaultProps;
|
|
16
|
-
simpleValidate: (arg1: any) => any;
|
|
17
|
-
getUserInput: () => any;
|
|
18
|
-
validate: (arg1: any, arg2: any) => any;
|
|
19
|
-
focus: () => boolean;
|
|
20
|
-
render(): React.ReactNode;
|
|
21
|
-
}
|
|
22
|
-
declare const _default: Readonly<{
|
|
23
|
-
name: string;
|
|
24
|
-
displayName: string;
|
|
25
|
-
getWidget?: (() => typeof ReactionDiagramWidget) | undefined;
|
|
26
|
-
widget: typeof ReactionDiagramWidget;
|
|
27
|
-
accessible?: boolean | ((props: any) => boolean) | undefined;
|
|
28
|
-
hidden?: boolean | undefined;
|
|
29
|
-
version?: import("../types").Version | undefined;
|
|
30
|
-
supportedAlignments?: readonly import("../types").Alignment[] | undefined;
|
|
31
|
-
defaultAlignment?: import("../types").Alignment | undefined;
|
|
32
|
-
getDefaultAlignment?: (() => import("../types").Alignment) | undefined;
|
|
33
|
-
isLintable?: boolean | undefined;
|
|
34
|
-
tracking?: import("../types").Tracking | undefined;
|
|
35
|
-
traverseChildWidgets?: any;
|
|
36
|
-
transform?: import("../types").WidgetTransform | undefined;
|
|
37
|
-
staticTransform?: import("../types").WidgetTransform | undefined;
|
|
38
|
-
propUpgrades?: {
|
|
39
|
-
[key: string]: (arg1: any) => any;
|
|
40
|
-
} | undefined;
|
|
41
|
-
}>;
|
|
42
|
-
export default _default;
|