@khanacademy/math-input 3.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/.eslintrc.js +7 -1
  2. package/CHANGELOG.md +42 -0
  3. package/dist/components/input/__tests__/test-math-wrapper.d.ts +1 -1
  4. package/dist/components/input/__tests__/test-math-wrapper.js.flow +1 -1
  5. package/dist/components/input/key-handlers/handle-arrow.d.ts +3 -0
  6. package/dist/components/input/key-handlers/handle-arrow.js.flow +12 -0
  7. package/dist/components/input/key-handlers/handle-backspace.d.ts +7 -0
  8. package/dist/components/input/key-handlers/handle-backspace.js.flow +14 -0
  9. package/dist/components/input/key-handlers/handle-exponent.d.ts +3 -0
  10. package/dist/components/input/key-handlers/handle-exponent.js.flow +12 -0
  11. package/dist/components/input/key-handlers/handle-jump-out.d.ts +7 -0
  12. package/dist/components/input/key-handlers/handle-jump-out.js.flow +14 -0
  13. package/dist/components/input/math-wrapper.d.ts +7 -78
  14. package/dist/components/input/math-wrapper.js.flow +16 -78
  15. package/dist/components/input/mathquill-helpers.d.ts +46 -0
  16. package/dist/components/input/mathquill-helpers.js.flow +56 -0
  17. package/dist/components/input/mathquill-instance.d.ts +3 -0
  18. package/dist/components/input/mathquill-instance.js.flow +9 -0
  19. package/dist/components/input/mathquill-types.d.ts +25 -0
  20. package/dist/components/input/mathquill-types.js.flow +34 -0
  21. package/dist/components/key-translator.d.ts +4 -0
  22. package/dist/components/key-translator.js.flow +10 -0
  23. package/dist/components/keypad/button-assets.d.ts +2 -2
  24. package/dist/components/keypad/button-assets.js.flow +2 -2
  25. package/dist/components/keypad/button.d.ts +1 -0
  26. package/dist/components/keypad/button.js.flow +1 -0
  27. package/dist/components/keypad/extras-page/index.d.ts +10 -0
  28. package/dist/components/keypad/extras-page/index.js.flow +15 -0
  29. package/dist/components/keypad/index.d.ts +7 -1
  30. package/dist/components/keypad/index.js.flow +7 -1
  31. package/dist/components/keypad/keypad-page-items.d.ts +1 -1
  32. package/dist/components/keypad/keypad-page-items.js.flow +1 -1
  33. package/dist/components/keypad-legacy/gesture-manager.d.ts +21 -9
  34. package/dist/components/keypad-legacy/gesture-manager.js.flow +27 -12
  35. package/dist/components/keypad-legacy/gesture-state-machine.d.ts +9 -9
  36. package/dist/components/keypad-legacy/gesture-state-machine.js.flow +10 -10
  37. package/dist/components/keypad-legacy/keypad-button.d.ts +2 -2
  38. package/dist/components/keypad-legacy/keypad-button.js.flow +3 -3
  39. package/dist/components/keypad-legacy/store/actions.d.ts +4 -14
  40. package/dist/components/keypad-legacy/store/actions.js.flow +3 -15
  41. package/dist/components/keypad-legacy/store/types.d.ts +2 -2
  42. package/dist/components/keypad-legacy/store/types.js.flow +2 -2
  43. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +6 -6
  44. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +9 -14
  45. package/dist/components/keypad-legacy/two-page-keypad.d.ts +6 -4
  46. package/dist/components/keypad-legacy/two-page-keypad.js.flow +6 -4
  47. package/dist/components/tabbar/tabbar.d.ts +6 -9
  48. package/dist/components/tabbar/tabbar.js.flow +6 -9
  49. package/dist/components/tabbar/types.d.ts +1 -1
  50. package/dist/components/tabbar/types.js.flow +1 -1
  51. package/dist/data/key-configs.d.ts +3 -6
  52. package/dist/data/key-configs.js.flow +3 -8
  53. package/dist/data/keys.d.ts +2 -54
  54. package/dist/data/keys.js.flow +116 -55
  55. package/dist/enums.d.ts +2 -9
  56. package/dist/enums.js.flow +2 -11
  57. package/dist/es/index.js +2000 -1346
  58. package/dist/es/index.js.map +1 -1
  59. package/dist/index.d.ts +3 -2
  60. package/dist/index.js +2288 -1392
  61. package/dist/index.js.flow +4 -2
  62. package/dist/index.js.map +1 -1
  63. package/dist/strings.js +26 -10
  64. package/dist/types.d.ts +10 -12
  65. package/dist/types.js.flow +13 -12
  66. package/package.json +2 -1
  67. package/src/components/input/__tests__/context-tracking.test.ts +43 -44
  68. package/src/components/input/__tests__/mathquill.test.ts +133 -135
  69. package/src/components/input/key-handlers/handle-arrow.ts +70 -0
  70. package/src/components/input/key-handlers/handle-backspace.ts +275 -0
  71. package/src/components/input/key-handlers/handle-exponent.ts +52 -0
  72. package/src/components/input/key-handlers/handle-jump-out.ts +103 -0
  73. package/src/components/input/math-input.tsx +11 -12
  74. package/src/components/input/math-wrapper.ts +88 -837
  75. package/src/components/input/mathquill-helpers.ts +268 -0
  76. package/src/components/input/mathquill-instance.ts +5 -0
  77. package/src/components/input/mathquill-types.ts +55 -0
  78. package/src/components/key-translator.ts +209 -0
  79. package/src/components/keypad/button-assets.tsx +441 -100
  80. package/src/components/keypad/button.tsx +7 -2
  81. package/src/components/keypad/extras-page/index.tsx +27 -0
  82. package/src/components/keypad/geometry-page/index.tsx +1 -1
  83. package/src/components/keypad/index.tsx +34 -7
  84. package/src/components/keypad/keypad-mathquill.stories.tsx +82 -0
  85. package/src/components/keypad/keypad-page-items.tsx +3 -1
  86. package/src/components/keypad/operators-page/index.tsx +1 -1
  87. package/src/components/keypad-legacy/echo-manager.tsx +4 -4
  88. package/src/components/keypad-legacy/empty-keypad-button.tsx +6 -4
  89. package/src/components/keypad-legacy/gesture-manager.ts +32 -9
  90. package/src/components/keypad-legacy/gesture-state-machine.ts +14 -14
  91. package/src/components/keypad-legacy/keypad-button.tsx +15 -18
  92. package/src/components/keypad-legacy/many-keypad-button.tsx +9 -2
  93. package/src/components/keypad-legacy/store/actions.ts +3 -29
  94. package/src/components/keypad-legacy/store/echo-reducer.ts +2 -5
  95. package/src/components/keypad-legacy/store/index.ts +4 -10
  96. package/src/components/keypad-legacy/store/input-reducer.ts +1 -2
  97. package/src/components/keypad-legacy/store/keypad-reducer.ts +2 -3
  98. package/src/components/keypad-legacy/store/types.ts +2 -2
  99. package/src/components/keypad-legacy/touchable-keypad-button.tsx +8 -13
  100. package/src/components/keypad-legacy/two-page-keypad.tsx +18 -6
  101. package/src/components/tabbar/__tests__/tabbar.test.tsx +36 -36
  102. package/src/components/tabbar/icons.tsx +68 -52
  103. package/src/components/tabbar/item.tsx +5 -1
  104. package/src/components/tabbar/tabbar.stories.tsx +23 -12
  105. package/src/components/tabbar/tabbar.tsx +22 -38
  106. package/src/components/tabbar/types.ts +1 -1
  107. package/src/data/key-configs.ts +751 -304
  108. package/src/data/keys.ts +118 -65
  109. package/src/enums.ts +10 -9
  110. package/src/index.ts +3 -2
  111. package/src/math-input.stories.tsx +1 -1
  112. package/src/types.ts +10 -12
  113. package/tsconfig-build.tsbuildinfo +1 -1
