@khanacademy/perseus 31.0.1 → 31.1.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.css +1 -1
- package/dist/es/index.js +123 -93
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +101 -63
- package/dist/index.js.map +1 -1
- package/dist/widgets/interactive-graphs/graphs/components/movable-point-view.d.ts +8 -4
- package/dist/widgets/interactive-graphs/graphs/components/movable-point.d.ts +2 -1
- package/dist/widgets/interactive-graphs/reducer/interactive-graph-action.d.ts +8 -1
- package/dist/widgets/phet-simulation.d.ts +2 -2
- package/package.json +45 -45
package/dist/es/index.css
CHANGED
|
@@ -4440,7 +4440,7 @@ html body .mq-editable-field .mq-selection .mq-nthroot-container * {
|
|
|
4440
4440
|
}
|
|
4441
4441
|
|
|
4442
4442
|
.MafsView
|
|
4443
|
-
.movable-point:is(:focus
|
|
4443
|
+
.movable-point:is(:focus, .movable-point--focus)
|
|
4444
4444
|
.movable-point-focus-outline {
|
|
4445
4445
|
visibility: visible;
|
|
4446
4446
|
}
|
package/dist/es/index.js
CHANGED
|
@@ -45,31 +45,23 @@ import cornersOutIcon from '@phosphor-icons/core/regular/corners-out.svg';
|
|
|
45
45
|
import Link from '@khanacademy/wonder-blocks-link';
|
|
46
46
|
|
|
47
47
|
function _extends() {
|
|
48
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
49
|
-
for (var
|
|
50
|
-
var
|
|
51
|
-
for (var
|
|
52
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
53
|
-
target[key] = source[key];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
48
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
49
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
50
|
+
var t = arguments[e];
|
|
51
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
56
52
|
}
|
|
57
|
-
return
|
|
58
|
-
};
|
|
59
|
-
return _extends.apply(this, arguments);
|
|
53
|
+
return n;
|
|
54
|
+
}, _extends.apply(null, arguments);
|
|
60
55
|
}
|
|
61
56
|
|
|
62
|
-
function _objectWithoutPropertiesLoose(
|
|
63
|
-
if (
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
key = sourceKeys[i];
|
|
69
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
70
|
-
target[key] = source[key];
|
|
57
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
58
|
+
if (null == r) return {};
|
|
59
|
+
var t = {};
|
|
60
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
61
|
+
if (e.includes(n)) continue;
|
|
62
|
+
t[n] = r[n];
|
|
71
63
|
}
|
|
72
|
-
return
|
|
64
|
+
return t;
|
|
73
65
|
}
|
|
74
66
|
|
|
75
67
|
/**
|
|
@@ -532,6 +524,7 @@ class InnerMathInput extends React.Component {
|
|
|
532
524
|
onFocus: () => this.focus(),
|
|
533
525
|
onBlur: () => this.blur()
|
|
534
526
|
}), /*#__PURE__*/React.createElement(Popover, {
|
|
527
|
+
rootBoundary: "document",
|
|
535
528
|
opened: this.state.keypadOpen,
|
|
536
529
|
onClose: () => this.closeKeypad(),
|
|
537
530
|
dismissEnabled: true,
|
|
@@ -4515,16 +4508,14 @@ const InteractiveUtil = {
|
|
|
4515
4508
|
}
|
|
4516
4509
|
};
|
|
4517
4510
|
|
|
4518
|
-
function _classPrivateFieldBase(
|
|
4519
|
-
if (!
|
|
4520
|
-
|
|
4521
|
-
}
|
|
4522
|
-
return receiver;
|
|
4511
|
+
function _classPrivateFieldBase(e, t) {
|
|
4512
|
+
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance");
|
|
4513
|
+
return e;
|
|
4523
4514
|
}
|
|
4524
4515
|
|
|
4525
4516
|
var id = 0;
|
|
4526
|
-
function _classPrivateFieldKey(
|
|
4527
|
-
return "__private_" + id++ + "_" +
|
|
4517
|
+
function _classPrivateFieldKey(e) {
|
|
4518
|
+
return "__private_" + id++ + "_" + e;
|
|
4528
4519
|
}
|
|
4529
4520
|
|
|
4530
4521
|
/*!
|
|
@@ -30234,7 +30225,8 @@ const actions = {
|
|
|
30234
30225
|
},
|
|
30235
30226
|
pointGraph: {
|
|
30236
30227
|
movePoint,
|
|
30237
|
-
addPoint
|
|
30228
|
+
addPoint,
|
|
30229
|
+
removePoint
|
|
30238
30230
|
},
|
|
30239
30231
|
polygon: {
|
|
30240
30232
|
movePoint,
|
|
@@ -30270,6 +30262,13 @@ function addPoint(location) {
|
|
|
30270
30262
|
location
|
|
30271
30263
|
};
|
|
30272
30264
|
}
|
|
30265
|
+
const REMOVE_POINT = "remove-point";
|
|
30266
|
+
function removePoint(index) {
|
|
30267
|
+
return {
|
|
30268
|
+
type: REMOVE_POINT,
|
|
30269
|
+
index
|
|
30270
|
+
};
|
|
30271
|
+
}
|
|
30273
30272
|
const MOVE_ALL = "move-all";
|
|
30274
30273
|
function moveAll(delta) {
|
|
30275
30274
|
return {
|
|
@@ -30557,7 +30556,8 @@ const MovablePointView = /*#__PURE__*/forwardRef((props, hitboxRef) => {
|
|
|
30557
30556
|
color: color$1 = color.blue,
|
|
30558
30557
|
dragging,
|
|
30559
30558
|
focusBehavior,
|
|
30560
|
-
cursor
|
|
30559
|
+
cursor,
|
|
30560
|
+
onClick = () => {}
|
|
30561
30561
|
} = props;
|
|
30562
30562
|
|
|
30563
30563
|
// WB Tooltip requires a color name for the background color.
|
|
@@ -30592,7 +30592,12 @@ const MovablePointView = /*#__PURE__*/forwardRef((props, hitboxRef) => {
|
|
|
30592
30592
|
cursor
|
|
30593
30593
|
},
|
|
30594
30594
|
"data-testid": "movable-point",
|
|
30595
|
-
tabIndex: disableKeyboardInteraction ? -1 : tabIndex(focusBehavior)
|
|
30595
|
+
tabIndex: disableKeyboardInteraction ? -1 : tabIndex(focusBehavior),
|
|
30596
|
+
onFocus: () => {
|
|
30597
|
+
return getOnFocusChangeCallback(focusBehavior)(true);
|
|
30598
|
+
},
|
|
30599
|
+
onBlur: () => getOnFocusChangeCallback(focusBehavior)(false),
|
|
30600
|
+
onClick: onClick
|
|
30596
30601
|
}, /*#__PURE__*/React.createElement("circle", {
|
|
30597
30602
|
className: "movable-point-hitbox",
|
|
30598
30603
|
r: hitboxSizePx / 2,
|
|
@@ -30640,6 +30645,12 @@ function tabIndex(config) {
|
|
|
30640
30645
|
}
|
|
30641
30646
|
return undefined;
|
|
30642
30647
|
}
|
|
30648
|
+
function getOnFocusChangeCallback(config) {
|
|
30649
|
+
if (config.type === "uncontrolled") {
|
|
30650
|
+
return config.onFocusChange;
|
|
30651
|
+
}
|
|
30652
|
+
return () => {};
|
|
30653
|
+
}
|
|
30643
30654
|
|
|
30644
30655
|
const MovableLine = props => {
|
|
30645
30656
|
const {
|
|
@@ -31229,7 +31240,8 @@ const MovablePoint$1 = props => {
|
|
|
31229
31240
|
const elementRef = useRef(null);
|
|
31230
31241
|
const {
|
|
31231
31242
|
point,
|
|
31232
|
-
onMove,
|
|
31243
|
+
onMove = () => {},
|
|
31244
|
+
onFocusChange = () => {},
|
|
31233
31245
|
cursor,
|
|
31234
31246
|
color: color$1 = color.blue,
|
|
31235
31247
|
constrain = p => snap(snapStep, p)
|
|
@@ -31249,7 +31261,12 @@ const MovablePoint$1 = props => {
|
|
|
31249
31261
|
dragging: dragging,
|
|
31250
31262
|
focusBehavior: {
|
|
31251
31263
|
type: "uncontrolled",
|
|
31252
|
-
tabIndex: 0
|
|
31264
|
+
tabIndex: 0,
|
|
31265
|
+
onFocusChange
|
|
31266
|
+
},
|
|
31267
|
+
onClick: () => {
|
|
31268
|
+
var _elementRef$current;
|
|
31269
|
+
return (_elementRef$current = elementRef.current) == null ? void 0 : _elementRef$current.focus();
|
|
31253
31270
|
},
|
|
31254
31271
|
cursor: cursor
|
|
31255
31272
|
});
|
|
@@ -32465,6 +32482,8 @@ function interactiveGraphReducer(state, action) {
|
|
|
32465
32482
|
return doChangeRange(state, action);
|
|
32466
32483
|
case ADD_POINT:
|
|
32467
32484
|
return doAddPoint(state, action);
|
|
32485
|
+
case REMOVE_POINT:
|
|
32486
|
+
return doRemovePoint(state, action);
|
|
32468
32487
|
default:
|
|
32469
32488
|
throw new UnreachableCaseError(action);
|
|
32470
32489
|
}
|
|
@@ -32812,6 +32831,14 @@ function doAddPoint(state, action) {
|
|
|
32812
32831
|
coords: [...state.coords, snappedPoint]
|
|
32813
32832
|
});
|
|
32814
32833
|
}
|
|
32834
|
+
function doRemovePoint(state, action) {
|
|
32835
|
+
if (state.type !== "point") {
|
|
32836
|
+
return state;
|
|
32837
|
+
}
|
|
32838
|
+
return _extends({}, state, {
|
|
32839
|
+
coords: state.coords.filter((_, i) => i !== action.index)
|
|
32840
|
+
});
|
|
32841
|
+
}
|
|
32815
32842
|
const getDeltaVertex = (maxMoves, minMoves, delta) => {
|
|
32816
32843
|
const [deltaX, deltaY] = delta;
|
|
32817
32844
|
const maxXMove = Math.min(...maxMoves.map(move => move[X]));
|
|
@@ -42950,7 +42977,10 @@ var PassageRefTarget$1 = {
|
|
|
42950
42977
|
isLintable: true
|
|
42951
42978
|
};
|
|
42952
42979
|
|
|
42953
|
-
|
|
42980
|
+
/**
|
|
42981
|
+
* This is a PhET simulation widget. It is used for rendering simulations
|
|
42982
|
+
* from https://phet.colorado.edu/.
|
|
42983
|
+
*/
|
|
42954
42984
|
|
|
42955
42985
|
// For returning user input, but currently the PhET widget
|
|
42956
42986
|
// does not support accessing user input
|
|
@@ -43001,9 +43031,6 @@ class PhetSimulation extends React.Component {
|
|
|
43001
43031
|
};
|
|
43002
43032
|
this.locale = this.getPhetCompatibleLocale(getDependencies().kaLocale);
|
|
43003
43033
|
}
|
|
43004
|
-
getUserInput() {
|
|
43005
|
-
return null;
|
|
43006
|
-
}
|
|
43007
43034
|
async componentDidMount() {
|
|
43008
43035
|
await this.updateSimState(this.props.url);
|
|
43009
43036
|
}
|
|
@@ -43013,53 +43040,8 @@ class PhetSimulation extends React.Component {
|
|
|
43013
43040
|
await this.updateSimState(this.props.url);
|
|
43014
43041
|
}
|
|
43015
43042
|
}
|
|
43016
|
-
|
|
43017
|
-
|
|
43018
|
-
// We sandbox the iframe so that we allowlist only the functionality
|
|
43019
|
-
// that we need. This makes it safer to present third-party content
|
|
43020
|
-
// from the PhET website.
|
|
43021
|
-
// http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
|
|
43022
|
-
const sandboxProperties = "allow-same-origin allow-scripts";
|
|
43023
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
43024
|
-
style: styles$6.container
|
|
43025
|
-
}, this.state.banner !== null &&
|
|
43026
|
-
/*#__PURE__*/
|
|
43027
|
-
// TODO(anna): Make this banner focusable
|
|
43028
|
-
React.createElement(View, {
|
|
43029
|
-
style: {
|
|
43030
|
-
marginBottom: phoneMargin
|
|
43031
|
-
}
|
|
43032
|
-
}, /*#__PURE__*/React.createElement(Banner, {
|
|
43033
|
-
layout: "floating",
|
|
43034
|
-
kind: this.state.banner.kind,
|
|
43035
|
-
text: this.state.banner.message
|
|
43036
|
-
})), /*#__PURE__*/React.createElement("iframe", {
|
|
43037
|
-
ref: this.iframeRef,
|
|
43038
|
-
title: this.props.description,
|
|
43039
|
-
sandbox: sandboxProperties,
|
|
43040
|
-
style: {
|
|
43041
|
-
minWidth: 400,
|
|
43042
|
-
height: 360,
|
|
43043
|
-
width: "100%",
|
|
43044
|
-
borderWidth: 0
|
|
43045
|
-
},
|
|
43046
|
-
src: (_this$state$url = this.state.url) == null ? void 0 : _this$state$url.toString(),
|
|
43047
|
-
allow: "fullscreen"
|
|
43048
|
-
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
43049
|
-
icon: cornersOutIcon,
|
|
43050
|
-
onClick: () => {
|
|
43051
|
-
var _this$iframeRef$curre;
|
|
43052
|
-
(_this$iframeRef$curre = this.iframeRef.current) == null || _this$iframeRef$curre.requestFullscreen();
|
|
43053
|
-
},
|
|
43054
|
-
kind: "secondary",
|
|
43055
|
-
"aria-label": "Fullscreen",
|
|
43056
|
-
style: {
|
|
43057
|
-
marginTop: 5,
|
|
43058
|
-
marginBottom: 5,
|
|
43059
|
-
alignSelf: "flex-end"
|
|
43060
|
-
},
|
|
43061
|
-
disabled: this.state.url === null
|
|
43062
|
-
}));
|
|
43043
|
+
getUserInput() {
|
|
43044
|
+
return null;
|
|
43063
43045
|
}
|
|
43064
43046
|
async updateSimState(urlString) {
|
|
43065
43047
|
const url = makeSafeUrl(urlString, this.locale);
|
|
@@ -43117,6 +43099,54 @@ class PhetSimulation extends React.Component {
|
|
|
43117
43099
|
}
|
|
43118
43100
|
return true;
|
|
43119
43101
|
}
|
|
43102
|
+
render() {
|
|
43103
|
+
var _this$state$url;
|
|
43104
|
+
// We sandbox the iframe so that we allowlist only the functionality
|
|
43105
|
+
// that we need. This makes it safer to present third-party content
|
|
43106
|
+
// from the PhET website.
|
|
43107
|
+
// http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
|
|
43108
|
+
const sandboxProperties = "allow-same-origin allow-scripts";
|
|
43109
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
43110
|
+
style: styles$6.container
|
|
43111
|
+
}, this.state.banner !== null &&
|
|
43112
|
+
/*#__PURE__*/
|
|
43113
|
+
// TODO(anna): Make this banner focusable
|
|
43114
|
+
React.createElement(View, {
|
|
43115
|
+
style: {
|
|
43116
|
+
marginBottom: phoneMargin
|
|
43117
|
+
}
|
|
43118
|
+
}, /*#__PURE__*/React.createElement(Banner, {
|
|
43119
|
+
layout: "floating",
|
|
43120
|
+
kind: this.state.banner.kind,
|
|
43121
|
+
text: this.state.banner.message
|
|
43122
|
+
})), /*#__PURE__*/React.createElement("iframe", {
|
|
43123
|
+
ref: this.iframeRef,
|
|
43124
|
+
title: this.props.description,
|
|
43125
|
+
sandbox: sandboxProperties,
|
|
43126
|
+
style: {
|
|
43127
|
+
minWidth: 400,
|
|
43128
|
+
height: 360,
|
|
43129
|
+
width: "100%",
|
|
43130
|
+
borderWidth: 0
|
|
43131
|
+
},
|
|
43132
|
+
src: (_this$state$url = this.state.url) == null ? void 0 : _this$state$url.toString(),
|
|
43133
|
+
allow: "fullscreen"
|
|
43134
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
43135
|
+
icon: cornersOutIcon,
|
|
43136
|
+
onClick: () => {
|
|
43137
|
+
var _this$iframeRef$curre;
|
|
43138
|
+
(_this$iframeRef$curre = this.iframeRef.current) == null || _this$iframeRef$curre.requestFullscreen();
|
|
43139
|
+
},
|
|
43140
|
+
kind: "secondary",
|
|
43141
|
+
"aria-label": "Fullscreen",
|
|
43142
|
+
style: {
|
|
43143
|
+
marginTop: 5,
|
|
43144
|
+
marginBottom: 5,
|
|
43145
|
+
alignSelf: "flex-end"
|
|
43146
|
+
},
|
|
43147
|
+
disabled: this.state.url === null
|
|
43148
|
+
}));
|
|
43149
|
+
}
|
|
43120
43150
|
}
|
|
43121
43151
|
|
|
43122
43152
|
// Setting URL to null will display an error message in the iframe
|
|
@@ -43132,14 +43162,6 @@ const makeSafeUrl = (urlString, locale) => {
|
|
|
43132
43162
|
url.searchParams.set("locale", locale);
|
|
43133
43163
|
return url;
|
|
43134
43164
|
};
|
|
43135
|
-
var PhetSimulation$1 = {
|
|
43136
|
-
name: "phet-simulation",
|
|
43137
|
-
displayName: "PhET Simulation",
|
|
43138
|
-
widget: PhetSimulation,
|
|
43139
|
-
// Hides widget from content creators until full release
|
|
43140
|
-
hidden: true,
|
|
43141
|
-
isLintable: true
|
|
43142
|
-
};
|
|
43143
43165
|
const styles$6 = StyleSheet.create({
|
|
43144
43166
|
container: {
|
|
43145
43167
|
borderRadius: borderRadiusLarge,
|
|
@@ -43150,6 +43172,14 @@ const styles$6 = StyleSheet.create({
|
|
|
43150
43172
|
width: 650
|
|
43151
43173
|
}
|
|
43152
43174
|
});
|
|
43175
|
+
var PhetSimulation$1 = {
|
|
43176
|
+
name: "phet-simulation",
|
|
43177
|
+
displayName: "PhET Simulation",
|
|
43178
|
+
widget: PhetSimulation,
|
|
43179
|
+
// Hides widget from content creators until full release
|
|
43180
|
+
hidden: true,
|
|
43181
|
+
isLintable: true
|
|
43182
|
+
};
|
|
43153
43183
|
|
|
43154
43184
|
/* eslint-disable react/no-unsafe */
|
|
43155
43185
|
const {
|
|
@@ -44655,7 +44685,7 @@ const init = function init(options) {
|
|
|
44655
44685
|
|
|
44656
44686
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44657
44687
|
const libName = "@khanacademy/perseus";
|
|
44658
|
-
const libVersion = "31.0
|
|
44688
|
+
const libVersion = "31.1.0";
|
|
44659
44689
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44660
44690
|
|
|
44661
44691
|
const apiVersion = {
|