@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # @khanacademy/perseus
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 4a368030: Remove getKaTeX from the PerseusDependencies type
8
+
9
+ perseus-editor now detects KaTeX rendering errors by calling KaTeX directly,
10
+ rather than using getKaTeX from PerseusDependencies.
11
+
12
+ The logKaTeXError method, which was unused by Perseus, has been removed from
13
+ the PerseusDependencies type as well.
14
+
15
+ Clients should update their code by removing the getKaTeX and logKaTeXError
16
+ properties from their PerseusDependencies object. If they want to log an error
17
+ when TeX fails to render, they should do so in their TeX component.
18
+
19
+ - 9c4a6c96: Remove obsolete properties from the PerseusDependencies type
20
+
21
+ We are in the process of migrating the webapp and mobile repos to use
22
+ MathJax 3 as their math renderer instead of KaTeX. This change removes some of
23
+ Perseus's dependencies on KaTeX.
24
+
25
+ Clients should update their code by removing the `getRenderA11yString`,
26
+ `loadMathjax`, `KatexProvider`, and `shouldUseFutureKaTeX` properties from
27
+ their PerseusDependencies object.
28
+
29
+ ### Patch Changes
30
+
31
+ - 5cc23179: Upgraded <Lint> component to use TypeScript types for props
32
+ - e0a087d0: Upgraded <InlineIcon> component to use TypeScript types for props
33
+ - b062ad47: Upgraded <MathOutput> component to use TypeScript types for props
34
+ - 8a47076d: Upgraded <Tooltip> component to use TypeScript types for props
35
+ - 09ab3260: Upgraded HUD component to use TypeScript types for props
36
+ - 5432857d: Upgraded <Sortable> component (not widget) to use TypeScript types for props
37
+ - 40c2736d: Upgraded Graphie component to use TypeScript types for props
38
+ - b585fe29: Switch most @khanacademy/math-input psuedo-enums to enums
39
+ - 91617cfa: Upgraded FixedToResponsive component to use TypeScript types for props
40
+ - e284e7c1: Upgraded Graph component to use TypeScript types for props
41
+ - Updated dependencies [b585fe29]
42
+ - Updated dependencies [0c1cf562]
43
+ - @khanacademy/math-input@2.0.0
44
+
45
+ ## 5.0.0
46
+
47
+ ### Major Changes
48
+
49
+ - 472e20e1: Remove all references to multipleNumberInput (ie. Ask for (one|all) correct solution)
50
+
51
+ ### Patch Changes
52
+
53
+ - 22c5d564: Remove the use of React.FC<> and use types named Props/State in more components
54
+ - Updated dependencies [4c03a43d]
55
+ - Updated dependencies [22c5d564]
56
+ - @khanacademy/math-input@1.0.0
57
+ - @khanacademy/simple-markdown@0.9.3
58
+ - @khanacademy/pure-markdown@0.2.3
59
+
3
60
  ## 4.0.2
4
61
 
5
62
  ### Patch Changes
@@ -1,2 +1,28 @@
1
- declare const FixedToResponsive: any;
1
+ import * as React from "react";
2
+ type Props = {
3
+ width: number;
4
+ height: number;
5
+ children: React.ReactNode;
6
+ className?: string;
7
+ constrainHeight?: boolean;
8
+ allowFullBleed?: boolean;
9
+ };
10
+ type DefaultProps = {
11
+ className: Props["className"];
12
+ constrainHeight: Props["constrainHeight"];
13
+ allowFullBleed: Props["allowFullBleed"];
14
+ };
15
+ type State = {
16
+ viewportHeight: number | null;
17
+ viewportWidth: number | null;
18
+ };
19
+ declare class FixedToResponsive extends React.Component<Props, State> {
20
+ _isMounted: boolean;
21
+ static defaultProps: DefaultProps;
22
+ state: State;
23
+ componentDidMount(): void;
24
+ componentWillUnmount(): void;
25
+ _cacheViewportSize: () => void;
26
+ render(): JSX.Element;
27
+ }
2
28
  export default FixedToResponsive;
