@khanacademy/math-input 14.2.2 → 15.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/enums.d.ts +0 -4
- package/dist/es/index.js +173 -113
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +1309 -1191
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/package.json +3 -1
- 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 +10 -3
- package/src/components/keypad/__tests__/keypad.test.tsx +35 -0
- package/src/components/keypad/button-assets.tsx +27 -3
- package/src/components/keypad/mobile-keypad.tsx +25 -28
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @khanacademy/math-input
|
|
2
2
|
|
|
3
|
+
## 15.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
## 15.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [#786](https://github.com/Khan/perseus/pull/786) [`af4ebf37`](https://github.com/Khan/perseus/commit/af4ebf37dfed15ffd93a8cf2a20d0be464120dd7) Thanks [@handeyeco](https://github.com/handeyeco)! - Added a new required dep in Perseus and MathInput (required by WB)
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#791](https://github.com/Khan/perseus/pull/791) [`3eb0e158`](https://github.com/Khan/perseus/commit/3eb0e15860224cc595d5b7e78d2a5d60e808561c) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Minor fix to ensure that the keypadElement is always provided to mobile keypad consumers
|
|
18
|
+
|
|
3
19
|
## 14.2.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
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 = "
|
|
23
|
+
const libVersion = "15.0.1";
|
|
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"),
|
|
@@ -1279,10 +1218,9 @@ const mobileKeyTranslator = _extends({}, keyToMathquillMap, {
|
|
|
1279
1218
|
* from MathQuill changes.
|
|
1280
1219
|
*/
|
|
1281
1220
|
class MathWrapper {
|
|
1282
|
-
// MathQuill MathField input
|
|
1283
|
-
|
|
1284
1221
|
constructor(element, callbacks = {}) {
|
|
1285
1222
|
this.mathField = void 0;
|
|
1223
|
+
// MathQuill MathField input
|
|
1286
1224
|
this.callbacks = void 0;
|
|
1287
1225
|
this.mathField = createMathField(element, () => {
|
|
1288
1226
|
return {
|
|
@@ -1471,14 +1409,18 @@ class MathInput extends React.Component {
|
|
|
1471
1409
|
this.didTouchOutside = void 0;
|
|
1472
1410
|
this.didScroll = void 0;
|
|
1473
1411
|
this.mathField = void 0;
|
|
1412
|
+
// @ts-expect-error - TS2564 - Property 'recordTouchStartOutside' has no initializer and is not definitely assigned in the constructor.
|
|
1474
1413
|
this.recordTouchStartOutside = void 0;
|
|
1414
|
+
// @ts-expect-error - TS2564 - Property 'blurOnTouchEndOutside' has no initializer and is not definitely assigned in the constructor.
|
|
1475
1415
|
this.blurOnTouchEndOutside = void 0;
|
|
1476
1416
|
this.dragListener = void 0;
|
|
1477
1417
|
this.inputRef = void 0;
|
|
1478
1418
|
this._isMounted = void 0;
|
|
1479
1419
|
this._mathContainer = void 0;
|
|
1420
|
+
// @ts-expect-error - TS2564 - Property '_container' has no initializer and is not definitely assigned in the constructor.
|
|
1480
1421
|
this._container = void 0;
|
|
1481
1422
|
this._root = void 0;
|
|
1423
|
+
// @ts-expect-error - TS2564 - Property '_containerBounds' has no initializer and is not definitely assigned in the constructor.
|
|
1482
1424
|
this._containerBounds = void 0;
|
|
1483
1425
|
this._keypadBounds = void 0;
|
|
1484
1426
|
this.state = {
|
|
@@ -1504,6 +1446,7 @@ class MathInput extends React.Component {
|
|
|
1504
1446
|
this._root.style.padding = `${padding.paddingTop}px ${padding.paddingRight}px` + ` ${padding.paddingBottom}px ${padding.paddingLeft}px`;
|
|
1505
1447
|
this._root.style.fontSize = `${fontSizePt}pt`;
|
|
1506
1448
|
};
|
|
1449
|
+
/** Gets and cache they bounds of the keypadElement */
|
|
1507
1450
|
this._getKeypadBounds = () => {
|
|
1508
1451
|
if (!this._keypadBounds) {
|
|
1509
1452
|
var _this$props$keypadEle;
|
|
@@ -1574,7 +1517,7 @@ class MathInput extends React.Component {
|
|
|
1574
1517
|
var _this$props$keypadEle2, _this$props;
|
|
1575
1518
|
// Pass this component's handleKey method to the keypad so it can call
|
|
1576
1519
|
// it whenever it needs to trigger a keypress action.
|
|
1577
|
-
(_this$props$keypadEle2 = this.props.keypadElement) == null
|
|
1520
|
+
(_this$props$keypadEle2 = this.props.keypadElement) == null || _this$props$keypadEle2.setKeyHandler(key => {
|
|
1578
1521
|
const cursor = this.mathField.pressKey(key);
|
|
1579
1522
|
|
|
1580
1523
|
// Trigger an `onChange` if the value in the input changed, and hide
|
|
@@ -1597,7 +1540,7 @@ class MathInput extends React.Component {
|
|
|
1597
1540
|
return cursor;
|
|
1598
1541
|
});
|
|
1599
1542
|
this.mathField.focus();
|
|
1600
|
-
(_this$props = this.props) == null
|
|
1543
|
+
(_this$props = this.props) == null || _this$props.onFocus();
|
|
1601
1544
|
this.setState({
|
|
1602
1545
|
focused: true
|
|
1603
1546
|
}, () => {
|
|
@@ -1620,6 +1563,30 @@ class MathInput extends React.Component {
|
|
|
1620
1563
|
});
|
|
1621
1564
|
});
|
|
1622
1565
|
};
|
|
1566
|
+
/**
|
|
1567
|
+
* Tries to determine which DOM node to place the cursor next to based on
|
|
1568
|
+
* where the user drags the cursor handle. If it finds a node it will
|
|
1569
|
+
* place the cursor next to it, update the handle to be under the cursor,
|
|
1570
|
+
* and return true. If it doesn't find a node, it returns false.
|
|
1571
|
+
*
|
|
1572
|
+
* It searches for nodes by doing it tests at the following points:
|
|
1573
|
+
*
|
|
1574
|
+
* (x - dx, y), (x, y), (x + dx, y)
|
|
1575
|
+
*
|
|
1576
|
+
* If it doesn't find any nodes from the rendered math it will update y
|
|
1577
|
+
* by adding dy.
|
|
1578
|
+
*
|
|
1579
|
+
* The algorithm ends its search when y goes outside the bounds of
|
|
1580
|
+
* containerBounds.
|
|
1581
|
+
*
|
|
1582
|
+
* @param {DOMRect} containerBounds - bounds of the container node
|
|
1583
|
+
* @param {number} x - the initial x coordinate in the viewport
|
|
1584
|
+
* @param {number} y - the initial y coordinate in the viewport
|
|
1585
|
+
* @param {number} dx - horizontal spacing between elementFromPoint calls
|
|
1586
|
+
* @param {number} dy - vertical spacing between elementFromPoint calls,
|
|
1587
|
+
* sign determines direction.
|
|
1588
|
+
* @returns {boolean} - true if a node was hit, false otherwise.
|
|
1589
|
+
*/
|
|
1623
1590
|
this._findHitNode = (containerBounds, x, y, dx, dy) => {
|
|
1624
1591
|
while (y >= containerBounds.top && y <= containerBounds.bottom) {
|
|
1625
1592
|
y += dy;
|
|
@@ -1691,6 +1658,13 @@ class MathInput extends React.Component {
|
|
|
1691
1658
|
}
|
|
1692
1659
|
return false;
|
|
1693
1660
|
};
|
|
1661
|
+
/**
|
|
1662
|
+
* Inserts the cursor at the DOM node closest to the given coordinates,
|
|
1663
|
+
* based on hit-tests conducted using #_findHitNode.
|
|
1664
|
+
*
|
|
1665
|
+
* @param {number} x - the x coordinate in the viewport
|
|
1666
|
+
* @param {number} y - the y coordinate in the viewport
|
|
1667
|
+
*/
|
|
1694
1668
|
this._insertCursorAtClosestNode = (x, y) => {
|
|
1695
1669
|
const cursor = this.mathField.getCursor();
|
|
1696
1670
|
|
|
@@ -1804,6 +1778,12 @@ class MathInput extends React.Component {
|
|
|
1804
1778
|
this._updateCursorHandle();
|
|
1805
1779
|
}
|
|
1806
1780
|
};
|
|
1781
|
+
/**
|
|
1782
|
+
* When a touch starts in the cursor handle, we track it so as to avoid
|
|
1783
|
+
* handling any touch events ourself.
|
|
1784
|
+
*
|
|
1785
|
+
* @param {TouchEvent} e - the raw touch event from the browser
|
|
1786
|
+
*/
|
|
1807
1787
|
this.onCursorHandleTouchStart = e => {
|
|
1808
1788
|
// NOTE(charlie): The cursor handle is a child of this view, so whenever
|
|
1809
1789
|
// it receives a touch event, that event would also typically be bubbled
|
|
@@ -1827,6 +1807,12 @@ class MathInput extends React.Component {
|
|
|
1827
1807
|
return value;
|
|
1828
1808
|
}
|
|
1829
1809
|
};
|
|
1810
|
+
/**
|
|
1811
|
+
* When the user moves the cursor handle update the position of the cursor
|
|
1812
|
+
* and the handle.
|
|
1813
|
+
*
|
|
1814
|
+
* @param {TouchEvent} e - the raw touch event from the browser
|
|
1815
|
+
*/
|
|
1830
1816
|
this.onCursorHandleTouchMove = e => {
|
|
1831
1817
|
e.stopPropagation();
|
|
1832
1818
|
const x = e.changedTouches[0].clientX;
|
|
@@ -1859,10 +1845,20 @@ class MathInput extends React.Component {
|
|
|
1859
1845
|
const adjustedY = y - distanceAboveFingerToTrySelecting;
|
|
1860
1846
|
this._insertCursorAtClosestNode(x, adjustedY);
|
|
1861
1847
|
};
|
|
1848
|
+
/**
|
|
1849
|
+
* When the user releases the cursor handle, animate it back into place.
|
|
1850
|
+
*
|
|
1851
|
+
* @param {TouchEvent} e - the raw touch event from the browser
|
|
1852
|
+
*/
|
|
1862
1853
|
this.onCursorHandleTouchEnd = e => {
|
|
1863
1854
|
e.stopPropagation();
|
|
1864
1855
|
this._updateCursorHandle(true);
|
|
1865
1856
|
};
|
|
1857
|
+
/**
|
|
1858
|
+
* If the gesture is cancelled mid-drag, simply hide it.
|
|
1859
|
+
*
|
|
1860
|
+
* @param {TouchEvent} e - the raw touch event from the browser
|
|
1861
|
+
*/
|
|
1866
1862
|
this.onCursorHandleTouchCancel = e => {
|
|
1867
1863
|
e.stopPropagation();
|
|
1868
1864
|
this._updateCursorHandle(true);
|
|
@@ -1921,6 +1917,10 @@ class MathInput extends React.Component {
|
|
|
1921
1917
|
const focusedBorderWidthPx = 2;
|
|
1922
1918
|
return this.state.focused ? focusedBorderWidthPx : normalBorderWidthPx;
|
|
1923
1919
|
};
|
|
1920
|
+
// Calculate the appropriate padding based on the border width (which is
|
|
1921
|
+
// considered 'padding', since we're using 'border-box') and the fact
|
|
1922
|
+
// that MathQuill automatically applies 2px of padding to the inner
|
|
1923
|
+
// input.
|
|
1924
1924
|
this.getInputInnerPadding = () => {
|
|
1925
1925
|
const paddingInset = totalDesiredPadding - this.getBorderWidthPx();
|
|
1926
1926
|
|
|
@@ -2413,6 +2413,66 @@ function Tabbar(props) {
|
|
|
2413
2413
|
})));
|
|
2414
2414
|
}
|
|
2415
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
|
+
|
|
2416
2476
|
const getDefaultOperatorFields = ({
|
|
2417
2477
|
key,
|
|
2418
2478
|
keyType: _keyType = "OPERATOR",
|
|
@@ -2490,17 +2550,7 @@ const KeyConfigs = {
|
|
|
2490
2550
|
keyType: "VALUE",
|
|
2491
2551
|
// I18N: A label for a 'decimal' sign (represented as '.' or ',').
|
|
2492
2552
|
ariaLabel: i18n._("Decimal")
|
|
2493
|
-
}),
|
|
2494
|
-
icon: decimalSeparator === DecimalSeparator.COMMA ? {
|
|
2495
|
-
// TODO(charlie): Get an SVG icon for the comma, or verify with
|
|
2496
|
-
// design that the text-rendered version is acceptable.
|
|
2497
|
-
type: IconType.TEXT,
|
|
2498
|
-
data: ","
|
|
2499
|
-
} : {
|
|
2500
|
-
type: IconType.SVG,
|
|
2501
|
-
data: "PERIOD"
|
|
2502
|
-
}
|
|
2503
|
-
}),
|
|
2553
|
+
})),
|
|
2504
2554
|
PERIOD: _extends({}, getDefaultOperatorFields({
|
|
2505
2555
|
key: "PERIOD",
|
|
2506
2556
|
keyType: "VALUE",
|
|
@@ -3065,16 +3115,32 @@ function ButtonAsset({
|
|
|
3065
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",
|
|
3066
3116
|
fill: "#21242C"
|
|
3067
3117
|
}));
|
|
3068
|
-
// TODO(ned): Per the notes in `KeyConfigs`, shouldn't this be a comma
|
|
3069
|
-
// that we replace with the period icon for i18n? Duplicating for now.
|
|
3070
3118
|
case "DECIMAL":
|
|
3071
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
|
|
3072
3137
|
return /*#__PURE__*/React.createElement("svg", {
|
|
3073
3138
|
width: "40",
|
|
3074
3139
|
height: "40",
|
|
3075
3140
|
viewBox: "0 0 40 40",
|
|
3076
3141
|
fill: "none",
|
|
3077
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
3142
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3143
|
+
"data-test-id": "period-decimal"
|
|
3078
3144
|
}, /*#__PURE__*/React.createElement("path", {
|
|
3079
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",
|
|
3080
3146
|
fill: "#21242C"
|
|
@@ -5160,13 +5226,6 @@ function processStyleType(style) {
|
|
|
5160
5226
|
}
|
|
5161
5227
|
|
|
5162
5228
|
class TransitionChild extends React.Component {
|
|
5163
|
-
// Each 2-tuple in the queue represents two classnames: one to remove and
|
|
5164
|
-
// one to add (in that order).
|
|
5165
|
-
|
|
5166
|
-
// We keep track of all of the current applied classes so that we can remove
|
|
5167
|
-
// them before a new transition starts in the case of the current transition
|
|
5168
|
-
// being interrupted.
|
|
5169
|
-
|
|
5170
5229
|
// The use of getDerivedStateFromProps here is to avoid an extra call to
|
|
5171
5230
|
// setState if the component re-enters. This can happen if TransitionGroup
|
|
5172
5231
|
// sets `in` from `false` to `true`.
|
|
@@ -5183,7 +5242,12 @@ class TransitionChild extends React.Component {
|
|
|
5183
5242
|
}
|
|
5184
5243
|
constructor(props) {
|
|
5185
5244
|
super(props);
|
|
5245
|
+
// Each 2-tuple in the queue represents two classnames: one to remove and
|
|
5246
|
+
// one to add (in that order).
|
|
5186
5247
|
this.classNameQueue = void 0;
|
|
5248
|
+
// We keep track of all of the current applied classes so that we can remove
|
|
5249
|
+
// them before a new transition starts in the case of the current transition
|
|
5250
|
+
// being interrupted.
|
|
5187
5251
|
this.appliedClassNames = void 0;
|
|
5188
5252
|
this._isMounted = false;
|
|
5189
5253
|
this.addClass = (elem, className) => {
|
|
@@ -5412,7 +5476,7 @@ class MobileKeypad extends React.Component {
|
|
|
5412
5476
|
this.dismiss = () => {
|
|
5413
5477
|
var _this$props$onDismiss, _this$props;
|
|
5414
5478
|
this.props.setKeypadActive(false);
|
|
5415
|
-
(_this$props$onDismiss = (_this$props = this.props).onDismiss) == null
|
|
5479
|
+
(_this$props$onDismiss = (_this$props = this.props).onDismiss) == null || _this$props$onDismiss.call(_this$props);
|
|
5416
5480
|
};
|
|
5417
5481
|
this.configure = (configuration, cb) => {
|
|
5418
5482
|
this.setState({
|
|
@@ -5458,7 +5522,7 @@ class MobileKeypad extends React.Component {
|
|
|
5458
5522
|
this._containerResizeObserver.observe(this._containerRef.current);
|
|
5459
5523
|
}
|
|
5460
5524
|
}
|
|
5461
|
-
(_this$props$onElement = (_this$props2 = this.props).onElementMounted) == null
|
|
5525
|
+
(_this$props$onElement = (_this$props2 = this.props).onElementMounted) == null || _this$props$onElement.call(_this$props2, {
|
|
5462
5526
|
activate: this.activate,
|
|
5463
5527
|
dismiss: this.dismiss,
|
|
5464
5528
|
configure: this.configure,
|
|
@@ -5471,7 +5535,7 @@ class MobileKeypad extends React.Component {
|
|
|
5471
5535
|
var _this$_containerResiz;
|
|
5472
5536
|
window.removeEventListener("resize", this._throttleResizeHandler);
|
|
5473
5537
|
window.removeEventListener("orientationchange", this._throttleResizeHandler);
|
|
5474
|
-
(_this$_containerResiz = this._containerResizeObserver) == null
|
|
5538
|
+
(_this$_containerResiz = this._containerResizeObserver) == null || _this$_containerResiz.disconnect();
|
|
5475
5539
|
}
|
|
5476
5540
|
_handleClickKey(key) {
|
|
5477
5541
|
var _this$state$keyHandle, _this$state;
|
|
@@ -5499,7 +5563,10 @@ class MobileKeypad extends React.Component {
|
|
|
5499
5563
|
...(Array.isArray(style) ? style : [style])];
|
|
5500
5564
|
const isExpression = (keypadConfig == null ? void 0 : keypadConfig.keypadType) === "EXPRESSION";
|
|
5501
5565
|
const convertDotToTimes = keypadConfig == null ? void 0 : keypadConfig.times;
|
|
5502
|
-
return /*#__PURE__*/React.createElement(
|
|
5566
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
5567
|
+
style: containerStyle,
|
|
5568
|
+
forwardRef: this._containerRef
|
|
5569
|
+
}, /*#__PURE__*/React.createElement(AphroditeCSSTransitionGroup, {
|
|
5503
5570
|
transitionEnterTimeout: AnimationDurationInMS,
|
|
5504
5571
|
transitionLeaveTimeout: AnimationDurationInMS,
|
|
5505
5572
|
transitionStyle: {
|
|
@@ -5518,10 +5585,7 @@ class MobileKeypad extends React.Component {
|
|
|
5518
5585
|
transform: "translate3d(0, 100%, 0)"
|
|
5519
5586
|
}
|
|
5520
5587
|
}
|
|
5521
|
-
}, keypadActive ? /*#__PURE__*/React.createElement(
|
|
5522
|
-
style: containerStyle,
|
|
5523
|
-
forwardRef: this._containerRef
|
|
5524
|
-
}, /*#__PURE__*/React.createElement(Keypad$2, {
|
|
5588
|
+
}, keypadActive ? /*#__PURE__*/React.createElement(Keypad$2, {
|
|
5525
5589
|
onAnalyticsEvent: this.props.onAnalyticsEvent,
|
|
5526
5590
|
extraKeys: keypadConfig == null ? void 0 : keypadConfig.extraKeys,
|
|
5527
5591
|
onClickKey: key => this._handleClickKey(key),
|
|
@@ -5536,7 +5600,7 @@ class MobileKeypad extends React.Component {
|
|
|
5536
5600
|
advancedRelations: isExpression,
|
|
5537
5601
|
expandedView: containerWidth > expandedViewThreshold$1,
|
|
5538
5602
|
showDismiss: true
|
|
5539
|
-
})
|
|
5603
|
+
}) : null));
|
|
5540
5604
|
}
|
|
5541
5605
|
}
|
|
5542
5606
|
const styles$c = StyleSheet.create({
|
|
@@ -7840,7 +7904,6 @@ class PopoverManager extends React.Component {
|
|
|
7840
7904
|
// naming convention: verb + noun
|
|
7841
7905
|
// the noun should be one of the other properties in the object that's
|
|
7842
7906
|
// being dispatched
|
|
7843
|
-
|
|
7844
7907
|
const dismissKeypad = () => {
|
|
7845
7908
|
return {
|
|
7846
7909
|
type: "DismissKeypad"
|
|
@@ -8622,7 +8685,7 @@ class KeypadContainer extends React.Component {
|
|
|
8622
8685
|
});
|
|
8623
8686
|
const containerWidth = ((_this$_containerRef$c = this._containerRef.current) == null ? void 0 : _this$_containerRef$c.clientWidth) || 0;
|
|
8624
8687
|
const containerHeight = ((_this$_containerRef$c2 = this._containerRef.current) == null ? void 0 : _this$_containerRef$c2.clientHeight) || 0;
|
|
8625
|
-
(_this$props$onPageSiz = (_this$props = this.props).onPageSizeChange) == null
|
|
8688
|
+
(_this$props$onPageSiz = (_this$props = this.props).onPageSizeChange) == null || _this$props$onPageSiz.call(_this$props, window.innerWidth, window.innerHeight, containerWidth, containerHeight);
|
|
8626
8689
|
};
|
|
8627
8690
|
this.renderKeypad = () => {
|
|
8628
8691
|
const {
|
|
@@ -8698,7 +8761,7 @@ class KeypadContainer extends React.Component {
|
|
|
8698
8761
|
var _this$_containerResiz;
|
|
8699
8762
|
window.removeEventListener("resize", this._throttleResizeHandler);
|
|
8700
8763
|
window.removeEventListener("orientationchange", this._throttleResizeHandler);
|
|
8701
|
-
(_this$_containerResiz = this._containerResizeObserver) == null
|
|
8764
|
+
(_this$_containerResiz = this._containerResizeObserver) == null || _this$_containerResiz.disconnect();
|
|
8702
8765
|
}
|
|
8703
8766
|
render() {
|
|
8704
8767
|
const {
|
|
@@ -8830,10 +8893,7 @@ var KeypadContainer$1 = connect(mapStateToProps, mapDispatchToProps, null, {
|
|
|
8830
8893
|
* It is entirely ignorant of the existence of popovers and the positions of
|
|
8831
8894
|
* DOM nodes, operating solely on IDs. The state machine does accommodate for
|
|
8832
8895
|
* multi-touch interactions, tracking gesture state on a per-touch basis.
|
|
8833
|
-
*/
|
|
8834
|
-
|
|
8835
|
-
// exported for tests
|
|
8836
|
-
|
|
8896
|
+
*/ // exported for tests
|
|
8837
8897
|
const defaultOptions = {
|
|
8838
8898
|
longPressWaitTimeMs: 50,
|
|
8839
8899
|
swipeThresholdPx: 20,
|
|
@@ -9010,7 +9070,7 @@ class GestureStateMachine {
|
|
|
9010
9070
|
// gestures are ignored.
|
|
9011
9071
|
if (this.swipeState.touchId === touchId) {
|
|
9012
9072
|
var _this$handlers$onSwip, _this$handlers;
|
|
9013
|
-
(_this$handlers$onSwip = (_this$handlers = this.handlers).onSwipeChange) == null
|
|
9073
|
+
(_this$handlers$onSwip = (_this$handlers = this.handlers).onSwipeChange) == null || _this$handlers$onSwip.call(_this$handlers, pageX - this.swipeState.startX);
|
|
9014
9074
|
}
|
|
9015
9075
|
} else if (this.touchState[touchId]) {
|
|
9016
9076
|
// It could be touch events started outside the keypad and
|
|
@@ -9031,7 +9091,7 @@ class GestureStateMachine {
|
|
|
9031
9091
|
touchId,
|
|
9032
9092
|
startX
|
|
9033
9093
|
};
|
|
9034
|
-
(_this$handlers$onSwip2 = (_this$handlers2 = this.handlers).onSwipeChange) == null
|
|
9094
|
+
(_this$handlers$onSwip2 = (_this$handlers2 = this.handlers).onSwipeChange) == null || _this$handlers$onSwip2.call(_this$handlers2, pageX - this.swipeState.startX);
|
|
9035
9095
|
} else {
|
|
9036
9096
|
const id = getId();
|
|
9037
9097
|
if (id !== activeNodeId) {
|
|
@@ -9055,7 +9115,7 @@ class GestureStateMachine {
|
|
|
9055
9115
|
// gestures are ignored.
|
|
9056
9116
|
if (this.swipeState.touchId === touchId) {
|
|
9057
9117
|
var _this$handlers$onSwip3, _this$handlers3;
|
|
9058
|
-
(_this$handlers$onSwip3 = (_this$handlers3 = this.handlers).onSwipeEnd) == null
|
|
9118
|
+
(_this$handlers$onSwip3 = (_this$handlers3 = this.handlers).onSwipeEnd) == null || _this$handlers$onSwip3.call(_this$handlers3, pageX - this.swipeState.startX);
|
|
9059
9119
|
this.swipeState = null;
|
|
9060
9120
|
}
|
|
9061
9121
|
} else if (this.touchState[touchId]) {
|
|
@@ -9090,7 +9150,7 @@ class GestureStateMachine {
|
|
|
9090
9150
|
if (this.swipeState) {
|
|
9091
9151
|
if (this.swipeState.touchId === touchId) {
|
|
9092
9152
|
var _this$handlers$onSwip4, _this$handlers4;
|
|
9093
|
-
(_this$handlers$onSwip4 = (_this$handlers4 = this.handlers).onSwipeEnd) == null
|
|
9153
|
+
(_this$handlers$onSwip4 = (_this$handlers4 = this.handlers).onSwipeEnd) == null || _this$handlers$onSwip4.call(_this$handlers4, 0);
|
|
9094
9154
|
this.swipeState = null;
|
|
9095
9155
|
}
|
|
9096
9156
|
} else if (this.touchState[touchId]) {
|
|
@@ -10034,7 +10094,7 @@ class ProvidedKeypad extends React.Component {
|
|
|
10034
10094
|
setKeyHandler: this.setKeyHandler,
|
|
10035
10095
|
getDOMNode: this.getDOMNode
|
|
10036
10096
|
});
|
|
10037
|
-
(_this$props$onElement = (_this$props = this.props).onElementMounted) == null
|
|
10097
|
+
(_this$props$onElement = (_this$props = this.props).onElementMounted) == null || _this$props$onElement.call(_this$props, elementWithDispatchMethods);
|
|
10038
10098
|
};
|
|
10039
10099
|
this.onDismiss = () => {
|
|
10040
10100
|
var _this$props$onDismiss, _this$props2;
|
|
@@ -10044,7 +10104,7 @@ class ProvidedKeypad extends React.Component {
|
|
|
10044
10104
|
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V1"
|
|
10045
10105
|
}
|
|
10046
10106
|
});
|
|
10047
|
-
(_this$props$onDismiss = (_this$props2 = this.props).onDismiss) == null
|
|
10107
|
+
(_this$props$onDismiss = (_this$props2 = this.props).onDismiss) == null || _this$props$onDismiss.call(_this$props2);
|
|
10048
10108
|
};
|
|
10049
10109
|
this.store = createStore();
|
|
10050
10110
|
}
|