@khanacademy/perseus 19.7.3 → 19.8.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.js +262 -174
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +255 -166
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +1 -1
- package/dist/perseus-types.d.ts +140 -21
- package/dist/renderer.d.ts +4 -6
- package/dist/server-item-renderer.d.ts +1 -1
- package/dist/types.d.ts +2 -5
- package/dist/widgets/expression.d.ts +6 -6
- package/dist/widgets/interactive-graphs/graphs/segment.d.ts +3 -2
- package/dist/widgets/interactive-graphs/interactive-graph-action.d.ts +17 -0
- package/dist/widgets/interactive-graphs/interactive-graph-reducer.d.ts +3 -0
- package/dist/widgets/interactive-graphs/interactive-graph-state.d.ts +19 -0
- package/dist/widgets/interactive-graphs/mafs-graph.d.ts +1 -1
- package/dist/widgets/interactive-graphs/types.d.ts +6 -6
- package/dist/widgets/interactive-graphs/utils.d.ts +3 -14
- package/dist/widgets/label-image.d.ts +2 -12
- package/dist/widgets/lights-puzzle.d.ts +17 -11
- package/dist/widgets/molecule.d.ts +17 -15
- package/dist/widgets/passage-ref-target.d.ts +15 -13
- package/dist/widgets/reaction-diagram.d.ts +14 -9
- package/dist/widgets/unit.d.ts +2 -1
- package/package.json +1 -1
package/dist/perseus-api.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ export declare const ApiOptions: {
|
|
|
95
95
|
inModal?: boolean | undefined;
|
|
96
96
|
crossOutEnabled?: boolean | undefined;
|
|
97
97
|
editorChangeDelay?: number | undefined;
|
|
98
|
-
onWidgetStartProps?: ((widgets: import("./types").PerseusWidgetMap) => import("./types").PerseusWidgetMap) | undefined;
|
|
99
98
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
99
|
+
onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => import("./perseus-types").PerseusWidgetsMap) | undefined;
|
|
100
100
|
}> & {
|
|
101
101
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
102
102
|
baseElements: {
|
package/dist/perseus-types.d.ts
CHANGED
|
@@ -6,6 +6,87 @@ type StyleParams = {
|
|
|
6
6
|
stroke?: string;
|
|
7
7
|
};
|
|
8
8
|
type Empty = Record<never, never>;
|
|
9
|
+
export type PerseusWidgetsMap = {
|
|
10
|
+
[key in `categorizer ${number}`]: CategorizerWidget;
|
|
11
|
+
} & {
|
|
12
|
+
[key in `cs-program ${number}`]: CSProgramWidget;
|
|
13
|
+
} & {
|
|
14
|
+
[key in `definition ${number}`]: DefinitionWidget;
|
|
15
|
+
} & {
|
|
16
|
+
[key in `dropdown ${number}`]: DropdownWidget;
|
|
17
|
+
} & {
|
|
18
|
+
[key in `example-widget ${number}`]: ExampleWidget;
|
|
19
|
+
} & {
|
|
20
|
+
[key in `example-graphie-widget ${number}`]: ExampleGraphieWidget;
|
|
21
|
+
} & {
|
|
22
|
+
[key in `explanation ${number}`]: ExplanationWidget;
|
|
23
|
+
} & {
|
|
24
|
+
[key in `expression ${number}`]: ExpressionWidget;
|
|
25
|
+
} & {
|
|
26
|
+
[key in `grapher ${number}`]: GrapherWidget;
|
|
27
|
+
} & {
|
|
28
|
+
[key in `group ${number}`]: GroupWidget;
|
|
29
|
+
} & {
|
|
30
|
+
[key in `graded-group ${number}`]: GradedGroupWidget;
|
|
31
|
+
} & {
|
|
32
|
+
[key in `graded-group-set ${number}`]: GradedGroupSetWidget;
|
|
33
|
+
} & {
|
|
34
|
+
[key in `iframe ${number}`]: IFrameWidget;
|
|
35
|
+
} & {
|
|
36
|
+
[key in `image ${number}`]: ImageWidget;
|
|
37
|
+
} & {
|
|
38
|
+
[key in `input-number ${number}`]: InputNumberWidget;
|
|
39
|
+
} & {
|
|
40
|
+
[key in `interaction ${number}`]: InteractionWidget;
|
|
41
|
+
} & {
|
|
42
|
+
[key in `interactive-graph ${number}`]: InteractiveGraphWidget;
|
|
43
|
+
} & {
|
|
44
|
+
[key in `label-image ${number}`]: LabelImageWidget;
|
|
45
|
+
} & {
|
|
46
|
+
[key in `lights-puzzle ${number}`]: LightsPuzzleWidget;
|
|
47
|
+
} & {
|
|
48
|
+
[key in `matcher ${number}`]: MatcherWidget;
|
|
49
|
+
} & {
|
|
50
|
+
[key in `matrix ${number}`]: MatrixWidget;
|
|
51
|
+
} & {
|
|
52
|
+
[key in `measurer ${number}`]: MeasurerWidget;
|
|
53
|
+
} & {
|
|
54
|
+
[key in `molecule-renderer ${number}`]: MoleculeRendererWidget;
|
|
55
|
+
} & {
|
|
56
|
+
[key in `number-line ${number}`]: NumberLineWidget;
|
|
57
|
+
} & {
|
|
58
|
+
[key in `numeric-input ${number}`]: NumericInputWidget;
|
|
59
|
+
} & {
|
|
60
|
+
[key in `orderer ${number}`]: OrdererWidget;
|
|
61
|
+
} & {
|
|
62
|
+
[key in `passage ${number}`]: PassageWidget;
|
|
63
|
+
} & {
|
|
64
|
+
[key in `passage-ref ${number}`]: PassageRefWidget;
|
|
65
|
+
} & {
|
|
66
|
+
[key in `passage-ref-target ${number}`]: PassageRefWidget;
|
|
67
|
+
} & {
|
|
68
|
+
[key in `plotter ${number}`]: PlotterWidget;
|
|
69
|
+
} & {
|
|
70
|
+
[key in `python-program ${number}`]: PythonProgramWidget;
|
|
71
|
+
} & {
|
|
72
|
+
[key in `radio ${number}`]: RadioWidget;
|
|
73
|
+
} & {
|
|
74
|
+
[key in `reaction-diagram ${number}`]: ReactionDiagramWidget;
|
|
75
|
+
} & {
|
|
76
|
+
[key in `sequence ${number}`]: SequenceWidget;
|
|
77
|
+
} & {
|
|
78
|
+
[key in `simple-markdown-tester ${number}`]: SimpleMarkdownTesterWidget;
|
|
79
|
+
} & {
|
|
80
|
+
[key in `simulator ${number}`]: SimulatorWidget;
|
|
81
|
+
} & {
|
|
82
|
+
[key in `sorter ${number}`]: SorterWidget;
|
|
83
|
+
} & {
|
|
84
|
+
[key in `table ${number}`]: TableWidget;
|
|
85
|
+
} & {
|
|
86
|
+
[key in `unit-input ${number}`]: UnitInputWidget;
|
|
87
|
+
} & {
|
|
88
|
+
[key in `video ${number}`]: VideoWidget;
|
|
89
|
+
};
|
|
9
90
|
export type PerseusItem = {
|
|
10
91
|
question: PerseusRenderer;
|
|
11
92
|
hints: ReadonlyArray<PerseusRenderer>;
|
|
@@ -21,9 +102,7 @@ export type Version = {
|
|
|
21
102
|
};
|
|
22
103
|
export type PerseusRenderer = {
|
|
23
104
|
content: string;
|
|
24
|
-
widgets:
|
|
25
|
-
[key: string]: PerseusWidget;
|
|
26
|
-
};
|
|
105
|
+
widgets: PerseusWidgetsMap;
|
|
27
106
|
replace?: boolean;
|
|
28
107
|
metadata?: ReadonlyArray<string>;
|
|
29
108
|
images: {
|
|
@@ -81,7 +160,7 @@ export type InputNumberWidget = Widget<'input-number', PerseusInputNumberWidgetO
|
|
|
81
160
|
export type LightsPuzzleWidget = Widget<'lights-puzzle', PerseusLightsPuzzleWidgetOptions>;
|
|
82
161
|
export type MoleculeRendererWidget = Widget<'molecule-renderer', PerseusMoleculeRendererWidgetOptions>;
|
|
83
162
|
export type RefTargetWidget = Widget<'passage-ref-target', PerseusPassageRefTargetWidgetOptions>;
|
|
84
|
-
export type ReactionDiagramWidget = Widget<'reaction-
|
|
163
|
+
export type ReactionDiagramWidget = Widget<'reaction-diagram', PerseusReactionDiagramWidgetOptions>;
|
|
85
164
|
export type SimpleMarkdownTesterWidget = Widget<'simple-markdown-tester', PerseusSimpleMarkdownTesterWidgetOptions>;
|
|
86
165
|
export type UnitInputWidget = Widget<'unit-input', PerseusUnitInputWidgetOptions>;
|
|
87
166
|
export type VideoWidget = Widget<'video', PerseusVideoWidgetOptions>;
|
|
@@ -124,13 +203,30 @@ export type PerseusDropdownChoice = {
|
|
|
124
203
|
content: string;
|
|
125
204
|
correct: boolean;
|
|
126
205
|
};
|
|
206
|
+
export type PerseusExampleWidgetOptions = {
|
|
207
|
+
value: string;
|
|
208
|
+
};
|
|
209
|
+
export type PerseusExampleGraphieGraph = {
|
|
210
|
+
box: Size;
|
|
211
|
+
range: [Coord, Coord];
|
|
212
|
+
labels: ReadonlyArray<string>;
|
|
213
|
+
markings: "graph" | "grid" | "none";
|
|
214
|
+
gridStep: [number, number];
|
|
215
|
+
step: [number, number];
|
|
216
|
+
showProtractor?: boolean;
|
|
217
|
+
showRuler?: boolean;
|
|
218
|
+
valid?: boolean;
|
|
219
|
+
backgroundImage?: PerseusImageBackground | null;
|
|
220
|
+
};
|
|
221
|
+
export type PerseusExampleGraphieWidgetOptions = {
|
|
222
|
+
graph: PerseusExampleGraphieGraph;
|
|
223
|
+
coord: [Coord, Coord] | null;
|
|
224
|
+
};
|
|
127
225
|
export type PerseusExplanationWidgetOptions = {
|
|
128
226
|
showPrompt: string;
|
|
129
227
|
hidePrompt: string;
|
|
130
228
|
explanation: string;
|
|
131
|
-
widgets:
|
|
132
|
-
[key: string]: PerseusWidget;
|
|
133
|
-
};
|
|
229
|
+
widgets: PerseusWidgetsMap;
|
|
134
230
|
static: boolean;
|
|
135
231
|
};
|
|
136
232
|
export type LegacyButtonSets = ReadonlyArray<"basic" | "basic+div" | "trig" | "prealgebra" | "logarithms" | "basic relations" | "advanced relations">;
|
|
@@ -154,9 +250,7 @@ export type PerseusGradedGroupWidgetOptions = {
|
|
|
154
250
|
hasHint?: boolean | null | undefined;
|
|
155
251
|
hint?: PerseusRenderer | null | undefined;
|
|
156
252
|
content: string;
|
|
157
|
-
widgets:
|
|
158
|
-
[key: string]: PerseusWidget;
|
|
159
|
-
};
|
|
253
|
+
widgets: PerseusWidgetsMap;
|
|
160
254
|
widgetEnabled?: boolean | null | undefined;
|
|
161
255
|
immutableWidgets?: boolean | null | undefined;
|
|
162
256
|
images: {
|
|
@@ -342,6 +436,12 @@ export type PerseusLabelImageMarker = {
|
|
|
342
436
|
x: number;
|
|
343
437
|
y: number;
|
|
344
438
|
};
|
|
439
|
+
export type PerseusLightsPuzzleWidgetOptions = {
|
|
440
|
+
cells?: ReadonlyArray<ReadonlyArray<boolean>>;
|
|
441
|
+
startCells?: ReadonlyArray<ReadonlyArray<boolean>>;
|
|
442
|
+
flipPattern?: string;
|
|
443
|
+
moveCount?: number;
|
|
444
|
+
};
|
|
345
445
|
export type PerseusMatcherWidgetOptions = {
|
|
346
446
|
labels: ReadonlyArray<string>;
|
|
347
447
|
left: ReadonlyArray<string>;
|
|
@@ -460,9 +560,7 @@ export type PerseusRadioChoice = {
|
|
|
460
560
|
clue?: string;
|
|
461
561
|
correct?: boolean;
|
|
462
562
|
isNoneOfTheAbove?: boolean;
|
|
463
|
-
widgets?:
|
|
464
|
-
[key: string]: PerseusWidget;
|
|
465
|
-
};
|
|
563
|
+
widgets?: PerseusWidgetsMap;
|
|
466
564
|
};
|
|
467
565
|
export type PerseusSequenceWidgetOptions = {
|
|
468
566
|
json: ReadonlyArray<PerseusRenderer>;
|
|
@@ -687,13 +785,34 @@ export type PerseusInputNumberWidgetOptions = {
|
|
|
687
785
|
value: string | number;
|
|
688
786
|
customKeypad?: boolean;
|
|
689
787
|
};
|
|
690
|
-
export type
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
export type
|
|
696
|
-
|
|
697
|
-
|
|
788
|
+
export type PerseusMoleculeRendererWidgetOptions = {
|
|
789
|
+
widgetId: string;
|
|
790
|
+
rotationAngle?: number;
|
|
791
|
+
smiles?: string;
|
|
792
|
+
};
|
|
793
|
+
export type PerseusPassageRefTargetWidgetOptions = {
|
|
794
|
+
content: string;
|
|
795
|
+
};
|
|
796
|
+
export type PerseusReactionDiagramWidgetOptions = {
|
|
797
|
+
rotationAngle: ReadonlyArray<number>;
|
|
798
|
+
widgetId: string;
|
|
799
|
+
separators: ReadonlyArray<PerseusReactionDiagramSeparators>;
|
|
800
|
+
smiles: ReadonlyArray<string>;
|
|
801
|
+
};
|
|
802
|
+
export type PerseusReactionDiagramSeparators = {
|
|
803
|
+
type: string;
|
|
804
|
+
topText: string;
|
|
805
|
+
bottomText: string;
|
|
806
|
+
};
|
|
807
|
+
export type PerseusReactionDiagramSeparatorsData = {
|
|
808
|
+
topText: string;
|
|
809
|
+
bottomText: string;
|
|
810
|
+
};
|
|
811
|
+
export type PerseusSimpleMarkdownTesterWidgetOptions = {
|
|
812
|
+
value: string;
|
|
813
|
+
};
|
|
814
|
+
export type PerseusUnitInputWidgetOptions = {
|
|
815
|
+
value: string;
|
|
816
|
+
};
|
|
698
817
|
export type PerseusWidgetOptions = PerseusCategorizerWidgetOptions | PerseusCSProgramWidgetOptions | PerseusDefinitionWidgetOptions | PerseusDropdownWidgetOptions | PerseusExampleGraphieWidgetOptions | PerseusExampleWidgetOptions | PerseusExplanationWidgetOptions | PerseusExpressionWidgetOptions | PerseusGradedGroupSetWidgetOptions | PerseusGradedGroupWidgetOptions | PerseusIFrameWidgetOptions | PerseusImageWidgetOptions | PerseusInputNumberWidgetOptions | PerseusInteractionWidgetOptions | PerseusInteractiveGraphWidgetOptions | PerseusLabelImageWidgetOptions | PerseusLightsPuzzleWidgetOptions | PerseusMatcherWidgetOptions | PerseusMatrixWidgetOptions | PerseusMeasurerWidgetOptions | PerseusMoleculeRendererWidgetOptions | PerseusNumberLineWidgetOptions | PerseusNumericInputWidgetOptions | PerseusOrdererWidgetOptions | PerseusPassageRefTargetWidgetOptions | PerseusPassageRefWidgetOptions | PerseusPassageWidgetOptions | PerseusPlotterWidgetOptions | PerseusRadioWidgetOptions | PerseusReactionDiagramWidgetOptions | PerseusSequenceWidgetOptions | PerseusSimpleMarkdownTesterWidgetOptions | PerseusSimulatorWidgetOptions | PerseusSorterWidgetOptions | PerseusTableWidgetOptions | PerseusUnitInputWidgetOptions | PerseusVideoWidgetOptions;
|
|
699
818
|
export {};
|
package/dist/renderer.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ 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 } from "./perseus-types";
|
|
7
|
-
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, PerseusScore,
|
|
6
|
+
import type { PerseusRenderer, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap } from "./perseus-types";
|
|
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";
|
|
10
10
|
type WidgetState = {
|
|
@@ -123,10 +123,8 @@ declare class Renderer extends React.Component<Props, State> {
|
|
|
123
123
|
widgetInfo: State["widgetInfo"];
|
|
124
124
|
widgetProps: State["widgetProps"];
|
|
125
125
|
};
|
|
126
|
-
_getAllWidgetsInfo: (props: Props) =>
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
_getAllWidgetsStartProps: (allWidgetInfo: PerseusWidgetMap, props: Props) => PerseusWidgetMap;
|
|
126
|
+
_getAllWidgetsInfo: (props: Props) => PerseusWidgetsMap;
|
|
127
|
+
_getAllWidgetsStartProps: (allWidgetInfo: PerseusWidgetsMap, props: Props) => PerseusWidgetsMap;
|
|
130
128
|
_getDefaultWidgetInfo: (widgetId: string) => any;
|
|
131
129
|
_getWidgetInfo: (widgetId: string) => PerseusWidget;
|
|
132
130
|
renderWidget: (impliedType: string, id: string, state: WidgetState) => null | React.ReactNode;
|
|
@@ -137,8 +137,8 @@ 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
|
-
onWidgetStartProps?: ((widgets: import("./types").PerseusWidgetMap) => import("./types").PerseusWidgetMap) | undefined;
|
|
141
140
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
141
|
+
onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => import("./perseus-types").PerseusWidgetsMap) | undefined;
|
|
142
142
|
}> | undefined;
|
|
143
143
|
linterContext?: PerseusLinter.LinterContextProps | undefined;
|
|
144
144
|
onRendered?: ((isRendered: boolean) => void) | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ILogger } from "./logging/log";
|
|
2
2
|
import type { Item } from "./multi-items/item-types";
|
|
3
|
-
import type { PerseusAnswerArea, PerseusRenderer, PerseusWidget } from "./perseus-types";
|
|
3
|
+
import type { PerseusAnswerArea, PerseusRenderer, PerseusWidget, PerseusWidgetsMap } from "./perseus-types";
|
|
4
4
|
import type { SizeClass } from "./util/sizing-utils";
|
|
5
5
|
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
6
6
|
import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
|
|
@@ -105,8 +105,8 @@ export type APIOptions = Readonly<{
|
|
|
105
105
|
inModal?: boolean;
|
|
106
106
|
crossOutEnabled?: boolean;
|
|
107
107
|
editorChangeDelay?: number;
|
|
108
|
-
onWidgetStartProps?: (widgets: PerseusWidgetMap) => PerseusWidgetMap;
|
|
109
108
|
flags?: Record<string, boolean | Record<string, boolean>>;
|
|
109
|
+
onWidgetStartProps?: (widgets: PerseusWidgetsMap) => PerseusWidgetsMap;
|
|
110
110
|
}>;
|
|
111
111
|
type TeXProps = {
|
|
112
112
|
children: string;
|
|
@@ -246,9 +246,6 @@ export type WidgetExports<T extends React.ComponentType<any> = React.ComponentTy
|
|
|
246
246
|
[key: string]: (arg1: any) => any;
|
|
247
247
|
};
|
|
248
248
|
}>;
|
|
249
|
-
export type PerseusWidgetMap = {
|
|
250
|
-
[key: string]: PerseusWidget;
|
|
251
|
-
};
|
|
252
249
|
export type FilterCriterion = string | ((id: string, widgetInfo: PerseusWidget, widget?: Widget | null | undefined) => boolean);
|
|
253
250
|
export type WidgetProps<RenderProps, Rubric, TrackingExtraArgs = Empty> = RenderProps & {
|
|
254
251
|
widgetId: string;
|
|
@@ -123,8 +123,8 @@ declare const _default: Readonly<{
|
|
|
123
123
|
inModal?: boolean | undefined;
|
|
124
124
|
crossOutEnabled?: boolean | undefined;
|
|
125
125
|
editorChangeDelay?: number | undefined;
|
|
126
|
-
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
127
126
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
127
|
+
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => import("../perseus-types").PerseusWidgetsMap) | undefined;
|
|
128
128
|
}> & {
|
|
129
129
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
130
130
|
baseElements: {
|
|
@@ -190,8 +190,8 @@ declare const _default: Readonly<{
|
|
|
190
190
|
inModal?: boolean | undefined;
|
|
191
191
|
crossOutEnabled?: boolean | undefined;
|
|
192
192
|
editorChangeDelay?: number | undefined;
|
|
193
|
-
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
194
193
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
194
|
+
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => import("../perseus-types").PerseusWidgetsMap) | undefined;
|
|
195
195
|
}> & {
|
|
196
196
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
197
197
|
baseElements: {
|
|
@@ -257,8 +257,8 @@ declare const _default: Readonly<{
|
|
|
257
257
|
inModal?: boolean | undefined;
|
|
258
258
|
crossOutEnabled?: boolean | undefined;
|
|
259
259
|
editorChangeDelay?: number | undefined;
|
|
260
|
-
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
261
260
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
261
|
+
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => import("../perseus-types").PerseusWidgetsMap) | undefined;
|
|
262
262
|
}> & {
|
|
263
263
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
264
264
|
baseElements: {
|
|
@@ -321,8 +321,8 @@ declare const _default: Readonly<{
|
|
|
321
321
|
inModal?: boolean | undefined;
|
|
322
322
|
crossOutEnabled?: boolean | undefined;
|
|
323
323
|
editorChangeDelay?: number | undefined;
|
|
324
|
-
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
325
324
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
325
|
+
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => import("../perseus-types").PerseusWidgetsMap) | undefined;
|
|
326
326
|
}> & {
|
|
327
327
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
328
328
|
baseElements: {
|
|
@@ -388,8 +388,8 @@ declare const _default: Readonly<{
|
|
|
388
388
|
inModal?: boolean | undefined;
|
|
389
389
|
crossOutEnabled?: boolean | undefined;
|
|
390
390
|
editorChangeDelay?: number | undefined;
|
|
391
|
-
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
392
391
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
392
|
+
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => import("../perseus-types").PerseusWidgetsMap) | undefined;
|
|
393
393
|
}> & {
|
|
394
394
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
395
395
|
baseElements: {
|
|
@@ -455,8 +455,8 @@ declare const _default: Readonly<{
|
|
|
455
455
|
inModal?: boolean | undefined;
|
|
456
456
|
crossOutEnabled?: boolean | undefined;
|
|
457
457
|
editorChangeDelay?: number | undefined;
|
|
458
|
-
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
459
458
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
459
|
+
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => import("../perseus-types").PerseusWidgetsMap) | undefined;
|
|
460
460
|
}> & {
|
|
461
461
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
462
462
|
baseElements: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { SegmentGraphState } from "../interactive-graph-state";
|
|
3
3
|
import type { MafsGraphProps } from "../types";
|
|
4
|
-
|
|
4
|
+
type SegmentProps = MafsGraphProps<SegmentGraphState>;
|
|
5
5
|
export declare const SegmentGraph: (props: SegmentProps) => JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { vec } from "mafs";
|
|
2
|
+
export type InteractiveGraphAction = MoveControlPoint | MoveSegment;
|
|
3
|
+
export declare const MOVE_CONTROL_POINT = "move-control-point";
|
|
4
|
+
export interface MoveControlPoint {
|
|
5
|
+
type: typeof MOVE_CONTROL_POINT;
|
|
6
|
+
objectIndex: number;
|
|
7
|
+
pointIndex: number;
|
|
8
|
+
destination: vec.Vector2;
|
|
9
|
+
}
|
|
10
|
+
export declare function moveControlPoint(objectIndex: number, pointIndex: number, destination: vec.Vector2): MoveControlPoint;
|
|
11
|
+
export declare const MOVE_SEGMENT = "move-segment";
|
|
12
|
+
export interface MoveSegment {
|
|
13
|
+
type: typeof MOVE_SEGMENT;
|
|
14
|
+
segmentIndex: number;
|
|
15
|
+
delta: vec.Vector2;
|
|
16
|
+
}
|
|
17
|
+
export declare function moveSegment(segmentIndex: number, delta: vec.Vector2): MoveSegment;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { InteractiveGraphAction } from "./interactive-graph-action";
|
|
2
|
+
import type { InteractiveGraphState } from "./interactive-graph-state";
|
|
3
|
+
export declare function interactiveGraphReducer(state: Readonly<InteractiveGraphState>, action: InteractiveGraphAction): InteractiveGraphState;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PerseusGraphType } from "../../perseus-types";
|
|
2
|
+
import type { Interval, vec } from "mafs";
|
|
3
|
+
export type InteractiveGraphState = SegmentGraphState;
|
|
4
|
+
export interface SegmentGraphState extends InteractiveGraphStateCommon {
|
|
5
|
+
type: "segment";
|
|
6
|
+
segments: Segment[];
|
|
7
|
+
}
|
|
8
|
+
export interface InteractiveGraphStateCommon {
|
|
9
|
+
hasBeenInteractedWith: boolean;
|
|
10
|
+
range: [Interval, Interval];
|
|
11
|
+
snapStep: vec.Vector2;
|
|
12
|
+
}
|
|
13
|
+
export type Segment = [vec.Vector2, vec.Vector2];
|
|
14
|
+
export declare function initializeGraphState(params: {
|
|
15
|
+
range: [Interval, Interval];
|
|
16
|
+
step: vec.Vector2;
|
|
17
|
+
snapStep: vec.Vector2;
|
|
18
|
+
graph: PerseusGraphType;
|
|
19
|
+
}): InteractiveGraphState;
|
|
@@ -41,8 +41,8 @@ export declare const MafsGraph: React.ForwardRefExoticComponent<import("../../pe
|
|
|
41
41
|
inModal?: boolean | undefined;
|
|
42
42
|
crossOutEnabled?: boolean | undefined;
|
|
43
43
|
editorChangeDelay?: number | undefined;
|
|
44
|
-
onWidgetStartProps?: ((widgets: import("../../types").PerseusWidgetMap) => import("../../types").PerseusWidgetMap) | undefined;
|
|
45
44
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
45
|
+
onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => import("../../perseus-types").PerseusWidgetsMap) | undefined;
|
|
46
46
|
}> & {
|
|
47
47
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
48
48
|
baseElements: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InteractiveGraphAction } from "./interactive-graph-action";
|
|
2
|
+
import type { InteractiveGraphState } from "./interactive-graph-state";
|
|
3
|
+
import type { PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
|
|
2
4
|
import type { WidgetProps } from "../../types";
|
|
3
5
|
export type InteractiveGraphProps = WidgetProps<PerseusInteractiveGraphWidgetOptions, PerseusInteractiveGraphWidgetOptions>;
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} & Omit<InteractiveGraphProps, "graph"> & {
|
|
8
|
-
graph: T;
|
|
6
|
+
export type MafsGraphProps<T extends InteractiveGraphState> = {
|
|
7
|
+
graphState: T;
|
|
8
|
+
dispatch: (action: InteractiveGraphAction) => unknown;
|
|
9
9
|
};
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import type { Coord } from "../../interactive2/types";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare const useInteractivePoint: (coords: vec.Vector2, snaps: [number, number], range: [[number, number], [number, number]]) => import("mafs").UseMovablePoint;
|
|
6
|
-
/**
|
|
7
|
-
* We do not want to call `onGraphChange` until the user
|
|
8
|
-
* has interacted with the graph. See the test,
|
|
9
|
-
* "should reject no interaction"
|
|
10
|
-
*/
|
|
11
|
-
export declare const useEffectAfterFirstRender: (fn: () => void, deps: DependencyList) => void;
|
|
12
|
-
export declare const constrain: (coord: [number, number], snapStep: [number, number], range: [[number, number], [number, number]]) => [number, number];
|
|
13
|
-
export declare const normalizePoints: (range: PerseusInteractiveGraphWidgetOptions["range"], step: PerseusInteractiveGraphWidgetOptions["step"], coordsList: ReadonlyArray<Coord>, noSnap?: boolean) => Array<Coord>;
|
|
14
|
-
export declare const normalizeCoords: (coordsList: ReadonlyArray<Coord>, ranges: PerseusInteractiveGraphWidgetOptions["range"]) => Array<Coord>;
|
|
15
|
-
export declare const getLineCoords: (graph: PerseusGraphTypeRay | PerseusGraphTypeLinear, range: PerseusInteractiveGraphWidgetOptions["range"], step: PerseusInteractiveGraphWidgetOptions["step"]) => ReadonlyArray<Coord>;
|
|
2
|
+
import type { PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
|
|
3
|
+
export declare const normalizePoints: <A extends readonly Coord[]>(range: PerseusInteractiveGraphWidgetOptions["range"], step: PerseusInteractiveGraphWidgetOptions["step"], coordsList: A, noSnap?: boolean) => A;
|
|
4
|
+
export declare const normalizeCoords: <A extends readonly Coord[]>(coordsList: A, ranges: PerseusInteractiveGraphWidgetOptions["range"]) => A;
|
|
@@ -104,11 +104,6 @@ declare const _default: Readonly<{
|
|
|
104
104
|
imagePlaceholder?: React.ReactNode;
|
|
105
105
|
widgetPlaceholder?: React.ReactNode;
|
|
106
106
|
baseElements?: {
|
|
107
|
-
/**
|
|
108
|
-
* Test whether point is contained within triangle.
|
|
109
|
-
*
|
|
110
|
-
* Implementation taken from: https://stackoverflow.com/a/2049593
|
|
111
|
-
*/
|
|
112
107
|
Link: React.ComponentType<any>;
|
|
113
108
|
} | undefined;
|
|
114
109
|
imagePreloader?: ((dimensions: import("../types").Dimensions) => React.ReactNode) | undefined;
|
|
@@ -127,8 +122,8 @@ declare const _default: Readonly<{
|
|
|
127
122
|
inModal?: boolean | undefined;
|
|
128
123
|
crossOutEnabled?: boolean | undefined;
|
|
129
124
|
editorChangeDelay?: number | undefined;
|
|
130
|
-
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
131
125
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
126
|
+
onWidgetStartProps?: ((widgets: import("..").PerseusWidgetsMap) => import("..").PerseusWidgetsMap) | undefined;
|
|
132
127
|
}>;
|
|
133
128
|
choices: readonly string[];
|
|
134
129
|
imageAlt: string;
|
|
@@ -158,11 +153,6 @@ declare const _default: Readonly<{
|
|
|
158
153
|
imagePlaceholder?: React.ReactNode;
|
|
159
154
|
widgetPlaceholder?: React.ReactNode;
|
|
160
155
|
baseElements?: {
|
|
161
|
-
/**
|
|
162
|
-
* Test whether point is contained within triangle.
|
|
163
|
-
*
|
|
164
|
-
* Implementation taken from: https://stackoverflow.com/a/2049593
|
|
165
|
-
*/
|
|
166
156
|
Link: React.ComponentType<any>;
|
|
167
157
|
} | undefined;
|
|
168
158
|
imagePreloader?: ((dimensions: import("../types").Dimensions) => React.ReactNode) | undefined;
|
|
@@ -181,8 +171,8 @@ declare const _default: Readonly<{
|
|
|
181
171
|
inModal?: boolean | undefined;
|
|
182
172
|
crossOutEnabled?: boolean | undefined;
|
|
183
173
|
editorChangeDelay?: number | undefined;
|
|
184
|
-
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
185
174
|
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
175
|
+
onWidgetStartProps?: ((widgets: import("..").PerseusWidgetsMap) => import("..").PerseusWidgetsMap) | undefined;
|
|
186
176
|
}>;
|
|
187
177
|
choices: readonly string[];
|
|
188
178
|
imageAlt: string;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
|
|
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> {
|
|
4
17
|
_currPattern: any;
|
|
5
18
|
_nextPattern: any;
|
|
6
19
|
_patternIndex: number;
|
|
7
|
-
static
|
|
8
|
-
cells: PropTypes.Requireable<((boolean | null | undefined)[] | null | undefined)[]>;
|
|
9
|
-
startCells: PropTypes.Requireable<((boolean | null | undefined)[] | null | undefined)[]>;
|
|
10
|
-
flipPattern: PropTypes.Validator<string>;
|
|
11
|
-
moveCount: PropTypes.Validator<number>;
|
|
12
|
-
onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
13
|
-
};
|
|
14
|
-
static defaultProps: any;
|
|
20
|
+
static defaultProps: DefaultProps;
|
|
15
21
|
getUserInput: () => any;
|
|
16
22
|
render(): React.ReactNode;
|
|
17
23
|
change: (...args: ReadonlyArray<unknown>) => any;
|
|
@@ -20,7 +26,7 @@ declare class LightsPuzzle extends React.Component<any> {
|
|
|
20
26
|
componentDidUpdate(prevProps: any): void;
|
|
21
27
|
_initNextPatterns: () => void;
|
|
22
28
|
_shiftPatterns: () => void;
|
|
23
|
-
_flipTile: (
|
|
29
|
+
_flipTile: (FlipCoords: any) => void;
|
|
24
30
|
_reset: () => void;
|
|
25
31
|
simpleValidate: (arg1: any) => any;
|
|
26
32
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import type { PerseusMoleculeRendererWidgetOptions } from "../perseus-types";
|
|
3
|
+
type MoleculeState = {
|
|
4
|
+
parsedSmiles: any;
|
|
5
|
+
error: string | null;
|
|
6
|
+
};
|
|
7
|
+
type Props = {
|
|
8
|
+
widgetId: PerseusMoleculeRendererWidgetOptions["widgetId"];
|
|
9
|
+
smiles: PerseusMoleculeRendererWidgetOptions["smiles"];
|
|
10
|
+
rotationAngle: PerseusMoleculeRendererWidgetOptions["rotationAngle"];
|
|
11
|
+
};
|
|
12
|
+
export declare class Molecule extends React.Component<Props, MoleculeState> {
|
|
13
|
+
state: MoleculeState;
|
|
10
14
|
UNSAFE_componentWillMount(): void;
|
|
11
15
|
componentDidMount(): void;
|
|
12
16
|
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
@@ -16,13 +20,11 @@ export declare class Molecule extends React.Component<any, any> {
|
|
|
16
20
|
canvasRender: () => void;
|
|
17
21
|
render(): React.ReactNode;
|
|
18
22
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
static defaultProps: any;
|
|
23
|
+
type DefaultProps = {
|
|
24
|
+
rotationAngle: Props["rotationAngle"];
|
|
25
|
+
};
|
|
26
|
+
declare class MoleculeWidget extends React.Component<Props> {
|
|
27
|
+
static defaultProps: DefaultProps;
|
|
26
28
|
simpleValidate: (arg1: any) => any;
|
|
27
29
|
getUserInput: () => ReadonlyArray<ReadonlyArray<string>>;
|
|
28
30
|
validate: (arg1: any, arg2: any) => any;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import * as Changeable from "../mixins/changeable";
|
|
3
|
+
import type { PerseusPassageRefTargetWidgetOptions } from "../perseus-types";
|
|
4
|
+
import type { APIOptions } from "../types";
|
|
5
|
+
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
6
|
+
type Props = Changeable.ChangeableProps & {
|
|
7
|
+
apiOptions: APIOptions;
|
|
8
|
+
content: PerseusPassageRefTargetWidgetOptions["content"];
|
|
9
|
+
linterContext: LinterContextProps;
|
|
10
|
+
};
|
|
11
|
+
type DefaultProps = {
|
|
12
|
+
content: Props["content"];
|
|
13
|
+
linterContext: Props["linterContext"];
|
|
14
|
+
};
|
|
15
|
+
declare class PassageRefTarget extends React.Component<Props> {
|
|
16
|
+
static defaultProps: DefaultProps;
|
|
15
17
|
static validate(state: any, rubric: any): any;
|
|
16
18
|
getUserInput: () => any;
|
|
17
19
|
change: (arg1: any, arg2: any, arg3: any) => any;
|