@khanacademy/perseus 29.0.0 → 30.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/dist/components/lint.d.ts +8 -1
- package/dist/es/index.js +86 -14
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +86 -13
- package/dist/index.js.map +1 -1
- package/dist/widgets/expression.d.ts +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18331,10 +18331,39 @@ var Severity = /*#__PURE__*/function (Severity) {
|
|
|
18331
18331
|
**/
|
|
18332
18332
|
class Lint extends React__namespace.Component {
|
|
18333
18333
|
_positionTimeout;
|
|
18334
|
+
state = {
|
|
18335
|
+
tooltipAbove: true
|
|
18336
|
+
};
|
|
18337
|
+
componentDidMount() {
|
|
18338
|
+
// TODO(somewhatabstract): Use WB timing
|
|
18339
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
18340
|
+
this._positionTimeout = window.setTimeout(this.getPosition);
|
|
18341
|
+
}
|
|
18342
|
+
componentWillUnmount() {
|
|
18343
|
+
// TODO(somewhatabstract): Use WB timing
|
|
18344
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
18345
|
+
window.clearTimeout(this._positionTimeout);
|
|
18346
|
+
}
|
|
18347
|
+
|
|
18348
|
+
// We can't call setState in componentDidMount without risking a render
|
|
18349
|
+
// thrash, and we can't call getBoundingClientRect in render, so we
|
|
18350
|
+
// borrow a timeout approach from learnstorm-dashboard.jsx and set our
|
|
18351
|
+
// state once the component has mounted and we can get what we need.
|
|
18352
|
+
getPosition = () => {
|
|
18353
|
+
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'getBoundingClientRect' does not exist on type 'Element | Text'.
|
|
18354
|
+
const rect = ReactDOM__default["default"].findDOMNode(this).getBoundingClientRect();
|
|
18355
|
+
// TODO(scottgrant): This is a magic number! We don't know the size
|
|
18356
|
+
// of the tooltip at this point, so we're arbitrarily choosing a
|
|
18357
|
+
// point at which to flip the tooltip's position.
|
|
18358
|
+
this.setState({
|
|
18359
|
+
tooltipAbove: rect.top > 100
|
|
18360
|
+
});
|
|
18361
|
+
};
|
|
18334
18362
|
|
|
18335
18363
|
// Render the <a> element that holds the indicator icon and the tooltip
|
|
18336
18364
|
// We pass different styles for the inline and block cases
|
|
18337
18365
|
renderLink = style => {
|
|
18366
|
+
const tooltipAbove = this.state.tooltipAbove;
|
|
18338
18367
|
let severityStyle;
|
|
18339
18368
|
let warningText;
|
|
18340
18369
|
let warningTextStyle;
|
|
@@ -18351,21 +18380,22 @@ class Lint extends React__namespace.Component {
|
|
|
18351
18380
|
warningText = "Recommendation";
|
|
18352
18381
|
warningTextStyle = styles$B.warning;
|
|
18353
18382
|
}
|
|
18354
|
-
return /*#__PURE__*/React__namespace.createElement(
|
|
18355
|
-
backgroundColor: "offBlack",
|
|
18356
|
-
content: /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, this.props.message.split("\n\n").map((m, i) => /*#__PURE__*/React__namespace.createElement("p", {
|
|
18357
|
-
key: i,
|
|
18358
|
-
className: aphrodite.css(styles$B.tooltipParagraph)
|
|
18359
|
-
}, /*#__PURE__*/React__namespace.createElement("span", {
|
|
18360
|
-
className: aphrodite.css(warningTextStyle)
|
|
18361
|
-
}, warningText, ":", " "), m)))
|
|
18362
|
-
}, /*#__PURE__*/React__namespace.createElement("a", {
|
|
18383
|
+
return /*#__PURE__*/React__namespace.createElement("a", {
|
|
18363
18384
|
href: `https://khanacademy.org/r/linter-rules#${this.props.ruleName}`,
|
|
18364
18385
|
target: "lint-help-window",
|
|
18365
18386
|
className: aphrodite.css(style)
|
|
18366
18387
|
}, /*#__PURE__*/React__namespace.createElement("span", {
|
|
18367
18388
|
className: aphrodite.css(styles$B.indicator, severityStyle)
|
|
18368
|
-
}, this.props.severity === 1 && /*#__PURE__*/React__namespace.createElement(InlineIcon, exclamationIcon))
|
|
18389
|
+
}, this.props.severity === 1 && /*#__PURE__*/React__namespace.createElement(InlineIcon, exclamationIcon)), /*#__PURE__*/React__namespace.createElement("div", {
|
|
18390
|
+
className: aphrodite.css(styles$B.tooltip, tooltipAbove && styles$B.tooltipAbove)
|
|
18391
|
+
}, this.props.message.split("\n\n").map((m, i) => /*#__PURE__*/React__namespace.createElement("p", {
|
|
18392
|
+
key: i,
|
|
18393
|
+
className: aphrodite.css(styles$B.tooltipParagraph)
|
|
18394
|
+
}, /*#__PURE__*/React__namespace.createElement("span", {
|
|
18395
|
+
className: aphrodite.css(warningTextStyle)
|
|
18396
|
+
}, warningText, ":", " "), m)), /*#__PURE__*/React__namespace.createElement("div", {
|
|
18397
|
+
className: aphrodite.css(styles$B.tail, tooltipAbove && styles$B.tailAbove)
|
|
18398
|
+
})));
|
|
18369
18399
|
};
|
|
18370
18400
|
|
|
18371
18401
|
// The main render method surrounds linty content with a block or
|
|
@@ -18568,11 +18598,54 @@ const styles$B = aphrodite.StyleSheet.create({
|
|
|
18568
18598
|
indicatorGuideline: {
|
|
18569
18599
|
backgroundColor: "#ffbe26"
|
|
18570
18600
|
},
|
|
18601
|
+
// These are the styles for the tooltip
|
|
18602
|
+
tooltip: {
|
|
18603
|
+
// Absolute positioning relative to the lint indicator circle.
|
|
18604
|
+
position: "absolute",
|
|
18605
|
+
right: -12,
|
|
18606
|
+
// The tooltip is hidden by default; only displayed on hover
|
|
18607
|
+
display: "none",
|
|
18608
|
+
// When it is displayed, it goes on top!
|
|
18609
|
+
zIndex: 1000,
|
|
18610
|
+
// These styles control what the tooltip looks like
|
|
18611
|
+
color: white$1,
|
|
18612
|
+
backgroundColor: gray17,
|
|
18613
|
+
opacity: 0.9,
|
|
18614
|
+
fontFamily: baseFontFamily$1,
|
|
18615
|
+
fontSize: "12px",
|
|
18616
|
+
lineHeight: "15px",
|
|
18617
|
+
width: "320px",
|
|
18618
|
+
borderRadius: "4px"
|
|
18619
|
+
},
|
|
18620
|
+
// If we're going to render the tooltip above the warning circle, we use
|
|
18621
|
+
// the previous rules in tooltip, but change the position slightly.
|
|
18622
|
+
tooltipAbove: {
|
|
18623
|
+
bottom: 32
|
|
18624
|
+
},
|
|
18625
|
+
// We give the tooltip a little triangular "tail" that points down at
|
|
18626
|
+
// the lint indicator circle. This is inside the tooltip and positioned
|
|
18627
|
+
// relative to it. It also shares the opacity of the tooltip. We're using
|
|
18628
|
+
// the standard CSS trick for drawing triangles with a thick border.
|
|
18629
|
+
tail: {
|
|
18630
|
+
position: "absolute",
|
|
18631
|
+
top: -12,
|
|
18632
|
+
right: 16,
|
|
18633
|
+
width: 0,
|
|
18634
|
+
height: 0,
|
|
18635
|
+
// This is the CSS triangle trick
|
|
18636
|
+
borderLeft: "8px solid transparent",
|
|
18637
|
+
borderRight: "8px solid transparent",
|
|
18638
|
+
borderBottom: "12px solid " + gray17
|
|
18639
|
+
},
|
|
18640
|
+
tailAbove: {
|
|
18641
|
+
bottom: -12,
|
|
18642
|
+
borderBottom: "none",
|
|
18643
|
+
borderTop: "12px solid " + gray17,
|
|
18644
|
+
top: "auto"
|
|
18645
|
+
},
|
|
18571
18646
|
// Each warning in the tooltip is its own <p>. They are 12 pixels from
|
|
18572
18647
|
// the edges of the tooltip and 12 pixels from each other.
|
|
18573
18648
|
tooltipParagraph: {
|
|
18574
|
-
fontFamily: wonderBlocksTokens.font.family.sans,
|
|
18575
|
-
color: wonderBlocksTokens.color.white,
|
|
18576
18649
|
margin: 12
|
|
18577
18650
|
},
|
|
18578
18651
|
// The text "Warning" inside the tooltip is highlighted like this
|
|
@@ -44552,7 +44625,7 @@ const init = function (options) {
|
|
|
44552
44625
|
|
|
44553
44626
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44554
44627
|
const libName = "@khanacademy/perseus";
|
|
44555
|
-
const libVersion = "
|
|
44628
|
+
const libVersion = "30.0.0";
|
|
44556
44629
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44557
44630
|
|
|
44558
44631
|
const apiVersion = {
|