@khanacademy/perseus 21.6.0 → 22.0.1

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 (62) hide show
  1. package/dist/article-renderer.d.ts +6 -0
  2. package/dist/components/highlighting/ui/highlight-set-renderer.d.ts +14 -0
  3. package/dist/components/highlighting/ui/highlighting-ui.d.ts +17 -0
  4. package/dist/components/i18n-context.d.ts +16 -0
  5. package/dist/components/input-with-examples.d.ts +6 -0
  6. package/dist/components/math-input.d.ts +22 -2
  7. package/dist/components/number-input.d.ts +6 -0
  8. package/dist/es/index.js +883 -496
  9. package/dist/es/index.js.map +1 -1
  10. package/dist/es/strings.js +312 -0
  11. package/dist/es/strings.js.map +1 -0
  12. package/dist/hint-renderer.d.ts +6 -0
  13. package/dist/hints-renderer.d.ts +6 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1099 -534
  16. package/dist/index.js.map +1 -1
  17. package/dist/multi-items/multi-renderer.d.ts +6 -0
  18. package/dist/perseus-types.d.ts +3 -2
  19. package/dist/renderer.d.ts +2 -0
  20. package/dist/server-item-renderer.d.ts +6 -0
  21. package/dist/strings.d.ts +190 -0
  22. package/dist/strings.js +395 -119
  23. package/dist/strings.js.map +1 -0
  24. package/dist/types.d.ts +2 -1
  25. package/dist/util/answer-types.d.ts +4 -12
  26. package/dist/util.d.ts +2 -1
  27. package/dist/widgets/categorizer.d.ts +8 -1
  28. package/dist/widgets/definition.d.ts +6 -0
  29. package/dist/widgets/deprecated-standin/index.d.ts +6 -0
  30. package/dist/widgets/explanation.d.ts +6 -0
  31. package/dist/widgets/expression.d.ts +12 -1
  32. package/dist/widgets/graded-group-answer-bar.d.ts +6 -0
  33. package/dist/widgets/graded-group.d.ts +6 -0
  34. package/dist/widgets/group.d.ts +6 -0
  35. package/dist/widgets/image.d.ts +6 -0
  36. package/dist/widgets/input-number.d.ts +8 -1
  37. package/dist/widgets/interactive-graph.d.ts +6 -0
  38. package/dist/widgets/interactive-graphs/graphs/components/arrowhead.d.ts +1 -0
  39. package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +21 -0
  40. package/dist/widgets/interactive-graphs/locked-point.d.ts +1 -1
  41. package/dist/widgets/interactive-graphs/mafs-graph.d.ts +1 -0
  42. package/dist/widgets/interactive-graphs/reducer/use-graph-config.d.ts +1 -0
  43. package/dist/widgets/label-image/marker.d.ts +6 -0
  44. package/dist/widgets/label-image.d.ts +6 -0
  45. package/dist/widgets/matcher.d.ts +6 -0
  46. package/dist/widgets/matrix.d.ts +9 -1
  47. package/dist/widgets/molecule.d.ts +6 -0
  48. package/dist/widgets/number-line.d.ts +6 -0
  49. package/dist/widgets/numeric-input.d.ts +8 -1
  50. package/dist/widgets/passage-ref-target.d.ts +6 -0
  51. package/dist/widgets/passage-ref.d.ts +6 -0
  52. package/dist/widgets/passage.d.ts +6 -0
  53. package/dist/widgets/plotter.d.ts +6 -0
  54. package/dist/widgets/radio/choice-a11y-text.d.ts +2 -1
  55. package/dist/widgets/radio/radio.d.ts +8 -1
  56. package/dist/widgets/radio/util.d.ts +2 -1
  57. package/dist/widgets/table.d.ts +7 -0
  58. package/dist/widgets/unit.d.ts +8 -1
  59. package/dist/widgets/video.d.ts +6 -0
  60. package/dist/widgets.d.ts +2 -1
  61. package/package.json +18 -6
  62. package/dist/widgets/label-image/strings.d.ts +0 -3
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { PerseusI18nContext } from "../components/i18n-context";
2
3
  import Renderer from "../renderer";
3
4
  import type { Item, ContentNode, HintNode, TagsNode } from "./item-types";
4
5
  import type { Shape, ArrayShape } from "./shape-types";
@@ -55,6 +56,11 @@ type State = {
55
56
  renderError: Error | null | undefined;
56
57
  };
