@khanacademy/perseus 49.2.1 → 50.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 (146) hide show
  1. package/dist/article-renderer.d.ts +2 -6
  2. package/dist/components/graph.d.ts +1 -1
  3. package/dist/components/graphie.d.ts +1 -1
  4. package/dist/components/highlighting/ui/highlight-set-renderer.d.ts +1 -4
  5. package/dist/components/highlighting/ui/highlighting-ui.d.ts +1 -4
  6. package/dist/components/i18n-context.d.ts +1 -1
  7. package/dist/components/input-with-examples.d.ts +1 -4
  8. package/dist/components/math-input.d.ts +2 -6
  9. package/dist/components/number-input.d.ts +2 -5
  10. package/dist/components/svg-image.d.ts +1 -1
  11. package/dist/es/index.js +547 -1380
  12. package/dist/es/index.js.map +1 -1
  13. package/dist/es/strings.js +40 -85
  14. package/dist/es/strings.js.map +1 -1
  15. package/dist/hint-renderer.d.ts +1 -4
  16. package/dist/hints-renderer.d.ts +2 -5
  17. package/dist/index.d.ts +5 -7
  18. package/dist/index.js +588 -1407
  19. package/dist/index.js.map +1 -1
  20. package/dist/renderer-util.d.ts +1 -1
  21. package/dist/renderer.d.ts +2 -5
  22. package/dist/server-item-renderer.d.ts +3 -7
  23. package/dist/strings.d.ts +8 -0
  24. package/dist/strings.js +40 -84
  25. package/dist/strings.js.map +1 -1
  26. package/dist/types.d.ts +1 -2
  27. package/dist/util/extract-perseus-data.d.ts +1 -1
  28. package/dist/util/parse-perseus-json/index.d.ts +33 -4
  29. package/dist/util/parse-perseus-json/perseus-parsers/categorizer-widget.d.ts +1 -1
  30. package/dist/util/parse-perseus-json/perseus-parsers/cs-program-widget.d.ts +1 -1
  31. package/dist/util/parse-perseus-json/perseus-parsers/definition-widget.d.ts +1 -1
  32. package/dist/util/parse-perseus-json/perseus-parsers/dropdown-widget.d.ts +1 -1
  33. package/dist/util/parse-perseus-json/perseus-parsers/explanation-widget.d.ts +1 -1
  34. package/dist/util/parse-perseus-json/perseus-parsers/expression-widget.d.ts +1 -1
  35. package/dist/util/parse-perseus-json/perseus-parsers/graded-group-set-widget.d.ts +1 -1
  36. package/dist/util/parse-perseus-json/perseus-parsers/graded-group-widget.d.ts +3 -3
  37. package/dist/util/parse-perseus-json/perseus-parsers/grapher-widget.d.ts +1 -1
  38. package/dist/util/parse-perseus-json/perseus-parsers/group-widget.d.ts +1 -1
  39. package/dist/util/parse-perseus-json/perseus-parsers/hint.d.ts +1 -1
  40. package/dist/util/parse-perseus-json/perseus-parsers/iframe-widget.d.ts +1 -1
  41. package/dist/util/parse-perseus-json/perseus-parsers/image-widget.d.ts +1 -1
  42. package/dist/util/parse-perseus-json/perseus-parsers/images-map.d.ts +1 -1
  43. package/dist/util/parse-perseus-json/perseus-parsers/input-number-widget.d.ts +1 -1
  44. package/dist/util/parse-perseus-json/perseus-parsers/interaction-widget.d.ts +1 -1
  45. package/dist/util/parse-perseus-json/perseus-parsers/interactive-graph-widget.d.ts +1 -1
  46. package/dist/util/parse-perseus-json/perseus-parsers/label-image-widget.d.ts +1 -1
  47. package/dist/util/parse-perseus-json/perseus-parsers/matcher-widget.d.ts +1 -1
  48. package/dist/util/parse-perseus-json/perseus-parsers/matrix-widget.d.ts +1 -1
  49. package/dist/util/parse-perseus-json/perseus-parsers/measurer-widget.d.ts +1 -1
  50. package/dist/util/parse-perseus-json/perseus-parsers/molecule-renderer-widget.d.ts +1 -1
  51. package/dist/util/parse-perseus-json/perseus-parsers/number-line-widget.d.ts +1 -1
  52. package/dist/util/parse-perseus-json/perseus-parsers/numeric-input-widget.d.ts +1 -1
  53. package/dist/util/parse-perseus-json/perseus-parsers/orderer-widget.d.ts +1 -1
  54. package/dist/util/parse-perseus-json/perseus-parsers/passage-ref-widget.d.ts +1 -1
  55. package/dist/util/parse-perseus-json/perseus-parsers/passage-widget.d.ts +1 -1
  56. package/dist/util/parse-perseus-json/perseus-parsers/perseus-article.d.ts +3 -0
  57. package/dist/util/parse-perseus-json/perseus-parsers/perseus-image-background.d.ts +1 -1
  58. package/dist/util/parse-perseus-json/perseus-parsers/perseus-item.d.ts +1 -1
  59. package/dist/util/parse-perseus-json/perseus-parsers/perseus-renderer.d.ts +1 -1
  60. package/dist/util/parse-perseus-json/perseus-parsers/phet-simulation-widget.d.ts +1 -1
  61. package/dist/util/parse-perseus-json/perseus-parsers/plotter-widget.d.ts +1 -1
  62. package/dist/util/parse-perseus-json/perseus-parsers/python-program-widget.d.ts +1 -1
  63. package/dist/util/parse-perseus-json/perseus-parsers/radio-widget.d.ts +1 -1
  64. package/dist/util/parse-perseus-json/perseus-parsers/sorter-widget.d.ts +1 -1
  65. package/dist/util/parse-perseus-json/perseus-parsers/table-widget.d.ts +1 -1
  66. package/dist/util/parse-perseus-json/perseus-parsers/versioned-widget-options.d.ts +1 -1
  67. package/dist/util/parse-perseus-json/perseus-parsers/video-widget.d.ts +1 -1
  68. package/dist/util/parse-perseus-json/perseus-parsers/widget.d.ts +1 -1
  69. package/dist/util/parse-perseus-json/perseus-parsers/widgets-map.d.ts +1 -1
  70. package/dist/util/test-utils.d.ts +1 -1
  71. package/dist/util.d.ts +1 -1
  72. package/dist/validation.types.d.ts +9 -3
  73. package/dist/widget-ai-utils/grapher/grapher-ai-utils.d.ts +1 -1
  74. package/dist/widget-ai-utils/interactive-graph/interactive-graph-ai-utils.d.ts +1 -1
  75. package/dist/widget-ai-utils/mock-widget/prompt-utils.d.ts +13 -0
  76. package/dist/widget-ai-utils/prompt-types.d.ts +2 -1
  77. package/dist/widget-container.d.ts +1 -1
  78. package/dist/widget-type-utils.d.ts +1 -1
  79. package/dist/widgets/categorizer/categorizer.d.ts +2 -5
  80. package/dist/widgets/cs-program/cs-program.d.ts +1 -1
  81. package/dist/widgets/definition/definition.d.ts +2 -5
  82. package/dist/widgets/deprecated-standin/deprecated-standin.d.ts +1 -4
  83. package/dist/widgets/dropdown/dropdown.d.ts +2 -5
  84. package/dist/widgets/explanation/explanation.d.ts +2 -5
  85. package/dist/widgets/expression/expression.d.ts +5 -8
  86. package/dist/widgets/graded-group/graded-group-answer-bar.d.ts +1 -4
  87. package/dist/widgets/graded-group/graded-group.d.ts +2 -5
  88. package/dist/widgets/graded-group-set/graded-group-set.d.ts +1 -1
  89. package/dist/widgets/grapher/grapher.d.ts +2 -2
  90. package/dist/widgets/group/group.d.ts +2 -5
  91. package/dist/widgets/iframe/iframe.d.ts +1 -1
  92. package/dist/widgets/image/image.d.ts +2 -5
  93. package/dist/widgets/input-number/input-number.d.ts +2 -6
  94. package/dist/widgets/interaction/interaction.d.ts +1 -1
  95. package/dist/widgets/interactive-graph.d.ts +4 -6
  96. package/dist/widgets/interactive-graphs/backgrounds/grid.d.ts +2 -2
  97. package/dist/widgets/interactive-graphs/backgrounds/legacy-grid.d.ts +1 -1
  98. package/dist/widgets/interactive-graphs/graph-locked-labels-layer.d.ts +1 -1
  99. package/dist/widgets/interactive-graphs/graph-locked-layer.d.ts +1 -1
  100. package/dist/widgets/interactive-graphs/graphs/circle.d.ts +2 -0
  101. package/dist/widgets/interactive-graphs/graphs/components/angle-indicators.d.ts +1 -1
  102. package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +2 -2
  103. package/dist/widgets/interactive-graphs/locked-figures/locked-ellipse.d.ts +1 -1
  104. package/dist/widgets/interactive-graphs/locked-figures/locked-function.d.ts +1 -1
  105. package/dist/widgets/interactive-graphs/locked-figures/locked-label.d.ts +1 -1
  106. package/dist/widgets/interactive-graphs/locked-figures/locked-line.d.ts +1 -1
  107. package/dist/widgets/interactive-graphs/locked-figures/locked-point.d.ts +1 -1
  108. package/dist/widgets/interactive-graphs/locked-figures/locked-polygon.d.ts +1 -1
  109. package/dist/widgets/interactive-graphs/locked-figures/locked-vector.d.ts +1 -1
  110. package/dist/widgets/interactive-graphs/mafs-state-to-interactive-graph.d.ts +1 -1
  111. package/dist/widgets/interactive-graphs/reducer/initialize-graph-state.d.ts +1 -1
  112. package/dist/widgets/interactive-graphs/reducer/interactive-graph-state.d.ts +1 -1
  113. package/dist/widgets/interactive-graphs/reducer/use-graph-config.d.ts +2 -1
  114. package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +1 -1
  115. package/dist/widgets/interactive-graphs/types.d.ts +1 -1
  116. package/dist/widgets/interactive-graphs/utils.d.ts +1 -1
  117. package/dist/widgets/label-image/label-image.d.ts +2 -5
  118. package/dist/widgets/label-image/marker.d.ts +1 -4
  119. package/dist/widgets/matcher/matcher.d.ts +2 -5
  120. package/dist/widgets/matrix/matrix.d.ts +2 -5
  121. package/dist/widgets/measurer/measurer.d.ts +1 -1
  122. package/dist/widgets/mock-widgets/index.d.ts +2 -0
  123. package/dist/widgets/mock-widgets/mock-asset-loading-widget.d.ts +17 -0
  124. package/dist/widgets/mock-widgets/mock-widget.d.ts +47 -0
  125. package/dist/widgets/mock-widgets/score-mock-widget.d.ts +5 -0
  126. package/dist/widgets/molecule/molecule.d.ts +1 -1
  127. package/dist/widgets/number-line/number-line.d.ts +1 -4
  128. package/dist/widgets/numeric-input/numeric-input.d.ts +2 -6
  129. package/dist/widgets/orderer/orderer.d.ts +1 -1
  130. package/dist/widgets/passage/passage.d.ts +2 -5
  131. package/dist/widgets/passage-ref/passage-ref.d.ts +2 -5
  132. package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +2 -5
  133. package/dist/widgets/phet-simulation/phet-simulation.d.ts +2 -5
  134. package/dist/widgets/plotter/plotter.d.ts +2 -5
  135. package/dist/widgets/radio/base-radio.d.ts +1 -1
  136. package/dist/widgets/radio/radio-component.d.ts +2 -5
  137. package/dist/widgets/radio/radio.d.ts +1 -1
  138. package/dist/widgets/sorter/sorter.d.ts +1 -1
  139. package/dist/widgets/table/table.d.ts +2 -5
  140. package/dist/widgets/video/video.d.ts +2 -5
  141. package/dist/widgets.d.ts +1 -1
  142. package/package.json +46 -45
  143. package/dist/interactive2/objective_.d.ts +0 -34
  144. package/dist/perseus-types.d.ts +0 -980
  145. package/dist/util/answer-types.d.ts +0 -69
  146. package/dist/util/math.d.ts +0 -29
