@khanacademy/math-input 3.0.0 → 4.1.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 (113) hide show
  1. package/.eslintrc.js +7 -1
  2. package/CHANGELOG.md +42 -0
  3. package/dist/components/input/__tests__/test-math-wrapper.d.ts +1 -1
  4. package/dist/components/input/__tests__/test-math-wrapper.js.flow +1 -1
  5. package/dist/components/input/key-handlers/handle-arrow.d.ts +3 -0
  6. package/dist/components/input/key-handlers/handle-arrow.js.flow +12 -0
  7. package/dist/components/input/key-handlers/handle-backspace.d.ts +7 -0
  8. package/dist/components/input/key-handlers/handle-backspace.js.flow +14 -0
  9. package/dist/components/input/key-handlers/handle-exponent.d.ts +3 -0
  10. package/dist/components/input/key-handlers/handle-exponent.js.flow +12 -0
  11. package/dist/components/input/key-handlers/handle-jump-out.d.ts +7 -0
  12. package/dist/components/input/key-handlers/handle-jump-out.js.flow +14 -0
  13. package/dist/components/input/math-wrapper.d.ts +7 -78
  14. package/dist/components/input/math-wrapper.js.flow +16 -78
  15. package/dist/components/input/mathquill-helpers.d.ts +46 -0
  16. package/dist/components/input/mathquill-helpers.js.flow +56 -0
  17. package/dist/components/input/mathquill-instance.d.ts +3 -0
  18. package/dist/components/input/mathquill-instance.js.flow +9 -0
  19. package/dist/components/input/mathquill-types.d.ts +25 -0
  20. package/dist/components/input/mathquill-types.js.flow +34 -0
  21. package/dist/components/key-translator.d.ts +4 -0
  22. package/dist/components/key-translator.js.flow +10 -0
  23. package/dist/components/keypad/button-assets.d.ts +2 -2
  24. package/dist/components/keypad/button-assets.js.flow +2 -2
  25. package/dist/components/keypad/button.d.ts +1 -0
  26. package/dist/components/keypad/button.js.flow +1 -0
  27. package/dist/components/keypad/extras-page/index.d.ts +10 -0
  28. package/dist/components/keypad/extras-page/index.js.flow +15 -0
  29. package/dist/components/keypad/index.d.ts +7 -1
  30. package/dist/components/keypad/index.js.flow +7 -1
  31. package/dist/components/keypad/keypad-page-items.d.ts +1 -1
  32. package/dist/components/keypad/keypad-page-items.js.flow +1 -1
  33. package/dist/components/keypad-legacy/gesture-manager.d.ts +21 -9
  34. package/dist/components/keypad-legacy/gesture-manager.js.flow +27 -12
  35. package/dist/components/keypad-legacy/gesture-state-machine.d.ts +9 -9
  36. package/dist/components/keypad-legacy/gesture-state-machine.js.flow +10 -10
  37. package/dist/components/keypad-legacy/keypad-button.d.ts +2 -2
  38. package/dist/components/keypad-legacy/keypad-button.js.flow +3 -3
  39. package/dist/components/keypad-legacy/store/actions.d.ts +4 -14
  40. package/dist/components/keypad-legacy/store/actions.js.flow +3 -15
  41. package/dist/components/keypad-legacy/store/types.d.ts +2 -2
  42. package/dist/components/keypad-legacy/store/types.js.flow +2 -2
  43. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +6 -6
  44. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +9 -14
  45. package/dist/components/keypad-legacy/two-page-keypad.d.ts +6 -4
  46. package/dist/components/keypad-legacy/two-page-keypad.js.flow +6 -4
  47. package/dist/components/tabbar/tabbar.d.ts +6 -9
  48. package/dist/components/tabbar/tabbar.js.flow +6 -9
  49. package/dist/components/tabbar/types.d.ts +1 -1
  50. package/dist/components/tabbar/types.js.flow +1 -1
  51. package/dist/data/key-configs.d.ts +3 -6
  52. package/dist/data/key-configs.js.flow +3 -8
  53. package/dist/data/keys.d.ts +2 -54
  54. package/dist/data/keys.js.flow +116 -55
  55. package/dist/enums.d.ts +2 -9
  56. package/dist/enums.js.flow +2 -11
  57. package/dist/es/index.js +2000 -1346
  58. package/dist/es/index.js.map +1 -1
  59. package/dist/index.d.ts +3 -2
  60. package/dist/index.js +2288 -1392
  61. package/dist/index.js.flow +4 -2
  62. package/dist/index.js.map +1 -1
  63. package/dist/strings.js +26 -10
  64. package/dist/types.d.ts +10 -12
  65. package/dist/types.js.flow +13 -12
  66. package/package.json +2 -1
  67. package/src/components/input/__tests__/context-tracking.test.ts +43 -44
  68. package/src/components/input/__tests__/mathquill.test.ts +133 -135
  69. package/src/components/input/key-handlers/handle-arrow.ts +70 -0
  70. package/src/components/input/key-handlers/handle-backspace.ts +275 -0
  71. package/src/components/input/key-handlers/handle-exponent.ts +52 -0
  72. package/src/components/input/key-handlers/handle-jump-out.ts +103 -0
  73. package/src/components/input/math-input.tsx +11 -12
  74. package/src/components/input/math-wrapper.ts +88 -837
  75. package/src/components/input/mathquill-helpers.ts +268 -0
  76. package/src/components/input/mathquill-instance.ts +5 -0
  77. package/src/components/input/mathquill-types.ts +55 -0
  78. package/src/components/key-translator.ts +209 -0
  79. package/src/components/keypad/button-assets.tsx +441 -100
  80. package/src/components/keypad/button.tsx +7 -2
  81. package/src/components/keypad/extras-page/index.tsx +27 -0
  82. package/src/components/keypad/geometry-page/index.tsx +1 -1
  83. package/src/components/keypad/index.tsx +34 -7
  84. package/src/components/keypad/keypad-mathquill.stories.tsx +82 -0
  85. package/src/components/keypad/keypad-page-items.tsx +3 -1
  86. package/src/components/keypad/operators-page/index.tsx +1 -1
  87. package/src/components/keypad-legacy/echo-manager.tsx +4 -4
  88. package/src/components/keypad-legacy/empty-keypad-button.tsx +6 -4
  89. package/src/components/keypad-legacy/gesture-manager.ts +32 -9
  90. package/src/components/keypad-legacy/gesture-state-machine.ts +14 -14
  91. package/src/components/keypad-legacy/keypad-button.tsx +15 -18
  92. package/src/components/keypad-legacy/many-keypad-button.tsx +9 -2
  93. package/src/components/keypad-legacy/store/actions.ts +3 -29
  94. package/src/components/keypad-legacy/store/echo-reducer.ts +2 -5
  95. package/src/components/keypad-legacy/store/index.ts +4 -10
  96. package/src/components/keypad-legacy/store/input-reducer.ts +1 -2
  97. package/src/components/keypad-legacy/store/keypad-reducer.ts +2 -3
  98. package/src/components/keypad-legacy/store/types.ts +2 -2
  99. package/src/components/keypad-legacy/touchable-keypad-button.tsx +8 -13
  100. package/src/components/keypad-legacy/two-page-keypad.tsx +18 -6
  101. package/src/components/tabbar/__tests__/tabbar.test.tsx +36 -36
  102. package/src/components/tabbar/icons.tsx +68 -52
  103. package/src/components/tabbar/item.tsx +5 -1
  104. package/src/components/tabbar/tabbar.stories.tsx +23 -12
  105. package/src/components/tabbar/tabbar.tsx +22 -38
  106. package/src/components/tabbar/types.ts +1 -1
  107. package/src/data/key-configs.ts +751 -304
  108. package/src/data/keys.ts +118 -65
  109. package/src/enums.ts +10 -9
  110. package/src/index.ts +3 -2
  111. package/src/math-input.stories.tsx +1 -1
  112. package/src/types.ts +10 -12
  113. package/tsconfig-build.tsbuildinfo +1 -1
