@khanacademy/math-input 17.0.3 → 17.0.5

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 (84) hide show
  1. package/dist/es/index.js +2 -2
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/index.js +2 -2
  4. package/dist/index.js.map +1 -1
  5. package/package.json +5 -2
  6. package/.eslintrc.js +0 -18
  7. package/CHANGELOG.md +0 -654
  8. package/less/main.less +0 -2
  9. package/less/overrides.less +0 -122
  10. package/src/components/__tests__/integration.test.tsx +0 -300
  11. package/src/components/aphrodite-css-transition-group/index.tsx +0 -78
  12. package/src/components/aphrodite-css-transition-group/transition-child.tsx +0 -192
  13. package/src/components/aphrodite-css-transition-group/types.ts +0 -20
  14. package/src/components/aphrodite-css-transition-group/util.ts +0 -97
  15. package/src/components/input/__tests__/context-tracking.test.ts +0 -176
  16. package/src/components/input/__tests__/mathquill-helpers.test.ts +0 -105
  17. package/src/components/input/__tests__/mathquill.test.ts +0 -747
  18. package/src/components/input/__tests__/test-math-wrapper.ts +0 -29
  19. package/src/components/input/cursor-contexts.ts +0 -37
  20. package/src/components/input/cursor-handle.tsx +0 -137
  21. package/src/components/input/cursor-styles.ts +0 -10
  22. package/src/components/input/drag-listener.ts +0 -79
  23. package/src/components/input/math-input.tsx +0 -1036
  24. package/src/components/input/math-wrapper.ts +0 -189
  25. package/src/components/input/mathquill-helpers.ts +0 -262
  26. package/src/components/input/mathquill-instance.ts +0 -106
  27. package/src/components/input/mathquill-types.ts +0 -32
  28. package/src/components/input/scroll-into-view.ts +0 -65
  29. package/src/components/key-handlers/__tests__/handle-jump-out.test.ts +0 -94
  30. package/src/components/key-handlers/handle-arrow.ts +0 -70
  31. package/src/components/key-handlers/handle-backspace.ts +0 -277
  32. package/src/components/key-handlers/handle-exponent.ts +0 -53
  33. package/src/components/key-handlers/handle-jump-out.ts +0 -107
  34. package/src/components/key-handlers/key-translator.ts +0 -222
  35. package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +0 -1913
  36. package/src/components/keypad/__tests__/__snapshots__/mobile-keypad.test.tsx.snap +0 -600
  37. package/src/components/keypad/__tests__/keypad-button.test.tsx +0 -84
  38. package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +0 -304
  39. package/src/components/keypad/__tests__/keypad-v2.cypress.ts +0 -16
  40. package/src/components/keypad/__tests__/keypad.test.tsx +0 -321
  41. package/src/components/keypad/__tests__/mobile-keypad.test.tsx +0 -115
  42. package/src/components/keypad/__tests__/test-data-tabs.ts +0 -21
  43. package/src/components/keypad/button-assets.tsx +0 -1880
  44. package/src/components/keypad/index.tsx +0 -2
  45. package/src/components/keypad/keypad-button.stories.tsx +0 -81
  46. package/src/components/keypad/keypad-button.tsx +0 -124
  47. package/src/components/keypad/keypad-mathquill.stories.tsx +0 -109
  48. package/src/components/keypad/keypad-pages/extras-page.tsx +0 -35
  49. package/src/components/keypad/keypad-pages/fractions-page.tsx +0 -125
  50. package/src/components/keypad/keypad-pages/geometry-page.tsx +0 -34
  51. package/src/components/keypad/keypad-pages/keypad-pages.stories.tsx +0 -37
  52. package/src/components/keypad/keypad-pages/numbers-page.tsx +0 -94
  53. package/src/components/keypad/keypad-pages/operators-page.tsx +0 -117
  54. package/src/components/keypad/keypad.tsx +0 -233
  55. package/src/components/keypad/mobile-keypad-internals.tsx +0 -240
  56. package/src/components/keypad/mobile-keypad.tsx +0 -24
  57. package/src/components/keypad/navigation-button.tsx +0 -127
  58. package/src/components/keypad/navigation-pad.stories.tsx +0 -26
  59. package/src/components/keypad/navigation-pad.tsx +0 -67
  60. package/src/components/keypad/shared-keys.tsx +0 -109
  61. package/src/components/keypad/utils.ts +0 -34
  62. package/src/components/keypad-context.tsx +0 -70
  63. package/src/components/prop-types.ts +0 -16
  64. package/src/components/tabbar/__tests__/tabbar.test.tsx +0 -105
  65. package/src/components/tabbar/icons.tsx +0 -122
  66. package/src/components/tabbar/index.ts +0 -1
  67. package/src/components/tabbar/item.tsx +0 -146
  68. package/src/components/tabbar/tabbar.stories.tsx +0 -83
  69. package/src/components/tabbar/tabbar.tsx +0 -65
  70. package/src/data/key-configs.ts +0 -770
  71. package/src/data/keys.ts +0 -123
  72. package/src/enums.ts +0 -27
  73. package/src/fake-react-native-web/index.ts +0 -11
  74. package/src/fake-react-native-web/text.tsx +0 -55
  75. package/src/fake-react-native-web/view.tsx +0 -91
  76. package/src/full-keypad.stories.tsx +0 -142
  77. package/src/full-mobile-input.stories.tsx +0 -115
  78. package/src/index.ts +0 -52
  79. package/src/types.ts +0 -70
  80. package/src/utils.test.ts +0 -33
  81. package/src/utils.ts +0 -61
  82. package/src/version.ts +0 -10
  83. package/tsconfig-build.json +0 -11
  84. package/tsconfig-build.tsbuildinfo +0 -1
