@khanacademy/perseus-core 42.3.0 → 42.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.
@@ -6,24 +6,9 @@ type ObjectSchema = Record<keyof any, Parser<any>>;
6
6
  * iff each sub-parser in the `schema` accepts the object's corresponding
7
7
  * property value.
8
8
  *
9
- * The returned parser filters out properties not present in the schema. If
10
- * you don't want this behavior, try `looseObject`.
9
+ * The returned parser filters out properties not present in the schema.
11
10
  */
12
11
  export declare function object<S extends ObjectSchema>(schema: S): Parser<OptionalizeProperties<{
13
12
  [K in keyof S]: ParsedValue<S[K]>;
14
13
  }>>;
15
- /**
16
- * Given a `schema`, returns an object parser. The parser accepts an object
17
- * iff each sub-parser in the `schema` accepts the object's corresponding
18
- * property value.
19
- *
20
- * The parser preserves any object properties not present in the schema. If
21
- * you want unrecognized properties to be filtered out instead, try `object`.
22
- *
23
- * @internal
24
- * Only used in tests.
25
- */
26
- export declare function looseObject<S extends ObjectSchema>(schema: S): Parser<OptionalizeProperties<{
27
- [K in keyof S]: ParsedValue<S[K]>;
28
- }>>;
29
14
  export {};
@@ -1,10 +1,12 @@
1
1
  /**
2
- * Parses one tile in a Drag And Drop widget's choice bank. Shared across the
3
- * widget family, like `PerseusAnswerTile`.
2
+ * The fields of one tile in a Drag And Drop widget's choice bank. Shared
3
+ * across the widget family, like `PerseusAnswerTile`. A widget builds its
4
+ * tile parser with `object({...answerTileSchema, ...})`, adding any fields
5
+ * of its own, rather than restating these.
4
6
  */
5
- export declare const parseAnswerTile: import("../parser-types").Parser<import("../general-purpose-parsers/object-types").OptionalizeProperties<{
6
- id: string;
7
- content: string;
8
- label: string;
9
- imageHeight: number | undefined;
10
- }>>;
7
+ export declare const answerTileSchema: {
8
+ id: import("../parser-types").Parser<string>;
9
+ content: import("../parser-types").Parser<string>;
10
+ label: import("../parser-types").Parser<string>;
11
+ imageHeight: import("../parser-types").Parser<number | undefined>;
12
+ };
@@ -0,0 +1,3 @@
1
+ export declare const parseBlankUserInput: import("../parser-types").Parser<import("../general-purpose-parsers/object-types").OptionalizeProperties<{
2
+ selected: string | null;
3
+ }>>;
@@ -0,0 +1,3 @@
1
+ export declare const parseFillInTheBlankUserInput: import("../parser-types").Parser<Record<string, import("../general-purpose-parsers/object-types").OptionalizeProperties<{
2
+ selected: string | null;
3
+ }>>>;
@@ -8,12 +8,12 @@ export declare const parseFillInTheBlankWidget: Parser<import("../general-purpos
8
8
  content: string;
9
9
  widgets: import("../..").MakeWidgetMap<import("../..").PerseusWidgetTypes>;
10
10
  tiles: import("../general-purpose-parsers/object-types").OptionalizeProperties<{
11
+ maxUses: number | "unlimited";
11
12
  id: string;
12
13
  content: string;
13
14
  label: string;
14
15
  imageHeight: number | undefined;
15
16
  }>[];
16
- maxUsesPerTile: number | "unlimited";
17
17
  randomize: boolean;
18
18
  }>;
19
19
  key: number | null | undefined;
@@ -4,13 +4,13 @@ export declare const parseNumberLineWidget: import("../parser-types").Parser<imp
4
4
  graded: boolean | undefined;
5
5
  alignment: "default" | "block" | "inline-block" | "inline" | "wrap-left" | "wrap-right" | "full-width" | undefined;
