@khanacademy/perseus 38.0.1 → 39.0.1

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 (51) hide show
  1. package/dist/components/math-input.d.ts +1 -1
  2. package/dist/components/sortable.d.ts +1 -1
  3. package/dist/definition-context.d.ts +1 -1
  4. package/dist/es/index.js +121 -226
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +96 -202
  8. package/dist/index.js.map +1 -1
  9. package/dist/interactive2/movable-point.d.ts +1 -1
  10. package/dist/multi-items/prop-type-builders.d.ts +0 -6
  11. package/dist/perseus-api.d.ts +3 -1
  12. package/dist/perseus-types.d.ts +3 -42
  13. package/dist/renderer.d.ts +1 -2
  14. package/dist/server-item-renderer.d.ts +3 -2
  15. package/dist/sigfigs.d.ts +0 -16
  16. package/dist/styles/constants.d.ts +0 -18
  17. package/dist/types.d.ts +4 -6
  18. package/dist/util/math.d.ts +0 -1
  19. package/dist/util.d.ts +2 -1
  20. package/dist/validation.types.d.ts +17 -16
  21. package/dist/widgets/__shared__/noop-validator.d.ts +1 -1
  22. package/dist/widgets/definition/definition.d.ts +1 -2
  23. package/dist/widgets/explanation/explanation.d.ts +1 -2
  24. package/dist/widgets/expression/expression.d.ts +25 -12
  25. package/dist/widgets/iframe/iframe-validator.d.ts +1 -1
  26. package/dist/widgets/image/image.d.ts +1 -2
  27. package/dist/widgets/input-number/input-number.d.ts +0 -1
  28. package/dist/widgets/interaction/interaction.d.ts +1 -2
  29. package/dist/widgets/interactive-graphs/graphs/components/movable-line.d.ts +0 -11
  30. package/dist/widgets/interactive-graphs/graphs/point.d.ts +0 -2
  31. package/dist/widgets/interactive-graphs/graphs/use-transform.d.ts +0 -1
  32. package/dist/widgets/interactive-graphs/mafs-supported-graph-types.d.ts +2 -1
  33. package/dist/widgets/interactive-graphs/protractor.d.ts +0 -2
  34. package/dist/widgets/label-image/answer-choices.d.ts +1 -1
  35. package/dist/widgets/label-image/label-image.d.ts +12 -28
  36. package/dist/widgets/matrix/matrix-validator.d.ts +1 -1
  37. package/dist/widgets/matrix/matrix.d.ts +0 -1
  38. package/dist/widgets/measurer/measurer.d.ts +3 -15
  39. package/dist/widgets/molecule/molecule.d.ts +0 -21
  40. package/dist/widgets/number-line/number-line.d.ts +0 -1
  41. package/dist/widgets/numeric-input/numeric-input.d.ts +0 -1
  42. package/dist/widgets/orderer/orderer.d.ts +1 -1
  43. package/dist/widgets/passage/passage.d.ts +1 -2
  44. package/dist/widgets/passage-ref/passage-ref.d.ts +1 -2
  45. package/dist/widgets/radio/base-radio.d.ts +5 -10
  46. package/dist/widgets/radio/focus-ring.d.ts +4 -11
  47. package/dist/widgets/table/table.d.ts +0 -1
  48. package/dist/widgets/video/video.d.ts +1 -2
  49. package/package.json +3 -3
  50. package/dist/util/fix-passage-refs.d.ts +0 -3
  51. package/dist/widgets/radio/choice.jsx.fixture.d.ts +0 -1
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { SingleSelect } from "@khanacademy/wonder-blocks-dropdown";
5
5
  import * as React from "react";
