@khanacademy/math-input 15.0.1 → 16.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 (140) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/components/aphrodite-css-transition-group/transition-child.d.ts +11 -8
  3. package/dist/components/keypad/index.d.ts +1 -1
  4. package/dist/components/keypad/mobile-keypad-internals.d.ts +49 -0
  5. package/dist/components/keypad/mobile-keypad.d.ts +4 -48
  6. package/dist/es/index.js +168 -4740
  7. package/dist/es/index.js.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js +166 -4722
  10. package/dist/index.js.map +1 -1
  11. package/package.json +10 -9
  12. package/src/components/__tests__/integration.test.tsx +2 -3
  13. package/src/components/keypad/__tests__/mobile-keypad.test.tsx +8 -8
  14. package/src/components/keypad/index.tsx +1 -1
  15. package/src/components/keypad/mobile-keypad-internals.tsx +240 -0
  16. package/src/components/keypad/mobile-keypad.tsx +21 -234
  17. package/src/full-mobile-input.stories.tsx +0 -1
  18. package/src/index.ts +1 -1
  19. package/tsconfig-build.tsbuildinfo +1 -1
  20. package/dist/components/keypad-legacy/compute-layout-parameters.d.ts +0 -28
  21. package/dist/components/keypad-legacy/corner-decal.d.ts +0 -12
  22. package/dist/components/keypad-legacy/echo-manager.d.ts +0 -17
  23. package/dist/components/keypad-legacy/empty-keypad-button.d.ts +0 -13
  24. package/dist/components/keypad-legacy/expression-keypad.d.ts +0 -21
  25. package/dist/components/keypad-legacy/fraction-keypad.d.ts +0 -21
  26. package/dist/components/keypad-legacy/gesture-manager.d.ts +0 -86
  27. package/dist/components/keypad-legacy/gesture-state-machine.d.ts +0 -105
  28. package/dist/components/keypad-legacy/icon.d.ts +0 -15
  29. package/dist/components/keypad-legacy/index.d.ts +0 -1
  30. package/dist/components/keypad-legacy/keypad-button.d.ts +0 -53
  31. package/dist/components/keypad-legacy/keypad-container.d.ts +0 -41
  32. package/dist/components/keypad-legacy/keypad.d.ts +0 -31
  33. package/dist/components/keypad-legacy/many-keypad-button.d.ts +0 -15
  34. package/dist/components/keypad-legacy/math-icon.d.ts +0 -16
  35. package/dist/components/keypad-legacy/multi-symbol-grid.d.ts +0 -14
  36. package/dist/components/keypad-legacy/multi-symbol-popover.d.ts +0 -12
  37. package/dist/components/keypad-legacy/navigation-pad.d.ts +0 -14
  38. package/dist/components/keypad-legacy/node-manager.d.ts +0 -49
  39. package/dist/components/keypad-legacy/popover-manager.d.ts +0 -13
  40. package/dist/components/keypad-legacy/popover-state-machine.d.ts +0 -68
  41. package/dist/components/keypad-legacy/provided-keypad.d.ts +0 -28
  42. package/dist/components/keypad-legacy/store/actions.d.ts +0 -55
  43. package/dist/components/keypad-legacy/store/echo-reducer.d.ts +0 -4
  44. package/dist/components/keypad-legacy/store/index.d.ts +0 -9
  45. package/dist/components/keypad-legacy/store/input-reducer.d.ts +0 -4
  46. package/dist/components/keypad-legacy/store/keypad-reducer.d.ts +0 -4
  47. package/dist/components/keypad-legacy/store/layout-reducer.d.ts +0 -4
  48. package/dist/components/keypad-legacy/store/shared.d.ts +0 -7
  49. package/dist/components/keypad-legacy/store/types.d.ts +0 -47
  50. package/dist/components/keypad-legacy/styles.d.ts +0 -5
  51. package/dist/components/keypad-legacy/svg-icon.d.ts +0 -12
  52. package/dist/components/keypad-legacy/text-icon.d.ts +0 -13
  53. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +0 -37
  54. package/dist/components/keypad-legacy/two-page-keypad.d.ts +0 -21
  55. package/dist/components/keypad-legacy/z-indexes.d.ts +0 -7
  56. package/dist/components/keypad-switch.d.ts +0 -12
  57. package/src/components/keypad-legacy/__tests__/gesture-state-machine.test.ts +0 -441
  58. package/src/components/keypad-legacy/__tests__/node-manager.test.ts +0 -89
  59. package/src/components/keypad-legacy/__tests__/two-page-keypad.test.tsx +0 -38
  60. package/src/components/keypad-legacy/compute-layout-parameters.ts +0 -205
  61. package/src/components/keypad-legacy/corner-decal.tsx +0 -56
  62. package/src/components/keypad-legacy/echo-manager.tsx +0 -152
  63. package/src/components/keypad-legacy/empty-keypad-button.tsx +0 -58
  64. package/src/components/keypad-legacy/expression-keypad.tsx +0 -315
  65. package/src/components/keypad-legacy/fraction-keypad.tsx +0 -180
  66. package/src/components/keypad-legacy/gesture-manager.ts +0 -255
  67. package/src/components/keypad-legacy/gesture-state-machine.ts +0 -329
  68. package/src/components/keypad-legacy/icon.tsx +0 -72
  69. package/src/components/keypad-legacy/iconography/arrow.js +0 -22
  70. package/src/components/keypad-legacy/iconography/backspace.js +0 -29
  71. package/src/components/keypad-legacy/iconography/cdot.js +0 -29
  72. package/src/components/keypad-legacy/iconography/cos.js +0 -30
  73. package/src/components/keypad-legacy/iconography/cube-root.js +0 -36
  74. package/src/components/keypad-legacy/iconography/dismiss.js +0 -25
  75. package/src/components/keypad-legacy/iconography/divide.js +0 -34
  76. package/src/components/keypad-legacy/iconography/down.js +0 -16
  77. package/src/components/keypad-legacy/iconography/equal.js +0 -33
  78. package/src/components/keypad-legacy/iconography/exp-2.js +0 -29
  79. package/src/components/keypad-legacy/iconography/exp-3.js +0 -29
  80. package/src/components/keypad-legacy/iconography/exp.js +0 -29
  81. package/src/components/keypad-legacy/iconography/frac.js +0 -44
  82. package/src/components/keypad-legacy/iconography/geq.js +0 -33
  83. package/src/components/keypad-legacy/iconography/gt.js +0 -33
  84. package/src/components/keypad-legacy/iconography/index.js +0 -45
  85. package/src/components/keypad-legacy/iconography/jump-into-numerator.js +0 -41
  86. package/src/components/keypad-legacy/iconography/jump-out-base.js +0 -30
  87. package/src/components/keypad-legacy/iconography/jump-out-denominator.js +0 -41
  88. package/src/components/keypad-legacy/iconography/jump-out-exponent.js +0 -30
  89. package/src/components/keypad-legacy/iconography/jump-out-numerator.js +0 -41
  90. package/src/components/keypad-legacy/iconography/jump-out-parentheses.js +0 -33
  91. package/src/components/keypad-legacy/iconography/left-paren.js +0 -33
  92. package/src/components/keypad-legacy/iconography/left.js +0 -16
  93. package/src/components/keypad-legacy/iconography/leq.js +0 -33
  94. package/src/components/keypad-legacy/iconography/ln.js +0 -29
  95. package/src/components/keypad-legacy/iconography/log-n.js +0 -29
  96. package/src/components/keypad-legacy/iconography/log.js +0 -29
  97. package/src/components/keypad-legacy/iconography/lt.js +0 -33
  98. package/src/components/keypad-legacy/iconography/minus.js +0 -32
  99. package/src/components/keypad-legacy/iconography/neq.js +0 -33
  100. package/src/components/keypad-legacy/iconography/parens.js +0 -33
  101. package/src/components/keypad-legacy/iconography/percent.js +0 -49
  102. package/src/components/keypad-legacy/iconography/period.js +0 -26
  103. package/src/components/keypad-legacy/iconography/plus.js +0 -32
  104. package/src/components/keypad-legacy/iconography/radical.js +0 -36
  105. package/src/components/keypad-legacy/iconography/right-paren.js +0 -33
  106. package/src/components/keypad-legacy/iconography/right.js +0 -16
  107. package/src/components/keypad-legacy/iconography/sin.js +0 -30
  108. package/src/components/keypad-legacy/iconography/sqrt.js +0 -32
  109. package/src/components/keypad-legacy/iconography/tan.js +0 -30
  110. package/src/components/keypad-legacy/iconography/times.js +0 -33
  111. package/src/components/keypad-legacy/iconography/up.js +0 -16
  112. package/src/components/keypad-legacy/index.ts +0 -1
  113. package/src/components/keypad-legacy/keypad-button.tsx +0 -368
  114. package/src/components/keypad-legacy/keypad-container.tsx +0 -358
  115. package/src/components/keypad-legacy/keypad.tsx +0 -162
  116. package/src/components/keypad-legacy/many-keypad-button.tsx +0 -54
  117. package/src/components/keypad-legacy/math-icon.tsx +0 -66
  118. package/src/components/keypad-legacy/multi-symbol-grid.tsx +0 -182
  119. package/src/components/keypad-legacy/multi-symbol-popover.tsx +0 -58
  120. package/src/components/keypad-legacy/navigation-pad.tsx +0 -140
  121. package/src/components/keypad-legacy/node-manager.ts +0 -133
  122. package/src/components/keypad-legacy/popover-manager.tsx +0 -73
  123. package/src/components/keypad-legacy/popover-state-machine.ts +0 -184
  124. package/src/components/keypad-legacy/provided-keypad.tsx +0 -136
  125. package/src/components/keypad-legacy/store/actions.ts +0 -155
  126. package/src/components/keypad-legacy/store/echo-reducer.ts +0 -57
  127. package/src/components/keypad-legacy/store/index.ts +0 -110
  128. package/src/components/keypad-legacy/store/input-reducer.ts +0 -55
  129. package/src/components/keypad-legacy/store/keypad-reducer.ts +0 -58
  130. package/src/components/keypad-legacy/store/layout-reducer.test.ts +0 -171
  131. package/src/components/keypad-legacy/store/layout-reducer.ts +0 -129
  132. package/src/components/keypad-legacy/store/shared.ts +0 -12
  133. package/src/components/keypad-legacy/store/types.ts +0 -78
  134. package/src/components/keypad-legacy/styles.ts +0 -38
  135. package/src/components/keypad-legacy/svg-icon.tsx +0 -24
  136. package/src/components/keypad-legacy/text-icon.tsx +0 -53
  137. package/src/components/keypad-legacy/touchable-keypad-button.tsx +0 -163
  138. package/src/components/keypad-legacy/two-page-keypad.tsx +0 -115
  139. package/src/components/keypad-legacy/z-indexes.ts +0 -8
  140. package/src/components/keypad-switch.tsx +0 -42
