@khanacademy/math-input 21.1.0 → 21.1.2
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/aphrodite-css-transition-group/util.d.ts +0 -3
- package/dist/components/input/mathquill-helpers.d.ts +0 -5
- package/dist/components/input/mathquill-types.d.ts +0 -7
- package/dist/components/input/scroll-into-view.d.ts +0 -1
- package/dist/components/keypad/keypad.d.ts +2 -8
- package/dist/components/tabbar/item.d.ts +1 -2
- package/dist/enums.d.ts +2 -1
- package/dist/es/index.js +44 -73
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/index.d.ts +0 -1
- package/dist/index.js +34 -73
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
- package/dist/fake-react-native-web/text.d.ts +0 -14
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
/// <reference path="../../../types/aphrodite.d.ts" />
|
|
2
|
-
import type { InAnimationStyles } from "./types";
|
|
3
1
|
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
4
2
|
export declare function processStyleType(style?: StyleType): {
|
|
5
3
|
className: string;
|
|
6
4
|
style: Record<any, any>;
|
|
7
5
|
};
|
|
8
|
-
export declare const createTransition: (styles: InAnimationStyles) => import("aphrodite").StyleDeclaration;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { CursorContext } from "./cursor-contexts";
|
|
2
2
|
import type { MathFieldInterface } from "./mathquill-types";
|
|
3
3
|
export declare function isFraction(node: any): boolean;
|
|
4
|
-
export declare function isNumerator(node: any): boolean;
|
|
5
|
-
export declare function isDenominator(node: any): boolean;
|
|
6
|
-
export declare function isSubScript(node: any): boolean;
|
|
7
|
-
export declare function isSuperScript(node: any): boolean;
|
|
8
4
|
export declare function isParens(node: any): boolean;
|
|
9
|
-
export declare function isLeaf(node: any): boolean;
|
|
10
5
|
export declare function isSquareRoot(node: any): boolean;
|
|
11
6
|
export declare function isNthRoot(node: any): boolean;
|
|
12
7
|
export declare function isNthRootIndex(node: any): boolean;
|
|
@@ -11,12 +11,6 @@ export type MathFieldInterface = MathQuill.v3.EditableMathQuill & {
|
|
|
11
11
|
cursor: () => MathQuill.Cursor;
|
|
12
12
|
controller: () => MathQuill.Controller;
|
|
13
13
|
};
|
|
14
|
-
export declare enum MathFieldActionType {
|
|
15
|
-
WRITE = "write",
|
|
16
|
-
CMD = "cmd",
|
|
17
|
-
KEYSTROKE = "keystroke",
|
|
18
|
-
MQ_END = 0
|
|
19
|
-
}
|
|
20
14
|
export type MathFieldUpdaterCallback = (mathField: MathFieldInterface, key: Key) => void;
|
|
21
15
|
/**
|
|
22
16
|
* The MathQuill API (see mathuill.d.ts) does not include types
|
|
@@ -64,4 +58,3 @@ declare module "mathquill" {
|
|
|
64
58
|
cursor?: Cursor;
|
|
65
59
|
}
|
|
66
60
|
}
|
|
67
|
-
export type MathQuillAriaStatisStringsMap = MathQuill.v3.AriaStaticStringsMap;
|
|
@@ -8,5 +8,4 @@
|
|
|
8
8
|
* TODO(charlie): Move this scroll logic out of our components and into a higher
|
|
9
9
|
* level in the component tree--perhaps even into webapp, beyond Perseus.
|
|
10
10
|
*/
|
|
11
|
-
export declare const toolbarHeightPx = 60;
|
|
12
11
|
export declare const scrollIntoView: (containerNode: any, keypadNode: any) => void;
|
|
@@ -4,7 +4,7 @@ import type { ClickKeyCallback } from "../../types";
|
|
|
4
4
|
import type { CursorContext } from "../input/cursor-contexts";
|
|
5
5
|
import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
|
|
6
6
|
export type Props = {
|
|
7
|
-
extraKeys
|
|
7
|
+
extraKeys?: ReadonlyArray<Key>;
|
|
8
8
|
cursorContext?: (typeof CursorContext)[keyof typeof CursorContext];
|
|
9
9
|
showDismiss?: boolean;
|
|
10
10
|
expandedView?: boolean;
|
|
@@ -19,10 +19,4 @@ export type Props = {
|
|
|
19
19
|
onClickKey: ClickKeyCallback;
|
|
20
20
|
onAnalyticsEvent: AnalyticsEventHandlerFn;
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
declare namespace Keypad {
|
|
24
|
-
var defaultProps: {
|
|
25
|
-
extraKeys: never[];
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export default Keypad;
|
|
22
|
+
export default function Keypad({ extraKeys, ...props }: Props): React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { KeypadPageType } from "../../types";
|
|
3
|
-
|
|
3
|
+
type ItemState = "active" | "inactive" | "disabled";
|
|
4
4
|
type TabItemProps = {
|
|
5
5
|
onClick: () => void;
|
|
6
6
|
itemState: ItemState;
|
|
@@ -9,5 +9,4 @@ type TabItemProps = {
|
|
|
9
9
|
role: "tab" | "button";
|
|
10
10
|
};
|
|
11
11
|
declare function TabbarItem(props: TabItemProps): React.ReactElement;
|
|
12
|
-
export declare const TabbarItemForTesting: typeof TabbarItem;
|
|
13
12
|
export default TabbarItem;
|
package/dist/enums.d.ts
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import PropTypes from 'prop-types';
|
|
|
16
16
|
|
|
17
17
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
18
18
|
const libName = "@khanacademy/math-input";
|
|
19
|
-
const libVersion = "21.1.
|
|
19
|
+
const libVersion = "21.1.2";
|
|
20
20
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
21
21
|
|
|
22
22
|
function _extends() {
|
|
@@ -29,25 +29,6 @@ function _extends() {
|
|
|
29
29
|
}, _extends.apply(null, arguments);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// https://github.com/necolas/react-native-web/blob/master/src/components/Text/index.js
|
|
33
|
-
StyleSheet.create({
|
|
34
|
-
initial: {
|
|
35
|
-
color: "inherit",
|
|
36
|
-
display: "inline",
|
|
37
|
-
font: "inherit",
|
|
38
|
-
margin: 0,
|
|
39
|
-
padding: 0,
|
|
40
|
-
textDecorationLine: "none",
|
|
41
|
-
wordWrap: "break-word"
|
|
42
|
-
},
|
|
43
|
-
singleLineStyle: {
|
|
44
|
-
maxWidth: "100%",
|
|
45
|
-
overflow: "hidden",
|
|
46
|
-
textOverflow: "ellipsis",
|
|
47
|
-
whiteSpace: "nowrap"
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
32
|
class View extends React.Component {
|
|
52
33
|
render() {
|
|
53
34
|
const className = css(View.styles.initial, ...(Array.isArray(this.props.style) ? this.props.style : [this.props.style])) + (this.props.extraClassName ? ` ${this.props.extraClassName}` : "");
|
|
@@ -381,6 +362,14 @@ class DragListener {
|
|
|
381
362
|
}
|
|
382
363
|
}
|
|
383
364
|
|
|
365
|
+
let MathFieldActionType = /*#__PURE__*/function (MathFieldActionType) {
|
|
366
|
+
MathFieldActionType["WRITE"] = "write";
|
|
367
|
+
MathFieldActionType["CMD"] = "cmd";
|
|
368
|
+
MathFieldActionType["KEYSTROKE"] = "keystroke";
|
|
369
|
+
MathFieldActionType[MathFieldActionType["MQ_END"] = 0] = "MQ_END";
|
|
370
|
+
return MathFieldActionType;
|
|
371
|
+
}({});
|
|
372
|
+
|
|
384
373
|
/**
|
|
385
374
|
* Enum that defines the various contexts in which a cursor can exist. The
|
|
386
375
|
* active context is determined first by looking at the cursor's siblings (e.g.,
|
|
@@ -554,29 +543,6 @@ function createMathField(container, locale, strings, configCallback) {
|
|
|
554
543
|
return mathField;
|
|
555
544
|
}
|
|
556
545
|
|
|
557
|
-
/**
|
|
558
|
-
* Editable math fields have all of the above methods in addition to
|
|
559
|
-
* the ones listed here.
|
|
560
|
-
* https://docs.mathquill.com/en/latest/Api_Methods/
|
|
561
|
-
*/
|
|
562
|
-
|
|
563
|
-
let MathFieldActionType = /*#__PURE__*/function (MathFieldActionType) {
|
|
564
|
-
MathFieldActionType["WRITE"] = "write";
|
|
565
|
-
MathFieldActionType["CMD"] = "cmd";
|
|
566
|
-
MathFieldActionType["KEYSTROKE"] = "keystroke";
|
|
567
|
-
MathFieldActionType[MathFieldActionType["MQ_END"] = 0] = "MQ_END";
|
|
568
|
-
return MathFieldActionType;
|
|
569
|
-
}({});
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* The MathQuill API (see mathuill.d.ts) does not include types
|
|
573
|
-
* for cursor() and controller(), and adding these types there
|
|
574
|
-
* in the MathQuill repo causes unexpected conflicts with other types.
|
|
575
|
-
*
|
|
576
|
-
* We don't want to use the cursor and controller default type `any`
|
|
577
|
-
* so we declare the types here.
|
|
578
|
-
*/
|
|
579
|
-
|
|
580
546
|
const Numerals = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
581
547
|
const GreekLetters = ["\\theta", "\\pi"];
|
|
582
548
|
const Letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
|
|
@@ -1159,27 +1125,20 @@ function handleJumpOut(mathField, key) {
|
|
|
1159
1125
|
}
|
|
1160
1126
|
}
|
|
1161
1127
|
|
|
1162
|
-
|
|
1163
|
-
ActionType["WRITE"] = "write";
|
|
1164
|
-
ActionType["CMD"] = "cmd";
|
|
1165
|
-
ActionType["KEYSTROKE"] = "keystroke";
|
|
1166
|
-
ActionType[ActionType["MQ_END"] = 0] = "MQ_END";
|
|
1167
|
-
return ActionType;
|
|
1168
|
-
}(ActionType || {});
|
|
1169
|
-
function buildGenericCallback(str, type = ActionType.WRITE) {
|
|
1128
|
+
function buildGenericCallback(str, type = MathFieldActionType.WRITE) {
|
|
1170
1129
|
return function (mathQuill) {
|
|
1171
1130
|
switch (type) {
|
|
1172
|
-
case
|
|
1131
|
+
case MathFieldActionType.WRITE:
|
|
1173
1132
|
{
|
|
1174
1133
|
mathQuill.write(str);
|
|
1175
1134
|
return;
|
|
1176
1135
|
}
|
|
1177
|
-
case
|
|
1136
|
+
case MathFieldActionType.CMD:
|
|
1178
1137
|
{
|
|
1179
1138
|
mathQuill.cmd(str);
|
|
1180
1139
|
return;
|
|
1181
1140
|
}
|
|
1182
|
-
case
|
|
1141
|
+
case MathFieldActionType.KEYSTROKE:
|
|
1183
1142
|
{
|
|
1184
1143
|
mathQuill.keystroke(str);
|
|
1185
1144
|
return;
|
|
@@ -1245,17 +1204,17 @@ const getKeyTranslator = (locale, strings) => ({
|
|
|
1245
1204
|
TIMES: buildGenericCallback("\\times"),
|
|
1246
1205
|
// The `FRAC_EXCLUSIVE` variant is handled manually, since we may need to do
|
|
1247
1206
|
// some additional navigation depending on the cursor position.
|
|
1248
|
-
FRAC_INCLUSIVE: buildGenericCallback("/",
|
|
1249
|
-
FRAC: buildGenericCallback("\\frac",
|
|
1250
|
-
LEFT_PAREN: buildGenericCallback("(",
|
|
1251
|
-
RIGHT_PAREN: buildGenericCallback(")",
|
|
1252
|
-
SQRT: buildGenericCallback("sqrt",
|
|
1253
|
-
PI: buildGenericCallback("pi",
|
|
1254
|
-
THETA: buildGenericCallback("theta",
|
|
1255
|
-
RADICAL: buildGenericCallback("nthroot",
|
|
1256
|
-
BACKSPACE: buildGenericCallback("Backspace",
|
|
1257
|
-
UP: buildGenericCallback("Up",
|
|
1258
|
-
DOWN: buildGenericCallback("Down",
|
|
1207
|
+
FRAC_INCLUSIVE: buildGenericCallback("/", MathFieldActionType.CMD),
|
|
1208
|
+
FRAC: buildGenericCallback("\\frac", MathFieldActionType.CMD),
|
|
1209
|
+
LEFT_PAREN: buildGenericCallback("(", MathFieldActionType.CMD),
|
|
1210
|
+
RIGHT_PAREN: buildGenericCallback(")", MathFieldActionType.CMD),
|
|
1211
|
+
SQRT: buildGenericCallback("sqrt", MathFieldActionType.CMD),
|
|
1212
|
+
PI: buildGenericCallback("pi", MathFieldActionType.CMD),
|
|
1213
|
+
THETA: buildGenericCallback("theta", MathFieldActionType.CMD),
|
|
1214
|
+
RADICAL: buildGenericCallback("nthroot", MathFieldActionType.CMD),
|
|
1215
|
+
BACKSPACE: buildGenericCallback("Backspace", MathFieldActionType.KEYSTROKE),
|
|
1216
|
+
UP: buildGenericCallback("Up", MathFieldActionType.KEYSTROKE),
|
|
1217
|
+
DOWN: buildGenericCallback("Down", MathFieldActionType.KEYSTROKE),
|
|
1259
1218
|
CUBE_ROOT: mathQuill => {
|
|
1260
1219
|
mathQuill.write("\\sqrt[3]{}");
|
|
1261
1220
|
mathQuill.keystroke("Left"); // under the root
|
|
@@ -1265,7 +1224,7 @@ const getKeyTranslator = (locale, strings) => ({
|
|
|
1265
1224
|
const cursor = mathQuill.cursor();
|
|
1266
1225
|
// If there's nothing to the left of the cursor, then we want to
|
|
1267
1226
|
// leave the cursor to the left of the fraction after creating it.
|
|
1268
|
-
const shouldNavigateLeft = cursor[mathQuillInstance.L] ===
|
|
1227
|
+
const shouldNavigateLeft = cursor[mathQuillInstance.L] === MathFieldActionType.MQ_END;
|
|
1269
1228
|
mathQuill.cmd("\\frac");
|
|
1270
1229
|
if (shouldNavigateLeft) {
|
|
1271
1230
|
mathQuill.keystroke("Left");
|
|
@@ -2381,6 +2340,16 @@ const inlineStyles = {
|
|
|
2381
2340
|
}
|
|
2382
2341
|
};
|
|
2383
2342
|
|
|
2343
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
2344
|
+
if (null == r) return {};
|
|
2345
|
+
var t = {};
|
|
2346
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
2347
|
+
if (e.includes(n)) continue;
|
|
2348
|
+
t[n] = r[n];
|
|
2349
|
+
}
|
|
2350
|
+
return t;
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2384
2353
|
const IconAsset = function IconAsset({
|
|
2385
2354
|
tintColor,
|
|
2386
2355
|
type
|
|
@@ -5111,9 +5080,7 @@ function SharedKeys(props) {
|
|
|
5111
5080
|
}));
|
|
5112
5081
|
}
|
|
5113
5082
|
|
|
5114
|
-
const
|
|
5115
|
-
extraKeys: []
|
|
5116
|
-
};
|
|
5083
|
+
const _excluded = ["extraKeys"];
|
|
5117
5084
|
function getAvailableTabs(props) {
|
|
5118
5085
|
var _props$extraKeys;
|
|
5119
5086
|
// We don't want to show any available tabs on the fractions keypad
|
|
@@ -5137,7 +5104,11 @@ function getAvailableTabs(props) {
|
|
|
5137
5104
|
|
|
5138
5105
|
// The main (v2) Keypad. Use this component to present an accessible, onscreen
|
|
5139
5106
|
// keypad to learners for entering math expressions.
|
|
5140
|
-
function Keypad(
|
|
5107
|
+
function Keypad(_ref) {
|
|
5108
|
+
let {
|
|
5109
|
+
extraKeys = []
|
|
5110
|
+
} = _ref,
|
|
5111
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
5141
5112
|
// If we're using the Fractions keypad, we want to default select that page
|
|
5142
5113
|
// Otherwise, we want to default to the Numbers page
|
|
5143
5114
|
const defaultSelectedPage = props.fractionsOnly ? "Fractions" : "Numbers";
|
|
@@ -5145,11 +5116,12 @@ function Keypad(props) {
|
|
|
5145
5116
|
const [isMounted, setIsMounted] = React.useState(false);
|
|
5146
5117
|
|
|
5147
5118
|
// We don't want any tabs available on mobile fractions keypad
|
|
5148
|
-
const availableTabs = getAvailableTabs(props
|
|
5119
|
+
const availableTabs = getAvailableTabs(_extends({}, props, {
|
|
5120
|
+
extraKeys
|
|
5121
|
+
}));
|
|
5149
5122
|
const {
|
|
5150
5123
|
onClickKey,
|
|
5151
5124
|
cursorContext,
|
|
5152
|
-
extraKeys,
|
|
5153
5125
|
convertDotToTimes,
|
|
5154
5126
|
divisionKey,
|
|
5155
5127
|
preAlgebra,
|
|
@@ -5233,7 +5205,6 @@ function Keypad(props) {
|
|
|
5233
5205
|
onClickKey: onClickKey
|
|
5234
5206
|
}))));
|
|
5235
5207
|
}
|
|
5236
|
-
Keypad.defaultProps = defaultProps;
|
|
5237
5208
|
const styles$1 = StyleSheet.create({
|
|
5238
5209
|
keypadOuterContainer: {
|
|
5239
5210
|
display: "flex",
|