@khanacademy/perseus 61.0.3 → 61.2.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.
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { PerseusStrings } from "./strings";
3
3
  import type { SizeClass } from "./util/sizing-utils";
4
4
  import type { WidgetPromptJSON } from "./widget-ai-utils/prompt-types";
5
5
  import type { KeypadAPI } from "@khanacademy/math-input";
6
- import type { Hint, PerseusAnswerArea, PerseusGraphType, PerseusFeatureFlags, PerseusWidget, PerseusWidgetsMap, AnalyticsEventHandlerFn, Version, WidgetOptionsUpgradeMap, Rubric, UserInput, UserInputArray, UserInputMap } from "@khanacademy/perseus-core";
6
+ import type { Hint, PerseusAnswerArea, PerseusGraphType, PerseusFeatureFlags, PerseusWidget, PerseusWidgetsMap, AnalyticsEventHandlerFn, Version, WidgetOptionsUpgradeMap, Rubric, UserInput, UserInputArray, UserInputMap, Relationship } from "@khanacademy/perseus-core";
7
7
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
8
8
  import type { Result } from "@khanacademy/wonder-blocks-data";
9
9
  import type * as React from "react";
@@ -89,6 +89,10 @@ export type ChangeHandler = (arg1: {
89
89
  selected?: number;
90
90
  plot?: any;
91
91
  graph?: PerseusGraphType;
92
+ divisionRange?: number[];
93
+ numDivisions?: number;
94
+ numLinePosition?: number;
95
+ rel?: Relationship;
92
96
  }, callback?: () => void, silent?: boolean) => unknown;
93
97
  export type ImageUploader = (file: File, callback: (url: string) => unknown) => unknown;
94
98
  export type Path = ReadonlyArray<string>;
