@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.
Files changed (153) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/highlighting/highlightable-content.d.ts +4 -4
  3. package/dist/components/highlighting/highlightable-content.js.flow +4 -7
  4. package/dist/components/highlighting/ui/highlight-renderer.d.ts +6 -6
  5. package/dist/components/highlighting/ui/highlight-renderer.js.flow +6 -8
  6. package/dist/components/highlighting/ui/highlight-set-renderer.d.ts +5 -5
  7. package/dist/components/highlighting/ui/highlight-set-renderer.js.flow +5 -8
  8. package/dist/components/highlighting/ui/highlight-tooltip.d.ts +2 -2
  9. package/dist/components/highlighting/ui/highlight-tooltip.js.flow +2 -4
  10. package/dist/components/highlighting/ui/highlighting-ui.d.ts +2 -2
  11. package/dist/components/highlighting/ui/highlighting-ui.js.flow +2 -2
  12. package/dist/components/highlighting/ui/selection-tracker.d.ts +5 -5
  13. package/dist/components/highlighting/ui/selection-tracker.js.flow +5 -7
  14. package/dist/components/highlighting/word-indexer.d.ts +2 -2
  15. package/dist/components/highlighting/word-indexer.js.flow +2 -2
  16. package/dist/components/inline-icon.d.ts +35 -1
  17. package/dist/components/inline-icon.js.flow +11 -1
  18. package/dist/components/simple-keypad-input.d.ts +1 -1
  19. package/dist/components/simple-keypad-input.js.flow +1 -1
  20. package/dist/components/tex-buttons.d.ts +2 -2
  21. package/dist/components/tex-buttons.js.flow +2 -2
  22. package/dist/error-boundary.d.ts +4 -4
  23. package/dist/error-boundary.js.flow +4 -6
  24. package/dist/es/index.js +7 -10
  25. package/dist/es/index.js.map +1 -1
  26. package/dist/index.js +7 -10
  27. package/dist/index.js.map +1 -1
  28. package/dist/perseus-types.d.ts +0 -1
  29. package/dist/perseus-types.js.flow +0 -1
  30. package/dist/widgets/__stories__/test-keypad-context-wrapper.d.ts +2 -2
  31. package/dist/widgets/__stories__/test-keypad-context-wrapper.js.flow +2 -4
  32. package/dist/widgets/expression.d.ts +2 -2
  33. package/dist/widgets/expression.js.flow +2 -2
  34. package/dist/widgets/interaction/element-container.d.ts +5 -4
  35. package/dist/widgets/interaction/element-container.js.flow +6 -11
  36. package/dist/widgets/label-image/marker.d.ts +4 -4
  37. package/dist/widgets/label-image/marker.js.flow +4 -6
  38. package/dist/widgets/numeric-input.d.ts +0 -2
  39. package/dist/widgets/numeric-input.js.flow +0 -4
  40. package/dist/widgets/radio/base-radio.d.ts +7 -1
  41. package/dist/widgets/radio/base-radio.js.flow +7 -1
  42. package/dist/widgets/radio/choice-icon/choice-icon.d.ts +1 -1
  43. package/dist/widgets/radio/choice-icon/choice-icon.js.flow +1 -1
  44. package/dist/widgets/radio/choice-icon/cross-out-line.d.ts +2 -2
  45. package/dist/widgets/radio/choice-icon/cross-out-line.js.flow +2 -2
  46. package/dist/widgets/radio/focus-ring.d.ts +8 -1
  47. package/dist/widgets/radio/focus-ring.js.flow +8 -1
  48. package/dist/widgets/radio/option-status.d.ts +2 -2
  49. package/dist/widgets/radio/option-status.js.flow +2 -2
  50. package/dist/widgets/video-transcript-link.d.ts +1 -1
  51. package/dist/widgets/video-transcript-link.js.flow +1 -1
  52. package/package.json +4 -4
  53. package/src/__stories__/item-renderer.stories.tsx +2 -6
  54. package/src/__stories__/server-item-renderer.stories.tsx +2 -6
  55. package/src/components/__stories__/button-group.stories.tsx +2 -6
  56. package/src/components/__stories__/fixed-to-responsive.stories.tsx +14 -16
  57. package/src/components/__stories__/graph.stories.tsx +3 -5
  58. package/src/components/__stories__/graphie.stories.tsx +3 -5
  59. package/src/components/__stories__/hud.stories.tsx +2 -6
  60. package/src/components/__stories__/icon.stories.tsx +1 -1
  61. package/src/components/__stories__/image-loader.stories.tsx +4 -4
  62. package/src/components/__stories__/info-tip.stories.tsx +2 -6
  63. package/src/components/__stories__/inline-icon.stories.tsx +4 -8
  64. package/src/components/__stories__/input-with-examples.stories.tsx +6 -10
  65. package/src/components/__stories__/lint.stories.tsx +12 -12
  66. package/src/components/__stories__/math-input.stories.tsx +4 -8
  67. package/src/components/__stories__/math-output.stories.tsx +3 -5
  68. package/src/components/__stories__/multi-button-group.stories.tsx +2 -6
  69. package/src/components/__stories__/number-input.stories.tsx +6 -8
  70. package/src/components/__stories__/prop-check-box.stories.tsx +9 -9
  71. package/src/components/__stories__/range-input.stories.tsx +4 -6
  72. package/src/components/__stories__/simple-keypad-input.stories.tsx +2 -4
  73. package/src/components/__stories__/sortable.stories.tsx +15 -15
  74. package/src/components/__stories__/stub-tag-editor.stories.tsx +5 -9
  75. package/src/components/__stories__/svg-image.stories.tsx +10 -18
  76. package/src/components/__stories__/tex.stories.tsx +1 -3
  77. package/src/components/__stories__/text-buttons.stories.tsx +10 -22
  78. package/src/components/__stories__/text-input.stories.tsx +4 -10
  79. package/src/components/__stories__/text-list-editor.stories.tsx +1 -3
  80. package/src/components/__stories__/zoomable-tex.stories.tsx +6 -4
  81. package/src/components/__stories__/zoomable.stories.tsx +1 -3
  82. package/src/components/highlighting/highlightable-content.tsx +4 -7
  83. package/src/components/highlighting/ui/highlight-renderer.tsx +6 -9
  84. package/src/components/highlighting/ui/highlight-set-renderer.tsx +5 -8
  85. package/src/components/highlighting/ui/highlight-tooltip.tsx +2 -2
  86. package/src/components/highlighting/ui/highlighting-ui.tsx +2 -2
  87. package/src/components/highlighting/ui/selection-tracker.tsx +5 -8
  88. package/src/components/highlighting/word-indexer.tsx +2 -2
  89. package/src/components/inline-icon.tsx +2 -2
  90. package/src/components/simple-keypad-input.tsx +2 -2
  91. package/src/components/tex-buttons.tsx +2 -2
  92. package/src/components/visibility-observer/__stories__/visibility-observer.stories.tsx +1 -3
  93. package/src/error-boundary.tsx +4 -7
  94. package/src/multi-items/__stories__/multi-renderer.stories.tsx +1 -1
  95. package/src/multi-items/__tests__/multi-renderer.test.tsx +2 -3
  96. package/src/perseus-types.ts +0 -3
  97. package/src/util/graphie.ts +3 -3
  98. package/src/widgets/__stories__/categorizer.stories.tsx +1 -1
  99. package/src/widgets/__stories__/cs-program.stories.tsx +1 -1
  100. package/src/widgets/__stories__/definition.stories.tsx +3 -7
  101. package/src/widgets/__stories__/dropdown.stories.tsx +1 -1
  102. package/src/widgets/__stories__/explanation.stories.tsx +2 -2
  103. package/src/widgets/__stories__/expression.stories.tsx +5 -11
  104. package/src/widgets/__stories__/graded-group-set.stories.tsx +1 -1
  105. package/src/widgets/__stories__/graded-group.stories.tsx +1 -1
  106. package/src/widgets/__stories__/grapher.stories.tsx +7 -21
  107. package/src/widgets/__stories__/group.stories.tsx +1 -1
  108. package/src/widgets/__stories__/iframe.stories.tsx +1 -1
  109. package/src/widgets/__stories__/image.stories.tsx +1 -1
  110. package/src/widgets/__stories__/input-number.stories.tsx +3 -12
  111. package/src/widgets/__stories__/interaction.stories.tsx +1 -1
  112. package/src/widgets/__stories__/interactive-graph.stories.tsx +9 -9
  113. package/src/widgets/__stories__/matcher.stories.tsx +1 -1
  114. package/src/widgets/__stories__/matrix.stories.tsx +1 -1
  115. package/src/widgets/__stories__/number-line.stories.tsx +1 -1
  116. package/src/widgets/__stories__/numeric-input.stories.tsx +3 -5
  117. package/src/widgets/__stories__/orderer.stories.tsx +1 -1
  118. package/src/widgets/__stories__/passage-ref.stories.tsx +2 -2
  119. package/src/widgets/__stories__/passage.stories.tsx +3 -9
  120. package/src/widgets/__stories__/radio.stories.tsx +3 -5
  121. package/src/widgets/__stories__/sorter.stories.tsx +1 -1
  122. package/src/widgets/__stories__/test-keypad-context-wrapper.tsx +2 -4
  123. package/src/widgets/__stories__/transformer.stories.tsx +1 -1
  124. package/src/widgets/__stories__/unit.stories.tsx +1 -3
  125. package/src/widgets/__stories__/video-transcript-link.stories.tsx +2 -6
  126. package/src/widgets/__stories__/video.stories.tsx +1 -1
  127. package/src/widgets/__testdata__/group.testdata.ts +0 -2
  128. package/src/widgets/__tests__/group.test.tsx +0 -2
  129. package/src/widgets/__tests__/radio/focus-ring.test.tsx +0 -1
  130. package/src/widgets/expression.tsx +3 -3
  131. package/src/widgets/interaction/element-container.tsx +7 -8
  132. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +2 -4
  133. package/src/widgets/label-image/__stories__/marker.stories.tsx +9 -19
  134. package/src/widgets/label-image/marker.tsx +4 -4
  135. package/src/widgets/numeric-input.tsx +0 -3
  136. package/src/widgets/passage/passage-markdown.tsx +2 -2
  137. package/src/widgets/radio/__stories__/base-radio.stories.tsx +11 -19
  138. package/src/widgets/radio/__stories__/choice-icon.stories.tsx +9 -11
  139. package/src/widgets/radio/__stories__/choice-none-above.stories.tsx +1 -1
  140. package/src/widgets/radio/__stories__/choice.stories.tsx +4 -4
  141. package/src/widgets/radio/__stories__/focus-ring.stories.tsx +1 -1
  142. package/src/widgets/radio/__stories__/option-status.stories.tsx +2 -4
  143. package/src/widgets/radio/base-radio.tsx +1 -1
  144. package/src/widgets/radio/choice-icon/choice-icon.tsx +5 -5
  145. package/src/widgets/radio/choice-icon/cross-out-line.tsx +1 -3
  146. package/src/widgets/radio/choice-none-above.tsx +2 -2
  147. package/src/widgets/radio/choice.tsx +1 -3
  148. package/src/widgets/radio/focus-ring.tsx +1 -1
  149. package/src/widgets/radio/option-status.tsx +2 -4
  150. package/src/widgets/radio/widget.tsx +0 -1
  151. package/src/widgets/reaction-diagram.tsx +2 -2
  152. package/src/widgets/video-transcript-link.tsx +1 -1
  153. package/tsconfig.tsbuildinfo +1 -1