57
58
  declare class MultiRenderer extends React.Component<Props, State> {
59
+ static contextType: React.Context<{
60
+ strings: import("../strings").PerseusStrings;
61
+ locale: string;
62
+ }>;
63
+ context: React.ContextType<typeof PerseusI18nContext>;
58
64
  rendererDataTreeMapper: TreeMapper<ContentNode, ContentRendererData, HintNode, HintRendererData, TagsNode, null>;
59
65
  getRenderersMapper: TreeMapper<ContentRendererData, ContentRendererElement, HintRendererData, HintRendererElement, null, null>;
60
66
  constructor(props: Props);
@@ -347,8 +347,9 @@ export type PerseusInteractiveGraphWidgetOptions = {
347
347
  correct: PerseusGraphType;
348
348
  lockedFigures?: ReadonlyArray<LockedFigure>;
349
349
  };
350
- export declare const lockedFigureColors: readonly ["purple", "blue", "teal", "green", "gold", "red", "pink"];
351
- export type LockedFigureColor = (typeof lockedFigureColors)[number];
350
+ declare const lockedFigureColorNames: readonly ["blue", "green", "gray", "grayH", "grayI", "purple", "purpleD", "pink", "orange", "red"];
351
+ export type LockedFigureColor = (typeof lockedFigureColorNames)[number];
352
+ export declare const lockedFigureColors: Record<LockedFigureColor, string>;
352
353
  export type LockedFigure = LockedPointType | LockedLineType;
353
354
  export type LockedFigureType = LockedFigure["type"];
354
355
  export type LockedPointType = {
@@ -4,6 +4,7 @@ import TranslationLinter from "./translation-linter";
4
4
  import WidgetContainer from "./widget-container";
5
5
  import type { DependenciesContext } from "./dependencies";
6
6
  import type { PerseusRenderer, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions } from "./perseus-types";
7
+ import type { PerseusStrings } from "./strings";
7
8
  import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, PerseusScore, WidgetProps } from "./types";
8
9
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
9
10
  import "./styles/perseus-renderer.less";
@@ -86,6 +87,7 @@ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
86
87
  * Skip adding paragraph class
87
88
  */
88
89
  inline?: boolean;
90
+ strings: PerseusStrings;
89
91
  };
