@khanacademy/perseus-editor 1.1.1 → 2.0.1
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 +27 -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 +4006 -5409
- 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 +7 -6
- 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
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars, react/forbid-prop-types, react/sort-comp */
|
|
2
|
-
// @flow
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, react/forbid-prop-types, react/sort-comp */
|
|
3
2
|
/**
|
|
4
3
|
* This is an example graphie-using widget
|
|
5
4
|
*
|
|
@@ -22,10 +21,10 @@ import type {Coord, WidgetExports} from "@khanacademy/perseus";
|
|
|
22
21
|
|
|
23
22
|
const {Graphie} = components;
|
|
24
23
|
|
|
25
|
-
//
|
|
24
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'MovablePoint' does not exist on type 'typeof Graphie'.
|
|
26
25
|
const MovablePoint = Graphie.MovablePoint;
|
|
27
26
|
|
|
28
|
-
type Props =
|
|
27
|
+
type Props = any;
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
30
|
* This is the widget's renderer. It shows up in the right column
|
|
@@ -64,7 +63,7 @@ class ExampleGraphieWidget extends React.Component<Props> {
|
|
|
64
63
|
/**
|
|
65
64
|
* This is the widget's grading function
|
|
66
65
|
*/
|
|
67
|
-
static validate(state:
|
|
66
|
+
static validate(state: any, rubric: any): any {
|
|
68
67
|
if (state.coord == null) {
|
|
69
68
|
return {
|
|
70
69
|
type: "invalid",
|
|
@@ -87,11 +86,11 @@ class ExampleGraphieWidget extends React.Component<Props> {
|
|
|
87
86
|
};
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
getUserInput: () =>
|
|
89
|
+
getUserInput: () => any = () => {
|
|
91
90
|
return WidgetJsonifyDeprecated.getUserInput.call(this);
|
|
92
91
|
};
|
|
93
92
|
|
|
94
|
-
render(): React.
|
|
93
|
+
render(): React.ReactNode {
|
|
95
94
|
return (
|
|
96
95
|
<Graphie
|
|
97
96
|
// eslint-disable-next-line react/no-string-refs
|
|
@@ -117,17 +116,18 @@ class ExampleGraphieWidget extends React.Component<Props> {
|
|
|
117
116
|
);
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
change: (
|
|
119
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
121
120
|
return Changeable.change.apply(this, args);
|
|
122
121
|
};
|
|
123
122
|
|
|
124
|
-
movePoint: (Coord) => void = (newCoord) => {
|
|
123
|
+
movePoint: (arg1: Coord) => void = (newCoord) => {
|
|
124
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
125
125
|
this.change({
|
|
126
126
|
coord: newCoord,
|
|
127
127
|
});
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
_getGridConfig: (
|
|
130
|
+
_getGridConfig: (arg1: any) => any = (options) => {
|
|
131
131
|
return _.map(options.step, function (step, i) {
|
|
132
132
|
return Util.gridDimensionConfig(
|
|
133
133
|
step,
|
|
@@ -138,10 +138,7 @@ class ExampleGraphieWidget extends React.Component<Props> {
|
|
|
138
138
|
});
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
setupGraphie: (
|
|
142
|
-
graphie,
|
|
143
|
-
options,
|
|
144
|
-
) => {
|
|
141
|
+
setupGraphie: (arg1: any, arg2: any) => any = (graphie, options) => {
|
|
145
142
|
const gridConfig = this._getGridConfig(options);
|
|
146
143
|
graphie.graphInit({
|
|
147
144
|
range: options.range,
|
|
@@ -158,7 +155,7 @@ class ExampleGraphieWidget extends React.Component<Props> {
|
|
|
158
155
|
graphie.label([0, options.range[1][1]], options.labels[1], "above");
|
|
159
156
|
};
|
|
160
157
|
|
|
161
|
-
simpleValidate: (
|
|
158
|
+
simpleValidate: (arg1: any) => any = (rubric) => {
|
|
162
159
|
return ExampleGraphieWidget.validate(this.getUserInput(), rubric);
|
|
163
160
|
};
|
|
164
161
|
}
|
|
@@ -167,9 +164,9 @@ class ExampleGraphieWidget extends React.Component<Props> {
|
|
|
167
164
|
* For this widget to work, we must export it.
|
|
168
165
|
* We also must import this file in src/all-widgets.js
|
|
169
166
|
*/
|
|
170
|
-
export default
|
|
167
|
+
export default {
|
|
171
168
|
name: "example-graphie-widget",
|
|
172
169
|
displayName: "Example Graphie Widget",
|
|
173
170
|
hidden: true, // Hides this widget from the Perseus.Editor widget select
|
|
174
171
|
widget: ExampleGraphieWidget,
|
|
175
|
-
}
|
|
172
|
+
} as WidgetExports<typeof ExampleGraphieWidget>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {Changeable, EditorJsonify} from "@khanacademy/perseus";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
|
|
6
|
-
type Props =
|
|
5
|
+
type Props = any;
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* This is the widget's editor. This is what shows up on the left side
|
|
@@ -14,19 +13,22 @@ class ExampleWidgetEditor extends React.Component<Props> {
|
|
|
14
13
|
...Changeable.propTypes,
|
|
15
14
|
};
|
|
16
15
|
|
|
17
|
-
static widgetName
|
|
16
|
+
static widgetName = "example-widget" as const;
|
|
18
17
|
|
|
19
18
|
static defaultProps: Props = {
|
|
20
19
|
correct: "",
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
handleAnswerChange: (
|
|
22
|
+
handleAnswerChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void = (
|
|
23
|
+
event,
|
|
24
|
+
) => {
|
|
25
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
24
26
|
this.change({
|
|
25
27
|
correct: event.target.value,
|
|
26
28
|
});
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
render(): React.
|
|
31
|
+
render(): React.ReactNode {
|
|
30
32
|
return (
|
|
31
33
|
<div>
|
|
32
34
|
<label>
|
|
@@ -42,17 +44,18 @@ class ExampleWidgetEditor extends React.Component<Props> {
|
|
|
42
44
|
);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
change: (
|
|
47
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
46
48
|
return Changeable.change.apply(this, args);
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
focus: () => boolean = () => {
|
|
50
52
|
// eslint-disable-next-line react/no-string-refs
|
|
53
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
51
54
|
this.refs.input.focus();
|
|
52
55
|
return true;
|
|
53
56
|
};
|
|
54
57
|
|
|
55
|
-
serialize: () =>
|
|
58
|
+
serialize: () => any = () => {
|
|
56
59
|
return EditorJsonify.serialize.call(this);
|
|
57
60
|
};
|
|
58
61
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
/**
|
|
4
3
|
* This is a simple number-entry widget
|
|
5
4
|
* It is not as powerful as number-input, but has a simpler, more
|
|
@@ -15,8 +14,8 @@ import _ from "underscore";
|
|
|
15
14
|
|
|
16
15
|
import type {WidgetExports} from "@khanacademy/perseus";
|
|
17
16
|
|
|
18
|
-
class TextInput extends React.Component
|
|
19
|
-
render(): React.
|
|
17
|
+
class TextInput extends React.Component<any> {
|
|
18
|
+
render(): React.ReactNode {
|
|
20
19
|
return (
|
|
21
20
|
<input
|
|
22
21
|
// eslint-disable-next-line react/no-string-refs
|
|
@@ -29,11 +28,12 @@ class TextInput extends React.Component<$FlowFixMe> {
|
|
|
29
28
|
|
|
30
29
|
focus = () => {
|
|
31
30
|
// eslint-disable-next-line react/no-string-refs
|
|
31
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
32
32
|
this.refs.input.focus();
|
|
33
33
|
return true;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
changeValue = (e) => {
|
|
36
|
+
changeValue = (e: any) => {
|
|
37
37
|
// Translating from the js event e to the value
|
|
38
38
|
// of the textbox to send to onChange
|
|
39
39
|
this.props.onChange(e.target.value);
|
|
@@ -45,13 +45,13 @@ class TextInput extends React.Component<$FlowFixMe> {
|
|
|
45
45
|
* in the demo, and is what is visible to users, and where
|
|
46
46
|
* users enter their answers.
|
|
47
47
|
*/
|
|
48
|
-
class ExampleWidget extends React.Component
|
|
48
|
+
class ExampleWidget extends React.Component<any> {
|
|
49
49
|
static propTypes = {
|
|
50
50
|
...Changeable.propTypes,
|
|
51
51
|
value: PropTypes.string,
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
static defaultProps:
|
|
54
|
+
static defaultProps: any = {
|
|
55
55
|
value: "",
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -62,7 +62,7 @@ class ExampleWidget extends React.Component<$FlowFixMe> {
|
|
|
62
62
|
* value is usually the result of getUserInput on the widget
|
|
63
63
|
* rubric is the result of calling serialize() on the editor
|
|
64
64
|
*/
|
|
65
|
-
static validate(value: string, rubric:
|
|
65
|
+
static validate(value: string, rubric: any): any {
|
|
66
66
|
if (value === "") {
|
|
67
67
|
return {
|
|
68
68
|
type: "invalid",
|
|
@@ -90,16 +90,17 @@ class ExampleWidget extends React.Component<$FlowFixMe> {
|
|
|
90
90
|
/**
|
|
91
91
|
* Tell our parent to update our props.
|
|
92
92
|
*/
|
|
93
|
-
change: (
|
|
93
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
94
94
|
return Changeable.change.apply(this, args);
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
render(): React.
|
|
97
|
+
render(): React.ReactNode {
|
|
98
98
|
return (
|
|
99
99
|
<TextInput
|
|
100
100
|
// eslint-disable-next-line react/no-string-refs
|
|
101
101
|
ref="input"
|
|
102
102
|
value={this.props.value}
|
|
103
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
103
104
|
onChange={this.change("value")}
|
|
104
105
|
/>
|
|
105
106
|
);
|
|
@@ -116,6 +117,7 @@ class ExampleWidget extends React.Component<$FlowFixMe> {
|
|
|
116
117
|
*/
|
|
117
118
|
focus: () => boolean = () => {
|
|
118
119
|
// eslint-disable-next-line react/no-string-refs
|
|
120
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
119
121
|
this.refs.input.focus();
|
|
120
122
|
return true;
|
|
121
123
|
};
|
|
@@ -132,7 +134,7 @@ class ExampleWidget extends React.Component<$FlowFixMe> {
|
|
|
132
134
|
* message: null
|
|
133
135
|
* }
|
|
134
136
|
*/
|
|
135
|
-
simpleValidate: (
|
|
137
|
+
simpleValidate: (arg1: any) => any = (rubric) => {
|
|
136
138
|
return ExampleWidget.validate(this.getUserInput(), rubric);
|
|
137
139
|
};
|
|
138
140
|
}
|
|
@@ -140,7 +142,7 @@ class ExampleWidget extends React.Component<$FlowFixMe> {
|
|
|
140
142
|
/**
|
|
141
143
|
* For this widget to work, we must import this file in src/all-widgets.js
|
|
142
144
|
*/
|
|
143
|
-
export default
|
|
145
|
+
export default {
|
|
144
146
|
name: "example-widget",
|
|
145
147
|
displayName: "Example Widget",
|
|
146
148
|
|
|
@@ -150,4 +152,4 @@ export default ({
|
|
|
150
152
|
|
|
151
153
|
hidden: true, // Hides this widget from the Perseus.Editor widget select
|
|
152
154
|
widget: ExampleWidget,
|
|
153
|
-
}
|
|
155
|
+
} as WidgetExports<typeof ExampleWidget>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/* eslint-disable react/forbid-prop-types */
|
|
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 Editor from "../editor
|
|
7
|
+
import Editor from "../editor";
|
|
9
8
|
|
|
10
9
|
const {TextInput} = components;
|
|
11
10
|
|
|
@@ -14,10 +13,10 @@ const defaultExplanationProps = {
|
|
|
14
13
|
hidePrompt: "Hide explanation",
|
|
15
14
|
explanation: "explanation goes here\n\nmore explanation",
|
|
16
15
|
widgets: {},
|
|
17
|
-
};
|
|
16
|
+
} as const;
|
|
18
17
|
|
|
19
|
-
type Props =
|
|
20
|
-
type State =
|
|
18
|
+
type Props = any;
|
|
19
|
+
type State = any;
|
|
21
20
|
|
|
22
21
|
class ExplanationEditor extends React.Component<Props, State> {
|
|
23
22
|
static propTypes = {
|
|
@@ -29,19 +28,19 @@ class ExplanationEditor extends React.Component<Props, State> {
|
|
|
29
28
|
apiOptions: PropTypes.any,
|
|
30
29
|
};
|
|
31
30
|
|
|
32
|
-
static widgetName
|
|
31
|
+
static widgetName = "explanation" as const;
|
|
33
32
|
static defaultProps: Props = defaultExplanationProps;
|
|
34
33
|
state: State = {};
|
|
35
34
|
|
|
36
|
-
change: (
|
|
35
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
37
36
|
return Changeable.change.apply(this, args);
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
serialize: () =>
|
|
39
|
+
serialize: () => any = () => {
|
|
41
40
|
return EditorJsonify.serialize.call(this);
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
render(): React.
|
|
43
|
+
render(): React.ReactNode {
|
|
45
44
|
return (
|
|
46
45
|
<div className="perseus-widget-explanation-editor">
|
|
47
46
|
<div className="perseus-widget-row">
|
|
@@ -49,6 +48,7 @@ class ExplanationEditor extends React.Component<Props, State> {
|
|
|
49
48
|
Prompt to show explanation:{" "}
|
|
50
49
|
<TextInput
|
|
51
50
|
value={this.props.showPrompt}
|
|
51
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
52
52
|
onChange={this.change("showPrompt")}
|
|
53
53
|
/>
|
|
54
54
|
</label>
|
|
@@ -58,6 +58,7 @@ class ExplanationEditor extends React.Component<Props, State> {
|
|
|
58
58
|
Prompt to hide explanation:{" "}
|
|
59
59
|
<TextInput
|
|
60
60
|
value={this.props.hidePrompt}
|
|
61
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
61
62
|
onChange={this.change("hidePrompt")}
|
|
62
63
|
/>
|
|
63
64
|
</label>
|
|
@@ -70,13 +71,14 @@ class ExplanationEditor extends React.Component<Props, State> {
|
|
|
70
71
|
widgetEnabled={true}
|
|
71
72
|
immutableWidgets={false}
|
|
72
73
|
onChange={(props) => {
|
|
73
|
-
const newProps = {};
|
|
74
|
+
const newProps: Record<string, any> = {};
|
|
74
75
|
if (_.has(props, "content")) {
|
|
75
76
|
newProps.explanation = props.content;
|
|
76
77
|
}
|
|
77
78
|
if (_.has(props, "widgets")) {
|
|
78
79
|
newProps.widgets = props.widgets;
|
|
79
80
|
}
|
|
81
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
80
82
|
this.change(newProps);
|
|
81
83
|
}}
|
|
82
84
|
/>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable one-var, react/forbid-prop-types, react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import * as KAS from "@khanacademy/kas";
|
|
4
3
|
import {
|
|
5
4
|
components,
|
|
@@ -13,7 +12,7 @@ import PropTypes from "prop-types";
|
|
|
13
12
|
import * as React from "react";
|
|
14
13
|
import _ from "underscore";
|
|
15
14
|
|
|
16
|
-
import SortableArea from "../components/sortable
|
|
15
|
+
import SortableArea from "../components/sortable";
|
|
17
16
|
|
|
18
17
|
const {InfoTip, PropCheckBox, TexButtons} = components;
|
|
19
18
|
const {getDependencies} = Dependencies;
|
|
@@ -29,11 +28,11 @@ const answerFormType = PropTypes.shape({
|
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
// Pick a key that isn't currently used by an answer in answerForms
|
|
32
|
-
const _makeNewKey = (answerForms) => {
|
|
31
|
+
const _makeNewKey = (answerForms: any) => {
|
|
33
32
|
// first note all the currently used keys in an array, used like a map :3
|
|
34
33
|
// note that this automatically updates the array's length property to
|
|
35
34
|
// be one past the largest key.
|
|
36
|
-
const usedKeys = [];
|
|
35
|
+
const usedKeys: Array<boolean> = [];
|
|
37
36
|
answerForms.forEach((ans) => {
|
|
38
37
|
usedKeys[ans.key] = true;
|
|
39
38
|
});
|
|
@@ -50,7 +49,7 @@ const _makeNewKey = (answerForms) => {
|
|
|
50
49
|
return usedKeys.length;
|
|
51
50
|
};
|
|
52
51
|
|
|
53
|
-
class ExpressionEditor extends React.Component
|
|
52
|
+
class ExpressionEditor extends React.Component<any, any> {
|
|
54
53
|
static propTypes = {
|
|
55
54
|
...Changeable.propTypes,
|
|
56
55
|
answerForms: PropTypes.arrayOf(answerFormType),
|
|
@@ -59,16 +58,16 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
59
58
|
functions: PropTypes.arrayOf(PropTypes.string),
|
|
60
59
|
};
|
|
61
60
|
|
|
62
|
-
static widgetName
|
|
61
|
+
static widgetName = "expression" as const;
|
|
63
62
|
|
|
64
|
-
static defaultProps:
|
|
63
|
+
static defaultProps: any = {
|
|
65
64
|
answerForms: [],
|
|
66
65
|
times: false,
|
|
67
66
|
buttonSets: ["basic"],
|
|
68
67
|
functions: ["f", "g", "h"],
|
|
69
68
|
};
|
|
70
69
|
|
|
71
|
-
constructor(props:
|
|
70
|
+
constructor(props: any) {
|
|
72
71
|
super(props);
|
|
73
72
|
// Is the format of `value` TeX or plain text?
|
|
74
73
|
// TODO(alex): Remove after backfilling everything to TeX
|
|
@@ -94,11 +93,11 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
94
93
|
this.state = {isTex};
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
change: (
|
|
96
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
98
97
|
return Changeable.change.apply(this, args);
|
|
99
98
|
};
|
|
100
99
|
|
|
101
|
-
render(): React.
|
|
100
|
+
render(): React.ReactNode {
|
|
102
101
|
const answerOptions = this.props.answerForms
|
|
103
102
|
.map((obj, index) => {
|
|
104
103
|
const expressionProps = {
|
|
@@ -118,7 +117,7 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
118
117
|
trackInteraction: () => {},
|
|
119
118
|
|
|
120
119
|
widgetId: this.props.widgetId + "-" + index,
|
|
121
|
-
};
|
|
120
|
+
} as const;
|
|
122
121
|
|
|
123
122
|
return lens(obj)
|
|
124
123
|
.merge([], {
|
|
@@ -253,7 +252,7 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
253
252
|
);
|
|
254
253
|
}
|
|
255
254
|
|
|
256
|
-
serialize: () =>
|
|
255
|
+
serialize: () => any = () => {
|
|
257
256
|
const formSerializables = [
|
|
258
257
|
"value",
|
|
259
258
|
"form",
|
|
@@ -280,8 +279,8 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
280
279
|
.freeze();
|
|
281
280
|
};
|
|
282
281
|
|
|
283
|
-
getSaveWarnings: () =>
|
|
284
|
-
const issues = [];
|
|
282
|
+
getSaveWarnings: () => any = () => {
|
|
283
|
+
const issues: Array<any | string> = [];
|
|
285
284
|
|
|
286
285
|
if (this.props.answerForms.length === 0) {
|
|
287
286
|
issues.push("No answers specified");
|
|
@@ -324,7 +323,7 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
324
323
|
return issues;
|
|
325
324
|
};
|
|
326
325
|
|
|
327
|
-
_newEmptyAnswerForm: () =>
|
|
326
|
+
_newEmptyAnswerForm: () => any = () => {
|
|
328
327
|
return {
|
|
329
328
|
considered: "correct",
|
|
330
329
|
form: false,
|
|
@@ -341,26 +340,29 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
341
340
|
newAnswer: () => void = () => {
|
|
342
341
|
const answerForms = this.props.answerForms.slice();
|
|
343
342
|
answerForms.push(this._newEmptyAnswerForm());
|
|
343
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
344
344
|
this.change({answerForms});
|
|
345
345
|
};
|
|
346
346
|
|
|
347
|
-
handleRemoveForm: (number) => void = (i) => {
|
|
347
|
+
handleRemoveForm: (arg1: number) => void = (i) => {
|
|
348
348
|
const answerForms = this.props.answerForms.slice();
|
|
349
349
|
answerForms.splice(i, 1);
|
|
350
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
350
351
|
this.change({answerForms});
|
|
351
352
|
};
|
|
352
353
|
|
|
353
354
|
// called when the options (including the expression itself) to an answer
|
|
354
355
|
// form change
|
|
355
|
-
updateForm: (number,
|
|
356
|
+
updateForm: (arg1: number, arg2: any) => void = (i, props) => {
|
|
356
357
|
const answerForms = lens(this.props.answerForms)
|
|
357
358
|
.merge([i], props)
|
|
358
359
|
.freeze();
|
|
359
360
|
|
|
361
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
360
362
|
this.change({answerForms});
|
|
361
363
|
};
|
|
362
364
|
|
|
363
|
-
handleReorder: (
|
|
365
|
+
handleReorder: (arg1: any) => void = (components) => {
|
|
364
366
|
const answerForms = _(components).map((component) => {
|
|
365
367
|
const form = _(component.props).pick(
|
|
366
368
|
"considered",
|
|
@@ -368,15 +370,17 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
368
370
|
"simplify",
|
|
369
371
|
"value",
|
|
370
372
|
);
|
|
373
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'key' does not exist on type 'Pick<any, "form" | "value" | "simplify" | "considered">'.
|
|
371
374
|
form.key = component.key;
|
|
372
375
|
return form;
|
|
373
376
|
});
|
|
374
377
|
|
|
378
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
375
379
|
this.change({answerForms});
|
|
376
380
|
};
|
|
377
381
|
|
|
378
382
|
// called when the selected buttonset changes
|
|
379
|
-
handleButtonSet: (string) => void = (changingName) => {
|
|
383
|
+
handleButtonSet: (arg1: string) => void = (changingName) => {
|
|
380
384
|
const buttonSetNames = _(TexButtons.buttonSets).keys();
|
|
381
385
|
|
|
382
386
|
// Filter to preserve order - using .union and .difference would always
|
|
@@ -409,31 +413,35 @@ class ExpressionEditor extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
409
413
|
.reject((set) => set === remove)
|
|
410
414
|
.concat(keep);
|
|
411
415
|
|
|
416
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
|
|
412
417
|
this.change("buttonSets", buttonSets);
|
|
413
418
|
};
|
|
414
419
|
|
|
415
420
|
// called when the correct answer changes
|
|
416
|
-
handleTexInsert: (string) => void = (str) => {
|
|
421
|
+
handleTexInsert: (arg1: string) => void = (str) => {
|
|
417
422
|
// eslint-disable-next-line react/no-string-refs
|
|
423
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'insert' does not exist on type 'ReactInstance'.
|
|
418
424
|
this.refs.expression.insert(str);
|
|
419
425
|
};
|
|
420
426
|
|
|
421
427
|
// called when the function variables change
|
|
422
|
-
handleFunctions: (
|
|
423
|
-
|
|
428
|
+
handleFunctions: (arg1: React.ChangeEvent<HTMLInputElement>) => void = (
|
|
429
|
+
e,
|
|
430
|
+
) => {
|
|
431
|
+
const newProps: Record<string, any> = {};
|
|
424
432
|
newProps.functions = _.compact(e.target.value.split(/[ ,]+/));
|
|
425
433
|
this.props.onChange(newProps);
|
|
426
434
|
};
|
|
427
435
|
}
|
|
428
436
|
|
|
429
437
|
// Find the next element in arr after val, wrapping around to the first.
|
|
430
|
-
const findNextIn = function (arr
|
|
438
|
+
const findNextIn = function (arr: Array<string>, val: any) {
|
|
431
439
|
let ix = _(arr).indexOf(val);
|
|
432
440
|
ix = (ix + 1) % arr.length;
|
|
433
441
|
return arr[ix];
|
|
434
442
|
};
|
|
435
443
|
|
|
436
|
-
class AnswerOption extends React.Component
|
|
444
|
+
class AnswerOption extends React.Component<any, any> {
|
|
437
445
|
static propTypes = {
|
|
438
446
|
...Changeable.propTypes,
|
|
439
447
|
considered: PropTypes.oneOf(CONSIDERED).isRequired,
|
|
@@ -449,7 +457,7 @@ class AnswerOption extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
449
457
|
onDelete: PropTypes.func.isRequired,
|
|
450
458
|
};
|
|
451
459
|
|
|
452
|
-
state:
|
|
460
|
+
state: any = {deleteFocused: false};
|
|
453
461
|
|
|
454
462
|
handleDeleteBlur = () => {
|
|
455
463
|
this.setState({deleteFocused: false});
|
|
@@ -459,9 +467,10 @@ class AnswerOption extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
459
467
|
return Changeable.change.apply(this, args);
|
|
460
468
|
};
|
|
461
469
|
|
|
462
|
-
render(): React.
|
|
470
|
+
render(): React.ReactNode {
|
|
463
471
|
let removeButton = null;
|
|
464
472
|
if (this.state.deleteFocused) {
|
|
473
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Element' is not assignable to type 'null'.
|
|
465
474
|
removeButton = (
|
|
466
475
|
<button
|
|
467
476
|
type="button"
|
|
@@ -473,6 +482,7 @@ class AnswerOption extends React.Component<$FlowFixMe, $FlowFixMe> {
|
|
|
473
482
|
</button>
|
|
474
483
|
);
|
|
475
484
|
} else {
|
|
485
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Element' is not assignable to type 'null'.
|
|
476
486
|
removeButton = (
|
|
477
487
|
<button
|
|
478
488
|
type="button"
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/* eslint-disable react/forbid-prop-types, react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
import {components, icons, ApiOptions, Changeable} from "@khanacademy/perseus";
|
|
4
3
|
import {StyleSheet, css} from "aphrodite";
|
|
5
4
|
import PropTypes from "prop-types";
|
|
6
5
|
import * as React from "react";
|
|
7
6
|
import _ from "underscore";
|
|
8
7
|
|
|
9
|
-
import Editor from "../editor
|
|
8
|
+
import Editor from "../editor";
|
|
10
9
|
|
|
11
10
|
const {InlineIcon, TextInput} = components;
|
|
12
11
|
const {iconPlus, iconTrash} = icons;
|
|
13
12
|
|
|
14
|
-
type Props =
|
|
13
|
+
type Props = any;
|
|
15
14
|
|
|
16
15
|
class GradedGroupEditor extends React.Component<Props> {
|
|
17
16
|
static propTypes = {
|
|
@@ -23,7 +22,7 @@ class GradedGroupEditor extends React.Component<Props> {
|
|
|
23
22
|
apiOptions: ApiOptions.propTypes,
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
static widgetName
|
|
25
|
+
static widgetName = "graded-group" as const;
|
|
27
26
|
|
|
28
27
|
static defaultProps: Props = {
|
|
29
28
|
title: "",
|
|
@@ -33,23 +32,24 @@ class GradedGroupEditor extends React.Component<Props> {
|
|
|
33
32
|
hint: null,
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
change: (
|
|
35
|
+
change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
|
|
37
36
|
return Changeable.change.apply(this, args);
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
handleAddHint: () => void = () => {
|
|
41
|
-
const hint = {content: ""};
|
|
40
|
+
const hint = {content: ""} as const;
|
|
42
41
|
this.props.onChange({hint}, () => {
|
|
43
42
|
// eslint-disable-next-line react/no-string-refs
|
|
43
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
44
44
|
this.refs["hint-editor"].focus();
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
handleRemoveHint: (
|
|
48
|
+
handleRemoveHint: (arg1: React.MouseEvent) => void = (e) => {
|
|
49
49
|
this.props.onChange({hint: null});
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
render(): React.
|
|
52
|
+
render(): React.ReactNode {
|
|
53
53
|
return (
|
|
54
54
|
<div className="perseus-group-editor">
|
|
55
55
|
<div className="perseus-widget-row">
|
|
@@ -58,6 +58,7 @@ class GradedGroupEditor extends React.Component<Props> {
|
|
|
58
58
|
<TextInput
|
|
59
59
|
value={this.props.title}
|
|
60
60
|
className={css(styles.input)}
|
|
61
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 1.
|
|
61
62
|
onChange={this.change("title")}
|
|
62
63
|
/>
|
|
63
64
|
</label>
|
|
@@ -104,6 +105,7 @@ class GradedGroupEditor extends React.Component<Props> {
|
|
|
104
105
|
onChange={(props) => {
|
|
105
106
|
// Copy all props over from the existing hint
|
|
106
107
|
// and then add new props.
|
|
108
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 3 arguments, but got 2.
|
|
107
109
|
this.change(
|
|
108
110
|
"hint",
|
|
109
111
|
Object.assign({}, this.props.hint, props),
|
|
@@ -123,20 +125,26 @@ class GradedGroupEditor extends React.Component<Props> {
|
|
|
123
125
|
);
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
getSaveWarnings: () =>
|
|
128
|
+
getSaveWarnings: () => any = () => {
|
|
127
129
|
// eslint-disable-next-line react/no-string-refs
|
|
130
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
128
131
|
return this.refs.editor.getSaveWarnings();
|
|
129
132
|
};
|
|
130
133
|
|
|
131
|
-
serialize: () => {
|
|
134
|
+
serialize: () => {
|
|
135
|
+
title: string;
|
|
136
|
+
hint: any | null | undefined;
|
|
137
|
+
} = () => {
|
|
132
138
|
return {
|
|
133
139
|
title: this.props.title,
|
|
134
140
|
// eslint-disable-next-line react/no-string-refs
|
|
141
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
135
142
|
...this.refs.editor.serialize(),
|
|
136
143
|
hint:
|
|
137
144
|
// eslint-disable-next-line react/no-string-refs
|
|
138
145
|
this.refs["hint-editor"] &&
|
|
139
146
|
// eslint-disable-next-line react/no-string-refs
|
|
147
|
+
// @ts-expect-error [FEI-5003] - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
140
148
|
this.refs["hint-editor"].serialize(),
|
|
141
149
|
};
|
|
142
150
|
};
|