@khanacademy/perseus-editor 1.1.1 → 2.0.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.
- package/.babelrc.js +1 -1
- package/.eslintrc.js +1 -0
- package/CHANGELOG.md +14 -0
- package/dist/all-editors.d.ts +2 -0
- package/dist/all-editors.js.flow +8 -0
- package/dist/all-widgets.d.ts +22 -0
- package/dist/all-widgets.js.flow +34 -0
- package/dist/article-editor.d.ts +59 -0
- package/dist/article-editor.js.flow +72 -0
- package/dist/components/blur-input.d.ts +19 -0
- package/dist/components/blur-input.js.flow +25 -0
- package/dist/components/checkbox.d.ts +20 -0
- package/dist/components/checkbox.js.flow +26 -0
- package/dist/components/device-framer.d.ts +15 -0
- package/dist/components/device-framer.js.flow +20 -0
- package/dist/components/drag-target.d.ts +2 -0
- package/dist/components/drag-target.js.flow +8 -0
- package/dist/components/dropdown-option.d.ts +35 -0
- package/dist/components/dropdown-option.js.flow +49 -0
- package/dist/components/form-wrapped-text-field.d.ts +48 -0
- package/dist/components/form-wrapped-text-field.js.flow +48 -0
- package/dist/components/graph-settings.d.ts +2 -0
- package/dist/components/graph-settings.js.flow +8 -0
- package/dist/components/hover-behavior.d.ts +85 -0
- package/dist/components/hover-behavior.js.flow +48 -0
- package/dist/components/json-editor.d.ts +2 -0
- package/dist/components/json-editor.js.flow +8 -0
- package/dist/components/link.d.ts +41 -0
- package/dist/components/link.js.flow +50 -0
- package/dist/components/simple-button.d.ts +16 -0
- package/dist/components/simple-button.js.flow +18 -0
- package/dist/components/sortable.d.ts +2 -0
- package/dist/components/sortable.js.flow +8 -0
- package/dist/components/util.d.ts +1 -0
- package/dist/components/util.js.flow +9 -0
- package/dist/components/viewport-resizer.d.ts +16 -0
- package/dist/components/viewport-resizer.js.flow +22 -0
- package/dist/diffs/__stories__/perseus-diff-wrapper.d.ts +5 -0
- package/dist/diffs/__stories__/perseus-diff-wrapper.js.flow +11 -0
- package/dist/diffs/article-diff.d.ts +50 -0
- package/dist/diffs/article-diff.js.flow +71 -0
- package/dist/diffs/item-diff.d.ts +23 -0
- package/dist/diffs/item-diff.js.flow +41 -0
- package/dist/diffs/renderer-diff.d.ts +22 -0
- package/dist/diffs/renderer-diff.js.flow +25 -0
- package/dist/diffs/split-diff.d.ts +2 -0
- package/dist/diffs/split-diff.js.flow +8 -0
- package/dist/diffs/string-array-diff.d.ts +2 -0
- package/dist/diffs/string-array-diff.js.flow +11 -0
- package/dist/diffs/structured-item-diff.d.ts +25 -0
- package/dist/diffs/structured-item-diff.js.flow +37 -0
- package/dist/diffs/tags-diff.d.ts +21 -0
- package/dist/diffs/tags-diff.js.flow +24 -0
- package/dist/diffs/text-diff.d.ts +15 -0
- package/dist/diffs/text-diff.js.flow +21 -0
- package/dist/diffs/widget-diff-performer.d.ts +2 -0
- package/dist/diffs/widget-diff-performer.js.flow +8 -0
- package/dist/diffs/widget-diff.d.ts +21 -0
- package/dist/diffs/widget-diff.js.flow +31 -0
- package/dist/editor-page.d.ts +57 -0
- package/dist/editor-page.js.flow +73 -0
- package/dist/editor.d.ts +82 -0
- package/dist/editor.js.flow +98 -0
- package/dist/es/index.js +1428 -2587
- package/dist/es/index.js.map +1 -1
- package/dist/hint-editor.d.ts +64 -0
- package/dist/hint-editor.js.flow +87 -0
- package/dist/i18n.d.ts +7 -0
- package/dist/i18n.js.flow +13 -0
- package/dist/iframe-content-renderer.d.ts +22 -0
- package/dist/iframe-content-renderer.js.flow +28 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +1492 -2548
- package/dist/index.js.flow +23 -2
- package/dist/index.js.map +1 -1
- package/dist/item-editor.d.ts +36 -0
- package/dist/item-editor.js.flow +46 -0
- package/dist/item-extras-editor.d.ts +17 -0
- package/dist/item-extras-editor.js.flow +23 -0
- package/dist/katex-error-view.d.ts +16 -0
- package/dist/katex-error-view.js.flow +24 -0
- package/dist/multirenderer-editor.d.ts +32 -0
- package/dist/multirenderer-editor.js.flow +46 -0
- package/dist/section-control-button.d.ts +12 -0
- package/dist/section-control-button.js.flow +20 -0
- package/dist/stateful-article-editor.d.ts +10 -0
- package/dist/stateful-article-editor.js.flow +16 -0
- package/dist/stateful-editor-page.d.ts +2 -0
- package/dist/stateful-editor-page.js.flow +8 -0
- package/dist/testing-widgets.d.ts +22 -0
- package/dist/testing-widgets.js.flow +34 -0
- package/dist/util/register-all-widgets-and-editors-for-testing.d.ts +1 -0
- package/dist/util/register-all-widgets-and-editors-for-testing.js.flow +7 -0
- package/dist/widgets/categorizer-editor.d.ts +47 -0
- package/dist/widgets/categorizer-editor.js.flow +61 -0
- package/dist/widgets/cs-program-editor.d.ts +21 -0
- package/dist/widgets/cs-program-editor.js.flow +25 -0
- package/dist/widgets/definition-editor.d.ts +17 -0
- package/dist/widgets/definition-editor.js.flow +23 -0
- package/dist/widgets/dropdown-editor.d.ts +23 -0
- package/dist/widgets/dropdown-editor.js.flow +37 -0
- package/dist/widgets/example-graphie-widget-editor.d.ts +18 -0
- package/dist/widgets/example-graphie-widget-editor.js.flow +25 -0
- package/dist/widgets/example-graphie-widget.d.ts +87 -0
- package/dist/widgets/example-graphie-widget.js.flow +101 -0
- package/dist/widgets/example-widget-editor.d.ts +19 -0
- package/dist/widgets/example-widget-editor.js.flow +26 -0
- package/dist/widgets/example-widget.d.ts +71 -0
- package/dist/widgets/example-widget.js.flow +86 -0
- package/dist/widgets/explanation-editor.d.ts +21 -0
- package/dist/widgets/explanation-editor.js.flow +27 -0
- package/dist/widgets/expression-editor.d.ts +33 -0
- package/dist/widgets/expression-editor.js.flow +41 -0
- package/dist/widgets/graded-group-editor.d.ts +53 -0
- package/dist/widgets/graded-group-editor.js.flow +67 -0
- package/dist/widgets/graded-group-set-editor.d.ts +51 -0
- package/dist/widgets/graded-group-set-editor.js.flow +65 -0
- package/dist/widgets/grapher-editor.d.ts +14 -0
- package/dist/widgets/grapher-editor.js.flow +21 -0
- package/dist/widgets/group-editor.d.ts +49 -0
- package/dist/widgets/group-editor.js.flow +63 -0
- package/dist/widgets/iframe-editor.d.ts +18 -0
- package/dist/widgets/iframe-editor.js.flow +24 -0
- package/dist/widgets/image-editor.d.ts +2 -0
- package/dist/widgets/image-editor.js.flow +8 -0
- package/dist/widgets/input-number-editor.d.ts +47 -0
- package/dist/widgets/input-number-editor.js.flow +77 -0
- package/dist/widgets/interaction/constraint-editor.d.ts +26 -0
- package/dist/widgets/interaction/constraint-editor.js.flow +35 -0
- package/dist/widgets/interaction-editor.d.ts +28 -0
- package/dist/widgets/interaction-editor.js.flow +36 -0
- package/dist/widgets/interactive-graph-editor.d.ts +2 -0
- package/dist/widgets/interactive-graph-editor.js.flow +8 -0
- package/dist/widgets/label-image/answer-choices.d.ts +13 -0
- package/dist/widgets/label-image/answer-choices.js.flow +16 -0
- package/dist/widgets/label-image/behavior.d.ts +14 -0
- package/dist/widgets/label-image/behavior.js.flow +17 -0
- package/dist/widgets/label-image/marker.d.ts +30 -0
- package/dist/widgets/label-image/marker.js.flow +34 -0
- package/dist/widgets/label-image/question-markers.d.ts +22 -0
- package/dist/widgets/label-image/question-markers.js.flow +25 -0
- package/dist/widgets/label-image/select-image.d.ts +10 -0
- package/dist/widgets/label-image/select-image.js.flow +13 -0
- package/dist/widgets/label-image-editor.d.ts +45 -0
- package/dist/widgets/label-image-editor.js.flow +44 -0
- package/dist/widgets/lights-puzzle-editor.d.ts +24 -0
- package/dist/widgets/lights-puzzle-editor.js.flow +34 -0
- package/dist/widgets/matcher-editor.d.ts +19 -0
- package/dist/widgets/matcher-editor.js.flow +28 -0
- package/dist/widgets/matrix-editor.d.ts +20 -0
- package/dist/widgets/matrix-editor.js.flow +26 -0
- package/dist/widgets/measurer-editor.d.ts +32 -0
- package/dist/widgets/measurer-editor.js.flow +42 -0
- package/dist/widgets/molecule-editor.d.ts +17 -0
- package/dist/widgets/molecule-editor.js.flow +23 -0
- package/dist/widgets/number-line-editor.d.ts +36 -0
- package/dist/widgets/number-line-editor.js.flow +45 -0
- package/dist/widgets/numeric-input-editor.d.ts +2 -0
- package/dist/widgets/numeric-input-editor.js.flow +8 -0
- package/dist/widgets/orderer-editor.d.ts +20 -0
- package/dist/widgets/orderer-editor.js.flow +30 -0
- package/dist/widgets/passage-editor.d.ts +18 -0
- package/dist/widgets/passage-editor.js.flow +24 -0
- package/dist/widgets/passage-ref-editor.d.ts +11 -0
- package/dist/widgets/passage-ref-editor.js.flow +17 -0
- package/dist/widgets/passage-ref-target-editor.d.ts +16 -0
- package/dist/widgets/passage-ref-target-editor.js.flow +22 -0
- package/dist/widgets/plotter-editor.d.ts +45 -0
- package/dist/widgets/plotter-editor.js.flow +53 -0
- package/dist/widgets/radio/editor.d.ts +64 -0
- package/dist/widgets/radio/editor.js.flow +80 -0
- package/dist/widgets/reaction-diagram-editor.d.ts +20 -0
- package/dist/widgets/reaction-diagram-editor.js.flow +26 -0
- package/dist/widgets/sequence-editor.d.ts +56 -0
- package/dist/widgets/sequence-editor.js.flow +72 -0
- package/dist/widgets/simple-markdown-tester-editor.d.ts +14 -0
- package/dist/widgets/simple-markdown-tester-editor.js.flow +23 -0
- package/dist/widgets/simple-markdown-tester.d.ts +52 -0
- package/dist/widgets/simple-markdown-tester.js.flow +61 -0
- package/dist/widgets/simulator-editor.d.ts +20 -0
- package/dist/widgets/simulator-editor.js.flow +26 -0
- package/dist/widgets/sorter-editor.d.ts +16 -0
- package/dist/widgets/sorter-editor.js.flow +22 -0
- package/dist/widgets/table-editor.d.ts +18 -0
- package/dist/widgets/table-editor.js.flow +24 -0
- package/dist/widgets/transformer-editor.d.ts +11 -0
- package/dist/widgets/transformer-editor.js.flow +17 -0
- package/dist/widgets/unit-editor.d.ts +33 -0
- package/dist/widgets/unit-editor.js.flow +41 -0
- package/dist/widgets/video-editor.d.ts +19 -0
- package/dist/widgets/video-editor.js.flow +25 -0
- package/package.json +6 -5
- package/src/__stories__/{editor.stories.js → editor.stories.tsx} +4 -5
- package/src/__stories__/{section-control-button.stories.jsx → section-control-button.stories.tsx} +10 -11
- package/src/__testdata__/{input-number_testdata.js → input-number.testdata.ts} +2 -3
- package/src/__tests__/{editor_test.jsx → editor.test.tsx} +4 -7
- package/src/__tests__/{i18n_test.jsx → i18n.test.ts} +5 -5
- package/src/__tests__/{traversal_test.jsx → traversal.test.ts} +9 -10
- package/src/{all-editors_test.js → all-editors.test.ts} +1 -2
- package/src/all-editors.ts +83 -0
- package/src/all-widgets.ts +7 -0
- package/src/{article-editor.jsx → article-editor.tsx} +52 -42
- package/src/components/__stories__/{blur-input.stories.jsx → blur-input.stories.tsx} +2 -4
- package/src/components/{blur-input.jsx → blur-input.tsx} +12 -13
- package/src/components/{checkbox.jsx → checkbox.tsx} +18 -19
- package/src/components/{device-framer.jsx → device-framer.tsx} +4 -5
- package/src/components/{drag-target.jsx → drag-target.tsx} +0 -1
- package/src/components/{dropdown-option.jsx → dropdown-option.tsx} +40 -40
- package/src/components/{form-wrapped-text-field.jsx → form-wrapped-text-field.tsx} +47 -53
- package/src/components/{graph-settings.jsx → graph-settings.tsx} +4 -8
- package/src/components/{hover-behavior.jsx → hover-behavior.ts} +32 -33
- package/src/components/{json-editor.jsx → json-editor.tsx} +4 -3
- package/src/components/{link.jsx → link.ts} +33 -33
- package/src/components/{simple-button.jsx → simple-button.tsx} +3 -4
- package/src/components/{sortable.jsx → sortable.tsx} +3 -3
- package/src/components/{util.js → util.ts} +1 -2
- package/src/components/{viewport-resizer.jsx → viewport-resizer.tsx} +5 -6
- package/src/diffs/__stories__/{perseus-diff-wrapper.jsx → perseus-diff-wrapper.tsx} +3 -2
- package/src/diffs/__stories__/{structured-item-diff.stories.jsx → structured-item-diff.stories.tsx} +27 -22
- package/src/diffs/__stories__/{tags-diff.stories.jsx → tags-diff.stories.tsx} +12 -14
- package/src/diffs/__stories__/{text-diff.stories.jsx → text-diff.stories.tsx} +12 -14
- package/src/diffs/__tests__/{split-diff_test.js → split-diff.test.ts} +1 -2
- package/src/diffs/__tests__/{string-array-diff_test.js → string-array-diff.test.ts} +1 -2
- package/src/diffs/__tests__/{structured-item-diff_test.js → structured-item-diff.test.ts} +15 -14
- package/src/diffs/__tests__/{widget-diff-performer_test.js → widget-diff-performer.test.ts} +1 -2
- package/src/diffs/{article-diff.jsx → article-diff.tsx} +5 -6
- package/src/diffs/{item-diff.jsx → item-diff.tsx} +4 -5
- package/src/diffs/{renderer-diff.jsx → renderer-diff.tsx} +22 -28
- package/src/diffs/{split-diff.jsx → split-diff.ts} +4 -3
- package/src/diffs/{string-array-diff.jsx → string-array-diff.ts} +8 -9
- package/src/diffs/{structured-item-diff.jsx → structured-item-diff.tsx} +32 -27
- package/src/diffs/{tags-diff.jsx → tags-diff.tsx} +15 -16
- package/src/diffs/{text-diff.jsx → text-diff.tsx} +13 -13
- package/src/diffs/{widget-diff-performer.jsx → widget-diff-performer.ts} +3 -8
- package/src/diffs/{widget-diff.jsx → widget-diff.tsx} +15 -14
- package/src/{editor-page.jsx → editor-page.tsx} +52 -60
- package/src/{editor.jsx → editor.tsx} +315 -277
- package/src/{hint-editor.jsx → hint-editor.tsx} +105 -79
- package/src/{i18n.jsx → i18n.ts} +9 -6
- package/src/{iframe-content-renderer.jsx → iframe-content-renderer.tsx} +23 -17
- package/src/{index.js → index.ts} +15 -16
- package/src/{item-editor.jsx → item-editor.tsx} +35 -30
- package/src/{item-extras-editor.jsx → item-extras-editor.tsx} +3 -4
- package/src/{katex-error-view.jsx → katex-error-view.tsx} +4 -5
- package/src/{multirenderer-editor.jsx → multirenderer-editor.tsx} +132 -127
- package/src/{section-control-button.jsx → section-control-button.tsx} +10 -9
- package/src/{stateful-article-editor.jsx → stateful-article-editor.tsx} +2 -5
- package/src/{stateful-editor-page.jsx → stateful-editor-page.tsx} +1 -3
- package/src/{testing-widgets.js → testing-widgets.ts} +5 -6
- package/src/util/{register-all-widgets-and-editors-for-testing_test.js → register-all-widgets-and-editors-for-testing.test.ts} +1 -2
- package/src/util/{register-all-widgets-and-editors-for-testing.js → register-all-widgets-and-editors-for-testing.ts} +2 -3
- package/src/widgets/__stories__/{label-image-editor.stories.jsx → label-image-editor.stories.tsx} +22 -18
- package/src/widgets/__stories__/{radio-editor.stories.jsx → radio-editor.stories.tsx} +15 -10
- package/src/widgets/{categorizer-editor.jsx → categorizer-editor.tsx} +8 -6
- package/src/widgets/{cs-program-editor.jsx → cs-program-editor.tsx} +17 -17
- package/src/widgets/{definition-editor.jsx → definition-editor.tsx} +9 -8
- package/src/widgets/{dropdown-editor.jsx → dropdown-editor.tsx} +27 -19
- package/src/widgets/{example-graphie-widget-editor.jsx → example-graphie-widget-editor.tsx} +8 -8
- package/src/widgets/{example-graphie-widget.jsx → example-graphie-widget.tsx} +14 -17
- package/src/widgets/{example-widget-editor.jsx → example-widget-editor.tsx} +10 -7
- package/src/widgets/{example-widget.jsx → example-widget.tsx} +14 -12
- package/src/widgets/{explanation-editor.jsx → explanation-editor.tsx} +12 -10
- package/src/widgets/{expression-editor.jsx → expression-editor.tsx} +36 -26
- package/src/widgets/{graded-group-editor.jsx → graded-group-editor.tsx} +18 -10
- package/src/widgets/{graded-group-set-editor.jsx → graded-group-set-editor.tsx} +15 -12
- package/src/widgets/{grapher-editor.jsx → grapher-editor.tsx} +10 -9
- package/src/widgets/{group-editor.jsx → group-editor.tsx} +11 -9
- package/src/widgets/{iframe-editor.jsx → iframe-editor.tsx} +16 -13
- package/src/widgets/{image-editor.jsx → image-editor.tsx} +4 -7
- package/src/widgets/{input-number-editor.jsx → input-number-editor.tsx} +61 -47
- package/src/widgets/interaction/{constraint-editor.jsx → constraint-editor.tsx} +21 -24
- package/src/widgets/{interaction-editor.jsx → interaction-editor.tsx} +160 -61
- package/src/widgets/{interactive-graph-editor.jsx → interactive-graph-editor.tsx} +13 -10
- package/src/widgets/label-image/__stories__/{answer-choices.stories.jsx → answer-choices.stories.tsx} +22 -17
- package/src/widgets/label-image/__stories__/{behavior.stories.jsx → behavior.stories.tsx} +9 -10
- package/src/widgets/label-image/__stories__/{marker.stories.jsx → marker.stories.tsx} +11 -12
- package/src/widgets/label-image/__stories__/{question-markers.stories.jsx → question-markers.stories.tsx} +17 -16
- package/src/widgets/label-image/__stories__/{select-image.stories.jsx → select-image.stories.tsx} +12 -13
- package/src/widgets/label-image/{answer-choices.jsx → answer-choices.tsx} +18 -18
- package/src/widgets/label-image/{behavior.jsx → behavior.tsx} +9 -11
- package/src/widgets/label-image/{marker.jsx → marker.tsx} +17 -19
- package/src/widgets/label-image/{question-markers.jsx → question-markers.tsx} +16 -21
- package/src/widgets/label-image/{select-image.jsx → select-image.tsx} +5 -7
- package/src/widgets/{label-image-editor.jsx → label-image-editor.tsx} +38 -44
- package/src/widgets/{lights-puzzle-editor.jsx → lights-puzzle-editor.tsx} +34 -24
- package/src/widgets/{matcher-editor.jsx → matcher-editor.tsx} +9 -7
- package/src/widgets/{matrix-editor.jsx → matrix-editor.tsx} +10 -9
- package/src/widgets/{measurer-editor.jsx → measurer-editor.tsx} +21 -14
- package/src/widgets/{molecule-editor.jsx → molecule-editor.tsx} +9 -8
- package/src/widgets/{number-line-editor.jsx → number-line-editor.tsx} +19 -17
- package/src/widgets/{numeric-input-editor.jsx → numeric-input-editor.tsx} +10 -10
- package/src/widgets/{orderer-editor.jsx → orderer-editor.tsx} +17 -12
- package/src/widgets/{passage-editor.jsx → passage-editor.tsx} +9 -7
- package/src/widgets/{passage-ref-editor.jsx → passage-ref-editor.tsx} +8 -6
- package/src/widgets/{passage-ref-target-editor.jsx → passage-ref-target-editor.tsx} +9 -7
- package/src/widgets/{plotter-editor.jsx → plotter-editor.tsx} +34 -33
- package/src/widgets/radio/{editor.jsx → editor.tsx} +22 -21
- package/src/widgets/{reaction-diagram-editor.jsx → reaction-diagram-editor.tsx} +14 -10
- package/src/widgets/{sequence-editor.jsx → sequence-editor.tsx} +13 -13
- package/src/widgets/{simple-markdown-tester-editor.jsx → simple-markdown-tester-editor.tsx} +11 -9
- package/src/widgets/{simple-markdown-tester.jsx → simple-markdown-tester.tsx} +8 -7
- package/src/widgets/{simulator-editor.jsx → simulator-editor.tsx} +10 -8
- package/src/widgets/{sorter-editor.jsx → sorter-editor.tsx} +8 -6
- package/src/widgets/{table-editor.jsx → table-editor.tsx} +11 -10
- package/src/widgets/{transformer-editor.jsx → transformer-editor.tsx} +37 -35
- package/src/widgets/{unit-editor.jsx → unit-editor.tsx} +31 -25
- package/src/widgets/{video-editor.jsx → video-editor.tsx} +8 -9
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/all-editors.js +0 -85
- package/src/all-widgets.js +0 -10
- /package/dist/{strings.js → strings} +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/* eslint-disable react/forbid-prop-types, react/no-unsafe */
|
|
2
|
-
// @flow
|
|
3
2
|
import {ApiOptions, Changeable} from "@khanacademy/perseus";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import _ from "underscore";
|
|
7
6
|
|
|
8
|
-
import GradedGroupEditor from "./graded-group-editor
|
|
7
|
+
import GradedGroupEditor from "./graded-group-editor";
|
|
9
8
|
|
|
10
|
-
type Props =
|
|
9
|
+
type Props = any;
|
|
11
10
|
|
|
12
11
|
class GradedGroupSetEditor extends React.Component<Props> {
|
|
13
|
-
//
|
|
14
|
-
_editors: Array
|
|
12
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property '_editors' has no initializer and is not definitely assigned in the constructor.
|
|
13
|
+
_editors: Array<any>;
|
|
15
14
|
|
|
16
15
|
static propTypes = {
|
|
17
16
|
...Changeable.propTypes,
|
|
@@ -20,7 +19,7 @@ class GradedGroupSetEditor extends React.Component<Props> {
|
|
|
20
19
|
onChange: PropTypes.func.isRequired,
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
static widgetName
|
|
22
|
+
static widgetName = "graded-group-set" as const;
|
|
24
23
|
|
|
25
24
|
static defaultProps: Props = {
|
|
26
25
|
gradedGroups: [],
|
|
@@ -31,11 +30,11 @@ class GradedGroupSetEditor extends React.Component<Props> {
|
|
|
31
30
|
this._editors = [];
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
change: (
|
|
33
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
35
34
|
return Changeable.change.apply(this, args);
|
|
36
35
|
};
|
|
37
36
|
|
|
38
|
-
getSaveWarnings: () =>
|
|
37
|
+
getSaveWarnings: () => ReadonlyArray<any> = () => {
|
|
39
38
|
return [].concat(
|
|
40
39
|
...this._editors.map((editor) =>
|
|
41
40
|
editor ? editor.getSaveWarnings() : [],
|
|
@@ -43,13 +42,15 @@ class GradedGroupSetEditor extends React.Component<Props> {
|
|
|
43
42
|
);
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
serialize: () => {
|
|
45
|
+
serialize: () => {
|
|
46
|
+
gradedGroups: any;
|
|
47
|
+
} = () => {
|
|
47
48
|
return {
|
|
48
49
|
gradedGroups: this.props.gradedGroups,
|
|
49
50
|
};
|
|
50
51
|
};
|
|
51
52
|
|
|
52
|
-
renderGroups: () => React.
|
|
53
|
+
renderGroups: () => React.ReactElement = () => {
|
|
53
54
|
if (!this.props.gradedGroups) {
|
|
54
55
|
return null;
|
|
55
56
|
}
|
|
@@ -62,6 +63,7 @@ class GradedGroupSetEditor extends React.Component<Props> {
|
|
|
62
63
|
widgetEnabled={true}
|
|
63
64
|
immutableWidgets={false}
|
|
64
65
|
onChange={(data) =>
|
|
66
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
|
|
65
67
|
this.change(
|
|
66
68
|
"gradedGroups",
|
|
67
69
|
setArrayItem(this.props.gradedGroups, i, {
|
|
@@ -76,13 +78,14 @@ class GradedGroupSetEditor extends React.Component<Props> {
|
|
|
76
78
|
|
|
77
79
|
addGroup: () => void = () => {
|
|
78
80
|
const groups = this.props.gradedGroups || [];
|
|
81
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
|
|
79
82
|
this.change(
|
|
80
83
|
"gradedGroups",
|
|
81
84
|
groups.concat([GradedGroupEditor.defaultProps]),
|
|
82
85
|
);
|
|
83
86
|
};
|
|
84
87
|
|
|
85
|
-
render(): React.
|
|
88
|
+
render(): React.ReactNode {
|
|
86
89
|
return (
|
|
87
90
|
<div className="perseus-group-editor">
|
|
88
91
|
{this.renderGroups()}
|
|
@@ -92,7 +95,7 @@ class GradedGroupSetEditor extends React.Component<Props> {
|
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
const setArrayItem = (list, i, value) => [
|
|
98
|
+
const setArrayItem = (list, i: any, value) => [
|
|
96
99
|
...list.slice(0, i),
|
|
97
100
|
value,
|
|
98
101
|
...list.slice(i + 1),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {
|
|
4
3
|
components,
|
|
5
4
|
Changeable,
|
|
@@ -10,7 +9,7 @@ import {
|
|
|
10
9
|
import * as React from "react";
|
|
11
10
|
import _ from "underscore";
|
|
12
11
|
|
|
13
|
-
import GraphSettings from "../components/graph-settings
|
|
12
|
+
import GraphSettings from "../components/graph-settings";
|
|
14
13
|
|
|
15
14
|
const {InfoTip, MultiButtonGroup} = components;
|
|
16
15
|
const {containerSizeClass, getInteractiveBoxFromSizeClass} = SizingUtils;
|
|
@@ -24,14 +23,14 @@ const {
|
|
|
24
23
|
typeToButton,
|
|
25
24
|
} = GrapherUtil;
|
|
26
25
|
|
|
27
|
-
type Props =
|
|
26
|
+
type Props = any;
|
|
28
27
|
|
|
29
28
|
class GrapherEditor extends React.Component<Props> {
|
|
30
29
|
static propTypes = {
|
|
31
30
|
...Changeable.propTypes,
|
|
32
31
|
};
|
|
33
32
|
|
|
34
|
-
static widgetName
|
|
33
|
+
static widgetName = "grapher" as const;
|
|
35
34
|
|
|
36
35
|
static defaultProps: Props = {
|
|
37
36
|
correct: DEFAULT_GRAPHER_PROPS.plot,
|
|
@@ -39,11 +38,11 @@ class GrapherEditor extends React.Component<Props> {
|
|
|
39
38
|
availableTypes: DEFAULT_GRAPHER_PROPS.availableTypes,
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
change: (
|
|
41
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
43
42
|
return Changeable.change.apply(this, args);
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
render(): React.
|
|
45
|
+
render(): React.ReactNode {
|
|
47
46
|
const sizeClass = containerSizeClass.SMALL;
|
|
48
47
|
let equationString;
|
|
49
48
|
let graph;
|
|
@@ -63,13 +62,14 @@ class GrapherEditor extends React.Component<Props> {
|
|
|
63
62
|
this.props.onChange({correct: correct}, cb);
|
|
64
63
|
},
|
|
65
64
|
trackInteraction: function () {},
|
|
66
|
-
};
|
|
65
|
+
} as const;
|
|
67
66
|
|
|
68
67
|
graph = (
|
|
69
68
|
// NOTE(jeremy): This editor doesn't pass in a bunch of
|
|
70
69
|
// standard props that the Renderer provides normally (eg.
|
|
71
70
|
// alignment, findWidgets, etc).
|
|
72
71
|
// $FlowFixMe[prop-missing]
|
|
72
|
+
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
|
|
73
73
|
<Grapher
|
|
74
74
|
{...graphProps}
|
|
75
75
|
apiOptions={this.props.apiOptions}
|
|
@@ -111,6 +111,7 @@ class GrapherEditor extends React.Component<Props> {
|
|
|
111
111
|
rulerLabel={this.props.graph.rulerLabel}
|
|
112
112
|
rulerTicks={this.props.graph.rulerTicks}
|
|
113
113
|
showTooltips={this.props.graph.showTooltips}
|
|
114
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
114
115
|
onChange={this.change("graph")}
|
|
115
116
|
/>
|
|
116
117
|
<div className="perseus-widget-row">
|
|
@@ -127,7 +128,7 @@ class GrapherEditor extends React.Component<Props> {
|
|
|
127
128
|
);
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
handleAvailableTypesChange
|
|
131
|
+
handleAvailableTypesChange = (newAvailableTypes: Array<any>) => {
|
|
131
132
|
let correct = this.props.correct;
|
|
132
133
|
|
|
133
134
|
// If the currently 'correct' type is removed from the list of types,
|
|
@@ -143,7 +144,7 @@ class GrapherEditor extends React.Component<Props> {
|
|
|
143
144
|
});
|
|
144
145
|
};
|
|
145
146
|
|
|
146
|
-
serialize: () =>
|
|
147
|
+
serialize: () => any = () => {
|
|
147
148
|
return _.chain(this.props)
|
|
148
149
|
.pick("correct", "availableTypes")
|
|
149
150
|
.extend({graph: _.omit(this.props.graph, "box")})
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* eslint-disable react/forbid-prop-types, react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {ApiOptions, Changeable} from "@khanacademy/perseus";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import _ from "underscore";
|
|
7
6
|
|
|
8
|
-
import Editor from "../editor
|
|
7
|
+
import Editor from "../editor";
|
|
9
8
|
|
|
10
|
-
type Props =
|
|
9
|
+
type Props = any;
|
|
11
10
|
|
|
12
11
|
class GroupEditor extends React.Component<Props> {
|
|
13
12
|
static propTypes = {
|
|
@@ -19,7 +18,7 @@ class GroupEditor extends React.Component<Props> {
|
|
|
19
18
|
apiOptions: ApiOptions.propTypes,
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
static widgetName
|
|
21
|
+
static widgetName = "group" as const;
|
|
23
22
|
|
|
24
23
|
static defaultProps: Props = {
|
|
25
24
|
content: "",
|
|
@@ -30,7 +29,7 @@ class GroupEditor extends React.Component<Props> {
|
|
|
30
29
|
metadata: undefined,
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
render(): React.
|
|
32
|
+
render(): React.ReactNode {
|
|
34
33
|
return (
|
|
35
34
|
<div className="perseus-group-editor">
|
|
36
35
|
<div>
|
|
@@ -53,27 +52,30 @@ class GroupEditor extends React.Component<Props> {
|
|
|
53
52
|
);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
_renderMetadataEditor: () => React.
|
|
55
|
+
_renderMetadataEditor: () => React.ReactElement = () => {
|
|
57
56
|
const GroupMetadataEditor = this.props.apiOptions.GroupMetadataEditor;
|
|
58
57
|
return (
|
|
59
58
|
<GroupMetadataEditor
|
|
60
59
|
value={this.props.metadata}
|
|
60
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
61
61
|
onChange={this.change("metadata")}
|
|
62
62
|
/>
|
|
63
63
|
);
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
change: (
|
|
66
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
67
67
|
return Changeable.change.apply(this, args);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
getSaveWarnings: () =>
|
|
70
|
+
getSaveWarnings: () => ReadonlyArray<any> = () => {
|
|
71
71
|
// eslint-disable-next-line react/no-string-refs
|
|
72
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
72
73
|
return this.refs.editor.getSaveWarnings();
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
serialize: () =>
|
|
76
|
+
serialize: () => any = () => {
|
|
76
77
|
// eslint-disable-next-line react/no-string-refs
|
|
78
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
77
79
|
return _.extend({}, this.refs.editor.serialize(), {
|
|
78
80
|
metadata: this.props.metadata,
|
|
79
81
|
});
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {components, Changeable, EditorJsonify} from "@khanacademy/perseus";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import _ from "underscore";
|
|
7
6
|
|
|
8
|
-
import BlurInput from "../components/blur-input
|
|
7
|
+
import BlurInput from "../components/blur-input";
|
|
9
8
|
|
|
10
9
|
const {PropCheckBox} = components;
|
|
11
10
|
|
|
12
|
-
type PairEditorProps =
|
|
11
|
+
type PairEditorProps = any;
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* This is used for editing a name/value pair.
|
|
@@ -30,7 +29,7 @@ class PairEditor extends React.Component<PairEditorProps> {
|
|
|
30
29
|
return Changeable.change.apply(this, args);
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
render(): React.
|
|
32
|
+
render(): React.ReactNode {
|
|
34
33
|
return (
|
|
35
34
|
<fieldset>
|
|
36
35
|
<label>
|
|
@@ -58,7 +57,7 @@ class PairEditor extends React.Component<PairEditorProps> {
|
|
|
58
57
|
};
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
type PairsEditorProps =
|
|
60
|
+
type PairsEditorProps = any;
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
63
|
* This is used for editing a set of name/value pairs.
|
|
@@ -74,7 +73,7 @@ class PairsEditor extends React.Component<PairsEditorProps> {
|
|
|
74
73
|
).isRequired,
|
|
75
74
|
};
|
|
76
75
|
|
|
77
|
-
render(): React.
|
|
76
|
+
render(): React.ReactNode {
|
|
78
77
|
const editors = _.map(this.props.pairs, (pair, i) => {
|
|
79
78
|
return (
|
|
80
79
|
<PairEditor
|
|
@@ -93,7 +92,7 @@ class PairsEditor extends React.Component<PairsEditorProps> {
|
|
|
93
92
|
return Changeable.change.apply(this, args);
|
|
94
93
|
};
|
|
95
94
|
|
|
96
|
-
handlePairChange = (pairIndex, pair) => {
|
|
95
|
+
handlePairChange = (pairIndex: any, pair: any) => {
|
|
97
96
|
// If they're both non empty, add a new one
|
|
98
97
|
const pairs = this.props.pairs.slice();
|
|
99
98
|
pairs[pairIndex] = pair;
|
|
@@ -110,7 +109,7 @@ class PairsEditor extends React.Component<PairsEditorProps> {
|
|
|
110
109
|
};
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
type IframeEditorProps =
|
|
112
|
+
type IframeEditorProps = any;
|
|
114
113
|
|
|
115
114
|
/**
|
|
116
115
|
* This is the main editor for this widget, to specify all the options.
|
|
@@ -120,7 +119,7 @@ class IframeEditor extends React.Component<IframeEditorProps> {
|
|
|
120
119
|
...Changeable.propTypes,
|
|
121
120
|
};
|
|
122
121
|
|
|
123
|
-
static widgetName
|
|
122
|
+
static widgetName = "iframe" as const;
|
|
124
123
|
|
|
125
124
|
static defaultProps: IframeEditorProps = {
|
|
126
125
|
url: "",
|
|
@@ -131,11 +130,11 @@ class IframeEditor extends React.Component<IframeEditorProps> {
|
|
|
131
130
|
allowTopNavigation: false,
|
|
132
131
|
};
|
|
133
132
|
|
|
134
|
-
change: (
|
|
133
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
135
134
|
return Changeable.change.apply(this, args);
|
|
136
135
|
};
|
|
137
136
|
|
|
138
|
-
render(): React.
|
|
137
|
+
render(): React.ReactNode {
|
|
139
138
|
return (
|
|
140
139
|
<div>
|
|
141
140
|
<div style={{fontWeight: "bold", textAlign: "center"}}>
|
|
@@ -146,6 +145,7 @@ class IframeEditor extends React.Component<IframeEditorProps> {
|
|
|
146
145
|
Url or Program ID:
|
|
147
146
|
<BlurInput
|
|
148
147
|
value={this.props.url}
|
|
148
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
149
149
|
onChange={this.change("url")}
|
|
150
150
|
/>
|
|
151
151
|
</label>
|
|
@@ -163,6 +163,7 @@ class IframeEditor extends React.Component<IframeEditorProps> {
|
|
|
163
163
|
Width:
|
|
164
164
|
<BlurInput
|
|
165
165
|
value={this.props.width}
|
|
166
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
166
167
|
onChange={this.change("width")}
|
|
167
168
|
/>
|
|
168
169
|
</label>
|
|
@@ -170,6 +171,7 @@ class IframeEditor extends React.Component<IframeEditorProps> {
|
|
|
170
171
|
Height:
|
|
171
172
|
<BlurInput
|
|
172
173
|
value={this.props.height}
|
|
174
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
173
175
|
onChange={this.change("height")}
|
|
174
176
|
/>
|
|
175
177
|
</label>
|
|
@@ -188,11 +190,12 @@ class IframeEditor extends React.Component<IframeEditorProps> {
|
|
|
188
190
|
);
|
|
189
191
|
}
|
|
190
192
|
|
|
191
|
-
handleSettingsChange: (
|
|
193
|
+
handleSettingsChange: (arg1: any) => void = (settings) => {
|
|
194
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
192
195
|
this.change({settings: settings.pairs});
|
|
193
196
|
};
|
|
194
197
|
|
|
195
|
-
serialize: () =>
|
|
198
|
+
serialize: () => any = () => {
|
|
196
199
|
return EditorJsonify.serialize.call(this);
|
|
197
200
|
};
|
|
198
201
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable jsx-a11y/anchor-is-valid, react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {
|
|
4
3
|
components,
|
|
5
4
|
icons,
|
|
@@ -11,8 +10,8 @@ import createReactClass from "create-react-class";
|
|
|
11
10
|
import * as React from "react";
|
|
12
11
|
import _ from "underscore";
|
|
13
12
|
|
|
14
|
-
import BlurInput from "../components/blur-input
|
|
15
|
-
import Editor from "../editor
|
|
13
|
+
import BlurInput from "../components/blur-input";
|
|
14
|
+
import Editor from "../editor";
|
|
16
15
|
|
|
17
16
|
const {InfoTip, InlineIcon, RangeInput} = components;
|
|
18
17
|
|
|
@@ -22,7 +21,7 @@ const defaultBackgroundImage = {
|
|
|
22
21
|
url: null,
|
|
23
22
|
width: 0,
|
|
24
23
|
height: 0,
|
|
25
|
-
};
|
|
24
|
+
} as const;
|
|
26
25
|
|
|
27
26
|
// Match any image URL (including "web+graphie" links) that is hosted by KA.
|
|
28
27
|
// We're somewhat generous in our AWS URL matching
|
|
@@ -54,7 +53,7 @@ const captionAlignments = [
|
|
|
54
53
|
"above left",
|
|
55
54
|
];
|
|
56
55
|
|
|
57
|
-
const ImageEditor:
|
|
56
|
+
const ImageEditor: any = createReactClass({
|
|
58
57
|
displayName: "ImageEditor",
|
|
59
58
|
|
|
60
59
|
propTypes: {
|
|
@@ -214,7 +213,6 @@ const ImageEditor: $FlowFixMe = createReactClass({
|
|
|
214
213
|
},
|
|
215
214
|
|
|
216
215
|
change(...args) {
|
|
217
|
-
// $FlowFixMe[object-this-reference]
|
|
218
216
|
return Changeable.change.apply(this, args);
|
|
219
217
|
},
|
|
220
218
|
|
|
@@ -318,7 +316,6 @@ const ImageEditor: $FlowFixMe = createReactClass({
|
|
|
318
316
|
},
|
|
319
317
|
|
|
320
318
|
serialize() {
|
|
321
|
-
// $FlowFixMe[object-this-reference]
|
|
322
319
|
return EditorJsonify.serialize.call(this);
|
|
323
320
|
},
|
|
324
321
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {components, Util, InputNumber} from "@khanacademy/perseus";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
import ReactDOM from "react-dom";
|
|
6
5
|
import _ from "underscore";
|
|
7
6
|
|
|
8
|
-
import BlurInput from "../components/blur-input
|
|
7
|
+
import BlurInput from "../components/blur-input";
|
|
9
8
|
|
|
10
9
|
import type {ParsedValue} from "@khanacademy/perseus";
|
|
11
10
|
|
|
@@ -44,44 +43,57 @@ const answerTypes = {
|
|
|
44
43
|
name: "Numbers with pi",
|
|
45
44
|
forms: "pi",
|
|
46
45
|
},
|
|
47
|
-
};
|
|
46
|
+
} as const;
|
|
48
47
|
|
|
49
|
-
type Props = {
|
|
50
|
-
value: number
|
|
51
|
-
simplify:
|
|
52
|
-
size: React.ElementConfig<typeof InputNumber.widget>["size"],
|
|
53
|
-
inexact: React.ElementConfig<
|
|
48
|
+
type Props = {
|
|
49
|
+
value: number;
|
|
50
|
+
simplify: JSX.LibraryManagedAttributes<
|
|
54
51
|
typeof InputNumber.widget,
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
React.ComponentProps<typeof InputNumber.widget>
|
|
53
|
+
>["simplify"];
|
|
54
|
+
size: JSX.LibraryManagedAttributes<
|
|
57
55
|
typeof InputNumber.widget,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
React.ComponentProps<typeof InputNumber.widget>
|
|
57
|
+
>["size"];
|
|
58
|
+
inexact: JSX.LibraryManagedAttributes<
|
|
59
|
+
typeof InputNumber.widget,
|
|
60
|
+
React.ComponentProps<typeof InputNumber.widget>
|
|
61
|
+
>["reviewModeRubric"]["inexact"];
|
|
62
|
+
maxError: JSX.LibraryManagedAttributes<
|
|
63
|
+
typeof InputNumber.widget,
|
|
64
|
+
React.ComponentProps<typeof InputNumber.widget>
|
|
65
|
+
>["reviewModeRubric"]["maxError"];
|
|
66
|
+
answerType: JSX.LibraryManagedAttributes<
|
|
67
|
+
typeof InputNumber.widget,
|
|
68
|
+
React.ComponentProps<typeof InputNumber.widget>
|
|
69
|
+
>["answerType"];
|
|
70
|
+
rightAlign: JSX.LibraryManagedAttributes<
|
|
71
|
+
typeof InputNumber.widget,
|
|
72
|
+
React.ComponentProps<typeof InputNumber.widget>
|
|
73
|
+
>["rightAlign"];
|
|
74
|
+
onChange: (arg1: {
|
|
75
|
+
value?: ParsedValue | 0;
|
|
76
|
+
simplify?: Props["simplify"];
|
|
77
|
+
size?: Props["size"];
|
|
78
|
+
inexact?: Props["inexact"];
|
|
79
|
+
maxError?: Props["maxError"];
|
|
80
|
+
answerType?: Props["answerType"];
|
|
81
|
+
rightAlign?: Props["rightAlign"];
|
|
82
|
+
}) => void;
|
|
83
|
+
};
|
|
72
84
|
|
|
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
|
-
|
|
85
|
+
type DefaultProps = {
|
|
86
|
+
value: Props["value"];
|
|
87
|
+
simplify: Props["simplify"];
|
|
88
|
+
size: Props["size"];
|
|
89
|
+
inexact: Props["inexact"];
|
|
90
|
+
maxError: Props["maxError"];
|
|
91
|
+
answerType: Props["answerType"];
|
|
92
|
+
rightAlign: Props["rightAlign"];
|
|
93
|
+
};
|
|
82
94
|
|
|
83
95
|
class InputNumberEditor extends React.Component<Props> {
|
|
84
|
-
static widgetName
|
|
96
|
+
static widgetName = "input-number" as const;
|
|
85
97
|
|
|
86
98
|
static defaultProps: DefaultProps = {
|
|
87
99
|
value: 0,
|
|
@@ -93,12 +105,12 @@ class InputNumberEditor extends React.Component<Props> {
|
|
|
93
105
|
rightAlign: false,
|
|
94
106
|
};
|
|
95
107
|
|
|
96
|
-
handleAnswerChange: (string) => void = (str) => {
|
|
108
|
+
handleAnswerChange: (arg1: string) => void = (str) => {
|
|
97
109
|
const value = Util.firstNumericalParse(str) || 0;
|
|
98
110
|
this.props.onChange({value: value});
|
|
99
111
|
};
|
|
100
112
|
|
|
101
|
-
render(): React.
|
|
113
|
+
render(): React.ReactNode {
|
|
102
114
|
const answerTypeOptions = _.map(
|
|
103
115
|
answerTypes,
|
|
104
116
|
function (v, k) {
|
|
@@ -132,6 +144,7 @@ class InputNumberEditor extends React.Component<Props> {
|
|
|
132
144
|
value={this.props.simplify}
|
|
133
145
|
onChange={(e) => {
|
|
134
146
|
this.props.onChange({
|
|
147
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'string' is not assignable to type '"optional" | "required" | "enforced" | undefined'.
|
|
135
148
|
simplify: e.target.value,
|
|
136
149
|
});
|
|
137
150
|
}}
|
|
@@ -206,6 +219,7 @@ class InputNumberEditor extends React.Component<Props> {
|
|
|
206
219
|
<select
|
|
207
220
|
value={this.props.answerType}
|
|
208
221
|
onChange={(e) => {
|
|
222
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'string' is not assignable to type '"number" | "integer" | "mixed" | "decimal" | "improper" | "percent" | "pi" | "rational" | undefined'.
|
|
209
223
|
this.props.onChange({answerType: e.target.value});
|
|
210
224
|
}}
|
|
211
225
|
>
|
|
@@ -226,6 +240,7 @@ class InputNumberEditor extends React.Component<Props> {
|
|
|
226
240
|
<select
|
|
227
241
|
value={this.props.size}
|
|
228
242
|
onChange={(e) => {
|
|
243
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'string' is not assignable to type '"small" | "normal" | undefined'.
|
|
229
244
|
this.props.onChange({size: e.target.value});
|
|
230
245
|
}}
|
|
231
246
|
>
|
|
@@ -261,21 +276,20 @@ class InputNumberEditor extends React.Component<Props> {
|
|
|
261
276
|
}
|
|
262
277
|
|
|
263
278
|
focus: () => boolean = () => {
|
|
264
|
-
//
|
|
265
|
-
// $FlowFixMe[prop-missing]
|
|
279
|
+
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'focus' does not exist on type 'Element | Text'.
|
|
266
280
|
ReactDOM.findDOMNode(this.refs.input).focus(); // eslint-disable-line react/no-string-refs
|
|
267
281
|
return true;
|
|
268
282
|
};
|
|
269
283
|
|
|
270
|
-
serialize: () => {
|
|
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
|
-
|
|
284
|
+
serialize: () => {
|
|
285
|
+
value: Props["value"];
|
|
286
|
+
simplify: Props["simplify"];
|
|
287
|
+
size: Props["size"];
|
|
288
|
+
inexact: Props["inexact"];
|
|
289
|
+
maxError: Props["maxError"];
|
|
290
|
+
answerType: Props["answerType"];
|
|
291
|
+
rightAlign: Props["rightAlign"];
|
|
292
|
+
} = () => ({
|
|
279
293
|
value: this.props.value,
|
|
280
294
|
simplify: this.props.simplify,
|
|
281
295
|
size: this.props.size,
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {components, Changeable, Dependencies} from "@khanacademy/perseus";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
5
4
|
const {ButtonGroup, MathInput, NumberInput} = components;
|
|
6
5
|
|
|
7
|
-
type Props = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|};
|
|
6
|
+
type Props = Changeable.ChangeableProps & {
|
|
7
|
+
constraint: string;
|
|
8
|
+
constraintFn: string;
|
|
9
|
+
constraintXMax: string;
|
|
10
|
+
constraintXMin: string;
|
|
11
|
+
constraintYMax: string;
|
|
12
|
+
constraintYMin: string;
|
|
13
|
+
snap: number;
|
|
14
|
+
};
|
|
17
15
|
|
|
18
|
-
type DefaultProps = {
|
|
19
|
-
constraint: Props["constraint"]
|
|
20
|
-
constraintFn: Props["constraintFn"]
|
|
21
|
-
constraintXMax: Props["constraintXMax"]
|
|
22
|
-
constraintXMin: Props["constraintXMin"]
|
|
23
|
-
constraintYMax: Props["constraintYMax"]
|
|
24
|
-
constraintYMin: Props["constraintYMin"]
|
|
25
|
-
snap: Props["snap"]
|
|
26
|
-
|
|
16
|
+
type DefaultProps = {
|
|
17
|
+
constraint: Props["constraint"];
|
|
18
|
+
constraintFn: Props["constraintFn"];
|
|
19
|
+
constraintXMax: Props["constraintXMax"];
|
|
20
|
+
constraintXMin: Props["constraintXMin"];
|
|
21
|
+
constraintYMax: Props["constraintYMax"];
|
|
22
|
+
constraintYMin: Props["constraintYMin"];
|
|
23
|
+
snap: Props["snap"];
|
|
24
|
+
};
|
|
27
25
|
|
|
28
26
|
class ConstraintEditor extends React.Component<Props> {
|
|
29
27
|
static defaultProps: DefaultProps = {
|
|
@@ -38,14 +36,13 @@ class ConstraintEditor extends React.Component<Props> {
|
|
|
38
36
|
|
|
39
37
|
change: (
|
|
40
38
|
propName: string,
|
|
41
|
-
) => (value
|
|
39
|
+
) => (value?: any, callback?: () => unknown) => unknown = (
|
|
42
40
|
propName: string,
|
|
43
|
-
): ((value
|
|
44
|
-
// $FlowFixMe[incompatible-return](WEB-1727): change is an overloaded function, but we aren't typing it as overloaded
|
|
41
|
+
): ((value?: any, callback?: () => unknown) => unknown) => {
|
|
45
42
|
return Changeable.change.call(this, propName);
|
|
46
43
|
};
|
|
47
44
|
|
|
48
|
-
render(): React.
|
|
45
|
+
render(): React.ReactNode {
|
|
49
46
|
const {TeX} = Dependencies.getDependencies();
|
|
50
47
|
|
|
51
48
|
return (
|