@khanacademy/perseus 82.1.0 → 82.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.
Files changed (35) hide show
  1. package/dist/components/sortable.d.ts +1 -1
  2. package/dist/es/index.css +1 -1
  3. package/dist/es/index.css.map +1 -1
  4. package/dist/es/index.js +38 -35
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/es/strings.js +1 -1
  7. package/dist/es/strings.js.map +1 -1
  8. package/dist/index.css +1 -1
  9. package/dist/index.css.map +1 -1
  10. package/dist/index.js +37 -33
  11. package/dist/index.js.map +1 -1
  12. package/dist/question-paragraph.new.d.ts +9 -0
  13. package/dist/renderer.new.d.ts +1 -1
  14. package/dist/renderer.old.d.ts +1 -1
  15. package/dist/strings.d.ts +6 -0
  16. package/dist/strings.js +1 -1
  17. package/dist/strings.js.map +1 -1
  18. package/dist/util.d.ts +23 -0
  19. package/dist/widget-ai-utils/input-number/input-number-ai-utils.d.ts +1 -1
  20. package/dist/widget-ai-utils/numeric-input/prompt-utils.d.ts +1 -1
  21. package/dist/{widget-container.d.ts → widget-container.new.d.ts} +5 -0
  22. package/dist/widget-container.old.d.ts +31 -0
  23. package/dist/widgets/categorizer/categorizer.d.ts +63 -8
  24. package/dist/widgets/cs-program/cs-program.d.ts +1 -2
  25. package/dist/widgets/dropdown/dropdown.d.ts +1 -2
  26. package/dist/widgets/image/image.d.ts +1 -2
  27. package/dist/widgets/input-number/input-number.d.ts +60 -4
  28. package/dist/widgets/matcher/matcher.d.ts +66 -32
  29. package/dist/widgets/number-line/number-line.d.ts +1 -4
  30. package/dist/widgets/numeric-input/index.d.ts +1 -1
  31. package/dist/widgets/numeric-input/numeric-input.d.ts +76 -53
  32. package/dist/widgets/numeric-input/utils.d.ts +14 -1
  33. package/dist/widgets/phet-simulation/phet-simulation.d.ts +2 -0
  34. package/package.json +11 -11
  35. package/dist/widgets/numeric-input/numeric-input.class.d.ts +0 -127
package/dist/util.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getRealImageUrl, getBaseUrl, getSvgUrl, getDataUrl, getImageSizeModern, isLabeledSVG } from "@khanacademy/perseus-core";
2
2
  import type { Coord, Range } from "@khanacademy/perseus-core";
3
+ import type { ASTNode, SingleASTNode } from "@khanacademy/simple-markdown";
3
4
  import type * as React from "react";
