@khanacademy/math-input 14.2.0 → 14.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/es/index.js +18 -19
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/aphrodite-css-transition-group/transition-child.tsx +2 -1
- package/src/components/keypad/keypad-pages/keypad-pages.stories.tsx +9 -2
- package/src/components/keypad/keypad.tsx +2 -2
- package/src/components/keypad/navigation-pad.stories.tsx +2 -1
- package/src/components/keypad-context.tsx +25 -16
- package/src/components/keypad-legacy/text-icon.tsx +1 -1
- package/src/full-keypad.stories.tsx +7 -1
- package/tsconfig-build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Khan Academy's new expression editor for the mobile web.",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "14.2.
|
|
6
|
+
"version": "14.2.2",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"source": "src/index.ts",
|
|
21
21
|
"scripts": {},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@khanacademy/perseus-core": "1.
|
|
23
|
+
"@khanacademy/perseus-core": "1.3.0",
|
|
24
24
|
"mathquill": "git+https://git@github.com/Khan/mathquill.git#48410e80d760bbd5105544d4a4ab459a28dc2cbc",
|
|
25
25
|
"performance-now": "^0.2.0"
|
|
26
26
|
},
|
|
@@ -155,7 +155,8 @@ class TransitionChild extends React.Component<ChildProps, ChildState> {
|
|
|
155
155
|
|
|
156
156
|
queueClass(removeClassName: string, addClassName: string) {
|
|
157
157
|
this.classNameQueue.push([removeClassName, addClassName]);
|
|
158
|
-
|
|
158
|
+
// Queue operation for after the next paint.
|
|
159
|
+
this.props.schedule.timeout(this.flushClassNameQueue, 0);
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
flushClassNameQueue = () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {action} from "@storybook/addon-actions";
|
|
2
2
|
import {withKnobs} from "@storybook/addon-knobs";
|
|
3
|
+
import {INITIAL_VIEWPORTS} from "@storybook/addon-viewport";
|
|
3
4
|
import * as React from "react";
|
|
4
5
|
|
|
5
6
|
import GeometryInputPage from "./geometry-page";
|
|
@@ -13,7 +14,7 @@ export default {
|
|
|
13
14
|
backgrounds: {
|
|
14
15
|
values: [{name: "light background", value: "white", default: true}],
|
|
15
16
|
},
|
|
16
|
-
viewport: {defaultViewport: "iphone6"},
|
|
17
|
+
viewport: {defaultViewport: "iphone6", viewports: INITIAL_VIEWPORTS},
|
|
17
18
|
},
|
|
18
19
|
};
|
|
19
20
|
|
|
@@ -22,7 +23,13 @@ export const NumericInput = (): React.ReactElement => (
|
|
|
22
23
|
);
|
|
23
24
|
|
|
24
25
|
export const PreAlgebraInput = (): React.ReactElement => (
|
|
25
|
-
<PrealgebraInputPage
|
|
26
|
+
<PrealgebraInputPage
|
|
27
|
+
onClickKey={action("onClickKey")}
|
|
28
|
+
preAlgebra={true}
|
|
29
|
+
logarithms={true}
|
|
30
|
+
basicRelations={true}
|
|
31
|
+
advancedRelations={true}
|
|
32
|
+
/>
|
|
26
33
|
);
|
|
27
34
|
|
|
28
35
|
export const TrigonometryInput = (): React.ReactElement => (
|
|
@@ -74,7 +74,7 @@ function getAvailableTabs(props: Props): ReadonlyArray<KeypadPageType> {
|
|
|
74
74
|
// The main (v2) Keypad. Use this component to present an accessible, onscreen
|
|
75
75
|
// keypad to learners for entering math expressions.
|
|
76
76
|
export default function Keypad(props: Props) {
|
|
77
|
-
// If we're using the Fractions
|
|
77
|
+
// If we're using the Fractions keypad, we want to default select that page
|
|
78
78
|
// Otherwise, we want to default to the Numbers page
|
|
79
79
|
const defaultSelectedPage = props.fractionsOnly ? "Fractions" : "Numbers";
|
|
80
80
|
const [selectedPage, setSelectedPage] =
|
|
@@ -105,7 +105,7 @@ export default function Keypad(props: Props) {
|
|
|
105
105
|
? styles.fractionsGrid
|
|
106
106
|
: styles.expressionGrid;
|
|
107
107
|
|
|
108
|
-
// This
|
|
108
|
+
// This useEffect is only used to ensure that we can test the keypad in storybook
|
|
109
109
|
useEffect(() => {
|
|
110
110
|
setSelectedPage(defaultSelectedPage);
|
|
111
111
|
}, [fractionsOnly, defaultSelectedPage]);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {action} from "@storybook/addon-actions";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
|
|
3
4
|
import NavigationPad from "./navigation-pad";
|
|
@@ -19,7 +20,7 @@ export default {
|
|
|
19
20
|
export function basic() {
|
|
20
21
|
return (
|
|
21
22
|
<div style={{padding: 50}}>
|
|
22
|
-
<NavigationPad onClickKey={()
|
|
23
|
+
<NavigationPad onClickKey={action("onClickKey")} />
|
|
23
24
|
</div>
|
|
24
25
|
);
|
|
25
26
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Perseus Renderers (Server/Item/Article)
|
|
9
9
|
*/
|
|
10
10
|
import * as React from "react";
|
|
11
|
-
import {useState} from "react";
|
|
11
|
+
import {useState, useMemo} from "react";
|
|
12
12
|
|
|
13
13
|
import type {KeypadAPI, KeypadContextType} from "../types";
|
|
14
14
|
import type {KeypadContextRendererInterface} from "@khanacademy/perseus-core";
|
|
@@ -39,22 +39,31 @@ export function StatefulKeypadContextProvider(props: Props) {
|
|
|
39
39
|
const [scrollableElement, setScrollableElement] =
|
|
40
40
|
useState<HTMLElement | null>();
|
|
41
41
|
|
|
42
|
+
const memoizedValue = useMemo(
|
|
43
|
+
() => ({
|
|
44
|
+
keypadActive,
|
|
45
|
+
setKeypadActive,
|
|
46
|
+
keypadElement,
|
|
47
|
+
setKeypadElement,
|
|
48
|
+
renderer,
|
|
49
|
+
setRenderer,
|
|
50
|
+
scrollableElement,
|
|
51
|
+
setScrollableElement,
|
|
52
|
+
}),
|
|
53
|
+
[
|
|
54
|
+
keypadActive,
|
|
55
|
+
setKeypadActive,
|
|
56
|
+
keypadElement,
|
|
57
|
+
setKeypadElement,
|
|
58
|
+
renderer,
|
|
59
|
+
setRenderer,
|
|
60
|
+
scrollableElement,
|
|
61
|
+
setScrollableElement,
|
|
62
|
+
],
|
|
63
|
+
);
|
|
64
|
+
|
|
42
65
|
return (
|
|
43
|
-
<KeypadContext.Provider
|
|
44
|
-
value={{
|
|
45
|
-
setKeypadActive,
|
|
46
|
-
keypadActive,
|
|
47
|
-
setKeypadElement,
|
|
48
|
-
keypadElement,
|
|
49
|
-
setRenderer,
|
|
50
|
-
renderer,
|
|
51
|
-
// The scrollableElement options can likely be removed after
|
|
52
|
-
// the exercises-package is officially deprecated. They don't appear
|
|
53
|
-
// to be used anywhere except for the exercises-package and tests.
|
|
54
|
-
setScrollableElement,
|
|
55
|
-
scrollableElement,
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
66
|
+
<KeypadContext.Provider value={memoizedValue}>
|
|
58
67
|
{props.children}
|
|
59
68
|
</KeypadContext.Provider>
|
|
60
69
|
);
|
|
@@ -87,7 +87,13 @@ export default {
|
|
|
87
87
|
|
|
88
88
|
const Template: ComponentStory<typeof Keypad> = (
|
|
89
89
|
args: PropsFor<typeof Keypad>,
|
|
90
|
-
): React.ReactElement =>
|
|
90
|
+
): React.ReactElement => (
|
|
91
|
+
<Keypad
|
|
92
|
+
{...args}
|
|
93
|
+
onClickKey={action("onClickKey")}
|
|
94
|
+
onAnalyticsEvent={async (e) => action("onAnalyticsEvent")(e)}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
91
97
|
|
|
92
98
|
export const Default = Template.bind({});
|
|
93
99
|
|