@khanacademy/perseus 1.3.4 → 1.3.5
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 +7 -0
- package/dist/es/index.js +89 -41
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +89 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/item-renderer_test.jsx.snap +1 -1
- package/src/__tests__/__snapshots__/server-item-renderer_test.jsx.snap +1 -1
- package/src/components/input-with-examples.jsx +12 -13
- package/src/index.js +1 -0
- package/src/multi-items/__tests__/__snapshots__/multi-renderer_test.js.snap +6 -6
- package/src/perseus-types.js +5 -4
- package/src/util.js +1 -1
- package/src/widgets/__stories__/input-number.stories.jsx +29 -3
- package/src/widgets/__tests__/__snapshots__/group_test.jsx.snap +5 -5
- package/src/widgets/__tests__/__snapshots__/input-number_test.jsx.snap +1 -1
- package/src/widgets/__tests__/__snapshots__/radio_test.jsx.snap +52 -52
- package/src/widgets/input-number.jsx +65 -11
- package/src/widgets/numeric-input.jsx +3 -0
- package/src/widgets/radio/choice.jsx +1 -1
package/CHANGELOG.md
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -17959,17 +17959,17 @@ class Lint extends React.Component {
|
|
|
17959
17959
|
var warningTextStyle;
|
|
17960
17960
|
|
|
17961
17961
|
if (this.props.severity === 1) {
|
|
17962
|
-
severityStyle = styles$
|
|
17962
|
+
severityStyle = styles$B.indicatorError;
|
|
17963
17963
|
warningText = "Error";
|
|
17964
|
-
warningTextStyle = styles$
|
|
17964
|
+
warningTextStyle = styles$B.publishBlockingError;
|
|
17965
17965
|
} else if (this.props.severity === 2) {
|
|
17966
|
-
severityStyle = styles$
|
|
17966
|
+
severityStyle = styles$B.indicatorWarning;
|
|
17967
17967
|
warningText = "Warning";
|
|
17968
|
-
warningTextStyle = styles$
|
|
17968
|
+
warningTextStyle = styles$B.warning;
|
|
17969
17969
|
} else {
|
|
17970
|
-
severityStyle = styles$
|
|
17970
|
+
severityStyle = styles$B.indicatorGuideline;
|
|
17971
17971
|
warningText = "Recommendation";
|
|
17972
|
-
warningTextStyle = styles$
|
|
17972
|
+
warningTextStyle = styles$B.warning;
|
|
17973
17973
|
}
|
|
17974
17974
|
|
|
17975
17975
|
return /*#__PURE__*/React.createElement("a", {
|
|
@@ -17977,16 +17977,16 @@ class Lint extends React.Component {
|
|
|
17977
17977
|
target: "lint-help-window",
|
|
17978
17978
|
className: css(style)
|
|
17979
17979
|
}, /*#__PURE__*/React.createElement("span", {
|
|
17980
|
-
className: css(styles$
|
|
17980
|
+
className: css(styles$B.indicator, severityStyle)
|
|
17981
17981
|
}, this.props.severity === 1 && /*#__PURE__*/React.createElement(InlineIcon, exclamationIcon)), /*#__PURE__*/React.createElement("div", {
|
|
17982
|
-
className: css(styles$
|
|
17982
|
+
className: css(styles$B.tooltip, tooltipAbove && styles$B.tooltipAbove)
|
|
17983
17983
|
}, this.props.message.split("\n\n").map((m, i) => /*#__PURE__*/React.createElement("p", {
|
|
17984
17984
|
key: i,
|
|
17985
|
-
className: css(styles$
|
|
17985
|
+
className: css(styles$B.tooltipParagraph)
|
|
17986
17986
|
}, /*#__PURE__*/React.createElement("span", {
|
|
17987
17987
|
className: css(warningTextStyle)
|
|
17988
17988
|
}, warningText, ":", " "), m)), /*#__PURE__*/React.createElement("div", {
|
|
17989
|
-
className: css(styles$
|
|
17989
|
+
className: css(styles$B.tail, tooltipAbove && styles$B.tailAbove)
|
|
17990
17990
|
})));
|
|
17991
17991
|
});
|
|
17992
17992
|
}
|
|
@@ -18034,19 +18034,19 @@ class Lint extends React.Component {
|
|
|
18034
18034
|
|
|
18035
18035
|
if (blockHighlight) {
|
|
18036
18036
|
return /*#__PURE__*/React.createElement("span", {
|
|
18037
|
-
className: css(styles$
|
|
18038
|
-
}, this.renderLink(styles$
|
|
18037
|
+
className: css(styles$B.lintContainer, styles$B.lintContainerBlock)
|
|
18038
|
+
}, this.renderLink(styles$B.radioWidgetHoverTarget), /*#__PURE__*/React.createElement("span", null, children));
|
|
18039
18039
|
}
|
|
18040
18040
|
|
|
18041
18041
|
if (inline) {
|
|
18042
18042
|
return /*#__PURE__*/React.createElement("span", {
|
|
18043
|
-
className: css(styles$
|
|
18044
|
-
}, this.renderLink(styles$
|
|
18043
|
+
className: css(styles$B.lintContainer)
|
|
18044
|
+
}, this.renderLink(styles$B.inlineHoverTarget), /*#__PURE__*/React.createElement("span", null, children));
|
|
18045
18045
|
}
|
|
18046
18046
|
|
|
18047
18047
|
return /*#__PURE__*/React.createElement("div", {
|
|
18048
|
-
className: css(styles$
|
|
18049
|
-
}, this.renderLink(styles$
|
|
18048
|
+
className: css(styles$B.lintContainer)
|
|
18049
|
+
}, this.renderLink(styles$B.hoverTarget), /*#__PURE__*/React.createElement("div", null, children));
|
|
18050
18050
|
}
|
|
18051
18051
|
|
|
18052
18052
|
} // $FlowFixMe[prop-missing]
|
|
@@ -18071,7 +18071,7 @@ _defineProperty(Lint, "propTypes", {
|
|
|
18071
18071
|
severity: PropTypes.number
|
|
18072
18072
|
});
|
|
18073
18073
|
|
|
18074
|
-
var styles$
|
|
18074
|
+
var styles$B = StyleSheet.create({
|
|
18075
18075
|
// This is the class of the outermost element.
|
|
18076
18076
|
// We use relative positioning so that the lint indicator can be
|
|
18077
18077
|
// positioned absolutely relative to the position of the linty container.
|
|
@@ -19961,7 +19961,7 @@ class Renderer extends React.Component {
|
|
|
19961
19961
|
paddingRight: margin
|
|
19962
19962
|
};
|
|
19963
19963
|
|
|
19964
|
-
var mobileInnerStyle = _objectSpread2(_objectSpread2({}, innerStyle), styles$
|
|
19964
|
+
var mobileInnerStyle = _objectSpread2(_objectSpread2({}, innerStyle), styles$A.mobileZoomableParentFix);
|
|
19965
19965
|
|
|
19966
19966
|
return /*#__PURE__*/React.createElement("div", {
|
|
19967
19967
|
key: state.key,
|
|
@@ -20099,7 +20099,7 @@ class Renderer extends React.Component {
|
|
|
20099
20099
|
paddingRight: 0
|
|
20100
20100
|
};
|
|
20101
20101
|
|
|
20102
|
-
var _mobileInnerStyle = _objectSpread2(_objectSpread2({}, _innerStyle), styles$
|
|
20102
|
+
var _mobileInnerStyle = _objectSpread2(_objectSpread2({}, _innerStyle), styles$A.mobileZoomableParentFix);
|
|
20103
20103
|
|
|
20104
20104
|
var wrappedOutput = /*#__PURE__*/React.createElement("div", {
|
|
20105
20105
|
style: _objectSpread2(_objectSpread2({}, _mobileInnerStyle), {}, {
|
|
@@ -20778,7 +20778,7 @@ _defineProperty(Renderer, "defaultProps", {
|
|
|
20778
20778
|
linterContext: PerseusLinter.linterContextDefault
|
|
20779
20779
|
});
|
|
20780
20780
|
|
|
20781
|
-
var styles$
|
|
20781
|
+
var styles$A = {
|
|
20782
20782
|
mobileZoomableParentFix: {
|
|
20783
20783
|
// NOTE(abdul): There is an issue where transform animations will
|
|
20784
20784
|
// cause the Zoomable component to disappear when running on the
|
|
@@ -22054,9 +22054,6 @@ var Tooltip = createReactClass({
|
|
|
22054
22054
|
var {
|
|
22055
22055
|
captureScratchpadTouchStart: captureScratchpadTouchStart$3
|
|
22056
22056
|
} = Util;
|
|
22057
|
-
var MATH = "math";
|
|
22058
|
-
var TEXT = "text";
|
|
22059
|
-
var TEX = "tex";
|
|
22060
22057
|
|
|
22061
22058
|
class InputWithExamples extends React.Component {
|
|
22062
22059
|
constructor() {
|
|
@@ -22074,7 +22071,7 @@ class InputWithExamples extends React.Component {
|
|
|
22074
22071
|
_defineProperty(this, "_getInputClassName", () => {
|
|
22075
22072
|
// <MathOutput> is a special component that manages its own class and
|
|
22076
22073
|
// state, as it's a <span> that wants to act like an <input>.
|
|
22077
|
-
if (this.props.type ===
|
|
22074
|
+
if (this.props.type === "tex") {
|
|
22078
22075
|
return this.props.className;
|
|
22079
22076
|
} // Otherwise, we need to add these INPUT and FOCUSED tags here.
|
|
22080
22077
|
|
|
@@ -22109,7 +22106,7 @@ class InputWithExamples extends React.Component {
|
|
|
22109
22106
|
style: this.props.style
|
|
22110
22107
|
};
|
|
22111
22108
|
|
|
22112
|
-
if (this.props.type ===
|
|
22109
|
+
if (this.props.type === "tex") {
|
|
22113
22110
|
return inputProps;
|
|
22114
22111
|
} // Add useful props required for MATH and TEXT modes
|
|
22115
22112
|
|
|
@@ -22120,7 +22117,7 @@ class InputWithExamples extends React.Component {
|
|
|
22120
22117
|
}); // And add final props that are MATH- and TEXT-specific
|
|
22121
22118
|
|
|
22122
22119
|
|
|
22123
|
-
if (this.props.type ===
|
|
22120
|
+
if (this.props.type === "math") {
|
|
22124
22121
|
return _.extend({
|
|
22125
22122
|
buttonSet: this.props.buttonSet,
|
|
22126
22123
|
buttonsVisible: this.props.buttonsVisible,
|
|
@@ -22128,7 +22125,7 @@ class InputWithExamples extends React.Component {
|
|
|
22128
22125
|
}, inputProps);
|
|
22129
22126
|
}
|
|
22130
22127
|
|
|
22131
|
-
if (this.props.type ===
|
|
22128
|
+
if (this.props.type === "text") {
|
|
22132
22129
|
return _.extend({
|
|
22133
22130
|
autoCapitalize: "off",
|
|
22134
22131
|
autoComplete: "off",
|
|
@@ -22140,16 +22137,17 @@ class InputWithExamples extends React.Component {
|
|
|
22140
22137
|
|
|
22141
22138
|
_defineProperty(this, "_getComponentForInputType", () => {
|
|
22142
22139
|
switch (this.props.type) {
|
|
22143
|
-
case
|
|
22140
|
+
case "tex":
|
|
22144
22141
|
return MathOutput;
|
|
22145
22142
|
|
|
22146
|
-
case
|
|
22143
|
+
case "math":
|
|
22147
22144
|
return MathInput;
|
|
22148
22145
|
|
|
22149
|
-
case
|
|
22146
|
+
case "text":
|
|
22150
22147
|
return TextInput;
|
|
22151
22148
|
|
|
22152
22149
|
default:
|
|
22150
|
+
this.props.type;
|
|
22153
22151
|
return null;
|
|
22154
22152
|
}
|
|
22155
22153
|
});
|
|
@@ -22210,7 +22208,7 @@ class InputWithExamples extends React.Component {
|
|
|
22210
22208
|
// other types require, and is hence handled separately.
|
|
22211
22209
|
|
|
22212
22210
|
|
|
22213
|
-
if (this.props.type ===
|
|
22211
|
+
if (this.props.type === "tex") {
|
|
22214
22212
|
return input;
|
|
22215
22213
|
} // Else, we need to be able to show examples
|
|
22216
22214
|
|
|
@@ -22241,7 +22239,7 @@ class InputWithExamples extends React.Component {
|
|
|
22241
22239
|
}
|
|
22242
22240
|
|
|
22243
22241
|
_defineProperty(InputWithExamples, "defaultProps", {
|
|
22244
|
-
type:
|
|
22242
|
+
type: "text",
|
|
22245
22243
|
shouldShowExamples: true,
|
|
22246
22244
|
onFocus: function onFocus() {},
|
|
22247
22245
|
onBlur: function onBlur() {},
|
|
@@ -23241,20 +23239,33 @@ class InputNumber extends React.Component {
|
|
|
23241
23239
|
answers: answerStrings
|
|
23242
23240
|
});
|
|
23243
23241
|
}
|
|
23242
|
+
} // Note: This is _very_ similar to what `numeric-input.jsx` does. If
|
|
23243
|
+
// you modify this, double-check if you also need to modify that
|
|
23244
|
+
// component.
|
|
23245
|
+
|
|
23246
|
+
|
|
23247
|
+
var inputStyles = [styles$z.default, this.props.size === "small" ? styles$z.small : null, this.props.rightAlign ? styles$z.rightAlign : styles$z.leftAlign]; // Correct
|
|
23248
|
+
|
|
23249
|
+
if (rubric && correct && this.props.currentValue) {
|
|
23250
|
+
inputStyles.push(styles$z.answerStateCorrect);
|
|
23251
|
+
} // Incorrect
|
|
23252
|
+
|
|
23253
|
+
|
|
23254
|
+
if (rubric && !correct && this.props.currentValue) {
|
|
23255
|
+
inputStyles.push(styles$z.answerStateIncorrect);
|
|
23256
|
+
} // Unanswered
|
|
23257
|
+
|
|
23258
|
+
|
|
23259
|
+
if (rubric && !this.props.currentValue) {
|
|
23260
|
+
inputStyles.push(styles$z.answerStateUnanswered);
|
|
23244
23261
|
}
|
|
23245
23262
|
|
|
23246
|
-
var classes = {};
|
|
23247
|
-
classes["perseus-input-size-" + this.props.size] = true;
|
|
23248
|
-
classes["perseus-input-right-align"] = this.props.rightAlign;
|
|
23249
|
-
classes[ClassNames.CORRECT] = rubric && correct && this.props.currentValue;
|
|
23250
|
-
classes[ClassNames.INCORRECT] = rubric && !correct && this.props.currentValue;
|
|
23251
|
-
classes[ClassNames.UNANSWERED] = rubric && !this.props.currentValue;
|
|
23252
23263
|
var input = /*#__PURE__*/React.createElement(InputWithExamples // eslint-disable-next-line react/no-string-refs
|
|
23253
23264
|
, {
|
|
23254
23265
|
ref: "input",
|
|
23255
23266
|
value: this.props.currentValue,
|
|
23256
23267
|
onChange: this.handleChange,
|
|
23257
|
-
|
|
23268
|
+
style: inputStyles,
|
|
23258
23269
|
type: this._getInputType(),
|
|
23259
23270
|
examples: this.examples(),
|
|
23260
23271
|
shouldShowExamples: this.shouldShowExamples(),
|
|
@@ -23350,6 +23361,39 @@ _defineProperty(InputNumber, "defaultProps", {
|
|
|
23350
23361
|
linterContext: linterContextDefault
|
|
23351
23362
|
});
|
|
23352
23363
|
|
|
23364
|
+
var styles$z = StyleSheet.create({
|
|
23365
|
+
default: {
|
|
23366
|
+
width: 80,
|
|
23367
|
+
height: "auto"
|
|
23368
|
+
},
|
|
23369
|
+
small: {
|
|
23370
|
+
width: 40
|
|
23371
|
+
},
|
|
23372
|
+
leftAlign: {
|
|
23373
|
+
paddingLeft: Spacing.xxxSmall_4,
|
|
23374
|
+
paddingRight: 0
|
|
23375
|
+
},
|
|
23376
|
+
rightAlign: {
|
|
23377
|
+
textAlign: "right",
|
|
23378
|
+
paddingLeft: 0,
|
|
23379
|
+
paddingRight: Spacing.xxxSmall_4
|
|
23380
|
+
},
|
|
23381
|
+
answerStateCorrect: {
|
|
23382
|
+
color: satCorrectColor,
|
|
23383
|
+
backgroundColor: satCorrectBackgroundColor,
|
|
23384
|
+
border: "solid 1px ".concat(satCorrectBorderColor)
|
|
23385
|
+
},
|
|
23386
|
+
answerStateIncorrect: {
|
|
23387
|
+
color: satIncorrectColor,
|
|
23388
|
+
backgroundColor: satIncorrectBackgroundColor,
|
|
23389
|
+
border: "solid 1px ".concat(satIncorrectBorderColor)
|
|
23390
|
+
},
|
|
23391
|
+
answerStateUnanswered: {
|
|
23392
|
+
backgroundColor: "#eee",
|
|
23393
|
+
border: "solid 1px #999"
|
|
23394
|
+
}
|
|
23395
|
+
});
|
|
23396
|
+
|
|
23353
23397
|
var propTransform$4 = widgetOptions => {
|
|
23354
23398
|
var {
|
|
23355
23399
|
simplify,
|
|
@@ -23718,7 +23762,10 @@ class NumericInput extends React.Component {
|
|
|
23718
23762
|
onFocus: this._handleFocus,
|
|
23719
23763
|
onBlur: this._handleBlur
|
|
23720
23764
|
}));
|
|
23721
|
-
}
|
|
23765
|
+
} // Note: This is _very_ similar to what `input-number.jsx` does. If
|
|
23766
|
+
// you modify this, double-check if you also need to modify that
|
|
23767
|
+
// component.
|
|
23768
|
+
|
|
23722
23769
|
|
|
23723
23770
|
var styles = StyleSheet.create({
|
|
23724
23771
|
input: {
|
|
@@ -27403,7 +27450,8 @@ function Choice(props) {
|
|
|
27403
27450
|
disabled: disabled || apiOptions.staticRender || apiOptions.readOnly,
|
|
27404
27451
|
style: {
|
|
27405
27452
|
flex: 1,
|
|
27406
|
-
color: Color.offBlack
|
|
27453
|
+
color: Color.offBlack,
|
|
27454
|
+
userSelect: "text"
|
|
27407
27455
|
},
|
|
27408
27456
|
ref: forwardedRef,
|
|
27409
27457
|
"aria-hidden": "true"
|