@khanacademy/perseus 0.1.0 → 0.2.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 (57) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/es/index.css +4361 -0
  3. package/dist/es/index.js +3 -3
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/index.css +0 -7573
  6. package/dist/index.js +3 -3
  7. package/dist/index.js.map +1 -1
  8. package/dist/strings.js +0 -45
  9. package/package.json +4 -4
  10. package/src/components/fixed-to-responsive.jsx +1 -0
  11. package/src/components/graph.jsx +2 -1
  12. package/src/components/info-tip/info-tip.jsx +0 -3
  13. package/src/components/input-with-examples.jsx +1 -1
  14. package/src/components/lint.jsx +0 -2
  15. package/src/components/number-input.jsx +1 -1
  16. package/src/components/prop-check-box.jsx +3 -1
  17. package/src/components/range-input.jsx +1 -1
  18. package/src/components/simple-keypad-input.jsx +5 -5
  19. package/src/components/sortable.jsx +1 -0
  20. package/src/components/stub-tag-editor.jsx +1 -0
  21. package/src/interactive2/movable-helper-methods.js +1 -1
  22. package/src/interactive2/movable-line-options.js +2 -2
  23. package/src/interactive2/movable-line.js +1 -1
  24. package/src/interactive2/movable-point-options.js +1 -1
  25. package/src/interactive2/movable-point.jsx +1 -2
  26. package/src/interactive2/movable-polygon-options.js +1 -1
  27. package/src/interactive2/movable-polygon.js +2 -1
  28. package/src/interactive2/movable.js +1 -1
  29. package/src/interactive2/wrapped-defaults.js +1 -1
  30. package/src/interactive2/wrapped-ellipse.js +1 -1
  31. package/src/interactive2/wrapped-line.js +1 -1
  32. package/src/mixins/provide-keypad.jsx +1 -3
  33. package/src/perseus-markdown.jsx +1 -0
  34. package/src/styles/perseus-renderer.less +1 -2
  35. package/src/util/answer-types.js +1 -1
  36. package/src/util/graphie.js +1 -1
  37. package/src/util/interactive.js +11 -5
  38. package/src/util/math.js +1 -1
  39. package/src/widgets/cs-program.jsx +0 -1
  40. package/src/widgets/expression.jsx +3 -5
  41. package/src/widgets/grapher/util.jsx +9 -22
  42. package/src/widgets/grapher.jsx +6 -1
  43. package/src/widgets/iframe.jsx +0 -1
  44. package/src/widgets/image.jsx +1 -0
  45. package/src/widgets/input-number.jsx +1 -0
  46. package/src/widgets/interaction.jsx +2 -2
  47. package/src/widgets/interactive-graph.jsx +1 -2
  48. package/src/widgets/matrix.jsx +1 -0
  49. package/src/widgets/number-line.jsx +1 -1
  50. package/src/widgets/numeric-input.jsx +2 -2
  51. package/src/widgets/radio/cross-out-menu-wrapper.jsx +5 -5
  52. package/src/widgets/reaction-diagram.jsx +1 -0
  53. package/src/widgets/simulator.jsx +1 -1
  54. package/src/widgets/table.jsx +1 -2
  55. package/src/widgets/transformer.jsx +14 -8
  56. package/src/widgets/unit.jsx +1 -1
  57. package/src/widgets/video.jsx +1 -6
@@ -1,6 +1,11 @@
1
+ /* eslint-disable react/prop-types */
1
2
  /* eslint-disable react/sort-comp */
2
3
  // @flow
3
- import {number as knumber, vector as kvector, point as kpoint} from "kmath";
4
+ import {
5
+ number as knumber,
6
+ vector as kvector,
7
+ point as kpoint,
8
+ } from "@khanacademy/kmath";
4
9
  import * as React from "react";
5
10
  import _ from "underscore";
6
11
 
