@khanacademy/perseus 0.4.3 → 1.1.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.
Files changed (71) hide show
  1. package/.eslintrc.js +6 -1
  2. package/CHANGELOG.md +45 -0
  3. package/dist/es/index.css +15 -8
  4. package/dist/es/index.js +1214 -1404
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/index.css +15 -8
  7. package/dist/index.js +1217 -1411
  8. package/dist/index.js.map +1 -1
  9. package/dist/strings.js +0 -4
  10. package/package.json +9 -8
  11. package/src/components/number-input.jsx +2 -2
  12. package/src/components/simple-keypad-input.jsx +18 -21
  13. package/src/index.js +1 -1
  14. package/src/multi-items/__tests__/__snapshots__/multi-renderer_test.js.snap +426 -135
  15. package/src/multi-items/__tests__/multi-renderer_test.js +9 -9
  16. package/src/perseus-api.jsx +10 -36
  17. package/src/perseus-types.js +18 -145
  18. package/src/styles/constants.js +0 -2
  19. package/src/styles/perseus-renderer.less +8 -2
  20. package/src/styles/variables.less +0 -2
  21. package/src/styles/widgets/passage.less +9 -5
  22. package/src/types.js +18 -35
  23. package/src/util/answer-types.js +2 -3
  24. package/src/util/math.js +3 -10
  25. package/src/util.js +0 -6
  26. package/src/version.js +1 -1
  27. package/src/widgets/__stories__/numeric-input.stories.jsx +43 -2
  28. package/src/widgets/__testdata__/base-radio_testdata.js +22 -0
  29. package/src/widgets/__tests__/__snapshots__/definition_test.js.snap +4 -4
  30. package/src/widgets/__tests__/__snapshots__/group_test.jsx.snap +291 -130
  31. package/src/widgets/__tests__/__snapshots__/radio_test.jsx.snap +3293 -1415
  32. package/src/widgets/__tests__/group_test.jsx +4 -4
  33. package/src/widgets/__tests__/numeric-input_test.jsx +12 -8
  34. package/src/widgets/__tests__/passage_test.jsx +81 -0
  35. package/src/widgets/__tests__/radio/base-radio_test.jsx +291 -41
  36. package/src/widgets/__tests__/radio/choice-icon_test.jsx +67 -0
  37. package/src/widgets/__tests__/radio/choice_test.jsx +302 -0
  38. package/src/widgets/__tests__/radio/focus-ring_test.jsx +23 -0
  39. package/src/widgets/__tests__/radio/option-status_test.jsx +65 -0
  40. package/src/widgets/__tests__/radio_test.jsx +39 -15
  41. package/src/widgets/definition.jsx +1 -1
  42. package/src/widgets/group.jsx +84 -102
  43. package/src/widgets/input-number.jsx +6 -1
  44. package/src/widgets/numeric-input.jsx +87 -80
  45. package/src/widgets/passage/__tests__/passage-markdown_test.jsx +0 -9
  46. package/src/widgets/passage/get-line-height-for-node.js +4 -5
  47. package/src/widgets/passage/passage-markdown.jsx +176 -120
  48. package/src/widgets/passage.jsx +48 -46
  49. package/src/widgets/radio/__stories__/base-radio.stories.jsx +164 -17
  50. package/src/widgets/radio/__stories__/choice-icon.stories.jsx +202 -111
  51. package/src/widgets/radio/__stories__/choice-none-above.stories.jsx +21 -6
  52. package/src/widgets/radio/__stories__/choice.stories.jsx +138 -0
  53. package/src/widgets/radio/__stories__/focus-ring.stories.jsx +29 -23
  54. package/src/widgets/radio/__stories__/option-status.stories.jsx +93 -99
  55. package/src/widgets/radio/base-radio.jsx +485 -556
  56. package/src/widgets/radio/choice-a11y-text.js +62 -0
  57. package/src/widgets/radio/choice-icon/choice-icon.jsx +87 -0
  58. package/src/widgets/radio/choice-icon/cross-out-line.jsx +55 -0
  59. package/src/widgets/radio/choice-icon/library-choice-icon.jsx +214 -0
  60. package/src/widgets/radio/choice-icon/sat-choice-icon.jsx +120 -0
  61. package/src/widgets/radio/choice-icon/shared-styles.js +17 -0
  62. package/src/widgets/radio/choice-none-above.jsx +49 -40
  63. package/src/widgets/radio/choice.jsx +319 -347
  64. package/src/widgets/radio/choice.jsx.fixture.js +0 -18
  65. package/src/widgets/radio/focus-ring.jsx +29 -22
  66. package/src/widgets/radio/option-status.jsx +58 -36
  67. package/src/widgets/radio/widget.jsx +181 -136
  68. package/src/widgets/radio.jsx +16 -17
  69. package/src/widgets/radio/__stories__/cross-out-button.stories.jsx +0 -64
  70. package/src/widgets/radio/choice-icon.jsx +0 -469
  71. package/src/widgets/radio/cross-out-button.jsx +0 -134
