@khanacademy/math-input 21.1.0 → 21.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.
@@ -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;
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import type { KeypadPageType } from "../../types";
3
- export type ItemState = "active" | "inactive" | "disabled";
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
@@ -5,5 +5,6 @@ export declare enum KeypadType {
5
5
  FRACTION = "FRACTION",
6
6
  EXPRESSION = "EXPRESSION"
7
7
  }
8
- export declare const KeyTypes: string[];
8
+ declare const KeyTypes: string[];
9
9
  export type KeyType = (typeof KeyTypes)[number];
10
+ export {};
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.0";
19
+ const libVersion = "21.1.1";
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
- var ActionType = /*#__PURE__*/function (ActionType) {
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 ActionType.WRITE:
1131
+ case MathFieldActionType.WRITE:
1173
1132
  {
1174
1133
  mathQuill.write(str);
1175
1134
  return;
1176
1135
  }
1177
- case ActionType.CMD:
1136
+ case MathFieldActionType.CMD:
1178
1137
  {
1179
1138
  mathQuill.cmd(str);
1180
1139
  return;
1181
1140
  }
1182
- case ActionType.KEYSTROKE:
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("/", ActionType.CMD),
1249
- FRAC: buildGenericCallback("\\frac", ActionType.CMD),
1250
- LEFT_PAREN: buildGenericCallback("(", ActionType.CMD),
1251
- RIGHT_PAREN: buildGenericCallback(")", ActionType.CMD),
1252
- SQRT: buildGenericCallback("sqrt", ActionType.CMD),
1253
- PI: buildGenericCallback("pi", ActionType.CMD),
1254
- THETA: buildGenericCallback("theta", ActionType.CMD),
1255
- RADICAL: buildGenericCallback("nthroot", ActionType.CMD),
1256
- BACKSPACE: buildGenericCallback("Backspace", ActionType.KEYSTROKE),
1257
- UP: buildGenericCallback("Up", ActionType.KEYSTROKE),
1258
- DOWN: buildGenericCallback("Down", ActionType.KEYSTROKE),
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] === ActionType.MQ_END;
1227
+ const shouldNavigateLeft = cursor[mathQuillInstance.L] === MathFieldActionType.MQ_END;
1269
1228
  mathQuill.cmd("\\frac");
1270
1229
  if (shouldNavigateLeft) {
1271
1230
  mathQuill.keystroke("Left");