@khanacademy/perseus 12.3.0 → 13.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/CHANGELOG.md +38 -0
- package/dist/es/index.css +3 -3
- package/dist/es/index.js +593 -223
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9698 -9446
- package/dist/index.js.map +1 -1
- package/dist/item-renderer.d.ts +3 -1
- package/dist/perseus-types.d.ts +4 -2
- package/dist/widgets/label-image/strings.d.ts +3 -0
- package/dist/widgets/plotter.d.ts +8 -22
- package/package.json +10 -8
- package/src/__tests__/item-renderer.test.tsx +41 -0
- package/src/__tests__/widget-container.test.tsx +126 -0
- package/src/error-boundary.tsx +1 -0
- package/src/index.ts +5 -1
- package/src/item-renderer.tsx +4 -2
- package/src/perseus-types.ts +11 -2
- package/src/styles/articles.less +3 -1
- package/src/styles/perseus-renderer.less +1 -1
- package/src/widget-container.tsx +2 -1
- package/src/widgets/__tests__/__snapshots__/graded-group-set.test.ts.snap +50 -19
- package/src/widgets/__tests__/plotter.test.tsx +11 -8
- package/src/widgets/graded-group-set.tsx +70 -25
- package/src/widgets/label-image/strings.ts +3 -0
- package/src/widgets/plotter.tsx +29 -50
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/es/index.js
CHANGED
|
@@ -81,6 +81,7 @@ const customKeyTranslator = _extends({}, keyTranslator, {
|
|
|
81
81
|
class MathInput extends React.Component {
|
|
82
82
|
constructor(...args) {
|
|
83
83
|
super(...args);
|
|
84
|
+
// @ts-expect-error - TS2564 - Property 'mouseDown' has no initializer and is not definitely assigned in the constructor.
|
|
84
85
|
this.mouseDown = void 0;
|
|
85
86
|
this.__mathFieldWrapperRef = null;
|
|
86
87
|
this.__mathField = null;
|
|
@@ -94,7 +95,7 @@ class MathInput extends React.Component {
|
|
|
94
95
|
const inputModifier = customKeyTranslator[value];
|
|
95
96
|
if (inputModifier) {
|
|
96
97
|
inputModifier(input, value);
|
|
97
|
-
input == null
|
|
98
|
+
input == null || input.focus();
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -105,11 +106,11 @@ class MathInput extends React.Component {
|
|
|
105
106
|
if (_(value).isFunction()) {
|
|
106
107
|
value(input);
|
|
107
108
|
} else if (value[0] === "\\") {
|
|
108
|
-
input == null
|
|
109
|
+
input == null || input.cmd(value).focus();
|
|
109
110
|
} else {
|
|
110
|
-
input == null
|
|
111
|
+
input == null || input.write(value).focus();
|
|
111
112
|
}
|
|
112
|
-
input == null
|
|
113
|
+
input == null || input.focus();
|
|
113
114
|
};
|
|
114
115
|
this.mathField = () => {
|
|
115
116
|
if (!this.__mathField && this.__mathFieldWrapperRef) {
|
|
@@ -179,11 +180,13 @@ class MathInput extends React.Component {
|
|
|
179
180
|
};
|
|
180
181
|
this.focus = () => {
|
|
181
182
|
var _this$mathField;
|
|
182
|
-
(_this$mathField = this.mathField()) == null
|
|
183
|
+
(_this$mathField = this.mathField()) == null || _this$mathField.focus();
|
|
183
184
|
this.setState({
|
|
184
185
|
focused: true
|
|
185
186
|
});
|
|
186
187
|
};
|
|
188
|
+
// removing mathfield focus here makes the cursor vanished when the
|
|
189
|
+
// input is still focused
|
|
187
190
|
this.blur = () => this.setState({
|
|
188
191
|
focused: false
|
|
189
192
|
});
|
|
@@ -213,7 +216,7 @@ class MathInput extends React.Component {
|
|
|
213
216
|
var _this$mathField2;
|
|
214
217
|
// Ideally, we would be able to pass an initial value directly into
|
|
215
218
|
// the constructor
|
|
216
|
-
(_this$mathField2 = this.mathField()) == null
|
|
219
|
+
(_this$mathField2 = this.mathField()) == null || _this$mathField2.latex(this.props.value);
|
|
217
220
|
}
|
|
218
221
|
openKeypad() {
|
|
219
222
|
if (this.props.buttonsVisible === "never") {
|
|
@@ -433,7 +436,6 @@ var dependencies = /*#__PURE__*/Object.freeze({
|
|
|
433
436
|
// TODO(LP-11481): Change the primary API we use for logging in Perseus to use
|
|
434
437
|
// getDependencies() internally... simplify usage to just using a "singleton"
|
|
435
438
|
// which get's the injected logger.
|
|
436
|
-
|
|
437
439
|
/**
|
|
438
440
|
* @typedef {Object} Errors utility for referencing the Perseus error taxonomy.
|
|
439
441
|
*/
|
|
@@ -476,6 +478,10 @@ const Errors = Object.freeze({
|
|
|
476
478
|
* @type {ErrorKind} The kind of error being reported
|
|
477
479
|
*/
|
|
478
480
|
|
|
481
|
+
/**
|
|
482
|
+
* Provides logging infrastructure for Perseus
|
|
483
|
+
*/
|
|
484
|
+
|
|
479
485
|
const Log = {
|
|
480
486
|
// Logs a message
|
|
481
487
|
log: (message, extra) => {
|
|
@@ -1203,6 +1209,10 @@ const KhanMath = {
|
|
|
1203
1209
|
|
|
1204
1210
|
/* eslint-disable no-useless-escape */
|
|
1205
1211
|
const MAXERROR_EPSILON = Math.pow(2, -42);
|
|
1212
|
+
|
|
1213
|
+
// TOOD(kevinb): Figure out how this relates to KEScore in
|
|
1214
|
+
// perseus-all-package/types.js and see if there's a way to
|
|
1215
|
+
// unify these types.
|
|
1206
1216
|
const errors = {
|
|
1207
1217
|
APPROXIMATED_PI_ERROR: i18n._("Your answer is close, but you may " + "have approximated pi. Enter your " + "answer as a multiple of pi, like " + "<code>12\\ \\text{pi}</code> or " + "<code>2/3\\ \\text{pi}</code>"),
|
|
1208
1218
|
EXTRA_SYMBOLS_ERROR: i18n._("We could not understand your " + "answer. Please check your answer for extra " + "text or symbols."),
|
|
@@ -1934,6 +1944,10 @@ class Expression extends React.Component {
|
|
|
1934
1944
|
// this.isMounted() but is still considered an anti-pattern.
|
|
1935
1945
|
this._isMounted = true;
|
|
1936
1946
|
};
|
|
1947
|
+
// Whenever the input value changes, attempt to parse it.
|
|
1948
|
+
//
|
|
1949
|
+
// Clear any errors if this parse succeeds, show an error within a second
|
|
1950
|
+
// if it fails.
|
|
1937
1951
|
this.componentDidUpdate = prevProps => {
|
|
1938
1952
|
if (!_.isEqual(this.props.value, prevProps.value) || !_.isEqual(this.props.functions, prevProps.functions)) {
|
|
1939
1953
|
this.setState({
|
|
@@ -1974,7 +1988,7 @@ class Expression extends React.Component {
|
|
|
1974
1988
|
// otherwise, we may just be checking validity after changes.
|
|
1975
1989
|
if (scoring && score.type !== "invalid") {
|
|
1976
1990
|
var _this$props$analytics;
|
|
1977
|
-
(_this$props$analytics = this.props.analytics) == null
|
|
1991
|
+
(_this$props$analytics = this.props.analytics) == null || _this$props$analytics.onAnalyticsEvent({
|
|
1978
1992
|
type: "perseus:expression-evaluated",
|
|
1979
1993
|
payload: {
|
|
1980
1994
|
result: score.earned === score.total ? "correct" : "incorrect",
|
|
@@ -2005,7 +2019,7 @@ class Expression extends React.Component {
|
|
|
2005
2019
|
};
|
|
2006
2020
|
this._handleFocus = () => {
|
|
2007
2021
|
var _this$props$analytics2;
|
|
2008
|
-
(_this$props$analytics2 = this.props.analytics) == null
|
|
2022
|
+
(_this$props$analytics2 = this.props.analytics) == null || _this$props$analytics2.onAnalyticsEvent({
|
|
2009
2023
|
type: "perseus:expression-focused",
|
|
2010
2024
|
payload: null
|
|
2011
2025
|
});
|
|
@@ -2041,6 +2055,7 @@ class Expression extends React.Component {
|
|
|
2041
2055
|
/* c8 ignore next */
|
|
2042
2056
|
return [[]];
|
|
2043
2057
|
};
|
|
2058
|
+
// TODO(Nicole): I believe this is going away and won't be needed anymore
|
|
2044
2059
|
this.getGrammarTypeForPath = inputPath => {
|
|
2045
2060
|
/* c8 ignore next */
|
|
2046
2061
|
return "expression";
|
|
@@ -2228,7 +2243,7 @@ class Expression extends React.Component {
|
|
|
2228
2243
|
// this.props.keypadElement should always be set
|
|
2229
2244
|
// when apiOptions.customKeypad is set, but how
|
|
2230
2245
|
// to convince TypeScript of this?
|
|
2231
|
-
(_this$props$keypadEle = this.props.keypadElement) == null
|
|
2246
|
+
(_this$props$keypadEle = this.props.keypadElement) == null || _this$props$keypadEle.configure(this.props.keypadConfiguration, () => {
|
|
2232
2247
|
if (this._isMounted) {
|
|
2233
2248
|
this._handleFocus();
|
|
2234
2249
|
}
|
|
@@ -2472,6 +2487,9 @@ async function getImageSizeModern(url) {
|
|
|
2472
2487
|
}
|
|
2473
2488
|
|
|
2474
2489
|
/* eslint-disable @babel/no-invalid-this, getter-return, one-var */
|
|
2490
|
+
|
|
2491
|
+
// TODO: dedupe this with Coord in interactive2/types.js
|
|
2492
|
+
|
|
2475
2493
|
let supportsPassive = false;
|
|
2476
2494
|
const nestedMap$2 = function nestedMap(children, func, context) {
|
|
2477
2495
|
if (Array.isArray(children)) {
|
|
@@ -3152,12 +3170,12 @@ function getImageSize(url, callback) {
|
|
|
3152
3170
|
// width in a full-screen article.
|
|
3153
3171
|
if (img.width === 0 && img.height === 0) {
|
|
3154
3172
|
var _document$body;
|
|
3155
|
-
(_document$body = document.body) == null
|
|
3173
|
+
(_document$body = document.body) == null || _document$body.appendChild(img);
|
|
3156
3174
|
// TODO(scottgrant): Remove this use of _.defer.
|
|
3157
3175
|
_.defer(function () {
|
|
3158
3176
|
var _document$body2;
|
|
3159
3177
|
callback(img.clientWidth, img.clientHeight);
|
|
3160
|
-
(_document$body2 = document.body) == null
|
|
3178
|
+
(_document$body2 = document.body) == null || _document$body2.removeChild(img);
|
|
3161
3179
|
});
|
|
3162
3180
|
} else {
|
|
3163
3181
|
callback(img.width, img.height);
|
|
@@ -3561,11 +3579,11 @@ Zoom.prototype._zoomOriginal = function () {
|
|
|
3561
3579
|
$(this._targetImage).css("visibility", "hidden");
|
|
3562
3580
|
this._backdrop = document.createElement("div");
|
|
3563
3581
|
this._backdrop.className = "zoom-backdrop";
|
|
3564
|
-
(_document$body = document.body) == null
|
|
3582
|
+
(_document$body = document.body) == null || _document$body.appendChild(this._backdrop);
|
|
3565
3583
|
this._overlay = document.createElement("div");
|
|
3566
3584
|
this._overlay.className = "zoom-overlay";
|
|
3567
|
-
(_document$body2 = document.body) == null
|
|
3568
|
-
(_this$_overlay = this._overlay) == null
|
|
3585
|
+
(_document$body2 = document.body) == null || _document$body2.appendChild(this._overlay);
|
|
3586
|
+
(_this$_overlay = this._overlay) == null || _this$_overlay.appendChild(this.$zoomedImage[0]);
|
|
3569
3587
|
this._calculateZoom();
|
|
3570
3588
|
this._triggerAnimation();
|
|
3571
3589
|
};
|
|
@@ -10593,7 +10611,7 @@ _.extend(GraphUtils.Graphie.prototype, {
|
|
|
10593
10611
|
}
|
|
10594
10612
|
}
|
|
10595
10613
|
if (!options.allowScratchpad) {
|
|
10596
|
-
options.setDrawingAreaAvailable == null
|
|
10614
|
+
options.setDrawingAreaAvailable == null || options.setDrawingAreaAvailable(false);
|
|
10597
10615
|
}
|
|
10598
10616
|
|
|
10599
10617
|
// Add mouse and visible wrapper layers for DOM-node-wrapped movables
|
|
@@ -16061,10 +16079,19 @@ class Graphie extends React.Component {
|
|
|
16061
16079
|
constructor(...args) {
|
|
16062
16080
|
super(...args);
|
|
16063
16081
|
this.graphieDivRef = /*#__PURE__*/React.createRef();
|
|
16082
|
+
/**
|
|
16083
|
+
* Allow parents of the <Graphie> component to grab a reference to the
|
|
16084
|
+
* underlying graphie object using
|
|
16085
|
+
* `this.refs.graphieComponent.getGraphie()`
|
|
16086
|
+
*
|
|
16087
|
+
* This shouldn't be necessary for 90% of cases, but the power is there.
|
|
16088
|
+
* Use it for good and not evil.
|
|
16089
|
+
*/
|
|
16064
16090
|
this.getGraphie = () => {
|
|
16065
16091
|
// @ts-expect-error - TS2339 - Property '_graphie' does not exist on type 'Graphie'.
|
|
16066
16092
|
return this._graphie;
|
|
16067
16093
|
};
|
|
16094
|
+
// bounds-checked range
|
|
16068
16095
|
this._range = () => {
|
|
16069
16096
|
const boundsCheckRange = range => {
|
|
16070
16097
|
if (range[0] >= range[1]) {
|
|
@@ -16139,6 +16166,7 @@ class Graphie extends React.Component {
|
|
|
16139
16166
|
// @ts-expect-error - TS2339 - Property '_movables' does not exist on type 'Graphie'.
|
|
16140
16167
|
this._movables = {};
|
|
16141
16168
|
};
|
|
16169
|
+
// @ts-expect-error - TS2322 - Type '(children: readonly any[], options: any) => ReactElement<any, string | JSXElementConstructor<any>> | readonly ReactElement<any, string | JSXElementConstructor<any>>[]' is not assignable to type '(children: readonly any[], arg2: any) => ReactElement<any, string | JSXElementConstructor<any>>'.
|
|
16142
16170
|
this._renderMovables = (children, options) => {
|
|
16143
16171
|
// Each leaf of `children` is a movable descriptor created by a call to
|
|
16144
16172
|
// some `GraphieMovable`, such as `MovablePoint`.
|
|
@@ -16237,6 +16265,7 @@ class Graphie extends React.Component {
|
|
|
16237
16265
|
return newMovables[key];
|
|
16238
16266
|
});
|
|
16239
16267
|
};
|
|
16268
|
+
// Sort of like react diffing, but for movables
|
|
16240
16269
|
this._updateMovables = () => {
|
|
16241
16270
|
// @ts-expect-error - TS2339 - Property '_graphie' does not exist on type 'Graphie'.
|
|
16242
16271
|
const graphie = this._graphie;
|
|
@@ -16291,16 +16320,6 @@ class Graphie extends React.Component {
|
|
|
16291
16320
|
}
|
|
16292
16321
|
this._updateMovables();
|
|
16293
16322
|
}
|
|
16294
|
-
|
|
16295
|
-
/**
|
|
16296
|
-
* Allow parents of the <Graphie> component to grab a reference to the
|
|
16297
|
-
* underlying graphie object using
|
|
16298
|
-
* `this.refs.graphieComponent.getGraphie()`
|
|
16299
|
-
*
|
|
16300
|
-
* This shouldn't be necessary for 90% of cases, but the power is there.
|
|
16301
|
-
* Use it for good and not evil.
|
|
16302
|
-
*/
|
|
16303
|
-
|
|
16304
16323
|
render() {
|
|
16305
16324
|
return /*#__PURE__*/React.createElement("div", {
|
|
16306
16325
|
className: "graphie-container"
|
|
@@ -17043,10 +17062,14 @@ Tex.defaultProps = {
|
|
|
17043
17062
|
class Zoomable extends React.Component {
|
|
17044
17063
|
constructor(...args) {
|
|
17045
17064
|
super(...args);
|
|
17065
|
+
// @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
|
|
17046
17066
|
this._isMounted = void 0;
|
|
17067
|
+
// @ts-expect-error - TS2564 - Property '_observer' has no initializer and is not definitely assigned in the constructor.
|
|
17047
17068
|
this._observer = void 0;
|
|
17069
|
+
// @ts-expect-error - TS2564 - Property '_measuringInitialized' has no initializer and is not definitely assigned in the constructor.
|
|
17048
17070
|
this._measuringInitialized = void 0;
|
|
17049
17071
|
this._originalWidth = void 0;
|
|
17072
|
+
// @ts-expect-error - TS2564 - Property '_node' has no initializer and is not definitely assigned in the constructor.
|
|
17050
17073
|
this._node = void 0;
|
|
17051
17074
|
this.state = {
|
|
17052
17075
|
visible: false,
|
|
@@ -17312,9 +17335,11 @@ const DefinitionContext = /*#__PURE__*/React.createContext(defaultContext$1);
|
|
|
17312
17335
|
class DefinitionProvider extends React.Component {
|
|
17313
17336
|
constructor(...args) {
|
|
17314
17337
|
super(...args);
|
|
17338
|
+
// Context state
|
|
17315
17339
|
this.state = {
|
|
17316
17340
|
activeDefinitionId: null
|
|
17317
17341
|
};
|
|
17342
|
+
// Method to update state
|
|
17318
17343
|
this.setActiveDefinitionId = activeDefinitionId => {
|
|
17319
17344
|
this.setState(prevState => ({
|
|
17320
17345
|
activeDefinitionId
|
|
@@ -17349,9 +17374,11 @@ class ErrorBoundary extends React.Component {
|
|
|
17349
17374
|
};
|
|
17350
17375
|
}
|
|
17351
17376
|
componentDidCatch(error, info) {
|
|
17377
|
+
var _this$props$onError, _this$props;
|
|
17352
17378
|
this.setState({
|
|
17353
17379
|
error: error.toString()
|
|
17354
17380
|
});
|
|
17381
|
+
(_this$props$onError = (_this$props = this.props).onError) == null || _this$props$onError.call(_this$props, error, info);
|
|
17355
17382
|
Log.error("Perseus error boundary caught error", Errors.Internal, {
|
|
17356
17383
|
cause: error,
|
|
17357
17384
|
loggedMetadata: _extends({
|
|
@@ -17389,21 +17416,25 @@ function _noop() {}
|
|
|
17389
17416
|
* Wrapper for the trackInteraction apiOption.
|
|
17390
17417
|
*/
|
|
17391
17418
|
class InteractionTracker {
|
|
17392
|
-
// @ts-expect-error - TS2564 - Property '_tracked' has no initializer and is not definitely assigned in the constructor.
|
|
17393
|
-
|
|
17394
|
-
// @ts-expect-error - TS2564 - Property 'setting' has no initializer and is not definitely assigned in the constructor.
|
|
17395
|
-
|
|
17396
|
-
// @ts-expect-error - TS2564 - Property 'widgetID' has no initializer and is not definitely assigned in the constructor.
|
|
17397
|
-
|
|
17398
|
-
// @ts-expect-error - TS2564 - Property 'widgetType' has no initializer and is not definitely assigned in the constructor.
|
|
17399
|
-
|
|
17400
17419
|
constructor(trackApi, widgetType, widgetID, setting) {
|
|
17420
|
+
// @ts-expect-error - TS2564 - Property '_tracked' has no initializer and is not definitely assigned in the constructor.
|
|
17401
17421
|
this._tracked = void 0;
|
|
17422
|
+
// @ts-expect-error - TS2564 - Property 'setting' has no initializer and is not definitely assigned in the constructor.
|
|
17402
17423
|
this.setting = void 0;
|
|
17403
17424
|
this.track = void 0;
|
|
17404
17425
|
this.trackApi = void 0;
|
|
17426
|
+
// @ts-expect-error - TS2564 - Property 'widgetID' has no initializer and is not definitely assigned in the constructor.
|
|
17405
17427
|
this.widgetID = void 0;
|
|
17428
|
+
// @ts-expect-error - TS2564 - Property 'widgetType' has no initializer and is not definitely assigned in the constructor.
|
|
17406
17429
|
this.widgetType = void 0;
|
|
17430
|
+
/**
|
|
17431
|
+
* Function that actually calls the API to mark the interaction. This is
|
|
17432
|
+
* private. The public version is just `.track` and is bound to this object
|
|
17433
|
+
* for easy use in other context.
|
|
17434
|
+
*
|
|
17435
|
+
* @param extraData Any extra data to track about the event.
|
|
17436
|
+
* @private
|
|
17437
|
+
*/
|
|
17407
17438
|
this._track = extraData => {
|
|
17408
17439
|
if (this._tracked && !this.setting) {
|
|
17409
17440
|
return;
|
|
@@ -17425,15 +17456,6 @@ class InteractionTracker {
|
|
|
17425
17456
|
this.track = this._track;
|
|
17426
17457
|
}
|
|
17427
17458
|
}
|
|
17428
|
-
|
|
17429
|
-
/**
|
|
17430
|
-
* Function that actually calls the API to mark the interaction. This is
|
|
17431
|
-
* private. The public version is just `.track` and is bound to this object
|
|
17432
|
-
* for easy use in other context.
|
|
17433
|
-
*
|
|
17434
|
-
* @param extraData Any extra data to track about the event.
|
|
17435
|
-
* @private
|
|
17436
|
-
*/
|
|
17437
17459
|
}
|
|
17438
17460
|
|
|
17439
17461
|
/**
|
|
@@ -17519,6 +17541,10 @@ class Lint extends React.Component {
|
|
|
17519
17541
|
this.state = {
|
|
17520
17542
|
tooltipAbove: true
|
|
17521
17543
|
};
|
|
17544
|
+
// We can't call setState in componentDidMount without risking a render
|
|
17545
|
+
// thrash, and we can't call getBoundingClientRect in render, so we
|
|
17546
|
+
// borrow a timeout approach from learnstorm-dashboard.jsx and set our
|
|
17547
|
+
// state once the component has mounted and we can get what we need.
|
|
17522
17548
|
this.getPosition = () => {
|
|
17523
17549
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'getBoundingClientRect' does not exist on type 'Element | Text'.
|
|
17524
17550
|
const rect = ReactDOM__default.findDOMNode(this).getBoundingClientRect();
|
|
@@ -17529,6 +17555,8 @@ class Lint extends React.Component {
|
|
|
17529
17555
|
tooltipAbove: rect.top > 100
|
|
17530
17556
|
});
|
|
17531
17557
|
};
|
|
17558
|
+
// Render the <a> element that holds the indicator icon and the tooltip
|
|
17559
|
+
// We pass different styles for the inline and block cases
|
|
17532
17560
|
this.renderLink = style => {
|
|
17533
17561
|
const tooltipAbove = this.state.tooltipAbove;
|
|
17534
17562
|
let severityStyle;
|
|
@@ -17575,12 +17603,6 @@ class Lint extends React.Component {
|
|
|
17575
17603
|
// eslint-disable-next-line no-restricted-syntax
|
|
17576
17604
|
window.clearTimeout(this._positionTimeout);
|
|
17577
17605
|
}
|
|
17578
|
-
|
|
17579
|
-
// We can't call setState in componentDidMount without risking a render
|
|
17580
|
-
// thrash, and we can't call getBoundingClientRect in render, so we
|
|
17581
|
-
// borrow a timeout approach from learnstorm-dashboard.jsx and set our
|
|
17582
|
-
// state once the component has mounted and we can get what we need.
|
|
17583
|
-
|
|
17584
17606
|
// The main render method surrounds linty content with a block or
|
|
17585
17607
|
// inline container and the link element that displays the indicator
|
|
17586
17608
|
// and holds the tooltip.
|
|
@@ -18196,12 +18218,26 @@ class QuestionParagraph extends React.Component {
|
|
|
18196
18218
|
* anything in non-KA environments.
|
|
18197
18219
|
*/
|
|
18198
18220
|
|
|
18221
|
+
// A LintCB is called once the linter has been run.
|
|
18222
|
+
|
|
18199
18223
|
// msec to wait before we actually call the linter after receiving the
|
|
18200
18224
|
// last call. The timer is reset if the lint is called during the wait.
|
|
18201
18225
|
const DEBOUNCE_TIMEOUT = 1000;
|
|
18202
18226
|
class TranslationLinter {
|
|
18203
18227
|
constructor() {
|
|
18228
|
+
// To avoid linting when nothing has changed.
|
|
18204
18229
|
this.previousContent = null;
|
|
18230
|
+
/**
|
|
18231
|
+
* Runs the poentry linter on the given perseus string asynchronously.
|
|
18232
|
+
*
|
|
18233
|
+
* It doesn't do anything unless we're in a KA environment.
|
|
18234
|
+
*
|
|
18235
|
+
* onLintErrorsGenerated is called even if there are no errors. It is not
|
|
18236
|
+
* called if perseusStr is unchanged from the last call.
|
|
18237
|
+
*
|
|
18238
|
+
* Linting is relatively expensive -- so we debounce linting each instance
|
|
18239
|
+
* for some amount of time.
|
|
18240
|
+
*/
|
|
18205
18241
|
this.runLinter = debounce((perseusStr, onLintErrorsGenerated) => {
|
|
18206
18242
|
// TODO(FEI-5003): Do we still need to check for 'KA'?
|
|
18207
18243
|
if (typeof KA === "undefined") {
|
|
@@ -18807,11 +18843,12 @@ class WidgetContainer extends React.Component {
|
|
|
18807
18843
|
widget_type: type,
|
|
18808
18844
|
widget_id: this.props.id
|
|
18809
18845
|
},
|
|
18810
|
-
onError:
|
|
18846
|
+
onError: () => {
|
|
18811
18847
|
analytics.onAnalyticsEvent({
|
|
18812
18848
|
type: "perseus:widget-rendering-error",
|
|
18813
18849
|
payload: {
|
|
18814
|
-
widgetType: type
|
|
18850
|
+
widgetType: type,
|
|
18851
|
+
widgetId: this.props.id
|
|
18815
18852
|
}
|
|
18816
18853
|
});
|
|
18817
18854
|
}
|
|
@@ -18864,35 +18901,33 @@ const isIdPathPrefix = function isIdPathPrefix(prefixArray, wholeArray) {
|
|
|
18864
18901
|
}
|
|
18865
18902
|
});
|
|
18866
18903
|
};
|
|
18867
|
-
class Renderer extends React.Component {
|
|
18868
|
-
// @ts-expect-error - TS2564 - Property '_foundTextNodes' has no initializer and is not definitely assigned in the constructor.
|
|
18869
|
-
|
|
18870
|
-
// @ts-expect-error - TS2564 - Property '_interactionTrackers' has no initializer and is not definitely assigned in the constructor.
|
|
18871
|
-
|
|
18872
|
-
// @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
|
|
18873
|
-
|
|
18874
|
-
// @ts-expect-error - TS2564 - Property '_isTwoColumn' has no initializer and is not definitely assigned in the constructor.
|
|
18875
|
-
|
|
18876
|
-
// The i18n linter.
|
|
18877
|
-
|
|
18878
|
-
// @ts-expect-error - TS2564 - Property 'reuseMarkdown' has no initializer and is not definitely assigned in the constructor.
|
|
18879
|
-
|
|
18880
|
-
// @ts-expect-error - TS2564 - Property 'translationIndex' has no initializer and is not definitely assigned in the constructor.
|
|
18881
|
-
|
|
18882
|
-
// @ts-expect-error - TS2564 - Property 'widgetIds' has no initializer and is not definitely assigned in the constructor.
|
|
18883
18904
|
|
|
18905
|
+
// The return type for getUserInput. Widgets have full control of what is
|
|
18906
|
+
// returned so it's not easily typed (some widgets return a scalar (string),
|
|
18907
|
+
// some return a custom-built object, some delegate to
|
|
18908
|
+
// `WidgetJsonifyDeprecated` which returns an object containing widget props
|
|
18909
|
+
// (filtered by deprecated keys)).
|
|
18910
|
+
class Renderer extends React.Component {
|
|
18884
18911
|
constructor(_props) {
|
|
18885
18912
|
super(_props);
|
|
18886
18913
|
this._currentFocus = void 0;
|
|
18914
|
+
// @ts-expect-error - TS2564 - Property '_foundTextNodes' has no initializer and is not definitely assigned in the constructor.
|
|
18887
18915
|
this._foundTextNodes = void 0;
|
|
18916
|
+
// @ts-expect-error - TS2564 - Property '_interactionTrackers' has no initializer and is not definitely assigned in the constructor.
|
|
18888
18917
|
this._interactionTrackers = void 0;
|
|
18918
|
+
// @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
|
|
18889
18919
|
this._isMounted = void 0;
|
|
18920
|
+
// @ts-expect-error - TS2564 - Property '_isTwoColumn' has no initializer and is not definitely assigned in the constructor.
|
|
18890
18921
|
this._isTwoColumn = void 0;
|
|
18922
|
+
// The i18n linter.
|
|
18891
18923
|
this._translationLinter = void 0;
|
|
18892
18924
|
this._widgetContainers = new Map();
|
|
18893
18925
|
this.lastRenderedMarkdown = void 0;
|
|
18926
|
+
// @ts-expect-error - TS2564 - Property 'reuseMarkdown' has no initializer and is not definitely assigned in the constructor.
|
|
18894
18927
|
this.reuseMarkdown = void 0;
|
|
18928
|
+
// @ts-expect-error - TS2564 - Property 'translationIndex' has no initializer and is not definitely assigned in the constructor.
|
|
18895
18929
|
this.translationIndex = void 0;
|
|
18930
|
+
// @ts-expect-error - TS2564 - Property 'widgetIds' has no initializer and is not definitely assigned in the constructor.
|
|
18896
18931
|
this.widgetIds = void 0;
|
|
18897
18932
|
this.getApiOptions = () => {
|
|
18898
18933
|
return _extends({}, ApiOptions.defaults, this.props.apiOptions);
|
|
@@ -18904,6 +18939,7 @@ class Renderer extends React.Component {
|
|
|
18904
18939
|
widgetProps: this._getAllWidgetsStartProps(allWidgetInfo, props)
|
|
18905
18940
|
};
|
|
18906
18941
|
};
|
|
18942
|
+
// @ts-expect-error - TS2322 - Type '(props: Props) => Partial<Record<string, CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ... 35 more ... | VideoWidget>>' is not assignable to type '(props: Props) => { [key: string]: PerseusWidget; }'.
|
|
18907
18943
|
this._getAllWidgetsInfo = props => {
|
|
18908
18944
|
// @ts-expect-error - TS2345 - Argument of type '{ [key: string]: PerseusWidget; }' is not assignable to parameter of type 'Partial<Record<string, CategorizerWidget>>'.
|
|
18909
18945
|
return mapObject$2(props.widgets, (widgetInfo, widgetId) => {
|
|
@@ -18926,6 +18962,11 @@ class Renderer extends React.Component {
|
|
|
18926
18962
|
return getRendererPropsForWidgetInfo(widgetInfo, props.problemNum);
|
|
18927
18963
|
});
|
|
18928
18964
|
};
|
|
18965
|
+
// This is only used in _getWidgetInfo as a fallback if widgetId
|
|
18966
|
+
// doesn't exist in this.state.widgetInfo. It doesn't get run as
|
|
18967
|
+
// part of the happy path.
|
|
18968
|
+
// TODO(LP-10713): Refactor how we handle widgetIds that don't exist
|
|
18969
|
+
// in this.state.widgetInfo.
|
|
18929
18970
|
this._getDefaultWidgetInfo = widgetId => {
|
|
18930
18971
|
const widgetIdParts = Util.rTypeFromWidgetId.exec(widgetId);
|
|
18931
18972
|
if (widgetIdParts == null) {
|
|
@@ -19022,6 +19063,15 @@ class Renderer extends React.Component {
|
|
|
19022
19063
|
isLastUsedWidget: id === this.state.lastUsedWidgetId
|
|
19023
19064
|
});
|
|
19024
19065
|
};
|
|
19066
|
+
/**
|
|
19067
|
+
* Serializes the questions state so it can be recovered.
|
|
19068
|
+
*
|
|
19069
|
+
* The return value of this function can be sent to the
|
|
19070
|
+
* `restoreSerializedState` method to restore this state.
|
|
19071
|
+
*
|
|
19072
|
+
* If an instance of widgetProps is passed in, it generates the serialized
|
|
19073
|
+
* state from that instead of the current widget props.
|
|
19074
|
+
*/
|
|
19025
19075
|
this.getSerializedState = widgetProps => {
|
|
19026
19076
|
return mapObject$2(widgetProps || this.state.widgetProps, (props, widgetId) => {
|
|
19027
19077
|
const widget = this.getWidgetInstance(widgetId);
|
|
@@ -19086,6 +19136,12 @@ class Renderer extends React.Component {
|
|
|
19086
19136
|
setTimeout(fireCallback, 0);
|
|
19087
19137
|
});
|
|
19088
19138
|
};
|
|
19139
|
+
/**
|
|
19140
|
+
* Tell each of the radio widgets to show rationales for each of the
|
|
19141
|
+
* currently selected choices inside of them. If the widget is correct, it
|
|
19142
|
+
* shows rationales for all of the choices. This also disables interaction
|
|
19143
|
+
* with the choices that we show rationales for.
|
|
19144
|
+
*/
|
|
19089
19145
|
this.showRationalesForCurrentlySelectedChoices = () => {
|
|
19090
19146
|
Object.keys(this.props.widgets).forEach(widgetId => {
|
|
19091
19147
|
const widget = this.getWidgetInstance(widgetId);
|
|
@@ -19094,6 +19150,10 @@ class Renderer extends React.Component {
|
|
|
19094
19150
|
}
|
|
19095
19151
|
});
|
|
19096
19152
|
};
|
|
19153
|
+
/**
|
|
19154
|
+
* Tells each of the radio widgets to deselect any of the incorrect choices
|
|
19155
|
+
* that are currently selected (leaving correct choices still selected).
|
|
19156
|
+
*/
|
|
19097
19157
|
this.deselectIncorrectSelectedChoices = () => {
|
|
19098
19158
|
// TODO(emily): this has the exact same structure as
|
|
19099
19159
|
// showRationalesForCurrentlySelectedChoices above. Maybe DRY this up.
|
|
@@ -19104,6 +19164,37 @@ class Renderer extends React.Component {
|
|
|
19104
19164
|
}
|
|
19105
19165
|
});
|
|
19106
19166
|
};
|
|
19167
|
+
/**
|
|
19168
|
+
* Allows inter-widget communication.
|
|
19169
|
+
*
|
|
19170
|
+
* This function yields this Renderer's own internal widgets, and it's used
|
|
19171
|
+
* in two places.
|
|
19172
|
+
*
|
|
19173
|
+
* First, we expose our own internal widgets to each other by giving them
|
|
19174
|
+
* a `findWidgets` function that, in turn, calls this function.
|
|
19175
|
+
*
|
|
19176
|
+
* Second, we expose our own internal widgets to this Renderer's parent,
|
|
19177
|
+
* by allowing it to call this function directly. That way, it can hook us
|
|
19178
|
+
* up to other Renderers on the page, by writing a `findExternalWidgets`
|
|
19179
|
+
* prop that calls each other Renderer's `findInternalWidgets` function.
|
|
19180
|
+
*
|
|
19181
|
+
* Takes a `filterCriterion` on which widgets to return.
|
|
19182
|
+
* `filterCriterion` can be one of:
|
|
19183
|
+
* * A string widget id
|
|
19184
|
+
* * A string widget type
|
|
19185
|
+
* * a function from (id, widgetInfo, widgetComponent) to true or false
|
|
19186
|
+
*
|
|
19187
|
+
* Returns an array of the matching widget components.
|
|
19188
|
+
*
|
|
19189
|
+
* If you need to do logic with more than the components, it is possible
|
|
19190
|
+
* to do such logic inside the filter, rather than on the result array.
|
|
19191
|
+
*
|
|
19192
|
+
* See the passage-ref widget for an example.
|
|
19193
|
+
*
|
|
19194
|
+
* "Remember: abilities are not inherently good or evil, it's how you use
|
|
19195
|
+
* them." ~ Kyle Katarn
|
|
19196
|
+
* Please use this one with caution.
|
|
19197
|
+
*/
|
|
19107
19198
|
this.findInternalWidgets = filterCriterion => {
|
|
19108
19199
|
let filterFunc;
|
|
19109
19200
|
// Convenience filters:
|
|
@@ -19129,6 +19220,14 @@ class Renderer extends React.Component {
|
|
|
19129
19220
|
}).map(this.getWidgetInstance);
|
|
19130
19221
|
return results;
|
|
19131
19222
|
};
|
|
19223
|
+
/**
|
|
19224
|
+
* Allows inter-widget communication.
|
|
19225
|
+
*
|
|
19226
|
+
* Includes both widgets internal to this Renderer, and external widgets
|
|
19227
|
+
* exposed by the `findExternalWidgets` prop.
|
|
19228
|
+
*
|
|
19229
|
+
* See `findInteralWidgets` for more information.
|
|
19230
|
+
*/
|
|
19132
19231
|
this.findWidgets = filterCriterion => {
|
|
19133
19232
|
return [...this.findInternalWidgets(filterCriterion), ...this.props.findExternalWidgets(filterCriterion)];
|
|
19134
19233
|
};
|
|
@@ -19214,6 +19313,9 @@ class Renderer extends React.Component {
|
|
|
19214
19313
|
});
|
|
19215
19314
|
}
|
|
19216
19315
|
};
|
|
19316
|
+
// wrap top-level elements in a QuestionParagraph, mostly
|
|
19317
|
+
// for appropriate spacing and other css
|
|
19318
|
+
// @ts-expect-error - TS2322 - Type '(ast: any, state: WidgetState) => never[] | JSX.Element' is not assignable to type '(ast: any, state: WidgetState) => ReactElement<any, string | JSXElementConstructor<any>>'.
|
|
19217
19319
|
this.outputMarkdown = (ast, state) => {
|
|
19218
19320
|
if (_.isArray(ast)) {
|
|
19219
19321
|
// This is duplicated from simple-markdown
|
|
@@ -19285,6 +19387,7 @@ class Renderer extends React.Component {
|
|
|
19285
19387
|
paragraphIndex: state.paragraphIndex
|
|
19286
19388
|
}, /*#__PURE__*/React.createElement(ErrorBoundary, null, output));
|
|
19287
19389
|
};
|
|
19390
|
+
// output non-top-level nodes or arrays
|
|
19288
19391
|
this.outputNested = (ast, state) => {
|
|
19289
19392
|
if (_.isArray(ast)) {
|
|
19290
19393
|
// This is duplicated from simple-markdown
|
|
@@ -19315,6 +19418,7 @@ class Renderer extends React.Component {
|
|
|
19315
19418
|
}
|
|
19316
19419
|
return this.outputNode(ast, this.outputNested, state);
|
|
19317
19420
|
};
|
|
19421
|
+
// output individual AST nodes [not arrays]
|
|
19318
19422
|
this.outputNode = (node, nestedOutput, state) => {
|
|
19319
19423
|
const apiOptions = this.getApiOptions();
|
|
19320
19424
|
const imagePlaceholder = apiOptions.imagePlaceholder;
|
|
@@ -19548,6 +19652,9 @@ class Renderer extends React.Component {
|
|
|
19548
19652
|
// ...as well as right now (non-image, non-TeX or image from cache)
|
|
19549
19653
|
onRender();
|
|
19550
19654
|
};
|
|
19655
|
+
// Sets the current focus path
|
|
19656
|
+
// If the new focus path is not a prefix of the old focus path,
|
|
19657
|
+
// we send an onChangeFocus event back to our parent.
|
|
19551
19658
|
this._setCurrentFocus = path => {
|
|
19552
19659
|
const apiOptions = this.getApiOptions();
|
|
19553
19660
|
|
|
@@ -19700,6 +19807,7 @@ class Renderer extends React.Component {
|
|
|
19700
19807
|
this.blurPath(this._currentFocus);
|
|
19701
19808
|
}
|
|
19702
19809
|
};
|
|
19810
|
+
// Serializes widget state. Seems to be used only by editors though.
|
|
19703
19811
|
this.serialize = () => {
|
|
19704
19812
|
const state = {};
|
|
19705
19813
|
_.each(this.state.widgetInfo, function (info, id) {
|
|
@@ -19785,8 +19893,11 @@ class Renderer extends React.Component {
|
|
|
19785
19893
|
const widget = this.getWidgetInstance(widgetId);
|
|
19786
19894
|
|
|
19787
19895
|
// Widget handles parsing of the interWidgetPath.
|
|
19788
|
-
widget == null
|
|
19896
|
+
widget == null || widget.setInputValue == null || widget.setInputValue(interWidgetPath, newValue, focus);
|
|
19789
19897
|
};
|
|
19898
|
+
/**
|
|
19899
|
+
* Returns an array of the widget `.getUserInput()` results
|
|
19900
|
+
*/
|
|
19790
19901
|
this.getUserInput = () => {
|
|
19791
19902
|
return this.widgetIds.map(id => {
|
|
19792
19903
|
const widget = this.getWidgetInstance(id);
|
|
@@ -19797,9 +19908,22 @@ class Renderer extends React.Component {
|
|
|
19797
19908
|
}
|
|
19798
19909
|
});
|
|
19799
19910
|
};
|
|
19911
|
+
/**
|
|
19912
|
+
* Returns an array of all widget IDs in the order they occur in
|
|
19913
|
+
* the content.
|
|
19914
|
+
*/
|
|
19800
19915
|
this.getWidgetIds = () => {
|
|
19801
19916
|
return this.widgetIds;
|
|
19802
19917
|
};
|
|
19918
|
+
/**
|
|
19919
|
+
* Returns the result of `.getUserInput()` for each widget, in
|
|
19920
|
+
* a map from widgetId to userInput.
|
|
19921
|
+
* NOTE(jeremy): This function is hauntingly similar to `getUserInput` with
|
|
19922
|
+
* the major difference being that this function returns a map of
|
|
19923
|
+
* `widgetID` => UserInput and `getUserInput` simply returns an array. It
|
|
19924
|
+
* would be trivial to map between the results of each of these functions,
|
|
19925
|
+
* so we should aim to remove one of these functions.
|
|
19926
|
+
*/
|
|
19803
19927
|
this.getUserInputForWidgets = () => {
|
|
19804
19928
|
return mapObjectFromArray(this.widgetIds, id => {
|
|
19805
19929
|
const widget = this.getWidgetInstance(id);
|
|
@@ -19808,6 +19932,11 @@ class Renderer extends React.Component {
|
|
|
19808
19932
|
}
|
|
19809
19933
|
});
|
|
19810
19934
|
};
|
|
19935
|
+
/**
|
|
19936
|
+
* Returns an object mapping from widget ID to perseus-style score.
|
|
19937
|
+
* The keys of this object are the values of the array returned
|
|
19938
|
+
* from `getWidgetIds`.
|
|
19939
|
+
*/
|
|
19811
19940
|
this.scoreWidgets = () => {
|
|
19812
19941
|
const widgetProps = this.state.widgetInfo;
|
|
19813
19942
|
const onInputError = this.getApiOptions().onInputError;
|
|
@@ -19831,6 +19960,9 @@ class Renderer extends React.Component {
|
|
|
19831
19960
|
});
|
|
19832
19961
|
return widgetScores;
|
|
19833
19962
|
};
|
|
19963
|
+
/**
|
|
19964
|
+
* Grades the content.
|
|
19965
|
+
*/
|
|
19834
19966
|
this.score = () => {
|
|
19835
19967
|
return _.reduce(this.scoreWidgets(), Util.combineScores, Util.noScore);
|
|
19836
19968
|
};
|
|
@@ -19861,6 +19993,7 @@ class Renderer extends React.Component {
|
|
|
19861
19993
|
}
|
|
19862
19994
|
return examples[0];
|
|
19863
19995
|
};
|
|
19996
|
+
// TranslationLinter callback
|
|
19864
19997
|
this.handletranslationLintErrors = lintErrors => {
|
|
19865
19998
|
if (!this._isMounted) {
|
|
19866
19999
|
return;
|
|
@@ -21081,6 +21214,8 @@ class InputNumber extends React.Component {
|
|
|
21081
21214
|
/* c8 ignore next */
|
|
21082
21215
|
return [[]];
|
|
21083
21216
|
};
|
|
21217
|
+
// Note: We believe that this isn't used anywhere but are leaving it during
|
|
21218
|
+
// the initial refactor
|
|
21084
21219
|
this.getGrammarTypeForPath = path => {
|
|
21085
21220
|
/* c8 ignore next */
|
|
21086
21221
|
return "number";
|
|
@@ -21314,6 +21449,7 @@ class NumericInput extends React.Component {
|
|
|
21314
21449
|
// between 0 and finite solutions
|
|
21315
21450
|
previousValues: [""]
|
|
21316
21451
|
};
|
|
21452
|
+
// TODO(Nicole, Jeremy): This is maybe never used and should be removed
|
|
21317
21453
|
this.examples = () => {
|
|
21318
21454
|
var _this$props$answerFor;
|
|
21319
21455
|
// if the set of specified forms are empty, allow all forms
|
|
@@ -21347,16 +21483,16 @@ class NumericInput extends React.Component {
|
|
|
21347
21483
|
};
|
|
21348
21484
|
this.focus = () => {
|
|
21349
21485
|
var _this$inputRef;
|
|
21350
|
-
(_this$inputRef = this.inputRef) == null
|
|
21486
|
+
(_this$inputRef = this.inputRef) == null || _this$inputRef.focus();
|
|
21351
21487
|
return true;
|
|
21352
21488
|
};
|
|
21353
21489
|
this.focusInputPath = () => {
|
|
21354
21490
|
var _this$inputRef2;
|
|
21355
|
-
(_this$inputRef2 = this.inputRef) == null
|
|
21491
|
+
(_this$inputRef2 = this.inputRef) == null || _this$inputRef2.focus();
|
|
21356
21492
|
};
|
|
21357
21493
|
this.blurInputPath = () => {
|
|
21358
21494
|
var _this$inputRef3;
|
|
21359
|
-
(_this$inputRef3 = this.inputRef) == null
|
|
21495
|
+
(_this$inputRef3 = this.inputRef) == null || _this$inputRef3.blur();
|
|
21360
21496
|
};
|
|
21361
21497
|
this.getInputPaths = () => {
|
|
21362
21498
|
// The widget itself is an input, so we return a single empty list to
|
|
@@ -21689,12 +21825,16 @@ class PassageRef extends React.Component {
|
|
|
21689
21825
|
constructor(..._args) {
|
|
21690
21826
|
super(..._args);
|
|
21691
21827
|
this.displayName = "PassageRef";
|
|
21828
|
+
// @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
|
|
21692
21829
|
this._isMounted = void 0;
|
|
21830
|
+
// @ts-expect-error - TS2564 - Property '_throttledUpdateRange' has no initializer and is not definitely assigned in the constructor.
|
|
21693
21831
|
this._throttledUpdateRange = void 0;
|
|
21694
21832
|
this.state = {
|
|
21695
21833
|
lineRange: null,
|
|
21696
21834
|
content: null
|
|
21697
21835
|
};
|
|
21836
|
+
// TODO(tamarab): getUserInput needs to be updated to only return
|
|
21837
|
+
// props input by the user. Currently returns all the widget's props.
|
|
21698
21838
|
this.getUserInput = () => {
|
|
21699
21839
|
return removeDenylistProps(this.props);
|
|
21700
21840
|
};
|
|
@@ -21734,10 +21874,6 @@ class PassageRef extends React.Component {
|
|
|
21734
21874
|
shouldComponentUpdate(nextProps, nextState) {
|
|
21735
21875
|
return !_.isEqual(this.props, nextProps) || !_.isEqual(this.state, nextState);
|
|
21736
21876
|
}
|
|
21737
|
-
|
|
21738
|
-
// TODO(tamarab): getUserInput needs to be updated to only return
|
|
21739
|
-
// props input by the user. Currently returns all the widget's props.
|
|
21740
|
-
|
|
21741
21877
|
render() {
|
|
21742
21878
|
const lineRange = this.state.lineRange;
|
|
21743
21879
|
let lineRangeOutput;
|
|
@@ -22091,7 +22227,6 @@ const BASE_ICON_SIZE = 10;
|
|
|
22091
22227
|
// If you pass in an object you need to specify an SVG path to
|
|
22092
22228
|
// render along with the width and height of the path (to ensure
|
|
22093
22229
|
// that it gets scaled correctly).
|
|
22094
|
-
|
|
22095
22230
|
class Icon extends React.Component {
|
|
22096
22231
|
render() {
|
|
22097
22232
|
const {
|
|
@@ -22925,7 +23060,7 @@ const BaseRadio = function BaseRadio(props) {
|
|
|
22925
23060
|
|
|
22926
23061
|
// register a callback with the parent that allows
|
|
22927
23062
|
// the parent to focus an individual choice
|
|
22928
|
-
registerFocusFunction == null
|
|
23063
|
+
registerFocusFunction == null || registerFocusFunction(choiceIndex => {
|
|
22929
23064
|
const ref = choiceRefs.current[choiceIndex || 0];
|
|
22930
23065
|
// note(matthew): we know this is only getting passed
|
|
22931
23066
|
// to a WB Clickable button, so we force it to be of
|
|
@@ -23168,9 +23303,12 @@ const styles$q = StyleSheet.create({
|
|
|
23168
23303
|
}
|
|
23169
23304
|
});
|
|
23170
23305
|
|
|
23306
|
+
// RenderProps is the return type for radio.jsx#transform
|
|
23307
|
+
|
|
23171
23308
|
class Radio$1 extends React.Component {
|
|
23172
23309
|
constructor(...args) {
|
|
23173
23310
|
super(...args);
|
|
23311
|
+
// @ts-expect-error - TS2564 - Property 'focusFunction' has no initializer and is not definitely assigned in the constructor.
|
|
23174
23312
|
this.focusFunction = void 0;
|
|
23175
23313
|
this._renderRenderer = (content = "") => {
|
|
23176
23314
|
let nextPassageRefId = 1;
|
|
@@ -23213,6 +23351,19 @@ class Radio$1 extends React.Component {
|
|
|
23213
23351
|
})
|
|
23214
23352
|
});
|
|
23215
23353
|
};
|
|
23354
|
+
// When `BaseRadio`'s `onChange` handler is called, indicating a change in
|
|
23355
|
+
// our choices' state, we need to call our `onChange` handler in order to
|
|
23356
|
+
// persist those changes in the item's Perseus state.
|
|
23357
|
+
//
|
|
23358
|
+
// So, given the new values for each choice, construct the new
|
|
23359
|
+
// `choiceStates` objects, and pass them to `this.props.onChange`.
|
|
23360
|
+
//
|
|
23361
|
+
// `newValueLists` is an object with two keys: `checked` and `crossedOut`.
|
|
23362
|
+
// Each contains an array of boolean values, specifying the new checked and
|
|
23363
|
+
// crossed-out value of each choice.
|
|
23364
|
+
//
|
|
23365
|
+
// NOTE(mdr): This method expects to be auto-bound. If this component is
|
|
23366
|
+
// converted to an ES6 class, take care to auto-bind this method!
|
|
23216
23367
|
this.updateChoices = newValueLists => {
|
|
23217
23368
|
const {
|
|
23218
23369
|
choiceStates,
|
|
@@ -23251,6 +23402,11 @@ class Radio$1 extends React.Component {
|
|
|
23251
23402
|
this.simpleValidate = rubric => {
|
|
23252
23403
|
return Radio$1.validate(this.getUserInput(), rubric);
|
|
23253
23404
|
};
|
|
23405
|
+
/**
|
|
23406
|
+
* Turn on rationale display for the currently selected choices. Note that
|
|
23407
|
+
* this leaves rationales on for choices that are already showing
|
|
23408
|
+
* rationales.
|
|
23409
|
+
*/
|
|
23254
23410
|
this.showRationalesForCurrentlySelectedChoices = rubric => {
|
|
23255
23411
|
const {
|
|
23256
23412
|
choiceStates
|
|
@@ -23284,6 +23440,9 @@ class Radio$1 extends React.Component {
|
|
|
23284
23440
|
);
|
|
23285
23441
|
}
|
|
23286
23442
|
};
|
|
23443
|
+
/**
|
|
23444
|
+
* Deselects any currently-selected choices that are not correct choices.
|
|
23445
|
+
*/
|
|
23287
23446
|
this.deselectIncorrectSelectedChoices = () => {
|
|
23288
23447
|
if (this.props.choiceStates) {
|
|
23289
23448
|
const newStates = this.props.choiceStates.map((state, i) => _extends({}, state, {
|
|
@@ -23425,21 +23584,6 @@ class Radio$1 extends React.Component {
|
|
|
23425
23584
|
registerFocusFunction(fun) {
|
|
23426
23585
|
this.focusFunction = fun;
|
|
23427
23586
|
}
|
|
23428
|
-
|
|
23429
|
-
// When `BaseRadio`'s `onChange` handler is called, indicating a change in
|
|
23430
|
-
// our choices' state, we need to call our `onChange` handler in order to
|
|
23431
|
-
// persist those changes in the item's Perseus state.
|
|
23432
|
-
//
|
|
23433
|
-
// So, given the new values for each choice, construct the new
|
|
23434
|
-
// `choiceStates` objects, and pass them to `this.props.onChange`.
|
|
23435
|
-
//
|
|
23436
|
-
// `newValueLists` is an object with two keys: `checked` and `crossedOut`.
|
|
23437
|
-
// Each contains an array of boolean values, specifying the new checked and
|
|
23438
|
-
// crossed-out value of each choice.
|
|
23439
|
-
//
|
|
23440
|
-
// NOTE(mdr): This method expects to be auto-bound. If this component is
|
|
23441
|
-
// converted to an ES6 class, take care to auto-bind this method!
|
|
23442
|
-
|
|
23443
23587
|
render() {
|
|
23444
23588
|
const {
|
|
23445
23589
|
choices
|
|
@@ -24109,6 +24253,8 @@ var CSProgram$1 = {
|
|
|
24109
24253
|
hidden: true
|
|
24110
24254
|
};
|
|
24111
24255
|
|
|
24256
|
+
// TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
|
|
24257
|
+
|
|
24112
24258
|
class Definition extends React.Component {
|
|
24113
24259
|
constructor(...args) {
|
|
24114
24260
|
super(...args);
|
|
@@ -24277,6 +24423,11 @@ var Dropdown$1 = {
|
|
|
24277
24423
|
};
|
|
24278
24424
|
|
|
24279
24425
|
/* eslint-disable react/sort-comp */
|
|
24426
|
+
|
|
24427
|
+
// TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
|
|
24428
|
+
|
|
24429
|
+
// transform = _.identity
|
|
24430
|
+
|
|
24280
24431
|
class Explanation extends React.Component {
|
|
24281
24432
|
constructor(..._args) {
|
|
24282
24433
|
super(..._args);
|
|
@@ -24608,6 +24759,9 @@ const getNextState = (currentState, answerable) => {
|
|
|
24608
24759
|
// Prepended to all invalid messages to make the widget messages a bit clearer
|
|
24609
24760
|
const INVALID_MESSAGE_PREFIX = i18n._("We couldn't grade your answer.");
|
|
24610
24761
|
const DEFAULT_INVALID_MESSAGE = i18n._("It looks like you left something blank or ") + i18n._("entered in an invalid answer.");
|
|
24762
|
+
|
|
24763
|
+
// exports has no 'transform'
|
|
24764
|
+
|
|
24611
24765
|
// A Graded Group is more or less a Group widget that displays a check
|
|
24612
24766
|
// answer button below the rendered content. When clicked, the widget grades
|
|
24613
24767
|
// the stuff inside and displays feedback about whether the inputted answer was
|
|
@@ -24625,6 +24779,11 @@ class GradedGroup extends React.Component {
|
|
|
24625
24779
|
// @ts-expect-error - TS2345 - Argument of type 'readonly unknown[]' is not assignable to parameter of type 'any[]'.
|
|
24626
24780
|
return change.apply(this, args);
|
|
24627
24781
|
};
|
|
24782
|
+
// This is a little strange because the id of the widget that actually
|
|
24783
|
+
// changed is going to be lost in favor of the group widget's id. The
|
|
24784
|
+
// widgets prop also wasn't actually changed, and this only serves to
|
|
24785
|
+
// alert our renderer (our parent) of the fact that some interaction
|
|
24786
|
+
// has occurred.
|
|
24628
24787
|
this._onInteractWithWidget = id => {
|
|
24629
24788
|
// Reset grading display when user changes answer
|
|
24630
24789
|
this.setState({
|
|
@@ -24664,6 +24823,7 @@ class GradedGroup extends React.Component {
|
|
|
24664
24823
|
status: status
|
|
24665
24824
|
});
|
|
24666
24825
|
};
|
|
24826
|
+
// Mobile API
|
|
24667
24827
|
this.getInputPaths = () => {
|
|
24668
24828
|
// eslint-disable-next-line react/no-string-refs
|
|
24669
24829
|
// @ts-expect-error - TS2339 - Property 'getInputPaths' does not exist on type 'ReactInstance'.
|
|
@@ -24905,29 +25065,44 @@ class Indicators extends React.Component {
|
|
|
24905
25065
|
}
|
|
24906
25066
|
render() {
|
|
24907
25067
|
return /*#__PURE__*/React.createElement("ul", {
|
|
24908
|
-
|
|
25068
|
+
// reduntantly add class name for use in .less files--
|
|
25069
|
+
// the styles object key gets hashed
|
|
25070
|
+
className: classNames(css(styles$j.indicatorContainer), "indicatorContainer")
|
|
24909
25071
|
}, this.props.gradedGroups.map(({
|
|
24910
25072
|
title
|
|
24911
25073
|
}, i) => /*#__PURE__*/React.createElement("li", {
|
|
25074
|
+
className: css(styles$j.indicator),
|
|
25075
|
+
key: title
|
|
25076
|
+
}, /*#__PURE__*/React.createElement(Clickable, {
|
|
24912
25077
|
role: "button",
|
|
24913
25078
|
"aria-label": i18n._("Skip to %(title)s", {
|
|
24914
25079
|
title
|
|
24915
25080
|
}),
|
|
24916
|
-
|
|
24917
|
-
className: css(styles$j.indicator, i === this.props.currentGroup && styles$j.selectedIndicator),
|
|
24918
|
-
tabIndex: 0,
|
|
25081
|
+
style: styles$j.indicatorButton,
|
|
24919
25082
|
onClick: () => this.props.onChangeCurrentGroup(i),
|
|
24920
25083
|
onKeyDown: e => this.handleKeyDown(e, i)
|
|
24921
|
-
},
|
|
25084
|
+
}, ({
|
|
25085
|
+
hovered,
|
|
25086
|
+
focused,
|
|
25087
|
+
pressed
|
|
25088
|
+
}) => /*#__PURE__*/React.createElement(View, {
|
|
25089
|
+
style: [styles$j.indicatorDot, (hovered || focused || pressed) && styles$j.indicatorDotFocused]
|
|
25090
|
+
}, i === this.props.currentGroup && /*#__PURE__*/React.createElement(View, {
|
|
25091
|
+
style: styles$j.indicatorDotActive
|
|
25092
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
24922
25093
|
className: css(a11y.srOnly)
|
|
24923
|
-
}, i18n._("Current")))));
|
|
25094
|
+
}, i18n._("Current"))))))));
|
|
24924
25095
|
}
|
|
24925
25096
|
}
|
|
25097
|
+
|
|
25098
|
+
// no transform
|
|
25099
|
+
|
|
24926
25100
|
// TODO(jared): find a better name for this :) and for GradedGroup; the names
|
|
24927
25101
|
// are currently a little confusing.
|
|
24928
25102
|
class GradedGroupSet extends React.Component {
|
|
24929
25103
|
constructor(..._args) {
|
|
24930
25104
|
super(..._args);
|
|
25105
|
+
// @ts-expect-error - TS2564 - Property '_childGroup' has no initializer and is not definitely assigned in the constructor.
|
|
24931
25106
|
this._childGroup = void 0;
|
|
24932
25107
|
this.state = {
|
|
24933
25108
|
currentGroup: 0
|
|
@@ -24936,6 +25111,7 @@ class GradedGroupSet extends React.Component {
|
|
|
24936
25111
|
// @ts-expect-error - TS2345 - Argument of type 'readonly unknown[]' is not assignable to parameter of type 'any[]'.
|
|
24937
25112
|
return change.apply(this, args);
|
|
24938
25113
|
};
|
|
25114
|
+
// Mobile API
|
|
24939
25115
|
this.getInputPaths = () => {
|
|
24940
25116
|
return this._childGroup.getInputPaths();
|
|
24941
25117
|
};
|
|
@@ -25068,19 +25244,42 @@ const styles$j = StyleSheet.create({
|
|
|
25068
25244
|
display: "flex",
|
|
25069
25245
|
flexDirection: "row",
|
|
25070
25246
|
listStyle: "none",
|
|
25071
|
-
margin: "unset"
|
|
25247
|
+
margin: "unset",
|
|
25248
|
+
paddingInlineStart: "unset",
|
|
25249
|
+
flexWrap: "wrap"
|
|
25072
25250
|
},
|
|
25073
25251
|
indicator: {
|
|
25252
|
+
width: 24,
|
|
25253
|
+
height: 24
|
|
25254
|
+
},
|
|
25255
|
+
indicatorButton: {
|
|
25256
|
+
width: "100%",
|
|
25257
|
+
height: "100%",
|
|
25258
|
+
display: "flex",
|
|
25259
|
+
flexWrap: "wrap",
|
|
25260
|
+
placeContent: "center",
|
|
25261
|
+
cursor: "pointer",
|
|
25262
|
+
":focus": {
|
|
25263
|
+
outline: "none"
|
|
25264
|
+
}
|
|
25265
|
+
},
|
|
25266
|
+
indicatorDot: {
|
|
25267
|
+
boxSizing: "content-box",
|
|
25074
25268
|
width: 10,
|
|
25075
25269
|
height: 10,
|
|
25076
25270
|
borderRadius: "100%",
|
|
25077
|
-
|
|
25271
|
+
borderWidth: 2,
|
|
25078
25272
|
borderColor: Color.blue,
|
|
25079
|
-
|
|
25080
|
-
|
|
25273
|
+
borderStyle: "solid"
|
|
25274
|
+
},
|
|
25275
|
+
indicatorDotFocused: {
|
|
25276
|
+
borderWidth: 5,
|
|
25277
|
+
borderStyle: "double"
|
|
25081
25278
|
},
|
|
25082
|
-
|
|
25083
|
-
backgroundColor: Color.blue
|
|
25279
|
+
indicatorDotActive: {
|
|
25280
|
+
backgroundColor: Color.blue,
|
|
25281
|
+
width: "100%",
|
|
25282
|
+
height: "100%"
|
|
25084
25283
|
},
|
|
25085
25284
|
container: {
|
|
25086
25285
|
borderTop: `1px solid ${gray76}`,
|
|
@@ -25947,7 +26146,7 @@ FunctionGrapher.defaultProps = {
|
|
|
25947
26146
|
coords: null,
|
|
25948
26147
|
asymptote: null,
|
|
25949
26148
|
isMobile: false
|
|
25950
|
-
};
|
|
26149
|
+
}; // Really this is props.plot, I think
|
|
25951
26150
|
/* Widget and editor. */
|
|
25952
26151
|
class Grapher extends React.Component {
|
|
25953
26152
|
constructor(...args) {
|
|
@@ -26153,6 +26352,8 @@ var Grapher$1 = {
|
|
|
26153
26352
|
staticTransform: staticTransform$3
|
|
26154
26353
|
};
|
|
26155
26354
|
|
|
26355
|
+
// exports has no 'transform'
|
|
26356
|
+
|
|
26156
26357
|
class Group extends React.Component {
|
|
26157
26358
|
constructor(..._args) {
|
|
26158
26359
|
super(..._args);
|
|
@@ -26170,7 +26371,7 @@ class Group extends React.Component {
|
|
|
26170
26371
|
};
|
|
26171
26372
|
this.restoreSerializedState = (state, callback) => {
|
|
26172
26373
|
var _this$rendererRef3;
|
|
26173
|
-
(_this$rendererRef3 = this.rendererRef) == null
|
|
26374
|
+
(_this$rendererRef3 = this.rendererRef) == null || _this$rendererRef3.restoreSerializedState(state, callback);
|
|
26174
26375
|
// Tell our renderer that we have no props to change
|
|
26175
26376
|
// (all our changes were in state):
|
|
26176
26377
|
return null;
|
|
@@ -26179,6 +26380,7 @@ class Group extends React.Component {
|
|
|
26179
26380
|
var _this$rendererRef4;
|
|
26180
26381
|
return (_this$rendererRef4 = this.rendererRef) == null ? void 0 : _this$rendererRef4.score();
|
|
26181
26382
|
};
|
|
26383
|
+
// Mobile API:
|
|
26182
26384
|
this.getInputPaths = () => {
|
|
26183
26385
|
var _this$rendererRef5;
|
|
26184
26386
|
return (_this$rendererRef5 = this.rendererRef) == null ? void 0 : _this$rendererRef5.getInputPaths();
|
|
@@ -26193,15 +26395,15 @@ class Group extends React.Component {
|
|
|
26193
26395
|
};
|
|
26194
26396
|
this.focusInputPath = path => {
|
|
26195
26397
|
var _this$rendererRef8;
|
|
26196
|
-
(_this$rendererRef8 = this.rendererRef) == null
|
|
26398
|
+
(_this$rendererRef8 = this.rendererRef) == null || _this$rendererRef8.focusPath(path);
|
|
26197
26399
|
};
|
|
26198
26400
|
this.blurInputPath = path => {
|
|
26199
26401
|
var _this$rendererRef9;
|
|
26200
|
-
(_this$rendererRef9 = this.rendererRef) == null
|
|
26402
|
+
(_this$rendererRef9 = this.rendererRef) == null || _this$rendererRef9.blurPath(path);
|
|
26201
26403
|
};
|
|
26202
26404
|
this.showRationalesForCurrentlySelectedChoices = () => {
|
|
26203
26405
|
var _this$rendererRef10;
|
|
26204
|
-
(_this$rendererRef10 = this.rendererRef) == null
|
|
26406
|
+
(_this$rendererRef10 = this.rendererRef) == null || _this$rendererRef10.showRationalesForCurrentlySelectedChoices();
|
|
26205
26407
|
};
|
|
26206
26408
|
}
|
|
26207
26409
|
componentDidMount() {
|
|
@@ -26467,6 +26669,9 @@ const defaultBackgroundImage$3 = {
|
|
|
26467
26669
|
};
|
|
26468
26670
|
const editorAlignments = ["block", "full-width"];
|
|
26469
26671
|
const DEFAULT_ALIGNMENT = "block";
|
|
26672
|
+
|
|
26673
|
+
// there is no transform as part of exports
|
|
26674
|
+
|
|
26470
26675
|
class ImageWidget extends React.Component {
|
|
26471
26676
|
constructor(..._args) {
|
|
26472
26677
|
super(..._args);
|
|
@@ -26731,6 +26936,9 @@ const KAScompile = (expr, options) => {
|
|
|
26731
26936
|
_compileCache[hash] = cached;
|
|
26732
26937
|
return cached;
|
|
26733
26938
|
};
|
|
26939
|
+
|
|
26940
|
+
// There's no transform function in exports
|
|
26941
|
+
|
|
26734
26942
|
class Interaction extends React.Component {
|
|
26735
26943
|
constructor(..._args) {
|
|
26736
26944
|
super(..._args);
|
|
@@ -26796,6 +27004,7 @@ class Interaction extends React.Component {
|
|
|
26796
27004
|
// Default to 0 if the expression couldn't be parsed
|
|
26797
27005
|
return func(compiledVars) || 0;
|
|
26798
27006
|
};
|
|
27007
|
+
// Return an array of all the variables in an expression
|
|
26799
27008
|
this._extractVars = expr => {
|
|
26800
27009
|
if (expr == null) {
|
|
26801
27010
|
return [];
|
|
@@ -27304,8 +27513,15 @@ class Graph extends React.Component {
|
|
|
27304
27513
|
this.protractor = void 0;
|
|
27305
27514
|
this.ruler = void 0;
|
|
27306
27515
|
this._graphie = void 0;
|
|
27516
|
+
// @ts-expect-error - TS2564 - Property '_hasSetupGraphieThisUpdate' has no initializer and is not definitely assigned in the constructor.
|
|
27307
27517
|
this._hasSetupGraphieThisUpdate = void 0;
|
|
27518
|
+
// @ts-expect-error - TS2564 - Property '_shouldSetupGraphie' has no initializer and is not definitely assigned in the constructor.
|
|
27308
27519
|
this._shouldSetupGraphie = void 0;
|
|
27520
|
+
/* Reset the graphie canvas to its initial state
|
|
27521
|
+
*
|
|
27522
|
+
* Use when re-rendering the parent component and you need a blank
|
|
27523
|
+
* graphie.
|
|
27524
|
+
*/
|
|
27309
27525
|
this.reset = () => {
|
|
27310
27526
|
this._setupGraphie(false);
|
|
27311
27527
|
};
|
|
@@ -27512,13 +27728,6 @@ class Graph extends React.Component {
|
|
|
27512
27728
|
this._shouldSetupGraphie = false;
|
|
27513
27729
|
}
|
|
27514
27730
|
}
|
|
27515
|
-
|
|
27516
|
-
/* Reset the graphie canvas to its initial state
|
|
27517
|
-
*
|
|
27518
|
-
* Use when re-rendering the parent component and you need a blank
|
|
27519
|
-
* graphie.
|
|
27520
|
-
*/
|
|
27521
|
-
|
|
27522
27731
|
render() {
|
|
27523
27732
|
let image;
|
|
27524
27733
|
const imageData = this.props.backgroundImage;
|
|
@@ -27832,6 +28041,9 @@ const makeInvalidTypeError = (functionName, graphType) => {
|
|
|
27832
28041
|
}
|
|
27833
28042
|
});
|
|
27834
28043
|
};
|
|
28044
|
+
|
|
28045
|
+
// There's no transform function in exports
|
|
28046
|
+
|
|
27835
28047
|
class InteractiveGraph extends React.Component {
|
|
27836
28048
|
constructor(...args) {
|
|
27837
28049
|
super(...args);
|
|
@@ -27845,8 +28057,10 @@ class InteractiveGraph extends React.Component {
|
|
|
27845
28057
|
this.pointA = void 0;
|
|
27846
28058
|
this.pointB = void 0;
|
|
27847
28059
|
this.pointC = void 0;
|
|
28060
|
+
// @ts-expect-error - TS2564 - Property 'points' has no initializer and is not definitely assigned in the constructor.
|
|
27848
28061
|
this.points = void 0;
|
|
27849
28062
|
this.polygon = void 0;
|
|
28063
|
+
// @ts-expect-error - TS2564 - Property 'shouldResetGraphie' has no initializer and is not definitely assigned in the constructor.
|
|
27850
28064
|
this.shouldResetGraphie = void 0;
|
|
27851
28065
|
this.sinusoid = void 0;
|
|
27852
28066
|
this.trashCan = void 0;
|
|
@@ -27928,7 +28142,7 @@ class InteractiveGraph extends React.Component {
|
|
|
27928
28142
|
this.horizHairline.attr({
|
|
27929
28143
|
stroke: KhanColors.INTERACTIVE
|
|
27930
28144
|
});
|
|
27931
|
-
(_this$horizHairline = this.horizHairline) == null
|
|
28145
|
+
(_this$horizHairline = this.horizHairline) == null || _this$horizHairline.hide();
|
|
27932
28146
|
this.vertHairline = new WrappedLine(this.graphie, [0, 0], [0, 0], {
|
|
27933
28147
|
normalStyle: {
|
|
27934
28148
|
strokeWidth: 1
|
|
@@ -27937,7 +28151,7 @@ class InteractiveGraph extends React.Component {
|
|
|
27937
28151
|
this.vertHairline.attr({
|
|
27938
28152
|
stroke: KhanColors.INTERACTIVE
|
|
27939
28153
|
});
|
|
27940
|
-
(_this$vertHairline = this.vertHairline) == null
|
|
28154
|
+
(_this$vertHairline = this.vertHairline) == null || _this$vertHairline.hide();
|
|
27941
28155
|
}
|
|
27942
28156
|
const type = this.props.graph.type;
|
|
27943
28157
|
this["add" + capitalize(type) + "Controls"]();
|
|
@@ -27948,17 +28162,17 @@ class InteractiveGraph extends React.Component {
|
|
|
27948
28162
|
// Hairlines are already initialized when the graph is loaded, so
|
|
27949
28163
|
// here we just move them to the updated location and make them
|
|
27950
28164
|
// visible.
|
|
27951
|
-
(_this$horizHairline2 = this.horizHairline) == null
|
|
27952
|
-
(_this$horizHairline3 = this.horizHairline) == null
|
|
27953
|
-
(_this$vertHairline2 = this.vertHairline) == null
|
|
27954
|
-
(_this$vertHairline3 = this.vertHairline) == null
|
|
28165
|
+
(_this$horizHairline2 = this.horizHairline) == null || _this$horizHairline2.moveTo([this.props.range[0][0], point[1]], [this.props.range[0][1], point[1]]);
|
|
28166
|
+
(_this$horizHairline3 = this.horizHairline) == null || _this$horizHairline3.show();
|
|
28167
|
+
(_this$vertHairline2 = this.vertHairline) == null || _this$vertHairline2.moveTo([point[0], this.props.range[1][0]], [point[0], this.props.range[1][1]]);
|
|
28168
|
+
(_this$vertHairline3 = this.vertHairline) == null || _this$vertHairline3.show();
|
|
27955
28169
|
}
|
|
27956
28170
|
};
|
|
27957
28171
|
this.hideHairlines = () => {
|
|
27958
28172
|
if (this.props.apiOptions.isMobile) {
|
|
27959
28173
|
var _this$horizHairline4, _this$vertHairline4;
|
|
27960
|
-
(_this$horizHairline4 = this.horizHairline) == null
|
|
27961
|
-
(_this$vertHairline4 = this.vertHairline) == null
|
|
28174
|
+
(_this$horizHairline4 = this.horizHairline) == null || _this$horizHairline4.hide();
|
|
28175
|
+
(_this$vertHairline4 = this.vertHairline) == null || _this$vertHairline4.hide();
|
|
27962
28176
|
}
|
|
27963
28177
|
};
|
|
27964
28178
|
this.setTrashCanVisibility = opacity => {
|
|
@@ -27974,9 +28188,9 @@ class InteractiveGraph extends React.Component {
|
|
|
27974
28188
|
// trash can area.
|
|
27975
28189
|
if (!this.trashCan) {
|
|
27976
28190
|
var _graphie$raphael;
|
|
27977
|
-
this.trashCan = graphie == null
|
|
28191
|
+
this.trashCan = graphie == null || (_graphie$raphael = graphie.raphael) == null ? void 0 : _graphie$raphael.image(TRASH_ICON_URI, graphie.xpixels - 40, graphie.ypixels - 40, 40, 40);
|
|
27978
28192
|
}
|
|
27979
|
-
(_this$trashCan = this.trashCan) == null
|
|
28193
|
+
(_this$trashCan = this.trashCan) == null || _this$trashCan.attr({
|
|
27980
28194
|
opacity: opacity
|
|
27981
28195
|
});
|
|
27982
28196
|
}
|
|
@@ -28041,7 +28255,7 @@ class InteractiveGraph extends React.Component {
|
|
|
28041
28255
|
this.removeLine = () => {
|
|
28042
28256
|
var _this$line;
|
|
28043
28257
|
_.invoke(this.points, "remove");
|
|
28044
|
-
(_this$line = this.line) == null
|
|
28258
|
+
(_this$line = this.line) == null || _this$line.remove();
|
|
28045
28259
|
};
|
|
28046
28260
|
this.addLinearControls = () => {
|
|
28047
28261
|
this.addLine("line");
|
|
@@ -28144,23 +28358,23 @@ class InteractiveGraph extends React.Component {
|
|
|
28144
28358
|
if (this.parabola) {
|
|
28145
28359
|
var _this$graphie, _this$parabola;
|
|
28146
28360
|
const path = (_this$graphie = this.graphie) == null ? void 0 : _this$graphie.svgParabolaPath(a, b, c);
|
|
28147
|
-
(_this$parabola = this.parabola) == null
|
|
28361
|
+
(_this$parabola = this.parabola) == null || _this$parabola.attr({
|
|
28148
28362
|
path: path
|
|
28149
28363
|
});
|
|
28150
28364
|
} else {
|
|
28151
28365
|
var _this$graphie2, _this$parabola2, _this$parabola3;
|
|
28152
28366
|
this.parabola = (_this$graphie2 = this.graphie) == null ? void 0 : _this$graphie2.parabola(a, b, c);
|
|
28153
|
-
(_this$parabola2 = this.parabola) == null
|
|
28367
|
+
(_this$parabola2 = this.parabola) == null || _this$parabola2.attr(_extends({
|
|
28154
28368
|
stroke: this.props.apiOptions.isMobile ? KhanColors.BLUE_C : KhanColors.DYNAMIC
|
|
28155
28369
|
}, this._lineStroke()));
|
|
28156
|
-
(_this$parabola3 = this.parabola) == null
|
|
28370
|
+
(_this$parabola3 = this.parabola) == null || _this$parabola3.toBack();
|
|
28157
28371
|
}
|
|
28158
28372
|
};
|
|
28159
28373
|
this.removeQuadraticControls = () => {
|
|
28160
28374
|
var _this$pointA, _this$pointB, _this$pointC;
|
|
28161
|
-
(_this$pointA = this.pointA) == null
|
|
28162
|
-
(_this$pointB = this.pointB) == null
|
|
28163
|
-
(_this$pointC = this.pointC) == null
|
|
28375
|
+
(_this$pointA = this.pointA) == null || _this$pointA.remove();
|
|
28376
|
+
(_this$pointB = this.pointB) == null || _this$pointB.remove();
|
|
28377
|
+
(_this$pointC = this.pointC) == null || _this$pointC.remove();
|
|
28164
28378
|
if (this.parabola) {
|
|
28165
28379
|
this.parabola.remove();
|
|
28166
28380
|
this.parabola = null;
|
|
@@ -28228,22 +28442,22 @@ class InteractiveGraph extends React.Component {
|
|
|
28228
28442
|
if (this.sinusoid) {
|
|
28229
28443
|
var _this$graphie3, _this$sinusoid;
|
|
28230
28444
|
const path = (_this$graphie3 = this.graphie) == null ? void 0 : _this$graphie3.svgSinusoidPath(a, b, c, d);
|
|
28231
|
-
(_this$sinusoid = this.sinusoid) == null
|
|
28445
|
+
(_this$sinusoid = this.sinusoid) == null || _this$sinusoid.attr({
|
|
28232
28446
|
path: path
|
|
28233
28447
|
});
|
|
28234
28448
|
} else {
|
|
28235
28449
|
var _this$graphie4, _this$sinusoid2, _this$sinusoid3;
|
|
28236
28450
|
this.sinusoid = (_this$graphie4 = this.graphie) == null ? void 0 : _this$graphie4.sinusoid(a, b, c, d);
|
|
28237
|
-
(_this$sinusoid2 = this.sinusoid) == null
|
|
28451
|
+
(_this$sinusoid2 = this.sinusoid) == null || _this$sinusoid2.attr(_extends({
|
|
28238
28452
|
stroke: this.props.apiOptions.isMobile ? KhanColors.BLUE_C : KhanColors.DYNAMIC
|
|
28239
28453
|
}, this._lineStroke()));
|
|
28240
|
-
(_this$sinusoid3 = this.sinusoid) == null
|
|
28454
|
+
(_this$sinusoid3 = this.sinusoid) == null || _this$sinusoid3.toBack();
|
|
28241
28455
|
}
|
|
28242
28456
|
};
|
|
28243
28457
|
this.removeSinusoidControls = () => {
|
|
28244
28458
|
var _this$pointA2, _this$pointB2;
|
|
28245
|
-
(_this$pointA2 = this.pointA) == null
|
|
28246
|
-
(_this$pointB2 = this.pointB) == null
|
|
28459
|
+
(_this$pointA2 = this.pointA) == null || _this$pointA2.remove();
|
|
28460
|
+
(_this$pointB2 = this.pointB) == null || _this$pointB2.remove();
|
|
28247
28461
|
if (this.sinusoid) {
|
|
28248
28462
|
this.sinusoid.remove();
|
|
28249
28463
|
this.sinusoid = null;
|
|
@@ -28274,7 +28488,7 @@ class InteractiveGraph extends React.Component {
|
|
|
28274
28488
|
};
|
|
28275
28489
|
this.removeCircleControls = () => {
|
|
28276
28490
|
var _this$circle;
|
|
28277
|
-
(_this$circle = this.circle) == null
|
|
28491
|
+
(_this$circle = this.circle) == null || _this$circle.remove();
|
|
28278
28492
|
};
|
|
28279
28493
|
this.addLinearSystemControls = () => {
|
|
28280
28494
|
const graphie = this.graphie;
|
|
@@ -28439,7 +28653,7 @@ class InteractiveGraph extends React.Component {
|
|
|
28439
28653
|
// We should be checking if this.points is defined before rotating them.
|
|
28440
28654
|
// @ts-expect-error - TS4104 - The type 'readonly any[]' is 'readonly' and cannot be assigned to the mutable type 'any[]'. | TS2345 - Argument of type 'number | null | undefined' is not assignable to parameter of type 'number | undefined'.
|
|
28441
28655
|
this.points = rotate(this.points, index);
|
|
28442
|
-
(_this$polygon3 = this.polygon) == null
|
|
28656
|
+
(_this$polygon3 = this.polygon) == null || _this$polygon3.update({
|
|
28443
28657
|
closed: false
|
|
28444
28658
|
});
|
|
28445
28659
|
}
|
|
@@ -28470,13 +28684,13 @@ class InteractiveGraph extends React.Component {
|
|
|
28470
28684
|
const pointToRemove = this.points.pop();
|
|
28471
28685
|
if (this.points.length > 2) {
|
|
28472
28686
|
var _this$polygon4;
|
|
28473
|
-
(_this$polygon4 = this.polygon) == null
|
|
28687
|
+
(_this$polygon4 = this.polygon) == null || _this$polygon4.update({
|
|
28474
28688
|
closed: true
|
|
28475
28689
|
});
|
|
28476
28690
|
this.updateCoordsFromPoints();
|
|
28477
28691
|
} else {
|
|
28478
28692
|
var _this$polygon5;
|
|
28479
|
-
(_this$polygon5 = this.polygon) == null
|
|
28693
|
+
(_this$polygon5 = this.polygon) == null || _this$polygon5.update({
|
|
28480
28694
|
closed: false
|
|
28481
28695
|
});
|
|
28482
28696
|
this.clearCoords();
|
|
@@ -28500,7 +28714,7 @@ class InteractiveGraph extends React.Component {
|
|
|
28500
28714
|
this.removePoint(point$1);
|
|
28501
28715
|
if (this.points.length < 3) {
|
|
28502
28716
|
var _this$polygon6;
|
|
28503
|
-
(_this$polygon6 = this.polygon) == null
|
|
28717
|
+
(_this$polygon6 = this.polygon) == null || _this$polygon6.update({
|
|
28504
28718
|
closed: false
|
|
28505
28719
|
});
|
|
28506
28720
|
this.clearCoords();
|
|
@@ -28538,7 +28752,7 @@ class InteractiveGraph extends React.Component {
|
|
|
28538
28752
|
const canCloseUnclosedPolygon = isFirstOrLastPoint && pointNotMoved && notANewPoint && polygonNotClosed && allPointsPlotted;
|
|
28539
28753
|
if (canCloseUnclosedPolygon) {
|
|
28540
28754
|
var _this$polygon9;
|
|
28541
|
-
(_this$polygon9 = this.polygon) == null
|
|
28755
|
+
(_this$polygon9 = this.polygon) == null || _this$polygon9.update({
|
|
28542
28756
|
closed: true
|
|
28543
28757
|
});
|
|
28544
28758
|
this.updatePolygon();
|
|
@@ -28911,7 +29125,7 @@ class InteractiveGraph extends React.Component {
|
|
|
28911
29125
|
this.removePolygonControls = () => {
|
|
28912
29126
|
var _this$polygon11;
|
|
28913
29127
|
_.invoke(this.points, "remove");
|
|
28914
|
-
(_this$polygon11 = this.polygon) == null
|
|
29128
|
+
(_this$polygon11 = this.polygon) == null || _this$polygon11.remove();
|
|
28915
29129
|
};
|
|
28916
29130
|
this.addAngleControls = () => {
|
|
28917
29131
|
if (this.props.graph.type !== "angle") {
|
|
@@ -28956,7 +29170,7 @@ class InteractiveGraph extends React.Component {
|
|
|
28956
29170
|
this.removeAngleControls = () => {
|
|
28957
29171
|
var _this$angle2;
|
|
28958
29172
|
_.invoke(this.points, "remove");
|
|
28959
|
-
(_this$angle2 = this.angle) == null
|
|
29173
|
+
(_this$angle2 = this.angle) == null || _this$angle2.remove();
|
|
28960
29174
|
};
|
|
28961
29175
|
this.toggleShowSides = () => {
|
|
28962
29176
|
if (this.props.graph.type !== "polygon") {
|
|
@@ -29493,7 +29707,7 @@ class InteractiveGraph extends React.Component {
|
|
|
29493
29707
|
// eq() comparison but _.isEqual(0, -0) is false, so we'll use
|
|
29494
29708
|
// eq() anyway. The sort should be fine because it'll stringify
|
|
29495
29709
|
// it and -0 converted to a string is "0"
|
|
29496
|
-
guess == null
|
|
29710
|
+
guess == null || guess.sort();
|
|
29497
29711
|
// @ts-expect-error - TS2339 - Property 'sort' does not exist on type 'readonly Coord[]'.
|
|
29498
29712
|
correct.sort();
|
|
29499
29713
|
if (deepEq$2(guess, correct)) {
|
|
@@ -30610,6 +30824,7 @@ var globalStyles = /*#__PURE__*/Object.freeze({
|
|
|
30610
30824
|
class AnswerChoice extends React.Component {
|
|
30611
30825
|
constructor(...args) {
|
|
30612
30826
|
super(...args);
|
|
30827
|
+
// The radio button or checkbox input control.
|
|
30613
30828
|
this._input = void 0;
|
|
30614
30829
|
this.state = {
|
|
30615
30830
|
isInputFocused: false
|
|
@@ -30716,10 +30931,9 @@ class AnswerChoice extends React.Component {
|
|
|
30716
30931
|
}
|
|
30717
30932
|
}
|
|
30718
30933
|
class AnswerChoices extends React.Component {
|
|
30719
|
-
// The rendered answers elements.
|
|
30720
|
-
|
|
30721
30934
|
constructor(props) {
|
|
30722
30935
|
super(props);
|
|
30936
|
+
// The rendered answers elements.
|
|
30723
30937
|
this._choices = void 0;
|
|
30724
30938
|
this._choices = [];
|
|
30725
30939
|
this.state = {
|
|
@@ -30813,6 +31027,7 @@ const styles$h = StyleSheet.create({
|
|
|
30813
31027
|
class Marker extends React.Component {
|
|
30814
31028
|
constructor(...args) {
|
|
30815
31029
|
super(...args);
|
|
31030
|
+
// The marker icon element.
|
|
30816
31031
|
this._icon = void 0;
|
|
30817
31032
|
this.state = {
|
|
30818
31033
|
isFocused: false
|
|
@@ -31068,13 +31283,12 @@ const styles$g = StyleSheet.create({
|
|
|
31068
31283
|
}
|
|
31069
31284
|
});
|
|
31070
31285
|
|
|
31071
|
-
|
|
31072
|
-
|
|
31073
|
-
|
|
31074
|
-
|
|
31075
|
-
|
|
31076
|
-
// The rendered list of answer choices for the currently selected marker.
|
|
31286
|
+
/**
|
|
31287
|
+
* Represents a direction vector.
|
|
31288
|
+
* No diagonals allowed.
|
|
31289
|
+
*/
|
|
31077
31290
|
|
|
31291
|
+
class LabelImage extends React.Component {
|
|
31078
31292
|
static gradeMarker(marker) {
|
|
31079
31293
|
const score = {
|
|
31080
31294
|
hasAnswers: false,
|
|
@@ -31292,8 +31506,11 @@ class LabelImage extends React.Component {
|
|
|
31292
31506
|
}
|
|
31293
31507
|
constructor(props) {
|
|
31294
31508
|
super(props);
|
|
31509
|
+
// The rendered markers on the question image for labeling.
|
|
31295
31510
|
this._markers = void 0;
|
|
31511
|
+
// The popup component containing the answer choices.
|
|
31296
31512
|
this._selectedMarkerPopup = void 0;
|
|
31513
|
+
// The rendered list of answer choices for the currently selected marker.
|
|
31297
31514
|
this._answerChoices = void 0;
|
|
31298
31515
|
this.handleDocumentClick = e => {
|
|
31299
31516
|
// Dismiss open popup with answer choices if user clicks outside it.
|
|
@@ -31821,6 +32038,7 @@ class LightsPuzzle extends React.Component {
|
|
|
31821
32038
|
super(..._args);
|
|
31822
32039
|
this._currPattern = void 0;
|
|
31823
32040
|
this._nextPattern = void 0;
|
|
32041
|
+
// @ts-expect-error - TS2564 - Property '_patternIndex' has no initializer and is not definitely assigned in the constructor.
|
|
31824
32042
|
this._patternIndex = void 0;
|
|
31825
32043
|
this.getUserInput = () => {
|
|
31826
32044
|
return WidgetJsonifyDeprecated.getUserInput.call(this);
|
|
@@ -32022,8 +32240,11 @@ class Placeholder extends React.Component {
|
|
|
32022
32240
|
class Draggable extends React.Component {
|
|
32023
32241
|
constructor(...args) {
|
|
32024
32242
|
super(...args);
|
|
32243
|
+
// Handler returned by requestAnimationFrame.
|
|
32025
32244
|
this.animationFrameRequest = null;
|
|
32245
|
+
// @ts-expect-error - TS2564 - Property 'isMouseMoveUpBound' has no initializer and is not definitely assigned in the constructor.
|
|
32026
32246
|
this.isMouseMoveUpBound = void 0;
|
|
32247
|
+
// @ts-expect-error - TS2564 - Property '_mounted' has no initializer and is not definitely assigned in the constructor.
|
|
32027
32248
|
this._mounted = void 0;
|
|
32028
32249
|
this.state = {
|
|
32029
32250
|
startPosition: {
|
|
@@ -32724,11 +32945,15 @@ class Matcher extends React.Component {
|
|
|
32724
32945
|
right: this.refs.right.getOptions()
|
|
32725
32946
|
};
|
|
32726
32947
|
};
|
|
32948
|
+
// Programatic API for moving options
|
|
32949
|
+
// This is used by testing
|
|
32727
32950
|
this.moveLeftOptionToIndex = (option, index) => {
|
|
32728
32951
|
// eslint-disable-next-line react/no-string-refs
|
|
32729
32952
|
// @ts-expect-error - TS2339 - Property 'moveOptionToIndex' does not exist on type 'ReactInstance'.
|
|
32730
32953
|
this.refs.left.moveOptionToIndex(option, index);
|
|
32731
32954
|
};
|
|
32955
|
+
// Programatic API for moving options
|
|
32956
|
+
// This is used by testing
|
|
32732
32957
|
this.moveRightOptionToIndex = (option, index) => {
|
|
32733
32958
|
// eslint-disable-next-line react/no-string-refs
|
|
32734
32959
|
// @ts-expect-error - TS2339 - Property 'moveOptionToIndex' does not exist on type 'ReactInstance'.
|
|
@@ -32928,12 +33153,16 @@ class NumberInput extends React.Component {
|
|
|
32928
33153
|
this.state = {
|
|
32929
33154
|
format: this.props.format
|
|
32930
33155
|
};
|
|
33156
|
+
/* Return the current "value" of this input
|
|
33157
|
+
* If empty, it returns the placeholder (if it is a number) or null
|
|
33158
|
+
*/
|
|
32931
33159
|
this.getValue = () => {
|
|
32932
33160
|
return this.parseInputValue(
|
|
32933
33161
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
32934
33162
|
ReactDOM__default.findDOMNode(this.refs.input).value // eslint-disable-line react/no-string-refs
|
|
32935
33163
|
);
|
|
32936
33164
|
};
|
|
33165
|
+
/* Return the current string value of this input */
|
|
32937
33166
|
this.getStringValue = () => {
|
|
32938
33167
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
32939
33168
|
return ReactDOM__default.findDOMNode(this.refs.input).value.toString(); // eslint-disable-line react/no-string-refs
|
|
@@ -32946,6 +33175,7 @@ class NumberInput extends React.Component {
|
|
|
32946
33175
|
const result = firstNumericalParse(value);
|
|
32947
33176
|
return _.isFinite(result) ? result : this.props.value;
|
|
32948
33177
|
};
|
|
33178
|
+
/* Set text input focus to this input */
|
|
32949
33179
|
this.focus = () => {
|
|
32950
33180
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'focus' does not exist on type 'Element | Text'.
|
|
32951
33181
|
ReactDOM__default.findDOMNode(this.refs.input).focus(); // eslint-disable-line react/no-string-refs
|
|
@@ -33067,10 +33297,6 @@ class NumberInput extends React.Component {
|
|
|
33067
33297
|
this._setValue(this.props.value, this.state.format);
|
|
33068
33298
|
}
|
|
33069
33299
|
}
|
|
33070
|
-
|
|
33071
|
-
/* Return the current "value" of this input
|
|
33072
|
-
* If empty, it returns the placeholder (if it is a number) or null
|
|
33073
|
-
*/
|
|
33074
33300
|
}
|
|
33075
33301
|
NumberInput.propTypes = {
|
|
33076
33302
|
value: PropTypes.number,
|
|
@@ -33167,6 +33393,7 @@ const getMatrixSize = function getMatrixSize(matrix) {
|
|
|
33167
33393
|
class Matrix extends React.Component {
|
|
33168
33394
|
constructor(...args) {
|
|
33169
33395
|
super(...args);
|
|
33396
|
+
// @ts-expect-error - TS2564 - Property 'cursorPosition' has no initializer and is not definitely assigned in the constructor.
|
|
33170
33397
|
this.cursorPosition = void 0;
|
|
33171
33398
|
this.state = {
|
|
33172
33399
|
enterTheMatrix: 0
|
|
@@ -34896,6 +35123,9 @@ class NumberLine extends React.Component {
|
|
|
34896
35123
|
assert$3(_.isFinite(x));
|
|
34897
35124
|
return x;
|
|
34898
35125
|
};
|
|
35126
|
+
// This function is intended to be used by the client code
|
|
35127
|
+
// and by test code to directly set the target number line
|
|
35128
|
+
// position
|
|
34899
35129
|
this.movePosition = targetPosition => {
|
|
34900
35130
|
this.change({
|
|
34901
35131
|
numLinePosition: targetPosition
|
|
@@ -34965,6 +35195,7 @@ class NumberLine extends React.Component {
|
|
|
34965
35195
|
rel: newRel
|
|
34966
35196
|
});
|
|
34967
35197
|
};
|
|
35198
|
+
// @ts-expect-error - TS2322 - Type '(props: any) => any[]' is not assignable to type '(arg1: any) => [number, number]'.
|
|
34968
35199
|
this._getInequalityEndpoint = props => {
|
|
34969
35200
|
const isGreater = _(["ge", "gt"]).contains(props.rel);
|
|
34970
35201
|
const widthInPixels = 400;
|
|
@@ -34976,6 +35207,7 @@ class NumberLine extends React.Component {
|
|
|
34976
35207
|
const end = isGreater ? [right, 0] : [left, 0];
|
|
34977
35208
|
return end;
|
|
34978
35209
|
};
|
|
35210
|
+
// @ts-expect-error - TS2322 - Type '(props: any) => Element | null' is not assignable to type '(arg1: any) => ReactElement<any, string | JSXElementConstructor<any>>'.
|
|
34979
35211
|
this._renderInequality = props => {
|
|
34980
35212
|
if (props.isInequality) {
|
|
34981
35213
|
const end = this._getInequalityEndpoint(props);
|
|
@@ -35232,6 +35464,7 @@ const PropTypePosition = PropTypes.shape({
|
|
|
35232
35464
|
class Card extends React.Component {
|
|
35233
35465
|
constructor(...args) {
|
|
35234
35466
|
super(...args);
|
|
35467
|
+
// @ts-expect-error - TS2564 - Property 'mouseMoveUpBound' has no initializer and is not definitely assigned in the constructor.
|
|
35235
35468
|
this.mouseMoveUpBound = void 0;
|
|
35236
35469
|
this.state = {
|
|
35237
35470
|
dragging: false
|
|
@@ -35612,6 +35845,9 @@ class Orderer extends React.Component {
|
|
|
35612
35845
|
}
|
|
35613
35846
|
return draggableOffset.left + draggableWidth / 2 < bankOffset.left + bankWidth;
|
|
35614
35847
|
};
|
|
35848
|
+
// This component makes use of a lot of DOM manipulation
|
|
35849
|
+
// For testing and direct manipulation of values there's a function
|
|
35850
|
+
// to directly set the list value
|
|
35615
35851
|
this.setListValues = values => {
|
|
35616
35852
|
const list = values.map(value => {
|
|
35617
35853
|
return {
|
|
@@ -36568,6 +36804,7 @@ class HighlightSetRenderer extends React.PureComponent {
|
|
|
36568
36804
|
hoveredHighlightKey: null,
|
|
36569
36805
|
hoveringTooltipFor: null
|
|
36570
36806
|
};
|
|
36807
|
+
// eslint-disable-next-line react/sort-comp
|
|
36571
36808
|
this._highlightRenderers = {};
|
|
36572
36809
|
this._handleMouseMove = e => {
|
|
36573
36810
|
const mouseClientPosition = {
|
|
@@ -37015,11 +37252,15 @@ class WordIndexer extends React.PureComponent {
|
|
|
37015
37252
|
class HighlightableContent extends React.PureComponent {
|
|
37016
37253
|
constructor(...args) {
|
|
37017
37254
|
super(...args);
|
|
37255
|
+
// References to the mounted container and content divs.
|
|
37018
37256
|
this._container = void 0;
|
|
37019
37257
|
this._content = void 0;
|
|
37020
37258
|
this.state = {
|
|
37021
37259
|
wordRanges: []
|
|
37022
37260
|
};
|
|
37261
|
+
/**
|
|
37262
|
+
* Add the given DOMHighlight to the current set.
|
|
37263
|
+
*/
|
|
37023
37264
|
this._handleAddHighlight = highlight => {
|
|
37024
37265
|
const newDomHighlights = addHighlight(this._getDOMHighlights(), highlight);
|
|
37025
37266
|
const newSerializedHighlights = {};
|
|
@@ -37028,6 +37269,10 @@ class HighlightableContent extends React.PureComponent {
|
|
|
37028
37269
|
}
|
|
37029
37270
|
this.props.onSerializedHighlightsUpdate(newSerializedHighlights);
|
|
37030
37271
|
};
|
|
37272
|
+
/**
|
|
37273
|
+
* Remove the given highlight from the list, and call our callback with the
|
|
37274
|
+
* new set of highlights.
|
|
37275
|
+
*/
|
|
37031
37276
|
this._handleRemoveHighlight = keyToRemove => {
|
|
37032
37277
|
const {
|
|
37033
37278
|
serializedHighlights
|
|
@@ -37037,6 +37282,10 @@ class HighlightableContent extends React.PureComponent {
|
|
|
37037
37282
|
delete newSerializedHighlights[keyToRemove];
|
|
37038
37283
|
this.props.onSerializedHighlightsUpdate(newSerializedHighlights);
|
|
37039
37284
|
};
|
|
37285
|
+
/**
|
|
37286
|
+
* When our WordIndexer sends us a new cache of word ranges, store it in
|
|
37287
|
+
* our component state.
|
|
37288
|
+
*/
|
|
37040
37289
|
this._handleWordsUpdate = wordRanges => {
|
|
37041
37290
|
this.setState({
|
|
37042
37291
|
wordRanges
|
|
@@ -37067,11 +37316,6 @@ class HighlightableContent extends React.PureComponent {
|
|
|
37067
37316
|
}
|
|
37068
37317
|
return domHighlights;
|
|
37069
37318
|
}
|
|
37070
|
-
|
|
37071
|
-
/**
|
|
37072
|
-
* Add the given DOMHighlight to the current set.
|
|
37073
|
-
*/
|
|
37074
|
-
|
|
37075
37319
|
render() {
|
|
37076
37320
|
const highlights = this._getDOMHighlights();
|
|
37077
37321
|
|
|
@@ -37165,6 +37409,7 @@ function getInitialParseState() {
|
|
|
37165
37409
|
class RefStart extends React.Component {
|
|
37166
37410
|
constructor(...args) {
|
|
37167
37411
|
super(...args);
|
|
37412
|
+
// @ts-expect-error - TS2322 - Type '() => React.ReactNode' is not assignable to type '() => ReactElement<any, string | JSXElementConstructor<any>>'.
|
|
37168
37413
|
this.getRefContent = () => {
|
|
37169
37414
|
return this.props.refContent;
|
|
37170
37415
|
};
|
|
@@ -37174,10 +37419,7 @@ class RefStart extends React.Component {
|
|
|
37174
37419
|
style: REF_STYLE
|
|
37175
37420
|
}, i18n.doNotTranslate("_"));
|
|
37176
37421
|
}
|
|
37177
|
-
|
|
37178
|
-
// @ts-expect-error - TS2322 - Type '() => React.ReactNode' is not assignable to type '() => ReactElement<any, string | JSXElementConstructor<any>>'.
|
|
37179
37422
|
}
|
|
37180
|
-
|
|
37181
37423
|
class RefEnd extends React.Component {
|
|
37182
37424
|
render() {
|
|
37183
37425
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -37538,12 +37780,19 @@ const styles$8 = StyleSheet.create({
|
|
|
37538
37780
|
zIndex: -1
|
|
37539
37781
|
}
|
|
37540
37782
|
});
|
|
37783
|
+
|
|
37784
|
+
// The result of the `transform` function (end of this file)
|
|
37785
|
+
|
|
37786
|
+
// Information about a passage reference, used in inter-widgets.
|
|
37787
|
+
|
|
37541
37788
|
class Passage extends React.Component {
|
|
37542
37789
|
constructor(...args) {
|
|
37543
37790
|
super(...args);
|
|
37544
37791
|
this._contentRef = void 0;
|
|
37545
37792
|
this._lineHeightMeasurerRef = void 0;
|
|
37793
|
+
// @ts-expect-error - TS2564 - Property '_onResize' has no initializer and is not definitely assigned in the constructor.
|
|
37546
37794
|
this._onResize = void 0;
|
|
37795
|
+
// @ts-expect-error - TS2564 - Property '_stylesAppiedTimer' has no initializer and is not definitely assigned in the constructor.
|
|
37547
37796
|
this._stylesAppiedTimer = void 0;
|
|
37548
37797
|
this.state = {
|
|
37549
37798
|
nLines: null,
|
|
@@ -37572,7 +37821,7 @@ class Passage extends React.Component {
|
|
|
37572
37821
|
// height changes we expect are subpixel changes when the user
|
|
37573
37822
|
// zooms in/out, and the only way to listen for zoom events is to
|
|
37574
37823
|
// listen for resize events.
|
|
37575
|
-
(_this$_lineHeightMeas = this._lineHeightMeasurerRef) == null
|
|
37824
|
+
(_this$_lineHeightMeas = this._lineHeightMeasurerRef) == null || _this$_lineHeightMeas.measureLineHeight();
|
|
37576
37825
|
this._updateState();
|
|
37577
37826
|
}, 500);
|
|
37578
37827
|
window.addEventListener("resize", this._onResize);
|
|
@@ -37991,14 +38240,10 @@ var PassageRefTarget$1 = {
|
|
|
37991
38240
|
const {
|
|
37992
38241
|
deepEq: deepEq$1
|
|
37993
38242
|
} = Util;
|
|
37994
|
-
const BAR = "bar";
|
|
37995
|
-
const LINE = "line";
|
|
37996
|
-
const PIC = "pic";
|
|
37997
|
-
const HISTOGRAM = "histogram";
|
|
37998
|
-
const DOTPLOT = "dotplot";
|
|
37999
38243
|
class Plotter extends React.Component {
|
|
38000
38244
|
constructor(..._args) {
|
|
38001
38245
|
super(..._args);
|
|
38246
|
+
// @ts-expect-error - TS2564 - Property 'shouldSetupGraphie' has no initializer and is not definitely assigned in the constructor.
|
|
38002
38247
|
this.shouldSetupGraphie = void 0;
|
|
38003
38248
|
this._isMounted = false;
|
|
38004
38249
|
this.horizHairline = void 0;
|
|
@@ -38034,11 +38279,11 @@ class Plotter extends React.Component {
|
|
|
38034
38279
|
self.graphie = graphie;
|
|
38035
38280
|
self.graphie.pics = [];
|
|
38036
38281
|
self.graphie.dotTicks = [];
|
|
38037
|
-
const isBar = self.props.type ===
|
|
38038
|
-
const isLine = self.props.type ===
|
|
38039
|
-
const isPic = self.props.type ===
|
|
38040
|
-
const isHistogram = self.props.type ===
|
|
38041
|
-
const isDotplot = self.props.type ===
|
|
38282
|
+
const isBar = self.props.type === "bar";
|
|
38283
|
+
const isLine = self.props.type === "line";
|
|
38284
|
+
const isPic = self.props.type === "pic";
|
|
38285
|
+
const isHistogram = self.props.type === "histogram";
|
|
38286
|
+
const isDotplot = self.props.type === "dotplot";
|
|
38042
38287
|
const isTiledPlot = isPic || isDotplot;
|
|
38043
38288
|
const config = {};
|
|
38044
38289
|
const c = config; // c for short
|
|
@@ -38216,7 +38461,7 @@ class Plotter extends React.Component {
|
|
|
38216
38461
|
}
|
|
38217
38462
|
};
|
|
38218
38463
|
this.showHairlines = point => {
|
|
38219
|
-
if (this.props.apiOptions.isMobile
|
|
38464
|
+
if (this.props.apiOptions.isMobile) {
|
|
38220
38465
|
// Hairlines are already initialized when the graph is loaded, so
|
|
38221
38466
|
// here we just move them to the updated location and make them
|
|
38222
38467
|
// visible.
|
|
@@ -38271,7 +38516,7 @@ class Plotter extends React.Component {
|
|
|
38271
38516
|
|
|
38272
38517
|
// The deferred measurements returned from `labelCategory`.
|
|
38273
38518
|
const categoryHeightPromises = [];
|
|
38274
|
-
if (self.props.type ===
|
|
38519
|
+
if (self.props.type === "histogram") {
|
|
38275
38520
|
// Histograms with n labels/categories have n - 1 buckets
|
|
38276
38521
|
_.times(self.props.categories.length - 1, function (i) {
|
|
38277
38522
|
self.setupBar({
|
|
@@ -38301,26 +38546,26 @@ class Plotter extends React.Component {
|
|
|
38301
38546
|
_.each(self.props.categories, function (category, i) {
|
|
38302
38547
|
const startHeight = self.state.values[i];
|
|
38303
38548
|
let x;
|
|
38304
|
-
if (self.props.type ===
|
|
38549
|
+
if (self.props.type === "bar") {
|
|
38305
38550
|
x = self.setupBar({
|
|
38306
38551
|
index: i,
|
|
38307
38552
|
startHeight: startHeight,
|
|
38308
38553
|
config: config,
|
|
38309
38554
|
isHistogram: false
|
|
38310
38555
|
});
|
|
38311
|
-
} else if (self.props.type ===
|
|
38556
|
+
} else if (self.props.type === "line") {
|
|
38312
38557
|
x = self.setupLine(i, startHeight, config);
|
|
38313
|
-
} else if (self.props.type ===
|
|
38558
|
+
} else if (self.props.type === "pic") {
|
|
38314
38559
|
x = self.setupPic(i, config);
|
|
38315
|
-
} else if (self.props.type ===
|
|
38560
|
+
} else if (self.props.type === "dotplot") {
|
|
38316
38561
|
x = self.setupDotplot(i, config);
|
|
38317
38562
|
}
|
|
38318
38563
|
let tickStart = 0;
|
|
38319
38564
|
let tickEnd = -6 / c.scale[1];
|
|
38320
|
-
if (self.props.type ===
|
|
38565
|
+
if (self.props.type === "dotplot" && !isMobile) {
|
|
38321
38566
|
tickStart = -tickEnd;
|
|
38322
38567
|
}
|
|
38323
|
-
if (self.props.type ===
|
|
38568
|
+
if (self.props.type === "dotplot") {
|
|
38324
38569
|
// Dotplot lets you specify to only show labels every 'n'
|
|
38325
38570
|
// ticks. It also looks nicer if it makes the labelled
|
|
38326
38571
|
// ticks a bit bigger.
|
|
@@ -38446,7 +38691,7 @@ class Plotter extends React.Component {
|
|
|
38446
38691
|
},
|
|
38447
38692
|
onMove: function () {
|
|
38448
38693
|
const y = config.graph.lines[i].coord()[1];
|
|
38449
|
-
const values =
|
|
38694
|
+
const values = [...self.state.values];
|
|
38450
38695
|
values[i] = y;
|
|
38451
38696
|
self.setState({
|
|
38452
38697
|
values: values
|
|
@@ -38491,7 +38736,7 @@ class Plotter extends React.Component {
|
|
|
38491
38736
|
// Snap the line back into range.
|
|
38492
38737
|
this.transform();
|
|
38493
38738
|
}
|
|
38494
|
-
const values =
|
|
38739
|
+
const values = [...self.state.values];
|
|
38495
38740
|
values[i] = y;
|
|
38496
38741
|
self.setState({
|
|
38497
38742
|
values: values
|
|
@@ -38505,6 +38750,12 @@ class Plotter extends React.Component {
|
|
|
38505
38750
|
scaleBar(i, startHeight);
|
|
38506
38751
|
return x;
|
|
38507
38752
|
};
|
|
38753
|
+
/**
|
|
38754
|
+
* Renders a segment of an interactive line to the plotter graph
|
|
38755
|
+
* @param i the index of the point to render
|
|
38756
|
+
* @param startHeight the initial height of the given point
|
|
38757
|
+
* @param config the graph setup, such as scale and dimensions
|
|
38758
|
+
*/
|
|
38508
38759
|
this.setupLine = (i, startHeight, config) => {
|
|
38509
38760
|
const isMobile = this.props.apiOptions.isMobile;
|
|
38510
38761
|
const self = this;
|
|
@@ -38520,7 +38771,7 @@ class Plotter extends React.Component {
|
|
|
38520
38771
|
}],
|
|
38521
38772
|
onMove: function () {
|
|
38522
38773
|
const y = c.graph.points[i].coord()[1];
|
|
38523
|
-
const values =
|
|
38774
|
+
const values = [...self.state.values];
|
|
38524
38775
|
values[i] = y;
|
|
38525
38776
|
self.setState({
|
|
38526
38777
|
values: values
|
|
@@ -38561,7 +38812,7 @@ class Plotter extends React.Component {
|
|
|
38561
38812
|
});
|
|
38562
38813
|
c.graph.points[i].onMove = function (x, y) {
|
|
38563
38814
|
y = Math.min(Math.max(y, 0), c.dimY);
|
|
38564
|
-
const values =
|
|
38815
|
+
const values = [...self.state.values];
|
|
38565
38816
|
values[i] = y;
|
|
38566
38817
|
self.setState({
|
|
38567
38818
|
values: values
|
|
@@ -38674,7 +38925,7 @@ class Plotter extends React.Component {
|
|
|
38674
38925
|
return x;
|
|
38675
38926
|
};
|
|
38676
38927
|
this.setPicHeight = (i, y) => {
|
|
38677
|
-
const values =
|
|
38928
|
+
const values = [...this.state.values];
|
|
38678
38929
|
values[i] = y;
|
|
38679
38930
|
this.drawPicHeights(values, this.state.values);
|
|
38680
38931
|
this.setState({
|
|
@@ -38701,7 +38952,7 @@ class Plotter extends React.Component {
|
|
|
38701
38952
|
_.each(ps, function (pic, j) {
|
|
38702
38953
|
const y = (j + 1) * self.props.scaleY;
|
|
38703
38954
|
const show = y <= values[i];
|
|
38704
|
-
if (self.props.type ===
|
|
38955
|
+
if (self.props.type === "dotplot") {
|
|
38705
38956
|
const wasShown = y <= prevValues[i];
|
|
38706
38957
|
const wasJustShown = show && !wasShown;
|
|
38707
38958
|
if (wasJustShown) {
|
|
@@ -38768,7 +39019,7 @@ class Plotter extends React.Component {
|
|
|
38768
39019
|
}
|
|
38769
39020
|
}
|
|
38770
39021
|
Plotter.defaultProps = {
|
|
38771
|
-
type:
|
|
39022
|
+
type: "bar",
|
|
38772
39023
|
labels: ["", ""],
|
|
38773
39024
|
categories: [""],
|
|
38774
39025
|
scaleY: 1,
|
|
@@ -39175,6 +39426,7 @@ const maxSampleSize = 1000;
|
|
|
39175
39426
|
class Histogram extends React.Component {
|
|
39176
39427
|
constructor(...args) {
|
|
39177
39428
|
super(...args);
|
|
39429
|
+
/* Renders the vertical line that users can drag across the histogram. */
|
|
39178
39430
|
this._renderThresholdLine = () => {
|
|
39179
39431
|
// Recall the the y-range goes from [-1, yMax] to allow for ticks on
|
|
39180
39432
|
// the x-axis.
|
|
@@ -39198,6 +39450,7 @@ class Histogram extends React.Component {
|
|
|
39198
39450
|
onMove: this.handleMouseInteraction
|
|
39199
39451
|
}, _.map(coords, invisiblePointForCoord));
|
|
39200
39452
|
};
|
|
39453
|
+
/* Renders the shaded circle in the top right. */
|
|
39201
39454
|
this._renderCircle = () => {
|
|
39202
39455
|
const data = this.props.data;
|
|
39203
39456
|
|
|
@@ -39273,6 +39526,7 @@ class Histogram extends React.Component {
|
|
|
39273
39526
|
};
|
|
39274
39527
|
return [proportionBelow > 0 && plotBelowCircle(), proportionBelow < 1 && plotAboveCircle(), plotLabel()];
|
|
39275
39528
|
};
|
|
39529
|
+
/* Renders the actual bars of the histogram. */
|
|
39276
39530
|
this._renderData = () => {
|
|
39277
39531
|
const data = this.props.data;
|
|
39278
39532
|
// @ts-expect-error - TS2554 - Expected 1 arguments, but got 0.
|
|
@@ -39362,6 +39616,7 @@ class Histogram extends React.Component {
|
|
|
39362
39616
|
threshold: point[0]
|
|
39363
39617
|
});
|
|
39364
39618
|
};
|
|
39619
|
+
/* Convenience functions that help calculate props based on other props. */
|
|
39365
39620
|
this._range = props => {
|
|
39366
39621
|
const defaultRange = [[0, 100], [-1, 10]];
|
|
39367
39622
|
props = props || this.props;
|
|
@@ -39404,9 +39659,6 @@ class Histogram extends React.Component {
|
|
|
39404
39659
|
});
|
|
39405
39660
|
}
|
|
39406
39661
|
}
|
|
39407
|
-
|
|
39408
|
-
/* Renders the vertical line that users can drag across the histogram. */
|
|
39409
|
-
|
|
39410
39662
|
render() {
|
|
39411
39663
|
const data = this.props.data;
|
|
39412
39664
|
// @ts-expect-error - TS2554 - Expected 1 arguments, but got 0.
|
|
@@ -39456,6 +39708,7 @@ Histogram.defaultProps = {
|
|
|
39456
39708
|
class Simulator extends React.Component {
|
|
39457
39709
|
constructor(..._args) {
|
|
39458
39710
|
super(..._args);
|
|
39711
|
+
// @ts-expect-error - TS2564 - Property 'generateNumber' has no initializer and is not definitely assigned in the constructor.
|
|
39459
39712
|
this.generateNumber = void 0;
|
|
39460
39713
|
this.state = {
|
|
39461
39714
|
invalidInput: false
|
|
@@ -39495,6 +39748,7 @@ class Simulator extends React.Component {
|
|
|
39495
39748
|
userProportion: userProportion
|
|
39496
39749
|
}, cb);
|
|
39497
39750
|
};
|
|
39751
|
+
// @ts-expect-error - TS2322 - Type '(sampleSize: any, cb: any) => void' is not assignable to type '(number: any) => void'.
|
|
39498
39752
|
this.handleSampleSizeChange = (sampleSize, cb) => {
|
|
39499
39753
|
if (sampleSize != null) {
|
|
39500
39754
|
sampleSize = Math.min(maxSampleSize, Math.max(0, Math.floor(sampleSize)));
|
|
@@ -39537,6 +39791,7 @@ class Simulator extends React.Component {
|
|
|
39537
39791
|
};
|
|
39538
39792
|
return getSampleDistribution(props.sampleSize, props.numTrials, props.userProportion);
|
|
39539
39793
|
};
|
|
39794
|
+
/* InputPath API */
|
|
39540
39795
|
this.getInputPaths = () => {
|
|
39541
39796
|
return [["userProportion"], ["sampleSize"]];
|
|
39542
39797
|
};
|
|
@@ -39746,6 +40001,7 @@ const VERTICAL = "vertical";
|
|
|
39746
40001
|
class Sorter extends React.Component {
|
|
39747
40002
|
constructor(...args) {
|
|
39748
40003
|
super(...args);
|
|
40004
|
+
// @ts-expect-error - TS2564 - Property '_isMounted' has no initializer and is not definitely assigned in the constructor.
|
|
39749
40005
|
this._isMounted = void 0;
|
|
39750
40006
|
this.state = {
|
|
39751
40007
|
changed: false
|
|
@@ -40567,6 +40823,7 @@ const Transformations = {
|
|
|
40567
40823
|
vector: [x, y]
|
|
40568
40824
|
};
|
|
40569
40825
|
};
|
|
40826
|
+
/* InputPath API */
|
|
40570
40827
|
this.setInputValue = (path, value, cb) => {
|
|
40571
40828
|
const id = _.first(path);
|
|
40572
40829
|
const vector = _.clone(this.state.vector);
|
|
@@ -40704,6 +40961,7 @@ const Transformations = {
|
|
|
40704
40961
|
center: [centerX, centerY]
|
|
40705
40962
|
};
|
|
40706
40963
|
};
|
|
40964
|
+
/* InputPath API */
|
|
40707
40965
|
this.setInputValue = (path, value, cb) => {
|
|
40708
40966
|
const id = _.first(path);
|
|
40709
40967
|
let angleDeg = _.clone(this.state.angleDeg);
|
|
@@ -40882,6 +41140,7 @@ const Transformations = {
|
|
|
40882
41140
|
line: [[x1, y1], [x2, y2]]
|
|
40883
41141
|
};
|
|
40884
41142
|
};
|
|
41143
|
+
/* InputPath API */
|
|
40885
41144
|
this.setInputValue = (path, value, cb) => {
|
|
40886
41145
|
const id = _.first(path);
|
|
40887
41146
|
let j;
|
|
@@ -41044,6 +41303,7 @@ const Transformations = {
|
|
|
41044
41303
|
center: [x, y]
|
|
41045
41304
|
};
|
|
41046
41305
|
};
|
|
41306
|
+
/* InputPath API */
|
|
41047
41307
|
this.setInputValue = (path, value, cb) => {
|
|
41048
41308
|
const id = _.first(path);
|
|
41049
41309
|
let scale = this.state.scale;
|
|
@@ -41690,13 +41950,19 @@ class AddTransformBar extends React.Component {
|
|
|
41690
41950
|
}));
|
|
41691
41951
|
}
|
|
41692
41952
|
}
|
|
41953
|
+
|
|
41954
|
+
// there's no transform in the exports
|
|
41955
|
+
|
|
41693
41956
|
class Transformer extends React.Component {
|
|
41694
41957
|
constructor(..._args) {
|
|
41695
41958
|
super(..._args);
|
|
41959
|
+
// @ts-expect-error - TS2564 - Property 'tools' has no initializer and is not definitely assigned in the constructor.
|
|
41696
41960
|
this.tools = void 0;
|
|
41697
41961
|
this.currentTool = void 0;
|
|
41962
|
+
// @ts-expect-error - TS2564 - Property 'transformations' has no initializer and is not definitely assigned in the constructor.
|
|
41698
41963
|
this.transformations = void 0;
|
|
41699
41964
|
this.shape = void 0;
|
|
41965
|
+
// This is not the same as TransformerShape
|
|
41700
41966
|
this.dilationCircle = void 0;
|
|
41701
41967
|
this.rotatePoint = void 0;
|
|
41702
41968
|
this.rotateHandle = void 0;
|
|
@@ -41761,11 +42027,18 @@ class Transformer extends React.Component {
|
|
|
41761
42027
|
dilation: _.clone(this.props.tools.dilation)
|
|
41762
42028
|
};
|
|
41763
42029
|
};
|
|
42030
|
+
/* Applies all transformations in `transformations`
|
|
42031
|
+
* to the starting shape, and updates this.transformations
|
|
42032
|
+
* to reflect this
|
|
42033
|
+
*
|
|
42034
|
+
* Usually called with this.props.transformations
|
|
42035
|
+
*/
|
|
41764
42036
|
this.setTransformations = transformations => {
|
|
41765
42037
|
this.resetCoords();
|
|
41766
42038
|
this.transformations = _.clone(transformations);
|
|
41767
42039
|
_.each(this.transformations, this.applyTransform);
|
|
41768
42040
|
};
|
|
42041
|
+
// the polygon that we transform
|
|
41769
42042
|
this.addTransformerShape = (shape, translatable) => {
|
|
41770
42043
|
const self = this;
|
|
41771
42044
|
const graphie = this.graphie();
|
|
@@ -41872,22 +42145,27 @@ class Transformer extends React.Component {
|
|
|
41872
42145
|
this.addTranslationTool = () => {
|
|
41873
42146
|
var _this$shape, _this$shape2;
|
|
41874
42147
|
const self = this;
|
|
41875
|
-
(_this$shape = this.shape) == null
|
|
42148
|
+
(_this$shape = this.shape) == null || _this$shape.remove();
|
|
41876
42149
|
this.addTransformerShape((_this$shape2 = this.shape) == null ? void 0 : _this$shape2.toJSON(), /* translatable */true);
|
|
41877
42150
|
return {
|
|
41878
42151
|
remove: function () {
|
|
41879
42152
|
var _self$shape, _self$shape2;
|
|
41880
|
-
(_self$shape = self.shape) == null
|
|
42153
|
+
(_self$shape = self.shape) == null || _self$shape.remove();
|
|
41881
42154
|
self.addTransformerShape((_self$shape2 = self.shape) == null ? void 0 : _self$shape2.toJSON(), /* translatable */false);
|
|
41882
42155
|
}
|
|
41883
42156
|
};
|
|
41884
42157
|
};
|
|
42158
|
+
// Snaps a coord to this.graphie()'s snap
|
|
42159
|
+
// @ts-expect-error - TS2322 - Type '(coord: Coord) => number[]' is not assignable to type '(arg1: Coord) => Coord'.
|
|
41885
42160
|
this.snapCoord = coord => {
|
|
41886
42161
|
const graphie = this.graphie();
|
|
41887
42162
|
return _.map(coord, function (val, dim) {
|
|
41888
42163
|
return KhanMath.roundToNearest(graphie.snap[dim], val);
|
|
41889
42164
|
});
|
|
41890
42165
|
};
|
|
42166
|
+
// Normalize the coords into something that fits the new 45 degree
|
|
42167
|
+
// reflection line.
|
|
42168
|
+
// @ts-expect-error - TS2322 - Type '(messyCoords: [Coord, Coord]) => any[]' is not assignable to type '(arg1: [Coord, Coord]) => [Coord, Coord]'.
|
|
41891
42169
|
this.normalizeReflectionCoords = messyCoords => {
|
|
41892
42170
|
// @ts-expect-error - TS2345 - Argument of type 'Point' is not assignable to parameter of type 'Coord'.
|
|
41893
42171
|
const midpoint = this.snapCoord(line.midpoint(messyCoords));
|
|
@@ -42046,6 +42324,12 @@ class Transformer extends React.Component {
|
|
|
42046
42324
|
}
|
|
42047
42325
|
};
|
|
42048
42326
|
};
|
|
42327
|
+
/* Scales a distance from the default range of
|
|
42328
|
+
* [-10, 10] to the current this.props.graph.range
|
|
42329
|
+
*
|
|
42330
|
+
* Used for sizing various transformation tools
|
|
42331
|
+
* (rotation handle, dilation circle)
|
|
42332
|
+
*/
|
|
42049
42333
|
this.scaleToCurrentRange = dist => {
|
|
42050
42334
|
// eslint-disable-next-line react/no-string-refs
|
|
42051
42335
|
// @ts-expect-error - TS2339 - Property 'props' does not exist on type 'ReactInstance'.
|
|
@@ -42109,8 +42393,8 @@ class Transformer extends React.Component {
|
|
|
42109
42393
|
return {
|
|
42110
42394
|
remove: function () {
|
|
42111
42395
|
var _self$rotateHandle, _self$rotatePoint;
|
|
42112
|
-
(_self$rotateHandle = self.rotateHandle) == null
|
|
42113
|
-
(_self$rotatePoint = self.rotatePoint) == null
|
|
42396
|
+
(_self$rotateHandle = self.rotateHandle) == null || _self$rotateHandle.remove();
|
|
42397
|
+
(_self$rotatePoint = self.rotatePoint) == null || _self$rotatePoint.remove();
|
|
42114
42398
|
}
|
|
42115
42399
|
};
|
|
42116
42400
|
};
|
|
@@ -42180,10 +42464,13 @@ class Transformer extends React.Component {
|
|
|
42180
42464
|
return {
|
|
42181
42465
|
remove: function () {
|
|
42182
42466
|
var _self$dilationCircle;
|
|
42183
|
-
(_self$dilationCircle = self.dilationCircle) == null
|
|
42467
|
+
(_self$dilationCircle = self.dilationCircle) == null || _self$dilationCircle.remove();
|
|
42184
42468
|
}
|
|
42185
42469
|
};
|
|
42186
42470
|
};
|
|
42471
|
+
// returns a transformation object representing a rotation
|
|
42472
|
+
// rounds the angle to the nearest 15 degrees
|
|
42473
|
+
// @ts-expect-error - TS2322 - Type '(center: Coord, angleChanged: number) => { type: "rotation"; center: Coord; angleDeg: number; }' is not assignable to type '(arg1: Coord, arg2: number) => PerseusTransformerTransformation'.
|
|
42187
42474
|
this.getRotationTransformFromAngle = (center, angleChanged) => {
|
|
42188
42475
|
angleChanged = (angleChanged + 360) % 360;
|
|
42189
42476
|
if (angleChanged > 180) {
|
|
@@ -42198,10 +42485,13 @@ class Transformer extends React.Component {
|
|
|
42198
42485
|
angleDeg: roundedAngle
|
|
42199
42486
|
};
|
|
42200
42487
|
};
|
|
42488
|
+
// apply and save a transform
|
|
42201
42489
|
this.doTransform = (transform, callback) => {
|
|
42202
42490
|
this.applyTransform(transform);
|
|
42203
42491
|
this.addTransform(transform, callback);
|
|
42204
42492
|
};
|
|
42493
|
+
// apply a transform to our polygon (without modifying our transformation
|
|
42494
|
+
// list)
|
|
42205
42495
|
this.applyTransform = transform => {
|
|
42206
42496
|
if (this.props.graphMode !== "static") {
|
|
42207
42497
|
const transformFunc = TransformOps.apply(transform);
|
|
@@ -42209,6 +42499,7 @@ class Transformer extends React.Component {
|
|
|
42209
42499
|
this.applyCoordTransformation(transformFunc);
|
|
42210
42500
|
}
|
|
42211
42501
|
};
|
|
42502
|
+
// transform our polygon by transforming each point using a given function
|
|
42212
42503
|
this.applyCoordTransformation = pointTransform => {
|
|
42213
42504
|
var _this$shape3;
|
|
42214
42505
|
_.each(this.shape.points, function (point) {
|
|
@@ -42216,7 +42507,7 @@ class Transformer extends React.Component {
|
|
|
42216
42507
|
const newCoord = pointTransform(point.coord);
|
|
42217
42508
|
point.setCoord(newCoord);
|
|
42218
42509
|
});
|
|
42219
|
-
(_this$shape3 = this.shape) == null
|
|
42510
|
+
(_this$shape3 = this.shape) == null || _this$shape3.update();
|
|
42220
42511
|
};
|
|
42221
42512
|
this.resetCoords = () => {
|
|
42222
42513
|
var _this$shape4;
|
|
@@ -42224,8 +42515,9 @@ class Transformer extends React.Component {
|
|
|
42224
42515
|
_.each(this.shape.points, function (point, i) {
|
|
42225
42516
|
point.setCoord(startCoords[i]);
|
|
42226
42517
|
});
|
|
42227
|
-
(_this$shape4 = this.shape) == null
|
|
42518
|
+
(_this$shape4 = this.shape) == null || _this$shape4.update();
|
|
42228
42519
|
};
|
|
42520
|
+
// Remove the last transformation
|
|
42229
42521
|
this.handleUndoClick = () => {
|
|
42230
42522
|
// eslint-disable-next-line react/no-string-refs
|
|
42231
42523
|
// @ts-expect-error - TS2339 - Property 'changeSelected' does not exist on type 'ReactInstance'.
|
|
@@ -42243,6 +42535,7 @@ class Transformer extends React.Component {
|
|
|
42243
42535
|
// @ts-expect-error - TS2345 - Argument of type '(arg1: any) => unknown' is not assignable to parameter of type '() => unknown'.
|
|
42244
42536
|
callback);
|
|
42245
42537
|
};
|
|
42538
|
+
// add a transformation to our props list of transformation
|
|
42246
42539
|
this.addTransform = (transform, callback) => {
|
|
42247
42540
|
this.transformations = TransformOps.append(this.transformations, transform);
|
|
42248
42541
|
this.props.onChange({
|
|
@@ -42264,6 +42557,12 @@ class Transformer extends React.Component {
|
|
|
42264
42557
|
this.simpleValidate = rubric => {
|
|
42265
42558
|
return Transformer.validate(this.getUserInput(), rubric);
|
|
42266
42559
|
};
|
|
42560
|
+
/**
|
|
42561
|
+
* Calculate where the coordinates would be if they were
|
|
42562
|
+
* moved, even if we're in formal mode with no movement
|
|
42563
|
+
* (and thus the actual movablepoints may not have moved
|
|
42564
|
+
*/
|
|
42565
|
+
// @ts-expect-error - TS2322 - Type '() => [Coord, Coord] | readonly Coord[] | [Coord, Coord, Coord]' is not assignable to type '() => Coord'.
|
|
42267
42566
|
this.getCoords = () => {
|
|
42268
42567
|
const startCoords = this.props.starting.shape.coords;
|
|
42269
42568
|
const transforms = this.props.transformations;
|
|
@@ -42299,6 +42598,7 @@ class Transformer extends React.Component {
|
|
|
42299
42598
|
}
|
|
42300
42599
|
};
|
|
42301
42600
|
};
|
|
42601
|
+
/* InputPath API */
|
|
42302
42602
|
this._handleFocus = (...path) => {
|
|
42303
42603
|
this.props.onFocus(path);
|
|
42304
42604
|
};
|
|
@@ -43389,6 +43689,7 @@ class OldUnitInput extends React.Component {
|
|
|
43389
43689
|
this.getUserInput = () => {
|
|
43390
43690
|
return this.props.value;
|
|
43391
43691
|
};
|
|
43692
|
+
// begin mobile stuff
|
|
43392
43693
|
this.getInputPaths = () => {
|
|
43393
43694
|
// The widget itself is an input, so we return a single empty list to
|
|
43394
43695
|
// indicate this.
|
|
@@ -43530,7 +43831,6 @@ class OldUnitInput extends React.Component {
|
|
|
43530
43831
|
clearTimeout(this._errorTimeout);
|
|
43531
43832
|
}
|
|
43532
43833
|
// end mobile stuff
|
|
43533
|
-
|
|
43534
43834
|
// TODO(joel) think about showing the error buddy
|
|
43535
43835
|
render() {
|
|
43536
43836
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -43647,6 +43947,9 @@ const DEFAULT_HEIGHT = 720;
|
|
|
43647
43947
|
const KA_EMBED = "{host}/embed_video?slug={slug}" + "&internal_video_only=1";
|
|
43648
43948
|
const IS_URL = /^https?:\/\//;
|
|
43649
43949
|
const IS_KA_SITE = /(khanacademy\.org|localhost)/;
|
|
43950
|
+
|
|
43951
|
+
// exports has no 'transform'
|
|
43952
|
+
|
|
43650
43953
|
/**
|
|
43651
43954
|
* Video renderer.
|
|
43652
43955
|
*/
|
|
@@ -43768,7 +44071,7 @@ const init = function init(options) {
|
|
|
43768
44071
|
|
|
43769
44072
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
43770
44073
|
const libName = "@khanacademy/perseus";
|
|
43771
|
-
const libVersion = "
|
|
44074
|
+
const libVersion = "13.0.0";
|
|
43772
44075
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
43773
44076
|
|
|
43774
44077
|
const apiVersion = {
|
|
@@ -44027,6 +44330,12 @@ const styles$5 = StyleSheet.create({
|
|
|
44027
44330
|
class HintsRenderer extends React.Component {
|
|
44028
44331
|
constructor(...args) {
|
|
44029
44332
|
super(...args);
|
|
44333
|
+
// The isFinalHelpPage property determines if the user has requested help
|
|
44334
|
+
// after answering an exercise question incorrectly, which differs from
|
|
44335
|
+
// the case when the user is requesting successive hints. In the case
|
|
44336
|
+
// where isFinalHelpPage property is true, we want to display all hints.
|
|
44337
|
+
// We know the user is on the final help page when the hintsVisible
|
|
44338
|
+
// property jumps from 0 to the total number of hints.
|
|
44030
44339
|
this.state = {
|
|
44031
44340
|
isFinalHelpPage: false
|
|
44032
44341
|
};
|
|
@@ -44270,6 +44579,9 @@ const styles$4 = StyleSheet.create({
|
|
|
44270
44579
|
});
|
|
44271
44580
|
|
|
44272
44581
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
44582
|
+
|
|
44583
|
+
// This represents the shape of any component that uses this ProvideKeypad
|
|
44584
|
+
// mixin.
|
|
44273
44585
|
// NOTE: This is not a real component. It's a collection of methods used to
|
|
44274
44586
|
// create and manage a Keypad instances.
|
|
44275
44587
|
// TODO(LP-10789): replace this with a React Context object to pass information
|
|
@@ -44296,7 +44608,7 @@ const ProvideKeypad = {
|
|
|
44296
44608
|
// React tree. We may also want to add this keypad asynchronously
|
|
44297
44609
|
// or on-demand in the future.
|
|
44298
44610
|
_this._keypadContainer = document.createElement("div");
|
|
44299
|
-
(_document$body = document.body) == null
|
|
44611
|
+
(_document$body = document.body) == null || _document$body.appendChild(_this._keypadContainer);
|
|
44300
44612
|
render( /*#__PURE__*/React.createElement(MobileKeypad, {
|
|
44301
44613
|
onElementMounted: element => {
|
|
44302
44614
|
// NOTE(kevinb): The reason why this setState works is
|
|
@@ -44348,10 +44660,9 @@ const {
|
|
|
44348
44660
|
* @depreciated use ServerItemRenderer
|
|
44349
44661
|
*/
|
|
44350
44662
|
class ItemRenderer extends React.Component {
|
|
44351
|
-
// @ts-expect-error - TS2564 - Property 'questionRenderer' has no initializer and is not definitely assigned in the constructor.
|
|
44352
|
-
|
|
44353
44663
|
constructor(props) {
|
|
44354
44664
|
super(props);
|
|
44665
|
+
// @ts-expect-error - TS2564 - Property 'questionRenderer' has no initializer and is not definitely assigned in the constructor.
|
|
44355
44666
|
this.questionRenderer = void 0;
|
|
44356
44667
|
this.hintsRenderer = void 0;
|
|
44357
44668
|
this._currentFocus = void 0;
|
|
@@ -44362,6 +44673,7 @@ class ItemRenderer extends React.Component {
|
|
|
44362
44673
|
this._onRendererBlur(oldFocus);
|
|
44363
44674
|
}
|
|
44364
44675
|
};
|
|
44676
|
+
// NOTE: this must remain as an arrow function because we pass it Renderer
|
|
44365
44677
|
this.handleInteractWithWidget = widgetId => {
|
|
44366
44678
|
const withRemoved = _.difference(this.state.questionHighlightedWidgets, [widgetId]);
|
|
44367
44679
|
this.setState({
|
|
@@ -44496,7 +44808,9 @@ class ItemRenderer extends React.Component {
|
|
|
44496
44808
|
this.props.onShowCalculator && this.props.onShowCalculator();
|
|
44497
44809
|
}
|
|
44498
44810
|
if (answerArea.periodicTable) {
|
|
44499
|
-
this.props.onShowPeriodicTable && this.props.onShowPeriodicTable(
|
|
44811
|
+
this.props.onShowPeriodicTable && this.props.onShowPeriodicTable({
|
|
44812
|
+
showKey: answerArea.periodicTableWithKey
|
|
44813
|
+
});
|
|
44500
44814
|
}
|
|
44501
44815
|
if (answerArea.zTable) {
|
|
44502
44816
|
this.props.onShowZTable && this.props.onShowZTable();
|
|
@@ -44592,9 +44906,6 @@ class ItemRenderer extends React.Component {
|
|
|
44592
44906
|
const questionAreaInputPaths = this.questionRenderer.getInputPaths();
|
|
44593
44907
|
return questionAreaInputPaths;
|
|
44594
44908
|
}
|
|
44595
|
-
|
|
44596
|
-
// NOTE: this must remain as an arrow function because we pass it Renderer
|
|
44597
|
-
|
|
44598
44909
|
focus() {
|
|
44599
44910
|
return this.questionRenderer.focus();
|
|
44600
44911
|
}
|
|
@@ -44689,7 +45000,7 @@ class ItemRenderer extends React.Component {
|
|
|
44689
45000
|
}
|
|
44690
45001
|
};
|
|
44691
45002
|
this.questionRenderer.restoreSerializedState(state.question, fireCallback);
|
|
44692
|
-
(_this$hintsRenderer2 = this.hintsRenderer) == null
|
|
45003
|
+
(_this$hintsRenderer2 = this.hintsRenderer) == null || _this$hintsRenderer2.restoreSerializedState(state.hints, fireCallback);
|
|
44693
45004
|
}
|
|
44694
45005
|
showRationalesForCurrentlySelectedChoices() {
|
|
44695
45006
|
this.questionRenderer.showRationalesForCurrentlySelectedChoices();
|
|
@@ -44732,10 +45043,9 @@ const {
|
|
|
44732
45043
|
} = objective_;
|
|
44733
45044
|
/* eslint-disable-next-line react/no-unsafe */
|
|
44734
45045
|
class ServerItemRenderer extends React.Component {
|
|
44735
|
-
// @ts-expect-error - TS2564 - Property 'questionRenderer' has no initializer and is not definitely assigned in the constructor.
|
|
44736
|
-
|
|
44737
45046
|
constructor(props) {
|
|
44738
45047
|
super(props);
|
|
45048
|
+
// @ts-expect-error - TS2564 - Property 'questionRenderer' has no initializer and is not definitely assigned in the constructor.
|
|
44739
45049
|
this.questionRenderer = void 0;
|
|
44740
45050
|
this.hintsRenderer = void 0;
|
|
44741
45051
|
this._currentFocus = void 0;
|
|
@@ -44758,6 +45068,8 @@ class ServerItemRenderer extends React.Component {
|
|
|
44758
45068
|
this.props.apiOptions.interactionCallback();
|
|
44759
45069
|
}
|
|
44760
45070
|
};
|
|
45071
|
+
// This must be pre-bound otherwise SvgImage's shouldComponentUpdate
|
|
45072
|
+
// won't behave correctly and we'll get an infinite loop.
|
|
44761
45073
|
this.setAssetStatus = (assetKey, status) => {
|
|
44762
45074
|
// setState doesn't properly merge objects so we have to do it ourselves
|
|
44763
45075
|
const assetStatuses = _extends({}, this.state.assetStatuses, {
|
|
@@ -44981,10 +45293,6 @@ class ServerItemRenderer extends React.Component {
|
|
|
44981
45293
|
deselectIncorrectSelectedChoices() {
|
|
44982
45294
|
this.questionRenderer.deselectIncorrectSelectedChoices();
|
|
44983
45295
|
}
|
|
44984
|
-
|
|
44985
|
-
// This must be pre-bound otherwise SvgImage's shouldComponentUpdate
|
|
44986
|
-
// won't behave correctly and we'll get an infinite loop.
|
|
44987
|
-
|
|
44988
45296
|
render() {
|
|
44989
45297
|
const apiOptions = _extends({}, ApiOptions.defaults, this.props.apiOptions, {
|
|
44990
45298
|
onFocusChange: this._handleFocusChange
|
|
@@ -45330,7 +45638,7 @@ class MultiButtonGroup extends React.Component {
|
|
|
45330
45638
|
focus() {
|
|
45331
45639
|
var _ReactDOM$findDOMNode;
|
|
45332
45640
|
// @ts-expect-error - TS2339 - Property 'focus' does not exist on type 'Element | Text'.
|
|
45333
|
-
(_ReactDOM$findDOMNode = ReactDOM.findDOMNode(this)) == null
|
|
45641
|
+
(_ReactDOM$findDOMNode = ReactDOM.findDOMNode(this)) == null || _ReactDOM$findDOMNode.focus();
|
|
45334
45642
|
return true;
|
|
45335
45643
|
}
|
|
45336
45644
|
render() {
|
|
@@ -45503,7 +45811,6 @@ const symbStyle = {
|
|
|
45503
45811
|
// on the page rather than reusing an instance (which will cause an error).
|
|
45504
45812
|
// Also, it's useful for things which might look different depending on the
|
|
45505
45813
|
// props.
|
|
45506
|
-
|
|
45507
45814
|
const basic = [() => [/*#__PURE__*/React.createElement("span", {
|
|
45508
45815
|
key: "plus",
|
|
45509
45816
|
style: slightlyBig
|
|
@@ -45852,6 +46159,9 @@ var constants = /*#__PURE__*/Object.freeze({
|
|
|
45852
46159
|
// A background image applied to various widgets.
|
|
45853
46160
|
|
|
45854
46161
|
const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
|
|
46162
|
+
const plotterPlotTypes = ["bar", "line", "pic", "histogram", "dotplot"];
|
|
46163
|
+
|
|
46164
|
+
// TODO(FEI-3983): Create proper types for these.
|
|
45855
46165
|
|
|
45856
46166
|
/**
|
|
45857
46167
|
* Traverses a {content, widgets, images} renderer props object,
|
|
@@ -46036,6 +46346,49 @@ var shapes = {
|
|
|
46036
46346
|
* provided shape. If not, behavior is undefined and may not respect the type
|
|
46037
46347
|
* signatures specified here.
|
|
46038
46348
|
*/
|
|
46349
|
+
|
|
46350
|
+
/**
|
|
46351
|
+
* The sequence of edges that lead to a particular node in a Tree.
|
|
46352
|
+
* Elements can be `string` to correspond to an ObjectNode key, or `number` to
|
|
46353
|
+
* correspond to an ArrayNode index.
|
|
46354
|
+
*/
|
|
46355
|
+
|
|
46356
|
+
/**
|
|
46357
|
+
* These are function interfaces for mapping over various types of tree nodes.
|
|
46358
|
+
*
|
|
46359
|
+
* ArrayMapper is a bit more complicated than the leaf node mappers. It's
|
|
46360
|
+
* executed in the context of a `mapTree` call, after we've finished mapping
|
|
46361
|
+
* its child nodes, so the function has access to both the resulting array
|
|
46362
|
+
* (with mapped elements) and the original array (with the original untouched
|
|
46363
|
+
* elements).
|
|
46364
|
+
*
|
|
46365
|
+
* The ArrayMapper then has the opportunity to apply a final transformation to
|
|
46366
|
+
* the resulting array, like filtering certain elements or (in the hacky
|
|
46367
|
+
* MultiRenderer case) attaching a `renderHints` method to arrays of hint
|
|
46368
|
+
* renderers :)
|
|
46369
|
+
*
|
|
46370
|
+
* This is why `TreeMapper#setArrayMapper` must be called last: ArrayMapper's
|
|
46371
|
+
* types depend on the ContentMapper and HintMapper's types. And, since you can
|
|
46372
|
+
* only specify one mapper at a time in this builder interface (which is
|
|
46373
|
+
* necessary to provide default mappers in a type-safe way), you need your
|
|
46374
|
+
* dependencies to already be in place by the time you call `setArrayMapper`.
|
|
46375
|
+
* Otherwise, we'd have to set the ArrayMapper and *hope* that you *eventually*
|
|
46376
|
+
* provide a compatible ContentMapper and HintMapper, which is difficult to
|
|
46377
|
+
* prove at compile time.
|
|
46378
|
+
*
|
|
46379
|
+
* There's no ObjectMapper here, but not for any particular reason. We just
|
|
46380
|
+
* don't have a use case for it yet, so we haven't built it yet.
|
|
46381
|
+
*/
|
|
46382
|
+
|
|
46383
|
+
/**
|
|
46384
|
+
* A TreeMapper is a collection of node mappers, which, together, compose the
|
|
46385
|
+
* behavior for mapping over an entire tree.
|
|
46386
|
+
*
|
|
46387
|
+
* This serves as the interface for the two TreeMapper classes, including both
|
|
46388
|
+
* the internal mapper properties that we care about, and the `mapTree`
|
|
46389
|
+
* function that the call site will use.
|
|
46390
|
+
*/
|
|
46391
|
+
|
|
46039
46392
|
/**
|
|
46040
46393
|
* This is a TreeMapper that only has mappers specified for its leaf nodes; its
|
|
46041
46394
|
* array mapper is the identity function.
|
|
@@ -46331,6 +46684,23 @@ function treeToItem(node) {
|
|
|
46331
46684
|
}
|
|
46332
46685
|
|
|
46333
46686
|
const _excluded = ["item", "children", "shape", "serializedState", "onSerializedStateUpdated"];
|
|
46687
|
+
|
|
46688
|
+
// TODO(mdr)
|
|
46689
|
+
// TODO(mdr)
|
|
46690
|
+
// TODO(mdr)
|
|
46691
|
+
|
|
46692
|
+
// @ts-expect-error - TS2315 - Type 'Tree' is not generic.
|
|
46693
|
+
|
|
46694
|
+
/**
|
|
46695
|
+
* TODO(somewhatabstract, JIRA-XXXX):
|
|
46696
|
+
* Some usage of this type somewhere is causing TypeScript to believe that these
|
|
46697
|
+
* elements should be components. Don't know where that is, to fix it up
|
|
46698
|
+
* properly. In reality, these types are just too hard to use and aren't
|
|
46699
|
+
* really helping us out as I now have to suppress this rather than
|
|
46700
|
+
* get value from the type. :(
|
|
46701
|
+
*/ // @ts-expect-error - TS2315 - Type 'Tree' is not generic.
|
|
46702
|
+
// @ts-expect-error - TS2315 - Type 'Tree' is not generic.
|
|
46703
|
+
// @ts-expect-error - TS2315 - Type 'Tree' is not generic.
|
|
46334
46704
|
class MultiRenderer extends React.Component {
|
|
46335
46705
|
constructor(props) {
|
|
46336
46706
|
super(props);
|
|
@@ -46614,7 +46984,7 @@ class MultiRenderer extends React.Component {
|
|
|
46614
46984
|
return;
|
|
46615
46985
|
}
|
|
46616
46986
|
numCallbacks++;
|
|
46617
|
-
(_data$ref2 = data.ref) == null
|
|
46987
|
+
(_data$ref2 = data.ref) == null || _data$ref2.restoreSerializedState(state, countCallback);
|
|
46618
46988
|
});
|
|
46619
46989
|
}
|
|
46620
46990
|
|
|
@@ -46926,5 +47296,5 @@ const EditorJsonify = {
|
|
|
46926
47296
|
}
|
|
46927
47297
|
};
|
|
46928
47298
|
|
|
46929
|
-
export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemRenderer, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Transformer$1 as TransformerWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, globalConstants, globalStyles, iconPaths as icons, init, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, mediaQueries, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
|
|
47299
|
+
export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemRenderer, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Transformer$1 as TransformerWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, globalConstants, globalStyles, iconPaths as icons, init, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, mediaQueries, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
|
|
46930
47300
|
//# sourceMappingURL=index.js.map
|