@khanacademy/math-input 17.4.1 → 18.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/dist/components/i18n-context.d.ts +16 -0
- package/dist/components/input/math-input.d.ts +6 -0
- package/dist/components/input/math-wrapper.d.ts +4 -2
- package/dist/components/input/mathquill-instance.d.ts +2 -1
- package/dist/components/key-handlers/key-translator.d.ts +1 -2
- package/dist/components/keypad/utils.d.ts +2 -1
- package/dist/data/key-configs.d.ts +119 -2
- package/dist/es/index.js +345 -238
- package/dist/es/index.js.map +1 -1
- package/dist/es/strings.js +251 -0
- package/dist/es/strings.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +385 -246
- package/dist/index.js.map +1 -1
- package/dist/strings.d.ts +96 -0
- package/dist/strings.js +274 -101
- package/dist/strings.js.map +1 -0
- package/dist/utils.d.ts +5 -2
- package/package.json +21 -9
- package/dist/components/input/strings.d.ts +0 -19
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MathInputI18nContext provides a way to set the strings and locale that are
|
|
3
|
+
* used inside the Math Input package.
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import type { MathInputStrings } from "../strings";
|
|
8
|
+
type I18nContextType = {
|
|
9
|
+
strings: MathInputStrings;
|
|
10
|
+
locale: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const MathInputI18nContext: React.Context<I18nContextType>;
|
|
13
|
+
type Props = React.PropsWithChildren<I18nContextType>;
|
|
14
|
+
export declare function MathInputI18nContextProvider({ children, strings, locale, }: Props): JSX.Element;
|
|
15
|
+
export declare const useMathInputI18n: () => I18nContextType;
|
|
16
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { MathInputI18nContext } from "../i18n-context";
|
|
2
3
|
import type { KeypadAPI, KeypadContextType } from "../../types";
|
|
3
4
|
type Props = {
|
|
4
5
|
keypadElement?: KeypadAPI;
|
|
@@ -24,6 +25,11 @@ type State = {
|
|
|
24
25
|
showInputFocusStyle: boolean;
|
|
25
26
|
};
|
|
26
27
|
declare class MathInput extends React.Component<Props, State> {
|
|
28
|
+
static contextType: React.Context<{
|
|
29
|
+
strings: import("../../strings").MathInputStrings;
|
|
30
|
+
locale: string;
|
|
31
|
+
}>;
|
|
32
|
+
context: React.ContextType<typeof MathInputI18nContext>;
|
|
27
33
|
didTouchOutside: boolean | null | undefined;
|
|
28
34
|
didScroll: boolean | null | undefined;
|
|
29
35
|
mathField: any;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { MathFieldInterface } from "./mathquill-types";
|
|
1
|
+
import type { MathFieldInterface, MathFieldUpdaterCallback } from "./mathquill-types";
|
|
2
2
|
import type Key from "../../data/keys";
|
|
3
|
+
import type { MathInputStrings } from "../../strings";
|
|
3
4
|
/**
|
|
4
5
|
* This file contains a wrapper around MathQuill so that we can provide a
|
|
5
6
|
* more regular interface for the functionality we need while insulating us
|
|
@@ -8,7 +9,8 @@ import type Key from "../../data/keys";
|
|
|
8
9
|
declare class MathWrapper {
|
|
9
10
|
mathField: MathFieldInterface;
|
|
10
11
|
callbacks: any;
|
|
11
|
-
|
|
12
|
+
mobileKeyTranslator: Record<Key, MathFieldUpdaterCallback>;
|
|
13
|
+
constructor(element: any, strings: MathInputStrings, locale: string, callbacks?: {});
|
|
12
14
|
focus(): void;
|
|
13
15
|
blur(): void;
|
|
14
16
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MathQuillInterface, MathFieldConfig, MathFieldInterface } from "./mathquill-types";
|
|
2
|
+
import type { MathInputStrings } from "../../strings";
|
|
2
3
|
export declare const mathQuillInstance: MathQuillInterface;
|
|
3
4
|
/**
|
|
4
5
|
* Creates a new [MathField](http://docs.mathquill.com/en/latest/Api_Methods/#mqmathfieldhtml_element-config)
|
|
@@ -11,4 +12,4 @@ export declare const mathQuillInstance: MathQuillInterface;
|
|
|
11
12
|
* This allows callers to do minimal configuration as only configs
|
|
12
13
|
* that vary from the default need to be provided.
|
|
13
14
|
*/
|
|
14
|
-
export declare function createMathField(container: HTMLDivElement | HTMLSpanElement, configCallback?: (baseConfig: MathFieldConfig) => MathFieldConfig): MathFieldInterface;
|
|
15
|
+
export declare function createMathField(container: HTMLDivElement | HTMLSpanElement, strings: MathInputStrings, configCallback?: (baseConfig: MathFieldConfig) => MathFieldConfig): MathFieldInterface;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type Key from "../../data/keys";
|
|
2
2
|
import type { MathFieldUpdaterCallback } from "../input/mathquill-types";
|
|
3
|
-
declare const
|
|
4
|
-
export default keyToMathquillMap;
|
|
3
|
+
export declare const getKeyTranslator: (locale: string) => Record<Key, MathFieldUpdaterCallback>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { CursorContext } from "../input/cursor-contexts";
|
|
2
|
+
import type { MathInputStrings } from "../../strings";
|
|
2
3
|
export declare const expandedViewThreshold = 500;
|
|
3
|
-
export declare function getCursorContextConfig(cursorContext?: (typeof CursorContext)[keyof typeof CursorContext]): import("../../types").NonManyKeyConfig | null;
|
|
4
|
+
export declare function getCursorContextConfig(strings: MathInputStrings, cursorContext?: (typeof CursorContext)[keyof typeof CursorContext]): import("../../types").NonManyKeyConfig | null;
|
|
@@ -1,6 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains configuration settings for the buttons in the keypad.
|
|
3
|
+
*/
|
|
1
4
|
import type Key from "./keys";
|
|
5
|
+
import type { MathInputStrings } from "../strings";
|
|
2
6
|
import type { KeyConfig } from "../types";
|
|
3
|
-
declare const KeyConfigs: {
|
|
4
|
-
|
|
7
|
+
declare const KeyConfigs: (strings: MathInputStrings) => {
|
|
8
|
+
MANY: KeyConfig;
|
|
9
|
+
a: KeyConfig;
|
|
10
|
+
b: KeyConfig;
|
|
11
|
+
i: KeyConfig;
|
|
12
|
+
p: KeyConfig;
|
|
13
|
+
q: KeyConfig;
|
|
14
|
+
s: KeyConfig;
|
|
15
|
+
u: KeyConfig;
|
|
16
|
+
g: KeyConfig;
|
|
17
|
+
x: KeyConfig;
|
|
18
|
+
y: KeyConfig;
|
|
19
|
+
PLUS: KeyConfig;
|
|
20
|
+
MINUS: KeyConfig;
|
|
21
|
+
NEGATIVE: KeyConfig;
|
|
22
|
+
TIMES: KeyConfig;
|
|
23
|
+
DIVIDE: KeyConfig;
|
|
24
|
+
DECIMAL: KeyConfig;
|
|
25
|
+
PERIOD: KeyConfig;
|
|
26
|
+
PERCENT: KeyConfig;
|
|
27
|
+
CDOT: KeyConfig;
|
|
28
|
+
EQUAL: KeyConfig;
|
|
29
|
+
NEQ: KeyConfig;
|
|
30
|
+
GT: KeyConfig;
|
|
31
|
+
LT: KeyConfig;
|
|
32
|
+
GEQ: KeyConfig;
|
|
33
|
+
LEQ: KeyConfig;
|
|
34
|
+
FRAC_INCLUSIVE: KeyConfig;
|
|
35
|
+
FRAC_EXCLUSIVE: KeyConfig;
|
|
36
|
+
FRAC: KeyConfig;
|
|
37
|
+
EXP: KeyConfig;
|
|
38
|
+
EXP_2: KeyConfig;
|
|
39
|
+
EXP_3: KeyConfig;
|
|
40
|
+
SQRT: KeyConfig;
|
|
41
|
+
CUBE_ROOT: KeyConfig;
|
|
42
|
+
RADICAL: KeyConfig;
|
|
43
|
+
LEFT_PAREN: KeyConfig;
|
|
44
|
+
RIGHT_PAREN: KeyConfig;
|
|
45
|
+
LN: KeyConfig;
|
|
46
|
+
LOG: KeyConfig;
|
|
47
|
+
LOG_N: KeyConfig;
|
|
48
|
+
SIN: KeyConfig;
|
|
49
|
+
COS: KeyConfig;
|
|
50
|
+
TAN: KeyConfig;
|
|
51
|
+
PI: KeyConfig;
|
|
52
|
+
THETA: KeyConfig;
|
|
53
|
+
UP: KeyConfig;
|
|
54
|
+
RIGHT: KeyConfig;
|
|
55
|
+
DOWN: KeyConfig;
|
|
56
|
+
LEFT: KeyConfig;
|
|
57
|
+
BACKSPACE: KeyConfig;
|
|
58
|
+
DISMISS: KeyConfig;
|
|
59
|
+
JUMP_OUT_PARENTHESES: KeyConfig;
|
|
60
|
+
JUMP_OUT_EXPONENT: KeyConfig;
|
|
61
|
+
JUMP_OUT_BASE: KeyConfig;
|
|
62
|
+
JUMP_INTO_NUMERATOR: KeyConfig;
|
|
63
|
+
JUMP_OUT_NUMERATOR: KeyConfig;
|
|
64
|
+
JUMP_OUT_DENOMINATOR: KeyConfig;
|
|
65
|
+
NOOP: KeyConfig;
|
|
66
|
+
NUM_0: KeyConfig;
|
|
67
|
+
NUM_1: KeyConfig;
|
|
68
|
+
NUM_2: KeyConfig;
|
|
69
|
+
NUM_3: KeyConfig;
|
|
70
|
+
NUM_4: KeyConfig;
|
|
71
|
+
NUM_5: KeyConfig;
|
|
72
|
+
NUM_6: KeyConfig;
|
|
73
|
+
NUM_7: KeyConfig;
|
|
74
|
+
NUM_8: KeyConfig;
|
|
75
|
+
NUM_9: KeyConfig;
|
|
76
|
+
c: KeyConfig;
|
|
77
|
+
d: KeyConfig;
|
|
78
|
+
e: KeyConfig;
|
|
79
|
+
f: KeyConfig;
|
|
80
|
+
h: KeyConfig;
|
|
81
|
+
j: KeyConfig;
|
|
82
|
+
k: KeyConfig;
|
|
83
|
+
l: KeyConfig;
|
|
84
|
+
m: KeyConfig;
|
|
85
|
+
n: KeyConfig;
|
|
86
|
+
o: KeyConfig;
|
|
87
|
+
r: KeyConfig;
|
|
88
|
+
t: KeyConfig;
|
|
89
|
+
v: KeyConfig;
|
|
90
|
+
w: KeyConfig;
|
|
91
|
+
z: KeyConfig;
|
|
92
|
+
A: KeyConfig;
|
|
93
|
+
B: KeyConfig;
|
|
94
|
+
C: KeyConfig;
|
|
95
|
+
D: KeyConfig;
|
|
96
|
+
E: KeyConfig;
|
|
97
|
+
F: KeyConfig;
|
|
98
|
+
G: KeyConfig;
|
|
99
|
+
H: KeyConfig;
|
|
100
|
+
I: KeyConfig;
|
|
101
|
+
J: KeyConfig;
|
|
102
|
+
K: KeyConfig;
|
|
103
|
+
L: KeyConfig;
|
|
104
|
+
M: KeyConfig;
|
|
105
|
+
N: KeyConfig;
|
|
106
|
+
O: KeyConfig;
|
|
107
|
+
P: KeyConfig;
|
|
108
|
+
Q: KeyConfig;
|
|
109
|
+
R: KeyConfig;
|
|
110
|
+
S: KeyConfig;
|
|
111
|
+
T: KeyConfig;
|
|
112
|
+
U: KeyConfig;
|
|
113
|
+
V: KeyConfig;
|
|
114
|
+
W: KeyConfig;
|
|
115
|
+
X: KeyConfig;
|
|
116
|
+
Y: KeyConfig;
|
|
117
|
+
Z: KeyConfig;
|
|
118
|
+
PHI: KeyConfig;
|
|
119
|
+
NTHROOT3: KeyConfig;
|
|
120
|
+
POW: KeyConfig;
|
|
121
|
+
LOG_B: KeyConfig;
|
|
5
122
|
};
|
|
6
123
|
export default KeyConfigs;
|