@khanacademy/perseus 33.2.1 → 34.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/components/sortable.d.ts +1 -4
  2. package/dist/es/index.js +541 -585
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.js +540 -587
  6. package/dist/index.js.map +1 -1
  7. package/dist/perseus-api.d.ts +2 -0
  8. package/dist/perseus-types.d.ts +11 -6
  9. package/dist/server-item-renderer.d.ts +2 -0
  10. package/dist/types.d.ts +2 -2
  11. package/dist/util/answer-types.d.ts +1 -1
  12. package/dist/util.d.ts +2 -1
  13. package/dist/widgets/__shared__/noop-validator.d.ts +11 -0
  14. package/dist/widgets/categorizer/categorizer.d.ts +3 -1
  15. package/dist/widgets/cs-program/cs-program.d.ts +23 -17
  16. package/dist/widgets/dropdown/dropdown-validator.d.ts +4 -0
  17. package/dist/widgets/dropdown/dropdown.d.ts +1 -5
  18. package/dist/widgets/dropdown/dropdown.types.d.ts +5 -0
  19. package/dist/widgets/expression/expression-validator.d.ts +5 -0
  20. package/dist/widgets/expression/expression.d.ts +13 -6
  21. package/dist/widgets/expression/expression.types.d.ts +3 -0
  22. package/dist/widgets/expression/get-decimal-separator.d.ts +5 -0
  23. package/dist/widgets/iframe/iframe.d.ts +24 -15
  24. package/dist/widgets/interactive-graph.d.ts +3 -0
  25. package/dist/widgets/interactive-graphs/graph-locked-labels-layer.d.ts +2 -0
  26. package/dist/widgets/interactive-graphs/graphs/components/movable-point-view.d.ts +1 -1
  27. package/dist/widgets/interactive-graphs/graphs/components/movable-point.d.ts +2 -1
  28. package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +15 -4
  29. package/dist/widgets/interactive-graphs/mafs-graph.d.ts +3 -1
  30. package/dist/widgets/interactive-graphs/reducer/interactive-graph-action.d.ts +8 -1
  31. package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +2 -1
  32. package/dist/widgets/interactive-graphs/types.d.ts +5 -2
  33. package/dist/widgets/label-image/label-image.d.ts +4 -0
  34. package/dist/widgets/matcher/matcher.d.ts +17 -46
  35. package/dist/widgets/numeric-input/numeric-input-validator.d.ts +6 -0
  36. package/dist/widgets/numeric-input/numeric-input.d.ts +1 -5
  37. package/dist/widgets/numeric-input/numeric-input.types.d.ts +5 -0
  38. package/dist/widgets/orderer/orderer.d.ts +6 -5
  39. package/dist/widgets/sorter/sorter.d.ts +18 -44
  40. package/dist/widgets/table/table.d.ts +20 -24
  41. package/package.json +2 -1
  42. package/dist/mixins/widget-jsonify-deprecated.d.ts +0 -5
