@khanacademy/perseus-editor 44.0.1 → 44.0.3

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 (24) hide show
  1. package/dist/components/widget-editor.d.ts +1 -1
  2. package/dist/index.js +15 -16
  3. package/dist/index.js.map +1 -1
  4. package/dist/widgets/dropdown-editor/dropdown-editor.d.ts +0 -4
  5. package/dist/widgets/expression-editor/expression-editor.d.ts +11 -2
  6. package/dist/widgets/free-response-editor/free-response-editor.d.ts +7 -1
  7. package/dist/widgets/interaction-editor/constraint-editor.d.ts +7 -14
  8. package/dist/widgets/interaction-editor/function-editor.d.ts +6 -19
  9. package/dist/widgets/interaction-editor/interaction-editor.d.ts +10 -16
  10. package/dist/widgets/interaction-editor/label-editor.d.ts +6 -15
  11. package/dist/widgets/interaction-editor/line-editor.d.ts +6 -22
  12. package/dist/widgets/interaction-editor/movable-line-editor.d.ts +6 -23
  13. package/dist/widgets/interaction-editor/movable-point-editor.d.ts +6 -18
  14. package/dist/widgets/interaction-editor/parametric-editor.d.ts +6 -21
  15. package/dist/widgets/interaction-editor/point-editor.d.ts +6 -13
  16. package/dist/widgets/interaction-editor/rectangle-editor.d.ts +6 -17
  17. package/dist/widgets/interactive-graph-editor/components/interactive-graph-settings.d.ts +15 -14
  18. package/dist/widgets/interactive-graph-editor/interactive-graph-editor.d.ts +33 -95
  19. package/dist/widgets/label-image-editor/answer-choices.d.ts +1 -1
  20. package/dist/widgets/label-image-editor/select-image.d.ts +1 -1
  21. package/dist/widgets/numeric-input-editor/numeric-input-editor.d.ts +7 -1
  22. package/dist/widgets/table-editor/table-editor.d.ts +5 -7
  23. package/package.json +7 -7
  24. package/dist/testing/split-view.d.ts +0 -13
