@khanacademy/perseus 4.0.2 → 6.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 (249) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/components/fixed-to-responsive.d.ts +27 -1
  3. package/dist/components/fixed-to-responsive.js.flow +27 -1
  4. package/dist/components/graph.d.ts +42 -26
  5. package/dist/components/graph.js.flow +42 -28
  6. package/dist/components/graphie.d.ts +34 -22
  7. package/dist/components/graphie.js.flow +37 -24
  8. package/dist/components/highlighting/highlightable-content.d.ts +4 -4
  9. package/dist/components/highlighting/highlightable-content.js.flow +4 -7
  10. package/dist/components/highlighting/ui/highlight-renderer.d.ts +6 -6
  11. package/dist/components/highlighting/ui/highlight-renderer.js.flow +6 -8
  12. package/dist/components/highlighting/ui/highlight-set-renderer.d.ts +5 -5
  13. package/dist/components/highlighting/ui/highlight-set-renderer.js.flow +5 -8
  14. package/dist/components/highlighting/ui/highlight-tooltip.d.ts +2 -2
  15. package/dist/components/highlighting/ui/highlight-tooltip.js.flow +2 -4
  16. package/dist/components/highlighting/ui/highlighting-ui.d.ts +2 -2
  17. package/dist/components/highlighting/ui/highlighting-ui.js.flow +2 -2
  18. package/dist/components/highlighting/ui/selection-tracker.d.ts +5 -5
  19. package/dist/components/highlighting/ui/selection-tracker.js.flow +5 -7
  20. package/dist/components/highlighting/word-indexer.d.ts +2 -2
  21. package/dist/components/highlighting/word-indexer.js.flow +2 -2
  22. package/dist/components/hud.d.ts +8 -14
  23. package/dist/components/hud.js.flow +7 -14
  24. package/dist/components/inline-icon.d.ts +27 -3
  25. package/dist/components/inline-icon.js.flow +26 -3
  26. package/dist/components/lint.d.ts +41 -13
  27. package/dist/components/lint.js.flow +42 -13
  28. package/dist/components/math-output.d.ts +15 -11
  29. package/dist/components/math-output.js.flow +15 -11
  30. package/dist/components/simple-keypad-input.d.ts +1 -1
  31. package/dist/components/simple-keypad-input.js.flow +1 -1
  32. package/dist/components/sortable.d.ts +17 -9
  33. package/dist/components/sortable.js.flow +22 -9
  34. package/dist/components/svg-image.d.ts +5 -3
  35. package/dist/components/svg-image.js.flow +5 -3
  36. package/dist/components/tex-buttons.d.ts +2 -2
  37. package/dist/components/tex-buttons.js.flow +2 -2
  38. package/dist/components/tooltip.d.ts +45 -4
  39. package/dist/components/tooltip.js.flow +44 -31
  40. package/dist/error-boundary.d.ts +4 -4
  41. package/dist/error-boundary.js.flow +4 -6
  42. package/dist/es/index.css +0 -3
  43. package/dist/es/index.js +484 -658
  44. package/dist/es/index.js.map +1 -1
  45. package/dist/index.css +0 -3
  46. package/dist/index.js +488 -655
  47. package/dist/index.js.map +1 -1
  48. package/dist/perseus-types.d.ts +11 -10
  49. package/dist/perseus-types.js.flow +11 -10
  50. package/dist/renderer.d.ts +2 -2
  51. package/dist/renderer.js.flow +1 -3
  52. package/dist/styles/shared.d.ts +0 -1
  53. package/dist/styles/shared.js.flow +0 -1
  54. package/dist/types.d.ts +0 -10
  55. package/dist/types.js.flow +0 -13
  56. package/dist/util/a11y.d.ts +0 -1
  57. package/dist/util/a11y.js.flow +0 -1
  58. package/dist/util/interactive.d.ts +2 -0
  59. package/dist/util/interactive.js.flow +2 -0
  60. package/dist/util.d.ts +3 -3
  61. package/dist/util.js.flow +4 -3
  62. package/dist/widgets/__stories__/test-keypad-context-wrapper.d.ts +2 -2
  63. package/dist/widgets/__stories__/test-keypad-context-wrapper.js.flow +2 -4
  64. package/dist/widgets/expression.d.ts +2 -2
  65. package/dist/widgets/expression.js.flow +2 -2
  66. package/dist/widgets/grapher.d.ts +1 -1
  67. package/dist/widgets/grapher.js.flow +12 -3
  68. package/dist/widgets/interaction/element-container.d.ts +5 -4
  69. package/dist/widgets/interaction/element-container.js.flow +6 -11
  70. package/dist/widgets/label-image/marker.d.ts +4 -4
  71. package/dist/widgets/label-image/marker.js.flow +4 -6
  72. package/dist/widgets/matcher.d.ts +7 -3
  73. package/dist/widgets/matcher.js.flow +7 -3
  74. package/dist/widgets/number-line.d.ts +1 -1
  75. package/dist/widgets/number-line.js.flow +1 -1
  76. package/dist/widgets/numeric-input.d.ts +0 -2
  77. package/dist/widgets/numeric-input.js.flow +0 -4
  78. package/dist/widgets/radio/base-radio.d.ts +7 -1
  79. package/dist/widgets/radio/base-radio.js.flow +7 -1
  80. package/dist/widgets/radio/choice-icon/choice-icon.d.ts +1 -1
  81. package/dist/widgets/radio/choice-icon/choice-icon.js.flow +1 -1
  82. package/dist/widgets/radio/choice-icon/cross-out-line.d.ts +2 -2
  83. package/dist/widgets/radio/choice-icon/cross-out-line.js.flow +2 -2
  84. package/dist/widgets/radio/focus-ring.d.ts +8 -1
  85. package/dist/widgets/radio/focus-ring.js.flow +8 -1
  86. package/dist/widgets/radio/option-status.d.ts +2 -2
  87. package/dist/widgets/radio/option-status.js.flow +2 -2
  88. package/dist/widgets/video-transcript-link.d.ts +1 -1
  89. package/dist/widgets/video-transcript-link.js.flow +1 -1
  90. package/package.json +4 -4
  91. package/src/__stories__/item-renderer.stories.tsx +2 -6
  92. package/src/__stories__/server-item-renderer.stories.tsx +2 -6
  93. package/src/__tests__/__snapshots__/item-renderer.test.tsx.snap +151 -159
  94. package/src/__tests__/__snapshots__/renderer.test.tsx.snap +358 -394
  95. package/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap +169 -189
  96. package/src/components/__stories__/button-group.stories.tsx +2 -6
  97. package/src/components/__stories__/fixed-to-responsive.stories.tsx +14 -16
  98. package/src/components/__stories__/graph.stories.tsx +3 -5
  99. package/src/components/__stories__/graphie.stories.tsx +3 -5
  100. package/src/components/__stories__/hud.stories.tsx +2 -6
  101. package/src/components/__stories__/icon.stories.tsx +1 -1
  102. package/src/components/__stories__/image-loader.stories.tsx +4 -4
  103. package/src/components/__stories__/info-tip.stories.tsx +2 -6
  104. package/src/components/__stories__/inline-icon.stories.tsx +4 -8
  105. package/src/components/__stories__/input-with-examples.stories.tsx +6 -10
  106. package/src/components/__stories__/lint.stories.tsx +62 -27
  107. package/src/components/__stories__/math-input.stories.tsx +4 -8
  108. package/src/components/__stories__/math-output.stories.tsx +3 -5
  109. package/src/components/__stories__/multi-button-group.stories.tsx +2 -6
  110. package/src/components/__stories__/number-input.stories.tsx +6 -8
  111. package/src/components/__stories__/prop-check-box.stories.tsx +9 -9
  112. package/src/components/__stories__/range-input.stories.tsx +4 -6
  113. package/src/components/__stories__/simple-keypad-input.stories.tsx +2 -4
  114. package/src/components/__stories__/sortable.stories.tsx +20 -20
  115. package/src/components/__stories__/stub-tag-editor.stories.tsx +5 -9
  116. package/src/components/__stories__/svg-image.stories.tsx +10 -18
  117. package/src/components/__stories__/tex.stories.tsx +1 -3
  118. package/src/components/__stories__/text-buttons.stories.tsx +10 -22
  119. package/src/components/__stories__/text-input.stories.tsx +4 -10
  120. package/src/components/__stories__/text-list-editor.stories.tsx +1 -3
  121. package/src/components/__stories__/tooltip.stories.tsx +52 -0
  122. package/src/components/__stories__/zoomable-tex.stories.tsx +6 -4
  123. package/src/components/__stories__/zoomable.stories.tsx +1 -3
  124. package/src/components/__tests__/__snapshots__/sortable.test.tsx.snap +114 -30
  125. package/src/components/__tests__/__snapshots__/sorter.test.tsx.snap +172 -204
  126. package/src/components/__tests__/sortable.test.tsx +54 -16
  127. package/src/components/__tests__/sorter.test.tsx +12 -9
  128. package/src/components/fixed-to-responsive.tsx +43 -38
  129. package/src/components/graph.tsx +95 -81
  130. package/src/components/graphie.tsx +62 -32
  131. package/src/components/highlighting/highlightable-content.tsx +4 -7
  132. package/src/components/highlighting/ui/highlight-renderer.tsx +6 -9
  133. package/src/components/highlighting/ui/highlight-set-renderer.tsx +5 -8
  134. package/src/components/highlighting/ui/highlight-tooltip.tsx +2 -2
  135. package/src/components/highlighting/ui/highlighting-ui.tsx +2 -2
  136. package/src/components/highlighting/ui/selection-tracker.tsx +5 -8
  137. package/src/components/highlighting/word-indexer.tsx +2 -2
  138. package/src/components/hud.tsx +104 -115
  139. package/src/components/inline-icon.tsx +17 -34
  140. package/src/components/input-with-examples.tsx +4 -4
  141. package/src/components/lint.tsx +47 -41
  142. package/src/components/math-output.tsx +17 -11
  143. package/src/components/simple-keypad-input.tsx +4 -4
  144. package/src/components/sortable.tsx +134 -94
  145. package/src/components/svg-image.tsx +10 -11
  146. package/src/components/tex-buttons.tsx +2 -2
  147. package/src/components/tooltip.tsx +189 -171
  148. package/src/components/visibility-observer/__stories__/visibility-observer.stories.tsx +1 -3
  149. package/src/error-boundary.tsx +4 -7
  150. package/src/interactive2/types.ts +2 -2
  151. package/src/multi-items/__stories__/multi-renderer.stories.tsx +1 -1
  152. package/src/multi-items/__tests__/__snapshots__/multi-renderer.test.tsx.snap +708 -764
  153. package/src/multi-items/__tests__/multi-renderer.test.tsx +2 -3
  154. package/src/perseus-types.ts +13 -12
  155. package/src/renderer.tsx +11 -22
  156. package/src/types.ts +0 -18
  157. package/src/util/graphie.ts +3 -3
  158. package/src/util/interactive.ts +18 -5
  159. package/src/util/tex.ts +13 -77
  160. package/src/util.ts +3 -4
  161. package/src/widgets/__stories__/categorizer.stories.tsx +1 -1
  162. package/src/widgets/__stories__/cs-program.stories.tsx +1 -1
  163. package/src/widgets/__stories__/definition.stories.tsx +3 -7
  164. package/src/widgets/__stories__/dropdown.stories.tsx +1 -1
  165. package/src/widgets/__stories__/explanation.stories.tsx +2 -2
  166. package/src/widgets/__stories__/expression.stories.tsx +5 -11
  167. package/src/widgets/__stories__/graded-group-set.stories.tsx +1 -1
  168. package/src/widgets/__stories__/graded-group.stories.tsx +1 -1
  169. package/src/widgets/__stories__/grapher.stories.tsx +7 -21
  170. package/src/widgets/__stories__/group.stories.tsx +1 -1
  171. package/src/widgets/__stories__/iframe.stories.tsx +1 -1
  172. package/src/widgets/__stories__/image.stories.tsx +1 -1
  173. package/src/widgets/__stories__/input-number.stories.tsx +3 -12
  174. package/src/widgets/__stories__/interaction.stories.tsx +1 -1
  175. package/src/widgets/__stories__/interactive-graph.stories.tsx +9 -9
  176. package/src/widgets/__stories__/matcher.stories.tsx +1 -1
  177. package/src/widgets/__stories__/matrix.stories.tsx +1 -1
  178. package/src/widgets/__stories__/number-line.stories.tsx +1 -1
  179. package/src/widgets/__stories__/numeric-input.stories.tsx +3 -5
  180. package/src/widgets/__stories__/orderer.stories.tsx +1 -1
  181. package/src/widgets/__stories__/passage-ref.stories.tsx +2 -2
  182. package/src/widgets/__stories__/passage.stories.tsx +3 -9
  183. package/src/widgets/__stories__/radio.stories.tsx +3 -5
  184. package/src/widgets/__stories__/sorter.stories.tsx +1 -1
  185. package/src/widgets/__stories__/test-keypad-context-wrapper.tsx +2 -4
  186. package/src/widgets/__stories__/transformer.stories.tsx +1 -1
  187. package/src/widgets/__stories__/unit.stories.tsx +1 -3
  188. package/src/widgets/__stories__/video-transcript-link.stories.tsx +2 -6
  189. package/src/widgets/__stories__/video.stories.tsx +1 -1
  190. package/src/widgets/__testdata__/group.testdata.ts +0 -2
  191. package/src/widgets/__tests__/__snapshots__/categorizer.test.ts.snap +717 -773
  192. package/src/widgets/__tests__/__snapshots__/cs-program.test.ts.snap +28 -36
  193. package/src/widgets/__tests__/__snapshots__/definition.test.ts.snap +52 -60
  194. package/src/widgets/__tests__/__snapshots__/dropdown.test.ts.snap +100 -108
  195. package/src/widgets/__tests__/__snapshots__/explanation.test.ts.snap +212 -260
  196. package/src/widgets/__tests__/__snapshots__/graded-group-set-jipt.test.ts.snap +613 -641
  197. package/src/widgets/__tests__/__snapshots__/graded-group-set.test.ts.snap +249 -261
  198. package/src/widgets/__tests__/__snapshots__/graded-group.test.ts.snap +671 -735
  199. package/src/widgets/__tests__/__snapshots__/grapher.test.ts.snap +2676 -2684
  200. package/src/widgets/__tests__/__snapshots__/group.test.tsx.snap +938 -1002
  201. package/src/widgets/__tests__/__snapshots__/iframe.test.ts.snap +28 -36
  202. package/src/widgets/__tests__/__snapshots__/image.test.ts.snap +227 -255
  203. package/src/widgets/__tests__/__snapshots__/input-number.test.ts.snap +353 -357
  204. package/src/widgets/__tests__/__snapshots__/interaction.test.ts.snap +255 -259
  205. package/src/widgets/__tests__/__snapshots__/interactive-graph.test.ts.snap +2401 -2433
  206. package/src/widgets/__tests__/__snapshots__/matcher.test.tsx.snap +600 -756
  207. package/src/widgets/__tests__/__snapshots__/matrix.test.ts.snap +420 -428
  208. package/src/widgets/__tests__/__snapshots__/number-line.test.ts.snap +762 -770
  209. package/src/widgets/__tests__/__snapshots__/numeric-input.test.ts.snap +373 -393
  210. package/src/widgets/__tests__/__snapshots__/orderer.test.ts.snap +116 -148
  211. package/src/widgets/__tests__/__snapshots__/passage-ref.test.ts.snap +289 -301
  212. package/src/widgets/__tests__/__snapshots__/passage.test.tsx.snap +1679 -1711
  213. package/src/widgets/__tests__/__snapshots__/radio.test.ts.snap +2692 -2960
  214. package/src/widgets/__tests__/__snapshots__/video.test.ts.snap +90 -98
  215. package/src/widgets/__tests__/group.test.tsx +0 -2
  216. package/src/widgets/__tests__/matcher.test.tsx +33 -9
  217. package/src/widgets/__tests__/radio/focus-ring.test.tsx +0 -1
  218. package/src/widgets/expression.tsx +12 -9
  219. package/src/widgets/grapher.tsx +3 -3
  220. package/src/widgets/image.tsx +2 -2
  221. package/src/widgets/interaction/element-container.tsx +7 -8
  222. package/src/widgets/interactive-graph.tsx +5 -5
  223. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +2 -4
  224. package/src/widgets/label-image/__stories__/marker.stories.tsx +9 -19
  225. package/src/widgets/label-image/marker.tsx +4 -4
  226. package/src/widgets/matcher.tsx +43 -24
  227. package/src/widgets/number-line.tsx +1 -1
  228. package/src/widgets/numeric-input.tsx +0 -3
  229. package/src/widgets/passage/passage-markdown.tsx +2 -2
  230. package/src/widgets/radio/__stories__/base-radio.stories.tsx +11 -19
  231. package/src/widgets/radio/__stories__/choice-icon.stories.tsx +9 -11
  232. package/src/widgets/radio/__stories__/choice-none-above.stories.tsx +1 -1
  233. package/src/widgets/radio/__stories__/choice.stories.tsx +4 -4
  234. package/src/widgets/radio/__stories__/focus-ring.stories.tsx +1 -1
  235. package/src/widgets/radio/__stories__/option-status.stories.tsx +2 -4
  236. package/src/widgets/radio/base-radio.tsx +1 -1
  237. package/src/widgets/radio/choice-icon/choice-icon.tsx +5 -5
  238. package/src/widgets/radio/choice-icon/cross-out-line.tsx +1 -3
  239. package/src/widgets/radio/choice-none-above.tsx +2 -2
  240. package/src/widgets/radio/choice.tsx +1 -3
  241. package/src/widgets/radio/focus-ring.tsx +1 -1
  242. package/src/widgets/radio/option-status.tsx +2 -4
  243. package/src/widgets/radio/widget.tsx +0 -1
  244. package/src/widgets/reaction-diagram.tsx +2 -2
  245. package/src/widgets/simulator.tsx +4 -6
  246. package/src/widgets/video-transcript-link.tsx +1 -1
  247. package/{tsconfig.json → tsconfig-build.json} +6 -6
  248. package/tsconfig-build.tsbuildinfo +1 -0
  249. package/tsconfig.tsbuildinfo +0 -1
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import type { TrackedSelection } from "./selection-tracker";
3
3
  import type { DOMHighlight, DOMHighlightSet, DOMRange, ZIndexes } from "./types";
