@khanacademy/perseus 4.0.1 → 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 (210) hide show
  1. package/CHANGELOG.md +26 -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 +3 -3
  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 +53 -233
  25. package/dist/es/index.js.map +1 -1
  26. package/dist/index.js +53 -233
  27. package/dist/index.js.map +1 -1
  28. package/dist/multi-items/multi-renderer.d.ts +1 -1
  29. package/dist/multi-items/multi-renderer.js.flow +1 -1
  30. package/dist/multi-items/prop-type-builders.d.ts +1 -1
  31. package/dist/multi-items/shape-types.d.ts +1 -1
  32. package/dist/multi-items/shape-types.js.flow +1 -1
  33. package/dist/multi-items/tree-types.d.ts +1 -1
  34. package/dist/multi-items/tree-types.js.flow +1 -1
  35. package/dist/perseus-types.d.ts +0 -1
  36. package/dist/perseus-types.js.flow +0 -1
  37. package/dist/widgets/__stories__/test-keypad-context-wrapper.d.ts +6 -0
  38. package/dist/widgets/__stories__/test-keypad-context-wrapper.js.flow +12 -0
  39. package/dist/widgets/expression.d.ts +2 -2
  40. package/dist/widgets/expression.js.flow +2 -2
  41. package/dist/widgets/interaction/element-container.d.ts +5 -4
  42. package/dist/widgets/interaction/element-container.js.flow +6 -11
  43. package/dist/widgets/label-image/marker.d.ts +4 -4
  44. package/dist/widgets/label-image/marker.js.flow +4 -6
  45. package/dist/widgets/numeric-input.d.ts +0 -2
  46. package/dist/widgets/numeric-input.js.flow +0 -4
  47. package/dist/widgets/radio/base-radio.d.ts +7 -1
  48. package/dist/widgets/radio/base-radio.js.flow +7 -1
  49. package/dist/widgets/radio/choice-icon/choice-icon.d.ts +1 -1
  50. package/dist/widgets/radio/choice-icon/choice-icon.js.flow +1 -1
  51. package/dist/widgets/radio/choice-icon/cross-out-line.d.ts +2 -2
  52. package/dist/widgets/radio/choice-icon/cross-out-line.js.flow +2 -2
  53. package/dist/widgets/radio/focus-ring.d.ts +8 -1
  54. package/dist/widgets/radio/focus-ring.js.flow +8 -1
  55. package/dist/widgets/radio/option-status.d.ts +2 -2
  56. package/dist/widgets/radio/option-status.js.flow +2 -2
  57. package/dist/widgets/video-transcript-link.d.ts +1 -1
  58. package/dist/widgets/video-transcript-link.js.flow +1 -1
  59. package/package.json +4 -4
  60. package/src/__stories__/item-renderer.stories.tsx +2 -6
  61. package/src/__stories__/server-item-renderer.stories.tsx +2 -6
  62. package/src/__testdata__/item-renderer.testdata.ts +1 -1
  63. package/src/__testdata__/renderer.testdata.ts +1 -1
  64. package/src/__tests__/item-renderer.test.tsx +1 -2
  65. package/src/__tests__/renderer-api.test.tsx +1 -5
  66. package/src/__tests__/renderer.test.tsx +1 -1
  67. package/src/components/__stories__/button-group.stories.tsx +2 -6
  68. package/src/components/__stories__/fixed-to-responsive.stories.tsx +14 -16
  69. package/src/components/__stories__/graph.stories.tsx +3 -5
  70. package/src/components/__stories__/graphie.stories.tsx +3 -5
  71. package/src/components/__stories__/hud.stories.tsx +2 -6
  72. package/src/components/__stories__/icon.stories.tsx +1 -1
  73. package/src/components/__stories__/image-loader.stories.tsx +4 -4
  74. package/src/components/__stories__/info-tip.stories.tsx +2 -6
  75. package/src/components/__stories__/inline-icon.stories.tsx +4 -8
  76. package/src/components/__stories__/input-with-examples.stories.tsx +6 -10
  77. package/src/components/__stories__/lint.stories.tsx +12 -12
  78. package/src/components/__stories__/math-input.stories.tsx +4 -8
  79. package/src/components/__stories__/math-output.stories.tsx +3 -5
  80. package/src/components/__stories__/multi-button-group.stories.tsx +2 -6
  81. package/src/components/__stories__/number-input.stories.tsx +6 -8
  82. package/src/components/__stories__/prop-check-box.stories.tsx +9 -9
  83. package/src/components/__stories__/range-input.stories.tsx +4 -6
  84. package/src/components/__stories__/simple-keypad-input.stories.tsx +2 -4
  85. package/src/components/__stories__/sortable.stories.tsx +15 -15
  86. package/src/components/__stories__/stub-tag-editor.stories.tsx +5 -9
  87. package/src/components/__stories__/svg-image.stories.tsx +10 -18
  88. package/src/components/__stories__/tex.stories.tsx +1 -3
  89. package/src/components/__stories__/text-buttons.stories.tsx +10 -22
  90. package/src/components/__stories__/text-input.stories.tsx +4 -10
  91. package/src/components/__stories__/text-list-editor.stories.tsx +1 -3
  92. package/src/components/__stories__/zoomable-tex.stories.tsx +6 -4
  93. package/src/components/__stories__/zoomable.stories.tsx +1 -3
  94. package/src/components/fixed-to-responsive.tsx +0 -1
  95. package/src/components/graph.tsx +0 -4
  96. package/src/components/highlighting/highlightable-content.tsx +4 -7
  97. package/src/components/highlighting/ui/highlight-renderer.tsx +6 -9
  98. package/src/components/highlighting/ui/highlight-set-renderer.tsx +5 -8
  99. package/src/components/highlighting/ui/highlight-tooltip.tsx +2 -2
  100. package/src/components/highlighting/ui/highlighting-ui.tsx +5 -15
  101. package/src/components/highlighting/ui/selection-tracker.tsx +6 -9
  102. package/src/components/highlighting/word-indexer.tsx +2 -6
  103. package/src/components/inline-icon.tsx +2 -2
  104. package/src/components/math-input.tsx +0 -2
  105. package/src/components/number-input.tsx +0 -2
  106. package/src/components/simple-keypad-input.tsx +2 -2
  107. package/src/components/tex-buttons.tsx +2 -2
  108. package/src/components/text-list-editor.tsx +0 -4
  109. package/src/components/visibility-observer/__stories__/visibility-observer.stories.tsx +1 -3
  110. package/src/components/zoomable-tex.tsx +0 -2
  111. package/src/components/zoomable.tsx +0 -4
  112. package/src/definition-context.tsx +0 -1
  113. package/src/error-boundary.tsx +4 -7
  114. package/src/hints-renderer.tsx +1 -1
  115. package/src/interactive2/__tests__/movable-point.test.ts +0 -1
  116. package/src/item-renderer.tsx +0 -5
  117. package/src/mixins/changeable.ts +1 -1
  118. package/src/multi-items/__stories__/multi-renderer.stories.tsx +1 -5
  119. package/src/multi-items/__tests__/items.test.ts +3 -13
  120. package/src/multi-items/__tests__/multi-renderer.test.tsx +3 -4
  121. package/src/multi-items/__tests__/prop-type-builders.test.ts +1 -1
  122. package/src/multi-items/__tests__/trees.test.ts +2 -10
  123. package/src/multi-items/multi-renderer.tsx +7 -10
  124. package/src/multi-items/prop-type-builders.ts +1 -1
  125. package/src/multi-items/shape-types.ts +1 -1
  126. package/src/multi-items/tree-types.ts +1 -1
  127. package/src/perseus-markdown.tsx +0 -2
  128. package/src/perseus-types.ts +1 -4
  129. package/src/renderer.tsx +2 -5
  130. package/src/server-item-renderer.tsx +0 -3
  131. package/src/util/graphie.ts +3 -3
  132. package/src/util/interactive.ts +0 -4
  133. package/src/util/math.ts +0 -3
  134. package/src/widgets/__stories__/categorizer.stories.tsx +1 -1
  135. package/src/widgets/__stories__/cs-program.stories.tsx +1 -1
  136. package/src/widgets/__stories__/definition.stories.tsx +3 -7
  137. package/src/widgets/__stories__/dropdown.stories.tsx +1 -1
  138. package/src/widgets/__stories__/explanation.stories.tsx +2 -2
  139. package/src/widgets/__stories__/expression.stories.tsx +113 -13
  140. package/src/widgets/__stories__/graded-group-set.stories.tsx +1 -1
  141. package/src/widgets/__stories__/graded-group.stories.tsx +1 -1
  142. package/src/widgets/__stories__/grapher.stories.tsx +7 -21
  143. package/src/widgets/__stories__/group.stories.tsx +1 -1
  144. package/src/widgets/__stories__/iframe.stories.tsx +1 -1
  145. package/src/widgets/__stories__/image.stories.tsx +2 -2
  146. package/src/widgets/__stories__/input-number.stories.tsx +3 -12
  147. package/src/widgets/__stories__/interaction.stories.tsx +1 -1
  148. package/src/widgets/__stories__/interactive-graph.stories.tsx +9 -9
  149. package/src/widgets/__stories__/matcher.stories.tsx +1 -1
  150. package/src/widgets/__stories__/matrix.stories.tsx +1 -1
  151. package/src/widgets/__stories__/number-line.stories.tsx +1 -1
  152. package/src/widgets/__stories__/numeric-input.stories.tsx +3 -5
  153. package/src/widgets/__stories__/orderer.stories.tsx +1 -1
  154. package/src/widgets/__stories__/passage-ref.stories.tsx +2 -2
  155. package/src/widgets/__stories__/passage.stories.tsx +3 -9
  156. package/src/widgets/__stories__/radio.stories.tsx +3 -5
  157. package/src/widgets/__stories__/sorter.stories.tsx +1 -1
  158. package/src/widgets/__stories__/{on-screen-keypad.stories.tsx → test-keypad-context-wrapper.tsx} +15 -57
  159. package/src/widgets/__stories__/transformer.stories.tsx +1 -1
  160. package/src/widgets/__stories__/unit.stories.tsx +1 -3
  161. package/src/widgets/__stories__/video-transcript-link.stories.tsx +2 -6
  162. package/src/widgets/__stories__/video.stories.tsx +1 -1
  163. package/src/widgets/__testdata__/expression.testdata.ts +16 -12
  164. package/src/widgets/__testdata__/group.testdata.ts +0 -2
  165. package/src/widgets/__testdata__/numeric-input.testdata.ts +0 -1
  166. package/src/widgets/__testdata__/transformer.testdata.ts +0 -1
  167. package/src/widgets/__tests__/group.test.tsx +0 -2
  168. package/src/widgets/__tests__/radio/focus-ring.test.tsx +0 -1
  169. package/src/widgets/__tests__/radio.test.ts +1 -1
  170. package/src/widgets/expression.tsx +4 -4
  171. package/src/widgets/graded-group-set.tsx +0 -4
  172. package/src/widgets/graded-group.tsx +0 -4
  173. package/src/widgets/grapher/util.tsx +1 -5
  174. package/src/widgets/grapher.tsx +0 -5
  175. package/src/widgets/group.tsx +0 -1
  176. package/src/widgets/interaction/element-container.tsx +7 -8
  177. package/src/widgets/interaction.tsx +0 -1
  178. package/src/widgets/interactive-graph.tsx +3 -62
  179. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +2 -4
  180. package/src/widgets/label-image/__stories__/marker.stories.tsx +9 -19
  181. package/src/widgets/label-image/marker.tsx +4 -4
  182. package/src/widgets/label-image.tsx +1 -1
  183. package/src/widgets/measurer.tsx +0 -1
  184. package/src/widgets/number-line.tsx +0 -2
  185. package/src/widgets/numeric-input.tsx +0 -3
  186. package/src/widgets/orderer.tsx +0 -3
  187. package/src/widgets/passage/passage-markdown.tsx +3 -3
  188. package/src/widgets/passage-ref-target.tsx +0 -1
  189. package/src/widgets/passage.tsx +1 -1
  190. package/src/widgets/plotter.tsx +0 -1
  191. package/src/widgets/radio/__stories__/base-radio.stories.tsx +13 -21
  192. package/src/widgets/radio/__stories__/choice-icon.stories.tsx +9 -11
  193. package/src/widgets/radio/__stories__/choice-none-above.stories.tsx +1 -1
  194. package/src/widgets/radio/__stories__/choice.stories.tsx +4 -4
  195. package/src/widgets/radio/__stories__/focus-ring.stories.tsx +1 -1
  196. package/src/widgets/radio/__stories__/option-status.stories.tsx +2 -4
  197. package/src/widgets/radio/base-radio.tsx +2 -2
  198. package/src/widgets/radio/choice-icon/choice-icon.tsx +5 -5
  199. package/src/widgets/radio/choice-icon/cross-out-line.tsx +1 -3
  200. package/src/widgets/radio/choice-none-above.tsx +2 -2
  201. package/src/widgets/radio/choice.tsx +1 -3
  202. package/src/widgets/radio/focus-ring.tsx +1 -1
  203. package/src/widgets/radio/option-status.tsx +2 -4
  204. package/src/widgets/radio/widget.tsx +0 -1
  205. package/src/widgets/reaction-diagram.tsx +2 -2
  206. package/src/widgets/transformer.tsx +1 -16
  207. package/src/widgets/video-transcript-link.tsx +1 -1
  208. package/src/widgets.ts +1 -1
  209. package/src/zoom.ts +0 -3
  210. package/tsconfig.tsbuildinfo +1 -1
