@khanacademy/math-input 1.0.1 → 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 +5 -1
- 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-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/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.js +362 -391
- 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.d.ts +3 -6
- package/dist/index.js +379 -406
- package/dist/index.js.flow +3 -6
- package/dist/index.js.map +1 -1
- package/dist/store/actions.d.ts +3 -3
- package/dist/store/actions.js.flow +5 -4
- package/dist/store/shared.d.ts +2 -1
- package/dist/store/shared.js.flow +2 -1
- package/dist/store/types.d.ts +4 -5
- package/dist/store/types.js.flow +4 -5
- package/dist/types.d.ts +15 -16
- package/dist/types.js.flow +20 -20
- 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-button.tsx +20 -21
- package/src/components/keypad-container.tsx +8 -9
- 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/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 +8 -8
- package/src/store/actions.ts +4 -3
- package/src/store/echo-reducer.ts +5 -5
- package/src/store/index.ts +1 -2
- package/src/store/input-reducer.ts +4 -4
- package/src/store/layout-reducer.ts +9 -9
- package/src/store/pager-reducer.ts +3 -3
- package/src/store/shared.ts +4 -4
- package/src/store/types.ts +4 -5
- package/src/types.ts +20 -20
- package/src/utils.ts +3 -3
- package/tsconfig-build.tsbuildinfo +1 -0
- package/dist/consts.d.ts +0 -51
- package/dist/consts.js.flow +0 -66
- package/src/consts.ts +0 -91
- package/tsconfig.tsbuildinfo +0 -1
- /package/{tsconfig.json → tsconfig-build.json} +0 -0
|
@@ -6,7 +6,7 @@ import {StyleSheet, css} from "aphrodite";
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import {connect} from "react-redux";
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {BorderDirection, BorderStyles, KeyType} from "../enums";
|
|
10
10
|
import {View} from "../fake-react-native-web/index";
|
|
11
11
|
|
|
12
12
|
import {
|
|
@@ -23,9 +23,8 @@ import CornerDecal from "./corner-decal";
|
|
|
23
23
|
import Icon from "./icon";
|
|
24
24
|
import MultiSymbolGrid from "./multi-symbol-grid";
|
|
25
25
|
|
|
26
|
-
import type {KeyType} from "../consts";
|
|
27
26
|
import type {State} from "../store/types";
|
|
28
|
-
import type {Border, KeyConfig,
|
|
27
|
+
import type {Border, KeyConfig, IconConfig} from "../types";
|
|
29
28
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
30
29
|
|
|
31
30
|
interface ReduxProps {
|
|
@@ -41,7 +40,7 @@ interface Props extends ReduxProps {
|
|
|
41
40
|
focused: boolean;
|
|
42
41
|
popoverEnabled: boolean;
|
|
43
42
|
type: KeyType;
|
|
44
|
-
icon:
|
|
43
|
+
icon: IconConfig;
|
|
45
44
|
style?: StyleType;
|
|
46
45
|
onTouchCancel?: (evt: React.TouchEvent<HTMLDivElement>) => void;
|
|
47
46
|
onTouchEnd?: (evt: React.TouchEvent<HTMLDivElement>) => void;
|
|
@@ -102,7 +101,7 @@ class KeypadButton extends React.PureComponent<Props> {
|
|
|
102
101
|
// object. This method must be called whenever a property that
|
|
103
102
|
// influences the possible outcomes of `this._getFocusStyle` and
|
|
104
103
|
// `this._getButtonStyle` changes (such as `this.buttonSizeStyle`).
|
|
105
|
-
for (const type of Object.
|
|
104
|
+
for (const type of Object.values(KeyType)) {
|
|
106
105
|
css(View.styles.initial, ...this._getFocusStyle(type));
|
|
107
106
|
|
|
108
107
|
for (const borders of Object.values(BorderStyles)) {
|
|
@@ -114,11 +113,11 @@ class KeypadButton extends React.PureComponent<Props> {
|
|
|
114
113
|
}
|
|
115
114
|
};
|
|
116
115
|
|
|
117
|
-
_getFocusStyle = (type) => {
|
|
116
|
+
_getFocusStyle = (type: KeyType) => {
|
|
118
117
|
let focusBackgroundStyle;
|
|
119
118
|
if (
|
|
120
|
-
type ===
|
|
121
|
-
type ===
|
|
119
|
+
type === KeyType.INPUT_NAVIGATION ||
|
|
120
|
+
type === KeyType.KEYPAD_NAVIGATION
|
|
122
121
|
) {
|
|
123
122
|
focusBackgroundStyle = styles.light;
|
|
124
123
|
} else {
|
|
@@ -132,35 +131,35 @@ class KeypadButton extends React.PureComponent<Props> {
|
|
|
132
131
|
// Select the appropriate style for the button.
|
|
133
132
|
let backgroundStyle;
|
|
134
133
|
switch (type) {
|
|
135
|
-
case
|
|
134
|
+
case KeyType.EMPTY:
|
|
136
135
|
backgroundStyle = styles.empty;
|
|
137
136
|
break;
|
|
138
137
|
|
|
139
|
-
case
|
|
140
|
-
case
|
|
138
|
+
case KeyType.MANY:
|
|
139
|
+
case KeyType.VALUE:
|
|
141
140
|
backgroundStyle = styles.value;
|
|
142
141
|
break;
|
|
143
142
|
|
|
144
|
-
case
|
|
143
|
+
case KeyType.OPERATOR:
|
|
145
144
|
backgroundStyle = styles.operator;
|
|
146
145
|
break;
|
|
147
146
|
|
|
148
|
-
case
|
|
149
|
-
case
|
|
147
|
+
case KeyType.INPUT_NAVIGATION:
|
|
148
|
+
case KeyType.KEYPAD_NAVIGATION:
|
|
150
149
|
backgroundStyle = styles.control;
|
|
151
150
|
break;
|
|
152
151
|
|
|
153
|
-
case
|
|
152
|
+
case KeyType.ECHO:
|
|
154
153
|
backgroundStyle = null;
|
|
155
154
|
break;
|
|
156
155
|
}
|
|
157
156
|
|
|
158
157
|
const borderStyle = [];
|
|
159
|
-
if (borders.includes(
|
|
158
|
+
if (borders.includes(BorderDirection.LEFT)) {
|
|
160
159
|
// @ts-expect-error TS2345
|
|
161
160
|
borderStyle.push(styles.leftBorder);
|
|
162
161
|
}
|
|
163
|
-
if (borders.includes(
|
|
162
|
+
if (borders.includes(BorderDirection.BOTTOM)) {
|
|
164
163
|
// @ts-expect-error TS2345
|
|
165
164
|
borderStyle.push(styles.bottomBorder);
|
|
166
165
|
}
|
|
@@ -169,7 +168,7 @@ class KeypadButton extends React.PureComponent<Props> {
|
|
|
169
168
|
styles.buttonBase,
|
|
170
169
|
backgroundStyle,
|
|
171
170
|
...borderStyle,
|
|
172
|
-
type ===
|
|
171
|
+
type === KeyType.ECHO && styles.echo,
|
|
173
172
|
this.buttonSizeStyle,
|
|
174
173
|
// React Native allows you to set the 'style' props on user defined
|
|
175
174
|
// components.
|
|
@@ -198,7 +197,7 @@ class KeypadButton extends React.PureComponent<Props> {
|
|
|
198
197
|
// We render in the focus state if the key is focused, or if it's an
|
|
199
198
|
// echo.
|
|
200
199
|
const renderFocused =
|
|
201
|
-
(!disabled && focused) || popoverEnabled || type ===
|
|
200
|
+
(!disabled && focused) || popoverEnabled || type === KeyType.ECHO;
|
|
202
201
|
const buttonStyle = this._getButtonStyle(type, borders, style);
|
|
203
202
|
const focusStyle = this._getFocusStyle(type);
|
|
204
203
|
const iconWrapperStyle = [
|
|
@@ -219,9 +218,9 @@ class KeypadButton extends React.PureComponent<Props> {
|
|
|
219
218
|
childKeys &&
|
|
220
219
|
childKeys.length > 0 && <CornerDecal style={styles.decalInset} />;
|
|
221
220
|
|
|
222
|
-
if (type ===
|
|
221
|
+
if (type === KeyType.EMPTY) {
|
|
223
222
|
return <View style={buttonStyle} {...eventHandlers} />;
|
|
224
|
-
} else if (type ===
|
|
223
|
+
} else if (type === KeyType.MANY) {
|
|
225
224
|
// TODO(charlie): Make the long-press interaction accessible. See
|
|
226
225
|
// the TODO in key-configs.js for more.
|
|
227
226
|
const manyButtonA11yMarkup = {
|
|
@@ -2,7 +2,7 @@ import {StyleSheet} from "aphrodite";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {connect} from "react-redux";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {LayoutMode, KeypadType} from "../enums";
|
|
6
6
|
import {View} from "../fake-react-native-web/index";
|
|
7
7
|
import {setPageSize} from "../store/actions";
|
|
8
8
|
|
|
@@ -18,7 +18,6 @@ import NavigationPad from "./navigation-pad";
|
|
|
18
18
|
import Styles from "./styles";
|
|
19
19
|
import * as zIndexes from "./z-indexes";
|
|
20
20
|
|
|
21
|
-
import type {KeypadType} from "../consts";
|
|
22
21
|
import type {State as ReduxState} from "../store/types";
|
|
23
22
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
24
23
|
|
|
@@ -28,7 +27,7 @@ interface ReduxProps {
|
|
|
28
27
|
active?: boolean;
|
|
29
28
|
extraKeys?: ReadonlyArray<string>;
|
|
30
29
|
keypadType?: KeypadType;
|
|
31
|
-
layoutMode?:
|
|
30
|
+
layoutMode?: LayoutMode;
|
|
32
31
|
navigationPadEnabled?: boolean;
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -128,8 +127,8 @@ class KeypadContainer extends React.Component<Props, State> {
|
|
|
128
127
|
// crop themselves. At least we're colocating all the layout
|
|
129
128
|
// information in this component, though.
|
|
130
129
|
roundTopLeft:
|
|
131
|
-
layoutMode ===
|
|
132
|
-
roundTopRight: layoutMode ===
|
|
130
|
+
layoutMode === LayoutMode.COMPACT && !navigationPadEnabled,
|
|
131
|
+
roundTopRight: layoutMode === LayoutMode.COMPACT,
|
|
133
132
|
};
|
|
134
133
|
|
|
135
134
|
// Select the appropriate keyboard given the type.
|
|
@@ -140,10 +139,10 @@ class KeypadContainer extends React.Component<Props, State> {
|
|
|
140
139
|
// clear what that format would look like exactly. Plus, there aren't
|
|
141
140
|
// very many of them. So to keep us moving, we'll just hardcode.
|
|
142
141
|
switch (keypadType) {
|
|
143
|
-
case
|
|
142
|
+
case KeypadType.FRACTION:
|
|
144
143
|
return <FractionKeypad {...keypadProps} />;
|
|
145
144
|
|
|
146
|
-
case
|
|
145
|
+
case KeypadType.EXPRESSION:
|
|
147
146
|
return <ExpressionKeypad {...keypadProps} />;
|
|
148
147
|
|
|
149
148
|
default:
|
|
@@ -186,7 +185,7 @@ class KeypadContainer extends React.Component<Props, State> {
|
|
|
186
185
|
const keypadStyle = [
|
|
187
186
|
row,
|
|
188
187
|
styles.keypadBorder,
|
|
189
|
-
layoutMode ===
|
|
188
|
+
layoutMode === LayoutMode.FULLSCREEN
|
|
190
189
|
? styles.fullscreen
|
|
191
190
|
: styles.compact,
|
|
192
191
|
];
|
|
@@ -211,7 +210,7 @@ class KeypadContainer extends React.Component<Props, State> {
|
|
|
211
210
|
>
|
|
212
211
|
{navigationPadEnabled && (
|
|
213
212
|
<NavigationPad
|
|
214
|
-
roundTopLeft={layoutMode ===
|
|
213
|
+
roundTopLeft={layoutMode === LayoutMode.COMPACT}
|
|
215
214
|
style={styles.navigationPadContainer}
|
|
216
215
|
/>
|
|
217
216
|
)}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
|
|
8
|
-
import {KeyTypes} from "../consts";
|
|
9
8
|
import KeyConfigs from "../data/key-configs";
|
|
10
9
|
import Keys from "../data/keys";
|
|
10
|
+
import {KeyType} from "../enums";
|
|
11
11
|
|
|
12
12
|
import EmptyKeypadButton from "./empty-keypad-button";
|
|
13
13
|
import TouchableKeypadButton from "./touchable-keypad-button";
|
|
@@ -35,7 +35,7 @@ class ManyKeypadButton extends React.Component<Props> {
|
|
|
35
35
|
} else {
|
|
36
36
|
const keyConfig = {
|
|
37
37
|
id: Keys.MANY,
|
|
38
|
-
type:
|
|
38
|
+
type: KeyType.MANY,
|
|
39
39
|
childKeyIds: keys,
|
|
40
40
|
};
|
|
41
41
|
return <TouchableKeypadButton keyConfig={keyConfig} {...rest} />;
|
|
@@ -6,20 +6,19 @@
|
|
|
6
6
|
import {StyleSheet} from "aphrodite";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {IconType} from "../enums";
|
|
10
10
|
import {View} from "../fake-react-native-web/index";
|
|
11
|
+
import {IconConfig} from "../types";
|
|
11
12
|
|
|
12
13
|
import {iconSizeHeightPx, iconSizeWidthPx} from "./common-style";
|
|
13
14
|
import Icon from "./icon";
|
|
14
15
|
import Styles from "./styles";
|
|
15
16
|
|
|
16
|
-
import type {Icon as IconType} from "../types";
|
|
17
|
-
|
|
18
17
|
const {row, column, centered, fullWidth} = Styles;
|
|
19
18
|
|
|
20
19
|
type Props = {
|
|
21
20
|
focused: boolean;
|
|
22
|
-
icons: ReadonlyArray<
|
|
21
|
+
icons: ReadonlyArray<IconConfig>;
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
class MultiSymbolGrid extends React.Component<Props> {
|
|
@@ -32,7 +31,7 @@ class MultiSymbolGrid extends React.Component<Props> {
|
|
|
32
31
|
// Supporting other types of icons is possible but would require
|
|
33
32
|
// some styles coercion and doesn't seem worthwhile right now.
|
|
34
33
|
icons.forEach((icon) => {
|
|
35
|
-
if (icon.type !==
|
|
34
|
+
if (icon.type !== IconType.MATH) {
|
|
36
35
|
throw new Error(
|
|
37
36
|
`Received invalid icon: type=${icon.type}, ` +
|
|
38
37
|
`data=${icon.data}`,
|
|
@@ -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 {
|
|
@@ -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],
|