@@ -4,17 +4,14 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
+ import { StyleType } from "@khanacademy/wonder-blocks-core";
7
8
  import * as React from "react";
8
- import type { TabbarItemType } from "./types";
9
- declare type TabbarState = {|
10
- selectedItem: number,
11
- |};
9
+ import { TabbarItemType } from "./types";
12
10
  declare type Props = {|
13
11
  items: $ReadOnlyArray<TabbarItemType>,
14
- onSelect: (item: TabbarItemType) => void,
12
+ selectedItem: TabbarItemType,
13
+ onSelectItem: (item: TabbarItemType) => void,
14
+ style?: StyleType,
15
15
  |};
16
- declare class Tabbar extends React.Component<Props, TabbarState> {
17
- state: TabbarState;
18
- render(): React.Node;
19
- }
16
+ declare function Tabbar(props: Props): React.Element<any>;
20
17
  declare export default typeof Tabbar;
@@ -1 +1 @@
1
- export type TabbarItemType = "Geometry" | "Operators" | "Numbers";
1
+ export type TabbarItemType = "Geometry" | "Operators" | "Numbers" | "Extras";
@@ -4,4 +4,4 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- export type TabbarItemType = "Geometry" | "Operators" | "Numbers";
7
+ export type TabbarItemType = "Geometry" | "Operators" | "Numbers" | "Extras";
@@ -1,9 +1,6 @@
1
- export type KeyConfig = {
2
- id: string;
3
- type: string;
4
- ariaLabel: string;
5
- };
1
+ import { KeyConfig } from "../types";
2
+ import Key from "./keys";
6
3
  declare const KeyConfigs: {
7
- [key: string]: any;
4
+ [key in Key]: KeyConfig;
8
5
  };