@@ -27,7 +27,7 @@ type RendererData = ContentRendererData | HintRendererData;
27
27
  type RendererDataTree = Tree<ContentRendererData, HintRendererData, null>;
28
28
  /**
29
29
  * TODO(somewhatabstract, JIRA-XXXX):
30
- * Some usage of this type somewhere is causing Flow to believe that these
30
+ * Some usage of this type somewhere is causing TypeScript to believe that these
31
31
  * elements should be components. Don't know where that is, to fix it up
32
32
  * properly. In reality, these types are just too hard to use and aren't
33
33
  * really helping us out as I now have to suppress this rather than
@@ -39,7 +39,7 @@ declare type RendererDataTree = Tree<
39
39
  >;
40
40
  /**
41
41
  * TODO(somewhatabstract, JIRA-XXXX):
42
- * Some usage of this type somewhere is causing Flow to believe that these
42
+ * Some usage of this type somewhere is causing TypeScript to believe that these
43
43
  * elements should be components. Don't know where that is, to fix it up
44
44
  * properly. In reality, these types are just too hard to use and aren't
45
45
  * really helping us out as I now have to suppress this rather than
@@ -2,7 +2,7 @@
2
2
  * Utility functions to build React PropTypes for multi-items and shapes.
3
3
  *
4
4
  * If you're writing new components, though, consider using the Item and Shape
5
- * Flow types instead.
5
+ * types instead.
6
6
  */
