@khanacademy/math-input 0.0.0-PR532-20230516152439 → 0.0.0-PR533-20230517213530

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 (34) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/dist/components/key-translator.d.ts +5 -0
  3. package/dist/components/key-translator.js.flow +11 -0
  4. package/dist/components/keypad-legacy/gesture-manager.d.ts +11 -1
  5. package/dist/components/keypad-legacy/gesture-manager.js.flow +14 -4
  6. package/dist/components/keypad-legacy/gesture-state-machine.d.ts +5 -5
  7. package/dist/components/keypad-legacy/gesture-state-machine.js.flow +6 -6
  8. package/dist/components/keypad-legacy/store/actions.d.ts +1 -11
  9. package/dist/components/keypad-legacy/store/actions.js.flow +0 -12
  10. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +1 -1
  11. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +1 -1
  12. package/dist/data/keys.d.ts +1 -1
  13. package/dist/data/keys.js.flow +5 -1
  14. package/dist/es/index.js +234 -64
  15. package/dist/es/index.js.map +1 -1
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +243 -63
  18. package/dist/index.js.flow +1 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/types.d.ts +7 -0
  21. package/dist/types.js.flow +7 -0
  22. package/package.json +1 -1
  23. package/src/components/key-translator.ts +182 -0
  24. package/src/components/keypad/button-assets.tsx +4 -0
  25. package/src/components/keypad/keypad-mathquill.stories.tsx +69 -0
  26. package/src/components/keypad-legacy/gesture-manager.ts +16 -4
  27. package/src/components/keypad-legacy/gesture-state-machine.ts +10 -10
  28. package/src/components/keypad-legacy/store/actions.ts +0 -26
  29. package/src/components/keypad-legacy/store/index.ts +1 -7
  30. package/src/data/key-configs.ts +20 -0
  31. package/src/data/keys.ts +7 -1
  32. package/src/index.ts +1 -0
  33. package/src/types.ts +8 -0
  34. package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @khanacademy/math-input
2
2
 
3
- ## 0.0.0-PR532-20230516152439
3
+ ## 0.0.0-PR533-20230517213530
4
4
 
5
5
  ### Major Changes
6
6
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### Minor Changes
10
10
 
11
- - 648dbca9: Added remaining missing keys for current pages
11
+ - 0d352105: Added remaining missing keys for current pages
12
12
 
13
13
  ### Patch Changes
14
14
 
@@ -0,0 +1,5 @@
1
+ import Key from "../data/keys";
2
+ import { MathQuillInterface } from "../types";
3
+ type MathQuillCallback = (mathQuill: MathQuillInterface) => void;
4
+ declare const keyToMathquillMap: Record<Key, MathQuillCallback | null>;
5
+ export default keyToMathquillMap;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import Key from "../data/keys";
8
+ import { MathQuillInterface } from "../types";
9
+ declare type MathQuillCallback = (mathQuill: MathQuillInterface) => void;
10
+ declare var keyToMathquillMap: { [key: Key]: MathQuillCallback | null };
11
+ declare export default typeof keyToMathquillMap;
@@ -5,16 +5,26 @@
5
5
  */
6
6
  import * as React from "react";
7
7
  import Key from "../../data/keys";
8
+ import { ActiveNodesObj, LayoutProps } from "../../types";
8
9
  import GestureStateMachine from "./gesture-state-machine";
9
10
  import NodeManager from "./node-manager";
10
11
  import PopoverStateMachine from "./popover-state-machine";
