@khanacademy/perseus 4.0.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/components/highlighting/highlightable-content.d.ts +4 -4
  3. package/dist/components/highlighting/highlightable-content.js.flow +4 -7
  4. package/dist/components/highlighting/ui/highlight-renderer.d.ts +6 -6
  5. package/dist/components/highlighting/ui/highlight-renderer.js.flow +6 -8
  6. package/dist/components/highlighting/ui/highlight-set-renderer.d.ts +5 -5
  7. package/dist/components/highlighting/ui/highlight-set-renderer.js.flow +5 -8
  8. package/dist/components/highlighting/ui/highlight-tooltip.d.ts +2 -2
  9. package/dist/components/highlighting/ui/highlight-tooltip.js.flow +2 -4
  10. package/dist/components/highlighting/ui/highlighting-ui.d.ts +3 -3
  11. package/dist/components/highlighting/ui/highlighting-ui.js.flow +2 -2
  12. package/dist/components/highlighting/ui/selection-tracker.d.ts +5 -5
  13. package/dist/components/highlighting/ui/selection-tracker.js.flow +5 -7
  14. package/dist/components/highlighting/word-indexer.d.ts +2 -2
  15. package/dist/components/highlighting/word-indexer.js.flow +2 -2
  16. package/dist/components/inline-icon.d.ts +35 -1
  17. package/dist/components/inline-icon.js.flow +11 -1
  18. package/dist/components/simple-keypad-input.d.ts +1 -1
  19. package/dist/components/simple-keypad-input.js.flow +1 -1
  20. package/dist/components/tex-buttons.d.ts +2 -2
  21. package/dist/components/tex-buttons.js.flow +2 -2
  22. package/dist/error-boundary.d.ts +4 -4
  23. package/dist/error-boundary.js.flow +4 -6
  24. package/dist/es/index.js +53 -233
  25. package/dist/es/index.js.map +1 -1
  26. package/dist/index.js +53 -233
  27. package/dist/index.js.map +1 -1
  28. package/dist/multi-items/multi-renderer.d.ts +1 -1
  29. package/dist/multi-items/multi-renderer.js.flow +1 -1
  30. package/dist/multi-items/prop-type-builders.d.ts +1 -1
  31. package/dist/multi-items/shape-types.d.ts +1 -1
  32. package/dist/multi-items/shape-types.js.flow +1 -1
  33. package/dist/multi-items/tree-types.d.ts +1 -1
  34. package/dist/multi-items/tree-types.js.flow +1 -1
  35. package/dist/perseus-types.d.ts +0 -1
  36. package/dist/perseus-types.js.flow +0 -1
  37. package/dist/widgets/__stories__/test-keypad-context-wrapper.d.ts +6 -0
  38. package/dist/widgets/__stories__/test-keypad-context-wrapper.js.flow +12 -0
  39. package/dist/widgets/expression.d.ts +2 -2
  40. package/dist/widgets/expression.js.flow +2 -2
  41. package/dist/widgets/interaction/element-container.d.ts +5 -4
  42. package/dist/widgets/interaction/element-container.js.flow +6 -11
  43. package/dist/widgets/label-image/marker.d.ts +4 -4
  44. package/dist/widgets/label-image/marker.js.flow +4 -6
  45. package/dist/widgets/numeric-input.d.ts +0 -2
  46. package/dist/widgets/numeric-input.js.flow +0 -4
  47. package/dist/widgets/radio/base-radio.d.ts +7 -1
  48. package/dist/widgets/radio/base-radio.js.flow +7 -1
  49. package/dist/widgets/radio/choice-icon/choice-icon.d.ts +1 -1
  50. package/dist/widgets/radio/choice-icon/choice-icon.js.flow +1 -1
  51. package/dist/widgets/radio/choice-icon/cross-out-line.d.ts +2 -2
  52. package/dist/widgets/radio/choice-icon/cross-out-line.js.flow +2 -2
  53. package/dist/widgets/radio/focus-ring.d.ts +8 -1
  54. package/dist/widgets/radio/focus-ring.js.flow +8 -1
  55. package/dist/widgets/radio/option-status.d.ts +2 -2
  56. package/dist/widgets/radio/option-status.js.flow +2 -2
  57. package/dist/widgets/video-transcript-link.d.ts +1 -1
  58. package/dist/widgets/video-transcript-link.js.flow +1 -1
  59. package/package.json +4 -4
  60. package/src/__stories__/item-renderer.stories.tsx +2 -6
  61. package/src/__stories__/server-item-renderer.stories.tsx +2 -6
  62. package/src/__testdata__/item-renderer.testdata.ts +1 -1
  63. package/src/__testdata__/renderer.testdata.ts +1 -1
  64. package/src/__tests__/item-renderer.test.tsx +1 -2
  65. package/src/__tests__/renderer-api.test.tsx +1 -5
  66. package/src/__tests__/renderer.test.tsx +1 -1
  67. package/src/components/__stories__/button-group.stories.tsx +2 -6
  68. package/src/components/__stories__/fixed-to-responsive.stories.tsx +14 -16
  69. package/src/components/__stories__/graph.stories.tsx +3 -5
  70. package/src/components/__stories__/graphie.stories.tsx +3 -5
  71. package/src/components/__stories__/hud.stories.tsx +2 -6
  72. package/src/components/__stories__/icon.stories.tsx +1 -1
  73. package/src/components/__stories__/image-loader.stories.tsx +4 -4
  74. package/src/components/__stories__/info-tip.stories.tsx +2 -6
  75. package/src/components/__stories__/inline-icon.stories.tsx +4 -8
  76. package/src/components/__stories__/input-with-examples.stories.tsx +6 -10
  77. package/src/components/__stories__/lint.stories.tsx +12 -12
  78. package/src/components/__stories__/math-input.stories.tsx +4 -8
  79. package/src/components/__stories__/math-output.stories.tsx +3 -5
  80. package/src/components/__stories__/multi-button-group.stories.tsx +2 -6
  81. package/src/components/__stories__/number-input.stories.tsx +6 -8
  82. package/src/components/__stories__/prop-check-box.stories.tsx +9 -9
  83. package/src/components/__stories__/range-input.stories.tsx +4 -6
  84. package/src/components/__stories__/simple-keypad-input.stories.tsx +2 -4
  85. package/src/components/__stories__/sortable.stories.tsx +15 -15
  86. package/src/components/__stories__/stub-tag-editor.stories.tsx +5 -9
  87. package/src/components/__stories__/svg-image.stories.tsx +10 -18
  88. package/src/components/__stories__/tex.stories.tsx +1 -3
  89. package/src/components/__stories__/text-buttons.stories.tsx +10 -22
  90. package/src/components/__stories__/text-input.stories.tsx +4 -10
  91. package/src/components/__stories__/text-list-editor.stories.tsx +1 -3
  92. package/src/components/__stories__/zoomable-tex.stories.tsx +6 -4
  93. package/src/components/__stories__/zoomable.stories.tsx +1 -3
  94. package/src/components/fixed-to-responsive.tsx +0 -1
  95. package/src/components/graph.tsx +0 -4
  96. package/src/components/highlighting/highlightable-content.tsx +4 -7
  97. package/src/components/highlighting/ui/highlight-renderer.tsx +6 -9
  98. package/src/components/highlighting/ui/highlight-set-renderer.tsx +5 -8
  99. package/src/components/highlighting/ui/highlight-tooltip.tsx +2 -2
  100. package/src/components/highlighting/ui/highlighting-ui.tsx +5 -15
  101. package/src/components/highlighting/ui/selection-tracker.tsx +6 -9
  102. package/src/components/highlighting/word-indexer.tsx +2 -6
  103. package/src/components/inline-icon.tsx +2 -2
  104. package/src/components/math-input.tsx +0 -2
  105. package/src/components/number-input.tsx +0 -2
  106. package/src/components/simple-keypad-input.tsx +2 -2
  107. package/src/components/tex-buttons.tsx +2 -2
  108. package/src/components/text-list-editor.tsx +0 -4
  109. package/src/components/visibility-observer/__stories__/visibility-observer.stories.tsx +1 -3
  110. package/src/components/zoomable-tex.tsx +0 -2
  111. package/src/components/zoomable.tsx +0 -4
  112. package/src/definition-context.tsx +0 -1
  113. package/src/error-boundary.tsx +4 -7
  114. package/src/hints-renderer.tsx +1 -1
  115. package/src/interactive2/__tests__/movable-point.test.ts +0 -1
  116. package/src/item-renderer.tsx +0 -5
  117. package/src/mixins/changeable.ts +1 -1
  118. package/src/multi-items/__stories__/multi-renderer.stories.tsx +1 -5
  119. package/src/multi-items/__tests__/items.test.ts +3 -13
  120. package/src/multi-items/__tests__/multi-renderer.test.tsx +3 -4
  121. package/src/multi-items/__tests__/prop-type-builders.test.ts +1 -1
  122. package/src/multi-items/__tests__/trees.test.ts +2 -10
  123. package/src/multi-items/multi-renderer.tsx +7 -10
  124. package/src/multi-items/prop-type-builders.ts +1 -1
  125. package/src/multi-items/shape-types.ts +1 -1
  126. package/src/multi-items/tree-types.ts +1 -1
  127. package/src/perseus-markdown.tsx +0 -2
  128. package/src/perseus-types.ts +1 -4
  129. package/src/renderer.tsx +2 -5
  130. package/src/server-item-renderer.tsx +0 -3
  131. package/src/util/graphie.ts +3 -3
  132. package/src/util/interactive.ts +0 -4
  133. package/src/util/math.ts +0 -3
  134. package/src/widgets/__stories__/categorizer.stories.tsx +1 -1
  135. package/src/widgets/__stories__/cs-program.stories.tsx +1 -1
  136. package/src/widgets/__stories__/definition.stories.tsx +3 -7
  137. package/src/widgets/__stories__/dropdown.stories.tsx +1 -1
  138. package/src/widgets/__stories__/explanation.stories.tsx +2 -2
  139. package/src/widgets/__stories__/expression.stories.tsx +113 -13
  140. package/src/widgets/__stories__/graded-group-set.stories.tsx +1 -1
  141. package/src/widgets/__stories__/graded-group.stories.tsx +1 -1
  142. package/src/widgets/__stories__/grapher.stories.tsx +7 -21
  143. package/src/widgets/__stories__/group.stories.tsx +1 -1
  144. package/src/widgets/__stories__/iframe.stories.tsx +1 -1
  145. package/src/widgets/__stories__/image.stories.tsx +2 -2
  146. package/src/widgets/__stories__/input-number.stories.tsx +3 -12
  147. package/src/widgets/__stories__/interaction.stories.tsx +1 -1
  148. package/src/widgets/__stories__/interactive-graph.stories.tsx +9 -9
  149. package/src/widgets/__stories__/matcher.stories.tsx +1 -1
  150. package/src/widgets/__stories__/matrix.stories.tsx +1 -1
  151. package/src/widgets/__stories__/number-line.stories.tsx +1 -1
  152. package/src/widgets/__stories__/numeric-input.stories.tsx +3 -5
  153. package/src/widgets/__stories__/orderer.stories.tsx +1 -1
  154. package/src/widgets/__stories__/passage-ref.stories.tsx +2 -2
  155. package/src/widgets/__stories__/passage.stories.tsx +3 -9
  156. package/src/widgets/__stories__/radio.stories.tsx +3 -5
  157. package/src/widgets/__stories__/sorter.stories.tsx +1 -1
  158. package/src/widgets/__stories__/{on-screen-keypad.stories.tsx → test-keypad-context-wrapper.tsx} +15 -57
  159. package/src/widgets/__stories__/transformer.stories.tsx +1 -1
  160. package/src/widgets/__stories__/unit.stories.tsx +1 -3
  161. package/src/widgets/__stories__/video-transcript-link.stories.tsx +2 -6
  162. package/src/widgets/__stories__/video.stories.tsx +1 -1
  163. package/src/widgets/__testdata__/expression.testdata.ts +16 -12
  164. package/src/widgets/__testdata__/group.testdata.ts +0 -2
  165. package/src/widgets/__testdata__/numeric-input.testdata.ts +0 -1
  166. package/src/widgets/__testdata__/transformer.testdata.ts +0 -1
  167. package/src/widgets/__tests__/group.test.tsx +0 -2
  168. package/src/widgets/__tests__/radio/focus-ring.test.tsx +0 -1
  169. package/src/widgets/__tests__/radio.test.ts +1 -1
  170. package/src/widgets/expression.tsx +4 -4
  171. package/src/widgets/graded-group-set.tsx +0 -4
  172. package/src/widgets/graded-group.tsx +0 -4
  173. package/src/widgets/grapher/util.tsx +1 -5
  174. package/src/widgets/grapher.tsx +0 -5
  175. package/src/widgets/group.tsx +0 -1
  176. package/src/widgets/interaction/element-container.tsx +7 -8
  177. package/src/widgets/interaction.tsx +0 -1
  178. package/src/widgets/interactive-graph.tsx +3 -62
  179. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +2 -4
  180. package/src/widgets/label-image/__stories__/marker.stories.tsx +9 -19
  181. package/src/widgets/label-image/marker.tsx +4 -4
  182. package/src/widgets/label-image.tsx +1 -1
  183. package/src/widgets/measurer.tsx +0 -1
  184. package/src/widgets/number-line.tsx +0 -2
  185. package/src/widgets/numeric-input.tsx +0 -3
  186. package/src/widgets/orderer.tsx +0 -3
  187. package/src/widgets/passage/passage-markdown.tsx +3 -3
  188. package/src/widgets/passage-ref-target.tsx +0 -1
  189. package/src/widgets/passage.tsx +1 -1
  190. package/src/widgets/plotter.tsx +0 -1
  191. package/src/widgets/radio/__stories__/base-radio.stories.tsx +13 -21
  192. package/src/widgets/radio/__stories__/choice-icon.stories.tsx +9 -11
  193. package/src/widgets/radio/__stories__/choice-none-above.stories.tsx +1 -1
  194. package/src/widgets/radio/__stories__/choice.stories.tsx +4 -4
  195. package/src/widgets/radio/__stories__/focus-ring.stories.tsx +1 -1
  196. package/src/widgets/radio/__stories__/option-status.stories.tsx +2 -4
  197. package/src/widgets/radio/base-radio.tsx +2 -2
  198. package/src/widgets/radio/choice-icon/choice-icon.tsx +5 -5
  199. package/src/widgets/radio/choice-icon/cross-out-line.tsx +1 -3
  200. package/src/widgets/radio/choice-none-above.tsx +2 -2
  201. package/src/widgets/radio/choice.tsx +1 -3
  202. package/src/widgets/radio/focus-ring.tsx +1 -1
  203. package/src/widgets/radio/option-status.tsx +2 -4
  204. package/src/widgets/radio/widget.tsx +0 -1
  205. package/src/widgets/reaction-diagram.tsx +2 -2
  206. package/src/widgets/transformer.tsx +1 -16
  207. package/src/widgets/video-transcript-link.tsx +1 -1
  208. package/src/widgets.ts +1 -1
  209. package/src/zoom.ts +0 -3
  210. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @khanacademy/perseus
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 472e20e1: Remove all references to multipleNumberInput (ie. Ask for (one|all) correct solution)
8
+
9
+ ### Patch Changes
10
+
11
+ - 22c5d564: Remove the use of React.FC<> and use types named Props/State in more components
12
+ - Updated dependencies [4c03a43d]
13
+ - Updated dependencies [22c5d564]
14
+ - @khanacademy/math-input@1.0.0
15
+ - @khanacademy/simple-markdown@0.9.3
16
+ - @khanacademy/pure-markdown@0.2.3
17
+
18
+ ## 4.0.2
19
+
20
+ ### Patch Changes
21
+
22
+ - 90c1833e: Fix lint
23
+ - Updated dependencies [8e8d85cd]
24
+ - Updated dependencies [77391aa8]
25
+ - @khanacademy/math-input@0.7.2
26
+ - @khanacademy/simple-markdown@0.9.2
27
+ - @khanacademy/pure-markdown@0.2.2
28
+
3
29
  ## 4.0.1
