@khanacademy/perseus 19.1.2 → 19.1.3

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 (56) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/all-widgets.d.ts +1 -1
  3. package/dist/basic-widgets.d.ts +1 -1
  4. package/dist/es/index.js +14 -14
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/extra-widgets.d.ts +1 -1
  7. package/dist/index.js +14 -14
  8. package/dist/index.js.map +1 -1
  9. package/dist/types.d.ts +1 -1
  10. package/dist/widgets/categorizer.d.ts +1 -1
  11. package/dist/widgets/cs-program.d.ts +1 -1
  12. package/dist/widgets/definition.d.ts +1 -1
  13. package/dist/widgets/deprecated-standin/index.d.ts +1 -1
  14. package/dist/widgets/dropdown.d.ts +1 -1
  15. package/dist/widgets/explanation.d.ts +1 -1
  16. package/dist/widgets/expression.d.ts +14 -14
  17. package/dist/widgets/graded-group-set.d.ts +1 -1
  18. package/dist/widgets/graded-group.d.ts +1 -1
  19. package/dist/widgets/grapher.d.ts +1 -1
  20. package/dist/widgets/group.d.ts +1 -1
  21. package/dist/widgets/iframe.d.ts +1 -1
  22. package/dist/widgets/image.d.ts +1 -1
  23. package/dist/widgets/input-number.d.ts +1 -1
  24. package/dist/widgets/interaction.d.ts +1 -1
  25. package/dist/widgets/interactive-graph.d.ts +1 -1
  26. package/dist/widgets/label-image.d.ts +14 -14
  27. package/dist/widgets/lights-puzzle.d.ts +1 -1
  28. package/dist/widgets/matcher.d.ts +1 -1
  29. package/dist/widgets/matrix.d.ts +1 -1
  30. package/dist/widgets/measurer.d.ts +1 -1
  31. package/dist/widgets/molecule.d.ts +1 -1
  32. package/dist/widgets/number-line.d.ts +1 -1
  33. package/dist/widgets/numeric-input.d.ts +1 -1
  34. package/dist/widgets/orderer.d.ts +1 -1
  35. package/dist/widgets/passage-ref-target.d.ts +1 -1
  36. package/dist/widgets/passage-ref.d.ts +1 -1
  37. package/dist/widgets/passage.d.ts +1 -1
  38. package/dist/widgets/plotter.d.ts +1 -1
  39. package/dist/widgets/radio.d.ts +1 -1
  40. package/dist/widgets/reaction-diagram.d.ts +1 -1
  41. package/dist/widgets/sequence.d.ts +1 -1
  42. package/dist/widgets/simulator.d.ts +1 -1
  43. package/dist/widgets/sorter.d.ts +1 -1
  44. package/dist/widgets/table.d.ts +1 -1
  45. package/dist/widgets/unit.d.ts +1 -1
  46. package/dist/widgets/video.d.ts +1 -1
  47. package/package.json +2 -2
  48. package/src/__tests__/init.test.ts +10 -0
  49. package/src/init.ts +1 -4
  50. package/src/types.ts +4 -2
  51. package/src/widgets/__tests__/__snapshots__/input-number.test.ts.snap +1 -1
  52. package/src/widgets/__tests__/__snapshots__/numeric-input.test.ts.snap +1 -1
  53. package/src/widgets/label-image/marker.tsx +4 -0
  54. package/src/widgets/label-image.tsx +2 -7
  55. package/src/widgets.ts +4 -1
  56. package/tsconfig-build.tsbuildinfo +1 -1
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": "19.1.2",
6
+ "version": "19.1.3",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@khanacademy/kas": "^0.3.7",
26
26
  "@khanacademy/kmath": "^0.1.10",
27
- "@khanacademy/math-input": "^17.0.1",
27
+ "@khanacademy/math-input": "^17.0.2",
28
28
  "@khanacademy/perseus-core": "1.4.1",
29
29
  "@khanacademy/perseus-linter": "^0.3.10",
30
30
  "@khanacademy/pure-markdown": "^0.2.13",