6
- export type AnswerType = {
6
+ type AnswerType = {
7
7
  content: string;
8
8
  checked: boolean;
9
9
  };
@@ -11,6 +11,7 @@ import Marker from "./marker";
11
11
  import type { InteractiveMarkerType } from "./types";
12
12
  import type { DependencyProps } from "../../dependencies";
13
13
  import type { ChangeableProps } from "../../mixins/changeable";
14
+ import type { PerseusLabelImageWidgetOptions } from "../../perseus-types";
14
15
  import type { APIOptions, Widget } from "../../types";
15
16
  import type { PerseusLabelImageRubric, PerseusLabelImageUserInput } from "../../validation.types";
16
17
  export type PreferredPopoverDirection = "NONE" | "UP" | "DOWN" | "LEFT" | "RIGHT";
@@ -32,16 +33,9 @@ type Point = {
32
33
  x: number;
33
34
  y: number;
34
35
  };
35
- type LabelImageProps = ChangeableProps & DependencyProps & {
36
+ type LabelImageProps = ChangeableProps & DependencyProps & Omit<PerseusLabelImageWidgetOptions, "markers"> & {
36
37
  apiOptions: APIOptions;
37
- choices: ReadonlyArray<string>;
38
- imageAlt: string;
39
- imageUrl: string;
40
- imageWidth: number;
41
- imageHeight: number;
42
38
  markers: ReadonlyArray<InteractiveMarkerType>;
43
- multipleAnswers: boolean;
44
- hideChoicesFromInstructions: boolean;
45
39
  questionCompleted: boolean;
46
40
  preferredPopoverDirection?: PreferredPopoverDirection;
47
41
  };
@@ -91,7 +85,7 @@ export declare class LabelImage extends React.Component<LabelImageProps, LabelIm
91
85
  declare const _default: Readonly<{
92
86
  name: string;
93
87
  displayName: string;
94
- getWidget?: (() => React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../../types").PerseusDependenciesV2> & {
88
+ getWidget?: (() => React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../../types").PerseusDependenciesV2> & Omit<PerseusLabelImageWidgetOptions, "markers"> & {
95
89
  apiOptions: Readonly<{
96
90
  isArticle?: boolean | undefined;
97
91
  onFocusChange?: ((newFocusPath: import("../../types").FocusPath, oldFocusPath: import("../../types").FocusPath, keypadHeight?: number | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
@@ -114,7 +108,9 @@ declare const _default: Readonly<{
114
108
  type: string;
115
109
  id: string;
116
110
  correct?: boolean | undefined;
117
- } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<import("../../types").TrackingSequenceExtraArguments>) => void) | undefined;
111
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
112
+ visible: number;
113
+ }>) => void) | undefined;
118
114
  customKeypad?: boolean | undefined;
119
115
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
120
116
  isMobile?: boolean | undefined;
@@ -149,20 +145,13 @@ declare const _default: Readonly<{
149
145
  "locked-function-labels"?: boolean | undefined;
150
146
  }) | undefined;
151
147
  } | undefined;
152
- onWidgetStartProps?: ((widgets: import("../..").PerseusWidgetsMap) => void) | undefined;
148
+ onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
153
149
  }>;
154
- choices: readonly string[];
155
- imageAlt: string;
156
- imageUrl: string;
157
- imageWidth: number;
158
- imageHeight: number;
159
150
  markers: readonly InteractiveMarkerType[];
160
- multipleAnswers: boolean;
161
- hideChoicesFromInstructions: boolean;
162
151
  questionCompleted: boolean;
163
152
  preferredPopoverDirection?: PreferredPopoverDirection | undefined;
164
153
  }, "analytics"> & React.RefAttributes<LabelImage>>) | undefined;
165
- widget: React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../../types").PerseusDependenciesV2> & {
154
+ widget: React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../../types").PerseusDependenciesV2> & Omit<PerseusLabelImageWidgetOptions, "markers"> & {
166
155
  apiOptions: Readonly<{
167
156
  isArticle?: boolean | undefined;
168
157
  onFocusChange?: ((newFocusPath: import("../../types").FocusPath, oldFocusPath: import("../../types").FocusPath, keypadHeight?: number | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
@@ -185,7 +174,9 @@ declare const _default: Readonly<{
185
174
  type: string;
186
175
  id: string;
187
176
  correct?: boolean | undefined;
188
- } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<import("../../types").TrackingSequenceExtraArguments>) => void) | undefined;
177
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
178
+ visible: number;
179
+ }>) => void) | undefined;
189
180
  customKeypad?: boolean | undefined;
190
181
  nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
191
182
  isMobile?: boolean | undefined;
@@ -220,16 +211,9 @@ declare const _default: Readonly<{
220
211
  "locked-function-labels"?: boolean | undefined;
221
212
  }) | undefined;
222
213
  } | undefined;
