@khanacademy/perseus 4.0.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/components/highlighting/highlightable-content.d.ts +4 -4
- package/dist/components/highlighting/highlightable-content.js.flow +4 -7
- package/dist/components/highlighting/ui/highlight-renderer.d.ts +6 -6
- package/dist/components/highlighting/ui/highlight-renderer.js.flow +6 -8
- package/dist/components/highlighting/ui/highlight-set-renderer.d.ts +5 -5
- package/dist/components/highlighting/ui/highlight-set-renderer.js.flow +5 -8
- package/dist/components/highlighting/ui/highlight-tooltip.d.ts +2 -2
- package/dist/components/highlighting/ui/highlight-tooltip.js.flow +2 -4
- package/dist/components/highlighting/ui/highlighting-ui.d.ts +2 -2
- package/dist/components/highlighting/ui/highlighting-ui.js.flow +2 -2
- package/dist/components/highlighting/ui/selection-tracker.d.ts +5 -5
- package/dist/components/highlighting/ui/selection-tracker.js.flow +5 -7
- package/dist/components/highlighting/word-indexer.d.ts +2 -2
- package/dist/components/highlighting/word-indexer.js.flow +2 -2
- package/dist/components/inline-icon.d.ts +35 -1
- package/dist/components/inline-icon.js.flow +11 -1
- package/dist/components/simple-keypad-input.d.ts +1 -1
- package/dist/components/simple-keypad-input.js.flow +1 -1
- package/dist/components/tex-buttons.d.ts +2 -2
- package/dist/components/tex-buttons.js.flow +2 -2
- package/dist/error-boundary.d.ts +4 -4
- package/dist/error-boundary.js.flow +4 -6
- package/dist/es/index.js +7 -10
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +0 -1
- package/dist/perseus-types.js.flow +0 -1
- package/dist/widgets/__stories__/test-keypad-context-wrapper.d.ts +2 -2
- package/dist/widgets/__stories__/test-keypad-context-wrapper.js.flow +2 -4
- package/dist/widgets/expression.d.ts +2 -2
- package/dist/widgets/expression.js.flow +2 -2
- package/dist/widgets/interaction/element-container.d.ts +5 -4
- package/dist/widgets/interaction/element-container.js.flow +6 -11
- package/dist/widgets/label-image/marker.d.ts +4 -4
- package/dist/widgets/label-image/marker.js.flow +4 -6
- package/dist/widgets/numeric-input.d.ts +0 -2
- package/dist/widgets/numeric-input.js.flow +0 -4
- package/dist/widgets/radio/base-radio.d.ts +7 -1
- package/dist/widgets/radio/base-radio.js.flow +7 -1
- package/dist/widgets/radio/choice-icon/choice-icon.d.ts +1 -1
- package/dist/widgets/radio/choice-icon/choice-icon.js.flow +1 -1
- package/dist/widgets/radio/choice-icon/cross-out-line.d.ts +2 -2
- package/dist/widgets/radio/choice-icon/cross-out-line.js.flow +2 -2
- package/dist/widgets/radio/focus-ring.d.ts +8 -1
- package/dist/widgets/radio/focus-ring.js.flow +8 -1
- package/dist/widgets/radio/option-status.d.ts +2 -2
- package/dist/widgets/radio/option-status.js.flow +2 -2
- package/dist/widgets/video-transcript-link.d.ts +1 -1
- package/dist/widgets/video-transcript-link.js.flow +1 -1
- package/package.json +4 -4
- package/src/__stories__/item-renderer.stories.tsx +2 -6
- package/src/__stories__/server-item-renderer.stories.tsx +2 -6
- package/src/components/__stories__/button-group.stories.tsx +2 -6
- package/src/components/__stories__/fixed-to-responsive.stories.tsx +14 -16
- package/src/components/__stories__/graph.stories.tsx +3 -5
- package/src/components/__stories__/graphie.stories.tsx +3 -5
- package/src/components/__stories__/hud.stories.tsx +2 -6
- package/src/components/__stories__/icon.stories.tsx +1 -1
- package/src/components/__stories__/image-loader.stories.tsx +4 -4
- package/src/components/__stories__/info-tip.stories.tsx +2 -6
- package/src/components/__stories__/inline-icon.stories.tsx +4 -8
- package/src/components/__stories__/input-with-examples.stories.tsx +6 -10
- package/src/components/__stories__/lint.stories.tsx +12 -12
- package/src/components/__stories__/math-input.stories.tsx +4 -8
- package/src/components/__stories__/math-output.stories.tsx +3 -5
- package/src/components/__stories__/multi-button-group.stories.tsx +2 -6
- package/src/components/__stories__/number-input.stories.tsx +6 -8
- package/src/components/__stories__/prop-check-box.stories.tsx +9 -9
- package/src/components/__stories__/range-input.stories.tsx +4 -6
- package/src/components/__stories__/simple-keypad-input.stories.tsx +2 -4
- package/src/components/__stories__/sortable.stories.tsx +15 -15
- package/src/components/__stories__/stub-tag-editor.stories.tsx +5 -9
- package/src/components/__stories__/svg-image.stories.tsx +10 -18
- package/src/components/__stories__/tex.stories.tsx +1 -3
- package/src/components/__stories__/text-buttons.stories.tsx +10 -22
- package/src/components/__stories__/text-input.stories.tsx +4 -10
- package/src/components/__stories__/text-list-editor.stories.tsx +1 -3
- package/src/components/__stories__/zoomable-tex.stories.tsx +6 -4
- package/src/components/__stories__/zoomable.stories.tsx +1 -3
- package/src/components/highlighting/highlightable-content.tsx +4 -7
- package/src/components/highlighting/ui/highlight-renderer.tsx +6 -9
- package/src/components/highlighting/ui/highlight-set-renderer.tsx +5 -8
- package/src/components/highlighting/ui/highlight-tooltip.tsx +2 -2
- package/src/components/highlighting/ui/highlighting-ui.tsx +2 -2
- package/src/components/highlighting/ui/selection-tracker.tsx +5 -8
- package/src/components/highlighting/word-indexer.tsx +2 -2
- package/src/components/inline-icon.tsx +2 -2
- package/src/components/simple-keypad-input.tsx +2 -2
- package/src/components/tex-buttons.tsx +2 -2
- package/src/components/visibility-observer/__stories__/visibility-observer.stories.tsx +1 -3
- package/src/error-boundary.tsx +4 -7
- package/src/multi-items/__stories__/multi-renderer.stories.tsx +1 -1
- package/src/multi-items/__tests__/multi-renderer.test.tsx +2 -3
- package/src/perseus-types.ts +0 -3
- package/src/util/graphie.ts +3 -3
- package/src/widgets/__stories__/categorizer.stories.tsx +1 -1
- package/src/widgets/__stories__/cs-program.stories.tsx +1 -1
- package/src/widgets/__stories__/definition.stories.tsx +3 -7
- package/src/widgets/__stories__/dropdown.stories.tsx +1 -1
- package/src/widgets/__stories__/explanation.stories.tsx +2 -2
- package/src/widgets/__stories__/expression.stories.tsx +5 -11
- package/src/widgets/__stories__/graded-group-set.stories.tsx +1 -1
- package/src/widgets/__stories__/graded-group.stories.tsx +1 -1
- package/src/widgets/__stories__/grapher.stories.tsx +7 -21
- package/src/widgets/__stories__/group.stories.tsx +1 -1
- package/src/widgets/__stories__/iframe.stories.tsx +1 -1
- package/src/widgets/__stories__/image.stories.tsx +1 -1
- package/src/widgets/__stories__/input-number.stories.tsx +3 -12
- package/src/widgets/__stories__/interaction.stories.tsx +1 -1
- package/src/widgets/__stories__/interactive-graph.stories.tsx +9 -9
- package/src/widgets/__stories__/matcher.stories.tsx +1 -1
- package/src/widgets/__stories__/matrix.stories.tsx +1 -1
- package/src/widgets/__stories__/number-line.stories.tsx +1 -1
- package/src/widgets/__stories__/numeric-input.stories.tsx +3 -5
- package/src/widgets/__stories__/orderer.stories.tsx +1 -1
- package/src/widgets/__stories__/passage-ref.stories.tsx +2 -2
- package/src/widgets/__stories__/passage.stories.tsx +3 -9
- package/src/widgets/__stories__/radio.stories.tsx +3 -5
- package/src/widgets/__stories__/sorter.stories.tsx +1 -1
- package/src/widgets/__stories__/test-keypad-context-wrapper.tsx +2 -4
- package/src/widgets/__stories__/transformer.stories.tsx +1 -1
- package/src/widgets/__stories__/unit.stories.tsx +1 -3
- package/src/widgets/__stories__/video-transcript-link.stories.tsx +2 -6
- package/src/widgets/__stories__/video.stories.tsx +1 -1
- package/src/widgets/__testdata__/group.testdata.ts +0 -2
- package/src/widgets/__tests__/group.test.tsx +0 -2
- package/src/widgets/__tests__/radio/focus-ring.test.tsx +0 -1
- package/src/widgets/expression.tsx +3 -3
- package/src/widgets/interaction/element-container.tsx +7 -8
- package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +2 -4
- package/src/widgets/label-image/__stories__/marker.stories.tsx +9 -19
- package/src/widgets/label-image/marker.tsx +4 -4
- package/src/widgets/numeric-input.tsx +0 -3
- package/src/widgets/passage/passage-markdown.tsx +2 -2
- package/src/widgets/radio/__stories__/base-radio.stories.tsx +11 -19
- package/src/widgets/radio/__stories__/choice-icon.stories.tsx +9 -11
- package/src/widgets/radio/__stories__/choice-none-above.stories.tsx +1 -1
- package/src/widgets/radio/__stories__/choice.stories.tsx +4 -4
- package/src/widgets/radio/__stories__/focus-ring.stories.tsx +1 -1
- package/src/widgets/radio/__stories__/option-status.stories.tsx +2 -4
- package/src/widgets/radio/base-radio.tsx +1 -1
- package/src/widgets/radio/choice-icon/choice-icon.tsx +5 -5
- package/src/widgets/radio/choice-icon/cross-out-line.tsx +1 -3
- package/src/widgets/radio/choice-none-above.tsx +2 -2
- package/src/widgets/radio/choice.tsx +1 -3
- package/src/widgets/radio/focus-ring.tsx +1 -1
- package/src/widgets/radio/option-status.tsx +2 -4
- package/src/widgets/radio/widget.tsx +0 -1
- package/src/widgets/reaction-diagram.tsx +2 -2
- package/src/widgets/video-transcript-link.tsx +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -31,7 +31,7 @@ import type {
|
|
|
31
31
|
DOMRange,
|
|
32
32
|
} from "./types";
|
|
33
33
|
|
|
34
|
-
type
|
|
34
|
+
type Props = {
|
|
35
35
|
// The highlightable content itself. Highlights will be defined relative to
|
|
36
36
|
// the content specified here.
|
|
37
37
|
children?: React.ReactElement<any>;
|
|
@@ -57,21 +57,18 @@ type HighlightableContentProps = {
|
|
|
57
57
|
serializedHighlights: SerializedHighlightSet;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
type
|
|
60
|
+
type State = {
|
|
61
61
|
// A cached list of DOMRanges, each representing one of the content's
|
|
62
62
|
// semantic words. Sorted in document order.
|
|
63
63
|
wordRanges: ReadonlyArray<DOMRange>;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
class HighlightableContent extends React.PureComponent<
|
|
67
|
-
HighlightableContentProps,
|
|
68
|
-
HighlightableContentState
|
|
69
|
-
> {
|
|
66
|
+
class HighlightableContent extends React.PureComponent<Props, State> {
|
|
70
67
|
// References to the mounted container and content divs.
|
|
71
68
|
_container: HTMLElement | null | undefined;
|
|
72
69
|
_content: HTMLElement | null | undefined;
|
|
73
70
|
|
|
74
|
-
state:
|
|
71
|
+
state: State = {
|
|
75
72
|
wordRanges: [],
|
|
76
73
|
};
|
|
77
74
|
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
|
|
22
22
|
import type {DOMHighlight, Position, Rect, ZIndexes} from "./types";
|
|
23
23
|
|
|
24
|
-
type
|
|
24
|
+
type Props = {
|
|
25
25
|
// The DOMHighlight to render.
|
|
26
26
|
highlight: DOMHighlight;
|
|
27
27
|
// A unique key corresponding to the given `highlight`.
|
|
@@ -36,7 +36,7 @@ type HighlightRendererProps = {
|
|
|
36
36
|
zIndexes: ZIndexes;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
type
|
|
39
|
+
type State = {
|
|
40
40
|
// The set of rectangles that cover this highlight's content, relative to
|
|
41
41
|
// the offset parent. This cache is updated on mount and on changes to
|
|
42
42
|
// the `highlight` and `offsetParent` props.
|
|
@@ -50,17 +50,14 @@ type HighlightRendererState = {
|
|
|
50
50
|
cachedHighlightRects: ReadonlyArray<Rect>;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
class HighlightRenderer extends React.PureComponent<
|
|
54
|
-
|
|
55
|
-
HighlightRendererState
|
|
56
|
-
> {
|
|
57
|
-
state: HighlightRendererState = {
|
|
53
|
+
class HighlightRenderer extends React.PureComponent<Props, State> {
|
|
54
|
+
state: State = {
|
|
58
55
|
cachedHighlightRects: this._computeRects(this.props),
|
|
59
56
|
// @ts-expect-error [FEI-5003] - TS2322 - Type '{ cachedHighlightRects: readonly Rect[]; tooltipIsHovered: boolean; }' is not assignable to type 'HighlightRendererState'.
|
|
60
57
|
tooltipIsHovered: false,
|
|
61
58
|
};
|
|
62
59
|
|
|
63
|
-
UNSAFE_componentWillReceiveProps(nextProps:
|
|
60
|
+
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
|
64
61
|
if (
|
|
65
62
|
this.props.highlight !== nextProps.highlight ||
|
|
66
63
|
this.props.offsetParent !== nextProps.offsetParent
|
|
@@ -76,7 +73,7 @@ class HighlightRenderer extends React.PureComponent<
|
|
|
76
73
|
* coordinates relative to the offset parent. That way, we can use them
|
|
77
74
|
* for CSS positioning.
|
|
78
75
|
*/
|
|
79
|
-
_computeRects(props:
|
|
76
|
+
_computeRects(props: Props): ReadonlyArray<Rect> {
|
|
80
77
|
const {highlight, offsetParent} = props;
|
|
81
78
|
|
|
82
79
|
// Get the set of rectangles that covers the range's text, relative to
|
|
@@ -15,7 +15,7 @@ import HighlightTooltip from "./highlight-tooltip";
|
|
|
15
15
|
|
|
16
16
|
import type {DOMHighlightSet, Position, ZIndexes} from "./types";
|
|
17
17
|
|
|
18
|
-
type
|
|
18
|
+
type Props = {
|
|
19
19
|
// Whether the highlights are user-editable. If false, highlights are
|
|
20
20
|
// read-only.
|
|
21
21
|
editable: boolean;
|
|
@@ -33,7 +33,7 @@ type HighlightSetRendererProps = {
|
|
|
33
33
|
// highlights below content.
|
|
34
34
|
zIndexes: ZIndexes;
|
|
35
35
|
};
|
|
36
|
-
type
|
|
36
|
+
type State = {
|
|
37
37
|
// If the user is currently hovering over a highlight, this field contains
|
|
38
38
|
// its key.
|
|
39
39
|
hoveredHighlightKey: string | null | undefined;
|
|
@@ -42,11 +42,8 @@ type HighlightSetRendererState = {
|
|
|
42
42
|
hoveringTooltipFor: string | null | undefined;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
class HighlightSetRenderer extends React.PureComponent<
|
|
46
|
-
|
|
47
|
-
HighlightSetRendererState
|
|
48
|
-
> {
|
|
49
|
-
state: HighlightSetRendererState = {
|
|
45
|
+
class HighlightSetRenderer extends React.PureComponent<Props, State> {
|
|
46
|
+
state: State = {
|
|
50
47
|
hoveredHighlightKey: null,
|
|
51
48
|
hoveringTooltipFor: null,
|
|
52
49
|
};
|
|
@@ -60,7 +57,7 @@ class HighlightSetRenderer extends React.PureComponent<
|
|
|
60
57
|
this._updateEditListeners(false, this.props.editable);
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
UNSAFE_componentWillReceiveProps(nextProps:
|
|
60
|
+
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
|
64
61
|
this._updateEditListeners(this.props.editable, nextProps.editable);
|
|
65
62
|
|
|
66
63
|
// If we were previously hovering over a highlight that has been
|
|
@@ -23,7 +23,7 @@ import {getRelativeRect} from "./util";
|
|
|
23
23
|
|
|
24
24
|
import type {Rect} from "./types";
|
|
25
25
|
|
|
26
|
-
type
|
|
26
|
+
type Props = {
|
|
27
27
|
label: string;
|
|
28
28
|
onClick: () => unknown;
|
|
29
29
|
onMouseEnter?: () => unknown;
|
|
@@ -33,7 +33,7 @@ type HighlightTooltipProps = {
|
|
|
33
33
|
offsetParent: Element;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
class HighlightTooltip extends React.PureComponent<
|
|
36
|
+
class HighlightTooltip extends React.PureComponent<Props> {
|
|
37
37
|
_getFocusRect(): Rect | null | undefined {
|
|
38
38
|
const {focusNode, focusOffset, offsetParent} = this.props;
|
|
39
39
|
|
|
@@ -21,7 +21,7 @@ import SelectionTracker from "./selection-tracker";
|
|
|
21
21
|
import type {TrackedSelection} from "./selection-tracker";
|
|
22
22
|
import type {DOMHighlight, DOMHighlightSet, DOMRange, ZIndexes} from "./types";
|
|
23
23
|
|
|
24
|
-
type
|
|
24
|
+
type Props = {
|
|
25
25
|
// A function that builds a DOMHighlight from the given DOMRange, if
|
|
26
26
|
// possible. If it would not currently be valid to add a highlight over the
|
|
27
27
|
// given DOMRange, returns null.
|
|
@@ -49,7 +49,7 @@ type HighlightingUIProps = {
|
|
|
49
49
|
zIndexes: ZIndexes;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
class HighlightingUI extends React.PureComponent<
|
|
52
|
+
class HighlightingUI extends React.PureComponent<Props> {
|
|
53
53
|
_handleAddHighlight(highlightToAdd: DOMHighlight) {
|
|
54
54
|
this.props.onAddHighlight(highlightToAdd);
|
|
55
55
|
|
|
@@ -22,7 +22,7 @@ export type TrackedSelection = {
|
|
|
22
22
|
proposedHighlight: DOMHighlight;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
type
|
|
25
|
+
type Props = {
|
|
26
26
|
// A function that builds a DOMHighlight from the given DOMRange, if
|
|
27
27
|
// possible. If it would not currently be valid to add a highlight over the
|
|
28
28
|
// given DOMRange, returns null.
|
|
@@ -38,7 +38,7 @@ type SelectionTrackerProps = {
|
|
|
38
38
|
enabled: boolean;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
type
|
|
41
|
+
type State = {
|
|
42
42
|
// The current state of the mouse button. We distinguish between down,
|
|
43
43
|
// down and the selection has changed since going down, and up.
|
|
44
44
|
mouseState: "down" | "down-and-selecting" | "up";
|
|
@@ -46,11 +46,8 @@ type SelectionTrackerState = {
|
|
|
46
46
|
trackedSelection: TrackedSelection | null | undefined;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
class SelectionTracker extends React.PureComponent<
|
|
50
|
-
|
|
51
|
-
SelectionTrackerState
|
|
52
|
-
> {
|
|
53
|
-
state: SelectionTrackerState = {
|
|
49
|
+
class SelectionTracker extends React.PureComponent<Props, State> {
|
|
50
|
+
state: State = {
|
|
54
51
|
mouseState: "up",
|
|
55
52
|
trackedSelection: null,
|
|
56
53
|
};
|
|
@@ -59,7 +56,7 @@ class SelectionTracker extends React.PureComponent<
|
|
|
59
56
|
this._updateListeners(false, this.props.enabled);
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
componentDidUpdate(prevProps:
|
|
59
|
+
componentDidUpdate(prevProps: Props) {
|
|
63
60
|
if (this.props.buildHighlight !== prevProps.buildHighlight) {
|
|
64
61
|
// The highlight-building function changed, so the
|
|
65
62
|
// proposedHighlight we built with it might be different, or no
|
|
@@ -18,7 +18,7 @@ import {PerseusError} from "../../perseus-error";
|
|
|
18
18
|
|
|
19
19
|
import type {DOMRange} from "./types";
|
|
20
20
|
|
|
21
|
-
type
|
|
21
|
+
type Props = {
|
|
22
22
|
// The content to display and traverse in search of words.
|
|
23
23
|
children?: React.ReactElement<any>;
|
|
24
24
|
// After each mount and update, this callback is called with the list of
|
|
@@ -26,7 +26,7 @@ type WordIndexerProps = {
|
|
|
26
26
|
onWordsUpdate: (wordRanges: ReadonlyArray<DOMRange>) => unknown;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
class WordIndexer extends React.PureComponent<
|
|
29
|
+
class WordIndexer extends React.PureComponent<Props> {
|
|
30
30
|
_container: HTMLElement | null | undefined;
|
|
31
31
|
/* eslint-enable react/sort-comp */
|
|
32
32
|
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
import PropTypes from "prop-types";
|
|
27
27
|
import * as React from "react";
|
|
28
28
|
|
|
29
|
-
const InlineIcon
|
|
29
|
+
const InlineIcon = ({
|
|
30
30
|
path,
|
|
31
31
|
width,
|
|
32
32
|
height,
|
|
33
33
|
style = {},
|
|
34
34
|
title,
|
|
35
|
-
}): React.ReactElement => (
|
|
35
|
+
}: InlineIconProps): React.ReactElement => (
|
|
36
36
|
<svg
|
|
37
37
|
role="img"
|
|
38
38
|
aria-hidden={!title}
|
|
@@ -17,6 +17,8 @@ import PropTypes from "prop-types";
|
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
|
|
19
19
|
export default class SimpleKeypadInput extends React.Component<any> {
|
|
20
|
+
_isMounted = false;
|
|
21
|
+
|
|
20
22
|
componentDidMount() {
|
|
21
23
|
// TODO(scottgrant): This is a hack to remove the deprecated call to
|
|
22
24
|
// this.isMounted() but is still considered an anti-pattern.
|
|
@@ -27,8 +29,6 @@ export default class SimpleKeypadInput extends React.Component<any> {
|
|
|
27
29
|
this._isMounted = false;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
_isMounted = false;
|
|
31
|
-
|
|
32
32
|
focus() {
|
|
33
33
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'focus' does not exist on type 'ReactInstance'.
|
|
34
34
|
this.refs.input.focus(); // eslint-disable-line react/no-string-refs
|
|
@@ -253,7 +253,7 @@ const buttonSets: ButtonSets = {
|
|
|
253
253
|
|
|
254
254
|
export type ButtonSetsType = ReadonlyArray<keyof typeof buttonSets>;
|
|
255
255
|
|
|
256
|
-
type
|
|
256
|
+
type Props = {
|
|
257
257
|
sets: ButtonSetsType;
|
|
258
258
|
onInsert: (arg1: Inserter) => void;
|
|
259
259
|
className?: string;
|
|
@@ -264,7 +264,7 @@ const buttonSetsPropType = PropTypes.arrayOf(
|
|
|
264
264
|
PropTypes.oneOf(_(buttonSets).keys()),
|
|
265
265
|
);
|
|
266
266
|
|
|
267
|
-
class TexButtons extends React.Component<
|
|
267
|
+
class TexButtons extends React.Component<Props> {
|
|
268
268
|
static buttonSets: typeof buttonSets = buttonSets;
|
|
269
269
|
static buttonSetsType: any = buttonSetsPropType;
|
|
270
270
|
|
|
@@ -136,8 +136,6 @@ class VisibilityTest extends React.Component<Props, State> {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export const AlertWhenNotVisible: React.
|
|
140
|
-
args,
|
|
141
|
-
): React.ReactElement => {
|
|
139
|
+
export const AlertWhenNotVisible = (args: StoryArgs): React.ReactElement => {
|
|
142
140
|
return <VisibilityTest />;
|
|
143
141
|
};
|
package/src/error-boundary.tsx
CHANGED
|
@@ -2,18 +2,15 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import {Errors, Log} from "./logging/log";
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type Props = {
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
};
|
|
8
|
-
type
|
|
8
|
+
type State = {
|
|
9
9
|
error: string;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
class ErrorBoundary extends React.Component<
|
|
13
|
-
|
|
14
|
-
ErrorBoundaryState
|
|
15
|
-
> {
|
|
16
|
-
constructor(props: ErrorBoundaryProps) {
|
|
12
|
+
class ErrorBoundary extends React.Component<Props, State> {
|
|
13
|
+
constructor(props: Props) {
|
|
17
14
|
super(props);
|
|
18
15
|
this.state = {error: ""};
|
|
19
16
|
}
|
|
@@ -23,9 +23,8 @@ import type {Item} from "../item-types";
|
|
|
23
23
|
import type {Tree} from "../tree-types";
|
|
24
24
|
|
|
25
25
|
// A little helper used in the render callback of a MultiRenderer.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}> = ({renderers}): React.ReactElement => {
|
|
26
|
+
type Props = {renderers: any};
|
|
27
|
+
const SimpleLayout = ({renderers}: Props): React.ReactElement => {
|
|
29
28
|
if (renderers == null) {
|
|
30
29
|
throw new Error("renderers was null");
|
|
31
30
|
}
|
package/src/perseus-types.ts
CHANGED
|
@@ -732,9 +732,6 @@ export type PerseusNumericInputWidgetOptions = {
|
|
|
732
732
|
size: string;
|
|
733
733
|
// A coefficient style number allows the student to use - for -1 and an empty string to mean 1.
|
|
734
734
|
coefficient: boolean;
|
|
735
|
-
// Whether we're asking for all correct solutions or only one
|
|
736
|
-
// NOTE: perseus_data.go says this is required even though it isn't necessary.
|
|
737
|
-
multipleNumberInput?: boolean;
|
|
738
735
|
// Whether to right-align the text or not
|
|
739
736
|
// NOTE: perseus_data.go says this is required even though it isn't necessary.
|
|
740
737
|
rightAlign?: boolean;
|
package/src/util/graphie.ts
CHANGED
|
@@ -1034,7 +1034,7 @@ GraphUtils.createGraphie = function (el: any) {
|
|
|
1034
1034
|
* the function at i
|
|
1035
1035
|
* @param {[]} rangeArray array of ranges over which the
|
|
1036
1036
|
* corresponding functions are defined
|
|
1037
|
-
* @return {
|
|
1037
|
+
* @return {Set<any>} set of paths
|
|
1038
1038
|
*/
|
|
1039
1039
|
plotPiecewise: function (fnArray, rangeArray) {
|
|
1040
1040
|
const paths = raphael.set();
|
|
@@ -1058,8 +1058,8 @@ GraphUtils.createGraphie = function (el: any) {
|
|
|
1058
1058
|
* return a Raphael set of Raphael circle objects at those
|
|
1059
1059
|
* coordinates
|
|
1060
1060
|
*
|
|
1061
|
-
* @param {Array
|
|
1062
|
-
* @return {
|
|
1061
|
+
* @param {Array<[number, number]>} endpointArray
|
|
1062
|
+
* @return {Set<any>} set of circles
|
|
1063
1063
|
*/
|
|
1064
1064
|
plotEndpointCircles: function (endpointArray) {
|
|
1065
1065
|
const circles = raphael.set();
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -94,18 +94,14 @@ const article = {
|
|
|
94
94
|
|
|
95
95
|
type StoryArgs = Record<any, any>;
|
|
96
96
|
|
|
97
|
-
export const Question1
|
|
97
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
98
98
|
return <RendererWithDebugUI question={question1} />;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
export const MultipleDefinitions: React.
|
|
102
|
-
args,
|
|
103
|
-
): React.ReactElement => {
|
|
101
|
+
export const MultipleDefinitions = (args: StoryArgs): React.ReactElement => {
|
|
104
102
|
return <RendererWithDebugUI question={question2} />;
|
|
105
103
|
};
|
|
106
104
|
|
|
107
|
-
export const ArticleDefintion: React.
|
|
108
|
-
args,
|
|
109
|
-
): React.ReactElement => {
|
|
105
|
+
export const ArticleDefintion = (args: StoryArgs): React.ReactElement => {
|
|
110
106
|
return <ArticleRenderer json={article} useNewStyles />;
|
|
111
107
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -9,10 +9,10 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const Question2
|
|
16
|
+
export const Question2 = (args: StoryArgs): React.ReactElement => {
|
|
17
17
|
return <RendererWithDebugUI question={question2} />;
|
|
18
18
|
};
|
|
@@ -45,9 +45,7 @@ const WrappedKeypadContext = (props: WrappedKeypadContextProps) => {
|
|
|
45
45
|
);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
export const DesktopKitchenSink: React.
|
|
49
|
-
args,
|
|
50
|
-
): React.ReactElement => {
|
|
48
|
+
export const DesktopKitchenSink = (args: StoryArgs): React.ReactElement => {
|
|
51
49
|
const reviewModeRubric = {
|
|
52
50
|
functions: ["f", "g", "h"],
|
|
53
51
|
times: true,
|
|
@@ -88,11 +86,11 @@ export const DesktopKitchenSink: React.FC<StoryArgs> = (
|
|
|
88
86
|
);
|
|
89
87
|
};
|
|
90
88
|
|
|
91
|
-
export const Desktop
|
|
89
|
+
export const Desktop = (args: StoryArgs): React.ReactElement => {
|
|
92
90
|
return <WrappedKeypadContext item={expressionItem3} customKeypad={false} />;
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
export const Mobile
|
|
93
|
+
export const Mobile = (args: StoryArgs): React.ReactElement => {
|
|
96
94
|
return (
|
|
97
95
|
<div>
|
|
98
96
|
<p>
|
|
@@ -107,9 +105,7 @@ export const Mobile: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
|
107
105
|
);
|
|
108
106
|
};
|
|
109
107
|
|
|
110
|
-
export const ExpressionItem2: React.
|
|
111
|
-
args,
|
|
112
|
-
): React.ReactElement => {
|
|
108
|
+
export const ExpressionItem2 = (args: StoryArgs): React.ReactElement => {
|
|
113
109
|
return (
|
|
114
110
|
<WrappedKeypadContext
|
|
115
111
|
item={expressionItem2}
|
|
@@ -118,9 +114,7 @@ export const ExpressionItem2: React.FC<StoryArgs> = (
|
|
|
118
114
|
);
|
|
119
115
|
};
|
|
120
116
|
|
|
121
|
-
export const ExpressionItem3: React.
|
|
122
|
-
args,
|
|
123
|
-
): React.ReactElement => {
|
|
117
|
+
export const ExpressionItem3 = (args: StoryArgs): React.ReactElement => {
|
|
124
118
|
return (
|
|
125
119
|
<WrappedKeypadContext
|
|
126
120
|
item={expressionItem3}
|
|
@@ -12,7 +12,7 @@ type GradedGroupSetStory = {
|
|
|
12
12
|
args: StoryArgs;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const Article1
|
|
15
|
+
export const Article1 = (args: StoryArgs): React.ReactElement => {
|
|
16
16
|
return (
|
|
17
17
|
<RendererWithDebugUI
|
|
18
18
|
apiOptions={{
|
|
@@ -17,44 +17,30 @@ export default {
|
|
|
17
17
|
|
|
18
18
|
type StoryArgs = Record<any, any>;
|
|
19
19
|
|
|
20
|
-
export const AbsoluteValueQuestion: React.
|
|
21
|
-
args,
|
|
22
|
-
): React.ReactElement => {
|
|
20
|
+
export const AbsoluteValueQuestion = (args: StoryArgs): React.ReactElement => {
|
|
23
21
|
return <RendererWithDebugUI question={absoluteValueQuestion} />;
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
export const ExponentialQuestion: React.
|
|
27
|
-
args,
|
|
28
|
-
): React.ReactElement => {
|
|
24
|
+
export const ExponentialQuestion = (args: StoryArgs): React.ReactElement => {
|
|
29
25
|
return <RendererWithDebugUI question={exponentialQuestion} />;
|
|
30
26
|
};
|
|
31
27
|
|
|
32
|
-
export const LinearQuestion: React.
|
|
33
|
-
args,
|
|
34
|
-
): React.ReactElement => {
|
|
28
|
+
export const LinearQuestion = (args: StoryArgs): React.ReactElement => {
|
|
35
29
|
return <RendererWithDebugUI question={linearQuestion} />;
|
|
36
30
|
};
|
|
37
31
|
|
|
38
|
-
export const LogarithmQuestion: React.
|
|
39
|
-
args,
|
|
40
|
-
): React.ReactElement => {
|
|
32
|
+
export const LogarithmQuestion = (args: StoryArgs): React.ReactElement => {
|
|
41
33
|
return <RendererWithDebugUI question={logarithmQuestion} />;
|
|
42
34
|
};
|
|
43
35
|
|
|
44
|
-
export const QuadraticQuestion: React.
|
|
45
|
-
args,
|
|
46
|
-
): React.ReactElement => {
|
|
36
|
+
export const QuadraticQuestion = (args: StoryArgs): React.ReactElement => {
|
|
47
37
|
return <RendererWithDebugUI question={quadraticQuestion} />;
|
|
48
38
|
};
|
|
49
39
|
|
|
50
|
-
export const SinusoidQuestion: React.
|
|
51
|
-
args,
|
|
52
|
-
): React.ReactElement => {
|
|
40
|
+
export const SinusoidQuestion = (args: StoryArgs): React.ReactElement => {
|
|
53
41
|
return <RendererWithDebugUI question={sinusoidQuestion} />;
|
|
54
42
|
};
|
|
55
43
|
|
|
56
|
-
export const ComplexQuestion: React.
|
|
57
|
-
args,
|
|
58
|
-
): React.ReactElement => {
|
|
44
|
+
export const ComplexQuestion = (args: StoryArgs): React.ReactElement => {
|
|
59
45
|
return <RendererWithDebugUI question={multipleAvailableTypesQuestion} />;
|
|
60
46
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -9,6 +9,6 @@ export default {
|
|
|
9
9
|
|
|
10
10
|
type StoryArgs = Record<any, any>;
|
|
11
11
|
|
|
12
|
-
export const Question1
|
|
12
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
13
13
|
return <RendererWithDebugUI question={question1} />;
|
|
14
14
|
};
|
|
@@ -16,7 +16,7 @@ type ImageStory = {
|
|
|
16
16
|
args: StoryArgs;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const Question1
|
|
19
|
+
export const Question1 = (args: StoryArgs): React.ReactElement => {
|
|
20
20
|
const apiOptions: APIOptions = {
|
|
21
21
|
isMobile: args.isMobile,
|
|
22
22
|
};
|
|
@@ -82,29 +82,20 @@ const updateWidgetOptions = (
|
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
export const Rational: React.
|
|
86
|
-
args,
|
|
87
|
-
): React.ReactElement => {
|
|
85
|
+
export const Rational = (args: InputNumberOptions): React.ReactElement => {
|
|
88
86
|
const question = updateWidgetOptions(question1, "input-number 1", args);
|
|
89
87
|
return <RendererWithDebugUI question={question} />;
|
|
90
88
|
};
|
|
91
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'args' does not exist on type 'FC<PerseusInputNumberWidgetOptions>'.
|
|
92
89
|
Rational.args = question1.widgets["input-number 1"].options;
|
|
93
90
|
|
|
94
|
-
export const PiSimplify: React.
|
|
95
|
-
args,
|
|
96
|
-
): React.ReactElement => {
|
|
91
|
+
export const PiSimplify = (args: InputNumberOptions): React.ReactElement => {
|
|
97
92
|
const question = updateWidgetOptions(question2, "input-number 1", args);
|
|
98
93
|
return <RendererWithDebugUI question={question} />;
|
|
99
94
|
};
|
|
100
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'args' does not exist on type 'FC<PerseusInputNumberWidgetOptions>'.
|
|
101
95
|
PiSimplify.args = question2.widgets["input-number 1"].options;
|
|
102
96
|
|
|
103
|
-
export const Percent: React.
|
|
104
|
-
args,
|
|
105
|
-
): React.ReactElement => {
|
|
97
|
+
export const Percent = (args: InputNumberOptions): React.ReactElement => {
|
|
106
98
|
const question = updateWidgetOptions(question3, "input-number 1", args);
|
|
107
99
|
return <RendererWithDebugUI question={question} />;
|
|
108
100
|
};
|
|
109
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'args' does not exist on type 'FC<PerseusInputNumberWidgetOptions>'.
|
|
110
101
|
Percent.args = question3.widgets["input-number 1"].options;
|