9
6
  export default KeyConfigs;
@@ -4,12 +4,7 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- export type KeyConfig = {|
8
- id: string,
9
- type: string,
10
- ariaLabel: string,
11
- |};
12
- declare var KeyConfigs: {
13
- [key: string]: any,
14
- };
7
+ import { KeyConfig } from "../types";
8
+ import Key from "./keys";
9
+ declare var KeyConfigs: $ObjMapi<{ [k: Key]: any }, <key>(key) => KeyConfig>;
15
10
  declare export default typeof KeyConfigs;
@@ -1,54 +1,2 @@
1
- /**
2
- * This file contains constants for keypad buttons that aren't single
3
- * alphanumeric characters.
4
- */
5
- declare enum Keys {
6
- PLUS = "PLUS",
7
- MINUS = "MINUS",
8
- NEGATIVE = "NEGATIVE",
9
- TIMES = "TIMES",
10
- DIVIDE = "DIVIDE",
11
- DECIMAL = "DECIMAL",
12
- PERIOD = "PERIOD",
13
- PERCENT = "PERCENT",
14
- CDOT = "CDOT",
15
- EQUAL = "EQUAL",
16
- NEQ = "NEQ",
17
- GT = "GT",
18
- LT = "LT",
19
- GEQ = "GEQ",
20
- LEQ = "LEQ",
21
- FRAC_INCLUSIVE = "FRAC_INCLUSIVE",
22
- FRAC_EXCLUSIVE = "FRAC_EXCLUSIVE",
23
- FRAC = "FRAC",
24
- EXP = "EXP",
25
- EXP_2 = "EXP_2",
26
- EXP_3 = "EXP_3",
27
- SQRT = "SQRT",
28
- CUBE_ROOT = "CUBE_ROOT",
29
- RADICAL = "RADICAL",
30
- LEFT_PAREN = "LEFT_PAREN",
31
- RIGHT_PAREN = "RIGHT_PAREN",
32
- LN = "LN",
33
- LOG = "LOG",
34
- LOG_N = "LOG_N",
35
- SIN = "SIN",
36
- COS = "COS",
37
- TAN = "TAN",
38
- PI = "PI",
39
- THETA = "THETA",
40
- UP = "UP",
41
- RIGHT = "RIGHT",
42
- DOWN = "DOWN",
43
- LEFT = "LEFT",
44
- BACKSPACE = "BACKSPACE",
45
- DISMISS = "DISMISS",
46
- JUMP_OUT_PARENTHESES = "JUMP_OUT_PARENTHESES",
47
- JUMP_OUT_EXPONENT = "JUMP_OUT_EXPONENT",
48
- JUMP_OUT_BASE = "JUMP_OUT_BASE",
49
- JUMP_INTO_NUMERATOR = "JUMP_INTO_NUMERATOR",
50
- JUMP_OUT_NUMERATOR = "JUMP_OUT_NUMERATOR",
51
- JUMP_OUT_DENOMINATOR = "JUMP_OUT_DENOMINATOR",
52
- NOOP = "NOOP"
53
- }
54
- export default Keys;
1
+ type Key = "PLUS" | "MINUS" | "NEGATIVE" | "TIMES" | "DIVIDE" | "DECIMAL" | "PERIOD" | "PERCENT" | "CDOT" | "EQUAL" | "NEQ" | "GT" | "LT" | "GEQ" | "LEQ" | "FRAC_INCLUSIVE" | "FRAC_EXCLUSIVE" | "FRAC" | "EXP" | "EXP_2" | "EXP_3" | "SQRT" | "CUBE_ROOT" | "RADICAL" | "LEFT_PAREN" | "RIGHT_PAREN" | "LN" | "LOG" | "LOG_N" | "SIN" | "COS" | "TAN" | "PI" | "THETA" | "UP" | "RIGHT" | "DOWN" | "LEFT" | "BACKSPACE" | "DISMISS" | "JUMP_OUT_PARENTHESES" | "JUMP_OUT_EXPONENT" | "JUMP_OUT_BASE" | "JUMP_INTO_NUMERATOR" | "JUMP_OUT_NUMERATOR" | "JUMP_OUT_DENOMINATOR" | "NOOP" | "MANY" | "NUM_0" | "NUM_1" | "NUM_2" | "NUM_3" | "NUM_4" | "NUM_5" | "NUM_6" | "NUM_7" | "NUM_8" | "NUM_9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "PHI" | "NTHROOT3" | "POW" | "LOG_B";
2
+ export default Key;
@@ -4,58 +4,119 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- /**
8
- * This file contains constants for keypad buttons that aren't single
9
- * alphanumeric characters.
10
- */
11
-
12
- declare var Keys: {|
13
- +PLUS: "PLUS", // "PLUS"
14
- +MINUS: "MINUS", // "MINUS"
15
- +NEGATIVE: "NEGATIVE", // "NEGATIVE"
16
- +TIMES: "TIMES", // "TIMES"
17
- +DIVIDE: "DIVIDE", // "DIVIDE"
18
- +DECIMAL: "DECIMAL", // "DECIMAL"
19
- +PERIOD: "PERIOD", // "PERIOD"
20
- +PERCENT: "PERCENT", // "PERCENT"
21
- +CDOT: "CDOT", // "CDOT"
22
- +EQUAL: "EQUAL", // "EQUAL"
23
- +NEQ: "NEQ", // "NEQ"
24
- +GT: "GT", // "GT"
25
- +LT: "LT", // "LT"
26
- +GEQ: "GEQ", // "GEQ"
27
- +LEQ: "LEQ", // "LEQ"
28
- +FRAC_INCLUSIVE: "FRAC_INCLUSIVE", // "FRAC_INCLUSIVE"
29
- +FRAC_EXCLUSIVE: "FRAC_EXCLUSIVE", // "FRAC_EXCLUSIVE"
30
- +FRAC: "FRAC", // "FRAC"
31
- +EXP: "EXP", // "EXP"
32
- +EXP_2: "EXP_2", // "EXP_2"
33
- +EXP_3: "EXP_3", // "EXP_3"
34
- +SQRT: "SQRT", // "SQRT"
35
- +CUBE_ROOT: "CUBE_ROOT", // "CUBE_ROOT"
36
- +RADICAL: "RADICAL", // "RADICAL"
37
- +LEFT_PAREN: "LEFT_PAREN", // "LEFT_PAREN"
38
- +RIGHT_PAREN: "RIGHT_PAREN", // "RIGHT_PAREN"
39
- +LN: "LN", // "LN"
40
- +LOG: "LOG", // "LOG"
41
- +LOG_N: "LOG_N", // "LOG_N"
42
- +SIN: "SIN", // "SIN"
43
- +COS: "COS", // "COS"
44
- +TAN: "TAN", // "TAN"
45
- +PI: "PI", // "PI"
46
- +THETA: "THETA", // "THETA"
47
- +UP: "UP", // "UP"
48
- +RIGHT: "RIGHT", // "RIGHT"
49
- +DOWN: "DOWN", // "DOWN"
50
- +LEFT: "LEFT", // "LEFT"
51
- +BACKSPACE: "BACKSPACE", // "BACKSPACE"
52
- +DISMISS: "DISMISS", // "DISMISS"
53
- +JUMP_OUT_PARENTHESES: "JUMP_OUT_PARENTHESES", // "JUMP_OUT_PARENTHESES"
54
- +JUMP_OUT_EXPONENT: "JUMP_OUT_EXPONENT", // "JUMP_OUT_EXPONENT"
55
- +JUMP_OUT_BASE: "JUMP_OUT_BASE", // "JUMP_OUT_BASE"
56
- +JUMP_INTO_NUMERATOR: "JUMP_INTO_NUMERATOR", // "JUMP_INTO_NUMERATOR"
57
- +JUMP_OUT_NUMERATOR: "JUMP_OUT_NUMERATOR", // "JUMP_OUT_NUMERATOR"
58
- +JUMP_OUT_DENOMINATOR: "JUMP_OUT_DENOMINATOR", // "JUMP_OUT_DENOMINATOR"
59
- +NOOP: "NOOP", // "NOOP"
60
- |};
61
- declare export default typeof Keys;
7
+ declare type Key =
8
+ | "PLUS"
9
+ | "MINUS"
10
+ | "NEGATIVE"
11
+ | "TIMES"
12
+ | "DIVIDE"
13
+ | "DECIMAL"
14
+ | "PERIOD"
15
+ | "PERCENT"
16
+ | "CDOT"
17
+ | "EQUAL"
18
+ | "NEQ"
19
+ | "GT"
20
+ | "LT"
21
+ | "GEQ"
22
+ | "LEQ"
23
+ | "FRAC_INCLUSIVE"
24
+ | "FRAC_EXCLUSIVE"
25
+ | "FRAC"
26
+ | "EXP"
27
+ | "EXP_2"
28
+ | "EXP_3"
29
+ | "SQRT"
30
+ | "CUBE_ROOT"
31
+ | "RADICAL"
32
+ | "LEFT_PAREN"
33
+ | "RIGHT_PAREN"
34
+ | "LN"
35
+ | "LOG"
36
+ | "LOG_N"
37
+ | "SIN"
38
+ | "COS"
39
+ | "TAN"
40
+ | "PI"
41
+ | "THETA"
42
+ | "UP"
43
+ | "RIGHT"
44
+ | "DOWN"
45
+ | "LEFT"
46
+ | "BACKSPACE"
47
+ | "DISMISS"
48
+ | "JUMP_OUT_PARENTHESES"
49
+ | "JUMP_OUT_EXPONENT"
50
+ | "JUMP_OUT_BASE"
51
+ | "JUMP_INTO_NUMERATOR"
52
+ | "JUMP_OUT_NUMERATOR"
53
+ | "JUMP_OUT_DENOMINATOR"
54
+ | "NOOP"
55
+ | "MANY"
56
+ | "NUM_0"
57
+ | "NUM_1"
58
+ | "NUM_2"
59
+ | "NUM_3"
60
+ | "NUM_4"
61
+ | "NUM_5"
62
+ | "NUM_6"
63
+ | "NUM_7"
64
+ | "NUM_8"
65
+ | "NUM_9"
66
+ | "a"
67
+ | "b"
68
+ | "c"
69
+ | "d"
70
+ | "e"
71
+ | "f"
72
+ | "g"
73
+ | "h"
74
+ | "i"
75
+ | "j"
76
+ | "k"
77
+ | "l"
78
+ | "m"
79
+ | "n"
80
+ | "o"
81
+ | "p"
82
+ | "q"
83
+ | "r"
84
+ | "s"
85
+ | "t"
86
+ | "u"
87
+ | "v"
88
+ | "w"
89
+ | "x"
90
+ | "y"
91
+ | "z"
92
+ | "A"
93
+ | "B"
94
+ | "C"
95
+ | "D"
96
+ | "E"
97
+ | "F"
98
+ | "G"
99
+ | "H"
100
+ | "I"
101
+ | "J"
102
+ | "K"
103
+ | "L"
104
+ | "M"
105
+ | "N"
106
+ | "O"
107
+ | "P"
108
+ | "Q"
109
+ | "R"
110
+ | "S"
111
+ | "T"
112
+ | "U"
113
+ | "V"
114
+ | "W"
115
+ | "X"
116
+ | "Y"
117
+ | "Z"
118
+ | "PHI"
119
+ | "NTHROOT3"
120
+ | "POW"
121
+ | "LOG_B";
122
+ declare export default typeof Key;
package/dist/enums.d.ts CHANGED
@@ -5,15 +5,8 @@ export declare enum KeypadType {
5
5
  FRACTION = "FRACTION",
6
6
  EXPRESSION = "EXPRESSION"
7
7
  }