223
- onWidgetStartProps?: ((widgets: import("../..").PerseusWidgetsMap) => void) | undefined;
214
+ onWidgetStartProps?: ((widgets: import("../../perseus-types").PerseusWidgetsMap) => void) | undefined;
224
215
  }>;
225
- choices: readonly string[];
226
- imageAlt: string;
227
- imageUrl: string;
228
- imageWidth: number;
229
- imageHeight: number;
230
216
  markers: readonly InteractiveMarkerType[];
231
- multipleAnswers: boolean;
232
- hideChoicesFromInstructions: boolean;
233
217
  questionCompleted: boolean;
234
218
  preferredPopoverDirection?: PreferredPopoverDirection | undefined;
235
219
  }, "analytics"> & React.RefAttributes<LabelImage>>;
@@ -1,5 +1,5 @@
1
1
  import type { PerseusStrings } from "../../strings";
2
2
  import type { PerseusScore } from "../../types";
3
3
  import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "../../validation.types";
4
- declare function matrixValidator(state: PerseusMatrixUserInput, rubric: PerseusMatrixRubric, strings: PerseusStrings): PerseusScore;
4
+ declare function matrixValidator(userInput: PerseusMatrixUserInput, rubric: PerseusMatrixRubric, strings: PerseusStrings): PerseusScore;
5
5
  export default matrixValidator;
