@khanacademy/perseus 32.0.1 → 33.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,14 +105,7 @@ export declare const ApiOptions: {
105
105
  "linear-system"?: boolean | undefined;
106
106
  "unlimited-point"?: boolean | undefined;
107
107
  } & {
108
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
109
108
  "interactive-graph-locked-features-labels"?: boolean | undefined;
110
- } & {
111
- "start-coords-ui-phase-1"?: boolean | undefined;
112
- "start-coords-ui-phase-2"?: boolean | undefined;
113
- "start-coords-ui-point"?: boolean | undefined;
114
- "start-coords-ui-polygon"?: boolean | undefined;
115
- "start-coords-ui-angle"?: boolean | undefined;
116
109
  }) | undefined;
117
110
  } | undefined;
118
111
  onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -379,6 +379,8 @@ export type PerseusInteractiveGraphWidgetOptions = {
379
379
  graph: PerseusGraphType;
380
380
  correct: PerseusGraphType;
381
381
  lockedFigures?: ReadonlyArray<LockedFigure>;
382
+ fullGraphAriaLabel?: string;
383
+ fullGraphAriaDescription?: string;
382
384
  };
383
385
  declare const lockedFigureColorNames: readonly ["blue", "green", "grayH", "purple", "pink", "orange", "red"];
384
386
  export type LockedFigureColor = (typeof lockedFigureColorNames)[number];
@@ -450,7 +452,7 @@ export type PerseusGraphTypeAngle = {
450
452
  angleOffsetDeg?: number;
451
453
  snapDegrees?: number;
452
454
  match?: "congruent";
453
- coords?: [Coord, Coord, Coord];
455
+ coords?: [Coord, Coord, Coord] | null;
454
456
  startCoords?: [Coord, Coord, Coord];
455
457
  };
456
458
  export type PerseusGraphTypeCircle = {
@@ -464,18 +466,18 @@ export type PerseusGraphTypeCircle = {
464
466
  } & PerseusGraphTypeCommon;
465
467
  export type PerseusGraphTypeLinear = {
466
468
  type: "linear";
467
- coords?: CollinearTuple;
469
+ coords?: CollinearTuple | null;
468
470
  startCoords?: CollinearTuple;
469
471
  } & PerseusGraphTypeCommon;
470
472
  export type PerseusGraphTypeLinearSystem = {
471
473
  type: "linear-system";
472
- coords?: CollinearTuple[];
474
+ coords?: CollinearTuple[] | null;
473
475
  startCoords?: CollinearTuple[];
474
476
  } & PerseusGraphTypeCommon;
475
477
  export type PerseusGraphTypePoint = {
476
478
  type: "point";
477
479
  numPoints?: number | "unlimited";
478
- coords?: ReadonlyArray<Coord>;
480
+ coords?: ReadonlyArray<Coord> | null;
479
481
  startCoords?: ReadonlyArray<Coord>;
480
482
  } & PerseusGraphTypeCommon;
481
483
  export type PerseusGraphTypePolygon = {
@@ -485,28 +487,28 @@ export type PerseusGraphTypePolygon = {
485
487
  showSides?: boolean;
486
488
  snapTo?: "grid" | "angles" | "sides";
487
489
  match?: "similar" | "congruent" | "approx";
488
- coords?: ReadonlyArray<Coord>;
490
+ coords?: ReadonlyArray<Coord> | null;
489
491
  startCoords?: ReadonlyArray<Coord>;
490
492
  } & PerseusGraphTypeCommon;
491
493
  export type PerseusGraphTypeQuadratic = {
492
494
  type: "quadratic";
493
- coords?: [Coord, Coord, Coord];
495
+ coords?: [Coord, Coord, Coord] | null;
494
496
  startCoords?: [Coord, Coord, Coord];
495
497
  } & PerseusGraphTypeCommon;
496
498
  export type PerseusGraphTypeSegment = {
497
499
  type: "segment";
498
500
  numSegments?: number;
499
- coords?: CollinearTuple[];
501
+ coords?: CollinearTuple[] | null;
500
502
  startCoords?: CollinearTuple[];
501
503
  } & PerseusGraphTypeCommon;
502
504
  export type PerseusGraphTypeSinusoid = {
503
505
  type: "sinusoid";
504
- coords?: ReadonlyArray<Coord>;
506
+ coords?: ReadonlyArray<Coord> | null;
505
507
  startCoords?: ReadonlyArray<Coord>;
506
508
  } & PerseusGraphTypeCommon;
507
509
  export type PerseusGraphTypeRay = {
508
510
  type: "ray";
509
- coords?: CollinearTuple;
511
+ coords?: CollinearTuple | null;
510
512
  startCoords?: CollinearTuple;
511
513
  } & PerseusGraphTypeCommon;
512
514
  export type PerseusLabelImageWidgetOptions = {
@@ -150,14 +150,7 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<SharedRendererProps
150
150
  "linear-system"?: boolean | undefined;
151
151
  "unlimited-point"?: boolean | undefined;
152
152
  } & {
153
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
154
153
  "interactive-graph-locked-features-labels"?: boolean | undefined;
155
- } & {
156
- "start-coords-ui-phase-1"?: boolean | undefined;
157
- "start-coords-ui-phase-2"?: boolean | undefined;
158
- "start-coords-ui-point"?: boolean | undefined;
159
- "start-coords-ui-polygon"?: boolean | undefined;
160
- "start-coords-ui-angle"?: boolean | undefined;
161
154
  }) | undefined;
162
155
  } | undefined;
