@khanacademy/math-input 3.0.0 → 4.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 (91) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/components/input/__tests__/test-math-wrapper.d.ts +1 -1
  3. package/dist/components/input/__tests__/test-math-wrapper.js.flow +1 -1
  4. package/dist/components/input/key-handlers/handle-arrow.d.ts +3 -0
  5. package/dist/components/input/key-handlers/handle-arrow.js.flow +12 -0
  6. package/dist/components/input/key-handlers/handle-backspace.d.ts +7 -0
  7. package/dist/components/input/key-handlers/handle-backspace.js.flow +14 -0
  8. package/dist/components/input/key-handlers/handle-exponent.d.ts +3 -0
  9. package/dist/components/input/key-handlers/handle-exponent.js.flow +12 -0
  10. package/dist/components/input/key-handlers/handle-jump-out.d.ts +7 -0
  11. package/dist/components/input/key-handlers/handle-jump-out.js.flow +14 -0
  12. package/dist/components/input/math-wrapper.d.ts +7 -78
  13. package/dist/components/input/math-wrapper.js.flow +16 -78
  14. package/dist/components/input/mathquill-helpers.d.ts +46 -0
  15. package/dist/components/input/mathquill-helpers.js.flow +56 -0
  16. package/dist/components/input/mathquill-instance.d.ts +3 -0
  17. package/dist/components/input/mathquill-instance.js.flow +9 -0
  18. package/dist/components/input/mathquill-types.d.ts +25 -0
  19. package/dist/components/input/mathquill-types.js.flow +34 -0
  20. package/dist/components/key-translator.d.ts +4 -0
  21. package/dist/components/key-translator.js.flow +10 -0
  22. package/dist/components/keypad/button-assets.d.ts +2 -2
  23. package/dist/components/keypad/button-assets.js.flow +2 -2
  24. package/dist/components/keypad/keypad-page-items.d.ts +1 -1
  25. package/dist/components/keypad/keypad-page-items.js.flow +1 -1
  26. package/dist/components/keypad-legacy/gesture-manager.d.ts +21 -9
  27. package/dist/components/keypad-legacy/gesture-manager.js.flow +27 -12
  28. package/dist/components/keypad-legacy/gesture-state-machine.d.ts +9 -9
  29. package/dist/components/keypad-legacy/gesture-state-machine.js.flow +10 -10
  30. package/dist/components/keypad-legacy/keypad-button.d.ts +2 -2
  31. package/dist/components/keypad-legacy/keypad-button.js.flow +3 -3
  32. package/dist/components/keypad-legacy/store/actions.d.ts +4 -14
  33. package/dist/components/keypad-legacy/store/actions.js.flow +3 -15
  34. package/dist/components/keypad-legacy/store/types.d.ts +2 -2
  35. package/dist/components/keypad-legacy/store/types.js.flow +2 -2
  36. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +6 -6
  37. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +9 -14
  38. package/dist/data/key-configs.d.ts +3 -6
  39. package/dist/data/key-configs.js.flow +3 -8
  40. package/dist/data/keys.d.ts +2 -54
  41. package/dist/data/keys.js.flow +116 -55
  42. package/dist/enums.d.ts +2 -9
  43. package/dist/enums.js.flow +2 -11
  44. package/dist/es/index.js +1781 -1196
  45. package/dist/es/index.js.map +1 -1
  46. package/dist/index.d.ts +3 -2
  47. package/dist/index.js +2069 -1242
  48. package/dist/index.js.flow +4 -2
  49. package/dist/index.js.map +1 -1
  50. package/dist/strings.js +26 -10
  51. package/dist/types.d.ts +10 -12
  52. package/dist/types.js.flow +13 -12
  53. package/package.json +1 -1
  54. package/src/components/input/__tests__/context-tracking.test.ts +43 -44
  55. package/src/components/input/__tests__/mathquill.test.ts +133 -135
  56. package/src/components/input/key-handlers/handle-arrow.ts +70 -0
  57. package/src/components/input/key-handlers/handle-backspace.ts +275 -0
  58. package/src/components/input/key-handlers/handle-exponent.ts +52 -0
  59. package/src/components/input/key-handlers/handle-jump-out.ts +103 -0
  60. package/src/components/input/math-input.tsx +11 -12
  61. package/src/components/input/math-wrapper.ts +88 -837
  62. package/src/components/input/mathquill-helpers.ts +268 -0
  63. package/src/components/input/mathquill-instance.ts +5 -0
  64. package/src/components/input/mathquill-types.ts +55 -0
  65. package/src/components/key-translator.ts +209 -0
  66. package/src/components/keypad/button-assets.tsx +411 -100
  67. package/src/components/keypad/geometry-page/index.tsx +1 -1
  68. package/src/components/keypad/keypad-mathquill.stories.tsx +69 -0
  69. package/src/components/keypad/keypad-page-items.tsx +2 -1
  70. package/src/components/keypad/operators-page/index.tsx +1 -1
  71. package/src/components/keypad-legacy/echo-manager.tsx +4 -4
  72. package/src/components/keypad-legacy/empty-keypad-button.tsx +6 -4
  73. package/src/components/keypad-legacy/gesture-manager.ts +32 -9
  74. package/src/components/keypad-legacy/gesture-state-machine.ts +14 -14
  75. package/src/components/keypad-legacy/keypad-button.tsx +15 -18
  76. package/src/components/keypad-legacy/many-keypad-button.tsx +9 -2
  77. package/src/components/keypad-legacy/store/actions.ts +3 -29
  78. package/src/components/keypad-legacy/store/echo-reducer.ts +2 -5
  79. package/src/components/keypad-legacy/store/index.ts +4 -10
  80. package/src/components/keypad-legacy/store/input-reducer.ts +1 -2
  81. package/src/components/keypad-legacy/store/keypad-reducer.ts +2 -3
  82. package/src/components/keypad-legacy/store/types.ts +2 -2
  83. package/src/components/keypad-legacy/touchable-keypad-button.tsx +8 -13
  84. package/src/components/tabbar/icons.tsx +0 -2
  85. package/src/data/key-configs.ts +751 -304
  86. package/src/data/keys.ts +118 -65
  87. package/src/enums.ts +10 -9
  88. package/src/index.ts +3 -2
  89. package/src/math-input.stories.tsx +1 -1
  90. package/src/types.ts +10 -12
  91. package/tsconfig-build.tsbuildinfo +1 -1
