@khanacademy/math-input 17.0.4 → 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 (82) hide show
  1. package/dist/es/index.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/package.json +5 -2
  4. package/.eslintrc.js +0 -18
  5. package/CHANGELOG.md +0 -660
  6. package/less/main.less +0 -2
  7. package/less/overrides.less +0 -122
  8. package/src/components/__tests__/integration.test.tsx +0 -300
  9. package/src/components/aphrodite-css-transition-group/index.tsx +0 -78
  10. package/src/components/aphrodite-css-transition-group/transition-child.tsx +0 -192
  11. package/src/components/aphrodite-css-transition-group/types.ts +0 -20
  12. package/src/components/aphrodite-css-transition-group/util.ts +0 -97
  13. package/src/components/input/__tests__/context-tracking.test.ts +0 -176
  14. package/src/components/input/__tests__/mathquill-helpers.test.ts +0 -105
  15. package/src/components/input/__tests__/mathquill.test.ts +0 -747
  16. package/src/components/input/__tests__/test-math-wrapper.ts +0 -29
  17. package/src/components/input/cursor-contexts.ts +0 -37
  18. package/src/components/input/cursor-handle.tsx +0 -137
  19. package/src/components/input/cursor-styles.ts +0 -10
  20. package/src/components/input/drag-listener.ts +0 -79
  21. package/src/components/input/math-input.tsx +0 -1036
  22. package/src/components/input/math-wrapper.ts +0 -189
  23. package/src/components/input/mathquill-helpers.ts +0 -262
  24. package/src/components/input/mathquill-instance.ts +0 -106
  25. package/src/components/input/mathquill-types.ts +0 -32
  26. package/src/components/input/scroll-into-view.ts +0 -65
  27. package/src/components/key-handlers/__tests__/handle-jump-out.test.ts +0 -94
  28. package/src/components/key-handlers/handle-arrow.ts +0 -70
  29. package/src/components/key-handlers/handle-backspace.ts +0 -277
  30. package/src/components/key-handlers/handle-exponent.ts +0 -53
  31. package/src/components/key-handlers/handle-jump-out.ts +0 -107
  32. package/src/components/key-handlers/key-translator.ts +0 -222
  33. package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +0 -1913
  34. package/src/components/keypad/__tests__/__snapshots__/mobile-keypad.test.tsx.snap +0 -600
  35. package/src/components/keypad/__tests__/keypad-button.test.tsx +0 -84
  36. package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +0 -304
  37. package/src/components/keypad/__tests__/keypad-v2.cypress.ts +0 -16
  38. package/src/components/keypad/__tests__/keypad.test.tsx +0 -321
  39. package/src/components/keypad/__tests__/mobile-keypad.test.tsx +0 -115
  40. package/src/components/keypad/__tests__/test-data-tabs.ts +0 -21
  41. package/src/components/keypad/button-assets.tsx +0 -1880
  42. package/src/components/keypad/index.tsx +0 -2
  43. package/src/components/keypad/keypad-button.stories.tsx +0 -81
  44. package/src/components/keypad/keypad-button.tsx +0 -124
  45. package/src/components/keypad/keypad-mathquill.stories.tsx +0 -109
  46. package/src/components/keypad/keypad-pages/extras-page.tsx +0 -35
  47. package/src/components/keypad/keypad-pages/fractions-page.tsx +0 -125
  48. package/src/components/keypad/keypad-pages/geometry-page.tsx +0 -34
  49. package/src/components/keypad/keypad-pages/keypad-pages.stories.tsx +0 -37
  50. package/src/components/keypad/keypad-pages/numbers-page.tsx +0 -94
  51. package/src/components/keypad/keypad-pages/operators-page.tsx +0 -117
  52. package/src/components/keypad/keypad.tsx +0 -233
  53. package/src/components/keypad/mobile-keypad-internals.tsx +0 -240
  54. package/src/components/keypad/mobile-keypad.tsx +0 -24
  55. package/src/components/keypad/navigation-button.tsx +0 -127
  56. package/src/components/keypad/navigation-pad.stories.tsx +0 -26
  57. package/src/components/keypad/navigation-pad.tsx +0 -67
  58. package/src/components/keypad/shared-keys.tsx +0 -109
  59. package/src/components/keypad/utils.ts +0 -34
  60. package/src/components/keypad-context.tsx +0 -70
  61. package/src/components/prop-types.ts +0 -16
  62. package/src/components/tabbar/__tests__/tabbar.test.tsx +0 -105
  63. package/src/components/tabbar/icons.tsx +0 -122
  64. package/src/components/tabbar/index.ts +0 -1
  65. package/src/components/tabbar/item.tsx +0 -146
  66. package/src/components/tabbar/tabbar.stories.tsx +0 -83
  67. package/src/components/tabbar/tabbar.tsx +0 -65
  68. package/src/data/key-configs.ts +0 -770
  69. package/src/data/keys.ts +0 -123
  70. package/src/enums.ts +0 -27
  71. package/src/fake-react-native-web/index.ts +0 -11
  72. package/src/fake-react-native-web/text.tsx +0 -55
  73. package/src/fake-react-native-web/view.tsx +0 -91
  74. package/src/full-keypad.stories.tsx +0 -142
  75. package/src/full-mobile-input.stories.tsx +0 -115
  76. package/src/index.ts +0 -52
  77. package/src/types.ts +0 -70
  78. package/src/utils.test.ts +0 -33
  79. package/src/utils.ts +0 -61
  80. package/src/version.ts +0 -10
  81. package/tsconfig-build.json +0 -11
  82. 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;