@khanacademy/math-input 2.0.0 → 4.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.
- package/CHANGELOG.md +55 -0
- package/dist/components/input/__tests__/test-math-wrapper.d.ts +1 -1
- package/dist/components/input/__tests__/test-math-wrapper.js.flow +1 -1
- package/dist/components/input/key-handlers/handle-arrow.d.ts +3 -0
- package/dist/components/input/key-handlers/handle-arrow.js.flow +12 -0
- package/dist/components/input/key-handlers/handle-backspace.d.ts +7 -0
- package/dist/components/input/key-handlers/handle-backspace.js.flow +14 -0
- package/dist/components/input/key-handlers/handle-exponent.d.ts +3 -0
- package/dist/components/input/key-handlers/handle-exponent.js.flow +12 -0
- package/dist/components/input/key-handlers/handle-jump-out.d.ts +7 -0
- package/dist/components/input/key-handlers/handle-jump-out.js.flow +14 -0
- package/dist/components/input/math-input.d.ts +1 -1
- package/dist/components/input/math-input.js.flow +1 -1
- package/dist/components/input/math-wrapper.d.ts +7 -78
- package/dist/components/input/math-wrapper.js.flow +16 -78
- package/dist/components/input/mathquill-helpers.d.ts +46 -0
- package/dist/components/input/mathquill-helpers.js.flow +56 -0
- package/dist/components/input/mathquill-instance.d.ts +3 -0
- package/dist/components/input/mathquill-instance.js.flow +9 -0
- package/dist/components/input/mathquill-types.d.ts +25 -0
- package/dist/components/input/mathquill-types.js.flow +34 -0
- package/dist/components/key-translator.d.ts +4 -0
- package/dist/components/key-translator.js.flow +10 -0
- package/dist/components/keypad/button-assets.d.ts +2 -2
- package/dist/components/keypad/button-assets.js.flow +2 -2
- package/dist/components/keypad/button.d.ts +1 -2
- package/dist/components/keypad/button.js.flow +1 -1
- package/dist/components/keypad/{pre-algebra-page.d.ts → geometry-page/index.d.ts} +1 -1
- package/dist/components/keypad/{pre-algebra-page.js.flow → geometry-page/index.js.flow} +1 -1
- package/dist/components/keypad/index.d.ts +5 -4
- package/dist/components/keypad/index.js.flow +9 -4
- package/dist/components/keypad/keypad-page-items.d.ts +9 -3
- package/dist/components/keypad/keypad-page-items.js.flow +9 -3
- package/dist/components/keypad/{numeric-input-page.d.ts → numbers-page/index.d.ts} +3 -2
- package/dist/components/keypad/numbers-page/index.js.flow +17 -0
- package/dist/components/keypad/numbers-page/types.d.ts +4 -0
- package/dist/components/keypad/numbers-page/types.js.flow +10 -0
- package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +7 -0
- package/dist/components/keypad/{numeric-input-page.js.flow → operators-page/advanced-relations-buttons.js.flow} +3 -4
- package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +7 -0
- package/dist/components/keypad/{trigonometry-page.js.flow → operators-page/basic-relations-buttons.js.flow} +3 -6
- package/dist/components/keypad/operators-page/index.d.ts +9 -0
- package/dist/components/keypad/operators-page/index.js.flow +17 -0
- package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +7 -0
- package/dist/components/keypad/operators-page/logarithms-buttons.js.flow +12 -0
- package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +7 -0
- package/dist/components/keypad/operators-page/pre-algebra-buttons.js.flow +12 -0
- package/dist/components/keypad/operators-page/types.d.ts +6 -0
- package/dist/components/keypad/operators-page/types.js.flow +12 -0
- package/dist/components/{compute-layout-parameters.d.ts → keypad-legacy/compute-layout-parameters.d.ts} +1 -1
- package/dist/components/{compute-layout-parameters.js.flow → keypad-legacy/compute-layout-parameters.js.flow} +1 -1
- package/dist/components/{echo-manager.d.ts → keypad-legacy/echo-manager.d.ts} +2 -11
- package/dist/components/{echo-manager.js.flow → keypad-legacy/echo-manager.js.flow} +2 -11
- package/dist/components/{expression-keypad.d.ts → keypad-legacy/expression-keypad.d.ts} +3 -4
- package/dist/components/{expression-keypad.js.flow → keypad-legacy/expression-keypad.js.flow} +3 -4
- package/dist/components/{fraction-keypad.d.ts → keypad-legacy/fraction-keypad.d.ts} +2 -2
- package/dist/components/{fraction-keypad.js.flow → keypad-legacy/fraction-keypad.js.flow} +2 -2
- package/dist/components/{gesture-manager.d.ts → keypad-legacy/gesture-manager.d.ts} +22 -10
- package/dist/components/{gesture-manager.js.flow → keypad-legacy/gesture-manager.js.flow} +28 -13
- package/dist/components/{gesture-state-machine.d.ts → keypad-legacy/gesture-state-machine.d.ts} +9 -9
- package/dist/components/{gesture-state-machine.js.flow → keypad-legacy/gesture-state-machine.js.flow} +10 -10
- package/dist/components/{icon.d.ts → keypad-legacy/icon.d.ts} +1 -1
- package/dist/components/{icon.js.flow → keypad-legacy/icon.js.flow} +1 -1
- package/dist/components/{keypad-button.d.ts → keypad-legacy/keypad-button.d.ts} +6 -6
- package/dist/components/{keypad-button.js.flow → keypad-legacy/keypad-button.js.flow} +7 -7
- package/dist/components/{keypad-container.d.ts → keypad-legacy/keypad-container.d.ts} +2 -2
- package/dist/components/{keypad-container.js.flow → keypad-legacy/keypad-container.js.flow} +3 -3
- package/dist/components/{keypad.d.ts → keypad-legacy/keypad.d.ts} +3 -3
- package/dist/components/{keypad.js.flow → keypad-legacy/keypad.js.flow} +3 -3
- package/dist/components/{multi-symbol-grid.d.ts → keypad-legacy/multi-symbol-grid.d.ts} +1 -1
- package/dist/components/{multi-symbol-grid.js.flow → keypad-legacy/multi-symbol-grid.js.flow} +1 -1
- package/dist/components/{multi-symbol-popover.d.ts → keypad-legacy/multi-symbol-popover.d.ts} +1 -1
- package/dist/components/{multi-symbol-popover.js.flow → keypad-legacy/multi-symbol-popover.js.flow} +1 -1
- package/dist/components/{node-manager.d.ts → keypad-legacy/node-manager.d.ts} +3 -4
- package/dist/components/{node-manager.js.flow → keypad-legacy/node-manager.js.flow} +3 -5
- package/dist/components/{popover-manager.d.ts → keypad-legacy/popover-manager.d.ts} +1 -1
- package/dist/components/{popover-manager.js.flow → keypad-legacy/popover-manager.js.flow} +1 -1
- package/dist/components/{popover-state-machine.d.ts → keypad-legacy/popover-state-machine.d.ts} +1 -1
- package/dist/components/{popover-state-machine.js.flow → keypad-legacy/popover-state-machine.js.flow} +1 -1
- package/dist/components/{provided-keypad.d.ts → keypad-legacy/provided-keypad.d.ts} +1 -1
- package/dist/components/{provided-keypad.js.flow → keypad-legacy/provided-keypad.js.flow} +1 -1
- package/dist/{store → components/keypad-legacy/store}/actions.d.ts +6 -17
- package/dist/{store → components/keypad-legacy/store}/actions.js.flow +7 -22
- package/dist/{store → components/keypad-legacy/store}/index.d.ts +0 -1
- package/dist/{store → components/keypad-legacy/store}/index.js.flow +0 -1
- package/dist/components/keypad-legacy/store/shared.d.ts +7 -0
- package/dist/components/keypad-legacy/store/shared.js.flow +14 -0
- package/dist/{store → components/keypad-legacy/store}/types.d.ts +5 -15
- package/dist/{store → components/keypad-legacy/store}/types.js.flow +5 -15
- package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +37 -0
- package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +59 -0
- package/dist/components/{two-page-keypad.d.ts → keypad-legacy/two-page-keypad.d.ts} +0 -1
- package/dist/components/{two-page-keypad.js.flow → keypad-legacy/two-page-keypad.js.flow} +0 -1
- package/dist/data/key-configs.d.ts +4 -5
- package/dist/data/key-configs.js.flow +3 -6
- package/dist/data/keys.d.ts +2 -56
- package/dist/data/keys.js.flow +116 -57
- package/dist/enums.d.ts +2 -9
- package/dist/enums.js.flow +2 -11
- package/dist/es/index.js +6393 -5116
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +6868 -5330
- package/dist/index.js.flow +6 -3
- package/dist/index.js.map +1 -1
- package/dist/strings.js +26 -10
- package/dist/types.d.ts +19 -17
- package/dist/types.js.flow +28 -23
- package/package.json +1 -1
- package/src/components/input/__tests__/context-tracking.test.ts +43 -44
- package/src/components/input/__tests__/mathquill.test.ts +133 -135
- package/src/components/input/key-handlers/handle-arrow.ts +70 -0
- package/src/components/input/key-handlers/handle-backspace.ts +275 -0
- package/src/components/input/key-handlers/handle-exponent.ts +52 -0
- package/src/components/input/key-handlers/handle-jump-out.ts +103 -0
- package/src/components/input/math-input.tsx +12 -13
- package/src/components/input/math-wrapper.ts +88 -837
- package/src/components/input/mathquill-helpers.ts +268 -0
- package/src/components/input/mathquill-instance.ts +5 -0
- package/src/components/input/mathquill-types.ts +55 -0
- package/src/components/key-translator.ts +209 -0
- package/src/components/keypad/button-assets.tsx +452 -116
- package/src/components/keypad/button.stories.tsx +61 -13
- package/src/components/keypad/button.tsx +1 -1
- package/src/components/keypad/{trigonometry-page.tsx → geometry-page/index.tsx} +4 -5
- package/src/components/keypad/index.tsx +19 -14
- package/src/components/keypad/keypad-mathquill.stories.tsx +69 -0
- package/src/components/keypad/keypad-page-items.tsx +36 -22
- package/src/components/keypad/keypad-pages.stories.tsx +5 -5
- package/src/components/keypad/keypad.stories.tsx +75 -17
- package/src/components/keypad/{numeric-input-page.tsx → numbers-page/index.tsx} +47 -11
- package/src/components/keypad/numbers-page/types.ts +4 -0
- package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +32 -0
- package/src/components/keypad/operators-page/basic-relations-buttons.tsx +32 -0
- package/src/components/keypad/{pre-algebra-page.tsx → operators-page/index.tsx} +26 -30
- package/src/components/keypad/operators-page/logarithms-buttons.tsx +32 -0
- package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +36 -0
- package/src/components/keypad/operators-page/types.ts +6 -0
- package/src/components/{__tests__ → keypad-legacy/__tests__}/two-page-keypad.test.tsx +0 -2
- package/src/components/{compute-layout-parameters.ts → keypad-legacy/compute-layout-parameters.ts} +2 -3
- package/src/components/{corner-decal.tsx → keypad-legacy/corner-decal.tsx} +2 -3
- package/src/components/{echo-manager.tsx → keypad-legacy/echo-manager.tsx} +8 -21
- package/src/components/{empty-keypad-button.tsx → keypad-legacy/empty-keypad-button.tsx} +8 -6
- package/src/components/{expression-keypad.tsx → keypad-legacy/expression-keypad.tsx} +8 -17
- package/src/components/{fraction-keypad.tsx → keypad-legacy/fraction-keypad.tsx} +6 -6
- package/src/components/{gesture-manager.ts → keypad-legacy/gesture-manager.ts} +34 -11
- package/src/components/{gesture-state-machine.ts → keypad-legacy/gesture-state-machine.ts} +14 -14
- package/src/components/{icon.tsx → keypad-legacy/icon.tsx} +3 -3
- package/src/components/{keypad-button.tsx → keypad-legacy/keypad-button.tsx} +26 -26
- package/src/components/{keypad-container.tsx → keypad-legacy/keypad-container.tsx} +6 -6
- package/src/components/{keypad.tsx → keypad-legacy/keypad.tsx} +5 -5
- package/src/components/{many-keypad-button.tsx → keypad-legacy/many-keypad-button.tsx} +13 -6
- package/src/components/{math-icon.tsx → keypad-legacy/math-icon.tsx} +2 -2
- package/src/components/{multi-symbol-grid.tsx → keypad-legacy/multi-symbol-grid.tsx} +4 -4
- package/src/components/{multi-symbol-popover.tsx → keypad-legacy/multi-symbol-popover.tsx} +3 -4
- package/src/components/{navigation-pad.tsx → keypad-legacy/navigation-pad.tsx} +5 -5
- package/src/components/{node-manager.ts → keypad-legacy/node-manager.ts} +2 -10
- package/src/components/{popover-manager.tsx → keypad-legacy/popover-manager.tsx} +2 -2
- package/src/components/{popover-state-machine.ts → keypad-legacy/popover-state-machine.ts} +1 -1
- package/src/components/{provided-keypad.tsx → keypad-legacy/provided-keypad.tsx} +4 -5
- package/src/{store → components/keypad-legacy/store}/actions.ts +7 -36
- package/src/{store → components/keypad-legacy/store}/echo-reducer.ts +3 -7
- package/src/{store → components/keypad-legacy/store}/index.ts +7 -20
- package/src/{store → components/keypad-legacy/store}/input-reducer.ts +4 -5
- package/src/{store → components/keypad-legacy/store}/keypad-reducer.ts +3 -4
- package/src/{store → components/keypad-legacy/store}/layout-reducer.ts +3 -3
- package/src/{store → components/keypad-legacy/store}/shared.ts +3 -3
- package/src/{store → components/keypad-legacy/store}/types.ts +15 -19
- package/src/components/{styles.ts → keypad-legacy/styles.ts} +1 -1
- package/src/components/{text-icon.tsx → keypad-legacy/text-icon.tsx} +2 -2
- package/src/components/{touchable-keypad-button.tsx → keypad-legacy/touchable-keypad-button.tsx} +35 -21
- package/src/components/{two-page-keypad.tsx → keypad-legacy/two-page-keypad.tsx} +5 -6
- package/src/components/tabbar/icons.tsx +0 -2
- package/src/data/key-configs.ts +751 -309
- package/src/data/keys.ts +118 -70
- package/src/enums.ts +10 -9
- package/src/index.ts +6 -3
- package/src/math-input.stories.tsx +3 -3
- package/src/types.ts +21 -16
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/keypad/trigonometry-page.d.ts +0 -8
- package/dist/components/touchable-keypad-button.d.ts +0 -30
- package/dist/components/touchable-keypad-button.js.flow +0 -35
- package/dist/components/velocity-tracker.d.ts +0 -48
- package/dist/components/velocity-tracker.js.flow +0 -54
- package/dist/store/pager-reducer.d.ts +0 -4
- package/dist/store/pager-reducer.js.flow +0 -13
- package/dist/store/shared.d.ts +0 -7
- package/dist/store/shared.js.flow +0 -14
- package/src/components/velocity-tracker.ts +0 -86
- package/src/store/pager-reducer.ts +0 -125
- /package/dist/components/{corner-decal.d.ts → keypad-legacy/corner-decal.d.ts} +0 -0
- /package/dist/components/{corner-decal.js.flow → keypad-legacy/corner-decal.js.flow} +0 -0
- /package/dist/components/{empty-keypad-button.d.ts → keypad-legacy/empty-keypad-button.d.ts} +0 -0
- /package/dist/components/{empty-keypad-button.js.flow → keypad-legacy/empty-keypad-button.js.flow} +0 -0
- /package/dist/components/{many-keypad-button.d.ts → keypad-legacy/many-keypad-button.d.ts} +0 -0
- /package/dist/components/{many-keypad-button.js.flow → keypad-legacy/many-keypad-button.js.flow} +0 -0
- /package/dist/components/{math-icon.d.ts → keypad-legacy/math-icon.d.ts} +0 -0
- /package/dist/components/{math-icon.js.flow → keypad-legacy/math-icon.js.flow} +0 -0
- /package/dist/components/{navigation-pad.d.ts → keypad-legacy/navigation-pad.d.ts} +0 -0
- /package/dist/components/{navigation-pad.js.flow → keypad-legacy/navigation-pad.js.flow} +0 -0
- /package/dist/{store → components/keypad-legacy/store}/echo-reducer.d.ts +0 -0
- /package/dist/{store → components/keypad-legacy/store}/echo-reducer.js.flow +0 -0
- /package/dist/{store → components/keypad-legacy/store}/input-reducer.d.ts +0 -0
- /package/dist/{store → components/keypad-legacy/store}/input-reducer.js.flow +0 -0
- /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.d.ts +0 -0
- /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.js.flow +0 -0
- /package/dist/{store → components/keypad-legacy/store}/layout-reducer.d.ts +0 -0
- /package/dist/{store → components/keypad-legacy/store}/layout-reducer.js.flow +0 -0
- /package/dist/components/{styles.d.ts → keypad-legacy/styles.d.ts} +0 -0
- /package/dist/components/{styles.js.flow → keypad-legacy/styles.js.flow} +0 -0
- /package/dist/components/{svg-icon.d.ts → keypad-legacy/svg-icon.d.ts} +0 -0
- /package/dist/components/{svg-icon.js.flow → keypad-legacy/svg-icon.js.flow} +0 -0
- /package/dist/components/{text-icon.d.ts → keypad-legacy/text-icon.d.ts} +0 -0
- /package/dist/components/{text-icon.js.flow → keypad-legacy/text-icon.js.flow} +0 -0
- /package/dist/components/{z-indexes.d.ts → keypad-legacy/z-indexes.d.ts} +0 -0
- /package/dist/components/{z-indexes.js.flow → keypad-legacy/z-indexes.js.flow} +0 -0
- /package/src/components/{__tests__ → keypad-legacy/__tests__}/gesture-state-machine.test.ts +0 -0
- /package/src/components/{__tests__ → keypad-legacy/__tests__}/node-manager.test.ts +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/arrow.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/backspace.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/cdot.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/cos.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/cube-root.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/dismiss.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/divide.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/down.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/equal.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/exp-2.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/exp-3.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/exp.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/frac.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/geq.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/gt.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/index.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-into-numerator.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-base.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-denominator.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-exponent.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-numerator.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-parentheses.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/left-paren.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/left.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/leq.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/ln.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/log-n.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/log.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/lt.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/minus.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/neq.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/parens.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/percent.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/period.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/plus.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/radical.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/right-paren.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/right.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/sin.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/sqrt.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/tan.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/times.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/up.js +0 -0
- /package/src/components/{svg-icon.tsx → keypad-legacy/svg-icon.tsx} +0 -0
- /package/src/components/{z-indexes.ts → keypad-legacy/z-indexes.ts} +0 -0
package/src/data/keys.ts
CHANGED
|
@@ -1,72 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type Key =
|
|
2
|
+
| "PLUS"
|
|
3
|
+
| "MINUS"
|
|
4
|
+
| "NEGATIVE"
|
|
5
|
+
| "TIMES"
|
|
6
|
+
| "DIVIDE"
|
|
7
|
+
| "DECIMAL"
|
|
8
|
+
| "PERIOD"
|
|
9
|
+
| "PERCENT"
|
|
10
|
+
| "CDOT"
|
|
11
|
+
| "EQUAL"
|
|
12
|
+
| "NEQ"
|
|
13
|
+
| "GT"
|
|
14
|
+
| "LT"
|
|
15
|
+
| "GEQ"
|
|
16
|
+
| "LEQ" // mobile native only
|
|
17
|
+
| "FRAC_INCLUSIVE" // mobile native only
|
|
18
|
+
| "FRAC_EXCLUSIVE" // mobile native only
|
|
19
|
+
| "FRAC"
|
|
20
|
+
| "EXP"
|
|
21
|
+
| "EXP_2"
|
|
22
|
+
| "EXP_3"
|
|
23
|
+
| "SQRT"
|
|
24
|
+
| "CUBE_ROOT"
|
|
25
|
+
| "RADICAL"
|
|
26
|
+
| "LEFT_PAREN"
|
|
27
|
+
| "RIGHT_PAREN"
|
|
28
|
+
| "LN"
|
|
29
|
+
| "LOG"
|
|
30
|
+
| "LOG_N"
|
|
31
|
+
| "SIN"
|
|
32
|
+
| "COS" // TODO(charlie): Add in additional Greek letters.
|
|
33
|
+
| "TAN"
|
|
34
|
+
| "PI"
|
|
35
|
+
| "THETA"
|
|
36
|
+
| "UP"
|
|
37
|
+
| "RIGHT"
|
|
38
|
+
| "DOWN"
|
|
39
|
+
| "LEFT"
|
|
40
|
+
| "BACKSPACE"
|
|
41
|
+
| "DISMISS"
|
|
42
|
+
| "JUMP_OUT_PARENTHESES"
|
|
43
|
+
| "JUMP_OUT_EXPONENT"
|
|
44
|
+
| "JUMP_OUT_BASE"
|
|
45
|
+
| "JUMP_INTO_NUMERATOR"
|
|
46
|
+
| "JUMP_OUT_NUMERATOR"
|
|
47
|
+
| "JUMP_OUT_DENOMINATOR" // Multi-functional keys.
|
|
48
|
+
| "NOOP" // mobile native only
|
|
49
|
+
| "MANY" // A custom key that captures an arbitrary number of symbols but has no 'default' symbol or action.
|
|
50
|
+
| "NUM_0"
|
|
51
|
+
| "NUM_1"
|
|
52
|
+
| "NUM_2"
|
|
53
|
+
| "NUM_3"
|
|
54
|
+
| "NUM_4"
|
|
55
|
+
| "NUM_5"
|
|
56
|
+
| "NUM_6"
|
|
57
|
+
| "NUM_7"
|
|
58
|
+
| "NUM_8"
|
|
59
|
+
| "NUM_9"
|
|
60
|
+
| "a"
|
|
61
|
+
| "b"
|
|
62
|
+
| "c"
|
|
63
|
+
| "d"
|
|
64
|
+
| "e"
|
|
65
|
+
| "f"
|
|
66
|
+
| "g"
|
|
67
|
+
| "h"
|
|
68
|
+
| "i"
|
|
69
|
+
| "j"
|
|
70
|
+
| "k"
|
|
71
|
+
| "l"
|
|
72
|
+
| "m"
|
|
73
|
+
| "n"
|
|
74
|
+
| "o"
|
|
75
|
+
| "p"
|
|
76
|
+
| "q"
|
|
77
|
+
| "r"
|
|
78
|
+
| "s"
|
|
79
|
+
| "t"
|
|
80
|
+
| "u"
|
|
81
|
+
| "v"
|
|
82
|
+
| "w"
|
|
83
|
+
| "x"
|
|
84
|
+
| "y"
|
|
85
|
+
| "z"
|
|
86
|
+
| "A"
|
|
87
|
+
| "B"
|
|
88
|
+
| "C"
|
|
89
|
+
| "D"
|
|
90
|
+
| "E"
|
|
91
|
+
| "F"
|
|
92
|
+
| "G"
|
|
93
|
+
| "H"
|
|
94
|
+
| "I"
|
|
95
|
+
| "J"
|
|
96
|
+
| "K"
|
|
97
|
+
| "L"
|
|
98
|
+
| "M"
|
|
99
|
+
| "N"
|
|
100
|
+
| "O"
|
|
101
|
+
| "P"
|
|
102
|
+
| "Q"
|
|
103
|
+
| "R"
|
|
104
|
+
| "S"
|
|
105
|
+
| "T"
|
|
106
|
+
| "U"
|
|
107
|
+
| "V"
|
|
108
|
+
| "W"
|
|
109
|
+
| "X"
|
|
110
|
+
| "Y"
|
|
111
|
+
| "Z"
|
|
5
112
|
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
NEGATIVE = "NEGATIVE",
|
|
13
|
-
TIMES = "TIMES",
|
|
14
|
-
DIVIDE = "DIVIDE",
|
|
15
|
-
DECIMAL = "DECIMAL",
|
|
16
|
-
PERIOD = "PERIOD",
|
|
17
|
-
PERCENT = "PERCENT",
|
|
18
|
-
CDOT = "CDOT",
|
|
19
|
-
EQUAL = "EQUAL",
|
|
20
|
-
NEQ = "NEQ",
|
|
21
|
-
GT = "GT",
|
|
22
|
-
LT = "LT",
|
|
23
|
-
GEQ = "GEQ",
|
|
24
|
-
LEQ = "LEQ", // mobile native only
|
|
25
|
-
FRAC_INCLUSIVE = "FRAC_INCLUSIVE", // mobile native only
|
|
26
|
-
FRAC_EXCLUSIVE = "FRAC_EXCLUSIVE", // mobile native only
|
|
27
|
-
FRAC = "FRAC",
|
|
28
|
-
EXP = "EXP",
|
|
29
|
-
EXP_2 = "EXP_2",
|
|
30
|
-
EXP_3 = "EXP_3",
|
|
31
|
-
SQRT = "SQRT",
|
|
32
|
-
CUBE_ROOT = "CUBE_ROOT",
|
|
33
|
-
RADICAL = "RADICAL",
|
|
34
|
-
LEFT_PAREN = "LEFT_PAREN",
|
|
35
|
-
RIGHT_PAREN = "RIGHT_PAREN",
|
|
36
|
-
LN = "LN",
|
|
37
|
-
LOG = "LOG",
|
|
38
|
-
LOG_N = "LOG_N",
|
|
39
|
-
SIN = "SIN",
|
|
40
|
-
COS = "COS", // TODO(charlie): Add in additional Greek letters.
|
|
41
|
-
TAN = "TAN",
|
|
113
|
+
// Currently only used by
|
|
114
|
+
// Perseus' Expression MathInput
|
|
115
|
+
| "PHI"
|
|
116
|
+
| "NTHROOT3"
|
|
117
|
+
| "POW"
|
|
118
|
+
| "LOG_B";
|
|
42
119
|
|
|
43
|
-
|
|
44
|
-
THETA = "THETA",
|
|
45
|
-
|
|
46
|
-
UP = "UP",
|
|
47
|
-
RIGHT = "RIGHT",
|
|
48
|
-
DOWN = "DOWN",
|
|
49
|
-
LEFT = "LEFT",
|
|
50
|
-
BACKSPACE = "BACKSPACE",
|
|
51
|
-
DISMISS = "DISMISS",
|
|
52
|
-
|
|
53
|
-
JUMP_OUT_PARENTHESES = "JUMP_OUT_PARENTHESES",
|
|
54
|
-
JUMP_OUT_EXPONENT = "JUMP_OUT_EXPONENT",
|
|
55
|
-
JUMP_OUT_BASE = "JUMP_OUT_BASE",
|
|
56
|
-
JUMP_INTO_NUMERATOR = "JUMP_INTO_NUMERATOR",
|
|
57
|
-
JUMP_OUT_NUMERATOR = "JUMP_OUT_NUMERATOR",
|
|
58
|
-
JUMP_OUT_DENOMINATOR = "JUMP_OUT_DENOMINATOR", // Multi-functional keys.
|
|
59
|
-
|
|
60
|
-
NOOP = "NOOP", // mobile native only
|
|
61
|
-
|
|
62
|
-
// Multi-functional keys.
|
|
63
|
-
// A custom key that captures an arbitrary number of symbols but has no
|
|
64
|
-
// 'default' symbol or action.
|
|
65
|
-
FRAC_MULTI = "FRAC_MULTI", // mobile native only
|
|
66
|
-
|
|
67
|
-
// A custom key that captures an arbitrary number of symbols but has no
|
|
68
|
-
// 'default' symbol or action.
|
|
69
|
-
MANY = "MANY",
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default Keys;
|
|
120
|
+
export default Key;
|
package/src/enums.ts
CHANGED
|
@@ -7,25 +7,26 @@ export enum KeypadType {
|
|
|
7
7
|
EXPRESSION = "EXPRESSION",
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
|
|
10
|
+
export const KeyTypes = [
|
|
11
|
+
"EMPTY",
|
|
12
12
|
// For numerals, variables, and any other characters that themselves
|
|
13
13
|
// compose 'values'.
|
|
14
|
-
|
|
14
|
+
"VALUE",
|
|
15
15
|
// For buttons that insert or adjust math in an input.
|
|
16
|
-
|
|
16
|
+
"OPERATOR",
|
|
17
17
|
// For buttons that move the cursor in an input (including via
|
|
18
18
|
// deletion).
|
|
19
|
-
|
|
19
|
+
"INPUT_NAVIGATION",
|
|
20
20
|
// For buttons that modify the broader keypad state (e.g., by changing
|
|
21
21
|
// the visible pane).
|
|
22
|
-
|
|
22
|
+
"KEYPAD_NAVIGATION",
|
|
23
23
|
// For buttons that house multiple buttons and have no action
|
|
24
24
|
// themselves.
|
|
25
|
-
|
|
25
|
+
"MANY",
|
|
26
26
|
// For the echo animation that appears on press.
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
"ECHO",
|
|
28
|
+
];
|
|
29
|
+
export type KeyType = typeof KeyTypes[number];
|
|
29
30
|
|
|
30
31
|
export enum DeviceOrientation {
|
|
31
32
|
LANDSCAPE = "LANDSCAPE",
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,10 @@ import "../less/main.less";
|
|
|
7
7
|
export {CursorContext} from "./components/input/cursor-contexts";
|
|
8
8
|
export {default as KeypadInput} from "./components/input/math-input";
|
|
9
9
|
export {keypadElementPropType} from "./components/prop-types";
|
|
10
|
-
export {default as
|
|
10
|
+
export {default as LegacyKeypad} from "./components/keypad-legacy/provided-keypad";
|
|
11
11
|
export {default as KeyConfigs} from "./data/key-configs";
|
|
12
|
-
export {default as Keys} from "./data/keys";
|
|
13
|
-
export {KeyType, KeypadType} from "./enums";
|
|
12
|
+
export type {default as Keys} from "./data/keys";
|
|
13
|
+
export {type KeyType, KeypadType} from "./enums";
|
|
14
|
+
|
|
15
|
+
export {default as Keypad} from "./components/keypad/index";
|
|
16
|
+
export {default as keyTranslator} from "./components/key-translator";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {LegacyKeypad, KeypadInput, KeypadType} from "./index";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
title: "Full MathInput",
|
|
@@ -10,7 +10,7 @@ export const Basic = () => {
|
|
|
10
10
|
const [value, setValue] = React.useState("");
|
|
11
11
|
const [keypadElement, setKeypadElement] = React.useState<any>(null);
|
|
12
12
|
const [keypadType, setKeypadType] = React.useState<KeypadType>(
|
|
13
|
-
KeypadType.
|
|
13
|
+
KeypadType.EXPRESSION,
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
React.useEffect(() => {
|
|
@@ -55,7 +55,7 @@ export const Basic = () => {
|
|
|
55
55
|
}}
|
|
56
56
|
/>
|
|
57
57
|
|
|
58
|
-
<
|
|
58
|
+
<LegacyKeypad
|
|
59
59
|
onElementMounted={(node) => {
|
|
60
60
|
if (node && !keypadElement) {
|
|
61
61
|
setKeypadElement(node);
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Key from "./data/keys";
|
|
2
2
|
import {
|
|
3
3
|
BorderDirection,
|
|
4
4
|
EchoAnimationType,
|
|
@@ -11,27 +11,26 @@ import type {CursorContext} from "./components/input/cursor-contexts";
|
|
|
11
11
|
|
|
12
12
|
export type Border = Partial<ReadonlyArray<BorderDirection>>;
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export interface Bound {
|
|
15
15
|
top: number;
|
|
16
16
|
right: number;
|
|
17
17
|
bottom: number;
|
|
18
18
|
left: number;
|
|
19
19
|
height: number;
|
|
20
20
|
width: number;
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
export type Popover = {
|
|
24
|
-
parentId:
|
|
24
|
+
parentId: Key;
|
|
25
25
|
bounds: Partial<Bound>;
|
|
26
|
-
childKeyIds: Array<
|
|
26
|
+
childKeyIds: Array<Key>;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export type Echo = {
|
|
30
30
|
animationId: string;
|
|
31
31
|
animationType: EchoAnimationType;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
initialBounds: DOMRect;
|
|
32
|
+
id: Key;
|
|
33
|
+
initialBounds: Bound;
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
export type IconConfig = {
|
|
@@ -39,20 +38,26 @@ export type IconConfig = {
|
|
|
39
38
|
data: string;
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
export type
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
type: KeyType;
|
|
46
|
-
childKeyIds: Array<Keys>;
|
|
41
|
+
export type NonManyKeyConfig = {
|
|
42
|
+
id: Key;
|
|
43
|
+
type: Exclude<KeyType, "MANY">;
|
|
47
44
|
icon: IconConfig;
|
|
45
|
+
ariaLabel: string;
|
|
48
46
|
};
|
|
49
47
|
|
|
48
|
+
export type ManyKeyConfig = Omit<NonManyKeyConfig, "type"> & {
|
|
49
|
+
type: Extract<KeyType, "MANY">;
|
|
50
|
+
childKeyIds: ReadonlyArray<string>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type KeyConfig = NonManyKeyConfig | ManyKeyConfig;
|
|
54
|
+
|
|
50
55
|
export type KeypadConfiguration = {
|
|
51
56
|
keypadType: KeypadType;
|
|
52
|
-
extraKeys?: ReadonlyArray<
|
|
57
|
+
extraKeys?: ReadonlyArray<Key>;
|
|
53
58
|
};
|
|
54
59
|
|
|
55
|
-
export type KeyHandler = (key:
|
|
60
|
+
export type KeyHandler = (key: Key) => Cursor;
|
|
56
61
|
|
|
57
62
|
export type Cursor = {
|
|
58
63
|
context: CursorContext;
|
|
@@ -78,4 +83,4 @@ export type ActiveNodesObj = {
|
|
|
78
83
|
focus: string | null;
|
|
79
84
|
};
|
|
80
85
|
|
|
81
|
-
export type LayoutProps = {initialBounds:
|
|
86
|
+
export type LayoutProps = {initialBounds: Bound};
|