12
+ type Options = {
13
+ swipeEnabled: boolean;
14
+ };
15
+ type Handlers = {
16
+ onSwipeChange?: (dx: number) => void;
17
+ onSwipeEnd?: (dx: number) => void;
18
+ onActiveNodesChanged: (activeNodes: ActiveNodesObj) => void;
19
+ onClick: (key: Key, layoutProps: LayoutProps, inPopover: boolean) => void;
20
+ };
11
21
  declare class GestureManager {
12
22
  swipeEnabled: boolean;
13
23
  trackEvents: boolean;
14
24
  nodeManager: NodeManager;
15
25
  popoverStateMachine: PopoverStateMachine;
16
26
  gestureStateMachine: GestureStateMachine;
17
- constructor(options: any, handlers: any, disabledSwipeKeys: Array<Key>, multiPressableKeys: Array<Key>);
27
+ constructor(options: Options, handlers: Handlers, disabledSwipeKeys: ReadonlyArray<Key>, multiPressableKeys: ReadonlyArray<Key>);
18
28
  /**
19
29
  * Handle a touch-start event that originated in a node registered with the
20
30
  * gesture system.
@@ -6,9 +6,19 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  import Key from "../../data/keys";
9
+ import { ActiveNodesObj, LayoutProps } from "../../types";
9
10
  import GestureStateMachine from "./gesture-state-machine";
10
11
  import NodeManager from "./node-manager";
11
12
  import PopoverStateMachine from "./popover-state-machine";
13
+ declare type Options = {|
14
+ swipeEnabled: boolean,
15
+ |};
16
+ declare type Handlers = {|
17
+ onSwipeChange?: (dx: number) => void,
18
+ onSwipeEnd?: (dx: number) => void,
19
+ onActiveNodesChanged: (activeNodes: ActiveNodesObj) => void,
20
+ onClick: (key: Key, layoutProps: LayoutProps, inPopover: boolean) => void,
21
+ |};
12
22
  declare class GestureManager {
13
23
  swipeEnabled: boolean;
14
24
  trackEvents: boolean;
@@ -16,10 +26,10 @@ declare class GestureManager {
16
26
  popoverStateMachine: PopoverStateMachine;
17
27
  gestureStateMachine: GestureStateMachine;
18
28
  constructor(
19
- options: any,
20
- handlers: any,
21
- disabledSwipeKeys: Array<Key>,
22
- multiPressableKeys: Array<Key>
29
+ options: Options,
30
+ handlers: Handlers,
31
+ disabledSwipeKeys: $ReadOnlyArray<Key>,
32
+ multiPressableKeys: $ReadOnlyArray<Key>
23
33
  ): this;
24
34
 
25
35
  /**
@@ -11,8 +11,8 @@ export type Handlers = {
11
11
  onBlur: () => void;
12
12
  onTrigger: (id: string) => void;
13
13
  onLongPress: (id: string) => void;
14
- onSwipeChange: (x: number) => void;
15
- onSwipeEnd: (x: number) => void;
14
+ onSwipeChange?: (x: number) => void;
15
+ onSwipeEnd?: (x: number) => void;
16
16
  onTouchEnd: (id: string) => void;
17
17
  };
18
18
  type Options = {
@@ -35,11 +35,11 @@ type SwipeState = {
35
35
  declare class GestureStateMachine {
36
36
  handlers: Handlers;
37
37
  options: Options;
38
- swipeDisabledNodeIds: Partial<Key[]>;
39
- multiPressableKeys: Partial<Key[]>;
38
+ swipeDisabledNodeIds: ReadonlyArray<Key>;
39
+ multiPressableKeys: ReadonlyArray<Key>;
40
40
  touchState: Partial<TouchStateMap>;
41
41
  swipeState: SwipeState | null;
42
- constructor(handlers: Handlers, options: Partial<Options>, swipeDisabledNodeIds?: Key[], multiPressableKeys?: Key[]);
42
+ constructor(handlers: Handlers, options: Partial<Options>, swipeDisabledNodeIds?: ReadonlyArray<Key>, multiPressableKeys?: ReadonlyArray<Key>);
43
43
  _maybeCancelLongPressForTouch(touchId: any): void;
44
44
  _maybeCancelPressAndHoldForTouch(touchId: any): void;
45
45
  _cleanupTouchEvent(touchId: any): void;
@@ -18,8 +18,8 @@ export type Handlers = {|
18
18
  onBlur: () => void,
19
19
  onTrigger: (id: string) => void,
20
20
  onLongPress: (id: string) => void,
21
- onSwipeChange: (x: number) => void,
22
- onSwipeEnd: (x: number) => void,
21
+ onSwipeChange?: (x: number) => void,
22
+ onSwipeEnd?: (x: number) => void,
23
23
  onTouchEnd: (id: string) => void,
24
24
  |};
25
25
  declare type Options = {|
@@ -42,15 +42,15 @@ declare type SwipeState = {|
42
42
  declare class GestureStateMachine {
43
43
  handlers: Handlers;
44
44
  options: Options;
45
- swipeDisabledNodeIds: $Rest<Key[], {}>;
46
- multiPressableKeys: $Rest<Key[], {}>;
45
+ swipeDisabledNodeIds: $ReadOnlyArray<Key>;
46
+ multiPressableKeys: $ReadOnlyArray<Key>;
47
47
  touchState: $Rest<TouchStateMap, {}>;
48
48
  swipeState: SwipeState | null;
49
49
  constructor(
50
50
  handlers: Handlers,
51
51
  options: $Rest<Options, {}>,
52
- swipeDisabledNodeIds?: Key[],
53
- multiPressableKeys?: Key[]
52
+ swipeDisabledNodeIds?: $ReadOnlyArray<Key>,
53
+ multiPressableKeys?: $ReadOnlyArray<Key>
54
54
  ): this;
55
55
  _maybeCancelLongPressForTouch(touchId: any): void;
56
56
  _maybeCancelPressAndHoldForTouch(touchId: any): void;
@@ -37,16 +37,6 @@ type SetCursorAction = {
37
37
  cursor: Cursor;
38
38
  };
39
39
  export declare const setCursor: (cursor: Cursor) => SetCursorAction;
40
- type OnSwipeChangeAction = {
41
- type: "OnSwipeChange";
42
- dx: number;
43
- };
44
- export declare const onSwipeChange: (dx: number) => OnSwipeChangeAction;
45
- type OnSwipeEndAction = {
46
- type: "OnSwipeEnd";
47
- dx: number;
48
- };
49
- export declare const onSwipeEnd: (dx: number) => OnSwipeEndAction;
50
40
  type SetActiveNodesAction = {
51
41
  type: "SetActiveNodes";
52
42
  activeNodes: any;
@@ -59,5 +49,5 @@ type PressKeyAction = {
59
49
  inPopover: boolean;
60
50
  };
61
51
  export declare const pressKey: (key: Key, initialBounds: Bound, inPopover: any) => PressKeyAction;
62
- export type Action = DismissKeypadAction | ActivateKeypadAction | ConfigureKeypadAction | SetPageSizeAction | RemoveEchoAction | SetKeyHandlerAction | SetCursorAction | OnSwipeChangeAction | OnSwipeEndAction | SetActiveNodesAction | PressKeyAction;
52
+ export type Action = DismissKeypadAction | ActivateKeypadAction | ConfigureKeypadAction | SetPageSizeAction | RemoveEchoAction | SetKeyHandlerAction | SetCursorAction | SetActiveNodesAction | PressKeyAction;
63
53
  export {};
@@ -56,16 +56,6 @@ declare type SetCursorAction = {|
56
56
  cursor: Cursor,
57
57
  |};
58
58
  declare export var setCursor: (cursor: Cursor) => SetCursorAction;
59
- declare type OnSwipeChangeAction = {|
60
- type: "OnSwipeChange",
61
- dx: number,
62
- |};
63
- declare export var onSwipeChange: (dx: number) => OnSwipeChangeAction;
64
- declare type OnSwipeEndAction = {|
65
- type: "OnSwipeEnd",
66
- dx: number,
67
- |};
68
- declare export var onSwipeEnd: (dx: number) => OnSwipeEndAction;
69
59
  declare type SetActiveNodesAction = {|
70
60
  type: "SetActiveNodes",
71
61
  activeNodes: any,
@@ -92,7 +82,5 @@ export type Action =
92
82
  | RemoveEchoAction
93
83
  | SetKeyHandlerAction
94
84
  | SetCursorAction
95
- | OnSwipeChangeAction
96
- | OnSwipeEndAction
97
85
  | SetActiveNodesAction
98
86
  | PressKeyAction;
@@ -33,5 +33,5 @@ declare class TouchableKeypadButton extends React.Component<Props> {
33
33
  componentWillUnmount(): void;
34
34
  render(): JSX.Element;
35
35
  }
36
- declare const _default: import("react-redux").ConnectedComponent<typeof TouchableKeypadButton, import("react-redux").Omit<React.ClassAttributes<TouchableKeypadButton> & Props, "style" | "ariaLabel" | "type" | "id" | "icon" | "focused" | "borders" | "childKeys" | "disabled" | "popoverEnabled" | "gestureManager" | "childKeyIds"> & OwnProps>;
36
+ declare const _default: import("react-redux").ConnectedComponent<typeof TouchableKeypadButton, import("react-redux").Omit<React.ClassAttributes<TouchableKeypadButton> & Props, "style" | "ariaLabel" | "type" | "id" | "icon" | "childKeyIds" | "focused" | "borders" | "childKeys" | "disabled" | "popoverEnabled" | "gestureManager"> & OwnProps>;
37
37
  export default _default;
@@ -45,13 +45,13 @@ declare var _default: $Flowgen$Import$react_2d_redux.ConnectedComponent<
45
45
  | "type"
46
46
  | "id"
47
47
  | "icon"
48
+ | "childKeyIds"
48
49
  | "focused"
49
50
  | "borders"
50
51
  | "childKeys"
51
52
  | "disabled"
52
53
  | "popoverEnabled"
53
54
  | "gestureManager"
54
- | "childKeyIds"
55
55
  >,
56
56
  ...OwnProps,
57
57
  |}
@@ -1,2 +1,2 @@
1
- type Key = "PLUS" | "MINUS" | "NEGATIVE" | "TIMES" | "DIVIDE" | "DECIMAL" | "PERIOD" | "PERCENT" | "CDOT" | "EQUAL" | "NEQ" | "GT" | "LT" | "GEQ" | "LEQ" | "FRAC_INCLUSIVE" | "FRAC_EXCLUSIVE" | "FRAC" | "EXP" | "EXP_2" | "EXP_3" | "SQRT" | "CUBE_ROOT" | "RADICAL" | "LEFT_PAREN" | "RIGHT_PAREN" | "LN" | "LOG" | "LOG_N" | "SIN" | "COS" | "TAN" | "PI" | "THETA" | "UP" | "RIGHT" | "DOWN" | "LEFT" | "BACKSPACE" | "DISMISS" | "JUMP_OUT_PARENTHESES" | "JUMP_OUT_EXPONENT" | "JUMP_OUT_BASE" | "JUMP_INTO_NUMERATOR" | "JUMP_OUT_NUMERATOR" | "JUMP_OUT_DENOMINATOR" | "NOOP" | "MANY" | "NUM_0" | "NUM_1" | "NUM_2" | "NUM_3" | "NUM_4" | "NUM_5" | "NUM_6" | "NUM_7" | "NUM_8" | "NUM_9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
1
+ type Key = "PLUS" | "MINUS" | "NEGATIVE" | "TIMES" | "DIVIDE" | "DECIMAL" | "PERIOD" | "PERCENT" | "CDOT" | "EQUAL" | "NEQ" | "GT" | "LT" | "GEQ" | "LEQ" | "FRAC_INCLUSIVE" | "FRAC_EXCLUSIVE" | "FRAC" | "EXP" | "EXP_2" | "EXP_3" | "SQRT" | "CUBE_ROOT" | "RADICAL" | "LEFT_PAREN" | "RIGHT_PAREN" | "LN" | "LOG" | "LOG_N" | "SIN" | "COS" | "TAN" | "PI" | "THETA" | "UP" | "RIGHT" | "DOWN" | "LEFT" | "BACKSPACE" | "DISMISS" | "JUMP_OUT_PARENTHESES" | "JUMP_OUT_EXPONENT" | "JUMP_OUT_BASE" | "JUMP_INTO_NUMERATOR" | "JUMP_OUT_NUMERATOR" | "JUMP_OUT_DENOMINATOR" | "NOOP" | "MANY" | "NUM_0" | "NUM_1" | "NUM_2" | "NUM_3" | "NUM_4" | "NUM_5" | "NUM_6" | "NUM_7" | "NUM_8" | "NUM_9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "PHI" | "NTHROOT3" | "POW" | "LOG_B";
2
2
  export default Key;
@@ -114,5 +114,9 @@ declare type Key =
114
114
  | "W"
115
115
  | "X"
116
116
  | "Y"
117
- | "Z";
117
+ | "Z"
118
+ | "PHI"
119
+ | "NTHROOT3"
120
+ | "POW"
121
+ | "LOG_B";
118
122
  declare export default typeof Key;