@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,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* The Option is an item to be used in the Select components and the
|
|
4
3
|
* derivations such as MultiSelect, CheckList, and CheckBoxList. Also includes
|
|
@@ -10,61 +9,53 @@ import {css, StyleSheet} from "aphrodite";
|
|
|
10
9
|
import * as React from "react";
|
|
11
10
|
import ReactDOM from "react-dom";
|
|
12
11
|
|
|
13
|
-
import {focusWithChromeStickyFocusBugWorkaround} from "./util
|
|
12
|
+
import {focusWithChromeStickyFocusBugWorkaround} from "./util";
|
|
14
13
|
|
|
15
14
|
export type OptionRenderer = (
|
|
16
|
-
children:
|
|
15
|
+
children: React.ReactElement<any> | null | undefined,
|
|
17
16
|
value: string,
|
|
18
17
|
selected: boolean,
|
|
19
18
|
disabled?: boolean,
|
|
20
|
-
) => React.
|
|
19
|
+
) => React.ReactElement<any>;
|
|
21
20
|
|
|
22
21
|
const {Icon} = components;
|
|
23
22
|
const {colors} = globalStyles;
|
|
24
23
|
|
|
25
|
-
const findAndFocusElement = (component
|
|
26
|
-
const DOMNode:
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const findAndFocusElement = (component?: Element | null) => {
|
|
25
|
+
const DOMNode: Element | Text | null | undefined =
|
|
26
|
+
ReactDOM.findDOMNode(component);
|
|
27
|
+
const button = DOMNode as HTMLInputElement;
|
|
28
|
+
// @ts-expect-error [FEI-5003] - TS2774 - This condition will always return true since this function is always defined. Did you mean to call it instead?
|
|
29
29
|
if (button.focus) {
|
|
30
30
|
focusWithChromeStickyFocusBugWorkaround(button);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
type OptionProps = {
|
|
34
|
+
type OptionProps = {
|
|
35
35
|
// The value to use when the option is selected
|
|
36
|
-
value: string
|
|
37
|
-
|
|
36
|
+
value: string;
|
|
38
37
|
// The display of the option
|
|
39
|
-
children?: React.
|
|
40
|
-
|
|
38
|
+
children?: React.ReactNode;
|
|
41
39
|
// Is the current option selected?
|
|
42
|
-
selected?: boolean
|
|
43
|
-
|
|
40
|
+
selected?: boolean;
|
|
44
41
|
// Is the current option disabled?
|
|
45
|
-
disabled?: boolean
|
|
46
|
-
|
|
42
|
+
disabled?: boolean;
|
|
47
43
|
// An event when an option is clicked
|
|
48
|
-
onClick?: () => void
|
|
49
|
-
|
|
44
|
+
onClick?: () => void;
|
|
50
45
|
// An optional rendering function to render the details of the option
|
|
51
|
-
optionRenderer?: OptionRenderer
|
|
52
|
-
|
|
46
|
+
optionRenderer?: OptionRenderer;
|
|
53
47
|
// An optional function to call when the dropdown should close
|
|
54
48
|
// Only relevant if the Option is inside of a dropdown menu
|
|
55
|
-
onDropdownClose?: () => void
|
|
56
|
-
|
|
49
|
+
onDropdownClose?: () => void;
|
|
57
50
|
// An optional value to override the focus styling of an option.
|
|
58
51
|
// Use caution when using this - keyboard users need to know what they're
|
|
59
52
|
// focused on in order to interact with the product!
|
|
60
|
-
hideFocusState?: boolean
|
|
61
|
-
|
|
53
|
+
hideFocusState?: boolean;
|
|
62
54
|
// An optional test id that can be used to identify this Option in automated tests.
|
|
63
|
-
testId?: string
|
|
64
|
-
|
|
55
|
+
testId?: string;
|
|
65
56
|
// Text to provide for assistive tech users
|
|
66
|
-
ariaLabel?: string
|
|
67
|
-
|
|
57
|
+
ariaLabel?: string;
|
|
58
|
+
};
|
|
68
59
|
|
|
69
60
|
const check = `M10,3.8C10,4,9.9,4.2,9.8,4.3L5.1,8.9L4.3,9.8C4.2,9.9,4,10,3.8,10
|
|
70
61
|
S3.5,9.9,3.4,9.8L2.5,8.9L0.2,6.6C0.1,6.5,0,6.3,0,6.2s0.1-0.3,0.2-0.4
|
|
@@ -75,6 +66,7 @@ const check = `M10,3.8C10,4,9.9,4.2,9.8,4.3L5.1,8.9L4.3,9.8C4.2,9.9,4,10,3.8,10
|
|
|
75
66
|
export const optionHeight = 30;
|
|
76
67
|
|
|
77
68
|
class Option extends React.Component<OptionProps> {
|
|
69
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property 'node' has no initializer and is not definitely assigned in the constructor.
|
|
78
70
|
node: HTMLDivElement;
|
|
79
71
|
|
|
80
72
|
handleKeyDown(event: any): void {
|
|
@@ -106,7 +98,7 @@ class Option extends React.Component<OptionProps> {
|
|
|
106
98
|
}
|
|
107
99
|
}
|
|
108
100
|
|
|
109
|
-
render(): React.
|
|
101
|
+
render(): React.ReactNode {
|
|
110
102
|
const {
|
|
111
103
|
selected,
|
|
112
104
|
value,
|
|
@@ -124,6 +116,7 @@ class Option extends React.Component<OptionProps> {
|
|
|
124
116
|
// TODO(mdr): We found a new Flow error when upgrading:
|
|
125
117
|
// "node (null) This type is incompatible with this.node (HTMLDivElement)"
|
|
126
118
|
// $FlowFixMe[incompatible-type](0.52.0->0.53.0)
|
|
119
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'HTMLButtonElement | null' is not assignable to type 'HTMLDivElement'.
|
|
127
120
|
ref={(node) => (this.node = node)}
|
|
128
121
|
value={value}
|
|
129
122
|
role="menuitemradio"
|
|
@@ -133,6 +126,7 @@ class Option extends React.Component<OptionProps> {
|
|
|
133
126
|
disabled && styles.cursorDefault,
|
|
134
127
|
hideFocusState && styles.noFocus,
|
|
135
128
|
)}
|
|
129
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type '(value: string) => void' is not assignable to type 'MouseEventHandler<HTMLButtonElement>'.
|
|
136
130
|
onClick={(value: string) => {
|
|
137
131
|
if (!disabled && onClick) {
|
|
138
132
|
// TODO(mdr): We found a new Flow error here when upgrading
|
|
@@ -140,10 +134,11 @@ class Option extends React.Component<OptionProps> {
|
|
|
140
134
|
// argument)". This comment was automatically added to
|
|
141
135
|
// this file, to suppress the error for now. Please
|
|
142
136
|
// consider fixing!
|
|
143
|
-
//
|
|
137
|
+
// @ts-expect-error [FEI-5003] - TS2554 - Expected 0 arguments, but got 1.
|
|
144
138
|
onClick(value);
|
|
145
139
|
}
|
|
146
140
|
}}
|
|
141
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type '(event: KeyboardEvent) => void' is not assignable to type 'KeyboardEventHandler<HTMLButtonElement>'.
|
|
147
142
|
onKeyDown={(event: KeyboardEvent) => this.handleKeyDown(event)}
|
|
148
143
|
aria-disabled={disabled}
|
|
149
144
|
aria-label={ariaLabel}
|
|
@@ -189,23 +184,23 @@ class Option extends React.Component<OptionProps> {
|
|
|
189
184
|
// - how does the drop down interact with tooltips? what's the z-index order?
|
|
190
185
|
class OptionGroup extends React.Component<{
|
|
191
186
|
// An event when an option is selected
|
|
192
|
-
onSelected: (value: string) => void
|
|
187
|
+
onSelected: (value: string) => void;
|
|
193
188
|
// The list of options to display
|
|
194
|
-
children?: Array<React.
|
|
189
|
+
children?: Array<React.ReactElement<React.ComponentProps<typeof Option>>>;
|
|
195
190
|
// The currently selected options
|
|
196
|
-
selectedValues: Array<string
|
|
191
|
+
selectedValues: Array<string>;
|
|
197
192
|
// An optional rendering function to render the details of the options
|
|
198
|
-
optionRenderer?: OptionRenderer
|
|
193
|
+
optionRenderer?: OptionRenderer;
|
|
199
194
|
// An override to skip the bit of top/bottom spacing around the group
|
|
200
|
-
noMargin?: boolean
|
|
195
|
+
noMargin?: boolean;
|
|
201
196
|
// An optional function to call when the dropdown should close
|
|
202
|
-
onDropdownClose?: () => void
|
|
197
|
+
onDropdownClose?: () => void;
|
|
203
198
|
// An optional value to override the focus styling of an option.
|
|
204
199
|
// Use caution when using this - keyboard users need to know what
|
|
205
200
|
// they're focused on in order to interact with the product!
|
|
206
|
-
hideFocusState?: boolean
|
|
207
|
-
...
|
|
201
|
+
hideFocusState?: boolean;
|
|
208
202
|
}> {
|
|
203
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property 'focusedElement' has no initializer and is not definitely assigned in the constructor.
|
|
209
204
|
focusedElement: Element;
|
|
210
205
|
|
|
211
206
|
componentDidMount() {
|
|
@@ -214,7 +209,7 @@ class OptionGroup extends React.Component<{
|
|
|
214
209
|
}
|
|
215
210
|
}
|
|
216
211
|
|
|
217
|
-
render(): React.
|
|
212
|
+
render(): React.ReactNode {
|
|
218
213
|
const {
|
|
219
214
|
children,
|
|
220
215
|
onSelected,
|
|
@@ -227,6 +222,7 @@ class OptionGroup extends React.Component<{
|
|
|
227
222
|
|
|
228
223
|
return (
|
|
229
224
|
<div
|
|
225
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type 'Window | null' is not assignable to type 'Top<string | number> | undefined'.
|
|
230
226
|
style={{top}}
|
|
231
227
|
className={css(
|
|
232
228
|
styles.optionGroup,
|
|
@@ -234,6 +230,7 @@ class OptionGroup extends React.Component<{
|
|
|
234
230
|
)}
|
|
235
231
|
>
|
|
236
232
|
{React.Children.map(children, (child, index) => {
|
|
233
|
+
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'.
|
|
237
234
|
const selected = selectedValues.includes(child.props.value);
|
|
238
235
|
|
|
239
236
|
const reference =
|
|
@@ -241,10 +238,13 @@ class OptionGroup extends React.Component<{
|
|
|
241
238
|
? (node: Element) => (this.focusedElement = node)
|
|
242
239
|
: null;
|
|
243
240
|
|
|
241
|
+
// @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
|
|
244
242
|
return React.cloneElement(child, {
|
|
243
|
+
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'.
|
|
245
244
|
...child.props,
|
|
246
245
|
key: index,
|
|
247
246
|
selected: selected,
|
|
247
|
+
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'.
|
|
248
248
|
onClick: () => onSelected(child.props.value),
|
|
249
249
|
optionRenderer: optionRenderer,
|
|
250
250
|
ref: reference,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* DEPRECATED: Use <TextField> from ./text-field.jsx instead.
|
|
4
3
|
*
|
|
@@ -13,27 +12,24 @@ import Color from "@khanacademy/wonder-blocks-color";
|
|
|
13
12
|
import {StyleSheet, css} from "aphrodite";
|
|
14
13
|
import * as React from "react";
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type Props = {|
|
|
15
|
+
type Props = {
|
|
19
16
|
// This id is used to tie the input field to the label that describes it.
|
|
20
17
|
// TODO(diedra): Instead of passing in this id to connect the label and input
|
|
21
18
|
// field, we should pass in the label for the input field and place it
|
|
22
19
|
// inside the <form>.
|
|
23
|
-
id?: string
|
|
24
|
-
testId?: string
|
|
25
|
-
type?: string
|
|
26
|
-
name?: string
|
|
27
|
-
readOnly?: boolean
|
|
28
|
-
value?:
|
|
29
|
-
placeholder?: string
|
|
20
|
+
id?: string;
|
|
21
|
+
testId?: string;
|
|
22
|
+
type?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
value?: string | ReadonlyArray<string> | number | undefined;
|
|
26
|
+
placeholder?: string;
|
|
30
27
|
// https://reactjs.org/docs/uncontrolled-components.html#default-values
|
|
31
|
-
defaultValue?:
|
|
32
|
-
disabled?: boolean
|
|
33
|
-
autoFocus?: boolean
|
|
34
|
-
maxLength?: number
|
|
35
|
-
invalid?: "true" | "false"
|
|
36
|
-
|
|
28
|
+
defaultValue?: string | number | ReadonlyArray<string> | undefined;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
autoFocus?: boolean;
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
invalid?: "true" | "false";
|
|
37
33
|
// styling
|
|
38
34
|
// This prop is passed directly to <input>. This is incorrect since HTML
|
|
39
35
|
// tags don't know what to do with an aphrodite which is typed as:
|
|
@@ -44,57 +40,54 @@ type Props = {|
|
|
|
44
40
|
// }
|
|
45
41
|
// TODO(WB-1026): Update StyleType to reflect the aphrodite type
|
|
46
42
|
// TODO(FEI-3282): Update uses of StyleType in webapp to be correct
|
|
47
|
-
style?:
|
|
48
|
-
className?: string
|
|
49
|
-
width?: number | string
|
|
50
|
-
grow?: boolean | number
|
|
51
|
-
shrink?: boolean | number
|
|
43
|
+
style?: React.CSSProperties | undefined;
|
|
44
|
+
className?: string;
|
|
45
|
+
width?: number | string;
|
|
46
|
+
grow?: boolean | number;
|
|
47
|
+
shrink?: boolean | number;
|
|
52
48
|
// HACK(mattmorgan) to enforce WB LabelMedium-like styles on this older
|
|
53
49
|
// component.
|
|
54
|
-
labelMediumInputText?: boolean
|
|
55
|
-
icon?: React.
|
|
56
|
-
leftSideIcon?: boolean
|
|
57
|
-
backgroundColor?: string
|
|
58
|
-
focusBorderColor?: string
|
|
59
|
-
borderColor?: string
|
|
60
|
-
color?: string
|
|
61
|
-
|
|
50
|
+
labelMediumInputText?: boolean;
|
|
51
|
+
icon?: React.ReactElement<React.ComponentProps<typeof components.Icon>>;
|
|
52
|
+
leftSideIcon?: boolean;
|
|
53
|
+
backgroundColor?: string;
|
|
54
|
+
focusBorderColor?: string;
|
|
55
|
+
borderColor?: string;
|
|
56
|
+
color?: string;
|
|
62
57
|
// events
|
|
63
|
-
onSubmit?: (
|
|
64
|
-
onBlur?: (
|
|
65
|
-
onFocus?: (
|
|
66
|
-
onChange?: (
|
|
67
|
-
onClick?: (
|
|
68
|
-
onKeyPress?: (
|
|
69
|
-
onKeyDown?: (
|
|
70
|
-
|
|
58
|
+
onSubmit?: (arg1: React.ChangeEvent<HTMLInputElement>) => unknown;
|
|
59
|
+
onBlur?: (arg1: React.ChangeEvent<HTMLInputElement>) => unknown;
|
|
60
|
+
onFocus?: (arg1: React.ChangeEvent<HTMLInputElement>) => unknown;
|
|
61
|
+
onChange?: (arg1: React.ChangeEvent<HTMLInputElement>) => unknown;
|
|
62
|
+
onClick?: (arg1: React.MouseEvent<HTMLInputElement>) => unknown;
|
|
63
|
+
onKeyPress?: (arg1: React.KeyboardEvent<HTMLInputElement>) => unknown;
|
|
64
|
+
onKeyDown?: (arg1: React.KeyboardEvent<HTMLInputElement>) => unknown;
|
|
71
65
|
// aria
|
|
72
|
-
"aria-label"?: string
|
|
73
|
-
"aria-describedby"?:
|
|
74
|
-
|
|
66
|
+
["aria-label"]?: string;
|
|
67
|
+
["aria-describedby"]?: string | undefined;
|
|
68
|
+
};
|
|
75
69
|
|
|
76
|
-
type State = {
|
|
77
|
-
focused: boolean
|
|
78
|
-
|
|
70
|
+
type State = {
|
|
71
|
+
focused: boolean;
|
|
72
|
+
};
|
|
79
73
|
|
|
80
|
-
type PropsWithForwardRef = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|};
|
|
74
|
+
type PropsWithForwardRef = Props & {
|
|
75
|
+
forwardedRef: React.ForwardedRef<HTMLInputElement>;
|
|
76
|
+
};
|
|
84
77
|
|
|
85
78
|
class FormWrappedTextField extends React.Component<PropsWithForwardRef, State> {
|
|
86
79
|
state = {
|
|
87
80
|
focused: false,
|
|
88
81
|
};
|
|
89
82
|
|
|
90
|
-
handleBlur = (e:
|
|
83
|
+
handleBlur = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
91
84
|
const {onBlur} = this.props;
|
|
92
85
|
onBlur && onBlur(e);
|
|
93
86
|
|
|
94
87
|
this.setState({focused: false});
|
|
95
88
|
};
|
|
96
89
|
|
|
97
|
-
handleFocus = (e:
|
|
90
|
+
handleFocus = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
98
91
|
const {onFocus} = this.props;
|
|
99
92
|
onFocus && onFocus(e);
|
|
100
93
|
|
|
@@ -169,8 +162,9 @@ class FormWrappedTextField extends React.Component<PropsWithForwardRef, State> {
|
|
|
169
162
|
// the form.
|
|
170
163
|
return (
|
|
171
164
|
<form
|
|
172
|
-
className={css(spanStyle)}
|
|
165
|
+
className={css(...spanStyle)}
|
|
173
166
|
style={extraStyles}
|
|
167
|
+
// @ts-expect-error [FEI-5003] - TS2322 - Type '((arg1: ChangeEvent<HTMLInputElement>) => unknown) | ((e: Event) => void)' is not assignable to type 'FormEventHandler<HTMLFormElement> | undefined'.
|
|
174
168
|
onSubmit={onSubmit || this.disableDefault}
|
|
175
169
|
>
|
|
176
170
|
{leftSideIcon && wrappedIcon}
|
|
@@ -243,6 +237,6 @@ const styles = StyleSheet.create({
|
|
|
243
237
|
},
|
|
244
238
|
});
|
|
245
239
|
|
|
246
|
-
export default
|
|
240
|
+
export default React.forwardRef<HTMLInputElement, Props>((props, ref) => (
|
|
247
241
|
<FormWrappedTextField {...props} forwardedRef={ref} />
|
|
248
|
-
))
|
|
242
|
+
));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/forbid-prop-types, react/no-unsafe */
|
|
2
|
-
// @flow
|
|
3
2
|
import {
|
|
4
3
|
components,
|
|
5
4
|
interactiveSizes,
|
|
@@ -21,13 +20,12 @@ const defaultBackgroundImage = {
|
|
|
21
20
|
url: null,
|
|
22
21
|
width: 0,
|
|
23
22
|
height: 0,
|
|
24
|
-
};
|
|
23
|
+
} as const;
|
|
25
24
|
|
|
26
|
-
function numSteps(range, step) {
|
|
25
|
+
function numSteps(range: any, step: any) {
|
|
27
26
|
return Math.floor((range[1] - range[0]) / step);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
// $FlowFixMe[signature-verification-failure]
|
|
31
29
|
const GraphSettings = createReactClass({
|
|
32
30
|
displayName: "GraphSettings",
|
|
33
31
|
|
|
@@ -121,7 +119,6 @@ const GraphSettings = createReactClass({
|
|
|
121
119
|
},
|
|
122
120
|
|
|
123
121
|
change(...args) {
|
|
124
|
-
// $FlowFixMe[object-this-reference]
|
|
125
122
|
return Changeable.change.apply(this, args);
|
|
126
123
|
},
|
|
127
124
|
|
|
@@ -141,7 +138,7 @@ const GraphSettings = createReactClass({
|
|
|
141
138
|
return;
|
|
142
139
|
}
|
|
143
140
|
|
|
144
|
-
const setUrl = (url, width, height) => {
|
|
141
|
+
const setUrl = (url, width: number, height: number) => {
|
|
145
142
|
const image = _.clone(this.props.backgroundImage);
|
|
146
143
|
image.url = url;
|
|
147
144
|
image.width = width;
|
|
@@ -154,8 +151,7 @@ const GraphSettings = createReactClass({
|
|
|
154
151
|
);
|
|
155
152
|
};
|
|
156
153
|
|
|
157
|
-
//
|
|
158
|
-
// $FlowFixMe[prop-missing]
|
|
154
|
+
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
159
155
|
const url = ReactDOM.findDOMNode(this.refs["bg-url"]).value; // eslint-disable-line react/no-string-refs
|
|
160
156
|
if (url) {
|
|
161
157
|
Util.getImageSize(url, (width, height) => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable react/sort-comp */
|
|
2
|
-
// @flow
|
|
3
2
|
/**
|
|
4
3
|
* Add hover behavior to another component.
|
|
5
4
|
*
|
|
@@ -46,35 +45,35 @@
|
|
|
46
45
|
*/
|
|
47
46
|
import * as React from "react";
|
|
48
47
|
|
|
49
|
-
type Handlers = {
|
|
50
|
-
onBlur: () =>
|
|
51
|
-
onClick: (e:
|
|
52
|
-
onFocus: () =>
|
|
53
|
-
onMouseDown: () =>
|
|
54
|
-
onMouseEnter: () =>
|
|
55
|
-
onMouseLeave: () =>
|
|
56
|
-
onTouchStart: () =>
|
|
57
|
-
onTouchEnd: () =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
type State = {
|
|
61
|
-
focused: boolean
|
|
62
|
-
hovered: boolean
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type Props = {
|
|
66
|
-
children?: (state: State, handlers: Handlers) => React.
|
|
67
|
-
disabled?: boolean
|
|
68
|
-
onClick?: (e:
|
|
69
|
-
startHovered: boolean
|
|
70
|
-
shouldUpdate: () => boolean
|
|
71
|
-
|
|
48
|
+
type Handlers = {
|
|
49
|
+
onBlur: () => unknown;
|
|
50
|
+
onClick: (e: React.MouseEvent) => unknown;
|
|
51
|
+
onFocus: () => unknown;
|
|
52
|
+
onMouseDown: () => unknown;
|
|
53
|
+
onMouseEnter: () => unknown;
|
|
54
|
+
onMouseLeave: () => unknown;
|
|
55
|
+
onTouchStart: () => unknown;
|
|
56
|
+
onTouchEnd: () => unknown;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type State = {
|
|
60
|
+
focused: boolean;
|
|
61
|
+
hovered: boolean;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type Props = {
|
|
65
|
+
children?: (state: State, handlers: Handlers) => React.ReactElement;
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
onClick?: (e: React.MouseEvent) => unknown;
|
|
68
|
+
startHovered: boolean;
|
|
69
|
+
shouldUpdate: () => boolean;
|
|
70
|
+
};
|
|
72
71
|
|
|
73
72
|
export default class HoverBehavior extends React.Component<Props, State> {
|
|
74
|
-
static defaultProps: {
|
|
75
|
-
shouldUpdate: () => boolean
|
|
76
|
-
startHovered: boolean
|
|
77
|
-
|
|
73
|
+
static defaultProps: {
|
|
74
|
+
shouldUpdate: () => boolean;
|
|
75
|
+
startHovered: boolean;
|
|
76
|
+
} = {
|
|
78
77
|
startHovered: false,
|
|
79
78
|
shouldUpdate: () => true,
|
|
80
79
|
};
|
|
@@ -88,12 +87,12 @@ export default class HoverBehavior extends React.Component<Props, State> {
|
|
|
88
87
|
};
|
|
89
88
|
}
|
|
90
89
|
|
|
90
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property 'focusFlag' has no initializer and is not definitely assigned in the constructor.
|
|
91
91
|
focusFlag: boolean;
|
|
92
|
+
// @ts-expect-error [FEI-5003] - TS2564 - Property 'waitingForClick' has no initializer and is not definitely assigned in the constructor.
|
|
92
93
|
waitingForClick: boolean;
|
|
93
94
|
|
|
94
|
-
handleClick: (e:
|
|
95
|
-
e: SyntheticMouseEvent<>,
|
|
96
|
-
) => {
|
|
95
|
+
handleClick: (e: React.MouseEvent) => void = (e: React.MouseEvent) => {
|
|
97
96
|
if (!this.props.disabled) {
|
|
98
97
|
if (this.props.shouldUpdate()) {
|
|
99
98
|
this.waitingForClick = false;
|
|
@@ -160,7 +159,7 @@ export default class HoverBehavior extends React.Component<Props, State> {
|
|
|
160
159
|
}
|
|
161
160
|
};
|
|
162
161
|
|
|
163
|
-
render(): React.
|
|
162
|
+
render(): React.ReactNode {
|
|
164
163
|
const handlers = {
|
|
165
164
|
onBlur: this.handleBlur,
|
|
166
165
|
onClick: this.handleClick,
|
|
@@ -170,7 +169,7 @@ export default class HoverBehavior extends React.Component<Props, State> {
|
|
|
170
169
|
onMouseLeave: this.handleMouseLeave,
|
|
171
170
|
onTouchStart: this.handleTouchStart,
|
|
172
171
|
onTouchEnd: this.handleTouchEnd,
|
|
173
|
-
};
|
|
172
|
+
} as const;
|
|
174
173
|
|
|
175
174
|
const {children} = this.props;
|
|
176
175
|
return children?.(this.state, handlers) || null;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/* eslint-disable @babel/no-invalid-this */
|
|
3
3
|
/* eslint-disable react/no-unsafe */
|
|
4
4
|
/* eslint-disable react/sort-comp */
|
|
5
|
-
// @flow
|
|
6
5
|
import createReactClass from "create-react-class";
|
|
7
6
|
import * as React from "react";
|
|
8
7
|
import _ from "underscore";
|
|
@@ -76,10 +75,11 @@ const JsonEditor: any = createReactClass({
|
|
|
76
75
|
valid: true,
|
|
77
76
|
},
|
|
78
77
|
function () {
|
|
78
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
79
79
|
this.props.onChange(json);
|
|
80
80
|
},
|
|
81
81
|
);
|
|
82
|
-
} catch (ex) {
|
|
82
|
+
} catch (ex: any) {
|
|
83
83
|
this.setState({
|
|
84
84
|
currentValue: nextString,
|
|
85
85
|
valid: false,
|
|
@@ -106,10 +106,11 @@ const JsonEditor: any = createReactClass({
|
|
|
106
106
|
valid: true,
|
|
107
107
|
},
|
|
108
108
|
function () {
|
|
109
|
+
// @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
109
110
|
this.props.onChange(json);
|
|
110
111
|
},
|
|
111
112
|
);
|
|
112
|
-
} catch (ex) {
|
|
113
|
+
} catch (ex: any) {
|
|
113
114
|
this.setState({
|
|
114
115
|
currentValue: JSON.stringify(this.props.value, null, 4),
|
|
115
116
|
valid: true,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* A generic link that removes common link styles.
|
|
4
3
|
*
|
|
@@ -15,53 +14,54 @@ import type {CSSProperties} from "aphrodite";
|
|
|
15
14
|
// button styling (backgroundColor, border, and padding).
|
|
16
15
|
const DEFAULT_HREF = "javascript:void(0)";
|
|
17
16
|
|
|
18
|
-
type DefaultProps = {
|
|
19
|
-
element:
|
|
17
|
+
type DefaultProps = {
|
|
18
|
+
element: React.ElementType;
|
|
20
19
|
// Whether the link should appear in a 'highlighted' state. In
|
|
21
20
|
// practice, this will apply the same styles that are applied on-hover.
|
|
22
|
-
highlighted: boolean
|
|
23
|
-
href: string
|
|
21
|
+
highlighted: boolean;
|
|
22
|
+
href: string;
|
|
24
23
|
// Pass through styles but also add our own to normalize
|
|
25
|
-
style: CSSProperties | Array<CSSProperties
|
|
26
|
-
|
|
24
|
+
style: CSSProperties | Array<CSSProperties>;
|
|
25
|
+
};
|
|
27
26
|
|
|
28
|
-
type LinkProps = {
|
|
29
|
-
|
|
30
|
-
children?: React.Node,
|
|
27
|
+
type LinkProps = DefaultProps & {
|
|
28
|
+
children?: React.ReactNode;
|
|
31
29
|
// An additional class name to add. This is supported so-as to allow
|
|
32
30
|
// Perseus to add class-based styles to links when using this
|
|
33
31
|
// component as its base link class.
|
|
34
|
-
className?: string
|
|
32
|
+
className?: string;
|
|
35
33
|
// Additional direct styles to add.
|
|
36
|
-
inlineStyles?: {
|
|
34
|
+
inlineStyles?: {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
};
|
|
37
37
|
// Optional referrer query parameter to add to the end of the URL, used
|
|
38
38
|
// for analytics purposes.
|
|
39
|
-
referrer?: string
|
|
39
|
+
referrer?: string;
|
|
40
40
|
// A target window to open a link in
|
|
41
|
-
target?: string
|
|
41
|
+
target?: string;
|
|
42
42
|
// The relationship between the linked page and the current page.
|
|
43
43
|
// Mostly used to prevent abuse from linked sites.
|
|
44
|
-
rel?: string
|
|
44
|
+
rel?: string;
|
|
45
45
|
// The data-test-id attribute
|
|
46
|
-
testId?: string
|
|
46
|
+
testId?: string;
|
|
47
47
|
// Specify either an HTML tag (like "a") or a React component (like
|
|
48
48
|
// React Router's `Link`) to be used as the underlying element.
|
|
49
49
|
|
|
50
|
-
onClick?: (e:
|
|
51
|
-
onMouseOver?: (e:
|
|
52
|
-
onMouseLeave?: (e:
|
|
53
|
-
onMouseEnter?: (e:
|
|
54
|
-
onBlur?: (e: SyntheticEvent
|
|
55
|
-
onFocus?: (e: SyntheticEvent
|
|
56
|
-
onKeyDown?: (e:
|
|
57
|
-
"aria-label"?: string
|
|
58
|
-
"aria-selected"?: boolean
|
|
59
|
-
"aria-current"?: boolean
|
|
60
|
-
role?: "tab"
|
|
61
|
-
title?: string
|
|
62
|
-
id?: string
|
|
63
|
-
tabIndex?: number
|
|
64
|
-
|
|
50
|
+
onClick?: (e: React.MouseEvent) => unknown;
|
|
51
|
+
onMouseOver?: (e: React.MouseEvent) => unknown;
|
|
52
|
+
onMouseLeave?: (e: React.MouseEvent) => unknown;
|
|
53
|
+
onMouseEnter?: (e: React.MouseEvent) => unknown;
|
|
54
|
+
onBlur?: (e: React.SyntheticEvent) => unknown;
|
|
55
|
+
onFocus?: (e: React.SyntheticEvent) => unknown;
|
|
56
|
+
onKeyDown?: (e: React.KeyboardEvent) => unknown;
|
|
57
|
+
["aria-label"]?: string;
|
|
58
|
+
["aria-selected"]?: boolean;
|
|
59
|
+
["aria-current"]?: boolean;
|
|
60
|
+
role?: "tab";
|
|
61
|
+
title?: string;
|
|
62
|
+
id?: string;
|
|
63
|
+
tabIndex?: number;
|
|
64
|
+
};
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* A wrapper that creates an anchor tag with normalized styles
|
|
@@ -70,11 +70,11 @@ class Link extends React.Component<LinkProps> {
|
|
|
70
70
|
static defaultProps: DefaultProps = {
|
|
71
71
|
highlighted: false,
|
|
72
72
|
href: DEFAULT_HREF,
|
|
73
|
-
style:
|
|
73
|
+
style: [] as Array<CSSProperties>,
|
|
74
74
|
element: "a",
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
render(): React.
|
|
77
|
+
render(): React.ReactNode {
|
|
78
78
|
const {
|
|
79
79
|
children,
|
|
80
80
|
className,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Provides a simple styled button
|
|
4
3
|
*
|
|
@@ -8,20 +7,20 @@ import {StyleSheet, css} from "aphrodite";
|
|
|
8
7
|
import PropTypes from "prop-types";
|
|
9
8
|
import * as React from "react";
|
|
10
9
|
|
|
11
|
-
class SimpleButton extends React.Component
|
|
10
|
+
class SimpleButton extends React.Component<any> {
|
|
12
11
|
static propTypes = {
|
|
13
12
|
children: PropTypes.node,
|
|
14
13
|
color: PropTypes.oneOf(["orange", "green"]),
|
|
15
14
|
onClick: PropTypes.func,
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
static defaultProps:
|
|
17
|
+
static defaultProps: any = {
|
|
19
18
|
children: null,
|
|
20
19
|
color: "green",
|
|
21
20
|
onClick: () => {},
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
render(): React.
|
|
23
|
+
render(): React.ReactNode {
|
|
25
24
|
const {children, color, onClick, ...otherProps} = this.props;
|
|
26
25
|
return (
|
|
27
26
|
<div
|