4
5
  type WordPosition = {
5
6
  start: number;
@@ -34,6 +35,27 @@ type TouchHandlers = {
34
35
  * arrays of strings.
35
36
  */
36
37
  declare function inputPathsEqual(a?: ReadonlyArray<string> | null, b?: ReadonlyArray<string> | null): boolean;
38
+ /**
39
+ * Some widgets render as inline content but CANNOT safely live
40
+ * inside a paragraph (`<p>`). When this function returns true, the
41
+ * QuestionParagraph component will not render the containing <p> element.
42
+ * No additional processing is done on the sibling nodes.
43
+ */
44
+ export declare const noParagraphForInlineWidget: (node: SingleASTNode) => boolean;
45
+ /**
46
+ * Handle situations in the markdown where a block-level widget doesn't have the
47
+ * expected double-newline characters in place. The blockRegex function in
48
+ * perseus-markdown.tsx expects a double-newline. When only a single newline
49
+ * character exists, then the widget is contained by a <p> element, which is
50
+ * invalid HTML. This function splits out the widget from the inline text so
51
+ * that the HTML is valid (<p> elements surround inline content, block-level
52
+ * widgets are by themselves).
53
+ *
54
+ * Only direct children of top-level paragraphs are considered; block widgets
55
+ * nested inside inline formatting (e.g. `strong`) or inside other containers
56
+ * (tables, columns) are not split out.
57
+ */
58
+ declare function splitBlockWidgetsFromParagraphs(ast: ASTNode): ASTNode;
37
59
  /**
38
60
  * Return the first valid interpretation of 'text' as a number, in the form
39
61
  * {value: 2.3, exact: true}.
@@ -164,6 +186,7 @@ declare const Util: {
164
186
  readonly rTypeFromWidgetId: RegExp;
165
187
  readonly rWidgetParts: RegExp;
166
188
  readonly snowman: "☃";
189
+ readonly splitBlockWidgetsFromParagraphs: typeof splitBlockWidgetsFromParagraphs;
167
190
  readonly firstNumericalParse: typeof firstNumericalParse;
168
191
  readonly stringArrayOfSize: typeof stringArrayOfSize;
169
192
  readonly stringArrayOfSize2D: typeof stringArrayOfSize2D;
@@ -14,7 +14,7 @@ export type InputNumberPromptJSON = {
14
14
  * Shown to learners using screen readers to describe what value should
15
15
  * be entered.
16
16
  */
17
- label: string;
17
+ label?: string;
18
18
  /**
19
19
  * The current state of the widget user interface. Usually represents a
20
20
  * learner's attempt to answer a question.
@@ -1,4 +1,4 @@
1
- import type numericInput from "../../widgets/numeric-input/numeric-input.class";
1
+ import type numericInput from "../../widgets/numeric-input/numeric-input";
2
2
  import type React from "react";
3
3
  /**
4
4
  * JSON describing a numeric-input widget. Intended for consumption by AI tools.
@@ -1,3 +1,8 @@
1
+ /***********************************************************************
2
+ * *
3
+ * WARNING!!!! THERE ARE ACTIVE CHANGES HAPPENING IN THE RENDERER! *
4
+ * *
5
+ ***********************************************************************/
1
6
  import { type PerseusWidgetOptions } from "@khanacademy/perseus-core";
2
7
  import * as React from "react";
3
8
  import type { WidgetProps } from "./types";
@@ -0,0 +1,31 @@
1
+ /***********************************************************************
2
+ * *
3
+ * WARNING!!!! THERE ARE ACTIVE CHANGES HAPPENING IN THE RENDERER! *
4
+ * *
5
+ ***********************************************************************/
6
+ import { type PerseusWidgetOptions } from "@khanacademy/perseus-core";
7
+ import * as React from "react";
8
+ import type { WidgetProps } from "./types";
9
+ import type { LinterContextProps } from "@khanacademy/perseus-linter";
10
+ type Props = {
11
+ type: string;
12
+ id: string;
13
+ widgetProps: WidgetProps<any, PerseusWidgetOptions>;
14
+ linterContext: LinterContextProps;
15
+ };
16
+ type DefaultProps = {
17
+ linterContext: LinterContextProps;
18
+ };
19
+ type State = {
20
+ sizeClass: "small" | "medium" | "large" | "xlarge";
21
+ };
22
+ declare class WidgetContainerOld extends React.Component<Props, State> {
23
+ widgetRef: React.RefObject<React.ComponentType<any>>;
24
+ static defaultProps: DefaultProps;
25
+ state: State;
26
+ componentDidMount(): void;
27
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
28
+ getWidget: () => any;
29
+ render(): React.ReactNode;
30
+ }
31
+ export default WidgetContainerOld;
@@ -1,11 +1,7 @@
1
- import * as React from "react";
2
- import type { PerseusDependenciesV2, WidgetProps } from "../../types";
3
- import type { PerseusCategorizerWidgetOptions, PerseusCategorizerUserInput } from "@khanacademy/perseus-core";
1
+ import React from "react";
2
+ import type { PerseusDependenciesV2, Widget, WidgetProps } from "../../types";
3
+ import type { PerseusCategorizerUserInput, PerseusCategorizerWidgetOptions } from "@khanacademy/perseus-core";
4
4
  type ExternalProps = WidgetProps<PerseusCategorizerWidgetOptions, PerseusCategorizerUserInput>;
5
- type Props = ExternalProps & {
6
- linterContext: NonNullable<ExternalProps["linterContext"]>;
7
- dependencies: PerseusDependenciesV2;
8
- };
9
5
  /**
10
6
  * @deprecated and likely a very broken API
11
7
  * [LEMS-3185] do not trust serializedState
@@ -20,7 +16,66 @@ declare function getStartUserInput(): PerseusCategorizerUserInput;
20
16
  declare const _default: {
21
17
  name: string;
22
18
  displayName: string;
23
- widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
19
+ widget: React.ForwardRefExoticComponent<Omit<Omit<PerseusCategorizerWidgetOptions & {
20
+ trackInteraction: (extraData?: Empty | undefined) => void;
21
+ widgetId: string;
22
+ widgetIndex: number;
23
+ alignment: string | null | undefined;
24
+ static: boolean | null | undefined;
25
+ graded?: boolean | null;
26
+ problemNum: number | null | undefined;
27
+ apiOptions: Readonly<Readonly<{
28
+ isArticle?: boolean;
29
+ onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
30
+ showAlignmentOptions?: boolean;
31
+ readOnly?: boolean;
32
+ editingDisabled?: boolean;
33
+ answerableCallback?: (arg1: boolean) => unknown;
34
+ getAnotherHint?: () => unknown;
35
+ interactionCallback?: (widgetData: {
36
+ [widgetId: string]: any;
37
+ }) => void;
38
+ imagePlaceholder?: React.ReactNode;
39
+ widgetPlaceholder?: React.ReactNode;
40
+ baseElements?: {
41
+ Link: React.ComponentType<any>;
42
+ };
43
+ trackInteraction?: (args: {
44
+ type: string;
45
+ id: string;
46
+ correct?: boolean;
47
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
48
+ visible: number;
49
+ }>) => void;
50
+ customKeypad?: boolean;
51
+ isMobile?: boolean;
52
+ isMobileApp?: boolean;
53
+ hintProgressColor?: string;
54
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
55
+ }> & {
56
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
57
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
58
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
59
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
60
+ editingDisabled: NonNullable<import("../..").APIOptions["editingDisabled"]>;
61
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
62
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
63
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
64
+ }>;
65
+ keypadElement?: any;
66
+ onFocus: (blurPath: import("../..").FocusPath) => void;
67
+ onBlur: (blurPath: import("../..").FocusPath) => void;
68
+ findWidgets: import("../../types").FindWidgetsFunction;
69
+ reviewMode: boolean;
70
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
71
+ handleUserInput: (newUserInput: PerseusCategorizerUserInput, cb?: () => void, silent?: boolean) => void;
72
+ userInput: PerseusCategorizerUserInput;
73
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
74
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
75
+ } & {
76
+ linterContext: NonNullable<ExternalProps["linterContext"]>;
77
+ dependencies: PerseusDependenciesV2;
78
+ } & React.RefAttributes<Widget>, "dependencies">, "ref"> & React.RefAttributes<any>>;
24
79
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
25
80
  getCorrectUserInput: typeof getCorrectUserInput;
26
81
  getStartUserInput: typeof getStartUserInput;
@@ -4,7 +4,6 @@
4
4
  import React from "react";
5
5
  import type { Widget } from "../../types";
6
6
  import type { PerseusCSProgramWidgetOptions, PerseusCSProgramUserInput } from "@khanacademy/perseus-core";
7
- type WidgetHandle = Pick<Widget, "getPromptJSON" | "getSerializedState">;
8
7
  /**
9
8
  * @deprecated and likely a very broken API
10
9
  * [LEMS-3185] do not trust serializedState
@@ -70,7 +69,7 @@ declare const _default: {
70
69
  userInput: PerseusCSProgramUserInput;
71
70
  linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
72
71
  containerSizeClass: import("../../util/sizing-utils").SizeClass;
73
- } & React.RefAttributes<WidgetHandle>>;
72
+ } & React.RefAttributes<Widget>>;
74
73
  hidden: true;
75
74
  getStartUserInput: typeof getStartUserInput;
76
75
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import type { PerseusDependenciesV2, Widget } from "../../types";
3
3
  import type { PerseusDropdownUserInput, PerseusDropdownWidgetOptions } from "@khanacademy/perseus-core";
4
- type WidgetHandle = Pick<Widget, "focus" | "getPromptJSON" | "getSerializedState">;
5
4
  /**
6
5
  * @deprecated and likely a very broken API
7
6
  * [LEMS-3185] do not trust serializedState
@@ -70,7 +69,7 @@ declare const _default: {
70
69
  containerSizeClass: import("../../util/sizing-utils").SizeClass;
71
70
  } & {
72
71
  dependencies: PerseusDependenciesV2;
73
- } & React.RefAttributes<WidgetHandle>, "dependencies">, "ref"> & React.RefAttributes<any>>;
72
+ } & React.RefAttributes<Widget>, "dependencies">, "ref"> & React.RefAttributes<any>>;
74
73
  getStartUserInput: typeof getStartUserInput;
75
74
  getCorrectUserInput: typeof getCorrectUserInput;
76
75
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import type { Widget } from "../../types";
3
3
  import type { PerseusImageWidgetOptions } from "@khanacademy/perseus-core";
4
- type WidgetHandle = Pick<Widget, "getPromptJSON">;
5
4
  declare const _default: {
6
5
  name: string;
7
6
  displayName: string;
@@ -61,7 +60,7 @@ declare const _default: {
61
60
  userInput: Empty;
62
61
  linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
63
62
  containerSizeClass: import("../../util/sizing-utils").SizeClass;
64
- } & React.RefAttributes<WidgetHandle>>;
63
+ } & React.RefAttributes<Widget>>;
65
64
  isLintable: true;
66
65
  };
67
66
  export default _default;
@@ -8,11 +8,67 @@ declare const _default: {
8
8
  name: string;
9
9
  displayName: string;
10
10
  hidden: true;
11
- widget: typeof import("../numeric-input/numeric-input.class").NumericInput;
11
+ widget: import("react").ForwardRefExoticComponent<import("@khanacademy/perseus-core").PerseusNumericInputWidgetOptions & {
12
+ trackInteraction: (extraData?: Empty | undefined) => void;
13
+ widgetId: string;
14
+ widgetIndex: number;
15
+ alignment: string | null | undefined;
16
+ static: boolean | null | undefined;
17
+ graded?: boolean | null;
18
+ problemNum: number | null | undefined;
19
+ apiOptions: Readonly<Readonly<{
20
+ isArticle?: boolean;
21
+ onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
22
+ showAlignmentOptions?: boolean;
23
+ readOnly?: boolean;
24
+ editingDisabled?: boolean;
25
+ answerableCallback?: (arg1: boolean) => unknown;
26
+ getAnotherHint?: () => unknown;
27
+ interactionCallback?: (widgetData: {
28
+ [widgetId: string]: any;
29
+ }) => void;
30
+ imagePlaceholder?: React.ReactNode;
31
+ widgetPlaceholder?: React.ReactNode;
32
+ baseElements?: {
33
+ Link: React.ComponentType<any>;
34
+ };
35
+ trackInteraction?: (args: {
36
+ type: string;
37
+ id: string;
38
+ correct?: boolean;
39
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
40
+ visible: number;
41
+ }>) => void;
42
+ customKeypad?: boolean;
43
+ isMobile?: boolean;
44
+ isMobileApp?: boolean;
45
+ hintProgressColor?: string;
46
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
47
+ }> & {
48
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
49
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
50
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
51
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
52
+ editingDisabled: NonNullable<import("../..").APIOptions["editingDisabled"]>;
53
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
54
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
55
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
56
+ }>;
57
+ keypadElement?: any;
58
+ onFocus: (blurPath: import("../..").FocusPath) => void;
59
+ onBlur: (blurPath: import("../..").FocusPath) => void;
60
+ findWidgets: import("../../types").FindWidgetsFunction;
61
+ reviewMode: boolean;
62
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
63
+ handleUserInput: (newUserInput: import("@khanacademy/perseus-core").PerseusNumericInputUserInput, cb?: () => void, silent?: boolean) => void;
64
+ userInput: import("@khanacademy/perseus-core").PerseusNumericInputUserInput;
65
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
66
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
67
+ } & import("react").RefAttributes<import("../../types").Widget>>;
12
68
  isLintable: true;
13
- getOneCorrectAnswerFromRubric: (rubric: import("@khanacademy/perseus-core").PerseusNumericInputRubric) => string | null | undefined;
14
- getStartUserInput: () => import("@khanacademy/perseus-core").PerseusNumericInputUserInput;
15
- getCorrectUserInput: (options: import("@khanacademy/perseus-core").PerseusNumericInputWidgetOptions) => import("@khanacademy/perseus-core").PerseusNumericInputUserInput;
69
+ getOneCorrectAnswerFromRubric: typeof import("../numeric-input/utils").getOneCorrectAnswerFromRubric;
70
+ getStartUserInput: typeof import("../numeric-input/utils").getStartUserInput;
71
+ getCorrectUserInput: typeof import("../numeric-input/utils").getCorrectUserInput;
16
72
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
17
73
  };
18
74
  export default _default;
@@ -1,39 +1,15 @@
1
1
  import * as React from "react";
2
- import { PerseusI18nContext } from "../../components/i18n-context";
3
2
  import type { SortableOption } from "../../components/sortable";
4
- import type { WidgetProps, Widget, PerseusDependenciesV2 } from "../../types";
5
- import type { MatcherPromptJSON } from "../../widget-ai-utils/matcher/matcher-ai-utils";
3
+ import type { Widget, PerseusDependenciesV2 } from "../../types";
6
4
  import type { PerseusMatcherWidgetOptions, PerseusMatcherUserInput, MatcherPublicWidgetOptions } from "@khanacademy/perseus-core";
7
- type Props = WidgetProps<PerseusMatcherWidgetOptions, PerseusMatcherUserInput> & {
8
- dependencies: PerseusDependenciesV2;
9
- };
10
- type DefaultProps = {
11
- labels: Props["labels"];
12
- orderMatters: Props["orderMatters"];
13
- padding: Props["padding"];
14
- problemNum: Props["problemNum"];
15
- linterContext: Props["linterContext"];
16
- userInput: Props["userInput"];
17
- };
18
- type State = {
19
- leftHeight: number;
20
- rightHeight: number;
21
- texRendererLoaded: boolean;
22
- };
23
- export declare class Matcher extends React.Component<Props, State> implements Widget {
24
- static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
25
- context: React.ContextType<typeof PerseusI18nContext>;
26
- static defaultProps: DefaultProps;
27
- state: State;
28
- componentDidMount(): void;
29
- changeAndTrack: () => void;
30
- onMeasureLeft: (arg1: any) => void;
31
- onMeasureRight: (arg1: any) => void;
32
- _getUserInputFromSortable: () => PerseusMatcherUserInput;
33
- getPromptJSON(): MatcherPromptJSON;
5
+ /**
6
+ * The imperative API the Matcher widget exposes to its parent renderer. On top
7
+ * of the usual `Widget` methods, it can move a named option to a given index
8
+ * within its column, as if the user had dragged it there.
9
+ */
10
+ export interface MatcherHandle extends Widget {
34
11
  moveLeftOptionToIndex: (option: SortableOption, index: number) => void;
35
12
  moveRightOptionToIndex: (option: SortableOption, index: number) => void;
36
- render(): React.ReactElement;
37
13
  }
38
14
  declare function getStartUserInput(options: MatcherPublicWidgetOptions, problemNum: number): PerseusMatcherUserInput;
39
15
  /**
@@ -45,7 +21,65 @@ declare const _default: {
45
21
  name: string;
46
22
  displayName: string;
47
23
  hidden: true;
48
- widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
24
+ widget: React.ForwardRefExoticComponent<Omit<Omit<PerseusMatcherWidgetOptions & {
25
+ trackInteraction: (extraData?: Empty | undefined) => void;
26
+ widgetId: string;
27
+ widgetIndex: number;
28
+ alignment: string | null | undefined;
29
+ static: boolean | null | undefined;
30
+ graded?: boolean | null;
31
+ problemNum: number | null | undefined;
32
+ apiOptions: Readonly<Readonly<{
33
+ isArticle?: boolean;
34
+ onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
35
+ showAlignmentOptions?: boolean;
36
+ readOnly?: boolean;
37
+ editingDisabled?: boolean;
38
+ answerableCallback?: (arg1: boolean) => unknown;
39
+ getAnotherHint?: () => unknown;
40
+ interactionCallback?: (widgetData: {
41
+ [widgetId: string]: any;
42
+ }) => void;
43
+ imagePlaceholder?: React.ReactNode;
44
+ widgetPlaceholder?: React.ReactNode;
45
+ baseElements?: {
46
+ Link: React.ComponentType<any>;
47
+ };
48
+ trackInteraction?: (args: {
49
+ type: string;
50
+ id: string;
51
+ correct?: boolean;
52
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
53
+ visible: number;
54
+ }>) => void;
55
+ customKeypad?: boolean;
56
+ isMobile?: boolean;
57
+ isMobileApp?: boolean;
58
+ hintProgressColor?: string;
59
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
60
+ }> & {
61
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
62
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
63
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
64
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
65
+ editingDisabled: NonNullable<import("../..").APIOptions["editingDisabled"]>;
66
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
67
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
68
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
69
+ }>;
70
+ keypadElement?: any;
71
+ onFocus: (blurPath: import("../..").FocusPath) => void;
72
+ onBlur: (blurPath: import("../..").FocusPath) => void;
73
+ findWidgets: import("../../types").FindWidgetsFunction;
74
+ reviewMode: boolean;
75
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
76
+ handleUserInput: (newUserInput: PerseusMatcherUserInput, cb?: () => void, silent?: boolean) => void;
77
+ userInput: PerseusMatcherUserInput;
78
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
79
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
80
+ } & {
81
+ dependencies: PerseusDependenciesV2;
82
+ } & React.RefAttributes<MatcherHandle>, "dependencies">, "ref"> & React.RefAttributes<any>>;
49
83
  isLintable: true;
50
84
  getStartUserInput: typeof getStartUserInput;
51
85
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
@@ -1,9 +1,6 @@
1
1
  import * as React from "react";
2
2
  import type { Widget, PerseusDependenciesV2 } from "../../types";
3
3
  import type { PerseusNumberLineUserInput, PerseusNumberLineWidgetOptions, NumberLinePublicWidgetOptions } from "@khanacademy/perseus-core";
4
- type WidgetHandle = Pick<Widget, "focus" | "focusInputPath" | "blurInputPath" | "getInputPaths" | "getDOMNodeForPath" | "getSerializedState" | "getPromptJSON"> & {
5
- movePosition: (targetPosition: number) => void;
6
- };
7
4
  /**
8
5
  * @deprecated and likely a very broken API
9
6
  * [LEMS-3185] do not trust serializedState
@@ -72,7 +69,7 @@ declare const _default: {
72
69
  containerSizeClass: import("../../util/sizing-utils").SizeClass;
73
70
  } & {
74
71
  dependencies: PerseusDependenciesV2;
75
- } & React.RefAttributes<WidgetHandle>, "dependencies">, "ref"> & React.RefAttributes<any>>;
72
+ } & React.RefAttributes<Widget>, "dependencies">, "ref"> & React.RefAttributes<any>>;
76
73
  getCorrectUserInput: typeof getCorrectUserInput;
77
74
  getStartUserInput: typeof getStartUserInput;
78
75
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
@@ -1 +1 @@
1
- export { default } from "./numeric-input.class";
1
+ export { default } from "./numeric-input";
@@ -1,11 +1,12 @@
1
1
  import * as React from "react";
2
- import type { Focusable } from "../../types";
2
+ import { getCorrectUserInput, getOneCorrectAnswerFromRubric, getStartUserInput, getUserInputFromSerializedState } from "./utils";
3
+ import type { Widget } from "../../types";
4
+ import type { PerseusNumericInputUserInput, PerseusNumericInputWidgetOptions } from "@khanacademy/perseus-core";
3
5
  /**
4
- * The NumericInputComponent is a child component of the NumericInput class
5
- * component. It is responsible for rendering the UI elements of the Numeric
6
- * Input widget.
6
+ * The NumericInput widget is a numeric input field that supports a variety of
7
+ * answer forms, including integers, decimals, fractions, and mixed numbers.
7
8
  */
8
- export declare const NumericInputComponent: React.ForwardRefExoticComponent<import("@khanacademy/perseus-core").PerseusNumericInputWidgetOptions & {
9
+ export declare const NumericInput: React.ForwardRefExoticComponent<PerseusNumericInputWidgetOptions & {
9
10
  trackInteraction: (extraData?: Empty | undefined) => void;
10
11
  widgetId: string;
11
12
  widgetIndex: number;
@@ -57,53 +58,75 @@ export declare const NumericInputComponent: React.ForwardRefExoticComponent<impo
57
58
  findWidgets: import("../../types").FindWidgetsFunction;
58
59
  reviewMode: boolean;
59
60
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
60
- handleUserInput: (newUserInput: import("@khanacademy/perseus-core").PerseusNumericInputUserInput, cb?: () => void, silent?: boolean) => void;
61
- userInput: import("@khanacademy/perseus-core").PerseusNumericInputUserInput;
61
+ handleUserInput: (newUserInput: PerseusNumericInputUserInput, cb?: () => void, silent?: boolean) => void;
62
+ userInput: PerseusNumericInputUserInput;
62
63
  linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
63
64
  containerSizeClass: import("../../util/sizing-utils").SizeClass;
64
- } & {
65
- size: NonNullable<string>;
66
- textAlign: NonNullable<"center" | "left" | "right">;
67
- apiOptions: NonNullable<Readonly<Readonly<{
68
- isArticle?: boolean;
69
- onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
70
- showAlignmentOptions?: boolean;
71
- readOnly?: boolean;
72
- editingDisabled?: boolean;
73
- answerableCallback?: (arg1: boolean) => unknown;
74
- getAnotherHint?: () => unknown;
75
- interactionCallback?: (widgetData: {
76
- [widgetId: string]: any;
77
- }) => void;
78
- imagePlaceholder?: React.ReactNode;
79
- widgetPlaceholder?: React.ReactNode;
80
- baseElements?: {
81
- Link: React.ComponentType<any>;
82
- };
83
- trackInteraction?: (args: {
84
- type: string;
85
- id: string;
86
- correct?: boolean;
87
- } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
88
- visible: number;
89
- }>) => void;
90
- customKeypad?: boolean;
91
- isMobile?: boolean;
92
- isMobileApp?: boolean;
93
- hintProgressColor?: string;
94
- flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
95
- }> & {
96
- baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
97
- isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
98
- isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
99
- isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
100
- editingDisabled: NonNullable<import("../..").APIOptions["editingDisabled"]>;
101
- onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
102
- readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
103
- showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
104
- }>>;
105
- coefficient: NonNullable<boolean>;
106
- answerForms: ReadonlyArray<import("@khanacademy/perseus-core").PerseusNumericInputAnswerForm>;
107
- labelText: string;
108
- linterContext: NonNullable<import("@khanacademy/perseus-linter").LinterContextProps>;
109
- } & React.RefAttributes<Focusable>>;
65
+ } & React.RefAttributes<Widget>>;
66
+ declare const _default: {
67
+ name: string;
68
+ displayName: string;
69
+ widget: React.ForwardRefExoticComponent<PerseusNumericInputWidgetOptions & {
70
+ trackInteraction: (extraData?: Empty | undefined) => void;
71
+ widgetId: string;
72
+ widgetIndex: number;
73
+ alignment: string | null | undefined;
74
+ static: boolean | null | undefined;
75
+ graded?: boolean | null;
76
+ problemNum: number | null | undefined;
77
+ apiOptions: Readonly<Readonly<{
78
+ isArticle?: boolean;
79
+ onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
80
+ showAlignmentOptions?: boolean;
81
+ readOnly?: boolean;
82
+ editingDisabled?: boolean;
83
+ answerableCallback?: (arg1: boolean) => unknown;
84
+ getAnotherHint?: () => unknown;
85
+ interactionCallback?: (widgetData: {
86
+ [widgetId: string]: any;
87
+ }) => void;
88
+ imagePlaceholder?: React.ReactNode;
89
+ widgetPlaceholder?: React.ReactNode;
90
+ baseElements?: {
91
+ Link: React.ComponentType<any>;
92
+ };
93
+ trackInteraction?: (args: {
94
+ type: string;
95
+ id: string;
96
+ correct?: boolean;
97
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
98
+ visible: number;
99
+ }>) => void;
100
+ customKeypad?: boolean;
101
+ isMobile?: boolean;
102
+ isMobileApp?: boolean;
103
+ hintProgressColor?: string;
104
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
105
+ }> & {
106
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
107
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
108
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
109
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
110
+ editingDisabled: NonNullable<import("../..").APIOptions["editingDisabled"]>;
111
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
112
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
113
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
114
+ }>;
115
+ keypadElement?: any;
116
+ onFocus: (blurPath: import("../..").FocusPath) => void;
117
+ onBlur: (blurPath: import("../..").FocusPath) => void;
118
+ findWidgets: import("../../types").FindWidgetsFunction;
119
+ reviewMode: boolean;
120
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
121
+ handleUserInput: (newUserInput: PerseusNumericInputUserInput, cb?: () => void, silent?: boolean) => void;
122
+ userInput: PerseusNumericInputUserInput;
123
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
124
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
125
+ } & React.RefAttributes<Widget>>;
126
+ isLintable: true;
127
+ getCorrectUserInput: typeof getCorrectUserInput;
128
+ getOneCorrectAnswerFromRubric: typeof getOneCorrectAnswerFromRubric;
129
+ getStartUserInput: typeof getStartUserInput;
130
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
131
+ };
132
+ export default _default;
@@ -1,5 +1,5 @@
1
1
  import type { PerseusStrings } from "../../strings";
2
- import type { PerseusNumericInputAnswerForm, PerseusNumericInputWidgetOptions } from "@khanacademy/perseus-core";
2
+ import type { PerseusNumericInputAnswerForm, PerseusNumericInputRubric, PerseusNumericInputUserInput, PerseusNumericInputWidgetOptions } from "@khanacademy/perseus-core";
3
3
  /**
4
4
  * Generates the specific set of examples for the current question.
5
5
  * This string is shown as examples to the user in a tooltip.
@@ -21,3 +21,16 @@ export declare const unionAnswerForms: (answerFormsList: ReadonlyArray<ReadonlyA
21
21
  * so that we can generate the examples for the widget.
22
22
  */
23
23
  export declare function normalizeCorrectAnswerForms(answers: PerseusNumericInputWidgetOptions["answers"]): ReadonlyArray<PerseusNumericInputAnswerForm>;
24
+ export declare function getStartUserInput(): PerseusNumericInputUserInput;
25
+ /**
26
+ * @deprecated and likely a very broken API
27
+ * [LEMS-3185] do not trust serializedState
28
+ */
29
+ export declare function getUserInputFromSerializedState(serializedState: any): PerseusNumericInputUserInput;
30
+ export declare function findPrecision(value: number): number;
31
+ export declare function findCommonFractions(value: number): {
32
+ num: number;
33
+ denom: number;
34
+ } | undefined;
35
+ export declare function getCorrectUserInput(options: PerseusNumericInputWidgetOptions): PerseusNumericInputUserInput;
36
+ export declare function getOneCorrectAnswerFromRubric(rubric: PerseusNumericInputRubric): string | null | undefined;
@@ -48,6 +48,8 @@ export declare class PhetSimulation extends React.Component<Props, State> implem
48
48
  * the lack of support for the Fullscreen API.
49
49
  */
50
50
  toggleFullScreen: () => void;
51
+ requestIframeFullscreen: () => void;
52
+ renderCornerButton(url: URL, isMobileApp: boolean | undefined): React.ReactNode;
51
53
  render(): React.ReactNode;
52
54
  }
53
55
  declare const _default: {