@khanacademy/math-input 14.0.0 → 14.1.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.
@@ -0,0 +1 @@
1
+ export declare const libVersion = "__lib_version__";
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Khan Academy's new expression editor for the mobile web.",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "14.0.0",
6
+ "version": "14.1.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -20,7 +20,7 @@
20
20
  "source": "src/index.ts",
21
21
  "scripts": {},
22
22
  "dependencies": {
23
- "@khanacademy/perseus-core": "1.1.0",
23
+ "@khanacademy/perseus-core": "1.1.1",
24
24
  "mathquill": "git+https://git@github.com/Khan/mathquill.git#32d9f351aaa68537170b3120a52e99b8def3a2c3",
25
25
  "performance-now": "^0.2.0"
26
26
  },
@@ -34,7 +34,7 @@
34
34
  "aphrodite": "^1.1.0",
35
35
  "jquery": "^2.1.1",
36
36
  "katex": "^0.11.1",
37
- "perseus-build-settings": "^0.2.0",
37
+ "perseus-build-settings": "^0.2.1",
38
38
  "prop-types": "15.6.1",
39
39
  "react": "^16.8.0",
40
40
  "react-dom": "^16.8.0",
@@ -170,7 +170,6 @@ exports[`keypad should snapshot expanded: first render 1`] = `
170
170
  <div
171
171
  aria-label="Keypad"
172
172
  class="default_xu2jcg-o_O-keypadGrid_ztxlrb-o_O-expressionGrid_1fuqhx9"
173
- role="grid"
174
173
  tabindex="0"
175
174
  >
176
175
  <div
@@ -1223,7 +1222,6 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
1223
1222
  <div
1224
1223
  aria-label="Keypad"
1225
1224
  class="default_xu2jcg-o_O-keypadGrid_ztxlrb-o_O-expressionGrid_1fuqhx9"
1226
- role="grid"
1227
1225
  tabindex="0"
1228
1226
  >
1229
1227
  <div
@@ -151,7 +151,6 @@ export default function Keypad(props: Props) {
151
151
  <View style={styles.keypadInnerContainer}>
152
152
  <View
153
153
  style={[styles.keypadGrid, gridStyle]}
154
- role="grid"
155
154
  tabIndex={0}
156
155
  aria-label="Keypad"
157
156
  >
@@ -85,43 +85,47 @@ class ProvidedKeypad extends React.Component<Props> implements KeypadAPI {
85
85
  return ReactDOM.findDOMNode(this);
86
86
  };
87
87
 
88
+ onElementMounted: (element: any) => void = (element) => {
89
+ this.props.onAnalyticsEvent({
90
+ type: "math-input:keypad-opened",
91
+ payload: {
92
+ virtualKeypadVersion: "MATH_INPUT_KEYPAD_V1",
93
+ },
94
+ });
95
+
96
+ // Append the dispatch methods that we want to expose
97
+ // externally to the returned React element.
98
+ const elementWithDispatchMethods = {
99
+ ...element,
100
+ activate: this.activate,
101
+ dismiss: this.dismiss,
102
+ configure: this.configure,
103
+ setCursor: this.setCursor,
104
+ setKeyHandler: this.setKeyHandler,
105
+ getDOMNode: this.getDOMNode,
106
+ } as const;
107
+ this.props.onElementMounted?.(elementWithDispatchMethods);
108
+ };
109
+
110
+ onDismiss: () => void = () => {
111
+ this.props.onAnalyticsEvent({
112
+ type: "math-input:keypad-closed",
113
+ payload: {
114
+ virtualKeypadVersion: "MATH_INPUT_KEYPAD_V1",
115
+ },
116
+ });
117
+
118
+ this.props.onDismiss?.();
119
+ };
120
+
88
121
  render(): React.ReactNode {
89
- const {onElementMounted, onDismiss, style} = this.props;
122
+ const {style} = this.props;
90
123
 
91
124
  return (
92
125
  <Provider store={this.store}>
93
126
  <KeypadContainer
94
- onElementMounted={(element) => {
95
- this.props.onAnalyticsEvent({
96
- type: "math-input:keypad-opened",
97
- payload: {
98
- virtualKeypadVersion: "MATH_INPUT_KEYPAD_V1",
99
- },
100
- });
101
-
102
- // Append the dispatch methods that we want to expose
103
- // externally to the returned React element.
104
- const elementWithDispatchMethods = {
105
- ...element,
106
- activate: this.activate,
107
- dismiss: this.dismiss,
108
- configure: this.configure,
109
- setCursor: this.setCursor,
110
- setKeyHandler: this.setKeyHandler,
111
- getDOMNode: this.getDOMNode,
112
- } as const;
113
- onElementMounted?.(elementWithDispatchMethods);
114
- }}
115
- onDismiss={() => {
116
- this.props.onAnalyticsEvent({
117
- type: "math-input:keypad-closed",
118
- payload: {
119
- virtualKeypadVersion: "MATH_INPUT_KEYPAD_V1",
120
- },
121
- });
122
-
123
- onDismiss?.();
124
- }}
127
+ onElementMounted={this.onElementMounted}
128
+ onDismiss={this.onDismiss}
125
129
  style={style}
126
130
  />
127
131
  </Provider>
package/src/data/keys.ts CHANGED
@@ -1,120 +1,123 @@
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"
1
+ export const KeyArray = [
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",
112
112
 
113
113
  // Currently only used by
114
114
  // Perseus' Expression MathInput
115
- | "PHI"
116
- | "NTHROOT3"
117
- | "POW"
118
- | "LOG_B";
115
+ "PHI",
116
+ "NTHROOT3",
117
+ "POW",
118
+ "LOG_B",
119
+ ] as const;
120
+
121
+ type Key = typeof KeyArray[number];
119
122
 
120
123
  export default Key;
package/src/index.ts CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  import "../less/main.less";
6
6
 
7
+ export {libVersion} from "./version";
8
+
7
9
  // MathInput input field (MathQuill wrapper)
8
10
  export {default as KeypadInput} from "./components/input/math-input";
9
11
 
@@ -41,6 +43,7 @@ export type {KeypadAPI, KeypadConfiguration} from "./types";
41
43
 
42
44
  // Key list, configuration map, and types
43
45
  export type {default as Keys} from "./data/keys";
46
+ export {KeyArray} from "./data/keys";
44
47
  export {default as KeyConfigs} from "./data/key-configs";
45
48
  export {type KeyType, KeypadType} from "./enums";
46
49
 
package/src/version.ts ADDED
@@ -0,0 +1,10 @@
1
+ // This file is processed by a Rollup plugin (replace) to inject the production
2
+ // version number during the release build.
3
+ // In dev, you'll never see the version number.
4
+
5
+ import {addLibraryVersionToPerseusDebug} from "@khanacademy/perseus-core";
6
+
7
+ const libName = "@khanacademy/math-input";
8
+ export const libVersion = "__lib_version__";
9
+
10
+ addLibraryVersionToPerseusDebug(libName, libVersion);
@@ -6,5 +6,6 @@
6
6
  },
7
7
  "references": [
8
8
  {"path": "../perseus-core/tsconfig-build.json"},
9
+ {"path": "../perseus-core/tsconfig-build.json"},
9
10
  ]
10
11
  }