@khanacademy/math-input 5.0.0 → 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 (35) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/components/input/cursor-contexts.d.ts +9 -9
  3. package/dist/components/input/cursor-contexts.js.flow +7 -8
  4. package/dist/components/input/math-wrapper.d.ts +1 -1
  5. package/dist/components/input/math-wrapper.js.flow +8 -2
  6. package/dist/components/input/mathquill-helpers.d.ts +1 -1
  7. package/dist/components/input/mathquill-helpers.js.flow +1 -1
  8. package/dist/components/keypad/index.d.ts +4 -3
  9. package/dist/components/keypad/index.js.flow +7 -3
  10. package/dist/components/keypad/shared-keys.d.ts +1 -1
  11. package/dist/components/keypad/shared-keys.js.flow +4 -1
  12. package/dist/components/keypad-legacy/expression-keypad.d.ts +1 -1
  13. package/dist/components/keypad-legacy/expression-keypad.js.flow +4 -1
  14. package/dist/components/keypad-legacy/fraction-keypad.d.ts +1 -1
  15. package/dist/components/keypad-legacy/fraction-keypad.js.flow +4 -1
  16. package/dist/es/index.js +23 -13
  17. package/dist/es/index.js.map +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +23 -12
  20. package/dist/index.js.flow +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/types.d.ts +2 -2
  23. package/dist/types.js.flow +2 -2
  24. package/package.json +1 -1
  25. package/src/components/input/cursor-contexts.ts +9 -9
  26. package/src/components/input/mathquill-helpers.ts +1 -1
  27. package/src/components/keypad/__tests__/keypad.test.tsx +37 -2
  28. package/src/components/keypad/index.tsx +10 -4
  29. package/src/components/keypad/keypad-mathquill.stories.tsx +3 -3
  30. package/src/components/keypad/shared-keys.tsx +4 -2
  31. package/src/components/keypad-legacy/expression-keypad.tsx +1 -1
  32. package/src/components/keypad-legacy/fraction-keypad.tsx +1 -1
  33. package/src/index.ts +2 -0
  34. package/src/types.ts +2 -3
  35. package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @khanacademy/math-input
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 36e3a212: Make v2 keypad dismiss button optional, hidden by default
8
+
9
+ ### Patch Changes
10
+
11
+ - fa735526: Fix issue with uses of CursorContext not being converted by flowgen
12
+
13
+ ## 5.0.1
14
+
15
+ ### Patch Changes
16
+
17
+ - 0cd9f3c4: Export getCursorContext helper from MathInput
18
+
3
19
  ## 5.0.0
4
20
 
5
21
  ### Major Changes
@@ -9,12 +9,12 @@
9
9
  * now, we show the dismiss button rather than allowing the user to jump out of
10
10
  * the radical.
11
11
  */
12
- export declare enum CursorContext {
13
- NONE = "NONE",
14
- IN_PARENS = "IN_PARENS",
15
- IN_SUPER_SCRIPT = "IN_SUPER_SCRIPT",
16
- IN_SUB_SCRIPT = "IN_SUB_SCRIPT",
17
- IN_NUMERATOR = "IN_NUMERATOR",
18
- IN_DENOMINATOR = "IN_DENOMINATOR",
19
- BEFORE_FRACTION = "BEFORE_FRACTION"
20
- }
12
+ export declare const CursorContext: {
13
+ readonly NONE: "NONE";
14
+ readonly IN_PARENS: "IN_PARENS";
15
+ readonly IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT";
16
+ readonly IN_SUB_SCRIPT: "IN_SUB_SCRIPT";
17
+ readonly IN_NUMERATOR: "IN_NUMERATOR";
18
+ readonly IN_DENOMINATOR: "IN_DENOMINATOR";
19
+ readonly BEFORE_FRACTION: "BEFORE_FRACTION";
20
+ };
@@ -15,13 +15,12 @@
15
15
  * now, we show the dismiss button rather than allowing the user to jump out of
16
16
  * the radical.
17
17
  */
