@khanacademy/math-input 1.0.0 → 2.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 +10 -0
- package/dist/components/compute-layout-parameters.d.ts +2 -1
- package/dist/components/compute-layout-parameters.js.flow +2 -21
- package/dist/components/echo-manager.d.ts +4 -4
- package/dist/components/echo-manager.js.flow +4 -4
- package/dist/components/expression-keypad.d.ts +1 -1
- package/dist/components/expression-keypad.js.flow +1 -1
- package/dist/components/fraction-keypad.d.ts +1 -1
- package/dist/components/fraction-keypad.js.flow +1 -1
- package/dist/components/gesture-state-machine.d.ts +7 -7
- package/dist/components/gesture-state-machine.js.flow +8 -8
- package/dist/components/icon.d.ts +2 -2
- package/dist/components/icon.js.flow +2 -2
- package/dist/components/input/cursor-contexts.d.ts +10 -9
- package/dist/components/input/cursor-contexts.js.flow +11 -16
- package/dist/components/input/math-wrapper.d.ts +3 -2
- package/dist/components/input/math-wrapper.js.flow +3 -16
- package/dist/components/keypad/index.d.ts +1 -1
- package/dist/components/keypad/index.js.flow +1 -3
- package/dist/components/keypad-button.d.ts +8 -8
- package/dist/components/keypad-button.js.flow +10 -9
- package/dist/components/keypad-container.d.ts +2 -3
- package/dist/components/keypad-container.js.flow +2 -3
- package/dist/components/keypad.d.ts +1 -1
- package/dist/components/keypad.js.flow +1 -1
- package/dist/components/multi-symbol-grid.d.ts +2 -2
- package/dist/components/multi-symbol-grid.js.flow +2 -2
- package/dist/components/node-manager.d.ts +2 -5
- package/dist/components/node-manager.js.flow +2 -5
- package/dist/components/popover-state-machine.d.ts +1 -8
- package/dist/components/popover-state-machine.js.flow +2 -8
- package/dist/components/provided-keypad.d.ts +1 -4
- package/dist/components/provided-keypad.js.flow +1 -4
- package/dist/components/styles.d.ts +1 -2
- package/dist/components/styles.js.flow +1 -3
- package/dist/components/touchable-keypad-button.d.ts +6 -6
- package/dist/components/touchable-keypad-button.js.flow +6 -6
- package/dist/data/keys.d.ts +51 -52
- package/dist/data/keys.js.flow +50 -99
- package/dist/enums.d.ts +49 -0
- package/dist/enums.js.flow +63 -0
- package/dist/es/index.css +0 -3
- package/dist/es/index.js +415 -455
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/view.d.ts +1 -2
- package/dist/fake-react-native-web/view.js.flow +1 -2
- package/dist/index.css +0 -3
- package/dist/index.d.ts +3 -6
- package/dist/index.js +438 -477
- package/dist/index.js.flow +3 -6
- package/dist/index.js.map +1 -1
- package/dist/store/actions.d.ts +64 -0
- package/dist/store/actions.js.flow +101 -0
- package/dist/store/echo-reducer.d.ts +2 -3
- package/dist/store/echo-reducer.js.flow +2 -6
- package/dist/store/index.d.ts +5 -41
- package/dist/store/index.js.flow +5 -52
- package/dist/store/input-reducer.d.ts +2 -5
- package/dist/store/input-reducer.js.flow +3 -6
- package/dist/store/keypad-reducer.d.ts +2 -7
- package/dist/store/keypad-reducer.js.flow +3 -8
- package/dist/store/layout-reducer.d.ts +2 -19
- package/dist/store/layout-reducer.js.flow +3 -20
- package/dist/store/pager-reducer.d.ts +2 -11
- package/dist/store/pager-reducer.js.flow +3 -12
- package/dist/store/shared.d.ts +2 -1
- package/dist/store/shared.js.flow +2 -1
- package/dist/store/types.d.ts +5 -5
- package/dist/store/types.js.flow +5 -5
- package/dist/types.d.ts +28 -16
- package/dist/types.js.flow +32 -20
- package/less/overrides.less +0 -6
- package/package.json +1 -1
- package/src/components/compute-layout-parameters.ts +6 -6
- package/src/components/echo-manager.tsx +10 -10
- package/src/components/expression-keypad.tsx +9 -10
- package/src/components/fraction-keypad.tsx +11 -12
- package/src/components/gesture-state-machine.ts +8 -8
- package/src/components/icon.tsx +6 -6
- package/src/components/input/__tests__/context-tracking.test.ts +20 -20
- package/src/components/input/cursor-contexts.ts +22 -29
- package/src/components/input/math-wrapper.ts +75 -67
- package/src/components/keypad/index.tsx +1 -1
- package/src/components/keypad-button.tsx +20 -21
- package/src/components/keypad-container.tsx +9 -10
- package/src/components/keypad.tsx +1 -1
- package/src/components/many-keypad-button.tsx +2 -2
- package/src/components/multi-symbol-grid.tsx +4 -5
- package/src/components/multi-symbol-popover.tsx +1 -1
- package/src/components/navigation-pad.tsx +1 -1
- package/src/components/node-manager.ts +2 -2
- package/src/components/popover-state-machine.ts +2 -10
- package/src/components/provided-keypad.tsx +3 -12
- package/src/components/touchable-keypad-button.tsx +7 -7
- package/src/data/key-configs.ts +58 -58
- package/src/data/keys.ts +53 -105
- package/src/enums.ts +74 -0
- package/src/index.ts +3 -9
- package/src/math-input.stories.tsx +67 -0
- package/src/store/actions.ts +179 -0
- package/src/store/echo-reducer.ts +10 -7
- package/src/store/index.ts +24 -24
- package/src/store/input-reducer.ts +7 -6
- package/src/store/keypad-reducer.ts +3 -6
- package/src/store/layout-reducer.ts +12 -11
- package/src/store/pager-reducer.ts +30 -46
- package/src/store/shared.ts +4 -4
- package/src/store/types.ts +21 -5
- package/src/types.ts +32 -20
- package/src/utils.ts +3 -3
- package/tsconfig-build.tsbuildinfo +1 -0
- package/dist/actions/index.d.ts +0 -31
- package/dist/actions/index.js.flow +0 -40
- package/dist/consts.d.ts +0 -51
- package/dist/consts.js.flow +0 -66
- package/src/actions/index.ts +0 -57
- package/src/consts.ts +0 -91
- package/tsconfig.tsbuildinfo +0 -1
- /package/src/components/{gesture-manager.tsx → gesture-manager.ts} +0 -0
- /package/{tsconfig.json → tsconfig-build.json} +0 -0
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
import {StyleSheet} from "aphrodite";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
|
|
9
|
-
import {BorderStyles} from "../consts";
|
|
10
9
|
import KeyConfigs from "../data/key-configs";
|
|
10
|
+
import {BorderStyles} from "../enums";
|
|
11
11
|
import {View} from "../fake-react-native-web/index";
|
|
12
12
|
|
|
13
13
|
import {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {Border} from "../types";
|
|
1
|
+
import type {Border, LayoutProps} from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* A manager for our node-to-ID system. In particular, this class is
|
|
4
4
|
* responsible for maintaing a mapping between DOM nodes and node IDs, and
|
|
@@ -122,7 +122,7 @@ class NodeManager {
|
|
|
122
122
|
* @returns {object} - the bounding client rect for the given node, along
|
|
123
123
|
* with its borders
|
|
124
124
|
*/
|
|
125
|
-
layoutPropsForId(id: string):
|
|
125
|
+
layoutPropsForId(id: string): LayoutProps {
|
|
126
126
|
if (!this._cachedBoundingBoxesById[id]) {
|
|
127
127
|
const node = this._nodesById[id];
|
|
128
128
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {ActiveNodesObj} from "../types";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* A state machine for the popover state. In particular, this class manages the
|
|
3
5
|
* mapping of parent nodes to their children, and translates touch events that
|
|
@@ -5,16 +7,6 @@
|
|
|
5
7
|
* is present.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
|
-
type ActiveNodesObjPopover = {
|
|
9
|
-
parentId: string;
|
|
10
|
-
childIds: ReadonlyArray<string>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type ActiveNodesObj = {
|
|
14
|
-
popover: ActiveNodesObjPopover | null;
|
|
15
|
-
focus: string | null;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
10
|
type Handlers = {
|
|
19
11
|
onActiveNodesChanged: (activeNodes: ActiveNodesObj) => void;
|
|
20
12
|
onClick: (keyId: string, domNodeId: string, inPopover: boolean) => void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable react/no-unsafe */
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import ReactDOM from "react-dom";
|
|
4
3
|
import {Provider} from "react-redux";
|
|
@@ -9,7 +8,7 @@ import {
|
|
|
9
8
|
configureKeypad,
|
|
10
9
|
setCursor,
|
|
11
10
|
setKeyHandler,
|
|
12
|
-
} from "../actions
|
|
11
|
+
} from "../store/actions";
|
|
13
12
|
import {createStore} from "../store/index";
|
|
14
13
|
|
|
15
14
|
import KeypadContainer from "./keypad-container";
|
|
@@ -24,21 +23,13 @@ type Props = {
|
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
class ProvidedKeypad extends React.Component<Props> {
|
|
27
|
-
mounted?: boolean;
|
|
28
26
|
store: any;
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
constructor(props) {
|
|
29
|
+
super(props);
|
|
31
30
|
this.store = createStore();
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
componentDidMount() {
|
|
35
|
-
this.mounted = true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
componentWillUnmount() {
|
|
39
|
-
this.mounted = false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
33
|
activate: () => void = () => {
|
|
43
34
|
this.store.dispatch(activateKeypad());
|
|
44
35
|
};
|
|
@@ -9,27 +9,27 @@ import * as React from "react";
|
|
|
9
9
|
import ReactDOM from "react-dom";
|
|
10
10
|
import {connect} from "react-redux";
|
|
11
11
|
|
|
12
|
-
import {KeyType, KeyTypes} from "../consts";
|
|
13
12
|
import KeyConfigs from "../data/key-configs";
|
|
13
|
+
import Keys from "../data/keys";
|
|
14
|
+
import {KeyType} from "../enums";
|
|
14
15
|
|
|
15
16
|
import GestureManager from "./gesture-manager";
|
|
16
17
|
import KeypadButton from "./keypad-button";
|
|
17
18
|
|
|
18
|
-
import type {
|
|
19
|
-
import type {Border, Icon} from "../types";
|
|
19
|
+
import type {Border, IconConfig} from "../types";
|
|
20
20
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
21
21
|
|
|
22
22
|
type Props = {
|
|
23
23
|
borders: Border;
|
|
24
|
-
childKeyIds: ReadonlyArray<
|
|
24
|
+
childKeyIds: ReadonlyArray<Keys>;
|
|
25
25
|
disabled: boolean;
|
|
26
26
|
focused: boolean;
|
|
27
27
|
gestureManager: GestureManager;
|
|
28
|
-
id:
|
|
28
|
+
id: Keys;
|
|
29
29
|
popoverEnabled: boolean;
|
|
30
30
|
style: StyleType;
|
|
31
31
|
type: KeyType;
|
|
32
|
-
icon:
|
|
32
|
+
icon: IconConfig;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
class TouchableKeypadButton extends React.Component<Props> {
|
|
@@ -118,7 +118,7 @@ const mapStateToProps = (state, ownProps) => {
|
|
|
118
118
|
// Override with the default child props, if the key is a multi-symbol key
|
|
119
119
|
// (but not a many-symbol key, which operates under different rules).
|
|
120
120
|
const useFirstChildProps =
|
|
121
|
-
type !==
|
|
121
|
+
type !== KeyType.MANY && childKeys && childKeys.length > 0;
|
|
122
122
|
|
|
123
123
|
return {
|
|
124
124
|
...rest,
|
package/src/data/key-configs.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as i18n from "@khanacademy/wonder-blocks-i18n";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {DecimalSeparator, IconType, KeyType} from "../enums";
|
|
7
7
|
import {decimalSeparator} from "../utils";
|
|
8
8
|
|
|
9
9
|
import Keys from "./keys";
|
|
@@ -17,240 +17,240 @@ export type KeyConfig = {
|
|
|
17
17
|
const KeyConfigs: any = {
|
|
18
18
|
// Basic math keys.
|
|
19
19
|
[Keys.PLUS]: {
|
|
20
|
-
type:
|
|
20
|
+
type: KeyType.OPERATOR,
|
|
21
21
|
// I18N: A label for a plus sign.
|
|
22
22
|
ariaLabel: i18n._("Plus"),
|
|
23
23
|
},
|
|
24
24
|
[Keys.MINUS]: {
|
|
25
|
-
type:
|
|
25
|
+
type: KeyType.OPERATOR,
|
|
26
26
|
// I18N: A label for a minus sign.
|
|
27
27
|
ariaLabel: i18n._("Minus"),
|
|
28
28
|
},
|
|
29
29
|
[Keys.NEGATIVE]: {
|
|
30
|
-
type:
|
|
30
|
+
type: KeyType.VALUE,
|
|
31
31
|
// I18N: A label for a minus sign.
|
|
32
32
|
ariaLabel: i18n._("Negative"),
|
|
33
33
|
},
|
|
34
34
|
[Keys.TIMES]: {
|
|
35
|
-
type:
|
|
35
|
+
type: KeyType.OPERATOR,
|
|
36
36
|
// I18N: A label for a multiplication sign (represented with an 'x').
|
|
37
37
|
ariaLabel: i18n._("Multiply"),
|
|
38
38
|
},
|
|
39
39
|
[Keys.DIVIDE]: {
|
|
40
|
-
type:
|
|
40
|
+
type: KeyType.OPERATOR,
|
|
41
41
|
// I18N: A label for a division sign.
|
|
42
42
|
ariaLabel: i18n._("Divide"),
|
|
43
43
|
},
|
|
44
44
|
[Keys.DECIMAL]: {
|
|
45
|
-
type:
|
|
45
|
+
type: KeyType.VALUE,
|
|
46
46
|
// I18N: A label for a decimal symbol.
|
|
47
47
|
ariaLabel: i18n._("Decimal"),
|
|
48
48
|
icon:
|
|
49
|
-
decimalSeparator ===
|
|
49
|
+
decimalSeparator === DecimalSeparator.COMMA
|
|
50
50
|
? {
|
|
51
51
|
// TODO(charlie): Get an SVG icon for the comma, or verify with
|
|
52
52
|
// design that the text-rendered version is acceptable.
|
|
53
|
-
type:
|
|
53
|
+
type: IconType.TEXT,
|
|
54
54
|
data: ",",
|
|
55
55
|
}
|
|
56
56
|
: {
|
|
57
|
-
type:
|
|
57
|
+
type: IconType.SVG,
|
|
58
58
|
data: Keys.PERIOD,
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
[Keys.PERCENT]: {
|
|
62
|
-
type:
|
|
62
|
+
type: KeyType.OPERATOR,
|
|
63
63
|
// I18N: A label for a percent sign.
|
|
64
64
|
ariaLabel: i18n._("Percent"),
|
|
65
65
|
},
|
|
66
66
|
[Keys.CDOT]: {
|
|
67
|
-
type:
|
|
67
|
+
type: KeyType.OPERATOR,
|
|
68
68
|
// I18N: A label for a multiplication sign (represented as a dot).
|
|
69
69
|
ariaLabel: i18n._("Multiply"),
|
|
70
70
|
},
|
|
71
71
|
[Keys.EQUAL]: {
|
|
72
|
-
type:
|
|
72
|
+
type: KeyType.OPERATOR,
|
|
73
73
|
ariaLabel: i18n._("Equals sign"),
|
|
74
74
|
},
|
|
75
75
|
[Keys.NEQ]: {
|
|
76
|
-
type:
|
|
76
|
+
type: KeyType.OPERATOR,
|
|
77
77
|
ariaLabel: i18n._("Not-equals sign"),
|
|
78
78
|
},
|
|
79
79
|
[Keys.GT]: {
|
|
80
|
-
type:
|
|
80
|
+
type: KeyType.OPERATOR,
|
|
81
81
|
// I18N: A label for a 'greater than' sign (represented as '>').
|
|
82
82
|
ariaLabel: i18n._("Greater than sign"),
|
|
83
83
|
},
|
|
84
84
|
[Keys.LT]: {
|
|
85
|
-
type:
|
|
85
|
+
type: KeyType.OPERATOR,
|
|
86
86
|
// I18N: A label for a 'less than' sign (represented as '<').
|
|
87
87
|
ariaLabel: i18n._("Less than sign"),
|
|
88
88
|
},
|
|
89
89
|
[Keys.GEQ]: {
|
|
90
|
-
type:
|
|
90
|
+
type: KeyType.OPERATOR,
|
|
91
91
|
ariaLabel: i18n._("Greater than or equal to sign"),
|
|
92
92
|
},
|
|
93
93
|
[Keys.LEQ]: {
|
|
94
|
-
type:
|
|
94
|
+
type: KeyType.OPERATOR,
|
|
95
95
|
ariaLabel: i18n._("Less than or equal to sign"),
|
|
96
96
|
},
|
|
97
97
|
// mobile native
|
|
98
98
|
[Keys.FRAC_INCLUSIVE]: {
|
|
99
|
-
type:
|
|
99
|
+
type: KeyType.OPERATOR,
|
|
100
100
|
// I18N: A label for a button that creates a new fraction and puts the
|
|
101
101
|
// current expression in the numerator of that fraction.
|
|
102
102
|
ariaLabel: i18n._("Fraction, with current expression in numerator"),
|
|
103
103
|
},
|
|
104
104
|
// mobile native
|
|
105
105
|
[Keys.FRAC_EXCLUSIVE]: {
|
|
106
|
-
type:
|
|
106
|
+
type: KeyType.OPERATOR,
|
|
107
107
|
// I18N: A label for a button that creates a new fraction next to the
|
|
108
108
|
// cursor.
|
|
109
109
|
ariaLabel: i18n._("Fraction, excluding the current expression"),
|
|
110
110
|
},
|
|
111
111
|
// mobile web
|
|
112
112
|
[Keys.FRAC]: {
|
|
113
|
-
type:
|
|
113
|
+
type: KeyType.OPERATOR,
|
|
114
114
|
// I18N: A label for a button that creates a new fraction next to the
|
|
115
115
|
// cursor.
|
|
116
116
|
ariaLabel: i18n._("Fraction, excluding the current expression"),
|
|
117
117
|
},
|
|
118
118
|
[Keys.EXP]: {
|
|
119
|
-
type:
|
|
119
|
+
type: KeyType.OPERATOR,
|
|
120
120
|
// I18N: A label for a button that will allow the user to input a custom
|
|
121
121
|
// exponent.
|
|
122
122
|
ariaLabel: i18n._("Custom exponent"),
|
|
123
123
|
},
|
|
124
124
|
[Keys.EXP_2]: {
|
|
125
|
-
type:
|
|
125
|
+
type: KeyType.OPERATOR,
|
|
126
126
|
// I18N: A label for a button that will square (take to the second
|
|
127
127
|
// power) some math.
|
|
128
128
|
ariaLabel: i18n._("Square"),
|
|
129
129
|
},
|
|
130
130
|
[Keys.EXP_3]: {
|
|
131
|
-
type:
|
|
131
|
+
type: KeyType.OPERATOR,
|
|
132
132
|
// I18N: A label for a button that will cube (take to the third power)
|
|
133
133
|
// some math.
|
|
134
134
|
ariaLabel: i18n._("Cube"),
|
|
135
135
|
},
|
|
136
136
|
[Keys.SQRT]: {
|
|
137
|
-
type:
|
|
137
|
+
type: KeyType.OPERATOR,
|
|
138
138
|
ariaLabel: i18n._("Square root"),
|
|
139
139
|
},
|
|
140
140
|
[Keys.CUBE_ROOT]: {
|
|
141
|
-
type:
|
|
141
|
+
type: KeyType.OPERATOR,
|
|
142
142
|
ariaLabel: i18n._("Cube root"),
|
|
143
143
|
},
|
|
144
144
|
[Keys.RADICAL]: {
|
|
145
|
-
type:
|
|
145
|
+
type: KeyType.OPERATOR,
|
|
146
146
|
ariaLabel: i18n._("Radical with custom root"),
|
|
147
147
|
},
|
|
148
148
|
[Keys.LEFT_PAREN]: {
|
|
149
|
-
type:
|
|
149
|
+
type: KeyType.OPERATOR,
|
|
150
150
|
ariaLabel: i18n._("Left parenthesis"),
|
|
151
151
|
},
|
|
152
152
|
[Keys.RIGHT_PAREN]: {
|
|
153
|
-
type:
|
|
153
|
+
type: KeyType.OPERATOR,
|
|
154
154
|
ariaLabel: i18n._("Right parenthesis"),
|
|
155
155
|
},
|
|
156
156
|
[Keys.LN]: {
|
|
157
|
-
type:
|
|
157
|
+
type: KeyType.OPERATOR,
|
|
158
158
|
ariaLabel: i18n._("Natural logarithm"),
|
|
159
159
|
},
|
|
160
160
|
[Keys.LOG]: {
|
|
161
|
-
type:
|
|
161
|
+
type: KeyType.OPERATOR,
|
|
162
162
|
ariaLabel: i18n._("Logarithm with base 10"),
|
|
163
163
|
},
|
|
164
164
|
[Keys.LOG_N]: {
|
|
165
|
-
type:
|
|
165
|
+
type: KeyType.OPERATOR,
|
|
166
166
|
ariaLabel: i18n._("Logarithm with custom base"),
|
|
167
167
|
},
|
|
168
168
|
[Keys.SIN]: {
|
|
169
|
-
type:
|
|
169
|
+
type: KeyType.OPERATOR,
|
|
170
170
|
ariaLabel: i18n._("Sine"),
|
|
171
171
|
},
|
|
172
172
|
[Keys.COS]: {
|
|
173
|
-
type:
|
|
173
|
+
type: KeyType.OPERATOR,
|
|
174
174
|
ariaLabel: i18n._("Cosine"),
|
|
175
175
|
},
|
|
176
176
|
[Keys.TAN]: {
|
|
177
|
-
type:
|
|
177
|
+
type: KeyType.OPERATOR,
|
|
178
178
|
ariaLabel: i18n._("Tangent"),
|
|
179
179
|
},
|
|
180
180
|
[Keys.PI]: {
|
|
181
|
-
type:
|
|
181
|
+
type: KeyType.VALUE,
|
|
182
182
|
ariaLabel: i18n._("Pi"),
|
|
183
183
|
icon: {
|
|
184
|
-
type:
|
|
184
|
+
type: IconType.MATH,
|
|
185
185
|
data: "\\pi",
|
|
186
186
|
},
|
|
187
187
|
},
|
|
188
188
|
[Keys.THETA]: {
|
|
189
|
-
type:
|
|
189
|
+
type: KeyType.VALUE,
|
|
190
190
|
ariaLabel: i18n._("Theta"),
|
|
191
191
|
icon: {
|
|
192
|
-
type:
|
|
192
|
+
type: IconType.MATH,
|
|
193
193
|
data: "\\theta",
|
|
194
194
|
},
|
|
195
195
|
},
|
|
196
196
|
[Keys.NOOP]: {
|
|
197
|
-
type:
|
|
197
|
+
type: KeyType.EMPTY,
|
|
198
198
|
},
|
|
199
199
|
|
|
200
200
|
// Input navigation keys.
|
|
201
201
|
[Keys.UP]: {
|
|
202
|
-
type:
|
|
202
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
203
203
|
ariaLabel: i18n._("Up arrow"),
|
|
204
204
|
},
|
|
205
205
|
[Keys.RIGHT]: {
|
|
206
|
-
type:
|
|
206
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
207
207
|
ariaLabel: i18n._("Right arrow"),
|
|
208
208
|
},
|
|
209
209
|
[Keys.DOWN]: {
|
|
210
|
-
type:
|
|
210
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
211
211
|
ariaLabel: i18n._("Down arrow"),
|
|
212
212
|
},
|
|
213
213
|
[Keys.LEFT]: {
|
|
214
|
-
type:
|
|
214
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
215
215
|
ariaLabel: i18n._("Left arrow"),
|
|
216
216
|
},
|
|
217
217
|
[Keys.JUMP_OUT_PARENTHESES]: {
|
|
218
|
-
type:
|
|
218
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
219
219
|
ariaLabel: i18n._("Navigate right out of a set of parentheses"),
|
|
220
220
|
},
|
|
221
221
|
[Keys.JUMP_OUT_EXPONENT]: {
|
|
222
|
-
type:
|
|
222
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
223
223
|
ariaLabel: i18n._("Navigate right out of an exponent"),
|
|
224
224
|
},
|
|
225
225
|
[Keys.JUMP_OUT_BASE]: {
|
|
226
|
-
type:
|
|
226
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
227
227
|
ariaLabel: i18n._("Navigate right out of a base"),
|
|
228
228
|
},
|
|
229
229
|
[Keys.JUMP_INTO_NUMERATOR]: {
|
|
230
|
-
type:
|
|
230
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
231
231
|
ariaLabel: i18n._("Navigate right into the numerator of a fraction"),
|
|
232
232
|
},
|
|
233
233
|
[Keys.JUMP_OUT_NUMERATOR]: {
|
|
234
|
-
type:
|
|
234
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
235
235
|
ariaLabel: i18n._(
|
|
236
236
|
"Navigate right out of the numerator and into the denominator",
|
|
237
237
|
),
|
|
238
238
|
},
|
|
239
239
|
[Keys.JUMP_OUT_DENOMINATOR]: {
|
|
240
|
-
type:
|
|
240
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
241
241
|
ariaLabel: i18n._(
|
|
242
242
|
"Navigate right out of the denominator of a fraction",
|
|
243
243
|
),
|
|
244
244
|
},
|
|
245
245
|
[Keys.BACKSPACE]: {
|
|
246
|
-
type:
|
|
246
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
247
247
|
// I18N: A label for a button that will delete some input.
|
|
248
248
|
ariaLabel: i18n._("Delete"),
|
|
249
249
|
},
|
|
250
250
|
|
|
251
251
|
// Keypad navigation keys.
|
|
252
252
|
[Keys.DISMISS]: {
|
|
253
|
-
type:
|
|
253
|
+
type: KeyType.KEYPAD_NAVIGATION,
|
|
254
254
|
// I18N: A label for a button that will dismiss/hide a keypad.
|
|
255
255
|
ariaLabel: i18n._("Dismiss"),
|
|
256
256
|
},
|
|
@@ -268,7 +268,7 @@ KeyConfigs[Keys.FRAC_MULTI] = {
|
|
|
268
268
|
|
|
269
269
|
// TODO(charlie): Use the numeral color for the 'Many' key.
|
|
270
270
|
KeyConfigs[Keys.MANY] = {
|
|
271
|
-
type:
|
|
271
|
+
type: KeyType.MANY,
|
|
272
272
|
// childKeyIds will be configured by the client.
|
|
273
273
|
};
|
|
274
274
|
|
|
@@ -280,10 +280,10 @@ for (const num of NUMBERS) {
|
|
|
280
280
|
// would mean that we'd be using text beyond the variable key).
|
|
281
281
|
const textRepresentation = `${num}`;
|
|
282
282
|
KeyConfigs[`NUM_${num}`] = {
|
|
283
|
-
type:
|
|
283
|
+
type: KeyType.VALUE,
|
|
284
284
|
ariaLabel: textRepresentation,
|
|
285
285
|
icon: {
|
|
286
|
-
type:
|
|
286
|
+
type: IconType.TEXT,
|
|
287
287
|
data: textRepresentation,
|
|
288
288
|
},
|
|
289
289
|
};
|
|
@@ -324,10 +324,10 @@ for (const letter of LETTERS) {
|
|
|
324
324
|
|
|
325
325
|
for (const textRepresentation of [lowerCaseVariable, upperCaseVariable]) {
|
|
326
326
|
KeyConfigs[textRepresentation] = {
|
|
327
|
-
type:
|
|
327
|
+
type: KeyType.VALUE,
|
|
328
328
|
ariaLabel: textRepresentation,
|
|
329
329
|
icon: {
|
|
330
|
-
type:
|
|
330
|
+
type: IconType.MATH,
|
|
331
331
|
data: textRepresentation,
|
|
332
332
|
},
|
|
333
333
|
};
|
|
@@ -339,7 +339,7 @@ for (const key of Object.keys(KeyConfigs)) {
|
|
|
339
339
|
id: key,
|
|
340
340
|
// Default to an SVG icon indexed by the key name.
|
|
341
341
|
icon: {
|
|
342
|
-
type:
|
|
342
|
+
type: IconType.SVG,
|
|
343
343
|
data: key,
|
|
344
344
|
},
|
|
345
345
|
...KeyConfigs[key],
|
package/src/data/keys.ts
CHANGED
|
@@ -3,122 +3,70 @@
|
|
|
3
3
|
* alphanumeric characters.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export type Key =
|
|
7
|
-
| "PLUS"
|
|
8
|
-
| "MINUS"
|
|
9
|
-
| "NEGATIVE"
|
|
10
|
-
| "TIMES"
|
|
11
|
-
| "DIVIDE"
|
|
12
|
-
| "DECIMAL"
|
|
13
|
-
| "PERIOD"
|
|
14
|
-
| "PERCENT"
|
|
15
|
-
| "CDOT"
|
|
16
|
-
| "EQUAL"
|
|
17
|
-
| "NEQ"
|
|
18
|
-
| "GT"
|
|
19
|
-
| "LT"
|
|
20
|
-
| "GEQ"
|
|
21
|
-
| "LEQ" // mobile native only
|
|
22
|
-
| "FRAC_INCLUSIVE" // mobile native only
|
|
23
|
-
| "FRAC_EXCLUSIVE"
|
|
24
|
-
| "FRAC"
|
|
25
|
-
| "EXP"
|
|
26
|
-
| "EXP_2"
|
|
27
|
-
| "EXP_3"
|
|
28
|
-
| "SQRT"
|
|
29
|
-
| "CUBE_ROOT"
|
|
30
|
-
| "RADICAL"
|
|
31
|
-
| "LEFT_PAREN"
|
|
32
|
-
| "RIGHT_PAREN"
|
|
33
|
-
| "LN"
|
|
34
|
-
| "LOG"
|
|
35
|
-
| "LOG_N"
|
|
36
|
-
| "SIN"
|
|
37
|
-
| "COS" // TODO(charlie): Add in additional Greek letters.
|
|
38
|
-
| "TAN"
|
|
39
|
-
| "PI"
|
|
40
|
-
| "THETA"
|
|
41
|
-
| "UP"
|
|
42
|
-
| "RIGHT"
|
|
43
|
-
| "DOWN"
|
|
44
|
-
| "LEFT"
|
|
45
|
-
| "BACKSPACE"
|
|
46
|
-
| "DISMISS"
|
|
47
|
-
| "JUMP_OUT_PARENTHESES"
|
|
48
|
-
| "JUMP_OUT_EXPONENT"
|
|
49
|
-
| "JUMP_OUT_BASE"
|
|
50
|
-
| "JUMP_INTO_NUMERATOR"
|
|
51
|
-
| "JUMP_OUT_NUMERATOR"
|
|
52
|
-
| "JUMP_OUT_DENOMINATOR" // Multi-functional keys.
|
|
53
|
-
| "NOOP" // mobile native only
|
|
54
|
-
// A custom key that captures an arbitrary number of symbols but has no
|
|
55
|
-
// 'default' symbol or action.
|
|
56
|
-
| "FRAC_MULTI"
|
|
57
|
-
| "MANY";
|
|
58
|
-
|
|
59
6
|
// TODO(charlie): There's duplication between this file and key-configs.js.
|
|
60
7
|
// We should clean it up by removing this file and requiring clients to use the
|
|
61
8
|
// `id` field on the key configurations.
|
|
62
|
-
|
|
63
|
-
PLUS
|
|
64
|
-
MINUS
|
|
65
|
-
NEGATIVE
|
|
66
|
-
TIMES
|
|
67
|
-
DIVIDE
|
|
68
|
-
DECIMAL
|
|
69
|
-
PERIOD
|
|
70
|
-
PERCENT
|
|
71
|
-
CDOT
|
|
72
|
-
EQUAL
|
|
73
|
-
NEQ
|
|
74
|
-
GT
|
|
75
|
-
LT
|
|
76
|
-
GEQ
|
|
77
|
-
LEQ
|
|
78
|
-
FRAC_INCLUSIVE
|
|
79
|
-
FRAC_EXCLUSIVE
|
|
80
|
-
FRAC
|
|
81
|
-
EXP
|
|
82
|
-
EXP_2
|
|
83
|
-
EXP_3
|
|
84
|
-
SQRT
|
|
85
|
-
CUBE_ROOT
|
|
86
|
-
RADICAL
|
|
87
|
-
LEFT_PAREN
|
|
88
|
-
RIGHT_PAREN
|
|
89
|
-
LN
|
|
90
|
-
LOG
|
|
91
|
-
LOG_N
|
|
92
|
-
SIN
|
|
93
|
-
COS
|
|
94
|
-
TAN
|
|
9
|
+
enum Keys {
|
|
10
|
+
PLUS = "PLUS",
|
|
11
|
+
MINUS = "MINUS",
|
|
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",
|
|
95
42
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
THETA: "THETA",
|
|
43
|
+
PI = "PI",
|
|
44
|
+
THETA = "THETA",
|
|
99
45
|
|
|
100
|
-
UP
|
|
101
|
-
RIGHT
|
|
102
|
-
DOWN
|
|
103
|
-
LEFT
|
|
104
|
-
BACKSPACE
|
|
105
|
-
DISMISS
|
|
46
|
+
UP = "UP",
|
|
47
|
+
RIGHT = "RIGHT",
|
|
48
|
+
DOWN = "DOWN",
|
|
49
|
+
LEFT = "LEFT",
|
|
50
|
+
BACKSPACE = "BACKSPACE",
|
|
51
|
+
DISMISS = "DISMISS",
|
|
106
52
|
|
|
107
|
-
JUMP_OUT_PARENTHESES
|
|
108
|
-
JUMP_OUT_EXPONENT
|
|
109
|
-
JUMP_OUT_BASE
|
|
110
|
-
JUMP_INTO_NUMERATOR
|
|
111
|
-
JUMP_OUT_NUMERATOR
|
|
112
|
-
JUMP_OUT_DENOMINATOR
|
|
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.
|
|
113
59
|
|
|
114
|
-
NOOP
|
|
60
|
+
NOOP = "NOOP", // mobile native only
|
|
115
61
|
|
|
116
62
|
// Multi-functional keys.
|
|
117
|
-
|
|
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
|
|
118
66
|
|
|
119
67
|
// A custom key that captures an arbitrary number of symbols but has no
|
|
120
68
|
// 'default' symbol or action.
|
|
121
|
-
MANY
|
|
122
|
-
}
|
|
69
|
+
MANY = "MANY",
|
|
70
|
+
}
|
|
123
71
|
|
|
124
72
|
export default Keys;
|