package/dist/strings.js CHANGED
@@ -36,8 +36,6 @@ module.exports = [
36
36
  i18n._("an integer, like $6$", {}),
37
37
  i18n._("Beginning of reading passage footnotes.", {}),
38
38
  i18n._("Beginning of reading passage.", {}),
39
- i18n._("Bring back", {}),
40
- i18n._("Bring back Choice %(letter)s", {}),
41
39
  i18n._("Check", {}),
42
40
  i18n._("Check your significant figures.", {}),
43
41
  i18n._("Check your units.", {}),
@@ -54,8 +52,6 @@ module.exports = [
54
52
  i18n._("Correct (but you crossed it out)", {}),
55
53
  i18n._("Correct (selected)", {}),
56
54
  i18n._("Correct!", {}),
57
- i18n._("Cross out", {}),
58
- i18n._("Cross out Choice %(letter)s", {}),
59
55
  // I18N: As in the command, "Dilate the polygon"
60
56
  i18n._("Dilate", {}),
61
57
  i18n._("dilation", {}),
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": "0.4.3",
6
+ "version": "1.1.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -21,12 +21,12 @@
21
21
  "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
22
22
  },
23
23
  "dependencies": {
24
- "@khanacademy/kas": "^0.2.6",
25
- "@khanacademy/kmath": "^0.0.7",
26
- "@khanacademy/math-input": "^0.6.2",
27
- "@khanacademy/perseus-linter": "^0.2.2",
28
- "@khanacademy/pure-markdown": "^0.1.2",
29
- "@khanacademy/simple-markdown": "^0.8.5",
24
+ "@khanacademy/kas": "^0.2.7",
25
+ "@khanacademy/kmath": "^0.0.8",
26
+ "@khanacademy/math-input": "^0.6.3",
27
+ "@khanacademy/perseus-linter": "^0.2.3",
28
+ "@khanacademy/pure-markdown": "^0.1.3",
29
+ "@khanacademy/simple-markdown": "^0.8.6",
30
30
  "mathquill": "git+https://git@github.com/Khan/mathquill.git#a9ae54e057c5c1acc8244a5627acbff29901d992"
31
31
  },
32
32
  "devDependencies": {
@@ -54,8 +54,9 @@
54
54
  "eslint-plugin-import": "^2.26.0",
55
55
  "intersection-observer": "^0.12.0",
56
56
  "jquery": "^2.1.1",
57
+ "katex": "^0.11.1",
57
58
  "lodash.debounce": "^4.0.8",
58
- "perseus-build-settings": "^0.0.4",
59
+ "perseus-build-settings": "^0.0.5",
59
60
  "prop-types": "^15.6.1",
60
61
  "react": "16.14.0",
61
62
  "react-dom": "16.14.0",
@@ -11,7 +11,7 @@ import _ from "underscore";
11
11
  import Util from "../util.js";
12
12
  import KhanMath from "../util/math.js";
13
13
 
14
- import type {Format} from "../util/math.js";
14
+ import type {MathFormat} from "../perseus-types";
15
15
 
16
16
  const {firstNumericalParse, captureScratchpadTouchStart} = Util;
17
17
  const toNumericString = KhanMath.toNumericString;
@@ -242,7 +242,7 @@ class NumberInput extends React.Component<$FlowFixMe, $FlowFixMe> {
242
242
  }
243
243
  };
244
244
 
245
- _setValue: (number, Format) => void = (val, format) => {
245
+ _setValue: (number, MathFormat) => void = (val, format) => {
246
246
  // eslint-disable-next-line react/no-string-refs
247
247
  $(ReactDOM.findDOMNode(this.refs.input)).val(
248
248
  toNumericString(val, format),
@@ -14,42 +14,35 @@ import {
14
14
  KeypadTypes,
15
15
  keypadElementPropType,
16
16
  } from "@khanacademy/math-input";
17
- import createReactClass from "create-react-class";
18
17
  import PropTypes from "prop-types";
19
18
  import * as React from "react";
20
19
 
21
- const SimpleKeypadInput: any = createReactClass({
22
- displayName: "SimpleKeypadInput",
23
-
24
- propTypes: {
25
- keypadElement: keypadElementPropType,
26
- onFocus: PropTypes.func,
27
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
28
- },
29
-
30
- componentDidMount: function () {
20
+ export default class SimpleKeypadInput extends React.Component<$FlowFixMe> {
21
+ componentDidMount() {
31
22
  // TODO(scottgrant): This is a hack to remove the deprecated call to
32
23
  // this.isMounted() but is still considered an anti-pattern.
33
24
  this._isMounted = true;
34
- },
25
+ }
35
26
 
36
- componentWillUnmount: function () {
27
+ componentWillUnmount() {
37
28
  this._isMounted = false;
38
- },
29
+ }
30
+
31
+ _isMounted: boolean = false;
39
32
 
40
33
  focus() {
41
34
  // $FlowFixMe[object-this-reference]
42
35
  this.refs.input.focus(); // eslint-disable-line react/no-string-refs
43
- },
36
+ }
44
37
 
45
38
  blur() {
46
39
  // $FlowFixMe[object-this-reference]
47
40
  this.refs.input.blur(); // eslint-disable-line react/no-string-refs
48
- },
41
+ }
49
42
 
50
- getValue: function () {
43
+ getValue(): string | number {
51
44
  return this.props.value;
52
- },
45
+ }
53
46
 
54
47
  render(): React.Node {
55
48
  // $FlowFixMe[object-this-reference]
@@ -85,7 +78,11 @@ const SimpleKeypadInput: any = createReactClass({
85
78
  {...rest}
86
79
  />
87
80
  );
88
- },
89
- });
81
+ }
82
+ }
90
83
 
91
- export default SimpleKeypadInput;
84
+ SimpleKeypadInput.propTypes = {
85
+ keypadElement: keypadElementPropType,
86
+ onFocus: PropTypes.func,
87
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
88
+ };
package/src/index.js CHANGED
@@ -121,11 +121,11 @@ export type {
121
121
  WidgetInfo,
122
122
  } from "./types.js";
123
123
  export type {
124
+ MathFormat,
124
125
  InputNumberWidget,
125
126
  PerseusRadioWidgetOptions,
126
127
  PerseusRenderer,
127
128
  } from "./perseus-types.js";
128
- export type {Format} from "./util/math.js";
129
129
  export type {Coord} from "./interactive2/types.js";
130
130
  export type {MarkerType} from "./widgets/label-image/types.js";
131
131