@khanacademy/math-input 6.0.2 → 7.0.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/components/input/math-input.d.ts +2 -2
  3. package/dist/components/input/math-input.js.flow +2 -2
  4. package/dist/components/keypad/index.d.ts +2 -26
  5. package/dist/components/keypad/index.js.flow +2 -31
  6. package/dist/components/keypad/keypad.d.ts +26 -0
  7. package/dist/components/keypad/keypad.js.flow +37 -0
  8. package/dist/components/keypad/mobile-keypad.d.ts +39 -0
  9. package/dist/components/keypad/mobile-keypad.js.flow +57 -0
  10. package/dist/components/keypad/shared-keys.d.ts +1 -1
  11. package/dist/components/keypad/shared-keys.js.flow +1 -1
  12. package/dist/components/keypad-legacy/index.d.ts +1 -0
  13. package/dist/components/keypad-legacy/index.js.flow +7 -0
  14. package/dist/components/keypad-legacy/provided-keypad.d.ts +2 -2
  15. package/dist/components/keypad-legacy/provided-keypad.js.flow +10 -2
  16. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +1 -1
  17. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +1 -1
  18. package/dist/components/keypad-legacy/two-page-keypad.d.ts +1 -1
  19. package/dist/components/keypad-legacy/two-page-keypad.js.flow +1 -1
  20. package/dist/components/tabbar/index.d.ts +2 -0
  21. package/dist/components/tabbar/index.js.flow +8 -0
  22. package/dist/es/index.js +306 -173
  23. package/dist/es/index.js.map +1 -1
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.js +322 -187
  26. package/dist/index.js.flow +9 -9
  27. package/dist/index.js.map +1 -1
  28. package/dist/types.d.ts +9 -0
  29. package/dist/types.js.flow +12 -0
  30. package/package.json +2 -2
  31. package/src/components/input/math-input.tsx +4 -5
  32. package/src/components/keypad/index.tsx +2 -173
  33. package/src/components/keypad/keypad.stories.tsx +2 -1
  34. package/src/components/keypad/keypad.tsx +171 -0
  35. package/src/components/keypad/mobile-keypad.tsx +165 -0
  36. package/src/components/keypad/shared-keys.tsx +1 -1
  37. package/src/components/keypad-legacy/index.ts +1 -0
  38. package/src/components/keypad-legacy/provided-keypad.tsx +7 -2
  39. package/src/components/keypad-legacy/two-page-keypad.tsx +3 -2
  40. package/src/components/prop-types.js +0 -1
  41. package/src/components/tabbar/index.ts +2 -0
  42. package/src/full-math-input.stories.tsx +78 -0
  43. package/src/index.ts +28 -9
  44. package/src/types.ts +11 -0
  45. package/tsconfig-build.tsbuildinfo +1 -1
  46. package/src/math-input.stories.tsx +0 -67
package/dist/index.js CHANGED
@@ -10,9 +10,9 @@ var React = require('react');
10
10
  var ReactDOM = require('react-dom');
11
11
  var $ = require('jquery');
12
12
  var MathQuill = require('mathquill');
13
- var PropTypes = require('prop-types');
14
13
  var reactRedux = require('react-redux');
15
14
  var katex = require('katex');
15
+ var PropTypes = require('prop-types');
16
16
  var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
17
17
  var Clickable = require('@khanacademy/wonder-blocks-clickable');
18
18
  var reactTransitionGroup = require('react-transition-group');
@@ -21,21 +21,21 @@ var Redux = require('redux');
21
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
22
 