@@ -0,0 +1,10 @@
1
+ import init from "../init";
2
+ import {getWidget} from "../widgets";
3
+
4
+ describe("init", () => {
5
+ it("should correctly replace the transformer widget", async () => {
6
+ await init({skipMathJax: true});
7
+
8
+ expect(getWidget("transformer")).not.toBeNull();
9
+ });
10
+ });
package/src/init.ts CHANGED
@@ -21,10 +21,7 @@ const init = function (options: PerseusOptions): Promise<undefined> {
21
21
  Widgets.registerWidgets(basicWidgets);
22
22
  Widgets.registerWidgets(extraWidgets);
23
23
 
24
- // This section replaces widgets
25
- // When it's time to replace the transformer widget
26
- // uncomment this line
27
- // Widgets.replaceWidget("transformer", "deprecated-standin");
24
+ Widgets.replaceWidget("transformer", "deprecated-standin");
28
25
 
29
26
  // Pass skipMathJax: true if MathJax is already loaded and configured.
30
27
  const skipMathJax = options.skipMathJax;
package/src/types.ts CHANGED
@@ -411,9 +411,13 @@ export type WidgetExports<
411
411
  > = Readonly<{
412
412
  name: string;
413
413
  displayName: string;
414
+
415
+ // Widgets should provide _one_ of these two properties only!
414
416
  // TODO: figure out how to ensure that the component returned supports
415
417
  // the `validate` method.
416
418
  getWidget?: () => T;
419
+ widget: T;
420
+
417
421
  accessible?: boolean | ((props: any) => boolean);
418
422
  /** Supresses widget from showing up in the dropdown in the content editor */
419
423
  hidden?: boolean;
@@ -449,8 +453,6 @@ export type WidgetExports<
449
453
  propUpgrades?: {
450
454
  [key: string]: (arg1: any) => any;
451
455
  }; // OldProps => NewProps,
452
-
453
- widget: T;
454
456
  }>;
455
457
 
456
458
  export type PerseusWidgetMap = {
@@ -182,7 +182,7 @@ exports[`rendering supports mobile rendering: mobile render 1`] = `
182
182
  class="mq-textarea"
183
183
  >
184
184
  <span
185
- aria-label="Math Input:"
185
+ aria-label="Math input box:"
186
186
  />
187
187
  </span>
188
188
  <span
@@ -44,7 +44,7 @@ exports[`Numeric input widget styles differently on mobile: mobile render 1`] =
44
44
  class="mq-textarea"
45
45
  >
46
46
  <span
47
- aria-label="Math Input:"
47
+ aria-label="Math input box:"
48
48
  />
49
49
  </span>
50
50
  <span
@@ -7,6 +7,7 @@
7
7
 
8
8
  import Color from "@khanacademy/wonder-blocks-color";
9
9
  import {View, type StyleType} from "@khanacademy/wonder-blocks-core";
10
+ import * as i18n from "@khanacademy/wonder-blocks-i18n";
10
11
  import {StyleSheet} from "aphrodite";
11
12
  import * as React from "react";
12
13
 
@@ -127,6 +128,7 @@ export default class Marker extends React.Component<Props> {
127
128
  answerStyles,
128
129
  hovered,
129
130
  focused,
131
+ label,
130
132
  } = this.props;
131
133
 
132
134
  // We cannot make dropdown openers untabbable, so we isolate tabbing
@@ -141,6 +143,8 @@ export default class Marker extends React.Component<Props> {
141
143
  styles.marker,
142
144
  active && !markerDisabled && styles.markerActive,
143
145
  ]}
146
+ // already translated in: /widgets/graded-group.tsx
147
+ aria-label={markerDisabled ? i18n._("Correct!") : label}
144
148
  >
145
149
  {this.renderIcon()}
146
150
  </View>
@@ -598,16 +598,11 @@ export class LabelImage extends React.Component<
598
598
  }
599
599
  // cannot change answer choices once question is answered
600
600
  disabled={disabled}
601
- opener={({opened, text}) => (
601
+ opener={({opened}) => (
602
602
  <Clickable
603
603
  role="button"
604
+ aria-expanded={opened}
604
605
  key={`marker-${marker.x}.${marker.y}`}
605
- aria-label={
606
- // already translated in: /widgets/graded-group.tsx
607
- showCorrectness === "correct"
608
- ? i18n._("Correct!")
609
- : marker.label
610
- }
611
606
  >
612
607
  {({hovered, focused, pressed}) => (
613
608
  <Marker
package/src/widgets.ts CHANGED
@@ -170,7 +170,10 @@ export const upgradeWidgetInfoToLatestVersion = (
170
170
  oldWidgetInfo: PerseusWidget,
171
171
  ): PerseusWidget => {
172
172
  const type = oldWidgetInfo.type;
173
- // TODO(LP-10707): Remove unnecessary type checking (`type` is a string)
173
+ // NOTE(jeremy): This looks like it could be replaced by fixing types so
174
+ // that `type` is non-optional. But we're seeing this in Sentry today so I
175
+ // suspect we have legacy data (potentially unpublished) and we should
176
+ // figure that out before depending solely on types.
174
177
  if (!_.isString(type)) {
175
178
  throw new PerseusError(
176
179
  "widget type must be a string, but was: " + type,