@khanacademy/perseus-editor 18.2.3 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.js +85 -16
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +599 -497
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -53,10 +53,10 @@ var arrowFatUp = require('@phosphor-icons/core/regular/arrow-fat-up.svg');
|
|
|
53
53
|
var minusCircle = require('@phosphor-icons/core/regular/minus-circle.svg');
|
|
54
54
|
var arrowCounterClockwise = require('@phosphor-icons/core/bold/arrow-counter-clockwise-bold.svg');
|
|
55
55
|
|
|
56
|
-
function
|
|
56
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
57
57
|
|
|
58
|
-
function
|
|
59
|
-
if (e && e
|
|
58
|
+
function _interopNamespaceCompat(e) {
|
|
59
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
60
60
|
var n = Object.create(null);
|
|
61
61
|
if (e) {
|
|
62
62
|
Object.keys(e).forEach(function (k) {
|
|
@@ -69,45 +69,48 @@ function _interopNamespace(e) {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
n
|
|
72
|
+
n.default = e;
|
|
73
73
|
return Object.freeze(n);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
var _extends__default = /*#__PURE__*/
|
|
77
|
-
var React__namespace = /*#__PURE__*/
|
|
78
|
-
var ___default = /*#__PURE__*/
|
|
79
|
-
var Clickable__default = /*#__PURE__*/
|
|
80
|
-
var $__default = /*#__PURE__*/
|
|
81
|
-
var katex__default = /*#__PURE__*/
|
|
82
|
-
var Switch__default = /*#__PURE__*/
|
|
83
|
-
var caretRight__default = /*#__PURE__*/
|
|
84
|
-
var PropTypes__default = /*#__PURE__*/
|
|
85
|
-
var classNames__default = /*#__PURE__*/
|
|
86
|
-
var ReactDOM__default = /*#__PURE__*/
|
|
87
|
-
var KAS__namespace = /*#__PURE__*/
|
|
88
|
-
var Button__default = /*#__PURE__*/
|
|
89
|
-
var Banner__default = /*#__PURE__*/
|
|
90
|
-
var Pill__default = /*#__PURE__*/
|
|
91
|
-
var plusCircle__default = /*#__PURE__*/
|
|
92
|
-
var pencilCircle__default = /*#__PURE__*/
|
|
93
|
-
var IconButton__default = /*#__PURE__*/
|
|
94
|
-
var caretDoubleDownIcon__default = /*#__PURE__*/
|
|
95
|
-
var caretDoubleUpIcon__default = /*#__PURE__*/
|
|
96
|
-
var caretDownIcon__default = /*#__PURE__*/
|
|
97
|
-
var caretUpIcon__default = /*#__PURE__*/
|
|
98
|
-
var trashIcon__default = /*#__PURE__*/
|
|
99
|
-
var copyIcon__default = /*#__PURE__*/
|
|
100
|
-
var autoPasteIcon__default = /*#__PURE__*/
|
|
101
|
-
var arrowFatDown__default = /*#__PURE__*/
|
|
102
|
-
var arrowFatLeft__default = /*#__PURE__*/
|
|
103
|
-
var arrowFatRight__default = /*#__PURE__*/
|
|
104
|
-
var arrowFatUp__default = /*#__PURE__*/
|
|
105
|
-
var minusCircle__default = /*#__PURE__*/
|
|
106
|
-
var arrowCounterClockwise__default = /*#__PURE__*/
|
|
76
|
+
var _extends__default = /*#__PURE__*/_interopDefaultCompat(_extends);
|
|
77
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
78
|
+
var ___default = /*#__PURE__*/_interopDefaultCompat(_);
|
|
79
|
+
var Clickable__default = /*#__PURE__*/_interopDefaultCompat(Clickable);
|
|
80
|
+
var $__default = /*#__PURE__*/_interopDefaultCompat($);
|
|
81
|
+
var katex__default = /*#__PURE__*/_interopDefaultCompat(katex);
|
|
82
|
+
var Switch__default = /*#__PURE__*/_interopDefaultCompat(Switch);
|
|
83
|
+
var caretRight__default = /*#__PURE__*/_interopDefaultCompat(caretRight);
|
|
84
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultCompat(PropTypes);
|
|
85
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
86
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefaultCompat(ReactDOM);
|
|
87
|
+
var KAS__namespace = /*#__PURE__*/_interopNamespaceCompat(KAS);
|
|
88
|
+
var Button__default = /*#__PURE__*/_interopDefaultCompat(Button);
|
|
89
|
+
var Banner__default = /*#__PURE__*/_interopDefaultCompat(Banner);
|
|
90
|
+
var Pill__default = /*#__PURE__*/_interopDefaultCompat(Pill);
|
|
91
|
+
var plusCircle__default = /*#__PURE__*/_interopDefaultCompat(plusCircle);
|
|
92
|
+
var pencilCircle__default = /*#__PURE__*/_interopDefaultCompat(pencilCircle);
|
|
93
|
+
var IconButton__default = /*#__PURE__*/_interopDefaultCompat(IconButton);
|
|
94
|
+
var caretDoubleDownIcon__default = /*#__PURE__*/_interopDefaultCompat(caretDoubleDownIcon);
|
|
95
|
+
var caretDoubleUpIcon__default = /*#__PURE__*/_interopDefaultCompat(caretDoubleUpIcon);
|
|
96
|
+
var caretDownIcon__default = /*#__PURE__*/_interopDefaultCompat(caretDownIcon);
|
|
97
|
+
var caretUpIcon__default = /*#__PURE__*/_interopDefaultCompat(caretUpIcon);
|
|
98
|
+
var trashIcon__default = /*#__PURE__*/_interopDefaultCompat(trashIcon);
|
|
99
|
+
var copyIcon__default = /*#__PURE__*/_interopDefaultCompat(copyIcon);
|
|
100
|
+
var autoPasteIcon__default = /*#__PURE__*/_interopDefaultCompat(autoPasteIcon);
|
|
101
|
+
var arrowFatDown__default = /*#__PURE__*/_interopDefaultCompat(arrowFatDown);
|
|
102
|
+
var arrowFatLeft__default = /*#__PURE__*/_interopDefaultCompat(arrowFatLeft);
|
|
103
|
+
var arrowFatRight__default = /*#__PURE__*/_interopDefaultCompat(arrowFatRight);
|
|
104
|
+
var arrowFatUp__default = /*#__PURE__*/_interopDefaultCompat(arrowFatUp);
|
|
105
|
+
var minusCircle__default = /*#__PURE__*/_interopDefaultCompat(minusCircle);
|
|
106
|
+
var arrowCounterClockwise__default = /*#__PURE__*/_interopDefaultCompat(arrowCounterClockwise);
|
|
107
107
|
|
|
108
108
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
109
|
+
// version number during the release build.
|
|
110
|
+
// In dev, you'll never see the version number.
|
|
111
|
+
|
|
109
112
|
const libName = "@khanacademy/perseus-editor";
|
|
110
|
-
const libVersion = "
|
|
113
|
+
const libVersion = "20.0.0";
|
|
111
114
|
perseusUtils.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
112
115
|
|
|
113
116
|
const devices = {
|
|
@@ -128,6 +131,7 @@ const perseusFrameBorderWidth = 1;
|
|
|
128
131
|
/**
|
|
129
132
|
* A component that displays its contents inside a device frame.
|
|
130
133
|
*/
|
|
134
|
+
|
|
131
135
|
const SCREEN_SIZES = {
|
|
132
136
|
phone: {
|
|
133
137
|
width: 320,
|
|
@@ -190,6 +194,7 @@ const DeviceFramer = _ref => {
|
|
|
190
194
|
};
|
|
191
195
|
|
|
192
196
|
/* eslint-disable @babel/no-invalid-this */
|
|
197
|
+
/* eslint-disable react/no-unsafe */
|
|
193
198
|
class JsonEditor extends React__namespace.Component {
|
|
194
199
|
static displayName;
|
|
195
200
|
static defaultProps = {
|
|
@@ -209,7 +214,7 @@ class JsonEditor extends React__namespace.Component {
|
|
|
209
214
|
};
|
|
210
215
|
}
|
|
211
216
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
212
|
-
const shouldReplaceContent = !this.state.valid || !___default
|
|
217
|
+
const shouldReplaceContent = !this.state.valid || !___default.default.isEqual(nextProps.value, JSON.parse(this.state.currentValue ? this.state.currentValue : ""));
|
|
213
218
|
if (shouldReplaceContent) {
|
|
214
219
|
this.setState(this.getInitialState());
|
|
215
220
|
}
|
|
@@ -234,7 +239,7 @@ class JsonEditor extends React__namespace.Component {
|
|
|
234
239
|
try {
|
|
235
240
|
let json = JSON.parse(nextString);
|
|
236
241
|
// Some extra handling to allow copy-pasting from /api/vi
|
|
237
|
-
if (___default
|
|
242
|
+
if (___default.default.isString(json)) {
|
|
238
243
|
json = JSON.parse(json);
|
|
239
244
|
}
|
|
240
245
|
// This callback unfortunately causes multiple renders,
|
|
@@ -262,7 +267,7 @@ class JsonEditor extends React__namespace.Component {
|
|
|
262
267
|
try {
|
|
263
268
|
let json = JSON.parse(nextString);
|
|
264
269
|
// Some extra handling to allow copy-pasting from /api/vi
|
|
265
|
-
if (___default
|
|
270
|
+
if (___default.default.isString(json)) {
|
|
266
271
|
json = JSON.parse(json);
|
|
267
272
|
}
|
|
268
273
|
// This callback unfortunately causes multiple renders,
|
|
@@ -304,7 +309,7 @@ class SectionControlButton extends React__namespace.Component {
|
|
|
304
309
|
onClick,
|
|
305
310
|
title
|
|
306
311
|
} = this.props;
|
|
307
|
-
return /*#__PURE__*/React__namespace.createElement(Clickable__default
|
|
312
|
+
return /*#__PURE__*/React__namespace.createElement(Clickable__default.default, {
|
|
308
313
|
className: "section-control-button " + "simple-button " + "simple-button--small ",
|
|
309
314
|
onClick: e => {
|
|
310
315
|
e.preventDefault();
|
|
@@ -315,6 +320,11 @@ class SectionControlButton extends React__namespace.Component {
|
|
|
315
320
|
"aria-label": title,
|
|
316
321
|
style: styles$T.button
|
|
317
322
|
}, _ref => {
|
|
323
|
+
let {
|
|
324
|
+
hovered,
|
|
325
|
+
focused,
|
|
326
|
+
pressed
|
|
327
|
+
} = _ref;
|
|
318
328
|
return /*#__PURE__*/React__namespace.createElement(InlineIcon$9, icon);
|
|
319
329
|
});
|
|
320
330
|
}
|
|
@@ -3132,20 +3142,22 @@ var texify = {
|
|
|
3132
3142
|
};
|
|
3133
3143
|
|
|
3134
3144
|
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
|
|
3145
|
+
/* vim: set ts=2 et sw=2 tw=80: */
|
|
3146
|
+
|
|
3135
3147
|
|
|
3136
3148
|
// Add \ce, \pu, and \tripledash to the KaTeX macros.
|
|
3137
3149
|
|
|
3138
|
-
katex__default
|
|
3150
|
+
katex__default.default.__defineMacro("\\ce", function (context) {
|
|
3139
3151
|
return chemParse(context.consumeArgs(1)[0], "ce");
|
|
3140
3152
|
});
|
|
3141
|
-
katex__default
|
|
3153
|
+
katex__default.default.__defineMacro("\\pu", function (context) {
|
|
3142
3154
|
return chemParse(context.consumeArgs(1)[0], "pu");
|
|
3143
3155
|
});
|
|
3144
3156
|
|
|
3145
3157
|
// Needed for \bond for the ~ forms
|
|
3146
3158
|
// Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not
|
|
3147
3159
|
// a mathematical minus, U+2212. So we need that extra 0.56.
|
|
3148
|
-
katex__default
|
|
3160
|
+
katex__default.default.__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");
|
|
3149
3161
|
|
|
3150
3162
|
class DragTarget extends React__namespace.Component {
|
|
3151
3163
|
static defaultProps = {
|
|
@@ -3199,7 +3211,7 @@ class DragTarget extends React__namespace.Component {
|
|
|
3199
3211
|
shouldDragHighlight,
|
|
3200
3212
|
...forwardProps
|
|
3201
3213
|
} = this.props;
|
|
3202
|
-
return /*#__PURE__*/React__namespace.createElement(Component, _extends__default
|
|
3214
|
+
return /*#__PURE__*/React__namespace.createElement(Component, _extends__default.default({}, forwardProps, {
|
|
3203
3215
|
style: Object.assign({}, this.props.style, opacity),
|
|
3204
3216
|
onDrop: this.handleDrop,
|
|
3205
3217
|
onDragEnd: this.handleDragEnd,
|
|
@@ -3252,7 +3264,7 @@ const {
|
|
|
3252
3264
|
const _upgradeWidgetInfo = props => {
|
|
3253
3265
|
// We can't call serialize here because this.refs.widget
|
|
3254
3266
|
// doesn't exist before this component is mounted.
|
|
3255
|
-
const filteredProps = ___default
|
|
3267
|
+
const filteredProps = ___default.default.omit(props, perseus.WIDGET_PROP_DENYLIST);
|
|
3256
3268
|
return perseusCore.upgradeWidgetInfoToLatestVersion(filteredProps);
|
|
3257
3269
|
};
|
|
3258
3270
|
|
|
@@ -3375,7 +3387,7 @@ class WidgetEditor extends React__namespace.Component {
|
|
|
3375
3387
|
title: "Remove image widget"
|
|
3376
3388
|
})), /*#__PURE__*/React__namespace.createElement("div", {
|
|
3377
3389
|
className: "perseus-widget-editor-content " + (this.state.showWidget ? "enter" : "leave")
|
|
3378
|
-
}, Ed && /*#__PURE__*/React__namespace.createElement(Ed, _extends__default
|
|
3390
|
+
}, Ed && /*#__PURE__*/React__namespace.createElement(Ed, _extends__default.default({
|
|
3379
3391
|
ref: this.widget,
|
|
3380
3392
|
onChange: this._handleWidgetChange,
|
|
3381
3393
|
static: widgetInfo.static,
|
|
@@ -3393,7 +3405,7 @@ function LabeledSwitch$1(props) {
|
|
|
3393
3405
|
htmlFor: id
|
|
3394
3406
|
}, label), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
3395
3407
|
size: wonderBlocksTokens.spacing.xxSmall_6
|
|
3396
|
-
}), /*#__PURE__*/React__namespace.createElement(Switch__default
|
|
3408
|
+
}), /*#__PURE__*/React__namespace.createElement(Switch__default.default, _extends__default.default({
|
|
3397
3409
|
id: id
|
|
3398
3410
|
}, switchProps)));
|
|
3399
3411
|
}
|
|
@@ -3415,7 +3427,7 @@ class WidgetSelect extends React__namespace.Component {
|
|
|
3415
3427
|
};
|
|
3416
3428
|
render() {
|
|
3417
3429
|
const widgets = perseus.Widgets.getPublicWidgets();
|
|
3418
|
-
const orderedWidgetNames = ___default
|
|
3430
|
+
const orderedWidgetNames = ___default.default.sortBy(___default.default.keys(widgets), name => {
|
|
3419
3431
|
return widgets[name].displayName;
|
|
3420
3432
|
});
|
|
3421
3433
|
const addWidgetString = "Add a widget\u2026";
|
|
@@ -3443,7 +3455,7 @@ class WidgetSelect extends React__namespace.Component {
|
|
|
3443
3455
|
function ToggleableCaret(props) {
|
|
3444
3456
|
const iconStyle = props.isExpanded ? styles$S.expanded : styles$S.collapsed;
|
|
3445
3457
|
return /*#__PURE__*/React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
3446
|
-
icon: caretRight__default
|
|
3458
|
+
icon: caretRight__default.default,
|
|
3447
3459
|
style: iconStyle
|
|
3448
3460
|
});
|
|
3449
3461
|
}
|
|
@@ -3627,7 +3639,7 @@ class Editor extends React__namespace.Component {
|
|
|
3627
3639
|
// are guaranteed to be up-to-date before componentDidMount or
|
|
3628
3640
|
// componentDidUpdate fires.
|
|
3629
3641
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
3630
|
-
$__default
|
|
3642
|
+
$__default.default(this.textarea.current)
|
|
3631
3643
|
// @ts-expect-error - TS2339 - Property 'on' does not exist on type 'JQueryStatic'.
|
|
3632
3644
|
.on("copy cut", this._maybeCopyWidgets)
|
|
3633
3645
|
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
@@ -3686,7 +3698,7 @@ class Editor extends React__namespace.Component {
|
|
|
3686
3698
|
// widget data before specifying the `key` prop, to ensure the
|
|
3687
3699
|
// key overrides any `key` field on the widget (which might not
|
|
3688
3700
|
// be unique.
|
|
3689
|
-
, _extends__default
|
|
3701
|
+
, _extends__default.default({}, this.props.widgets[id], {
|
|
3690
3702
|
ref: id,
|
|
3691
3703
|
id: id,
|
|
3692
3704
|
key: id
|
|
@@ -3728,18 +3740,18 @@ class Editor extends React__namespace.Component {
|
|
|
3728
3740
|
|
|
3729
3741
|
// Discard any images in our dimension table that no
|
|
3730
3742
|
// longer exist in content.
|
|
3731
|
-
const images = ___default
|
|
3743
|
+
const images = ___default.default.pick(props.images, imageUrls);
|
|
3732
3744
|
|
|
3733
3745
|
// Only calculate sizes for images that were not present previously.
|
|
3734
3746
|
// Most content edits shouldn't have new images.
|
|
3735
3747
|
// This could get weird in the case of multiple images with the same
|
|
3736
3748
|
// URL, if you've changed the backing image size, but given graphie
|
|
3737
3749
|
// hashes it's probably an edge case.
|
|
3738
|
-
const newImageUrls = ___default
|
|
3750
|
+
const newImageUrls = ___default.default.filter(imageUrls, url => !images[url]);
|
|
3739
3751
|
|
|
3740
3752
|
// TODO(jack): Q promises would make this nicer and only
|
|
3741
3753
|
// fire once.
|
|
3742
|
-
___default
|
|
3754
|
+
___default.default.each(newImageUrls, url => {
|
|
3743
3755
|
perseus.Util.getImageSize(url, (width, height) => {
|
|
3744
3756
|
// We keep modifying the same image object rather than a new
|
|
3745
3757
|
// copy from this.props because all changes here are additive.
|
|
@@ -3752,7 +3764,7 @@ class Editor extends React__namespace.Component {
|
|
|
3752
3764
|
height: height
|
|
3753
3765
|
};
|
|
3754
3766
|
props.onChange({
|
|
3755
|
-
images: ___default
|
|
3767
|
+
images: ___default.default.clone(images)
|
|
3756
3768
|
},
|
|
3757
3769
|
// @ts-expect-error - TS2345 - Argument of type 'null' is not assignable to parameter of type '(() => unknown) | undefined'.
|
|
3758
3770
|
null,
|
|
@@ -3809,11 +3821,11 @@ class Editor extends React__namespace.Component {
|
|
|
3809
3821
|
* extended to recognize this sentinel and highlight it like for
|
|
3810
3822
|
* widgets.
|
|
3811
3823
|
*/
|
|
3812
|
-
___default
|
|
3824
|
+
___default.default(files).chain().map(function (file) {
|
|
3813
3825
|
if (!file.type.match("image.*")) {
|
|
3814
3826
|
return null;
|
|
3815
3827
|
}
|
|
3816
|
-
const sentinel = "\u2603 " + ___default
|
|
3828
|
+
const sentinel = "\u2603 " + ___default.default.uniqueId("image_");
|
|
3817
3829
|
// TODO(joel) - figure out how to temporarily include the image
|
|
3818
3830
|
// before the server returns.
|
|
3819
3831
|
content += "\n\n";
|
|
@@ -3821,7 +3833,7 @@ class Editor extends React__namespace.Component {
|
|
|
3821
3833
|
file: file,
|
|
3822
3834
|
sentinel: sentinel
|
|
3823
3835
|
};
|
|
3824
|
-
}).reject(___default
|
|
3836
|
+
}).reject(___default.default.isNull).tap(() => {
|
|
3825
3837
|
// See componentDidUpdate() for how this flag is used
|
|
3826
3838
|
this.lastUserValue = origContent;
|
|
3827
3839
|
this.props.onChange({
|
|
@@ -3891,13 +3903,13 @@ class Editor extends React__namespace.Component {
|
|
|
3891
3903
|
// is actually pasting something originally from Perseus later.
|
|
3892
3904
|
const textarea = e.currentTarget;
|
|
3893
3905
|
const selectedText = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
|
|
3894
|
-
const widgetNames = ___default
|
|
3906
|
+
const widgetNames = ___default.default.map(
|
|
3895
3907
|
// @ts-expect-error - TS2345 - Argument of type 'RegExpMatchArray | null' is not assignable to parameter of type 'Collection<any>'.
|
|
3896
3908
|
selectedText.match(rWidgetSplit), syntax => {
|
|
3897
3909
|
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
3898
3910
|
return perseus.Util.rWidgetParts.exec(syntax)[1];
|
|
3899
3911
|
});
|
|
3900
|
-
const widgetData = ___default
|
|
3912
|
+
const widgetData = ___default.default.pick(this.serialize().widgets, widgetNames);
|
|
3901
3913
|
localStorage.perseusLastCopiedText = selectedText;
|
|
3902
3914
|
localStorage.perseusLastCopiedWidgets = JSON.stringify(widgetData);
|
|
3903
3915
|
perseus.Log.log(`Widgets copied: ${localStorage.perseusLastCopiedWidgets}`);
|
|
@@ -3934,7 +3946,7 @@ class Editor extends React__namespace.Component {
|
|
|
3934
3946
|
for (const [key, data] of Object.entries(widgetData)) {
|
|
3935
3947
|
safeWidgetData[safeWidgetMapping[key]] = data;
|
|
3936
3948
|
}
|
|
3937
|
-
const newWidgets = ___default
|
|
3949
|
+
const newWidgets = ___default.default.extend(safeWidgetData, this.props.widgets);
|
|
3938
3950
|
|
|
3939
3951
|
// Use safe widget name map to construct new text
|
|
3940
3952
|
const safeText = lastCopiedText.replace(rWidgetSplit, syntax => {
|
|
@@ -3976,24 +3988,24 @@ class Editor extends React__namespace.Component {
|
|
|
3976
3988
|
// see: LEMS-1845
|
|
3977
3989
|
|
|
3978
3990
|
// List of widgets about to be pasted as [[name, number], ...]
|
|
3979
|
-
const widgets = ___default
|
|
3980
|
-
const widgetTypes = ___default
|
|
3991
|
+
const widgets = ___default.default.keys(widgetData).map(name => name.split(" "));
|
|
3992
|
+
const widgetTypes = ___default.default.uniq(widgets.map(widget => widget[0]));
|
|
3981
3993
|
|
|
3982
3994
|
// List of existing widgets as [[name, number], ...]
|
|
3983
|
-
const existingWidgets = ___default
|
|
3995
|
+
const existingWidgets = ___default.default.keys(this.props.widgets).map(name => name.split(" "));
|
|
3984
3996
|
|
|
3985
3997
|
// Mapping of widget type to a safe (non-conflicting) number
|
|
3986
3998
|
// eg. { "image": 2, "dropdown": 1 }
|
|
3987
3999
|
const safeWidgetNums = {};
|
|
3988
|
-
___default
|
|
3989
|
-
safeWidgetNums[type] = ___default
|
|
4000
|
+
___default.default.each(widgetTypes, type => {
|
|
4001
|
+
safeWidgetNums[type] = ___default.default.chain(existingWidgets).filter(existingWidget => existingWidget[0] === type).map(existingWidget => +existingWidget[1] + 1).max().value();
|
|
3990
4002
|
// If there are no existing widgets _.max returns -Infinity
|
|
3991
4003
|
safeWidgetNums[type] = Math.max(safeWidgetNums[type], 1);
|
|
3992
4004
|
});
|
|
3993
4005
|
|
|
3994
4006
|
// Construct mapping, incrementing the vals in safeWidgetNums as we go
|
|
3995
4007
|
const safeWidgetMapping = {};
|
|
3996
|
-
___default
|
|
4008
|
+
___default.default.each(widgets, widget => {
|
|
3997
4009
|
const widgetName = widget.join(" ");
|
|
3998
4010
|
const widgetType = widget[0];
|
|
3999
4011
|
safeWidgetMapping[widgetName] = `${widgetType} ${safeWidgetNums[widgetType]}`;
|
|
@@ -4008,7 +4020,7 @@ class Editor extends React__namespace.Component {
|
|
|
4008
4020
|
// because the results of a .match might be null if no
|
|
4009
4021
|
// widgets were found.
|
|
4010
4022
|
// @ts-expect-error - TS2345 - Argument of type 'RegExpMatchArray | null' is not assignable to parameter of type 'Collection<any>'.
|
|
4011
|
-
const allWidgetIds = ___default
|
|
4023
|
+
const allWidgetIds = ___default.default.map(oldContent.match(rWidgetSplit), syntax => {
|
|
4012
4024
|
const match = perseus.Util.rWidgetParts.exec(syntax);
|
|
4013
4025
|
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
4014
4026
|
const type = match[2];
|
|
@@ -4016,7 +4028,7 @@ class Editor extends React__namespace.Component {
|
|
|
4016
4028
|
const num = +match[3];
|
|
4017
4029
|
return [type, num];
|
|
4018
4030
|
});
|
|
4019
|
-
const widgetNum = ___default
|
|
4031
|
+
const widgetNum = ___default.default.reduce(allWidgetIds, (currentNum, otherId) => {
|
|
4020
4032
|
const [otherType, otherNum] = otherId;
|
|
4021
4033
|
if (otherType === widgetType) {
|
|
4022
4034
|
return Math.max(otherNum + 1, currentNum);
|
|
@@ -4108,13 +4120,13 @@ class Editor extends React__namespace.Component {
|
|
|
4108
4120
|
};
|
|
4109
4121
|
getSaveWarnings = () => {
|
|
4110
4122
|
// eslint-disable-next-line react/no-string-refs
|
|
4111
|
-
const widgetIds = ___default
|
|
4112
|
-
const warnings = ___default
|
|
4123
|
+
const widgetIds = ___default.default.intersection(this.widgetIds, ___default.default.keys(this.refs));
|
|
4124
|
+
const warnings = ___default.default(widgetIds).chain().map(id => {
|
|
4113
4125
|
// eslint-disable-next-line react/no-string-refs
|
|
4114
4126
|
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
4115
4127
|
const issuesFunc = this.refs[id].getSaveWarnings;
|
|
4116
4128
|
const issues = issuesFunc ? issuesFunc() : [];
|
|
4117
|
-
return ___default
|
|
4129
|
+
return ___default.default.map(issues, issue => id + ": " + issue);
|
|
4118
4130
|
}).flatten(true).value();
|
|
4119
4131
|
return warnings;
|
|
4120
4132
|
};
|
|
@@ -4138,8 +4150,8 @@ class Editor extends React__namespace.Component {
|
|
|
4138
4150
|
// interactive-graph and plotter).
|
|
4139
4151
|
const widgets = {};
|
|
4140
4152
|
// eslint-disable-next-line react/no-string-refs
|
|
4141
|
-
const widgetIds = ___default
|
|
4142
|
-
___default
|
|
4153
|
+
const widgetIds = ___default.default.intersection(this.widgetIds, ___default.default.keys(this.refs));
|
|
4154
|
+
___default.default.each(widgetIds, id => {
|
|
4143
4155
|
// eslint-disable-next-line react/no-string-refs
|
|
4144
4156
|
// @ts-expect-error - TS2339 - Property 'serialize' does not exist on type 'ReactInstance'.
|
|
4145
4157
|
widgets[id] = this.refs[id].serialize();
|
|
@@ -4153,7 +4165,7 @@ class Editor extends React__namespace.Component {
|
|
|
4153
4165
|
// have been fixed to only return props,
|
|
4154
4166
|
// and the above no longer applies.
|
|
4155
4167
|
if (options && options.keepDeletedWidgets) {
|
|
4156
|
-
___default
|
|
4168
|
+
___default.default.chain(this.props.widgets).keys().reject(id => ___default.default.contains(widgetIds, id)).each(id => {
|
|
4157
4169
|
widgets[id] = this.props.widgets[id];
|
|
4158
4170
|
});
|
|
4159
4171
|
}
|
|
@@ -4198,7 +4210,7 @@ class Editor extends React__namespace.Component {
|
|
|
4198
4210
|
if (node.type === "math" || node.type === "blockMath") {
|
|
4199
4211
|
const content = perseus.preprocessTex(node.content);
|
|
4200
4212
|
try {
|
|
4201
|
-
katex__default
|
|
4213
|
+
katex__default.default.renderToString(content, {
|
|
4202
4214
|
colorIsTextColor: true
|
|
4203
4215
|
});
|
|
4204
4216
|
} catch (e) {
|
|
@@ -4249,7 +4261,7 @@ class Editor extends React__namespace.Component {
|
|
|
4249
4261
|
// }
|
|
4250
4262
|
// }, this);
|
|
4251
4263
|
|
|
4252
|
-
this.widgetIds = ___default
|
|
4264
|
+
this.widgetIds = ___default.default.keys(widgets);
|
|
4253
4265
|
widgetsDropDown = /*#__PURE__*/React__namespace.createElement(WidgetSelect, {
|
|
4254
4266
|
onChange: this._addWidget
|
|
4255
4267
|
});
|
|
@@ -4546,6 +4558,7 @@ class ArticleEditor extends React__namespace.Component {
|
|
|
4546
4558
|
paths: this.props.contentPaths
|
|
4547
4559
|
},
|
|
4548
4560
|
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
4561
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
4549
4562
|
legacyPerseusLint: editor ? editor.getSaveWarnings() : []
|
|
4550
4563
|
};
|
|
4551
4564
|
}
|
|
@@ -4609,7 +4622,7 @@ class ArticleEditor extends React__namespace.Component {
|
|
|
4609
4622
|
/* eslint-enable no-alert */
|
|
4610
4623
|
},
|
|
4611
4624
|
title: "Delete this section"
|
|
4612
|
-
}))), /*#__PURE__*/React__namespace.createElement(Editor, _extends__default
|
|
4625
|
+
}))), /*#__PURE__*/React__namespace.createElement(Editor, _extends__default.default({}, section, {
|
|
4613
4626
|
apiOptions: apiOptions,
|
|
4614
4627
|
imageUploader: imageUploader,
|
|
4615
4628
|
onChange: newProps => this._handleEditorChange(i, newProps),
|
|
@@ -4706,7 +4719,7 @@ class ArticleEditor extends React__namespace.Component {
|
|
|
4706
4719
|
_handleAddSectionAfter(i) {
|
|
4707
4720
|
// We do a full serialization here because we
|
|
4708
4721
|
// might be copying widgets:
|
|
4709
|
-
const sections = ___default
|
|
4722
|
+
const sections = ___default.default.clone(this.serialize());
|
|
4710
4723
|
// Here we do magic to allow you to copy-paste
|
|
4711
4724
|
// things from the previous section into the new
|
|
4712
4725
|
// section while preserving widgets.
|
|
@@ -5218,21 +5231,23 @@ const JSDiff = {
|
|
|
5218
5231
|
const splitDiff = function (diffEntries) {
|
|
5219
5232
|
const lines = [];
|
|
5220
5233
|
let currentLine = [];
|
|
5221
|
-
___default
|
|
5234
|
+
___default.default.each(diffEntries, entry => {
|
|
5222
5235
|
const values = entry.value.split("\n");
|
|
5223
|
-
___default
|
|
5236
|
+
___default.default.each(values, (value, i) => {
|
|
5224
5237
|
const isNewline = i > 0;
|
|
5225
5238
|
if (isNewline) {
|
|
5226
5239
|
// @ts-expect-error - TS2345 - Argument of type 'any[]' is not assignable to parameter of type 'never'.
|
|
5227
5240
|
lines.push(currentLine);
|
|
5228
5241
|
currentLine = [];
|
|
5229
5242
|
}
|
|
5230
|
-
const newEntry = ___default
|
|
5243
|
+
const newEntry = ___default.default.extend({}, entry, {
|
|
5231
5244
|
value: value
|
|
5232
5245
|
});
|
|
5233
5246
|
currentLine.push(newEntry);
|
|
5234
5247
|
});
|
|
5235
5248
|
});
|
|
5249
|
+
|
|
5250
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
5236
5251
|
if (currentLine.length) {
|
|
5237
5252
|
// @ts-expect-error - TS2345 - Argument of type 'any[]' is not assignable to parameter of type 'never'.
|
|
5238
5253
|
lines.push(currentLine);
|
|
@@ -5253,7 +5268,7 @@ const statusFor = function (chunk) {
|
|
|
5253
5268
|
|
|
5254
5269
|
// Turn a chunk (which contains an array of values and a status)
|
|
5255
5270
|
// into an array of values, each with the same status
|
|
5256
|
-
const splitUpChunk = chunk => ___default
|
|
5271
|
+
const splitUpChunk = chunk => ___default.default.map(chunk.value, value => {
|
|
5257
5272
|
return {
|
|
5258
5273
|
value: value,
|
|
5259
5274
|
status: statusFor(chunk)
|
|
@@ -5263,7 +5278,7 @@ const splitUpChunk = chunk => ___default["default"].map(chunk.value, value => {
|
|
|
5263
5278
|
// Apply `fn` to every element in `lst` and then concatenate all the results
|
|
5264
5279
|
// http://clojuredocs.org/clojure_core/clojure.core/mapcat
|
|
5265
5280
|
const mapcat = function (lst, fn) {
|
|
5266
|
-
return ___default
|
|
5281
|
+
return ___default.default.flatten(___default.default.map(lst, fn), true /* only flatten one level */);
|
|
5267
5282
|
};
|
|
5268
5283
|
|
|
5269
5284
|
// > ArrayDiff.diff([1,2,3], [2,3,4]);
|
|
@@ -5273,12 +5288,12 @@ const mapcat = function (lst, fn) {
|
|
|
5273
5288
|
// { "value": [4],
|
|
5274
5289
|
// "added": true }]
|
|
5275
5290
|
const ArrayDiff = new JSDiff.Diff();
|
|
5276
|
-
ArrayDiff.tokenize = array => ___default
|
|
5291
|
+
ArrayDiff.tokenize = array => ___default.default.map(array, elem => [elem]);
|
|
5277
5292
|
// The default is `+` for string concatenation, which doesn't work for array
|
|
5278
5293
|
// concatenation.
|
|
5279
5294
|
ArrayDiff.join = (a, b) => a.concat(b);
|
|
5280
5295
|
// By default jsDiff uses ===
|
|
5281
|
-
ArrayDiff.equals = ___default
|
|
5296
|
+
ArrayDiff.equals = ___default.default.isEqual;
|
|
5282
5297
|
|
|
5283
5298
|
// Take the output of jsdiff's function (which concatenates adjacent entries)
|
|
5284
5299
|
// and make it just one entry per chunk
|
|
@@ -5300,8 +5315,8 @@ const stringArrayDiff = function (a, b) {
|
|
|
5300
5315
|
const diffResult = ArrayDiff.diff(a, b);
|
|
5301
5316
|
const flattened = flattenChunks(diffResult);
|
|
5302
5317
|
return {
|
|
5303
|
-
before: ___default
|
|
5304
|
-
after: ___default
|
|
5318
|
+
before: ___default.default.filter(flattened, entry => entry.status !== "added"),
|
|
5319
|
+
after: ___default.default.filter(flattened, entry => entry.status !== "removed")
|
|
5305
5320
|
};
|
|
5306
5321
|
};
|
|
5307
5322
|
|
|
@@ -5326,11 +5341,11 @@ const classFor = function (entry, ifAdded, ifRemoved) {
|
|
|
5326
5341
|
};
|
|
5327
5342
|
class ImageDiffSide extends React__namespace.Component {
|
|
5328
5343
|
static propTypes = {
|
|
5329
|
-
images: PropTypes__default
|
|
5344
|
+
images: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({})).isRequired
|
|
5330
5345
|
};
|
|
5331
5346
|
render() {
|
|
5332
|
-
return /*#__PURE__*/React__namespace.createElement("div", null, ___default
|
|
5333
|
-
const className = classNames__default
|
|
5347
|
+
return /*#__PURE__*/React__namespace.createElement("div", null, ___default.default.map(this.props.images, (entry, index) => {
|
|
5348
|
+
const className = classNames__default.default({
|
|
5334
5349
|
image: true,
|
|
5335
5350
|
"image-unchanged": entry.status === "unchanged",
|
|
5336
5351
|
"image-added": entry.status === "added",
|
|
@@ -5349,9 +5364,9 @@ class ImageDiffSide extends React__namespace.Component {
|
|
|
5349
5364
|
}
|
|
5350
5365
|
class TextDiff extends React__namespace.Component {
|
|
5351
5366
|
static propTypes = {
|
|
5352
|
-
after: PropTypes__default
|
|
5353
|
-
before: PropTypes__default
|
|
5354
|
-
title: PropTypes__default
|
|
5367
|
+
after: PropTypes__default.default.string,
|
|
5368
|
+
before: PropTypes__default.default.string,
|
|
5369
|
+
title: PropTypes__default.default.string.isRequired
|
|
5355
5370
|
};
|
|
5356
5371
|
static defaultProps = {
|
|
5357
5372
|
after: "",
|
|
@@ -5376,15 +5391,15 @@ class TextDiff extends React__namespace.Component {
|
|
|
5376
5391
|
const beforeImages = imagesInString(this.props.before);
|
|
5377
5392
|
const afterImages = imagesInString(this.props.after);
|
|
5378
5393
|
const images = stringArrayDiff(beforeImages, afterImages);
|
|
5379
|
-
const renderedLines = ___default
|
|
5394
|
+
const renderedLines = ___default.default.map(lines, line => {
|
|
5380
5395
|
const contents = {};
|
|
5381
|
-
contents.before = ___default
|
|
5396
|
+
contents.before = ___default.default(line).map(function (entry, i) {
|
|
5382
5397
|
return /*#__PURE__*/React__namespace.createElement("span", {
|
|
5383
5398
|
key: i,
|
|
5384
5399
|
className: classFor(entry, "not-present", "removed dark")
|
|
5385
5400
|
}, entry.value);
|
|
5386
5401
|
});
|
|
5387
|
-
contents.after = ___default
|
|
5402
|
+
contents.after = ___default.default(line).map(function (entry, i) {
|
|
5388
5403
|
return /*#__PURE__*/React__namespace.createElement("span", {
|
|
5389
5404
|
key: i,
|
|
5390
5405
|
className: classFor(entry, "added dark", "not-present")
|
|
@@ -5392,7 +5407,7 @@ class TextDiff extends React__namespace.Component {
|
|
|
5392
5407
|
});
|
|
5393
5408
|
return contents;
|
|
5394
5409
|
});
|
|
5395
|
-
const className = classNames__default
|
|
5410
|
+
const className = classNames__default.default({
|
|
5396
5411
|
"diff-row": true,
|
|
5397
5412
|
collapsed: this.state.collapsed
|
|
5398
5413
|
});
|
|
@@ -5402,13 +5417,13 @@ class TextDiff extends React__namespace.Component {
|
|
|
5402
5417
|
className: "diff-header"
|
|
5403
5418
|
}, this.props.title), /*#__PURE__*/React__namespace.createElement("div", {
|
|
5404
5419
|
className: "diff-body ui-helper-clearfix"
|
|
5405
|
-
}, ___default
|
|
5420
|
+
}, ___default.default.map([BEFORE$1, AFTER$1], (side, index) => {
|
|
5406
5421
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
5407
5422
|
className: "diff-row " + side,
|
|
5408
5423
|
key: index
|
|
5409
|
-
}, !this.state.collapsed && ___default
|
|
5424
|
+
}, !this.state.collapsed && ___default.default.map(renderedLines, (line, lineNum) => {
|
|
5410
5425
|
const changed = line[side].length > 1;
|
|
5411
|
-
const lineClass = classNames__default
|
|
5426
|
+
const lineClass = classNames__default.default({
|
|
5412
5427
|
"diff-line": true,
|
|
5413
5428
|
added: side === AFTER$1 && changed,
|
|
5414
5429
|
removed: side === BEFORE$1 && changed
|
|
@@ -5420,7 +5435,7 @@ class TextDiff extends React__namespace.Component {
|
|
|
5420
5435
|
}), !this.state.collapsed && /*#__PURE__*/React__namespace.createElement(ImageDiffSide, {
|
|
5421
5436
|
images: images[side]
|
|
5422
5437
|
}));
|
|
5423
|
-
})), ___default
|
|
5438
|
+
})), ___default.default.map([BEFORE$1, AFTER$1], (side, index) => {
|
|
5424
5439
|
return (
|
|
5425
5440
|
/*#__PURE__*/
|
|
5426
5441
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events -- TODO(LEMS-2871): Address a11y error
|
|
@@ -5465,10 +5480,10 @@ const valueEntry = function (before, after, key) {
|
|
|
5465
5480
|
|
|
5466
5481
|
// For values which require a more granular diff (objects and arrays)
|
|
5467
5482
|
const objectEntry = function (before, after, key) {
|
|
5468
|
-
const beforeKeys = ___default
|
|
5469
|
-
const afterKeys = ___default
|
|
5470
|
-
const keys = ___default
|
|
5471
|
-
const children = ___default
|
|
5483
|
+
const beforeKeys = ___default.default.isObject(before) ? ___default.default(before).keys() : [];
|
|
5484
|
+
const afterKeys = ___default.default.isObject(after) ? ___default.default(after).keys() : [];
|
|
5485
|
+
const keys = ___default.default.union(beforeKeys, afterKeys);
|
|
5486
|
+
const children = ___default.default.map(keys, function (key) {
|
|
5472
5487
|
return performDiff((before || {})[key], (after || {})[key], key);
|
|
5473
5488
|
});
|
|
5474
5489
|
let status;
|
|
@@ -5477,7 +5492,7 @@ const objectEntry = function (before, after, key) {
|
|
|
5477
5492
|
} else if (after === undefined) {
|
|
5478
5493
|
status = REMOVED;
|
|
5479
5494
|
} else {
|
|
5480
|
-
const changed = ___default
|
|
5495
|
+
const changed = ___default.default.any(children, function (child) {
|
|
5481
5496
|
return child.status !== UNCHANGED$1;
|
|
5482
5497
|
});
|
|
5483
5498
|
status = changed ? CHANGED : UNCHANGED$1;
|
|
@@ -5508,15 +5523,15 @@ const AFTER = "after";
|
|
|
5508
5523
|
const UNCHANGED = "unchanged";
|
|
5509
5524
|
class DiffSide extends React__namespace.Component {
|
|
5510
5525
|
static propTypes = {
|
|
5511
|
-
className: PropTypes__default
|
|
5512
|
-
depth: PropTypes__default
|
|
5513
|
-
propKey: PropTypes__default
|
|
5514
|
-
showKey: PropTypes__default
|
|
5515
|
-
side: PropTypes__default
|
|
5516
|
-
value: PropTypes__default
|
|
5526
|
+
className: PropTypes__default.default.string.isRequired,
|
|
5527
|
+
depth: PropTypes__default.default.number.isRequired,
|
|
5528
|
+
propKey: PropTypes__default.default.string.isRequired,
|
|
5529
|
+
showKey: PropTypes__default.default.bool.isRequired,
|
|
5530
|
+
side: PropTypes__default.default.oneOf([BEFORE, AFTER]).isRequired,
|
|
5531
|
+
value: PropTypes__default.default.string
|
|
5517
5532
|
};
|
|
5518
5533
|
render() {
|
|
5519
|
-
const className = classNames__default
|
|
5534
|
+
const className = classNames__default.default(this.props.className, {
|
|
5520
5535
|
"diff-row": true,
|
|
5521
5536
|
before: this.props.side === BEFORE,
|
|
5522
5537
|
after: this.props.side === AFTER
|
|
@@ -5534,8 +5549,8 @@ class DiffSide extends React__namespace.Component {
|
|
|
5534
5549
|
}
|
|
5535
5550
|
class CollapsedRow extends React__namespace.Component {
|
|
5536
5551
|
static propTypes = {
|
|
5537
|
-
depth: PropTypes__default
|
|
5538
|
-
onClick: PropTypes__default
|
|
5552
|
+
depth: PropTypes__default.default.number,
|
|
5553
|
+
onClick: PropTypes__default.default.func.isRequired
|
|
5539
5554
|
};
|
|
5540
5555
|
static defaultProps = {
|
|
5541
5556
|
depth: 0
|
|
@@ -5550,7 +5565,7 @@ class CollapsedRow extends React__namespace.Component {
|
|
|
5550
5565
|
style: {
|
|
5551
5566
|
clear: "both"
|
|
5552
5567
|
}
|
|
5553
|
-
}, ___default
|
|
5568
|
+
}, ___default.default.map([BEFORE, AFTER], function (side) {
|
|
5554
5569
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
5555
5570
|
className: "diff-row collapsed " + side,
|
|
5556
5571
|
key: side
|
|
@@ -5567,14 +5582,14 @@ class CollapsedRow extends React__namespace.Component {
|
|
|
5567
5582
|
// Component representing a single property that may be nested.
|
|
5568
5583
|
class DiffEntry extends React__namespace.Component {
|
|
5569
5584
|
static propTypes = {
|
|
5570
|
-
depth: PropTypes__default
|
|
5571
|
-
entry: PropTypes__default
|
|
5572
|
-
after: PropTypes__default
|
|
5573
|
-
before: PropTypes__default
|
|
5574
|
-
children: PropTypes__default
|
|
5575
|
-
key: PropTypes__default
|
|
5585
|
+
depth: PropTypes__default.default.number,
|
|
5586
|
+
entry: PropTypes__default.default.shape({
|
|
5587
|
+
after: PropTypes__default.default.string,
|
|
5588
|
+
before: PropTypes__default.default.string,
|
|
5589
|
+
children: PropTypes__default.default.arrayOf(PropTypes__default.default.any),
|
|
5590
|
+
key: PropTypes__default.default.string
|
|
5576
5591
|
}),
|
|
5577
|
-
expanded: PropTypes__default
|
|
5592
|
+
expanded: PropTypes__default.default.bool
|
|
5578
5593
|
};
|
|
5579
5594
|
static defaultProps = {
|
|
5580
5595
|
depth: 0
|
|
@@ -5593,12 +5608,12 @@ class DiffEntry extends React__namespace.Component {
|
|
|
5593
5608
|
const propertyAdded = entry.status === "added";
|
|
5594
5609
|
const propertyChanged = entry.status === "changed";
|
|
5595
5610
|
const hasChildren = entry.children.length > 0;
|
|
5596
|
-
const leftClass = classNames__default
|
|
5611
|
+
const leftClass = classNames__default.default({
|
|
5597
5612
|
removed: propertyDeleted || propertyChanged && !hasChildren,
|
|
5598
5613
|
dark: propertyDeleted,
|
|
5599
5614
|
"blank-space": propertyAdded
|
|
5600
5615
|
});
|
|
5601
|
-
const rightClass = classNames__default
|
|
5616
|
+
const rightClass = classNames__default.default({
|
|
5602
5617
|
added: propertyAdded || propertyChanged && !hasChildren,
|
|
5603
5618
|
dark: propertyAdded,
|
|
5604
5619
|
"blank-space": propertyDeleted
|
|
@@ -5607,7 +5622,7 @@ class DiffEntry extends React__namespace.Component {
|
|
|
5607
5622
|
if (this.state.expanded) {
|
|
5608
5623
|
shownChildren = entry.children;
|
|
5609
5624
|
} else {
|
|
5610
|
-
shownChildren = ___default
|
|
5625
|
+
shownChildren = ___default.default(entry.children).select(function (child) {
|
|
5611
5626
|
return child.status !== UNCHANGED;
|
|
5612
5627
|
});
|
|
5613
5628
|
}
|
|
@@ -5637,7 +5652,7 @@ class DiffEntry extends React__namespace.Component {
|
|
|
5637
5652
|
propKey: entry.key,
|
|
5638
5653
|
showKey: !propertyDeleted,
|
|
5639
5654
|
value: entry.after
|
|
5640
|
-
})), ___default
|
|
5655
|
+
})), ___default.default.map(shownChildren, function (child) {
|
|
5641
5656
|
return /*#__PURE__*/React__namespace.createElement(DiffEntry, {
|
|
5642
5657
|
key: child.key,
|
|
5643
5658
|
depth: self.props.depth + 1,
|
|
@@ -5654,11 +5669,11 @@ class DiffEntry extends React__namespace.Component {
|
|
|
5654
5669
|
// For image widgets, show the actual image
|
|
5655
5670
|
class ImageWidgetDiff extends React__namespace.Component {
|
|
5656
5671
|
static propTypes = {
|
|
5657
|
-
after: PropTypes__default
|
|
5658
|
-
options: PropTypes__default
|
|
5672
|
+
after: PropTypes__default.default.shape({
|
|
5673
|
+
options: PropTypes__default.default.objectOf(PropTypes__default.default.any)
|
|
5659
5674
|
}).isRequired,
|
|
5660
|
-
before: PropTypes__default
|
|
5661
|
-
options: PropTypes__default
|
|
5675
|
+
before: PropTypes__default.default.shape({
|
|
5676
|
+
options: PropTypes__default.default.objectOf(PropTypes__default.default.any)
|
|
5662
5677
|
}).isRequired
|
|
5663
5678
|
};
|
|
5664
5679
|
render() {
|
|
@@ -5671,7 +5686,7 @@ class ImageWidgetDiff extends React__namespace.Component {
|
|
|
5671
5686
|
return /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("div", {
|
|
5672
5687
|
className: "diff-row before"
|
|
5673
5688
|
}, beforeSrc && /*#__PURE__*/React__namespace.createElement("div", {
|
|
5674
|
-
className: classNames__default
|
|
5689
|
+
className: classNames__default.default({
|
|
5675
5690
|
image: true,
|
|
5676
5691
|
"image-unchanged": beforeSrc === afterSrc,
|
|
5677
5692
|
"image-removed": beforeSrc !== afterSrc
|
|
@@ -5682,7 +5697,7 @@ class ImageWidgetDiff extends React__namespace.Component {
|
|
|
5682
5697
|
}))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
5683
5698
|
className: "diff-row after"
|
|
5684
5699
|
}, afterSrc && /*#__PURE__*/React__namespace.createElement("div", {
|
|
5685
|
-
className: classNames__default
|
|
5700
|
+
className: classNames__default.default({
|
|
5686
5701
|
image: true,
|
|
5687
5702
|
"image-unchanged": beforeSrc === afterSrc,
|
|
5688
5703
|
"image-added": beforeSrc !== afterSrc
|
|
@@ -5695,14 +5710,14 @@ class ImageWidgetDiff extends React__namespace.Component {
|
|
|
5695
5710
|
}
|
|
5696
5711
|
class WidgetDiff extends React__namespace.Component {
|
|
5697
5712
|
static propTypes = {
|
|
5698
|
-
after: PropTypes__default
|
|
5699
|
-
options: PropTypes__default
|
|
5713
|
+
after: PropTypes__default.default.shape({
|
|
5714
|
+
options: PropTypes__default.default.objectOf(PropTypes__default.default.any)
|
|
5700
5715
|
}),
|
|
5701
|
-
before: PropTypes__default
|
|
5702
|
-
options: PropTypes__default
|
|
5716
|
+
before: PropTypes__default.default.shape({
|
|
5717
|
+
options: PropTypes__default.default.objectOf(PropTypes__default.default.any)
|
|
5703
5718
|
}),
|
|
5704
|
-
title: PropTypes__default
|
|
5705
|
-
type: PropTypes__default
|
|
5719
|
+
title: PropTypes__default.default.string.isRequired,
|
|
5720
|
+
type: PropTypes__default.default.string
|
|
5706
5721
|
};
|
|
5707
5722
|
static defaultProps = {
|
|
5708
5723
|
after: {},
|
|
@@ -5735,6 +5750,7 @@ class WidgetDiff extends React__namespace.Component {
|
|
|
5735
5750
|
/**
|
|
5736
5751
|
* A side by side diff view for Perseus renderers.
|
|
5737
5752
|
*/
|
|
5753
|
+
|
|
5738
5754
|
// In diffs, only show the widgetInfo props that can change
|
|
5739
5755
|
const filterWidgetInfo = function (widgetInfo, showAlignmentOptions) {
|
|
5740
5756
|
const {
|
|
@@ -5800,8 +5816,10 @@ class RendererDiff extends React__namespace.Component {
|
|
|
5800
5816
|
}
|
|
5801
5817
|
const beforeWidgets = Object.keys(before.widgets ?? {}).filter(widget => before.content.includes(widget));
|
|
5802
5818
|
const afterWidgets = Object.keys(after.widgets ?? {}).filter(widget => after.content.includes(widget));
|
|
5819
|
+
|
|
5820
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
5803
5821
|
if (beforeWidgets.length || afterWidgets.length) {
|
|
5804
|
-
const widgets = ___default
|
|
5822
|
+
const widgets = ___default.default.union(beforeWidgets, afterWidgets);
|
|
5805
5823
|
widgetsDiff = widgets.map(widget => /*#__PURE__*/React__namespace.createElement(WidgetDiff, {
|
|
5806
5824
|
before: filterWidgetInfo(before.widgets?.[widget], showAlignmentOptions),
|
|
5807
5825
|
after: filterWidgetInfo(after.widgets?.[widget], showAlignmentOptions),
|
|
@@ -5817,17 +5835,21 @@ class RendererDiff extends React__namespace.Component {
|
|
|
5817
5835
|
}
|
|
5818
5836
|
|
|
5819
5837
|
/* eslint-disable react/no-unsafe */
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5838
|
+
/**
|
|
5839
|
+
* A side by side diff view for Perseus articles.
|
|
5840
|
+
*/
|
|
5841
|
+
|
|
5842
|
+
const rendererProps = PropTypes__default.default.shape({
|
|
5843
|
+
content: PropTypes__default.default.string,
|
|
5844
|
+
images: PropTypes__default.default.objectOf(PropTypes__default.default.any),
|
|
5845
|
+
widgets: PropTypes__default.default.objectOf(PropTypes__default.default.any)
|
|
5824
5846
|
});
|
|
5825
5847
|
class ArticleDiff extends React__namespace.Component {
|
|
5826
5848
|
static propTypes = {
|
|
5827
5849
|
// TODO(alex): Check whether we still have any Perseus articles whose
|
|
5828
5850
|
// top-level json is an object, not an array. If not, simplify here.
|
|
5829
|
-
after: PropTypes__default
|
|
5830
|
-
before: PropTypes__default
|
|
5851
|
+
after: PropTypes__default.default.oneOfType([rendererProps, PropTypes__default.default.arrayOf(rendererProps)]).isRequired,
|
|
5852
|
+
before: PropTypes__default.default.oneOfType([rendererProps, PropTypes__default.default.arrayOf(rendererProps)]).isRequired
|
|
5831
5853
|
};
|
|
5832
5854
|
static _stateFromProps = props => {
|
|
5833
5855
|
const {
|
|
@@ -5849,7 +5871,7 @@ class ArticleDiff extends React__namespace.Component {
|
|
|
5849
5871
|
after
|
|
5850
5872
|
} = this.state;
|
|
5851
5873
|
const sectionCount = Math.max(before.length, after.length);
|
|
5852
|
-
const sections = ___default
|
|
5874
|
+
const sections = ___default.default.times(sectionCount, n => /*#__PURE__*/React__namespace.createElement(RendererDiff, {
|
|
5853
5875
|
before: n < before.length ? before[n] : undefined,
|
|
5854
5876
|
after: n < after.length ? after[n] : undefined,
|
|
5855
5877
|
title: `Section ${n + 1}`,
|
|
@@ -5867,10 +5889,11 @@ class ArticleDiff extends React__namespace.Component {
|
|
|
5867
5889
|
* A side by side diff view for Perseus exercise items
|
|
5868
5890
|
* in the standard layout.
|
|
5869
5891
|
*/
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5892
|
+
|
|
5893
|
+
const itemProps = PropTypes__default.default.shape({
|
|
5894
|
+
question: PropTypes__default.default.shape({}).isRequired,
|
|
5895
|
+
answerArea: PropTypes__default.default.shape({}).isRequired,
|
|
5896
|
+
hints: PropTypes__default.default.arrayOf(PropTypes__default.default.any).isRequired
|
|
5874
5897
|
});
|
|
5875
5898
|
class ItemDiff extends React__namespace.Component {
|
|
5876
5899
|
static propTypes = {
|
|
@@ -5895,7 +5918,7 @@ class ItemDiff extends React__namespace.Component {
|
|
|
5895
5918
|
after: after.answerArea,
|
|
5896
5919
|
title: "Question extras"
|
|
5897
5920
|
});
|
|
5898
|
-
const hints = ___default
|
|
5921
|
+
const hints = ___default.default.times(hintCount, function (n) {
|
|
5899
5922
|
return /*#__PURE__*/React__namespace.createElement(RendererDiff, {
|
|
5900
5923
|
before: n < before.hints.length ? before.hints[n] : undefined,
|
|
5901
5924
|
after: n < after.hints.length ? after.hints[n] : undefined,
|
|
@@ -5914,6 +5937,11 @@ class ItemDiff extends React__namespace.Component {
|
|
|
5914
5937
|
}
|
|
5915
5938
|
|
|
5916
5939
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
5940
|
+
/* eslint-disable @babel/no-invalid-this */
|
|
5941
|
+
/**
|
|
5942
|
+
* Collection of classes for rendering the hint editor area,
|
|
5943
|
+
* hint editor boxes, and hint previews
|
|
5944
|
+
*/
|
|
5917
5945
|
const {
|
|
5918
5946
|
InfoTip: InfoTip$p,
|
|
5919
5947
|
InlineIcon: InlineIcon$5
|
|
@@ -5978,11 +6006,11 @@ class HintEditor extends React__namespace.Component {
|
|
|
5978
6006
|
}, /*#__PURE__*/React__namespace.createElement("button", {
|
|
5979
6007
|
type: "button",
|
|
5980
6008
|
className: this.props.isLast ? "hidden" : "",
|
|
5981
|
-
onClick: ___default
|
|
6009
|
+
onClick: ___default.default.partial(this.props.onMove, 1)
|
|
5982
6010
|
}, /*#__PURE__*/React__namespace.createElement(InlineIcon$5, iconCircleArrowDown)), " ", /*#__PURE__*/React__namespace.createElement("button", {
|
|
5983
6011
|
type: "button",
|
|
5984
6012
|
className: this.props.isFirst ? "hidden" : "",
|
|
5985
|
-
onClick: ___default
|
|
6013
|
+
onClick: ___default.default.partial(this.props.onMove, -1)
|
|
5986
6014
|
}, /*#__PURE__*/React__namespace.createElement(InlineIcon$5, iconCircleArrowUp)), " ", this.props.isLast && /*#__PURE__*/React__namespace.createElement(InfoTip$p, null, /*#__PURE__*/React__namespace.createElement("p", null, "The last hint is automatically bolded."))), /*#__PURE__*/React__namespace.createElement("input", {
|
|
5987
6015
|
type: "checkbox"
|
|
5988
6016
|
// @ts-expect-error - TS2322 - Type 'boolean | null | undefined' is not assignable to type 'boolean | undefined'.
|
|
@@ -6086,7 +6114,7 @@ class CombinedHintsEditor extends React__namespace.Component {
|
|
|
6086
6114
|
handleHintChange = (i, newProps, cb, silent) => {
|
|
6087
6115
|
// TODO(joel) - lens
|
|
6088
6116
|
const hints = [...this.props.hints];
|
|
6089
|
-
hints[i] = ___default
|
|
6117
|
+
hints[i] = ___default.default.extend({}, this.serializeHint(i, {
|
|
6090
6118
|
keepDeletedWidgets: true
|
|
6091
6119
|
}), newProps);
|
|
6092
6120
|
this.props.onChange({
|
|
@@ -6132,8 +6160,8 @@ class CombinedHintsEditor extends React__namespace.Component {
|
|
|
6132
6160
|
});
|
|
6133
6161
|
};
|
|
6134
6162
|
getSaveWarnings = () => {
|
|
6135
|
-
return ___default
|
|
6136
|
-
return ___default
|
|
6163
|
+
return ___default.default.chain(this.props.hints).map((hint, i) => {
|
|
6164
|
+
return ___default.default.map(
|
|
6137
6165
|
// eslint-disable-next-line react/no-string-refs
|
|
6138
6166
|
// @ts-expect-error - TS2339 - Property 'getSaveWarnings' does not exist on type 'ReactInstance'.
|
|
6139
6167
|
this.refs["hintEditor" + i].getSaveWarnings(), issue => "Hint " + (i + 1) + ": " + issue);
|
|
@@ -6154,7 +6182,7 @@ class CombinedHintsEditor extends React__namespace.Component {
|
|
|
6154
6182
|
itemId,
|
|
6155
6183
|
hints
|
|
6156
6184
|
} = this.props;
|
|
6157
|
-
const hintElems = ___default
|
|
6185
|
+
const hintElems = ___default.default.map(hints, function (hint, i) {
|
|
6158
6186
|
return /*#__PURE__*/React__namespace.createElement(CombinedHintEditor, {
|
|
6159
6187
|
ref: "hintEditor" + i,
|
|
6160
6188
|
key: "hintEditor" + i,
|
|
@@ -6378,20 +6406,20 @@ class ItemEditor extends React__namespace.Component {
|
|
|
6378
6406
|
|
|
6379
6407
|
// Notify the parent that the question or answer area has been updated.
|
|
6380
6408
|
updateProps = (newProps, cb, silent) => {
|
|
6381
|
-
const props = ___default
|
|
6382
|
-
this.props.onChange(___default
|
|
6409
|
+
const props = ___default.default(this.props).pick("question", "answerArea");
|
|
6410
|
+
this.props.onChange(___default.default(props).extend(newProps), cb, silent);
|
|
6383
6411
|
};
|
|
6384
6412
|
triggerPreviewUpdate = newData => {
|
|
6385
6413
|
this.frame.current?.sendNewData(newData);
|
|
6386
6414
|
};
|
|
6387
6415
|
handleEditorChange = (newProps, cb, silent) => {
|
|
6388
|
-
const question = ___default
|
|
6416
|
+
const question = ___default.default.extend({}, this.props.question, newProps);
|
|
6389
6417
|
this.updateProps({
|
|
6390
6418
|
question
|
|
6391
6419
|
}, cb, silent);
|
|
6392
6420
|
};
|
|
6393
6421
|
handleItemExtrasChange = (newProps, cb, silent) => {
|
|
6394
|
-
const answerArea = ___default
|
|
6422
|
+
const answerArea = ___default.default.extend({}, this.props.answerArea, newProps);
|
|
6395
6423
|
this.updateProps({
|
|
6396
6424
|
answerArea
|
|
6397
6425
|
}, cb, silent);
|
|
@@ -6416,7 +6444,7 @@ class ItemEditor extends React__namespace.Component {
|
|
|
6416
6444
|
className: "perseus-editor-left-cell"
|
|
6417
6445
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
6418
6446
|
className: "pod-title"
|
|
6419
|
-
}, "Question"), /*#__PURE__*/React__namespace.createElement(Editor, _extends__default
|
|
6447
|
+
}, "Question"), /*#__PURE__*/React__namespace.createElement(Editor, _extends__default.default({
|
|
6420
6448
|
ref: this.questionEditor
|
|
6421
6449
|
// Using the AssessmentItem content ID as the key
|
|
6422
6450
|
// ensures that when the user navigates to another
|
|
@@ -6457,7 +6485,7 @@ class ItemEditor extends React__namespace.Component {
|
|
|
6457
6485
|
className: "perseus-editor-left-cell"
|
|
6458
6486
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
6459
6487
|
className: "pod-title"
|
|
6460
|
-
}, "Question extras"), /*#__PURE__*/React__namespace.createElement(ItemExtrasEditor, _extends__default
|
|
6488
|
+
}, "Question extras"), /*#__PURE__*/React__namespace.createElement(ItemExtrasEditor, _extends__default.default({
|
|
6461
6489
|
ref: this.itemExtrasEditor,
|
|
6462
6490
|
onChange: this.handleItemExtrasChange
|
|
6463
6491
|
}, this.props.answerArea))), /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -6483,7 +6511,7 @@ class EditorPage extends React__namespace.Component {
|
|
|
6483
6511
|
super(props);
|
|
6484
6512
|
this.state = {
|
|
6485
6513
|
// @ts-expect-error - TS2322 - Type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "hints" | "question" | "answerArea" | "itemDataVersion">' is not assignable to type 'PerseusJson'.
|
|
6486
|
-
json: ___default
|
|
6514
|
+
json: ___default.default.pick(this.props, "question", "answerArea", "hints", "itemDataVersion"),
|
|
6487
6515
|
gradeMessage: "",
|
|
6488
6516
|
wasAnswered: false,
|
|
6489
6517
|
highlightLint: true,
|
|
@@ -6539,7 +6567,7 @@ class EditorPage extends React__namespace.Component {
|
|
|
6539
6567
|
};
|
|
6540
6568
|
this.itemEditor.current?.triggerPreviewUpdate({
|
|
6541
6569
|
type: "question",
|
|
6542
|
-
data: ___default
|
|
6570
|
+
data: ___default.default({
|
|
6543
6571
|
item: this.serialize(),
|
|
6544
6572
|
apiOptions: deviceBasedApiOptions,
|
|
6545
6573
|
initialHintsVisible: 0,
|
|
@@ -6552,7 +6580,7 @@ class EditorPage extends React__namespace.Component {
|
|
|
6552
6580
|
},
|
|
6553
6581
|
reviewMode: true,
|
|
6554
6582
|
legacyPerseusLint: this.itemEditor.current?.getSaveWarnings()
|
|
6555
|
-
}).extend(___default
|
|
6583
|
+
}).extend(___default.default(this.props).pick("workAreaSelector", "solutionAreaSelector", "hintsAreaSelector", "problemNum"))
|
|
6556
6584
|
});
|
|
6557
6585
|
}
|
|
6558
6586
|
getApiOptions() {
|
|
@@ -6570,13 +6598,13 @@ class EditorPage extends React__namespace.Component {
|
|
|
6570
6598
|
if (this.props.jsonMode) {
|
|
6571
6599
|
return this.state.json;
|
|
6572
6600
|
}
|
|
6573
|
-
return ___default
|
|
6601
|
+
return ___default.default.extend(this.itemEditor.current?.serialize(options), {
|
|
6574
6602
|
hints: this.hintsEditor.current?.serialize(options)
|
|
6575
6603
|
});
|
|
6576
6604
|
}
|
|
6577
6605
|
handleChange = (toChange, cb, silent) => {
|
|
6578
|
-
const newProps = ___default
|
|
6579
|
-
___default
|
|
6606
|
+
const newProps = ___default.default(this.props).pick("question", "hints", "answerArea");
|
|
6607
|
+
___default.default(newProps).extend(toChange);
|
|
6580
6608
|
this.props.onChange(newProps, cb, silent);
|
|
6581
6609
|
};
|
|
6582
6610
|
changeJSON = newJson => {
|
|
@@ -6680,7 +6708,7 @@ function ContentPreview(_ref) {
|
|
|
6680
6708
|
keypadElement,
|
|
6681
6709
|
setKeypadElement
|
|
6682
6710
|
} = _ref2;
|
|
6683
|
-
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(perseus.Renderer, _extends__default
|
|
6711
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(perseus.Renderer, _extends__default.default({
|
|
6684
6712
|
strings: i18n.strings,
|
|
6685
6713
|
apiOptions: {
|
|
6686
6714
|
...apiOptions,
|
|
@@ -6715,10 +6743,10 @@ class CategorizerEditor extends React__namespace.Component {
|
|
|
6715
6743
|
static propTypes = {
|
|
6716
6744
|
...perseus.Changeable.propTypes,
|
|
6717
6745
|
apiOptions: perseus.ApiOptions.propTypes,
|
|
6718
|
-
items: PropTypes__default
|
|
6719
|
-
categories: PropTypes__default
|
|
6720
|
-
values: PropTypes__default
|
|
6721
|
-
randomizeItems: PropTypes__default
|
|
6746
|
+
items: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
6747
|
+
categories: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
6748
|
+
values: PropTypes__default.default.arrayOf(PropTypes__default.default.number),
|
|
6749
|
+
randomizeItems: PropTypes__default.default.bool
|
|
6722
6750
|
};
|
|
6723
6751
|
static widgetName = "categorizer";
|
|
6724
6752
|
static defaultProps = perseusCore.categorizerLogic.defaultWidgetOptions;
|
|
@@ -6766,7 +6794,7 @@ class CategorizerEditor extends React__namespace.Component {
|
|
|
6766
6794
|
// is deleted from the middle. Inconvenient, but
|
|
6767
6795
|
// it's at least possible for content creators to
|
|
6768
6796
|
// catch and fix.
|
|
6769
|
-
values: ___default
|
|
6797
|
+
values: ___default.default.first(this.props.values, items.length)
|
|
6770
6798
|
});
|
|
6771
6799
|
},
|
|
6772
6800
|
layout: "vertical"
|
|
@@ -6838,6 +6866,10 @@ class BlurInput extends React__namespace.Component {
|
|
|
6838
6866
|
}
|
|
6839
6867
|
|
|
6840
6868
|
/* eslint-disable no-useless-escape */
|
|
6869
|
+
/**
|
|
6870
|
+
* This editor is for embedding Khan Academy CS programs.
|
|
6871
|
+
*/
|
|
6872
|
+
|
|
6841
6873
|
const {
|
|
6842
6874
|
InfoTip: InfoTip$n
|
|
6843
6875
|
} = perseus.components;
|
|
@@ -6847,11 +6879,11 @@ const DEFAULT_HEIGHT = 400;
|
|
|
6847
6879
|
/**
|
|
6848
6880
|
* This is used for editing a name/value pair.
|
|
6849
6881
|
*/
|
|
6850
|
-
|
|
6882
|
+
let PairEditor$1 = class PairEditor extends React__namespace.Component {
|
|
6851
6883
|
static propTypes = {
|
|
6852
6884
|
...perseus.Changeable.propTypes,
|
|
6853
|
-
name: PropTypes__default
|
|
6854
|
-
value: PropTypes__default
|
|
6885
|
+
name: PropTypes__default.default.string,
|
|
6886
|
+
value: PropTypes__default.default.string
|
|
6855
6887
|
};
|
|
6856
6888
|
static defaultProps = {
|
|
6857
6889
|
name: "",
|
|
@@ -6880,17 +6912,17 @@ class PairEditor$1 extends React__namespace.Component {
|
|
|
6880
6912
|
onChange: this.change("value")
|
|
6881
6913
|
})));
|
|
6882
6914
|
}
|
|
6883
|
-
}
|
|
6915
|
+
};
|
|
6884
6916
|
|
|
6885
6917
|
/**
|
|
6886
6918
|
* This is used for editing a set of name/value pairs.
|
|
6887
6919
|
*/
|
|
6888
|
-
|
|
6920
|
+
let PairsEditor$1 = class PairsEditor extends React__namespace.Component {
|
|
6889
6921
|
static propTypes = {
|
|
6890
6922
|
...perseus.Changeable.propTypes,
|
|
6891
|
-
pairs: PropTypes__default
|
|
6892
|
-
name: PropTypes__default
|
|
6893
|
-
value: PropTypes__default
|
|
6923
|
+
pairs: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
6924
|
+
name: PropTypes__default.default.string,
|
|
6925
|
+
value: PropTypes__default.default.string
|
|
6894
6926
|
})).isRequired
|
|
6895
6927
|
};
|
|
6896
6928
|
change = (() => {
|
|
@@ -6919,7 +6951,7 @@ class PairsEditor$1 extends React__namespace.Component {
|
|
|
6919
6951
|
return perseus.EditorJsonify.serialize.call(this);
|
|
6920
6952
|
};
|
|
6921
6953
|
render() {
|
|
6922
|
-
const editors = ___default
|
|
6954
|
+
const editors = ___default.default.map(this.props.pairs, (pair, i) => {
|
|
6923
6955
|
return /*#__PURE__*/React__namespace.createElement(PairEditor$1, {
|
|
6924
6956
|
key: i,
|
|
6925
6957
|
name: pair.name,
|
|
@@ -6931,7 +6963,7 @@ class PairsEditor$1 extends React__namespace.Component {
|
|
|
6931
6963
|
});
|
|
6932
6964
|
return /*#__PURE__*/React__namespace.createElement("div", null, editors);
|
|
6933
6965
|
}
|
|
6934
|
-
}
|
|
6966
|
+
};
|
|
6935
6967
|
const KA_PROGRAM_URL = /khanacademy\.org\/computer-programming\/[^\/]+\/(\d+)/;
|
|
6936
6968
|
|
|
6937
6969
|
/**
|
|
@@ -6979,7 +7011,7 @@ class CSProgramEditor extends React__namespace.Component {
|
|
|
6979
7011
|
} = perseus.Dependencies.getDependencies();
|
|
6980
7012
|
const host = isDevServer ? InitialRequestUrl.origin : "https://www.khanacademy.org";
|
|
6981
7013
|
const baseUrl = `${host}/api/internal/scratchpads/${programID}`;
|
|
6982
|
-
$__default
|
|
7014
|
+
$__default.default.getJSON(baseUrl).done(programInfo => {
|
|
6983
7015
|
const programType = programInfo.userAuthoredContentType;
|
|
6984
7016
|
this.change({
|
|
6985
7017
|
width: programInfo.width,
|
|
@@ -7042,9 +7074,9 @@ const {
|
|
|
7042
7074
|
class DefinitionEditor extends React__namespace.Component {
|
|
7043
7075
|
static propTypes = {
|
|
7044
7076
|
...perseus.Changeable.propTypes,
|
|
7045
|
-
togglePrompt: PropTypes__default
|
|
7046
|
-
definition: PropTypes__default
|
|
7047
|
-
apiOptions: PropTypes__default
|
|
7077
|
+
togglePrompt: PropTypes__default.default.string,
|
|
7078
|
+
definition: PropTypes__default.default.string,
|
|
7079
|
+
apiOptions: PropTypes__default.default.any
|
|
7048
7080
|
};
|
|
7049
7081
|
static widgetName = "definition";
|
|
7050
7082
|
static defaultProps = perseusCore.definitionLogic.defaultWidgetOptions;
|
|
@@ -7084,7 +7116,7 @@ class DefinitionEditor extends React__namespace.Component {
|
|
|
7084
7116
|
placeholder: "definition goes here",
|
|
7085
7117
|
onChange: props => {
|
|
7086
7118
|
const newProps = {};
|
|
7087
|
-
if (___default
|
|
7119
|
+
if (___default.default.has(props, "content")) {
|
|
7088
7120
|
newProps.definition = props.content;
|
|
7089
7121
|
}
|
|
7090
7122
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
@@ -7111,11 +7143,11 @@ const {
|
|
|
7111
7143
|
} = perseus.components;
|
|
7112
7144
|
class DropdownEditor extends React__namespace.Component {
|
|
7113
7145
|
static propTypes = {
|
|
7114
|
-
choices: PropTypes__default
|
|
7115
|
-
content: PropTypes__default
|
|
7116
|
-
correct: PropTypes__default
|
|
7146
|
+
choices: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
7147
|
+
content: PropTypes__default.default.string,
|
|
7148
|
+
correct: PropTypes__default.default.bool
|
|
7117
7149
|
})),
|
|
7118
|
-
placeholder: PropTypes__default
|
|
7150
|
+
placeholder: PropTypes__default.default.string
|
|
7119
7151
|
};
|
|
7120
7152
|
static widgetName = "dropdown";
|
|
7121
7153
|
static defaultProps = perseusCore.dropdownLogic.defaultWidgetOptions;
|
|
@@ -7135,8 +7167,8 @@ class DropdownEditor extends React__namespace.Component {
|
|
|
7135
7167
|
});
|
|
7136
7168
|
};
|
|
7137
7169
|
onCorrectChange = choiceIndex => {
|
|
7138
|
-
const choices = ___default
|
|
7139
|
-
return ___default
|
|
7170
|
+
const choices = ___default.default.map(this.props.choices, function (choice, i) {
|
|
7171
|
+
return ___default.default.extend({}, choice, {
|
|
7140
7172
|
correct: i === choiceIndex
|
|
7141
7173
|
});
|
|
7142
7174
|
});
|
|
@@ -7146,7 +7178,7 @@ class DropdownEditor extends React__namespace.Component {
|
|
|
7146
7178
|
};
|
|
7147
7179
|
onContentChange = (choiceIndex, e) => {
|
|
7148
7180
|
const choices = this.props.choices.slice();
|
|
7149
|
-
const choice = ___default
|
|
7181
|
+
const choice = ___default.default.clone(choices[choiceIndex]);
|
|
7150
7182
|
choice.content = e.target.value;
|
|
7151
7183
|
choices[choiceIndex] = choice;
|
|
7152
7184
|
this.props.onChange({
|
|
@@ -7166,7 +7198,7 @@ class DropdownEditor extends React__namespace.Component {
|
|
|
7166
7198
|
};
|
|
7167
7199
|
removeChoice = (choiceIndex, e) => {
|
|
7168
7200
|
e.preventDefault();
|
|
7169
|
-
const choices = ___default
|
|
7201
|
+
const choices = ___default.default(this.props.choices).clone();
|
|
7170
7202
|
choices.splice(choiceIndex, 1);
|
|
7171
7203
|
this.props.onChange({
|
|
7172
7204
|
choices: choices
|
|
@@ -7174,14 +7206,14 @@ class DropdownEditor extends React__namespace.Component {
|
|
|
7174
7206
|
};
|
|
7175
7207
|
focus = i => {
|
|
7176
7208
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'focus' does not exist on type 'Element | Text'.
|
|
7177
|
-
ReactDOM__default
|
|
7209
|
+
ReactDOM__default.default.findDOMNode(this.refs["editor" + i]).focus(); // eslint-disable-line react/no-string-refs
|
|
7178
7210
|
return true;
|
|
7179
7211
|
};
|
|
7180
7212
|
serialize = () => {
|
|
7181
7213
|
return perseus.EditorJsonify.serialize.call(this);
|
|
7182
7214
|
};
|
|
7183
7215
|
render() {
|
|
7184
|
-
const dropdownGroupName = ___default
|
|
7216
|
+
const dropdownGroupName = ___default.default.uniqueId("perseus_dropdown_");
|
|
7185
7217
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
7186
7218
|
className: "perseus-widget-dropdown"
|
|
7187
7219
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -7264,17 +7296,18 @@ class DropdownEditor extends React__namespace.Component {
|
|
|
7264
7296
|
}
|
|
7265
7297
|
|
|
7266
7298
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
7299
|
+
/* eslint-disable react/forbid-prop-types */
|
|
7267
7300
|
const {
|
|
7268
7301
|
TextInput: TextInput$6
|
|
7269
7302
|
} = perseus.components;
|
|
7270
7303
|
class ExplanationEditor extends React__namespace.Component {
|
|
7271
7304
|
static propTypes = {
|
|
7272
7305
|
...perseus.Changeable.propTypes,
|
|
7273
|
-
showPrompt: PropTypes__default
|
|
7274
|
-
hidePrompt: PropTypes__default
|
|
7275
|
-
explanation: PropTypes__default
|
|
7276
|
-
widgets: PropTypes__default
|
|
7277
|
-
apiOptions: PropTypes__default
|
|
7306
|
+
showPrompt: PropTypes__default.default.string,
|
|
7307
|
+
hidePrompt: PropTypes__default.default.string,
|
|
7308
|
+
explanation: PropTypes__default.default.string,
|
|
7309
|
+
widgets: PropTypes__default.default.object,
|
|
7310
|
+
apiOptions: PropTypes__default.default.any
|
|
7278
7311
|
};
|
|
7279
7312
|
static widgetName = "explanation";
|
|
7280
7313
|
static defaultProps = perseusCore.explanationLogic.defaultWidgetOptions;
|
|
@@ -7318,10 +7351,10 @@ class ExplanationEditor extends React__namespace.Component {
|
|
|
7318
7351
|
immutableWidgets: false,
|
|
7319
7352
|
onChange: props => {
|
|
7320
7353
|
const newProps = {};
|
|
7321
|
-
if (___default
|
|
7354
|
+
if (___default.default.has(props, "content")) {
|
|
7322
7355
|
newProps.explanation = props.content;
|
|
7323
7356
|
}
|
|
7324
|
-
if (___default
|
|
7357
|
+
if (___default.default.has(props, "widgets")) {
|
|
7325
7358
|
newProps.widgets = props.widgets;
|
|
7326
7359
|
}
|
|
7327
7360
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
@@ -7639,7 +7672,7 @@ class SortableArea extends React__namespace.Component {
|
|
|
7639
7672
|
this._dragItems = this._dragItems || [];
|
|
7640
7673
|
const items =
|
|
7641
7674
|
// @ts-expect-error - TS2531 - Object is possibly 'null'
|
|
7642
|
-
ReactDOM__default
|
|
7675
|
+
ReactDOM__default.default.findDOMNode(this).querySelectorAll("[draggable=true]");
|
|
7643
7676
|
const oldItems = [];
|
|
7644
7677
|
const newItems = [];
|
|
7645
7678
|
for (let i = 0; i < this._dragItems.length; i++) {
|
|
@@ -7815,7 +7848,7 @@ class ExpressionEditor extends React__namespace.Component {
|
|
|
7815
7848
|
if (!hasCorrect) {
|
|
7816
7849
|
issues.push("No correct answer specified");
|
|
7817
7850
|
}
|
|
7818
|
-
___default
|
|
7851
|
+
___default.default(this.props.answerForms).each((form, ix) => {
|
|
7819
7852
|
if (this.props.value === "") {
|
|
7820
7853
|
issues.push(`Answer ${ix + 1} is empty`);
|
|
7821
7854
|
} else {
|
|
@@ -7896,7 +7929,7 @@ class ExpressionEditor extends React__namespace.Component {
|
|
|
7896
7929
|
}
|
|
7897
7930
|
handleReorder = components => {
|
|
7898
7931
|
const answerForms = components.map(component => {
|
|
7899
|
-
const form = ___default
|
|
7932
|
+
const form = ___default.default(component.props).pick("considered", "form", "simplify", "value");
|
|
7900
7933
|
// @ts-expect-error - TS2339 - Property 'key' does not exist on type 'Pick<any, "form" | "value" | "simplify" | "considered">'.
|
|
7901
7934
|
form.key = component.key;
|
|
7902
7935
|
return form;
|
|
@@ -8083,7 +8116,7 @@ class ExpressionEditor extends React__namespace.Component {
|
|
|
8083
8116
|
style: {
|
|
8084
8117
|
margin: "4px 0"
|
|
8085
8118
|
}
|
|
8086
|
-
}, "student responses area matched against these from top to bottom"), sortable, /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement(Button__default
|
|
8119
|
+
}, "student responses area matched against these from top to bottom"), sortable, /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
8087
8120
|
size: "small",
|
|
8088
8121
|
onClick: this.newAnswer
|
|
8089
8122
|
}, "Add new answer")));
|
|
@@ -8129,17 +8162,17 @@ class AnswerOption extends React__namespace.Component {
|
|
|
8129
8162
|
this.props.onChangeConsidered(newVal);
|
|
8130
8163
|
};
|
|
8131
8164
|
render() {
|
|
8132
|
-
const removeButton = this.state.deleteFocused ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Button__default
|
|
8165
|
+
const removeButton = this.state.deleteFocused ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
8133
8166
|
size: "small",
|
|
8134
8167
|
onClick: this.handleImSure,
|
|
8135
8168
|
color: "destructive"
|
|
8136
8169
|
}, "I'm sure!"), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
8137
8170
|
size: wonderBlocksTokens.spacing.small_12
|
|
8138
|
-
}), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
8171
|
+
}), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
8139
8172
|
size: "small",
|
|
8140
8173
|
onClick: this.handleCancelDelete,
|
|
8141
8174
|
light: true
|
|
8142
|
-
}, "Cancel")) : /*#__PURE__*/React__namespace.createElement(Button__default
|
|
8175
|
+
}, "Cancel")) : /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
8143
8176
|
size: "small",
|
|
8144
8177
|
onClick: this.handleDelete,
|
|
8145
8178
|
color: "destructive",
|
|
@@ -8217,6 +8250,7 @@ const styles$N = aphrodite.StyleSheet.create({
|
|
|
8217
8250
|
});
|
|
8218
8251
|
|
|
8219
8252
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
8253
|
+
/* eslint-disable react/forbid-prop-types */
|
|
8220
8254
|
const {
|
|
8221
8255
|
InlineIcon: InlineIcon$3,
|
|
8222
8256
|
TextInput: TextInput$5
|
|
@@ -8224,10 +8258,10 @@ const {
|
|
|
8224
8258
|
class GradedGroupEditor extends React__namespace.Component {
|
|
8225
8259
|
static propTypes = {
|
|
8226
8260
|
...perseus.Changeable.propTypes,
|
|
8227
|
-
title: PropTypes__default
|
|
8228
|
-
content: PropTypes__default
|
|
8229
|
-
widgets: PropTypes__default
|
|
8230
|
-
images: PropTypes__default
|
|
8261
|
+
title: PropTypes__default.default.string,
|
|
8262
|
+
content: PropTypes__default.default.string,
|
|
8263
|
+
widgets: PropTypes__default.default.object,
|
|
8264
|
+
images: PropTypes__default.default.object,
|
|
8231
8265
|
apiOptions: perseus.ApiOptions.propTypes
|
|
8232
8266
|
};
|
|
8233
8267
|
static widgetName = "graded-group";
|
|
@@ -8345,8 +8379,8 @@ class GradedGroupSetEditor extends React__namespace.Component {
|
|
|
8345
8379
|
static propTypes = {
|
|
8346
8380
|
...perseus.Changeable.propTypes,
|
|
8347
8381
|
apiOptions: perseus.ApiOptions.propTypes,
|
|
8348
|
-
gradedGroups: PropTypes__default
|
|
8349
|
-
onChange: PropTypes__default
|
|
8382
|
+
gradedGroups: PropTypes__default.default.array,
|
|
8383
|
+
onChange: PropTypes__default.default.func.isRequired
|
|
8350
8384
|
};
|
|
8351
8385
|
static widgetName = "graded-group-set";
|
|
8352
8386
|
static defaultProps = perseusCore.gradedGroupSetLogic.defaultWidgetOptions;
|
|
@@ -8376,7 +8410,7 @@ class GradedGroupSetEditor extends React__namespace.Component {
|
|
|
8376
8410
|
if (!this.props.gradedGroups) {
|
|
8377
8411
|
return null;
|
|
8378
8412
|
}
|
|
8379
|
-
return this.props.gradedGroups.map((group, i) => /*#__PURE__*/React__namespace.createElement(GradedGroupEditor, _extends__default
|
|
8413
|
+
return this.props.gradedGroups.map((group, i) => /*#__PURE__*/React__namespace.createElement(GradedGroupEditor, _extends__default.default({
|
|
8380
8414
|
key: i,
|
|
8381
8415
|
ref: el => this._editors[i] = el
|
|
8382
8416
|
}, group, {
|
|
@@ -8407,6 +8441,9 @@ class GradedGroupSetEditor extends React__namespace.Component {
|
|
|
8407
8441
|
const setArrayItem = (list, i, value) => [...list.slice(0, i), value, ...list.slice(i + 1)];
|
|
8408
8442
|
|
|
8409
8443
|
/* eslint-disable react/forbid-prop-types, react/no-unsafe */
|
|
8444
|
+
/**
|
|
8445
|
+
* Used in the editors for the Grapher and Interaction widgets.
|
|
8446
|
+
*/
|
|
8410
8447
|
const {
|
|
8411
8448
|
ButtonGroup: ButtonGroup$6,
|
|
8412
8449
|
InfoTip: InfoTip$k,
|
|
@@ -8461,10 +8498,10 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8461
8498
|
// TODO(scottgrant): This is a hack to remove the deprecated call to
|
|
8462
8499
|
// this.isMounted() but is still considered an anti-pattern.
|
|
8463
8500
|
this._isMounted = true;
|
|
8464
|
-
this.changeGraph = ___default
|
|
8501
|
+
this.changeGraph = ___default.default.debounce(this.changeGraph, 300);
|
|
8465
8502
|
}
|
|
8466
8503
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
8467
|
-
if (!___default
|
|
8504
|
+
if (!___default.default.isEqual(this.props.labels, nextProps.labels) || !___default.default.isEqual(this.props.gridStep, nextProps.gridStep) || !___default.default.isEqual(this.props.snapStep, nextProps.snapStep) || !___default.default.isEqual(this.props.step, nextProps.step) || !___default.default.isEqual(this.props.range, nextProps.range) || !___default.default.isEqual(this.props.backgroundImage, nextProps.backgroundImage)) {
|
|
8468
8505
|
this.setState(this.stateFromProps(nextProps));
|
|
8469
8506
|
}
|
|
8470
8507
|
}
|
|
@@ -8478,7 +8515,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8478
8515
|
snapStepTextbox: props.snapStep,
|
|
8479
8516
|
stepTextbox: props.step,
|
|
8480
8517
|
rangeTextbox: props.range,
|
|
8481
|
-
backgroundImage: ___default
|
|
8518
|
+
backgroundImage: ___default.default.clone(props.backgroundImage)
|
|
8482
8519
|
};
|
|
8483
8520
|
}
|
|
8484
8521
|
|
|
@@ -8511,7 +8548,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8511
8548
|
return;
|
|
8512
8549
|
}
|
|
8513
8550
|
const setUrl = (url, width, height) => {
|
|
8514
|
-
const image = ___default
|
|
8551
|
+
const image = ___default.default.clone(this.props.backgroundImage);
|
|
8515
8552
|
image.url = url;
|
|
8516
8553
|
image.width = width;
|
|
8517
8554
|
image.height = height;
|
|
@@ -8521,7 +8558,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8521
8558
|
};
|
|
8522
8559
|
|
|
8523
8560
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
8524
|
-
const url = ReactDOM__default
|
|
8561
|
+
const url = ReactDOM__default.default.findDOMNode(this.refs["bg-url"]).value; // eslint-disable-line react/no-string-refs
|
|
8525
8562
|
if (url) {
|
|
8526
8563
|
perseus.Util.getImageSize(url, (width, height) => {
|
|
8527
8564
|
if (this._isMounted) {
|
|
@@ -8533,7 +8570,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8533
8570
|
}
|
|
8534
8571
|
}
|
|
8535
8572
|
renderLabelChoices(choices) {
|
|
8536
|
-
return ___default
|
|
8573
|
+
return ___default.default.map(choices, function (_ref) {
|
|
8537
8574
|
let [name, value] = _ref;
|
|
8538
8575
|
return /*#__PURE__*/React__namespace.createElement("option", {
|
|
8539
8576
|
key: value,
|
|
@@ -8542,8 +8579,8 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8542
8579
|
});
|
|
8543
8580
|
}
|
|
8544
8581
|
validRange(range) {
|
|
8545
|
-
const numbers = ___default
|
|
8546
|
-
return ___default
|
|
8582
|
+
const numbers = ___default.default.every(range, function (num) {
|
|
8583
|
+
return ___default.default.isFinite(num);
|
|
8547
8584
|
});
|
|
8548
8585
|
if (!numbers) {
|
|
8549
8586
|
return "Range must be a valid number";
|
|
@@ -8561,7 +8598,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8561
8598
|
minTicks,
|
|
8562
8599
|
maxTicks
|
|
8563
8600
|
} = settings;
|
|
8564
|
-
if (!___default
|
|
8601
|
+
if (!___default.default.isFinite(step)) {
|
|
8565
8602
|
return name + " must be a valid number";
|
|
8566
8603
|
}
|
|
8567
8604
|
const nSteps = numSteps$1(range, step);
|
|
@@ -8614,28 +8651,28 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8614
8651
|
validateGraphSettings(range, step, gridStep, snapStep, image) {
|
|
8615
8652
|
const self = this;
|
|
8616
8653
|
let msg;
|
|
8617
|
-
const goodRange = ___default
|
|
8654
|
+
const goodRange = ___default.default.every(range, function (range) {
|
|
8618
8655
|
msg = self.validRange(range);
|
|
8619
8656
|
return msg === true;
|
|
8620
8657
|
});
|
|
8621
8658
|
if (!goodRange) {
|
|
8622
8659
|
return msg;
|
|
8623
8660
|
}
|
|
8624
|
-
const goodStep = ___default
|
|
8661
|
+
const goodStep = ___default.default.every(step, function (step, i) {
|
|
8625
8662
|
msg = self.validStep(step, range[i]);
|
|
8626
8663
|
return msg === true;
|
|
8627
8664
|
});
|
|
8628
8665
|
if (!goodStep) {
|
|
8629
8666
|
return msg;
|
|
8630
8667
|
}
|
|
8631
|
-
const goodGridStep = ___default
|
|
8668
|
+
const goodGridStep = ___default.default.every(gridStep, function (gridStep, i) {
|
|
8632
8669
|
msg = self.validGridStep(gridStep, range[i]);
|
|
8633
8670
|
return msg === true;
|
|
8634
8671
|
});
|
|
8635
8672
|
if (!goodGridStep) {
|
|
8636
8673
|
return msg;
|
|
8637
8674
|
}
|
|
8638
|
-
const goodSnapStep = ___default
|
|
8675
|
+
const goodSnapStep = ___default.default.every(snapStep, function (snapStep, i) {
|
|
8639
8676
|
msg = self.validSnapStep(snapStep, range[i]);
|
|
8640
8677
|
return msg === true;
|
|
8641
8678
|
});
|
|
@@ -8692,17 +8729,17 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8692
8729
|
changeGridStep(gridStep) {
|
|
8693
8730
|
this.setState({
|
|
8694
8731
|
gridStepTextbox: gridStep,
|
|
8695
|
-
snapStepTextbox: ___default
|
|
8732
|
+
snapStepTextbox: ___default.default.map(gridStep, function (step) {
|
|
8696
8733
|
return step / 2;
|
|
8697
8734
|
})
|
|
8698
8735
|
}, this.changeGraph);
|
|
8699
8736
|
}
|
|
8700
8737
|
changeGraph() {
|
|
8701
8738
|
const labels = this.state.labelsTextbox;
|
|
8702
|
-
const range = ___default
|
|
8703
|
-
return ___default
|
|
8739
|
+
const range = ___default.default.map(this.state.rangeTextbox, function (range) {
|
|
8740
|
+
return ___default.default.map(range, Number);
|
|
8704
8741
|
});
|
|
8705
|
-
const step = ___default
|
|
8742
|
+
const step = ___default.default.map(this.state.stepTextbox, Number);
|
|
8706
8743
|
const gridStep = this.state.gridStepTextbox;
|
|
8707
8744
|
const snapStep = this.state.snapStepTextbox;
|
|
8708
8745
|
const image = this.state.backgroundImage;
|
|
@@ -8735,7 +8772,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8735
8772
|
const {
|
|
8736
8773
|
TeX
|
|
8737
8774
|
} = perseus.Dependencies.getDependencies();
|
|
8738
|
-
return /*#__PURE__*/React__namespace.createElement("div", null, ___default
|
|
8775
|
+
return /*#__PURE__*/React__namespace.createElement("div", null, ___default.default.contains(this.props.editableSettings, "canvas") && /*#__PURE__*/React__namespace.createElement("div", {
|
|
8739
8776
|
className: "graph-settings"
|
|
8740
8777
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
8741
8778
|
className: "perseus-widget-row"
|
|
@@ -8751,7 +8788,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8751
8788
|
}
|
|
8752
8789
|
})), /*#__PURE__*/React__namespace.createElement("div", {
|
|
8753
8790
|
className: "perseus-widget-row"
|
|
8754
|
-
}, "Scale (px per div):", " ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(" + scale[0] + ", " + scale[1] + ")"))), ___default
|
|
8791
|
+
}, "Scale (px per div):", " ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(" + scale[0] + ", " + scale[1] + ")"))), ___default.default.contains(this.props.editableSettings, "graph") && /*#__PURE__*/React__namespace.createElement("div", {
|
|
8755
8792
|
className: "graph-settings"
|
|
8756
8793
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
8757
8794
|
className: "perseus-widget-row"
|
|
@@ -8817,7 +8854,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8817
8854
|
id: "grid-step",
|
|
8818
8855
|
value: this.state.gridStepTextbox,
|
|
8819
8856
|
onChange: this.changeGridStep
|
|
8820
|
-
}))), ___default
|
|
8857
|
+
}))), ___default.default.contains(this.props.editableSettings, "snap") && /*#__PURE__*/React__namespace.createElement("div", {
|
|
8821
8858
|
className: "perseus-widget-row"
|
|
8822
8859
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
8823
8860
|
className: "perseus-widget-left-col"
|
|
@@ -8853,7 +8890,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8853
8890
|
showTooltips: value
|
|
8854
8891
|
});
|
|
8855
8892
|
}
|
|
8856
|
-
}))), ___default
|
|
8893
|
+
}))), ___default.default.contains(this.props.editableSettings, "image") && /*#__PURE__*/React__namespace.createElement("div", {
|
|
8857
8894
|
className: "image-settings"
|
|
8858
8895
|
}, /*#__PURE__*/React__namespace.createElement("div", null, "Background image:"), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", {
|
|
8859
8896
|
htmlFor: "bg-url"
|
|
@@ -8866,7 +8903,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8866
8903
|
ref: "bg-url",
|
|
8867
8904
|
value: this.state.backgroundImage.url || "",
|
|
8868
8905
|
onChange: e => {
|
|
8869
|
-
const image = ___default
|
|
8906
|
+
const image = ___default.default.clone(this.props.backgroundImage);
|
|
8870
8907
|
image.url = e.target.value;
|
|
8871
8908
|
this.setState({
|
|
8872
8909
|
backgroundImage: image
|
|
@@ -8874,7 +8911,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8874
8911
|
},
|
|
8875
8912
|
onKeyPress: this.changeBackgroundUrl,
|
|
8876
8913
|
onBlur: this.changeBackgroundUrl
|
|
8877
|
-
}), /*#__PURE__*/React__namespace.createElement(InfoTip$k, null, /*#__PURE__*/React__namespace.createElement("p", null, "Create an image in graphie, or use the \"Add image\" function to create a background.")))), ___default
|
|
8914
|
+
}), /*#__PURE__*/React__namespace.createElement(InfoTip$k, null, /*#__PURE__*/React__namespace.createElement("p", null, "Create an image in graphie, or use the \"Add image\" function to create a background.")))), ___default.default.contains(this.props.editableSettings, "measure") && /*#__PURE__*/React__namespace.createElement("div", {
|
|
8878
8915
|
className: "misc-settings"
|
|
8879
8916
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
8880
8917
|
className: "perseus-widget-row"
|
|
@@ -8910,7 +8947,7 @@ class GraphSettings extends React__namespace.Component {
|
|
|
8910
8947
|
}, this.renderLabelChoices([["inches", "in"], ["feet", "ft"], ["yards", "yd"], ["miles", "mi"]]))))), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", null, " ", "Ruler ticks:", " ", /*#__PURE__*/React__namespace.createElement("select", {
|
|
8911
8948
|
onChange: this.changeRulerTicks,
|
|
8912
8949
|
value: this.props.rulerTicks
|
|
8913
|
-
}, ___default
|
|
8950
|
+
}, ___default.default.map([1, 2, 4, 8, 10, 16], function (n) {
|
|
8914
8951
|
return /*#__PURE__*/React__namespace.createElement("option", {
|
|
8915
8952
|
key: n,
|
|
8916
8953
|
value: n
|
|
@@ -8950,7 +8987,7 @@ class GrapherEditor extends React__namespace.Component {
|
|
|
8950
8987
|
|
|
8951
8988
|
// If the currently 'correct' type is removed from the list of types,
|
|
8952
8989
|
// we need to change it to avoid impossible questions.
|
|
8953
|
-
if (!___default
|
|
8990
|
+
if (!___default.default.contains(newAvailableTypes, this.props.correct.type)) {
|
|
8954
8991
|
const graph = this.props.graph;
|
|
8955
8992
|
const newType = chooseType(newAvailableTypes);
|
|
8956
8993
|
correct = defaultPlotProps(newType, graph);
|
|
@@ -8961,8 +8998,8 @@ class GrapherEditor extends React__namespace.Component {
|
|
|
8961
8998
|
});
|
|
8962
8999
|
};
|
|
8963
9000
|
serialize = () => {
|
|
8964
|
-
return ___default
|
|
8965
|
-
graph: ___default
|
|
9001
|
+
return ___default.default.chain(this.props).pick("correct", "availableTypes").extend({
|
|
9002
|
+
graph: ___default.default.omit(this.props.graph, "box")
|
|
8966
9003
|
}).value();
|
|
8967
9004
|
};
|
|
8968
9005
|
render() {
|
|
@@ -8977,7 +9014,7 @@ class GrapherEditor extends React__namespace.Component {
|
|
|
8977
9014
|
onChange: (newProps, cb) => {
|
|
8978
9015
|
let correct = this.props.correct;
|
|
8979
9016
|
if (correct.type === newProps.plot?.type) {
|
|
8980
|
-
correct = ___default
|
|
9017
|
+
correct = ___default.default.extend({}, correct, newProps.plot);
|
|
8981
9018
|
} else {
|
|
8982
9019
|
// Clear options from previous graph
|
|
8983
9020
|
correct = newProps.plot;
|
|
@@ -8994,7 +9031,7 @@ class GrapherEditor extends React__namespace.Component {
|
|
|
8994
9031
|
// standard props that the Renderer provides normally (eg.
|
|
8995
9032
|
// alignment, findWidgets, etc).
|
|
8996
9033
|
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
8997
|
-
React__namespace.createElement(Grapher, _extends__default
|
|
9034
|
+
React__namespace.createElement(Grapher, _extends__default.default({}, graphProps, {
|
|
8998
9035
|
apiOptions: this.props.apiOptions,
|
|
8999
9036
|
containerSizeClass: sizeClass
|
|
9000
9037
|
}));
|
|
@@ -9026,19 +9063,20 @@ class GrapherEditor extends React__namespace.Component {
|
|
|
9026
9063
|
}, /*#__PURE__*/React__namespace.createElement("label", null, "Available functions: "), /*#__PURE__*/React__namespace.createElement(MultiButtonGroup, {
|
|
9027
9064
|
allowEmpty: false,
|
|
9028
9065
|
values: this.props.availableTypes,
|
|
9029
|
-
buttons: ___default
|
|
9066
|
+
buttons: ___default.default.map(perseusCore.GrapherUtil.allTypes, typeToButton),
|
|
9030
9067
|
onChange: this.handleAvailableTypesChange
|
|
9031
9068
|
})), graph);
|
|
9032
9069
|
}
|
|
9033
9070
|
}
|
|
9034
9071
|
|
|
9035
9072
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
9073
|
+
/* eslint-disable react/forbid-prop-types */
|
|
9036
9074
|
class GroupEditor extends React__namespace.Component {
|
|
9037
9075
|
static propTypes = {
|
|
9038
9076
|
...perseus.Changeable.propTypes,
|
|
9039
|
-
content: PropTypes__default
|
|
9040
|
-
widgets: PropTypes__default
|
|
9041
|
-
images: PropTypes__default
|
|
9077
|
+
content: PropTypes__default.default.string,
|
|
9078
|
+
widgets: PropTypes__default.default.object,
|
|
9079
|
+
images: PropTypes__default.default.object,
|
|
9042
9080
|
apiOptions: perseus.ApiOptions.propTypes
|
|
9043
9081
|
};
|
|
9044
9082
|
static widgetName = "group";
|
|
@@ -9057,7 +9095,7 @@ class GroupEditor extends React__namespace.Component {
|
|
|
9057
9095
|
return this.editor.current?.getSaveWarnings();
|
|
9058
9096
|
};
|
|
9059
9097
|
serialize = () => {
|
|
9060
|
-
return ___default
|
|
9098
|
+
return ___default.default.extend({}, this.editor.current?.serialize());
|
|
9061
9099
|
};
|
|
9062
9100
|
render() {
|
|
9063
9101
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -9082,8 +9120,8 @@ class GroupEditor extends React__namespace.Component {
|
|
|
9082
9120
|
class PairEditor extends React__namespace.Component {
|
|
9083
9121
|
static propTypes = {
|
|
9084
9122
|
...perseus.Changeable.propTypes,
|
|
9085
|
-
name: PropTypes__default
|
|
9086
|
-
value: PropTypes__default
|
|
9123
|
+
name: PropTypes__default.default.string,
|
|
9124
|
+
value: PropTypes__default.default.string
|
|
9087
9125
|
};
|
|
9088
9126
|
static defaultProps = {
|
|
9089
9127
|
name: "",
|
|
@@ -9117,9 +9155,9 @@ class PairEditor extends React__namespace.Component {
|
|
|
9117
9155
|
class PairsEditor extends React__namespace.Component {
|
|
9118
9156
|
static propTypes = {
|
|
9119
9157
|
...perseus.Changeable.propTypes,
|
|
9120
|
-
pairs: PropTypes__default
|
|
9121
|
-
name: PropTypes__default
|
|
9122
|
-
value: PropTypes__default
|
|
9158
|
+
pairs: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
9159
|
+
name: PropTypes__default.default.string,
|
|
9160
|
+
value: PropTypes__default.default.string
|
|
9123
9161
|
})).isRequired
|
|
9124
9162
|
};
|
|
9125
9163
|
change = (() => {
|
|
@@ -9148,7 +9186,7 @@ class PairsEditor extends React__namespace.Component {
|
|
|
9148
9186
|
return perseus.EditorJsonify.serialize.call(this);
|
|
9149
9187
|
};
|
|
9150
9188
|
render() {
|
|
9151
|
-
const editors = ___default
|
|
9189
|
+
const editors = ___default.default.map(this.props.pairs, (pair, i) => {
|
|
9152
9190
|
return /*#__PURE__*/React__namespace.createElement(PairEditor, {
|
|
9153
9191
|
key: i,
|
|
9154
9192
|
name: pair.name,
|
|
@@ -9326,7 +9364,7 @@ class ImageEditor extends React__namespace.Component {
|
|
|
9326
9364
|
}
|
|
9327
9365
|
onCoordinateChange(labelIndex, newCoordinates) {
|
|
9328
9366
|
const labels = this.props.labels.slice();
|
|
9329
|
-
labels[labelIndex] = ___default
|
|
9367
|
+
labels[labelIndex] = ___default.default.extend({}, labels[labelIndex], {
|
|
9330
9368
|
coordinates: newCoordinates
|
|
9331
9369
|
});
|
|
9332
9370
|
this.props.onChange({
|
|
@@ -9336,7 +9374,7 @@ class ImageEditor extends React__namespace.Component {
|
|
|
9336
9374
|
onContentChange(labelIndex, e) {
|
|
9337
9375
|
const newContent = e.target.value;
|
|
9338
9376
|
const labels = this.props.labels.slice();
|
|
9339
|
-
labels[labelIndex] = ___default
|
|
9377
|
+
labels[labelIndex] = ___default.default.extend({}, labels[labelIndex], {
|
|
9340
9378
|
content: newContent
|
|
9341
9379
|
});
|
|
9342
9380
|
this.props.onChange({
|
|
@@ -9346,7 +9384,7 @@ class ImageEditor extends React__namespace.Component {
|
|
|
9346
9384
|
onAlignmentChange(labelIndex, e) {
|
|
9347
9385
|
const newAlignment = e.target.value;
|
|
9348
9386
|
const labels = this.props.labels.slice();
|
|
9349
|
-
labels[labelIndex] = ___default
|
|
9387
|
+
labels[labelIndex] = ___default.default.extend({}, labels[labelIndex], {
|
|
9350
9388
|
alignment: newAlignment
|
|
9351
9389
|
});
|
|
9352
9390
|
this.props.onChange({
|
|
@@ -9362,7 +9400,7 @@ class ImageEditor extends React__namespace.Component {
|
|
|
9362
9400
|
if (!this._isMounted) {
|
|
9363
9401
|
return;
|
|
9364
9402
|
}
|
|
9365
|
-
const image = ___default
|
|
9403
|
+
const image = ___default.default.clone(this.props.backgroundImage);
|
|
9366
9404
|
image.url = url;
|
|
9367
9405
|
image.width = width;
|
|
9368
9406
|
image.height = height;
|
|
@@ -9486,7 +9524,7 @@ class InputNumberEditor extends React__namespace.Component {
|
|
|
9486
9524
|
rightAlign: this.props.rightAlign
|
|
9487
9525
|
});
|
|
9488
9526
|
render() {
|
|
9489
|
-
const answerTypeOptions = ___default
|
|
9527
|
+
const answerTypeOptions = ___default.default.map(perseusScore.inputNumberAnswerTypes, function (v, k) {
|
|
9490
9528
|
return /*#__PURE__*/React__namespace.createElement("option", {
|
|
9491
9529
|
value: k,
|
|
9492
9530
|
key: k
|
|
@@ -9571,6 +9609,7 @@ class InputNumberEditor extends React__namespace.Component {
|
|
|
9571
9609
|
}
|
|
9572
9610
|
|
|
9573
9611
|
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
9612
|
+
|
|
9574
9613
|
const {
|
|
9575
9614
|
InlineIcon: InlineIcon$1
|
|
9576
9615
|
} = perseus.components;
|
|
@@ -9627,7 +9666,7 @@ class ColorPicker extends React__namespace.Component {
|
|
|
9627
9666
|
return /*#__PURE__*/React__namespace.createElement(ButtonGroup$5, {
|
|
9628
9667
|
value: this.props.value,
|
|
9629
9668
|
allowEmpty: false,
|
|
9630
|
-
buttons: ___default
|
|
9669
|
+
buttons: ___default.default.map(colors, color => {
|
|
9631
9670
|
return {
|
|
9632
9671
|
value: color,
|
|
9633
9672
|
content: /*#__PURE__*/React__namespace.createElement("span", null, /*#__PURE__*/React__namespace.createElement("span", {
|
|
@@ -10389,16 +10428,16 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10389
10428
|
});
|
|
10390
10429
|
}
|
|
10391
10430
|
_getAllVarSubscripts(elements) {
|
|
10392
|
-
return ___default
|
|
10431
|
+
return ___default.default.map(___default.default.where(elements, {
|
|
10393
10432
|
type: "movable-point"
|
|
10394
|
-
}), element => element.options.varSubscript).concat(___default
|
|
10433
|
+
}), element => element.options.varSubscript).concat(___default.default.map(___default.default.where(elements, {
|
|
10395
10434
|
type: "movable-line"
|
|
10396
|
-
}), element => element.options.startSubscript)).concat(___default
|
|
10435
|
+
}), element => element.options.startSubscript)).concat(___default.default.map(___default.default.where(elements, {
|
|
10397
10436
|
type: "movable-line"
|
|
10398
10437
|
}), element => element.options.endSubscript));
|
|
10399
10438
|
}
|
|
10400
10439
|
_getAllFunctionNames(elements) {
|
|
10401
|
-
return ___default
|
|
10440
|
+
return ___default.default.map(___default.default.where(elements, {
|
|
10402
10441
|
type: "function"
|
|
10403
10442
|
}), element => element.options.funcName);
|
|
10404
10443
|
}
|
|
@@ -10407,7 +10446,7 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10407
10446
|
// of step. Grr..
|
|
10408
10447
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
10409
10448
|
this.change({
|
|
10410
|
-
graph: ___default
|
|
10449
|
+
graph: ___default.default.extend(___default.default.omit(newProps, "step"), {
|
|
10411
10450
|
tickStep: newProps.step
|
|
10412
10451
|
})
|
|
10413
10452
|
});
|
|
@@ -10421,15 +10460,15 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10421
10460
|
const newElement = {
|
|
10422
10461
|
type: elementType,
|
|
10423
10462
|
key: elementType + "-" + (Math.random() * 0xffffff << 0).toString(16),
|
|
10424
|
-
options: elementType === "point" ? ___default
|
|
10463
|
+
options: elementType === "point" ? ___default.default.clone(PointEditor.defaultProps) : elementType === "line" ? ___default.default.clone(LineEditor.defaultProps) : elementType === "movable-point" ? ___default.default.clone(MovablePointEditor.defaultProps) : elementType === "movable-line" ? ___default.default.clone(MovableLineEditor.defaultProps) : elementType === "function" ? ___default.default.clone(FunctionEditor.defaultProps) : elementType === "parametric" ? ___default.default.clone(ParametricEditor.defaultProps) : elementType === "label" ? ___default.default.clone(LabelEditor.defaultProps) : elementType === "rectangle" ? ___default.default.clone(RectangleEditor.defaultProps) : {}
|
|
10425
10464
|
};
|
|
10426
10465
|
let nextSubscript;
|
|
10427
10466
|
if (elementType === "movable-point") {
|
|
10428
|
-
nextSubscript = ___default
|
|
10467
|
+
nextSubscript = ___default.default.max([___default.default.max(this.state.usedVarSubscripts), -1]) + 1;
|
|
10429
10468
|
// @ts-expect-error - TS2339 - Property 'varSubscript' does not exist on type '{}'.
|
|
10430
10469
|
newElement.options.varSubscript = nextSubscript;
|
|
10431
10470
|
} else if (elementType === "movable-line") {
|
|
10432
|
-
nextSubscript = ___default
|
|
10471
|
+
nextSubscript = ___default.default.max([___default.default.max(this.state.usedVarSubscripts), -1]) + 1;
|
|
10433
10472
|
// @ts-expect-error - TS2339 - Property 'startSubscript' does not exist on type '{}'.
|
|
10434
10473
|
newElement.options.startSubscript = nextSubscript;
|
|
10435
10474
|
// @ts-expect-error - TS2339 - Property 'endSubscript' does not exist on type '{}'.
|
|
@@ -10437,7 +10476,7 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10437
10476
|
} else if (elementType === "function") {
|
|
10438
10477
|
// TODO(eater): The 22nd function added will be {(x) since '{'
|
|
10439
10478
|
// comes after 'z'
|
|
10440
|
-
const nextLetter = String.fromCharCode(___default
|
|
10479
|
+
const nextLetter = String.fromCharCode(___default.default.max([___default.default.max(___default.default.map(this.state.usedFunctionNames, function (c) {
|
|
10441
10480
|
return c.charCodeAt(0);
|
|
10442
10481
|
})), "e".charCodeAt(0)]) + 1);
|
|
10443
10482
|
// @ts-expect-error - TS2339 - Property 'funcName' does not exist on type '{}'.
|
|
@@ -10452,12 +10491,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10452
10491
|
const element = this.props.elements[index];
|
|
10453
10492
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
10454
10493
|
this.change({
|
|
10455
|
-
elements: ___default
|
|
10494
|
+
elements: ___default.default.without(this.props.elements, element)
|
|
10456
10495
|
});
|
|
10457
10496
|
};
|
|
10458
10497
|
_moveElementUp = index => {
|
|
10459
10498
|
const element = this.props.elements[index];
|
|
10460
|
-
const newElements = ___default
|
|
10499
|
+
const newElements = ___default.default.without(this.props.elements, element);
|
|
10461
10500
|
newElements.splice(index - 1, 0, element);
|
|
10462
10501
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
10463
10502
|
this.change({
|
|
@@ -10466,7 +10505,7 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10466
10505
|
};
|
|
10467
10506
|
_moveElementDown = index => {
|
|
10468
10507
|
const element = this.props.elements[index];
|
|
10469
|
-
const newElements = ___default
|
|
10508
|
+
const newElements = ___default.default.without(this.props.elements, element);
|
|
10470
10509
|
newElements.splice(index + 1, 0, element);
|
|
10471
10510
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
|
|
10472
10511
|
this.change({
|
|
@@ -10502,7 +10541,7 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10502
10541
|
gridStep: this.props.graph.gridStep,
|
|
10503
10542
|
markings: this.props.graph.markings,
|
|
10504
10543
|
onChange: this._updateGraphProps
|
|
10505
|
-
}), /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, this.props.graph.valid !== true && /*#__PURE__*/React__namespace.createElement("div", null, this.props.graph.valid))), ___default
|
|
10544
|
+
}), /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, this.props.graph.valid !== true && /*#__PURE__*/React__namespace.createElement("div", null, this.props.graph.valid))), ___default.default.map(this.props.elements, function (element, n) {
|
|
10506
10545
|
if (element.type === "movable-point") {
|
|
10507
10546
|
return /*#__PURE__*/React__namespace.createElement(ElementContainer, {
|
|
10508
10547
|
title: /*#__PURE__*/React__namespace.createElement("span", null, "Movable point", " ", /*#__PURE__*/React__namespace.createElement(TeX, null, "(x_{" + element.options.varSubscript + "}, y_{" + element.options.varSubscript + "})"))
|
|
@@ -10525,12 +10564,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10525
10564
|
,
|
|
10526
10565
|
onDelete: this._deleteElement.bind(this, n),
|
|
10527
10566
|
key: element.key
|
|
10528
|
-
}, /*#__PURE__*/React__namespace.createElement(MovablePointEditor, _extends__default
|
|
10567
|
+
}, /*#__PURE__*/React__namespace.createElement(MovablePointEditor, _extends__default.default({}, element.options, {
|
|
10529
10568
|
onChange: newProps => {
|
|
10530
10569
|
const elements = JSON.parse(JSON.stringify(
|
|
10531
10570
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10532
10571
|
this.props.elements));
|
|
10533
|
-
___default
|
|
10572
|
+
___default.default.extend(elements[n].options, newProps);
|
|
10534
10573
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10535
10574
|
this.change({
|
|
10536
10575
|
elements: elements
|
|
@@ -10560,12 +10599,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10560
10599
|
,
|
|
10561
10600
|
onDelete: this._deleteElement.bind(this, n),
|
|
10562
10601
|
key: element.key
|
|
10563
|
-
}, /*#__PURE__*/React__namespace.createElement(MovableLineEditor, _extends__default
|
|
10602
|
+
}, /*#__PURE__*/React__namespace.createElement(MovableLineEditor, _extends__default.default({}, element.options, {
|
|
10564
10603
|
onChange: newProps => {
|
|
10565
10604
|
const elements = JSON.parse(JSON.stringify(
|
|
10566
10605
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10567
10606
|
this.props.elements));
|
|
10568
|
-
___default
|
|
10607
|
+
___default.default.extend(elements[n].options, newProps);
|
|
10569
10608
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10570
10609
|
this.change({
|
|
10571
10610
|
elements: elements
|
|
@@ -10595,12 +10634,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10595
10634
|
,
|
|
10596
10635
|
onDelete: this._deleteElement.bind(this, n),
|
|
10597
10636
|
key: element.key
|
|
10598
|
-
}, /*#__PURE__*/React__namespace.createElement(PointEditor, _extends__default
|
|
10637
|
+
}, /*#__PURE__*/React__namespace.createElement(PointEditor, _extends__default.default({}, element.options, {
|
|
10599
10638
|
onChange: newProps => {
|
|
10600
10639
|
const elements = JSON.parse(JSON.stringify(
|
|
10601
10640
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10602
10641
|
this.props.elements));
|
|
10603
|
-
___default
|
|
10642
|
+
___default.default.extend(elements[n].options, newProps);
|
|
10604
10643
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10605
10644
|
this.change({
|
|
10606
10645
|
elements: elements
|
|
@@ -10630,12 +10669,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10630
10669
|
,
|
|
10631
10670
|
onDelete: this._deleteElement.bind(this, n),
|
|
10632
10671
|
key: element.key
|
|
10633
|
-
}, /*#__PURE__*/React__namespace.createElement(LineEditor, _extends__default
|
|
10672
|
+
}, /*#__PURE__*/React__namespace.createElement(LineEditor, _extends__default.default({}, element.options, {
|
|
10634
10673
|
onChange: newProps => {
|
|
10635
10674
|
const elements = JSON.parse(JSON.stringify(
|
|
10636
10675
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10637
10676
|
this.props.elements));
|
|
10638
|
-
___default
|
|
10677
|
+
___default.default.extend(elements[n].options, newProps);
|
|
10639
10678
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10640
10679
|
this.change({
|
|
10641
10680
|
elements: elements
|
|
@@ -10664,12 +10703,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10664
10703
|
,
|
|
10665
10704
|
onDelete: this._deleteElement,
|
|
10666
10705
|
key: element.key
|
|
10667
|
-
}, /*#__PURE__*/React__namespace.createElement(FunctionEditor, _extends__default
|
|
10706
|
+
}, /*#__PURE__*/React__namespace.createElement(FunctionEditor, _extends__default.default({}, element.options, {
|
|
10668
10707
|
onChange: newProps => {
|
|
10669
10708
|
const elements = JSON.parse(JSON.stringify(
|
|
10670
10709
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10671
10710
|
this.props.elements));
|
|
10672
|
-
___default
|
|
10711
|
+
___default.default.extend(elements[n].options, newProps);
|
|
10673
10712
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10674
10713
|
this.change({
|
|
10675
10714
|
elements: elements
|
|
@@ -10698,12 +10737,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10698
10737
|
,
|
|
10699
10738
|
onDelete: this._deleteElement,
|
|
10700
10739
|
key: element.key
|
|
10701
|
-
}, /*#__PURE__*/React__namespace.createElement(ParametricEditor, _extends__default
|
|
10740
|
+
}, /*#__PURE__*/React__namespace.createElement(ParametricEditor, _extends__default.default({}, element.options, {
|
|
10702
10741
|
onChange: newProps => {
|
|
10703
10742
|
const elements = JSON.parse(JSON.stringify(
|
|
10704
10743
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10705
10744
|
this.props.elements));
|
|
10706
|
-
___default
|
|
10745
|
+
___default.default.extend(elements[n].options, newProps);
|
|
10707
10746
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10708
10747
|
this.change({
|
|
10709
10748
|
elements: elements
|
|
@@ -10732,12 +10771,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10732
10771
|
,
|
|
10733
10772
|
onDelete: this._deleteElement,
|
|
10734
10773
|
key: element.key
|
|
10735
|
-
}, /*#__PURE__*/React__namespace.createElement(LabelEditor, _extends__default
|
|
10774
|
+
}, /*#__PURE__*/React__namespace.createElement(LabelEditor, _extends__default.default({}, element.options, {
|
|
10736
10775
|
onChange: newProps => {
|
|
10737
10776
|
const elements = JSON.parse(JSON.stringify(
|
|
10738
10777
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10739
10778
|
this.props.elements));
|
|
10740
|
-
___default
|
|
10779
|
+
___default.default.extend(elements[n].options, newProps);
|
|
10741
10780
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10742
10781
|
this.change({
|
|
10743
10782
|
elements: elements
|
|
@@ -10766,12 +10805,12 @@ class InteractionEditor extends React__namespace.Component {
|
|
|
10766
10805
|
,
|
|
10767
10806
|
onDelete: this._deleteElement,
|
|
10768
10807
|
key: element.key
|
|
10769
|
-
}, /*#__PURE__*/React__namespace.createElement(RectangleEditor, _extends__default
|
|
10808
|
+
}, /*#__PURE__*/React__namespace.createElement(RectangleEditor, _extends__default.default({}, element.options, {
|
|
10770
10809
|
onChange: newProps => {
|
|
10771
10810
|
const elements = JSON.parse(JSON.stringify(
|
|
10772
10811
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10773
10812
|
this.props.elements));
|
|
10774
|
-
___default
|
|
10813
|
+
___default.default.extend(elements[n].options, newProps);
|
|
10775
10814
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
10776
10815
|
this.change({
|
|
10777
10816
|
elements: elements
|
|
@@ -10922,7 +10961,7 @@ function Heading(_ref) {
|
|
|
10922
10961
|
isCollapsible,
|
|
10923
10962
|
onToggle
|
|
10924
10963
|
} = _ref;
|
|
10925
|
-
return /*#__PURE__*/React__namespace.createElement(Clickable__default
|
|
10964
|
+
return /*#__PURE__*/React__namespace.createElement(Clickable__default.default, {
|
|
10926
10965
|
style: [styles$I.container, !isCollapsible && styles$I.notClickable],
|
|
10927
10966
|
disabled: !isCollapsible,
|
|
10928
10967
|
onClick: () => isCollapsible && onToggle?.(!isOpen)
|
|
@@ -11077,6 +11116,9 @@ const styles$G = aphrodite.StyleSheet.create({
|
|
|
11077
11116
|
});
|
|
11078
11117
|
|
|
11079
11118
|
/* eslint-disable react/forbid-prop-types, react/no-unsafe */
|
|
11119
|
+
/**
|
|
11120
|
+
* Used in the editor for the InteractiveGraph widget.
|
|
11121
|
+
*/
|
|
11080
11122
|
const {
|
|
11081
11123
|
ButtonGroup: ButtonGroup$1,
|
|
11082
11124
|
InfoTip: InfoTip$g,
|
|
@@ -11134,10 +11176,10 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
11134
11176
|
// TODO(scottgrant): This is a hack to remove the deprecated call to
|
|
11135
11177
|
// this.isMounted() but is still considered an anti-pattern.
|
|
11136
11178
|
this._isMounted = true;
|
|
11137
|
-
this.changeGraph = ___default
|
|
11179
|
+
this.changeGraph = ___default.default.debounce(this.changeGraph, 300);
|
|
11138
11180
|
}
|
|
11139
11181
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
11140
|
-
if (!___default
|
|
11182
|
+
if (!___default.default.isEqual(this.props.labels, nextProps.labels) || !___default.default.isEqual(this.props.labelLocation, nextProps.labelLocation) || !___default.default.isEqual(this.props.gridStep, nextProps.gridStep) || !___default.default.isEqual(this.props.snapStep, nextProps.snapStep) || !___default.default.isEqual(this.props.step, nextProps.step) || !___default.default.isEqual(this.props.range, nextProps.range) || !___default.default.isEqual(this.props.backgroundImage, nextProps.backgroundImage)) {
|
|
11141
11183
|
this.setState(InteractiveGraphSettings.stateFromProps(nextProps));
|
|
11142
11184
|
}
|
|
11143
11185
|
}
|
|
@@ -11188,8 +11230,8 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
11188
11230
|
}, nameAndValue[0]));
|
|
11189
11231
|
};
|
|
11190
11232
|
validRange = range => {
|
|
11191
|
-
const numbers = ___default
|
|
11192
|
-
return ___default
|
|
11233
|
+
const numbers = ___default.default.every(range, function (num) {
|
|
11234
|
+
return ___default.default.isFinite(num);
|
|
11193
11235
|
});
|
|
11194
11236
|
if (!numbers) {
|
|
11195
11237
|
return "Range must be a valid number";
|
|
@@ -11257,28 +11299,28 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
11257
11299
|
validateGraphSettings = (range, step, gridStep, snapStep, image) => {
|
|
11258
11300
|
const self = this;
|
|
11259
11301
|
let msg;
|
|
11260
|
-
const goodRange = ___default
|
|
11302
|
+
const goodRange = ___default.default.every(range, function (range) {
|
|
11261
11303
|
msg = self.validRange(range);
|
|
11262
11304
|
return msg === true;
|
|
11263
11305
|
});
|
|
11264
11306
|
if (!goodRange) {
|
|
11265
11307
|
return msg;
|
|
11266
11308
|
}
|
|
11267
|
-
const goodStep = ___default
|
|
11309
|
+
const goodStep = ___default.default.every(step, function (step, i) {
|
|
11268
11310
|
msg = self.validStep(step, range[i]);
|
|
11269
11311
|
return msg === true;
|
|
11270
11312
|
});
|
|
11271
11313
|
if (!goodStep) {
|
|
11272
11314
|
return msg;
|
|
11273
11315
|
}
|
|
11274
|
-
const goodGridStep = ___default
|
|
11316
|
+
const goodGridStep = ___default.default.every(gridStep, function (gridStep, i) {
|
|
11275
11317
|
msg = self.validGridStep(gridStep, range[i]);
|
|
11276
11318
|
return msg === true;
|
|
11277
11319
|
});
|
|
11278
11320
|
if (!goodGridStep) {
|
|
11279
11321
|
return msg;
|
|
11280
11322
|
}
|
|
11281
|
-
const goodSnapStep = ___default
|
|
11323
|
+
const goodSnapStep = ___default.default.every(snapStep, function (snapStep, i) {
|
|
11282
11324
|
msg = self.validSnapStep(snapStep, range[i]);
|
|
11283
11325
|
return msg === true;
|
|
11284
11326
|
});
|
|
@@ -11335,7 +11377,7 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
11335
11377
|
changeGridStep = gridStep => {
|
|
11336
11378
|
this.setState({
|
|
11337
11379
|
gridStepTextbox: gridStep,
|
|
11338
|
-
snapStepTextbox: ___default
|
|
11380
|
+
snapStepTextbox: ___default.default.map(gridStep, function (step) {
|
|
11339
11381
|
return step / 2;
|
|
11340
11382
|
})
|
|
11341
11383
|
}, this.changeGraph);
|
|
@@ -11343,10 +11385,10 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
11343
11385
|
changeGraph = () => {
|
|
11344
11386
|
const labels = this.state.labelsTextbox;
|
|
11345
11387
|
const labelLocation = this.state.labelLocation;
|
|
11346
|
-
const range = ___default
|
|
11347
|
-
return ___default
|
|
11388
|
+
const range = ___default.default.map(this.state.rangeTextbox, function (range) {
|
|
11389
|
+
return ___default.default.map(range, Number);
|
|
11348
11390
|
});
|
|
11349
|
-
const step = ___default
|
|
11391
|
+
const step = ___default.default.map(this.state.stepTextbox, Number);
|
|
11350
11392
|
const gridStep = this.state.gridStepTextbox;
|
|
11351
11393
|
const snapStep = this.state.snapStepTextbox;
|
|
11352
11394
|
const image = this.state.backgroundImage;
|
|
@@ -11532,7 +11574,7 @@ class InteractiveGraphSettings extends React__namespace.Component {
|
|
|
11532
11574
|
});
|
|
11533
11575
|
},
|
|
11534
11576
|
style: styles$F.resetSpaceTop
|
|
11535
|
-
})), this.props.showProtractor && /*#__PURE__*/React__namespace.createElement(Banner__default
|
|
11577
|
+
})), this.props.showProtractor && /*#__PURE__*/React__namespace.createElement(Banner__default.default, {
|
|
11536
11578
|
layout: "floating",
|
|
11537
11579
|
text: "The protractor is not accessible. Please consider an alternate approach.",
|
|
11538
11580
|
kind: "warning"
|
|
@@ -11638,7 +11680,7 @@ function SRTree(props) {
|
|
|
11638
11680
|
}
|
|
11639
11681
|
}, elementArias.map((aria, index) => /*#__PURE__*/React__namespace.createElement("li", {
|
|
11640
11682
|
key: index
|
|
11641
|
-
}, showTags && /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
11683
|
+
}, showTags && /*#__PURE__*/React__namespace.createElement(Pill__default.default, {
|
|
11642
11684
|
size: "small",
|
|
11643
11685
|
kind: "success",
|
|
11644
11686
|
style: styles$E.smallSpaceRight
|
|
@@ -11646,7 +11688,7 @@ function SRTree(props) {
|
|
|
11646
11688
|
style: styles$E.indentListLeft
|
|
11647
11689
|
}, aria.attributes.map((value, index) => /*#__PURE__*/React__namespace.createElement("li", {
|
|
11648
11690
|
key: index
|
|
11649
|
-
}, /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
11691
|
+
}, /*#__PURE__*/React__namespace.createElement(Pill__default.default, {
|
|
11650
11692
|
size: "small",
|
|
11651
11693
|
kind: value.name === "label" ? "info" : "neutral",
|
|
11652
11694
|
style: styles$E.smallSpaceRight
|
|
@@ -11681,7 +11723,7 @@ function InteractiveGraphSRTree(_ref) {
|
|
|
11681
11723
|
isCollapsible: true
|
|
11682
11724
|
}), isExpanded && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
11683
11725
|
style: [styles$E.row, styles$E.tagSwitch]
|
|
11684
|
-
}, /*#__PURE__*/React__namespace.createElement(Switch__default
|
|
11726
|
+
}, /*#__PURE__*/React__namespace.createElement(Switch__default.default, {
|
|
11685
11727
|
id: switchId,
|
|
11686
11728
|
checked: showTags,
|
|
11687
11729
|
onChange: setShowTags
|
|
@@ -11729,7 +11771,7 @@ const SegmentCountSelector = _ref => {
|
|
|
11729
11771
|
onChange(num);
|
|
11730
11772
|
},
|
|
11731
11773
|
style: styles$D.singleSelectShort
|
|
11732
|
-
}, ___default
|
|
11774
|
+
}, ___default.default.range(1, 7).map(n => /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.OptionItem, {
|
|
11733
11775
|
key: n,
|
|
11734
11776
|
value: `${n}`,
|
|
11735
11777
|
label: `${n} segment${n > 1 ? "s" : ""}`
|
|
@@ -11822,7 +11864,7 @@ const ScrolllessNumberTextField = props => {
|
|
|
11822
11864
|
ref?.removeEventListener("wheel", ignoreScroll);
|
|
11823
11865
|
};
|
|
11824
11866
|
}, [inputRef]);
|
|
11825
|
-
return /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.TextField, _extends__default
|
|
11867
|
+
return /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.TextField, _extends__default.default({}, restOfProps, {
|
|
11826
11868
|
type: "number",
|
|
11827
11869
|
value: focused ? wipValue : value,
|
|
11828
11870
|
onChange: newValue => {
|
|
@@ -12191,9 +12233,9 @@ function LockedFigureAria(props) {
|
|
|
12191
12233
|
placeholder: "Ex. Point at (x, y)",
|
|
12192
12234
|
rows: 1,
|
|
12193
12235
|
resizeType: "vertical"
|
|
12194
|
-
}), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
12236
|
+
}), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
12195
12237
|
kind: "tertiary",
|
|
12196
|
-
startIcon: pencilCircle__default
|
|
12238
|
+
startIcon: pencilCircle__default.default,
|
|
12197
12239
|
style: styles$u.button,
|
|
12198
12240
|
onClick: () => {
|
|
12199
12241
|
setLoading(true);
|
|
@@ -12232,32 +12274,32 @@ const LockedFigureSettingsActions = props => {
|
|
|
12232
12274
|
} = props;
|
|
12233
12275
|
return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
12234
12276
|
style: styles$t.container
|
|
12235
|
-
}, /*#__PURE__*/React__namespace.createElement(Button__default
|
|
12236
|
-
startIcon: trashIcon__default
|
|
12277
|
+
}, /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
12278
|
+
startIcon: trashIcon__default.default,
|
|
12237
12279
|
"aria-label": `Delete locked ${figureType}`,
|
|
12238
12280
|
onClick: onRemove,
|
|
12239
12281
|
kind: "tertiary",
|
|
12240
12282
|
style: styles$t.deleteButton
|
|
12241
|
-
}, "Delete"), onMove && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Spring, null), /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
12242
|
-
icon: caretDoubleUpIcon__default
|
|
12283
|
+
}, "Delete"), onMove && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Spring, null), /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
12284
|
+
icon: caretDoubleUpIcon__default.default,
|
|
12243
12285
|
size: "small",
|
|
12244
12286
|
"aria-label": `Move locked ${figureType} to the back`,
|
|
12245
12287
|
onClick: () => onMove("back"),
|
|
12246
12288
|
style: styles$t.iconButton
|
|
12247
|
-
}), /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
12248
|
-
icon: caretUpIcon__default
|
|
12289
|
+
}), /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
12290
|
+
icon: caretUpIcon__default.default,
|
|
12249
12291
|
size: "small",
|
|
12250
12292
|
"aria-label": `Move locked ${figureType} backward`,
|
|
12251
12293
|
onClick: () => onMove("backward"),
|
|
12252
12294
|
style: styles$t.iconButton
|
|
12253
|
-
}), /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
12254
|
-
icon: caretDownIcon__default
|
|
12295
|
+
}), /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
12296
|
+
icon: caretDownIcon__default.default,
|
|
12255
12297
|
size: "small",
|
|
12256
12298
|
"aria-label": `Move locked ${figureType} forward`,
|
|
12257
12299
|
onClick: () => onMove("forward"),
|
|
12258
12300
|
style: styles$t.iconButton
|
|
12259
|
-
}), /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
12260
|
-
icon: caretDoubleDownIcon__default
|
|
12301
|
+
}), /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
12302
|
+
icon: caretDoubleDownIcon__default.default,
|
|
12261
12303
|
size: "small",
|
|
12262
12304
|
"aria-label": `Move locked ${figureType} to the front`,
|
|
12263
12305
|
onClick: () => onMove("front"),
|
|
@@ -12729,7 +12771,7 @@ const LockedEllipseSettings = props => {
|
|
|
12729
12771
|
style: styles$r.horizontalRule
|
|
12730
12772
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
12731
12773
|
size: wonderBlocksTokens.spacing.small_12
|
|
12732
|
-
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default
|
|
12774
|
+
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default.default({}, label, {
|
|
12733
12775
|
key: labelIndex,
|
|
12734
12776
|
expanded: true,
|
|
12735
12777
|
onChangeProps: newLabel => {
|
|
@@ -12739,9 +12781,9 @@ const LockedEllipseSettings = props => {
|
|
|
12739
12781
|
handleLabelRemove(labelIndex);
|
|
12740
12782
|
},
|
|
12741
12783
|
containerStyle: styles$r.labelContainer
|
|
12742
|
-
}))), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
12784
|
+
}))), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
12743
12785
|
kind: "tertiary",
|
|
12744
|
-
startIcon: plusCircle__default
|
|
12786
|
+
startIcon: plusCircle__default.default,
|
|
12745
12787
|
onClick: () => {
|
|
12746
12788
|
const newLabel = {
|
|
12747
12789
|
...getDefaultFigureForType("label"),
|
|
@@ -13053,7 +13095,7 @@ const LockedFunctionSettings = props => {
|
|
|
13053
13095
|
style: styles$p.horizontalRule
|
|
13054
13096
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
13055
13097
|
size: wonderBlocksTokens.spacing.small_12
|
|
13056
|
-
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels.map((label, labelIndex, allLabels) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default
|
|
13098
|
+
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels.map((label, labelIndex, allLabels) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default.default({
|
|
13057
13099
|
key: labelIndex
|
|
13058
13100
|
}, label, {
|
|
13059
13101
|
expanded: true,
|
|
@@ -13064,9 +13106,9 @@ const LockedFunctionSettings = props => {
|
|
|
13064
13106
|
handleLabelRemove(labelIndex);
|
|
13065
13107
|
},
|
|
13066
13108
|
containerStyle: styles$p.labelContainer
|
|
13067
|
-
}))), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
13109
|
+
}))), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
13068
13110
|
kind: "tertiary",
|
|
13069
|
-
startIcon: plusCircle__default
|
|
13111
|
+
startIcon: plusCircle__default.default,
|
|
13070
13112
|
onClick: () => {
|
|
13071
13113
|
const newLabel = {
|
|
13072
13114
|
...getDefaultFigureForType("label"),
|
|
@@ -13098,15 +13140,15 @@ const ExampleItem = props => {
|
|
|
13098
13140
|
return /*#__PURE__*/React__namespace.createElement("li", {
|
|
13099
13141
|
key: `${category}-${index}`,
|
|
13100
13142
|
className: aphrodite.css(styles$p.exampleRow)
|
|
13101
|
-
}, /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
13102
|
-
icon: autoPasteIcon__default
|
|
13143
|
+
}, /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
13144
|
+
icon: autoPasteIcon__default.default,
|
|
13103
13145
|
"aria-label": "paste example",
|
|
13104
13146
|
"aria-describedby": exampleId,
|
|
13105
13147
|
onClick: () => pasteEquationFn("equation", example),
|
|
13106
13148
|
size: "medium",
|
|
13107
13149
|
style: styles$p.copyPasteButton
|
|
13108
|
-
}), /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
13109
|
-
icon: copyIcon__default
|
|
13150
|
+
}), /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
13151
|
+
icon: copyIcon__default.default,
|
|
13110
13152
|
"aria-label": "copy example",
|
|
13111
13153
|
"aria-describedby": exampleId,
|
|
13112
13154
|
onClick: () => navigator.clipboard.writeText(example),
|
|
@@ -13231,7 +13273,7 @@ const LabeledSwitch = props => {
|
|
|
13231
13273
|
const switchId = React.useId();
|
|
13232
13274
|
return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
13233
13275
|
style: [styles$o.row, style]
|
|
13234
|
-
}, /*#__PURE__*/React__namespace.createElement(Switch__default
|
|
13276
|
+
}, /*#__PURE__*/React__namespace.createElement(Switch__default.default, {
|
|
13235
13277
|
id: switchId,
|
|
13236
13278
|
checked: checked,
|
|
13237
13279
|
onChange: onChange
|
|
@@ -13395,7 +13437,7 @@ const LockedPointSettings = props => {
|
|
|
13395
13437
|
style: styles$n.horizontalRule
|
|
13396
13438
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
13397
13439
|
size: wonderBlocksTokens.spacing.small_12
|
|
13398
|
-
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default
|
|
13440
|
+
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default.default({}, label, {
|
|
13399
13441
|
key: labelIndex,
|
|
13400
13442
|
containerStyle: !isDefiningPoint && styles$n.lockedPointLabelContainer,
|
|
13401
13443
|
expanded: true,
|
|
@@ -13405,9 +13447,9 @@ const LockedPointSettings = props => {
|
|
|
13405
13447
|
onRemove: () => {
|
|
13406
13448
|
handleLabelRemove(labelIndex);
|
|
13407
13449
|
}
|
|
13408
|
-
}))), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
13450
|
+
}))), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
13409
13451
|
kind: "tertiary",
|
|
13410
|
-
startIcon: plusCircle__default
|
|
13452
|
+
startIcon: plusCircle__default.default,
|
|
13411
13453
|
onClick: () => {
|
|
13412
13454
|
const newLabel = {
|
|
13413
13455
|
...getDefaultFigureForType("label"),
|
|
@@ -13624,7 +13666,7 @@ const LockedLineSettings = props => {
|
|
|
13624
13666
|
})
|
|
13625
13667
|
})), isInvalid && /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
|
|
13626
13668
|
style: styles$m.errorText
|
|
13627
|
-
}, lengthZeroStr), /*#__PURE__*/React__namespace.createElement(LockedPointSettings, _extends__default
|
|
13669
|
+
}, lengthZeroStr), /*#__PURE__*/React__namespace.createElement(LockedPointSettings, _extends__default.default({
|
|
13628
13670
|
headerLabel: "Point 1",
|
|
13629
13671
|
expanded: true,
|
|
13630
13672
|
showPoint: showPoint1,
|
|
@@ -13634,7 +13676,7 @@ const LockedLineSettings = props => {
|
|
|
13634
13676
|
showPoint1: newValue
|
|
13635
13677
|
}),
|
|
13636
13678
|
onChangeProps: newProps => handleChangePoint(newProps, 0)
|
|
13637
|
-
})), /*#__PURE__*/React__namespace.createElement(LockedPointSettings, _extends__default
|
|
13679
|
+
})), /*#__PURE__*/React__namespace.createElement(LockedPointSettings, _extends__default.default({
|
|
13638
13680
|
headerLabel: "Point 2",
|
|
13639
13681
|
expanded: true,
|
|
13640
13682
|
showPoint: showPoint2,
|
|
@@ -13660,7 +13702,7 @@ const LockedLineSettings = props => {
|
|
|
13660
13702
|
style: styles$m.horizontalRule
|
|
13661
13703
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
13662
13704
|
size: wonderBlocksTokens.spacing.small_12
|
|
13663
|
-
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default
|
|
13705
|
+
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default.default({}, label, {
|
|
13664
13706
|
key: labelIndex,
|
|
13665
13707
|
expanded: true,
|
|
13666
13708
|
onChangeProps: newLabel => {
|
|
@@ -13670,9 +13712,9 @@ const LockedLineSettings = props => {
|
|
|
13670
13712
|
handleLabelRemove(labelIndex);
|
|
13671
13713
|
},
|
|
13672
13714
|
containerStyle: styles$m.labelContainer
|
|
13673
|
-
}))), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
13715
|
+
}))), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
13674
13716
|
kind: "tertiary",
|
|
13675
|
-
startIcon: plusCircle__default
|
|
13717
|
+
startIcon: plusCircle__default.default,
|
|
13676
13718
|
onClick: () => {
|
|
13677
13719
|
// Additional vertical offset for each label so
|
|
13678
13720
|
// they don't overlap.
|
|
@@ -13956,9 +13998,9 @@ const LockedPolygonSettings = props => {
|
|
|
13956
13998
|
// Only show the minus (delete) buttons if there are
|
|
13957
13999
|
// more than 3 points. 3 points is the minimum number
|
|
13958
14000
|
// of points for a polygon (triangle).
|
|
13959
|
-
points.length > 3 && /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
14001
|
+
points.length > 3 && /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
13960
14002
|
"aria-label": `Delete polygon point ${pointLabel}`,
|
|
13961
|
-
icon: minusCircle__default
|
|
14003
|
+
icon: minusCircle__default.default,
|
|
13962
14004
|
color: "destructive",
|
|
13963
14005
|
onClick: () => {
|
|
13964
14006
|
const newPoints = [...points];
|
|
@@ -13971,9 +14013,9 @@ const LockedPolygonSettings = props => {
|
|
|
13971
14013
|
}));
|
|
13972
14014
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
13973
14015
|
style: [styles$k.row, styles$k.polygonActionsContainer]
|
|
13974
|
-
}, /*#__PURE__*/React__namespace.createElement(Button__default
|
|
14016
|
+
}, /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
13975
14017
|
kind: "tertiary",
|
|
13976
|
-
startIcon: plusCircle__default
|
|
14018
|
+
startIcon: plusCircle__default.default,
|
|
13977
14019
|
onClick: () => {
|
|
13978
14020
|
props.onChangeProps({
|
|
13979
14021
|
points: [...points, [0, 0]]
|
|
@@ -13981,31 +14023,31 @@ const LockedPolygonSettings = props => {
|
|
|
13981
14023
|
}
|
|
13982
14024
|
}, "Add point"), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Spring, null), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
13983
14025
|
style: styles$k.movementButtonsContainer
|
|
13984
|
-
}, /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
14026
|
+
}, /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
13985
14027
|
"aria-label": "Move polygon up",
|
|
13986
14028
|
style: styles$k.iconButton,
|
|
13987
14029
|
size: "small",
|
|
13988
|
-
icon: arrowFatUp__default
|
|
14030
|
+
icon: arrowFatUp__default.default,
|
|
13989
14031
|
onClick: () => handlePolygonMove("up")
|
|
13990
14032
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
13991
14033
|
style: styles$k.row
|
|
13992
|
-
}, /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
14034
|
+
}, /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
13993
14035
|
"aria-label": "Move polygon left",
|
|
13994
14036
|
style: styles$k.iconButton,
|
|
13995
14037
|
size: "small",
|
|
13996
|
-
icon: arrowFatLeft__default
|
|
14038
|
+
icon: arrowFatLeft__default.default,
|
|
13997
14039
|
onClick: () => handlePolygonMove("left")
|
|
13998
|
-
}), /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
14040
|
+
}), /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
13999
14041
|
"aria-label": "Move polygon down",
|
|
14000
14042
|
style: styles$k.iconButton,
|
|
14001
14043
|
size: "small",
|
|
14002
|
-
icon: arrowFatDown__default
|
|
14044
|
+
icon: arrowFatDown__default.default,
|
|
14003
14045
|
onClick: () => handlePolygonMove("down")
|
|
14004
|
-
}), /*#__PURE__*/React__namespace.createElement(IconButton__default
|
|
14046
|
+
}), /*#__PURE__*/React__namespace.createElement(IconButton__default.default, {
|
|
14005
14047
|
"aria-label": "Move polygon right",
|
|
14006
14048
|
style: styles$k.iconButton,
|
|
14007
14049
|
size: "small",
|
|
14008
|
-
icon: arrowFatRight__default
|
|
14050
|
+
icon: arrowFatRight__default.default,
|
|
14009
14051
|
onClick: () => handlePolygonMove("right")
|
|
14010
14052
|
}))))), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
14011
14053
|
size: wonderBlocksTokens.spacing.small_12
|
|
@@ -14023,7 +14065,7 @@ const LockedPolygonSettings = props => {
|
|
|
14023
14065
|
style: styles$k.horizontalRule
|
|
14024
14066
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
14025
14067
|
size: wonderBlocksTokens.spacing.small_12
|
|
14026
|
-
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default
|
|
14068
|
+
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default.default({}, label, {
|
|
14027
14069
|
key: labelIndex,
|
|
14028
14070
|
expanded: true,
|
|
14029
14071
|
onChangeProps: newLabel => {
|
|
@@ -14033,9 +14075,9 @@ const LockedPolygonSettings = props => {
|
|
|
14033
14075
|
handleLabelRemove(labelIndex);
|
|
14034
14076
|
},
|
|
14035
14077
|
containerStyle: styles$k.labelContainer
|
|
14036
|
-
}))), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
14078
|
+
}))), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
14037
14079
|
kind: "tertiary",
|
|
14038
|
-
startIcon: plusCircle__default
|
|
14080
|
+
startIcon: plusCircle__default.default,
|
|
14039
14081
|
onClick: () => {
|
|
14040
14082
|
const newLabel = {
|
|
14041
14083
|
...getDefaultFigureForType("label"),
|
|
@@ -14252,7 +14294,7 @@ const LockedVectorSettings = props => {
|
|
|
14252
14294
|
style: styles$j.horizontalRule
|
|
14253
14295
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
14254
14296
|
size: wonderBlocksTokens.spacing.small_12
|
|
14255
|
-
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default
|
|
14297
|
+
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Visible labels"), labels?.map((label, labelIndex) => /*#__PURE__*/React__namespace.createElement(LockedLabelSettings, _extends__default.default({}, label, {
|
|
14256
14298
|
key: labelIndex,
|
|
14257
14299
|
expanded: true,
|
|
14258
14300
|
onChangeProps: newLabel => {
|
|
@@ -14262,9 +14304,9 @@ const LockedVectorSettings = props => {
|
|
|
14262
14304
|
handleLabelRemove(labelIndex);
|
|
14263
14305
|
},
|
|
14264
14306
|
containerStyle: styles$j.labelContainer
|
|
14265
|
-
}))), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
14307
|
+
}))), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
14266
14308
|
kind: "tertiary",
|
|
14267
|
-
startIcon: plusCircle__default
|
|
14309
|
+
startIcon: plusCircle__default.default,
|
|
14268
14310
|
onClick: () => {
|
|
14269
14311
|
// Additional vertical offset for each label so
|
|
14270
14312
|
// they don't overlap.
|
|
@@ -14325,6 +14367,7 @@ const styles$j = aphrodite.StyleSheet.create({
|
|
|
14325
14367
|
* Used in the interactive graph editor's locked figures section.
|
|
14326
14368
|
*/
|
|
14327
14369
|
|
|
14370
|
+
|
|
14328
14371
|
// Union this type with other locked figure types when they are added.
|
|
14329
14372
|
|
|
14330
14373
|
const LockedFigureSettings = props => {
|
|
@@ -14449,7 +14492,7 @@ const LockedFiguresSection = props => {
|
|
|
14449
14492
|
onToggle: () => setIsExpanded(!isExpanded),
|
|
14450
14493
|
isCollapsible: true
|
|
14451
14494
|
}), isExpanded && /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, null, figures?.map((figure, index) => {
|
|
14452
|
-
return /*#__PURE__*/React__namespace.createElement(LockedFigureSettings, _extends__default
|
|
14495
|
+
return /*#__PURE__*/React__namespace.createElement(LockedFigureSettings, _extends__default.default({
|
|
14453
14496
|
key: `${uniqueId}-locked-${figure}-${index}`,
|
|
14454
14497
|
expanded: expandedStates[index],
|
|
14455
14498
|
onToggle: newValue => {
|
|
@@ -14469,7 +14512,7 @@ const LockedFiguresSection = props => {
|
|
|
14469
14512
|
onChange: addLockedFigure
|
|
14470
14513
|
}), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
14471
14514
|
size: wonderBlocksTokens.spacing.small_12
|
|
14472
|
-
}), showExpandButton && /*#__PURE__*/React__namespace.createElement(Button__default
|
|
14515
|
+
}), showExpandButton && /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
14473
14516
|
kind: "secondary",
|
|
14474
14517
|
onClick: () => toggleExpanded(allCollapsed),
|
|
14475
14518
|
style: styles$i.button
|
|
@@ -15056,8 +15099,8 @@ const StartCoordsSettings = props => {
|
|
|
15056
15099
|
onToggle: () => setIsOpen(!isOpen)
|
|
15057
15100
|
}), isOpen && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(StartCoordsSettingsInner, props), /*#__PURE__*/React__namespace.createElement(wonderBlocksLayout.Strut, {
|
|
15058
15101
|
size: wonderBlocksTokens.spacing.small_12
|
|
15059
|
-
}), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
15060
|
-
startIcon: arrowCounterClockwise__default
|
|
15102
|
+
}), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
15103
|
+
startIcon: arrowCounterClockwise__default.default,
|
|
15061
15104
|
kind: "tertiary",
|
|
15062
15105
|
size: "small",
|
|
15063
15106
|
onClick: () => {
|
|
@@ -15070,7 +15113,7 @@ const {
|
|
|
15070
15113
|
InfoTip: InfoTip$b
|
|
15071
15114
|
} = perseus.components;
|
|
15072
15115
|
const InteractiveGraph = perseus.InteractiveGraphWidget.widget;
|
|
15073
|
-
const POLYGON_SIDES = ___default
|
|
15116
|
+
const POLYGON_SIDES = ___default.default.map(___default.default.range(3, 13), function (value) {
|
|
15074
15117
|
return /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.OptionItem, {
|
|
15075
15118
|
key: `polygon-sides-${value}`,
|
|
15076
15119
|
value: `${value}`,
|
|
@@ -15109,22 +15152,24 @@ class InteractiveGraphEditor extends React__namespace.Component {
|
|
|
15109
15152
|
// is copied from the question editor and pasted into the hint editor
|
|
15110
15153
|
// (double brackets in the markdown).
|
|
15111
15154
|
serialize() {
|
|
15112
|
-
const json = ___default
|
|
15155
|
+
const json = ___default.default.pick(this.props, "step", "backgroundImage", "markings", "labels", "labelLocation", "showProtractor", "showTooltips", "range", "gridStep", "snapStep", "lockedFigures", "fullGraphAriaLabel", "fullGraphAriaDescription");
|
|
15113
15156
|
|
|
15114
15157
|
// eslint-disable-next-line react/no-string-refs
|
|
15115
15158
|
const graph = this.refs.graph;
|
|
15159
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
15116
15160
|
if (graph) {
|
|
15117
15161
|
// @ts-expect-error TS2339 Property 'getUserInput' does not exist on type 'ReactInstance'. Property 'getUserInput' does not exist on type 'Component<any, {}, any>'.
|
|
15162
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
15118
15163
|
const correct = graph && graph.getUserInput();
|
|
15119
|
-
___default
|
|
15164
|
+
___default.default.extend(json, {
|
|
15120
15165
|
graph: {
|
|
15121
15166
|
type: correct.type,
|
|
15122
15167
|
startCoords: this.props.graph && getStartCoords(this.props.graph)
|
|
15123
15168
|
},
|
|
15124
15169
|
correct: correct
|
|
15125
15170
|
});
|
|
15126
|
-
___default
|
|
15127
|
-
if (___default
|
|
15171
|
+
___default.default.each(["allowReflexAngles", "angleOffsetDeg", "numPoints", "numSides", "numSegments", "showAngles", "showSides", "snapTo", "snapDegrees"], function (key) {
|
|
15172
|
+
if (___default.default.has(correct, key)) {
|
|
15128
15173
|
// @ts-expect-error - TS2339 - Property 'graph' does not exist on type 'Pick<any, "step" | "range" | "backgroundImage" | "snapStep" | "labels" | "showTooltips" | "markings" | "gridStep" | "showProtractor">'.
|
|
15129
15174
|
json.graph[key] = correct[key];
|
|
15130
15175
|
}
|
|
@@ -15152,8 +15197,12 @@ class InteractiveGraphEditor extends React__namespace.Component {
|
|
|
15152
15197
|
render() {
|
|
15153
15198
|
let graph;
|
|
15154
15199
|
let equationString;
|
|
15155
|
-
const gridStep =
|
|
15156
|
-
|
|
15200
|
+
const gridStep =
|
|
15201
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
15202
|
+
this.props.gridStep || perseus.Util.getGridStep(this.props.range, this.props.step, perseus.interactiveSizes.defaultBoxSize);
|
|
15203
|
+
const snapStep =
|
|
15204
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
15205
|
+
this.props.snapStep || perseus.Util.snapStepFromGridStep(gridStep);
|
|
15157
15206
|
const sizeClass = perseus.containerSizeClass.SMALL;
|
|
15158
15207
|
if (this.props.valid === true) {
|
|
15159
15208
|
const correct = this.props.correct;
|
|
@@ -15203,7 +15252,7 @@ class InteractiveGraphEditor extends React__namespace.Component {
|
|
|
15203
15252
|
// getWidgetProps() and widget-container.jsx that the editors don't
|
|
15204
15253
|
// bother passing.
|
|
15205
15254
|
// @ts-expect-error - TS2769 - No overload matches this call.
|
|
15206
|
-
React__namespace.createElement(InteractiveGraph, _extends__default
|
|
15255
|
+
React__namespace.createElement(InteractiveGraph, _extends__default.default({}, graphProps, {
|
|
15207
15256
|
containerSizeClass: sizeClass,
|
|
15208
15257
|
apiOptions: {
|
|
15209
15258
|
...this.props.apiOptions,
|
|
@@ -15308,7 +15357,9 @@ class InteractiveGraphEditor extends React__namespace.Component {
|
|
|
15308
15357
|
label: "Number of sides:"
|
|
15309
15358
|
}, /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.SingleSelect, {
|
|
15310
15359
|
key: "polygon-select",
|
|
15311
|
-
selectedValue:
|
|
15360
|
+
selectedValue:
|
|
15361
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
15362
|
+
this.props.correct?.numSides ? `${this.props.correct.numSides}` : "3",
|
|
15312
15363
|
placeholder: "",
|
|
15313
15364
|
onChange: newValue => {
|
|
15314
15365
|
invariant(this.props.graph?.type === "polygon");
|
|
@@ -15432,7 +15483,7 @@ class InteractiveGraphEditor extends React__namespace.Component {
|
|
|
15432
15483
|
}
|
|
15433
15484
|
});
|
|
15434
15485
|
}
|
|
15435
|
-
})), this.props.graph?.type && shouldShowStartCoordsUI(this.props.graph, this.props.static) && /*#__PURE__*/React__namespace.createElement(StartCoordsSettings, _extends__default
|
|
15486
|
+
})), this.props.graph?.type && shouldShowStartCoordsUI(this.props.graph, this.props.static) && /*#__PURE__*/React__namespace.createElement(StartCoordsSettings, _extends__default.default({}, this.props.graph, {
|
|
15436
15487
|
range: this.props.range,
|
|
15437
15488
|
step: this.props.step,
|
|
15438
15489
|
onChange: this.changeStartCoords
|
|
@@ -15676,12 +15727,18 @@ class FormWrappedTextField extends React__namespace.Component {
|
|
|
15676
15727
|
} = this.state;
|
|
15677
15728
|
const extraStyles = {};
|
|
15678
15729
|
const spanStyle = [styles$9.input, styles$9.container];
|
|
15730
|
+
|
|
15731
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
15679
15732
|
if (width) {
|
|
15680
15733
|
extraStyles.width = width;
|
|
15681
15734
|
}
|
|
15735
|
+
|
|
15736
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
15682
15737
|
if (grow) {
|
|
15683
15738
|
extraStyles.flexGrow = grow === true ? 1 : grow;
|
|
15684
15739
|
}
|
|
15740
|
+
|
|
15741
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
15685
15742
|
if (shrink || shrink === 0) {
|
|
15686
15743
|
extraStyles.flexShrink = shrink === true ? 0 : shrink;
|
|
15687
15744
|
}
|
|
@@ -15710,7 +15767,7 @@ class FormWrappedTextField extends React__namespace.Component {
|
|
|
15710
15767
|
// @ts-expect-error - TS2322 - Type '((arg1: ChangeEvent<HTMLInputElement>) => unknown) | ((e: Event) => void)' is not assignable to type 'FormEventHandler<HTMLFormElement> | undefined'.
|
|
15711
15768
|
,
|
|
15712
15769
|
onSubmit: onSubmit || this.disableDefault
|
|
15713
|
-
}, leftSideIcon && wrappedIcon, /*#__PURE__*/React__namespace.createElement("input", _extends__default
|
|
15770
|
+
}, leftSideIcon && wrappedIcon, /*#__PURE__*/React__namespace.createElement("input", _extends__default.default({}, allProps, {
|
|
15714
15771
|
onFocus: this.handleFocus,
|
|
15715
15772
|
onBlur: this.handleBlur,
|
|
15716
15773
|
type: type,
|
|
@@ -15777,7 +15834,7 @@ const styles$9 = aphrodite.StyleSheet.create({
|
|
|
15777
15834
|
justifyContent: "center"
|
|
15778
15835
|
}
|
|
15779
15836
|
});
|
|
15780
|
-
var FormWrappedTextField$1 = /*#__PURE__*/React__namespace.forwardRef((props, ref) => /*#__PURE__*/React__namespace.createElement(FormWrappedTextField, _extends__default
|
|
15837
|
+
var FormWrappedTextField$1 = /*#__PURE__*/React__namespace.forwardRef((props, ref) => /*#__PURE__*/React__namespace.createElement(FormWrappedTextField, _extends__default.default({}, props, {
|
|
15781
15838
|
forwardedRef: ref
|
|
15782
15839
|
})));
|
|
15783
15840
|
|
|
@@ -15890,6 +15947,7 @@ const styles$8 = aphrodite.StyleSheet.create({
|
|
|
15890
15947
|
/**
|
|
15891
15948
|
* Controlled list of answer choices, handles adding and removing answers.
|
|
15892
15949
|
*/
|
|
15950
|
+
|
|
15893
15951
|
const {
|
|
15894
15952
|
Icon: Icon$1
|
|
15895
15953
|
} = perseus.components;
|
|
@@ -16233,7 +16291,7 @@ class Checkbox extends React__namespace.Component {
|
|
|
16233
16291
|
let {
|
|
16234
16292
|
focused
|
|
16235
16293
|
} = _ref;
|
|
16236
|
-
return /*#__PURE__*/React__namespace.createElement("div", _extends__default
|
|
16294
|
+
return /*#__PURE__*/React__namespace.createElement("div", _extends__default.default({}, handlers, {
|
|
16237
16295
|
className: aphrodite.css(styles$6.container, focused && styles$6.focused),
|
|
16238
16296
|
style: style,
|
|
16239
16297
|
"data-testid": dataTestId,
|
|
@@ -16336,6 +16394,7 @@ const styles$6 = aphrodite.StyleSheet.create({
|
|
|
16336
16394
|
/**
|
|
16337
16395
|
* Controlled component to display and change widget options.
|
|
16338
16396
|
*/
|
|
16397
|
+
|
|
16339
16398
|
const Behavior = _ref => {
|
|
16340
16399
|
let {
|
|
16341
16400
|
multipleAnswers,
|
|
@@ -16448,13 +16507,20 @@ function focusWithChromeStickyFocusBugWorkaround(element) {
|
|
|
16448
16507
|
}
|
|
16449
16508
|
|
|
16450
16509
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
16510
|
+
/**
|
|
16511
|
+
* The Option is an item to be used in the Select components and the
|
|
16512
|
+
* derivations such as MultiSelect, CheckList, and CheckBoxList. Also includes
|
|
16513
|
+
* OptionGroup which is an internal component used in the dropdowns to house
|
|
16514
|
+
* a list of options.
|
|
16515
|
+
**/
|
|
16451
16516
|
const {
|
|
16452
16517
|
Icon
|
|
16453
16518
|
} = perseus.components;
|
|
16454
16519
|
const findAndFocusElement = component => {
|
|
16455
|
-
const DOMNode = ReactDOM__default
|
|
16520
|
+
const DOMNode = ReactDOM__default.default.findDOMNode(component);
|
|
16456
16521
|
const button = DOMNode;
|
|
16457
16522
|
// @ts-expect-error - TS2774 - This condition will always return true since this function is always defined. Did you mean to call it instead?
|
|
16523
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
16458
16524
|
if (button.focus) {
|
|
16459
16525
|
focusWithChromeStickyFocusBugWorkaround(button);
|
|
16460
16526
|
}
|
|
@@ -16540,6 +16606,7 @@ class OptionGroup extends React__namespace.Component {
|
|
|
16540
16606
|
// @ts-expect-error - TS2564 - Property 'focusedElement' has no initializer and is not definitely assigned in the constructor.
|
|
16541
16607
|
focusedElement;
|
|
16542
16608
|
componentDidMount() {
|
|
16609
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
16543
16610
|
if (this.focusedElement) {
|
|
16544
16611
|
findAndFocusElement(this.focusedElement);
|
|
16545
16612
|
}
|
|
@@ -16636,6 +16703,14 @@ const styles$4 = aphrodite.StyleSheet.create({
|
|
|
16636
16703
|
});
|
|
16637
16704
|
|
|
16638
16705
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
16706
|
+
/* eslint-disable react/no-unsafe */
|
|
16707
|
+
/**
|
|
16708
|
+
* Controlled editor image marker on the question image.
|
|
16709
|
+
*
|
|
16710
|
+
* Allows to select which label choices are the answers for each marker, using
|
|
16711
|
+
* the dropdown component.
|
|
16712
|
+
*/
|
|
16713
|
+
|
|
16639
16714
|
class Marker extends React__namespace.Component {
|
|
16640
16715
|
_marker;
|
|
16641
16716
|
constructor(props) {
|
|
@@ -16912,7 +16987,7 @@ class QuestionMarkers extends React__namespace.Component {
|
|
|
16912
16987
|
className: aphrodite.css(styles$2.image),
|
|
16913
16988
|
src: staticUrl(perseus.Util.getRealImageUrl(imageUrl)),
|
|
16914
16989
|
onDoubleClick: this.handleImageDoubleClick
|
|
16915
|
-
}), markers.map((marker, index) => /*#__PURE__*/React__namespace.createElement(Marker, _extends__default
|
|
16990
|
+
}), markers.map((marker, index) => /*#__PURE__*/React__namespace.createElement(Marker, _extends__default.default({}, marker, {
|
|
16916
16991
|
choices: choices,
|
|
16917
16992
|
key: `${marker.x}.${marker.y}`
|
|
16918
16993
|
// Update marker in the list.
|
|
@@ -16956,6 +17031,7 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
16956
17031
|
/**
|
|
16957
17032
|
* Controlled component for selecting the question image, for answer labeling.
|
|
16958
17033
|
*/
|
|
17034
|
+
|
|
16959
17035
|
const SelectImage = _ref => {
|
|
16960
17036
|
let {
|
|
16961
17037
|
onChange,
|
|
@@ -16972,7 +17048,7 @@ const SelectImage = _ref => {
|
|
|
16972
17048
|
value: url
|
|
16973
17049
|
}), /*#__PURE__*/React__namespace.createElement("div", {
|
|
16974
17050
|
className: aphrodite.css(styles$1.spacer)
|
|
16975
|
-
}), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
17051
|
+
}), /*#__PURE__*/React__namespace.createElement(Button__default.default
|
|
16976
17052
|
// TODO(michaelpolyak): Design calls for uploading an image from
|
|
16977
17053
|
// the widget. This functionality already exists in
|
|
16978
17054
|
// `perseus-one-package/item-controls.jsx`, it's not obvious if
|
|
@@ -17011,6 +17087,7 @@ const styles$1 = aphrodite.StyleSheet.create({
|
|
|
17011
17087
|
* that involve the use of images, and enable learners to demonstrate their
|
|
17012
17088
|
* knowledge by directly interacting with the image.
|
|
17013
17089
|
*/
|
|
17090
|
+
|
|
17014
17091
|
class LabelImageEditor extends React__namespace.Component {
|
|
17015
17092
|
_questionMarkers;
|
|
17016
17093
|
static defaultProps = perseusCore.labelImageLogic.defaultWidgetOptions;
|
|
@@ -17026,6 +17103,7 @@ class LabelImageEditor extends React__namespace.Component {
|
|
|
17026
17103
|
|
|
17027
17104
|
// Automatically reveal their dropdowns as a prompt to the content
|
|
17028
17105
|
// creator to select answers and set the ARIA label.
|
|
17106
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17029
17107
|
if (newIndices.length && this._questionMarkers) {
|
|
17030
17108
|
this._questionMarkers.openDropdownForMarkerIndices(newIndices);
|
|
17031
17109
|
}
|
|
@@ -17046,12 +17124,15 @@ class LabelImageEditor extends React__namespace.Component {
|
|
|
17046
17124
|
} else if (!imageAlt) {
|
|
17047
17125
|
warnings.push("Question image has no alt text");
|
|
17048
17126
|
}
|
|
17127
|
+
|
|
17128
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17049
17129
|
if (!markers.length) {
|
|
17050
17130
|
warnings.push("Question has no markers, to label answers on image");
|
|
17051
17131
|
} else {
|
|
17052
17132
|
let numNoAnswers = 0;
|
|
17053
17133
|
let numNoLabels = 0;
|
|
17054
17134
|
for (const marker of markers) {
|
|
17135
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17055
17136
|
if (!marker.answers.length) {
|
|
17056
17137
|
numNoAnswers++;
|
|
17057
17138
|
}
|
|
@@ -17059,9 +17140,13 @@ class LabelImageEditor extends React__namespace.Component {
|
|
|
17059
17140
|
numNoLabels++;
|
|
17060
17141
|
}
|
|
17061
17142
|
}
|
|
17143
|
+
|
|
17144
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17062
17145
|
if (numNoAnswers) {
|
|
17063
17146
|
warnings.push(`Question has ${numNoAnswers} markers with no ` + "answers selected");
|
|
17064
17147
|
}
|
|
17148
|
+
|
|
17149
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17065
17150
|
if (numNoLabels) {
|
|
17066
17151
|
warnings.push(`Question has ${numNoLabels} markers with no ` + "ARIA label");
|
|
17067
17152
|
}
|
|
@@ -17139,7 +17224,9 @@ class LabelImageEditor extends React__namespace.Component {
|
|
|
17139
17224
|
}), /*#__PURE__*/React__namespace.createElement("div", {
|
|
17140
17225
|
className: aphrodite.css(styles.largeSpacer)
|
|
17141
17226
|
}), /*#__PURE__*/React__namespace.createElement(QuestionMarkers, {
|
|
17142
|
-
choices: choices
|
|
17227
|
+
choices: choices
|
|
17228
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17229
|
+
,
|
|
17143
17230
|
imageUrl: imageSelected ? imageUrl : "",
|
|
17144
17231
|
imageWidth: imageWidth,
|
|
17145
17232
|
imageHeight: imageHeight,
|
|
@@ -17177,16 +17264,16 @@ const {
|
|
|
17177
17264
|
} = perseus.components;
|
|
17178
17265
|
class MatcherEditor extends React__namespace.Component {
|
|
17179
17266
|
static propTypes = {
|
|
17180
|
-
left: PropTypes__default
|
|
17181
|
-
right: PropTypes__default
|
|
17182
|
-
labels: PropTypes__default
|
|
17183
|
-
orderMatters: PropTypes__default
|
|
17184
|
-
padding: PropTypes__default
|
|
17267
|
+
left: PropTypes__default.default.array,
|
|
17268
|
+
right: PropTypes__default.default.array,
|
|
17269
|
+
labels: PropTypes__default.default.array,
|
|
17270
|
+
orderMatters: PropTypes__default.default.bool,
|
|
17271
|
+
padding: PropTypes__default.default.bool
|
|
17185
17272
|
};
|
|
17186
17273
|
static widgetName = "matcher";
|
|
17187
17274
|
static defaultProps = perseusCore.matcherLogic.defaultWidgetOptions;
|
|
17188
17275
|
onLabelChange = (index, e) => {
|
|
17189
|
-
const labels = ___default
|
|
17276
|
+
const labels = ___default.default.clone(this.props.labels);
|
|
17190
17277
|
labels[index] = e.target.value;
|
|
17191
17278
|
this.props.onChange({
|
|
17192
17279
|
labels: labels
|
|
@@ -17199,7 +17286,7 @@ class MatcherEditor extends React__namespace.Component {
|
|
|
17199
17286
|
return [];
|
|
17200
17287
|
};
|
|
17201
17288
|
serialize = () => {
|
|
17202
|
-
return ___default
|
|
17289
|
+
return ___default.default.pick(this.props, "left", "right", "labels", "orderMatters", "padding");
|
|
17203
17290
|
};
|
|
17204
17291
|
render() {
|
|
17205
17292
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -17265,11 +17352,11 @@ const MAX_BOARD_SIZE = 6;
|
|
|
17265
17352
|
class MatrixEditor extends React__namespace.Component {
|
|
17266
17353
|
static propTypes = {
|
|
17267
17354
|
...perseus.Changeable.propTypes,
|
|
17268
|
-
matrixBoardSize: PropTypes__default
|
|
17269
|
-
answers: PropTypes__default
|
|
17270
|
-
prefix: PropTypes__default
|
|
17271
|
-
suffix: PropTypes__default
|
|
17272
|
-
cursorPosition: PropTypes__default
|
|
17355
|
+
matrixBoardSize: PropTypes__default.default.arrayOf(PropTypes__default.default.number).isRequired,
|
|
17356
|
+
answers: PropTypes__default.default.arrayOf(PropTypes__default.default.arrayOf(PropTypes__default.default.number)),
|
|
17357
|
+
prefix: PropTypes__default.default.string,
|
|
17358
|
+
suffix: PropTypes__default.default.string,
|
|
17359
|
+
cursorPosition: PropTypes__default.default.arrayOf(PropTypes__default.default.number)
|
|
17273
17360
|
};
|
|
17274
17361
|
static widgetName = "matrix";
|
|
17275
17362
|
static defaultProps = perseusCore.matrixLogic.defaultWidgetOptions;
|
|
@@ -17286,8 +17373,8 @@ class MatrixEditor extends React__namespace.Component {
|
|
|
17286
17373
|
const matrixSize = perseusCore.getMatrixSize(this.props.answers);
|
|
17287
17374
|
if (range[0] !== null && range[1] !== null) {
|
|
17288
17375
|
range = [Math.round(Math.min(Math.max(range[0], 1), MAX_BOARD_SIZE)), Math.round(Math.min(Math.max(range[1], 1), MAX_BOARD_SIZE))];
|
|
17289
|
-
const answers = ___default
|
|
17290
|
-
return ___default
|
|
17376
|
+
const answers = ___default.default(Math.min(range[0], matrixSize[0])).times(row => {
|
|
17377
|
+
return ___default.default(Math.min(range[1], matrixSize[1])).times(col => {
|
|
17291
17378
|
return this.props.answers[row][col];
|
|
17292
17379
|
});
|
|
17293
17380
|
});
|
|
@@ -17301,7 +17388,7 @@ class MatrixEditor extends React__namespace.Component {
|
|
|
17301
17388
|
return perseus.EditorJsonify.serialize.call(this);
|
|
17302
17389
|
};
|
|
17303
17390
|
render() {
|
|
17304
|
-
const matrixProps = ___default
|
|
17391
|
+
const matrixProps = ___default.default.extend({
|
|
17305
17392
|
numericInput: true,
|
|
17306
17393
|
onBlur: () => {},
|
|
17307
17394
|
onFocus: () => {},
|
|
@@ -17367,18 +17454,18 @@ class MeasurerEditor extends React__namespace.Component {
|
|
|
17367
17454
|
static widgetName = "measurer";
|
|
17368
17455
|
static propTypes = {
|
|
17369
17456
|
...perseus.Changeable.propTypes,
|
|
17370
|
-
box: PropTypes__default
|
|
17371
|
-
image: PropTypes__default
|
|
17372
|
-
url: PropTypes__default
|
|
17373
|
-
top: PropTypes__default
|
|
17374
|
-
left: PropTypes__default
|
|
17457
|
+
box: PropTypes__default.default.arrayOf(PropTypes__default.default.number),
|
|
17458
|
+
image: PropTypes__default.default.shape({
|
|
17459
|
+
url: PropTypes__default.default.string,
|
|
17460
|
+
top: PropTypes__default.default.number,
|
|
17461
|
+
left: PropTypes__default.default.number
|
|
17375
17462
|
}),
|
|
17376
|
-
showProtractor: PropTypes__default
|
|
17377
|
-
showRuler: PropTypes__default
|
|
17378
|
-
rulerLabel: PropTypes__default
|
|
17379
|
-
rulerTicks: PropTypes__default
|
|
17380
|
-
rulerPixels: PropTypes__default
|
|
17381
|
-
rulerLength: PropTypes__default
|
|
17463
|
+
showProtractor: PropTypes__default.default.bool,
|
|
17464
|
+
showRuler: PropTypes__default.default.bool,
|
|
17465
|
+
rulerLabel: PropTypes__default.default.string,
|
|
17466
|
+
rulerTicks: PropTypes__default.default.number,
|
|
17467
|
+
rulerPixels: PropTypes__default.default.number,
|
|
17468
|
+
rulerLength: PropTypes__default.default.number
|
|
17382
17469
|
};
|
|
17383
17470
|
static defaultProps = perseusCore.measurerLogic.defaultWidgetOptions;
|
|
17384
17471
|
className = "perseus-widget-measurer";
|
|
@@ -17401,13 +17488,13 @@ class MeasurerEditor extends React__namespace.Component {
|
|
|
17401
17488
|
this._changeImage("left", newLeft);
|
|
17402
17489
|
};
|
|
17403
17490
|
_changeImage = (subProp, newValue) => {
|
|
17404
|
-
const image = ___default
|
|
17491
|
+
const image = ___default.default.clone(this.props.image);
|
|
17405
17492
|
image[subProp] = newValue;
|
|
17406
17493
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
|
|
17407
17494
|
this.change("image", image);
|
|
17408
17495
|
};
|
|
17409
17496
|
renderLabelChoices = choices => {
|
|
17410
|
-
return ___default
|
|
17497
|
+
return ___default.default.map(choices, function (nameAndValue) {
|
|
17411
17498
|
const [name, value] = nameAndValue;
|
|
17412
17499
|
return /*#__PURE__*/React__namespace.createElement("option", {
|
|
17413
17500
|
key: value,
|
|
@@ -17419,7 +17506,7 @@ class MeasurerEditor extends React__namespace.Component {
|
|
|
17419
17506
|
return perseus.EditorJsonify.serialize.call(this);
|
|
17420
17507
|
};
|
|
17421
17508
|
render() {
|
|
17422
|
-
const image = ___default
|
|
17509
|
+
const image = ___default.default.extend({}, defaultImage, this.props.image);
|
|
17423
17510
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
17424
17511
|
className: "perseus-widget-measurer"
|
|
17425
17512
|
}, /*#__PURE__*/React__namespace.createElement("div", null, "Image displayed under protractor and/or ruler:"), /*#__PURE__*/React__namespace.createElement("div", null, "URL:", " ", /*#__PURE__*/React__namespace.createElement("input", {
|
|
@@ -17490,7 +17577,7 @@ class MeasurerEditor extends React__namespace.Component {
|
|
|
17490
17577
|
// @ts-expect-error - TS2554 - Expected 3 arguments, but got 2.
|
|
17491
17578
|
this.change("rulerTicks", +e.target.value),
|
|
17492
17579
|
value: this.props.rulerTicks
|
|
17493
|
-
}, ___default
|
|
17580
|
+
}, ___default.default.map([1, 2, 4, 8, 10, 16], function (n) {
|
|
17494
17581
|
return /*#__PURE__*/React__namespace.createElement("option", {
|
|
17495
17582
|
key: n,
|
|
17496
17583
|
value: n
|
|
@@ -17520,8 +17607,8 @@ const {
|
|
|
17520
17607
|
class MoleculeWidgetEditor extends React__namespace.Component {
|
|
17521
17608
|
static propTypes = {
|
|
17522
17609
|
...perseus.Changeable.propTypes,
|
|
17523
|
-
rotationAngle: PropTypes__default
|
|
17524
|
-
smiles: PropTypes__default
|
|
17610
|
+
rotationAngle: PropTypes__default.default.number,
|
|
17611
|
+
smiles: PropTypes__default.default.string
|
|
17525
17612
|
};
|
|
17526
17613
|
static widgetName = "molecule-renderer";
|
|
17527
17614
|
change = (() => {
|
|
@@ -17613,12 +17700,13 @@ class NumberLineEditor extends React__namespace.Component {
|
|
|
17613
17700
|
const divRange = this.props.divisionRange.slice();
|
|
17614
17701
|
|
|
17615
17702
|
// Don't allow a fraction for the number of divisions
|
|
17616
|
-
numDivisions = ___default
|
|
17703
|
+
numDivisions = ___default.default.isFinite(numDivisions) ? Math.round(numDivisions) : 0;
|
|
17617
17704
|
|
|
17618
17705
|
// Don't allow negative numbers for the number of divisions
|
|
17619
17706
|
numDivisions = numDivisions < 0 ? numDivisions * -1 : numDivisions;
|
|
17620
17707
|
|
|
17621
17708
|
// If the number of divisions isn't blank, update the number line
|
|
17709
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17622
17710
|
if (numDivisions) {
|
|
17623
17711
|
// Constrain numDivisions to be within the allowed range
|
|
17624
17712
|
numDivisions = Math.min(divRange[1], Math.max(divRange[0], numDivisions));
|
|
@@ -17664,6 +17752,7 @@ class NumberLineEditor extends React__namespace.Component {
|
|
|
17664
17752
|
let step;
|
|
17665
17753
|
if (!isTickCtrl) {
|
|
17666
17754
|
// this will help constrain the answer to what is reachable
|
|
17755
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17667
17756
|
step = tickStep ? tickStep / snapDivisions : width / numDivisions / snapDivisions;
|
|
17668
17757
|
} else {
|
|
17669
17758
|
// but if tickCtrl is on, the range of what is reachable is
|
|
@@ -17803,7 +17892,9 @@ class NumberLineEditor extends React__namespace.Component {
|
|
|
17803
17892
|
}
|
|
17804
17893
|
})), /*#__PURE__*/React__namespace.createElement("div", {
|
|
17805
17894
|
className: "perseus-widget-row"
|
|
17806
|
-
}, isTickCtrl && /*#__PURE__*/React__namespace.createElement("span", null, /*#__PURE__*/React__namespace.createElement("label", null, "Start num divisions at", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$5
|
|
17895
|
+
}, isTickCtrl && /*#__PURE__*/React__namespace.createElement("span", null, /*#__PURE__*/React__namespace.createElement("label", null, "Start num divisions at", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$5
|
|
17896
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17897
|
+
, {
|
|
17807
17898
|
value: this.props.numDivisions || null,
|
|
17808
17899
|
format: "decimal",
|
|
17809
17900
|
onChange: this.onNumDivisionsChange,
|
|
@@ -17812,7 +17903,9 @@ class NumberLineEditor extends React__namespace.Component {
|
|
|
17812
17903
|
},
|
|
17813
17904
|
placeholder: width / this.props.tickStep,
|
|
17814
17905
|
useArrowKeys: true
|
|
17815
|
-
})), /*#__PURE__*/React__namespace.createElement(InfoTip$8, null, /*#__PURE__*/React__namespace.createElement("p", null, "This controls the number (and position) of the tick marks. The number of divisions is constrained to", " " + divisionRange[0] + EN_DASH + divisionRange[1], ".", /*#__PURE__*/React__namespace.createElement("br", null), /*#__PURE__*/React__namespace.createElement("strong", null, "Note:"), " The user will be able to specify the number of divisions in a number input."))), !isTickCtrl && /*#__PURE__*/React__namespace.createElement("span", null, /*#__PURE__*/React__namespace.createElement("label", null, "Num divisions:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$5
|
|
17906
|
+
})), /*#__PURE__*/React__namespace.createElement(InfoTip$8, null, /*#__PURE__*/React__namespace.createElement("p", null, "This controls the number (and position) of the tick marks. The number of divisions is constrained to", " " + divisionRange[0] + EN_DASH + divisionRange[1], ".", /*#__PURE__*/React__namespace.createElement("br", null), /*#__PURE__*/React__namespace.createElement("strong", null, "Note:"), " The user will be able to specify the number of divisions in a number input."))), !isTickCtrl && /*#__PURE__*/React__namespace.createElement("span", null, /*#__PURE__*/React__namespace.createElement("label", null, "Num divisions:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$5
|
|
17907
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17908
|
+
, {
|
|
17816
17909
|
value: this.props.numDivisions || null,
|
|
17817
17910
|
format: "decimal",
|
|
17818
17911
|
onChange: this.onNumDivisionsChange,
|
|
@@ -17821,7 +17914,9 @@ class NumberLineEditor extends React__namespace.Component {
|
|
|
17821
17914
|
},
|
|
17822
17915
|
placeholder: width / this.props.tickStep,
|
|
17823
17916
|
useArrowKeys: true
|
|
17824
|
-
})), " ", /*#__PURE__*/React__namespace.createElement("label", null, "or tick step:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$5
|
|
17917
|
+
})), " ", /*#__PURE__*/React__namespace.createElement("label", null, "or tick step:", " ", /*#__PURE__*/React__namespace.createElement(NumberInput$5
|
|
17918
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
17919
|
+
, {
|
|
17825
17920
|
value: this.props.tickStep || null,
|
|
17826
17921
|
format: this.props.labelStyle,
|
|
17827
17922
|
onChange: this.onTickStepChange,
|
|
@@ -17982,8 +18077,8 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
17982
18077
|
});
|
|
17983
18078
|
};
|
|
17984
18079
|
updateAnswer = (choiceIndex, update) => {
|
|
17985
|
-
if (!___default
|
|
17986
|
-
return ___default
|
|
18080
|
+
if (!___default.default.isObject(update)) {
|
|
18081
|
+
return ___default.default.partial((choiceIndex, key, value) => {
|
|
17987
18082
|
const update = {};
|
|
17988
18083
|
update[key] = value;
|
|
17989
18084
|
this.updateAnswer(choiceIndex, update);
|
|
@@ -18000,7 +18095,7 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18000
18095
|
const lastAnswer = initAnswer(this.state.lastStatus);
|
|
18001
18096
|
answers = answers.concat(lastAnswer);
|
|
18002
18097
|
}
|
|
18003
|
-
answers[choiceIndex] = ___default
|
|
18098
|
+
answers[choiceIndex] = ___default.default.extend({}, answers[choiceIndex], update);
|
|
18004
18099
|
this.props.onChange({
|
|
18005
18100
|
answers: answers
|
|
18006
18101
|
});
|
|
@@ -18021,7 +18116,7 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18021
18116
|
const warnings = [];
|
|
18022
18117
|
// TODO(emily): This doesn't actually work, because the value is either
|
|
18023
18118
|
// null or undefined when undefined, probably.
|
|
18024
|
-
if (___default
|
|
18119
|
+
if (___default.default.contains(___default.default.pluck(this.props.answers, "value"), "")) {
|
|
18025
18120
|
// @ts-expect-error - TS2345 - Argument of type 'string' is not assignable to parameter of type 'never'.
|
|
18026
18121
|
warnings.push("One or more answers is empty");
|
|
18027
18122
|
}
|
|
@@ -18062,7 +18157,7 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18062
18157
|
role: role,
|
|
18063
18158
|
onClick: onClick
|
|
18064
18159
|
};
|
|
18065
|
-
return /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
18160
|
+
return /*#__PURE__*/React__namespace.createElement(Pill__default.default, pillProps, children);
|
|
18066
18161
|
};
|
|
18067
18162
|
const RadioOption = props => {
|
|
18068
18163
|
const {
|
|
@@ -18134,12 +18229,12 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18134
18229
|
className: "perseus-widget-row"
|
|
18135
18230
|
}, /*#__PURE__*/React__namespace.createElement("legend", {
|
|
18136
18231
|
className: "inline-options"
|
|
18137
|
-
}, "Width: "), /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
18232
|
+
}, "Width: "), /*#__PURE__*/React__namespace.createElement(Pill__default.default, _extends__default.default({}, commonOptionProps, {
|
|
18138
18233
|
kind: this.props.size === "normal" ? "accent" : "transparent",
|
|
18139
18234
|
onClick: () => {
|
|
18140
18235
|
this.change("size")("normal");
|
|
18141
18236
|
}
|
|
18142
|
-
}), "Normal (80px)"), /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
18237
|
+
}), "Normal (80px)"), /*#__PURE__*/React__namespace.createElement(Pill__default.default, _extends__default.default({}, commonOptionProps, {
|
|
18143
18238
|
kind: this.props.size === "small" ? "accent" : "transparent",
|
|
18144
18239
|
onClick: () => {
|
|
18145
18240
|
this.change("size")("small");
|
|
@@ -18149,14 +18244,14 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18149
18244
|
className: "perseus-widget-row"
|
|
18150
18245
|
}, /*#__PURE__*/React__namespace.createElement("legend", {
|
|
18151
18246
|
className: "inline-options"
|
|
18152
|
-
}, "Alignment: "), /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
18247
|
+
}, "Alignment: "), /*#__PURE__*/React__namespace.createElement(Pill__default.default, _extends__default.default({}, commonOptionProps, {
|
|
18153
18248
|
kind: this.props.rightAlign ? "transparent" : "accent",
|
|
18154
18249
|
onClick: () => {
|
|
18155
18250
|
this.props.onChange({
|
|
18156
18251
|
rightAlign: false
|
|
18157
18252
|
});
|
|
18158
18253
|
}
|
|
18159
|
-
}), "Left"), /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
18254
|
+
}), "Left"), /*#__PURE__*/React__namespace.createElement(Pill__default.default, _extends__default.default({}, commonOptionProps, {
|
|
18160
18255
|
kind: this.props.rightAlign ? "accent" : "transparent",
|
|
18161
18256
|
onClick: () => {
|
|
18162
18257
|
this.props.onChange({
|
|
@@ -18175,14 +18270,14 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18175
18270
|
className: "perseus-widget-row"
|
|
18176
18271
|
}, /*#__PURE__*/React__namespace.createElement("legend", {
|
|
18177
18272
|
className: "inline-options"
|
|
18178
|
-
}, "Number style: "), /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
18273
|
+
}, "Number style: "), /*#__PURE__*/React__namespace.createElement(Pill__default.default, _extends__default.default({}, commonOptionProps, {
|
|
18179
18274
|
kind: this.props.coefficient ? "transparent" : "accent",
|
|
18180
18275
|
onClick: () => {
|
|
18181
18276
|
this.props.onChange({
|
|
18182
18277
|
coefficient: false
|
|
18183
18278
|
});
|
|
18184
18279
|
}
|
|
18185
|
-
}), "Standard"), /*#__PURE__*/React__namespace.createElement(Pill__default
|
|
18280
|
+
}), "Standard"), /*#__PURE__*/React__namespace.createElement(Pill__default.default, _extends__default.default({}, commonOptionProps, {
|
|
18186
18281
|
kind: this.props.coefficient ? "accent" : "transparent",
|
|
18187
18282
|
onClick: () => {
|
|
18188
18283
|
this.props.onChange({
|
|
@@ -18230,7 +18325,7 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18230
18325
|
value: answer.value,
|
|
18231
18326
|
className: "numeric-input-value",
|
|
18232
18327
|
placeholder: "answer",
|
|
18233
|
-
format: ___default
|
|
18328
|
+
format: ___default.default.last(answer.answerForms || []),
|
|
18234
18329
|
onFormatChange: (newValue, format) => {
|
|
18235
18330
|
// NOTE(charlie): The mobile web expression
|
|
18236
18331
|
// editor relies on this automatic answer
|
|
@@ -18269,7 +18364,7 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18269
18364
|
className: "max-error-input-value",
|
|
18270
18365
|
placeholder: 0,
|
|
18271
18366
|
value: answers[i]["maxError"],
|
|
18272
|
-
format: ___default
|
|
18367
|
+
format: ___default.default.last(answer.answerForms || []),
|
|
18273
18368
|
onChange: this.updateAnswer(i, "maxError")
|
|
18274
18369
|
})), /*#__PURE__*/React__namespace.createElement("fieldset", {
|
|
18275
18370
|
className: "perseus-widget-row"
|
|
@@ -18298,8 +18393,8 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18298
18393
|
}
|
|
18299
18394
|
}, "Ungraded")), unsimplifiedAnswers(i), /*#__PURE__*/React__namespace.createElement("div", {
|
|
18300
18395
|
className: "perseus-widget-row"
|
|
18301
|
-
}, "(Articles only) Message shown to user:"), editor, suggestedAnswerTypes(i), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
18302
|
-
startIcon: trashIcon__default
|
|
18396
|
+
}, "(Articles only) Message shown to user:"), editor, suggestedAnswerTypes(i), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
18397
|
+
startIcon: trashIcon__default.default,
|
|
18303
18398
|
"aria-label": `Delete ${answerHeading}`,
|
|
18304
18399
|
className: "delete-item-button",
|
|
18305
18400
|
onClick: () => {
|
|
@@ -18328,7 +18423,7 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18328
18423
|
className: `perseus-editor-accordion-container ${this.state.showAnswers ? "expanded" : "collapsed"}`
|
|
18329
18424
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
18330
18425
|
className: "perseus-editor-accordion-content"
|
|
18331
|
-
}, generateInputAnswerEditors(), /*#__PURE__*/React__namespace.createElement(Button__default
|
|
18426
|
+
}, generateInputAnswerEditors(), /*#__PURE__*/React__namespace.createElement(Button__default.default, {
|
|
18332
18427
|
kind: "tertiary",
|
|
18333
18428
|
onClick: this.addAnswer
|
|
18334
18429
|
}, "Add new answer"))));
|
|
@@ -18336,6 +18431,7 @@ class NumericInputEditor extends React__namespace.Component {
|
|
|
18336
18431
|
}
|
|
18337
18432
|
|
|
18338
18433
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
18434
|
+
/* eslint-disable react/forbid-prop-types */
|
|
18339
18435
|
const {
|
|
18340
18436
|
InfoTip: InfoTip$6,
|
|
18341
18437
|
TextListEditor: TextListEditor$2
|
|
@@ -18346,17 +18442,17 @@ const HORIZONTAL$1 = "horizontal";
|
|
|
18346
18442
|
const VERTICAL$1 = "vertical";
|
|
18347
18443
|
class OrdererEditor extends React__namespace.Component {
|
|
18348
18444
|
static propTypes = {
|
|
18349
|
-
correctOptions: PropTypes__default
|
|
18350
|
-
otherOptions: PropTypes__default
|
|
18351
|
-
height: PropTypes__default
|
|
18352
|
-
layout: PropTypes__default
|
|
18353
|
-
onChange: PropTypes__default
|
|
18445
|
+
correctOptions: PropTypes__default.default.array,
|
|
18446
|
+
otherOptions: PropTypes__default.default.array,
|
|
18447
|
+
height: PropTypes__default.default.oneOf([NORMAL, AUTO]),
|
|
18448
|
+
layout: PropTypes__default.default.oneOf([HORIZONTAL$1, VERTICAL$1]),
|
|
18449
|
+
onChange: PropTypes__default.default.func.isRequired
|
|
18354
18450
|
};
|
|
18355
18451
|
static widgetName = "orderer";
|
|
18356
18452
|
static defaultProps = perseusCore.ordererLogic.defaultWidgetOptions;
|
|
18357
18453
|
onOptionsChange = (whichOptions, options, cb) => {
|
|
18358
18454
|
const props = {};
|
|
18359
|
-
props[whichOptions] = ___default
|
|
18455
|
+
props[whichOptions] = ___default.default.map(options, function (option) {
|
|
18360
18456
|
return {
|
|
18361
18457
|
content: option
|
|
18362
18458
|
};
|
|
@@ -18377,7 +18473,7 @@ class OrdererEditor extends React__namespace.Component {
|
|
|
18377
18473
|
// We combine the correct answer and the other cards by merging them,
|
|
18378
18474
|
// removing duplicates and empty cards, and sorting them into
|
|
18379
18475
|
// categories based on their content
|
|
18380
|
-
const options = ___default
|
|
18476
|
+
const options = ___default.default.chain(___default.default.pluck(this.props.correctOptions, "content")).union(___default.default.pluck(this.props.otherOptions, "content")).uniq().reject(function (content) {
|
|
18381
18477
|
return content === "";
|
|
18382
18478
|
}).sort().sortBy(function (content) {
|
|
18383
18479
|
if (/\d/.test(content)) {
|
|
@@ -18404,13 +18500,13 @@ class OrdererEditor extends React__namespace.Component {
|
|
|
18404
18500
|
return /*#__PURE__*/React__namespace.createElement("div", {
|
|
18405
18501
|
className: "perseus-widget-orderer"
|
|
18406
18502
|
}, /*#__PURE__*/React__namespace.createElement("div", null, " ", "Correct answer:", " ", /*#__PURE__*/React__namespace.createElement(InfoTip$6, null, /*#__PURE__*/React__namespace.createElement("p", null, "Place the cards in the correct order. The same card can be used more than once in the answer but will only be displayed once at the top of a stack of identical cards."))), /*#__PURE__*/React__namespace.createElement(TextListEditor$2, {
|
|
18407
|
-
options: ___default
|
|
18503
|
+
options: ___default.default.pluck(this.props.correctOptions, "content")
|
|
18408
18504
|
// eslint-disable-next-line react/jsx-no-bind
|
|
18409
18505
|
,
|
|
18410
18506
|
onChange: this.onOptionsChange.bind(this, "correctOptions"),
|
|
18411
18507
|
layout: this.props.layout
|
|
18412
18508
|
}), /*#__PURE__*/React__namespace.createElement("div", null, " ", "Other cards:", " ", /*#__PURE__*/React__namespace.createElement(InfoTip$6, null, /*#__PURE__*/React__namespace.createElement("p", null, "Create cards that are not part of the answer."))), /*#__PURE__*/React__namespace.createElement(TextListEditor$2, {
|
|
18413
|
-
options: ___default
|
|
18509
|
+
options: ___default.default.pluck(this.props.otherOptions, "content")
|
|
18414
18510
|
// eslint-disable-next-line react/jsx-no-bind
|
|
18415
18511
|
,
|
|
18416
18512
|
onChange: this.onOptionsChange.bind(this, "otherOptions"),
|
|
@@ -18443,10 +18539,10 @@ const {
|
|
|
18443
18539
|
class PassageEditor extends React__namespace.Component {
|
|
18444
18540
|
static propTypes = {
|
|
18445
18541
|
...perseus.Changeable.propTypes,
|
|
18446
|
-
passageTitle: PropTypes__default
|
|
18447
|
-
passageText: PropTypes__default
|
|
18448
|
-
footnotes: PropTypes__default
|
|
18449
|
-
showLineNumbers: PropTypes__default
|
|
18542
|
+
passageTitle: PropTypes__default.default.string,
|
|
18543
|
+
passageText: PropTypes__default.default.string,
|
|
18544
|
+
footnotes: PropTypes__default.default.string,
|
|
18545
|
+
showLineNumbers: PropTypes__default.default.bool
|
|
18450
18546
|
};
|
|
18451
18547
|
static widgetName = "passage";
|
|
18452
18548
|
static defaultProps = perseusCore.passageLogic.defaultWidgetOptions;
|
|
@@ -18528,9 +18624,9 @@ const {
|
|
|
18528
18624
|
class PassageRefEditor extends React__namespace.Component {
|
|
18529
18625
|
static propTypes = {
|
|
18530
18626
|
...perseus.Changeable.propTypes,
|
|
18531
|
-
passageNumber: PropTypes__default
|
|
18532
|
-
referenceNumber: PropTypes__default
|
|
18533
|
-
summaryText: PropTypes__default
|
|
18627
|
+
passageNumber: PropTypes__default.default.number,
|
|
18628
|
+
referenceNumber: PropTypes__default.default.number,
|
|
18629
|
+
summaryText: PropTypes__default.default.string
|
|
18534
18630
|
};
|
|
18535
18631
|
static widgetName = "passage-ref";
|
|
18536
18632
|
static defaultProps = perseusCore.passageRefLogic.defaultWidgetOptions;
|
|
@@ -18569,7 +18665,7 @@ class PassageRefEditor extends React__namespace.Component {
|
|
|
18569
18665
|
class PassageRefTargetEditor extends React__namespace.Component {
|
|
18570
18666
|
static propTypes = {
|
|
18571
18667
|
...perseus.Changeable.propTypes,
|
|
18572
|
-
content: PropTypes__default
|
|
18668
|
+
content: PropTypes__default.default.string
|
|
18573
18669
|
};
|
|
18574
18670
|
static widgetName = "passage-ref-target";
|
|
18575
18671
|
static defaultProps = perseusCore.passageRefTargetLogic.defaultWidgetOptions;
|
|
@@ -18648,7 +18744,7 @@ const CORRECT = "correct";
|
|
|
18648
18744
|
const editingStates = [STARTING, CORRECT];
|
|
18649
18745
|
// Return a copy of array with length n, padded with given value
|
|
18650
18746
|
function padArray(array, n, value) {
|
|
18651
|
-
const copy = ___default
|
|
18747
|
+
const copy = ___default.default.clone(array);
|
|
18652
18748
|
copy.length = n;
|
|
18653
18749
|
for (let i = array.length; i < n; i++) {
|
|
18654
18750
|
copy[i] = value;
|
|
@@ -18742,13 +18838,13 @@ class PlotterEditor extends React__namespace.Component {
|
|
|
18742
18838
|
}
|
|
18743
18839
|
if (categories) {
|
|
18744
18840
|
// eslint-disable-next-line react/no-string-refs
|
|
18745
|
-
const node = ReactDOM__default
|
|
18841
|
+
const node = ReactDOM__default.default.findDOMNode(this.refs.categories);
|
|
18746
18842
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
18747
18843
|
node.value = categories.join(", ");
|
|
18748
18844
|
}
|
|
18749
18845
|
};
|
|
18750
18846
|
changeLabel = (i, e) => {
|
|
18751
|
-
const labels = ___default
|
|
18847
|
+
const labels = ___default.default.clone(this.props.labels);
|
|
18752
18848
|
labels[i] = e.target.value;
|
|
18753
18849
|
this.props.onChange({
|
|
18754
18850
|
labels: labels
|
|
@@ -18778,6 +18874,7 @@ class PlotterEditor extends React__namespace.Component {
|
|
|
18778
18874
|
};
|
|
18779
18875
|
changeScale = e => {
|
|
18780
18876
|
const oldScale = this.props.scaleY;
|
|
18877
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
18781
18878
|
const newScale = +e.target.value || editorDefaults.scaleY;
|
|
18782
18879
|
const scale = function (value) {
|
|
18783
18880
|
return value * newScale / oldScale;
|
|
@@ -18786,20 +18883,22 @@ class PlotterEditor extends React__namespace.Component {
|
|
|
18786
18883
|
this.props.onChange({
|
|
18787
18884
|
scaleY: newScale,
|
|
18788
18885
|
maxY: maxY,
|
|
18789
|
-
correct: ___default
|
|
18790
|
-
starting: ___default
|
|
18886
|
+
correct: ___default.default.map(this.props.correct, scale),
|
|
18887
|
+
starting: ___default.default.map(this.props.starting, scale)
|
|
18791
18888
|
});
|
|
18792
18889
|
|
|
18793
18890
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
18794
|
-
ReactDOM__default
|
|
18891
|
+
ReactDOM__default.default.findDOMNode(this.refs.maxY).value = maxY; // eslint-disable-line react/no-string-refs
|
|
18795
18892
|
};
|
|
18796
18893
|
changeMax = e => {
|
|
18797
18894
|
this.props.onChange({
|
|
18895
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
18798
18896
|
maxY: +e.target.value || editorDefaults.maxY
|
|
18799
18897
|
});
|
|
18800
18898
|
};
|
|
18801
18899
|
changeSnaps = e => {
|
|
18802
18900
|
this.props.onChange({
|
|
18901
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
18803
18902
|
snapsPerLine: +e.target.value || editorDefaults.snapsPerLine
|
|
18804
18903
|
});
|
|
18805
18904
|
};
|
|
@@ -18816,22 +18915,22 @@ class PlotterEditor extends React__namespace.Component {
|
|
|
18816
18915
|
let categories;
|
|
18817
18916
|
if (this.props.type === "histogram" || this.props.type === "dotplot") {
|
|
18818
18917
|
// Ranges for histogram and dotplot labels should start at zero
|
|
18819
|
-
categories = ___default
|
|
18918
|
+
categories = ___default.default.range(0, length + scale, scale);
|
|
18820
18919
|
} else {
|
|
18821
|
-
categories = ___default
|
|
18920
|
+
categories = ___default.default.range(scale, length + scale, scale);
|
|
18822
18921
|
}
|
|
18823
|
-
categories = ___default
|
|
18824
|
-
categories = ___default
|
|
18922
|
+
categories = ___default.default.map(categories, num => num + min);
|
|
18923
|
+
categories = ___default.default.map(categories, formatNumber);
|
|
18825
18924
|
this.changeCategories(categories);
|
|
18826
18925
|
|
|
18827
18926
|
// eslint-disable-next-line react/no-string-refs
|
|
18828
|
-
const node = ReactDOM__default
|
|
18927
|
+
const node = ReactDOM__default.default.findDOMNode(this.refs.categories);
|
|
18829
18928
|
|
|
18830
18929
|
// @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'value' does not exist on type 'Element | Text'.
|
|
18831
18930
|
node.value = categories.join(", ");
|
|
18832
18931
|
};
|
|
18833
18932
|
serialize = () => {
|
|
18834
|
-
const json = ___default
|
|
18933
|
+
const json = ___default.default.pick(this.props, "correct", "starting", "type", "labels", "categories", "scaleY", "maxY", "snapsPerLine", "labelInterval");
|
|
18835
18934
|
if (this.props.type === "pic") {
|
|
18836
18935
|
// @ts-expect-error - TS2339 - Property 'picUrl' does not exist on type 'Pick<Readonly<any> & Readonly<{ children?: ReactNode; }>, "type" | "correct" | "labels" | "categories" | "starting" | "scaleY" | "maxY" | "snapsPerLine" | "labelInterval">'.
|
|
18837
18936
|
json.picUrl = this.props.picUrl;
|
|
@@ -18839,8 +18938,8 @@ class PlotterEditor extends React__namespace.Component {
|
|
|
18839
18938
|
return json;
|
|
18840
18939
|
};
|
|
18841
18940
|
render() {
|
|
18842
|
-
const setFromScale = ___default
|
|
18843
|
-
const canChangeSnaps = !___default
|
|
18941
|
+
const setFromScale = ___default.default.contains(["line", "histogram", "dotplot"], this.props.type);
|
|
18942
|
+
const canChangeSnaps = !___default.default.contains(["pic", "dotplot"], this.props.type);
|
|
18844
18943
|
const props = {
|
|
18845
18944
|
trackInteraction: () => {},
|
|
18846
18945
|
...this.props
|
|
@@ -18854,14 +18953,14 @@ class PlotterEditor extends React__namespace.Component {
|
|
|
18854
18953
|
type: "radio",
|
|
18855
18954
|
name: "chart-type",
|
|
18856
18955
|
checked: this.props.type === type,
|
|
18857
|
-
onChange: ___default
|
|
18956
|
+
onChange: ___default.default.partial(this.changeType, type)
|
|
18858
18957
|
}), type);
|
|
18859
18958
|
}, this)), /*#__PURE__*/React__namespace.createElement("div", null, "Labels:", " ", ["x", "y"].map((axis, i) => {
|
|
18860
18959
|
return /*#__PURE__*/React__namespace.createElement("label", {
|
|
18861
18960
|
key: axis
|
|
18862
18961
|
}, axis + ":", /*#__PURE__*/React__namespace.createElement("input", {
|
|
18863
18962
|
type: "text",
|
|
18864
|
-
onChange: ___default
|
|
18963
|
+
onChange: ___default.default.partial(this.changeLabel, i),
|
|
18865
18964
|
defaultValue: this.props.labels[i]
|
|
18866
18965
|
}));
|
|
18867
18966
|
}, this)), setFromScale && /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -18919,7 +19018,7 @@ class PlotterEditor extends React__namespace.Component {
|
|
|
18919
19018
|
disabled: editing === CORRECT && this.props.static,
|
|
18920
19019
|
checked: this.props.static ? editing === STARTING : this.state.editing === editing,
|
|
18921
19020
|
onChange: e => this.changeEditing(editing)
|
|
18922
|
-
}), editing)), /*#__PURE__*/React__namespace.createElement(InfoTip$3, null, /*#__PURE__*/React__namespace.createElement("p", null, "Use this toggle to switch between editing the correct answer (what the student will be graded on) and the starting values (what the student will see plotted when they start the problem). Note: These cannot be the same."), /*#__PURE__*/React__namespace.createElement("p", null, "In static mode, the starting values are rendered out to the displayed widget."))), /*#__PURE__*/React__namespace.createElement(Plotter, _extends__default
|
|
19021
|
+
}), editing)), /*#__PURE__*/React__namespace.createElement(InfoTip$3, null, /*#__PURE__*/React__namespace.createElement("p", null, "Use this toggle to switch between editing the correct answer (what the student will be graded on) and the starting values (what the student will see plotted when they start the problem). Note: These cannot be the same."), /*#__PURE__*/React__namespace.createElement("p", null, "In static mode, the starting values are rendered out to the displayed widget."))), /*#__PURE__*/React__namespace.createElement(Plotter, _extends__default.default({}, props, {
|
|
18923
19022
|
starting: this.props[this.state.editing],
|
|
18924
19023
|
onChange: this.handlePlotterChange
|
|
18925
19024
|
})));
|
|
@@ -19048,12 +19147,12 @@ class RadioEditor extends React__namespace.Component {
|
|
|
19048
19147
|
})();
|
|
19049
19148
|
onMultipleSelectChange = allowMultiple => {
|
|
19050
19149
|
allowMultiple = allowMultiple.multipleSelect;
|
|
19051
|
-
const numCorrect = ___default
|
|
19150
|
+
const numCorrect = ___default.default.reduce(this.props.choices, function (memo, choice) {
|
|
19052
19151
|
return choice.correct ? memo + 1 : memo;
|
|
19053
19152
|
}, 0);
|
|
19054
19153
|
if (!allowMultiple && numCorrect > 1) {
|
|
19055
|
-
const choices = ___default
|
|
19056
|
-
return ___default
|
|
19154
|
+
const choices = ___default.default.map(this.props.choices, function (choice) {
|
|
19155
|
+
return ___default.default.defaults({
|
|
19057
19156
|
correct: false
|
|
19058
19157
|
}, choice);
|
|
19059
19158
|
});
|
|
@@ -19097,7 +19196,7 @@ class RadioEditor extends React__namespace.Component {
|
|
|
19097
19196
|
};
|
|
19098
19197
|
onContentChange = (choiceIndex, newContent) => {
|
|
19099
19198
|
const choices = this.props.choices.slice();
|
|
19100
|
-
choices[choiceIndex] = ___default
|
|
19199
|
+
choices[choiceIndex] = ___default.default.extend({}, choices[choiceIndex], {
|
|
19101
19200
|
content: newContent
|
|
19102
19201
|
});
|
|
19103
19202
|
this.props.onChange({
|
|
@@ -19106,7 +19205,7 @@ class RadioEditor extends React__namespace.Component {
|
|
|
19106
19205
|
};
|
|
19107
19206
|
onClueChange(choiceIndex, newClue) {
|
|
19108
19207
|
const choices = this.props.choices.slice();
|
|
19109
|
-
choices[choiceIndex] = ___default
|
|
19208
|
+
choices[choiceIndex] = ___default.default.extend({}, choices[choiceIndex], {
|
|
19110
19209
|
clue: newClue
|
|
19111
19210
|
});
|
|
19112
19211
|
if (newClue === "") {
|
|
@@ -19155,7 +19254,7 @@ class RadioEditor extends React__namespace.Component {
|
|
|
19155
19254
|
return true;
|
|
19156
19255
|
};
|
|
19157
19256
|
getSaveWarnings = () => {
|
|
19158
|
-
if (!___default
|
|
19257
|
+
if (!___default.default.some(___default.default.pluck(this.props.choices, "correct"))) {
|
|
19159
19258
|
return ["No choice is marked as correct."];
|
|
19160
19259
|
}
|
|
19161
19260
|
return [];
|
|
@@ -19187,7 +19286,7 @@ class RadioEditor extends React__namespace.Component {
|
|
|
19187
19286
|
};
|
|
19188
19287
|
}
|
|
19189
19288
|
render() {
|
|
19190
|
-
const numCorrect = ___default
|
|
19289
|
+
const numCorrect = ___default.default.reduce(this.props.choices, function (memo, choice) {
|
|
19191
19290
|
return choice.correct ? memo + 1 : memo;
|
|
19192
19291
|
}, 0);
|
|
19193
19292
|
return /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -19279,6 +19378,7 @@ class RadioEditor extends React__namespace.Component {
|
|
|
19279
19378
|
}
|
|
19280
19379
|
|
|
19281
19380
|
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
19381
|
+
/* eslint-disable react/forbid-prop-types */
|
|
19282
19382
|
const {
|
|
19283
19383
|
InfoTip: InfoTip$2,
|
|
19284
19384
|
TextListEditor
|
|
@@ -19287,9 +19387,9 @@ const HORIZONTAL = "horizontal";
|
|
|
19287
19387
|
const VERTICAL = "vertical";
|
|
19288
19388
|
class SorterEditor extends React__namespace.Component {
|
|
19289
19389
|
static propTypes = {
|
|
19290
|
-
correct: PropTypes__default
|
|
19291
|
-
layout: PropTypes__default
|
|
19292
|
-
padding: PropTypes__default
|
|
19390
|
+
correct: PropTypes__default.default.array,
|
|
19391
|
+
layout: PropTypes__default.default.oneOf([HORIZONTAL, VERTICAL]),
|
|
19392
|
+
padding: PropTypes__default.default.bool
|
|
19293
19393
|
};
|
|
19294
19394
|
static widgetName = "sorter";
|
|
19295
19395
|
static defaultProps = perseusCore.sorterLogic.defaultWidgetOptions;
|
|
@@ -19299,7 +19399,7 @@ class SorterEditor extends React__namespace.Component {
|
|
|
19299
19399
|
});
|
|
19300
19400
|
};
|
|
19301
19401
|
serialize = () => {
|
|
19302
|
-
return ___default
|
|
19402
|
+
return ___default.default.pick(this.props, "correct", "layout", "padding");
|
|
19303
19403
|
};
|
|
19304
19404
|
render() {
|
|
19305
19405
|
const editor = this;
|
|
@@ -19341,10 +19441,10 @@ const {
|
|
|
19341
19441
|
const Table = perseus.TableWidget.widget;
|
|
19342
19442
|
class TableEditor extends React__namespace.Component {
|
|
19343
19443
|
static propTypes = {
|
|
19344
|
-
rows: PropTypes__default
|
|
19345
|
-
columns: PropTypes__default
|
|
19346
|
-
headers: PropTypes__default
|
|
19347
|
-
answers: PropTypes__default
|
|
19444
|
+
rows: PropTypes__default.default.number,
|
|
19445
|
+
columns: PropTypes__default.default.number,
|
|
19446
|
+
headers: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
19447
|
+
answers: PropTypes__default.default.arrayOf(PropTypes__default.default.arrayOf(PropTypes__default.default.string))
|
|
19348
19448
|
};
|
|
19349
19449
|
static widgetName = "table";
|
|
19350
19450
|
static defaultProps = perseusCore.tableLogic.defaultWidgetOptions;
|
|
@@ -19353,7 +19453,9 @@ class TableEditor extends React__namespace.Component {
|
|
|
19353
19453
|
this.numberOfColumns.current?.focus();
|
|
19354
19454
|
};
|
|
19355
19455
|
onSizeInput = (numRawRows, numRawColumns) => {
|
|
19456
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
19356
19457
|
let rows = +numRawRows || 0;
|
|
19458
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
19357
19459
|
let columns = +numRawColumns || 0;
|
|
19358
19460
|
rows = Math.min(Math.max(1, rows), 30);
|
|
19359
19461
|
columns = Math.min(Math.max(1, columns), 6);
|
|
@@ -19364,7 +19466,7 @@ class TableEditor extends React__namespace.Component {
|
|
|
19364
19466
|
if (rows <= oldRows) {
|
|
19365
19467
|
answers.length = rows;
|
|
19366
19468
|
} else {
|
|
19367
|
-
___default
|
|
19469
|
+
___default.default(rows - oldRows).times(function () {
|
|
19368
19470
|
answers.push(perseus.Util.stringArrayOfSize(oldColumns));
|
|
19369
19471
|
});
|
|
19370
19472
|
}
|
|
@@ -19373,14 +19475,14 @@ class TableEditor extends React__namespace.Component {
|
|
|
19373
19475
|
if (columns <= oldColumns) {
|
|
19374
19476
|
array.length = columns;
|
|
19375
19477
|
} else {
|
|
19376
|
-
___default
|
|
19478
|
+
___default.default(columns - oldColumns).times(function () {
|
|
19377
19479
|
array.push("");
|
|
19378
19480
|
});
|
|
19379
19481
|
}
|
|
19380
19482
|
}
|
|
19381
19483
|
const headers = this.props.headers;
|
|
19382
19484
|
fixColumnSizing(headers);
|
|
19383
|
-
___default
|
|
19485
|
+
___default.default.each(answers, fixColumnSizing);
|
|
19384
19486
|
this.props.onChange({
|
|
19385
19487
|
rows: rows,
|
|
19386
19488
|
columns: columns,
|
|
@@ -19389,9 +19491,9 @@ class TableEditor extends React__namespace.Component {
|
|
|
19389
19491
|
});
|
|
19390
19492
|
};
|
|
19391
19493
|
serialize = () => {
|
|
19392
|
-
const json = ___default
|
|
19393
|
-
return ___default
|
|
19394
|
-
answers: ___default
|
|
19494
|
+
const json = ___default.default.pick(this.props, "headers", "rows", "columns");
|
|
19495
|
+
return ___default.default.extend({}, json, {
|
|
19496
|
+
answers: ___default.default.map(this.props.answers, ___default.default.clone)
|
|
19395
19497
|
});
|
|
19396
19498
|
};
|
|
19397
19499
|
render() {
|
|
@@ -19455,8 +19557,8 @@ function getSlugFromUrl(url) {
|
|
|
19455
19557
|
class VideoEditor extends React__namespace.Component {
|
|
19456
19558
|
static propTypes = {
|
|
19457
19559
|
...perseus.Changeable.propTypes,
|
|
19458
|
-
location: PropTypes__default
|
|
19459
|
-
onChange: PropTypes__default
|
|
19560
|
+
location: PropTypes__default.default.string,
|
|
19561
|
+
onChange: PropTypes__default.default.func
|
|
19460
19562
|
};
|
|
19461
19563
|
static widgetName = "video";
|
|
19462
19564
|
static defaultProps = perseusCore.videoLogic.defaultWidgetOptions;
|
|
@@ -19495,7 +19597,7 @@ perseus.Widgets.registerWidgets(perseus.widgets);
|
|
|
19495
19597
|
perseus.Widgets.replaceDeprecatedWidgets();
|
|
19496
19598
|
perseus.Widgets.replaceDeprecatedEditors();
|
|
19497
19599
|
|
|
19498
|
-
Object.defineProperty(exports,
|
|
19600
|
+
Object.defineProperty(exports, "widgets", {
|
|
19499
19601
|
enumerable: true,
|
|
19500
19602
|
get: function () { return perseus.widgets; }
|
|
19501
19603
|
});
|