@khanacademy/perseus-editor 2.15.2 → 2.15.4

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 (38) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/editor-page.d.ts +4 -10
  3. package/dist/editor.d.ts +2 -2
  4. package/dist/es/index.js +25 -14
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/index.js +25 -14
  7. package/dist/index.js.map +1 -1
  8. package/dist/widgets/interactive-graph-editor.d.ts +92 -92
  9. package/package.json +2 -2
  10. package/src/__stories__/editor-page.stories.tsx +65 -0
  11. package/src/__stories__/editor.stories.tsx +2 -4
  12. package/src/editor-page.tsx +5 -11
  13. package/src/editor.tsx +2 -2
  14. package/src/widgets/__stories__/categorizer-editor.stories.tsx +24 -0
  15. package/src/widgets/__stories__/definition-editor.stories.tsx +18 -0
  16. package/src/widgets/__stories__/dropdown-editor.stories.tsx +18 -0
  17. package/src/widgets/__stories__/explanation-editor.stories.tsx +18 -0
  18. package/src/widgets/__stories__/input-number-editor.stories.tsx +18 -0
  19. package/src/widgets/__stories__/matcher-editor.stories.tsx +18 -0
  20. package/src/widgets/__stories__/number-line-editor.stories.tsx +18 -0
  21. package/src/widgets/__stories__/numeric-input-editor.stories.tsx +18 -0
  22. package/src/widgets/__stories__/radio-editor.stories.tsx +3 -3
  23. package/src/widgets/__stories__/sorter-editor.stories.tsx +18 -0
  24. package/src/widgets/__tests__/categorizer-editor.test.tsx +51 -0
  25. package/src/widgets/__tests__/definition-editor.test.tsx +41 -0
  26. package/src/widgets/__tests__/dropdown-editor.test.tsx +57 -0
  27. package/src/widgets/__tests__/explanation-editor.test.tsx +59 -0
  28. package/src/widgets/__tests__/input-number-editor.test.tsx +128 -0
  29. package/src/widgets/__tests__/matcher-editor.test.tsx +47 -0
  30. package/src/widgets/__tests__/number-line-editor.test.tsx +144 -0
  31. package/src/widgets/__tests__/numeric-input-editor.test.tsx +177 -0
  32. package/src/widgets/__tests__/radio-editor.test.tsx +118 -0
  33. package/src/widgets/__tests__/sorter-editor.test.tsx +55 -0
  34. package/src/widgets/dropdown-editor.tsx +1 -0
  35. package/src/widgets/input-number-editor.tsx +2 -0
  36. package/src/widgets/number-line-editor.tsx +16 -5
  37. package/src/widgets/numeric-input-editor.tsx +2 -0
  38. package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @khanacademy/perseus-editor
2
2
 