@@ -1,16 +1,22 @@
1
1
  import * as React from "react";
2
+ import Key from "../../data/keys";
3
+ import { TabbarItemType } from "../tabbar/types";
2
4
  import { NumbersPageOptions } from "./numbers-page/types";
3
5
  import { OperatorsButtonSets } from "./operators-page/types";
4
- import type { TabbarItemType } from "../tabbar/types";
5
6
  export type Props = {
6
7
  onClickKey: (keyConfig: string) => void;
7
8
  trigonometry?: boolean;
9
+ extraKeys: ReadonlyArray<Key>;
8
10
  } & OperatorsButtonSets & NumbersPageOptions;
9
11
  type State = {
10
12
  selectedPage: TabbarItemType;
11
13
  };
14
+ type DefaultProps = {
15
+ extraKeys: Props["extraKeys"];
16
+ };
12
17
  export default class Keypad extends React.Component<Props, State> {
13
18
  state: State;
19
+ static defaultProps: DefaultProps;
14
20
  render(): React.ReactNode;
15
21
  }
16
22
  export {};
@@ -5,13 +5,15 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
+ import Key from "../../data/keys";
9
+ import { TabbarItemType } from "../tabbar/types";
8
10
  import { NumbersPageOptions } from "./numbers-page/types";
9
11
  import { OperatorsButtonSets } from "./operators-page/types";