@@ -399,7 +403,13 @@ export type FilterCriterion = string | ((id: string, widgetInfo: PerseusWidget,
399
403
  * any `propUpgrades` the widget defines as well as its `transform` or
400
404
  * `staticTransform` functions (depending on the options `static` flag).
401
405
  */
402
- export type WidgetProps<RenderProps, Rubric = Empty, TrackingExtraArgs = Empty> = RenderProps & {
406
+ export type WidgetProps<RenderProps, Rubric = Empty, TrackingExtraArgs = Empty> = RenderProps & UniversalWidgetProps<Rubric, TrackingExtraArgs>;
407
+ /**
408
+ * The props passed to every widget, regardless of its `type`.
409
+ */
410
+ export type UniversalWidgetProps<ReviewModeRubric = Empty, TrackingExtraArgs = Empty> = {
411
+ reviewModeRubric?: ReviewModeRubric | null | undefined;
412
+ trackInteraction: (extraData?: TrackingExtraArgs) => void;
403
413
  widgetId: string;
404
414
  alignment: string | null | undefined;
405
415
  static: boolean | null | undefined;
@@ -415,19 +425,21 @@ export type WidgetProps<RenderProps, Rubric = Empty, TrackingExtraArgs = Empty>
415
425
  onFocus: (blurPath: FocusPath) => void;
416
426
  onBlur: (blurPath: FocusPath) => void;
417
427
  findWidgets: (criterion: FilterCriterion) => ReadonlyArray<Widget>;
418
- reviewModeRubric?: Rubric | null | undefined;
419
428
  reviewMode: boolean;
420
429
  onChange: ChangeHandler;
421
- trackInteraction: (extraData?: TrackingExtraArgs) => void;
422
430
  isLastUsedWidget: boolean;
423
431
  linterContext: LinterContextProps;
424
432
  containerSizeClass: SizeClass;
425
433
  };
426
434
  export type ChangeFn = (newPropsOrSinglePropName: string | {
427
435
  [key: string]: any;
428
- }, propValue?: any, callback?: () => unknown) => any | null | undefined;
436
+ }, propValue?: any, callback?: () => unknown) => any;
429
437
  export type SharedRendererProps = {
430
438
  apiOptions: APIOptions;
431
439
  linterContext: LinterContextProps;
432
440
  };
441
+ export interface Focusable {
442
+ focus: () => void;
443
+ blur: () => void;
444
+ }
433
445
  export {};
@@ -1,4 +1,4 @@
1
- import type { CategorizerWidget, ExpressionWidget, InteractiveGraphWidget, NumericInputWidget, PerseusRenderer, RadioWidget, PerseusScore, UserInputMap } from "@khanacademy/perseus-core";
1
+ import type { CategorizerWidget, ExpressionWidget, InteractiveGraphWidget, NumericInputWidget, PerseusRenderer, PerseusWidgetTypes, RadioWidget, PerseusScore, UserInputMap, PerseusItem } from "@khanacademy/perseus-core";
2
2
  /**
3
3
  * Thin wrapper around scorePerseusItem for internal testing
4
4
  */
@@ -38,3 +38,25 @@ export declare function generateTestExpressionWidget(): ExpressionWidget;
38
38
  * @returns {NumericInputWidget} skeleton NumericInputWidget for testing
39
39
  */
40
40
  export declare function generateTestNumericInputWidget(): NumericInputWidget;
41
+ /**
42
+ * Creates an object with the minimum amount
43
+ * of data to be a properly typed PerseusItem
44
+ * containing answerful information
45
+ *
46
+ * @template T - The widget type extending keyof PerseusWidgetTypes
47
+ * @param {T} widgetType - The type of widget to create, as a string, ex. "radio"
48
+ * @param {PerseusWidgetTypes[T]["options"]} options - The options for the widget
49
+ * @returns {PerseusItem} skeleton PerseusItem for testing
50
+ */
51
+ export declare function getAnswerfulItem<T extends keyof PerseusWidgetTypes>(widgetType: T, options: PerseusWidgetTypes[T]["options"]): PerseusItem;
52
+ /**
53
+ * Creates an object with the minimum amount
54
+ * of data to be a properly typed PerseusItem
55
+ * containing answerless information
56
+ *
57
+ * @template T - The widget type extending keyof PerseusWidgetTypes
58
+ * @param {T} widgetType - The type of widget to create, as a string, ex. "radio"
59
+ * @param {PerseusWidgetTypes[T]["options"]} options - The options for the widget
60
+ * @returns {PerseusItem} skeleton PerseusItem for testing
61
+ */
62
+ export declare function getAnswerlessItem<T extends keyof PerseusWidgetTypes>(widgetType: T, options: PerseusWidgetTypes[T]["options"]): PerseusItem;
package/dist/util.d.ts CHANGED
@@ -41,7 +41,7 @@ declare function inputPathsEqual(a?: ReadonlyArray<string> | null, b?: ReadonlyA
41
41
  */
42
42
  declare function firstNumericalParse(text: string): ParsedValue | null | undefined;
43
43
  declare function stringArrayOfSize(size: number): string[];
44
- declare function stringArrayOfSize2D(opt: {
44
+ export declare function stringArrayOfSize2D(opt: {
45
45
  rows: number;
46
46
  columns: number;
47
47
  }): string[][];
@@ -74,72 +74,7 @@ declare const _default: {
74
74
  name: string;
75
75
  displayName: string;
76
76
  accessible: true;
77
- widget: React.ForwardRefExoticComponent<Omit<Pick<RenderProps & {
78
- widgetId: string;
79
- alignment: string | null | undefined;
80
- static: boolean | null | undefined;
81
- problemNum: number | null | undefined;
82
- apiOptions: Readonly<Readonly<{
83
- isArticle?: boolean;
84
- onFocusChange?: (newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
85
- GroupMetadataEditor?: React.ComponentType<any>;
86
- showAlignmentOptions?: boolean;
87
- readOnly?: boolean;
88
- answerableCallback?: (arg1: boolean) => unknown;
89
- getAnotherHint?: () => unknown;
90
- interactionCallback?: (widgetData: {
91
- [widgetId: string]: any;
92
- }) => void;
93
- groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
94
- imagePlaceholder?: React.ReactNode;
95
- widgetPlaceholder?: React.ReactNode;
96
- baseElements?: {
97
- Link: React.ComponentType<any>;
98
- };
99
- imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
100
- trackInteraction?: (args: {
101
- type: string;
102
- id: string;
103
- correct?: boolean;
104
- } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
105
- visible: number;
106
- }>) => void;
107
- customKeypad?: boolean;
108
- nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
109
- isMobile?: boolean;
110
- setDrawingAreaAvailable?: (arg1: boolean) => unknown;
111
- hintProgressColor?: string;
112
- canScrollPage?: boolean;
113
- crossOutEnabled?: boolean;
114
- editorChangeDelay?: number;
115
- flags?: Record<"new-radio-widget", boolean>;
116
- onWidgetStartProps?: (widgets: import("@khanacademy/perseus-core").PerseusWidgetsMap) => void;
117
- }> & {
118
- baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
119
- canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
120
- crossOutEnabled: NonNullable<import("../..").APIOptions["crossOutEnabled"]>;
121
- editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
122
- groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
123
- isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
124
- isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
125
- onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
126
- readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
127
- setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
128
- showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
129
- }>;
130
- keypadElement?: any;
131
- questionCompleted?: boolean;
132
- onFocus: (blurPath: FocusPath) => void;
133
- onBlur: (blurPath: FocusPath) => void;
134
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
135
- reviewModeRubric?: Empty | null | undefined;
136
- reviewMode: boolean;
137
- onChange: import("../..").ChangeHandler;
138
- trackInteraction: (extraData?: Empty | undefined) => void;
139
- isLastUsedWidget: boolean;
140
- linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
141
- containerSizeClass: import("../../util/sizing-utils").SizeClass;
142
- } & Partial<import("../..").PerseusDependenciesV2> & {
77
+ widget: React.ForwardRefExoticComponent<Omit<Pick<RenderProps & import("../../types").UniversalWidgetProps<Empty, Empty> & Partial<import("../..").PerseusDependenciesV2> & {
143
78
  apiOptions: NonNullable<ExternalProps["apiOptions"]>;
144
79
  buttonSets: NonNullable<ExternalProps["buttonSets"]>;
145
80
  functions: NonNullable<ExternalProps["functions"]>;
@@ -150,7 +85,7 @@ declare const _default: {
150
85
  visibleLabel: PerseusExpressionWidgetOptions["visibleLabel"];
151
86
  ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
152
87
  value: string;
153
- }, "static" | "containerSizeClass" | "widgetId" | "onChange" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "ariaLabel" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "alignment" | "reviewModeRubric" | "isLastUsedWidget" | "visibleLabel" | "buttonsVisible" | "keypadConfiguration"> & {
88
+ }, "static" | "containerSizeClass" | "widgetId" | "onChange" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "ariaLabel" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "reviewModeRubric" | "alignment" | "isLastUsedWidget" | "visibleLabel" | "buttonsVisible" | "keypadConfiguration"> & {
154
89
  value?: string | undefined;
155
90
  apiOptions?: Readonly<Readonly<{
156
91
  isArticle?: boolean;
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Group widget (different than GradedGroup and GradedGroupSet)
3
+ * is a widget that was specifically made for old SAT content
4
+ * and no longer seems to be needed.
5
+ * There's some question to whether we want to keep it
6
+ * to let content creators access old content that is no longer
7
+ * learner-facing, but new content cannot be made with Group.
8
+ */
1
9
  import * as React from "react";
2
10
  import { PerseusI18nContext } from "../../components/i18n-context";
3
11
  import Renderer from "../../renderer";
@@ -7,7 +7,7 @@
7
7
  * but could also be used for embedding viz's hosted elsewhere.
8
8
  */
9
9
  import * as React from "react";
10
- import type { WidgetProps, Widget } from "../../types";
10
+ import type { WidgetProps, Widget, ChangeFn } from "../../types";
11
11
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
12
12
  import type { PerseusIFrameUserInput, UserInputStatus, PerseusIFrameWidgetOptions } from "@khanacademy/perseus-core";
13
13
  type RenderProps = PerseusIFrameWidgetOptions & {
@@ -30,7 +30,7 @@ declare class Iframe extends React.Component<Props> implements Widget {
30
30
  getUserInput(): PerseusIFrameUserInput;
31
31
  getPromptJSON(): UnsupportedWidgetPromptJSON;
32
32
  handleMessageEvent: (arg1: any) => void;
33
- change: (...args: ReadonlyArray<unknown>) => any;
33
+ change: ChangeFn;
34
34
  render(): React.ReactNode;
35
35
  }
36
36
  declare const _default: {
@@ -3,12 +3,7 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { Path, Widget, WidgetProps } from "../../types";
4
4
  import type { InputNumberPromptJSON } from "../../widget-ai-utils/input-number/input-number-ai-utils";
5
5
  import type { PerseusInputNumberWidgetOptions, PerseusInputNumberUserInput } from "@khanacademy/perseus-core";
6
- type RenderProps = {
7
- simplify: PerseusInputNumberWidgetOptions["simplify"];
8
- size: PerseusInputNumberWidgetOptions["size"];
9
- answerType: PerseusInputNumberWidgetOptions["answerType"];
10
- rightAlign: PerseusInputNumberWidgetOptions["rightAlign"];
11
- };
6
+ type RenderProps = Pick<PerseusInputNumberWidgetOptions, "simplify" | "size" | "answerType" | "rightAlign">;
12
7
  type ExternalProps = WidgetProps<RenderProps>;
13
8
  type Props = ExternalProps & {
14
9
  apiOptions: NonNullable<ExternalProps["apiOptions"]>;
@@ -18,14 +13,7 @@ type Props = ExternalProps & {
18
13
  currentValue: string;
19
14
  answerType: NonNullable<ExternalProps["answerType"]>;
20
15
  };
21
- type DefaultProps = {
22
- answerType: Props["answerType"];
23
- apiOptions: Props["apiOptions"];
24
- currentValue: Props["currentValue"];
25
- linterContext: Props["linterContext"];
26
- rightAlign: Props["rightAlign"];
27
- size: Props["size"];
28
- };
16
+ type DefaultProps = Pick<Props, "answerType" | "apiOptions" | "currentValue" | "linterContext" | "rightAlign" | "size">;
29
17
  declare class InputNumber extends React.Component<Props> implements Widget {
30
18
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
31
19
  context: React.ContextType<typeof PerseusI18nContext>;
@@ -47,13 +35,15 @@ declare class InputNumber extends React.Component<Props> implements Widget {
47
35
  examples(): ReadonlyArray<string>;
48
36
  render(): React.ReactNode;
49
37
  }
38
+ declare function transform(widgetOptions: PerseusInputNumberWidgetOptions): RenderProps;
39
+ declare function getOneCorrectAnswerFromRubric(rubric: any): string | undefined;
50
40
  declare const _default: {
51
41
  name: string;
52
42
  displayName: string;
53
43
  hidden: true;
54
44
  widget: typeof InputNumber;
55
- transform: (widgetOptions: PerseusInputNumberWidgetOptions) => RenderProps;
56
45
  isLintable: true;
57
- getOneCorrectAnswerFromRubric(rubric: any): string | null | undefined;
46
+ transform: typeof transform;
47
+ getOneCorrectAnswerFromRubric: typeof getOneCorrectAnswerFromRubric;
58
48
  };
59
49
  export default _default;
@@ -94,7 +94,7 @@ type RenderProps = {
94
94
  * Shapes (points, chords, etc) displayed on the graph that cannot be moved
95
95
  * by the user.
96
96
  */
97
- lockedFigures?: LockedFigure[];
97
+ lockedFigures: LockedFigure[];
98
98
  /**
99
99
  * Aria label that applies to the entire graph.
100
100
  */
@@ -7,7 +7,7 @@ import "./mafs-styles.css";
7
7
  export type MafsGraphProps = {
8
8
  box: [number, number];
9
9
  backgroundImage?: InteractiveGraphProps["backgroundImage"];
10
- lockedFigures?: InteractiveGraphProps["lockedFigures"];
10
+ lockedFigures: InteractiveGraphProps["lockedFigures"];
11
11
  step: InteractiveGraphProps["step"];
12
12
  gridStep: [x: number, y: number];
13
13
  containerSizeClass: InteractiveGraphProps["containerSizeClass"];
@@ -11,7 +11,7 @@ export type StatefulMafsGraphProps = {
11
11
  * submitted their guess).
12
12
  */
13
13
  correct?: PerseusGraphType;
14
- lockedFigures?: InteractiveGraphProps["lockedFigures"];
14
+ lockedFigures: InteractiveGraphProps["lockedFigures"];
15
15
  range: InteractiveGraphProps["range"];
16
16
  snapStep: [x: number, y: number];
17
17
  step: InteractiveGraphProps["step"];
@@ -1,8 +1,8 @@
1
- import { type PerseusMatrixUserInput, type PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
2
1
  import * as React from "react";
3
2
  import { PerseusI18nContext } from "../../components/i18n-context";
4
3
  import type { FocusPath, Widget, WidgetProps } from "../../types";
5
4
  import type { MatrixPromptJSON } from "../../widget-ai-utils/matrix/matrix-ai-utils";
5
+ import type { MatrixPublicWidgetOptions, PerseusMatrixUserInput, PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
6
6
  type ExternalProps = WidgetProps<{
7
7
  prefix: string;
8
8
  suffix: string;
@@ -11,6 +11,9 @@ type ExternalProps = WidgetProps<{
11
11
  matrixBoardSize: ReadonlyArray<number>;
12
12
  static?: boolean | undefined;
13
13
  }>;
14
+ type RenderProps = MatrixPublicWidgetOptions & {
15
+ emptyMatrix: ReadonlyArray<ReadonlyArray<string>>;
16
+ };
14
17
  type Props = ExternalProps & {
15
18
  onChange: (arg1: {
16
19
  cursorPosition?: ReadonlyArray<number>;
@@ -51,12 +54,13 @@ declare class Matrix extends React.Component<Props, State> implements Widget {
51
54
  getPromptJSON(): MatrixPromptJSON;
52
55
  render(): React.ReactNode;
53
56
  }
57
+ declare function transform(widgetOptions: MatrixPublicWidgetOptions): RenderProps;
54
58
  declare const _default: {
55
59
  name: string;
56
60
  displayName: string;
57
61
  hidden: true;
58
62
  widget: typeof Matrix;
59
- transform: (arg1: any) => any;
63
+ transform: typeof transform;
60
64
  staticTransform: (arg1: any) => any;
61
65
  isLintable: true;
62
66
  };
@@ -1,11 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { ChangeableProps } from "../../mixins/changeable";
4
- import type { APIOptions, FocusPath, Widget } from "../../types";
3
+ import type { FocusPath, Widget, WidgetProps, UniversalWidgetProps } from "../../types";
5
4
  import type { NumberLinePromptJSON } from "../../widget-ai-utils/number-line/number-line-ai-utils";
6
- import type { Relationship, PerseusNumberLineUserInput } from "@khanacademy/perseus-core";
7
- type Props = ChangeableProps & {
8
- range: [number, number];
5
+ import type { Relationship, PerseusNumberLineUserInput, PerseusNumberLineWidgetOptions, NumberLinePublicWidgetOptions } from "@khanacademy/perseus-core";
6
+ import type { PropsFor } from "@khanacademy/wonder-blocks-core";
7
+ /**
8
+ * The type of `this.props` inside the NumberLine widget.
9
+ */
10
+ type Props = WidgetProps<{
11
+ range: number[];
9
12
  labelRange: Array<number | null>;
10
13
  labelStyle: string;
11
14
  labelTicks: boolean;
@@ -16,15 +19,8 @@ type Props = ChangeableProps & {
16
19
  isInequality: boolean;
17
20
  numLinePosition: number;
18
21
  rel: Relationship;
19
- onFocus: (arg1: any) => void;
20
- onBlur: (arg1: any) => void;
21
- onChange: (arg1: any, arg2?: () => void | null | undefined) => void;
22
- apiOptions: APIOptions;
23
- keypadElement: HTMLElement | null | undefined;
24
- static?: boolean;
25
22
  showTooltips?: boolean;
26
- trackInteraction: () => void;
27
- };
23
+ }>;
28
24
  type DefaultProps = {
29
25
  range: Props["range"];
30
26
  labelStyle: Props["labelStyle"];
@@ -39,6 +35,10 @@ type DefaultProps = {
39
35
  rel: Props["rel"];
40
36
  apiOptions: Props["apiOptions"];
41
37
  };
38
+ /**
39
+ * The props returned by the `transform` and `staticTransform` functions.
40
+ */
41
+ type RenderProps = Omit<PropsFor<typeof NumberLine>, keyof UniversalWidgetProps>;
42
42
  type State = {
43
43
  numDivisionsEmpty: boolean;
44
44
  };
@@ -71,11 +71,13 @@ declare class NumberLine extends React.Component<Props, State> implements Widget
71
71
  getPromptJSON(): NumberLinePromptJSON;
72
72
  render(): React.ReactNode;
73
73
  }
74
+ declare function numberLineTransform(editorProps: NumberLinePublicWidgetOptions): RenderProps;
75
+ declare function staticTransform(editorProps: PerseusNumberLineWidgetOptions): RenderProps;
74
76
  declare const _default: {
75
77
  name: string;
76
78
  displayName: string;
77
79
  widget: typeof NumberLine;
78
- transform: (arg1: any) => any;
79
- staticTransform: (arg1: any) => any;
80
+ transform: typeof numberLineTransform;
81
+ staticTransform: typeof staticTransform;
80
82
  };
81
83
  export default _default;
@@ -1,8 +1,29 @@
1
+ import * as React from "react";
2
+ import type { Focusable } from "../../types";
3
+ import type { LinterContextProps } from "@khanacademy/perseus-linter";
4
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
5
+ type Props = {
6
+ value: string;
7
+ onChange: any;
8
+ className?: string;
9
+ examples: ReadonlyArray<string>;
10
+ shouldShowExamples: boolean;
11
+ convertDotToTimes?: boolean;
12
+ buttonSet?: string;
13
+ buttonsVisible?: "always" | "never" | "focused";
14
+ labelText?: string;
15
+ onFocus?: () => void;
16
+ onBlur?: () => void;
17
+ disabled?: boolean;
18
+ style?: StyleType;
19
+ id: string;
20
+ linterContext?: LinterContextProps;
21
+ };
1
22
  /**
2
23
  * The InputWithExamples component is a child component of the NumericInput
3
24
  * and InputNumber components. It is responsible for rendering the UI elements
4
25
  * for the desktop versions of these widgets, and displays a tooltip with
5
26
  * examples of how to input the selected answer forms.
6
27
  */
7
- declare const InputWithExamples: any;
28
+ declare const InputWithExamples: React.ForwardRefExoticComponent<Props & React.RefAttributes<Focusable>>;
8
29
  export default InputWithExamples;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { FocusPath, Widget, WidgetProps } from "../../types";
2
+ import type { FocusPath, Focusable, Widget, WidgetProps } from "../../types";
3
3
  import type { NumericInputPromptJSON } from "../../widget-ai-utils/numeric-input/prompt-utils";
4
4
  import type { PerseusNumericInputWidgetOptions, PerseusNumericInputAnswerForm, PerseusNumericInputRubric, PerseusNumericInputUserInput } from "@khanacademy/perseus-core";
5
5
  type ExternalProps = WidgetProps<PerseusNumericInputWidgetOptions>;
@@ -31,7 +31,7 @@ type RenderProps = {
31
31
  * by using the functional component for the rendering the UI of the widget.
32
32
  */
33
33
  export declare class NumericInput extends React.Component<NumericInputProps> implements Widget {
34
- inputRef: React.RefObject<any>;
34
+ inputRef: React.RefObject<Focusable>;
35
35
  static defaultProps: DefaultProps;
36
36
  static getUserInputFromProps(props: NumericInputProps): PerseusNumericInputUserInput;
37
37
  focus: () => boolean;
@@ -1,75 +1,11 @@
1
1
  import * as React from "react";
2
+ import type { Focusable } from "../../types";
2
3
  /**
3
4
  * The NumericInputComponent is a child component of the NumericInput class
4
5
  * component. It is responsible for rendering the UI elements of the Numeric
5
6
  * Input widget.
6
7
  */
7
- export declare const NumericInputComponent: React.ForwardRefExoticComponent<import("@khanacademy/perseus-core").PerseusNumericInputWidgetOptions & {
8
- widgetId: string;
9
- alignment: string | null | undefined;
10
- static: boolean | null | undefined;
11
- problemNum: number | null | undefined;
12
- apiOptions: Readonly<Readonly<{
13
- isArticle?: boolean;
14
- onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
15
- GroupMetadataEditor?: React.ComponentType<any>;
16
- showAlignmentOptions?: boolean;
17
- readOnly?: boolean;
18
- answerableCallback?: (arg1: boolean) => unknown;
19
- getAnotherHint?: () => unknown;
20
- interactionCallback?: (widgetData: {
21
- [widgetId: string]: any;
22
- }) => void;
23
- groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
24
- imagePlaceholder?: React.ReactNode;
25
- widgetPlaceholder?: React.ReactNode;
26
- baseElements?: {
27
- Link: React.ComponentType<any>;
28
- };
29
- imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
30
- trackInteraction?: (args: {
31
- type: string;
32
- id: string;
33
- correct?: boolean;
34
- } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
35
- visible: number;
36
- }>) => void;
37
- customKeypad?: boolean;
38
- nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
39
- isMobile?: boolean;
40
- setDrawingAreaAvailable?: (arg1: boolean) => unknown;
41
- hintProgressColor?: string;
42
- canScrollPage?: boolean;
43
- crossOutEnabled?: boolean;
44
- editorChangeDelay?: number;
45
- flags?: Record<"new-radio-widget", boolean>;
46
- onWidgetStartProps?: (widgets: import("@khanacademy/perseus-core").PerseusWidgetsMap) => void;
47
- }> & {
48
- baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
49
- canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
50
- crossOutEnabled: NonNullable<import("../..").APIOptions["crossOutEnabled"]>;
51
- editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
52
- groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
53
- isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
54
- isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
55
- onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
56
- readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
57
- setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
58
- showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
59
- }>;
60
- keypadElement?: any;
61
- questionCompleted?: boolean;
62
- onFocus: (blurPath: import("../..").FocusPath) => void;
63
- onBlur: (blurPath: import("../..").FocusPath) => void;
64
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<import("../../types").Widget>;
65
- reviewModeRubric?: Empty | null | undefined;
66
- reviewMode: boolean;
67
- onChange: import("../..").ChangeHandler;
68
- trackInteraction: (extraData?: Empty | undefined) => void;
69
- isLastUsedWidget: boolean;
70
- linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
71
- containerSizeClass: import("../../util/sizing-utils").SizeClass;
72
- } & {
8
+ export declare const NumericInputComponent: React.ForwardRefExoticComponent<import("@khanacademy/perseus-core").PerseusNumericInputWidgetOptions & import("../../types").UniversalWidgetProps<Empty, Empty> & {
73
9
  size: NonNullable<string>;
74
10
  rightAlign: NonNullable<boolean | undefined>;
75
11
  apiOptions: NonNullable<Readonly<Readonly<{
@@ -125,4 +61,4 @@ export declare const NumericInputComponent: React.ForwardRefExoticComponent<impo
125
61
  labelText: string;
126
62
  linterContext: NonNullable<import("@khanacademy/perseus-linter").LinterContextProps>;
127
63
  currentValue: string;
128
- } & React.RefAttributes<unknown>>;
64
+ } & React.RefAttributes<Focusable>>;
@@ -1,23 +1,17 @@
1
1
  import * as React from "react";
2
2
  import type { Widget, WidgetProps } from "../../types";
3
3
  import type { OrdererPromptJSON } from "../../widget-ai-utils/orderer/orderer-ai-utils";
4
- import type { PerseusOrdererWidgetOptions, PerseusOrdererUserInput } from "@khanacademy/perseus-core";
4
+ import type { PerseusOrdererUserInput } from "@khanacademy/perseus-core";
5
+ import type { OrdererPublicWidgetOptions } from "@khanacademy/perseus-core/src/widgets/orderer/orderer-util";
5
6
  type Position = {
6
7
  left: number;
7
8
  top: number;
8
9
  };
9
- type RenderProps = PerseusOrdererWidgetOptions & {
10
+ type RenderProps = OrdererPublicWidgetOptions & {
10
11
  current: any;
11
12
  };
12
13
  type OrdererProps = WidgetProps<RenderProps>;
13
- type OrdererDefaultProps = {
14
- current: OrdererProps["current"];
15
- options: OrdererProps["options"];
16
- correctOptions: OrdererProps["correctOptions"];
17
- height: OrdererProps["height"];
18
- layout: OrdererProps["layout"];
19
- linterContext: OrdererProps["linterContext"];
20
- };
14
+ type OrdererDefaultProps = Pick<OrdererProps, "current" | "options" | "height" | "layout" | "linterContext">;
21
15
  type OrdererState = {
22
16
  current: ReadonlyArray<any>;
23
17
  dragging: boolean;
@@ -3,7 +3,8 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { Widget, WidgetProps } from "../../types";
4
4
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
5
5
  import type { PerseusPlotterWidgetOptions, PerseusPlotterUserInput } from "@khanacademy/perseus-core";
6
- type RenderProps = PerseusPlotterWidgetOptions;
6
+ import type { PlotterPublicWidgetOptions } from "@khanacademy/perseus-core/src/widgets/plotter/plotter-util";
7
+ type RenderProps = PlotterPublicWidgetOptions;
7
8
  type Props = WidgetProps<RenderProps> & {
8
9
  labelInterval: NonNullable<PerseusPlotterWidgetOptions["labelInterval"]>;
9
10
  picSize: NonNullable<PerseusPlotterWidgetOptions["picSize"]>;