4
30
 
5
31
  ### Patch Changes
@@ -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
  }
@@ -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,9 +11,9 @@ 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
- _selectionIsValid(trackedSelection?: TrackedSelection | null): boolean;
16
+ _selectionIsValid(trackedSelection?: TrackedSelection | null): trackedSelection is TrackedSelection;
17
17
  render(): React.ReactNode;
18
18
  }
19
19
  export default HighlightingUI;
@@ -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,5 +1,39 @@
1
+ /**
2
+ * A stripped version of Icon.jsx from webapp. Takes an SVG icon and renders it
3
+ * inline like Font Awesome did.
4
+ *
5
+ * If you are looking for an icon that we've used before you should look in
6
+ * webapp's `icon-paths.js` which is a reference file for all the SVG paths
7
+ * that we've used. You'll need to copy the object from that file into
8
+ * whichever file you're using the icon and explicitly pass it in to the
9
+ * <InlineIcon/> React component.
10
+ *
11
+ * We assume that the viewBox is cropped and aligned to (0, 0), but icons can
12
+ * be defined differently. At some point we might want to add these attributes
13
+ * to `icon-paths.js`, but for now this is a fairly safe assumption.
14
+ *
15
+ * Sample usage:
16
+ *
17
+ * const editIcon = {
18
+ * 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",
19
+ * width: 100,
20
+ * height: 78.912,
21
+ * };
22
+ * <InlineIcon {...editIcon} />
23
+ *
24
+ */
25
+ import PropTypes from "prop-types";
1
26
  import * as React from "react";
