@khanacademy/perseus-core 4.0.0 → 5.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.
@@ -0,0 +1,12 @@
1
+ export declare const KeypadKeys: readonly ["PLUS", "MINUS", "NEGATIVE", "TIMES", "DIVIDE", "DECIMAL", "PERIOD", "PERCENT", "CDOT", "EQUAL", "NEQ", "GT", "LT", "GEQ", "LEQ", "FRAC_INCLUSIVE", "FRAC_EXCLUSIVE", "FRAC", "EXP", "EXP_2", "EXP_3", "SQRT", "CUBE_ROOT", "RADICAL", "LEFT_PAREN", "RIGHT_PAREN", "LN", "LOG", "LOG_N", "SIN", "COS", "TAN", "PI", "THETA", "UP", "RIGHT", "DOWN", "LEFT", "BACKSPACE", "DISMISS", "JUMP_OUT_PARENTHESES", "JUMP_OUT_EXPONENT", "JUMP_OUT_BASE", "JUMP_INTO_NUMERATOR", "JUMP_OUT_NUMERATOR", "JUMP_OUT_DENOMINATOR", "NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4", "NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
2
+ export type KeypadKey = (typeof KeypadKeys)[number];
3
+ export type KeypadType = "FRACTION" | "EXPRESSION";
4
+ export type KeypadConfiguration = {
5
+ keypadType: KeypadType;
6
+ extraKeys?: ReadonlyArray<KeypadKey>;
7
+ times?: boolean;
8
+ scientific?: boolean;
9
+ };
10
+ export interface KeypadContextRendererInterface {
11
+ blur(): void;
12
+ }
package/dist/types.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- export interface KeypadContextRendererInterface {
2
- blur(): void;
3
- }
4
1
  type State = any;
5
2
  export interface RendererInterface {
6
3
  getSerializedState(): State;
@@ -0,0 +1,8 @@
1
+ import { type KeypadConfiguration } from "../../keypad";
2
+ import type { PerseusExpressionWidgetOptions } from "../../data-schema";
3
+ /**
4
+ * Scrape the answer forms for any variables or contants (like Pi)
5
+ * that need to be included as keys on the keypad.
6
+ */
7
+ declare function deriveExtraKeys(widgetOptions: PerseusExpressionWidgetOptions): KeypadConfiguration["extraKeys"];
8
+ export default deriveExtraKeys;
@@ -4,6 +4,7 @@ export declare const currentVersion: {
4
4
  minor: number;
5
5
  };
6
6
  export declare const widgetOptionsUpgrades: {
7
+ readonly "2": (v1options: any) => PerseusExpressionWidgetOptions;
7
8
  readonly "1": (v0options: any) => PerseusExpressionWidgetOptions;
8
9
  };
9
10
  export type ExpressionDefaultWidgetOptions = Pick<PerseusExpressionWidgetOptions, "answerForms" | "times" | "buttonSets" | "functions">;
@@ -3,13 +3,14 @@ import type { PerseusExpressionWidgetOptions } from "@khanacademy/perseus-core";
3
3
  * For details on the individual options, see the
4
4
  * PerseusExpressionWidgetOptions type
5
5
  */
6
- type ExpressionPublicWidgetOptions = {
6
+ export type ExpressionPublicWidgetOptions = {
7
7
  buttonSets: PerseusExpressionWidgetOptions["buttonSets"];
8
8
  functions: PerseusExpressionWidgetOptions["functions"];
9
9
  times: PerseusExpressionWidgetOptions["times"];
10
10
  visibleLabel?: PerseusExpressionWidgetOptions["visibleLabel"];
11
11
  ariaLabel?: PerseusExpressionWidgetOptions["ariaLabel"];
12
12
  buttonsVisible?: PerseusExpressionWidgetOptions["buttonsVisible"];
13
+ extraKeys?: PerseusExpressionWidgetOptions["extraKeys"];
13
14
  };
14
15
  /**
15
16
  * Given a PerseusExpressionWidgetOptions object, return a new object with only
@@ -3,7 +3,9 @@ export declare const currentVersion: {
3
3
  major: number;
4
4
  minor: number;
5
5
  };
6
+ export declare function deriveNumCorrect(options: PerseusRadioWidgetOptions): number;
6
7
  export declare const widgetOptionsUpgrades: {
8
+ readonly "2": (v1props: any) => PerseusRadioWidgetOptions;
7
9
  readonly "1": (v0props: any) => PerseusRadioWidgetOptions;
8
10
  };
9
11
  export type RadioDefaultWidgetOptions = Pick<PerseusRadioWidgetOptions, "choices" | "displayCount" | "randomize" | "hasNoneOfTheAbove" | "multipleSelect" | "countChoices" | "deselectEnabled">;
@@ -7,6 +7,7 @@ type RadioPublicWidgetOptions = {
7
7
  choices: ReadonlyArray<RadioChoicePublicData>;
8
8
  hasNoneOfTheAbove?: PerseusRadioWidgetOptions["hasNoneOfTheAbove"];
9
9
  countChoices?: PerseusRadioWidgetOptions["countChoices"];
10
+ numCorrect?: PerseusRadioWidgetOptions["numCorrect"];
10
11
  randomize?: PerseusRadioWidgetOptions["randomize"];
11
12
  multipleSelect?: PerseusRadioWidgetOptions["multipleSelect"];
12
13
  deselectEnabled?: PerseusRadioWidgetOptions["deselectEnabled"];
@@ -18,6 +19,15 @@ type RadioPublicWidgetOptions = {
18
19
  * Only the options from each Radio choice that should be exposed to the client.
19
20
  */
20
21
  type RadioChoicePublicData = Pick<PerseusRadioChoice, "content" | "isNoneOfTheAbove" | "widgets">;
22
+ /**
23
+ * Shared functionality to determine if numCorrect is used, because:
24
+ *
25
+ * 1. numCorrect is conditionally used for rendering pre-scoring
26
+ * 2. numCorrect also exposes information about answers
27
+ *
28
+ * So only include/use numCorrect when we know it's useful.
29
+ */
30
+ export declare function usesNumCorrect(multipleSelect: PerseusRadioWidgetOptions["multipleSelect"], countChoices: PerseusRadioWidgetOptions["countChoices"], numCorrect: PerseusRadioWidgetOptions["numCorrect"]): number | false | undefined;
21
31
  /**
22
32
  * Given a PerseusRadioWidgetOptions object, return a new object with only
23
33
  * the public options that should be exposed to the client.
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": "4.0.0",
6
+ "version": "5.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -21,7 +21,9 @@
21
21
  "files": [
22
22
  "dist"
23
23
  ],
24
- "dependencies": {},
24
+ "dependencies": {
25
+ "@khanacademy/kas": "0.5.0"
26
+ },
25
27
  "devDependencies": {
26
28
  "@khanacademy/wonder-stuff-core": "1.5.4",
27
29
  "underscore": "^1.4.4"