90
92
  type State = {
91
93
  translationLintErrors: ReadonlyArray<string>;
@@ -8,6 +8,7 @@ import * as PerseusLinter from "@khanacademy/perseus-linter";
8
8
  * This component is compatible with server-rendering of a perseus exercise.
9
9
  */
10
10
  import * as React from "react";
11
+ import { PerseusI18nContext } from "./components/i18n-context";
11
12
  import Renderer from "./renderer";
12
13
  import type { PerseusItem, ShowSolutions } from "./perseus-types";
13
14
  import type { APIOptions, FocusPath, PerseusDependenciesV2 } from "./types";
@@ -42,6 +43,11 @@ type SerializedState = {
42
43
  hints: any;
43
44
  };
44
45
  export declare class ServerItemRenderer extends React.Component<Props, State> implements RendererInterface, KeypadContextRendererInterface {
46
+ static contextType: React.Context<{
47
+ strings: import("./strings").PerseusStrings;
48
+ locale: string;
49
+ }>;
50
+ context: React.ContextType<typeof PerseusI18nContext>;
45
51
  questionRenderer: Renderer;
46
52
  hintsRenderer: any;
47
53
  _currentFocus: FocusPath;
@@ -0,0 +1,190 @@
1
+ /**
2
+ * The translated strings that are used to render Perseus.
3
+ */
4
+ export type PerseusStrings = {
5
+ closeKeypad: string;
6
+ openKeypad: string;
7
+ removeHighlight: string;
8
+ addHighlight: string;
9
+ hintPos: ({ pos }: {
10
+ pos: number;
11
+ }) => string;
12
+ errorRendering: ({ error }: {
13
+ error: string;
14
+ }) => string;
15
+ APPROXIMATED_PI_ERROR: string;
16
+ EXTRA_SYMBOLS_ERROR: string;
17
+ NEEDS_TO_BE_SIMPLFIED_ERROR: string;
18
+ MISSING_PERCENT_ERROR: string;
19
+ MULTIPLICATION_SIGN_ERROR: string;
20
+ WRONG_CASE_ERROR: string;
21
+ WRONG_LETTER_ERROR: string;
22
+ invalidSelection: string;
23
+ ERROR_TITLE: string;
24
+ ERROR_MESSAGE: string;
25
+ hints: string;
26
+ getAnotherHint: string;
27
+ deprecatedStandin: string;
28
+ keepTrying: string;
29
+ tryAgain: string;
30
+ check: string;
31
+ correctExcited: string;
32
+ nextQuestion: string;
33
+ skipToTitle: ({ title }: {
34
+ title: string;
35
+ }) => string;
36
+ current: string;
37
+ correct: string;
38
+ correctSelected: string;
39
+ correctCrossedOut: string;
40
+ incorrect: string;
41
+ incorrectSelected: string;
42
+ hideExplanation: string;
43
+ explain: string;
44
+ INVALID_MESSAGE_PREFIX: string;
45
+ DEFAULT_INVALID_MESSAGE_1: string;
46
+ DEFAULT_INVALID_MESSAGE_2: string;
47
+ integerExample: string;
48
+ properExample: string;
49
+ simplifiedProperExample: string;
50
+ improperExample: string;
51
+ simplifiedImproperExample: string;
52
+ mixedExample: string;
53
+ decimalExample: string;
54
+ percentExample: string;
55
+ piExample: string;
56
+ yourAnswer: string;
57
+ yourAnswerLabel: string;
58
+ addPoints: string;
59
+ addVertices: string;
60
+ tapMultiple: string;
61
+ tapSingle: string;
62
+ clickMultiple: string;
63
+ clickSingle: string;
64
+ choices: string;
65
+ answers: ({ num }: {
66
+ num: number;
67
+ }) => string;
68
+ hideAnswersToggleLabel: string;
69
+ moves: ({ num }: {
70
+ num: number;
71
+ }) => string;
72
+ clickTiles: string;
73
+ turnOffLights: string;
74
+ fillAllCells: string;
75
+ molecularDrawing: ({ content }: {
76
+ content: string;
77
+ }) => string;
78
+ switchDirection: string;
79
+ circleOpen: string;
80
+ circleFilled: string;
81
+ numDivisions: string;
82
+ divisions: ({ divRangeString }: {
83
+ divRangeString: string;
84
+ }) => string;
85
+ lineRange: ({ lineRange }: {
86
+ lineRange: string;
87
+ }) => string;
88
+ lineNumber: ({ lineNumber }: {
89
+ lineNumber: string;
90
+ }) => string;
91
+ symbolPassage: ({ questionSymbol, questionNumber, }: {
92
+ questionSymbol: string;
93
+ questionNumber: string;
94
+ }) => string;
95
+ symbolQuestion: ({ sentenceSymbol }: {
96
+ sentenceSymbol: string;
97
+ }) => string;
98
+ lineLabel: string;
99
+ beginningPassage: string;
100
+ beginningFootnotes: string;
101
+ endPassage: string;
102
+ questionMarker: ({ number }: {
103
+ number: string;
104
+ }) => string;
105
+ circleMarker: ({ number }: {
106
+ number: string;
107
+ }) => string;
108
+ sentenceMarker: ({ number }: {
109
+ number: string;
110
+ }) => string;
111
+ dragHandles: string;
112
+ tapAddPoints: string;
113
+ false: string;
114
+ true: string;
115
+ no: string;
116
+ yes: string;
117
+ chooseCorrectNum: string;
118
+ notNoneOfTheAbove: string;
119
+ noneOfTheAbove: string;
120
+ chooseNumAnswers: ({ numCorrect }: {
121
+ numCorrect: string;
122
+ }) => string;
123
+ chooseAllAnswers: string;
124
+ chooseOneAnswer: string;
125
+ choiceCheckedCorrect: ({ letter }: {
126
+ letter: string;
127
+ }) => string;
128
+ choiceCrossedOutCorrect: ({ letter }: {
129
+ letter: string;
130
+ }) => string;
131
+ choiceCorrect: ({ letter }: {
132
+ letter: string;
133
+ }) => string;
134
+ choiceCheckedIncorrect: ({ letter }: {
135
+ letter: string;
136
+ }) => string;
137
+ choiceCrossedOutIncorrect: ({ letter }: {
138
+ letter: string;
139
+ }) => string;
140
+ choiceIncorrect: ({ letter }: {
141
+ letter: string;
142
+ }) => string;
143
+ choiceChecked: ({ letter }: {
144
+ letter: string;
145
+ }) => string;
146
+ choiceCrossedOut: ({ letter }: {
147
+ letter: string;
148
+ }) => string;
149
+ choice: ({ letter }: {
150
+ letter: string;
151
+ }) => string;
152
+ crossOut: string;
153
+ crossOutOption: string;
154
+ crossOutChoice: ({ letter }: {
155
+ letter: string;
156
+ }) => string;
157
+ bringBack: string;
158
+ openMenuForChoice: ({ letter }: {
159
+ letter: string;
160
+ }) => string;
161
+ letters: string;
162
+ rightArrow: string;
163
+ dontUnderstandUnits: string;
164
+ checkSigFigs: string;
165
+ answerNumericallyIncorrect: string;
166
+ checkUnits: string;
167
+ dontUnderstand: string;
168
+ loading: string;
169
+ videoTranscript: string;
170
+ somethingWrong: string;
171
+ videoWrapper: string;
172
+ };
173
+ /**
174
+ * Untranslated strings used in Perseus. To be used by an external
175
+ * translator to produce translated strings, passed in as `PerseusStrings`.
176
+ */
177
+ export declare const strings: {
178
+ [key in keyof PerseusStrings]: string | {
179
+ context?: string;
180
+ message: string;
181
+ } | {
182
+ context?: string;
183
+ one: string;
184
+ other: string;
185
+ };
186
+ };
187
+ /**
188
+ * Mock strings for the Perseus package, to be used for tests and Storybook.
189
+ */
190
+ export declare const mockStrings: PerseusStrings;