2
- declare const InlineIcon: React.FC<InlineIconProps>;
27
+ declare const InlineIcon: {
28
+ ({ path, width, height, style, title, }: InlineIconProps): React.ReactElement;
29
+ propTypes: {
30
+ path: PropTypes.Validator<string>;
31
+ height: PropTypes.Validator<number>;
32
+ width: PropTypes.Validator<number>;
33
+ style: PropTypes.Requireable<object>;
34
+ title: PropTypes.Requireable<string>;
35
+ };
36
+ };
3
37
  export type InlineIconProps = {
4
38
  path: string;
5
39
  height: number;
@@ -4,8 +4,18 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
+ import PropTypes from "prop-types";
7
8
  import * as React from "react";
8
- declare var InlineIcon: React.StatelessFunctionalComponent<InlineIconProps>;
9
+ declare var InlineIcon: {|
10
+ (x: InlineIconProps): React.Element<any>,
11
+ propTypes: {|
12
+ path: PropTypes.Validator<string>,
13
+ height: PropTypes.Validator<number>,
14
+ width: PropTypes.Validator<number>,
15
+ style: PropTypes.Requireable<{ ... }>,
16
+ title: PropTypes.Requireable<string>,
17
+ |},
18
+ |};
9
19
  export type InlineIconProps = {|
10
20
  path: string,
11
21
  height: number,
@@ -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;
@@ -6,13 +6,13 @@ type ButtonSets = {
6
6
  };
7
7
  declare const buttonSets: ButtonSets;
8
8
  export type ButtonSetsType = ReadonlyArray<keyof typeof buttonSets>;
9
- type TexButtonProps = {
9
+ type Props = {
10
10
  sets: ButtonSetsType;
11
11
  onInsert: (arg1: Inserter) => void;
12
12
  className?: string;
13
13
  convertDotToTimes?: boolean;
14
14
  };
15
- declare class TexButtons extends React.Component<TexButtonProps> {
15
+ declare class TexButtons extends React.Component<Props> {
16
16
  static buttonSets: typeof buttonSets;
17
17
  static buttonSetsType: any;
18
18
  render(): React.ReactNode;
@@ -12,13 +12,13 @@ declare type ButtonSets = {
12
12
  };
13
13
  declare var buttonSets: ButtonSets;
14
14
  export type ButtonSetsType = $ReadOnlyArray<$Keys<typeof buttonSets>>;
15
- declare type TexButtonProps = {|
15
+ declare type Props = {|
16
16
  sets: ButtonSetsType,
17
17
  onInsert: (arg1: Inserter) => void,
18
18
  className?: string,
19
19
  convertDotToTimes?: boolean,
20
20
  |};
21
- declare class TexButtons extends React.Component<TexButtonProps> {
21
+ declare class TexButtons extends React.Component<Props> {
22
22
  static buttonSets: typeof buttonSets;
23
23
  static buttonSetsType: any;
24
24
  render(): React.Node;
@@ -1,12 +1,12 @@
1
1
  import * as React from "react";
2
- type ErrorBoundaryProps = {
2
+ type Props = {
3
3
  children: React.ReactNode;
4
4
  };
5
- type ErrorBoundaryState = {
5
+ type State = {
6
6
  error: string;
7
7
  };
8
- declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
9
- constructor(props: ErrorBoundaryProps);
8
+ declare class ErrorBoundary extends React.Component<Props, State> {
9
+ constructor(props: Props);
10
10
  componentDidCatch(error: Error, info: any): void;
11
11
  render(): React.ReactNode;
12
12
  }
@@ -5,16 +5,14 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- declare type ErrorBoundaryProps = {|
8
+ declare type Props = {|
9
9
  children: React.Node,
10
10
  |};
11
- declare type ErrorBoundaryState = {|
11
+ declare type State = {|
12
12
  error: string,
13
13
  |};
14
- declare class ErrorBoundary
15
- extends React.Component<ErrorBoundaryProps, ErrorBoundaryState>
16
- {
17
- constructor(props: ErrorBoundaryProps): this;
14
+ declare class ErrorBoundary extends React.Component<Props, State> {
15
+ constructor(props: Props): this;
18
16
  componentDidCatch(error: Error, info: any): void;
19
17
  render(): React.Node;
20
18
  }