@khanacademy/perseus 4.0.1 → 4.0.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 +11 -0
- package/dist/components/highlighting/ui/highlighting-ui.d.ts +1 -1
- package/dist/es/index.js +46 -223
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +46 -223
- package/dist/index.js.map +1 -1
- package/dist/multi-items/multi-renderer.d.ts +1 -1
- package/dist/multi-items/multi-renderer.js.flow +1 -1
- package/dist/multi-items/prop-type-builders.d.ts +1 -1
- package/dist/multi-items/shape-types.d.ts +1 -1
- package/dist/multi-items/shape-types.js.flow +1 -1
- package/dist/multi-items/tree-types.d.ts +1 -1
- package/dist/multi-items/tree-types.js.flow +1 -1
- package/dist/widgets/__stories__/test-keypad-context-wrapper.d.ts +6 -0
- package/dist/widgets/__stories__/test-keypad-context-wrapper.js.flow +14 -0
- package/package.json +4 -4
- package/src/__testdata__/item-renderer.testdata.ts +1 -1
- package/src/__testdata__/renderer.testdata.ts +1 -1
- package/src/__tests__/item-renderer.test.tsx +1 -2
- package/src/__tests__/renderer-api.test.tsx +1 -5
- package/src/__tests__/renderer.test.tsx +1 -1
- package/src/components/fixed-to-responsive.tsx +0 -1
- package/src/components/graph.tsx +0 -4
- package/src/components/highlighting/ui/highlighting-ui.tsx +3 -13
- package/src/components/highlighting/ui/selection-tracker.tsx +1 -1
- package/src/components/highlighting/word-indexer.tsx +0 -4
- package/src/components/math-input.tsx +0 -2
- package/src/components/number-input.tsx +0 -2
- package/src/components/text-list-editor.tsx +0 -4
- package/src/components/zoomable-tex.tsx +0 -2
- package/src/components/zoomable.tsx +0 -4
- package/src/definition-context.tsx +0 -1
- package/src/hints-renderer.tsx +1 -1
- package/src/interactive2/__tests__/movable-point.test.ts +0 -1
- package/src/item-renderer.tsx +0 -5
- package/src/mixins/changeable.ts +1 -1
- package/src/multi-items/__stories__/multi-renderer.stories.tsx +0 -4
- package/src/multi-items/__tests__/items.test.ts +3 -13
- package/src/multi-items/__tests__/multi-renderer.test.tsx +1 -1
- package/src/multi-items/__tests__/prop-type-builders.test.ts +1 -1
- package/src/multi-items/__tests__/trees.test.ts +2 -10
- package/src/multi-items/multi-renderer.tsx +7 -10
- package/src/multi-items/prop-type-builders.ts +1 -1
- package/src/multi-items/shape-types.ts +1 -1
- package/src/multi-items/tree-types.ts +1 -1
- package/src/perseus-markdown.tsx +0 -2
- package/src/perseus-types.ts +1 -1
- package/src/renderer.tsx +2 -5
- package/src/server-item-renderer.tsx +0 -3
- package/src/util/interactive.ts +0 -4
- package/src/util/math.ts +0 -3
- package/src/widgets/__stories__/expression.stories.tsx +113 -7
- package/src/widgets/__stories__/image.stories.tsx +1 -1
- package/src/widgets/__stories__/{on-screen-keypad.stories.tsx → test-keypad-context-wrapper.tsx} +17 -57
- package/src/widgets/__testdata__/expression.testdata.ts +16 -12
- package/src/widgets/__testdata__/numeric-input.testdata.ts +0 -1
- package/src/widgets/__testdata__/transformer.testdata.ts +0 -1
- package/src/widgets/__tests__/radio.test.ts +1 -1
- package/src/widgets/expression.tsx +1 -1
- package/src/widgets/graded-group-set.tsx +0 -4
- package/src/widgets/graded-group.tsx +0 -4
- package/src/widgets/grapher/util.tsx +1 -5
- package/src/widgets/grapher.tsx +0 -5
- package/src/widgets/group.tsx +0 -1
- package/src/widgets/interaction.tsx +0 -1
- package/src/widgets/interactive-graph.tsx +3 -62
- package/src/widgets/label-image.tsx +1 -1
- package/src/widgets/measurer.tsx +0 -1
- package/src/widgets/number-line.tsx +0 -2
- package/src/widgets/orderer.tsx +0 -3
- package/src/widgets/passage/passage-markdown.tsx +1 -1
- package/src/widgets/passage-ref-target.tsx +0 -1
- package/src/widgets/passage.tsx +1 -1
- package/src/widgets/plotter.tsx +0 -1
- package/src/widgets/radio/__stories__/base-radio.stories.tsx +2 -2
- package/src/widgets/radio/base-radio.tsx +1 -1
- package/src/widgets/transformer.tsx +1 -16
- package/src/widgets.ts +1 -1
- package/src/zoom.ts +0 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -417,7 +417,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
417
417
|
[-10, 10],
|
|
418
418
|
],
|
|
419
419
|
step: [1, 1],
|
|
420
|
-
// $FlowFixMe[prop-missing]
|
|
421
420
|
// @ts-expect-error [FEI-5003] - TS2739 - Type '{ readonly url: null; }' is missing the following properties from type 'PerseusImageBackground': width, height
|
|
422
421
|
backgroundImage: defaultBackgroundImage,
|
|
423
422
|
markings: "graph",
|
|
@@ -727,10 +726,8 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
727
726
|
return Interactive2.addMaybeMobileMovablePoint(this, {
|
|
728
727
|
coord: coord,
|
|
729
728
|
constraints: [
|
|
730
|
-
// $FlowFixMe[prop-missing]
|
|
731
729
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
732
730
|
Interactive2.MovablePoint.constraints.bound(),
|
|
733
|
-
// $FlowFixMe[prop-missing]
|
|
734
731
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
735
732
|
Interactive2.MovablePoint.constraints.snap(),
|
|
736
733
|
],
|
|
@@ -798,7 +795,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
798
795
|
|
|
799
796
|
const onMoveHandler = () => {
|
|
800
797
|
const graph = _.extend({}, this.props.graph, {
|
|
801
|
-
// $FlowFixMe[incompatible-use]
|
|
802
798
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2531 - Object is possibly 'null'. | TS2531 - Object is possibly 'null'.
|
|
803
799
|
coords: [pointA.coord(), pointB.coord(), pointC.coord()],
|
|
804
800
|
});
|
|
@@ -813,19 +809,15 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
813
809
|
pointA = this.pointA = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
814
810
|
coord: coords[0],
|
|
815
811
|
constraints: [
|
|
816
|
-
// $FlowFixMe[prop-missing]
|
|
817
812
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
818
813
|
Interactive2.MovablePoint.constraints.bound(),
|
|
819
|
-
// $FlowFixMe[prop-missing]
|
|
820
814
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
821
815
|
Interactive2.MovablePoint.constraints.snap(),
|
|
822
816
|
(coord) => {
|
|
823
817
|
return (
|
|
824
818
|
!pointA ||
|
|
825
|
-
// $FlowFixMe[incompatible-use]
|
|
826
819
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
|
|
827
820
|
(coord[0] !== pointB.coord()[0] &&
|
|
828
|
-
// $FlowFixMe[incompatible-use]
|
|
829
821
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
|
|
830
822
|
coord[0] !== pointC.coord()[0])
|
|
831
823
|
);
|
|
@@ -841,19 +833,15 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
841
833
|
pointB = this.pointB = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
842
834
|
coord: coords[1],
|
|
843
835
|
constraints: [
|
|
844
|
-
// $FlowFixMe[prop-missing]
|
|
845
836
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
846
837
|
Interactive2.MovablePoint.constraints.bound(),
|
|
847
|
-
// $FlowFixMe[prop-missing]
|
|
848
838
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
849
839
|
Interactive2.MovablePoint.constraints.snap(),
|
|
850
840
|
(coord: any) => {
|
|
851
841
|
return (
|
|
852
842
|
!pointB ||
|
|
853
|
-
// $FlowFixMe[incompatible-use]
|
|
854
843
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
|
|
855
844
|
(coord[0] !== pointA.coord()[0] &&
|
|
856
|
-
// $FlowFixMe[incompatible-use]
|
|
857
845
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
|
|
858
846
|
coord[0] !== pointC.coord()[0])
|
|
859
847
|
);
|
|
@@ -869,19 +857,15 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
869
857
|
pointC = this.pointC = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
870
858
|
coord: coords[2],
|
|
871
859
|
constraints: [
|
|
872
|
-
// $FlowFixMe[prop-missing]
|
|
873
860
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
874
861
|
Interactive2.MovablePoint.constraints.bound(),
|
|
875
|
-
// $FlowFixMe[prop-missing]
|
|
876
862
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
877
863
|
Interactive2.MovablePoint.constraints.snap(),
|
|
878
864
|
(coord: any) => {
|
|
879
865
|
return (
|
|
880
866
|
!pointC ||
|
|
881
|
-
// $FlowFixMe[incompatible-use]
|
|
882
867
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
|
|
883
868
|
(coord[0] !== pointA.coord()[0] &&
|
|
884
|
-
// $FlowFixMe[incompatible-use]
|
|
885
869
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
|
|
886
870
|
coord[0] !== pointB.coord()[0])
|
|
887
871
|
);
|
|
@@ -943,7 +927,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
943
927
|
|
|
944
928
|
const onMoveHandler = () => {
|
|
945
929
|
const graph = _.extend({}, this.props.graph, {
|
|
946
|
-
// $FlowFixMe[incompatible-use]
|
|
947
930
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
|
|
948
931
|
coords: [pointA.coord(), pointB.coord()],
|
|
949
932
|
});
|
|
@@ -958,10 +941,8 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
958
941
|
pointA = this.pointA = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
959
942
|
coord: coords[0],
|
|
960
943
|
constraints: [
|
|
961
|
-
// $FlowFixMe[prop-missing]
|
|
962
944
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
963
945
|
Interactive2.MovablePoint.constraints.bound(),
|
|
964
|
-
// $FlowFixMe[prop-missing]
|
|
965
946
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
966
947
|
Interactive2.MovablePoint.constraints.snap(),
|
|
967
948
|
(coord: any) => {
|
|
@@ -976,10 +957,8 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
976
957
|
{
|
|
977
958
|
coord: coords[1],
|
|
978
959
|
constraints: [
|
|
979
|
-
// $FlowFixMe[prop-missing]
|
|
980
960
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
981
961
|
Interactive2.MovablePoint.constraints.bound(),
|
|
982
|
-
// $FlowFixMe[prop-missing]
|
|
983
962
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
984
963
|
Interactive2.MovablePoint.constraints.snap(),
|
|
985
964
|
(coord: any) => {
|
|
@@ -1049,9 +1028,7 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1049
1028
|
|
|
1050
1029
|
$(circle).on("move", () => {
|
|
1051
1030
|
const graph = _.extend({}, this.props.graph, {
|
|
1052
|
-
// $FlowFixMe[incompatible-use]
|
|
1053
1031
|
center: circle.center,
|
|
1054
|
-
// $FlowFixMe[incompatible-use]
|
|
1055
1032
|
radius: circle.radius,
|
|
1056
1033
|
});
|
|
1057
1034
|
this.onChange({graph: graph});
|
|
@@ -1085,10 +1062,8 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1085
1062
|
Interactive2.addMaybeMobileMovablePoint(this, {
|
|
1086
1063
|
coord: coord,
|
|
1087
1064
|
constraints: [
|
|
1088
|
-
// $FlowFixMe[prop-missing]
|
|
1089
1065
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1090
1066
|
Interactive2.MovablePoint.constraints.bound(),
|
|
1091
|
-
// $FlowFixMe[prop-missing]
|
|
1092
1067
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1093
1068
|
Interactive2.MovablePoint.constraints.snap(),
|
|
1094
1069
|
(coord) => {
|
|
@@ -1152,9 +1127,7 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1152
1127
|
const graphie = this.graphie;
|
|
1153
1128
|
const screenPoint = graphie?.scalePoint(coord);
|
|
1154
1129
|
return (
|
|
1155
|
-
// $FlowFixMe[incompatible-use]
|
|
1156
1130
|
screenPoint[0] >= graphie.xpixels - 40 &&
|
|
1157
|
-
// $FlowFixMe[incompatible-use]
|
|
1158
1131
|
screenPoint[1] >= graphie.ypixels - 40
|
|
1159
1132
|
);
|
|
1160
1133
|
};
|
|
@@ -1188,10 +1161,8 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1188
1161
|
point = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
1189
1162
|
coord: coord,
|
|
1190
1163
|
constraints: [
|
|
1191
|
-
// $FlowFixMe[prop-missing]
|
|
1192
1164
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1193
1165
|
Interactive2.MovablePoint.constraints.bound(),
|
|
1194
|
-
// $FlowFixMe[prop-missing]
|
|
1195
1166
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1196
1167
|
Interactive2.MovablePoint.constraints.snap(),
|
|
1197
1168
|
function (coord) {
|
|
@@ -1563,12 +1534,10 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1563
1534
|
const point = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
1564
1535
|
coord: coord,
|
|
1565
1536
|
constraints: [
|
|
1566
|
-
// $FlowFixMe[prop-missing]
|
|
1567
1537
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1568
1538
|
Interactive2.MovablePoint.constraints.bound(),
|
|
1569
1539
|
snapToGrid
|
|
1570
|
-
? //
|
|
1571
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1540
|
+
? // @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1572
1541
|
Interactive2.MovablePoint.constraints.snap()
|
|
1573
1542
|
: null,
|
|
1574
1543
|
graphConstraint,
|
|
@@ -1686,10 +1655,8 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1686
1655
|
createPoint({
|
|
1687
1656
|
coord: coord,
|
|
1688
1657
|
constraints: [
|
|
1689
|
-
// $FlowFixMe[prop-missing]
|
|
1690
1658
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1691
1659
|
Interactive2.MovablePoint.constraints.bound(),
|
|
1692
|
-
// $FlowFixMe[prop-missing]
|
|
1693
1660
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1694
1661
|
Interactive2.MovablePoint.constraints.snap(),
|
|
1695
1662
|
(coord: any) => {
|
|
@@ -1718,15 +1685,12 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1718
1685
|
points: points,
|
|
1719
1686
|
static: false,
|
|
1720
1687
|
constraints: [
|
|
1721
|
-
// $FlowFixMe[prop-missing]
|
|
1722
1688
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1723
1689
|
Interactive2.MovableLine.constraints.bound(),
|
|
1724
|
-
// $FlowFixMe[prop-missing]
|
|
1725
1690
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1726
1691
|
Interactive2.MovableLine.constraints.snap(),
|
|
1727
1692
|
],
|
|
1728
1693
|
onMove: [
|
|
1729
|
-
// $FlowFixMe[prop-missing]
|
|
1730
1694
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'onMove' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
1731
1695
|
Interactive2.MovableLine.onMove.updatePoints,
|
|
1732
1696
|
updateCoordProps,
|
|
@@ -1870,12 +1834,10 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1870
1834
|
const self = this;
|
|
1871
1835
|
self.polygon = Interactive2.addMovablePolygon(graphie, {
|
|
1872
1836
|
constraints: [
|
|
1873
|
-
// $FlowFixMe[prop-missing]
|
|
1874
1837
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => undefined'.
|
|
1875
1838
|
Interactive2.MovablePolygon.constraints.bound(),
|
|
1876
1839
|
snapToGrid
|
|
1877
|
-
? //
|
|
1878
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => undefined'.
|
|
1840
|
+
? // @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => undefined'.
|
|
1879
1841
|
Interactive2.MovablePolygon.constraints.snap()
|
|
1880
1842
|
: null,
|
|
1881
1843
|
],
|
|
@@ -1886,7 +1848,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
1886
1848
|
numArcs: numArcs,
|
|
1887
1849
|
sideLabels: sideLabels,
|
|
1888
1850
|
onMove: [
|
|
1889
|
-
// $FlowFixMe[prop-missing]
|
|
1890
1851
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'onMove' does not exist on type '(graphie: any, movable: any, options: any) => undefined'.
|
|
1891
1852
|
Interactive2.MovablePolygon.onMove.updatePoints,
|
|
1892
1853
|
function () {
|
|
@@ -2135,7 +2096,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2135
2096
|
props: Props,
|
|
2136
2097
|
): ReadonlyArray<Coord> {
|
|
2137
2098
|
return (
|
|
2138
|
-
// $FlowFixMe[incompatible-return]
|
|
2139
2099
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'coords' does not exist on type 'PerseusGraphType'.
|
|
2140
2100
|
graph.coords ||
|
|
2141
2101
|
InteractiveGraph.pointsFromNormalized(props, [
|
|
@@ -2230,7 +2190,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2230
2190
|
): ReadonlyArray<ReadonlyArray<Coord>> {
|
|
2231
2191
|
return (
|
|
2232
2192
|
// The callers assume that we're return an array of points
|
|
2233
|
-
// $FlowFixMe[incompatible-return]
|
|
2234
2193
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'coords' does not exist on type 'PerseusGraphType'.
|
|
2235
2194
|
graph.coords ||
|
|
2236
2195
|
_.map(
|
|
@@ -2323,17 +2282,11 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2323
2282
|
const n = graph.numSegments || 1;
|
|
2324
2283
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'number[] | undefined' is not assignable to type 'readonly number[]'.
|
|
2325
2284
|
const ys: ReadonlyArray<number> = {
|
|
2326
|
-
// $FlowFixMe[unsupported-syntax]
|
|
2327
2285
|
1: [5],
|
|
2328
|
-
// $FlowFixMe[unsupported-syntax]
|
|
2329
2286
|
2: [5, -5],
|
|
2330
|
-
// $FlowFixMe[unsupported-syntax]
|
|
2331
2287
|
3: [5, 0, -5],
|
|
2332
|
-
// $FlowFixMe[unsupported-syntax]
|
|
2333
2288
|
4: [6, 2, -2, -6],
|
|
2334
|
-
// $FlowFixMe[unsupported-syntax]
|
|
2335
2289
|
5: [6, 3, 0, -3, -6],
|
|
2336
|
-
// $FlowFixMe[unsupported-syntax]
|
|
2337
2290
|
6: [5, 3, 1, -1, -3, -5],
|
|
2338
2291
|
}[n];
|
|
2339
2292
|
const range = [
|
|
@@ -2645,7 +2598,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2645
2598
|
// If both of the guess points are on the correct line, it's
|
|
2646
2599
|
// correct.
|
|
2647
2600
|
if (
|
|
2648
|
-
// $FlowFixMe[incompatible-use] - Fix type so coords can't be omitted
|
|
2649
2601
|
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
2650
2602
|
collinear(correct[0], correct[1], guess[0]) &&
|
|
2651
2603
|
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
@@ -2693,8 +2645,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2693
2645
|
// If the parabola coefficients match, it's correct.
|
|
2694
2646
|
const guessCoeffs = this.getQuadraticCoefficients(state.coords);
|
|
2695
2647
|
const correctCoeffs = this.getQuadraticCoefficients(
|
|
2696
|
-
// $FlowFixMe[incompatible-call]
|
|
2697
|
-
// $FlowFixMe[prop-missing]
|
|
2698
2648
|
// @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'readonly Coord[] | undefined' is not assignable to parameter of type 'readonly Coord[]'.
|
|
2699
2649
|
rubric.correct.coords,
|
|
2700
2650
|
);
|
|
@@ -2713,8 +2663,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2713
2663
|
) {
|
|
2714
2664
|
const guessCoeffs = this.getSinusoidCoefficients(state.coords);
|
|
2715
2665
|
const correctCoeffs = this.getSinusoidCoefficients(
|
|
2716
|
-
// $FlowFixMe[incompatible-call]
|
|
2717
|
-
// $FlowFixMe[prop-missing]
|
|
2718
2666
|
// @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'readonly Coord[] | undefined' is not assignable to parameter of type 'readonly Coord[]'.
|
|
2719
2667
|
rubric.correct.coords,
|
|
2720
2668
|
);
|
|
@@ -2738,7 +2686,6 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2738
2686
|
) {
|
|
2739
2687
|
if (
|
|
2740
2688
|
deepEq(state.center, rubric.correct.center) &&
|
|
2741
|
-
// $FlowFixMe[prop-missing]
|
|
2742
2689
|
eq(state.radius, rubric.correct.radius)
|
|
2743
2690
|
) {
|
|
2744
2691
|
return {
|
|
@@ -2831,10 +2778,8 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2831
2778
|
const guess = state.coords;
|
|
2832
2779
|
const correct = rubric.correct.coords;
|
|
2833
2780
|
if (
|
|
2834
|
-
// $FlowFixMe[incompatible-use]
|
|
2835
2781
|
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'.
|
|
2836
2782
|
deepEq(guess[0], correct[0]) &&
|
|
2837
|
-
// $FlowFixMe[incompatible-use]
|
|
2838
2783
|
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
2839
2784
|
collinear(correct[0], correct[1], guess[1])
|
|
2840
2785
|
) {
|
|
@@ -2869,14 +2814,10 @@ class InteractiveGraph extends React.Component<Props, State> {
|
|
|
2869
2814
|
match = eq(...angles);
|
|
2870
2815
|
} else {
|
|
2871
2816
|
/* exact */
|
|
2872
|
-
match =
|
|
2873
|
-
// $FlowFixMe[incompatible-use]
|
|
2874
|
-
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
2817
|
+
match = // @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
2875
2818
|
deepEq(guess[1], correct[1]) &&
|
|
2876
|
-
// $FlowFixMe[incompatible-use]
|
|
2877
2819
|
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
2878
2820
|
collinear(correct[1], correct[0], guess[0]) &&
|
|
2879
|
-
// $FlowFixMe[incompatible-use]
|
|
2880
2821
|
// @ts-expect-error [FEI-5003] - TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'. | TS2532 - Object is possibly 'undefined'.
|
|
2881
2822
|
collinear(correct[1], correct[2], guess[2]);
|
|
2882
2823
|
}
|
|
@@ -11,7 +11,7 @@ import {Popover, PopoverContentCore} from "@khanacademy/wonder-blocks-popover";
|
|
|
11
11
|
import {StyleSheet, css} from "aphrodite";
|
|
12
12
|
import classNames from "classnames";
|
|
13
13
|
import * as React from "react";
|
|
14
|
-
import ReactDOM from "react-dom";
|
|
14
|
+
import * as ReactDOM from "react-dom";
|
|
15
15
|
|
|
16
16
|
import AssetContext from "../asset-context";
|
|
17
17
|
import SvgImage from "../components/svg-image";
|
package/src/widgets/measurer.tsx
CHANGED
|
@@ -79,7 +79,6 @@ const Measurer: any = createReactClass({
|
|
|
79
79
|
left: image.left,
|
|
80
80
|
}}
|
|
81
81
|
>
|
|
82
|
-
{/* $FlowFixMe[prop-missing]: alt prop is missing */}
|
|
83
82
|
{/* @ts-expect-error [FEI-5003] - TS2741 - Property 'alt' is missing in type '{ src: any; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'. */}
|
|
84
83
|
<SvgImage src={image.url} />
|
|
85
84
|
</div>
|
|
@@ -160,7 +160,6 @@ const TickMarks: any = Graphie.createSimpleClass((graphie, props) => {
|
|
|
160
160
|
color: KhanColors.BLUE_D,
|
|
161
161
|
}
|
|
162
162
|
: {},
|
|
163
|
-
// $FlowFixMe[incompatible-call]
|
|
164
163
|
() => _label(graphie, props.labelStyle, leftLabel, leftLabel, base),
|
|
165
164
|
),
|
|
166
165
|
);
|
|
@@ -173,7 +172,6 @@ const TickMarks: any = Graphie.createSimpleClass((graphie, props) => {
|
|
|
173
172
|
}
|
|
174
173
|
: {},
|
|
175
174
|
() =>
|
|
176
|
-
// $FlowFixMe[incompatible-call]
|
|
177
175
|
_label(graphie, props.labelStyle, rightLabel, rightLabel, base),
|
|
178
176
|
),
|
|
179
177
|
);
|
package/src/widgets/orderer.tsx
CHANGED
|
@@ -502,10 +502,7 @@ class Orderer extends React.Component<OrdererProps, OrdererState> {
|
|
|
502
502
|
current: list,
|
|
503
503
|
dragging: true,
|
|
504
504
|
placeholderIndex: placeholderIndex,
|
|
505
|
-
// $FlowFixMe[prop-missing]
|
|
506
|
-
// $FlowFixMe[incompatible-use]
|
|
507
505
|
dragKey: opt.key,
|
|
508
|
-
// $FlowFixMe[incompatible-use]
|
|
509
506
|
dragContent: opt.content,
|
|
510
507
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'width' does not exist on type 'JQueryStatic'.
|
|
511
508
|
dragWidth: $draggable.width(),
|
|
@@ -150,7 +150,7 @@ const rules = {
|
|
|
150
150
|
|
|
151
151
|
// A "magic" capture that matches the opening {{
|
|
152
152
|
// but captures the full ref text internally :D
|
|
153
|
-
// unfortunately the "magic" makes
|
|
153
|
+
// unfortunately the "magic" makes TypeScript upset,
|
|
154
154
|
// so there's this questionable workaround
|
|
155
155
|
capture[1] = source.slice(2, closeIndex);
|
|
156
156
|
return capture;
|
|
@@ -47,7 +47,6 @@ class PassageRefTarget extends React.Component<any> {
|
|
|
47
47
|
|
|
48
48
|
render(): React.ReactNode {
|
|
49
49
|
return (
|
|
50
|
-
// $FlowFixMe[prop-missing]: inline doesn't exist in Renderer's declared props
|
|
51
50
|
<Renderer
|
|
52
51
|
content={this.props.content}
|
|
53
52
|
// @ts-expect-error [FEI-5003] - TS2322 - Type '{ content: any; inline: boolean; apiOptions: any; linterContext: any; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Renderer> & Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | ... 3 more ... | "legacyPerseusLint"> & InexactPartial<...> & InexactPartial<...>'.
|
package/src/widgets/passage.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import * as i18n from "@khanacademy/wonder-blocks-i18n";
|
|
|
3
3
|
import {StyleSheet, css} from "aphrodite";
|
|
4
4
|
import $ from "jquery";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import ReactDOM from "react-dom";
|
|
6
|
+
import * as ReactDOM from "react-dom";
|
|
7
7
|
import _ from "underscore";
|
|
8
8
|
|
|
9
9
|
import HighlightableContent from "../components/highlighting/highlightable-content";
|
package/src/widgets/plotter.tsx
CHANGED
|
@@ -927,7 +927,6 @@ class Plotter extends React.Component<any, any> {
|
|
|
927
927
|
if (i > 0) {
|
|
928
928
|
c.graph.lines[i] = Interactive2.addMovableLine(graphie, {
|
|
929
929
|
points: [c.graph.points[i - 1], c.graph.points[i]],
|
|
930
|
-
// $FlowFixMe[prop-missing]
|
|
931
930
|
// @ts-expect-error [FEI-5003] - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
932
931
|
constraints: Interactive2.MovablePoint.constraints.fixed(),
|
|
933
932
|
normalStyle: {
|
|
@@ -146,7 +146,7 @@ export const SingleKitchenSink: React.FC<StoryArgs> = (
|
|
|
146
146
|
|
|
147
147
|
const rubricChoices = choices.map(({correct}) => ({
|
|
148
148
|
// note(matthew): reviewModeRubric.choices requires content,
|
|
149
|
-
// but I don't see how it's getting used and
|
|
149
|
+
// but I don't see how it's getting used and TypeScript gets mad
|
|
150
150
|
// when I use choice.content because it's not a string.
|
|
151
151
|
// reviewModeRubric could probably use a look over.
|
|
152
152
|
content: "",
|
|
@@ -186,7 +186,7 @@ export const MultipleKitchenSink: React.FC<StoryArgs> = (
|
|
|
186
186
|
|
|
187
187
|
const rubricChoices = choices.map((c) => ({
|
|
188
188
|
// note(matthew): reviewModeRubric.choices requires content,
|
|
189
|
-
// but I don't see how it's getting used and
|
|
189
|
+
// but I don't see how it's getting used and TypeScript gets mad
|
|
190
190
|
// when I use choice.content because it's not a string.
|
|
191
191
|
// reviewModeRubric could probably use a look over.
|
|
192
192
|
content: "",
|
|
@@ -325,7 +325,7 @@ const BaseRadio: React.FC<Props> = function (props): React.ReactElement {
|
|
|
325
325
|
|
|
326
326
|
let correctnessClass;
|
|
327
327
|
// reviewMode is only true if there's a rubric
|
|
328
|
-
// but
|
|
328
|
+
// but TypeScript doesn't understand that
|
|
329
329
|
if (reviewMode && reviewModeRubric) {
|
|
330
330
|
correctnessClass = reviewModeRubric.choices[i].correct
|
|
331
331
|
? ApiClassNames.CORRECT
|
|
@@ -1281,9 +1281,7 @@ const ShapeTypes = {
|
|
|
1281
1281
|
fixed: !options.translatable && !options.editable,
|
|
1282
1282
|
},
|
|
1283
1283
|
visible: options.showPoints,
|
|
1284
|
-
// $FlowFixMe[prop-missing]
|
|
1285
1284
|
snapX: (options.snap && options.snap[0]) || 0,
|
|
1286
|
-
// $FlowFixMe[prop-missing]
|
|
1287
1285
|
snapY: (options.snap && options.snap[1]) || 0,
|
|
1288
1286
|
bounded: false, // Don't bound it when placing it on the graph
|
|
1289
1287
|
onMove: onMove,
|
|
@@ -2111,7 +2109,6 @@ class Transformer extends React.Component<Props> {
|
|
|
2111
2109
|
transform = {
|
|
2112
2110
|
type: "translation",
|
|
2113
2111
|
// NOTE(kevib): these should be numbers
|
|
2114
|
-
// $FlowFixMe[incompatible-type]
|
|
2115
2112
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'null' is not assignable to type 'number'. | TS2322 - Type 'null' is not assignable to type 'number'.
|
|
2116
2113
|
vector: [null, null],
|
|
2117
2114
|
};
|
|
@@ -2120,11 +2117,9 @@ class Transformer extends React.Component<Props> {
|
|
|
2120
2117
|
transform = {
|
|
2121
2118
|
type: "rotation",
|
|
2122
2119
|
// NOTE(kevib): these should be numbers
|
|
2123
|
-
// $FlowFixMe[incompatible-type]
|
|
2124
2120
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'null' is not assignable to type 'number'. | TS2322 - Type 'null' is not assignable to type 'number'.
|
|
2125
2121
|
center: [null, null],
|
|
2126
2122
|
// NOTE(kevib): this should be a number
|
|
2127
|
-
// $FlowFixMe[incompatible-type]
|
|
2128
2123
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'null' is not assignable to type 'number'.
|
|
2129
2124
|
angleDeg: null,
|
|
2130
2125
|
};
|
|
@@ -2135,11 +2130,9 @@ class Transformer extends React.Component<Props> {
|
|
|
2135
2130
|
type: "reflection",
|
|
2136
2131
|
line: [
|
|
2137
2132
|
// NOTE(kevib): these should be numbers
|
|
2138
|
-
// $FlowFixMe[incompatible-type]
|
|
2139
2133
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'null' is not assignable to type 'number'. | TS2322 - Type 'null' is not assignable to type 'number'.
|
|
2140
2134
|
[null, null],
|
|
2141
2135
|
// NOTE(kevib): these should be numbers
|
|
2142
|
-
// $FlowFixMe[incompatible-type]
|
|
2143
2136
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'null' is not assignable to type 'number'. | TS2322 - Type 'null' is not assignable to type 'number'.
|
|
2144
2137
|
[null, null],
|
|
2145
2138
|
],
|
|
@@ -2149,11 +2142,9 @@ class Transformer extends React.Component<Props> {
|
|
|
2149
2142
|
transform = {
|
|
2150
2143
|
type: "dilation",
|
|
2151
2144
|
// NOTE(kevib): these should be numbers
|
|
2152
|
-
// $FlowFixMe[incompatible-type]
|
|
2153
2145
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'null' is not assignable to type 'number'. | TS2322 - Type 'null' is not assignable to type 'number'.
|
|
2154
2146
|
center: [null, null],
|
|
2155
2147
|
// NOTE(kevib): this should be a number
|
|
2156
|
-
// $FlowFixMe[incompatible-type]
|
|
2157
2148
|
// @ts-expect-error [FEI-5003] - TS2322 - Type 'null' is not assignable to type 'number'.
|
|
2158
2149
|
scale: null,
|
|
2159
2150
|
};
|
|
@@ -2381,7 +2372,6 @@ class Transformer extends React.Component<Props> {
|
|
|
2381
2372
|
if (reflectRotateHandle) {
|
|
2382
2373
|
$(reflectRotateHandle).on("move", function () {
|
|
2383
2374
|
const rotateHandleApprox = self.snapCoord(
|
|
2384
|
-
// $FlowFixMe[incompatible-use]
|
|
2385
2375
|
// @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'.
|
|
2386
2376
|
reflectRotateHandle.coord,
|
|
2387
2377
|
);
|
|
@@ -2476,7 +2466,6 @@ class Transformer extends React.Component<Props> {
|
|
|
2476
2466
|
hoverWidth: this.scaleToCurrentRange(0.4),
|
|
2477
2467
|
onMove: function (newAngle, oldAngle) {
|
|
2478
2468
|
const transform = self.getRotationTransformFromAngle(
|
|
2479
|
-
// $FlowFixMe[incompatible-use]
|
|
2480
2469
|
self.rotatePoint.coord,
|
|
2481
2470
|
newAngle - oldAngle,
|
|
2482
2471
|
);
|
|
@@ -2530,9 +2519,7 @@ class Transformer extends React.Component<Props> {
|
|
|
2530
2519
|
self.doTransform({
|
|
2531
2520
|
type: "dilation",
|
|
2532
2521
|
// NOTE(kevinb): It's hard to convince that this.dilationCircle
|
|
2533
|
-
// will still be defined here.
|
|
2534
|
-
// $FlowFixMe[incompatible-use]
|
|
2535
|
-
center: self.dilationCircle.centerPoint.coord,
|
|
2522
|
+
// will still be defined here. center: self.dilationCircle.centerPoint.coord,
|
|
2536
2523
|
scale: newRadius / oldRadius,
|
|
2537
2524
|
});
|
|
2538
2525
|
},
|
|
@@ -2569,7 +2556,6 @@ class Transformer extends React.Component<Props> {
|
|
|
2569
2556
|
origOnMoveEnd(args);
|
|
2570
2557
|
}
|
|
2571
2558
|
self.changeTool("dilation", {
|
|
2572
|
-
// $FlowFixMe[incompatible-use]
|
|
2573
2559
|
coord: self.dilationCircle.centerPoint.coord,
|
|
2574
2560
|
});
|
|
2575
2561
|
};
|
|
@@ -2750,7 +2736,6 @@ class Transformer extends React.Component<Props> {
|
|
|
2750
2736
|
// handle coordinates in formal mode without movement, since
|
|
2751
2737
|
// the movablepoints never move
|
|
2752
2738
|
shape: {
|
|
2753
|
-
// $FlowFixMe[incompatible-use]
|
|
2754
2739
|
type: this.shape.type,
|
|
2755
2740
|
coords: this.getCoords(),
|
|
2756
2741
|
options: this.shape?.getOptions(),
|
package/src/widgets.ts
CHANGED
|
@@ -363,7 +363,7 @@ const validAlignments: ReadonlyArray<Alignment> = [
|
|
|
363
363
|
* invalid.
|
|
364
364
|
*/
|
|
365
365
|
// TODO(alex): Change this to run as a testcase (vs. being run at runtime)
|
|
366
|
-
// TODO(LP-10707): I think this can be completely removed because our
|
|
366
|
+
// TODO(LP-10707): I think this can be completely removed because our TypeScript types
|
|
367
367
|
// enforce this!
|
|
368
368
|
export const validateAlignments = () => {
|
|
369
369
|
_.each(widgets, function (widgetInfo) {
|
package/src/zoom.ts
CHANGED
|
@@ -399,15 +399,12 @@ Zoom.prototype._calculateZoom = function () {
|
|
|
399
399
|
const viewportAspectRatio = viewportWidth / viewportHeight;
|
|
400
400
|
|
|
401
401
|
if (
|
|
402
|
-
// $FlowFixMe[invalid-compare]
|
|
403
402
|
originalFullImageWidth < viewportWidth &&
|
|
404
|
-
// $FlowFixMe[invalid-compare]
|
|
405
403
|
originalFullImageHeight < viewportHeight
|
|
406
404
|
) {
|
|
407
405
|
this._imgScaleFactor = maxScaleFactor;
|
|
408
406
|
} else if (imageAspectRatio < viewportAspectRatio) {
|
|
409
407
|
this._imgScaleFactor =
|
|
410
|
-
// $FlowFixMe[unsafe-addition]
|
|
411
408
|
(viewportHeight / originalFullImageHeight) * maxScaleFactor;
|
|
412
409
|
} else {
|
|
413
410
|
this._imgScaleFactor =
|