@@ -1,315 +0,0 @@
1
- /**
2
- * A keypad that includes all of the expression symbols.
3
- */
4
-
5
- import {StyleSheet} from "aphrodite";
6
- import * as React from "react";
7
- import {connect} from "react-redux";
8
-
9
- import KeyConfigs from "../../data/key-configs";
10
- import {BorderStyles} from "../../enums";
11
- import {View} from "../../fake-react-native-web/index";
12
- import {valueGrey, controlGrey} from "../common-style";
13
- import {CursorContext} from "../input/cursor-contexts";
14
-
15
- import ManyKeypadButton from "./many-keypad-button";
16
- import Styles from "./styles";
17
- import TouchableKeypadButton from "./touchable-keypad-button";
18
- import TwoPageKeypad from "./two-page-keypad";
19
-
20
- import type {KeypadLayout} from "../../types";
21
- import type {State} from "./store/types";
22
-
23
- const {row, column, oneColumn, fullWidth, roundedTopLeft, roundedTopRight} =
24
- Styles;
25
-
26
- interface ReduxProps {
27
- cursorContext?: typeof CursorContext[keyof typeof CursorContext];
28
- dynamicJumpOut: boolean;
29
- }
30
-
31
- interface Props extends ReduxProps {
32
- extraKeys?: ReadonlyArray<string>;
33
- roundTopLeft: boolean;
34
- roundTopRight: boolean;
35
- }
36
-
37
- export const expressionKeypadLayout: KeypadLayout = {
38
- rows: 4,
39
- columns: 5,
40
- numPages: 2,
41
- // Since we include a two-key popover in the top-right, when the popover
42
- // is visible, the keypad will expand to fill the equivalent of five
43
- // rows vertically.
44
- maxVisibleRows: 4,
45
- };
46
-
47
- class ExpressionKeypad extends React.Component<Props> {
48
- render() {
49
- const {
50
- cursorContext,
51
- dynamicJumpOut,
52
- extraKeys,
53
- roundTopLeft,
54
- roundTopRight,
55
- } = this.props;
56
-
57
- let dismissOrJumpOutKey;
58
- if (dynamicJumpOut) {
59
- switch (cursorContext) {
60
- case CursorContext.IN_PARENS:
61
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
62
- break;
63
-
64
- case CursorContext.IN_SUPER_SCRIPT:
65
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
66
- break;
67
-
68
- case CursorContext.IN_SUB_SCRIPT:
69
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
70
- break;
71
-
72
- case CursorContext.BEFORE_FRACTION:
73
- dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
74
- break;
75
-
76
- case CursorContext.IN_NUMERATOR:
77
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
78
- break;
79
-
80
- case CursorContext.IN_DENOMINATOR:
81
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
82
- break;
83
-
84
- case CursorContext.NONE:
85
- default:
86
- dismissOrJumpOutKey = KeyConfigs.DISMISS;
87
- break;
88
- }
89
- } else {
90
- dismissOrJumpOutKey = KeyConfigs.DISMISS;
91
- }
92
-
93
- const rightPageStyle = [
94
- row,
95
- fullWidth,
96
- styles.rightPage,
97
- roundTopRight && roundedTopRight,
98
- ];
99
- const rightPage = (
100
- <View style={rightPageStyle}>
101
- <View style={[column, oneColumn]}>
102
- <TouchableKeypadButton
103
- keyConfig={KeyConfigs.NUM_7}
104
- borders={BorderStyles.NONE}
105
- />
106
- <TouchableKeypadButton
107
- keyConfig={KeyConfigs.NUM_4}
108
- borders={BorderStyles.NONE}
109
- />
110
- <TouchableKeypadButton
111
- keyConfig={KeyConfigs.NUM_1}
112
- borders={BorderStyles.BOTTOM}
113
- />
114
- <ManyKeypadButton keys={extraKeys} />
115
- </View>
116
- <View style={[column, oneColumn]}>
117
- <TouchableKeypadButton
118
- keyConfig={KeyConfigs.NUM_8}
119
- borders={BorderStyles.NONE}
120
- />
121
- <TouchableKeypadButton
122
- keyConfig={KeyConfigs.NUM_5}
123
- borders={BorderStyles.NONE}
124
- />
125
- <TouchableKeypadButton
126
- keyConfig={KeyConfigs.NUM_2}
127
- borders={BorderStyles.NONE}
128
- />
129
- <TouchableKeypadButton
130
- keyConfig={KeyConfigs.NUM_0}
131
- borders={BorderStyles.LEFT}
132
- />
133
- </View>
134
- <View style={[column, oneColumn]}>
135
- <TouchableKeypadButton
136
- keyConfig={KeyConfigs.NUM_9}
137
- borders={BorderStyles.NONE}
138
- />
139
- <TouchableKeypadButton
140
- keyConfig={KeyConfigs.NUM_6}
141
- borders={BorderStyles.NONE}
142
- />
143
- <TouchableKeypadButton
144
- keyConfig={KeyConfigs.NUM_3}
145
- borders={BorderStyles.BOTTOM}
146
- />
147
- <TouchableKeypadButton
148
- keyConfig={KeyConfigs.DECIMAL}
149
- borders={BorderStyles.LEFT}
150
- />
151
- </View>
152
- <View style={[column, oneColumn]}>
153
- <TouchableKeypadButton
154
- keyConfig={KeyConfigs.DIVIDE}
155
- borders={BorderStyles.LEFT}
156
- />
157
- <TouchableKeypadButton
158
- keyConfig={KeyConfigs.TIMES}
159
- borders={BorderStyles.LEFT}
160
- />
161
- <TouchableKeypadButton
162
- keyConfig={KeyConfigs.MINUS}
163
- borders={BorderStyles.LEFT}
164
- />
165
- <TouchableKeypadButton
166
- keyConfig={KeyConfigs.PLUS}
167
- borders={BorderStyles.LEFT}
168
- />
169
- </View>
170
- <View style={[column, oneColumn]}>
171
- <TouchableKeypadButton
172
- keyConfig={KeyConfigs.FRAC}
173
- style={roundTopRight && roundedTopRight}
174
- />
175
- <TouchableKeypadButton keyConfig={KeyConfigs.CDOT} />
176
- <TouchableKeypadButton
177
- keyConfig={KeyConfigs.BACKSPACE}
178
- borders={BorderStyles.LEFT}
179
- />
180
- <TouchableKeypadButton
181
- keyConfig={dismissOrJumpOutKey}
182
- borders={BorderStyles.LEFT}
183
- />
184
- </View>
185
- </View>
186
- );
187
-
188
- const leftPageStyle = [
189
- row,
190
- fullWidth,
191
- styles.leftPage,
192
- roundTopLeft && roundedTopLeft,
193
- ];
194
- const leftPage = (
195
- <View style={leftPageStyle}>
196
- <View style={[column, oneColumn]}>
197
- <TouchableKeypadButton
198
- keyConfig={KeyConfigs.EXP_2}
199
- borders={BorderStyles.NONE}
200
- style={roundTopLeft && roundedTopLeft}
201
- />
202
- <TouchableKeypadButton
203
- keyConfig={KeyConfigs.SQRT}
204
- borders={BorderStyles.NONE}
205
- />
206
- <TouchableKeypadButton
207
- keyConfig={KeyConfigs.LOG}
208
- borders={BorderStyles.BOTTOM}
209
- />
210
- <TouchableKeypadButton
211
- keyConfig={KeyConfigs.SIN}
212
- borders={BorderStyles.NONE}
213
- />
214
- </View>
215
- <View style={[column, oneColumn]}>
216
- <TouchableKeypadButton
217
- keyConfig={KeyConfigs.EXP_3}
218
- borders={BorderStyles.NONE}
219
- />
220
- <TouchableKeypadButton
221
- keyConfig={KeyConfigs.CUBE_ROOT}
222
- borders={BorderStyles.NONE}
223
- />
224
- <TouchableKeypadButton
225
- keyConfig={KeyConfigs.LN}
226
- borders={BorderStyles.BOTTOM}
227
- />
228
- <TouchableKeypadButton
229
- keyConfig={KeyConfigs.COS}
230
- borders={BorderStyles.NONE}
231
- />
232
- </View>
233
- <View style={[column, oneColumn]}>
234
- <TouchableKeypadButton
235
- keyConfig={KeyConfigs.EXP}
236
- borders={BorderStyles.NONE}
237
- />
238
- <TouchableKeypadButton
239
- keyConfig={KeyConfigs.RADICAL}
240
- borders={BorderStyles.NONE}
241
- />
242
- <TouchableKeypadButton
243
- keyConfig={KeyConfigs.LOG_N}
244
- borders={BorderStyles.BOTTOM}
245
- />
246
- <TouchableKeypadButton
247
- keyConfig={KeyConfigs.TAN}
248
- borders={BorderStyles.NONE}
249
- />
250
- </View>
251
- <View style={[column, oneColumn]}>
252
- <TouchableKeypadButton
253
- keyConfig={KeyConfigs.GEQ}
254
- borders={BorderStyles.LEFT}
255
- />
256
- <TouchableKeypadButton
257
- keyConfig={KeyConfigs.EQUAL}
258
- borders={BorderStyles.LEFT}
259
- />
260
- <TouchableKeypadButton keyConfig={KeyConfigs.LEQ} />
261
- <TouchableKeypadButton
262
- keyConfig={KeyConfigs.LEFT_PAREN}
263
- borders={BorderStyles.LEFT}
264
- />
265
- </View>
266
- <View style={[column, oneColumn]}>
267
- <TouchableKeypadButton
268
- keyConfig={KeyConfigs.GT}
269
- borders={BorderStyles.NONE}
270
- />
271
- <TouchableKeypadButton
272
- keyConfig={KeyConfigs.NEQ}
273
- borders={BorderStyles.NONE}
274
- />
275
- <TouchableKeypadButton
276
- keyConfig={KeyConfigs.LT}
277
- borders={BorderStyles.BOTTOM}
278
- />
279
- <TouchableKeypadButton
280
- keyConfig={KeyConfigs.RIGHT_PAREN}
281
- borders={BorderStyles.NONE}
282
- />
283
- </View>
284
- </View>
285
- );
286
-
287
- return <TwoPageKeypad rightPage={rightPage} leftPage={leftPage} />;
288
- }
289
- }
290
-
291
- const styles = StyleSheet.create({
292
- // NOTE(charlie): These backgrounds are applied to as to fill in some
293
- // unfortunate 'cracks' in the layout. However, not all keys in the first
294
- // page use this background color (namely, the 'command' keys, backspace and
295
- // dismiss).
296
- // TODO(charlie): Apply the proper background between the 'command' keys.
297
- rightPage: {
298
- backgroundColor: valueGrey,
299
- },
300
-
301
- leftPage: {
302
- backgroundColor: controlGrey,
303
- },
304
- });
305
-
306
- const mapStateToProps = (state: State): ReduxProps => {
307
- return {
308
- cursorContext: state.input.cursor?.context,
309
- dynamicJumpOut: !state.layout.navigationPadEnabled,
310
- };
311
- };
312
-
313
- export default connect(mapStateToProps, null, null, {forwardRef: true})(
314
- ExpressionKeypad,
315
- );
@@ -1,180 +0,0 @@
1
- /**
2
- * A keypad that includes the digits, as well as the symbols required to deal
3
- * with fractions, decimals, and percents.
4
- */
5
-
6
- import * as React from "react";
7
- import {connect} from "react-redux";
8
-
9
- import KeyConfigs from "../../data/key-configs";
10
- import {BorderStyles} from "../../enums";
11
- import {View} from "../../fake-react-native-web/index";
12
- import {CursorContext} from "../input/cursor-contexts";
13
-
14
- import Keypad from "./keypad";
15
- import Styles from "./styles";
16
- import TouchableKeypadButton from "./touchable-keypad-button";
17
-
18
- import type {KeypadLayout} from "../../types";
19
- import type {State} from "./store/types";
20
-
21
- const {row, roundedTopLeft, roundedTopRight} = Styles;
22
-
23
- interface ReduxProps {
24
- cursorContext?: typeof CursorContext[keyof typeof CursorContext];
25
- dynamicJumpOut: boolean;
26
- }
27
-
28
- interface Props extends ReduxProps {
29
- roundTopLeft: boolean;
30
- roundTopRight: boolean;
31
- }
32
-
33
- export const fractionKeypadLayout: KeypadLayout = {
34
- rows: 4,
35
- columns: 4,
36
- numPages: 1,
37
- // Since we include a two-key popover in the top-right, when the popover
38
- // is visible, the keypad will expand to fill the equivalent of five
39
- // rows vertically.
40
- maxVisibleRows: 5,
41
- };
42
-
43
- class FractionKeypad extends React.Component<Props> {
44
- render() {
45
- const {cursorContext, dynamicJumpOut, roundTopLeft, roundTopRight} =
46
- this.props;
47
-
48
- let dismissOrJumpOutKey;
49
- if (dynamicJumpOut) {
50
- switch (cursorContext) {
51
- case CursorContext.IN_PARENS:
52
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
53
- break;
54
-
55
- case CursorContext.IN_SUPER_SCRIPT:
56
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
57
- break;
58
-
59
- case CursorContext.IN_SUB_SCRIPT:
60
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
61
- break;
62
-
63
- case CursorContext.BEFORE_FRACTION:
64
- dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
65
- break;
66
-
67
- case CursorContext.IN_NUMERATOR:
68
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
69
- break;
70
-
71
- case CursorContext.IN_DENOMINATOR:
72
- dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
73
- break;
74
-
75
- case CursorContext.NONE:
76
- default:
77
- dismissOrJumpOutKey = KeyConfigs.DISMISS;
78
- break;
79
- }
80
- } else {
81
- dismissOrJumpOutKey = KeyConfigs.DISMISS;
82
- }
83
-
84
- return (
85
- <Keypad>
86
- <View style={row}>
87
- <TouchableKeypadButton
88
- keyConfig={KeyConfigs.NUM_7}
89
- borders={BorderStyles.NONE}
90
- style={roundTopLeft && roundedTopLeft}
91
- />
92
- <TouchableKeypadButton
93
- keyConfig={KeyConfigs.NUM_8}
94
- borders={BorderStyles.NONE}
95
- />
96
- <TouchableKeypadButton
97
- keyConfig={KeyConfigs.NUM_9}
98
- borders={BorderStyles.NONE}
99
- />
100
- <TouchableKeypadButton
101
- keyConfig={KeyConfigs.FRAC}
102
- disabled={
103
- // NOTE(charlie): It's only sufficient to use
104
- // `IN_NUMERATOR` and `IN_DENOMINATOR` here because we
105
- // don't support parentheses in this keypad. If we did,
106
- // then when the cursor was inside a parenthetical
107
- // expression in a numerator or denominator, this check
108
- // would fail.
109
- cursorContext === CursorContext.IN_NUMERATOR ||
110
- cursorContext === CursorContext.IN_DENOMINATOR
111
- }
112
- style={roundTopRight && roundedTopRight}
113
- />
114
- </View>
115
- <View style={row}>
116
- <TouchableKeypadButton
117
- keyConfig={KeyConfigs.NUM_4}
118
- borders={BorderStyles.NONE}
119
- />
120
- <TouchableKeypadButton
121
- keyConfig={KeyConfigs.NUM_5}
122
- borders={BorderStyles.NONE}
123
- />
124
- <TouchableKeypadButton
125
- keyConfig={KeyConfigs.NUM_6}
126
- borders={BorderStyles.NONE}
127
- />
128
- <TouchableKeypadButton keyConfig={KeyConfigs.PERCENT} />
129
- </View>
130
- <View style={row}>
131
- <TouchableKeypadButton
132
- keyConfig={KeyConfigs.NUM_1}
133
- borders={BorderStyles.BOTTOM}
134
- />
135
- <TouchableKeypadButton
136
- keyConfig={KeyConfigs.NUM_2}
137
- borders={BorderStyles.NONE}
138
- />
139
- <TouchableKeypadButton
140
- keyConfig={KeyConfigs.NUM_3}
141
- borders={BorderStyles.BOTTOM}
142
- />
143
- <TouchableKeypadButton
144
- keyConfig={KeyConfigs.BACKSPACE}
145
- borders={BorderStyles.LEFT}
146
- />
147
- </View>
148
- <View style={row}>
149
- <TouchableKeypadButton
150
- keyConfig={KeyConfigs.NEGATIVE}
151
- borders={BorderStyles.NONE}
152
- />
153
- <TouchableKeypadButton
154
- keyConfig={KeyConfigs.NUM_0}
155
- borders={BorderStyles.LEFT}
156
- />
157
- <TouchableKeypadButton
158
- keyConfig={KeyConfigs.DECIMAL}
159
- borders={BorderStyles.LEFT}
160
- />
161
- <TouchableKeypadButton
162
- keyConfig={dismissOrJumpOutKey}
163
- borders={BorderStyles.LEFT}
164
- />
165
- </View>
166
- </Keypad>
167
- );
168
- }
169
- }
170
-
171
- const mapStateToProps = (state: State): ReduxProps => {
172
- return {
173
- cursorContext: state.input.cursor?.context,
174
- dynamicJumpOut: !state.layout.navigationPadEnabled,
175
- };
176
- };
177
-
178
- export default connect(mapStateToProps, null, null, {forwardRef: true})(
179
- FractionKeypad,
180
- );