@@ -1,222 +0,0 @@
1
- import {decimalSeparator} from "../../utils";
2
- import {mathQuillInstance} from "../input/mathquill-instance";
3
-
4
- import handleArrow from "./handle-arrow";
5
- import handleExponent from "./handle-exponent";
6
- import handleJumpOut from "./handle-jump-out";
7
-
8
- import type Key from "../../data/keys";
9
- import type {
10
- MathFieldInterface,
11
- MathFieldUpdaterCallback,
12
- } from "../input/mathquill-types";
13
-
14
- enum ActionType {
15
- WRITE = "write",
16
- CMD = "cmd",
17
- KEYSTROKE = "keystroke",
18
- MQ_END = 0,
19
- }
20
-
21
- function buildGenericCallback(
22
- str: string,
23
- type: ActionType = ActionType.WRITE,
24
- ): MathFieldUpdaterCallback {
25
- return function (mathQuill: MathFieldInterface) {
26
- switch (type) {
27
- case ActionType.WRITE: {
28
- mathQuill.write(str);
29
- return;
30
- }
31
- case ActionType.CMD: {
32
- mathQuill.cmd(str);
33
- return;
34
- }
35
- case ActionType.KEYSTROKE: {
36
- mathQuill.keystroke(str);
37
- return;
38
- }
39
- }
40
- };
41
- }
42
-
43
- function buildNormalFunctionCallback(command: string) {
44
- return function (mathField: MathFieldInterface) {
45
- mathField.write(`\\${command}\\left(\\right)`);
46
- mathField.keystroke("Left");
47
- };
48
- }
49
-
50
- const keyToMathquillMap: Record<Key, MathFieldUpdaterCallback> = {
51
- EXP: handleExponent,
52
- EXP_2: handleExponent,
53
- EXP_3: handleExponent,
54
-
55
- JUMP_OUT_PARENTHESES: handleJumpOut,
56
- JUMP_OUT_EXPONENT: handleJumpOut,
57
- JUMP_OUT_BASE: handleJumpOut,
58
- JUMP_INTO_NUMERATOR: handleJumpOut,
59
- JUMP_OUT_NUMERATOR: handleJumpOut,
60
- JUMP_OUT_DENOMINATOR: handleJumpOut,
61
-
62
- LEFT: handleArrow,
63
- RIGHT: handleArrow,
64
-
65
- LOG: buildNormalFunctionCallback("log"),
66
- LN: buildNormalFunctionCallback("ln"),
67
- SIN: buildNormalFunctionCallback("sin"),
68
- COS: buildNormalFunctionCallback("cos"),
69
- TAN: buildNormalFunctionCallback("tan"),
70
-
71
- CDOT: buildGenericCallback("\\cdot"),
72
- DECIMAL: buildGenericCallback(decimalSeparator),
73
- DIVIDE: buildGenericCallback("\\div"),
74
- EQUAL: buildGenericCallback("="),
75
- GEQ: buildGenericCallback("\\geq"),
76
- GT: buildGenericCallback(">"),
77
- LEQ: buildGenericCallback("\\leq"),
78
- LT: buildGenericCallback("<"),
79
- MINUS: buildGenericCallback("-"),
80
- NEGATIVE: buildGenericCallback("-"),
81
- NEQ: buildGenericCallback("\\neq"),
82
- PERCENT: buildGenericCallback("%"),
83
- PERIOD: buildGenericCallback("."),
84
- PLUS: buildGenericCallback("+"),
85
- TIMES: buildGenericCallback("\\times"),
86
-
87
- // The `FRAC_EXCLUSIVE` variant is handled manually, since we may need to do
88
- // some additional navigation depending on the cursor position.
89
- FRAC_INCLUSIVE: buildGenericCallback("/", ActionType.CMD),
90
- FRAC: buildGenericCallback("\\frac", ActionType.CMD),
91
- LEFT_PAREN: buildGenericCallback("(", ActionType.CMD),
92
- RIGHT_PAREN: buildGenericCallback(")", ActionType.CMD),
93
- SQRT: buildGenericCallback("sqrt", ActionType.CMD),
94
- PHI: buildGenericCallback("\\phi", ActionType.CMD),
95
- PI: buildGenericCallback("pi", ActionType.CMD),
96
- THETA: buildGenericCallback("theta", ActionType.CMD),
97
- RADICAL: buildGenericCallback("nthroot", ActionType.CMD),
98
-
99
- BACKSPACE: buildGenericCallback("Backspace", ActionType.KEYSTROKE),
100
- UP: buildGenericCallback("Up", ActionType.KEYSTROKE),
101
- DOWN: buildGenericCallback("Down", ActionType.KEYSTROKE),
102
-
103
- CUBE_ROOT: (mathQuill) => {
104
- mathQuill.write("\\sqrt[3]{}");
105
- mathQuill.keystroke("Left"); // under the root
106
- },
107
-
108
- FRAC_EXCLUSIVE: (mathQuill) => {
109
- const cursor = mathQuill.cursor();
110
- // If there's nothing to the left of the cursor, then we want to
111
- // leave the cursor to the left of the fraction after creating it.
112
- const shouldNavigateLeft =
113
- cursor[mathQuillInstance.L] === ActionType.MQ_END;
114
- mathQuill.cmd("\\frac");
115
- if (shouldNavigateLeft) {
116
- mathQuill.keystroke("Left");
117
- }
118
- },
119
-
120
- LOG_B: (mathQuill) => {
121
- mathQuill.typedText("log_");
122
- mathQuill.keystroke("Right");
123
- mathQuill.typedText("(");
124
- mathQuill.keystroke("Left");
125
- mathQuill.keystroke("Left");
126
- },
127
-
128
- LOG_N: (mathQuill) => {
129
- mathQuill.write("log_{ }\\left(\\right)");
130
- mathQuill.keystroke("Left"); // into parentheses
131
- mathQuill.keystroke("Left"); // out of parentheses
132
- mathQuill.keystroke("Left"); // into index
133
- },
134
-
135
- NTHROOT3: (mathQuill) => {
136
- mathQuill.typedText("nthroot3");
137
- mathQuill.keystroke("Right");
138
- },
139
-
140
- POW: (mathQuill) => {
141
- const contents = mathQuill.latex();
142
- mathQuill.typedText("^");
143
-
144
- // If the input hasn't changed (for example, if we're
145
- // attempting to add an exponent on an empty input or an empty
146
- // denominator), insert our own "a^b"
147
- if (mathQuill.latex() === contents) {
148
- mathQuill.typedText("a^b");
149
- }
150
- },
151
-
152
- // These need to be overwritten by the consumer
153
- // if they're going to be used
154
- DISMISS: () => {},
155
- NOOP: () => {},
156
- MANY: () => {},
157
-
158
- NUM_0: buildGenericCallback("0"),
159
- NUM_1: buildGenericCallback("1"),
160
- NUM_2: buildGenericCallback("2"),
161
- NUM_3: buildGenericCallback("3"),
162
- NUM_4: buildGenericCallback("4"),
163
- NUM_5: buildGenericCallback("5"),
164
- NUM_6: buildGenericCallback("6"),
165
- NUM_7: buildGenericCallback("7"),
166
- NUM_8: buildGenericCallback("8"),
167
- NUM_9: buildGenericCallback("9"),
168
- a: buildGenericCallback("a"),
169
- b: buildGenericCallback("b"),
170
- c: buildGenericCallback("c"),
171
- d: buildGenericCallback("d"),
172
- e: buildGenericCallback("e"),
173
- f: buildGenericCallback("f"),
174
- g: buildGenericCallback("g"),
175
- h: buildGenericCallback("h"),
176
- i: buildGenericCallback("i"),
177
- j: buildGenericCallback("j"),
178
- k: buildGenericCallback("k"),
179
- l: buildGenericCallback("l"),
180
- m: buildGenericCallback("m"),
181
- n: buildGenericCallback("n"),
182
- o: buildGenericCallback("o"),
183
- p: buildGenericCallback("p"),
184
- q: buildGenericCallback("q"),
185
- r: buildGenericCallback("r"),
186
- s: buildGenericCallback("s"),
187
- t: buildGenericCallback("t"),
188
- u: buildGenericCallback("u"),
189
- v: buildGenericCallback("v"),
190
- w: buildGenericCallback("w"),
191
- x: buildGenericCallback("x"),
192
- y: buildGenericCallback("y"),
193
- z: buildGenericCallback("z"),
194
- A: buildGenericCallback("A"),
195
- B: buildGenericCallback("B"),
196
- C: buildGenericCallback("C"),
197
- D: buildGenericCallback("D"),
198
- E: buildGenericCallback("E"),
199
- F: buildGenericCallback("F"),
200
- G: buildGenericCallback("G"),
201
- H: buildGenericCallback("H"),
202
- I: buildGenericCallback("I"),
203
- J: buildGenericCallback("J"),
204
- K: buildGenericCallback("K"),
205
- L: buildGenericCallback("L"),
206
- M: buildGenericCallback("M"),
207
- N: buildGenericCallback("N"),
208
- O: buildGenericCallback("O"),
209
- P: buildGenericCallback("P"),
210
- Q: buildGenericCallback("Q"),
211
- R: buildGenericCallback("R"),
212
- S: buildGenericCallback("S"),
213
- T: buildGenericCallback("T"),
214
- U: buildGenericCallback("U"),
215
- V: buildGenericCallback("V"),
216
- W: buildGenericCallback("W"),
217
- X: buildGenericCallback("X"),
218
- Y: buildGenericCallback("Y"),
219
- Z: buildGenericCallback("Z"),
220
- };
221
-
222
- export default keyToMathquillMap;