@khanacademy/perseus 21.2.2 → 21.3.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.
@@ -95,7 +95,15 @@ export declare const ApiOptions: {
95
95
  inModal?: boolean | undefined;
96
96
  crossOutEnabled?: boolean | undefined;
97
97
  editorChangeDelay?: number | undefined;
98
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
98
+ flags?: {
99
+ mafs?: false | {
100
+ polygon?: boolean | undefined;
101
+ linear?: boolean | undefined;
102
+ segment?: boolean | undefined;
103
+ "linear-system"?: boolean | undefined;
104
+ ray?: boolean | undefined;
105
+ } | undefined;
106
+ } | undefined;
99
107
  onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
100
108
  }> & {
101
109
  GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
@@ -431,12 +431,6 @@ export type PerseusLabelImageMarker = {
431
431
  x: number;
432
432
  y: number;
433
433
  };
434
- export type PerseusLightsPuzzleWidgetOptions = {
435
- cells?: ReadonlyArray<ReadonlyArray<boolean>>;
436
- startCells?: ReadonlyArray<ReadonlyArray<boolean>>;
437
- flipPattern?: string;
438
- moveCount?: number;
439
- };
440
434
  export type PerseusMatcherWidgetOptions = {
441
435
  labels: ReadonlyArray<string>;
442
436
  left: ReadonlyArray<string>;
@@ -788,21 +782,6 @@ export type PerseusMoleculeRendererWidgetOptions = {
788
782
  export type PerseusPassageRefTargetWidgetOptions = {
789
783
  content: string;
790
784
  };
791
- export type PerseusReactionDiagramWidgetOptions = {
792
- rotationAngle: ReadonlyArray<number>;
793
- widgetId: string;
794
- separators: ReadonlyArray<PerseusReactionDiagramSeparators>;
795
- smiles: ReadonlyArray<string>;
796
- };
797
- export type PerseusReactionDiagramSeparators = {
798
- type: string;
799
- topText: string;
800
- bottomText: string;
801
- };
802
- export type PerseusReactionDiagramSeparatorsData = {
803
- topText: string;
804
- bottomText: string;
805
- };
806
785
  export type PerseusSimpleMarkdownTesterWidgetOptions = {
807
786
  value: string;
808
787
  };
@@ -137,7 +137,15 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
137
137
  inModal?: boolean | undefined;
138
138
  crossOutEnabled?: boolean | undefined;
139
139
  editorChangeDelay?: number | undefined;
140
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
140
+ flags?: {
141
+ mafs?: false | {
142
+ polygon?: boolean | undefined;
143
+ linear?: boolean | undefined;
144
+ segment?: boolean | undefined;
145
+ "linear-system"?: boolean | undefined;
146
+ ray?: boolean | undefined;
147
+ } | undefined;
148
+ } | undefined;
141
149
  onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
142
150
  }> | undefined;
143
151
  linterContext?: PerseusLinter.LinterContextProps | undefined;
package/dist/strings.js CHANGED
@@ -46,7 +46,6 @@ module.exports = [
46
46
  i18n._("Choose all answers that apply:", {}),
47
47
  i18n._("Click each dot on the image to select all answers that apply.", {}),
48
48
  i18n._("Click each dot on the image to select an answer.", {}),
49
- i18n._("Click on the tiles to change the lights.", {}),
50
49
  i18n._("Click to add points", {}),
51
50
  i18n._("Click to add vertices", {}),
52
51
  i18n._("close math keypad", {}),
@@ -86,7 +85,6 @@ module.exports = [
86
85
  i18n._("Make circle open", {}),
87
86
  i18n._("Make sure you fill in all cells in the matrix.", {}),
88
87
  i18n._("Make sure you select something for every row.", {}),
89
- i18n.ngettext("Moves: %(num)s","Moves: %(num)s", {}),
90
88
  i18n._("Next question", {}),
91
89
  i18n._("No", {}),
92
90
  i18n._("None of the above", {}),
@@ -95,7 +93,6 @@ module.exports = [
95
93
  i18n._("open math keypad", {}),
96
94
  i18n._("Please choose the correct number of answers.", {}),
97
95
  i18n.$_("Please make sure the number of divisions is in the range %(divRangeString)s.", {}),
98
- i18n._("Reaction arrow pointing to the right.", {}),
99
96
  i18n._("Remove highlight", {}),
100
97
  i18n._("See video transcript", {}),
101
98
  i18n._("Skip to %(title)s", {}),
@@ -113,7 +110,6 @@ module.exports = [
113
110
  i18n._("We could not understand your answer. Please check your answer for extra text or symbols.", {}),
114
111
  i18n._("We couldn't grade your answer.", {}),
115
112
  i18n._("Yes", {}),
116
- i18n._("You must turn on all of the lights to continue.", {}),
117
113
  i18n._("Your answer includes a wrong variable letter.", {}),
118
114
  i18n._("Your answer includes use of a variable with the wrong case.", {}),
119
115
  i18n._("Your answer is almost correct, but it is missing a <code>\\%</code> at the end.", {}),
package/dist/types.d.ts CHANGED
@@ -77,6 +77,7 @@ type TrackInteractionArgs = {
77
77
  id: string;
78
78
  correct?: boolean;
79
79
  } & Partial<TrackingGradedGroupExtraArguments> & Partial<TrackingSequenceExtraArguments>;
80
+ export declare const MafsFlags: readonly ["segment", "linear", "linear-system", "ray", "polygon"];
80
81
  /**
81
82
  * APIOptions provides different ways to customize the behaviour of Perseus.
82
83
  *
@@ -198,7 +199,16 @@ export type APIOptions = Readonly<{
198
199
  */
199
200
  editorChangeDelay?: number;
200
201
  /** Feature flags that can be passed from consuming application. */
201
- flags?: Record<string, boolean | Record<string, boolean>>;
202
+ flags?: {
203
+ /**
204
+ * Flags related to the interactive-graph Mafs migration.
205
+ *
206
+ * Add values to the `MafsFlags` array to create new flags.
207
+ */
208
+ mafs?: false | {
209
+ [Key in (typeof MafsFlags)[number]]?: boolean;
210
+ };
211
+ };
202
212
  /**
203
213
  * This is a callback function that returns all of the Widget props
204
214
  * after they have been transformed by the widget's transform function.
@@ -123,7 +123,15 @@ declare const _default: Readonly<{
123
123
  inModal?: boolean | undefined;
124
124
  crossOutEnabled?: boolean | undefined;
125
125
  editorChangeDelay?: number | undefined;
126
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
126
+ flags?: {
127
+ mafs?: false | {
128
+ polygon?: boolean | undefined;
129
+ linear?: boolean | undefined;
130
+ segment?: boolean | undefined;
131
+ "linear-system"?: boolean | undefined;
132
+ ray?: boolean | undefined;
133
+ } | undefined;
134
+ } | undefined;
127
135
  onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
128
136
  }> & {
129
137
  GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
@@ -190,7 +198,15 @@ declare const _default: Readonly<{
190
198
  inModal?: boolean | undefined;
191
199
  crossOutEnabled?: boolean | undefined;
192
200
  editorChangeDelay?: number | undefined;
193
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
201
+ flags?: {
202
+ mafs?: false | {
203
+ polygon?: boolean | undefined;
204
+ linear?: boolean | undefined;
205
+ segment?: boolean | undefined;
206
+ "linear-system"?: boolean | undefined;
207
+ ray?: boolean | undefined;
208
+ } | undefined;
209
+ } | undefined;
194
210
  onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
195
211
  }> & {
196
212
  GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
@@ -257,7 +273,15 @@ declare const _default: Readonly<{
257
273
  inModal?: boolean | undefined;
258
274
  crossOutEnabled?: boolean | undefined;
259
275
  editorChangeDelay?: number | undefined;
260
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
276
+ flags?: {
277
+ mafs?: false | {
278
+ polygon?: boolean | undefined;
279
+ linear?: boolean | undefined;
280
+ segment?: boolean | undefined;
281
+ "linear-system"?: boolean | undefined;
282
+ ray?: boolean | undefined;
283
+ } | undefined;
284
+ } | undefined;
261
285
  onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
262
286
  }> & {
263
287
  GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
@@ -321,7 +345,15 @@ declare const _default: Readonly<{
321
345
  inModal?: boolean | undefined;
322
346
  crossOutEnabled?: boolean | undefined;
323
347
  editorChangeDelay?: number | undefined;
324
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
348
+ flags?: {
349
+ mafs?: false | {
350
+ polygon?: boolean | undefined;
351
+ linear?: boolean | undefined;
352
+ segment?: boolean | undefined;
353
+ "linear-system"?: boolean | undefined;
354
+ ray?: boolean | undefined;
355
+ } | undefined;
356
+ } | undefined;
325
357
  onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
326
358
  }> & {
327
359
  GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
@@ -388,7 +420,15 @@ declare const _default: Readonly<{
388
420
  inModal?: boolean | undefined;
389
421
  crossOutEnabled?: boolean | undefined;
390
422
  editorChangeDelay?: number | undefined;
391
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
423
+ flags?: {
424
+ mafs?: false | {
425
+ polygon?: boolean | undefined;
426
+ linear?: boolean | undefined;
427
+ segment?: boolean | undefined;
428
+ "linear-system"?: boolean | undefined;
429
+ ray?: boolean | undefined;
430
+ } | undefined;
431
+ } | undefined;
392
432
  onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
393
433
  }> & {
394
434
  GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
@@ -455,7 +495,15 @@ declare const _default: Readonly<{
455
495
  inModal?: boolean | undefined;
456
496
  crossOutEnabled?: boolean | undefined;
457
497
  editorChangeDelay?: number | undefined;
458
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
498
+ flags?: {
499
+ mafs?: false | {
500
+ polygon?: boolean | undefined;
501
+ linear?: boolean | undefined;
502
+ segment?: boolean | undefined;
503
+ "linear-system"?: boolean | undefined;
504
+ ray?: boolean | undefined;
505
+ } | undefined;
506
+ } | undefined;
459
507
  onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
460
508
  }> & {
461
509
  GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
@@ -1 +1 @@
1
- export { MafsGraph } from "./mafs-graph";
1
+ export { StatefulMafsGraph } from "./mafs-graph";
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
- import type { InteractiveGraphProps } from "./types";
2
+ import { type InteractiveGraphAction } from "./reducer/interactive-graph-action";
3
+ import type { InteractiveGraphState, InteractiveGraphProps } from "./types";
3
4
  import type { Widget } from "../../renderer";
4
5
  import "mafs/core.css";
5
6
  import "./mafs-styles.css";
@@ -16,6 +17,10 @@ export type Props = {
16
17
  markings: InteractiveGraphProps["markings"];
17
18
  onChange: InteractiveGraphProps["onChange"];
18
19
  };
19
- export declare const MafsGraph: React.ForwardRefExoticComponent<Props & {
20
- children?: React.ReactNode;
21
- } & React.RefAttributes<Partial<Widget>>>;
20
+ export declare const StatefulMafsGraph: React.ForwardRefExoticComponent<Props & React.RefAttributes<Partial<Widget>>>;
21
+ type MafsGraphProps = Props & {
22
+ state: InteractiveGraphState;
23
+ dispatch: React.Dispatch<InteractiveGraphAction>;
24
+ };
25
+ export declare const MafsGraph: (props: MafsGraphProps) => JSX.Element;
26
+ export {};
@@ -122,7 +122,15 @@ declare const _default: Readonly<{
122
122
  inModal?: boolean | undefined;
123
123
  crossOutEnabled?: boolean | undefined;
124
124
  editorChangeDelay?: number | undefined;
125
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
125
+ flags?: {
126
+ mafs?: false | {
127
+ polygon?: boolean | undefined;
128
+ linear?: boolean | undefined;
129
+ segment?: boolean | undefined;
130
+ "linear-system"?: boolean | undefined;
131
+ ray?: boolean | undefined;
132
+ } | undefined;
133
+ } | undefined;
126
134
  onWidgetStartProps?: ((widgets: import("..").PerseusWidgetsMap) => void) | undefined;
127
135
  }>;
128
136
  choices: readonly string[];
@@ -171,7 +179,15 @@ declare const _default: Readonly<{
171
179
  inModal?: boolean | undefined;
172
180
  crossOutEnabled?: boolean | undefined;
173
181
  editorChangeDelay?: number | undefined;
174
- flags?: Record<string, boolean | Record<string, boolean>> | undefined;
182
+ flags?: {
183
+ mafs?: false | {
184
+ polygon?: boolean | undefined;
185
+ linear?: boolean | undefined;
186
+ segment?: boolean | undefined;
187
+ "linear-system"?: boolean | undefined;
188
+ ray?: boolean | undefined;
189
+ } | undefined;
190
+ } | undefined;
175
191
  onWidgetStartProps?: ((widgets: import("..").PerseusWidgetsMap) => void) | undefined;
176
192
  }>;
177
193
  choices: readonly string[];
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": "21.2.2",
6
+ "version": "21.3.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -1,53 +0,0 @@
1
- import * as React from "react";
2
- import * as Changeable from "../mixins/changeable";
3
- import type { PerseusLightsPuzzleWidgetOptions } from "../perseus-types";
4
- type LightsPuzzleProps = Changeable.ChangeableProps & {
5
- cells: PerseusLightsPuzzleWidgetOptions["cells"];
6
- startCells: PerseusLightsPuzzleWidgetOptions["startCells"];
7
- flipPattern: PerseusLightsPuzzleWidgetOptions["flipPattern"];
8
- moveCount: PerseusLightsPuzzleWidgetOptions["moveCount"];
9
- };
10
- type DefaultProps = {
11
- cells: LightsPuzzleProps["cells"];
12
- startCells: LightsPuzzleProps["startCells"];
13
- flipPattern: LightsPuzzleProps["flipPattern"];
14
- moveCount: LightsPuzzleProps["moveCount"];
15
- };
16
- declare class LightsPuzzle extends React.Component<LightsPuzzleProps> {
17
- _currPattern: any;
18
- _nextPattern: any;
19
- _patternIndex: number;
20
- static defaultProps: DefaultProps;
21
- getUserInput: () => any;
22
- render(): React.ReactNode;
23
- change: (...args: ReadonlyArray<unknown>) => any;
24
- _width: () => number;
25
- componentDidMount(): void;
26
- componentDidUpdate(prevProps: any): void;
27
- _initNextPatterns: () => void;
28
- _shiftPatterns: () => void;
29
- _flipTile: (FlipCoords: any) => void;
30
- _reset: () => void;
31
- simpleValidate: (arg1: any) => any;
32
- }
33
- declare const _default: Readonly<{
34
- name: string;
35
- displayName: string;
36
- getWidget?: (() => typeof LightsPuzzle) | undefined;
37
- widget: typeof LightsPuzzle;
38
- accessible?: boolean | ((props: any) => boolean) | undefined;
39
- hidden?: boolean | undefined;
40
- version?: import("../types").Version | undefined;
41
- supportedAlignments?: readonly import("../types").Alignment[] | undefined;
42
- defaultAlignment?: import("../types").Alignment | undefined;
43
- getDefaultAlignment?: (() => import("../types").Alignment) | undefined;
44
- isLintable?: boolean | undefined;
45
- tracking?: import("../types").Tracking | undefined;
46
- traverseChildWidgets?: any;
47
- transform?: import("../types").WidgetTransform | undefined;
48
- staticTransform?: import("../types").WidgetTransform | undefined;
49
- propUpgrades?: {
50
- [key: string]: (arg1: any) => any;
51
- } | undefined;
52
- }>;
53
- export default _default;
@@ -1,42 +0,0 @@
1
- import * as React from "react";
2
- import type { PerseusReactionDiagramWidgetOptions } from "../perseus-types";
3
- type ReactionDiagramProps = {
4
- rotationAngle: PerseusReactionDiagramWidgetOptions["rotationAngle"];
5
- separators: PerseusReactionDiagramWidgetOptions["separators"];
6
- smiles: PerseusReactionDiagramWidgetOptions["smiles"];
7
- widgetId: PerseusReactionDiagramWidgetOptions["widgetId"];
8
- };
9
- type DefaultProps = {
10
- rotationAngle: ReactionDiagramProps["rotationAngle"];
11
- separators: ReactionDiagramProps["separators"];
12
- smiles: ReactionDiagramProps["smiles"];
13
- };
14
- declare class ReactionDiagramWidget extends React.Component<ReactionDiagramProps> {
15
- static defaultProps: DefaultProps;
16
- simpleValidate: (arg1: any) => any;
17
- getUserInput: () => any;
18
- validate: (arg1: any, arg2: any) => any;
19
- focus: () => boolean;
20
- render(): React.ReactNode;
21
- }
22
- declare const _default: Readonly<{
23
- name: string;
24
- displayName: string;
25
- getWidget?: (() => typeof ReactionDiagramWidget) | undefined;
26
- widget: typeof ReactionDiagramWidget;
27
- accessible?: boolean | ((props: any) => boolean) | undefined;
28
- hidden?: boolean | undefined;
29
- version?: import("../types").Version | undefined;
30
- supportedAlignments?: readonly import("../types").Alignment[] | undefined;
31
- defaultAlignment?: import("../types").Alignment | undefined;
32
- getDefaultAlignment?: (() => import("../types").Alignment) | undefined;
33
- isLintable?: boolean | undefined;
34
- tracking?: import("../types").Tracking | undefined;
35
- traverseChildWidgets?: any;
36
- transform?: import("../types").WidgetTransform | undefined;
37
- staticTransform?: import("../types").WidgetTransform | undefined;
38
- propUpgrades?: {
39
- [key: string]: (arg1: any) => any;
40
- } | undefined;
41
- }>;
42
- export default _default;