@@ -10,18 +10,13 @@ import ReactDOM from "react-dom";
10
10
  import {connect} from "react-redux";
11
11
 
12
12
  import KeyConfigs from "../../data/key-configs";
13
- import Keys from "../../data/keys";
13
+ import Key from "../../data/keys";
14
14
  import {KeyType} from "../../enums";
15
15
 
16
16
  import GestureManager from "./gesture-manager";
17
17
  import KeypadButton from "./keypad-button";
18
18
 
19
- import type {
20
- Border,
21
- IconConfig,
22
- KeyConfig,
23
- NonManyKeyConfig,
24
- } from "../../types";
19
+ import type {Border, IconConfig, KeyConfig} from "../../types";
25
20
  import type {State} from "./store/types";
26
21
  import type {StyleType} from "@khanacademy/wonder-blocks-core";
27
22
 
@@ -38,12 +33,12 @@ interface OwnProps extends SharedProps {
38
33
  interface Props extends SharedProps {
39
34
  childKeyIds?: ReadonlyArray<string>;
40
35
  gestureManager: GestureManager;
41
- id: Keys | "MANY";
36
+ id: Key;
42
37
  focused: boolean;
43
38
  popoverEnabled: boolean;
44
- childKeys?: ReadonlyArray<NonManyKeyConfig>;
39
+ childKeys?: ReadonlyArray<KeyConfig>;
45
40
  ariaLabel?: string;
46
- icon: IconConfig;
41
+ icon?: IconConfig;
47
42
  type: KeyType;
48
43
  }
49
44
 
@@ -116,7 +111,7 @@ class TouchableKeypadButton extends React.Component<Props> {
116
111
  }
117
112
  }
118
113
 
119
- const extractProps = (keyConfig: NonManyKeyConfig) => {
114
+ const extractProps = (keyConfig: KeyConfig) => {
120
115
  const {ariaLabel, icon, type} = keyConfig;
121
116
  return {ariaLabel, icon, type};
122
117
  };
@@ -130,14 +125,14 @@ const mapStateToProps = (state: State, ownProps: OwnProps): Props => {
130
125
  const childKeyIds =
131
126
  "childKeyIds" in keyConfig ? keyConfig.childKeyIds : undefined;
132
127
 
133
- const childKeys = childKeyIds
128
+ const childKeys: readonly KeyConfig[] | undefined = childKeyIds
134
129
  ? childKeyIds.map((id) => KeyConfigs[id])
135
130
  : undefined;
136
131
 
137
132
  // Override with the default child props, if the key is a multi-symbol key
138
133
  // (but not a many-symbol key, which operates under different rules).
139
134
  const useFirstChildProps =
140
- type !== KeyType.MANY && childKeys && childKeys.length > 0;
135
+ type !== "MANY" && childKeys && childKeys.length > 0;
141
136
 
142
137
  return {
143
138
  ...rest,
@@ -28,8 +28,6 @@ const IconAsset = function ({tintColor, type}: Props): React.ReactElement {
28
28
  } else if (type === "Operators") {
29
29
  return (
30
30
  <svg
31
- width="32"
32
- height="32"
33
31
  viewBox="0 0 32 32"
34
32
  fill="none"
35
33
  xmlns="http://www.w3.org/2000/svg"