3
+ ## 2.15.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#892](https://github.com/Khan/perseus/pull/892) [`22a8f42c`](https://github.com/Khan/perseus/commit/22a8f42c9e31cc74f1ab2f5a375ce5166353153f) Thanks [@handeyeco](https://github.com/handeyeco)! - add tests for NumberLineEditor
8
+
9
+ * [#887](https://github.com/Khan/perseus/pull/887) [`d09fdb98`](https://github.com/Khan/perseus/commit/d09fdb98963f23dbeb2009518513db671e0f09bb) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Add Storybook story for EditorPage component
10
+
11
+ - [#882](https://github.com/Khan/perseus/pull/882) [`6f1ddaa3`](https://github.com/Khan/perseus/commit/6f1ddaa3eae41d87aaf3514ab0f4cd7875b3125b) Thanks [@handeyeco](https://github.com/handeyeco)! - Add tests for RadioEditor
12
+
13
+ * [#893](https://github.com/Khan/perseus/pull/893) [`cbd51e81`](https://github.com/Khan/perseus/commit/cbd51e810cc6f6f406fa92b5faceb4fb3655bbb4) Thanks [@handeyeco](https://github.com/handeyeco)! - add tests for InputNumber
14
+
15
+ - [#884](https://github.com/Khan/perseus/pull/884) [`c2172fb9`](https://github.com/Khan/perseus/commit/c2172fb90f247b3a914eaf7eb01b7b15ceb1f0c0) Thanks [@handeyeco](https://github.com/handeyeco)! - Add tests for DropdownEditor
16
+
17
+ * [#891](https://github.com/Khan/perseus/pull/891) [`4fe720db`](https://github.com/Khan/perseus/commit/4fe720dbb388b71606bbf98c0606523b3eb3e395) Thanks [@handeyeco](https://github.com/handeyeco)! - add tests for DefinitionEditor
18
+
19
+ - [#890](https://github.com/Khan/perseus/pull/890) [`6607ed0d`](https://github.com/Khan/perseus/commit/6607ed0d81adedc84a201ddb4b55f32a78e92dc0) Thanks [@handeyeco](https://github.com/handeyeco)! - add tests for CategorizerEditor
20
+
21
+ * [#888](https://github.com/Khan/perseus/pull/888) [`68d8a766`](https://github.com/Khan/perseus/commit/68d8a766bfa769b8ab57c60e79be7080c6b32593) Thanks [@handeyeco](https://github.com/handeyeco)! - add tests for MatcherEditor
22
+
23
+ - [#886](https://github.com/Khan/perseus/pull/886) [`eeac31b7`](https://github.com/Khan/perseus/commit/eeac31b7be6ef2526f0f7ae20cc6bfa237581798) Thanks [@handeyeco](https://github.com/handeyeco)! - Add tests for SorterEditor
24
+
25
+ * [#885](https://github.com/Khan/perseus/pull/885) [`8e0eb5bc`](https://github.com/Khan/perseus/commit/8e0eb5bc7059c99054f9b13af9780c1103ebf5ee) Thanks [@handeyeco](https://github.com/handeyeco)! - Add tests for ExplanationEditor
26
+
27
+ - [#883](https://github.com/Khan/perseus/pull/883) [`0b90e681`](https://github.com/Khan/perseus/commit/0b90e681b7c81f76bca419c879c0985e3fa1226f) Thanks [@handeyeco](https://github.com/handeyeco)! - Add tests for NumericInputEditor
28
+
29
+ - Updated dependencies [[`c9db8185`](https://github.com/Khan/perseus/commit/c9db818510e2e0fd142c23298890dcad89a7549a), [`d09fdb98`](https://github.com/Khan/perseus/commit/d09fdb98963f23dbeb2009518513db671e0f09bb)]:
30
+ - @khanacademy/perseus@17.4.0
31
+
32
+ ## 2.15.3
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [[`fdc00c90`](https://github.com/Khan/perseus/commit/fdc00c90a19d3e241b3a5cdc2b1df5d761b24af3)]:
37
+ - @khanacademy/perseus@17.3.3
38
+
3
39
  ## 2.15.2
4
40
 
5
41
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { APIOptions, APIOptionsWithDefaults, ChangeHandler, DeviceType, Hint, ImageUploader, Version } from "@khanacademy/perseus";
2
+ import type { APIOptions, APIOptionsWithDefaults, ChangeHandler, DeviceType, Hint, ImageUploader, Version, PerseusItem } from "@khanacademy/perseus";
3
3
  import type { KEScore } from "@khanacademy/perseus-core";
4
4
  type Props = {
5
5
  apiOptions?: APIOptions;
@@ -18,14 +18,8 @@ type Props = {
18
18
  question?: any;
19
19
  previewURL: string;
20
20
  };
21
- type PerseusJson = {
22
- question: any;
23
- answerArea: any;
24
- hints: ReadonlyArray<Hint>;
25
- itemDataVersion?: Version;
26
- };
27
21
  type State = {
28
- json: PerseusJson;
22
+ json: PerseusItem;
29
23
  gradeMessage: string;
30
24
  wasAnswered: boolean;
31
25
  highlightLint: boolean;
@@ -49,9 +43,9 @@ declare class EditorPage extends React.Component<Props, State> {
49
43
  getSaveWarnings(): any;
50
44
  serialize(options?: {
51
45
  keepDeletedWidgets?: boolean;
52
- }): any | PerseusJson;
46
+ }): any | PerseusItem;
53
47
  handleChange: ChangeHandler;
54
- changeJSON: (newJson: PerseusJson) => void;
48
+ changeJSON: (newJson: PerseusItem) => void;
55
49
  scorePreview(): KEScore | null | undefined;
56
50
  render(): React.ReactNode;
57
51
  }
package/dist/editor.d.ts CHANGED
@@ -20,7 +20,7 @@ type Props = Readonly<{
20
20
  imageUploader?: (file: string, callback: (url: string) => unknown) => unknown;
21
21
  onChange: ChangeHandler;
22
22
  }>;
23
- type DeafultProps = {
23
+ type DefaultProps = {
24
24
  content: string;
25
25
  disabled: boolean;
26
26
  images: Record<any, any>;
@@ -41,7 +41,7 @@ declare class Editor extends React.Component<Props, State> {
41
41
  lastUserValue: string | null | undefined;
42
42
  deferredChange: any | null | undefined;
43
43
  widgetIds: any | null | undefined;
44
- static defaultProps: DeafultProps;
44
+ static defaultProps: DefaultProps;
45
45
  state: State;
46
46
  componentDidMount(): void;
47
47
  UNSAFE_componentWillReceiveProps(nextProps: Props): void;
package/dist/es/index.js CHANGED
@@ -24,7 +24,7 @@ import * as i18n$1 from '@khanacademy/wonder-blocks-i18n';
24
24
 
25
25
  // This file is processed by a Rollup plugin (replace) to inject the production
26
26
  const libName = "@khanacademy/perseus-editor";
27
- const libVersion = "2.15.2";
27
+ const libVersion = "2.15.4";
28
28
  addLibraryVersionToPerseusDebug(libName, libVersion);
29
29
 
30
30
  function _extends() {
@@ -26326,7 +26326,8 @@ class DropdownEditor extends React.Component {
26326
26326
  value: choice.content
26327
26327
  }), /*#__PURE__*/React.createElement("a", {
26328
26328
  href: "#",
26329
- className: "simple-button orange"
26329
+ className: "simple-button orange",
26330
+ "aria-label": "Delete choice"
26330
26331
  // eslint-disable-next-line react/jsx-no-bind
26331
26332
  // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
26332
26333
  ,
@@ -28536,6 +28537,7 @@ class InputNumberEditor extends React.Component {
28536
28537
  type: "text",
28537
28538
  disabled: !this.props.inexact,
28538
28539
  defaultValue: this.props.maxError,
28540
+ "aria-label": "Max error",
28539
28541
  onBlur: e => {
28540
28542
  const ans = "" + (Util.firstNumericalParse(e.target.value) || 0);
28541
28543
  e.target.value = ans;
@@ -28550,7 +28552,8 @@ class InputNumberEditor extends React.Component {
28550
28552
  this.props.onChange({
28551
28553
  answerType: e.target.value
28552
28554
  });
28553
- }
28555
+ },
28556
+ "aria-label": "Answer type"
28554
28557
  }, answerTypeOptions), /*#__PURE__*/React.createElement(InfoTip$f, null, /*#__PURE__*/React.createElement("p", null, "Use the default \"Numbers\" unless the answer must be in a specific form (e.g., question is about converting decimals to fractions)."))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("label", null, "Width", " ", /*#__PURE__*/React.createElement("select", {
28555
28558
  value: this.props.size,
28556
28559
  onChange: e => {
@@ -32444,18 +32447,24 @@ class NumberLineEditor extends React.Component {
32444
32447
  value: this.props.correctRel
32445
32448
  // @ts-expect-error - TS2322 - Type '(arg1: ChangeEvent<HTMLInputElement>) => void' is not assignable to type 'ChangeEventHandler<HTMLSelectElement>'.
32446
32449
  ,
32447
- onChange: this.onChangeRelation
32450
+ onChange: this.onChangeRelation,
32451
+ "aria-label": "Select relationship"
32448
32452
  }, /*#__PURE__*/React.createElement("option", {
32449
- value: "eq"
32450
- }, " = "), /*#__PURE__*/React.createElement("option", {
32451
- value: "lt"
32452
- }, " < "), /*#__PURE__*/React.createElement("option", {
32453
- value: "gt"
32454
- }, " > "), /*#__PURE__*/React.createElement("option", {
32455
- value: "le"
32456
- }, " \u2264 "), /*#__PURE__*/React.createElement("option", {
32457
- value: "ge"
32458
- }, " \u2265 ")), " ", /*#__PURE__*/React.createElement(NumberInput$7, {
32453
+ value: "eq",
32454
+ "aria-label": "Equal"
32455
+ }, "="), /*#__PURE__*/React.createElement("option", {
32456
+ value: "lt",
32457
+ "aria-label": "Less than"
32458
+ }, "<"), /*#__PURE__*/React.createElement("option", {
32459
+ value: "gt",
32460
+ "aria-label": "Greater than"
32461
+ }, ">"), /*#__PURE__*/React.createElement("option", {
32462
+ value: "le",
32463
+ "aria-label": "Less than or equal"
32464
+ }, "\u2264"), /*#__PURE__*/React.createElement("option", {
32465
+ value: "ge",
32466
+ "aria-label": "Greater than or equal"
32467
+ }, "\u2265")), " ", /*#__PURE__*/React.createElement(NumberInput$7, {
32459
32468
  value: this.props.correctX,
32460
32469
  format: this.props.labelStyle
32461
32470
  // eslint-disable-next-line react/jsx-no-bind
@@ -32848,11 +32857,13 @@ const NumericInputEditor = createReactClass({
32848
32857
  }, answer.status), /*#__PURE__*/React.createElement("a", {
32849
32858
  href: "javascript:void(0)",
32850
32859
  className: "answer-trash",
32860
+ "aria-label": "Delete answer",
32851
32861
  onClick: () => this.onTrashAnswer(i),
32852
32862
  onKeyDown: e => this.onSpace(e, this.onTrashAnswer, i)
32853
32863
  }, /*#__PURE__*/React.createElement(InlineIcon$3, iconTrash$2)), /*#__PURE__*/React.createElement("a", {
32854
32864
  href: "javascript:void(0)",
32855
32865
  className: "options-toggle",
32866
+ "aria-label": "Toggle options",
32856
32867
  onClick: () => this.onToggleOptions(i),
32857
32868
  onKeyDown: e => this.onSpace(e, this.onToggleOptions, i)
32858
32869
  }, /*#__PURE__*/React.createElement(InlineIcon$3, iconGear))), /*#__PURE__*/React.createElement("div", {