6
6
  options: import("../general-purpose-parsers/object-types").OptionalizeProperties<{
7
- range: number[];
8
- labelRange: (number | null)[];
7
+ range: [number, number];
8
+ labelRange: [number | null, number | null];
9
9
  labelStyle: "mixed" | "improper" | "decimal" | "non-reduced";
10
10
  labelTicks: boolean;
11
11
  isTickCtrl: boolean;
12
12
  isInequality: boolean;
13
- divisionRange: number[];
13
+ divisionRange: [number, number];
14
14
  numDivisions: number | null | undefined;
15
15
  snapDivisions: number;
16
16
  tickStep: number | null | undefined;
@@ -7,6 +7,15 @@ export declare const parseSorterWidget: import("../parser-types").Parser<import(
7
7
  correct: string[];
8
8
  padding: boolean;
9
9
  layout: "horizontal" | "vertical";
10
+ variant: "scale" | "timeline";
11
+ legend: import("../general-purpose-parsers/object-types").OptionalizeProperties<{
12
+ startCap: "none" | "bar" | "arrow";
13
+ endCap: "none" | "bar" | "arrow";
14
+ startLabel: string;
15
+ endLabel: string;
16
+ ariaLabel: string;
17
+ position: "above" | "below";
18
+ }> | undefined;
10
19
  }>;
11
20
  key: number | null | undefined;
12
21
  version: import("../general-purpose-parsers/object-types").OptionalizeProperties<{
@@ -0,0 +1,42 @@
1
+ declare const _default: {
2
+ question: {
3
+ content: string;
4
+ images: {};
5
+ widgets: {
6
+ "sorter 1": {
7
+ type: string;
8
+ alignment: string;
9
+ static: boolean;
10
+ graded: boolean;
11
+ options: {
12
+ correct: string[];
13
+ layout: string;
14
+ padding: boolean;
15
+ variant: string;
16
+ legend: {
17
+ startCap: string;
18
+ endCap: string;
19
+ startLabel: string;
20
+ endLabel: string;
21
+ ariaLabel: string;
22
+ position: string;
23
+ };
24
+ };
25
+ version: {
26
+ major: number;
27
+ minor: number;
28
+ };
29
+ };
30
+ };
31
+ };
32
+ answerArea: {
33
+ calculator: boolean;
34
+ financialCalculatorMonthlyPayment: boolean;
35
+ financialCalculatorTotalAmount: boolean;
36
+ financialCalculatorTimeToPayOff: boolean;
37
+ periodicTable: boolean;
38
+ periodicTableWithKey: boolean;
39
+ };
40
+ hints: never[];
41
+ };
42
+ export default _default;
@@ -0,0 +1,33 @@
1
+ declare const _default: {
2
+ question: {
3
+ content: string;
4
+ images: {};
5
+ widgets: {
6
+ "sorter 1": {
7
+ type: string;
8
+ alignment: string;
9
+ static: boolean;
10
+ graded: boolean;
11
+ options: {
12
+ correct: string[];
13
+ layout: string;
14
+ padding: boolean;
15
+ };
16
+ version: {
17
+ major: number;
18
+ minor: number;
19
+ };
20
+ };
21
+ };
22
+ };
23
+ answerArea: {
24
+ calculator: boolean;
25
+ financialCalculatorMonthlyPayment: boolean;
26
+ financialCalculatorTotalAmount: boolean;
27
+ financialCalculatorTimeToPayOff: boolean;
28
+ periodicTable: boolean;
29
+ periodicTableWithKey: boolean;
30
+ };
31
+ hints: never[];
32
+ };
33
+ export default _default;
@@ -1,4 +1,5 @@
1
- import type { FillInTheBlankWidget, PerseusAnswerTile, PerseusFillInTheBlankWidgetOptions } from "../../data-schema";
1
+ import type { FillInTheBlankWidget, PerseusAnswerTile, PerseusFillInTheBlankTile, PerseusFillInTheBlankWidgetOptions } from "../../data-schema";
2
2
  export declare function generateAnswerTile(tile?: Partial<PerseusAnswerTile>): PerseusAnswerTile;
3
+ export declare function generateFillInTheBlankTile(tile?: Partial<PerseusFillInTheBlankTile>): PerseusFillInTheBlankTile;
3
4
  export declare function generateFillInTheBlankOptions(options?: Partial<PerseusFillInTheBlankWidgetOptions>): PerseusFillInTheBlankWidgetOptions;
4
5
  export declare function generateFillInTheBlankWidget(fillInTheBlankWidgetProperties?: Partial<Omit<FillInTheBlankWidget, "type">>): FillInTheBlankWidget;
@@ -1,3 +1,4 @@
1
- import type { PerseusSorterWidgetOptions, SorterWidget } from "../../data-schema";
1
+ import type { PerseusSorterWidgetOptions, SorterLegend, SorterWidget } from "../../data-schema";
2
2
  export declare function generateSorterOptions(options?: Partial<PerseusSorterWidgetOptions>): PerseusSorterWidgetOptions;
3
+ export declare function generateSorterLegend(options?: Partial<SorterLegend>): SorterLegend;
3
4
  export declare function generateSorterWidget(sorterWidgetProperties?: Partial<Omit<SorterWidget, "type">>): SorterWidget;
@@ -0,0 +1,5 @@
1
+ import type { PerseusScore } from "../validation.types";
2
+ /**
3
+ * Returns true if the score earned all of its available points.
4
+ */
5
+ export declare function isCorrect(score: PerseusScore): boolean;
@@ -148,6 +148,11 @@ export type PerseusDropdownUserInput = {
148
148
  * string the learner typed, parsed by @khanacademy/kas for scoring.
149
149
  */
150
150
  export type PerseusExpressionUserInput = string;
151
+ /**
152
+ * User input for the Fill in the Blank widget: a map of blank widget IDs
153
+ * to each blank's user input.
154
+ */
155
+ export type PerseusFillInTheBlankUserInput = Record<string, PerseusBlankUserInput>;
151
156
  /**
152
157
  * User input for the Group widget: a map of widget IDs to each widget's user
153
158
  * input. Scored by recursively scoring all contained widgets.
@@ -294,10 +299,12 @@ export type PerseusTableUserInput = string[][];
294
299
  * explanation.
295
300
  */
296
301
  interface UserInputRegistry {
302
+ blank: PerseusBlankUserInput;
297
303
  categorizer: PerseusCategorizerUserInput;
298
304
  "cs-program": PerseusCSProgramUserInput;
299
305
  dropdown: PerseusDropdownUserInput;
300
306
  expression: PerseusExpressionUserInput;
307
+ "fill-in-the-blank": PerseusFillInTheBlankUserInput;
301
308
  "free-response": PerseusFreeResponseUserInput;
302
309
  grapher: PerseusGrapherUserInput;
303
310
  group: PerseusGroupUserInput;
@@ -20,6 +20,8 @@ export type SorterPublicWidgetOptions = {
20
20
  * TODO(LEMS-4535): rename this
21
21
  */
22
22
  correct: PerseusSorterWidgetOptions["correct"];
23
+ variant: PerseusSorterWidgetOptions["variant"];
24
+ legend?: PerseusSorterWidgetOptions["legend"];
23
25
  /**
24
26
  * @deprecated
25
27
  *
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": "42.3.0",
6
+ "version": "42.5.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -1,14 +0,0 @@
1
- import { ErrorTrackingParseContext } from "../error-tracking-parse-context";
2
- import type { Mismatch } from "../parser-types";
3
- import type { Failure } from "../result";
4
- export declare function ctx(): ErrorTrackingParseContext;
5
- export declare const anyFailure: Failure<any>;
6
- export declare const anySuccess: import("../result").Success<any>;
7
- export declare function parseFailureWith(expected: Partial<Mismatch>): Failure<Mismatch[]>;
8
- /**
9
- * Summons a value of type T out of thin air!
10
- *
11
- * (Terms and conditions apply. Value will not actually be returned.
12
- * For use in typetests only.)
13
- */
14
- export declare function summon<T>(): T;
@@ -1 +0,0 @@
1
- export declare function range(min: number, max: number): number[];