@khanacademy/perseus 36.1.2 → 37.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 (53) hide show
  1. package/dist/all-widgets.d.ts +1 -0
  2. package/dist/basic-widgets.d.ts +1 -0
  3. package/dist/components/math-input.d.ts +1 -1
  4. package/dist/es/index.js +447 -612
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/extra-widgets.d.ts +1 -0
  7. package/dist/index.js +412 -588
  8. package/dist/index.js.map +1 -1
  9. package/dist/renderer-util.d.ts +8 -0
  10. package/dist/renderer.d.ts +19 -20
  11. package/dist/server-item-renderer.d.ts +3 -1
  12. package/dist/types.d.ts +11 -3
  13. package/dist/util.d.ts +4 -0
  14. package/dist/validation.types.d.ts +14 -6
  15. package/dist/widgets/categorizer/categorizer.d.ts +3 -5
  16. package/dist/widgets/cs-program/cs-program.d.ts +2 -3
  17. package/dist/widgets/definition/definition.d.ts +3 -4
  18. package/dist/widgets/deprecated-standin/deprecated-standin.d.ts +35 -0
  19. package/dist/widgets/deprecated-standin/index.d.ts +1 -37
  20. package/dist/widgets/dropdown/dropdown.d.ts +2 -3
  21. package/dist/widgets/explanation/explanation.d.ts +4 -5
  22. package/dist/widgets/expression/expression.d.ts +4 -8
  23. package/dist/widgets/graded-group/graded-group.d.ts +1 -0
  24. package/dist/widgets/graded-group-set/graded-group-set.d.ts +1 -0
  25. package/dist/widgets/grapher/grapher.d.ts +2 -3
  26. package/dist/widgets/group/group.d.ts +8 -5
  27. package/dist/widgets/iframe/iframe.d.ts +2 -3
  28. package/dist/widgets/image/image.d.ts +3 -4
  29. package/dist/widgets/input-number/input-number.d.ts +2 -5
  30. package/dist/widgets/interaction/interaction.d.ts +3 -4
  31. package/dist/widgets/interactive-graph.d.ts +2 -4
  32. package/dist/widgets/label-image/label-image.d.ts +3 -4
  33. package/dist/widgets/matcher/matcher.d.ts +2 -3
  34. package/dist/widgets/matrix/matrix.d.ts +3 -5
  35. package/dist/widgets/measurer/measurer.d.ts +2 -4
  36. package/dist/widgets/molecule/molecule.d.ts +2 -4
  37. package/dist/widgets/number-line/number-line.d.ts +3 -4
  38. package/dist/widgets/numeric-input/numeric-input.d.ts +2 -3
  39. package/dist/widgets/orderer/orderer.d.ts +2 -3
  40. package/dist/widgets/passage/passage.d.ts +3 -9
  41. package/dist/widgets/passage-ref/passage-ref.d.ts +3 -4
  42. package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +2 -4
  43. package/dist/widgets/phet-simulation/phet-simulation.d.ts +2 -2
  44. package/dist/widgets/plotter/plotter.d.ts +2 -3
  45. package/dist/widgets/python-program/python-program.d.ts +1 -0
  46. package/dist/widgets/radio/radio-component.d.ts +2 -5
  47. package/dist/widgets/radio/radio.d.ts +1 -0
  48. package/dist/widgets/sorter/sorter.d.ts +2 -3
  49. package/dist/widgets/table/table.d.ts +3 -5
  50. package/dist/widgets/video/video.d.ts +2 -8
  51. package/dist/widgets.d.ts +2 -1
  52. package/package.json +2 -2
  53. package/dist/widgets/expression/expression.types.d.ts +0 -2
@@ -0,0 +1,8 @@
1
+ import type { PerseusWidgetsMap } from "./perseus-types";
2
+ import type { PerseusStrings } from "./strings";
3
+ import type { PerseusScore } from "./types";
4
+ import type { UserInputMap } from "./validation.types";
5
+ export declare function emptyWidgetsFunctional(widgets: PerseusWidgetsMap, widgetIds: Array<string>, userInputMap: UserInputMap, strings: PerseusStrings, locale: string): ReadonlyArray<string>;
6
+ export declare function scoreWidgetsFunctional(widgets: PerseusWidgetsMap, widgetIds: Array<string>, userInputMap: UserInputMap, strings: PerseusStrings, locale: string): {
7
+ [widgetId: string]: PerseusScore;
8
+ };
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { PerseusI18nContext } from "./components/i18n-context";
2
3
  import InteractionTracker from "./interaction-tracker";
3
4
  import TranslationLinter from "./translation-linter";
4
5
  import WidgetContainer from "./widget-container";
@@ -6,7 +7,7 @@ import type { DependenciesContext } from "./dependencies";
6
7
  import type { PerseusRenderer, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions } from "./perseus-types";
7
8
  import type { PerseusStrings } from "./strings";
8
9
  import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, PerseusScore, SerializedState, Widget, WidgetProps } from "./types";
9
- import type { UserInput } from "./validation.types";
10
+ import type { UserInputArray, UserInputMap } from "./validation.types";
10
11
  import type { KeypadAPI } from "@khanacademy/math-input";
11
12
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
12
13
  import "./styles/perseus-renderer.less";
@@ -61,9 +62,7 @@ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
61
62
  };