@@ -2,10 +2,10 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import Renderer from "../../renderer";
4
4
  import scoreGroup from "./score-group";
5
- import type { PerseusGroupWidgetOptions } from "../../perseus-types";
6
5
  import type { ChangeFn, FocusPath, Widget, WidgetProps } from "../../types";
7
6
  import type { PerseusGroupRubric, UserInputArray } from "../../validation.types";
8
7
  import type { GroupPromptJSON } from "../../widget-ai-utils/group/group-ai-utils";
8
+ import type { PerseusGroupWidgetOptions } from "@khanacademy/perseus-core";
9
9
  type RenderProps = PerseusGroupWidgetOptions;
10
10
  type Props = WidgetProps<RenderProps, PerseusGroupRubric>;
11
11
  type DefaultProps = {
@@ -15,10 +15,7 @@ type DefaultProps = {
15
15
  linterContext: Props["linterContext"];
16
16
  };
17
17
  declare class Group extends React.Component<Props> implements Widget {
18
- static contextType: React.Context<{
19
- strings: import("../../strings").PerseusStrings;
20
- locale: string;
21
- }>;
18
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
22
19
  context: React.ContextType<typeof PerseusI18nContext>;
23
20
  rendererRef: Renderer | null | undefined;
24
21
  static defaultProps: DefaultProps;
@@ -8,10 +8,10 @@
8
8
  */
9
9
  import * as React from "react";
10
10
  import { scoreIframe } from "./score-iframe";
11
- import type { PerseusIFrameWidgetOptions } from "../../perseus-types";
12
11
  import type { WidgetProps, Widget } from "../../types";
13
12
  import type { PerseusIFrameRubric, PerseusIFrameUserInput, UserInputStatus } from "../../validation.types";
14
13
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
14
+ import type { PerseusIFrameWidgetOptions } from "@khanacademy/perseus-core";
15
15
  type RenderProps = PerseusIFrameWidgetOptions & {
16
16
  status: UserInputStatus;
17
17
  message: string | null;
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { PerseusImageWidgetOptions } from "../../perseus-types";
4
3
  import type { ChangeFn, WidgetProps, Widget } from "../../types";
5
4
  import type { ImagePromptJSON } from "../../widget-ai-utils/image/image-ai-utils";
5
+ import type { PerseusImageWidgetOptions } from "@khanacademy/perseus-core";
6
6
  type RenderProps = PerseusImageWidgetOptions;
7
7
  type ExternalProps = WidgetProps<RenderProps>;
8
8
  type Props = ExternalProps & {
@@ -28,10 +28,7 @@ type DefaultProps = {
28
28
  linterContext: Props["linterContext"];
29
29
  };
30
30
  declare class ImageWidget extends React.Component<Props> implements Widget {
31
- static contextType: React.Context<{
32
- strings: import("../../strings").PerseusStrings;
33
- locale: string;
34
- }>;
31
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
35
32
  context: React.ContextType<typeof PerseusI18nContext>;
36
33
  static defaultProps: DefaultProps;
37
34
  isWidget: true;
@@ -1,11 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import scoreInputNumber from "./score-input-number";
4
- import type { PerseusInputNumberWidgetOptions } from "../../perseus-types";
5
- import type { PerseusStrings } from "../../strings";
6
4
  import type { Path, Widget, WidgetProps } from "../../types";
7
5
  import type { PerseusInputNumberRubric, PerseusInputNumberUserInput } from "../../validation.types";
8
6
  import type { InputNumberPromptJSON } from "../../widget-ai-utils/input-number/input-number-ai-utils";
7
+ import type { PerseusInputNumberWidgetOptions } from "@khanacademy/perseus-core";
9
8
  type RenderProps = {
10
9
  simplify: PerseusInputNumberWidgetOptions["simplify"];
11
10
  size: PerseusInputNumberWidgetOptions["size"];
@@ -30,10 +29,7 @@ type DefaultProps = {
30
29
  size: Props["size"];
31
30
  };
32
31
  declare class InputNumber extends React.Component<Props> implements Widget {
33
- static contextType: React.Context<{
34
- strings: PerseusStrings;
35
- locale: string;
36
- }>;
32
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
37
33
  context: React.ContextType<typeof PerseusI18nContext>;
38
34
  static defaultProps: DefaultProps;
39
35
  static getUserInputFromProps(props: Props): {
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import type { Coord } from "../../interactive2/types";
3
- import type { PerseusInteractionWidgetOptions } from "../../perseus-types";
4
3
  import type { Widget, WidgetProps } from "../../types";
5
4
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
5
+ import type { PerseusInteractionWidgetOptions } from "@khanacademy/perseus-core";
6
6
  type RenderProps = PerseusInteractionWidgetOptions;
7
7
  type Props = WidgetProps<RenderProps>;
8
8
  type DefaultProps = {
@@ -4,12 +4,12 @@ import scoreInteractiveGraph from "./interactive-graphs/score-interactive-graph"
4
4
  import type { StatefulMafsGraphType } from "./interactive-graphs/stateful-mafs-graph";
5
5
  import type { QuadraticGraphState } from "./interactive-graphs/types";
6
6
  import type { Coord } from "../interactive2/types";
7
- import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeSegment, GraphRange, LockedFigure, PerseusImageBackground } from "../perseus-types";
8
7
  import type { ChangeHandler, WidgetProps } from "../types";
9
8
  import type { QuadraticCoefficient, Range, SineCoefficient } from "../util/geometry";
10
9
  import type { PerseusInteractiveGraphRubric, PerseusInteractiveGraphUserInput } from "../validation.types";
11
10
  import type { InteractiveGraphPromptJSON } from "../widget-ai-utils/interactive-graph/interactive-graph-ai-utils";
12
11
  import type { UnsupportedWidgetPromptJSON } from "../widget-ai-utils/unsupported-widget";
12
+ import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeSegment, GraphRange, LockedFigure, PerseusImageBackground, MarkingsType } from "@khanacademy/perseus-core";
13
13
  type RenderProps = {
14
14
  /**
15
15
  * Where the little black axis lines & labels (ticks) should render.
@@ -36,11 +36,12 @@ type RenderProps = {
36
36
  backgroundImage?: PerseusImageBackground;
37
37
  /**
38
38
  * The type of markings to display on the graph.
39
+ * - axes: shows the axes without the gride lines
39
40
  * - graph: shows the axes and the grid lines
40
41
  * - grid: shows only the grid lines
41
42
  * - none: shows no markings
42
43
  */
43
- markings: "graph" | "grid" | "none";
44
+ markings: MarkingsType;
44
45
  /**
45
46
  * How to label the X and Y axis. default: ["x", "y"]
46
47
  */
@@ -119,10 +120,7 @@ type DefaultProps = {
119
120
  export declare function getSinusoidCoefficients(coords: ReadonlyArray<Coord>): SineCoefficient;
120
121
  export declare function getQuadraticCoefficients(coords: ReadonlyArray<Coord>): QuadraticCoefficient;
121
122
  declare class LegacyInteractiveGraph extends React.Component<Props, State> {
122
- static contextType: React.Context<{
123
- strings: import("../strings").PerseusStrings;
124
- locale: string;
125
- }>;
123
+ static contextType: React.Context<import("../components/i18n-context").I18nContextType>;
126
124
  context: React.ContextType<typeof PerseusI18nContext>;
127
125
  angle: any | null | undefined;
128
126
  circle: any | null | undefined;
@@ -1,12 +1,12 @@
1
1
  import * as React from "react";
2
- import type { GraphRange } from "../../../perseus-types";
3
2
  import type { SizeClass } from "../../../util/sizing-utils";
3
+ import type { GraphRange, MarkingsType } from "@khanacademy/perseus-core";
4
4
  import type { vec } from "mafs";
5
5
  interface GridProps {
6
6
  gridStep: vec.Vector2;
7
7
  range: GraphRange;
8
8
  containerSizeClass: SizeClass;
9
- markings: "graph" | "grid" | "none";
9
+ markings: MarkingsType;
10
10
  width: number;
11
11
  height: number;
12
12
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { PerseusImageBackground } from "../../../perseus-types";
2
+ import type { PerseusImageBackground } from "@khanacademy/perseus-core";
3
3
  interface Props {
4
4
  box: [number, number];
5
5
  backgroundImage?: PerseusImageBackground;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { LockedFigure } from "../../perseus-types";
2
+ import type { LockedFigure } from "@khanacademy/perseus-core";
3
3
  type Props = {
4
4
  lockedFigures: ReadonlyArray<LockedFigure>;
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { LockedFigure } from "../../perseus-types";
2
+ import type { LockedFigure } from "@khanacademy/perseus-core";
3
3
  import type { Interval } from "mafs";
4
4
  type Props = {
5
5
  lockedFigures: ReadonlyArray<LockedFigure>;
@@ -1,2 +1,4 @@
1
+ import type { I18nContextType } from "../../../components/i18n-context";
1
2
  import type { CircleGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
2
3
  export declare function renderCircleGraph(state: CircleGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
4
+ export declare function describeCircleGraph(state: CircleGraphState, i18n: I18nContextType): Record<string, string>;
@@ -1,6 +1,6 @@
1
1
  import { vec } from "mafs";
2
2
  import * as React from "react";
3
- import type { CollinearTuple } from "../../../../perseus-types";
3
+ import type { CollinearTuple } from "@khanacademy/perseus-core";
4
4
  import type { Interval } from "mafs";
5
5
  interface PolygonAngleProps {
6
6
  centerPoint: vec.Vector2;
@@ -1,6 +1,6 @@
1
1
  import { vec } from "mafs";
2
2
  import type { Coord } from "../../interactive2/types";
3
- import type { CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedLineStyle, PerseusRenderer } from "../../perseus-types";
3
+ import type { CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedLineStyle, MarkingsType, PerseusRenderer } from "@khanacademy/perseus-core";
4
4
  import type { Interval } from "mafs";
5
5
  export type LockedFunctionOptions = {
6
6
  color?: LockedFigureColor;
@@ -47,7 +47,7 @@ declare class InteractiveGraphQuestionBuilder {
47
47
  }): InteractiveGraphQuestionBuilder;
48
48
  withGridStep(x: number, y: number): InteractiveGraphQuestionBuilder;
49
49
  withAxisLabels(x: string, y: string): InteractiveGraphQuestionBuilder;
50
- withMarkings(markings: "graph" | "grid" | "none"): InteractiveGraphQuestionBuilder;
50
+ withMarkings(markings: MarkingsType): InteractiveGraphQuestionBuilder;
51
51
  withXRange(min: number, max: number): InteractiveGraphQuestionBuilder;
52
52
  withYRange(min: number, max: number): InteractiveGraphQuestionBuilder;
53
53
  withSnapStep(x: number, y: number): InteractiveGraphQuestionBuilder;
@@ -1,4 +1,4 @@
1
+ import { type LockedEllipseType } from "@khanacademy/perseus-core";
1
2
  import * as React from "react";
2
- import { type LockedEllipseType } from "../../../perseus-types";
3
3
  declare const LockedEllipse: (props: LockedEllipseType) => React.JSX.Element;
4
4
  export default LockedEllipse;
@@ -1,4 +1,4 @@
1
1
  import * as React from "react";
2
- import type { LockedFunctionType } from "../../../perseus-types";
2
+ import type { LockedFunctionType } from "@khanacademy/perseus-core";
3
3
  declare const LockedFunction: (props: LockedFunctionType) => React.JSX.Element | null;
4
4
  export default LockedFunction;
@@ -1,3 +1,3 @@
1
+ import { type LockedLabelType } from "@khanacademy/perseus-core";
1
2
  import * as React from "react";
2
- import { type LockedLabelType } from "../../../perseus-types";
3
3
  export default function LockedLabel(props: LockedLabelType): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { LockedLineType } from "../../../perseus-types";
2
+ import type { LockedLineType } from "@khanacademy/perseus-core";
3
3
  import type { Interval } from "mafs";
4
4
  type Props = LockedLineType & {
5
5
  range: [Interval, Interval];
@@ -1,4 +1,4 @@
1
+ import { type LockedPointType } from "@khanacademy/perseus-core";
1
2
  import * as React from "react";
2
- import { type LockedPointType } from "../../../perseus-types";
3
3
  declare const LockedPoint: (props: LockedPointType) => React.JSX.Element;
4
4
  export default LockedPoint;
@@ -1,4 +1,4 @@
1
1
  import * as React from "react";
2
- import type { LockedPolygonType } from "../../../perseus-types";
2
+ import type { LockedPolygonType } from "@khanacademy/perseus-core";
3
3
  declare const LockedPolygon: (props: LockedPolygonType) => React.JSX.Element;
4
4
  export default LockedPolygon;
@@ -1,4 +1,4 @@
1
1
  import * as React from "react";
2
- import type { LockedVectorType } from "../../../perseus-types";
2
+ import type { LockedVectorType } from "@khanacademy/perseus-core";
3
3
  declare const LockedVector: (props: LockedVectorType) => React.JSX.Element;
4
4
  export default LockedVector;
@@ -1,3 +1,3 @@
1
1
  import type { InteractiveGraphState } from "./types";
2
- import type { PerseusGraphType } from "@khanacademy/perseus";
2
+ import type { PerseusGraphType } from "@khanacademy/perseus-core";
3
3
  export declare function mafsStateToInteractiveGraph(state: InteractiveGraphState, originalGraph: PerseusGraphType): PerseusGraphType;
@@ -1,6 +1,6 @@
1
1
  import type { Coord } from "../../../interactive2/types";
2
- import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypeCircle, PerseusGraphTypeLinear, PerseusGraphTypeLinearSystem, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeQuadratic, PerseusGraphTypeRay, PerseusGraphTypeSegment, PerseusGraphTypeSinusoid } from "../../../perseus-types";
3
2
  import type { InteractiveGraphState, PairOfPoints } from "../types";
3
+ import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypeCircle, PerseusGraphTypeLinear, PerseusGraphTypeLinearSystem, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeQuadratic, PerseusGraphTypeRay, PerseusGraphTypeSegment, PerseusGraphTypeSinusoid } from "@khanacademy/perseus-core";
4
4
  import type { Interval } from "mafs";
5
5
  export type InitializeGraphStateParams = {
6
6
  range: [x: Interval, y: Interval];
@@ -1,5 +1,5 @@
1
- import type { PerseusGraphType } from "../../../perseus-types";
2
1
  import type { CircleGraphState, InteractiveGraphState } from "../types";
2
+ import type { PerseusGraphType } from "@khanacademy/perseus-core";
3
3
  export declare function getGradableGraph(state: InteractiveGraphState, initialGraph: PerseusGraphType): PerseusGraphType;
4
4
  /**
5
5
  * determine radius of a circle graph
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
+ import type { MarkingsType } from "@khanacademy/perseus-core";
2
3
  import type { Interval, vec } from "mafs";
3
4
  export type GraphConfig = {
4
5
  range: [Interval, Interval];
5
6
  tickStep: vec.Vector2;
6
7
  gridStep: vec.Vector2;
7
8
  snapStep: vec.Vector2;
8
- markings: "graph" | "grid" | "none";
9
+ markings: MarkingsType;
9
10
  showTooltips: boolean;
10
11
  graphDimensionsInPixels: vec.Vector2;
11
12
  width: number;
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import type { InteractiveGraphProps } from "./types";
3
- import type { PerseusGraphType } from "../../perseus-types";
4
3
  import type { APIOptions } from "../../types";
5
4
  import type { PerseusInteractiveGraphUserInput } from "../../validation.types";
5
+ import type { PerseusGraphType } from "@khanacademy/perseus-core";
6
6
  export type StatefulMafsGraphProps = {
7
7
  flags?: APIOptions["flags"];
8
8
  box: [number, number];
@@ -1,7 +1,7 @@
1
1
  import type { InteractiveGraphAction } from "./reducer/interactive-graph-action";
2
2
  import type { Coord } from "../../interactive2/types";
3
- import type { PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
4
3
  import type { WidgetProps } from "../../types";
4
+ import type { PerseusInteractiveGraphWidgetOptions } from "@khanacademy/perseus-core";
5
5
  import type { Interval, vec } from "mafs";
6
6
  import type { ReactNode } from "react";
7
7
  export type InteractiveGraphProps = WidgetProps<PerseusInteractiveGraphWidgetOptions, PerseusInteractiveGraphWidgetOptions>;
@@ -1,7 +1,7 @@
1
1
  import type { MafsGraphProps } from "./mafs-graph";
2
2
  import type { InteractiveGraphState, UnlimitedGraphState } from "./types";
3
3
  import type { Coord } from "../../interactive2/types";
4
- import type { PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
4
+ import type { PerseusInteractiveGraphWidgetOptions } from "@khanacademy/perseus-core";
5
5
  import type { Interval, vec } from "mafs";
6
6
  /**
7
7
  * 44 is touch best practice and AAA compliant for WCAG
@@ -12,10 +12,10 @@ import scoreLabelImage from "./score-label-image";
12
12
  import type { InteractiveMarkerType } from "./types";
13
13
  import type { DependencyProps } from "../../dependencies";
14
14
  import type { ChangeableProps } from "../../mixins/changeable";
15
- import type { PerseusLabelImageWidgetOptions } from "../../perseus-types";
16
15
  import type { APIOptions, Widget } from "../../types";
17
16
  import type { PerseusLabelImageRubric, PerseusLabelImageUserInput } from "../../validation.types";
18
17
  import type { LabelImagePromptJSON } from "../../widget-ai-utils/label-image/label-image-ai-utils";
18
+ import type { PerseusLabelImageWidgetOptions } from "@khanacademy/perseus-core";
19
19
  export type PreferredPopoverDirection = "NONE" | "UP" | "DOWN" | "LEFT" | "RIGHT";
20
20
  /**
21
21
  * Represents a direction vector.
@@ -47,10 +47,7 @@ type LabelImageState = {
47
47
  hideAnswers: boolean;
48
48
  };
49
49
  export declare class LabelImage extends React.Component<LabelImageProps, LabelImageState> implements Widget {
50
- static contextType: React.Context<{
51
- strings: import("../../strings").PerseusStrings;
52
- locale: string;
53
- }>;
50
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
54
51
  context: React.ContextType<typeof PerseusI18nContext>;
55
52
  _markers: Array<Marker | null | undefined>;
56
53
  _mounted: boolean;
@@ -21,10 +21,7 @@ type Props = InteractiveMarkerType & {
21
21
  hovered: boolean;
22
22
  };
23
23
  export default class Marker extends React.Component<Props> {
24
- static contextType: React.Context<{
25
- strings: import("../../strings").PerseusStrings;
26
- locale: string;
27
- }>;
24
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
28
25
  context: React.ContextType<typeof PerseusI18nContext>;
29
26
  _icon: HTMLElement | null | undefined;
30
27
  _mounted: boolean;
@@ -2,10 +2,10 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import scoreMatcher from "./score-matcher";
4
4
  import type { SortableOption } from "../../components/sortable";
5
- import type { PerseusMatcherWidgetOptions } from "../../perseus-types";
6
5
  import type { WidgetProps, Widget } from "../../types";
7
6
  import type { PerseusMatcherRubric, PerseusMatcherUserInput } from "../../validation.types";
8
7
  import type { MatcherPromptJSON } from "../../widget-ai-utils/matcher/matcher-ai-utils";
8
+ import type { PerseusMatcherWidgetOptions } from "@khanacademy/perseus-core";
9
9
  type RenderProps = PerseusMatcherWidgetOptions;
10
10
  type Props = WidgetProps<RenderProps, PerseusMatcherRubric>;
11
11
  type DefaultProps = {
@@ -24,10 +24,7 @@ type State = {
24
24
  texRendererLoaded: boolean;
25
25
  };
26
26
  export declare class Matcher extends React.Component<Props, State> implements Widget {
27
- static contextType: React.Context<{
28
- strings: import("../../strings").PerseusStrings;
29
- locale: string;
30
- }>;
27
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
31
28
  context: React.ContextType<typeof PerseusI18nContext>;
32
29
  static defaultProps: DefaultProps;
33
30
  state: State;
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import scoreMatrix from "./score-matrix";
4
- import type { PerseusMatrixWidgetAnswers } from "../../perseus-types";
5
4
  import type { WidgetProps, Widget, FocusPath } from "../../types";
6
5
  import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "../../validation.types";
7
6
  import type { MatrixPromptJSON } from "../../widget-ai-utils/matrix/matrix-ai-utils";
7
+ import type { PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
8
8
  export declare function getMatrixSize(matrix: ReadonlyArray<ReadonlyArray<number>>): number[];
9
9
  type ExternalProps = WidgetProps<{
10
10
  prefix: string;
@@ -34,10 +34,7 @@ type State = {
34
34
  enterTheMatrix: number;
35
35
  };
36
36
  declare class Matrix extends React.Component<Props, State> implements Widget {
37
- static contextType: React.Context<{
38
- strings: import("../../strings").PerseusStrings;
39
- locale: string;
40
- }>;
37
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
41
38
  context: React.ContextType<typeof PerseusI18nContext>;
42
39
  cursorPosition: [number, number];
43
40
  static defaultProps: DefaultProps;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
- import type { PerseusMeasurerWidgetOptions } from "../../perseus-types";
3
2
  import type { Widget, WidgetProps } from "../../types";
4
3
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
4
+ import type { PerseusMeasurerWidgetOptions } from "@khanacademy/perseus-core";
5
5
  type Props = WidgetProps<PerseusMeasurerWidgetOptions, PerseusMeasurerWidgetOptions> & {
6
6
  protractorX: number;
7
7
  protractorY: number;
@@ -0,0 +1,2 @@
1
+ export { default as MockWidget } from "./mock-widget";
2
+ export { default as MockAssetLoadingWidget } from "./mock-asset-loading-widget";
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import type { PerseusItem } from "@khanacademy/perseus-core";
3
+ export declare const mockedAssetItem: PerseusItem;
4
+ /**
5
+ * This is a Mock Asset Loading Perseus widget, which is used specifically for
6
+ * our server-item-renderer tests to test the asset loading callbacks.
7
+ */
8
+ export declare class MockAssetLoadingWidget extends React.Component<Record<any, any>> {
9
+ setAssetStatus: ((assetKey: string, loaded: boolean) => void) | null;
10
+ render(): React.ReactNode;
11
+ }
12
+ declare const _default: {
13
+ name: string;
14
+ displayName: string;
15
+ widget: typeof MockAssetLoadingWidget;
16
+ };
17
+ export default _default;
@@ -0,0 +1,47 @@
1
+ import * as React from "react";
2
+ import scoreMockWidget from "./score-mock-widget";
3
+ import type { WidgetProps, Widget, FocusPath } from "../../types";
4
+ import type { PerseusMockWidgetRubric, PerseusMockWidgetUserInput } from "../../validation.types";
5
+ import type { MockWidgetPromptJSON } from "../../widget-ai-utils/mock-widget/prompt-utils";
6
+ import type { MockWidgetOptions } from "@khanacademy/perseus-core";
7
+ type ExternalProps = WidgetProps<MockWidgetOptions, PerseusMockWidgetRubric>;
8
+ type DefaultProps = {
9
+ currentValue: Props["currentValue"];
10
+ };
11
+ type Props = ExternalProps & {
12
+ currentValue: string;
13
+ };
14
+ /**
15
+ * This is a Mock Perseus widget, which is used for our various rendering tests
16
+ * both internally and in consuming projects. It is a simple widget that renders
17
+ * an interactable input field, and allows the user to input a string value.
18
+ *
19
+ * Please use this widget for all tests that are not specifically testing the
20
+ * functionality of a particular widget, such as testing the rendering components.
21
+ * This allows us to more easily update our widget schemas and behaviour without needing to
22
+ * update many different irrelevant tests across our codebases.
23
+ *
24
+ * You can register this widget for your tests by calling `registerWidget("mock-widget", MockWidget);`
25
+ */
26
+ export declare class MockWidget extends React.Component<Props> implements Widget {
27
+ static defaultProps: DefaultProps;
28
+ inputRef: HTMLElement | null;
29
+ static getUserInputFromProps(props: Props): PerseusMockWidgetUserInput;
30
+ getPromptJSON(): MockWidgetPromptJSON;
31
+ setInputValue: (arg1: FocusPath, arg2: string, arg3?: () => unknown | null | undefined) => void;
32
+ focus: () => boolean;
33
+ focusInputPath: () => void;
34
+ blurInputPath: () => void;
35
+ getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
36
+ getUserInput(): PerseusMockWidgetUserInput;
37
+ handleChange: (arg1: string, arg2?: () => unknown | null | undefined) => void;
38
+ render(): React.ReactNode;
39
+ }
40
+ declare const _default: {
41
+ name: string;
42
+ displayName: string;
43
+ widget: typeof MockWidget;
44
+ isLintable: true;
45
+ scorer: typeof scoreMockWidget;
46
+ };
47
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import type { PerseusStrings } from "../../strings";
2
+ import type { PerseusMockWidgetUserInput, PerseusMockWidgetRubric } from "../../validation.types";
3
+ import type { PerseusScore } from "@khanacademy/perseus";
4
+ declare function scoreMockWidget(userInput: PerseusMockWidgetUserInput, rubric: PerseusMockWidgetRubric, strings: PerseusStrings): PerseusScore;
5
+ export default scoreMockWidget;
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
- import type { PerseusMoleculeRendererWidgetOptions } from "../../perseus-types";
3
2
  import type { Widget } from "../../types";
3
+ import type { PerseusMoleculeRendererWidgetOptions } from "@khanacademy/perseus-core";
4
4
  type Props = {
5
5
  widgetId: PerseusMoleculeRendererWidgetOptions["widgetId"];
6
6
  smiles: PerseusMoleculeRendererWidgetOptions["smiles"];
@@ -45,10 +45,7 @@ type State = {
45
45
  numDivisionsEmpty: boolean;
46
46
  };
47
47
  declare class NumberLine extends React.Component<Props, State> implements Widget {
48
- static contextType: React.Context<{
49
- strings: import("../../strings").PerseusStrings;
50
- locale: string;
51
- }>;
48
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
52
49
  context: React.ContextType<typeof PerseusI18nContext>;
53
50
  static defaultProps: DefaultProps;
54
51
  state: any;
@@ -3,11 +3,10 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import InputWithExamples from "../../components/input-with-examples";
4
4
  import SimpleKeypadInput from "../../components/simple-keypad-input";
5
5
  import scoreNumericInput from "./score-numeric-input";
6
- import type { PerseusNumericInputWidgetOptions, PerseusNumericInputAnswerForm } from "../../perseus-types";
7
- import type { PerseusStrings } from "../../strings";
8
6
  import type { FocusPath, Widget, WidgetProps } from "../../types";
9
7
  import type { PerseusNumericInputRubric, PerseusNumericInputUserInput } from "../../validation.types";
10
8
  import type { NumericInputPromptJSON } from "../../widget-ai-utils/numeric-input/prompt-utils";
9
+ import type { PerseusNumericInputWidgetOptions, PerseusNumericInputAnswerForm } from "@khanacademy/perseus-core";
11
10
  type ExternalProps = WidgetProps<PerseusNumericInputWidgetOptions, PerseusNumericInputRubric>;
12
11
  type Props = ExternalProps & {
13
12
  size: NonNullable<ExternalProps["size"]>;
@@ -34,10 +33,7 @@ type State = {
34
33
  isFocused: boolean;
35
34
  };
36
35
  export declare class NumericInput extends React.Component<Props, State> implements Widget {
37
- static contextType: React.Context<{
38
- strings: PerseusStrings;
39
- locale: string;
40
- }>;
36
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
41
37
  context: React.ContextType<typeof PerseusI18nContext>;
42
38
  inputRef: SimpleKeypadInput | InputWithExamples | null | undefined;
43
39
  static defaultProps: DefaultProps;
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
2
  import { scoreOrderer } from "./score-orderer";
3
- import type { PerseusOrdererWidgetOptions } from "../../perseus-types";
4
3
  import type { WidgetProps, Widget } from "../../types";
5
4
  import type { PerseusOrdererRubric, PerseusOrdererUserInput } from "../../validation.types";
6
5
  import type { OrdererPromptJSON } from "../../widget-ai-utils/orderer/orderer-ai-utils";
6
+ import type { PerseusOrdererWidgetOptions } from "@khanacademy/perseus-core";
7
7
  type Position = {
8
8
  left: number;
9
9
  top: number;
@@ -3,9 +3,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { ParseState } from "./passage-markdown";
4
4
  import type { SerializedHighlightSet } from "../../components/highlighting/types";
5
5
  import type { ChangeableProps } from "../../mixins/changeable";
6
- import type { PerseusPassageWidgetOptions, PerseusWidget } from "../../perseus-types";
7
6
  import type { WidgetProps, Widget } from "../../types";
8
7
  import type { PassagePromptJSON } from "../../widget-ai-utils/passage/passage-ai-utils";
8
+ import type { PerseusPassageWidgetOptions, PerseusWidget } from "@khanacademy/perseus-core";
9
9
  import type { SingleASTNode } from "@khanacademy/simple-markdown";
10
10
  export declare class LineHeightMeasurer extends React.Component<Record<any, any>> {
11
11
  _line: HTMLDivElement | null | undefined;
@@ -42,10 +42,7 @@ export type Reference = {
42
42
  content: string | null | undefined;
43
43
  };
44
44
  export declare class Passage extends React.Component<PassageProps, PassageState> implements Widget {
45
- static contextType: React.Context<{
46
- strings: import("../../strings").PerseusStrings;
47
- locale: string;
48
- }>;
45
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
49
46
  context: React.ContextType<typeof PerseusI18nContext>;
50
47
  _contentRef: HTMLDivElement | null | undefined;
51
48
  _lineHeightMeasurerRef: LineHeightMeasurer | null | undefined;
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { PerseusPassageRefWidgetOptions } from "../../perseus-types";
4
3
  import type { ChangeFn, Widget, WidgetProps } from "../../types";
5
4
  import type { PassageRefPromptJSON } from "../../widget-ai-utils/passage-ref/passage-ref-ai-utils";
5
+ import type { PerseusPassageRefWidgetOptions } from "@khanacademy/perseus-core";
6
6
  type RenderProps = {
7
7
  passageNumber: PerseusPassageRefWidgetOptions["passageNumber"];
8
8
  referenceNumber: PerseusPassageRefWidgetOptions["referenceNumber"];
@@ -19,10 +19,7 @@ type State = {
19
19
  content: string | null | undefined;
20
20
  };
21
21
  declare class PassageRef extends React.Component<Props, State> implements Widget {
22
- static contextType: React.Context<{
23
- strings: import("../../strings").PerseusStrings;
24
- locale: string;
25
- }>;
22
+ static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
26
23
  context: React.ContextType<typeof PerseusI18nContext>;
27
24
  displayName: string;
28
25
  _isMounted: boolean;