23
23
  function _interopNamespace(e) {
24
- if (e && e.__esModule) return e;
25
- var n = Object.create(null);
26
- if (e) {
27
- Object.keys(e).forEach(function (k) {
28
- if (k !== 'default') {
29
- var d = Object.getOwnPropertyDescriptor(e, k);
30
- Object.defineProperty(n, k, d.get ? d : {
31
- enumerable: true,
32
- get: function () { return e[k]; }
33
- });
34
- }
24
+ if (e && e.__esModule) return e;
25
+ var n = Object.create(null);
26
+ if (e) {
27
+ Object.keys(e).forEach(function (k) {
28
+ if (k !== 'default') {
29
+ var d = Object.getOwnPropertyDescriptor(e, k);
30
+ Object.defineProperty(n, k, d.get ? d : {
31
+ enumerable: true,
32
+ get: function () { return e[k]; }
35
33
  });
36
- }
37
- n["default"] = e;
38
- return Object.freeze(n);
34
+ }
35
+ });
36
+ }
37
+ n["default"] = e;
38
+ return Object.freeze(n);
39
39
  }
40
40
 
41
41
  var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
@@ -44,43 +44,11 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
44
44
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
45
45
  var $__default = /*#__PURE__*/_interopDefaultLegacy($);
46
46
  var MathQuill__default = /*#__PURE__*/_interopDefaultLegacy(MathQuill);
47
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
48
47
  var katex__default = /*#__PURE__*/_interopDefaultLegacy(katex);
48
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
49
49
  var Clickable__default = /*#__PURE__*/_interopDefaultLegacy(Clickable);
50
50
  var Redux__namespace = /*#__PURE__*/_interopNamespace(Redux);
51
51
 
52
- /**
53
- * Enum that defines the various contexts in which a cursor can exist. The
54
- * active context is determined first by looking at the cursor's siblings (e.g.,
55
- * for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
56
- * cursor could in theory be nested in multiple contexts, we only care about the
57
- * immediate context.
58
- *
59
- * TODO(charlie): Add a context to represent being inside of a radical. Right
60
- * now, we show the dismiss button rather than allowing the user to jump out of
61
- * the radical.
62
- */
63
-
64
- const CursorContext = {
65
- // The cursor is not in any of the other viable contexts.
66
- NONE: "NONE",
67
- // The cursor is within a set of parentheses.
68
- IN_PARENS: "IN_PARENS",
69
- // The cursor is within a superscript (e.g., an exponent).
70
- IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT",
71
- // The cursor is within a subscript (e.g., the base of a custom logarithm).
72
- IN_SUB_SCRIPT: "IN_SUB_SCRIPT",
73
- // The cursor is in the numerator of a fraction.
74
- IN_NUMERATOR: "IN_NUMERATOR",
75
- // The cursor is in the denominator of a fraction.
76
- IN_DENOMINATOR: "IN_DENOMINATOR",
77
- // The cursor is sitting before a fraction; that is, the cursor is within
78
- // what looks to be a mixed number preceding a fraction. This will only be
79
- // the case when the only math between the cursor and the fraction to its
80
- // write is non-leaf math (numbers and variables).
81
- BEFORE_FRACTION: "BEFORE_FRACTION"
82
- };
83
-
84
52
  function _defineProperty(obj, key, value) {
85
53
  key = _toPropertyKey(key);
86
54
  if (key in obj) {
@@ -130,7 +98,7 @@ class Text extends React__namespace.Component {
130
98
  numberOfLines,
131
99
  style
132
100
  } = this.props;
133
- const className = aphrodite.css(styles$h.initial, ...(Array.isArray(style) ? style : [style]), numberOfLines === 1 && styles$h.singleLineStyle);
101
+ const className = aphrodite.css(styles$i.initial, ...(Array.isArray(style) ? style : [style]), numberOfLines === 1 && styles$i.singleLineStyle);
134
102
  return /*#__PURE__*/React__namespace.createElement("span", {
135
103
  className: className,
136
104
  style: this.props.dynamicStyle
@@ -139,7 +107,7 @@ class Text extends React__namespace.Component {
139
107
  }
140
108
 
141
109
  // https://github.com/necolas/react-native-web/blob/master/src/components/Text/index.js
142
- const styles$h = aphrodite.StyleSheet.create({
110
+ const styles$i = aphrodite.StyleSheet.create({
143
111
  initial: {
144
112
  color: "inherit",
145
113
  display: "inline",
@@ -409,6 +377,38 @@ class DragListener {
409
377
  }
410
378
  }
411
379
 
380
+ /**
381
+ * Enum that defines the various contexts in which a cursor can exist. The
382
+ * active context is determined first by looking at the cursor's siblings (e.g.,
383
+ * for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
384
+ * cursor could in theory be nested in multiple contexts, we only care about the
385
+ * immediate context.
386
+ *
387
+ * TODO(charlie): Add a context to represent being inside of a radical. Right
388
+ * now, we show the dismiss button rather than allowing the user to jump out of
389
+ * the radical.
390
+ */
391
+
392
+ const CursorContext = {
393
+ // The cursor is not in any of the other viable contexts.
394
+ NONE: "NONE",
395
+ // The cursor is within a set of parentheses.
396
+ IN_PARENS: "IN_PARENS",
397
+ // The cursor is within a superscript (e.g., an exponent).
398
+ IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT",
399
+ // The cursor is within a subscript (e.g., the base of a custom logarithm).
400
+ IN_SUB_SCRIPT: "IN_SUB_SCRIPT",
401
+ // The cursor is in the numerator of a fraction.
402
+ IN_NUMERATOR: "IN_NUMERATOR",
403
+ // The cursor is in the denominator of a fraction.
404
+ IN_DENOMINATOR: "IN_DENOMINATOR",
405
+ // The cursor is sitting before a fraction; that is, the cursor is within
406
+ // what looks to be a mixed number preceding a fraction. This will only be
407
+ // the case when the only math between the cursor and the fraction to its
408
+ // write is non-leaf math (numbers and variables).
409
+ BEFORE_FRACTION: "BEFORE_FRACTION"
410
+ };
411
+
412
412
  // We only need one MathQuill instance (referred to as MQ in the docs)
413
413
  // and that contains some MQ constants and the MathField constructor
414
414
  const mathQuillInstance = MathQuill__default["default"].getInterface(2);
@@ -1578,7 +1578,8 @@ class MathInput extends React__namespace.Component {
1578
1578
  });
1579
1579
  _defineProperty(this, "_getKeypadBounds", () => {
1580
1580
  if (!this._keypadBounds) {
1581
- const node = this.props.keypadElement.getDOMNode();
1581
+ var _this$props$keypadEle;
1582
+ const node = (_this$props$keypadEle = this.props.keypadElement) === null || _this$props$keypadEle === void 0 ? void 0 : _this$props$keypadEle.getDOMNode();
1582
1583
  this._cacheKeypadBounds(node);
1583
1584
  }
1584
1585
  return this._keypadBounds;
@@ -1642,9 +1643,10 @@ class MathInput extends React__namespace.Component {
1642
1643
  });
1643
1644
  });
1644
1645
  _defineProperty(this, "focus", () => {
1646
+ var _this$props$keypadEle2;
1645
1647
  // Pass this component's handleKey method to the keypad so it can call
1646
1648
  // it whenever it needs to trigger a keypress action.
1647
- this.props.keypadElement.setKeyHandler(key => {
1649
+ (_this$props$keypadEle2 = this.props.keypadElement) === null || _this$props$keypadEle2 === void 0 ? void 0 : _this$props$keypadEle2.setKeyHandler(key => {
1648
1650
  const cursor = this.mathField.pressKey(key);
1649
1651
 
1650
1652
  // Trigger an `onChange` if the value in the input changed, and hide
@@ -2159,7 +2161,7 @@ class MathInput extends React__namespace.Component {
2159
2161
  // to the open the keyboard, and then remove the second half of this label.
2160
2162
  const ariaLabel = i18n__namespace._("Math input box") + " " + i18n__namespace._("Tap with one or two fingers to open keyboard");
2161
2163
  return /*#__PURE__*/React__namespace.createElement(View, {
2162
- style: styles$g.input,
2164
+ style: styles$h.input,
2163
2165
  onTouchStart: this.handleTouchStart,
2164
2166
  onTouchMove: this.handleTouchMove,
2165
2167
  onTouchEnd: this.handleTouchEnd,
@@ -2205,7 +2207,7 @@ const numeralHeightPx = 20;
2205
2207
  const totalDesiredPadding = 12;
2206
2208
  const minHeightPx = numeralHeightPx + totalDesiredPadding * 2;
2207
2209
  const minWidthPx = 64;
2208
- const styles$g = aphrodite.StyleSheet.create({
2210
+ const styles$h = aphrodite.StyleSheet.create({
2209
2211
  input: {
2210
2212
  position: "relative",
2211
2213
  display: "inline-block",
@@ -2237,21 +2239,6 @@ const inlineStyles$1 = {
2237
2239
  }
2238
2240
  };
2239
2241
 
2240
- /**
2241
- * React PropTypes that may be shared between components.
2242
- */
2243
-
2244
- // NOTE(jared): This is no longer guaranteed to be React element
2245
- // NOTE(matthewc): only seems to be used in Perseus
2246
- const keypadElementPropType = PropTypes__default["default"].shape({
2247
- activate: PropTypes__default["default"].func.isRequired,
2248
- dismiss: PropTypes__default["default"].func.isRequired,
2249
- configure: PropTypes__default["default"].func.isRequired,
2250
- setCursor: PropTypes__default["default"].func.isRequired,
2251
- setKeyHandler: PropTypes__default["default"].func.isRequired,
2252
- getDOMNode: PropTypes__default["default"].func.isRequired
2253
- });
2254
-
2255
2242
  /**
2256
2243
  * This file contains configuration settings for the buttons in the keypad.
2257
2244
  */
@@ -3025,7 +3012,7 @@ class CornerDecal extends React__namespace.Component {
3025
3012
  const {
3026
3013
  style
3027
3014
  } = this.props;
3028
- const containerStyle = [styles$f.container, ...(Array.isArray(style) ? style : [style])];
3015
+ const containerStyle = [styles$g.container, ...(Array.isArray(style) ? style : [style])];
3029
3016
  return /*#__PURE__*/React__namespace.createElement(View, {
3030
3017
  style: containerStyle
3031
3018
  }, /*#__PURE__*/React__namespace.createElement("svg", {
@@ -3041,7 +3028,7 @@ class CornerDecal extends React__namespace.Component {
3041
3028
  }
3042
3029
 
3043
3030
  const triangleSizePx = 7;
3044
- const styles$f = aphrodite.StyleSheet.create({
3031
+ const styles$g = aphrodite.StyleSheet.create({
3045
3032
  container: {
3046
3033
  position: "absolute",
3047
3034
  top: 0,
@@ -3111,13 +3098,13 @@ class MathIcon extends React__namespace.Component {
3111
3098
  const {
3112
3099
  style
3113
3100
  } = this.props;
3114
- const containerStyle = [row$7, centered$4, styles$e.size, styles$e.base, ...(Array.isArray(style) ? style : [style])];
3101
+ const containerStyle = [row$7, centered$4, styles$f.size, styles$f.base, ...(Array.isArray(style) ? style : [style])];
3115
3102
  return /*#__PURE__*/React__namespace.createElement(View, {
3116
3103
  style: containerStyle
3117
3104
  });
3118
3105
  }
3119
3106
  }
3120
- const styles$e = aphrodite.StyleSheet.create({
3107
+ const styles$f = aphrodite.StyleSheet.create({
3121
3108
  size: {
3122
3109
  height: iconSizeHeightPx,
3123
3110
  width: iconSizeWidthPx
@@ -4225,48 +4212,48 @@ const JumpOutDenominator = () => {
4225
4212
  */
4226
4213
 
4227
4214
  var Iconography = /*#__PURE__*/Object.freeze({
4228
- __proto__: null,
4229
- COS: Cos,
4230
- LOG: Log,
4231
- EQUAL: Equal,
4232
- BACKSPACE: Backspace,
4233
- SQRT: Sqrt,
4234
- EXP: Exp,
4235
- NEQ: Neq,
4236
- GEQ: Geq,
4237
- LN: Ln,
4238
- DISMISS: Dismiss,
4239
- SIN: Sin,
4240
- LT: Lt,
4241
- CUBE_ROOT: CubeRoot,
4242
- PLUS: Plus,
4243
- TAN: Tan,
4244
- LEFT: Left,
4245
- UP: Up,
4246
- DOWN: Down,
4247
- LEFT_PAREN: LeftParen,
4248
- RIGHT_PAREN: RightParen,
4249
- GT: Gt,
4250
- DIVIDE: Divide,
4251
- PERIOD: Period,
4252
- PERCENT: Percent,
4253
- TIMES: Times,
4254
- EXP_3: Exp3,
4255
- EXP_2: Exp2,
4256
- RIGHT: Right,
4257
- CDOT: Cdot,
4258
- LOG_N: LogN,
4259
- LEQ: Leq,
4260
- MINUS: Minus,
4261
- NEGATIVE: Minus,
4262
- RADICAL: Radical,
4263
- FRAC: FracInclusive,
4264
- JUMP_OUT_PARENTHESES: JumpOutParentheses,
4265
- JUMP_OUT_EXPONENT: JumpOutExponent,
4266
- JUMP_OUT_BASE: JumpOutBase,
4267
- JUMP_INTO_NUMERATOR: JumpIntoNumerator,
4268
- JUMP_OUT_NUMERATOR: JumpOutNumerator,
4269
- JUMP_OUT_DENOMINATOR: JumpOutDenominator
4215
+ __proto__: null,
4216
+ COS: Cos,
4217
+ LOG: Log,
4218
+ EQUAL: Equal,
4219
+ BACKSPACE: Backspace,
4220
+ SQRT: Sqrt,
4221
+ EXP: Exp,
4222
+ NEQ: Neq,
4223
+ GEQ: Geq,
4224
+ LN: Ln,
4225
+ DISMISS: Dismiss,
4226
+ SIN: Sin,
4227
+ LT: Lt,
4228
+ CUBE_ROOT: CubeRoot,
4229
+ PLUS: Plus,
4230
+ TAN: Tan,
4231
+ LEFT: Left,
4232
+ UP: Up,
4233
+ DOWN: Down,
4234
+ LEFT_PAREN: LeftParen,
4235
+ RIGHT_PAREN: RightParen,
4236
+ GT: Gt,
4237
+ DIVIDE: Divide,
4238
+ PERIOD: Period,
4239
+ PERCENT: Percent,
4240
+ TIMES: Times,
4241
+ EXP_3: Exp3,
4242
+ EXP_2: Exp2,
4243
+ RIGHT: Right,
4244
+ CDOT: Cdot,
4245
+ LOG_N: LogN,
4246
+ LEQ: Leq,
4247
+ MINUS: Minus,
4248
+ NEGATIVE: Minus,
4249
+ RADICAL: Radical,
4250
+ FRAC: FracInclusive,
4251
+ JUMP_OUT_PARENTHESES: JumpOutParentheses,
4252
+ JUMP_OUT_EXPONENT: JumpOutExponent,
4253
+ JUMP_OUT_BASE: JumpOutBase,
4254
+ JUMP_INTO_NUMERATOR: JumpIntoNumerator,
4255
+ JUMP_OUT_NUMERATOR: JumpOutNumerator,
4256
+ JUMP_OUT_DENOMINATOR: JumpOutDenominator
4270
4257
  });
4271
4258
 
4272
4259
  /**
@@ -4300,13 +4287,13 @@ class TextIcon extends React__namespace.Component {
4300
4287
  character,
4301
4288
  style
4302
4289
  } = this.props;
4303
- const containerStyle = [row$6, centered$3, styles$d.size, styles$d.base, ...(Array.isArray(style) ? style : [style])];
4290
+ const containerStyle = [row$6, centered$3, styles$e.size, styles$e.base, ...(Array.isArray(style) ? style : [style])];
4304
4291
  return /*#__PURE__*/React__namespace.createElement(View, {
4305
4292
  style: containerStyle
4306
4293
  }, /*#__PURE__*/React__namespace.createElement(Text, null, character));
4307
4294
  }
4308
4295
  }
4309
- const styles$d = aphrodite.StyleSheet.create({
4296
+ const styles$e = aphrodite.StyleSheet.create({
4310
4297
  size: {
4311
4298
  height: iconSizeHeightPx,
4312
4299
  width: iconSizeWidthPx
@@ -4329,7 +4316,7 @@ class Icon extends React__namespace.PureComponent {
4329
4316
  icon,
4330
4317
  style
4331
4318
  } = this.props;
4332
- const styleWithFocus = [focused ? styles$c.focused : styles$c.unfocused, ...(Array.isArray(style) ? style : [style])];
4319
+ const styleWithFocus = [focused ? styles$d.focused : styles$d.unfocused, ...(Array.isArray(style) ? style : [style])];
4333
4320
  switch (icon.type) {
4334
4321
  case IconType.MATH:
4335
4322
  return /*#__PURE__*/React__namespace.createElement(MathIcon, {
@@ -4355,7 +4342,7 @@ class Icon extends React__namespace.PureComponent {
4355
4342
  }
4356
4343
  }
4357
4344
  }
4358
- const styles$c = aphrodite.StyleSheet.create({
4345
+ const styles$d = aphrodite.StyleSheet.create({
4359
4346
  unfocused: {
4360
4347
  color: unfocusedColor
4361
4348
  },
@@ -4397,19 +4384,19 @@ class MultiSymbolGrid extends React__namespace.Component {
4397
4384
  focused: focused
4398
4385
  });
4399
4386
  } else {
4400
- const primaryIconStyle = styles$b.base;
4401
- const secondaryIconStyle = [styles$b.base, styles$b.secondary];
4387
+ const primaryIconStyle = styles$c.base;
4388
+ const secondaryIconStyle = [styles$c.base, styles$c.secondary];
4402
4389
  if (icons.length === 2) {
4403
4390
  return /*#__PURE__*/React__namespace.createElement(View, {
4404
- style: [row$5, styles$b.size]
4391
+ style: [row$5, styles$c.size]
4405
4392
  }, /*#__PURE__*/React__namespace.createElement(View, {
4406
- style: [column$3, centered$2, fullWidth$3, styles$b.middleLeft]
4393
+ style: [column$3, centered$2, fullWidth$3, styles$c.middleLeft]
4407
4394
  }, /*#__PURE__*/React__namespace.createElement(Icon, {
4408
4395
  style: primaryIconStyle,
4409
4396
  icon: icons[0],
4410
4397
  focused: focused
4411
4398
  })), /*#__PURE__*/React__namespace.createElement(View, {
4412
- style: [column$3, centered$2, fullWidth$3, styles$b.middleRight]
4399
+ style: [column$3, centered$2, fullWidth$3, styles$c.middleRight]
4413
4400
  }, /*#__PURE__*/React__namespace.createElement(Icon, {
4414
4401
  style: secondaryIconStyle,
4415
4402
  icon: icons[1],
@@ -4417,17 +4404,17 @@ class MultiSymbolGrid extends React__namespace.Component {
4417
4404
  })));
4418
4405
  } else if (icons.length >= 3) {
4419
4406
  return /*#__PURE__*/React__namespace.createElement(View, {
4420
- style: [column$3, styles$b.size]
4407
+ style: [column$3, styles$c.size]
4421
4408
  }, /*#__PURE__*/React__namespace.createElement(View, {
4422
4409
  style: row$5
4423
4410
  }, /*#__PURE__*/React__namespace.createElement(View, {
4424
- style: [centered$2, fullWidth$3, styles$b.topLeft]
4411
+ style: [centered$2, fullWidth$3, styles$c.topLeft]
4425
4412
  }, /*#__PURE__*/React__namespace.createElement(Icon, {
4426
4413
  style: primaryIconStyle,
4427
4414
  icon: icons[0],
4428
4415
  focused: focused
4429
4416
  })), /*#__PURE__*/React__namespace.createElement(View, {
4430
- style: [centered$2, fullWidth$3, styles$b.topRight]
4417
+ style: [centered$2, fullWidth$3, styles$c.topRight]
4431
4418
  }, /*#__PURE__*/React__namespace.createElement(Icon, {
4432
4419
  style: secondaryIconStyle,
4433
4420
  icon: icons[1],
@@ -4435,13 +4422,13 @@ class MultiSymbolGrid extends React__namespace.Component {
4435
4422
  }))), /*#__PURE__*/React__namespace.createElement(View, {
4436
4423
  style: row$5
4437
4424
  }, /*#__PURE__*/React__namespace.createElement(View, {
4438
- style: [centered$2, fullWidth$3, styles$b.bottomLeft]
4425
+ style: [centered$2, fullWidth$3, styles$c.bottomLeft]
4439
4426
  }, /*#__PURE__*/React__namespace.createElement(Icon, {
4440
4427
  style: secondaryIconStyle,
4441
4428
  icon: icons[2],
4442
4429
  focused: focused
4443
4430
  })), /*#__PURE__*/React__namespace.createElement(View, {
4444
- style: [centered$2, fullWidth$3, styles$b.bottomRight]
4431
+ style: [centered$2, fullWidth$3, styles$c.bottomRight]
4445
4432
  }, icons[3] && /*#__PURE__*/React__namespace.createElement(Icon, {
4446
4433
  style: secondaryIconStyle,
4447
4434
  icon: icons[3],
@@ -4454,7 +4441,7 @@ class MultiSymbolGrid extends React__namespace.Component {
4454
4441
  }
4455
4442
  const verticalInsetPx = 2;
4456
4443
  const horizontalInsetPx = 4;
4457
- const styles$b = aphrodite.StyleSheet.create({
4444
+ const styles$c = aphrodite.StyleSheet.create({
4458
4445
  size: {
4459
4446
  height: iconSizeHeightPx,
4460
4447
  width: iconSizeWidthPx
@@ -4515,29 +4502,29 @@ class KeypadButton$1 extends React__namespace.PureComponent {
4515
4502
  _defineProperty(this, "_getFocusStyle", type => {
4516
4503
  let focusBackgroundStyle;
4517
4504
  if (type === "INPUT_NAVIGATION" || type === "KEYPAD_NAVIGATION") {
4518
- focusBackgroundStyle = styles$a.light;
4505
+ focusBackgroundStyle = styles$b.light;
4519
4506
  } else {
4520
- focusBackgroundStyle = styles$a.bright;
4507
+ focusBackgroundStyle = styles$b.bright;
4521
4508
  }
4522
- return [styles$a.focusBox, focusBackgroundStyle];
4509
+ return [styles$b.focusBox, focusBackgroundStyle];
4523
4510
  });
4524
4511
  _defineProperty(this, "_getButtonStyle", (type, borders, style) => {
4525
4512
  // Select the appropriate style for the button.
4526
4513
  let backgroundStyle;
4527
4514
  switch (type) {
4528
4515
  case "EMPTY":
4529
- backgroundStyle = styles$a.empty;
4516
+ backgroundStyle = styles$b.empty;
4530
4517
  break;
4531
4518
  case "MANY":
4532
4519
  case "VALUE":
4533
- backgroundStyle = styles$a.value;
4520
+ backgroundStyle = styles$b.value;
4534
4521
  break;
4535
4522
  case "OPERATOR":
4536
- backgroundStyle = styles$a.operator;
4523
+ backgroundStyle = styles$b.operator;
4537
4524
  break;
4538
4525
  case "INPUT_NAVIGATION":
4539
4526
  case "KEYPAD_NAVIGATION":
4540
- backgroundStyle = styles$a.control;
4527
+ backgroundStyle = styles$b.control;
4541
4528
  break;
4542
4529
  case "ECHO":
4543
4530
  backgroundStyle = null;
@@ -4546,13 +4533,13 @@ class KeypadButton$1 extends React__namespace.PureComponent {
4546
4533
  const borderStyle = [];
4547
4534
  if (borders.includes(BorderDirection.LEFT)) {
4548
4535
  // @ts-expect-error TS2345
4549
- borderStyle.push(styles$a.leftBorder);
4536
+ borderStyle.push(styles$b.leftBorder);
4550
4537
  }
4551
4538
  if (borders.includes(BorderDirection.BOTTOM)) {
4552
4539
  // @ts-expect-error TS2345
4553
- borderStyle.push(styles$a.bottomBorder);
4540
+ borderStyle.push(styles$b.bottomBorder);
4554
4541
  }
4555
- return [styles$a.buttonBase, backgroundStyle, ...borderStyle, type === "ECHO" && styles$a.echo, this.buttonSizeStyle,
4542
+ return [styles$b.buttonBase, backgroundStyle, ...borderStyle, type === "ECHO" && styles$b.echo, this.buttonSizeStyle,
4556
4543
  // React Native allows you to set the 'style' props on user defined
4557
4544
  // components.
4558
4545
  // See: https://facebook.github.io/react-native/docs/style.html
@@ -4597,7 +4584,7 @@ class KeypadButton$1 extends React__namespace.PureComponent {
4597
4584
  const renderFocused = !disabled && focused || popoverEnabled || type === "ECHO";
4598
4585
  const buttonStyle = this._getButtonStyle(type, borders, style);
4599
4586
  const focusStyle = this._getFocusStyle(type);
4600
- const iconWrapperStyle = [styles$a.iconWrapper, disabled ? styles$a.disabled : undefined];
4587
+ const iconWrapperStyle = [styles$b.iconWrapper, disabled ? styles$b.disabled : undefined];
4601
4588
  const eventHandlers = {
4602
4589
  onTouchCancel,
4603
4590
  onTouchEnd,
@@ -4608,7 +4595,7 @@ class KeypadButton$1 extends React__namespace.PureComponent {
4608
4595
  style: focusStyle
4609
4596
  });
4610
4597
  const maybeCornerDecal = !renderFocused && !disabled && childKeys && childKeys.length > 0 && /*#__PURE__*/React__namespace.createElement(CornerDecal, {
4611
- style: styles$a.decalInset
4598
+ style: styles$b.decalInset
4612
4599
  });
4613
4600
  if (type === "EMPTY") {
4614
4601
  return /*#__PURE__*/React__namespace.createElement(View, _extends({
@@ -4657,7 +4644,7 @@ _defineProperty(KeypadButton$1, "defaultProps", {
4657
4644
  });
4658
4645
  const focusInsetPx = 4;
4659
4646
  const focusBoxZIndex = 0;
4660
- const styles$a = aphrodite.StyleSheet.create({
4647
+ const styles$b = aphrodite.StyleSheet.create({
4661
4648
  buttonBase: {
4662
4649
  flex: 1,
4663
4650
  cursor: "pointer",
@@ -4810,7 +4797,7 @@ class TouchableKeypadButton extends React__namespace.Component {
4810
4797
  onTouchMove: evt => gestureManager.onTouchMove(evt),
4811
4798
  onTouchCancel: evt => gestureManager.onTouchCancel(evt)
4812
4799
  };
4813
- const styleWithAddons = [...(Array.isArray(style) ? style : [style]), styles$9.preventScrolls];
4800
+ const styleWithAddons = [...(Array.isArray(style) ? style : [style]), styles$a.preventScrolls];
4814
4801
  return /*#__PURE__*/React__namespace.createElement(KeypadButton$2, _extends({
4815
4802
  ref: node => gestureManager.registerDOMNode(id, ReactDOM__default["default"].findDOMNode(node), childKeyIds),
4816
4803
  borders: borders,
@@ -4863,7 +4850,7 @@ const mapStateToProps$5 = (state, ownProps) => {
4863
4850
  ...extractProps(useFirstChildProps ? childKeys[0] : keyConfig)
4864
4851
  };
4865
4852
  };
4866
- const styles$9 = aphrodite.StyleSheet.create({
4853
+ const styles$a = aphrodite.StyleSheet.create({
4867
4854
  preventScrolls: {
4868
4855
  // Touch events that start in the touchable buttons shouldn't be
4869
4856
  // allowed to produce page scrolls.
@@ -5010,7 +4997,7 @@ const IconAsset = function (_ref) {
5010
4997
  }
5011
4998
  };
5012
4999
 
5013
- const styles$8 = aphrodite.StyleSheet.create({
5000
+ const styles$9 = aphrodite.StyleSheet.create({
5014
5001
  base: {
5015
5002
  display: "flex",
5016
5003
  width: 44,
@@ -5081,7 +5068,7 @@ class TabbarItem extends React__namespace.Component {
5081
5068
  onClick: onClick,
5082
5069
  disabled: itemState === "disabled",
5083
5070
  "aria-label": itemType,
5084
- style: styles$8.clickable,
5071
+ style: styles$9.clickable,
5085
5072
  "aria-selected": itemState === "active",
5086
5073
  role: "tab"
5087
5074
  }, _ref => {
@@ -5092,14 +5079,14 @@ class TabbarItem extends React__namespace.Component {
5092
5079
  } = _ref;
5093
5080
  const tintColor = imageTintColor(itemState, hovered, focused, pressed);
5094
5081
  return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
5095
- style: [styles$8.base, itemState !== "disabled" && hovered && styles$8.hovered, focused && styles$8.focused, pressed && styles$8.pressed]
5082
+ style: [styles$9.base, itemState !== "disabled" && hovered && styles$9.hovered, focused && styles$9.focused, pressed && styles$9.pressed]
5096
5083
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
5097
- style: [styles$8.innerBox, pressed && styles$8.innerBoxPressed]
5084
+ style: [styles$9.innerBox, pressed && styles$9.innerBoxPressed]
5098
5085
  }, /*#__PURE__*/React__namespace.createElement(IconAsset, {
5099
5086
  type: itemType,
5100
5087
  tintColor: tintColor
5101
5088
  })), itemState === "active" && /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
5102
- style: [styles$8.activeIndicator, {
5089
+ style: [styles$9.activeIndicator, {
5103
5090
  backgroundColor: tintColor
5104
5091
  }]
5105
5092
  }));
@@ -5107,7 +5094,7 @@ class TabbarItem extends React__namespace.Component {
5107
5094
  }
5108
5095
  }
5109
5096
 
5110
- const styles$7 = aphrodite.StyleSheet.create({
5097
+ const styles$8 = aphrodite.StyleSheet.create({
5111
5098
  tabbar: {
5112
5099
  display: "flex",
5113
5100
  flexDirection: "row",
@@ -5129,10 +5116,10 @@ function Tabbar(props) {
5129
5116
  style
5130
5117
  } = props;
5131
5118
  return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
5132
- style: [styles$7.tabbar, style],
5119
+ style: [styles$8.tabbar, style],
5133
5120
  role: "tablist"
5134
5121
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
5135
- style: [styles$7.pages]
5122
+ style: [styles$8.pages]
5136
5123
  }, items.map(item => /*#__PURE__*/React__namespace.createElement(TabbarItem, {
5137
5124
  key: "tabbar-item-".concat(item),
5138
5125
  itemState: item === selectedItem ? "active" : "inactive",
@@ -5283,7 +5270,7 @@ class MultiSymbolPopover extends React__namespace.Component {
5283
5270
  // TODO(charlie): We have to require this lazily because of a cyclic
5284
5271
  // dependence in our components.
5285
5272
  return /*#__PURE__*/React__namespace.createElement(View, {
5286
- style: styles$6.container
5273
+ style: styles$7.container
5287
5274
  }, keys.map(key => {
5288
5275
  return /*#__PURE__*/React__namespace.createElement(TouchableKeypadButton$1, {
5289
5276
  keyConfig: key,
@@ -5292,7 +5279,7 @@ class MultiSymbolPopover extends React__namespace.Component {
5292
5279
  }));
5293
5280
  }
5294
5281
  }
5295
- const styles$6 = aphrodite.StyleSheet.create({
5282
+ const styles$7 = aphrodite.StyleSheet.create({
5296
5283
  container: {
5297
5284
  flexDirection: "column-reverse",
5298
5285
  position: "relative",
@@ -5578,7 +5565,7 @@ class TwoPageKeypad extends React__namespace.Component {
5578
5565
  } = this.state;
5579
5566
  if (paginationEnabled) {
5580
5567
  return /*#__PURE__*/React__namespace.createElement(Keypad$2, {
5581
- style: [column$2, styles$5.keypad]
5568
+ style: [column$2, styles$6.keypad]
5582
5569
  }, /*#__PURE__*/React__namespace.createElement(Tabbar, {
5583
5570
  items: ["Numbers", "Operators"],
5584
5571
  selectedItem: selectedPage,
@@ -5587,24 +5574,24 @@ class TwoPageKeypad extends React__namespace.Component {
5587
5574
  selectedPage: selectedItem
5588
5575
  });
5589
5576
  },
5590
- style: styles$5.tabbar
5577
+ style: styles$6.tabbar
5591
5578
  }), /*#__PURE__*/React__namespace.createElement(View, {
5592
- style: styles$5.borderTop
5579
+ style: styles$6.borderTop
5593
5580
  }, selectedPage === "Numbers" && rightPage, selectedPage === "Operators" && leftPage));
5594
5581
  } else {
5595
5582
  return /*#__PURE__*/React__namespace.createElement(Keypad$2, {
5596
- style: styles$5.keypad
5583
+ style: styles$6.keypad
5597
5584
  }, /*#__PURE__*/React__namespace.createElement(View, {
5598
5585
  style: row$4
5599
5586
  }, /*#__PURE__*/React__namespace.createElement(View, {
5600
5587
  style: fullWidth$2
5601
5588
  }, leftPage), /*#__PURE__*/React__namespace.createElement(View, {
5602
- style: [styles$5.borderLeft, fullWidth$2]
5589
+ style: [styles$6.borderLeft, fullWidth$2]
5603
5590
  }, rightPage)));
5604
5591
  }
5605
5592
  }
5606
5593
  }
5607
- const styles$5 = aphrodite.StyleSheet.create({
5594
+ const styles$6 = aphrodite.StyleSheet.create({
5608
5595
  keypad: {
5609
5596
  // Set the background to light grey, so that when the user drags the
5610
5597
  // keypad pages past the edges, there's a grey backdrop.
@@ -5690,7 +5677,7 @@ class ExpressionKeypad extends React__namespace.Component {
5690
5677
  } else {
5691
5678
  dismissOrJumpOutKey = KeyConfigs.DISMISS;
5692
5679
  }
5693
- const rightPageStyle = [row$3, fullWidth$1, styles$4.rightPage, roundTopRight && roundedTopRight$1];
5680
+ const rightPageStyle = [row$3, fullWidth$1, styles$5.rightPage, roundTopRight && roundedTopRight$1];
5694
5681
  const rightPage = /*#__PURE__*/React__namespace.createElement(View, {
5695
5682
  style: rightPageStyle
5696
5683
  }, /*#__PURE__*/React__namespace.createElement(View, {
@@ -5762,7 +5749,7 @@ class ExpressionKeypad extends React__namespace.Component {
5762
5749
  keyConfig: dismissOrJumpOutKey,
5763
5750
  borders: BorderStyles.LEFT
5764
5751
  })));
5765
- const leftPageStyle = [row$3, fullWidth$1, styles$4.leftPage, roundTopLeft && roundedTopLeft$2];
5752
+ const leftPageStyle = [row$3, fullWidth$1, styles$5.leftPage, roundTopLeft && roundedTopLeft$2];
5766
5753
  const leftPage = /*#__PURE__*/React__namespace.createElement(View, {
5767
5754
  style: leftPageStyle
5768
5755
  }, /*#__PURE__*/React__namespace.createElement(View, {
@@ -5842,7 +5829,7 @@ class ExpressionKeypad extends React__namespace.Component {
5842
5829
  });
5843
5830
  }
5844
5831
  }
5845
- const styles$4 = aphrodite.StyleSheet.create({
5832
+ const styles$5 = aphrodite.StyleSheet.create({
5846
5833
  // NOTE(charlie): These backgrounds are applied to as to fill in some
5847
5834
  // unfortunate 'cracks' in the layout. However, not all keys in the first
5848
5835
  // page use this background color (namely, the 'command' keys, backspace and
@@ -6018,7 +6005,7 @@ class NavigationPad extends React__namespace.Component {
6018
6005
  roundTopLeft,
6019
6006
  style
6020
6007
  } = this.props;
6021
- const containerStyle = [column, centered$1, styles$3.container, roundTopLeft && roundedTopLeft, ...(Array.isArray(style) ? style : [style])];
6008
+ const containerStyle = [column, centered$1, styles$4.container, roundTopLeft && roundedTopLeft, ...(Array.isArray(style) ? style : [style])];
6022
6009
  return /*#__PURE__*/React__namespace.createElement(View, {
6023
6010
  style: containerStyle
6024
6011
  }, /*#__PURE__*/React__namespace.createElement(View, {
@@ -6026,32 +6013,32 @@ class NavigationPad extends React__namespace.Component {
6026
6013
  }, /*#__PURE__*/React__namespace.createElement(TouchableKeypadButton$1, {
6027
6014
  keyConfig: KeyConfigs.UP,
6028
6015
  borders: BorderStyles.NONE,
6029
- style: [styles$3.navigationKey, styles$3.topArrow]
6016
+ style: [styles$4.navigationKey, styles$4.topArrow]
6030
6017
  })), /*#__PURE__*/React__namespace.createElement(View, {
6031
6018
  style: [row$1, centered$1, stretch]
6032
6019
  }, /*#__PURE__*/React__namespace.createElement(TouchableKeypadButton$1, {
6033
6020
  keyConfig: KeyConfigs.LEFT,
6034
6021
  borders: BorderStyles.NONE,
6035
- style: [styles$3.navigationKey, styles$3.leftArrow]
6022
+ style: [styles$4.navigationKey, styles$4.leftArrow]
6036
6023
  }), /*#__PURE__*/React__namespace.createElement(View, {
6037
- style: styles$3.horizontalSpacer
6024
+ style: styles$4.horizontalSpacer
6038
6025
  }), /*#__PURE__*/React__namespace.createElement(TouchableKeypadButton$1, {
6039
6026
  keyConfig: KeyConfigs.RIGHT,
6040
6027
  borders: BorderStyles.NONE,
6041
- style: [styles$3.navigationKey, styles$3.rightArrow]
6028
+ style: [styles$4.navigationKey, styles$4.rightArrow]
6042
6029
  })), /*#__PURE__*/React__namespace.createElement(View, {
6043
6030
  style: [row$1, centered$1]
6044
6031
  }, /*#__PURE__*/React__namespace.createElement(TouchableKeypadButton$1, {
6045
6032
  keyConfig: KeyConfigs.DOWN,
6046
6033
  borders: BorderStyles.NONE,
6047
- style: [styles$3.navigationKey, styles$3.bottomArrow]
6034
+ style: [styles$4.navigationKey, styles$4.bottomArrow]
6048
6035
  })));
6049
6036
  }
6050
6037
  }
6051
6038
  const buttonSizePx = 48;
6052
6039
  const borderRadiusPx = 4;
6053
6040
  const borderWidthPx$1 = 1;
6054
- const styles$3 = aphrodite.StyleSheet.create({
6041
+ const styles$4 = aphrodite.StyleSheet.create({
6055
6042
  container: {
6056
6043
  backgroundColor: controlGrey,
6057
6044
  width: navigationPadWidthPx
@@ -6224,8 +6211,8 @@ class KeypadContainer extends React__namespace.Component {
6224
6211
  ...inlineStyles.invisible
6225
6212
  };
6226
6213
  }
6227
- const keypadContainerStyle = [row, centered, fullWidth, styles$2.keypadContainer, ...(Array.isArray(style) ? style : [style])];
6228
- const keypadStyle = [row, styles$2.keypadBorder, layoutMode === LayoutMode.FULLSCREEN ? styles$2.fullscreen : styles$2.compact];
6214
+ const keypadContainerStyle = [row, centered, fullWidth, styles$3.keypadContainer, ...(Array.isArray(style) ? style : [style])];
6215
+ const keypadStyle = [row, styles$3.keypadBorder, layoutMode === LayoutMode.FULLSCREEN ? styles$3.fullscreen : styles$3.compact];
6229
6216
 
6230
6217
  // TODO(charlie): When the keypad is shorter than the width of the
6231
6218
  // screen, add a border on its left and right edges, and round out the
@@ -6244,15 +6231,15 @@ class KeypadContainer extends React__namespace.Component {
6244
6231
  }
6245
6232
  }, navigationPadEnabled && /*#__PURE__*/React__namespace.createElement(NavigationPad, {
6246
6233
  roundTopLeft: layoutMode === LayoutMode.COMPACT,
6247
- style: styles$2.navigationPadContainer
6234
+ style: styles$3.navigationPadContainer
6248
6235
  }), /*#__PURE__*/React__namespace.createElement(View, {
6249
- style: styles$2.keypadLayout
6236
+ style: styles$3.keypadLayout
6250
6237
  }, this.renderKeypad())));
6251
6238
  }
6252
6239
  }
6253
6240
  const keypadAnimationDurationMs = 300;
6254
6241
  const borderWidthPx = 1;
6255
- const styles$2 = aphrodite.StyleSheet.create({
6242
+ const styles$3 = aphrodite.StyleSheet.create({
6256
6243
  keypadContainer: {
6257
6244
  bottom: 0,
6258
6245
  left: 0,
@@ -8459,7 +8446,7 @@ const KeypadButton = _ref => {
8459
8446
  }
8460
8447
  }, /*#__PURE__*/React__namespace.createElement(Clickable__default["default"], {
8461
8448
  onClick: () => onClickKey(keyConfig.id),
8462
- style: styles$1.clickable,
8449
+ style: styles$2.clickable,
8463
8450
  "aria-label": keyConfig.ariaLabel
8464
8451
  }, _ref2 => {
8465
8452
  let {
@@ -8468,17 +8455,17 @@ const KeypadButton = _ref => {
8468
8455
  pressed
8469
8456
  } = _ref2;
8470
8457
  return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
8471
- style: [styles$1.outerBoxBase]
8458
+ style: [styles$2.outerBoxBase]
8472
8459
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
8473
- style: [styles$1.base, tintColor != null ? {
8460
+ style: [styles$2.base, tintColor != null ? {
8474
8461
  background: tintColor
8475
- } : undefined, hovered && styles$1.hovered, focused && styles$1.focused, pressed && styles$1.pressed]
8462
+ } : undefined, hovered && styles$2.hovered, focused && styles$2.focused, pressed && styles$2.pressed]
8476
8463
  }, /*#__PURE__*/React__namespace.createElement(ButtonAsset, {
8477
8464
  id: keyConfig.id
8478
8465
  })));
8479
8466
  }));
8480
8467
  };
8481
- const styles$1 = aphrodite.StyleSheet.create({
8468
+ const styles$2 = aphrodite.StyleSheet.create({
8482
8469
  base: {
8483
8470
  display: "flex",
8484
8471
  justifyContent: "center",
@@ -8839,10 +8826,10 @@ function Keypad(props) {
8839
8826
  onSelectItem: tabbarItem => {
8840
8827
  setSelectedPage(tabbarItem);
8841
8828
  },
8842
- style: styles.tabbar,
8829
+ style: styles$1.tabbar,
8843
8830
  onClickClose: showDismiss ? () => onClickKey("DISMISS") : undefined
8844
8831
  }), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
8845
- style: styles.grid,
8832
+ style: styles$1.grid,
8846
8833
  role: "grid",
8847
8834
  tabIndex: 0,
8848
8835
  "aria-label": "Keypad"
@@ -8868,7 +8855,7 @@ function Keypad(props) {
8868
8855
  })));
8869
8856
  }
8870
8857
  Keypad.defaultProps = defaultProps;
8871
- const styles = aphrodite.StyleSheet.create({
8858
+ const styles$1 = aphrodite.StyleSheet.create({
8872
8859
  tabbar: {
8873
8860
  background: Color__default["default"].white
8874
8861
  },
@@ -8876,18 +8863,166 @@ const styles = aphrodite.StyleSheet.create({
8876
8863
  display: "grid",
8877
8864
  gridTemplateColumns: "repeat(6, 1fr)",
8878
8865
  gridTemplateRows: "repeat(4, 1fr)",
8879
- backgroundColor: "#DBDCDD",
8880
- maxHeight: 200,
8881
- maxWidth: 300
8866
+ backgroundColor: "#DBDCDD"
8882
8867
  }
8883
8868
  });
8884
8869
 
8870
+ /**
8871
+ * This is the v2 equivalent of v1's ProvidedKeypad. It follows the same
8872
+ * external API so that it can be hot-swapped with the v1 keypad and
8873
+ * is responsible for connecting the keypad with MathInput and the Renderer.
8874
+ *
8875
+ * Ideally this strategy of attaching methods on the class component for
8876
+ * other components to call will be replaced props/callbacks since React
8877
+ * doesn't support this type of code anymore (functional components
8878
+ * can't have methods attached to them).
8879
+ */
8880
+
8881
+ class MobileKeypad extends React__namespace.Component {
8882
+ constructor() {
8883
+ super(...arguments);
8884
+ _defineProperty(this, "hasMounted", false);
8885
+ _defineProperty(this, "state", {
8886
+ active: false
8887
+ });
8888
+ _defineProperty(this, "activate", () => {
8889
+ this.setState({
8890
+ active: true
8891
+ });
8892
+ });
8893
+ _defineProperty(this, "dismiss", () => {
8894
+ this.setState({
8895
+ active: false
8896
+ }, () => {
8897
+ var _this$props$onDismiss, _this$props;
8898
+ (_this$props$onDismiss = (_this$props = this.props).onDismiss) === null || _this$props$onDismiss === void 0 ? void 0 : _this$props$onDismiss.call(_this$props);
8899
+ });
8900
+ });
8901
+ _defineProperty(this, "configure", (configuration, cb) => {
8902
+ this.setState({
8903
+ keypadConfig: configuration
8904
+ });
8905
+
8906
+ // TODO(matthewc)[LC-1080]: this was brought in from v1's ProvidedKeypad.
8907
+ // We need to investigate whether we still need this.
8908
+ // HACK(charlie): In Perseus, triggering a focus causes the keypad to
8909
+ // animate into view and re-configure. We'd like to provide the option
8910
+ // to re-render the re-configured keypad before animating it into view,
8911
+ // to avoid jank in the animation. As such, we support passing a
8912
+ // callback into `configureKeypad`. However, implementing this properly
8913
+ // would require middleware, etc., so we just hack it on with
8914
+ // `setTimeout` for now.
8915
+ setTimeout(() => cb && cb());
8916
+ });
8917
+ _defineProperty(this, "setCursor", cursor => {
8918
+ this.setState({
8919
+ cursor
8920
+ });
8921
+ });
8922
+ _defineProperty(this, "setKeyHandler", keyHandler => {
8923
+ this.setState({
8924
+ keyHandler
8925
+ });
8926
+ });
8927
+ _defineProperty(this, "getDOMNode", () => {
8928
+ return ReactDOM__default["default"].findDOMNode(this);
8929
+ });
8930
+ }
8931
+ _handleClickKey(key) {
8932
+ var _this$state$keyHandle, _this$state;
8933
+ if (key === "DISMISS") {
8934
+ this.dismiss();
8935
+ return;
8936
+ }
8937
+ const cursor = (_this$state$keyHandle = (_this$state = this.state).keyHandler) === null || _this$state$keyHandle === void 0 ? void 0 : _this$state$keyHandle.call(_this$state, key);
8938
+ this.setState({
8939
+ cursor
8940
+ });
8941
+ }
8942
+ render() {
8943
+ const {
8944
+ active,
8945
+ cursor,
8946
+ keypadConfig
8947
+ } = this.state;
8948
+ const containerStyle = [styles.keypadContainer, active ? styles.activeKeypadContainer : null];
8949
+ const isExpression = (keypadConfig === null || keypadConfig === void 0 ? void 0 : keypadConfig.keypadType) === "EXPRESSION";
8950
+ return /*#__PURE__*/React__namespace.createElement(View, {
8951
+ style: containerStyle,
8952
+ ref: element => {
8953
+ if (!this.hasMounted && element) {
8954
+ var _this$props$onElement, _this$props2;
8955
+ // TODO(matthewc)[LC-1081]: clean up this weird
8956
+ // object and type the onElementMounted callback
8957
+ // Append the dispatch methods that we want to expose
8958
+ // externally to the returned React element.
8959
+ const elementWithDispatchMethods = {
8960
+ ...element,
8961
+ activate: this.activate,
8962
+ dismiss: this.dismiss,
8963
+ configure: this.configure,
8964
+ setCursor: this.setCursor,
8965
+ setKeyHandler: this.setKeyHandler,
8966
+ getDOMNode: this.getDOMNode
8967
+ };
8968
+ this.hasMounted = true;
8969
+ (_this$props$onElement = (_this$props2 = this.props).onElementMounted) === null || _this$props$onElement === void 0 ? void 0 : _this$props$onElement.call(_this$props2, elementWithDispatchMethods);
8970
+ }
8971
+ }
8972
+ }, /*#__PURE__*/React__namespace.createElement(Keypad
8973
+ // TODO(jeremy)
8974
+ , {
8975
+ sendEvent: async () => {},
8976
+ extraKeys: keypadConfig === null || keypadConfig === void 0 ? void 0 : keypadConfig.extraKeys,
8977
+ onClickKey: key => this._handleClickKey(key),
8978
+ cursorContext: cursor === null || cursor === void 0 ? void 0 : cursor.context,
8979
+ multiplicationDot: isExpression,
8980
+ divisionKey: isExpression,
8981
+ trigonometry: isExpression,
8982
+ preAlgebra: isExpression,
8983
+ logarithms: isExpression,
8984
+ basicRelations: isExpression,
8985
+ advancedRelations: isExpression,
8986
+ showDismiss: true
8987
+ }));
8988
+ }
8989
+ }
8990
+ const styles = aphrodite.StyleSheet.create({
8991
+ keypadContainer: {
8992
+ bottom: 0,
8993
+ left: 0,
8994
+ right: 0,
8995
+ position: "fixed",
8996
+ transition: "200ms ease-out",
8997
+ transitionProperty: "transform",
8998
+ transform: "translate3d(0, 100%, 0)"
8999
+ },
9000
+ activeKeypadContainer: {
9001
+ transform: "translate3d(0, 0, 0)"
9002
+ }
9003
+ });
9004
+
9005
+ /**
9006
+ * React PropTypes that may be shared between components.
9007
+ */
9008
+
9009
+ // NOTE(jared): This is no longer guaranteed to be React element
9010
+ const keypadElementPropType = PropTypes__default["default"].shape({
9011
+ activate: PropTypes__default["default"].func.isRequired,
9012
+ dismiss: PropTypes__default["default"].func.isRequired,
9013
+ configure: PropTypes__default["default"].func.isRequired,
9014
+ setCursor: PropTypes__default["default"].func.isRequired,
9015
+ setKeyHandler: PropTypes__default["default"].func.isRequired,
9016
+ getDOMNode: PropTypes__default["default"].func.isRequired
9017
+ });
9018
+
8885
9019
  exports.CursorContext = CursorContext;
8886
9020
  exports.KeyConfigs = KeyConfigs;
8887
9021
  exports.Keypad = Keypad;
8888
9022
  exports.KeypadInput = MathInput;
8889
9023
  exports.KeypadType = KeypadType;
8890
9024
  exports.LegacyKeypad = ProvidedKeypad;
9025
+ exports.MobileKeypad = MobileKeypad;
8891
9026
  exports.createMathField = createMathField;
8892
9027
  exports.getCursorContext = getCursorContext;
8893
9028
  exports.keyTranslator = keyToMathquillMap;