@khanacademy/math-input 5.0.1 → 6.0.1
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 +16 -0
- package/dist/components/input/cursor-contexts.d.ts +9 -9
- package/dist/components/input/cursor-contexts.js.flow +7 -8
- package/dist/components/input/math-wrapper.d.ts +1 -1
- package/dist/components/input/math-wrapper.js.flow +8 -2
- package/dist/components/input/mathquill-helpers.d.ts +1 -1
- package/dist/components/input/mathquill-helpers.js.flow +1 -1
- package/dist/components/keypad/index.d.ts +4 -3
- package/dist/components/keypad/index.js.flow +7 -3
- package/dist/components/keypad/shared-keys.d.ts +1 -1
- package/dist/components/keypad/shared-keys.js.flow +4 -1
- package/dist/components/keypad-legacy/expression-keypad.d.ts +1 -1
- package/dist/components/keypad-legacy/expression-keypad.js.flow +4 -1
- package/dist/components/keypad-legacy/fraction-keypad.d.ts +1 -1
- package/dist/components/keypad-legacy/fraction-keypad.js.flow +4 -1
- package/dist/es/index.js +34 -21
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +34 -21
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.js.flow +2 -2
- package/package.json +1 -1
- package/src/components/input/cursor-contexts.ts +9 -9
- package/src/components/input/mathquill-helpers.ts +1 -1
- package/src/components/keypad/__tests__/keypad.test.tsx +37 -2
- package/src/components/keypad/index.tsx +10 -4
- package/src/components/keypad/keypad-button.tsx +6 -14
- package/src/components/keypad/keypad-mathquill.stories.tsx +3 -3
- package/src/components/keypad/shared-keys.tsx +4 -2
- package/src/components/keypad-legacy/expression-keypad.tsx +1 -1
- package/src/components/keypad-legacy/fraction-keypad.tsx +1 -1
- package/src/components/tabbar/item.tsx +6 -0
- package/src/types.ts +2 -3
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @khanacademy/math-input
|
|
2
2
|
|
|
3
|
+
## 6.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8d1745c1: Removed double focus outline from keypad buttons
|
|
8
|
+
|
|
9
|
+
## 6.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- 36e3a212: Make v2 keypad dismiss button optional, hidden by default
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- fa735526: Fix issue with uses of CursorContext not being converted by flowgen
|
|
18
|
+
|
|
3
19
|
## 5.0.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
* now, we show the dismiss button rather than allowing the user to jump out of
|
|
10
10
|
* the radical.
|
|
11
11
|
*/
|
|
12
|
-
export declare
|
|
13
|
-
NONE
|
|
14
|
-
IN_PARENS
|
|
15
|
-
IN_SUPER_SCRIPT
|
|
16
|
-
IN_SUB_SCRIPT
|
|
17
|
-
IN_NUMERATOR
|
|
18
|
-
IN_DENOMINATOR
|
|
19
|
-
BEFORE_FRACTION
|
|
20
|
-
}
|
|
12
|
+
export declare const CursorContext: {
|
|
13
|
+
readonly NONE: "NONE";
|
|
14
|
+
readonly IN_PARENS: "IN_PARENS";
|
|
15
|
+
readonly IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT";
|
|
16
|
+
readonly IN_SUB_SCRIPT: "IN_SUB_SCRIPT";
|
|
17
|
+
readonly IN_NUMERATOR: "IN_NUMERATOR";
|
|
18
|
+
readonly IN_DENOMINATOR: "IN_DENOMINATOR";
|
|
19
|
+
readonly BEFORE_FRACTION: "BEFORE_FRACTION";
|
|
20
|
+
};
|
|
@@ -15,13 +15,12 @@
|
|
|
15
15
|
* now, we show the dismiss button rather than allowing the user to jump out of
|
|
16
16
|
* the radical.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
18
|
declare export var CursorContext: {|
|
|
20
|
-
+NONE: "NONE",
|
|
21
|
-
+IN_PARENS: "IN_PARENS",
|
|
22
|
-
+IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT",
|
|
23
|
-
+IN_SUB_SCRIPT: "IN_SUB_SCRIPT",
|
|
24
|
-
+IN_NUMERATOR: "IN_NUMERATOR",
|
|
25
|
-
+IN_DENOMINATOR: "IN_DENOMINATOR",
|
|
26
|
-
+BEFORE_FRACTION: "BEFORE_FRACTION",
|
|
19
|
+
+NONE: "NONE",
|
|
20
|
+
+IN_PARENS: "IN_PARENS",
|
|
21
|
+
+IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT",
|
|
22
|
+
+IN_SUB_SCRIPT: "IN_SUB_SCRIPT",
|
|
23
|
+
+IN_NUMERATOR: "IN_NUMERATOR",
|
|
24
|
+
+IN_DENOMINATOR: "IN_DENOMINATOR",
|
|
25
|
+
+BEFORE_FRACTION: "BEFORE_FRACTION",
|
|
27
26
|
|};
|
|
@@ -31,7 +31,7 @@ declare class MathWrapper {
|
|
|
31
31
|
*/
|
|
32
32
|
setCursorPosition(x: number, y: number, hitNode: HTMLElement): void;
|
|
33
33
|
getCursor(): any;
|
|
34
|
-
contextForCursor():
|
|
34
|
+
contextForCursor(): "NONE" | "IN_PARENS" | "IN_SUPER_SCRIPT" | "IN_SUB_SCRIPT" | "IN_NUMERATOR" | "IN_DENOMINATOR" | "BEFORE_FRACTION";
|
|
35
35
|
getSelection(): any;
|
|
36
36
|
getContent(): string;
|
|
37
37
|
setContent(latex: string): void;
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import * as $Flowgen$Import$_2e__2f_cursor_2d_contexts from "./cursor-contexts";
|
|
8
7
|
import Key from "../../data/keys";
|
|
9
8
|
import { Cursor } from "../../types";
|
|
10
9
|
import { MathFieldInterface } from "./mathquill-types";
|
|
@@ -39,7 +38,14 @@ declare class MathWrapper {
|
|
|
39
38
|
*/
|
|
40
39
|
setCursorPosition(x: number, y: number, hitNode: HTMLElement): void;
|
|
41
40
|
getCursor(): any;
|
|
42
|
-
contextForCursor():
|
|
41
|
+
contextForCursor():
|
|
42
|
+
| "NONE"
|
|
43
|
+
| "IN_PARENS"
|
|
44
|
+
| "IN_SUPER_SCRIPT"
|
|
45
|
+
| "IN_SUB_SCRIPT"
|
|
46
|
+
| "IN_NUMERATOR"
|
|
47
|
+
| "IN_DENOMINATOR"
|
|
48
|
+
| "BEFORE_FRACTION";
|
|
43
49
|
getSelection(): any;
|
|
44
50
|
getContent(): string;
|
|
45
51
|
setContent(latex: string): void;
|
|
@@ -43,4 +43,4 @@ export declare function maybeFindCommandBeforeParens(leftParenNode: any): {
|
|
|
43
43
|
startNode: any;
|
|
44
44
|
endNode: any;
|
|
45
45
|
} | null;
|
|
46
|
-
export declare function getCursorContext(mathField?: MathFieldInterface): CursorContext;
|
|
46
|
+
export declare function getCursorContext(mathField?: MathFieldInterface): typeof CursorContext[keyof typeof CursorContext];
|
|
@@ -4,16 +4,17 @@ import { ClickKeyCallback } from "../../types";
|
|
|
4
4
|
import { CursorContext } from "../input/cursor-contexts";
|
|
5
5
|
import type { SendEventFn } from "@khanacademy/perseus-core";
|
|
6
6
|
export type Props = {
|
|
7
|
-
onClickKey: ClickKeyCallback;
|
|
8
|
-
cursorContext?: CursorContext;
|
|
9
|
-
trigonometry?: boolean;
|
|
10
7
|
extraKeys: ReadonlyArray<Key>;
|
|
8
|
+
cursorContext?: typeof CursorContext[keyof typeof CursorContext];
|
|
9
|
+
showDismiss?: boolean;
|
|
11
10
|
multiplicationDot?: boolean;
|
|
12
11
|
divisionKey?: boolean;
|
|
12
|
+
trigonometry?: boolean;
|
|
13
13
|
preAlgebra?: boolean;
|
|
14
14
|
logarithms?: boolean;
|
|
15
15
|
basicRelations?: boolean;
|
|
16
16
|
advancedRelations?: boolean;
|
|
17
|
+
onClickKey: ClickKeyCallback;
|
|
17
18
|
sendEvent: SendEventFn;
|
|
18
19
|
};
|
|
19
20
|
declare function Keypad(props: Props): JSX.Element;
|
|
@@ -9,16 +9,20 @@ import { ClickKeyCallback } from "../../types";
|
|
|
9
9
|
import { CursorContext } from "../input/cursor-contexts";
|
|
10
10
|
import type { SendEventFn } from "@khanacademy/perseus-core";
|
|
11
11
|
export type Props = {|
|
|
12
|
-
onClickKey: ClickKeyCallback,
|
|
13
|
-
cursorContext?: CursorContext,
|
|
14
|
-
trigonometry?: boolean,
|
|
15
12
|
extraKeys: $ReadOnlyArray<Key>,
|
|
13
|
+
cursorContext?: $ElementType<
|
|
14
|
+
typeof CursorContext,
|
|
15
|
+
$Keys<typeof CursorContext>
|
|
16
|
+
>,
|
|
17
|
+
showDismiss?: boolean,
|
|
16
18
|
multiplicationDot?: boolean,
|
|
17
19
|
divisionKey?: boolean,
|
|
20
|
+
trigonometry?: boolean,
|
|
18
21
|
preAlgebra?: boolean,
|
|
19
22
|
logarithms?: boolean,
|
|
20
23
|
basicRelations?: boolean,
|
|
21
24
|
advancedRelations?: boolean,
|
|
25
|
+
onClickKey: ClickKeyCallback,
|
|
22
26
|
sendEvent: SendEventFn,
|
|
23
27
|
|};
|
|
24
28
|
declare var Keypad: typeof npm$namespace$Keypad;
|
|
@@ -5,7 +5,7 @@ import { TabbarItemType } from "../tabbar/types";
|
|
|
5
5
|
type Props = {
|
|
6
6
|
onClickKey: ClickKeyCallback;
|
|
7
7
|
selectedPage: TabbarItemType;
|
|
8
|
-
cursorContext?: CursorContext;
|
|
8
|
+
cursorContext?: typeof CursorContext[keyof typeof CursorContext];
|
|
9
9
|
multiplicationDot?: boolean;
|
|
10
10
|
divisionKey?: boolean;
|
|
11
11
|
};
|
|
@@ -10,7 +10,10 @@ import { TabbarItemType } from "../tabbar/types";
|
|
|
10
10
|
declare type Props = {|
|
|
11
11
|
onClickKey: ClickKeyCallback,
|
|
12
12
|
selectedPage: TabbarItemType,
|
|
13
|
-
cursorContext?:
|
|
13
|
+
cursorContext?: $ElementType<
|
|
14
|
+
typeof CursorContext,
|
|
15
|
+
$Keys<typeof CursorContext>
|
|
16
|
+
>,
|
|
14
17
|
multiplicationDot?: boolean,
|
|
15
18
|
divisionKey?: boolean,
|
|
16
19
|
|};
|
|
@@ -5,7 +5,7 @@ import * as React from "react";
|
|
|
5
5
|
import { CursorContext } from "../input/cursor-contexts";
|
|
6
6
|
import type { KeypadLayout } from "../../types";
|
|
7
7
|
interface ReduxProps {
|
|
8
|
-
cursorContext?: CursorContext;
|
|
8
|
+
cursorContext?: typeof CursorContext[keyof typeof CursorContext];
|
|
9
9
|
dynamicJumpOut: boolean;
|
|
10
10
|
}
|
|
11
11
|
interface Props extends ReduxProps {
|
|
@@ -9,7 +9,10 @@ import * as React from "react";
|
|
|
9
9
|
import { CursorContext } from "../input/cursor-contexts";
|
|
10
10
|
import type { KeypadLayout } from "../../types";
|
|
11
11
|
declare interface ReduxProps {
|
|
12
|
-
cursorContext?:
|
|
12
|
+
cursorContext?: $ElementType<
|
|
13
|
+
typeof CursorContext,
|
|
14
|
+
$Keys<typeof CursorContext>
|
|
15
|
+
>;
|
|
13
16
|
dynamicJumpOut: boolean;
|
|
14
17
|
}
|
|
15
18
|
declare type Props = {
|
|
@@ -6,7 +6,7 @@ import * as React from "react";
|
|
|
6
6
|
import { CursorContext } from "../input/cursor-contexts";
|
|
7
7
|
import type { KeypadLayout } from "../../types";
|
|
8
8
|
interface ReduxProps {
|
|
9
|
-
cursorContext?: CursorContext;
|
|
9
|
+
cursorContext?: typeof CursorContext[keyof typeof CursorContext];
|
|
10
10
|
dynamicJumpOut: boolean;
|
|
11
11
|
}
|
|
12
12
|
interface Props extends ReduxProps {
|
|
@@ -9,7 +9,10 @@ import * as React from "react";
|
|
|
9
9
|
import { CursorContext } from "../input/cursor-contexts";
|
|
10
10
|
import type { KeypadLayout } from "../../types";
|
|
11
11
|
declare interface ReduxProps {
|
|
12
|
-
cursorContext?:
|
|
12
|
+
cursorContext?: $ElementType<
|
|
13
|
+
typeof CursorContext,
|
|
14
|
+
$Keys<typeof CursorContext>
|
|
15
|
+
>;
|
|
13
16
|
dynamicJumpOut: boolean;
|
|
14
17
|
}
|
|
15
18
|
declare type Props = {
|
package/dist/es/index.js
CHANGED
|
@@ -27,16 +27,25 @@ import * as Redux from 'redux';
|
|
|
27
27
|
* the radical.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
const CursorContext = {
|
|
31
|
+
// The cursor is not in any of the other viable contexts.
|
|
32
|
+
NONE: "NONE",
|
|
33
|
+
// The cursor is within a set of parentheses.
|
|
34
|
+
IN_PARENS: "IN_PARENS",
|
|
35
|
+
// The cursor is within a superscript (e.g., an exponent).
|
|
36
|
+
IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT",
|
|
37
|
+
// The cursor is within a subscript (e.g., the base of a custom logarithm).
|
|
38
|
+
IN_SUB_SCRIPT: "IN_SUB_SCRIPT",
|
|
39
|
+
// The cursor is in the numerator of a fraction.
|
|
40
|
+
IN_NUMERATOR: "IN_NUMERATOR",
|
|
41
|
+
// The cursor is in the denominator of a fraction.
|
|
42
|
+
IN_DENOMINATOR: "IN_DENOMINATOR",
|
|
43
|
+
// The cursor is sitting before a fraction; that is, the cursor is within
|
|
44
|
+
// what looks to be a mixed number preceding a fraction. This will only be
|
|
45
|
+
// the case when the only math between the cursor and the fraction to its
|
|
46
|
+
// write is non-leaf math (numbers and variables).
|
|
47
|
+
BEFORE_FRACTION: "BEFORE_FRACTION"
|
|
48
|
+
};
|
|
40
49
|
|
|
41
50
|
function _extends() {
|
|
42
51
|
_extends = Object.assign || function (target) {
|
|
@@ -4899,6 +4908,11 @@ const styles$8 = StyleSheet.create({
|
|
|
4899
4908
|
width: 36,
|
|
4900
4909
|
height: 3,
|
|
4901
4910
|
marginLeft: 3
|
|
4911
|
+
},
|
|
4912
|
+
clickable: {
|
|
4913
|
+
":focus": {
|
|
4914
|
+
outline: `none`
|
|
4915
|
+
}
|
|
4902
4916
|
}
|
|
4903
4917
|
});
|
|
4904
4918
|
function imageTintColor(itemState, hovered, focused, pressed) {
|
|
@@ -4924,6 +4938,7 @@ class TabbarItem extends React.Component {
|
|
|
4924
4938
|
onClick: onClick,
|
|
4925
4939
|
disabled: itemState === "disabled",
|
|
4926
4940
|
"aria-label": itemType,
|
|
4941
|
+
style: styles$8.clickable,
|
|
4927
4942
|
"aria-selected": itemState === "active",
|
|
4928
4943
|
role: "tab"
|
|
4929
4944
|
}, ({
|
|
@@ -8254,7 +8269,7 @@ const KeypadButton = ({
|
|
|
8254
8269
|
pressed
|
|
8255
8270
|
}) => {
|
|
8256
8271
|
return /*#__PURE__*/React.createElement(View$1, {
|
|
8257
|
-
style: [styles$1.outerBoxBase
|
|
8272
|
+
style: [styles$1.outerBoxBase]
|
|
8258
8273
|
}, /*#__PURE__*/React.createElement(View$1, {
|
|
8259
8274
|
style: [styles$1.base, tintColor != null ? {
|
|
8260
8275
|
background: tintColor
|
|
@@ -8280,7 +8295,7 @@ const styles$1 = StyleSheet.create({
|
|
|
8280
8295
|
padding: 1
|
|
8281
8296
|
},
|
|
8282
8297
|
hovered: {
|
|
8283
|
-
border: `
|
|
8298
|
+
border: `2px solid ${Color.blue}`,
|
|
8284
8299
|
padding: 1,
|
|
8285
8300
|
boxShadow: "none"
|
|
8286
8301
|
},
|
|
@@ -8303,16 +8318,13 @@ const styles$1 = StyleSheet.create({
|
|
|
8303
8318
|
borderRadius: 7,
|
|
8304
8319
|
border: "2px solid transparent"
|
|
8305
8320
|
},
|
|
8306
|
-
outerBoxHover: {
|
|
8307
|
-
border: `2px solid ${Color.blue}`
|
|
8308
|
-
},
|
|
8309
|
-
outerBoxPressed: {
|
|
8310
|
-
border: "2px solid #1B50B3"
|
|
8311
|
-
},
|
|
8312
8321
|
clickable: {
|
|
8313
8322
|
width: "100%",
|
|
8314
8323
|
height: "100%",
|
|
8315
|
-
boxSizing: "border-box"
|
|
8324
|
+
boxSizing: "border-box",
|
|
8325
|
+
":focus": {
|
|
8326
|
+
outline: `none`
|
|
8327
|
+
}
|
|
8316
8328
|
}
|
|
8317
8329
|
});
|
|
8318
8330
|
|
|
@@ -8595,7 +8607,8 @@ function Keypad(props) {
|
|
|
8595
8607
|
preAlgebra,
|
|
8596
8608
|
logarithms,
|
|
8597
8609
|
basicRelations,
|
|
8598
|
-
advancedRelations
|
|
8610
|
+
advancedRelations,
|
|
8611
|
+
showDismiss
|
|
8599
8612
|
} = props;
|
|
8600
8613
|
return /*#__PURE__*/React.createElement(View$1, null, /*#__PURE__*/React.createElement(Tabbar, {
|
|
8601
8614
|
items: availablePages,
|
|
@@ -8604,7 +8617,7 @@ function Keypad(props) {
|
|
|
8604
8617
|
setSelectedPage(tabbarItem);
|
|
8605
8618
|
},
|
|
8606
8619
|
style: styles.tabbar,
|
|
8607
|
-
onClickClose: () => onClickKey("DISMISS")
|
|
8620
|
+
onClickClose: showDismiss ? () => onClickKey("DISMISS") : undefined
|
|
8608
8621
|
}), /*#__PURE__*/React.createElement(View$1, {
|
|
8609
8622
|
style: styles.grid,
|
|
8610
8623
|
role: "grid",
|