10
- import type { TabbarItemType } from "../tabbar/types";
11
12
  export type Props = {|
12
13
  ...{|
13
14
  onClickKey: (keyConfig: string) => void,
14
15
  trigonometry?: boolean,
16
+ extraKeys: $ReadOnlyArray<Key>,
15
17
  |},
16
18
  ...OperatorsButtonSets,
17
19
  ...NumbersPageOptions,
@@ -19,7 +21,11 @@ export type Props = {|
19
21
  declare type State = {|
20
22
  selectedPage: TabbarItemType,
21
23
  |};
24
+ declare type DefaultProps = {|
25
+ extraKeys: $PropertyType<Props, "extraKeys">,
26
+ |};
22
27
  declare export default class Keypad extends React.Component<Props, State> {
23
28
  state: State;
29
+ static defaultProps: DefaultProps;
24
30
  render(): React.Node;
25
31
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { KeyConfig } from "../../data/key-configs";
2
+ import { KeyConfig } from "../../types";
3
3
  import type { StyleType } from "@khanacademy/wonder-blocks-core";
4
4
  type KeypadPageContainerProps = {
5
5
  children: React.ReactNode;
@@ -5,7 +5,7 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- import type { KeyConfig } from "../../data/key-configs";
8
+ import { KeyConfig } from "../../types";
9
9
  import type { StyleType } from "@khanacademy/wonder-blocks-core";
10
10
  declare type KeypadPageContainerProps = {|
11
11
  children: React.Node,
@@ -3,46 +3,58 @@
3
3
  * connects our various bits of logic for managing gestures and interactions,
4
4
  * and links them together.
5
5
  */
6
+ import * as React from "react";
7
+ import Key from "../../data/keys";
8
+ import { ActiveNodesObj, LayoutProps } from "../../types";
6
9
  import GestureStateMachine from "./gesture-state-machine";
7
10
  import NodeManager from "./node-manager";
8
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
+ };
9
21
  declare class GestureManager {
10
22
  swipeEnabled: boolean;
11
23
  trackEvents: boolean;
12
24
  nodeManager: NodeManager;
13
25
  popoverStateMachine: PopoverStateMachine;
14
26
  gestureStateMachine: GestureStateMachine;
15
- constructor(options: any, handlers: any, disabledSwipeKeys: any, multiPressableKeys: any);
27
+ constructor(options: Options, handlers: Handlers, disabledSwipeKeys: ReadonlyArray<Key>, multiPressableKeys: ReadonlyArray<Key>);
16
28
  /**
17
29
  * Handle a touch-start event that originated in a node registered with the
18
30
  * gesture system.
19
31
  *
20
- * @param {TouchEvent} evt - the raw touch event from the browser
32
+ * @param {React.TouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
21
33
  * @param {string} id - the identifier of the DOM node in which the touch
22
34
  * occurred
23
35
  */
24
- onTouchStart(evt: TouchEvent, id?: any): void;
36
+ onTouchStart(evt: React.TouchEvent<HTMLDivElement>, id?: string | undefined): void;
25
37
  /**
26
38
  * Handle a touch-move event that originated in a node registered with the
27
39
  * gesture system.
28
40
  *
29
- * @param {TouchEvent} evt - the raw touch event from the browser
41
+ * @param {React.TouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
30
42
  */
31
- onTouchMove(evt: TouchEvent): void;
43
+ onTouchMove(evt: React.TouchEvent<HTMLDivElement>): void;
32
44
  /**
33
45
  * Handle a touch-end event that originated in a node registered with the
34
46
  * gesture system.
35
47
  *
36
- * @param {TouchEvent} evt - the raw touch event from the browser
48
+ * @param {React.TouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
37
49
  */
38
- onTouchEnd(evt: TouchEvent): void;
50
+ onTouchEnd(evt: React.TouchEvent<HTMLDivElement>): void;
39
51
  /**
40
52
  * Handle a touch-cancel event that originated in a node registered with the
41
53
  * gesture system.
42
54
  *
43
- * @param {TouchEvent} evt - the raw touch event from the browser
55
+ * @param {React.TouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
44
56
  */
45
- onTouchCancel(evt: TouchEvent): void;
57
+ onTouchCancel(evt: React.TouchEvent<HTMLDivElement>): void;
46
58
  /**
47
59
  * Register a DOM node with a given identifier.
48
60
  *
@@ -4,9 +4,21 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
+ import * as React from "react";
8
+ import Key from "../../data/keys";
9
+ import { ActiveNodesObj, LayoutProps } from "../../types";
7
10
  import GestureStateMachine from "./gesture-state-machine";
8
11
  import NodeManager from "./node-manager";
9
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
+ |};
10
22
  declare class GestureManager {
11
23
  swipeEnabled: boolean;
12
24
  trackEvents: boolean;
@@ -14,41 +26,44 @@ declare class GestureManager {
14
26
  popoverStateMachine: PopoverStateMachine;
15
27
  gestureStateMachine: GestureStateMachine;
16
28
  constructor(
17
- options: any,
18
- handlers: any,
19
- disabledSwipeKeys: any,
20
- multiPressableKeys: any
29
+ options: Options,
30
+ handlers: Handlers,
31
+ disabledSwipeKeys: $ReadOnlyArray<Key>,
32
+ multiPressableKeys: $ReadOnlyArray<Key>
21
33
  ): this;
22
34
 
23
35
  /**
24
36
  * Handle a touch-start event that originated in a node registered with the
25
37
  * gesture system.
26
- * @param {TouchEvent} evt - the raw touch event from the browser
38
+ * @param {SyntheticTouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
27
39
  * @param {string} id - the identifier of the DOM node in which the touch
28
40
  * occurred
29
41
  */
30
- onTouchStart(evt: TouchEvent, id?: any): void;
42
+ onTouchStart(
43
+ evt: SyntheticTouchEvent<HTMLDivElement>,
44
+ id?: string | void
45
+ ): void;
31
46
 
32
47
  /**
33
48
  * Handle a touch-move event that originated in a node registered with the
34
49
  * gesture system.
35
- * @param {TouchEvent} evt - the raw touch event from the browser
50
+ * @param {SyntheticTouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
36
51
  */
37
- onTouchMove(evt: TouchEvent): void;
52
+ onTouchMove(evt: SyntheticTouchEvent<HTMLDivElement>): void;
38
53
 
39
54
  /**
40
55
  * Handle a touch-end event that originated in a node registered with the
41
56
  * gesture system.
42
- * @param {TouchEvent} evt - the raw touch event from the browser
57
+ * @param {SyntheticTouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
43
58
  */
44
- onTouchEnd(evt: TouchEvent): void;
59
+ onTouchEnd(evt: SyntheticTouchEvent<HTMLDivElement>): void;
45
60
 
46
61
  /**
47
62
  * Handle a touch-cancel event that originated in a node registered with the
48
63
  * gesture system.
49
- * @param {TouchEvent} evt - the raw touch event from the browser
64
+ * @param {SyntheticTouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
50
65
  */
51
- onTouchCancel(evt: TouchEvent): void;
66
+ onTouchCancel(evt: SyntheticTouchEvent<HTMLDivElement>): void;
52
67
 
53
68
  /**
54
69
  * Register a DOM node with a given identifier.
@@ -1,4 +1,4 @@
1
- import Keys from "../../data/keys";
1
+ import Key from "../../data/keys";
2
2
  /**
3
3
  * The state machine that backs our gesture system. In particular, this state
4
4
  * machine manages the interplay between focuses, touch ups, and swiping.
@@ -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 = {
@@ -21,25 +21,25 @@ type Options = {
21
21
  holdIntervalMs: number;
22
22
  };
23
23
  type TouchState = {
24
- activeNodeId: Keys;
24
+ activeNodeId: Key;
25
25
  pressAndHoldIntervalId: number | null;
26
26
  longPressTimeoutId: number | null;
27
27
  swipeLocked: boolean;
28
28
  startX: number;
29
29
  };
30
- type TouchStateMap = Record<Keys, TouchState>;
30
+ type TouchStateMap = Record<Key, TouchState>;
31
31
  type SwipeState = {
32
- touchId: Keys;
32
+ touchId: Key;
33
33
  startX: number;
34
34
  };
35
35
  declare class GestureStateMachine {
36
36
  handlers: Handlers;
37
37
  options: Options;
38
- swipeDisabledNodeIds: Partial<[Keys]>;
39
- multiPressableKeys: Partial<[Keys]>;
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?: [Keys], multiPressableKeys?: [Keys]);
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;
@@ -4,7 +4,7 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import Keys from "../../data/keys";
7
+ import Key from "../../data/keys";
8
8
 
9
9
  /**
10
10
  * The state machine that backs our gesture system. In particular, this state
@@ -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 = {|
@@ -28,29 +28,29 @@ declare type Options = {|
28
28
  holdIntervalMs: number,
29
29
  |};
30
30
  declare type TouchState = {|
31
- activeNodeId: Keys,
31
+ activeNodeId: Key,
32
32
  pressAndHoldIntervalId: number | null,
33
33
  longPressTimeoutId: number | null,
34
34
  swipeLocked: boolean,
35
35
  startX: number,
36
36
  |};
37
- declare type TouchStateMap = { [key: Keys]: TouchState };
37
+ declare type TouchStateMap = { [key: Key]: TouchState };
38
38
  declare type SwipeState = {|
39
- touchId: Keys,
39
+ touchId: Key,
40
40
  startX: number,
41
41
  |};
42
42
  declare class GestureStateMachine {
43
43
  handlers: Handlers;
44
44
  options: Options;
45
- swipeDisabledNodeIds: $Rest<[Keys], {}>;
46
- multiPressableKeys: $Rest<[Keys], {}>;
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?: [Keys],
53
- multiPressableKeys?: [Keys]
52
+ swipeDisabledNodeIds?: $ReadOnlyArray<Key>,
53
+ multiPressableKeys?: $ReadOnlyArray<Key>
54
54
  ): this;
55
55
  _maybeCancelLongPressForTouch(touchId: any): void;
56
56
  _maybeCancelPressAndHoldForTouch(touchId: any): void;
@@ -17,7 +17,7 @@ interface Props extends ReduxProps {
17
17
  focused: boolean;
18
18
  popoverEnabled: boolean;
19
19
  type: KeyType;
20
- icon: IconConfig;
20
+ icon?: IconConfig;
21
21
  style?: StyleType;
22
22
  onTouchCancel?: (evt: React.TouchEvent<HTMLDivElement>) => void;
23
23
  onTouchEnd?: (evt: React.TouchEvent<HTMLDivElement>) => void;
@@ -42,7 +42,7 @@ declare class KeypadButton extends React.PureComponent<Props> {
42
42
  _getButtonStyle: (type: any, borders: any, style?: any) => any[];
43
43
  render(): JSX.Element;
44
44
  }
45
- declare const _default: import("react-redux").ConnectedComponent<typeof KeypadButton, import("react-redux").Omit<Pick<React.ClassAttributes<KeypadButton> & Props, "style" | "ref" | "ariaLabel" | "onTouchCancel" | "onTouchEnd" | "onTouchMove" | "onTouchStart" | "icon" | "type" | "heightPx" | "widthPx" | "key"> & {
45
+ declare const _default: import("react-redux").ConnectedComponent<typeof KeypadButton, import("react-redux").Omit<Pick<React.ClassAttributes<KeypadButton> & Props, "style" | "ref" | "ariaLabel" | "onTouchCancel" | "onTouchEnd" | "onTouchMove" | "onTouchStart" | "type" | "icon" | "key" | "heightPx" | "widthPx"> & {
46
46
  focused?: boolean | undefined;
47
47
  borders?: readonly (BorderDirection | undefined)[] | undefined;
48
48
  childKeys?: readonly NonManyKeyConfig[] | undefined;
@@ -21,7 +21,7 @@ declare type Props = {
21
21
  focused: boolean,
22
22
  popoverEnabled: boolean,
23
23
  type: KeyType,
24
- icon: IconConfig,
24
+ icon?: IconConfig,
25
25
  style?: StyleType,
26
26
  onTouchCancel?: (evt: SyntheticTouchEvent<HTMLDivElement>) => void,
27
27
  onTouchEnd?: (evt: SyntheticTouchEvent<HTMLDivElement>) => void,
@@ -59,11 +59,11 @@ declare var _default: $Flowgen$Import$react_2d_redux.ConnectedComponent<
59
59
  | "onTouchEnd"
60
60
  | "onTouchMove"
61
61
  | "onTouchStart"
62
- | "icon"
63
62
  | "type"
63
+ | "icon"
64
+ | "key"
64
65
  | "heightPx"
65
66
  | "widthPx"
66
- | "key"
67
67
  >,
68
68
  ...{|
69
69
  focused?: boolean | void,
@@ -1,4 +1,4 @@
1
- import Keys from "../../../data/keys";
1
+ import Key from "../../../data/keys";
2
2
  import type { Bound, KeypadConfiguration, KeyHandler, Cursor, ActiveNodesObj } from "../../../types";
3
3
  type DismissKeypadAction = {
4
4
  type: "DismissKeypad";
@@ -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;
@@ -54,10 +44,10 @@ type SetActiveNodesAction = {
54
44
  export declare const setActiveNodes: (activeNodes: ActiveNodesObj) => SetActiveNodesAction;
55
45
  type PressKeyAction = {
56
46
  type: "PressKey";
57
- key: Keys;
47
+ key: Key;
58
48
  initialBounds: Bound;
59
49
  inPopover: boolean;
60
50
  };
61
- export declare const pressKey: (key: Keys, initialBounds: Bound, inPopover: any) => PressKeyAction;
62
- export type Action = DismissKeypadAction | ActivateKeypadAction | ConfigureKeypadAction | SetPageSizeAction | RemoveEchoAction | SetKeyHandlerAction | SetCursorAction | OnSwipeChangeAction | OnSwipeEndAction | SetActiveNodesAction | PressKeyAction;
51
+ export declare const pressKey: (key: Key, initialBounds: Bound, inPopover: any) => PressKeyAction;
52
+ export type Action = DismissKeypadAction | ActivateKeypadAction | ConfigureKeypadAction | SetPageSizeAction | RemoveEchoAction | SetKeyHandlerAction | SetCursorAction | SetActiveNodesAction | PressKeyAction;
63
53
  export {};
@@ -4,7 +4,7 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import Keys from "../../../data/keys";
7
+ import Key from "../../../data/keys";
8
8
  import type {
9
9
  Bound,
10
10
  KeypadConfiguration,
@@ -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,
@@ -75,12 +65,12 @@ declare export var setActiveNodes: (
75
65
  ) => SetActiveNodesAction;
76
66
  declare type PressKeyAction = {|
77
67
  type: "PressKey",
78
- key: Keys,
68
+ key: Key,
79
69
  initialBounds: Bound,
80
70
  inPopover: boolean,
81
71
  |};
82
72
  declare export var pressKey: (
83
- key: Keys,
73
+ key: Key,
84
74
  initialBounds: Bound,
85
75
  inPopover: any
86
76
  ) => PressKeyAction;
@@ -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;
@@ -1,4 +1,4 @@
1
- import Keys from "../../../data/keys";
1
+ import Key from "../../../data/keys";
2
2
  import { LayoutMode, KeypadType } from "../../../enums";
3
3
  import GestureManager from "../gesture-manager";
4
4
  import type { Cursor, KeyHandler, Popover, Echo } from "../../../types";
@@ -13,7 +13,7 @@ export interface KeypadState {
13
13
  }
14
14
  export interface GestureState {
15
15
  popover: Popover | null;
16
- focus: Keys | null;
16
+ focus: Key | null;
17
17
  gestureManager: GestureManager;
18
18
  }
19
19
  export interface EchoState {
@@ -4,7 +4,7 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import Keys from "../../../data/keys";
7
+ import Key from "../../../data/keys";
8
8
  import { LayoutMode, KeypadType } from "../../../enums";
9
9
  import GestureManager from "../gesture-manager";
10
10
  import type { Cursor, KeyHandler, Popover, Echo } from "../../../types";
@@ -19,7 +19,7 @@ export interface KeypadState {
19
19
  }
20
20
  export interface GestureState {
21
21
  popover: Popover | null;
22
- focus: Keys | null;
22
+ focus: Key | null;
23
23
  gestureManager: GestureManager;
24
24
  }
25
25
  export interface EchoState {
@@ -4,10 +4,10 @@
4
4
  * touch events globally) opaque to the KeypadButton.
5
5
  */
6
6
  import * as React from "react";
7
- import Keys from "../../data/keys";
7
+ import Key from "../../data/keys";
8
8
  import { KeyType } from "../../enums";
9
9
  import GestureManager from "./gesture-manager";
10
- import type { Border, IconConfig, KeyConfig, NonManyKeyConfig } from "../../types";
10
+ import type { Border, IconConfig, KeyConfig } from "../../types";
11
11
  import type { StyleType } from "@khanacademy/wonder-blocks-core";
12
12
  interface SharedProps {
13
13
  borders?: Border;
@@ -20,12 +20,12 @@ interface OwnProps extends SharedProps {
20
20
  interface Props extends SharedProps {
21
21
  childKeyIds?: ReadonlyArray<string>;
22
22
  gestureManager: GestureManager;
23
- id: Keys | "MANY";
23
+ id: Key;
24
24
  focused: boolean;
25
25
  popoverEnabled: boolean;
26
- childKeys?: ReadonlyArray<NonManyKeyConfig>;
26
+ childKeys?: ReadonlyArray<KeyConfig>;
27
27
  ariaLabel?: string;
28
- icon: IconConfig;
28
+ icon?: IconConfig;
29
29
  type: KeyType;
30
30
  }
31
31
  declare class TouchableKeypadButton extends React.Component<Props> {
@@ -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" | "focused" | "icon" | "borders" | "childKeys" | "disabled" | "popoverEnabled" | "type" | "gestureManager" | "childKeyIds" | "id"> & 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;
@@ -6,15 +6,10 @@
6
6
  */
7
7
  import * as $Flowgen$Import$react_2d_redux from "react-redux";
8
8
  import * as React from "react";
9
- import Keys from "../../data/keys";
9
+ import Key from "../../data/keys";
10
10
  import { KeyType } from "../../enums";
11
11
  import GestureManager from "./gesture-manager";
12
- import type {
13
- Border,
14
- IconConfig,
15
- KeyConfig,
16
- NonManyKeyConfig,
17
- } from "../../types";
12
+ import type { Border, IconConfig, KeyConfig } from "../../types";
18
13
  import type { StyleType } from "@khanacademy/wonder-blocks-core";
19
14
  declare interface SharedProps {
20
15
  borders?: Border;
@@ -27,12 +22,12 @@ declare type OwnProps = {
27
22
  declare type Props = {
28
23
  childKeyIds?: $ReadOnlyArray<string>,
29
24
  gestureManager: GestureManager,
30
- id: Keys | "MANY",
25
+ id: Key,
31
26
  focused: boolean,
32
27
  popoverEnabled: boolean,
33
- childKeys?: $ReadOnlyArray<NonManyKeyConfig>,
28
+ childKeys?: $ReadOnlyArray<KeyConfig>,
34
29
  ariaLabel?: string,
35
- icon: IconConfig,
30
+ icon?: IconConfig,
36
31
  type: KeyType,
37
32
  } & SharedProps;
38
33
  declare class TouchableKeypadButton extends React.Component<Props> {
@@ -47,16 +42,16 @@ declare var _default: $Flowgen$Import$react_2d_redux.ConnectedComponent<
47
42
  {| ...React.ClassAttributes<TouchableKeypadButton>, ...Props |},
48
43
  | "style"
49
44
  | "ariaLabel"
50
- | "focused"
45
+ | "type"
46
+ | "id"
51
47
  | "icon"
48
+ | "childKeyIds"
49
+ | "focused"
52
50
  | "borders"
53
51
  | "childKeys"
54
52
  | "disabled"
55
53
  | "popoverEnabled"
56
- | "type"
57
54
  | "gestureManager"
58
- | "childKeyIds"
59
- | "id"
60
55
  >,
61
56
  ...OwnProps,
62
57
  |}
@@ -2,6 +2,7 @@
2
2
  * A keypad with two pages of keys.
3
3
  */
4
4
  import * as React from "react";
5
+ import { TabbarItemType } from "../tabbar/types";
5
6
  interface ReduxProps {
6
7
  paginationEnabled: boolean;
7
8
  }
@@ -9,10 +10,11 @@ interface Props extends ReduxProps {
9
10
  leftPage: React.ReactNode;
10
11
  rightPage: React.ReactNode;
11
12
  }
12
- declare class TwoPageKeypad extends React.Component<Props> {
13
- state: {
14
- selectedPage: string;
15
- };
13
+ type State = {
14
+ selectedPage: TabbarItemType;
15
+ };
16
+ declare class TwoPageKeypad extends React.Component<Props, State> {
17
+ state: State;
16
18
  render(): JSX.Element;
17
19
  }
18
20
  declare const _default: import("react-redux").ConnectedComponent<typeof TwoPageKeypad, import("react-redux").Omit<React.ClassAttributes<TwoPageKeypad> & Props, "paginationEnabled">>;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import * as $Flowgen$Import$react_2d_redux from "react-redux";
8
8
  import * as React from "react";
9
+ import { TabbarItemType } from "../tabbar/types";
9
10
  declare interface ReduxProps {
10
11
  paginationEnabled: boolean;
11
12
  }
@@ -13,10 +14,11 @@ declare type Props = {
13
14
  leftPage: React.Node,
14
15
  rightPage: React.Node,
15
16
  } & ReduxProps;
16
- declare class TwoPageKeypad extends React.Component<Props> {
17
- state: {|
18
- selectedPage: string,
19
- |};
17
+ declare type State = {|
18
+ selectedPage: TabbarItemType,
19
+ |};
20
+ declare class TwoPageKeypad extends React.Component<Props, State> {
21
+ state: State;
20
22
  render(): React$Node;
21
23
  }
22
24
  declare var _default: $Flowgen$Import$react_2d_redux.ConnectedComponent<
@@ -1,14 +1,11 @@
1
+ import { StyleType } from "@khanacademy/wonder-blocks-core";
1
2
  import * as React from "react";
2
- import type { TabbarItemType } from "./types";
3
- type TabbarState = {
4
- selectedItem: number;
5
- };
3
+ import { TabbarItemType } from "./types";
6
4
  type Props = {
7
5
  items: ReadonlyArray<TabbarItemType>;
8
- onSelect: (item: TabbarItemType) => void;
6
+ selectedItem: TabbarItemType;
7
+ onSelectItem: (item: TabbarItemType) => void;
8
+ style?: StyleType;
9
9
  };
10
- declare class Tabbar extends React.Component<Props, TabbarState> {
11
- state: TabbarState;
12
- render(): React.ReactNode;
13
- }
10
+ declare function Tabbar(props: Props): React.ReactElement;
14
11
  export default Tabbar;