@khanacademy/perseus 62.0.0 → 63.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,35 @@
1
+ import { type ShowSolutions } from "@khanacademy/perseus-core";
2
+ import type { ChoiceState } from "../../../types";
3
+ import type { RadioChoiceWithMetadata } from "../radio.new";
4
+ interface GetChoiceStatesProps {
5
+ choices: ReadonlyArray<RadioChoiceWithMetadata>;
6
+ isStatic?: boolean | null;
7
+ showSolutions?: ShowSolutions;
8
+ choiceStates?: ReadonlyArray<ChoiceState>;
9
+ values?: ReadonlyArray<boolean>;
10
+ }
11
+ /**
12
+ * Determine the updated choice states for the Radio widget, based on the
13
+ * widget's static / showSolutions states, choiceStates, and values.
14
+ *
15
+ * @param choices - The choices for the Radio widget.
16
+ * @param isStatic - Whether the widget is static.
17
+ * @param showSolutions - Whether the widget is in showSolutions mode.
18
+ * @param choiceStates - The choice states for the widget. (The user's current selection states.)
19
+ * @param values - The values for the widget. (Deprecated: The user's current selection states for old content.)
20
+ * @returns The updated choice states for the widget.
21
+ */
22
+ export declare const getChoiceStates: ({ choices, isStatic, showSolutions, choiceStates, values, }: GetChoiceStatesProps) => ReadonlyArray<ChoiceState>;
23
+ /**
24
+ * Parse the nested widgets in the content of a Radio widget.
25
+ * Currently this only supports passage-ref widgets, but can
26
+ * be extended to support other nested widgets in the future.
27
+ *
28
+ * @param content - The content of the Radio widget.
29
+ * @returns The parsed content and the extracted widgets.
30
+ */
31
+ export declare const parseNestedWidgets: (content: string) => {
32
+ parsedContent: string;
33
+ extractedWidgets: Record<string, any>;
34
+ };
35
+ export {};
@@ -0,0 +1,72 @@
1
+ import type { PerseusStrings } from "../../../strings";
2
+ /**
3
+ * Given a choice's position in the radio widget, return the corresponding
4
+ * "choice letter". (For example, `getChoiceLetter(0)` is "A",
5
+ * `getChoiceLetter(1)` is "B", etc.)
6
+ *
7
+ * All locales use English letters for the choice letters.
8
+ *
9
+ * @param pos - The position of the choice in the radio widget.
10
+ * @param strings - The strings for the Radio widget.
11
+ * @returns The choice letter for the given position.
12
+ */
13
+ export declare const getChoiceLetter: (pos: number, strings: PerseusStrings) => string;
14
+ interface GetOptionStatusTextProps {
15
+ checked: boolean;
16
+ correct: boolean;
17
+ crossedOut: boolean;
18
+ strings: PerseusStrings;
19
+ }
20
+ /**
21
+ * Get the correct (translated) string for an option status (correct, incorrect, selected, etc.)
22
+ *
23
+ * @param checked - Whether the option is checked.
24
+ * @param correct - Whether the option is correct.
25
+ * @param crossedOut - Whether the option is crossed out.
26
+ * @param strings - The strings for the Radio widget.
27
+ * @returns The appropriate string for the option status.
28
+ */
29
+ export declare const getOptionStatusText: ({ checked, correct, crossedOut, strings, }: GetOptionStatusTextProps) => string;
30
+ interface GetInstructionsTextProps {
31
+ multipleSelect: boolean;
32
+ countChoices: boolean | null | undefined;
33
+ numCorrect: number;
34
+ strings: PerseusStrings;
35
+ }
36
+ /**
37
+ * Get the (translated) instructions string for a Radio widget.
38
+ *
39
+ * This is the text that appears above the widget that explains
40
+ * how many choices the user should select.
41
+ *
42
+ * @param multipleSelect - Whether the widget is a multiple-select widget.
43
+ * @param countChoices - Whether the widget counts choices.
44
+ * @param numCorrect - The number of correct choices.
45
+ * @param strings - The strings for the Radio widget.
46
+ * @returns The instructions string for the widget.
47
+ */
48
+ export declare const getInstructionsText: ({ multipleSelect, countChoices, numCorrect, strings, }: GetInstructionsTextProps) => string;
49
+ interface GetA11yTextProps {
50
+ letter: string;
51
+ checked: boolean;
52
+ correct: boolean;
53
+ crossedOut: boolean;
54
+ showCorrectness: boolean;
55
+ strings: PerseusStrings;
56
+ }
57
+ /**
58
+ * Get the (translated) a11y string for a Radio widget.
59
+ *
60
+ * This string is provided to screen readers to help the user
61
+ * understand the current state of a Radio option.
62
+ *
63
+ * @param letter - The letter for the choice.
64
+ * @param checked - Whether the choice is checked.
65
+ * @param correct - Whether the choice is correct.
66
+ * @param crossedOut - Whether the choice is crossed out.
67
+ * @param showCorrectness - Whether the correctness is shown.
68
+ * @param strings - The strings for the Radio widget.
69
+ * @returns The a11y string for the Radio option.
70
+ */
71
+ export declare const getA11yText: ({ letter, checked, correct, crossedOut, showCorrectness, strings, }: GetA11yTextProps) => string;
72
+ export {};
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": "62.0.0",
6
+ "version": "63.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -42,12 +42,12 @@
42
42
  "tiny-invariant": "^1.3.1",