@@ -9,10 +9,6 @@ interface Props extends PerseusDropdownWidgetOptions {
9
9
  * An editor for adding a dropdown widget that allows users to select an option from a predefined list.
10
10
  */
11
11
  declare class DropdownEditor extends React.Component<Props> {
12
- static propTypes: {
13
- choices: any;
14
- placeholder: any;
15
- };
16
12
  static defaultProps: PerseusDropdownWidgetOptions;
17
13
  handleChange(changed: Partial<PerseusDropdownWidgetOptions>): void;
18
14
  onCorrectChange(choiceIndex: number): void;
@@ -1,7 +1,7 @@
1
1
  import { PerseusExpressionAnswerFormConsidered } from "@khanacademy/perseus-core";
2
2
  import * as React from "react";
3
3
  import type { APIOptions } from "@khanacademy/perseus";
4
- import type { PerseusExpressionWidgetOptions, PerseusExpressionUserInput } from "@khanacademy/perseus-core";
4
+ import type { PerseusExpressionWidgetOptions, LegacyButtonSets, PerseusExpressionAnswerForm, PerseusExpressionUserInput } from "@khanacademy/perseus-core";
5
5
  type EditableExpressionWidgetOptions = Omit<PerseusExpressionWidgetOptions, "buttonsVisible">;
6
6
  type Props = {
7
7
  apiOptions: APIOptions;
@@ -15,7 +15,16 @@ interface State {
15
15
  * An editor for adding an expression widget that allows users to enter mathematical expressions.
16
16
  */
17
17
  declare class ExpressionEditor extends React.Component<Props, State> {
18
- static defaultProps: any;
18
+ static defaultProps: {
19
+ answerForms: PerseusExpressionAnswerForm[];
20
+ buttonSets: LegacyButtonSets;
21
+ functions: string[];
22
+ times: boolean;
23
+ extraKeys?: import("@khanacademy/perseus-core").KeypadKey[];
24
+ visibleLabel?: string;
25
+ ariaLabel?: string;
26
+ buttonsVisible?: "always" | "never" | "focused";
27
+ };
19
28
  constructor(props: Props);
20
29
  handleChange(changes: Partial<EditableExpressionWidgetOptions>): void;
21
30
  serialize(): PerseusExpressionWidgetOptions;
@@ -9,7 +9,13 @@ type Props = PerseusFreeResponseWidgetOptions & {
9
9
  * An editor for adding a free response widget that allows users to enter open-ended text answers.
10
10
  */
11
11
  declare class FreeResponseEditor extends React.Component<Props> {
12
- static defaultProps: any;
12
+ static defaultProps: {
13
+ allowUnlimitedCharacters: boolean;
14
+ characterLimit: number;
15
+ placeholder: string;
16
+ question: string;
17
+ scoringCriteria: ReadonlyArray<PerseusFreeResponseWidgetScoringCriterion>;
18
+ };
13
19
  handleChange(changes: Partial<PerseusFreeResponseWidgetOptions>): void;
14
20
  serialize: () => PerseusFreeResponseWidgetOptions;
15
21
  getSaveWarnings: () => Array<string>;
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
2
+ interface ConstraintOptions {
4
3
  constraint: string;
5
4
  constraintFn: string;
6
5
  constraintXMax: string;
@@ -8,19 +7,13 @@ type Props = ChangeableProps & {
8
7
  constraintYMax: string;
9
8
  constraintYMin: string;
10
9
  snap: number;
11
- };
12
- type DefaultProps = {
13
- constraint: Props["constraint"];
14
- constraintFn: Props["constraintFn"];
15
- constraintXMax: Props["constraintXMax"];
16
- constraintXMin: Props["constraintXMin"];
17
- constraintYMax: Props["constraintYMax"];
18
- constraintYMin: Props["constraintYMin"];
19
- snap: Props["snap"];
20
- };
10
+ }
11
+ interface Props extends ConstraintOptions {
12
+ onChange: (options: ConstraintOptions) => void;
13
+ }
21
14
  declare class ConstraintEditor extends React.Component<Props> {
22
- static defaultProps: DefaultProps;
23
- change: (propName: string) => (value?: any, callback?: () => unknown) => unknown;
15
+ static defaultProps: ConstraintOptions;
16
+ handleChange(changes: Partial<ConstraintOptions>): void;
24
17
  render(): React.ReactNode;
25
18
  }
26
19
  export default ConstraintEditor;
@@ -1,24 +1,11 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
4
- value: string;
5
- rangeMin: string;
6
- rangeMax: string;
7
- color: string;
8
- strokeDasharray: string;
9
- strokeWidth: number;
10
- };
11
- type DefaultProps = {
12
- value: Props["value"];
13
- rangeMin: Props["rangeMin"];
14
- rangeMax: Props["rangeMax"];
15
- color: Props["color"];
16
- strokeDasharray: Props["strokeDasharray"];
17
- strokeWidth: Props["strokeWidth"];
18
- };
2
+ import type { PerseusInteractionFunctionElementOptions } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionFunctionElementOptions {
4
+ onChange: (options: PerseusInteractionFunctionElementOptions) => void;
5
+ }
19
6
  declare class FunctionEditor extends React.Component<Props> {
20
- static defaultProps: DefaultProps;
21
- change: (arg1: any, arg2?: any, arg3?: any) => any;
7
+ static defaultProps: PerseusInteractionFunctionElementOptions;
8
+ handleChange(changes: Partial<PerseusInteractionFunctionElementOptions>): void;
22
9
  render(): React.ReactNode;
23
10
  }
24
11
  export default FunctionEditor;
@@ -1,19 +1,8 @@
1
- import { type Coords, type PerseusInteractionWidgetOptions, type MarkingsType } from "@khanacademy/perseus-core";
2
1
  import * as React from "react";
3
- type Graph = {
4
- box: ReadonlyArray<number>;
5
- labels: ReadonlyArray<string>;
6
- range: Coords;
7
- tickStep: [number, number];
8
- gridStep: [number, number];
9
- markings: MarkingsType;
10
- valid?: boolean;
11
- };
12
- type Props = {
13
- onChange: (newProps: Record<string, unknown>) => void;
14
- elements: ReadonlyArray<any>;
15
- graph: Graph;
16
- };
2
+ import type { PerseusInteractionWidgetOptions, PerseusInteractionElement } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionWidgetOptions {
4
+ onChange: (options: PerseusInteractionWidgetOptions) => void;
5
+ }
17
6
  type State = any;
18
7
  /**
19
8
  * An editor for the interaction widget that allows users to engage with interactive content.
@@ -27,9 +16,14 @@ declare class InteractionEditor extends React.Component<Props, State> {
27
16
  static defaultProps: PerseusInteractionWidgetOptions;
28
17
  state: State;
29
18
  UNSAFE_componentWillReceiveProps(nextProps: Props): void;
19
+ handleChange(changes: Partial<PerseusInteractionWidgetOptions>): void;
20
+ handleElementChange(n: number, newElement: PerseusInteractionElement): void;
30
21
  _getAllVarSubscripts(elements: ReadonlyArray<any>): ReadonlyArray<any>;
31
22
  _getAllFunctionNames(elements: ReadonlyArray<any>): ReadonlyArray<string>;
32
- _updateGraphProps: (newProps: Record<string, unknown>) => void;
23
+ _updateGraphProps: (newProps: Record<string, any>) => void;
24
+ nextSubscript(): number;
25
+ nextFuncName(): string;
26
+ createElement(elementType: string): PerseusInteractionElement;
33
27
  _addNewElement: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
34
28
  _deleteElement: (arg1: number) => void;
35
29
  _moveElementUp: (arg1: number) => void;
@@ -1,20 +1,11 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
4
- color: string;
5
- coordX: string;
6
- coordY: string;
7
- label: string;
8
- };
9
- type DefaultProps = {
10
- color: Props["color"];
11
- coordX: Props["coordX"];
12
- coordY: Props["coordY"];
13
- label: Props["label"];
14
- };
2
+ import type { PerseusInteractionLabelElementOptions } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionLabelElementOptions {
4
+ onChange: (options: PerseusInteractionLabelElementOptions) => void;
5
+ }
15
6
  declare class LabelEditor extends React.Component<Props> {
16
- static defaultProps: DefaultProps;
17
- change: (arg1: any, arg2?: any, arg3?: any) => any;
7
+ static defaultProps: PerseusInteractionLabelElementOptions;
8
+ handleChange(changes: Partial<PerseusInteractionLabelElementOptions>): void;
18
9
  render(): React.ReactNode;
19
10
  }
20
11
  export default LabelEditor;
@@ -1,27 +1,11 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
4
- startX: string;
5
- startY: string;
6
- endX: string;
7
- endY: string;
8
- color: string;
9
- strokeDasharray: string;
10
- arrows: string;
11
- strokeWidth: number;
12
- };
13
- type DefaultProps = {
14
- startX: Props["startX"];
15
- startY: Props["startY"];
16
- endX: Props["endX"];
17
- endY: Props["endY"];
18
- color: Props["color"];
19
- strokeDasharray: Props["strokeDasharray"];
20
- arrows: Props["arrows"];
21
- strokeWidth: Props["strokeWidth"];
22
- };
2
+ import type { PerseusInteractionLineElementOptions } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionLineElementOptions {
4
+ onChange: (options: PerseusInteractionLineElementOptions) => void;
5
+ }
23
6
  declare class LineEditor extends React.Component<Props> {
24
- static defaultProps: DefaultProps;
7
+ static defaultProps: PerseusInteractionLineElementOptions;
8
+ handleChange(changes: Partial<PerseusInteractionLineElementOptions>): void;
25
9
  change: (arg1: any, arg2?: any, arg3?: any) => any;
26
10
  render(): React.ReactNode;
27
11
  }
@@ -1,28 +1,11 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps, ChangeFn } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
4
- startX: string;
5
- startY: string;
6
- endX: string;
7
- endY: string;
8
- constraint: string;
9
- snap: number;
10
- constraintFn: string;
11
- startSubscript: number;
12
- endSubscript: number;
13
- };
14
- type DefaultProps = {
15
- startX: Props["startX"];
16
- startY: Props["startY"];
17
- endX: Props["endX"];
18
- endY: Props["endY"];
19
- constraint: Props["constraint"];
20
- snap: Props["snap"];
21
- constraintFn: Props["constraintFn"];
22
- };
2
+ import type { PerseusInteractionMovableLineElementOptions } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionMovableLineElementOptions {
4
+ onChange: (options: PerseusInteractionMovableLineElementOptions) => void;
5
+ }
23
6
  declare class MovableLineEditor extends React.Component<Props> {
24
- static defaultProps: DefaultProps;
25
- change: ChangeFn;
7
+ static defaultProps: PerseusInteractionMovableLineElementOptions;
8
+ handleChange(changes: Partial<PerseusInteractionMovableLineElementOptions>): void;
26
9
  render(): React.ReactNode;
27
10
  }
28
11
  export default MovableLineEditor;
@@ -1,23 +1,11 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps, ChangeFn } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
4
- startX: string;
5
- startY: string;
6
- constraint: string;
7
- snap: number;
8
- constraintFn: string;
9
- varSubscript: number;
10
- };
11
- type DefaultProps = {
12
- startX: Props["startX"];
13
- startY: Props["startY"];
14
- constraint: Props["constraint"];
15
- snap: Props["snap"];
16
- constraintFn: Props["constraintFn"];
17
- };
2
+ import type { PerseusInteractionMovablePointElementOptions } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionMovablePointElementOptions {
4
+ onChange: (options: PerseusInteractionMovablePointElementOptions) => void;
5
+ }
18
6
  declare class MovablePointEditor extends React.Component<Props> {
19
- static defaultProps: DefaultProps;
20
- change: ChangeFn;
7
+ static defaultProps: PerseusInteractionMovablePointElementOptions;
8
+ handleChange(options: Partial<PerseusInteractionMovablePointElementOptions>): void;
21
9
  render(): React.ReactNode;
22
10
  }
23
11
  export default MovablePointEditor;
@@ -1,26 +1,11 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
4
- x: string;
5
- y: string;
6
- rangeMin: string;
7
- rangeMax: string;
8
- color: string;
9
- strokeDasharray: string;
10
- strokeWidth: number;
11
- };
12
- type DefaultProps = {
13
- x: Props["x"];
14
- y: Props["y"];
15
- rangeMin: Props["rangeMin"];
16
- rangeMax: Props["rangeMax"];
17
- color: Props["color"];
18
- strokeDasharray: Props["strokeDasharray"];
19
- strokeWidth: Props["strokeWidth"];
20
- };
2
+ import type { PerseusInteractionParametricElementOptions } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionParametricElementOptions {
4
+ onChange: (options: PerseusInteractionParametricElementOptions) => void;
5
+ }
21
6
  declare class ParametricEditor extends React.Component<Props> {
22
- static defaultProps: DefaultProps;
23
- change: (arg1: any, arg2?: any, arg3?: any) => any;
7
+ static defaultProps: PerseusInteractionParametricElementOptions;
8
+ handleChange(changes: Partial<PerseusInteractionParametricElementOptions>): void;
24
9
  render(): React.ReactNode;
25
10
  }
26
11
  export default ParametricEditor;
@@ -1,18 +1,11 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
4
- coordX: string;
5
- coordY: string;
6
- color: string;
7
- };
8
- type DefaultProps = {
9
- coordX: Props["coordX"];
10
- coordY: Props["coordY"];
11
- color: Props["color"];
12
- };
2
+ import type { PerseusInteractionPointElementOptions } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionPointElementOptions {
4
+ onChange: (options: PerseusInteractionPointElementOptions) => void;
5
+ }
13
6
  declare class PointEditor extends React.Component<Props> {
14
- static defaultProps: DefaultProps;
15
- change: (arg1: any, arg2?: any, arg3?: any) => any;
7
+ static defaultProps: PerseusInteractionPointElementOptions;
8
+ handleChange(changes: Partial<PerseusInteractionPointElementOptions>): void;
16
9
  render(): React.ReactNode;
17
10
  }
18
11
  export default PointEditor;
@@ -1,22 +1,11 @@
1
1
  import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = ChangeableProps & {
4
- color: string;
5
- coordX: string;
6
- coordY: string;
7
- height: string;
8
- width: string;
9
- };
10
- type DefaultProps = {
11
- color: Props["color"];
12
- coordX: Props["coordX"];
13
- coordY: Props["coordY"];
14
- height: Props["height"];
15
- width: Props["width"];
16
- };
2
+ import type { PerseusInteractionRectangleElementOptions } from "@khanacademy/perseus-core";
3
+ interface Props extends PerseusInteractionRectangleElementOptions {
4
+ onChange: (options: PerseusInteractionRectangleElementOptions) => void;
5
+ }
17
6
  declare class RectangleEditor extends React.Component<Props> {
18
- static defaultProps: DefaultProps;
19
- change: (arg1: any, arg2?: any, arg3?: any) => any;
7
+ static defaultProps: PerseusInteractionRectangleElementOptions;
8
+ handleChange(changes: Partial<PerseusInteractionRectangleElementOptions>): void;
20
9
  render(): React.ReactNode;
21
10
  }
22
11
  export default RectangleEditor;
@@ -1,17 +1,12 @@
1
1
  import * as React from "react";
2
- import type { ChangeFn } from "../../../mixins/changeable";
3
2
  import type { APIOptionsWithDefaults } from "@khanacademy/perseus";
4
3
  import type { AxisLabelLocation, ShowAxisArrows, ShowAxisTicks, MarkingsType, PerseusImageBackground } from "@khanacademy/perseus-core";
5
4
  type Range = [min: number, max: number];
6
- interface Props {
7
- /**
8
- * The size of the graph area in pixels.
9
- */
10
- box: [x: number, y: number];
5
+ export interface InteractiveGraphSettingsData {
11
6
  /**
12
7
  * The labels for the x and y axes.
13
8
  */
14
- labels: ReadonlyArray<string>;
9
+ labels: string[];
15
10
  /**
16
11
  * Specifies the location of the labels on the graph. default: "onAxis".
17
12
  * - "onAxis": Labels are positioned on the axis at the right (x) and top (y) of the graph.
@@ -69,12 +64,18 @@ interface Props {
69
64
  * Whether to show tooltips on the graph.
70
65
  */
71
66
  showTooltips: boolean;
72
- onChange: (arg1: Partial<Props>) => void;
67
+ }
68
+ interface Props extends InteractiveGraphSettingsData {
69
+ /**
70
+ * The size of the graph area in pixels.
71
+ */
72
+ box: [x: number, y: number];
73
+ onChange: (settings: InteractiveGraphSettingsData) => void;
73
74
  apiOptions: APIOptionsWithDefaults;
74
75
  }
75
76
  interface State {
76
77
  isExpanded: boolean;
77
- labelsTextbox: ReadonlyArray<string>;
78
+ labelsTextbox: string[];
78
79
  labelLocation: AxisLabelLocation;
79
80
  gridStepTextbox: [x: number, y: number];
80
81
  snapStepTextbox: [x: number, y: number];
@@ -90,7 +91,7 @@ declare class InteractiveGraphSettings extends React.Component<Props, State> {
90
91
  labelXRef: React.RefObject<HTMLInputElement>;
91
92
  labelYRef: React.RefObject<HTMLInputElement>;
92
93
  static stateFromProps(props: Props): {
93
- labelsTextbox: readonly string[];
94
+ labelsTextbox: string[];
94
95
  labelLocation: AxisLabelLocation;
95
96
  gridStepTextbox: [x: number, y: number];
96
97
  snapStepTextbox: [x: number, y: number];
@@ -140,7 +141,7 @@ declare class InteractiveGraphSettings extends React.Component<Props, State> {
140
141
  componentDidMount(): void;
141
142
  UNSAFE_componentWillReceiveProps(nextProps: any): void;
142
143
  componentWillUnmount(): void;
143
- change: ChangeFn;
144
+ handleChange(changes: Partial<InteractiveGraphSettingsData>): void;
144
145
  changeBackgroundUrl: (e: any) => void;
145
146
  renderLabelChoices: (choices: any) => any;
146
147
  validRange: (range: any) => true | "Range must be a valid number" | "Range must have a higher number on the right";
@@ -155,9 +156,9 @@ declare class InteractiveGraphSettings extends React.Component<Props, State> {
155
156
  changeShowAxisArrows: (axis: keyof ShowAxisArrows) => void;
156
157
  changeShowAxisTicks: (axis: keyof ShowAxisTicks) => void;
157
158
  changeStepsBasedOnRange: () => void;
158
- changeStep: (step: any) => void;
159
- changeSnapStep: (snapStep: any) => void;
160
- changeGridStep: (gridStep: any) => void;
159
+ changeStep: (step: [number, number]) => void;
160
+ changeSnapStep: (snapStep: [number, number]) => void;
161
+ changeGridStep: (gridStep: [number, number]) => void;
161
162
  changeGraph: () => void;
162
163
  render(): React.JSX.Element;
163
164
  }
@@ -1,119 +1,57 @@
1
1
  import * as React from "react";
2
+ import type { InteractiveGraphSettingsData } from "./components/interactive-graph-settings";
2
3
  import type { APIOptionsWithDefaults } from "@khanacademy/perseus";
3
- import type { PerseusInteractiveGraphUserInput, LockedFigure, PerseusImageBackground, PerseusInteractiveGraphWidgetOptions, PerseusGraphType, MarkingsType, AxisLabelLocation, ShowAxisArrows, ShowAxisTicks } from "@khanacademy/perseus-core";
4
- type Range = [min: number, max: number];
5
- export type Props = {
6
- apiOptions: APIOptionsWithDefaults;
7
- /**
8
- * The labels for the x and y axes.
9
- */
10
- labels: ReadonlyArray<string>;
11
- /**
12
- * Specifies the location of the labels on the graph. default: "onAxis".
13
- * - "onAxis": Labels are positioned on the axis at the right (x) and top (y) of the graph.
14
- * - "alongEdge": Labels are centered along the bottom (x) and left (y) edges of the graph.
15
- * The y label is rotated. Typically used when the range min is near 0 with longer labels.
16
- */
17
- labelLocation?: AxisLabelLocation;
18
- /**
19
- * The range of the graph in the x and y directions.
20
- */
21
- range: [x: Range, y: Range];
22
- /**
23
- * Whether the graph is bounded on the x and y axes.
24
- */
25
- showAxisArrows: ShowAxisArrows;
26
- /**
27
- * Whether to show tick marks and tick numbers per axis.
28
- */
29
- showAxisTicks: ShowAxisTicks;
30
- /**
31
- * How far apart the tick marks on the axes are in the x and y
32
- * directions.
33
- */
34
- step: [x: number, y: number];
35
- /**
36
- * How far apart the grid lines are in the x and y directions.
37
- */
38
- gridStep: [x: number, y: number];
39
- /**
40
- * How far apart the snap-to points are in the x and y directions.
41
- */
42
- snapStep: [x: number, y: number];
43
- /**
44
- * The size of the graph in pixels.
45
- */
46
- box: [x: number, y: number];
4
+ import type { PerseusInteractiveGraphWidgetOptions, PerseusGraphType } from "@khanacademy/perseus-core";
5
+ interface State {
47
6
  /**
48
7
  * An error message to display in the graph area, or true if the
49
8
  * graph is valid.
50
9
  */
51
10
  valid: true | string;
52
- /**
53
- * The background image to display in the graph area and its properties.
54
- */
55
- backgroundImage: PerseusImageBackground;
56
- /**
57
- * The type of markings to display on the graph.
58
- * - graph: shows the axes and the grid lines
59
- * - grid: shows only the grid lines
60
- * - none: shows no markings
61
- */
62
- markings: MarkingsType;
63
- /**
64
- * Whether to show the protractor on the graph.
65
- */
66
- showProtractor: boolean;
67
- /**
68
- * Whether to show tooltips on the graph.
69
- * (Currently not used, but will be in the future.)
70
- */
71
- showTooltips: boolean;
72
- /**
73
- * The current correct answer for the graph. Updated by this component
74
- * when the graph is changed.
75
- *
76
- * Note that the "Correct answer:" textbox is not an interactive
77
- * element. Instead, it is a representation of the correct answer based
78
- * on the state of the interactive graph previewed at the bottom of the
79
- * editor page.
80
- */
81
- correct: PerseusGraphType;
82
- /**
83
- * The locked figures to display in the graph area.
84
- * Locked figures are graph elements (points, lines, line segmeents,
85
- * etc.) that are locked in place and not interactive.
86
- */
87
- lockedFigures?: Array<LockedFigure>;
88
- fullGraphAriaLabel?: string;
89
- fullGraphAriaDescription?: string;
90
- /**
91
- * The graph to display in the graph area.
92
- */
93
- graph: PerseusInteractiveGraphUserInput;
94
- onChange: (props: Partial<Props>) => void;
11
+ }
12
+ export interface Props extends PerseusInteractiveGraphWidgetOptions {
13
+ apiOptions: APIOptionsWithDefaults;
14
+ onChange: (options: PerseusInteractiveGraphWidgetOptions) => void;
95
15
  static?: boolean;
96
- /**
97
- * Whether this widget is graded.
98
- */
99
- graded?: boolean;
100
- };
16
+ }
101
17
  /**
102
18
  * An editor for the InteractiveGraph widget, which allows the user to
103
19
  * specify the graph's properties and the correct answer.
104
20
  *
105
21
  * Used in the exercise editor.
106
22
  */
107
- declare class InteractiveGraphEditor extends React.Component<Props> {
23
+ declare class InteractiveGraphEditor extends React.Component<Props, State> {
108
24
  static bestPractices: {
109
25
  url: string;
110
26
  label: string;
111
27
  };
112
28
  displayName: string;
113
29
  className: string;
114
- static defaultProps: PerseusInteractiveGraphWidgetOptions & {
115
- valid: true | string;
30
+ state: State;
31
+ static defaultProps: {
32
+ step: [number, number];
33
+ gridStep?: [x: number, y: number];
34
+ snapStep?: [x: number, y: number];
35
+ backgroundImage: import("@khanacademy/perseus-core").PerseusImageBackground;
36
+ markings: import("@khanacademy/perseus-core").MarkingsType;
37
+ labels: string[];
38
+ labelLocation: import("@khanacademy/perseus-core").AxisLabelLocation;
39
+ showAxisArrows: import("@khanacademy/perseus-core").ShowAxisArrows;
40
+ showAxisTicks: import("@khanacademy/perseus-core").ShowAxisTicks;
41
+ showProtractor: boolean;
42
+ showRuler?: boolean;
43
+ showTooltips: boolean;
44
+ rulerLabel?: string;
45
+ rulerTicks?: number;
46
+ range: import("@khanacademy/perseus-core").GraphRange;
47
+ graph: PerseusGraphType;
48
+ correct: PerseusGraphType;
49
+ lockedFigures: import("@khanacademy/perseus-core").LockedFigure[];
50
+ fullGraphAriaLabel?: string;
51
+ fullGraphAriaDescription?: string;
116
52
  };
53
+ handleChange(changes: Partial<PerseusInteractiveGraphWidgetOptions>): void;
54
+ handleSettingsChange({ valid, ...settings }: InteractiveGraphSettingsData): void;
117
55
  changeStartCoords: (coords: any) => void;
118
56
  changePointLabels: (pointLabels: ReadonlyArray<string>) => void;
119
57
  changeShowPointLabels: (showPointLabels: boolean) => void;
@@ -2,7 +2,7 @@
2
2
  * Controlled list of answer choices, handles adding and removing answers.
3
3
  */
4
4
  import * as React from "react";
5
- export interface AnswerChoicesProps {
5
+ interface AnswerChoicesProps {
6
6
  choices: ReadonlyArray<string>;
7
7
  onChange: (choices: ReadonlyArray<string>) => void;
8
8
  editingDisabled: boolean;
@@ -2,7 +2,7 @@
2
2
  * Controlled component for selecting the question image, for answer labeling.
3
3
  */
4
4
  import * as React from "react";
5
- export interface SelectImageProps {
5
+ interface SelectImageProps {
6
6
  onChange: (url: string) => void;
7
7
  url: string;
8
8
  editingDisabled?: boolean;
@@ -18,7 +18,13 @@ interface State {
18
18
  */
19
19
  declare class NumericInputEditor extends React.Component<Props, State> {
20
20
  static displayName: string;
21
- static defaultProps: any;
21
+ static defaultProps: {
22
+ answers: import("@khanacademy/perseus-core").PerseusNumericInputAnswer[];
23
+ labelText?: string | undefined;
24
+ size: string;
25
+ coefficient: boolean;
26
+ textAlign: "left" | "right" | "center";
27
+ };
22
28
  constructor(props: Props);
23
29
  change: ChangeFn;
24
30
  onToggleAnswers: (answerIndex: number) => void;