@@ -101,7 +101,6 @@ class Iframe extends React.Component<$FlowFixMe> {
101
101
  // If the URL doesnt start with http, it must be a program ID
102
102
  if (url && url.length && url.indexOf("http") !== 0) {
103
103
  url =
104
- // eslint-disable-next-line static-service/require-safe-link-to
105
104
  "https://www.khanacademy.org/computer-programming/program/" +
106
105
  url +
107
106
  "/embedded?buttons=no&embed=yes&editor=no&author=no";
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  /* eslint-disable react/sort-comp */
2
3
  // @flow
3
4
  import {StyleSheet, css} from "aphrodite";
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  /* eslint-disable react/sort-comp */
2
3
  // @flow
3
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @babel/no-invalid-this, react/no-unsafe, react/sort-comp */
2
2
  // @flow
3
- import KAS from "kas";
4
- import {vector as kvector} from "kmath";
3
+ import * as KAS from "@khanacademy/kas";
4
+ import {vector as kvector} from "@khanacademy/kmath";
5
5
  import * as React from "react";
6
6
  import _ from "underscore";
7
7
 
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable @babel/no-invalid-this, react/no-unsafe, react/sort-comp */
2
2
  // @flow
3
+ import {number as knumber, point as kpoint} from "@khanacademy/kmath";
3
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
4
5
  import $ from "jquery";
5
- import kmath from "kmath";
6
6
  import debounce from "lodash.debounce";
7
7
  import * as React from "react";
8
8
  import _ from "underscore";
@@ -37,7 +37,6 @@ type SineCoefficient = [
37
37
  ];
38
38
  type QuadraticCoefficient = [/* a */ number, /* b */ number, /* c */ number];
39
39
 
40
- const {number: knumber, point: kpoint} = kmath;
41
40
  const {DeprecationMixin} = Util;
42
41
 
43
42
  const TRASH_ICON_URI =
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  /* eslint-disable react/sort-comp */
2
3
  // @flow
3
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
@@ -1,6 +1,6 @@
1
1
  // @flow
2
+ import {number as knumber} from "@khanacademy/kmath";
2
3
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
3
- import {number as knumber} from "kmath";
4
4
  import * as React from "react";
5
5
  import ReactDOM from "react-dom";
6
6
  import _ from "underscore";
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  // @flow
2
3
 
3
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
@@ -9,8 +10,7 @@ import InputWithExamples from "../components/input-with-examples.jsx";
9
10
  import PossibleAnswers from "../components/possible-answers.jsx";
10
11
  import SimpleKeypadInput from "../components/simple-keypad-input.jsx";
11
12
  import {linterContextDefault} from "../gorgon/proptypes.js";
12
- import {ClassNames as ApiClassNames} from "../perseus-api.jsx";
13
- import {ApiOptions} from "../perseus-api.jsx";
13
+ import {ApiOptions, ClassNames as ApiClassNames} from "../perseus-api.jsx";
14
14
  import TexWrangler from "../tex-wrangler.js";
15
15
  import KhanAnswerTypes from "../util/answer-types.js";
16
16
  import KhanMath from "../util/math.js";
@@ -10,7 +10,7 @@
10
10
  * to uncover a cross-out button underneath. (This is why we need to wrap the
11
11
  * content!)
12
12
  */
13
- import colors from "@khanacademy/wonder-blocks-color";
13
+ import Color from "@khanacademy/wonder-blocks-color";
14
14
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
15
15
  import {StyleSheet, css} from "aphrodite";
16
16
  import * as React from "react";
@@ -248,9 +248,9 @@ export default class CrossOutMenuWrapper extends React.PureComponent<
248
248
  return this.props.primaryProductColor;
249
249
  }
250
250
  if (this.state.hovered) {
251
- return colors.offBlack;
251
+ return Color.offBlack;
252
252
  }
253
- return colors.offBlack50;
253
+ return Color.offBlack50;
254
254
  }
255
255
 
