@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,4 +1,6 @@
1
1
  import type { Coord } from "./interactive2/types";
2
+ export type Range = [number, number];
3
+ export type Size = [number, number];
2
4
  type Empty = Record<string, never>;
3
5
  export type PerseusItem = {
4
6
  question: PerseusRenderer;
@@ -87,8 +89,8 @@ export type VideoWidget = Widget<'video', PerseusVideoWidgetOptions>;
87
89
  export type PerseusWidget = CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ExampleGraphieWidget | ExampleWidget | ExplanationWidget | ExpressionWidget | GradedGroupSetWidget | GradedGroupWidget | GrapherWidget | GroupWidget | IFrameWidget | ImageWidget | InputNumberWidget | InteractionWidget | InteractiveGraphWidget | LabelImageWidget | LightsPuzzleWidget | MatcherWidget | MatrixWidget | MeasurerWidget | MoleculeRendererWidget | NumberLineWidget | NumericInputWidget | OrdererWidget | PassageRefWidget | PassageWidget | PlotterWidget | RadioWidget | ReactionDiagramWidget | RefTargetWidget | SequenceWidget | SimpleMarkdownTesterWidget | SimulatorWidget | SorterWidget | TableWidget | TransformerWidget | UnitInputWidget | VideoWidget;
88
90
  export type PerseusImageBackground = {
89
91
  url: string | null | undefined;
90
- width: number;
91
- height: number;
92
+ width?: number;
93
+ height?: number;
92
94
  top?: number;
93
95
  left?: number;
94
96
  scale?: number | string;
@@ -227,8 +229,8 @@ export type PerseusImageWidgetOptions = {
227
229
  backgroundImage: PerseusImageBackground;
228
230
  static?: boolean;
229
231
  labels?: ReadonlyArray<PerseusImageLabel>;
230
- range?: ReadonlyArray<ReadonlyArray<number>>;
231
- box?: ReadonlyArray<number>;
232
+ range?: [Range, Range];
233
+ box?: Size;
232
234
  };
233
235
  export type PerseusImageLabel = {
234
236
  content: string;
@@ -361,7 +363,6 @@ export type PerseusNumericInputWidgetOptions = {
361
363
  labelText: string;
362
364
  size: string;
363
365
  coefficient: boolean;
364
- multipleNumberInput?: boolean;
365
366
  rightAlign?: boolean;
366
367
  static: boolean;
367
368
  answerForms?: ReadonlyArray<PerseusNumericInputAnswerForm>;
@@ -607,19 +608,19 @@ export type PerseusInteractionWidgetOptions = {
607
608
  };
608
609
  export type PerseusInteractionGraph = {
609
610
  editableSettings?: ReadonlyArray<"canvas" | "graph">;
610
- box: ReadonlyArray<number>;
611
+ box: Size;
611
612
  labels: ReadonlyArray<string>;
612
- range: ReadonlyArray<ReadonlyArray<number>>;
613
- gridStep: ReadonlyArray<number>;
613
+ range: [Range, Range];
614
+ gridStep: Readonly<[number, number]>;
614
615
  markings: string;
615
- snapStep?: ReadonlyArray<number>;
616
+ snapStep?: Readonly<[number, number]>;
616
617
  valid?: boolean | string;
617
618
  backgroundImage?: PerseusImageBackground;
618
619
  showProtractor?: boolean;
619
620
  showRuler?: boolean;
620
621
  rulerLabel?: string;
621
622
  rulerTicks?: number;
622
- tickStep: ReadonlyArray<number>;
623
+ tickStep: Readonly<[number, number]>;
623
624
  };
624
625
  export type PerseusInteractionElement = {
625
626
  type: "function";
@@ -5,6 +5,8 @@
5
5
  * @flow
6
6
  */
7
7
  import type { Coord } from "./interactive2/types";
8
+ export type Range = [number, number];
9
+ export type Size = [number, number];
8
10
  declare type Empty = { [key: string]: empty };
9
11
  export type PerseusItem = {|
10
12
  question: PerseusRenderer,
@@ -205,8 +207,8 @@ export type PerseusWidget =
205
207
  | VideoWidget;
206
208
  export type PerseusImageBackground = {|
207
209
  url: string | null | void,
208
- width: number,
209
- height: number,
210
+ width?: number,
211
+ height?: number,
210
212
  top?: number,
211
213
  left?: number,
212
214
  scale?: number | string,
@@ -354,8 +356,8 @@ export type PerseusImageWidgetOptions = {|
354
356
  backgroundImage: PerseusImageBackground,
355
357
  static?: boolean,
356
358
  labels?: $ReadOnlyArray<PerseusImageLabel>,
357
- range?: $ReadOnlyArray<$ReadOnlyArray<number>>,
358
- box?: $ReadOnlyArray<number>,
359
+ range?: [Range, Range],
360
+ box?: Size,
359
361
  |};
360
362
  export type PerseusImageLabel = {|
361
363
  content: string,
@@ -532,7 +534,6 @@ export type PerseusNumericInputWidgetOptions = {|
532
534
  labelText: string,
533
535
  size: string,
534
536
  coefficient: boolean,
535
- multipleNumberInput?: boolean,
536
537
  rightAlign?: boolean,
537
538
  static: boolean,
538
539
  answerForms?: $ReadOnlyArray<PerseusNumericInputAnswerForm>,
@@ -810,19 +811,19 @@ export type PerseusInteractionWidgetOptions = {|
810
811
  |};
811
812
  export type PerseusInteractionGraph = {|
812
813
  editableSettings?: $ReadOnlyArray<"canvas" | "graph">,
813
- box: $ReadOnlyArray<number>,
814
+ box: Size,
814
815
  labels: $ReadOnlyArray<string>,
815
- range: $ReadOnlyArray<$ReadOnlyArray<number>>,
816
- gridStep: $ReadOnlyArray<number>,
816
+ range: [Range, Range],
817
+ gridStep: $ReadOnly<[number, number]>,
817
818
  markings: string,
818
- snapStep?: $ReadOnlyArray<number>,
819
+ snapStep?: $ReadOnly<[number, number]>,
819
820
  valid?: boolean | string,
820
821
  backgroundImage?: PerseusImageBackground,
821
822
  showProtractor?: boolean,
822
823
  showRuler?: boolean,
823
824
  rulerLabel?: string,
824
825
  rulerTicks?: number,
825
- tickStep: $ReadOnlyArray<number>,
826
+ tickStep: $ReadOnly<[number, number]>,
826
827
  |};
827
828
  export type PerseusInteractionElement =
828
829
  | {|
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import InteractionTracker from "./interaction-tracker";
3
3
  import TranslationLinter from "./translation-linter";
4
4
  import type { PerseusRenderer, PerseusWidgetOptions } from "./perseus-types";
5
- import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, LinterContextProps, PerseusDependencies, PerseusScore, WidgetInfo, WidgetProps } from "./types";
5
+ import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, LinterContextProps, PerseusScore, WidgetInfo, WidgetProps } from "./types";
6
6
  import "./styles/perseus-renderer.less";
7
7
  type WidgetState = {
8
8
  isMobile?: boolean;
@@ -98,7 +98,7 @@ declare class Renderer extends React.Component<Props, State> {
98
98
  _isMounted: boolean;
99
99
  _isTwoColumn: boolean;
100
100
  _translationLinter: TranslationLinter;
101
- lastRenderedMarkdown: React.ReactElement<React.ComponentProps<PerseusDependencies["KatexProvider"]>>;
101
+ lastRenderedMarkdown: React.ReactNode;
102
102
  reuseMarkdown: boolean;
103
103
  translationIndex: number;
104
104
  widgetIds: Array<string>;
@@ -14,7 +14,6 @@ import type {
14
14
  FilterCriterion,
15
15
  FocusPath,
16
16
  LinterContextProps,
17
- PerseusDependencies,
18
17
  PerseusScore,
19
18
  WidgetInfo,
20
19
  WidgetProps,
@@ -135,8 +134,7 @@ declare class Renderer extends React.Component<Props, State> {
135
134
  _isMounted: boolean;
136
135
  _isTwoColumn: boolean;
137
136
  _translationLinter: TranslationLinter;
138
- lastRenderedMarkdown: React.Element<$PropertyType<PerseusDependencies, "KatexProvider">
139
- >;
137
+ lastRenderedMarkdown: React.Node;
140
138
  reuseMarkdown: boolean;
141
139
  translationIndex: number;
142
140
  widgetIds: Array<string>;
@@ -1,3 +1,2 @@
1
- import type { StyleDeclaration } from "aphrodite";
2
1
  declare const _default: StyleDeclaration;
3
2
  export default _default;
@@ -4,6 +4,5 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import type { StyleDeclaration } from "aphrodite";
8
7
  declare var _default: StyleDeclaration;
9
8
  declare export default typeof _default;
package/dist/types.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import katex from "katex";
2
- import katexA11y from "katex/dist/contrib/render-a11y-string";
3
1
  import * as React from "react";
4
2
  import type { SerializedHighlightSet } from "./components/highlighting/types";
5
3
  import type { ILogger } from "./logging/log";
@@ -170,14 +168,6 @@ export type PerseusDependencies = {
170
168
  graphieMovablesJiptLabels: JiptLabelStore;
171
169
  svgImageJiptLabels: JiptLabelStore;
172
170
  rendererTranslationComponents: JiptTranslationComponents;
173
- getKaTeX: () => Promise<katex>;
174
- getRenderA11yString: () => Promise<katexA11y>;
175
- loadMathjax: () => Promise<unknown>;
176
- logKaTeXError: (expression: string, error: Error) => Promise<Response | null | undefined>;
177
- KatexProvider: React.ComponentType<{
178
- children: React.ReactNode;
179
- }>;
180
- shouldUseFutureKaTeX: (flag: boolean) => void;
181
171
  TeX: React.ComponentType<TeXProps>;
182
172
  staticUrl: StaticUrlFn;
183
173
  InitialRequestUrl: InitialRequestUrlInterface;
@@ -4,8 +4,6 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import katex from "katex";
8
- import katexA11y from "katex/dist/contrib/render-a11y-string";
9
7
  import * as React from "react";
10
8
  import type { SerializedHighlightSet } from "./components/highlighting/types";
11
9
  import type { ILogger } from "./logging/log";
@@ -200,17 +198,6 @@ export type PerseusDependencies = {|
200
198
  graphieMovablesJiptLabels: JiptLabelStore,
201
199
  svgImageJiptLabels: JiptLabelStore,
202
200
  rendererTranslationComponents: JiptTranslationComponents,
203
- getKaTeX: () => Promise<katex>,
204
- getRenderA11yString: () => Promise<katexA11y>,
205
- loadMathjax: () => Promise<mixed>,
206
- logKaTeXError: (
207
- expression: string,
208
- error: Error
209
- ) => Promise<Response | null | void>,
210
- KatexProvider: React.ComponentType<{|
211
- children: React.Node,
212
- |}>,
213
- shouldUseFutureKaTeX: (flag: boolean) => void,
214
201
  TeX: React.ComponentType<TeXProps>,
215
202
  staticUrl: StaticUrlFn,
216
203
  InitialRequestUrl: InitialRequestUrlInterface,
@@ -1,3 +1,2 @@
1
- import type { StyleDeclaration } from "aphrodite";
2
1
  declare const _default: StyleDeclaration;
3
2
  export default _default;
@@ -4,6 +4,5 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import type { StyleDeclaration } from "aphrodite";
8
7
  declare var _default: StyleDeclaration;
9
8
  declare export default typeof _default;
@@ -5,5 +5,7 @@
5
5
  * `Graphie` prototype for dealing with interactive graphie elements.
6
6
  */
7
7
  import "../jquery.mobile.vmouse";
8
+ import type { Coord } from "../interactive2/types";
9
+ export type MouseHandler = (position: Coord) => void;
8
10
  declare const InteractiveUtils: any;
9
11
  export default InteractiveUtils;
@@ -5,5 +5,7 @@
5
5
  * @flow
6
6
  */
7
7
  import "../jquery.mobile.vmouse";
8
+ import type { Coord } from "../interactive2/types";
9
+ export type MouseHandler = (position: Coord) => void;
8
10
  declare var InteractiveUtils: any;
9
11
  declare export default typeof InteractiveUtils;
package/dist/util.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Range } from "./perseus-types";
1
2
  import type { Widget, PerseusScore, KEScore } from "./types";
2
3
  type WordPosition = {
3
4
  start: number;
@@ -21,7 +22,7 @@ export type GridDimensions = {
21
22
  type QueryParams = {
22
23
  [param: string]: string;
23
24
  };
24
- type Position = {
25
+ export type Position = {
25
26
  top: number;
26
27
  left: number;
27
28
  };
@@ -107,13 +108,12 @@ declare function tickStepFromExtent(extent: Coordinates, dimensionConstraint: nu
107
108
  * tickStepFromNumTicks(50, 6) // returns 10
108
109
  */
109
110
  declare function tickStepFromNumTicks(span: number, numTicks: number): number;
110
- type Range = [number, number];
111
111
  /**
112
112
  * Constrain tick steps intended for desktop size graphs
113
113
  * to something more suitable for mobile size graphs.
114
114
  * Specifically, we aim for 10 or fewer ticks per graph axis.
115
115
  */
116
- declare function constrainedTickStepsFromTickSteps(tickSteps: Coordinates, ranges: [Range, Range]): Coordinates;
116
+ declare function constrainedTickStepsFromTickSteps(tickSteps: [number, number], ranges: [Range, Range]): Coordinates;
117
117
  /**
118
118
  * Approximate equality on numbers and primitives.
119
119
  */
package/dist/util.js.flow CHANGED
@@ -4,6 +4,7 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
+ import type { Range } from "./perseus-types";
7
8
  import type { Widget, PerseusScore, KEScore } from "./types";
8
9
  declare type WordPosition = {|
9
10
  start: number,
@@ -27,7 +28,7 @@ export type GridDimensions = {|
27
28
  declare type QueryParams = {
28
29
  [param: string]: string,
29
30
  };
30
- declare type Position = {|
31
+ export type Position = {|
31
32
  top: number,
32
33
  left: number,
33
34
  |};
@@ -155,14 +156,14 @@ declare function tickStepFromExtent(
155
156
  * tickStepFromNumTicks(50, 6) // returns 10
156
157
  */
157
158
  declare function tickStepFromNumTicks(span: number, numTicks: number): number;
158
- declare type Range = [number, number];
159
+
159
160
  /**
160
161
  * Constrain tick steps intended for desktop size graphs
161
162
  * to something more suitable for mobile size graphs.
162
163
  * Specifically, we aim for 10 or fewer ticks per graph axis.
163
164
  */
164
165
  declare function constrainedTickStepsFromTickSteps(
165
- tickSteps: Coordinates,
166
+ tickSteps: [number, number],
166
167
  ranges: [Range, Range]
167
168
  ): Coordinates;
168
169
 
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
- type TestKeypadContextWrapperProps = {
2
+ type Props = {
3
3
  children: React.ReactElement;
4
4
  };
5
- declare const TestKeypadContextWrapper: (props: TestKeypadContextWrapperProps) => React.ReactElement;
5
+ declare const TestKeypadContextWrapper: (props: Props) => React.ReactElement;
6
6
  export default TestKeypadContextWrapper;
@@ -5,10 +5,8 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- declare type TestKeypadContextWrapperProps = {|
8
+ declare type Props = {|
9
9
  children: React.Element<any>,
10
10
  |};
11
- declare var TestKeypadContextWrapper: (
12
- props: TestKeypadContextWrapperProps
13
- ) => React.Element<any>;
11
+ declare var TestKeypadContextWrapper: (props: Props) => React.Element<any>;
14
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
@@ -30,7 +30,7 @@ declare class Grapher extends React.Component<Props> {
30
30
  box: NonNullable<Props["graph"]["box"]>;
31
31
  gridStep: NonNullable<Props["graph"]["gridStep"]>;
32
32
  }): ReadonlyArray<GridDimensions>;
33
- _calculateMobileTickStep(gridStep: JSX.LibraryManagedAttributes<typeof Graphie, React.ComponentProps<typeof Graphie>>["gridStep"], step: JSX.LibraryManagedAttributes<typeof Graphie, React.ComponentProps<typeof Graphie>>["step"], ranges: JSX.LibraryManagedAttributes<typeof Graphie, React.ComponentProps<typeof Graphie>>["ranges"]): any;
33
+ _calculateMobileTickStep(gridStep: JSX.LibraryManagedAttributes<typeof Graphie, Required<React.ComponentProps<typeof Graphie>>>["gridStep"], step: JSX.LibraryManagedAttributes<typeof Graphie, Required<React.ComponentProps<typeof Graphie>>>["step"], ranges: JSX.LibraryManagedAttributes<typeof Graphie, Required<React.ComponentProps<typeof Graphie>>>["ranges"]): any;
34
34
  _setupGraphie: (arg1: any, arg2: any) => void;
35
35
  showHairlines: (arg1: Coord) => void;
36
36
  hideHairlines: () => void;
@@ -47,15 +47,24 @@ declare class Grapher extends React.Component<Props> {
47
47
  |}): $ReadOnlyArray<GridDimensions>;
48
48
  _calculateMobileTickStep(
49
49
  gridStep: $PropertyType<
50
- React.ElementConfig<typeof Graphie>,
50
+ JSX.LibraryManagedAttributes<
51
+ typeof Graphie,
52
+ Required<React.ElementProps<typeof Graphie>>
53
+ >,
51
54
  "gridStep"
52
55
  >,
53
56
  step: $PropertyType<
54
- React.ElementConfig<typeof Graphie>,
57
+ JSX.LibraryManagedAttributes<
58
+ typeof Graphie,
59
+ Required<React.ElementProps<typeof Graphie>>
60
+ >,
55
61
  "step"
56
62
  >,
57
63
  ranges: $PropertyType<
58
- React.ElementConfig<typeof Graphie>,
64
+ JSX.LibraryManagedAttributes<
65
+ typeof Graphie,
66
+ Required<React.ElementProps<typeof Graphie>>
67
+ >,
59
68
  "ranges"
60
69
  >
61
70
  ): any;
@@ -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">;
@@ -1,6 +1,11 @@
1
1
  import PropTypes from "prop-types";
2
2
  import * as React from "react";
3
3
  import type { SortableOption } from "../components/sortable";
4
+ type State = {
5
+ leftHeight: number;
6
+ rightHeight: number;
7
+ texRendererLoaded: boolean;
8
+ };
4
9
  declare class Matcher extends React.Component<any, any> {
5
10
  static propTypes: {
6
11
  apiOptions: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
@@ -48,9 +53,8 @@ declare class Matcher extends React.Component<any, any> {
48
53
  }>>;
49
54
  };
50
55
  static defaultProps: any;
51
- state: any;
52
- componentDidMount(): void;
53
- render(): React.ReactNode;
56
+ state: State;
57
+ render(): React.ReactElement;
54
58
  changeAndTrack: (arg1: any) => void;
55
59
  onMeasureLeft: (arg1: any) => void;
56
60
  onMeasureRight: (arg1: any) => void;
@@ -8,6 +8,11 @@ import * as $Flowgen$Import$_2e__2e__2f_types from "../types";
8
8
  import PropTypes from "prop-types";
9
9
  import * as React from "react";
10
10
  import type { SortableOption } from "../components/sortable";
11
+ declare type State = {|
12
+ leftHeight: number,
13
+ rightHeight: number,
14
+ texRendererLoaded: boolean,
15
+ |};
11
16
  declare class Matcher extends React.Component<any, any> {
12
17
  static propTypes: {|
13
18
  apiOptions: PropTypes.Validator<
@@ -65,9 +70,8 @@ declare class Matcher extends React.Component<any, any> {
65
70
  >,
66
71
  |};
67
72
  static defaultProps: any;
68
- state: any;
69
- componentDidMount(): void;
70
- render(): React.Node;
73
+ state: State;
74
+ render(): React.Element<any>;
71
75
  changeAndTrack: (arg1: any) => void;
72
76
  onMeasureLeft: (arg1: any) => void;
73
77
  onMeasureRight: (arg1: any) => void;
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import type { ChangeableProps } from "../mixins/changeable";
3
3
  import type { APIOptions } from "../types";
4
4
  type Props = ChangeableProps & {
5
- range: ReadonlyArray<number>;
5
+ range: [number, number];
6
6
  labelRange: ReadonlyArray<number | null>;
7
7
  labelStyle: string;
8
8
  labelTicks: boolean;
@@ -11,7 +11,7 @@ import type { APIOptions } from "../types";
11
11
  declare type Props = {|
12
12
  ...ChangeableProps,
13
13
  ...{|
14
- range: $ReadOnlyArray<number>,
14
+ range: [number, number],
15
15
  labelRange: $ReadOnlyArray<number | null>,
16
16
  labelStyle: string,
17
17
  labelTicks: boolean,
@@ -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;