@khanacademy/math-input 16.5.1 → 17.0.1
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 +12 -0
- package/dist/components/input/math-wrapper.d.ts +3 -2
- package/dist/components/input/mathquill-helpers.d.ts +3 -4
- package/dist/components/input/mathquill-instance.d.ts +2 -2
- package/dist/components/input/mathquill-types.d.ts +4 -290
- package/dist/es/index.css +209 -104
- package/dist/es/index.js +67 -86
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +209 -104
- package/dist/index.js +67 -86
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/__tests__/integration.test.tsx +25 -13
- package/src/components/input/__tests__/mathquill.test.ts +37 -35
- package/src/components/input/__tests__/test-math-wrapper.ts +1 -2
- package/src/components/input/math-input.tsx +3 -18
- package/src/components/input/math-wrapper.ts +9 -16
- package/src/components/input/mathquill-helpers.ts +15 -26
- package/src/components/input/mathquill-instance.ts +71 -71
- package/src/components/input/mathquill-types.ts +4 -334
- package/src/components/key-handlers/handle-arrow.ts +1 -2
- package/src/components/key-handlers/handle-backspace.ts +6 -7
- package/src/components/key-handlers/handle-exponent.ts +1 -2
- package/src/components/key-handlers/handle-jump-out.ts +1 -2
- package/src/components/key-handlers/key-translator.ts +1 -1
- package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +34 -34
- package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +11 -5
- package/src/components/keypad/keypad-mathquill.stories.tsx +1 -1
- package/src/components/keypad/shared-keys.tsx +6 -6
- package/src/full-keypad.stories.tsx +14 -0
- package/tsconfig-build.tsbuildinfo +1 -1
|
@@ -594,12 +594,12 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
594
594
|
</button>
|
|
595
595
|
</div>
|
|
596
596
|
<div
|
|
597
|
-
class="default_xu2jcg-o_O-
|
|
598
|
-
data-test-id="
|
|
597
|
+
class="default_xu2jcg-o_O-inlineStyles_771h91"
|
|
598
|
+
data-test-id="FRAC"
|
|
599
599
|
>
|
|
600
600
|
<button
|
|
601
601
|
aria-disabled="false"
|
|
602
|
-
aria-label="
|
|
602
|
+
aria-label="Fraction, excluding the current expression"
|
|
603
603
|
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4-o_O-clickable_rukhmf"
|
|
604
604
|
type="button"
|
|
605
605
|
>
|
|
@@ -618,13 +618,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
618
618
|
>
|
|
619
619
|
<path
|
|
620
620
|
clip-rule="evenodd"
|
|
621
|
-
d="
|
|
622
|
-
fill="#21242C"
|
|
623
|
-
fill-rule="evenodd"
|
|
624
|
-
/>
|
|
625
|
-
<path
|
|
626
|
-
clip-rule="evenodd"
|
|
627
|
-
d="M20 28c-.5523 0-1-.4477-1-1V13c0-.5523.4477-1 1-1s1 .4477 1 1v14c0 .5523-.4477 1-1 1z"
|
|
621
|
+
d="M16 10C16 9.44772 16.4477 9 17 9H23C23.5523 9 24 9.44772 24 10V16C24 16.5523 23.5523 17 23 17H17C16.4477 17 16 16.5523 16 16V10ZM18 11H22V15H18V11ZM14 20C14 19.4477 14.4477 19 15 19H25C25.5523 19 26 19.4477 26 20C26 20.5523 25.5523 21 25 21H15C14.4477 21 14 20.5523 14 20ZM17 23C16.4477 23 16 23.4477 16 24V30C16 30.5523 16.4477 31 17 31H23C23.5523 31 24 30.5523 24 30V24C24 23.4477 23.5523 23 23 23H17ZM22 25H18V29H22V25Z"
|
|
628
622
|
fill="#21242C"
|
|
629
623
|
fill-rule="evenodd"
|
|
630
624
|
/>
|
|
@@ -634,12 +628,12 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
634
628
|
</button>
|
|
635
629
|
</div>
|
|
636
630
|
<div
|
|
637
|
-
class="default_xu2jcg-o_O-
|
|
638
|
-
data-test-id="
|
|
631
|
+
class="default_xu2jcg-o_O-inlineStyles_wb5o9j"
|
|
632
|
+
data-test-id="PLUS"
|
|
639
633
|
>
|
|
640
634
|
<button
|
|
641
635
|
aria-disabled="false"
|
|
642
|
-
aria-label="
|
|
636
|
+
aria-label="Plus"
|
|
643
637
|
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4-o_O-clickable_rukhmf"
|
|
644
638
|
type="button"
|
|
645
639
|
>
|
|
@@ -662,18 +656,24 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
662
656
|
fill="#21242C"
|
|
663
657
|
fill-rule="evenodd"
|
|
664
658
|
/>
|
|
659
|
+
<path
|
|
660
|
+
clip-rule="evenodd"
|
|
661
|
+
d="M20 28c-.5523 0-1-.4477-1-1V13c0-.5523.4477-1 1-1s1 .4477 1 1v14c0 .5523-.4477 1-1 1z"
|
|
662
|
+
fill="#21242C"
|
|
663
|
+
fill-rule="evenodd"
|
|
664
|
+
/>
|
|
665
665
|
</svg>
|
|
666
666
|
</div>
|
|
667
667
|
</div>
|
|
668
668
|
</button>
|
|
669
669
|
</div>
|
|
670
670
|
<div
|
|
671
|
-
class="default_xu2jcg-o_O-
|
|
672
|
-
data-test-id="
|
|
671
|
+
class="default_xu2jcg-o_O-inlineStyles_9isr9w"
|
|
672
|
+
data-test-id="MINUS"
|
|
673
673
|
>
|
|
674
674
|
<button
|
|
675
675
|
aria-disabled="false"
|
|
676
|
-
aria-label="
|
|
676
|
+
aria-label="Minus"
|
|
677
677
|
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4-o_O-clickable_rukhmf"
|
|
678
678
|
type="button"
|
|
679
679
|
>
|
|
@@ -692,7 +692,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
692
692
|
>
|
|
693
693
|
<path
|
|
694
694
|
clip-rule="evenodd"
|
|
695
|
-
d="
|
|
695
|
+
d="M12 20c0-.5523.4477-1 1-1h14c.5523 0 1 .4477 1 1s-.4477 1-1 1H13c-.5523 0-1-.4477-1-1z"
|
|
696
696
|
fill="#21242C"
|
|
697
697
|
fill-rule="evenodd"
|
|
698
698
|
/>
|
|
@@ -1647,12 +1647,12 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1647
1647
|
</button>
|
|
1648
1648
|
</div>
|
|
1649
1649
|
<div
|
|
1650
|
-
class="default_xu2jcg-o_O-
|
|
1651
|
-
data-test-id="
|
|
1650
|
+
class="default_xu2jcg-o_O-inlineStyles_771h91"
|
|
1651
|
+
data-test-id="FRAC"
|
|
1652
1652
|
>
|
|
1653
1653
|
<button
|
|
1654
1654
|
aria-disabled="false"
|
|
1655
|
-
aria-label="
|
|
1655
|
+
aria-label="Fraction, excluding the current expression"
|
|
1656
1656
|
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4-o_O-clickable_rukhmf"
|
|
1657
1657
|
type="button"
|
|
1658
1658
|
>
|
|
@@ -1671,13 +1671,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1671
1671
|
>
|
|
1672
1672
|
<path
|
|
1673
1673
|
clip-rule="evenodd"
|
|
1674
|
-
d="
|
|
1675
|
-
fill="#21242C"
|
|
1676
|
-
fill-rule="evenodd"
|
|
1677
|
-
/>
|
|
1678
|
-
<path
|
|
1679
|
-
clip-rule="evenodd"
|
|
1680
|
-
d="M20 28c-.5523 0-1-.4477-1-1V13c0-.5523.4477-1 1-1s1 .4477 1 1v14c0 .5523-.4477 1-1 1z"
|
|
1674
|
+
d="M16 10C16 9.44772 16.4477 9 17 9H23C23.5523 9 24 9.44772 24 10V16C24 16.5523 23.5523 17 23 17H17C16.4477 17 16 16.5523 16 16V10ZM18 11H22V15H18V11ZM14 20C14 19.4477 14.4477 19 15 19H25C25.5523 19 26 19.4477 26 20C26 20.5523 25.5523 21 25 21H15C14.4477 21 14 20.5523 14 20ZM17 23C16.4477 23 16 23.4477 16 24V30C16 30.5523 16.4477 31 17 31H23C23.5523 31 24 30.5523 24 30V24C24 23.4477 23.5523 23 23 23H17ZM22 25H18V29H22V25Z"
|
|
1681
1675
|
fill="#21242C"
|
|
1682
1676
|
fill-rule="evenodd"
|
|
1683
1677
|
/>
|
|
@@ -1687,12 +1681,12 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1687
1681
|
</button>
|
|
1688
1682
|
</div>
|
|
1689
1683
|
<div
|
|
1690
|
-
class="default_xu2jcg-o_O-
|
|
1691
|
-
data-test-id="
|
|
1684
|
+
class="default_xu2jcg-o_O-inlineStyles_wb5o9j"
|
|
1685
|
+
data-test-id="PLUS"
|
|
1692
1686
|
>
|
|
1693
1687
|
<button
|
|
1694
1688
|
aria-disabled="false"
|
|
1695
|
-
aria-label="
|
|
1689
|
+
aria-label="Plus"
|
|
1696
1690
|
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4-o_O-clickable_rukhmf"
|
|
1697
1691
|
type="button"
|
|
1698
1692
|
>
|
|
@@ -1715,18 +1709,24 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1715
1709
|
fill="#21242C"
|
|
1716
1710
|
fill-rule="evenodd"
|
|
1717
1711
|
/>
|
|
1712
|
+
<path
|
|
1713
|
+
clip-rule="evenodd"
|
|
1714
|
+
d="M20 28c-.5523 0-1-.4477-1-1V13c0-.5523.4477-1 1-1s1 .4477 1 1v14c0 .5523-.4477 1-1 1z"
|
|
1715
|
+
fill="#21242C"
|
|
1716
|
+
fill-rule="evenodd"
|
|
1717
|
+
/>
|
|
1718
1718
|
</svg>
|
|
1719
1719
|
</div>
|
|
1720
1720
|
</div>
|
|
1721
1721
|
</button>
|
|
1722
1722
|
</div>
|
|
1723
1723
|
<div
|
|
1724
|
-
class="default_xu2jcg-o_O-
|
|
1725
|
-
data-test-id="
|
|
1724
|
+
class="default_xu2jcg-o_O-inlineStyles_9isr9w"
|
|
1725
|
+
data-test-id="MINUS"
|
|
1726
1726
|
>
|
|
1727
1727
|
<button
|
|
1728
1728
|
aria-disabled="false"
|
|
1729
|
-
aria-label="
|
|
1729
|
+
aria-label="Minus"
|
|
1730
1730
|
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4-o_O-clickable_rukhmf"
|
|
1731
1731
|
type="button"
|
|
1732
1732
|
>
|
|
@@ -1745,7 +1745,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1745
1745
|
>
|
|
1746
1746
|
<path
|
|
1747
1747
|
clip-rule="evenodd"
|
|
1748
|
-
d="
|
|
1748
|
+
d="M12 20c0-.5523.4477-1 1-1h14c.5523 0 1 .4477 1 1s-.4477 1-1 1H13c-.5523 0-1-.4477-1-1z"
|
|
1749
1749
|
fill="#21242C"
|
|
1750
1750
|
fill-rule="evenodd"
|
|
1751
1751
|
/>
|
|
@@ -140,7 +140,9 @@ describe("Keypad v2 with MathQuill", () => {
|
|
|
140
140
|
userEvent.click(screen.getByRole("button", {name: "Square"}));
|
|
141
141
|
|
|
142
142
|
// Assert
|
|
143
|
-
expect(mockMathInputCallback).toHaveBeenLastCalledWith(
|
|
143
|
+
expect(mockMathInputCallback).toHaveBeenLastCalledWith(
|
|
144
|
+
"a^{2}+b^{2}=c^{2}",
|
|
145
|
+
);
|
|
144
146
|
});
|
|
145
147
|
|
|
146
148
|
it("can write the Pythagorean theorem (complex)", () => {
|
|
@@ -177,7 +179,7 @@ describe("Keypad v2 with MathQuill", () => {
|
|
|
177
179
|
|
|
178
180
|
// Assert
|
|
179
181
|
expect(mockMathInputCallback).toHaveBeenLastCalledWith(
|
|
180
|
-
"c=\\sqrt{a^2+b^2}",
|
|
182
|
+
"c=\\sqrt{a^{2}+b^{2}}",
|
|
181
183
|
);
|
|
182
184
|
});
|
|
183
185
|
|
|
@@ -202,10 +204,12 @@ describe("Keypad v2 with MathQuill", () => {
|
|
|
202
204
|
userEvent.click(screen.getByRole("button", {name: "b"}));
|
|
203
205
|
userEvent.click(screen.getByRole("tab", {name: "Operators"}));
|
|
204
206
|
userEvent.click(screen.getByRole("button", {name: "Square"}));
|
|
205
|
-
userEvent.type(screen.getByRole("textbox"), "=c^2");
|
|
207
|
+
userEvent.type(screen.getByRole("textbox"), "=c^{2}");
|
|
206
208
|
|
|
207
209
|
// Assert
|
|
208
|
-
expect(mockMathInputCallback).toHaveBeenLastCalledWith(
|
|
210
|
+
expect(mockMathInputCallback).toHaveBeenLastCalledWith(
|
|
211
|
+
"a^{2}+b^{2}=c^{2}",
|
|
212
|
+
);
|
|
209
213
|
});
|
|
210
214
|
|
|
211
215
|
it("deletes from the input using the backspace button", () => {
|
|
@@ -242,7 +246,9 @@ describe("Keypad v2 with MathQuill", () => {
|
|
|
242
246
|
|
|
243
247
|
// Assert
|
|
244
248
|
// make sure the formula was typed correctly
|
|
245
|
-
expect(mockMathInputCallback).toHaveBeenLastCalledWith(
|
|
249
|
+
expect(mockMathInputCallback).toHaveBeenLastCalledWith(
|
|
250
|
+
"a^{2}+b^{2}=c^{2}",
|
|
251
|
+
);
|
|
246
252
|
|
|
247
253
|
userEvent.click(screen.getByRole("tab", {name: "Numbers"}));
|
|
248
254
|
// delete: need 14 backspaces in MathQuill to delete `a^2+b^2=c^2`
|
|
@@ -37,21 +37,21 @@ export default function SharedKeys(props: Props) {
|
|
|
37
37
|
return (
|
|
38
38
|
<>
|
|
39
39
|
<KeypadButton
|
|
40
|
-
keyConfig={Keys.
|
|
40
|
+
keyConfig={Keys.FRAC}
|
|
41
41
|
onClickKey={onClickKey}
|
|
42
|
-
coord={
|
|
42
|
+
coord={fractionCoord}
|
|
43
43
|
secondary
|
|
44
44
|
/>
|
|
45
45
|
<KeypadButton
|
|
46
|
-
keyConfig={Keys.
|
|
46
|
+
keyConfig={Keys.PLUS}
|
|
47
47
|
onClickKey={onClickKey}
|
|
48
|
-
coord={[
|
|
48
|
+
coord={[4, 0]}
|
|
49
49
|
secondary
|
|
50
50
|
/>
|
|
51
51
|
<KeypadButton
|
|
52
|
-
keyConfig={Keys.
|
|
52
|
+
keyConfig={Keys.MINUS}
|
|
53
53
|
onClickKey={onClickKey}
|
|
54
|
-
coord={
|
|
54
|
+
coord={[5, 0]}
|
|
55
55
|
secondary
|
|
56
56
|
/>
|
|
57
57
|
|
|
@@ -126,3 +126,17 @@ Everything.args = {
|
|
|
126
126
|
showDismiss: true,
|
|
127
127
|
extraKeys: ["a", "b", "c"],
|
|
128
128
|
};
|
|
129
|
+
|
|
130
|
+
export const EverythingMinusNavigationPad = Template.bind({});
|
|
131
|
+
EverythingMinusNavigationPad.args = {
|
|
132
|
+
advancedRelations: true,
|
|
133
|
+
basicRelations: true,
|
|
134
|
+
divisionKey: true,
|
|
135
|
+
logarithms: true,
|
|
136
|
+
convertDotToTimes: false,
|
|
137
|
+
preAlgebra: true,
|
|
138
|
+
trigonometry: true,
|
|
139
|
+
expandedView: false,
|
|
140
|
+
showDismiss: true,
|
|
141
|
+
extraKeys: ["a", "b", "c"],
|
|
142
|
+
};
|