163
156
  onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
package/dist/types.d.ts CHANGED
@@ -75,8 +75,7 @@ type TrackInteractionArgs = {
75
75
  correct?: boolean;
76
76
  } & Partial<TrackingGradedGroupExtraArguments> & Partial<TrackingSequenceExtraArguments>;
77
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-m2b", "interactive-graph-locked-features-labels"];
79
- export declare const InteractiveGraphEditorFlags: readonly ["start-coords-ui-phase-1", "start-coords-ui-phase-2", "start-coords-ui-point", "start-coords-ui-polygon", "start-coords-ui-angle"];
78
+ export declare const InteractiveGraphLockedFeaturesFlags: readonly ["interactive-graph-locked-features-labels"];
80
79
  /**
81
80
  * APIOptions provides different ways to customize the behaviour of Perseus.
82
81
  *
@@ -208,8 +207,6 @@ export type APIOptions = Readonly<{
208
207
  [Key in (typeof MafsGraphTypeFlags)[number]]?: boolean;
209
208
  } & {
210
209
  [Key in (typeof InteractiveGraphLockedFeaturesFlags)[number]]?: boolean;
211
- } & {
212
- [Key in (typeof InteractiveGraphEditorFlags)[number]]?: boolean;
213
210
  });
214
211
  };
215
212
  /**
@@ -151,14 +151,7 @@ declare const _default: Readonly<{
151
151
  "linear-system"?: boolean | undefined;
152
152
  "unlimited-point"?: boolean | undefined;
153
153
  } & {
154
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
155
154
  "interactive-graph-locked-features-labels"?: boolean | undefined;
156
- } & {
157
- "start-coords-ui-phase-1"?: boolean | undefined;
158
- "start-coords-ui-phase-2"?: boolean | undefined;
159
- "start-coords-ui-point"?: boolean | undefined;
160
- "start-coords-ui-polygon"?: boolean | undefined;
161
- "start-coords-ui-angle"?: boolean | undefined;
162
155
  }) | undefined;
163
156
  } | undefined;
164
157
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -237,14 +230,7 @@ declare const _default: Readonly<{
237
230
  "linear-system"?: boolean | undefined;
238
231
  "unlimited-point"?: boolean | undefined;
239
232
  } & {
240
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
241
233
  "interactive-graph-locked-features-labels"?: boolean | undefined;
242
- } & {
243
- "start-coords-ui-phase-1"?: boolean | undefined;
244
- "start-coords-ui-phase-2"?: boolean | undefined;
245
- "start-coords-ui-point"?: boolean | undefined;
246
- "start-coords-ui-polygon"?: boolean | undefined;
247
- "start-coords-ui-angle"?: boolean | undefined;
248
234
  }) | undefined;
249
235
  } | undefined;
250
236
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -323,14 +309,7 @@ declare const _default: Readonly<{
323
309
  "linear-system"?: boolean | undefined;
324
310
  "unlimited-point"?: boolean | undefined;
325
311
  } & {
326
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
327
312
  "interactive-graph-locked-features-labels"?: boolean | undefined;
328
- } & {
329
- "start-coords-ui-phase-1"?: boolean | undefined;
330
- "start-coords-ui-phase-2"?: boolean | undefined;
331
- "start-coords-ui-point"?: boolean | undefined;
332
- "start-coords-ui-polygon"?: boolean | undefined;
333
- "start-coords-ui-angle"?: boolean | undefined;
334
313
  }) | undefined;
335
314
  } | undefined;
336
315
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -408,14 +387,7 @@ declare const _default: Readonly<{
408
387
  "linear-system"?: boolean | undefined;
409
388
  "unlimited-point"?: boolean | undefined;
410
389
  } & {
411
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
412
390
  "interactive-graph-locked-features-labels"?: boolean | undefined;
413
- } & {
414
- "start-coords-ui-phase-1"?: boolean | undefined;
415
- "start-coords-ui-phase-2"?: boolean | undefined;
416
- "start-coords-ui-point"?: boolean | undefined;
417
- "start-coords-ui-polygon"?: boolean | undefined;
418
- "start-coords-ui-angle"?: boolean | undefined;
419
391
  }) | undefined;
420
392
  } | undefined;
421
393
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -494,14 +466,7 @@ declare const _default: Readonly<{
494
466
  "linear-system"?: boolean | undefined;
495
467
  "unlimited-point"?: boolean | undefined;
496
468
  } & {
497
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
498
469
  "interactive-graph-locked-features-labels"?: boolean | undefined;
499
- } & {
500
- "start-coords-ui-phase-1"?: boolean | undefined;
501
- "start-coords-ui-phase-2"?: boolean | undefined;
502
- "start-coords-ui-point"?: boolean | undefined;
503
- "start-coords-ui-polygon"?: boolean | undefined;
504
- "start-coords-ui-angle"?: boolean | undefined;
505
470
  }) | undefined;
506
471
  } | undefined;
507
472
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -580,14 +545,7 @@ declare const _default: Readonly<{
580
545
  "linear-system"?: boolean | undefined;
581
546
  "unlimited-point"?: boolean | undefined;
582
547
  } & {
583
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
584
548
  "interactive-graph-locked-features-labels"?: boolean | undefined;
585
- } & {
586
- "start-coords-ui-phase-1"?: boolean | undefined;
587
- "start-coords-ui-phase-2"?: boolean | undefined;
588
- "start-coords-ui-point"?: boolean | undefined;
589
- "start-coords-ui-polygon"?: boolean | undefined;
590
- "start-coords-ui-angle"?: boolean | undefined;
591
549
  }) | undefined;
592
550
  } | undefined;
593
551
  onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
@@ -1,3 +1,5 @@
1
1
  import * as React from "react";
2
+ import type { Interval } from "mafs";
3
+ export declare const shouldShowLabel: (number: number, range: [Interval, Interval]) => boolean;
2
4
  export declare function generateTickLocations(tickStep: number, min: number, max: number): number[];
3
5
  export declare const AxisTicks: () => React.JSX.Element;
@@ -3,20 +3,12 @@ import type { GraphRange } from "../../../perseus-types";
3
3
  import type { SizeClass } from "../../../util/sizing-utils";
4
4
  import type { vec } from "mafs";
5
5
  interface GridProps {
6
- tickStep: vec.Vector2;
7
6
  gridStep: vec.Vector2;
8
7
  range: GraphRange;
9
8
  containerSizeClass: SizeClass;
10
9
  markings: "graph" | "grid" | "none";
10
+ width: number;
11
+ height: number;
11
12
  }
12
- /**
13
- * lineLabelText get the text that should
14
- * be displayed for a specific tick place
15
- *
16
- * @param {number} n the tick number
17
- * @param {number} tickStep how frequently a label should appear
18
- * @param {vec.Vector2} range the min/max range on the axis
19
- */
20
- export declare const lineLabelText: (n: number, tickStep: number, range: vec.Vector2) => string;
21
13
  export declare const Grid: (props: GridProps) => React.JSX.Element | null;