@@ -35,7 +35,6 @@ declare class Matrix extends React.Component<Props, State> implements Widget {
35
35
  state: State;
36
36
  componentDidMount(): void;
37
37
  getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
38
- getGrammarTypeForPath: (arg1: any) => string;
39
38
  _handleFocus: (arg1: any, arg2: any) => void;
40
39
  _handleBlur: (arg1: any, arg2: any) => void;
41
40
  focus: () => boolean;
@@ -1,21 +1,9 @@
1
1
  import * as React from "react";
2
- import type { APIOptions, Widget } from "../../types";
3
- type Props = {
4
- apiOptions: APIOptions;
5
- box: [number, number];
6
- image: {
7
- url?: string;
8
- top?: number;
9
- left?: number;
10
- };
11
- showProtractor: boolean;
2
+ import type { PerseusMeasurerWidgetOptions } from "../../perseus-types";
3
+ import type { Widget, WidgetProps } from "../../types";
4
+ type Props = WidgetProps<PerseusMeasurerWidgetOptions, PerseusMeasurerWidgetOptions> & {
12
5
  protractorX: number;
13
6
  protractorY: number;
14
- showRuler: boolean;
15
- rulerLabel: string;
16
- rulerTicks: number;
17
- rulerPixels: number;
18
- rulerLength: number;
19
7
  };
20
8
  type DefaultProps = {
21
9
  box: Props["box"];
@@ -1,32 +1,11 @@
1
1
  import * as React from "react";
2
- import { PerseusI18nContext } from "../../components/i18n-context";
3
2
  import type { PerseusMoleculeRendererWidgetOptions } from "../../perseus-types";
4
3
  import type { Widget } from "../../types";
5
- type MoleculeState = {
6
- parsedSmiles: any;
7
- error: string | null;
8
- };
9
4
  type Props = {
10
5
  widgetId: PerseusMoleculeRendererWidgetOptions["widgetId"];
11
6
  smiles: PerseusMoleculeRendererWidgetOptions["smiles"];
12
7
  rotationAngle: PerseusMoleculeRendererWidgetOptions["rotationAngle"];
13
8
  };
14
- export declare class Molecule extends React.Component<Props, MoleculeState> {
15
- static contextType: React.Context<{
16
- strings: import("../../strings").PerseusStrings;
17
- locale: string;
18
- }>;
19
- context: React.ContextType<typeof PerseusI18nContext>;
20
- state: MoleculeState;
21
- UNSAFE_componentWillMount(): void;
22
- componentDidMount(): void;
23
- UNSAFE_componentWillReceiveProps(nextProps: any): void;
24
- componentDidUpdate(): void;
25
- stateFromSmiles: (arg1: any) => void;
26
- setCanvasBounds: (arg1: any, arg2: any) => any;
27
- canvasRender: () => void;
28
- render(): React.ReactNode;
29
- }
30
9
  type DefaultProps = {
31
10
  rotationAngle: Props["rotationAngle"];
32
11
  };
@@ -60,7 +60,6 @@ declare class NumberLine extends React.Component<Props, State> implements Widget
60
60
  blurInputPath: (arg1: any) => void;
61
61
  getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
62
62
  getDOMNodeForPath(inputPath: FocusPath): Element | Text | null;
63
- getGrammarTypeForPath(inputPath: FocusPath): "number" | undefined;
64
63
  setInputValue: (arg1: any, arg2: any, arg3: any) => void;
65
64
  _renderGraphie: () => React.ReactElement;
66
65
  snapNumLinePosition: (arg1: any, arg2: number) => number;
@@ -46,7 +46,6 @@ export declare class NumericInput extends React.Component<Props, State> implemen
46
46
  focusInputPath: () => void;
47
47
  blurInputPath: () => void;
48
48
  getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
49
- getGrammarTypeForPath: (arg1: FocusPath) => string;
50
49
  setInputValue: (arg1: FocusPath, arg2: string, arg3?: () => unknown | null | undefined) => void;
51
50
  getUserInput(): PerseusNumericInputUserInput;
52
51
  handleChange: (arg1: string, arg2?: () => unknown | null | undefined) => void;
@@ -9,7 +9,7 @@ type Position = {
9
9
  type RenderProps = PerseusOrdererWidgetOptions & {
10
10
  current: any;
11
11
  };
12
- export type OrdererProps = WidgetProps<RenderProps, PerseusOrdererRubric>;
12
+ type OrdererProps = WidgetProps<RenderProps, PerseusOrdererRubric>;
13
13
  type OrdererDefaultProps = {
14
14
  current: OrdererProps["current"];
15
15
  options: OrdererProps["options"];
@@ -5,7 +5,6 @@ import type { SerializedHighlightSet } from "../../components/highlighting/types
5
5
  import type { ChangeableProps } from "../../mixins/changeable";
6
6
  import type { PerseusPassageWidgetOptions, PerseusWidget } from "../../perseus-types";
7
7
  import type { WidgetProps, Widget } from "../../types";
8
- import type { PerseusPassageRubric } from "../../validation.types";
9
8
  import type { SingleASTNode } from "@khanacademy/simple-markdown";
10
9
  export declare class LineHeightMeasurer extends React.Component<Record<any, any>> {
11
10
  _line: HTMLDivElement | null | undefined;
@@ -19,7 +18,7 @@ type RenderProps = {
19
18
  showLineNumbers: PerseusPassageWidgetOptions["showLineNumbers"];
20
19
  };
21
20
  type FindWidgetsCallback = (id: string, widgetInfo: PerseusWidget) => boolean;
22
- type PassageProps = ChangeableProps & WidgetProps<RenderProps, PerseusPassageRubric> & {
21
+ type PassageProps = ChangeableProps & WidgetProps<RenderProps> & {
23
22
  findWidgets: (arg1: FindWidgetsCallback) => ReadonlyArray<Passage>;
24
23
  highlights: SerializedHighlightSet;
25
24
  };
@@ -2,13 +2,12 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusPassageRefWidgetOptions } from "../../perseus-types";
4
4
  import type { ChangeFn, Widget, WidgetProps } from "../../types";
5
- import type { PerseusPassageRefRubric } from "../../validation.types";
6
5
  type RenderProps = {
7
6
  passageNumber: PerseusPassageRefWidgetOptions["passageNumber"];
8
7
  referenceNumber: PerseusPassageRefWidgetOptions["referenceNumber"];
9
8
  summaryText: PerseusPassageRefWidgetOptions["summaryText"];
10
9
  };
11
- type Props = WidgetProps<RenderProps, PerseusPassageRefRubric>;
10
+ type Props = WidgetProps<RenderProps>;
12
11
  type DefaultProps = {
13
12
  passageNumber: Props["passageNumber"];
14
13
  referenceNumber: Props["referenceNumber"];
@@ -21,12 +21,13 @@ type Props = {
21
21
  apiOptions: APIOptions;
22
22
  choices: ReadonlyArray<ChoiceType>;
23
23
  deselectEnabled?: boolean;
24
- editMode: boolean;
24
+ editMode?: boolean;
25
25
  labelWrap: boolean;
26
26
  countChoices: boolean | null | undefined;
27
27
  numCorrect: number;
28
- multipleSelect: boolean;
29
- reviewModeRubric?: PerseusRadioWidgetOptions;
28
+ multipleSelect?: boolean;
29
+ reviewModeRubric?: PerseusRadioWidgetOptions | null;
30
+ reviewMode: boolean;
30
31
  onChange: (newValues: {
31
32
  checked: ReadonlyArray<boolean>;
32
33
  crossedOut: ReadonlyArray<boolean>;
@@ -34,11 +35,5 @@ type Props = {
34
35
  registerFocusFunction?: (arg1: FocusFunction) => void;
35
36
  isLastUsedWidget?: boolean;
36
37
  };
37
- declare const BaseRadio: {
38
- (props: Props): React.ReactElement;
39
- defaultProps: {
40
- editMode: boolean;
41
- multipleSelect: boolean;
42
- };
43
- };
38
+ declare const BaseRadio: ({ apiOptions, reviewModeRubric, reviewMode, choices, editMode, multipleSelect, labelWrap, countChoices, numCorrect, isLastUsedWidget, onChange, registerFocusFunction, }: Props) => React.ReactElement;
44
39
  export default BaseRadio;
@@ -4,16 +4,9 @@
4
4
  import * as React from "react";
5
5
  type Props = {
6
6
  children?: React.ReactNode;
7
- visible: boolean;
8
- color: string;
9
- multipleSelect: boolean;
10
- };
11
- declare const FocusRing: {
12
- (props: Props): React.ReactElement;
13
- defaultProps: {
14
- visible: boolean;
15
- color: string;
16
- multipleSelect: boolean;
17
- };
7
+ visible?: boolean;
8
+ color?: string;
9
+ multipleSelect?: boolean;
18
10
  };
11
+ declare const FocusRing: ({ visible, color, multipleSelect, children, }: Props) => React.ReactElement;
19
12
  export default FocusRing;
@@ -37,7 +37,6 @@ declare class Table extends React.Component<Props> implements Widget {
37
37
  blurInputPath: (arg1: any) => void;
38
38
  getDOMNodeForPath(path: any): Element | Text | null;
39
39
  getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
40
- getGrammarTypeForPath: (arg1: any) => string;
41
40
  setInputValue: (arg1: any, arg2: any, arg3: any) => void;
42
41
  render(): React.ReactNode;
43
42
  }
@@ -5,9 +5,8 @@ import * as React from "react";
5
5
  import { PerseusI18nContext } from "../../components/i18n-context";
6
6
  import type { PerseusVideoWidgetOptions } from "../../perseus-types";
7
7
  import type { Widget, WidgetProps } from "../../types";
8
- import type { PerseusVideoRubric } from "../../validation.types";
9
8
  type RenderProps = PerseusVideoWidgetOptions;
10
- type Props = WidgetProps<RenderProps, PerseusVideoRubric> & {
9
+ type Props = WidgetProps<RenderProps> & {
11
10
  alignment: string;
12
11
  };
13
12
  /**
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": "38.0.1",
6
+ "version": "39.0.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -43,9 +43,9 @@
43
43
  "@khanacademy/kas": "^0.3.15",
44
44
  "@khanacademy/keypad-context": "^1.0.3",
45
45
  "@khanacademy/kmath": "^0.1.15",
46
- "@khanacademy/math-input": "^21.1.0",
46
+ "@khanacademy/math-input": "^21.1.2",
47
47
  "@khanacademy/perseus-core": "1.5.2",
48
- "@khanacademy/perseus-linter": "^1.2.2",
48
+ "@khanacademy/perseus-linter": "^1.2.3",
49
49
  "@khanacademy/pure-markdown": "^0.3.10",
50
50
  "@khanacademy/simple-markdown": "^0.13.3",
51
51
  "@types/classnames": "2.2.0",
@@ -1,3 +0,0 @@
1
- import type { MultiItem, PerseusItem } from "../perseus-types";
2
- declare const fixPassageRefs: (itemData: PerseusItem | MultiItem) => any;
3
- export default fixPassageRefs;
@@ -1 +0,0 @@
1
- export declare const instances: ReadonlyArray<unknown>;