@khanacademy/perseus 28.2.0 → 29.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.
@@ -14,9 +14,6 @@ type Props = {
14
14
  blockHighlight?: boolean;
15
15
  severity?: Severity;
16
16
  };
17
- type State = {
18
- tooltipAbove: boolean;
19
- };
20
17
  /**
21
18
  * This component renders "lint" nodes in a markdown parse tree. Lint nodes
22
19
  * are inserted into the tree by the Perseus linter (see
@@ -39,12 +36,8 @@ type State = {
39
36
  * that has a right margin (like anything blockquoted) the circle will appear
40
37
  * to the left of where it belongs. And if there is more
41
38
  **/
42
- declare class Lint extends React.Component<Props, State> {
39
+ declare class Lint extends React.Component<Props> {
43
40
  _positionTimeout: number | undefined;
44
- state: State;
45
- componentDidMount(): void;
46
- componentWillUnmount(): void;
47
- getPosition: () => void;
48
41
  renderLink: (arg1: any) => React.ReactElement;
49
42
  render(): React.ReactNode;
50
43
  }
package/dist/es/index.js CHANGED
@@ -15,7 +15,7 @@ import ReactDOM__default from 'react-dom';
15
15
  import _, { debounce as debounce$1 } from 'underscore';
16
16
  import Clickable from '@khanacademy/wonder-blocks-clickable';
17
17
  import { Popover, PopoverContentCore, PopoverContent } from '@khanacademy/wonder-blocks-popover';
18
- import { color, spacing } from '@khanacademy/wonder-blocks-tokens';
18
+ import { color, spacing, font } from '@khanacademy/wonder-blocks-tokens';
19
19
  import $ from 'jquery';
20
20
  import { v4 } from 'uuid';
21
21
  import PropTypes from 'prop-types';
@@ -1293,7 +1293,7 @@ const KhanMath = {
1293
1293
  * with an approx symbol if num had to be rounded, and trailing 0s
1294
1294
  */
1295
1295
  toFixedApprox: function (num, precision) {
1296
- // TODO(aria): Make this locale-dependent like KhanUtil.localeToFixed
1296
+ // TODO(aria): Make this locale-dependent
1297
1297
  const fixedStr = num.toFixed(precision);
1298
1298
  if (number.equal(+fixedStr, num)) {
1299
1299
  return fixedStr;
@@ -18171,27 +18171,9 @@ class Lint extends React.Component {
18171
18171
  constructor(...args) {
18172
18172
  super(...args);
18173
18173
  this._positionTimeout = void 0;
18174
- this.state = {
18175
- tooltipAbove: true
18176
- };
18177
- // We can't call setState in componentDidMount without risking a render
18178
- // thrash, and we can't call getBoundingClientRect in render, so we
18179
- // borrow a timeout approach from learnstorm-dashboard.jsx and set our
18180
- // state once the component has mounted and we can get what we need.
18181
- this.getPosition = () => {
18182
- // @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'getBoundingClientRect' does not exist on type 'Element | Text'.
18183
- const rect = ReactDOM__default.findDOMNode(this).getBoundingClientRect();
18184
- // TODO(scottgrant): This is a magic number! We don't know the size
18185
- // of the tooltip at this point, so we're arbitrarily choosing a
18186
- // point at which to flip the tooltip's position.
18187
- this.setState({
18188
- tooltipAbove: rect.top > 100
18189
- });
18190
- };
18191
18174
  // Render the <a> element that holds the indicator icon and the tooltip
18192
18175
  // We pass different styles for the inline and block cases
18193
18176
  this.renderLink = style => {
18194
- const tooltipAbove = this.state.tooltipAbove;
18195
18177
  let severityStyle;
18196
18178
  let warningText;
18197
18179
  let warningTextStyle;
@@ -18208,34 +18190,23 @@ class Lint extends React.Component {
18208
18190
  warningText = "Recommendation";
18209
18191
  warningTextStyle = styles$B.warning;
18210
18192
  }
18211
- return /*#__PURE__*/React.createElement("a", {
18193
+ return /*#__PURE__*/React.createElement(Tooltip$1, {
18194
+ backgroundColor: "offBlack",
18195
+ content: /*#__PURE__*/React.createElement(React.Fragment, null, this.props.message.split("\n\n").map((m, i) => /*#__PURE__*/React.createElement("p", {
18196
+ key: i,
18197
+ className: css(styles$B.tooltipParagraph)
18198
+ }, /*#__PURE__*/React.createElement("span", {
18199
+ className: css(warningTextStyle)
18200
+ }, warningText, ":", " "), m)))
18201
+ }, /*#__PURE__*/React.createElement("a", {
18212
18202
  href: `https://khanacademy.org/r/linter-rules#${this.props.ruleName}`,
18213
18203
  target: "lint-help-window",
18214
18204
  className: css(style)
18215
18205
  }, /*#__PURE__*/React.createElement("span", {
18216
18206
  className: css(styles$B.indicator, severityStyle)
18217
- }, this.props.severity === 1 && /*#__PURE__*/React.createElement(InlineIcon, exclamationIcon)), /*#__PURE__*/React.createElement("div", {
18218
- className: css(styles$B.tooltip, tooltipAbove && styles$B.tooltipAbove)
18219
- }, this.props.message.split("\n\n").map((m, i) => /*#__PURE__*/React.createElement("p", {
18220
- key: i,
18221
- className: css(styles$B.tooltipParagraph)
18222
- }, /*#__PURE__*/React.createElement("span", {
18223
- className: css(warningTextStyle)
18224
- }, warningText, ":", " "), m)), /*#__PURE__*/React.createElement("div", {
18225
- className: css(styles$B.tail, tooltipAbove && styles$B.tailAbove)
18226
- })));
18207
+ }, this.props.severity === 1 && /*#__PURE__*/React.createElement(InlineIcon, exclamationIcon))));
18227
18208
  };
18228
18209
  }
18229
- componentDidMount() {
18230
- // TODO(somewhatabstract): Use WB timing
18231
- // eslint-disable-next-line no-restricted-syntax
18232
- this._positionTimeout = window.setTimeout(this.getPosition);
18233
- }
18234
- componentWillUnmount() {
18235
- // TODO(somewhatabstract): Use WB timing
18236
- // eslint-disable-next-line no-restricted-syntax
18237
- window.clearTimeout(this._positionTimeout);
18238
- }
18239
18210
  // The main render method surrounds linty content with a block or
18240
18211
  // inline container and the link element that displays the indicator
18241
18212
  // and holds the tooltip.
@@ -18436,54 +18407,11 @@ const styles$B = StyleSheet.create({
18436
18407
  indicatorGuideline: {
18437
18408
  backgroundColor: "#ffbe26"
18438
18409
  },
18439
- // These are the styles for the tooltip
18440
- tooltip: {
18441
- // Absolute positioning relative to the lint indicator circle.
18442
- position: "absolute",
18443
- right: -12,
18444
- // The tooltip is hidden by default; only displayed on hover
18445
- display: "none",
18446
- // When it is displayed, it goes on top!
18447
- zIndex: 1000,
18448
- // These styles control what the tooltip looks like
18449
- color: white$1,
18450
- backgroundColor: gray17,
18451
- opacity: 0.9,
18452
- fontFamily: baseFontFamily$1,
18453
- fontSize: "12px",
18454
- lineHeight: "15px",
18455
- width: "320px",
18456
- borderRadius: "4px"
18457
- },
18458
- // If we're going to render the tooltip above the warning circle, we use
18459
- // the previous rules in tooltip, but change the position slightly.
18460
- tooltipAbove: {
18461
- bottom: 32
18462
- },
18463
- // We give the tooltip a little triangular "tail" that points down at
18464
- // the lint indicator circle. This is inside the tooltip and positioned
18465
- // relative to it. It also shares the opacity of the tooltip. We're using
18466
- // the standard CSS trick for drawing triangles with a thick border.
18467
- tail: {
18468
- position: "absolute",
18469
- top: -12,
18470
- right: 16,
18471
- width: 0,
18472
- height: 0,
18473
- // This is the CSS triangle trick
18474
- borderLeft: "8px solid transparent",
18475
- borderRight: "8px solid transparent",
18476
- borderBottom: "12px solid " + gray17
18477
- },
18478
- tailAbove: {
18479
- bottom: -12,
18480
- borderBottom: "none",
18481
- borderTop: "12px solid " + gray17,
18482
- top: "auto"
18483
- },
18484
18410
  // Each warning in the tooltip is its own <p>. They are 12 pixels from
18485
18411
  // the edges of the tooltip and 12 pixels from each other.
18486
18412
  tooltipParagraph: {
18413
+ fontFamily: font.family.sans,
18414
+ color: color.white,
18487
18415
  margin: 12
18488
18416
  },
18489
18417
  // The text "Warning" inside the tooltip is highlighted like this
@@ -22577,7 +22505,7 @@ var sharedStyles = StyleSheet.create({
22577
22505
  zIndex: zIndexAboveScratchpad
22578
22506
  },
22579
22507
  blankBackground: {
22580
- // TODO(emily): Use KhanUtil._BACKGROUND?
22508
+ // TODO(emily): Use WB colors?
22581
22509
  backgroundColor: "#FDFDFD"
22582
22510
  },
22583
22511
  perseusSrOnly: {
@@ -29692,6 +29620,18 @@ const LegacyGrid = ({
29692
29620
 
29693
29621
  // Range is replaced within this file with Interval, but it is used elsewhere
29694
29622
  // and exported from the package, so we need to keep it around.
29623
+ /**
29624
+ * A "PerseusItem" is a classic Perseus item. It is rendered by the
29625
+ * `ServerItemRenderer` and the layout is pre-set.
29626
+ *
29627
+ * To render more complex Perseus items, see the `Item` type in the multi item
29628
+ * area.
29629
+ */
29630
+ /**
29631
+ * A "MultiItem" is an advanced Perseus item. It is rendered by the
29632
+ * `MultiRenderer` and you can control the layout of individual parts of the
29633
+ * item.
29634
+ */
29695
29635
  const ItemExtras = [
29696
29636
  // The user might benefit from using a Scientific Calculator. Provided on Khan Academy when true
29697
29637
  "calculator",
@@ -31892,7 +31832,8 @@ const MafsGraph = props => {
31892
31832
  boxSizing: "content-box",
31893
31833
  marginLeft: "20px",
31894
31834
  marginBottom: "20px",
31895
- pointerEvents: props.static ? "none" : "auto"
31835
+ pointerEvents: props.static ? "none" : "auto",
31836
+ userSelect: "none"
31896
31837
  }
31897
31838
  }, /*#__PURE__*/React.createElement(LegacyGrid, {
31898
31839
  box: props.box,
@@ -44260,7 +44201,7 @@ const init = function init(options) {
44260
44201
 
44261
44202
  // This file is processed by a Rollup plugin (replace) to inject the production
44262
44203
  const libName = "@khanacademy/perseus";
44263
- const libVersion = "28.2.0";
44204
+ const libVersion = "29.0.0";
44264
44205
  addLibraryVersionToPerseusDebug(libName, libVersion);
44265
44206
 
44266
44207
  const apiVersion = {
@@ -47670,7 +47611,6 @@ const genericPerseusItemData = {
47670
47611
  minor: 1
47671
47612
  },
47672
47613
  hints: [],
47673
- _multi: null,
47674
47614
  answer: null
47675
47615
  };
47676
47616