@@ -95,6 +95,7 @@ export declare const ApiOptions: {
95
95
  mafs?: false | ({
96
96
  circle?: boolean | undefined;
97
97
  polygon?: boolean | undefined;
98
+ none?: boolean | undefined;
98
99
  linear?: boolean | undefined;
99
100
  quadratic?: boolean | undefined;
100
101
  sinusoid?: boolean | undefined;
@@ -106,6 +107,7 @@ export declare const ApiOptions: {
106
107
  "unlimited-point"?: boolean | undefined;
107
108
  } & {
108
109
  "interactive-graph-locked-features-labels"?: boolean | undefined;
110
+ "locked-point-labels"?: boolean | undefined;
109
111
  }) | undefined;
110
112
  } | undefined;
111
113
  onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -387,18 +387,20 @@ export type LockedFigureColor = (typeof lockedFigureColorNames)[number];
387
387
  export declare const lockedFigureColors: Record<LockedFigureColor, string>;
388
388
  export type LockedFigure = LockedPointType | LockedLineType | LockedVectorType | LockedEllipseType | LockedPolygonType | LockedFunctionType | LockedLabelType;
389
389
  export type LockedFigureType = LockedFigure["type"];
390
+ export type LockedLineStyle = "solid" | "dashed";
390
391
  export type LockedPointType = {
391
392
  type: "point";
392
393
  coord: Coord;
393
394
  color: LockedFigureColor;
394
395
  filled: boolean;
396
+ labels: LockedLabelType[];
395
397
  };
396
398
  export type LockedLineType = {
397
399
  type: "line";
398
400
  kind: "line" | "ray" | "segment";
399
401
  points: [point1: LockedPointType, point2: LockedPointType];
400
402
  color: LockedFigureColor;
401
- lineStyle: "solid" | "dashed";
403
+ lineStyle: LockedLineStyle;
402
404
  showPoint1: boolean;
403
405
  showPoint2: boolean;
404
406
  };
@@ -416,7 +418,7 @@ export type LockedEllipseType = {
416
418
  angle: number;
417
419
  color: LockedFigureColor;
418
420
  fillStyle: LockedFigureFillType;
419
- strokeStyle: "solid" | "dashed";
421
+ strokeStyle: LockedLineStyle;
420
422
  };
421
423
  export type LockedPolygonType = {
422
424
  type: "polygon";
@@ -424,12 +426,12 @@ export type LockedPolygonType = {
424
426
  color: LockedFigureColor;
425
427
  showVertices: boolean;
426
428
  fillStyle: LockedFigureFillType;
427
- strokeStyle: "solid" | "dashed";
429
+ strokeStyle: LockedLineStyle;
428
430
  };
429
431
  export type LockedFunctionType = {
430
432
  type: "function";
431
433
  color: LockedFigureColor;
432
- strokeStyle: "solid" | "dashed";
434
+ strokeStyle: LockedLineStyle;
433
435
  equation: string;
434
436
  directionalAxis: "x" | "y";
435
437
  domain?: Interval;
@@ -441,7 +443,7 @@ export type LockedLabelType = {
441
443
  color: LockedFigureColor;
442
444
  size: "small" | "medium" | "large";
443
445
  };
444
- export type PerseusGraphType = PerseusGraphTypeAngle | PerseusGraphTypeCircle | PerseusGraphTypeLinear | PerseusGraphTypeLinearSystem | PerseusGraphTypePoint | PerseusGraphTypePolygon | PerseusGraphTypeQuadratic | PerseusGraphTypeRay | PerseusGraphTypeSegment | PerseusGraphTypeSinusoid;
446
+ export type PerseusGraphType = PerseusGraphTypeAngle | PerseusGraphTypeCircle | PerseusGraphTypeLinear | PerseusGraphTypeLinearSystem | PerseusGraphTypeNone | PerseusGraphTypePoint | PerseusGraphTypePolygon | PerseusGraphTypeQuadratic | PerseusGraphTypeRay | PerseusGraphTypeSegment | PerseusGraphTypeSinusoid;
445
447
  export type PerseusGraphTypeCommon = {
446
448
  coord?: Coord;
447
449
  };
@@ -474,6 +476,9 @@ export type PerseusGraphTypeLinearSystem = {
474
476
  coords?: CollinearTuple[] | null;
475
477
  startCoords?: CollinearTuple[];
476
478
  } & PerseusGraphTypeCommon;
479
+ export type PerseusGraphTypeNone = {
480
+ type: "none";
481
+ };
477
482
  export type PerseusGraphTypePoint = {
478
483
  type: "point";
479
484
  numPoints?: number | "unlimited";
@@ -661,7 +666,7 @@ export type PerseusSimulatorWidgetOptions = {
661
666
  export type PerseusSorterWidgetOptions = {
662
667
  correct: ReadonlyArray<string>;
663
668
  padding: boolean;
664
- layout: string;
669
+ layout: "horizontal" | "vertical";
665
670
  };
666
671
  export type PerseusTableWidgetOptions = {
667
672
  headers: ReadonlyArray<string>;
@@ -140,6 +140,7 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<SharedRendererProps
140
140
  mafs?: false | ({
141
141
  circle?: boolean | undefined;
142
142
  polygon?: boolean | undefined;
143
+ none?: boolean | undefined;
143
144
  linear?: boolean | undefined;
144
145
  quadratic?: boolean | undefined;
145
146
  sinusoid?: boolean | undefined;
@@ -151,6 +152,7 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<SharedRendererProps
151
152
  "unlimited-point"?: boolean | undefined;
152
153
  } & {
153
154
  "interactive-graph-locked-features-labels"?: boolean | undefined;
155
+ "locked-point-labels"?: boolean | undefined;
154
156
  }) | undefined;
155
157
  } | undefined;
156
158
  onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
package/dist/types.d.ts CHANGED
@@ -74,8 +74,8 @@ type TrackInteractionArgs = {
74
74
  id: string;
75
75
  correct?: boolean;
76
76
  } & Partial<TrackingGradedGroupExtraArguments> & Partial<TrackingSequenceExtraArguments>;
77
- export declare const MafsGraphTypeFlags: readonly ["angle", "segment", "linear", "linear-system", "ray", "polygon", "circle", "quadratic", "sinusoid", "point", "unlimited-point"];
78
- export declare const InteractiveGraphLockedFeaturesFlags: readonly ["interactive-graph-locked-features-labels"];
77
+ export declare const MafsGraphTypeFlags: readonly ["angle", "segment", "linear", "linear-system", "ray", "polygon", "circle", "quadratic", "sinusoid", "point", "unlimited-point", "none"];
78
+ export declare const InteractiveGraphLockedFeaturesFlags: readonly ["interactive-graph-locked-features-labels", "locked-point-labels"];
79
79
  /**
80
80
  * APIOptions provides different ways to customize the behaviour of Perseus.
81
81
  *
@@ -1,7 +1,7 @@
1
1
  import type { PerseusStrings } from "../strings";
2
2
  type Guess = any;
3
3
  type Predicate = any;
4
- type Score = {
4
+ export type Score = {
5
5
  empty: boolean;
6
6
  correct: boolean;
7
7
  message: string | null | undefined;
package/dist/util.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { Range } from "./perseus-types";
3
3
  import type { PerseusStrings } from "./strings";
4
4
  import type { Widget, PerseusScore } from "./types";
5
5
  import type { KEScore } from "@khanacademy/perseus-core";
6
+ import type * as React from "react";
6
7
  type WordPosition = {
7
8
  start: number;
8
9
  end: number;
@@ -173,7 +174,7 @@ declare function extractPointerLocation(event: any): Position | null | undefined
173
174
  * Pass this function as the touchstart for an element to
174
175
  * avoid sending the touch to the mobile scratchpad
175
176
  */
176
- declare function captureScratchpadTouchStart(e: TouchEvent): void;
177
+ declare function captureScratchpadTouchStart(e: React.TouchEvent): void;
177
178
  declare function getImageSize(url: string, callback: (width: number, height: number) => void): void;
178
179
  /**
179
180
  * Gets the word right before where the textarea cursor is
@@ -0,0 +1,11 @@
1
+ import type { PerseusScore } from "../../types";
2
+ /**
3
+ * Several widgets don't have "right"/"wrong" validation logic,
4
+ * so this just says to move on past those widgets
5
+ *
6
+ * TODO: widgets that use this probably shouldn't have any
7
+ * validation logic and the thing validating an exercise
8
+ * should just know to skip these
9
+ */
10
+ declare function noopValidator(): PerseusScore;
11
+ export default noopValidator;
@@ -3,7 +3,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusCategorizerWidgetOptions } from "../../perseus-types";
4
4
  import type { PerseusStrings } from "../../strings";
5
5
  import type { PerseusScore, WidgetProps } from "../../types";
6
- type UserInput = any;
6
+ type UserInput = {
7
+ values: ReadonlyArray<number>;
8
+ };
7
9
  export type Rubric = PerseusCategorizerWidgetOptions;
8
10
  type Props = WidgetProps<RenderProps, Rubric> & {
9
11
  values: ReadonlyArray<string>;
@@ -1,28 +1,34 @@
1
1
  /**
2
2
  * This widget is for embedding Khan Academy CS programs.
3
3
  */
4
- import PropTypes from "prop-types";
5
4
  import * as React from "react";
6
- declare class CSProgram extends React.Component<any> {
7
- static propTypes: {
8
- programID: PropTypes.Requireable<string>;
9
- programType: PropTypes.Requireable<string>;
10
- width: PropTypes.Requireable<number>;
11
- height: PropTypes.Requireable<number>;
12
- settings: PropTypes.Requireable<any[]>;
13
- showEditor: PropTypes.Requireable<boolean>;
14
- showButtons: PropTypes.Requireable<boolean>;
15
- status: PropTypes.Requireable<string>;
16
- message: PropTypes.Requireable<string>;
17
- onChange: PropTypes.Validator<(...args: any[]) => any>;
18
- };
19
- static validate(state: any, rubric: any): any;
20
- static defaultProps: any;
5
+ import type { PerseusCSProgramWidgetOptions } from "../../perseus-types";
6
+ import type { PerseusScore, WidgetProps } from "../../types";
7
+ type Status = "correct" | "incorrect" | "incomplete";
8
+ type UserInput = {
9
+ status: Status;
10
+ message: string | null;
11
+ };
12
+ type RenderProps = PerseusCSProgramWidgetOptions & {
13
+ status: Status;
14
+ message: string | null;
15
+ };
16
+ export type Rubric = PerseusCSProgramWidgetOptions;
17
+ type Props = WidgetProps<RenderProps, Rubric>;
18
+ type DefaultProps = {
19
+ showEditor: Props["showEditor"];
20
+ showButtons: Props["showButtons"];
21
+ status: Props["status"];
22
+ message: Props["message"];
23
+ };
24
+ declare class CSProgram extends React.Component<Props> {
25
+ static defaultProps: DefaultProps;
26
+ static validate(state: UserInput, rubric: any): PerseusScore;
21
27
  componentDidMount(): void;
22
28
  componentWillUnmount(): void;
23
29
  handleMessageEvent: (arg1: any) => void;
24
30
  change: (...args: ReadonlyArray<unknown>) => any;
25
- simpleValidate: (arg1: any) => any;
31
+ simpleValidate(rubric: any): PerseusScore;
26
32
  render(): React.ReactNode;
27
33
  }
28
34
  declare const _default: Readonly<{
@@ -0,0 +1,4 @@
1
+ import type { Rubric, UserInput } from "./dropdown.types";
2
+ import type { PerseusScore } from "../../types";
3
+ declare function dropdownValidator(userInput: UserInput, rubric: Rubric): PerseusScore;
4
+ export default dropdownValidator;
@@ -1,10 +1,6 @@
1
1
  import * as React from "react";
2
- import type { PerseusDropdownWidgetOptions } from "../../perseus-types";
2
+ import type { Rubric, UserInput } from "./dropdown.types";
3
3
  import type { PerseusScore, WidgetProps } from "../../types";
4
- type Rubric = PerseusDropdownWidgetOptions;
5
- type UserInput = {
6
- value: number;
7
- };
8
4
  type Props = WidgetProps<RenderProps, Rubric> & {
9
5
  selected: number;
10
6
  };
@@ -0,0 +1,5 @@
1
+ import type { PerseusDropdownWidgetOptions } from "../../perseus-types";
2
+ export type Rubric = PerseusDropdownWidgetOptions;
3
+ export type UserInput = {
4
+ value: number;
5
+ };
@@ -0,0 +1,5 @@
1
+ import type { Rubric, OnInputErrorFunctionType } from "./expression.types";
2
+ import type { PerseusStrings } from "../../strings";
3
+ import type { PerseusScore } from "../../types";
4
+ declare function expressionValidator(userInput: string, rubric: Rubric, onInputError: OnInputErrorFunctionType | undefined, strings: PerseusStrings, locale: string): PerseusScore;
5
+ export default expressionValidator;
@@ -1,12 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
+ import type { Rubric, OnInputErrorFunctionType } from "./expression.types";
3
4
  import type { DependenciesContext } from "../../dependencies";
4
5
  import type { PerseusExpressionWidgetOptions } from "../../perseus-types";
5
6
  import type { PerseusStrings } from "../../strings";
6
7
  import type { PerseusScore, WidgetProps } from "../../types";
7
8
  import type { Keys as Key, KeypadConfiguration } from "@khanacademy/math-input";
8
9
  type InputPath = ReadonlyArray<string>;
9
- type Rubric = PerseusExpressionWidgetOptions;
10
10
  type RenderProps = {
11
11
  buttonSets: PerseusExpressionWidgetOptions["buttonSets"];
12
12
  buttonsVisible?: PerseusExpressionWidgetOptions["buttonsVisible"];
@@ -44,11 +44,6 @@ type DefaultProps = {
44
44
  times: Props["times"];
45
45
  value: Props["value"];
46
46
  };
47
- type OnInputErrorFunctionType = (arg1?: any, arg2?: any, arg3?: any) => boolean | null | undefined;
48
- /**
49
- * Get the character used for separating decimals.
50
- */
51
- export declare const getDecimalSeparator: (locale: string) => string;
52
47
  export declare class Expression extends React.Component<Props, ExpressionState> {
53
48
  static contextType: React.Context<{
54
49
  strings: PerseusStrings;
@@ -141,6 +136,7 @@ declare const _default: Readonly<{
141
136
  mafs?: false | ({
142
137
  circle?: boolean | undefined;
143
138
  polygon?: boolean | undefined;
139
+ none?: boolean | undefined;
144
140
  linear?: boolean | undefined;
145
141
  quadratic?: boolean | undefined;
146
142
  sinusoid?: boolean | undefined;
@@ -152,6 +148,7 @@ declare const _default: Readonly<{
152
148
  "unlimited-point"?: boolean | undefined;
153
149
  } & {
154
150
  "interactive-graph-locked-features-labels"?: boolean | undefined;
151
+ "locked-point-labels"?: boolean | undefined;
155
152
  }) | undefined;
156
153
  } | undefined;
157
154
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -220,6 +217,7 @@ declare const _default: Readonly<{
220
217
  mafs?: false | ({
221
218
  circle?: boolean | undefined;
222
219
  polygon?: boolean | undefined;
220
+ none?: boolean | undefined;
223
221
  linear?: boolean | undefined;
224
222
  quadratic?: boolean | undefined;
225
223
  sinusoid?: boolean | undefined;
@@ -231,6 +229,7 @@ declare const _default: Readonly<{
231
229
  "unlimited-point"?: boolean | undefined;
232
230
  } & {
233
231
  "interactive-graph-locked-features-labels"?: boolean | undefined;
232
+ "locked-point-labels"?: boolean | undefined;
234
233
  }) | undefined;
235
234
  } | undefined;
236
235
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -299,6 +298,7 @@ declare const _default: Readonly<{
299
298
  mafs?: false | ({
300
299
  circle?: boolean | undefined;
301
300
  polygon?: boolean | undefined;
301
+ none?: boolean | undefined;
302
302
  linear?: boolean | undefined;
303
303
  quadratic?: boolean | undefined;
304
304
  sinusoid?: boolean | undefined;
@@ -310,6 +310,7 @@ declare const _default: Readonly<{
310
310
  "unlimited-point"?: boolean | undefined;
311
311
  } & {
312
312
  "interactive-graph-locked-features-labels"?: boolean | undefined;
313
+ "locked-point-labels"?: boolean | undefined;
313
314
  }) | undefined;
314
315
  } | undefined;
315
316
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -377,6 +378,7 @@ declare const _default: Readonly<{
377
378
  mafs?: false | ({
378
379
  circle?: boolean | undefined;
379
380
  polygon?: boolean | undefined;
381
+ none?: boolean | undefined;
380
382
  linear?: boolean | undefined;
381
383
  quadratic?: boolean | undefined;
382
384
  sinusoid?: boolean | undefined;
@@ -388,6 +390,7 @@ declare const _default: Readonly<{
388
390
  "unlimited-point"?: boolean | undefined;
389
391
  } & {
390
392
  "interactive-graph-locked-features-labels"?: boolean | undefined;
393
+ "locked-point-labels"?: boolean | undefined;
391
394
  }) | undefined;
392
395
  } | undefined;
393
396
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -456,6 +459,7 @@ declare const _default: Readonly<{
456
459
  mafs?: false | ({
457
460
  circle?: boolean | undefined;
458
461
  polygon?: boolean | undefined;
462
+ none?: boolean | undefined;
459
463
  linear?: boolean | undefined;
460
464
  quadratic?: boolean | undefined;
461
465
  sinusoid?: boolean | undefined;
@@ -467,6 +471,7 @@ declare const _default: Readonly<{
467
471
  "unlimited-point"?: boolean | undefined;
468
472
  } & {
469
473
  "interactive-graph-locked-features-labels"?: boolean | undefined;
474
+ "locked-point-labels"?: boolean | undefined;
470
475
  }) | undefined;
471
476
  } | undefined;
472
477
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -535,6 +540,7 @@ declare const _default: Readonly<{
535
540
  mafs?: false | ({
536
541
  circle?: boolean | undefined;
537
542
  polygon?: boolean | undefined;
543
+ none?: boolean | undefined;
538
544
  linear?: boolean | undefined;
539
545
  quadratic?: boolean | undefined;
540
546
  sinusoid?: boolean | undefined;
@@ -546,6 +552,7 @@ declare const _default: Readonly<{
546
552
  "unlimited-point"?: boolean | undefined;
547
553
  } & {
548
554
  "interactive-graph-locked-features-labels"?: boolean | undefined;
555
+ "locked-point-labels"?: boolean | undefined;
549
556
  }) | undefined;
550
557
  } | undefined;
551
558
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -0,0 +1,3 @@
1
+ import type { PerseusExpressionWidgetOptions } from "../../perseus-types";
2
+ export type Rubric = PerseusExpressionWidgetOptions;
3
+ export type OnInputErrorFunctionType = (arg1?: any, arg2?: any, arg3?: any) => boolean | null | undefined;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Get the character used for separating decimals.
3
+ */
4
+ declare const getDecimalSeparator: (locale: string) => string;
5
+ export default getDecimalSeparator;
@@ -6,24 +6,33 @@
6
6
  * It's particularly well suited for embedding our ProcessingJS programs,
7
7
  * but could also be used for embedding viz's hosted elsewhere.
8
8
  */
9
- import PropTypes from "prop-types";
10
9
  import * as React from "react";
11
- declare class Iframe extends React.Component<any> {
12
- static propTypes: {
13
- width: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
14
- height: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
15
- url: PropTypes.Requireable<string>;
16
- settings: PropTypes.Requireable<any[]>;
17
- status: PropTypes.Requireable<string>;
18
- message: PropTypes.Requireable<string>;
19
- allowFullScreen: PropTypes.Requireable<boolean>;
20
- allowTopNavigation: PropTypes.Requireable<boolean>;
21
- onChange: PropTypes.Validator<(...args: any[]) => any>;
22
- };
23
- static defaultProps: any;
10
+ import type { PerseusIFrameWidgetOptions } from "../../perseus-types";
11
+ import type { WidgetProps } from "../../types";
12
+ type Status = "correct" | "incorrect" | "incomplete";
13
+ type UserInput = {
14
+ status: Status;
15
+ message: string | null;
16
+ };
17
+ type RenderProps = PerseusIFrameWidgetOptions & {
18
+ status: Status;
19
+ message: string | null;
20
+ width: string;
21
+ height: string;
22
+ };
23
+ export type Rubric = PerseusIFrameWidgetOptions;
24
+ type Props = WidgetProps<RenderProps, Rubric>;
25
+ type DefaultProps = {
26
+ status: Props["status"];
27
+ message: Props["message"];
28
+ allowFullScreen: Props["allowFullScreen"];
29
+ allowTopNavigation: Props["allowTopNavigation"];
30
+ };
31
+ declare class Iframe extends React.Component<Props> {
32
+ static defaultProps: DefaultProps;
24
33
  componentDidMount(): void;
25
34
  componentWillUnmount(): void;
26
- getUserInput: () => any;
35
+ getUserInput(): UserInput;
27
36
  handleMessageEvent: (arg1: any) => void;
28
37
  change: (...args: ReadonlyArray<unknown>) => any;
29
38
  simpleValidate: (arg1: any) => any;
@@ -68,6 +68,8 @@ declare class LegacyInteractiveGraph extends React.Component<Props, State> {
68
68
  };
69
69
  addLine: (arg1: string) => void;
70
70
  removeLine: () => void;
71
+ addNoneControls: () => void;
72
+ removeNoneControls: () => void;
71
73
  addLinearControls: () => void;
72
74
  removeLinearControls: () => void;
73
75
  addQuadraticControls: () => void;
@@ -146,6 +148,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
146
148
  static normalizeCoords(coordsList: ReadonlyArray<Coord>, ranges: [Range, Range]): ReadonlyArray<Coord>;
147
149
  static getEquationString(props: Props): string;
148
150
  static pointsFromNormalized(props: Props, coordsList: ReadonlyArray<Coord>, noSnap?: boolean): ReadonlyArray<Coord>;
151
+ static getNoneEquationString(): string;
149
152
  static getLinearEquationString(props: Props): string;
150
153
  static getCurrentQuadraticCoefficients(props: Props): QuadraticCoefficient;
151
154
  static defaultQuadraticCoords(props: Props): QuadraticGraphState["coords"];
@@ -1,6 +1,8 @@
1
1
  import * as React from "react";
2
2
  import type { LockedFigure } from "../../perseus-types";
3
+ import type { APIOptions } from "../../types";
3
4
  type Props = {
5
+ flags?: APIOptions["flags"];
4
6
  lockedFigures: ReadonlyArray<LockedFigure>;
5
7
  };
6
8
  export default function GraphLockedLabelsLayer(props: Props): (React.JSX.Element | null)[];
@@ -17,7 +17,7 @@ type ControlledFocusBehavior = {
17
17
  type UncontrolledFocusBehavior = {
18
18
  type: "uncontrolled";
19
19
  tabIndex: number;
20
- onFocusChange: (isFocused: boolean) => unknown;
20
+ onFocusChange?: (event: React.FocusEvent, isFocused: boolean) => unknown;
21
21
  };
22
22
  export declare const MovablePointView: React.ForwardRefExoticComponent<Props & React.RefAttributes<SVGGElement>>;
23
23
  export {};
@@ -5,10 +5,11 @@ import type { vec } from "mafs";
5
5
  type Props = {
6
6
  point: vec.Vector2;
7
7
  onMove?: (newPoint: vec.Vector2) => unknown;
8
+ onClick?: () => unknown;
8
9
  color?: string;
9
10
  cursor?: CSSCursor | undefined;
10
11
  constrain?: KeyboardMovementConstraint;
11
- onFocusChange?: (isFocused: boolean) => unknown;
12
+ onFocusChange?: (event: React.FocusEvent, isFocused: boolean) => unknown;
12
13
  };
13
14
  export declare const MovablePoint: (props: Props) => React.JSX.Element;
14
15
  export {};
@@ -1,7 +1,12 @@
1
1
  import type { Coord } from "../../interactive2/types";
2
- import type { CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedFunctionType, PerseusRenderer } from "../../perseus-types";
3
- import type { vec } from "mafs";
4
- export type LockedFunctionOptions = Omit<Partial<LockedFunctionType>, "type" | "equation">;
2
+ import type { CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedLineStyle, PerseusRenderer } from "../../perseus-types";
3
+ import type { Interval, vec } from "mafs";
4
+ export type LockedFunctionOptions = {
5
+ color?: LockedFigureColor;
6
+ strokeStyle?: LockedLineStyle;
7
+ directionalAxis?: "x" | "y";
8
+ domain?: Interval;
9
+ };
5
10
  export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
6
11
  declare class InteractiveGraphQuestionBuilder {
7
12
  private content;
@@ -45,6 +50,7 @@ declare class InteractiveGraphQuestionBuilder {
45
50
  startCoords?: CollinearTuple[];
46
51
  coords?: CollinearTuple[];
47
52
  }): InteractiveGraphQuestionBuilder;
53
+ withNoInteractiveFigure(): this;
48
54
  withLinear(options?: {
49
55
  coords?: CollinearTuple;
50
56
  startCoords?: CollinearTuple;
@@ -97,10 +103,15 @@ declare class InteractiveGraphQuestionBuilder {
97
103
  addLockedPointAt(x: number, y: number, options?: {
98
104
  color?: LockedFigureColor;
99
105
  filled?: boolean;
106
+ labels?: {
107
+ text: string;
108
+ coord?: Coord;
109
+ size?: "small" | "medium" | "large";
110
+ }[];
100
111
  }): InteractiveGraphQuestionBuilder;
101
112
  addLockedLine(point1: vec.Vector2, point2: vec.Vector2, options?: {
102
113
  kind?: "line" | "ray" | "segment";
103
- lineStyle?: "solid" | "dashed";
114
+ lineStyle?: LockedLineStyle;
104
115
  color?: LockedFigureColor;
105
116
  filled?: [boolean, boolean];
106
117
  showPoint1?: boolean;
@@ -1,11 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { type InteractiveGraphAction } from "./reducer/interactive-graph-action";
3
3
  import type { InteractiveGraphState, InteractiveGraphProps } from "./types";
4
+ import type { APIOptions } from "../../types";
4
5
  import type { vec } from "mafs";
5
6
  import "mafs/core.css";
6
7
  import "./mafs-styles.css";
7
8
  export type MafsGraphProps = {
8
- showLabelsFlag?: boolean;
9
+ flags?: APIOptions["flags"];
9
10
  box: [number, number];
10
11
  backgroundImage?: InteractiveGraphProps["backgroundImage"];
11
12
  lockedFigures?: InteractiveGraphProps["lockedFigures"];
@@ -23,6 +24,7 @@ export type MafsGraphProps = {
23
24
  readOnly: boolean;
24
25
  static: boolean | null | undefined;
25
26
  };
27
+ export declare const REMOVE_BUTTON_ID = "perseus_mafs_remove_button";
26
28
  export declare const MafsGraph: (props: MafsGraphProps) => React.JSX.Element;
27
29
  export declare const calculateNestedSVGCoords: (range: vec.Vector2[], width: number, height: number) => {
28
30
  viewboxX: number;
@@ -1,6 +1,6 @@
1
1
  import type { InitializeGraphStateParams } from "./initialize-graph-state";
2
2
  import type { Interval, vec } from "mafs";
3
- export type InteractiveGraphAction = Reinitialize | MovePointInFigure | MoveLine | MoveAll | MovePoint | MoveCenter | MoveRadiusPoint | ChangeSnapStep | ChangeRange | AddPoint | RemovePoint | FocusPoint | BlurPoint | DeleteIntent;
3
+ export type InteractiveGraphAction = Reinitialize | MovePointInFigure | MoveLine | MoveAll | MovePoint | MoveCenter | MoveRadiusPoint | ChangeSnapStep | ChangeRange | AddPoint | RemovePoint | FocusPoint | BlurPoint | DeleteIntent | ClickPoint;
4
4
  export declare const actions: {
5
5
  global: {
6
6
  deleteIntent: typeof deleteIntent;
@@ -26,6 +26,7 @@ export declare const actions: {
26
26
  removePoint: typeof removePoint;
27
27
  focusPoint: typeof focusPoint;
28
28
  blurPoint: typeof blurPoint;
29
+ clickPoint: typeof clickPoint;
29
30
  };
30
31
  polygon: {
31
32
  movePoint: typeof movePoint;
@@ -81,6 +82,12 @@ export interface BlurPoint {
81
82
  type: typeof BLUR_POINT;
82
83
  }
83
84
  declare function blurPoint(): BlurPoint;
85
+ export declare const CLICK_POINT = "click-point";
86
+ export interface ClickPoint {
87
+ type: typeof CLICK_POINT;
88
+ index: number;
89
+ }
90
+ declare function clickPoint(index: number): ClickPoint;
84
91
  export declare const MOVE_ALL = "move-all";
85
92
  export interface MoveAll {
86
93
  type: typeof MOVE_ALL;
@@ -2,8 +2,9 @@ import * as React from "react";
2
2
  import type { InteractiveGraphProps } from "./types";
3
3
  import type { PerseusGraphType } from "../../perseus-types";
4
4
  import type { Widget } from "../../renderer";
5
+ import type { APIOptions } from "../../types";
5
6
  export type StatefulMafsGraphProps = {
6
- showLabelsFlag?: boolean;
7
+ flags?: APIOptions["flags"];
7
8
  box: [number, number];
8
9
  backgroundImage?: InteractiveGraphProps["backgroundImage"];
9
10
  graph: PerseusGraphType;
@@ -8,7 +8,7 @@ export type MafsGraphProps<T extends InteractiveGraphState> = {
8
8
  graphState: T;
9
9
  dispatch: (action: InteractiveGraphAction) => unknown;
10
10
  };
11
- export type InteractiveGraphState = AngleGraphState | SegmentGraphState | LinearSystemGraphState | LinearGraphState | RayGraphState | PolygonGraphState | PointGraphState | CircleGraphState | QuadraticGraphState | SinusoidGraphState;
11
+ export type InteractiveGraphState = AngleGraphState | SegmentGraphState | LinearSystemGraphState | LinearGraphState | RayGraphState | NoneGraphState | PolygonGraphState | PointGraphState | CircleGraphState | QuadraticGraphState | SinusoidGraphState;
12
12
  export interface InteractiveGraphStateCommon {
13
13
  hasBeenInteractedWith: boolean;
14
14
  range: [xRange: Interval, yRange: Interval];
@@ -26,12 +26,15 @@ export interface LinearSystemGraphState extends InteractiveGraphStateCommon {
26
26
  type: "linear-system";
27
27
  coords: PairOfPoints[];
28
28
  }
29
+ export interface NoneGraphState extends InteractiveGraphStateCommon {
30
+ type: "none";
31
+ }
29
32
  export interface PointGraphState extends InteractiveGraphStateCommon {
30
33
  type: "point";
31
34
  coords: Coord[];
32
35
  numPoints?: number | "unlimited";
33
36
  focusedPointIndex: number | null;
34
- previouslyFocusedPointIndex: number | null;
37
+ showRemovePointButton: boolean;
35
38
  }
36
39
  export interface RayGraphState extends InteractiveGraphStateCommon {
37
40
  type: "ray";