@khanacademy/math-input 15.0.0 → 15.1.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/CHANGELOG.md +12 -0
- package/dist/components/aphrodite-css-transition-group/transition-child.d.ts +11 -8
- package/dist/enums.d.ts +0 -4
- package/dist/es/index.js +85 -80
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +85 -79
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/package.json +10 -9
- package/src/components/key-handlers/key-translator.ts +1 -4
- package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +2 -0
- package/src/components/keypad/__tests__/__snapshots__/mobile-keypad.test.tsx.snap +1 -0
- package/src/components/keypad/__tests__/keypad.test.tsx +35 -0
- package/src/components/keypad/button-assets.tsx +27 -3
- package/src/data/key-configs.ts +1 -14
- package/src/enums.ts +0 -5
- package/src/utils.ts +4 -1
- package/tsconfig-build.tsbuildinfo +1 -1
- package/src/components/keypad-legacy/__tests__/two-page-keypad.test.tsx +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @khanacademy/math-input
|
|
2
2
|
|
|
3
|
+
## 15.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#811](https://github.com/Khan/perseus/pull/811) [`bca527ab`](https://github.com/Khan/perseus/commit/bca527abc4d8b29942efec12509f9cf8be401e75) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Bump all Wonder Blocks dependencies to latest
|
|
8
|
+
|
|
9
|
+
## 15.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#800](https://github.com/Khan/perseus/pull/800) [`1d58b887`](https://github.com/Khan/perseus/commit/1d58b887179b129b5027e20484fde5169170f052) Thanks [@handeyeco](https://github.com/handeyeco)! - Bugfix: conditionally switch between period/comma for decimal separator
|
|
14
|
+
|
|
3
15
|
## 15.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { AnimationStyles } from "./types";
|
|
3
|
-
declare const _default:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
declare const _default: {
|
|
4
|
+
(props: {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
transitionStyles: AnimationStyles | (() => AnimationStyles);
|
|
7
|
+
appearTimeout?: number | undefined;
|
|
8
|
+
enterTimeout?: number | undefined;
|
|
9
|
+
leaveTimeout?: number | undefined;
|
|
10
|
+
in?: boolean | undefined;
|
|
11
|
+
}): JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
11
14
|
export default _default;
|
package/dist/enums.d.ts
CHANGED
|
@@ -31,10 +31,6 @@ export declare enum IconType {
|
|
|
31
31
|
SVG = "SVG",
|
|
32
32
|
TEXT = "TEXT"
|
|
33
33
|
}
|
|
34
|
-
export declare enum DecimalSeparator {
|
|
35
|
-
COMMA = "COMMA",
|
|
36
|
-
PERIOD = "PERIOD"
|
|
37
|
-
}
|
|
38
34
|
export declare enum EchoAnimationType {
|
|
39
35
|
SLIDE_AND_FADE = "SLIDE_AND_FADE",
|
|
40
36
|
FADE_ONLY = "FADE_ONLY",
|
package/dist/es/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import * as Redux from 'redux';
|
|
|
20
20
|
|
|
21
21
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
22
22
|
const libName = "@khanacademy/math-input";
|
|
23
|
-
const libVersion = "15.
|
|
23
|
+
const libVersion = "15.1.0";
|
|
24
24
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
25
25
|
|
|
26
26
|
function _extends() {
|
|
@@ -826,70 +826,10 @@ function handleBackspace(mathField) {
|
|
|
826
826
|
}
|
|
827
827
|
}
|
|
828
828
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
let KeypadType = /*#__PURE__*/function (KeypadType) {
|
|
834
|
-
KeypadType["FRACTION"] = "FRACTION";
|
|
835
|
-
KeypadType["EXPRESSION"] = "EXPRESSION";
|
|
836
|
-
return KeypadType;
|
|
837
|
-
}({});
|
|
838
|
-
const KeyTypes = ["EMPTY",
|
|
839
|
-
// For numerals, variables, and any other characters that themselves
|
|
840
|
-
// compose 'values'.
|
|
841
|
-
"VALUE",
|
|
842
|
-
// For buttons that insert or adjust math in an input.
|
|
843
|
-
"OPERATOR",
|
|
844
|
-
// For buttons that move the cursor in an input (including via
|
|
845
|
-
// deletion).
|
|
846
|
-
"INPUT_NAVIGATION",
|
|
847
|
-
// For buttons that modify the broader keypad state (e.g., by changing
|
|
848
|
-
// the visible pane).
|
|
849
|
-
"KEYPAD_NAVIGATION",
|
|
850
|
-
// For buttons that house multiple buttons and have no action
|
|
851
|
-
// themselves.
|
|
852
|
-
"MANY",
|
|
853
|
-
// For the echo animation that appears on press.
|
|
854
|
-
"ECHO"];
|
|
855
|
-
let DeviceOrientation = /*#__PURE__*/function (DeviceOrientation) {
|
|
856
|
-
DeviceOrientation["LANDSCAPE"] = "LANDSCAPE";
|
|
857
|
-
DeviceOrientation["PORTRAIT"] = "PORTRAIT";
|
|
858
|
-
return DeviceOrientation;
|
|
859
|
-
}({});
|
|
860
|
-
let LayoutMode = /*#__PURE__*/function (LayoutMode) {
|
|
861
|
-
LayoutMode["FULLSCREEN"] = "FULLSCREEN";
|
|
862
|
-
LayoutMode["COMPACT"] = "COMPACT";
|
|
863
|
-
return LayoutMode;
|
|
864
|
-
}({});
|
|
865
|
-
let BorderDirection = /*#__PURE__*/function (BorderDirection) {
|
|
866
|
-
BorderDirection["LEFT"] = "LEFT";
|
|
867
|
-
BorderDirection["BOTTOM"] = "BOTTOM";
|
|
868
|
-
return BorderDirection;
|
|
869
|
-
}({});
|
|
870
|
-
const BorderStyles = {
|
|
871
|
-
LEFT: [BorderDirection.LEFT],
|
|
872
|
-
BOTTOM: [BorderDirection.BOTTOM],
|
|
873
|
-
ALL: [BorderDirection.LEFT, BorderDirection.BOTTOM],
|
|
874
|
-
NONE: []
|
|
829
|
+
const DecimalSeparator = {
|
|
830
|
+
COMMA: ",",
|
|
831
|
+
PERIOD: "."
|
|
875
832
|
};
|
|
876
|
-
let IconType = /*#__PURE__*/function (IconType) {
|
|
877
|
-
IconType["MATH"] = "MATH";
|
|
878
|
-
IconType["SVG"] = "SVG";
|
|
879
|
-
IconType["TEXT"] = "TEXT";
|
|
880
|
-
return IconType;
|
|
881
|
-
}({});
|
|
882
|
-
let DecimalSeparator = /*#__PURE__*/function (DecimalSeparator) {
|
|
883
|
-
DecimalSeparator["COMMA"] = "COMMA";
|
|
884
|
-
DecimalSeparator["PERIOD"] = "PERIOD";
|
|
885
|
-
return DecimalSeparator;
|
|
886
|
-
}({});
|
|
887
|
-
let EchoAnimationType = /*#__PURE__*/function (EchoAnimationType) {
|
|
888
|
-
EchoAnimationType["SLIDE_AND_FADE"] = "SLIDE_AND_FADE";
|
|
889
|
-
EchoAnimationType["FADE_ONLY"] = "FADE_ONLY";
|
|
890
|
-
EchoAnimationType["LONG_FADE_ONLY"] = "LONG_FADE_ONLY";
|
|
891
|
-
return EchoAnimationType;
|
|
892
|
-
}({});
|
|
893
833
|
|
|
894
834
|
// NOTES(kevinb):
|
|
895
835
|
// - In order to get the correct decimal separator for the current locale,
|
|
@@ -1076,7 +1016,6 @@ var ActionType = /*#__PURE__*/function (ActionType) {
|
|
|
1076
1016
|
ActionType[ActionType["MQ_END"] = 0] = "MQ_END";
|
|
1077
1017
|
return ActionType;
|
|
1078
1018
|
}(ActionType || {});
|
|
1079
|
-
const decimalSymbol = decimalSeparator === DecimalSeparator.COMMA ? "," : ".";
|
|
1080
1019
|
function buildGenericCallback(str, type = ActionType.WRITE) {
|
|
1081
1020
|
return function (mathQuill) {
|
|
1082
1021
|
switch (type) {
|
|
@@ -1122,7 +1061,7 @@ const keyToMathquillMap = {
|
|
|
1122
1061
|
COS: buildNormalFunctionCallback("cos"),
|
|
1123
1062
|
TAN: buildNormalFunctionCallback("tan"),
|
|
1124
1063
|
CDOT: buildGenericCallback("\\cdot"),
|
|
1125
|
-
DECIMAL: buildGenericCallback(
|
|
1064
|
+
DECIMAL: buildGenericCallback(decimalSeparator),
|
|
1126
1065
|
DIVIDE: buildGenericCallback("\\div"),
|
|
1127
1066
|
EQUAL: buildGenericCallback("="),
|
|
1128
1067
|
GEQ: buildGenericCallback("\\geq"),
|
|
@@ -2474,6 +2413,66 @@ function Tabbar(props) {
|
|
|
2474
2413
|
})));
|
|
2475
2414
|
}
|
|
2476
2415
|
|
|
2416
|
+
/**
|
|
2417
|
+
* Constants that are shared between multiple files.
|
|
2418
|
+
*/
|
|
2419
|
+
|
|
2420
|
+
let KeypadType = /*#__PURE__*/function (KeypadType) {
|
|
2421
|
+
KeypadType["FRACTION"] = "FRACTION";
|
|
2422
|
+
KeypadType["EXPRESSION"] = "EXPRESSION";
|
|
2423
|
+
return KeypadType;
|
|
2424
|
+
}({});
|
|
2425
|
+
const KeyTypes = ["EMPTY",
|
|
2426
|
+
// For numerals, variables, and any other characters that themselves
|
|
2427
|
+
// compose 'values'.
|
|
2428
|
+
"VALUE",
|
|
2429
|
+
// For buttons that insert or adjust math in an input.
|
|
2430
|
+
"OPERATOR",
|
|
2431
|
+
// For buttons that move the cursor in an input (including via
|
|
2432
|
+
// deletion).
|
|
2433
|
+
"INPUT_NAVIGATION",
|
|
2434
|
+
// For buttons that modify the broader keypad state (e.g., by changing
|
|
2435
|
+
// the visible pane).
|
|
2436
|
+
"KEYPAD_NAVIGATION",
|
|
2437
|
+
// For buttons that house multiple buttons and have no action
|
|
2438
|
+
// themselves.
|
|
2439
|
+
"MANY",
|
|
2440
|
+
// For the echo animation that appears on press.
|
|
2441
|
+
"ECHO"];
|
|
2442
|
+
let DeviceOrientation = /*#__PURE__*/function (DeviceOrientation) {
|
|
2443
|
+
DeviceOrientation["LANDSCAPE"] = "LANDSCAPE";
|
|
2444
|
+
DeviceOrientation["PORTRAIT"] = "PORTRAIT";
|
|
2445
|
+
return DeviceOrientation;
|
|
2446
|
+
}({});
|
|
2447
|
+
let LayoutMode = /*#__PURE__*/function (LayoutMode) {
|
|
2448
|
+
LayoutMode["FULLSCREEN"] = "FULLSCREEN";
|
|
2449
|
+
LayoutMode["COMPACT"] = "COMPACT";
|
|
2450
|
+
return LayoutMode;
|
|
2451
|
+
}({});
|
|
2452
|
+
let BorderDirection = /*#__PURE__*/function (BorderDirection) {
|
|
2453
|
+
BorderDirection["LEFT"] = "LEFT";
|
|
2454
|
+
BorderDirection["BOTTOM"] = "BOTTOM";
|
|
2455
|
+
return BorderDirection;
|
|
2456
|
+
}({});
|
|
2457
|
+
const BorderStyles = {
|
|
2458
|
+
LEFT: [BorderDirection.LEFT],
|
|
2459
|
+
BOTTOM: [BorderDirection.BOTTOM],
|
|
2460
|
+
ALL: [BorderDirection.LEFT, BorderDirection.BOTTOM],
|
|
2461
|
+
NONE: []
|
|
2462
|
+
};
|
|
2463
|
+
let IconType = /*#__PURE__*/function (IconType) {
|
|
2464
|
+
IconType["MATH"] = "MATH";
|
|
2465
|
+
IconType["SVG"] = "SVG";
|
|
2466
|
+
IconType["TEXT"] = "TEXT";
|
|
2467
|
+
return IconType;
|
|
2468
|
+
}({});
|
|
2469
|
+
let EchoAnimationType = /*#__PURE__*/function (EchoAnimationType) {
|
|
2470
|
+
EchoAnimationType["SLIDE_AND_FADE"] = "SLIDE_AND_FADE";
|
|
2471
|
+
EchoAnimationType["FADE_ONLY"] = "FADE_ONLY";
|
|
2472
|
+
EchoAnimationType["LONG_FADE_ONLY"] = "LONG_FADE_ONLY";
|
|
2473
|
+
return EchoAnimationType;
|
|
2474
|
+
}({});
|
|
2475
|
+
|
|
2477
2476
|
const getDefaultOperatorFields = ({
|
|
2478
2477
|
key,
|
|
2479
2478
|
keyType: _keyType = "OPERATOR",
|
|
@@ -2551,17 +2550,7 @@ const KeyConfigs = {
|
|
|
2551
2550
|
keyType: "VALUE",
|
|
2552
2551
|
// I18N: A label for a 'decimal' sign (represented as '.' or ',').
|
|
2553
2552
|
ariaLabel: i18n._("Decimal")
|
|
2554
|
-
}),
|
|
2555
|
-
icon: decimalSeparator === DecimalSeparator.COMMA ? {
|
|
2556
|
-
// TODO(charlie): Get an SVG icon for the comma, or verify with
|
|
2557
|
-
// design that the text-rendered version is acceptable.
|
|
2558
|
-
type: IconType.TEXT,
|
|
2559
|
-
data: ","
|
|
2560
|
-
} : {
|
|
2561
|
-
type: IconType.SVG,
|
|
2562
|
-
data: "PERIOD"
|
|
2563
|
-
}
|
|
2564
|
-
}),
|
|
2553
|
+
})),
|
|
2565
2554
|
PERIOD: _extends({}, getDefaultOperatorFields({
|
|
2566
2555
|
key: "PERIOD",
|
|
2567
2556
|
keyType: "VALUE",
|
|
@@ -3126,16 +3115,32 @@ function ButtonAsset({
|
|
|
3126
3115
|
d: "M16.735 16.8558c0 1.024.272 1.812.816 2.364.552.544 1.32.816 2.304.816.528 0 .992-.084 1.392-.252.408-.168.752-.392 1.032-.672.28-.288.492-.62.636-.996.144-.384.216-.792.216-1.224 0-.504-.08-.952-.24-1.344-.152-.4-.372-.74-.66-1.02-.28-.28-.616-.492-1.008-.636-.392-.152-.82-.228-1.284-.228-.488 0-.928.08-1.32.24-.392.16-.728.384-1.008.672-.28.28-.496.616-.648 1.008-.152.384-.228.808-.228 1.272zm4.428 5.364c.16-.2.308-.388.444-.564.136-.184.264-.368.384-.552-.416.296-.88.524-1.392.684-.512.152-1.056.228-1.632.228-.624 0-1.224-.104-1.8-.312-.576-.216-1.088-.532-1.536-.948-.448-.424-.808-.944-1.08-1.56-.264-.624-.396-1.34-.396-2.148 0-.76.14-1.476.42-2.148.288-.672.688-1.256 1.2-1.752.512-.504 1.124-.9 1.836-1.188.712-.288 1.5-.432 2.364-.432.856 0 1.632.14 2.328.42.696.272 1.288.66 1.776 1.164.488.496.864 1.092 1.128 1.788.264.688.396 1.448.396 2.28 0 .52-.048 1.012-.144 1.476-.088.464-.22.916-.396 1.356-.168.432-.376.86-.624 1.284-.24.416-.512.84-.816 1.272l-4.068 5.832c-.12.176-.3.32-.54.432-.232.112-.496.168-.792.168h-2.364l5.304-6.78z",
|
|
3127
3116
|
fill: "#21242C"
|
|
3128
3117
|
}));
|
|
3129
|
-
// TODO(ned): Per the notes in `KeyConfigs`, shouldn't this be a comma
|
|
3130
|
-
// that we replace with the period icon for i18n? Duplicating for now.
|
|
3131
3118
|
case "DECIMAL":
|
|
3132
3119
|
case "PERIOD":
|
|
3120
|
+
// Different locales use different symbols for the decimal separator
|
|
3121
|
+
// (, vs .)
|
|
3122
|
+
if (id === "DECIMAL" && decimalSeparator === DecimalSeparator.COMMA) {
|
|
3123
|
+
// comma decimal separator
|
|
3124
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
3125
|
+
width: "40",
|
|
3126
|
+
height: "40",
|
|
3127
|
+
viewBox: "0 0 32 32",
|
|
3128
|
+
fill: "none",
|
|
3129
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3130
|
+
"data-test-id": "comma-decimal"
|
|
3131
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
3132
|
+
d: "M11.5559 25.3544C11.8679 24.661 12.1799 23.933 12.4919 23.1704C12.8039 22.425 13.0986 21.6884 13.3759 20.9604C13.6706 20.2324 13.9219 19.5737 14.1299 18.9844H16.6259L16.7299 19.2704C16.4526 19.877 16.1232 20.5357 15.7419 21.2464C15.3606 21.9397 14.9619 22.633 14.5459 23.3264C14.1299 24.037 13.7139 24.713 13.2979 25.3544H11.5559Z",
|
|
3133
|
+
fill: "#21242C"
|
|
3134
|
+
}));
|
|
3135
|
+
}
|
|
3136
|
+
// period / US decimal separator
|
|
3133
3137
|
return /*#__PURE__*/React.createElement("svg", {
|
|
3134
3138
|
width: "40",
|
|
3135
3139
|
height: "40",
|
|
3136
3140
|
viewBox: "0 0 40 40",
|
|
3137
3141
|
fill: "none",
|
|
3138
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
3142
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3143
|
+
"data-test-id": "period-decimal"
|
|
3139
3144
|
}, /*#__PURE__*/React.createElement("path", {
|
|
3140
3145
|
d: "M18.3401 27.512c0-.232.04-.448.12-.648.088-.208.204-.388.348-.54.152-.152.328-.272.528-.36.208-.088.428-.132.66-.132.232 0 .448.044.648.132.208.088.388.208.54.36.152.152.272.332.36.54.088.2.132.416.132.648 0 .24-.044.46-.132.66-.088.2-.208.376-.36.528-.152.152-.332.268-.54.348-.2.088-.416.132-.648.132-.232 0-.452-.044-.66-.132-.2-.08-.376-.196-.528-.348-.144-.152-.26-.328-.348-.528-.08-.2-.12-.42-.12-.66z",
|
|
3141
3146
|
fill: "#21242C"
|