22
14
  export {};
@@ -5,6 +5,8 @@ export type LockedFunctionOptions = Omit<Partial<LockedFunctionType>, "type" | "
5
5
  export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
6
6
  declare class InteractiveGraphQuestionBuilder {
7
7
  private content;
8
+ private fullGraphAriaLabel?;
9
+ private fullGraphAriaDescription?;
8
10
  private backgroundImage?;
9
11
  private gridStep;
10
12
  private labels;
@@ -20,6 +22,8 @@ declare class InteractiveGraphQuestionBuilder {
20
22
  private staticMode;
21
23
  build(): PerseusRenderer;
22
24
  withContent(content: string): InteractiveGraphQuestionBuilder;
25
+ withFullGraphAriaLabel(label: string): InteractiveGraphQuestionBuilder;
26
+ withFullGraphAriaDescription(description: string): InteractiveGraphQuestionBuilder;
23
27
  withStaticMode(staticMode: boolean): InteractiveGraphQuestionBuilder;
24
28
  withBackgroundImage(url: string, height: number, width: number, options?: {
25
29
  scale?: number;
@@ -1,6 +1,7 @@
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 { vec } from "mafs";
4
5
  import "mafs/core.css";
5
6
  import "./mafs-styles.css";
6
7
  export type MafsGraphProps = {
@@ -15,9 +16,15 @@ export type MafsGraphProps = {
15
16
  showTooltips: Required<InteractiveGraphProps["showTooltips"]>;
16
17
  showProtractor: boolean;
17
18
  labels: InteractiveGraphProps["labels"];
19
+ fullGraphAriaLabel?: InteractiveGraphProps["fullGraphAriaLabel"];
20
+ fullGraphAriaDescription?: InteractiveGraphProps["fullGraphAriaDescription"];
18
21
  state: InteractiveGraphState;
19
22
  dispatch: React.Dispatch<InteractiveGraphAction>;
20
23
  readOnly: boolean;
21
24
  static: boolean | null | undefined;
22
25
  };
23
26
  export declare const MafsGraph: (props: MafsGraphProps) => React.JSX.Element;
27
+ export declare const calculateNestedSVGCoords: (range: vec.Vector2[], width: number, height: number) => {
28
+ viewboxX: number;
29
+ viewboxY: number;
30
+ };
@@ -19,6 +19,8 @@ export type StatefulMafsGraphProps = {
19
19
  showTooltips: Required<InteractiveGraphProps["showTooltips"]>;
20
20
  showProtractor: boolean;
21
21
  labels: InteractiveGraphProps["labels"];
22
+ fullGraphAriaLabel?: InteractiveGraphProps["fullGraphAriaLabel"];
23
+ fullGraphAriaDescription?: InteractiveGraphProps["fullGraphAriaDescription"];
22
24
  readOnly: boolean;
23
25
  static: InteractiveGraphProps["static"];
24
26
  };
@@ -143,14 +143,7 @@ declare const _default: Readonly<{
143
143
  "linear-system"?: boolean | undefined;
144
144
  "unlimited-point"?: boolean | undefined;
145
145
  } & {
146
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
147
146
  "interactive-graph-locked-features-labels"?: boolean | undefined;
148
- } & {
149
- "start-coords-ui-phase-1"?: boolean | undefined;
150
- "start-coords-ui-phase-2"?: boolean | undefined;
151
- "start-coords-ui-point"?: boolean | undefined;
152
- "start-coords-ui-polygon"?: boolean | undefined;
153
- "start-coords-ui-angle"?: boolean | undefined;
154
147
  }) | undefined;
155
148
  } | undefined;
156
149
  onWidgetStartProps?: ((widgets: import("../..").PerseusWidgetsMap) => void) | undefined;
@@ -213,14 +206,7 @@ declare const _default: Readonly<{
213
206
  "linear-system"?: boolean | undefined;
214
207
  "unlimited-point"?: boolean | undefined;
215
208
  } & {
216
- "interactive-graph-locked-features-m2b"?: boolean | undefined;
217
209
  "interactive-graph-locked-features-labels"?: boolean | undefined;
218
- } & {
219
- "start-coords-ui-phase-1"?: boolean | undefined;
220
- "start-coords-ui-phase-2"?: boolean | undefined;
221
- "start-coords-ui-point"?: boolean | undefined;
222
- "start-coords-ui-polygon"?: boolean | undefined;
223
- "start-coords-ui-angle"?: boolean | undefined;
224
210
  }) | undefined;
225
211
  } | undefined;
226
212
  onWidgetStartProps?: ((widgets: import("../..").PerseusWidgetsMap) => void) | undefined;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "32.0.1",
6
+ "version": "33.1.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -1,12 +0,0 @@
1
- import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = {
4
- value?: string;
5
- } & ChangeableProps;
6
- declare class ArrowPicker extends React.Component<Props> {
7
- static defaultProps: {
8
- value: string;
9
- };
10
- render(): React.ReactNode;
11
- }
12
- export default ArrowPicker;
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = {
4
- lightColors?: boolean;
5
- value?: string;
6
- } & ChangeableProps;
7
- declare class ColorPicker extends React.Component<Props> {
8
- static defaultProps: {
9
- lightColors: boolean;
10
- value: any;
11
- };
12
- render(): React.ReactNode;
13
- }
14
- export default ColorPicker;
@@ -1,12 +0,0 @@
1
- import * as React from "react";
2
- import type { ChangeableProps } from "../../mixins/changeable";
3
- type Props = {
4
- value?: string;
5
- } & ChangeableProps;
6
- declare class DashPicker extends React.Component<Props> {
7
- static defaultProps: {
8
- value: string;
9
- };
10
- render(): React.ReactNode;
11
- }
12
- export default DashPicker;
@@ -1,22 +0,0 @@
1
- import * as React from "react";
2
- type Props = {
3
- children: React.ReactElement<any> | ReadonlyArray<React.ReactElement<any>>;
4
- initiallyVisible: boolean;
5
- onDelete?: () => void | null | undefined;
6
- onDown?: () => void | null | undefined;
7
- onUp?: () => void | null | undefined;
8
- title: string | React.ReactElement<any>;
9
- };
10
- type State = {
11
- show: boolean;
12
- };
13
- declare class ElementContainer extends React.Component<Props, State> {
14
- static defaultProps: {
15
- initiallyVisible: boolean;
16
- title: string;
17
- };
18
- constructor(props: Props);
19
- toggle: (e: React.SyntheticEvent) => void;
20
- render(): React.ReactNode;
21
- }
22
- export default ElementContainer;
@@ -1,13 +0,0 @@
1
- import * as React from "react";
2
- type ShowTickLabelProps = {
3
- gridStep: number;
4
- tickStep: number;
5
- label: number;
6
- graphEdge: number;
7
- position: number;
8
- axisOutOfBounds: boolean;
9
- };
10
- export declare const AxisTickLabels: () => React.JSX.Element;
11
- export declare const showTickLabel: ({ gridStep, tickStep, label, graphEdge, position, axisOutOfBounds, }: ShowTickLabelProps) => boolean;
12
- export declare function generateTickLocations(tickStep: number, min: number, max: number): number[];
13
- export {};