@khanacademy/perseus-editor 1.0.9 → 1.0.10

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Perseus editors",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "1.0.9",
6
+ "version": "1.0.10",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@khanacademy/kas": "^0.2.7",
25
25
  "@khanacademy/kmath": "^0.0.8",
26
- "@khanacademy/perseus": "^1.3.4"
26
+ "@khanacademy/perseus": "^1.3.5"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@khanacademy/wonder-blocks-button": "^2.11.5",
@@ -1,13 +1,14 @@
1
1
  /* eslint-disable react/sort-comp */
2
2
  // @flow
3
- import {components, Util} from "@khanacademy/perseus";
4
- import PropTypes from "prop-types";
3
+ import {components, Util, InputNumber} from "@khanacademy/perseus";
5
4
  import * as React from "react";
6
5
  import ReactDOM from "react-dom";
7
6
  import _ from "underscore";
8
7
 
9
8
  import BlurInput from "../components/blur-input.jsx";
10
9
 
10
+ import type {ParsedValue} from "@khanacademy/perseus";
11
+
11
12
  const {InfoTip} = components;
12
13
 
13
14
  const answerTypes = {
@@ -45,22 +46,44 @@ const answerTypes = {
45
46
  },
46
47
  };
47
48
 
48
- type Props = $FlowFixMe;
49
+ type Props = {|
50
+ value: number,
51
+ simplify: React.ElementConfig<typeof InputNumber.widget>["simplify"],
52
+ size: React.ElementConfig<typeof InputNumber.widget>["size"],
53
+ inexact: React.ElementConfig<
54
+ typeof InputNumber.widget,
55
+ >["reviewModeRubric"]["inexact"],
56
+ maxError: React.ElementConfig<
57
+ typeof InputNumber.widget,
58
+ >["reviewModeRubric"]["maxError"],
59
+ answerType: React.ElementConfig<typeof InputNumber.widget>["answerType"],
60
+ rightAlign: React.ElementConfig<typeof InputNumber.widget>["rightAlign"],
49
61
 
50
- class InputNumberEditor extends React.Component<Props> {
51
- static propTypes = {
52
- value: PropTypes.number,
53
- simplify: PropTypes.oneOf(["required", "optional", "enforced"]),
54
- size: PropTypes.oneOf(["normal", "small"]),
55
- inexact: PropTypes.bool,
56
- maxError: PropTypes.number,
57
- answerType: PropTypes.string,
58
- rightAlign: PropTypes.bool,
59
- };
62
+ onChange: ({|
63
+ value?: ParsedValue | 0,
64
+ simplify?: Props["simplify"],
65
+ size?: Props["size"],
66
+ inexact?: Props["inexact"],
67
+ maxError?: Props["maxError"],
68
+ answerType?: Props["answerType"],
69
+ rightAlign?: Props["rightAlign"],
70
+ |}) => void,
71
+ |};
72
+
73
+ type DefaultProps = {|
74
+ value: Props["value"],
75
+ simplify: Props["simplify"],
76
+ size: Props["size"],
77
+ inexact: Props["inexact"],
78
+ maxError: Props["maxError"],
79
+ answerType: Props["answerType"],
80
+ rightAlign: Props["rightAlign"],
81
+ |};
60
82
 
83
+ class InputNumberEditor extends React.Component<Props> {
61
84
  static widgetName: "input-number" = "input-number";
62
85
 
63
- static defaultProps: Props = {
86
+ static defaultProps: DefaultProps = {
64
87
  value: 0,
65
88
  simplify: "required",
66
89
  size: "normal",
@@ -245,25 +268,22 @@ class InputNumberEditor extends React.Component<Props> {
245
268
  };
246
269
 
247
270
  serialize: () => {|
248
- value: $FlowFixMe,
249
- simplify: $FlowFixMe,
250
- size: $FlowFixMe,
251
- inexact: $FlowFixMe,
252
- maxError: $FlowFixMe,
253
- answerType: $FlowFixMe,
254
- rightAlign: $FlowFixMe,
255
- |} = () => {
256
- return _.pick(
257
- this.props,
258
- "value",
259
- "simplify",
260
- "size",
261
- "inexact",
262
- "maxError",
263
- "answerType",
264
- "rightAlign",
265
- );
266
- };
271
+ value: Props["value"],
272
+ simplify: Props["simplify"],
273
+ size: Props["size"],
274
+ inexact: Props["inexact"],
275
+ maxError: Props["maxError"],
276
+ answerType: Props["answerType"],
277
+ rightAlign: Props["rightAlign"],
278
+ |} = () => ({
279
+ value: this.props.value,
280
+ simplify: this.props.simplify,
281
+ size: this.props.size,
282
+ inexact: this.props.inexact,
283
+ maxError: this.props.maxError,
284
+ answerType: this.props.answerType,
285
+ rightAlign: this.props.rightAlign,
286
+ });
267
287
  }
268
288
 
269
289
  export default InputNumberEditor;