@khanacademy/perseus-core 18.4.0 → 18.5.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.
@@ -1,2 +1,7 @@
1
1
  import type { Parser } from "../parser-types";
2
2
  export declare function array<T>(elementParser: Parser<T>): Parser<T[]>;
3
+ /**
4
+ * Like the standard `array` parser, but passes the array index to a parser factory function.
5
+ * This allows element parsers to generate index-based default values.
6
+ */
7
+ export declare function arrayWithIndex<T>(elementParserFactory: (index: number) => Parser<T>): Parser<T[]>;
@@ -1,3 +1,3 @@
1
1
  export declare const parseCategorizerUserInput: import("../parser-types").Parser<import("../general-purpose-parsers/object-types").OptionalizeProperties<{
2
- values: number[];
2
+ values: (number | null | undefined)[];
3
3
  }>>;
@@ -6,6 +6,7 @@ declare const parseRadioWidgetV3: import("../parser-types").Parser<import("../..
6
6
  rationale: string | undefined;
7
7
  correct: boolean | undefined;
8
8
  isNoneOfTheAbove: boolean | undefined;
9
+ id: string;
9
10
  }>[];
10
11
  hasNoneOfTheAbove: boolean | undefined;
11
12
  countChoices: boolean | undefined;
@@ -75,6 +76,7 @@ export declare const parseRadioWidget: import("../parser-types").Parser<import("
75
76
  rationale: string | undefined;
76
77
  correct: boolean | undefined;
77
78
  isNoneOfTheAbove: boolean | undefined;
79
+ id: string;
78
80
  }>[];
79
81
  hasNoneOfTheAbove: boolean | undefined;
80
82
  countChoices: boolean | undefined;
@@ -150,30 +150,40 @@ export declare const v3Widget: {
150
150
  graded: boolean;
151
151
  options: {
152
152
  choices: ({
153
+ id: string;
153
154
  content: string;
154
155
  correct: boolean;
155
156
  rationale: string;
156
157
  isNoneOfTheAbove: boolean;
158
+ widgets?: undefined;
157
159
  } | {
160
+ id: string;
158
161
  content: string;
159
162
  correct: boolean;
160
163
  rationale: string;
164
+ widgets: undefined;
161
165
  isNoneOfTheAbove?: undefined;
162
166
  } | {
167
+ id: string;
163
168
  content: string;
164
169
  correct: boolean;
165
170
  isNoneOfTheAbove: boolean;
166
171
  rationale?: undefined;
172
+ widgets?: undefined;
167
173
  } | {
174
+ id: string;
168
175
  content: string;
169
176
  rationale: string;
170
177
  isNoneOfTheAbove: boolean;
171
178
  correct?: undefined;
179
+ widgets?: undefined;
172
180
  } | {
181
+ id: string;
173
182
  content: string;
174
183
  correct?: undefined;
175
184
  rationale?: undefined;
176
185
  isNoneOfTheAbove?: undefined;
186
+ widgets?: undefined;
177
187
  })[];
178
188
  numCorrect: number;
179
189
  hasNoneOfTheAbove: boolean;
@@ -30,8 +30,8 @@
30
30
  */
31
31
  import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusRadioChoice, PerseusGraphCorrectType, MakeWidgetMap, PerseusFreeResponseWidgetScoringCriterion } from "./data-schema";
32
32
  import type { Relationship } from "./types";
33
- export type WidgetValidatorFunction = (userInput: UserInput, validationData: ValidationData, locale: string) => ValidationResult;
34
- export type WidgetScorerFunction = (userInput: UserInput, rubric: Rubric, locale?: string) => PerseusScore;
33
+ export type WidgetValidatorFunction = (userInput: UserInput | undefined, validationData: ValidationData, locale: string) => ValidationResult;
34
+ export type WidgetScorerFunction = (userInput: UserInput | undefined, rubric: Rubric, locale?: string) => PerseusScore;
35
35
  export type PerseusScore = {
36
36
  type: "invalid";
37
37
  message?: string | null | undefined;
@@ -50,7 +50,7 @@ export type PerseusCategorizerRubric = {
50
50
  values: number[];
51
51
  } & PerseusCategorizerValidationData;
52
52
  export type PerseusCategorizerUserInput = {
53
- values: PerseusCategorizerRubric["values"];
53
+ values: Array<number | null | undefined>;
54
54
  };
55
55
  export type PerseusCategorizerValidationData = {
56
56
  items: string[];
@@ -1,2 +1,5 @@
1
- import type { PerseusRadioWidgetOptions } from "../../data-schema";
2
- export declare function deriveNumCorrect(choices: PerseusRadioWidgetOptions["choices"]): number;
1
+ interface Choice {
2
+ correct?: boolean;
3
+ }
4
+ export declare function deriveNumCorrect(choices: Choice[]): number;
5
+ export {};
@@ -1,7 +1,7 @@
1
1
  import type { PerseusRadioChoice, PerseusRadioWidgetOptions } from "../../data-schema";
2
2
  /**
3
3
  * For details on the individual options, see the
4
- * PerseusRadioWidgetOptions type
4
+ * PerseusRadioWidgetOptions type.
5
5
  */
6
6
  export type RadioPublicWidgetOptions = {
7
7
  choices: ReadonlyArray<RadioChoicePublicData>;
@@ -15,7 +15,7 @@ export type RadioPublicWidgetOptions = {
15
15
  /**
16
16
  * Only the options from each Radio choice that should be exposed to the client.
17
17
  */
18
- type RadioChoicePublicData = Pick<PerseusRadioChoice, "content" | "isNoneOfTheAbove">;
18
+ type RadioChoicePublicData = Pick<PerseusRadioChoice, "id" | "content" | "isNoneOfTheAbove">;
19
19
  /**
20
20
  * Shared functionality to determine if numCorrect is used, because:
21
21
  *
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Shared Perseus infrastructure",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "18.4.0",
6
+ "version": "18.5.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },