@khanacademy/math-input 16.1.0 → 16.1.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/README.md +1 -9
- package/dist/components/input/cursor-styles.d.ts +5 -0
- package/dist/components/input/scroll-into-view.d.ts +1 -0
- package/dist/enums.d.ts +0 -29
- package/dist/es/index.css +0 -66
- package/dist/es/index.js +18 -45
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +0 -66
- package/dist/index.js +18 -45
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -40
- package/less/main.less +0 -3
- package/package.json +3 -7
- package/src/components/input/cursor-handle.tsx +1 -1
- package/src/components/input/cursor-styles.ts +10 -0
- package/src/components/input/math-input.tsx +5 -7
- package/src/components/input/scroll-into-view.ts +4 -1
- package/src/data/key-configs.ts +0 -9
- package/src/enums.ts +0 -43
- package/src/types.ts +1 -54
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/common-style.d.ts +0 -21
- package/index.html +0 -21
- package/less/echo.less +0 -56
- package/less/popover.less +0 -22
- package/less/tabbar.less +0 -6
- package/src/components/common-style.ts +0 -46
- package/tools/svg-to-react/convert.py +0 -111
- package/tools/svg-to-react/icons/math-keypad-icon-0.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-1.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-2.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-3.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-4.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-5.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-6.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-7.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-8.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-9.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-addition.svg +0 -34
- package/tools/svg-to-react/icons/math-keypad-icon-cos.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-delete.svg +0 -36
- package/tools/svg-to-react/icons/math-keypad-icon-dismiss.svg +0 -36
- package/tools/svg-to-react/icons/math-keypad-icon-division.svg +0 -36
- package/tools/svg-to-react/icons/math-keypad-icon-equals-not.svg +0 -50
- package/tools/svg-to-react/icons/math-keypad-icon-equals.svg +0 -48
- package/tools/svg-to-react/icons/math-keypad-icon-exponent-2.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-exponent-3.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-exponent.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-fraction.svg +0 -42
- package/tools/svg-to-react/icons/math-keypad-icon-greater-than.svg +0 -46
- package/tools/svg-to-react/icons/math-keypad-icon-jump-out-base.svg +0 -44
- package/tools/svg-to-react/icons/math-keypad-icon-jump-out-denominator.svg +0 -48
- package/tools/svg-to-react/icons/math-keypad-icon-jump-out-exponent.svg +0 -44
- package/tools/svg-to-react/icons/math-keypad-icon-jump-out-parentheses.svg +0 -44
- package/tools/svg-to-react/icons/math-keypad-icon-less-than.svg +0 -46
- package/tools/svg-to-react/icons/math-keypad-icon-log-10.svg +0 -36
- package/tools/svg-to-react/icons/math-keypad-icon-log-e.svg +0 -36
- package/tools/svg-to-react/icons/math-keypad-icon-log.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-multiplication-cross.svg +0 -40
- package/tools/svg-to-react/icons/math-keypad-icon-multiplication-dot.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-percent.svg +0 -42
- package/tools/svg-to-react/icons/math-keypad-icon-radical-2.svg +0 -36
- package/tools/svg-to-react/icons/math-keypad-icon-radical-3.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-radical.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-radix-character.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-sin.svg +0 -38
- package/tools/svg-to-react/icons/math-keypad-icon-subtraction.svg +0 -32
- package/tools/svg-to-react/icons/math-keypad-icon-tan.svg +0 -38
- package/tools/svg-to-react/symbol_map.py +0 -41
package/dist/types.d.ts
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
import type { CursorContext } from "./components/input/cursor-contexts";
|
|
2
2
|
import type Key from "./data/keys";
|
|
3
|
-
import type {
|
|
3
|
+
import type { KeyType, KeypadType } from "./enums";
|
|
4
4
|
import type { KeypadContextRendererInterface } from "@khanacademy/perseus-core";
|
|
5
5
|
import type * as React from "react";
|
|
6
6
|
import type ReactDOM from "react-dom";
|
|
7
|
-
export type Border = Partial<ReadonlyArray<BorderDirection>>;
|
|
8
|
-
export interface Bound {
|
|
9
|
-
top: number;
|
|
10
|
-
right: number;
|
|
11
|
-
bottom: number;
|
|
12
|
-
left: number;
|
|
13
|
-
height: number;
|
|
14
|
-
width: number;
|
|
15
|
-
}
|
|
16
|
-
export type Popover = {
|
|
17
|
-
parentId: Key;
|
|
18
|
-
bounds: Partial<Bound>;
|
|
19
|
-
childKeyIds: Array<Key>;
|
|
20
|
-
};
|
|
21
|
-
export type Echo = {
|
|
22
|
-
animationId: string;
|
|
23
|
-
animationType: EchoAnimationType;
|
|
24
|
-
id: Key;
|
|
25
|
-
initialBounds: Bound;
|
|
26
|
-
};
|
|
27
7
|
export type IconConfig = {
|
|
28
|
-
type: IconType;
|
|
29
8
|
data: string;
|
|
30
9
|
};
|
|
31
10
|
export type NonManyKeyConfig = {
|
|
@@ -48,23 +27,6 @@ export type KeyHandler = (key: Key) => Cursor;
|
|
|
48
27
|
export type Cursor = {
|
|
49
28
|
context: typeof CursorContext[keyof typeof CursorContext];
|
|
50
29
|
};
|
|
51
|
-
export type KeypadLayout = {
|
|
52
|
-
rows: number;
|
|
53
|
-
columns: number;
|
|
54
|
-
numPages: number;
|
|
55
|
-
maxVisibleRows: number;
|
|
56
|
-
};
|
|
57
|
-
type ActiveNodesObjPopover = {
|
|
58
|
-
parentId: string;
|
|
59
|
-
childIds: ReadonlyArray<string>;
|
|
60
|
-
};
|
|
61
|
-
export type ActiveNodesObj = {
|
|
62
|
-
popover: ActiveNodesObjPopover | null;
|
|
63
|
-
focus: string | null;
|
|
64
|
-
};
|
|
65
|
-
export type LayoutProps = {
|
|
66
|
-
initialBounds: Bound;
|
|
67
|
-
};
|
|
68
30
|
export type ClickKeyCallback = (key: Key, event?: React.SyntheticEvent) => void;
|
|
69
31
|
export type KeypadPageType = "Geometry" | "Operators" | "Numbers" | "Fractions" | "Extras" | "Dismiss";
|
|
70
32
|
export interface KeypadAPI {
|
|
@@ -85,4 +47,3 @@ export type KeypadContextType = {
|
|
|
85
47
|
setScrollableElement: (scrollableElement?: HTMLElement | null | undefined) => void;
|
|
86
48
|
scrollableElement: HTMLElement | null | undefined;
|
|
87
49
|
};
|
|
88
|
-
export {};
|
package/less/main.less
CHANGED
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": "16.1.
|
|
6
|
+
"version": "16.1.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -40,11 +40,9 @@
|
|
|
40
40
|
"prop-types": "15.6.1",
|
|
41
41
|
"react": "^16.8.0",
|
|
42
42
|
"react-dom": "^16.8.0",
|
|
43
|
-
"react-redux": "^7.2.6",
|
|
44
43
|
"react-router": "^5.2.1",
|
|
45
44
|
"react-router-dom": "^5.3.0",
|
|
46
|
-
"react-transition-group": "^4.4.1"
|
|
47
|
-
"redux": "^4.0.0"
|
|
45
|
+
"react-transition-group": "^4.4.1"
|
|
48
46
|
},
|
|
49
47
|
"peerDependencies": {
|
|
50
48
|
"@khanacademy/wonder-blocks-clickable": "^4.0.11",
|
|
@@ -61,11 +59,9 @@
|
|
|
61
59
|
"prop-types": "15.6.1",
|
|
62
60
|
"react": "^16.8.0",
|
|
63
61
|
"react-dom": "^16.8.0",
|
|
64
|
-
"react-redux": "^7.2.6",
|
|
65
62
|
"react-router": "^5.2.1",
|
|
66
63
|
"react-router-dom": "^5.3.0",
|
|
67
|
-
"react-transition-group": "^4.4.1"
|
|
68
|
-
"redux": "^4.0.0"
|
|
64
|
+
"react-transition-group": "^4.4.1"
|
|
69
65
|
},
|
|
70
66
|
"keywords": []
|
|
71
67
|
}
|
|
@@ -7,7 +7,7 @@ import * as React from "react";
|
|
|
7
7
|
import {
|
|
8
8
|
cursorHandleRadiusPx,
|
|
9
9
|
cursorHandleDistanceMultiplier,
|
|
10
|
-
} from "
|
|
10
|
+
} from "./cursor-styles";
|
|
11
11
|
|
|
12
12
|
const touchTargetRadiusPx = 2 * cursorHandleRadiusPx;
|
|
13
13
|
const touchTargetHeightPx = 2 * touchTargetRadiusPx;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common parameters used to style components.
|
|
3
|
+
*/
|
|
4
|
+
export const cursorHandleRadiusPx = 11;
|
|
5
|
+
|
|
6
|
+
// The amount to multiply the radius by to get the distance from the
|
|
7
|
+
// center to the tip of the cursor handle. The cursor is a circle with
|
|
8
|
+
// one quadrant replace with a square. The hypotenuse of the square is
|
|
9
|
+
// 1.045 times the radius of the circle.
|
|
10
|
+
export const cursorHandleDistanceMultiplier = 1.045;
|
|
@@ -7,14 +7,12 @@ import * as React from "react";
|
|
|
7
7
|
import ReactDOM from "react-dom";
|
|
8
8
|
|
|
9
9
|
import {View} from "../../fake-react-native-web/index";
|
|
10
|
+
|
|
11
|
+
import CursorHandle from "./cursor-handle";
|
|
10
12
|
import {
|
|
11
13
|
cursorHandleRadiusPx,
|
|
12
14
|
cursorHandleDistanceMultiplier,
|
|
13
|
-
|
|
14
|
-
offBlack,
|
|
15
|
-
} from "../common-style";
|
|
16
|
-
|
|
17
|
-
import CursorHandle from "./cursor-handle";
|
|
15
|
+
} from "./cursor-styles";
|
|
18
16
|
import DragListener from "./drag-listener";
|
|
19
17
|
import MathWrapper from "./math-wrapper";
|
|
20
18
|
import {scrollIntoView} from "./scroll-into-view";
|
|
@@ -876,7 +874,7 @@ class MathInput extends React.Component<Props, State> {
|
|
|
876
874
|
borderWidth: this.getBorderWidthPx(),
|
|
877
875
|
...(focused
|
|
878
876
|
? {
|
|
879
|
-
borderColor:
|
|
877
|
+
borderColor: Color.blue,
|
|
880
878
|
}
|
|
881
879
|
: {}),
|
|
882
880
|
...style,
|
|
@@ -982,7 +980,7 @@ const inlineStyles = {
|
|
|
982
980
|
borderStyle: "solid",
|
|
983
981
|
borderColor: Color.offBlack50,
|
|
984
982
|
borderRadius: 4,
|
|
985
|
-
color: offBlack,
|
|
983
|
+
color: Color.offBlack,
|
|
986
984
|
},
|
|
987
985
|
} as const;
|
|
988
986
|
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* level in the component tree--perhaps even into webapp, beyond Perseus.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// HACK(charlie): This should be injected by webapp somehow.
|
|
13
|
+
// TODO(charlie): Add a link to the webapp location as soon as the footer
|
|
14
|
+
// has settled down.
|
|
15
|
+
export const toolbarHeightPx = 60;
|
|
13
16
|
|
|
14
17
|
export const scrollIntoView = (containerNode, keypadNode) => {
|
|
15
18
|
// TODO(charlie): There's no need for us to be reading the keypad bounds
|
package/src/data/key-configs.ts
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as i18n from "@khanacademy/wonder-blocks-i18n";
|
|
5
5
|
|
|
6
|
-
import {IconType} from "../enums";
|
|
7
|
-
|
|
8
6
|
import type Key from "./keys";
|
|
9
7
|
import type {KeyType} from "../enums";
|
|
10
8
|
import type {KeyConfig} from "../types";
|
|
@@ -12,7 +10,6 @@ import type {KeyConfig} from "../types";
|
|
|
12
10
|
type KeyConfigMapper = (args: {
|
|
13
11
|
key: Key;
|
|
14
12
|
keyType?: KeyType;
|
|
15
|
-
iconType?: IconType;
|
|
16
13
|
ariaLabel?: string;
|
|
17
14
|
data?: string;
|
|
18
15
|
}) => KeyConfig;
|
|
@@ -20,7 +17,6 @@ type KeyConfigMapper = (args: {
|
|
|
20
17
|
const getDefaultOperatorFields: KeyConfigMapper = ({
|
|
21
18
|
key,
|
|
22
19
|
keyType = "OPERATOR",
|
|
23
|
-
iconType = IconType.SVG,
|
|
24
20
|
ariaLabel = key,
|
|
25
21
|
data = key,
|
|
26
22
|
}) => ({
|
|
@@ -28,7 +24,6 @@ const getDefaultOperatorFields: KeyConfigMapper = ({
|
|
|
28
24
|
type: keyType,
|
|
29
25
|
ariaLabel,
|
|
30
26
|
icon: {
|
|
31
|
-
type: iconType,
|
|
32
27
|
data,
|
|
33
28
|
},
|
|
34
29
|
});
|
|
@@ -36,7 +31,6 @@ const getDefaultOperatorFields: KeyConfigMapper = ({
|
|
|
36
31
|
const getDefaultValueFields: KeyConfigMapper = ({
|
|
37
32
|
key,
|
|
38
33
|
keyType = "VALUE",
|
|
39
|
-
iconType = IconType.MATH,
|
|
40
34
|
ariaLabel = key,
|
|
41
35
|
data = key,
|
|
42
36
|
}) => ({
|
|
@@ -44,7 +38,6 @@ const getDefaultValueFields: KeyConfigMapper = ({
|
|
|
44
38
|
type: keyType,
|
|
45
39
|
ariaLabel,
|
|
46
40
|
icon: {
|
|
47
|
-
type: iconType,
|
|
48
41
|
data,
|
|
49
42
|
},
|
|
50
43
|
});
|
|
@@ -53,14 +46,12 @@ const getDefaultNumberFields: KeyConfigMapper = ({
|
|
|
53
46
|
key,
|
|
54
47
|
data = key.replace("NUM_", ""),
|
|
55
48
|
keyType = "VALUE",
|
|
56
|
-
iconType = IconType.TEXT,
|
|
57
49
|
ariaLabel = data,
|
|
58
50
|
}) => ({
|
|
59
51
|
id: key,
|
|
60
52
|
type: keyType,
|
|
61
53
|
ariaLabel,
|
|
62
54
|
icon: {
|
|
63
|
-
type: iconType,
|
|
64
55
|
data,
|
|
65
56
|
},
|
|
66
57
|
});
|
package/src/enums.ts
CHANGED
|
@@ -23,48 +23,5 @@ export const KeyTypes = [
|
|
|
23
23
|
// For buttons that house multiple buttons and have no action
|
|
24
24
|
// themselves.
|
|
25
25
|
"MANY",
|
|
26
|
-
// For the echo animation that appears on press.
|
|
27
|
-
"ECHO",
|
|
28
26
|
];
|
|
29
27
|
export type KeyType = typeof KeyTypes[number];
|
|
30
|
-
|
|
31
|
-
export enum DeviceOrientation {
|
|
32
|
-
LANDSCAPE = "LANDSCAPE",
|
|
33
|
-
PORTRAIT = "PORTRAIT",
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export enum DeviceType {
|
|
37
|
-
PHONE = "PHONE",
|
|
38
|
-
TABLET = "TABLET",
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export enum LayoutMode {
|
|
42
|
-
FULLSCREEN = "FULLSCREEN",
|
|
43
|
-
COMPACT = "COMPACT",
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export enum BorderDirection {
|
|
47
|
-
LEFT = "LEFT",
|
|
48
|
-
BOTTOM = "BOTTOM",
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const BorderStyles: {
|
|
52
|
-
[style: string]: ReadonlyArray<BorderDirection>;
|
|
53
|
-
} = {
|
|
54
|
-
LEFT: [BorderDirection.LEFT],
|
|
55
|
-
BOTTOM: [BorderDirection.BOTTOM],
|
|
56
|
-
ALL: [BorderDirection.LEFT, BorderDirection.BOTTOM],
|
|
57
|
-
NONE: [],
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export enum IconType {
|
|
61
|
-
MATH = "MATH",
|
|
62
|
-
SVG = "SVG",
|
|
63
|
-
TEXT = "TEXT",
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export enum EchoAnimationType {
|
|
67
|
-
SLIDE_AND_FADE = "SLIDE_AND_FADE",
|
|
68
|
-
FADE_ONLY = "FADE_ONLY",
|
|
69
|
-
LONG_FADE_ONLY = "LONG_FADE_ONLY",
|
|
70
|
-
}
|
package/src/types.ts
CHANGED
|
@@ -1,42 +1,11 @@
|
|
|
1
1
|
import type {CursorContext} from "./components/input/cursor-contexts";
|
|
2
2
|
import type Key from "./data/keys";
|
|
3
|
-
import type {
|
|
4
|
-
BorderDirection,
|
|
5
|
-
EchoAnimationType,
|
|
6
|
-
IconType,
|
|
7
|
-
KeyType,
|
|
8
|
-
KeypadType,
|
|
9
|
-
} from "./enums";
|
|
3
|
+
import type {KeyType, KeypadType} from "./enums";
|
|
10
4
|
import type {KeypadContextRendererInterface} from "@khanacademy/perseus-core";
|
|
11
5
|
import type * as React from "react";
|
|
12
6
|
import type ReactDOM from "react-dom";
|
|
13
7
|
|
|
14
|
-
export type Border = Partial<ReadonlyArray<BorderDirection>>;
|
|
15
|
-
|
|
16
|
-
export interface Bound {
|
|
17
|
-
top: number;
|
|
18
|
-
right: number;
|
|
19
|
-
bottom: number;
|
|
20
|
-
left: number;
|
|
21
|
-
height: number;
|
|
22
|
-
width: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type Popover = {
|
|
26
|
-
parentId: Key;
|
|
27
|
-
bounds: Partial<Bound>;
|
|
28
|
-
childKeyIds: Array<Key>;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type Echo = {
|
|
32
|
-
animationId: string;
|
|
33
|
-
animationType: EchoAnimationType;
|
|
34
|
-
id: Key;
|
|
35
|
-
initialBounds: Bound;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
8
|
export type IconConfig = {
|
|
39
|
-
type: IconType;
|
|
40
9
|
data: string;
|
|
41
10
|
};
|
|
42
11
|
|
|
@@ -66,28 +35,6 @@ export type Cursor = {
|
|
|
66
35
|
context: typeof CursorContext[keyof typeof CursorContext];
|
|
67
36
|
};
|
|
68
37
|
|
|
69
|
-
export type KeypadLayout = {
|
|
70
|
-
rows: number;
|
|
71
|
-
columns: number;
|
|
72
|
-
numPages: number;
|
|
73
|
-
// Since we include a two-key popover in the top-right, when the popover
|
|
74
|
-
// is visible, the keypad will expand to fill the equivalent of five
|
|
75
|
-
// rows vertically.
|
|
76
|
-
maxVisibleRows: number;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
type ActiveNodesObjPopover = {
|
|
80
|
-
parentId: string;
|
|
81
|
-
childIds: ReadonlyArray<string>;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type ActiveNodesObj = {
|
|
85
|
-
popover: ActiveNodesObjPopover | null;
|
|
86
|
-
focus: string | null;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type LayoutProps = {initialBounds: Bound};
|
|
90
|
-
|
|
91
38
|
export type ClickKeyCallback = (key: Key, event?: React.SyntheticEvent) => void;
|
|
92
39
|
|
|
93
40
|
export type KeypadPageType =
|