7
7
  import type { Shape } from "./shape-types";
8
8
  /**
@@ -11,7 +11,7 @@
11
11
  * Shapes also enable us to traverse a multi-item-shaped tree with confidence,
12
12
  * even when we can't infer the shape from the tree alone.
13
13
  *
14
- * We *could* go all-in on a more general library to make certain Flow types
14
+ * We *could* go all-in on a more general library to make certain types
15
15
  * runtime-inspectable, in order to DRY some things up, but that's probably a
16
16
  * big ol' infrastructural magic mess, and the narrower scope of Shapes makes
17
17
  * it easier to be confident that we've covered all cases rather than having to
@@ -17,7 +17,7 @@
17
17
  * Shapes also enable us to traverse a multi-item-shaped tree with confidence,
18
18
  * even when we can't infer the shape from the tree alone.
19
19
  *
20
- * We *could* go all-in on a more general library to make certain Flow types
20
+ * We *could* go all-in on a more general library to make certain types
21
21
  * runtime-inspectable, in order to DRY some things up, but that's probably a
22
22
  * big ol' infrastructural magic mess, and the narrower scope of Shapes makes
23
23
  * it easier to be confident that we've covered all cases rather than having to
@@ -28,7 +28,7 @@ export type ObjectNode<C, H, T> = {
28
28
  * TODO(somewhatabstract, JIRA-XXXX):
29
29
  * We should ditch this type or create some helpers for working with it.
30
30
  * As it stands, consumers have to check each node's type before using it
31
- * in order to ensure that flow can track its refinement and appropriate use.
31
+ * in order to ensure that TypeScript can track its refinement and appropriate use.
32
32
  * It's messy.
33
33
  */
