@khanacademy/perseus 83.0.0 → 83.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,15 +16,6 @@ type Props = WidgetProps<PerseusGradedGroupWidgetOptions, Empty, TrackingGradedG
16
16
  onNextQuestion?: () => unknown;
17
17
  dependencies: PerseusDependenciesV2;
18
18
  };
19
- type DefaultProps = {
20
- title: Props["title"];
21
- content: Props["content"];
22
- widgets: Props["widgets"];
23
- images: Props["images"];
24
- hint: Props["hint"];
25
- hasHint: Props["hasHint"];
26
- linterContext: Props["linterContext"];
27
- };
28
19
  type State = {
29
20
  status: (typeof GRADING_STATUSES)[keyof typeof GRADING_STATUSES];
30
21
  showHint: boolean;
@@ -34,7 +25,6 @@ type State = {
34
25
  export declare class GradedGroup extends React.Component<Props, State> implements Widget {
35
26
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
36
27
  context: React.ContextType<typeof PerseusI18nContext>;
37
- static defaultProps: DefaultProps;
38
28
  state: State;
39
29
  rendererRef: React.RefObject<Renderer>;
40
30
  hintRendererRef: React.RefObject<Renderer>;
@@ -13,17 +13,10 @@ import type { FocusPath, Widget, WidgetProps } from "../../types";
13
13
  import type { GroupPromptJSON } from "../../widget-ai-utils/group/group-ai-utils";
14
14
  import type { PerseusGroupUserInput, PerseusGroupWidgetOptions, PerseusRenderer } from "@khanacademy/perseus-core";
15
15
  type Props = WidgetProps<PerseusGroupWidgetOptions, PerseusGroupUserInput>;
16
- type DefaultProps = {
17
- content: Props["content"];
18
- widgets: Props["widgets"];
19
- images: Props["images"];
20
- linterContext: Props["linterContext"];
21
- };
22
16
  declare class Group extends React.Component<Props> implements Widget {
23
17
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
24
18
  context: React.ContextType<typeof PerseusI18nContext>;
25
19
  rendererRef: Renderer | null | undefined;
26
- static defaultProps: DefaultProps;
27
20
  componentDidMount(): void;
28
21
  getPromptJSON(): GroupPromptJSON;
29
22
  /**
@@ -4,134 +4,12 @@ import type { StatefulMafsGraphType } from "./stateful-mafs-graph";
4
4
  import type { WidgetProps } from "../../types";
5
5
  import type { InteractiveGraphPromptJSON } from "../../widget-ai-utils/interactive-graph/interactive-graph-ai-utils";
6
6
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
7
- import type { PerseusGraphType, PerseusInteractiveGraphWidgetOptions, GraphRange, InteractiveGraphPublicWidgetOptions, LockedFigure, PerseusImageBackground, MarkingsType, PerseusInteractiveGraphUserInput, AxisLabelLocation, ShowAxisArrows, ShowAxisTicks } from "@khanacademy/perseus-core";
8
- type InteractiveGraphProps = {
9
- /**
10
- * Where the little black axis lines & labels (ticks) should render.
11
- * Also known as the tick step. default [1, 1]
12
- *
13
- * NOTE(kevinb): perseus_data.go defines this as Array<number>
14
- */
15
- step: [number, number];
16
- /**
17
- * Where the grid lines on the graph will render. default [1, 1]
18
- *
19
- * NOTE(kevinb): perseus_data.go defines this as Array<number>
20
- */
21
- gridStep?: [x: number, y: number];
22
- /**
23
- * Where the graph points will lock to when they are dragged. default [0.5, 0.5]
24
- *
25
- * NOTE(kevinb): perseus_data.go defines this as Array<number>
26
- */
27
- snapStep?: [x: number, y: number];
28
- /**
29
- * An optional image to use in the background
30
- */
31
- backgroundImage?: PerseusImageBackground;
32
- /**
33
- * The type of markings to display on the graph.
34
- * - axes: shows the axes without the gride lines
35
- * - graph: shows the axes and the grid lines
36
- * - grid: shows only the grid lines
37
- * - none: shows no markings
38
- */
39
- markings: MarkingsType;
40
- /**
41
- * How to label the X and Y axis. default: ["x", "y"]
42
- */
43
- labels: string[];
44
- /**
45
- * Where to put the axis labels on the graph. default: "onAxis"
46
- */
47
- labelLocation: AxisLabelLocation;
48
- /**
49
- * Whether to show the Protractor tool overlaid on top of the graph
50
- */
51
- showProtractor: boolean;
52
- /**
53
- * Whether to show the Ruler tool overlaid on top of the graph.
54
- * @deprecated - no longer used by the InteractiveGraph widget. The
55
- * property is kept on this type to prevent its accidental reuse in future
56
- * features, since it may appear in production data.
57
- */
58
- showRuler?: boolean;
59
- /**
60
- * Whether to show tooltips on the graph
61
- */
62
- showTooltips?: boolean;
63
- /**
64
- * The unit to show on the ruler. e.g. "mm", "cm", "m", "km", "in", "ft",
65
- * "yd", "mi".
66
- * @deprecated - no longer used by the InteractiveGraph widget. The
67
- * property is kept on this type to prevent its accidental reuse in future
68
- * features, since it may appear in production data.
69
- */
70
- rulerLabel?: string;
71
- /**
72
- * How many ticks to show on the ruler. e.g. 1, 2, 4, 8, 10, 16. Must be
73
- * an integer.
74
- * @deprecated - no longer used by the InteractiveGraph widget. The
75
- * property is kept on this type to prevent its accidental reuse in future
76
- * features, since it may appear in production data.
77
- */
78
- rulerTicks?: number;
79
- /**
80
- * The X and Y coordinate ranges for the view of the graph. default: [[-10, 10], [-10, 10]]
81
- *
82
- * NOTE(kevinb): perseus_data.go defines this as Array<Array<number>>
83
- */
84
- range: GraphRange;
85
- /**
86
- * Whether to show the arrows on the axis.
87
- */
88
- showAxisArrows: ShowAxisArrows;
89
- /**
90
- * Whether to show tick marks and tick numbers per axis.
91
- */
92
- showAxisTicks: ShowAxisTicks;
93
- /**
94
- * The type of graph
95
- */
96
- graph: PerseusGraphType;
97
- /**
98
- * The correct answer for this widget.
99
- */
100
- correct?: PerseusGraphType;
101
- /**
102
- * Shapes (points, chords, etc) displayed on the graph that cannot be moved
103
- * by the user.
104
- */
105
- lockedFigures: LockedFigure[];
106
- /**
107
- * Aria label that applies to the entire graph.
108
- */
109
- fullGraphAriaLabel?: string;
110
- /**
111
- * Aria description that applies to the entire graph.
112
- */
113
- fullGraphAriaDescription?: string;
114
- };
115
- export type Props = WidgetProps<InteractiveGraphProps, PerseusInteractiveGraphUserInput>;
116
- type DefaultProps = {
117
- labels: string[];
118
- labelLocation: Props["labelLocation"];
119
- range: Props["range"];
120
- showAxisArrows: Props["showAxisArrows"];
121
- showAxisTicks: Props["showAxisTicks"];
122
- step: Props["step"];
123
- backgroundImage: Props["backgroundImage"];
124
- markings: Props["markings"];
125
- showTooltips: Props["showTooltips"];
126
- showProtractor: Props["showProtractor"];
127
- userInput: Props["userInput"];
128
- };
129
- type State = any;
130
- declare class InteractiveGraph extends React.Component<Props, State> {
7
+ import type { PerseusGraphType, PerseusInteractiveGraphWidgetOptions, InteractiveGraphPublicWidgetOptions, PerseusInteractiveGraphUserInput } from "@khanacademy/perseus-core";
8
+ export type Props = WidgetProps<PerseusInteractiveGraphWidgetOptions, PerseusInteractiveGraphUserInput>;
9
+ declare class InteractiveGraph extends React.Component<Props> {
131
10
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
132
11
  context: React.ContextType<typeof PerseusI18nContext>;
133
12
  mafsRef: React.RefObject<StatefulMafsGraphType>;
134
- static defaultProps: DefaultProps;
135
13
  static getEquationString(props: Props): string;
136
14
  getUserInput(): PerseusInteractiveGraphUserInput;
137
15
  getPromptJSON(): InteractiveGraphPromptJSON | UnsupportedWidgetPromptJSON;
@@ -144,20 +22,20 @@ declare class InteractiveGraph extends React.Component<Props, State> {
144
22
  step: [number, number];
145
23
  gridStep?: [x: number, y: number];
146
24
  snapStep?: [x: number, y: number];
147
- backgroundImage?: PerseusImageBackground;
148
- markings: MarkingsType;
25
+ backgroundImage: import("@khanacademy/perseus-core").PerseusImageBackground;
26
+ markings: import("@khanacademy/perseus-core").MarkingsType;
149
27
  labels: string[];
150
- labelLocation: AxisLabelLocation;
28
+ labelLocation: import("@khanacademy/perseus-core").AxisLabelLocation;
29
+ showAxisArrows: import("@khanacademy/perseus-core").ShowAxisArrows;
30
+ showAxisTicks: import("@khanacademy/perseus-core").ShowAxisTicks;
151
31
  showProtractor: boolean;
152
32
  showRuler?: boolean;
153
- showTooltips?: boolean;
33
+ showTooltips: boolean;
154
34
  rulerLabel?: string;
155
35
  rulerTicks?: number;
156
- range: GraphRange;
157
- showAxisArrows: ShowAxisArrows;
158
- showAxisTicks: ShowAxisTicks;
159
- correct?: PerseusGraphType;
160
- lockedFigures: LockedFigure[];
36
+ range: import("@khanacademy/perseus-core").GraphRange;
37
+ correct: PerseusGraphType;
38
+ lockedFigures: import("@khanacademy/perseus-core").LockedFigure[];
161
39
  fullGraphAriaLabel?: string;
162
40
  fullGraphAriaDescription?: string;
163
41
  trackInteraction: (extraData?: Empty | undefined) => void;
@@ -1,3 +1,19 @@
1
1
  import type { StrokeWeight } from "@khanacademy/perseus-core";
2
+ import type * as React from "react";
2
3
  export declare const strokeWeights: Record<StrokeWeight, number>;
4
+ /**
5
+ * A dashed locked figure's `stroke-dasharray`, scaled to the stroke width so the
6
+ * dashes stay visible at every weight. mafs hardcodes `4, 3` regardless of
7
+ * width, making thick lines read as nearly solid; this restores legacy graphie's
8
+ * width-proportional pattern (Raphael's `[4, 3]` × width). Thin yields `4, 3`,
9
+ * unchanged.
10
+ */
11
+ export declare function getDashArrayForWeight(weight: StrokeWeight): string;
12
+ /**
13
+ * Inline `<g>` style that sets `--mafs-line-stroke-dash-style` to the
14
+ * weight-scaled dash pattern; mafs reads that variable for every dashed
15
+ * primitive (Line, Vector, Polygon, Ellipse, Plot) below. `undefined` for solid
16
+ * figures, so no inline style is emitted.
17
+ */
18
+ export declare function dashedStrokeStyle(isDashed: boolean, weight: StrokeWeight): React.CSSProperties | undefined;
3
19
  export declare function clampDomain(domain: [number | null, number | null], graphBounds: [number, number]): [number, number] | null;
@@ -0,0 +1,27 @@
1
+ import type { InteractiveGraphAction } from "../reducer/interactive-graph-action";
2
+ import type { InteractiveGraphState } from "../types";
3
+ import type { LockedFigure } from "@khanacademy/perseus-core";
4
+ import type * as React from "react";
5
+ /**
6
+ * A contiguous run of locked figures sharing the same clipping treatment.
7
+ * Points render unclipped (a boundary point would otherwise be sliced in half
8
+ * by the clip); every other figure is clipped to the graph's visible range.
9
+ */
10
+ export interface LockedFigureClipRun {
11
+ clipped: boolean;
12
+ figures: LockedFigure[];
13
+ }
14
+ /**
15
+ * Group locked figures into contiguous runs by clipping treatment, preserving
16
+ * author order. Rendering all points in one pass would push them after every
17
+ * other figure, so the DOM (and screen-reader) order would no longer match the
18
+ * authored order; grouping into ordered runs keeps them interleaved as authored.
19
+ *
20
+ * Label figures are skipped: they render in GraphLockedLabelsLayer, not this
21
+ * layer, so including them would emit empty clip wrappers and split point runs.
22
+ */
23
+ export declare function getLockedFigureClipRuns(lockedFigures: ReadonlyArray<LockedFigure>): ReadonlyArray<LockedFigureClipRun>;
24
+ export declare function handleFocusEvent(event: React.FocusEvent, state: InteractiveGraphState, dispatch: (action: InteractiveGraphAction) => unknown): void;
25
+ export declare function handleBlurEvent(_event: React.FocusEvent, state: InteractiveGraphState, dispatch: (action: InteractiveGraphAction) => unknown): void;
26
+ export declare function handleKeyboardEvent(event: React.KeyboardEvent, state: InteractiveGraphState, dispatch: (action: InteractiveGraphAction) => unknown): void;
27
+ export declare function describedByIds(...args: Array<string | false | 0 | null | undefined>): string | undefined;
@@ -5,9 +5,6 @@ import type { MockWidgetPromptJSON } from "../../widget-ai-utils/mock-widget/pro
5
5
  import type { PerseusMockWidgetUserInput } from "@khanacademy/perseus-score";
6
6
  type ExternalProps = WidgetProps<MockWidgetOptions, PerseusMockWidgetUserInput>;
7
7
  type Props = ExternalProps;
8
- type DefaultProps = {
9
- userInput: Props["userInput"];
10
- };
11
8
  /**
12
9
  * This is a Mock Perseus widget, which is used for our various rendering tests
13
10
  * both internally and in consuming projects. It is a simple widget that renders
@@ -21,7 +18,6 @@ type DefaultProps = {
21
18
  * You can register this widget for your tests by calling `registerWidget("mock-widget", MockWidget);`
22
19
  */
23
20
  declare class MockWidgetComponent extends React.Component<Props> implements Widget {
24
- static defaultProps: DefaultProps;
25
21
  inputRef: HTMLElement | null;
26
22
  getPromptJSON(): MockWidgetPromptJSON;
27
23
  focus: () => boolean;
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": "83.0.0",
6
+ "version": "83.0.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -43,40 +43,40 @@
43
43
  "mafs": "0.19.0",
44
44
  "tiny-invariant": "1.3.1",
45
45
  "uuid": "^10.0.0",
46
- "@khanacademy/kas": "2.2.5",
47
- "@khanacademy/keypad-context": "3.2.79",
48
- "@khanacademy/kmath": "2.4.38",
49
- "@khanacademy/math-input": "26.6.8",
50
- "@khanacademy/perseus-core": "34.0.1",
51
- "@khanacademy/perseus-linter": "5.1.19",
52
- "@khanacademy/perseus-score": "8.12.11",
46
+ "@khanacademy/kas": "2.2.6",
47
+ "@khanacademy/keypad-context": "3.2.80",
48
+ "@khanacademy/kmath": "2.4.39",
49
+ "@khanacademy/math-input": "27.0.0",
50
+ "@khanacademy/perseus-core": "34.0.2",
51
+ "@khanacademy/perseus-linter": "5.1.20",
52
+ "@khanacademy/perseus-score": "8.12.12",
53
53
  "@khanacademy/perseus-utils": "2.1.5",
54
- "@khanacademy/pure-markdown": "2.3.1",
55
- "@khanacademy/simple-markdown": "3.0.0"
54
+ "@khanacademy/pure-markdown": "2.3.2",
55
+ "@khanacademy/simple-markdown": "3.0.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@khanacademy/wonder-blocks-announcer": "1.1.1",
59
- "@khanacademy/wonder-blocks-banner": "5.1.10",
60
- "@khanacademy/wonder-blocks-button": "11.7.6",
61
- "@khanacademy/wonder-blocks-clickable": "8.2.8",
59
+ "@khanacademy/wonder-blocks-banner": "5.1.11",
60
+ "@khanacademy/wonder-blocks-button": "11.7.7",
61
+ "@khanacademy/wonder-blocks-clickable": "8.2.9",
62
62
  "@khanacademy/wonder-blocks-core": "12.4.4",
63
63
  "@khanacademy/wonder-blocks-data": "15.0.3",
64
- "@khanacademy/wonder-blocks-dropdown": "10.11.7",
65
- "@khanacademy/wonder-blocks-form": "7.6.9",
66
- "@khanacademy/wonder-blocks-icon": "5.3.22",
67
- "@khanacademy/wonder-blocks-icon-button": "11.4.4",
68
- "@khanacademy/wonder-blocks-labeled-field": "4.1.8",
69
- "@khanacademy/wonder-blocks-layout": "3.1.59",
70
- "@khanacademy/wonder-blocks-link": "10.3.8",
71
- "@khanacademy/wonder-blocks-modal": "8.7.10",
72
- "@khanacademy/wonder-blocks-pill": "3.1.72",
73
- "@khanacademy/wonder-blocks-popover": "6.3.11",
74
- "@khanacademy/wonder-blocks-progress-spinner": "3.1.59",
75
- "@khanacademy/wonder-blocks-switch": "3.4.8",
64
+ "@khanacademy/wonder-blocks-dropdown": "10.11.8",
65
+ "@khanacademy/wonder-blocks-form": "7.6.10",
66
+ "@khanacademy/wonder-blocks-icon": "5.3.23",
67
+ "@khanacademy/wonder-blocks-icon-button": "11.4.5",
68
+ "@khanacademy/wonder-blocks-labeled-field": "4.1.9",
69
+ "@khanacademy/wonder-blocks-layout": "3.1.60",
70
+ "@khanacademy/wonder-blocks-link": "10.3.9",
71
+ "@khanacademy/wonder-blocks-modal": "8.7.11",
72
+ "@khanacademy/wonder-blocks-pill": "3.1.73",
73
+ "@khanacademy/wonder-blocks-popover": "6.3.12",
74
+ "@khanacademy/wonder-blocks-progress-spinner": "3.1.60",
75
+ "@khanacademy/wonder-blocks-switch": "3.4.9",
76
76
  "@khanacademy/wonder-blocks-timing": "7.1.0",
77
- "@khanacademy/wonder-blocks-tokens": "17.2.0",
78
- "@khanacademy/wonder-blocks-tooltip": "4.2.0",
79
- "@khanacademy/wonder-blocks-typography": "5.0.2",
77
+ "@khanacademy/wonder-blocks-tokens": "17.3.0",
78
+ "@khanacademy/wonder-blocks-tooltip": "4.2.1",
79
+ "@khanacademy/wonder-blocks-typography": "5.0.3",
80
80
  "@khanacademy/wonder-stuff-core": "3.0.0",
81
81
  "@phosphor-icons/core": "2.0.2",
82
82
  "@popperjs/core": "2.10.2",
@@ -88,32 +88,32 @@
88
88
  "react-dom": "18.2.0",
89
89
  "react-popper": "^2.2.5",
90
90
  "underscore": "1.4.4",
91
- "perseus-build-settings": "0.9.0",
91
+ "perseus-build-settings": "0.9.1",
92
92
  "raphael": "1.5.4"
93
93
  },
94
94
  "peerDependencies": {
95
95
  "@khanacademy/wonder-blocks-announcer": "^1.1.1",
96
- "@khanacademy/wonder-blocks-banner": "^5.1.10",
97
- "@khanacademy/wonder-blocks-button": "^11.7.6",
98
- "@khanacademy/wonder-blocks-clickable": "^8.2.8",
96
+ "@khanacademy/wonder-blocks-banner": "^5.1.11",
97
+ "@khanacademy/wonder-blocks-button": "^11.7.7",
98
+ "@khanacademy/wonder-blocks-clickable": "^8.2.9",
99
99
  "@khanacademy/wonder-blocks-core": "^12.4.4",
100
100
  "@khanacademy/wonder-blocks-data": "^15.0.3",
101
- "@khanacademy/wonder-blocks-dropdown": "^10.11.7",
102
- "@khanacademy/wonder-blocks-form": "^7.6.9",
103
- "@khanacademy/wonder-blocks-icon": "^5.3.22",
104
- "@khanacademy/wonder-blocks-icon-button": "^11.4.4",
105
- "@khanacademy/wonder-blocks-labeled-field": "^4.1.8",
106
- "@khanacademy/wonder-blocks-layout": "^3.1.59",
107
- "@khanacademy/wonder-blocks-link": "^10.3.8",
108
- "@khanacademy/wonder-blocks-modal": "^8.7.10",
109
- "@khanacademy/wonder-blocks-pill": "^3.1.72",
110
- "@khanacademy/wonder-blocks-popover": "^6.3.11",
111
- "@khanacademy/wonder-blocks-progress-spinner": "^3.1.59",
112
- "@khanacademy/wonder-blocks-switch": "^3.4.8",
101
+ "@khanacademy/wonder-blocks-dropdown": "^10.11.8",
102
+ "@khanacademy/wonder-blocks-form": "^7.6.10",
103
+ "@khanacademy/wonder-blocks-icon": "^5.3.23",
104
+ "@khanacademy/wonder-blocks-icon-button": "^11.4.5",
105
+ "@khanacademy/wonder-blocks-labeled-field": "^4.1.9",
106
+ "@khanacademy/wonder-blocks-layout": "^3.1.60",
107
+ "@khanacademy/wonder-blocks-link": "^10.3.9",
108
+ "@khanacademy/wonder-blocks-modal": "^8.7.11",
109
+ "@khanacademy/wonder-blocks-pill": "^3.1.73",
110
+ "@khanacademy/wonder-blocks-popover": "^6.3.12",
111
+ "@khanacademy/wonder-blocks-progress-spinner": "^3.1.60",
112
+ "@khanacademy/wonder-blocks-switch": "^3.4.9",
113
113
  "@khanacademy/wonder-blocks-timing": "^7.1.0",
114
- "@khanacademy/wonder-blocks-tokens": "^17.2.0",
115
- "@khanacademy/wonder-blocks-tooltip": "^4.2.0",
116
- "@khanacademy/wonder-blocks-typography": "^5.0.2",
114
+ "@khanacademy/wonder-blocks-tokens": "^17.3.0",
115
+ "@khanacademy/wonder-blocks-tooltip": "^4.2.1",
116
+ "@khanacademy/wonder-blocks-typography": "^5.0.3",
117
117
  "@khanacademy/wonder-stuff-core": "^3.0.0",
118
118
  "@phosphor-icons/core": "^2.0.2",
119
119
  "@popperjs/core": "^2.10.2",
@@ -128,7 +128,7 @@
128
128
  },
129
129
  "keywords": [],
130
130
  "khan": {
131
- "catalogHash": "3f4a3330f0a56ab9"
131
+ "catalogHash": "bcf5b2d4681b77c1"
132
132
  },
133
133
  "scripts": {}
134
134
  }