62
63
  type State = {
63
64
  translationLintErrors: ReadonlyArray<string>;
64
- widgetInfo: Readonly<{
65
- [id: string]: PerseusWidget | null | undefined;
66
- }>;
65
+ widgetInfo: Readonly<PerseusWidgetsMap>;
67
66
  widgetProps: Readonly<{
68
67
  [id: string]: any | null | undefined;
69
68
  }>;
@@ -72,6 +71,11 @@ type State = {
72
71
  };
73
72
  type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExternalWidgets" | "highlightedWidgets" | "images" | "linterContext" | "onInteractWithWidget" | "onRender" | "onSerializedStateUpdated" | "questionCompleted" | "showSolutions" | "reviewMode" | "serializedState" | "widgets">>;
74
73
  declare class Renderer extends React.Component<Props, State> {
74
+ static contextType: React.Context<{
75
+ strings: PerseusStrings;
76
+ locale: string;
77
+ }>;
78
+ context: React.ContextType<typeof PerseusI18nContext>;
75
79
  _currentFocus: FocusPath | null | undefined;
76
80
  _foundTextNodes: boolean;
77
81
  _interactionTrackers: {
@@ -189,42 +193,37 @@ declare class Renderer extends React.Component<Props, State> {
189
193
  blurPath: (path: FocusPath) => void;
190
194
  blur: () => void;
191
195
  serialize: () => Record<any, any>;
192
- emptyWidgets: () => any;
196
+ emptyWidgets(): ReadonlyArray<string>;
193
197
  _setWidgetProps: SetWidgetPropsFn;
194
198
  setInputValue: (path: FocusPath, newValue: string, focus?: () => unknown) => void;
195
199
  /**
196
200
  * Returns an array of the widget `.getUserInput()` results
201
+ *
202
+ * TODO: can we remove this?
203
+ * @deprecated use getUserInputMap
204
+ */
205
+ getUserInput(): UserInputArray;
206
+ /**
207
+ * Returns an object of the widget `.getUserInput()` results
197
208
  */
198
- getUserInput: () => ReadonlyArray<UserInput | null | undefined>;
209
+ getUserInputMap(): UserInputMap;
199
210
  /**
200
211
  * Returns an array of all widget IDs in the order they occur in
201
212
  * the content.
202
213
  */
203
214
  getWidgetIds: () => ReadonlyArray<string>;
204
- /**
205
- * Returns the result of `.getUserInput()` for each widget, in
206
- * a map from widgetId to userInput.
207
- * NOTE(jeremy): This function is hauntingly similar to `getUserInput` with
208
- * the major difference being that this function returns a map of
209
- * `widgetID` => UserInput and `getUserInput` simply returns an array. It
210
- * would be trivial to map between the results of each of these functions,
211
- * so we should aim to remove one of these functions.
212
- */
213
- getUserInputForWidgets: () => {
214
- [widgetId: string]: UserInput | null | undefined;
215
- };
216
215
  /**
217
216
  * Returns an object mapping from widget ID to perseus-style score.
218
217
  * The keys of this object are the values of the array returned
219
218
  * from `getWidgetIds`.
220
219
  */
221
- scoreWidgets: () => {
220
+ scoreWidgets(): {
222
221
  [widgetId: string]: PerseusScore;
223
222
  };
224
223
  /**
225
224
  * Grades the content.
226
225
  */
227
- score: () => PerseusScore;
226
+ score(): PerseusScore;
228
227
  guessAndScore: () => [any, PerseusScore];
229
228
  examples: () => ReadonlyArray<string> | null | undefined;
230
229
  handletranslationLintErrors: (lintErrors: ReadonlyArray<string>) => void;
@@ -118,7 +118,9 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<SharedRendererProps
118
118
  id: string;
119
119
  correct?: boolean | undefined;
120
120
  } & Partial<import("./types").TrackingGradedGroupExtraArguments> & Partial<import("./types").TrackingSequenceExtraArguments>) => void) | undefined;
121
- customKeypad?: boolean | undefined;
121
+ customKeypad?: boolean | undefined; /**
122
+ * Get a representation of the current state of the item.
123
+ */
122
124
  nativeKeypadProxy?: ((blur: () => void) => KeypadAPI) | undefined;
123
125
  isMobile?: boolean | undefined;
124
126
  setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { Item } from "./multi-items/item-types";
3
3
  import type { Hint, PerseusAnswerArea, PerseusGraphType, PerseusWidget, PerseusWidgetsMap } from "./perseus-types";
4
4
  import type { PerseusStrings } from "./strings";
5
5
  import type { SizeClass } from "./util/sizing-utils";
6
- import type { UserInput } from "./validation.types";
6
+ import type { Rubric, UserInput, UserInputArray, UserInputMap } from "./validation.types";
7
7
  import type { KeypadAPI } from "@khanacademy/math-input";
8
8
  import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
9
9
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
@@ -33,6 +33,12 @@ export type SerializedState = Record<string, any>;
33
33
  * scoring, state serialization/deserialization, and focus management.
34
34
  */
35
35
  export interface Widget {
36
+ /**
37
+ * don't use isWidget; it's just a dummy property to help TypeScript's weak
38
+ * typing to recognize non-interactive widgets as Widgets
39
+ * @deprecated
40
+ */
41
+ isWidget?: true;
36
42
  focus?: () => {
37
43
  id: string;
38
44
  path: FocusPath;
@@ -46,8 +52,8 @@ export interface Widget {
46
52
  focusInputPath?: (path: FocusPath) => void;
47
53
  getInputPaths?: () => ReadonlyArray<FocusPath>;
48
54
  setInputValue?: (path: FocusPath, newValue: string, focus?: () => unknown) => void;
49
- getUserInput?: () => UserInput | null | undefined;
50
- simpleValidate?: (options?: any, onOutputError?: (widgetId: any, value: string, message?: string | null | undefined) => unknown | null | undefined) => PerseusScore;
55
+ getUserInputMap?: () => UserInputMap | undefined;
56
+ getUserInput?: () => UserInputArray | UserInput | undefined;
51
57
  showRationalesForCurrentlySelectedChoices?: (options?: any) => void;
52
58
  examples?: () => ReadonlyArray<string>;
53
59
  }
@@ -352,6 +358,7 @@ export type TrackingSequenceExtraArguments = {
352
358
  export type Alignment = "default" | "block" | "inline-block" | "inline" | "float-left" | "float-right" | "full-width";
353
359
  type WidgetOptions = any;
354
360
  export type WidgetTransform = (arg1: WidgetOptions, strings: PerseusStrings, problemNumber?: number) => any;
361
+ export type WidgetValidatorFunction = (userInput: UserInput, rubric: Rubric, string?: PerseusStrings, locale?: string) => PerseusScore;
355
362
  export type WidgetExports<T extends React.ComponentType<any> & Widget = React.ComponentType<any>> = Readonly<{
356
363
  name: string;
357
364
  displayName: string;
@@ -379,6 +386,7 @@ export type WidgetExports<T extends React.ComponentType<any> & Widget = React.Co
379
386
  /** transforms the widget options to the props used to render the widget for
380
387
  static renders */
381
388
  staticTransform?: WidgetTransform;
389
+ validator?: WidgetValidatorFunction;
382
390
  /**
383
391
  A map of major version numbers (as a string, eg "1") to a function that
384
392
  migrates from the _previous_ major version.
package/dist/util.d.ts CHANGED
@@ -47,6 +47,9 @@ declare function shuffle<T>(array: ReadonlyArray<T>, randomSeed: number | RNG, e
47
47
  * if one is wrong, the total score is wrong, etc.
48
48
  */
49
49
  declare function combineScores(scoreA: PerseusScore, scoreB: PerseusScore): PerseusScore;
50
+ declare function flattenScores(widgetScoreMap: {
51
+ [widgetId: string]: PerseusScore;
52
+ }): PerseusScore;
50
53
  export declare function isCorrect(score: PerseusScore): boolean;
51
54
  declare function keScoreFromPerseusScore(score: PerseusScore, guess: any, state: any): KEScore;
52
55
  /**
@@ -203,6 +206,7 @@ declare const Util: {
203
206
  readonly shuffle: typeof shuffle;
204
207
  readonly split: (str: string, r: RegExp) => ReadonlyArray<string>;
205
208
  readonly combineScores: typeof combineScores;
209
+ readonly flattenScores: typeof flattenScores;
206
210
  readonly keScoreFromPerseusScore: typeof keScoreFromPerseusScore;
207
211
  readonly firstNumericalParse: typeof firstNumericalParse;
208
212
  readonly stringArrayOfSize: typeof stringArrayOfSize;
@@ -1,10 +1,8 @@
1
1
  import type { Coord } from "./interactive2/types";
2
- import type { PerseusDefinitionWidgetOptions, PerseusDropdownWidgetOptions, PerseusExplanationWidgetOptions, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGrapherWidgetOptions, PerseusGraphType, PerseusIFrameWidgetOptions, PerseusImageWidgetOptions, PerseusInputNumberWidgetOptions, PerseusInteractionWidgetOptions, PerseusLabelImageWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetOptions, PerseusNumberLineWidgetOptions, PerseusNumericInputWidgetOptions, PerseusOrdererWidgetOptions, PerseusPassageRefWidgetOptions, PerseusPassageWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioWidgetOptions, PerseusSorterWidgetOptions, PerseusTableWidgetOptions, PerseusVideoWidgetOptions } from "./perseus-types";
2
+ import type { PerseusDefinitionWidgetOptions, PerseusDropdownChoice, PerseusExplanationWidgetOptions, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGrapherWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusIFrameWidgetOptions, PerseusImageWidgetOptions, PerseusInputNumberWidgetOptions, PerseusInteractionWidgetOptions, PerseusLabelImageWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetOptions, PerseusNumberLineWidgetOptions, PerseusNumericInputWidgetOptions, PerseusOrdererWidgetOptions, PerseusPassageRefWidgetOptions, PerseusPassageWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioWidgetOptions, PerseusSorterWidgetOptions, PerseusTableWidgetOptions, PerseusVideoWidgetOptions } from "./perseus-types";
3
3
  import type { InteractiveMarkerType } from "./widgets/label-image/types";
4
4
  import type { Relationship } from "./widgets/number-line/number-line";
5
5
  export type UserInputStatus = "correct" | "incorrect" | "incomplete";
6
- export type EmptyUserInput = Empty;
7
- export type NullUserInput = null;
8
6
  export type PerseusCategorizerRubric = {
9
7
  values: ReadonlyArray<number>;
10
8
  };
@@ -17,7 +15,9 @@ export type PerseusCSProgramUserInput = {
17
15
  message: string | null;
18
16
  };
19
17
  export type PerseusDefinitionRubric = PerseusDefinitionWidgetOptions;
20
- export type PerseusDropdownRubric = PerseusDropdownWidgetOptions;
18
+ export type PerseusDropdownRubric = {
19
+ choices: ReadonlyArray<PerseusDropdownChoice>;
20
+ };
21
21
  export type PerseusDropdownUserInput = {
22
22
  value: number;
23
23
  };
@@ -27,6 +27,7 @@ export type PerseusExpressionRubric = {
27
27
  functions: ReadonlyArray<string>;
28
28
  };
29
29
  export type PerseusExpressionUserInput = string;
30
+ export type PerseusGroupRubric = PerseusGroupWidgetOptions;
30
31
  export type PerseusGradedGroupRubric = PerseusGradedGroupWidgetOptions;
31
32
  export type PerseusGradedGroupSetRubric = PerseusGradedGroupSetWidgetOptions;
32
33
  export type PerseusGrapherRubric = PerseusGrapherWidgetOptions;
@@ -68,7 +69,6 @@ export type PerseusMatrixRubric = PerseusMatrixWidgetOptions;
68
69
  export type PerseusMatrixUserInput = {
69
70
  answers: ReadonlyArray<ReadonlyArray<number>>;
70
71
  };
71
- export type PerseusMoleculeUserInput = ReadonlyArray<ReadonlyArray<string>>;
72
72
  export type PerseusNumberLineRubric = PerseusNumberLineWidgetOptions & {
73
73
  isInequality: boolean;
74
74
  };
@@ -107,4 +107,12 @@ export type PerseusSorterUserInput = {
107
107
  export type PerseusTableRubric = PerseusTableWidgetOptions;
108
108
  export type PerseusTableUserInput = ReadonlyArray<ReadonlyArray<string>>;
109
109
  export type PerseusVideoRubric = PerseusVideoWidgetOptions;
110
- export type UserInput = PerseusCategorizerUserInput | PerseusCSProgramUserInput | PerseusDropdownUserInput | PerseusExpressionUserInput | PerseusGrapherUserInput | PerseusIFrameUserInput | PerseusInputNumberUserInput | PerseusInteractiveGraphUserInput | PerseusLabelImageUserInput | PerseusMatcherUserInput | PerseusMatrixUserInput | PerseusMoleculeUserInput | PerseusNumberLineUserInput | PerseusNumericInputUserInput | PerseusOrdererUserInput | PerseusPlotterUserInput | PerseusRadioUserInput | PerseusSorterUserInput | PerseusTableUserInput | EmptyUserInput;
110
+ export type Rubric = PerseusCategorizerRubric | PerseusCSProgramRubric | PerseusDefinitionRubric | PerseusDropdownRubric | PerseusExplanationRubric | PerseusExpressionRubric | PerseusGroupRubric | PerseusGradedGroupRubric | PerseusGradedGroupSetRubric | PerseusGrapherRubric | PerseusIFrameRubric | PerseusImageRubric | PerseusInputNumberRubric | PerseusInteractionRubric | PerseusInteractiveGraphRubric | PerseusLabelImageRubric | PerseusMatcherRubric | PerseusMatrixRubric | PerseusNumberLineRubric | PerseusNumericInputRubric | PerseusOrdererRubric | PerseusPassageRubric | PerseusPassageRefRubric | PerseusPlotterRubric | PerseusRadioRubric | PerseusSorterRubric | PerseusTableRubric | PerseusVideoRubric;
111
+ export type UserInput = PerseusCategorizerUserInput | PerseusCSProgramUserInput | PerseusDropdownUserInput | PerseusExpressionUserInput | PerseusGrapherUserInput | PerseusIFrameUserInput | PerseusInputNumberUserInput | PerseusInteractiveGraphUserInput | PerseusLabelImageUserInput | PerseusMatcherUserInput | PerseusMatrixUserInput | PerseusNumberLineUserInput | PerseusNumericInputUserInput | PerseusOrdererUserInput | PerseusPlotterUserInput | PerseusRadioUserInput | PerseusSorterUserInput | PerseusTableUserInput;
112
+ export type UserInputMap = {
113
+ [widgetId: string]: UserInput | UserInputMap;
114
+ };
115
+ /**
116
+ * deprecated prefer using UserInputMap
117
+ */
118
+ export type UserInputArray = ReadonlyArray<UserInputArray | UserInput | null | undefined>;
@@ -1,8 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusCategorizerWidgetOptions } from "../../perseus-types";
4
- import type { PerseusStrings } from "../../strings";
5
- import type { PerseusScore, Widget, WidgetProps } from "../../types";
4
+ import type { Widget, WidgetProps } from "../../types";
6
5
  import type { PerseusCategorizerRubric, PerseusCategorizerUserInput } from "../../validation.types";
7
6
  type Props = WidgetProps<RenderProps, PerseusCategorizerRubric> & {
8
7
  values: ReadonlyArray<string>;
@@ -18,18 +17,16 @@ type State = {
18
17
  };
19
18
  export declare class Categorizer extends React.Component<Props, State> implements Widget {
20
19
  static contextType: React.Context<{
21
- strings: PerseusStrings;
20
+ strings: import("../../strings").PerseusStrings;
22
21
  locale: string;
23
22
  }>;
24
23
  context: React.ContextType<typeof PerseusI18nContext>;
25
24
  static defaultProps: DefaultProps;
26
25
  state: State;
27
- static validate(userInput: PerseusCategorizerUserInput, rubric: PerseusCategorizerRubric, strings: PerseusStrings): PerseusScore;
28
26
  static getUserInputFromProps(props: Props): PerseusCategorizerUserInput;
29
27
  change: (...args: ReadonlyArray<unknown>) => any;
30
28
  getUserInput(): PerseusCategorizerUserInput;
31
29
  onChange(itemNum: any, catNum: any): void;
32
- simpleValidate(rubric: PerseusCategorizerRubric): PerseusScore;
33
30
  render(): React.ReactNode;
34
31
  }
35
32
  type RenderProps = {
@@ -54,6 +51,7 @@ declare const _default: Readonly<{
54
51
  traverseChildWidgets?: any;
55
52
  transform?: import("../../types").WidgetTransform | undefined;
56
53
  staticTransform?: import("../../types").WidgetTransform | undefined;
54
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
57
55
  propUpgrades?: {
58
56
  [key: string]: (arg1: any) => any;
59
57
  } | undefined;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as React from "react";
5
5
  import type { PerseusCSProgramWidgetOptions } from "../../perseus-types";
6
- import type { PerseusScore, Widget, WidgetProps } from "../../types";
6
+ import type { Widget, WidgetProps } from "../../types";
7
7
  import type { PerseusCSProgramRubric, PerseusCSProgramUserInput } from "../../validation.types";
8
8
  type RenderProps = PerseusCSProgramWidgetOptions & PerseusCSProgramUserInput;
9
9
  type Props = WidgetProps<RenderProps, PerseusCSProgramRubric>;
@@ -15,13 +15,11 @@ type DefaultProps = {
15
15
  };
16
16
  declare class CSProgram extends React.Component<Props> implements Widget {
17
17
  static defaultProps: DefaultProps;
18
- static validate(state: PerseusCSProgramUserInput): PerseusScore;
19
18
  componentDidMount(): void;
20
19
  componentWillUnmount(): void;
21
20
  handleMessageEvent: (arg1: any) => void;
22
21
  change: (...args: ReadonlyArray<unknown>) => any;
23
22
  getUserInput(): PerseusCSProgramUserInput;
24
- simpleValidate(): PerseusScore;
25
23
  render(): React.ReactNode;
26
24
  }
27
25
  declare const _default: Readonly<{
@@ -40,6 +38,7 @@ declare const _default: Readonly<{
40
38
  traverseChildWidgets?: any;
41
39
  transform?: import("../../types").WidgetTransform | undefined;
42
40
  staticTransform?: import("../../types").WidgetTransform | undefined;
41
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
43
42
  propUpgrades?: {
44
43
  [key: string]: (arg1: any) => any;
45
44
  } | undefined;
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusRenderer, PerseusDefinitionWidgetOptions } from "../../perseus-types";
4
4
  import type { Widget, WidgetProps } from "../../types";
5
- import type { EmptyUserInput, PerseusDefinitionRubric } from "../../validation.types";
5
+ import type { PerseusDefinitionRubric } from "../../validation.types";
6
6
  type RenderProps = PerseusDefinitionWidgetOptions;
7
7
  type DefinitionProps = WidgetProps<RenderProps, PerseusDefinitionRubric> & {
8
8
  widgets: PerseusRenderer["widgets"];
@@ -18,9 +18,7 @@ declare class Definition extends React.Component<DefinitionProps> implements Wid
18
18
  }>;
19
19
  context: React.ContextType<typeof PerseusI18nContext>;
20
20
  static defaultProps: DefaultProps;
21
- static validate(): import("../../types").PerseusScore;
22
- getUserInput(): EmptyUserInput;
23
- simpleValidate(): import("../../types").PerseusScore;
21
+ isWidget: true;
24
22
  render(): React.ReactNode;
25
23
  }
26
24
  declare const _default: Readonly<{
@@ -39,6 +37,7 @@ declare const _default: Readonly<{
39
37
  traverseChildWidgets?: any;
40
38
  transform?: import("../../types").WidgetTransform | undefined;
41
39
  staticTransform?: import("../../types").WidgetTransform | undefined;
40
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
42
41
  propUpgrades?: {
43
42
  [key: string]: (arg1: any) => any;
44
43
  } | undefined;
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import { PerseusI18nContext } from "../../components/i18n-context";
3
+ import type { Widget } from "../../types";
4
+ type Props = any;
5
+ declare class DeprecatedStandin extends React.Component<Props> implements Widget {
6
+ static contextType: React.Context<{
7
+ strings: import("../../strings").PerseusStrings;
8
+ locale: string;
9
+ }>;
10
+ context: React.ContextType<typeof PerseusI18nContext>;
11
+ isWidget: true;
12
+ render(): React.JSX.Element;
13
+ }
14
+ declare const _default: Readonly<{
15
+ name: string;
16
+ displayName: string;
17
+ getWidget?: (() => typeof DeprecatedStandin) | undefined;
18
+ widget: typeof DeprecatedStandin;
19
+ accessible?: boolean | ((props: any) => boolean) | undefined;
20
+ hidden?: boolean | undefined;
21
+ version?: import("../../types").Version | undefined;
22
+ supportedAlignments?: readonly import("../../types").Alignment[] | undefined;
23
+ defaultAlignment?: import("../../types").Alignment | undefined;
24
+ getDefaultAlignment?: (() => import("../../types").Alignment) | undefined;
25
+ isLintable?: boolean | undefined;
26
+ tracking?: import("../../types").Tracking | undefined;
27
+ traverseChildWidgets?: any;
28
+ transform?: import("../../types").WidgetTransform | undefined;
29
+ staticTransform?: import("../../types").WidgetTransform | undefined;
30
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
31
+ propUpgrades?: {
32
+ [key: string]: (arg1: any) => any;
33
+ } | undefined;
34
+ }>;
35
+ export default _default;
@@ -1,37 +1 @@
1
- import React from "react";
2
- import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { PerseusScore, Widget } from "../../types";
4
- import type { EmptyUserInput } from "../../validation.types";
5
- type Props = any;
6
- declare class DeprecatedStandin extends React.Component<Props> implements Widget {
7
- static contextType: React.Context<{
8
- strings: import("../../strings").PerseusStrings;
9
- locale: string;
10
- }>;
11
- context: React.ContextType<typeof PerseusI18nContext>;
12
- static validate(): PerseusScore;
13
- getUserInput(): EmptyUserInput;
14
- simpleValidate(): PerseusScore;
15
- render(): React.JSX.Element;
16
- }
17
- declare const _default: Readonly<{
18
- name: string;
19
- displayName: string;
20
- getWidget?: (() => typeof DeprecatedStandin) | undefined;
21
- widget: typeof DeprecatedStandin;
22
- accessible?: boolean | ((props: any) => boolean) | undefined;
23
- hidden?: boolean | undefined;
24
- version?: import("../../types").Version | undefined;
25
- supportedAlignments?: readonly import("../../types").Alignment[] | undefined;
26
- defaultAlignment?: import("../../types").Alignment | undefined;
27
- getDefaultAlignment?: (() => import("../../types").Alignment) | undefined;
28
- isLintable?: boolean | undefined;
29
- tracking?: import("../../types").Tracking | undefined;
30
- traverseChildWidgets?: any;
31
- transform?: import("../../types").WidgetTransform | undefined;
32
- staticTransform?: import("../../types").WidgetTransform | undefined;
33
- propUpgrades?: {
34
- [key: string]: (arg1: any) => any;
35
- } | undefined;
36
- }>;
37
- export default _default;
1
+ export { default } from "./deprecated-standin";
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { PerseusScore, Widget, WidgetProps } from "../../types";
2
+ import type { Widget, WidgetProps } from "../../types";
3
3
  import type { PerseusDropdownRubric, PerseusDropdownUserInput } from "../../validation.types";
4
4
  type Props = WidgetProps<RenderProps, PerseusDropdownRubric> & {
5
5
  selected: number;
@@ -12,12 +12,10 @@ type DefaultProps = {
12
12
  };
13
13
  declare class Dropdown extends React.Component<Props> implements Widget {
14
14
  static defaultProps: DefaultProps;
15
- static validate(userInput: PerseusDropdownUserInput, rubric: PerseusDropdownRubric): PerseusScore;
16
15
  focus: () => boolean;
17
16
  _handleChangeEvent: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
18
17
  _handleChange: (arg1: number) => void;
19
18
  getUserInput(): PerseusDropdownUserInput;
20
- simpleValidate(rubric: PerseusDropdownRubric): PerseusScore;
21
19
  render(): React.ReactNode;
22
20
  }
23
21
  type RenderProps = {
@@ -40,6 +38,7 @@ declare const _default: Readonly<{
40
38
  traverseChildWidgets?: any;
41
39
  transform?: import("../../types").WidgetTransform | undefined;
42
40
  staticTransform?: import("../../types").WidgetTransform | undefined;
41
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
43
42
  propUpgrades?: {
44
43
  [key: string]: (arg1: any) => any;
45
44
  } | undefined;
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusExplanationWidgetOptions } from "../../perseus-types";
4
4
  import type { Widget, WidgetProps } from "../../types";
5
- import type { EmptyUserInput, PerseusExplanationRubric } from "../../validation.types";
5
+ import type { PerseusExplanationRubric } from "../../validation.types";
6
6
  type RenderProps = PerseusExplanationWidgetOptions;
7
7
  type Props = WidgetProps<RenderProps, PerseusExplanationRubric>;
8
8
  type DefaultProps = {
@@ -21,16 +21,14 @@ declare class Explanation extends React.Component<Props, State> implements Widge
21
21
  locale: string;
22
22
  }>;
23
23
  context: React.ContextType<typeof PerseusI18nContext>;
24
+ static defaultProps: DefaultProps;
25
+ isWidget: true;
24
26
  state: State;
25
27
  _mounted: boolean;
26
- static defaultProps: DefaultProps;
27
- static validate(): import("../../types").PerseusScore;
28
28
  componentDidMount(): void;
29
29
  componentWillUnmount(): void;
30
30
  change: (arg1: any, arg2: any, arg3: any) => any;
31
31
  _onClick: () => void;
32
- getUserInput(): EmptyUserInput;
33
- simpleValidate(): import("../../types").PerseusScore;
34
32
  render(): React.ReactNode;
35
33
  }
36
34
  declare const _default: Readonly<{
@@ -49,6 +47,7 @@ declare const _default: Readonly<{
49
47
  traverseChildWidgets?: any;
50
48
  transform?: import("../../types").WidgetTransform | undefined;
51
49
  staticTransform?: import("../../types").WidgetTransform | undefined;
50
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
52
51
  propUpgrades?: {
53
52
  [key: string]: (arg1: any) => any;
54
53
  } | undefined;
@@ -2,8 +2,7 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { DependenciesContext } from "../../dependencies";
4
4
  import type { PerseusExpressionWidgetOptions } from "../../perseus-types";
5
- import type { PerseusStrings } from "../../strings";
6
- import type { FocusPath, PerseusScore, Widget, WidgetProps } from "../../types";
5
+ import type { FocusPath, Widget, WidgetProps } from "../../types";
7
6
  import type { PerseusExpressionRubric, PerseusExpressionUserInput } from "../../validation.types";
8
7
  import type { Keys as Key, KeypadConfiguration } from "@khanacademy/math-input";
9
8
  type InputPath = ReadonlyArray<string>;
@@ -46,13 +45,12 @@ type DefaultProps = {
46
45
  };
47
46
  export declare class Expression extends React.Component<Props, ExpressionState> implements Widget {
48
47
  static contextType: React.Context<{
49
- strings: PerseusStrings;
48
+ strings: import("../../strings").PerseusStrings;
50
49
  locale: string;
51
50
  }>;
52
51
  context: React.ContextType<typeof PerseusI18nContext>;
53
52
  _textareaId: string;
54
53
  _isMounted: boolean;
55
- static validate(userInput: PerseusExpressionUserInput, rubric: PerseusExpressionRubric, strings: PerseusStrings, locale: string): PerseusScore;
56
54
  static getUserInputFromProps(props: Props): PerseusExpressionUserInput;
57
55
  static getOneCorrectAnswerFromRubric(rubric: PerseusExpressionRubric): string | null | undefined;
58
56
  static defaultProps: DefaultProps;
@@ -62,9 +60,6 @@ export declare class Expression extends React.Component<Props, ExpressionState>
62
60
  componentDidUpdate: (prevProps: Props) => void;
63
61
  componentWillUnmount: () => void;
64
62
  _handleMouseDown: () => void;
65
- simpleValidate: (rubric: PerseusExpressionRubric & {
66
- scoring?: boolean;
67
- }) => PerseusScore;
68
63
  getUserInput(): PerseusExpressionUserInput;
69
64
  change: (...args: any) => any | undefined;
70
65
  parse: (value: string, props: Props) => any;
@@ -91,7 +86,7 @@ export declare class Expression extends React.Component<Props, ExpressionState>
91
86
  * to be included as keys on the keypad. These are scraped from the answer
92
87
  * forms.
93
88
  */
94
- declare const keypadConfigurationForProps: (widgetOptions: PerseusExpressionWidgetOptions) => KeypadConfiguration;
89
+ export declare const keypadConfigurationForProps: (widgetOptions: PerseusExpressionWidgetOptions) => KeypadConfiguration;
95
90
  declare const _default: Readonly<{
96
91
  name: string;
97
92
  displayName: string;
@@ -614,6 +609,7 @@ declare const _default: Readonly<{
614
609
  traverseChildWidgets?: any;
615
610
  transform?: import("../../types").WidgetTransform | undefined;
616
611
  staticTransform?: import("../../types").WidgetTransform | undefined;
612
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
617
613
  propUpgrades?: {
618
614
  [key: string]: (arg1: any) => any;
619
615
  } | undefined;
@@ -65,6 +65,7 @@ declare const _default: Readonly<{
65
65
  traverseChildWidgets?: any;
66
66
  transform?: import("../../types").WidgetTransform | undefined;
67
67
  staticTransform?: import("../../types").WidgetTransform | undefined;
68
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
68
69
  propUpgrades?: {
69
70
  [key: string]: (arg1: any) => any;
70
71
  } | undefined;
@@ -45,6 +45,7 @@ declare const _default: Readonly<{
45
45
  traverseChildWidgets?: any;
46
46
  transform?: import("../../types").WidgetTransform | undefined;
47
47
  staticTransform?: import("../../types").WidgetTransform | undefined;
48
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
48
49
  propUpgrades?: {
49
50
  [key: string]: (arg1: any) => any;
50
51
  } | undefined;
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import Graphie from "../../components/graphie";
3
3
  import type { Coord } from "../../interactive2/types";
4
4
  import type { PerseusGrapherWidgetOptions } from "../../perseus-types";
5
- import type { PerseusScore, Widget, WidgetProps } from "../../types";
5
+ import type { Widget, WidgetProps } from "../../types";
6
6
  import type { GridDimensions } from "../../util";
7
7
  import type { PerseusGrapherRubric, PerseusGrapherUserInput } from "../../validation.types";
8
8
  import type { PropsFor } from "@khanacademy/wonder-blocks-core";
@@ -23,7 +23,6 @@ declare class Grapher extends React.Component<Props> implements Widget {
23
23
  horizHairline: any;
24
24
  vertHairline: any;
25
25
  static defaultProps: DefaultProps;
26
- static validate(state: PerseusGrapherUserInput, rubric: PerseusGrapherRubric): PerseusScore;
27
26
  static getUserInputFromProps(props: Props): PerseusGrapherUserInput;
28
27
  handlePlotChanges: (arg1: any) => any;
29
28
  handleActiveTypeChange: (arg1: any) => any;
@@ -35,7 +34,6 @@ declare class Grapher extends React.Component<Props> implements Widget {
35
34
  _setupGraphie: (arg1: any, arg2: any) => void;
36
35
  showHairlines: (arg1: Coord) => void;
37
36
  hideHairlines: () => void;
38
- simpleValidate(rubric: PerseusGrapherRubric): PerseusScore;
39
37
  getUserInput(): PerseusGrapherUserInput;
40
38
  render(): React.ReactNode;
41
39
  }
@@ -55,6 +53,7 @@ declare const _default: Readonly<{
55
53
  traverseChildWidgets?: any;
56
54
  transform?: import("../../types").WidgetTransform | undefined;
57
55
  staticTransform?: import("../../types").WidgetTransform | undefined;
56
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
58
57
  propUpgrades?: {
59
58
  [key: string]: (arg1: any) => any;
60
59
  } | undefined;
@@ -3,10 +3,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import Renderer from "../../renderer";
4
4
  import type { PerseusGroupWidgetOptions } from "../../perseus-types";
5
5
  import type { ChangeFn, FocusPath, Widget, WidgetProps } from "../../types";
6
- import type { UserInput } from "../../validation.types";
7
- type Rubric = PerseusGroupWidgetOptions;
6
+ import type { PerseusGroupRubric, UserInputArray } from "../../validation.types";
8
7
  type RenderProps = PerseusGroupWidgetOptions;
9
- type Props = WidgetProps<RenderProps, Rubric>;
8
+ type Props = WidgetProps<RenderProps, PerseusGroupRubric>;
10
9
  type DefaultProps = {
11
10
  content: Props["content"];
12
11
  widgets: Props["widgets"];
@@ -23,10 +22,13 @@ declare class Group extends React.Component<Props> implements Widget {
23
22
  static defaultProps: DefaultProps;
24
23
  componentDidMount(): void;
25
24
  change: ChangeFn;
26
- getUserInput(): ReadonlyArray<UserInput | null | undefined> | undefined;
25
+ getUserInputMap(): import("../../validation.types").UserInputMap | undefined;
26
+ /**
27
+ * @deprecated getUserInputMap should be used for Groups
28
+ */
29
+ getUserInput(): UserInputArray | undefined;
27
30
  getSerializedState: () => any;
28
31
  restoreSerializedState: (arg1: any, arg2: any) => null;
29
- simpleValidate(): import("../../types").PerseusScore;
30
32
  getInputPaths(): readonly FocusPath[];
31
33
  setInputValue: (arg1: FocusPath, arg2: string, arg3: () => unknown) => void;
32
34
  focus(): boolean;
@@ -51,6 +53,7 @@ declare const _default: Readonly<{
51
53
  traverseChildWidgets?: any;
52
54
  transform?: import("../../types").WidgetTransform | undefined;
53
55
  staticTransform?: import("../../types").WidgetTransform | undefined;
56
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
54
57
  propUpgrades?: {
55
58
  [key: string]: (arg1: any) => any;
56
59
  } | undefined;
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import * as React from "react";
10
10
  import type { PerseusIFrameWidgetOptions } from "../../perseus-types";
11
- import type { PerseusScore, WidgetProps, Widget } from "../../types";
11
+ import type { WidgetProps, Widget } from "../../types";
12
12
  import type { PerseusIFrameRubric, PerseusIFrameUserInput, UserInputStatus } from "../../validation.types";
13
13
  type RenderProps = PerseusIFrameWidgetOptions & {
14
14
  status: UserInputStatus;
@@ -25,13 +25,11 @@ type DefaultProps = {
25
25
  };
26
26
  declare class Iframe extends React.Component<Props> implements Widget {
27
27
  static defaultProps: DefaultProps;
28
- static validate(state: PerseusIFrameUserInput): PerseusScore;
29
28
  componentDidMount(): void;
30
29
  componentWillUnmount(): void;
31
30
  getUserInput(): PerseusIFrameUserInput;
32
31
  handleMessageEvent: (arg1: any) => void;
33
32
  change: (...args: ReadonlyArray<unknown>) => any;
34
- simpleValidate(): PerseusScore;
35
33
  render(): React.ReactNode;
36
34
  }
37
35
  declare const _default: Readonly<{
@@ -50,6 +48,7 @@ declare const _default: Readonly<{
50
48
  traverseChildWidgets?: any;
51
49
  transform?: import("../../types").WidgetTransform | undefined;
52
50
  staticTransform?: import("../../types").WidgetTransform | undefined;
51
+ validator?: import("../../types").WidgetValidatorFunction | undefined;
53
52
  propUpgrades?: {
54
53
  [key: string]: (arg1: any) => any;
55
54
  } | undefined;