@khanacademy/perseus 82.1.0 → 83.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 (43) hide show
  1. package/dist/components/sortable.d.ts +1 -1
  2. package/dist/components.d.ts +0 -2
  3. package/dist/es/index.css +2 -2
  4. package/dist/es/index.css.map +1 -1
  5. package/dist/es/index.js +88 -98
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/es/strings.js +1 -1
  8. package/dist/es/strings.js.map +1 -1
  9. package/dist/index.css +2 -2
  10. package/dist/index.css.map +1 -1
  11. package/dist/index.js +89 -98
  12. package/dist/index.js.map +1 -1
  13. package/dist/question-paragraph.new.d.ts +9 -0
  14. package/dist/renderer.new.d.ts +1 -1
  15. package/dist/renderer.old.d.ts +1 -1
  16. package/dist/strings.d.ts +6 -0
  17. package/dist/strings.js +1 -1
  18. package/dist/strings.js.map +1 -1
  19. package/dist/styles/constants.d.ts +2 -7
  20. package/dist/util.d.ts +23 -0
  21. package/dist/widget-ai-utils/input-number/input-number-ai-utils.d.ts +1 -1
  22. package/dist/widget-ai-utils/numeric-input/prompt-utils.d.ts +1 -1
  23. package/dist/{widget-container.d.ts → widget-container.new.d.ts} +5 -0
  24. package/dist/widget-container.old.d.ts +31 -0
  25. package/dist/widgets/categorizer/categorizer.d.ts +63 -8
  26. package/dist/widgets/cs-program/cs-program.d.ts +1 -2
  27. package/dist/widgets/dropdown/dropdown.d.ts +1 -2
  28. package/dist/widgets/image/image.d.ts +1 -2
  29. package/dist/widgets/input-number/input-number.d.ts +60 -4
  30. package/dist/widgets/interaction/interaction.d.ts +2 -2
  31. package/dist/widgets/matcher/matcher.d.ts +66 -32
  32. package/dist/widgets/measurer/measurer.d.ts +1 -4
  33. package/dist/widgets/number-line/number-line.d.ts +1 -4
  34. package/dist/widgets/numeric-input/index.d.ts +1 -1
  35. package/dist/widgets/numeric-input/numeric-input.d.ts +76 -53
  36. package/dist/widgets/numeric-input/utils.d.ts +14 -1
  37. package/dist/widgets/phet-simulation/phet-simulation.d.ts +2 -0
  38. package/dist/widgets/table/table.d.ts +17 -56
  39. package/package.json +12 -11
  40. package/dist/components/info-tip/index.d.ts +0 -19
  41. package/dist/components/info-tip/info-tip-base.d.ts +0 -6
  42. package/dist/components/text-list-editor.d.ts +0 -15
  43. package/dist/widgets/numeric-input/numeric-input.class.d.ts +0 -127
@@ -1,9 +1,6 @@
1
1
  export declare const baseFontFamily = "'Lato', sans-serif";
2
2
  export declare const boldFontFamily = "'Lato-Bold', 'Lato', sans-serif";
3
- export declare const kaGreen = "#71B307";
4
3
  export declare const white = "#FFFFFF";
5
- export declare const gray97 = "#F6F7F7";
6
- export declare const gray85 = "#D6D8DA";
7
4
  export declare const gray76 = "#BABEC2";
8
5
  export declare const gray68 = "#888D93";
9
6
  export declare const gray17 = "#21242c";
@@ -17,8 +14,8 @@ export declare const pureMdMax = "1023px";
17
14
  export declare const pureLgMax = "1279px";
18
15
  export declare const phoneMargin = 16;
19
16
  export declare const negativePhoneMargin = -16;
20
- export declare const hintBorderWidth = 4;
21
- export declare const baseUnitPx = 16;
17
+ export declare const hintBorderWidth: string;
18
+ export declare const hintPaddingInlineStart: string;
22
19
  export declare const interactiveSizes: {
23
20
  readonly defaultBoxSize: 400;
24
21
  readonly defaultBoxSizeSmall: 288;
@@ -29,7 +26,5 @@ export declare const warningColor = "#f86700";
29
26
  export declare const warningColorHover = "#df5c00";
30
27
  export declare const warningColorActive = "#c75300";
31
28
  export declare const publishBlockingErrorColor = "#be2612";
32
- export declare const radioBorderColor = "#BABEC2";
33
- export declare const checkedColor = "#71B307";
34
29
  export declare const articleMaxWidthInPx = 688;
35
30
  export declare const articleMaxWidthTableInPx = 512;
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;
@@ -18,9 +18,9 @@ declare class Interaction extends React.Component<Props, State> implements Widge
18
18
  state: State;
19
19
  UNSAFE_componentWillReceiveProps(nextProps: Props): void;
20
20
  _setupGraphie: (arg1: any, arg2: any) => void;
21
- _updatePointLocation: (arg1: string, arg2: Coord) => void;
21
+ _updatePointLocation: (arg1: number, arg2: Coord) => void;
22
22
  _updateLineLocation: (arg1: any, arg2: Coord) => void;
23
- _eval: (arg1: any, arg2: any) => number;
23
+ _eval: (arg1: any, arg2?: any) => number;
24
24
  _extractVars: (arg1: any) => ReadonlyArray<any>;
25
25
  getPromptJSON(): UnsupportedWidgetPromptJSON;
26
26
  render(): React.ReactNode;
@@ -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;
@@ -2,10 +2,7 @@ import { type PerseusMeasurerWidgetOptions } from "@khanacademy/perseus-core";
2
2
  import * as React from "react";
3
3
  import type { Widget, WidgetProps } from "../../types";
4
4
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
5
- type Props = WidgetProps<PerseusMeasurerWidgetOptions> & {
6
- protractorX: number;
7
- protractorY: number;
8
- };
5
+ type Props = WidgetProps<PerseusMeasurerWidgetOptions>;
9
6
  declare class Measurer extends React.Component<Props> implements Widget {
10
7
  isWidget: true;
11
8
  ruler: any;
@@ -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";