18
-
19
18
  declare export var CursorContext: {|
20
- +NONE: "NONE", // "NONE"
21
- +IN_PARENS: "IN_PARENS", // "IN_PARENS"
22
- +IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT", // "IN_SUPER_SCRIPT"
23
- +IN_SUB_SCRIPT: "IN_SUB_SCRIPT", // "IN_SUB_SCRIPT"
24
- +IN_NUMERATOR: "IN_NUMERATOR", // "IN_NUMERATOR"
25
- +IN_DENOMINATOR: "IN_DENOMINATOR", // "IN_DENOMINATOR"
26
- +BEFORE_FRACTION: "BEFORE_FRACTION", // "BEFORE_FRACTION"
19
+ +NONE: "NONE",
20
+ +IN_PARENS: "IN_PARENS",
21
+ +IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT",
22
+ +IN_SUB_SCRIPT: "IN_SUB_SCRIPT",
23
+ +IN_NUMERATOR: "IN_NUMERATOR",
24
+ +IN_DENOMINATOR: "IN_DENOMINATOR",
25
+ +BEFORE_FRACTION: "BEFORE_FRACTION",
27
26
  |};
@@ -31,7 +31,7 @@ declare class MathWrapper {
31
31
  */
32
32
  setCursorPosition(x: number, y: number, hitNode: HTMLElement): void;
33
33
  getCursor(): any;
34
- contextForCursor(): import("./cursor-contexts").CursorContext;
34
+ contextForCursor(): "NONE" | "IN_PARENS" | "IN_SUPER_SCRIPT" | "IN_SUB_SCRIPT" | "IN_NUMERATOR" | "IN_DENOMINATOR" | "BEFORE_FRACTION";
35
35
  getSelection(): any;
36
36
  getContent(): string;
37
37
  setContent(latex: string): void;
@@ -4,7 +4,6 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import * as $Flowgen$Import$_2e__2f_cursor_2d_contexts from "./cursor-contexts";
8
7
  import Key from "../../data/keys";
9
8
  import { Cursor } from "../../types";
10
9
  import { MathFieldInterface } from "./mathquill-types";
@@ -39,7 +38,14 @@ declare class MathWrapper {
39
38
  */
40
39
  setCursorPosition(x: number, y: number, hitNode: HTMLElement): void;
41
40
  getCursor(): any;
42
- contextForCursor(): $Flowgen$Import$_2e__2f_cursor_2d_contexts.CursorContext;
41
+ contextForCursor():
42
+ | "NONE"
43
+ | "IN_PARENS"
44
+ | "IN_SUPER_SCRIPT"
45
+ | "IN_SUB_SCRIPT"
46
+ | "IN_NUMERATOR"
47
+ | "IN_DENOMINATOR"
48
+ | "BEFORE_FRACTION";
43
49
  getSelection(): any;
44
50
  getContent(): string;
45
51
  setContent(latex: string): void;
@@ -43,4 +43,4 @@ export declare function maybeFindCommandBeforeParens(leftParenNode: any): {
43
43
  startNode: any;
44
44
  endNode: any;
45
45
  } | null;
46
- export declare function getCursorContext(mathField?: MathFieldInterface): CursorContext;
46
+ export declare function getCursorContext(mathField?: MathFieldInterface): typeof CursorContext[keyof typeof CursorContext];
@@ -53,4 +53,4 @@ declare export function maybeFindCommandBeforeParens(leftParenNode: any): {|
53
53
  |} | null;
54
54
  declare export function getCursorContext(
55
55
  mathField?: MathFieldInterface
56
- ): CursorContext;
56
+ ): $ElementType<typeof CursorContext, $Keys<typeof CursorContext>>;
@@ -4,16 +4,17 @@ import { ClickKeyCallback } from "../../types";
4
4
  import { CursorContext } from "../input/cursor-contexts";
5
5
  import type { SendEventFn } from "@khanacademy/perseus-core";
6
6
  export type Props = {
7
- onClickKey: ClickKeyCallback;
8
- cursorContext?: CursorContext;
9
- trigonometry?: boolean;
10
7
  extraKeys: ReadonlyArray<Key>;
8
+ cursorContext?: typeof CursorContext[keyof typeof CursorContext];
9
+ showDismiss?: boolean;
11
10
  multiplicationDot?: boolean;
12
11
  divisionKey?: boolean;
12
+ trigonometry?: boolean;
13
13
  preAlgebra?: boolean;
14
14
  logarithms?: boolean;
15
15
  basicRelations?: boolean;
16
16
  advancedRelations?: boolean;
17
+ onClickKey: ClickKeyCallback;
17
18
  sendEvent: SendEventFn;
18
19
  };
19
20
  declare function Keypad(props: Props): JSX.Element;
@@ -9,16 +9,20 @@ import { ClickKeyCallback } from "../../types";
9
9
  import { CursorContext } from "../input/cursor-contexts";
10
10
  import type { SendEventFn } from "@khanacademy/perseus-core";
11
11
  export type Props = {|
12
- onClickKey: ClickKeyCallback,
13
- cursorContext?: CursorContext,
14
- trigonometry?: boolean,
15
12
  extraKeys: $ReadOnlyArray<Key>,
13
+ cursorContext?: $ElementType<
14
+ typeof CursorContext,
15
+ $Keys<typeof CursorContext>
16
+ >,
17
+ showDismiss?: boolean,
16
18
  multiplicationDot?: boolean,
17
19
  divisionKey?: boolean,
20
+ trigonometry?: boolean,
18
21
  preAlgebra?: boolean,
19
22
  logarithms?: boolean,
20
23
  basicRelations?: boolean,
21
24
  advancedRelations?: boolean,
25
+ onClickKey: ClickKeyCallback,
22
26
  sendEvent: SendEventFn,
23
27
  |};
24
28
  declare var Keypad: typeof npm$namespace$Keypad;
@@ -5,7 +5,7 @@ import { TabbarItemType } from "../tabbar/types";
5
5
  type Props = {
6
6
  onClickKey: ClickKeyCallback;
7
7
  selectedPage: TabbarItemType;
8
- cursorContext?: CursorContext;
8
+ cursorContext?: typeof CursorContext[keyof typeof CursorContext];
9
9
  multiplicationDot?: boolean;
10
10
  divisionKey?: boolean;
11
11
  };
@@ -10,7 +10,10 @@ import { TabbarItemType } from "../tabbar/types";
10
10
  declare type Props = {|
11
11
  onClickKey: ClickKeyCallback,
12
12
  selectedPage: TabbarItemType,
13
- cursorContext?: CursorContext,
13
+ cursorContext?: $ElementType<
14
+ typeof CursorContext,
15
+ $Keys<typeof CursorContext>
16
+ >,
14
17
  multiplicationDot?: boolean,
15
18
  divisionKey?: boolean,
16
19
  |};
@@ -5,7 +5,7 @@ import * as React from "react";
5
5
  import { CursorContext } from "../input/cursor-contexts";
6
6
  import type { KeypadLayout } from "../../types";
7
7
  interface ReduxProps {
8
- cursorContext?: CursorContext;
8
+ cursorContext?: typeof CursorContext[keyof typeof CursorContext];
9
9
  dynamicJumpOut: boolean;
10
10
  }
11
11
  interface Props extends ReduxProps {
@@ -9,7 +9,10 @@ import * as React from "react";
9
9
  import { CursorContext } from "../input/cursor-contexts";
10
10
  import type { KeypadLayout } from "../../types";
11
11
  declare interface ReduxProps {
12
- cursorContext?: CursorContext;
12
+ cursorContext?: $ElementType<
13
+ typeof CursorContext,
14
+ $Keys<typeof CursorContext>
15
+ >;
13
16
  dynamicJumpOut: boolean;
14
17
  }
15
18
  declare type Props = {
@@ -6,7 +6,7 @@ import * as React from "react";
6
6
  import { CursorContext } from "../input/cursor-contexts";
7
7
  import type { KeypadLayout } from "../../types";
8
8
  interface ReduxProps {
9
- cursorContext?: CursorContext;
9
+ cursorContext?: typeof CursorContext[keyof typeof CursorContext];
10
10
  dynamicJumpOut: boolean;
11
11
  }
12
12
  interface Props extends ReduxProps {
@@ -9,7 +9,10 @@ import * as React from "react";
9
9
  import { CursorContext } from "../input/cursor-contexts";
10
10
  import type { KeypadLayout } from "../../types";
11
11
  declare interface ReduxProps {
12
- cursorContext?: CursorContext;
12
+ cursorContext?: $ElementType<
13
+ typeof CursorContext,
14
+ $Keys<typeof CursorContext>
15
+ >;
13
16
  dynamicJumpOut: boolean;
14
17
  }
15
18
  declare type Props = {
package/dist/es/index.js CHANGED
@@ -27,16 +27,25 @@ import * as Redux from 'redux';
27
27
  * the radical.
28
28
  */
29
29
 
30
- let CursorContext = /*#__PURE__*/function (CursorContext) {
31
- CursorContext["NONE"] = "NONE";
32
- CursorContext["IN_PARENS"] = "IN_PARENS";
33
- CursorContext["IN_SUPER_SCRIPT"] = "IN_SUPER_SCRIPT";
34
- CursorContext["IN_SUB_SCRIPT"] = "IN_SUB_SCRIPT";
35
- CursorContext["IN_NUMERATOR"] = "IN_NUMERATOR";
36
- CursorContext["IN_DENOMINATOR"] = "IN_DENOMINATOR";
37
- CursorContext["BEFORE_FRACTION"] = "BEFORE_FRACTION";
38
- return CursorContext;
39
- }({});
30
+ const CursorContext = {
31
+ // The cursor is not in any of the other viable contexts.
32
+ NONE: "NONE",
33
+ // The cursor is within a set of parentheses.
34
+ IN_PARENS: "IN_PARENS",
35
+ // The cursor is within a superscript (e.g., an exponent).
36
+ IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT",
37
+ // The cursor is within a subscript (e.g., the base of a custom logarithm).
38
+ IN_SUB_SCRIPT: "IN_SUB_SCRIPT",
39
+ // The cursor is in the numerator of a fraction.
40
+ IN_NUMERATOR: "IN_NUMERATOR",
41
+ // The cursor is in the denominator of a fraction.
42
+ IN_DENOMINATOR: "IN_DENOMINATOR",
43
+ // The cursor is sitting before a fraction; that is, the cursor is within
44
+ // what looks to be a mixed number preceding a fraction. This will only be
45
+ // the case when the only math between the cursor and the fraction to its
46
+ // write is non-leaf math (numbers and variables).
47
+ BEFORE_FRACTION: "BEFORE_FRACTION"
48
+ };
40
49
 
41
50
  function _extends() {
42
51
  _extends = Object.assign || function (target) {
@@ -8595,7 +8604,8 @@ function Keypad(props) {
8595
8604
  preAlgebra,
8596
8605
  logarithms,
8597
8606
  basicRelations,
8598
- advancedRelations
8607
+ advancedRelations,
8608
+ showDismiss
8599
8609
  } = props;
8600
8610
  return /*#__PURE__*/React.createElement(View$1, null, /*#__PURE__*/React.createElement(Tabbar, {
8601
8611
  items: availablePages,
@@ -8604,7 +8614,7 @@ function Keypad(props) {
8604
8614
  setSelectedPage(tabbarItem);
8605
8615
  },
8606
8616
  style: styles.tabbar,
8607
- onClickClose: () => onClickKey("DISMISS")
8617
+ onClickClose: showDismiss ? () => onClickKey("DISMISS") : undefined
8608
8618
  }), /*#__PURE__*/React.createElement(View$1, {
8609
8619
  style: styles.grid,
8610
8620
  role: "grid",
@@ -8646,5 +8656,5 @@ const styles = StyleSheet.create({
8646
8656
  }
8647
8657
  });
8648
8658
 
8649
- export { CursorContext, KeyConfigs, Keypad, MathInput as KeypadInput, KeypadType, ProvidedKeypad as LegacyKeypad, createMathField, keyToMathquillMap as keyTranslator, keypadElementPropType, mathQuillInstance };
8659
+ export { CursorContext, KeyConfigs, Keypad, MathInput as KeypadInput, KeypadType, ProvidedKeypad as LegacyKeypad, createMathField, getCursorContext, keyToMathquillMap as keyTranslator, keypadElementPropType, mathQuillInstance };
8650
8660
  //# sourceMappingURL=index.js.map