@khanacademy/perseus 82.0.0 → 82.1.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.
@@ -15,7 +15,6 @@ export declare const pureXsMax = "567px";
15
15
  export declare const pureSmMax = "767px";
16
16
  export declare const pureMdMax = "1023px";
17
17
  export declare const pureLgMax = "1279px";
18
- export declare const tableBackgroundAccent = "#F9F9F9";
19
18
  export declare const phoneMargin = 16;
20
19
  export declare const negativePhoneMargin = -16;
21
20
  export declare const hintBorderWidth = 4;
@@ -1,32 +1,10 @@
1
1
  /**
2
2
  * This widget is for embedding Khan Academy CS programs.
3
3
  */
4
- import * as React from "react";
5
- import { PerseusI18nContext } from "../../components/i18n-context";
6
- import type { Widget, WidgetProps } from "../../types";
7
- import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
4
+ import React from "react";
5
+ import type { Widget } from "../../types";
8
6
  import type { PerseusCSProgramWidgetOptions, PerseusCSProgramUserInput } from "@khanacademy/perseus-core";
9
- type Props = WidgetProps<PerseusCSProgramWidgetOptions, PerseusCSProgramUserInput>;
10
- type DefaultProps = {
11
- showEditor: Props["showEditor"];
12
- showButtons: Props["showButtons"];
13
- userInput: Props["userInput"];
14
- };
15
- declare class CSProgram extends React.Component<Props> implements Widget {
16
- static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
17
- context: React.ContextType<typeof PerseusI18nContext>;
18
- static defaultProps: DefaultProps;
19
- componentDidMount(): void;
20
- componentWillUnmount(): void;
21
- handleMessageEvent: (arg1: any) => void;
22
- getPromptJSON(): UnsupportedWidgetPromptJSON;
23
- /**
24
- * @deprecated and likely very broken API
25
- * [LEMS-3185] do not trust serializedState
26
- */
27
- getSerializedState(): any;
28
- render(): React.ReactNode;
29
- }
7
+ type WidgetHandle = Pick<Widget, "getPromptJSON" | "getSerializedState">;
30
8
  /**
31
9
  * @deprecated and likely a very broken API
32
10
  * [LEMS-3185] do not trust serializedState
@@ -36,7 +14,63 @@ declare function getStartUserInput(): PerseusCSProgramUserInput;
36
14
  declare const _default: {
37
15
  name: string;
38
16
  displayName: string;
39
- widget: typeof CSProgram;
17
+ widget: React.ForwardRefExoticComponent<PerseusCSProgramWidgetOptions & {
18
+ trackInteraction: (extraData?: Empty | undefined) => void;
19
+ widgetId: string;
20
+ widgetIndex: number;
21
+ alignment: string | null | undefined;
22
+ static: boolean | null | undefined;
23
+ graded?: boolean | null;
24
+ problemNum: number | null | undefined;
25
+ apiOptions: Readonly<Readonly<{
26
+ isArticle?: boolean;
27
+ onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
28
+ showAlignmentOptions?: boolean;
29
+ readOnly?: boolean;
30
+ editingDisabled?: boolean;
31
+ answerableCallback?: (arg1: boolean) => unknown;
32
+ getAnotherHint?: () => unknown;
33
+ interactionCallback?: (widgetData: {
34
+ [widgetId: string]: any;
35
+ }) => void;
36
+ imagePlaceholder?: React.ReactNode;
37
+ widgetPlaceholder?: React.ReactNode;
38
+ baseElements?: {
39
+ Link: React.ComponentType<any>;
40
+ };
41
+ trackInteraction?: (args: {
42
+ type: string;
43
+ id: string;
44
+ correct?: boolean;
45
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
46
+ visible: number;
47
+ }>) => void;
48
+ customKeypad?: boolean;
49
+ isMobile?: boolean;
50
+ isMobileApp?: boolean;
51
+ hintProgressColor?: string;
52
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
53
+ }> & {
54
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
55
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
56
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
57
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
58
+ editingDisabled: NonNullable<import("../..").APIOptions["editingDisabled"]>;
59
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
60
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
61
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
62
+ }>;
63
+ keypadElement?: any;
64
+ onFocus: (blurPath: import("../..").FocusPath) => void;
65
+ onBlur: (blurPath: import("../..").FocusPath) => void;
66
+ findWidgets: import("../../types").FindWidgetsFunction;
67
+ reviewMode: boolean;
68
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
69
+ handleUserInput: (newUserInput: PerseusCSProgramUserInput, cb?: () => void, silent?: boolean) => void;
70
+ userInput: PerseusCSProgramUserInput;
71
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
72
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
73
+ } & React.RefAttributes<WidgetHandle>>;
40
74
  hidden: true;
41
75
  getStartUserInput: typeof getStartUserInput;
42
76
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
@@ -0,0 +1,26 @@
1
+ import * as React from "react";
2
+ import type { vec } from "mafs";
3
+ interface Props {
4
+ /** Pixel-space start point of the asymptote line. */
5
+ start: vec.Vector2;
6
+ /** Pixel-space end point of the asymptote line. */
7
+ end: vec.Vector2;
8
+ /** Stroke color of the dashed line (usually the graph's interactive color). */
9
+ color: string | undefined;
10
+ /** Class applied to both lines (e.g. "movable-dragging" while dragging). */
11
+ className?: string;
12
+ /** Test id applied to the dashed line. */
13
+ testId?: string;
14
+ }
15
+ /**
16
+ * The shared visual for a graph asymptote: a dashed line drawn over a solid
17
+ * backing line. The backing line (in the page background color) sits underneath
18
+ * so the dashes stay visible on top of grid lines and axes.
19
+ *
20
+ * This is presentational only — no hit target, no drag behavior. Interactive
21
+ * asymptotes (exponential/logarithm) render it inside `MovableAsymptote`, which
22
+ * supplies the hitbox and drag handle; derived, non-interactive asymptotes
23
+ * (tangent) render it directly.
24
+ */
25
+ export declare function DashedAsymptoteLine(props: Props): React.JSX.Element;
26
+ export {};
@@ -1,11 +1,8 @@
1
1
  import * as React from "react";