256
256
  _renderMenu(): React.Element<"div"> {
@@ -396,7 +396,7 @@ const styles = StyleSheet.create({
396
396
  // to being closed, rather than awkwardly _sliding_ closed.
397
397
  [mediaQueries.smOrSmaller]: {
398
398
  transition: "transform 0.2s ease-out",
399
- backgroundColor: colors.white,
399
+ backgroundColor: Color.white,
400
400
  },
401
401
  },
402
402
 
@@ -471,7 +471,7 @@ const styles = StyleSheet.create({
471
471
  alignItems: "center",
472
472
  justifyContent: "center",
473
473
 
474
- background: colors.offBlack50,
474
+ background: Color.offBlack50,
475
475
  cursor: "pointer",
476
476
 
477
477
  [mediaQueries.mdOrLarger]: {
@@ -67,6 +67,7 @@ class ReactionDiagramWidget extends React.Component<$FlowFixMe> {
67
67
  // we're limited to a single reaction step. At some point, add support
68
68
  // for more steps in the reaction.
69
69
  rotationAngle: PropTypes.arrayOf(PropTypes.number),
70
+ // eslint-disable-next-line react/forbid-prop-types
70
71
  separators: PropTypes.arrayOf(PropTypes.object),
71
72
  smiles: PropTypes.arrayOf(PropTypes.string),
72
73
  widgetId: PropTypes.string,
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-unused-vars, react/no-unsafe, react/sort-comp */
2
2
  // @flow
3
+ import {number as knumber} from "@khanacademy/kmath";
3
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
4
- import {number as knumber} from "kmath";
5
5
  import PropTypes from "prop-types";
6
6
  import * as React from "react";
7
7
  import ReactDOM from "react-dom";
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react/sort-comp */
2
2
  // @flow
3
- import {propTypes} from "@khanacademy/math-input";
3
+ import {keypadElementPropType} from "@khanacademy/math-input";
4
4
  import PropTypes from "prop-types";
5
5
  import * as React from "react";
6
6
  import ReactDOM from "react-dom";
@@ -18,7 +18,6 @@ import KhanAnswerTypes from "../util/answer-types.js";
18
18
  import type {WidgetExports} from "../types.js";
19
19
 
20
20
  const {assert} = InteractiveUtil;
21
- const {keypadElementPropType} = propTypes;
22
21
 
23
22
  /* Input handling: Maps a (row, column) pair to a unique ref used by React,
24
23
  * and extracts (row, column) pairs from input paths, used to allow outsiders
@@ -1,4 +1,8 @@
1
- /* eslint-disable @babel/no-invalid-this, camelcase, react/no-did-update-set-state, react/sort-comp */
1
+ /* eslint-disable react/prop-types */
2
+ /* eslint-disable @babel/no-invalid-this */
3
+ /* eslint-disable camelcase */
4
+ /* eslint-disable react/no-did-update-set-state */
5
+ /* eslint-disable react/sort-comp */
2
6
  /*
3
7
  NOTE(Pereus stabilize project): This widget is no-longer-used as of January
4
8
  2022. It's not present in US content but is still present in some
@@ -10,16 +14,16 @@ ref: https://khanacademy.slack.com/archives/CJDRXTGQ7/p1641857400011600
10
14
  ref: https://khanacademy.slack.com/archives/C2RFQGYKU/p1596160975061500?thread_ts=1596129758.040000&cid=C2RFQGYKU
11
15
  */
12
16
  // @flow
13
- import * as i18n from "@khanacademy/wonder-blocks-i18n";
14
- import createReactClass from "create-react-class";
15
- import $ from "jquery";
16
17
  import {
17
18
  number as knumber,
18
19
  vector as kvector,
19
20
  point as kpoint,
20
21
  ray as kray,
21
22
  line as kline,
22
- } from "kmath";
23
+ } from "@khanacademy/kmath";
24
+ import * as i18n from "@khanacademy/wonder-blocks-i18n";
25
+ import createReactClass from "create-react-class";
26
+ import $ from "jquery";
23
27
  import * as React from "react";
24
28
  import ReactDOM from "react-dom";
25
29
  import _ from "underscore";
@@ -823,6 +827,7 @@ const Transformations = {
823
827
  transform1: ReflectionTransformation,
824
828
  transform2: ReflectionTransformation,
825
829
  ) {
830
+ // $FlowFixMe[incompatible-call]
826
831
  if (!kline.equal(transform1.line, transform2.line)) {
827
832
  return false;
828
833
  }
@@ -2151,15 +2156,16 @@ class Transformer extends React.Component<Props> {
2151
2156
  normalizeReflectionCoords: ([Coord, Coord]) => [Coord, Coord] = (
2152
2157
  messyCoords,
2153
2158
  ) => {
2159
+ // $FlowFixMe[incompatible-call]
2154
2160
  const midpoint = this.snapCoord(kline.midpoint(messyCoords));
2155
2161
  const origDirectionPolar = kvector.polarDegFromCart(
2156
2162
  kvector.subtract(messyCoords[0], messyCoords[1]),
2157
2163
  );
2158
- const directionPolar = [
2164
+
2165
+ const direction = kvector.cartFromPolarDeg(
2159
2166
  1,
2160
2167
  KhanMath.roundToNearest(45, origDirectionPolar[1]),
2161
- ];
2162
- const direction = kvector.cartFromPolarDeg(directionPolar);
2168
+ );
2163
2169
  const coords = _.map(
2164
2170
  [-1, 1],
2165
2171
  function (directionCoefficient) {
@@ -4,10 +4,10 @@
4
4
  // terms of a certain type.
5
5
  // TODO(joel): Allow sigfigs within a range rather than an exact expected
6
6
  // value?
7
+ import * as KAS from "@khanacademy/kas";
7
8
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
8
9
  import lens from "hubble";
9
10
  import $ from "jquery";
10
- import KAS from "kas";
11
11
  import * as React from "react";
12
12
  import ReactDOM from "react-dom";
13
13
  import _ from "underscore";
@@ -16,11 +16,7 @@ import a11y from "../util/a11y.js";
16
16
  import VideoTranscriptLink from "./video-transcript-link.jsx";
17
17
 
18
18
  import type {PerseusVideoWidgetOptions} from "../perseus-types.js";
19
- import type {
20
- PerseusScore,
21
- WidgetExports,
22
- WidgetProps,
23
- } from "../types.js";
19
+ import type {PerseusScore, WidgetExports, WidgetProps} from "../types.js";
24
20
 
25
21
  // Current default is 720p, based on the typical videos we upload currently
26
22
  const DEFAULT_WIDTH = 1280;
@@ -83,7 +79,6 @@ class Video extends React.Component<Props> {
83
79
  url = location;
84
80
  } else {
85
81
  url = KA_EMBED.replace("{slug}", location);
86
- // eslint-disable-next-line static-service/require-safe-link-to
87
82
  let embedHostname = "https://www.khanacademy.org";
88
83
  if (IS_KA_SITE.test(InitialRequestUrl.host)) {
89
84
  embedHostname = InitialRequestUrl.origin;