@khanacademy/math-input 12.1.1 → 13.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.
- package/CHANGELOG.md +11 -0
- package/dist/components/keypad/keypad.d.ts +1 -1
- package/dist/components/keypad/mobile-keypad.d.ts +1 -0
- package/dist/components/keypad/shared-keys.d.ts +1 -1
- package/dist/es/index.js +28 -8
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +84 -26
- package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +1 -1
- package/src/components/keypad/__tests__/keypad.test.tsx +30 -0
- package/src/components/keypad/keypad-button.tsx +3 -0
- package/src/components/keypad/keypad-mathquill.stories.tsx +1 -1
- package/src/components/keypad/keypad.stories.tsx +2 -2
- package/src/components/keypad/keypad.tsx +3 -3
- package/src/components/keypad/mobile-keypad.tsx +20 -3
- package/src/components/keypad/shared-keys.tsx +4 -4
- package/src/full-math-input.stories.tsx +14 -2
- package/src/index.ts +1 -1
- package/src/types.ts +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -175,6 +175,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
175
175
|
>
|
|
176
176
|
<div
|
|
177
177
|
class="default_xu2jcg-o_O-inlineStyles_1c2q4k1"
|
|
178
|
+
data-test-id="NUM_1"
|
|
178
179
|
>
|
|
179
180
|
<button
|
|
180
181
|
aria-disabled="false"
|
|
@@ -206,6 +207,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
206
207
|
</div>
|
|
207
208
|
<div
|
|
208
209
|
class="default_xu2jcg-o_O-inlineStyles_4h080i"
|
|
210
|
+
data-test-id="NUM_2"
|
|
209
211
|
>
|
|
210
212
|
<button
|
|
211
213
|
aria-disabled="false"
|
|
@@ -237,6 +239,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
237
239
|
</div>
|
|
238
240
|
<div
|
|
239
241
|
class="default_xu2jcg-o_O-inlineStyles_ei5lhv"
|
|
242
|
+
data-test-id="NUM_3"
|
|
240
243
|
>
|
|
241
244
|
<button
|
|
242
245
|
aria-disabled="false"
|
|
@@ -268,6 +271,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
268
271
|
</div>
|
|
269
272
|
<div
|
|
270
273
|
class="default_xu2jcg-o_O-inlineStyles_1drshe8"
|
|
274
|
+
data-test-id="NUM_4"
|
|
271
275
|
>
|
|
272
276
|
<button
|
|
273
277
|
aria-disabled="false"
|
|
@@ -299,6 +303,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
299
303
|
</div>
|
|
300
304
|
<div
|
|
301
305
|
class="default_xu2jcg-o_O-inlineStyles_1j1cer"
|
|
306
|
+
data-test-id="NUM_5"
|
|
302
307
|
>
|
|
303
308
|
<button
|
|
304
309
|
aria-disabled="false"
|
|
@@ -330,6 +335,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
330
335
|
</div>
|
|
331
336
|
<div
|
|
332
337
|
class="default_xu2jcg-o_O-inlineStyles_1qj00wi"
|
|
338
|
+
data-test-id="NUM_6"
|
|
333
339
|
>
|
|
334
340
|
<button
|
|
335
341
|
aria-disabled="false"
|
|
@@ -361,6 +367,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
361
367
|
</div>
|
|
362
368
|
<div
|
|
363
369
|
class="default_xu2jcg-o_O-inlineStyles_1o7q2hf"
|
|
370
|
+
data-test-id="NUM_7"
|
|
364
371
|
>
|
|
365
372
|
<button
|
|
366
373
|
aria-disabled="false"
|
|
@@ -392,6 +399,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
392
399
|
</div>
|
|
393
400
|
<div
|
|
394
401
|
class="default_xu2jcg-o_O-inlineStyles_11fd5hs"
|
|
402
|
+
data-test-id="NUM_8"
|
|
395
403
|
>
|
|
396
404
|
<button
|
|
397
405
|
aria-disabled="false"
|
|
@@ -423,6 +431,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
423
431
|
</div>
|
|
424
432
|
<div
|
|
425
433
|
class="default_xu2jcg-o_O-inlineStyles_mr6jkh"
|
|
434
|
+
data-test-id="NUM_9"
|
|
426
435
|
>
|
|
427
436
|
<button
|
|
428
437
|
aria-disabled="false"
|
|
@@ -454,6 +463,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
454
463
|
</div>
|
|
455
464
|
<div
|
|
456
465
|
class="default_xu2jcg-o_O-inlineStyles_xra0eu"
|
|
466
|
+
data-test-id="NUM_0"
|
|
457
467
|
>
|
|
458
468
|
<button
|
|
459
469
|
aria-disabled="false"
|
|
@@ -485,6 +495,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
485
495
|
</div>
|
|
486
496
|
<div
|
|
487
497
|
class="default_xu2jcg-o_O-inlineStyles_6bvuz9"
|
|
498
|
+
data-test-id="DECIMAL"
|
|
488
499
|
>
|
|
489
500
|
<button
|
|
490
501
|
aria-disabled="false"
|
|
@@ -516,6 +527,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
516
527
|
</div>
|
|
517
528
|
<div
|
|
518
529
|
class="default_xu2jcg-o_O-inlineStyles_l02gwk"
|
|
530
|
+
data-test-id="NEGATIVE"
|
|
519
531
|
>
|
|
520
532
|
<button
|
|
521
533
|
aria-disabled="false"
|
|
@@ -549,6 +561,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
549
561
|
</div>
|
|
550
562
|
<div
|
|
551
563
|
class="default_xu2jcg-o_O-inlineStyles_ma0as6"
|
|
564
|
+
data-test-id="PERCENT"
|
|
552
565
|
>
|
|
553
566
|
<button
|
|
554
567
|
aria-disabled="false"
|
|
@@ -582,6 +595,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
582
595
|
</div>
|
|
583
596
|
<div
|
|
584
597
|
class="default_xu2jcg-o_O-inlineStyles_wb5o9j"
|
|
598
|
+
data-test-id="PLUS"
|
|
585
599
|
>
|
|
586
600
|
<button
|
|
587
601
|
aria-disabled="false"
|
|
@@ -621,6 +635,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
621
635
|
</div>
|
|
622
636
|
<div
|
|
623
637
|
class="default_xu2jcg-o_O-inlineStyles_9isr9w"
|
|
638
|
+
data-test-id="MINUS"
|
|
624
639
|
>
|
|
625
640
|
<button
|
|
626
641
|
aria-disabled="false"
|
|
@@ -654,10 +669,11 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
654
669
|
</div>
|
|
655
670
|
<div
|
|
656
671
|
class="default_xu2jcg-o_O-inlineStyles_771h91"
|
|
672
|
+
data-test-id="FRAC"
|
|
657
673
|
>
|
|
658
674
|
<button
|
|
659
675
|
aria-disabled="false"
|
|
660
|
-
aria-label="Fraction,
|
|
676
|
+
aria-label="Fraction, excluding the current expression"
|
|
661
677
|
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4-o_O-clickable_rukhmf"
|
|
662
678
|
type="button"
|
|
663
679
|
>
|
|
@@ -687,6 +703,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
687
703
|
</div>
|
|
688
704
|
<div
|
|
689
705
|
class="default_xu2jcg-o_O-inlineStyles_lv836c"
|
|
706
|
+
data-test-id="CDOT"
|
|
690
707
|
>
|
|
691
708
|
<button
|
|
692
709
|
aria-disabled="false"
|
|
@@ -707,18 +724,27 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
707
724
|
width="40"
|
|
708
725
|
xmlns="http://www.w3.org/2000/svg"
|
|
709
726
|
>
|
|
710
|
-
<
|
|
711
|
-
clip-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
727
|
+
<g
|
|
728
|
+
clip-path="url(#clip0_874_41555)"
|
|
729
|
+
>
|
|
730
|
+
<circle
|
|
731
|
+
cx="20"
|
|
732
|
+
cy="20"
|
|
733
|
+
fill="#21242C"
|
|
734
|
+
r="1.5"
|
|
735
|
+
/>
|
|
736
|
+
</g>
|
|
737
|
+
<defs>
|
|
738
|
+
<clippath
|
|
739
|
+
id="clip0_874_41555"
|
|
740
|
+
>
|
|
741
|
+
<path
|
|
742
|
+
d="M0 0h3v3H0z"
|
|
743
|
+
fill="#fff"
|
|
744
|
+
transform="translate(18.5 18.5)"
|
|
745
|
+
/>
|
|
746
|
+
</clippath>
|
|
747
|
+
</defs>
|
|
722
748
|
</svg>
|
|
723
749
|
</div>
|
|
724
750
|
</div>
|
|
@@ -726,6 +752,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
726
752
|
</div>
|
|
727
753
|
<div
|
|
728
754
|
class="default_xu2jcg-o_O-inlineStyles_k65qc5"
|
|
755
|
+
data-test-id="LEFT_PAREN"
|
|
729
756
|
>
|
|
730
757
|
<button
|
|
731
758
|
aria-disabled="false"
|
|
@@ -759,6 +786,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
759
786
|
</div>
|
|
760
787
|
<div
|
|
761
788
|
class="default_xu2jcg-o_O-inlineStyles_1bljvrq"
|
|
789
|
+
data-test-id="RIGHT_PAREN"
|
|
762
790
|
>
|
|
763
791
|
<button
|
|
764
792
|
aria-disabled="false"
|
|
@@ -792,6 +820,7 @@ exports[`keypad should snapshot expanded: first render 1`] = `
|
|
|
792
820
|
</div>
|
|
793
821
|
<div
|
|
794
822
|
class="default_xu2jcg-o_O-inlineStyles_y8g975"
|
|
823
|
+
data-test-id="BACKSPACE"
|
|
795
824
|
>
|
|
796
825
|
<button
|
|
797
826
|
aria-disabled="false"
|
|
@@ -1199,6 +1228,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1199
1228
|
>
|
|
1200
1229
|
<div
|
|
1201
1230
|
class="default_xu2jcg-o_O-inlineStyles_1c2q4k1"
|
|
1231
|
+
data-test-id="NUM_1"
|
|
1202
1232
|
>
|
|
1203
1233
|
<button
|
|
1204
1234
|
aria-disabled="false"
|
|
@@ -1230,6 +1260,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1230
1260
|
</div>
|
|
1231
1261
|
<div
|
|
1232
1262
|
class="default_xu2jcg-o_O-inlineStyles_4h080i"
|
|
1263
|
+
data-test-id="NUM_2"
|
|
1233
1264
|
>
|
|
1234
1265
|
<button
|
|
1235
1266
|
aria-disabled="false"
|
|
@@ -1261,6 +1292,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1261
1292
|
</div>
|
|
1262
1293
|
<div
|
|
1263
1294
|
class="default_xu2jcg-o_O-inlineStyles_ei5lhv"
|
|
1295
|
+
data-test-id="NUM_3"
|
|
1264
1296
|
>
|
|
1265
1297
|
<button
|
|
1266
1298
|
aria-disabled="false"
|
|
@@ -1292,6 +1324,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1292
1324
|
</div>
|
|
1293
1325
|
<div
|
|
1294
1326
|
class="default_xu2jcg-o_O-inlineStyles_1drshe8"
|
|
1327
|
+
data-test-id="NUM_4"
|
|
1295
1328
|
>
|
|
1296
1329
|
<button
|
|
1297
1330
|
aria-disabled="false"
|
|
@@ -1323,6 +1356,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1323
1356
|
</div>
|
|
1324
1357
|
<div
|
|
1325
1358
|
class="default_xu2jcg-o_O-inlineStyles_1j1cer"
|
|
1359
|
+
data-test-id="NUM_5"
|
|
1326
1360
|
>
|
|
1327
1361
|
<button
|
|
1328
1362
|
aria-disabled="false"
|
|
@@ -1354,6 +1388,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1354
1388
|
</div>
|
|
1355
1389
|
<div
|
|
1356
1390
|
class="default_xu2jcg-o_O-inlineStyles_1qj00wi"
|
|
1391
|
+
data-test-id="NUM_6"
|
|
1357
1392
|
>
|
|
1358
1393
|
<button
|
|
1359
1394
|
aria-disabled="false"
|
|
@@ -1385,6 +1420,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1385
1420
|
</div>
|
|
1386
1421
|
<div
|
|
1387
1422
|
class="default_xu2jcg-o_O-inlineStyles_1o7q2hf"
|
|
1423
|
+
data-test-id="NUM_7"
|
|
1388
1424
|
>
|
|
1389
1425
|
<button
|
|
1390
1426
|
aria-disabled="false"
|
|
@@ -1416,6 +1452,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1416
1452
|
</div>
|
|
1417
1453
|
<div
|
|
1418
1454
|
class="default_xu2jcg-o_O-inlineStyles_11fd5hs"
|
|
1455
|
+
data-test-id="NUM_8"
|
|
1419
1456
|
>
|
|
1420
1457
|
<button
|
|
1421
1458
|
aria-disabled="false"
|
|
@@ -1447,6 +1484,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1447
1484
|
</div>
|
|
1448
1485
|
<div
|
|
1449
1486
|
class="default_xu2jcg-o_O-inlineStyles_mr6jkh"
|
|
1487
|
+
data-test-id="NUM_9"
|
|
1450
1488
|
>
|
|
1451
1489
|
<button
|
|
1452
1490
|
aria-disabled="false"
|
|
@@ -1478,6 +1516,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1478
1516
|
</div>
|
|
1479
1517
|
<div
|
|
1480
1518
|
class="default_xu2jcg-o_O-inlineStyles_xra0eu"
|
|
1519
|
+
data-test-id="NUM_0"
|
|
1481
1520
|
>
|
|
1482
1521
|
<button
|
|
1483
1522
|
aria-disabled="false"
|
|
@@ -1509,6 +1548,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1509
1548
|
</div>
|
|
1510
1549
|
<div
|
|
1511
1550
|
class="default_xu2jcg-o_O-inlineStyles_6bvuz9"
|
|
1551
|
+
data-test-id="DECIMAL"
|
|
1512
1552
|
>
|
|
1513
1553
|
<button
|
|
1514
1554
|
aria-disabled="false"
|
|
@@ -1540,6 +1580,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1540
1580
|
</div>
|
|
1541
1581
|
<div
|
|
1542
1582
|
class="default_xu2jcg-o_O-inlineStyles_l02gwk"
|
|
1583
|
+
data-test-id="NEGATIVE"
|
|
1543
1584
|
>
|
|
1544
1585
|
<button
|
|
1545
1586
|
aria-disabled="false"
|
|
@@ -1573,6 +1614,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1573
1614
|
</div>
|
|
1574
1615
|
<div
|
|
1575
1616
|
class="default_xu2jcg-o_O-inlineStyles_ma0as6"
|
|
1617
|
+
data-test-id="PERCENT"
|
|
1576
1618
|
>
|
|
1577
1619
|
<button
|
|
1578
1620
|
aria-disabled="false"
|
|
@@ -1606,6 +1648,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1606
1648
|
</div>
|
|
1607
1649
|
<div
|
|
1608
1650
|
class="default_xu2jcg-o_O-inlineStyles_wb5o9j"
|
|
1651
|
+
data-test-id="PLUS"
|
|
1609
1652
|
>
|
|
1610
1653
|
<button
|
|
1611
1654
|
aria-disabled="false"
|
|
@@ -1645,6 +1688,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1645
1688
|
</div>
|
|
1646
1689
|
<div
|
|
1647
1690
|
class="default_xu2jcg-o_O-inlineStyles_9isr9w"
|
|
1691
|
+
data-test-id="MINUS"
|
|
1648
1692
|
>
|
|
1649
1693
|
<button
|
|
1650
1694
|
aria-disabled="false"
|
|
@@ -1678,10 +1722,11 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1678
1722
|
</div>
|
|
1679
1723
|
<div
|
|
1680
1724
|
class="default_xu2jcg-o_O-inlineStyles_771h91"
|
|
1725
|
+
data-test-id="FRAC"
|
|
1681
1726
|
>
|
|
1682
1727
|
<button
|
|
1683
1728
|
aria-disabled="false"
|
|
1684
|
-
aria-label="Fraction,
|
|
1729
|
+
aria-label="Fraction, excluding the current expression"
|
|
1685
1730
|
class="button_vr44p2-o_O-reset_152ygtm-o_O-link_13xlah4-o_O-clickable_rukhmf"
|
|
1686
1731
|
type="button"
|
|
1687
1732
|
>
|
|
@@ -1711,6 +1756,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1711
1756
|
</div>
|
|
1712
1757
|
<div
|
|
1713
1758
|
class="default_xu2jcg-o_O-inlineStyles_lv836c"
|
|
1759
|
+
data-test-id="CDOT"
|
|
1714
1760
|
>
|
|
1715
1761
|
<button
|
|
1716
1762
|
aria-disabled="false"
|
|
@@ -1731,18 +1777,27 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1731
1777
|
width="40"
|
|
1732
1778
|
xmlns="http://www.w3.org/2000/svg"
|
|
1733
1779
|
>
|
|
1734
|
-
<
|
|
1735
|
-
clip-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1780
|
+
<g
|
|
1781
|
+
clip-path="url(#clip0_874_41555)"
|
|
1782
|
+
>
|
|
1783
|
+
<circle
|
|
1784
|
+
cx="20"
|
|
1785
|
+
cy="20"
|
|
1786
|
+
fill="#21242C"
|
|
1787
|
+
r="1.5"
|
|
1788
|
+
/>
|
|
1789
|
+
</g>
|
|
1790
|
+
<defs>
|
|
1791
|
+
<clippath
|
|
1792
|
+
id="clip0_874_41555"
|
|
1793
|
+
>
|
|
1794
|
+
<path
|
|
1795
|
+
d="M0 0h3v3H0z"
|
|
1796
|
+
fill="#fff"
|
|
1797
|
+
transform="translate(18.5 18.5)"
|
|
1798
|
+
/>
|
|
1799
|
+
</clippath>
|
|
1800
|
+
</defs>
|
|
1746
1801
|
</svg>
|
|
1747
1802
|
</div>
|
|
1748
1803
|
</div>
|
|
@@ -1750,6 +1805,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1750
1805
|
</div>
|
|
1751
1806
|
<div
|
|
1752
1807
|
class="default_xu2jcg-o_O-inlineStyles_k65qc5"
|
|
1808
|
+
data-test-id="LEFT_PAREN"
|
|
1753
1809
|
>
|
|
1754
1810
|
<button
|
|
1755
1811
|
aria-disabled="false"
|
|
@@ -1783,6 +1839,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1783
1839
|
</div>
|
|
1784
1840
|
<div
|
|
1785
1841
|
class="default_xu2jcg-o_O-inlineStyles_1bljvrq"
|
|
1842
|
+
data-test-id="RIGHT_PAREN"
|
|
1786
1843
|
>
|
|
1787
1844
|
<button
|
|
1788
1845
|
aria-disabled="false"
|
|
@@ -1816,6 +1873,7 @@ exports[`keypad should snapshot unexpanded: first render 1`] = `
|
|
|
1816
1873
|
</div>
|
|
1817
1874
|
<div
|
|
1818
1875
|
class="default_xu2jcg-o_O-inlineStyles_y8g975"
|
|
1876
|
+
data-test-id="BACKSPACE"
|
|
1819
1877
|
>
|
|
1820
1878
|
<button
|
|
1821
1879
|
aria-disabled="false"
|
|
@@ -116,6 +116,36 @@ describe("keypad", () => {
|
|
|
116
116
|
).not.toBeInTheDocument();
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
+
it(`shows the dot symbol when convertDotToTimes is false`, () => {
|
|
120
|
+
// Arrange
|
|
121
|
+
// Act
|
|
122
|
+
render(
|
|
123
|
+
<Keypad
|
|
124
|
+
onClickKey={() => {}}
|
|
125
|
+
convertDotToTimes={false}
|
|
126
|
+
onAnalyticsEvent={async () => {}}
|
|
127
|
+
/>,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// Assert
|
|
131
|
+
expect(screen.getByTestId("CDOT")).toBeInTheDocument();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it(`shows the times symbol when convertDotToTimes is true`, () => {
|
|
135
|
+
// Arrange
|
|
136
|
+
// Act
|
|
137
|
+
render(
|
|
138
|
+
<Keypad
|
|
139
|
+
onClickKey={() => {}}
|
|
140
|
+
convertDotToTimes={true}
|
|
141
|
+
onAnalyticsEvent={async () => {}}
|
|
142
|
+
/>,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// Assert
|
|
146
|
+
expect(screen.getByTestId("TIMES")).toBeInTheDocument();
|
|
147
|
+
});
|
|
148
|
+
|
|
119
149
|
it(`hides the tabs if providing the Fraction Keypad`, () => {
|
|
120
150
|
// Arrange
|
|
121
151
|
// Act
|
|
@@ -38,6 +38,9 @@ export const KeypadButton = ({
|
|
|
38
38
|
gridRow: coord[1] + 1,
|
|
39
39
|
...style,
|
|
40
40
|
}}
|
|
41
|
+
// Unfortunately the CDOT and TIMES buttons are identical in the DOM
|
|
42
|
+
// apart from the ICON SVG, so we need to use testId.
|
|
43
|
+
testId={keyConfig.id}
|
|
41
44
|
>
|
|
42
45
|
<Clickable
|
|
43
46
|
onClick={(e) => onClickKey(keyConfig.id, e)}
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
divisionKey: false,
|
|
28
28
|
logarithms: false,
|
|
29
29
|
fractionsOnly: false,
|
|
30
|
-
|
|
30
|
+
convertDotToTimes: false,
|
|
31
31
|
preAlgebra: false,
|
|
32
32
|
trigonometry: false,
|
|
33
33
|
sendEvent: () => {},
|
|
@@ -113,7 +113,7 @@ Everything.args = {
|
|
|
113
113
|
basicRelations: true,
|
|
114
114
|
divisionKey: true,
|
|
115
115
|
logarithms: true,
|
|
116
|
-
|
|
116
|
+
convertDotToTimes: false,
|
|
117
117
|
preAlgebra: true,
|
|
118
118
|
trigonometry: true,
|
|
119
119
|
expandedView: true,
|
|
@@ -26,7 +26,7 @@ export type Props = {
|
|
|
26
26
|
showDismiss?: boolean;
|
|
27
27
|
expandedView?: boolean;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
convertDotToTimes?: boolean;
|
|
30
30
|
divisionKey?: boolean;
|
|
31
31
|
trigonometry?: boolean;
|
|
32
32
|
preAlgebra?: boolean;
|
|
@@ -88,7 +88,7 @@ export default function Keypad(props: Props) {
|
|
|
88
88
|
onClickKey,
|
|
89
89
|
cursorContext,
|
|
90
90
|
extraKeys,
|
|
91
|
-
|
|
91
|
+
convertDotToTimes,
|
|
92
92
|
divisionKey,
|
|
93
93
|
preAlgebra,
|
|
94
94
|
logarithms,
|
|
@@ -186,7 +186,7 @@ export default function Keypad(props: Props) {
|
|
|
186
186
|
<SharedKeys
|
|
187
187
|
onClickKey={onClickKey}
|
|
188
188
|
cursorContext={cursorContext}
|
|
189
|
-
|
|
189
|
+
convertDotToTimes={convertDotToTimes}
|
|
190
190
|
divisionKey={divisionKey}
|
|
191
191
|
selectedPage={selectedPage}
|
|
192
192
|
/>
|
|
@@ -39,6 +39,7 @@ type Props = {
|
|
|
39
39
|
type State = {
|
|
40
40
|
active: boolean;
|
|
41
41
|
containerWidth: number;
|
|
42
|
+
hasBeenActivated: boolean;
|
|
42
43
|
keypadConfig?: KeypadConfiguration;
|
|
43
44
|
keyHandler?: KeyHandler;
|
|
44
45
|
cursor?: Cursor;
|
|
@@ -53,6 +54,7 @@ class MobileKeypad extends React.Component<Props, State> implements KeypadAPI {
|
|
|
53
54
|
state: State = {
|
|
54
55
|
active: false,
|
|
55
56
|
containerWidth: 0,
|
|
57
|
+
hasBeenActivated: false,
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
componentDidMount() {
|
|
@@ -107,7 +109,10 @@ class MobileKeypad extends React.Component<Props, State> implements KeypadAPI {
|
|
|
107
109
|
};
|
|
108
110
|
|
|
109
111
|
activate: () => void = () => {
|
|
110
|
-
this.setState({
|
|
112
|
+
this.setState({
|
|
113
|
+
active: true,
|
|
114
|
+
hasBeenActivated: true,
|
|
115
|
+
});
|
|
111
116
|
};
|
|
112
117
|
|
|
113
118
|
dismiss: () => void = () => {
|
|
@@ -158,7 +163,8 @@ class MobileKeypad extends React.Component<Props, State> implements KeypadAPI {
|
|
|
158
163
|
|
|
159
164
|
render(): React.ReactNode {
|
|
160
165
|
const {style} = this.props;
|
|
161
|
-
const {active, containerWidth, cursor, keypadConfig} =
|
|
166
|
+
const {active, hasBeenActivated, containerWidth, cursor, keypadConfig} =
|
|
167
|
+
this.state;
|
|
162
168
|
|
|
163
169
|
const containerStyle = [
|
|
164
170
|
// internal styles
|
|
@@ -168,11 +174,22 @@ class MobileKeypad extends React.Component<Props, State> implements KeypadAPI {
|
|
|
168
174
|
...(Array.isArray(style) ? style : [style]),
|
|
169
175
|
];
|
|
170
176
|
|
|
177
|
+
// If the keypad is yet to have ever been activated, we keep it invisible
|
|
178
|
+
// so as to avoid, e.g., the keypad flashing at the bottom of the page
|
|
179
|
+
// during the initial render.
|
|
180
|
+
// Done inline (dynamicStyle) since stylesheets might not be loaded yet.
|
|
181
|
+
let dynamicStyle = {};
|
|
182
|
+
if (!active && !hasBeenActivated) {
|
|
183
|
+
dynamicStyle = {visibility: "hidden"};
|
|
184
|
+
}
|
|
185
|
+
|
|
171
186
|
const isExpression = keypadConfig?.keypadType === "EXPRESSION";
|
|
187
|
+
const convertDotToTimes = keypadConfig?.times;
|
|
172
188
|
|
|
173
189
|
return (
|
|
174
190
|
<View
|
|
175
191
|
style={containerStyle}
|
|
192
|
+
dynamicStyle={dynamicStyle}
|
|
176
193
|
forwardRef={this._containerRef}
|
|
177
194
|
ref={(element) => {
|
|
178
195
|
if (!this.hasMounted && element) {
|
|
@@ -203,7 +220,7 @@ class MobileKeypad extends React.Component<Props, State> implements KeypadAPI {
|
|
|
203
220
|
onClickKey={(key) => this._handleClickKey(key)}
|
|
204
221
|
cursorContext={cursor?.context}
|
|
205
222
|
fractionsOnly={!isExpression}
|
|
206
|
-
|
|
223
|
+
convertDotToTimes={convertDotToTimes}
|
|
207
224
|
divisionKey={isExpression}
|
|
208
225
|
trigonometry={isExpression}
|
|
209
226
|
preAlgebra={isExpression}
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
onClickKey: ClickKeyCallback;
|
|
13
13
|
selectedPage: KeypadPageType;
|
|
14
14
|
cursorContext?: typeof CursorContext[keyof typeof CursorContext];
|
|
15
|
-
|
|
15
|
+
convertDotToTimes?: boolean;
|
|
16
16
|
divisionKey?: boolean;
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ export default function SharedKeys(props: Props) {
|
|
|
21
21
|
onClickKey,
|
|
22
22
|
cursorContext,
|
|
23
23
|
divisionKey,
|
|
24
|
-
|
|
24
|
+
convertDotToTimes,
|
|
25
25
|
selectedPage,
|
|
26
26
|
} = props;
|
|
27
27
|
|
|
@@ -48,7 +48,7 @@ export default function SharedKeys(props: Props) {
|
|
|
48
48
|
secondary
|
|
49
49
|
/>
|
|
50
50
|
<KeypadButton
|
|
51
|
-
keyConfig={Keys.
|
|
51
|
+
keyConfig={Keys.FRAC}
|
|
52
52
|
onClickKey={onClickKey}
|
|
53
53
|
coord={fractionCoord}
|
|
54
54
|
secondary
|
|
@@ -56,7 +56,7 @@ export default function SharedKeys(props: Props) {
|
|
|
56
56
|
|
|
57
57
|
{/* Row 2 */}
|
|
58
58
|
<KeypadButton
|
|
59
|
-
keyConfig={
|
|
59
|
+
keyConfig={convertDotToTimes ? Keys.TIMES : Keys.CDOT}
|
|
60
60
|
onClickKey={onClickKey}
|
|
61
61
|
coord={[4, 1]}
|
|
62
62
|
secondary
|