43
43
  "uuid": "^10.0.0",
44
44
  "@khanacademy/kas": "2.0.4",
45
- "@khanacademy/keypad-context": "3.0.9",
46
- "@khanacademy/kmath": "2.0.9",
47
- "@khanacademy/math-input": "25.1.4",
48
- "@khanacademy/perseus-core": "11.0.0",
49
- "@khanacademy/perseus-linter": "3.0.9",
50
- "@khanacademy/perseus-score": "6.0.0",
45
+ "@khanacademy/keypad-context": "3.0.10",
46
+ "@khanacademy/kmath": "2.0.10",
47
+ "@khanacademy/math-input": "25.1.5",
48
+ "@khanacademy/perseus-core": "12.0.0",
49
+ "@khanacademy/perseus-linter": "3.0.10",
50
+ "@khanacademy/perseus-score": "7.0.0",
51
51
  "@khanacademy/perseus-utils": "2.0.3",
52
52
  "@khanacademy/pure-markdown": "2.0.4",
53
53
  "@khanacademy/simple-markdown": "2.0.4"
@@ -62,6 +62,7 @@
62
62
  "@khanacademy/wonder-blocks-form": "7.1.10",
63
63
  "@khanacademy/wonder-blocks-icon-button": "9.0.4",
64
64
  "@khanacademy/wonder-blocks-icon": "5.1.3",
65
+ "@khanacademy/wonder-blocks-labeled-field": "3.0.6",
65
66
  "@khanacademy/wonder-blocks-layout": "3.1.9",
66
67
  "@khanacademy/wonder-blocks-link": "9.0.3",
67
68
  "@khanacademy/wonder-blocks-pill": "3.1.10",
@@ -98,6 +99,7 @@
98
99
  "@khanacademy/wonder-blocks-form": "7.1.10",
99
100
  "@khanacademy/wonder-blocks-icon": "5.1.3",
100
101
  "@khanacademy/wonder-blocks-icon-button": "9.0.4",
102
+ "@khanacademy/wonder-blocks-labeled-field": "3.0.6",
101
103
  "@khanacademy/wonder-blocks-layout": "3.1.9",
102
104
  "@khanacademy/wonder-blocks-link": "9.0.3",
103
105
  "@khanacademy/wonder-blocks-pill": "3.1.10",
@@ -1,14 +0,0 @@
1
- import type { PerseusStrings } from "../../strings";
2
- /**
3
- * This function is used to generate the a11y text for the radio widget.
4
- * It is used in the radio-component.tsx file to generate the a11y text for the radio widget.
5
- *
6
- * This function is a duplicate of the getA11yText function in choice-a11y-text.ts
7
- * for the Radio Revitalization Project. (LEMS-2933)
8
- *
9
- * This function will eventually replace choice-a11y-text.ts when the feature flag is no longer needed.
10
- *
11
- * TODO(LEMS-2994): Clean up this file.
12
- */
13
- declare function getA11yText(letter: string, checked: boolean, correct: boolean, crossedOut: boolean, showCorrectness: boolean, strings: PerseusStrings): string;
14
- export default getA11yText;