8
- export declare enum KeyType {
9
- EMPTY = "EMPTY",
10
- VALUE = "VALUE",
11
- OPERATOR = "OPERATOR",
12
- INPUT_NAVIGATION = "INPUT_NAVIGATION",
13
- KEYPAD_NAVIGATION = "KEYPAD_NAVIGATION",
14
- MANY = "MANY",
15
- ECHO = "ECHO"
16
- }
8
+ export declare const KeyTypes: string[];
9
+ export type KeyType = typeof KeyTypes[number];
17
10
  export declare enum DeviceOrientation {
18
11
  LANDSCAPE = "LANDSCAPE",
19
12
  PORTRAIT = "PORTRAIT"
@@ -12,17 +12,8 @@ declare export var KeypadType: {|
12
12
  +FRACTION: "FRACTION", // "FRACTION"
13
13
  +EXPRESSION: "EXPRESSION", // "EXPRESSION"
14
14
  |};
15
-
16
- declare export var KeyType: {|
17
- +EMPTY: "EMPTY", // "EMPTY"
18
- +VALUE: "VALUE", // "VALUE"
19
- +OPERATOR: "OPERATOR", // "OPERATOR"
20
- +INPUT_NAVIGATION: "INPUT_NAVIGATION", // "INPUT_NAVIGATION"
21
- +KEYPAD_NAVIGATION: "KEYPAD_NAVIGATION", // "KEYPAD_NAVIGATION"
22
- +MANY: "MANY", // "MANY"
23
- +ECHO: "ECHO", // "ECHO"
24
- |};
25
-
15
+ declare export var KeyTypes: string[];
16
+ export type KeyType = $ElementType<typeof KeyTypes, number>;
26
17
  declare export var DeviceOrientation: {|
27
18
  +LANDSCAPE: "LANDSCAPE", // "LANDSCAPE"
28
19
  +PORTRAIT: "PORTRAIT", // "PORTRAIT"