@@ -4,5 +4,31 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- declare var FixedToResponsive: any;
7
+ import * as React from "react";
8
+ declare type Props = {|
9
+ width: number,
10
+ height: number,
11
+ children: React.Node,
12
+ className?: string,
13
+ constrainHeight?: boolean,
14
+ allowFullBleed?: boolean,
15
+ |};
16
+ declare type DefaultProps = {|
17
+ className: $PropertyType<Props, "className">,
18
+ constrainHeight: $PropertyType<Props, "constrainHeight">,
19
+ allowFullBleed: $PropertyType<Props, "allowFullBleed">,
20
+ |};
21
+ declare type State = {|
22
+ viewportHeight: number | null,
23
+ viewportWidth: number | null,
24
+ |};
25
+ declare class FixedToResponsive extends React.Component<Props, State> {
26
+ _isMounted: boolean;
27
+ static defaultProps: DefaultProps;
28
+ state: State;
29
+ componentDidMount(): void;
30
+ componentWillUnmount(): void;
31
+ _cacheViewportSize: () => void;
32
+ render(): React$Node;
33
+ }
8
34
  declare export default typeof FixedToResponsive;
@@ -1,37 +1,52 @@
1
- import PropTypes from "prop-types";
2
1
  import * as React from "react";
3
- declare class Graph extends React.Component<any> {
2
+ import { Coord } from "../interactive2/types";
3
+ import { PerseusImageBackground } from "../perseus-types";
4
+ type Props = {
5
+ box: Readonly<[number, number]>;
6
+ labels: ReadonlyArray<string>;
7
+ range: Readonly<[Coord, Coord]>;
8
+ step: Readonly<[number, number]>;
9
+ gridStep: Readonly<[number, number]>;
10
+ snapStep: Readonly<[number, number]>;
11
+ markings: string;
12
+ backgroundImage: PerseusImageBackground;
13
+ showProtractor: boolean;
14
+ showRuler: boolean;
15
+ rulerLabel: string;
16
+ rulerTicks: number;
17
+ instructions?: string;
18
+ isMobile: boolean;
19
+ onGraphieUpdated?: (graphie: any) => void;
20
+ onClick?: (Coord: any) => void;
21
+ onMouseDown?: (Coord: any) => void;
22
+ onMouseUp?: (Coord: any) => void;
23
+ onMouseMove?: (Coord: any) => void;
24
+ setDrawingAreaAvailable?: (boolean: any) => void;
25
+ };
26
+ type DefaultProps = {
27
+ labels: Props["labels"];
28
+ range: Props["range"];
29
+ step: Props["step"];
30
+ gridStep: Props["gridStep"];
31
+ snapStep: Props["snapStep"];
32
+ markings: Props["markings"];
33
+ backgroundImage: Props["backgroundImage"];
34
+ showProtractor: Props["showProtractor"];
35
+ showRuler: Props["showRuler"];
36
+ rulerLabel: Props["rulerLabel"];
37
+ rulerTicks: Props["rulerTicks"];
38
+ isMobile: Props["isMobile"];
39
+ };
40
+ declare class Graph extends React.Component<Props> {
4
41
  protractor: any;
5
42
  ruler: any;
6
43
  _graphie: any;
7
44
  _hasSetupGraphieThisUpdate: boolean;
8
45
  _shouldSetupGraphie: boolean;
9
- static propTypes: {
10
- box: PropTypes.Validator<any[]>;
11
- labels: PropTypes.Requireable<(string | null | undefined)[]>;
12
- range: PropTypes.Requireable<((number | null | undefined)[] | null | undefined)[]>;
13
- step: PropTypes.Requireable<(number | null | undefined)[]>;
14
- gridStep: PropTypes.Requireable<(number | null | undefined)[]>;
15
- snapStep: PropTypes.Requireable<(number | null | undefined)[]>;
16
- markings: PropTypes.Requireable<string>;
17
- backgroundImage: PropTypes.Requireable<PropTypes.InferProps<{
18
- url: PropTypes.Requireable<string>;
19
- }>>;
20
- showProtractor: PropTypes.Requireable<boolean>;
21
- showRuler: PropTypes.Requireable<boolean>;
22
- rulerLabel: PropTypes.Requireable<string>;
23
- rulerTicks: PropTypes.Requireable<number>;
24
- onGraphieUpdated: PropTypes.Requireable<(...args: any[]) => any>;
25
- instructions: PropTypes.Requireable<string>;
26
- onClick: PropTypes.Requireable<(...args: any[]) => any>;
27
- setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
28
- isMobile: PropTypes.Requireable<boolean>;
29
- };
30
- static defaultProps: any;
31
- render(): React.ReactNode;
46
+ static defaultProps: DefaultProps;
32
47
  componentDidMount(): void;
33
- componentDidUpdate(): void;
34
48
  UNSAFE_componentWillReceiveProps(nextProps: any): void;
49
+ componentDidUpdate(): void;
35
50
  reset: () => void;
36
51
  graphie: () => any;
37
52
  pointsFromNormalized: (arg1: any, arg2: any) => any;
@@ -40,5 +55,6 @@ declare class Graph extends React.Component<any> {
40
55
  _updateProtractor: () => void;
41
56
  _updateRuler: () => void;
42
57
  toJSON: () => any;
58
+ render(): React.ReactNode;
43
59
  }
44
60
  export default Graph;
@@ -4,42 +4,55 @@
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 Graph extends React.Component<any> {
8
+ import { Coord } from "../interactive2/types";
9
+ import { PerseusImageBackground } from "../perseus-types";
10
+ declare type Props = {|
11
+ box: $ReadOnly<[number, number]>,
12
+ labels: $ReadOnlyArray<string>,
13
+ range: $ReadOnly<[Coord, Coord]>,
14
+ step: $ReadOnly<[number, number]>,
15
+ gridStep: $ReadOnly<[number, number]>,
16
+ snapStep: $ReadOnly<[number, number]>,
17
+ markings: string,
18
+ backgroundImage: PerseusImageBackground,
19
+ showProtractor: boolean,
20
+ showRuler: boolean,
21
+ rulerLabel: string,
22
+ rulerTicks: number,
23
+ instructions?: string,
24
+ isMobile: boolean,
25
+ onGraphieUpdated?: (graphie: any) => void,
26
+ onClick?: (Coord: any) => void,
27
+ onMouseDown?: (Coord: any) => void,
28
+ onMouseUp?: (Coord: any) => void,
29
+ onMouseMove?: (Coord: any) => void,
30
+ setDrawingAreaAvailable?: (boolean: any) => void,
31
+ |};
32
+ declare type DefaultProps = {|
33
+ labels: $PropertyType<Props, "labels">,
34
+ range: $PropertyType<Props, "range">,
35
+ step: $PropertyType<Props, "step">,
36
+ gridStep: $PropertyType<Props, "gridStep">,
37
+ snapStep: $PropertyType<Props, "snapStep">,
38
+ markings: $PropertyType<Props, "markings">,
39
+ backgroundImage: $PropertyType<Props, "backgroundImage">,
40
+ showProtractor: $PropertyType<Props, "showProtractor">,
41
+ showRuler: $PropertyType<Props, "showRuler">,
42
+ rulerLabel: $PropertyType<Props, "rulerLabel">,
43
+ rulerTicks: $PropertyType<Props, "rulerTicks">,
44
+ isMobile: $PropertyType<Props, "isMobile">,
45
+ |};
46
+ declare class Graph extends React.Component<Props> {
10
47
  protractor: any;
11
48
  ruler: any;
12
49
  _graphie: any;
13
50
  _hasSetupGraphieThisUpdate: boolean;
14
51
  _shouldSetupGraphie: boolean;
15
- static propTypes: {|
16
- box: PropTypes.Validator<any[]>,
17
- labels: PropTypes.Requireable<(string | null | void)[]>,
18
- range: PropTypes.Requireable<((number | null | void)[] | null | void)[]>,
19
- step: PropTypes.Requireable<(number | null | void)[]>,
20
- gridStep: PropTypes.Requireable<(number | null | void)[]>,
21
- snapStep: PropTypes.Requireable<(number | null | void)[]>,
22
- markings: PropTypes.Requireable<string>,
23
- backgroundImage: PropTypes.Requireable<
24
- PropTypes.InferProps<{|
25
- url: PropTypes.Requireable<string>,
26
- |}>
27
- >,
28
- showProtractor: PropTypes.Requireable<boolean>,
29
- showRuler: PropTypes.Requireable<boolean>,
30
- rulerLabel: PropTypes.Requireable<string>,
31
- rulerTicks: PropTypes.Requireable<number>,
32
- onGraphieUpdated: PropTypes.Requireable<(...args: any[]) => any>,
33
- instructions: PropTypes.Requireable<string>,
34
- onClick: PropTypes.Requireable<(...args: any[]) => any>,
35
- setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>,
36
- isMobile: PropTypes.Requireable<boolean>,
37
- |};
38
- static defaultProps: any;
39
- render(): React.Node;
52
+ static defaultProps: DefaultProps;
40
53
  componentDidMount(): void;
41
- componentDidUpdate(): void;
42
54
  UNSAFE_componentWillReceiveProps(nextProps: any): void;
55
+ componentDidUpdate(): void;
43
56
  reset: () => void;
44
57
  graphie: () => any;
45
58
  pointsFromNormalized: (arg1: any, arg2: any) => any;
@@ -48,5 +61,6 @@ declare class Graph extends React.Component<any> {
48
61
  _updateProtractor: () => void;
49
62
  _updateRuler: () => void;
50
63
  toJSON: () => any;
64
+ render(): React.Node;
51
65
  }
52
66
  declare export default typeof Graph;
@@ -1,25 +1,37 @@
1
- import PropTypes from "prop-types";
2
1
  import * as React from "react";
3
- type Props = any;
2
+ import type { Coord } from "../interactive2/types";
3
+ import type { Range, Size } from "../perseus-types";
4
+ type Props = {
5
+ addMouseLayer?: boolean;
6
+ box: Size;
7
+ range: [Coord, Coord];
8
+ ranges?: [Range, Range];
9
+ gridStep?: [number, number];
10
+ step?: [number, number];
11
+ scale?: [number, number];
12
+ isMobile?: boolean;
13
+ responsive?: boolean;
14
+ children?: React.ReactNode;
15
+ options: any;
16
+ setDrawingAreaAvailable?: (boolean: any) => void;
17
+ setup: (graphie: any, options: {
18
+ range: [Coord, Coord];
19
+ scale: [number, number];
20
+ }) => void;
21
+ onClick?: (at: Coord) => void;
22
+ onMouseDown?: (at: Coord) => void;
23
+ onMouseMove?: (at: Coord) => void;
24
+ onMouseUp?: (at: Coord) => void;
25
+ };
26
+ type DefaultProps = {
27
+ range: Props["range"];
28
+ options: Props["options"];
29
+ responsive: Props["responsive"];
30
+ addMouseLayer: Props["addMouseLayer"];
31
+ };
4
32
  declare class Graphie extends React.Component<Props> {
5
- static propTypes: {
6
- addMouseLayer: PropTypes.Requireable<boolean>;
7
- box: PropTypes.Validator<(number | null | undefined)[]>;
8
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
9
- isMobile: PropTypes.Requireable<boolean>;
10
- onClick: PropTypes.Requireable<(...args: any[]) => any>;
11
- onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
12
- onMouseMove: PropTypes.Requireable<(...args: any[]) => any>;
13
- onMouseUp: PropTypes.Requireable<(...args: any[]) => any>;
14
- options: PropTypes.Requireable<PropTypes.InferProps<{
15
- snapStep: PropTypes.Requireable<(number | null | undefined)[]>;
16
- }>>;
17
- range: PropTypes.Requireable<((number | null | undefined)[] | null | undefined)[]>;
18
- responsive: PropTypes.Requireable<boolean>;
19
- setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>;
20
- setup: PropTypes.Validator<(...args: any[]) => any>;
21
- };
22
- static defaultProps: any;
33
+ graphieDivRef: React.RefObject<HTMLDivElement>;
34
+ static defaultProps: DefaultProps;
23
35
  componentDidMount(): void;
24
36
  shouldComponentUpdate(nextProps: Props): boolean;
25
37
  componentDidUpdate(prevProps: Props): void;
@@ -32,8 +44,8 @@ declare class Graphie extends React.Component<Props> {
32
44
  * Use it for good and not evil.
33
45
  */
34
46
  getGraphie: () => any;
35
- _range: () => ReadonlyArray<[number, number]>;
36
- _box: () => ReadonlyArray<number>;
47
+ _range: () => [Coord, Coord];
48
+ _box: () => Size;
37
49
  _scale: () => ReadonlyArray<number>;
38
50
  _setupGraphie: () => void;
39
51
  _removeMovables: () => void;
@@ -4,30 +4,43 @@
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;
8
+ import type { Coord } from "../interactive2/types";
9
+ import type { Range, Size } from "../perseus-types";
10
+ declare type Props = {|
11
+ addMouseLayer?: boolean,
12
+ box: Size,
13
+ range: [Coord, Coord],
14
+ ranges?: [Range, Range],
15
+ gridStep?: [number, number],
16
+ step?: [number, number],
17
+ scale?: [number, number],
18
+ isMobile?: boolean,
19
+ responsive?: boolean,
20
+ children?: React.Node,
21
+ options: any,
22
+ setDrawingAreaAvailable?: (boolean: any) => void,
23
+ setup: (
24
+ graphie: any,
25
+ options: {|
26
+ range: [Coord, Coord],
27
+ scale: [number, number],
28
+ |}
29
+ ) => void,
30
+ onClick?: (at: Coord) => void,
31
+ onMouseDown?: (at: Coord) => void,
32
+ onMouseMove?: (at: Coord) => void,
33
+ onMouseUp?: (at: Coord) => void,
34
+ |};
35
+ declare type DefaultProps = {|
36
+ range: $PropertyType<Props, "range">,
37
+ options: $PropertyType<Props, "options">,
38
+ responsive: $PropertyType<Props, "responsive">,
39
+ addMouseLayer: $PropertyType<Props, "addMouseLayer">,
40
+ |};
10
41
  declare class Graphie extends React.Component<Props> {
11
- static propTypes: {|
12
- addMouseLayer: PropTypes.Requireable<boolean>,
13
- box: PropTypes.Validator<(number | null | void)[]>,
14
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>,
15
- isMobile: PropTypes.Requireable<boolean>,
16
- onClick: PropTypes.Requireable<(...args: any[]) => any>,
17
- onMouseDown: PropTypes.Requireable<(...args: any[]) => any>,
18
- onMouseMove: PropTypes.Requireable<(...args: any[]) => any>,
19
- onMouseUp: PropTypes.Requireable<(...args: any[]) => any>,
20
- options: PropTypes.Requireable<
21
- PropTypes.InferProps<{|
22
- snapStep: PropTypes.Requireable<(number | null | void)[]>,
23
- |}>
24
- >,
25
- range: PropTypes.Requireable<((number | null | void)[] | null | void)[]>,
26
- responsive: PropTypes.Requireable<boolean>,
27
- setDrawingAreaAvailable: PropTypes.Requireable<(...args: any[]) => any>,
28
- setup: PropTypes.Validator<(...args: any[]) => any>,
29
- |};
30
- static defaultProps: any;
42
+ graphieDivRef: React.RefObject<HTMLDivElement>;
43
+ static defaultProps: DefaultProps;
31
44
  componentDidMount(): void;
32
45
  shouldComponentUpdate(nextProps: Props): boolean;
33
46
  componentDidUpdate(prevProps: Props): void;
@@ -41,8 +54,8 @@ declare class Graphie extends React.Component<Props> {
41
54
  * Use it for good and not evil.
42
55
  */
43
56
  getGraphie: () => any;
44
- _range: () => $ReadOnlyArray<[number, number]>;
45
- _box: () => $ReadOnlyArray<number>;
57
+ _range: () => [Coord, Coord];
58
+ _box: () => Size;
46
59
  _scale: () => $ReadOnlyArray<number>;
47
60
  _setupGraphie: () => void;
48
61
  _removeMovables: () => void;
@@ -1,19 +1,19 @@
1
1
  import * as React from "react";
2
2
  import type { DOMHighlight, DOMHighlightSet, SerializedHighlightSet, DOMRange } from "./types";
3
- type HighlightableContentProps = {
3
+ type Props = {
4
4
  children?: React.ReactElement<any>;
5
5
  editable: boolean;
6
6
  enabled: boolean;
7
7
  onSerializedHighlightsUpdate: (serializedHighlights: SerializedHighlightSet) => unknown;
8
8
  serializedHighlights: SerializedHighlightSet;
9
9
  };
10
- type HighlightableContentState = {
10
+ type State = {
11
11
  wordRanges: ReadonlyArray<DOMRange>;
12
12
  };
13
- declare class HighlightableContent extends React.PureComponent<HighlightableContentProps, HighlightableContentState> {
13
+ declare class HighlightableContent extends React.PureComponent<Props, State> {
14
14
  _container: HTMLElement | null | undefined;
15
15
  _content: HTMLElement | null | undefined;
16
- state: HighlightableContentState;
16
+ state: State;
17
17
  _buildHighlight(highlightRange: DOMRange): DOMHighlight | null | undefined;
18
18
  /**
19
19
  * Take the highlights from props, and deserialize them into DOMHighlights,
@@ -11,7 +11,7 @@ import type {
11
11
  SerializedHighlightSet,
12
12
  DOMRange,
13
13
  } from "./types";
14
- declare type HighlightableContentProps = {|
14
+ declare type Props = {|
15
15
  children?: React.Element<any>,
16
16
  editable: boolean,
17
17
  enabled: boolean,
@@ -20,16 +20,13 @@ declare type HighlightableContentProps = {|
20
20
  ) => mixed,
21
21
  serializedHighlights: SerializedHighlightSet,
22
22
  |};
23
- declare type HighlightableContentState = {|
23
+ declare type State = {|
24
24
  wordRanges: $ReadOnlyArray<DOMRange>,
25
25
  |};
26
- declare class HighlightableContent
27
- extends
28
- React.PureComponent<HighlightableContentProps, HighlightableContentState>
29
- {
26
+ declare class HighlightableContent extends React.PureComponent<Props, State> {
30
27
  _container: HTMLElement | null | void;
31
28
  _content: HTMLElement | null | void;
32
- state: HighlightableContentState;
29
+ state: State;
33
30
  _buildHighlight(highlightRange: DOMRange): DOMHighlight | null | void;
34
31
 
35
32
  /**
@@ -1,23 +1,23 @@
1
1
  import * as React from "react";
2
2
  import type { DOMHighlight, Position, Rect, ZIndexes } from "./types";
3
- type HighlightRendererProps = {
3
+ type Props = {
4
4
  highlight: DOMHighlight;
5
5
  highlightKey: string;
6
6
  offsetParent: Element;
7
7
  zIndexes: ZIndexes;
8
8
  };
9
- type HighlightRendererState = {
9
+ type State = {
10
10
  cachedHighlightRects: ReadonlyArray<Rect>;
11
11
  };
12
- declare class HighlightRenderer extends React.PureComponent<HighlightRendererProps, HighlightRendererState> {
13
- state: HighlightRendererState;
14
- UNSAFE_componentWillReceiveProps(nextProps: HighlightRendererProps): void;
12
+ declare class HighlightRenderer extends React.PureComponent<Props, State> {
13
+ state: State;
14
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
15
15
  /**
16
16
  * Compute the set of rectangles that cover the highlighted content, with
17
17
  * coordinates relative to the offset parent. That way, we can use them
18
18
  * for CSS positioning.
19
19
  */
20
- _computeRects(props: HighlightRendererProps): ReadonlyArray<Rect>;
20
+ _computeRects(props: Props): ReadonlyArray<Rect>;
21
21
  /**
22
22
  * Return whether the given mouse position (coordinates relative to this
23
23
  * component's offset parent) is hovering over the given rectangle
@@ -6,27 +6,25 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  import type { DOMHighlight, Position, Rect, ZIndexes } from "./types";
9
- declare type HighlightRendererProps = {|
9
+ declare type Props = {|
10
10
  highlight: DOMHighlight,
11
11
  highlightKey: string,
12
12
  offsetParent: Element,
13
13
  zIndexes: ZIndexes,
14
14
  |};
15
- declare type HighlightRendererState = {|
15
+ declare type State = {|
16
16
  cachedHighlightRects: $ReadOnlyArray<Rect>,
17
17
  |};
18
- declare class HighlightRenderer
19
- extends React.PureComponent<HighlightRendererProps, HighlightRendererState>
20
- {
21
- state: HighlightRendererState;
22
- UNSAFE_componentWillReceiveProps(nextProps: HighlightRendererProps): void;
18
+ declare class HighlightRenderer extends React.PureComponent<Props, State> {
19
+ state: State;
20
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
23
21
 
24
22
  /**
25
23
  * Compute the set of rectangles that cover the highlighted content, with
26
24
  * coordinates relative to the offset parent. That way, we can use them
27
25
  * for CSS positioning.
28
26
  */
29
- _computeRects(props: HighlightRendererProps): $ReadOnlyArray<Rect>;
27
+ _computeRects(props: Props): $ReadOnlyArray<Rect>;
30
28
 
31
29
  /**
32
30
  * Return whether the given mouse position (coordinates relative to this
@@ -1,24 +1,24 @@
1
1
  import * as React from "react";
2
2
  import HighlightRenderer from "./highlight-renderer";
3
3
  import type { DOMHighlightSet, Position, ZIndexes } from "./types";
4
- type HighlightSetRendererProps = {
4
+ type Props = {
5
5
  editable: boolean;
6
6
  highlights: DOMHighlightSet;
7
7
  offsetParent: Element;
8
8
  onRemoveHighlight: (highlightKey: string) => unknown;
9
9
  zIndexes: ZIndexes;
10
10
  };
11
- type HighlightSetRendererState = {
11
+ type State = {
12
12
  hoveredHighlightKey: string | null | undefined;
13
13
  hoveringTooltipFor: string | null | undefined;
14
14
  };
15
- declare class HighlightSetRenderer extends React.PureComponent<HighlightSetRendererProps, HighlightSetRendererState> {
16
- state: HighlightSetRendererState;
15
+ declare class HighlightSetRenderer extends React.PureComponent<Props, State> {
16
+ state: State;
17
17
  _highlightRenderers: {
18
18
  [highlightKey: string]: HighlightRenderer;
19
19
  };
20
20
  componentDidMount(): void;
21
- UNSAFE_componentWillReceiveProps(nextProps: HighlightSetRendererProps): void;
21
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
22
22
  componentWillUnmount(): void;
23
23
  /**
24
24
  * Given whether we were previously listening to mousemove events, and
@@ -7,27 +7,24 @@
7
7
  import * as React from "react";
8
8
  import HighlightRenderer from "./highlight-renderer";
9
9
  import type { DOMHighlightSet, Position, ZIndexes } from "./types";
10
- declare type HighlightSetRendererProps = {|
10
+ declare type Props = {|
11
11
  editable: boolean,
12
12
  highlights: DOMHighlightSet,
13
13
  offsetParent: Element,
14
14
  onRemoveHighlight: (highlightKey: string) => mixed,
15
15
  zIndexes: ZIndexes,
16
16
  |};
17
- declare type HighlightSetRendererState = {|
17
+ declare type State = {|
18
18
  hoveredHighlightKey: string | null | void,
19
19
  hoveringTooltipFor: string | null | void,
20
20
  |};
21
- declare class HighlightSetRenderer
22
- extends
23
- React.PureComponent<HighlightSetRendererProps, HighlightSetRendererState>
24
- {
25
- state: HighlightSetRendererState;
21
+ declare class HighlightSetRenderer extends React.PureComponent<Props, State> {
22
+ state: State;
26
23
  _highlightRenderers: {
27
24
  [highlightKey: string]: HighlightRenderer,
28
25
  };
29
26
  componentDidMount(): void;
30
- UNSAFE_componentWillReceiveProps(nextProps: HighlightSetRendererProps): void;
27
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
31
28
  componentWillUnmount(): void;
32
29
 
33
30
  /**
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import type { Rect } from "./types";
3
- type HighlightTooltipProps = {
3
+ type Props = {
4
4
  label: string;
5
5
  onClick: () => unknown;
6
6
  onMouseEnter?: () => unknown;
@@ -9,7 +9,7 @@ type HighlightTooltipProps = {
9
9
  focusOffset: number;
10
10
  offsetParent: Element;
11
11
  };
12
- declare class HighlightTooltip extends React.PureComponent<HighlightTooltipProps> {
12
+ declare class HighlightTooltip extends React.PureComponent<Props> {
13
13
  _getFocusRect(): Rect | null | undefined;
14
14
  render(): null | React.ReactNode;
15
15
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  import type { Rect } from "./types";
9
- declare type HighlightTooltipProps = {|
9
+ declare type Props = {|
10
10
  label: string,
11
11
  onClick: () => mixed,
12
12
  onMouseEnter?: () => mixed,
@@ -15,9 +15,7 @@ declare type HighlightTooltipProps = {|
15
15
  focusOffset: number,
16
16
  offsetParent: Element,
17
17
  |};
18
- declare class HighlightTooltip
19
- extends React.PureComponent<HighlightTooltipProps>
20
- {
18
+ declare class HighlightTooltip extends React.PureComponent<Props> {
21
19
  _getFocusRect(): Rect | null | void;
22
20
  render(): null | React.Node;
23
21
  }