2
- import type { WidgetProps, PerseusDependenciesV2 } from "../../types";
2
+ import type { Widget, PerseusDependenciesV2 } from "../../types";
3
3
  import type { PerseusNumberLineUserInput, PerseusNumberLineWidgetOptions, NumberLinePublicWidgetOptions } from "@khanacademy/perseus-core";
4
- /**
5
- * The type of `this.props` inside the NumberLine widget.
6
- */
7
- type Props = WidgetProps<PerseusNumberLineWidgetOptions, PerseusNumberLineUserInput> & {
8
- dependencies: PerseusDependenciesV2;
4
+ type WidgetHandle = Pick<Widget, "focus" | "focusInputPath" | "blurInputPath" | "getInputPaths" | "getDOMNodeForPath" | "getSerializedState" | "getPromptJSON"> & {
5
+ movePosition: (targetPosition: number) => void;
9
6
  };
10
7
  /**
11
8
  * @deprecated and likely a very broken API
@@ -17,7 +14,65 @@ declare function getStartUserInput(options: NumberLinePublicWidgetOptions): Pers
17
14
  declare const _default: {
18
15
  name: string;
19
16
  displayName: string;
20
- widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
17
+ widget: React.ForwardRefExoticComponent<Omit<Omit<PerseusNumberLineWidgetOptions & {
18
+ trackInteraction: (extraData?: Empty | undefined) => void;
19
+ widgetId: string;
20
+ widgetIndex: number;
21
+ alignment: string | null | undefined;
22
+ static: boolean | null | undefined;
23
+ graded?: boolean | null;
24
+ problemNum: number | null | undefined;
25
+ apiOptions: Readonly<Readonly<{
26
+ isArticle?: boolean;
27
+ onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
28
+ showAlignmentOptions?: boolean;
29
+ readOnly?: boolean;
30
+ editingDisabled?: boolean;
31
+ answerableCallback?: (arg1: boolean) => unknown;
32
+ getAnotherHint?: () => unknown;
33
+ interactionCallback?: (widgetData: {
34
+ [widgetId: string]: any;
35
+ }) => void;
36
+ imagePlaceholder?: React.ReactNode;
37
+ widgetPlaceholder?: React.ReactNode;
38
+ baseElements?: {
39
+ Link: React.ComponentType<any>;
40
+ };
41
+ trackInteraction?: (args: {
42
+ type: string;
43
+ id: string;
44
+ correct?: boolean;
45
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
46
+ visible: number;
47
+ }>) => void;
48
+ customKeypad?: boolean;
49
+ isMobile?: boolean;
50
+ isMobileApp?: boolean;
51
+ hintProgressColor?: string;
52
+ flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator", boolean>;
53
+ }> & {
54
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
55
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
56
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
57
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
58
+ editingDisabled: NonNullable<import("../..").APIOptions["editingDisabled"]>;
59
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
60
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
61
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
62
+ }>;
63
+ keypadElement?: any;
64
+ onFocus: (blurPath: import("../..").FocusPath) => void;
65
+ onBlur: (blurPath: import("../..").FocusPath) => void;
66
+ findWidgets: import("../../types").FindWidgetsFunction;
67
+ reviewMode: boolean;
68
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
69
+ handleUserInput: (newUserInput: PerseusNumberLineUserInput, cb?: () => void, silent?: boolean) => void;
70
+ userInput: PerseusNumberLineUserInput;
71
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
72
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
73
+ } & {
74
+ dependencies: PerseusDependenciesV2;
75
+ } & React.RefAttributes<WidgetHandle>, "dependencies">, "ref"> & React.RefAttributes<any>>;
21
76
  getCorrectUserInput: typeof getCorrectUserInput;
22
77
  getStartUserInput: typeof getStartUserInput;
23
78
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
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": "82.0.0",
6
+ "version": "82.1.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -43,12 +43,12 @@
43
43
  "tiny-invariant": "1.3.1",
44
44
  "uuid": "^10.0.0",
45
45
  "@khanacademy/kas": "2.2.3",
46
- "@khanacademy/keypad-context": "3.2.76",
47
- "@khanacademy/kmath": "2.4.35",
48
- "@khanacademy/math-input": "26.6.5",
49
- "@khanacademy/perseus-core": "33.0.0",
50
- "@khanacademy/perseus-linter": "5.1.16",
51
- "@khanacademy/perseus-score": "8.12.8",
46
+ "@khanacademy/keypad-context": "3.2.77",
47
+ "@khanacademy/kmath": "2.4.36",
48
+ "@khanacademy/math-input": "26.6.6",
49
+ "@khanacademy/perseus-core": "33.0.1",
50
+ "@khanacademy/perseus-linter": "5.1.17",
51
+ "@khanacademy/perseus-score": "8.12.9",
52
52
  "@khanacademy/perseus-utils": "2.1.5",
53
53
  "@khanacademy/pure-markdown": "2.3.1",
54
54
  "@khanacademy/simple-markdown": "3.0.0"