4
- type HighlightingUIProps = {
4
+ type Props = {
5
5
  buildHighlight: (range: DOMRange) => DOMHighlight | null | undefined;
6
6
  contentNode: Node;
7
7
  editable: boolean;
@@ -11,7 +11,7 @@ type HighlightingUIProps = {
11
11
  onRemoveHighlight: (highlightKey: string) => unknown;
12
12
  zIndexes: ZIndexes;
13
13
  };
14
- declare class HighlightingUI extends React.PureComponent<HighlightingUIProps> {
14
+ declare class HighlightingUI extends React.PureComponent<Props> {
15
15
  _handleAddHighlight(highlightToAdd: DOMHighlight): void;
16
16
  _selectionIsValid(trackedSelection?: TrackedSelection | null): trackedSelection is TrackedSelection;
17
17
  render(): React.ReactNode;
@@ -12,7 +12,7 @@ import type {
12
12
  DOMRange,
13
13
  ZIndexes,
14
14
  } from "./types";
15
- declare type HighlightingUIProps = {|
15
+ declare type Props = {|
16
16
  buildHighlight: (range: DOMRange) => DOMHighlight | null | void,
17
17
  contentNode: Node,
18
18
  editable: boolean,
@@ -22,7 +22,7 @@ declare type HighlightingUIProps = {|
22
22
  onRemoveHighlight: (highlightKey: string) => mixed,
23
23
  zIndexes: ZIndexes,
24
24
  |};
25
- declare class HighlightingUI extends React.PureComponent<HighlightingUIProps> {
25
+ declare class HighlightingUI extends React.PureComponent<Props> {
26
26
  _handleAddHighlight(highlightToAdd: DOMHighlight): void;
27
27
  _selectionIsValid(trackedSelection?: TrackedSelection | null): boolean;
28
28
  render(): React.Node;
@@ -9,19 +9,19 @@ export type TrackedSelection = {
9
9
  focusOffset: number;
10
10
  proposedHighlight: DOMHighlight;
11
11
  };
12
- type SelectionTrackerProps = {
12
+ type Props = {
13
13
  buildHighlight: (domRange: DOMRange) => DOMHighlight | null | undefined;
14
14
  children?: (trackedSelection: TrackedSelection | null | undefined, userIsMouseSelecting: boolean) => React.ReactElement<any>;
15
15
  enabled: boolean;
16
16
  };
17
- type SelectionTrackerState = {
17
+ type State = {
18
18
  mouseState: "down" | "down-and-selecting" | "up";
19
19
  trackedSelection: TrackedSelection | null | undefined;
20
20
  };
21
- declare class SelectionTracker extends React.PureComponent<SelectionTrackerProps, SelectionTrackerState> {
22
- state: SelectionTrackerState;
21
+ declare class SelectionTracker extends React.PureComponent<Props, State> {
22
+ state: State;
23
23
  componentDidMount(): void;
24
- componentDidUpdate(prevProps: SelectionTrackerProps): void;
24
+ componentDidUpdate(prevProps: Props): void;
25
25
  componentWillUnmount(): void;
26
26
  _updateListeners(wasListening: boolean, willListen: boolean): void;
27
27
  /**
@@ -11,7 +11,7 @@ export type TrackedSelection = {|
11
11
  focusOffset: number,
12
12
  proposedHighlight: DOMHighlight,
13
13
  |};
14
- declare type SelectionTrackerProps = {|
14
+ declare type Props = {|
15
15
  buildHighlight: (domRange: DOMRange) => DOMHighlight | null | void,
16
16
  children?: (
17
17
  trackedSelection: TrackedSelection | null | void,
@@ -19,16 +19,14 @@ declare type SelectionTrackerProps = {|
19
19
  ) => React.Element<any>,
20
20
  enabled: boolean,
21
21
  |};
22
- declare type SelectionTrackerState = {|
22
+ declare type State = {|
23
23
  mouseState: "down" | "down-and-selecting" | "up",
24
24
  trackedSelection: TrackedSelection | null | void,
25
25
  |};
26
- declare class SelectionTracker
27
- extends React.PureComponent<SelectionTrackerProps, SelectionTrackerState>
28
- {
29
- state: SelectionTrackerState;
26
+ declare class SelectionTracker extends React.PureComponent<Props, State> {
27
+ state: State;
30
28
  componentDidMount(): void;
31
- componentDidUpdate(prevProps: SelectionTrackerProps): void;
29
+ componentDidUpdate(prevProps: Props): void;
32
30
  componentWillUnmount(): void;
33
31
  _updateListeners(wasListening: boolean, willListen: boolean): void;
34
32
 
@@ -13,11 +13,11 @@
13
13
  */
14
14
  import * as React from "react";
15
15
  import type { DOMRange } from "./types";
16
- type WordIndexerProps = {
16
+ type Props = {
17
17
  children?: React.ReactElement<any>;
18
18
  onWordsUpdate: (wordRanges: ReadonlyArray<DOMRange>) => unknown;
19
19
  };
20
- declare class WordIndexer extends React.PureComponent<WordIndexerProps> {
20
+ declare class WordIndexer extends React.PureComponent<Props> {
21
21
  _container: HTMLElement | null | undefined;
22
22
  componentDidMount(): void;
23
23
  componentDidUpdate(): void;
@@ -6,11 +6,11 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  import type { DOMRange } from "./types";
9
- declare type WordIndexerProps = {|
9
+ declare type Props = {|
10
10
  children?: React.Element<any>,
11
11
  onWordsUpdate: (wordRanges: $ReadOnlyArray<DOMRange>) => mixed,
12
12
  |};
13
- declare class WordIndexer extends React.PureComponent<WordIndexerProps> {
13
+ declare class WordIndexer extends React.PureComponent<Props> {
14
14
  _container: HTMLElement | null | void;
15
15
  componentDidMount(): void;
16
16
  componentDidUpdate(): void;
@@ -1,15 +1,9 @@
1
- import PropTypes from "prop-types";
2
- import * as React from "react";
3
- declare class HUD extends React.Component<any> {
4
- static propTypes: {
5
- message: PropTypes.Validator<string>;
6
- enabled: PropTypes.Validator<boolean>;
7
- onClick: PropTypes.Validator<(...args: any[]) => any>;
8
- fixedPosition: PropTypes.Requireable<boolean>;
9
- };
10
- static defaultProps: any;
11
- renderVisibleIcon: () => React.ReactElement;
12
- renderHiddenIcon: () => React.ReactElement;
13
- render(): React.ReactNode;
14
- }
1
+ /// <reference types="react" />
2
+ type Props = {
3
+ message: string;
4
+ enabled: boolean;
5
+ onClick: () => void;
6
+ fixedPosition?: boolean;
7
+ };
8
+ declare const HUD: ({ message, enabled, onClick, fixedPosition }: Props) => JSX.Element;
15
9
  export default HUD;
@@ -4,18 +4,11 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import PropTypes from "prop-types";
8
- import * as React from "react";
9
- declare class HUD extends React.Component<any> {
10
- static propTypes: {|
11
- message: PropTypes.Validator<string>,
12
- enabled: PropTypes.Validator<boolean>,
13
- onClick: PropTypes.Validator<(...args: any[]) => any>,
14
- fixedPosition: PropTypes.Requireable<boolean>,
15
- |};
16
- static defaultProps: any;
17
- renderVisibleIcon: () => React.Element<any>;
18
- renderHiddenIcon: () => React.Element<any>;
19
- render(): React.Node;
20
- }
7
+ declare type Props = {|
8
+ message: string,
9
+ enabled: boolean,
10
+ onClick: () => void,
11
+ fixedPosition?: boolean,
12
+ |};
13
+ declare var HUD: (x: Props) => React$Node;
21
14
  declare export default typeof HUD;
@@ -1,10 +1,34 @@
1
1
  import * as React from "react";
2
- declare const InlineIcon: React.FC<InlineIconProps>;
3
- export type InlineIconProps = {
2
+ type InlineIconProps = {
4
3
  path: string;
5
4
  height: number;
6
5
  width: number;
7
- style?: any;
6
+ style?: React.CSSProperties;
8
7
  title?: string;
9
8
  };
9
+ /**
10
+ * A stripped version of Icon.jsx from webapp. Takes an SVG icon and renders it
11
+ * inline like Font Awesome did.
12
+ *
13
+ * If you are looking for an icon that we've used before you should look in
14
+ * webapp's `icon-paths.js` which is a reference file for all the SVG paths
15
+ * that we've used. You'll need to copy the object from that file into
16
+ * whichever file you're using the icon and explicitly pass it in to the
17
+ * <InlineIcon/> React component.
18
+ *
19
+ * We assume that the viewBox is cropped and aligned to (0, 0), but icons can
20
+ * be defined differently. At some point we might want to add these attributes
21
+ * to `icon-paths.js`, but for now this is a fairly safe assumption.
22
+ *
23
+ * Sample usage:
24
+ *
25
+ * const editIcon = {
26
+ * path: "M41.209 53.753l5.39 0l0 5.39l3.136 0l6.468-6.517-8.477-8.526-6.517 6.517l0 3.136zm33.173-34.937q-.882-.882-1.862.049l-19.6 19.6q-.931.98-.049 1.862t1.862-.049l19.6-19.6q.931-.98.049-1.862zm-38.563 45.668l0-16.121l37.632-37.632 16.17 16.121-37.632 37.632l-16.17 0zm43.022-12.397l0 10.633q-.049 6.713-4.753 11.417t-11.368 4.704l-46.599 0q-6.713 0-11.417-4.753t-4.704-11.368l0-46.599q0-6.664 4.753-11.417t11.368-4.704l46.599 0q3.528 0 6.566 1.372.833.392.98 1.323t-.49 1.617l-2.744 2.744q-.784.784-1.96.441t-2.352-.343l-46.599 0q-3.675 0-6.321 2.646t-2.646 6.321l0 46.599q0 3.675 2.646 6.321t6.321 2.646l46.599 0q3.675 0 6.321-2.646t2.646-6.321l0-7.056q0-.735.49-1.225l3.577-3.577q.833-.833 1.96-.392t1.127 1.617zm7.203-51.646q2.254 0 3.773 1.568l8.526 8.526q1.568 1.568 1.568 3.822t-1.568 3.773l-5.145 5.145-16.121-16.121 5.145-5.145q1.568-1.568 3.822-1.568z",
27
+ * width: 100,
28
+ * height: 78.912,
29
+ * };
30
+ * <InlineIcon {...editIcon} />
31
+ *
32
+ */
33
+ declare const InlineIcon: ({ path, width, height, style, title, }: InlineIconProps) => React.ReactElement;
10
34
  export default InlineIcon;
@@ -5,12 +5,35 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- declare var InlineIcon: React.StatelessFunctionalComponent<InlineIconProps>;
9
- export type InlineIconProps = {|
8
+ declare type InlineIconProps = {|
10
9
  path: string,
11
10
  height: number,
12
11
  width: number,
13
- style?: any,
12
+ style?: React.CSSProperties,
14
13
  title?: string,
15
14
  |};
15
+ /**
16
+ * A stripped version of Icon.jsx from webapp. Takes an SVG icon and renders it
17
+ * inline like Font Awesome did.
18
+ *
19
+ * If you are looking for an icon that we've used before you should look in
20
+ * webapp's `icon-paths.js` which is a reference file for all the SVG paths
21
+ * that we've used. You'll need to copy the object from that file into
22
+ * whichever file you're using the icon and explicitly pass it in to the
23
+ * <InlineIcon/> React component.
24
+ *
25
+ * We assume that the viewBox is cropped and aligned to (0, 0), but icons can
26
+ * be defined differently. At some point we might want to add these attributes
27
+ * to `icon-paths.js`, but for now this is a fairly safe assumption.
28
+ *
29
+ * Sample usage:
30
+ *
31
+ * const editIcon = {
32
+ * path: "M41.209 53.753l5.39 0l0 5.39l3.136 0l6.468-6.517-8.477-8.526-6.517 6.517l0 3.136zm33.173-34.937q-.882-.882-1.862.049l-19.6 19.6q-.931.98-.049 1.862t1.862-.049l19.6-19.6q.931-.98.049-1.862zm-38.563 45.668l0-16.121l37.632-37.632 16.17 16.121-37.632 37.632l-16.17 0zm43.022-12.397l0 10.633q-.049 6.713-4.753 11.417t-11.368 4.704l-46.599 0q-6.713 0-11.417-4.753t-4.704-11.368l0-46.599q0-6.664 4.753-11.417t11.368-4.704l46.599 0q3.528 0 6.566 1.372.833.392.98 1.323t-.49 1.617l-2.744 2.744q-.784.784-1.96.441t-2.352-.343l-46.599 0q-3.675 0-6.321 2.646t-2.646 6.321l0 46.599q0 3.675 2.646 6.321t6.321 2.646l46.599 0q3.675 0 6.321-2.646t2.646-6.321l0-7.056q0-.735.49-1.225l3.577-3.577q.833-.833 1.96-.392t1.127 1.617zm7.203-51.646q2.254 0 3.773 1.568l8.526 8.526q1.568 1.568 1.568 3.822t-1.568 3.773l-5.145 5.145-16.121-16.121 5.145-5.145q1.568-1.568 3.822-1.568z",
33
+ * width: 100,
34
+ * height: 78.912,
35
+ * };
36
+ * <InlineIcon {...editIcon} />
37
+ */
38
+ declare var InlineIcon: (x: InlineIconProps) => React.Element<any>;
16
39
  declare export default typeof InlineIcon;
@@ -1,18 +1,46 @@
1
- import PropTypes from "prop-types";
2
1
  import * as React from "react";
3
- type Props = any;
4
- type State = any;
2
+ declare enum Severity {
3
+ Error = 1,
4
+ Warning = 2,
5
+ Recommendation = 3,
6
+ OfflineReportingOnly = 4
7
+ }
8
+ type Props = {
9
+ children: React.ReactNode;
10
+ inline?: boolean;
11
+ message: string;
12
+ ruleName: string;
13
+ insideTable: boolean;
14
+ blockHighlight?: boolean;
15
+ severity?: Severity;
16
+ };
17
+ type State = {
18
+ tooltipAbove: boolean;
19
+ };
20
+ /**
21
+ * This component renders "lint" nodes in a markdown parse tree. Lint nodes
22
+ * are inserted into the tree by the Perseus linter (see
23
+ * perseus-linter/src/index).
24
+ *
25
+ * This component serves multiple purposes
26
+ *
27
+ * 1) It renders a small circle in the right margin to indicate that there
28
+ * is lint on (or near) that line.
29
+ *
30
+ * 2) The area around the circle is hoverable: when the mouse moves over it
31
+ * the linty content is highlighted and a tooltip is displayed that explains
32
+ * what the problem is.
33
+ *
34
+ * 3) The hoverable area is also an HTML <a> tag. Clicking on it opens
35
+ * a new tab and links to additional details about the specific lint rule.
36
+ *
37
+ * The CSS required to position the circles in the right margin is tricky
38
+ * and it does not always work perfectly. When lint occurs on a block element
39
+ * that has a right margin (like anything blockquoted) the circle will appear
40
+ * to the left of where it belongs. And if there is more
41
+ **/
5
42
  declare class Lint extends React.Component<Props, State> {
6
- _positionTimeout: number | null | undefined;
7
- static propTypes: {
8
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
9
- inline: PropTypes.Requireable<boolean>;
10
- message: PropTypes.Validator<string>;
11
- ruleName: PropTypes.Validator<string>;
12
- insideTable: PropTypes.Validator<boolean>;
13
- blockHighlight: PropTypes.Requireable<boolean>;
14
- severity: PropTypes.Requireable<number>;
15
- };
43
+ _positionTimeout: number | undefined;
16
44
  state: State;
17
45
  componentDidMount(): void;
18
46
  componentWillUnmount(): void;
@@ -4,21 +4,50 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import PropTypes from "prop-types";
8
7
  import * as React from "react";
9
- declare type Props = any;
10
- declare type State = any;
8
+
9
+ declare var Severity: {|
10
+ +Error: 1, // 1
11
+ +Warning: 2, // 2
12
+ +Recommendation: 3, // 3
13
+ +OfflineReportingOnly: 4, // 4
14
+ |};
15
+ declare type Props = {|
16
+ children: React.Node,
17
+ inline?: boolean,
18
+ message: string,
19
+ ruleName: string,
20
+ insideTable: boolean,
21
+ blockHighlight?: boolean,
22
+ severity?: $Values<typeof Severity>,
23
+ |};
24
+ declare type State = {|
25
+ tooltipAbove: boolean,
26
+ |};
27
+ /**
28
+ * This component renders "lint" nodes in a markdown parse tree. Lint nodes
29
+ * are inserted into the tree by the Perseus linter (see
30
+ * perseus-linter/src/index).
31
+ *
32
+ * This component serves multiple purposes
33
+ *
34
+ * 1) It renders a small circle in the right margin to indicate that there
35
+ * is lint on (or near) that line.
36
+ *
37
+ * 2) The area around the circle is hoverable: when the mouse moves over it
38
+ * the linty content is highlighted and a tooltip is displayed that explains
39
+ * what the problem is.
40
+ *
41
+ * 3) The hoverable area is also an HTML <a> tag. Clicking on it opens
42
+ * a new tab and links to additional details about the specific lint rule.
43
+ *
44
+ * The CSS required to position the circles in the right margin is tricky
45
+ * and it does not always work perfectly. When lint occurs on a block element
46
+ * that has a right margin (like anything blockquoted) the circle will appear
47
+ * to the left of where it belongs. And if there is more
48
+ */
11
49
  declare class Lint extends React.Component<Props, State> {
12
- _positionTimeout: number | null | void;
13
- static propTypes: {|
14
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>,
15
- inline: PropTypes.Requireable<boolean>,
16
- message: PropTypes.Validator<string>,
17
- ruleName: PropTypes.Validator<string>,
18
- insideTable: PropTypes.Validator<boolean>,
19
- blockHighlight: PropTypes.Requireable<boolean>,
20
- severity: PropTypes.Requireable<number>,
21
- |};
50
+ _positionTimeout: number | void;
22
51
  state: State;
23
52
  componentDidMount(): void;
24
53
  componentWillUnmount(): void;
@@ -1,15 +1,19 @@
1
- import PropTypes from "prop-types";
2
1
  import * as React from "react";
3
- declare class MathOutput extends React.Component<any, any> {
4
- static propTypes: {
5
- value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
6
- className: PropTypes.Requireable<string>;
7
- labelText: PropTypes.Requireable<string>;
8
- onFocus: PropTypes.Requireable<(...args: any[]) => any>;
9
- onBlur: PropTypes.Requireable<(...args: any[]) => any>;
10
- };
11
- static defaultProps: any;
12
- state: any;
2
+ type Props = {
3
+ value: string | number;
4
+ className?: string;
5
+ labelText?: string;
6
+ onFocus: () => void;
7
+ onBlur: () => void;
8
+ };
9
+ type DefaultProps = Pick<Props, "value" | "onFocus" | "onBlur">;
10
+ type State = {
11
+ focused: boolean;
12
+ selectorNamespace: string;
13
+ };
14
+ declare class MathOutput extends React.Component<Props, State> {
15
+ static defaultProps: DefaultProps;
16
+ state: State;
13
17
  _getInputClassName: () => string;
14
18
  _getDisplayValue: (arg1: string | number) => string;
15
19
  render(): React.ReactNode;
@@ -4,18 +4,22 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import PropTypes from "prop-types";
8
7
  import * as React from "react";
9
- declare class MathOutput extends React.Component<any, any> {
10
- static propTypes: {|
11
- value: PropTypes.Requireable<$NonMaybeType<string | number | null | void>>,
12
- className: PropTypes.Requireable<string>,
13
- labelText: PropTypes.Requireable<string>,
14
- onFocus: PropTypes.Requireable<(...args: any[]) => any>,
15
- onBlur: PropTypes.Requireable<(...args: any[]) => any>,
16
- |};
17
- static defaultProps: any;
18
- state: any;
8
+ declare type Props = {|
9
+ value: string | number,
10
+ className?: string,
11
+ labelText?: string,
12
+ onFocus: () => void,
13
+ onBlur: () => void,
14
+ |};
15
+ declare type DefaultProps = Pick<Props, "value" | "onFocus" | "onBlur">;
16
+ declare type State = {|
17
+ focused: boolean,
18
+ selectorNamespace: string,
19
+ |};
20
+ declare class MathOutput extends React.Component<Props, State> {
21
+ static defaultProps: DefaultProps;
22
+ state: State;
19
23
  _getInputClassName: () => string;
20
24
  _getDisplayValue: (arg1: string | number) => string;
21
25
  render(): React.Node;
@@ -9,9 +9,9 @@
9
9
  */
10
10
  import * as React from "react";
11
11
  export default class SimpleKeypadInput extends React.Component<any> {
12
+ _isMounted: boolean;
12
13
  componentDidMount(): void;
13
14
  componentWillUnmount(): void;
14
- _isMounted: boolean;
15
15
  focus(): void;
16
16
  blur(): void;
17
17
  getValue(): string | number;
@@ -6,9 +6,9 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  declare export default class SimpleKeypadInput extends React.Component<any> {
9
+ _isMounted: boolean;
9
10
  componentDidMount(): void;
10
11
  componentWillUnmount(): void;
11
- _isMounted: boolean;
12
12
  focus(): void;
13
13
  blur(): void;
14
14
  getValue(): string | number;
@@ -1,6 +1,16 @@
1
1
  import * as React from "react";
2
+ import { Position } from "../util";
2
3
  import type { LinterContextProps } from "../types";
3
- type SortableLayoutKind = "horizontal" | "vertical";
4
+ export declare enum Layout {
5
+ HORIZONTAL = "horizontal",
6
+ VERTICAL = "vertical"
7
+ }
8
+ declare enum ItemState {
9
+ STATIC = "static",
10
+ DRAGGING = "dragging",
11
+ ANIMATING = "animating",
12
+ DISABLED = "disabled"
13
+ }
4
14
  export type SortableOption = string;
5
15
  type SortableProps = {
6
16
  constraints: {
@@ -8,7 +18,7 @@ type SortableProps = {
8
18
  height: number;
9
19
  } | Record<any, any>;
10
20
  disabled: boolean;
11
- layout: SortableLayoutKind;
21
+ layout: Layout;
12
22
  margin: number;
13
23
  onChange: (arg1: any) => void;
14
24
  onMeasure: (arg1: {
@@ -17,8 +27,8 @@ type SortableProps = {
17
27
  }) => void;
18
28
  padding: boolean;
19
29
  linterContext: LinterContextProps;
20
- waitForKatexLoad: boolean;
21
30
  options: ReadonlyArray<SortableOption>;
31
+ waitForTexRendererToLoad: boolean;
22
32
  };
23
33
  type DefaultProps = {
24
34
  constraints: SortableProps["constraints"];
@@ -29,27 +39,25 @@ type DefaultProps = {
29
39
  onMeasure: SortableProps["onMeasure"];
30
40
  padding: SortableProps["padding"];
31
41
  linterContext: SortableProps["linterContext"];
32
- waitForKatexLoad: SortableProps["waitForKatexLoad"];
42
+ waitForTexRendererToLoad: SortableProps["waitForTexRendererToLoad"];
33
43
  };
34
- type ItemState = "disabled" | "static" | "dragging" | "animating";
35
44
  type SortableItem = {
36
45
  option: SortableOption;
37
46
  key: number;
38
- type: ItemState;
39
- endPosition: any;
47
+ state: ItemState;
48
+ endPosition: Position | Record<string, never>;
40
49
  width: number;
41
50
  height: number;
42
51
  };
43
52
  type SortableState = {
44
53
  items: ReadonlyArray<SortableItem>;
45
- katex: null | any;
54
+ texRendererLoaded: boolean;
46
55
  };
47
56
  declare class Sortable extends React.Component<SortableProps, SortableState> {
48
57
  static defaultProps: DefaultProps;
49
58
  constructor(props: SortableProps);
50
59
  UNSAFE_componentWillReceiveProps(nextProps: SortableProps): void;
51
60
  componentDidUpdate(): void;
52
- componentDidMount(): void;
53
61
  static itemsFromProps(props: {
54
62
  disabled: boolean;
55
63
  options: ReadonlyArray<SortableOption>;
@@ -5,8 +5,20 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
+ import { Position } from "../util";
8
9
  import type { LinterContextProps } from "../types";
9
- declare type SortableLayoutKind = "horizontal" | "vertical";
10
+
11
+ declare export var Layout: {|
12
+ +HORIZONTAL: "horizontal", // "horizontal"
13
+ +VERTICAL: "vertical", // "vertical"
14
+ |};
15
+
16
+ declare var ItemState: {|
17
+ +STATIC: "static", // "static"
18
+ +DRAGGING: "dragging", // "dragging"
19
+ +ANIMATING: "animating", // "animating"
20
+ +DISABLED: "disabled", // "disabled"
21
+ |};
10
22
  export type SortableOption = string;
11
23
  declare type SortableProps = {|
12
24
  constraints:
@@ -16,7 +28,7 @@ declare type SortableProps = {|
16
28
  |}
17
29
  | { [key: any]: any },
18
30
  disabled: boolean,
19
- layout: SortableLayoutKind,
31
+ layout: $Values<typeof Layout>,
20
32
  margin: number,
21
33
  onChange: (arg1: any) => void,
22
34
  onMeasure: (arg1: {|
@@ -25,8 +37,8 @@ declare type SortableProps = {|
25
37
  |}) => void,
26
38
  padding: boolean,
27
39
  linterContext: LinterContextProps,
28
- waitForKatexLoad: boolean,
29
40
  options: $ReadOnlyArray<SortableOption>,
41
+ waitForTexRendererToLoad: boolean,
30
42
  |};
31
43
  declare type DefaultProps = {|
32
44
  constraints: $PropertyType<SortableProps, "constraints">,
@@ -37,27 +49,28 @@ declare type DefaultProps = {|
37
49
  onMeasure: $PropertyType<SortableProps, "onMeasure">,
38
50
  padding: $PropertyType<SortableProps, "padding">,
39
51
  linterContext: $PropertyType<SortableProps, "linterContext">,
40
- waitForKatexLoad: $PropertyType<SortableProps, "waitForKatexLoad">,
52
+ waitForTexRendererToLoad: $PropertyType<
53
+ SortableProps,
54
+ "waitForTexRendererToLoad"
55
+ >,
41
56
  |};
42
- declare type ItemState = "disabled" | "static" | "dragging" | "animating";
43
57
  declare type SortableItem = {|
44
58
  option: SortableOption,
45
59
  key: number,
46
- type: ItemState,
47
- endPosition: any,
60
+ state: $Values<typeof ItemState>,
61
+ endPosition: Position | { [key: string]: empty },
48
62
  width: number,
49
63
  height: number,
50
64
  |};
51
65
  declare type SortableState = {|
52
66
  items: $ReadOnlyArray<SortableItem>,
53
- katex: null | any,
67
+ texRendererLoaded: boolean,
54
68
  |};
55
69
  declare class Sortable extends React.Component<SortableProps, SortableState> {
56
70
  static defaultProps: DefaultProps;
57
71
  constructor(props: SortableProps): this;
58
72
  UNSAFE_componentWillReceiveProps(nextProps: SortableProps): void;
59
73
  componentDidUpdate(): void;
60
- componentDidMount(): void;
61
74
  static itemsFromProps(props: {|
62
75
  disabled: boolean,
63
76
  options: $ReadOnlyArray<SortableOption>,
@@ -1,12 +1,14 @@
1
1
  import * as React from "react";
2
+ import { Coord } from "../interactive2/types";
3
+ import type { Size } from "../perseus-types";
2
4
  import type { Alignment, Dimensions } from "../types";
3
5
  type Props = {
4
6
  allowFullBleed?: boolean;
5
7
  alt: string;
6
8
  constrainHeight?: boolean;
7
9
  extraGraphie?: {
8
- box: ReadonlyArray<any>;
9
- range: ReadonlyArray<any>;
10
+ box: Size;
11
+ range: [Coord, Coord];
10
12
  labels: ReadonlyArray<any>;
11
13
  };
12
14
  height?: number;
@@ -38,7 +40,7 @@ type State = {
38
40
  labelsRendered: LabelsRenderedMap;
39
41
  labelDataIsLocalized: boolean;
40
42
  labels: ReadonlyArray<Label>;
41
- range: ReadonlyArray<any>;
43
+ range: [Coord, Coord];
42
44
  };
43
45
  declare class SvgImage extends React.Component<Props, State> {
44
46
  _isMounted: boolean;