34
34
  export type Tree<C, H, T> = C | H | T | ArrayNode<C, H, T> | ObjectNode<C, H, T>;
@@ -34,7 +34,7 @@ export type ObjectNode<C, H, T> = {
34
34
  * TODO(somewhatabstract, JIRA-XXXX):
35
35
  * We should ditch this type or create some helpers for working with it.
36
36
  * As it stands, consumers have to check each node's type before using it
37
- * in order to ensure that flow can track its refinement and appropriate use.
37
+ * in order to ensure that TypeScript can track its refinement and appropriate use.
38
38
  * It's messy.
39
39
  */
40
40
  export type Tree<C, H, T> =
@@ -361,7 +361,6 @@ export type PerseusNumericInputWidgetOptions = {
361
361
  labelText: string;
362
362
  size: string;
363
363
  coefficient: boolean;
364
- multipleNumberInput?: boolean;
365
364
  rightAlign?: boolean;
366
365
  static: boolean;
367
366
  answerForms?: ReadonlyArray<PerseusNumericInputAnswerForm>;
@@ -532,7 +532,6 @@ export type PerseusNumericInputWidgetOptions = {|
532
532
  labelText: string,
533
533
  size: string,
534
534
  coefficient: boolean,
535
- multipleNumberInput?: boolean,
536
535
  rightAlign?: boolean,
537
536
  static: boolean,
538
537
  answerForms?: $ReadOnlyArray<PerseusNumericInputAnswerForm>,
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ type Props = {
3
+ children: React.ReactElement;
4
+ };
5
+ declare const TestKeypadContextWrapper: (props: Props) => React.ReactElement;
6
+ export default TestKeypadContextWrapper;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type Props = {|
9
+ children: React.Element<any>,
10
+ |};
11
+ declare var TestKeypadContextWrapper: (props: Props) => React.Element<any>;
12
+ declare export default typeof TestKeypadContextWrapper;
@@ -30,6 +30,8 @@ type DefaultProps = {
30
30
  };
31
31
  type OnInputErrorFunctionType = (arg1?: any, arg2?: any, arg3?: any) => boolean | null | undefined;
32
32
  export declare class Expression extends React.Component<Props, ExpressionState> {
33
+ _isMounted: boolean;
34
+ errorTimeout: null | number;
33
35
  static validate(userInput: string, rubric: Rubric, onInputError?: OnInputErrorFunctionType): PerseusScore;
34
36
  static getUserInputFromProps(props: Props): string;
35
37
  static getOneCorrectAnswerFromRubric(rubric: Rubric): string | null | undefined;
@@ -39,8 +41,6 @@ export declare class Expression extends React.Component<Props, ExpressionState>
39
41
  componentDidMount: () => void;
40
42
  componentDidUpdate: (prevProps: Props) => void;
41
43
  componentWillUnmount: () => void;
42
- _isMounted: boolean;
43
- errorTimeout: null | number;
44
44
  simpleValidate: (rubric: Rubric, onInputError: OnInputErrorFunctionType) => PerseusScore;
45
45
  getUserInput: () => string;
46
46
  change: (...args: any) => any | undefined;
@@ -46,6 +46,8 @@ declare type OnInputErrorFunctionType = (
46
46
  declare export class Expression
47
47
  extends React.Component<Props, ExpressionState>
48
48
  {
49
+ _isMounted: boolean;
50
+ errorTimeout: null | number;
49
51
  static validate(
50
52
  userInput: string,
51
53
  rubric: Rubric,
@@ -59,8 +61,6 @@ declare export class Expression
59
61
  componentDidMount: () => void;
60
62
  componentDidUpdate: (prevProps: Props) => void;
61
63
  componentWillUnmount: () => void;
62
- _isMounted: boolean;
63
- errorTimeout: null | number;
64
64
  simpleValidate: (
65
65
  rubric: Rubric,
66
66
  onInputError: OnInputErrorFunctionType
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- type ElementContainerProps = {
2
+ type Props = {
3
3
  children: React.ReactElement<any> | ReadonlyArray<React.ReactElement<any>>;
4
4
  initiallyVisible: boolean;
5
5
  onDelete?: () => void | null | undefined;
@@ -7,14 +7,15 @@ type ElementContainerProps = {
7
7
  onUp?: () => void | null | undefined;
8
8
  title: string | React.ReactElement<any>;
9
9
  };
10
- declare class ElementContainer extends React.Component<ElementContainerProps, {
10
+ type State = {
11
11
  show: boolean;
12
- }> {
12
+ };
13
+ declare class ElementContainer extends React.Component<Props, State> {
13
14
  static defaultProps: {
14
15
  initiallyVisible: boolean;
15
16
  title: string;
16
17
  };
17
- constructor(props: ElementContainerProps);
18
+ constructor(props: Props);
18
19
  toggle: (e: React.SyntheticEvent) => void;
19
20
  render(): React.ReactNode;
20
21
  }
@@ -5,7 +5,7 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- declare type ElementContainerProps = {|
8
+ declare type Props = {|
9
9
  children: React.Element<any> | $ReadOnlyArray<React.Element<any>>,
10
10
  initiallyVisible: boolean,
11
11
  onDelete?: () => void | null | void,
@@ -13,20 +13,15 @@ declare type ElementContainerProps = {|
13
13
  onUp?: () => void | null | void,
14
14
  title: string | React.Element<any>,
15
15
  |};
16
- declare class ElementContainer
17
- extends
18
- React.Component<
19
- ElementContainerProps,
20
- {|
21
- show: boolean,
22
- |}
23
- >
24
- {
16
+ declare type State = {|
17
+ show: boolean,
18
+ |};
19
+ declare class ElementContainer extends React.Component<Props, State> {
25
20
  static defaultProps: {|
26
21
  initiallyVisible: boolean,
27
22
  title: string,
28
23
  |};
29
- constructor(props: ElementContainerProps): this;
24
+ constructor(props: Props): this;
30
25
  toggle: (e: SyntheticEvent<>) => void;
31
26
  render(): React.Node;
32
27
  }
@@ -5,21 +5,21 @@
5
5
  */
6
6
  import * as React from "react";
7
7
  import type { InteractiveMarkerType } from "./types";
8
- type MarkerProps = InteractiveMarkerType & {
8
+ type Props = InteractiveMarkerType & {
9
9
  showSelected: boolean;
10
10
  showPulsate: boolean;
11
11
  onClick: (e: MouseEvent) => void;
12
12
  onKeyDown: (e: KeyboardEvent) => void;
13
13
  };
14
- type MarkerState = {
14
+ type State = {
15
15
  isFocused: boolean;
16
16
  };
17
- export default class Marker extends React.Component<MarkerProps, MarkerState> {
17
+ export default class Marker extends React.Component<Props, State> {
18
18
  _icon: HTMLElement | null | undefined;
19
19
  static defaultProps: {
20
20
  selected: ReadonlyArray<any>;
21
21
  };
22
- state: MarkerState;
22
+ state: State;
23
23
  handleFocus(): void;
24
24
  handleBlur(): void;
25
25
  renderIcon(): React.ReactElement<React.ComponentProps<"div">>;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  import type { InteractiveMarkerType } from "./types";
9
- declare type MarkerProps = {|
9
+ declare type Props = {|
10
10
  ...InteractiveMarkerType,
11
11
  ...{|
12
12
  showSelected: boolean,
@@ -15,17 +15,15 @@ declare type MarkerProps = {|
15
15
  onKeyDown: (e: KeyboardEvent) => void,
16
16
  |},
17
17
  |};
18
- declare type MarkerState = {|
18
+ declare type State = {|
19
19
  isFocused: boolean,
20
20
  |};
21
- declare export default class Marker
22
- extends React.Component<MarkerProps, MarkerState>
23
- {
21
+ declare export default class Marker extends React.Component<Props, State> {
24
22
  _icon: HTMLElement | null | void;
25
23
  static defaultProps: {|
26
24
  selected: $ReadOnlyArray<any>,
27
25
  |};
28
- state: MarkerState;
26
+ state: State;
29
27
  handleFocus(): void;
30
28
  handleBlur(): void;
31
29
  renderIcon(): React.Element<"div">;
@@ -16,7 +16,6 @@ type Props = ExternalProps & {
16
16
  answerForms: NonNullable<ExternalProps["answerForms"]>;
17
17
  labelText: NonNullable<ExternalProps["labelText"]>;
18
18
  linterContext: NonNullable<ExternalProps["linterContext"]>;
19
- multipleNumberInput: NonNullable<ExternalProps["multipleNumberInput"]>;
20
19
  currentValue: string;
21
20
  };
22
21
  type DefaultProps = {
@@ -28,7 +27,6 @@ type DefaultProps = {
28
27
  answerForms: Props["answerForms"];
29
28
  labelText: Props["labelText"];
30
29
  linterContext: Props["linterContext"];
31
- multipleNumberInput: Props["multipleNumberInput"];
32
30
  };
33
31
  type State = {
34
32
  previousValues: ReadonlyArray<string>;
@@ -31,9 +31,6 @@ declare type Props = {|
31
31
  answerForms: $NonMaybeType<$PropertyType<ExternalProps, "answerForms">>,
32
32
  labelText: $NonMaybeType<$PropertyType<ExternalProps, "labelText">>,
33
33
  linterContext: $NonMaybeType<$PropertyType<ExternalProps, "linterContext">>,
34
- multipleNumberInput: $NonMaybeType<
35
- $PropertyType<ExternalProps, "multipleNumberInput">
36
- >,
37
34
  currentValue: string,
38
35
  |},
39
36
  |};
@@ -46,7 +43,6 @@ declare type DefaultProps = {|
46
43
  answerForms: $PropertyType<Props, "answerForms">,
47
44
  labelText: $PropertyType<Props, "labelText">,
48
45
  linterContext: $PropertyType<Props, "linterContext">,
49
- multipleNumberInput: $PropertyType<Props, "multipleNumberInput">,
50
46
  |};
51
47
  declare type State = {|
52
48
  previousValues: $ReadOnlyArray<string>,
@@ -34,5 +34,11 @@ type Props = {
34
34
  registerFocusFunction?: (arg1: FocusFunction) => void;
35
35
  isLastUsedWidget?: boolean;
36
36
  };
37
- declare const BaseRadio: React.FC<Props>;
37
+ declare const BaseRadio: {
38
+ (props: Props): React.ReactElement;
39
+ defaultProps: {
40
+ editMode: boolean;
41
+ multipleSelect: boolean;
42
+ };
43
+ };
38
44
  export default BaseRadio;
@@ -40,5 +40,11 @@ declare type Props = {|
40
40
  registerFocusFunction?: (arg1: FocusFunction) => void,
41
41
  isLastUsedWidget?: boolean,
42
42
  |};
43
- declare var BaseRadio: React.StatelessFunctionalComponent<Props>;
43
+ declare var BaseRadio: {|
44
+ (props: Props): React.Element<any>,
45
+ defaultProps: {|
46
+ editMode: boolean,
47
+ multipleSelect: boolean,
48
+ |},
49
+ |};
44
50
  declare export default typeof BaseRadio;
@@ -12,5 +12,5 @@ type ChoiceIconProps = {
12
12
  reviewMode: boolean;
13
13
  previouslyAnswered: boolean;
14
14
  };
15
- declare const ChoiceIcon: React.FC<ChoiceIconProps>;
15
+ declare const ChoiceIcon: (props: ChoiceIconProps) => React.ReactElement;
16
16
  export default ChoiceIcon;
@@ -18,5 +18,5 @@ declare type ChoiceIconProps = {|
18
18
  reviewMode: boolean,
19
19
  previouslyAnswered: boolean,
20
20
  |};
21
- declare var ChoiceIcon: React.StatelessFunctionalComponent<ChoiceIconProps>;
21
+ declare var ChoiceIcon: (props: ChoiceIconProps) => React.Element<any>;
22
22
  declare export default typeof ChoiceIcon;
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
  * The "cross-out line" that appears over the icon when the choice has been
4
4
  * `crossedOut`.
5
5
  */
6
- declare const CrossOutLine: React.FC<{
6
+ declare const CrossOutLine: (props: {
7
7
  color: string;
8
- }>;
8
+ }) => React.ReactElement;
9
9
  export default CrossOutLine;
@@ -10,7 +10,7 @@ import * as React from "react";
10
10
  * The "cross-out line" that appears over the icon when the choice has been
11
11
  * `crossedOut`.
12
12
  */
13
- declare var CrossOutLine: React.StatelessFunctionalComponent<{|
13
+ declare var CrossOutLine: (props: {|
14
14
  color: string,
15
- |}>;
15
+ |}) => React.Element<any>;
16
16
  declare export default typeof CrossOutLine;
@@ -8,5 +8,12 @@ type Props = {
8
8
  color: string;
9
9
  multipleSelect: boolean;
10
10
  };
11
- declare const FocusRing: React.FC<Props>;
11
+ declare const FocusRing: {
12
+ (props: Props): React.ReactElement;
13
+ defaultProps: {
14
+ visible: boolean;
15
+ color: string;
16
+ multipleSelect: boolean;
17
+ };
18
+ };
12
19
  export default FocusRing;
@@ -11,5 +11,12 @@ declare type Props = {|
11
11
  color: string,
12
12
  multipleSelect: boolean,
13
13
  |};
14
- declare var FocusRing: React.StatelessFunctionalComponent<Props>;
14
+ declare var FocusRing: {|
15
+ (props: Props): React.Element<any>,
16
+ defaultProps: {|
17
+ visible: boolean,
18
+ color: string,
19
+ multipleSelect: boolean,
20
+ |},
21
+ |};
15
22
  declare export default typeof FocusRing;
@@ -6,12 +6,12 @@
6
6
  * between the states more immediately clear to users.
7
7
  */
8
8
  import * as React from "react";
9
- type OptionStatusProps = {
9
+ type Props = {
10
10
  correct: boolean;
11
11
  checked: boolean;
12
12
  crossedOut: boolean;
13
13
  previouslyAnswered: boolean;
14
14
  reviewMode: boolean;
15
15
  };
16
- declare const OptionStatus: React.FC<OptionStatusProps>;
16
+ declare const OptionStatus: (props: Props) => React.ReactElement;
17
17
  export default OptionStatus;
@@ -5,12 +5,12 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- declare type OptionStatusProps = {|
8
+ declare type Props = {|
9
9
  correct: boolean,
10
10
  checked: boolean,
11
11
  crossedOut: boolean,
12
12
  previouslyAnswered: boolean,
13
13
  reviewMode: boolean,
14
14
  |};
15
- declare var OptionStatus: React.StatelessFunctionalComponent<OptionStatusProps>;
15
+ declare var OptionStatus: (props: Props) => React.Element<any>;
16
16
  declare export default typeof OptionStatus;
@@ -8,5 +8,5 @@ type Props = {
8
8
  /**
9
9
  * Video Transcript Link Component.
10
10
  */
11
- declare const VideoTranscriptLink: React.FC<Props>;
11
+ declare const VideoTranscriptLink: (props: Props) => React.ReactElement;
12
12
  export default VideoTranscriptLink;
@@ -11,5 +11,5 @@ declare type Props = {|
11
11
  /**
12
12
  * Video Transcript Link Component.
13
13
  */
14
- declare var VideoTranscriptLink: React.StatelessFunctionalComponent<Props>;
14
+ declare var VideoTranscriptLink: (props: Props) => React.Element<any>;
15
15
  declare export default typeof VideoTranscriptLink;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "4.0.1",
6
+ "version": "5.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -23,10 +23,10 @@
23
23
  "dependencies": {
24
24
  "@khanacademy/kas": "^0.3.1",
25
25
  "@khanacademy/kmath": "^0.1.1",
26
- "@khanacademy/math-input": "^0.7.1",
26
+ "@khanacademy/math-input": "^1.0.0",
27
27
  "@khanacademy/perseus-linter": "^0.3.1",
28
- "@khanacademy/pure-markdown": "^0.2.1",
29
- "@khanacademy/simple-markdown": "^0.9.1",
28
+ "@khanacademy/pure-markdown": "^0.2.3",
29
+ "@khanacademy/simple-markdown": "^0.9.3",
30
30
  "mathquill": "git+https://git@github.com/Khan/mathquill.git#a9ae54e057c5c1acc8244a5627acbff29901d992"
31
31
  },
32
32
  "devDependencies": {
@@ -16,14 +16,10 @@ export default {
16
16
  title: "Perseus/Renderers/Item Renderer",
17
17
  } as Story;
18
18
 
19
- export const InputNumberItem: React.FC<StoryArgs> = (
20
- args,
21
- ): React.ReactElement => {
19
+ export const InputNumberItem = (args: StoryArgs): React.ReactElement => {
22
20
  return <ItemRendererWithDebugUI item={itemWithInput} />;
23
21
  };
24
22
 
25
- export const LabelImageItem: React.FC<StoryArgs> = (
26
- args,
27
- ): React.ReactElement => {
23
+ export const LabelImageItem = (args: StoryArgs): React.ReactElement => {
28
24
  return <ItemRendererWithDebugUI item={labelImageItem} />;
29
25
  };
@@ -16,14 +16,10 @@ export default {
16
16
  title: "Perseus/Renderers/Server Item Renderer",
17
17
  } as Story;
18
18
 
19
- export const InputNumberItem: React.FC<StoryArgs> = (
20
- args,
21
- ): React.ReactElement => {
19
+ export const InputNumberItem = (args: StoryArgs): React.ReactElement => {
22
20
  return <ServerItemRendererWithDebugUI item={itemWithInput} />;
23
21
  };
24
22
 
25
- export const LabelImageItem: React.FC<StoryArgs> = (
26
- args,
27
- ): React.ReactElement => {
23
+ export const LabelImageItem = (args: StoryArgs): React.ReactElement => {
28
24
  return <ServerItemRendererWithDebugUI item={labelImageItem} />;
29
25
  };
@@ -111,7 +111,7 @@ export const labelImageItem: PerseusItem = {
111
111
  export const mockedItem: PerseusItem = {
112
112
  // The mock widget type is not part of the PerseusWidget type union (and
113
113
  // we don't want to make it such to avoid polluting our production types
114
- // for test purposes) so we force Flow to accept it here.
114
+ // for test purposes) so we force TypeScript to accept it here.
115
115
  // @ts-expect-error [FEI-5003] - TS2352 - Conversion of type '{ content: string; images: {}; widgets: { "mock-widget 1": { graded: true; version: { major: number; minor: number; }; static: false; type: "mock-widget"; options: { static: false; smiling: boolean; }; alignment: string; }; "mock-widget 2": { ...; }; "mock-widget 3": { ...; }; "mock-widget 4": { ...; }; }; }' to type 'PerseusRenderer' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
116
116
  question: {
117
117
  content:
@@ -89,7 +89,7 @@ export const question2: PerseusRenderer = {
89
89
  export const mockedItem: PerseusRenderer = {
90
90
  // The mock widget type is not part of the PerseusWidget type union (and
91
91
  // we don't want to make it such to avoid polluting our production types
92
- // for test purposes) so we force Flow to accept it here.
92
+ // for test purposes) so we force TypeScript to accept it here.
93
93
  content:
94
94
  "Mock widgets ==> [[\u2603 mock-widget 1]] [[\u2603 mock-widget 2]] [[\u2603 mock-widget 3]]",
95
95
  images: {},
@@ -93,7 +93,7 @@ export const renderQuestion = (
93
93
  };
94
94
 
95
95
  // Finds a widget in the given renderer by ID. The return type is non-optional
96
- // (ie. it assumes the widget will exist) to make Flow happier in the tests
96
+ // (ie. it assumes the widget will exist) to make TypeScript happier in the tests
97
97
  // that use this function.
98
98
  const getWidgetById = (
99
99
  renderer: ItemRenderer,
@@ -111,7 +111,6 @@ const makeHint = (content: string): PerseusRenderer => ({
111
111
  content:
112
112
  "Maybe if you try using a calculator? See: [[\u2603 mock-hint-widget 1]]",
113
113
  widgets: {
114
- // $FlowFixMe[incompatible-return]
115
114
  "mock-hint-widget 1": {
116
115
  graded: true,
117
116
  version: {major: 0, minor: 0},
@@ -33,7 +33,6 @@ const delayedPromise = (value: undefined) => {
33
33
  const renderQuestionArea = function (item, apiOptions): any {
34
34
  const wrapper = mount(
35
35
  <RenderStateRoot>
36
- {/* $FlowFixMe[prop-missing] */}
37
36
  <Renderer
38
37
  content={item.question.content}
39
38
  images={item.question.images}
@@ -171,9 +170,8 @@ describe("Perseus API", function () {
171
170
  renderer.setInputValue(widgetId, "5");
172
171
  },
173
172
  });
173
+
174
174
  const input =
175
- // $FlowFixMe[incompatible-use]
176
- // $FlowFixMe[prop-missing]
177
175
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'querySelector' does not exist on type 'Element | Text'.
178
176
  ReactDOM.findDOMNode(renderer).querySelector("input");
179
177
 
@@ -251,8 +249,6 @@ describe("Perseus API", function () {
251
249
  });
252
250
 
253
251
  const inputs =
254
- // $FlowFixMe[incompatible-use]
255
- // $FlowFixMe[prop-missing]
256
252
  // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'querySelectorAll' does not exist on type 'Element | Text'.
257
253
  ReactDOM.findDOMNode(renderer).querySelectorAll("input");
258
254
  const input1 = inputs[0];
@@ -184,7 +184,7 @@ describe("renderer", () => {
184
184
 
185
185
  it("should derive type widget ID if type missing", () => {
186
186
  // Arrange
187
- // Note that the Flow types disallow this, but our Renderer handles the
187
+ // Note that the types disallow this, but our Renderer handles the
188
188
  // case so for now, I'm adding this test. We can remove the test
189
189
  // if/when we clean up the code for it in _getAllWidgetsInfo().
190
190
  const question = {
@@ -30,9 +30,7 @@ const HarnassedButtonGroup = (
30
30
  );
31
31
  };
32
32
 
33
- export const ButtonsWithNoTitles: React.FC<StoryArgs> = (
34
- args,
35
- ): React.ReactElement => {
33
+ export const ButtonsWithNoTitles = (args: StoryArgs): React.ReactElement => {
36
34
  return (
37
35
  <HarnassedButtonGroup
38
36
  buttons={[
@@ -44,9 +42,7 @@ export const ButtonsWithNoTitles: React.FC<StoryArgs> = (
44
42
  );
45
43
  };
46
44
 
47
- export const ButtonsWithTitles: React.FC<StoryArgs> = (
48
- args,
49
- ): React.ReactElement => {
45
+ export const ButtonsWithTitles = (args: StoryArgs): React.ReactElement => {
50
46
  return (
51
47
  <HarnassedButtonGroup
52
48
  buttons={[