@@ -31,7 +31,7 @@ import type {
31
31
  DOMRange,
32
32
  } from "./types";
33
33
 
34
- type HighlightableContentProps = {
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 HighlightableContentState = {
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: HighlightableContentState = {
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 HighlightRendererProps = {
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 HighlightRendererState = {
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
- HighlightRendererProps,
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: HighlightRendererProps) {
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: HighlightRendererProps): ReadonlyArray<Rect> {
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 HighlightSetRendererProps = {
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 HighlightSetRendererState = {
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
- HighlightSetRendererProps,
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: HighlightSetRendererProps) {
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 HighlightTooltipProps = {
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<HighlightTooltipProps> {
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 HighlightingUIProps = {
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<HighlightingUIProps> {
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 SelectionTrackerProps = {
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 SelectionTrackerState = {
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
- SelectionTrackerProps,
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: SelectionTrackerProps) {
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 WordIndexerProps = {
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<WordIndexerProps> {
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: React.FC<InlineIconProps> = ({
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 TexButtonProps = {
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<TexButtonProps> {
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.FC<StoryArgs> = (
140
- args,
141
- ): React.ReactElement => {
139
+ export const AlertWhenNotVisible = (args: StoryArgs): React.ReactElement => {
142
140
  return <VisibilityTest />;
143
141
  };
@@ -2,18 +2,15 @@ import * as React from "react";
2
2
 
3
3
  import {Errors, Log} from "./logging/log";
4
4
 
5
- type ErrorBoundaryProps = {
5
+ type Props = {
6
6
  children: React.ReactNode;
7
7
  };
8
- type ErrorBoundaryState = {
8
+ type State = {
9
9
  error: string;
10
10
  };
11
11
 
12
- class ErrorBoundary extends React.Component<
13
- ErrorBoundaryProps,
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
  }
@@ -13,7 +13,7 @@ type Story = {
13
13
  title: string;
14
14
  };
15
15
 
16
- export const SingleItem: React.FC<StoryArgs> = (args): React.ReactElement => {
16
+ export const SingleItem = (args: StoryArgs): React.ReactElement => {
17
17
  const item = {
18
18
  _multi: {
19
19
  ...question1._multi,
@@ -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
- const SimpleLayout: React.FC<{
27
- renderers: any;
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
  }
@@ -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;
@@ -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 {Raphael set}
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 of arrays} endpointArray
1062
- * @return {Raphael set}
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: React.FC<StoryArgs> = (args): React.ReactElement => {
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: React.FC<StoryArgs> = (args): React.ReactElement => {
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: React.FC<StoryArgs> = (args): React.ReactElement => {
97
+ export const Question1 = (args: StoryArgs): React.ReactElement => {
98
98
  return <RendererWithDebugUI question={question1} />;
99
99
  };
100
100
 
101
- export const MultipleDefinitions: React.FC<StoryArgs> = (
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.FC<StoryArgs> = (
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: React.FC<StoryArgs> = (args): React.ReactElement => {
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: React.FC<StoryArgs> = (args): React.ReactElement => {
12
+ export const Question1 = (args: StoryArgs): React.ReactElement => {
13
13
  return <RendererWithDebugUI question={question1} />;
14
14
  };
15
15
 
16
- export const Question2: React.FC<StoryArgs> = (args): React.ReactElement => {
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.FC<StoryArgs> = (
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: React.FC<StoryArgs> = (args): React.ReactElement => {
89
+ export const Desktop = (args: StoryArgs): React.ReactElement => {
92
90
  return <WrappedKeypadContext item={expressionItem3} customKeypad={false} />;
93
91
  };
94
92
 
95
- export const Mobile: React.FC<StoryArgs> = (args): React.ReactElement => {
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.FC<StoryArgs> = (
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.FC<StoryArgs> = (
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: React.FC<StoryArgs> = (args): React.ReactElement => {
15
+ export const Article1 = (args: StoryArgs): React.ReactElement => {
16
16
  return (
17
17
  <RendererWithDebugUI
18
18
  apiOptions={{
@@ -12,7 +12,7 @@ type Story = {
12
12
  args: StoryArgs;
13
13
  };
14
14
 
15
- export const Question1: React.FC<StoryArgs> = (args): React.ReactElement => {
15
+ export const Question1 = (args: StoryArgs): React.ReactElement => {
16
16
  return (
17
17
  <RendererWithDebugUI
18
18
  question={question1}
@@ -17,44 +17,30 @@ export default {
17
17
 
18
18
  type StoryArgs = Record<any, any>;
19
19
 
20
- export const AbsoluteValueQuestion: React.FC<StoryArgs> = (
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.FC<StoryArgs> = (
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.FC<StoryArgs> = (
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.FC<StoryArgs> = (
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.FC<StoryArgs> = (
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.FC<StoryArgs> = (
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.FC<StoryArgs> = (
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: React.FC<StoryArgs> = (args): React.ReactElement => {
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: React.FC<StoryArgs> = (args): React.ReactElement => {
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: React.FC<StoryArgs> = (args): React.ReactElement => {
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.FC<InputNumberOptions> = (
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.FC<InputNumberOptions> = (
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.FC<InputNumberOptions> = (
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;
@@ -9,6 +9,6 @@ export default {
9
9
 
10
10
  type StoryArgs = Record<any, any>;
11
11
 
12
- export const Question1: React.FC<StoryArgs> = (args): React.ReactElement => (
12
+ export const Question1 = (args: StoryArgs): React.ReactElement => (
13
13
  <RendererWithDebugUI question={question1} />
14
14
  );